comparison libpurple/protocols/yahoo/yahoo_friend.c @ 26165:74bb0836f164

msn interoperability : presence settings
author Sulabh Mahajan <sulabh@soc.pidgin.im>
date Wed, 21 Jan 2009 09:14:01 +0000
parents 3b19ea3c8165
children bc31ebd391d3
comparison
equal deleted inserted replaced
26164:1e02d4592894 26165:74bb0836f164
145 145
146 void yahoo_process_presence(PurpleConnection *gc, struct yahoo_packet *pkt) 146 void yahoo_process_presence(PurpleConnection *gc, struct yahoo_packet *pkt)
147 { 147 {
148 GSList *l = pkt->hash; 148 GSList *l = pkt->hash;
149 YahooFriend *f; 149 YahooFriend *f;
150 char *temp = NULL;
150 char *who = NULL; 151 char *who = NULL;
151 int value = 0; 152 int value = 0;
153 int protocol = 0;
154 gboolean wlm = FALSE;
152 155
153 while (l) { 156 while (l) {
154 struct yahoo_pair *pair = l->data; 157 struct yahoo_pair *pair = l->data;
155 158
156 switch (pair->key) { 159 switch (pair->key) {
157 case 7: 160 case 7:
158 who = pair->value; 161 temp = pair->value;
159 break; 162 break;
160 case 31: 163 case 31:
161 value = strtol(pair->value, NULL, 10); 164 value = strtol(pair->value, NULL, 10);
162 break; 165 break;
166 case 241:
167 protocol = strtol(pair->value, NULL, 10);
168 wlm = TRUE;
169 break;
163 } 170 }
164 171
165 l = l->next; 172 l = l->next;
166 } 173 }
174
175 if(wlm)
176 who = g_strconcat("wlm/", temp, NULL);
177 else
178 who = g_strdup(temp);
167 179
168 if (value != 1 && value != 2) { 180 if (value != 1 && value != 2) {
169 purple_debug_error("yahoo", "Received unknown value for presence key: %d\n", value); 181 purple_debug_error("yahoo", "Received unknown value for presence key: %d\n", value);
170 return; 182 return;
171 } 183 }
172 184
173 g_return_if_fail(who != NULL); 185 g_return_if_fail(who != NULL);
174 186
175 f = yahoo_friend_find(gc, who); 187 f = yahoo_friend_find(gc, who);
176 if (!f) 188 if (!f) {
177 return; 189 g_free(who);
190 return;
191 }
178 192
179 if (pkt->service == YAHOO_SERVICE_PRESENCE_PERM) { 193 if (pkt->service == YAHOO_SERVICE_PRESENCE_PERM) {
180 purple_debug_info("yahoo", "Setting permanent presence for %s to %d.\n", who, (value == 1)); 194 purple_debug_info("yahoo", "Setting permanent presence for %s to %d.\n", who, (value == 1));
181 /* If setting from perm offline to online when in invisible status, 195 /* If setting from perm offline to online when in invisible status,
182 * this has already been taken care of (when the temp status changed) */ 196 * this has already been taken care of (when the temp status changed) */
192 if (value == 1) 206 if (value == 1)
193 f->presence = YAHOO_PRESENCE_ONLINE; 207 f->presence = YAHOO_PRESENCE_ONLINE;
194 else 208 else
195 f->presence = YAHOO_PRESENCE_DEFAULT; 209 f->presence = YAHOO_PRESENCE_DEFAULT;
196 } 210 }
211 g_free(who);
197 } 212 }
198 213
199 void yahoo_friend_update_presence(PurpleConnection *gc, const char *name, 214 void yahoo_friend_update_presence(PurpleConnection *gc, const char *name,
200 YahooPresenceVisibility presence) 215 YahooPresenceVisibility presence)
201 { 216 {
202 struct yahoo_data *yd = gc->proto_data; 217 struct yahoo_data *yd = gc->proto_data;
203 struct yahoo_packet *pkt = NULL; 218 struct yahoo_packet *pkt = NULL;
204 YahooFriend *f; 219 YahooFriend *f;
205 const char *thirtyone, *thirteen; 220 const char *thirtyone, *thirteen;
206 int service = -1; 221 int service = -1;
222 const char *temp = NULL;
207 223
208 if (!yd->logged_in) 224 if (!yd->logged_in)
209 return; 225 return;
210 226
211 f = yahoo_friend_find(gc, name); 227 f = yahoo_friend_find(gc, name);
212 if (!f) 228 if (!f)
213 return; 229 return;
230
231 if(f->protocol == 2)
232 temp = name+4;
233 else
234 temp = name;
214 235
215 /* No need to change the value if it is already correct */ 236 /* No need to change the value if it is already correct */
216 if (f->presence == presence) { 237 if (f->presence == presence) {
217 purple_debug_info("yahoo", "Not setting presence because there are no changes.\n"); 238 purple_debug_info("yahoo", "Not setting presence because there are no changes.\n");
218 return; 239 return;
239 if(f->protocol) 260 if(f->protocol)
240 yahoo_packet_hash(pkt, "ssssssiss", 261 yahoo_packet_hash(pkt, "ssssssiss",
241 1, purple_connection_get_display_name(gc), 262 1, purple_connection_get_display_name(gc),
242 31, "2", 13, "2", 263 31, "2", 13, "2",
243 302, "319", 300, "319", 264 302, "319", 300, "319",
244 7, name, 241, f->protocol, 265 7, temp, 241, f->protocol,
245 301, "319", 303, "319"); 266 301, "319", 303, "319");
246 else 267 else
247 yahoo_packet_hash(pkt, "ssssssss", 268 yahoo_packet_hash(pkt, "ssssssss",
248 1, purple_connection_get_display_name(gc), 269 1, purple_connection_get_display_name(gc),
249 31, "2", 13, "2", 270 31, "2", 13, "2",
250 302, "319", 300, "319", 271 302, "319", 300, "319",
251 7, name, 272 7, temp,
252 301, "319", 303, "319"); 273 301, "319", 303, "319");
253 274
254 yahoo_packet_send_and_free(pkt, yd); 275 yahoo_packet_send_and_free(pkt, yd);
255 } 276 }
256 277
266 if(f->protocol) 287 if(f->protocol)
267 yahoo_packet_hash(pkt, "ssssssiss", 288 yahoo_packet_hash(pkt, "ssssssiss",
268 1, purple_connection_get_display_name(gc), 289 1, purple_connection_get_display_name(gc),
269 31, thirtyone, 13, thirteen, 290 31, thirtyone, 13, thirteen,
270 302, "319", 300, "319", 291 302, "319", 300, "319",
271 7, name, 241, f->protocol, 292 7, temp, 241, f->protocol,
272 301, "319", 303, "319"); 293 301, "319", 303, "319");
273 else 294 else
274 yahoo_packet_hash(pkt, "ssssssss", 295 yahoo_packet_hash(pkt, "ssssssss",
275 1, purple_connection_get_display_name(gc), 296 1, purple_connection_get_display_name(gc),
276 31, thirtyone, 13, thirteen, 297 31, thirtyone, 13, thirteen,
277 302, "319", 300, "319", 298 302, "319", 300, "319",
278 7, name, 299 7, temp,
279 301, "319", 303, "319"); 300 301, "319", 303, "319");
280 301
281 yahoo_packet_send_and_free(pkt, yd); 302 yahoo_packet_send_and_free(pkt, yd);
282 } 303 }
283 } 304 }