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