aboutsummaryrefslogtreecommitdiff
path: root/src/lib/eventloop.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/eventloop.c')
-rw-r--r--src/lib/eventloop.c45
1 files changed, 37 insertions, 8 deletions
diff --git a/src/lib/eventloop.c b/src/lib/eventloop.c
index 54a7d2aa..3e3972fa 100644
--- a/src/lib/eventloop.c
+++ b/src/lib/eventloop.c
@@ -100,6 +100,15 @@ struct GNUNET_GTK_MainLoop
100 */ 100 */
101 GNUNET_SCHEDULER_TaskIdentifier dummy_task; 101 GNUNET_SCHEDULER_TaskIdentifier dummy_task;
102 102
103 /**
104 * Remaining command-line arguments.
105 */
106 char *const*argv;
107
108 /**
109 * Number of remaining arguments.
110 */
111 int argc;
103 112
104#if WINDOWS 113#if WINDOWS
105 /** 114 /**
@@ -203,8 +212,10 @@ GNUNET_GTK_main_loop_get_builder (struct GNUNET_GTK_MainLoop *ml)
203 return ml->builder; 212 return ml->builder;
204} 213}
205 214
215
206int 216int
207GNUNET_GTK_main_loop_build_window (struct GNUNET_GTK_MainLoop *ml, gpointer data) 217GNUNET_GTK_main_loop_build_window (struct GNUNET_GTK_MainLoop *ml,
218 gpointer data)
208{ 219{
209 ml->builder = GNUNET_GTK_get_new_builder (ml->main_window_file, data); 220 ml->builder = GNUNET_GTK_get_new_builder (ml->main_window_file, data);
210 if (ml->builder == NULL) 221 if (ml->builder == NULL)
@@ -245,6 +256,23 @@ GNUNET_GTK_main_loop_get_object (struct GNUNET_GTK_MainLoop * ml,
245 256
246 257
247/** 258/**
259 * Get remaining command line arguments.
260 *
261 * @param ml handle to the main loop
262 * @param argc set to argument count
263 * @param argv set to argument vector
264 */
265void
266GNUNET_GTK_main_loop_get_args (struct GNUNET_GTK_MainLoop * ml,
267 int *argc,
268 char *const**argv)
269{
270 *argc = ml->argc;
271 *argv = ml->argv;
272}
273
274
275/**
248 * Task to run Gtk events (within a GNUnet scheduler task). 276 * Task to run Gtk events (within a GNUnet scheduler task).
249 * 277 *
250 * @param cls the main loop handle 278 * @param cls the main loop handle
@@ -816,7 +844,7 @@ gnunet_gtk_select (void *cls, struct GNUNET_NETWORK_FDSet *rfds,
816 * is initialized. Initializes up GTK and Glade and starts the 844 * is initialized. Initializes up GTK and Glade and starts the
817 * combined event loop. 845 * combined event loop.
818 * 846 *
819 * @param cls the 'struct GNUNET_GTK_MainLoop' 847 * @param cls the `struct GNUNET_GTK_MainLoop`
820 * @param args leftover command line arguments (go to gtk) 848 * @param args leftover command line arguments (go to gtk)
821 * @param cfgfile name of the configuration file 849 * @param cfgfile name of the configuration file
822 * @param cfg handle to the configuration 850 * @param cfg handle to the configuration
@@ -871,6 +899,8 @@ run_main_loop (void *cls, char *const *args, const char *cfgfile,
871 ml->gmc = g_main_loop_get_context (ml->gml); 899 ml->gmc = g_main_loop_get_context (ml->gml);
872 ml->cfg = gcfg; 900 ml->cfg = gcfg;
873 ml->cfgfile = GNUNET_strdup (cfgfile); 901 ml->cfgfile = GNUNET_strdup (cfgfile);
902 ml->argc = argc;
903 ml->argv = args;
874#if WINDOWS 904#if WINDOWS
875 ml->hEventRead = CreateEvent (NULL, TRUE, FALSE, NULL); 905 ml->hEventRead = CreateEvent (NULL, TRUE, FALSE, NULL);
876 ml->hEventReadReady = CreateEvent (NULL, TRUE, TRUE, NULL); 906 ml->hEventReadReady = CreateEvent (NULL, TRUE, TRUE, NULL);
@@ -884,10 +914,6 @@ run_main_loop (void *cls, char *const *args, const char *cfgfile,
884 ml->read_array_length = 0; 914 ml->read_array_length = 0;
885#endif 915#endif
886 916
887 /* run main task of the application */
888 GNUNET_SCHEDULER_add_continuation (ml->main_task, ml,
889 GNUNET_SCHEDULER_REASON_STARTUP);
890
891 /* start the Gtk event loop */ 917 /* start the Gtk event loop */
892 GNUNET_assert (TRUE == g_main_context_acquire (ml->gmc)); 918 GNUNET_assert (TRUE == g_main_context_acquire (ml->gmc));
893 GNUNET_SCHEDULER_set_select (&gnunet_gtk_select, ml); 919 GNUNET_SCHEDULER_set_select (&gnunet_gtk_select, ml);
@@ -897,6 +923,9 @@ run_main_loop (void *cls, char *const *args, const char *cfgfile,
897 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 923 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
898 &keepalive_task, ml); 924 &keepalive_task, ml);
899 925
926 /* run main task of the application */
927 GNUNET_SCHEDULER_add_continuation (ml->main_task, ml,
928 GNUNET_SCHEDULER_REASON_STARTUP);
900} 929}
901 930
902 931
@@ -909,8 +938,8 @@ run_main_loop (void *cls, char *const *args, const char *cfgfile,
909 * @param argv command line options 938 * @param argv command line options
910 * @param options allowed command line options 939 * @param options allowed command line options
911 * @param main_window_file glade file for the main window 940 * @param main_window_file glade file for the main window
912 * @param main_task first task to run, closure will be set to the 'struct GNUNET_GTK_MainLoop' 941 * @param main_task first task to run, closure will be set to the `struct GNUNET_GTK_MainLoop`
913 * @return GNUNET_OK on success, GNUNET_SYSERR on error (i.e. bad command-line options, etc) 942 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error (i.e. bad command-line options, etc)
914 */ 943 */
915int 944int
916GNUNET_GTK_main_loop_start (const char *binary_name, const char *binary_help, 945GNUNET_GTK_main_loop_start (const char *binary_name, const char *binary_help,