Changeset eb6df6a


Ignore:
Timestamp:
2010-07-11T17:21:21Z (9 years ago)
Author:
Sven Moritz Hallberg <pesco@…>
Branches:
master
Children:
be999a5
Parents:
3759849 (diff), 00540d4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge with upstraem bitlbee 1.2.8

Files:
13 edited

Legend:

Unmodified
Added
Removed
  • bitlbee.h

    r3759849 reb6df6a  
    3838
    3939#define PACKAGE "BitlBee"
    40 #define BITLBEE_VERSION "1.2.7"
     40#define BITLBEE_VERSION "1.2.8"
    4141#define VERSION BITLBEE_VERSION
    4242#define BITLBEE_VER(a,b,c) (((a) << 16) + ((b) << 8) + (c))
    43 #define BITLBEE_VERSION_CODE BITLBEE_VER(1, 2, 7)
     43#define BITLBEE_VERSION_CODE BITLBEE_VER(1, 2, 8)
    4444
    4545#define MAX_STRING 511
  • doc/CHANGES

    r3759849 reb6df6a  
    33
    44http://bugs.bitlbee.org/bitlbee/timeline?daysback=90&changeset=on
     5
     6Version 1.2.8:
     7- Now always using the AIM-style authentication method for OSCAR connections,
     8  even when connecting to ICQ. This solves login issues some people were
     9  having. (If you have problems, try changing the old_icq_auth setting.)
     10- Twitter:
     11  * Allow changing the Twitter API base URL so the module can also be used
     12    for identi.ca or any other compatible network.
     13  * Fetch the full list of Twitter contacts instead of slowly adding all
     14    contacts as they post a message.
     15  * Fixed message length counting.
     16  * Allow following/unfollowing people using the usual add/remove commands.
     17  * Better error reporting.
     18- Added a user_agent setting to the Jabber module to get around artificial
     19  client restrictions.
     20- Allow nick changes (although only before register/identify).
     21- Some more minor bugfixes/etc.
     22
     23Finished 4 Jul 2010
    524
    625Version 1.2.7:
  • doc/user-guide/commands.xml

    r3759849 reb6df6a  
    633633        </bitlbee-setting>
    634634
     635        <bitlbee-setting name="base_url" type="string" scope="account">
     636                <default>http://twitter.com</default>
     637
     638                <description>
     639                        <para>
     640                                There are more services that understand the Twitter API than just Twitter.com. BitlBee can connect to all Twitter API implementations.
     641                        </para>
     642
     643                        <para>
     644                                For example, set this setting to <emphasis>http://identi.ca/api</emphasis> to use Identi.ca.
     645                        </para>
     646
     647                        <para>
     648                                Keep two things in mind: When not using Twitter, you <emphasis>must</emphasis> also disable the <emphasis>oauth</emphasis> setting as it currently only works with Twitter. If you're still having issues, make sure there is <emphasis>no</emphasis> slash at the end of the URL you enter here.
     649                        </para>
     650                </description>
     651        </bitlbee-setting>
     652
    635653        <bitlbee-setting name="buddy_sendbuffer" type="boolean" scope="global">
    636654                <default>false</default>
     
    12311249        </bitlbee-setting>
    12321250
     1251        <bitlbee-setting name="user_agent" type="string" scope="account">
     1252                <default>BitlBee</default>
     1253
     1254                <description>
     1255                        <para>
     1256                                Some Jabber servers are configured to only allow a few (or even just one) kinds of XMPP clients to connect to them.
     1257                        </para>
     1258                       
     1259                        <para>
     1260                                You can change this setting to make BitlBee present itself as a different client, so that you can still connect to these servers.
     1261                        </para>
     1262                </description>
     1263        </bitlbee-setting>
     1264
    12331265        <bitlbee-setting name="voice_buddies" type="string" scope="global">
    12341266                <default>notaway</default>
     
    12441276                        </para>
    12451277                </description>
    1246 
    12471278        </bitlbee-setting>
    12481279
  • protocols/jabber/iq.c

    r3759849 reb6df6a  
    6565                if( strcmp( s, XMLNS_VERSION ) == 0 )
    6666                {
    67                         xt_add_child( reply, xt_new_node( "name", "BitlBee", NULL ) );
     67                        xt_add_child( reply, xt_new_node( "name", set_getstr( &ic->acc->set, "user_agent" ), NULL ) );
    6868                        xt_add_child( reply, xt_new_node( "version", BITLBEE_VERSION, NULL ) );
    6969                        xt_add_child( reply, xt_new_node( "os", ARCH, NULL ) );
     
    105105                        xt_add_attr( c, "category", "client" );
    106106                        xt_add_attr( c, "type", "pc" );
    107                         xt_add_attr( c, "name", "BitlBee" );
     107                        xt_add_attr( c, "name", set_getstr( &ic->acc->set, "user_agent" ) );
    108108                        xt_add_child( reply, c );
    109109                       
  • protocols/jabber/jabber.c

    r3759849 reb6df6a  
    7979        s = set_add( &acc->set, "tls", "try", set_eval_tls, acc );
    8080        s->flags |= ACC_SET_OFFLINE_ONLY;
     81       
     82        s = set_add( &acc->set, "user_agent", "BitlBee", NULL, acc );
    8183       
    8284        s = set_add( &acc->set, "xmlconsole", "false", set_eval_bool, acc );
     
    286288                g_hash_table_destroy( jd->node_cache );
    287289       
     290        jabber_buddy_remove_all( ic );
     291       
    288292        xt_free( jd->xt );
    289293       
     
    470474{
    471475        /* Just any whitespace character is enough as a keepalive for XMPP sessions. */
    472         jabber_write( ic, "\n", 1 );
     476        if( !jabber_write( ic, "\n", 1 ) )
     477                return;
    473478       
    474479        /* This runs the garbage collection every minute, which means every packet
  • protocols/jabber/jabber.h

    r3759849 reb6df6a  
    230230int jabber_buddy_remove( struct im_connection *ic, char *full_jid );
    231231int jabber_buddy_remove_bare( struct im_connection *ic, char *bare_jid );
     232void jabber_buddy_remove_all( struct im_connection *ic );
    232233time_t jabber_get_timestamp( struct xt_node *xt );
    233234struct jabber_error *jabber_error_parse( struct xt_node *node, char *xmlns );
  • protocols/jabber/jabber_util.c

    r3759849 reb6df6a  
    665665}
    666666
     667static gboolean jabber_buddy_remove_all_cb( gpointer key, gpointer value, gpointer data )
     668{
     669        struct jabber_buddy *bud, *next;
     670       
     671        bud = value;
     672        while( bud )
     673        {
     674                next = bud->next;
     675                g_free( bud->ext_jid );
     676                g_free( bud->full_jid );
     677                g_free( bud->away_message );
     678                g_free( bud );
     679                bud = next;
     680        }
     681       
     682        return TRUE;
     683}
     684
     685void jabber_buddy_remove_all( struct im_connection *ic )
     686{
     687        struct jabber_data *jd = ic->proto_data;
     688       
     689        g_hash_table_foreach_remove( jd->buddies, jabber_buddy_remove_all_cb, NULL );
     690        g_hash_table_destroy( jd->buddies );
     691}
     692
    667693time_t jabber_get_timestamp( struct xt_node *xt )
    668694{
  • protocols/jabber/message.c

    r3759849 reb6df6a  
    5555                        struct xt_node *inv, *reason;
    5656                       
    57                         if( strcmp( ns, XMLNS_MUC_USER ) == 0 &&
     57                        if( ns && strcmp( ns, XMLNS_MUC_USER ) == 0 &&
    5858                            ( inv = xt_find_node( c->children, "invite" ) ) )
    5959                        {
  • protocols/twitter/twitter.c

    r3759849 reb6df6a  
    4040                return 0;
    4141
    42         // If the user uses multiple private message windows we need to get the
    43         // users buddies.
    44         if (g_strcasecmp(set_getstr(&ic->acc->set, "mode"), "many") == 0)
    45                 twitter_get_statuses_friends(ic, -1);
    46 
    4742        // Do stuff..
    4843        twitter_get_home_timeline(ic, -1);
     
    5651        struct twitter_data *td = ic->proto_data;
    5752       
    58         imcb_log( ic, "Connecting to Twitter" );
     53        imcb_log( ic, "Getting initial statuses" );
    5954
    6055        // Run this once. After this queue the main loop function.
     
    6661}
    6762
     63static void twitter_oauth_start( struct im_connection *ic );
     64
     65void twitter_login_finish( struct im_connection *ic )
     66{
     67        struct twitter_data *td = ic->proto_data;
     68       
     69        if( set_getbool( &ic->acc->set, "oauth" ) && !td->oauth_info )
     70                twitter_oauth_start( ic );
     71        else if( g_strcasecmp( set_getstr( &ic->acc->set, "mode" ), "one" ) != 0 &&
     72                 !( td->flags & TWITTER_HAVE_FRIENDS ) )
     73        {
     74                imcb_log( ic, "Getting contact list" );
     75                twitter_get_statuses_friends( ic, -1 );
     76        }
     77        else
     78                twitter_main_loop_start( ic );
     79}
    6880
    6981static const struct oauth_service twitter_oauth =
     
    128140                ic->acc->pass = oauth_to_string( info );
    129141               
    130                 twitter_main_loop_start( ic );
     142                twitter_login_finish( ic );
    131143        }
    132144       
     
    211223        imcb_buddy_status( ic, name, OPT_LOGGED_IN, NULL, NULL );
    212224       
    213         if( td->oauth_info || !set_getbool( &acc->set, "oauth" ) )
    214                 twitter_main_loop_start( ic );
    215         else
    216                 twitter_oauth_start( ic );
     225        imcb_log( ic, "Connecting" );
     226       
     227        twitter_login_finish( ic );
    217228}
    218229
     
    236247        {
    237248                oauth_info_free( td->oauth_info );
     249                g_free( td->url_host );
     250                g_free( td->url_path );
    238251                g_free( td->pass );
    239252                g_free( td );
     
    256269                    td->oauth_info && td->oauth_info->token == NULL )
    257270                {
    258                         if( !oauth_access_token( message, td->oauth_info ) )
     271                        char pin[strlen(message)+1], *s;
     272                       
     273                        strcpy( pin, message );
     274                        for( s = pin + sizeof( pin ) - 2; s > pin && isspace( *s ); s -- )
     275                                *s = '\0';
     276                        for( s = pin; *s && isspace( *s ); s ++ ) {}
     277                       
     278                        if( !oauth_access_token( s, td->oauth_info ) )
    259279                        {
    260280                                imcb_error( ic, "OAuth error: %s", "Failed to send access token request" );
  • protocols/twitter/twitter.h

    r3759849 reb6df6a  
    3333#endif
    3434
     35typedef enum
     36{
     37        TWITTER_HAVE_FRIENDS = 1,
     38} twitter_flags_t;
     39
    3540struct twitter_data
    3641{
     
    4247        struct groupchat *home_timeline_gc;
    4348        gint http_fails;
     49        twitter_flags_t flags;
    4450       
    4551        gboolean url_ssl;
     
    5662GSList *twitter_connections;
    5763
     64void twitter_login_finish( struct im_connection *ic );
     65
    5866#endif //_TWITTER_H
  • protocols/twitter/twitter_lib.c

    r3759849 reb6df6a  
    4242struct twitter_xml_list {
    4343        int type;
    44         int next_cursor;
     44        gint64 next_cursor;
    4545        GSList *list;
    4646        gpointer data;
     
    5858        guint64 id;
    5959};
     60
     61static void twitter_groupchat_init(struct im_connection *ic);
    6062
    6163/**
     
    153155 * Get the friends ids.
    154156 */
    155 void twitter_get_friends_ids(struct im_connection *ic, int next_cursor)
     157void twitter_get_friends_ids(struct im_connection *ic, gint64 next_cursor)
    156158{
    157159        // Primitive, but hey! It works...     
    158160        char* args[2];
    159161        args[0] = "cursor";
    160         args[1] = g_strdup_printf ("%d", next_cursor);
     162        args[1] = g_strdup_printf ("%lld", (long long) next_cursor);
    161163        twitter_http(ic, TWITTER_FRIENDS_IDS_URL, twitter_http_get_friends_ids, ic, 0, args, 2);
    162164
     
    169171static xt_status twitter_xt_next_cursor( struct xt_node *node, struct twitter_xml_list *txl )
    170172{
    171         // Do something with the cursor.
    172         txl->next_cursor = node->text != NULL ? atoi(node->text) : -1;
     173        char *end = NULL;
     174       
     175        if( node->text )
     176                txl->next_cursor = g_ascii_strtoll( node->text, &end, 10 );
     177        if( end == NULL )
     178                txl->next_cursor = -1;
    173179
    174180        return XT_HANDLED;
     
    413419 * Get the timeline.
    414420 */
    415 void twitter_get_home_timeline(struct im_connection *ic, int next_cursor)
     421void twitter_get_home_timeline(struct im_connection *ic, gint64 next_cursor)
    416422{
    417423        struct twitter_data *td = ic->proto_data;
     
    419425        char* args[4];
    420426        args[0] = "cursor";
    421         args[1] = g_strdup_printf ("%d", next_cursor);
     427        args[1] = g_strdup_printf ("%lld", (long long) next_cursor);
    422428        if (td->home_timeline_id) {
    423429                args[2] = "since_id";
     
    431437                g_free(args[3]);
    432438        }
     439}
     440
     441static void twitter_groupchat_init(struct im_connection *ic)
     442{
     443        char *name_hint;
     444        struct groupchat *gc;
     445        struct twitter_data *td = ic->proto_data;
     446       
     447        td->home_timeline_gc = gc = imcb_chat_new( ic, "home/timeline" );
     448       
     449        name_hint = g_strdup_printf( "Twitter_%s", ic->acc->user );
     450        imcb_chat_name_hint( gc, name_hint );
     451        g_free( name_hint );
    433452}
    434453
     
    445464        // Create a new groupchat if it does not exsist.
    446465        if (!td->home_timeline_gc)
    447         {   
    448                 char *name_hint = g_strdup_printf( "Twitter_%s", ic->acc->user );
    449                 td->home_timeline_gc = gc = imcb_chat_new( ic, "home/timeline" );
    450                 imcb_chat_name_hint( gc, name_hint );
    451                 g_free( name_hint );
    452                 // Add the current user to the chat...
     466                twitter_groupchat_init(ic);
     467       
     468        gc = td->home_timeline_gc;
     469        if (!gc->joined)
    453470                imcb_chat_add_buddy( gc, ic->acc->user );
    454         }
    455         else
    456         {   
    457                 gc = td->home_timeline_gc;
    458         }
    459471
    460472        for ( l = list; l ; l = g_slist_next(l) )
     
    604616       
    605617        // Check if the HTTP request went well.
    606         if (req->status_code != 200) {
     618        if (req->status_code == 401)
     619        {
     620                imcb_error( ic, "Authentication failure" );
     621                imc_logout( ic, FALSE );
     622                return;
     623        } else if (req->status_code != 200) {
    607624                // It didn't go well, output the error and return.
    608                 if (++td->http_fails >= 5)
    609                         imcb_error(ic, "Could not retrieve " TWITTER_SHOW_FRIENDS_URL ": %s", twitter_parse_error(req));
    610                
     625                imcb_error(ic, "Could not retrieve " TWITTER_SHOW_FRIENDS_URL ": %s", twitter_parse_error(req));
     626                imc_logout( ic, TRUE );
    611627                return;
    612628        } else {
    613629                td->http_fails = 0;
    614630        }
     631       
     632        if( !td->home_timeline_gc &&
     633            g_strcasecmp( set_getstr( &ic->acc->set, "mode" ), "chat" ) == 0 )
     634                twitter_groupchat_init( ic );
    615635
    616636        txl = g_new0(struct twitter_xml_list, 1);
     
    634654        // if the next_cursor is set to something bigger then 0 there are more friends to gather.
    635655        if (txl->next_cursor > 0)
     656        {
    636657                twitter_get_statuses_friends(ic, txl->next_cursor);
    637 
     658        }
     659        else
     660        {
     661                td->flags |= TWITTER_HAVE_FRIENDS;
     662                twitter_login_finish(ic);
     663        }
     664       
    638665        // Free the structure.
    639666        txl_free(txl);
     
    644671 * Get the friends.
    645672 */
    646 void twitter_get_statuses_friends(struct im_connection *ic, int next_cursor)
     673void twitter_get_statuses_friends(struct im_connection *ic, gint64 next_cursor)
    647674{
    648675        char* args[2];
    649676        args[0] = "cursor";
    650         args[1] = g_strdup_printf ("%d", next_cursor);
     677        args[1] = g_strdup_printf ("%lld", (long long) next_cursor);
    651678
    652679        twitter_http(ic, TWITTER_SHOW_FRIENDS_URL, twitter_http_get_statuses_friends, ic, 0, args, 2);
  • protocols/twitter/twitter_lib.h

    r3759849 reb6df6a  
    7676#define TWITTER_BLOCKS_DESTROY_URL "/blocks/destroy/"
    7777
    78 void twitter_get_friends_ids(struct im_connection *ic, int next_cursor);
    79 void twitter_get_home_timeline(struct im_connection *ic, int next_cursor);
    80 void twitter_get_statuses_friends(struct im_connection *ic, int next_cursor);
     78void twitter_get_friends_ids(struct im_connection *ic, gint64 next_cursor);
     79void twitter_get_home_timeline(struct im_connection *ic, gint64 next_cursor);
     80void twitter_get_statuses_friends(struct im_connection *ic, gint64 next_cursor);
    8181
    8282void twitter_post_status(struct im_connection *ic, char *msg);
  • storage_xml.c

    r3759849 reb6df6a  
    6060        char *given_pass;
    6161        xml_pass_st pass_st;
     62        int unknown_tag;
    6263};
    6364
     
    8788        irc_t *irc = xd->irc;
    8889       
    89         if( g_strcasecmp( element_name, "user" ) == 0 )
     90        if( xd->unknown_tag > 0 )
     91        {
     92                xd->unknown_tag ++;
     93        }
     94        else if( g_strcasecmp( element_name, "user" ) == 0 )
    9095        {
    9196                char *nick = xml_attr( attr_names, attr_values, "nick" );
     
    225230        else
    226231        {
     232                xd->unknown_tag ++;
     233                irc_usermsg( irc, "Warning: Unknown XML tag found in configuration file (%s). "
     234                                  "This may happen when downgrading BitlBee versions. "
     235                                  "This tag will be skipped and the information will be lost "
     236                                  "once you save your settings.", element_name );
     237                /*
    227238                g_set_error( error, G_MARKUP_ERROR, G_MARKUP_ERROR_UNKNOWN_ELEMENT,
    228239                             "Unkown element: %s", element_name );
     240                */
    229241        }
    230242}
     
    234246        struct xml_parsedata *xd = data;
    235247       
    236         if( g_strcasecmp( element_name, "setting" ) == 0 && xd->current_setting )
     248        if( xd->unknown_tag > 0 )
     249        {
     250                xd->unknown_tag --;
     251        }
     252        else if( g_strcasecmp( element_name, "setting" ) == 0 && xd->current_setting )
    237253        {
    238254                g_free( xd->current_setting );
     
    404420                return STORAGE_ALREADY_EXISTS;
    405421       
    406         strcat( path, "~" );
    407         if( ( fd = open( path, O_WRONLY | O_CREAT | O_TRUNC, 0600 ) ) < 0 )
     422        strcat( path, ".XXXXXX" );
     423        if( ( fd = mkstemp( path ) ) < 0 )
    408424        {
    409425                irc_usermsg( irc, "Error while opening configuration file." );
     
    499515        close( fd );
    500516       
    501         path2 = g_strndup( path, strlen( path ) - 1 );
     517        path2 = g_strndup( path, strlen( path ) - 7 );
    502518        if( rename( path, path2 ) != 0 )
    503519        {
Note: See TracChangeset for help on using the changeset viewer.