source: skype/skype.c @ 62f51ee9

Last change on this file since 62f51ee9 was 62f51ee9, checked in by Miklos Vajna <vmiklos@…>, at 2009-01-07T02:29:07Z

last whitespace fixes

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