aboutsummaryrefslogtreecommitdiff
path: root/src/notifications.cpp
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@canonical.com>2016-04-27 14:31:28 -0300
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-08-29 14:37:39 +0200
commit7ecfadf5eb61fe32332293ec6de2fe18bfedf0fa (patch)
tree7744b8e3b4df771805d4ff600dfaab356eac479e /src/notifications.cpp
parent02ea97a63928c5da4ca1882d34ae61076b06c945 (diff)
downloadayatana-indicator-datetime-7ecfadf5eb61fe32332293ec6de2fe18bfedf0fa.tar.gz
ayatana-indicator-datetime-7ecfadf5eb61fe32332293ec6de2fe18bfedf0fa.tar.bz2
ayatana-indicator-datetime-7ecfadf5eb61fe32332293ec6de2fe18bfedf0fa.zip
Only creates messaging menu if calendar app is instaled. Update tests.
Diffstat (limited to 'src/notifications.cpp')
-rw-r--r--src/notifications.cpp22
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
}