int main(int argc, char **argv) { GOptionContext *context; GMainLoop *loop; GError *err = NULL; DBusGProxy *dev; char *username; g_type_init(); dbus_g_object_register_marshaller (fprintd_marshal_VOID__STRING_BOOLEAN, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INVALID); context = g_option_context_new ("Verify a fingerprint"); g_option_context_add_main_entries (context, entries, NULL); if (g_option_context_parse (context, &argc, &argv, &err) == FALSE) { g_print ("couldn't parse command-line options: %s\n", err->message); g_error_free (err); return 1; } if (usernames == NULL) { username = ""; } else { username = usernames[0]; } if (g_fatal_warnings) { GLogLevelFlags fatal_mask; fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK); fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL; g_log_set_always_fatal (fatal_mask); } loop = g_main_loop_new(NULL, FALSE); create_manager(); dev = open_device(username); find_finger(dev, username); do_verify(dev); release_device(dev); return 0; }
void HREinitPopt(){ option_man=create_manager(16); ADD_ARRAY(option_man,option_group,struct poptOption); struct poptOption null_opt=POPT_TABLEEND; ensure_access(option_man,0); option_group[0]=null_opt; }
static void on_bus_acquired (GDBusConnection *connection, const char *name, gpointer data) { create_manager (); }
void view::init_meteo_manager() { cg::range_2 const& lat = settings_.lat_bounds; cg::range_2 const& lon = settings_.lon_bounds; double const num_points = 4096.; if (lat.empty() || lon.empty()) return; else { double step = 0.015; int lat_pnts = int(lat.size() / step); int lon_pnts = int(lon.size() / step); if (lat_pnts * lon_pnts > num_points) { double dec = cg::sqrt((lat_pnts * lon_pnts) / num_points); lat_pnts = lat_pnts / dec + 1; lon_pnts = lon_pnts / dec + 1; step = lat.size() / lat_pnts; } if (!mgr_) { mgr_ = create_manager(cg::geo_point_2(lat.lo(), lon.lo()), cg::geo_point_2(step, step), cg::point_2i(lat_pnts, lon_pnts)); mgr_proxy_ = mgr_->get_proxy(); mgr_cursor_ = mgr_proxy_->create_cursor(); } else mgr_->resize(cg::geo_point_2(lat.lo(), lon.lo()), cg::geo_point_2(step, step), cg::point_2i(lat_pnts, lon_pnts)); } }
/* 功能: 初始化线程池,创建最少的线程数 * 参数: * 返回值: 成功返回true,失败返回false */ bool ThreadPool::init(){ if(initialed) return true; /* 创建num个线程 */ if(!create_thread(num_min_t)) return false; if(manager_flag) if(!create_manager()) cout<<" craete manager failed! "<<endl; initialed = true; return true; }
gboolean set_fingerprint_label (GtkWidget *label1, GtkWidget *label2) { GDBusProxy *device; GVariant *result; GVariantIter *fingers; GError *error = NULL; if (manager == NULL) { create_manager (); if (manager == NULL) { return FALSE; } } device = get_first_device (); if (device == NULL) return FALSE; result = g_dbus_proxy_call_sync (device, "ListEnrolledFingers", g_variant_new ("(s)", ""), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if (!result) { if (!g_dbus_error_is_remote_error (error) || strcmp (g_dbus_error_get_remote_error(error), "net.reactivated.Fprint.Error.NoEnrolledPrints") != 0) { g_object_unref (device); return FALSE; } } if (result && g_variant_is_of_type (result, G_VARIANT_TYPE ("(as)"))) g_variant_get (result, "(as)", &fingers); else fingers = NULL; if (fingers == NULL || g_variant_iter_n_children (fingers) == 0) { is_disable = FALSE; gtk_label_set_text (GTK_LABEL (label1), _("Disabled")); gtk_label_set_text (GTK_LABEL (label2), _("Disabled")); } else { is_disable = TRUE; gtk_label_set_text (GTK_LABEL (label1), _("Enabled")); gtk_label_set_text (GTK_LABEL (label2), _("Enabled")); } if (result != NULL) g_variant_unref (result); if (fingers != NULL) g_variant_iter_free (fingers); g_object_unref (device); return TRUE; }
void set_fingerprint_label (GtkWidget *enable, GtkWidget *disable) { char **fingers; DBusGProxy *device; GError *error = NULL; gtk_widget_set_no_show_all (enable, TRUE); gtk_widget_set_no_show_all (disable, TRUE); if (manager == NULL) { create_manager (); if (manager == NULL) { gtk_widget_hide (enable); gtk_widget_hide (disable); return; } } device = get_first_device (); if (device == NULL) { gtk_widget_hide (enable); gtk_widget_hide (disable); return; } if (!dbus_g_proxy_call (device, "ListEnrolledFingers", &error, G_TYPE_STRING, "", G_TYPE_INVALID, G_TYPE_STRV, &fingers, G_TYPE_INVALID)) { if (dbus_g_error_has_name (error, "net.reactivated.Fprint.Error.NoEnrolledPrints") == FALSE) { gtk_widget_hide (enable); gtk_widget_hide (disable); g_object_unref (device); return; } fingers = NULL; } if (fingers == NULL || g_strv_length (fingers) == 0) { gtk_widget_hide (disable); gtk_widget_show (enable); is_disable = FALSE; } else { gtk_widget_hide (enable); gtk_widget_show (disable); is_disable = TRUE; } g_strfreev (fingers); g_object_unref (device); }
int main(int argc, char **argv) { g_type_init(); create_manager(); if (argc < 2) { g_print ("Usage: %s <username> [usernames...]\n", argv[0]); return 1; } process_devices (argv); return 0; }
event_queue_t event_queue(){ event_queue_t queue=(event_queue_t)HREmalloc(NULL,sizeof(struct event_queue_s)); queue->man=create_manager(1024); queue->request=NULL; ADD_ARRAY(queue->man,queue->request,MPI_Request); queue->cb=NULL; ADD_ARRAY(queue->man,queue->cb,event_callback); queue->context=NULL; ADD_ARRAY(queue->man,queue->context,void*); queue->pending=0; queue->wait_some_calls=0; queue->wait_some_multi=0; queue->test_some_calls=0; queue->test_some_none=0; queue->test_some_multi=0; return queue; }
int main(int argc, char **argv) { GMainLoop *loop; g_type_init(); loop = g_main_loop_new(NULL, FALSE); create_manager(); if (argc < 2) { g_print ("Usage: %s <username> [usernames...]\n", argv[0]); return 1; } process_devices (argv); return 0; }
static void delete_fingerprints (void) { DBusGProxy *device; if (manager == NULL) { create_manager (); if (manager == NULL) return; } device = get_first_device (); if (device == NULL) return; dbus_g_proxy_call (device, "DeleteEnrolledFingers", NULL, G_TYPE_STRING, "", G_TYPE_INVALID, G_TYPE_INVALID); g_object_unref (device); }
string_index_t SIcreate(){ int i; string_index_t si; si=(string_index_t)RTmallocZero(sizeof(struct stringindex)); si->count=0; si->free_list=END_OF_LIST; si->man=create_manager(DATA_BLOCK_SIZE); //si->next=(int*)RTmalloc(DATA_BLOCK_SIZE*sizeof(int)); ADD_ARRAY_CB(si->man,si->next,int,next_resize,NULL); //si->len=(int*)RTmalloc(DATA_BLOCK_SIZE*sizeof(int)); ADD_ARRAY_CB(si->man,si->len,int,len_resize,si); //si->data=(char**)RTmalloc(DATA_BLOCK_SIZE*sizeof(char*)); ADD_ARRAY(si->man,si->data,char*); //create_free_list(si); si->table=(int*)RTmalloc((TABLE_INITIAL+1)*sizeof(int)); si->mask=TABLE_INITIAL; for(i=0;i<=TABLE_INITIAL;i++){ si->table[i]=END_OF_LIST; } return si; };
static void delete_fingerprints (void) { GDBusProxy *device; GVariant *result; if (manager == NULL) { create_manager (); if (manager == NULL) return; } device = get_first_device (); if (device == NULL) return; result = g_dbus_proxy_call_sync (device, "DeleteEnrolledFingers", g_variant_new ("(s)", ""), G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL); if (result) g_variant_unref (result); g_object_unref (device); }
MSSndCardManager * ms_snd_card_manager_get(void){ if (scm==NULL) scm=create_manager(); return scm; }
MSWebCamManager * ms_web_cam_manager_get(void){ if (scm==NULL) scm=create_manager(); return scm; }
static void enroll_fingerprints (GtkWindow *parent, GtkWidget *label1, GtkWidget *label2, UmUser *user) { GDBusProxy *device; GtkBuilder *dialog; EnrollData *data; GtkWidget *ass; const char *filename; char *msg; GVariant *result; GError *error = NULL; device = NULL; if (manager == NULL) { create_manager (); if (manager != NULL) device = get_first_device (); } else { device = get_first_device (); } if (manager == NULL || device == NULL) { GtkWidget *d; d = get_error_dialog (_("Could not access any fingerprint readers"), _("Please contact your system administrator for help."), parent); gtk_dialog_run (GTK_DIALOG (d)); gtk_widget_destroy (d); return; } data = g_new0 (EnrollData, 1); data->device = device; data->label1 = label1; data->label2 = label2; /* Get some details about the device */ result = g_dbus_connection_call_sync (connection, "net.reactivated.Fprint", g_dbus_proxy_get_object_path (data->device), "org.freedesktop.DBus.Properties", "GetAll", g_variant_new ("(s)", "net.reactivated.Fprint.Device"), G_VARIANT_TYPE ("(a{sv})"), G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL); if (result) { GVariant *props; gchar *scan_type; g_variant_get (result, "(@a{sv})", &props); g_variant_lookup (props, "name", "s", &data->name); g_variant_lookup (props, "scan-type", "s", &scan_type); if (g_strcmp0 (scan_type, "swipe") == 0) data->is_swipe = TRUE; g_free (scan_type); g_variant_unref (props); g_variant_unref (result); } dialog = gtk_builder_new (); filename = UIDIR "/account-fingerprint.ui"; if (!g_file_test (filename, G_FILE_TEST_EXISTS)) filename = "data/account-fingerprint.ui"; if (!gtk_builder_add_from_file (dialog, filename, &error)) { g_error ("%s", error->message); g_error_free (error); return; } data->dialog = dialog; ass = WID ("assistant"); gtk_window_set_title (GTK_WINDOW (ass), _("Enable Fingerprint Login")); gtk_window_set_transient_for (GTK_WINDOW (ass), parent); gtk_window_set_modal (GTK_WINDOW (ass), TRUE); gtk_window_set_resizable (GTK_WINDOW (ass), FALSE); gtk_window_set_type_hint (GTK_WINDOW (ass), GDK_WINDOW_TYPE_HINT_DIALOG); g_signal_connect (G_OBJECT (ass), "cancel", G_CALLBACK (assistant_cancelled), data); g_signal_connect (G_OBJECT (ass), "close", G_CALLBACK (assistant_cancelled), data); g_signal_connect (G_OBJECT (ass), "prepare", G_CALLBACK (assistant_prepare), data); /* Page 1 */ gtk_combo_box_set_active (GTK_COMBO_BOX (WID ("finger_combobox")), 0); g_signal_connect (G_OBJECT (WID ("radiobutton1")), "toggled", G_CALLBACK (finger_radio_button_toggled), data); g_signal_connect (G_OBJECT (WID ("radiobutton2")), "toggled", G_CALLBACK (finger_radio_button_toggled), data); g_signal_connect (G_OBJECT (WID ("radiobutton3")), "toggled", G_CALLBACK (finger_radio_button_toggled), data); g_signal_connect (G_OBJECT (WID ("finger_combobox")), "changed", G_CALLBACK (finger_combobox_changed), data); data->finger = selected_finger (dialog); g_object_set_data (G_OBJECT (WID("page1")), "name", "intro"); /* translators: * The variable is the name of the device, for example: * "To enable fingerprint login, you need to save one of your fingerprints, using the * 'Digital Persona U.are.U 4000/4000B' device." */ msg = g_strdup_printf (_("To enable fingerprint login, you need to save one of your fingerprints, using the '%s' device."), data->name); gtk_label_set_text (GTK_LABEL (WID("intro-label")), msg); g_free (msg); gtk_assistant_set_page_complete (GTK_ASSISTANT (ass), WID("page1"), TRUE); gtk_assistant_set_page_title (GTK_ASSISTANT (ass), WID("page1"), _("Selecting finger")); gtk_assistant_set_page_title (GTK_ASSISTANT (ass), WID("page2"), _("Enrolling fingerprints")); gtk_assistant_set_page_title (GTK_ASSISTANT (ass), WID("page3"), _("Summary")); /* Page 2 */ g_object_set_data (G_OBJECT (WID("page2")), "name", "enroll"); msg = g_strdup_printf (TR(finger_str_to_msg (data->finger, data->is_swipe)), data->name); gtk_label_set_text (GTK_LABEL (WID("enroll-label")), msg); g_free (msg); /* Page 3 */ g_object_set_data (G_OBJECT (WID("page3")), "name", "summary"); data->ass = ass; gtk_widget_show_all (ass); }
static void enroll_fingerprints (GtkWindow *parent, GtkWidget *enable, GtkWidget *disable) { DBusGProxy *device, *p; GHashTable *props; GtkBuilder *dialog; EnrollData *data; GtkWidget *ass; char *msg; device = NULL; if (manager == NULL) { create_manager (); if (manager != NULL) device = get_first_device (); } else { device = get_first_device (); } if (manager == NULL || device == NULL) { GtkWidget *d; d = get_error_dialog (_("Could not access any fingerprint readers"), _("Please contact your system administrator for help."), parent); gtk_dialog_run (GTK_DIALOG (d)); gtk_widget_destroy (d); return; } data = g_new0 (EnrollData, 1); data->device = device; data->enable = enable; data->disable = disable; /* Get some details about the device */ p = dbus_g_proxy_new_from_proxy (device, "org.freedesktop.DBus.Properties", NULL); if (dbus_g_proxy_call (p, "GetAll", NULL, G_TYPE_STRING, "net.reactivated.Fprint.Device", G_TYPE_INVALID, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), &props, G_TYPE_INVALID)) { const char *scan_type; data->name = g_value_dup_string (g_hash_table_lookup (props, "name")); scan_type = g_value_dup_string (g_hash_table_lookup (props, "scan-type")); if (g_str_equal (scan_type, "swipe")) data->is_swipe = TRUE; g_hash_table_destroy (props); } g_object_unref (p); dialog = gtk_builder_new (); gtk_builder_add_from_file (dialog, MATECC_UI_DIR "/mate-about-me-fingerprint.ui", NULL); data->dialog = dialog; ass = WID ("assistant"); gtk_window_set_title (GTK_WINDOW (ass), _("Enable Fingerprint Login")); gtk_window_set_transient_for (GTK_WINDOW (ass), parent); gtk_window_set_position (GTK_WINDOW (ass), GTK_WIN_POS_CENTER_ON_PARENT); g_signal_connect (G_OBJECT (ass), "cancel", G_CALLBACK (assistant_cancelled), data); g_signal_connect (G_OBJECT (ass), "close", G_CALLBACK (assistant_cancelled), data); g_signal_connect (G_OBJECT (ass), "prepare", G_CALLBACK (assistant_prepare), data); /* Page 1 */ gtk_combo_box_set_active (GTK_COMBO_BOX (WID ("finger_combobox")), 0); g_signal_connect (G_OBJECT (WID ("radiobutton1")), "toggled", G_CALLBACK (finger_radio_button_toggled), data); g_signal_connect (G_OBJECT (WID ("radiobutton2")), "toggled", G_CALLBACK (finger_radio_button_toggled), data); g_signal_connect (G_OBJECT (WID ("radiobutton3")), "toggled", G_CALLBACK (finger_radio_button_toggled), data); g_signal_connect (G_OBJECT (WID ("finger_combobox")), "changed", G_CALLBACK (finger_combobox_changed), data); data->finger = selected_finger (dialog); g_object_set_data (G_OBJECT (WID("page1")), "name", "intro"); /* translators: * The variable is the name of the device, for example: * "To enable fingerprint login, you need to save one of your fingerprints, using the * 'Digital Persona U.are.U 4000/4000B' device." */ msg = g_strdup_printf (_("To enable fingerprint login, you need to save one of your fingerprints, using the '%s' device."), data->name); gtk_label_set_text (GTK_LABEL (WID("intro-label")), msg); g_free (msg); gtk_assistant_set_page_complete (GTK_ASSISTANT (ass), WID("page1"), TRUE); /* Page 2 */ if (data->is_swipe != FALSE) gtk_assistant_set_page_title (GTK_ASSISTANT (ass), WID("page2"), _("Swipe finger on reader")); else gtk_assistant_set_page_title (GTK_ASSISTANT (ass), WID("page2"), _("Place finger on reader")); g_object_set_data (G_OBJECT (WID("page2")), "name", "enroll"); msg = g_strdup_printf (TR(finger_str_to_msg (data->finger, data->is_swipe)), data->name); gtk_label_set_text (GTK_LABEL (WID("enroll-label")), msg); g_free (msg); /* Page 3 */ g_object_set_data (G_OBJECT (WID("page3")), "name", "summary"); data->ass = ass; gtk_widget_show_all (ass); }