comparison mcabber/src/commands.c @ 210:f64818ba3503

[/trunk] Changeset 222 by mikael * Add /move command * roster: Add buddy_setgroup() * roster.c: Fix a small memory leak * Keep documentation up-to-date
author mikael
date Sun, 08 May 2005 07:02:11 +0000
parents 8b08f34922c5
children 465d98d2f8e3
comparison
equal deleted inserted replaced
209:353a4f8a3f61 210:f64818ba3503
40 void do_say(char *arg); 40 void do_say(char *arg);
41 void do_buffer(char *arg); 41 void do_buffer(char *arg);
42 void do_clear(char *arg); 42 void do_clear(char *arg);
43 void do_info(char *arg); 43 void do_info(char *arg);
44 void do_rename(char *arg); 44 void do_rename(char *arg);
45 void do_move(char *arg);
45 46
46 // Global variable for the commands list 47 // Global variable for the commands list
47 static GSList *Commands; 48 static GSList *Commands;
48 49
49 50
73 cmd_add("clear", "Clear the dialog window", 0, 0, &do_clear); 74 cmd_add("clear", "Clear the dialog window", 0, 0, &do_clear);
74 cmd_add("del", "Delete the current buddy", 0, 0, &do_del); 75 cmd_add("del", "Delete the current buddy", 0, 0, &do_del);
75 cmd_add("group", "Change group display settings", COMPL_GROUP, 0, &do_group); 76 cmd_add("group", "Change group display settings", COMPL_GROUP, 0, &do_group);
76 cmd_add("help", "Display some help", COMPL_CMD, 0, NULL); 77 cmd_add("help", "Display some help", COMPL_CMD, 0, NULL);
77 cmd_add("info", "Show basic infos on current buddy", 0, 0, &do_info); 78 cmd_add("info", "Show basic infos on current buddy", 0, 0, &do_info);
78 //cmd_add("move"); 79 cmd_add("move", "Move the current buddy to another group", 0, 0, &do_move);
79 //cmd_add("nick"); 80 //cmd_add("nick");
80 cmd_add("quit", "Exit the software", 0, 0, NULL); 81 cmd_add("quit", "Exit the software", 0, 0, NULL);
81 cmd_add("rename", "Rename the current buddy", 0, 0, &do_rename); 82 cmd_add("rename", "Rename the current buddy", 0, 0, &do_rename);
82 //cmd_add("request_auth"); 83 //cmd_add("request_auth");
83 cmd_add("roster", "Manipulate the roster/buddylist", COMPL_ROSTER, 0, 84 cmd_add("roster", "Manipulate the roster/buddylist", COMPL_ROSTER, 0,
458 459
459 g_free(newname); 460 g_free(newname);
460 update_roster = TRUE; 461 update_roster = TRUE;
461 } 462 }
462 463
464 void do_move(char *arg)
465 {
466 gpointer bud;
467 const char *jid, *name;
468 guint type;
469 char *newgroupname, *p;
470
471 if (!current_buddy) return;
472 bud = BUDDATA(current_buddy);
473
474 jid = buddy_getjid(bud);
475 name = buddy_getname(bud);
476 type = buddy_gettype(bud);
477
478 if (type & ROSTER_TYPE_GROUP) {
479 scr_LogPrint("You can't move groups!");
480 return;
481 }
482
483 newgroupname = g_strdup(arg);
484 // Remove trailing space
485 for (p = newgroupname; *p; p++) ;
486 while (p > newgroupname && *p == ' ') *p = 0;
487
488 // Call to buddy_setgroup() should be at the end, as current implementation
489 // clones the buddy and deletes the old one (and thus, jid and name are
490 // freed)
491 jb_updatebuddy(jid, name, newgroupname);
492 buddy_setgroup(bud, newgroupname);
493
494 g_free(newgroupname);
495 update_roster = TRUE;
496 }
497