Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/commands.c @ 116:1e7e59775f12
[/trunk] Changeset 130 by mikael
* Add /status command.
* Fix /quit command when there is a trailing word ("/quit bye"...).
* Add an extension (.txt) to the TODO file.
author | mikael |
---|---|
date | Mon, 25 Apr 2005 15:26:17 +0000 |
parents | 8ac67e951eab |
children | 1e8f646e2c5b |
comparison
equal
deleted
inserted
replaced
115:33bff2c57293 | 116:1e7e59775f12 |
---|---|
31 #include "utils.h" | 31 #include "utils.h" |
32 | 32 |
33 // Commands callbacks | 33 // Commands callbacks |
34 void do_roster(char *arg); | 34 void do_roster(char *arg); |
35 void do_clear(char *arg); | 35 void do_clear(char *arg); |
36 void do_status(char *arg); | |
36 | 37 |
37 // Global variable for the commands list | 38 // Global variable for the commands list |
38 static GSList *Commands; | 39 static GSList *Commands; |
39 | 40 |
40 | 41 |
71 //cmd_add("request_auth"); | 72 //cmd_add("request_auth"); |
72 cmd_add("roster", "Manipulate the roster/buddylist", COMPL_ROSTER, 0, &do_roster); | 73 cmd_add("roster", "Manipulate the roster/buddylist", COMPL_ROSTER, 0, &do_roster); |
73 cmd_add("say", "Say something to the selected buddy", 0, 0, NULL); | 74 cmd_add("say", "Say something to the selected buddy", 0, 0, NULL); |
74 //cmd_add("search"); | 75 //cmd_add("search"); |
75 //cmd_add("send_auth"); | 76 //cmd_add("send_auth"); |
76 cmd_add("status", "Show or set your status", COMPL_STATUS, 0, NULL); | 77 cmd_add("status", "Show or set your status", COMPL_STATUS, 0, &do_status); |
77 | 78 |
78 // Status category | 79 // Status category |
79 compl_add_category_word(COMPL_STATUS, "online"); | 80 compl_add_category_word(COMPL_STATUS, "online"); |
80 compl_add_category_word(COMPL_STATUS, "avail"); | 81 compl_add_category_word(COMPL_STATUS, "avail"); |
81 compl_add_category_word(COMPL_STATUS, "invisible"); | 82 compl_add_category_word(COMPL_STATUS, "invisible"); |
169 ; | 170 ; |
170 for (p-- ; p>line && (*p == ' ') ; p--) | 171 for (p-- ; p>line && (*p == ' ') ; p--) |
171 *p = 0; | 172 *p = 0; |
172 | 173 |
173 // Command "quit"? | 174 // Command "quit"? |
174 if (!strcasecmp(line, "/quit")) { | 175 if (!strncasecmp(line, "/quit", 5)) |
175 return 255; | 176 if (!line[5] || line[5] == ' ') |
176 } | 177 return 255; |
177 | 178 |
178 // Commands handling | 179 // Commands handling |
179 curcmd = cmd_get(line); | 180 curcmd = cmd_get(line); |
180 | 181 |
181 if (!curcmd) { | 182 if (!curcmd) { |
224 void do_clear(char *arg) | 225 void do_clear(char *arg) |
225 { | 226 { |
226 scr_Clear(); | 227 scr_Clear(); |
227 } | 228 } |
228 | 229 |
230 void do_status(char *arg) | |
231 { | |
232 enum imstatus st; | |
233 | |
234 if (!arg || (*arg == 0)) { | |
235 scr_LogPrint("Your status is: %c", imstatus2char[jb_getstatus()]); | |
236 return; | |
237 } | |
238 | |
239 if (!strcmp(arg, "offline")) st = offline; | |
240 else if (!strcmp(arg, "online")) st = available; | |
241 else if (!strcmp(arg, "avail")) st = available; | |
242 else if (!strcmp(arg, "away")) st = away; | |
243 else if (!strcmp(arg, "invisible")) st = invisible; | |
244 else if (!strcmp(arg, "dnd")) st = dontdisturb; | |
245 else if (!strcmp(arg, "busy")) st = occupied; | |
246 else if (!strcmp(arg, "notavail")) st = notavail; | |
247 else if (!strcmp(arg, "free")) st = freeforchat; | |
248 else { | |
249 // XXX TODO no parameter == status request | |
250 scr_LogPrint("Unrecognized parameter!"); | |
251 return; | |
252 } | |
253 | |
254 // XXX special case if offline?? | |
255 jb_setstatus(st, NULL); // TODO handle message (instead of NULL) | |
256 } | |
257 |