Beispiel #1
0
static
gboolean recognized_handler(gpointer data)
{
    g_debug("[%s] recognized", __func__);
    js_post_signal("start-login");
    recognition_info.reco_state = RECOGNIZE_FINISH;
    return G_SOURCE_REMOVE;
}
Beispiel #2
0
JS_EXPORT_API
void dock_toggle_launcher(gboolean show)
{
    if (show) {
        run_command("dde-launcher");
    } else {
        dbus_launcher_hide();
        js_post_signal("launcher_destroy");
    }
}
Beispiel #3
0
JS_EXPORT_API
void installer_emit_webview_ok ()
{
    static gboolean inited = FALSE;
    if (!inited) {
        inited = TRUE;

        if (nowm){
            js_post_signal("without_wm");
        }

        if (is_virtual_pc()){
            js_post_signal("is_virtual_machine");
        }

        if (auto_conf_path == NULL) {
            init_parted ();
        }else{
            js_post_signal("auto_mode");
        }

    }
}
Beispiel #4
0
static gboolean _frame_handler(GstElement *img, GstBuffer *buffer, gpointer data)
{
    static gboolean inited = FALSE;
    static gboolean sended = FALSE;

    if (!inited) {
        g_timer_start(recognition_info.timer);
        inited = TRUE;
    }

    if (frame == NULL)
        frame = cvCreateImageHeader(cvSize(640, 480), IPL_DEPTH_8U, 3);

    switch (recognition_info.reco_state) {
    case NOT_START_RECOGNIZING:
        g_debug("[%s] not start recognizing", __func__);
        if (copy_buffer != NULL)
            gst_buffer_unref(copy_buffer);

        if (pure_buffer != NULL)
            gst_buffer_unref(pure_buffer);

        copy_buffer = gst_buffer_copy((buffer));
        pure_buffer = gst_buffer_copy((buffer));

        frame->imageData = (char*)GST_BUFFER_DATA(copy_buffer);
        if (recognition_info.detect_is_enabled) {
            detect(frame);
        } else {
            g_timer_start(recognition_info.timer);
        }
        recognition_info.source_data = (guchar*)(frame->imageData);
        recognition_info.length = GST_BUFFER_SIZE(copy_buffer);
        recognition_info.has_data = TRUE;
        break;
    case START_RECOGNIZING:
        g_debug("[%s] start recognizing", __func__);
        recognition_info.source_data = (guchar*)GST_BUFFER_DATA(pure_buffer);
        recognition_info.length = GST_BUFFER_SIZE(pure_buffer);
        GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(recognition_info.source_data,
                                                     GDK_COLORSPACE_RGB,  // color space
                                                     FALSE,  // has alpha
                                                     8,  // bits per sample
                                                     CAMERA_WIDTH,  // width
                                                     CAMERA_HEIGHT,  // height
                                                     3*CAMERA_WIDTH,  // row stride
                                                     NULL,  // destroy function
                                                     NULL  // destroy function data
                                                    );
        GError* error = NULL;
        gdk_pixbuf_save(pixbuf, "/tmp/deepin_user_face.png", "png", &error, NULL);
        if (error != NULL) {
            g_debug("[%s] %s", __func__, error->message);
            g_error_free(error);
        }

        g_object_unref(pixbuf);
        recognition_info.has_data = TRUE;

        js_post_signal("start-animation");
        recognition_info.reco_state = RECOGNIZING;
        sended = FALSE;
        reco();
        break;
    case RECOGNIZED:
        g_debug("[%s] recognized", __func__);
        if (!sended) {
            g_timeout_add(ANIMATION_TIME, recognized_handler, NULL);
            sended = TRUE;
        }
        break;
    case NOT_RECOGNIZED:
        g_debug("[%s] not recognized", __func__);
        if (!sended) {
            g_timeout_add(ANIMATION_TIME, not_recognize_handler, NULL);
            sended = TRUE;
        }
        break;
    case RECOGNIZE_FINISH:
        g_debug("[%s] recognizing finish", __func__);
        if (copy_buffer != NULL)
            gst_buffer_unref(copy_buffer);
        copy_buffer = gst_buffer_copy((buffer));
        recognition_info.source_data = (guchar*)GST_BUFFER_DATA(copy_buffer);
        recognition_info.length = GST_BUFFER_SIZE(pure_buffer);
        recognition_info.has_data = TRUE;
    }

    return TRUE;
}
Beispiel #5
0
JS_EXPORT_API
gboolean lock_try_unlock (const gchar *username,const gchar *password)
{
    if (lock_is_guest()) {
        js_post_signal("auth-succeed");
        gtk_main_quit();
        return TRUE;
    }

    gboolean succeed = FALSE;

    GDBusProxy *lock_proxy = NULL;
    GVariant *lock_succeed = NULL;
    GError *error = NULL;

    lock_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
            G_DBUS_PROXY_FLAGS_NONE,
            NULL,
            "com.deepin.dde.lock",
            "/com/deepin/dde/lock",
            "com.deepin.dde.lock",
            NULL,
            &error);

    if (error != NULL) {
        g_warning ("connect com.deepin.dde.lock failed");
        g_error_free (error);
    }
    error = NULL;

    lock_succeed  = g_dbus_proxy_call_sync (lock_proxy,
            "UnlockCheck",
            g_variant_new ("(ss)", username, password),
            G_DBUS_CALL_FLAGS_NONE,
            -1,
            NULL,
            &error);

    //g_assert (lock_succeed != NULL);
    if (error != NULL) {
        g_warning ("try unlock:UnlockCheck %s\n", error->message);
        g_error_free (error);
    }
    error = NULL;

    g_variant_get (lock_succeed, "(b)", &succeed);

    g_variant_unref (lock_succeed);
    g_object_unref (lock_proxy);

    if (succeed) {
        js_post_signal("auth-succeed");

    } else {
        JSObjectRef error_message = json_create();
        json_append_string(error_message, "error", _("Wrong Password"));
        js_post_message("auth-failed", error_message);
    }

    return succeed;
}
Beispiel #6
0
void close_launcher_window()
{
    dbus_launcher_hide();
    js_post_signal("launcher_destroy");
}