diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2014-02-27 11:10:25 +0100 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2014-03-19 15:24:23 +0100 |
commit | eeeb6e27be376e74c1ad02c092d8e27011ee738e (patch) | |
tree | 7c11a308d91c64e0971bb4401f01485a942b3921 | |
parent | 382ecfa16f30c2db80a8996f93dacf5a62d7231c (diff) |
session: add shared-dir property and option
Allow to specify the shared directory from the command line, or at
runtime via properties. (still default to xdg public share, if none
specified)
-rw-r--r-- | gtk/channel-webdav.c | 8 | ||||
-rw-r--r-- | gtk/spice-option.c | 5 | ||||
-rw-r--r-- | gtk/spice-session-priv.h | 3 | ||||
-rw-r--r-- | gtk/spice-session.c | 49 |
4 files changed, 62 insertions, 3 deletions
diff --git a/gtk/channel-webdav.c b/gtk/channel-webdav.c index 28760f5..ffd617e 100644 --- a/gtk/channel-webdav.c +++ b/gtk/channel-webdav.c @@ -36,7 +36,11 @@ static PhodavServer* phodav_server_get(SpiceSession *session, gint *port); * * The "webdav" channel exports a directory to the guest for file * manipulation (read/write/copy etc). The underlying protocol is - * implemented using WebDAV (RFC 4918) + * implemented using WebDAV (RFC 4918). + * + * By default, the shared directory is the one associated with GLib + * %G_USER_DIRECTORY_PUBLIC_SHARE. You can specify a different + * directory with #SpiceSession #SpiceSession:shared-dir property. * * Since: 0.24 */ @@ -697,7 +701,7 @@ static PhodavServer* webdav_server_new(SpiceSession *session) g_warn_if_fail(!session->priv->webdav); - dav = phodav_server_new(0, g_get_user_special_dir(G_USER_DIRECTORY_PUBLIC_SHARE)); + dav = phodav_server_new(0, spice_session_get_shared_dir(session)); session->priv->webdav = dav; for (i = 0; i < sizeof(session->priv->webdav_magic); i++) session->priv->webdav_magic[i] = g_random_int_range(0, 255); diff --git a/gtk/spice-option.c b/gtk/spice-option.c index 5f7c803..1c861e2 100644 --- a/gtk/spice-option.c +++ b/gtk/spice-option.c @@ -41,6 +41,7 @@ static gboolean disable_usbredir = FALSE; static gint cache_size = 0; static gint glz_window_size = 0; static gchar *secure_channels = NULL; +static gchar *shared_dir = NULL; G_GNUC_NORETURN static void option_version(void) @@ -192,6 +193,8 @@ GOptionGroup* spice_get_option_group(void) N_("Image cache size"), N_("<bytes>") }, { "spice-glz-window-size", '\0', 0, G_OPTION_ARG_INT, &glz_window_size, N_("Glz compression history size"), N_("<bytes>") }, + { "spice-shared-dir", '\0', 0, G_OPTION_ARG_FILENAME, &shared_dir, + N_("Shared directory"), N_("<dir>") }, { "spice-debug", '\0', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, option_debug, N_("Enable Spice-GTK debugging"), NULL }, @@ -275,4 +278,6 @@ void spice_set_session_option(SpiceSession *session) g_object_set(session, "cache-size", cache_size, NULL); if (glz_window_size) g_object_set(session, "glz-window-size", glz_window_size, NULL); + if (shared_dir) + g_object_set(session, "shared-dir", shared_dir, NULL); } diff --git a/gtk/spice-session-priv.h b/gtk/spice-session-priv.h index cf9f9d1..94535a8 100644 --- a/gtk/spice-session-priv.h +++ b/gtk/spice-session-priv.h @@ -46,6 +46,7 @@ struct _SpiceSessionPrivate { guint verify; gboolean read_only; SpiceURI *proxy; + gchar *shared_dir; /* whether to enable audio */ gboolean audio; @@ -160,6 +161,8 @@ void spice_session_set_name(SpiceSession *session, const gchar *name); gboolean spice_session_is_playback_active(SpiceSession *session); guint32 spice_session_get_playback_latency(SpiceSession *session); void spice_session_sync_playback_latency(SpiceSession *session); +const gchar* spice_session_get_shared_dir(SpiceSession *session); +void spice_session_set_shared_dir(SpiceSession *session, const gchar *dir); G_END_DECLS diff --git a/gtk/spice-session.c b/gtk/spice-session.c index 1c4c34e..c168bc3 100644 --- a/gtk/spice-session.c +++ b/gtk/spice-session.c @@ -110,7 +110,8 @@ enum { PROP_NAME, PROP_CA, PROP_PROXY, - PROP_SECURE_CHANNELS + PROP_SECURE_CHANNELS, + PROP_SHARED_DIR }; /* signals */ @@ -239,6 +240,7 @@ spice_session_finalize(GObject *gobject) g_free(s->smartcard_db); g_strfreev(s->disable_effects); g_strfreev(s->secure_channels); + g_free(s->shared_dir); g_clear_pointer(&s->images, cache_unref); glz_decoder_window_destroy(s->glz_window); @@ -504,6 +506,9 @@ static void spice_session_get_property(GObject *gobject, case PROP_PROXY: g_value_take_string(value, spice_uri_to_string(s->proxy)); break; + case PROP_SHARED_DIR: + g_value_set_string(value, spice_session_get_shared_dir(session)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec); break; @@ -626,6 +631,9 @@ static void spice_session_set_property(GObject *gobject, case PROP_PROXY: update_proxy(session, g_value_get_string(value)); break; + case PROP_SHARED_DIR: + spice_session_set_shared_dir(session, g_value_get_string(value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec); break; @@ -1173,6 +1181,23 @@ static void spice_session_class_init(SpiceSessionClass *klass) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + /** + * SpiceSession:shared-dir: + * + * Location of the shared directory + * + * Since: 0.24 + **/ + g_object_class_install_property + (gobject_class, PROP_SHARED_DIR, + g_param_spec_string("shared-dir", + "Shared directory", + "Shared directory", + g_get_user_special_dir(G_USER_DIRECTORY_PUBLIC_SHARE), + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT | + G_PARAM_STATIC_STRINGS)); + g_type_class_add_private(klass, sizeof(SpiceSessionPrivate)); } @@ -2193,6 +2218,28 @@ guint32 spice_session_get_playback_latency(SpiceSession *session) } } +G_GNUC_INTERNAL +const gchar* spice_session_get_shared_dir(SpiceSession *session) +{ + SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session); + + g_return_val_if_fail(s != NULL, NULL); + + return s->shared_dir; +} + +G_GNUC_INTERNAL +void spice_session_set_shared_dir(SpiceSession *session, const gchar *dir) +{ + SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session); + + g_return_if_fail(dir != NULL); + g_return_if_fail(s != NULL); + + g_free(s->shared_dir); + s->shared_dir = g_strdup(dir); +} + /** * spice_session_get_proxy_uri: * @session: a #SpiceSession |