--- a/mcabber/mcabber/commands.c Tue Jan 19 16:09:27 2010 +0200
+++ b/mcabber/mcabber/commands.c Tue Jan 19 19:16:38 2010 +0200
@@ -888,7 +888,7 @@
char *msg;
enum imstatus st;
- if (!lconnection || !lm_connection_is_authenticated(lconnection)) {
+ if (!xmpp_is_online()) {
scr_LogPrint(LPRINT_NORMAL, "You are not connected.");
return;
}
@@ -1022,7 +1022,7 @@
char *id, *nick;
char *jid_utf8 = NULL;
- if (!lconnection || !lm_connection_is_authenticated(lconnection)) {
+ if (!xmpp_is_online()) {
scr_LogPrint(LPRINT_NORMAL, "You are not connected.");
return;
}
@@ -1184,7 +1184,7 @@
int isroom;
gpointer xep184 = NULL;
- if (!lconnection || !lm_connection_is_authenticated(lconnection)) {
+ if (!xmpp_is_online()) {
scr_LogPrint(LPRINT_NORMAL, "You are not connected.");
return 1;
}
@@ -1529,7 +1529,7 @@
LmMessageSubType msg_type = LM_MESSAGE_SUB_TYPE_NOT_SET;
bool quiet = FALSE;
- if (!lconnection || !lm_connection_is_authenticated(lconnection)) {
+ if (!xmpp_is_online()) {
scr_LogPrint(LPRINT_NORMAL, "You are not connected.");
return;
}
@@ -2249,7 +2249,7 @@
char **paramlst;
char *subcmd;
- if (!lconnection || !lm_connection_is_authenticated(lconnection)) {
+ if (!xmpp_is_online()) {
scr_LogPrint(LPRINT_NORMAL, "You are not connected.");
return;
}
@@ -3042,7 +3042,7 @@
char *subcmd;
gpointer bud;
- if (!lconnection || !lm_connection_is_authenticated(lconnection)) {
+ if (!xmpp_is_online()) {
scr_LogPrint(LPRINT_NORMAL, "You are not connected.");
return;
}
@@ -3139,7 +3139,7 @@
char *subcmd;
char *jid_utf8;
- if (!lconnection || !lm_connection_is_authenticated(lconnection)) {
+ if (!xmpp_is_online()) {
scr_LogPrint(LPRINT_NORMAL, "You are not connected.");
return;
}
@@ -3253,7 +3253,7 @@
return;
}
- if (!lconnection || !lm_connection_is_authenticated(lconnection)) {
+ if (!xmpp_is_online()) {
scr_LogPrint(LPRINT_NORMAL, "You are not connected.");
free_arg_lst(paramlst);
return;
--- a/mcabber/mcabber/histolog.c Tue Jan 19 16:09:27 2010 +0200
+++ b/mcabber/mcabber/histolog.c Tue Jan 19 19:16:38 2010 +0200
@@ -445,7 +445,7 @@
goto hlog_save_state_return;
}
- if (!lconnection || !lm_connection_is_authenticated(lconnection)) {
+ if (!xmpp_is_online()) {
// We're not connected. Let's use the unread_jids hash.
GList *unread_jid = unread_jid_get_list();
unread_ptr = unread_jid;
--- a/mcabber/mcabber/xmpp.c Tue Jan 19 16:09:27 2010 +0200
+++ b/mcabber/mcabber/xmpp.c Tue Jan 19 19:16:38 2010 +0200
@@ -93,6 +93,14 @@
iqlast = time(NULL);
}
+gboolean xmpp_is_online(void)
+{
+ if (lconnection && lm_connection_is_authenticated(lconnection))
+ return TRUE;
+ else
+ return FALSE;
+}
+
// Note: the caller should check the jid is correct
void xmpp_addbuddy(const char *bjid, const char *name, const char *group)
{
@@ -100,7 +108,7 @@
LmMessage *iq;
char *cleanjid;
- if (!lconnection || !lm_connection_is_authenticated(lconnection))
+ if (!xmpp_is_online())
return;
cleanjid = jidtodisp(bjid); // Stripping resource, just in case...
@@ -139,7 +147,7 @@
LmMessageNode *x;
char *cleanjid;
- if (!lconnection || !lm_connection_is_authenticated(lconnection))
+ if (!xmpp_is_online())
return;
// XXX We should check name's and group's correctness
@@ -170,7 +178,7 @@
LmMessage *iq;
char *cleanjid;
- if (!lconnection || !lm_connection_is_authenticated(lconnection))
+ if (!xmpp_is_online())
return;
cleanjid = jidtodisp(bjid); // Stripping resource, just in case...
@@ -306,7 +314,7 @@
if (encrypted)
*encrypted = 0;
- if (!lconnection || !lm_connection_is_authenticated(lconnection))
+ if (!xmpp_is_online())
return;
if (!text && type == ROSTER_TYPE_USER)
@@ -487,7 +495,7 @@
char *rjid, *fjid = NULL;
struct jep0085 *jep85 = NULL;
- if (!lconnection || !lm_connection_is_authenticated(lconnection))
+ if (!xmpp_is_online())
return;
sl_buddy = roster_find(bjid, jidsearch, ROSTER_TYPE_USER);
@@ -546,7 +554,7 @@
struct jep0022 *jep22 = NULL;
guint jep22_state;
- if (!lconnection || !lm_connection_is_authenticated(lconnection))
+ if (!xmpp_is_online())
return;
rname = strchr(fjid, JID_RESOURCE_SEPARATOR);
@@ -1814,7 +1822,7 @@
// Only send the packet if we're online.
// (But we want to update internal status even when disconnected,
// in order to avoid some problems during network failures)
- if (lconnection && lm_connection_is_authenticated(lconnection)) {
+ if (xmpp_is_online()) {
const char *s_msg = (st != invisible ? msg : NULL);
m = lm_message_new_presence(st, recipient, s_msg);
insert_entity_capabilities(m->node, st); // Entity Capabilities (XEP-0115)
@@ -1837,7 +1845,7 @@
// If we didn't change our _global_ status, we are done
if (recipient) return;
- if (lconnection && lm_connection_is_authenticated(lconnection)) {
+ if (xmpp_is_online()) {
// Send presence to chatrooms
if (st != invisible) {
struct T_presence room_presence;
@@ -2058,7 +2066,7 @@
if (!changed)
return;
- if (lconnection && lm_connection_is_authenticated(lconnection))
+ if (xmpp_is_online())
send_storage(bookmarks);
else
scr_LogPrint(LPRINT_LOGNORM,
@@ -2199,7 +2207,7 @@
if (!changed)
return;
- if (lconnection && lm_connection_is_authenticated(lconnection))
+ if (xmpp_is_online())
send_storage(rosternotes);
else
scr_LogPrint(LPRINT_LOGNORM,
--- a/mcabber/mcabber/xmpp.h Tue Jan 19 16:09:27 2010 +0200
+++ b/mcabber/mcabber/xmpp.h Tue Jan 19 19:16:38 2010 +0200
@@ -33,6 +33,7 @@
void xmpp_connect(void);
void xmpp_disconnect(void);
+gboolean xmpp_is_online(void);
void xmpp_room_join(const char *room, const char *nickname, const char *passwd);
int xmpp_room_setattrib(const char *roomid, const char *fjid,
--- a/mcabber/mcabber/xmpp_muc.c Tue Jan 19 16:09:27 2010 +0200
+++ b/mcabber/mcabber/xmpp_muc.c Tue Jan 19 19:16:38 2010 +0200
@@ -113,7 +113,7 @@
gchar *roomid;
GSList *room_elt;
- if (!lconnection || !lm_connection_is_authenticated(lconnection) || !room)
+ if (!xmpp_is_online() || !room)
return;
if (!nickname) return;
@@ -162,7 +162,7 @@
LmMessage *msg;
LmMessageNode *x, *y;
- if (!lconnection || !lm_connection_is_authenticated(lconnection) || !room || !fjid)
+ if (!xmpp_is_online() || !room || !fjid)
return;
msg = lm_message_new(room, LM_MESSAGE_TYPE_MESSAGE);
@@ -188,7 +188,7 @@
LmMessage *iq;
LmMessageNode *query, *x;
- if (!lconnection || !lm_connection_is_authenticated(lconnection) || !roomid)
+ if (!xmpp_is_online() || !roomid)
return 1;
if (!fjid && !nick) return 1;
@@ -238,7 +238,7 @@
LmMessageNode *node;
LmMessage *iq;
- if (!lconnection || !lm_connection_is_authenticated(lconnection) || !room)
+ if (!xmpp_is_online() || !room)
return;
iq = lm_message_new_with_sub_type(room, LM_MESSAGE_TYPE_IQ,
@@ -262,7 +262,7 @@
LmMessage *iq;
LmMessageNode *query, *x;
- if (!lconnection || !lm_connection_is_authenticated(lconnection) || !room)
+ if (!xmpp_is_online() || !room)
return;
iq = lm_message_new_with_sub_type(room, LM_MESSAGE_TYPE_IQ,