Changeset 89db90e


Ignore:
Timestamp:
2015-03-12T09:10:16Z (5 years ago)
Author:
dequis <dx@…>
Children:
fc650a8
Parents:
0e4c3dd (diff), 3bb333c (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 branch 'develop' into feat/hip-cat

Files:
1 added
27 edited

Legend:

Unmodified
Added
Removed
  • .gitignore

    r0e4c3dd r89db90e  
    3030.git
    3131.gitignore
     32bitlbee.service
     33bitlbee@.service
  • .travis.yml

    r0e4c3dd r89db90e  
    11language: c
    2 script: ./configure && make check && dpkg-buildpackage -uc -us
     2
     3script:
     4 - ./configure
     5 - make check
     6 - dpkg-buildpackage -uc -us
     7
    38before_install:
    49 - sudo apt-get update -qq
     
    712 - sudo dpkg -i *.deb
    813
     14env:
     15  global:
     16   # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
     17   #   via the "travis encrypt" command using the project repo's public key
     18   - secure: "MO6hy2cRxR02A0nSenfQFyPFpepxorJ+XgNkq2JS7LtI6tcwYRR0alvunIPJXam1/OUKxoFsBJLS1nCJTvEUXFCOvoTSAoMiePTBUEg2zfzcTb5k+cqtcOUznCXHNmXAwrqriP4vkG+57ijO9Ojz2r9LijcvjtFDRFJQY9Rcs38="
     19
     20addons:
     21  coverity_scan:
     22    project:
     23      name: "bitlbee/bitlbee"
     24      description: "An IRC to other chat networks gateway"
     25    notification_email: dx@dxzone.com.ar
     26    build_command_prepend: ./configure --otr=1 --debug=1
     27    build_command: make
     28    branch_pattern: coverity_scan
     29
     30notifications:
     31  email: false
  • Makefile

    r0e4c3dd r89db90e  
    2525
    2626doc:
     27ifdef DOC
    2728        $(MAKE) -C doc
     29endif
    2830
    2931uninstall: uninstall-bin uninstall-doc
     
    7375
    7476install-doc:
     77ifdef DOC
    7578        $(MAKE) -C doc install
     79endif
    7680ifdef SKYPE_PI
    7781        $(MAKE) -C protocols/skype install-doc
     
    7983
    8084uninstall-doc:
     85ifdef DOC
    8186        $(MAKE) -C doc uninstall
     87endif
    8288ifdef SKYPE_PI
    8389        $(MAKE) -C protocols/skype uninstall-doc
  • configure

    r0e4c3dd r89db90e  
    3737purple=0
    3838
     39doc=1
    3940debug=0
    4041strip=1
     
    5960# Cygwin and Darwin don't support PIC/PIE
    6061case "$arch" in
    61     CYGWIN* )
    62         pie=0;;
    63     Darwin )
    64         pie=0;;
     62        CYGWIN* )
     63                pie=0;;
     64        Darwin )
     65                pie=0;;
    6566esac
    6667
     
    9495                (automatically disables other protocol modules)
    9596
     97--doc=0/1       Disable/enable help.txt generation      $doc
    9698--debug=0/1     Disable/enable debugging                $debug
    9799--strip=0/1     Disable/enable binary stripping         $strip
     
    448450        ret=1
    449451        echo "$RESOLV_NS_TESTCODE" | $CC -o $TMPFILE -x c - $LIBRESOLV >/dev/null 2>/dev/null
    450         if [ "$?" = "0" ]; then
    451                 ret=0
    452         fi
     452        if [ "$?" = "0" ]; then
     453                ret=0
     454        fi
    453455
    454456        rm -f $TMPFILE
     
    463465                if [ -f $i/libresolv.a ]; then
    464466                        echo "$RESOLV_NS_TESTCODE" | $CC -o $TMPFILE -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null
    465                         if [ "$?" = "0" ]; then
    466                                 ret=0
    467                         fi
     467                        if [ "$?" = "0" ]; then
     468                                ret=0
     469                        fi
    468470                fi
    469471        done
     
    475477detect_nameser_has_ns_types()
    476478{
    477     TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
    478     ret=1
    479     # since we aren't actually linking with ns_* routines
    480     # we can just compile the test code
    481     echo "$RESOLV_NS_TYPES_TESTCODE" | $CC -o $TMPFILE -x c -  >/dev/null 2>/dev/null
    482     if [ "$?" = "0" ]; then
    483         ret=0
    484     fi
    485 
    486     rm -f $TMPFILE
    487     return $ret
     479        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
     480        ret=1
     481        # since we aren't actually linking with ns_* routines
     482        # we can just compile the test code
     483        echo "$RESOLV_NS_TYPES_TESTCODE" | $CC -o $TMPFILE -x c -  >/dev/null 2>/dev/null
     484        if [ "$?" = "0" ]; then
     485                ret=0
     486        fi
     487
     488        rm -f $TMPFILE
     489        return $ret
    488490}
    489491
     
    546548if detect_resolv_dynamic || detect_resolv_static; then
    547549        echo '#define HAVE_RESOLV_A' >> config.h
    548     if detect_resolv_ns_dynamic || detect_resolv_ns_static; then
    549             echo '#define HAVE_RESOLV_A_WITH_NS' >> config.h
    550     fi
    551 else
    552     echo 'Insufficient resolv routines. Jabber server must be set explicitly'
     550        if detect_resolv_ns_dynamic || detect_resolv_ns_static; then
     551                echo '#define HAVE_RESOLV_A_WITH_NS' >> config.h
     552        fi
     553else
     554        echo 'Insufficient resolv routines. Jabber server must be set explicitly'
    553555fi
    554556
     
    647649fi
    648650
    649 if [ ! -e doc/user-guide/help.txt ] && ! type xmlto > /dev/null 2> /dev/null; then
    650         echo
    651         echo 'WARNING: Building from an unreleased source tree without prebuilt helpfile.'
    652         echo 'Install xmlto if you want online help to work.'
     651if [ "$doc" = "1" ]; then
     652        if [ ! -e doc/user-guide/help.txt ] && \
     653             ! type xmlto > /dev/null 2> /dev/null || \
     654             ! type xsltproc > /dev/null 2> /dev/null
     655        then
     656                echo
     657                echo 'WARNING: Building from an unreleased source tree without prebuilt helpfile.'
     658                echo 'Install xmlto and xsltproc if you want online help to work.'
     659        else
     660                echo "DOC=1" >> Makefile.settings
     661        fi
     662
     663        if [ "$skype" = "1" -o "$skype" = "plugin" ]; then
     664                # skype also needs asciidoc
     665                if ! type a2x > /dev/null 2> /dev/null; then
     666                        echo
     667                        echo 'WARNING: The skyped man page requires asciidoc. It will not be generated.'
     668                else
     669                        echo "ASCIIDOC=1" >> Makefile.settings
     670                fi
     671        fi
    653672fi
    654673
  • help.c

    r0e4c3dd r89db90e  
    3030#undef write
    3131
    32 #define BUFSIZE 1100
     32#define BUFSIZE 2048
    3333
    3434help_t *help_init(help_t **help, const char *helpfile)
  • ipc.c

    r0e4c3dd r89db90e  
    776776        }
    777777
     778        child_list = g_slist_remove(child_list, c);
     779
    778780        g_free(c->host);
    779781        g_free(c->nick);
     
    781783        g_free(c->password);
    782784        g_free(c);
    783 
    784         child_list = g_slist_remove(child_list, c);
    785785
    786786        /* Also, if any child has a reference to this one, remove it. */
  • irc.c

    r0e4c3dd r89db90e  
    764764                        irc_rootmsg(irc,
    765765                                    "Welcome to the BitlBee gateway!\n\n"
     766                                    "Running %s %s\n\n"
    766767                                    "If you've never used BitlBee before, please do read the help "
    767768                                    "information using the \x02help\x02 command. Lots of FAQs are "
    768769                                    "answered there.\n"
    769770                                    "If you already have an account on this server, just use the "
    770                                     "\x02identify\x02 command to identify yourself.");
     771                                    "\x02identify\x02 command to identify yourself.",
     772                                    PACKAGE, BITLBEE_VERSION);
    771773
    772774                        /* This is for bug #209 (use PASS to identify to NickServ). */
  • irc_send.c

    r0e4c3dd r89db90e  
    5555{
    5656        char motd[2048];
    57         size_t len;
     57        ssize_t len;
    5858        int fd;
    5959
  • lib/oauth.c

    r0e4c3dd r89db90e  
    9696{
    9797        int key_len = strlen(key);
    98         GSList *l, *n;
    99 
    100         if (params == NULL) {
     98        GSList *l;
     99
     100        if (!params) {
    101101                return;
    102102        }
    103103
    104         for (l = *params; l; l = n) {
    105                 n = l->next;
    106 
    107                 if (strncmp((char *) l->data, key, key_len) == 0 &&
    108                     ((char *) l->data)[key_len] == '=') {
    109                         g_free(l->data);
    110                         *params = g_slist_remove(*params, l->data);
     104        for (l = *params; l; l = l->next) {
     105                char *data = l->data;
     106
     107                if (strncmp(data, key, key_len) == 0 && data[key_len] == '=') {
     108                        *params = g_slist_remove(*params, data);
     109                        g_free(data);
    111110                }
    112111        }
  • protocols/bee.h

    r0e4c3dd r89db90e  
    154154G_MODULE_EXPORT void imcb_buddy_times(struct im_connection *ic, const char *handle, time_t login, time_t idle);
    155155/* Call when a handle says something. 'flags' and 'sent_at may be just 0. */
    156 G_MODULE_EXPORT void imcb_buddy_msg(struct im_connection *ic, const char *handle, char *msg, guint32 flags,
     156G_MODULE_EXPORT void imcb_buddy_msg(struct im_connection *ic, const char *handle, const char *msg, guint32 flags,
    157157                                    time_t sent_at);
    158158
  • protocols/bee_user.c

    r0e4c3dd r89db90e  
    6868        }
    6969
     70        bee->users = g_slist_remove(bee->users, bu);
     71
    7072        g_free(bu->handle);
    7173        g_free(bu->fullname);
     
    7476        g_free(bu->status_msg);
    7577        g_free(bu);
    76 
    77         bee->users = g_slist_remove(bee->users, bu);
    7878
    7979        return 1;
     
    247247}
    248248
    249 void imcb_buddy_msg(struct im_connection *ic, const char *handle, char *msg, uint32_t flags, time_t sent_at)
     249void imcb_buddy_msg(struct im_connection *ic, const char *handle, const char *msg, uint32_t flags, time_t sent_at)
    250250{
    251251        bee_t *bee = ic->bee;
  • protocols/jabber/s5bytestream.c

    r0e4c3dd r89db90e  
    2323
    2424#include "jabber.h"
    25 #include "sha1.h"
    2625#include "lib/ftutil.h"
    2726#include <poll.h>
     
    4241
    4342        /* SHA1( SID + Initiator JID + Target JID) */
    44         char *pseudoadr;
     43        char *pseudoaddr;
    4544
    4645        gint connect_timeout;
     
    130129        }
    131130
    132         g_free(bt->pseudoadr);
     131        g_free(bt->pseudoaddr);
    133132
    134133        while (bt->streamhosts) {
     
    254253}
    255254
     255void jabber_bs_remove_events(struct bs_transfer *bt)
     256{
     257        struct jabber_transfer *tf = bt->tf;
     258
     259        if (tf->watch_out) {
     260                b_event_remove(tf->watch_out);
     261                tf->watch_out = 0;
     262        }
     263
     264        if (tf->watch_in) {
     265                b_event_remove(tf->watch_in);
     266                tf->watch_in = 0;
     267        }
     268
     269        if (tf->fd != -1) {
     270                closesocket(tf->fd);
     271                tf->fd = -1;
     272        }
     273
     274        if (bt->connect_timeout) {
     275                b_event_remove(bt->connect_timeout);
     276                bt->connect_timeout = 0;
     277        }
     278}
     279
    256280/* Bad luck */
    257281void jabber_bs_canceled(file_transfer_t *ft, char *reason)
     
    260284
    261285        imcb_log(tf->ic, "File transfer aborted: %s", reason);
     286}
     287
     288static struct jabber_transfer *get_ft_by_sid(GSList *tflist, char *sid) {
     289        GSList *l;
     290        for (l = tflist; l; l = g_slist_next(l)) {
     291                struct jabber_transfer *tft = l->data;
     292                if ((strcmp(tft->sid, sid) == 0)) {
     293                        return tft;
     294                }
     295        }
     296        return NULL;
     297}
     298
     299/* SHA1( SID + Initiator JID + Target JID ) is given to the streamhost which it will match against the initiator's value
     300 * Returns a newly allocated string */
     301static char *generate_pseudoaddr(char *sid, char *ini_jid, char *tgt_jid) {
     302        char *contents = g_strconcat(sid, ini_jid, tgt_jid, NULL);
     303        char *hash_hex = g_compute_checksum_for_string(G_CHECKSUM_SHA1, contents, -1);
     304        g_free(contents);
     305        return hash_hex;
     306}
     307
     308static jabber_streamhost_t *jabber_streamhost_new(char *jid, char *host, int port)
     309{
     310        jabber_streamhost_t *sh = g_new0(jabber_streamhost_t, 1);
     311        sh->jid = g_strdup(jid);
     312        sh->host = g_strdup(host);
     313        if (port) {
     314                g_snprintf(sh->port, sizeof(sh->port), "%u", port);
     315        }
     316        return sh;
    262317}
    263318
     
    270325        struct jabber_data *jd = ic->proto_data;
    271326        struct jabber_transfer *tf = NULL;
    272         GSList *tflist;
    273327        struct bs_transfer *bt;
    274328        GSList *shlist = NULL;
    275329        struct xt_node *shnode;
    276 
    277         sha1_state_t sha;
    278         char hash_hex[41];
    279         unsigned char hash[20];
    280         int i;
    281330
    282331        if (!(iq_id   = xt_find_attr(node, "id")) ||
     
    303352                    (port_s = xt_find_attr(shnode, "port")) &&
    304353                    (sscanf(port_s, "%d", &port) == 1)) {
    305                         jabber_streamhost_t *sh = g_new0(jabber_streamhost_t, 1);
    306                         sh->jid = g_strdup(jid);
    307                         sh->host = g_strdup(host);
    308                         sprintf(sh->port, "%u", port);
    309                         shlist = g_slist_append(shlist, sh);
     354                        shlist = g_slist_append(shlist, jabber_streamhost_new(jid, host, port));
    310355                }
    311356                shnode = shnode->next;
     
    317362        }
    318363
    319         /* Let's see if we can find out what this bytestream should be for... */
    320 
    321         for (tflist = jd->filetransfers; tflist; tflist = g_slist_next(tflist)) {
    322                 struct jabber_transfer *tft = tflist->data;
    323                 if ((strcmp(tft->sid, sid) == 0) &&
    324                     (strcmp(tft->ini_jid, ini_jid) == 0) &&
    325                     (strcmp(tft->tgt_jid, tgt_jid) == 0)) {
    326                         tf = tft;
    327                         break;
    328                 }
    329         }
    330 
    331         if (!tf) {
     364        if (!(tf = get_ft_by_sid(jd->filetransfers, sid))) {
    332365                imcb_log(ic, "WARNING: Received bytestream request from %s that doesn't match an SI request", ini_jid);
    333366                return XT_HANDLED;
     
    339372
    340373        tf->ft->canceled = jabber_bs_canceled;
    341 
    342         /* SHA1( SID + Initiator JID + Target JID ) is given to the streamhost which it will match against the initiator's value */
    343         sha1_init(&sha);
    344         sha1_append(&sha, (unsigned char *) sid, strlen(sid));
    345         sha1_append(&sha, (unsigned char *) ini_jid, strlen(ini_jid));
    346         sha1_append(&sha, (unsigned char *) tgt_jid, strlen(tgt_jid));
    347         sha1_finish(&sha, hash);
    348 
    349         for (i = 0; i < 20; i++) {
    350                 sprintf(hash_hex + i * 2, "%02x", hash[i]);
    351         }
    352374
    353375        bt = g_new0(struct bs_transfer, 1);
     
    356378        bt->sh = shlist->data;
    357379        bt->phase = BS_PHASE_CONNECT;
    358         bt->pseudoadr = g_strdup(hash_hex);
     380        bt->pseudoaddr = generate_pseudoaddr(sid, ini_jid, tgt_jid);
    359381        tf->streamhandle = bt;
    360382        tf->ft->free = jabber_bs_free_transfer;
     
    451473                        .rsv = 0,
    452474                        .atyp = 0x03,
    453                         .addrlen = strlen(bt->pseudoadr),
     475                        .addrlen = strlen(bt->pseudoaddr),
    454476                        .port = 0
    455477                };
     
    468490
    469491                /* copy hash into connect message */
    470                 memcpy(socks5_connect.address, bt->pseudoadr, socks5_connect.addrlen);
     492                memcpy(socks5_connect.address, bt->pseudoaddr, socks5_connect.addrlen);
    471493
    472494                ASSERTSOCKOP(send(fd, &socks5_connect, sizeof(struct socks5_message), 0), "Sending SOCKS5 Connect");
     
    558580        if (shlist && shlist->next) {
    559581                bt->sh = shlist->next->data;
     582                jabber_bs_remove_events(bt);
    560583                return jabber_bs_recv_handshake(bt, -1, 0);
    561584        }
     
    731754        struct jabber_data *jd = ic->proto_data;
    732755        struct bs_transfer *bt;
    733         GSList *tflist;
    734756        struct xt_node *c;
    735757        char *sid, *jid;
     
    750772        /* Let's see if we can find out what this bytestream should be for... */
    751773
    752         for (tflist = jd->filetransfers; tflist; tflist = g_slist_next(tflist)) {
    753                 struct jabber_transfer *tft = tflist->data;
    754                 if ((strcmp(tft->sid, sid) == 0)) {
    755                         tf = tft;
    756                         break;
    757                 }
    758         }
    759 
    760         if (!tf) {
     774        if (!(tf = get_ft_by_sid(jd->filetransfers, sid))) {
    761775                imcb_log(ic, "WARNING: Received SOCKS5 bytestream reply to unknown request");
    762776                return XT_HANDLED;
     
    776790                /* using a proxy, abort listen */
    777791
    778                 if (tf->watch_in) {
    779                         b_event_remove(tf->watch_in);
    780                         tf->watch_in = 0;
    781                 }
    782 
    783                 if (tf->fd != -1) {
    784                         closesocket(tf->fd);
    785                         tf->fd = -1;
    786                 }
    787 
    788                 if (bt->connect_timeout) {
    789                         b_event_remove(bt->connect_timeout);
    790                         bt->connect_timeout = 0;
    791                 }
     792                jabber_bs_remove_events(bt);
    792793
    793794                GSList *shlist;
     
    838839{
    839840        char *sid;
    840         GSList *tflist;
    841841        struct jabber_transfer *tf = NULL;
    842842        struct xt_node *query;
     
    846846        sid = xt_find_attr(query, "sid");
    847847
    848         for (tflist = jd->filetransfers; tflist; tflist = g_slist_next(tflist)) {
    849                 struct jabber_transfer *tft = tflist->data;
    850                 if ((strcmp(tft->sid, sid) == 0)) {
    851                         tf = tft;
    852                         break;
    853                 }
    854         }
    855 
    856         if (!tf) {
     848        if (!(tf = get_ft_by_sid(jd->filetransfers, sid))) {
    857849                imcb_log(ic, "WARNING: Received SOCKS5 bytestream activation for unknown stream");
    858850                return XT_HANDLED;
     
    883875        *port++ = '\0';
    884876
    885         sh = g_new0(jabber_streamhost_t, 1);
    886         sh->jid = g_strdup(jid);
    887         sh->host = g_strdup(host);
    888         g_snprintf(sh->port, sizeof(sh->port), "%s", port);
     877        sh = jabber_streamhost_new(jid, host, 0);
     878        strncpy(sh->port, port, sizeof(sh->port));
    889879
    890880        return sh;
     
    910900                if (strcmp(proxy, "<local>") == 0) {
    911901                        if ((tf->fd = ft_listen(&tf->saddr, host, port, jd->fd, FALSE, &errmsg)) != -1) {
    912                                 sh = g_new0(jabber_streamhost_t, 1);
    913                                 sh->jid = g_strdup(tf->ini_jid);
    914                                 sh->host = g_strdup(host);
    915                                 g_snprintf(sh->port, sizeof(sh->port), "%s", port);
     902                                sh = jabber_streamhost_new(tf->ini_jid, host, 0);
     903                                strncpy(sh->port, port, sizeof(sh->port));
    916904                                bt->streamhosts = g_slist_append(bt->streamhosts, sh);
    917905
     
    948936{
    949937        struct bs_transfer *bt;
    950         sha1_state_t sha;
    951         char hash_hex[41];
    952         unsigned char hash[20];
    953         int i, ret;
    954 
    955         /* SHA1( SID + Initiator JID + Target JID ) is given to the streamhost which it will match against the initiator's value */
    956         sha1_init(&sha);
    957         sha1_append(&sha, (unsigned char *) tf->sid, strlen(tf->sid));
    958         sha1_append(&sha, (unsigned char *) tf->ini_jid, strlen(tf->ini_jid));
    959         sha1_append(&sha, (unsigned char *) tf->tgt_jid, strlen(tf->tgt_jid));
    960         sha1_finish(&sha, hash);
    961 
    962         for (i = 0; i < 20; i++) {
    963                 sprintf(hash_hex + i * 2, "%02x", hash[i]);
    964         }
    965938
    966939        bt = g_new0(struct bs_transfer, 1);
    967940        bt->tf = tf;
    968941        bt->phase = BS_PHASE_CONNECT;
    969         bt->pseudoadr = g_strdup(hash_hex);
     942        bt->pseudoaddr = generate_pseudoaddr(tf->sid, tf->ini_jid, tf->tgt_jid);
    970943        tf->streamhandle = bt;
    971944        tf->ft->free = jabber_bs_free_transfer;
     
    974947        jabber_si_set_proxies(bt);
    975948
    976         ret = jabber_bs_send_request(tf, bt->streamhosts);
    977 
    978         return ret;
     949        return jabber_bs_send_request(tf, bt->streamhosts);
    979950}
    980951
     
    11391110                                               socks5_connect.atyp);
    11401111                }
    1141                 if (!(memcmp(socks5_connect.address, bt->pseudoadr, 40) == 0)) {
     1112                if (!(memcmp(socks5_connect.address, bt->pseudoaddr, 40) == 0)) {
    11421113                        return jabber_bs_abort(bt, "SOCKS5 Connect message contained wrong digest");
    11431114                }
  • protocols/jabber/sasl.c

    r0e4c3dd r89db90e  
    4242        "https://www.facebook.com/dialog/oauth",
    4343        "https://graph.facebook.com/oauth/access_token",
    44         "http://www.bitlbee.org/main.php/Facebook/oauth2.html",
     44        "https://www.bitlbee.org/main.php/Facebook/oauth2.html",
    4545        "offline_access,xmpp_login",
    4646        "126828914005625",
  • protocols/msn/msn.c

    r0e4c3dd r89db90e  
    4141        s->flags |= SET_NOSAVE | ACC_SET_ONLINE_ONLY;
    4242
    43         s = set_add(&acc->set, "server", MSN_NS_HOST, set_eval_account, acc);
     43        s = set_add(&acc->set, "server", NULL, set_eval_account, acc);
    4444        s->flags |= SET_NOSAVE | ACC_SET_OFFLINE_ONLY;
    4545
     
    5858        struct im_connection *ic = imcb_new(acc);
    5959        struct msn_data *md = g_new0(struct msn_data, 1);
     60        char *server = set_getstr(&ic->acc->set, "server");
    6061
    6162        ic->proto_data = md;
    6263        ic->flags |= OPT_PONGS | OPT_PONGED;
     64
     65        if (!server) {
     66                imcb_error(ic, "The msn protocol is disabled in this version because most servers disabled MSNP18 over port 1863.");
     67                imcb_error(ic, "If you find a working server, you can change the 'server' setting of this account. Good luck!");
     68                imcb_error(ic, "See also: http://ismsndeadyet.com/"); // shameless plug
     69                imc_logout(ic, FALSE);
     70                return;
     71        }
    6372
    6473        if (strchr(acc->user, '@') == NULL) {
     
    7685
    7786        imcb_log(ic, "Connecting");
    78         msn_ns_connect(ic, md->ns,
    79                        set_getstr(&ic->acc->set, "server"),
     87        msn_ns_connect(ic, md->ns, server,
    8088                       set_getint(&ic->acc->set, "port"));
    8189}
     
    112120                while (md->groups) {
    113121                        struct msn_group *mg = md->groups->data;
     122                        md->groups = g_slist_remove(md->groups, mg);
    114123                        g_free(mg->id);
    115124                        g_free(mg->name);
    116125                        g_free(mg);
    117                         md->groups = g_slist_remove(md->groups, mg);
    118126                }
    119127
     
    127135                while (md->grpq) {
    128136                        struct msn_groupadd *ga = md->grpq->data;
     137                        md->grpq = g_slist_remove(md->grpq, ga);
    129138                        g_free(ga->group);
    130139                        g_free(ga->who);
    131140                        g_free(ga);
    132                         md->grpq = g_slist_remove(md->grpq, ga);
    133141                }
    134142
  • protocols/msn/ns.c

    r0e4c3dd r89db90e  
    944944                struct msn_message *m = (*msgq)->data;
    945945
     946                *msgq = g_slist_remove(*msgq, m);
    946947                g_free(m->who);
    947948                g_free(m->text);
    948949                g_free(m);
    949 
    950                 *msgq = g_slist_remove(*msgq, m);
    951         }
    952 }
     950        }
     951}
  • protocols/msn/sb.c

    r0e4c3dd r89db90e  
    519519                                        }
    520520                                }
     521                                sb->msgq = g_slist_remove(sb->msgq, m);
    521522                                g_free(m->text);
    522523                                g_free(m->who);
    523524                                g_free(m);
    524 
    525                                 sb->msgq = g_slist_remove(sb->msgq, m);
    526525                        }
    527526
  • protocols/msn/soap.h

    r0e4c3dd r89db90e  
    167167
    168168#define SOAP_MEMLIST_PAYLOAD \
    169         "<FindMembership xmlns=\"http://www.msn.com/webservices/AddressBook\"><serviceFilter xmlns=\"http://www.msn.com/webservices/AddressBook\"><Types xmlns=\"http://www.msn.com/webservices/AddressBook\"><ServiceType xmlns=\"http://www.msn.com/webservices/AddressBook\">Messenger</ServiceType><ServiceType xmlns=\"http://www.msn.com/webservices/AddressBook\">Invitation</ServiceType><ServiceType xmlns=\"http://www.msn.com/webservices/AddressBook\">SocialNetwork</ServiceType><ServiceType xmlns=\"http://www.msn.com/webservices/AddressBook\">Space</ServiceType><ServiceType xmlns=\"http://www.msn.com/webservices/AddressBook\">Profile</ServiceType></Types></serviceFilter>" \
     169        "<FindMembership xmlns=\"http://www.msn.com/webservices/AddressBook\"><serviceFilter><Types><ServiceType>Messenger</ServiceType><ServiceType>IMAvailability</ServiceType></Types></serviceFilter><expandMembership>true</expandMembership>" \
    170170        "</FindMembership>"
    171171
  • protocols/nogaim.h

    r0e4c3dd r89db90e  
    180180        void (* set_away)       (struct im_connection *, char *state, char *message);
    181181        /* Implementing this function is optional. */
    182         void (* get_away)       (struct im_connection *, char *who);
    183         /* Implementing this function is optional. */
    184182        int (* send_typing)    (struct im_connection *, char *who, int flags);
    185183
     
    195193        void (* rem_permit)     (struct im_connection *, char *who);
    196194        void (* rem_deny)       (struct im_connection *, char *who);
    197         /* Doesn't actually have UI hooks. Not used at all, can be removed. */
    198         void (* set_permit_deny)(struct im_connection *);
    199195
    200196        /* Request profile info. Free-formatted stuff, the IM module gives back
    201197           this info via imcb_log(). Implementing these are optional. */
    202198        void (* get_info)       (struct im_connection *, char *who);
    203         /* set_my_name is *DEPRECATED*, not used by the UI anymore. Use the
    204            display_name setting instead. */
    205         void (* set_my_name)    (struct im_connection *, char *name);
    206         void (* set_name)       (struct im_connection *, char *who, char *name);
    207199
    208200        /* Group chat stuff. */
  • protocols/oscar/oscar.c

    r0e4c3dd r89db90e  
    19141914}
    19151915
    1916 static void oscar_get_away(struct im_connection *g, char *who)
    1917 {
    1918         struct oscar_data *odata = (struct oscar_data *) g->proto_data;
    1919 
    1920         if (odata->icq) {
    1921                 /** FIXME(wilmer): Hmm, lost the ability to get away msgs here, do we care to get that back?
    1922                 struct buddy *budlight = imcb_find_buddy(g, who);
    1923                 if (budlight)
    1924                         if ((budlight->uc & 0xff80) >> 7)
    1925                                 if (budlight->caps & AIM_CAPS_ICQSERVERRELAY)
    1926                                         aim_send_im_ch2_geticqmessage(odata->sess, who, (budlight->uc & 0xff80) >> 7);
    1927                 */
    1928         } else {
    1929                 aim_getinfo(odata->sess, odata->conn, who, AIM_GETINFO_AWAYMESSAGE);
    1930         }
    1931 }
    1932 
    19331916static void oscar_set_away_aim(struct im_connection *ic, struct oscar_data *od, const char *state, const char *message)
    19341917{
     
    27122695        ret->get_info = oscar_get_info;
    27132696        ret->set_away = oscar_set_away;
    2714         ret->get_away = oscar_get_away;
    27152697        ret->add_buddy = oscar_add_buddy;
    27162698        ret->remove_buddy = oscar_remove_buddy;
  • protocols/purple/ft-direct.c

    r0e4c3dd r89db90e  
    2828
    2929#include "bitlbee.h"
     30#include "bpurple.h"
    3031
    3132#include <stdarg.h>
     
    207208void purple_transfer_request(struct im_connection *ic, file_transfer_t *ft, char *handle)
    208209{
    209         PurpleAccount *pa = ic->proto_data;
     210        struct purple_data *pd = ic->proto_data;
    210211        struct prpl_xfer_data *px;
    211212
     
    213214           multi-threaded anyway. */
    214215        next_ft = ft;
    215         serv_send_file(purple_account_get_connection(pa), handle, ft->file_name);
     216        serv_send_file(purple_account_get_connection(pd->account), handle,
     217                       ft->file_name);
    216218
    217219        ft->write = prpl_xfer_write;
  • protocols/purple/ft.c

    r0e4c3dd r89db90e  
    2828
    2929#include "bitlbee.h"
     30#include "bpurple.h"
    3031
    3132#include <stdarg.h>
     
    285286{
    286287        struct prpl_xfer_data *px = ft->data;
    287         PurpleAccount *pa = px->ic->proto_data;
     288        struct purple_data *pd = px->ic->proto_data;
    288289
    289290        /* xfer_new() will pick up this variable. It's a hack but we're not
    290291           multi-threaded anyway. */
    291292        next_ft = ft;
    292         serv_send_file(purple_account_get_connection(pa), px->handle, px->fn);
     293        serv_send_file(purple_account_get_connection(pd->account),
     294                   px->handle, px->fn);
    293295}
    294296
  • protocols/purple/purple.c

    r0e4c3dd r89db90e  
    2323
    2424#include "bitlbee.h"
     25#include "bpurple.h"
    2526#include "help.h"
    2627
     
    4243{
    4344        GSList *i;
     45        struct purple_data *pd;
    4446
    4547        for (i = purple_connections; i; i = i->next) {
    46                 if (((struct im_connection *) i->data)->proto_data == pa) {
     48                pd = ((struct im_connection *) i->data)->proto_data;
     49                if (pd->account == pa) {
    4750                        return i->data;
    4851                }
     
    290293{
    291294        struct im_connection *ic = imcb_new(acc);
    292         PurpleAccount *pa;
     295        struct purple_data *pd;
    293296
    294297        if ((local_bee != NULL && local_bee != acc->bee) ||
     
    306309        purple_connections = g_slist_prepend(purple_connections, ic);
    307310
    308         ic->proto_data = pa = purple_account_new(acc->user, (char *) acc->prpl->data);
    309         purple_account_set_password(pa, acc->pass);
    310         purple_sync_settings(acc, pa);
    311 
    312         purple_account_set_enabled(pa, "BitlBee", TRUE);
     311        ic->proto_data = pd = g_new0(struct purple_data, 1);
     312        pd->account = purple_account_new(acc->user, (char *) acc->prpl->data);
     313        purple_account_set_password(pd->account, acc->pass);
     314        purple_sync_settings(acc, pd->account);
     315
     316        purple_account_set_enabled(pd->account, "BitlBee", TRUE);
    313317}
    314318
    315319static void purple_logout(struct im_connection *ic)
    316320{
    317         PurpleAccount *pa = ic->proto_data;
    318 
    319         purple_account_set_enabled(pa, "BitlBee", FALSE);
     321        struct purple_data *pd = ic->proto_data;
     322
     323        purple_account_set_enabled(pd->account, "BitlBee", FALSE);
    320324        purple_connections = g_slist_remove(purple_connections, ic);
    321         purple_accounts_remove(pa);
     325        purple_accounts_remove(pd->account);
     326        g_free(pd);
    322327}
    323328
     
    325330{
    326331        PurpleConversation *conv;
     332        struct purple_data *pd = ic->proto_data;
    327333
    328334        if ((conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM,
    329                                                           who, ic->proto_data)) == NULL) {
     335                                                          who, pd->account)) == NULL) {
    330336                conv = purple_conversation_new(PURPLE_CONV_TYPE_IM,
    331                                                ic->proto_data, who);
     337                                               pd->account, who);
    332338        }
    333339
     
    339345static GList *purple_away_states(struct im_connection *ic)
    340346{
    341         PurpleAccount *pa = ic->proto_data;
     347        struct purple_data *pd = ic->proto_data;
    342348        GList *st, *ret = NULL;
    343349
    344         for (st = purple_account_get_status_types(pa); st; st = st->next) {
     350        for (st = purple_account_get_status_types(pd->account); st; st = st->next) {
    345351                PurpleStatusPrimitive prim = purple_status_type_get_primitive(st->data);
    346352                if (prim != PURPLE_STATUS_AVAILABLE && prim != PURPLE_STATUS_OFFLINE) {
     
    354360static void purple_set_away(struct im_connection *ic, char *state_txt, char *message)
    355361{
    356         PurpleAccount *pa = ic->proto_data;
    357         GList *status_types = purple_account_get_status_types(pa), *st;
     362        struct purple_data *pd = ic->proto_data;
     363        GList *status_types = purple_account_get_status_types(pd->account), *st;
    358364        PurpleStatusType *pst = NULL;
    359365        GList *args = NULL;
     
    378384        }
    379385
    380         purple_account_set_status_list(pa, st ? purple_status_type_get_id(pst) : "away",
     386        purple_account_set_status_list(pd->account,
     387                                       st ? purple_status_type_get_id(pst) : "away",
    381388                                       TRUE, args);
    382389
     
    447454        PurpleBuddy *pb;
    448455        PurpleGroup *pg = NULL;
     456        struct purple_data *pd = ic->proto_data;
    449457
    450458        if (group && !(pg = purple_find_group(group))) {
     
    453461        }
    454462
    455         pb = purple_buddy_new((PurpleAccount *) ic->proto_data, who, NULL);
     463        pb = purple_buddy_new(pd->account, who, NULL);
    456464        purple_blist_add_buddy(pb, NULL, pg, NULL);
    457         purple_account_add_buddy((PurpleAccount *) ic->proto_data, pb);
    458 
    459         purple_gg_buddylist_export(((PurpleAccount *) ic->proto_data)->gc);
     465        purple_account_add_buddy(pd->account, pb);
     466
     467        purple_gg_buddylist_export(pd->account->gc);
    460468}
    461469
     
    463471{
    464472        PurpleBuddy *pb;
    465 
    466         pb = purple_find_buddy((PurpleAccount *) ic->proto_data, who);
     473        struct purple_data *pd = ic->proto_data;
     474
     475        pb = purple_find_buddy(pd->account, who);
    467476        if (pb != NULL) {
    468477                PurpleGroup *group;
    469478
    470479                group = purple_buddy_get_group(pb);
    471                 purple_account_remove_buddy((PurpleAccount *) ic->proto_data, pb, group);
     480                purple_account_remove_buddy(pd->account, pb, group);
    472481
    473482                purple_blist_remove_buddy(pb);
    474483        }
    475484
    476         purple_gg_buddylist_export(((PurpleAccount *) ic->proto_data)->gc);
     485        purple_gg_buddylist_export(pd->account->gc);
    477486}
    478487
    479488static void purple_add_permit(struct im_connection *ic, char *who)
    480489{
    481         PurpleAccount *pa = ic->proto_data;
    482 
    483         purple_privacy_permit_add(pa, who, FALSE);
     490        struct purple_data *pd = ic->proto_data;
     491
     492        purple_privacy_permit_add(pd->account, who, FALSE);
    484493}
    485494
    486495static void purple_add_deny(struct im_connection *ic, char *who)
    487496{
    488         PurpleAccount *pa = ic->proto_data;
    489 
    490         purple_privacy_deny_add(pa, who, FALSE);
     497        struct purple_data *pd = ic->proto_data;
     498
     499        purple_privacy_deny_add(pd->account, who, FALSE);
    491500}
    492501
    493502static void purple_rem_permit(struct im_connection *ic, char *who)
    494503{
    495         PurpleAccount *pa = ic->proto_data;
    496 
    497         purple_privacy_permit_remove(pa, who, FALSE);
     504        struct purple_data *pd = ic->proto_data;
     505
     506        purple_privacy_permit_remove(pd->account, who, FALSE);
    498507}
    499508
    500509static void purple_rem_deny(struct im_connection *ic, char *who)
    501510{
    502         PurpleAccount *pa = ic->proto_data;
    503 
    504         purple_privacy_deny_remove(pa, who, FALSE);
     511        struct purple_data *pd = ic->proto_data;
     512
     513        purple_privacy_deny_remove(pd->account, who, FALSE);
    505514}
    506515
    507516static void purple_get_info(struct im_connection *ic, char *who)
    508517{
    509         serv_get_info(purple_account_get_connection(ic->proto_data), who);
     518        struct purple_data *pd = ic->proto_data;
     519
     520        serv_get_info(purple_account_get_connection(pd->account), who);
    510521}
    511522
     
    517528{
    518529        PurpleTypingState state = PURPLE_NOT_TYPING;
    519         PurpleAccount *pa = ic->proto_data;
     530        struct purple_data *pd = ic->proto_data;
    520531
    521532        if (flags & OPT_TYPING) {
     
    525536        }
    526537
    527         serv_send_typing(purple_account_get_connection(pa), who, state);
     538        serv_send_typing(purple_account_get_connection(pd->account), who, state);
    528539
    529540        return 1;
     
    559570        /* There went my nice afternoon. :-( */
    560571
    561         PurpleAccount *pa = ic->proto_data;
    562         PurplePlugin *prpl = purple_plugins_find_with_id(pa->protocol_id);
     572        struct purple_data *pd = ic->proto_data;
     573        PurplePlugin *prpl = purple_plugins_find_with_id(pd->account->protocol_id);
    563574        PurplePluginProtocolInfo *pi = prpl->info->extra_info;
    564         PurpleBuddy *pb = purple_find_buddy((PurpleAccount *) ic->proto_data, who);
     575        PurpleBuddy *pb = purple_find_buddy(pd->account, who);
    565576        PurpleMenuAction *mi;
    566577        GList *menu;
     
    597608        PurpleConversation *pc = gc->data;
    598609        PurpleConvChat *pcc = PURPLE_CONV_CHAT(pc);
    599 
    600         serv_chat_invite(purple_account_get_connection(gc->ic->proto_data),
     610        struct purple_data *pd = gc->ic->proto_data;
     611
     612        serv_chat_invite(purple_account_get_connection(pd->account),
    601613                         purple_conv_chat_get_id(pcc),
    602614                         message && *message ? message : "Please join my chat",
     
    623635                                   set_t **sets)
    624636{
    625         PurpleAccount *pa = ic->proto_data;
    626         PurplePlugin *prpl = purple_plugins_find_with_id(pa->protocol_id);
     637        struct purple_data *pd = ic->proto_data;
     638        PurplePlugin *prpl = purple_plugins_find_with_id(pd->account->protocol_id);
    627639        PurplePluginProtocolInfo *pi = prpl->info->extra_info;
    628640        GHashTable *chat_hash;
     
    631643
    632644        if (!pi->chat_info || !pi->chat_info_defaults ||
    633             !(info = pi->chat_info(purple_account_get_connection(pa)))) {
     645            !(info = pi->chat_info(purple_account_get_connection(pd->account)))) {
    634646                imcb_error(ic, "Joining chatrooms not supported by this protocol");
    635647                return NULL;
    636648        }
    637649
    638         if ((conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, room, pa))) {
     650        if ((conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT,
     651                                                          room, pd->account))) {
    639652                purple_conversation_destroy(conv);
    640653        }
    641654
    642         chat_hash = pi->chat_info_defaults(purple_account_get_connection(pa), room);
     655        chat_hash = pi->chat_info_defaults(
     656                purple_account_get_connection(pd->account), room
     657        );
    643658
    644659        for (l = info; l; l = l->next) {
     
    654669        }
    655670
    656         serv_join_chat(purple_account_get_connection(pa), chat_hash);
     671        serv_join_chat(purple_account_get_connection(pd->account), chat_hash);
    657672
    658673        return NULL;
     
    10331048}
    10341049
     1050/* So it turns out some requests have no account context at all, because
     1051 * libpurple hates us. This means that query_del_by_conn() won't remove those
     1052 * on logout, and will segfault if the user replies. That's why this exists.
     1053 */
     1054static void prplcb_close_request(PurpleRequestType type, void *data)
     1055{
     1056        if (type == PURPLE_REQUEST_ACTION) {
     1057                struct prplcb_request_action_data *pqad = data;
     1058                query_del(local_bee->ui_data, pqad->bee_data);
     1059        }
     1060        /* Add the request input handler here when that becomes a thing */
     1061}
     1062
    10351063/*
    10361064static void prplcb_request_test()
     
    10471075        NULL,
    10481076        NULL,
    1049         NULL,
     1077        prplcb_close_request,
    10501078        NULL,
    10511079};
  • protocols/skype/Makefile

    r0e4c3dd r89db90e  
    66DATE := $(shell date +%Y-%m-%d)
    77INSTALL = install
    8 ASCIIDOC = yes
    98
    10 ifeq ($(ASCIIDOC),yes)
     9
     10ifdef ASCIIDOC
    1111MANPAGES = skyped.1
    1212else
     
    2929
    3030install-doc: doc
    31 ifeq ($(ASCIIDOC),yes)
     31ifdef ASCIIDOC
    3232        $(INSTALL) -d $(DESTDIR)$(MANDIR)/man1
    3333        $(INSTALL) -m644 $(MANPAGES) $(DESTDIR)$(MANDIR)/man1
  • protocols/twitter/twitter.c

    r0e4c3dd r89db90e  
    852852}
    853853
     854/* Parses a decimal or hex tweet ID, returns TRUE on success */
     855static gboolean twitter_parse_id(char *string, int base, guint64 *id)
     856{
     857        guint64 parsed;
     858        char *endptr;
     859
     860        errno = 0;
     861        parsed = g_ascii_strtoull(string, &endptr, base);
     862        if (errno || endptr == string || *endptr != '\0') {
     863                return FALSE;
     864        }
     865        *id = parsed;
     866        return TRUE;
     867}
     868
    854869/** Convert the given bitlbee tweet ID, bitlbee username, or twitter tweet ID
    855870 *  into a twitter tweet ID.
     
    879894                        arg++;
    880895                }
    881                 if (sscanf(arg, "%" G_GINT64_MODIFIER "x", &id) == 1 &&
    882                     id < TWITTER_LOG_LENGTH) {
     896                if (twitter_parse_id(arg, 16, &id) && id < TWITTER_LOG_LENGTH) {
    883897                        bu = td->log[id].bu;
    884898                        id = td->log[id].id;
     
    887901                                bu = NULL;
    888902                        }
    889                 } else if (sscanf(arg, "%" G_GINT64_MODIFIER "d", &id) == 1) {
     903                } else if (twitter_parse_id(arg, 10, &id)) {
    890904                        /* Allow normal tweet IDs as well; not a very useful
    891905                           feature but it's always been there. Just ignore
  • protocols/twitter/twitter_lib.c

    r0e4c3dd r89db90e  
    862862
    863863                imcb_error(ic, "Stream closed (%s)", req->status_string);
     864                if (req->status_code == 401) {
     865                        imcb_error(ic, "Check your system clock.");
     866                }
    864867                imc_logout(ic, TRUE);
    865868                return;
  • protocols/yahoo/yahoo.c

    r0e4c3dd r89db90e  
    733733                inp = l->data;
    734734                if (inp->h == tag) {
     735                        byahoo_inputs = g_slist_remove(byahoo_inputs, inp);
    735736                        g_free(inp->d);
    736737                        g_free(inp);
    737                         byahoo_inputs = g_slist_remove(byahoo_inputs, inp);
    738738                        break;
    739739                }
  • storage_xml.c

    r0e4c3dd r89db90e  
    103103        if (protocol) {
    104104                prpl = find_protocol(protocol);
     105                if (!prpl) {
     106                        irc_rootmsg(xd->irc, "Error loading user config: Protocol not found: `%s'", protocol);
     107                        return XT_ABORT;
     108                }
    105109                local = protocol_account_islocal(protocol);
    106110        }
     
    197201        fn = g_strconcat(global.conf->configdir, xd->given_nick, ".xml", NULL);
    198202        if ((fd = open(fn, O_RDONLY)) < 0) {
    199                 ret = STORAGE_NO_SUCH_USER;
     203                if (errno == ENOENT) {
     204                        ret = STORAGE_NO_SUCH_USER;
     205                } else {
     206                        irc_rootmsg(irc, "Error loading user config: %s", g_strerror(errno));
     207                }
    200208                goto error;
    201209        }
     
    259267
    260268
    261 static gboolean xml_generate_nick(gpointer key, gpointer value, gpointer data);
    262269static void xml_generate_settings(struct xt_node *cur, set_t **head);
    263270
     
    292299
    293300        for (acc = irc->b->accounts; acc; acc = acc->next) {
     301                GHashTableIter iter;
     302                gpointer key, value;
    294303                unsigned char *pass_cr;
    295304                char *pass_b64;
     
    312321                g_free(pass_b64);
    313322
    314                 /* This probably looks pretty strange. g_hash_table_foreach
    315                    is quite a PITA already (but it can't get much better in
    316                    C without using #define, I'm afraid), and it
    317                    doesn't seem to be possible to abort the foreach on write
    318                    errors, so instead let's use the _find function and
    319                    return TRUE on write errors. Which means, if we found
    320                    something, there was an error. :-) */
    321                 g_hash_table_find(acc->nicks, xml_generate_nick, cur);
     323                g_hash_table_iter_init(&iter, acc->nicks);
     324                while (g_hash_table_iter_next(&iter, &key, &value)) {
     325                        struct xt_node *node = xt_new_node("buddy", NULL, NULL);
     326                        xt_add_attr(node, "handle", key);
     327                        xt_add_attr(node, "nick", value);
     328                        xt_add_child(cur, node);
     329                }
    322330
    323331                xml_generate_settings(cur, &acc->set);
     
    343351
    344352        return root;
    345 }
    346 
    347 static gboolean xml_generate_nick(gpointer key, gpointer value, gpointer data)
    348 {
    349         struct xt_node *node = xt_new_node("buddy", NULL, NULL);
    350 
    351         xt_add_attr(node, "handle", key);
    352         xt_add_attr(node, "nick", value);
    353         xt_add_child((struct xt_node *) data, node);
    354 
    355         return FALSE;
    356353}
    357354
     
    388385        strcat(path, ".XXXXXX");
    389386        if ((fd = mkstemp(path)) < 0) {
    390                 irc_rootmsg(irc, "Error while opening configuration file.");
    391                 return STORAGE_OTHER_ERROR;
     387                goto error;
    392388        }
    393389
     
    411407
    412408error:
    413         irc_rootmsg(irc, "Write error. Disk full?");
     409        irc_rootmsg(irc, "Write error: %s", g_strerror(errno));
    414410        ret = STORAGE_OTHER_ERROR;
    415411
Note: See TracChangeset for help on using the changeset viewer.