Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/commands.c @ 472:75442262c082
Disable some commands when not connected
Disable status/status_to, add, rawxml, room, say/msay when not connected,
as these commands could be called with an empty buddylist.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sun, 02 Oct 2005 18:05:34 +0200 |
parents | 82a27508fb85 |
children | fa49ac0bb8f3 |
comparison
equal
deleted
inserted
replaced
471:82a27508fb85 | 472:75442262c082 |
---|---|
229 // the network. | 229 // the network. |
230 void send_message(const char *msg) | 230 void send_message(const char *msg) |
231 { | 231 { |
232 const char *jid; | 232 const char *jid; |
233 | 233 |
234 if (!jb_getonline()) { | |
235 scr_LogPrint(LPRINT_NORMAL, "You are not connected"); | |
236 return; | |
237 } | |
238 | |
234 if (!current_buddy) { | 239 if (!current_buddy) { |
235 scr_LogPrint(LPRINT_NORMAL, "No buddy currently selected."); | 240 scr_LogPrint(LPRINT_NORMAL, "No buddy currently selected."); |
236 return; | 241 return; |
237 } | 242 } |
238 | 243 |
401 { | 406 { |
402 enum imstatus st; | 407 enum imstatus st; |
403 int len; | 408 int len; |
404 char *msg; | 409 char *msg; |
405 | 410 |
411 if (!jb_getonline()) { | |
412 scr_LogPrint(LPRINT_NORMAL, "You are not connected"); | |
413 return; | |
414 } | |
415 | |
406 msg = strchr(arg, ' '); | 416 msg = strchr(arg, ' '); |
407 if (!msg) | 417 if (!msg) |
408 len = strlen(arg); | 418 len = strlen(arg); |
409 else | 419 else |
410 len = msg - arg; | 420 len = msg - arg; |
473 } | 483 } |
474 | 484 |
475 static void do_add(char *arg) | 485 static void do_add(char *arg) |
476 { | 486 { |
477 char *id, *nick; | 487 char *id, *nick; |
488 | |
489 if (!jb_getonline()) { | |
490 scr_LogPrint(LPRINT_NORMAL, "You are not connected"); | |
491 return; | |
492 } | |
493 | |
478 if (!arg || (!*arg)) { | 494 if (!arg || (!*arg)) { |
479 scr_LogPrint(LPRINT_NORMAL, "Wrong usage"); | 495 scr_LogPrint(LPRINT_NORMAL, "Wrong usage"); |
480 return; | 496 return; |
481 } | 497 } |
482 | 498 |
926 settings_set(SETTINGS_TYPE_BINDING, keycode, value); | 942 settings_set(SETTINGS_TYPE_BINDING, keycode, value); |
927 } | 943 } |
928 | 944 |
929 static void do_rawxml(char *arg) | 945 static void do_rawxml(char *arg) |
930 { | 946 { |
947 if (!jb_getonline()) { | |
948 scr_LogPrint(LPRINT_NORMAL, "You are not connected"); | |
949 return; | |
950 } | |
951 | |
931 if (!strncasecmp(arg, "send ", 5)) { | 952 if (!strncasecmp(arg, "send ", 5)) { |
932 gchar *buffer; | 953 gchar *buffer; |
933 for (arg += 5; *arg && *arg == ' '; arg++) | 954 for (arg += 5; *arg && *arg == ' '; arg++) |
934 ; | 955 ; |
935 buffer = to_utf8(arg); | 956 buffer = to_utf8(arg); |
947 } | 968 } |
948 | 969 |
949 static void do_room(char *arg) | 970 static void do_room(char *arg) |
950 { | 971 { |
951 gpointer bud; | 972 gpointer bud; |
973 | |
974 if (!jb_getonline()) { | |
975 scr_LogPrint(LPRINT_NORMAL, "You are not connected"); | |
976 return; | |
977 } | |
952 | 978 |
953 if (!arg || (!*arg)) { | 979 if (!arg || (!*arg)) { |
954 scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); | 980 scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); |
955 return; | 981 return; |
956 } | 982 } |