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