Skip to content
Browse files

Add extended-join support

  • Loading branch information...
1 parent 4e88e9c commit 96a26ccdb3951d77acb05688a73fe39a51808463 @TingPing committed Mar 14, 2013
Showing with 39 additions and 12 deletions.
  1. +1 −0 src/common/hexchat.h
  2. +4 −7 src/common/inbound.c
  3. +1 −1 src/common/inbound.h
  4. +14 −1 src/common/proto-irc.c
  5. +1 −0 src/common/server.c
  6. +17 −2 src/common/userlist.c
  7. +1 −1 src/common/userlist.h
View
1 src/common/hexchat.h
@@ -574,6 +574,7 @@ typedef struct server
unsigned int have_capab:1; /* supports CAPAB (005 tells us) */
unsigned int have_idmsg:1; /* freenode's IDENTIFY-MSG */
unsigned int have_accountnotify:1;
+ unsigned int have_extjoin:1;
unsigned int have_sasl:1; /* SASL capability */
unsigned int have_except:1; /* ban exemptions +e */
unsigned int using_cp1255:1; /* encoding is CP1255/WINDOWS-1255? */
View
11 src/common/inbound.c
@@ -659,12 +659,12 @@ inbound_nameslist (server *serv, char *chan, char *names)
case 0:
name[pos] = 0;
if (pos != 0)
- userlist_add (sess, name, 0);
+ userlist_add (sess, name, 0, NULL, NULL);
return;
case ' ':
name[pos] = 0;
pos = 0;
- userlist_add (sess, name, 0);
+ userlist_add (sess, name, 0, NULL, NULL);
break;
default:
name[pos] = *names;
@@ -709,13 +709,13 @@ inbound_topicnew (server *serv, char *nick, char *chan, char *topic)
}
void
-inbound_join (server *serv, char *chan, char *user, char *ip)
+inbound_join (server *serv, char *chan, char *user, char *ip, char *account, char *realname)
{
session *sess = find_channel (serv, chan);
if (sess)
{
EMIT_SIGNAL (XP_TE_JOIN, sess, user, chan, ip, NULL, 0);
- userlist_add (sess, user, ip);
+ userlist_add (sess, user, ip, account, realname);
}
}
@@ -1265,9 +1265,6 @@ inbound_user_info (session *sess, char *chan, char *user, char *host,
sprintf (uhost, "%s@%s", user, host);
}
- if (strcmp (account, "*") == 0 || strcmp (account, ":0") == 0)
- account = NULL;
-
if (chan)
{
who_sess = find_channel (serv, chan);
View
2 src/common/inbound.h
@@ -12,7 +12,7 @@ void inbound_kick (server *serv, char *chan, char *user, char *kicker, char *rea
void inbound_notice (server *serv, char *to, char *nick, char *msg, char *ip, int id);
void inbound_quit (server *serv, char *nick, char *ip, char *reason);
void inbound_topicnew (server *serv, char *nick, char *chan, char *topic);
-void inbound_join (server *serv, char *chan, char *user, char *ip);
+void inbound_join (server *serv, char *chan, char *user, char *ip, char *account, char *realname);
void inbound_ujoin (server *serv, char *chan, char *nick, char *ip);
void inbound_topictime (server *serv, char *chan, char *nick, time_t stamp);
void inbound_topic (server *serv, char *chan, char *topic_text);
View
15 src/common/proto-irc.c
@@ -953,13 +953,15 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[])
case WORDL('J','O','I','N'):
{
char *chan = word[3];
+ char *account = word[4];
+ char *realname = word_eol[5] + 1;
if (*chan == ':')
chan++;
if (!serv->p_cmp (nick, serv->nick))
inbound_ujoin (serv, chan, nick, ip);
else
- inbound_join (serv, chan, nick, ip);
+ inbound_join (serv, chan, nick, ip, account, realname);
}
return;
@@ -1164,6 +1166,11 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[])
serv->have_accountnotify = TRUE;
}
+ if (strstr (word_eol[5], "extended-join") != 0)
+ {
+ serv->have_extjoin = TRUE;
+ }
+
if (strstr (word_eol[5], "sasl") != 0)
{
serv->have_sasl = TRUE;
@@ -1197,6 +1204,12 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[])
want_cap ? strcat (buffer, " account-notify") : strcpy (buffer, "CAP REQ :account-notify");
want_cap = 1;
}
+
+ if (strstr (word_eol[5], "extended-join") != 0)
+ {
+ want_cap ? strcat (buffer, " extended-join") : strcpy (buffer, "CAP REQ :extended-join");
+ want_cap = 1;
+ }
/* if the SASL password is set, request SASL auth */
if (strstr (word_eol[5], "sasl") != 0 && strlen (sess->server->saslpassword) != 0)
{
View
1 src/common/server.c
@@ -1913,6 +1913,7 @@ server_set_defaults (server *serv)
serv->have_capab = FALSE;
serv->have_idmsg = FALSE;
serv->have_accountnotify = FALSE;
+ serv->have_extjoin = FALSE;
serv->have_sasl = FALSE;
serv->have_except = FALSE;
}
View
19 src/common/userlist.c
@@ -146,7 +146,7 @@ userlist_add_hostname (struct session *sess, char *nick, char *hostname,
user->realname = strdup (realname);
if (!user->servername && servername)
user->servername = strdup (servername);
- if (!user->account && account)
+ if (!user->account && account && strcmp (account, ":0") != 0)
user->account = strdup (account);
if (away != 0xff)
@@ -175,6 +175,8 @@ free_user (struct User *user, gpointer data)
free (user->hostname);
if (user->servername)
free (user->servername);
+ if (user->account)
+ free (user->account);
free (user);
return TRUE;
@@ -378,7 +380,7 @@ userlist_remove_user (struct session *sess, struct User *user)
}
void
-userlist_add (struct session *sess, char *name, char *hostname)
+userlist_add (struct session *sess, char *name, char *hostname, char *account, char *realname)
{
struct User *user;
int row, prefix_chars;
@@ -404,13 +406,26 @@ userlist_add (struct session *sess, char *name, char *hostname)
/* is it me? */
if (!sess->server->p_cmp (user->nick, sess->server->nick))
user->me = TRUE;
+ /* extended join info */
+ if (sess->server->have_extjoin)
+ {
+ if (account && strcmp (account, "*") != 0)
+ user->account = strdup (account);
+ if (realname)
+ user->realname = strdup (realname);
+ }
+
row = userlist_insertname (sess, user);
/* duplicate? some broken servers trigger this */
if (row == -1)
{
if (user->hostname)
free (user->hostname);
+ if (user->account)
+ free (user->account);
+ if (user->realname)
+ free (user->realname);
free (user);
return;
}
View
2 src/common/userlist.h
@@ -32,7 +32,7 @@ struct User *userlist_find (session *sess, const char *name);
struct User *userlist_find_global (server *serv, char *name);
void userlist_clear (session *sess);
void userlist_free (session *sess);
-void userlist_add (session *sess, char *name, char *hostname);
+void userlist_add (session *sess, char *name, char *hostname, char *account, char *realname);
int userlist_remove (session *sess, char *name);
void userlist_remove_user (session *sess, struct User *user);
int userlist_change (session *sess, char *oldname, char *newname);

0 comments on commit 96a26cc

Please sign in to comment.
Something went wrong with that request. Please try again.