Merge branch '0.7'
This commit is contained in:
commit
1ea69e2329
|
@ -32,7 +32,7 @@ include(QtStatic)
|
||||||
|
|
||||||
set(SNORE_VERSION_MAJOR 0)
|
set(SNORE_VERSION_MAJOR 0)
|
||||||
set(SNORE_VERSION_MINOR 7)
|
set(SNORE_VERSION_MINOR 7)
|
||||||
set(SNORE_VERSION_PATCH 0)
|
set(SNORE_VERSION_PATCH 1)
|
||||||
|
|
||||||
set(SNORE_SUFFIX "-qt5")
|
set(SNORE_SUFFIX "-qt5")
|
||||||
set(SNORE_CamelCase_SUFFIX "Qt5")
|
set(SNORE_CamelCase_SUFFIX "Qt5")
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
ecm_optional_add_subdirectory(toasty)
|
ecm_optional_add_subdirectory(toasty)
|
||||||
ecm_optional_add_subdirectory(nma)
|
|
||||||
ecm_optional_add_subdirectory(sound)
|
ecm_optional_add_subdirectory(sound)
|
||||||
ecm_optional_add_subdirectory(speech)
|
ecm_optional_add_subdirectory(speech)
|
||||||
ecm_optional_add_subdirectory(pushover_backend)
|
ecm_optional_add_subdirectory(pushover_backend)
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
add_snore_plugin(NMA SOURCES nma.cpp SETTINGS_SOURCES nmasettings.cpp TYPE SecondaryBackend)
|
|
|
@ -1,68 +0,0 @@
|
||||||
/*
|
|
||||||
SnoreNotify is a Notification Framework based on Qt
|
|
||||||
Copyright (C) 2015 Hannah 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 "nmaconstants.h"
|
|
||||||
|
|
||||||
#include "libsnore/utils.h"
|
|
||||||
|
|
||||||
#include <QNetworkReply>
|
|
||||||
#include <QNetworkRequest>
|
|
||||||
|
|
||||||
namespace SnorePlugin {
|
|
||||||
|
|
||||||
void NMA::slotNotify(Snore::Notification notification)
|
|
||||||
{
|
|
||||||
QString key = settingsValue(NMAConstants::ApiKey).toString();
|
|
||||||
if (key.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QNetworkRequest request(QUrl::fromEncoded("https://www.notifymyandroid.com/publicapi/notify"));
|
|
||||||
request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(QLatin1String("application/x-www-form-urlencoded")));
|
|
||||||
|
|
||||||
QString data = QLatin1String("apikey=") + key
|
|
||||||
+ QLatin1String("&application=") + notification.application().name()
|
|
||||||
+ QLatin1String("&event=") + notification.title()
|
|
||||||
+ QLatin1String("&priority=") + QString::number(notification.priority())
|
|
||||||
+ QLatin1String("&description=");
|
|
||||||
|
|
||||||
if (notification.constHints().value("supports-markup").toBool()) {
|
|
||||||
data += notification.text(Snore::Utils::Href | Snore::Utils::Bold | Snore::Utils::Break |
|
|
||||||
Snore::Utils::Underline | Snore::Utils::Font | Snore::Utils::Italic)
|
|
||||||
+ QLatin1String("&content-type=text/html");
|
|
||||||
} else {
|
|
||||||
data += notification.text();
|
|
||||||
}
|
|
||||||
|
|
||||||
QNetworkReply *reply = m_manager.post(request, data.toUtf8().constData());
|
|
||||||
connect(reply, &QNetworkReply::finished, [reply]() {
|
|
||||||
qCDebug(SNORE) << reply->error();
|
|
||||||
qCDebug(SNORE) << reply->readAll();
|
|
||||||
reply->close();
|
|
||||||
reply->deleteLater();
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void NMA::setDefaultSettings()
|
|
||||||
{
|
|
||||||
setDefaultSettingsValue(NMAConstants::ApiKey, QString());
|
|
||||||
SnoreSecondaryBackend::setDefaultSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,49 +0,0 @@
|
||||||
/*
|
|
||||||
SnoreNotify is a Notification Framework based on Qt
|
|
||||||
Copyright (C) 2015 Hannah 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/snoresecondarybackend.h"
|
|
||||||
|
|
||||||
#include <QNetworkAccessManager>
|
|
||||||
|
|
||||||
namespace SnorePlugin {
|
|
||||||
|
|
||||||
|
|
||||||
class NMA : public Snore::SnoreSecondaryBackend
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_INTERFACES(Snore::SnoreSecondaryBackend)
|
|
||||||
Q_PLUGIN_METADATA(IID "org.Snore.SecondaryNotificationBackend/1.0" FILE "snore_plugin.json")
|
|
||||||
public:
|
|
||||||
NMA() = default;
|
|
||||||
~NMA() = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void setDefaultSettings() override;
|
|
||||||
|
|
||||||
public Q_SLOTS:
|
|
||||||
void slotNotify(Snore::Notification notification) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
QNetworkAccessManager m_manager;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif // NMA_H
|
|
|
@ -1,9 +0,0 @@
|
||||||
#ifndef NMACONSTANTS_H
|
|
||||||
#define NMACONSTANTS_H
|
|
||||||
|
|
||||||
#include "libsnore/snoreglobals.h"
|
|
||||||
|
|
||||||
namespace NMAConstants {
|
|
||||||
static const Snore::SettingsKey ApiKey = {QStringLiteral("ApiKey"), Snore::GlobalSetting};
|
|
||||||
}
|
|
||||||
#endif // NMACONSTANTS_H
|
|
|
@ -1,46 +0,0 @@
|
||||||
/*
|
|
||||||
SnoreNotify is a Notification Framework based on Qt
|
|
||||||
Copyright (C) 2015 Hannah 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 "nmaconstants.h"
|
|
||||||
|
|
||||||
#include "libsnore/plugins/plugins.h"
|
|
||||||
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QLineEdit>
|
|
||||||
|
|
||||||
NMASettings::NMASettings(Snore::SnorePlugin *plugin, QWidget *parent) :
|
|
||||||
Snore::PluginSettingsWidget(plugin, parent),
|
|
||||||
m_lineEdit(new QLineEdit)
|
|
||||||
{
|
|
||||||
addRow(tr("Api Key:"), m_lineEdit, tr("The api key which can be found in your account page at <a href=\"http://notifymyandroid.com/\">Notifymyandroid.com</a>."));
|
|
||||||
addRow(QString(), new QLabel(tr("If you don't have an account yet please register at <a href=\"http://notifymyandroid.com/\">Notifymyandroid.com</a>."), this));
|
|
||||||
}
|
|
||||||
|
|
||||||
NMASettings::~NMASettings()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void NMASettings::load()
|
|
||||||
{
|
|
||||||
m_lineEdit->setText(settingsValue(NMAConstants::ApiKey).toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void NMASettings::save()
|
|
||||||
{
|
|
||||||
setSettingsValue(NMAConstants::ApiKey, m_lineEdit->text());
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
/*
|
|
||||||
SnoreNotify is a Notification Framework based on Qt
|
|
||||||
Copyright (C) 2015 Hannah 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 "libsnore/plugins/settingsplugin.h"
|
|
||||||
#include "libsnore/settings/pluginsettingswidget.h"
|
|
||||||
|
|
||||||
class QLineEdit;
|
|
||||||
|
|
||||||
class NMASettings : public Snore::PluginSettingsWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit NMASettings(Snore::SnorePlugin *plugin, QWidget *parent = 0);
|
|
||||||
~NMASettings();
|
|
||||||
|
|
||||||
void load() override;
|
|
||||||
void save() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
QLineEdit *m_lineEdit;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
SNORE_DECLARE_SETTINGS_PLUGIN(NMA)
|
|
||||||
|
|
||||||
#endif // NOTIFYMYANDROID_HH
|
|
Loading…
Reference in New Issue