42
44
static gchar *panel = "default";
43
45
static gchar *config = "default";
44
46
static gchar *desktop = "gnome";
45
static gchar *address = "";
47
gchar *g_address = "unix:tmpdir=/tmp";
46
48
gchar *g_cache = "auto";
47
49
gboolean g_mempro = FALSE;
48
50
gboolean g_verbose = FALSE;
49
gint g_dbus_timeout = 5000;
51
gint g_gdbus_timeout = 5000;
50
52
#ifdef G_THREADS_ENABLED
51
53
gint g_monitor_timeout = 0;
65
67
{ "single", 's', 0, G_OPTION_ARG_NONE, &single, "do not execute panel and config module.", NULL },
66
68
{ "xim", 'x', 0, G_OPTION_ARG_NONE, &xim, "execute ibus XIM server.", NULL },
67
69
{ "desktop", 'n', 0, G_OPTION_ARG_STRING, &desktop, "specify the name of desktop session. [default=gnome]", "name" },
68
{ "panel", 'p', 0, G_OPTION_ARG_STRING, &panel, "specify the cmdline of panel program.", "cmdline" },
69
{ "config", 'c', 0, G_OPTION_ARG_STRING, &config, "specify the cmdline of config program.", "cmdline" },
70
{ "address", 'a', 0, G_OPTION_ARG_STRING, &address, "specify the address of ibus daemon.", "address" },
70
{ "panel", 'p', 0, G_OPTION_ARG_STRING, &panel, "specify the cmdline of panel program. pass 'disable' not to start a panel program.", "cmdline" },
71
{ "config", 'c', 0, G_OPTION_ARG_STRING, &config, "specify the cmdline of config program. pass 'disable' not to start a config program.", "cmdline" },
72
{ "address", 'a', 0, G_OPTION_ARG_STRING, &g_address, "specify the address of ibus daemon.", "address" },
71
73
{ "replace", 'r', 0, G_OPTION_ARG_NONE, &replace, "if there is an old ibus-daemon is running, it will be replaced.", NULL },
72
74
{ "cache", 't', 0, G_OPTION_ARG_STRING, &g_cache, "specify the cache mode. [auto/refresh/none]", NULL },
73
{ "timeout", 'o', 0, G_OPTION_ARG_INT, &g_dbus_timeout, "dbus reply timeout in milliseconds.", "timeout [default is 2000]" },
75
{ "timeout", 'o', 0, G_OPTION_ARG_INT, &g_gdbus_timeout, "gdbus reply timeout in milliseconds. pass -1 to use the default timeout of gdbus.", "timeout [default is 5000]" },
74
76
#ifdef G_THREADS_ENABLED
75
77
{ "monitor-timeout", 'j', 0, G_OPTION_ARG_INT, &g_monitor_timeout, "timeout of poll changes of engines in seconds. 0 to disable it. ", "timeout [default is 0]" },
87
* @cmdline: An absolute path of the executable and its parameters, e.g. "/usr/lib/ibus/ibus-x11 --kill-daemon".
88
* @returns: TRUE if both parsing cmdline and executing the command succeed.
90
* Execute cmdline. Child process's stdin, stdout, and stderr are attached to /dev/null.
91
* You don't have to handle SIGCHLD from the child process since glib will do.
84
94
execute_cmdline (const gchar *cmdline)
86
96
g_assert (cmdline);
100
GError *error = NULL;
94
101
if (!g_shell_parse_argv (cmdline, &argc, &argv, &error)) {
95
102
g_warning ("Can not parse cmdline `%s` exec: %s", cmdline, error->message);
96
103
g_error_free (error);
166
179
main (gint argc, gchar **argv)
168
GOptionContext *context;
172
GError *error = NULL;
174
181
setlocale (LC_ALL, "");
176
context = g_option_context_new ("- ibus daemon");
183
GOptionContext *context = g_option_context_new ("- ibus daemon");
178
184
g_option_context_add_main_entries (context, entries, "ibus-daemon");
180
186
g_argv = g_strdupv (argv);
187
GError *error = NULL;
181
188
if (!g_option_context_parse (context, &argc, &argv, &error)) {
182
189
g_printerr ("Option parsing failed: %s\n", error->message);
190
g_error_free (error);
193
if (g_gdbus_timeout < -1) {
194
g_printerr ("Bad timeout (must be >= -1): %d\n", g_gdbus_timeout);
235
247
g_object_unref (bus);
239
/* create ibus server */
240
server = bus_server_get_default ();
241
bus_server_listen (server);
244
252
/* execute config component */
245
253
if (g_strcmp0 (config, "default") == 0) {
246
IBusComponent *component;
254
BusComponent *component;
247
255
component = bus_registry_lookup_component_by_name (BUS_DEFAULT_REGISTRY, IBUS_SERVICE_CONFIG);
249
ibus_component_set_restart (component, restart);
257
bus_component_set_restart (component, restart);
251
if (component == NULL || !ibus_component_start (component, g_verbose)) {
259
if (component == NULL || !bus_component_start (component, g_verbose)) {
252
260
g_printerr ("Can not execute default config program\n");
260
/* execut panel component */
268
/* execute panel component */
261
269
if (g_strcmp0 (panel, "default") == 0) {
262
IBusComponent *component;
270
BusComponent *component;
263
271
component = bus_registry_lookup_component_by_name (BUS_DEFAULT_REGISTRY, IBUS_SERVICE_PANEL);
265
ibus_component_set_restart (component, restart);
273
bus_component_set_restart (component, restart);
267
if (component == NULL || !ibus_component_start (component, g_verbose)) {
275
if (component == NULL || !bus_component_start (component, g_verbose)) {
268
276
g_printerr ("Can not execute default panel program\n");