Merge lp:~ken-vandine/telepathy-indicator/lp_926072 into lp:telepathy-indicator

Proposed by Ken VanDine
Status: Merged
Merged at revision: 56
Proposed branch: lp:~ken-vandine/telepathy-indicator/lp_926072
Merge into: lp:telepathy-indicator
Diff against target: 113 lines (+39/-18)
1 file modified
src/indicator-approver.c (+39/-18)
To merge this branch: bzr merge lp:~ken-vandine/telepathy-indicator/lp_926072
Reviewer Review Type Date Requested Status
Sebastien Bacher Approve
Review via email: mp+98719@code.launchpad.net

Description of the change

 * use get_requested to determine if we should get the contact with get_initiator_contact or get_target_contact (LP: #926072)
 * don't observe chat room channels, it seems there is no way to sanely determine if we should get notified. The observer in gnome-shell doesn't observe chat room channels either.

To post a comment you must log in.
Revision history for this message
Ken VanDine (ken-vandine) wrote :

This will also fix (LP: #910785)

Revision history for this message
Ken VanDine (ken-vandine) wrote :

This will also fix (LP: #929002)

Revision history for this message
Sebastien Bacher (seb128) wrote :

looks fine to me!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/indicator-approver.c'
2--- src/indicator-approver.c 2012-02-16 18:37:01 +0000
3+++ src/indicator-approver.c 2012-03-21 20:09:17 +0000
4@@ -217,6 +217,19 @@
5 return FALSE;
6 }
7
8+static TpContact *
9+get_contact_from_channel (TpChannel * channel)
10+{
11+ g_return_val_if_fail (TP_IS_CHANNEL (channel), NULL);
12+ TpContact *contact = NULL;
13+ if (tp_channel_get_requested (TP_CHANNEL (channel)))
14+ contact = tp_channel_get_target_contact (TP_CHANNEL (channel));
15+ else
16+ contact = tp_channel_get_initiator_contact (TP_CHANNEL (channel));
17+ return TP_CONTACT (contact);
18+}
19+
20+
21 static void
22 handle_contacts_pending_add_indicator_cb (TpConnection *connection, guint n_contacts, TpContact * const *contacts, guint n_failed, const TpHandle *failed, const GError *err, gpointer user_data, GObject *weak_object)
23 {
24@@ -227,9 +240,22 @@
25 const gchar *alias = "";
26 GFile *avatar = NULL;
27 GdkPixbuf *pixbuf = NULL;
28- TpContact *contact = contacts[0];
29- alias = tp_contact_get_alias (contact);
30- avatar = tp_contact_get_avatar_file (contact);
31+ TpContact *contact = NULL;
32+
33+ contact = get_contact_from_channel (channel);
34+
35+ if (contact)
36+ {
37+ alias = tp_contact_get_alias (contact);
38+ avatar = tp_contact_get_avatar_file (contact);
39+ g_debug ("handle_contacts_pending_add_indicator_cb HAS CONTACT alias: %s", alias);
40+ } else
41+ {
42+ alias = tp_channel_get_initiator_identifier (channel);
43+ g_debug ("handle_contacts_pending_add_indicator_cb NO CONTACT alias: %s", alias);
44+ }
45+ g_debug ("handle_contacts_pending_add_indicator_cb alias: %s", alias);
46+
47 id = tp_channel_get_identifier (TP_CHANNEL (channel));
48 IndicateIndicator *indicator;
49 indicator = indicate_indicator_new ();
50@@ -316,7 +342,6 @@
51 message_received_cb (TpTextChannel *channel, TpMessage *message, gpointer user_data)
52 {
53 g_debug ("message_received_cb: %s", tp_channel_get_identifier (TP_CHANNEL (channel)));
54-
55 g_timeout_add (100, check_pending_messages, channel);
56 }
57
58@@ -324,6 +349,7 @@
59 handle_contacts_add_indicator_cb (TpConnection *connection, guint n_contacts, TpContact * const *contacts, guint n_failed, const TpHandle *failed, const GError *err, gpointer user_data, GObject *weak_object)
60 {
61 IndicateIndicator *indicator = NULL;
62+ TpContact *contact = NULL;
63 const gchar *id = "";
64 const gchar *alias = "";
65 GTimeVal time;
66@@ -338,17 +364,19 @@
67 channels = tp_channel_dispatch_operation_borrow_channels (dispatch_op);
68 channel = g_ptr_array_index (channels, 0);
69
70- if (TP_IS_CHANNEL (channel))
71+ contact = get_contact_from_channel (channel);
72+
73+ if (contact)
74+ {
75+ alias = tp_contact_get_alias (contact);
76+ avatar = tp_contact_get_avatar_file (contact);
77+ } else
78 {
79 alias = tp_channel_get_initiator_identifier (channel);
80- id = tp_channel_get_identifier (TP_CHANNEL (channel));
81 }
82+ g_debug ("handle_contacts_add_indicator_cb alias: %s", alias);
83
84- if (contacts)
85- {
86- alias = tp_contact_get_alias (contacts[0]);
87- avatar = tp_contact_get_avatar_file (contacts[0]);
88- }
89+ id = tp_channel_get_identifier (TP_CHANNEL (channel));
90
91 if (check_indicator (id))
92 {
93@@ -445,7 +473,6 @@
94 G_CALLBACK (pending_message_removed_cb), NULL);
95
96 check_pending_messages (TP_CHANNEL (channel));
97-
98 }
99 }
100 g_list_free(itr);
101@@ -934,12 +961,6 @@
102 TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT,
103 NULL));
104
105- /* room text chat */
106- tp_base_client_take_observer_filter (observer, tp_asv_new (
107- TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_TEXT,
108- TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_ROOM,
109- NULL));
110-
111 if (!tp_base_client_register (observer, &error))
112 {
113 if (error)

Subscribers

People subscribed via source and target branches

to all changes: