diff options
author | Renato Araujo Oliveira Filho <renato.filho@canonical.com> | 2016-04-27 14:31:28 -0300 |
---|---|---|
committer | Robert Tari <robert@tari.in> | 2021-07-06 11:49:07 +0200 |
commit | 76e3bd94724e9bc7bedd24548103e31d85334d53 (patch) | |
tree | 7ae6ec836aba1b2d29c780b765760d7b22ed8b43 /src/notifications.cpp | |
parent | ec226fce51ed4ba7f16c5f1d3f87c180c6335918 (diff) | |
download | ayatana-indicator-datetime-76e3bd94724e9bc7bedd24548103e31d85334d53.tar.gz ayatana-indicator-datetime-76e3bd94724e9bc7bedd24548103e31d85334d53.tar.bz2 ayatana-indicator-datetime-76e3bd94724e9bc7bedd24548103e31d85334d53.zip |
Only creates messaging menu if calendar app is instaled. Update tests.
Diffstat (limited to 'src/notifications.cpp')
-rw-r--r-- | src/notifications.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/notifications.cpp b/src/notifications.cpp index dc42534..9817686 100644 --- a/src/notifications.cpp +++ b/src/notifications.cpp @@ -150,14 +150,17 @@ class Engine::Impl public: Impl(const std::string& app_name): - m_messaging_app(messaging_menu_app_new(calendar_app_id().c_str()), g_object_unref), m_app_name(app_name) { if (!notify_init(app_name.c_str())) g_critical("Unable to initialize libnotify!"); // messaging menu - messaging_menu_app_register(m_messaging_app.get()); + auto app_id = calendar_app_id(); + if (!app_id.empty()) { + m_messaging_app.reset(messaging_menu_app_new(app_id.c_str()), g_object_unref); + messaging_menu_app_register(m_messaging_app.get()); + } } ~Impl() @@ -166,7 +169,8 @@ public: remove_all (); notify_uninit (); - messaging_menu_app_unregister (m_messaging_app.get()); + if (m_messaging_app) + messaging_menu_app_unregister (m_messaging_app.get()); } const std::string& app_name() const @@ -280,6 +284,9 @@ public: std::string post(const Builder::Impl& data) { + if (!m_messaging_app) { + return std::string(); + } uuid_t message_uuid; uuid_generate(message_uuid); @@ -439,9 +446,14 @@ private: { #ifdef HAS_LOMIRIAPPLAUNCH auto app_id = lomiri::app_launch::AppID::discover("com.lomiri.calendar"); - return std::string(app_id) + ".desktop"; + + if (!app_id.empty()) + return std::string(app_id) + ".desktop"; + else + return std::string(); + #else - return ""; + return std::string(); #endif } |