mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-27 10:06:22 +00:00
Fixed string handling on roster request
This commit is contained in:
20
jabber.c
20
jabber.c
@@ -152,7 +152,7 @@ static void _jabber_conn_handler(xmpp_conn_t * const conn,
|
|||||||
if (status == XMPP_CONN_CONNECT) {
|
if (status == XMPP_CONN_CONNECT) {
|
||||||
const char *jid = xmpp_conn_get_jid(conn);
|
const char *jid = xmpp_conn_get_jid(conn);
|
||||||
const char *msg = " logged in successfully.";
|
const char *msg = " logged in successfully.";
|
||||||
char line[strlen(jid) + strlen(msg) + 2];
|
char line[strlen(jid) + 1 + strlen(msg) + 1];
|
||||||
sprintf(line, "%s %s", xmpp_conn_get_jid(conn), msg);
|
sprintf(line, "%s %s", xmpp_conn_get_jid(conn), msg);
|
||||||
title_bar_connected();
|
title_bar_connected();
|
||||||
|
|
||||||
@@ -183,7 +183,7 @@ static int _roster_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanz
|
|||||||
void * const userdata)
|
void * const userdata)
|
||||||
{
|
{
|
||||||
xmpp_stanza_t *query, *item;
|
xmpp_stanza_t *query, *item;
|
||||||
char *type, *name;
|
char *type, *name, *jid;
|
||||||
|
|
||||||
type = xmpp_stanza_get_type(stanza);
|
type = xmpp_stanza_get_type(stanza);
|
||||||
|
|
||||||
@@ -192,17 +192,19 @@ static int _roster_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanz
|
|||||||
else {
|
else {
|
||||||
query = xmpp_stanza_get_child_by_name(stanza, "query");
|
query = xmpp_stanza_get_child_by_name(stanza, "query");
|
||||||
cons_highlight_show("Roster:");
|
cons_highlight_show("Roster:");
|
||||||
|
|
||||||
for (item = xmpp_stanza_get_children(query); item;
|
for (item = xmpp_stanza_get_children(query); item;
|
||||||
item = xmpp_stanza_get_next(item)) {
|
item = xmpp_stanza_get_next(item)) {
|
||||||
if ((name = xmpp_stanza_get_attribute(item, "name"))) {
|
name = xmpp_stanza_get_attribute(item, "name");
|
||||||
char line[200];
|
jid = xmpp_stanza_get_attribute(item, "jid");
|
||||||
sprintf(line, " %s (%s)", name,
|
if (name != NULL) {
|
||||||
xmpp_stanza_get_attribute(item, "jid"));
|
char line[2 + strlen(name) + 2 + strlen(jid) + 1 + 1];
|
||||||
|
sprintf(line, " %s (%s)", name, jid);
|
||||||
cons_show(line);
|
cons_show(line);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
char line[200];
|
char line[2 + strlen(jid) + 1];
|
||||||
sprintf(line, " %s",
|
sprintf(line, " %s", jid);
|
||||||
xmpp_stanza_get_attribute(item, "jid"));
|
|
||||||
cons_show(line);
|
cons_show(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user