source: skype/skype.c @ 09e2a69

Last change on this file since 09e2a69 was 09e2a69, checked in by Miklos Vajna <vmiklos@…>, at 2007-10-16T23:09:22Z

implement skype_chat_topic()

  • Property mode set to 100644
File size: 18.2 KB
Line 
1/*
2 *  skype.c - Skype plugin for BitlBee
3 *
4 *  Copyright (c) 2007 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#include <stdio.h>
27#include <poll.h>
28#include <bitlbee.h>
29#include <glib.h>
30
31#define SKYPE_PORT_DEFAULT "2727"
32
33/*
34 * Enumerations
35 */
36
37typedef enum
38{
39        SKYPE_CALL_RINGING = 1,
40        SKYPE_CALL_MISSED
41} skype_call_status;
42
43typedef enum
44{
45        SKYPE_FILETRANSFER_NEW = 1,
46        SKYPE_FILETRANSFER_FAILED
47} skype_filetransfer_status;
48
49/*
50 * Structures
51 */
52
53struct skype_data
54{
55        struct im_connection *ic;
56        char *username;
57        /* The effective file descriptor. We store it here so any function can
58         * write() to it. */
59        int fd;
60        /* File descriptor returned by bitlbee. we store it so we know when
61         * we're connected and when we aren't. */
62        int bfd;
63        /* When we receive a new message id, we query the properties, finally
64         * the chatname. Store the properties here so that we can use
65         * imcb_buddy_msg() when we got the chatname. */
66        char *handle;
67        char *body;
68        char *type;
69        /* This is necessary because we send a notification when we get the
70         * handle. So we store the state here and then we can send a
71         * notification about the handle is in a given status. */
72        skype_call_status call_status;
73        /* Same for file transfers. */
74        skype_filetransfer_status filetransfer_status;
75        /* Using /j #nick we want to have a groupchat with two people. Usually
76         * not (default). */
77        char* groupchat_with;
78};
79
80struct skype_away_state
81{
82        char *code;
83        char *full_name;
84};
85
86struct skype_buddy_ask_data
87{
88        struct im_connection *ic;
89        char *handle;
90};
91
92/*
93 * Tables
94 */
95
96const struct skype_away_state skype_away_state_list[] =
97{
98        { "ONLINE",  "Online" },
99        { "SKYPEME",  "Skype Me" },
100        { "AWAY",   "Away" },
101        { "NA",    "Not available" },
102        { "DND",      "Do Not Disturb" },
103        { "INVISIBLE",      "Invisible" },
104        { "OFFLINE",      "Offline" },
105        { NULL, NULL}
106};
107
108/*
109 * Functions
110 */
111
112static void skype_init( account_t *acc )
113{
114        set_t *s;
115
116        s = set_add( &acc->set, "port", SKYPE_PORT_DEFAULT, set_eval_int, acc );
117        s->flags |= ACC_SET_OFFLINE_ONLY;
118
119        s = set_add( &acc->set, "server", NULL, set_eval_account, acc );
120        s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY;
121}
122
123int skype_write( struct im_connection *ic, char *buf, int len )
124{
125        struct skype_data *sd = ic->proto_data;
126        struct pollfd pfd[1];
127
128        pfd[0].fd = sd->fd;
129        pfd[0].events = POLLOUT;
130
131        /* This poll is necessary or we'll get a SIGPIPE when we write() to
132         * sd->fd. */
133        poll(pfd, 1, 1000);
134        if(pfd[0].revents & POLLHUP)
135        {
136                imcb_error( ic, "Could not connect to server" );
137                imc_logout( ic, TRUE );
138                return FALSE;
139        }
140        write( sd->fd, buf, len );
141
142        return TRUE;
143}
144
145static void skype_buddy_ask_yes( gpointer w, struct skype_buddy_ask_data *bla )
146{
147        char *buf = g_strdup_printf("SET USER %s ISAUTHORIZED TRUE", bla->handle);
148        skype_write( bla->ic, buf, strlen( buf ) );
149        g_free(buf);
150        g_free(bla->handle);
151        g_free(bla);
152}
153
154static void skype_buddy_ask_no( gpointer w, struct skype_buddy_ask_data *bla )
155{
156        char *buf = g_strdup_printf("SET USER %s ISAUTHORIZED FALSE", bla->handle);
157        skype_write( bla->ic, buf, strlen( buf ) );
158        g_free(buf);
159        g_free(bla->handle);
160        g_free(bla);
161}
162
163void skype_buddy_ask( struct im_connection *ic, char *handle, char *message)
164{
165        struct skype_buddy_ask_data *bla = g_new0( struct skype_buddy_ask_data, 1 );
166        char *buf;
167
168        bla->ic = ic;
169        bla->handle = g_strdup(handle);
170
171        buf = g_strdup_printf( "The user %s wants to add you to his/her buddy list, saying: '%s'.", handle, message);
172        imcb_ask( ic, buf, bla, skype_buddy_ask_yes, skype_buddy_ask_no );
173        g_free( buf );
174}
175
176struct groupchat *skype_chat_by_name( struct im_connection *ic, char *name )
177{
178        struct groupchat *ret;
179
180        for( ret = ic->conversations; ret; ret = ret->next )
181        {
182                if(strcmp(name, ret->title ) == 0 )
183                        break;
184        }
185
186        return ret;
187}
188
189static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition cond )
190{
191        struct im_connection *ic = data;
192        struct skype_data *sd = ic->proto_data;
193        char buf[1024];
194        int st;
195        char **lines, **lineptr, *line, *ptr;
196
197        if( !sd || sd->fd == -1 )
198                return FALSE;
199        /* Read the whole data. */
200        st = read( sd->fd, buf, sizeof( buf ) );
201        if( st > 0 )
202        {
203                buf[st] = '\0';
204                /* Then split it up to lines. */
205                lines = g_strsplit(buf, "\n", 0);
206                lineptr = lines;
207                while((line = *lineptr))
208                {
209                        if(!strlen(line))
210                                break;
211                        if(!strncmp(line, "USERS ", 6))
212                        {
213                                char **i;
214                                char **nicks;
215
216                                nicks = g_strsplit(line + 6, ", ", 0);
217                                i = nicks;
218                                while(*i)
219                                {
220                                        g_snprintf(buf, 1024, "GET USER %s ONLINESTATUS\n", *i);
221                                        skype_write( ic, buf, strlen( buf ) );
222                                        i++;
223                                }
224                                g_strfreev(nicks);
225                        }
226                        else if(!strncmp(line, "USER ", 5))
227                        {
228                                int flags = 0;
229                                char *status = strrchr(line, ' ');
230                                char *user = strchr(line, ' ');
231                                status++;
232                                ptr = strchr(++user, ' ');
233                                *ptr = '\0';
234                                ptr++;
235                                if(!strncmp(ptr, "ONLINESTATUS ", 13) &&
236                                                strcmp(user, sd->username) != 0
237                                                && strcmp(user, "echo123") != 0)
238                                {
239                                        ptr = g_strdup_printf("%s@skype.com", user);
240                                        imcb_add_buddy(ic, ptr, NULL);
241                                        if(strcmp(status, "OFFLINE") != 0)
242                                                flags |= OPT_LOGGED_IN;
243                                        if(strcmp(status, "ONLINE") != 0 && strcmp(status, "SKYPEME") != 0)
244                                                flags |= OPT_AWAY;
245                                        imcb_buddy_status(ic, ptr, flags, NULL, NULL);
246                                        g_free(ptr);
247                                }
248                                else if(!strncmp(ptr, "RECEIVEDAUTHREQUEST ", 20))
249                                {
250                                        char *message = ptr + 20;
251                                        if(strlen(message))
252                                                skype_buddy_ask(ic, user, message);
253                                }
254                                else if(!strncmp(ptr, "BUDDYSTATUS ", 12))
255                                {
256                                        char *st = ptr + 12;
257                                        if(!strcmp(st, "3"))
258                                        {
259                                                char *buf = g_strdup_printf("%s@skype.com", user);
260                                                imcb_add_buddy(ic, buf, NULL);
261                                                g_free(buf);
262                                        }
263                                }
264                        }
265                        else if(!strncmp(line, "CHATMESSAGE ", 12))
266                        {
267                                char *id = strchr(line, ' ');
268                                if(++id)
269                                {
270                                        char *info = strchr(id, ' ');
271                                        *info = '\0';
272                                        info++;
273                                        if(!strcmp(info, "STATUS RECEIVED"))
274                                        {
275                                                /* New message ID:
276                                                 * (1) Request its from field
277                                                 * (2) Request its body
278                                                 * (3) Request its type
279                                                 * (4) Query chatname
280                                                 */
281                                                g_snprintf(buf, 1024, "GET CHATMESSAGE %s FROM_HANDLE\n", id);
282                                                skype_write( ic, buf, strlen( buf ) );
283                                                g_snprintf(buf, 1024, "GET CHATMESSAGE %s BODY\n", id);
284                                                skype_write( ic, buf, strlen( buf ) );
285                                                g_snprintf(buf, 1024, "GET CHATMESSAGE %s TYPE\n", id);
286                                                skype_write( ic, buf, strlen( buf ) );
287                                                g_snprintf(buf, 1024, "GET CHATMESSAGE %s CHATNAME\n", id);
288                                                skype_write( ic, buf, strlen( buf ) );
289                                        }
290                                        else if(!strncmp(info, "FROM_HANDLE ", 12))
291                                        {
292                                                info += 12;
293                                                /* New from field value. Store
294                                                 * it, then we can later use it
295                                                 * when we got the message's
296                                                 * body. */
297                                                g_free(sd->handle);
298                                                sd->handle = g_strdup_printf("%s@skype.com", info);
299                                        }
300                                        else if(!strncmp(info, "EDITED_BY ", 10))
301                                        {
302                                                info += 10;
303                                                /* This is the same as
304                                                 * FROM_HANDLE, except that we
305                                                 * never request these lines
306                                                 * from Skype, we just get
307                                                 * them. */
308                                                g_free(sd->handle);
309                                                sd->handle = g_strdup_printf("%s@skype.com", info);
310                                        }
311                                        else if(!strncmp(info, "BODY ", 5))
312                                        {
313                                                info += 5;
314                                                g_free(sd->body);
315                                                sd->body = g_strdup(info);
316                                        }
317                                        else if(!strncmp(info, "TYPE ", 5))
318                                        {
319                                                info += 5;
320                                                g_free(sd->type);
321                                                sd->type = g_strdup(info);
322                                        }
323                                        else if(!strncmp(info, "CHATNAME ", 9))
324                                        {
325                                                info += 9;
326                                                if(sd->handle && sd->body && sd->type)
327                                                {
328                                                        struct groupchat *gc = skype_chat_by_name(ic, info);
329                                                        if(!strcmp(sd->type, "SAID"))
330                                                        {
331                                                                if(!gc)
332                                                                        /* Private message */
333                                                                        imcb_buddy_msg(ic, sd->handle, sd->body, 0, 0);
334                                                                else
335                                                                        /* Groupchat message */
336                                                                        imcb_chat_msg(gc, sd->handle, sd->body, 0, 0);
337                                                        }
338                                                        else if(!strcmp(sd->type, "SETTOPIC"))
339                                                        {
340                                                                if(gc)
341                                                                        imcb_chat_topic(gc, sd->handle, sd->body);
342                                                        }
343                                                        else if(!strcmp(sd->type, "LEFT"))
344                                                        {
345                                                                if(gc)
346                                                                        imcb_chat_remove_buddy(gc, sd->handle, NULL);
347                                                        }
348                                                }
349                                        }
350                                }
351                        }
352                        else if(!strncmp(line, "CALL ", 5))
353                        {
354                                char *id = strchr(line, ' ');
355                                if(++id)
356                                {
357                                        char *info = strchr(id, ' ');
358                                        *info = '\0';
359                                        info++;
360                                        if(!strcmp(info, "STATUS RINGING"))
361                                        {
362                                                g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id);
363                                                skype_write( ic, buf, strlen( buf ) );
364                                                sd->call_status = SKYPE_CALL_RINGING;
365                                        }
366                                        else if(!strcmp(info, "STATUS MISSED"))
367                                        {
368                                                g_snprintf(buf, 1024, "GET CALL %s PARTNER_HANDLE\n", id);
369                                                skype_write( ic, buf, strlen( buf ) );
370                                                sd->call_status = SKYPE_CALL_MISSED;
371                                        }
372                                        else if(!strncmp(info, "PARTNER_HANDLE ", 15))
373                                        {
374                                                info += 15;
375                                                if(sd->call_status) {
376                                                        switch(sd->call_status)
377                                                        {
378                                                                case SKYPE_CALL_RINGING:
379                                                                        imcb_log(ic, "The user %s is currently ringing you.", info);
380                                                                        break;
381                                                                case SKYPE_CALL_MISSED:
382                                                                        imcb_log(ic, "You have missed a call from user %s.", info);
383                                                                        break;
384                                                        }
385                                                        sd->call_status = 0;
386                                                }
387                                        }
388                                }
389                        }
390                        else if(!strncmp(line, "FILETRANSFER ", 13))
391                        {
392                                char *id = strchr(line, ' ');
393                                if(++id)
394                                {
395                                        char *info = strchr(id, ' ');
396                                        *info = '\0';
397                                        info++;
398                                        if(!strcmp(info, "STATUS NEW"))
399                                        {
400                                                g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n", id);
401                                                skype_write( ic, buf, strlen( buf ) );
402                                                sd->filetransfer_status = SKYPE_FILETRANSFER_NEW;
403                                        }
404                                        else if(!strcmp(info, "STATUS FAILED"))
405                                        {
406                                                g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n", id);
407                                                skype_write( ic, buf, strlen( buf ) );
408                                                sd->filetransfer_status = SKYPE_FILETRANSFER_FAILED;
409                                        }
410                                        else if(!strncmp(info, "PARTNER_HANDLE ", 15))
411                                        {
412                                                info += 15;
413                                                if(sd->filetransfer_status) {
414                                                        switch(sd->filetransfer_status)
415                                                        {
416                                                                case SKYPE_FILETRANSFER_NEW:
417                                                                        imcb_log(ic, "The user %s offered a new file for you.", info);
418                                                                        break;
419                                                                case SKYPE_FILETRANSFER_FAILED:
420                                                                        imcb_log(ic, "Failed to transfer file from user %s.", info);
421                                                                        break;
422                                                        }
423                                                        sd->filetransfer_status = 0;
424                                                }
425                                        }
426                                }
427                        }
428                        else if(!strncmp(line, "CHAT ", 5))
429                        {
430                                char *id = strchr(line, ' ');
431                                if(++id)
432                                {
433                                        char *info = strchr(id, ' ');
434                                        if(info)
435                                                *info = '\0';
436                                        info++;
437                                        if(!strcmp(info, "STATUS MULTI_SUBSCRIBED"))
438                                        {
439                                                imcb_chat_new( ic, id );
440                                        }
441                                        else if(!strcmp(info, "STATUS DIALOG") && sd->groupchat_with)
442                                        {
443                                                struct groupchat *gc = imcb_chat_new( ic, id );
444                                                /* According to the docs this
445                                                 * is necessary. However it
446                                                 * does not seem the situation
447                                                 * and it would open an extra
448                                                 * window on our client, so
449                                                 * just leave it out. */
450                                                /*g_snprintf(buf, 1024, "OPEN CHAT %s\n", id);
451                                                skype_write(ic, buf, strlen(buf));*/
452                                                g_snprintf(buf, 1024, "%s@skype.com", sd->groupchat_with);
453                                                imcb_chat_add_buddy(gc, buf);
454                                                imcb_chat_add_buddy(gc, sd->username);
455                                                g_free(sd->groupchat_with);
456                                                sd->groupchat_with = NULL;
457                                        }
458                                        else if(!strcmp(info, "STATUS UNSUBSCRIBED"))
459                                        {
460                                                struct groupchat *gc = skype_chat_by_name(ic, id);
461                                                if(gc)
462                                                        gc->data = (void*)FALSE;
463                                        }
464                                        else if(!strncmp(info, "TOPIC ", 6))
465                                        {
466                                                info += 6;
467                                                struct groupchat *gc = skype_chat_by_name(ic, id);
468                                                if(gc)
469                                                        imcb_chat_topic(gc, NULL, info);
470                                        }
471                                        else if(!strncmp(info, "ACTIVEMEMBERS ", 14))
472                                        {
473                                                info += 14;
474                                                struct groupchat *gc = skype_chat_by_name(ic, id);
475                                                /* Hack! We set ->data to TRUE
476                                                 * while we're on the channel
477                                                 * so that we won't rejoin
478                                                 * after a /part. */
479                                                if(gc && !gc->data)
480                                                {
481                                                        char **members = g_strsplit(info, " ", 0);
482                                                        int i;
483                                                        for(i=0;members[i];i++)
484                                                        {
485                                                                if(!strcmp(members[i], sd->username))
486                                                                        continue;
487                                                                g_snprintf(buf, 1024, "%s@skype.com", members[i]);
488                                                                if(!g_list_find_custom(gc->in_room, buf, (GCompareFunc)strcmp))
489                                                                        imcb_chat_add_buddy(gc, buf);
490                                                        }
491                                                        imcb_chat_add_buddy(gc, sd->username);
492                                                        g_strfreev(members);
493                                                }
494                                        }
495                                }
496                        }
497                        lineptr++;
498                }
499                g_strfreev(lines);
500        }
501        else if( st == 0 || ( st < 0 && !sockerr_again() ) )
502        {
503                closesocket( sd->fd );
504                sd->fd = -1;
505
506                imcb_error( ic, "Error while reading from server" );
507                imc_logout( ic, TRUE );
508                return FALSE;
509        }
510        return TRUE;
511}
512
513gboolean skype_start_stream( struct im_connection *ic )
514{
515        struct skype_data *sd = ic->proto_data;
516        char *buf;
517        int st;
518
519        if(!sd)
520                return FALSE;
521
522        if( sd->bfd <= 0 )
523                sd->bfd = b_input_add( sd->fd, GAIM_INPUT_READ, skype_read_callback, ic );
524
525        /* This will download all buddies. */
526        buf = g_strdup_printf("SEARCH FRIENDS\n");
527        st = skype_write( ic, buf, strlen( buf ) );
528        g_free(buf);
529        buf = g_strdup_printf("SET USERSTATUS ONLINE\n");
530        skype_write( ic, buf, strlen( buf ) );
531        g_free(buf);
532        return st;
533}
534
535gboolean skype_connected( gpointer data, gint source, b_input_condition cond )
536{
537        struct im_connection *ic = data;
538        imcb_connected(ic);
539        return skype_start_stream(ic);
540}
541
542static void skype_login( account_t *acc )
543{
544        struct im_connection *ic = imcb_new( acc );
545        struct skype_data *sd = g_new0( struct skype_data, 1 );
546
547        ic->proto_data = sd;
548
549        imcb_log( ic, "Connecting" );
550        sd->fd = proxy_connect(acc->server, set_getint( &acc->set, "port" ), skype_connected, ic );
551        sd->username = g_strdup( acc->user );
552
553        sd->ic = ic;
554}
555
556static void skype_logout( struct im_connection *ic )
557{
558        struct skype_data *sd = ic->proto_data;
559        char *buf;
560
561        buf = g_strdup_printf("SET USERSTATUS OFFLINE\n");
562        skype_write( ic, buf, strlen( buf ) );
563        g_free(buf);
564
565        g_free(sd->username);
566        g_free(sd->handle);
567        g_free(sd);
568        ic->proto_data = NULL;
569}
570
571static int skype_buddy_msg( struct im_connection *ic, char *who, char *message, int flags )
572{
573        char *buf, *ptr, *nick;
574        int st;
575
576        nick = g_strdup(who);
577        ptr = strchr(nick, '@');
578        if(ptr)
579                *ptr = '\0';
580
581        buf = g_strdup_printf("MESSAGE %s %s\n", nick, message);
582        g_free(nick);
583        st = skype_write( ic, buf, strlen( buf ) );
584        g_free(buf);
585
586        return st;
587}
588
589const struct skype_away_state *skype_away_state_by_name( char *name )
590{
591        int i;
592
593        for( i = 0; skype_away_state_list[i].full_name; i ++ )
594                if( g_strcasecmp( skype_away_state_list[i].full_name, name ) == 0 )
595                        return( skype_away_state_list + i );
596
597        return NULL;
598}
599
600static void skype_set_away( struct im_connection *ic, char *state_txt, char *message )
601{
602        const struct skype_away_state *state;
603        char *buf;
604
605        if( strcmp( state_txt, GAIM_AWAY_CUSTOM ) == 0 )
606                state = skype_away_state_by_name( "Away" );
607        else
608                state = skype_away_state_by_name( state_txt );
609        buf = g_strdup_printf("SET USERSTATUS %s\n", state->code);
610        skype_write( ic, buf, strlen( buf ) );
611        g_free(buf);
612}
613
614static GList *skype_away_states( struct im_connection *ic )
615{
616        GList *l = NULL;
617        int i;
618       
619        for( i = 0; skype_away_state_list[i].full_name; i ++ )
620                l = g_list_append( l, (void*) skype_away_state_list[i].full_name );
621       
622        return l;
623}
624
625static void skype_add_buddy( struct im_connection *ic, char *who, char *group )
626{
627        char *buf, *nick, *ptr;
628
629        nick = g_strdup(who);
630        ptr = strchr(nick, '@');
631        if(ptr)
632                *ptr = '\0';
633        buf = g_strdup_printf("SET USER %s BUDDYSTATUS 2 Please authorize me\n", nick);
634        skype_write( ic, buf, strlen( buf ) );
635        g_free(nick);
636}
637
638static void skype_remove_buddy( struct im_connection *ic, char *who, char *group )
639{
640        char *buf, *nick, *ptr;
641
642        nick = g_strdup(who);
643        ptr = strchr(nick, '@');
644        if(ptr)
645                *ptr = '\0';
646        buf = g_strdup_printf("SET USER %s BUDDYSTATUS 1\n", nick);
647        skype_write( ic, buf, strlen( buf ) );
648        g_free(nick);
649}
650
651void skype_chat_msg( struct groupchat *gc, char *message, int flags )
652{
653        struct im_connection *ic = gc->ic;
654        char *buf;
655        buf = g_strdup_printf("CHATMESSAGE %s %s\n", gc->title, message);
656        skype_write( ic, buf, strlen( buf ) );
657        g_free(buf);
658}
659
660void skype_chat_leave( struct groupchat *gc )
661{
662        struct im_connection *ic = gc->ic;
663        char *buf;
664        buf = g_strdup_printf("ALTER CHAT %s LEAVE\n", gc->title);
665        skype_write( ic, buf, strlen( buf ) );
666        g_free(buf);
667        gc->data = (void*)TRUE;
668}
669
670void skype_chat_invite(struct groupchat *gc, char *who, char *message)
671{
672        struct im_connection *ic = gc->ic;
673        char *buf, *ptr, *nick;
674        nick = g_strdup(message);
675        ptr = strchr(nick, '@');
676        if(ptr)
677                *ptr = '\0';
678        buf = g_strdup_printf("ALTER CHAT %s ADDMEMBERS %s\n", gc->title, nick);
679        skype_write( ic, buf, strlen( buf ) );
680        g_free(buf);
681        g_free(nick);
682}
683
684void skype_chat_topic(struct groupchat *gc, char *message)
685{
686        struct im_connection *ic = gc->ic;
687        char *buf;
688        buf = g_strdup_printf("ALTER CHAT %s SETTOPIC %s\n", gc->title, message);
689        skype_write( ic, buf, strlen( buf ) );
690        g_free(buf);
691}
692
693struct groupchat *skype_chat_with(struct im_connection *ic, char *who)
694{
695        struct skype_data *sd = ic->proto_data;
696        char *ptr, *nick, *buf;
697        nick = g_strdup(who);
698        ptr = strchr(nick, '@');
699        if(ptr)
700                *ptr = '\0';
701        buf = g_strdup_printf("CHAT CREATE %s\n", nick);
702        skype_write(ic, buf, strlen(buf));
703        g_free(buf);
704        sd->groupchat_with = g_strdup(nick);
705        g_free(nick);
706        return(NULL);
707}
708
709void init_plugin(void)
710{
711        struct prpl *ret = g_new0( struct prpl, 1 );
712
713        ret->name = "skype";
714        ret->login = skype_login;
715        ret->init = skype_init;
716        ret->logout = skype_logout;
717        ret->buddy_msg = skype_buddy_msg;
718        ret->away_states = skype_away_states;
719        ret->set_away = skype_set_away;
720        ret->add_buddy = skype_add_buddy;
721        ret->remove_buddy = skype_remove_buddy;
722        ret->chat_msg = skype_chat_msg;
723        ret->chat_leave = skype_chat_leave;
724        ret->chat_invite = skype_chat_invite;
725        ret->chat_with = skype_chat_with;
726        ret->handle_cmp = g_strcasecmp;
727        ret->chat_topic = skype_chat_topic;
728        register_protocol( ret );
729}
Note: See TracBrowser for help on using the repository browser.