90
91
static void empathy_status_icon_class_init (EmpathyStatusIconClass *klass);
91
92
static void empathy_status_icon_init (EmpathyStatusIcon *icon);
92
93
static void status_icon_finalize (GObject *object);
93
static void status_icon_filter_new_channel (EmpathyFilter *filter,
94
static void status_icon_text_filter_new_channel (EmpathyFilter *filter,
97
EmpathyStatusIcon *icon);
98
static void status_icon_call_filter_new_channel (EmpathyFilter *filter,
96
101
EmpathyStatusIcon *icon);
193
198
TP_IFACE_CHANNEL_TYPE_TEXT,
194
199
MC_FILTER_PRIORITY_DIALOG,
195
200
MC_FILTER_FLAG_INCOMING);
201
priv->call_filter = empathy_filter_new ("org.gnome.Empathy.CallFilter",
202
"/org/gnome/Empathy/CallFilter",
203
TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
204
MC_FILTER_PRIORITY_DIALOG,
205
MC_FILTER_FLAG_INCOMING);
197
207
/* Setup EmpathyIdle */
198
208
priv->idle = empathy_idle_new ();
216
226
status_icon_idle_notify_cb (icon);
218
228
g_signal_connect (priv->text_filter, "new-channel",
219
G_CALLBACK (status_icon_filter_new_channel),
229
G_CALLBACK (status_icon_text_filter_new_channel),
231
g_signal_connect (priv->call_filter, "new-channel",
232
G_CALLBACK (status_icon_call_filter_new_channel),
221
234
g_signal_connect_swapped (priv->idle, "notify",
222
235
G_CALLBACK (status_icon_idle_notify_cb),
320
334
g_object_set_data (G_OBJECT (tp_chat), "filter", filter);
321
335
g_object_unref (account);
323
messages = empathy_tp_chat_get_pendings (tp_chat);
325
empathy_debug (DEBUG_DOMAIN, "No pending msg, waiting...");
326
g_signal_connect (tp_chat, "message-received",
327
G_CALLBACK (status_icon_message_received_cb),
332
status_icon_message_received_cb (tp_chat, messages->data, icon);
334
g_list_foreach (messages, (GFunc) g_object_unref, NULL);
335
g_list_free (messages);
337
g_signal_connect (tp_chat, "message-received",
338
G_CALLBACK (status_icon_message_received_cb),
358
362
event = status_icon_event_new (icon, EMPATHY_IMAGE_NEW_MESSAGE, msg);
359
363
event->func = status_icon_event_msg_cb;
360
364
event->user_data = tp_chat;
369
status_icon_call_member_added_cb (EmpathyTpGroup *group,
370
EmpathyContact *member,
371
EmpathyContact *actor,
373
const gchar *message,
374
EmpathyStatusIcon *icon)
376
EmpathyFilter *filter;
378
if (empathy_contact_is_user (member)) {
379
/* We are member, it's an outgoing call, we can dispatch
380
* the channel without asking the user */
381
empathy_debug (DEBUG_DOMAIN, "Process OUTGOING call channel");
382
filter = g_object_get_data (G_OBJECT (group), "filter");
383
empathy_filter_process (filter,
384
empathy_tp_group_get_channel (group),
386
g_object_unref (group);
391
status_icon_event_call_cb (StatusIconEvent *event)
393
EmpathyFilter *filter;
394
EmpathyTpGroup *group;
396
empathy_debug (DEBUG_DOMAIN, "Dispatching call channel");
398
group = event->user_data;
399
filter = g_object_get_data (G_OBJECT (group), "filter");
400
empathy_filter_process (filter,
401
empathy_tp_group_get_channel (group),
403
g_object_unref (group);
407
status_icon_call_local_pending_cb (EmpathyTpGroup *group,
408
EmpathyContact *member,
409
EmpathyContact *actor,
411
const gchar *message,
412
EmpathyStatusIcon *icon)
414
StatusIconEvent *event;
416
if (empathy_contact_is_user (member)) {
419
/* We are local pending, it's an incoming call, we need to ask
420
* the user if he wants to accept the call. */
421
empathy_debug (DEBUG_DOMAIN, "INCOMING call, add event");
423
msg = g_strdup_printf (_("Incoming call from %s:\n%s"),
424
empathy_contact_get_name (member),
427
event = status_icon_event_new (icon, EMPATHY_IMAGE_VOIP, msg);
428
event->func = status_icon_event_call_cb;
429
event->user_data = group;
435
status_icon_call_filter_new_channel (EmpathyFilter *filter,
438
EmpathyStatusIcon *icon)
440
EmpathyStatusIconPriv *priv;
442
EmpathyTpGroup *group;
444
priv = GET_PRIV (icon);
446
account = mission_control_get_account_for_connection (priv->mc, tp_conn, NULL);
448
empathy_debug (DEBUG_DOMAIN, "New media channel to be filtered");
450
/* FIXME: We have to check if the user is member or local-pending to
451
* know if it's an incoming or outgoing call because of the way we
452
* request media channels MC can't know if it's incoming or outgoing */
453
group = empathy_tp_group_new (account, tp_chan);
454
g_object_set_data (G_OBJECT (group), "filter", filter);
455
g_object_unref (account);
457
g_signal_connect (group, "member-added",
458
G_CALLBACK (status_icon_call_member_added_cb),
460
g_signal_connect (group, "local-pending",
461
G_CALLBACK (status_icon_call_local_pending_cb),