mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-08 06:32:55 -04:00
Implement notifications on Android
Notify when there are unread messages
This commit is contained in:
parent
d540900df5
commit
5be6094214
10 changed files with 120 additions and 17 deletions
83
retroshare-android-notify-service/src/main.cpp
Normal file
83
retroshare-android-notify-service/src/main.cpp
Normal file
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* RetroShare Android Service
|
||||
* Copyright (C) 2016 Gioacchino Mazzurco <gio@eigenlab.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QQmlContext>
|
||||
#include <QFileInfo>
|
||||
#include <QDebug>
|
||||
|
||||
#ifdef __ANDROID__
|
||||
# include "util/androiddebug.h"
|
||||
#endif
|
||||
|
||||
#include "libresapilocalclient.h"
|
||||
#include "notificationsbridge.h"
|
||||
|
||||
#include "retroshare/rsinit.h"
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#ifdef __ANDROID__
|
||||
AndroidStdIOCatcher dbg; (void) dbg;
|
||||
#endif
|
||||
|
||||
QCoreApplication app(argc, argv);
|
||||
|
||||
QString sockPath = QString::fromStdString(RsAccounts::ConfigDirectory());
|
||||
sockPath.append("/libresapi.sock");
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
|
||||
qmlRegisterType<NotificationsBridge>(
|
||||
"org.retroshare.qml_components.NotificationsBridge", 1, 0,
|
||||
"NotificationsBridge");
|
||||
NotificationsBridge notificationsBridge;
|
||||
engine.rootContext()->setContextProperty("notificationsBridge",
|
||||
¬ificationsBridge);
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
engine.rootContext()->setContextProperty("QT_DEBUG", true);
|
||||
#else
|
||||
engine.rootContext()->setContextProperty("QT_DEBUG", false);
|
||||
#endif // QT_DEBUG
|
||||
|
||||
engine.rootContext()->setContextProperty("apiSocketPath", sockPath);
|
||||
|
||||
LibresapiLocalClient rsApi;
|
||||
|
||||
while (!QFileInfo::exists(sockPath))
|
||||
{
|
||||
qDebug() << "RetroShareAndroidNotifyService waiting for core to"
|
||||
<< "listen on:" << sockPath;
|
||||
|
||||
usleep(2500000);
|
||||
}
|
||||
|
||||
rsApi.openConnection(sockPath);
|
||||
|
||||
qmlRegisterType<LibresapiLocalClient>(
|
||||
"org.retroshare.qml_components.LibresapiLocalClient", 1, 0,
|
||||
"LibresapiLocalClient");
|
||||
engine.rootContext()->setContextProperty("rsApi", &rsApi);
|
||||
|
||||
engine.load(QUrl(QLatin1String("qrc:/main.qml")));
|
||||
|
||||
return app.exec();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue