Changes in / [ba3233c:7d53efb]


Ignore:
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • bitlbee.h

    rba3233c r7d53efb  
    3535
    3636#define PACKAGE "BitlBee"
    37 #define BITLBEE_VERSION "1.2.7"
     37#define BITLBEE_VERSION "1.2.6a"
    3838#define VERSION BITLBEE_VERSION
    3939#define BITLBEE_VER(a,b,c) (((a) << 16) + ((b) << 8) + (c))
    40 #define BITLBEE_VERSION_CODE BITLBEE_VER(1, 2, 7)
     40#define BITLBEE_VERSION_CODE BITLBEE_VER(1, 2, 6)
    4141
    4242#define MAX_STRING 511
  • debian/changelog

    rba3233c r7d53efb  
    1 bitlbee (1.2.7-1) unstable; urgency=high
    2 
    3   * New upstream version.
    4   * Fixes MSN Messenger login issues, so uploading at high priority.
    5 
    6  -- Wilmer van der Gaast <wilmer@gaast.net>  Sat, 15 May 2010 16:15:57 +0100
    7 
    81bitlbee (1.2.6a-1) unstable; urgency=low
    92
  • debian/control

    rba3233c r7d53efb  
    1515Description: An IRC to other chat networks gateway
    1616 This program can be used as an IRC server which forwards everything you
    17  say to people on other chat networks: Jabber, ICQ, AIM, MSN, Yahoo! and
    18  Twitter.
     17 say to people on other chat networks: Jabber, ICQ, AIM, MSN and Yahoo.
    1918
    2019Package: bitlbee-dev
     
    2322Description: An IRC to other chat networks gateway
    2423 This program can be used as an IRC server which forwards everything you
    25  say to people on other chat networks: Jabber, ICQ, AIM, MSN, Yahoo! and
    26  Twitter.
     24 say to people on other chat networks: Jabber, ICQ, AIM, MSN and Yahoo.
    2725 .
    2826 This package holds development stuff for compiling plug-ins.
  • debian/rules

    rba3233c r7d53efb  
    9999                find usr -type f -exec md5sum {} \; > DEBIAN/md5sums
    100100
    101 ifdef BITLBEE_FORCE_VERSION
    102101        dpkg-gencontrol -ldebian/changelog -isp -pbitlbee-dev -Pdebian/bitlbee-dev -v1:$(BITLBEE_VERSION)-0
    103 else
    104         dpkg-gencontrol -ldebian/changelog -isp -pbitlbee-dev -Pdebian/bitlbee-dev
    105 endif
    106102
    107103        dpkg --build debian/bitlbee-dev ..
  • doc/CHANGES

    rba3233c r7d53efb  
    33
    44http://bugs.bitlbee.org/bitlbee/timeline?daysback=90&changeset=on
    5 
    6 Version 1.2.7:
    7 - Fixed problems with MSN Messenger authentication. ("Could not parse
    8   Passport server response")
    9 - Fixed broken typing notifications when talking to GTalk contacts.
    10 - Fixed an issue with non-anonymous Jabber chatrooms polluting the nick
    11   namespace, sometimes generating odd warning messages.
    12 - Restored ability to start groupchats on ICQ.
    13 - Added show_offline setting that will also show offline contacts in the
    14   control channel.
    15 - OAuth support for Twitter: This means the module will keep working after
    16   June (this also changes "via API" under your tweets into "via BitlBee").
    17 
    18 Finished 15 May 2010
    195
    206Version 1.2.6a:
  • doc/bitlbee.8

    rba3233c r7d53efb  
    3939networks and acts as a gateway. Users can connect to the server
    4040with any normal IRC client and see their 'buddy list' in
    41 &bitlbee. It currently supports Oscar (AIM and ICQ),
    42 MSN, Jabber, Yahoo! and Twitter.
     41&bitlbee. BitlBee's protocol support is based on the gaim
     42protocol plugins. BitlBee currently supports Oscar (aim and icq),
     43MSN, Jabber and Yahoo.
    4344
    4445\fBbitlbee\fP should be called by
  • doc/user-guide/commands.xml

    rba3233c r7d53efb  
    620620
    621621        <bitlbee-setting name="ignore_auth_requests" type="boolean" scope="account">
    622                 <default>false</default>
     622                <default>true</default>
    623623
    624624                <description>
  • doc/user-guide/quickstart.xml

    rba3233c r7d53efb  
    33
    44<para>
    5 Welcome to BitlBee, your IRC gateway to ICQ, MSN, AOL, Jabber, Yahoo! and Twitter.
     5Welcome to BitlBee, your IRC gateway to ICQ, MSN, AOL, Jabber and Yahoo Instant Messaging Systems.
    66</para>
    77
     
    4343
    4444<para>
    45 Other available IM protocols are msn, oscar, yahoo and twitter. OSCAR is the protocol used by ICQ and AOL. For more information about the <emphasis>account add</emphasis> command, see <emphasis>help account add</emphasis>.
     45Other available IM protocols are msn, oscar, and yahoo. OSCAR is the protocol used by ICQ and AOL. For more information about the <emphasis>account add</emphasis> command, see <emphasis>help account add</emphasis>.
    4646</para>
    4747
  • irc_commands.c

    rba3233c r7d53efb  
    7373static void irc_cmd_nick( irc_t *irc, char **cmd )
    7474{
    75         if( irc->status & USTATUS_IDENTIFIED && irc->nick )
    76         {
    77                 irc_reply( irc, 438, "%s %s :You can only change your nick if you're not "
    78                            "logged in (i.e. pre-identify)", irc->nick, cmd[1] );
     75        if( irc->nick )
     76        {
     77                irc_reply( irc, 438, ":The hand of the deity is upon thee, thy nick may not change" );
    7978        }
    8079        /* This is not clean, but for now it'll have to be like this... */
    81         else if( ( nick_cmp( cmd[1], irc->mynick ) == 0 ) || ( nick_cmp( cmd[1], NS_NICK ) == 0 ) || ( user_find( irc, cmd[1] ) != NULL ) )
    82         {
    83                 irc_reply( irc, 433, "%s :This nick is already in use", cmd[1] );
     80        else if( ( nick_cmp( cmd[1], irc->mynick ) == 0 ) || ( nick_cmp( cmd[1], NS_NICK ) == 0 ) )
     81        {
     82                irc_reply( irc, 433, ":This nick is already in use" );
    8483        }
    8584        else if( !nick_ok( cmd[1] ) )
    8685        {
    8786                /* [SH] Invalid characters. */
    88                 irc_reply( irc, 432, "%s :This nick contains invalid characters", cmd[1] );
    89         }
    90         else if(irc->nick)
    91         {
    92                 if( user_find( irc, irc->nick ) )
    93                         user_rename(irc, irc->nick, cmd[1]);
    94 
    95                 irc_write( irc, ":%s!%s@%s NICK %s", irc->nick, irc->user, irc->host, cmd[1] );
    96                 g_free(irc->nick);
    97                 irc->nick = g_strdup( cmd[1] );
     87                irc_reply( irc, 432, ":This nick contains invalid characters" );
    9888        }
    9989        else
  • lib/misc.c

    rba3233c r7d53efb  
    154154{
    155155        char *start = in;
    156         char out[strlen(in)+1];
     156        char *out = g_malloc( strlen( in ) + 1 );
    157157        char *s = out, *cs;
    158158        int i, matched;
    159159       
    160         memset( out, 0, sizeof( out ) );
     160        memset( out, 0, strlen( in ) + 1 );
    161161       
    162162        while( *in )
     
    220220       
    221221        strcpy( start, out );
     222        g_free( out );
    222223}
    223224
  • lib/xmltree.c

    rba3233c r7d53efb  
    449449        while( node )
    450450        {
    451                 char *colon;
    452                
    453                 if( g_strcasecmp( node->name, name ) == 0 ||
    454                     ( ( colon = strchr( node->name, ':' ) ) &&
    455                       g_strcasecmp( colon + 1, name ) == 0 ) )
     451                if( g_strcasecmp( node->name, name ) == 0 )
    456452                        break;
    457453               
     
    465461{
    466462        int i;
    467         char *colon;
    468463       
    469464        if( !node )
     
    473468                if( g_strcasecmp( node->attr[i].key, key ) == 0 )
    474469                        break;
    475        
    476         /* This is an awful hack that only takes care of namespace prefixes
    477            inside a tag. Since IMHO excessive namespace usage in XMPP is
    478            massive overkill anyway (this code exists for almost four years
    479            now and never really missed it): Meh. */
    480         if( !node->attr[i].key && strcmp( key, "xmlns" ) == 0 &&
    481             ( colon = strchr( node->name, ':' ) ) )
    482         {
    483                 *colon = '\0';
    484                 for( i = 0; node->attr[i].key; i ++ )
    485                         if( strncmp( node->attr[i].key, "xmlns:", 6 ) == 0 &&
    486                             strcmp( node->attr[i].key + 6, node->name ) == 0 )
    487                                 break;
    488                 *colon = ':';
    489         }
    490470       
    491471        return node->attr[i].value;
  • protocols/jabber/conference.c

    rba3233c r7d53efb  
    272272                }
    273273               
    274                 if( bud != jc->me && bud->flags & JBFLAG_IS_ANONYMOUS )
    275                 {
    276                         /* If JIDs are anonymized, add them to the local
    277                            list for the duration of this chat. */
     274                if( bud != jc->me )
     275                {
    278276                        imcb_add_buddy( ic, bud->ext_jid, NULL );
    279277                        imcb_buddy_nick_hint( ic, bud->ext_jid, bud->resource );
  • protocols/jabber/iq.c

    rba3233c r7d53efb  
    127127                    !( s = xt_find_attr( c, "xmlns" ) ) )
    128128                {
     129                        imcb_log( ic, "Warning: Received incomplete IQ-%s packet", type );
    129130                        return XT_HANDLED;
    130131                }
  • protocols/msn/passport.c

    rba3233c r7d53efb  
    145145        char *s;
    146146       
    147         if( ( s = xt_find_attr( node, "Id" ) ) &&
    148             ( strncmp( s, "Compact", 7 ) == 0 ||
    149               strncmp( s, "PPToken", 7 ) == 0 ) )
     147        if( ( s = xt_find_attr( node, "Id" ) ) && strcmp( s, "PPToken1" ) == 0 )
    150148                mad->token = g_memdup( node->text, node->text_len + 1 );
    151149       
  • protocols/msn/sb.c

    rba3233c r7d53efb  
    328328        struct msn_data *md = ic->proto_data;
    329329       
    330         if( msn_handler( sb->handler ) != -1 )
    331                 return TRUE;
    332        
    333         if( sb->msgq != NULL )
     330        if( msn_handler( sb->handler ) == -1 )
    334331        {
    335332                time_t now = time( NULL );
    336                 char buf[1024];
    337333               
    338334                if( now - md->first_sb_failure > 600 )
     
    351347                                      "There might be problems delivering your messages." );
    352348               
    353                 if( md->msgq == NULL )
    354                 {
    355                         md->msgq = sb->msgq;
    356                 }
    357                 else
    358                 {
    359                         GSList *l;
    360                        
    361                         for( l = md->msgq; l->next; l = l->next );
    362                         l->next = sb->msgq;
    363                 }
    364                 sb->msgq = NULL;
    365                
    366                 debug( "Moved queued messages back to the main queue, "
    367                        "creating a new switchboard to retry." );
    368                 g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId );
    369                 if( !msn_write( ic, buf, strlen( buf ) ) )
    370                         return FALSE;
    371         }
    372        
    373         msn_sb_destroy( sb );
    374         return FALSE;
     349                if( sb->msgq != NULL )
     350                {
     351                        char buf[1024];
     352                       
     353                        if( md->msgq == NULL )
     354                        {
     355                                md->msgq = sb->msgq;
     356                        }
     357                        else
     358                        {
     359                                GSList *l;
     360                               
     361                                for( l = md->msgq; l->next; l = l->next );
     362                                l->next = sb->msgq;
     363                        }
     364                        sb->msgq = NULL;
     365                       
     366                        debug( "Moved queued messages back to the main queue, creating a new switchboard to retry." );
     367                        g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId );
     368                        if( !msn_write( ic, buf, strlen( buf ) ) )
     369                                return FALSE;
     370                }
     371               
     372                msn_sb_destroy( sb );
     373               
     374                return FALSE;
     375        }
     376        else
     377        {
     378                return TRUE;
     379        }
    375380}
    376381
  • protocols/oscar/oscar.c

    rba3233c r7d53efb  
    205205static int gaim_icbm_param_info  (aim_session_t *, aim_frame_t *, ...);
    206206static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...);
     207static int gaim_memrequest       (aim_session_t *, aim_frame_t *, ...);
    207208static int gaim_selfinfo         (aim_session_t *, aim_frame_t *, ...);
    208209static int gaim_offlinemsg       (aim_session_t *, aim_frame_t *, ...);
     
    569570        aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ERROR, gaim_parse_genericerr, 0);
    570571        aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BOS, AIM_CB_BOS_ERROR, gaim_parse_genericerr, 0);
     572        aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, 0x1f, gaim_memrequest, 0);
    571573        aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_SELFINFO, gaim_selfinfo, 0);
    572574        aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSG, gaim_offlinemsg, 0);
     
    602604}
    603605
     606struct pieceofcrap {
     607        struct im_connection *ic;
     608        unsigned long offset;
     609        unsigned long len;
     610        char *modname;
     611        int fd;
     612        aim_conn_t *conn;
     613        unsigned int inpa;
     614};
     615
     616static gboolean damn_you(gpointer data, gint source, b_input_condition c)
     617{
     618        struct pieceofcrap *pos = data;
     619        struct oscar_data *od = pos->ic->proto_data;
     620        char in = '\0';
     621        int x = 0;
     622        unsigned char m[17];
     623
     624        while (read(pos->fd, &in, 1) == 1) {
     625                if (in == '\n')
     626                        x++;
     627                else if (in != '\r')
     628                        x = 0;
     629                if (x == 2)
     630                        break;
     631                in = '\0';
     632        }
     633        if (in != '\n') {
     634                imcb_error(pos->ic, "Gaim was unable to get a valid hash for logging into AIM."
     635                                " You may be disconnected shortly.");
     636                b_event_remove(pos->inpa);
     637                closesocket(pos->fd);
     638                g_free(pos);
     639                return FALSE;
     640        }
     641        /* [WvG] Wheeeee! Who needs error checking anyway? ;-) */
     642        read(pos->fd, m, 16);
     643        m[16] = '\0';
     644        b_event_remove(pos->inpa);
     645        closesocket(pos->fd);
     646        aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH);
     647        g_free(pos);
     648       
     649        return FALSE;
     650}
     651
     652static gboolean straight_to_hell(gpointer data, gint source, b_input_condition cond) {
     653        struct pieceofcrap *pos = data;
     654        char buf[BUF_LONG];
     655
     656        if (source < 0) {
     657                imcb_error(pos->ic, "Gaim was unable to get a valid hash for logging into AIM."
     658                                " You may be disconnected shortly.");
     659                if (pos->modname)
     660                        g_free(pos->modname);
     661                g_free(pos);
     662                return FALSE;
     663        }
     664
     665        g_snprintf(buf, sizeof(buf), "GET " AIMHASHDATA
     666                        "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n",
     667                        pos->offset, pos->len, pos->modname ? pos->modname : "");
     668        write(pos->fd, buf, strlen(buf));
     669        if (pos->modname)
     670                g_free(pos->modname);
     671        pos->inpa = b_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos);
     672        return FALSE;
     673}
     674
    604675/* size of icbmui.ocm, the largest module in AIM 3.5 */
    605676#define AIM_MAX_FILE_SIZE 98304
     677
     678int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) {
     679        va_list ap;
     680        struct pieceofcrap *pos;
     681        guint32 offset, len;
     682        char *modname;
     683        int fd;
     684
     685        va_start(ap, fr);
     686        offset = (guint32)va_arg(ap, unsigned long);
     687        len = (guint32)va_arg(ap, unsigned long);
     688        modname = va_arg(ap, char *);
     689        va_end(ap);
     690
     691        if (len == 0) {
     692                aim_sendmemblock(sess, fr->conn, offset, len, NULL,
     693                                AIM_SENDMEMBLOCK_FLAG_ISREQUEST);
     694                return 1;
     695        }
     696        /* uncomment this when you're convinced it's right. remember, it's been wrong before.
     697        if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) {
     698                char *buf;
     699                int i = 8;
     700                if (modname)
     701                        i += strlen(modname);
     702                buf = g_malloc(i);
     703                i = 0;
     704                if (modname) {
     705                        memcpy(buf, modname, strlen(modname));
     706                        i += strlen(modname);
     707                }
     708                buf[i++] = offset & 0xff;
     709                buf[i++] = (offset >> 8) & 0xff;
     710                buf[i++] = (offset >> 16) & 0xff;
     711                buf[i++] = (offset >> 24) & 0xff;
     712                buf[i++] = len & 0xff;
     713                buf[i++] = (len >> 8) & 0xff;
     714                buf[i++] = (len >> 16) & 0xff;
     715                buf[i++] = (len >> 24) & 0xff;
     716                aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST);
     717                g_free(buf);
     718                return 1;
     719        }
     720        */
     721
     722        pos = g_new0(struct pieceofcrap, 1);
     723        pos->ic = sess->aux_data;
     724        pos->conn = fr->conn;
     725
     726        pos->offset = offset;
     727        pos->len = len;
     728        pos->modname = modname ? g_strdup(modname) : NULL;
     729
     730        fd = proxy_connect("gaim.sourceforge.net", 80, straight_to_hell, pos);
     731        if (fd < 0) {
     732                if (pos->modname)
     733                        g_free(pos->modname);
     734                g_free(pos);
     735                imcb_error(sess->aux_data, "Gaim was unable to get a valid hash for logging into AIM."
     736                                " You may be disconnected shortly.");
     737        }
     738        pos->fd = fd;
     739
     740        return 1;
     741}
    606742
    607743static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) {
     
    10301166                m = g_list_append(m, exch);
    10311167
    1032                 g_snprintf(txt, 1024, "Got an invitation to chatroom %s from %s: %s", name, userinfo->sn, args->msg);
     1168                g_snprintf( txt, 1024, "Got an invitation to chatroom %s from %s: %s", name, userinfo->sn, args->msg );
    10331169
    10341170                inv->ic = ic;
     
    10361172                inv->name = g_strdup(name);
    10371173               
    1038                 imcb_ask(ic, txt, inv, oscar_accept_chat, oscar_reject_chat);
     1174                imcb_ask( ic, txt, inv, oscar_accept_chat, oscar_reject_chat);
    10391175       
    10401176                if (name)
    10411177                        g_free(name);
    1042         } else if (args->reqclass & AIM_CAPS_ICQRTF) {
    1043                 // TODO: constify
    1044                 char text[strlen(args->info.rtfmsg.rtfmsg)+1];
    1045                 strncpy(text, args->info.rtfmsg.rtfmsg, sizeof(text));
    1046                 imcb_buddy_msg(ic, normalize(userinfo->sn), text, 0, 0);
    10471178        }
    10481179
     
    25202651        char * chatname;
    25212652       
    2522         chatname = g_strdup_printf("%s%s_%d", isdigit(*ic->acc->user) ? "icq_" : "",
    2523                                    ic->acc->user, chat_id++);
     2653        chatname = g_strdup_printf("%s%d", ic->acc->user, chat_id++);
    25242654 
    25252655        ret = oscar_chat_join(ic, chatname, NULL, NULL);
  • protocols/twitter/twitter.c

    rba3233c r7d53efb  
    2727#include "twitter_http.h"
    2828#include "twitter_lib.h"
    29 #include "url.h"
    3029
    3130/**
     
    7170        "http://api.twitter.com/oauth/request_token",
    7271        "http://api.twitter.com/oauth/access_token",
    73         "https://api.twitter.com/oauth/authorize",
     72        "http://api.twitter.com/oauth/authorize",
    7473        .consumer_key = "xsDNKJuNZYkZyMcu914uEA",
    7574        .consumer_secret = "FCxqcr0pXKzsF9ajmP57S3VQ8V6Drk4o2QYtqMcOszo",
     
    161160        set_t *s;
    162161       
    163         s = set_add( &acc->set, "base_url", TWITTER_API_URL, NULL, acc );
    164         s->flags |= ACC_SET_OFFLINE_ONLY;
    165        
    166162        s = set_add( &acc->set, "message_length", "140", set_eval_int, acc );
    167163       
     
    179175{
    180176        struct im_connection *ic = imcb_new( acc );
    181         struct twitter_data *td;
     177        struct twitter_data *td = g_new0( struct twitter_data, 1 );
    182178        char name[strlen(acc->user)+9];
    183         url_t url;
    184 
    185         if( !url_set( &url, set_getstr( &ic->acc->set, "base_url" ) ) ||
    186             ( url.proto != PROTO_HTTP && url.proto != PROTO_HTTPS ) )
    187         {
    188                 imcb_error( ic, "Incorrect API base URL: %s", set_getstr( &ic->acc->set, "base_url" ) );
    189                 imc_logout( ic, FALSE );
    190                 return;
    191         }
    192        
     179
    193180        twitter_connections = g_slist_append( twitter_connections, ic );
    194         td = g_new0( struct twitter_data, 1 );
    195181        ic->proto_data = td;
    196        
    197         td->url_ssl = url.proto == PROTO_HTTPS;
    198         td->url_port = url.port;
    199         td->url_host = g_strdup( url.host );
    200         if( strcmp( url.file, "/" ) != 0 )
    201                 td->url_path = g_strdup( url.file );
    202         else
    203                 td->url_path = g_strdup( "" );
     182        ic->flags |= OPT_DOES_HTML;
    204183       
    205184        td->user = acc->user;
    206         if( strstr( acc->pass, "oauth_token=" ) )
     185        if( !set_getbool( &acc->set, "oauth" ) )
     186                td->pass = g_strdup( acc->pass );
     187        else if( strstr( acc->pass, "oauth_token=" ) )
    207188                td->oauth_info = oauth_from_string( acc->pass, &twitter_oauth );
     189        td->home_timeline_id = 0;
    208190       
    209191        sprintf( name, "twitter_%s", acc->user );
     
    211193        imcb_buddy_status( ic, name, OPT_LOGGED_IN, NULL, NULL );
    212194       
    213         if( td->oauth_info || !set_getbool( &acc->set, "oauth" ) )
     195        if( td->pass || td->oauth_info )
    214196                twitter_main_loop_start( ic );
    215197        else
  • protocols/twitter/twitter.h

    rba3233c r7d53efb  
    4242        struct groupchat *home_timeline_gc;
    4343        gint http_fails;
    44        
    45         gboolean url_ssl;
    46         int url_port;
    47         char *url_host;
    48         char *url_path;
    4944};
    5045
  • protocols/twitter/twitter_http.c

    rba3233c r7d53efb  
    4141
    4242
    43 static char *twitter_url_append(char *url, char *key, char* value);
     43char *twitter_url_append(char *url, char *key, char* value);
    4444
    4545/**
     
    4747 * This is actually pretty generic function... Perhaps it should move to the lib/http_client.c
    4848 */
    49 void *twitter_http(struct im_connection *ic, char *url_string, http_input_function func, gpointer data, int is_post, char** arguments, int arguments_len)
     49void *twitter_http(char *url_string, http_input_function func, gpointer data, int is_post, char* user, char* pass, struct oauth_info* oi, char** arguments, int arguments_len)
    5050{
    51         struct twitter_data *td = ic->proto_data;
     51        url_t *url = g_new0( url_t, 1 );
    5252        char *tmp;
    53         GString *request = g_string_new("");
     53        char *request;
    5454        void *ret;
     55        char *userpass = NULL;
     56        char *userpass_base64;
    5557        char *url_arguments;
    5658
    57         url_arguments = g_strdup("");
     59        // Fill the url structure.
     60        if( !url_set( url, url_string ) )
     61        {
     62                g_free( url );
     63                return NULL;
     64        }
     65
     66        if( url->proto != PROTO_HTTP && url->proto != PROTO_HTTPS )
     67        {
     68                g_free( url );
     69                return NULL;
     70        }
     71
     72        // Concatenate user and pass
     73        if (user && pass) {
     74                userpass = g_strdup_printf("%s:%s", user, pass);
     75                userpass_base64 = base64_encode((unsigned char*)userpass, strlen(userpass));
     76        } else {
     77                userpass_base64 = NULL;
     78        }
     79
     80        url_arguments = g_malloc(1);
     81        url_arguments[0] = '\0';
    5882
    5983        // Construct the url arguments.
     
    6993        }
    7094
     95        // Do GET stuff...
     96        if (!is_post)
     97        {
     98                // Find the char-pointer of the end of the string.
     99                tmp = url->file + strlen(url->file);
     100                tmp[0] = '?';
     101                // append the url_arguments to the end of the url->file.
     102                // TODO GM: Check the length?
     103                g_stpcpy (tmp+1, url_arguments);
     104        }
     105
     106
    71107        // Make the request.
    72         g_string_printf(request, "%s %s%s%s%s HTTP/1.0\r\n"
    73                                  "Host: %s\r\n"
    74                                  "User-Agent: BitlBee " BITLBEE_VERSION " " ARCH "/" CPU "\r\n",
    75                                  is_post ? "POST" : "GET",
    76                                  td->url_path, url_string,
    77                                  is_post ? "" : "?", is_post ? "" : url_arguments,
    78                                  td->url_host);
     108        request = g_strdup_printf(  "%s %s HTTP/1.0\r\n"
     109                                    "Host: %s\r\n"
     110                                    "User-Agent: BitlBee " BITLBEE_VERSION " " ARCH "/" CPU "\r\n",
     111                                    is_post ? "POST" : "GET", url->file, url->host );
    79112
    80113        // If a pass and user are given we append them to the request.
    81         if (td->oauth_info)
     114        if (oi)
    82115        {
    83116                char *full_header;
    84                 char *full_url;
    85117               
    86                 full_url = g_strconcat(set_getstr(&ic->acc->set, "base_url" ), url_string, NULL);
    87                 full_header = oauth_http_header(td->oauth_info, is_post ? "POST" : "GET",
    88                                                 full_url, url_arguments);
     118                full_header = oauth_http_header(oi, is_post ? "POST" : "GET",
     119                                                url_string, url_arguments);
    89120               
    90                 g_string_append_printf(request, "Authorization: %s\r\n", full_header);
     121                tmp = g_strdup_printf("%sAuthorization: %s\r\n", request, full_header);
     122                g_free(request);
    91123                g_free(full_header);
    92                 g_free(full_url);
     124                request = tmp;
    93125        }
    94         else
     126        else if (userpass_base64)
    95127        {
    96                 char userpass[strlen(ic->acc->user)+2+strlen(ic->acc->pass)];
    97                 char *userpass_base64;
    98                
    99                 g_snprintf(userpass, sizeof(userpass), "%s:%s", ic->acc->user, ic->acc->pass);
    100                 userpass_base64 = base64_encode((unsigned char*)userpass, strlen(userpass));
    101                 g_string_append_printf(request, "Authorization: Basic %s\r\n", userpass_base64);
    102                 g_free( userpass_base64 );
     128                tmp = g_strdup_printf("%sAuthorization: Basic %s\r\n", request, userpass_base64);
     129                g_free(request);
     130                request = tmp;
    103131        }
    104132
     
    107135        {
    108136                // Append the Content-Type and url-encoded arguments.
    109                 g_string_append_printf(request,
    110                                        "Content-Type: application/x-www-form-urlencoded\r\n"
    111                                        "Content-Length: %zd\r\n\r\n%s",
    112                                        strlen(url_arguments), url_arguments);
     137                tmp = g_strdup_printf("%sContent-Type: application/x-www-form-urlencoded\r\nContent-Length: %zd\r\n\r\n%s",
     138                                                                request, strlen(url_arguments), url_arguments);
     139                g_free(request);
     140                request = tmp;
    113141        } else {
    114142                // Append an extra \r\n to end the request...
    115                 g_string_append(request, "\r\n");
     143                tmp = g_strdup_printf("%s\r\n", request);
     144                g_free(request);
     145                request = tmp;
    116146        }
    117147
    118         ret = http_dorequest(td->url_host, td->url_port, td->url_ssl, request->str, func, data);
     148        ret = http_dorequest( url->host, url->port,     url->proto == PROTO_HTTPS, request, func, data );
    119149
     150        g_free( url );
     151        g_free( userpass );
     152        g_free( userpass_base64 );
    120153        g_free( url_arguments );
    121         g_string_free( request, TRUE );
     154        g_free( request );
    122155        return ret;
    123156}
    124157
    125 static char *twitter_url_append(char *url, char *key, char* value)
     158char *twitter_url_append(char *url, char *key, char* value)
    126159{
    127160        char *key_encoded = g_strndup(key, 3 * strlen(key));
  • protocols/twitter/twitter_http.h

    rba3233c r7d53efb  
    3030struct oauth_info;
    3131
    32 void *twitter_http(struct im_connection *ic, char *url_string, http_input_function func,
    33                    gpointer data, int is_post, char** arguments, int arguments_len);
     32void *twitter_http(char *url_string, http_input_function func, gpointer data, int is_post,
     33                   char* user, char* pass, struct oauth_info *oi, char** arguments, int arguments_len);
    3434
    3535#endif //_TWITTER_HTTP_H
  • protocols/twitter/twitter_lib.c

    rba3233c r7d53efb  
    117117}
    118118
    119 /* Warning: May return a malloc()ed value, which will be free()d on the next
    120    call. Only for short-term use. */
    121 static char *twitter_parse_error(struct http_request *req)
    122 {
    123         static char *ret = NULL;
    124         struct xt_parser *xp = NULL;
    125         struct xt_node *node;
    126        
    127         g_free(ret);
    128         ret = NULL;
    129        
    130         if (req->body_size > 0)
    131         {
    132                 xp = xt_new(NULL, NULL);
    133                 xt_feed(xp, req->reply_body, req->body_size);
    134                
    135                 if ((node = xt_find_node(xp->root, "hash")) &&
    136                     (node = xt_find_node(node->children, "error")) &&
    137                     node->text_len > 0)
    138                 {
    139                         ret = g_strdup_printf("%s (%s)", req->status_string, node->text);
    140                         xt_free(xp);
    141                         return ret;
    142                 }
    143                
    144                 xt_free(xp);
    145         }
    146        
    147         return req->status_string;
    148 }
    149 
    150119static void twitter_http_get_friends_ids(struct http_request *req);
    151120
     
    155124void twitter_get_friends_ids(struct im_connection *ic, int next_cursor)
    156125{
     126        struct twitter_data *td = ic->proto_data;
     127
    157128        // Primitive, but hey! It works...     
    158129        char* args[2];
    159130        args[0] = "cursor";
    160131        args[1] = g_strdup_printf ("%d", next_cursor);
    161         twitter_http(ic, TWITTER_FRIENDS_IDS_URL, twitter_http_get_friends_ids, ic, 0, args, 2);
     132        twitter_http(TWITTER_FRIENDS_IDS_URL, twitter_http_get_friends_ids, ic, 0, td->user, td->pass, td->oauth_info, args, 2);
    162133
    163134        g_free(args[1]);
     
    225196                // It didn't go well, output the error and return.
    226197                if (++td->http_fails >= 5)
    227                         imcb_error(ic, "Could not retrieve friends: %s", twitter_parse_error(req));
     198                        imcb_error(ic, "Could not retrieve friends. HTTP STATUS: %d", req->status_code);
    228199               
    229200                return;
     
    425396        }
    426397
    427         twitter_http(ic, TWITTER_HOME_TIMELINE_URL, twitter_http_get_home_timeline, ic, 0, args, td->home_timeline_id ? 4 : 2);
     398        twitter_http(TWITTER_HOME_TIMELINE_URL, twitter_http_get_home_timeline, ic, 0, td->user, td->pass, td->oauth_info, args, td->home_timeline_id ? 4 : 2);
    428399
    429400        g_free(args[1]);
     
    463434                twitter_add_buddy(ic, status->user->screen_name, status->user->name);
    464435               
    465                 strip_html(status->text);
    466                
    467436                // Say it!
    468437                if (g_strcasecmp(td->user, status->user->screen_name) == 0)
     
    502471                status = l->data;
    503472               
    504                 strip_html( status->text );
    505473                if( mode_one )
    506474                        text = g_strdup_printf( "\002<\002%s\002>\002 %s",
     
    555523                // It didn't go well, output the error and return.
    556524                if (++td->http_fails >= 5)
    557                         imcb_error(ic, "Could not retrieve " TWITTER_HOME_TIMELINE_URL ": %s", twitter_parse_error(req));
     525                        imcb_error(ic, "Could not retrieve " TWITTER_HOME_TIMELINE_URL ". HTTP STATUS: %d", req->status_code);
    558526               
    559527                return;
     
    607575                // It didn't go well, output the error and return.
    608576                if (++td->http_fails >= 5)
    609                         imcb_error(ic, "Could not retrieve " TWITTER_SHOW_FRIENDS_URL ": %s", twitter_parse_error(req));
     577                        imcb_error(ic, "Could not retrieve " TWITTER_SHOW_FRIENDS_URL " HTTP STATUS: %d", req->status_code);
    610578               
    611579                return;
     
    646614void twitter_get_statuses_friends(struct im_connection *ic, int next_cursor)
    647615{
     616        struct twitter_data *td = ic->proto_data;
     617
    648618        char* args[2];
    649619        args[0] = "cursor";
    650620        args[1] = g_strdup_printf ("%d", next_cursor);
    651621
    652         twitter_http(ic, TWITTER_SHOW_FRIENDS_URL, twitter_http_get_statuses_friends, ic, 0, args, 2);
     622        twitter_http(TWITTER_SHOW_FRIENDS_URL, twitter_http_get_statuses_friends, ic, 0, td->user, td->pass, td->oauth_info, args, 2);
    653623
    654624        g_free(args[1]);
     
    669639        if (req->status_code != 200) {
    670640                // It didn't go well, output the error and return.
    671                 imcb_error(ic, "HTTP error: %s", twitter_parse_error(req));
     641                imcb_error(ic, "HTTP Error... STATUS: %d", req->status_code);
    672642                return;
    673643        }
     
    679649void twitter_post_status(struct im_connection *ic, char* msg)
    680650{
     651        struct twitter_data *td = ic->proto_data;
     652
    681653        char* args[2];
    682654        args[0] = "status";
    683655        args[1] = msg;
    684         twitter_http(ic, TWITTER_STATUS_UPDATE_URL, twitter_http_post, ic, 1, args, 2);
     656        twitter_http(TWITTER_STATUS_UPDATE_URL, twitter_http_post, ic, 1, td->user, td->pass, td->oauth_info, args, 2);
    685657//      g_free(args[1]);
    686658}
     
    692664void twitter_direct_messages_new(struct im_connection *ic, char *who, char *msg)
    693665{
     666        struct twitter_data *td = ic->proto_data;
     667
    694668        char* args[4];
    695669        args[0] = "screen_name";
     
    698672        args[3] = msg;
    699673        // Use the same callback as for twitter_post_status, since it does basically the same.
    700         twitter_http(ic, TWITTER_DIRECT_MESSAGES_NEW_URL, twitter_http_post, ic, 1, args, 4);
     674        twitter_http(TWITTER_DIRECT_MESSAGES_NEW_URL, twitter_http_post, ic, 1, td->user, td->pass, td->oauth_info, args, 4);
    701675//      g_free(args[1]);
    702676//      g_free(args[3]);
     
    705679void twitter_friendships_create_destroy(struct im_connection *ic, char *who, int create)
    706680{
     681        struct twitter_data *td = ic->proto_data;
     682
    707683        char* args[2];
    708684        args[0] = "screen_name";
    709685        args[1] = who;
    710         twitter_http(ic, create ? TWITTER_FRIENDSHIPS_CREATE_URL : TWITTER_FRIENDSHIPS_DESTROY_URL, twitter_http_post, ic, 1, args, 2);
    711 }
     686        twitter_http(create ? TWITTER_FRIENDSHIPS_CREATE_URL : TWITTER_FRIENDSHIPS_DESTROY_URL, twitter_http_post, ic, 1, td->user, td->pass, td->oauth_info, args, 2);
     687}
     688
     689
     690
  • protocols/twitter/twitter_lib.h

    rba3233c r7d53efb  
    3232
    3333/* Status URLs */
    34 #define TWITTER_STATUS_UPDATE_URL "/statuses/update.xml"
    35 #define TWITTER_STATUS_SHOW_URL "/statuses/show/"
    36 #define TWITTER_STATUS_DESTROY_URL "/statuses/destroy/"
     34#define TWITTER_STATUS_UPDATE_URL TWITTER_API_URL "/statuses/update.xml"
     35#define TWITTER_STATUS_SHOW_URL TWITTER_API_URL "/statuses/show/"
     36#define TWITTER_STATUS_DESTROY_URL TWITTER_API_URL "/statuses/destroy/"
    3737
    3838/* Timeline URLs */
    39 #define TWITTER_PUBLIC_TIMELINE_URL "/statuses/public_timeline.xml"
    40 #define TWITTER_FEATURED_USERS_URL "/statuses/featured.xml"
    41 #define TWITTER_FRIENDS_TIMELINE_URL "/statuses/friends_timeline.xml"
    42 #define TWITTER_HOME_TIMELINE_URL "/statuses/home_timeline.xml"
    43 #define TWITTER_MENTIONS_URL "/statuses/mentions.xml"
    44 #define TWITTER_USER_TIMELINE_URL "/statuses/user_timeline.xml"
     39#define TWITTER_PUBLIC_TIMELINE_URL TWITTER_API_URL "/statuses/public_timeline.xml"
     40#define TWITTER_FEATURED_USERS_URL TWITTER_API_URL "/statuses/featured.xml"
     41#define TWITTER_FRIENDS_TIMELINE_URL TWITTER_API_URL "/statuses/friends_timeline.xml"
     42#define TWITTER_HOME_TIMELINE_URL TWITTER_API_URL "/statuses/home_timeline.xml"
     43#define TWITTER_MENTIONS_URL TWITTER_API_URL "/statuses/mentions.xml"
     44#define TWITTER_USER_TIMELINE_URL TWITTER_API_URL "/statuses/user_timeline.xml"
    4545
    4646/* Users URLs */
    47 #define TWITTER_SHOW_USERS_URL "/users/show.xml"
    48 #define TWITTER_SHOW_FRIENDS_URL "/statuses/friends.xml"
    49 #define TWITTER_SHOW_FOLLOWERS_URL "/statuses/followers.xml"
     47#define TWITTER_SHOW_USERS_URL TWITTER_API_URL "/users/show.xml"
     48#define TWITTER_SHOW_FRIENDS_URL TWITTER_API_URL "/statuses/friends.xml"
     49#define TWITTER_SHOW_FOLLOWERS_URL TWITTER_API_URL "/statuses/followers.xml"
    5050
    5151/* Direct messages URLs */
    52 #define TWITTER_DIRECT_MESSAGES_URL "/direct_messages.xml"
    53 #define TWITTER_DIRECT_MESSAGES_NEW_URL "/direct_messages/new.xml"
    54 #define TWITTER_DIRECT_MESSAGES_SENT_URL "/direct_messages/sent.xml"
    55 #define TWITTER_DIRECT_MESSAGES_DESTROY_URL "/direct_messages/destroy/"
     52#define TWITTER_DIRECT_MESSAGES_URL TWITTER_API_URL "/direct_messages.xml"
     53#define TWITTER_DIRECT_MESSAGES_NEW_URL TWITTER_API_URL "/direct_messages/new.xml"
     54#define TWITTER_DIRECT_MESSAGES_SENT_URL TWITTER_API_URL "/direct_messages/sent.xml"
     55#define TWITTER_DIRECT_MESSAGES_DESTROY_URL TWITTER_API_URL "/direct_messages/destroy/"
    5656
    5757/* Friendships URLs */
    58 #define TWITTER_FRIENDSHIPS_CREATE_URL "/friendships/create.xml"
    59 #define TWITTER_FRIENDSHIPS_DESTROY_URL "/friendships/destroy.xml"
    60 #define TWITTER_FRIENDSHIPS_SHOW_URL "/friendships/show.xml"
     58#define TWITTER_FRIENDSHIPS_CREATE_URL TWITTER_API_URL "/friendships/create.xml"
     59#define TWITTER_FRIENDSHIPS_DESTROY_URL TWITTER_API_URL "/friendships/destroy.xml"
     60#define TWITTER_FRIENDSHIPS_SHOW_URL TWITTER_API_URL "/friendships/show.xml"
    6161
    6262/* Social graphs URLs */
    63 #define TWITTER_FRIENDS_IDS_URL "/friends/ids.xml"
    64 #define TWITTER_FOLLOWERS_IDS_URL "/followers/ids.xml"
     63#define TWITTER_FRIENDS_IDS_URL TWITTER_API_URL "/friends/ids.xml"
     64#define TWITTER_FOLLOWERS_IDS_URL TWITTER_API_URL "/followers/ids.xml"
    6565
    6666/* Account URLs */
    67 #define TWITTER_ACCOUNT_RATE_LIMIT_URL "/account/rate_limit_status.xml"
     67#define TWITTER_ACCOUNT_RATE_LIMIT_URL TWITTER_API_URL "/account/rate_limit_status.xml"
    6868
    6969/* Favorites URLs */
    70 #define TWITTER_FAVORITES_GET_URL "/favorites.xml"
    71 #define TWITTER_FAVORITE_CREATE_URL "/favorites/create/"
    72 #define TWITTER_FAVORITE_DESTROY_URL "/favorites/destroy/"
     70#define TWITTER_FAVORITES_GET_URL TWITTER_API_URL "/favorites.xml"
     71#define TWITTER_FAVORITE_CREATE_URL TWITTER_API_URL "/favorites/create/"
     72#define TWITTER_FAVORITE_DESTROY_URL TWITTER_API_URL "/favorites/destroy/"
    7373
    7474/* Block URLs */
    75 #define TWITTER_BLOCKS_CREATE_URL "/blocks/create/"
    76 #define TWITTER_BLOCKS_DESTROY_URL "/blocks/destroy/"
     75#define TWITTER_BLOCKS_CREATE_URL TWITTER_API_URL "/blocks/create/"
     76#define TWITTER_BLOCKS_DESTROY_URL TWITTER_API_URL "/blocks/destroy/"
    7777
    7878void twitter_get_friends_ids(struct im_connection *ic, int next_cursor);
  • protocols/yahoo/yahoo.c

    rba3233c r7d53efb  
    138138        struct im_connection *ic = imcb_new( acc );
    139139        struct byahoo_data *yd = ic->proto_data = g_new0( struct byahoo_data, 1 );
    140         char *s;
    141140       
    142141        yd->logged_in = FALSE;
    143142        yd->current_status = YAHOO_STATUS_AVAILABLE;
    144        
    145         if( ( s = strchr( acc->user, '@' ) ) && g_strcasecmp( s, "@yahoo.com" ) == 0 )
    146                 imcb_error( ic, "Your Yahoo! username should just be a username. "
    147                                 "Do not include any @domain part." );
    148143       
    149144        imcb_log( ic, "Connecting" );
     
    833828        YList *m;
    834829       
    835         if( g_strcasecmp( who, ic->acc->user ) == 0 )
    836                 /* WTF, Yahoo! seems to echo these now? */
    837                 return;
    838        
    839830        inv = g_malloc( sizeof( struct byahoo_conf_invitation ) );
    840831        memset( inv, 0, sizeof( struct byahoo_conf_invitation ) );
Note: See TracChangeset for help on using the changeset viewer.