diff 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
line wrap: on
line diff
--- a/mcabber/src/commands.c	Sun Oct 02 10:57:09 2005 +0200
+++ b/mcabber/src/commands.c	Sun Oct 02 18:05:34 2005 +0200
@@ -231,6 +231,11 @@
 {
   const char *jid;
 
+  if (!jb_getonline()) {
+    scr_LogPrint(LPRINT_NORMAL, "You are not connected");
+    return;
+  }
+
   if (!current_buddy) {
     scr_LogPrint(LPRINT_NORMAL, "No buddy currently selected.");
     return;
@@ -403,6 +408,11 @@
   int len;
   char *msg;
 
+  if (!jb_getonline()) {
+    scr_LogPrint(LPRINT_NORMAL, "You are not connected");
+    return;
+  }
+
   msg = strchr(arg, ' ');
   if (!msg)
     len = strlen(arg);
@@ -475,6 +485,12 @@
 static void do_add(char *arg)
 {
   char *id, *nick;
+
+  if (!jb_getonline()) {
+    scr_LogPrint(LPRINT_NORMAL, "You are not connected");
+    return;
+  }
+
   if (!arg || (!*arg)) {
     scr_LogPrint(LPRINT_NORMAL, "Wrong usage");
     return;
@@ -928,6 +944,11 @@
 
 static void do_rawxml(char *arg)
 {
+  if (!jb_getonline()) {
+    scr_LogPrint(LPRINT_NORMAL, "You are not connected");
+    return;
+  }
+
   if (!strncasecmp(arg, "send ", 5))  {
     gchar *buffer;
     for (arg += 5; *arg && *arg == ' '; arg++)
@@ -950,6 +971,11 @@
 {
   gpointer bud;
 
+  if (!jb_getonline()) {
+    scr_LogPrint(LPRINT_NORMAL, "You are not connected");
+    return;
+  }
+
   if (!arg || (!*arg)) {
     scr_LogPrint(LPRINT_NORMAL, "Missing parameter");
     return;