~ubuntu-branches/ubuntu/utopic/gossip/utopic

« back to all changes in this revision

Viewing changes to src/gossip-sound.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2006-10-17 11:15:38 UTC
  • mfrom: (1.1.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20061017111538-8dhxm4g1uoesb0hm
Tags: 0.18-0ubuntu1
* New upstream release:
  - Fixed "Fix crash in src/gossip-galago.c due to missing presence states"
  - Fixed "Fix white space bugs"
  - Fixed "Redesign adding a contact to a GtkDialog instead of GnomeDruid"
  - Fixed "Fix wrong linking order"
  - Fixed "Does not compile on Ubuntu Dapper Drake" 
  - Fixed "Scroll to contact name in history window" 
  - Fixed "The accounts dialog should use widget sets for known protocols"
  - Fixed "Contact information window should appear on the same desktop"
  - Fixed "Remove protocol specific instances of gossip_account_[set,get]_*"
  - Fixed "Use g_base64_[decode/encode] instead of our version"
  - Fixed "Bad glist usage, use g_list_prepend instead"
  - Fixed "Use GtkLinkButton instead of GnomeHRef"
  - Fixed "Gossip fails to build with Galago enabled"
  - Fixed "Gossip fails to build due to some errors in peekaboo-galago.c"
  - Fixed "Implement gossip_account_has_param()"
  - Fixed "Empty resource results in invalid JID used to send messages"
  - Translations: Updated el, nl, sv, ne, fi.
* debian/control.in:
  - bumped glib Build-Dep, dropped galago Build-Dep.
  - drop galago references.
* debian/rules:
  - drop --enable-galago.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
#define DEBUG_DOMAIN "Sound"
37
37
 
38
38
/* Time to wait before we use sounds for an account after it has gone
39
 
 * online/offline, so we don't spam the sound with online's, etc 
40
 
 */ 
 
39
 * online/offline, so we don't spam the sound with online's, etc
 
40
 */
41
41
#define SOUND_WAIT_TIME 10000
42
42
 
43
43
static void sound_contact_presence_updated_cb (GossipSession *session,
62
62
                             GossipProtocol *protocol,
63
63
                             gpointer        user_data)
64
64
{
65
 
        guint id;
 
65
        guint        id;
 
66
        const gchar *account_id;
66
67
 
67
68
        if (g_hash_table_lookup (account_states, account)) {
68
69
                return;
69
70
        }
70
71
 
 
72
        gossip_account_param_get (account, "id", &account_id, NULL);
71
73
        gossip_debug (DEBUG_DOMAIN, "Account update, account:'%s' is now online",
72
 
                      gossip_account_get_id (account));
 
74
                      account_id);
73
75
 
74
76
        id = g_timeout_add (SOUND_WAIT_TIME,
75
 
                            (GSourceFunc) sound_protocol_timeout_cb, 
 
77
                            (GSourceFunc) sound_protocol_timeout_cb,
76
78
                            account);
77
79
        g_hash_table_insert (account_states, account, GUINT_TO_POINTER (id));
78
80
}
85
87
        GossipAccount *contact_account;
86
88
 
87
89
        contact_account = gossip_contact_get_account (contact);
88
 
        
 
90
 
89
91
        if (gossip_account_equal (contact_account, account)) {
90
92
                return TRUE;
91
93
        }
125
127
                                      gossip_contact_get_id (contact));
126
128
                        gossip_sound_play (GOSSIP_SOUND_OFFLINE);
127
129
                }
128
 
                        
 
130
 
129
131
                g_hash_table_remove (contact_states, contact);
130
132
        } else {
131
133
                GossipAccount *account;
132
 
                
 
134
 
133
135
                account = gossip_contact_get_account (contact);
134
136
 
135
137
                /* Only show notifications after being online for some
136
138
                 * time instead of spamming notifications each time we
137
139
                 * connect.
138
140
                 */
139
 
                if (!g_hash_table_lookup (account_states, account) && 
 
141
                if (!g_hash_table_lookup (account_states, account) &&
140
142
                    !g_hash_table_lookup (contact_states, contact)) {
141
143
                        gossip_debug (DEBUG_DOMAIN, "Presence update, contact:'%s' is now online",
142
144
                                      gossip_contact_get_id (contact));
143
145
                        gossip_sound_play (GOSSIP_SOUND_ONLINE);
144
146
                }
145
147
 
146
 
                g_hash_table_insert (contact_states, 
147
 
                                     g_object_ref (contact), 
 
148
                g_hash_table_insert (contact_states,
 
149
                                     g_object_ref (contact),
148
150
                                     g_object_ref (presence));
149
151
        }
150
152
}
153
155
gossip_sound_play (GossipSound sound)
154
156
{
155
157
        GossipSession       *session;
156
 
        GossipPresence      *p;
157
 
        GossipPresenceState  state;
 
158
        GossipPresence      *p;
 
159
        GossipPresenceState  state;
158
160
        gboolean             enabled;
159
161
        gboolean             sounds_when_busy;
160
162
        gboolean             sounds_when_away;
184
186
        gossip_conf_get_bool (gossip_conf_get (),
185
187
                               GOSSIP_PREFS_SOUNDS_WHEN_AWAY,
186
188
                               &sounds_when_away);
187
 
        
188
 
        p = gossip_session_get_presence (gossip_app_get_session ());
189
 
        state = gossip_presence_get_state (p);
190
 
 
191
 
        if (!sounds_when_busy && state == GOSSIP_PRESENCE_STATE_BUSY) {
 
189
 
 
190
        p = gossip_session_get_presence (gossip_app_get_session ());
 
191
        state = gossip_presence_get_state (p);
 
192
 
 
193
        if (!sounds_when_busy && state == GOSSIP_PRESENCE_STATE_BUSY) {
192
194
                return;
193
195
        }
194
196
 
195
 
        if (!sounds_when_away && (state == GOSSIP_PRESENCE_STATE_AWAY || 
 
197
        if (!sounds_when_away && (state == GOSSIP_PRESENCE_STATE_AWAY ||
196
198
                                  state == GOSSIP_PRESENCE_STATE_EXT_AWAY)) {
197
199
                return;
198
200
        }
216
218
                return;
217
219
        }
218
220
#endif
219
 
}               
 
221
}
220
222
 
221
 
void 
 
223
void
222
224
gossip_sound_set_enabled (gboolean enabled)
223
225
{
224
226
        sound_disabled = !enabled;
225
227
}
226
228
 
227
 
void 
 
229
void
228
230
gossip_sound_init (GossipSession *session)
229
231
{
230
232
        g_return_if_fail (GOSSIP_IS_SESSION (session));
237
239
        gnome_sound_sample_load ("gossip/Online", DATADIR "/sounds/gossip/online.wav");
238
240
        gnome_sound_sample_load ("gossip/Offline", DATADIR "/sounds/gossip/offline.wav");
239
241
#endif
240
 
        
 
242
 
241
243
        saved_session = g_object_ref (session);
242
244
 
243
245
        account_states = g_hash_table_new_full (gossip_account_hash,
264
266
                          NULL);
265
267
}
266
268
 
267
 
void 
 
269
void
268
270
gossip_sound_finalize (void)
269
271
{
270
272
        g_assert (saved_session != NULL);
275
277
        g_signal_handlers_disconnect_by_func (saved_session,
276
278
                                              sound_contact_presence_updated_cb,
277
279
                                              NULL);
278
 
        
 
280
 
279
281
        g_hash_table_destroy (account_states);
280
282
        g_hash_table_destroy (contact_states);
281
283