9376
|
1 /**
|
|
2 * @file ycht.c The Yahoo! protocol plugin, YCHT protocol stuff.
|
|
3 *
|
|
4 * gaim
|
|
5 *
|
|
6 * Copyright (C) 2004 Timothy Ringenbach <omarvo@hotmail.com>
|
|
7 * Liberal amounts of code borrowed from the rest of the Yahoo! prpl.
|
|
8 *
|
|
9 * Gaim is the legal property of its developers, whose names are too numerous
|
|
10 * to list here. Please refer to the COPYRIGHT file distributed with this
|
|
11 * source distribution.
|
|
12 *
|
|
13 * This program is free software; you can redistribute it and/or modify
|
|
14 * it under the terms of the GNU General Public License as published by
|
|
15 * the Free Software Foundation; either version 2 of the License, or
|
|
16 * (at your option) any later version.
|
|
17 *
|
|
18 * This program is distributed in the hope that it will be useful,
|
|
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21 * GNU General Public License for more details.
|
|
22 *
|
|
23 * You should have received a copy of the GNU General Public License
|
|
24 * along with this program; if not, write to the Free Software
|
|
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
26 */
|
|
27
|
|
28 #include <string.h>
|
|
29
|
|
30 #include "internal.h"
|
|
31 #include "prpl.h"
|
|
32 #include "notify.h"
|
|
33 #include "account.h"
|
|
34 #include "proxy.h"
|
|
35 #include "debug.h"
|
|
36 #include "conversation.h"
|
|
37 #include "util.h"
|
|
38
|
|
39 #include "yahoo.h"
|
|
40 #include "ycht.h"
|
|
41 #include "yahoochat.h"
|
|
42
|
|
43 /*
|
|
44 * dword: YCHT
|
|
45 * dword: 0x000000AE
|
|
46 * dword: service
|
|
47 * word: status
|
|
48 * word: size
|
|
49 */
|
|
50 #define YAHOO_CHAT_ID (1)
|
|
51 /************************************************************************************
|
|
52 * Functions to process various kinds of packets.
|
|
53 ************************************************************************************/
|
|
54 static void ycht_process_login(YchtConn *ycht, YchtPkt *pkt)
|
|
55 {
|
|
56 GaimConnection *gc = ycht->gc;
|
|
57 struct yahoo_data *yd = gc->proto_data;
|
|
58
|
|
59 if (ycht->logged_in)
|
|
60 return;
|
|
61
|
|
62 yd->chat_online = TRUE;
|
|
63 ycht->logged_in = TRUE;
|
|
64
|
|
65 if (ycht->room)
|
|
66 ycht_chat_join(ycht, ycht->room);
|
|
67 }
|
|
68
|
|
69 static void ycht_process_logout(YchtConn *ycht, YchtPkt *pkt)
|
|
70 {
|
|
71 GaimConnection *gc = ycht->gc;
|
|
72 struct yahoo_data *yd = gc->proto_data;
|
|
73
|
|
74 yd->chat_online = FALSE;
|
|
75 ycht->logged_in = FALSE;
|
|
76 }
|
|
77
|
|
78 static void ycht_process_chatjoin(YchtConn *ycht, YchtPkt *pkt)
|
|
79 {
|
|
80 char *room, *topic;
|
|
81 GaimConnection *gc = ycht->gc;
|
|
82 GaimConversation *c = NULL;
|
|
83 gboolean new_room = FALSE;
|
|
84 char **members;
|
|
85 int i;
|
|
86
|
|
87 room = g_list_nth_data(pkt->data, 0);
|
|
88 topic = g_list_nth_data(pkt->data, 1);
|
|
89 if (!g_list_nth_data(pkt->data, 4))
|
|
90 return;
|
|
91 if (!room)
|
|
92 return;
|
|
93
|
|
94 members = g_strsplit(g_list_nth_data(pkt->data, 4), "\001", 0);
|
|
95 for (i = 0; members[i]; i++) {
|
|
96 char *tmp = strchr(members[i], '\002');
|
|
97 if (tmp)
|
|
98 *tmp = '\0';
|
|
99 }
|
|
100
|
|
101
|
|
102 if (g_list_length(pkt->data) > 5)
|
|
103 new_room = TRUE;
|
|
104
|
|
105 if (new_room && ycht->changing_rooms) {
|
|
106 serv_got_chat_left(gc, YAHOO_CHAT_ID);
|
|
107 ycht->changing_rooms = FALSE;
|
|
108 c = serv_got_joined_chat(gc, YAHOO_CHAT_ID, room);
|
|
109 } else {
|
|
110 c = gaim_find_chat(gc, YAHOO_CHAT_ID);
|
|
111 }
|
|
112
|
|
113
|
|
114 if (topic)
|
|
115 gaim_conv_chat_set_topic(GAIM_CONV_CHAT(c), NULL, topic);
|
|
116
|
|
117 for (i = 0; members[i]; i++) {
|
|
118 if (new_room) {
|
|
119 /*if (!strcmp(members[i], gaim_connection_get_display_name(ycht->gc)))
|
|
120 continue;*/
|
9846
|
121 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c), members[i], NULL, GAIM_CBFLAGS_NONE, TRUE);
|
9376
|
122 } else {
|
|
123 yahoo_chat_add_user(GAIM_CONV_CHAT(c), members[i], NULL);
|
|
124 }
|
|
125 }
|
|
126
|
|
127 g_strfreev(members);
|
|
128 }
|
|
129
|
|
130 static void ycht_process_chatpart(YchtConn *ycht, YchtPkt *pkt)
|
|
131 {
|
|
132 char *room, *who;
|
|
133
|
|
134 room = g_list_nth_data(pkt->data, 0);
|
|
135 who = g_list_nth_data(pkt->data, 1);
|
|
136
|
|
137 if (who && room) {
|
|
138 GaimConversation *c = gaim_find_chat(ycht->gc, YAHOO_CHAT_ID);
|
|
139 if (c && !gaim_utf8_strcasecmp(gaim_conversation_get_name(c), room))
|
|
140 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c), who, NULL);
|
|
141
|
|
142 }
|
|
143 }
|
|
144
|
|
145 static void ycht_progress_chatmsg(YchtConn *ycht, YchtPkt *pkt)
|
|
146 {
|
|
147 char *who, *what, *msg;
|
|
148 GaimConversation *c;
|
|
149 GaimConnection *gc = ycht->gc;
|
|
150
|
|
151 who = g_list_nth_data(pkt->data, 1);
|
|
152 what = g_list_nth_data(pkt->data, 2);
|
|
153
|
|
154 if (!who || !what)
|
|
155 return;
|
|
156
|
|
157 c = gaim_find_chat(gc, YAHOO_CHAT_ID);
|
|
158 if (!c)
|
|
159 return;
|
|
160
|
|
161 msg = yahoo_string_decode(gc, what, 1);
|
|
162 what = yahoo_codes_to_html(msg);
|
|
163 g_free(msg);
|
|
164
|
|
165 if (pkt->service == YCHT_SERVICE_CHATMSG_EMOTE) {
|
|
166 char *tmp = g_strdup_printf("/me %s", what);
|
|
167 g_free(what);
|
|
168 what = tmp;
|
|
169 }
|
|
170
|
|
171 serv_got_chat_in(gc, YAHOO_CHAT_ID, who, 0, what, time(NULL));
|
|
172 g_free(what);
|
|
173 }
|
|
174
|
|
175 static void ycht_progress_online_friends(YchtConn *ycht, YchtPkt *pkt)
|
|
176 {
|
|
177 #if 0
|
|
178 GaimConnection *gc = ycht->gc;
|
|
179 struct yahoo_data *yd = gc->proto_data;
|
|
180
|
|
181 if (ycht->logged_in)
|
|
182 return;
|
|
183
|
|
184 yd->chat_online = TRUE;
|
|
185 ycht->logged_in = TRUE;
|
|
186
|
|
187 if (ycht->room)
|
|
188 ycht_chat_join(ycht, ycht->room);
|
|
189 #endif
|
|
190 }
|
|
191
|
|
192 /*****************************************************************************
|
|
193 * Functions dealing with YCHT packets and their contents directly.
|
|
194 *****************************************************************************/
|
|
195 static void ycht_packet_dump(const char *data, int len)
|
|
196 {
|
|
197 #ifdef YAHOO_YCHT_DEBUG
|
|
198 int i;
|
|
199
|
|
200 gaim_debug(GAIM_DEBUG_MISC, "yahoo", "");
|
|
201
|
|
202 for (i = 0; i + 1 < len; i += 2) {
|
|
203 if ((i % 16 == 0) && i) {
|
|
204 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n");
|
|
205 gaim_debug(GAIM_DEBUG_MISC, "yahoo", "");
|
|
206 }
|
|
207
|
|
208 gaim_debug(GAIM_DEBUG_MISC, NULL, "%02hhx%02hhx ", data[i], data[i + 1]);
|
|
209 }
|
|
210 if (i < len)
|
|
211 gaim_debug(GAIM_DEBUG_MISC, NULL, "%02hhx", data[i]);
|
|
212
|
|
213 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n");
|
|
214 gaim_debug(GAIM_DEBUG_MISC, "yahoo", "");
|
|
215
|
|
216 for (i = 0; i < len; i++) {
|
|
217 if ((i % 16 == 0) && i) {
|
|
218 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n");
|
|
219 gaim_debug(GAIM_DEBUG_MISC, "yahoo", "");
|
|
220 }
|
|
221
|
|
222 if (g_ascii_isprint(data[i]))
|
|
223 gaim_debug(GAIM_DEBUG_MISC, NULL, "%c ", data[i]);
|
|
224 else
|
|
225 gaim_debug(GAIM_DEBUG_MISC, NULL, ". ");
|
|
226 }
|
|
227
|
|
228 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n");
|
|
229 #endif
|
|
230 }
|
|
231
|
|
232 static YchtPkt *ycht_packet_new(guint version, guint service, int status)
|
|
233 {
|
|
234 YchtPkt *ret;
|
|
235
|
|
236 ret = g_new0(YchtPkt, 1);
|
|
237
|
|
238 ret->version = version;
|
|
239 ret->service = service;
|
|
240 ret->status = status;
|
|
241
|
|
242 return ret;
|
|
243 }
|
|
244
|
|
245 static void ycht_packet_append(YchtPkt *pkt, const char *str)
|
|
246 {
|
|
247 g_return_if_fail(pkt != NULL);
|
|
248 g_return_if_fail(str != NULL);
|
|
249
|
|
250 pkt->data = g_list_append(pkt->data, g_strdup(str));
|
|
251 }
|
|
252
|
|
253 static int ycht_packet_length(YchtPkt *pkt)
|
|
254 {
|
|
255 int ret;
|
|
256 GList *l;
|
|
257
|
|
258 ret = YCHT_HEADER_LEN;
|
|
259
|
|
260 for (l = pkt->data; l; l = l->next) {
|
|
261 ret += strlen(l->data);
|
|
262 if (l->next)
|
|
263 ret += strlen(YCHT_SEP);
|
|
264 }
|
|
265
|
|
266 return ret;
|
|
267 }
|
|
268
|
|
269 static void ycht_packet_send(YchtConn *ycht, YchtPkt *pkt)
|
|
270 {
|
|
271 int len, pos;
|
|
272 char *buf;
|
|
273 GList *l;
|
|
274
|
|
275 g_return_if_fail(ycht != NULL);
|
|
276 g_return_if_fail(pkt != NULL);
|
|
277 g_return_if_fail(ycht->fd != -1);
|
|
278
|
|
279 pos = 0;
|
|
280 len = ycht_packet_length(pkt);
|
|
281 buf = g_malloc(len);
|
|
282
|
|
283 memcpy(buf + pos, "YCHT", 4); pos += 4;
|
|
284 pos += yahoo_put32(buf + pos, pkt->version);
|
|
285 pos += yahoo_put32(buf + pos, pkt->service);
|
|
286 pos += yahoo_put16(buf + pos, pkt->status);
|
|
287 pos += yahoo_put16(buf + pos, len - YCHT_HEADER_LEN);
|
|
288
|
|
289 for (l = pkt->data; l; l = l->next) {
|
|
290 int slen = strlen(l->data);
|
|
291 memcpy(buf + pos, l->data, slen); pos += slen;
|
|
292
|
|
293 if (l->next) {
|
|
294 memcpy(buf + pos, YCHT_SEP, strlen(YCHT_SEP));
|
|
295 pos += strlen(YCHT_SEP);
|
|
296 }
|
|
297 }
|
|
298
|
|
299 write(ycht->fd, buf, len);
|
|
300 g_free(buf);
|
|
301 }
|
|
302
|
|
303 static void ycht_packet_read(YchtPkt *pkt, const char *buf, int len)
|
|
304 {
|
|
305 const char *pos = buf;
|
|
306 const char *needle;
|
|
307 char *tmp, *tmp2;
|
|
308 int i = 0;
|
|
309
|
|
310 while (len > 0 && (needle = g_strstr_len(pos, len, YCHT_SEP))) {
|
|
311 tmp = g_strndup(pos, needle - pos);
|
|
312 pkt->data = g_list_append(pkt->data, tmp);
|
|
313 len -= needle - pos + strlen(YCHT_SEP);
|
|
314 pos = needle + strlen(YCHT_SEP);
|
|
315 tmp2 = g_strescape(tmp, NULL);
|
|
316 gaim_debug_misc("yahoo", "Data[%d]:\t%s\n", i++, tmp2);
|
|
317 g_free(tmp2);
|
|
318 }
|
|
319
|
|
320 if (len) {
|
|
321 tmp = g_strndup(pos, len);
|
|
322 pkt->data = g_list_append(pkt->data, tmp);
|
|
323 tmp2 = g_strescape(tmp, NULL);
|
|
324 gaim_debug_misc("yahoo", "Data[%d]:\t%s\n", i, tmp2);
|
|
325 g_free(tmp2);
|
|
326 };
|
|
327
|
|
328 gaim_debug_misc("yahoo", "--==End of incoming YCHT packet==--\n");
|
|
329 }
|
|
330
|
|
331 static void ycht_packet_process(YchtConn *ycht, YchtPkt *pkt)
|
|
332 {
|
|
333 if (pkt->data && !strncmp(pkt->data->data, "*** Danger Will Robinson!!!", strlen("*** Danger Will Robinson!!!")))
|
|
334 return;
|
|
335
|
|
336 switch (pkt->service) {
|
|
337 case YCHT_SERVICE_LOGIN:
|
|
338 ycht_process_login(ycht, pkt);
|
|
339 break;
|
|
340 case YCHT_SERVICE_LOGOUT:
|
|
341 ycht_process_logout(ycht, pkt);
|
|
342 break;
|
|
343 case YCHT_SERVICE_CHATJOIN:
|
|
344 ycht_process_chatjoin(ycht, pkt);
|
|
345 break;
|
|
346 case YCHT_SERVICE_CHATPART:
|
|
347 ycht_process_chatpart(ycht, pkt);
|
|
348 break;
|
|
349 case YCHT_SERVICE_CHATMSG:
|
|
350 case YCHT_SERVICE_CHATMSG_EMOTE:
|
|
351 ycht_progress_chatmsg(ycht, pkt);
|
|
352 break;
|
|
353 case YCHT_SERVICE_ONLINE_FRIENDS:
|
|
354 ycht_progress_online_friends(ycht, pkt);
|
|
355 break;
|
|
356 default:
|
|
357 gaim_debug_warning("yahoo", "YCHT: warning, unhandled service 0x%02x\n", pkt->service);
|
|
358 }
|
|
359 }
|
|
360
|
|
361 static void ycht_packet_free(YchtPkt *pkt)
|
|
362 {
|
|
363 GList *l;
|
|
364
|
|
365 g_return_if_fail(pkt != NULL);
|
|
366
|
|
367 for (l = pkt->data; l; l = l->next)
|
|
368 g_free(l->data);
|
|
369 g_list_free(pkt->data);
|
|
370 g_free(pkt);
|
|
371 }
|
|
372
|
|
373 /************************************************************************************
|
|
374 * Functions dealing with connecting and disconnecting and reading data into YchtPkt
|
|
375 * structs, and all that stuff.
|
|
376 ************************************************************************************/
|
|
377
|
|
378 void ycht_connection_close(YchtConn *ycht)
|
|
379 {
|
|
380 struct yahoo_data *yd = ycht->gc->proto_data;
|
|
381
|
|
382 if (yd) {
|
|
383 yd->ycht = NULL;
|
|
384 yd->chat_online = FALSE;
|
|
385 }
|
|
386
|
|
387 if (ycht->fd > 0)
|
|
388 close(ycht->fd);
|
|
389 if (ycht->inpa)
|
|
390 gaim_input_remove(ycht->inpa);
|
|
391
|
|
392 if (ycht->rxqueue)
|
|
393 g_free(ycht->rxqueue);
|
|
394
|
|
395 g_free(ycht);
|
|
396 }
|
|
397
|
|
398 static void ycht_connection_error(YchtConn *ycht, const gchar *error)
|
|
399 {
|
9397
|
400
|
9376
|
401 gaim_notify_info(ycht->gc, NULL, _("Connection problem with the YCHT server."), error);
|
|
402 ycht_connection_close(ycht);
|
|
403 }
|
|
404
|
|
405 static void ycht_pending(gpointer data, gint source, GaimInputCondition cond)
|
|
406 {
|
|
407 YchtConn *ycht = data;
|
|
408 char buf[1024];
|
|
409 int len;
|
|
410
|
|
411 len = read(ycht->fd, buf, sizeof(buf));
|
|
412
|
|
413 if (len <= 0) {
|
9397
|
414 ycht_connection_error(ycht, _("Unable to read"));
|
9376
|
415 return;
|
|
416 }
|
|
417
|
|
418 ycht->rxqueue = g_realloc(ycht->rxqueue, len + ycht->rxlen);
|
|
419 memcpy(ycht->rxqueue + ycht->rxlen, buf, len);
|
|
420 ycht->rxlen += len;
|
|
421
|
|
422 while (1) {
|
|
423 YchtPkt *pkt;
|
|
424 int pos = 0;
|
|
425 int pktlen;
|
|
426 guint service;
|
|
427 guint version;
|
|
428 gint status;
|
|
429
|
|
430 if (ycht->rxlen < YCHT_HEADER_LEN)
|
|
431 return;
|
|
432
|
|
433 if (strncmp("YCHT", ycht->rxqueue, 4) != 0)
|
|
434 gaim_debug_error("yahoo", "YCHT: protocol error.\n");
|
|
435
|
|
436 pos += 4; /* YCHT */
|
|
437
|
|
438 version = yahoo_get32(ycht->rxqueue + pos); pos += 4;
|
|
439 service = yahoo_get32(ycht->rxqueue + pos); pos += 4;
|
|
440 status = yahoo_get16(ycht->rxqueue + pos); pos += 2;
|
|
441 pktlen = yahoo_get16(ycht->rxqueue + pos); pos += 2;
|
|
442 gaim_debug(GAIM_DEBUG_MISC, "yahoo",
|
|
443 "ycht: %d bytes to read, rxlen is %d\n", pktlen, ycht->rxlen);
|
|
444
|
|
445 if (ycht->rxlen < (YCHT_HEADER_LEN + pktlen))
|
|
446 return;
|
|
447
|
|
448 gaim_debug_misc("yahoo", "--==Incoming YCHT packet==--\n");
|
|
449 gaim_debug(GAIM_DEBUG_MISC, "yahoo",
|
|
450 "YCHT Service: 0x%02x Version: 0x%02x Status: 0x%02x\n",
|
|
451 service, version, status);
|
|
452 ycht_packet_dump(ycht->rxqueue, YCHT_HEADER_LEN + pktlen);
|
|
453
|
|
454 pkt = ycht_packet_new(version, service, status);
|
|
455 ycht_packet_read(pkt, ycht->rxqueue + pos, pktlen);
|
|
456
|
|
457 ycht->rxlen -= YCHT_HEADER_LEN + pktlen;
|
|
458 if (ycht->rxlen) {
|
|
459 char *tmp = g_memdup(ycht->rxqueue + YCHT_HEADER_LEN + pktlen, ycht->rxlen);
|
|
460 g_free(ycht->rxqueue);
|
|
461 ycht->rxqueue = tmp;
|
|
462 } else {
|
|
463 g_free(ycht->rxqueue);
|
|
464 ycht->rxqueue = NULL;
|
|
465 }
|
|
466
|
|
467 ycht_packet_process(ycht, pkt);
|
|
468
|
|
469 ycht_packet_free(pkt);
|
|
470 }
|
|
471 }
|
|
472
|
|
473 static void ycht_got_connected(gpointer data, gint source, GaimInputCondition cond)
|
|
474 {
|
|
475 YchtConn *ycht = data;
|
|
476 GaimConnection *gc = ycht->gc;
|
|
477 struct yahoo_data *yd = gc->proto_data;
|
|
478 YchtPkt *pkt;
|
|
479 char *buf;
|
|
480
|
|
481 if (source < 0) {
|
9397
|
482 ycht_connection_error(ycht, _("Unable to connect."));
|
9376
|
483 return;
|
|
484 }
|
|
485
|
|
486 ycht->fd = source;
|
|
487
|
|
488 pkt = ycht_packet_new(YCHT_VERSION, YCHT_SERVICE_LOGIN, 0);
|
|
489
|
|
490 buf = g_strdup_printf("%s\001Y=%s; T=%s", gaim_connection_get_display_name(gc), yd->cookie_y, yd->cookie_t);
|
|
491 ycht_packet_append(pkt, buf);
|
|
492 g_free(buf);
|
|
493
|
|
494 ycht_packet_send(ycht, pkt);
|
|
495
|
|
496 ycht_packet_free(pkt);
|
|
497
|
|
498 ycht->inpa = gaim_input_add(ycht->fd, GAIM_INPUT_READ, ycht_pending, ycht);
|
|
499 }
|
|
500
|
|
501 void ycht_connection_open(GaimConnection *gc)
|
|
502 {
|
|
503 YchtConn *ycht;
|
|
504 struct yahoo_data *yd = gc->proto_data;
|
|
505 GaimAccount *account = gaim_connection_get_account(gc);
|
|
506
|
|
507 ycht = g_new0(YchtConn, 1);
|
|
508 ycht->gc = gc;
|
|
509 ycht->fd = -1;
|
|
510
|
|
511 yd->ycht = ycht;
|
|
512
|
|
513 if (gaim_proxy_connect(account,
|
|
514 gaim_account_get_string(account, "ycht-server", YAHOO_YCHT_HOST),
|
|
515 gaim_account_get_int(account, "ycht-port", YAHOO_YCHT_PORT),
|
|
516 ycht_got_connected, ycht) != 0)
|
|
517 {
|
9397
|
518 ycht_connection_error(ycht, _("Connection problem"));
|
9376
|
519 return;
|
|
520 }
|
|
521 }
|
|
522
|
|
523 /*******************************************************************************************
|
|
524 * These are functions called because the user did something.
|
|
525 *******************************************************************************************/
|
|
526
|
|
527 void ycht_chat_join(YchtConn *ycht, const char *room)
|
|
528 {
|
|
529 YchtPkt *pkt;
|
|
530 char *tmp;
|
|
531
|
|
532 tmp = g_strdup(room);
|
|
533 if (ycht->room)
|
|
534 g_free(ycht->room);
|
|
535 ycht->room = tmp;
|
|
536
|
|
537 if (!ycht->logged_in)
|
|
538 return;
|
|
539
|
|
540 ycht->changing_rooms = TRUE;
|
|
541 pkt = ycht_packet_new(YCHT_VERSION, YCHT_SERVICE_CHATJOIN, 0);
|
|
542 ycht_packet_append(pkt, ycht->room);
|
|
543 ycht_packet_send(ycht, pkt);
|
|
544 ycht_packet_free(pkt);
|
|
545 }
|
|
546
|
|
547 int ycht_chat_send(YchtConn *ycht, const char *room, const char *what)
|
|
548 {
|
|
549 YchtPkt *pkt;
|
|
550 char *msg1, *msg2, *buf;
|
|
551
|
|
552 if (strcmp(room, ycht->room))
|
|
553 gaim_debug_warning("yahoo", "uhoh, sending to the wrong room!\n");
|
|
554
|
|
555 pkt = ycht_packet_new(YCHT_VERSION, YCHT_SERVICE_CHATMSG, 0);
|
|
556
|
|
557 msg1 = yahoo_html_to_codes(what);
|
|
558 msg2 = yahoo_string_encode(ycht->gc, msg1, NULL);
|
|
559 g_free(msg1);
|
|
560
|
|
561 buf = g_strdup_printf("%s\001%s", ycht->room, msg2);
|
|
562 ycht_packet_append(pkt, buf);
|
|
563 g_free(msg2);
|
|
564 g_free(buf);
|
|
565
|
|
566 ycht_packet_send(ycht, pkt);
|
|
567 ycht_packet_free(pkt);
|
|
568 return 1;
|
|
569 }
|
|
570
|
|
571 void ycht_chat_leave(YchtConn *ycht, const char *room, gboolean logout)
|
|
572 {
|
|
573 if (logout)
|
|
574 ycht_connection_close(ycht);
|
|
575 }
|
|
576
|
|
577 void ycht_chat_send_invite(YchtConn *ycht, const char *room, const char *buddy, const char *msg)
|
|
578 {
|
|
579 }
|
|
580
|
|
581 void ycht_chat_goto_user(YchtConn *ycht, const char *name)
|
|
582 {
|
|
583 }
|
|
584
|
|
585 void ycht_chat_send_keepalive(YchtConn *ycht)
|
|
586 {
|
|
587 YchtPkt *pkt;
|
|
588
|
|
589 pkt = ycht_packet_new(YCHT_VERSION, YCHT_SERVICE_PING, 0);
|
|
590 ycht_packet_send(ycht, pkt);
|
|
591 ycht_packet_free(pkt);
|
|
592 }
|