mcabber/src/commands.c
changeset 1272 033576acac4c
parent 1268 dbc907b2d92f
child 1279 8bbc764139ef
equal deleted inserted replaced
1271:f8a874ff453a 1272:033576acac4c
    75 static void do_pgp(char *arg);
    75 static void do_pgp(char *arg);
    76 static void do_iline(char *arg);
    76 static void do_iline(char *arg);
    77 static void do_screen_refresh(char *arg);
    77 static void do_screen_refresh(char *arg);
    78 static void do_chat_disable(char *arg);
    78 static void do_chat_disable(char *arg);
    79 static void do_source(char *arg);
    79 static void do_source(char *arg);
       
    80 static void do_color(char *arg);
    80 
    81 
    81 // Global variable for the commands list
    82 // Global variable for the commands list
    82 static GSList *Commands;
    83 static GSList *Commands;
    83 
    84 
    84 
    85 
   145   cmd_add("source", "Read a configuration file", 0, 0, &do_source);
   146   cmd_add("source", "Read a configuration file", 0, 0, &do_source);
   146   cmd_add("status", "Show or set your status", COMPL_STATUS, 0, &do_status);
   147   cmd_add("status", "Show or set your status", COMPL_STATUS, 0, &do_status);
   147   cmd_add("status_to", "Show or set your status for one recipient",
   148   cmd_add("status_to", "Show or set your status for one recipient",
   148           COMPL_JID, COMPL_STATUS, &do_status_to);
   149           COMPL_JID, COMPL_STATUS, &do_status_to);
   149   cmd_add("version", "Show mcabber version", 0, 0, &do_version);
   150   cmd_add("version", "Show mcabber version", 0, 0, &do_version);
       
   151   cmd_add("color", "Set coloring options", COMPL_COLOR, 0, &do_color);
   150 
   152 
   151   // Status category
   153   // Status category
   152   compl_add_category_word(COMPL_STATUS, "online");
   154   compl_add_category_word(COMPL_STATUS, "online");
   153   compl_add_category_word(COMPL_STATUS, "avail");
   155   compl_add_category_word(COMPL_STATUS, "avail");
   154   compl_add_category_word(COMPL_STATUS, "invisible");
   156   compl_add_category_word(COMPL_STATUS, "invisible");
   250   compl_add_category_word(COMPL_PGP, "disable");
   252   compl_add_category_word(COMPL_PGP, "disable");
   251   compl_add_category_word(COMPL_PGP, "enable");
   253   compl_add_category_word(COMPL_PGP, "enable");
   252   compl_add_category_word(COMPL_PGP, "force");
   254   compl_add_category_word(COMPL_PGP, "force");
   253   compl_add_category_word(COMPL_PGP, "info");
   255   compl_add_category_word(COMPL_PGP, "info");
   254   compl_add_category_word(COMPL_PGP, "setkey");
   256   compl_add_category_word(COMPL_PGP, "setkey");
       
   257 
       
   258   // Color category
       
   259   compl_add_category_word(COMPL_COLOR, "roster");
   255 }
   260 }
   256 
   261 
   257 //  expandalias(line)
   262 //  expandalias(line)
   258 // If there is one, expand the alias in line and returns a new allocated line
   263 // If there is one, expand the alias in line and returns a new allocated line
   259 // If no alias is found, returns line
   264 // If no alias is found, returns line
   695     scr_RosterPrevGroup();
   700     scr_RosterPrevGroup();
   696   } else if (!strcasecmp(subcmd, "group_next")) {
   701   } else if (!strcasecmp(subcmd, "group_next")) {
   697     scr_RosterNextGroup();
   702     scr_RosterNextGroup();
   698   } else if (!strcasecmp(subcmd, "note")) {
   703   } else if (!strcasecmp(subcmd, "note")) {
   699     roster_note(arg);
   704     roster_note(arg);
       
   705   } else
       
   706     scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!");
       
   707   free_arg_lst(paramlst);
       
   708 }
       
   709 
       
   710 void do_color(char *arg)
       
   711 {
       
   712   char **paramlst;
       
   713   char *subcmd;
       
   714 
       
   715   paramlst = split_arg(arg, 2, 1); // subcmd, arg
       
   716   subcmd = *paramlst;
       
   717   arg = *(paramlst+1);
       
   718 
       
   719   if (!subcmd || !*subcmd) {
       
   720     scr_LogPrint(LPRINT_NORMAL, "Missing parameter.");
       
   721     free_arg_lst(paramlst);
       
   722     return;
       
   723   }
       
   724 
       
   725   if (!strcasecmp(subcmd, "roster")) {
       
   726     char **arglist = split_arg(arg, 3, 0);
       
   727     char *status = *arglist, *wildcard = arglist[1], *color = arglist[2];
       
   728     if (status && !strcmp(status, "clear")) { // Not a color command, clear all
       
   729       scr_RosterClearColor();
       
   730       update_roster = TRUE;
       
   731     } else {
       
   732       if (!status || !*status || !wildcard || !*wildcard || !color || !*color) {
       
   733         scr_LogPrint(LPRINT_NORMAL, "Missing argument");
       
   734       } else {
       
   735         update_roster = scr_RosterColor(status, wildcard, color)
       
   736                         || update_roster;
       
   737       }
       
   738     }
       
   739     free_arg_lst(arglist);
   700   } else
   740   } else
   701     scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!");
   741     scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!");
   702   free_arg_lst(paramlst);
   742   free_arg_lst(paramlst);
   703 }
   743 }
   704 
   744