source: skype/skype.c @ 039116a

Last change on this file since 039116a was 039116a, checked in by Miklos Vajna <vmiklos@…>, at 2008-06-28T00:09:25Z

add support for bitlbee-1.2.1

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