[7daec06] | 1 | /* |
---|
| 2 | * skype.c - Skype plugin for BitlBee |
---|
[5adcc65] | 3 | * |
---|
[9ec6b36] | 4 | * Copyright (c) 2007-2013 by Miklos Vajna <vmiklos@vmiklos.hu> |
---|
[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> |
---|
[ff18fc1] | 25 | #include <stdio.h> |
---|
[f06e3ac] | 26 | #include <bitlbee.h> |
---|
[7f41495] | 27 | #include <ssl_client.h> |
---|
[f06e3ac] | 28 | |
---|
[f5aedd91] | 29 | #define SKYPE_DEFAULT_SERVER "localhost" |
---|
[4bbd9db] | 30 | #define SKYPE_DEFAULT_PORT "2727" |
---|
[c213d6b] | 31 | #define IRC_LINE_SIZE 1024 |
---|
[ff436ba] | 32 | #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) |
---|
[f06e3ac] | 33 | |
---|
[bbba374] | 34 | /* |
---|
| 35 | * Enumerations |
---|
| 36 | */ |
---|
| 37 | |
---|
[359f4d9] | 38 | enum { |
---|
[df9255d] | 39 | SKYPE_CALL_RINGING = 1, |
---|
[9db0234] | 40 | SKYPE_CALL_MISSED, |
---|
[2eb4b1f] | 41 | SKYPE_CALL_CANCELLED, |
---|
[acd9478] | 42 | SKYPE_CALL_FINISHED, |
---|
[d87daf3] | 43 | SKYPE_CALL_REFUSED |
---|
[5365f84] | 44 | }; |
---|
[bbba374] | 45 | |
---|
[359f4d9] | 46 | enum { |
---|
[df9255d] | 47 | SKYPE_FILETRANSFER_NEW = 1, |
---|
[b2dc873] | 48 | SKYPE_FILETRANSFER_TRANSFERRING, |
---|
| 49 | SKYPE_FILETRANSFER_COMPLETED, |
---|
[df9255d] | 50 | SKYPE_FILETRANSFER_FAILED |
---|
[5365f84] | 51 | }; |
---|
[df9255d] | 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; |
---|
[b2dc873] | 85 | /* Path of the file being transferred. */ |
---|
| 86 | char *filetransfer_path; |
---|
[86278cd] | 87 | /* Using /j #nick we want to have a groupchat with two people. Usually |
---|
| 88 | * not (default). */ |
---|
[5adcc65] | 89 | char *groupchat_with; |
---|
[f8674db] | 90 | /* The user who invited us to the chat. */ |
---|
[5adcc65] | 91 | char *adder; |
---|
[a5f76a2] | 92 | /* If we are waiting for a confirmation about we changed the topic. */ |
---|
| 93 | int topic_wait; |
---|
[67454bd] | 94 | /* These are used by the info command. */ |
---|
| 95 | char *info_fullname; |
---|
| 96 | char *info_phonehome; |
---|
| 97 | char *info_phoneoffice; |
---|
| 98 | char *info_phonemobile; |
---|
| 99 | char *info_nrbuddies; |
---|
| 100 | char *info_tz; |
---|
| 101 | char *info_seen; |
---|
| 102 | char *info_birthday; |
---|
| 103 | char *info_sex; |
---|
| 104 | char *info_language; |
---|
| 105 | char *info_country; |
---|
| 106 | char *info_province; |
---|
| 107 | char *info_city; |
---|
| 108 | char *info_homepage; |
---|
| 109 | char *info_about; |
---|
[b054fad] | 110 | /* When a call fails, we get the reason and later we get the failure |
---|
| 111 | * event, so store the failure code here till then */ |
---|
| 112 | int failurereason; |
---|
[d9ce18c] | 113 | /* If this is just an update of an already received message. */ |
---|
| 114 | int is_edit; |
---|
[89d6845] | 115 | /* List of struct skype_group* */ |
---|
| 116 | GList *groups; |
---|
[46641bf] | 117 | /* Pending user which has to be added to the next group which is |
---|
| 118 | * created. */ |
---|
| 119 | char *pending_user; |
---|
[f06e3ac] | 120 | }; |
---|
| 121 | |
---|
[5adcc65] | 122 | struct skype_away_state { |
---|
[adce2de] | 123 | char *code; |
---|
| 124 | char *full_name; |
---|
| 125 | }; |
---|
| 126 | |
---|
[5adcc65] | 127 | struct skype_buddy_ask_data { |
---|
[7daec06] | 128 | struct im_connection *ic; |
---|
[e0074cb] | 129 | /* This is also used for call IDs for simplicity */ |
---|
[7daec06] | 130 | char *handle; |
---|
| 131 | }; |
---|
| 132 | |
---|
[89d6845] | 133 | struct skype_group { |
---|
| 134 | int id; |
---|
| 135 | char *name; |
---|
| 136 | GList *users; |
---|
| 137 | }; |
---|
| 138 | |
---|
[7daec06] | 139 | /* |
---|
| 140 | * Tables |
---|
| 141 | */ |
---|
| 142 | |
---|
[5adcc65] | 143 | const struct skype_away_state skype_away_state_list[] = { |
---|
[bc744df] | 144 | { "AWAY", "Away" }, |
---|
| 145 | { "NA", "Not available" }, |
---|
| 146 | { "DND", "Do Not Disturb" }, |
---|
| 147 | { "INVISIBLE", "Invisible" }, |
---|
| 148 | { "OFFLINE", "Offline" }, |
---|
[4b740c2] | 149 | { "SKYPEME", "Skype Me" }, |
---|
| 150 | { "ONLINE", "Online" }, |
---|
[23411c6] | 151 | { NULL, NULL} |
---|
[adce2de] | 152 | }; |
---|
| 153 | |
---|
[7daec06] | 154 | /* |
---|
| 155 | * Functions |
---|
| 156 | */ |
---|
[d3cbd17] | 157 | |
---|
[7c300bb] | 158 | int skype_write(struct im_connection *ic, char *buf, int len) |
---|
[f06e3ac] | 159 | { |
---|
| 160 | struct skype_data *sd = ic->proto_data; |
---|
[1fb89e3] | 161 | struct pollfd pfd[1]; |
---|
| 162 | |
---|
[e8e2892] | 163 | if (!sd->ssl) |
---|
| 164 | return FALSE; |
---|
| 165 | |
---|
[1fb89e3] | 166 | pfd[0].fd = sd->fd; |
---|
| 167 | pfd[0].events = POLLOUT; |
---|
[f06e3ac] | 168 | |
---|
[7daec06] | 169 | /* This poll is necessary or we'll get a SIGPIPE when we write() to |
---|
| 170 | * sd->fd. */ |
---|
[1fb89e3] | 171 | poll(pfd, 1, 1000); |
---|
[5adcc65] | 172 | if (pfd[0].revents & POLLHUP) { |
---|
| 173 | imc_logout(ic, TRUE); |
---|
[1fb89e3] | 174 | return FALSE; |
---|
| 175 | } |
---|
[5adcc65] | 176 | ssl_write(sd->ssl, buf, len); |
---|
[f06e3ac] | 177 | |
---|
[9fd4241] | 178 | return TRUE; |
---|
[f06e3ac] | 179 | } |
---|
| 180 | |
---|
[1f4fc80] | 181 | int skype_printf(struct im_connection *ic, char *fmt, ...) |
---|
| 182 | { |
---|
| 183 | va_list args; |
---|
| 184 | char str[IRC_LINE_SIZE]; |
---|
[5d9db76] | 185 | |
---|
[1f4fc80] | 186 | va_start(args, fmt); |
---|
| 187 | vsnprintf(str, IRC_LINE_SIZE, fmt, args); |
---|
| 188 | va_end(args); |
---|
| 189 | |
---|
[7c300bb] | 190 | return skype_write(ic, str, strlen(str)); |
---|
[1f4fc80] | 191 | } |
---|
| 192 | |
---|
[5adcc65] | 193 | static void skype_buddy_ask_yes(void *data) |
---|
[d3cbd17] | 194 | { |
---|
[039116a] | 195 | struct skype_buddy_ask_data *bla = data; |
---|
[1f4fc80] | 196 | skype_printf(bla->ic, "SET USER %s ISAUTHORIZED TRUE", |
---|
[8c09bb3] | 197 | bla->handle); |
---|
[d3cbd17] | 198 | g_free(bla->handle); |
---|
| 199 | g_free(bla); |
---|
| 200 | } |
---|
| 201 | |
---|
[5adcc65] | 202 | static void skype_buddy_ask_no(void *data) |
---|
[d3cbd17] | 203 | { |
---|
[039116a] | 204 | struct skype_buddy_ask_data *bla = data; |
---|
[1f4fc80] | 205 | skype_printf(bla->ic, "SET USER %s ISAUTHORIZED FALSE", |
---|
[8c09bb3] | 206 | bla->handle); |
---|
[d3cbd17] | 207 | g_free(bla->handle); |
---|
| 208 | g_free(bla); |
---|
| 209 | } |
---|
| 210 | |
---|
[5adcc65] | 211 | void skype_buddy_ask(struct im_connection *ic, char *handle, char *message) |
---|
[d3cbd17] | 212 | { |
---|
[8c09bb3] | 213 | struct skype_buddy_ask_data *bla = g_new0(struct skype_buddy_ask_data, |
---|
| 214 | 1); |
---|
[d3cbd17] | 215 | char *buf; |
---|
| 216 | |
---|
| 217 | bla->ic = ic; |
---|
| 218 | bla->handle = g_strdup(handle); |
---|
| 219 | |
---|
[e1d6b38] | 220 | buf = g_strdup_printf("The user %s wants to add you to his/her buddy list, saying: '%s'.", handle, message); |
---|
[5adcc65] | 221 | imcb_ask(ic, buf, bla, skype_buddy_ask_yes, skype_buddy_ask_no); |
---|
| 222 | g_free(buf); |
---|
[d3cbd17] | 223 | } |
---|
| 224 | |
---|
[5adcc65] | 225 | static void skype_call_ask_yes(void *data) |
---|
[e0074cb] | 226 | { |
---|
[039116a] | 227 | struct skype_buddy_ask_data *bla = data; |
---|
[1f4fc80] | 228 | skype_printf(bla->ic, "SET CALL %s STATUS INPROGRESS", |
---|
[8c09bb3] | 229 | bla->handle); |
---|
[e0074cb] | 230 | g_free(bla->handle); |
---|
| 231 | g_free(bla); |
---|
| 232 | } |
---|
| 233 | |
---|
[5adcc65] | 234 | static void skype_call_ask_no(void *data) |
---|
[e0074cb] | 235 | { |
---|
[039116a] | 236 | struct skype_buddy_ask_data *bla = data; |
---|
[1f4fc80] | 237 | skype_printf(bla->ic, "SET CALL %s STATUS FINISHED", |
---|
[8c09bb3] | 238 | bla->handle); |
---|
[e0074cb] | 239 | g_free(bla->handle); |
---|
| 240 | g_free(bla); |
---|
| 241 | } |
---|
| 242 | |
---|
[5adcc65] | 243 | void skype_call_ask(struct im_connection *ic, char *call_id, char *message) |
---|
[e0074cb] | 244 | { |
---|
[8c09bb3] | 245 | struct skype_buddy_ask_data *bla = g_new0(struct skype_buddy_ask_data, |
---|
| 246 | 1); |
---|
[e0074cb] | 247 | |
---|
| 248 | bla->ic = ic; |
---|
| 249 | bla->handle = g_strdup(call_id); |
---|
| 250 | |
---|
[5adcc65] | 251 | imcb_ask(ic, message, bla, skype_call_ask_yes, skype_call_ask_no); |
---|
[e0074cb] | 252 | } |
---|
[72aa7f0] | 253 | |
---|
[b054fad] | 254 | static char *skype_call_strerror(int err) |
---|
| 255 | { |
---|
[5adcc65] | 256 | switch (err) { |
---|
| 257 | case 1: |
---|
| 258 | return "Miscellaneous error"; |
---|
| 259 | case 2: |
---|
| 260 | return "User or phone number does not exist."; |
---|
| 261 | case 3: |
---|
| 262 | return "User is offline"; |
---|
| 263 | case 4: |
---|
| 264 | return "No proxy found"; |
---|
| 265 | case 5: |
---|
| 266 | return "Session terminated."; |
---|
| 267 | case 6: |
---|
| 268 | return "No common codec found."; |
---|
| 269 | case 7: |
---|
| 270 | return "Sound I/O error."; |
---|
| 271 | case 8: |
---|
| 272 | return "Problem with remote sound device."; |
---|
| 273 | case 9: |
---|
| 274 | return "Call blocked by recipient."; |
---|
| 275 | case 10: |
---|
| 276 | return "Recipient not a friend."; |
---|
| 277 | case 11: |
---|
| 278 | return "Current user not authorized by recipient."; |
---|
| 279 | case 12: |
---|
| 280 | return "Sound recording error."; |
---|
| 281 | default: |
---|
| 282 | return "Unknown error"; |
---|
[b054fad] | 283 | } |
---|
| 284 | } |
---|
| 285 | |
---|
[54ca269] | 286 | static char *skype_group_by_username(struct im_connection *ic, char *username) |
---|
| 287 | { |
---|
| 288 | struct skype_data *sd = ic->proto_data; |
---|
| 289 | int i, j; |
---|
| 290 | |
---|
| 291 | /* NEEDSWORK: we just search for the first group of the user, multiple |
---|
| 292 | * groups / user is not yet supported by BitlBee. */ |
---|
| 293 | |
---|
| 294 | for (i = 0; i < g_list_length(sd->groups); i++) { |
---|
| 295 | struct skype_group *sg = g_list_nth_data(sd->groups, i); |
---|
| 296 | for (j = 0; j < g_list_length(sg->users); j++) { |
---|
| 297 | if (!strcmp(g_list_nth_data(sg->users, j), username)) |
---|
| 298 | return sg->name; |
---|
| 299 | } |
---|
| 300 | } |
---|
| 301 | return NULL; |
---|
| 302 | } |
---|
| 303 | |
---|
[46e9822] | 304 | static struct skype_group *skype_group_by_name(struct im_connection *ic, char *name) |
---|
| 305 | { |
---|
| 306 | struct skype_data *sd = ic->proto_data; |
---|
| 307 | int i; |
---|
| 308 | |
---|
| 309 | for (i = 0; i < g_list_length(sd->groups); i++) { |
---|
| 310 | struct skype_group *sg = g_list_nth_data(sd->groups, i); |
---|
| 311 | if (!strcmp(sg->name, name)) |
---|
| 312 | return sg; |
---|
| 313 | } |
---|
| 314 | return NULL; |
---|
| 315 | } |
---|
| 316 | |
---|
[078b0b9] | 317 | static void skype_parse_users(struct im_connection *ic, char *line) |
---|
| 318 | { |
---|
[1f4fc80] | 319 | char **i, **nicks; |
---|
[078b0b9] | 320 | |
---|
| 321 | nicks = g_strsplit(line + 6, ", ", 0); |
---|
[1f4fc80] | 322 | for (i = nicks; *i; i++) |
---|
| 323 | skype_printf(ic, "GET USER %s ONLINESTATUS\n", *i); |
---|
[078b0b9] | 324 | g_strfreev(nicks); |
---|
| 325 | } |
---|
| 326 | |
---|
[6e14204] | 327 | static void skype_parse_user(struct im_connection *ic, char *line) |
---|
| 328 | { |
---|
| 329 | int flags = 0; |
---|
| 330 | char *ptr; |
---|
| 331 | struct skype_data *sd = ic->proto_data; |
---|
| 332 | char *user = strchr(line, ' '); |
---|
| 333 | char *status = strrchr(line, ' '); |
---|
| 334 | |
---|
| 335 | status++; |
---|
| 336 | ptr = strchr(++user, ' '); |
---|
| 337 | if (!ptr) |
---|
| 338 | return; |
---|
| 339 | *ptr = '\0'; |
---|
| 340 | ptr++; |
---|
[49a3c02] | 341 | if (!strncmp(ptr, "ONLINESTATUS ", 13)) { |
---|
| 342 | if (!strcmp(user, sd->username)) |
---|
| 343 | return; |
---|
| 344 | if (!set_getbool(&ic->acc->set, "test_join") |
---|
| 345 | && !strcmp(user, "echo123")) |
---|
| 346 | return; |
---|
[6e14204] | 347 | ptr = g_strdup_printf("%s@skype.com", user); |
---|
[54ca269] | 348 | imcb_add_buddy(ic, ptr, skype_group_by_username(ic, user)); |
---|
[62f51ee9] | 349 | if (strcmp(status, "OFFLINE") && (strcmp(status, "SKYPEOUT") || |
---|
| 350 | !set_getbool(&ic->acc->set, "skypeout_offline"))) |
---|
[6e14204] | 351 | flags |= OPT_LOGGED_IN; |
---|
[62f51ee9] | 352 | if (strcmp(status, "ONLINE") && strcmp(status, "SKYPEME")) |
---|
[6e14204] | 353 | flags |= OPT_AWAY; |
---|
| 354 | imcb_buddy_status(ic, ptr, flags, NULL, NULL); |
---|
| 355 | g_free(ptr); |
---|
| 356 | } else if (!strncmp(ptr, "RECEIVEDAUTHREQUEST ", 20)) { |
---|
| 357 | char *message = ptr + 20; |
---|
| 358 | if (strlen(message)) |
---|
| 359 | skype_buddy_ask(ic, user, message); |
---|
| 360 | } else if (!strncmp(ptr, "BUDDYSTATUS ", 12)) { |
---|
| 361 | char *st = ptr + 12; |
---|
| 362 | if (!strcmp(st, "3")) { |
---|
| 363 | char *buf = g_strdup_printf("%s@skype.com", user); |
---|
[54ca269] | 364 | imcb_add_buddy(ic, buf, skype_group_by_username(ic, user)); |
---|
[6e14204] | 365 | g_free(buf); |
---|
| 366 | } |
---|
[78d22cd0] | 367 | } else if (!strncmp(ptr, "MOOD_TEXT ", 10)) { |
---|
[4c674bb] | 368 | char *buf = g_strdup_printf("%s@skype.com", user); |
---|
[78d22cd0] | 369 | bee_user_t *bu = bee_user_by_handle(ic->bee, ic, buf); |
---|
| 370 | g_free(buf); |
---|
| 371 | buf = ptr + 10; |
---|
[451f121] | 372 | if (bu) |
---|
[78d22cd0] | 373 | imcb_buddy_status(ic, bu->handle, bu->flags, NULL, |
---|
[4ab7225] | 374 | *buf ? buf : NULL); |
---|
[78d22cd0] | 375 | if (set_getbool(&ic->acc->set, "show_moods")) |
---|
| 376 | imcb_log(ic, "User `%s' changed mood text to `%s'", user, buf); |
---|
[3518933] | 377 | } else if (!strncmp(ptr, "FULLNAME ", 9)) |
---|
[d7938f9] | 378 | sd->info_fullname = g_strdup(ptr + 9); |
---|
[6e14204] | 379 | else if (!strncmp(ptr, "PHONE_HOME ", 11)) |
---|
[d7938f9] | 380 | sd->info_phonehome = g_strdup(ptr + 11); |
---|
[6e14204] | 381 | else if (!strncmp(ptr, "PHONE_OFFICE ", 13)) |
---|
[d7938f9] | 382 | sd->info_phoneoffice = g_strdup(ptr + 13); |
---|
[6e14204] | 383 | else if (!strncmp(ptr, "PHONE_MOBILE ", 13)) |
---|
[d7938f9] | 384 | sd->info_phonemobile = g_strdup(ptr + 13); |
---|
[6e14204] | 385 | else if (!strncmp(ptr, "NROF_AUTHED_BUDDIES ", 20)) |
---|
[d7938f9] | 386 | sd->info_nrbuddies = g_strdup(ptr + 20); |
---|
[6e14204] | 387 | else if (!strncmp(ptr, "TIMEZONE ", 9)) |
---|
[d7938f9] | 388 | sd->info_tz = g_strdup(ptr + 9); |
---|
[6e14204] | 389 | else if (!strncmp(ptr, "LASTONLINETIMESTAMP ", 20)) |
---|
[d7938f9] | 390 | sd->info_seen = g_strdup(ptr + 20); |
---|
[6e14204] | 391 | else if (!strncmp(ptr, "SEX ", 4)) |
---|
[d7938f9] | 392 | sd->info_sex = g_strdup(ptr + 4); |
---|
[6e14204] | 393 | else if (!strncmp(ptr, "LANGUAGE ", 9)) |
---|
[d7938f9] | 394 | sd->info_language = g_strdup(ptr + 9); |
---|
[6e14204] | 395 | else if (!strncmp(ptr, "COUNTRY ", 8)) |
---|
[d7938f9] | 396 | sd->info_country = g_strdup(ptr + 8); |
---|
[6e14204] | 397 | else if (!strncmp(ptr, "PROVINCE ", 9)) |
---|
[d7938f9] | 398 | sd->info_province = g_strdup(ptr + 9); |
---|
[6e14204] | 399 | else if (!strncmp(ptr, "CITY ", 5)) |
---|
[d7938f9] | 400 | sd->info_city = g_strdup(ptr + 5); |
---|
[6e14204] | 401 | else if (!strncmp(ptr, "HOMEPAGE ", 9)) |
---|
[d7938f9] | 402 | sd->info_homepage = g_strdup(ptr + 9); |
---|
[6e14204] | 403 | else if (!strncmp(ptr, "ABOUT ", 6)) { |
---|
[85341dd] | 404 | /* Support multiple about lines. */ |
---|
| 405 | if (!sd->info_about) |
---|
| 406 | sd->info_about = g_strdup(ptr + 6); |
---|
| 407 | else { |
---|
| 408 | GString *st = g_string_new(sd->info_about); |
---|
| 409 | g_string_append_printf(st, "\n%s", ptr + 6); |
---|
| 410 | g_free(sd->info_about); |
---|
| 411 | sd->info_about = g_strdup(st->str); |
---|
| 412 | g_string_free(st, TRUE); |
---|
| 413 | } |
---|
[e1d6b38] | 414 | } else if (!strncmp(ptr, "BIRTHDAY ", 9)) { |
---|
[85341dd] | 415 | sd->info_birthday = g_strdup(ptr + 9); |
---|
[6e14204] | 416 | |
---|
| 417 | GString *st = g_string_new("Contact Information\n"); |
---|
| 418 | g_string_append_printf(st, "Skype Name: %s\n", user); |
---|
| 419 | if (sd->info_fullname) { |
---|
| 420 | if (strlen(sd->info_fullname)) |
---|
[62f51ee9] | 421 | g_string_append_printf(st, "Full Name: %s\n", |
---|
| 422 | sd->info_fullname); |
---|
[6e14204] | 423 | g_free(sd->info_fullname); |
---|
[7c2daf5f] | 424 | sd->info_fullname = NULL; |
---|
[6e14204] | 425 | } |
---|
| 426 | if (sd->info_phonehome) { |
---|
| 427 | if (strlen(sd->info_phonehome)) |
---|
[62f51ee9] | 428 | g_string_append_printf(st, "Home Phone: %s\n", |
---|
| 429 | sd->info_phonehome); |
---|
[6e14204] | 430 | g_free(sd->info_phonehome); |
---|
[7c2daf5f] | 431 | sd->info_phonehome = NULL; |
---|
[6e14204] | 432 | } |
---|
| 433 | if (sd->info_phoneoffice) { |
---|
| 434 | if (strlen(sd->info_phoneoffice)) |
---|
[62f51ee9] | 435 | g_string_append_printf(st, "Office Phone: %s\n", |
---|
| 436 | sd->info_phoneoffice); |
---|
[6e14204] | 437 | g_free(sd->info_phoneoffice); |
---|
[7c2daf5f] | 438 | sd->info_phoneoffice = NULL; |
---|
[6e14204] | 439 | } |
---|
| 440 | if (sd->info_phonemobile) { |
---|
| 441 | if (strlen(sd->info_phonemobile)) |
---|
[62f51ee9] | 442 | g_string_append_printf(st, "Mobile Phone: %s\n", |
---|
| 443 | sd->info_phonemobile); |
---|
[6e14204] | 444 | g_free(sd->info_phonemobile); |
---|
[7c2daf5f] | 445 | sd->info_phonemobile = NULL; |
---|
[6e14204] | 446 | } |
---|
| 447 | g_string_append_printf(st, "Personal Information\n"); |
---|
| 448 | if (sd->info_nrbuddies) { |
---|
| 449 | if (strlen(sd->info_nrbuddies)) |
---|
[62f51ee9] | 450 | g_string_append_printf(st, |
---|
| 451 | "Contacts: %s\n", sd->info_nrbuddies); |
---|
[6e14204] | 452 | g_free(sd->info_nrbuddies); |
---|
[7c2daf5f] | 453 | sd->info_nrbuddies = NULL; |
---|
[6e14204] | 454 | } |
---|
| 455 | if (sd->info_tz) { |
---|
| 456 | if (strlen(sd->info_tz)) { |
---|
| 457 | char ib[256]; |
---|
| 458 | time_t t = time(NULL); |
---|
| 459 | t += atoi(sd->info_tz)-(60*60*24); |
---|
| 460 | struct tm *gt = gmtime(&t); |
---|
| 461 | strftime(ib, 256, "%H:%M:%S", gt); |
---|
[62f51ee9] | 462 | g_string_append_printf(st, |
---|
| 463 | "Local Time: %s\n", ib); |
---|
[6e14204] | 464 | } |
---|
| 465 | g_free(sd->info_tz); |
---|
[7c2daf5f] | 466 | sd->info_tz = NULL; |
---|
[6e14204] | 467 | } |
---|
| 468 | if (sd->info_seen) { |
---|
| 469 | if (strlen(sd->info_seen)) { |
---|
| 470 | char ib[256]; |
---|
| 471 | time_t it = atoi(sd->info_seen); |
---|
| 472 | struct tm *tm = localtime(&it); |
---|
| 473 | strftime(ib, 256, ("%Y. %m. %d. %H:%M"), tm); |
---|
[62f51ee9] | 474 | g_string_append_printf(st, |
---|
| 475 | "Last Seen: %s\n", ib); |
---|
[6e14204] | 476 | } |
---|
| 477 | g_free(sd->info_seen); |
---|
[7c2daf5f] | 478 | sd->info_seen = NULL; |
---|
[6e14204] | 479 | } |
---|
| 480 | if (sd->info_birthday) { |
---|
[62f51ee9] | 481 | if (strlen(sd->info_birthday) && |
---|
| 482 | strcmp(sd->info_birthday, "0")) { |
---|
[6e14204] | 483 | char ib[256]; |
---|
| 484 | struct tm tm; |
---|
| 485 | strptime(sd->info_birthday, "%Y%m%d", &tm); |
---|
| 486 | strftime(ib, 256, "%B %d, %Y", &tm); |
---|
[62f51ee9] | 487 | g_string_append_printf(st, |
---|
| 488 | "Birthday: %s\n", ib); |
---|
[6e14204] | 489 | |
---|
| 490 | strftime(ib, 256, "%Y", &tm); |
---|
| 491 | int year = atoi(ib); |
---|
| 492 | time_t t = time(NULL); |
---|
| 493 | struct tm *lt = localtime(&t); |
---|
[62f51ee9] | 494 | g_string_append_printf(st, |
---|
| 495 | "Age: %d\n", lt->tm_year+1900-year); |
---|
[6e14204] | 496 | } |
---|
| 497 | g_free(sd->info_birthday); |
---|
[7c2daf5f] | 498 | sd->info_birthday = NULL; |
---|
[6e14204] | 499 | } |
---|
| 500 | if (sd->info_sex) { |
---|
| 501 | if (strlen(sd->info_sex)) { |
---|
| 502 | char *iptr = sd->info_sex; |
---|
| 503 | while (*iptr++) |
---|
| 504 | *iptr = tolower(*iptr); |
---|
[62f51ee9] | 505 | g_string_append_printf(st, |
---|
| 506 | "Gender: %s\n", sd->info_sex); |
---|
[6e14204] | 507 | } |
---|
| 508 | g_free(sd->info_sex); |
---|
[7c2daf5f] | 509 | sd->info_sex = NULL; |
---|
[6e14204] | 510 | } |
---|
| 511 | if (sd->info_language) { |
---|
| 512 | if (strlen(sd->info_language)) { |
---|
| 513 | char *iptr = strchr(sd->info_language, ' '); |
---|
| 514 | if (iptr) |
---|
| 515 | iptr++; |
---|
| 516 | else |
---|
| 517 | iptr = sd->info_language; |
---|
[62f51ee9] | 518 | g_string_append_printf(st, |
---|
| 519 | "Language: %s\n", iptr); |
---|
[6e14204] | 520 | } |
---|
| 521 | g_free(sd->info_language); |
---|
[7c2daf5f] | 522 | sd->info_language = NULL; |
---|
[6e14204] | 523 | } |
---|
| 524 | if (sd->info_country) { |
---|
| 525 | if (strlen(sd->info_country)) { |
---|
| 526 | char *iptr = strchr(sd->info_country, ' '); |
---|
| 527 | if (iptr) |
---|
| 528 | iptr++; |
---|
| 529 | else |
---|
| 530 | iptr = sd->info_country; |
---|
[62f51ee9] | 531 | g_string_append_printf(st, |
---|
| 532 | "Country: %s\n", iptr); |
---|
[6e14204] | 533 | } |
---|
| 534 | g_free(sd->info_country); |
---|
[7c2daf5f] | 535 | sd->info_country = NULL; |
---|
[6e14204] | 536 | } |
---|
| 537 | if (sd->info_province) { |
---|
| 538 | if (strlen(sd->info_province)) |
---|
[62f51ee9] | 539 | g_string_append_printf(st, |
---|
| 540 | "Region: %s\n", sd->info_province); |
---|
[6e14204] | 541 | g_free(sd->info_province); |
---|
[7c2daf5f] | 542 | sd->info_province = NULL; |
---|
[6e14204] | 543 | } |
---|
| 544 | if (sd->info_city) { |
---|
| 545 | if (strlen(sd->info_city)) |
---|
[62f51ee9] | 546 | g_string_append_printf(st, |
---|
| 547 | "City: %s\n", sd->info_city); |
---|
[6e14204] | 548 | g_free(sd->info_city); |
---|
[7c2daf5f] | 549 | sd->info_city = NULL; |
---|
[6e14204] | 550 | } |
---|
| 551 | if (sd->info_homepage) { |
---|
| 552 | if (strlen(sd->info_homepage)) |
---|
[62f51ee9] | 553 | g_string_append_printf(st, |
---|
| 554 | "Homepage: %s\n", sd->info_homepage); |
---|
[6e14204] | 555 | g_free(sd->info_homepage); |
---|
[7c2daf5f] | 556 | sd->info_homepage = NULL; |
---|
[6e14204] | 557 | } |
---|
| 558 | if (sd->info_about) { |
---|
| 559 | if (strlen(sd->info_about)) |
---|
[62f51ee9] | 560 | g_string_append_printf(st, "%s\n", |
---|
| 561 | sd->info_about); |
---|
[6e14204] | 562 | g_free(sd->info_about); |
---|
[7c2daf5f] | 563 | sd->info_about = NULL; |
---|
[6e14204] | 564 | } |
---|
| 565 | imcb_log(ic, "%s", st->str); |
---|
| 566 | g_string_free(st, TRUE); |
---|
| 567 | } |
---|
| 568 | } |
---|
| 569 | |
---|
[e1d6b38] | 570 | static void skype_parse_chatmessage_said_emoted(struct im_connection *ic, struct groupchat *gc, char *body) |
---|
[6e14204] | 571 | { |
---|
| 572 | struct skype_data *sd = ic->proto_data; |
---|
[c213d6b] | 573 | char buf[IRC_LINE_SIZE]; |
---|
[e1d6b38] | 574 | if (!strcmp(sd->type, "SAID")) { |
---|
| 575 | if (!sd->is_edit) |
---|
| 576 | g_snprintf(buf, IRC_LINE_SIZE, "%s", body); |
---|
| 577 | else { |
---|
| 578 | g_snprintf(buf, IRC_LINE_SIZE, "%s %s", set_getstr(&ic->acc->set, "edit_prefix"), body); |
---|
| 579 | sd->is_edit = 0; |
---|
| 580 | } |
---|
| 581 | } else |
---|
| 582 | g_snprintf(buf, IRC_LINE_SIZE, "/me %s", body); |
---|
| 583 | if (!gc) |
---|
| 584 | /* Private message */ |
---|
| 585 | imcb_buddy_msg(ic, sd->handle, buf, 0, 0); |
---|
| 586 | else |
---|
| 587 | /* Groupchat message */ |
---|
| 588 | imcb_chat_msg(gc, sd->handle, buf, 0, 0); |
---|
| 589 | } |
---|
| 590 | |
---|
| 591 | static void skype_parse_chatmessage(struct im_connection *ic, char *line) |
---|
| 592 | { |
---|
| 593 | struct skype_data *sd = ic->proto_data; |
---|
[6e14204] | 594 | char *id = strchr(line, ' '); |
---|
| 595 | |
---|
[6b9d22a] | 596 | if (!++id) |
---|
| 597 | return; |
---|
| 598 | char *info = strchr(id, ' '); |
---|
| 599 | |
---|
| 600 | if (!info) |
---|
| 601 | return; |
---|
| 602 | *info = '\0'; |
---|
| 603 | info++; |
---|
[7825f58] | 604 | if (!strcmp(info, "STATUS RECEIVED") || !strncmp(info, "EDITED_TIMESTAMP", 16)) { |
---|
[6b9d22a] | 605 | /* New message ID: |
---|
| 606 | * (1) Request its from field |
---|
| 607 | * (2) Request its body |
---|
| 608 | * (3) Request its type |
---|
| 609 | * (4) Query chatname |
---|
| 610 | */ |
---|
[1f4fc80] | 611 | skype_printf(ic, "GET CHATMESSAGE %s FROM_HANDLE\n", id); |
---|
[d1d5b34] | 612 | if (!strcmp(info, "STATUS RECEIVED")) |
---|
| 613 | skype_printf(ic, "GET CHATMESSAGE %s BODY\n", id); |
---|
[d9ce18c] | 614 | else |
---|
| 615 | sd->is_edit = 1; |
---|
[1f4fc80] | 616 | skype_printf(ic, "GET CHATMESSAGE %s TYPE\n", id); |
---|
| 617 | skype_printf(ic, "GET CHATMESSAGE %s CHATNAME\n", id); |
---|
[6b9d22a] | 618 | } else if (!strncmp(info, "FROM_HANDLE ", 12)) { |
---|
| 619 | info += 12; |
---|
| 620 | /* New from field value. Store |
---|
| 621 | * it, then we can later use it |
---|
| 622 | * when we got the message's |
---|
| 623 | * body. */ |
---|
| 624 | g_free(sd->handle); |
---|
| 625 | sd->handle = g_strdup_printf("%s@skype.com", info); |
---|
| 626 | } else if (!strncmp(info, "EDITED_BY ", 10)) { |
---|
| 627 | info += 10; |
---|
| 628 | /* This is the same as |
---|
| 629 | * FROM_HANDLE, except that we |
---|
| 630 | * never request these lines |
---|
| 631 | * from Skype, we just get |
---|
| 632 | * them. */ |
---|
| 633 | g_free(sd->handle); |
---|
| 634 | sd->handle = g_strdup_printf("%s@skype.com", info); |
---|
| 635 | } else if (!strncmp(info, "BODY ", 5)) { |
---|
| 636 | info += 5; |
---|
| 637 | sd->body = g_list_append(sd->body, g_strdup(info)); |
---|
| 638 | } else if (!strncmp(info, "TYPE ", 5)) { |
---|
| 639 | info += 5; |
---|
| 640 | g_free(sd->type); |
---|
| 641 | sd->type = g_strdup(info); |
---|
[7825f58] | 642 | } else if (!strncmp(info, "CHATNAME ", 9)) { |
---|
| 643 | info += 9; |
---|
| 644 | if (sd->handle && sd->body && sd->type) { |
---|
[451f121] | 645 | struct groupchat *gc = bee_chat_by_title(ic->bee, ic, info); |
---|
[7825f58] | 646 | int i; |
---|
| 647 | for (i = 0; i < g_list_length(sd->body); i++) { |
---|
| 648 | char *body = g_list_nth_data(sd->body, i); |
---|
| 649 | if (!strcmp(sd->type, "SAID") || |
---|
| 650 | !strcmp(sd->type, "EMOTED")) { |
---|
[e1d6b38] | 651 | skype_parse_chatmessage_said_emoted(ic, gc, body); |
---|
[7825f58] | 652 | } else if (!strcmp(sd->type, "SETTOPIC") && gc) |
---|
| 653 | imcb_chat_topic(gc, |
---|
| 654 | sd->handle, body, 0); |
---|
| 655 | else if (!strcmp(sd->type, "LEFT") && gc) |
---|
| 656 | imcb_chat_remove_buddy(gc, |
---|
| 657 | sd->handle, NULL); |
---|
[6e14204] | 658 | } |
---|
[7825f58] | 659 | g_list_free(sd->body); |
---|
| 660 | sd->body = NULL; |
---|
| 661 | } |
---|
[6e14204] | 662 | } |
---|
| 663 | } |
---|
| 664 | |
---|
[9f2f25f] | 665 | static void skype_parse_call(struct im_connection *ic, char *line) |
---|
| 666 | { |
---|
| 667 | struct skype_data *sd = ic->proto_data; |
---|
| 668 | char *id = strchr(line, ' '); |
---|
[c213d6b] | 669 | char buf[IRC_LINE_SIZE]; |
---|
[9f2f25f] | 670 | |
---|
[6b9d22a] | 671 | if (!++id) |
---|
| 672 | return; |
---|
| 673 | char *info = strchr(id, ' '); |
---|
| 674 | |
---|
| 675 | if (!info) |
---|
| 676 | return; |
---|
| 677 | *info = '\0'; |
---|
| 678 | info++; |
---|
| 679 | if (!strncmp(info, "FAILUREREASON ", 14)) |
---|
| 680 | sd->failurereason = atoi(strchr(info, ' ')); |
---|
| 681 | else if (!strcmp(info, "STATUS RINGING")) { |
---|
| 682 | if (sd->call_id) |
---|
| 683 | g_free(sd->call_id); |
---|
| 684 | sd->call_id = g_strdup(id); |
---|
[1f4fc80] | 685 | skype_printf(ic, "GET CALL %s PARTNER_HANDLE\n", id); |
---|
[6b9d22a] | 686 | sd->call_status = SKYPE_CALL_RINGING; |
---|
| 687 | } else if (!strcmp(info, "STATUS MISSED")) { |
---|
[1f4fc80] | 688 | skype_printf(ic, "GET CALL %s PARTNER_HANDLE\n", id); |
---|
[6b9d22a] | 689 | sd->call_status = SKYPE_CALL_MISSED; |
---|
| 690 | } else if (!strcmp(info, "STATUS CANCELLED")) { |
---|
[1f4fc80] | 691 | skype_printf(ic, "GET CALL %s PARTNER_HANDLE\n", id); |
---|
[6b9d22a] | 692 | sd->call_status = SKYPE_CALL_CANCELLED; |
---|
| 693 | } else if (!strcmp(info, "STATUS FINISHED")) { |
---|
[1f4fc80] | 694 | skype_printf(ic, "GET CALL %s PARTNER_HANDLE\n", id); |
---|
[6b9d22a] | 695 | sd->call_status = SKYPE_CALL_FINISHED; |
---|
| 696 | } else if (!strcmp(info, "STATUS REFUSED")) { |
---|
[1f4fc80] | 697 | skype_printf(ic, "GET CALL %s PARTNER_HANDLE\n", id); |
---|
[6b9d22a] | 698 | sd->call_status = SKYPE_CALL_REFUSED; |
---|
| 699 | } else if (!strcmp(info, "STATUS UNPLACED")) { |
---|
| 700 | if (sd->call_id) |
---|
| 701 | g_free(sd->call_id); |
---|
| 702 | /* Save the ID for later usage (Cancel/Finish). */ |
---|
| 703 | sd->call_id = g_strdup(id); |
---|
| 704 | sd->call_out = TRUE; |
---|
| 705 | } else if (!strcmp(info, "STATUS FAILED")) { |
---|
[62f51ee9] | 706 | imcb_error(ic, "Call failed: %s", |
---|
| 707 | skype_call_strerror(sd->failurereason)); |
---|
[6b9d22a] | 708 | sd->call_id = NULL; |
---|
| 709 | } else if (!strncmp(info, "DURATION ", 9)) { |
---|
| 710 | if (sd->call_duration) |
---|
| 711 | g_free(sd->call_duration); |
---|
| 712 | sd->call_duration = g_strdup(info+9); |
---|
| 713 | } else if (!strncmp(info, "PARTNER_HANDLE ", 15)) { |
---|
| 714 | info += 15; |
---|
[62f51ee9] | 715 | if (!sd->call_status) |
---|
| 716 | return; |
---|
| 717 | switch (sd->call_status) { |
---|
| 718 | case SKYPE_CALL_RINGING: |
---|
| 719 | if (sd->call_out) |
---|
[e1d6b38] | 720 | imcb_log(ic, "You are currently ringing the user %s.", info); |
---|
[62f51ee9] | 721 | else { |
---|
[c213d6b] | 722 | g_snprintf(buf, IRC_LINE_SIZE, |
---|
[62f51ee9] | 723 | "The user %s is currently ringing you.", |
---|
| 724 | info); |
---|
| 725 | skype_call_ask(ic, sd->call_id, buf); |
---|
[9f2f25f] | 726 | } |
---|
[62f51ee9] | 727 | break; |
---|
| 728 | case SKYPE_CALL_MISSED: |
---|
| 729 | imcb_log(ic, "You have missed a call from user %s.", |
---|
| 730 | info); |
---|
| 731 | break; |
---|
| 732 | case SKYPE_CALL_CANCELLED: |
---|
| 733 | imcb_log(ic, "You cancelled the call to the user %s.", |
---|
| 734 | info); |
---|
[6b9d22a] | 735 | sd->call_status = 0; |
---|
[62f51ee9] | 736 | sd->call_out = FALSE; |
---|
| 737 | break; |
---|
| 738 | case SKYPE_CALL_REFUSED: |
---|
| 739 | if (sd->call_out) |
---|
| 740 | imcb_log(ic, "The user %s refused the call.", |
---|
| 741 | info); |
---|
| 742 | else |
---|
| 743 | imcb_log(ic, |
---|
| 744 | "You refused the call from user %s.", |
---|
| 745 | info); |
---|
| 746 | sd->call_out = FALSE; |
---|
| 747 | break; |
---|
| 748 | case SKYPE_CALL_FINISHED: |
---|
| 749 | if (sd->call_duration) |
---|
| 750 | imcb_log(ic, |
---|
| 751 | "You finished the call to the user %s " |
---|
| 752 | "(duration: %s seconds).", |
---|
| 753 | info, sd->call_duration); |
---|
| 754 | else |
---|
| 755 | imcb_log(ic, |
---|
| 756 | "You finished the call to the user %s.", |
---|
| 757 | info); |
---|
| 758 | sd->call_out = FALSE; |
---|
| 759 | break; |
---|
| 760 | default: |
---|
| 761 | /* Don't be noisy, ignore other statuses for now. */ |
---|
| 762 | break; |
---|
[9f2f25f] | 763 | } |
---|
[62f51ee9] | 764 | sd->call_status = 0; |
---|
[9f2f25f] | 765 | } |
---|
| 766 | } |
---|
| 767 | |
---|
[e200daf] | 768 | static void skype_parse_filetransfer(struct im_connection *ic, char *line) |
---|
| 769 | { |
---|
| 770 | struct skype_data *sd = ic->proto_data; |
---|
| 771 | char *id = strchr(line, ' '); |
---|
| 772 | |
---|
[6b9d22a] | 773 | if (!++id) |
---|
| 774 | return; |
---|
| 775 | char *info = strchr(id, ' '); |
---|
| 776 | |
---|
| 777 | if (!info) |
---|
| 778 | return; |
---|
| 779 | *info = '\0'; |
---|
| 780 | info++; |
---|
| 781 | if (!strcmp(info, "STATUS NEW")) { |
---|
[1f4fc80] | 782 | skype_printf(ic, "GET FILETRANSFER %s PARTNER_HANDLE\n", |
---|
[62f51ee9] | 783 | id); |
---|
[6b9d22a] | 784 | sd->filetransfer_status = SKYPE_FILETRANSFER_NEW; |
---|
| 785 | } else if (!strcmp(info, "STATUS FAILED")) { |
---|
[1f4fc80] | 786 | skype_printf(ic, "GET FILETRANSFER %s PARTNER_HANDLE\n", |
---|
[62f51ee9] | 787 | id); |
---|
[6b9d22a] | 788 | sd->filetransfer_status = SKYPE_FILETRANSFER_FAILED; |
---|
[b2dc873] | 789 | } else if (!strcmp(info, "STATUS COMPLETED")) { |
---|
| 790 | skype_printf(ic, "GET FILETRANSFER %s PARTNER_HANDLE\n", id); |
---|
| 791 | sd->filetransfer_status = SKYPE_FILETRANSFER_COMPLETED; |
---|
| 792 | } else if (!strcmp(info, "STATUS TRANSFERRING")) { |
---|
| 793 | skype_printf(ic, "GET FILETRANSFER %s PARTNER_HANDLE\n", id); |
---|
| 794 | sd->filetransfer_status = SKYPE_FILETRANSFER_TRANSFERRING; |
---|
| 795 | } else if (!strncmp(info, "FILEPATH ", 9)) { |
---|
| 796 | info += 9; |
---|
| 797 | sd->filetransfer_path = g_strdup(info); |
---|
[6b9d22a] | 798 | } else if (!strncmp(info, "PARTNER_HANDLE ", 15)) { |
---|
| 799 | info += 15; |
---|
[62f51ee9] | 800 | if (!sd->filetransfer_status) |
---|
| 801 | return; |
---|
| 802 | switch (sd->filetransfer_status) { |
---|
| 803 | case SKYPE_FILETRANSFER_NEW: |
---|
| 804 | imcb_log(ic, "The user %s offered a new file for you.", |
---|
| 805 | info); |
---|
| 806 | break; |
---|
| 807 | case SKYPE_FILETRANSFER_FAILED: |
---|
| 808 | imcb_log(ic, "Failed to transfer file from user %s.", |
---|
| 809 | info); |
---|
| 810 | break; |
---|
[b2dc873] | 811 | case SKYPE_FILETRANSFER_COMPLETED: |
---|
| 812 | imcb_log(ic, "File transfer from user %s completed.", info); |
---|
| 813 | break; |
---|
| 814 | case SKYPE_FILETRANSFER_TRANSFERRING: |
---|
| 815 | if (sd->filetransfer_path) { |
---|
| 816 | imcb_log(ic, "File transfer from user %s started, saving to %s.", info, sd->filetransfer_path); |
---|
| 817 | g_free(sd->filetransfer_path); |
---|
| 818 | sd->filetransfer_path = NULL; |
---|
| 819 | } |
---|
| 820 | break; |
---|
[e200daf] | 821 | } |
---|
[62f51ee9] | 822 | sd->filetransfer_status = 0; |
---|
[e200daf] | 823 | } |
---|
| 824 | } |
---|
| 825 | |
---|
[fbb15f2] | 826 | static struct skype_group *skype_group_by_id(struct im_connection *ic, int id) |
---|
| 827 | { |
---|
[89d6845] | 828 | struct skype_data *sd = ic->proto_data; |
---|
| 829 | int i; |
---|
| 830 | |
---|
| 831 | for (i = 0; i < g_list_length(sd->groups); i++) { |
---|
| 832 | struct skype_group *sg = (struct skype_group *)g_list_nth_data(sd->groups, i); |
---|
| 833 | |
---|
| 834 | if (sg->id == id) |
---|
| 835 | return sg; |
---|
| 836 | } |
---|
| 837 | return NULL; |
---|
| 838 | } |
---|
| 839 | |
---|
[fbb15f2] | 840 | static void skype_group_free(struct skype_group *sg, gboolean usersonly) |
---|
| 841 | { |
---|
[89d6845] | 842 | int i; |
---|
[fbb15f2] | 843 | |
---|
[89d6845] | 844 | for (i = 0; i < g_list_length(sg->users); i++) { |
---|
| 845 | char *user = g_list_nth_data(sg->users, i); |
---|
| 846 | g_free(user); |
---|
| 847 | } |
---|
| 848 | sg->users = NULL; |
---|
| 849 | if (usersonly) |
---|
| 850 | return; |
---|
| 851 | g_free(sg->name); |
---|
| 852 | g_free(sg); |
---|
| 853 | } |
---|
| 854 | |
---|
[54ca269] | 855 | /* Update the group of each user in this group */ |
---|
[fbb15f2] | 856 | static void skype_group_users(struct im_connection *ic, struct skype_group *sg) |
---|
| 857 | { |
---|
[54ca269] | 858 | int i; |
---|
| 859 | |
---|
| 860 | for (i = 0; i < g_list_length(sg->users); i++) { |
---|
| 861 | char *user = g_list_nth_data(sg->users, i); |
---|
| 862 | char *buf = g_strdup_printf("%s@skype.com", user); |
---|
| 863 | imcb_add_buddy(ic, buf, sg->name); |
---|
| 864 | g_free(buf); |
---|
| 865 | } |
---|
| 866 | } |
---|
| 867 | |
---|
[89d6845] | 868 | static void skype_parse_group(struct im_connection *ic, char *line) |
---|
| 869 | { |
---|
| 870 | struct skype_data *sd = ic->proto_data; |
---|
| 871 | char *id = strchr(line, ' '); |
---|
| 872 | |
---|
| 873 | if (!++id) |
---|
| 874 | return; |
---|
| 875 | |
---|
| 876 | char *info = strchr(id, ' '); |
---|
| 877 | |
---|
| 878 | if (!info) |
---|
| 879 | return; |
---|
| 880 | *info = '\0'; |
---|
| 881 | info++; |
---|
| 882 | |
---|
| 883 | if (!strncmp(info, "DISPLAYNAME ", 12)) { |
---|
| 884 | info += 12; |
---|
| 885 | |
---|
| 886 | /* Name given for a group ID: try to update it or insert a new |
---|
| 887 | * one if not found */ |
---|
| 888 | struct skype_group *sg = skype_group_by_id(ic, atoi(id)); |
---|
| 889 | if (sg) { |
---|
| 890 | g_free(sg->name); |
---|
| 891 | sg->name = g_strdup(info); |
---|
| 892 | } else { |
---|
| 893 | sg = g_new0(struct skype_group, 1); |
---|
| 894 | sg->id = atoi(id); |
---|
| 895 | sg->name = g_strdup(info); |
---|
| 896 | sd->groups = g_list_append(sd->groups, sg); |
---|
| 897 | } |
---|
| 898 | } else if (!strncmp(info, "USERS ", 6)) { |
---|
| 899 | struct skype_group *sg = skype_group_by_id(ic, atoi(id)); |
---|
| 900 | |
---|
| 901 | if (sg) { |
---|
| 902 | char **i; |
---|
| 903 | char **users = g_strsplit(info + 6, ", ", 0); |
---|
| 904 | |
---|
| 905 | skype_group_free(sg, TRUE); |
---|
| 906 | i = users; |
---|
| 907 | while (*i) { |
---|
| 908 | sg->users = g_list_append(sg->users, g_strdup(*i)); |
---|
| 909 | i++; |
---|
| 910 | } |
---|
| 911 | g_strfreev(users); |
---|
[54ca269] | 912 | skype_group_users(ic, sg); |
---|
[89d6845] | 913 | } else |
---|
[fbb15f2] | 914 | log_message(LOGLVL_ERROR, |
---|
| 915 | "No skype group with id %s. That's probably a bug.", id); |
---|
[46641bf] | 916 | } else if (!strncmp(info, "NROFUSERS ", 10)) { |
---|
| 917 | if (!sd->pending_user) { |
---|
| 918 | /* Number of users changed in this group, query its type to see |
---|
| 919 | * if it's a custom one we should care about. */ |
---|
| 920 | skype_printf(ic, "GET GROUP %s TYPE", id); |
---|
| 921 | return; |
---|
| 922 | } |
---|
| 923 | |
---|
| 924 | /* This is a newly created group, we have a single user |
---|
| 925 | * to add. */ |
---|
| 926 | struct skype_group *sg = skype_group_by_id(ic, atoi(id)); |
---|
| 927 | |
---|
| 928 | if (sg) { |
---|
| 929 | skype_printf(ic, "ALTER GROUP %d ADDUSER %s", sg->id, sd->pending_user); |
---|
| 930 | g_free(sd->pending_user); |
---|
| 931 | sd->pending_user = NULL; |
---|
| 932 | } else |
---|
| 933 | log_message(LOGLVL_ERROR, |
---|
| 934 | "No skype group with id %s. That's probably a bug.", id); |
---|
[2b183e4] | 935 | } else if (!strcmp(info, "TYPE CUSTOM_GROUP")) |
---|
[cb6d3c9] | 936 | /* This one is interesting, query its users. */ |
---|
| 937 | skype_printf(ic, "GET GROUP %s USERS", id); |
---|
[89d6845] | 938 | } |
---|
| 939 | |
---|
[c35bf7a] | 940 | static void skype_parse_chat(struct im_connection *ic, char *line) |
---|
| 941 | { |
---|
| 942 | struct skype_data *sd = ic->proto_data; |
---|
[c213d6b] | 943 | char buf[IRC_LINE_SIZE]; |
---|
[c35bf7a] | 944 | char *id = strchr(line, ' '); |
---|
| 945 | |
---|
[6b9d22a] | 946 | if (!++id) |
---|
| 947 | return; |
---|
| 948 | struct groupchat *gc; |
---|
| 949 | char *info = strchr(id, ' '); |
---|
[c35bf7a] | 950 | |
---|
[6b9d22a] | 951 | if (!info) |
---|
| 952 | return; |
---|
| 953 | *info = '\0'; |
---|
| 954 | info++; |
---|
| 955 | /* Remove fake chat if we created one in skype_chat_with() */ |
---|
[451f121] | 956 | gc = bee_chat_by_title(ic->bee, ic, ""); |
---|
[6b9d22a] | 957 | if (gc) |
---|
| 958 | imcb_chat_free(gc); |
---|
| 959 | if (!strcmp(info, "STATUS MULTI_SUBSCRIBED")) { |
---|
[c573f1b] | 960 | gc = bee_chat_by_title(ic->bee, ic, id); |
---|
| 961 | if (!gc) { |
---|
| 962 | gc = imcb_chat_new(ic, id); |
---|
| 963 | imcb_chat_name_hint(gc, id); |
---|
| 964 | } |
---|
[1f4fc80] | 965 | skype_printf(ic, "GET CHAT %s ADDER\n", id); |
---|
| 966 | skype_printf(ic, "GET CHAT %s TOPIC\n", id); |
---|
[6b9d22a] | 967 | } else if (!strcmp(info, "STATUS DIALOG") && sd->groupchat_with) { |
---|
| 968 | gc = imcb_chat_new(ic, id); |
---|
[72b60c7e] | 969 | imcb_chat_name_hint(gc, id); |
---|
[6b9d22a] | 970 | /* According to the docs this |
---|
| 971 | * is necessary. However it |
---|
| 972 | * does not seem the situation |
---|
| 973 | * and it would open an extra |
---|
| 974 | * window on our client, so |
---|
| 975 | * just leave it out. */ |
---|
[1f4fc80] | 976 | /*skype_printf(ic, "OPEN CHAT %s\n", id);*/ |
---|
[5d9db76] | 977 | g_snprintf(buf, IRC_LINE_SIZE, "%s@skype.com", |
---|
| 978 | sd->groupchat_with); |
---|
[6b9d22a] | 979 | imcb_chat_add_buddy(gc, buf); |
---|
| 980 | imcb_chat_add_buddy(gc, sd->username); |
---|
| 981 | g_free(sd->groupchat_with); |
---|
| 982 | sd->groupchat_with = NULL; |
---|
[1f4fc80] | 983 | skype_printf(ic, "GET CHAT %s ADDER\n", id); |
---|
| 984 | skype_printf(ic, "GET CHAT %s TOPIC\n", id); |
---|
[6b9d22a] | 985 | } else if (!strcmp(info, "STATUS UNSUBSCRIBED")) { |
---|
[451f121] | 986 | gc = bee_chat_by_title(ic->bee, ic, id); |
---|
[c35bf7a] | 987 | if (gc) |
---|
[6b9d22a] | 988 | gc->data = (void *)FALSE; |
---|
| 989 | } else if (!strncmp(info, "ADDER ", 6)) { |
---|
| 990 | info += 6; |
---|
| 991 | g_free(sd->adder); |
---|
| 992 | sd->adder = g_strdup_printf("%s@skype.com", info); |
---|
| 993 | } else if (!strncmp(info, "TOPIC ", 6)) { |
---|
| 994 | info += 6; |
---|
[451f121] | 995 | gc = bee_chat_by_title(ic->bee, ic, id); |
---|
[6b9d22a] | 996 | if (gc && (sd->adder || sd->topic_wait)) { |
---|
| 997 | if (sd->topic_wait) { |
---|
| 998 | sd->adder = g_strdup(sd->username); |
---|
| 999 | sd->topic_wait = 0; |
---|
[c35bf7a] | 1000 | } |
---|
[6b9d22a] | 1001 | imcb_chat_topic(gc, sd->adder, info, 0); |
---|
| 1002 | g_free(sd->adder); |
---|
| 1003 | sd->adder = NULL; |
---|
| 1004 | } |
---|
[2487112] | 1005 | } else if (!strncmp(info, "MEMBERS ", 8)) { |
---|
| 1006 | info += 8; |
---|
[451f121] | 1007 | gc = bee_chat_by_title(ic->bee, ic, id); |
---|
[6b9d22a] | 1008 | /* Hack! We set ->data to TRUE |
---|
| 1009 | * while we're on the channel |
---|
| 1010 | * so that we won't rejoin |
---|
| 1011 | * after a /part. */ |
---|
[62f51ee9] | 1012 | if (!gc || gc->data) |
---|
| 1013 | return; |
---|
| 1014 | char **members = g_strsplit(info, " ", 0); |
---|
| 1015 | int i; |
---|
| 1016 | for (i = 0; members[i]; i++) { |
---|
| 1017 | if (!strcmp(members[i], sd->username)) |
---|
| 1018 | continue; |
---|
[5d9db76] | 1019 | g_snprintf(buf, IRC_LINE_SIZE, "%s@skype.com", |
---|
| 1020 | members[i]); |
---|
[62f51ee9] | 1021 | if (!g_list_find_custom(gc->in_room, buf, |
---|
| 1022 | (GCompareFunc)strcmp)) |
---|
| 1023 | imcb_chat_add_buddy(gc, buf); |
---|
[c35bf7a] | 1024 | } |
---|
[62f51ee9] | 1025 | imcb_chat_add_buddy(gc, sd->username); |
---|
| 1026 | g_strfreev(members); |
---|
[c35bf7a] | 1027 | } |
---|
| 1028 | } |
---|
| 1029 | |
---|
[2709f4c] | 1030 | static void skype_parse_password(struct im_connection *ic, char *line) |
---|
| 1031 | { |
---|
| 1032 | if (!strncmp(line+9, "OK", 2)) |
---|
| 1033 | imcb_connected(ic); |
---|
| 1034 | else { |
---|
| 1035 | imcb_error(ic, "Authentication Failed"); |
---|
| 1036 | imc_logout(ic, TRUE); |
---|
| 1037 | } |
---|
| 1038 | } |
---|
| 1039 | |
---|
[607f5e3] | 1040 | static void skype_parse_profile(struct im_connection *ic, char *line) |
---|
| 1041 | { |
---|
| 1042 | imcb_log(ic, "SkypeOut balance value is '%s'.", line+21); |
---|
| 1043 | } |
---|
| 1044 | |
---|
| 1045 | static void skype_parse_ping(struct im_connection *ic, char *line) |
---|
| 1046 | { |
---|
[4ae3ffc] | 1047 | /* Unused parameter */ |
---|
| 1048 | line = line; |
---|
[1f4fc80] | 1049 | skype_printf(ic, "PONG\n"); |
---|
[607f5e3] | 1050 | } |
---|
| 1051 | |
---|
| 1052 | static void skype_parse_chats(struct im_connection *ic, char *line) |
---|
| 1053 | { |
---|
| 1054 | char **i; |
---|
| 1055 | char **chats = g_strsplit(line + 6, ", ", 0); |
---|
| 1056 | |
---|
| 1057 | i = chats; |
---|
| 1058 | while (*i) { |
---|
[1f4fc80] | 1059 | skype_printf(ic, "GET CHAT %s STATUS\n", *i); |
---|
| 1060 | skype_printf(ic, "GET CHAT %s ACTIVEMEMBERS\n", *i); |
---|
[607f5e3] | 1061 | i++; |
---|
| 1062 | } |
---|
| 1063 | g_strfreev(chats); |
---|
| 1064 | } |
---|
| 1065 | |
---|
[8b8d1bed] | 1066 | static void skype_parse_groups(struct im_connection *ic, char *line) |
---|
| 1067 | { |
---|
[3c7af69] | 1068 | if (!set_getbool(&ic->acc->set, "read_groups")) |
---|
| 1069 | return; |
---|
| 1070 | |
---|
[8b8d1bed] | 1071 | char **i; |
---|
| 1072 | char **groups = g_strsplit(line + 7, ", ", 0); |
---|
| 1073 | |
---|
| 1074 | i = groups; |
---|
| 1075 | while (*i) { |
---|
| 1076 | skype_printf(ic, "GET GROUP %s DISPLAYNAME\n", *i); |
---|
| 1077 | skype_printf(ic, "GET GROUP %s USERS\n", *i); |
---|
| 1078 | i++; |
---|
| 1079 | } |
---|
| 1080 | g_strfreev(groups); |
---|
| 1081 | } |
---|
| 1082 | |
---|
[46e9822] | 1083 | static void skype_parse_alter_group(struct im_connection *ic, char *line) |
---|
| 1084 | { |
---|
| 1085 | char *id = line + strlen("ALTER GROUP"); |
---|
| 1086 | |
---|
| 1087 | if (!++id) |
---|
| 1088 | return; |
---|
| 1089 | |
---|
| 1090 | char *info = strchr(id, ' '); |
---|
| 1091 | |
---|
| 1092 | if (!info) |
---|
| 1093 | return; |
---|
| 1094 | *info = '\0'; |
---|
| 1095 | info++; |
---|
| 1096 | |
---|
| 1097 | if (!strncmp(info, "ADDUSER ", 8)) { |
---|
| 1098 | struct skype_group *sg = skype_group_by_id(ic, atoi(id)); |
---|
| 1099 | |
---|
| 1100 | info += 8; |
---|
| 1101 | if (sg) { |
---|
| 1102 | char *buf = g_strdup_printf("%s@skype.com", info); |
---|
| 1103 | sg->users = g_list_append(sg->users, g_strdup(info)); |
---|
| 1104 | imcb_add_buddy(ic, buf, sg->name); |
---|
| 1105 | g_free(buf); |
---|
| 1106 | } else |
---|
| 1107 | log_message(LOGLVL_ERROR, |
---|
| 1108 | "No skype group with id %s. That's probably a bug.", id); |
---|
| 1109 | } |
---|
| 1110 | } |
---|
| 1111 | |
---|
[ff436ba] | 1112 | typedef void (*skype_parser)(struct im_connection *ic, char *line); |
---|
| 1113 | |
---|
[8c09bb3] | 1114 | static gboolean skype_read_callback(gpointer data, gint fd, |
---|
| 1115 | b_input_condition cond) |
---|
[1323e36] | 1116 | { |
---|
| 1117 | struct im_connection *ic = data; |
---|
| 1118 | struct skype_data *sd = ic->proto_data; |
---|
[c213d6b] | 1119 | char buf[IRC_LINE_SIZE]; |
---|
[ff436ba] | 1120 | int st, i; |
---|
[6e14204] | 1121 | char **lines, **lineptr, *line; |
---|
[ff436ba] | 1122 | static struct parse_map { |
---|
| 1123 | char *k; |
---|
| 1124 | skype_parser v; |
---|
| 1125 | } parsers[] = { |
---|
| 1126 | { "USERS ", skype_parse_users }, |
---|
| 1127 | { "USER ", skype_parse_user }, |
---|
| 1128 | { "CHATMESSAGE ", skype_parse_chatmessage }, |
---|
| 1129 | { "CALL ", skype_parse_call }, |
---|
| 1130 | { "FILETRANSFER ", skype_parse_filetransfer }, |
---|
| 1131 | { "CHAT ", skype_parse_chat }, |
---|
[89d6845] | 1132 | { "GROUP ", skype_parse_group }, |
---|
[ff436ba] | 1133 | { "PASSWORD ", skype_parse_password }, |
---|
| 1134 | { "PROFILE PSTN_BALANCE ", skype_parse_profile }, |
---|
| 1135 | { "PING", skype_parse_ping }, |
---|
| 1136 | { "CHATS ", skype_parse_chats }, |
---|
[8b8d1bed] | 1137 | { "GROUPS ", skype_parse_groups }, |
---|
[46e9822] | 1138 | { "ALTER GROUP ", skype_parse_alter_group }, |
---|
[ff436ba] | 1139 | }; |
---|
[1323e36] | 1140 | |
---|
[4ae3ffc] | 1141 | /* Unused parameters */ |
---|
| 1142 | fd = fd; |
---|
| 1143 | cond = cond; |
---|
| 1144 | |
---|
[5adcc65] | 1145 | if (!sd || sd->fd == -1) |
---|
[1323e36] | 1146 | return FALSE; |
---|
[7daec06] | 1147 | /* Read the whole data. */ |
---|
[5adcc65] | 1148 | st = ssl_read(sd->ssl, buf, sizeof(buf)); |
---|
| 1149 | if (st > 0) { |
---|
[1323e36] | 1150 | buf[st] = '\0'; |
---|
[7daec06] | 1151 | /* Then split it up to lines. */ |
---|
[9fd4241] | 1152 | lines = g_strsplit(buf, "\n", 0); |
---|
| 1153 | lineptr = lines; |
---|
[5adcc65] | 1154 | while ((line = *lineptr)) { |
---|
| 1155 | if (!strlen(line)) |
---|
[9fd4241] | 1156 | break; |
---|
[b820226] | 1157 | if (set_getbool(&ic->acc->set, "skypeconsole_receive")) |
---|
| 1158 | imcb_buddy_msg(ic, "skypeconsole", line, 0, 0); |
---|
[6b9d22a] | 1159 | for (i = 0; i < ARRAY_SIZE(parsers); i++) |
---|
| 1160 | if (!strncmp(line, parsers[i].k, |
---|
| 1161 | strlen(parsers[i].k))) { |
---|
[ff436ba] | 1162 | parsers[i].v(ic, line); |
---|
| 1163 | break; |
---|
| 1164 | } |
---|
[9fd4241] | 1165 | lineptr++; |
---|
| 1166 | } |
---|
| 1167 | g_strfreev(lines); |
---|
[5adcc65] | 1168 | } else if (st == 0 || (st < 0 && !sockerr_again())) { |
---|
[58b65b33] | 1169 | ssl_disconnect(sd->ssl); |
---|
[1323e36] | 1170 | sd->fd = -1; |
---|
[58b65b33] | 1171 | sd->ssl = NULL; |
---|
[1323e36] | 1172 | |
---|
[5adcc65] | 1173 | imcb_error(ic, "Error while reading from server"); |
---|
| 1174 | imc_logout(ic, TRUE); |
---|
[1323e36] | 1175 | return FALSE; |
---|
| 1176 | } |
---|
| 1177 | return TRUE; |
---|
| 1178 | } |
---|
| 1179 | |
---|
[5adcc65] | 1180 | gboolean skype_start_stream(struct im_connection *ic) |
---|
[f06e3ac] | 1181 | { |
---|
[1323e36] | 1182 | struct skype_data *sd = ic->proto_data; |
---|
[f06e3ac] | 1183 | int st; |
---|
| 1184 | |
---|
[5adcc65] | 1185 | if (!sd) |
---|
[1fb89e3] | 1186 | return FALSE; |
---|
| 1187 | |
---|
[5adcc65] | 1188 | if (sd->bfd <= 0) |
---|
[7670b02] | 1189 | sd->bfd = b_input_add(sd->fd, B_EV_IO_READ, |
---|
[8c09bb3] | 1190 | skype_read_callback, ic); |
---|
[1323e36] | 1191 | |
---|
[a0b206b] | 1192 | /* Log in */ |
---|
[1f4fc80] | 1193 | skype_printf(ic, "USERNAME %s\n", ic->acc->user); |
---|
| 1194 | skype_printf(ic, "PASSWORD %s\n", ic->acc->pass); |
---|
[a0b206b] | 1195 | |
---|
[8b8d1bed] | 1196 | /* This will download all buddies and groups. */ |
---|
[54ca269] | 1197 | st = skype_printf(ic, "SEARCH GROUPS CUSTOM\n"); |
---|
| 1198 | skype_printf(ic, "SEARCH FRIENDS\n"); |
---|
[8b8d1bed] | 1199 | |
---|
[1f4fc80] | 1200 | skype_printf(ic, "SET USERSTATUS ONLINE\n"); |
---|
[5acf9ab] | 1201 | |
---|
| 1202 | /* Auto join to bookmarked chats if requested.*/ |
---|
[1f4fc80] | 1203 | if (set_getbool(&ic->acc->set, "auto_join")) |
---|
| 1204 | skype_printf(ic, "SEARCH BOOKMARKEDCHATS\n"); |
---|
[f06e3ac] | 1205 | return st; |
---|
| 1206 | } |
---|
| 1207 | |
---|
[486ddb5] | 1208 | gboolean skype_connected(gpointer data, int returncode, void *source, b_input_condition cond) |
---|
[f06e3ac] | 1209 | { |
---|
| 1210 | struct im_connection *ic = data; |
---|
[c7304b2] | 1211 | struct skype_data *sd = ic->proto_data; |
---|
[4ae3ffc] | 1212 | |
---|
| 1213 | /* Unused parameter */ |
---|
| 1214 | cond = cond; |
---|
| 1215 | |
---|
[5adcc65] | 1216 | if (!source) { |
---|
[c7304b2] | 1217 | sd->ssl = NULL; |
---|
[5adcc65] | 1218 | imcb_error(ic, "Could not connect to server"); |
---|
| 1219 | imc_logout(ic, TRUE); |
---|
[c7304b2] | 1220 | return FALSE; |
---|
| 1221 | } |
---|
[5adcc65] | 1222 | imcb_log(ic, "Connected to server, logging in"); |
---|
[4ae3ffc] | 1223 | |
---|
[f06e3ac] | 1224 | return skype_start_stream(ic); |
---|
| 1225 | } |
---|
| 1226 | |
---|
[5adcc65] | 1227 | static void skype_login(account_t *acc) |
---|
[f06e3ac] | 1228 | { |
---|
[5adcc65] | 1229 | struct im_connection *ic = imcb_new(acc); |
---|
| 1230 | struct skype_data *sd = g_new0(struct skype_data, 1); |
---|
[f06e3ac] | 1231 | |
---|
| 1232 | ic->proto_data = sd; |
---|
| 1233 | |
---|
[5adcc65] | 1234 | imcb_log(ic, "Connecting"); |
---|
[8c09bb3] | 1235 | sd->ssl = ssl_connect(set_getstr(&acc->set, "server"), |
---|
[a72dc2b] | 1236 | set_getint(&acc->set, "port"), FALSE, skype_connected, ic); |
---|
[5adcc65] | 1237 | sd->fd = sd->ssl ? ssl_getfd(sd->ssl) : -1; |
---|
| 1238 | sd->username = g_strdup(acc->user); |
---|
[f06e3ac] | 1239 | |
---|
| 1240 | sd->ic = ic; |
---|
[08a355b] | 1241 | |
---|
| 1242 | if (set_getbool(&acc->set, "skypeconsole")) |
---|
| 1243 | imcb_add_buddy(ic, "skypeconsole", NULL); |
---|
[f06e3ac] | 1244 | } |
---|
| 1245 | |
---|
[5adcc65] | 1246 | static void skype_logout(struct im_connection *ic) |
---|
[f06e3ac] | 1247 | { |
---|
| 1248 | struct skype_data *sd = ic->proto_data; |
---|
[89d6845] | 1249 | int i; |
---|
[98bca36] | 1250 | |
---|
[1f4fc80] | 1251 | skype_printf(ic, "SET USERSTATUS OFFLINE\n"); |
---|
[98bca36] | 1252 | |
---|
[e1d6b38] | 1253 | while (ic->groupchats) |
---|
[bd11422] | 1254 | imcb_chat_free(ic->groupchats->data); |
---|
| 1255 | |
---|
[89d6845] | 1256 | for (i = 0; i < g_list_length(sd->groups); i++) { |
---|
| 1257 | struct skype_group *sg = (struct skype_group *)g_list_nth_data(sd->groups, i); |
---|
| 1258 | skype_group_free(sg, FALSE); |
---|
| 1259 | } |
---|
[58b65b33] | 1260 | |
---|
| 1261 | if (sd->ssl) |
---|
| 1262 | ssl_disconnect(sd->ssl); |
---|
| 1263 | |
---|
[a3d6427] | 1264 | g_free(sd->username); |
---|
[7613670] | 1265 | g_free(sd->handle); |
---|
[f06e3ac] | 1266 | g_free(sd); |
---|
[98bca36] | 1267 | ic->proto_data = NULL; |
---|
[f06e3ac] | 1268 | } |
---|
| 1269 | |
---|
[8c09bb3] | 1270 | static int skype_buddy_msg(struct im_connection *ic, char *who, char *message, |
---|
| 1271 | int flags) |
---|
[93ece66] | 1272 | { |
---|
[1f4fc80] | 1273 | char *ptr, *nick; |
---|
[93ece66] | 1274 | int st; |
---|
| 1275 | |
---|
[4ae3ffc] | 1276 | /* Unused parameter */ |
---|
| 1277 | flags = flags; |
---|
| 1278 | |
---|
[cbec0d6] | 1279 | nick = g_strdup(who); |
---|
[77c1abe] | 1280 | ptr = strchr(nick, '@'); |
---|
[5adcc65] | 1281 | if (ptr) |
---|
[0bb1b7f] | 1282 | *ptr = '\0'; |
---|
[93ece66] | 1283 | |
---|
[08a355b] | 1284 | if (!strncmp(who, "skypeconsole", 12)) |
---|
[1f4fc80] | 1285 | st = skype_printf(ic, "%s\n", message); |
---|
[08a355b] | 1286 | else |
---|
[1f4fc80] | 1287 | st = skype_printf(ic, "MESSAGE %s %s\n", nick, message); |
---|
[77c1abe] | 1288 | g_free(nick); |
---|
[93ece66] | 1289 | |
---|
| 1290 | return st; |
---|
| 1291 | } |
---|
| 1292 | |
---|
[5adcc65] | 1293 | const struct skype_away_state *skype_away_state_by_name(char *name) |
---|
[23411c6] | 1294 | { |
---|
| 1295 | int i; |
---|
| 1296 | |
---|
[5adcc65] | 1297 | for (i = 0; skype_away_state_list[i].full_name; i++) |
---|
| 1298 | if (g_strcasecmp(skype_away_state_list[i].full_name, name) == 0) |
---|
| 1299 | return skype_away_state_list + i; |
---|
[23411c6] | 1300 | |
---|
| 1301 | return NULL; |
---|
| 1302 | } |
---|
| 1303 | |
---|
[8c09bb3] | 1304 | static void skype_set_away(struct im_connection *ic, char *state_txt, |
---|
| 1305 | char *message) |
---|
[f06e3ac] | 1306 | { |
---|
[23411c6] | 1307 | const struct skype_away_state *state; |
---|
| 1308 | |
---|
[4ae3ffc] | 1309 | /* Unused parameter */ |
---|
| 1310 | message = message; |
---|
| 1311 | |
---|
[4b740c2] | 1312 | if (state_txt == NULL) |
---|
| 1313 | state = skype_away_state_by_name("Online"); |
---|
[23411c6] | 1314 | else |
---|
[5adcc65] | 1315 | state = skype_away_state_by_name(state_txt); |
---|
[1f4fc80] | 1316 | skype_printf(ic, "SET USERSTATUS %s\n", state->code); |
---|
[f06e3ac] | 1317 | } |
---|
| 1318 | |
---|
[5adcc65] | 1319 | static GList *skype_away_states(struct im_connection *ic) |
---|
[f06e3ac] | 1320 | { |
---|
[5adcc65] | 1321 | static GList *l; |
---|
[adce2de] | 1322 | int i; |
---|
[5adcc65] | 1323 | |
---|
[4ae3ffc] | 1324 | /* Unused parameter */ |
---|
| 1325 | ic = ic; |
---|
| 1326 | |
---|
[5adcc65] | 1327 | if (l == NULL) |
---|
| 1328 | for (i = 0; skype_away_state_list[i].full_name; i++) |
---|
[8c09bb3] | 1329 | l = g_list_append(l, |
---|
| 1330 | (void *)skype_away_state_list[i].full_name); |
---|
[5adcc65] | 1331 | |
---|
[f06e3ac] | 1332 | return l; |
---|
| 1333 | } |
---|
| 1334 | |
---|
[5adcc65] | 1335 | static char *skype_set_display_name(set_t *set, char *value) |
---|
[93dffea] | 1336 | { |
---|
| 1337 | account_t *acc = set->data; |
---|
| 1338 | struct im_connection *ic = acc->ic; |
---|
| 1339 | |
---|
[1f4fc80] | 1340 | skype_printf(ic, "SET PROFILE FULLNAME %s", value); |
---|
[5adcc65] | 1341 | return value; |
---|
[93dffea] | 1342 | } |
---|
| 1343 | |
---|
[7764fb1] | 1344 | static char *skype_set_mood_text(set_t *set, char *value) |
---|
| 1345 | { |
---|
| 1346 | account_t *acc = set->data; |
---|
| 1347 | struct im_connection *ic = acc->ic; |
---|
| 1348 | |
---|
| 1349 | skype_printf(ic, "SET PROFILE MOOD_TEXT %s", value); |
---|
| 1350 | return value; |
---|
| 1351 | } |
---|
| 1352 | |
---|
[5adcc65] | 1353 | static char *skype_set_balance(set_t *set, char *value) |
---|
[2af671a] | 1354 | { |
---|
| 1355 | account_t *acc = set->data; |
---|
| 1356 | struct im_connection *ic = acc->ic; |
---|
| 1357 | |
---|
[1f4fc80] | 1358 | skype_printf(ic, "GET PROFILE PSTN_BALANCE"); |
---|
[5adcc65] | 1359 | return value; |
---|
[2af671a] | 1360 | } |
---|
| 1361 | |
---|
[fbb15f2] | 1362 | static void skype_call(struct im_connection *ic, char *value) |
---|
| 1363 | { |
---|
[71c4bb6] | 1364 | char *nick = g_strdup(value); |
---|
| 1365 | char *ptr = strchr(nick, '@'); |
---|
| 1366 | |
---|
| 1367 | if (ptr) |
---|
| 1368 | *ptr = '\0'; |
---|
| 1369 | skype_printf(ic, "CALL %s", nick); |
---|
| 1370 | g_free(nick); |
---|
| 1371 | } |
---|
| 1372 | |
---|
| 1373 | static void skype_hangup(struct im_connection *ic) |
---|
| 1374 | { |
---|
| 1375 | struct skype_data *sd = ic->proto_data; |
---|
| 1376 | |
---|
| 1377 | if (sd->call_id) { |
---|
| 1378 | skype_printf(ic, "SET CALL %s STATUS FINISHED", |
---|
| 1379 | sd->call_id); |
---|
| 1380 | g_free(sd->call_id); |
---|
| 1381 | sd->call_id = 0; |
---|
| 1382 | } else |
---|
| 1383 | imcb_error(ic, "There are no active calls currently."); |
---|
| 1384 | } |
---|
| 1385 | |
---|
[5adcc65] | 1386 | static char *skype_set_call(set_t *set, char *value) |
---|
[b68b023] | 1387 | { |
---|
| 1388 | account_t *acc = set->data; |
---|
| 1389 | struct im_connection *ic = acc->ic; |
---|
| 1390 | |
---|
[fbb15f2] | 1391 | if (value) |
---|
[451f121] | 1392 | skype_call(ic, value); |
---|
[fbb15f2] | 1393 | else |
---|
[71c4bb6] | 1394 | skype_hangup(ic); |
---|
[5adcc65] | 1395 | return value; |
---|
[b68b023] | 1396 | } |
---|
| 1397 | |
---|
[5adcc65] | 1398 | static void skype_add_buddy(struct im_connection *ic, char *who, char *group) |
---|
[f06e3ac] | 1399 | { |
---|
[46641bf] | 1400 | struct skype_data *sd = ic->proto_data; |
---|
[1f4fc80] | 1401 | char *nick, *ptr; |
---|
[6627d92] | 1402 | |
---|
[cbec0d6] | 1403 | nick = g_strdup(who); |
---|
[6627d92] | 1404 | ptr = strchr(nick, '@'); |
---|
[5adcc65] | 1405 | if (ptr) |
---|
[6627d92] | 1406 | *ptr = '\0'; |
---|
[46e9822] | 1407 | |
---|
| 1408 | if (!group) { |
---|
| 1409 | skype_printf(ic, "SET USER %s BUDDYSTATUS 2 Please authorize me\n", |
---|
| 1410 | nick); |
---|
| 1411 | g_free(nick); |
---|
| 1412 | } else { |
---|
| 1413 | struct skype_group *sg = skype_group_by_name(ic, group); |
---|
| 1414 | |
---|
| 1415 | if (!sg) { |
---|
| 1416 | /* No such group, we need to create it, then have to |
---|
| 1417 | * add the user once it's created. */ |
---|
[46641bf] | 1418 | skype_printf(ic, "CREATE GROUP %s", group); |
---|
| 1419 | sd->pending_user = g_strdup(nick); |
---|
[46e9822] | 1420 | } else { |
---|
| 1421 | skype_printf(ic, "ALTER GROUP %d ADDUSER %s", sg->id, nick); |
---|
| 1422 | } |
---|
| 1423 | } |
---|
[f06e3ac] | 1424 | } |
---|
| 1425 | |
---|
[5adcc65] | 1426 | static void skype_remove_buddy(struct im_connection *ic, char *who, char *group) |
---|
[f06e3ac] | 1427 | { |
---|
[1f4fc80] | 1428 | char *nick, *ptr; |
---|
[6627d92] | 1429 | |
---|
[4ae3ffc] | 1430 | /* Unused parameter */ |
---|
| 1431 | group = group; |
---|
| 1432 | |
---|
[cbec0d6] | 1433 | nick = g_strdup(who); |
---|
[6627d92] | 1434 | ptr = strchr(nick, '@'); |
---|
[5adcc65] | 1435 | if (ptr) |
---|
[6627d92] | 1436 | *ptr = '\0'; |
---|
[1f4fc80] | 1437 | skype_printf(ic, "SET USER %s BUDDYSTATUS 1\n", nick); |
---|
[6627d92] | 1438 | g_free(nick); |
---|
[f06e3ac] | 1439 | } |
---|
| 1440 | |
---|
[5adcc65] | 1441 | void skype_chat_msg(struct groupchat *gc, char *message, int flags) |
---|
[66c9558] | 1442 | { |
---|
[79e20f9] | 1443 | struct im_connection *ic = gc->ic; |
---|
[4ae3ffc] | 1444 | |
---|
| 1445 | /* Unused parameter */ |
---|
| 1446 | flags = flags; |
---|
| 1447 | |
---|
[1f4fc80] | 1448 | skype_printf(ic, "CHATMESSAGE %s %s\n", gc->title, message); |
---|
[66c9558] | 1449 | } |
---|
| 1450 | |
---|
[5adcc65] | 1451 | void skype_chat_leave(struct groupchat *gc) |
---|
[b01dc6c] | 1452 | { |
---|
| 1453 | struct im_connection *ic = gc->ic; |
---|
[1f4fc80] | 1454 | skype_printf(ic, "ALTER CHAT %s LEAVE\n", gc->title); |
---|
[5adcc65] | 1455 | gc->data = (void *)TRUE; |
---|
[760319d] | 1456 | } |
---|
| 1457 | |
---|
| 1458 | void skype_chat_invite(struct groupchat *gc, char *who, char *message) |
---|
| 1459 | { |
---|
| 1460 | struct im_connection *ic = gc->ic; |
---|
[1f4fc80] | 1461 | char *ptr, *nick; |
---|
[4ae3ffc] | 1462 | |
---|
[17dd2ed] | 1463 | nick = g_strdup(who); |
---|
[760319d] | 1464 | ptr = strchr(nick, '@'); |
---|
[5adcc65] | 1465 | if (ptr) |
---|
[760319d] | 1466 | *ptr = '\0'; |
---|
[1f4fc80] | 1467 | skype_printf(ic, "ALTER CHAT %s ADDMEMBERS %s\n", gc->title, nick); |
---|
[760319d] | 1468 | g_free(nick); |
---|
[b01dc6c] | 1469 | } |
---|
| 1470 | |
---|
[09e2a69] | 1471 | void skype_chat_topic(struct groupchat *gc, char *message) |
---|
| 1472 | { |
---|
| 1473 | struct im_connection *ic = gc->ic; |
---|
[a5f76a2] | 1474 | struct skype_data *sd = ic->proto_data; |
---|
[1f4fc80] | 1475 | skype_printf(ic, "ALTER CHAT %s SETTOPIC %s\n", |
---|
[8c09bb3] | 1476 | gc->title, message); |
---|
[a5f76a2] | 1477 | sd->topic_wait = 1; |
---|
[09e2a69] | 1478 | } |
---|
| 1479 | |
---|
[86278cd] | 1480 | struct groupchat *skype_chat_with(struct im_connection *ic, char *who) |
---|
| 1481 | { |
---|
| 1482 | struct skype_data *sd = ic->proto_data; |
---|
[1f4fc80] | 1483 | char *ptr, *nick; |
---|
[86278cd] | 1484 | nick = g_strdup(who); |
---|
| 1485 | ptr = strchr(nick, '@'); |
---|
[5adcc65] | 1486 | if (ptr) |
---|
[86278cd] | 1487 | *ptr = '\0'; |
---|
[1f4fc80] | 1488 | skype_printf(ic, "CHAT CREATE %s\n", nick); |
---|
[86278cd] | 1489 | sd->groupchat_with = g_strdup(nick); |
---|
| 1490 | g_free(nick); |
---|
[5652d43] | 1491 | /* We create a fake chat for now. We will replace it with a real one in |
---|
| 1492 | * the real callback. */ |
---|
[5adcc65] | 1493 | return imcb_chat_new(ic, ""); |
---|
[86278cd] | 1494 | } |
---|
| 1495 | |
---|
[67454bd] | 1496 | static void skype_get_info(struct im_connection *ic, char *who) |
---|
| 1497 | { |
---|
[1f4fc80] | 1498 | char *ptr, *nick; |
---|
[67454bd] | 1499 | nick = g_strdup(who); |
---|
| 1500 | ptr = strchr(nick, '@'); |
---|
[5adcc65] | 1501 | if (ptr) |
---|
[67454bd] | 1502 | *ptr = '\0'; |
---|
[1f4fc80] | 1503 | skype_printf(ic, "GET USER %s FULLNAME\n", nick); |
---|
| 1504 | skype_printf(ic, "GET USER %s PHONE_HOME\n", nick); |
---|
| 1505 | skype_printf(ic, "GET USER %s PHONE_OFFICE\n", nick); |
---|
| 1506 | skype_printf(ic, "GET USER %s PHONE_MOBILE\n", nick); |
---|
| 1507 | skype_printf(ic, "GET USER %s NROF_AUTHED_BUDDIES\n", nick); |
---|
| 1508 | skype_printf(ic, "GET USER %s TIMEZONE\n", nick); |
---|
| 1509 | skype_printf(ic, "GET USER %s LASTONLINETIMESTAMP\n", nick); |
---|
| 1510 | skype_printf(ic, "GET USER %s SEX\n", nick); |
---|
| 1511 | skype_printf(ic, "GET USER %s LANGUAGE\n", nick); |
---|
| 1512 | skype_printf(ic, "GET USER %s COUNTRY\n", nick); |
---|
| 1513 | skype_printf(ic, "GET USER %s PROVINCE\n", nick); |
---|
| 1514 | skype_printf(ic, "GET USER %s CITY\n", nick); |
---|
| 1515 | skype_printf(ic, "GET USER %s HOMEPAGE\n", nick); |
---|
| 1516 | skype_printf(ic, "GET USER %s ABOUT\n", nick); |
---|
[85341dd] | 1517 | /* |
---|
| 1518 | * Hack: we query the bithday property which is always a single line, |
---|
| 1519 | * so we can send the collected properties to the user when we have |
---|
| 1520 | * this one. |
---|
| 1521 | */ |
---|
| 1522 | skype_printf(ic, "GET USER %s BIRTHDAY\n", nick); |
---|
[67454bd] | 1523 | } |
---|
| 1524 | |
---|
[5adcc65] | 1525 | static void skype_set_my_name(struct im_connection *ic, char *info) |
---|
[93dffea] | 1526 | { |
---|
[5adcc65] | 1527 | skype_set_display_name(set_find(&ic->acc->set, "display_name"), info); |
---|
[93dffea] | 1528 | } |
---|
| 1529 | |
---|
[5adcc65] | 1530 | static void skype_init(account_t *acc) |
---|
[93dffea] | 1531 | { |
---|
| 1532 | set_t *s; |
---|
| 1533 | |
---|
[8c09bb3] | 1534 | s = set_add(&acc->set, "server", SKYPE_DEFAULT_SERVER, set_eval_account, |
---|
| 1535 | acc); |
---|
[93dffea] | 1536 | s->flags |= ACC_SET_OFFLINE_ONLY; |
---|
| 1537 | |
---|
[5adcc65] | 1538 | s = set_add(&acc->set, "port", SKYPE_DEFAULT_PORT, set_eval_int, acc); |
---|
[93dffea] | 1539 | s->flags |= ACC_SET_OFFLINE_ONLY; |
---|
| 1540 | |
---|
[8c09bb3] | 1541 | s = set_add(&acc->set, "display_name", NULL, skype_set_display_name, |
---|
| 1542 | acc); |
---|
[93dffea] | 1543 | s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY; |
---|
[b68b023] | 1544 | |
---|
[7764fb1] | 1545 | s = set_add(&acc->set, "mood_text", NULL, skype_set_mood_text, acc); |
---|
| 1546 | s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY; |
---|
| 1547 | |
---|
[5adcc65] | 1548 | s = set_add(&acc->set, "call", NULL, skype_set_call, acc); |
---|
[b68b023] | 1549 | s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY; |
---|
[2af671a] | 1550 | |
---|
[5adcc65] | 1551 | s = set_add(&acc->set, "balance", NULL, skype_set_balance, acc); |
---|
[2af671a] | 1552 | s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY; |
---|
[bd417a1] | 1553 | |
---|
[5adcc65] | 1554 | s = set_add(&acc->set, "skypeout_offline", "true", set_eval_bool, acc); |
---|
[08a355b] | 1555 | |
---|
[5adcc65] | 1556 | s = set_add(&acc->set, "skypeconsole", "false", set_eval_bool, acc); |
---|
[08a355b] | 1557 | s->flags |= ACC_SET_OFFLINE_ONLY; |
---|
[5acf9ab] | 1558 | |
---|
[8c09bb3] | 1559 | s = set_add(&acc->set, "skypeconsole_receive", "false", set_eval_bool, |
---|
| 1560 | acc); |
---|
[b820226] | 1561 | s->flags |= ACC_SET_OFFLINE_ONLY; |
---|
| 1562 | |
---|
[5adcc65] | 1563 | s = set_add(&acc->set, "auto_join", "false", set_eval_bool, acc); |
---|
[5acf9ab] | 1564 | s->flags |= ACC_SET_OFFLINE_ONLY; |
---|
[f4d37c6] | 1565 | |
---|
[49a3c02] | 1566 | s = set_add(&acc->set, "test_join", "false", set_eval_bool, acc); |
---|
| 1567 | s->flags |= ACC_SET_OFFLINE_ONLY; |
---|
| 1568 | |
---|
[304aa33] | 1569 | s = set_add(&acc->set, "show_moods", "false", set_eval_bool, acc); |
---|
| 1570 | |
---|
[f4d37c6] | 1571 | s = set_add(&acc->set, "edit_prefix", "EDIT:", |
---|
[1e3120f] | 1572 | NULL, acc); |
---|
[3c7af69] | 1573 | |
---|
| 1574 | s = set_add(&acc->set, "read_groups", "false", set_eval_bool, acc); |
---|
[93dffea] | 1575 | } |
---|
| 1576 | |
---|
[c6e0218] | 1577 | #if BITLBEE_VERSION_CODE > BITLBEE_VER(3, 0, 1) |
---|
[fbb15f2] | 1578 | GList *skype_buddy_action_list(bee_user_t *bu) |
---|
[71c4bb6] | 1579 | { |
---|
[fbb15f2] | 1580 | static GList *ret; |
---|
[71c4bb6] | 1581 | |
---|
[a5e6aa1] | 1582 | /* Unused parameter */ |
---|
| 1583 | bu = bu; |
---|
| 1584 | |
---|
[fbb15f2] | 1585 | if (ret == NULL) { |
---|
[71c4bb6] | 1586 | static const struct buddy_action ba[3] = { |
---|
| 1587 | {"CALL", "Initiate a call" }, |
---|
| 1588 | {"HANGUP", "Hang up a call" }, |
---|
| 1589 | }; |
---|
| 1590 | |
---|
[fbb15f2] | 1591 | ret = g_list_prepend(ret, (void *) ba + 0); |
---|
[71c4bb6] | 1592 | } |
---|
| 1593 | |
---|
| 1594 | return ret; |
---|
| 1595 | } |
---|
| 1596 | |
---|
[fbb15f2] | 1597 | void *skype_buddy_action(struct bee_user *bu, const char *action, char * const args[], void *data) |
---|
[71c4bb6] | 1598 | { |
---|
[a5e6aa1] | 1599 | /* Unused parameters */ |
---|
| 1600 | args = args; |
---|
| 1601 | data = data; |
---|
| 1602 | |
---|
[fbb15f2] | 1603 | if (!g_strcasecmp(action, "CALL")) |
---|
[71c4bb6] | 1604 | skype_call(bu->ic, bu->handle); |
---|
[fbb15f2] | 1605 | else if (!g_strcasecmp(action, "HANGUP")) |
---|
[71c4bb6] | 1606 | skype_hangup(bu->ic); |
---|
| 1607 | |
---|
| 1608 | return NULL; |
---|
| 1609 | } |
---|
| 1610 | #endif |
---|
| 1611 | |
---|
[f06e3ac] | 1612 | void init_plugin(void) |
---|
| 1613 | { |
---|
[5adcc65] | 1614 | struct prpl *ret = g_new0(struct prpl, 1); |
---|
[f06e3ac] | 1615 | |
---|
| 1616 | ret->name = "skype"; |
---|
| 1617 | ret->login = skype_login; |
---|
| 1618 | ret->init = skype_init; |
---|
| 1619 | ret->logout = skype_logout; |
---|
[93ece66] | 1620 | ret->buddy_msg = skype_buddy_msg; |
---|
[67454bd] | 1621 | ret->get_info = skype_get_info; |
---|
[93dffea] | 1622 | ret->set_my_name = skype_set_my_name; |
---|
[f06e3ac] | 1623 | ret->away_states = skype_away_states; |
---|
[7daec06] | 1624 | ret->set_away = skype_set_away; |
---|
[f06e3ac] | 1625 | ret->add_buddy = skype_add_buddy; |
---|
| 1626 | ret->remove_buddy = skype_remove_buddy; |
---|
[66c9558] | 1627 | ret->chat_msg = skype_chat_msg; |
---|
[b01dc6c] | 1628 | ret->chat_leave = skype_chat_leave; |
---|
[760319d] | 1629 | ret->chat_invite = skype_chat_invite; |
---|
[86278cd] | 1630 | ret->chat_with = skype_chat_with; |
---|
[f06e3ac] | 1631 | ret->handle_cmp = g_strcasecmp; |
---|
[09e2a69] | 1632 | ret->chat_topic = skype_chat_topic; |
---|
[c6e0218] | 1633 | #if BITLBEE_VERSION_CODE > BITLBEE_VER(3, 0, 1) |
---|
[71c4bb6] | 1634 | ret->buddy_action_list = skype_buddy_action_list; |
---|
| 1635 | ret->buddy_action = skype_buddy_action; |
---|
| 1636 | #endif |
---|
[5adcc65] | 1637 | register_protocol(ret); |
---|
[f06e3ac] | 1638 | } |
---|