Compare commits
4 commits
master
...
stay-awake
Author | SHA1 | Date | |
---|---|---|---|
|
f9fee1c312 | ||
|
c771f395da | ||
|
ce8047028d | ||
|
af2a4b0be7 |
23 changed files with 545 additions and 12 deletions
|
@ -34,6 +34,8 @@ SOURCES += src/harbour-fernschreiber.cpp \
|
||||||
src/namedaction.cpp \
|
src/namedaction.cpp \
|
||||||
src/notificationmanager.cpp \
|
src/notificationmanager.cpp \
|
||||||
src/processlauncher.cpp \
|
src/processlauncher.cpp \
|
||||||
|
src/stayawakeadaptor.cpp \
|
||||||
|
src/stayawakeinterface.cpp \
|
||||||
src/stickermanager.cpp \
|
src/stickermanager.cpp \
|
||||||
src/tdlibfile.cpp \
|
src/tdlibfile.cpp \
|
||||||
src/tdlibreceiver.cpp \
|
src/tdlibreceiver.cpp \
|
||||||
|
@ -163,6 +165,8 @@ HEADERS += \
|
||||||
src/namedaction.h \
|
src/namedaction.h \
|
||||||
src/notificationmanager.h \
|
src/notificationmanager.h \
|
||||||
src/processlauncher.h \
|
src/processlauncher.h \
|
||||||
|
src/stayawakeadaptor.h \
|
||||||
|
src/stayawakeinterface.h \
|
||||||
src/stickermanager.h \
|
src/stickermanager.h \
|
||||||
src/tdlibfile.h \
|
src/tdlibfile.h \
|
||||||
src/tdlibreceiver.h \
|
src/tdlibreceiver.h \
|
||||||
|
|
|
@ -62,6 +62,26 @@ Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TextSwitch {
|
||||||
|
checked: appSettings.autoRun
|
||||||
|
text: qsTr("Autorun at startup")
|
||||||
|
description: qsTr("Fernschreiber will automatically be run at startup")
|
||||||
|
automaticCheck: false
|
||||||
|
onClicked: {
|
||||||
|
appSettings.autoRun = !checked
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TextSwitch {
|
||||||
|
checked: appSettings.stayInBackground
|
||||||
|
text: qsTr("Stay in background")
|
||||||
|
description: qsTr("Fernschreiber will stay active in the background after the app was closed")
|
||||||
|
automaticCheck: false
|
||||||
|
onClicked: {
|
||||||
|
appSettings.stayInBackground = !checked
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ComboBox {
|
ComboBox {
|
||||||
id: feedbackComboBox
|
id: feedbackComboBox
|
||||||
label: qsTr("Notification feedback")
|
label: qsTr("Notification feedback")
|
||||||
|
|
|
@ -20,9 +20,20 @@
|
||||||
#define DEBUG_MODULE AppSettings
|
#define DEBUG_MODULE AppSettings
|
||||||
#include "debuglog.h"
|
#include "debuglog.h"
|
||||||
|
|
||||||
|
#include <QDBusInterface>
|
||||||
|
#include <QDBusReply>
|
||||||
|
#include <QGuiApplication>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QProcess>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const QString KEY_SEND_BY_ENTER("sendByEnter");
|
const QString KEY_SEND_BY_ENTER("sendByEnter");
|
||||||
const QString KEY_USE_OPEN_WITH("useOpenWith");
|
const QString KEY_USE_OPEN_WITH("useOpenWith");
|
||||||
|
const QString KEY_AUTO_RUN("autoRun");
|
||||||
|
const QString KEY_STAY_IN_BACKGROUND("stayInBackground");
|
||||||
const QString KEY_SHOW_STICKERS_AS_IMAGES("showStickersAsImages");
|
const QString KEY_SHOW_STICKERS_AS_IMAGES("showStickersAsImages");
|
||||||
const QString KEY_ANIMATE_STICKERS("animateStickers");
|
const QString KEY_ANIMATE_STICKERS("animateStickers");
|
||||||
const QString KEY_NOTIFICATION_TURNS_DISPLAY_ON("notificationTurnsDisplayOn");
|
const QString KEY_NOTIFICATION_TURNS_DISPLAY_ON("notificationTurnsDisplayOn");
|
||||||
|
@ -62,6 +73,36 @@ void AppSettings::setUseOpenWith(bool useOpenWith)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AppSettings::getAutoRun() const
|
||||||
|
{
|
||||||
|
return settings.value(KEY_AUTO_RUN, false).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSettings::setAutoRun(bool autoRun)
|
||||||
|
{
|
||||||
|
if (getAutoRun() != autoRun) {
|
||||||
|
LOG(KEY_AUTO_RUN << autoRun);
|
||||||
|
settings.setValue(KEY_AUTO_RUN, autoRun);
|
||||||
|
autoRun ? initializeAutoRun() : disableAutoRun();
|
||||||
|
emit autoRunChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AppSettings::getStayInBackground() const
|
||||||
|
{
|
||||||
|
return settings.value(KEY_STAY_IN_BACKGROUND, false).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSettings::setStayInBackground(bool stayInBackground)
|
||||||
|
{
|
||||||
|
if (getStayInBackground() != stayInBackground) {
|
||||||
|
LOG(KEY_STAY_IN_BACKGROUND << stayInBackground);
|
||||||
|
settings.setValue(KEY_STAY_IN_BACKGROUND, stayInBackground);
|
||||||
|
QGuiApplication::setQuitOnLastWindowClosed(!stayInBackground);
|
||||||
|
emit stayInBackgroundChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool AppSettings::showStickersAsImages() const
|
bool AppSettings::showStickersAsImages() const
|
||||||
{
|
{
|
||||||
return settings.value(KEY_SHOW_STICKERS_AS_IMAGES, true).toBool();
|
return settings.value(KEY_SHOW_STICKERS_AS_IMAGES, true).toBool();
|
||||||
|
@ -131,3 +172,81 @@ void AppSettings::setStorageOptimizer(bool enable)
|
||||||
emit storageOptimizerChanged();
|
emit storageOptimizerChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AppSettings::isAppRunning()
|
||||||
|
{
|
||||||
|
LOG("Checking via D-Bus if app is already running...");
|
||||||
|
QDBusInterface dBusInterface("de.ygriega.stayawake", "/de/ygriega/stayawake", "", QDBusConnection::sessionBus());
|
||||||
|
if (dBusInterface.isValid()) {
|
||||||
|
QDBusReply<bool> reply = dBusInterface.call("showUI");
|
||||||
|
if (reply.isValid()) {
|
||||||
|
return reply.value();
|
||||||
|
}
|
||||||
|
LOG("D-Bus call to show UI failed. App doesn't seem to be running (properly)!" << reply.error().message());
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
LOG("Fernschreiber D-Bus session interface is not existing. App doesn't seem to be running!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSettings::initializeAutoRun()
|
||||||
|
{
|
||||||
|
LOG("Initialize Auto-Run...");
|
||||||
|
|
||||||
|
QDir scriptsSystemDDir(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/systemd/scripts");
|
||||||
|
if (!scriptsSystemDDir.exists()) {
|
||||||
|
scriptsSystemDDir.mkpath(scriptsSystemDDir.path());
|
||||||
|
}
|
||||||
|
QFile autorunAppFile(scriptsSystemDDir.path() + "/autorun-fernschreiber");
|
||||||
|
if (!autorunAppFile.exists()) {
|
||||||
|
LOG("Creating autorun app file at " << autorunAppFile.fileName());
|
||||||
|
if (autorunAppFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
|
QTextStream appFileOut(&autorunAppFile);
|
||||||
|
appFileOut.setCodec("UTF-8");
|
||||||
|
appFileOut << QString("#!/bin/sh -").toUtf8() << "\n";
|
||||||
|
appFileOut << QString("").toUtf8() << "\n";
|
||||||
|
appFileOut << QString("/usr/bin/invoker -n -s --type=silica-qt5 /usr/bin/harbour-fernschreiber").toUtf8() << "\n";
|
||||||
|
appFileOut.flush();
|
||||||
|
autorunAppFile.close();
|
||||||
|
QProcess::startDetached("chmod u+x " + QFileInfo(autorunAppFile).filePath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QDir userSystemDDir(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/systemd/user");
|
||||||
|
if (!userSystemDDir.exists()) {
|
||||||
|
userSystemDDir.mkpath(userSystemDDir.path());
|
||||||
|
}
|
||||||
|
QFile autorunServiceFile(userSystemDDir.path() + "/autorun-fernschreiber.service");
|
||||||
|
if (!autorunServiceFile.exists()) {
|
||||||
|
LOG("Creating autorun service file at " << autorunServiceFile.fileName());
|
||||||
|
if (autorunServiceFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
|
QTextStream serviceFileOut(&autorunServiceFile);
|
||||||
|
serviceFileOut.setCodec("UTF-8");
|
||||||
|
serviceFileOut << QString("[Unit]").toUtf8() << "\n";
|
||||||
|
serviceFileOut << QString("Description=Autorun Fernschreiber at startup").toUtf8() << "\n";
|
||||||
|
serviceFileOut << QString("Requires=lipstick.service").toUtf8() << "\n";
|
||||||
|
serviceFileOut << QString("After=lipstick.service").toUtf8() << "\n";
|
||||||
|
serviceFileOut << QString("").toUtf8() << "\n";
|
||||||
|
serviceFileOut << QString("[Service]").toUtf8() << "\n";
|
||||||
|
serviceFileOut << QString("Type=oneshot").toUtf8() << "\n";
|
||||||
|
serviceFileOut << QString("ExecStart=" + QFileInfo(autorunAppFile).filePath()).toUtf8() << "\n";
|
||||||
|
serviceFileOut << QString("").toUtf8() << "\n";
|
||||||
|
serviceFileOut << QString("[Install]").toUtf8() << "\n";
|
||||||
|
serviceFileOut << QString("WantedBy=post-user-session.target").toUtf8() << "\n";
|
||||||
|
serviceFileOut.flush();
|
||||||
|
autorunServiceFile.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QProcess::startDetached("systemctl --user enable " + QFileInfo(autorunServiceFile).filePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSettings::disableAutoRun()
|
||||||
|
{
|
||||||
|
LOG("Disabling Auto-Run...");
|
||||||
|
QFile autorunServiceFile(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/systemd/user/autorun-fernschreiber.service");
|
||||||
|
if (autorunServiceFile.exists()) {
|
||||||
|
QProcess::startDetached("systemctl --user disable " + QFileInfo(autorunServiceFile).filePath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -20,11 +20,14 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <QQuickView>
|
||||||
|
|
||||||
class AppSettings : public QObject {
|
class AppSettings : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool sendByEnter READ getSendByEnter WRITE setSendByEnter NOTIFY sendByEnterChanged)
|
Q_PROPERTY(bool sendByEnter READ getSendByEnter WRITE setSendByEnter NOTIFY sendByEnterChanged)
|
||||||
Q_PROPERTY(bool useOpenWith READ getUseOpenWith WRITE setUseOpenWith NOTIFY useOpenWithChanged)
|
Q_PROPERTY(bool useOpenWith READ getUseOpenWith WRITE setUseOpenWith NOTIFY useOpenWithChanged)
|
||||||
|
Q_PROPERTY(bool autoRun READ getAutoRun WRITE setAutoRun NOTIFY autoRunChanged)
|
||||||
|
Q_PROPERTY(bool stayInBackground READ getStayInBackground WRITE setStayInBackground NOTIFY stayInBackgroundChanged)
|
||||||
Q_PROPERTY(bool showStickersAsImages READ showStickersAsImages WRITE setShowStickersAsImages NOTIFY showStickersAsImagesChanged)
|
Q_PROPERTY(bool showStickersAsImages READ showStickersAsImages WRITE setShowStickersAsImages NOTIFY showStickersAsImagesChanged)
|
||||||
Q_PROPERTY(bool animateStickers READ animateStickers WRITE setAnimateStickers NOTIFY animateStickersChanged)
|
Q_PROPERTY(bool animateStickers READ animateStickers WRITE setAnimateStickers NOTIFY animateStickersChanged)
|
||||||
Q_PROPERTY(bool notificationTurnsDisplayOn READ notificationTurnsDisplayOn WRITE setNotificationTurnsDisplayOn NOTIFY notificationTurnsDisplayOnChanged)
|
Q_PROPERTY(bool notificationTurnsDisplayOn READ notificationTurnsDisplayOn WRITE setNotificationTurnsDisplayOn NOTIFY notificationTurnsDisplayOnChanged)
|
||||||
|
@ -48,6 +51,12 @@ public:
|
||||||
bool getUseOpenWith() const;
|
bool getUseOpenWith() const;
|
||||||
void setUseOpenWith(bool useOpenWith);
|
void setUseOpenWith(bool useOpenWith);
|
||||||
|
|
||||||
|
bool getAutoRun() const;
|
||||||
|
void setAutoRun(bool autoRun);
|
||||||
|
|
||||||
|
bool getStayInBackground() const;
|
||||||
|
void setStayInBackground(bool stayInBackground);
|
||||||
|
|
||||||
bool showStickersAsImages() const;
|
bool showStickersAsImages() const;
|
||||||
void setShowStickersAsImages(bool showAsImages);
|
void setShowStickersAsImages(bool showAsImages);
|
||||||
|
|
||||||
|
@ -63,9 +72,13 @@ public:
|
||||||
bool storageOptimizer() const;
|
bool storageOptimizer() const;
|
||||||
void setStorageOptimizer(bool enable);
|
void setStorageOptimizer(bool enable);
|
||||||
|
|
||||||
|
bool isAppRunning();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void sendByEnterChanged();
|
void sendByEnterChanged();
|
||||||
void useOpenWithChanged();
|
void useOpenWithChanged();
|
||||||
|
void autoRunChanged();
|
||||||
|
void stayInBackgroundChanged();
|
||||||
void showStickersAsImagesChanged();
|
void showStickersAsImagesChanged();
|
||||||
void animateStickersChanged();
|
void animateStickersChanged();
|
||||||
void notificationTurnsDisplayOnChanged();
|
void notificationTurnsDisplayOnChanged();
|
||||||
|
@ -74,6 +87,9 @@ signals:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
|
void initializeAutoRun();
|
||||||
|
void disableAutoRun();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // APPSETTINGS_H
|
#endif // APPSETTINGS_H
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#define DBUSADAPTOR_H
|
#define DBUSADAPTOR_H
|
||||||
|
|
||||||
#include <QDBusAbstractAdaptor>
|
#include <QDBusAbstractAdaptor>
|
||||||
|
#include <QQuickView>
|
||||||
|
|
||||||
class DBusAdaptor : public QDBusAbstractAdaptor
|
class DBusAdaptor : public QDBusAbstractAdaptor
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,7 +39,10 @@
|
||||||
#include "namedaction.h"
|
#include "namedaction.h"
|
||||||
#include "notificationmanager.h"
|
#include "notificationmanager.h"
|
||||||
#include "mceinterface.h"
|
#include "mceinterface.h"
|
||||||
|
#include "dbusinterface.h"
|
||||||
#include "dbusadaptor.h"
|
#include "dbusadaptor.h"
|
||||||
|
#include "stayawakeinterface.h"
|
||||||
|
#include "stayawakeadaptor.h"
|
||||||
#include "processlauncher.h"
|
#include "processlauncher.h"
|
||||||
#include "stickermanager.h"
|
#include "stickermanager.h"
|
||||||
#include "tgsplugin.h"
|
#include "tgsplugin.h"
|
||||||
|
@ -75,6 +78,23 @@ int main(int argc, char *argv[])
|
||||||
context->setContextProperty("appSettings", appSettings);
|
context->setContextProperty("appSettings", appSettings);
|
||||||
qmlRegisterUncreatableType<AppSettings>(uri, 1, 0, "AppSettings", QString());
|
qmlRegisterUncreatableType<AppSettings>(uri, 1, 0, "AppSettings", QString());
|
||||||
|
|
||||||
|
if (appSettings->isAppRunning()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (appSettings->getStayInBackground()) {
|
||||||
|
app.data()->setQuitOnLastWindowClosed(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
DBusInterface *dBusInterface = new DBusInterface(view.data());
|
||||||
|
DBusAdaptor *dBusAdaptor = dBusInterface->getDBusAdaptor();
|
||||||
|
context->setContextProperty("dBusAdaptor", dBusAdaptor);
|
||||||
|
|
||||||
|
StayAwakeInterface *stayAwakeInterface = new StayAwakeInterface(view.data());
|
||||||
|
StayAwakeAdaptor *stayAwakeAdaptor = stayAwakeInterface->getStayAwakeAdaptor();
|
||||||
|
stayAwakeAdaptor->setAppView(view.data());
|
||||||
|
context->setContextProperty("stayAwakeAdaptor", stayAwakeAdaptor);
|
||||||
|
|
||||||
MceInterface *mceInterface = new MceInterface(view.data());
|
MceInterface *mceInterface = new MceInterface(view.data());
|
||||||
TDLibWrapper *tdLibWrapper = new TDLibWrapper(appSettings, mceInterface, view.data());
|
TDLibWrapper *tdLibWrapper = new TDLibWrapper(appSettings, mceInterface, view.data());
|
||||||
context->setContextProperty("tdLibWrapper", tdLibWrapper);
|
context->setContextProperty("tdLibWrapper", tdLibWrapper);
|
||||||
|
@ -83,9 +103,6 @@ int main(int argc, char *argv[])
|
||||||
FernschreiberUtils *fernschreiberUtils = new FernschreiberUtils(view.data());
|
FernschreiberUtils *fernschreiberUtils = new FernschreiberUtils(view.data());
|
||||||
context->setContextProperty("fernschreiberUtils", fernschreiberUtils);
|
context->setContextProperty("fernschreiberUtils", fernschreiberUtils);
|
||||||
|
|
||||||
DBusAdaptor *dBusAdaptor = tdLibWrapper->getDBusAdaptor();
|
|
||||||
context->setContextProperty("dBusAdaptor", dBusAdaptor);
|
|
||||||
|
|
||||||
ChatListModel chatListModel(tdLibWrapper);
|
ChatListModel chatListModel(tdLibWrapper);
|
||||||
context->setContextProperty("chatListModel", &chatListModel);
|
context->setContextProperty("chatListModel", &chatListModel);
|
||||||
|
|
||||||
|
|
46
src/stayawakeadaptor.cpp
Normal file
46
src/stayawakeadaptor.cpp
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2020 Sebastian J. Wolf and other contributors
|
||||||
|
|
||||||
|
This file is part of Fernschreiber.
|
||||||
|
|
||||||
|
Fernschreiber is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Fernschreiber 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 General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Fernschreiber. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "stayawakeadaptor.h"
|
||||||
|
|
||||||
|
#define DEBUG_MODULE StayAwakeAdaptor
|
||||||
|
#include "debuglog.h"
|
||||||
|
|
||||||
|
StayAwakeAdaptor::StayAwakeAdaptor(QObject *parent): QDBusAbstractAdaptor(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void StayAwakeAdaptor::setAppView(QQuickView *appView)
|
||||||
|
{
|
||||||
|
this->appView = appView;
|
||||||
|
}
|
||||||
|
|
||||||
|
void StayAwakeAdaptor::sendToBackground()
|
||||||
|
{
|
||||||
|
LOG("Minimize appo! But how?");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool StayAwakeAdaptor::showUI()
|
||||||
|
{
|
||||||
|
LOG("UI shall wake up!");
|
||||||
|
this->appView->showFullScreen();
|
||||||
|
return true;
|
||||||
|
}
|
48
src/stayawakeadaptor.h
Normal file
48
src/stayawakeadaptor.h
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2020 Sebastian J. Wolf and other contributors
|
||||||
|
|
||||||
|
This file is part of Fernschreiber.
|
||||||
|
|
||||||
|
Fernschreiber is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Fernschreiber 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 General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Fernschreiber. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef STAYAWAKEADAPTOR_H
|
||||||
|
#define STAYAWAKEADAPTOR_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <QDBusAbstractAdaptor>
|
||||||
|
#include <QQuickView>
|
||||||
|
|
||||||
|
class StayAwakeAdaptor : public QDBusAbstractAdaptor
|
||||||
|
{
|
||||||
|
|
||||||
|
Q_OBJECT
|
||||||
|
Q_CLASSINFO("D-Bus Interface", "de.ygriega.stayawake")
|
||||||
|
|
||||||
|
public:
|
||||||
|
StayAwakeAdaptor(QObject *parent);
|
||||||
|
|
||||||
|
void setAppView(QQuickView* appView);
|
||||||
|
Q_INVOKABLE void sendToBackground();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
bool showUI();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QQuickView *appView;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // STAYAWAKEADAPTOR_H
|
50
src/stayawakeinterface.cpp
Normal file
50
src/stayawakeinterface.cpp
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2020 Sebastian J. Wolf and other contributors
|
||||||
|
|
||||||
|
This file is part of Fernschreiber.
|
||||||
|
|
||||||
|
Fernschreiber is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Fernschreiber 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 General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Fernschreiber. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "stayawakeinterface.h"
|
||||||
|
|
||||||
|
#define DEBUG_MODULE StayAwakeInterface
|
||||||
|
#include "debuglog.h"
|
||||||
|
|
||||||
|
StayAwakeInterface::StayAwakeInterface(QObject *parent) : QObject(parent)
|
||||||
|
{
|
||||||
|
LOG("Initializing D-BUS connectivity");
|
||||||
|
this->stayAwakeAdaptor = new StayAwakeAdaptor(this);
|
||||||
|
QDBusConnection sessionBusConnection = QDBusConnection::sessionBus();
|
||||||
|
|
||||||
|
if (!sessionBusConnection.isConnected()) {
|
||||||
|
WARN("Error connecting to D-BUS");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sessionBusConnection.registerObject("/de/ygriega/stayawake", this)) {
|
||||||
|
WARN("Error registering root object to D-BUS" << sessionBusConnection.lastError().message());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sessionBusConnection.registerService("de.ygriega.stayawake")) {
|
||||||
|
WARN("Error registering interface to D-BUS" << sessionBusConnection.lastError().message());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StayAwakeAdaptor *StayAwakeInterface::getStayAwakeAdaptor()
|
||||||
|
{
|
||||||
|
return this->stayAwakeAdaptor;
|
||||||
|
}
|
45
src/stayawakeinterface.h
Normal file
45
src/stayawakeinterface.h
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2020 Sebastian J. Wolf and other contributors
|
||||||
|
|
||||||
|
This file is part of Fernschreiber.
|
||||||
|
|
||||||
|
Fernschreiber is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Fernschreiber 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 General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Fernschreiber. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef STAYAWAKEINTERFACE_H
|
||||||
|
#define STAYAWAKEINTERFACE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QtDBus>
|
||||||
|
|
||||||
|
#include "stayawakeadaptor.h"
|
||||||
|
|
||||||
|
class StayAwakeInterface : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit StayAwakeInterface(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
StayAwakeAdaptor *getStayAwakeAdaptor();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
private:
|
||||||
|
StayAwakeAdaptor *stayAwakeAdaptor;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // STAYAWAKEINTERFACE_H
|
|
@ -63,7 +63,6 @@ TDLibWrapper::TDLibWrapper(AppSettings *appSettings, MceInterface *mceInterface,
|
||||||
tdLibDatabaseDirectory.mkpath(tdLibDatabaseDirectoryPath);
|
tdLibDatabaseDirectory.mkpath(tdLibDatabaseDirectoryPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->dbusInterface = new DBusInterface(this);
|
|
||||||
if (this->appSettings->getUseOpenWith()) {
|
if (this->appSettings->getUseOpenWith()) {
|
||||||
this->initializeOpenWith();
|
this->initializeOpenWith();
|
||||||
} else {
|
} else {
|
||||||
|
@ -1043,11 +1042,6 @@ void TDLibWrapper::registerJoinChat()
|
||||||
this->joinChatRequested = false;
|
this->joinChatRequested = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBusAdaptor *TDLibWrapper::getDBusAdaptor()
|
|
||||||
{
|
|
||||||
return this->dbusInterface->getDBusAdaptor();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TDLibWrapper::handleVersionDetected(const QString &version)
|
void TDLibWrapper::handleVersionDetected(const QString &version)
|
||||||
{
|
{
|
||||||
this->version = version;
|
this->version = version;
|
||||||
|
|
|
@ -117,8 +117,6 @@ public:
|
||||||
Q_INVOKABLE bool getJoinChatRequested();
|
Q_INVOKABLE bool getJoinChatRequested();
|
||||||
Q_INVOKABLE void registerJoinChat();
|
Q_INVOKABLE void registerJoinChat();
|
||||||
|
|
||||||
DBusAdaptor *getDBusAdaptor();
|
|
||||||
|
|
||||||
// Direct TDLib functions
|
// Direct TDLib functions
|
||||||
Q_INVOKABLE void sendRequest(const QVariantMap &requestObject);
|
Q_INVOKABLE void sendRequest(const QVariantMap &requestObject);
|
||||||
Q_INVOKABLE void setAuthenticationPhoneNumber(const QString &phoneNumber);
|
Q_INVOKABLE void setAuthenticationPhoneNumber(const QString &phoneNumber);
|
||||||
|
@ -278,7 +276,6 @@ private:
|
||||||
AppSettings *appSettings;
|
AppSettings *appSettings;
|
||||||
MceInterface *mceInterface;
|
MceInterface *mceInterface;
|
||||||
TDLibReceiver *tdLibReceiver;
|
TDLibReceiver *tdLibReceiver;
|
||||||
DBusInterface *dbusInterface;
|
|
||||||
QString version;
|
QString version;
|
||||||
TDLibWrapper::AuthorizationState authorizationState;
|
TDLibWrapper::AuthorizationState authorizationState;
|
||||||
QVariantMap authorizationStateData;
|
QVariantMap authorizationStateData;
|
||||||
|
|
|
@ -1294,6 +1294,22 @@
|
||||||
<source>Enable storage optimizer</source>
|
<source>Enable storage optimizer</source>
|
||||||
<translation>Speicheroptimierer einschalten</translation>
|
<translation>Speicheroptimierer einschalten</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Stay in background</source>
|
||||||
|
<translation>Im Hintergrund bleiben</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Fernschreiber will stay active in the background after the app was closed</source>
|
||||||
|
<translation>Fernschreiber wird im Hintergrund aktiv bleiben nachdem die App geschlossen wurde</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Autorun at startup</source>
|
||||||
|
<translation>Automatischer Start</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Fernschreiber will automatically be run at startup</source>
|
||||||
|
<translation>Fernschreiber wird automatisch gestartet während das Gerät hochgefahren wird.</translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>StickerPicker</name>
|
<name>StickerPicker</name>
|
||||||
|
|
|
@ -1294,6 +1294,22 @@
|
||||||
<source>Enable storage optimizer</source>
|
<source>Enable storage optimizer</source>
|
||||||
<translation>Enable storage optimizer</translation>
|
<translation>Enable storage optimizer</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Stay in background</source>
|
||||||
|
<translation>Stay in background</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Fernschreiber will stay active in the background after the app was closed</source>
|
||||||
|
<translation>Fernschreiber will stay active in the background after the app was closed</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Autorun at startup</source>
|
||||||
|
<translation>Autorun at startup</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Fernschreiber will automatically be run at startup</source>
|
||||||
|
<translation>Fernschreiber will automatically be run at startup</translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>StickerPicker</name>
|
<name>StickerPicker</name>
|
||||||
|
|
|
@ -1275,6 +1275,22 @@
|
||||||
<source>Enable storage optimizer</source>
|
<source>Enable storage optimizer</source>
|
||||||
<translation>Optimizador de almacenamiento</translation>
|
<translation>Optimizador de almacenamiento</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Stay in background</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Fernschreiber will stay active in the background after the app was closed</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Autorun at startup</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Fernschreiber will automatically be run at startup</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>StickerPicker</name>
|
<name>StickerPicker</name>
|
||||||
|
|
|
@ -1295,6 +1295,22 @@
|
||||||
<source>Enable storage optimizer</source>
|
<source>Enable storage optimizer</source>
|
||||||
<translation>Käytä tallennustilan optimointia</translation>
|
<translation>Käytä tallennustilan optimointia</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Stay in background</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Fernschreiber will stay active in the background after the app was closed</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Autorun at startup</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Fernschreiber will automatically be run at startup</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>StickerPicker</name>
|
<name>StickerPicker</name>
|
||||||
|
|
|
@ -1275,6 +1275,22 @@
|
||||||
<source>Enable storage optimizer</source>
|
<source>Enable storage optimizer</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Stay in background</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Fernschreiber will stay active in the background after the app was closed</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Autorun at startup</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Fernschreiber will automatically be run at startup</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>StickerPicker</name>
|
<name>StickerPicker</name>
|
||||||
|
|
|
@ -1294,6 +1294,22 @@
|
||||||
<source>Enable storage optimizer</source>
|
<source>Enable storage optimizer</source>
|
||||||
<translation>Abilita ottimizzazione memoria</translation>
|
<translation>Abilita ottimizzazione memoria</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Stay in background</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Fernschreiber will stay active in the background after the app was closed</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Autorun at startup</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Fernschreiber will automatically be run at startup</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>StickerPicker</name>
|
<name>StickerPicker</name>
|
||||||
|
|
|
@ -1313,6 +1313,22 @@
|
||||||
<source>Enable storage optimizer</source>
|
<source>Enable storage optimizer</source>
|
||||||
<translation>Włącz optymalizację pamięci</translation>
|
<translation>Włącz optymalizację pamięci</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Stay in background</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Fernschreiber will stay active in the background after the app was closed</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Autorun at startup</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Fernschreiber will automatically be run at startup</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>StickerPicker</name>
|
<name>StickerPicker</name>
|
||||||
|
|
|
@ -1313,6 +1313,22 @@
|
||||||
<source>Enable storage optimizer</source>
|
<source>Enable storage optimizer</source>
|
||||||
<translation>Включить оптимизацию хранилища</translation>
|
<translation>Включить оптимизацию хранилища</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Stay in background</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Fernschreiber will stay active in the background after the app was closed</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Autorun at startup</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Fernschreiber will automatically be run at startup</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>StickerPicker</name>
|
<name>StickerPicker</name>
|
||||||
|
|
|
@ -1294,6 +1294,22 @@
|
||||||
<source>Enable storage optimizer</source>
|
<source>Enable storage optimizer</source>
|
||||||
<translation>Aktivera lagringsoptimering</translation>
|
<translation>Aktivera lagringsoptimering</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Stay in background</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Fernschreiber will stay active in the background after the app was closed</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Autorun at startup</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Fernschreiber will automatically be run at startup</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>StickerPicker</name>
|
<name>StickerPicker</name>
|
||||||
|
|
|
@ -1275,6 +1275,22 @@
|
||||||
<source>Enable storage optimizer</source>
|
<source>Enable storage optimizer</source>
|
||||||
<translation>启用储存加速器</translation>
|
<translation>启用储存加速器</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Stay in background</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Fernschreiber will stay active in the background after the app was closed</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Autorun at startup</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Fernschreiber will automatically be run at startup</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>StickerPicker</name>
|
<name>StickerPicker</name>
|
||||||
|
|
|
@ -1294,6 +1294,22 @@
|
||||||
<source>Enable storage optimizer</source>
|
<source>Enable storage optimizer</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Stay in background</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Fernschreiber will stay active in the background after the app was closed</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Autorun at startup</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Fernschreiber will automatically be run at startup</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>StickerPicker</name>
|
<name>StickerPicker</name>
|
||||||
|
|
Loading…
Reference in a new issue