aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2013-02-21 14:03:15 +0000
committerWilmer van der Gaast <wilmer@gaast.net>2013-02-21 14:03:15 +0000
commit06eef808b0ce5d7d7056240be6286aa79ac6a9ec (patch)
treef2ef90945c7595580ff4aeb33ee78320132c8ab4
parent12f500f085fe715b62e13c9b67b23f952c100a21 (diff)
For the lazy among us: When adding a Jabber/MSN contact within the same
domain like you, you can omit the domain name.
-rw-r--r--protocols/account.h1
-rw-r--r--protocols/jabber/jabber.c3
-rw-r--r--protocols/jabber/jabber.h2
-rw-r--r--protocols/msn/msn.c3
-rw-r--r--root_commands.c14
5 files changed, 20 insertions, 3 deletions
diff --git a/protocols/account.h b/protocols/account.h
index a39be2e2..66eb677c 100644
--- a/protocols/account.h
+++ b/protocols/account.h
@@ -69,6 +69,7 @@ typedef enum
{
ACC_FLAG_AWAY_MESSAGE = 0x01, /* Supports away messages instead of just states. */
ACC_FLAG_STATUS_MESSAGE = 0x02, /* Supports status messages (without being away). */
+ ACC_FLAG_HANDLE_DOMAINS = 0x04, /* Contact handles need a domain portion. */
} account_flag_t;
#endif
diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c
index 86daaa6a..8f0f8cac 100644
--- a/protocols/jabber/jabber.c
+++ b/protocols/jabber/jabber.c
@@ -95,7 +95,8 @@ static void jabber_init( account_t *acc )
s = set_add( &acc->set, "xmlconsole", "false", set_eval_bool, acc );
s->flags |= ACC_SET_OFFLINE_ONLY;
- acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE;
+ acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE |
+ ACC_FLAG_HANDLE_DOMAINS;
}
static void jabber_generate_id_hash( struct jabber_data *jd );
diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h
index fa0ca015..f5127a0b 100644
--- a/protocols/jabber/jabber.h
+++ b/protocols/jabber/jabber.h
@@ -195,7 +195,7 @@ struct jabber_transfer
struct sockaddr_storage saddr;
};
-#define JABBER_XMLCONSOLE_HANDLE "xmlconsole"
+#define JABBER_XMLCONSOLE_HANDLE "_xmlconsole"
#define JABBER_OAUTH_HANDLE "jabber_oauth"
/* Prefixes to use for packet IDs (mainly for IQ packets ATM). Usually the
diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c
index 845f9cf8..f842512b 100644
--- a/protocols/msn/msn.c
+++ b/protocols/msn/msn.c
@@ -43,7 +43,8 @@ static void msn_init( account_t *acc )
set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc );
set_add( &acc->set, "switchboard_keepalives", "false", set_eval_bool, acc );
- acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE;
+ acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE |
+ ACC_FLAG_HANDLE_DOMAINS;
}
static void msn_login( account_t *acc )
diff --git a/root_commands.c b/root_commands.c
index 6188245d..3e5b90a4 100644
--- a/root_commands.c
+++ b/root_commands.c
@@ -679,6 +679,7 @@ static void cmd_add( irc_t *irc, char **cmd )
{
account_t *a;
int add_on_server = 1;
+ char *handle = NULL, *s;
if( g_strcasecmp( cmd[1], "-tmp" ) == 0 )
{
@@ -716,6 +717,18 @@ static void cmd_add( irc_t *irc, char **cmd )
}
}
+ if( ( a->flags & ACC_FLAG_HANDLE_DOMAINS ) && cmd[2][0] != '_' &&
+ ( !( s = strchr( cmd[2], '@' ) ) || s[1] == '\0' ) )
+ {
+ /* If there's no @ or it's the last char, append the user's
+ domain name now. Exclude handles starting with a _ so
+ adding _xmlconsole will keep working. */
+ if( s )
+ *s = '\0';
+ if( ( s = strchr( a->user, '@' ) ) )
+ cmd[2] = handle = g_strconcat( cmd[2], s, NULL );
+ }
+
if( add_on_server )
{
irc_channel_t *ic;
@@ -745,6 +758,7 @@ static void cmd_add( irc_t *irc, char **cmd )
"to contact `%s'", iu->nick, cmd[2] );
}
+ g_free( handle );
}
static void cmd_remove( irc_t *irc, char **cmd )