Mercurial > pidgin
annotate src/protocols/oscar/chat.c @ 6318:96196cfb132e
[gaim-migrate @ 6817]
How now, brown cow?
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 28 Jul 2003 02:52:23 +0000 |
parents | 5e9364e9b29e |
children | 6d3d8f11e765 |
rev | line source |
---|---|
2086 | 1 /* |
3952 | 2 * Family 0x000e - Routines for the Chat service. |
2086 | 3 * |
4 */ | |
5 | |
6 #define FAIM_INTERNAL | |
7 #include <aim.h> | |
8 | |
5927 | 9 #include <string.h> |
10 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
11 /* Stored in the ->priv of chat connections */ |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
12 struct chatconnpriv { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
13 fu16_t exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
14 char *name; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
15 fu16_t instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
16 }; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
17 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
18 faim_internal void aim_conn_kill_chat(aim_session_t *sess, aim_conn_t *conn) |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
19 { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
20 struct chatconnpriv *ccp = (struct chatconnpriv *)conn->priv; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
21 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
22 if (ccp) |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
23 free(ccp->name); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
24 free(ccp); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
25 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
26 return; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
27 } |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
28 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
29 faim_export char *aim_chat_getname(aim_conn_t *conn) |
2086 | 30 { |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
31 struct chatconnpriv *ccp; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
32 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
33 if (!conn) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
34 return NULL; |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
35 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
36 if (conn->type != AIM_CONN_TYPE_CHAT) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
37 return NULL; |
2086 | 38 |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
39 ccp = (struct chatconnpriv *)conn->priv; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
40 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
41 return ccp->name; |
2086 | 42 } |
43 | |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
44 /* XXX get this into conn.c -- evil!! */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
45 faim_export aim_conn_t *aim_chat_getconn(aim_session_t *sess, const char *name) |
2086 | 46 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
47 aim_conn_t *cur; |
2086 | 48 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
49 for (cur = sess->connlist; cur; cur = cur->next) { |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
50 struct chatconnpriv *ccp = (struct chatconnpriv *)cur->priv; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
51 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
52 if (cur->type != AIM_CONN_TYPE_CHAT) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
53 continue; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
54 if (!cur->priv) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
55 faimdprintf(sess, 0, "faim: chat: chat connection with no name! (fd = %d)\n", cur->fd); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
56 continue; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
57 } |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
58 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
59 if (strcmp(ccp->name, name) == 0) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
60 break; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
61 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
62 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
63 return cur; |
2086 | 64 } |
65 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
66 faim_export int aim_chat_attachname(aim_conn_t *conn, fu16_t exchange, const char *roomname, fu16_t instance) |
2086 | 67 { |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
68 struct chatconnpriv *ccp; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
69 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
70 if (!conn || !roomname) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
71 return -EINVAL; |
2086 | 72 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
73 if (conn->priv) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
74 free(conn->priv); |
2086 | 75 |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
76 if (!(ccp = malloc(sizeof(struct chatconnpriv)))) |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
77 return -ENOMEM; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
78 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
79 ccp->exchange = exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
80 ccp->name = strdup(roomname); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
81 ccp->instance = instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
82 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
83 conn->priv = (void *)ccp; |
2086 | 84 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
85 return 0; |
2086 | 86 } |
87 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
88 static int aim_addtlvtochain_chatroom(aim_tlvlist_t **list, fu16_t type, fu16_t exchange, const char *roomname, fu16_t instance) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
89 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
90 fu8_t *buf; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
91 int buflen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
92 aim_bstream_t bs; |
2086 | 93 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
94 buflen = 2 + 1 + strlen(roomname) + 2; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
95 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
96 if (!(buf = malloc(buflen))) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
97 return 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
98 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
99 aim_bstream_init(&bs, buf, buflen); |
2086 | 100 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
101 aimbs_put16(&bs, exchange); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
102 aimbs_put8(&bs, strlen(roomname)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
103 aimbs_putraw(&bs, roomname, strlen(roomname)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
104 aimbs_put16(&bs, instance); |
2086 | 105 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
106 aim_addtlvtochain_raw(list, type, aim_bstream_curpos(&bs), buf); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
107 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
108 free(buf); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
109 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
110 return 0; |
2086 | 111 } |
112 | |
113 /* | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
114 * Join a room of name roomname. This is the first step to joining an |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
115 * already created room. It's basically a Service Request for |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
116 * family 0x000e, with a little added on to specify the exchange and room |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
117 * name. |
2086 | 118 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
119 faim_export int aim_chat_join(aim_session_t *sess, aim_conn_t *conn, fu16_t exchange, const char *roomname, fu16_t instance) |
2086 | 120 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
121 aim_frame_t *fr; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
122 aim_snacid_t snacid; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
123 aim_tlvlist_t *tl = NULL; |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
124 struct chatsnacinfo csi; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
125 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
126 if (!sess || !conn || !roomname || !strlen(roomname)) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
127 return -EINVAL; |
2086 | 128 |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
129 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 512))) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
130 return -ENOMEM; |
2086 | 131 |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
132 memset(&csi, 0, sizeof(csi)); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
133 csi.exchange = exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
134 strncpy(csi.name, roomname, sizeof(csi.name)); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
135 csi.instance = instance; |
2086 | 136 |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
137 snacid = aim_cachesnac(sess, 0x0001, 0x0004, 0x0000, &csi, sizeof(csi)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
138 aim_putsnac(&fr->data, 0x0001, 0x0004, 0x0000, snacid); |
2086 | 139 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
140 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
141 * Requesting service chat (0x000e) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
142 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
143 aimbs_put16(&fr->data, 0x000e); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
144 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
145 aim_addtlvtochain_chatroom(&tl, 0x0001, exchange, roomname, instance); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
146 aim_writetlvchain(&fr->data, &tl); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
147 aim_freetlvchain(&tl); |
2086 | 148 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
149 aim_tx_enqueue(sess, fr); |
2086 | 150 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
151 return 0; |
2086 | 152 } |
153 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
154 faim_internal int aim_chat_readroominfo(aim_bstream_t *bs, struct aim_chat_roominfo *outinfo) |
2086 | 155 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
156 int namelen; |
2086 | 157 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
158 if (!bs || !outinfo) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
159 return 0; |
2086 | 160 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
161 outinfo->exchange = aimbs_get16(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
162 namelen = aimbs_get8(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
163 outinfo->name = aimbs_getstr(bs, namelen); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
164 outinfo->instance = aimbs_get16(bs); |
2086 | 165 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
166 return 0; |
2086 | 167 } |
168 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
169 faim_export int aim_chat_leaveroom(aim_session_t *sess, const char *name) |
2086 | 170 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
171 aim_conn_t *conn; |
2086 | 172 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
173 if (!(conn = aim_chat_getconn(sess, name))) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
174 return -ENOENT; |
2086 | 175 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
176 aim_conn_close(conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
177 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
178 return 0; |
2086 | 179 } |
180 | |
181 /* | |
182 * conn must be a BOS connection! | |
183 */ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
184 faim_export int aim_chat_invite(aim_session_t *sess, aim_conn_t *conn, const char *sn, const char *msg, fu16_t exchange, const char *roomname, fu16_t instance) |
2086 | 185 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
186 int i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
187 aim_frame_t *fr; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
188 aim_msgcookie_t *cookie; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
189 struct aim_invite_priv *priv; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
190 fu8_t ckstr[8]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
191 aim_snacid_t snacid; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
192 aim_tlvlist_t *otl = NULL, *itl = NULL; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
193 fu8_t *hdr; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
194 int hdrlen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
195 aim_bstream_t hdrbs; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
196 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
197 if (!sess || !conn || !sn || !msg || !roomname) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
198 return -EINVAL; |
2086 | 199 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
200 if (conn->type != AIM_CONN_TYPE_BOS) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
201 return -EINVAL; |
2086 | 202 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
203 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152+strlen(sn)+strlen(roomname)+strlen(msg)))) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
204 return -ENOMEM; |
2086 | 205 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
206 snacid = aim_cachesnac(sess, 0x0004, 0x0006, 0x0000, sn, strlen(sn)+1); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
207 aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
208 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
209 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
210 * Cookie |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
211 */ |
4901 | 212 for (i = 0; i < 8; i++) |
213 ckstr[i] = (fu8_t)rand(); | |
2086 | 214 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
215 /* XXX should be uncached by an unwritten 'invite accept' handler */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
216 if ((priv = malloc(sizeof(struct aim_invite_priv)))) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
217 priv->sn = strdup(sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
218 priv->roomname = strdup(roomname); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
219 priv->exchange = exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
220 priv->instance = instance; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
221 } |
2086 | 222 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
223 if ((cookie = aim_mkcookie(ckstr, AIM_COOKIETYPE_INVITE, priv))) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
224 aim_cachecookie(sess, cookie); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
225 else |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
226 free(priv); |
2086 | 227 |
4901 | 228 /* ICBM Header */ |
229 aimbs_putraw(&fr->data, ckstr, 8); /* Cookie */ | |
230 aimbs_put16(&fr->data, 0x0002); /* Channel */ | |
231 aimbs_put8(&fr->data, strlen(sn)); /* Screename length */ | |
232 aimbs_putraw(&fr->data, sn, strlen(sn)); /* Screenname */ | |
2086 | 233 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
234 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
235 * TLV t(0005) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
236 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
237 * Everything else is inside this TLV. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
238 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
239 * Sigh. AOL was rather inconsistent right here. So we have |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
240 * to play some minor tricks. Right inside the type 5 is some |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
241 * raw data, followed by a series of TLVs. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
242 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
243 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
244 hdrlen = 2+8+16+6+4+4+strlen(msg)+4+2+1+strlen(roomname)+2; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
245 hdr = malloc(hdrlen); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
246 aim_bstream_init(&hdrbs, hdr, hdrlen); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
247 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
248 aimbs_put16(&hdrbs, 0x0000); /* Unknown! */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
249 aimbs_putraw(&hdrbs, ckstr, sizeof(ckstr)); /* I think... */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
250 aim_putcap(&hdrbs, AIM_CAPS_CHAT); |
2086 | 251 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
252 aim_addtlvtochain16(&itl, 0x000a, 0x0001); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
253 aim_addtlvtochain_noval(&itl, 0x000f); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
254 aim_addtlvtochain_raw(&itl, 0x000c, strlen(msg), msg); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
255 aim_addtlvtochain_chatroom(&itl, 0x2711, exchange, roomname, instance); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
256 aim_writetlvchain(&hdrbs, &itl); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
257 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
258 aim_addtlvtochain_raw(&otl, 0x0005, aim_bstream_curpos(&hdrbs), hdr); |
2086 | 259 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
260 aim_writetlvchain(&fr->data, &otl); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
261 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
262 free(hdr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
263 aim_freetlvchain(&itl); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
264 aim_freetlvchain(&otl); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
265 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
266 aim_tx_enqueue(sess, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
267 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
268 return 0; |
2086 | 269 } |
270 | |
271 /* | |
3952 | 272 * Subtype 0x0002 - General room information. Lots of stuff. |
2086 | 273 * |
274 * Values I know are in here but I havent attached | |
275 * them to any of the 'Unknown's: | |
276 * - Language (English) | |
277 * | |
278 */ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
279 static int infoupdate(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
2086 | 280 { |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2270
diff
changeset
|
281 aim_userinfo_t *userinfo = NULL; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
282 aim_rxcallback_t userfunc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
283 int ret = 0; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
284 int usercount = 0; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
285 fu8_t detaillevel = 0; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
286 char *roomname = NULL; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
287 struct aim_chat_roominfo roominfo; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
288 fu16_t tlvcount = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
289 aim_tlvlist_t *tlvlist; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
290 char *roomdesc = NULL; |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
291 fu16_t flags = 0; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
292 fu32_t creationtime = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
293 fu16_t maxmsglen = 0, maxvisiblemsglen = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
294 fu16_t unknown_d2 = 0, unknown_d5 = 0; |
2086 | 295 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
296 aim_chat_readroominfo(bs, &roominfo); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
297 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
298 detaillevel = aimbs_get8(bs); |
2086 | 299 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
300 if (detaillevel != 0x02) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
301 faimdprintf(sess, 0, "faim: chat_roomupdateinfo: detail level %d not supported\n", detaillevel); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
302 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
303 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
304 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
305 tlvcount = aimbs_get16(bs); |
2086 | 306 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
307 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
308 * Everything else are TLVs. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
309 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
310 tlvlist = aim_readtlvchain(bs); |
2086 | 311 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
312 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
313 * TLV type 0x006a is the room name in Human Readable Form. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
314 */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
315 if (aim_gettlv(tlvlist, 0x006a, 1)) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
316 roomname = aim_gettlv_str(tlvlist, 0x006a, 1); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
317 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
318 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
319 * Type 0x006f: Number of occupants. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
320 */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
321 if (aim_gettlv(tlvlist, 0x006f, 1)) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
322 usercount = aim_gettlv16(tlvlist, 0x006f, 1); |
2086 | 323 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
324 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
325 * Type 0x0073: Occupant list. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
326 */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
327 if (aim_gettlv(tlvlist, 0x0073, 1)) { |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
328 int curoccupant = 0; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
329 aim_tlv_t *tmptlv; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
330 aim_bstream_t occbs; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
331 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
332 tmptlv = aim_gettlv(tlvlist, 0x0073, 1); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
333 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
334 /* Allocate enough userinfo structs for all occupants */ |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2270
diff
changeset
|
335 userinfo = calloc(usercount, sizeof(aim_userinfo_t)); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
336 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
337 aim_bstream_init(&occbs, tmptlv->value, tmptlv->length); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
338 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
339 while (curoccupant < usercount) |
5836 | 340 aim_info_extract(sess, &occbs, &userinfo[curoccupant++]); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
341 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
342 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
343 /* |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
344 * Type 0x00c9: Flags. (AIM_CHATROOM_FLAG) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
345 */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
346 if (aim_gettlv(tlvlist, 0x00c9, 1)) |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
347 flags = aim_gettlv16(tlvlist, 0x00c9, 1); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
348 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
349 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
350 * Type 0x00ca: Creation time (4 bytes) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
351 */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
352 if (aim_gettlv(tlvlist, 0x00ca, 1)) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
353 creationtime = aim_gettlv32(tlvlist, 0x00ca, 1); |
2086 | 354 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
355 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
356 * Type 0x00d1: Maximum Message Length |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
357 */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
358 if (aim_gettlv(tlvlist, 0x00d1, 1)) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
359 maxmsglen = aim_gettlv16(tlvlist, 0x00d1, 1); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
360 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
361 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
362 * Type 0x00d2: Unknown. (2 bytes) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
363 */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
364 if (aim_gettlv(tlvlist, 0x00d2, 1)) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
365 unknown_d2 = aim_gettlv16(tlvlist, 0x00d2, 1); |
2086 | 366 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
367 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
368 * Type 0x00d3: Room Description |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
369 */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
370 if (aim_gettlv(tlvlist, 0x00d3, 1)) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
371 roomdesc = aim_gettlv_str(tlvlist, 0x00d3, 1); |
2086 | 372 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
373 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
374 * Type 0x000d4: Unknown (flag only) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
375 */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
376 if (aim_gettlv(tlvlist, 0x000d4, 1)) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
377 ; |
2086 | 378 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
379 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
380 * Type 0x00d5: Unknown. (1 byte) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
381 */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
382 if (aim_gettlv(tlvlist, 0x00d5, 1)) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
383 unknown_d5 = aim_gettlv8(tlvlist, 0x00d5, 1); |
2086 | 384 |
385 | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
386 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
387 * Type 0x00d6: Encoding 1 ("us-ascii") |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
388 */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
389 if (aim_gettlv(tlvlist, 0x000d6, 1)) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
390 ; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
391 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
392 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
393 * Type 0x00d7: Language 1 ("en") |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
394 */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
395 if (aim_gettlv(tlvlist, 0x000d7, 1)) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
396 ; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
397 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
398 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
399 * Type 0x00d8: Encoding 2 ("us-ascii") |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
400 */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
401 if (aim_gettlv(tlvlist, 0x000d8, 1)) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
402 ; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
403 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
404 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
405 * Type 0x00d9: Language 2 ("en") |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
406 */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
407 if (aim_gettlv(tlvlist, 0x000d9, 1)) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
408 ; |
2086 | 409 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
410 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
411 * Type 0x00da: Maximum visible message length |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
412 */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
413 if (aim_gettlv(tlvlist, 0x000da, 1)) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
414 maxvisiblemsglen = aim_gettlv16(tlvlist, 0x00da, 1); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
415 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
416 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) { |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
417 ret = userfunc(sess, |
5836 | 418 rx, |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
419 &roominfo, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
420 roomname, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
421 usercount, |
5836 | 422 userinfo, |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
423 roomdesc, |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
424 flags, |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
425 creationtime, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
426 maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
427 unknown_d2, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
428 unknown_d5, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
429 maxvisiblemsglen); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
430 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
431 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
432 free(roominfo.name); |
5836 | 433 |
434 while (usercount > 0) | |
435 aim_info_free(&userinfo[--usercount]); | |
436 | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
437 free(userinfo); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
438 free(roomname); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
439 free(roomdesc); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
440 aim_freetlvchain(&tlvlist); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
441 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
442 return ret; |
2086 | 443 } |
444 | |
3952 | 445 /* Subtypes 0x0003 and 0x0004 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
446 static int userlistchange(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
2086 | 447 { |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2270
diff
changeset
|
448 aim_userinfo_t *userinfo = NULL; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
449 aim_rxcallback_t userfunc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
450 int curcount = 0, ret = 0; |
2086 | 451 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
452 while (aim_bstream_empty(bs)) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
453 curcount++; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2270
diff
changeset
|
454 userinfo = realloc(userinfo, curcount * sizeof(aim_userinfo_t)); |
5836 | 455 aim_info_extract(sess, bs, &userinfo[curcount-1]); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
456 } |
2086 | 457 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
458 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
459 ret = userfunc(sess, rx, curcount, userinfo); |
2086 | 460 |
5836 | 461 aim_info_free(userinfo); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
462 free(userinfo); |
2086 | 463 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
464 return ret; |
2086 | 465 } |
466 | |
467 /* | |
3952 | 468 * Subtype 0x0005 - Send a Chat Message. |
469 * | |
470 * Possible flags: | |
471 * AIM_CHATFLAGS_NOREFLECT -- Unset the flag that requests messages | |
472 * should be sent to their sender. | |
473 * AIM_CHATFLAGS_AWAY -- Mark the message as an autoresponse | |
474 * (Note that WinAIM does not honor this, | |
475 * and displays the message as normal.) | |
476 * | |
477 * XXX convert this to use tlvchains | |
478 */ | |
479 faim_export int aim_chat_send_im(aim_session_t *sess, aim_conn_t *conn, fu16_t flags, const char *msg, int msglen) | |
480 { | |
481 int i; | |
482 aim_frame_t *fr; | |
483 aim_msgcookie_t *cookie; | |
484 aim_snacid_t snacid; | |
485 fu8_t ckstr[8]; | |
486 aim_tlvlist_t *otl = NULL, *itl = NULL; | |
487 | |
488 if (!sess || !conn || !msg || (msglen <= 0)) | |
489 return 0; | |
490 | |
491 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152))) | |
492 return -ENOMEM; | |
493 | |
494 snacid = aim_cachesnac(sess, 0x000e, 0x0005, 0x0000, NULL, 0); | |
495 aim_putsnac(&fr->data, 0x000e, 0x0005, 0x0000, snacid); | |
496 | |
4901 | 497 /* |
498 * Cookie | |
3952 | 499 * |
500 * XXX mkcookie should generate the cookie and cache it in one | |
501 * operation to preserve uniqueness. | |
502 */ | |
4901 | 503 for (i = 0; i < 8; i++) |
504 ckstr[i] = (fu8_t)rand(); | |
3952 | 505 |
506 cookie = aim_mkcookie(ckstr, AIM_COOKIETYPE_CHAT, NULL); | |
507 cookie->data = NULL; /* XXX store something useful here */ | |
508 | |
509 aim_cachecookie(sess, cookie); | |
510 | |
4901 | 511 /* ICBM Header */ |
512 aimbs_putraw(&fr->data, ckstr, 8); /* Cookie */ | |
513 aimbs_put16(&fr->data, 0x0003); /* Channel */ | |
3952 | 514 |
515 /* | |
516 * Type 1: Flag meaning this message is destined to the room. | |
517 */ | |
518 aim_addtlvtochain_noval(&otl, 0x0001); | |
519 | |
520 /* | |
521 * Type 6: Reflect | |
522 */ | |
523 if (!(flags & AIM_CHATFLAGS_NOREFLECT)) | |
524 aim_addtlvtochain_noval(&otl, 0x0006); | |
525 | |
526 /* | |
527 * Type 7: Autoresponse | |
528 */ | |
529 if (flags & AIM_CHATFLAGS_AWAY) | |
530 aim_addtlvtochain_noval(&otl, 0x0007); | |
531 | |
532 /* | |
533 * SubTLV: Type 1: Message | |
534 */ | |
6001 | 535 aim_addtlvtochain_raw(&itl, 0x0001, msglen, msg); |
3952 | 536 |
537 /* | |
538 * Type 5: Message block. Contains more TLVs. | |
539 * | |
540 * This could include other information... We just | |
541 * put in a message TLV however. | |
542 * | |
543 */ | |
544 aim_addtlvtochain_frozentlvlist(&otl, 0x0005, &itl); | |
545 | |
546 aim_writetlvchain(&fr->data, &otl); | |
547 | |
548 aim_freetlvchain(&itl); | |
549 aim_freetlvchain(&otl); | |
550 | |
551 aim_tx_enqueue(sess, fr); | |
552 | |
553 return 0; | |
554 } | |
555 | |
556 /* | |
557 * Subtype 0x0006 | |
558 * | |
2086 | 559 * We could probably include this in the normal ICBM parsing |
560 * code as channel 0x0003, however, since only the start | |
561 * would be the same, we might as well do it here. | |
562 * | |
563 * General outline of this SNAC: | |
564 * snac | |
565 * cookie | |
566 * channel id | |
567 * tlvlist | |
568 * unknown | |
569 * source user info | |
570 * name | |
571 * evility | |
572 * userinfo tlvs | |
573 * online time | |
574 * etc | |
575 * message metatlv | |
576 * message tlv | |
577 * message string | |
578 * possibly others | |
579 * | |
580 */ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
581 static int incomingmsg(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
2086 | 582 { |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2270
diff
changeset
|
583 aim_userinfo_t userinfo; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
584 aim_rxcallback_t userfunc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
585 int ret = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
586 fu8_t *cookie; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
587 fu16_t channel; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
588 aim_tlvlist_t *otl; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
589 char *msg = NULL; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
590 aim_msgcookie_t *ck; |
2086 | 591 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2270
diff
changeset
|
592 memset(&userinfo, 0, sizeof(aim_userinfo_t)); |
2086 | 593 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
594 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
595 * ICBM Cookie. Uncache it. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
596 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
597 cookie = aimbs_getraw(bs, 8); |
2086 | 598 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
599 if ((ck = aim_uncachecookie(sess, cookie, AIM_COOKIETYPE_CHAT))) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
600 free(ck->data); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
601 free(ck); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
602 } |
2086 | 603 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
604 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
605 * Channel ID |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
606 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
607 * Channels 1 and 2 are implemented in the normal ICBM |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
608 * parser. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
609 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
610 * We only do channel 3 here. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
611 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
612 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
613 channel = aimbs_get16(bs); |
2086 | 614 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
615 if (channel != 0x0003) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
616 faimdprintf(sess, 0, "faim: chat_incoming: unknown channel! (0x%04x)\n", channel); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
617 return 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
618 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
619 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
620 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
621 * Start parsing TLVs right away. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
622 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
623 otl = aim_readtlvchain(bs); |
2086 | 624 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
625 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
626 * Type 0x0003: Source User Information |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
627 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
628 if (aim_gettlv(otl, 0x0003, 1)) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
629 aim_tlv_t *userinfotlv; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
630 aim_bstream_t tbs; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
631 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
632 userinfotlv = aim_gettlv(otl, 0x0003, 1); |
2086 | 633 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
634 aim_bstream_init(&tbs, userinfotlv->value, userinfotlv->length); |
5836 | 635 aim_info_extract(sess, &tbs, &userinfo); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
636 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
637 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
638 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
639 * Type 0x0001: If present, it means it was a message to the |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
640 * room (as opposed to a whisper). |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
641 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
642 if (aim_gettlv(otl, 0x0001, 1)) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
643 ; |
2086 | 644 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
645 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
646 * Type 0x0005: Message Block. Conains more TLVs. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
647 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
648 if (aim_gettlv(otl, 0x0005, 1)) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
649 aim_tlvlist_t *itl; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
650 aim_tlv_t *msgblock; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
651 aim_bstream_t tbs; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
652 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
653 msgblock = aim_gettlv(otl, 0x0005, 1); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
654 aim_bstream_init(&tbs, msgblock->value, msgblock->length); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
655 itl = aim_readtlvchain(&tbs); |
2086 | 656 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
657 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
658 * Type 0x0001: Message. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
659 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
660 if (aim_gettlv(itl, 0x0001, 1)) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
661 msg = aim_gettlv_str(itl, 0x0001, 1); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
662 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
663 aim_freetlvchain(&itl); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
664 } |
2086 | 665 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
666 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
667 ret = userfunc(sess, rx, &userinfo, msg); |
2086 | 668 |
5836 | 669 aim_info_free(&userinfo); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
670 free(cookie); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
671 free(msg); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
672 aim_freetlvchain(&otl); |
2086 | 673 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
674 return ret; |
2086 | 675 } |
676 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
677 static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
2086 | 678 { |
679 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
680 if (snac->subtype == 0x0002) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
681 return infoupdate(sess, mod, rx, snac, bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
682 else if ((snac->subtype == 0x0003) || (snac->subtype == 0x0004)) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
683 return userlistchange(sess, mod, rx, snac, bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
684 else if (snac->subtype == 0x0006) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
685 return incomingmsg(sess, mod, rx, snac, bs); |
2086 | 686 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
687 return 0; |
2086 | 688 } |
689 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
690 faim_internal int chat_modfirst(aim_session_t *sess, aim_module_t *mod) |
2086 | 691 { |
692 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
693 mod->family = 0x000e; |
2672 | 694 mod->version = 0x0001; |
4071 | 695 mod->toolid = 0x0010; |
696 mod->toolversion = 0x0629; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
697 mod->flags = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
698 strncpy(mod->name, "chat", sizeof(mod->name)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
699 mod->snachandler = snachandler; |
2086 | 700 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
701 return 0; |
2086 | 702 } |