Mercurial > pidgin.yaz
comparison src/protocols/yahoo/yahoo.c @ 3630:9682c0e022c6
[gaim-migrate @ 3753]
Yeah this will probably break a lot of shit knowing my luck. But hey, I really don't care what people thnk.
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Fri, 11 Oct 2002 03:14:01 +0000 |
parents | bb966d68f9e3 |
children | 1c39909fb476 |
comparison
equal
deleted
inserted
replaced
3629:afc5bb164c5a | 3630:9682c0e022c6 |
---|---|
22 | 22 |
23 #ifdef HAVE_CONFIG_H | 23 #ifdef HAVE_CONFIG_H |
24 #include "config.h" | 24 #include "config.h" |
25 #endif | 25 #endif |
26 | 26 |
27 | 27 #ifndef _WIN32 |
28 #include <netdb.h> | 28 #include <netdb.h> |
29 #include <unistd.h> | 29 #include <unistd.h> |
30 #include <errno.h> | |
31 #include <netinet/in.h> | 30 #include <netinet/in.h> |
32 #include <arpa/inet.h> | 31 #include <arpa/inet.h> |
32 #include <sys/socket.h> | |
33 #else | |
34 #include <winsock.h> | |
35 #endif | |
36 | |
37 #include <errno.h> | |
33 #include <string.h> | 38 #include <string.h> |
34 #include <stdlib.h> | 39 #include <stdlib.h> |
35 #include <stdio.h> | 40 #include <stdio.h> |
36 #include <time.h> | 41 #include <time.h> |
37 #include <sys/socket.h> | |
38 #include <sys/stat.h> | 42 #include <sys/stat.h> |
39 #include <ctype.h> | 43 #include <ctype.h> |
40 #include "multi.h" | 44 #include "multi.h" |
41 #include "prpl.h" | 45 #include "prpl.h" |
42 #include "gaim.h" | 46 #include "gaim.h" |
43 #include "proxy.h" | 47 #include "proxy.h" |
44 #include "md5.h" | 48 #include "md5.h" |
45 | 49 |
50 #ifdef _WIN32 | |
51 #include "win32dep.h" | |
52 #endif | |
53 | |
46 extern char *yahoo_crypt(char *, char *); | 54 extern char *yahoo_crypt(char *, char *); |
55 | |
56 /* for win32 compatability */ | |
57 G_MODULE_IMPORT GSList *connections; | |
47 | 58 |
48 #include "pixmaps/status-away.xpm" | 59 #include "pixmaps/status-away.xpm" |
49 #include "pixmaps/status-here.xpm" | 60 #include "pixmaps/status-here.xpm" |
50 #include "pixmaps/status-idle.xpm" | 61 #include "pixmaps/status-idle.xpm" |
51 #include "pixmaps/status-game.xpm" | 62 #include "pixmaps/status-game.xpm" |
352 pos += yahoo_put32(data + pos, pkt->id); | 363 pos += yahoo_put32(data + pos, pkt->id); |
353 | 364 |
354 yahoo_packet_write(pkt, data + pos); | 365 yahoo_packet_write(pkt, data + pos); |
355 | 366 |
356 yahoo_packet_dump(data, len); | 367 yahoo_packet_dump(data, len); |
368 #ifndef _WIN32 | |
357 ret = write(yd->fd, data, len); | 369 ret = write(yd->fd, data, len); |
358 | 370 #else |
371 ret = send(yd->fd, data, len, 0); | |
372 #endif | |
359 g_free(data); | 373 g_free(data); |
360 | 374 |
361 return ret; | 375 return ret; |
362 } | 376 } |
363 | 377 |
875 struct gaim_connection *gc = data; | 889 struct gaim_connection *gc = data; |
876 struct yahoo_data *yd = gc->proto_data; | 890 struct yahoo_data *yd = gc->proto_data; |
877 char buf[1024]; | 891 char buf[1024]; |
878 int len; | 892 int len; |
879 | 893 |
894 #ifndef _WIN32 | |
880 len = read(yd->fd, buf, sizeof(buf)); | 895 len = read(yd->fd, buf, sizeof(buf)); |
896 #else | |
897 len = recv(yd->fd, buf, sizeof(buf), 0); | |
898 #endif | |
881 | 899 |
882 if (len <= 0) { | 900 if (len <= 0) { |
901 #ifdef _WIN32 | |
902 if(len == SOCKET_ERROR) | |
903 debug_printf("Error reading socket: %d\n", WSAGetLastError()); | |
904 else if( len == 0 ) | |
905 debug_printf("Connection was gracefully closed.\n"); | |
906 #endif | |
883 hide_login_progress_error(gc, "Unable to read"); | 907 hide_login_progress_error(gc, "Unable to read"); |
884 signoff(gc); | 908 signoff(gc); |
885 return; | 909 return; |
886 } | 910 } |
887 | 911 |
939 struct gaim_connection *gc = data; | 963 struct gaim_connection *gc = data; |
940 struct yahoo_data *yd; | 964 struct yahoo_data *yd; |
941 struct yahoo_packet *pkt; | 965 struct yahoo_packet *pkt; |
942 | 966 |
943 if (!g_slist_find(connections, gc)) { | 967 if (!g_slist_find(connections, gc)) { |
968 #ifndef _WIN32 | |
944 close(source); | 969 close(source); |
970 #else | |
971 closesocket(source); | |
972 #endif | |
945 return; | 973 return; |
946 } | 974 } |
947 | 975 |
948 if (source < 0) { | 976 if (source < 0) { |
949 hide_login_progress(gc, "Unable to connect"); | 977 hide_login_progress(gc, "Unable to connect"); |
1007 g_hash_table_foreach_remove(yd->hash, yahoo_destroy_hash, NULL); | 1035 g_hash_table_foreach_remove(yd->hash, yahoo_destroy_hash, NULL); |
1008 g_hash_table_destroy(yd->hash); | 1036 g_hash_table_destroy(yd->hash); |
1009 g_hash_table_foreach_remove(yd->games, yahoo_destroy_hash, NULL); | 1037 g_hash_table_foreach_remove(yd->games, yahoo_destroy_hash, NULL); |
1010 g_hash_table_destroy(yd->games); | 1038 g_hash_table_destroy(yd->games); |
1011 if (yd->fd >= 0) | 1039 if (yd->fd >= 0) |
1040 #ifndef _WIN32 | |
1012 close(yd->fd); | 1041 close(yd->fd); |
1042 #else | |
1043 closesocket(yd->fd); | |
1044 #endif | |
1013 if (yd->rxqueue) | 1045 if (yd->rxqueue) |
1014 g_free(yd->rxqueue); | 1046 g_free(yd->rxqueue); |
1015 yd->rxlen = 0; | 1047 yd->rxlen = 0; |
1016 if (gc->inpa) | 1048 if (gc->inpa) |
1017 gaim_input_remove(gc->inpa); | 1049 gaim_input_remove(gc->inpa); |
1408 return smilies; | 1440 return smilies; |
1409 } | 1441 } |
1410 | 1442 |
1411 static struct prpl *my_protocol = NULL; | 1443 static struct prpl *my_protocol = NULL; |
1412 | 1444 |
1413 void yahoo_init(struct prpl *ret) { | 1445 G_MODULE_EXPORT void yahoo_init(struct prpl *ret) { |
1414 struct proto_user_opt *puo; | 1446 struct proto_user_opt *puo; |
1415 ret->protocol = PROTO_YAHOO; | 1447 ret->protocol = PROTO_YAHOO; |
1416 ret->options = OPT_PROTO_MAIL_CHECK; | 1448 ret->options = OPT_PROTO_MAIL_CHECK; |
1417 ret->name = g_strdup("Yahoo"); | 1449 ret->name = g_strdup("Yahoo"); |
1418 ret->login = yahoo_login; | 1450 ret->login = yahoo_login; |
1446 my_protocol = ret; | 1478 my_protocol = ret; |
1447 } | 1479 } |
1448 | 1480 |
1449 #ifndef STATIC | 1481 #ifndef STATIC |
1450 | 1482 |
1451 void *gaim_prpl_init(struct prpl *prpl) | 1483 G_MODULE_EXPORT void gaim_prpl_init(struct prpl *prpl) |
1452 { | 1484 { |
1453 yahoo_init(prpl); | 1485 yahoo_init(prpl); |
1454 prpl->plug->desc.api_version = PLUGIN_API_VERSION; | 1486 prpl->plug->desc.api_version = PLUGIN_API_VERSION; |
1455 } | 1487 } |
1456 | 1488 |