void spice_session_setup(JNIEnv *env, SpiceSession *session, jstring h, jstring p, jstring tp, jstring pw, jstring cf, jstring cs) { const char *host = NULL; const char *port = NULL; const char *tls_port = NULL; const char *password = NULL; const char *ca_file = NULL; const char *cert_subj = NULL; host = (*env)->GetStringUTFChars(env, h, NULL); port = (*env)->GetStringUTFChars(env, p, NULL); tls_port = (*env)->GetStringUTFChars(env, tp, NULL); password = (*env)->GetStringUTFChars(env, pw, NULL); ca_file = (*env)->GetStringUTFChars(env, cf, NULL); cert_subj = (*env)->GetStringUTFChars(env, cs, NULL); g_return_if_fail(SPICE_IS_SESSION(session)); if (host) g_object_set(session, "host", host, NULL); // If we receive "-1" for a port, we assume the port is not set. if (port && strcmp (port, "-1") != 0) g_object_set(session, "port", port, NULL); if (tls_port && strcmp (tls_port, "-1") != 0) g_object_set(session, "tls-port", tls_port, NULL); if (password) g_object_set(session, "password", password, NULL); if (ca_file) g_object_set(session, "ca-file", ca_file, NULL); if (cert_subj) g_object_set(session, "cert-subject", cert_subj, NULL); }
G_GNUC_INTERNAL gboolean spice_smartcard_manager_init_finish(SpiceSession *session, GAsyncResult *result, GError **err) { g_return_val_if_fail(SPICE_IS_SESSION(session), FALSE); return TRUE; }
/** * spice_set_session_option: * @session: a #SpiceSession to set option upon * * Set various properties on @session, according to the commandline * arguments given to spice_get_option_group() option group. **/ void spice_set_session_option(SpiceSession *session) { g_return_if_fail(SPICE_IS_SESSION(session)); if (ca_file == NULL) { const char *homedir = g_getenv("HOME"); if (!homedir) homedir = g_get_home_dir(); ca_file = g_strdup_printf("%s/.spicec/spice_truststore.pem", homedir); } if (disable_effects) { GStrv effects; effects = g_strsplit(disable_effects, ",", -1); if (effects) g_object_set(session, "disable-effects", effects, NULL); g_strfreev(effects); } if (color_depth) g_object_set(session, "color-depth", color_depth, NULL); if (ca_file) g_object_set(session, "ca-file", ca_file, NULL); if (host_subject) g_object_set(session, "cert-subject", host_subject, NULL); if (smartcard) { g_object_set(session, "enable-smartcard", smartcard, NULL); if (smartcard_certificates) { GStrv certs_strv; certs_strv = g_strsplit(smartcard_certificates, ",", -1); if (certs_strv) g_object_set(session, "smartcard-certificates", certs_strv, NULL); g_strfreev(certs_strv); } if (smartcard_db) g_object_set(session, "smartcard-db", smartcard_db, NULL); } if (usbredir_auto_redirect_filter) { SpiceUsbDeviceManager *m = spice_usb_device_manager_get(session, NULL); if (m) g_object_set(m, "auto-connect-filter", usbredir_auto_redirect_filter, NULL); } if (usbredir_redirect_on_connect) { SpiceUsbDeviceManager *m = spice_usb_device_manager_get(session, NULL); if (m) g_object_set(m, "redirect-on-connect", usbredir_redirect_on_connect, NULL); } if (disable_usbredir) g_object_set(session, "enable-usbredir", FALSE, NULL); if (disable_audio) g_object_set(session, "enable-audio", FALSE, NULL); if (cache_size) g_object_set(session, "cache-size", cache_size, NULL); if (glz_window_size) g_object_set(session, "glz-window-size", glz_window_size, NULL); }
void spice_cmdline_session_setup(SpiceSession *session) { g_return_if_fail(SPICE_IS_SESSION(session)); if (uri) g_object_set(session, "uri", uri, NULL); if (host) g_object_set(session, "host", host, NULL); if (port) g_object_set(session, "port", port, NULL); if (tls_port) g_object_set(session, "tls-port", tls_port, NULL); if (password) g_object_set(session, "password", password, NULL); }
/** * spice_gtk_session_get: * @session: #SpiceSession for which to get the #SpiceGtkSession * * Gets the #SpiceGtkSession associated with the passed in #SpiceSession. * A new #SpiceGtkSession instance will be created the first time this * function is called for a certain #SpiceSession. * * Note that this function returns a weak reference, which should not be used * after the #SpiceSession itself has been unref-ed by the caller. * * Returns: (transfer none): a weak reference to the #SpiceGtkSession associated with the passed in #SpiceSession * * Since 0.8 **/ SpiceGtkSession *spice_gtk_session_get(SpiceSession *session) { g_return_val_if_fail(SPICE_IS_SESSION(session), NULL); SpiceGtkSession *self; static GStaticMutex mutex = G_STATIC_MUTEX_INIT; g_static_mutex_lock(&mutex); self = session->priv->gtk_session; if (self == NULL) { self = g_object_new(SPICE_TYPE_GTK_SESSION, "session", session, NULL); session->priv->gtk_session = self; } g_static_mutex_unlock(&mutex); return SPICE_GTK_SESSION(self); }
G_GNUC_INTERNAL gboolean spice_smartcard_manager_init_finish(SpiceSession *session, GAsyncResult *result, GError **err) { GSimpleAsyncResult *simple; g_return_val_if_fail(SPICE_IS_SESSION(session), FALSE); g_return_val_if_fail(G_IS_SIMPLE_ASYNC_RESULT(result), FALSE); SPICE_DEBUG("smartcard_manager_finish"); simple = G_SIMPLE_ASYNC_RESULT(result); g_return_val_if_fail(g_simple_async_result_get_source_tag(simple) == spice_smartcard_manager_init, FALSE); if (g_simple_async_result_propagate_error(simple, err)) return FALSE; spice_smartcard_manager_update_monitor(); return TRUE; }
static gboolean smartcard_manager_init(SmartcardManagerInitArgs *args) { gchar *emul_args = NULL; VCardEmulOptions *options = NULL; VCardEmulError emul_init_status; gchar *dbname = NULL; GStrv certificates = NULL; gboolean retval = FALSE; SPICE_DEBUG("smartcard_manager_init"); g_return_val_if_fail(SPICE_IS_SESSION(args->session), FALSE); g_object_get(G_OBJECT(args->session), "smartcard-db", &dbname, "smartcard-certificates", &certificates, NULL); if ((certificates == NULL) || (g_strv_length(certificates) != 3)) goto init; if (dbname) { emul_args = g_strdup_printf("db=\"%s\" use_hw=no " "soft=(,%s,CAC,,%s,%s,%s)", dbname, SPICE_SOFTWARE_READER_NAME, certificates[0], certificates[1], certificates[2]); } else { emul_args = g_strdup_printf("use_hw=no soft=(,%s,CAC,,%s,%s,%s)", SPICE_SOFTWARE_READER_NAME, certificates[0], certificates[1], certificates[2]); } options = vcard_emul_options(emul_args); if (options == NULL) { args->err = g_error_new(SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED, "vcard_emul_options() failed!"); goto end; } if (g_cancellable_set_error_if_cancelled(args->cancellable, &args->err)) goto end; init: SPICE_DEBUG("vcard_emul_init"); emul_init_status = vcard_emul_init(options); if ((emul_init_status != VCARD_EMUL_OK) && (emul_init_status != VCARD_EMUL_INIT_ALREADY_INITED)) { args->err = g_error_new(SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED, "Failed to initialize smartcard"); goto end; } retval = TRUE; end: SPICE_DEBUG("smartcard_manager_init end: %d", retval); g_free(emul_args); g_free(dbname); g_strfreev(certificates); return retval; }