From 76e3bd94724e9bc7bedd24548103e31d85334d53 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Wed, 27 Apr 2016 14:31:28 -0300 Subject: Only creates messaging menu if calendar app is instaled. Update tests. --- src/notifications.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'src') 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 } -- cgit v1.2.3