~ubuntu-branches/ubuntu/saucy/bitlbee-skype/saucy

« back to all changes in this revision

Viewing changes to skype.c

  • Committer: Bazaar Package Importer
  • Author(s): أحمد المحمودي (Ahmed El-Mahmoudy)
  • Date: 2010-12-16 20:02:19 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20101216200219-vn8fvgvhehje3wdc
Tags: 0.8.4-0ubuntu1
* New upstream release
  + Supports bitlbee 3.0
* Added debian/watch
* Removed 01-config-files.patch as it got applied upstream.
* Added python2.7.diff to use python instead of python2.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 *  skype.c - Skype plugin for BitlBee
3
3
 *
4
 
 *  Copyright (c) 2007, 2008, 2009 by Miklos Vajna <vmiklos@frugalware.org>
 
4
 *  Copyright (c) 2007, 2008, 2009, 2010 by Miklos Vajna <vmiklos@frugalware.org>
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
23
23
#define _BSD_SOURCE
24
24
#include <poll.h>
25
25
#include <bitlbee.h>
26
 
#include <bitlbee/ssl_client.h>
 
26
#include <ssl_client.h>
27
27
 
28
28
#define SKYPE_DEFAULT_SERVER "localhost"
29
29
#define SKYPE_DEFAULT_PORT "2727"
31
31
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
32
32
 
33
33
/*
 
34
 * Compatibility with BitlBee 1.3+
 
35
 */
 
36
#if BITLBEE_VERSION_CODE < BITLBEE_VER(1, 3, 0)
 
37
#define B_EV_IO_READ GAIM_INPUT_READ
 
38
#endif
 
39
 
 
40
/*
34
41
 * Enumerations
35
42
 */
36
43
 
144
151
        struct skype_data *sd = ic->proto_data;
145
152
        struct pollfd pfd[1];
146
153
 
 
154
        if (!sd->ssl)
 
155
                return FALSE;
 
156
 
147
157
        pfd[0].fd = sd->fd;
148
158
        pfd[0].events = POLLOUT;
149
159
 
234
244
}
235
245
struct groupchat *skype_chat_by_name(struct im_connection *ic, char *name)
236
246
{
 
247
#if BITLBEE_VERSION_CODE < BITLBEE_VER(1, 3, 0)
237
248
        struct groupchat *ret;
238
249
 
239
250
        for (ret = ic->groupchats; ret; ret = ret->next)
241
252
                        break;
242
253
 
243
254
        return ret;
 
255
#else
 
256
        return bee_chat_by_title(ic->bee, ic, name);
 
257
#endif
244
258
}
245
259
 
246
260
static char *skype_call_strerror(int err)
299
313
                return;
300
314
        *ptr = '\0';
301
315
        ptr++;
302
 
        if (!strncmp(ptr, "ONLINESTATUS ", 13) &&
303
 
                        strcmp(user, sd->username) != 0
304
 
                        && strcmp(user, "echo123") != 0) {
 
316
        if (!strncmp(ptr, "ONLINESTATUS ", 13)) {
 
317
                        if (!strcmp(user, sd->username))
 
318
                                return;
 
319
                        if (!set_getbool(&ic->acc->set, "test_join")
 
320
                                && !strcmp(user, "echo123"))
 
321
                                return;
305
322
                ptr = g_strdup_printf("%s@skype.com", user);
306
323
                imcb_add_buddy(ic, ptr, NULL);
307
324
                if (strcmp(status, "OFFLINE") && (strcmp(status, "SKYPEOUT") ||
322
339
                        imcb_add_buddy(ic, buf, NULL);
323
340
                        g_free(buf);
324
341
                }
 
342
        } else if (!strncmp(ptr, "MOOD_TEXT ", 10)) {
 
343
                char *buf = g_strdup_printf("%s@skype.com", user);
 
344
#if BITLBEE_VERSION_CODE < BITLBEE_VER(1, 3, 0)
 
345
                user_t *u = user_findhandle(ic, buf);
 
346
                g_free(buf);
 
347
                buf = ptr + 10;
 
348
                if (u) {
 
349
                        if (u->status_msg)
 
350
                                g_free(u->status_msg);
 
351
                        if (strlen(buf))
 
352
                                u->status_msg = g_strdup(buf);
 
353
                        else
 
354
                                u->status_msg = NULL;
 
355
                }
 
356
#else
 
357
                bee_user_t *bu = bee_user_by_handle(ic->bee, ic, buf);
 
358
                g_free(buf);
 
359
                buf = ptr + 10;
 
360
                if (bu) {
 
361
                        imcb_buddy_status(ic, bu->handle, bu->flags, NULL,
 
362
                                        *buf ? buf : NULL);
 
363
                }
 
364
#endif
 
365
                if (set_getbool(&ic->acc->set, "show_moods"))
 
366
                        imcb_log(ic, "User `%s' changed mood text to `%s'", user, buf);
325
367
        } else if (!strncmp(ptr, "FULLNAME ", 9))
326
368
                sd->info_fullname = g_strdup(ptr + 9);
327
369
        else if (!strncmp(ptr, "PHONE_HOME ", 11))
749
791
        if (gc)
750
792
                imcb_chat_free(gc);
751
793
        if (!strcmp(info, "STATUS MULTI_SUBSCRIBED")) {
752
 
                imcb_chat_new(ic, id);
 
794
                gc = imcb_chat_new(ic, id);
 
795
                imcb_chat_name_hint(gc, id);
753
796
                skype_printf(ic, "GET CHAT %s ADDER\n", id);
754
797
                skype_printf(ic, "GET CHAT %s TOPIC\n", id);
755
798
        } else if (!strcmp(info, "STATUS DIALOG") && sd->groupchat_with) {
756
799
                gc = imcb_chat_new(ic, id);
 
800
                imcb_chat_name_hint(gc, id);
757
801
                /* According to the docs this
758
802
                 * is necessary. However it
759
803
                 * does not seem the situation
831
875
 
832
876
static void skype_parse_ping(struct im_connection *ic, char *line)
833
877
{
 
878
        /* Unused parameter */
 
879
        line = line;
834
880
        skype_printf(ic, "PONG\n");
835
881
}
836
882
 
874
920
                { "CHATS ", skype_parse_chats },
875
921
        };
876
922
 
 
923
        /* Unused parameters */
 
924
        fd = fd;
 
925
        cond = cond;
 
926
 
877
927
        if (!sd || sd->fd == -1)
878
928
                return FALSE;
879
929
        /* Read the whole data. */
917
967
                return FALSE;
918
968
 
919
969
        if (sd->bfd <= 0)
920
 
                sd->bfd = b_input_add(sd->fd, GAIM_INPUT_READ,
 
970
                sd->bfd = b_input_add(sd->fd, B_EV_IO_READ,
921
971
                        skype_read_callback, ic);
922
972
 
923
973
        /* Log in */
938
988
{
939
989
        struct im_connection *ic = data;
940
990
        struct skype_data *sd = ic->proto_data;
 
991
 
 
992
        /* Unused parameter */
 
993
        cond = cond;
 
994
 
941
995
        if (!source) {
942
996
                sd->ssl = NULL;
943
997
                imcb_error(ic, "Could not connect to server");
945
999
                return FALSE;
946
1000
        }
947
1001
        imcb_log(ic, "Connected to server, logging in");
 
1002
 
948
1003
        return skype_start_stream(ic);
949
1004
}
950
1005
 
985
1040
        char *ptr, *nick;
986
1041
        int st;
987
1042
 
 
1043
        /* Unused parameter */
 
1044
        flags = flags;
 
1045
 
988
1046
        nick = g_strdup(who);
989
1047
        ptr = strchr(nick, '@');
990
1048
        if (ptr)
1015
1073
{
1016
1074
        const struct skype_away_state *state;
1017
1075
 
 
1076
        /* Unused parameter */
 
1077
        message = message;
 
1078
 
1018
1079
        if (state_txt == NULL)
1019
1080
                state = skype_away_state_by_name("Online");
1020
1081
        else
1027
1088
        static GList *l;
1028
1089
        int i;
1029
1090
 
 
1091
        /* Unused parameter */
 
1092
        ic = ic;
 
1093
 
1030
1094
        if (l == NULL)
1031
1095
                for (i = 0; skype_away_state_list[i].full_name; i++)
1032
1096
                        l = g_list_append(l,
1061
1125
        char *nick, *ptr;
1062
1126
 
1063
1127
        if (value) {
 
1128
#if BITLBEE_VERSION_CODE < BITLBEE_VER(1, 3, 0)
 
1129
                /* IRC stuff shouldn't be touched from inside IM modules. */
1064
1130
                user_t *u = user_find(acc->irc, value);
1065
1131
                /* We are starting a call */
1066
 
                if (!u)
 
1132
                if (u)
 
1133
                        nick = g_strdup(u->handle);
 
1134
                else
 
1135
#endif
1067
1136
                        nick = g_strdup(value);
1068
 
                else
1069
 
                        nick = g_strdup(u->handle);
1070
1137
                ptr = strchr(nick, '@');
1071
1138
                if (ptr)
1072
1139
                        *ptr = '\0';
1090
1157
{
1091
1158
        char *nick, *ptr;
1092
1159
 
 
1160
        /* Unused parameter */
 
1161
        group = group;
 
1162
 
1093
1163
        nick = g_strdup(who);
1094
1164
        ptr = strchr(nick, '@');
1095
1165
        if (ptr)
1103
1173
{
1104
1174
        char *nick, *ptr;
1105
1175
 
 
1176
        /* Unused parameter */
 
1177
        group = group;
 
1178
 
1106
1179
        nick = g_strdup(who);
1107
1180
        ptr = strchr(nick, '@');
1108
1181
        if (ptr)
1114
1187
void skype_chat_msg(struct groupchat *gc, char *message, int flags)
1115
1188
{
1116
1189
        struct im_connection *ic = gc->ic;
 
1190
 
 
1191
        /* Unused parameter */
 
1192
        flags = flags;
 
1193
 
1117
1194
        skype_printf(ic, "CHATMESSAGE %s %s\n", gc->title, message);
1118
1195
}
1119
1196
 
1128
1205
{
1129
1206
        struct im_connection *ic = gc->ic;
1130
1207
        char *ptr, *nick;
 
1208
 
 
1209
        /* Unused parameter */
 
1210
        who = who;
 
1211
 
1131
1212
        nick = g_strdup(message);
1132
1213
        ptr = strchr(nick, '@');
1133
1214
        if (ptr)
1223
1304
        s = set_add(&acc->set, "auto_join", "false", set_eval_bool, acc);
1224
1305
        s->flags |= ACC_SET_OFFLINE_ONLY;
1225
1306
 
 
1307
        s = set_add(&acc->set, "test_join", "false", set_eval_bool, acc);
 
1308
        s->flags |= ACC_SET_OFFLINE_ONLY;
 
1309
 
 
1310
        s = set_add(&acc->set, "show_moods", "false", set_eval_bool, acc);
 
1311
 
1226
1312
        s = set_add(&acc->set, "edit_prefix", "EDIT:",
1227
1313
                        NULL, acc);
1228
1314
}