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