~dobey/indicator-datetime/build-parallel

« back to all changes in this revision

Viewing changes to src/snap.cpp

  • Committer: Bileto Bot
  • Date: 2016-06-27 08:46:58 UTC
  • mfrom: (450.1.1 resync-trunk)
  • Revision ID: ci-train-bot@canonical.com-20160627084658-s17qv0l1agjpn1yk
No-change rebuild for libical soname change.

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
                    const Alarm& alarm,
85
85
                    response_func on_response)
86
86
    {
87
 
        // If calendar notifications are disabled, don't show them
88
 
        if (!appointment.is_ubuntu_alarm() && !calendar_notifications_are_enabled()) {
89
 
            g_debug("Skipping disabled calendar event '%s' notification", appointment.summary.c_str());
 
87
        // If calendar notifications are muted, don't show them
 
88
        if (!appointment.is_ubuntu_alarm() && calendar_events_are_muted()) {
 
89
            g_debug("Skipping muted calendar event '%s' notification", appointment.summary.c_str());
90
90
            return;
91
91
        }
92
92
 
97
97
        const bool interactive = appointment.is_ubuntu_alarm() && m_engine->supports_actions();
98
98
 
99
99
        // force the system to stay awake
100
 
        std::shared_ptr<uin::Awake> awake;
101
 
        if (appointment.is_ubuntu_alarm() || calendar_bubbles_enabled() || calendar_list_enabled()) {
102
 
            awake = std::make_shared<uin::Awake>(m_engine->app_name());
103
 
        }
 
100
        auto awake = std::make_shared<uin::Awake>(m_engine->app_name());
104
101
 
105
102
        // calendar events are muted in silent mode; alarm clocks never are
106
103
        std::shared_ptr<uin::Sound> sound;
107
 
        if (appointment.is_ubuntu_alarm() || (calendar_sounds_enabled() && !silent_mode())) {
 
104
        // FIXME: only play sounds for alarms for now, we should itegrate it with
 
105
        // system settings to decide if we should play sounds for calendar notification or not
 
106
        if (appointment.is_ubuntu_alarm()) {
108
107
            // create the sound.
109
108
            const auto role = appointment.is_ubuntu_alarm() ? "alarm" : "alert";
110
109
            const auto uri = get_alarm_uri(appointment, alarm, m_settings);
115
114
 
116
115
        // create the haptic feedback...
117
116
        std::shared_ptr<uin::Haptic> haptic;
118
 
        if (should_vibrate() && (appointment.is_ubuntu_alarm() || calendar_vibrations_enabled())) {
119
 
            // when in silent mode should only vibrate if user defined so
120
 
            if (!silent_mode() || vibrate_in_silent_mode_enabled()) {
121
 
                const auto haptic_mode = m_settings->alarm_haptic.get();
122
 
                if (haptic_mode == "pulse")
123
 
                    haptic = std::make_shared<uin::Haptic>(uin::Haptic::MODE_PULSE, appointment.is_ubuntu_alarm());
124
 
            }
 
117
        if (should_vibrate()) {
 
118
            const auto haptic_mode = m_settings->alarm_haptic.get();
 
119
            if (haptic_mode == "pulse")
 
120
                haptic = std::make_shared<uin::Haptic>(uin::Haptic::MODE_PULSE, appointment.is_ubuntu_alarm());
125
121
        }
126
122
 
127
123
        // show a notification...
184
180
            });
185
181
        }
186
182
 
187
 
        b.set_show_notification_bubble(appointment.is_ubuntu_alarm() || calendar_bubbles_enabled());
188
 
        b.set_post_to_messaging_menu(appointment.is_ubuntu_alarm() || calendar_list_enabled());
189
 
 
190
183
        const auto key = m_engine->show(b);
191
184
        if (key)
192
185
            m_notifications.insert (key);
194
187
 
195
188
private:
196
189
 
197
 
    bool calendar_notifications_are_enabled() const
198
 
    {
199
 
        return m_settings->cal_notification_enabled.get();
200
 
    }
201
 
 
202
 
    bool calendar_sounds_enabled() const
203
 
    {
204
 
        return m_settings->cal_notification_sounds.get();
205
 
    }
206
 
 
207
 
    bool calendar_vibrations_enabled() const
208
 
    {
209
 
        return m_settings->cal_notification_vibrations.get();
210
 
    }
211
 
 
212
 
    bool calendar_bubbles_enabled() const
213
 
    {
214
 
        return m_settings->cal_notification_bubbles.get();
215
 
    }
216
 
 
217
 
    bool calendar_list_enabled() const
218
 
    {
219
 
        return m_settings->cal_notification_list.get();
220
 
    }
221
 
 
222
 
    bool vibrate_in_silent_mode_enabled() const
223
 
    {
224
 
        return m_settings->vibrate_silent_mode.get();
 
190
    bool calendar_events_are_muted() const
 
191
    {
 
192
        for(const auto& app : m_settings->muted_apps.get()) {
 
193
            if (app.first == "com.ubuntu.calendar") {
 
194
                return true;
 
195
            }
 
196
        }
 
197
 
 
198
        return false;
225
199
    }
226
200
 
227
201
    static void on_sound_proxy_ready(GObject* /*source_object*/, GAsyncResult* res, gpointer gself)