source: skype/skype.c @ ff436ba

Last change on this file since ff436ba was ff436ba, checked in by Miklos Vajna <vmiklos@…>, at 2009-01-07T01:56:18Z

introduce the parse_map struct

  • Property mode set to 100644
File size: 34.4 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") || !set_getbool(&ic->acc->set, "skypeout_offline")))
310                        flags |= OPT_LOGGED_IN;
311                if (strcmp(status, "ONLINE") != 0 && strcmp(status, "SKYPEME") != 0)
312                        flags |= OPT_AWAY;
313                imcb_buddy_status(ic, ptr, flags, NULL, NULL);
314                g_free(ptr);
315        } else if (!strncmp(ptr, "RECEIVEDAUTHREQUEST ", 20)) {
316                char *message = ptr + 20;
317                if (strlen(message))
318                        skype_buddy_ask(ic, user, message);
319        } else if (!strncmp(ptr, "BUDDYSTATUS ", 12)) {
320                char *st = ptr + 12;
321                if (!strcmp(st, "3")) {
322                        char *buf = g_strdup_printf("%s@skype.com", user);
323                        imcb_add_buddy(ic, buf, NULL);
324                        g_free(buf);
325                }
326        } else if (!strncmp(ptr, "FULLNAME ", 9))
327                sd->info_fullname = g_strdup_printf("%s", ptr + 9);
328        else if (!strncmp(ptr, "PHONE_HOME ", 11))
329                sd->info_phonehome = g_strdup_printf("%s", ptr + 11);
330        else if (!strncmp(ptr, "PHONE_OFFICE ", 13))
331                sd->info_phoneoffice = g_strdup_printf("%s", ptr + 13);
332        else if (!strncmp(ptr, "PHONE_MOBILE ", 13))
333                sd->info_phonemobile = g_strdup_printf("%s", ptr + 13);
334        else if (!strncmp(ptr, "NROF_AUTHED_BUDDIES ", 20))
335                sd->info_nrbuddies = g_strdup_printf("%s", ptr + 20);
336        else if (!strncmp(ptr, "TIMEZONE ", 9))
337                sd->info_tz = g_strdup_printf("%s", ptr + 9);
338        else if (!strncmp(ptr, "LASTONLINETIMESTAMP ", 20))
339                sd->info_seen = g_strdup_printf("%s", ptr + 20);
340        else if (!strncmp(ptr, "BIRTHDAY ", 9))
341                sd->info_birthday = g_strdup_printf("%s", ptr + 9);
342        else if (!strncmp(ptr, "SEX ", 4))
343                sd->info_sex = g_strdup_printf("%s", ptr + 4);
344        else if (!strncmp(ptr, "LANGUAGE ", 9))
345                sd->info_language = g_strdup_printf("%s", ptr + 9);
346        else if (!strncmp(ptr, "COUNTRY ", 8))
347                sd->info_country = g_strdup_printf("%s", ptr + 8);
348        else if (!strncmp(ptr, "PROVINCE ", 9))
349                sd->info_province = g_strdup_printf("%s", ptr + 9);
350        else if (!strncmp(ptr, "CITY ", 5))
351                sd->info_city = g_strdup_printf("%s", ptr + 5);
352        else if (!strncmp(ptr, "HOMEPAGE ", 9))
353                sd->info_homepage = g_strdup_printf("%s", ptr + 9);
354        else if (!strncmp(ptr, "ABOUT ", 6)) {
355                sd->info_about = g_strdup_printf("%s", ptr + 6);
356
357                GString *st = g_string_new("Contact Information\n");
358                g_string_append_printf(st, "Skype Name: %s\n", user);
359                if (sd->info_fullname) {
360                        if (strlen(sd->info_fullname))
361                                g_string_append_printf(st, "Full Name: %s\n", sd->info_fullname);
362                        g_free(sd->info_fullname);
363                }
364                if (sd->info_phonehome) {
365                        if (strlen(sd->info_phonehome))
366                                g_string_append_printf(st, "Home Phone: %s\n", sd->info_phonehome);
367                        g_free(sd->info_phonehome);
368                }
369                if (sd->info_phoneoffice) {
370                        if (strlen(sd->info_phoneoffice))
371                                g_string_append_printf(st, "Office Phone: %s\n", sd->info_phoneoffice);
372                        g_free(sd->info_phoneoffice);
373                }
374                if (sd->info_phonemobile) {
375                        if (strlen(sd->info_phonemobile))
376                                g_string_append_printf(st, "Mobile Phone: %s\n", sd->info_phonemobile);
377                        g_free(sd->info_phonemobile);
378                }
379                g_string_append_printf(st, "Personal Information\n");
380                if (sd->info_nrbuddies) {
381                        if (strlen(sd->info_nrbuddies))
382                                g_string_append_printf(st, "Contacts: %s\n", sd->info_nrbuddies);
383                        g_free(sd->info_nrbuddies);
384                }
385                if (sd->info_tz) {
386                        if (strlen(sd->info_tz)) {
387                                char ib[256];
388                                time_t t = time(NULL);
389                                t += atoi(sd->info_tz)-(60*60*24);
390                                struct tm *gt = gmtime(&t);
391                                strftime(ib, 256, "%H:%M:%S", gt);
392                                g_string_append_printf(st, "Local Time: %s\n", ib);
393                        }
394                        g_free(sd->info_tz);
395                }
396                if (sd->info_seen) {
397                        if (strlen(sd->info_seen)) {
398                                char ib[256];
399                                time_t it = atoi(sd->info_seen);
400                                struct tm *tm = localtime(&it);
401                                strftime(ib, 256, ("%Y. %m. %d. %H:%M"), tm);
402                                g_string_append_printf(st, "Last Seen: %s\n", ib);
403                        }
404                        g_free(sd->info_seen);
405                }
406                if (sd->info_birthday) {
407                        if (strlen(sd->info_birthday) && strcmp(sd->info_birthday, "0")) {
408                                char ib[256];
409                                struct tm tm;
410                                strptime(sd->info_birthday, "%Y%m%d", &tm);
411                                strftime(ib, 256, "%B %d, %Y", &tm);
412                                g_string_append_printf(st, "Birthday: %s\n", ib);
413
414                                strftime(ib, 256, "%Y", &tm);
415                                int year = atoi(ib);
416                                time_t t = time(NULL);
417                                struct tm *lt = localtime(&t);
418                                g_string_append_printf(st, "Age: %d\n", lt->tm_year+1900-year);
419                        }
420                        g_free(sd->info_birthday);
421                }
422                if (sd->info_sex) {
423                        if (strlen(sd->info_sex)) {
424                                char *iptr = sd->info_sex;
425                                while (*iptr++)
426                                        *iptr = tolower(*iptr);
427                                g_string_append_printf(st, "Gender: %s\n", sd->info_sex);
428                        }
429                        g_free(sd->info_sex);
430                }
431                if (sd->info_language) {
432                        if (strlen(sd->info_language)) {
433                                char *iptr = strchr(sd->info_language, ' ');
434                                if (iptr)
435                                        iptr++;
436                                else
437                                        iptr = sd->info_language;
438                                g_string_append_printf(st, "Language: %s\n", iptr);
439                        }
440                        g_free(sd->info_language);
441                }
442                if (sd->info_country) {
443                        if (strlen(sd->info_country)) {
444                                char *iptr = strchr(sd->info_country, ' ');
445                                if (iptr)
446                                        iptr++;
447                                else
448                                        iptr = sd->info_country;
449                                g_string_append_printf(st, "Country: %s\n", iptr);
450                        }
451                        g_free(sd->info_country);
452                }
453                if (sd->info_province) {
454                        if (strlen(sd->info_province))
455                                g_string_append_printf(st, "Region: %s\n", sd->info_province);
456                        g_free(sd->info_province);
457                }
458                if (sd->info_city) {
459                        if (strlen(sd->info_city))
460                                g_string_append_printf(st, "City: %s\n", sd->info_city);
461                        g_free(sd->info_city);
462                }
463                if (sd->info_homepage) {
464                        if (strlen(sd->info_homepage))
465                                g_string_append_printf(st, "Homepage: %s\n", sd->info_homepage);
466                        g_free(sd->info_homepage);
467                }
468                if (sd->info_about) {
469                        if (strlen(sd->info_about))
470                                g_string_append_printf(st, "%s\n", sd->info_about);
471                        g_free(sd->info_about);
472                }
473                imcb_log(ic, "%s", st->str);
474                g_string_free(st, TRUE);
475        }
476}
477
478static void skype_parse_chatmessage(struct im_connection *ic, char *line)
479{
480        struct skype_data *sd = ic->proto_data;
481        char buf[1024];
482        char *id = strchr(line, ' ');
483
484        if (++id) {
485                char *info = strchr(id, ' ');
486
487                if (!info)
488                        return;
489                *info = '\0';
490                info++;
491                if (!strcmp(info, "STATUS RECEIVED")) {
492                        /* New message ID:
493                         * (1) Request its from field
494                         * (2) Request its body
495                         * (3) Request its type
496                         * (4) Query chatname
497                         */
498                        g_snprintf(buf, 1024, "GET CHATMESSAGE %s FROM_HANDLE\n", id);
499                        skype_write(ic, buf);
500                        g_snprintf(buf, 1024, "GET CHATMESSAGE %s BODY\n", id);
501                        skype_write(ic, buf);
502                        g_snprintf(buf, 1024, "GET CHATMESSAGE %s TYPE\n", id);
503                        skype_write(ic, buf);
504                        g_snprintf(buf, 1024, "GET CHATMESSAGE %s CHATNAME\n", id);
505                        skype_write(ic, buf);
506                } else if (!strncmp(info, "FROM_HANDLE ", 12)) {
507                        info += 12;
508                        /* New from field value. Store
509                         * it, then we can later use it
510                         * when we got the message's
511                         * body. */
512                        g_free(sd->handle);
513                        sd->handle = g_strdup_printf("%s@skype.com", info);
514                } else if (!strncmp(info, "EDITED_BY ", 10)) {
515                        info += 10;
516                        /* This is the same as
517                         * FROM_HANDLE, except that we
518                         * never request these lines
519                         * from Skype, we just get
520                         * them. */
521                        g_free(sd->handle);
522                        sd->handle = g_strdup_printf("%s@skype.com", info);
523                } else if (!strncmp(info, "BODY ", 5)) {
524                        info += 5;
525                        sd->body = g_list_append(sd->body, g_strdup(info));
526                }       else if (!strncmp(info, "TYPE ", 5)) {
527                        info += 5;
528                        g_free(sd->type);
529                        sd->type = g_strdup(info);
530                } else if (!strncmp(info, "CHATNAME ", 9)) {
531                        info += 9;
532                        if (sd->handle && sd->body && sd->type) {
533                                struct groupchat *gc = skype_chat_by_name(ic, info);
534                                int i;
535                                for (i = 0; i < g_list_length(sd->body); i++) {
536                                        char *body = g_list_nth_data(sd->body, i);
537                                        if (!strcmp(sd->type, "SAID") || !strcmp(sd->type, "EMOTED")) {
538                                                if (!strcmp(sd->type, "SAID"))
539                                                        g_snprintf(buf, 1024, "%s", body);
540                                                else
541                                                        g_snprintf(buf, 1024, "/me %s", body);
542                                                if (!gc)
543                                                        /* Private message */
544                                                        imcb_buddy_msg(ic, sd->handle, buf, 0, 0);
545                                                else
546                                                        /* Groupchat message */
547                                                        imcb_chat_msg(gc, sd->handle, buf, 0, 0);
548                                        } else if (!strcmp(sd->type, "SETTOPIC")) {
549                                                if (gc)
550                                                        imcb_chat_topic(gc, sd->handle, body, 0);
551                                        } else if (!strcmp(sd->type, "LEFT")) {
552                                                if (gc)
553                                                        imcb_chat_remove_buddy(gc, sd->handle, NULL);
554                                        }
555                                }
556                                g_list_free(sd->body);
557                                sd->body = NULL;
558                        }
559                }
560        }
561}
562
563static void skype_parse_call(struct im_connection *ic, char *line)
564{
565        struct skype_data *sd = ic->proto_data;
566        char *id = strchr(line, ' ');
567        char buf[1024];
568
569        if (++id) {
570                char *info = strchr(id, ' ');
571
572                if (!info)
573                        return;
574                *info = '\0';
575                info++;
576                if (!strncmp(info, "FAILUREREASON ", 14))
577                        sd->failurereason = atoi(strchr(info, ' '));
578                else if (!strcmp(info, "STATUS RINGING")) {
579                        if (sd->call_id)
580                                g_free(sd->call_id);
581                        sd->call_id = g_strdup(id);
582                        g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id);
583                        skype_write(ic, buf);
584                        sd->call_status = SKYPE_CALL_RINGING;
585                } else if (!strcmp(info, "STATUS MISSED")) {
586                        g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id);
587                        skype_write(ic, buf);
588                        sd->call_status = SKYPE_CALL_MISSED;
589                } else if (!strcmp(info, "STATUS CANCELLED")) {
590                        g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id);
591                        skype_write(ic, buf);
592                        sd->call_status = SKYPE_CALL_CANCELLED;
593                } else if (!strcmp(info, "STATUS FINISHED")) {
594                        g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id);
595                        skype_write(ic, buf);
596                        sd->call_status = SKYPE_CALL_FINISHED;
597                } else if (!strcmp(info, "STATUS REFUSED")) {
598                        g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id);
599                        skype_write(ic, buf);
600                        sd->call_status = SKYPE_CALL_REFUSED;
601                } else if (!strcmp(info, "STATUS UNPLACED")) {
602                        if (sd->call_id)
603                                g_free(sd->call_id);
604                        /* Save the ID for later usage (Cancel/Finish). */
605                        sd->call_id = g_strdup(id);
606                        sd->call_out = TRUE;
607                } else if (!strcmp(info, "STATUS FAILED")) {
608                        imcb_error(ic, "Call failed: %s", skype_call_strerror(sd->failurereason));
609                        sd->call_id = NULL;
610                } else if (!strncmp(info, "DURATION ", 9)) {
611                        if (sd->call_duration)
612                                g_free(sd->call_duration);
613                        sd->call_duration = g_strdup(info+9);
614                } else if (!strncmp(info, "PARTNER_HANDLE ", 15)) {
615                        info += 15;
616                        if (sd->call_status) {
617                                switch (sd->call_status) {
618                                        case SKYPE_CALL_RINGING:
619                                                if (sd->call_out)
620                                                        imcb_log(ic, "You are currently ringing the user %s.", info);
621                                                else {
622                                                        g_snprintf(buf, 1024, "The user %s is currently ringing you.", info);
623                                                        skype_call_ask(ic, sd->call_id, buf);
624                                                }
625                                                break;
626                                        case SKYPE_CALL_MISSED:
627                                                imcb_log(ic, "You have missed a call from user %s.", info);
628                                                break;
629                                        case SKYPE_CALL_CANCELLED:
630                                                imcb_log(ic, "You cancelled the call to the user %s.", info);
631                                                sd->call_status = 0;
632                                                sd->call_out = FALSE;
633                                                break;
634                                        case SKYPE_CALL_REFUSED:
635                                                if (sd->call_out)
636                                                        imcb_log(ic, "The user %s refused the call.", info);
637                                                else
638                                                        imcb_log(ic, "You refused the call from user %s.", info);
639                                                sd->call_out = FALSE;
640                                                break;
641                                        case SKYPE_CALL_FINISHED:
642                                                if (sd->call_duration)
643                                                        imcb_log(ic, "You finished the call to the user %s (duration: %s seconds).", info, sd->call_duration);
644                                                else
645                                                        imcb_log(ic, "You finished the call to the user %s.", info);
646                                                sd->call_out = FALSE;
647                                                break;
648                                        default:
649                                                /* Don't be noisy, ignore other statuses for now. */
650                                                break;
651                                }
652                                sd->call_status = 0;
653                        }
654                }
655        }
656}
657
658static void skype_parse_filetransfer(struct im_connection *ic, char *line)
659{
660        struct skype_data *sd = ic->proto_data;
661        char buf[1024];
662        char *id = strchr(line, ' ');
663
664        if (++id) {
665                char *info = strchr(id, ' ');
666
667                if (!info)
668                        return;
669                *info = '\0';
670                info++;
671                if (!strcmp(info, "STATUS NEW")) {
672                        g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n", id);
673                        skype_write(ic, buf);
674                        sd->filetransfer_status = SKYPE_FILETRANSFER_NEW;
675                } else if (!strcmp(info, "STATUS FAILED")) {
676                        g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n", id);
677                        skype_write(ic, buf);
678                        sd->filetransfer_status = SKYPE_FILETRANSFER_FAILED;
679                } else if (!strncmp(info, "PARTNER_HANDLE ", 15)) {
680                        info += 15;
681                        if (sd->filetransfer_status) {
682                                switch (sd->filetransfer_status) {
683                                        case SKYPE_FILETRANSFER_NEW:
684                                                imcb_log(ic, "The user %s offered a new file for you.", info);
685                                                break;
686                                        case SKYPE_FILETRANSFER_FAILED:
687                                                imcb_log(ic, "Failed to transfer file from user %s.", info);
688                                                break;
689                                }
690                                sd->filetransfer_status = 0;
691                        }
692                }
693        }
694}
695
696static void skype_parse_chat(struct im_connection *ic, char *line)
697{
698        struct skype_data *sd = ic->proto_data;
699        char buf[1024];
700        char *id = strchr(line, ' ');
701
702        if (++id) {
703                struct groupchat *gc;
704                char *info = strchr(id, ' ');
705
706                if (!info)
707                        return;
708                *info = '\0';
709                info++;
710                /* Remove fake chat if we created one in skype_chat_with() */
711                gc = skype_chat_by_name(ic, "");
712                if (gc)
713                        imcb_chat_free(gc);
714                if (!strcmp(info, "STATUS MULTI_SUBSCRIBED")) {
715                        imcb_chat_new(ic, id);
716                        g_snprintf(buf, 1024, "GET CHAT %s ADDER\n", id);
717                        skype_write(ic, buf);
718                        g_snprintf(buf, 1024, "GET CHAT %s TOPIC\n", id);
719                        skype_write(ic, buf);
720                } else if (!strcmp(info, "STATUS DIALOG") && sd->groupchat_with) {
721                        gc = imcb_chat_new(ic, id);
722                        /* According to the docs this
723                         * is necessary. However it
724                         * does not seem the situation
725                         * and it would open an extra
726                         * window on our client, so
727                         * just leave it out. */
728                        /*g_snprintf(buf, 1024, "OPEN CHAT %s\n", id);
729                          skype_write(ic, buf);*/
730                        g_snprintf(buf, 1024, "%s@skype.com", sd->groupchat_with);
731                        imcb_chat_add_buddy(gc, buf);
732                        imcb_chat_add_buddy(gc, sd->username);
733                        g_free(sd->groupchat_with);
734                        sd->groupchat_with = NULL;
735                        g_snprintf(buf, 1024, "GET CHAT %s ADDER\n", id);
736                        skype_write(ic, buf);
737                        g_snprintf(buf, 1024, "GET CHAT %s TOPIC\n", id);
738                        skype_write(ic, buf);
739                } else if (!strcmp(info, "STATUS UNSUBSCRIBED")) {
740                        gc = skype_chat_by_name(ic, id);
741                        if (gc)
742                                gc->data = (void *)FALSE;
743                } else if (!strncmp(info, "ADDER ", 6)) {
744                        info += 6;
745                        g_free(sd->adder);
746                        sd->adder = g_strdup_printf("%s@skype.com", info);
747                } else if (!strncmp(info, "TOPIC ", 6)) {
748                        info += 6;
749                        gc = skype_chat_by_name(ic, id);
750                        if (gc && (sd->adder || sd->topic_wait)) {
751                                if (sd->topic_wait) {
752                                        sd->adder = g_strdup(sd->username);
753                                        sd->topic_wait = 0;
754                                }
755                                imcb_chat_topic(gc, sd->adder, info, 0);
756                                g_free(sd->adder);
757                                sd->adder = NULL;
758                        }
759                } else if (!strncmp(info, "ACTIVEMEMBERS ", 14)) {
760                        info += 14;
761                        gc = skype_chat_by_name(ic, id);
762                        /* Hack! We set ->data to TRUE
763                         * while we're on the channel
764                         * so that we won't rejoin
765                         * after a /part. */
766                        if (gc && !gc->data) {
767                                char **members = g_strsplit(info, " ", 0);
768                                int i;
769                                for (i = 0; members[i]; i++) {
770                                        if (!strcmp(members[i], sd->username))
771                                                continue;
772                                        g_snprintf(buf, 1024, "%s@skype.com", members[i]);
773                                        if (!g_list_find_custom(gc->in_room, buf, (GCompareFunc)strcmp))
774                                                imcb_chat_add_buddy(gc, buf);
775                                }
776                                imcb_chat_add_buddy(gc, sd->username);
777                                g_strfreev(members);
778                        }
779                }
780        }
781}
782
783static void skype_parse_password(struct im_connection *ic, char *line)
784{
785        if (!strncmp(line+9, "OK", 2))
786                imcb_connected(ic);
787        else {
788                imcb_error(ic, "Authentication Failed");
789                imc_logout(ic, TRUE);
790        }
791}
792
793static void skype_parse_profile(struct im_connection *ic, char *line)
794{
795        imcb_log(ic, "SkypeOut balance value is '%s'.", line+21);
796}
797
798static void skype_parse_ping(struct im_connection *ic, char *line)
799{
800        skype_write(ic, "PONG\n");
801}
802
803static void skype_parse_chats(struct im_connection *ic, char *line)
804{
805        char buf[1024];
806        char **i;
807        char **chats = g_strsplit(line + 6, ", ", 0);
808
809        i = chats;
810        while (*i) {
811                g_snprintf(buf, 1024, "GET CHAT %s STATUS\n", *i);
812                skype_write(ic, buf);
813                g_snprintf(buf, 1024, "GET CHAT %s ACTIVEMEMBERS\n", *i);
814                skype_write(ic, buf);
815                i++;
816        }
817        g_strfreev(chats);
818}
819
820typedef void (*skype_parser)(struct im_connection *ic, char *line);
821
822static gboolean skype_read_callback(gpointer data, gint fd,
823                                    b_input_condition cond)
824{
825        struct im_connection *ic = data;
826        struct skype_data *sd = ic->proto_data;
827        char buf[1024];
828        int st, i;
829        char **lines, **lineptr, *line;
830        static struct parse_map {
831                char *k;
832                skype_parser v;
833        } parsers[] = {
834                { "USERS ", skype_parse_users },
835                { "USER ", skype_parse_user },
836                { "CHATMESSAGE ", skype_parse_chatmessage },
837                { "CALL ", skype_parse_call },
838                { "FILETRANSFER ", skype_parse_filetransfer },
839                { "CHAT ", skype_parse_chat },
840                { "PASSWORD ", skype_parse_password },
841                { "PROFILE PSTN_BALANCE ", skype_parse_profile },
842                { "PING", skype_parse_ping },
843                { "CHATS ", skype_parse_chats },
844        };
845
846        if (!sd || sd->fd == -1)
847                return FALSE;
848        /* Read the whole data. */
849        st = ssl_read(sd->ssl, buf, sizeof(buf));
850        if (st > 0) {
851                buf[st] = '\0';
852                /* Then split it up to lines. */
853                lines = g_strsplit(buf, "\n", 0);
854                lineptr = lines;
855                while ((line = *lineptr)) {
856                        if (!strlen(line))
857                                break;
858                        if (set_getbool(&ic->acc->set, "skypeconsole_receive"))
859                                imcb_buddy_msg(ic, "skypeconsole", line, 0, 0);
860                        for (i = 0; i < ARRAY_SIZE(parsers); i++) {
861                                if (!strncmp(line, parsers[i].k, strlen(parsers[i].k))) {
862                                        parsers[i].v(ic, line);
863                                        break;
864                                }
865                        }
866                        lineptr++;
867                }
868                g_strfreev(lines);
869        } else if (st == 0 || (st < 0 && !sockerr_again())) {
870                closesocket(sd->fd);
871                sd->fd = -1;
872
873                imcb_error(ic, "Error while reading from server");
874                imc_logout(ic, TRUE);
875                return FALSE;
876        }
877        return TRUE;
878}
879
880gboolean skype_start_stream(struct im_connection *ic)
881{
882        struct skype_data *sd = ic->proto_data;
883        char *buf;
884        int st;
885
886        if (!sd)
887                return FALSE;
888
889        if (sd->bfd <= 0)
890                sd->bfd = b_input_add(sd->fd, GAIM_INPUT_READ,
891                        skype_read_callback, ic);
892
893        /* Log in */
894        buf = g_strdup_printf("USERNAME %s\n", ic->acc->user);
895        st = skype_write(ic, buf);
896        g_free(buf);
897        buf = g_strdup_printf("PASSWORD %s\n", ic->acc->pass);
898        st = skype_write(ic, buf);
899        g_free(buf);
900
901        /* This will download all buddies. */
902        buf = g_strdup_printf("SEARCH FRIENDS\n");
903        st = skype_write(ic, buf);
904        g_free(buf);
905        buf = g_strdup_printf("SET USERSTATUS ONLINE\n");
906        skype_write(ic, buf);
907        g_free(buf);
908
909        /* Auto join to bookmarked chats if requested.*/
910        if (set_getbool(&ic->acc->set, "auto_join")) {
911                buf = g_strdup_printf("SEARCH BOOKMARKEDCHATS\n");
912                skype_write(ic, buf);
913                g_free(buf);
914        }
915        return st;
916}
917
918gboolean skype_connected(gpointer data, void *source, b_input_condition cond)
919{
920        struct im_connection *ic = data;
921        struct skype_data *sd = ic->proto_data;
922        if (!source) {
923                sd->ssl = NULL;
924                imcb_error(ic, "Could not connect to server");
925                imc_logout(ic, TRUE);
926                return FALSE;
927        }
928        imcb_log(ic, "Connected to server, logging in");
929        return skype_start_stream(ic);
930}
931
932static void skype_login(account_t *acc)
933{
934        struct im_connection *ic = imcb_new(acc);
935        struct skype_data *sd = g_new0(struct skype_data, 1);
936
937        ic->proto_data = sd;
938
939        imcb_log(ic, "Connecting");
940        sd->ssl = ssl_connect(set_getstr(&acc->set, "server"),
941                set_getint(&acc->set, "port"), skype_connected, ic);
942        sd->fd = sd->ssl ? ssl_getfd(sd->ssl) : -1;
943        sd->username = g_strdup(acc->user);
944
945        sd->ic = ic;
946
947        if (set_getbool(&acc->set, "skypeconsole"))
948                imcb_add_buddy(ic, "skypeconsole", NULL);
949}
950
951static void skype_logout(struct im_connection *ic)
952{
953        struct skype_data *sd = ic->proto_data;
954        char *buf;
955
956        buf = g_strdup_printf("SET USERSTATUS OFFLINE\n");
957        skype_write(ic, buf);
958        g_free(buf);
959
960        g_free(sd->username);
961        g_free(sd->handle);
962        g_free(sd);
963        ic->proto_data = NULL;
964}
965
966static int skype_buddy_msg(struct im_connection *ic, char *who, char *message,
967                           int flags)
968{
969        char *buf, *ptr, *nick;
970        int st;
971
972        nick = g_strdup(who);
973        ptr = strchr(nick, '@');
974        if (ptr)
975                *ptr = '\0';
976
977        if (!strncmp(who, "skypeconsole", 12))
978                buf = g_strdup_printf("%s\n", message);
979        else
980                buf = g_strdup_printf("MESSAGE %s %s\n", nick, message);
981        g_free(nick);
982        st = skype_write(ic, buf);
983        g_free(buf);
984
985        return st;
986}
987
988const struct skype_away_state *skype_away_state_by_name(char *name)
989{
990        int i;
991
992        for (i = 0; skype_away_state_list[i].full_name; i++)
993                if (g_strcasecmp(skype_away_state_list[i].full_name, name) == 0)
994                        return skype_away_state_list + i;
995
996        return NULL;
997}
998
999static void skype_set_away(struct im_connection *ic, char *state_txt,
1000                           char *message)
1001{
1002        const struct skype_away_state *state;
1003        char *buf;
1004
1005        if (strcmp(state_txt, GAIM_AWAY_CUSTOM) == 0)
1006                state = skype_away_state_by_name("Away");
1007        else
1008                state = skype_away_state_by_name(state_txt);
1009        buf = g_strdup_printf("SET USERSTATUS %s\n", state->code);
1010        skype_write(ic, buf);
1011        g_free(buf);
1012}
1013
1014static GList *skype_away_states(struct im_connection *ic)
1015{
1016        static GList *l;
1017        int i;
1018
1019        if (l == NULL)
1020                for (i = 0; skype_away_state_list[i].full_name; i++)
1021                        l = g_list_append(l,
1022                                (void *)skype_away_state_list[i].full_name);
1023
1024        return l;
1025}
1026
1027static char *skype_set_display_name(set_t *set, char *value)
1028{
1029        account_t *acc = set->data;
1030        struct im_connection *ic = acc->ic;
1031        char *buf;
1032
1033        buf = g_strdup_printf("SET PROFILE FULLNAME %s", value);
1034        skype_write(ic, buf);
1035        g_free(buf);
1036        return value;
1037}
1038
1039static char *skype_set_balance(set_t *set, char *value)
1040{
1041        account_t *acc = set->data;
1042        struct im_connection *ic = acc->ic;
1043        char *buf;
1044
1045        buf = g_strdup_printf("GET PROFILE PSTN_BALANCE");
1046        skype_write(ic, buf);
1047        g_free(buf);
1048        return value;
1049}
1050
1051static char *skype_set_call(set_t *set, char *value)
1052{
1053        account_t *acc = set->data;
1054        struct im_connection *ic = acc->ic;
1055        struct skype_data *sd = ic->proto_data;
1056        char *nick, *ptr, *buf;
1057
1058        if (value) {
1059                user_t *u = user_find(acc->irc, value);
1060                /* We are starting a call */
1061                if (!u)
1062                        nick = g_strdup(value);
1063                else
1064                        nick = g_strdup(u->handle);
1065                ptr = strchr(nick, '@');
1066                if (ptr)
1067                        *ptr = '\0';
1068
1069                buf = g_strdup_printf("CALL %s", nick);
1070                skype_write(ic, buf);
1071                g_free(buf);
1072                g_free(nick);
1073        } else {
1074                /* We are ending a call */
1075                if (sd->call_id) {
1076                        buf = g_strdup_printf("SET CALL %s STATUS FINISHED",
1077                                sd->call_id);
1078                        skype_write(ic, buf);
1079                        g_free(buf);
1080                        g_free(sd->call_id);
1081                        sd->call_id = NULL;
1082                } else
1083                        imcb_error(ic, "There are no active calls currently.");
1084        }
1085        return value;
1086}
1087
1088static void skype_add_buddy(struct im_connection *ic, char *who, char *group)
1089{
1090        char *buf, *nick, *ptr;
1091
1092        nick = g_strdup(who);
1093        ptr = strchr(nick, '@');
1094        if (ptr)
1095                *ptr = '\0';
1096        buf = g_strdup_printf("SET USER %s BUDDYSTATUS 2 Please authorize me\n",
1097                nick);
1098        skype_write(ic, buf);
1099        g_free(nick);
1100}
1101
1102static void skype_remove_buddy(struct im_connection *ic, char *who, char *group)
1103{
1104        char *buf, *nick, *ptr;
1105
1106        nick = g_strdup(who);
1107        ptr = strchr(nick, '@');
1108        if (ptr)
1109                *ptr = '\0';
1110        buf = g_strdup_printf("SET USER %s BUDDYSTATUS 1\n", nick);
1111        skype_write(ic, buf);
1112        g_free(nick);
1113}
1114
1115void skype_chat_msg(struct groupchat *gc, char *message, int flags)
1116{
1117        struct im_connection *ic = gc->ic;
1118        char *buf;
1119        buf = g_strdup_printf("CHATMESSAGE %s %s\n", gc->title, message);
1120        skype_write(ic, buf);
1121        g_free(buf);
1122}
1123
1124void skype_chat_leave(struct groupchat *gc)
1125{
1126        struct im_connection *ic = gc->ic;
1127        char *buf;
1128        buf = g_strdup_printf("ALTER CHAT %s LEAVE\n", gc->title);
1129        skype_write(ic, buf);
1130        g_free(buf);
1131        gc->data = (void *)TRUE;
1132}
1133
1134void skype_chat_invite(struct groupchat *gc, char *who, char *message)
1135{
1136        struct im_connection *ic = gc->ic;
1137        char *buf, *ptr, *nick;
1138        nick = g_strdup(message);
1139        ptr = strchr(nick, '@');
1140        if (ptr)
1141                *ptr = '\0';
1142        buf = g_strdup_printf("ALTER CHAT %s ADDMEMBERS %s\n", gc->title, nick);
1143        skype_write(ic, buf);
1144        g_free(buf);
1145        g_free(nick);
1146}
1147
1148void skype_chat_topic(struct groupchat *gc, char *message)
1149{
1150        struct im_connection *ic = gc->ic;
1151        struct skype_data *sd = ic->proto_data;
1152        char *buf;
1153        buf = g_strdup_printf("ALTER CHAT %s SETTOPIC %s\n",
1154                gc->title, message);
1155        skype_write(ic, buf);
1156        g_free(buf);
1157        sd->topic_wait = 1;
1158}
1159
1160struct groupchat *skype_chat_with(struct im_connection *ic, char *who)
1161{
1162        struct skype_data *sd = ic->proto_data;
1163        char *ptr, *nick, *buf;
1164        nick = g_strdup(who);
1165        ptr = strchr(nick, '@');
1166        if (ptr)
1167                *ptr = '\0';
1168        buf = g_strdup_printf("CHAT CREATE %s\n", nick);
1169        skype_write(ic, buf);
1170        g_free(buf);
1171        sd->groupchat_with = g_strdup(nick);
1172        g_free(nick);
1173        /* We create a fake chat for now. We will replace it with a real one in
1174         * the real callback. */
1175        return imcb_chat_new(ic, "");
1176}
1177
1178static void skype_get_info(struct im_connection *ic, char *who)
1179{
1180        char *ptr, *nick, *buf;
1181        nick = g_strdup(who);
1182        ptr = strchr(nick, '@');
1183        if (ptr)
1184                *ptr = '\0';
1185        buf = g_strdup_printf("GET USER %s FULLNAME\n", nick);
1186        skype_write(ic, buf);
1187        g_free(buf);
1188        buf = g_strdup_printf("GET USER %s PHONE_HOME\n", nick);
1189        skype_write(ic, buf);
1190        g_free(buf);
1191        buf = g_strdup_printf("GET USER %s PHONE_OFFICE\n", nick);
1192        skype_write(ic, buf);
1193        g_free(buf);
1194        buf = g_strdup_printf("GET USER %s PHONE_MOBILE\n", nick);
1195        skype_write(ic, buf);
1196        g_free(buf);
1197        buf = g_strdup_printf("GET USER %s NROF_AUTHED_BUDDIES\n", nick);
1198        skype_write(ic, buf);
1199        g_free(buf);
1200        buf = g_strdup_printf("GET USER %s TIMEZONE\n", nick);
1201        skype_write(ic, buf);
1202        g_free(buf);
1203        buf = g_strdup_printf("GET USER %s LASTONLINETIMESTAMP\n", nick);
1204        skype_write(ic, buf);
1205        g_free(buf);
1206        buf = g_strdup_printf("GET USER %s BIRTHDAY\n", nick);
1207        skype_write(ic, buf);
1208        g_free(buf);
1209        buf = g_strdup_printf("GET USER %s SEX\n", nick);
1210        skype_write(ic, buf);
1211        g_free(buf);
1212        buf = g_strdup_printf("GET USER %s LANGUAGE\n", nick);
1213        skype_write(ic, buf);
1214        g_free(buf);
1215        buf = g_strdup_printf("GET USER %s COUNTRY\n", nick);
1216        skype_write(ic, buf);
1217        g_free(buf);
1218        buf = g_strdup_printf("GET USER %s PROVINCE\n", nick);
1219        skype_write(ic, buf);
1220        g_free(buf);
1221        buf = g_strdup_printf("GET USER %s CITY\n", nick);
1222        skype_write(ic, buf);
1223        g_free(buf);
1224        buf = g_strdup_printf("GET USER %s HOMEPAGE\n", nick);
1225        skype_write(ic, buf);
1226        g_free(buf);
1227        buf = g_strdup_printf("GET USER %s ABOUT\n", nick);
1228        skype_write(ic, buf);
1229        g_free(buf);
1230}
1231
1232static void skype_set_my_name(struct im_connection *ic, char *info)
1233{
1234        skype_set_display_name(set_find(&ic->acc->set, "display_name"), info);
1235}
1236
1237static void skype_init(account_t *acc)
1238{
1239        set_t *s;
1240
1241        s = set_add(&acc->set, "server", SKYPE_DEFAULT_SERVER, set_eval_account,
1242                acc);
1243        s->flags |= ACC_SET_OFFLINE_ONLY;
1244
1245        s = set_add(&acc->set, "port", SKYPE_DEFAULT_PORT, set_eval_int, acc);
1246        s->flags |= ACC_SET_OFFLINE_ONLY;
1247
1248        s = set_add(&acc->set, "display_name", NULL, skype_set_display_name,
1249                acc);
1250        s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY;
1251
1252        s = set_add(&acc->set, "call", NULL, skype_set_call, acc);
1253        s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY;
1254
1255        s = set_add(&acc->set, "balance", NULL, skype_set_balance, acc);
1256        s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY;
1257
1258        s = set_add(&acc->set, "skypeout_offline", "true", set_eval_bool, acc);
1259
1260        s = set_add(&acc->set, "skypeconsole", "false", set_eval_bool, acc);
1261        s->flags |= ACC_SET_OFFLINE_ONLY;
1262
1263        s = set_add(&acc->set, "skypeconsole_receive", "false", set_eval_bool,
1264                acc);
1265        s->flags |= ACC_SET_OFFLINE_ONLY;
1266
1267        s = set_add(&acc->set, "auto_join", "false", set_eval_bool, acc);
1268        s->flags |= ACC_SET_OFFLINE_ONLY;
1269}
1270
1271void init_plugin(void)
1272{
1273        struct prpl *ret = g_new0(struct prpl, 1);
1274
1275        ret->name = "skype";
1276        ret->login = skype_login;
1277        ret->init = skype_init;
1278        ret->logout = skype_logout;
1279        ret->buddy_msg = skype_buddy_msg;
1280        ret->get_info = skype_get_info;
1281        ret->set_my_name = skype_set_my_name;
1282        ret->away_states = skype_away_states;
1283        ret->set_away = skype_set_away;
1284        ret->add_buddy = skype_add_buddy;
1285        ret->remove_buddy = skype_remove_buddy;
1286        ret->chat_msg = skype_chat_msg;
1287        ret->chat_leave = skype_chat_leave;
1288        ret->chat_invite = skype_chat_invite;
1289        ret->chat_with = skype_chat_with;
1290        ret->handle_cmp = g_strcasecmp;
1291        ret->chat_topic = skype_chat_topic;
1292        register_protocol(ret);
1293}
Note: See TracBrowser for help on using the repository browser.