comparison mcabber/src/jabglue.c @ 244:5f8b529412bd

[/trunk] Changeset 257 by mikael * Let the /add command set the nickname
author mikael
date Tue, 14 Jun 2005 19:35:37 +0000
parents 8584f919d9b9
children 7f2e61392b2e
comparison
equal deleted inserted replaced
243:c07fa9baca3f 244:5f8b529412bd
299 free(buffer); 299 free(buffer);
300 jb_reset_keepalive(); 300 jb_reset_keepalive();
301 } 301 }
302 302
303 // Note: the caller should check the jid is correct 303 // Note: the caller should check the jid is correct
304 void jb_addbuddy(const char *jid, const char *group) 304 void jb_addbuddy(const char *jid, const char *name, const char *group)
305 { 305 {
306 xmlnode x, y, z; 306 xmlnode x, y, z;
307 char *cleanjid; 307 char *cleanjid;
308 308
309 if (!online) return; 309 if (!online) return;
318 318
319 x = jutil_iqnew(JPACKET__SET, NS_ROSTER); 319 x = jutil_iqnew(JPACKET__SET, NS_ROSTER);
320 y = xmlnode_get_tag(x, "query"); 320 y = xmlnode_get_tag(x, "query");
321 z = xmlnode_insert_tag(y, "item"); 321 z = xmlnode_insert_tag(y, "item");
322 xmlnode_put_attrib(z, "jid", jid); 322 xmlnode_put_attrib(z, "jid", jid);
323
324 if (name) {
325 char *name_utf8 = utf8_encode(name);
326 z = xmlnode_insert_tag(z, "name");
327 xmlnode_insert_cdata(z, name_utf8, (unsigned) -1);
328 free(name_utf8);
329 }
323 330
324 if (group) { 331 if (group) {
325 char *group_utf8 = utf8_encode(group); 332 char *group_utf8 = utf8_encode(group);
326 z = xmlnode_insert_tag(z, "group"); 333 z = xmlnode_insert_tag(z, "group");
327 xmlnode_insert_cdata(z, group_utf8, (unsigned) -1); 334 xmlnode_insert_cdata(z, group_utf8, (unsigned) -1);
330 337
331 jab_send(jc, x); 338 jab_send(jc, x);
332 xmlnode_free(x); 339 xmlnode_free(x);
333 340
334 cleanjid = jidtodisp(jid); 341 cleanjid = jidtodisp(jid);
335 roster_add_user(cleanjid, NULL, group, ROSTER_TYPE_USER); 342 roster_add_user(cleanjid, name, group, ROSTER_TYPE_USER);
336 g_free(cleanjid); 343 g_free(cleanjid);
337 buddylist_build(); 344 buddylist_build();
338 345
339 // useless IMHO: if user appears his status will change 346 update_roster = TRUE;
340 //update_roster = TRUE;
341 } 347 }
342 348
343 void jb_delbuddy(const char *jid) 349 void jb_delbuddy(const char *jid)
344 { 350 {
345 xmlnode x, y, z; 351 xmlnode x, y, z;