Mercurial > hg
comparison mcabber/src/commands.c @ 1377:cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
- add the command /room setopt
- add option 'muc_auto_whois'
The MUC settings auto_whois and print_status can be set on
a per-room basis.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Tue, 27 Nov 2007 23:57:20 +0100 |
parents | 23afeb5c555b |
children | 74b7621537d7 |
comparison
equal
deleted
inserted
replaced
1376:a0deb5124ebf | 1377:cd9182f0b5c7 |
---|---|
234 compl_add_category_word(COMPL_ROOM, "names"); | 234 compl_add_category_word(COMPL_ROOM, "names"); |
235 compl_add_category_word(COMPL_ROOM, "nick"); | 235 compl_add_category_word(COMPL_ROOM, "nick"); |
236 compl_add_category_word(COMPL_ROOM, "privmsg"); | 236 compl_add_category_word(COMPL_ROOM, "privmsg"); |
237 compl_add_category_word(COMPL_ROOM, "remove"); | 237 compl_add_category_word(COMPL_ROOM, "remove"); |
238 compl_add_category_word(COMPL_ROOM, "role"); | 238 compl_add_category_word(COMPL_ROOM, "role"); |
239 compl_add_category_word(COMPL_ROOM, "setopt"); | |
239 compl_add_category_word(COMPL_ROOM, "topic"); | 240 compl_add_category_word(COMPL_ROOM, "topic"); |
240 compl_add_category_word(COMPL_ROOM, "unban"); | 241 compl_add_category_word(COMPL_ROOM, "unban"); |
241 compl_add_category_word(COMPL_ROOM, "unlock"); | 242 compl_add_category_word(COMPL_ROOM, "unlock"); |
242 compl_add_category_word(COMPL_ROOM, "whois"); | 243 compl_add_category_word(COMPL_ROOM, "whois"); |
243 | 244 |
2424 } | 2425 } |
2425 | 2426 |
2426 jb_room_unlock(buddy_getjid(bud)); | 2427 jb_room_unlock(buddy_getjid(bud)); |
2427 } | 2428 } |
2428 | 2429 |
2430 static void room_setopt(gpointer bud, char *arg) | |
2431 { | |
2432 char **paramlst; | |
2433 char *param, *value; | |
2434 enum { opt_none = 0, opt_printstatus, opt_autowhois } option = 0; | |
2435 | |
2436 paramlst = split_arg(arg, 2, 1); // param, value | |
2437 param = *paramlst; | |
2438 value = *(paramlst+1); | |
2439 if (!param) { | |
2440 scr_LogPrint(LPRINT_NORMAL, "Please specify a room option."); | |
2441 free_arg_lst(paramlst); | |
2442 return; | |
2443 } | |
2444 | |
2445 if (!strcasecmp(param, "print_status")) | |
2446 option = opt_printstatus; | |
2447 else if (!strcasecmp(param, "auto_whois")) | |
2448 option = opt_autowhois; | |
2449 else { | |
2450 scr_LogPrint(LPRINT_NORMAL, "Wrong option!"); | |
2451 free_arg_lst(paramlst); | |
2452 return; | |
2453 } | |
2454 | |
2455 // If no value is given, display the current value | |
2456 if (!value) { | |
2457 const char *strval; | |
2458 if (option == opt_printstatus) | |
2459 strval = strprintstatus[buddy_getprintstatus(bud)]; | |
2460 else | |
2461 strval = strautowhois[buddy_getautowhois(bud)]; | |
2462 scr_LogPrint(LPRINT_NORMAL, "%s is set to: %s", param, strval); | |
2463 free_arg_lst(paramlst); | |
2464 return; | |
2465 } | |
2466 | |
2467 if (option == opt_printstatus) { | |
2468 enum room_printstatus eval; | |
2469 if (!strcasecmp(value, "none")) | |
2470 eval = status_none; | |
2471 else if (!strcasecmp(value, "in_and_out")) | |
2472 eval = status_in_and_out; | |
2473 else if (!strcasecmp(value, "all")) | |
2474 eval = status_all; | |
2475 else { | |
2476 eval = status_default; | |
2477 if (strcasecmp(value, "default") != 0) | |
2478 scr_LogPrint(LPRINT_NORMAL, "Unrecognized value, assuming default..."); | |
2479 } | |
2480 buddy_setprintstatus(bud, eval); | |
2481 } else if (option == opt_autowhois) { | |
2482 enum room_autowhois eval; | |
2483 if (!strcasecmp(value, "on")) | |
2484 eval = autowhois_on; | |
2485 else if (!strcasecmp(value, "off")) | |
2486 eval = autowhois_off; | |
2487 else { | |
2488 eval = autowhois_default; | |
2489 if (strcasecmp(value, "default") != 0) | |
2490 scr_LogPrint(LPRINT_NORMAL, "Unrecognized value, assuming default..."); | |
2491 } | |
2492 buddy_setautowhois(bud, eval); | |
2493 } | |
2494 | |
2495 free_arg_lst(paramlst); | |
2496 } | |
2497 | |
2429 // room_whois(..) | 2498 // room_whois(..) |
2430 // If interactive is TRUE, chatmode can be enabled. | 2499 // If interactive is TRUE, chatmode can be enabled. |
2431 void room_whois(gpointer bud, char *arg, guint interactive) | 2500 void room_whois(gpointer bud, char *arg, guint interactive) |
2432 { | 2501 { |
2433 char **paramlst; | 2502 char **paramlst; |
2654 if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) | 2723 if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
2655 room_destroy(bud, arg); | 2724 room_destroy(bud, arg); |
2656 } else if (!strcasecmp(subcmd, "unlock")) { | 2725 } else if (!strcasecmp(subcmd, "unlock")) { |
2657 if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) | 2726 if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
2658 room_unlock(bud, arg); | 2727 room_unlock(bud, arg); |
2728 } else if (!strcasecmp(subcmd, "setopt")) { | |
2729 if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) | |
2730 room_setopt(bud, arg); | |
2659 } else if (!strcasecmp(subcmd, "topic")) { | 2731 } else if (!strcasecmp(subcmd, "topic")) { |
2660 if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) | 2732 if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
2661 room_topic(bud, arg); | 2733 room_topic(bud, arg); |
2662 } else if (!strcasecmp(subcmd, "whois")) { | 2734 } else if (!strcasecmp(subcmd, "whois")) { |
2663 if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) | 2735 if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) |