Mercurial > pidgin.yaz
annotate libfaim/aim_buddylist.c @ 932:13bdc97d433e
[gaim-migrate @ 942]
bah. hopefully this will help people who aren't POSIX compliant.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Thu, 21 Sep 2000 00:45:30 +0000 |
parents | 595ac7759563 |
children | 920c86b753d7 |
rev | line source |
---|---|
2 | 1 |
283
0f14e6d8a51b
[gaim-migrate @ 293]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
2 #include <faim/aim.h> |
2 | 3 |
4 /* | |
5 * aim_add_buddy() | |
6 * | |
7 * Adds a single buddy to your buddy list after login. | |
8 * | |
9 */ | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
10 faim_export unsigned long aim_add_buddy(struct aim_session_t *sess, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
11 struct aim_conn_t *conn, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
12 char *sn ) |
2 | 13 { |
237 | 14 struct command_tx_struct *newpacket; |
15 int i; | |
2 | 16 |
237 | 17 if(!sn) |
18 return -1; | |
2 | 19 |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
20 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+1+strlen(sn)))) |
237 | 21 return -1; |
22 | |
23 newpacket->lock = 1; | |
2 | 24 |
237 | 25 i = aim_putsnac(newpacket->data, 0x0003, 0x0004, 0x0000, sess->snac_nextid); |
26 i += aimutil_put8(newpacket->data+i, strlen(sn)); | |
27 i += aimutil_putstr(newpacket->data+i, sn, strlen(sn)); | |
2 | 28 |
237 | 29 aim_tx_enqueue(sess, newpacket ); |
2 | 30 |
715
58106806ac2b
[gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
31 #if 0 /* do we really need this code? */ |
2 | 32 { |
33 struct aim_snac_t snac; | |
34 | |
237 | 35 snac.id = sess->snac_nextid; |
2 | 36 snac.family = 0x0003; |
37 snac.type = 0x0004; | |
38 snac.flags = 0x0000; | |
39 | |
40 snac.data = malloc( strlen( sn ) + 1 ); | |
41 memcpy( snac.data, sn, strlen( sn ) + 1 ); | |
42 | |
237 | 43 aim_newsnac(sess, &snac); |
2 | 44 } |
715
58106806ac2b
[gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
45 #endif |
2 | 46 |
237 | 47 return( sess->snac_nextid++ ); |
2 | 48 } |
49 | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
50 faim_export unsigned long aim_remove_buddy(struct aim_session_t *sess, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
51 struct aim_conn_t *conn, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
52 char *sn ) |
2 | 53 { |
237 | 54 struct command_tx_struct *newpacket; |
55 int i; | |
2 | 56 |
237 | 57 if(!sn) |
58 return -1; | |
2 | 59 |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
60 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+1+strlen(sn)))) |
237 | 61 return -1; |
62 | |
63 newpacket->lock = 1; | |
2 | 64 |
237 | 65 i = aim_putsnac(newpacket->data, 0x0003, 0x0005, 0x0000, sess->snac_nextid); |
2 | 66 |
237 | 67 i += aimutil_put8(newpacket->data+i, strlen(sn)); |
68 i += aimutil_putstr(newpacket->data+i, sn, strlen(sn)); | |
2 | 69 |
237 | 70 aim_tx_enqueue(sess, newpacket); |
2 | 71 |
72 { | |
73 struct aim_snac_t snac; | |
74 | |
237 | 75 snac.id = sess->snac_nextid; |
2 | 76 snac.family = 0x0003; |
77 snac.type = 0x0005; | |
78 snac.flags = 0x0000; | |
79 | |
80 snac.data = malloc( strlen( sn ) + 1 ); | |
81 memcpy( snac.data, sn, strlen( sn ) + 1 ); | |
82 | |
237 | 83 aim_newsnac(sess, &snac ); |
2 | 84 } |
85 | |
237 | 86 return( sess->snac_nextid++ ); |
2 | 87 } |
88 | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
89 faim_internal int aim_parse_buddyrights(struct aim_session_t *sess, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
90 struct command_rx_struct *command, ...) |
835
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
91 { |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
92 rxcallback_t userfunc = NULL; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
93 int ret=1; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
94 struct aim_tlvlist_t *tlvlist; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
95 struct aim_tlv_t *tlv; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
96 unsigned short maxbuddies = 0, maxwatchers = 0; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
97 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
98 /* |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
99 * TLVs follow |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
100 */ |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
101 if (!(tlvlist = aim_readtlvchain(command->data+10, command->commandlen-10))) |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
102 return ret; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
103 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
104 /* |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
105 * TLV type 0x0001: Maximum number of buddies. |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
106 */ |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
107 if ((tlv = aim_gettlv(tlvlist, 0x0001, 1))) { |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
108 maxbuddies = aimutil_get16(tlv->value); |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
109 } |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
110 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
111 /* |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
112 * TLV type 0x0002: Maximum number of watchers. |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
113 * |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
114 * XXX: what the hell is a watcher? |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
115 * |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
116 */ |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
117 if ((tlv = aim_gettlv(tlvlist, 0x0002, 1))) { |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
118 maxwatchers = aimutil_get16(tlv->value); |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
119 } |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
120 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
121 userfunc = aim_callhandler(command->conn, 0x0003, 0x0003); |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
122 if (userfunc) |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
123 ret = userfunc(sess, command, maxbuddies, maxwatchers); |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
124 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
125 aim_freetlvchain(&tlvlist); |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
126 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
127 return ret; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
128 } |