Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/jabglue.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 | eaa2ad773192 |
children | c024d1d5d350 |
comparison
equal
deleted
inserted
replaced
471:82a27508fb85 | 472:75442262c082 |
---|---|
41 static unsigned int KeepaliveDelay; | 41 static unsigned int KeepaliveDelay; |
42 static unsigned int prio; | 42 static unsigned int prio; |
43 static int s_id; | 43 static int s_id; |
44 static int regmode, regdone; | 44 static int regmode, regdone; |
45 static enum imstatus mystatus = offline; | 45 static enum imstatus mystatus = offline; |
46 unsigned char online; | 46 static unsigned char online; |
47 | 47 |
48 char imstatus2char[imstatus_size+1] = { | 48 char imstatus2char[imstatus_size+1] = { |
49 '_', 'o', 'i', 'f', 'd', 'n', 'a', '\0' | 49 '_', 'o', 'i', 'f', 'd', 'n', 'a', '\0' |
50 }; | 50 }; |
51 | 51 |
118 strcat(jid, "/"); | 118 strcat(jid, "/"); |
119 strcat(jid, resource); | 119 strcat(jid, resource); |
120 return jid; | 120 return jid; |
121 } | 121 } |
122 | 122 |
123 inline unsigned char jb_getonline(void) | |
124 { | |
125 return online; | |
126 } | |
127 | |
123 jconn jb_connect(const char *jid, const char *server, unsigned int port, | 128 jconn jb_connect(const char *jid, const char *server, unsigned int port, |
124 int ssl, const char *pass) | 129 int ssl, const char *pass) |
125 { | 130 { |
126 char *utf8_jid; | 131 char *utf8_jid; |
127 if (!port) { | 132 if (!port) { |
337 | 342 |
338 void jb_send_msg(const char *jid, const char *text, int type) | 343 void jb_send_msg(const char *jid, const char *text, int type) |
339 { | 344 { |
340 gchar *strtype; | 345 gchar *strtype; |
341 gchar *buffer = to_utf8(text); | 346 gchar *buffer = to_utf8(text); |
347 | |
348 if (!online) return; | |
342 | 349 |
343 if (type == ROSTER_TYPE_ROOM) | 350 if (type == ROSTER_TYPE_ROOM) |
344 strtype = TMSG_GROUPCHAT; | 351 strtype = TMSG_GROUPCHAT; |
345 else | 352 else |
346 strtype = TMSG_CHAT; | 353 strtype = TMSG_CHAT; |
475 void jb_room_join(const char *room, const char *nickname) | 482 void jb_room_join(const char *room, const char *nickname) |
476 { | 483 { |
477 xmlnode x, y; | 484 xmlnode x, y; |
478 gchar *roomid, *utf8_nickname; | 485 gchar *roomid, *utf8_nickname; |
479 | 486 |
480 if (!online || !room || !nickname) return; | 487 if (!online || !room) return; |
488 if (!nickname) return; | |
481 | 489 |
482 utf8_nickname = to_utf8(nickname); | 490 utf8_nickname = to_utf8(nickname); |
483 roomid = g_strdup_printf("%s/%s", room, utf8_nickname); | 491 roomid = g_strdup_printf("%s/%s", room, utf8_nickname); |
484 g_free(utf8_nickname); | 492 g_free(utf8_nickname); |
485 if (check_jid_syntax(roomid)) { | 493 if (check_jid_syntax(roomid)) { |
506 // room syntax: "room@server" | 514 // room syntax: "room@server" |
507 void jb_room_unlock(const char *room) | 515 void jb_room_unlock(const char *room) |
508 { | 516 { |
509 xmlnode x, y, z; | 517 xmlnode x, y, z; |
510 | 518 |
511 if (!online) return; | 519 if (!online || !room) return; |
512 if (!room) return; | |
513 | 520 |
514 x = jutil_iqnew(JPACKET__SET, "http://jabber.org/protocol/muc#owner"); | 521 x = jutil_iqnew(JPACKET__SET, "http://jabber.org/protocol/muc#owner"); |
515 xmlnode_put_attrib(x, "id", "unlock1"); // XXX | 522 xmlnode_put_attrib(x, "id", "unlock1"); // XXX |
516 xmlnode_put_attrib(x, "to", room); | 523 xmlnode_put_attrib(x, "to", room); |
517 y = xmlnode_get_tag(x, "query"); | 524 y = xmlnode_get_tag(x, "query"); |