...
 
Commits (1)
......@@ -54,7 +54,7 @@ kde_enable_exceptions()
# Find packages
find_package(PkgConfig REQUIRED)
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Qml Quick Svg Sql QuickControls2 Xml)
find_package(KF5Kirigami2 REQUIRED)
find_package(KF5 COMPONENTS Kirigami2 Notifications REQUIRED)
pkg_search_module(QXmpp REQUIRED qxmpp>=0.9)
# Optional QtQuickCompiler
......@@ -159,6 +159,7 @@ target_link_libraries(${PROJECT_NAME}
Qt5::Svg
Qt5::Network
Qt5::Xml
KF5::Notifications
${__Qt5Widgets_LIBRARIES}
# currently needs to be hardcoded for windows builds
qxmpp
......
......@@ -171,7 +171,7 @@ void MessageHandler::handleMessage(const QXmppMessage &msg)
contactName = contactJid;
if (!entry.sentByMe)
Notifications::sendMessageNotification(contactName.toStdString(),
notifications.sendNotification(contactName.toStdString(),
msg.body().toStdString());
// TODO: Move back following call to RosterManager::handleMessage when spoiler
......
......@@ -39,6 +39,7 @@
#include <QXmppMessageReceiptManager.h>
// Kaidan
#include "Enums.h"
#include "Notifications.h"
class Kaidan;
class MessageModel;
......@@ -93,6 +94,7 @@ private:
QXmppCarbonManager *carbonManager;
#endif
QString chatPartner;
Notifications notifications;
};
#endif // MESSAGEHANDLER_H
/*
* Kaidan - A user-friendly XMPP client for every device!
*
* Copyright (C) 2016-2019 Kaidan developers and contributors
* (see the LICENSE file for a full list of copyright authors)
*
* Kaidan 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.
*
* In addition, as a special exception, the author of Kaidan gives
* permission to link the code of its release with the OpenSSL
* project's "OpenSSL" library (or with modified versions of it that
* use the same license as the "OpenSSL" library), and distribute the
* linked executables. You must obey the GNU General Public License in
* all respects for all of the code used other than "OpenSSL". If you
* modify this file, you may extend this exception to your version of
* the file, but you are not obligated to do so. If you do not wish to
* do so, delete this exception statement from your version.
*
* Kaidan 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 Kaidan. If not, see <http://www.gnu.org/licenses/>.
*/
// Kaidan
#include "Notifications.h"
#include "Globals.h"
#include <QDebug>
Notifications::Notifications(QObject *parent) : QObject(parent)
{
}
void Notifications::sendMessageNotification(std::string fromName, std::string message)
void Notifications::sendNotification()
{
#ifdef NOTIFICATIONS_LIBNOTIFY
std::string command = "notify-send \"" + fromName + ": " + message + "\" -a kaidan -i kaidan -t 7000";
system(command.c_str());
#endif
KNotification *notification = new KNotification("message");
notification->setTitle(APPLICATION_DISPLAY_NAME);
notification->setText("Moooooooin Leude!");
notification->setActions( QStringList("Open chat"));
notification->sendEvent();
qDebug() << "\n\n\n ####### Moin Leude sent!!! \n\n\n";
}
/*
* Kaidan - A user-friendly XMPP client for every device!
*
* Copyright (C) 2016-2019 Kaidan developers and contributors
* (see the LICENSE file for a full list of copyright authors)
*
* Kaidan 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.
*
* In addition, as a special exception, the author of Kaidan gives
* permission to link the code of its release with the OpenSSL
* project's "OpenSSL" library (or with modified versions of it that
* use the same license as the "OpenSSL" library), and distribute the
* linked executables. You must obey the GNU General Public License in
* all respects for all of the code used other than "OpenSSL". If you
* modify this file, you may extend this exception to your version of
* the file, but you are not obligated to do so. If you do not wish to
* do so, delete this exception statement from your version.
*
* Kaidan 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 Kaidan. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NOTIFICATIONS_H
#define NOTIFICATIONS_H
#include <string>
#include <QObject>
#include <KNotification>
namespace Notifications
class Notifications : public QObject
{
void sendMessageNotification(std::string fromName, std::string message);
}
Q_OBJECT
public:
Notifications(QObject *parent = nullptr);
signals:
public slots:
void sendNotification();
};
#endif // NOTIFICATIONS_H