diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2022-02-08 22:05:22 +0100 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2022-02-08 22:05:22 +0100 |
commit | b439ad041ff4478453f0bd4e00f55224d653c69b (patch) | |
tree | d04a05b67e5e7d325ca5f18a567906bcaefad6e1 /src | |
parent | 4e9da1fb0791336cc25b323aed3bbbb20c1b9fb5 (diff) | |
parent | 91af5e2854d40d06515416b4b89eb66b346ebe56 (diff) | |
download | ayatana-indicator-datetime-b439ad041ff4478453f0bd4e00f55224d653c69b.tar.gz ayatana-indicator-datetime-b439ad041ff4478453f0bd4e00f55224d653c69b.tar.bz2 ayatana-indicator-datetime-b439ad041ff4478453f0bd4e00f55224d653c69b.zip |
Merge branch 'tari01-pr/fix-cppcheck-suppressions'
Attributes GH PR #86: https://github.com/AyatanaIndicators/ayatana-indicator-datetime/pull/86
Diffstat (limited to 'src')
-rw-r--r-- | src/actions.cpp | 14 | ||||
-rw-r--r-- | src/engine-eds.cpp | 22 | ||||
-rw-r--r-- | src/exporter.cpp | 10 | ||||
-rw-r--r-- | src/haptic.cpp | 2 | ||||
-rw-r--r-- | src/locations-settings.cpp | 16 | ||||
-rw-r--r-- | src/menu.cpp | 16 | ||||
-rw-r--r-- | src/notifications.cpp | 2 | ||||
-rw-r--r-- | src/planner-aggregate.cpp | 4 | ||||
-rw-r--r-- | src/wakeup-timer-mainloop.cpp | 4 | ||||
-rw-r--r-- | src/wakeup-timer-powerd.cpp | 4 |
10 files changed, 57 insertions, 37 deletions
diff --git a/src/actions.cpp b/src/actions.cpp index 315340a..c184aef 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -1,5 +1,6 @@ /* * Copyright 2013 Canonical Ltd. + * Copyright 2021 Robert Tari * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published @@ -15,11 +16,12 @@ * * Authors: * Charles Kerr <charles.kerr@canonical.com> + * Robert Tari <robert@tari.in> */ #include <datetime/actions.h> #include <datetime/utils.h> // split_settings_location() - +#include <algorithm> #include <glib.h> #include <gio/gio.h> @@ -50,16 +52,18 @@ DateTime datetime_from_timet_variant(GVariant* v) bool lookup_appointment_by_uid(const std::shared_ptr<State>& state, const gchar* uid, Appointment& setme) { - for(const auto& appt : state->calendar_upcoming->appointments().get()) + bool bRet = false; + + std::for_each(state->calendar_upcoming->appointments().get().begin(), state->calendar_upcoming->appointments().get().end(), [uid, &setme, &bRet](const Appointment& appt) { if (appt.uid == uid) { setme = appt; - return true; + bRet = true; } - } + }); - return false; + return bRet; } void on_appointment_activated (GSimpleAction*, GVariant *vdata, gpointer gself) diff --git a/src/engine-eds.cpp b/src/engine-eds.cpp index 4396d45..b7f4682 100644 --- a/src/engine-eds.cpp +++ b/src/engine-eds.cpp @@ -19,6 +19,10 @@ * Robert Tari <robert@tari.in> */ +#ifndef ALARM_DEFAULT_SOUND +#define ALARM_DEFAULT_SOUND "dummy" +#endif + #include <datetime/engine-eds.h> #include <datetime/myself.h> #include <libical/ical.h> @@ -48,7 +52,7 @@ class EdsEngine::Impl { public: - Impl(const std::shared_ptr<Myself> &myself) + explicit Impl(const std::shared_ptr<Myself> &myself) : m_myself(myself) { auto cancellable_deleter = [](GCancellable * c) { @@ -473,14 +477,14 @@ private: // for each component.. for (auto l=components; l!=nullptr; l=l->next) { - bool changed = false; + bool bChanged = false; // for each alarm... auto component = E_CAL_COMPONENT(l->data); auto auids = e_cal_component_get_alarm_uids(component); - for(auto l=auids; l!=nullptr; l=l->next) + for(auto lAlarms=auids; lAlarms!=nullptr; lAlarms=lAlarms->next) { - auto auid = static_cast<const char*>(l->data); + auto auid = static_cast<const char*>(lAlarms->data); auto alarm = e_cal_component_get_alarm(component, auid); if (alarm == nullptr) continue; @@ -490,13 +494,13 @@ private: { e_cal_component_remove_alarm (component, auid); e_cal_component_add_alarm (component, new_alarm); - changed = true; + bChanged = true; g_clear_pointer (&new_alarm, e_cal_component_alarm_free); } } g_slist_free_full (auids, g_free); - if (changed) + if (bChanged) { auto icc = e_cal_component_get_icalcomponent(component); // icc owned by ecc modify_slist = g_slist_prepend(modify_slist, icc); @@ -1127,9 +1131,9 @@ private: alarm.text = get_alarm_text(a); if (alarm.audio_url.empty()) - alarm.audio_url = get_alarm_sound_url(a, (baseline.is_alarm() ? - "file://" ALARM_DEFAULT_SOUND : - "file://" CALENDAR_DEFAULT_SOUND)); + { + alarm.audio_url = get_alarm_sound_url(a, (baseline.is_alarm() ? "file://" ALARM_DEFAULT_SOUND : "file://" CALENDAR_DEFAULT_SOUND)); + } if (!alarm.time.is_set()) alarm.time = trigger_time; diff --git a/src/exporter.cpp b/src/exporter.cpp index ea514c0..41a1583 100644 --- a/src/exporter.cpp +++ b/src/exporter.cpp @@ -1,5 +1,6 @@ /* * Copyright 2013 Canonical Ltd. + * Copyright 2021 Robert Tari * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published @@ -15,6 +16,7 @@ * * Authors: * Charles Kerr <charles.kerr@canonical.com> + * Robert Tari <robert@tari.in> */ #include <datetime/dbus-shared.h> @@ -37,7 +39,7 @@ class Exporter::Impl { public: - Impl(const std::shared_ptr<Settings>& settings): + explicit Impl(const std::shared_ptr<Settings>& settings): m_settings(settings), m_alarm_props(datetime_alarm_properties_skeleton_new()) { @@ -190,10 +192,10 @@ private: for(auto& menu : m_menus) { const auto path = std::string(BUS_DATETIME_PATH) + "/" + menu->name(); - const auto id = g_dbus_connection_export_menu_model(m_bus, path.c_str(), menu->menu_model(), &error); - if (id) + const auto nId = g_dbus_connection_export_menu_model(m_bus, path.c_str(), menu->menu_model(), &error); + if (nId) { - m_exported_menu_ids.insert(id); + m_exported_menu_ids.insert(nId); } else { diff --git a/src/haptic.cpp b/src/haptic.cpp index 7e09c24..370f0f9 100644 --- a/src/haptic.cpp +++ b/src/haptic.cpp @@ -39,7 +39,7 @@ class Haptic::Impl { public: - Impl(bool repeat): + explicit Impl(bool repeat): m_cancellable(g_cancellable_new()), m_repeat(repeat) { diff --git a/src/locations-settings.cpp b/src/locations-settings.cpp index f1e2b42..2673e66 100644 --- a/src/locations-settings.cpp +++ b/src/locations-settings.cpp @@ -1,5 +1,6 @@ /* * Copyright 2013 Canonical Ltd. + * Copyright 2021 Robert Tari * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published @@ -15,6 +16,7 @@ * * Authors: * Charles Kerr <charles.kerr@canonical.com> + * Robert Tari <robert@tari.in> */ #include <datetime/locations-settings.h> @@ -59,10 +61,10 @@ SettingsLocations::reload() } // add the other detected timezones - for(const auto& zone : m_timezones->timezones.get()) + for(const auto& sZone : m_timezones->timezones.get()) { - gchar * name = get_beautified_timezone_name(zone.c_str(), timezone_name.c_str()); - Location l(zone, name); + gchar * name = get_beautified_timezone_name(sZone.c_str(), timezone_name.c_str()); + Location l(sZone, name); if (std::find(v.begin(), v.end(), l) == v.end()) v.push_back(l); g_free(name); @@ -73,14 +75,14 @@ SettingsLocations::reload() { for(const auto& locstr : m_settings->locations.get()) { - gchar* zone; + gchar* sZone; gchar* name; - split_settings_location(locstr.c_str(), &zone, &name); - Location loc(zone, name); + split_settings_location(locstr.c_str(), &sZone, &name); + Location loc(sZone, name); if (std::find(v.begin(), v.end(), loc) == v.end()) v.push_back(loc); g_free(name); - g_free(zone); + g_free(sZone); } } diff --git a/src/menu.cpp b/src/menu.cpp index ab0bd71..1f80cd4 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -107,10 +107,6 @@ Menu::get_display_appointments(const std::vector<Appointment>& appointments_in, if (a_full_day_today != b_full_day_today) return a_full_day_today; - const bool a_after_today = (a.begin > end_of_day) || (a.end > end_of_day); - const bool b_after_today = (a.begin > end_of_day) || (a.end > end_of_day); - if (a_after_today != b_after_today) - return a_after_today; if (a.begin != b.begin) return a.begin < b.begin; if (b.end != b.end) @@ -554,7 +550,7 @@ protected: update_header(); } - GVariant* create_header_state() + GVariant* create_header_state() override { const auto title = _("Date and Time"); auto label = g_variant_new_string(m_formatter->header.get().c_str()); @@ -597,13 +593,19 @@ protected: update_header(); } - GVariant* create_header_state() + GVariant* create_header_state() override { // are there alarms? bool has_alarms = false; for(const auto& appointment : m_upcoming) - if((has_alarms = appointment.is_alarm())) + { + has_alarms = appointment.is_alarm(); + + if (has_alarms) + { break; + } + } GVariantBuilder b; g_variant_builder_init(&b, G_VARIANT_TYPE_VARDICT); diff --git a/src/notifications.cpp b/src/notifications.cpp index e38e5dc..bb0e05c 100644 --- a/src/notifications.cpp +++ b/src/notifications.cpp @@ -165,7 +165,7 @@ class Engine::Impl public: - Impl(const std::string& app_name): + explicit Impl(const std::string& app_name): m_app_name(app_name) { if (!notify_init(app_name.c_str())) diff --git a/src/planner-aggregate.cpp b/src/planner-aggregate.cpp index 23a1230..3b05ea1 100644 --- a/src/planner-aggregate.cpp +++ b/src/planner-aggregate.cpp @@ -1,5 +1,6 @@ /* * Copyright 2014 Canonical Ltd. + * Copyright 2021 Robert Tari * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published @@ -15,6 +16,7 @@ * * Authors: * Charles Kerr <charles.kerr@canonical.com> + * Robert Tari <robert@tari.in> */ #include <datetime/planner-aggregate.h> @@ -30,7 +32,7 @@ namespace datetime { class AggregatePlanner::Impl { public: - Impl(AggregatePlanner* owner): + explicit Impl(AggregatePlanner* owner): m_owner(owner) { } diff --git a/src/wakeup-timer-mainloop.cpp b/src/wakeup-timer-mainloop.cpp index 56961f2..738306c 100644 --- a/src/wakeup-timer-mainloop.cpp +++ b/src/wakeup-timer-mainloop.cpp @@ -1,5 +1,6 @@ /* * Copyright 2014 Canonical Ltd. + * Copyright 2021 Robert Tari * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published @@ -15,6 +16,7 @@ * * Authors: * Charles Kerr <charles.kerr@canonical.com> + * Robert Tari <robert@tari.in> */ #include <datetime/wakeup-timer-mainloop.h> @@ -36,7 +38,7 @@ class MainloopWakeupTimer::Impl public: - Impl(const std::shared_ptr<Clock>& clock): + explicit Impl(const std::shared_ptr<Clock>& clock): m_clock(clock) { } diff --git a/src/wakeup-timer-powerd.cpp b/src/wakeup-timer-powerd.cpp index e66c94c..f775999 100644 --- a/src/wakeup-timer-powerd.cpp +++ b/src/wakeup-timer-powerd.cpp @@ -1,5 +1,6 @@ /* * Copyright 2014 Canonical Ltd. + * Copyright 2021 Robert Tari * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published @@ -15,6 +16,7 @@ * * Authors: * Charles Kerr <charles.kerr@canonical.com> + * Robert Tari <robert@tari.in> */ #include <datetime/clock.h> @@ -38,7 +40,7 @@ class PowerdWakeupTimer::Impl { public: - Impl(const std::shared_ptr<Clock>& clock): + explicit Impl(const std::shared_ptr<Clock>& clock): m_clock(clock), m_cancellable(g_cancellable_new()) { |