Mercurial > hg
comparison mcabber/src/commands.c @ 283:00b2377539ac
Add /set command (to get/set/unset options values)
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Wed, 06 Jul 2005 22:29:17 +0100 |
parents | 4d7040cff8ee |
children | edc263a5d350 |
comparison
equal
deleted
inserted
replaced
282:87d6ac21cd1b | 283:00b2377539ac |
---|---|
28 #include "compl.h" | 28 #include "compl.h" |
29 #include "hooks.h" | 29 #include "hooks.h" |
30 #include "hbuf.h" | 30 #include "hbuf.h" |
31 #include "utf8.h" | 31 #include "utf8.h" |
32 #include "utils.h" | 32 #include "utils.h" |
33 #include "settings.h" | |
33 | 34 |
34 // Commands callbacks | 35 // Commands callbacks |
35 void do_roster(char *arg); | 36 void do_roster(char *arg); |
36 void do_status(char *arg); | 37 void do_status(char *arg); |
37 void do_add(char *arg); | 38 void do_add(char *arg); |
42 void do_buffer(char *arg); | 43 void do_buffer(char *arg); |
43 void do_clear(char *arg); | 44 void do_clear(char *arg); |
44 void do_info(char *arg); | 45 void do_info(char *arg); |
45 void do_rename(char *arg); | 46 void do_rename(char *arg); |
46 void do_move(char *arg); | 47 void do_move(char *arg); |
48 void do_set(char *arg); | |
47 | 49 |
48 // Global variable for the commands list | 50 // Global variable for the commands list |
49 static GSList *Commands; | 51 static GSList *Commands; |
50 | 52 |
51 | 53 |
88 cmd_add("roster", "Manipulate the roster/buddylist", COMPL_ROSTER, 0, | 90 cmd_add("roster", "Manipulate the roster/buddylist", COMPL_ROSTER, 0, |
89 &do_roster); | 91 &do_roster); |
90 cmd_add("say", "Say something to the selected buddy", 0, 0, &do_say); | 92 cmd_add("say", "Say something to the selected buddy", 0, 0, &do_say); |
91 //cmd_add("search"); | 93 //cmd_add("search"); |
92 //cmd_add("send_auth"); | 94 //cmd_add("send_auth"); |
95 cmd_add("set", "Set/query an option value", 0, 0, &do_set); | |
93 cmd_add("status", "Show or set your status", COMPL_STATUS, 0, &do_status); | 96 cmd_add("status", "Show or set your status", COMPL_STATUS, 0, &do_status); |
94 | 97 |
95 // Status category | 98 // Status category |
96 compl_add_category_word(COMPL_STATUS, "online"); | 99 compl_add_category_word(COMPL_STATUS, "online"); |
97 compl_add_category_word(COMPL_STATUS, "avail"); | 100 compl_add_category_word(COMPL_STATUS, "avail"); |
605 | 608 |
606 g_free(newgroupname); | 609 g_free(newgroupname); |
607 update_roster = TRUE; | 610 update_roster = TRUE; |
608 } | 611 } |
609 | 612 |
613 void do_set(char *arg) | |
614 { | |
615 guint assign; | |
616 const gchar *option, *value; | |
617 | |
618 assign = parse_assigment(arg, &option, &value); | |
619 if (!option) { | |
620 scr_LogPrint("Huh?"); | |
621 return; | |
622 } | |
623 if (!assign) { | |
624 // This is a query | |
625 value = settings_opt_get(option); | |
626 if (value) { | |
627 scr_LogPrint("%s = [%s]", option, value); | |
628 } else | |
629 scr_LogPrint("Option %s is not set", option); | |
630 return; | |
631 } | |
632 // Update the option | |
633 // XXX Maybe some options should be protected when user is connected | |
634 // (server, username, etc.). And we should catch some options here, too | |
635 // (hide_offline_buddies for ex.) | |
636 if (!value) { | |
637 settings_del(SETTINGS_TYPE_OPTION, option); | |
638 } else { | |
639 settings_set(SETTINGS_TYPE_OPTION, option, value); | |
640 } | |
641 } | |
642 |