#include "ui-line.h"
#include "network.h"
#include "configuration.h"
+#include "startup.h"
#ifdef HAVE_GNOME
#include "ui-gnome.h"
static int optarg_start;
static int optarg_stop;
int optarg_no_fork;
+static int optarg_startup_query;
+static int optarg_startup_on;
+static int optarg_startup_off;
void (*ui_interactive)(void);
#else /* HAVE_GNOME */
#define OPT_TEXT_IF_GNOME N_("(no Gnome UI compiled - stub only); --text must be first argument")
#endif /* HAVE_GNOME */
- UDPGATE_POPT(0 ,"text" ,POPT_ARG_NONE ,&optarg_text ,0,
- OPT_TEXT_IF_GNOME,NULL),
-#undef OPT_TEXT_IF_GNOME
- 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,
+ UDPGATE_POPT(0 ,"text" ,POPT_ARG_NONE ,&optarg_text ,0,
+ OPT_TEXT_IF_GNOME,NULL),
+#undef OPT_TEXT_IF_GNOME
+ 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,
+ UDPGATE_POPT('1',"no-fork" ,POPT_ARG_NONE ,&optarg_no_fork ,0,
N_("Do not detach from the current process"),NULL),
+ UDPGATE_POPT(0 ,"startup-query",POPT_ARG_NONE ,&optarg_startup_query,0,
+ N_("Query the current state of the system startup registrance"),NULL),
+ UDPGATE_POPT(0 ,"startup-on" ,POPT_ARG_NONE ,&optarg_startup_on ,0,
+ N_("Register for the automatic system startup"),NULL),
+ UDPGATE_POPT(0 ,"startup-off" ,POPT_ARG_NONE ,&optarg_startup_off ,0,
+ N_("Unregister from the automatic system startup"),NULL),
#undef UDPGATE_POPT
POPT_TABLEEND
#ifdef HAVE_GNOME
gboolean no_gnome;
#endif /* HAVE_GNOME */
+int exit_rc=EXIT_SUCCESS;
#if 0
g_log_set_always_fatal(~(0
is_interactive=(1
&& !optarg_start
- && !optarg_stop);
+ && !optarg_stop
+ && !optarg_startup_query
+ && !optarg_startup_on
+ && !optarg_startup_off);
/* Initialize UI here to catch all GLog errors below. */
if (is_interactive
g_error(_("No UI interface could be initialized"));
if (!is_interactive) {
+
+ if (optarg_startup_query || optarg_startup_off || optarg_startup_on)
+ startup_init();
+
if (optarg_stop)
- network_stop();
+ if (!network_stop())
+ exit_rc=2;
+ if (optarg_startup_query) {
+gboolean is_on;
+
+ if (startup_query(&is_on)) {
+ g_message((is_on
+ ? _("System startup registrance is turned on.")
+ : _("System startup registrance is turned off.")));
+ if (exit_rc<2)
+ exit_rc=(is_on ? 0 : 1);
+ }
+ else
+ exit_rc=2;
+ }
+ if (optarg_startup_off) {
+ if (!startup_off())
+ exit_rc=2;
+ }
+ if (optarg_startup_on) {
+ if (!startup_on())
+ exit_rc=2;
+ }
if (optarg_start)
- network_start(optarg_port);
+ if (!network_start(optarg_port))
+ exit_rc=2;
+
network_detach();
}
else
configuration_write();
- return EXIT_SUCCESS;
+ exit(exit_rc);
}