Ignore:
Timestamp:
2008-07-16T23:22:52Z (16 years ago)
Author:
Sven Moritz Hallberg <pesco@…>
Branches:
master
Children:
9b55485
Parents:
9730d72 (diff), 6a78c0e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge in latest trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/oscar/oscar.c

    r9730d72 r6738a67  
    6060
    6161#define OSCAR_GROUP "Friends"
     62
     63#define BUF_LEN 2048
     64#define BUF_LONG ( BUF_LEN * 2 )
    6265
    6366/* Don't know if support for UTF8 is really working. For now it's UTF16 here.
     
    240243};
    241244static int msgerrreasonlen = 25;
     245
     246/* Hurray, this function is NOT thread-safe \o/ */
     247static char *normalize(const char *s)
     248{
     249        static char buf[BUF_LEN];
     250        char *t, *u;
     251        int x = 0;
     252
     253        g_return_val_if_fail((s != NULL), NULL);
     254
     255        u = t = g_strdup(s);
     256
     257        strcpy(t, s);
     258        g_strdown(t);
     259
     260        while (*t && (x < BUF_LEN - 1)) {
     261                if (*t != ' ' && *t != '!') {
     262                        buf[x] = *t;
     263                        x++;
     264                }
     265                t++;
     266        }
     267        buf[x] = '\0';
     268        g_free(u);
     269        return buf;
     270}
    242271
    243272static gboolean oscar_callback(gpointer data, gint source,
     
    10021031        }
    10031032
    1004         tmp = g_strdup(normalize(ic->acc->user));
    1005         if (!strcmp(tmp, normalize(info->sn)))
     1033        if (!aim_sncmp(ic->acc->user, info->sn))
    10061034                g_snprintf(ic->displayname, sizeof(ic->displayname), "%s", info->sn);
    1007         g_free(tmp);
    1008 
    1009         imcb_buddy_status(ic, info->sn, flags, state_string, NULL);
    1010         /* imcb_buddy_times(ic, info->sn, signon, time_idle); */
     1035
     1036        tmp = normalize(info->sn);
     1037        imcb_buddy_status(ic, tmp, flags, state_string, NULL);
     1038        /* imcb_buddy_times(ic, tmp, signon, time_idle); */
     1039
    10111040
    10121041        return 1;
     
    10221051        va_end(ap);
    10231052
    1024         imcb_buddy_status(ic, info->sn, 0, NULL, NULL );
     1053        imcb_buddy_status(ic, normalize(info->sn), 0, NULL, NULL );
    10251054
    10261055        return 1;
     
    10781107       
    10791108        strip_linefeed(tmp);
    1080         imcb_buddy_msg(ic, userinfo->sn, tmp, flags, 0);
     1109        imcb_buddy_msg(ic, normalize(userinfo->sn), tmp, flags, 0);
    10811110        g_free(tmp);
    10821111       
     
    10841113}
    10851114
    1086 void oscar_accept_chat(gpointer w, struct aim_chat_invitation * inv);
    1087 void oscar_reject_chat(gpointer w, struct aim_chat_invitation * inv);
     1115void oscar_accept_chat(void *data);
     1116void oscar_reject_chat(void *data);
    10881117       
    10891118static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) {
     
    11191148}
    11201149
    1121 static void gaim_icq_authgrant(gpointer w, struct icq_auth *data) {
     1150static void gaim_icq_authgrant(void *data_) {
     1151        struct icq_auth *data = data_;
    11221152        char *uin, message;
    11231153        struct oscar_data *od = (struct oscar_data *)data->ic->proto_data;
     
    11341164}
    11351165
    1136 static void gaim_icq_authdeny(gpointer w, struct icq_auth *data) {
     1166static void gaim_icq_authdeny(void *data_) {
     1167        struct icq_auth *data = data_;
    11371168        char *uin, *message;
    11381169        struct oscar_data *od = (struct oscar_data *)data->ic->proto_data;
     
    11751206                        message = g_strdup(args->msg);
    11761207                        strip_linefeed(message);
    1177                         imcb_buddy_msg(ic, uin, message, 0, 0);
     1208                        imcb_buddy_msg(ic, normalize(uin), message, 0, 0);
    11781209                        g_free(uin);
    11791210                        g_free(message);
     
    11941225
    11951226                        strip_linefeed(message);
    1196                         imcb_buddy_msg(ic, uin, message, 0, 0);
     1227                        imcb_buddy_msg(ic, normalize(uin), message, 0, 0);
    11971228                        g_free(uin);
    11981229                        g_free(m);
     
    14691500
    14701501        for (i = 0; i < count; i++)
    1471                 imcb_chat_add_buddy(c->cnv, info[i].sn);
     1502                imcb_chat_add_buddy(c->cnv, normalize(info[i].sn));
    14721503
    14731504        return 1;
     
    14921523
    14931524        for (i = 0; i < count; i++)
    1494                 imcb_chat_remove_buddy(c->cnv, info[i].sn, NULL);
     1525                imcb_chat_remove_buddy(c->cnv, normalize(info[i].sn), NULL);
    14951526
    14961527        return 1;
     
    15431574        tmp = g_malloc(BUF_LONG);
    15441575        g_snprintf(tmp, BUF_LONG, "%s", msg);
    1545         imcb_chat_msg(ccon->cnv, info->sn, tmp, 0, 0);
     1576        imcb_chat_msg(ccon->cnv, normalize(info->sn), tmp, 0, 0);
    15461577        g_free(tmp);
    15471578
     
    17561787                        g_snprintf(sender, sizeof(sender), "%u", msg->sender);
    17571788                        strip_linefeed(dialog_msg);
    1758                         imcb_buddy_msg(ic, sender, dialog_msg, 0, t);
     1789                        imcb_buddy_msg(ic, normalize(sender), dialog_msg, 0, t);
    17591790                        g_free(dialog_msg);
    17601791                } break;
     
    17771808
    17781809                        strip_linefeed(dialog_msg);
    1779                         imcb_buddy_msg(ic, sender, dialog_msg, 0, t);
     1810                        imcb_buddy_msg(ic, normalize(sender), dialog_msg, 0, t);
    17801811                        g_free(dialog_msg);
    17811812                        g_free(m);
     
    20152046        struct aim_ssi_item *curitem;
    20162047        int tmp;
     2048        char *nrm;
    20172049
    20182050        /* Add from server list to local list */
    20192051        tmp = 0;
    20202052        for (curitem=sess->ssi.items; curitem; curitem=curitem->next) {
     2053                nrm = curitem->name ? normalize(curitem->name) : NULL;
     2054               
    20212055                switch (curitem->type) {
    20222056                        case 0x0000: /* Buddy */
    2023                                 if ((curitem->name) && (!imcb_find_buddy(ic, curitem->name))) {
     2057                                if ((curitem->name) && (!imcb_find_buddy(ic, nrm))) {
    20242058                                        char *realname = NULL;
    20252059
     
    20272061                                                    realname = aim_gettlv_str(curitem->data, 0x0131, 1);
    20282062                                               
    2029                                         imcb_add_buddy(ic, curitem->name, NULL);
     2063                                        imcb_add_buddy(ic, nrm, NULL);
    20302064                                       
    20312065                                        if (realname) {
    2032                                                 imcb_buddy_nick_hint(ic, curitem->name, realname);
    2033                                                 imcb_rename_buddy(ic, curitem->name, realname);
     2066                                                imcb_buddy_nick_hint(ic, nrm, realname);
     2067                                                imcb_rename_buddy(ic, nrm, realname);
    20342068                                                g_free(realname);
    20352069                                        }
     
    20432077                                        if (!list) {
    20442078                                                char *name;
    2045                                                 name = g_strdup(normalize(curitem->name));
     2079                                                name = g_strdup(nrm);
    20462080                                                ic->permit = g_slist_append(ic->permit, name);
    20472081                                                tmp++;
     
    20562090                                        if (!list) {
    20572091                                                char *name;
    2058                                                 name = g_strdup(normalize(curitem->name));
     2092                                                name = g_strdup(nrm);
    20592093                                                ic->deny = g_slist_append(ic->deny, name);
    20602094                                                tmp++;
     
    21182152                        if( st == 0x00 )
    21192153                        {
    2120                                 imcb_add_buddy( sess->aux_data, list, NULL );
     2154                                imcb_add_buddy( sess->aux_data, normalize(list), NULL );
    21212155                        }
    21222156                        else if( st == 0x0E )
     
    24482482        if(type2 == 0x0002) {
    24492483                /* User is typing */
    2450                 imcb_buddy_typing(ic, sn, OPT_TYPING);
     2484                imcb_buddy_typing(ic, normalize(sn), OPT_TYPING);
    24512485        }
    24522486        else if (type2 == 0x0001) {
    24532487                /* User has typed something, but is not actively typing (stale) */
    2454                 imcb_buddy_typing(ic, sn, OPT_THINKING);
     2488                imcb_buddy_typing(ic, normalize(sn), OPT_THINKING);
    24552489        }
    24562490        else {
    24572491                /* User has stopped typing */
    2458                 imcb_buddy_typing(ic, sn, 0);
     2492                imcb_buddy_typing(ic, normalize(sn), 0);
    24592493        }
    24602494       
     
    25882622}
    25892623
    2590 void oscar_accept_chat(gpointer w, struct aim_chat_invitation * inv)
    2591 {
     2624void oscar_accept_chat(void *data)
     2625{
     2626        struct aim_chat_invitation * inv = data;
     2627       
    25922628        oscar_chat_join(inv->ic, inv->name, NULL, NULL);
    25932629        g_free(inv->name);
     
    25952631}
    25962632
    2597 void oscar_reject_chat(gpointer w, struct aim_chat_invitation * inv)
    2598 {
     2633void oscar_reject_chat(void *data)
     2634{
     2635        struct aim_chat_invitation * inv = data;
     2636       
    25992637        g_free(inv->name);
    26002638        g_free(inv);
Note: See TracChangeset for help on using the changeset viewer.