static void init_outside(const char * iconfile, const char *exefile) { IBusComponent *component; IBusEngineDesc * desc; ibus_init(); bus = ibus_bus_new(); g_signal_connect (bus, "disconnected", G_CALLBACK (ibus_disconnected_cb), NULL); factory = ibus_factory_new(ibus_bus_get_connection(bus)); ibus_bus_request_name(bus, "org.freedesktop.IBus.handwrite", 0); desc = ibus_engine_desc_new("handwrite", "handwrite", _("hand write recognizer"), "zh_CN", "GPL", MICROCAI_WITHEMAIL, iconfile, "us"); component = ibus_component_new("org.freedesktop.IBus.handwrite", "handwrite", PACKAGE_VERSION, "GPL", MICROCAI_WITHEMAIL, PACKAGE_BUGREPORT, exefile, GETTEXT_PACKAGE); ibus_component_add_engine(component, desc); ibus_bus_register_component(bus, component); ibus_factory_add_engine(factory, "handwrite", IBUS_TYPE_HANDWRITE_ENGINE); g_object_unref(component); }
static gboolean init (void) { ibus_init (); bus = ibus_bus_new (); g_object_ref_sink (bus); g_signal_connect (bus, "disconnected", G_CALLBACK (ibus_disconnected_cb), NULL); ibus_libthai_init (bus); factory = ibus_factory_new (ibus_bus_get_connection (bus)); g_object_ref_sink (factory); ibus_factory_add_engine (factory, "libthai", IBUS_TYPE_LIBTHAI_ENGINE); if (opt_ibus) { ibus_bus_request_name (bus, "org.freedesktop.IBus.LibThai", 0); } else { IBusComponent *component; component = ibus_libthai_get_component (); if (!component) { g_print ("Cannot create LibThai component.\n"); return FALSE; } ibus_bus_register_component (bus, component); } return TRUE; }
int main(int argc, char* argv[]) { gtk_init(&argc, &argv); ibus_init(); ParseParameters(&argc, &argv, paramters); setlocale(LC_ALL, ""); gtk_set_locale(); textdomain(GETTEXT_PACKAGE); #ifdef DEBUG bindtextdomain(GETTEXT_PACKAGE, "/tmp/usr/share/locale"); #endif if (!have_ibus) { char exefile[4096] = { 0 }; char iconfile[4096] = { 0 }; realpath(argv[0], exefile); realpath(icon_file, iconfile); init_outside(iconfile, exefile); printf(_("ibus-handwrite Version %s Start Up\n"), PACKAGE_VERSION); } else { init_inside(); } gtk_main(); return 0; }
static void start_component (void) { GList *engines, *p; IBusComponent *component; ibus_init (); bus = ibus_bus_new (); g_signal_connect (bus, "disconnected", G_CALLBACK (ibus_disconnected_cb), NULL); component = ibus_xkb_get_component (); factory = ibus_factory_new (ibus_bus_get_connection (bus)); engines = ibus_component_get_engines (component); for (p = engines; p != NULL; p = p->next) { IBusEngineDesc *engine = (IBusEngineDesc *)p->data; ibus_factory_add_engine (factory, engine->name, IBUS_TYPE_XKB_LAYOUT_ENGINE); } if (ibus) { ibus_bus_request_name (bus, "org.freedesktop.IBus.XKBLayouts", 0); } else { ibus_bus_register_component (bus, component); } g_object_unref (component); ibus_main (); }
static Eina_Bool im_module_init(void) { ecore_main_loop_glib_integrate(); ibus_init(); ecore_imf_module_register(&ibus_im_info, im_module_create, im_module_exit); return EINA_TRUE; }
/* --------------------------------------- 目标板初始化 --------------------------------------- */ static void_t board_init (void_t) { #if FALSE ibus_init(); nand_format(); #else usb0_init(); #endif }
static void start_component(void) { IBUS_CHEWING_LOG(INFO, "start_component"); ibus_init(); bus = ibus_bus_new(); g_signal_connect(bus, "disconnected", G_CALLBACK(ibus_disconnected_cb), NULL); factory = ibus_factory_new(ibus_bus_get_connection(bus)); ibus_factory_add_engine(factory, "chewing", IBUS_TYPE_CHEWING_ENGINE); if (ibus) { ibus_bus_request_name(bus, QUOTE_ME(PROJECT_SCHEMA_ID), 0); } else { IBusComponent *component = NULL; if (xml) { component = ibus_component_new_from_file(QUOTE_ME(DATA_DIR) "/ibus/component/chewing.xml"); } else { component = ibus_component_new(QUOTE_ME(PROJECT_SCHEMA_ID), _("Chewing component"), QUOTE_ME(PRJ_VER), "GPLv2+", _("Peng Huang, Ding-Yi Chen"), "http://code.google.com/p/ibus", QUOTE_ME(LIBEXEC_DIR) "/ibus-engine-chewing --ibus", QUOTE_ME(PROJECT_NAME)); } IBusEngineDesc *engineDesc = ibus_engine_desc_new_varargs("name", "chewing", "longname", _("Chewing"), "description", _("Chinese chewing input method"), "language", "zh_TW", "license", "GPLv2+", "author", _("Peng Huang, Ding-Yi Chen"), "icon", QUOTE_ME(PRJ_DATA_DIR) "/icons/" QUOTE_ME(PROJECT_NAME) ".png", "layout", "us", "setup", QUOTE_ME(LIBEXEC_DIR) "/ibus-setup-chewing", "version", QUOTE_ME(PRJ_VER), "textdomain", QUOTE_ME(PROJECT_NAME), NULL); ibus_component_add_engine(component, engineDesc); ibus_bus_register_component(bus, component); } ibus_main(); }
static void rime_with_ibus() { ibus_init(); IBusBus *bus = ibus_bus_new(); g_object_ref_sink(bus); if (!ibus_bus_is_connected(bus)) { g_warning("not connected to ibus"); exit(0); } g_signal_connect(bus, "disconnected", G_CALLBACK(ibus_disconnect_cb), NULL); IBusConfig *config = ibus_bus_get_config(bus); if (!config) { g_warning("ibus config not accessible"); } else { g_object_ref_sink(config); ibus_rime_load_settings(config); g_signal_connect(config, "value-changed", G_CALLBACK(ibus_rime_config_value_changed_cb), NULL); } IBusFactory *factory = ibus_factory_new(ibus_bus_get_connection(bus)); g_object_ref_sink(factory); ibus_factory_add_engine(factory, "rime", IBUS_TYPE_RIME_ENGINE); if (!ibus_bus_request_name(bus, "com.googlecode.rimeime.Rime", 0)) { g_error("error requesting bus name"); exit(1); } if (!notify_init("ibus-rime")) { g_error("notify_init failed"); exit(1); } RimeSetupLogging("rime.ibus"); gboolean full_check = FALSE; ibus_rime_start(full_check); ibus_main(); RimeFinalize(); notify_uninit(); if (config) { g_object_unref(config); } g_object_unref(factory); g_object_unref(bus); }
static void ibus_memconf_start (void) { ibus_init (); bus = ibus_bus_new (); if (!ibus_bus_is_connected (bus)) { exit (-1); } g_signal_connect (bus, "disconnected", G_CALLBACK (ibus_disconnected_cb), NULL); config = ibus_config_memconf_new (ibus_bus_get_connection (bus)); ibus_bus_request_name (bus, IBUS_SERVICE_CONFIG, 0); ibus_main (); }
static void _init_ibus (void) { if (_bus != NULL) return; ibus_init (); _bus = ibus_bus_new (); g_signal_connect (_bus, "disconnected", G_CALLBACK (_bus_disconnected_cb), NULL); }
static void _init_ibus (void) { if (_bus != NULL) return; ibus_init (); _bus = ibus_bus_new (); g_signal_connect (_bus, "disconnected", G_CALLBACK (_bus_disconnected_cb), NULL); _use_sync_mode = _get_boolean_env ("IBUS_ENABLE_SYNC_MODE", FALSE); }
static void print_engines_xml (void) { IBusComponent* component; GString* output; ibus_init(); component = ibus_unikey_get_component (); output = g_string_new (""); ibus_component_output_engines (component, output, 0); fprintf (stdout, "%s", output->str); g_string_free(output, TRUE); }
static void init () { ibus_init (); bus = ibus_bus_new (); g_object_ref_sink(bus); if (!ibus_bus_is_connected (bus)) { g_warning("Can not connect to ibus"); exit (0); } g_signal_connect (bus, "disconnected", G_CALLBACK (ibus_disconnected_cb), NULL); IBusConfig* config = ibus_bus_get_config(bus); g_object_ref_sink(config); SunPinyinConfig::set_config(config); component = ibus_component_new ("org.freedesktop.IBus.SunPinyin", "SunPinyin2", "0.1.0", "LGPL/CDDL", "Kov Chai <*****@*****.**>", "http://code.google.com/p/sunpinyin/", "", "ibus-sunpinyin"); ibus_component_add_engine (component, ibus_engine_desc_new ("sunpinyin", "SunPinyin", _("Simplified Chinese Input Method developed by SUN"), "zh_CN", "LGPL/CDDL", "Kov Chai <*****@*****.**>", IBUS_SUNPINYIN_ICON_DIR"/sunpinyin-logo.png", "en")); factory = ibus_factory_new (ibus_bus_get_connection (bus)); ibus_factory_add_engine (factory, "sunpinyin", IBUS_TYPE_SUNPINYIN_ENGINE); if (by_ibus) { ibus_bus_request_name (bus, "org.freedesktop.IBus.SunPinyin", 0); } else { ibus_bus_register_component (bus, component); } ibus_main (); }
static void _init_ibus (void) { if (_bus != NULL) return; ibus_init (); _bus = ibus_bus_new (); if (!ibus_bus_is_connected (_bus)) { g_error ("Can not connect to ibus-daemon!"); } g_signal_connect (_bus, "disconnected", G_CALLBACK (_bus_disconnected_cb), NULL); }
static Eina_Bool im_module_init(void) { const char *s; if (!getenv("DISPLAY")) return EINA_FALSE; if ((s = getenv("ELM_DISPLAY"))) { if (strcmp(s, "x11")) return EINA_FALSE; } ecore_main_loop_glib_integrate(); ibus_init(); ecore_imf_module_register(&ibus_im_info, im_module_create, im_module_exit); return EINA_TRUE; }
gint main (gint argc, gchar **argv) { gint result; ibus_init (); g_test_init (&argc, &argv, NULL); bus = ibus_bus_new (); g_test_add_func ("/ibus/input_context", test_input_context); g_test_add_func ("/ibus/input_context_async_with_callback", test_async_apis); result = g_test_run (); g_object_unref (bus); return result; }
static void init (void) { IBusComponent *component; ibus_init (); bus = ibus_bus_new (); g_signal_connect (bus, "disconnected", G_CALLBACK (ibus_disconnected_cb), NULL); ibus_array_init(bus); component = ibus_component_new ("org.freedesktop.IBus.Array", "Array 30 Input Method", "0.0.1", "GPL", "Yu-Chun Wang <*****@*****.**>", "http://code.google.com/p/ibus/", "", "ibus-array"); ibus_component_add_engine (component, ibus_engine_desc_new ("array", "Array 30 Input Method", "Array 30 Input Method", "zh_TW", "GPL", "Yu-Chun Wang <*****@*****.**>", PKGDATADIR"/icon/ibus-array.png", "us")); factory = ibus_factory_new (ibus_bus_get_connection (bus)); ibus_factory_add_engine (factory, "array", IBUS_TYPE_ARRAY_ENGINE); if (ibus) { ibus_bus_request_name (bus, "org.freedesktop.IBus.Array", 0); } else { ibus_bus_register_component (bus, component); } g_object_unref (component); }
App::App(int argc, char** argv): QGuiApplication(argc, argv) ,m_eventFilter(new XcbEventFilter) ,m_init(false) ,m_bus(0) ,m_impanel(0) ,m_keyboardGrabbed(false) ,m_doGrab(false) ,m_syms(0) { m_syms = xcb_key_symbols_alloc(QX11Info::connection()); installNativeEventFilter(m_eventFilter.data()); ibus_init (); m_bus = ibus_bus_new (); g_signal_connect (m_bus, "connected", G_CALLBACK (ibus_connected_cb), this); g_signal_connect (m_bus, "disconnected", G_CALLBACK (ibus_disconnected_cb), this); if (ibus_bus_is_connected (m_bus)) { init(); } initIconMap(m_iconMap); }
GtkWidget* unikey_main_setup_dialog_new() { GtkBuilder* builder; IBusBus* bus; GtkDialog* dlgMain; ibus_init(); bus = ibus_bus_new(); g_signal_connect(bus, "disconnected", G_CALLBACK(gtk_main_quit), NULL); config = ibus_bus_get_config(bus); builder = gtk_builder_new(); gtk_builder_add_from_file(builder, UI_DATA_DIR "/setup-main.ui", NULL); dlgMain = GTK_DIALOG(gtk_builder_get_object(builder, "dlg_main_setup")); init_dialog_controls(builder); g_object_unref(builder); return GTK_WIDGET(dlgMain); }
static void init_inside() { IBusComponent *component; ibus_init(); bus = ibus_bus_new(); g_signal_connect (bus, "disconnected", G_CALLBACK (ibus_disconnected_cb), NULL); factory = ibus_factory_new(ibus_bus_get_connection(bus)); ibus_bus_request_name(bus, "org.freedesktop.IBus.handwrite", 0); component = ibus_component_new("org.freedesktop.IBus.handwrite", "handwrite", PACKAGE_VERSION, "GPL", MICROCAI_WITHEMAIL, PACKAGE_BUGREPORT, PKGDATADIR, GETTEXT_PACKAGE); ibus_bus_register_component(bus, component); ibus_factory_add_engine(factory, "handwrite", IBUS_TYPE_HANDWRITE_ENGINE); g_object_unref(component); }
static void start_component (void) { GList* engines; GList* p; IBusComponent* component; ibus_init (); UnikeySetup (); bus = ibus_bus_new (); g_signal_connect (bus, "disconnected", G_CALLBACK(ibus_disconnected_cb), NULL); component = ibus_unikey_get_component (); factory = ibus_factory_new (ibus_bus_get_connection (bus)); engines = ibus_component_get_engines (component); for (p = engines; p != NULL; p = p->next) { IBusEngineDesc* engine = (IBusEngineDesc*)p->data; #if IBUS_CHECK_VERSION(1,3,99) ibus_factory_add_engine (factory, ibus_engine_desc_get_name(engine), IBUS_TYPE_UNIKEY_ENGINE); #else ibus_factory_add_engine (factory, engine->name, IBUS_TYPE_UNIKEY_ENGINE); #endif } if (ibus) ibus_bus_request_name (bus, "org.freedesktop.IBus.Unikey", 0); else ibus_bus_register_component (bus, component); g_object_unref (component); ibus_unikey_init (bus); ibus_main (); ibus_unikey_exit (); }
void setup_input_tabs (GtkBuilder *builder, GisKeyboardPage *page) { GtkWidget *treeview; GtkTreeViewColumn *column; GtkCellRenderer *cell; GtkListStore *store; GtkTreeSelection *selection; /* set up the list of active inputs */ treeview = WID("active_input_sources"); column = gtk_tree_view_column_new (); cell = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (column, cell, TRUE); gtk_tree_view_column_add_attribute (column, cell, "text", NAME_COLUMN); gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column); store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_DESKTOP_APP_INFO); gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), GTK_TREE_MODEL (store)); input_sources_settings = g_settings_new (GNOME_DESKTOP_INPUT_SOURCES_DIR); g_settings_delay (input_sources_settings); g_object_weak_ref (G_OBJECT (builder), (GWeakNotify) g_object_unref, input_sources_settings); if (!xkb_info) xkb_info = gnome_xkb_info_new (); #ifdef HAVE_IBUS ibus_init (); if (!ibus) { ibus = ibus_bus_new_async (); if (ibus_bus_is_connected (ibus)) fetch_ibus_engines (builder); else g_signal_connect_swapped (ibus, "connected", G_CALLBACK (fetch_ibus_engines), builder); g_object_weak_ref (G_OBJECT (builder), (GWeakNotify) clear_ibus, NULL); } maybe_start_ibus (); #endif populate_with_active_sources (store); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)); g_signal_connect_swapped (selection, "changed", G_CALLBACK (update_button_sensitivity), builder); /* set up the buttons */ g_signal_connect (WID("input_source_add"), "clicked", G_CALLBACK (add_input), builder); g_signal_connect (WID("input_source_remove"), "clicked", G_CALLBACK (remove_selected_input), builder); g_signal_connect (WID("input_source_move_up"), "clicked", G_CALLBACK (move_selected_input_up), builder); g_signal_connect (WID("input_source_move_down"), "clicked", G_CALLBACK (move_selected_input_down), builder); g_signal_connect (WID("input_source_show"), "clicked", G_CALLBACK (show_selected_layout), builder); g_signal_connect (WID("input_source_settings"), "clicked", G_CALLBACK (show_selected_settings), builder); /* use an em dash is no shortcut */ update_shortcuts (builder); /* g_signal_connect (WID("jump-to-shortcuts"), "activate-link", G_CALLBACK (go_to_shortcuts), page);*/ g_signal_connect (G_OBJECT (input_sources_settings), "changed::" KEY_INPUT_SOURCES, G_CALLBACK (input_sources_changed), builder); }
int main(int argc, char* argv[]) { IBusComponent *component; IBusEngineDesc * desc; GError * err = NULL; gboolean have_ibus=FALSE; const gchar * language="zh"; const gchar * icon_dir = NULL; const gchar * locale_dir = NULL; setlocale(LC_ALL, ""); gtk_set_locale(); textdomain(GETTEXT_PACKAGE); GOptionEntry args[] = { {"ibus",'\0',0,G_OPTION_ARG_NONE,&have_ibus}, {"icondir",'\0',0,G_OPTION_ARG_STRING,&icon_dir,_("the icon file"),N_("icon file")}, {"table",'\0',0,G_OPTION_ARG_STRING,&tablefile,_("set table file path"),N_("tablefile")}, {"locale",'\0',0,G_OPTION_ARG_STRING,&locale_dir,_("set locale path"),N_("locale")}, #ifdef WITH_ZINNIA {"lang",'\0',0,G_OPTION_ARG_STRING,&language,_("set languate, accept zh and jp"),N_("lang")}, #endif {0} }; gtk_init_with_args(&argc,&argv,PACKAGE_NAME,args,PACKAGE_NAME,&err); if(G_UNLIKELY(!gtk_gl_init_check(&argc, &argv))) { g_warning("GLX extension not available, use slow soft cairo rendering instead"); } #ifdef WITH_ZINNIA if(strcmp(language,"zh")==0 ||strcmp(language,"zh_CN") ==0 ) { }else if( strcmp(language,"jp") ==0 || strcmp(language,"ja")==0 ) { g_strlcpy(lang,"ja",20); }else { g_error("pass jp or zh to --lang!"); } #endif if(locale_dir) { bindtextdomain(GETTEXT_PACKAGE,locale_dir); } gchar * engine_name = g_strdup_printf("handwrite-%s",lang); gchar * dbus_name = g_strdup_printf("org.freedesktop.IBus.handwrite-%s",lang); ibus_init(); if(icon_dir) realpath(icon_dir, icondir); bus = ibus_bus_new(); g_signal_connect (bus, "disconnected", G_CALLBACK (gtk_main_quit), NULL); factory = ibus_factory_new(ibus_bus_get_connection(bus)); ibus_bus_request_name(bus, dbus_name, 0); // g_free(dbus_name); if (!have_ibus) { char * exefile ; exefile = realpath(argv[0],NULL); component = ibus_component_new(dbus_name, "handwrite", PACKAGE_VERSION, "GPL", MICROCAI_WITHEMAIL, PACKAGE_BUGREPORT, exefile, GETTEXT_PACKAGE); gchar * iconfile = g_strdup_printf("%s/ibus-handwrite.svg",icondir); desc = ibus_engine_desc_new(engine_name, "handwrite", _("hand write recognizer"), lang, "GPL", MICROCAI_WITHEMAIL, iconfile, "us"); ibus_component_add_engine(component, desc); free(exefile); g_free(iconfile); }else { component = ibus_component_new(dbus_name, "handwrite", PACKAGE_VERSION, "GPL", MICROCAI_WITHEMAIL, PACKAGE_BUGREPORT, PKGDATADIR, GETTEXT_PACKAGE); } g_free(dbus_name); ibus_bus_register_component(bus, component); ibus_factory_add_engine(factory, engine_name, IBUS_TYPE_HANDWRITE_ENGINE); g_free(engine_name); g_object_unref(component); GdkScreen * screen = gdk_screen_get_default(); GdkColormap * map = gdk_screen_get_rgba_colormap(screen); if(map) gtk_widget_set_default_colormap(map); printf(_("ibus-handwrite Version %s Start Up\n"), PACKAGE_VERSION); gtk_main(); return 0; }
static void ibus_impanel_start (void) { ibus_init (); bus = ibus_bus_new (); if (!ibus_bus_is_connected (bus)) { exit (-1); } g_signal_connect (bus, "disconnected", G_CALLBACK (ibus_disconnected_cb), NULL); impanel = ibus_panel_impanel_new (ibus_bus_get_connection (bus)); ibus_bus_request_name (bus, IBUS_SERVICE_PANEL, 0); ibus_panel_impanel_set_bus(impanel, bus); #if !IBUS_CHECK_VERSION(1,4,99) ibus_main (); #else Display* dpy = XOpenDisplay(0); Window root = DefaultRootWindow(dpy); XEvent ev; unsigned int modifiers = ControlMask; int keycode = XKeysymToKeycode(dpy, XK_space); XGrabKey(dpy, keycode, modifiers, root, False, GrabModeAsync, GrabModeAsync); XGrabKey(dpy, keycode, modifiers | LockMask, root, False, GrabModeAsync, GrabModeAsync); // capslock XGrabKey(dpy, keycode, modifiers | Mod2Mask, root, False, GrabModeAsync, GrabModeAsync); // numlock XGrabKey(dpy, keycode, modifiers | LockMask | Mod2Mask, root, False, GrabModeAsync, GrabModeAsync); XSelectInput(dpy, root, KeyPressMask); // XCloseDisplay(dpy); main_loop = g_main_loop_new(NULL, FALSE); int dpyfd = ConnectionNumber(dpy); GPollFD dpy_pollfd = {dpyfd, G_IO_IN | G_IO_HUP | G_IO_ERR, 0}; GSourceFuncs x11_source_funcs = { x11_fd_prepare, x11_fd_check, x11_fd_dispatch, NULL, /* finalize */ NULL, /* closure_callback */ NULL /* closure_marshal */ }; GSource *x11_source = g_source_new(&x11_source_funcs, sizeof(x11_source_t)); ((x11_source_t*)x11_source)->dpy = dpy; g_source_add_poll(x11_source, &dpy_pollfd); g_source_set_can_recurse(x11_source, TRUE); g_source_attach(x11_source, NULL); g_main_loop_run (main_loop); g_main_loop_unref (main_loop); main_loop = NULL; XUngrabKey(dpy, keycode, modifiers, root); XUngrabKey(dpy, keycode, modifiers | LockMask, root); XUngrabKey(dpy, keycode, modifiers | Mod2Mask, root); XUngrabKey(dpy, keycode, modifiers | LockMask | Mod2Mask, root); XCloseDisplay(dpy); #endif }
gint main (gint argc, gchar **argv) { setlocale (LC_ALL, ""); GOptionContext *context = g_option_context_new ("- ibus daemon"); g_option_context_add_main_entries (context, entries, "ibus-daemon"); g_argv = g_strdupv (argv); GError *error = NULL; if (!g_option_context_parse (context, &argc, &argv, &error)) { g_printerr ("Option parsing failed: %s\n", error->message); g_error_free (error); exit (-1); } if (g_gdbus_timeout < -1) { g_printerr ("Bad timeout (must be >= -1): %d\n", g_gdbus_timeout); exit (-1); } if (g_mempro) { g_mem_set_vtable (glib_mem_profiler_table); signal (SIGUSR2, _sig_usr2_handler); } /* check uid */ { const gchar *username = ibus_get_user_name (); uid_t uid = getuid (); struct passwd *pwd = getpwuid (uid); if (pwd == NULL || g_strcmp0 (pwd->pw_name, username) != 0) { g_printerr ("Please run ibus-daemon with login user! Do not run ibus-daemon with sudo or su.\n"); exit (-1); } } /* daemonize process */ if (daemonize) { if (daemon (1, 0) != 0) { g_printerr ("Can not daemonize ibus.\n"); exit (-1); } } /* create a new process group. this is important to kill all of its children by SIGTERM at a time in bus_ibus_impl_destroy. */ setpgid (0, 0); ibus_init (); ibus_set_log_handler (g_verbose); /* check if ibus-daemon is running in this session */ if (ibus_get_address () != NULL) { IBusBus *bus = ibus_bus_new (); if (ibus_bus_is_connected (bus)) { if (!replace) { g_printerr ("current session already has an ibus-daemon.\n"); exit (-1); } ibus_bus_exit (bus, FALSE); while (ibus_bus_is_connected (bus)) { g_main_context_iteration (NULL, TRUE); } } g_object_unref (bus); } bus_server_init (); if (!single) { /* execute config component */ if (g_strcmp0 (config, "default") == 0) { BusComponent *component; component = bus_ibus_impl_lookup_component_by_name ( BUS_DEFAULT_IBUS, IBUS_SERVICE_CONFIG); if (component) { bus_component_set_restart (component, restart); } if (component == NULL || !bus_component_start (component, g_verbose)) { g_printerr ("Can not execute default config program\n"); exit (-1); } } else if (g_strcmp0 (config, "disable") != 0 && g_strcmp0 (config, "") != 0) { if (!execute_cmdline (config)) exit (-1); } /* execute panel component */ if (g_strcmp0 (panel, "default") == 0) { BusComponent *component; component = bus_ibus_impl_lookup_component_by_name ( BUS_DEFAULT_IBUS, IBUS_SERVICE_PANEL); if (component) { bus_component_set_restart (component, restart); } if (component == NULL || !bus_component_start (component, g_verbose)) { g_printerr ("Can not execute default panel program\n"); exit (-1); } } else if (g_strcmp0 (panel, "disable") != 0 && g_strcmp0 (panel, "") != 0) { if (!execute_cmdline (panel)) exit (-1); } } /* execute ibus xim server */ if (xim) { if (!execute_cmdline (LIBEXECDIR "/ibus-x11 --kill-daemon")) exit (-1); } bus_server_run (); return 0; }
int main(int argc, char **argv) { int opt; bool bluetooth = FALSE; bool mk3 = TRUE; bool camera = TRUE; int hw_version = 0; int gpio_number = 18; const char *port = "/dev/ttyAMA0"; char *startup = NULL; int cdcinterval = 0; bool gpio_changed = FALSE; mainloop_init(); while ((opt = getopt(argc, argv, "c:g:s:v:bhmr")) != -1) { switch (opt) { case 'b': bluetooth = 1; break; case 'c': cdcinterval = atoi(optarg); break; case 'g': gpio_number = atoi(optarg); gpio_changed = TRUE; break; case 'm': mk3 = 0; break; case 'r': camera = 0; break; case 's': startup = strdup(optarg); break; case 'v': hw_version = atoi(optarg); break; case 'h': default: fprintf(stderr, "Usage: %s [flags] [serial-port]\n" "\n" "Flags:\n" "\t-b Car has bluetooth, don't use Phone and Speak buttons\n" "\t-c <time> Force CDC-info replies every <time> seconds\n" "\t-g <number> GPIO number to use for IBUS line monitor (0 = Use TH3122)\n" "\t-m Do not do MK3 style CDC announcements\n" "\t-r Do not switch to camera in reverse gear\n" "\t-s <string> Send extra string to IBUS at startup\n" "\t-v <number> Set PiBUS hardware version\n" "\n", argv[0]); return -1; } } if (argc > optind) { port = argv[optind]; } if (!gpio_changed && hw_version >= 4) { gpio_number = 17; } if (gpio_init() != 0) { fprintf(stderr, "Can't init gpio\r\n"); return -4; } if (ibus_init(port, startup, bluetooth, camera, mk3, cdcinterval, gpio_number, hw_version) != 0) { return -2; } if (keyboard_init() != 0) { fprintf(stderr, "Can't open keyboard\r\n"); return -3; } mainloop(); gpio_cleanup(); ibus_cleanup(); keyboard_cleanup(); return 0; }