int main(int argc, char *argv[]) { UniqueApp *app; GtkWidget *window; GtkWidget *notebook; GError *error = NULL; bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); if (gtk_init_with_args(&argc, &argv, NULL, options, GETTEXT_PACKAGE, &error) == FALSE) { if (error) { g_print("%s\n", error->message); g_error_free(error); } else g_print("An unknown error occurred\n"); return 1; } if (option_dump != FALSE) { dump_devices (); return 0; } app = unique_app_new ("org.mate.Bluetooth.properties", NULL); if (unique_app_is_running (app)) { gdk_notify_startup_complete (); unique_app_send_message (app, UNIQUE_ACTIVATE, NULL); return 0; } g_set_application_name(_("Bluetooth Properties")); gtk_window_set_default_icon_name("bluetooth"); bluetooth_plugin_manager_init (); notebook = gtk_notebook_new(); gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE); setup_adapter(GTK_NOTEBOOK(notebook)); window = create_window(notebook); g_signal_connect (app, "message-received", G_CALLBACK (message_received_cb), window); gtk_main(); bluetooth_plugin_manager_cleanup (); cleanup_adapter(); g_object_unref(app); return 0; }
int main(int argc, char **argv) { int c, err = 0; while ((c = getopt(argc, argv, "v")) != EOF) { switch (c) { case 'v': verblevel++; break; case '?': default: err++; break; } } if (err || argc > optind) { fprintf(stderr, "Usage: lsiio [options]...\n" "List industrial I/O devices\n" " -v Increase verbosity (may be given multiple times)\n"); exit(1); } return dump_devices(); }
void move_daemon::handle_disconnect(const char *path) { std::vector<psmove_dev *>::iterator it; for (it = devs.begin(); it != devs.end(); ++it) { const char *dev_path = _psmove_get_device_path((*it)->move); if (strcmp(path, dev_path) == 0) { delete (*it); it = devs.erase(it); break; } } dump_devices(); }
int main(int argc, char **argv) { DBusError error; DBusConnection *conn; LibHalContext *hal_ctx; int i, err; opterr = 0; opt.list = 1; while ((i = getopt_long(argc, argv, "a:hr:", options, NULL)) != -1) { switch (i) { case 'a': opt.add = 1; opt.list = 0; opt.udi = optarg; break; case 'r': opt.remove = 1; opt.list = 0; opt.udi = optarg; break; case 'h': help(); return 0; default: help(); return 1; } } dbus_error_init(&error); if (!(conn = dbus_bus_get(DBUS_BUS_SYSTEM, &error))) { fprintf(stderr, "error: dbus_bus_get: %s: %s\n", error.name, error.message); LIBHAL_FREE_DBUS_ERROR (&error); return 2; } /* fprintf(stderr, "connected to: %s\n", dbus_bus_get_unique_name(conn)); */ if (!(hal_ctx = libhal_ctx_new())) return 3; if (!libhal_ctx_set_dbus_connection(hal_ctx, conn)) return 4; if (!libhal_ctx_init(hal_ctx, &error)) { if (dbus_error_is_set(&error)) { fprintf (stderr, "error: libhal_ctx_init: %s: %s\n", error.name, error.message); LIBHAL_FREE_DBUS_ERROR (&error); } fprintf (stderr, "Could not initialise connection to hald.\n" "Normally this means the HAL daemon (hald) is not running or not ready.\n"); return 5; } err = 0; if (opt.list) err = dump_devices(hal_ctx, argv[optind]); else if (opt.remove) err = remove_udi(hal_ctx, opt.udi); else if (opt.add) err = add_udi(hal_ctx, opt.udi); else err = 6; libhal_ctx_shutdown(hal_ctx, &error); libhal_ctx_free(hal_ctx); dbus_connection_unref(conn); dbus_error_free(&error); return err; }
void move_daemon::handle_connection(const char *path, const wchar_t *serial) { devs.push_back(new psmove_dev(this, path, serial)); dump_devices(); }