Mercurial > hg
changeset 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 | c024d1d5d350 |
files | mcabber/src/commands.c mcabber/src/jabglue.c mcabber/src/jabglue.h |
diffstat | 3 files changed, 38 insertions(+), 4 deletions(-) [+] |
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;
--- a/mcabber/src/jabglue.c Sun Oct 02 10:57:09 2005 +0200 +++ b/mcabber/src/jabglue.c Sun Oct 02 18:05:34 2005 +0200 @@ -43,7 +43,7 @@ static int s_id; static int regmode, regdone; static enum imstatus mystatus = offline; -unsigned char online; +static unsigned char online; char imstatus2char[imstatus_size+1] = { '_', 'o', 'i', 'f', 'd', 'n', 'a', '\0' @@ -120,6 +120,11 @@ return jid; } +inline unsigned char jb_getonline(void) +{ + return online; +} + jconn jb_connect(const char *jid, const char *server, unsigned int port, int ssl, const char *pass) { @@ -340,6 +345,8 @@ gchar *strtype; gchar *buffer = to_utf8(text); + if (!online) return; + if (type == ROSTER_TYPE_ROOM) strtype = TMSG_GROUPCHAT; else @@ -477,7 +484,8 @@ xmlnode x, y; gchar *roomid, *utf8_nickname; - if (!online || !room || !nickname) return; + if (!online || !room) return; + if (!nickname) return; utf8_nickname = to_utf8(nickname); roomid = g_strdup_printf("%s/%s", room, utf8_nickname); @@ -508,8 +516,7 @@ { xmlnode x, y, z; - if (!online) return; - if (!room) return; + if (!online || !room) return; x = jutil_iqnew(JPACKET__SET, "http://jabber.org/protocol/muc#owner"); xmlnode_put_attrib(x, "id", "unlock1"); // XXX
--- a/mcabber/src/jabglue.h Sun Oct 02 10:57:09 2005 +0200 +++ b/mcabber/src/jabglue.h Sun Oct 02 18:05:34 2005 +0200 @@ -40,6 +40,7 @@ const char *resource); jconn jb_connect(const char *jid, const char *server, unsigned int port, int ssl, const char *pass); +inline unsigned char jb_getonline(void); void jb_disconnect(void); void jb_main(); void jb_addbuddy(const char *jid, const char *name, const char *group);