comparison libpurple/protocols/oscar/family_chat.c @ 30388:88689cda97d8

Turns out that ncc doesn't catch everything, so continue killing things mercilessly. Removed AIM_CHATROOM_FLAG_* defines and everything that wasn't used in purple_conv_chat_info_update() (pretty much all contents of a packet). Also, removed unused aim_util_*() and aim_chat_getconn() functions.
author ivan.komarov@soc.pidgin.im
date Wed, 28 Jul 2010 18:59:39 +0000
parents 420907755a2f
children 553cd883a29a
comparison
equal deleted inserted replaced
30387:420907755a2f 30388:88689cda97d8
45 g_free(ccp); 45 g_free(ccp);
46 46
47 return; 47 return;
48 } 48 }
49 49
50 /* XXX get this into conn.c -- evil!! */
51 FlapConnection *
52 aim_chat_getconn(OscarData *od, const char *name)
53 {
54 GSList *cur;
55
56 for (cur = od->oscar_connections; cur; cur = cur->next)
57 {
58 FlapConnection *conn;
59 struct chatconnpriv *ccp;
60
61 conn = cur->data;
62 ccp = (struct chatconnpriv *)conn->internal;
63
64 if (conn->type != SNAC_FAMILY_CHAT)
65 continue;
66 if (!conn->internal)
67 {
68 purple_debug_misc("oscar", "%sfaim: chat: chat connection with no name! (fd = %d)\n",
69 conn->gsc ? "(ssl) " : "", conn->gsc ? conn->gsc->fd : conn->fd);
70 continue;
71 }
72
73 if (strcmp(ccp->name, name) == 0)
74 return conn;
75 }
76
77 return NULL;
78 }
79
80 int 50 int
81 aim_chat_readroominfo(ByteStream *bs, struct aim_chat_roominfo *outinfo) 51 aim_chat_readroominfo(ByteStream *bs, struct aim_chat_roominfo *outinfo)
82 { 52 {
83 if (!bs || !outinfo) 53 if (!bs || !outinfo)
84 return 0; 54 return 0;
100 * 70 *
101 */ 71 */
102 static int 72 static int
103 infoupdate(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) 73 infoupdate(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
104 { 74 {
105 aim_userinfo_t *userinfo = NULL;
106 aim_rxcallback_t userfunc; 75 aim_rxcallback_t userfunc;
107 int ret = 0; 76 int ret = 0;
108 int usercount;
109 guint8 detaillevel = 0; 77 guint8 detaillevel = 0;
110 char *roomname;
111 struct aim_chat_roominfo roominfo; 78 struct aim_chat_roominfo roominfo;
112 guint16 tlvcount = 0;
113 GSList *tlvlist; 79 GSList *tlvlist;
114 aim_tlv_t *tlv;
115 char *roomdesc;
116 guint16 flags;
117 guint32 creationtime;
118 guint16 maxmsglen, maxvisiblemsglen; 80 guint16 maxmsglen, maxvisiblemsglen;
119 guint16 unknown_d2, unknown_d5;
120 81
121 aim_chat_readroominfo(bs, &roominfo); 82 aim_chat_readroominfo(bs, &roominfo);
122 83
123 detaillevel = byte_stream_get8(bs); 84 detaillevel = byte_stream_get8(bs);
124 85
125 if (detaillevel != 0x02) { 86 if (detaillevel != 0x02) {
126 purple_debug_misc("oscar", "faim: chat_roomupdateinfo: detail level %d not supported\n", detaillevel); 87 purple_debug_misc("oscar", "faim: chat_roomupdateinfo: detail level %d not supported\n", detaillevel);
127 return 1; 88 return 1;
128 } 89 }
129 90
130 tlvcount = byte_stream_get16(bs);
131
132 /* 91 /*
133 * Everything else are TLVs. 92 * Everything else are TLVs.
134 */ 93 */
135 tlvlist = aim_tlvlist_read(bs); 94 tlvlist = aim_tlvlist_read(bs);
136 95
137 /* 96 /*
138 * TLV type 0x006a is the room name in Human Readable Form.
139 */
140 roomname = aim_tlv_getstr(tlvlist, 0x006a, 1);
141
142 /*
143 * Type 0x006f: Number of occupants.
144 */
145 usercount = aim_tlv_get16(tlvlist, 0x006f, 1);
146
147 /*
148 * Type 0x0073: Occupant list.
149 */
150 tlv = aim_tlv_gettlv(tlvlist, 0x0073, 1);
151 if (tlv != NULL)
152 {
153 int curoccupant = 0;
154 ByteStream occbs;
155
156 /* Allocate enough userinfo structs for all occupants */
157 userinfo = g_new0(aim_userinfo_t, usercount);
158
159 byte_stream_init(&occbs, tlv->value, tlv->length);
160
161 while (curoccupant < usercount)
162 aim_info_extract(od, &occbs, &userinfo[curoccupant++]);
163 }
164
165 /*
166 * Type 0x00c9: Flags. (AIM_CHATROOM_FLAG)
167 */
168 flags = aim_tlv_get16(tlvlist, 0x00c9, 1);
169
170 /*
171 * Type 0x00ca: Creation time (4 bytes)
172 */
173 creationtime = aim_tlv_get32(tlvlist, 0x00ca, 1);
174
175 /*
176 * Type 0x00d1: Maximum Message Length 97 * Type 0x00d1: Maximum Message Length
177 */ 98 */
178 maxmsglen = aim_tlv_get16(tlvlist, 0x00d1, 1); 99 maxmsglen = aim_tlv_get16(tlvlist, 0x00d1, 1);
179 100
180 /* 101 /*
181 * Type 0x00d2: Unknown. (2 bytes)
182 */
183 unknown_d2 = aim_tlv_get16(tlvlist, 0x00d2, 1);
184
185 /*
186 * Type 0x00d3: Room Description
187 */
188 roomdesc = aim_tlv_getstr(tlvlist, 0x00d3, 1);
189
190 #if 0
191 /*
192 * Type 0x000d4: Unknown (flag only)
193 */
194 if (aim_tlv_gettlv(tlvlist, 0x000d4, 1)) {
195 /* Unhandled */
196 }
197 #endif
198
199 /*
200 * Type 0x00d5: Unknown. (1 byte)
201 */
202 unknown_d5 = aim_tlv_get8(tlvlist, 0x00d5, 1);
203
204 #if 0
205 /*
206 * Type 0x00d6: Encoding 1 ("us-ascii")
207 */
208 if (aim_tlv_gettlv(tlvlist, 0x000d6, 1)) {
209 /* Unhandled */
210 }
211
212 /*
213 * Type 0x00d7: Language 1 ("en")
214 */
215 if (aim_tlv_gettlv(tlvlist, 0x000d7, 1)) {
216 /* Unhandled */
217 }
218
219 /*
220 * Type 0x00d8: Encoding 2 ("us-ascii")
221 */
222 if (aim_tlv_gettlv(tlvlist, 0x000d8, 1)) {
223 /* Unhandled */
224 }
225
226 /*
227 * Type 0x00d9: Language 2 ("en")
228 */
229 if (aim_tlv_gettlv(tlvlist, 0x000d9, 1)) {
230 /* Unhandled */
231 }
232 #endif
233
234 /*
235 * Type 0x00da: Maximum visible message length 102 * Type 0x00da: Maximum visible message length
236 */ 103 */
237 maxvisiblemsglen = aim_tlv_get16(tlvlist, 0x00da, 1); 104 maxvisiblemsglen = aim_tlv_get16(tlvlist, 0x00da, 1);
238 105
239 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) { 106 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) {
240 ret = userfunc(od, conn, 107 ret = userfunc(od, conn, frame, maxmsglen, maxvisiblemsglen);
241 frame,
242 &roominfo,
243 roomname,
244 usercount,
245 userinfo,
246 roomdesc,
247 flags,
248 creationtime,
249 maxmsglen,
250 unknown_d2,
251 unknown_d5,
252 maxvisiblemsglen);
253 } 108 }
254 109
255 g_free(roominfo.name); 110 g_free(roominfo.name);
256 111
257 while (usercount > 0)
258 aim_info_free(&userinfo[--usercount]);
259
260 g_free(userinfo);
261 g_free(roomname);
262 g_free(roomdesc);
263 aim_tlvlist_free(tlvlist); 112 aim_tlvlist_free(tlvlist);
264 113
265 return ret; 114 return ret;
266 } 115 }
267 116