Ignore:
Timestamp:
2012-10-19T23:38:33Z (7 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
509cf60
Parents:
386042c
Message:

Massive cleanup in OSCAR.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/oscar/misc.c

    r386042c r6042a54  
    1313
    1414#include <aim.h>
    15 
    16 /*
    17  * aim_bos_setbuddylist(buddylist)
    18  *
    19  * This just builds the "set buddy list" command then queues it.
    20  *
    21  * buddy_list = "Screen Name One&ScreenNameTwo&";
    22  *
    23  * TODO: Clean this up. 
    24  *
    25  * XXX: I can't stress the TODO enough.
    26  *
    27  */
    28 int aim_bos_setbuddylist(aim_session_t *sess, aim_conn_t *conn, const char *buddy_list)
    29 {
    30         aim_frame_t *fr;
    31         aim_snacid_t snacid;
    32         int len = 0;
    33         char *localcpy = NULL;
    34         char *tmpptr = NULL;
    35 
    36         if (!buddy_list || !(localcpy = g_strdup(buddy_list)))
    37                 return -EINVAL;
    38 
    39         for (tmpptr = strtok(localcpy, "&"); tmpptr; ) {
    40                 len += 1 + strlen(tmpptr);
    41                 tmpptr = strtok(NULL, "&");
    42         }
    43 
    44         if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+len)))
    45                 return -ENOMEM;
    46 
    47         snacid = aim_cachesnac(sess, 0x0003, 0x0004, 0x0000, NULL, 0);
    48         aim_putsnac(&fr->data, 0x0003, 0x0004, 0x0000, snacid);
    49 
    50         strncpy(localcpy, buddy_list, strlen(buddy_list) + 1);
    51 
    52         for (tmpptr = strtok(localcpy, "&"); tmpptr; ) {
    53 
    54                 aimbs_put8(&fr->data, strlen(tmpptr));
    55                 aimbs_putraw(&fr->data, (guint8 *)tmpptr, strlen(tmpptr));
    56                 tmpptr = strtok(NULL, "&");
    57         }
    58 
    59         aim_tx_enqueue(sess, fr);
    60 
    61         g_free(localcpy);
    62 
    63         return 0;
    64 }
    6515
    6616/*
     
    12777
    12878/*
    129  * Send a warning to destsn.
    130  *
    131  * Flags:
    132  *  AIM_WARN_ANON  Send as an anonymous (doesn't count as much)
    133  *
    134  * returns -1 on error (couldn't alloc packet), 0 on success.
    135  *
    136  */
    137 int aim_send_warning(aim_session_t *sess, aim_conn_t *conn, const char *destsn, guint32 flags)
    138 {
    139         aim_frame_t *fr;
    140         aim_snacid_t snacid;
    141         guint16 outflags = 0x0000;
    142 
    143         if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, strlen(destsn)+13)))
    144                 return -ENOMEM;
    145 
    146         snacid = aim_cachesnac(sess, 0x0004, 0x0008, 0x0000, destsn, strlen(destsn)+1);
    147 
    148         aim_putsnac(&fr->data, 0x0004, 0x0008, 0x0000, snacid);
    149 
    150         if (flags & AIM_WARN_ANON)
    151                 outflags |= 0x0001;
    152 
    153         aimbs_put16(&fr->data, outflags);
    154         aimbs_put8(&fr->data, strlen(destsn));
    155         aimbs_putraw(&fr->data, (guint8 *)destsn, strlen(destsn));
    156 
    157         aim_tx_enqueue(sess, fr);
    158 
    159         return 0;
    160 }
    161 
    162 /*
    16379 * Generic routine for sending commands.
    16480 *
     
    254170{
    255171        return aim_genericreq_n(sess, conn, 0x0002, 0x0002);
    256 }
    257 
    258 /*
    259  * Set directory profile data (not the same as aim_bos_setprofile!)
    260  *
    261  * privacy: 1 to allow searching, 0 to disallow.
    262  */
    263 int aim_setdirectoryinfo(aim_session_t *sess, aim_conn_t *conn, const char *first, const char *middle, const char *last, const char *maiden, const char *nickname, const char *street, const char *city, const char *state, const char *zip, int country, guint16 privacy)
    264 {
    265         aim_frame_t *fr;
    266         aim_snacid_t snacid;
    267         aim_tlvlist_t *tl = NULL;
    268 
    269 
    270         aim_addtlvtochain16(&tl, 0x000a, privacy);
    271 
    272         if (first)
    273                 aim_addtlvtochain_raw(&tl, 0x0001, strlen(first), (guint8 *)first);
    274         if (last)
    275                 aim_addtlvtochain_raw(&tl, 0x0002, strlen(last), (guint8 *)last);
    276         if (middle)
    277                 aim_addtlvtochain_raw(&tl, 0x0003, strlen(middle), (guint8 *)middle);
    278         if (maiden)
    279                 aim_addtlvtochain_raw(&tl, 0x0004, strlen(maiden), (guint8 *)maiden);
    280 
    281         if (state)
    282                 aim_addtlvtochain_raw(&tl, 0x0007, strlen(state), (guint8 *)state);
    283         if (city)
    284                 aim_addtlvtochain_raw(&tl, 0x0008, strlen(city), (guint8 *)city);
    285 
    286         if (nickname)
    287                 aim_addtlvtochain_raw(&tl, 0x000c, strlen(nickname), (guint8 *)nickname);
    288         if (zip)
    289                 aim_addtlvtochain_raw(&tl, 0x000d, strlen(zip), (guint8 *)zip);
    290 
    291         if (street)
    292                 aim_addtlvtochain_raw(&tl, 0x0021, strlen(street), (guint8 *)street);
    293 
    294         if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+aim_sizetlvchain(&tl))))
    295                 return -ENOMEM;
    296 
    297         snacid = aim_cachesnac(sess, 0x0002, 0x0009, 0x0000, NULL, 0);
    298        
    299         aim_putsnac(&fr->data, 0x0002, 0x0009, 0x0000, snacid);
    300         aim_writetlvchain(&fr->data, &tl);
    301         aim_freetlvchain(&tl);
    302 
    303         aim_tx_enqueue(sess, fr);
    304 
    305         return 0;
    306 }
    307 
    308 /* XXX pass these in better */
    309 int aim_setuserinterests(aim_session_t *sess, aim_conn_t *conn, const char *interest1, const char *interest2, const char *interest3, const char *interest4, const char *interest5, guint16 privacy)
    310 {
    311         aim_frame_t *fr;
    312         aim_tlvlist_t *tl = NULL;
    313 
    314         /* ?? privacy ?? */
    315         aim_addtlvtochain16(&tl, 0x000a, privacy);
    316 
    317         if (interest1)
    318                 aim_addtlvtochain_raw(&tl, 0x0000b, strlen(interest1), (guint8 *)interest1);
    319         if (interest2)
    320                 aim_addtlvtochain_raw(&tl, 0x0000b, strlen(interest2), (guint8 *)interest2);
    321         if (interest3)
    322                 aim_addtlvtochain_raw(&tl, 0x0000b, strlen(interest3), (guint8 *)interest3);
    323         if (interest4)
    324                 aim_addtlvtochain_raw(&tl, 0x0000b, strlen(interest4), (guint8 *)interest4);
    325         if (interest5)
    326                 aim_addtlvtochain_raw(&tl, 0x0000b, strlen(interest5), (guint8 *)interest5);
    327 
    328         if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+aim_sizetlvchain(&tl))))
    329                 return -ENOMEM;
    330 
    331         aim_cachesnac(sess, 0x0002, 0x000f, 0x0000, NULL, 0);
    332 
    333         aim_putsnac(&fr->data, 0x0002, 0x000f, 0x0000, 0);
    334         aim_writetlvchain(&fr->data, &tl);
    335         aim_freetlvchain(&tl);
    336 
    337         aim_tx_enqueue(sess, fr);
    338 
    339         return 0;
    340172}
    341173
Note: See TracChangeset for help on using the changeset viewer.