mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-04-17 20:08:28 +00:00
exemple notif
This commit is contained in:
parent
bf25a1c86e
commit
c876913201
3 changed files with 57 additions and 12 deletions
|
|
@ -26,8 +26,12 @@ set(QT_PACKAGES Quick Qml Widgets Svg Test NetworkAuth Concurrent)# Search Core
|
||||||
if (UNIX AND NOT APPLE)
|
if (UNIX AND NOT APPLE)
|
||||||
list(APPEND QT_PACKAGES DBus)
|
list(APPEND QT_PACKAGES DBus)
|
||||||
endif()
|
endif()
|
||||||
find_package(Qt6 REQUIRED COMPONENTS Core)
|
# foreach(package ${Qt_PACKAGES})
|
||||||
find_package(Qt6 REQUIRED COMPONENTS ${QT_PACKAGES})
|
# find_package(Qt6 REQUIRED COMPONENTS ${package})
|
||||||
|
# endforeach()
|
||||||
|
|
||||||
|
find_package(Qt6 REQUIRED COMPONENTS Core DBus Svg Test NetworkAuth Concurrent)
|
||||||
|
find_package(Qt6 REQUIRED COMPONENTS)
|
||||||
find_package(Qt6 REQUIRED COMPONENTS LinguistTools)
|
find_package(Qt6 REQUIRED COMPONENTS LinguistTools)
|
||||||
|
|
||||||
find_package(ECM REQUIRED NO_MODULE)
|
find_package(ECM REQUIRED NO_MODULE)
|
||||||
|
|
@ -230,11 +234,12 @@ foreach(T ${APP_TARGETS})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
target_link_libraries(${TARGET_NAME} PRIVATE Qt6::Core)
|
target_link_libraries(${TARGET_NAME} PRIVATE Qt6::Core)
|
||||||
|
target_link_libraries(${TARGET_NAME} PRIVATE Qt6::DBus)
|
||||||
foreach(T ${QT_PACKAGES})
|
foreach(T ${QT_PACKAGES})
|
||||||
target_link_libraries(${TARGET_NAME} PRIVATE Qt6::${T})
|
target_link_libraries(${TARGET_NAME} PRIVATE Qt6::${T})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
target_link_libraries(${TARGET_NAME} PRIVATE KF6::Notifications)
|
||||||
|
|
||||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake" "${CMAKE_CURRENT_BINARY_DIR}/config.h")
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake" "${CMAKE_CURRENT_BINARY_DIR}/config.h")
|
||||||
|
|
||||||
|
|
@ -256,5 +261,5 @@ elseif(WIN32)
|
||||||
install(FILES linphone.notifyrc DESTINATION "data/knotifications6/" TYPE BIN)
|
install(FILES linphone.notifyrc DESTINATION "data/knotifications6/" TYPE BIN)
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
# macOS : ~/Library/Application Support/linphone/knotifications6/
|
# macOS : ~/Library/Application Support/linphone/knotifications6/
|
||||||
install(FILES linphone.notifyrc DESTINATION "linphone/knotifications6/" TYPE BIN)
|
install(FILES linphone.notifyrc DESTINATION "linphone/knotifications6/")
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,10 @@
|
||||||
#include "tool/LinphoneEnums.hpp"
|
#include "tool/LinphoneEnums.hpp"
|
||||||
|
|
||||||
#include "App.hpp"
|
#include "App.hpp"
|
||||||
|
#include <KNotification>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
#include <QDBusInterface>
|
||||||
|
#include <QDBusReply>
|
||||||
#include <QDirIterator>
|
#include <QDirIterator>
|
||||||
#include <QFileSelector>
|
#include <QFileSelector>
|
||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
|
|
@ -279,6 +281,34 @@ void App::setAutoStart(bool enabled) {
|
||||||
|
|
||||||
#endif // ifdef Q_OS_LINUX
|
#endif // ifdef Q_OS_LINUX
|
||||||
|
|
||||||
|
void App::sendNotification(const QString &title, const QString &message) {
|
||||||
|
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||||
|
if (!bus.isConnected()) {
|
||||||
|
lDebug() << "DBus sessionBus non connecté";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lDebug() << "dbus conected";
|
||||||
|
|
||||||
|
QDBusInterface iface("org.freedesktop.Notifications", "/org/freedesktop/Notifications",
|
||||||
|
"org.freedesktop.Notifications", bus);
|
||||||
|
|
||||||
|
if (!iface.isValid()) {
|
||||||
|
lDebug() << "Interface DBus invalide";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QVariant> args;
|
||||||
|
args << QStringLiteral("linphone") << quint32(0) << QString() << title << message << QStringList() << QVariantMap()
|
||||||
|
<< int(5000);
|
||||||
|
|
||||||
|
QDBusMessage reply = iface.callWithArgumentList(QDBus::AutoDetect, QStringLiteral("Notify"), args);
|
||||||
|
if (reply.type() == QDBusMessage::ErrorMessage) {
|
||||||
|
lDebug() << "Erreur Notify:" << reply.errorMessage();
|
||||||
|
} else {
|
||||||
|
lDebug() << "Notification envoyée";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// End Autostart
|
// End Autostart
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -559,7 +589,7 @@ void App::setSelf(QSharedPointer<App>(me)) {
|
||||||
});
|
});
|
||||||
mCoreModelConnection->makeConnectToCore(&App::lForceOidcTimeout, [this] {
|
mCoreModelConnection->makeConnectToCore(&App::lForceOidcTimeout, [this] {
|
||||||
qDebug() << "App: force oidc timeout";
|
qDebug() << "App: force oidc timeout";
|
||||||
mCoreModelConnection->invokeToModel([this] { emit CoreModel::getInstance() -> forceOidcTimeout(); });
|
mCoreModelConnection->invokeToModel([this] { emit CoreModel::getInstance()->forceOidcTimeout(); });
|
||||||
});
|
});
|
||||||
mCoreModelConnection->makeConnectToModel(&CoreModel::timeoutTimerStarted, [this]() {
|
mCoreModelConnection->makeConnectToModel(&CoreModel::timeoutTimerStarted, [this]() {
|
||||||
qDebug() << "App: oidc timer started";
|
qDebug() << "App: oidc timer started";
|
||||||
|
|
@ -862,9 +892,17 @@ void App::initCore() {
|
||||||
}
|
}
|
||||||
if (mSettings->autoCheckForUpdateOnStart()) checkForUpdate();
|
if (mSettings->autoCheckForUpdateOnStart()) checkForUpdate();
|
||||||
setIsRestarting(false);
|
setIsRestarting(false);
|
||||||
|
lDebug() << "test notif";
|
||||||
|
auto *n = new KNotification("call");
|
||||||
|
n->setTitle("Test");
|
||||||
|
n->setText("Bonjour");
|
||||||
|
n->sendEvent();
|
||||||
window->show();
|
window->show();
|
||||||
window->requestActivate();
|
window->requestActivate();
|
||||||
|
|
||||||
|
lDebug() << "test notif dbus";
|
||||||
|
sendNotification("Notif dbus", "Message dbus");
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------
|
||||||
lDebug() << log().arg("Creating KeyboardShortcuts");
|
lDebug() << log().arg("Creating KeyboardShortcuts");
|
||||||
KeyboardShortcuts::create(getMainWindow());
|
KeyboardShortcuts::create(getMainWindow());
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,8 @@ public:
|
||||||
static Thread *getLinphoneThread();
|
static Thread *getLinphoneThread();
|
||||||
Notifier *getNotifier() const;
|
Notifier *getNotifier() const;
|
||||||
|
|
||||||
|
void sendNotification(const QString &title, const QString &message);
|
||||||
|
|
||||||
EventCountNotifier *getEventCountNotifier();
|
EventCountNotifier *getEventCountNotifier();
|
||||||
int getEventCount() const;
|
int getEventCount() const;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue