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