source: protocols/jabber/jabber.c @ 6e9ae72

Last change on this file since 6e9ae72 was 6e9ae72, checked in by Wilmer van der Gaast <wilmer@…>, at 2011-12-17T13:50:01Z

Mainline merge.

  • Property mode set to 100644
File size: 17.4 KB
RevLine 
[f06894d]1/***************************************************************************\
2*                                                                           *
3*  BitlBee - An IRC to IM gateway                                           *
4*  Jabber module - Main file                                                *
5*                                                                           *
6*  Copyright 2006 Wilmer van der Gaast <wilmer@gaast.net>                   *
7*                                                                           *
8*  This program is free software; you can redistribute it and/or modify     *
9*  it under the terms of the GNU General Public License as published by     *
10*  the Free Software Foundation; either version 2 of the License, or        *
11*  (at your option) any later version.                                      *
12*                                                                           *
13*  This program is distributed in the hope that it will be useful,          *
14*  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
15*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
16*  GNU General Public License for more details.                             *
17*                                                                           *
18*  You should have received a copy of the GNU General Public License along  *
19*  with this program; if not, write to the Free Software Foundation, Inc.,  *
20*  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.              *
21*                                                                           *
22\***************************************************************************/
23
24#include <glib.h>
25#include <string.h>
26#include <unistd.h>
27#include <ctype.h>
28#include <stdio.h>
29
[21167d2]30#include "ssl_client.h"
[f06894d]31#include "xmltree.h"
32#include "bitlbee.h"
33#include "jabber.h"
[608f8cf]34#include "md5.h"
[f06894d]35
[b5c8a34]36GSList *jabber_connections;
37
[7f69740]38/* First enty is the default */
39static const int jabber_port_list[] = {
40        5222,
41        5223,
42        5220,
43        5221,
44        5224,
45        5225,
46        5226,
47        5227,
48        5228,
49        5229,
50        80,
51        443,
52        0
53};
54
[0da65d5]55static void jabber_init( account_t *acc )
[f06894d]56{
57        set_t *s;
[7f69740]58        char str[16];
[f06894d]59       
[76c85b4c]60        s = set_add( &acc->set, "activity_timeout", "600", set_eval_int, acc );
61       
[57b4525]62        s = set_add( &acc->set, "oauth", "false", set_eval_bool, acc );
63
[7f69740]64        g_snprintf( str, sizeof( str ), "%d", jabber_port_list[0] );
65        s = set_add( &acc->set, "port", str, set_eval_int, acc );
[f06894d]66        s->flags |= ACC_SET_OFFLINE_ONLY;
67       
[ebe7b36]68        s = set_add( &acc->set, "priority", "0", set_eval_priority, acc );
[1c3008a]69
70        s = set_add( &acc->set, "proxy", "<local>;<auto>", NULL, acc );
[f06894d]71       
[ebe7b36]72        s = set_add( &acc->set, "resource", "BitlBee", NULL, acc );
73        s->flags |= ACC_SET_OFFLINE_ONLY;
[f06894d]74       
[76c85b4c]75        s = set_add( &acc->set, "resource_select", "activity", NULL, acc );
[a21a8ac]76       
[f06894d]77        s = set_add( &acc->set, "server", NULL, set_eval_account, acc );
[7125cb3]78        s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY | SET_NULL_OK;
[f06894d]79       
80        s = set_add( &acc->set, "ssl", "false", set_eval_bool, acc );
81        s->flags |= ACC_SET_OFFLINE_ONLY;
82       
83        s = set_add( &acc->set, "tls", "try", set_eval_tls, acc );
84        s->flags |= ACC_SET_OFFLINE_ONLY;
[a6df0b5]85       
[06b5893]86        s = set_add( &acc->set, "sasl", "true", set_eval_bool, acc );
87        s->flags |= ACC_SET_OFFLINE_ONLY | SET_HIDDEN_DEFAULT;
88
[4eef271]89        s = set_add( &acc->set, "user_agent", "BitlBee", NULL, acc );
90       
[a6df0b5]91        s = set_add( &acc->set, "xmlconsole", "false", set_eval_bool, acc );
92        s->flags |= ACC_SET_OFFLINE_ONLY;
[840bba8]93       
94        acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE;
[f06894d]95}
96
[608f8cf]97static void jabber_generate_id_hash( struct jabber_data *jd );
98
[f06894d]99static void jabber_login( account_t *acc )
100{
[84b045d]101        struct im_connection *ic = imcb_new( acc );
[21167d2]102        struct jabber_data *jd = g_new0( struct jabber_data, 1 );
[4a5d885]103        char *s;
[21167d2]104       
[b5c8a34]105        /* For now this is needed in the _connected() handlers if using
106           GLib event handling, to make sure we're not handling events
107           on dead connections. */
108        jabber_connections = g_slist_prepend( jabber_connections, ic );
109       
[0da65d5]110        jd->ic = ic;
111        ic->proto_data = jd;
[21167d2]112       
113        jd->username = g_strdup( acc->user );
114        jd->server = strchr( jd->username, '@' );
115       
[de03374]116        jd->fd = jd->r_inpa = jd->w_inpa = -1;
117       
[21167d2]118        if( jd->server == NULL )
119        {
[84b045d]120                imcb_error( ic, "Incomplete account name (format it like <username@jabberserver.name>)" );
[c2fb3809]121                imc_logout( ic, FALSE );
[21167d2]122                return;
123        }
124       
125        /* So don't think of free()ing jd->server.. :-) */
126        *jd->server = 0;
127        jd->server ++;
128       
[3b3cd693]129        if( ( s = strchr( jd->server, '/' ) ) )
130        {
131                *s = 0;
132                set_setstr( &acc->set, "resource", s + 1 );
133               
134                /* Also remove the /resource from the original variable so we
135                   won't have to do this again every time. */
136                s = strchr( acc->user, '/' );
137                *s = 0;
138        }
139       
[038d17f]140        jd->node_cache = g_hash_table_new_full( g_str_hash, g_str_equal, NULL, jabber_cache_entry_free );
[6a1128d]141        jd->buddies = g_hash_table_new( g_str_hash, g_str_equal );
[fe7a554]142       
[4a5d885]143        if( set_getbool( &acc->set, "oauth" ) )
144        {
[f138bd2]145                jd->fd = jd->r_inpa = jd->w_inpa = -1;
146               
[4a5d885]147                /* For the first login with OAuth, we have to authenticate via the browser.
148                   For subsequent logins, exchange the refresh token for a valid access
149                   token (even though the last one maybe didn't expire yet). */
150                if( strncmp( acc->pass, "refresh_token=", 14 ) != 0 )
[f988ad3]151                {
[4a5d885]152                        sasl_oauth2_init( ic );
[f988ad3]153                        ic->flags |= OPT_SLOW_LOGIN;
154                }
[4a5d885]155                else
156                        sasl_oauth2_refresh( ic, acc->pass + 14 );
157        }
158        else
159                jabber_connect( ic );
160}
161
162/* Separate this from jabber_login() so we can do OAuth first if necessary.
163   Putting this in io.c would probably be more correct. */
164void jabber_connect( struct im_connection *ic )
165{
166        account_t *acc = ic->acc;
167        struct jabber_data *jd = ic->proto_data;
168        int i;
169        char *connect_to;
170        struct ns_srv_reply **srvl = NULL, *srv = NULL;
171       
[36e9f62]172        /* Figure out the hostname to connect to. */
[3b3cd693]173        if( acc->server && *acc->server )
[36e9f62]174                connect_to = acc->server;
[ffdf2e7]175        else if( ( srvl = srv_lookup( "xmpp-client", "tcp", jd->server ) ) ||
176                 ( srvl = srv_lookup( "jabber-client", "tcp", jd->server ) ) )
177        {
178                /* Find the lowest-priority one. These usually come
179                   back in random/shuffled order. Not looking at
180                   weights etc for now. */
181                srv = *srvl;
182                for( i = 1; srvl[i]; i ++ )
183                        if( srvl[i]->prio < srv->prio )
184                                srv = srvl[i];
185               
[36e9f62]186                connect_to = srv->name;
[ffdf2e7]187        }
[36e9f62]188        else
189                connect_to = jd->server;
190       
[84b045d]191        imcb_log( ic, "Connecting" );
[35f6677]192       
[7f69740]193        for( i = 0; jabber_port_list[i] > 0; i ++ )
194                if( set_getint( &acc->set, "port" ) == jabber_port_list[i] )
195                        break;
196
197        if( jabber_port_list[i] == 0 )
[0f4c1bb5]198        {
[7f69740]199                imcb_log( ic, "Illegal port number" );
[c2fb3809]200                imc_logout( ic, FALSE );
[0f4c1bb5]201                return;
202        }
203       
[36e9f62]204        /* For non-SSL connections we can try to use the port # from the SRV
205           reply, but let's not do that when using SSL, SSL usually runs on
206           non-standard ports... */
[21167d2]207        if( set_getbool( &acc->set, "ssl" ) )
208        {
[0da65d5]209                jd->ssl = ssl_connect( connect_to, set_getint( &acc->set, "port" ), jabber_connected_ssl, ic );
[3b3cd693]210                jd->fd = jd->ssl ? ssl_getfd( jd->ssl ) : -1;
[21167d2]211        }
212        else
213        {
[0da65d5]214                jd->fd = proxy_connect( connect_to, srv ? srv->port : set_getint( &acc->set, "port" ), jabber_connected_plain, ic );
[21167d2]215        }
[ffdf2e7]216        srv_free( srvl );
[35f6677]217       
218        if( jd->fd == -1 )
219        {
[84b045d]220                imcb_error( ic, "Could not connect to server" );
[c2fb3809]221                imc_logout( ic, TRUE );
[fb4ebcc5]222               
223                return;
[35f6677]224        }
[a6df0b5]225       
226        if( set_getbool( &acc->set, "xmlconsole" ) )
227        {
228                jd->flags |= JFLAG_XMLCONSOLE;
229                /* Shouldn't really do this at this stage already, maybe. But
230                   I think this shouldn't break anything. */
231                imcb_add_buddy( ic, JABBER_XMLCONSOLE_HANDLE, NULL );
232        }
[608f8cf]233       
234        jabber_generate_id_hash( jd );
235}
236
[89d736a]237/* This generates an unfinished md5_state_t variable. Every time we generate
238   an ID, we finish the state by adding a sequence number and take the hash. */
[608f8cf]239static void jabber_generate_id_hash( struct jabber_data *jd )
240{
[89d736a]241        md5_byte_t binbuf[4];
[608f8cf]242        char *s;
243       
[89d736a]244        md5_init( &jd->cached_id_prefix );
245        md5_append( &jd->cached_id_prefix, (unsigned char *) jd->username, strlen( jd->username ) );
246        md5_append( &jd->cached_id_prefix, (unsigned char *) jd->server, strlen( jd->server ) );
[608f8cf]247        s = set_getstr( &jd->ic->acc->set, "resource" );
[89d736a]248        md5_append( &jd->cached_id_prefix, (unsigned char *) s, strlen( s ) );
249        random_bytes( binbuf, 4 );
250        md5_append( &jd->cached_id_prefix, binbuf, 4 );
[f06894d]251}
252
[0da65d5]253static void jabber_logout( struct im_connection *ic )
[f06894d]254{
[0da65d5]255        struct jabber_data *jd = ic->proto_data;
[21167d2]256       
[4ac647d]257        while( jd->filetransfers )
[17a6ee9]258                imcb_file_canceled( ic, ( ( struct jabber_transfer *) jd->filetransfers->data )->ft, "Logging out" );
[4ac647d]259
260        while( jd->streamhosts )
261        {
262                jabber_streamhost_t *sh = jd->streamhosts->data;
263                jd->streamhosts = g_slist_remove( jd->streamhosts, sh );
264                g_free( sh->jid );
265                g_free( sh->host );
266                g_free( sh );
267        }
268
[de03374]269        if( jd->fd >= 0 )
270                jabber_end_stream( ic );
[4a0614e]271       
[c377417]272        while( ic->groupchats )
[aea8b68]273                jabber_chat_free( ic->groupchats->data );
[c377417]274       
[21167d2]275        if( jd->r_inpa >= 0 )
276                b_event_remove( jd->r_inpa );
277        if( jd->w_inpa >= 0 )
278                b_event_remove( jd->w_inpa );
279       
280        if( jd->ssl )
281                ssl_disconnect( jd->ssl );
282        if( jd->fd >= 0 )
283                closesocket( jd->fd );
284       
[fe7a554]285        if( jd->tx_len )
286                g_free( jd->txq );
287       
[de03374]288        if( jd->node_cache )
289                g_hash_table_destroy( jd->node_cache );
[038d17f]290       
[04a927c]291        jabber_buddy_remove_all( ic );
292       
[70f6aab8]293        xt_free( jd->xt );
294       
[f138bd2]295        g_free( jd->oauth2_access_token );
[5e202b0]296        g_free( jd->away_message );
[21167d2]297        g_free( jd->username );
298        g_free( jd );
[b5c8a34]299       
300        jabber_connections = g_slist_remove( jabber_connections, ic );
[f06894d]301}
302
[f6c963b]303static int jabber_buddy_msg( struct im_connection *ic, char *who, char *message, int flags )
[f06894d]304{
[0da65d5]305        struct jabber_data *jd = ic->proto_data;
[a21a8ac]306        struct jabber_buddy *bud;
[cc2cb2d]307        struct xt_node *node;
[b9f8b87]308        char *s;
[4a0614e]309        int st;
310       
[bb95d43]311        if( g_strcasecmp( who, JABBER_XMLCONSOLE_HANDLE ) == 0 )
312                return jabber_write( ic, message, strlen( message ) );
313       
[4a5d885]314        if( g_strcasecmp( who, "jabber_oauth" ) == 0 )
315        {
316                if( sasl_oauth2_get_refresh_token( ic, message ) )
317                {
318                        return 1;
319                }
320                else
321                {
322                        imcb_error( ic, "OAuth failure" );
323                        imc_logout( ic, TRUE );
[911d97a]324                        return 0;
[4a5d885]325                }
326        }
327       
[5bd21df]328        if( ( s = strchr( who, '=' ) ) && jabber_chat_by_jid( ic, s + 1 ) )
[b9f8b87]329                bud = jabber_buddy_by_ext_jid( ic, who, 0 );
330        else
[76c85b4c]331                bud = jabber_buddy_by_jid( ic, who, GET_BUDDY_BARE_OK );
[a214954]332       
[4a0614e]333        node = xt_new_node( "body", message, NULL );
[788a1af]334        node = jabber_make_packet( "message", "chat", bud ? bud->full_jid : who, node );
[a21a8ac]335       
[0d3f30f]336        if( bud && ( jd->flags & JFLAG_WANT_TYPING ) &&
[788a1af]337            ( ( bud->flags & JBFLAG_DOES_XEP85 ) ||
338             !( bud->flags & JBFLAG_PROBED_XEP85 ) ) )
[a21a8ac]339        {
340                struct xt_node *act;
341               
342                /* If the user likes typing notification and if we don't know
[788a1af]343                   (and didn't probe before) if this resource supports XEP85,
[abbd8ed]344                   include a probe in this packet now. Also, if we know this
345                   buddy does support XEP85, we have to send this <active/>
346                   tag to tell that the user stopped typing (well, that's what
347                   we guess when s/he pressed Enter...). */
[a21a8ac]348                act = xt_new_node( "active", NULL, NULL );
[47d3ac4]349                xt_add_attr( act, "xmlns", XMLNS_CHATSTATES );
[a21a8ac]350                xt_add_child( node, act );
351               
352                /* Just make sure we do this only once. */
[788a1af]353                bud->flags |= JBFLAG_PROBED_XEP85;
[a21a8ac]354        }
355       
[0da65d5]356        st = jabber_write_packet( ic, node );
[4a0614e]357        xt_free_node( node );
358       
359        return st;
[f06894d]360}
361
[0da65d5]362static GList *jabber_away_states( struct im_connection *ic )
[dd788bb]363{
[5e202b0]364        static GList *l = NULL;
365        int i;
[dd788bb]366       
[5e202b0]367        if( l == NULL )
368                for( i = 0; jabber_away_state_list[i].full_name; i ++ )
369                        l = g_list_append( l, (void*) jabber_away_state_list[i].full_name );
[dd788bb]370       
[5e202b0]371        return l;
[dd788bb]372}
373
[0da65d5]374static void jabber_get_info( struct im_connection *ic, char *who )
[038d17f]375{
[6a1128d]376        struct jabber_buddy *bud;
[038d17f]377       
[76c85b4c]378        bud = jabber_buddy_by_jid( ic, who, GET_BUDDY_FIRST );
[7e83adca]379       
[6a1128d]380        while( bud )
381        {
[63770b4]382                imcb_log( ic, "Buddy %s (%d) information:", bud->full_jid, bud->priority );
383                if( bud->away_state )
384                        imcb_log( ic, "Away state: %s", bud->away_state->full_name );
[daae10f]385                imcb_log( ic, "Status message: %s", bud->away_message ? bud->away_message : "(none)" );
[63770b4]386               
[6a1128d]387                bud = bud->next;
388        }
[1991be6]389       
[0da65d5]390        jabber_get_vcard( ic, bud ? bud->full_jid : who );
[038d17f]391}
392
[0da65d5]393static void jabber_set_away( struct im_connection *ic, char *state_txt, char *message )
[dd788bb]394{
[0da65d5]395        struct jabber_data *jd = ic->proto_data;
[5e202b0]396       
[840bba8]397        /* state_txt == NULL -> Not away.
398           Unknown state -> fall back to the first defined away state. */
[daae10f]399        if( state_txt == NULL )
400                jd->away_state = NULL;
401        else if( ( jd->away_state = jabber_away_state_by_name( state_txt ) ) == NULL )
402                jd->away_state = jabber_away_state_list;
[840bba8]403       
[5e202b0]404        g_free( jd->away_message );
405        jd->away_message = ( message && *message ) ? g_strdup( message ) : NULL;
406       
[0da65d5]407        presence_send_update( ic );
[deff040]408}
409
[0da65d5]410static void jabber_add_buddy( struct im_connection *ic, char *who, char *group )
[cfbb3a6]411{
[bb95d43]412        struct jabber_data *jd = ic->proto_data;
413       
414        if( g_strcasecmp( who, JABBER_XMLCONSOLE_HANDLE ) == 0 )
415        {
416                jd->flags |= JFLAG_XMLCONSOLE;
417                imcb_add_buddy( ic, JABBER_XMLCONSOLE_HANDLE, NULL );
418                return;
419        }
420       
[46d215d]421        if( jabber_add_to_roster( ic, who, NULL, group ) )
[0da65d5]422                presence_send_request( ic, who, "subscribe" );
[cfbb3a6]423}
424
[0da65d5]425static void jabber_remove_buddy( struct im_connection *ic, char *who, char *group )
[cfbb3a6]426{
[bb95d43]427        struct jabber_data *jd = ic->proto_data;
428       
429        if( g_strcasecmp( who, JABBER_XMLCONSOLE_HANDLE ) == 0 )
430        {
431                jd->flags &= ~JFLAG_XMLCONSOLE;
[a3d5766]432                /* Not necessary for now. And for now the code isn't too
433                   happy if the buddy is completely gone right after calling
434                   this function already.
[998b103]435                imcb_remove_buddy( ic, JABBER_XMLCONSOLE_HANDLE, NULL );
[a3d5766]436                */
[bb95d43]437                return;
438        }
439       
[788a1af]440        /* We should always do this part. Clean up our administration a little bit. */
[0da65d5]441        jabber_buddy_remove_bare( ic, who );
[788a1af]442       
[0da65d5]443        if( jabber_remove_from_roster( ic, who ) )
444                presence_send_request( ic, who, "unsubscribe" );
[cfbb3a6]445}
446
[03f3828]447static struct groupchat *jabber_chat_join_( struct im_connection *ic, const char *room, const char *nick, const char *password, set_t **sets )
[e35d1a1]448{
449        if( strchr( room, '@' ) == NULL )
450                imcb_error( ic, "Invalid room name: %s", room );
[5bd21df]451        else if( jabber_chat_by_jid( ic, room ) )
[e35d1a1]452                imcb_error( ic, "Already present in chat `%s'", room );
453        else
[6d544a1]454                return jabber_chat_join( ic, room, nick, set_getstr( sets, "password" ) );
[e35d1a1]455       
456        return NULL;
457}
458
[43671b9]459static void jabber_chat_msg_( struct groupchat *c, char *message, int flags )
460{
461        if( c && message )
462                jabber_chat_msg( c, message, flags );
463}
464
[ef5c185]465static void jabber_chat_topic_( struct groupchat *c, char *topic )
466{
467        if( c && topic )
468                jabber_chat_topic( c, topic );
469}
470
[e35d1a1]471static void jabber_chat_leave_( struct groupchat *c )
472{
473        if( c )
474                jabber_chat_leave( c, NULL );
475}
476
[c058ff9]477static void jabber_chat_invite_( struct groupchat *c, char *who, char *msg )
478{
479        struct jabber_chat *jc = c->data;
480        gchar *msg_alt = NULL;
481
482        if( msg == NULL )
483                msg_alt = g_strdup_printf( "%s invited you to %s", c->ic->acc->user, jc->name );
484       
485        if( c && who )
486                jabber_chat_invite( c, who, msg ? msg : msg_alt );
487       
488        g_free( msg_alt );
489}
490
[0da65d5]491static void jabber_keepalive( struct im_connection *ic )
[deff040]492{
493        /* Just any whitespace character is enough as a keepalive for XMPP sessions. */
[38ff846]494        if( !jabber_write( ic, "\n", 1 ) )
495                return;
[a214954]496       
[038d17f]497        /* This runs the garbage collection every minute, which means every packet
498           is in the cache for about a minute (which should be enough AFAIK). */
[0da65d5]499        jabber_cache_clean( ic );
[dd788bb]500}
501
[0da65d5]502static int jabber_send_typing( struct im_connection *ic, char *who, int typing )
[a21a8ac]503{
[0da65d5]504        struct jabber_data *jd = ic->proto_data;
[a21a8ac]505        struct jabber_buddy *bud;
506       
507        /* Enable typing notification related code from now. */
508        jd->flags |= JFLAG_WANT_TYPING;
509       
[0da65d5]510        if( ( bud = jabber_buddy_by_jid( ic, who, 0 ) ) == NULL )
[788a1af]511        {
512                /* Sending typing notifications to unknown buddies is
513                   unsupported for now. Shouldn't be a problem, I think. */
514                return 0;
515        }
516       
517        if( bud->flags & JBFLAG_DOES_XEP85 )
[a21a8ac]518        {
519                /* We're only allowed to send this stuff if we know the other
520                   side supports it. */
521               
522                struct xt_node *node;
523                char *type;
524                int st;
525               
[df1fb67]526                if( typing & OPT_TYPING )
[a21a8ac]527                        type = "composing";
[df1fb67]528                else if( typing & OPT_THINKING )
529                        type = "paused";
530                else
531                        type = "active";
[a21a8ac]532               
533                node = xt_new_node( type, NULL, NULL );
[47d3ac4]534                xt_add_attr( node, "xmlns", XMLNS_CHATSTATES );
[a21a8ac]535                node = jabber_make_packet( "message", "chat", bud->full_jid, node );
536               
[0da65d5]537                st = jabber_write_packet( ic, node );
[a21a8ac]538                xt_free_node( node );
539               
540                return st;
541        }
542       
543        return 1;
544}
545
[6d544a1]546void jabber_chat_add_settings( account_t *acc, set_t **head )
547{
548        /* Meh. Stupid room passwords. Not trying to obfuscate/hide
549           them from the user for now. */
550        set_add( head, "password", NULL, NULL, NULL );
551}
552
553void jabber_chat_free_settings( account_t *acc, set_t **head )
554{
555        set_del( head, "password" );
556}
557
[d88c92a]558GList *jabber_buddy_action_list( bee_user_t *bu )
559{
560        static GList *ret = NULL;
561       
562        if( ret == NULL )
563        {
[a97a336]564                static const struct buddy_action ba[2] = {
[d88c92a]565                        { "VERSION", "Get client (version) information" },
566                };
567               
[a97a336]568                ret = g_list_prepend( ret, (void*) ba + 0 );
[d88c92a]569        }
570       
571        return ret;
572}
573
574void *jabber_buddy_action( struct bee_user *bu, const char *action, char * const args[], void *data )
575{
576        if( g_strcasecmp( action, "VERSION" ) == 0 )
577        {
578                struct jabber_buddy *bud;
579               
580                if( ( bud = jabber_buddy_by_ext_jid( bu->ic, bu->handle, 0 ) ) == NULL )
581                        bud = jabber_buddy_by_jid( bu->ic, bu->handle, GET_BUDDY_FIRST );
582                for( ; bud; bud = bud->next )
583                        jabber_iq_version_send( bu->ic, bud, data );
584        }
585       
586        return NULL;
587}
588
[0da65d5]589void jabber_initmodule()
[f06894d]590{
[deff040]591        struct prpl *ret = g_new0( struct prpl, 1 );
[f06894d]592       
593        ret->name = "jabber";
[6d544a1]594        ret->mms = 0;                        /* no limit */
[f06894d]595        ret->login = jabber_login;
[0da65d5]596        ret->init = jabber_init;
597        ret->logout = jabber_logout;
[f6c963b]598        ret->buddy_msg = jabber_buddy_msg;
[dd788bb]599        ret->away_states = jabber_away_states;
600        ret->set_away = jabber_set_away;
[f06894d]601//      ret->set_info = jabber_set_info;
[038d17f]602        ret->get_info = jabber_get_info;
[cfbb3a6]603        ret->add_buddy = jabber_add_buddy;
604        ret->remove_buddy = jabber_remove_buddy;
[43671b9]605        ret->chat_msg = jabber_chat_msg_;
[ef5c185]606        ret->chat_topic = jabber_chat_topic_;
[c058ff9]607        ret->chat_invite = jabber_chat_invite_;
[e35d1a1]608        ret->chat_leave = jabber_chat_leave_;
609        ret->chat_join = jabber_chat_join_;
[6d544a1]610        ret->chat_add_settings = jabber_chat_add_settings;
611        ret->chat_free_settings = jabber_chat_free_settings;
[deff040]612        ret->keepalive = jabber_keepalive;
[a21a8ac]613        ret->send_typing = jabber_send_typing;
[f06894d]614        ret->handle_cmp = g_strcasecmp;
[2ff2076]615        ret->transfer_request = jabber_si_transfer_request;
[d88c92a]616        ret->buddy_action_list = jabber_buddy_action_list;
617        ret->buddy_action = jabber_buddy_action;
[f06894d]618
[deff040]619        register_protocol( ret );
[f06894d]620}
Note: See TracBrowser for help on using the repository browser.