[7daec06] | 1 | /* |
---|
| 2 | * skype.c - Skype plugin for BitlBee |
---|
[5adcc65] | 3 | * |
---|
[5258dcc9] | 4 | * Copyright (c) 2007, 2008, 2009 by Miklos Vajna <vmiklos@frugalware.org> |
---|
[f06e3ac] | 5 | * |
---|
[7daec06] | 6 | * Several ideas are used from the BitlBee Jabber plugin, which is |
---|
| 7 | * |
---|
| 8 | * Copyright (c) 2006 by Wilmer van der Gaast <wilmer@gaast.net> |
---|
[5adcc65] | 9 | * |
---|
[7daec06] | 10 | * This program is free software; you can redistribute it and/or modify |
---|
| 11 | * it under the terms of the GNU General Public License as published by |
---|
| 12 | * the Free Software Foundation; either version 2 of the License, or |
---|
| 13 | * (at your option) any later version. |
---|
| 14 | * |
---|
| 15 | * This program is distributed in the hope that it will be useful, |
---|
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 18 | * GNU General Public License for more details. |
---|
| 19 | * |
---|
| 20 | * You should have received a copy of the GNU General Public License |
---|
| 21 | * along with this program; if not, write to the Free Software |
---|
[5adcc65] | 22 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
---|
[7daec06] | 23 | * USA. |
---|
[f06e3ac] | 24 | */ |
---|
[7daec06] | 25 | |
---|
[f9c3e7b] | 26 | #define _XOPEN_SOURCE |
---|
[f06e3ac] | 27 | #include <stdio.h> |
---|
[ed2e37f] | 28 | #include <poll.h> |
---|
[f06e3ac] | 29 | #include <bitlbee.h> |
---|
[c7304b2] | 30 | #include <bitlbee/ssl_client.h> |
---|
[72aa7f0] | 31 | #include <glib.h> |
---|
[f06e3ac] | 32 | |
---|
[f5aedd91] | 33 | #define SKYPE_DEFAULT_SERVER "localhost" |
---|
[4bbd9db] | 34 | #define SKYPE_DEFAULT_PORT "2727" |
---|
[f06e3ac] | 35 | |
---|
[bbba374] | 36 | /* |
---|
| 37 | * Enumerations |
---|
| 38 | */ |
---|
| 39 | |
---|
[359f4d9] | 40 | enum { |
---|
[df9255d] | 41 | SKYPE_CALL_RINGING = 1, |
---|
[9db0234] | 42 | SKYPE_CALL_MISSED, |
---|
[2eb4b1f] | 43 | SKYPE_CALL_CANCELLED, |
---|
[acd9478] | 44 | SKYPE_CALL_FINISHED, |
---|
[d87daf3] | 45 | SKYPE_CALL_REFUSED |
---|
[bbba374] | 46 | } skype_call_status; |
---|
| 47 | |
---|
[359f4d9] | 48 | enum { |
---|
[df9255d] | 49 | SKYPE_FILETRANSFER_NEW = 1, |
---|
| 50 | SKYPE_FILETRANSFER_FAILED |
---|
| 51 | } skype_filetransfer_status; |
---|
| 52 | |
---|
[7daec06] | 53 | /* |
---|
| 54 | * Structures |
---|
| 55 | */ |
---|
| 56 | |
---|
[5adcc65] | 57 | struct skype_data { |
---|
[f06e3ac] | 58 | struct im_connection *ic; |
---|
[a3d6427] | 59 | char *username; |
---|
[368861e] | 60 | /* The effective file descriptor. We store it here so any function can |
---|
| 61 | * write() to it. */ |
---|
[f06e3ac] | 62 | int fd; |
---|
[368861e] | 63 | /* File descriptor returned by bitlbee. we store it so we know when |
---|
| 64 | * we're connected and when we aren't. */ |
---|
| 65 | int bfd; |
---|
[c7304b2] | 66 | /* ssl_getfd() uses this to get the file desciptor. */ |
---|
| 67 | void *ssl; |
---|
[2a0f99c] | 68 | /* When we receive a new message id, we query the properties, finally |
---|
| 69 | * the chatname. Store the properties here so that we can use |
---|
[c81d0ef] | 70 | * imcb_buddy_msg() when we got the chatname. */ |
---|
[77c1abe] | 71 | char *handle; |
---|
[a7af5f0] | 72 | /* List, because of multiline messages. */ |
---|
| 73 | GList *body; |
---|
[2a0f99c] | 74 | char *type; |
---|
[bbba374] | 75 | /* This is necessary because we send a notification when we get the |
---|
| 76 | * handle. So we store the state here and then we can send a |
---|
| 77 | * notification about the handle is in a given status. */ |
---|
[359f4d9] | 78 | int call_status; |
---|
[2eb4b1f] | 79 | char *call_id; |
---|
[48181f0] | 80 | char *call_duration; |
---|
[d87daf3] | 81 | /* If the call is outgoing or not */ |
---|
| 82 | int call_out; |
---|
[df9255d] | 83 | /* Same for file transfers. */ |
---|
[359f4d9] | 84 | int filetransfer_status; |
---|
[86278cd] | 85 | /* Using /j #nick we want to have a groupchat with two people. Usually |
---|
| 86 | * not (default). */ |
---|
[5adcc65] | 87 | char *groupchat_with; |
---|
[f8674db] | 88 | /* The user who invited us to the chat. */ |
---|
[5adcc65] | 89 | char *adder; |
---|
[a5f76a2] | 90 | /* If we are waiting for a confirmation about we changed the topic. */ |
---|
| 91 | int topic_wait; |
---|
[67454bd] | 92 | /* These are used by the info command. */ |
---|
| 93 | char *info_fullname; |
---|
| 94 | char *info_phonehome; |
---|
| 95 | char *info_phoneoffice; |
---|
| 96 | char *info_phonemobile; |
---|
| 97 | char *info_nrbuddies; |
---|
| 98 | char *info_tz; |
---|
| 99 | char *info_seen; |
---|
| 100 | char *info_birthday; |
---|
| 101 | char *info_sex; |
---|
| 102 | char *info_language; |
---|
| 103 | char *info_country; |
---|
| 104 | char *info_province; |
---|
| 105 | char *info_city; |
---|
| 106 | char *info_homepage; |
---|
| 107 | char *info_about; |
---|
[b054fad] | 108 | /* When a call fails, we get the reason and later we get the failure |
---|
| 109 | * event, so store the failure code here till then */ |
---|
| 110 | int failurereason; |
---|
[f06e3ac] | 111 | }; |
---|
| 112 | |
---|
[5adcc65] | 113 | struct skype_away_state { |
---|
[adce2de] | 114 | char *code; |
---|
| 115 | char *full_name; |
---|
| 116 | }; |
---|
| 117 | |
---|
[5adcc65] | 118 | struct skype_buddy_ask_data { |
---|
[7daec06] | 119 | struct im_connection *ic; |
---|
[e0074cb] | 120 | /* This is also used for call IDs for simplicity */ |
---|
[7daec06] | 121 | char *handle; |
---|
| 122 | }; |
---|
| 123 | |
---|
| 124 | /* |
---|
| 125 | * Tables |
---|
| 126 | */ |
---|
| 127 | |
---|
[5adcc65] | 128 | const struct skype_away_state skype_away_state_list[] = { |
---|
[adce2de] | 129 | { "ONLINE", "Online" }, |
---|
| 130 | { "SKYPEME", "Skype Me" }, |
---|
| 131 | { "AWAY", "Away" }, |
---|
| 132 | { "NA", "Not available" }, |
---|
| 133 | { "DND", "Do Not Disturb" }, |
---|
| 134 | { "INVISIBLE", "Invisible" }, |
---|
[23411c6] | 135 | { "OFFLINE", "Offline" }, |
---|
| 136 | { NULL, NULL} |
---|
[adce2de] | 137 | }; |
---|
| 138 | |
---|
[7daec06] | 139 | /* |
---|
| 140 | * Functions |
---|
| 141 | */ |
---|
[d3cbd17] | 142 | |
---|
[5adcc65] | 143 | int skype_write(struct im_connection *ic, char *buf) |
---|
[f06e3ac] | 144 | { |
---|
| 145 | struct skype_data *sd = ic->proto_data; |
---|
[1fb89e3] | 146 | struct pollfd pfd[1]; |
---|
[a5f4040] | 147 | int len = strlen(buf); |
---|
[1fb89e3] | 148 | |
---|
| 149 | pfd[0].fd = sd->fd; |
---|
| 150 | pfd[0].events = POLLOUT; |
---|
[f06e3ac] | 151 | |
---|
[7daec06] | 152 | /* This poll is necessary or we'll get a SIGPIPE when we write() to |
---|
| 153 | * sd->fd. */ |
---|
[1fb89e3] | 154 | poll(pfd, 1, 1000); |
---|
[5adcc65] | 155 | if (pfd[0].revents & POLLHUP) { |
---|
| 156 | imc_logout(ic, TRUE); |
---|
[1fb89e3] | 157 | return FALSE; |
---|
| 158 | } |
---|
[5adcc65] | 159 | ssl_write(sd->ssl, buf, len); |
---|
[f06e3ac] | 160 | |
---|
[9fd4241] | 161 | return TRUE; |
---|
[f06e3ac] | 162 | } |
---|
| 163 | |
---|
[5adcc65] | 164 | static void skype_buddy_ask_yes(void *data) |
---|
[d3cbd17] | 165 | { |
---|
[039116a] | 166 | struct skype_buddy_ask_data *bla = data; |
---|
[8c09bb3] | 167 | char *buf = g_strdup_printf("SET USER %s ISAUTHORIZED TRUE", |
---|
| 168 | bla->handle); |
---|
[5adcc65] | 169 | skype_write(bla->ic, buf); |
---|
[d3cbd17] | 170 | g_free(buf); |
---|
| 171 | g_free(bla->handle); |
---|
| 172 | g_free(bla); |
---|
| 173 | } |
---|
| 174 | |
---|
[5adcc65] | 175 | static void skype_buddy_ask_no(void *data) |
---|
[d3cbd17] | 176 | { |
---|
[039116a] | 177 | struct skype_buddy_ask_data *bla = data; |
---|
[8c09bb3] | 178 | char *buf = g_strdup_printf("SET USER %s ISAUTHORIZED FALSE", |
---|
| 179 | bla->handle); |
---|
[5adcc65] | 180 | skype_write(bla->ic, buf); |
---|
[d3cbd17] | 181 | g_free(buf); |
---|
| 182 | g_free(bla->handle); |
---|
| 183 | g_free(bla); |
---|
| 184 | } |
---|
| 185 | |
---|
[5adcc65] | 186 | void skype_buddy_ask(struct im_connection *ic, char *handle, char *message) |
---|
[d3cbd17] | 187 | { |
---|
[8c09bb3] | 188 | struct skype_buddy_ask_data *bla = g_new0(struct skype_buddy_ask_data, |
---|
| 189 | 1); |
---|
[d3cbd17] | 190 | char *buf; |
---|
| 191 | |
---|
| 192 | bla->ic = ic; |
---|
| 193 | bla->handle = g_strdup(handle); |
---|
| 194 | |
---|
[8c09bb3] | 195 | buf = g_strdup_printf("The user %s wants to add you to " |
---|
| 196 | "his/her buddy list, saying: '%s'.", handle, message); |
---|
[5adcc65] | 197 | imcb_ask(ic, buf, bla, skype_buddy_ask_yes, skype_buddy_ask_no); |
---|
| 198 | g_free(buf); |
---|
[d3cbd17] | 199 | } |
---|
| 200 | |
---|
[5adcc65] | 201 | static void skype_call_ask_yes(void *data) |
---|
[e0074cb] | 202 | { |
---|
[039116a] | 203 | struct skype_buddy_ask_data *bla = data; |
---|
[8c09bb3] | 204 | char *buf = g_strdup_printf("SET CALL %s STATUS INPROGRESS", |
---|
| 205 | bla->handle); |
---|
[5adcc65] | 206 | skype_write(bla->ic, buf); |
---|
[e0074cb] | 207 | g_free(buf); |
---|
| 208 | g_free(bla->handle); |
---|
| 209 | g_free(bla); |
---|
| 210 | } |
---|
| 211 | |
---|
[5adcc65] | 212 | static void skype_call_ask_no(void *data) |
---|
[e0074cb] | 213 | { |
---|
[039116a] | 214 | struct skype_buddy_ask_data *bla = data; |
---|
[8c09bb3] | 215 | char *buf = g_strdup_printf("SET CALL %s STATUS FINISHED", |
---|
| 216 | bla->handle); |
---|
[5adcc65] | 217 | skype_write(bla->ic, buf); |
---|
[e0074cb] | 218 | g_free(buf); |
---|
| 219 | g_free(bla->handle); |
---|
| 220 | g_free(bla); |
---|
| 221 | } |
---|
| 222 | |
---|
[5adcc65] | 223 | void skype_call_ask(struct im_connection *ic, char *call_id, char *message) |
---|
[e0074cb] | 224 | { |
---|
[8c09bb3] | 225 | struct skype_buddy_ask_data *bla = g_new0(struct skype_buddy_ask_data, |
---|
| 226 | 1); |
---|
[e0074cb] | 227 | |
---|
| 228 | bla->ic = ic; |
---|
| 229 | bla->handle = g_strdup(call_id); |
---|
| 230 | |
---|
[5adcc65] | 231 | imcb_ask(ic, message, bla, skype_call_ask_yes, skype_call_ask_no); |
---|
[e0074cb] | 232 | } |
---|
[5adcc65] | 233 | struct groupchat *skype_chat_by_name(struct im_connection *ic, char *name) |
---|
[72aa7f0] | 234 | { |
---|
| 235 | struct groupchat *ret; |
---|
| 236 | |
---|
[5adcc65] | 237 | for (ret = ic->groupchats; ret; ret = ret->next) |
---|
| 238 | if (strcmp(name, ret->title) == 0) |
---|
[72aa7f0] | 239 | break; |
---|
| 240 | |
---|
| 241 | return ret; |
---|
| 242 | } |
---|
| 243 | |
---|
[b054fad] | 244 | static char *skype_call_strerror(int err) |
---|
| 245 | { |
---|
[5adcc65] | 246 | switch (err) { |
---|
| 247 | case 1: |
---|
| 248 | return "Miscellaneous error"; |
---|
| 249 | case 2: |
---|
| 250 | return "User or phone number does not exist."; |
---|
| 251 | case 3: |
---|
| 252 | return "User is offline"; |
---|
| 253 | case 4: |
---|
| 254 | return "No proxy found"; |
---|
| 255 | case 5: |
---|
| 256 | return "Session terminated."; |
---|
| 257 | case 6: |
---|
| 258 | return "No common codec found."; |
---|
| 259 | case 7: |
---|
| 260 | return "Sound I/O error."; |
---|
| 261 | case 8: |
---|
| 262 | return "Problem with remote sound device."; |
---|
| 263 | case 9: |
---|
| 264 | return "Call blocked by recipient."; |
---|
| 265 | case 10: |
---|
| 266 | return "Recipient not a friend."; |
---|
| 267 | case 11: |
---|
| 268 | return "Current user not authorized by recipient."; |
---|
| 269 | case 12: |
---|
| 270 | return "Sound recording error."; |
---|
| 271 | default: |
---|
| 272 | return "Unknown error"; |
---|
[b054fad] | 273 | } |
---|
| 274 | } |
---|
| 275 | |
---|
[078b0b9] | 276 | static void skype_parse_users(struct im_connection *ic, char *line) |
---|
| 277 | { |
---|
| 278 | char **i, **nicks, *ptr; |
---|
| 279 | |
---|
| 280 | nicks = g_strsplit(line + 6, ", ", 0); |
---|
[8bbe52a] | 281 | for (i = nicks; *i; i++) { |
---|
[078b0b9] | 282 | ptr = g_strdup_printf("GET USER %s ONLINESTATUS\n", *i); |
---|
| 283 | skype_write(ic, ptr); |
---|
| 284 | g_free(ptr); |
---|
| 285 | } |
---|
| 286 | g_strfreev(nicks); |
---|
| 287 | } |
---|
| 288 | |
---|
[8c09bb3] | 289 | static gboolean skype_read_callback(gpointer data, gint fd, |
---|
| 290 | b_input_condition cond) |
---|
[1323e36] | 291 | { |
---|
| 292 | struct im_connection *ic = data; |
---|
| 293 | struct skype_data *sd = ic->proto_data; |
---|
| 294 | char buf[1024]; |
---|
| 295 | int st; |
---|
[9fd4241] | 296 | char **lines, **lineptr, *line, *ptr; |
---|
[1323e36] | 297 | |
---|
[5adcc65] | 298 | if (!sd || sd->fd == -1) |
---|
[1323e36] | 299 | return FALSE; |
---|
[7daec06] | 300 | /* Read the whole data. */ |
---|
[5adcc65] | 301 | st = ssl_read(sd->ssl, buf, sizeof(buf)); |
---|
| 302 | if (st > 0) { |
---|
[1323e36] | 303 | buf[st] = '\0'; |
---|
[7daec06] | 304 | /* Then split it up to lines. */ |
---|
[9fd4241] | 305 | lines = g_strsplit(buf, "\n", 0); |
---|
| 306 | lineptr = lines; |
---|
[5adcc65] | 307 | while ((line = *lineptr)) { |
---|
| 308 | if (!strlen(line)) |
---|
[9fd4241] | 309 | break; |
---|
[b820226] | 310 | if (set_getbool(&ic->acc->set, "skypeconsole_receive")) |
---|
| 311 | imcb_buddy_msg(ic, "skypeconsole", line, 0, 0); |
---|
[078b0b9] | 312 | if (!strncmp(line, "USERS ", 6)) |
---|
| 313 | skype_parse_users(ic, line); |
---|
| 314 | else if (!strncmp(line, "USER ", 5)) { |
---|
[adce2de] | 315 | int flags = 0; |
---|
[be975f8] | 316 | char *status = strrchr(line, ' '); |
---|
| 317 | char *user = strchr(line, ' '); |
---|
[adce2de] | 318 | status++; |
---|
[be975f8] | 319 | ptr = strchr(++user, ' '); |
---|
| 320 | *ptr = '\0'; |
---|
[6627d92] | 321 | ptr++; |
---|
[5adcc65] | 322 | if (!strncmp(ptr, "ONLINESTATUS ", 13) && |
---|
[7daec06] | 323 | strcmp(user, sd->username) != 0 |
---|
[5adcc65] | 324 | && strcmp(user, "echo123") != 0) { |
---|
[a3d6427] | 325 | ptr = g_strdup_printf("%s@skype.com", user); |
---|
| 326 | imcb_add_buddy(ic, ptr, NULL); |
---|
[5adcc65] | 327 | if (strcmp(status, "OFFLINE") && (strcmp(status, "SKYPEOUT") || !set_getbool(&ic->acc->set, "skypeout_offline"))) |
---|
[a3d6427] | 328 | flags |= OPT_LOGGED_IN; |
---|
[5adcc65] | 329 | if (strcmp(status, "ONLINE") != 0 && strcmp(status, "SKYPEME") != 0) |
---|
[a3d6427] | 330 | flags |= OPT_AWAY; |
---|
| 331 | imcb_buddy_status(ic, ptr, flags, NULL, NULL); |
---|
| 332 | g_free(ptr); |
---|
[5adcc65] | 333 | } else if (!strncmp(ptr, "RECEIVEDAUTHREQUEST ", 20)) { |
---|
[d3cbd17] | 334 | char *message = ptr + 20; |
---|
[5adcc65] | 335 | if (strlen(message)) |
---|
[d3cbd17] | 336 | skype_buddy_ask(ic, user, message); |
---|
[5adcc65] | 337 | } else if (!strncmp(ptr, "BUDDYSTATUS ", 12)) { |
---|
[d3cbd17] | 338 | char *st = ptr + 12; |
---|
[5adcc65] | 339 | if (!strcmp(st, "3")) { |
---|
[d3cbd17] | 340 | char *buf = g_strdup_printf("%s@skype.com", user); |
---|
| 341 | imcb_add_buddy(ic, buf, NULL); |
---|
| 342 | g_free(buf); |
---|
| 343 | } |
---|
[5adcc65] | 344 | } else if (!strncmp(ptr, "FULLNAME ", 9)) |
---|
[67454bd] | 345 | sd->info_fullname = g_strdup_printf("%s", ptr + 9); |
---|
[5adcc65] | 346 | else if (!strncmp(ptr, "PHONE_HOME ", 11)) |
---|
[93052e1] | 347 | sd->info_phonehome = g_strdup_printf("%s", ptr + 11); |
---|
[5adcc65] | 348 | else if (!strncmp(ptr, "PHONE_OFFICE ", 13)) |
---|
[93052e1] | 349 | sd->info_phoneoffice = g_strdup_printf("%s", ptr + 13); |
---|
[5adcc65] | 350 | else if (!strncmp(ptr, "PHONE_MOBILE ", 13)) |
---|
[93052e1] | 351 | sd->info_phonemobile = g_strdup_printf("%s", ptr + 13); |
---|
[5adcc65] | 352 | else if (!strncmp(ptr, "NROF_AUTHED_BUDDIES ", 20)) |
---|
[93052e1] | 353 | sd->info_nrbuddies = g_strdup_printf("%s", ptr + 20); |
---|
[5adcc65] | 354 | else if (!strncmp(ptr, "TIMEZONE ", 9)) |
---|
[93052e1] | 355 | sd->info_tz = g_strdup_printf("%s", ptr + 9); |
---|
[5adcc65] | 356 | else if (!strncmp(ptr, "LASTONLINETIMESTAMP ", 20)) |
---|
[93052e1] | 357 | sd->info_seen = g_strdup_printf("%s", ptr + 20); |
---|
[5adcc65] | 358 | else if (!strncmp(ptr, "BIRTHDAY ", 9)) |
---|
[93052e1] | 359 | sd->info_birthday = g_strdup_printf("%s", ptr + 9); |
---|
[5adcc65] | 360 | else if (!strncmp(ptr, "SEX ", 4)) |
---|
[93052e1] | 361 | sd->info_sex = g_strdup_printf("%s", ptr + 4); |
---|
[5adcc65] | 362 | else if (!strncmp(ptr, "LANGUAGE ", 9)) |
---|
[93052e1] | 363 | sd->info_language = g_strdup_printf("%s", ptr + 9); |
---|
[5adcc65] | 364 | else if (!strncmp(ptr, "COUNTRY ", 8)) |
---|
[93052e1] | 365 | sd->info_country = g_strdup_printf("%s", ptr + 8); |
---|
[5adcc65] | 366 | else if (!strncmp(ptr, "PROVINCE ", 9)) |
---|
[93052e1] | 367 | sd->info_province = g_strdup_printf("%s", ptr + 9); |
---|
[5adcc65] | 368 | else if (!strncmp(ptr, "CITY ", 5)) |
---|
[93052e1] | 369 | sd->info_city = g_strdup_printf("%s", ptr + 5); |
---|
[5adcc65] | 370 | else if (!strncmp(ptr, "HOMEPAGE ", 9)) |
---|
[93052e1] | 371 | sd->info_homepage = g_strdup_printf("%s", ptr + 9); |
---|
[5adcc65] | 372 | else if (!strncmp(ptr, "ABOUT ", 6)) { |
---|
[67454bd] | 373 | sd->info_about = g_strdup_printf("%s", ptr + 6); |
---|
| 374 | |
---|
[93052e1] | 375 | GString *st = g_string_new("Contact Information\n"); |
---|
[67454bd] | 376 | g_string_append_printf(st, "Skype Name: %s\n", user); |
---|
[5adcc65] | 377 | if (sd->info_fullname) { |
---|
| 378 | if (strlen(sd->info_fullname)) |
---|
[93052e1] | 379 | g_string_append_printf(st, "Full Name: %s\n", sd->info_fullname); |
---|
[67454bd] | 380 | g_free(sd->info_fullname); |
---|
| 381 | } |
---|
[5adcc65] | 382 | if (sd->info_phonehome) { |
---|
| 383 | if (strlen(sd->info_phonehome)) |
---|
[93052e1] | 384 | g_string_append_printf(st, "Home Phone: %s\n", sd->info_phonehome); |
---|
| 385 | g_free(sd->info_phonehome); |
---|
| 386 | } |
---|
[5adcc65] | 387 | if (sd->info_phoneoffice) { |
---|
| 388 | if (strlen(sd->info_phoneoffice)) |
---|
[93052e1] | 389 | g_string_append_printf(st, "Office Phone: %s\n", sd->info_phoneoffice); |
---|
| 390 | g_free(sd->info_phoneoffice); |
---|
| 391 | } |
---|
[5adcc65] | 392 | if (sd->info_phonemobile) { |
---|
| 393 | if (strlen(sd->info_phonemobile)) |
---|
[93052e1] | 394 | g_string_append_printf(st, "Mobile Phone: %s\n", sd->info_phonemobile); |
---|
| 395 | g_free(sd->info_phonemobile); |
---|
| 396 | } |
---|
| 397 | g_string_append_printf(st, "Personal Information\n"); |
---|
[5adcc65] | 398 | if (sd->info_nrbuddies) { |
---|
| 399 | if (strlen(sd->info_nrbuddies)) |
---|
[93052e1] | 400 | g_string_append_printf(st, "Contacts: %s\n", sd->info_nrbuddies); |
---|
| 401 | g_free(sd->info_nrbuddies); |
---|
| 402 | } |
---|
[5adcc65] | 403 | if (sd->info_tz) { |
---|
| 404 | if (strlen(sd->info_tz)) { |
---|
[33cac97] | 405 | char ib[256]; |
---|
| 406 | time_t t = time(NULL); |
---|
| 407 | t += atoi(sd->info_tz)-(60*60*24); |
---|
| 408 | struct tm *gt = gmtime(&t); |
---|
| 409 | strftime(ib, 256, "%H:%M:%S", gt); |
---|
| 410 | g_string_append_printf(st, "Local Time: %s\n", ib); |
---|
[885efac6] | 411 | } |
---|
[93052e1] | 412 | g_free(sd->info_tz); |
---|
| 413 | } |
---|
[5adcc65] | 414 | if (sd->info_seen) { |
---|
| 415 | if (strlen(sd->info_seen)) { |
---|
[3c5aded] | 416 | char ib[256]; |
---|
| 417 | time_t it = atoi(sd->info_seen); |
---|
| 418 | struct tm *tm = localtime(&it); |
---|
| 419 | strftime(ib, 256, ("%Y. %m. %d. %H:%M"), tm); |
---|
| 420 | g_string_append_printf(st, "Last Seen: %s\n", ib); |
---|
[885efac6] | 421 | } |
---|
[93052e1] | 422 | g_free(sd->info_seen); |
---|
| 423 | } |
---|
[5adcc65] | 424 | if (sd->info_birthday) { |
---|
| 425 | if (strlen(sd->info_birthday) && strcmp(sd->info_birthday, "0")) { |
---|
[f9c3e7b] | 426 | char ib[256]; |
---|
| 427 | struct tm tm; |
---|
| 428 | strptime(sd->info_birthday, "%Y%m%d", &tm); |
---|
| 429 | strftime(ib, 256, "%B %d, %Y", &tm); |
---|
| 430 | g_string_append_printf(st, "Birthday: %s\n", ib); |
---|
[5b9847d] | 431 | |
---|
| 432 | strftime(ib, 256, "%Y", &tm); |
---|
| 433 | int year = atoi(ib); |
---|
| 434 | time_t t = time(NULL); |
---|
| 435 | struct tm *lt = localtime(&t); |
---|
| 436 | g_string_append_printf(st, "Age: %d\n", lt->tm_year+1900-year); |
---|
[885efac6] | 437 | } |
---|
[93052e1] | 438 | g_free(sd->info_birthday); |
---|
| 439 | } |
---|
[5adcc65] | 440 | if (sd->info_sex) { |
---|
| 441 | if (strlen(sd->info_sex)) { |
---|
[6b43dd4] | 442 | char *iptr = sd->info_sex; |
---|
[5adcc65] | 443 | while (*iptr++) |
---|
[6b43dd4] | 444 | *iptr = tolower(*iptr); |
---|
[93052e1] | 445 | g_string_append_printf(st, "Gender: %s\n", sd->info_sex); |
---|
[885efac6] | 446 | } |
---|
[93052e1] | 447 | g_free(sd->info_sex); |
---|
| 448 | } |
---|
[5adcc65] | 449 | if (sd->info_language) { |
---|
| 450 | if (strlen(sd->info_language)) { |
---|
[885efac6] | 451 | char *iptr = strchr(sd->info_language, ' '); |
---|
[5adcc65] | 452 | if (iptr) |
---|
[885efac6] | 453 | iptr++; |
---|
| 454 | else |
---|
| 455 | iptr = sd->info_language; |
---|
| 456 | g_string_append_printf(st, "Language: %s\n", iptr); |
---|
| 457 | } |
---|
[93052e1] | 458 | g_free(sd->info_language); |
---|
| 459 | } |
---|
[5adcc65] | 460 | if (sd->info_country) { |
---|
| 461 | if (strlen(sd->info_country)) { |
---|
[885efac6] | 462 | char *iptr = strchr(sd->info_country, ' '); |
---|
[5adcc65] | 463 | if (iptr) |
---|
[885efac6] | 464 | iptr++; |
---|
| 465 | else |
---|
| 466 | iptr = sd->info_country; |
---|
[191470d] | 467 | g_string_append_printf(st, "Country: %s\n", iptr); |
---|
[885efac6] | 468 | } |
---|
[93052e1] | 469 | g_free(sd->info_country); |
---|
| 470 | } |
---|
[5adcc65] | 471 | if (sd->info_province) { |
---|
| 472 | if (strlen(sd->info_province)) |
---|
[93052e1] | 473 | g_string_append_printf(st, "Region: %s\n", sd->info_province); |
---|
| 474 | g_free(sd->info_province); |
---|
| 475 | } |
---|
[5adcc65] | 476 | if (sd->info_city) { |
---|
| 477 | if (strlen(sd->info_city)) |
---|
[93052e1] | 478 | g_string_append_printf(st, "City: %s\n", sd->info_city); |
---|
| 479 | g_free(sd->info_city); |
---|
| 480 | } |
---|
[5adcc65] | 481 | if (sd->info_homepage) { |
---|
| 482 | if (strlen(sd->info_homepage)) |
---|
[93052e1] | 483 | g_string_append_printf(st, "Homepage: %s\n", sd->info_homepage); |
---|
| 484 | g_free(sd->info_homepage); |
---|
| 485 | } |
---|
[5adcc65] | 486 | if (sd->info_about) { |
---|
| 487 | if (strlen(sd->info_about)) |
---|
[93052e1] | 488 | g_string_append_printf(st, "%s\n", sd->info_about); |
---|
| 489 | g_free(sd->info_about); |
---|
| 490 | } |
---|
[67454bd] | 491 | imcb_log(ic, "%s", st->str); |
---|
| 492 | g_string_free(st, TRUE); |
---|
| 493 | } |
---|
[5adcc65] | 494 | } else if (!strncmp(line, "CHATMESSAGE ", 12)) { |
---|
[77c1abe] | 495 | char *id = strchr(line, ' '); |
---|
[5adcc65] | 496 | if (++id) { |
---|
[77c1abe] | 497 | char *info = strchr(id, ' '); |
---|
| 498 | *info = '\0'; |
---|
| 499 | info++; |
---|
[5adcc65] | 500 | if (!strcmp(info, "STATUS RECEIVED")) { |
---|
[7daec06] | 501 | /* New message ID: |
---|
| 502 | * (1) Request its from field |
---|
| 503 | * (2) Request its body |
---|
[2a0f99c] | 504 | * (3) Request its type |
---|
| 505 | * (4) Query chatname |
---|
[7daec06] | 506 | */ |
---|
[77c1abe] | 507 | g_snprintf(buf, 1024, "GET CHATMESSAGE %s FROM_HANDLE\n", id); |
---|
[5adcc65] | 508 | skype_write(ic, buf); |
---|
[77c1abe] | 509 | g_snprintf(buf, 1024, "GET CHATMESSAGE %s BODY\n", id); |
---|
[5adcc65] | 510 | skype_write(ic, buf); |
---|
[2a0f99c] | 511 | g_snprintf(buf, 1024, "GET CHATMESSAGE %s TYPE\n", id); |
---|
[5adcc65] | 512 | skype_write(ic, buf); |
---|
[c81d0ef] | 513 | g_snprintf(buf, 1024, "GET CHATMESSAGE %s CHATNAME\n", id); |
---|
[5adcc65] | 514 | skype_write(ic, buf); |
---|
| 515 | } else if (!strncmp(info, "FROM_HANDLE ", 12)) { |
---|
[77c1abe] | 516 | info += 12; |
---|
[7daec06] | 517 | /* New from field value. Store |
---|
| 518 | * it, then we can later use it |
---|
| 519 | * when we got the message's |
---|
| 520 | * body. */ |
---|
[7613670] | 521 | g_free(sd->handle); |
---|
[77c1abe] | 522 | sd->handle = g_strdup_printf("%s@skype.com", info); |
---|
[5adcc65] | 523 | } else if (!strncmp(info, "EDITED_BY ", 10)) { |
---|
[5d1b0774] | 524 | info += 10; |
---|
| 525 | /* This is the same as |
---|
| 526 | * FROM_HANDLE, except that we |
---|
| 527 | * never request these lines |
---|
| 528 | * from Skype, we just get |
---|
| 529 | * them. */ |
---|
| 530 | g_free(sd->handle); |
---|
| 531 | sd->handle = g_strdup_printf("%s@skype.com", info); |
---|
[5adcc65] | 532 | } else if (!strncmp(info, "BODY ", 5)) { |
---|
[77c1abe] | 533 | info += 5; |
---|
[a7af5f0] | 534 | sd->body = g_list_append(sd->body, g_strdup(info)); |
---|
[5adcc65] | 535 | } else if (!strncmp(info, "TYPE ", 5)) { |
---|
[2a0f99c] | 536 | info += 5; |
---|
| 537 | g_free(sd->type); |
---|
| 538 | sd->type = g_strdup(info); |
---|
[5adcc65] | 539 | } else if (!strncmp(info, "CHATNAME ", 9)) { |
---|
[c81d0ef] | 540 | info += 9; |
---|
[5adcc65] | 541 | if (sd->handle && sd->body && sd->type) { |
---|
[31870ae] | 542 | struct groupchat *gc = skype_chat_by_name(ic, info); |
---|
[a7af5f0] | 543 | int i; |
---|
[5adcc65] | 544 | for (i = 0; i < g_list_length(sd->body); i++) { |
---|
[a7af5f0] | 545 | char *body = g_list_nth_data(sd->body, i); |
---|
[5adcc65] | 546 | if (!strcmp(sd->type, "SAID") || !strcmp(sd->type, "EMOTED")) { |
---|
[54e6207] | 547 | char *st; |
---|
[5adcc65] | 548 | if (!strcmp(sd->type, "SAID")) |
---|
[54e6207] | 549 | st = g_strdup(body); |
---|
| 550 | else |
---|
| 551 | st = g_strdup_printf("/me %s", body); |
---|
[5adcc65] | 552 | if (!gc) |
---|
[a7af5f0] | 553 | /* Private message */ |
---|
[54e6207] | 554 | imcb_buddy_msg(ic, sd->handle, st, 0, 0); |
---|
[a7af5f0] | 555 | else |
---|
| 556 | /* Groupchat message */ |
---|
[54e6207] | 557 | imcb_chat_msg(gc, sd->handle, st, 0, 0); |
---|
| 558 | g_free(st); |
---|
[5adcc65] | 559 | } else if (!strcmp(sd->type, "SETTOPIC")) { |
---|
| 560 | if (gc) |
---|
[de2f05e] | 561 | imcb_chat_topic(gc, sd->handle, body, 0); |
---|
[5adcc65] | 562 | } else if (!strcmp(sd->type, "LEFT")) { |
---|
| 563 | if (gc) |
---|
[a7af5f0] | 564 | imcb_chat_remove_buddy(gc, sd->handle, NULL); |
---|
| 565 | } |
---|
[2a0f99c] | 566 | } |
---|
[a7af5f0] | 567 | g_list_free(sd->body); |
---|
| 568 | sd->body = NULL; |
---|
[7daec06] | 569 | } |
---|
[77c1abe] | 570 | } |
---|
| 571 | } |
---|
[5adcc65] | 572 | } else if (!strncmp(line, "CALL ", 5)) { |
---|
[ecfbc5d] | 573 | char *id = strchr(line, ' '); |
---|
[5adcc65] | 574 | if (++id) { |
---|
[ecfbc5d] | 575 | char *info = strchr(id, ' '); |
---|
| 576 | *info = '\0'; |
---|
| 577 | info++; |
---|
[5adcc65] | 578 | if (!strncmp(info, "FAILUREREASON ", 14)) |
---|
[b054fad] | 579 | sd->failurereason = atoi(strchr(info, ' ')); |
---|
[5adcc65] | 580 | else if (!strcmp(info, "STATUS RINGING")) { |
---|
| 581 | if (sd->call_id) |
---|
[e0074cb] | 582 | g_free(sd->call_id); |
---|
| 583 | sd->call_id = g_strdup(id); |
---|
[ecfbc5d] | 584 | g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); |
---|
[5adcc65] | 585 | skype_write(ic, buf); |
---|
[d87daf3] | 586 | sd->call_status = SKYPE_CALL_RINGING; |
---|
[5adcc65] | 587 | } else if (!strcmp(info, "STATUS MISSED")) { |
---|
[bbba374] | 588 | g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); |
---|
[5adcc65] | 589 | skype_write(ic, buf); |
---|
[bbba374] | 590 | sd->call_status = SKYPE_CALL_MISSED; |
---|
[5adcc65] | 591 | } else if (!strcmp(info, "STATUS CANCELLED")) { |
---|
[d87daf3] | 592 | g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); |
---|
[5adcc65] | 593 | skype_write(ic, buf); |
---|
[d87daf3] | 594 | sd->call_status = SKYPE_CALL_CANCELLED; |
---|
[5adcc65] | 595 | } else if (!strcmp(info, "STATUS FINISHED")) { |
---|
[acd9478] | 596 | g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); |
---|
[5adcc65] | 597 | skype_write(ic, buf); |
---|
[acd9478] | 598 | sd->call_status = SKYPE_CALL_FINISHED; |
---|
[5adcc65] | 599 | } else if (!strcmp(info, "STATUS REFUSED")) { |
---|
[a92fb07] | 600 | g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id); |
---|
[5adcc65] | 601 | skype_write(ic, buf); |
---|
[a92fb07] | 602 | sd->call_status = SKYPE_CALL_REFUSED; |
---|
[5adcc65] | 603 | } else if (!strcmp(info, "STATUS UNPLACED")) { |
---|
| 604 | if (sd->call_id) |
---|
[2eb4b1f] | 605 | g_free(sd->call_id); |
---|
| 606 | /* Save the ID for later usage (Cancel/Finish). */ |
---|
| 607 | sd->call_id = g_strdup(id); |
---|
[d87daf3] | 608 | sd->call_out = TRUE; |
---|
[5adcc65] | 609 | } else if (!strcmp(info, "STATUS FAILED")) { |
---|
[b054fad] | 610 | imcb_error(ic, "Call failed: %s", skype_call_strerror(sd->failurereason)); |
---|
[76eb071] | 611 | sd->call_id = NULL; |
---|
[5adcc65] | 612 | } else if (!strncmp(info, "DURATION ", 9)) { |
---|
| 613 | if (sd->call_duration) |
---|
[48181f0] | 614 | g_free(sd->call_duration); |
---|
| 615 | sd->call_duration = g_strdup(info+9); |
---|
[5adcc65] | 616 | } else if (!strncmp(info, "PARTNER_HANDLE ", 15)) { |
---|
[ecfbc5d] | 617 | info += 15; |
---|
[5adcc65] | 618 | if (sd->call_status) { |
---|
| 619 | switch (sd->call_status) { |
---|
| 620 | case SKYPE_CALL_RINGING: |
---|
| 621 | if (sd->call_out) |
---|
| 622 | imcb_log(ic, "You are currently ringing the user %s.", info); |
---|
| 623 | else { |
---|
| 624 | g_snprintf(buf, 1024, "The user %s is currently ringing you.", info); |
---|
| 625 | skype_call_ask(ic, sd->call_id, buf); |
---|
| 626 | } |
---|
| 627 | break; |
---|
| 628 | case SKYPE_CALL_MISSED: |
---|
| 629 | imcb_log(ic, "You have missed a call from user %s.", info); |
---|
| 630 | break; |
---|
| 631 | case SKYPE_CALL_CANCELLED: |
---|
| 632 | imcb_log(ic, "You cancelled the call to the user %s.", info); |
---|
| 633 | sd->call_status = 0; |
---|
| 634 | sd->call_out = FALSE; |
---|
| 635 | break; |
---|
| 636 | case SKYPE_CALL_REFUSED: |
---|
| 637 | if (sd->call_out) |
---|
| 638 | imcb_log(ic, "The user %s refused the call.", info); |
---|
| 639 | else |
---|
| 640 | imcb_log(ic, "You refused the call from user %s.", info); |
---|
| 641 | sd->call_out = FALSE; |
---|
| 642 | break; |
---|
| 643 | case SKYPE_CALL_FINISHED: |
---|
| 644 | if (sd->call_duration) |
---|
| 645 | imcb_log(ic, "You finished the call to the user %s (duration: %s seconds).", info, sd->call_duration); |
---|
| 646 | else |
---|
| 647 | imcb_log(ic, "You finished the call to the user %s.", info); |
---|
| 648 | sd->call_out = FALSE; |
---|
| 649 | break; |
---|
| 650 | default: |
---|
| 651 | /* Don't be noisy, ignore other statuses for now. */ |
---|
| 652 | break; |
---|
[df9255d] | 653 | } |
---|
| 654 | sd->call_status = 0; |
---|
| 655 | } |
---|
| 656 | } |
---|
| 657 | } |
---|
[5adcc65] | 658 | } else if (!strncmp(line, "FILETRANSFER ", 13)) { |
---|
[df9255d] | 659 | char *id = strchr(line, ' '); |
---|
[5adcc65] | 660 | if (++id) { |
---|
[df9255d] | 661 | char *info = strchr(id, ' '); |
---|
| 662 | *info = '\0'; |
---|
| 663 | info++; |
---|
[5adcc65] | 664 | if (!strcmp(info, "STATUS NEW")) { |
---|
[df9255d] | 665 | g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n", id); |
---|
[5adcc65] | 666 | skype_write(ic, buf); |
---|
[df9255d] | 667 | sd->filetransfer_status = SKYPE_FILETRANSFER_NEW; |
---|
[5adcc65] | 668 | } else if (!strcmp(info, "STATUS FAILED")) { |
---|
[df9255d] | 669 | g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n", id); |
---|
[5adcc65] | 670 | skype_write(ic, buf); |
---|
[df9255d] | 671 | sd->filetransfer_status = SKYPE_FILETRANSFER_FAILED; |
---|
[5adcc65] | 672 | } else if (!strncmp(info, "PARTNER_HANDLE ", 15)) { |
---|
[df9255d] | 673 | info += 15; |
---|
[5adcc65] | 674 | if (sd->filetransfer_status) { |
---|
| 675 | switch (sd->filetransfer_status) { |
---|
| 676 | case SKYPE_FILETRANSFER_NEW: |
---|
| 677 | imcb_log(ic, "The user %s offered a new file for you.", info); |
---|
| 678 | break; |
---|
| 679 | case SKYPE_FILETRANSFER_FAILED: |
---|
| 680 | imcb_log(ic, "Failed to transfer file from user %s.", info); |
---|
| 681 | break; |
---|
[df9255d] | 682 | } |
---|
| 683 | sd->filetransfer_status = 0; |
---|
[bbba374] | 684 | } |
---|
[ecfbc5d] | 685 | } |
---|
| 686 | } |
---|
[5adcc65] | 687 | } else if (!strncmp(line, "CHAT ", 5)) { |
---|
[2d07803] | 688 | char *id = strchr(line, ' '); |
---|
[5adcc65] | 689 | if (++id) { |
---|
[2d07803] | 690 | char *info = strchr(id, ' '); |
---|
[5adcc65] | 691 | if (info) |
---|
[86f2683] | 692 | *info = '\0'; |
---|
[2d07803] | 693 | info++; |
---|
[5652d43] | 694 | /* Remove fake chat if we created one in skype_chat_with() */ |
---|
| 695 | struct groupchat *gc = skype_chat_by_name(ic, ""); |
---|
[5adcc65] | 696 | if (gc) |
---|
[5652d43] | 697 | imcb_chat_free(gc); |
---|
[5adcc65] | 698 | if (!strcmp(info, "STATUS MULTI_SUBSCRIBED")) { |
---|
| 699 | imcb_chat_new(ic, id); |
---|
[f8674db] | 700 | g_snprintf(buf, 1024, "GET CHAT %s ADDER\n", id); |
---|
[a5f4040] | 701 | skype_write(ic, buf); |
---|
[f8674db] | 702 | g_snprintf(buf, 1024, "GET CHAT %s TOPIC\n", id); |
---|
[a5f4040] | 703 | skype_write(ic, buf); |
---|
[5adcc65] | 704 | } else if (!strcmp(info, "STATUS DIALOG") && sd->groupchat_with) { |
---|
| 705 | gc = imcb_chat_new(ic, id); |
---|
[86278cd] | 706 | /* According to the docs this |
---|
| 707 | * is necessary. However it |
---|
| 708 | * does not seem the situation |
---|
| 709 | * and it would open an extra |
---|
| 710 | * window on our client, so |
---|
| 711 | * just leave it out. */ |
---|
| 712 | /*g_snprintf(buf, 1024, "OPEN CHAT %s\n", id); |
---|
[a5f4040] | 713 | skype_write(ic, buf);*/ |
---|
[86278cd] | 714 | g_snprintf(buf, 1024, "%s@skype.com", sd->groupchat_with); |
---|
| 715 | imcb_chat_add_buddy(gc, buf); |
---|
| 716 | imcb_chat_add_buddy(gc, sd->username); |
---|
| 717 | g_free(sd->groupchat_with); |
---|
| 718 | sd->groupchat_with = NULL; |
---|
[f8674db] | 719 | g_snprintf(buf, 1024, "GET CHAT %s ADDER\n", id); |
---|
[a5f4040] | 720 | skype_write(ic, buf); |
---|
[f8674db] | 721 | g_snprintf(buf, 1024, "GET CHAT %s TOPIC\n", id); |
---|
[a5f4040] | 722 | skype_write(ic, buf); |
---|
[5adcc65] | 723 | } else if (!strcmp(info, "STATUS UNSUBSCRIBED")) { |
---|
[5652d43] | 724 | gc = skype_chat_by_name(ic, id); |
---|
[5adcc65] | 725 | if (gc) |
---|
| 726 | gc->data = (void *)FALSE; |
---|
| 727 | } else if (!strncmp(info, "ADDER ", 6)) { |
---|
[f8674db] | 728 | info += 6; |
---|
| 729 | g_free(sd->adder); |
---|
| 730 | sd->adder = g_strdup_printf("%s@skype.com", info); |
---|
[5adcc65] | 731 | } else if (!strncmp(info, "TOPIC ", 6)) { |
---|
[d601f9b] | 732 | info += 6; |
---|
[5652d43] | 733 | gc = skype_chat_by_name(ic, id); |
---|
[5adcc65] | 734 | if (gc && (sd->adder || sd->topic_wait)) { |
---|
| 735 | if (sd->topic_wait) { |
---|
[a5f76a2] | 736 | sd->adder = g_strdup(sd->username); |
---|
| 737 | sd->topic_wait = 0; |
---|
| 738 | } |
---|
| 739 | imcb_chat_topic(gc, sd->adder, info, 0); |
---|
[f8674db] | 740 | g_free(sd->adder); |
---|
| 741 | sd->adder = NULL; |
---|
| 742 | } |
---|
[5adcc65] | 743 | } else if (!strncmp(info, "ACTIVEMEMBERS ", 14)) { |
---|
[72aa7f0] | 744 | info += 14; |
---|
[5652d43] | 745 | gc = skype_chat_by_name(ic, id); |
---|
[ec159f1] | 746 | /* Hack! We set ->data to TRUE |
---|
| 747 | * while we're on the channel |
---|
| 748 | * so that we won't rejoin |
---|
| 749 | * after a /part. */ |
---|
[5adcc65] | 750 | if (gc && !gc->data) { |
---|
[349ee4a] | 751 | char **members = g_strsplit(info, " ", 0); |
---|
| 752 | int i; |
---|
[5adcc65] | 753 | for (i = 0; members[i]; i++) { |
---|
| 754 | if (!strcmp(members[i], sd->username)) |
---|
[349ee4a] | 755 | continue; |
---|
| 756 | g_snprintf(buf, 1024, "%s@skype.com", members[i]); |
---|
[5adcc65] | 757 | if (!g_list_find_custom(gc->in_room, buf, (GCompareFunc)strcmp)) |
---|
[c09d327] | 758 | imcb_chat_add_buddy(gc, buf); |
---|
[349ee4a] | 759 | } |
---|
| 760 | imcb_chat_add_buddy(gc, sd->username); |
---|
| 761 | g_strfreev(members); |
---|
[72aa7f0] | 762 | } |
---|
| 763 | } |
---|
[2d07803] | 764 | } |
---|
[5adcc65] | 765 | } else if (!strncmp(line, "PASSWORD ", 9)) { |
---|
| 766 | if (!strncmp(line+9, "OK", 2)) |
---|
[c7304b2] | 767 | imcb_connected(ic); |
---|
[5adcc65] | 768 | else { |
---|
[c7304b2] | 769 | imcb_error(ic, "Authentication Failed"); |
---|
[5adcc65] | 770 | imc_logout(ic, TRUE); |
---|
[c7304b2] | 771 | } |
---|
[5adcc65] | 772 | } else if (!strncmp(line, "PROFILE PSTN_BALANCE ", 21)) |
---|
[b7d3dff7] | 773 | imcb_log(ic, "SkypeOut balance value is '%s'.", line+21); |
---|
[5adcc65] | 774 | else if (!strncmp(line, "PING", 4)) { |
---|
[6af3e14] | 775 | g_snprintf(buf, 1024, "PONG\n"); |
---|
[a5f4040] | 776 | skype_write(ic, buf); |
---|
[5adcc65] | 777 | } else if (!strncmp(line, "CHATS ", 6)) { |
---|
[5acf9ab] | 778 | char **i; |
---|
| 779 | char **chats = g_strsplit(line + 6, ", ", 0); |
---|
| 780 | |
---|
| 781 | i = chats; |
---|
[5adcc65] | 782 | while (*i) { |
---|
[5acf9ab] | 783 | g_snprintf(buf, 1024, "GET CHAT %s STATUS\n", *i); |
---|
[5adcc65] | 784 | skype_write(ic, buf); |
---|
[5acf9ab] | 785 | g_snprintf(buf, 1024, "GET CHAT %s ACTIVEMEMBERS\n", *i); |
---|
[5adcc65] | 786 | skype_write(ic, buf); |
---|
[5acf9ab] | 787 | i++; |
---|
| 788 | } |
---|
| 789 | g_strfreev(chats); |
---|
| 790 | } |
---|
[9fd4241] | 791 | lineptr++; |
---|
| 792 | } |
---|
| 793 | g_strfreev(lines); |
---|
[5adcc65] | 794 | } else if (st == 0 || (st < 0 && !sockerr_again())) { |
---|
| 795 | closesocket(sd->fd); |
---|
[1323e36] | 796 | sd->fd = -1; |
---|
| 797 | |
---|
[5adcc65] | 798 | imcb_error(ic, "Error while reading from server"); |
---|
| 799 | imc_logout(ic, TRUE); |
---|
[1323e36] | 800 | return FALSE; |
---|
| 801 | } |
---|
| 802 | return TRUE; |
---|
| 803 | } |
---|
| 804 | |
---|
[5adcc65] | 805 | gboolean skype_start_stream(struct im_connection *ic) |
---|
[f06e3ac] | 806 | { |
---|
[1323e36] | 807 | struct skype_data *sd = ic->proto_data; |
---|
[f06e3ac] | 808 | char *buf; |
---|
| 809 | int st; |
---|
| 810 | |
---|
[5adcc65] | 811 | if (!sd) |
---|
[1fb89e3] | 812 | return FALSE; |
---|
| 813 | |
---|
[5adcc65] | 814 | if (sd->bfd <= 0) |
---|
[8c09bb3] | 815 | sd->bfd = b_input_add(sd->fd, GAIM_INPUT_READ, |
---|
| 816 | skype_read_callback, ic); |
---|
[1323e36] | 817 | |
---|
[a0b206b] | 818 | /* Log in */ |
---|
| 819 | buf = g_strdup_printf("USERNAME %s\n", ic->acc->user); |
---|
[5adcc65] | 820 | st = skype_write(ic, buf); |
---|
[a0b206b] | 821 | g_free(buf); |
---|
| 822 | buf = g_strdup_printf("PASSWORD %s\n", ic->acc->pass); |
---|
[5adcc65] | 823 | st = skype_write(ic, buf); |
---|
[a0b206b] | 824 | g_free(buf); |
---|
| 825 | |
---|
[7daec06] | 826 | /* This will download all buddies. */ |
---|
[9fd4241] | 827 | buf = g_strdup_printf("SEARCH FRIENDS\n"); |
---|
[5adcc65] | 828 | st = skype_write(ic, buf); |
---|
[f06e3ac] | 829 | g_free(buf); |
---|
[348a3a2] | 830 | buf = g_strdup_printf("SET USERSTATUS ONLINE\n"); |
---|
[5adcc65] | 831 | skype_write(ic, buf); |
---|
[348a3a2] | 832 | g_free(buf); |
---|
[5acf9ab] | 833 | |
---|
| 834 | /* Auto join to bookmarked chats if requested.*/ |
---|
| 835 | if (set_getbool(&ic->acc->set, "auto_join")) { |
---|
| 836 | buf = g_strdup_printf("SEARCH BOOKMARKEDCHATS\n"); |
---|
[5adcc65] | 837 | skype_write(ic, buf); |
---|
[5acf9ab] | 838 | g_free(buf); |
---|
| 839 | } |
---|
[f06e3ac] | 840 | return st; |
---|
| 841 | } |
---|
| 842 | |
---|
[5adcc65] | 843 | gboolean skype_connected(gpointer data, void *source, b_input_condition cond) |
---|
[f06e3ac] | 844 | { |
---|
| 845 | struct im_connection *ic = data; |
---|
[c7304b2] | 846 | struct skype_data *sd = ic->proto_data; |
---|
[5adcc65] | 847 | if (!source) { |
---|
[c7304b2] | 848 | sd->ssl = NULL; |
---|
[5adcc65] | 849 | imcb_error(ic, "Could not connect to server"); |
---|
| 850 | imc_logout(ic, TRUE); |
---|
[c7304b2] | 851 | return FALSE; |
---|
| 852 | } |
---|
[5adcc65] | 853 | imcb_log(ic, "Connected to server, logging in"); |
---|
[f06e3ac] | 854 | return skype_start_stream(ic); |
---|
| 855 | } |
---|
| 856 | |
---|
[5adcc65] | 857 | static void skype_login(account_t *acc) |
---|
[f06e3ac] | 858 | { |
---|
[5adcc65] | 859 | struct im_connection *ic = imcb_new(acc); |
---|
| 860 | struct skype_data *sd = g_new0(struct skype_data, 1); |
---|
[f06e3ac] | 861 | |
---|
| 862 | ic->proto_data = sd; |
---|
| 863 | |
---|
[5adcc65] | 864 | imcb_log(ic, "Connecting"); |
---|
[8c09bb3] | 865 | sd->ssl = ssl_connect(set_getstr(&acc->set, "server"), |
---|
| 866 | set_getint(&acc->set, "port"), skype_connected, ic); |
---|
[5adcc65] | 867 | sd->fd = sd->ssl ? ssl_getfd(sd->ssl) : -1; |
---|
| 868 | sd->username = g_strdup(acc->user); |
---|
[f06e3ac] | 869 | |
---|
| 870 | sd->ic = ic; |
---|
[08a355b] | 871 | |
---|
| 872 | if (set_getbool(&acc->set, "skypeconsole")) |
---|
| 873 | imcb_add_buddy(ic, "skypeconsole", NULL); |
---|
[f06e3ac] | 874 | } |
---|
| 875 | |
---|
[5adcc65] | 876 | static void skype_logout(struct im_connection *ic) |
---|
[f06e3ac] | 877 | { |
---|
| 878 | struct skype_data *sd = ic->proto_data; |
---|
[98bca36] | 879 | char *buf; |
---|
| 880 | |
---|
| 881 | buf = g_strdup_printf("SET USERSTATUS OFFLINE\n"); |
---|
[5adcc65] | 882 | skype_write(ic, buf); |
---|
[98bca36] | 883 | g_free(buf); |
---|
| 884 | |
---|
[a3d6427] | 885 | g_free(sd->username); |
---|
[7613670] | 886 | g_free(sd->handle); |
---|
[f06e3ac] | 887 | g_free(sd); |
---|
[98bca36] | 888 | ic->proto_data = NULL; |
---|
[f06e3ac] | 889 | } |
---|
| 890 | |
---|
[8c09bb3] | 891 | static int skype_buddy_msg(struct im_connection *ic, char *who, char *message, |
---|
| 892 | int flags) |
---|
[93ece66] | 893 | { |
---|
[77c1abe] | 894 | char *buf, *ptr, *nick; |
---|
[93ece66] | 895 | int st; |
---|
| 896 | |
---|
[cbec0d6] | 897 | nick = g_strdup(who); |
---|
[77c1abe] | 898 | ptr = strchr(nick, '@'); |
---|
[5adcc65] | 899 | if (ptr) |
---|
[0bb1b7f] | 900 | *ptr = '\0'; |
---|
[93ece66] | 901 | |
---|
[08a355b] | 902 | if (!strncmp(who, "skypeconsole", 12)) |
---|
| 903 | buf = g_strdup_printf("%s\n", message); |
---|
| 904 | else |
---|
| 905 | buf = g_strdup_printf("MESSAGE %s %s\n", nick, message); |
---|
[77c1abe] | 906 | g_free(nick); |
---|
[5adcc65] | 907 | st = skype_write(ic, buf); |
---|
[93ece66] | 908 | g_free(buf); |
---|
| 909 | |
---|
| 910 | return st; |
---|
| 911 | } |
---|
| 912 | |
---|
[5adcc65] | 913 | const struct skype_away_state *skype_away_state_by_name(char *name) |
---|
[23411c6] | 914 | { |
---|
| 915 | int i; |
---|
| 916 | |
---|
[5adcc65] | 917 | for (i = 0; skype_away_state_list[i].full_name; i++) |
---|
| 918 | if (g_strcasecmp(skype_away_state_list[i].full_name, name) == 0) |
---|
| 919 | return skype_away_state_list + i; |
---|
[23411c6] | 920 | |
---|
| 921 | return NULL; |
---|
| 922 | } |
---|
| 923 | |
---|
[8c09bb3] | 924 | static void skype_set_away(struct im_connection *ic, char *state_txt, |
---|
| 925 | char *message) |
---|
[f06e3ac] | 926 | { |
---|
[23411c6] | 927 | const struct skype_away_state *state; |
---|
| 928 | char *buf; |
---|
| 929 | |
---|
[5adcc65] | 930 | if (strcmp(state_txt, GAIM_AWAY_CUSTOM) == 0) |
---|
| 931 | state = skype_away_state_by_name("Away"); |
---|
[23411c6] | 932 | else |
---|
[5adcc65] | 933 | state = skype_away_state_by_name(state_txt); |
---|
[23411c6] | 934 | buf = g_strdup_printf("SET USERSTATUS %s\n", state->code); |
---|
[5adcc65] | 935 | skype_write(ic, buf); |
---|
[23411c6] | 936 | g_free(buf); |
---|
[f06e3ac] | 937 | } |
---|
| 938 | |
---|
[5adcc65] | 939 | static GList *skype_away_states(struct im_connection *ic) |
---|
[f06e3ac] | 940 | { |
---|
[5adcc65] | 941 | static GList *l; |
---|
[adce2de] | 942 | int i; |
---|
[5adcc65] | 943 | |
---|
| 944 | if (l == NULL) |
---|
| 945 | for (i = 0; skype_away_state_list[i].full_name; i++) |
---|
[8c09bb3] | 946 | l = g_list_append(l, |
---|
| 947 | (void *)skype_away_state_list[i].full_name); |
---|
[5adcc65] | 948 | |
---|
[f06e3ac] | 949 | return l; |
---|
| 950 | } |
---|
| 951 | |
---|
[5adcc65] | 952 | static char *skype_set_display_name(set_t *set, char *value) |
---|
[93dffea] | 953 | { |
---|
| 954 | account_t *acc = set->data; |
---|
| 955 | struct im_connection *ic = acc->ic; |
---|
| 956 | char *buf; |
---|
| 957 | |
---|
[fcef6e6] | 958 | buf = g_strdup_printf("SET PROFILE FULLNAME %s", value); |
---|
[5adcc65] | 959 | skype_write(ic, buf); |
---|
[93dffea] | 960 | g_free(buf); |
---|
[5adcc65] | 961 | return value; |
---|
[93dffea] | 962 | } |
---|
| 963 | |
---|
[5adcc65] | 964 | static char *skype_set_balance(set_t *set, char *value) |
---|
[2af671a] | 965 | { |
---|
| 966 | account_t *acc = set->data; |
---|
| 967 | struct im_connection *ic = acc->ic; |
---|
| 968 | char *buf; |
---|
| 969 | |
---|
| 970 | buf = g_strdup_printf("GET PROFILE PSTN_BALANCE"); |
---|
[5adcc65] | 971 | skype_write(ic, buf); |
---|
[2af671a] | 972 | g_free(buf); |
---|
[5adcc65] | 973 | return value; |
---|
[2af671a] | 974 | } |
---|
| 975 | |
---|
[5adcc65] | 976 | static char *skype_set_call(set_t *set, char *value) |
---|
[b68b023] | 977 | { |
---|
| 978 | account_t *acc = set->data; |
---|
| 979 | struct im_connection *ic = acc->ic; |
---|
[2eb4b1f] | 980 | struct skype_data *sd = ic->proto_data; |
---|
[b68b023] | 981 | char *nick, *ptr, *buf; |
---|
| 982 | |
---|
[5adcc65] | 983 | if (value) { |
---|
[2eb4b1f] | 984 | user_t *u = user_find(acc->irc, value); |
---|
| 985 | /* We are starting a call */ |
---|
[5adcc65] | 986 | if (!u) |
---|
[51dc72d] | 987 | nick = g_strdup(value); |
---|
[a317ba6] | 988 | else |
---|
| 989 | nick = g_strdup(u->handle); |
---|
[2eb4b1f] | 990 | ptr = strchr(nick, '@'); |
---|
[5adcc65] | 991 | if (ptr) |
---|
[2eb4b1f] | 992 | *ptr = '\0'; |
---|
| 993 | |
---|
| 994 | buf = g_strdup_printf("CALL %s", nick); |
---|
[5adcc65] | 995 | skype_write(ic, buf); |
---|
[2eb4b1f] | 996 | g_free(buf); |
---|
| 997 | g_free(nick); |
---|
[5adcc65] | 998 | } else { |
---|
[2eb4b1f] | 999 | /* We are ending a call */ |
---|
[5adcc65] | 1000 | if (sd->call_id) { |
---|
[8c09bb3] | 1001 | buf = g_strdup_printf("SET CALL %s STATUS FINISHED", |
---|
| 1002 | sd->call_id); |
---|
[5adcc65] | 1003 | skype_write(ic, buf); |
---|
[2eb4b1f] | 1004 | g_free(buf); |
---|
[9fd7202] | 1005 | g_free(sd->call_id); |
---|
| 1006 | sd->call_id = NULL; |
---|
[5adcc65] | 1007 | } else |
---|
[2eb4b1f] | 1008 | imcb_error(ic, "There are no active calls currently."); |
---|
[b68b023] | 1009 | } |
---|
[5adcc65] | 1010 | return value; |
---|
[b68b023] | 1011 | } |
---|
| 1012 | |
---|
[5adcc65] | 1013 | static void skype_add_buddy(struct im_connection *ic, char *who, char *group) |
---|
[f06e3ac] | 1014 | { |
---|
[6627d92] | 1015 | char *buf, *nick, *ptr; |
---|
| 1016 | |
---|
[cbec0d6] | 1017 | nick = g_strdup(who); |
---|
[6627d92] | 1018 | ptr = strchr(nick, '@'); |
---|
[5adcc65] | 1019 | if (ptr) |
---|
[6627d92] | 1020 | *ptr = '\0'; |
---|
[8c09bb3] | 1021 | buf = g_strdup_printf("SET USER %s BUDDYSTATUS 2 Please authorize me\n", |
---|
| 1022 | nick); |
---|
[5adcc65] | 1023 | skype_write(ic, buf); |
---|
[6627d92] | 1024 | g_free(nick); |
---|
[f06e3ac] | 1025 | } |
---|
| 1026 | |
---|
[5adcc65] | 1027 | static void skype_remove_buddy(struct im_connection *ic, char *who, char *group) |
---|
[f06e3ac] | 1028 | { |
---|
[6627d92] | 1029 | char *buf, *nick, *ptr; |
---|
| 1030 | |
---|
[cbec0d6] | 1031 | nick = g_strdup(who); |
---|
[6627d92] | 1032 | ptr = strchr(nick, '@'); |
---|
[5adcc65] | 1033 | if (ptr) |
---|
[6627d92] | 1034 | *ptr = '\0'; |
---|
| 1035 | buf = g_strdup_printf("SET USER %s BUDDYSTATUS 1\n", nick); |
---|
[5adcc65] | 1036 | skype_write(ic, buf); |
---|
[6627d92] | 1037 | g_free(nick); |
---|
[f06e3ac] | 1038 | } |
---|
| 1039 | |
---|
[5adcc65] | 1040 | void skype_chat_msg(struct groupchat *gc, char *message, int flags) |
---|
[66c9558] | 1041 | { |
---|
[79e20f9] | 1042 | struct im_connection *ic = gc->ic; |
---|
| 1043 | char *buf; |
---|
| 1044 | buf = g_strdup_printf("CHATMESSAGE %s %s\n", gc->title, message); |
---|
[5adcc65] | 1045 | skype_write(ic, buf); |
---|
[79e20f9] | 1046 | g_free(buf); |
---|
[66c9558] | 1047 | } |
---|
| 1048 | |
---|
[5adcc65] | 1049 | void skype_chat_leave(struct groupchat *gc) |
---|
[b01dc6c] | 1050 | { |
---|
| 1051 | struct im_connection *ic = gc->ic; |
---|
| 1052 | char *buf; |
---|
| 1053 | buf = g_strdup_printf("ALTER CHAT %s LEAVE\n", gc->title); |
---|
[5adcc65] | 1054 | skype_write(ic, buf); |
---|
[b01dc6c] | 1055 | g_free(buf); |
---|
[5adcc65] | 1056 | gc->data = (void *)TRUE; |
---|
[760319d] | 1057 | } |
---|
| 1058 | |
---|
| 1059 | void skype_chat_invite(struct groupchat *gc, char *who, char *message) |
---|
| 1060 | { |
---|
| 1061 | struct im_connection *ic = gc->ic; |
---|
| 1062 | char *buf, *ptr, *nick; |
---|
| 1063 | nick = g_strdup(message); |
---|
| 1064 | ptr = strchr(nick, '@'); |
---|
[5adcc65] | 1065 | if (ptr) |
---|
[760319d] | 1066 | *ptr = '\0'; |
---|
| 1067 | buf = g_strdup_printf("ALTER CHAT %s ADDMEMBERS %s\n", gc->title, nick); |
---|
[5adcc65] | 1068 | skype_write(ic, buf); |
---|
[760319d] | 1069 | g_free(buf); |
---|
| 1070 | g_free(nick); |
---|
[b01dc6c] | 1071 | } |
---|
| 1072 | |
---|
[09e2a69] | 1073 | void skype_chat_topic(struct groupchat *gc, char *message) |
---|
| 1074 | { |
---|
| 1075 | struct im_connection *ic = gc->ic; |
---|
[a5f76a2] | 1076 | struct skype_data *sd = ic->proto_data; |
---|
[09e2a69] | 1077 | char *buf; |
---|
[8c09bb3] | 1078 | buf = g_strdup_printf("ALTER CHAT %s SETTOPIC %s\n", |
---|
| 1079 | gc->title, message); |
---|
[5adcc65] | 1080 | skype_write(ic, buf); |
---|
[09e2a69] | 1081 | g_free(buf); |
---|
[a5f76a2] | 1082 | sd->topic_wait = 1; |
---|
[09e2a69] | 1083 | } |
---|
| 1084 | |
---|
[86278cd] | 1085 | struct groupchat *skype_chat_with(struct im_connection *ic, char *who) |
---|
| 1086 | { |
---|
| 1087 | struct skype_data *sd = ic->proto_data; |
---|
| 1088 | char *ptr, *nick, *buf; |
---|
| 1089 | nick = g_strdup(who); |
---|
| 1090 | ptr = strchr(nick, '@'); |
---|
[5adcc65] | 1091 | if (ptr) |
---|
[86278cd] | 1092 | *ptr = '\0'; |
---|
| 1093 | buf = g_strdup_printf("CHAT CREATE %s\n", nick); |
---|
[a5f4040] | 1094 | skype_write(ic, buf); |
---|
[86278cd] | 1095 | g_free(buf); |
---|
| 1096 | sd->groupchat_with = g_strdup(nick); |
---|
| 1097 | g_free(nick); |
---|
[5652d43] | 1098 | /* We create a fake chat for now. We will replace it with a real one in |
---|
| 1099 | * the real callback. */ |
---|
[5adcc65] | 1100 | return imcb_chat_new(ic, ""); |
---|
[86278cd] | 1101 | } |
---|
| 1102 | |
---|
[67454bd] | 1103 | static void skype_get_info(struct im_connection *ic, char *who) |
---|
| 1104 | { |
---|
| 1105 | char *ptr, *nick, *buf; |
---|
| 1106 | nick = g_strdup(who); |
---|
| 1107 | ptr = strchr(nick, '@'); |
---|
[5adcc65] | 1108 | if (ptr) |
---|
[67454bd] | 1109 | *ptr = '\0'; |
---|
| 1110 | buf = g_strdup_printf("GET USER %s FULLNAME\n", nick); |
---|
[a5f4040] | 1111 | skype_write(ic, buf); |
---|
[67454bd] | 1112 | g_free(buf); |
---|
| 1113 | buf = g_strdup_printf("GET USER %s PHONE_HOME\n", nick); |
---|
[a5f4040] | 1114 | skype_write(ic, buf); |
---|
[67454bd] | 1115 | g_free(buf); |
---|
| 1116 | buf = g_strdup_printf("GET USER %s PHONE_OFFICE\n", nick); |
---|
[a5f4040] | 1117 | skype_write(ic, buf); |
---|
[67454bd] | 1118 | g_free(buf); |
---|
| 1119 | buf = g_strdup_printf("GET USER %s PHONE_MOBILE\n", nick); |
---|
[a5f4040] | 1120 | skype_write(ic, buf); |
---|
[67454bd] | 1121 | g_free(buf); |
---|
| 1122 | buf = g_strdup_printf("GET USER %s NROF_AUTHED_BUDDIES\n", nick); |
---|
[a5f4040] | 1123 | skype_write(ic, buf); |
---|
[67454bd] | 1124 | g_free(buf); |
---|
| 1125 | buf = g_strdup_printf("GET USER %s TIMEZONE\n", nick); |
---|
[a5f4040] | 1126 | skype_write(ic, buf); |
---|
[67454bd] | 1127 | g_free(buf); |
---|
| 1128 | buf = g_strdup_printf("GET USER %s LASTONLINETIMESTAMP\n", nick); |
---|
[a5f4040] | 1129 | skype_write(ic, buf); |
---|
[67454bd] | 1130 | g_free(buf); |
---|
| 1131 | buf = g_strdup_printf("GET USER %s BIRTHDAY\n", nick); |
---|
[a5f4040] | 1132 | skype_write(ic, buf); |
---|
[67454bd] | 1133 | g_free(buf); |
---|
| 1134 | buf = g_strdup_printf("GET USER %s SEX\n", nick); |
---|
[a5f4040] | 1135 | skype_write(ic, buf); |
---|
[67454bd] | 1136 | g_free(buf); |
---|
| 1137 | buf = g_strdup_printf("GET USER %s LANGUAGE\n", nick); |
---|
[a5f4040] | 1138 | skype_write(ic, buf); |
---|
[67454bd] | 1139 | g_free(buf); |
---|
| 1140 | buf = g_strdup_printf("GET USER %s COUNTRY\n", nick); |
---|
[a5f4040] | 1141 | skype_write(ic, buf); |
---|
[67454bd] | 1142 | g_free(buf); |
---|
| 1143 | buf = g_strdup_printf("GET USER %s PROVINCE\n", nick); |
---|
[a5f4040] | 1144 | skype_write(ic, buf); |
---|
[67454bd] | 1145 | g_free(buf); |
---|
| 1146 | buf = g_strdup_printf("GET USER %s CITY\n", nick); |
---|
[a5f4040] | 1147 | skype_write(ic, buf); |
---|
[67454bd] | 1148 | g_free(buf); |
---|
| 1149 | buf = g_strdup_printf("GET USER %s HOMEPAGE\n", nick); |
---|
[a5f4040] | 1150 | skype_write(ic, buf); |
---|
[67454bd] | 1151 | g_free(buf); |
---|
| 1152 | buf = g_strdup_printf("GET USER %s ABOUT\n", nick); |
---|
[a5f4040] | 1153 | skype_write(ic, buf); |
---|
[67454bd] | 1154 | g_free(buf); |
---|
| 1155 | } |
---|
| 1156 | |
---|
[5adcc65] | 1157 | static void skype_set_my_name(struct im_connection *ic, char *info) |
---|
[93dffea] | 1158 | { |
---|
[5adcc65] | 1159 | skype_set_display_name(set_find(&ic->acc->set, "display_name"), info); |
---|
[93dffea] | 1160 | } |
---|
| 1161 | |
---|
[5adcc65] | 1162 | static void skype_init(account_t *acc) |
---|
[93dffea] | 1163 | { |
---|
| 1164 | set_t *s; |
---|
| 1165 | |
---|
[8c09bb3] | 1166 | s = set_add(&acc->set, "server", SKYPE_DEFAULT_SERVER, set_eval_account, |
---|
| 1167 | acc); |
---|
[93dffea] | 1168 | s->flags |= ACC_SET_OFFLINE_ONLY; |
---|
| 1169 | |
---|
[5adcc65] | 1170 | s = set_add(&acc->set, "port", SKYPE_DEFAULT_PORT, set_eval_int, acc); |
---|
[93dffea] | 1171 | s->flags |= ACC_SET_OFFLINE_ONLY; |
---|
| 1172 | |
---|
[8c09bb3] | 1173 | s = set_add(&acc->set, "display_name", NULL, skype_set_display_name, |
---|
| 1174 | acc); |
---|
[93dffea] | 1175 | s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY; |
---|
[b68b023] | 1176 | |
---|
[5adcc65] | 1177 | s = set_add(&acc->set, "call", NULL, skype_set_call, acc); |
---|
[b68b023] | 1178 | s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY; |
---|
[2af671a] | 1179 | |
---|
[5adcc65] | 1180 | s = set_add(&acc->set, "balance", NULL, skype_set_balance, acc); |
---|
[2af671a] | 1181 | s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY; |
---|
[bd417a1] | 1182 | |
---|
[5adcc65] | 1183 | s = set_add(&acc->set, "skypeout_offline", "true", set_eval_bool, acc); |
---|
[08a355b] | 1184 | |
---|
[5adcc65] | 1185 | s = set_add(&acc->set, "skypeconsole", "false", set_eval_bool, acc); |
---|
[08a355b] | 1186 | s->flags |= ACC_SET_OFFLINE_ONLY; |
---|
[5acf9ab] | 1187 | |
---|
[8c09bb3] | 1188 | s = set_add(&acc->set, "skypeconsole_receive", "false", set_eval_bool, |
---|
| 1189 | acc); |
---|
[b820226] | 1190 | s->flags |= ACC_SET_OFFLINE_ONLY; |
---|
| 1191 | |
---|
[5adcc65] | 1192 | s = set_add(&acc->set, "auto_join", "false", set_eval_bool, acc); |
---|
[5acf9ab] | 1193 | s->flags |= ACC_SET_OFFLINE_ONLY; |
---|
[93dffea] | 1194 | } |
---|
| 1195 | |
---|
[f06e3ac] | 1196 | void init_plugin(void) |
---|
| 1197 | { |
---|
[5adcc65] | 1198 | struct prpl *ret = g_new0(struct prpl, 1); |
---|
[f06e3ac] | 1199 | |
---|
| 1200 | ret->name = "skype"; |
---|
| 1201 | ret->login = skype_login; |
---|
| 1202 | ret->init = skype_init; |
---|
| 1203 | ret->logout = skype_logout; |
---|
[93ece66] | 1204 | ret->buddy_msg = skype_buddy_msg; |
---|
[67454bd] | 1205 | ret->get_info = skype_get_info; |
---|
[93dffea] | 1206 | ret->set_my_name = skype_set_my_name; |
---|
[f06e3ac] | 1207 | ret->away_states = skype_away_states; |
---|
[7daec06] | 1208 | ret->set_away = skype_set_away; |
---|
[f06e3ac] | 1209 | ret->add_buddy = skype_add_buddy; |
---|
| 1210 | ret->remove_buddy = skype_remove_buddy; |
---|
[66c9558] | 1211 | ret->chat_msg = skype_chat_msg; |
---|
[b01dc6c] | 1212 | ret->chat_leave = skype_chat_leave; |
---|
[760319d] | 1213 | ret->chat_invite = skype_chat_invite; |
---|
[86278cd] | 1214 | ret->chat_with = skype_chat_with; |
---|
[f06e3ac] | 1215 | ret->handle_cmp = g_strcasecmp; |
---|
[09e2a69] | 1216 | ret->chat_topic = skype_chat_topic; |
---|
[5adcc65] | 1217 | register_protocol(ret); |
---|
[f06e3ac] | 1218 | } |
---|