diff options
-rw-r--r-- | src/notifications.cpp | 22 | ||||
-rw-r--r-- | tests/test-notification.cpp | 2 | ||||
-rw-r--r-- | tests/test-sound.cpp | 2 |
3 files changed, 19 insertions, 7 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 } diff --git a/tests/test-notification.cpp b/tests/test-notification.cpp index d660982..d04cc8d 100644 --- a/tests/test-notification.cpp +++ b/tests/test-notification.cpp @@ -63,7 +63,7 @@ TEST_F(NotificationFixture,Notification) bool expected_notify_called; bool expected_vibrate_called; } test_appts[] = { - { appt, "calendar", "Event", true, true }, + { appt, "calendar-app", "Event", true, true }, { ualarm, "alarm-clock", "Alarm", true, true } }; diff --git a/tests/test-sound.cpp b/tests/test-sound.cpp index 013c388..0d80109 100644 --- a/tests/test-sound.cpp +++ b/tests/test-sound.cpp @@ -85,7 +85,7 @@ TEST_F(NotificationFixture, InteractiveDuration) // confirm that the icon passed to Notify was "alarm-clock" g_variant_get_child (params, 2, "&s", &str); - ASSERT_STREQ("calendar", str); + ASSERT_STREQ("calendar-app", str); // confirm that the hints passed to Notify included a timeout matching duration_minutes int32_t i32; |