source: protocols/skype/skype.c @ e31e5b8

Last change on this file since e31e5b8 was e31e5b8, checked in by Wilmer van der Gaast <wilmer@…>, at 2013-04-20T13:05:55Z

Merging "storage" branch which I wrote long ago. It separates generation of
XML-formatted user configs from disk I/O so we can try to start using other
mechanisms to store them (a REST API or something, for example).

  • Property mode set to 100644
File size: 42.6 KB
RevLine 
[7daec06]1/*
2 *  skype.c - Skype plugin for BitlBee
[5adcc65]3 *
[9ec6b36]4 *  Copyright (c) 2007-2013 by Miklos Vajna <vmiklos@vmiklos.hu>
[f06e3ac]5 *
[7daec06]6 *  This program is free software; you can redistribute it and/or modify
7 *  it under the terms of the GNU General Public License as published by
8 *  the Free Software Foundation; either version 2 of the License, or
9 *  (at your option) any later version.
10 *
11 *  This program is distributed in the hope that it will be useful,
12 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 *  GNU General Public License for more details.
15 *
16 *  You should have received a copy of the GNU General Public License
17 *  along with this program; if not, write to the Free Software
[5adcc65]18 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
[7daec06]19 *  USA.
[f06e3ac]20 */
[7daec06]21
[f9c3e7b]22#define _XOPEN_SOURCE
[1f4fc80]23#define _BSD_SOURCE
[ed2e37f]24#include <poll.h>
[ff18fc1]25#include <stdio.h>
[f06e3ac]26#include <bitlbee.h>
[7f41495]27#include <ssl_client.h>
[f06e3ac]28
[f5aedd91]29#define SKYPE_DEFAULT_SERVER "localhost"
[4bbd9db]30#define SKYPE_DEFAULT_PORT "2727"
[61d2eabb]31#define IRC_LINE_SIZE 16384
[ff436ba]32#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
[f06e3ac]33
[bbba374]34/*
35 * Enumerations
36 */
37
[359f4d9]38enum {
[df9255d]39        SKYPE_CALL_RINGING = 1,
[9db0234]40        SKYPE_CALL_MISSED,
[2eb4b1f]41        SKYPE_CALL_CANCELLED,
[acd9478]42        SKYPE_CALL_FINISHED,
[d87daf3]43        SKYPE_CALL_REFUSED
[5365f84]44};
[bbba374]45
[359f4d9]46enum {
[df9255d]47        SKYPE_FILETRANSFER_NEW = 1,
[b2dc873]48        SKYPE_FILETRANSFER_TRANSFERRING,
49        SKYPE_FILETRANSFER_COMPLETED,
[df9255d]50        SKYPE_FILETRANSFER_FAILED
[5365f84]51};
[df9255d]52
[7daec06]53/*
54 * Structures
55 */
56
[5adcc65]57struct skype_data {
[f06e3ac]58        struct im_connection *ic;
[a3d6427]59        char *username;
[368861e]60        /* The effective file descriptor. We store it here so any function can
61         * write() to it. */
[f06e3ac]62        int fd;
[368861e]63        /* File descriptor returned by bitlbee. we store it so we know when
64         * we're connected and when we aren't. */
65        int bfd;
[c7304b2]66        /* ssl_getfd() uses this to get the file desciptor. */
67        void *ssl;
[2a0f99c]68        /* When we receive a new message id, we query the properties, finally
69         * the chatname. Store the properties here so that we can use
[c81d0ef]70         * imcb_buddy_msg() when we got the chatname. */
[77c1abe]71        char *handle;
[a7af5f0]72        /* List, because of multiline messages. */
73        GList *body;
[2a0f99c]74        char *type;
[bbba374]75        /* This is necessary because we send a notification when we get the
76         * handle. So we store the state here and then we can send a
77         * notification about the handle is in a given status. */
[359f4d9]78        int call_status;
[2eb4b1f]79        char *call_id;
[48181f0]80        char *call_duration;
[d87daf3]81        /* If the call is outgoing or not */
82        int call_out;
[df9255d]83        /* Same for file transfers. */
[359f4d9]84        int filetransfer_status;
[b2dc873]85        /* Path of the file being transferred. */
86        char *filetransfer_path;
[86278cd]87        /* Using /j #nick we want to have a groupchat with two people. Usually
88         * not (default). */
[5adcc65]89        char *groupchat_with;
[f8674db]90        /* The user who invited us to the chat. */
[5adcc65]91        char *adder;
[a5f76a2]92        /* If we are waiting for a confirmation about we changed the topic. */
93        int topic_wait;
[67454bd]94        /* These are used by the info command. */
95        char *info_fullname;
96        char *info_phonehome;
97        char *info_phoneoffice;
98        char *info_phonemobile;
99        char *info_nrbuddies;
100        char *info_tz;
101        char *info_seen;
102        char *info_birthday;
103        char *info_sex;
104        char *info_language;
105        char *info_country;
106        char *info_province;
107        char *info_city;
108        char *info_homepage;
109        char *info_about;
[b054fad]110        /* When a call fails, we get the reason and later we get the failure
111         * event, so store the failure code here till then */
112        int failurereason;
[d9ce18c]113        /* If this is just an update of an already received message. */
114        int is_edit;
[89d6845]115        /* List of struct skype_group* */
116        GList *groups;
[46641bf]117        /* Pending user which has to be added to the next group which is
118         * created. */
119        char *pending_user;
[36f6ab3]120        /* If the info command was used, to determine what to do with FULLNAME result. */
121        int is_info;
[f06e3ac]122};
123
[5adcc65]124struct skype_away_state {
[adce2de]125        char *code;
126        char *full_name;
127};
128
[5adcc65]129struct skype_buddy_ask_data {
[7daec06]130        struct im_connection *ic;
[e0074cb]131        /* This is also used for call IDs for simplicity */
[7daec06]132        char *handle;
133};
134
[89d6845]135struct skype_group {
136        int id;
137        char *name;
138        GList *users;
139};
140
[7daec06]141/*
142 * Tables
143 */
144
[5adcc65]145const struct skype_away_state skype_away_state_list[] = {
[bc744df]146        { "AWAY", "Away" },
147        { "NA", "Not available" },
148        { "DND", "Do Not Disturb" },
149        { "INVISIBLE", "Invisible" },
150        { "OFFLINE", "Offline" },
[4b740c2]151        { "SKYPEME", "Skype Me" },
152        { "ONLINE", "Online" },
[23411c6]153        { NULL, NULL}
[adce2de]154};
155
[7daec06]156/*
157 * Functions
158 */
[d3cbd17]159
[7c300bb]160int skype_write(struct im_connection *ic, char *buf, int len)
[f06e3ac]161{
162        struct skype_data *sd = ic->proto_data;
[1fb89e3]163        struct pollfd pfd[1];
164
[e8e2892]165        if (!sd->ssl)
166                return FALSE;
167
[1fb89e3]168        pfd[0].fd = sd->fd;
169        pfd[0].events = POLLOUT;
[f06e3ac]170
[7daec06]171        /* This poll is necessary or we'll get a SIGPIPE when we write() to
172         * sd->fd. */
[1fb89e3]173        poll(pfd, 1, 1000);
[5adcc65]174        if (pfd[0].revents & POLLHUP) {
175                imc_logout(ic, TRUE);
[1fb89e3]176                return FALSE;
177        }
[5adcc65]178        ssl_write(sd->ssl, buf, len);
[f06e3ac]179
[9fd4241]180        return TRUE;
[f06e3ac]181}
182
[1f4fc80]183int skype_printf(struct im_connection *ic, char *fmt, ...)
184{
185        va_list args;
186        char str[IRC_LINE_SIZE];
[5d9db76]187
[1f4fc80]188        va_start(args, fmt);
189        vsnprintf(str, IRC_LINE_SIZE, fmt, args);
190        va_end(args);
191
[7c300bb]192        return skype_write(ic, str, strlen(str));
[1f4fc80]193}
194
[5adcc65]195static void skype_buddy_ask_yes(void *data)
[d3cbd17]196{
[039116a]197        struct skype_buddy_ask_data *bla = data;
[5a0ffa2]198        skype_printf(bla->ic, "SET USER %s ISAUTHORIZED TRUE\n",
[8c09bb3]199                bla->handle);
[d3cbd17]200        g_free(bla->handle);
201        g_free(bla);
202}
203
[5adcc65]204static void skype_buddy_ask_no(void *data)
[d3cbd17]205{
[039116a]206        struct skype_buddy_ask_data *bla = data;
[5a0ffa2]207        skype_printf(bla->ic, "SET USER %s ISAUTHORIZED FALSE\n",
[8c09bb3]208                bla->handle);
[d3cbd17]209        g_free(bla->handle);
210        g_free(bla);
211}
212
[5adcc65]213void skype_buddy_ask(struct im_connection *ic, char *handle, char *message)
[d3cbd17]214{
[8c09bb3]215        struct skype_buddy_ask_data *bla = g_new0(struct skype_buddy_ask_data,
216                1);
[d3cbd17]217        char *buf;
218
219        bla->ic = ic;
220        bla->handle = g_strdup(handle);
221
[e1d6b38]222        buf = g_strdup_printf("The user %s wants to add you to his/her buddy list, saying: '%s'.", handle, message);
[5adcc65]223        imcb_ask(ic, buf, bla, skype_buddy_ask_yes, skype_buddy_ask_no);
224        g_free(buf);
[d3cbd17]225}
226
[5adcc65]227static void skype_call_ask_yes(void *data)
[e0074cb]228{
[039116a]229        struct skype_buddy_ask_data *bla = data;
[5a0ffa2]230        skype_printf(bla->ic, "SET CALL %s STATUS INPROGRESS\n",
[8c09bb3]231                bla->handle);
[e0074cb]232        g_free(bla->handle);
233        g_free(bla);
234}
235
[5adcc65]236static void skype_call_ask_no(void *data)
[e0074cb]237{
[039116a]238        struct skype_buddy_ask_data *bla = data;
[5a0ffa2]239        skype_printf(bla->ic, "SET CALL %s STATUS FINISHED\n",
[8c09bb3]240                bla->handle);
[e0074cb]241        g_free(bla->handle);
242        g_free(bla);
243}
244
[5adcc65]245void skype_call_ask(struct im_connection *ic, char *call_id, char *message)
[e0074cb]246{
[8c09bb3]247        struct skype_buddy_ask_data *bla = g_new0(struct skype_buddy_ask_data,
248                1);
[e0074cb]249
250        bla->ic = ic;
251        bla->handle = g_strdup(call_id);
252
[5adcc65]253        imcb_ask(ic, message, bla, skype_call_ask_yes, skype_call_ask_no);
[e0074cb]254}
[72aa7f0]255
[b054fad]256static char *skype_call_strerror(int err)
257{
[5adcc65]258        switch (err) {
259        case 1:
260                return "Miscellaneous error";
261        case 2:
262                return "User or phone number does not exist.";
263        case 3:
264                return "User is offline";
265        case 4:
266                return "No proxy found";
267        case 5:
268                return "Session terminated.";
269        case 6:
270                return "No common codec found.";
271        case 7:
272                return "Sound I/O error.";
273        case 8:
274                return "Problem with remote sound device.";
275        case 9:
276                return "Call blocked by recipient.";
277        case 10:
278                return "Recipient not a friend.";
279        case 11:
280                return "Current user not authorized by recipient.";
281        case 12:
282                return "Sound recording error.";
283        default:
284                return "Unknown error";
[b054fad]285        }
286}
287
[54ca269]288static char *skype_group_by_username(struct im_connection *ic, char *username)
289{
290        struct skype_data *sd = ic->proto_data;
291        int i, j;
292
293        /* NEEDSWORK: we just search for the first group of the user, multiple
294         * groups / user is not yet supported by BitlBee. */
295
296        for (i = 0; i < g_list_length(sd->groups); i++) {
297                struct skype_group *sg = g_list_nth_data(sd->groups, i);
298                for (j = 0; j < g_list_length(sg->users); j++) {
299                        if (!strcmp(g_list_nth_data(sg->users, j), username))
300                                return sg->name;
301                }
302        }
303        return NULL;
304}
305
[46e9822]306static struct skype_group *skype_group_by_name(struct im_connection *ic, char *name)
307{
308        struct skype_data *sd = ic->proto_data;
309        int i;
310
311        for (i = 0; i < g_list_length(sd->groups); i++) {
312                struct skype_group *sg = g_list_nth_data(sd->groups, i);
313                if (!strcmp(sg->name, name))
314                        return sg;
315        }
316        return NULL;
317}
318
[078b0b9]319static void skype_parse_users(struct im_connection *ic, char *line)
320{
[1f4fc80]321        char **i, **nicks;
[078b0b9]322
323        nicks = g_strsplit(line + 6, ", ", 0);
[36f6ab3]324        for (i = nicks; *i; i++) {
[1f4fc80]325                skype_printf(ic, "GET USER %s ONLINESTATUS\n", *i);
[36f6ab3]326                skype_printf(ic, "GET USER %s FULLNAME\n", *i);
327        }
[078b0b9]328        g_strfreev(nicks);
329}
330
[6e14204]331static void skype_parse_user(struct im_connection *ic, char *line)
332{
333        int flags = 0;
334        char *ptr;
335        struct skype_data *sd = ic->proto_data;
336        char *user = strchr(line, ' ');
337        char *status = strrchr(line, ' ');
338
339        status++;
340        ptr = strchr(++user, ' ');
341        if (!ptr)
342                return;
343        *ptr = '\0';
344        ptr++;
[49a3c02]345        if (!strncmp(ptr, "ONLINESTATUS ", 13)) {
346                        if (!strcmp(user, sd->username))
347                                return;
348                        if (!set_getbool(&ic->acc->set, "test_join")
349                                && !strcmp(user, "echo123"))
350                                return;
[6e14204]351                ptr = g_strdup_printf("%s@skype.com", user);
[54ca269]352                imcb_add_buddy(ic, ptr, skype_group_by_username(ic, user));
[62f51ee9]353                if (strcmp(status, "OFFLINE") && (strcmp(status, "SKYPEOUT") ||
354                        !set_getbool(&ic->acc->set, "skypeout_offline")))
[6e14204]355                        flags |= OPT_LOGGED_IN;
[62f51ee9]356                if (strcmp(status, "ONLINE") && strcmp(status, "SKYPEME"))
[6e14204]357                        flags |= OPT_AWAY;
358                imcb_buddy_status(ic, ptr, flags, NULL, NULL);
359                g_free(ptr);
360        } else if (!strncmp(ptr, "RECEIVEDAUTHREQUEST ", 20)) {
361                char *message = ptr + 20;
362                if (strlen(message))
363                        skype_buddy_ask(ic, user, message);
364        } else if (!strncmp(ptr, "BUDDYSTATUS ", 12)) {
365                char *st = ptr + 12;
366                if (!strcmp(st, "3")) {
367                        char *buf = g_strdup_printf("%s@skype.com", user);
[54ca269]368                        imcb_add_buddy(ic, buf, skype_group_by_username(ic, user));
[6e14204]369                        g_free(buf);
370                }
[78d22cd0]371        } else if (!strncmp(ptr, "MOOD_TEXT ", 10)) {
[4c674bb]372                char *buf = g_strdup_printf("%s@skype.com", user);
[78d22cd0]373                bee_user_t *bu = bee_user_by_handle(ic->bee, ic, buf);
374                g_free(buf);
375                buf = ptr + 10;
[451f121]376                if (bu)
[78d22cd0]377                        imcb_buddy_status(ic, bu->handle, bu->flags, NULL,
[4ab7225]378                                        *buf ? buf : NULL);
[78d22cd0]379                if (set_getbool(&ic->acc->set, "show_moods"))
380                        imcb_log(ic, "User `%s' changed mood text to `%s'", user, buf);
[36f6ab3]381        } else if (!strncmp(ptr, "FULLNAME ", 9)) {
382                char *name = ptr + 9;
383                if (sd->is_info) {
384                        sd->is_info = FALSE;
385                        sd->info_fullname = g_strdup(name);
386                } else {
387                        char *buf = g_strdup_printf("%s@skype.com", user);
388                        imcb_rename_buddy(ic, buf, name);
389                        g_free(buf);
390                }
391        } else if (!strncmp(ptr, "PHONE_HOME ", 11))
[d7938f9]392                sd->info_phonehome = g_strdup(ptr + 11);
[6e14204]393        else if (!strncmp(ptr, "PHONE_OFFICE ", 13))
[d7938f9]394                sd->info_phoneoffice = g_strdup(ptr + 13);
[6e14204]395        else if (!strncmp(ptr, "PHONE_MOBILE ", 13))
[d7938f9]396                sd->info_phonemobile = g_strdup(ptr + 13);
[6e14204]397        else if (!strncmp(ptr, "NROF_AUTHED_BUDDIES ", 20))
[d7938f9]398                sd->info_nrbuddies = g_strdup(ptr + 20);
[6e14204]399        else if (!strncmp(ptr, "TIMEZONE ", 9))
[d7938f9]400                sd->info_tz = g_strdup(ptr + 9);
[6e14204]401        else if (!strncmp(ptr, "LASTONLINETIMESTAMP ", 20))
[d7938f9]402                sd->info_seen = g_strdup(ptr + 20);
[6e14204]403        else if (!strncmp(ptr, "SEX ", 4))
[d7938f9]404                sd->info_sex = g_strdup(ptr + 4);
[6e14204]405        else if (!strncmp(ptr, "LANGUAGE ", 9))
[d7938f9]406                sd->info_language = g_strdup(ptr + 9);
[6e14204]407        else if (!strncmp(ptr, "COUNTRY ", 8))
[d7938f9]408                sd->info_country = g_strdup(ptr + 8);
[6e14204]409        else if (!strncmp(ptr, "PROVINCE ", 9))
[d7938f9]410                sd->info_province = g_strdup(ptr + 9);
[6e14204]411        else if (!strncmp(ptr, "CITY ", 5))
[d7938f9]412                sd->info_city = g_strdup(ptr + 5);
[6e14204]413        else if (!strncmp(ptr, "HOMEPAGE ", 9))
[d7938f9]414                sd->info_homepage = g_strdup(ptr + 9);
[6e14204]415        else if (!strncmp(ptr, "ABOUT ", 6)) {
[85341dd]416                /* Support multiple about lines. */
417                if (!sd->info_about)
418                        sd->info_about = g_strdup(ptr + 6);
419                else {
420                        GString *st = g_string_new(sd->info_about);
421                        g_string_append_printf(st, "\n%s", ptr + 6);
422                        g_free(sd->info_about);
423                        sd->info_about = g_strdup(st->str);
424                        g_string_free(st, TRUE);
425                }
[e1d6b38]426        } else if (!strncmp(ptr, "BIRTHDAY ", 9)) {
[85341dd]427                sd->info_birthday = g_strdup(ptr + 9);
[6e14204]428
429                GString *st = g_string_new("Contact Information\n");
430                g_string_append_printf(st, "Skype Name: %s\n", user);
431                if (sd->info_fullname) {
432                        if (strlen(sd->info_fullname))
[62f51ee9]433                                g_string_append_printf(st, "Full Name: %s\n",
434                                        sd->info_fullname);
[6e14204]435                        g_free(sd->info_fullname);
[7c2daf5f]436                        sd->info_fullname = NULL;
[6e14204]437                }
438                if (sd->info_phonehome) {
439                        if (strlen(sd->info_phonehome))
[62f51ee9]440                                g_string_append_printf(st, "Home Phone: %s\n",
441                                        sd->info_phonehome);
[6e14204]442                        g_free(sd->info_phonehome);
[7c2daf5f]443                        sd->info_phonehome = NULL;
[6e14204]444                }
445                if (sd->info_phoneoffice) {
446                        if (strlen(sd->info_phoneoffice))
[62f51ee9]447                                g_string_append_printf(st, "Office Phone: %s\n",
448                                        sd->info_phoneoffice);
[6e14204]449                        g_free(sd->info_phoneoffice);
[7c2daf5f]450                        sd->info_phoneoffice = NULL;
[6e14204]451                }
452                if (sd->info_phonemobile) {
453                        if (strlen(sd->info_phonemobile))
[62f51ee9]454                                g_string_append_printf(st, "Mobile Phone: %s\n",
455                                        sd->info_phonemobile);
[6e14204]456                        g_free(sd->info_phonemobile);
[7c2daf5f]457                        sd->info_phonemobile = NULL;
[6e14204]458                }
459                g_string_append_printf(st, "Personal Information\n");
460                if (sd->info_nrbuddies) {
461                        if (strlen(sd->info_nrbuddies))
[62f51ee9]462                                g_string_append_printf(st,
463                                        "Contacts: %s\n", sd->info_nrbuddies);
[6e14204]464                        g_free(sd->info_nrbuddies);
[7c2daf5f]465                        sd->info_nrbuddies = NULL;
[6e14204]466                }
467                if (sd->info_tz) {
468                        if (strlen(sd->info_tz)) {
469                                char ib[256];
470                                time_t t = time(NULL);
471                                t += atoi(sd->info_tz)-(60*60*24);
472                                struct tm *gt = gmtime(&t);
473                                strftime(ib, 256, "%H:%M:%S", gt);
[62f51ee9]474                                g_string_append_printf(st,
475                                        "Local Time: %s\n", ib);
[6e14204]476                        }
477                        g_free(sd->info_tz);
[7c2daf5f]478                        sd->info_tz = NULL;
[6e14204]479                }
480                if (sd->info_seen) {
481                        if (strlen(sd->info_seen)) {
482                                char ib[256];
483                                time_t it = atoi(sd->info_seen);
484                                struct tm *tm = localtime(&it);
485                                strftime(ib, 256, ("%Y. %m. %d. %H:%M"), tm);
[62f51ee9]486                                g_string_append_printf(st,
487                                        "Last Seen: %s\n", ib);
[6e14204]488                        }
489                        g_free(sd->info_seen);
[7c2daf5f]490                        sd->info_seen = NULL;
[6e14204]491                }
492                if (sd->info_birthday) {
[62f51ee9]493                        if (strlen(sd->info_birthday) &&
494                                strcmp(sd->info_birthday, "0")) {
[6e14204]495                                char ib[256];
496                                struct tm tm;
497                                strptime(sd->info_birthday, "%Y%m%d", &tm);
498                                strftime(ib, 256, "%B %d, %Y", &tm);
[62f51ee9]499                                g_string_append_printf(st,
500                                        "Birthday: %s\n", ib);
[6e14204]501
502                                strftime(ib, 256, "%Y", &tm);
503                                int year = atoi(ib);
504                                time_t t = time(NULL);
505                                struct tm *lt = localtime(&t);
[62f51ee9]506                                g_string_append_printf(st,
507                                        "Age: %d\n", lt->tm_year+1900-year);
[6e14204]508                        }
509                        g_free(sd->info_birthday);
[7c2daf5f]510                        sd->info_birthday = NULL;
[6e14204]511                }
512                if (sd->info_sex) {
513                        if (strlen(sd->info_sex)) {
514                                char *iptr = sd->info_sex;
515                                while (*iptr++)
516                                        *iptr = tolower(*iptr);
[62f51ee9]517                                g_string_append_printf(st,
518                                        "Gender: %s\n", sd->info_sex);
[6e14204]519                        }
520                        g_free(sd->info_sex);
[7c2daf5f]521                        sd->info_sex = NULL;
[6e14204]522                }
523                if (sd->info_language) {
524                        if (strlen(sd->info_language)) {
525                                char *iptr = strchr(sd->info_language, ' ');
526                                if (iptr)
527                                        iptr++;
528                                else
529                                        iptr = sd->info_language;
[62f51ee9]530                                g_string_append_printf(st,
531                                        "Language: %s\n", iptr);
[6e14204]532                        }
533                        g_free(sd->info_language);
[7c2daf5f]534                        sd->info_language = NULL;
[6e14204]535                }
536                if (sd->info_country) {
537                        if (strlen(sd->info_country)) {
538                                char *iptr = strchr(sd->info_country, ' ');
539                                if (iptr)
540                                        iptr++;
541                                else
542                                        iptr = sd->info_country;
[62f51ee9]543                                g_string_append_printf(st,
544                                        "Country: %s\n", iptr);
[6e14204]545                        }
546                        g_free(sd->info_country);
[7c2daf5f]547                        sd->info_country = NULL;
[6e14204]548                }
549                if (sd->info_province) {
550                        if (strlen(sd->info_province))
[62f51ee9]551                                g_string_append_printf(st,
552                                        "Region: %s\n", sd->info_province);
[6e14204]553                        g_free(sd->info_province);
[7c2daf5f]554                        sd->info_province = NULL;
[6e14204]555                }
556                if (sd->info_city) {
557                        if (strlen(sd->info_city))
[62f51ee9]558                                g_string_append_printf(st,
559                                        "City: %s\n", sd->info_city);
[6e14204]560                        g_free(sd->info_city);
[7c2daf5f]561                        sd->info_city = NULL;
[6e14204]562                }
563                if (sd->info_homepage) {
564                        if (strlen(sd->info_homepage))
[62f51ee9]565                                g_string_append_printf(st,
566                                        "Homepage: %s\n", sd->info_homepage);
[6e14204]567                        g_free(sd->info_homepage);
[7c2daf5f]568                        sd->info_homepage = NULL;
[6e14204]569                }
570                if (sd->info_about) {
571                        if (strlen(sd->info_about))
[62f51ee9]572                                g_string_append_printf(st, "%s\n",
573                                        sd->info_about);
[6e14204]574                        g_free(sd->info_about);
[7c2daf5f]575                        sd->info_about = NULL;
[6e14204]576                }
577                imcb_log(ic, "%s", st->str);
578                g_string_free(st, TRUE);
579        }
580}
581
[e1d6b38]582static void skype_parse_chatmessage_said_emoted(struct im_connection *ic, struct groupchat *gc, char *body)
[6e14204]583{
584        struct skype_data *sd = ic->proto_data;
[c213d6b]585        char buf[IRC_LINE_SIZE];
[e1d6b38]586        if (!strcmp(sd->type, "SAID")) {
587                if (!sd->is_edit)
588                        g_snprintf(buf, IRC_LINE_SIZE, "%s", body);
589                else {
590                        g_snprintf(buf, IRC_LINE_SIZE, "%s %s", set_getstr(&ic->acc->set, "edit_prefix"), body);
591                        sd->is_edit = 0;
592                }
593        } else
594                g_snprintf(buf, IRC_LINE_SIZE, "/me %s", body);
595        if (!gc)
596                /* Private message */
597                imcb_buddy_msg(ic, sd->handle, buf, 0, 0);
598        else
599                /* Groupchat message */
600                imcb_chat_msg(gc, sd->handle, buf, 0, 0);
601}
602
603static void skype_parse_chatmessage(struct im_connection *ic, char *line)
604{
605        struct skype_data *sd = ic->proto_data;
[6e14204]606        char *id = strchr(line, ' ');
607
[6b9d22a]608        if (!++id)
609                return;
610        char *info = strchr(id, ' ');
611
612        if (!info)
613                return;
614        *info = '\0';
615        info++;
[7825f58]616        if (!strcmp(info, "STATUS RECEIVED") || !strncmp(info, "EDITED_TIMESTAMP", 16)) {
[6b9d22a]617                /* New message ID:
618                 * (1) Request its from field
619                 * (2) Request its body
620                 * (3) Request its type
621                 * (4) Query chatname
622                 */
[1f4fc80]623                skype_printf(ic, "GET CHATMESSAGE %s FROM_HANDLE\n", id);
[d1d5b34]624                if (!strcmp(info, "STATUS RECEIVED"))
625                        skype_printf(ic, "GET CHATMESSAGE %s BODY\n", id);
[d9ce18c]626                else
627                        sd->is_edit = 1;
[1f4fc80]628                skype_printf(ic, "GET CHATMESSAGE %s TYPE\n", id);
629                skype_printf(ic, "GET CHATMESSAGE %s CHATNAME\n", id);
[6b9d22a]630        } else if (!strncmp(info, "FROM_HANDLE ", 12)) {
631                info += 12;
632                /* New from field value. Store
633                 * it, then we can later use it
634                 * when we got the message's
635                 * body. */
636                g_free(sd->handle);
637                sd->handle = g_strdup_printf("%s@skype.com", info);
638        } else if (!strncmp(info, "EDITED_BY ", 10)) {
639                info += 10;
640                /* This is the same as
641                 * FROM_HANDLE, except that we
642                 * never request these lines
643                 * from Skype, we just get
644                 * them. */
645                g_free(sd->handle);
646                sd->handle = g_strdup_printf("%s@skype.com", info);
647        } else if (!strncmp(info, "BODY ", 5)) {
648                info += 5;
649                sd->body = g_list_append(sd->body, g_strdup(info));
650        }       else if (!strncmp(info, "TYPE ", 5)) {
651                info += 5;
652                g_free(sd->type);
653                sd->type = g_strdup(info);
[7825f58]654        } else if (!strncmp(info, "CHATNAME ", 9)) {
655                info += 9;
656                if (sd->handle && sd->body && sd->type) {
[451f121]657                        struct groupchat *gc = bee_chat_by_title(ic->bee, ic, info);
[7825f58]658                        int i;
659                        for (i = 0; i < g_list_length(sd->body); i++) {
660                                char *body = g_list_nth_data(sd->body, i);
661                                if (!strcmp(sd->type, "SAID") ||
662                                        !strcmp(sd->type, "EMOTED")) {
[e1d6b38]663                                        skype_parse_chatmessage_said_emoted(ic, gc, body);
[7825f58]664                                } else if (!strcmp(sd->type, "SETTOPIC") && gc)
665                                        imcb_chat_topic(gc,
666                                                sd->handle, body, 0);
667                                else if (!strcmp(sd->type, "LEFT") && gc)
668                                        imcb_chat_remove_buddy(gc,
669                                                sd->handle, NULL);
[6e14204]670                        }
[7825f58]671                        g_list_free(sd->body);
672                        sd->body = NULL;
673                }
[6e14204]674        }
675}
676
[9f2f25f]677static void skype_parse_call(struct im_connection *ic, char *line)
678{
679        struct skype_data *sd = ic->proto_data;
680        char *id = strchr(line, ' ');
[c213d6b]681        char buf[IRC_LINE_SIZE];
[9f2f25f]682
[6b9d22a]683        if (!++id)
684                return;
685        char *info = strchr(id, ' ');
686
687        if (!info)
688                return;
689        *info = '\0';
690        info++;
691        if (!strncmp(info, "FAILUREREASON ", 14))
692                sd->failurereason = atoi(strchr(info, ' '));
693        else if (!strcmp(info, "STATUS RINGING")) {
694                if (sd->call_id)
695                        g_free(sd->call_id);
696                sd->call_id = g_strdup(id);
[1f4fc80]697                skype_printf(ic, "GET CALL %s PARTNER_HANDLE\n", id);
[6b9d22a]698                sd->call_status = SKYPE_CALL_RINGING;
699        } else if (!strcmp(info, "STATUS MISSED")) {
[1f4fc80]700                skype_printf(ic, "GET CALL %s PARTNER_HANDLE\n", id);
[6b9d22a]701                sd->call_status = SKYPE_CALL_MISSED;
702        } else if (!strcmp(info, "STATUS CANCELLED")) {
[1f4fc80]703                skype_printf(ic, "GET CALL %s PARTNER_HANDLE\n", id);
[6b9d22a]704                sd->call_status = SKYPE_CALL_CANCELLED;
705        } else if (!strcmp(info, "STATUS FINISHED")) {
[1f4fc80]706                skype_printf(ic, "GET CALL %s PARTNER_HANDLE\n", id);
[6b9d22a]707                sd->call_status = SKYPE_CALL_FINISHED;
708        } else if (!strcmp(info, "STATUS REFUSED")) {
[1f4fc80]709                skype_printf(ic, "GET CALL %s PARTNER_HANDLE\n", id);
[6b9d22a]710                sd->call_status = SKYPE_CALL_REFUSED;
711        } else if (!strcmp(info, "STATUS UNPLACED")) {
712                if (sd->call_id)
713                        g_free(sd->call_id);
714                /* Save the ID for later usage (Cancel/Finish). */
715                sd->call_id = g_strdup(id);
716                sd->call_out = TRUE;
717        } else if (!strcmp(info, "STATUS FAILED")) {
[62f51ee9]718                imcb_error(ic, "Call failed: %s",
719                        skype_call_strerror(sd->failurereason));
[6b9d22a]720                sd->call_id = NULL;
721        } else if (!strncmp(info, "DURATION ", 9)) {
722                if (sd->call_duration)
723                        g_free(sd->call_duration);
724                sd->call_duration = g_strdup(info+9);
725        } else if (!strncmp(info, "PARTNER_HANDLE ", 15)) {
726                info += 15;
[62f51ee9]727                if (!sd->call_status)
728                        return;
729                switch (sd->call_status) {
730                case SKYPE_CALL_RINGING:
731                        if (sd->call_out)
[e1d6b38]732                                imcb_log(ic, "You are currently ringing the user %s.", info);
[62f51ee9]733                        else {
[c213d6b]734                                g_snprintf(buf, IRC_LINE_SIZE,
[62f51ee9]735                                        "The user %s is currently ringing you.",
736                                        info);
737                                skype_call_ask(ic, sd->call_id, buf);
[9f2f25f]738                        }
[62f51ee9]739                        break;
740                case SKYPE_CALL_MISSED:
741                        imcb_log(ic, "You have missed a call from user %s.",
742                                info);
743                        break;
744                case SKYPE_CALL_CANCELLED:
745                        imcb_log(ic, "You cancelled the call to the user %s.",
746                                info);
[6b9d22a]747                        sd->call_status = 0;
[62f51ee9]748                        sd->call_out = FALSE;
749                        break;
750                case SKYPE_CALL_REFUSED:
751                        if (sd->call_out)
752                                imcb_log(ic, "The user %s refused the call.",
753                                        info);
754                        else
755                                imcb_log(ic,
756                                        "You refused the call from user %s.",
757                                        info);
758                        sd->call_out = FALSE;
759                        break;
760                case SKYPE_CALL_FINISHED:
761                        if (sd->call_duration)
762                                imcb_log(ic,
763                                        "You finished the call to the user %s "
764                                        "(duration: %s seconds).",
765                                        info, sd->call_duration);
766                        else
767                                imcb_log(ic,
768                                        "You finished the call to the user %s.",
769                                        info);
770                        sd->call_out = FALSE;
771                        break;
772                default:
773                        /* Don't be noisy, ignore other statuses for now. */
774                        break;
[9f2f25f]775                }
[62f51ee9]776                sd->call_status = 0;
[9f2f25f]777        }
778}
779
[e200daf]780static void skype_parse_filetransfer(struct im_connection *ic, char *line)
781{
782        struct skype_data *sd = ic->proto_data;
783        char *id = strchr(line, ' ');
784
[6b9d22a]785        if (!++id)
786                return;
787        char *info = strchr(id, ' ');
788
789        if (!info)
790                return;
791        *info = '\0';
792        info++;
793        if (!strcmp(info, "STATUS NEW")) {
[1f4fc80]794                skype_printf(ic, "GET FILETRANSFER %s PARTNER_HANDLE\n",
[62f51ee9]795                        id);
[6b9d22a]796                sd->filetransfer_status = SKYPE_FILETRANSFER_NEW;
797        } else if (!strcmp(info, "STATUS FAILED")) {
[1f4fc80]798                skype_printf(ic, "GET FILETRANSFER %s PARTNER_HANDLE\n",
[62f51ee9]799                        id);
[6b9d22a]800                sd->filetransfer_status = SKYPE_FILETRANSFER_FAILED;
[b2dc873]801        } else if (!strcmp(info, "STATUS COMPLETED")) {
802                skype_printf(ic, "GET FILETRANSFER %s PARTNER_HANDLE\n", id);
803                sd->filetransfer_status = SKYPE_FILETRANSFER_COMPLETED;
804        } else if (!strcmp(info, "STATUS TRANSFERRING")) {
805                skype_printf(ic, "GET FILETRANSFER %s PARTNER_HANDLE\n", id);
806                sd->filetransfer_status = SKYPE_FILETRANSFER_TRANSFERRING;
807        } else if (!strncmp(info, "FILEPATH ", 9)) {
808                info += 9;
809                sd->filetransfer_path = g_strdup(info);
[6b9d22a]810        } else if (!strncmp(info, "PARTNER_HANDLE ", 15)) {
811                info += 15;
[62f51ee9]812                if (!sd->filetransfer_status)
813                        return;
814                switch (sd->filetransfer_status) {
815                case SKYPE_FILETRANSFER_NEW:
816                        imcb_log(ic, "The user %s offered a new file for you.",
817                                info);
818                        break;
819                case SKYPE_FILETRANSFER_FAILED:
820                        imcb_log(ic, "Failed to transfer file from user %s.",
821                                info);
822                        break;
[b2dc873]823                case SKYPE_FILETRANSFER_COMPLETED:
824                        imcb_log(ic, "File transfer from user %s completed.", info);
825                        break;
826                case SKYPE_FILETRANSFER_TRANSFERRING:
827                        if (sd->filetransfer_path) {
828                                imcb_log(ic, "File transfer from user %s started, saving to %s.", info, sd->filetransfer_path);
829                                g_free(sd->filetransfer_path);
830                                sd->filetransfer_path = NULL;
831                        }
832                        break;
[e200daf]833                }
[62f51ee9]834                sd->filetransfer_status = 0;
[e200daf]835        }
836}
837
[fbb15f2]838static struct skype_group *skype_group_by_id(struct im_connection *ic, int id)
839{
[89d6845]840        struct skype_data *sd = ic->proto_data;
841        int i;
842
843        for (i = 0; i < g_list_length(sd->groups); i++) {
844                struct skype_group *sg = (struct skype_group *)g_list_nth_data(sd->groups, i);
845
846                if (sg->id == id)
847                        return sg;
848        }
849        return NULL;
850}
851
[fbb15f2]852static void skype_group_free(struct skype_group *sg, gboolean usersonly)
853{
[89d6845]854        int i;
[fbb15f2]855
[89d6845]856        for (i = 0; i < g_list_length(sg->users); i++) {
857                char *user = g_list_nth_data(sg->users, i);
858                g_free(user);
859        }
860        sg->users = NULL;
861        if (usersonly)
862                return;
863        g_free(sg->name);
864        g_free(sg);
865}
866
[54ca269]867/* Update the group of each user in this group */
[fbb15f2]868static void skype_group_users(struct im_connection *ic, struct skype_group *sg)
869{
[54ca269]870        int i;
871
872        for (i = 0; i < g_list_length(sg->users); i++) {
873                char *user = g_list_nth_data(sg->users, i);
874                char *buf = g_strdup_printf("%s@skype.com", user);
875                imcb_add_buddy(ic, buf, sg->name);
876                g_free(buf);
877        }
878}
879
[89d6845]880static void skype_parse_group(struct im_connection *ic, char *line)
881{
882        struct skype_data *sd = ic->proto_data;
883        char *id = strchr(line, ' ');
884
885        if (!++id)
886                return;
887
888        char *info = strchr(id, ' ');
889
890        if (!info)
891                return;
892        *info = '\0';
893        info++;
894
895        if (!strncmp(info, "DISPLAYNAME ", 12)) {
896                info += 12;
897
898                /* Name given for a group ID: try to update it or insert a new
899                 * one if not found */
900                struct skype_group *sg = skype_group_by_id(ic, atoi(id));
901                if (sg) {
902                        g_free(sg->name);
903                        sg->name = g_strdup(info);
904                } else {
905                        sg = g_new0(struct skype_group, 1);
906                        sg->id = atoi(id);
907                        sg->name = g_strdup(info);
908                        sd->groups = g_list_append(sd->groups, sg);
909                }
910        } else if (!strncmp(info, "USERS ", 6)) {
911                struct skype_group *sg = skype_group_by_id(ic, atoi(id));
912
913                if (sg) {
914                        char **i;
915                        char **users = g_strsplit(info + 6, ", ", 0);
916
917                        skype_group_free(sg, TRUE);
918                        i = users;
919                        while (*i) {
920                                sg->users = g_list_append(sg->users, g_strdup(*i));
921                                i++;
922                        }
923                        g_strfreev(users);
[54ca269]924                        skype_group_users(ic, sg);
[89d6845]925                } else
[fbb15f2]926                        log_message(LOGLVL_ERROR,
927                                "No skype group with id %s. That's probably a bug.", id);
[46641bf]928        } else if (!strncmp(info, "NROFUSERS ", 10)) {
929                if (!sd->pending_user) {
930                        /* Number of users changed in this group, query its type to see
931                         * if it's a custom one we should care about. */
[5a0ffa2]932                        skype_printf(ic, "GET GROUP %s TYPE\n", id);
[46641bf]933                        return;
934                }
935
936                /* This is a newly created group, we have a single user
937                 * to add. */
938                struct skype_group *sg = skype_group_by_id(ic, atoi(id));
939
940                if (sg) {
[5a0ffa2]941                        skype_printf(ic, "ALTER GROUP %d ADDUSER %s\n", sg->id, sd->pending_user);
[46641bf]942                        g_free(sd->pending_user);
943                        sd->pending_user = NULL;
944                } else
945                        log_message(LOGLVL_ERROR,
946                                        "No skype group with id %s. That's probably a bug.", id);
[2b183e4]947        } else if (!strcmp(info, "TYPE CUSTOM_GROUP"))
[cb6d3c9]948                /* This one is interesting, query its users. */
[5a0ffa2]949                skype_printf(ic, "GET GROUP %s USERS\n", id);
[89d6845]950}
951
[c35bf7a]952static void skype_parse_chat(struct im_connection *ic, char *line)
953{
954        struct skype_data *sd = ic->proto_data;
[c213d6b]955        char buf[IRC_LINE_SIZE];
[c35bf7a]956        char *id = strchr(line, ' ');
957
[6b9d22a]958        if (!++id)
959                return;
960        struct groupchat *gc;
961        char *info = strchr(id, ' ');
[c35bf7a]962
[6b9d22a]963        if (!info)
964                return;
965        *info = '\0';
966        info++;
967        /* Remove fake chat if we created one in skype_chat_with() */
[451f121]968        gc = bee_chat_by_title(ic->bee, ic, "");
[6b9d22a]969        if (gc)
970                imcb_chat_free(gc);
971        if (!strcmp(info, "STATUS MULTI_SUBSCRIBED")) {
[c573f1b]972                gc = bee_chat_by_title(ic->bee, ic, id);
973                if (!gc) {
974                        gc = imcb_chat_new(ic, id);
975                        imcb_chat_name_hint(gc, id);
976                }
[1f4fc80]977                skype_printf(ic, "GET CHAT %s ADDER\n", id);
978                skype_printf(ic, "GET CHAT %s TOPIC\n", id);
[6b9d22a]979        } else if (!strcmp(info, "STATUS DIALOG") && sd->groupchat_with) {
980                gc = imcb_chat_new(ic, id);
[72b60c7e]981                imcb_chat_name_hint(gc, id);
[6b9d22a]982                /* According to the docs this
983                 * is necessary. However it
984                 * does not seem the situation
985                 * and it would open an extra
986                 * window on our client, so
987                 * just leave it out. */
[1f4fc80]988                /*skype_printf(ic, "OPEN CHAT %s\n", id);*/
[5d9db76]989                g_snprintf(buf, IRC_LINE_SIZE, "%s@skype.com",
990                                sd->groupchat_with);
[6b9d22a]991                imcb_chat_add_buddy(gc, buf);
992                imcb_chat_add_buddy(gc, sd->username);
993                g_free(sd->groupchat_with);
994                sd->groupchat_with = NULL;
[1f4fc80]995                skype_printf(ic, "GET CHAT %s ADDER\n", id);
996                skype_printf(ic, "GET CHAT %s TOPIC\n", id);
[6b9d22a]997        } else if (!strcmp(info, "STATUS UNSUBSCRIBED")) {
[451f121]998                gc = bee_chat_by_title(ic->bee, ic, id);
[c35bf7a]999                if (gc)
[6b9d22a]1000                        gc->data = (void *)FALSE;
1001        } else if (!strncmp(info, "ADDER ", 6)) {
1002                info += 6;
1003                g_free(sd->adder);
1004                sd->adder = g_strdup_printf("%s@skype.com", info);
1005        } else if (!strncmp(info, "TOPIC ", 6)) {
1006                info += 6;
[451f121]1007                gc = bee_chat_by_title(ic->bee, ic, id);
[6b9d22a]1008                if (gc && (sd->adder || sd->topic_wait)) {
1009                        if (sd->topic_wait) {
1010                                sd->adder = g_strdup(sd->username);
1011                                sd->topic_wait = 0;
[c35bf7a]1012                        }
[6b9d22a]1013                        imcb_chat_topic(gc, sd->adder, info, 0);
1014                        g_free(sd->adder);
1015                        sd->adder = NULL;
1016                }
[6f360a0]1017        } else if (!strncmp(info, "MEMBERS ", 8) || !strncmp(info, "ACTIVEMEMBERS ", 14) ) {
[2487112]1018                info += 8;
[451f121]1019                gc = bee_chat_by_title(ic->bee, ic, id);
[6b9d22a]1020                /* Hack! We set ->data to TRUE
1021                 * while we're on the channel
1022                 * so that we won't rejoin
1023                 * after a /part. */
[62f51ee9]1024                if (!gc || gc->data)
1025                        return;
1026                char **members = g_strsplit(info, " ", 0);
1027                int i;
1028                for (i = 0; members[i]; i++) {
1029                        if (!strcmp(members[i], sd->username))
1030                                continue;
[5d9db76]1031                        g_snprintf(buf, IRC_LINE_SIZE, "%s@skype.com",
1032                                        members[i]);
[62f51ee9]1033                        if (!g_list_find_custom(gc->in_room, buf,
1034                                (GCompareFunc)strcmp))
1035                                imcb_chat_add_buddy(gc, buf);
[c35bf7a]1036                }
[62f51ee9]1037                imcb_chat_add_buddy(gc, sd->username);
1038                g_strfreev(members);
[c35bf7a]1039        }
1040}
1041
[2709f4c]1042static void skype_parse_password(struct im_connection *ic, char *line)
1043{
1044        if (!strncmp(line+9, "OK", 2))
1045                imcb_connected(ic);
1046        else {
1047                imcb_error(ic, "Authentication Failed");
1048                imc_logout(ic, TRUE);
1049        }
1050}
1051
[607f5e3]1052static void skype_parse_profile(struct im_connection *ic, char *line)
1053{
1054        imcb_log(ic, "SkypeOut balance value is '%s'.", line+21);
1055}
1056
1057static void skype_parse_ping(struct im_connection *ic, char *line)
1058{
[4ae3ffc]1059        /* Unused parameter */
1060        line = line;
[1f4fc80]1061        skype_printf(ic, "PONG\n");
[607f5e3]1062}
1063
1064static void skype_parse_chats(struct im_connection *ic, char *line)
1065{
1066        char **i;
1067        char **chats = g_strsplit(line + 6, ", ", 0);
1068
1069        i = chats;
1070        while (*i) {
[1f4fc80]1071                skype_printf(ic, "GET CHAT %s STATUS\n", *i);
1072                skype_printf(ic, "GET CHAT %s ACTIVEMEMBERS\n", *i);
[607f5e3]1073                i++;
1074        }
1075        g_strfreev(chats);
1076}
1077
[8b8d1bed]1078static void skype_parse_groups(struct im_connection *ic, char *line)
1079{
[3c7af69]1080        if (!set_getbool(&ic->acc->set, "read_groups"))
1081                return;
1082
[8b8d1bed]1083        char **i;
1084        char **groups = g_strsplit(line + 7, ", ", 0);
1085
1086        i = groups;
1087        while (*i) {
1088                skype_printf(ic, "GET GROUP %s DISPLAYNAME\n", *i);
1089                skype_printf(ic, "GET GROUP %s USERS\n", *i);
1090                i++;
1091        }
1092        g_strfreev(groups);
1093}
1094
[46e9822]1095static void skype_parse_alter_group(struct im_connection *ic, char *line)
1096{
1097        char *id = line + strlen("ALTER GROUP");
1098
1099        if (!++id)
1100                return;
1101
1102        char *info = strchr(id, ' ');
1103
1104        if (!info)
1105                return;
1106        *info = '\0';
1107        info++;
1108
1109        if (!strncmp(info, "ADDUSER ", 8)) {
1110                struct skype_group *sg = skype_group_by_id(ic, atoi(id));
1111
1112                info += 8;
1113                if (sg) {
1114                        char *buf = g_strdup_printf("%s@skype.com", info);
1115                        sg->users = g_list_append(sg->users, g_strdup(info));
1116                        imcb_add_buddy(ic, buf, sg->name);
1117                        g_free(buf);
1118                } else
1119                        log_message(LOGLVL_ERROR,
1120                                "No skype group with id %s. That's probably a bug.", id);
1121        }
1122}
1123
[ff436ba]1124typedef void (*skype_parser)(struct im_connection *ic, char *line);
1125
[8c09bb3]1126static gboolean skype_read_callback(gpointer data, gint fd,
1127                                    b_input_condition cond)
[1323e36]1128{
1129        struct im_connection *ic = data;
1130        struct skype_data *sd = ic->proto_data;
[c213d6b]1131        char buf[IRC_LINE_SIZE];
[ff436ba]1132        int st, i;
[6e14204]1133        char **lines, **lineptr, *line;
[ff436ba]1134        static struct parse_map {
1135                char *k;
1136                skype_parser v;
1137        } parsers[] = {
1138                { "USERS ", skype_parse_users },
1139                { "USER ", skype_parse_user },
1140                { "CHATMESSAGE ", skype_parse_chatmessage },
1141                { "CALL ", skype_parse_call },
1142                { "FILETRANSFER ", skype_parse_filetransfer },
1143                { "CHAT ", skype_parse_chat },
[89d6845]1144                { "GROUP ", skype_parse_group },
[ff436ba]1145                { "PASSWORD ", skype_parse_password },
1146                { "PROFILE PSTN_BALANCE ", skype_parse_profile },
1147                { "PING", skype_parse_ping },
1148                { "CHATS ", skype_parse_chats },
[8b8d1bed]1149                { "GROUPS ", skype_parse_groups },
[46e9822]1150                { "ALTER GROUP ", skype_parse_alter_group },
[ff436ba]1151        };
[1323e36]1152
[4ae3ffc]1153        /* Unused parameters */
1154        fd = fd;
1155        cond = cond;
1156
[5adcc65]1157        if (!sd || sd->fd == -1)
[1323e36]1158                return FALSE;
[7daec06]1159        /* Read the whole data. */
[5adcc65]1160        st = ssl_read(sd->ssl, buf, sizeof(buf));
[61d2eabb]1161        if (st >= IRC_LINE_SIZE-1) {
1162                /* As we don't buffer incoming data, if IRC_LINE_SIZE amount of bytes
1163                 * were received, there's a good chance last message was truncated
1164                 * and the next recv() will yield garbage. */
1165                imcb_error(ic, "Unable to handle incoming data from skyped");
1166                st = 0;
1167        }
[5adcc65]1168        if (st > 0) {
[1323e36]1169                buf[st] = '\0';
[7daec06]1170                /* Then split it up to lines. */
[9fd4241]1171                lines = g_strsplit(buf, "\n", 0);
1172                lineptr = lines;
[5adcc65]1173                while ((line = *lineptr)) {
1174                        if (!strlen(line))
[9fd4241]1175                                break;
[b820226]1176                        if (set_getbool(&ic->acc->set, "skypeconsole_receive"))
1177                                imcb_buddy_msg(ic, "skypeconsole", line, 0, 0);
[6b9d22a]1178                        for (i = 0; i < ARRAY_SIZE(parsers); i++)
1179                                if (!strncmp(line, parsers[i].k,
1180                                        strlen(parsers[i].k))) {
[ff436ba]1181                                        parsers[i].v(ic, line);
1182                                        break;
1183                                }
[9fd4241]1184                        lineptr++;
1185                }
1186                g_strfreev(lines);
[5adcc65]1187        } else if (st == 0 || (st < 0 && !sockerr_again())) {
[58b65b33]1188                ssl_disconnect(sd->ssl);
[1323e36]1189                sd->fd = -1;
[58b65b33]1190                sd->ssl = NULL;
[1323e36]1191
[5adcc65]1192                imcb_error(ic, "Error while reading from server");
1193                imc_logout(ic, TRUE);
[1323e36]1194                return FALSE;
1195        }
1196        return TRUE;
1197}
1198
[5adcc65]1199gboolean skype_start_stream(struct im_connection *ic)
[f06e3ac]1200{
[1323e36]1201        struct skype_data *sd = ic->proto_data;
[f06e3ac]1202        int st;
1203
[5adcc65]1204        if (!sd)
[1fb89e3]1205                return FALSE;
1206
[5adcc65]1207        if (sd->bfd <= 0)
[7670b02]1208                sd->bfd = b_input_add(sd->fd, B_EV_IO_READ,
[8c09bb3]1209                        skype_read_callback, ic);
[1323e36]1210
[a0b206b]1211        /* Log in */
[1f4fc80]1212        skype_printf(ic, "USERNAME %s\n", ic->acc->user);
1213        skype_printf(ic, "PASSWORD %s\n", ic->acc->pass);
[a0b206b]1214
[8b8d1bed]1215        /* This will download all buddies and groups. */
[54ca269]1216        st = skype_printf(ic, "SEARCH GROUPS CUSTOM\n");
1217        skype_printf(ic, "SEARCH FRIENDS\n");
[8b8d1bed]1218
[1f4fc80]1219        skype_printf(ic, "SET USERSTATUS ONLINE\n");
[5acf9ab]1220
1221        /* Auto join to bookmarked chats if requested.*/
[215e171]1222        if (set_getbool(&ic->acc->set, "auto_join")) {
[1f4fc80]1223                skype_printf(ic, "SEARCH BOOKMARKEDCHATS\n");
[215e171]1224                skype_printf(ic, "SEARCH ACTIVECHATS\n");
1225                skype_printf(ic, "SEARCH MISSEDCHATS\n");
1226                skype_printf(ic, "SEARCH RECENTCHATS\n");
1227        }
[f06e3ac]1228        return st;
1229}
1230
[486ddb5]1231gboolean skype_connected(gpointer data, int returncode, void *source, b_input_condition cond)
[f06e3ac]1232{
1233        struct im_connection *ic = data;
[c7304b2]1234        struct skype_data *sd = ic->proto_data;
[4ae3ffc]1235
1236        /* Unused parameter */
1237        cond = cond;
1238
[5adcc65]1239        if (!source) {
[c7304b2]1240                sd->ssl = NULL;
[5adcc65]1241                imcb_error(ic, "Could not connect to server");
1242                imc_logout(ic, TRUE);
[c7304b2]1243                return FALSE;
1244        }
[5adcc65]1245        imcb_log(ic, "Connected to server, logging in");
[4ae3ffc]1246
[f06e3ac]1247        return skype_start_stream(ic);
1248}
1249
[5adcc65]1250static void skype_login(account_t *acc)
[f06e3ac]1251{
[5adcc65]1252        struct im_connection *ic = imcb_new(acc);
1253        struct skype_data *sd = g_new0(struct skype_data, 1);
[f06e3ac]1254
1255        ic->proto_data = sd;
1256
[5adcc65]1257        imcb_log(ic, "Connecting");
[8c09bb3]1258        sd->ssl = ssl_connect(set_getstr(&acc->set, "server"),
[a72dc2b]1259                set_getint(&acc->set, "port"), FALSE, skype_connected, ic);
[5adcc65]1260        sd->fd = sd->ssl ? ssl_getfd(sd->ssl) : -1;
1261        sd->username = g_strdup(acc->user);
[f06e3ac]1262
1263        sd->ic = ic;
[08a355b]1264
1265        if (set_getbool(&acc->set, "skypeconsole"))
1266                imcb_add_buddy(ic, "skypeconsole", NULL);
[f06e3ac]1267}
1268
[5adcc65]1269static void skype_logout(struct im_connection *ic)
[f06e3ac]1270{
1271        struct skype_data *sd = ic->proto_data;
[89d6845]1272        int i;
[98bca36]1273
[1f4fc80]1274        skype_printf(ic, "SET USERSTATUS OFFLINE\n");
[98bca36]1275
[e1d6b38]1276        while (ic->groupchats)
[bd11422]1277                imcb_chat_free(ic->groupchats->data);
1278
[89d6845]1279        for (i = 0; i < g_list_length(sd->groups); i++) {
1280                struct skype_group *sg = (struct skype_group *)g_list_nth_data(sd->groups, i);
1281                skype_group_free(sg, FALSE);
1282        }
[58b65b33]1283
1284        if (sd->ssl)
1285                ssl_disconnect(sd->ssl);
1286
[a3d6427]1287        g_free(sd->username);
[7613670]1288        g_free(sd->handle);
[f06e3ac]1289        g_free(sd);
[98bca36]1290        ic->proto_data = NULL;
[f06e3ac]1291}
1292
[8c09bb3]1293static int skype_buddy_msg(struct im_connection *ic, char *who, char *message,
1294                           int flags)
[93ece66]1295{
[1f4fc80]1296        char *ptr, *nick;
[93ece66]1297        int st;
1298
[4ae3ffc]1299        /* Unused parameter */
1300        flags = flags;
1301
[cbec0d6]1302        nick = g_strdup(who);
[77c1abe]1303        ptr = strchr(nick, '@');
[5adcc65]1304        if (ptr)
[0bb1b7f]1305                *ptr = '\0';
[93ece66]1306
[08a355b]1307        if (!strncmp(who, "skypeconsole", 12))
[1f4fc80]1308                st = skype_printf(ic, "%s\n", message);
[08a355b]1309        else
[1f4fc80]1310                st = skype_printf(ic, "MESSAGE %s %s\n", nick, message);
[77c1abe]1311        g_free(nick);
[93ece66]1312
1313        return st;
1314}
1315
[5adcc65]1316const struct skype_away_state *skype_away_state_by_name(char *name)
[23411c6]1317{
1318        int i;
1319
[5adcc65]1320        for (i = 0; skype_away_state_list[i].full_name; i++)
1321                if (g_strcasecmp(skype_away_state_list[i].full_name, name) == 0)
1322                        return skype_away_state_list + i;
[23411c6]1323
1324        return NULL;
1325}
1326
[8c09bb3]1327static void skype_set_away(struct im_connection *ic, char *state_txt,
1328                           char *message)
[f06e3ac]1329{
[23411c6]1330        const struct skype_away_state *state;
1331
[4ae3ffc]1332        /* Unused parameter */
1333        message = message;
1334
[4b740c2]1335        if (state_txt == NULL)
1336                state = skype_away_state_by_name("Online");
[23411c6]1337        else
[5adcc65]1338                state = skype_away_state_by_name(state_txt);
[1f4fc80]1339        skype_printf(ic, "SET USERSTATUS %s\n", state->code);
[f06e3ac]1340}
1341
[5adcc65]1342static GList *skype_away_states(struct im_connection *ic)
[f06e3ac]1343{
[5adcc65]1344        static GList *l;
[adce2de]1345        int i;
[5adcc65]1346
[4ae3ffc]1347        /* Unused parameter */
1348        ic = ic;
1349
[5adcc65]1350        if (l == NULL)
1351                for (i = 0; skype_away_state_list[i].full_name; i++)
[8c09bb3]1352                        l = g_list_append(l,
1353                                (void *)skype_away_state_list[i].full_name);
[5adcc65]1354
[f06e3ac]1355        return l;
1356}
1357
[5adcc65]1358static char *skype_set_display_name(set_t *set, char *value)
[93dffea]1359{
1360        account_t *acc = set->data;
1361        struct im_connection *ic = acc->ic;
1362
[5a0ffa2]1363        skype_printf(ic, "SET PROFILE FULLNAME %s\n", value);
[5adcc65]1364        return value;
[93dffea]1365}
1366
[7764fb1]1367static char *skype_set_mood_text(set_t *set, char *value)
1368{
1369        account_t *acc = set->data;
1370        struct im_connection *ic = acc->ic;
1371
[5a0ffa2]1372        skype_printf(ic, "SET PROFILE MOOD_TEXT %s\n", value);
[7764fb1]1373        return value;
1374}
1375
[5adcc65]1376static char *skype_set_balance(set_t *set, char *value)
[2af671a]1377{
1378        account_t *acc = set->data;
1379        struct im_connection *ic = acc->ic;
1380
[5a0ffa2]1381        skype_printf(ic, "GET PROFILE PSTN_BALANCE\n");
[5adcc65]1382        return value;
[2af671a]1383}
1384
[fbb15f2]1385static void skype_call(struct im_connection *ic, char *value)
1386{
[71c4bb6]1387        char *nick = g_strdup(value);
1388        char *ptr = strchr(nick, '@');
1389
1390        if (ptr)
1391                *ptr = '\0';
[5a0ffa2]1392        skype_printf(ic, "CALL %s\n", nick);
[71c4bb6]1393        g_free(nick);
1394}
1395
1396static void skype_hangup(struct im_connection *ic)
1397{
1398        struct skype_data *sd = ic->proto_data;
1399
1400        if (sd->call_id) {
[5a0ffa2]1401                skype_printf(ic, "SET CALL %s STATUS FINISHED\n",
[71c4bb6]1402                                sd->call_id);
1403                g_free(sd->call_id);
1404                sd->call_id = 0;
1405        } else
1406                imcb_error(ic, "There are no active calls currently.");
1407}
1408
[5adcc65]1409static char *skype_set_call(set_t *set, char *value)
[b68b023]1410{
1411        account_t *acc = set->data;
1412        struct im_connection *ic = acc->ic;
1413
[fbb15f2]1414        if (value)
[451f121]1415                skype_call(ic, value);
[fbb15f2]1416        else
[71c4bb6]1417                skype_hangup(ic);
[5adcc65]1418        return value;
[b68b023]1419}
1420
[5adcc65]1421static void skype_add_buddy(struct im_connection *ic, char *who, char *group)
[f06e3ac]1422{
[46641bf]1423        struct skype_data *sd = ic->proto_data;
[1f4fc80]1424        char *nick, *ptr;
[6627d92]1425
[cbec0d6]1426        nick = g_strdup(who);
[6627d92]1427        ptr = strchr(nick, '@');
[5adcc65]1428        if (ptr)
[6627d92]1429                *ptr = '\0';
[46e9822]1430
1431        if (!group) {
1432                skype_printf(ic, "SET USER %s BUDDYSTATUS 2 Please authorize me\n",
1433                                nick);
1434                g_free(nick);
1435        } else {
1436                struct skype_group *sg = skype_group_by_name(ic, group);
1437
1438                if (!sg) {
1439                        /* No such group, we need to create it, then have to
1440                         * add the user once it's created. */
[5a0ffa2]1441                        skype_printf(ic, "CREATE GROUP %s\n", group);
[46641bf]1442                        sd->pending_user = g_strdup(nick);
[46e9822]1443                } else {
[5a0ffa2]1444                        skype_printf(ic, "ALTER GROUP %d ADDUSER %s\n", sg->id, nick);
[46e9822]1445                }
1446        }
[f06e3ac]1447}
1448
[5adcc65]1449static void skype_remove_buddy(struct im_connection *ic, char *who, char *group)
[f06e3ac]1450{
[1f4fc80]1451        char *nick, *ptr;
[6627d92]1452
[4ae3ffc]1453        /* Unused parameter */
1454        group = group;
1455
[cbec0d6]1456        nick = g_strdup(who);
[6627d92]1457        ptr = strchr(nick, '@');
[5adcc65]1458        if (ptr)
[6627d92]1459                *ptr = '\0';
[1f4fc80]1460        skype_printf(ic, "SET USER %s BUDDYSTATUS 1\n", nick);
[6627d92]1461        g_free(nick);
[f06e3ac]1462}
1463
[5adcc65]1464void skype_chat_msg(struct groupchat *gc, char *message, int flags)
[66c9558]1465{
[79e20f9]1466        struct im_connection *ic = gc->ic;
[4ae3ffc]1467
1468        /* Unused parameter */
1469        flags = flags;
1470
[1f4fc80]1471        skype_printf(ic, "CHATMESSAGE %s %s\n", gc->title, message);
[66c9558]1472}
1473
[5adcc65]1474void skype_chat_leave(struct groupchat *gc)
[b01dc6c]1475{
1476        struct im_connection *ic = gc->ic;
[1f4fc80]1477        skype_printf(ic, "ALTER CHAT %s LEAVE\n", gc->title);
[5adcc65]1478        gc->data = (void *)TRUE;
[760319d]1479}
1480
1481void skype_chat_invite(struct groupchat *gc, char *who, char *message)
1482{
1483        struct im_connection *ic = gc->ic;
[1f4fc80]1484        char *ptr, *nick;
[4ae3ffc]1485
[17dd2ed]1486        nick = g_strdup(who);
[760319d]1487        ptr = strchr(nick, '@');
[5adcc65]1488        if (ptr)
[760319d]1489                *ptr = '\0';
[1f4fc80]1490        skype_printf(ic, "ALTER CHAT %s ADDMEMBERS %s\n", gc->title, nick);
[760319d]1491        g_free(nick);
[b01dc6c]1492}
1493
[09e2a69]1494void skype_chat_topic(struct groupchat *gc, char *message)
1495{
1496        struct im_connection *ic = gc->ic;
[a5f76a2]1497        struct skype_data *sd = ic->proto_data;
[1f4fc80]1498        skype_printf(ic, "ALTER CHAT %s SETTOPIC %s\n",
[8c09bb3]1499                gc->title, message);
[a5f76a2]1500        sd->topic_wait = 1;
[09e2a69]1501}
1502
[86278cd]1503struct groupchat *skype_chat_with(struct im_connection *ic, char *who)
1504{
1505        struct skype_data *sd = ic->proto_data;
[1f4fc80]1506        char *ptr, *nick;
[86278cd]1507        nick = g_strdup(who);
1508        ptr = strchr(nick, '@');
[5adcc65]1509        if (ptr)
[86278cd]1510                *ptr = '\0';
[1f4fc80]1511        skype_printf(ic, "CHAT CREATE %s\n", nick);
[86278cd]1512        sd->groupchat_with = g_strdup(nick);
1513        g_free(nick);
[5652d43]1514        /* We create a fake chat for now. We will replace it with a real one in
1515         * the real callback. */
[5adcc65]1516        return imcb_chat_new(ic, "");
[86278cd]1517}
1518
[67454bd]1519static void skype_get_info(struct im_connection *ic, char *who)
1520{
[36f6ab3]1521        struct skype_data *sd = ic->proto_data;
[1f4fc80]1522        char *ptr, *nick;
[67454bd]1523        nick = g_strdup(who);
1524        ptr = strchr(nick, '@');
[5adcc65]1525        if (ptr)
[67454bd]1526                *ptr = '\0';
[36f6ab3]1527        sd->is_info = TRUE;
[1f4fc80]1528        skype_printf(ic, "GET USER %s FULLNAME\n", nick);
1529        skype_printf(ic, "GET USER %s PHONE_HOME\n", nick);
1530        skype_printf(ic, "GET USER %s PHONE_OFFICE\n", nick);
1531        skype_printf(ic, "GET USER %s PHONE_MOBILE\n", nick);
1532        skype_printf(ic, "GET USER %s NROF_AUTHED_BUDDIES\n", nick);
1533        skype_printf(ic, "GET USER %s TIMEZONE\n", nick);
1534        skype_printf(ic, "GET USER %s LASTONLINETIMESTAMP\n", nick);
1535        skype_printf(ic, "GET USER %s SEX\n", nick);
1536        skype_printf(ic, "GET USER %s LANGUAGE\n", nick);
1537        skype_printf(ic, "GET USER %s COUNTRY\n", nick);
1538        skype_printf(ic, "GET USER %s PROVINCE\n", nick);
1539        skype_printf(ic, "GET USER %s CITY\n", nick);
1540        skype_printf(ic, "GET USER %s HOMEPAGE\n", nick);
1541        skype_printf(ic, "GET USER %s ABOUT\n", nick);
[85341dd]1542        /*
1543         * Hack: we query the bithday property which is always a single line,
1544         * so we can send the collected properties to the user when we have
1545         * this one.
1546         */
1547        skype_printf(ic, "GET USER %s BIRTHDAY\n", nick);
[67454bd]1548}
1549
[5adcc65]1550static void skype_init(account_t *acc)
[93dffea]1551{
1552        set_t *s;
1553
[8c09bb3]1554        s = set_add(&acc->set, "server", SKYPE_DEFAULT_SERVER, set_eval_account,
1555                acc);
[93dffea]1556        s->flags |= ACC_SET_OFFLINE_ONLY;
1557
[5adcc65]1558        s = set_add(&acc->set, "port", SKYPE_DEFAULT_PORT, set_eval_int, acc);
[93dffea]1559        s->flags |= ACC_SET_OFFLINE_ONLY;
1560
[8c09bb3]1561        s = set_add(&acc->set, "display_name", NULL, skype_set_display_name,
1562                acc);
[bb5ce568]1563        s->flags |= SET_NOSAVE | ACC_SET_ONLINE_ONLY;
[b68b023]1564
[7764fb1]1565        s = set_add(&acc->set, "mood_text", NULL, skype_set_mood_text, acc);
1566        s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY;
1567
[5adcc65]1568        s = set_add(&acc->set, "call", NULL, skype_set_call, acc);
[bb5ce568]1569        s->flags |= SET_NOSAVE | ACC_SET_ONLINE_ONLY;
[2af671a]1570
[5adcc65]1571        s = set_add(&acc->set, "balance", NULL, skype_set_balance, acc);
[bb5ce568]1572        s->flags |= SET_NOSAVE | ACC_SET_ONLINE_ONLY;
[bd417a1]1573
[5adcc65]1574        s = set_add(&acc->set, "skypeout_offline", "true", set_eval_bool, acc);
[08a355b]1575
[5adcc65]1576        s = set_add(&acc->set, "skypeconsole", "false", set_eval_bool, acc);
[08a355b]1577        s->flags |= ACC_SET_OFFLINE_ONLY;
[5acf9ab]1578
[8c09bb3]1579        s = set_add(&acc->set, "skypeconsole_receive", "false", set_eval_bool,
1580                acc);
[b820226]1581        s->flags |= ACC_SET_OFFLINE_ONLY;
1582
[5adcc65]1583        s = set_add(&acc->set, "auto_join", "false", set_eval_bool, acc);
[5acf9ab]1584        s->flags |= ACC_SET_OFFLINE_ONLY;
[f4d37c6]1585
[49a3c02]1586        s = set_add(&acc->set, "test_join", "false", set_eval_bool, acc);
1587        s->flags |= ACC_SET_OFFLINE_ONLY;
1588
[304aa33]1589        s = set_add(&acc->set, "show_moods", "false", set_eval_bool, acc);
1590
[f4d37c6]1591        s = set_add(&acc->set, "edit_prefix", "EDIT:",
[1e3120f]1592                        NULL, acc);
[3c7af69]1593
1594        s = set_add(&acc->set, "read_groups", "false", set_eval_bool, acc);
[93dffea]1595}
1596
[c6e0218]1597#if BITLBEE_VERSION_CODE > BITLBEE_VER(3, 0, 1)
[fbb15f2]1598GList *skype_buddy_action_list(bee_user_t *bu)
[71c4bb6]1599{
[fbb15f2]1600        static GList *ret;
[71c4bb6]1601
[a5e6aa1]1602        /* Unused parameter */
1603        bu = bu;
1604
[fbb15f2]1605        if (ret == NULL) {
[c7336ba]1606                static const struct buddy_action ba[2] = {
[71c4bb6]1607                        {"CALL", "Initiate a call" },
1608                        {"HANGUP", "Hang up a call" },
1609                };
[c7336ba]1610                int i;
[71c4bb6]1611
[c7336ba]1612                for (i = 0; i < ARRAY_SIZE(ba); i++)
1613                        ret = g_list_prepend(ret, (void *)(ba + i));
[71c4bb6]1614        }
1615
1616        return ret;
1617}
1618
[fbb15f2]1619void *skype_buddy_action(struct bee_user *bu, const char *action, char * const args[], void *data)
[71c4bb6]1620{
[a5e6aa1]1621        /* Unused parameters */
1622        args = args;
1623        data = data;
1624
[fbb15f2]1625        if (!g_strcasecmp(action, "CALL"))
[71c4bb6]1626                skype_call(bu->ic, bu->handle);
[fbb15f2]1627        else if (!g_strcasecmp(action, "HANGUP"))
[71c4bb6]1628                skype_hangup(bu->ic);
1629
1630        return NULL;
1631}
1632#endif
1633
[f06e3ac]1634void init_plugin(void)
1635{
[5adcc65]1636        struct prpl *ret = g_new0(struct prpl, 1);
[f06e3ac]1637
1638        ret->name = "skype";
1639        ret->login = skype_login;
1640        ret->init = skype_init;
1641        ret->logout = skype_logout;
[93ece66]1642        ret->buddy_msg = skype_buddy_msg;
[67454bd]1643        ret->get_info = skype_get_info;
[f06e3ac]1644        ret->away_states = skype_away_states;
[7daec06]1645        ret->set_away = skype_set_away;
[f06e3ac]1646        ret->add_buddy = skype_add_buddy;
1647        ret->remove_buddy = skype_remove_buddy;
[66c9558]1648        ret->chat_msg = skype_chat_msg;
[b01dc6c]1649        ret->chat_leave = skype_chat_leave;
[760319d]1650        ret->chat_invite = skype_chat_invite;
[86278cd]1651        ret->chat_with = skype_chat_with;
[f06e3ac]1652        ret->handle_cmp = g_strcasecmp;
[09e2a69]1653        ret->chat_topic = skype_chat_topic;
[c6e0218]1654#if BITLBEE_VERSION_CODE > BITLBEE_VER(3, 0, 1)
[71c4bb6]1655        ret->buddy_action_list = skype_buddy_action_list;
1656        ret->buddy_action = skype_buddy_action;
1657#endif
[5adcc65]1658        register_protocol(ret);
[f06e3ac]1659}
Note: See TracBrowser for help on using the repository browser.