comparison mcabber/src/commands.c @ 1351:43e777a5ff06

The group name can be specified in the /group command
author Mikael Berthe <mikael@lilotux.net>
date Sat, 10 Nov 2007 22:28:16 +0100
parents 096411233fce
children 61a54e172010
comparison
equal deleted inserted replaced
1350:096411233fce 1351:43e777a5ff06
987 scr_UpdateBuddyWindow(); 987 scr_UpdateBuddyWindow();
988 } 988 }
989 989
990 static void do_group(char *arg) 990 static void do_group(char *arg)
991 { 991 {
992 gpointer group; 992 gpointer group = NULL;
993 guint leave_buddywindow; 993 guint leave_buddywindow;
994 char **paramlst;
995 char *subcmd;
994 996
995 if (!*arg) { 997 if (!*arg) {
996 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); 998 scr_LogPrint(LPRINT_NORMAL, "Missing parameter.");
997 return; 999 return;
998 } 1000 }
999 1001
1000 if (!current_buddy) 1002 if (!current_buddy)
1001 return; 1003 return;
1002 1004
1003 group = buddy_getgroup(BUDDATA(current_buddy)); 1005 paramlst = split_arg(arg, 2, 1); // subcmd, [arg]
1006 subcmd = *paramlst;
1007 arg = *(paramlst+1);
1008
1009 if (!subcmd || !*subcmd)
1010 goto do_group_return; // Should not happen anyway
1011
1012 if (arg && *arg) {
1013 GSList *roster_elt;
1014 roster_elt = roster_find(arg, namesearch, ROSTER_TYPE_GROUP);
1015 if (roster_elt)
1016 group = buddy_getgroup(roster_elt->data);
1017 } else {
1018 group = buddy_getgroup(BUDDATA(current_buddy));
1019 }
1004 if (!group) 1020 if (!group)
1005 return; 1021 goto do_group_return;
1006 1022
1007 // We'll have to redraw the chat window if we're not currently on the group 1023 // We'll have to redraw the chat window if we're not currently on the group
1008 // entry itself, because it means we'll have to leave the current buddy 1024 // entry itself, because it means we'll have to leave the current buddy
1009 // chat window. 1025 // chat window.
1010 leave_buddywindow = (group != BUDDATA(current_buddy)); 1026 leave_buddywindow = (group != BUDDATA(current_buddy));
1011 1027
1012 if (!(buddy_gettype(group) & ROSTER_TYPE_GROUP)) { 1028 if (!(buddy_gettype(group) & ROSTER_TYPE_GROUP)) {
1013 scr_LogPrint(LPRINT_NORMAL, "You need to select a group."); 1029 scr_LogPrint(LPRINT_NORMAL, "You need to select a group.");
1014 return; 1030 goto do_group_return;
1015 } 1031 }
1016 1032
1017 if (!strcasecmp(arg, "expand") || !strcasecmp(arg, "unfold")) { 1033 if (!strcasecmp(subcmd, "expand") || !strcasecmp(subcmd, "unfold")) {
1018 buddy_setflags(group, ROSTER_FLAG_HIDE, FALSE); 1034 buddy_setflags(group, ROSTER_FLAG_HIDE, FALSE);
1019 } else if (!strcasecmp(arg, "shrink") || !strcasecmp(arg, "fold")) { 1035 } else if (!strcasecmp(subcmd, "shrink") || !strcasecmp(subcmd, "fold")) {
1020 buddy_setflags(group, ROSTER_FLAG_HIDE, TRUE); 1036 buddy_setflags(group, ROSTER_FLAG_HIDE, TRUE);
1021 } else if (!strcasecmp(arg, "toggle")) { 1037 } else if (!strcasecmp(subcmd, "toggle")) {
1022 buddy_setflags(group, ROSTER_FLAG_HIDE, 1038 buddy_setflags(group, ROSTER_FLAG_HIDE,
1023 !(buddy_getflags(group) & ROSTER_FLAG_HIDE)); 1039 !(buddy_getflags(group) & ROSTER_FLAG_HIDE));
1024 } else { 1040 } else {
1025 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); 1041 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!");
1026 return; 1042 goto do_group_return;
1027 } 1043 }
1028 1044
1029 buddylist_build(); 1045 buddylist_build();
1030 update_roster = TRUE; 1046 update_roster = TRUE;
1031 if (leave_buddywindow) scr_ShowBuddyWindow(); 1047 if (leave_buddywindow)
1048 scr_ShowBuddyWindow();
1049
1050 do_group_return:
1051 free_arg_lst(paramlst);
1032 } 1052 }
1033 1053
1034 static int send_message_to(const char *fjid, const char *msg, const char *subj, 1054 static int send_message_to(const char *fjid, const char *msg, const char *subj,
1035 const char *type_overwrite) 1055 const char *type_overwrite)
1036 { 1056 {