Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/oscar/oscar.c

    r30ce1ce rf774e01  
    9191        gboolean icq;
    9292        GSList *evilhack;
     93       
     94        GHashTable *ips;
    9395
    9496        struct {
     
    356358        struct oscar_data *odata = ic->proto_data = g_new0(struct oscar_data, 1);
    357359
    358         if (!isdigit(acc->user[0])) {
     360        if (isdigit(acc->user[0]))
     361                odata->icq = TRUE;
     362        else
    359363                ic->flags |= OPT_DOES_HTML;
    360         }
    361364
    362365        sess = g_new0(aim_session_t, 1);
     
    411414                g_free(cr);
    412415        }
     416        if (odata->ips)
     417                g_hash_table_destroy(odata->ips);
    413418        if (odata->email)
    414419                g_free(odata->email);
     
    987992                signon = time(NULL) - info->sessionlen;
    988993
     994        if (info->present & AIM_USERINFO_PRESENT_ICQIPADDR) {
     995                uint32_t *uin = g_new0(uint32_t, 1);
     996               
     997                if (od->ips == NULL)
     998                        od->ips = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, NULL);
     999               
     1000                if (sscanf(info->sn, "%d", uin) == 1)
     1001                        g_hash_table_insert(od->ips, uin, (gpointer) (long) info->icqinfo.ipaddr);
     1002        }
     1003
    9891004        tmp = g_strdup(normalize(ic->acc->user));
    9901005        if (!strcmp(tmp, normalize(info->sn)))
     
    10511066                g_snprintf(tmp, BUF_LONG, "%s", args->msg);
    10521067        } else {
    1053                 int i;
     1068                aim_mpmsg_section_t *part;
    10541069               
    10551070                *tmp = 0;
    1056                 for (i = 0; i < args->mpmsg.numparts; i ++) {
    1057                         g_strlcat(tmp, (char*) args->mpmsg.parts[i].data, BUF_LONG);
    1058                         g_strlcat(tmp, "\n", BUF_LONG);
     1071                for (part = args->mpmsg.parts; part; part = part->next) {
     1072                        if (part->data) {
     1073                                g_strlcat(tmp, (char*) part->data, BUF_LONG);
     1074                                g_strlcat(tmp, "\n", BUF_LONG);
     1075                        }
    10591076                }
    10601077        }
     
    22192236static int gaim_icqinfo(aim_session_t *sess, aim_frame_t *fr, ...)
    22202237{
    2221         struct im_connection *ic = sess->aux_data;
    2222         gchar who[16];
    2223         GString *str;
    2224         va_list ap;
    2225         struct aim_icq_info *info;
    2226 
    2227         va_start(ap, fr);
    2228         info = va_arg(ap, struct aim_icq_info *);
    2229         va_end(ap);
    2230 
    2231         if (!info->uin)
    2232                 return 0;
    2233 
    2234         str = g_string_sized_new(100);
    2235         g_snprintf(who, sizeof(who), "%u", info->uin);
    2236 
    2237         g_string_sprintfa(str, "%s: %s - %s: %s", _("UIN"), who, _("Nick"),
    2238                                 info->nick ? info->nick : "-");
    2239         info_string_append(str, "\n", _("First Name"), info->first);
    2240         info_string_append(str, "\n", _("Last Name"), info->last);
    2241                 info_string_append(str, "\n", _("Email Address"), info->email);
    2242         if (info->numaddresses && info->email2) {
    2243                 int i;
    2244                 for (i = 0; i < info->numaddresses; i++) {
    2245                                         info_string_append(str, "\n", _("Email Address"), info->email2[i]);
    2246                 }
    2247         }
    2248         info_string_append(str, "\n", _("Mobile Phone"), info->mobile);
    2249         if (info->gender != 0)
    2250                 info_string_append(str, "\n", _("Gender"), info->gender==1 ? _("Female") : _("Male"));
    2251         if (info->birthyear || info->birthmonth || info->birthday) {
    2252                 char date[30];
    2253                 struct tm tm;
    2254                 tm.tm_mday = (int)info->birthday;
    2255                 tm.tm_mon = (int)info->birthmonth-1;
    2256                 tm.tm_year = (int)info->birthyear%100;
    2257                 strftime(date, sizeof(date), "%Y-%m-%d", &tm);
    2258                 info_string_append(str, "\n", _("Birthday"), date);
    2259         }
    2260         if (info->age) {
    2261                 char age[5];
    2262                 g_snprintf(age, sizeof(age), "%hhd", info->age);
    2263                 info_string_append(str, "\n", _("Age"), age);
    2264         }
    2265                 info_string_append(str, "\n", _("Personal Web Page"), info->personalwebpage);
    2266         if (info->info && info->info[0]) {
    2267                 g_string_sprintfa(str, "\n%s:\n%s\n%s", _("Additional Information"),
    2268                                                 info->info, _("End of Additional Information"));
    2269         }
    2270         g_string_sprintfa(str, "\n");
    2271         if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) {
    2272                 g_string_sprintfa(str, "%s:", _("Home Address"));
    2273                 info_string_append(str, "\n", _("Address"), info->homeaddr);
    2274                 info_string_append(str, "\n", _("City"), info->homecity);
    2275                 info_string_append(str, "\n", _("State"), info->homestate);
    2276                                 info_string_append(str, "\n", _("Zip Code"), info->homezip);
    2277                 g_string_sprintfa(str, "\n");
    2278         }
    2279         if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) {
    2280                 g_string_sprintfa(str, "%s:", _("Work Address"));
    2281                 info_string_append(str, "\n", _("Address"), info->workaddr);
    2282                 info_string_append(str, "\n", _("City"), info->workcity);
    2283                 info_string_append(str, "\n", _("State"), info->workstate);
    2284                                 info_string_append(str, "\n", _("Zip Code"), info->workzip);
    2285                 g_string_sprintfa(str, "\n");
    2286         }
    2287         if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) {
    2288                 g_string_sprintfa(str, "%s:", _("Work Information"));
    2289                 info_string_append(str, "\n", _("Company"), info->workcompany);
    2290                 info_string_append(str, "\n", _("Division"), info->workdivision);
    2291                 info_string_append(str, "\n", _("Position"), info->workposition);
    2292                 if (info->workwebpage && info->workwebpage[0]) {
    2293                         info_string_append(str, "\n", _("Web Page"), info->workwebpage);
    2294                 }
    2295                 g_string_sprintfa(str, "\n");
    2296         }
    2297 
    2298                 imcb_log(ic, "%s\n%s", _("User Info"), str->str);
    2299         g_string_free(str, TRUE);
    2300 
    2301         return 1;
     2238        struct im_connection *ic = sess->aux_data;
     2239        struct oscar_data *od = ic->proto_data;
     2240        gchar who[16];
     2241        GString *str;
     2242        va_list ap;
     2243        struct aim_icq_info *info;
     2244        uint32_t ip;
     2245
     2246        va_start(ap, fr);
     2247        info = va_arg(ap, struct aim_icq_info *);
     2248        va_end(ap);
     2249
     2250        if (!info->uin)
     2251                return 0;
     2252
     2253        str = g_string_sized_new(512);
     2254        g_snprintf(who, sizeof(who), "%u", info->uin);
     2255
     2256        g_string_printf(str, "%s: %s - %s: %s", _("UIN"), who, _("Nick"),
     2257        info->nick ? info->nick : "-");
     2258        g_string_append_printf(str, "\n%s: %s", _("First Name"), info->first);
     2259        g_string_append_printf(str, "\n%s: %s", _("Last Name"), info->last);
     2260        g_string_append_printf(str, "\n%s: %s", _("Email Address"), info->email);
     2261        if (info->numaddresses && info->email2) {
     2262                int i;
     2263                for (i = 0; i < info->numaddresses; i++) {
     2264                        g_string_append_printf(str, "\n%s: %s", _("Email Address"), info->email2[i]);
     2265                }
     2266        }
     2267        if ((ip = (long) g_hash_table_lookup(od->ips, &info->uin)) != 0) {
     2268                g_string_append_printf(str, "\n%s: %d.%d.%d.%d", _("Last used IP address"),
     2269                                       (ip >> 24), (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff);
     2270        }
     2271        g_string_append_printf(str, "\n%s: %s", _("Mobile Phone"), info->mobile);
     2272        if (info->gender != 0)
     2273                g_string_append_printf(str, "\n%s: %s", _("Gender"), info->gender==1 ? _("Female") : _("Male"));
     2274        if (info->birthyear || info->birthmonth || info->birthday) {
     2275                char date[30];
     2276                struct tm tm;
     2277                memset(&tm, 0, sizeof(struct tm));
     2278                tm.tm_mday = (int)info->birthday;
     2279                tm.tm_mon = (int)info->birthmonth-1;
     2280                tm.tm_year = (int)info->birthyear%100;
     2281                strftime(date, sizeof(date), "%Y-%m-%d", &tm);
     2282                g_string_append_printf(str, "\n%s: %s", _("Birthday"), date);
     2283        }
     2284        if (info->age) {
     2285                char age[5];
     2286                g_snprintf(age, sizeof(age), "%hhd", info->age);
     2287                g_string_append_printf(str, "\n%s: %s", _("Age"), age);
     2288        }
     2289        g_string_append_printf(str, "\n%s: %s", _("Personal Web Page"), info->personalwebpage);
     2290        if (info->info && info->info[0]) {
     2291                g_string_sprintfa(str, "\n%s:\n%s\n%s", _("Additional Information"),
     2292                info->info, _("End of Additional Information"));
     2293        }
     2294        g_string_append_c(str, '\n');
     2295        if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) {
     2296                g_string_append_printf(str, "%s:", _("Home Address"));
     2297                g_string_append_printf(str, "\n%s: %s", _("Address"), info->homeaddr);
     2298                g_string_append_printf(str, "\n%s: %s", _("City"), info->homecity);
     2299                g_string_append_printf(str, "\n%s: %s", _("State"), info->homestate);
     2300                g_string_append_printf(str, "\n%s: %s", _("Zip Code"), info->homezip);
     2301                g_string_append_c(str, '\n');
     2302        }
     2303        if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) {
     2304                g_string_append_printf(str, "%s:", _("Work Address"));
     2305                g_string_append_printf(str, "\n%s: %s", _("Address"), info->workaddr);
     2306                g_string_append_printf(str, "\n%s: %s", _("City"), info->workcity);
     2307                g_string_append_printf(str, "\n%s: %s", _("State"), info->workstate);
     2308                g_string_append_printf(str, "\n%s: %s", _("Zip Code"), info->workzip);
     2309                g_string_append_c(str, '\n');
     2310        }
     2311        if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) {
     2312                g_string_append_printf(str, "%s:", _("Work Information"));
     2313                g_string_append_printf(str, "\n%s: %s", _("Company"), info->workcompany);
     2314                g_string_append_printf(str, "\n%s: %s", _("Division"), info->workdivision);
     2315                g_string_append_printf(str, "\n%s: %s", _("Position"), info->workposition);
     2316                if (info->workwebpage && info->workwebpage[0]) {
     2317                        g_string_append_printf(str, "\n%s: %s", _("Web Page"), info->workwebpage);
     2318                }
     2319                g_string_append_c(str, '\n');
     2320        }
     2321
     2322        imcb_log(ic, "%s\n%s", _("User Info"), str->str);
     2323        g_string_free(str, TRUE);
     2324
     2325        return 1;
    23022326
    23032327}
     
    24332457                /* User has stopped typing */
    24342458                imcb_buddy_typing(ic, sn, 0);
    2435         }       
     2459        }
    24362460       
    24372461        return 1;
Note: See TracChangeset for help on using the changeset viewer.