Code cleanup
Cosmetics. Mostly get rid of "jid" variables, as it is a structure pointer
defined in libjabber/jabber.h.
--- a/mcabber/src/commands.c Tue Nov 28 07:14:59 2006 +0100
+++ b/mcabber/src/commands.c Thu Nov 30 19:51:09 2006 +0100
@@ -294,7 +294,7 @@
// the network.
static void send_message(const char *msg, const char *subj)
{
- const char *jid;
+ const char *bjid;
guint crypted;
if (!jb_getonline()) {
@@ -307,14 +307,14 @@
return;
}
- jid = CURRENT_JID;
- if (!jid) {
+ bjid = CURRENT_JID;
+ if (!bjid) {
scr_LogPrint(LPRINT_NORMAL, "No buddy is currently selected.");
return;
}
// Network part
- jb_send_msg(jid, msg, buddy_gettype(BUDDATA(current_buddy)), subj, NULL,
+ jb_send_msg(bjid, msg, buddy_gettype(BUDDATA(current_buddy)), subj, NULL,
&crypted);
// Hook
@@ -325,7 +325,7 @@
hmsg = g_strdup_printf("[%s]\n%s", subj, msg);
else
hmsg = (char*)msg;
- hk_message_out(jid, NULL, 0, hmsg, crypted);
+ hk_message_out(bjid, NULL, 0, hmsg, crypted);
if (hmsg != msg) g_free(hmsg);
}
}
@@ -431,23 +431,23 @@
}
// Helper routine for buffer item_{lock,unlock}
-static void roster_buddylock(char *jid, bool lock)
+static void roster_buddylock(char *bjid, bool lock)
{
gpointer bud = NULL;
bool may_need_refresh = FALSE;
// Allow special jid "" or "." (current buddy)
- if (jid && (!*jid || !strcmp(jid, ".")))
- jid = NULL;
+ if (bjid && (!*bjid || !strcmp(bjid, ".")))
+ bjid = NULL;
- if (jid) {
+ if (bjid) {
// The JID has been specified. Quick check...
- if (check_jid_syntax(jid)) {
- scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber ID.", jid);
+ if (check_jid_syntax(bjid)) {
+ scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber ID.", bjid);
} else {
// Find the buddy
GSList *roster_elt;
- roster_elt = roster_find(jid, jidsearch,
+ roster_elt = roster_find(bjid, jidsearch,
ROSTER_TYPE_USER|ROSTER_TYPE_ROOM);
if (roster_elt)
bud = roster_elt->data;
@@ -537,23 +537,23 @@
static void roster_note(char *arg)
{
- const char *jid;
+ const char *bjid;
guint type;
if (!current_buddy)
return;
- jid = buddy_getjid(BUDDATA(current_buddy));
+ bjid = buddy_getjid(BUDDATA(current_buddy));
type = buddy_gettype(BUDDATA(current_buddy));
- if (!jid && type == ROSTER_TYPE_SPECIAL && !arg) {
+ if (!bjid && type == ROSTER_TYPE_SPECIAL && !arg) {
// We're in the status window (the only special buffer currently)
// Let's display all server notes
display_all_annotations();
return;
}
- if (!jid || (type != ROSTER_TYPE_USER &&
+ if (!bjid || (type != ROSTER_TYPE_USER &&
type != ROSTER_TYPE_ROOM &&
type != ROSTER_TYPE_AGENT)) {
scr_LogPrint(LPRINT_NORMAL, "This item can't have a note.");
@@ -567,14 +567,14 @@
notetxt = NULL; // delete note
else
notetxt = msg;
- jb_set_storage_rosternotes(jid, notetxt);
+ jb_set_storage_rosternotes(bjid, notetxt);
g_free(msg);
} else { // Display a note
- struct annotation *note = jb_get_storage_rosternotes(jid, FALSE);
+ struct annotation *note = jb_get_storage_rosternotes(bjid, FALSE);
if (note) {
- display_and_free_note(note, jid);
+ display_and_free_note(note, bjid);
} else {
- scr_WriteIncomingMessage(jid, "This item doesn't have a note.", 0,
+ scr_WriteIncomingMessage(bjid, "This item doesn't have a note.", 0,
HBB_PREFIX_INFO);
}
}
@@ -724,15 +724,15 @@
static void do_status_to(char *arg)
{
char **paramlst;
- char *jid, *st, *msg;
+ char *fjid, *st, *msg;
char *jid_utf8 = NULL;
paramlst = split_arg(arg, 3, 1); // jid, status, [message]
- jid = *paramlst;
+ fjid = *paramlst;
st = *(paramlst+1);
msg = *(paramlst+2);
- if (!jid || !st) {
+ if (!fjid || !st) {
scr_LogPrint(LPRINT_NORMAL,
"Please specify both a Jabber ID and a status.");
free_arg_lst(paramlst);
@@ -740,39 +740,39 @@
}
// Allow things like /status_to "" away
- if (!*jid || !strcmp(jid, "."))
- jid = NULL;
+ if (!*fjid || !strcmp(fjid, "."))
+ fjid = NULL;
- if (jid) {
+ if (fjid) {
// The JID has been specified. Quick check...
- if (check_jid_syntax(jid)) {
- scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber ID.", jid);
- jid = NULL;
+ if (check_jid_syntax(fjid)) {
+ scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber ID.", fjid);
+ fjid = NULL;
} else {
// Convert jid to lowercase
- char *p = jid;
+ char *p = fjid;
for ( ; *p && *p != JID_RESOURCE_SEPARATOR; p++)
*p = tolower(*p);
- jid = jid_utf8 = to_utf8(jid);
+ fjid = jid_utf8 = to_utf8(fjid);
}
} else {
// Add the current buddy
if (current_buddy)
- jid = (char*)buddy_getjid(BUDDATA(current_buddy));
- if (!jid)
+ fjid = (char*)buddy_getjid(BUDDATA(current_buddy));
+ if (!fjid)
scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID.");
}
- if (jid) {
- char *cmd;
+ if (fjid) {
+ char *cmdline;
if (!msg)
msg = "";
msg = to_utf8(msg);
- cmd = g_strdup_printf("%s %s", st, msg);
- scr_LogPrint(LPRINT_LOGNORM, "Sending to <%s> /status %s", jid, cmd);
- setstatus(jid, cmd);
+ cmdline = g_strdup_printf("%s %s", st, msg);
+ scr_LogPrint(LPRINT_LOGNORM, "Sending to <%s> /status %s", fjid, cmdline);
+ setstatus(fjid, cmdline);
g_free(msg);
- g_free(cmd);
+ g_free(cmdline);
g_free(jid_utf8);
}
free_arg_lst(paramlst);
@@ -834,7 +834,7 @@
static void do_del(char *arg)
{
- const char *jid;
+ const char *bjid;
if (*arg) {
scr_LogPrint(LPRINT_NORMAL, "This action does not require a parameter; "
@@ -842,9 +842,11 @@
return;
}
- if (!current_buddy) return;
- jid = buddy_getjid(BUDDATA(current_buddy));
- if (!jid) return;
+ if (!current_buddy)
+ return;
+ bjid = buddy_getjid(BUDDATA(current_buddy));
+ if (!bjid)
+ return;
if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_ROOM) {
// This is a chatroom
@@ -854,8 +856,8 @@
}
}
- scr_LogPrint(LPRINT_LOGNORM, "Removing <%s>...", jid);
- jb_delbuddy(jid);
+ scr_LogPrint(LPRINT_LOGNORM, "Removing <%s>...", bjid);
+ jb_delbuddy(bjid);
scr_UpdateBuddyWindow();
}
@@ -869,10 +871,12 @@
return;
}
- if (!current_buddy) return;
+ if (!current_buddy)
+ return;
group = buddy_getgroup(BUDDATA(current_buddy));
- if (!group) return;
+ if (!group)
+ return;
// We'll have to redraw the chat window if we're not currently on the group
// entry itself, because it means we'll have to leave the current buddy
@@ -901,13 +905,13 @@
if (leave_buddywindow) scr_ShowBuddyWindow();
}
-static int send_message_to(const char *jid, const char *msg, const char *subj)
+static int send_message_to(const char *fjid, const char *msg, const char *subj)
{
char *bare_jid, *rp;
char *hmsg;
guint crypted;
- if (!jid || !*jid) {
+ if (!fjid || !*fjid) {
scr_LogPrint(LPRINT_NORMAL, "You must specify a Jabber ID.");
return 1;
}
@@ -915,15 +919,15 @@
scr_LogPrint(LPRINT_NORMAL, "You must specify a message.");
return 1;
}
- if (check_jid_syntax((char*)jid)) {
- scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber ID.", jid);
+ if (check_jid_syntax((char*)fjid)) {
+ scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber ID.", fjid);
return 1;
}
// We must use the bare jid in hk_message_out()
- rp = strchr(jid, JID_RESOURCE_SEPARATOR);
- if (rp) bare_jid = g_strndup(jid, rp - jid);
- else bare_jid = (char*)jid;
+ rp = strchr(fjid, JID_RESOURCE_SEPARATOR);
+ if (rp) bare_jid = g_strndup(fjid, rp - fjid);
+ else bare_jid = (char*)fjid;
// Jump to window, create one if needed
scr_RosterJumpJid(bare_jid);
@@ -942,7 +946,7 @@
hmsg = (char*)msg;
// Network part
- jb_send_msg(jid, msg, ROSTER_TYPE_USER, subj, NULL, &crypted);
+ jb_send_msg(fjid, msg, ROSTER_TYPE_USER, subj, NULL, &crypted);
// Hook
hk_message_out(bare_jid, rp, 0, hmsg, crypted);
@@ -1093,7 +1097,7 @@
static void do_say_to(char *arg)
{
char **paramlst;
- char *jid, *msg;
+ char *fjid, *msg;
if (!jb_getonline()) {
scr_LogPrint(LPRINT_NORMAL, "You are not connected.");
@@ -1101,21 +1105,21 @@
}
paramlst = split_arg(arg, 2, 1); // jid, message
- jid = *paramlst;
+ fjid = *paramlst;
msg = *(paramlst+1);
- if (!jid || !strcmp(jid, ".")) {
+ if (!fjid || !strcmp(fjid, ".")) {
scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID.");
free_arg_lst(paramlst);
return;
}
- jid = to_utf8(jid);
+ fjid = to_utf8(fjid);
msg = to_utf8(msg);
- send_message_to(jid, msg, NULL);
+ send_message_to(fjid, msg, NULL);
- g_free(jid);
+ g_free(fjid);
g_free(msg);
free_arg_lst(paramlst);
}
@@ -1188,7 +1192,8 @@
char **paramlst;
char *subcmd;
- if (!current_buddy) return;
+ if (!current_buddy)
+ return;
if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_GROUP) {
scr_LogPrint(LPRINT_NORMAL, "Groups have no buffer.");
@@ -1248,22 +1253,23 @@
static void do_info(char *arg)
{
gpointer bud;
- const char *jid, *name;
+ const char *bjid, *name;
guint type;
char *buffer;
enum subscr esub;
- if (!current_buddy) return;
+ if (!current_buddy)
+ return;
bud = BUDDATA(current_buddy);
- jid = buddy_getjid(bud);
+ bjid = buddy_getjid(bud);
name = buddy_getname(bud);
type = buddy_gettype(bud);
esub = buddy_getsubscription(bud);
buffer = g_new(char, 4096);
- if (jid) {
+ if (bjid) {
GSList *resources;
char *bstr = "unknown";
@@ -1271,18 +1277,18 @@
scr_set_chatmode(TRUE);
scr_ShowBuddyWindow();
- snprintf(buffer, 4095, "jid: <%s>", jid);
- scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO);
+ snprintf(buffer, 4095, "jid: <%s>", bjid);
+ scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO);
if (name) {
snprintf(buffer, 4095, "Name: %s", name);
- scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO);
+ scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO);
}
if (type == ROSTER_TYPE_USER) bstr = "user";
else if (type == ROSTER_TYPE_ROOM) bstr = "chatroom";
else if (type == ROSTER_TYPE_AGENT) bstr = "agent";
snprintf(buffer, 127, "Type: %s", bstr);
- scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO);
+ scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO);
if (esub == sub_both) bstr = "both";
else if (esub & sub_from) bstr = "from";
@@ -1291,7 +1297,7 @@
snprintf(buffer, 64, "Subscription: %s", bstr);
if (esub & sub_pending)
strcat(buffer, " (pending)");
- scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO);
+ scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO);
resources = buddy_getresources(bud);
if (!resources && type == ROSTER_TYPE_USER) {
@@ -1299,7 +1305,7 @@
const char *rst_msg = buddy_getstatusmsg(bud, "");
if (rst_msg) {
snprintf(buffer, 4095, "Last status message: %s", rst_msg);
- scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO);
+ scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO);
}
}
for ( ; resources ; resources = g_slist_next(resources) ) {
@@ -1317,28 +1323,28 @@
snprintf(buffer, 4095, "Resource: [%c] (%d) %s", imstatus2char[rstatus],
rprio, (char*)resources->data);
- scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO);
+ scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO);
if (rst_msg) {
snprintf(buffer, 4095, "Status message: %s", rst_msg);
- scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_NONE);
+ scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE);
}
if (rst_time) {
char tbuf[128];
strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M:%S", localtime(&rst_time));
snprintf(buffer, 127, "Status timestamp: %s", tbuf);
- scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_NONE);
+ scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE);
}
#ifdef HAVE_GPGME
if (rpgp && rpgp->sign_keyid) {
snprintf(buffer, 4095, "PGP key id: %s", rpgp->sign_keyid);
- scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_NONE);
+ scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE);
if (rpgp->last_sigsum) {
gpgme_sigsum_t ss = rpgp->last_sigsum;
snprintf(buffer, 4095, "Last PGP signature: %s",
(ss & GPGME_SIGSUM_GREEN ? "good":
(ss & GPGME_SIGSUM_RED ? "bad" : "unknown")));
- scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_NONE);
+ scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE);
}
}
#endif
@@ -1355,13 +1361,13 @@
if (type == ROSTER_TYPE_USER ||
type == ROSTER_TYPE_ROOM ||
type == ROSTER_TYPE_AGENT) {
- struct annotation *note = jb_get_storage_rosternotes(jid, TRUE);
+ struct annotation *note = jb_get_storage_rosternotes(bjid, TRUE);
if (note) {
// We do not display the note, we just tell the user.
g_free(note->text);
g_free(note->jid);
g_free(note);
- scr_WriteIncomingMessage(jid, "(This item has an annotation)", 0,
+ scr_WriteIncomingMessage(bjid, "(This item has an annotation)", 0,
HBB_PREFIX_INFO);
}
}
@@ -1370,7 +1376,7 @@
// room_names() is a variation of do_info(), for chatrooms only
static void room_names(gpointer bud, char *arg)
{
- const char *jid;
+ const char *bjid;
char *buffer;
GSList *resources;
@@ -1383,11 +1389,11 @@
scr_set_chatmode(TRUE);
scr_ShowBuddyWindow();
- jid = buddy_getjid(bud);
+ bjid = buddy_getjid(bud);
buffer = g_new(char, 4096);
strncpy(buffer, "Room members:", 127);
- scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO);
+ scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO);
resources = buddy_getresources(bud);
for ( ; resources ; resources = g_slist_next(resources) ) {
@@ -1399,10 +1405,10 @@
snprintf(buffer, 4095, "[%c] %s", imstatus2char[rstatus],
(char*)resources->data);
- scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO);
+ scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO);
if (rst_msg) {
snprintf(buffer, 4095, "Status message: %s", rst_msg);
- scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_NONE);
+ scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE);
}
}
@@ -1411,28 +1417,29 @@
static void move_group_member(gpointer bud, void *groupnamedata)
{
- const char *jid, *name, *groupname;
+ const char *bjid, *name, *groupname;
groupname = (char *)groupnamedata;
- jid = buddy_getjid(bud);
+ bjid = buddy_getjid(bud);
name = buddy_getname(bud);
- jb_updatebuddy(jid, name, *groupname ? groupname : NULL);
+ jb_updatebuddy(bjid, name, *groupname ? groupname : NULL);
}
static void do_rename(char *arg)
{
gpointer bud;
- const char *jid, *group;
+ const char *bjid, *group;
guint type;
char *newname, *p;
char *name_utf8;
- if (!current_buddy) return;
+ if (!current_buddy)
+ return;
bud = BUDDATA(current_buddy);
- jid = buddy_getjid(bud);
+ bjid = buddy_getjid(bud);
group = buddy_getgroupname(bud);
type = buddy_gettype(bud);
@@ -1464,7 +1471,7 @@
} else {
// Rename a single buddy
buddy_setname(bud, name_utf8);
- jb_updatebuddy(jid, name_utf8, group);
+ jb_updatebuddy(bjid, name_utf8, group);
}
g_free(name_utf8);
@@ -1475,15 +1482,16 @@
static void do_move(char *arg)
{
gpointer bud;
- const char *jid, *name, *oldgroupname;
+ const char *bjid, *name, *oldgroupname;
guint type;
char *newgroupname, *p;
char *group_utf8;
- if (!current_buddy) return;
+ if (!current_buddy)
+ return;
bud = BUDDATA(current_buddy);
- jid = buddy_getjid(bud);
+ bjid = buddy_getjid(bud);
name = buddy_getname(bud);
type = buddy_gettype(bud);
@@ -1507,7 +1515,7 @@
group_utf8 = to_utf8(newgroupname);
if (strcmp(oldgroupname, group_utf8)) {
- jb_updatebuddy(jid, name, *group_utf8 ? group_utf8 : NULL);
+ jb_updatebuddy(bjid, name, *group_utf8 ? group_utf8 : NULL);
scr_RosterUp();
buddy_setgroup(bud, group_utf8);
}
@@ -1612,28 +1620,28 @@
static void do_bind(char *arg)
{
guint assign;
- const gchar *keycode, *value;
+ const gchar *k_code, *value;
- assign = parse_assigment(arg, &keycode, &value);
- if (!keycode) {
+ assign = parse_assigment(arg, &k_code, &value);
+ if (!k_code) {
settings_foreach(SETTINGS_TYPE_BINDING, &dump_bind, NULL);
return;
}
if (!assign) {
// This is a query
- value = settings_get(SETTINGS_TYPE_BINDING, keycode);
+ value = settings_get(SETTINGS_TYPE_BINDING, k_code);
if (value) {
- scr_LogPrint(LPRINT_NORMAL, "Key %s is bound to: %s", keycode, value);
+ scr_LogPrint(LPRINT_NORMAL, "Key %s is bound to: %s", k_code, value);
} else
- scr_LogPrint(LPRINT_NORMAL, "Key %s is not bound.", keycode);
+ scr_LogPrint(LPRINT_NORMAL, "Key %s is not bound.", k_code);
return;
}
// Update the key binding
if (!value) {
- settings_del(SETTINGS_TYPE_BINDING, keycode);
+ settings_del(SETTINGS_TYPE_BINDING, k_code);
} else {
gchar *value_utf8 = to_utf8(value);
- settings_set(SETTINGS_TYPE_BINDING, keycode, value_utf8);
+ settings_set(SETTINGS_TYPE_BINDING, k_code, value_utf8);
g_free(value_utf8);
}
}
@@ -1782,17 +1790,17 @@
{
char **paramlst;
const gchar *roomname;
- char* jid;
+ char* fjid;
gchar *reason_utf8;
paramlst = split_arg(arg, 2, 1); // jid, [reason]
- jid = *paramlst;
+ fjid = *paramlst;
arg = *(paramlst+1);
// An empty reason is no reason...
if (arg && !*arg)
arg = NULL;
- if (!jid || !*jid) {
+ if (!fjid || !*fjid) {
scr_LogPrint(LPRINT_NORMAL, "Missing or incorrect Jabber ID.");
free_arg_lst(paramlst);
return;
@@ -1800,8 +1808,8 @@
roomname = buddy_getjid(bud);
reason_utf8 = to_utf8(arg);
- jb_room_invite(roomname, jid, reason_utf8);
- scr_LogPrint(LPRINT_LOGNORM, "Invitation sent to <%s>.", jid);
+ jb_room_invite(roomname, fjid, reason_utf8);
+ scr_LogPrint(LPRINT_LOGNORM, "Invitation sent to <%s>.", fjid);
g_free(reason_utf8);
free_arg_lst(paramlst);
}
@@ -1809,16 +1817,16 @@
static void room_affil(gpointer bud, char *arg)
{
char **paramlst;
- gchar *jid, *rolename;
+ gchar *fjid, *rolename;
struct role_affil ra;
const char *roomid = buddy_getjid(bud);
paramlst = split_arg(arg, 3, 1); // jid, new_affil, [reason]
- jid = *paramlst;
+ fjid = *paramlst;
rolename = *(paramlst+1);
arg = *(paramlst+2);
- if (!jid || !*jid || !rolename || !*rolename) {
+ if (!fjid || !*fjid || !rolename || !*rolename) {
scr_LogPrint(LPRINT_NORMAL, "Please specify both a Jabber ID and a role.");
free_arg_lst(paramlst);
return;
@@ -1832,7 +1840,7 @@
if (ra.val.affil < imaffiliation_size) {
gchar *jid_utf8, *reason_utf8;
- jid_utf8 = to_utf8(jid);
+ jid_utf8 = to_utf8(fjid);
reason_utf8 = to_utf8(arg);
jb_room_setattrib(roomid, jid_utf8, NULL, ra, reason_utf8);
g_free(jid_utf8);
@@ -1846,16 +1854,16 @@
static void room_role(gpointer bud, char *arg)
{
char **paramlst;
- gchar *jid, *rolename;
+ gchar *fjid, *rolename;
struct role_affil ra;
const char *roomid = buddy_getjid(bud);
paramlst = split_arg(arg, 3, 1); // jid, new_role, [reason]
- jid = *paramlst;
+ fjid = *paramlst;
rolename = *(paramlst+1);
arg = *(paramlst+2);
- if (!jid || !*jid || !rolename || !*rolename) {
+ if (!fjid || !*fjid || !rolename || !*rolename) {
scr_LogPrint(LPRINT_NORMAL, "Please specify both a Jabber ID and a role.");
free_arg_lst(paramlst);
return;
@@ -1869,7 +1877,7 @@
if (ra.val.role < imrole_size) {
gchar *jid_utf8, *reason_utf8;
- jid_utf8 = to_utf8(jid);
+ jid_utf8 = to_utf8(fjid);
reason_utf8 = to_utf8(arg);
jb_room_setattrib(roomid, jid_utf8, NULL, ra, reason_utf8);
g_free(jid_utf8);
@@ -1885,16 +1893,16 @@
static void room_ban(gpointer bud, char *arg)
{
char **paramlst;
- gchar *jid;
+ gchar *fjid;
gchar *jid_utf8, *reason_utf8;
struct role_affil ra;
const char *roomid = buddy_getjid(bud);
paramlst = split_arg(arg, 2, 1); // jid, [reason]
- jid = *paramlst;
+ fjid = *paramlst;
arg = *(paramlst+1);
- if (!jid || !*jid) {
+ if (!fjid || !*fjid) {
scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID.");
free_arg_lst(paramlst);
return;
@@ -1903,7 +1911,7 @@
ra.type = type_affil;
ra.val.affil = affil_outcast;
- jid_utf8 = to_utf8(jid);
+ jid_utf8 = to_utf8(fjid);
reason_utf8 = to_utf8(arg);
jb_room_setattrib(roomid, jid_utf8, NULL, ra, reason_utf8);
g_free(jid_utf8);
@@ -1991,7 +1999,7 @@
static void room_privmsg(gpointer bud, char *arg)
{
char **paramlst;
- gchar *nick, *cmd;
+ gchar *nick, *cmdline;
paramlst = split_arg(arg, 2, 0); // nickname, message
nick = *paramlst;
@@ -2004,9 +2012,9 @@
return;
}
- cmd = g_strdup_printf("%s/%s %s", buddy_getjid(bud), nick, arg);
- do_say_to(cmd);
- g_free(cmd);
+ cmdline = g_strdup_printf("%s/%s %s", buddy_getjid(bud), nick, arg);
+ do_say_to(cmdline);
+ g_free(cmdline);
free_arg_lst(paramlst);
}
@@ -2086,7 +2094,7 @@
{
char **paramlst;
gchar *nick, *buffer;
- const char *jid, *realjid;
+ const char *bjid, *realjid;
const char *rst_msg;
gchar rprio;
enum imstatus rstatus;
@@ -2094,9 +2102,6 @@
enum imaffiliation affil;
time_t rst_time;
- char *strroles[] = { "none", "moderator", "participant", "visitor" };
- char *straffil[] = { "none", "owner", "admin", "member", "outcast" };
-
paramlst = split_arg(arg, 1, 0); // nickname
nick = *paramlst;
@@ -2114,7 +2119,7 @@
scr_ShowBuddyWindow();
}
- jid = buddy_getjid(bud);
+ bjid = buddy_getjid(bud);
rstatus = buddy_getstatus(bud, nick);
if (rstatus == offline) {
@@ -2136,32 +2141,32 @@
buffer = g_new(char, 4096);
snprintf(buffer, 4095, "Whois [%s]", nick);
- scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO);
+ scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO);
snprintf(buffer, 4095, "Status : [%c] %s", imstatus2char[rstatus],
rst_msg);
- scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_NONE);
+ scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE);
if (rst_time) {
char tbuf[128];
strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M:%S", localtime(&rst_time));
snprintf(buffer, 127, "Timestamp: %s", tbuf);
- scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_NONE);
+ scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE);
}
if (realjid) {
snprintf(buffer, 4095, "JID : <%s>", realjid);
- scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_NONE);
+ scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE);
}
- snprintf(buffer, 4095, "Role : %s", strroles[role]);
- scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_NONE);
+ snprintf(buffer, 4095, "Role : %s", strrole[role]);
+ scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE);
snprintf(buffer, 4095, "Affiliat.: %s", straffil[affil]);
- scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_NONE);
+ scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE);
snprintf(buffer, 4095, "Priority : %d", rprio);
- scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_NONE);
+ scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE);
- scr_WriteIncomingMessage(jid, "End of WHOIS", 0, HBB_PREFIX_INFO);
+ scr_WriteIncomingMessage(bjid, "End of WHOIS", 0, HBB_PREFIX_INFO);
g_free(buffer);
g_free(nick);
@@ -2329,7 +2334,8 @@
gpointer bud;
guint type;
- if (!current_buddy) return;
+ if (!current_buddy)
+ return;
bud = BUDDATA(current_buddy);
jid_utf8 = arg = (char*)buddy_getjid(bud);
@@ -2382,13 +2388,13 @@
static void do_request(char *arg)
{
char **paramlst;
- char *jid, *type;
+ char *fjid, *type;
enum iqreq_type numtype = iqreq_none;
char *jid_utf8 = NULL;
paramlst = split_arg(arg, 2, 0); // type, jid
type = *paramlst;
- jid = *(paramlst+1);
+ fjid = *(paramlst+1);
if (type) {
// Quick check...
@@ -2416,36 +2422,36 @@
}
// Allow special jid "" or "." (current buddy)
- if (jid && (!*jid || !strcmp(jid, ".")))
- jid = NULL;
+ if (fjid && (!*fjid || !strcmp(fjid, ".")))
+ fjid = NULL;
- if (jid) {
+ if (fjid) {
// The JID has been specified. Quick check...
- if (check_jid_syntax(jid)) {
- scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber ID.", jid);
- jid = NULL;
+ if (check_jid_syntax(fjid)) {
+ scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber ID.", fjid);
+ fjid = NULL;
} else {
// Convert jid to lowercase
char *p;
- for (p = jid; *p && *p != JID_RESOURCE_SEPARATOR; p++)
+ for (p = fjid; *p && *p != JID_RESOURCE_SEPARATOR; p++)
*p = tolower(*p);
- jid = jid_utf8 = to_utf8(jid);
+ fjid = jid_utf8 = to_utf8(fjid);
}
} else {
// Add the current buddy
if (current_buddy)
- jid = (char*)buddy_getjid(BUDDATA(current_buddy));
- if (!jid)
+ fjid = (char*)buddy_getjid(BUDDATA(current_buddy));
+ if (!fjid)
scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID.");
}
- if (jid) {
+ if (fjid) {
switch (numtype) {
case iqreq_version:
case iqreq_time:
case iqreq_last:
case iqreq_vcard:
- jb_request(jid, numtype);
+ jb_request(fjid, numtype);
break;
default:
break;
--- a/mcabber/src/histolog.c Tue Nov 28 07:14:59 2006 +0100
+++ b/mcabber/src/histolog.c Thu Nov 30 19:51:09 2006 +0100
@@ -40,20 +40,20 @@
static char *RootDir;
-// user_histo_file()
+// user_histo_file(jid)
// Returns history filename for the given jid
// Note: the caller *must* free the filename after use (if not null).
-static char *user_histo_file(const char *jid)
+static char *user_histo_file(const char *bjid)
{
char *filename;
char *lowerid, *p;
if (!UseFileLogging && !FileLoadLogs) return NULL;
- lowerid = g_strdup(jid);
+ lowerid = g_strdup(bjid);
for (p=lowerid; *p ; p++)
*p = tolower(*p);
- filename = g_new(char, strlen(RootDir) + strlen(jid) + 1);
+ filename = g_new(char, strlen(RootDir) + strlen(bjid) + 1);
strcpy(filename, RootDir);
strcat(filename, lowerid);
g_free(lowerid);
@@ -62,7 +62,7 @@
// write_histo_line()
// Adds a history (multi-)line to the jid's history logfile
-static void write_histo_line(const char *jid,
+static void write_histo_line(const char *bjid,
time_t timestamp, guchar type, guchar info, const char *data)
{
guint len = 0;
@@ -75,7 +75,7 @@
if (!UseFileLogging) return;
- filename = user_histo_file(jid);
+ filename = user_histo_file(bjid);
// If timestamp is null, get current date
if (timestamp)
@@ -119,7 +119,7 @@
// hlog_read_history()
// Reads the jid's history logfile
-void hlog_read_history(const char *jid, GList **p_buddyhbuf, guint width)
+void hlog_read_history(const char *bjid, GList **p_buddyhbuf, guint width)
{
char *filename;
guchar type, info;
@@ -136,7 +136,7 @@
if (!FileLoadLogs) return;
- if ((roster_gettype(jid) & ROSTER_TYPE_ROOM) &&
+ if ((roster_gettype(bjid) & ROSTER_TYPE_ROOM) &&
(settings_opt_get_int("load_muc_logs") != 1))
return;
@@ -146,7 +146,7 @@
return;
}
- filename = user_histo_file(jid);
+ filename = user_histo_file(bjid);
fp = fopen(filename, "r");
g_free(filename);
@@ -156,7 +156,7 @@
// (it can take a while...)
if (!fstat(fileno(fp), &bufstat)) {
if (bufstat.st_size > 3145728)
- scr_LogPrint(LPRINT_LOGNORM, "Reading <%s> history file...", jid);
+ scr_LogPrint(LPRINT_LOGNORM, "Reading <%s> history file...", bjid);
}
starttime = 0;
@@ -186,7 +186,7 @@
(data[25] != ' ' && data[26] != ' '))) {
if (!err) {
scr_LogPrint(LPRINT_LOGNORM,
- "Error in history file format (%s), l.%u", jid, ln);
+ "Error in history file format (%s), l.%u", bjid, ln);
err = 1;
}
continue;
@@ -202,7 +202,7 @@
((type == 'I') && (!strchr("OAIFDN", info)))) {
if (!err) {
scr_LogPrint(LPRINT_LOGNORM, "Error in history file format (%s), l.%u",
- jid, ln);
+ bjid, ln);
err = 1;
}
continue;
@@ -300,18 +300,18 @@
}
}
-inline void hlog_write_message(const char *jid, time_t timestamp, int sent,
+inline void hlog_write_message(const char *bjid, time_t timestamp, int sent,
const char *msg)
{
- write_histo_line(jid, timestamp, 'M', ((sent) ? 'S' : 'R'), msg);
+ write_histo_line(bjid, timestamp, 'M', ((sent) ? 'S' : 'R'), msg);
}
-inline void hlog_write_status(const char *jid, time_t timestamp,
+inline void hlog_write_status(const char *bjid, time_t timestamp,
enum imstatus status, const char *status_msg)
{
// #1 XXX Check status value?
// #2 We could add a user-readable comment
- write_histo_line(jid, timestamp, 'S', toupper(imstatus2char[status]),
+ write_histo_line(bjid, timestamp, 'S', toupper(imstatus2char[status]),
status_msg);
}
--- a/mcabber/src/histolog.h Tue Nov 28 07:14:59 2006 +0100
+++ b/mcabber/src/histolog.h Thu Nov 30 19:51:09 2006 +0100
@@ -6,10 +6,10 @@
#include "jabglue.h"
void hlog_enable(guint enable, const char *root_dir, guint loadfile);
-void hlog_read_history(const char *jid, GList **p_buddyhbuf, guint width);
-inline void hlog_write_message(const char *jid, time_t timestamp, int sent,
+void hlog_read_history(const char *bjid, GList **p_buddyhbuf, guint width);
+inline void hlog_write_message(const char *bjid, time_t timestamp, int sent,
const char *msg);
-inline void hlog_write_status(const char *jid, time_t timestamp,
+inline void hlog_write_status(const char *bjid, time_t timestamp,
enum imstatus status, const char *status_msg);
#endif /* __HISTOLOG_H__ */
--- a/mcabber/src/hooks.c Tue Nov 28 07:14:59 2006 +0100
+++ b/mcabber/src/hooks.c Thu Nov 30 19:51:09 2006 +0100
@@ -33,7 +33,7 @@
static char *extcmd;
-inline void hk_message_in(const char *jid, const char *resname,
+inline void hk_message_in(const char *bjid, const char *resname,
time_t timestamp, const char *msg, const char *type,
guint encrypted)
{
@@ -65,16 +65,16 @@
wmsg = mmsg = g_strdup_printf("*%s %s", resname, msg+4);
} else {
if (!strncmp(msg, mkcmdstr("me "), strlen(mkcmdstr("me "))))
- wmsg = mmsg = g_strdup_printf("*%s %s", jid, msg+4);
+ wmsg = mmsg = g_strdup_printf("*%s %s", bjid, msg+4);
else
wmsg = (char*) msg;
}
// If this user isn't in the roster, we add it
- roster_usr = roster_find(jid, jidsearch, 0);
+ roster_usr = roster_find(bjid, jidsearch, 0);
if (!roster_usr) {
new_guy = TRUE;
- roster_usr = roster_add_user(jid, NULL, NULL, rtype, sub_none);
+ roster_usr = roster_add_user(bjid, NULL, NULL, rtype, sub_none);
if (!roster_usr) { // Shouldn't happen...
scr_LogPrint(LPRINT_LOGNORM, "ERROR: unable to add buddy!");
g_free(bmsg);
@@ -111,13 +111,13 @@
if (type && !strcmp(type, "error")) {
message_flags = HBB_PREFIX_ERR | HBB_PREFIX_IN;
- scr_LogPrint(LPRINT_LOGNORM, "Error message received from <%s>", jid);
+ scr_LogPrint(LPRINT_LOGNORM, "Error message received from <%s>", bjid);
}
// Note: the hlog_write should not be called first, because in some
// cases scr_WriteIncomingMessage() will load the history and we'd
// have the message twice...
- scr_WriteIncomingMessage(jid, wmsg, timestamp, message_flags);
+ scr_WriteIncomingMessage(bjid, wmsg, timestamp, message_flags);
// We don't log the modified message, but the original one
if (wmsg == mmsg)
@@ -129,21 +129,21 @@
// option is off (and it is not a history line)
if (!(message_flags & HBB_PREFIX_ERR) &&
(!is_room || (is_groupchat && log_muc_conf && !timestamp)))
- hlog_write_message(jid, timestamp, FALSE, wmsg);
+ hlog_write_message(bjid, timestamp, FALSE, wmsg);
// External command
// - We do not call hk_ext_cmd() for history lines in MUC
// - We do call hk_ext_cmd() for private messages in a room
if ((is_groupchat && !timestamp) || !is_groupchat)
- hk_ext_cmd(jid, (is_groupchat ? 'G' : 'M'), 'R', wmsg);
+ hk_ext_cmd(bjid, (is_groupchat ? 'G' : 'M'), 'R', wmsg);
// Display the sender in the log window
if ((!is_groupchat) && !(message_flags & HBB_PREFIX_ERR) &&
settings_opt_get_int("log_display_sender")) {
- const char *name = roster_getname(jid);
+ const char *name = roster_getname(bjid);
if (!name) name = "";
scr_LogPrint(LPRINT_NORMAL, "Message received from %s <%s/%s>",
- name, jid, (resname ? resname : ""));
+ name, bjid, (resname ? resname : ""));
}
// Beep, if enabled
@@ -168,7 +168,7 @@
// hk_message_out()
// nick should be set for private messages in a chat room, and null for
// normal messages.
-inline void hk_message_out(const char *jid, const char *nick,
+inline void hk_message_out(const char *bjid, const char *nick,
time_t timestamp, const char *msg, guint encrypted)
{
char *wmsg = NULL, *bmsg = NULL, *mmsg = NULL;
@@ -188,19 +188,19 @@
// Note: the hlog_write should not be called first, because in some
// cases scr_WriteOutgoingMessage() will load the history and we'd
// have the message twice...
- scr_WriteOutgoingMessage(jid, wmsg, (encrypted ? HBB_PREFIX_PGPCRYPT : 0));
+ scr_WriteOutgoingMessage(bjid, wmsg, (encrypted ? HBB_PREFIX_PGPCRYPT : 0));
// We don't log private messages
- if (!nick) hlog_write_message(jid, timestamp, TRUE, msg);
+ if (!nick) hlog_write_message(bjid, timestamp, TRUE, msg);
// External command
- hk_ext_cmd(jid, 'M', 'S', NULL);
+ hk_ext_cmd(bjid, 'M', 'S', NULL);
g_free(bmsg);
g_free(mmsg);
}
-inline void hk_statuschange(const char *jid, const char *resname, gchar prio,
+inline void hk_statuschange(const char *bjid, const char *resname, gchar prio,
time_t timestamp, enum imstatus status,
const char *status_msg)
{
@@ -214,10 +214,10 @@
st_in_buf = settings_opt_get_int("show_status_in_buffer");
buddy_format = settings_opt_get_int("buddy_format");
if (buddy_format) {
- const char *name = roster_getname(jid);
- if (name && strcmp(name, jid)) {
+ const char *name = roster_getname(bjid);
+ if (name && strcmp(name, bjid)) {
if (buddy_format == 1)
- bn = g_strdup_printf("%s <%s/%s>", name, jid, rn);
+ bn = g_strdup_printf("%s <%s/%s>", name, bjid, rn);
else if (buddy_format == 2)
bn = g_strdup_printf("%s/%s", name, rn);
else if (buddy_format == 3)
@@ -226,13 +226,13 @@
}
if (!bn) {
- bn = g_strdup_printf("<%s/%s>", jid, rn);
+ bn = g_strdup_printf("<%s/%s>", bjid, rn);
}
logsmsg = g_strdup(status_msg ? status_msg : "");
replace_nl_with_dots(logsmsg);
- oldstat = roster_getstatus(jid, resname);
+ oldstat = roster_getstatus(bjid, resname);
scr_LogPrint(LPRINT_LOGNORM, "Buddy status has changed: [%c>%c] %s %s",
imstatus2char[oldstat], imstatus2char[status], bn, logsmsg);
g_free(logsmsg);
@@ -241,23 +241,23 @@
if (st_in_buf == 2 ||
(st_in_buf == 1 && (status == offline || oldstat == offline))) {
// Write the status change in the buddy's buffer, only if it already exists
- if (scr_BuddyBufferExists(jid)) {
+ if (scr_BuddyBufferExists(bjid)) {
bn = g_strdup_printf("Buddy status has changed: [%c>%c] %s",
imstatus2char[oldstat], imstatus2char[status],
((status_msg) ? status_msg : ""));
- scr_WriteIncomingMessage(jid, bn, timestamp,
+ scr_WriteIncomingMessage(bjid, bn, timestamp,
HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG);
g_free(bn);
}
}
- roster_setstatus(jid, rn, prio, status, status_msg, timestamp,
+ roster_setstatus(bjid, rn, prio, status, status_msg, timestamp,
role_none, affil_none, NULL);
buddylist_build();
scr_DrawRoster();
- hlog_write_status(jid, timestamp, status, status_msg);
+ hlog_write_status(bjid, timestamp, status, status_msg);
// External command
- hk_ext_cmd(jid, 'S', imstatus2char[status], NULL);
+ hk_ext_cmd(bjid, 'S', imstatus2char[status], NULL);
}
inline void hk_mystatuschange(time_t timestamp, enum imstatus old_status,
@@ -288,7 +288,7 @@
// hk_ext_cmd()
// Launch an external command (process) for the given event.
// For now, data should be NULL.
-void hk_ext_cmd(const char *jid, guchar type, guchar info, const char *data)
+void hk_ext_cmd(const char *bjid, guchar type, guchar info, const char *data)
{
pid_t pid;
char *arg_type = NULL;
@@ -363,7 +363,7 @@
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
- if (execl(extcmd, extcmd, arg_type, arg_info, jid, arg_data, NULL) == -1) {
+ if (execl(extcmd, extcmd, arg_type, arg_info, bjid, arg_data, NULL) == -1) {
// scr_LogPrint(LPRINT_LOGNORM, "Cannot execute external command.");
exit(1);
}
--- a/mcabber/src/hooks.h Tue Nov 28 07:14:59 2006 +0100
+++ b/mcabber/src/hooks.h Thu Nov 30 19:51:09 2006 +0100
@@ -5,12 +5,12 @@
#include "jabglue.h"
-inline void hk_message_in(const char *jid, const char *resname,
+inline void hk_message_in(const char *bjid, const char *resname,
time_t timestamp, const char *msg, const char *type,
guint encrypted);
-inline void hk_message_out(const char *jid, const char *nickname,
+inline void hk_message_out(const char *bjid, const char *nickname,
time_t timestamp, const char *msg, guint encrypted);
-inline void hk_statuschange(const char *jid, const char *resname, gchar prio,
+inline void hk_statuschange(const char *bjid, const char *resname, gchar prio,
time_t timestamp, enum imstatus status,
char const *status_msg);
inline void hk_mystatuschange(time_t timestamp,
@@ -18,7 +18,7 @@
enum imstatus new_status, const char *msg);
void hk_ext_cmd_init(const char *command);
-void hk_ext_cmd(const char *jid, guchar type, guchar info, const char *data);
+void hk_ext_cmd(const char *bjid, guchar type, guchar info, const char *data);
#endif /* __HOOKS_H__ */
--- a/mcabber/src/jab_iq.c Tue Nov 28 07:14:59 2006 +0100
+++ b/mcabber/src/jab_iq.c Thu Nov 30 19:51:09 2006 +0100
@@ -56,7 +56,7 @@
// iqs_new(type, namespace, prefix, timeout)
// Create a query (GET, SET) IQ structure. This function should not be used
// for RESULT packets.
-eviqs *iqs_new(guint8 type, const char *ns, const char *prefix, time_t timeout)
+eviqs *iqs_new(guint8 type, const char *ns, const char *prefix, time_t tmout)
{
static guint iqs_idn;
eviqs *new_iqs;
@@ -67,8 +67,8 @@
new_iqs = g_new0(eviqs, 1);
time(&now_t);
new_iqs->ts_create = now_t;
- if (timeout)
- new_iqs->ts_expire = now_t + timeout;
+ if (tmout)
+ new_iqs->ts_expire = now_t + tmout;
new_iqs->type = type;
new_iqs->xmldata = jutil_iqnew(type, (char*)ns);
if (prefix)
@@ -182,7 +182,7 @@
static void handle_iq_roster(xmlnode x)
{
xmlnode y;
- const char *jid, *name, *group, *sub, *ask;
+ const char *fjid, *name, *group, *sub, *ask;
char *cleanalias;
enum subscr esub;
int need_refresh = FALSE;
@@ -190,17 +190,17 @@
for (y = xmlnode_get_tag(x, "item"); y; y = xmlnode_get_nextsibling(y)) {
- jid = xmlnode_get_attrib(y, "jid");
+ fjid = xmlnode_get_attrib(y, "jid");
name = xmlnode_get_attrib(y, "name");
sub = xmlnode_get_attrib(y, "subscription");
ask = xmlnode_get_attrib(y, "ask");
group = xmlnode_get_tag_data(y, "group");
- if (!jid)
+ if (!fjid)
continue;
- cleanalias = jidtodisp(jid);
+ cleanalias = jidtodisp(fjid);
esub = sub_none;
if (sub) {
@@ -594,12 +594,12 @@
handle_vcard_node(bjid, ansqry);
}
-void request_vcard(const char *jid)
+void request_vcard(const char *bjid)
{
eviqs *iqn;
char *barejid;
- barejid = jidtodisp(jid);
+ barejid = jidtodisp(bjid);
// Create a new IQ structure. We use NULL for the namespace because
// we'll have to use a special tag, not the usual "query" one.
@@ -617,17 +617,17 @@
static void storage_bookmarks_parse_conference(xmlnode xmldata)
{
- const char *jid, *name, *autojoin;
+ const char *fjid, *name, *autojoin;
char *bjid;
GSList *room_elt;
- jid = xmlnode_get_attrib(xmldata, "jid");
- if (!jid)
+ fjid = xmlnode_get_attrib(xmldata, "jid");
+ if (!fjid)
return;
name = xmlnode_get_attrib(xmldata, "name");
autojoin = xmlnode_get_attrib(xmldata, "autojoin");
- bjid = jidtodisp(jid); // Bare jid
+ bjid = jidtodisp(fjid); // Bare jid
// Make sure this is a room (it can be a conversion user->room)
room_elt = roster_find(bjid, jidsearch, 0);
--- a/mcabber/src/jab_priv.h Tue Nov 28 07:14:59 2006 +0100
+++ b/mcabber/src/jab_priv.h Thu Nov 30 19:51:09 2006 +0100
@@ -34,7 +34,7 @@
extern char *mcabber_version(void);
-char *jidtodisp(const char *jid);
+char *jidtodisp(const char *fjid);
void handle_packet_iq(jconn conn, char *type, char *from, xmlnode xmldata);
void display_server_error(xmlnode x);
eviqs *iqs_new(guint8 type, const char *ns, const char *prefix, time_t timeout);
--- a/mcabber/src/jabglue.c Tue Nov 28 07:14:59 2006 +0100
+++ b/mcabber/src/jabglue.c Thu Nov 30 19:51:09 2006 +0100
@@ -66,12 +66,12 @@
// jidtodisp(jid)
// Strips the resource part from the jid
// The caller should g_free the result after use.
-char *jidtodisp(const char *jid)
+char *jidtodisp(const char *fjid)
{
char *ptr;
char *alias;
- alias = g_strdup(jid);
+ alias = g_strdup(fjid);
if ((ptr = strchr(alias, JID_RESOURCE_SEPARATOR)) != NULL) {
*ptr = 0;
@@ -82,16 +82,16 @@
char *compose_jid(const char *username, const char *servername,
const char *resource)
{
- char *jid = g_new(char, 3 +
- strlen(username) + strlen(servername) + strlen(resource));
- strcpy(jid, username);
- if (!strchr(jid, JID_DOMAIN_SEPARATOR)) {
- strcat(jid, JID_DOMAIN_SEPARATORSTR);
- strcat(jid, servername);
+ char *fjid = g_new(char, 3 +
+ strlen(username) + strlen(servername) + strlen(resource));
+ strcpy(fjid, username);
+ if (!strchr(fjid, JID_DOMAIN_SEPARATOR)) {
+ strcat(fjid, JID_DOMAIN_SEPARATORSTR);
+ strcat(fjid, servername);
}
- strcat(jid, JID_RESOURCE_SEPARATORSTR);
- strcat(jid, resource);
- return jid;
+ strcat(fjid, JID_RESOURCE_SEPARATORSTR);
+ strcat(fjid, resource);
+ return fjid;
}
inline unsigned char jb_getonline(void)
@@ -99,7 +99,7 @@
return online;
}
-jconn jb_connect(const char *jid, const char *server, unsigned int port,
+jconn jb_connect(const char *fjid, const char *server, unsigned int port,
int ssl, const char *pass)
{
if (!port) {
@@ -111,9 +111,9 @@
jb_disconnect();
- if (!jid) return jc;
+ if (!fjid) return jc;
- jc = jab_new((char*)jid, (char*)pass, (char*)server, port, ssl);
+ jc = jab_new((char*)fjid, (char*)pass, (char*)server, port, ssl);
/* These 3 functions can deal with a NULL jc, no worry... */
jab_logger(jc, logger);
@@ -211,7 +211,7 @@
{
time_t now;
fd_set fds;
- long timeout;
+ long tmout;
struct timeval tv;
static time_t last_eviqs_check = 0L;
@@ -245,16 +245,16 @@
}
// Check auto-away timeout
- timeout = scr_GetAutoAwayTimeout(now);
- if (tv.tv_sec > timeout) {
- tv.tv_sec = timeout;
+ tmout = scr_GetAutoAwayTimeout(now);
+ if (tv.tv_sec > tmout) {
+ tv.tv_sec = tmout;
}
#if defined JEP0022 || defined JEP0085
// Check composing timeout
- timeout = scr_GetChatStatesTimeout(now);
- if (tv.tv_sec > timeout) {
- tv.tv_sec = timeout;
+ tmout = scr_GetChatStatesTimeout(now);
+ if (tv.tv_sec > tmout) {
+ tv.tv_sec = tmout;
}
#endif
@@ -323,7 +323,7 @@
static void roompresence(gpointer room, void *presencedata)
{
- const char *jid;
+ const char *bjid;
const char *nickname;
char *to;
struct T_presence *pres = presencedata;
@@ -331,12 +331,12 @@
if (!buddy_getinsideroom(room))
return;
- jid = buddy_getjid(room);
- if (!jid) return;
+ bjid = buddy_getjid(room);
+ if (!bjid) return;
nickname = buddy_getnickname(room);
if (!nickname) return;
- to = g_strdup_printf("%s/%s", jid, nickname);
+ to = g_strdup_printf("%s/%s", bjid, nickname);
jb_setstatus(pres->st, to, pres->msg, TRUE);
g_free(to);
}
@@ -509,7 +509,7 @@
// jb_send_msg(jid, test, type, subject, msgid, *encrypted)
// When encrypted is not NULL, the function set *encrypted to TRUE if the
// message has been PGP-encrypted.
-void jb_send_msg(const char *jid, const char *text, int type,
+void jb_send_msg(const char *fjid, const char *text, int type,
const char *subject, const char *msgid, guint *encrypted)
{
xmlnode x;
@@ -536,8 +536,8 @@
strtype = TMSG_CHAT;
#if defined HAVE_GPGME || defined JEP0022 || defined JEP0085
- rname = strchr(jid, JID_RESOURCE_SEPARATOR);
- barejid = jidtodisp(jid);
+ rname = strchr(fjid, JID_RESOURCE_SEPARATOR);
+ barejid = jidtodisp(fjid);
sl_buddy = roster_find(barejid, jidsearch, ROSTER_TYPE_USER);
g_free(barejid);
@@ -556,7 +556,7 @@
}
#endif
- x = jutil_msgnew(strtype, (char*)jid, NULL,
+ x = jutil_msgnew(strtype, (char*)fjid, NULL,
(enc ? "This message is PGP-encrypted." : (char*)text));
if (subject) {
xmlnode y;
@@ -644,7 +644,7 @@
#ifdef JEP0085
// jb_send_jep85_chatstate()
// Send a JEP-85 chatstate.
-static void jb_send_jep85_chatstate(const char *jid, guint state)
+static void jb_send_jep85_chatstate(const char *fjid, guint state)
{
xmlnode x;
xmlnode event;
@@ -655,8 +655,8 @@
if (!online) return;
- rname = strchr(jid, JID_RESOURCE_SEPARATOR);
- barejid = jidtodisp(jid);
+ rname = strchr(fjid, JID_RESOURCE_SEPARATOR);
+ barejid = jidtodisp(fjid);
sl_buddy = roster_find(barejid, jidsearch, ROSTER_TYPE_USER);
g_free(barejid);
@@ -686,7 +686,7 @@
jep85->last_state_sent = state;
- x = jutil_msgnew(TMSG_CHAT, (char*)jid, NULL, NULL);
+ x = jutil_msgnew(TMSG_CHAT, (char*)fjid, NULL, NULL);
event = xmlnode_insert_tag(x, chattag);
xmlnode_put_attrib(event, "xmlns", NS_CHATSTATES);
@@ -701,7 +701,7 @@
#ifdef JEP0022
// jb_send_jep22_event()
// Send a JEP-22 message event (delivered, composing...).
-static void jb_send_jep22_event(const char *jid, guint type)
+static void jb_send_jep22_event(const char *fjid, guint type)
{
xmlnode x;
xmlnode event;
@@ -713,8 +713,8 @@
if (!online) return;
- rname = strchr(jid, JID_RESOURCE_SEPARATOR);
- barejid = jidtodisp(jid);
+ rname = strchr(fjid, JID_RESOURCE_SEPARATOR);
+ barejid = jidtodisp(fjid);
sl_buddy = roster_find(barejid, jidsearch, ROSTER_TYPE_USER);
g_free(barejid);
@@ -747,7 +747,7 @@
jep22->last_state_sent = jep22_state;
}
- x = jutil_msgnew(TMSG_CHAT, (char*)jid, NULL, NULL);
+ x = jutil_msgnew(TMSG_CHAT, (char*)fjid, NULL, NULL);
event = xmlnode_insert_tag(x, "x");
xmlnode_put_attrib(event, "xmlns", NS_EVENT);
@@ -770,24 +770,24 @@
#if defined JEP0022 || defined JEP0085
void jb_send_chatstate(gpointer buddy, guint chatstate)
{
- const char *jid;
+ const char *bjid;
struct jep0085 *jep85 = NULL;
struct jep0022 *jep22 = NULL;
- jid = buddy_getjid(buddy);
- if (!jid) return;
+ bjid = buddy_getjid(buddy);
+ if (!bjid) return;
#ifdef JEP0085
jep85 = buddy_resource_jep85(buddy, NULL);
if (jep85 && jep85->support == CHATSTATES_SUPPORT_OK) {
- jb_send_jep85_chatstate(jid, chatstate);
+ jb_send_jep85_chatstate(bjid, chatstate);
return;
}
#endif
#ifdef JEP0022
jep22 = buddy_resource_jep22(buddy, NULL);
if (jep22 && jep22->support == CHATSTATES_SUPPORT_OK) {
- jb_send_jep22_event(jid, chatstate);
+ jb_send_jep22_event(bjid, chatstate);
}
#endif
}
@@ -827,50 +827,50 @@
// jb_subscr_send_auth(jid)
// Allow jid to receive our presence updates
-void jb_subscr_send_auth(const char *jid)
+void jb_subscr_send_auth(const char *bjid)
{
xmlnode x;
- x = jutil_presnew(JPACKET__SUBSCRIBED, (char *)jid, NULL);
+ x = jutil_presnew(JPACKET__SUBSCRIBED, (char *)bjid, NULL);
jab_send(jc, x);
xmlnode_free(x);
}
// jb_subscr_cancel_auth(jid)
// Cancel jid's subscription to our presence updates
-void jb_subscr_cancel_auth(const char *jid)
+void jb_subscr_cancel_auth(const char *bjid)
{
xmlnode x;
- x = jutil_presnew(JPACKET__UNSUBSCRIBED, (char *)jid, NULL);
+ x = jutil_presnew(JPACKET__UNSUBSCRIBED, (char *)bjid, NULL);
jab_send(jc, x);
xmlnode_free(x);
}
// jb_subscr_request_auth(jid)
// Request a subscription to jid's presence updates
-void jb_subscr_request_auth(const char *jid)
+void jb_subscr_request_auth(const char *bjid)
{
xmlnode x;
- x = jutil_presnew(JPACKET__SUBSCRIBE, (char *)jid, NULL);
+ x = jutil_presnew(JPACKET__SUBSCRIBE, (char *)bjid, NULL);
jab_send(jc, x);
xmlnode_free(x);
}
// jb_subscr_request_cancel(jid)
// Request to cancel jour subscription to jid's presence updates
-void jb_subscr_request_cancel(const char *jid)
+void jb_subscr_request_cancel(const char *bjid)
{
xmlnode x;
- x = jutil_presnew(JPACKET__UNSUBSCRIBE, (char *)jid, NULL);
+ x = jutil_presnew(JPACKET__UNSUBSCRIBE, (char *)bjid, NULL);
jab_send(jc, x);
xmlnode_free(x);
}
// Note: the caller should check the jid is correct
-void jb_addbuddy(const char *jid, const char *name, const char *group)
+void jb_addbuddy(const char *bjid, const char *name, const char *group)
{
xmlnode y, z;
eviqs *iqn;
@@ -878,7 +878,7 @@
if (!online) return;
- cleanjid = jidtodisp(jid);
+ cleanjid = jidtodisp(bjid); // Stripping resource, just in case...
// We don't check if the jabber user already exists in the roster,
// because it allows to re-ask for notification.
@@ -908,7 +908,7 @@
update_roster = TRUE;
}
-void jb_delbuddy(const char *jid)
+void jb_delbuddy(const char *bjid)
{
xmlnode y, z;
eviqs *iqn;
@@ -916,7 +916,7 @@
if (!online) return;
- cleanjid = jidtodisp(jid);
+ cleanjid = jidtodisp(bjid); // Stripping resource, just in case...
// If the current buddy is an agent, unsubscribe from it
if (roster_gettype(cleanjid) == ROSTER_TYPE_AGENT) {
@@ -950,7 +950,7 @@
update_roster = TRUE;
}
-void jb_updatebuddy(const char *jid, const char *name, const char *group)
+void jb_updatebuddy(const char *bjid, const char *name, const char *group)
{
xmlnode y;
eviqs *iqn;
@@ -960,7 +960,7 @@
// XXX We should check name's and group's correctness
- cleanjid = jidtodisp(jid);
+ cleanjid = jidtodisp(bjid); // Stripping resource, just in case...
iqn = iqs_new(JPACKET__SET, NS_ROSTER, NULL, IQS_DEFAULT_TIMEOUT);
y = xmlnode_insert_tag(xmlnode_get_tag(iqn->xmldata, "query"), "item");
@@ -977,7 +977,7 @@
g_free(cleanjid);
}
-void jb_request(const char *jid, enum iqreq_type reqtype)
+void jb_request(const char *fjid, enum iqreq_type reqtype)
{
GSList *resources;
GSList *roster_elt;
@@ -1000,39 +1000,39 @@
// vCard request
if (reqtype == iqreq_vcard) {
- char *bjid = jidtodisp(jid);
+ char *bjid = jidtodisp(fjid);
request_vcard(bjid);
scr_LogPrint(LPRINT_NORMAL, "Sent vCard request to <%s>", bjid);
g_free(bjid);
return;
}
- if (strchr(jid, JID_RESOURCE_SEPARATOR)) {
+ if (strchr(fjid, JID_RESOURCE_SEPARATOR)) {
// This is a full JID
- (*request_fn)(jid);
- scr_LogPrint(LPRINT_NORMAL, "Sent %s request to <%s>", strreqtype, jid);
+ (*request_fn)(fjid);
+ scr_LogPrint(LPRINT_NORMAL, "Sent %s request to <%s>", strreqtype, fjid);
return;
}
// The resource has not been specified
- roster_elt = roster_find(jid, jidsearch, ROSTER_TYPE_USER|ROSTER_TYPE_ROOM);
+ roster_elt = roster_find(fjid, jidsearch, ROSTER_TYPE_USER|ROSTER_TYPE_ROOM);
if (!roster_elt) {
- scr_LogPrint(LPRINT_NORMAL, "No known resource for <%s>...", jid);
- (*request_fn)(jid); // Let's send a request anyway...
- scr_LogPrint(LPRINT_NORMAL, "Sent %s request to <%s>", strreqtype, jid);
+ scr_LogPrint(LPRINT_NORMAL, "No known resource for <%s>...", fjid);
+ (*request_fn)(fjid); // Let's send a request anyway...
+ scr_LogPrint(LPRINT_NORMAL, "Sent %s request to <%s>", strreqtype, fjid);
return;
}
// Send a request to each resource
resources = buddy_getresources(roster_elt->data);
if (!resources) {
- scr_LogPrint(LPRINT_NORMAL, "No known resource for <%s>...", jid);
- (*request_fn)(jid); // Let's send a request anyway...
- scr_LogPrint(LPRINT_NORMAL, "Sent %s request to <%s>", strreqtype, jid);
+ scr_LogPrint(LPRINT_NORMAL, "No known resource for <%s>...", fjid);
+ (*request_fn)(fjid); // Let's send a request anyway...
+ scr_LogPrint(LPRINT_NORMAL, "Sent %s request to <%s>", strreqtype, fjid);
}
for ( ; resources ; resources = g_slist_next(resources) ) {
gchar *fulljid;
- fulljid = g_strdup_printf("%s/%s", jid, (char*)resources->data);
+ fulljid = g_strdup_printf("%s/%s", fjid, (char*)resources->data);
(*request_fn)(fulljid);
scr_LogPrint(LPRINT_NORMAL, "Sent %s request to <%s>", strreqtype, fulljid);
g_free(fulljid);
@@ -1144,25 +1144,25 @@
// (ex. role none for kick, affil outcast for ban...)
// The reason can be null
// Return 0 if everything is ok
-int jb_room_setattrib(const char *roomid, const char *jid, const char *nick,
+int jb_room_setattrib(const char *roomid, const char *fjid, const char *nick,
struct role_affil ra, const char *reason)
{
xmlnode y, z;
eviqs *iqn;
if (!online || !roomid) return 1;
- if (!jid && !nick) return 1;
+ if (!fjid && !nick) return 1;
if (check_jid_syntax((char*)roomid)) {
scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber id", roomid);
return 1;
}
- if (jid && check_jid_syntax((char*)jid)) {
- scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber id", jid);
+ if (fjid && check_jid_syntax((char*)fjid)) {
+ scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber id", fjid);
return 1;
}
- if (ra.type == type_affil && ra.val.affil == affil_outcast && !jid)
+ if (ra.type == type_affil && ra.val.affil == affil_outcast && !fjid)
return 1; // Shouldn't happen (jid mandatory when banning)
iqn = iqs_new(JPACKET__SET, "http://jabber.org/protocol/muc#admin",
@@ -1172,8 +1172,8 @@
y = xmlnode_get_tag(iqn->xmldata, "query");
z = xmlnode_insert_tag(y, "item");
- if (jid) {
- xmlnode_put_attrib(z, "jid", jid);
+ if (fjid) {
+ xmlnode_put_attrib(z, "jid", fjid);
} else { // nickname
xmlnode_put_attrib(z, "nick", nick);
}
@@ -1198,11 +1198,11 @@
// Invite a user to a MUC room
// room syntax: "room@server"
// reason can be null.
-void jb_room_invite(const char *room, const char *jid, const char *reason)
+void jb_room_invite(const char *room, const char *fjid, const char *reason)
{
xmlnode x, y, z;
- if (!online || !room || !jid) return;
+ if (!online || !room || !fjid) return;
x = jutil_msgnew(NULL, (char*)room, NULL, NULL);
@@ -1210,7 +1210,7 @@
xmlnode_put_attrib(y, "xmlns", "http://jabber.org/protocol/muc#user");
z = xmlnode_insert_tag(y, "invite");
- xmlnode_put_attrib(z, "to", jid);
+ xmlnode_put_attrib(z, "to", fjid);
if (reason) {
y = xmlnode_insert_tag(z, "reason");
@@ -1244,15 +1244,15 @@
// Walk through the storage tags
x = xmlnode_get_firstchild(bookmarks);
for ( ; x; x = xmlnode_get_nextsibling(x)) {
- const char *jid;
+ const char *fjid;
const char *p;
p = xmlnode_get_name(x);
// If the current node is a conference item, see if we have to replace it.
if (p && !strcmp(p, "conference")) {
- jid = xmlnode_get_attrib(x, "jid");
- if (!jid)
+ fjid = xmlnode_get_attrib(x, "jid");
+ if (!fjid)
continue;
- if (!strcmp(jid, roomid)) {
+ if (!strcmp(fjid, roomid)) {
// We've found a bookmark for this room. Let's hide it and we'll
// create a new one.
xmlnode_hide(x);
@@ -1354,15 +1354,15 @@
// Walk through the storage rosternotes tags
x = xmlnode_get_firstchild(rosternotes);
for ( ; x; x = xmlnode_get_nextsibling(x)) {
- const char *jid;
+ const char *fjid;
const char *p;
p = xmlnode_get_name(x);
// We want a note item
if (!p || strcmp(p, "note"))
continue;
// Just in case, check the jid...
- jid = xmlnode_get_attrib(x, "jid");
- if (jid && !strcmp(jid, barejid)) // We've found a note for this contact.
+ fjid = xmlnode_get_attrib(x, "jid");
+ if (fjid && !strcmp(fjid, barejid)) // We've found a note for this contact.
return parse_storage_rosternote(x);
}
return NULL; // No note found
@@ -1390,15 +1390,15 @@
// Walk through the storage tags
x = xmlnode_get_firstchild(rosternotes);
for ( ; x; x = xmlnode_get_nextsibling(x)) {
- const char *jid;
+ const char *fjid;
const char *p;
p = xmlnode_get_name(x);
// If the current node is a conference item, see if we have to replace it.
if (p && !strcmp(p, "note")) {
- jid = xmlnode_get_attrib(x, "jid");
- if (!jid)
+ fjid = xmlnode_get_attrib(x, "jid");
+ if (!fjid)
continue;
- if (!strcmp(jid, barejid)) {
+ if (!strcmp(fjid, barejid)) {
// We've found a note for this jid. Let's hide it and we'll
// create a new one.
cdate = xmlnode_get_attrib(x, "cdate");
@@ -1492,11 +1492,11 @@
const char *enc, time_t timestamp,
xmlnode xmldata_signed)
{
- char *jid;
+ char *bjid;
const char *rname, *s;
char *decrypted = NULL;
- jid = jidtodisp(from);
+ bjid = jidtodisp(from);
rname = strchr(from, JID_RESOURCE_SEPARATOR);
if (rname) rname++;
@@ -1510,36 +1510,36 @@
}
// Check signature of an unencrypted message
if (xmldata_signed && gpg_enabled())
- check_signature(jid, rname, xmldata_signed, decrypted);
+ check_signature(bjid, rname, xmldata_signed, decrypted);
#endif
// Check for unexpected groupchat messages
// If we receive a groupchat message from a room we're not a member of,
// this is probably a server issue and the best we can do is to send
// a type unavailable.
- if (type && !strcmp(type, "groupchat") && !roster_getnickname(jid)) {
+ if (type && !strcmp(type, "groupchat") && !roster_getnickname(bjid)) {
// It shouldn't happen, probably a server issue
GSList *room_elt;
char *mbuf;
mbuf = g_strdup_printf("Unexpected groupchat packet!");
scr_LogPrint(LPRINT_LOGNORM, "%s", mbuf);
- scr_WriteIncomingMessage(jid, mbuf, 0, HBB_PREFIX_INFO);
+ scr_WriteIncomingMessage(bjid, mbuf, 0, HBB_PREFIX_INFO);
g_free(mbuf);
// Send back an unavailable packet
- jb_setstatus(offline, jid, "", TRUE);
+ jb_setstatus(offline, bjid, "", TRUE);
// MUC
// Make sure this is a room (it can be a conversion user->room)
- room_elt = roster_find(jid, jidsearch, 0);
+ room_elt = roster_find(bjid, jidsearch, 0);
if (!room_elt) {
- room_elt = roster_add_user(jid, NULL, NULL, ROSTER_TYPE_ROOM, sub_none);
+ room_elt = roster_add_user(bjid, NULL, NULL, ROSTER_TYPE_ROOM, sub_none);
} else {
buddy_settype(room_elt->data, ROSTER_TYPE_ROOM);
}
- g_free(jid);
+ g_free(bjid);
g_free(decrypted);
buddylist_build();
@@ -1551,15 +1551,15 @@
// this is a regular message from an unsubscribed user.
// System messages (from our server) are allowed.
if (!settings_opt_get_int("block_unsubscribed") ||
- (roster_getsubscription(jid) & sub_from) ||
+ (roster_getsubscription(bjid) & sub_from) ||
(type && strcmp(type, "chat")) ||
- ((s = settings_opt_get("server")) != NULL && !strcasecmp(jid, s))) {
- hk_message_in(jid, rname, timestamp, body, type,
+ ((s = settings_opt_get("server")) != NULL && !strcasecmp(bjid, s))) {
+ hk_message_in(bjid, rname, timestamp, body, type,
(decrypted ? TRUE : FALSE));
} else {
- scr_LogPrint(LPRINT_LOGNORM, "Blocked a message from <%s>", jid);
+ scr_LogPrint(LPRINT_LOGNORM, "Blocked a message from <%s>", bjid);
}
- g_free(jid);
+ g_free(bjid);
g_free(decrypted);
}
@@ -2151,7 +2151,7 @@
#if defined JEP0022 || defined JEP0085
xmlnode state_ns = NULL;
const char *body;
- char *rname, *jid;
+ char *rname, *bjid;
GSList *sl_buddy;
guint events;
struct jep0022 *jep22 = NULL;
@@ -2163,14 +2163,14 @@
} which_jep = JEP_none;
rname = strchr(from, JID_RESOURCE_SEPARATOR);
- jid = jidtodisp(from);
- sl_buddy = roster_find(jid, jidsearch, ROSTER_TYPE_USER);
+ bjid = jidtodisp(from);
+ sl_buddy = roster_find(bjid, jidsearch, ROSTER_TYPE_USER);
+ g_free(bjid);
/* XXX Actually that's wrong, since it filters out server "offline"
messages (for JEP-0022). This JEP is (almost) deprecated so
we don't really care. */
if (!sl_buddy || !rname++) {
- g_free(jid);
return;
}
@@ -2195,7 +2195,6 @@
}
if (!which_jep) { /* Sender does not use chat states */
- g_free(jid);
return;
}
@@ -2258,8 +2257,6 @@
buddy_resource_setevents(sl_buddy->data, rname, events);
update_roster = TRUE;
-
- g_free(jid);
#endif
}
--- a/mcabber/src/jabglue.h Tue Nov 28 07:14:59 2006 +0100
+++ b/mcabber/src/jabglue.h Thu Nov 30 19:51:09 2006 +0100
@@ -44,24 +44,24 @@
char *compose_jid(const char *username, const char *servername,
const char *resource);
-jconn jb_connect(const char *jid, const char *server, unsigned int port,
+jconn jb_connect(const char *fjid, 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);
-void jb_subscr_send_auth(const char *jid);
-void jb_subscr_cancel_auth(const char *jid);
-void jb_subscr_request_auth(const char *jid);
-void jb_subscr_request_cancel(const char *jid);
-void jb_addbuddy(const char *jid, const char *name, const char *group);
-void jb_delbuddy(const char *jid);
-void jb_updatebuddy(const char *jid, const char *name, const char *group);
+void jb_subscr_send_auth(const char *bjid);
+void jb_subscr_cancel_auth(const char *bjid);
+void jb_subscr_request_auth(const char *bjid);
+void jb_subscr_request_cancel(const char *bjid);
+void jb_addbuddy(const char *bjid, const char *name, const char *group);
+void jb_delbuddy(const char *bjid);
+void jb_updatebuddy(const char *bjid, const char *name, const char *group);
inline enum imstatus jb_getstatus(void);
inline const char *jb_getstatusmsg(void);
void jb_setstatus(enum imstatus st, const char *recipient, const char *msg,
int do_not_sign);
inline void jb_setprevstatus(void);
-void jb_send_msg(const char *jid, const char *text, int type,
+void jb_send_msg(const char *fjid, const char *text, int type,
const char *subject, const char *id, guint *encrypted);
void jb_send_raw(const char *str);
void jb_send_chatstate(gpointer buddy, guint chatstate);
@@ -71,11 +71,11 @@
void jb_room_join(const char *room, const char *nickname, const char *passwd);
void jb_room_unlock(const char *room);
void jb_room_destroy(const char *room, const char *venue, const char *reason);
-void jb_room_invite(const char *room, const char *jid, const char *reason);
-int jb_room_setattrib(const char *roomid, const char *jid, const char *nick,
+void jb_room_invite(const char *room, const char *fjid, const char *reason);
+int jb_room_setattrib(const char *roomid, const char *fjid, const char *nick,
struct role_affil ra, const char *reason);
void jb_iqs_display_list(void);
-void jb_request(const char *jid, enum iqreq_type reqtype);
+void jb_request(const char *fjid, enum iqreq_type reqtype);
void jb_set_storage_bookmark(const char *roomid, const char *name,
const char *nick, const char *passwd,
int autojoin);
--- a/mcabber/src/main.c Tue Nov 28 07:14:59 2006 +0100
+++ b/mcabber/src/main.c Thu Nov 30 19:51:09 2006 +0100
@@ -67,7 +67,7 @@
{
const char *username, *password, *resource, *servername;
const char *proxy_host;
- char *jid;
+ char *bjid;
int ssl;
int sslverify = -1;
const char *sslvopt = NULL, *cafile = NULL, *capath = NULL, *ciphers = NULL;
@@ -135,9 +135,9 @@
}
}
- jid = compose_jid(username, servername, resource);
- jc = jb_connect(jid, servername, port, ssl, password);
- g_free(jid);
+ bjid = compose_jid(username, servername, resource);
+ jc = jb_connect(bjid, servername, port, ssl, password);
+ g_free(bjid);
if (!jc)
scr_LogPrint(LPRINT_LOGNORM, "Error connecting to (%s)", servername);
--- a/mcabber/src/roster.c Tue Nov 28 07:14:59 2006 +0100
+++ b/mcabber/src/roster.c Thu Nov 30 19:51:09 2006 +0100
@@ -264,7 +264,7 @@
GSList *roster_find(const char *jidname, enum findwhat type, guint roster_type)
{
GSList *sl_roster_elt = groups;
- GSList *res;
+ GSList *resource;
roster sample;
GCompareFunc comp;
@@ -290,8 +290,8 @@
if ((type == namesearch) && !strcmp(jidname, roster_elt->name))
return sl_roster_elt;
}
- res = g_slist_find_custom(roster_elt->list, &sample, comp);
- if (res) return res;
+ resource = g_slist_find_custom(roster_elt->list, &sample, comp);
+ if (resource) return resource;
sl_roster_elt = g_slist_next(sl_roster_elt);
}
return NULL;
--- a/mcabber/src/screen.c Tue Nov 28 07:14:59 2006 +0100
+++ b/mcabber/src/screen.c Thu Nov 30 19:51:09 2006 +0100
@@ -491,9 +491,9 @@
return NULL;
}
-int scr_BuddyBufferExists(const char *jid)
+int scr_BuddyBufferExists(const char *bjid)
{
- return (scr_SearchWindow(jid, FALSE) != NULL);
+ return (scr_SearchWindow(bjid, FALSE) != NULL);
}
// scr_UpdateWindow()
@@ -568,11 +568,11 @@
dir = '>';
wprintw(win_entry->win, "%.11s #%c# ", date, dir);
} else if (line->flags & HBB_PREFIX_IN) {
- char crypt = line->flags & HBB_PREFIX_PGPCRYPT ? '~' : '=';
- wprintw(win_entry->win, "%.11s <%c= ", date, crypt);
+ char cryptflag = line->flags & HBB_PREFIX_PGPCRYPT ? '~' : '=';
+ wprintw(win_entry->win, "%.11s <%c= ", date, cryptflag);
} else if (line->flags & HBB_PREFIX_OUT) {
- char crypt = line->flags & HBB_PREFIX_PGPCRYPT ? '~' : '-';
- wprintw(win_entry->win, "%.11s -%c> ", date, crypt);
+ char cryptflag = line->flags & HBB_PREFIX_PGPCRYPT ? '~' : '-';
+ wprintw(win_entry->win, "%.11s -%c> ", date, cryptflag);
} else if (line->flags & HBB_PREFIX_SPECIAL) {
strftime(date, 30, "%m-%d %H:%M:%S", localtime(&line->timestamp));
wprintw(win_entry->win, "%.14s ", date);
@@ -639,26 +639,26 @@
// Display the chat window buffer for the current buddy.
void scr_ShowBuddyWindow(void)
{
- const gchar *jid;
+ const gchar *bjid;
if (!current_buddy) {
- jid = NULL;
+ bjid = NULL;
} else {
- jid = CURRENT_JID;
+ bjid = CURRENT_JID;
if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL) {
scr_ShowWindow(buddy_getname(BUDDATA(current_buddy)), TRUE);
return;
}
}
- if (!jid) {
+ if (!bjid) {
top_panel(chatPanel);
top_panel(inputPanel);
currentWindow = NULL;
return;
}
- scr_ShowWindow(jid, FALSE);
+ scr_ShowWindow(bjid, FALSE);
}
// scr_UpdateBuddyWindow()
@@ -1336,7 +1336,7 @@
}
}
-inline void scr_WriteMessage(const char *jid, const char *text,
+inline void scr_WriteMessage(const char *bjid, const char *text,
time_t timestamp, guint prefix_flags)
{
char *xtext;
@@ -1347,7 +1347,7 @@
// XXX Are there other special chars we should filter out?
- scr_WriteInWindow(jid, xtext, timestamp, prefix_flags, FALSE);
+ scr_WriteInWindow(bjid, xtext, timestamp, prefix_flags, FALSE);
if (xtext != (char*)text)
g_free(xtext);
@@ -1570,8 +1570,8 @@
scr_ShowBuddyWindow();
}
-// scr_RosterJumpJid(jid)
-// Jump to buddy jid.
+// scr_RosterJumpJid(bjid)
+// Jump to buddy bjid.
// NOTE: With this function, the buddy is added to the roster if doesn't exist.
void scr_RosterJumpJid(char *barejid)
{
@@ -1930,12 +1930,12 @@
// scr_setmsgflag_if_needed(jid)
// Set the message flag unless we're already in the jid buffer window
-void scr_setmsgflag_if_needed(const char *jid, int special)
+void scr_setmsgflag_if_needed(const char *bjid, int special)
{
const char *current_id;
bool iscurrentlocked = FALSE;
- if (!jid)
+ if (!bjid)
return;
if (current_buddy) {
@@ -1951,8 +1951,8 @@
} else {
current_id = NULL;
}
- if (!chatmode || !current_id || strcmp(jid, current_id) || iscurrentlocked)
- roster_msg_setflag(jid, special, TRUE);
+ if (!chatmode || !current_id || strcmp(bjid, current_id) || iscurrentlocked)
+ roster_msg_setflag(bjid, special, TRUE);
}
// scr_set_multimode()
@@ -2502,9 +2502,9 @@
kcode->value = wgetch(inputWnd);
if (utf8_mode) {
- bool meta = (kcode->value == 27);
-
- if (meta)
+ bool ismeta = (kcode->value == 27);
+
+ if (ismeta)
ks[0] = wgetch(inputWnd);
else
ks[0] = kcode->value;
@@ -2516,7 +2516,7 @@
if (match > 0) {
kcode->value = match;
kcode->utf8 = 1;
- if (meta)
+ if (ismeta)
kcode->mcode = MKEY_META;
return;
}
@@ -2526,7 +2526,7 @@
}
while (i > 0)
ungetch(ks[i--]);
- if (meta)
+ if (ismeta)
ungetch(ks[0]);
memset(ks, 0, sizeof(ks));
}
@@ -2590,14 +2590,14 @@
boundcmd = settings_get(SETTINGS_TYPE_BINDING, asciikey);
if (boundcmd) {
- gchar *cmd, *boundcmd_locale;
+ gchar *cmdline, *boundcmd_locale;
boundcmd_locale = from_utf8(boundcmd);
- cmd = g_strdup_printf(mkcmdstr("%s"), boundcmd_locale);
+ cmdline = g_strdup_printf(mkcmdstr("%s"), boundcmd_locale);
scr_CheckAutoAway(TRUE);
- if (process_command(cmd))
+ if (process_command(cmdline))
return 255; // Quit
g_free(boundcmd_locale);
- g_free(cmd);
+ g_free(cmdline);
return 0;
}
--- a/mcabber/src/utils.c Tue Nov 28 07:14:59 2006 +0100
+++ b/mcabber/src/utils.c Thu Nov 30 19:51:09 2006 +0100
@@ -306,27 +306,27 @@
* Check if the full JID is valid
* Return 0 if it is valid, non zero otherwise
*/
-int check_jid_syntax(char *jid)
+int check_jid_syntax(char *fjid)
{
char *str;
char *domain, *resource;
int domlen;
- if (!jid) return 1;
+ if (!fjid) return 1;
- domain = strchr(jid, JID_DOMAIN_SEPARATOR);
+ domain = strchr(fjid, JID_DOMAIN_SEPARATOR);
/* the username is optional */
if (!domain) {
- domain = jid;
+ domain = fjid;
} else {
/* node identifiers may not be longer than 1023 bytes */
- if ((domain == jid) || (domain-jid > 1023))
+ if ((domain == fjid) || (domain-fjid > 1023))
return 1;
domain++;
/* check for low and invalid ascii characters in the username */
- for (str = jid; *str != JID_DOMAIN_SEPARATOR; str++) {
+ for (str = fjid; *str != JID_DOMAIN_SEPARATOR; str++) {
if (*str <= ' ' || *str == ':' || *str == JID_DOMAIN_SEPARATOR ||
*str == '<' || *str == '>' || *str == '\'' ||
*str == '"' || *str == '&') {
--- a/mcabber/src/utils.h Tue Nov 28 07:14:59 2006 +0100
+++ b/mcabber/src/utils.h Thu Nov 30 19:51:09 2006 +0100
@@ -26,7 +26,7 @@
inline void safe_usleep(unsigned int usec); /* Only for delays < 1s */
-int check_jid_syntax(char *jid);
+int check_jid_syntax(char *fjid);
void mc_strtolower(char *str);