1 /* This file is part of Cawbird, a Gtk+ linux Twitter client forked from Corebird. 2 * Copyright (C) 2017 Timm Bäder (Corebird) 3 * 4 * Cawbird is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * Cawbird is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with cawbird. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef __CB_USER_STREAM_H__ 19 #define __CB_USER_STREAM_H__ 20 21 #include <glib-object.h> 22 #include <rest/oauth-proxy.h> 23 #include <rest/rest-proxy.h> 24 #include "CbMessageReceiver.h" 25 #include "CbTypes.h" 26 27 G_BEGIN_DECLS 28 29 #define CB_TYPE_USER_STREAM (cb_user_stream_get_type ()) 30 G_DECLARE_FINAL_TYPE (CbUserStream, cb_user_stream, CB, USER_STREAM, GObject); 31 32 struct _CbUserStream 33 { 34 GObject parent_instance; 35 36 GPtrArray *receivers; 37 RestProxy *proxy; 38 GNetworkMonitor *network_monitor; 39 40 guint network_timeout_id; 41 guint heartbeat_timeout_id; 42 guint network_changed_id; 43 44 gint64 last_home_id; 45 guint timeline_timeout; 46 GCancellable *home_cancellable; 47 48 gint64 last_mentions_id; 49 guint mentions_timeout; 50 GCancellable *mentions_cancellable; 51 52 gint64 last_favourited_id; 53 guint favourited_timeout; 54 GCancellable *favourited_cancellable; 55 56 gint64 first_dm_id; 57 gint64 last_dm_id; 58 gint64 new_last_dm_id; // Placeholder for the next value of last_dm_id so that we can page back if lots of tweets came in 59 unsigned char dm_recursions; 60 guint dm_timeout; 61 GCancellable *dm_cancellable; 62 63 char *account_name; 64 65 guint state; 66 guint restarting : 1; 67 guint proxy_data_set : 1; 68 guint network_available: 1; 69 }; 70 typedef struct _CbUserStream CbUserStream; 71 72 CbUserStream * cb_user_stream_new (const char *account_name, 73 OAuthProxy *proxy); 74 void cb_user_stream_set_proxy_data (CbUserStream *self, 75 const char *token, 76 const char *token_secret); 77 void cb_user_stream_register (CbUserStream *self, 78 CbMessageReceiver *receiver); 79 void cb_user_stream_unregister (CbUserStream *self, 80 CbMessageReceiver *receiver); 81 void cb_user_stream_start (CbUserStream *self); 82 void cb_user_stream_stop (CbUserStream *self); 83 void cb_user_stream_push_data (CbUserStream *self, 84 const char *data); 85 void cb_user_stream_inject_tweet (CbUserStream *self, 86 CbStreamMessageType message_type, 87 const gchar *content) 88 89 G_END_DECLS; 90 91 #endif 92