source: protocols/twitter/twitter.h @ e88fe7da

Last change on this file since e88fe7da was c43146d, checked in by Wilmer van der Gaast <wilmer@…>, at 2015-05-03T16:47:19Z

Make replies to self work in Twitter.

Difficult because there's no bee_user struct pointing at the user themselves
so instead just fake one for very limited use.

  • Property mode set to 100644
File size: 4.1 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        TWITTER_HAVE_FRIENDS   = 0x00001,
38        TWITTER_MODE_ONE       = 0x00002,
39        TWITTER_MODE_MANY      = 0x00004,
40        TWITTER_MODE_CHAT      = 0x00008,
41        TWITTER_DOING_TIMELINE = 0x10000,
42        TWITTER_GOT_TIMELINE   = 0x20000,
43        TWITTER_GOT_MENTIONS   = 0x40000,
44} twitter_flags_t;
45
46typedef enum {
47        TWITTER_FILTER_TYPE_FOLLOW = 0,
48        TWITTER_FILTER_TYPE_TRACK
49} twitter_filter_type_t;
50
51struct twitter_log_data;
52
53struct twitter_data {
54        char* user;
55        struct oauth_info *oauth_info;
56
57        gpointer home_timeline_obj;
58        gpointer mentions_obj;
59
60        guint64 timeline_id;
61
62        GSList *follow_ids;
63        GSList *filters;
64
65        guint64 last_status_id; /* For undo */
66        gint main_loop_id;
67        gint filter_update_id;
68        struct http_request *stream;
69        struct http_request *filter_stream;
70        struct groupchat *timeline_gc;
71        gint http_fails;
72        twitter_flags_t flags;
73
74        /* set base_url */
75        gboolean url_ssl;
76        int url_port;
77        char *url_host;
78        char *url_path;
79
80        char *prefix; /* Used to generate contact + channel name. */
81
82        /* set show_ids */
83        struct twitter_log_data *log;
84        int log_id;
85};
86
87#define TWITTER_FILTER_UPDATE_WAIT 3000
88struct twitter_filter {
89        twitter_filter_type_t type;
90        char *text;
91        guint64 uid;
92        GSList *groupchats;
93};
94
95struct twitter_user_data {
96        guint64 last_id;
97        time_t last_time;
98};
99
100#define TWITTER_LOG_LENGTH 256
101struct twitter_log_data {
102        guint64 id;
103        /* DANGER: bu can be a dead pointer. Check it first.
104         * twitter_message_id_from_command_arg() will do this. */
105        struct bee_user *bu;
106};
107
108/**
109 * This has the same function as the msn_connections GSList. We use this to
110 * make sure the connection is still alive in callbacks before we do anything
111 * else.
112 */
113extern GSList *twitter_connections;
114
115/**
116 * Evil hack: Fake bee_user which will always point at the local user.
117 * Sometimes used as a return value by twitter_message_id_from_command_arg.
118 * NOT thread safe but don't you dare to even think of ever making BitlBee
119 * threaded. :-)
120 */
121extern bee_user_t twitter_log_local_user;
122
123void twitter_login_finish(struct im_connection *ic);
124
125struct http_request;
126char *twitter_parse_error(struct http_request *req);
127
128void twitter_log(struct im_connection *ic, char *format, ...);
129struct groupchat *twitter_groupchat_init(struct im_connection *ic);
130
131#endif //_TWITTER_H
Note: See TracBrowser for help on using the repository browser.