source: protocols/twitter/twitter.c @ b3d99e3

Last change on this file since b3d99e3 was b3d99e3, checked in by Wilmer van der Gaast <wilmer@…>, at 2012-09-15T16:03:33Z

Twitter module cleanup: Both Twitter and identi.ca "modules" support OAuth
now.

  • Property mode set to 100644
File size: 19.2 KB
Line 
1/***************************************************************************\
2*                                                                           *
3*  BitlBee - An IRC to IM gateway                                           *
4*  Simple module to facilitate twitter functionality.                       *
5*                                                                           *
6*  Copyright 2009 Geert Mulders <g.c.w.m.mulders@gmail.com>                 *
7*                                                                           *
8*  This library is free software; you can redistribute it and/or            *
9*  modify it under the terms of the GNU Lesser General Public               *
10*  License as published by the Free Software Foundation, version            *
11*  2.1.                                                                     *
12*                                                                           *
13*  This library is distributed in the hope that it will be useful,          *
14*  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
15*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU        *
16*  Lesser General Public License for more details.                          *
17*                                                                           *
18*  You should have received a copy of the GNU Lesser General Public License *
19*  along with this library; if not, write to the Free Software Foundation,  *
20*  Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA           *
21*                                                                           *
22****************************************************************************/
23
24#include "nogaim.h"
25#include "oauth.h"
26#include "twitter.h"
27#include "twitter_http.h"
28#include "twitter_lib.h"
29#include "url.h"
30
31#define twitter_msg( ic, fmt... ) \
32        do {                                            \
33                struct twitter_data *td = ic->proto_data;   \
34                if( td->timeline_gc )                       \
35                        imcb_chat_log( td->timeline_gc, fmt );  \
36                else                                        \
37                        imcb_log( ic, fmt );                    \
38        } while( 0 );
39
40GSList *twitter_connections = NULL;
41
42/**
43 * Main loop function
44 */
45gboolean twitter_main_loop(gpointer data, gint fd, b_input_condition cond)
46{
47        struct im_connection *ic = data;
48
49        // Check if we are still logged in...
50        if (!g_slist_find(twitter_connections, ic))
51                return 0;
52
53        // Do stuff..
54        twitter_get_timeline(ic, -1);
55
56        // If we are still logged in run this function again after timeout.
57        return (ic->flags & OPT_LOGGED_IN) == OPT_LOGGED_IN;
58}
59
60static void twitter_main_loop_start(struct im_connection *ic)
61{
62        struct twitter_data *td = ic->proto_data;
63
64        imcb_log(ic, "Getting initial statuses");
65
66        // Run this once. After this queue the main loop function.
67        twitter_main_loop(ic, -1, 0);
68
69        // Queue the main_loop
70        // Save the return value, so we can remove the timeout on logout.
71        td->main_loop_id =
72            b_timeout_add(set_getint(&ic->acc->set, "fetch_interval") * 1000, twitter_main_loop, ic);
73}
74
75static void twitter_oauth_start(struct im_connection *ic);
76
77void twitter_login_finish(struct im_connection *ic)
78{
79        struct twitter_data *td = ic->proto_data;
80
81        td->flags &= ~TWITTER_DOING_TIMELINE;
82
83        if (set_getbool(&ic->acc->set, "oauth") && !td->oauth_info)
84                twitter_oauth_start(ic);
85        else if (g_strcasecmp(set_getstr(&ic->acc->set, "mode"), "one") != 0 &&
86                 !(td->flags & TWITTER_HAVE_FRIENDS)) {
87                imcb_log(ic, "Getting contact list");
88                twitter_get_friends_ids(ic, -1);
89                //twitter_get_statuses_friends(ic, -1);
90        } else
91                twitter_main_loop_start(ic);
92}
93
94static const struct oauth_service twitter_oauth = {
95        "https://api.twitter.com/oauth/request_token",
96        "https://api.twitter.com/oauth/access_token",
97        "https://api.twitter.com/oauth/authorize",
98        .consumer_key = "xsDNKJuNZYkZyMcu914uEA",
99        .consumer_secret = "FCxqcr0pXKzsF9ajmP57S3VQ8V6Drk4o2QYtqMcOszo",
100};
101
102static const struct oauth_service identica_oauth = {
103        "https://identi.ca/api/oauth/request_token",
104        "https://identi.ca/api/oauth/access_token",
105        "https://identi.ca/api/oauth/authorize",
106        .consumer_key = "e147ff789fcbd8a5a07963afbb43f9da",
107        .consumer_secret = "c596267f277457ec0ce1ab7bb788d828",
108};
109
110static gboolean twitter_oauth_callback(struct oauth_info *info);
111
112static const struct oauth_service *get_oauth_service(struct im_connection *ic)
113{
114        struct twitter_data *td = ic->proto_data;
115
116        if (strstr(td->url_host, "identi.ca"))
117                return &identica_oauth;
118        else
119                return &twitter_oauth;
120
121        /* Could add more services, or allow configuring your own base URL +
122           API keys. */
123}
124
125static void twitter_oauth_start(struct im_connection *ic)
126{
127        struct twitter_data *td = ic->proto_data;
128
129        imcb_log(ic, "Requesting OAuth request token");
130
131        td->oauth_info = oauth_request_token(get_oauth_service(ic), twitter_oauth_callback, ic);
132
133        /* We need help from the user to complete OAuth login, so don't time
134           out on this login. */
135        ic->flags |= OPT_SLOW_LOGIN;
136}
137
138static gboolean twitter_oauth_callback(struct oauth_info *info)
139{
140        struct im_connection *ic = info->data;
141        struct twitter_data *td;
142
143        if (!g_slist_find(twitter_connections, ic))
144                return FALSE;
145
146        td = ic->proto_data;
147        if (info->stage == OAUTH_REQUEST_TOKEN) {
148                char name[strlen(ic->acc->user) + 9], *msg;
149
150                if (info->request_token == NULL) {
151                        imcb_error(ic, "OAuth error: %s", twitter_parse_error(info->http));
152                        imc_logout(ic, TRUE);
153                        return FALSE;
154                }
155
156                sprintf(name, "%s_%s", td->prefix, ic->acc->user);
157                msg = g_strdup_printf("To finish OAuth authentication, please visit "
158                                      "%s and respond with the resulting PIN code.",
159                                      info->auth_url);
160                imcb_buddy_msg(ic, name, msg, 0, 0);
161                g_free(msg);
162        } else if (info->stage == OAUTH_ACCESS_TOKEN) {
163                if (info->token == NULL || info->token_secret == NULL) {
164                        imcb_error(ic, "OAuth error: %s", twitter_parse_error(info->http));
165                        imc_logout(ic, TRUE);
166                        return FALSE;
167                } else {
168                        const char *sn = oauth_params_get(&info->params, "screen_name");
169
170                        if (sn != NULL && ic->acc->prpl->handle_cmp(sn, ic->acc->user) != 0) {
171                                imcb_log(ic, "Warning: You logged in via OAuth as %s "
172                                         "instead of %s.", sn, ic->acc->user);
173                        }
174                        g_free(td->user);
175                        td->user = g_strdup(sn);
176                }
177
178                /* IM mods didn't do this so far and it's ugly but I should
179                   be able to get away with it... */
180                g_free(ic->acc->pass);
181                ic->acc->pass = oauth_to_string(info);
182
183                twitter_login_finish(ic);
184        }
185
186        return TRUE;
187}
188
189
190static char *set_eval_mode(set_t * set, char *value)
191{
192        if (g_strcasecmp(value, "one") == 0 ||
193            g_strcasecmp(value, "many") == 0 || g_strcasecmp(value, "chat") == 0)
194                return value;
195        else
196                return NULL;
197}
198
199int twitter_url_len_diff(gchar *msg, unsigned int target_len)
200{
201        int url_len_diff = 0;
202
203        static GRegex *regex = NULL;
204        GMatchInfo *match_info;
205
206        if (regex == NULL)
207                regex = g_regex_new("(^|\\s)(http(s)?://[^\\s$]+)", 0, 0, NULL);
208       
209        g_regex_match(regex, msg, 0, &match_info);
210        while (g_match_info_matches(match_info)) {
211                gchar *url = g_match_info_fetch(match_info, 2);
212                url_len_diff += target_len - g_utf8_strlen(url, -1);
213                if (g_match_info_fetch(match_info, 3) != NULL)
214                        url_len_diff += 1;
215                g_free(url);
216                g_match_info_next(match_info, NULL);
217        }
218        g_match_info_free(match_info);
219
220        return url_len_diff;
221}
222
223static gboolean twitter_length_check(struct im_connection *ic, gchar * msg)
224{
225        int max = set_getint(&ic->acc->set, "message_length"), len;
226        int target_len = set_getint(&ic->acc->set, "target_url_length");
227        int url_len_diff = 0;
228   
229        if (target_len > 0)
230                url_len_diff = twitter_url_len_diff(msg, target_len);
231
232        if (max == 0 || (len = g_utf8_strlen(msg, -1) + url_len_diff) <= max)
233                return TRUE;
234
235        imcb_error(ic, "Maximum message length exceeded: %d > %d", len, max);
236
237        return FALSE;
238}
239
240static void twitter_init(account_t * acc)
241{
242        set_t *s;
243        char *def_url;
244        char *def_tul;
245
246        if (strcmp(acc->prpl->name, "twitter") == 0) {
247                def_url = TWITTER_API_URL;
248                def_tul = "20";
249        } else {                /* if( strcmp( acc->prpl->name, "identica" ) == 0 ) */
250                def_url = IDENTICA_API_URL;
251                def_tul = "0";
252        }
253
254        s = set_add(&acc->set, "auto_reply_timeout", "10800", set_eval_int, acc);
255
256        s = set_add(&acc->set, "base_url", def_url, NULL, acc);
257        s->flags |= ACC_SET_OFFLINE_ONLY;
258
259        s = set_add(&acc->set, "commands", "true", set_eval_bool, acc);
260
261        s = set_add(&acc->set, "fetch_interval", "60", set_eval_int, acc);
262        s->flags |= ACC_SET_OFFLINE_ONLY;
263
264        s = set_add(&acc->set, "fetch_mentions", "true", set_eval_bool, acc);
265
266        s = set_add(&acc->set, "message_length", "140", set_eval_int, acc);
267
268        s = set_add(&acc->set, "target_url_length", def_tul, set_eval_int, acc);
269
270        s = set_add(&acc->set, "mode", "chat", set_eval_mode, acc);
271        s->flags |= ACC_SET_OFFLINE_ONLY;
272
273        s = set_add(&acc->set, "oauth", "true", set_eval_oauth, acc);
274
275        s = set_add(&acc->set, "show_ids", "true", set_eval_bool, acc);
276        s->flags |= ACC_SET_OFFLINE_ONLY;
277
278        s = set_add(&acc->set, "show_old_mentions", "20", set_eval_int, acc);
279
280        s = set_add(&acc->set, "strip_newlines", "false", set_eval_bool, acc);
281}
282
283/**
284 * Login method. Since the twitter API works with seperate HTTP request we
285 * only save the user and pass to the twitter_data object.
286 */
287static void twitter_login(account_t * acc)
288{
289        struct im_connection *ic = imcb_new(acc);
290        struct twitter_data *td;
291        char name[strlen(acc->user) + 9];
292        url_t url;
293        char *s;
294       
295        if (!url_set(&url, set_getstr(&ic->acc->set, "base_url")) ||
296            (url.proto != PROTO_HTTP && url.proto != PROTO_HTTPS)) {
297                imcb_error(ic, "Incorrect API base URL: %s", set_getstr(&ic->acc->set, "base_url"));
298                imc_logout(ic, FALSE);
299                return;
300        }
301
302        imcb_log(ic, "Connecting");
303
304        twitter_connections = g_slist_append(twitter_connections, ic);
305        td = g_new0(struct twitter_data, 1);
306        ic->proto_data = td;
307        td->user = g_strdup(acc->user);
308
309        td->url_ssl = url.proto == PROTO_HTTPS;
310        td->url_port = url.port;
311        td->url_host = g_strdup(url.host);
312        if (strcmp(url.file, "/") != 0)
313                td->url_path = g_strdup(url.file);
314        else {
315                td->url_path = g_strdup("");
316                if (g_str_has_suffix(url.host, "twitter.com"))
317                        /* May fire for people who turned on HTTPS. */
318                        imcb_error(ic, "Warning: Twitter requires a version number in API calls "
319                                       "now. Try resetting the base_url account setting.");
320        }
321       
322        /* Hacky string mangling: Turn identi.ca into identi.ca and api.twitter.com
323           into twitter, and try to be sensible if we get anything else. */
324        td->prefix = g_strdup(url.host);
325        if (g_str_has_suffix(td->prefix, ".com"))
326                td->prefix[strlen(url.host) - 4] = '\0';
327        if ((s = strrchr(td->prefix, '.')) && strlen(s) > 4) {
328                /* If we have at least 3 chars after the last dot, cut off the rest.
329                   (mostly a www/api prefix or sth) */
330                s = g_strdup(s + 1);
331                g_free(td->prefix);
332                td->prefix = s;
333        }
334       
335        if (strstr(acc->pass, "oauth_token="))
336                td->oauth_info = oauth_from_string(acc->pass, get_oauth_service(ic));
337
338        sprintf(name, "%s_%s", td->prefix, acc->user);
339        imcb_add_buddy(ic, name, NULL);
340        imcb_buddy_status(ic, name, OPT_LOGGED_IN, NULL, NULL);
341
342        if (set_getbool(&acc->set, "show_ids"))
343                td->log = g_new0(struct twitter_log_data, TWITTER_LOG_LENGTH);
344
345        twitter_login_finish(ic);
346}
347
348/**
349 * Logout method. Just free the twitter_data.
350 */
351static void twitter_logout(struct im_connection *ic)
352{
353        struct twitter_data *td = ic->proto_data;
354
355        // Set the status to logged out.
356        ic->flags &= ~OPT_LOGGED_IN;
357
358        // Remove the main_loop function from the function queue.
359        b_event_remove(td->main_loop_id);
360
361        if (td->timeline_gc)
362                imcb_chat_free(td->timeline_gc);
363
364        if (td) {
365                oauth_info_free(td->oauth_info);
366                g_free(td->user);
367                g_free(td->prefix);
368                g_free(td->url_host);
369                g_free(td->url_path);
370                g_free(td->log);
371                g_free(td);
372        }
373
374        twitter_connections = g_slist_remove(twitter_connections, ic);
375}
376
377static void twitter_handle_command(struct im_connection *ic, char *message);
378
379/**
380 *
381 */
382static int twitter_buddy_msg(struct im_connection *ic, char *who, char *message, int away)
383{
384        struct twitter_data *td = ic->proto_data;
385        int plen = strlen(td->prefix);
386
387        if (g_strncasecmp(who, td->prefix, plen) == 0 && who[plen] == '_' &&
388            g_strcasecmp(who + plen + 1, ic->acc->user) == 0) {
389                if (set_getbool(&ic->acc->set, "oauth") &&
390                    td->oauth_info && td->oauth_info->token == NULL) {
391                        char pin[strlen(message) + 1], *s;
392
393                        strcpy(pin, message);
394                        for (s = pin + sizeof(pin) - 2; s > pin && isspace(*s); s--)
395                                *s = '\0';
396                        for (s = pin; *s && isspace(*s); s++) {
397                        }
398
399                        if (!oauth_access_token(s, td->oauth_info)) {
400                                imcb_error(ic, "OAuth error: %s",
401                                           "Failed to send access token request");
402                                imc_logout(ic, TRUE);
403                                return FALSE;
404                        }
405                } else
406                        twitter_handle_command(ic, message);
407        } else {
408                twitter_direct_messages_new(ic, who, message);
409        }
410        return (0);
411}
412
413/**
414 *
415 */
416static void twitter_set_my_name(struct im_connection *ic, char *info)
417{
418}
419
420static void twitter_get_info(struct im_connection *ic, char *who)
421{
422}
423
424static void twitter_add_buddy(struct im_connection *ic, char *who, char *group)
425{
426        twitter_friendships_create_destroy(ic, who, 1);
427}
428
429static void twitter_remove_buddy(struct im_connection *ic, char *who, char *group)
430{
431        twitter_friendships_create_destroy(ic, who, 0);
432}
433
434static void twitter_chat_msg(struct groupchat *c, char *message, int flags)
435{
436        if (c && message)
437                twitter_handle_command(c->ic, message);
438}
439
440static void twitter_chat_invite(struct groupchat *c, char *who, char *message)
441{
442}
443
444static void twitter_chat_leave(struct groupchat *c)
445{
446        struct twitter_data *td = c->ic->proto_data;
447
448        if (c != td->timeline_gc)
449                return;         /* WTF? */
450
451        /* If the user leaves the channel: Fine. Rejoin him/her once new
452           tweets come in. */
453        imcb_chat_free(td->timeline_gc);
454        td->timeline_gc = NULL;
455}
456
457static void twitter_keepalive(struct im_connection *ic)
458{
459}
460
461static void twitter_add_permit(struct im_connection *ic, char *who)
462{
463}
464
465static void twitter_rem_permit(struct im_connection *ic, char *who)
466{
467}
468
469static void twitter_add_deny(struct im_connection *ic, char *who)
470{
471}
472
473static void twitter_rem_deny(struct im_connection *ic, char *who)
474{
475}
476
477//static char *twitter_set_display_name( set_t *set, char *value )
478//{
479//      return value;
480//}
481
482static void twitter_buddy_data_add(struct bee_user *bu)
483{
484        bu->data = g_new0(struct twitter_user_data, 1);
485}
486
487static void twitter_buddy_data_free(struct bee_user *bu)
488{
489        g_free(bu->data);
490}
491
492static void twitter_handle_command(struct im_connection *ic, char *message)
493{
494        struct twitter_data *td = ic->proto_data;
495        char *cmds, **cmd, *new = NULL;
496        guint64 in_reply_to = 0;
497
498        cmds = g_strdup(message);
499        cmd = split_command_parts(cmds);
500
501        if (cmd[0] == NULL) {
502                g_free(cmds);
503                return;
504        } else if (!set_getbool(&ic->acc->set, "commands")) {
505                /* Not supporting commands. */
506        } else if (g_strcasecmp(cmd[0], "undo") == 0) {
507                guint64 id;
508
509                if (cmd[1] == NULL)
510                        twitter_status_destroy(ic, td->last_status_id);
511                else if (sscanf(cmd[1], "%" G_GUINT64_FORMAT, &id) == 1) {
512                        if (id < TWITTER_LOG_LENGTH && td->log)
513                                id = td->log[id].id;
514                       
515                        twitter_status_destroy(ic, id);
516                } else
517                        twitter_msg(ic, "Could not undo last action");
518
519                g_free(cmds);
520                return;
521        } else if (g_strcasecmp(cmd[0], "follow") == 0 && cmd[1]) {
522                twitter_add_buddy(ic, cmd[1], NULL);
523                g_free(cmds);
524                return;
525        } else if (g_strcasecmp(cmd[0], "unfollow") == 0 && cmd[1]) {
526                twitter_remove_buddy(ic, cmd[1], NULL);
527                g_free(cmds);
528                return;
529        } else if ((g_strcasecmp(cmd[0], "report") == 0 ||
530                    g_strcasecmp(cmd[0], "spam") == 0) && cmd[1]) {
531                char * screen_name;
532                guint64 id;
533                screen_name = cmd[1];
534                /* Report nominally works on users but look up the user who
535                   posted the given ID if the user wants to do it that way */
536                if (g_str_has_prefix(cmd[1], "#") &&
537                    sscanf(cmd[1] + 1, "%" G_GUINT64_FORMAT, &id) == 1) {
538                        if (id < TWITTER_LOG_LENGTH && td->log) {
539                                if (g_slist_find(ic->bee->users, td->log[id].bu)) {
540                                        screen_name = td->log[id].bu->handle;
541                                }
542                        }
543                }
544                twitter_report_spam(ic, screen_name);
545                g_free(cmds);
546                return;
547        } else if (g_strcasecmp(cmd[0], "rt") == 0 && cmd[1]) {
548                struct twitter_user_data *tud;
549                bee_user_t *bu;
550                guint64 id;
551
552                if (g_str_has_prefix(cmd[1], "#") &&
553                    sscanf(cmd[1] + 1, "%" G_GUINT64_FORMAT, &id) == 1) {
554                        if (id < TWITTER_LOG_LENGTH && td->log)
555                                id = td->log[id].id;
556                } else if ((bu = bee_user_by_handle(ic->bee, ic, cmd[1])) &&
557                    (tud = bu->data) && tud->last_id)
558                        id = tud->last_id;
559                else if (sscanf(cmd[1], "%" G_GUINT64_FORMAT, &id) == 1){
560                        if (id < TWITTER_LOG_LENGTH && td->log)
561                                id = td->log[id].id;
562                }
563
564                td->last_status_id = 0;
565                if (id)
566                        twitter_status_retweet(ic, id);
567                else
568                        twitter_msg(ic, "User `%s' does not exist or didn't "
569                                    "post any statuses recently", cmd[1]);
570
571                g_free(cmds);
572                return;
573        } else if (g_strcasecmp(cmd[0], "reply") == 0 && cmd[1] && cmd[2]) {
574                struct twitter_user_data *tud;
575                bee_user_t *bu = NULL;
576                guint64 id = 0;
577
578                if (g_str_has_prefix(cmd[1], "#") &&
579                    sscanf(cmd[1] + 1, "%" G_GUINT64_FORMAT, &id) == 1 &&
580                    (id < TWITTER_LOG_LENGTH) && td->log) {
581                        bu = td->log[id].bu;
582                        if (g_slist_find(ic->bee->users, bu))
583                                id = td->log[id].id;
584                        else
585                                bu = NULL;
586                } else if ((bu = bee_user_by_handle(ic->bee, ic, cmd[1])) &&
587                    (tud = bu->data) && tud->last_id) {
588                        id = tud->last_id;
589                } else if (sscanf(cmd[1], "%" G_GUINT64_FORMAT, &id) == 1 &&
590                           (id < TWITTER_LOG_LENGTH) && td->log) {
591                        bu = td->log[id].bu;
592                        if (g_slist_find(ic->bee->users, bu))
593                                id = td->log[id].id;
594                        else
595                                bu = NULL;
596                }
597
598                if (!id || !bu) {
599                        twitter_msg(ic, "User `%s' does not exist or didn't "
600                                    "post any statuses recently", cmd[1]);
601                        g_free(cmds);
602                        return;
603                }
604                message = new = g_strdup_printf("@%s %s", bu->handle, message + (cmd[2] - cmd[0]));
605                in_reply_to = id;
606        } else if (g_strcasecmp(cmd[0], "post") == 0) {
607                message += 5;
608        }
609
610        {
611                char *s;
612                bee_user_t *bu;
613
614                if (!twitter_length_check(ic, message)) {
615                        g_free(new);
616                        g_free(cmds);
617                        return;
618                }
619
620                s = cmd[0] + strlen(cmd[0]) - 1;
621                if (!new && s > cmd[0] && (*s == ':' || *s == ',')) {
622                        *s = '\0';
623
624                        if ((bu = bee_user_by_handle(ic->bee, ic, cmd[0]))) {
625                                struct twitter_user_data *tud = bu->data;
626
627                                new = g_strdup_printf("@%s %s", bu->handle,
628                                                      message + (s - cmd[0]) + 2);
629                                message = new;
630
631                                if (time(NULL) < tud->last_time +
632                                    set_getint(&ic->acc->set, "auto_reply_timeout"))
633                                        in_reply_to = tud->last_id;
634                        }
635                }
636
637                /* If the user runs undo between this request and its response
638                   this would delete the second-last Tweet. Prevent that. */
639                td->last_status_id = 0;
640                twitter_post_status(ic, message, in_reply_to);
641                g_free(new);
642        }
643        g_free(cmds);
644}
645
646void twitter_initmodule()
647{
648        struct prpl *ret = g_new0(struct prpl, 1);
649
650        ret->options = OPT_NOOTR;
651        ret->name = "twitter";
652        ret->login = twitter_login;
653        ret->init = twitter_init;
654        ret->logout = twitter_logout;
655        ret->buddy_msg = twitter_buddy_msg;
656        ret->get_info = twitter_get_info;
657        ret->set_my_name = twitter_set_my_name;
658        ret->add_buddy = twitter_add_buddy;
659        ret->remove_buddy = twitter_remove_buddy;
660        ret->chat_msg = twitter_chat_msg;
661        ret->chat_invite = twitter_chat_invite;
662        ret->chat_leave = twitter_chat_leave;
663        ret->keepalive = twitter_keepalive;
664        ret->add_permit = twitter_add_permit;
665        ret->rem_permit = twitter_rem_permit;
666        ret->add_deny = twitter_add_deny;
667        ret->rem_deny = twitter_rem_deny;
668        ret->buddy_data_add = twitter_buddy_data_add;
669        ret->buddy_data_free = twitter_buddy_data_free;
670        ret->handle_cmp = g_strcasecmp;
671
672        register_protocol(ret);
673
674        /* And an identi.ca variant: */
675        ret = g_memdup(ret, sizeof(struct prpl));
676        ret->name = "identica";
677        register_protocol(ret);
678}
Note: See TracBrowser for help on using the repository browser.