#include <libgnome/gnome-program.h>
#include <libgnomeui/gnome-ui-init.h>
+#include "main.h" /* self */
#include "ui-gnome.h"
+#include "ui-line.h"
+#include "network.h"
+
+
+/* Config: */
+#define LOCAL_PORT_DEFAULT 9201
-int optarg_verbose;
static int optarg_text;
+int optarg_verbose;
+int optarg_port=LOCAL_PORT_DEFAULT;
+static int optarg_start;
+static int optarg_stop;
+int optarg_no_fork;
+
+void (*ui_interactive)(void);
static const struct poptOption popt_table[]={
argDescrip: (argDescripP), \
}
- UDPGATE_POPT(0 ,"text" ,POPT_ARG_NONE ,&optarg_text ,0,
+ UDPGATE_POPT(0 ,"text" ,POPT_ARG_NONE ,&optarg_text ,0,
N_("Disable Gnome UI; --text must be first argument"),NULL),
- UDPGATE_POPT('v',"verbose" ,POPT_ARG_NONE ,&optarg_verbose,0,N_("Display additional debug information"),NULL),
+ UDPGATE_POPT('v',"verbose",POPT_ARG_NONE ,&optarg_verbose,0,
+ N_("Display additional debug information"),NULL),
+ UDPGATE_POPT('p',"port" ,POPT_ARG_INT |POPT_ARGFLAG_SHOW_DEFAULT,&optarg_port ,0,
+ N_("Listen on this UDP port"),NULL),
+ UDPGATE_POPT('s',"start" ,POPT_ARG_NONE ,&optarg_start ,0,
+ N_("Start the daemon"),NULL),
+ UDPGATE_POPT('S',"stop" ,POPT_ARG_NONE ,&optarg_stop ,0,
+ N_("Stop the daemon"),NULL),
+ UDPGATE_POPT('1',"no-fork",POPT_ARG_NONE ,&optarg_no_fork,0,
+ N_("Do not detach from the current process"),NULL),
#undef UDPGATE_POPT
POPT_TABLEEND
}
is_interactive=(1
-/* && ! optarg_scan_path_list
- && ! optarg_scan_disks_quick
- && ! optarg_scan_disks
- && ! optarg_microsoft_com */ );
+ && !optarg_start
+ && !optarg_stop);
/* Initialize UI here to catch all GLog errors below. */
if (is_interactive
&& (no_gnome || !ui_gnome_init())
-/* && !ui_line_init()*/)
+ && !ui_line_init())
g_error(_("No UI interface could be initialized"));
- if (!is_interactive)
- /*scan_batch()*/;
+ if (!is_interactive) {
+ if (optarg_stop)
+ network_stop();
+ if (optarg_start)
+ network_start(optarg_port);
+ network_detach();
+ }
else
- ui_gnome_interactive();
+ (*ui_interactive)();
return EXIT_SUCCESS;
}