annotate libfaim/aim_buddylist.c @ 1190:c3ebd5932e32

[gaim-migrate @ 1200] this is not a drill committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Sat, 02 Dec 2000 20:02:59 +0000
parents 595ac7759563
children 920c86b753d7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1
283
0f14e6d8a51b [gaim-migrate @ 293]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 237
diff changeset
2 #include <faim/aim.h>
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4 /*
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
5 * aim_add_buddy()
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
6 *
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
7 * Adds a single buddy to your buddy list after login.
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
8 *
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
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
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
13 {
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
14 struct command_tx_struct *newpacket;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
15 int i;
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
16
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
17 if(!sn)
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
18 return -1;
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
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
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
21 return -1;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
22
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
23 newpacket->lock = 1;
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
24
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
25 i = aim_putsnac(newpacket->data, 0x0003, 0x0004, 0x0000, sess->snac_nextid);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
26 i += aimutil_put8(newpacket->data+i, strlen(sn));
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
27 i += aimutil_putstr(newpacket->data+i, sn, strlen(sn));
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
28
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
29 aim_tx_enqueue(sess, newpacket );
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
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
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
32 {
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
33 struct aim_snac_t snac;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
34
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
35 snac.id = sess->snac_nextid;
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
36 snac.family = 0x0003;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
37 snac.type = 0x0004;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
38 snac.flags = 0x0000;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
39
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
40 snac.data = malloc( strlen( sn ) + 1 );
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
41 memcpy( snac.data, sn, strlen( sn ) + 1 );
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
42
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
43 aim_newsnac(sess, &snac);
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
44 }
715
58106806ac2b [gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 445
diff changeset
45 #endif
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
46
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
47 return( sess->snac_nextid++ );
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
48 }
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
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
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
53 {
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
54 struct command_tx_struct *newpacket;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
55 int i;
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
56
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
57 if(!sn)
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
58 return -1;
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
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
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
61 return -1;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
62
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
63 newpacket->lock = 1;
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
64
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
65 i = aim_putsnac(newpacket->data, 0x0003, 0x0005, 0x0000, sess->snac_nextid);
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
66
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
67 i += aimutil_put8(newpacket->data+i, strlen(sn));
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
68 i += aimutil_putstr(newpacket->data+i, sn, strlen(sn));
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
69
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
70 aim_tx_enqueue(sess, newpacket);
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
71
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
72 {
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
73 struct aim_snac_t snac;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
74
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
75 snac.id = sess->snac_nextid;
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
76 snac.family = 0x0003;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
77 snac.type = 0x0005;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
78 snac.flags = 0x0000;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
79
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
80 snac.data = malloc( strlen( sn ) + 1 );
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
81 memcpy( snac.data, sn, strlen( sn ) + 1 );
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
82
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
83 aim_newsnac(sess, &snac );
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
84 }
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
85
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
86 return( sess->snac_nextid++ );
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
87 }
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
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 }