Commit b616a249 authored by Linus Jahn's avatar Linus Jahn Committed by GitHub

Add LibNotify-Linux notifications (#90)

This adds notifications using libnotify, but not native (it's only executing the command).
The new dependency is: `libnotify-bin`

Another TODO is to resolve the nicknames from the JIDs.
parent 6fe4cef1
......@@ -113,6 +113,10 @@ if(SAILFISH_OS)
SAILFISH_OS=True
PLATFORM_DISPLAY_NAME="Sailfish OS"
)
else()
set(KAIDAN_COMPILE_DEFINITIONS
NOTIFICATIONS_LIBNOTIFY=True
)
endif()
target_compile_definitions(${PROJECT_NAME} PRIVATE
......
......@@ -34,7 +34,7 @@ Create a working directory
Install dependencies to build Kaidan (for Debian Stretch and Sid)
* `sudo apt-get install git-core cmake build-essential zlib1g-dev libglib2.0-dev libssl-dev libxml2-dev libcrypto++-dev libpthread-stubs0-dev libidn11-dev libminiupnpc-dev libnatpmp-dev libswiften-dev libboost-system-dev libboost-program-options-dev libboost-serialization-dev libqt5quick5 libqt5quickcontrols2-5 libqt5quickwidgets5 libqt5qml5 libqt5gui5 libqt5core5a qtdeclarative5-dev qttools5-dev qt5-default qml-module-qtquick-controls2`
* `sudo apt-get install git-core cmake build-essential zlib1g-dev libglib2.0-dev libssl-dev libxml2-dev libcrypto++-dev libpthread-stubs0-dev libidn11-dev libminiupnpc-dev libnatpmp-dev libswiften-dev libboost-system-dev libnotify-bin libboost-program-options-dev libboost-serialization-dev libqt5quick5 libqt5quickcontrols2-5 libqt5quickwidgets5 libqt5qml5 libqt5gui5 libqt5core5a qtdeclarative5-dev qttools5-dev qt5-default qml-module-qtquick-controls2`
Debian currently has no Kirigami2 packages, so we have to install them from external sources.
......
......@@ -8,6 +8,7 @@ set(KAIDAN_SOURCES
${CURDIR}/RosterModel.cpp
${CURDIR}/MessageController.cpp
${CURDIR}/MessageModel.cpp
${CURDIR}/Notifications.cpp
${CURDIR}/PresenceController.cpp
${CURDIR}/ServiceDiscoveryManager.cpp
${CURDIR}/VCard.cpp
......
......@@ -35,6 +35,7 @@
#include <Swiften/Swiften.h>
// Kaidan
#include "MessageModel.h"
#include "Notifications.h"
MessageController::MessageController(QString* ownJid_, QObject *parent) : QObject(parent)
{
......@@ -114,6 +115,12 @@ void MessageController::handleMessageReceived(Swift::Message::ref message_)
&recipient_resource, &timestamp, &message, &msgId, false);
emit messageModelChanged();
// send a new notification | TODO: Resolve nickname from JID
Notifications::sendMessageNotification(
message_->getFrom().toBare().toString(),
*bodyOpt
);
}
// XEP-0184: Message Delivery Receipts
......
/*
* Kaidan - Cross platform XMPP client
*
* Copyright (C) 2017 LNJ <git@lnj.li>
*
* 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.
*
* 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"
void Notifications::sendMessageNotification(std::string fromName, std::string message)
{
#ifdef NOTIFICATIONS_LIBNOTIFY
std::string command = "notify-send \"" + fromName + ": " + message + "\" -a kaidan -i kaidan -t 4000";
system(command.c_str());
#endif
}
/*
* Kaidan - Cross platform XMPP client
*
* Copyright (C) 2017 LNJ <git@lnj.li>
*
* 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.
*
* 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/>.
*/
#include <string>
namespace Notifications {
void sendMessageNotification(std::string fromName, std::string message);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment