diff options
Diffstat (limited to 'protocols/jabber/jabber.c')
-rw-r--r-- | protocols/jabber/jabber.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index 4b5cb3a1..30e55159 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -62,6 +62,8 @@ static void jabber_init( account_t *acc ) s = set_add( &acc->set, "oauth", "false", set_eval_oauth, acc ); + s = set_add( &acc->set, "display_name", NULL, NULL, acc ); + g_snprintf( str, sizeof( str ), "%d", jabber_port_list[0] ); s = set_add( &acc->set, "port", str, set_eval_int, acc ); s->flags |= ACC_SET_OFFLINE_ONLY; @@ -317,6 +319,7 @@ static void jabber_logout( struct im_connection *ic ) g_free( jd->oauth2_access_token ); g_free( jd->away_message ); + g_free( jd->internal_jid ); g_free( jd->username ); g_free( jd->me ); g_free( jd ); @@ -472,14 +475,22 @@ static void jabber_remove_buddy( struct im_connection *ic, char *who, char *grou static struct groupchat *jabber_chat_join_( struct im_connection *ic, const char *room, const char *nick, const char *password, set_t **sets ) { struct jabber_data *jd = ic->proto_data; + char *final_nick; + /* Ignore the passed nick parameter if we have our own default */ + if ( !( final_nick = set_getstr( sets, "nick" ) ) && + !( final_nick = set_getstr( &ic->acc->set, "display_name" ) ) ) { + /* Well, whatever, actually use the provided default, then */ + final_nick = (char *) nick; + } + if( strchr( room, '@' ) == NULL ) imcb_error( ic, "%s is not a valid Jabber room name. Maybe you mean %s@conference.%s?", room, room, jd->server ); else if( jabber_chat_by_jid( ic, room ) ) imcb_error( ic, "Already present in chat `%s'", room ); else - return jabber_chat_join( ic, room, nick, set_getstr( sets, "password" ) ); + return jabber_chat_join( ic, room, final_nick, set_getstr( sets, "password" ) ); return NULL; } @@ -620,6 +631,13 @@ void *jabber_buddy_action( struct bee_user *bu, const char *action, char * const return NULL; } +gboolean jabber_handle_is_self( struct im_connection *ic, const char *who ) { + struct jabber_data *jd = ic->proto_data; + return ( ( g_strcasecmp( who, ic->acc->user ) == 0 ) || + ( jd->internal_jid && + g_strcasecmp( who, jd->internal_jid ) == 0 ) ); +} + void jabber_initmodule() { struct prpl *ret = g_new0( struct prpl, 1 ); @@ -647,6 +665,7 @@ void jabber_initmodule() ret->keepalive = jabber_keepalive; ret->send_typing = jabber_send_typing; ret->handle_cmp = g_strcasecmp; + ret->handle_is_self = jabber_handle_is_self; ret->transfer_request = jabber_si_transfer_request; ret->buddy_action_list = jabber_buddy_action_list; ret->buddy_action = jabber_buddy_action; |