merge in sm217s cookie code (which is work in progress)
[uzbl-mobile] / uzbl.h
1 /* statusbar symbols */
2 enum { SYM_TITLE, SYM_URI, SYM_NAME, 
3        SYM_LOADPRGS, SYM_LOADPRGSBAR,
4        SYM_KEYCMD, SYM_MODE};
5 const struct {
6     gchar *symbol_name;
7     guint symbol_token;
8 } symbols[] = {
9     {"NAME",                 SYM_NAME},
10     {"URI",                  SYM_URI},
11     {"TITLE",                SYM_TITLE},
12     {"KEYCMD",               SYM_KEYCMD},
13     {"MODE",                 SYM_MODE},
14     {"LOAD_PROGRESS",        SYM_LOADPRGS},
15     {"LOAD_PROGRESSBAR",     SYM_LOADPRGSBAR},
16     {NULL,                   0}
17 }, *symp = symbols;
18
19 /* status bar elements */
20 typedef struct {
21     gint           load_progress;
22 } StatusBar;
23
24 /* gui elements */
25 typedef struct {
26     GtkWidget*     main_window;
27     GtkWidget*     mainbar;
28     GtkWidget*     mainbar_label;
29     GtkScrollbar*  scbar_v;   // Horizontal and Vertical Scrollbar
30     GtkScrollbar*  scbar_h;   // (These are still hidden)
31     GtkAdjustment* bar_v; // Information about document length
32     GtkAdjustment* bar_h; // and scrolling position
33     WebKitWebView* web_view;
34     gchar*         main_title;
35
36     StatusBar sbar;
37 } GUI;
38
39 /* external communication*/
40 typedef struct {
41     char           fifo_path[64];
42     char           socket_path[108];
43 } Communication;
44
45 /* internal state */
46 typedef struct {
47     gchar    *uri;
48     gchar    *config_file;
49     gchar    *instance_name;
50     gchar    config_file_path[500];
51 } State;
52
53 typedef struct {
54     SoupSession *soup_session;
55     SoupLogger *soup_logger;
56     char *proxy_url;
57     char *useragent;
58     gint max_conns;
59     gint max_conns_host;
60 } Network;
61
62
63 /* main uzbl data structure */
64 typedef struct {
65     GUI     gui;
66     Communication comm;
67     State   state;
68     Network net;
69     Window  xwin;
70     GScanner *scan;
71 } Uzbl;
72
73 typedef struct {
74     char* name;
75     char* param;
76 } Action;
77
78
79
80 /* Functions */
81 static void
82 setup_scanner();
83
84 char *
85 itos(int val);
86
87 static gboolean
88 new_window_cb (WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequest *request, WebKitWebNavigationAction *navigation_action, WebKitWebPolicyDecision *policy_decision, gpointer user_data);
89
90 WebKitWebView*
91 create_web_view_cb (WebKitWebView  *web_view, WebKitWebFrame *frame, gpointer user_data);
92
93 static gboolean
94 download_cb (WebKitWebView *web_view, GObject *download, gpointer user_data);
95
96 static void
97 toggle_status_cb (WebKitWebView* page, const char *param);
98
99 static void
100 link_hover_cb (WebKitWebView* page, const gchar* title, const gchar* link, gpointer data);
101
102 static void
103 title_change_cb (WebKitWebView* web_view, WebKitWebFrame* web_frame, const gchar* title, gpointer data);
104
105 static void
106 progress_change_cb (WebKitWebView* page, gint progress, gpointer data);
107
108 static void
109 load_commit_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data);
110
111 static void
112 destroy_cb (GtkWidget* widget, gpointer data);
113
114 static void
115 log_history_cb ();
116
117 static void
118 commands_hash(void);
119
120 void
121 free_action(gpointer act);
122
123 Action*
124 new_action(const gchar *name, const gchar *param);
125
126 static bool
127 file_exists (const char * filename);
128
129 void
130 set_insert_mode(WebKitWebView *page, const gchar *param);
131
132 static void
133 load_uri (WebKitWebView * web_view, const gchar *param);
134
135 static void
136 new_window_load_uri (const gchar * uri);
137
138 static void
139 close_uzbl (WebKitWebView *page, const char *param);
140
141 static gboolean
142 run_command_async(const char *command, const char *args);
143
144 static gboolean
145 run_command_sync(const char *command, const char *args, char **stdout);
146
147 static void
148 spawn(WebKitWebView *web_view, const char *param);
149
150 static void
151 parse_command(const char *cmd, const char *param);
152
153 static void
154 parse_line(char *line);
155
156 void
157 build_stream_name(int type);
158
159 static void
160 control_fifo(GIOChannel *gio, GIOCondition condition);
161
162 static void
163 create_fifo();
164
165 static void
166 create_socket();
167
168 static void
169 control_socket(GIOChannel *chan);
170  
171
172 static void
173 update_title (void);
174  
175 static gboolean
176 key_press_cb (WebKitWebView* page, GdkEventKey* event);
177
178 static GtkWidget*
179 create_browser ();
180
181 static GtkWidget*
182 create_mainbar ();
183
184 static
185 GtkWidget* create_window ();
186
187 static void
188 add_binding (const gchar *key, const gchar *act);
189
190 static void
191 settings_init ();
192
193 static void
194 search_text (WebKitWebView *page, const char *param);
195
196 static void
197 run_js (WebKitWebView * web_view, const gchar *param);
198
199 static char *
200 str_replace (const char* search, const char* replace, const char* string);
201
202 static void handle_cookies (SoupSession *session,
203                                                         SoupMessage *msg,
204                                                         gpointer     user_data);
205 static void
206 save_cookies (SoupMessage *msg,
207                           gpointer     user_data);
208 /* vi: set et ts=4: */