source: protocols/twitter/twitter.h @ 73ee390

Last change on this file since 73ee390 was 73ee390, checked in by jgeboski <jgeboski@…>, at 2015-01-26T03:46:03Z

twitter: implemented filter based group chats

Filter group chats allow for the ability to read the tweets of select
users without actually following the users, and/or track keywords or
hashtags. A filter group chat can have multiple users, keywords, or
hashtags. These users, keywords, or hashtags can span multiple group
chats. This allows for rather robust filter organization.

The underlying structure for the filters is based on linked list, as
using the glib hash tables requires >= glib-2.16 for sanity. Since the
glib requirement of bitlbee is only 2.14, linked list are used in order
to prevent an overly complex implementation.

The idea for this patch was inspired by Artem Savkov's "Twitter search
channels" patch.

In order to use the filter group chats, a group chat must be added to
the twitter account. The channel room name is either follow:username,
track:keyword, and/or track:#hashtag. Multiple elements can be used by
separating each element by a semicolon.

  • Property mode set to 100644
File size: 3.8 KB
Line 
1/***************************************************************************\
2*                                                                           *
3*  BitlBee - An IRC to IM gateway                                           *
4*  Simple module to facilitate twitter functionality.                       *
5*                                                                           *
6*  Copyright 2009-2010 Geert Mulders <g.c.w.m.mulders@gmail.com>            *
7*  Copyright 2010-2012 Wilmer van der Gaast <wilmer@gaast.net>              *
8*                                                                           *
9*  This library is free software; you can redistribute it and/or            *
10*  modify it under the terms of the GNU Lesser General Public               *
11*  License as published by the Free Software Foundation, version            *
12*  2.1.                                                                     *
13*                                                                           *
14*  This library is distributed in the hope that it will be useful,          *
15*  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
16*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU        *
17*  Lesser General Public License for more details.                          *
18*                                                                           *
19*  You should have received a copy of the GNU Lesser General Public License *
20*  along with this library; if not, write to the Free Software Foundation,  *
21*  Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA           *
22*                                                                           *
23****************************************************************************/
24
25#include "nogaim.h"
26
27#ifndef _TWITTER_H
28#define _TWITTER_H
29
30#ifdef DEBUG_TWITTER
31#define debug( text... ) imcb_log( ic, text );
32#else
33#define debug( text... )
34#endif
35
36typedef enum
37{
38        TWITTER_HAVE_FRIENDS   = 0x00001,
39        TWITTER_MODE_ONE       = 0x00002,
40        TWITTER_MODE_MANY      = 0x00004,
41        TWITTER_MODE_CHAT      = 0x00008,
42        TWITTER_DOING_TIMELINE = 0x10000,
43        TWITTER_GOT_TIMELINE   = 0x20000,
44        TWITTER_GOT_MENTIONS   = 0x40000,
45} twitter_flags_t;
46
47typedef enum
48{
49        TWITTER_FILTER_TYPE_FOLLOW = 0,
50        TWITTER_FILTER_TYPE_TRACK
51} twitter_filter_type_t;
52
53struct twitter_log_data;
54
55struct twitter_data
56{
57        char* user;
58        struct oauth_info *oauth_info;
59
60        gpointer home_timeline_obj;
61        gpointer mentions_obj;
62
63        guint64 timeline_id;
64
65        GSList *follow_ids;
66        GSList *filters;
67       
68        guint64 last_status_id; /* For undo */
69        gint main_loop_id;
70        gint filter_update_id;
71        struct http_request *stream;
72        struct http_request *filter_stream;
73        struct groupchat *timeline_gc;
74        gint http_fails;
75        twitter_flags_t flags;
76       
77        /* set base_url */
78        gboolean url_ssl;
79        int url_port;
80        char *url_host;
81        char *url_path;
82
83        char *prefix; /* Used to generate contact + channel name. */
84       
85        /* set show_ids */
86        struct twitter_log_data *log;
87        int log_id;
88};
89
90#define TWITTER_FILTER_UPDATE_WAIT 3000
91struct twitter_filter
92{
93        twitter_filter_type_t type;
94        char *text;
95        guint64 uid;
96        GSList *groupchats;
97};
98
99struct twitter_user_data
100{
101        guint64 last_id;
102        time_t last_time;
103};
104
105#define TWITTER_LOG_LENGTH 256
106struct twitter_log_data
107{
108        guint64 id;
109        struct bee_user *bu; /* DANGER: can be a dead pointer. Check it first. */
110};
111
112/**
113 * This has the same function as the msn_connections GSList. We use this to
114 * make sure the connection is still alive in callbacks before we do anything
115 * else.
116 */
117extern GSList *twitter_connections;
118
119void twitter_login_finish( struct im_connection *ic );
120
121struct http_request;
122char *twitter_parse_error( struct http_request *req );
123
124void twitter_log(struct im_connection *ic, char *format, ... );
125struct groupchat *twitter_groupchat_init(struct im_connection *ic);
126
127#endif //_TWITTER_H
Note: See TracBrowser for help on using the repository browser.