aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/fs/gnunet-fs-gtk.c32
-rw-r--r--src/fs/gnunet-fs-gtk_open-uri.c4
-rw-r--r--src/include/gnunet_gtk.h18
-rw-r--r--src/lib/eventloop.c45
4 files changed, 85 insertions, 14 deletions
diff --git a/src/fs/gnunet-fs-gtk.c b/src/fs/gnunet-fs-gtk.c
index 1f7d4502..bfcd0710 100644
--- a/src/fs/gnunet-fs-gtk.c
+++ b/src/fs/gnunet-fs-gtk.c
@@ -658,7 +658,7 @@ handle_sks_zone_identity (void *cls,
658 * Actual main function run right after GNUnet's scheduler 658 * Actual main function run right after GNUnet's scheduler
659 * is initialized. Initializes up GTK and Glade. 659 * is initialized. Initializes up GTK and Glade.
660 * 660 *
661 * @param cls handle to the main loop ('struct GNUNET_GTK_MainLoop') 661 * @param cls handle to the main loop (`struct GNUNET_GTK_MainLoop`)
662 * @param tc scheduler context, unused 662 * @param tc scheduler context, unused
663 */ 663 */
664static void 664static void
@@ -793,6 +793,26 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
793 gtk_widget_show (main_context.main_window); 793 gtk_widget_show (main_context.main_window);
794 gtk_window_present (GTK_WINDOW (main_context.main_window)); 794 gtk_window_present (GTK_WINDOW (main_context.main_window));
795 } 795 }
796
797 {
798 char *const *argv;
799 int argc;
800 int i;
801
802 GNUNET_GTK_main_loop_get_args (ml, &argc, &argv);
803
804 for (i = 0; i < argc; i++)
805 {
806 if (GNUNET_OK !=
807 GNUNET_FS_GTK_handle_uri_string (argv[i],
808 1 /* anonymity level */))
809 fprintf (stderr,
810 "Invalid URI `%s'\n",
811 argv[i]);
812 }
813 }
814
815
796 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 816 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
797 &shutdown_task, NULL); 817 &shutdown_task, NULL);
798} 818}
@@ -837,11 +857,15 @@ main (int argc, char **argv)
837 857
838 return (UNIQUE_RESPONSE_OK == response) ? 0 : 1; 858 return (UNIQUE_RESPONSE_OK == response) ? 0 : 1;
839 } 859 }
860
840#endif 861#endif
841 if (GNUNET_OK != 862 if (GNUNET_OK !=
842 GNUNET_GTK_main_loop_start ("gnunet-fs-gtk", "GTK GUI for GNUnet", argc, 863 GNUNET_GTK_main_loop_start ("gnunet-fs-gtk",
843 argv, options, 864 "GTK GUI for GNUnet",
844 "gnunet_fs_gtk_main_window.glade", &run)) 865 argc, argv,
866 options,
867 "gnunet_fs_gtk_main_window.glade",
868 &run))
845 { 869 {
846#if HAVE_LIBUNIQUE 870#if HAVE_LIBUNIQUE
847 g_object_unref (unique_app); 871 g_object_unref (unique_app);
diff --git a/src/fs/gnunet-fs-gtk_open-uri.c b/src/fs/gnunet-fs-gtk_open-uri.c
index 2f0852ae..c272083d 100644
--- a/src/fs/gnunet-fs-gtk_open-uri.c
+++ b/src/fs/gnunet-fs-gtk_open-uri.c
@@ -38,7 +38,7 @@
38 * 38 *
39 * @param uris string we got 39 * @param uris string we got
40 * @param anonymity_level anonymity level to use 40 * @param anonymity_level anonymity level to use
41 * @return GNUNET_OK on success, GNUNET_NO if the URI type is not supported, GNUNET_SYSERR if we failed to 41 * @return #GNUNET_OK on success, #GNUNET_NO if the URI type is not supported, #GNUNET_SYSERR if we failed to
42 * parse the URI 42 * parse the URI
43 */ 43 */
44int 44int
@@ -63,7 +63,7 @@ GNUNET_FS_GTK_handle_uri_string (const char *uris,
63 * User selected "execute" in the open-URI dialog. 63 * User selected "execute" in the open-URI dialog.
64 * 64 *
65 * @param button the execute button 65 * @param button the execute button
66 * @param user_data the 'GtkBuilder' of the URI dialog 66 * @param user_data the `GtkBuilder` of the URI dialog
67 */ 67 */
68void 68void
69GNUNET_GTK_open_url_dialog_execute_button_clicked_cb (GtkButton * button, 69GNUNET_GTK_open_url_dialog_execute_button_clicked_cb (GtkButton * button,
diff --git a/src/include/gnunet_gtk.h b/src/include/gnunet_gtk.h
index fc5f9fbc..98685110 100644
--- a/src/include/gnunet_gtk.h
+++ b/src/include/gnunet_gtk.h
@@ -231,8 +231,26 @@ GtkBuilder *
231GNUNET_GTK_main_loop_get_builder (struct GNUNET_GTK_MainLoop *ml); 231GNUNET_GTK_main_loop_get_builder (struct GNUNET_GTK_MainLoop *ml);
232 232
233 233
234
235/**
236 * Get remaining command line arguments.
237 *
238 * @param ml handle to the main loop
239 * @param argc set to argument count
240 * @param argv set to argument vector
241 */
242void
243GNUNET_GTK_main_loop_get_args (struct GNUNET_GTK_MainLoop * ml,
244 int *argc,
245 char *const**argv);
246
247
234/** 248/**
235 * FIXME! 249 * FIXME!
250 *
251 * @param ml FIXME
252 * @param data FIXME
253 * @return FIXME
236 */ 254 */
237int 255int
238GNUNET_GTK_main_loop_build_window (struct GNUNET_GTK_MainLoop *ml, 256GNUNET_GTK_main_loop_build_window (struct GNUNET_GTK_MainLoop *ml,
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,