Ignore:
Timestamp:
2015-02-20T22:50:54Z (9 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
0b9daac, 3d45471, 7733b8c
Parents:
af359b4
git-author:
Indent <please@…> (19-02-15 05:47:20)
git-committer:
dequis <dx@…> (20-02-15 22:50:54)
Message:

Reindent everything to K&R style with tabs

Used uncrustify, with the configuration file in ./doc/uncrustify.cfg

Commit author set to "Indent <please@…>" so that it's easier to
skip while doing git blame.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/oscar/oscar.c

    raf359b4 r5ebff60  
    5050#define USEROPT_AUTHPORT  1
    5151
    52 #define UC_AOL          0x02
    53 #define UC_ADMIN        0x04
    54 #define UC_UNCONFIRMED  0x08
    55 #define UC_NORMAL       0x10
    56 #define UC_AB           0x20
    57 #define UC_WIRELESS     0x40
     52#define UC_AOL          0x02
     53#define UC_ADMIN        0x04
     54#define UC_UNCONFIRMED  0x08
     55#define UC_NORMAL       0x10
     56#define UC_AB           0x20
     57#define UC_WIRELESS     0x40
    5858
    5959#define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3"
     
    6262
    6363#define BUF_LEN 2048
    64 #define BUF_LONG ( BUF_LEN * 2 )
     64#define BUF_LONG (BUF_LEN * 2)
    6565
    6666/* Don't know if support for UTF8 is really working. For now it's UTF16 here.
     
    6868
    6969static int gaim_caps = AIM_CAPS_INTEROP | AIM_CAPS_ICHAT | AIM_CAPS_ICQSERVERRELAY | AIM_CAPS_CHAT;
    70 static guint8 gaim_features[] = {0x01, 0x01, 0x01, 0x02};
     70static guint8 gaim_features[] = { 0x01, 0x01, 0x01, 0x02 };
    7171
    7272struct oscar_data {
     
    9494        gboolean icq;
    9595        GSList *evilhack;
    96        
     96
    9797        GHashTable *ips;
    9898
     
    139139};
    140140
    141 static char *extract_name(const char *name) {
     141static char *extract_name(const char *name)
     142{
    142143        char *tmp;
    143144        int i, j;
    144145        char *x = strchr(name, '-');
    145         if (!x) return g_strdup(name);
     146
     147        if (!x) {
     148                return g_strdup(name);
     149        }
    146150        x = strchr(++x, '-');
    147         if (!x) return g_strdup(name);
     151        if (!x) {
     152                return g_strdup(name);
     153        }
    148154        tmp = g_strdup(++x);
    149155
     
    156162                strncpy(hex, x + ++i, 2); hex[2] = 0;
    157163                i++;
    158                 tmp[j++] = (char)strtol(hex, NULL, 16);
     164                tmp[j++] = (char) strtol(hex, NULL, 16);
    159165        }
    160166
     
    164170
    165171static struct chat_connection *find_oscar_chat_by_conn(struct im_connection *ic,
    166                                                         aim_conn_t *conn) {
    167         GSList *g = ((struct oscar_data *)ic->proto_data)->oscar_chats;
     172                                                       aim_conn_t *conn)
     173{
     174        GSList *g = ((struct oscar_data *) ic->proto_data)->oscar_chats;
    168175        struct chat_connection *c = NULL;
    169176
    170177        while (g) {
    171                 c = (struct chat_connection *)g->data;
    172                 if (c->conn == conn)
     178                c = (struct chat_connection *) g->data;
     179                if (c->conn == conn) {
    173180                        break;
     181                }
    174182                g = g->next;
    175183                c = NULL;
     
    179187}
    180188
    181 static int gaim_parse_auth_resp  (aim_session_t *, aim_frame_t *, ...);
    182 static int gaim_parse_login      (aim_session_t *, aim_frame_t *, ...);
    183 static int gaim_parse_logout     (aim_session_t *, aim_frame_t *, ...);
    184 static int gaim_handle_redirect  (aim_session_t *, aim_frame_t *, ...);
    185 static int gaim_parse_oncoming   (aim_session_t *, aim_frame_t *, ...);
    186 static int gaim_parse_offgoing   (aim_session_t *, aim_frame_t *, ...);
     189static int gaim_parse_auth_resp(aim_session_t *, aim_frame_t *, ...);
     190static int gaim_parse_login(aim_session_t *, aim_frame_t *, ...);
     191static int gaim_parse_logout(aim_session_t *, aim_frame_t *, ...);
     192static int gaim_handle_redirect(aim_session_t *, aim_frame_t *, ...);
     193static int gaim_parse_oncoming(aim_session_t *, aim_frame_t *, ...);
     194static int gaim_parse_offgoing(aim_session_t *, aim_frame_t *, ...);
    187195static int gaim_parse_incoming_im(aim_session_t *, aim_frame_t *, ...);
    188 static int gaim_parse_misses     (aim_session_t *, aim_frame_t *, ...);
    189 static int gaim_parse_motd       (aim_session_t *, aim_frame_t *, ...);
    190 static int gaim_chatnav_info     (aim_session_t *, aim_frame_t *, ...);
    191 static int gaim_chat_join        (aim_session_t *, aim_frame_t *, ...);
    192 static int gaim_chat_leave       (aim_session_t *, aim_frame_t *, ...);
    193 static int gaim_chat_info_update (aim_session_t *, aim_frame_t *, ...);
     196static int gaim_parse_misses(aim_session_t *, aim_frame_t *, ...);
     197static int gaim_parse_motd(aim_session_t *, aim_frame_t *, ...);
     198static int gaim_chatnav_info(aim_session_t *, aim_frame_t *, ...);
     199static int gaim_chat_join(aim_session_t *, aim_frame_t *, ...);
     200static int gaim_chat_leave(aim_session_t *, aim_frame_t *, ...);
     201static int gaim_chat_info_update(aim_session_t *, aim_frame_t *, ...);
    194202static int gaim_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...);
    195 static int gaim_parse_ratechange (aim_session_t *, aim_frame_t *, ...);
    196 static int gaim_bosrights        (aim_session_t *, aim_frame_t *, ...);
    197 static int conninitdone_bos      (aim_session_t *, aim_frame_t *, ...);
    198 static int conninitdone_admin    (aim_session_t *, aim_frame_t *, ...);
    199 static int conninitdone_chat     (aim_session_t *, aim_frame_t *, ...);
    200 static int conninitdone_chatnav  (aim_session_t *, aim_frame_t *, ...);
    201 static int gaim_parse_msgerr     (aim_session_t *, aim_frame_t *, ...);
     203static int gaim_parse_ratechange(aim_session_t *, aim_frame_t *, ...);
     204static int gaim_bosrights(aim_session_t *, aim_frame_t *, ...);
     205static int conninitdone_bos(aim_session_t *, aim_frame_t *, ...);
     206static int conninitdone_admin(aim_session_t *, aim_frame_t *, ...);
     207static int conninitdone_chat(aim_session_t *, aim_frame_t *, ...);
     208static int conninitdone_chatnav(aim_session_t *, aim_frame_t *, ...);
     209static int gaim_parse_msgerr(aim_session_t *, aim_frame_t *, ...);
    202210static int gaim_parse_locaterights(aim_session_t *, aim_frame_t *, ...);
    203211static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...);
    204 static int gaim_parse_locerr     (aim_session_t *, aim_frame_t *, ...);
    205 static int gaim_icbm_param_info  (aim_session_t *, aim_frame_t *, ...);
    206 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...);
    207 static int gaim_selfinfo         (aim_session_t *, aim_frame_t *, ...);
    208 static int gaim_offlinemsg       (aim_session_t *, aim_frame_t *, ...);
    209 static int gaim_offlinemsgdone   (aim_session_t *, aim_frame_t *, ...);
    210 static int gaim_ssi_parserights  (aim_session_t *, aim_frame_t *, ...);
    211 static int gaim_ssi_parselist    (aim_session_t *, aim_frame_t *, ...);
    212 static int gaim_ssi_parseack     (aim_session_t *, aim_frame_t *, ...);
    213 static int gaim_parsemtn         (aim_session_t *, aim_frame_t *, ...);
    214 static int gaim_icqinfo          (aim_session_t *, aim_frame_t *, ...);
    215 static int gaim_parseaiminfo     (aim_session_t *, aim_frame_t *, ...);
     212static int gaim_parse_locerr(aim_session_t *, aim_frame_t *, ...);
     213static int gaim_icbm_param_info(aim_session_t *, aim_frame_t *, ...);
     214static int gaim_parse_genericerr(aim_session_t *, aim_frame_t *, ...);
     215static int gaim_selfinfo(aim_session_t *, aim_frame_t *, ...);
     216static int gaim_offlinemsg(aim_session_t *, aim_frame_t *, ...);
     217static int gaim_offlinemsgdone(aim_session_t *, aim_frame_t *, ...);
     218static int gaim_ssi_parserights(aim_session_t *, aim_frame_t *, ...);
     219static int gaim_ssi_parselist(aim_session_t *, aim_frame_t *, ...);
     220static int gaim_ssi_parseack(aim_session_t *, aim_frame_t *, ...);
     221static int gaim_parsemtn(aim_session_t *, aim_frame_t *, ...);
     222static int gaim_icqinfo(aim_session_t *, aim_frame_t *, ...);
     223static int gaim_parseaiminfo(aim_session_t *, aim_frame_t *, ...);
    216224
    217225static char *msgerrreason[] = {
     
    268276
    269277static gboolean oscar_callback(gpointer data, gint source,
    270                                 b_input_condition condition) {
    271         aim_conn_t *conn = (aim_conn_t *)data;
     278                               b_input_condition condition)
     279{
     280        aim_conn_t *conn = (aim_conn_t *) data;
    272281        aim_session_t *sess = aim_conn_getsess(conn);
    273282        struct im_connection *ic = sess ? sess->aux_data : NULL;
     
    278287                return FALSE;
    279288        }
    280      
     289
    281290        if (!g_slist_find(get_connections(), ic)) {
    282                 /* oh boy. this is probably bad. i guess the only thing we 
     291                /* oh boy. this is probably bad. i guess the only thing we
    283292                 * can really do is return? */
    284293                return FALSE;
    285294        }
    286295
    287         odata = (struct oscar_data *)ic->proto_data;
     296        odata = (struct oscar_data *) ic->proto_data;
    288297
    289298        if (condition & B_EV_IO_READ) {
    290299                if (aim_get_command(odata->sess, conn) >= 0) {
    291300                        aim_rxdispatch(odata->sess);
    292                                if (odata->killme)
    293                                        imc_logout(ic, !odata->no_reconnect);
     301                        if (odata->killme) {
     302                                imc_logout(ic, !odata->no_reconnect);
     303                        }
    294304                } else {
    295305                        if ((conn->type == AIM_CONN_TYPE_BOS) ||
    296                                    !(aim_getconn_type(odata->sess, AIM_CONN_TYPE_BOS))) {
     306                            !(aim_getconn_type(odata->sess, AIM_CONN_TYPE_BOS))) {
    297307                                imcb_error(ic, _("Disconnected."));
    298308                                imc_logout(ic, TRUE);
     
    300310                                struct chat_connection *c = find_oscar_chat_by_conn(ic, conn);
    301311                                c->conn = NULL;
    302                                 if (c->inpa > 0)
     312                                if (c->inpa > 0) {
    303313                                        b_event_remove(c->inpa);
     314                                }
    304315                                c->inpa = 0;
    305316                                c->fd = -1;
     
    307318                                imcb_error(sess->aux_data, _("You have been disconnected from chat room %s."), c->name);
    308319                        } else if (conn->type == AIM_CONN_TYPE_CHATNAV) {
    309                                 if (odata->cnpa > 0)
     320                                if (odata->cnpa > 0) {
    310321                                        b_event_remove(odata->cnpa);
     322                                }
    311323                                odata->cnpa = 0;
    312324                                while (odata->create_rooms) {
     
    314326                                        g_free(cr->name);
    315327                                        odata->create_rooms =
    316                                                 g_slist_remove(odata->create_rooms, cr);
     328                                                g_slist_remove(odata->create_rooms, cr);
    317329                                        g_free(cr);
    318330                                        imcb_error(sess->aux_data, _("Chat is currently unavailable"));
     
    320332                                aim_conn_kill(odata->sess, &conn);
    321333                        } else if (conn->type == AIM_CONN_TYPE_AUTH) {
    322                                 if (odata->paspa > 0)
     334                                if (odata->paspa > 0) {
    323335                                        b_event_remove(odata->paspa);
     336                                }
    324337                                odata->paspa = 0;
    325338                                aim_conn_kill(odata->sess, &conn);
     
    332345                return FALSE;
    333346        }
    334                
     347
    335348        return TRUE;
    336349}
     
    360373        aim_conn_completeconnect(sess, conn);
    361374        ic->inpa = b_input_add(conn->fd, B_EV_IO_READ,
    362                         oscar_callback, conn);
    363        
     375                               oscar_callback, conn);
     376
    364377        return FALSE;
    365378}
     
    369382        set_t *s;
    370383        gboolean icq = g_ascii_isdigit(acc->user[0]);
    371        
     384
    372385        if (icq) {
    373386                set_add(&acc->set, "ignore_auth_requests", "false", set_eval_bool, acc);
    374387                set_add(&acc->set, "old_icq_auth", "false", set_eval_bool, acc);
    375388        }
    376        
     389
    377390        s = set_add(&acc->set, "server",
    378391                    icq ? AIM_DEFAULT_LOGIN_SERVER_ICQ
    379                         : AIM_DEFAULT_LOGIN_SERVER_AIM, set_eval_account, acc);
     392                    : AIM_DEFAULT_LOGIN_SERVER_AIM, set_eval_account, acc);
    380393        s->flags |= SET_NOSAVE | ACC_SET_OFFLINE_ONLY;
    381        
     394
    382395        if (icq) {
    383396                s = set_add(&acc->set, "web_aware", "false", set_eval_bool, acc);
    384397                s->flags |= ACC_SET_OFFLINE_ONLY;
    385398        }
    386        
     399
    387400        acc->flags |= ACC_FLAG_AWAY_MESSAGE;
    388401}
    389402
    390 static void oscar_login(account_t *acc) {
     403static void oscar_login(account_t *acc)
     404{
    391405        aim_session_t *sess;
    392406        aim_conn_t *conn;
     
    394408        struct oscar_data *odata = ic->proto_data = g_new0(struct oscar_data, 1);
    395409
    396         if (g_ascii_isdigit(acc->user[0]))
     410        if (g_ascii_isdigit(acc->user[0])) {
    397411                odata->icq = TRUE;
    398         else
     412        } else {
    399413                ic->flags |= OPT_DOES_HTML;
     414        }
    400415
    401416        sess = g_new0(aim_session_t, 1);
     
    415430                return;
    416431        }
    417        
     432
    418433        imcb_log(ic, _("Signon: %s"), ic->acc->user);
    419434
     
    432447}
    433448
    434 static void oscar_logout(struct im_connection *ic) {
    435         struct oscar_data *odata = (struct oscar_data *)ic->proto_data;
    436        
     449static void oscar_logout(struct im_connection *ic)
     450{
     451        struct oscar_data *odata = (struct oscar_data *) ic->proto_data;
     452
    437453        while (odata->oscar_chats) {
    438454                struct chat_connection *n = odata->oscar_chats->data;
    439                 if (n->inpa > 0)
     455                if (n->inpa > 0) {
    440456                        b_event_remove(n->inpa);
     457                }
    441458                g_free(n->name);
    442459                g_free(n->show);
     
    450467                g_free(cr);
    451468        }
    452         if (odata->ips)
     469        if (odata->ips) {
    453470                g_hash_table_destroy(odata->ips);
    454         if (odata->email)
     471        }
     472        if (odata->email) {
    455473                g_free(odata->email);
    456         if (odata->newp)
     474        }
     475        if (odata->newp) {
    457476                g_free(odata->newp);
    458         if (odata->oldp)
     477        }
     478        if (odata->oldp) {
    459479                g_free(odata->oldp);
    460         if (ic->inpa > 0)
     480        }
     481        if (ic->inpa > 0) {
    461482                b_event_remove(ic->inpa);
    462         if (odata->cnpa > 0)
     483        }
     484        if (odata->cnpa > 0) {
    463485                b_event_remove(odata->cnpa);
    464         if (odata->paspa > 0)
     486        }
     487        if (odata->paspa > 0) {
    465488                b_event_remove(odata->paspa);
     489        }
    466490        aim_session_kill(odata->sess);
    467491        g_free(odata->sess);
     
    471495}
    472496
    473 static gboolean oscar_bos_connect(gpointer data, gint source, b_input_condition cond) {
     497static gboolean oscar_bos_connect(gpointer data, gint source, b_input_condition cond)
     498{
    474499        struct im_connection *ic = data;
    475500        struct oscar_data *odata;
     
    494519        aim_conn_completeconnect(sess, bosconn);
    495520        ic->inpa = b_input_add(bosconn->fd, B_EV_IO_READ,
    496                         oscar_callback, bosconn);
     521                               oscar_callback, bosconn);
    497522        imcb_log(ic, _("Connection established, cookie sent"));
    498        
     523
    499524        return FALSE;
    500525}
    501526
    502 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) {
     527static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...)
     528{
    503529        va_list ap;
    504530        struct aim_authresp_info *info;
     
    507533
    508534        struct im_connection *ic = sess->aux_data;
    509         struct oscar_data *od = ic->proto_data;
     535        struct oscar_data *od = ic->proto_data;
     536
    510537        port = AIM_LOGIN_PORT;
    511538
     
    521548                        {
    522549                                int max = od->icq ? 8 : 16;
    523                                 if (strlen(ic->acc->pass) > max)
     550                                if (strlen(ic->acc->pass) > max) {
    524551                                        imcb_log(ic, "Note that the maximum password "
    525552                                                 "length supported by this protocol is "
    526553                                                 "%d characters, try logging in using "
    527554                                                 "a shorter password.", max);
     555                                }
    528556                        }
    529557//                      plugin_event(event_error, (void *)980, 0, 0, 0);
     
    536564                        /* connecting too frequently */
    537565                        od->no_reconnect = TRUE;
    538                         imcb_error(ic, _("You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer."));
     566                        imcb_error(ic,
     567                                   _(
     568                                           "You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer."));
    539569                        break;
    540570                case 0x1c:
     
    589619        aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_parse_logout, 0);
    590620
    591         ((struct oscar_data *)ic->proto_data)->conn = bosconn;
    592         for (i = 0; i < (int)strlen(info->bosip); i++) {
     621        ((struct oscar_data *) ic->proto_data)->conn = bosconn;
     622        for (i = 0; i < (int) strlen(info->bosip); i++) {
    593623                if (info->bosip[i] == ':') {
    594                         port = atoi(&(info->bosip[i+1]));
     624                        port = atoi(&(info->bosip[i + 1]));
    595625                        break;
    596626                }
     
    614644#define AIM_MAX_FILE_SIZE 98304
    615645
    616 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) {
     646static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...)
     647{
    617648#if 0
    618         struct client_info_s info = {"gaim", 4, 1, 2010, "us", "en", 0x0004, 0x0000, 0x04b};
     649        struct client_info_s info = { "gaim", 4, 1, 2010, "us", "en", 0x0004, 0x0000, 0x04b };
    619650#else
    620651        struct client_info_s info = AIM_CLIENTINFO_KNOWNGOOD;
     
    633664}
    634665
    635 static int gaim_parse_logout(aim_session_t *sess, aim_frame_t *fr, ...) {
     666static int gaim_parse_logout(aim_session_t *sess, aim_frame_t *fr, ...)
     667{
    636668        struct im_connection *ic = sess->aux_data;
    637669        struct oscar_data *odata = ic->proto_data;
     
    642674        code = va_arg(ap, int);
    643675        va_end(ap);
    644        
    645         imcb_error( ic, "Connection aborted by server: %s", code == 1 ?
    646                         "someone else logged in with your account" :
    647                         "unknown reason" );
    648        
     676
     677        imcb_error(ic, "Connection aborted by server: %s", code == 1 ?
     678                   "someone else logged in with your account" :
     679                   "unknown reason");
     680
    649681        /* Tell BitlBee to disable auto_reconnect if code == 1, since that
    650682           means a concurrent login somewhere else. */
    651683        odata->no_reconnect = code == 1;
    652        
     684
    653685        /* DO NOT log out here! Just tell the callback to do it. */
    654686        odata->killme = TRUE;
     
    657689}
    658690
    659 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) {
     691static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...)
     692{
    660693        struct im_connection *ic = sess->aux_data;
    661694        struct chat_connection *chatcon;
     
    673706        chatcon = find_oscar_chat_by_conn(ic, fr->conn);
    674707        chatcon->id = id;
    675        
     708
    676709        c = bee_chat_by_title(ic->bee, ic, chatcon->show);
    677         if (c && !c->data)
     710        if (c && !c->data) {
    678711                chatcon->cnv = c;
    679         else
     712        } else {
    680713                chatcon->cnv = imcb_chat_new(ic, chatcon->show);
     714        }
    681715        chatcon->cnv->data = chatcon;
    682716
     
    684718}
    685719
    686 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) {
     720static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...)
     721{
    687722
    688723        aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_ERROR, gaim_parse_genericerr, 0);
     
    696731}
    697732
    698 static gboolean oscar_chatnav_connect(gpointer data, gint source, b_input_condition cond) {
     733static gboolean oscar_chatnav_connect(gpointer data, gint source, b_input_condition cond)
     734{
    699735        struct im_connection *ic = data;
    700736        struct oscar_data *odata;
     
    718754        aim_conn_completeconnect(sess, tstconn);
    719755        odata->cnpa = b_input_add(tstconn->fd, B_EV_IO_READ,
    720                                         oscar_callback, tstconn);
    721        
     756                                  oscar_callback, tstconn);
     757
    722758        return FALSE;
    723759}
     
    746782        aim_conn_completeconnect(sess, tstconn);
    747783        odata->paspa = b_input_add(tstconn->fd, B_EV_IO_READ,
    748                                 oscar_callback, tstconn);
    749        
     784                                   oscar_callback, tstconn);
     785
    750786        return FALSE;
    751787}
     
    781817        aim_conn_completeconnect(sess, ccon->conn);
    782818        ccon->inpa = b_input_add(tstconn->fd,
    783                         B_EV_IO_READ,
    784                         oscar_callback, tstconn);
     819                                 B_EV_IO_READ,
     820                                 oscar_callback, tstconn);
    785821        odata->oscar_chats = g_slist_append(odata->oscar_chats, ccon);
    786        
     822
    787823        return FALSE;
    788824}
    789825
    790826/* Hrmph. I don't know how to make this look better. --mid */
    791 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) {
     827static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...)
     828{
    792829        va_list ap;
    793830        struct aim_redirect_data *redir;
     
    803840
    804841        port = AIM_LOGIN_PORT;
    805         for (i = 0; i < (int)strlen(redir->ip); i++) {
     842        for (i = 0; i < (int) strlen(redir->ip); i++) {
    806843                if (redir->ip[i] == ':') {
    807                         port = atoi(&(redir->ip[i+1]));
     844                        port = atoi(&(redir->ip[i + 1]));
    808845                        break;
    809846                }
     
    811848        host = g_strndup(redir->ip, i);
    812849
    813         switch(redir->group) {
     850        switch (redir->group) {
    814851        case 0x7: /* Authorizer */
    815852                tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL);
     
    818855                        return 1;
    819856                }
    820                 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0);
     857                aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin,
     858                                    0);
    821859//              aim_conn_addhandler(sess, tstconn, 0x0007, 0x0003, gaim_info_change, 0);
    822860//              aim_conn_addhandler(sess, tstconn, 0x0007, 0x0005, gaim_info_change, 0);
     
    838876                        return 1;
    839877                }
    840                 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0);
     878                aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE,
     879                                    conninitdone_chatnav, 0);
    841880
    842881                tstconn->status |= AIM_CONN_STATUS_INPROGRESS;
     
    850889                break;
    851890        case 0xe: /* Chat */
    852                 {
     891        {
    853892                struct chat_connection *ccon;
    854893
     
    859898                }
    860899
    861                 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0);
     900                aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat,
     901                                    0);
    862902
    863903                ccon = g_new0(struct chat_connection, 1);
     
    869909                ccon->instance = redir->chat.instance;
    870910                ccon->show = extract_name(redir->chat.room);
    871                
     911
    872912                ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS;
    873913                ccon->conn->fd = proxy_connect(host, port, oscar_chat_connect, ccon);
     
    881921                }
    882922                aim_sendcookie(sess, tstconn, redir->cookie);
    883                 }
    884                 break;
     923        }
     924        break;
    885925        default: /* huh? */
    886926                break;
     
    891931}
    892932
    893 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) {
     933static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...)
     934{
    894935        struct im_connection *ic = sess->aux_data;
    895936        struct oscar_data *od = ic->proto_data;
     
    900941
    901942        va_list ap;
     943
    902944        va_start(ap, fr);
    903945        info = va_arg(ap, aim_userinfo_t *);
     
    905947
    906948        if ((!od->icq) && (info->present & AIM_USERINFO_PRESENT_FLAGS)) {
    907                 if (info->flags & AIM_FLAG_AWAY)
     949                if (info->flags & AIM_FLAG_AWAY) {
    908950                        flags |= OPT_AWAY;
    909         }
    910        
     951                }
     952        }
     953
    911954        /* Maybe this should be done just for AIM contacts, not sure. */
    912         if (info->flags & AIM_FLAG_WIRELESS)
     955        if (info->flags & AIM_FLAG_WIRELESS) {
    913956                flags |= OPT_MOBILE;
    914        
     957        }
     958
    915959        if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) {
    916960                if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) &&
    917                       (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) {
     961                    (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) {
    918962                        flags |= OPT_AWAY;
    919963                }
    920                
    921                 if( info->icqinfo.status & AIM_ICQ_STATE_DND )
     964
     965                if (info->icqinfo.status & AIM_ICQ_STATE_DND) {
    922966                        state_string = "Do Not Disturb";
    923                 else if( info->icqinfo.status & AIM_ICQ_STATE_OUT )
     967                } else if (info->icqinfo.status & AIM_ICQ_STATE_OUT) {
    924968                        state_string = "Not Available";
    925                 else if( info->icqinfo.status & AIM_ICQ_STATE_BUSY )
     969                } else if (info->icqinfo.status & AIM_ICQ_STATE_BUSY) {
    926970                        state_string = "Occupied";
    927                 else if( info->icqinfo.status & AIM_ICQ_STATE_INVISIBLE )
     971                } else if (info->icqinfo.status & AIM_ICQ_STATE_INVISIBLE) {
    928972                        state_string = "Invisible";
     973                }
    929974        }
    930975
    931976        if (info->present & AIM_USERINFO_PRESENT_IDLE) {
    932977                time(&time_idle);
    933                 time_idle -= info->idletime*60;
    934         }
    935 
    936         if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN)
     978                time_idle -= info->idletime * 60;
     979        }
     980
     981        if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) {
    937982                signon = time(NULL) - info->sessionlen;
     983        }
    938984
    939985        if (info->present & AIM_USERINFO_PRESENT_ICQIPADDR) {
    940986                uint32_t *uin = g_new0(uint32_t, 1);
    941                
    942                 if (od->ips == NULL)
     987
     988                if (od->ips == NULL) {
    943989                        od->ips = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, NULL);
    944                
    945                 if (sscanf(info->sn, "%d", uin) == 1)
     990                }
     991
     992                if (sscanf(info->sn, "%d", uin) == 1) {
    946993                        g_hash_table_insert(od->ips, uin, (gpointer) (long) info->icqinfo.ipaddr);
     994                }
    947995        }
    948996
     
    9551003}
    9561004
    957 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) {
     1005static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...)
     1006{
    9581007        aim_userinfo_t *info;
    9591008        va_list ap;
     
    9641013        va_end(ap);
    9651014
    966         imcb_buddy_status(ic, normalize(info->sn), 0, NULL, NULL );
    967 
    968         return 1;
    969 }
    970 
    971 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) {
     1015        imcb_buddy_status(ic, normalize(info->sn), 0, NULL, NULL);
     1016
     1017        return 1;
     1018}
     1019
     1020static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo,
     1021                            struct aim_incomingim_ch1_args *args)
     1022{
    9721023        char *tmp = g_malloc(BUF_LONG + 1);
    9731024        struct im_connection *ic = sess->aux_data;
    9741025        int flags = 0;
    975        
    976         if (args->icbmflags & AIM_IMFLAGS_AWAY)
     1026
     1027        if (args->icbmflags & AIM_IMFLAGS_AWAY) {
    9771028                flags |= OPT_AWAY;
    978        
     1029        }
     1030
    9791031        if ((args->icbmflags & AIM_IMFLAGS_UNICODE) || (args->icbmflags & AIM_IMFLAGS_ISO_8859_1)) {
    9801032                char *src;
    981                
    982                 if (args->icbmflags & AIM_IMFLAGS_UNICODE)
     1033
     1034                if (args->icbmflags & AIM_IMFLAGS_UNICODE) {
    9831035                        src = "UCS-2BE";
    984                 else
     1036                } else {
    9851037                        src = "ISO8859-1";
    986                
     1038                }
     1039
    9871040                /* Try to use iconv first to convert the message to UTF8 - which is what BitlBee expects */
    9881041                if (do_iconv(src, "UTF-8", args->msg, tmp, args->msglen, BUF_LONG) >= 0) {
     
    9901043                } else if (args->icbmflags & AIM_IMFLAGS_UNICODE) {
    9911044                        int i;
    992                        
     1045
    9931046                        for (i = 0, tmp[0] = '\0'; i < args->msglen; i += 2) {
    9941047                                unsigned short uni;
    995                                
    996                                 uni = ((args->msg[i] & 0xff) << 8) | (args->msg[i+1] & 0xff);
    997        
     1048
     1049                                uni = ((args->msg[i] & 0xff) << 8) | (args->msg[i + 1] & 0xff);
     1050
    9981051                                if ((uni < 128) || ((uni >= 160) && (uni <= 255))) { /* ISO 8859-1 */
    999                                         g_snprintf(tmp+strlen(tmp), BUF_LONG-strlen(tmp), "%c", uni);
     1052                                        g_snprintf(tmp + strlen(tmp), BUF_LONG - strlen(tmp), "%c", uni);
    10001053                                } else { /* something else, do UNICODE entity */
    1001                                         g_snprintf(tmp+strlen(tmp), BUF_LONG-strlen(tmp), "&#%04x;", uni);
     1054                                        g_snprintf(tmp + strlen(tmp), BUF_LONG - strlen(tmp), "&#%04x;", uni);
    10021055                                }
    10031056                        }
     
    10091062        } else {
    10101063                aim_mpmsg_section_t *part;
    1011                
     1064
    10121065                *tmp = 0;
    10131066                for (part = args->mpmsg.parts; part; part = part->next) {
    10141067                        if (part->data) {
    1015                                 g_strlcat(tmp, (char*) part->data, BUF_LONG);
     1068                                g_strlcat(tmp, (char *) part->data, BUF_LONG);
    10161069                                g_strlcat(tmp, "\n", BUF_LONG);
    10171070                        }
    10181071                }
    10191072        }
    1020        
     1073
    10211074        strip_linefeed(tmp);
    10221075        imcb_buddy_msg(ic, normalize(userinfo->sn), tmp, flags, 0);
    10231076        g_free(tmp);
    1024        
     1077
    10251078        return 1;
    10261079}
     
    10281081void oscar_accept_chat(void *data);
    10291082void oscar_reject_chat(void *data);
    1030        
    1031 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) {
     1083
     1084static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo,
     1085                            struct aim_incomingim_ch2_args *args)
     1086{
    10321087        struct im_connection *ic = sess->aux_data;
    10331088
    1034         if (args->status != AIM_RENDEZVOUS_PROPOSE)
     1089        if (args->status != AIM_RENDEZVOUS_PROPOSE) {
    10351090                return 1;
     1091        }
    10361092
    10371093        if (args->reqclass & AIM_CAPS_CHAT) {
     
    10511107                inv->exchange = *exch;
    10521108                inv->name = g_strdup(name);
    1053                
     1109
    10541110                imcb_ask(ic, txt, inv, oscar_accept_chat, oscar_reject_chat);
    1055        
    1056                 if (name)
     1111
     1112                if (name) {
    10571113                        g_free(name);
     1114                }
    10581115        } else if (args->reqclass & AIM_CAPS_ICQRTF) {
    10591116                // TODO: constify
    1060                 char text[strlen(args->info.rtfmsg.rtfmsg)+1];
     1117                char text[strlen(args->info.rtfmsg.rtfmsg) + 1];
    10611118                strncpy(text, args->info.rtfmsg.rtfmsg, sizeof(text));
    10621119                imcb_buddy_msg(ic, normalize(userinfo->sn), text, 0, 0);
     
    10661123}
    10671124
    1068 static void gaim_icq_authgrant(void *data_) {
     1125static void gaim_icq_authgrant(void *data_)
     1126{
    10691127        struct icq_auth *data = data_;
    10701128        char *uin;
    1071         struct oscar_data *od = (struct oscar_data *)data->ic->proto_data;
    1072        
     1129        struct oscar_data *od = (struct oscar_data *) data->ic->proto_data;
     1130
    10731131        uin = g_strdup_printf("%u", data->uin);
    10741132        aim_ssi_auth_reply(od->sess, od->conn, uin, 1, "");
     
    10761134        // aim_send_im_ch4(od->sess, uin, AIM_ICQMSG_AUTHGRANTED, &message);
    10771135        imcb_ask_add(data->ic, uin, NULL);
    1078        
     1136
    10791137        g_free(uin);
    10801138        g_free(data);
    10811139}
    10821140
    1083 static void gaim_icq_authdeny(void *data_) {
     1141static void gaim_icq_authdeny(void *data_)
     1142{
    10841143        struct icq_auth *data = data_;
    10851144        char *uin, *message;
    1086         struct oscar_data *od = (struct oscar_data *)data->ic->proto_data;
    1087        
     1145        struct oscar_data *od = (struct oscar_data *) data->ic->proto_data;
     1146
    10881147        uin = g_strdup_printf("%u", data->uin);
    10891148        message = g_strdup_printf("No reason given.");
     
    10911150        // aim_send_im_ch4(od->sess, uin, AIM_ICQMSG_AUTHDENIED, message);
    10921151        g_free(message);
    1093        
     1152
    10941153        g_free(uin);
    10951154        g_free(data);
     
    10991158 * For when other people ask you for authorization
    11001159 */
    1101 static void gaim_icq_authask(struct im_connection *ic, guint32 uin, char *msg) {
     1160static void gaim_icq_authask(struct im_connection *ic, guint32 uin, char *msg)
     1161{
    11021162        struct icq_auth *data;
    11031163        char *reason = NULL;
    11041164        char *dialog_msg;
    11051165
    1106         if (set_getbool(&ic->acc->set, "ignore_auth_requests"))
     1166        if (set_getbool(&ic->acc->set, "ignore_auth_requests")) {
    11071167                return;
    1108        
     1168        }
     1169
    11091170        data = g_new(struct icq_auth, 1);
    11101171
    1111         if (strlen(msg) > 6)
     1172        if (strlen(msg) > 6) {
    11121173                reason = msg + 6;
    1113        
    1114         dialog_msg = g_strdup_printf("The user %u wants to add you to their buddy list for the following reason: %s", uin, reason ? reason : "No reason given.");
     1174        }
     1175
     1176        dialog_msg = g_strdup_printf("The user %u wants to add you to their buddy list for the following reason: %s",
     1177                                     uin, reason ? reason : "No reason given.");
    11151178        data->ic = ic;
    11161179        data->uin = uin;
     
    11191182}
    11201183
    1121 static int incomingim_chan4(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch4_args *args) {
     1184static int incomingim_chan4(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo,
     1185                            struct aim_incomingim_ch4_args *args)
     1186{
    11221187        struct im_connection *ic = sess->aux_data;
    11231188
    11241189        switch (args->type) {
    1125                 case 0x0001: { /* An almost-normal instant message.  Mac ICQ sends this.  It's peculiar. */
    1126                         char *uin, *message;
    1127                         uin = g_strdup_printf("%u", args->uin);
    1128                         message = g_strdup(args->msg);
    1129                         strip_linefeed(message);
    1130                         imcb_buddy_msg(ic, normalize(uin), message, 0, 0);
    1131                         g_free(uin);
    1132                         g_free(message);
    1133                 } break;
    1134 
    1135                 case 0x0004: { /* Someone sent you a URL */
    1136                         char *uin, *message;
    1137                         char **m;
    1138        
    1139                         uin = g_strdup_printf("%u", args->uin);
    1140                         m = g_strsplit(args->msg, "\376", 2);
    1141 
    1142                         if ((strlen(m[0]) != 0)) {
    1143                           message = g_strjoinv(" -- ", m);
    1144                         } else {
    1145                           message = m[1];
    1146                         }
    1147 
    1148                         strip_linefeed(message);
    1149                         imcb_buddy_msg(ic, normalize(uin), message, 0, 0);
    1150                         g_free(uin);
    1151                         g_free(m);
    1152                         g_free(message);
    1153                 } break;
    1154                
    1155                 case 0x0006: { /* Someone requested authorization */
    1156                         gaim_icq_authask(ic, args->uin, args->msg);
    1157                 } break;
    1158 
    1159                 case 0x0007: { /* Someone has denied you authorization */
    1160                         imcb_log(sess->aux_data, "The user %u has denied your request to add them to your contact list for the following reason:\n%s", args->uin, args->msg ? args->msg : _("No reason given.") );
    1161                 } break;
    1162 
    1163                 case 0x0008: { /* Someone has granted you authorization */
    1164                         imcb_log(sess->aux_data, "The user %u has granted your request to add them to your contact list for the following reason:\n%s", args->uin, args->msg ? args->msg : _("No reason given.") );
    1165                 } break;
    1166 
    1167                 case 0x0012: {
    1168                         /* Ack for authorizing/denying someone.  Or possibly an ack for sending any system notice */
    1169                 } break;
    1170 
    1171                 default: {;
    1172                 } break;
    1173         }
    1174 
    1175         return 1;
    1176 }
    1177 
    1178 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) {
     1190        case 0x0001: {         /* An almost-normal instant message.  Mac ICQ sends this.  It's peculiar. */
     1191                char *uin, *message;
     1192                uin = g_strdup_printf("%u", args->uin);
     1193                message = g_strdup(args->msg);
     1194                strip_linefeed(message);
     1195                imcb_buddy_msg(ic, normalize(uin), message, 0, 0);
     1196                g_free(uin);
     1197                g_free(message);
     1198        } break;
     1199
     1200        case 0x0004: {         /* Someone sent you a URL */
     1201                char *uin, *message;
     1202                char **m;
     1203
     1204                uin = g_strdup_printf("%u", args->uin);
     1205                m = g_strsplit(args->msg, "\376", 2);
     1206
     1207                if ((strlen(m[0]) != 0)) {
     1208                        message = g_strjoinv(" -- ", m);
     1209                } else {
     1210                        message = m[1];
     1211                }
     1212
     1213                strip_linefeed(message);
     1214                imcb_buddy_msg(ic, normalize(uin), message, 0, 0);
     1215                g_free(uin);
     1216                g_free(m);
     1217                g_free(message);
     1218        } break;
     1219
     1220        case 0x0006: {         /* Someone requested authorization */
     1221                gaim_icq_authask(ic, args->uin, args->msg);
     1222        } break;
     1223
     1224        case 0x0007: {         /* Someone has denied you authorization */
     1225                imcb_log(sess->aux_data,
     1226                         "The user %u has denied your request to add them to your contact list for the following reason:\n%s", args->uin,
     1227                         args->msg ? args->msg : _("No reason given."));
     1228        } break;
     1229
     1230        case 0x0008: {         /* Someone has granted you authorization */
     1231                imcb_log(sess->aux_data,
     1232                         "The user %u has granted your request to add them to your contact list for the following reason:\n%s", args->uin,
     1233                         args->msg ? args->msg : _("No reason given."));
     1234        } break;
     1235
     1236        case 0x0012: {
     1237                /* Ack for authorizing/denying someone.  Or possibly an ack for sending any system notice */
     1238        } break;
     1239
     1240        default: {; } break;
     1241        }
     1242
     1243        return 1;
     1244}
     1245
     1246static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...)
     1247{
    11791248        int channel, ret = 0;
    11801249        aim_userinfo_t *userinfo;
     
    11861255
    11871256        switch (channel) {
    1188                 case 1: { /* standard message */
    1189                         struct aim_incomingim_ch1_args *args;
    1190                         args = va_arg(ap, struct aim_incomingim_ch1_args *);
    1191                         ret = incomingim_chan1(sess, fr->conn, userinfo, args);
    1192                 } break;
    1193 
    1194                 case 2: { /* rendevous */
    1195                         struct aim_incomingim_ch2_args *args;
    1196                         args = va_arg(ap, struct aim_incomingim_ch2_args *);
    1197                         ret = incomingim_chan2(sess, fr->conn, userinfo, args);
    1198                 } break;
    1199 
    1200                 case 4: { /* ICQ */
    1201                         struct aim_incomingim_ch4_args *args;
    1202                         args = va_arg(ap, struct aim_incomingim_ch4_args *);
    1203                         ret = incomingim_chan4(sess, fr->conn, userinfo, args);
    1204                 } break;
    1205 
    1206                 default: {;
    1207                 } break;
     1257        case 1: {         /* standard message */
     1258                struct aim_incomingim_ch1_args *args;
     1259                args = va_arg(ap, struct aim_incomingim_ch1_args *);
     1260                ret = incomingim_chan1(sess, fr->conn, userinfo, args);
     1261        } break;
     1262
     1263        case 2: {         /* rendevous */
     1264                struct aim_incomingim_ch2_args *args;
     1265                args = va_arg(ap, struct aim_incomingim_ch2_args *);
     1266                ret = incomingim_chan2(sess, fr->conn, userinfo, args);
     1267        } break;
     1268
     1269        case 4: {         /* ICQ */
     1270                struct aim_incomingim_ch4_args *args;
     1271                args = va_arg(ap, struct aim_incomingim_ch4_args *);
     1272                ret = incomingim_chan4(sess, fr->conn, userinfo, args);
     1273        } break;
     1274
     1275        default: {; } break;
    12081276        }
    12091277
     
    12131281}
    12141282
    1215 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) {
     1283static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...)
     1284{
    12161285        va_list ap;
    12171286        guint16 nummissed, reason;
     
    12211290        va_arg(ap, unsigned int); /* chan */
    12221291        userinfo = va_arg(ap, aim_userinfo_t *);
    1223         nummissed = (guint16)va_arg(ap, unsigned int);
    1224         reason = (guint16)va_arg(ap, unsigned int);
     1292        nummissed = (guint16) va_arg(ap, unsigned int);
     1293        reason = (guint16) va_arg(ap, unsigned int);
    12251294        va_end(ap);
    12261295
    1227         switch(reason) {
    1228                 case 0:
    1229                         /* Invalid (0) */
    1230                         imcb_error(sess->aux_data,
    1231                                    nummissed == 1 ?
    1232                                    _("You missed %d message from %s because it was invalid.") :
    1233                                    _("You missed %d messages from %s because they were invalid."),
    1234                                    nummissed,
    1235                                    userinfo->sn);
    1236                         break;
    1237                 case 1:
    1238                         /* Message too large */
    1239                         imcb_error(sess->aux_data,
    1240                                    nummissed == 1 ?
    1241                                    _("You missed %d message from %s because it was too large.") :
    1242                                    _("You missed %d messages from %s because they were too large."),
    1243                                    nummissed,
    1244                                    userinfo->sn);
    1245                         break;
    1246                 case 2:
    1247                         /* Rate exceeded */
    1248                         imcb_error(sess->aux_data,
    1249                                    nummissed == 1 ?
    1250                                    _("You missed %d message from %s because the rate limit has been exceeded.") :
    1251                                    _("You missed %d messages from %s because the rate limit has been exceeded."),
    1252                                    nummissed,
    1253                                    userinfo->sn);
    1254                         break;
    1255                 case 3:
    1256                         /* Evil Sender */
    1257                         imcb_error(sess->aux_data,
    1258                                    nummissed == 1 ?
    1259                                    _("You missed %d message from %s because it was too evil.") :
    1260                                    _("You missed %d messages from %s because they are too evil."),
    1261                                    nummissed,
    1262                                    userinfo->sn);
    1263                         break;
    1264                 case 4:
    1265                         /* Evil Receiver */
    1266                         imcb_error(sess->aux_data,
    1267                                    nummissed == 1 ?
    1268                                    _("You missed %d message from %s because you are too evil.") :
    1269                                    _("You missed %d messages from %s because you are too evil."),
    1270                                    nummissed,
    1271                                    userinfo->sn);
    1272                         break;
    1273                 default:
    1274                         imcb_error(sess->aux_data,
    1275                                    nummissed == 1 ?
    1276                                    _("You missed %d message from %s for unknown reasons.") :
    1277                                    _("You missed %d messages from %s for unknown reasons."),
    1278                                    nummissed,
    1279                                    userinfo->sn);
    1280                         break;
    1281         }
    1282 
    1283         return 1;
    1284 }
    1285 
    1286 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) {
     1296        switch (reason) {
     1297        case 0:
     1298                /* Invalid (0) */
     1299                imcb_error(sess->aux_data,
     1300                           nummissed == 1 ?
     1301                           _("You missed %d message from %s because it was invalid.") :
     1302                           _("You missed %d messages from %s because they were invalid."),
     1303                           nummissed,
     1304                           userinfo->sn);
     1305                break;
     1306        case 1:
     1307                /* Message too large */
     1308                imcb_error(sess->aux_data,
     1309                           nummissed == 1 ?
     1310                           _("You missed %d message from %s because it was too large.") :
     1311                           _("You missed %d messages from %s because they were too large."),
     1312                           nummissed,
     1313                           userinfo->sn);
     1314                break;
     1315        case 2:
     1316                /* Rate exceeded */
     1317                imcb_error(sess->aux_data,
     1318                           nummissed == 1 ?
     1319                           _("You missed %d message from %s because the rate limit has been exceeded.") :
     1320                           _("You missed %d messages from %s because the rate limit has been exceeded."),
     1321                           nummissed,
     1322                           userinfo->sn);
     1323                break;
     1324        case 3:
     1325                /* Evil Sender */
     1326                imcb_error(sess->aux_data,
     1327                           nummissed == 1 ?
     1328                           _("You missed %d message from %s because it was too evil.") :
     1329                           _("You missed %d messages from %s because they are too evil."),
     1330                           nummissed,
     1331                           userinfo->sn);
     1332                break;
     1333        case 4:
     1334                /* Evil Receiver */
     1335                imcb_error(sess->aux_data,
     1336                           nummissed == 1 ?
     1337                           _("You missed %d message from %s because you are too evil.") :
     1338                           _("You missed %d messages from %s because you are too evil."),
     1339                           nummissed,
     1340                           userinfo->sn);
     1341                break;
     1342        default:
     1343                imcb_error(sess->aux_data,
     1344                           nummissed == 1 ?
     1345                           _("You missed %d message from %s for unknown reasons.") :
     1346                           _("You missed %d messages from %s for unknown reasons."),
     1347                           nummissed,
     1348                           userinfo->sn);
     1349                break;
     1350        }
     1351
     1352        return 1;
     1353}
     1354
     1355static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...)
     1356{
    12871357        va_list ap;
    12881358        guint16 reason;
    12891359
    12901360        va_start(ap, fr);
    1291         reason = (guint16)va_arg(ap, unsigned int);
     1361        reason = (guint16) va_arg(ap, unsigned int);
    12921362        va_end(ap);
    12931363
    12941364        imcb_error(sess->aux_data, _("SNAC threw error: %s"),
    1295                   reason < msgerrreasonlen ? msgerrreason[reason] : "Unknown error");
    1296 
    1297         return 1;
    1298 }
    1299 
    1300 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) {
     1365                   reason < msgerrreasonlen ? msgerrreason[reason] : "Unknown error");
     1366
     1367        return 1;
     1368}
     1369
     1370static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...)
     1371{
    13011372        va_list ap;
    13021373        char *destn;
     
    13041375
    13051376        va_start(ap, fr);
    1306         reason = (guint16)va_arg(ap, unsigned int);
     1377        reason = (guint16) va_arg(ap, unsigned int);
    13071378        destn = va_arg(ap, char *);
    13081379        va_end(ap);
    13091380
    13101381        imcb_error(sess->aux_data, _("Your message to %s did not get sent: %s"), destn,
    1311                         (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Reason unknown"));
    1312 
    1313         return 1;
    1314 }
    1315 
    1316 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) {
     1382                   (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Reason unknown"));
     1383
     1384        return 1;
     1385}
     1386
     1387static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...)
     1388{
    13171389        va_list ap;
    13181390        char *destn;
     
    13201392
    13211393        va_start(ap, fr);
    1322         reason = (guint16)va_arg(ap, unsigned int);
     1394        reason = (guint16) va_arg(ap, unsigned int);
    13231395        destn = va_arg(ap, char *);
    13241396        va_end(ap);
    13251397
    13261398        imcb_error(sess->aux_data, _("User information for %s unavailable: %s"), destn,
    1327                         (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Reason unknown"));
    1328 
    1329         return 1;
    1330 }
    1331 
    1332 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) {
     1399                   (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Reason unknown"));
     1400
     1401        return 1;
     1402}
     1403
     1404static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...)
     1405{
    13331406        guint16 id;
    13341407        va_list ap;
    13351408
    13361409        va_start(ap, fr);
    1337         id  = (guint16)va_arg(ap, unsigned int);
     1410        id  = (guint16) va_arg(ap, unsigned int);
    13381411        va_arg(ap, char *); /* msg */
    13391412        va_end(ap);
    13401413
    1341         if (id < 4)
     1414        if (id < 4) {
    13421415                imcb_error(sess->aux_data, _("Your connection may be lost."));
    1343 
    1344         return 1;
    1345 }
    1346 
    1347 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) {
     1416        }
     1417
     1418        return 1;
     1419}
     1420
     1421static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...)
     1422{
    13481423        va_list ap;
    13491424        guint16 type;
    13501425        struct im_connection *ic = sess->aux_data;
    1351         struct oscar_data *odata = (struct oscar_data *)ic->proto_data;
     1426        struct oscar_data *odata = (struct oscar_data *) ic->proto_data;
    13521427
    13531428        va_start(ap, fr);
    1354         type = (guint16)va_arg(ap, unsigned int);
    1355 
    1356         switch(type) {
    1357                 case 0x0002: {
    1358                         va_arg(ap, unsigned int); /* maxrooms */
    1359                         va_arg(ap, int); /* exchangecount */
    1360                         va_arg(ap, struct aim_chat_exchangeinfo *); /* exchanges */
    1361                         va_end(ap);
    1362 
    1363                         while (odata->create_rooms) {
    1364                                 struct create_room *cr = odata->create_rooms->data;
    1365                                 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange);
    1366                                 g_free(cr->name);
    1367                                 odata->create_rooms = g_slist_remove(odata->create_rooms, cr);
    1368                                 g_free(cr);
    1369                         }
    1370                         }
    1371                         break;
    1372                 case 0x0008: {
    1373                         char *ck;
    1374                         guint16 instance, exchange;
    1375 
    1376                         va_arg(ap, char *); /* fqcn */
    1377                         instance = (guint16)va_arg(ap, unsigned int);
    1378                         exchange = (guint16)va_arg(ap, unsigned int);
    1379                         va_arg(ap, unsigned int); /* flags */
    1380                         va_arg(ap, guint32); /* createtime */
    1381                         va_arg(ap, unsigned int); /* maxmsglen */
    1382                         va_arg(ap, unsigned int); /* maxoccupancy */
    1383                         va_arg(ap, int); /* createperms */
    1384                         va_arg(ap, unsigned int); /* unknown */
    1385                         va_arg(ap, char *); /* name */
    1386                         ck = va_arg(ap, char *);
    1387                         va_end(ap);
    1388 
    1389                         aim_chat_join(odata->sess, odata->conn, exchange, ck, instance);
    1390                         }
    1391                         break;
    1392                 default:
    1393                         va_end(ap);
    1394                         break;
    1395         }
    1396         return 1;
    1397 }
    1398 
    1399 static int gaim_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) {
     1429        type = (guint16) va_arg(ap, unsigned int);
     1430
     1431        switch (type) {
     1432        case 0x0002: {
     1433                va_arg(ap, unsigned int);         /* maxrooms */
     1434                va_arg(ap, int);         /* exchangecount */
     1435                va_arg(ap, struct aim_chat_exchangeinfo *);         /* exchanges */
     1436                va_end(ap);
     1437
     1438                while (odata->create_rooms) {
     1439                        struct create_room *cr = odata->create_rooms->data;
     1440                        aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange);
     1441                        g_free(cr->name);
     1442                        odata->create_rooms = g_slist_remove(odata->create_rooms, cr);
     1443                        g_free(cr);
     1444                }
     1445        }
     1446        break;
     1447        case 0x0008: {
     1448                char *ck;
     1449                guint16 instance, exchange;
     1450
     1451                va_arg(ap, char *);         /* fqcn */
     1452                instance = (guint16) va_arg(ap, unsigned int);
     1453                exchange = (guint16) va_arg(ap, unsigned int);
     1454                va_arg(ap, unsigned int);         /* flags */
     1455                va_arg(ap, guint32);         /* createtime */
     1456                va_arg(ap, unsigned int);         /* maxmsglen */
     1457                va_arg(ap, unsigned int);         /* maxoccupancy */
     1458                va_arg(ap, int);         /* createperms */
     1459                va_arg(ap, unsigned int);         /* unknown */
     1460                va_arg(ap, char *);         /* name */
     1461                ck = va_arg(ap, char *);
     1462                va_end(ap);
     1463
     1464                aim_chat_join(odata->sess, odata->conn, exchange, ck, instance);
     1465        }
     1466        break;
     1467        default:
     1468                va_end(ap);
     1469                break;
     1470        }
     1471        return 1;
     1472}
     1473
     1474static int gaim_chat_join(aim_session_t *sess, aim_frame_t *fr, ...)
     1475{
    14001476        va_list ap;
    14011477        int count, i;
     
    14111487
    14121488        c = find_oscar_chat_by_conn(g, fr->conn);
    1413         if (!c)
     1489        if (!c) {
    14141490                return 1;
    1415 
    1416         for (i = 0; i < count; i++)
     1491        }
     1492
     1493        for (i = 0; i < count; i++) {
    14171494                imcb_chat_add_buddy(c->cnv, normalize(info[i].sn));
    1418 
    1419         return 1;
    1420 }
    1421 
    1422 static int gaim_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) {
     1495        }
     1496
     1497        return 1;
     1498}
     1499
     1500static int gaim_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...)
     1501{
    14231502        va_list ap;
    14241503        int count, i;
     
    14341513
    14351514        c = find_oscar_chat_by_conn(g, fr->conn);
    1436         if (!c)
     1515        if (!c) {
    14371516                return 1;
    1438 
    1439         for (i = 0; i < count; i++)
     1517        }
     1518
     1519        for (i = 0; i < count; i++) {
    14401520                imcb_chat_remove_buddy(c->cnv, normalize(info[i].sn), NULL);
    1441 
    1442         return 1;
    1443 }
    1444 
    1445 static int gaim_chat_info_update(aim_session_t *sess, aim_frame_t *fr, ...) {
     1521        }
     1522
     1523        return 1;
     1524}
     1525
     1526static int gaim_chat_info_update(aim_session_t *sess, aim_frame_t *fr, ...)
     1527{
    14461528        va_list ap;
    14471529        guint16 maxmsglen, maxvisiblemsglen;
     
    14571539        va_arg(ap, int); /* unknown_c9 */
    14581540        va_arg(ap, unsigned long); /* creationtime */
    1459         maxmsglen = (guint16)va_arg(ap, int);
     1541        maxmsglen = (guint16) va_arg(ap, int);
    14601542        va_arg(ap, int); /* unknown_d2 */
    14611543        va_arg(ap, int); /* unknown_d5 */
    1462         maxvisiblemsglen = (guint16)va_arg(ap, int);
     1544        maxvisiblemsglen = (guint16) va_arg(ap, int);
    14631545        va_end(ap);
    14641546
     
    14691551}
    14701552
    1471 static int gaim_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) {
     1553static int gaim_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...)
     1554{
    14721555        va_list ap;
    14731556        aim_userinfo_t *info;
     
    14891572}
    14901573
    1491 static int gaim_parse_ratechange(aim_session_t *sess, aim_frame_t *fr, ...) {
     1574static int gaim_parse_ratechange(aim_session_t *sess, aim_frame_t *fr, ...)
     1575{
    14921576#if 0
    14931577        static const char *codes[5] = {
    14941578                "invalid",
    1495                  "change",
    1496                  "warning",
    1497                  "limit",
    1498                  "limit cleared",
     1579                "change",
     1580                "warning",
     1581                "limit",
     1582                "limit cleared",
    14991583        };
    15001584#endif
     
    15031587        guint32 windowsize, clear, currentavg;
    15041588
    1505         va_start(ap, fr); 
    1506         code = (guint16)va_arg(ap, unsigned int);
     1589        va_start(ap, fr);
     1590        code = (guint16) va_arg(ap, unsigned int);
    15071591        va_arg(ap, unsigned int); /* rateclass */
    1508         windowsize = (guint32)va_arg(ap, unsigned long);
    1509         clear = (guint32)va_arg(ap, unsigned long);
     1592        windowsize = (guint32) va_arg(ap, unsigned long);
     1593        clear = (guint32) va_arg(ap, unsigned long);
    15101594        va_arg(ap, unsigned long); /* alert */
    15111595        va_arg(ap, unsigned long); /* limit */
    15121596        va_arg(ap, unsigned long); /* disconnect */
    1513         currentavg = (guint32)va_arg(ap, unsigned long);
     1597        currentavg = (guint32) va_arg(ap, unsigned long);
    15141598        va_arg(ap, unsigned long); /* maxavg */
    15151599        va_end(ap);
     
    15171601        /* XXX fix these values */
    15181602        if (code == AIM_RATE_CODE_CHANGE) {
    1519                 if (currentavg >= clear)
     1603                if (currentavg >= clear) {
    15201604                        aim_conn_setlatency(fr->conn, 0);
     1605                }
    15211606        } else if (code == AIM_RATE_CODE_WARNING) {
    1522                 aim_conn_setlatency(fr->conn, windowsize/4);
     1607                aim_conn_setlatency(fr->conn, windowsize / 4);
    15231608        } else if (code == AIM_RATE_CODE_LIMIT) {
    15241609                imcb_error(sess->aux_data, _("The last message was not sent because you are over the rate limit. "
    1525                           "Please wait 10 seconds and try again."));
    1526                 aim_conn_setlatency(fr->conn, windowsize/2);
     1610                                             "Please wait 10 seconds and try again."));
     1611                aim_conn_setlatency(fr->conn, windowsize / 2);
    15271612        } else if (code == AIM_RATE_CODE_CLEARLIMIT) {
    15281613                aim_conn_setlatency(fr->conn, 0);
     
    15321617}
    15331618
    1534 static int gaim_selfinfo(aim_session_t *sess, aim_frame_t *fr, ...) {
    1535         return 1;
    1536 }
    1537 
    1538 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) {
     1619static int gaim_selfinfo(aim_session_t *sess, aim_frame_t *fr, ...)
     1620{
     1621        return 1;
     1622}
     1623
     1624static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...)
     1625{
    15391626
    15401627        aim_reqpersonalinfo(sess, fr->conn);
     
    15471634        aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS);
    15481635        aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE |
    1549                                                      AIM_PRIVFLAGS_ALLOWMEMBERSINCE);
    1550 
    1551         return 1;
    1552 }
    1553 
    1554 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) {
     1636                                AIM_PRIVFLAGS_ALLOWMEMBERSINCE);
     1637
     1638        return 1;
     1639}
     1640
     1641static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...)
     1642{
    15551643        struct im_connection *ic = sess->aux_data;
    15561644        struct oscar_data *od = ic->proto_data;
     
    15891677}
    15901678
    1591 static int gaim_icbm_param_info(aim_session_t *sess, aim_frame_t *fr, ...) {
     1679static int gaim_icbm_param_info(aim_session_t *sess, aim_frame_t *fr, ...)
     1680{
    15921681        struct aim_icbmparameters *params;
    15931682        va_list ap;
     
    16121701        guint16 maxsiglen;
    16131702        struct im_connection *ic = sess->aux_data;
    1614         struct oscar_data *odata = (struct oscar_data *)ic->proto_data;
     1703        struct oscar_data *odata = (struct oscar_data *) ic->proto_data;
    16151704
    16161705        va_start(ap, fr);
     
    16181707        va_end(ap);
    16191708
    1620         odata->rights.maxsiglen = odata->rights.maxawaymsglen = (guint)maxsiglen;
     1709        odata->rights.maxsiglen = odata->rights.maxawaymsglen = (guint) maxsiglen;
    16211710
    16221711        /* FIXME: It seems we're not really using this, and it broke now that
     
    16241713        aim_bos_setprofile(sess, fr->conn, ic->user->user_info, NULL, gaim_caps);
    16251714        */
    1626        
    1627         return 1;
    1628 }
    1629 
    1630 static int gaim_parse_buddyrights(aim_session_t *sess, aim_frame_t *fr, ...) {
     1715
     1716        return 1;
     1717}
     1718
     1719static int gaim_parse_buddyrights(aim_session_t *sess, aim_frame_t *fr, ...)
     1720{
    16311721        va_list ap;
    16321722        guint16 maxbuddies, maxwatchers;
    16331723        struct im_connection *ic = sess->aux_data;
    1634         struct oscar_data *odata = (struct oscar_data *)ic->proto_data;
     1724        struct oscar_data *odata = (struct oscar_data *) ic->proto_data;
    16351725
    16361726        va_start(ap, fr);
    1637         maxbuddies = (guint16)va_arg(ap, unsigned int);
    1638         maxwatchers = (guint16)va_arg(ap, unsigned int);
     1727        maxbuddies = (guint16) va_arg(ap, unsigned int);
     1728        maxwatchers = (guint16) va_arg(ap, unsigned int);
    16391729        va_end(ap);
    16401730
    1641         odata->rights.maxbuddies = (guint)maxbuddies;
    1642         odata->rights.maxwatchers = (guint)maxwatchers;
    1643 
    1644         return 1;
    1645 }
    1646 
    1647 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) {
     1731        odata->rights.maxbuddies = (guint) maxbuddies;
     1732        odata->rights.maxwatchers = (guint) maxwatchers;
     1733
     1734        return 1;
     1735}
     1736
     1737static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...)
     1738{
    16481739        guint16 maxpermits, maxdenies;
    16491740        va_list ap;
    16501741        struct im_connection *ic = sess->aux_data;
    1651         struct oscar_data *odata = (struct oscar_data *)ic->proto_data;
     1742        struct oscar_data *odata = (struct oscar_data *) ic->proto_data;
    16521743
    16531744        va_start(ap, fr);
    1654         maxpermits = (guint16)va_arg(ap, unsigned int);
    1655         maxdenies = (guint16)va_arg(ap, unsigned int);
     1745        maxpermits = (guint16) va_arg(ap, unsigned int);
     1746        maxdenies = (guint16) va_arg(ap, unsigned int);
    16561747        va_end(ap);
    16571748
    1658         odata->rights.maxpermits = (guint)maxpermits;
    1659         odata->rights.maxdenies = (guint)maxdenies;
     1749        odata->rights.maxpermits = (guint) maxpermits;
     1750        odata->rights.maxdenies = (guint) maxdenies;
    16601751
    16611752        aim_clientready(sess, fr->conn);
     
    16691760}
    16701761
    1671 static int gaim_offlinemsg(aim_session_t *sess, aim_frame_t *fr, ...) {
     1762static int gaim_offlinemsg(aim_session_t *sess, aim_frame_t *fr, ...)
     1763{
    16721764        va_list ap;
    16731765        struct aim_icq_offlinemsg *msg;
     
    16791771
    16801772        switch (msg->type) {
    1681                 case 0x0001: { /* Basic offline message */
    1682                         char sender[32];
    1683                         char *dialog_msg = g_strdup(msg->msg);
    1684                         time_t t = get_time(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0);
    1685                         g_snprintf(sender, sizeof(sender), "%u", msg->sender);
    1686                         strip_linefeed(dialog_msg);
    1687                         imcb_buddy_msg(ic, normalize(sender), dialog_msg, 0, t);
    1688                         g_free(dialog_msg);
    1689                 } break;
    1690 
    1691                 case 0x0004: { /* Someone sent you a URL */
    1692                         char sender[32];
    1693                         char *dialog_msg;
    1694                         char **m;
    1695 
    1696                         time_t t = get_time(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0);
    1697                         g_snprintf(sender, sizeof(sender), "%u", msg->sender);
    1698 
    1699                         m = g_strsplit(msg->msg, "\376", 2);
    1700 
    1701                         if ((strlen(m[0]) != 0)) {
    1702                           dialog_msg = g_strjoinv(" -- ", m);
    1703                         } else {
    1704                           dialog_msg = m[1];
    1705                         }
    1706 
    1707                         strip_linefeed(dialog_msg);
    1708                         imcb_buddy_msg(ic, normalize(sender), dialog_msg, 0, t);
    1709                         g_free(dialog_msg);
    1710                         g_free(m);
    1711                 } break;
    1712                
    1713                 case 0x0006: { /* Authorization request */
    1714                         gaim_icq_authask(ic, msg->sender, msg->msg);
    1715                 } break;
    1716 
    1717                 case 0x0007: { /* Someone has denied you authorization */
    1718                         imcb_log(sess->aux_data, "The user %u has denied your request to add them to your contact list for the following reason:\n%s", msg->sender, msg->msg ? msg->msg : _("No reason given.") );
    1719                 } break;
    1720 
    1721                 case 0x0008: { /* Someone has granted you authorization */
    1722                         imcb_log(sess->aux_data, "The user %u has granted your request to add them to your contact list for the following reason:\n%s", msg->sender, msg->msg ? msg->msg : _("No reason given.") );
    1723                 } break;
    1724 
    1725                 case 0x0012: {
    1726                         /* Ack for authorizing/denying someone.  Or possibly an ack for sending any system notice */
    1727                 } break;
    1728 
    1729                 default: {;
    1730                 }
     1773        case 0x0001: {         /* Basic offline message */
     1774                char sender[32];
     1775                char *dialog_msg = g_strdup(msg->msg);
     1776                time_t t = get_time(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0);
     1777                g_snprintf(sender, sizeof(sender), "%u", msg->sender);
     1778                strip_linefeed(dialog_msg);
     1779                imcb_buddy_msg(ic, normalize(sender), dialog_msg, 0, t);
     1780                g_free(dialog_msg);
     1781        } break;
     1782
     1783        case 0x0004: {         /* Someone sent you a URL */
     1784                char sender[32];
     1785                char *dialog_msg;
     1786                char **m;
     1787
     1788                time_t t = get_time(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0);
     1789                g_snprintf(sender, sizeof(sender), "%u", msg->sender);
     1790
     1791                m = g_strsplit(msg->msg, "\376", 2);
     1792
     1793                if ((strlen(m[0]) != 0)) {
     1794                        dialog_msg = g_strjoinv(" -- ", m);
     1795                } else {
     1796                        dialog_msg = m[1];
     1797                }
     1798
     1799                strip_linefeed(dialog_msg);
     1800                imcb_buddy_msg(ic, normalize(sender), dialog_msg, 0, t);
     1801                g_free(dialog_msg);
     1802                g_free(m);
     1803        } break;
     1804
     1805        case 0x0006: {         /* Authorization request */
     1806                gaim_icq_authask(ic, msg->sender, msg->msg);
     1807        } break;
     1808
     1809        case 0x0007: {         /* Someone has denied you authorization */
     1810                imcb_log(sess->aux_data,
     1811                         "The user %u has denied your request to add them to your contact list for the following reason:\n%s", msg->sender,
     1812                         msg->msg ? msg->msg : _("No reason given."));
     1813        } break;
     1814
     1815        case 0x0008: {         /* Someone has granted you authorization */
     1816                imcb_log(sess->aux_data,
     1817                         "The user %u has granted your request to add them to your contact list for the following reason:\n%s", msg->sender,
     1818                         msg->msg ? msg->msg : _("No reason given."));
     1819        } break;
     1820
     1821        case 0x0012: {
     1822                /* Ack for authorizing/denying someone.  Or possibly an ack for sending any system notice */
     1823        } break;
     1824
     1825        default: {; }
    17311826        }
    17321827
     
    17401835}
    17411836
    1742 static void oscar_keepalive(struct im_connection *ic) {
    1743         struct oscar_data *odata = (struct oscar_data *)ic->proto_data;
     1837static void oscar_keepalive(struct im_connection *ic)
     1838{
     1839        struct oscar_data *odata = (struct oscar_data *) ic->proto_data;
     1840
    17441841        aim_flap_nop(odata->sess, odata->conn);
    17451842}
    17461843
    1747 static int oscar_buddy_msg(struct im_connection *ic, char *name, char *message, int imflags) {
    1748         struct oscar_data *odata = (struct oscar_data *)ic->proto_data;
     1844static int oscar_buddy_msg(struct im_connection *ic, char *name, char *message, int imflags)
     1845{
     1846        struct oscar_data *odata = (struct oscar_data *) ic->proto_data;
    17491847        int ret = 0, len = strlen(message);
     1848
    17501849        if (imflags & OPT_AWAY) {
    17511850                ret = aim_send_im(odata->sess, name, AIM_IMFLAGS_AWAY, message);
     
    17531852                struct aim_sendimext_args args;
    17541853                char *s;
    1755                
     1854
    17561855                args.flags = AIM_IMFLAGS_ACK;
    1757                 if (odata->icq)
     1856                if (odata->icq) {
    17581857                        args.flags |= AIM_IMFLAGS_OFFLINE;
    1759                 for (s = message; *s; s++)
    1760                         if (*s & 128)
     1858                }
     1859                for (s = message; *s; s++) {
     1860                        if (*s & 128) {
    17611861                                break;
    1762                
     1862                        }
     1863                }
     1864
    17631865                /* Message contains high ASCII chars, time for some translation! */
    17641866                if (*s) {
     
    17741876                        } else {
    17751877                                /* OOF, translation failed... Oh well.. */
    1776                                 g_free( s );
     1878                                g_free(s);
    17771879                                s = message;
    17781880                        }
     
    17801882                        s = message;
    17811883                }
    1782                
     1884
    17831885                args.features = gaim_features;
    17841886                args.featureslen = sizeof(gaim_features);
    1785                
     1887
    17861888                args.destsn = name;
    17871889                args.msg    = s;
    17881890                args.msglen = len;
    1789                
     1891
    17901892                ret = aim_send_im_ext(odata->sess, &args);
    1791                
     1893
    17921894                if (s != message) {
    17931895                        g_free(s);
    17941896                }
    17951897        }
    1796         if (ret >= 0)
     1898        if (ret >= 0) {
    17971899                return 1;
     1900        }
    17981901        return ret;
    17991902}
    18001903
    1801 static void oscar_get_info(struct im_connection *g, char *name) {
    1802         struct oscar_data *odata = (struct oscar_data *)g->proto_data;
    1803         if (odata->icq)
     1904static void oscar_get_info(struct im_connection *g, char *name)
     1905{
     1906        struct oscar_data *odata = (struct oscar_data *) g->proto_data;
     1907
     1908        if (odata->icq) {
    18041909                aim_icq_getallinfo(odata->sess, name);
    1805         else {
     1910        } else {
    18061911                aim_getinfo(odata->sess, odata->conn, name, AIM_GETINFO_AWAYMESSAGE);
    18071912                aim_getinfo(odata->sess, odata->conn, name, AIM_GETINFO_GENERALINFO);
     
    18091914}
    18101915
    1811 static void oscar_get_away(struct im_connection *g, char *who) {
    1812         struct oscar_data *odata = (struct oscar_data *)g->proto_data;
     1916static void oscar_get_away(struct im_connection *g, char *who)
     1917{
     1918        struct oscar_data *odata = (struct oscar_data *) g->proto_data;
     1919
    18131920        if (odata->icq) {
    18141921                /** FIXME(wilmer): Hmm, lost the ability to get away msgs here, do we care to get that back?
    18151922                struct buddy *budlight = imcb_find_buddy(g, who);
    18161923                if (budlight)
    1817                         if ((budlight->uc & 0xff80) >> 7)
    1818                                 if (budlight->caps & AIM_CAPS_ICQSERVERRELAY)
    1819                                         aim_send_im_ch2_geticqmessage(odata->sess, who, (budlight->uc & 0xff80) >> 7);
     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);
    18201927                */
    1821         } else
     1928        } else {
    18221929                aim_getinfo(odata->sess, odata->conn, who, AIM_GETINFO_AWAYMESSAGE);
     1930        }
    18231931}
    18241932
    18251933static void oscar_set_away_aim(struct im_connection *ic, struct oscar_data *od, const char *state, const char *message)
    18261934{
    1827         if (state == NULL)
     1935        if (state == NULL) {
    18281936                state = "";
     1937        }
    18291938
    18301939        if (!g_strcasecmp(state, _("Visible"))) {
     
    18381947        }
    18391948
    1840         if (od->rights.maxawaymsglen == 0)
     1949        if (od->rights.maxawaymsglen == 0) {
    18411950                imcb_error(ic, "oscar_set_away_aim called before locate rights received");
     1951        }
    18421952
    18431953        aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_NORMAL);
     
    18521962
    18531963        if (strlen(message) > od->rights.maxawaymsglen) {
    1854                 imcb_error(ic, "Maximum away message length of %d bytes exceeded, truncating", od->rights.maxawaymsglen);
     1964                imcb_error(ic, "Maximum away message length of %d bytes exceeded, truncating",
     1965                           od->rights.maxawaymsglen);
    18551966        }
    18561967
     
    19052016                ic->away = g_strdup(msg);
    19062017        } else {
    1907                 if (no_message) {
     2018                if (no_message) {
    19082019                        aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_NORMAL);
    19092020                } else {
     
    19192030static void oscar_set_away(struct im_connection *ic, char *state, char *message)
    19202031{
    1921         struct oscar_data *od = (struct oscar_data *)ic->proto_data;
     2032        struct oscar_data *od = (struct oscar_data *) ic->proto_data;
    19222033
    19232034        oscar_set_away_aim(ic, od, state, message);
    1924         if (od->icq)
     2035        if (od->icq) {
    19252036                oscar_set_away_icq(ic, od, state, message);
     2037        }
    19262038
    19272039        return;
    19282040}
    19292041
    1930 static void oscar_add_buddy(struct im_connection *g, char *name, char *group) {
    1931         struct oscar_data *odata = (struct oscar_data *)g->proto_data;
     2042static void oscar_add_buddy(struct im_connection *g, char *name, char *group)
     2043{
     2044        struct oscar_data *odata = (struct oscar_data *) g->proto_data;
    19322045        bee_user_t *bu;
    1933        
    1934         if (group && (bu = bee_user_by_handle(g->bee, g, name)) && bu->group)
     2046
     2047        if (group && (bu = bee_user_by_handle(g->bee, g, name)) && bu->group) {
    19352048                aim_ssi_movebuddy(odata->sess, odata->conn, bu->group->name, group, name);
    1936         else
     2049        } else {
    19372050                aim_ssi_addbuddies(odata->sess, odata->conn, group ? : OSCAR_GROUP, &name, 1, 0);
    1938 }
    1939 
    1940 static void oscar_remove_buddy(struct im_connection *g, char *name, char *group) {
    1941         struct oscar_data *odata = (struct oscar_data *)g->proto_data;
     2051        }
     2052}
     2053
     2054static void oscar_remove_buddy(struct im_connection *g, char *name, char *group)
     2055{
     2056        struct oscar_data *odata = (struct oscar_data *) g->proto_data;
    19422057        struct aim_ssi_item *ssigroup;
    1943         while ((ssigroup = aim_ssi_itemlist_findparent(odata->sess->ssi.items, name)) && !aim_ssi_delbuddies(odata->sess, odata->conn, ssigroup->name, &name, 1));
    1944 }
    1945 
    1946 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) {
    1947         return 1;
    1948 }
    1949 
    1950 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) {
     2058
     2059        while ((ssigroup =
     2060                        aim_ssi_itemlist_findparent(odata->sess->ssi.items,
     2061                                                    name)) &&
     2062               !aim_ssi_delbuddies(odata->sess, odata->conn, ssigroup->name, &name, 1)) {
     2063                ;
     2064        }
     2065}
     2066
     2067static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...)
     2068{
     2069        return 1;
     2070}
     2071
     2072static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...)
     2073{
    19512074        struct im_connection *ic = sess->aux_data;
    19522075        struct aim_ssi_item *curitem, *curgroup = NULL;
     
    19562079        /* Add from server list to local list */
    19572080        tmp = 0;
    1958         for (curitem=sess->ssi.items; curitem; curitem=curitem->next) {
     2081        for (curitem = sess->ssi.items; curitem; curitem = curitem->next) {
    19592082                nrm = curitem->name ? normalize(curitem->name) : NULL;
    1960                
     2083
    19612084                switch (curitem->type) {
    1962                         case 0x0000: /* Buddy */
    1963                                 if ((curitem->name) && (!imcb_buddy_by_handle(ic, nrm))) {
    1964                                         char *realname = NULL;
    1965 
    1966                                         if (curitem->data && aim_gettlv(curitem->data, 0x0131, 1))
    1967                                                     realname = aim_gettlv_str(curitem->data, 0x0131, 1);
    1968                                        
    1969                                         imcb_add_buddy(ic, nrm, curgroup ? (curgroup->gid == curitem->gid ? curgroup->name : NULL) : NULL);
    1970                                        
    1971                                         if (realname) {
    1972                                                 imcb_buddy_nick_hint(ic, nrm, realname);
    1973                                                 imcb_rename_buddy(ic, nrm, realname);
    1974                                                 g_free(realname);
    1975                                         }
     2085                case 0x0000:         /* Buddy */
     2086                        if ((curitem->name) && (!imcb_buddy_by_handle(ic, nrm))) {
     2087                                char *realname = NULL;
     2088
     2089                                if (curitem->data && aim_gettlv(curitem->data, 0x0131, 1)) {
     2090                                        realname = aim_gettlv_str(curitem->data, 0x0131, 1);
    19762091                                }
    1977                                 break;
    1978 
    1979                         case 0x0001: /* Group */
    1980                                 curgroup = curitem;
    1981                                 break;
    1982 
    1983                         case 0x0002: /* Permit buddy */
    1984                                 if (curitem->name) {
    1985                                         GSList *list;
    1986                                         for (list=ic->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next);
    1987                                         if (!list) {
    1988                                                 char *name;
    1989                                                 name = g_strdup(nrm);
    1990                                                 ic->permit = g_slist_append(ic->permit, name);
    1991                                                 tmp++;
    1992                                         }
     2092
     2093                                imcb_add_buddy(ic, nrm,
     2094                                               curgroup ? (curgroup->gid ==
     2095                                                           curitem->gid ? curgroup->name : NULL) : NULL);
     2096
     2097                                if (realname) {
     2098                                        imcb_buddy_nick_hint(ic, nrm, realname);
     2099                                        imcb_rename_buddy(ic, nrm, realname);
     2100                                        g_free(realname);
    19932101                                }
    1994                                 break;
    1995 
    1996                         case 0x0003: /* Deny buddy */
    1997                                 if (curitem->name) {
    1998                                         GSList *list;
    1999                                         for (list=ic->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next);
    2000                                         if (!list) {
    2001                                                 char *name;
    2002                                                 name = g_strdup(nrm);
    2003                                                 ic->deny = g_slist_append(ic->deny, name);
    2004                                                 tmp++;
    2005                                         }
     2102                        }
     2103                        break;
     2104
     2105                case 0x0001:         /* Group */
     2106                        curgroup = curitem;
     2107                        break;
     2108
     2109                case 0x0002:         /* Permit buddy */
     2110                        if (curitem->name) {
     2111                                GSList *list;
     2112                                for (list = ic->permit; (list && aim_sncmp(curitem->name, list->data));
     2113                                     list = list->next) {
     2114                                        ;
    20062115                                }
    2007                                 break;
    2008 
    2009                         case 0x0004: /* Permit/deny setting */
    2010                                 if (curitem->data) {
    2011                                         guint8 permdeny;
    2012                                         if ((permdeny = aim_ssi_getpermdeny(sess->ssi.items)) && (permdeny != ic->permdeny)) {
    2013                                                 ic->permdeny = permdeny;
    2014                                                 tmp++;
    2015                                         }
     2116                                if (!list) {
     2117                                        char *name;
     2118                                        name = g_strdup(nrm);
     2119                                        ic->permit = g_slist_append(ic->permit, name);
     2120                                        tmp++;
    20162121                                }
    2017                                 break;
    2018 
    2019                         case 0x0005: /* Presence setting */
    2020                                 /* We don't want to change Gaim's setting because it applies to all accounts */
    2021                                 break;
     2122                        }
     2123                        break;
     2124
     2125                case 0x0003:         /* Deny buddy */
     2126                        if (curitem->name) {
     2127                                GSList *list;
     2128                                for (list = ic->deny;
     2129                                     (list && aim_sncmp(curitem->name, list->data)); list = list->next) {
     2130                                        ;
     2131                                }
     2132                                if (!list) {
     2133                                        char *name;
     2134                                        name = g_strdup(nrm);
     2135                                        ic->deny = g_slist_append(ic->deny, name);
     2136                                        tmp++;
     2137                                }
     2138                        }
     2139                        break;
     2140
     2141                case 0x0004:         /* Permit/deny setting */
     2142                        if (curitem->data) {
     2143                                guint8 permdeny;
     2144                                if ((permdeny = aim_ssi_getpermdeny(sess->ssi.items)) && (permdeny != ic->permdeny)) {
     2145                                        ic->permdeny = permdeny;
     2146                                        tmp++;
     2147                                }
     2148                        }
     2149                        break;
     2150
     2151                case 0x0005:         /* Presence setting */
     2152                        /* We don't want to change Gaim's setting because it applies to all accounts */
     2153                        break;
    20222154                } /* End of switch on curitem->type */
    20232155        } /* End of for loop */
    20242156
    20252157        aim_ssi_enable(sess, fr->conn);
    2026        
     2158
    20272159        /* Request offline messages, now that the buddy list is complete. */
    20282160        aim_icq_reqofflinemsgs(sess);
    2029        
     2161
    20302162        /* Now that we have a buddy list, we can tell BitlBee that we're online. */
    20312163        imcb_connected(ic);
    2032        
    2033         return 1;
    2034 }
    2035 
    2036 static int gaim_ssi_parseack( aim_session_t *sess, aim_frame_t *fr, ... )
     2164
     2165        return 1;
     2166}
     2167
     2168static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...)
    20372169{
    20382170        aim_snac_t *origsnac;
    20392171        va_list ap;
    20402172
    2041         va_start( ap, fr );
    2042         origsnac = va_arg( ap, aim_snac_t * );
    2043         va_end( ap );
    2044        
    2045         if( origsnac && origsnac->family == AIM_CB_FAM_SSI && origsnac->type == AIM_CB_SSI_ADD && origsnac->data )
    2046         {
    2047                 int i, st, count = aim_bstream_empty( &fr->data );
     2173        va_start(ap, fr);
     2174        origsnac = va_arg(ap, aim_snac_t *);
     2175        va_end(ap);
     2176
     2177        if (origsnac && origsnac->family == AIM_CB_FAM_SSI && origsnac->type == AIM_CB_SSI_ADD && origsnac->data) {
     2178                int i, st, count = aim_bstream_empty(&fr->data);
    20482179                char *list;
    2049                
    2050                 if( count & 1 )
    2051                 {
     2180
     2181                if (count & 1) {
    20522182                        /* Hmm, the length should be even... */
    2053                         imcb_error( sess->aux_data, "Received SSI ACK package with non-even length");
    2054                         return( 0 );
     2183                        imcb_error(sess->aux_data, "Received SSI ACK package with non-even length");
     2184                        return(0);
    20552185                }
    20562186                count >>= 1;
    2057                
     2187
    20582188                list = (char *) origsnac->data;
    2059                 for( i = 0; i < count; i ++ )
    2060                 {
    2061                         struct aim_ssi_item *ssigroup = aim_ssi_itemlist_findparent( sess->ssi.items, list );
     2189                for (i = 0; i < count; i++) {
     2190                        struct aim_ssi_item *ssigroup = aim_ssi_itemlist_findparent(sess->ssi.items, list);
    20622191                        char *group = ssigroup ? ssigroup->name : NULL;
    2063                        
    2064                         st = aimbs_get16( &fr->data );
    2065                         if( st == 0x00 )
    2066                         {
    2067                                 imcb_add_buddy( sess->aux_data, normalize(list), group );
     2192
     2193                        st = aimbs_get16(&fr->data);
     2194                        if (st == 0x00) {
     2195                                imcb_add_buddy(sess->aux_data, normalize(list), group);
     2196                        } else if (st == 0x0E) {
     2197                                imcb_log(sess->aux_data,
     2198                                         "Buddy %s can't be added without authorization, requesting authorization",
     2199                                         list);
     2200
     2201                                aim_ssi_auth_request(sess, fr->conn, list, "");
     2202                                aim_ssi_addbuddies(sess, fr->conn, OSCAR_GROUP, &list, 1, 1);
     2203                        } else if (st == 0x0A) {
     2204                                imcb_error(sess->aux_data, "Buddy %s is already in your list", list);
     2205                        } else {
     2206                                imcb_error(sess->aux_data, "Error while adding buddy: 0x%04x", st);
    20682207                        }
    2069                         else if( st == 0x0E )
    2070                         {
    2071                                 imcb_log( sess->aux_data, "Buddy %s can't be added without authorization, requesting authorization", list );
    2072                                
    2073                                 aim_ssi_auth_request( sess, fr->conn, list, "" );
    2074                                 aim_ssi_addbuddies( sess, fr->conn, OSCAR_GROUP, &list, 1, 1 );
    2075                         }
    2076                         else if( st == 0x0A )
    2077                         {
    2078                                 imcb_error( sess->aux_data, "Buddy %s is already in your list", list );
    2079                         }
    2080                         else
    2081                         {
    2082                                 imcb_error( sess->aux_data, "Error while adding buddy: 0x%04x", st );
    2083                         }
    2084                         list += strlen( list ) + 1;
    2085                 }
    2086         }
    2087        
    2088         return( 1 );
    2089 }
    2090 
    2091 static void oscar_add_permit(struct im_connection *ic, char *who) {
    2092         struct oscar_data *od = (struct oscar_data *)ic->proto_data;
     2208                        list += strlen(list) + 1;
     2209                }
     2210        }
     2211
     2212        return(1);
     2213}
     2214
     2215static void oscar_add_permit(struct im_connection *ic, char *who)
     2216{
     2217        struct oscar_data *od = (struct oscar_data *) ic->proto_data;
     2218
    20932219        if (od->icq) {
    20942220                aim_ssi_auth_reply(od->sess, od->conn, who, 1, "");
    20952221        } else {
    2096                 if (od->sess->ssi.received_data)
     2222                if (od->sess->ssi.received_data) {
    20972223                        aim_ssi_addpord(od->sess, od->conn, &who, 1, AIM_SSI_TYPE_PERMIT);
    2098         }
    2099 }
    2100 
    2101 static void oscar_add_deny(struct im_connection *ic, char *who) {
    2102         struct oscar_data *od = (struct oscar_data *)ic->proto_data;
     2224                }
     2225        }
     2226}
     2227
     2228static void oscar_add_deny(struct im_connection *ic, char *who)
     2229{
     2230        struct oscar_data *od = (struct oscar_data *) ic->proto_data;
     2231
    21032232        if (od->icq) {
    21042233                aim_ssi_auth_reply(od->sess, od->conn, who, 0, "");
    21052234        } else {
    2106                 if (od->sess->ssi.received_data)
     2235                if (od->sess->ssi.received_data) {
    21072236                        aim_ssi_addpord(od->sess, od->conn, &who, 1, AIM_SSI_TYPE_DENY);
    2108         }
    2109 }
    2110 
    2111 static void oscar_rem_permit(struct im_connection *ic, char *who) {
    2112         struct oscar_data *od = (struct oscar_data *)ic->proto_data;
     2237                }
     2238        }
     2239}
     2240
     2241static void oscar_rem_permit(struct im_connection *ic, char *who)
     2242{
     2243        struct oscar_data *od = (struct oscar_data *) ic->proto_data;
     2244
    21132245        if (!od->icq) {
    2114                 if (od->sess->ssi.received_data)
     2246                if (od->sess->ssi.received_data) {
    21152247                        aim_ssi_delpord(od->sess, od->conn, &who, 1, AIM_SSI_TYPE_PERMIT);
    2116         }
    2117 }
    2118 
    2119 static void oscar_rem_deny(struct im_connection *ic, char *who) {
    2120         struct oscar_data *od = (struct oscar_data *)ic->proto_data;
     2248                }
     2249        }
     2250}
     2251
     2252static void oscar_rem_deny(struct im_connection *ic, char *who)
     2253{
     2254        struct oscar_data *od = (struct oscar_data *) ic->proto_data;
     2255
    21212256        if (!od->icq) {
    2122                 if (od->sess->ssi.received_data)
     2257                if (od->sess->ssi.received_data) {
    21232258                        aim_ssi_delpord(od->sess, od->conn, &who, 1, AIM_SSI_TYPE_DENY);
     2259                }
    21242260        }
    21252261}
     
    21592295        va_end(ap);
    21602296
    2161         if (!info->uin)
     2297        if (!info->uin) {
    21622298                return 0;
     2299        }
    21632300
    21642301        str = g_string_sized_new(512);
    21652302        g_snprintf(who, sizeof(who), "%u", info->uin);
    21662303
    2167         g_string_printf(str, "%s: %s - %s: %s", _("UIN"), who, _("Nick"), 
    2168         info->nick ? info->nick : "-");
     2304        g_string_printf(str, "%s: %s - %s: %s", _("UIN"), who, _("Nick"),
     2305                        info->nick ? info->nick : "-");
    21692306        g_string_append_printf(str, "\n%s: %s", _("First Name"), info->first);
    21702307        g_string_append_printf(str, "\n%s: %s", _("Last Name"), info->last);
     
    21812318        }
    21822319        g_string_append_printf(str, "\n%s: %s", _("Mobile Phone"), info->mobile);
    2183         if (info->gender != 0)
    2184                 g_string_append_printf(str, "\n%s: %s", _("Gender"), info->gender==1 ? _("Female") : _("Male"));
     2320        if (info->gender != 0) {
     2321                g_string_append_printf(str, "\n%s: %s", _("Gender"), info->gender == 1 ? _("Female") : _("Male"));
     2322        }
    21852323        if (info->birthyear || info->birthmonth || info->birthday) {
    21862324                char date[30];
    21872325                struct tm tm;
    21882326                memset(&tm, 0, sizeof(struct tm));
    2189                 tm.tm_mday = (int)info->birthday;
    2190                 tm.tm_mon = (int)info->birthmonth-1;
    2191                 tm.tm_year = (int)info->birthyear%100;
     2327                tm.tm_mday = (int) info->birthday;
     2328                tm.tm_mon = (int) info->birthmonth - 1;
     2329                tm.tm_year = (int) info->birthyear % 100;
    21922330                strftime(date, sizeof(date), "%Y-%m-%d", &tm);
    21932331                g_string_append_printf(str, "\n%s: %s", _("Birthday"), date);
     
    22002338        g_string_append_printf(str, "\n%s: %s", _("Personal Web Page"), info->personalwebpage);
    22012339        if (info->info && info->info[0]) {
    2202                 g_string_sprintfa(str, "\n%s:\n%s\n%s", _("Additional Information"), 
    2203                 info->info, _("End of Additional Information"));
     2340                g_string_sprintfa(str, "\n%s:\n%s\n%s", _("Additional Information"),
     2341                                  info->info, _("End of Additional Information"));
    22042342        }
    22052343        g_string_append_c(str, '\n');
    2206         if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) {
     2344        if ((info->homeaddr &&
     2345             (info->homeaddr[0])) ||
     2346            (info->homecity &&
     2347             info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) {
    22072348                g_string_append_printf(str, "%s:", _("Home Address"));
    22082349                g_string_append_printf(str, "\n%s: %s", _("Address"), info->homeaddr);
    22092350                g_string_append_printf(str, "\n%s: %s", _("City"), info->homecity);
    2210                 g_string_append_printf(str, "\n%s: %s", _("State"), info->homestate); 
     2351                g_string_append_printf(str, "\n%s: %s", _("State"), info->homestate);
    22112352                g_string_append_printf(str, "\n%s: %s", _("Zip Code"), info->homezip);
    22122353                g_string_append_c(str, '\n');
    22132354        }
    2214         if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) {
     2355        if ((info->workaddr &&
     2356             info->workaddr[0]) ||
     2357            (info->workcity &&
     2358             info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) {
    22152359                g_string_append_printf(str, "%s:", _("Work Address"));
    22162360                g_string_append_printf(str, "\n%s: %s", _("Address"), info->workaddr);
     
    22202364                g_string_append_c(str, '\n');
    22212365        }
    2222         if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) {
     2366        if ((info->workcompany &&
     2367             info->workcompany[0]) ||
     2368            (info->workdivision &&
     2369             info->workdivision[0]) ||
     2370            (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) {
    22232371                g_string_append_printf(str, "%s:", _("Work Information"));
    22242372                g_string_append_printf(str, "\n%s: %s", _("Company"), info->workcompany);
     
    22472395        /* Make sure encoding begins with charset= */
    22482396        if (strncmp(encoding, "text/plain; charset=", 20) &&
    2249                 strncmp(encoding, "text/aolrtf; charset=", 21) &&
    2250                 strncmp(encoding, "text/x-aolrtf; charset=", 23))
    2251         {
     2397            strncmp(encoding, "text/aolrtf; charset=", 21) &&
     2398            strncmp(encoding, "text/x-aolrtf; charset=", 23)) {
    22522399                return NULL;
    22532400        }
     
    22562403        end = strrchr(encoding, '"');
    22572404
    2258         if ((begin == NULL) || (end == NULL) || (begin >= end))
     2405        if ((begin == NULL) || (end == NULL) || (begin >= end)) {
    22592406                return NULL;
    2260 
    2261         ret = g_strndup(begin+1, (end-1) - begin);
     2407        }
     2408
     2409        ret = g_strndup(begin + 1, (end - 1) - begin);
    22622410
    22632411        return ret;
     
    22882436         */
    22892437        if (*utf8 == 0) {
    2290             strncpy(utf8, text, textlen);
     2438                strncpy(utf8, text, textlen);
    22912439        }
    22922440
     
    23122460        va_end(ap);
    23132461
    2314         if(text_encoding)
     2462        if (text_encoding) {
    23152463                extracted_encoding = oscar_encoding_extract(text_encoding);
    2316         if(infotype == AIM_GETINFO_GENERALINFO) {
     2464        }
     2465        if (infotype == AIM_GETINFO_GENERALINFO) {
    23172466                /*Display idle time*/
    23182467                char buff[256];
    23192468                struct tm idletime;
    2320                 if(userinfo->idletime) {
     2469                if (userinfo->idletime) {
    23212470                        memset(&idletime, 0, sizeof(struct tm));
    23222471                        idletime.tm_mday = (userinfo->idletime / 60) / 24;
     
    23272476                        imcb_log(ic, "%s: %s", _("Idle Time"), buff);
    23282477                }
    2329                
    2330                 if(text) {
     2478
     2479                if (text) {
    23312480                        utf8 = oscar_encoding_to_utf8(extracted_encoding, text, text_length);
    23322481                        imcb_log(ic, "%s\n%s", _("User Info"), utf8);
     
    23342483                        imcb_log(ic, _("No user info available."));
    23352484                }
    2336         } else if(infotype == AIM_GETINFO_AWAYMESSAGE && userinfo->flags & AIM_FLAG_AWAY) {
     2485        } else if (infotype == AIM_GETINFO_AWAYMESSAGE && userinfo->flags & AIM_FLAG_AWAY) {
    23372486                utf8 = oscar_encoding_to_utf8(extracted_encoding, text, text_length);
    23382487                imcb_log(ic, "%s\n%s", _("Away Message"), utf8);
     
    23402489
    23412490        g_free(utf8);
    2342    
     2491
    23432492        return 1;
    23442493}
     
    23562505        type2 = va_arg(ap, int);
    23572506        va_end(ap);
    2358    
    2359         if(type2 == 0x0002) {
     2507
     2508        if (type2 == 0x0002) {
    23602509                /* User is typing */
    23612510                imcb_buddy_typing(ic, normalize(sn), OPT_TYPING);
    2362         }
    2363         else if (type2 == 0x0001) {
     2511        } else if (type2 == 0x0001) {
    23642512                /* User has typed something, but is not actively typing (stale) */
    23652513                imcb_buddy_typing(ic, normalize(sn), OPT_THINKING);
    2366         }
    2367         else {
     2514        } else {
    23682515                /* User has stopped typing */
    23692516                imcb_buddy_typing(ic, normalize(sn), 0);
    23702517        }
    2371        
     2518
    23722519        return 1;
    23732520}
     
    23762523{
    23772524        struct oscar_data *od = ic->proto_data;
    2378         return( aim_im_sendmtn(od->sess, 1, who, (typing & OPT_TYPING) ? 0x0002 : 0x0000) );
     2525
     2526        return(aim_im_sendmtn(od->sess, 1, who, (typing & OPT_TYPING) ? 0x0002 : 0x0000));
    23792527}
    23802528
     
    23822530{
    23832531        struct im_connection *ic = c->ic;
    2384         struct oscar_data * od = (struct oscar_data*)ic->proto_data;
     2532        struct oscar_data * od = (struct oscar_data*) ic->proto_data;
    23852533        struct chat_connection * ccon;
    23862534        int ret;
     
    23882536        guint16 flags;
    23892537        char *s;
    2390        
    2391         if (!(ccon = c->data))
     2538
     2539        if (!(ccon = c->data)) {
    23922540                return;
    2393                
    2394         for (s = message; *s; s++)
    2395                 if (*s & 128)
     2541        }
     2542
     2543        for (s = message; *s; s++) {
     2544                if (*s & 128) {
    23962545                        break;
    2397        
     2546                }
     2547        }
     2548
    23982549        flags = AIM_CHATFLAGS_NOREFLECT;
    2399        
     2550
    24002551        /* Message contains high ASCII chars, time for some translation! */
    24012552        if (*s) {
     
    24112562                } else {
    24122563                        /* OOF, translation failed... Oh well.. */
    2413                         g_free( s );
     2564                        g_free(s);
    24142565                        s = message;
    24152566                }
     
    24172568                s = message;
    24182569        }
    2419                
     2570
    24202571        ret = aim_chat_send_im(od->sess, ccon->conn, flags, s, len);
    2421                
    2422         if (s != message) {     
     2572
     2573        if (s != message) {
    24232574                g_free(s);
    2424   }
    2425  
     2575        }
     2576
    24262577/*  return (ret >= 0); */
    24272578}
     
    24302581{
    24312582        struct im_connection *ic = c->ic;
    2432         struct oscar_data * od = (struct oscar_data *)ic->proto_data;
     2583        struct oscar_data * od = (struct oscar_data *) ic->proto_data;
    24332584        struct chat_connection *ccon;
    2434        
    2435         if (!(ccon = c->data))
     2585
     2586        if (!(ccon = c->data)) {
    24362587                return;
    2437        
     2588        }
     2589
    24382590        aim_chat_invite(od->sess, od->conn, who, message ? message : "",
    2439                                         ccon->exchange, ccon->name, 0x0);
     2591                        ccon->exchange, ccon->name, 0x0);
    24402592}
    24412593
    24422594void oscar_chat_kill(struct im_connection *ic, struct chat_connection *cc)
    24432595{
    2444         struct oscar_data *od = (struct oscar_data *)ic->proto_data;
     2596        struct oscar_data *od = (struct oscar_data *) ic->proto_data;
    24452597
    24462598        /* Notify the conversation window that we've left the chat */
     
    24492601        /* Destroy the chat_connection */
    24502602        od->oscar_chats = g_slist_remove(od->oscar_chats, cc);
    2451         if (cc->inpa > 0)
     2603        if (cc->inpa > 0) {
    24522604                b_event_remove(cc->inpa);
     2605        }
    24532606        aim_conn_kill(od->sess, &cc->conn);
    24542607        g_free(cc->name);
     
    24592612void oscar_chat_leave(struct groupchat *c)
    24602613{
    2461         if (!c->data)
     2614        if (!c->data) {
    24622615                return;
     2616        }
    24632617        oscar_chat_kill(c->ic, c->data);
    24642618}
    24652619
    24662620struct groupchat *oscar_chat_join_internal(struct im_connection *ic, const char *room,
    2467         const char *nick, const char *password, int exchange_number)
    2468 {
    2469         struct oscar_data * od = (struct oscar_data *)ic->proto_data;
     2621                                           const char *nick, const char *password, int exchange_number)
     2622{
     2623        struct oscar_data * od = (struct oscar_data *) ic->proto_data;
    24702624        struct groupchat *ret = imcb_chat_new(ic, room);
    24712625        aim_conn_t * cur;
    24722626
    2473         if((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) {
     2627        if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) {
    24742628                aim_chatnav_createroom(od->sess, cur, room, exchange_number);
    2475                
     2629
    24762630                return ret;
    24772631        } else {
    24782632                struct create_room * cr = g_new0(struct create_room, 1);
    2479                
     2633
    24802634                cr->exchange = exchange_number;
    24812635                cr->name = g_strdup(room);
    24822636                od->create_rooms = g_slist_append(od->create_rooms, cr);
    24832637                aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV);
    2484                
     2638
    24852639                return ret;
    24862640        }
     
    24882642
    24892643struct groupchat *oscar_chat_join(struct im_connection *ic, const char *room,
    2490         const char *nick, const char *password, set_t **sets)
     2644                                  const char *nick, const char *password, set_t **sets)
    24912645{
    24922646        return oscar_chat_join_internal(ic, room, nick, password, set_getint(sets, "exchange_number"));
     
    24952649struct groupchat *oscar_chat_with(struct im_connection * ic, char *who)
    24962650{
    2497         struct oscar_data * od = (struct oscar_data *)ic->proto_data;
     2651        struct oscar_data * od = (struct oscar_data *) ic->proto_data;
    24982652        struct groupchat *ret;
    24992653        static int chat_id = 0;
    25002654        char * chatname, *s;
    2501        
     2655
    25022656        chatname = g_strdup_printf("%s%s%d", g_ascii_isdigit(*ic->acc->user) ? "icq" : "",
    25032657                                   ic->acc->user, chat_id++);
    2504        
    2505         for (s = chatname; *s; s ++)
    2506                 if (!g_ascii_isalnum(*s))
     2658
     2659        for (s = chatname; *s; s++) {
     2660                if (!g_ascii_isalnum(*s)) {
    25072661                        *s = '0';
    2508        
     2662                }
     2663        }
     2664
    25092665        ret = oscar_chat_join_internal(ic, chatname, NULL, NULL, 4);
    25102666        aim_chat_invite(od->sess, od->conn, who, "", 4, chatname, 0x0);
    25112667
    25122668        g_free(chatname);
    2513        
     2669
    25142670        return ret;
    25152671}
     
    25182674{
    25192675        struct aim_chat_invitation * inv = data;
    2520        
     2676
    25212677        oscar_chat_join_internal(inv->ic, inv->name, NULL, NULL, 4);
    25222678        g_free(inv->name);
     
    25272683{
    25282684        struct aim_chat_invitation * inv = data;
    2529        
     2685
    25302686        g_free(inv->name);
    25312687        g_free(inv);
     
    25422698}
    25432699
    2544 void oscar_initmodule() 
     2700void oscar_initmodule()
    25452701{
    25462702        struct prpl *ret = g_new0(struct prpl, 1);
     2703
    25472704        ret->name = "oscar";
    2548     ret->mms = 2343;       /* this guess taken from libotr UPGRADING file */
     2705        ret->mms = 2343;   /* this guess taken from libotr UPGRADING file */
    25492706        ret->away_states = oscar_away_states;
    25502707        ret->init = oscar_init;
     
    25702727        ret->rem_deny = oscar_rem_deny;
    25712728        ret->send_typing = oscar_send_typing;
    2572        
     2729
    25732730        ret->handle_cmp = aim_sncmp;
    25742731
Note: See TracChangeset for help on using the changeset viewer.