- Timestamp:
- 2009-12-12T01:04:43Z (15 years ago)
- Branches:
- master
- Children:
- 7c300bb
- Parents:
- c213d6b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
skype/skype.c
rc213d6b r1f4fc80 21 21 22 22 #define _XOPEN_SOURCE 23 #define _BSD_SOURCE 23 24 #include <poll.h> 24 25 #include <bitlbee.h> … … 158 159 } 159 160 161 int skype_printf(struct im_connection *ic, char *fmt, ...) 162 { 163 va_list args; 164 char str[IRC_LINE_SIZE]; 165 166 va_start(args, fmt); 167 vsnprintf(str, IRC_LINE_SIZE, fmt, args); 168 va_end(args); 169 170 return skype_write(ic, str); 171 } 172 160 173 static void skype_buddy_ask_yes(void *data) 161 174 { 162 175 struct skype_buddy_ask_data *bla = data; 163 char *buf = g_strdup_printf("SET USER %s ISAUTHORIZED TRUE",176 skype_printf(bla->ic, "SET USER %s ISAUTHORIZED TRUE", 164 177 bla->handle); 165 skype_write(bla->ic, buf);166 g_free(buf);167 178 g_free(bla->handle); 168 179 g_free(bla); … … 172 183 { 173 184 struct skype_buddy_ask_data *bla = data; 174 char *buf = g_strdup_printf("SET USER %s ISAUTHORIZED FALSE",185 skype_printf(bla->ic, "SET USER %s ISAUTHORIZED FALSE", 175 186 bla->handle); 176 skype_write(bla->ic, buf);177 g_free(buf);178 187 g_free(bla->handle); 179 188 g_free(bla); … … 198 207 { 199 208 struct skype_buddy_ask_data *bla = data; 200 char *buf = g_strdup_printf("SET CALL %s STATUS INPROGRESS",209 skype_printf(bla->ic, "SET CALL %s STATUS INPROGRESS", 201 210 bla->handle); 202 skype_write(bla->ic, buf);203 g_free(buf);204 211 g_free(bla->handle); 205 212 g_free(bla); … … 209 216 { 210 217 struct skype_buddy_ask_data *bla = data; 211 char *buf = g_strdup_printf("SET CALL %s STATUS FINISHED",218 skype_printf(bla->ic, "SET CALL %s STATUS FINISHED", 212 219 bla->handle); 213 skype_write(bla->ic, buf);214 g_free(buf);215 220 g_free(bla->handle); 216 221 g_free(bla); … … 272 277 static void skype_parse_users(struct im_connection *ic, char *line) 273 278 { 274 char **i, **nicks , *ptr;279 char **i, **nicks; 275 280 276 281 nicks = g_strsplit(line + 6, ", ", 0); 277 for (i = nicks; *i; i++) { 278 ptr = g_strdup_printf("GET USER %s ONLINESTATUS\n", *i); 279 skype_write(ic, ptr); 280 g_free(ptr); 281 } 282 for (i = nicks; *i; i++) 283 skype_printf(ic, "GET USER %s ONLINESTATUS\n", *i); 282 284 g_strfreev(nicks); 283 285 } … … 510 512 * (4) Query chatname 511 513 */ 512 g_snprintf(buf, IRC_LINE_SIZE, "GET CHATMESSAGE %s FROM_HANDLE\n", id); 513 skype_write(ic, buf); 514 g_snprintf(buf, IRC_LINE_SIZE, "GET CHATMESSAGE %s BODY\n", id); 515 skype_write(ic, buf); 516 g_snprintf(buf, IRC_LINE_SIZE, "GET CHATMESSAGE %s TYPE\n", id); 517 skype_write(ic, buf); 518 g_snprintf(buf, IRC_LINE_SIZE, "GET CHATMESSAGE %s CHATNAME\n", id); 519 skype_write(ic, buf); 514 skype_printf(ic, "GET CHATMESSAGE %s FROM_HANDLE\n", id); 515 skype_printf(ic, "GET CHATMESSAGE %s BODY\n", id); 516 skype_printf(ic, "GET CHATMESSAGE %s TYPE\n", id); 517 skype_printf(ic, "GET CHATMESSAGE %s CHATNAME\n", id); 520 518 } else if (!strncmp(info, "FROM_HANDLE ", 12)) { 521 519 info += 12; … … 598 596 g_free(sd->call_id); 599 597 sd->call_id = g_strdup(id); 600 g_snprintf(buf, IRC_LINE_SIZE, "GET CALL %s PARTNER_HANDLE\n", id); 601 skype_write(ic, buf); 598 skype_printf(ic, "GET CALL %s PARTNER_HANDLE\n", id); 602 599 sd->call_status = SKYPE_CALL_RINGING; 603 600 } else if (!strcmp(info, "STATUS MISSED")) { 604 g_snprintf(buf, IRC_LINE_SIZE, "GET CALL %s PARTNER_HANDLE\n", id); 605 skype_write(ic, buf); 601 skype_printf(ic, "GET CALL %s PARTNER_HANDLE\n", id); 606 602 sd->call_status = SKYPE_CALL_MISSED; 607 603 } else if (!strcmp(info, "STATUS CANCELLED")) { 608 g_snprintf(buf, IRC_LINE_SIZE, "GET CALL %s PARTNER_HANDLE\n", id); 609 skype_write(ic, buf); 604 skype_printf(ic, "GET CALL %s PARTNER_HANDLE\n", id); 610 605 sd->call_status = SKYPE_CALL_CANCELLED; 611 606 } else if (!strcmp(info, "STATUS FINISHED")) { 612 g_snprintf(buf, IRC_LINE_SIZE, "GET CALL %s PARTNER_HANDLE\n", id); 613 skype_write(ic, buf); 607 skype_printf(ic, "GET CALL %s PARTNER_HANDLE\n", id); 614 608 sd->call_status = SKYPE_CALL_FINISHED; 615 609 } else if (!strcmp(info, "STATUS REFUSED")) { 616 g_snprintf(buf, IRC_LINE_SIZE, "GET CALL %s PARTNER_HANDLE\n", id); 617 skype_write(ic, buf); 610 skype_printf(ic, "GET CALL %s PARTNER_HANDLE\n", id); 618 611 sd->call_status = SKYPE_CALL_REFUSED; 619 612 } else if (!strcmp(info, "STATUS UNPLACED")) { … … 690 683 { 691 684 struct skype_data *sd = ic->proto_data; 692 char buf[IRC_LINE_SIZE];693 685 char *id = strchr(line, ' '); 694 686 … … 702 694 info++; 703 695 if (!strcmp(info, "STATUS NEW")) { 704 g_snprintf(buf, IRC_LINE_SIZE, "GET FILETRANSFER %s PARTNER_HANDLE\n",696 skype_printf(ic, "GET FILETRANSFER %s PARTNER_HANDLE\n", 705 697 id); 706 skype_write(ic, buf);707 698 sd->filetransfer_status = SKYPE_FILETRANSFER_NEW; 708 699 } else if (!strcmp(info, "STATUS FAILED")) { 709 g_snprintf(buf, IRC_LINE_SIZE, "GET FILETRANSFER %s PARTNER_HANDLE\n",700 skype_printf(ic, "GET FILETRANSFER %s PARTNER_HANDLE\n", 710 701 id); 711 skype_write(ic, buf);712 702 sd->filetransfer_status = SKYPE_FILETRANSFER_FAILED; 713 703 } else if (!strncmp(info, "PARTNER_HANDLE ", 15)) { … … 750 740 if (!strcmp(info, "STATUS MULTI_SUBSCRIBED")) { 751 741 imcb_chat_new(ic, id); 752 g_snprintf(buf, IRC_LINE_SIZE, "GET CHAT %s ADDER\n", id); 753 skype_write(ic, buf); 754 g_snprintf(buf, IRC_LINE_SIZE, "GET CHAT %s TOPIC\n", id); 755 skype_write(ic, buf); 742 skype_printf(ic, "GET CHAT %s ADDER\n", id); 743 skype_printf(ic, "GET CHAT %s TOPIC\n", id); 756 744 } else if (!strcmp(info, "STATUS DIALOG") && sd->groupchat_with) { 757 745 gc = imcb_chat_new(ic, id); … … 762 750 * window on our client, so 763 751 * just leave it out. */ 764 /*g_snprintf(buf, IRC_LINE_SIZE, "OPEN CHAT %s\n", id); 765 skype_write(ic, buf);*/ 752 /*skype_printf(ic, "OPEN CHAT %s\n", id);*/ 766 753 g_snprintf(buf, IRC_LINE_SIZE, "%s@skype.com", sd->groupchat_with); 767 754 imcb_chat_add_buddy(gc, buf); … … 769 756 g_free(sd->groupchat_with); 770 757 sd->groupchat_with = NULL; 771 g_snprintf(buf, IRC_LINE_SIZE, "GET CHAT %s ADDER\n", id); 772 skype_write(ic, buf); 773 g_snprintf(buf, IRC_LINE_SIZE, "GET CHAT %s TOPIC\n", id); 774 skype_write(ic, buf); 758 skype_printf(ic, "GET CHAT %s ADDER\n", id); 759 skype_printf(ic, "GET CHAT %s TOPIC\n", id); 775 760 } else if (!strcmp(info, "STATUS UNSUBSCRIBED")) { 776 761 gc = skype_chat_by_name(ic, id); … … 834 819 static void skype_parse_ping(struct im_connection *ic, char *line) 835 820 { 836 skype_ write(ic, "PONG\n");821 skype_printf(ic, "PONG\n"); 837 822 } 838 823 839 824 static void skype_parse_chats(struct im_connection *ic, char *line) 840 825 { 841 char buf[IRC_LINE_SIZE];842 826 char **i; 843 827 char **chats = g_strsplit(line + 6, ", ", 0); … … 845 829 i = chats; 846 830 while (*i) { 847 g_snprintf(buf, IRC_LINE_SIZE, "GET CHAT %s STATUS\n", *i); 848 skype_write(ic, buf); 849 g_snprintf(buf, IRC_LINE_SIZE, "GET CHAT %s ACTIVEMEMBERS\n", *i); 850 skype_write(ic, buf); 831 skype_printf(ic, "GET CHAT %s STATUS\n", *i); 832 skype_printf(ic, "GET CHAT %s ACTIVEMEMBERS\n", *i); 851 833 i++; 852 834 } … … 917 899 { 918 900 struct skype_data *sd = ic->proto_data; 919 char *buf;920 901 int st; 921 902 … … 928 909 929 910 /* Log in */ 930 buf = g_strdup_printf("USERNAME %s\n", ic->acc->user); 931 st = skype_write(ic, buf); 932 g_free(buf); 933 buf = g_strdup_printf("PASSWORD %s\n", ic->acc->pass); 934 st = skype_write(ic, buf); 935 g_free(buf); 911 skype_printf(ic, "USERNAME %s\n", ic->acc->user); 912 skype_printf(ic, "PASSWORD %s\n", ic->acc->pass); 936 913 937 914 /* This will download all buddies. */ 938 buf = g_strdup_printf("SEARCH FRIENDS\n"); 939 st = skype_write(ic, buf); 940 g_free(buf); 941 buf = g_strdup_printf("SET USERSTATUS ONLINE\n"); 942 skype_write(ic, buf); 943 g_free(buf); 915 st = skype_printf(ic, "SEARCH FRIENDS\n"); 916 skype_printf(ic, "SET USERSTATUS ONLINE\n"); 944 917 945 918 /* Auto join to bookmarked chats if requested.*/ 946 if (set_getbool(&ic->acc->set, "auto_join")) { 947 buf = g_strdup_printf("SEARCH BOOKMARKEDCHATS\n"); 948 skype_write(ic, buf); 949 g_free(buf); 950 } 919 if (set_getbool(&ic->acc->set, "auto_join")) 920 skype_printf(ic, "SEARCH BOOKMARKEDCHATS\n"); 951 921 return st; 952 922 } … … 988 958 { 989 959 struct skype_data *sd = ic->proto_data; 990 char *buf; 991 992 buf = g_strdup_printf("SET USERSTATUS OFFLINE\n"); 993 skype_write(ic, buf); 994 g_free(buf); 960 961 skype_printf(ic, "SET USERSTATUS OFFLINE\n"); 995 962 996 963 g_free(sd->username); … … 1003 970 int flags) 1004 971 { 1005 char * buf, *ptr, *nick;972 char *ptr, *nick; 1006 973 int st; 1007 974 … … 1012 979 1013 980 if (!strncmp(who, "skypeconsole", 12)) 1014 buf = g_strdup_printf("%s\n", message);981 st = skype_printf(ic, "%s\n", message); 1015 982 else 1016 buf = g_strdup_printf("MESSAGE %s %s\n", nick, message);983 st = skype_printf(ic, "MESSAGE %s %s\n", nick, message); 1017 984 g_free(nick); 1018 st = skype_write(ic, buf);1019 g_free(buf);1020 985 1021 986 return st; … … 1037 1002 { 1038 1003 const struct skype_away_state *state; 1039 char *buf;1040 1004 1041 1005 if (strcmp(state_txt, GAIM_AWAY_CUSTOM) == 0) … … 1043 1007 else 1044 1008 state = skype_away_state_by_name(state_txt); 1045 buf = g_strdup_printf("SET USERSTATUS %s\n", state->code); 1046 skype_write(ic, buf); 1047 g_free(buf); 1009 skype_printf(ic, "SET USERSTATUS %s\n", state->code); 1048 1010 } 1049 1011 … … 1065 1027 account_t *acc = set->data; 1066 1028 struct im_connection *ic = acc->ic; 1067 char *buf; 1068 1069 buf = g_strdup_printf("SET PROFILE FULLNAME %s", value); 1070 skype_write(ic, buf); 1071 g_free(buf); 1029 1030 skype_printf(ic, "SET PROFILE FULLNAME %s", value); 1072 1031 return value; 1073 1032 } … … 1077 1036 account_t *acc = set->data; 1078 1037 struct im_connection *ic = acc->ic; 1079 char *buf; 1080 1081 buf = g_strdup_printf("GET PROFILE PSTN_BALANCE"); 1082 skype_write(ic, buf); 1083 g_free(buf); 1038 1039 skype_printf(ic, "GET PROFILE PSTN_BALANCE"); 1084 1040 return value; 1085 1041 } … … 1090 1046 struct im_connection *ic = acc->ic; 1091 1047 struct skype_data *sd = ic->proto_data; 1092 char *nick, *ptr , *buf;1048 char *nick, *ptr; 1093 1049 1094 1050 if (value) { … … 1103 1059 *ptr = '\0'; 1104 1060 1105 buf = g_strdup_printf("CALL %s", nick); 1106 skype_write(ic, buf); 1107 g_free(buf); 1061 skype_printf(ic, "CALL %s", nick); 1108 1062 g_free(nick); 1109 1063 } else { 1110 1064 /* We are ending a call */ 1111 1065 if (sd->call_id) { 1112 buf = g_strdup_printf("SET CALL %s STATUS FINISHED",1066 skype_printf(ic, "SET CALL %s STATUS FINISHED", 1113 1067 sd->call_id); 1114 skype_write(ic, buf);1115 g_free(buf);1116 1068 g_free(sd->call_id); 1117 1069 sd->call_id = NULL; … … 1124 1076 static void skype_add_buddy(struct im_connection *ic, char *who, char *group) 1125 1077 { 1126 char * buf, *nick, *ptr;1078 char *nick, *ptr; 1127 1079 1128 1080 nick = g_strdup(who); … … 1130 1082 if (ptr) 1131 1083 *ptr = '\0'; 1132 buf = g_strdup_printf("SET USER %s BUDDYSTATUS 2 Please authorize me\n",1084 skype_printf(ic, "SET USER %s BUDDYSTATUS 2 Please authorize me\n", 1133 1085 nick); 1134 skype_write(ic, buf);1135 1086 g_free(nick); 1136 1087 } … … 1138 1089 static void skype_remove_buddy(struct im_connection *ic, char *who, char *group) 1139 1090 { 1140 char * buf, *nick, *ptr;1091 char *nick, *ptr; 1141 1092 1142 1093 nick = g_strdup(who); … … 1144 1095 if (ptr) 1145 1096 *ptr = '\0'; 1146 buf = g_strdup_printf("SET USER %s BUDDYSTATUS 1\n", nick); 1147 skype_write(ic, buf); 1097 skype_printf(ic, "SET USER %s BUDDYSTATUS 1\n", nick); 1148 1098 g_free(nick); 1149 1099 } … … 1152 1102 { 1153 1103 struct im_connection *ic = gc->ic; 1154 char *buf; 1155 buf = g_strdup_printf("CHATMESSAGE %s %s\n", gc->title, message); 1156 skype_write(ic, buf); 1157 g_free(buf); 1104 skype_printf(ic, "CHATMESSAGE %s %s\n", gc->title, message); 1158 1105 } 1159 1106 … … 1161 1108 { 1162 1109 struct im_connection *ic = gc->ic; 1163 char *buf; 1164 buf = g_strdup_printf("ALTER CHAT %s LEAVE\n", gc->title); 1165 skype_write(ic, buf); 1166 g_free(buf); 1110 skype_printf(ic, "ALTER CHAT %s LEAVE\n", gc->title); 1167 1111 gc->data = (void *)TRUE; 1168 1112 } … … 1171 1115 { 1172 1116 struct im_connection *ic = gc->ic; 1173 char * buf, *ptr, *nick;1117 char *ptr, *nick; 1174 1118 nick = g_strdup(message); 1175 1119 ptr = strchr(nick, '@'); 1176 1120 if (ptr) 1177 1121 *ptr = '\0'; 1178 buf = g_strdup_printf("ALTER CHAT %s ADDMEMBERS %s\n", gc->title, nick); 1179 skype_write(ic, buf); 1180 g_free(buf); 1122 skype_printf(ic, "ALTER CHAT %s ADDMEMBERS %s\n", gc->title, nick); 1181 1123 g_free(nick); 1182 1124 } … … 1186 1128 struct im_connection *ic = gc->ic; 1187 1129 struct skype_data *sd = ic->proto_data; 1188 char *buf; 1189 buf = g_strdup_printf("ALTER CHAT %s SETTOPIC %s\n", 1130 skype_printf(ic, "ALTER CHAT %s SETTOPIC %s\n", 1190 1131 gc->title, message); 1191 skype_write(ic, buf);1192 g_free(buf);1193 1132 sd->topic_wait = 1; 1194 1133 } … … 1197 1136 { 1198 1137 struct skype_data *sd = ic->proto_data; 1199 char *ptr, *nick , *buf;1138 char *ptr, *nick; 1200 1139 nick = g_strdup(who); 1201 1140 ptr = strchr(nick, '@'); 1202 1141 if (ptr) 1203 1142 *ptr = '\0'; 1204 buf = g_strdup_printf("CHAT CREATE %s\n", nick); 1205 skype_write(ic, buf); 1206 g_free(buf); 1143 skype_printf(ic, "CHAT CREATE %s\n", nick); 1207 1144 sd->groupchat_with = g_strdup(nick); 1208 1145 g_free(nick); … … 1214 1151 static void skype_get_info(struct im_connection *ic, char *who) 1215 1152 { 1216 char *ptr, *nick , *buf;1153 char *ptr, *nick; 1217 1154 nick = g_strdup(who); 1218 1155 ptr = strchr(nick, '@'); 1219 1156 if (ptr) 1220 1157 *ptr = '\0'; 1221 buf = g_strdup_printf("GET USER %s FULLNAME\n", nick); 1222 skype_write(ic, buf); 1223 g_free(buf); 1224 buf = g_strdup_printf("GET USER %s PHONE_HOME\n", nick); 1225 skype_write(ic, buf); 1226 g_free(buf); 1227 buf = g_strdup_printf("GET USER %s PHONE_OFFICE\n", nick); 1228 skype_write(ic, buf); 1229 g_free(buf); 1230 buf = g_strdup_printf("GET USER %s PHONE_MOBILE\n", nick); 1231 skype_write(ic, buf); 1232 g_free(buf); 1233 buf = g_strdup_printf("GET USER %s NROF_AUTHED_BUDDIES\n", nick); 1234 skype_write(ic, buf); 1235 g_free(buf); 1236 buf = g_strdup_printf("GET USER %s TIMEZONE\n", nick); 1237 skype_write(ic, buf); 1238 g_free(buf); 1239 buf = g_strdup_printf("GET USER %s LASTONLINETIMESTAMP\n", nick); 1240 skype_write(ic, buf); 1241 g_free(buf); 1242 buf = g_strdup_printf("GET USER %s BIRTHDAY\n", nick); 1243 skype_write(ic, buf); 1244 g_free(buf); 1245 buf = g_strdup_printf("GET USER %s SEX\n", nick); 1246 skype_write(ic, buf); 1247 g_free(buf); 1248 buf = g_strdup_printf("GET USER %s LANGUAGE\n", nick); 1249 skype_write(ic, buf); 1250 g_free(buf); 1251 buf = g_strdup_printf("GET USER %s COUNTRY\n", nick); 1252 skype_write(ic, buf); 1253 g_free(buf); 1254 buf = g_strdup_printf("GET USER %s PROVINCE\n", nick); 1255 skype_write(ic, buf); 1256 g_free(buf); 1257 buf = g_strdup_printf("GET USER %s CITY\n", nick); 1258 skype_write(ic, buf); 1259 g_free(buf); 1260 buf = g_strdup_printf("GET USER %s HOMEPAGE\n", nick); 1261 skype_write(ic, buf); 1262 g_free(buf); 1263 buf = g_strdup_printf("GET USER %s ABOUT\n", nick); 1264 skype_write(ic, buf); 1265 g_free(buf); 1158 skype_printf(ic, "GET USER %s FULLNAME\n", nick); 1159 skype_printf(ic, "GET USER %s PHONE_HOME\n", nick); 1160 skype_printf(ic, "GET USER %s PHONE_OFFICE\n", nick); 1161 skype_printf(ic, "GET USER %s PHONE_MOBILE\n", nick); 1162 skype_printf(ic, "GET USER %s NROF_AUTHED_BUDDIES\n", nick); 1163 skype_printf(ic, "GET USER %s TIMEZONE\n", nick); 1164 skype_printf(ic, "GET USER %s LASTONLINETIMESTAMP\n", nick); 1165 skype_printf(ic, "GET USER %s BIRTHDAY\n", nick); 1166 skype_printf(ic, "GET USER %s SEX\n", nick); 1167 skype_printf(ic, "GET USER %s LANGUAGE\n", nick); 1168 skype_printf(ic, "GET USER %s COUNTRY\n", nick); 1169 skype_printf(ic, "GET USER %s PROVINCE\n", nick); 1170 skype_printf(ic, "GET USER %s CITY\n", nick); 1171 skype_printf(ic, "GET USER %s HOMEPAGE\n", nick); 1172 skype_printf(ic, "GET USER %s ABOUT\n", nick); 1266 1173 } 1267 1174
Note: See TracChangeset
for help on using the changeset viewer.