Mercurial > pidgin
comparison src/protocols/msn/msn.c @ 2993:7239a392486c
[gaim-migrate @ 3006]
0.53 :)
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Sat, 02 Mar 2002 04:52:21 +0000 |
parents | f7f7c9223312 |
children | 87fff45fa36b |
comparison
equal
deleted
inserted
replaced
2992:d16a0504f1c8 | 2993:7239a392486c |
---|---|
32 #define MSN_LUNCH 7 | 32 #define MSN_LUNCH 7 |
33 #define MSN_OFFLINE 8 | 33 #define MSN_OFFLINE 8 |
34 #define MSN_HIDDEN 9 | 34 #define MSN_HIDDEN 9 |
35 | 35 |
36 #define USEROPT_HOTMAIL 0 | 36 #define USEROPT_HOTMAIL 0 |
37 | |
38 #define MSN_TYPING_RECV_TIMEOUT 6 | |
39 #define MSN_TYPING_SEND_TIMEOUT 4 | |
37 | 40 |
38 struct msn_data { | 41 struct msn_data { |
39 int fd; | 42 int fd; |
40 int trId; | 43 int trId; |
41 int inpa; | 44 int inpa; |
509 flags |= IM_FLAG_GAIMUSER; | 512 flags |= IM_FLAG_GAIMUSER; |
510 } | 513 } |
511 content = strstr(msg, "Content-Type: "); | 514 content = strstr(msg, "Content-Type: "); |
512 if (!content) | 515 if (!content) |
513 return; | 516 return; |
514 if (!g_strncasecmp(content, "Content-Type: text/plain", | 517 if (!g_strncasecmp(content, "Content-Type: text/x-msmsgscontrol\r\n", |
515 strlen("Content-Type: text/plain"))) { | 518 strlen( "Content-Type: text/x-msmsgscontrol\r\n"))) { |
519 if (strstr(content,"TypingUser: ")) { | |
520 serv_got_typing(ms->gc, ms->msguser, MSN_TYPING_RECV_TIMEOUT); | |
521 return; | |
522 } | |
523 } else if (!g_strncasecmp(content, "Content-Type: text/plain", | |
524 strlen("Content-Type: text/plain"))) { | |
516 char *skiphead; | 525 char *skiphead; |
517 skiphead = strstr(msg, "\r\n\r\n"); | 526 skiphead = strstr(msg, "\r\n\r\n"); |
518 if (!skiphead || !skiphead[4]) { | 527 if (!skiphead || !skiphead[4]) { |
519 return; | 528 return; |
520 } | 529 } |
521 skiphead += 4; | 530 skiphead += 4; |
522 utf = utf8_to_str(skiphead); | 531 utf = utf8_to_str(skiphead); |
523 strip_linefeed(utf); | 532 strip_linefeed(utf); |
524 | 533 |
525 if (ms->chat) | 534 if (ms->chat) |
526 serv_got_chat_in(ms->gc, ms->chat->id, ms->msguser, flags, utf, time(NULL)); | 535 serv_got_chat_in(ms->gc, ms->chat->id, ms->msguser, flags, utf, time(NULL)); |
527 else | 536 else |
528 serv_got_im(ms->gc, ms->msguser, utf, flags, time(NULL), -1); | 537 serv_got_im(ms->gc, ms->msguser, utf, flags, time(NULL), -1); |
529 | 538 |
1473 g_slist_free(md->permit); | 1482 g_slist_free(md->permit); |
1474 g_slist_free(md->deny); | 1483 g_slist_free(md->deny); |
1475 g_free(md); | 1484 g_free(md); |
1476 } | 1485 } |
1477 | 1486 |
1487 static int msn_send_typing(struct gaim_connection *gc, char *who) { | |
1488 struct msn_switchboard *ms = msn_find_switch(gc, who); | |
1489 char header[MSN_BUF_LEN] = "MIME-Version: 1.0\r\n" | |
1490 "Content-Type: text/x-msmsgscontrol\r\n" | |
1491 "User-Agent: Gaim/" VERSION "\r\n" | |
1492 "TypingUser: "; | |
1493 char buf [MSN_BUF_LEN]; | |
1494 if (!ms) | |
1495 return; | |
1496 g_snprintf(buf, sizeof(buf), "MSG %d N %d\r\n%s%s\r\n\r\n\r\n", | |
1497 ++ms->trId, | |
1498 strlen(header) + strlen("\r\n\r\n\r\n") + strlen(gc->username), | |
1499 header, gc->username); | |
1500 if (msn_write(ms->fd, buf, strlen(buf)) < 0) | |
1501 msn_kill_switch(ms); | |
1502 return MSN_TYPING_SEND_TIMEOUT; | |
1503 } | |
1504 | |
1478 static int msn_send_im(struct gaim_connection *gc, char *who, char *message, int flags) | 1505 static int msn_send_im(struct gaim_connection *gc, char *who, char *message, int flags) |
1479 { | 1506 { |
1480 struct msn_data *md = gc->proto_data; | 1507 struct msn_data *md = gc->proto_data; |
1481 struct msn_switchboard *ms = msn_find_switch(gc, who); | 1508 struct msn_switchboard *ms = msn_find_switch(gc, who); |
1482 char buf[MSN_BUF_LEN]; | 1509 char buf[MSN_BUF_LEN]; |
1986 ret->list_icon = msn_list_icon; | 2013 ret->list_icon = msn_list_icon; |
1987 ret->buddy_menu = msn_buddy_menu; | 2014 ret->buddy_menu = msn_buddy_menu; |
1988 ret->login = msn_login; | 2015 ret->login = msn_login; |
1989 ret->close = msn_close; | 2016 ret->close = msn_close; |
1990 ret->send_im = msn_send_im; | 2017 ret->send_im = msn_send_im; |
2018 ret->send_typing = msn_send_typing; | |
1991 ret->away_states = msn_away_states; | 2019 ret->away_states = msn_away_states; |
1992 ret->set_away = msn_set_away; | 2020 ret->set_away = msn_set_away; |
1993 ret->set_idle = msn_set_idle; | 2021 ret->set_idle = msn_set_idle; |
1994 ret->add_buddy = msn_add_buddy; | 2022 ret->add_buddy = msn_add_buddy; |
1995 ret->remove_buddy = msn_rem_buddy; | 2023 ret->remove_buddy = msn_rem_buddy; |