1 /*
2  *  This file is part of GNOME Twitch - 'Enjoy Twitch on your GNU/Linux desktop'
3  *  Copyright © 2017 Vincent Szolnoky <vinszent@vinszent.com>
4  *
5  *  GNOME Twitch is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation, either version 3 of the License, or
8  *  (at your option) any later version.
9  *
10  *  GNOME Twitch is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with GNOME Twitch. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef GT_APP_H
20 #define GT_APP_H
21 
22 #include <gtk/gtk.h>
23 #include <libpeas/peas.h>
24 #include <libsoup/soup.h>
25 
26 G_BEGIN_DECLS
27 
28 #define GT_TYPE_APP (gt_app_get_type())
29 
30 G_DECLARE_FINAL_TYPE(GtApp, gt_app, GT, APP, GtkApplication)
31 
32 #include "gt-follows-manager.h"
33 #include "gt-irc.h"
34 #include "gt-http.h"
35 
36 typedef struct
37 {
38     gchar* id;
39     gchar* name;
40     gchar* oauth_token;
41     gchar* display_name;
42     gchar* bio;
43     gchar* logo_url;
44     gchar* type;
45     gchar* email;
46     gboolean email_verified;
47     gboolean partnered;
48     gboolean twitter_connected;
49     GDateTime* created_at;
50     GDateTime* updated_at;
51 
52     struct
53     {
54         gboolean email;
55         gboolean push;
56     } notifications;
57 } GtUserInfo;
58 
59 typedef struct
60 {
61     gboolean valid;
62     gchar* oauth_token;
63     gchar* user_name;
64     gchar* user_id;
65     gchar* client_id;
66     GStrv scopes;
67     GDateTime* created_at;
68     GDateTime* updated_at;
69 } GtOAuthInfo;
70 
71 #include "gt-twitch.h"
72 
73 typedef struct _GtAppPrivate GtAppPrivate;
74 
75 struct _GtApp
76 {
77     GtkApplication parent_instance;
78 
79     GtTwitch* twitch;
80     GtFollowsManager* fav_mgr;
81     GSettings* settings;
82 
83     PeasEngine* players_engine;
84 
85     SoupSession* soup;
86 
87     GtHTTP* http;
88 };
89 
90 typedef struct
91 {
92     gchar* name;
93     gboolean visible;
94     gboolean docked;
95     gboolean dark_theme;
96     gdouble opacity;
97     gdouble width;
98     gdouble height;
99     gdouble x_pos;
100     gdouble y_pos;
101     gdouble docked_handle_pos;
102 } GtChatViewSettings;
103 
104 GtChatViewSettings* gt_chat_view_settings_new();
105 GtApp* gt_app_new(void);
106 
107 extern GtApp* main_app;
108 extern gchar* ORIGINAL_LOCALE;
109 extern gint LOG_LEVEL;
110 extern gboolean NO_FANCY_LOGGING;
111 extern const gchar* TWITCH_AUTH_SCOPES[];
112 
113 gboolean gt_app_is_logged_in(GtApp* self);
114 void gt_app_set_oauth_info(GtApp* self, GtOAuthInfo* info);
115 const GtUserInfo* gt_app_get_user_info(GtApp* self);
116 const GtOAuthInfo* gt_app_get_oauth_info(GtApp* self);
117 const gchar* gt_app_get_language_filter(GtApp* self);
118 gboolean gt_app_should_show_notifications(GtApp* self);
119 
120 GtUserInfo*       gt_user_info_new();
121 void              gt_user_info_free(GtUserInfo* info);
122 GtOAuthInfo*      gt_oauth_info_new();
123 void              gt_oauth_info_free(GtOAuthInfo* info);
124 
125 G_END_DECLS
126 
127 #endif
128