+ g_free (msg);
+}
+
+static void
+status_icon_call_member_added_cb (EmpathyTpGroup *group,
+ EmpathyContact *member,
+ EmpathyContact *actor,
+ guint reason,
+ const gchar *message,
+ EmpathyStatusIcon *icon)
+{
+ EmpathyFilter *filter;
+
+ if (empathy_contact_is_user (member)) {
+ /* We are member, it's an outgoing call, we can dispatch
+ * the channel without asking the user */
+ empathy_debug (DEBUG_DOMAIN, "Process OUTGOING call channel");
+ filter = g_object_get_data (G_OBJECT (group), "filter");
+ empathy_filter_process (filter,
+ empathy_tp_group_get_channel (group),
+ TRUE);
+ g_object_unref (group);
+ }
+}
+
+static void
+status_icon_event_call_cb (StatusIconEvent *event)
+{
+ EmpathyFilter *filter;
+ EmpathyTpGroup *group;
+
+ empathy_debug (DEBUG_DOMAIN, "Dispatching call channel");
+
+ group = event->user_data;
+ filter = g_object_get_data (G_OBJECT (group), "filter");
+ empathy_filter_process (filter,
+ empathy_tp_group_get_channel (group),
+ TRUE);
+ g_object_unref (group);
+}
+
+static void
+status_icon_call_local_pending_cb (EmpathyTpGroup *group,
+ EmpathyContact *member,
+ EmpathyContact *actor,
+ guint reason,
+ const gchar *message,
+ EmpathyStatusIcon *icon)
+{
+ StatusIconEvent *event;
+
+ if (empathy_contact_is_user (member)) {
+ gchar *msg;
+
+ /* We are local pending, it's an incoming call, we need to ask
+ * the user if he wants to accept the call. */
+ empathy_debug (DEBUG_DOMAIN, "INCOMING call, add event");
+
+ msg = g_strdup_printf (_("Incoming call from %s:\n%s"),
+ empathy_contact_get_name (member),
+ message);
+
+ event = status_icon_event_new (icon, EMPATHY_IMAGE_VOIP, msg);
+ event->func = status_icon_event_call_cb;
+ event->user_data = group;
+ g_free (msg);
+ }
+}
+
+static void
+status_icon_call_filter_new_channel (EmpathyFilter *filter,
+ TpConn *tp_conn,
+ TpChan *tp_chan,
+ EmpathyStatusIcon *icon)
+{
+ EmpathyStatusIconPriv *priv;
+ McAccount *account;
+ EmpathyTpGroup *group;
+
+ priv = GET_PRIV (icon);
+
+ account = mission_control_get_account_for_connection (priv->mc, tp_conn, NULL);
+
+ empathy_debug (DEBUG_DOMAIN, "New media channel to be filtered");
+
+ /* FIXME: We have to check if the user is member or local-pending to
+ * know if it's an incoming or outgoing call because of the way we
+ * request media channels MC can't know if it's incoming or outgoing */
+ group = empathy_tp_group_new (account, tp_chan);
+ g_object_set_data (G_OBJECT (group), "filter", filter);
+ g_object_unref (account);
+
+ g_signal_connect (group, "member-added",
+ G_CALLBACK (status_icon_call_member_added_cb),
+ icon);
+ g_signal_connect (group, "local-pending",
+ G_CALLBACK (status_icon_call_local_pending_cb),
+ icon);