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