Changeset e64de00


Ignore:
Timestamp:
2008-01-12T00:24:46Z (16 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
59f527b6
Parents:
e7f8838
Message:

Killed info_string_append() and now showing the IP address of ICQ users
in the "info" command response.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • lib/misc.c

    re7f8838 re64de00  
    245245}
    246246
    247 void info_string_append(GString *str, char *newline, char *name, char *value)
    248 {
    249         if( value && value[0] )
    250                 g_string_sprintfa( str, "%s%s: %s", newline, name, value );
    251 }
    252 
    253247/* Decode%20a%20file%20name                                             */
    254248void http_decode( char *s )
  • lib/misc.h

    re7f8838 re64de00  
    4242G_MODULE_EXPORT char *strip_newlines(char *source);
    4343G_MODULE_EXPORT char *normalize( const char *s );
    44 G_MODULE_EXPORT void info_string_append( GString *str, char *newline, char *name, char *value );
    4544
    4645G_MODULE_EXPORT time_t get_time( int year, int month, int day, int hour, int min, int sec );
  • protocols/oscar/oscar.c

    re7f8838 re64de00  
    9191        gboolean icq;
    9292        GSList *evilhack;
     93       
     94        GHashTable *ips;
    9395
    9496        struct {
     
    412414                g_free(cr);
    413415        }
     416        if (odata->ips)
     417                g_hash_table_destroy(odata->ips);
    414418        if (odata->email)
    415419                g_free(odata->email);
     
    987991        if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN)
    988992                signon = time(NULL) - info->sessionlen;
     993
     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        }
    9891003
    9901004        tmp = g_strdup(normalize(ic->acc->user));
     
    22202234static int gaim_icqinfo(aim_session_t *sess, aim_frame_t *fr, ...)
    22212235{
    2222         struct im_connection *ic = sess->aux_data;
    2223         gchar who[16];
    2224         GString *str;
    2225         va_list ap;
    2226         struct aim_icq_info *info;
    2227 
    2228         va_start(ap, fr);
    2229         info = va_arg(ap, struct aim_icq_info *);
    2230         va_end(ap);
    2231 
    2232         if (!info->uin)
    2233                 return 0;
    2234 
    2235         str = g_string_sized_new(100);
    2236         g_snprintf(who, sizeof(who), "%u", info->uin);
    2237 
    2238         g_string_sprintfa(str, "%s: %s - %s: %s", _("UIN"), who, _("Nick"),
    2239                                 info->nick ? info->nick : "-");
    2240         info_string_append(str, "\n", _("First Name"), info->first);
    2241         info_string_append(str, "\n", _("Last Name"), info->last);
    2242                 info_string_append(str, "\n", _("Email Address"), info->email);
    2243         if (info->numaddresses && info->email2) {
    2244                 int i;
    2245                 for (i = 0; i < info->numaddresses; i++) {
    2246                                         info_string_append(str, "\n", _("Email Address"), info->email2[i]);
    2247                 }
    2248         }
    2249         info_string_append(str, "\n", _("Mobile Phone"), info->mobile);
    2250         if (info->gender != 0)
    2251                 info_string_append(str, "\n", _("Gender"), info->gender==1 ? _("Female") : _("Male"));
    2252         if (info->birthyear || info->birthmonth || info->birthday) {
    2253                 char date[30];
    2254                 struct tm tm;
    2255                 tm.tm_mday = (int)info->birthday;
    2256                 tm.tm_mon = (int)info->birthmonth-1;
    2257                 tm.tm_year = (int)info->birthyear%100;
    2258                 strftime(date, sizeof(date), "%Y-%m-%d", &tm);
    2259                 info_string_append(str, "\n", _("Birthday"), date);
    2260         }
    2261         if (info->age) {
    2262                 char age[5];
    2263                 g_snprintf(age, sizeof(age), "%hhd", info->age);
    2264                 info_string_append(str, "\n", _("Age"), age);
    2265         }
    2266                 info_string_append(str, "\n", _("Personal Web Page"), info->personalwebpage);
    2267         if (info->info && info->info[0]) {
    2268                 g_string_sprintfa(str, "\n%s:\n%s\n%s", _("Additional Information"),
    2269                                                 info->info, _("End of Additional Information"));
    2270         }
    2271         g_string_sprintfa(str, "\n");
    2272         if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) {
    2273                 g_string_sprintfa(str, "%s:", _("Home Address"));
    2274                 info_string_append(str, "\n", _("Address"), info->homeaddr);
    2275                 info_string_append(str, "\n", _("City"), info->homecity);
    2276                 info_string_append(str, "\n", _("State"), info->homestate);
    2277                                 info_string_append(str, "\n", _("Zip Code"), info->homezip);
    2278                 g_string_sprintfa(str, "\n");
    2279         }
    2280         if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) {
    2281                 g_string_sprintfa(str, "%s:", _("Work Address"));
    2282                 info_string_append(str, "\n", _("Address"), info->workaddr);
    2283                 info_string_append(str, "\n", _("City"), info->workcity);
    2284                 info_string_append(str, "\n", _("State"), info->workstate);
    2285                                 info_string_append(str, "\n", _("Zip Code"), info->workzip);
    2286                 g_string_sprintfa(str, "\n");
    2287         }
    2288         if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) {
    2289                 g_string_sprintfa(str, "%s:", _("Work Information"));
    2290                 info_string_append(str, "\n", _("Company"), info->workcompany);
    2291                 info_string_append(str, "\n", _("Division"), info->workdivision);
    2292                 info_string_append(str, "\n", _("Position"), info->workposition);
    2293                 if (info->workwebpage && info->workwebpage[0]) {
    2294                         info_string_append(str, "\n", _("Web Page"), info->workwebpage);
    2295                 }
    2296                 g_string_sprintfa(str, "\n");
    2297         }
    2298 
    2299                 imcb_log(ic, "%s\n%s", _("User Info"), str->str);
    2300         g_string_free(str, TRUE);
    2301 
    2302         return 1;
     2236        struct im_connection *ic = sess->aux_data;
     2237        struct oscar_data *od = ic->proto_data;
     2238        gchar who[16];
     2239        GString *str;
     2240        va_list ap;
     2241        struct aim_icq_info *info;
     2242        uint32_t ip;
     2243
     2244        va_start(ap, fr);
     2245        info = va_arg(ap, struct aim_icq_info *);
     2246        va_end(ap);
     2247
     2248        if (!info->uin)
     2249                return 0;
     2250
     2251        str = g_string_sized_new(512);
     2252        g_snprintf(who, sizeof(who), "%u", info->uin);
     2253
     2254        g_string_printf(str, "%s: %s - %s: %s", _("UIN"), who, _("Nick"),
     2255        info->nick ? info->nick : "-");
     2256        g_string_append_printf(str, "\n%s: %s", _("First Name"), info->first);
     2257        g_string_append_printf(str, "\n%s: %s", _("Last Name"), info->last);
     2258        g_string_append_printf(str, "\n%s: %s", _("Email Address"), info->email);
     2259        if (info->numaddresses && info->email2) {
     2260                int i;
     2261                for (i = 0; i < info->numaddresses; i++) {
     2262                        g_string_append_printf(str, "\n%s: %s", _("Email Address"), info->email2[i]);
     2263                }
     2264        }
     2265        if ((ip = (long) g_hash_table_lookup(od->ips, &info->uin)) != 0) {
     2266                g_string_append_printf(str, "\n%s: %d.%d.%d.%d", _("Last used IP address"),
     2267                                       (ip >> 24), (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff);
     2268        }
     2269        g_string_append_printf(str, "\n%s: %s", _("Mobile Phone"), info->mobile);
     2270        if (info->gender != 0)
     2271                g_string_append_printf(str, "\n%s: %s", _("Gender"), info->gender==1 ? _("Female") : _("Male"));
     2272        if (info->birthyear || info->birthmonth || info->birthday) {
     2273                char date[30];
     2274                struct tm tm;
     2275                tm.tm_mday = (int)info->birthday;
     2276                tm.tm_mon = (int)info->birthmonth-1;
     2277                tm.tm_year = (int)info->birthyear%100;
     2278                strftime(date, sizeof(date), "%Y-%m-%d", &tm);
     2279                g_string_append_printf(str, "\n%s: %s", _("Birthday"), date);
     2280        }
     2281        if (info->age) {
     2282                char age[5];
     2283                g_snprintf(age, sizeof(age), "%hhd", info->age);
     2284                g_string_append_printf(str, "\n%s: %s", _("Age"), age);
     2285        }
     2286        g_string_append_printf(str, "\n%s: %s", _("Personal Web Page"), info->personalwebpage);
     2287        if (info->info && info->info[0]) {
     2288                g_string_sprintfa(str, "\n%s:\n%s\n%s", _("Additional Information"),
     2289                info->info, _("End of Additional Information"));
     2290        }
     2291        g_string_append_c(str, '\n');
     2292        if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) {
     2293                g_string_append_printf(str, "%s:", _("Home Address"));
     2294                g_string_append_printf(str, "\n%s: %s", _("Address"), info->homeaddr);
     2295                g_string_append_printf(str, "\n%s: %s", _("City"), info->homecity);
     2296                g_string_append_printf(str, "\n%s: %s", _("State"), info->homestate);
     2297                g_string_append_printf(str, "\n%s: %s", _("Zip Code"), info->homezip);
     2298                g_string_append_c(str, '\n');
     2299        }
     2300        if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) {
     2301                g_string_append_printf(str, "%s:", _("Work Address"));
     2302                g_string_append_printf(str, "\n%s: %s", _("Address"), info->workaddr);
     2303                g_string_append_printf(str, "\n%s: %s", _("City"), info->workcity);
     2304                g_string_append_printf(str, "\n%s: %s", _("State"), info->workstate);
     2305                g_string_append_printf(str, "\n%s: %s", _("Zip Code"), info->workzip);
     2306                g_string_append_c(str, '\n');
     2307        }
     2308        if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) {
     2309                g_string_append_printf(str, "%s:", _("Work Information"));
     2310                g_string_append_printf(str, "\n%s: %s", _("Company"), info->workcompany);
     2311                g_string_append_printf(str, "\n%s: %s", _("Division"), info->workdivision);
     2312                g_string_append_printf(str, "\n%s: %s", _("Position"), info->workposition);
     2313                if (info->workwebpage && info->workwebpage[0]) {
     2314                        g_string_append_printf(str, "\n%s: %s", _("Web Page"), info->workwebpage);
     2315                }
     2316                g_string_append_c(str, '\n');
     2317        }
     2318
     2319        imcb_log(ic, "%s\n%s", _("User Info"), str->str);
     2320        g_string_free(str, TRUE);
     2321
     2322        return 1;
    23032323
    23042324}
     
    24342454                /* User has stopped typing */
    24352455                imcb_buddy_typing(ic, sn, 0);
    2436         }       
     2456        }
    24372457       
    24382458        return 1;
Note: See TracChangeset for help on using the changeset viewer.