Mercurial > pidgin
comparison src/protocols/zephyr/zephyr.c @ 9986:cf27dea1d0a5
[gaim-migrate @ 10898]
" This patch should make zephyr compile again, against
the status rewrite. Here's a diff against anoncvs HEAD." --Arun A Tharuvai
and so it does
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Wed, 08 Sep 2004 11:38:00 +0000 |
parents | f8e395a054e2 |
children | c124bef68132 |
comparison
equal
deleted
inserted
replaced
9985:8cc2866678f3 | 9986:cf27dea1d0a5 |
---|---|
86 char ourhostcanon[HOST_NAME_MAX + 1]; | 86 char ourhostcanon[HOST_NAME_MAX + 1]; |
87 zephyr_connection_type connection_type; | 87 zephyr_connection_type connection_type; |
88 int totzc[2]; | 88 int totzc[2]; |
89 int fromtzc[2]; | 89 int fromtzc[2]; |
90 char *exposure; | 90 char *exposure; |
91 pid_t tzc_pid; | 91 pid_t tzc_pid; |
92 gchar *away; | |
92 }; | 93 }; |
93 | 94 |
94 #define MAXCHILDREN 20 | 95 #define MAXCHILDREN 20 |
95 | 96 |
96 struct _parse_tree { | 97 struct _parse_tree { |
695 /* XXX add real error reporting */ | 696 /* XXX add real error reporting */ |
696 if (ZParseLocations(¬ice, NULL, &nlocs, &user) != ZERR_NONE) | 697 if (ZParseLocations(¬ice, NULL, &nlocs, &user) != ZERR_NONE) |
697 return; | 698 return; |
698 | 699 |
699 if ((b = gaim_find_buddy(gc->account, user)) == NULL) { | 700 if ((b = gaim_find_buddy(gc->account, user)) == NULL) { |
700 char* stripped_user = zephyr_strip_local_realm(zephyr,user); | 701 char* stripped_user = zephyr_strip_local_realm(zephyr,user); |
701 b = gaim_find_buddy(gc->account,stripped_user); | 702 b = gaim_find_buddy(gc->account,stripped_user); |
702 g_free(stripped_user); | 703 g_free(stripped_user); |
703 } | 704 } |
704 if ((b && pending_zloc(zephyr,b->name)) || pending_zloc(zephyr,user)) { | 705 if ((b && pending_zloc(zephyr,b->name)) || pending_zloc(zephyr,user)) { |
705 ZLocations_t locs; | 706 ZLocations_t locs; |
706 int one = 1; | 707 int one = 1; |
707 GString *str = g_string_new(""); | 708 GString *str = g_string_new(""); |
718 g_string_append_printf(str, _("<br>At %s since %s"), locs.host, locs.time); | 719 g_string_append_printf(str, _("<br>At %s since %s"), locs.host, locs.time); |
719 } | 720 } |
720 gaim_notify_userinfo(gc, b ? b->name : user, NULL, _("Buddy Information"), NULL, | 721 gaim_notify_userinfo(gc, b ? b->name : user, NULL, _("Buddy Information"), NULL, |
721 str->str, NULL, NULL); | 722 str->str, NULL, NULL); |
722 g_string_free(str, TRUE); | 723 g_string_free(str, TRUE); |
723 } else | 724 } else { |
724 serv_got_update(gc, b->name, (nlocs > 0) ? TRUE : FALSE, 0, 0, 0, 0); | 725 if (nlocs>0) |
726 gaim_prpl_got_user_status(gc->account,b->name,"online",NULL); | |
727 else | |
728 gaim_prpl_got_user_status(gc->account,b->name,"offline",NULL); | |
729 } | |
725 | 730 |
726 g_free(user); | 731 g_free(user); |
727 } | 732 } |
728 } else { | 733 } else { |
729 char *buf, *buf2, *buf3; | 734 char *buf, *buf2, *buf3; |
928 ptree->num_children=0; | 933 ptree->num_children=0; |
929 if (do_parse) { | 934 if (do_parse) { |
930 unsigned int p = 0; | 935 unsigned int p = 0; |
931 while(p < strlen(source)) { | 936 while(p < strlen(source)) { |
932 unsigned int end; | 937 unsigned int end; |
933 gchar *newstr; | 938 gchar *newstr; |
934 | 939 |
935 /* Eat white space: */ | 940 /* Eat white space: */ |
936 if(g_ascii_isspace(source[p]) || source[p] == '\001') { | 941 if(g_ascii_isspace(source[p]) || source[p] == '\001') { |
937 p++; | 942 p++; |
938 continue; | 943 continue; |
1016 fd_set rfds; | 1021 fd_set rfds; |
1017 int bufsize = 2048; | 1022 int bufsize = 2048; |
1018 char *buf = (char *)calloc(bufsize, 1); | 1023 char *buf = (char *)calloc(bufsize, 1); |
1019 char *bufcur = buf; | 1024 char *bufcur = buf; |
1020 int selected = 0; | 1025 int selected = 0; |
1021 parse_tree *incoming_msg; | 1026 parse_tree *incoming_msg; |
1022 | 1027 |
1023 FD_ZERO(&rfds); | 1028 FD_ZERO(&rfds); |
1024 FD_SET(zephyr->fromtzc[ZEPHYR_FD_READ], &rfds); | 1029 FD_SET(zephyr->fromtzc[ZEPHYR_FD_READ], &rfds); |
1025 tv.tv_sec = 0; | 1030 tv.tv_sec = 0; |
1026 tv.tv_usec = 0; | 1031 tv.tv_usec = 0; |
1027 incoming_msg=NULL; | 1032 incoming_msg=NULL; |
1028 | 1033 |
1029 while (select(zephyr->fromtzc[ZEPHYR_FD_READ] + 1, &rfds, NULL, NULL, &tv)) { | 1034 while (select(zephyr->fromtzc[ZEPHYR_FD_READ] + 1, &rfds, NULL, NULL, &tv)) { |
1030 selected = 1; | 1035 selected = 1; |
1031 read(zephyr->fromtzc[ZEPHYR_FD_READ], bufcur, 1); | 1036 read(zephyr->fromtzc[ZEPHYR_FD_READ], bufcur, 1); |
1032 bufcur++; | 1037 bufcur++; |
1098 parse_tree *locations; | 1103 parse_tree *locations; |
1099 gchar *locval; | 1104 gchar *locval; |
1100 user = tree_child(find_node(newparsetree,"user"),2)->contents; | 1105 user = tree_child(find_node(newparsetree,"user"),2)->contents; |
1101 | 1106 |
1102 if ((b = gaim_find_buddy(gc->account, user)) == NULL) { | 1107 if ((b = gaim_find_buddy(gc->account, user)) == NULL) { |
1103 gchar *stripped_user = zephyr_strip_local_realm(zephyr,user); | 1108 gchar *stripped_user = zephyr_strip_local_realm(zephyr,user); |
1104 b = gaim_find_buddy(gc->account, stripped_user); | 1109 b = gaim_find_buddy(gc->account, stripped_user); |
1105 g_free(stripped_user); | 1110 g_free(stripped_user); |
1106 } | 1111 } |
1107 locations = find_node(newparsetree,"locations"); | 1112 locations = find_node(newparsetree,"locations"); |
1108 locval = tree_child(tree_child(tree_child(tree_child(locations,2),0),0),2)->contents; | 1113 locval = tree_child(tree_child(tree_child(tree_child(locations,2),0),0),2)->contents; |
1109 | 1114 |
1110 if (!locval || !g_ascii_strcasecmp(locval," ") || (strlen(locval) == 0)) { | 1115 if (!locval || !g_ascii_strcasecmp(locval," ") || (strlen(locval) == 0)) { |
1130 | 1135 |
1131 gaim_notify_userinfo(gc, b ? b->name : user, NULL, _("Buddy Information"), NULL, | 1136 gaim_notify_userinfo(gc, b ? b->name : user, NULL, _("Buddy Information"), NULL, |
1132 str->str, NULL, NULL); | 1137 str->str, NULL, NULL); |
1133 g_string_free(str, TRUE); | 1138 g_string_free(str, TRUE); |
1134 } else { | 1139 } else { |
1135 serv_got_update(gc, b->name, nlocs, 0, 0, 0, 0); | 1140 if (nlocs>0) |
1141 gaim_prpl_got_user_status(gc->account,b->name,"online",NULL); | |
1142 else | |
1143 gaim_prpl_got_user_status(gc->account,b->name,"offline",NULL); | |
1136 } | 1144 } |
1137 } | 1145 } |
1138 else if (!g_ascii_strncasecmp(spewtype,"subscribed",10)) { | 1146 else if (!g_ascii_strncasecmp(spewtype,"subscribed",10)) { |
1139 } | 1147 } |
1140 else if (!g_ascii_strncasecmp(spewtype,"start",5)) { | 1148 else if (!g_ascii_strncasecmp(spewtype,"start",5)) { |
1219 gaim_debug_info("zephyr","chk: %s b->name %s\n",chk,b->name); | 1227 gaim_debug_info("zephyr","chk: %s b->name %s\n",chk,b->name); |
1220 /* XXX add real error reporting */ | 1228 /* XXX add real error reporting */ |
1221 /* doesn't matter if this fails or not; we'll just move on to the next one */ | 1229 /* doesn't matter if this fails or not; we'll just move on to the next one */ |
1222 if (use_zeph02(zephyr)) { | 1230 if (use_zeph02(zephyr)) { |
1223 #ifdef WIN32 | 1231 #ifdef WIN32 |
1224 int numlocs; | 1232 int numlocs; |
1225 int one=1; | 1233 int one=1; |
1226 ZLocateUser(chk,&numlocs,ZAUTH); | 1234 ZLocateUser(chk,&numlocs,ZAUTH); |
1227 if (numlocs) { | 1235 if (numlocs) { |
1228 int i; | 1236 int i; |
1229 for(i=0;i<numlocs;i++) { | 1237 for(i=0;i<numlocs;i++) { |
1230 ZGetLocations(&locations,&one); | 1238 ZGetLocations(&locations,&one); |
1231 serv_got_update(gc,b->name,1,0,0,0,0); | 1239 if (nlocs>0) |
1232 } | 1240 gaim_prpl_got_user_status(gc->account,b->name,"online",NULL); |
1233 } | 1241 else |
1242 gaim_prpl_got_user_status(gc->account,b->name,"offline",NULL); | |
1243 } | |
1244 } | |
1234 #else | 1245 #else |
1235 ZRequestLocations(chk, &ald, UNACKED, ZAUTH); | 1246 ZRequestLocations(chk, &ald, UNACKED, ZAUTH); |
1236 g_free(ald.user); | 1247 g_free(ald.user); |
1237 g_free(ald.version); | 1248 g_free(ald.version); |
1238 #endif /* WIN32 */ | 1249 #endif /* WIN32 */ |
1415 if ((fd = fopen(filename, "r")) != NULL) { | 1426 if ((fd = fopen(filename, "r")) != NULL) { |
1416 while (fgets(buff, BUFSIZ, fd)) { | 1427 while (fgets(buff, BUFSIZ, fd)) { |
1417 strip_comments(buff); | 1428 strip_comments(buff); |
1418 if (buff[0]) { | 1429 if (buff[0]) { |
1419 if (!(b = gaim_find_buddy(gc->account, buff))) { | 1430 if (!(b = gaim_find_buddy(gc->account, buff))) { |
1420 char *stripped_user = zephyr_strip_local_realm(gc->proto_data,buff); | 1431 char *stripped_user = zephyr_strip_local_realm(gc->proto_data,buff); |
1421 gaim_debug_info("zephyr","stripped_user %s\n",stripped_user); | 1432 gaim_debug_info("zephyr","stripped_user %s\n",stripped_user); |
1422 if (!(b = gaim_find_buddy(gc->account,stripped_user))){ | 1433 if (!(b = gaim_find_buddy(gc->account,stripped_user))){ |
1423 b = gaim_buddy_new(gc->account, stripped_user, NULL); | 1434 b = gaim_buddy_new(gc->account, stripped_user, NULL); |
1424 gaim_blist_add_buddy(b, NULL, g, NULL); | 1435 gaim_blist_add_buddy(b, NULL, g, NULL); |
1425 } | 1436 } |
1426 g_free(stripped_user); | 1437 g_free(stripped_user); |
1427 } | 1438 } |
1428 } | 1439 } |
1429 } | 1440 } |
1430 fclose(fd); | 1441 fclose(fd); |
1431 } | 1442 } |
1503 or | 1514 or |
1504 fsh username@hostname pathtotzc -e %s | 1515 fsh username@hostname pathtotzc -e %s |
1505 */ | 1516 */ |
1506 while(tzc_cmd_array[i] != NULL){ | 1517 while(tzc_cmd_array[i] != NULL){ |
1507 if (!g_strncasecmp(tzc_cmd_array[i],"%s",2)) { | 1518 if (!g_strncasecmp(tzc_cmd_array[i],"%s",2)) { |
1508 /* fprintf(stderr,"replacing %%s with %s\n",zephyr->exposure); */ | 1519 /* fprintf(stderr,"replacing %%s with %s\n",zephyr->exposure); */ |
1509 tzc_cmd_array[i] = g_strdup(zephyr->exposure); | 1520 tzc_cmd_array[i] = g_strdup(zephyr->exposure); |
1510 found_ps = TRUE; | 1521 found_ps = TRUE; |
1511 | 1522 |
1512 } else { | 1523 } else { |
1513 /* fprintf(stderr,"keeping %s\n",tzc_cmd_array[i]); */ | 1524 /* fprintf(stderr,"keeping %s\n",tzc_cmd_array[i]); */ |
1514 } | 1525 } |
1515 i++; | 1526 i++; |
1516 } | 1527 } |
1517 | 1528 |
1518 if (!found_ps) { | 1529 if (!found_ps) { |
1531 char *ptr; | 1542 char *ptr; |
1532 int parenlevel=0; | 1543 int parenlevel=0; |
1533 char* tempstr; | 1544 char* tempstr; |
1534 int tempstridx; | 1545 int tempstridx; |
1535 | 1546 |
1536 zephyr->tzc_pid = pid; | 1547 zephyr->tzc_pid = pid; |
1537 /* wait till we have data to read from ssh */ | 1548 /* wait till we have data to read from ssh */ |
1538 FD_ZERO(&rfds); | 1549 FD_ZERO(&rfds); |
1539 FD_SET(zephyr->fromtzc[ZEPHYR_FD_READ], &rfds); | 1550 FD_SET(zephyr->fromtzc[ZEPHYR_FD_READ], &rfds); |
1540 | 1551 |
1541 tv.tv_sec = 10; | 1552 tv.tv_sec = 10; |
1562 FD_SET(zephyr->fromtzc[ZEPHYR_FD_READ], &rfds); | 1573 FD_SET(zephyr->fromtzc[ZEPHYR_FD_READ], &rfds); |
1563 tv.tv_sec = 10; | 1574 tv.tv_sec = 10; |
1564 tv.tv_usec = 0; | 1575 tv.tv_usec = 0; |
1565 | 1576 |
1566 } | 1577 } |
1567 /* fprintf(stderr, "read from tzc\n"); */ | 1578 /* fprintf(stderr, "read from tzc\n"); */ |
1568 *bufcur = '\0'; | 1579 *bufcur = '\0'; |
1569 ptr = buf; | 1580 ptr = buf; |
1570 | 1581 |
1571 /* ignore all tzcoutput till we've received the first (*/ | 1582 /* ignore all tzcoutput till we've received the first (*/ |
1572 while (ptr < bufcur && (*ptr !='(')) { | 1583 while (ptr < bufcur && (*ptr !='(')) { |
1794 for (bnode = cnode->child; bnode; bnode = bnode->next) { | 1805 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
1795 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | 1806 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
1796 continue; | 1807 continue; |
1797 b = (GaimBuddy *) bnode; | 1808 b = (GaimBuddy *) bnode; |
1798 if (b->account == gc->account) { | 1809 if (b->account == gc->account) { |
1799 gchar *stripped_user = zephyr_strip_local_realm(zephyr,b->name); | 1810 gchar *stripped_user = zephyr_strip_local_realm(zephyr,b->name); |
1800 fprintf(fd, "%s\n", stripped_user); | 1811 fprintf(fd, "%s\n", stripped_user); |
1801 g_free(stripped_user); | 1812 g_free(stripped_user); |
1802 } | 1813 } |
1803 } | 1814 } |
1804 } | 1815 } |
1805 } | 1816 } |
1806 | 1817 |
1811 static void zephyr_close(GaimConnection * gc) | 1822 static void zephyr_close(GaimConnection * gc) |
1812 { | 1823 { |
1813 GList *l; | 1824 GList *l; |
1814 GSList *s; | 1825 GSList *s; |
1815 zephyr_account *zephyr = gc->proto_data; | 1826 zephyr_account *zephyr = gc->proto_data; |
1816 pid_t tzc_pid = zephyr->tzc_pid; | 1827 pid_t tzc_pid = zephyr->tzc_pid; |
1817 | 1828 |
1818 l = zephyr->pending_zloc_names; | 1829 l = zephyr->pending_zloc_names; |
1819 while (l) { | 1830 while (l) { |
1820 g_free((char *)l->data); | 1831 g_free((char *)l->data); |
1821 l = l->next; | 1832 l = l->next; |
1846 z_call(ZCancelSubscriptions(0)); | 1857 z_call(ZCancelSubscriptions(0)); |
1847 z_call(ZUnsetLocation()); | 1858 z_call(ZUnsetLocation()); |
1848 z_call(ZClosePort()); | 1859 z_call(ZClosePort()); |
1849 } else { | 1860 } else { |
1850 /* assume tzc */ | 1861 /* assume tzc */ |
1851 if (kill(tzc_pid,SIGTERM) == -1) { | 1862 if (kill(tzc_pid,SIGTERM) == -1) { |
1852 int err=errno; | 1863 int err=errno; |
1853 if (err==EINVAL) { | 1864 if (err==EINVAL) { |
1854 gaim_debug_error("zephyr","An invalid signal was specified when killing tzc\n"); | 1865 gaim_debug_error("zephyr","An invalid signal was specified when killing tzc\n"); |
1855 } | 1866 } |
1856 else if (err==ESRCH) { | 1867 else if (err==ESRCH) { |
1857 gaim_debug_error("zephyr","Tzc's pid didn't exist while killing tzc\n"); | 1868 gaim_debug_error("zephyr","Tzc's pid didn't exist while killing tzc\n"); |
1858 } | 1869 } |
1859 else if (err==EPERM) { | 1870 else if (err==EPERM) { |
1860 gaim_debug_error("zephyr","gaim didn't have permission to kill tzc\n"); | 1871 gaim_debug_error("zephyr","gaim didn't have permission to kill tzc\n"); |
1861 } | 1872 } |
1862 else { | 1873 else { |
1863 gaim_debug_error("zephyr","miscellaneous error while attempting to close tzc\n"); | 1874 gaim_debug_error("zephyr","miscellaneous error while attempting to close tzc\n"); |
1864 } | 1875 } |
1865 } | 1876 } |
1866 } | 1877 } |
1867 } | 1878 } |
1868 | 1879 |
1869 static int zephyr_send_message(zephyr_account *zephyr,char* zclass, char* instance, char* recipient, const char *im, | 1880 static int zephyr_send_message(zephyr_account *zephyr,char* zclass, char* instance, char* recipient, const char *im, |
1870 const char *sig, char *opcode) ; | 1881 const char *sig, char *opcode) ; |
1955 pos++; | 1966 pos++; |
1956 } | 1967 } |
1957 } else { | 1968 } else { |
1958 newmsg = g_strdup(""); | 1969 newmsg = g_strdup(""); |
1959 } | 1970 } |
1960 /* fprintf(stderr,"newmsg %s message %s\n",newmsg,message); */ | 1971 /* fprintf(stderr,"newmsg %s message %s\n",newmsg,message); */ |
1961 return newmsg; | 1972 return newmsg; |
1962 } | 1973 } |
1963 | 1974 |
1964 char* zephyr_tzc_deescape_str(const char *message) | 1975 char* zephyr_tzc_deescape_str(const char *message) |
1965 { | 1976 { |
2006 char* zsendstr; | 2017 char* zsendstr; |
2007 /* CMU cclub tzc doesn't grok opcodes for now */ | 2018 /* CMU cclub tzc doesn't grok opcodes for now */ |
2008 char* tzc_sig = zephyr_tzc_escape_msg(sig); | 2019 char* tzc_sig = zephyr_tzc_escape_msg(sig); |
2009 char *tzc_body = zephyr_tzc_escape_msg(html_buf2); | 2020 char *tzc_body = zephyr_tzc_escape_msg(html_buf2); |
2010 zsendstr = g_strdup_printf("((tzcfodder . send) (class . \"%s\") (auth . t) (recipients (\"%s\" . \"%s\")) (message . (\"%s\" \"%s\")) ) \n", | 2021 zsendstr = g_strdup_printf("((tzcfodder . send) (class . \"%s\") (auth . t) (recipients (\"%s\" . \"%s\")) (message . (\"%s\" \"%s\")) ) \n", |
2011 zclass, instance, recipient, tzc_sig, tzc_body); | 2022 zclass, instance, recipient, tzc_sig, tzc_body); |
2012 /* fprintf(stderr,"zsendstr = %s\n",zsendstr); */ | 2023 /* fprintf(stderr,"zsendstr = %s\n",zsendstr); */ |
2013 write(zephyr->totzc[ZEPHYR_FD_WRITE],zsendstr,strlen(zsendstr)); | 2024 write(zephyr->totzc[ZEPHYR_FD_WRITE],zsendstr,strlen(zsendstr)); |
2014 g_free(zsendstr); | 2025 g_free(zsendstr); |
2015 } else if (use_zeph02(zephyr)) { | 2026 } else if (use_zeph02(zephyr)) { |
2016 ZNotice_t notice; | 2027 ZNotice_t notice; |
2017 char *buf = g_strdup_printf("%s%c%s", sig, '\0', html_buf2); | 2028 char *buf = g_strdup_printf("%s%c%s", sig, '\0', html_buf2); |
2099 write(zephyr->totzc[ZEPHYR_FD_WRITE],zlocstr,strlen(zlocstr)); | 2110 write(zephyr->totzc[ZEPHYR_FD_WRITE],zlocstr,strlen(zlocstr)); |
2100 g_free(zlocstr); | 2111 g_free(zlocstr); |
2101 } | 2112 } |
2102 } | 2113 } |
2103 | 2114 |
2104 static void zephyr_set_away(GaimConnection * gc, const char *state, const char *msg) | 2115 static void zephyr_set_status(GaimAccount *account, GaimStatus *status) { |
2105 { | 2116 zephyr_account *zephyr = gaim_account_get_connection(account)->proto_data; |
2106 zephyr_account *zephyr = gc->proto_data; | 2117 const char *status_id = gaim_status_get_id(status); |
2107 if (gc->away) { | 2118 |
2108 g_free(gc->away); | 2119 if (zephyr->away) { |
2109 gc->away = NULL; | 2120 g_free(zephyr->away); |
2110 } | 2121 zephyr->away=NULL; |
2111 | 2122 } |
2112 if (!g_ascii_strcasecmp(state, _("Hidden"))) { | 2123 |
2124 if (!strcmp(status_id,"away")) { | |
2125 zephyr->away = g_strdup(gaim_status_get_attr_string(status,"message")); | |
2126 } | |
2127 else if (!strcmp(status_id,"online")) { | |
2128 if (use_zeph02(zephyr)) { | |
2129 ZSetLocation(get_exposure_level()); | |
2130 } | |
2131 else { | |
2132 char *zexpstr = g_strdup_printf("((tzcfodder . set-location) (hostname . \"%s\") (exposure . \"%s\"))\n",zephyr->ourhost,zephyr->exposure); | |
2133 write(zephyr->totzc[ZEPHYR_FD_WRITE],zexpstr,strlen(zexpstr)); | |
2134 g_free(zexpstr); | |
2135 } | |
2136 } | |
2137 else if (!strcmp(status_id,"hidden")) { | |
2113 /* XXX handle errors */ | 2138 /* XXX handle errors */ |
2114 if (use_zeph02(zephyr)) { | 2139 if (use_zeph02(zephyr)) { |
2115 ZSetLocation(EXPOSE_OPSTAFF); | 2140 ZSetLocation(EXPOSE_OPSTAFF); |
2116 } else { | 2141 } else { |
2117 char *zexpstr = g_strdup_printf("((tzcfodder . set-location) (hostname . \"%s\") (exposure . \"%s\"))\n",zephyr->ourhost,EXPOSE_OPSTAFF); | 2142 char *zexpstr = g_strdup_printf("((tzcfodder . set-location) (hostname . \"%s\") (exposure . \"%s\"))\n",zephyr->ourhost,EXPOSE_OPSTAFF); |
2118 write(zephyr->totzc[ZEPHYR_FD_WRITE],zexpstr,strlen(zexpstr)); | 2143 write(zephyr->totzc[ZEPHYR_FD_WRITE],zexpstr,strlen(zexpstr)); |
2119 g_free(zexpstr); | 2144 g_free(zexpstr); |
2120 } | 2145 } |
2121 gc->away = g_strdup(""); | 2146 } |
2122 } | 2147 } |
2123 else if (!g_ascii_strcasecmp(state, _("Online"))) { | 2148 |
2124 /* XXX handle errors */ | 2149 static GList *zephyr_status_types(GaimAccount *account) |
2125 if (use_zeph02(zephyr)) { | 2150 { |
2126 ZSetLocation(get_exposure_level()); | 2151 GaimStatusType *type; |
2127 } | 2152 GList *types = NULL; |
2128 else { | 2153 |
2129 char *zexpstr = g_strdup_printf("((tzcfodder . set-location) (hostname . \"%s\") (exposure . \"%s\"))\n",zephyr->ourhost,zephyr->exposure); | 2154 /* zephyr has several exposures |
2130 write(zephyr->totzc[ZEPHYR_FD_WRITE],zexpstr,strlen(zexpstr)); | 2155 NONE (where you are hidden, and zephyrs to you are in practice silently dropped -- yes this is wrong) |
2131 g_free(zexpstr); | 2156 OPSTAFF "hidden" |
2132 } | 2157 REALM-VISIBLE visible to people in local realm |
2133 } | 2158 REALM-ANNOUNCED REALM-VISIBLE+ plus your logins/logouts are announced to <login,username,*> |
2134 else /* state is GAIM_AWAY_CUSTOM */ if (msg) | 2159 NET-VISIBLE REALM-ANNOUNCED, plus visible to people in foreign realm |
2135 gc->away = g_strdup(msg); | 2160 NET-ANNOUNCED NET-VISIBLE, plus logins/logouts are announced to <login,username,*> |
2136 } | 2161 |
2137 | 2162 Online will set the user to the exposure they have in their options (defaulting to REALM-VISIBLE), |
2138 static GList *zephyr_away_states(GaimConnection * gc) | 2163 Hidden, will set the user's exposure to OPSTAFF |
2139 { | 2164 |
2140 GList *m = NULL; | 2165 Away won't change their exposure but will set an auto away message (for IMs only) |
2141 | 2166 */ |
2142 m = g_list_append(m, _("Online")); | 2167 |
2143 m = g_list_append(m, GAIM_AWAY_CUSTOM); | 2168 type = gaim_status_type_new(GAIM_STATUS_ONLINE, "online", _("Online"), FALSE); |
2144 m = g_list_append(m, _("Hidden")); | 2169 types = g_list_append(types,type); |
2145 | 2170 |
2146 return m; | 2171 type = gaim_status_type_new(GAIM_STATUS_HIDDEN, "hidden", _("Hidden"), FALSE); |
2172 types = g_list_append(types,type); | |
2173 | |
2174 type = gaim_status_type_new_with_attrs( | |
2175 GAIM_STATUS_AWAY, "away", _("Away"), TRUE, TRUE, FALSE, | |
2176 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING)); | |
2177 types = g_list_append(types, type); | |
2178 | |
2179 return types; | |
2147 } | 2180 } |
2148 | 2181 |
2149 static GList *zephyr_chat_info(GaimConnection * gc) | 2182 static GList *zephyr_chat_info(GaimConnection * gc) |
2150 { | 2183 { |
2151 GList *m = NULL; | 2184 GList *m = NULL; |
2346 gchar *topic_utf8; | 2379 gchar *topic_utf8; |
2347 zephyr_account* zephyr = gc->proto_data; | 2380 zephyr_account* zephyr = gc->proto_data; |
2348 char *sender = (char *)zephyr->username; | 2381 char *sender = (char *)zephyr->username; |
2349 | 2382 |
2350 zt = find_sub_by_id(gc->proto_data,id); | 2383 zt = find_sub_by_id(gc->proto_data,id); |
2351 /* find_sub_by_id can return NULL */ | 2384 /* find_sub_by_id can return NULL */ |
2352 if (!zt) | 2385 if (!zt) |
2353 return; | 2386 return; |
2354 gconv = gaim_find_conversation_with_account(zt->name, gc->account); | 2387 gconv = gaim_find_conversation_with_account(zt->name, gc->account); |
2355 gcc = gaim_conversation_get_chat_data(gconv); | 2388 gcc = gaim_conversation_get_chat_data(gconv); |
2356 | 2389 |
2357 topic_utf8 = zephyr_recv_convert(gc,(gchar *)topic,strlen(topic)); | 2390 topic_utf8 = zephyr_recv_convert(gc,(gchar *)topic,strlen(topic)); |
2358 gaim_conv_chat_set_topic(gcc,sender,topic_utf8); | 2391 gaim_conv_chat_set_topic(gcc,sender,topic_utf8); |
2653 NO_BUDDY_ICONS, | 2686 NO_BUDDY_ICONS, |
2654 zephyr_list_icon, | 2687 zephyr_list_icon, |
2655 NULL, /* ??? list_emblems */ | 2688 NULL, /* ??? list_emblems */ |
2656 NULL, /* ??? status_text */ | 2689 NULL, /* ??? status_text */ |
2657 NULL, /* ??? tooltip_text */ | 2690 NULL, /* ??? tooltip_text */ |
2658 zephyr_away_states, /* away_states */ | 2691 zephyr_status_types, /* status_types */ |
2659 NULL, /* ??? blist_node_menu - probably all useful actions are already handled*/ | 2692 NULL, /* ??? blist_node_menu - probably all useful actions are already handled*/ |
2660 zephyr_chat_info, /* chat_info */ | 2693 zephyr_chat_info, /* chat_info */ |
2661 NULL, /* chat_info_defaults */ | 2694 NULL, /* chat_info_defaults */ |
2662 zephyr_login, /* login */ | 2695 zephyr_login, /* login */ |
2663 zephyr_close, /* close */ | 2696 zephyr_close, /* close */ |
2664 zephyr_send_im, /* send_im */ | 2697 zephyr_send_im, /* send_im */ |
2665 NULL, /* XXX set info (Location?) */ | 2698 NULL, /* XXX set info (Location?) */ |
2666 zephyr_send_typing, /* send_typing */ | 2699 zephyr_send_typing, /* send_typing */ |
2667 zephyr_zloc, /* get_info */ | 2700 zephyr_zloc, /* get_info */ |
2668 zephyr_set_away, /* XXX set_away need to fix */ | 2701 zephyr_set_status, /* set_status */ |
2669 NULL, /* ??? set idle */ | 2702 NULL, /* ??? set idle */ |
2670 NULL, /* change password */ | 2703 NULL, /* change password */ |
2671 NULL, /* add_buddy */ | 2704 NULL, /* add_buddy */ |
2672 NULL, /* add_buddies */ | 2705 NULL, /* add_buddies */ |
2673 NULL, /* remove_buddy */ | 2706 NULL, /* remove_buddy */ |