mirror of
https://github.com/status-im/snorenotify.git
synced 2025-02-18 19:26:36 +00:00
add notify my android backend
This commit is contained in:
parent
e072cc3203
commit
1a576df4e8
27
lang/de.ts
27
lang/de.ts
@ -14,6 +14,14 @@
|
|||||||
<translation>Passwort:</translation>
|
<translation>Passwort:</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>NotifyMyAndroidSettings</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/plugins/secondary_backends/nma/nmasettings.cpp" line="28"/>
|
||||||
|
<source>Api Key:</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>SettingsDialog</name>
|
<name>SettingsDialog</name>
|
||||||
<message>
|
<message>
|
||||||
@ -99,22 +107,22 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>Snore::SettingsDialog</name>
|
<name>Snore::SettingsDialog</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/libsnore/settingsdialog.cpp" line="79"/>
|
<location filename="../src/libsnore/settingsdialog.cpp" line="78"/>
|
||||||
<source>Hello World</source>
|
<source>Hello World</source>
|
||||||
<translation>Hallo Welt</translation>
|
<translation>Hallo Welt</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/libsnore/settingsdialog.cpp" line="81"/>
|
<location filename="../src/libsnore/settingsdialog.cpp" line="80"/>
|
||||||
<source>This is Snore</source>
|
<source>This is Snore</source>
|
||||||
<translation>Dies ist Snore</translation>
|
<translation>Dies ist Snore</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/libsnore/settingsdialog.cpp" line="81"/>
|
<location filename="../src/libsnore/settingsdialog.cpp" line="80"/>
|
||||||
<source>Project Website</source>
|
<source>Project Website</source>
|
||||||
<translation>Projekt Webseite</translation>
|
<translation>Projekt Webseite</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/libsnore/settingsdialog.cpp" line="83"/>
|
<location filename="../src/libsnore/settingsdialog.cpp" line="82"/>
|
||||||
<source>Test Action</source>
|
<source>Test Action</source>
|
||||||
<translation>Test Aktion</translation>
|
<translation>Test Aktion</translation>
|
||||||
</message>
|
</message>
|
||||||
@ -150,17 +158,22 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>SoundSettings</name>
|
<name>SoundSettings</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/plugins/secondary_backends/sound/soundsettings.cpp" line="31"/>
|
<location filename="../src/plugins/secondary_backends/sound/soundsettings.cpp" line="34"/>
|
||||||
|
<source>Volume:</source>
|
||||||
|
<translation>Lautstärke:</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/plugins/secondary_backends/sound/soundsettings.cpp" line="36"/>
|
||||||
<source>Audio file:</source>
|
<source>Audio file:</source>
|
||||||
<translation>Audio Datei:</translation>
|
<translation>Audio Datei:</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/plugins/secondary_backends/sound/soundsettings.cpp" line="32"/>
|
<location filename="../src/plugins/secondary_backends/sound/soundsettings.cpp" line="37"/>
|
||||||
<source>Select a audio file</source>
|
<source>Select a audio file</source>
|
||||||
<translation>Wähle eine Audio Datei</translation>
|
<translation>Wähle eine Audio Datei</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/plugins/secondary_backends/sound/soundsettings.cpp" line="35"/>
|
<location filename="../src/plugins/secondary_backends/sound/soundsettings.cpp" line="40"/>
|
||||||
<source>All Audio files</source>
|
<source>All Audio files</source>
|
||||||
<translation>Alle Audio Dateien</translation>
|
<translation>Alle Audio Dateien</translation>
|
||||||
</message>
|
</message>
|
||||||
|
27
lang/en.ts
27
lang/en.ts
@ -14,6 +14,14 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>NotifyMyAndroidSettings</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/plugins/secondary_backends/nma/nmasettings.cpp" line="28"/>
|
||||||
|
<source>Api Key:</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>SettingsDialog</name>
|
<name>SettingsDialog</name>
|
||||||
<message>
|
<message>
|
||||||
@ -99,22 +107,22 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>Snore::SettingsDialog</name>
|
<name>Snore::SettingsDialog</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/libsnore/settingsdialog.cpp" line="79"/>
|
<location filename="../src/libsnore/settingsdialog.cpp" line="78"/>
|
||||||
<source>Hello World</source>
|
<source>Hello World</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/libsnore/settingsdialog.cpp" line="81"/>
|
<location filename="../src/libsnore/settingsdialog.cpp" line="80"/>
|
||||||
<source>This is Snore</source>
|
<source>This is Snore</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/libsnore/settingsdialog.cpp" line="81"/>
|
<location filename="../src/libsnore/settingsdialog.cpp" line="80"/>
|
||||||
<source>Project Website</source>
|
<source>Project Website</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/libsnore/settingsdialog.cpp" line="83"/>
|
<location filename="../src/libsnore/settingsdialog.cpp" line="82"/>
|
||||||
<source>Test Action</source>
|
<source>Test Action</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
@ -150,17 +158,22 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>SoundSettings</name>
|
<name>SoundSettings</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/plugins/secondary_backends/sound/soundsettings.cpp" line="31"/>
|
<location filename="../src/plugins/secondary_backends/sound/soundsettings.cpp" line="34"/>
|
||||||
|
<source>Volume:</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/plugins/secondary_backends/sound/soundsettings.cpp" line="36"/>
|
||||||
<source>Audio file:</source>
|
<source>Audio file:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/plugins/secondary_backends/sound/soundsettings.cpp" line="32"/>
|
<location filename="../src/plugins/secondary_backends/sound/soundsettings.cpp" line="37"/>
|
||||||
<source>Select a audio file</source>
|
<source>Select a audio file</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/plugins/secondary_backends/sound/soundsettings.cpp" line="35"/>
|
<location filename="../src/plugins/secondary_backends/sound/soundsettings.cpp" line="40"/>
|
||||||
<source>All Audio files</source>
|
<source>All Audio files</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
add_subdirectory(toasty)
|
add_subdirectory(toasty)
|
||||||
|
add_subdirectory(nma)
|
||||||
add_subdirectory(sound)
|
add_subdirectory(sound)
|
||||||
|
10
src/plugins/secondary_backends/nma/CMakeLists.txt
Normal file
10
src/plugins/secondary_backends/nma/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
set( NMA_SRC
|
||||||
|
nma.cpp
|
||||||
|
nmasettings.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(libsnore_secondary_backend_nma MODULE ${NMA_SRC} )
|
||||||
|
target_link_libraries(libsnore_secondary_backend_nma Snore::Libsnore)
|
||||||
|
|
||||||
|
install(TARGETS libsnore_secondary_backend_nma ${SNORE_PLUGIN_INSTALL_PATH})
|
||||||
|
|
70
src/plugins/secondary_backends/nma/nma.cpp
Normal file
70
src/plugins/secondary_backends/nma/nma.cpp
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
SnoreNotify is a Notification Framework based on Qt
|
||||||
|
Copyright (C) 2015 Patrick von Reth <vonreth@kde.org>
|
||||||
|
|
||||||
|
SnoreNotify is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
SnoreNotify 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 Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
|
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "nma.h"
|
||||||
|
#include "nmasettings.h"
|
||||||
|
|
||||||
|
#include"libsnore/utils.h"
|
||||||
|
|
||||||
|
#include <QNetworkAccessManager>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
#include <QNetworkRequest>
|
||||||
|
|
||||||
|
using namespace Snore;
|
||||||
|
|
||||||
|
NotifyMyAndroid::NotifyMyAndroid():
|
||||||
|
SnoreSecondaryBackend("NotifyMyAndroid", false)
|
||||||
|
{
|
||||||
|
setDefaultValue("ApiKey", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
NotifyMyAndroid::~NotifyMyAndroid()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void NotifyMyAndroid::slotNotify(Notification notification)
|
||||||
|
{
|
||||||
|
QString key = value("ApiKey").toString();
|
||||||
|
if (key.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QNetworkRequest request(QUrl("https://www.notifymyandroid.com/publicapi/notify"));
|
||||||
|
request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/x-www-form-urlencoded"));
|
||||||
|
|
||||||
|
// TODO: use toHTML?
|
||||||
|
QString data(QString("apikey=%1&application=%2&event=%3&description=%4&content-type=text/html")
|
||||||
|
.arg(key,
|
||||||
|
notification.application().name(),
|
||||||
|
Utils::toPlainText(notification.title()),
|
||||||
|
Utils::toPlainText(notification.text())));
|
||||||
|
|
||||||
|
QNetworkReply *reply = m_manager.post(request,data.toUtf8().constData());
|
||||||
|
connect(reply, &QNetworkReply::finished, [reply]() {
|
||||||
|
snoreDebug(SNORE_DEBUG) << reply->error();
|
||||||
|
snoreDebug(SNORE_DEBUG) << reply->readAll();
|
||||||
|
reply->close();
|
||||||
|
reply->deleteLater();
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
PluginSettingsWidget *NotifyMyAndroid::settingsWidget()
|
||||||
|
{
|
||||||
|
return new NotifyMyAndroidSettings(this);
|
||||||
|
}
|
44
src/plugins/secondary_backends/nma/nma.h
Normal file
44
src/plugins/secondary_backends/nma/nma.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
SnoreNotify is a Notification Framework based on Qt
|
||||||
|
Copyright (C) 2015 Patrick von Reth <vonreth@kde.org>
|
||||||
|
|
||||||
|
SnoreNotify is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
SnoreNotify 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 Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
|
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef NMA_H
|
||||||
|
#define NMA_H
|
||||||
|
|
||||||
|
#include "libsnore/plugins/snorebackend.h"
|
||||||
|
|
||||||
|
#include <QNetworkAccessManager>
|
||||||
|
|
||||||
|
class NotifyMyAndroid : public Snore::SnoreSecondaryBackend
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_INTERFACES(Snore::SnoreSecondaryBackend)
|
||||||
|
Q_PLUGIN_METADATA(IID "org.Snore.SecondaryNotificationBackend/1.0" FILE "plugin.json")
|
||||||
|
public:
|
||||||
|
NotifyMyAndroid();
|
||||||
|
~NotifyMyAndroid();
|
||||||
|
|
||||||
|
Snore::PluginSettingsWidget *settingsWidget() override;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void slotNotify(Snore::Notification notification) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QNetworkAccessManager m_manager;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // NMA_H
|
43
src/plugins/secondary_backends/nma/nmasettings.cpp
Normal file
43
src/plugins/secondary_backends/nma/nmasettings.cpp
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
SnoreNotify is a Notification Framework based on Qt
|
||||||
|
Copyright (C) 2015 Patrick von Reth <vonreth@kde.org>
|
||||||
|
|
||||||
|
SnoreNotify is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
SnoreNotify 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 Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
|
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "nmasettings.h"
|
||||||
|
|
||||||
|
#include "plugins/plugins.h"
|
||||||
|
|
||||||
|
#include <QLineEdit>
|
||||||
|
|
||||||
|
NotifyMyAndroidSettings::NotifyMyAndroidSettings(Snore::SnorePlugin *plugin, QWidget *parent) :
|
||||||
|
Snore::PluginSettingsWidget(plugin, parent),
|
||||||
|
m_lineEdit(new QLineEdit)
|
||||||
|
{
|
||||||
|
addRow(tr("Api Key:"), m_lineEdit);
|
||||||
|
}
|
||||||
|
|
||||||
|
NotifyMyAndroidSettings::~NotifyMyAndroidSettings()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void NotifyMyAndroidSettings::load()
|
||||||
|
{
|
||||||
|
m_lineEdit->setText(value("ApiKey").toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void NotifyMyAndroidSettings::save()
|
||||||
|
{
|
||||||
|
setValue("ApiKey", m_lineEdit->text());
|
||||||
|
}
|
40
src/plugins/secondary_backends/nma/nmasettings.h
Normal file
40
src/plugins/secondary_backends/nma/nmasettings.h
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
SnoreNotify is a Notification Framework based on Qt
|
||||||
|
Copyright (C) 2015 Patrick von Reth <vonreth@kde.org>
|
||||||
|
|
||||||
|
SnoreNotify is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
SnoreNotify 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 Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
|
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef NOTIFYMYANDROID_H
|
||||||
|
#define NOTIFYMYANDROID_H
|
||||||
|
|
||||||
|
#include "plugins/pluginsettingswidget.h"
|
||||||
|
|
||||||
|
class QLineEdit;
|
||||||
|
|
||||||
|
class NotifyMyAndroidSettings : public Snore::PluginSettingsWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit NotifyMyAndroidSettings(Snore::SnorePlugin *plugin, QWidget *parent = 0);
|
||||||
|
~NotifyMyAndroidSettings();
|
||||||
|
|
||||||
|
void load() override;
|
||||||
|
void save() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QLineEdit *m_lineEdit;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // NOTIFYMYANDROID_HH
|
1
src/plugins/secondary_backends/nma/plugin.json
Normal file
1
src/plugins/secondary_backends/nma/plugin.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{ "type" : "secondary_backend", "name" : "NotifyMyAndroid" }
|
Loading…
x
Reference in New Issue
Block a user