mcabber/mcabber/commands.c
changeset 1979 6febc7d1f760
parent 1978 986e514bec97
child 1980 3bcc57751283
equal deleted inserted replaced
1978:986e514bec97 1979:6febc7d1f760
  2796 
  2796 
  2797 static void room_setopt(gpointer bud, char *arg)
  2797 static void room_setopt(gpointer bud, char *arg)
  2798 {
  2798 {
  2799   char **paramlst;
  2799   char **paramlst;
  2800   char *param, *value;
  2800   char *param, *value;
  2801   enum { opt_none = 0, opt_printstatus, opt_autowhois } option = 0;
  2801   enum { opt_none = 0, opt_printstatus,
       
  2802          opt_autowhois, opt_flagjoins } option = 0;
  2802 
  2803 
  2803   paramlst = split_arg(arg, 2, 1); // param, value
  2804   paramlst = split_arg(arg, 2, 1); // param, value
  2804   param = *paramlst;
  2805   param = *paramlst;
  2805   value = *(paramlst+1);
  2806   value = *(paramlst+1);
  2806   if (!param) {
  2807   if (!param) {
  2811 
  2812 
  2812   if (!strcasecmp(param, "print_status"))
  2813   if (!strcasecmp(param, "print_status"))
  2813     option = opt_printstatus;
  2814     option = opt_printstatus;
  2814   else if (!strcasecmp(param, "auto_whois"))
  2815   else if (!strcasecmp(param, "auto_whois"))
  2815     option = opt_autowhois;
  2816     option = opt_autowhois;
       
  2817   else if (!strcasecmp(param, "flag_joins"))
       
  2818     option = opt_flagjoins;
  2816   else {
  2819   else {
  2817     scr_LogPrint(LPRINT_NORMAL, "Wrong option!");
  2820     scr_LogPrint(LPRINT_NORMAL, "Wrong option!");
  2818     free_arg_lst(paramlst);
  2821     free_arg_lst(paramlst);
  2819     return;
  2822     return;
  2820   }
  2823   }
  2822   // If no value is given, display the current value
  2825   // If no value is given, display the current value
  2823   if (!value) {
  2826   if (!value) {
  2824     const char *strval;
  2827     const char *strval;
  2825     if (option == opt_printstatus)
  2828     if (option == opt_printstatus)
  2826       strval = strprintstatus[buddy_getprintstatus(bud)];
  2829       strval = strprintstatus[buddy_getprintstatus(bud)];
       
  2830     else if (option == opt_autowhois)
       
  2831       strval = strautowhois[buddy_getautowhois(bud)];
  2827     else
  2832     else
  2828       strval = strautowhois[buddy_getautowhois(bud)];
  2833       strval = strflagjoins[buddy_getflagjoins(bud)];
  2829     scr_LogPrint(LPRINT_NORMAL, "%s is set to: %s", param, strval);
  2834     scr_LogPrint(LPRINT_NORMAL, "%s is set to: %s", param, strval);
  2830     free_arg_lst(paramlst);
  2835     free_arg_lst(paramlst);
  2831     return;
  2836     return;
  2832   }
  2837   }
  2833 
  2838 
  2855       eval = autowhois_default;
  2860       eval = autowhois_default;
  2856       if (strcasecmp(value, "default") != 0)
  2861       if (strcasecmp(value, "default") != 0)
  2857         scr_LogPrint(LPRINT_NORMAL, "Unrecognized value, assuming default...");
  2862         scr_LogPrint(LPRINT_NORMAL, "Unrecognized value, assuming default...");
  2858     }
  2863     }
  2859     buddy_setautowhois(bud, eval);
  2864     buddy_setautowhois(bud, eval);
       
  2865   } else if (option == opt_flagjoins) {
       
  2866     enum room_flagjoins eval;
       
  2867     if (!strcasecmp(value, "none"))
       
  2868       eval = flagjoins_none;
       
  2869     else if (!strcasecmp(value, "joins"))
       
  2870       eval = flagjoins_joins;
       
  2871     else if (!strcasecmp(value, "all"))
       
  2872       eval = flagjoins_all;
       
  2873     else {
       
  2874       eval = flagjoins_default;
       
  2875       if (strcasecmp(value, "default") != 0)
       
  2876         scr_LogPrint(LPRINT_NORMAL, "Unrecognized value, assuming default...");
       
  2877     }
       
  2878     buddy_setflagjoins(bud, eval);
  2860   }
  2879   }
  2861 
  2880 
  2862   free_arg_lst(paramlst);
  2881   free_arg_lst(paramlst);
  2863 }
  2882 }
  2864 
  2883 
  2960 {
  2979 {
  2961   const char *roomid;
  2980   const char *roomid;
  2962   const char *name = NULL, *nick = NULL, *group = NULL;
  2981   const char *name = NULL, *nick = NULL, *group = NULL;
  2963   char *tmpnick = NULL;
  2982   char *tmpnick = NULL;
  2964   enum room_autowhois autowhois = 0;
  2983   enum room_autowhois autowhois = 0;
       
  2984   enum room_flagjoins flagjoins = 0;
  2965   enum room_printstatus printstatus = 0;
  2985   enum room_printstatus printstatus = 0;
  2966   enum { bm_add = 0, bm_del = 1 } action = 0;
  2986   enum { bm_add = 0, bm_del = 1 } action = 0;
  2967   int autojoin = 0;
  2987   int autojoin = 0;
  2968   int nick_set = 0;
  2988   int nick_set = 0;
  2969 
  2989 
  2998     name = buddy_getname(bud);
  3018     name = buddy_getname(bud);
  2999     if (!nick_set)
  3019     if (!nick_set)
  3000       nick = buddy_getnickname(bud);
  3020       nick = buddy_getnickname(bud);
  3001     printstatus = buddy_getprintstatus(bud);
  3021     printstatus = buddy_getprintstatus(bud);
  3002     autowhois   = buddy_getautowhois(bud);
  3022     autowhois   = buddy_getautowhois(bud);
       
  3023     flagjoins   = buddy_getflagjoins(bud);
  3003     group       = buddy_getgroupname(bud);
  3024     group       = buddy_getgroupname(bud);
  3004   }
  3025   }
  3005 
  3026 
  3006   xmpp_set_storage_bookmark(roomid, name, nick, NULL, autojoin,
  3027   xmpp_set_storage_bookmark(roomid, name, nick, NULL, autojoin,
  3007                             printstatus, autowhois, group);
  3028                             printstatus, autowhois, flagjoins, group);
  3008   g_free (tmpnick);
  3029   g_free (tmpnick);
  3009 }
  3030 }
  3010 
  3031 
  3011 static void display_all_bookmarks(void)
  3032 static void display_all_bookmarks(void)
  3012 {
  3033 {