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