Qt/QML App for Friendiqa
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

friendiqa.cpp 3.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // This file is part of Friendiqa
  2. // https://github.com/lubuwest/Friendiqa
  3. // Copyright (C) 2017 Marco R. <thomasschmidt45@gmx.net>
  4. //
  5. // This program is free software: you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation, either version 3 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // In addition, as a special exception, the copyright holders give
  11. // permission to link the code of portions of this program with the
  12. // OpenSSL library under certain conditions as described in each
  13. // individual source file, and distribute linked combinations including
  14. // the two.
  15. //
  16. // You must obey the GNU General Public License in all respects for all
  17. // of the code used other than OpenSSL. If you modify file(s) with this
  18. // exception, you may extend this exception to your version of the
  19. // file(s), but you are not obligated to do so. If you do not wish to do
  20. // so, delete this exception statement from your version. If you delete
  21. // this exception statement from all source files in the program, then
  22. // also delete it here.
  23. //
  24. // This program is distributed in the hope that it will be useful,
  25. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. // GNU General Public License for more details.
  28. //
  29. // You should have received a copy of the GNU General Public License
  30. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  31. #include <QApplication>
  32. #include <QtQml/QQmlEngine>
  33. #include <QAndroidService>
  34. #include <QtAndroid>
  35. #include <QtQuick>
  36. #include "xhr.h"
  37. #include "updatenews.h"
  38. #include "filesystem.h"
  39. #include "remoteauthasyncimageprovider.h"
  40. #include "alarm.h"
  41. #include "AndroidNative/systemdispatcher.h"
  42. #include "AndroidNative/environment.h"
  43. //#include "AndroidNative/debug.h"
  44. #include "AndroidNative/mediascannerconnection.h"
  45. #ifdef Q_OS_ANDROID
  46. #include <QtAndroidExtras/QAndroidJniObject>
  47. #include <QtAndroidExtras/QAndroidJniEnvironment>
  48. JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void*) {
  49. Q_UNUSED(vm);
  50. qDebug("NativeInterface::JNI_OnLoad()"); // It must call this function within JNI_OnLoad to enable System Dispatcher
  51. AndroidNative::SystemDispatcher::registerNatives();
  52. return JNI_VERSION_1_6;
  53. }
  54. #endif
  55. int main(int argc, char *argv[]) {
  56. //qDebug()<< "argv Friendiqa"<< argv[0] <<" argv2" <<argv[1];
  57. if (qstrcmp(argv[1],"-service")==0){
  58. //qDebug()<<"FriendiqaMain Service";
  59. QAndroidService app(argc, argv);
  60. UPDATENEWS* updatenews= UPDATENEWS::instance();
  61. updatenews->setDatabase();
  62. updatenews->login();
  63. updatenews->timeline();
  64. app.connect (updatenews,SIGNAL(quitapp()),&app,SLOT(quit()));
  65. //QtAndroid::androidService().callMethod<void>("stopSelf");
  66. return app.exec();
  67. }
  68. else{
  69. QApplication app(argc, argv);
  70. QQuickView view;
  71. QTranslator qtTranslator;
  72. qtTranslator.load("friendiqa-" + QLocale::system().name(),":/translations");
  73. app.installTranslator(&qtTranslator);
  74. RemoteAuthAsyncImageProvider *imageProvider = new RemoteAuthAsyncImageProvider;
  75. view.engine()->addImageProvider("remoteauthimage",imageProvider);
  76. view.rootContext()->setContextProperty("remoteauth", imageProvider);
  77. XHR* xhr = XHR::instance();
  78. view.rootContext()->setContextProperty("xhr", xhr);
  79. FILESYSTEM* filesystem = FILESYSTEM::instance();
  80. view.rootContext()->setContextProperty("filesystem", filesystem);
  81. ALARM* alarm = ALARM::instance();
  82. view.rootContext()->setContextProperty("alarm", alarm);
  83. // UPDATENEWS* updatenews = UPDATENEWS::instance();
  84. // view.rootContext()->setContextProperty("updatenews", updatenews);
  85. view.setSource(QUrl("qrc:/qml/friendiqa.qml"));
  86. view.show();
  87. view.connect(view.rootContext()->engine(), SIGNAL(quit()), &app, SLOT(quit()));
  88. return app.exec();
  89. }
  90. }