source: skype/skype.c @ 77aa416

Last change on this file since 77aa416 was 4ae3ffc, checked in by Miklos Vajna <vmiklos@…>, at 2010-12-08T03:22:04Z

silence -Wunused-parameter warnings

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