From 846dfb9d7b16aec7923444083256a8565f308013 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Thu, 28 Apr 2016 09:35:05 -0300 Subject: Small fixes requeted by charles during the review. --- src/main.cpp | 1 - src/notifications.cpp | 39 +++++++++++++++++---------------------- src/snap.cpp | 2 +- 3 files changed, 18 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index f9a934a..729f0e5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -157,7 +157,6 @@ main(int /*argc*/, char** /*argv*/) snooze_planner->add(appointment, alarm); }; auto on_ok = [actions](const Appointment& app, const Alarm&){ - //TODO: add support for desktop actions->phone_open_appointment(app, app.begin); }; auto on_alarm_reached = [&engine, &snap, &on_snooze, &on_ok](const Appointment& appointment, const Alarm& alarm) { diff --git a/src/notifications.cpp b/src/notifications.cpp index 9817686..3c90e57 100644 --- a/src/notifications.cpp +++ b/src/notifications.cpp @@ -58,11 +58,11 @@ public: std::string m_body; std::string m_icon_name; std::chrono::seconds m_duration; - gint64 m_start_time; + gint64 m_start_time {}; std::set m_string_hints; std::vector> m_actions; std::function m_closed_callback; - std::function m_missed_click_callback; + std::function m_timeout_callback; }; Builder::Builder(): @@ -117,9 +117,9 @@ Builder::set_closed_callback (std::function cb) } void -Builder::set_missed_click_callback (std::function cb) +Builder::set_timeout_callback (std::function cb) { - impl->m_missed_click_callback.swap (cb); + impl->m_timeout_callback.swap (cb); } void @@ -312,7 +312,7 @@ public: data.m_start_time * G_USEC_PER_SEC); // secs -> microsecs if (msg) { - std::shared_ptr msg_data(new messaging_menu_data{message_id, data.m_missed_click_callback, this}); + std::shared_ptr msg_data(new messaging_menu_data{message_id, data.m_timeout_callback, this}); m_messaging_messages[message_id] = msg_data; g_signal_connect(G_OBJECT(msg), "activate", G_CALLBACK(on_message_activated), msg_data.get()); @@ -344,13 +344,8 @@ public: void remove_all () { // call remove() on all our keys - - std::set keys; - for (const auto& it : m_messaging_messages) - keys.insert (it.first); - - for (const std::string &key : keys) - remove (key); + while (!m_messaging_messages.empty()) + remove(m_messaging_messages.begin()->first); } private: @@ -400,7 +395,7 @@ private: gpointer data) { auto msg_data = static_cast(data); - auto it = msg_data->self->m_messaging_messages.find(msg_data->msg_id.c_str()); + auto it = msg_data->self->m_messaging_messages.find(msg_data->msg_id); g_return_if_fail (it != msg_data->self->m_messaging_messages.end()); const auto& ndata = it->second; @@ -411,7 +406,7 @@ private: static void on_message_destroyed(gpointer data) { auto msg_data = static_cast(data); - auto it = msg_data->self->m_messaging_messages.find(msg_data->msg_id.c_str()); + auto it = msg_data->self->m_messaging_messages.find(msg_data->msg_id); if (it != msg_data->self->m_messaging_messages.end()) msg_data->self->m_messaging_messages.erase(it); } @@ -448,6 +443,7 @@ private: auto app_id = lomiri::app_launch::AppID::discover("com.lomiri.calendar"); if (!app_id.empty()) + // Due the use of old API by messaging_menu we need append a extra ".desktop" to the app_id. return std::string(app_id) + ".desktop"; else return std::string(); @@ -463,13 +459,14 @@ private: if (app_desktop != nullptr) { auto icon_name = g_desktop_app_info_get_string(app_desktop, "Icon"); g_object_unref(app_desktop); - std::string result(icon_name); - g_free(icon_name); - return result; - } else { - g_warning("Fail to get calendar icon"); - return std::string(); + if (icon_name) { + std::string result(icon_name); + g_free(icon_name); + return result; + } } + g_warning("Fail to get calendar icon"); + return std::string(); } /*** @@ -490,8 +487,6 @@ private: mutable std::set m_lazy_caps; static constexpr char const * HINT_TIMEOUT {"x-canonical-snap-decisions-timeout"}; - static constexpr char const * DATETIME_INDICATOR_DESKTOP_FILE {"indicator-datetime.desktop"}; - static constexpr char const * DATETIME_INDICATOR_SOURCE_ID {"indicator-datetime"}; }; /*** diff --git a/src/snap.cpp b/src/snap.cpp index 60005f3..4078dd7 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -173,7 +173,7 @@ public: //TODO: we need to extend it to support alarms appoitments if (!appointment.is_ubuntu_alarm()) { - b.set_missed_click_callback([appointment, alarm, ok](){ + b.set_timeout_callback([appointment, alarm, ok](){ ok(appointment, alarm); }); } -- cgit v1.2.3