Mercurial > pidgin
comparison src/oscar.c @ 1858:487d98cdbe28
[gaim-migrate @ 1868]
fix chat.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sat, 19 May 2001 01:46:55 +0000 |
parents | 15a415b5f08c |
children | b1d62fe22d74 |
comparison
equal
deleted
inserted
replaced
1857:9ea0b9531bc9 | 1858:487d98cdbe28 |
---|---|
83 GSList *getfiles; | 83 GSList *getfiles; |
84 }; | 84 }; |
85 | 85 |
86 struct chat_connection { | 86 struct chat_connection { |
87 char *name; | 87 char *name; |
88 char *show; /* AOL did something funny to us */ | |
88 int exchange; | 89 int exchange; |
89 int fd; /* this is redundant since we have the conn below */ | 90 int fd; /* this is redundant since we have the conn below */ |
90 struct aim_conn_t *conn; | 91 struct aim_conn_t *conn; |
91 int inpa; | 92 int inpa; |
92 int id; | 93 int id; |
162 | 163 |
163 return n; | 164 return n; |
164 } | 165 } |
165 */ | 166 */ |
166 | 167 |
167 struct chat_connection *find_oscar_chat(struct gaim_connection *gc, int id) { | 168 static char *extract_name(char *name) { |
169 char *tmp; | |
170 int i, j; | |
171 char *x = strchr(name, '-'); | |
172 if (!x) return; | |
173 x = strchr(++x, '-'); | |
174 if (!x) return; | |
175 tmp = g_strdup(++x); | |
176 | |
177 for (i = 0, j = 0; x[i]; i++) { | |
178 if (x[i] != '%') | |
179 tmp[j++] = x[i]; | |
180 else { | |
181 char hex[3]; | |
182 hex[0] = x[++i]; | |
183 hex[1] = x[++i]; | |
184 hex[2] = 0; | |
185 sscanf(hex, "%x", &tmp[j++]); | |
186 } | |
187 } | |
188 | |
189 tmp[j] = 0; | |
190 return tmp; | |
191 } | |
192 | |
193 static struct chat_connection *find_oscar_chat(struct gaim_connection *gc, int id) { | |
168 GSList *g = ((struct oscar_data *)gc->proto_data)->oscar_chats; | 194 GSList *g = ((struct oscar_data *)gc->proto_data)->oscar_chats; |
169 struct chat_connection *c = NULL; | 195 struct chat_connection *c = NULL; |
170 if (gc->protocol != PROTO_OSCAR) return NULL; | 196 if (gc->protocol != PROTO_OSCAR) return NULL; |
171 | 197 |
172 while (g) { | 198 while (g) { |
464 while (c) { | 490 while (c) { |
465 n = (struct chat_connection *)c->data; | 491 n = (struct chat_connection *)c->data; |
466 if (n->inpa > 0) | 492 if (n->inpa > 0) |
467 gdk_input_remove(n->inpa); | 493 gdk_input_remove(n->inpa); |
468 g_free(n->name); | 494 g_free(n->name); |
495 g_free(n->show); | |
469 c = g_slist_remove(c, n); | 496 c = g_slist_remove(c, n); |
470 g_free(n); | 497 g_free(n); |
471 } | 498 } |
472 if (gc->inpa > 0) | 499 if (gc->inpa > 0) |
473 gdk_input_remove(gc->inpa); | 500 gdk_input_remove(gc->inpa); |
701 debug_printf("len is 0, hashing NULL\n"); | 728 debug_printf("len is 0, hashing NULL\n"); |
702 aim_sendmemblock(sess, command->conn, offset, len, NULL, | 729 aim_sendmemblock(sess, command->conn, offset, len, NULL, |
703 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); | 730 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
704 return 1; | 731 return 1; |
705 } | 732 } |
706 /* | 733 /* uncomment this when you're convinced it's right. remember, it's been wrong before. |
707 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { | 734 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { |
708 char buf[8]; | 735 char *buf; |
709 buf[0] = offset & 0xff; | 736 int i = 8; |
710 buf[1] = (offset >> 8) & 0xff; | 737 if (modname) |
711 buf[2] = (offset >> 16) & 0xff; | 738 i += strlen(modname); |
712 buf[3] = (offset >> 24) & 0xff; | 739 buf = g_malloc(i); |
713 buf[4] = len & 0xff; | 740 i = 0; |
714 buf[5] = (len >> 8) & 0xff; | 741 if (modname) { |
715 buf[6] = (len >> 16) & 0xff; | 742 memcpy(buf, modname, strlen(modname)); |
716 buf[7] = (len >> 24) & 0xff; | 743 i += strlen(modname); |
744 } | |
745 buf[i++] = offset & 0xff; | |
746 buf[i++] = (offset >> 8) & 0xff; | |
747 buf[i++] = (offset >> 16) & 0xff; | |
748 buf[i++] = (offset >> 24) & 0xff; | |
749 buf[i++] = len & 0xff; | |
750 buf[i++] = (len >> 8) & 0xff; | |
751 buf[i++] = (len >> 16) & 0xff; | |
752 buf[i++] = (len >> 24) & 0xff; | |
717 debug_printf("len + offset is invalid, hashing request\n"); | 753 debug_printf("len + offset is invalid, hashing request\n"); |
718 aim_sendmemblock(sess, command->conn, offset, 8, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); | 754 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
755 g_free(buf); | |
719 return 1; | 756 return 1; |
720 } | 757 } |
721 */ | 758 */ |
722 | 759 |
723 pos = g_new0(struct pieceofcrap, 1); | 760 pos = g_new0(struct pieceofcrap, 1); |
814 aim_bos_reqrate(sess, command->conn); | 851 aim_bos_reqrate(sess, command->conn); |
815 aim_bos_ackrateresp(sess, command->conn); | 852 aim_bos_ackrateresp(sess, command->conn); |
816 aim_chat_clientready(sess, command->conn); | 853 aim_chat_clientready(sess, command->conn); |
817 chatcon = find_oscar_chat_by_conn(gc, command->conn); | 854 chatcon = find_oscar_chat_by_conn(gc, command->conn); |
818 chatcon->id = id; | 855 chatcon->id = id; |
819 serv_got_joined_chat(gc, id++, aim_chat_getname(command->conn)); | 856 serv_got_joined_chat(gc, id++, chatcon->show); |
820 break; | 857 break; |
821 case AIM_CONN_TYPE_RENDEZVOUS: | 858 case AIM_CONN_TYPE_RENDEZVOUS: |
822 break; | 859 break; |
823 default: /* huh? */ | 860 default: /* huh? */ |
824 debug_printf("server ready: got unexpected connection type %04x\n", command->conn->type); | 861 debug_printf("server ready: got unexpected connection type %04x\n", command->conn->type); |
890 ccon = g_new0(struct chat_connection, 1); | 927 ccon = g_new0(struct chat_connection, 1); |
891 ccon->conn = tstconn; | 928 ccon->conn = tstconn; |
892 ccon->fd = tstconn->fd; | 929 ccon->fd = tstconn->fd; |
893 ccon->name = g_strdup(roomname); | 930 ccon->name = g_strdup(roomname); |
894 ccon->exchange = exchange; | 931 ccon->exchange = exchange; |
932 ccon->show = extract_name(roomname); | |
895 | 933 |
896 ccon->inpa = gdk_input_add(tstconn->fd, | 934 ccon->inpa = gdk_input_add(tstconn->fd, |
897 GDK_INPUT_READ | GDK_INPUT_EXCEPTION, | 935 GDK_INPUT_READ | GDK_INPUT_EXCEPTION, |
898 oscar_callback, tstconn); | 936 oscar_callback, tstconn); |
899 | 937 |
1671 struct aim_userinfo_s *info; | 1709 struct aim_userinfo_s *info; |
1672 struct gaim_connection *g = sess->aux_data; | 1710 struct gaim_connection *g = sess->aux_data; |
1673 | 1711 |
1674 GSList *bcs = g->buddy_chats; | 1712 GSList *bcs = g->buddy_chats; |
1675 struct conversation *b = NULL; | 1713 struct conversation *b = NULL; |
1714 struct chat_connection *c = NULL; | |
1676 | 1715 |
1677 va_start(ap, command); | 1716 va_start(ap, command); |
1678 count = va_arg(ap, int); | 1717 count = va_arg(ap, int); |
1679 info = va_arg(ap, struct aim_userinfo_s *); | 1718 info = va_arg(ap, struct aim_userinfo_s *); |
1680 va_end(ap); | 1719 va_end(ap); |
1681 | 1720 |
1682 while(bcs) { | 1721 c = find_oscar_chat_by_conn(g, command->conn); |
1722 if (!c) | |
1723 return 1; | |
1724 | |
1725 while (bcs) { | |
1683 b = (struct conversation *)bcs->data; | 1726 b = (struct conversation *)bcs->data; |
1684 if (!strcasecmp(b->name, (char *)command->conn->priv)) | 1727 if (!strcasecmp(b->name, c->show)) |
1685 break; | 1728 break; |
1686 bcs = bcs->next; | 1729 bcs = bcs->next; |
1687 b = NULL; | 1730 b = NULL; |
1688 } | 1731 } |
1689 if (!b) | 1732 if (!b) |
1702 struct aim_userinfo_s *info; | 1745 struct aim_userinfo_s *info; |
1703 struct gaim_connection *g = sess->aux_data; | 1746 struct gaim_connection *g = sess->aux_data; |
1704 | 1747 |
1705 GSList *bcs = g->buddy_chats; | 1748 GSList *bcs = g->buddy_chats; |
1706 struct conversation *b = NULL; | 1749 struct conversation *b = NULL; |
1750 struct chat_connection *c = NULL; | |
1707 | 1751 |
1708 va_start(ap, command); | 1752 va_start(ap, command); |
1709 count = va_arg(ap, int); | 1753 count = va_arg(ap, int); |
1710 info = va_arg(ap, struct aim_userinfo_s *); | 1754 info = va_arg(ap, struct aim_userinfo_s *); |
1711 va_end(ap); | 1755 va_end(ap); |
1712 | 1756 |
1713 while(bcs) { | 1757 c = find_oscar_chat_by_conn(g, command->conn); |
1758 if (!c) | |
1759 return 1; | |
1760 | |
1761 while (bcs) { | |
1714 b = (struct conversation *)bcs->data; | 1762 b = (struct conversation *)bcs->data; |
1715 if (!strcasecmp(b->name, (char *)command->conn->priv)) | 1763 if (!strcasecmp(b->name, c->show)) |
1716 break; | 1764 break; |
1717 bcs = bcs->next; | 1765 bcs = bcs->next; |
1718 b = NULL; | 1766 b = NULL; |
1719 } | 1767 } |
1720 if (!b) | 1768 if (!b) |
1747 info = va_arg(ap, struct aim_userinfo_s *); | 1795 info = va_arg(ap, struct aim_userinfo_s *); |
1748 msg = va_arg(ap, char *); | 1796 msg = va_arg(ap, char *); |
1749 | 1797 |
1750 while(bcs) { | 1798 while(bcs) { |
1751 b = (struct conversation *)bcs->data; | 1799 b = (struct conversation *)bcs->data; |
1752 if (!strcasecmp(b->name, (char *)command->conn->priv)) | 1800 tmp = extract_name(command->conn->priv); |
1801 if (!strcasecmp(b->name, tmp)) { | |
1802 g_free(tmp); | |
1753 break; | 1803 break; |
1804 } | |
1805 g_free(tmp); | |
1754 bcs = bcs->next; | 1806 bcs = bcs->next; |
1755 b = NULL; | 1807 b = NULL; |
1756 } | 1808 } |
1757 if (!b) | 1809 if (!b) |
1758 return 0; | 1810 return 0; |
2234 if (c->inpa > 0) | 2286 if (c->inpa > 0) |
2235 gdk_input_remove(c->inpa); | 2287 gdk_input_remove(c->inpa); |
2236 if (g && odata->sess) | 2288 if (g && odata->sess) |
2237 aim_conn_kill(odata->sess, &c->conn); | 2289 aim_conn_kill(odata->sess, &c->conn); |
2238 g_free(c->name); | 2290 g_free(c->name); |
2291 g_free(c->show); | |
2239 g_free(c); | 2292 g_free(c); |
2240 } | 2293 } |
2241 /* we do this because with Oscar it doesn't tell us we left */ | 2294 /* we do this because with Oscar it doesn't tell us we left */ |
2242 serv_got_chat_left(g, b->id); | 2295 serv_got_chat_left(g, b->id); |
2243 } | 2296 } |
2245 static void oscar_chat_send(struct gaim_connection *g, int id, char *message) { | 2298 static void oscar_chat_send(struct gaim_connection *g, int id, char *message) { |
2246 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | 2299 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
2247 struct aim_conn_t *cn; | 2300 struct aim_conn_t *cn; |
2248 GSList *bcs = g->buddy_chats; | 2301 GSList *bcs = g->buddy_chats; |
2249 struct conversation *b = NULL; | 2302 struct conversation *b = NULL; |
2303 struct chat_connection *c = NULL; | |
2250 | 2304 |
2251 while (bcs) { | 2305 while (bcs) { |
2252 b = (struct conversation *)bcs->data; | 2306 b = (struct conversation *)bcs->data; |
2253 if (id == b->id) | 2307 if (id == b->id) |
2254 break; | 2308 break; |
2256 b = NULL; | 2310 b = NULL; |
2257 } | 2311 } |
2258 if (!b) | 2312 if (!b) |
2259 return; | 2313 return; |
2260 | 2314 |
2261 cn = aim_chat_getconn(odata->sess, b->name); | 2315 bcs = odata->oscar_chats; |
2262 aim_chat_send_im(odata->sess, cn, 0, message, strlen(message)); | 2316 while (bcs) { |
2317 c = (struct chat_connection *)bcs->data; | |
2318 if (!strcmp(b->name, c->show)) | |
2319 break; | |
2320 bcs = bcs->next; | |
2321 c = NULL; | |
2322 } | |
2323 if (!c) | |
2324 return; | |
2325 | |
2326 aim_chat_send_im(odata->sess, c->conn, 0, message, strlen(message)); | |
2263 } | 2327 } |
2264 | 2328 |
2265 static char **oscar_list_icon(int uc) { | 2329 static char **oscar_list_icon(int uc) { |
2266 if (uc & UC_UNAVAILABLE) | 2330 if (uc & UC_UNAVAILABLE) |
2267 return (char **)away_icon_xpm; | 2331 return (char **)away_icon_xpm; |