~ubuntu-branches/ubuntu/feisty/gossip-telepathy/feisty

« back to all changes in this revision

Viewing changes to src/gossip-sound.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2006-12-20 15:09:43 UTC
  • mfrom: (1.1.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20061220150943-01hnkptgzfvw5d6e
Tags: 0.21~cvs20061220-0ubuntu1
* New CVS checkout.
* debian/control: Build-Depend on libtelepathy-dev (>= 0.0.40-0ubuntu2).

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
static void sound_contact_removed_cb          (GossipSession *session,
50
50
                                               GossipContact *contact,
51
51
                                               gpointer       user_data);
 
52
static void sound_contact_remove              (GossipContact *contact);
52
53
 
53
54
static GHashTable    *account_states = NULL;
54
55
static GHashTable    *contact_states = NULL;
71
72
        guint        id;
72
73
        const gchar *account_id;
73
74
 
 
75
        gossip_debug (DEBUG_DOMAIN, 
 
76
                      "Protocol connected for account:'%s'",
 
77
                      gossip_account_get_name (account));
 
78
 
74
79
        if (g_hash_table_lookup (account_states, account)) {
75
80
                return;
76
81
        }
77
82
 
78
83
        account_id = gossip_account_get_id (account);
79
 
        gossip_debug (DEBUG_DOMAIN, "Account update, account:'%s' is now online",
 
84
        gossip_debug (DEBUG_DOMAIN, 
 
85
                      "Account update, account:'%s' is now online",
80
86
                      account_id);
81
87
 
82
88
        id = g_timeout_add (SOUND_WAIT_TIME,
83
89
                            (GSourceFunc) sound_protocol_timeout_cb,
84
90
                            account);
85
 
        g_hash_table_insert (account_states, account, GUINT_TO_POINTER (id));
 
91
        g_hash_table_insert (account_states, g_object_ref (account),
 
92
                             GUINT_TO_POINTER (id));
86
93
}
87
94
 
88
95
static gboolean
102
109
}
103
110
 
104
111
static void
105
 
sound_protocol_disconnected_cb (GossipSession  *session,
106
 
                                GossipAccount  *account,
107
 
                                GossipProtocol *protocol,
108
 
                                gint            reason,
109
 
                                gpointer        user_data)
 
112
sound_protocol_disconnecting_cb (GossipSession  *session,
 
113
                                 GossipAccount  *account,
 
114
                                 GossipProtocol *protocol,
 
115
                                 gpointer        user_data)
110
116
{
 
117
        gossip_debug (DEBUG_DOMAIN, 
 
118
                      "Protocol disconnecting for account:'%s'",
 
119
                      gossip_account_get_name (account));
 
120
 
111
121
        g_hash_table_remove (account_states, account);
112
122
 
113
123
        g_hash_table_foreach_remove (contact_states,
129
139
        presence = gossip_contact_get_active_presence (contact);
130
140
        if (!presence) {
131
141
                if (g_hash_table_lookup (contact_states, contact)) {
132
 
                        gossip_debug (DEBUG_DOMAIN, "Presence update, contact:'%s' is now offline",
 
142
                        gossip_debug (DEBUG_DOMAIN,
 
143
                                      "Presence update, contact:'%s' is now offline",
133
144
                                      gossip_contact_get_id (contact));
134
145
                        gossip_sound_play (GOSSIP_SOUND_OFFLINE);
135
146
                }
146
157
                 */
147
158
                if (!g_hash_table_lookup (account_states, account) &&
148
159
                    !g_hash_table_lookup (contact_states, contact)) {
149
 
                        gossip_debug (DEBUG_DOMAIN, "Presence update, contact:'%s' is now online",
 
160
                        gossip_debug (DEBUG_DOMAIN, 
 
161
                                      "Presence update, contact:'%s' is now online",
150
162
                                      gossip_contact_get_id (contact));
151
163
                        gossip_sound_play (GOSSIP_SOUND_ONLINE);
152
164
                }
175
187
                          GossipContact *contact,
176
188
                          gpointer       user_data)
177
189
{
 
190
        g_hash_table_remove (contact_states, contact);
 
191
}
 
192
 
 
193
static void
 
194
sound_contact_remove (GossipContact *contact)
 
195
{
178
196
        g_signal_handlers_disconnect_by_func (contact,
179
197
                                              sound_contact_presence_updated_cb,
180
198
                                              NULL);
 
199
        g_object_unref (contact);
181
200
}
182
201
 
183
202
void
278
297
 
279
298
        contact_states = g_hash_table_new_full (gossip_contact_hash,
280
299
                                                gossip_contact_equal,
281
 
                                                (GDestroyNotify) g_object_unref,
 
300
                                                (GDestroyNotify) sound_contact_remove,
282
301
                                                (GDestroyNotify) g_object_unref);
283
302
 
284
303
        g_signal_connect (session, "protocol-connected",
285
304
                          G_CALLBACK (sound_protocol_connected_cb),
286
305
                          NULL);
287
 
        g_signal_connect (session, "protocol-disconnected",
288
 
                          G_CALLBACK (sound_protocol_disconnected_cb),
 
306
        g_signal_connect (session, "protocol-disconnecting",
 
307
                          G_CALLBACK (sound_protocol_disconnecting_cb),
289
308
                          NULL);
290
309
        g_signal_connect (session, "contact-added",
291
310
                          G_CALLBACK (sound_contact_added_cb),