mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-24 06:26:21 +00:00
Merge branch 'master' into pgp
This commit is contained in:
@@ -74,7 +74,7 @@ bookmark_request(void)
|
||||
|
||||
autocomplete_free(bookmark_ac);
|
||||
bookmark_ac = autocomplete_new();
|
||||
if (bookmark_list != NULL) {
|
||||
if (bookmark_list) {
|
||||
g_list_free_full(bookmark_list, _bookmark_item_destroy);
|
||||
bookmark_list = NULL;
|
||||
}
|
||||
@@ -96,12 +96,12 @@ bookmark_add(const char *jid, const char *nick, const char *password, const char
|
||||
} else {
|
||||
Bookmark *item = malloc(sizeof(*item));
|
||||
item->jid = strdup(jid);
|
||||
if (nick != NULL) {
|
||||
if (nick) {
|
||||
item->nick = strdup(nick);
|
||||
} else {
|
||||
item->nick = NULL;
|
||||
}
|
||||
if (password != NULL) {
|
||||
if (password) {
|
||||
item->password = strdup(password);
|
||||
} else {
|
||||
item->password = NULL;
|
||||
@@ -136,15 +136,15 @@ bookmark_update(const char *jid, const char *nick, const char *password, const c
|
||||
return FALSE;
|
||||
} else {
|
||||
Bookmark *bm = found->data;
|
||||
if (nick != NULL) {
|
||||
if (nick) {
|
||||
free(bm->nick);
|
||||
bm->nick = strdup(nick);
|
||||
}
|
||||
if (password != NULL) {
|
||||
if (password) {
|
||||
free(bm->password);
|
||||
bm->password = strdup(password);
|
||||
}
|
||||
if (autojoin_str != NULL) {
|
||||
if (autojoin_str) {
|
||||
if (g_strcmp0(autojoin_str, "on") == 0) {
|
||||
bm->autojoin = TRUE;
|
||||
} else if (g_strcmp0(autojoin_str, "off") == 0) {
|
||||
@@ -228,7 +228,7 @@ bookmark_find(const char * const search_str)
|
||||
void
|
||||
bookmark_autocomplete_reset(void)
|
||||
{
|
||||
if (bookmark_ac != NULL) {
|
||||
if (bookmark_ac) {
|
||||
autocomplete_reset(bookmark_ac);
|
||||
}
|
||||
}
|
||||
@@ -413,14 +413,14 @@ _send_bookmarks(void)
|
||||
xmpp_stanza_set_ns(storage, "storage:bookmarks");
|
||||
|
||||
GList *curr = bookmark_list;
|
||||
while (curr != NULL) {
|
||||
while (curr) {
|
||||
Bookmark *bookmark = curr->data;
|
||||
xmpp_stanza_t *conference = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(conference, STANZA_NAME_CONFERENCE);
|
||||
xmpp_stanza_set_attribute(conference, STANZA_ATTR_JID, bookmark->jid);
|
||||
|
||||
Jid *jidp = jid_create(bookmark->jid);
|
||||
if (jidp->localpart != NULL) {
|
||||
if (jidp->localpart) {
|
||||
xmpp_stanza_set_attribute(conference, STANZA_ATTR_NAME, jidp->localpart);
|
||||
}
|
||||
jid_destroy(jidp);
|
||||
@@ -431,7 +431,7 @@ _send_bookmarks(void)
|
||||
xmpp_stanza_set_attribute(conference, STANZA_ATTR_AUTOJOIN, "false");
|
||||
}
|
||||
|
||||
if (bookmark->nick != NULL) {
|
||||
if (bookmark->nick) {
|
||||
xmpp_stanza_t *nick_st = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(nick_st, STANZA_NAME_NICK);
|
||||
xmpp_stanza_t *nick_text = xmpp_stanza_new(ctx);
|
||||
@@ -443,7 +443,7 @@ _send_bookmarks(void)
|
||||
xmpp_stanza_release(nick_st);
|
||||
}
|
||||
|
||||
if (bookmark->password != NULL) {
|
||||
if (bookmark->password) {
|
||||
xmpp_stanza_t *password_st = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(password_st, STANZA_NAME_PASSWORD);
|
||||
xmpp_stanza_t *password_text = xmpp_stanza_new(ctx);
|
||||
|
||||
@@ -203,7 +203,7 @@ _caps_by_ver(const char * const ver)
|
||||
|
||||
gsize features_len = 0;
|
||||
gchar **features = g_key_file_get_string_list(cache, ver, "features", &features_len, NULL);
|
||||
if (features != NULL && features_len > 0) {
|
||||
if (features && features_len > 0) {
|
||||
GSList *features_list = NULL;
|
||||
int i;
|
||||
for (i = 0; i < features_len; i++) {
|
||||
@@ -395,16 +395,16 @@ caps_create(xmpp_stanza_t *query)
|
||||
GSList *features = NULL;
|
||||
|
||||
xmpp_stanza_t *softwareinfo = xmpp_stanza_get_child_by_ns(query, STANZA_NS_DATA);
|
||||
if (softwareinfo != NULL) {
|
||||
if (softwareinfo) {
|
||||
DataForm *form = form_create(softwareinfo);
|
||||
FormField *formField = NULL;
|
||||
|
||||
char *form_type = form_get_form_type_field(form);
|
||||
if (g_strcmp0(form_type, STANZA_DATAFORM_SOFTWARE) == 0) {
|
||||
GSList *field = form->fields;
|
||||
while (field != NULL) {
|
||||
while (field) {
|
||||
formField = field->data;
|
||||
if (formField->values != NULL) {
|
||||
if (formField->values) {
|
||||
if (strcmp(formField->var, "software") == 0) {
|
||||
software = strdup(formField->values->data);
|
||||
} else if (strcmp(formField->var, "software_version") == 0) {
|
||||
@@ -424,7 +424,7 @@ caps_create(xmpp_stanza_t *query)
|
||||
|
||||
xmpp_stanza_t *child = xmpp_stanza_get_children(query);
|
||||
GSList *identity_stanzas = NULL;
|
||||
while (child != NULL) {
|
||||
while (child) {
|
||||
if (g_strcmp0(xmpp_stanza_get_name(child), "feature") == 0) {
|
||||
features = g_slist_append(features, strdup(xmpp_stanza_get_attribute(child, "var")));
|
||||
}
|
||||
@@ -490,42 +490,42 @@ caps_create(xmpp_stanza_t *query)
|
||||
|
||||
Capabilities *new_caps = malloc(sizeof(struct capabilities_t));
|
||||
|
||||
if (category != NULL) {
|
||||
if (category) {
|
||||
new_caps->category = strdup(category);
|
||||
} else {
|
||||
new_caps->category = NULL;
|
||||
}
|
||||
if (type != NULL) {
|
||||
if (type) {
|
||||
new_caps->type = strdup(type);
|
||||
} else {
|
||||
new_caps->type = NULL;
|
||||
}
|
||||
if (name != NULL) {
|
||||
if (name) {
|
||||
new_caps->name = strdup(name);
|
||||
} else {
|
||||
new_caps->name = NULL;
|
||||
}
|
||||
if (software != NULL) {
|
||||
if (software) {
|
||||
new_caps->software = software;
|
||||
} else {
|
||||
new_caps->software = NULL;
|
||||
}
|
||||
if (software_version != NULL) {
|
||||
if (software_version) {
|
||||
new_caps->software_version = software_version;
|
||||
} else {
|
||||
new_caps->software_version = NULL;
|
||||
}
|
||||
if (os != NULL) {
|
||||
if (os) {
|
||||
new_caps->os = os;
|
||||
} else {
|
||||
new_caps->os = NULL;
|
||||
}
|
||||
if (os_version != NULL) {
|
||||
if (os_version) {
|
||||
new_caps->os_version = os_version;
|
||||
} else {
|
||||
new_caps->os_version = NULL;
|
||||
}
|
||||
if (features != NULL) {
|
||||
if (features) {
|
||||
new_caps->features = features;
|
||||
} else {
|
||||
new_caps->features = NULL;
|
||||
@@ -635,7 +635,7 @@ caps_close(void)
|
||||
void
|
||||
caps_destroy(Capabilities *caps)
|
||||
{
|
||||
if (caps != NULL) {
|
||||
if (caps) {
|
||||
free(caps->category);
|
||||
free(caps->type);
|
||||
free(caps->name);
|
||||
@@ -643,7 +643,7 @@ caps_destroy(Capabilities *caps)
|
||||
free(caps->software_version);
|
||||
free(caps->os);
|
||||
free(caps->os_version);
|
||||
if (caps->features != NULL) {
|
||||
if (caps->features) {
|
||||
g_slist_free_full(caps->features, free);
|
||||
}
|
||||
free(caps);
|
||||
|
||||
@@ -129,11 +129,11 @@ jabber_connect_with_account(const ProfAccount * const account)
|
||||
log_info("Connecting using account: %s", account->name);
|
||||
|
||||
// save account name and password for reconnect
|
||||
if (saved_account.name != NULL) {
|
||||
if (saved_account.name) {
|
||||
free(saved_account.name);
|
||||
}
|
||||
saved_account.name = strdup(account->name);
|
||||
if (saved_account.passwd != NULL) {
|
||||
if (saved_account.passwd) {
|
||||
free(saved_account.passwd);
|
||||
}
|
||||
saved_account.passwd = strdup(account->password);
|
||||
@@ -157,7 +157,7 @@ jabber_connect_with_details(const char * const jid,
|
||||
// save details for reconnect, remember name for account creating on success
|
||||
saved_details.name = strdup(jid);
|
||||
saved_details.passwd = strdup(passwd);
|
||||
if (altdomain != NULL) {
|
||||
if (altdomain) {
|
||||
saved_details.altdomain = strdup(altdomain);
|
||||
} else {
|
||||
saved_details.altdomain = NULL;
|
||||
@@ -199,11 +199,11 @@ jabber_disconnect(void)
|
||||
_connection_free_saved_account();
|
||||
_connection_free_saved_details();
|
||||
_connection_free_session_data();
|
||||
if (jabber_conn.conn != NULL) {
|
||||
if (jabber_conn.conn) {
|
||||
xmpp_conn_release(jabber_conn.conn);
|
||||
jabber_conn.conn = NULL;
|
||||
}
|
||||
if (jabber_conn.ctx != NULL) {
|
||||
if (jabber_conn.ctx) {
|
||||
xmpp_ctx_free(jabber_conn.ctx);
|
||||
jabber_conn.ctx = NULL;
|
||||
}
|
||||
@@ -238,7 +238,7 @@ jabber_process_events(void)
|
||||
break;
|
||||
case JABBER_DISCONNECTED:
|
||||
reconnect_sec = prefs_get_reconnect();
|
||||
if ((reconnect_sec != 0) && (reconnect_timer != NULL)) {
|
||||
if ((reconnect_sec != 0) && reconnect_timer) {
|
||||
int elapsed_sec = g_timer_elapsed(reconnect_timer, NULL);
|
||||
if (elapsed_sec > reconnect_sec) {
|
||||
_jabber_reconnect();
|
||||
@@ -302,7 +302,7 @@ void
|
||||
connection_set_presence_message(const char * const message)
|
||||
{
|
||||
FREE_SET_NULL(jabber_conn.presence_message);
|
||||
if (message != NULL) {
|
||||
if (message) {
|
||||
jabber_conn.presence_message = strdup(message);
|
||||
}
|
||||
}
|
||||
@@ -371,15 +371,15 @@ _jabber_connect(const char * const fulljid, const char * const passwd,
|
||||
jid_destroy(jid);
|
||||
|
||||
log_info("Connecting as %s", fulljid);
|
||||
if (jabber_conn.log != NULL) {
|
||||
if (jabber_conn.log) {
|
||||
free(jabber_conn.log);
|
||||
}
|
||||
jabber_conn.log = _xmpp_get_file_logger();
|
||||
|
||||
if (jabber_conn.conn != NULL) {
|
||||
if (jabber_conn.conn) {
|
||||
xmpp_conn_release(jabber_conn.conn);
|
||||
}
|
||||
if (jabber_conn.ctx != NULL) {
|
||||
if (jabber_conn.ctx) {
|
||||
xmpp_ctx_free(jabber_conn.ctx);
|
||||
}
|
||||
jabber_conn.ctx = xmpp_ctx_new(NULL, jabber_conn.log);
|
||||
@@ -436,7 +436,7 @@ _connection_handler(xmpp_conn_t * const conn,
|
||||
log_debug("Connection handler: XMPP_CONN_CONNECT");
|
||||
|
||||
// logged in with account
|
||||
if (saved_account.name != NULL) {
|
||||
if (saved_account.name) {
|
||||
log_debug("Connection handler: logged in with account name: %s", saved_account.name);
|
||||
sv_ev_login_account_success(saved_account.name);
|
||||
|
||||
@@ -474,7 +474,7 @@ _connection_handler(xmpp_conn_t * const conn,
|
||||
jabber_conn.conn_status = JABBER_CONNECTED;
|
||||
|
||||
if (prefs_get_reconnect() != 0) {
|
||||
if (reconnect_timer != NULL) {
|
||||
if (reconnect_timer) {
|
||||
g_timer_destroy(reconnect_timer);
|
||||
reconnect_timer = NULL;
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ form_create(xmpp_stanza_t * const form_stanza)
|
||||
|
||||
field->var = _get_attr(field_stanza, "var");
|
||||
|
||||
if (field->type_t != FIELD_HIDDEN && field->var != NULL) {
|
||||
if (field->type_t != FIELD_HIDDEN && field->var) {
|
||||
GString *tag = g_string_new("");
|
||||
g_string_printf(tag, "field%d", tag_num++);
|
||||
g_hash_table_insert(form->var_to_tag, strdup(field->var), strdup(tag->str));
|
||||
|
||||
@@ -476,7 +476,7 @@ _error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID);
|
||||
char *error_msg = stanza_get_error_message(stanza);
|
||||
|
||||
if (id != NULL) {
|
||||
if (id) {
|
||||
log_debug("IQ error handler fired, id: %s, error: %s", id, error_msg);
|
||||
log_error("IQ error received, id: %s, error: %s", id, error_msg);
|
||||
} else {
|
||||
@@ -496,13 +496,13 @@ _pong_handler(xmpp_conn_t *const conn, xmpp_stanza_t * const stanza,
|
||||
char *id = xmpp_stanza_get_id(stanza);
|
||||
char *type = xmpp_stanza_get_type(stanza);
|
||||
|
||||
if (id != NULL) {
|
||||
if (id) {
|
||||
log_debug("IQ pong handler fired, id: %s.", id);
|
||||
} else {
|
||||
log_debug("IQ pong handler fired.");
|
||||
}
|
||||
|
||||
if (id != NULL && type != NULL) {
|
||||
if (id && type) {
|
||||
// show warning if error
|
||||
if (strcmp(type, STANZA_TYPE_ERROR) == 0) {
|
||||
char *error_msg = stanza_get_error_message(stanza);
|
||||
@@ -511,9 +511,9 @@ _pong_handler(xmpp_conn_t *const conn, xmpp_stanza_t * const stanza,
|
||||
|
||||
// turn off autoping if error type is 'cancel'
|
||||
xmpp_stanza_t *error = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR);
|
||||
if (error != NULL) {
|
||||
if (error) {
|
||||
char *errtype = xmpp_stanza_get_type(error);
|
||||
if (errtype != NULL) {
|
||||
if (errtype) {
|
||||
if (strcmp(errtype, "cancel") == 0) {
|
||||
log_warning("Server ping (id=%s) error type 'cancel', disabling autoping.", id);
|
||||
prefs_set_autoping(0);
|
||||
@@ -830,7 +830,7 @@ _version_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
{
|
||||
char *id = xmpp_stanza_get_id(stanza);
|
||||
|
||||
if (id != NULL) {
|
||||
if (id) {
|
||||
log_debug("IQ version result handler fired, id: %s.", id);
|
||||
} else {
|
||||
log_debug("IQ version result handler fired.");
|
||||
@@ -855,13 +855,13 @@ _version_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
xmpp_stanza_t *version = xmpp_stanza_get_child_by_name(query, "version");
|
||||
xmpp_stanza_t *os = xmpp_stanza_get_child_by_name(query, "os");
|
||||
|
||||
if (name != NULL) {
|
||||
if (name) {
|
||||
name_str = xmpp_stanza_get_text(name);
|
||||
}
|
||||
if (version != NULL) {
|
||||
if (version) {
|
||||
version_str = xmpp_stanza_get_text(version);
|
||||
}
|
||||
if (os != NULL) {
|
||||
if (os) {
|
||||
os_str = xmpp_stanza_get_text(os);
|
||||
}
|
||||
|
||||
@@ -892,7 +892,7 @@ _ping_get_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
const char *to = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_TO);
|
||||
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
|
||||
|
||||
if (id != NULL) {
|
||||
if (id) {
|
||||
log_debug("IQ ping get handler fired, id: %s.", id);
|
||||
} else {
|
||||
log_debug("IQ ping get handler fired.");
|
||||
@@ -908,7 +908,7 @@ _ping_get_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
xmpp_stanza_set_attribute(pong, STANZA_ATTR_FROM, to);
|
||||
xmpp_stanza_set_attribute(pong, STANZA_ATTR_TYPE, STANZA_TYPE_RESULT);
|
||||
|
||||
if (id != NULL) {
|
||||
if (id) {
|
||||
xmpp_stanza_set_attribute(pong, STANZA_ATTR_ID, id);
|
||||
}
|
||||
|
||||
@@ -926,16 +926,16 @@ _version_get_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID);
|
||||
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
|
||||
|
||||
if (id != NULL) {
|
||||
if (id) {
|
||||
log_debug("IQ version get handler fired, id: %s.", id);
|
||||
} else {
|
||||
log_debug("IQ version get handler fired.");
|
||||
}
|
||||
|
||||
if (from != NULL) {
|
||||
if (from) {
|
||||
xmpp_stanza_t *response = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(response, STANZA_NAME_IQ);
|
||||
if (id != NULL) {
|
||||
if (id) {
|
||||
xmpp_stanza_set_id(response, id);
|
||||
}
|
||||
xmpp_stanza_set_attribute(response, STANZA_ATTR_TO, from);
|
||||
@@ -994,13 +994,13 @@ _disco_items_get_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID);
|
||||
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
|
||||
|
||||
if (id != NULL) {
|
||||
if (id) {
|
||||
log_debug("IQ disco items get handler fired, id: %s.", id);
|
||||
} else {
|
||||
log_debug("IQ disco items get handler fired.");
|
||||
}
|
||||
|
||||
if (from != NULL) {
|
||||
if (from) {
|
||||
xmpp_stanza_t *response = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(response, STANZA_NAME_IQ);
|
||||
xmpp_stanza_set_id(response, xmpp_stanza_get_id(stanza));
|
||||
@@ -1031,20 +1031,20 @@ _disco_info_get_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
|
||||
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID);
|
||||
|
||||
if (id != NULL) {
|
||||
if (id) {
|
||||
log_debug("IQ disco info get handler fired, id: %s.", id);
|
||||
} else {
|
||||
log_debug("IQ disco info get handler fired.");
|
||||
}
|
||||
|
||||
if (from != NULL) {
|
||||
if (from) {
|
||||
xmpp_stanza_t *response = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(response, STANZA_NAME_IQ);
|
||||
xmpp_stanza_set_id(response, xmpp_stanza_get_id(stanza));
|
||||
xmpp_stanza_set_attribute(response, STANZA_ATTR_TO, from);
|
||||
xmpp_stanza_set_type(response, STANZA_TYPE_RESULT);
|
||||
xmpp_stanza_t *query = caps_create_query_response_stanza(ctx);
|
||||
if (node_str != NULL) {
|
||||
if (node_str) {
|
||||
xmpp_stanza_set_attribute(query, STANZA_ATTR_NODE, node_str);
|
||||
}
|
||||
xmpp_stanza_add_child(response, query);
|
||||
@@ -1063,7 +1063,7 @@ _destroy_room_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const sta
|
||||
{
|
||||
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID);
|
||||
|
||||
if (id != NULL) {
|
||||
if (id) {
|
||||
log_debug("IQ destroy room result handler fired, id: %s.", id);
|
||||
} else {
|
||||
log_debug("IQ destroy room result handler fired.");
|
||||
@@ -1087,7 +1087,7 @@ _room_config_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
const char *type = xmpp_stanza_get_type(stanza);
|
||||
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
|
||||
|
||||
if (id != NULL) {
|
||||
if (id) {
|
||||
log_debug("IQ room config handler fired, id: %s.", id);
|
||||
} else {
|
||||
log_debug("IQ room config handler fired.");
|
||||
@@ -1142,7 +1142,7 @@ static int _room_affiliation_set_result_handler(xmpp_conn_t * const conn, xmpp_s
|
||||
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
|
||||
struct privilege_set_t *affiliation_set = (struct privilege_set_t *)userdata;
|
||||
|
||||
if (id != NULL) {
|
||||
if (id) {
|
||||
log_debug("IQ affiliation set handler fired, id: %s.", id);
|
||||
} else {
|
||||
log_debug("IQ affiliation set handler fired.");
|
||||
@@ -1171,7 +1171,7 @@ static int _room_role_set_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t
|
||||
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
|
||||
struct privilege_set_t *role_set = (struct privilege_set_t *)userdata;
|
||||
|
||||
if (id != NULL) {
|
||||
if (id) {
|
||||
log_debug("IQ role set handler fired, id: %s.", id);
|
||||
} else {
|
||||
log_debug("IQ role set handler fired.");
|
||||
@@ -1200,7 +1200,7 @@ _room_affiliation_list_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t *
|
||||
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
|
||||
char *affiliation = (char *)userdata;
|
||||
|
||||
if (id != NULL) {
|
||||
if (id) {
|
||||
log_debug("IQ affiliation list result handler fired, id: %s.", id);
|
||||
} else {
|
||||
log_debug("IQ affiliation list result handler fired.");
|
||||
@@ -1248,7 +1248,7 @@ _room_role_list_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const s
|
||||
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
|
||||
char *role = (char *)userdata;
|
||||
|
||||
if (id != NULL) {
|
||||
if (id) {
|
||||
log_debug("IQ role list result handler fired, id: %s.", id);
|
||||
} else {
|
||||
log_debug("IQ role list result handler fired.");
|
||||
@@ -1295,7 +1295,7 @@ _room_config_submit_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stan
|
||||
const char *type = xmpp_stanza_get_type(stanza);
|
||||
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
|
||||
|
||||
if (id != NULL) {
|
||||
if (id) {
|
||||
log_debug("IQ room config submit handler fired, id: %s.", id);
|
||||
} else {
|
||||
log_debug("IQ room config submit handler fired.");
|
||||
@@ -1322,7 +1322,7 @@ _room_kick_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza
|
||||
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
|
||||
char *nick = (char *)userdata;
|
||||
|
||||
if (id != NULL) {
|
||||
if (id) {
|
||||
log_debug("IQ kick result handler fired, id: %s.", id);
|
||||
} else {
|
||||
log_debug("IQ kick result handler fired.");
|
||||
@@ -1345,7 +1345,7 @@ _room_kick_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza
|
||||
static void
|
||||
_identity_destroy(DiscoIdentity *identity)
|
||||
{
|
||||
if (identity != NULL) {
|
||||
if (identity) {
|
||||
free(identity->name);
|
||||
free(identity->type);
|
||||
free(identity->category);
|
||||
@@ -1356,7 +1356,7 @@ _identity_destroy(DiscoIdentity *identity)
|
||||
static void
|
||||
_item_destroy(DiscoItem *item)
|
||||
{
|
||||
if (item != NULL) {
|
||||
if (item) {
|
||||
free(item->jid);
|
||||
free(item->name);
|
||||
free(item);
|
||||
@@ -1385,15 +1385,15 @@ _room_info_response_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stan
|
||||
|
||||
xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
|
||||
|
||||
if (query != NULL) {
|
||||
if (query) {
|
||||
xmpp_stanza_t *child = xmpp_stanza_get_children(query);
|
||||
GSList *identities = NULL;
|
||||
GSList *features = NULL;
|
||||
while (child != NULL) {
|
||||
while (child) {
|
||||
const char *stanza_name = xmpp_stanza_get_name(child);
|
||||
if (g_strcmp0(stanza_name, STANZA_NAME_FEATURE) == 0) {
|
||||
const char *var = xmpp_stanza_get_attribute(child, STANZA_ATTR_VAR);
|
||||
if (var != NULL) {
|
||||
if (var) {
|
||||
features = g_slist_append(features, strdup(var));
|
||||
}
|
||||
} else if (g_strcmp0(stanza_name, STANZA_NAME_IDENTITY) == 0) {
|
||||
@@ -1401,20 +1401,20 @@ _room_info_response_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stan
|
||||
const char *type = xmpp_stanza_get_attribute(child, STANZA_ATTR_TYPE);
|
||||
const char *category = xmpp_stanza_get_attribute(child, STANZA_ATTR_CATEGORY);
|
||||
|
||||
if ((name != NULL) || (category != NULL) || (type != NULL)) {
|
||||
if (name || category || type) {
|
||||
DiscoIdentity *identity = malloc(sizeof(struct disco_identity_t));
|
||||
|
||||
if (name != NULL) {
|
||||
if (name) {
|
||||
identity->name = strdup(name);
|
||||
} else {
|
||||
identity->name = NULL;
|
||||
}
|
||||
if (category != NULL) {
|
||||
if (category) {
|
||||
identity->category = strdup(category);
|
||||
} else {
|
||||
identity->category = NULL;
|
||||
}
|
||||
if (type != NULL) {
|
||||
if (type) {
|
||||
identity->type = strdup(type);
|
||||
} else {
|
||||
identity->type = NULL;
|
||||
@@ -1469,15 +1469,15 @@ _disco_info_response_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const sta
|
||||
|
||||
xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
|
||||
|
||||
if (query != NULL) {
|
||||
if (query) {
|
||||
xmpp_stanza_t *child = xmpp_stanza_get_children(query);
|
||||
GSList *identities = NULL;
|
||||
GSList *features = NULL;
|
||||
while (child != NULL) {
|
||||
while (child) {
|
||||
const char *stanza_name = xmpp_stanza_get_name(child);
|
||||
if (g_strcmp0(stanza_name, STANZA_NAME_FEATURE) == 0) {
|
||||
const char *var = xmpp_stanza_get_attribute(child, STANZA_ATTR_VAR);
|
||||
if (var != NULL) {
|
||||
if (var) {
|
||||
features = g_slist_append(features, strdup(var));
|
||||
}
|
||||
} else if (g_strcmp0(stanza_name, STANZA_NAME_IDENTITY) == 0) {
|
||||
@@ -1485,20 +1485,20 @@ _disco_info_response_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const sta
|
||||
const char *type = xmpp_stanza_get_attribute(child, STANZA_ATTR_TYPE);
|
||||
const char *category = xmpp_stanza_get_attribute(child, STANZA_ATTR_CATEGORY);
|
||||
|
||||
if ((name != NULL) || (category != NULL) || (type != NULL)) {
|
||||
if (name || category || type) {
|
||||
DiscoIdentity *identity = malloc(sizeof(struct disco_identity_t));
|
||||
|
||||
if (name != NULL) {
|
||||
if (name) {
|
||||
identity->name = strdup(name);
|
||||
} else {
|
||||
identity->name = NULL;
|
||||
}
|
||||
if (category != NULL) {
|
||||
if (category) {
|
||||
identity->category = strdup(category);
|
||||
} else {
|
||||
identity->category = NULL;
|
||||
}
|
||||
if (type != NULL) {
|
||||
if (type) {
|
||||
identity->type = strdup(type);
|
||||
} else {
|
||||
identity->type = NULL;
|
||||
@@ -1534,17 +1534,17 @@ _disco_items_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stan
|
||||
log_debug("Response to query: %s", id);
|
||||
xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
|
||||
|
||||
if (query != NULL) {
|
||||
if (query) {
|
||||
xmpp_stanza_t *child = xmpp_stanza_get_children(query);
|
||||
while (child != NULL) {
|
||||
while (child) {
|
||||
const char *stanza_name = xmpp_stanza_get_name(child);
|
||||
if ((stanza_name != NULL) && (g_strcmp0(stanza_name, STANZA_NAME_ITEM) == 0)) {
|
||||
if (stanza_name && (g_strcmp0(stanza_name, STANZA_NAME_ITEM) == 0)) {
|
||||
const char *item_jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
|
||||
if (item_jid != NULL) {
|
||||
if (item_jid) {
|
||||
DiscoItem *item = malloc(sizeof(struct disco_item_t));
|
||||
item->jid = strdup(item_jid);
|
||||
const char *item_name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME);
|
||||
if (item_name != NULL) {
|
||||
if (item_name) {
|
||||
item->name = strdup(item_name);
|
||||
} else {
|
||||
item->name = NULL;
|
||||
|
||||
@@ -174,7 +174,7 @@ presence_sub_request_exists(const char * const bare_jid)
|
||||
GSList *requests_p = autocomplete_create_list(sub_requests_ac);
|
||||
GSList *requests = requests_p;
|
||||
|
||||
while (requests != NULL) {
|
||||
while (requests) {
|
||||
if (strcmp(requests->data, bare_jid) == 0) {
|
||||
result = TRUE;
|
||||
break;
|
||||
@@ -182,7 +182,7 @@ presence_sub_request_exists(const char * const bare_jid)
|
||||
requests = g_slist_next(requests);
|
||||
}
|
||||
|
||||
if (requests_p != NULL) {
|
||||
if (requests_p) {
|
||||
g_slist_free_full(requests_p, free);
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ presence_update(const resource_presence_t presence_type, const char * const msg,
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg != NULL) {
|
||||
if (msg) {
|
||||
log_debug("Updating presence: %s, \"%s\"",
|
||||
string_from_resource_presence(presence_type), msg);
|
||||
} else {
|
||||
@@ -273,11 +273,11 @@ _send_room_presence(xmpp_conn_t *conn, xmpp_stanza_t *presence)
|
||||
GList *rooms_p = muc_rooms();
|
||||
GList *rooms = rooms_p;
|
||||
|
||||
while (rooms != NULL) {
|
||||
while (rooms) {
|
||||
const char *room = rooms->data;
|
||||
const char *nick = muc_nick(room);
|
||||
|
||||
if (nick != NULL) {
|
||||
if (nick) {
|
||||
char *full_room_jid = create_fulljid(room, nick);
|
||||
|
||||
xmpp_stanza_set_attribute(presence, STANZA_ATTR_TO, full_room_jid);
|
||||
@@ -289,7 +289,7 @@ _send_room_presence(xmpp_conn_t *conn, xmpp_stanza_t *presence)
|
||||
rooms = g_list_next(rooms);
|
||||
}
|
||||
|
||||
if (rooms_p != NULL) {
|
||||
if (rooms_p) {
|
||||
g_list_free(rooms_p);
|
||||
}
|
||||
}
|
||||
@@ -361,7 +361,7 @@ presence_leave_chat_room(const char * const room_jid)
|
||||
xmpp_conn_t *conn = connection_get_conn();
|
||||
char *nick = muc_nick(room_jid);
|
||||
|
||||
if (nick != NULL) {
|
||||
if (nick) {
|
||||
xmpp_stanza_t *presence = stanza_create_room_leave_presence(ctx, room_jid,
|
||||
nick);
|
||||
xmpp_send(conn, presence);
|
||||
@@ -378,11 +378,11 @@ _presence_error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
xmpp_stanza_t *error_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR);
|
||||
xmpp_stanza_t *x = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_X);
|
||||
char *xmlns = NULL;
|
||||
if (x != NULL) {
|
||||
if (x) {
|
||||
xmlns = xmpp_stanza_get_ns(x);
|
||||
}
|
||||
char *type = NULL;
|
||||
if (error_stanza != NULL) {
|
||||
if (error_stanza) {
|
||||
type = xmpp_stanza_get_attribute(error_stanza, STANZA_ATTR_TYPE);
|
||||
}
|
||||
|
||||
@@ -392,7 +392,7 @@ _presence_error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
|
||||
char *error_cond = NULL;
|
||||
xmpp_stanza_t *reason_st = xmpp_stanza_get_child_by_ns(error_stanza, STANZA_NS_STANZAS);
|
||||
if (reason_st != NULL) {
|
||||
if (reason_st) {
|
||||
error_cond = xmpp_stanza_get_name(reason_st);
|
||||
}
|
||||
if (error_cond == NULL) {
|
||||
@@ -412,15 +412,15 @@ _presence_error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
char *err_msg = stanza_get_error_message(stanza);
|
||||
|
||||
GString *log_msg = g_string_new("presence stanza error received");
|
||||
if (id != NULL) {
|
||||
if (id) {
|
||||
g_string_append(log_msg, " id=");
|
||||
g_string_append(log_msg, id);
|
||||
}
|
||||
if (from != NULL) {
|
||||
if (from) {
|
||||
g_string_append(log_msg, " from=");
|
||||
g_string_append(log_msg, from);
|
||||
}
|
||||
if (type != NULL) {
|
||||
if (type) {
|
||||
g_string_append(log_msg, " type=");
|
||||
g_string_append(log_msg, type);
|
||||
}
|
||||
@@ -431,7 +431,7 @@ _presence_error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
|
||||
g_string_free(log_msg, TRUE);
|
||||
|
||||
if (from != NULL) {
|
||||
if (from) {
|
||||
ui_handle_recipient_error(from, err_msg);
|
||||
} else {
|
||||
ui_handle_error(err_msg);
|
||||
@@ -514,7 +514,7 @@ _unavailable_handler(xmpp_conn_t * const conn,
|
||||
char *status_str = stanza_get_status(stanza, NULL);
|
||||
|
||||
if (strcmp(my_jid->barejid, from_jid->barejid) !=0) {
|
||||
if (from_jid->resourcepart != NULL) {
|
||||
if (from_jid->resourcepart) {
|
||||
sv_ev_contact_offline(from_jid->barejid, from_jid->resourcepart, status_str);
|
||||
|
||||
// hack for servers that do not send full jid with unavailable presence
|
||||
@@ -522,7 +522,7 @@ _unavailable_handler(xmpp_conn_t * const conn,
|
||||
sv_ev_contact_offline(from_jid->barejid, "__prof_default", status_str);
|
||||
}
|
||||
} else {
|
||||
if (from_jid->resourcepart != NULL) {
|
||||
if (from_jid->resourcepart) {
|
||||
connection_remove_available_resource(from_jid->resourcepart);
|
||||
}
|
||||
}
|
||||
@@ -656,7 +656,7 @@ _send_caps_request(char *node, char *caps_key, char *id, char *from)
|
||||
xmpp_ctx_t *ctx = connection_get_ctx();
|
||||
xmpp_conn_t *conn = connection_get_conn();
|
||||
|
||||
if (node != NULL) {
|
||||
if (node) {
|
||||
log_debug("Node string: %s.", node);
|
||||
if (!caps_contains(caps_key)) {
|
||||
log_debug("Capabilities not cached for '%s', sending discovery IQ.", from);
|
||||
@@ -732,14 +732,14 @@ _muc_user_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void *
|
||||
free(reason);
|
||||
|
||||
// kicked from room
|
||||
} else if (g_slist_find_custom(status_codes, "307", (GCompareFunc)g_strcmp0) != NULL) {
|
||||
} else if (g_slist_find_custom(status_codes, "307", (GCompareFunc)g_strcmp0)) {
|
||||
char *actor = stanza_get_actor(stanza);
|
||||
char *reason = stanza_get_reason(stanza);
|
||||
sv_ev_room_kicked(room, actor, reason);
|
||||
free(reason);
|
||||
|
||||
// banned from room
|
||||
} else if (g_slist_find_custom(status_codes, "301", (GCompareFunc)g_strcmp0) != NULL) {
|
||||
} else if (g_slist_find_custom(status_codes, "301", (GCompareFunc)g_strcmp0)) {
|
||||
char *actor = stanza_get_actor(stanza);
|
||||
char *reason = stanza_get_reason(stanza);
|
||||
sv_ev_room_banned(room, actor, reason);
|
||||
@@ -777,14 +777,14 @@ _muc_user_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void *
|
||||
GSList *status_codes = stanza_get_status_codes_by_ns(stanza, STANZA_NS_MUC_USER);
|
||||
|
||||
// kicked from room
|
||||
if (g_slist_find_custom(status_codes, "307", (GCompareFunc)g_strcmp0) != NULL) {
|
||||
if (g_slist_find_custom(status_codes, "307", (GCompareFunc)g_strcmp0)) {
|
||||
char *actor = stanza_get_actor(stanza);
|
||||
char *reason = stanza_get_reason(stanza);
|
||||
sv_ev_room_occupent_kicked(room, nick, actor, reason);
|
||||
free(reason);
|
||||
|
||||
// banned from room
|
||||
} else if (g_slist_find_custom(status_codes, "301", (GCompareFunc)g_strcmp0) != NULL) {
|
||||
} else if (g_slist_find_custom(status_codes, "301", (GCompareFunc)g_strcmp0)) {
|
||||
char *actor = stanza_get_actor(stanza);
|
||||
char *reason = stanza_get_reason(stanza);
|
||||
sv_ev_room_occupent_banned(room, nick, actor, reason);
|
||||
|
||||
@@ -132,7 +132,7 @@ roster_send_add_to_group(const char * const group, PContact contact)
|
||||
{
|
||||
GSList *groups = p_contact_groups(contact);
|
||||
GSList *new_groups = NULL;
|
||||
while (groups != NULL) {
|
||||
while (groups) {
|
||||
new_groups = g_slist_append(new_groups, strdup(groups->data));
|
||||
groups = g_slist_next(groups);
|
||||
}
|
||||
@@ -142,7 +142,7 @@ roster_send_add_to_group(const char * const group, PContact contact)
|
||||
char *unique_id = create_unique_id(NULL);
|
||||
GroupData *data = malloc(sizeof(GroupData));
|
||||
data->group = strdup(group);
|
||||
if (p_contact_name(contact) != NULL) {
|
||||
if (p_contact_name(contact)) {
|
||||
data->name = strdup(p_contact_name(contact));
|
||||
} else {
|
||||
data->name = strdup(p_contact_barejid(contact));
|
||||
@@ -162,7 +162,7 @@ static int
|
||||
_group_add_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
void * const userdata)
|
||||
{
|
||||
if (userdata != NULL) {
|
||||
if (userdata) {
|
||||
GroupData *data = userdata;
|
||||
ui_group_added(data->name, data->group);
|
||||
free(data->name);
|
||||
@@ -177,7 +177,7 @@ roster_send_remove_from_group(const char * const group, PContact contact)
|
||||
{
|
||||
GSList *groups = p_contact_groups(contact);
|
||||
GSList *new_groups = NULL;
|
||||
while (groups != NULL) {
|
||||
while (groups) {
|
||||
if (strcmp(groups->data, group) != 0) {
|
||||
new_groups = g_slist_append(new_groups, strdup(groups->data));
|
||||
}
|
||||
@@ -191,7 +191,7 @@ roster_send_remove_from_group(const char * const group, PContact contact)
|
||||
char *unique_id = create_unique_id(NULL);
|
||||
GroupData *data = malloc(sizeof(GroupData));
|
||||
data->group = strdup(group);
|
||||
if (p_contact_name(contact) != NULL) {
|
||||
if (p_contact_name(contact)) {
|
||||
data->name = strdup(p_contact_name(contact));
|
||||
} else {
|
||||
data->name = strdup(p_contact_barejid(contact));
|
||||
@@ -209,7 +209,7 @@ static int
|
||||
_group_remove_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
void * const userdata)
|
||||
{
|
||||
if (userdata != NULL) {
|
||||
if (userdata) {
|
||||
GroupData *data = userdata;
|
||||
ui_group_removed(data->name, data->group);
|
||||
free(data->name);
|
||||
@@ -235,7 +235,7 @@ _roster_set_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
// if from attribute exists and it is not current users barejid, ignore push
|
||||
Jid *my_jid = jid_create(jabber_get_fulljid());
|
||||
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
|
||||
if ((from != NULL) && (strcmp(from, my_jid->barejid) != 0)) {
|
||||
if (from && (strcmp(from, my_jid->barejid) != 0)) {
|
||||
jid_destroy(my_jid);
|
||||
return 1;
|
||||
}
|
||||
@@ -266,7 +266,7 @@ _roster_set_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
|
||||
// check for pending out subscriptions
|
||||
gboolean pending_out = FALSE;
|
||||
if ((ask != NULL) && (strcmp(ask, "subscribe") == 0)) {
|
||||
if (ask && (strcmp(ask, "subscribe") == 0)) {
|
||||
pending_out = TRUE;
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ _roster_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
|
||||
xmpp_stanza_t *item = xmpp_stanza_get_children(query);
|
||||
|
||||
while (item != NULL) {
|
||||
while (item) {
|
||||
const char *barejid = xmpp_stanza_get_attribute(item, STANZA_ATTR_JID);
|
||||
gchar *barejid_lower = g_utf8_strdown(barejid, -1);
|
||||
const char *name = xmpp_stanza_get_attribute(item, STANZA_ATTR_NAME);
|
||||
@@ -344,10 +344,10 @@ _get_groups_from_item(xmpp_stanza_t *item)
|
||||
GSList *groups = NULL;
|
||||
xmpp_stanza_t *group_element = xmpp_stanza_get_children(item);
|
||||
|
||||
while (group_element != NULL) {
|
||||
while (group_element) {
|
||||
if (strcmp(xmpp_stanza_get_name(group_element), STANZA_NAME_GROUP) == 0) {
|
||||
char *groupname = xmpp_stanza_get_text(group_element);
|
||||
if (groupname != NULL) {
|
||||
if (groupname) {
|
||||
groups = g_slist_append(groups, groupname);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ stanza_create_bookmarks_pubsub_add(xmpp_ctx_t *ctx, const char * const jid,
|
||||
xmpp_stanza_set_attribute(conference, STANZA_ATTR_AUTOJOIN, "false");
|
||||
}
|
||||
|
||||
if (nick != NULL) {
|
||||
if (nick) {
|
||||
xmpp_stanza_t *nick_st = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(nick_st, STANZA_NAME_NICK);
|
||||
xmpp_stanza_set_text(nick_st, nick);
|
||||
@@ -374,7 +374,7 @@ stanza_create_roster_set(xmpp_ctx_t *ctx, const char * const id,
|
||||
xmpp_stanza_t *iq = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
|
||||
xmpp_stanza_set_type(iq, STANZA_TYPE_SET);
|
||||
if (id != NULL) {
|
||||
if (id) {
|
||||
xmpp_stanza_set_id(iq, id);
|
||||
}
|
||||
|
||||
@@ -386,13 +386,13 @@ stanza_create_roster_set(xmpp_ctx_t *ctx, const char * const id,
|
||||
xmpp_stanza_set_name(item, STANZA_NAME_ITEM);
|
||||
xmpp_stanza_set_attribute(item, STANZA_ATTR_JID, jid);
|
||||
|
||||
if (handle != NULL) {
|
||||
if (handle) {
|
||||
xmpp_stanza_set_attribute(item, STANZA_ATTR_NAME, handle);
|
||||
} else {
|
||||
xmpp_stanza_set_attribute(item, STANZA_ATTR_NAME, "");
|
||||
}
|
||||
|
||||
while (groups != NULL) {
|
||||
while (groups) {
|
||||
xmpp_stanza_t *group = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_t *groupname = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(group, STANZA_NAME_GROUP);
|
||||
@@ -464,7 +464,7 @@ stanza_create_mediated_invite(xmpp_ctx_t *ctx, const char * const room,
|
||||
xmpp_stanza_set_name(invite, STANZA_NAME_INVITE);
|
||||
xmpp_stanza_set_attribute(invite, STANZA_ATTR_TO, contact);
|
||||
|
||||
if (reason != NULL) {
|
||||
if (reason) {
|
||||
xmpp_stanza_t *reason_st = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(reason_st, STANZA_NAME_REASON);
|
||||
xmpp_stanza_t *reason_txt = xmpp_stanza_new(ctx);
|
||||
@@ -499,7 +499,7 @@ stanza_create_room_join_presence(xmpp_ctx_t * const ctx,
|
||||
xmpp_stanza_set_ns(x, STANZA_NS_MUC);
|
||||
|
||||
// if a password was given
|
||||
if (passwd != NULL) {
|
||||
if (passwd) {
|
||||
xmpp_stanza_t *pass = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(pass, "password");
|
||||
xmpp_stanza_t *text = xmpp_stanza_new(ctx);
|
||||
@@ -893,7 +893,7 @@ stanza_create_disco_info_iq(xmpp_ctx_t *ctx, const char * const id, const char *
|
||||
xmpp_stanza_t *query = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
|
||||
xmpp_stanza_set_ns(query, XMPP_NS_DISCO_INFO);
|
||||
if (node != NULL) {
|
||||
if (node) {
|
||||
xmpp_stanza_set_attribute(query, STANZA_ATTR_NODE, node);
|
||||
}
|
||||
|
||||
@@ -964,7 +964,7 @@ stanza_create_ping_iq(xmpp_ctx_t *ctx, const char * const target)
|
||||
xmpp_stanza_t *iq = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
|
||||
xmpp_stanza_set_type(iq, STANZA_TYPE_GET);
|
||||
if (target != NULL) {
|
||||
if (target) {
|
||||
xmpp_stanza_set_attribute(iq, STANZA_ATTR_TO, target);
|
||||
}
|
||||
char *id = create_unique_id("ping");
|
||||
@@ -987,11 +987,11 @@ stanza_get_delay(xmpp_stanza_t * const stanza, GTimeVal *tv_stamp)
|
||||
{
|
||||
// first check for XEP-0203 delayed delivery
|
||||
xmpp_stanza_t *delay = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_DELAY);
|
||||
if (delay != NULL) {
|
||||
if (delay) {
|
||||
char *xmlns = xmpp_stanza_get_attribute(delay, STANZA_ATTR_XMLNS);
|
||||
if ((xmlns != NULL) && (strcmp(xmlns, "urn:xmpp:delay") == 0)) {
|
||||
if (xmlns && (strcmp(xmlns, "urn:xmpp:delay") == 0)) {
|
||||
char *stamp = xmpp_stanza_get_attribute(delay, STANZA_ATTR_STAMP);
|
||||
if ((stamp != NULL) && (g_time_val_from_iso8601(stamp, tv_stamp))) {
|
||||
if (stamp && (g_time_val_from_iso8601(stamp, tv_stamp))) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -1000,11 +1000,11 @@ stanza_get_delay(xmpp_stanza_t * const stanza, GTimeVal *tv_stamp)
|
||||
// otherwise check for XEP-0091 legacy delayed delivery
|
||||
// stanp format : CCYYMMDDThh:mm:ss
|
||||
xmpp_stanza_t *x = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_X);
|
||||
if (x != NULL) {
|
||||
if (x) {
|
||||
char *xmlns = xmpp_stanza_get_attribute(x, STANZA_ATTR_XMLNS);
|
||||
if ((xmlns != NULL) && (strcmp(xmlns, "jabber:x:delay") == 0)) {
|
||||
if (xmlns && (strcmp(xmlns, "jabber:x:delay") == 0)) {
|
||||
char *stamp = xmpp_stanza_get_attribute(x, STANZA_ATTR_STAMP);
|
||||
if ((stamp != NULL) && (g_time_val_from_iso8601(stamp, tv_stamp))) {
|
||||
if (stamp && (g_time_val_from_iso8601(stamp, tv_stamp))) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -1020,17 +1020,17 @@ stanza_get_status(xmpp_stanza_t *stanza, char *def)
|
||||
xmpp_stanza_t *status =
|
||||
xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_STATUS);
|
||||
|
||||
if (status != NULL) {
|
||||
if (status) {
|
||||
// xmpp_free and free may be different functions so convert all to
|
||||
// libc malloc
|
||||
char *s1, *s2 = NULL;
|
||||
s1 = xmpp_stanza_get_text(status);
|
||||
if (s1 != NULL) {
|
||||
if (s1) {
|
||||
s2 = strdup(s1);
|
||||
xmpp_free(ctx, s1);
|
||||
}
|
||||
return s2;
|
||||
} else if (def != NULL) {
|
||||
} else if (def) {
|
||||
return strdup(def);
|
||||
} else {
|
||||
return NULL;
|
||||
@@ -1044,17 +1044,17 @@ stanza_get_show(xmpp_stanza_t *stanza, char *def)
|
||||
xmpp_stanza_t *show =
|
||||
xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_SHOW);
|
||||
|
||||
if (show != NULL) {
|
||||
if (show) {
|
||||
// xmpp_free and free may be different functions so convert all to
|
||||
// libc malloc
|
||||
char *s1, *s2 = NULL;
|
||||
s1 = xmpp_stanza_get_text(show);
|
||||
if (s1 != NULL) {
|
||||
if (s1) {
|
||||
s2 = strdup(s1);
|
||||
xmpp_free(ctx, s1);
|
||||
}
|
||||
return s2;
|
||||
} else if (def != NULL) {
|
||||
} else if (def) {
|
||||
return strdup(def);
|
||||
} else {
|
||||
return NULL;
|
||||
@@ -1090,7 +1090,7 @@ stanza_muc_requires_config(xmpp_stanza_t * const stanza)
|
||||
|
||||
// muc user namespaced x element
|
||||
xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
|
||||
if (x != NULL) {
|
||||
if (x) {
|
||||
|
||||
// check for item element with owner affiliation
|
||||
xmpp_stanza_t *item = xmpp_stanza_get_child_by_name(x, "item");
|
||||
@@ -1104,7 +1104,7 @@ stanza_muc_requires_config(xmpp_stanza_t * const stanza)
|
||||
|
||||
// check for status code 201
|
||||
xmpp_stanza_t *x_children = xmpp_stanza_get_children(x);
|
||||
while (x_children != NULL) {
|
||||
while (x_children) {
|
||||
if (g_strcmp0(xmpp_stanza_get_name(x_children), STANZA_NAME_STATUS) == 0) {
|
||||
char *code = xmpp_stanza_get_attribute(x_children, STANZA_ATTR_CODE);
|
||||
if (g_strcmp0(code, "201") == 0) {
|
||||
@@ -1346,11 +1346,11 @@ stanza_is_room_nick_change(xmpp_stanza_t * const stanza)
|
||||
|
||||
// muc user namespaced x element
|
||||
xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
|
||||
if (x != NULL) {
|
||||
if (x) {
|
||||
|
||||
// check for status child element with 303 code
|
||||
xmpp_stanza_t *x_children = xmpp_stanza_get_children(x);
|
||||
while (x_children != NULL) {
|
||||
while (x_children) {
|
||||
if (g_strcmp0(xmpp_stanza_get_name(x_children), STANZA_NAME_STATUS) == 0) {
|
||||
char *code = xmpp_stanza_get_attribute(x_children, STANZA_ATTR_CODE);
|
||||
if (g_strcmp0(code, "303") == 0) {
|
||||
@@ -1374,7 +1374,7 @@ stanza_get_new_nick(xmpp_stanza_t * const stanza)
|
||||
xmpp_stanza_t *x = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_X);
|
||||
xmpp_stanza_t *x_children = xmpp_stanza_get_children(x);
|
||||
|
||||
while (x_children != NULL) {
|
||||
while (x_children) {
|
||||
if (strcmp(xmpp_stanza_get_name(x_children), STANZA_NAME_ITEM) == 0) {
|
||||
char *nick = xmpp_stanza_get_attribute(x_children, STANZA_ATTR_NICK);
|
||||
if (nick) {
|
||||
@@ -1488,9 +1488,9 @@ stanza_get_error_message(xmpp_stanza_t *stanza)
|
||||
xmpp_stanza_t *text_stanza = xmpp_stanza_get_child_by_name(error_stanza, STANZA_NAME_TEXT);
|
||||
|
||||
// check for text
|
||||
if (text_stanza != NULL) {
|
||||
if (text_stanza) {
|
||||
gchar *err_msg = xmpp_stanza_get_text(text_stanza);
|
||||
if (err_msg != NULL) {
|
||||
if (err_msg) {
|
||||
char *result = strdup(err_msg);
|
||||
xmpp_free(ctx, err_msg);
|
||||
return result;
|
||||
@@ -1525,7 +1525,7 @@ stanza_get_error_message(xmpp_stanza_t *stanza)
|
||||
int i;
|
||||
for (i = 0; i < ARRAY_SIZE(defined_conditions); i++) {
|
||||
xmpp_stanza_t *cond_stanza = xmpp_stanza_get_child_by_name(error_stanza, defined_conditions[i]);
|
||||
if (cond_stanza != NULL) {
|
||||
if (cond_stanza) {
|
||||
char *result = strdup(xmpp_stanza_get_name(cond_stanza));
|
||||
return result;
|
||||
}
|
||||
@@ -1562,7 +1562,7 @@ void
|
||||
stanza_attach_show(xmpp_ctx_t * const ctx, xmpp_stanza_t * const presence,
|
||||
const char * const show)
|
||||
{
|
||||
if (show != NULL) {
|
||||
if (show) {
|
||||
xmpp_stanza_t *show_stanza = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(show_stanza, STANZA_NAME_SHOW);
|
||||
xmpp_stanza_t *text = xmpp_stanza_new(ctx);
|
||||
@@ -1578,7 +1578,7 @@ void
|
||||
stanza_attach_status(xmpp_ctx_t * const ctx, xmpp_stanza_t * const presence,
|
||||
const char * const status)
|
||||
{
|
||||
if (status != NULL) {
|
||||
if (status) {
|
||||
xmpp_stanza_t *status_stanza = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(status_stanza, STANZA_NAME_STATUS);
|
||||
xmpp_stanza_t *text = xmpp_stanza_new(ctx);
|
||||
@@ -1725,9 +1725,9 @@ stanza_parse_presence(xmpp_stanza_t *stanza, int *err)
|
||||
|
||||
result->priority = 0;
|
||||
xmpp_stanza_t *priority_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_PRIORITY);
|
||||
if (priority_stanza != NULL) {
|
||||
if (priority_stanza) {
|
||||
char *priority_str = xmpp_stanza_get_text(priority_stanza);
|
||||
if (priority_str != NULL) {
|
||||
if (priority_str) {
|
||||
result->priority = atoi(priority_str);
|
||||
}
|
||||
free(priority_str);
|
||||
|
||||
Reference in New Issue
Block a user