[virt-tools-list] [virt-viewer v3 09/10] vv-file: Add 'newer-version-url' key to .vv files

Christophe Fergeau cfergeau at redhat.com
Tue Jun 9 10:38:20 UTC 2015


If set, this URL will be displayed when one of the version checks
('version' of 'versions' key fail). This URL should contain explanations
about how to get an updated remote-viewer version.
---
 man/remote-viewer.pod  |  5 +++++
 src/virt-viewer-file.c | 27 +++++++++++++++++++++++++++
 src/virt-viewer-file.h |  2 ++
 3 files changed, 34 insertions(+)

diff --git a/man/remote-viewer.pod b/man/remote-viewer.pod
index bda513d..1358f1b 100644
--- a/man/remote-viewer.pod
+++ b/man/remote-viewer.pod
@@ -156,6 +156,11 @@ remote-viewer builds matching the given 'osid' (fedora22, debian7, ...) must
 be at least version 'version'. For consistency, it's recommended to use libosinfo OS shortids as
 the osid.
 
+=item C<newer-version-url> (string)
+
+If specified, this field is an URL which will be displayed to the user when a version check
+fails.
+
 =item C<type> (string, mandatory)
 
 The session type, either "spice", "vnc" or "ovirt".
diff --git a/src/virt-viewer-file.c b/src/virt-viewer-file.c
index 3f06d1e..906d719 100644
--- a/src/virt-viewer-file.c
+++ b/src/virt-viewer-file.c
@@ -40,6 +40,8 @@
  *  The current list of [virt-viewer] keys is:
  * - version: string
  * - versions: list of id:versions strings
+ * - newer-version-url: string specifying an URL to display when the minimum
+ *   version check fails
  * - type: string, mandatory, values: "spice" (later "vnc" etc..)
  * - host: string
  * - port: int
@@ -120,6 +122,7 @@ enum  {
     PROP_PROXY,
     PROP_VERSION,
     PROP_VERSIONS,
+    PROP_VERSION_URL,
     PROP_SECURE_CHANNELS,
     PROP_DELETE_THIS_FILE,
     PROP_SECURE_ATTENTION,
@@ -676,6 +679,20 @@ virt_viewer_file_set_versions(VirtViewerFile* self, GHashTable *version_table)
     g_object_notify(G_OBJECT(self), "versions");
 }
 
+gchar*
+virt_viewer_file_get_version_url(VirtViewerFile* self)
+{
+    return virt_viewer_file_get_string(self, MAIN_GROUP, "newer-version-url");
+}
+
+void
+virt_viewer_file_set_version_url(VirtViewerFile* self, const gchar* value)
+{
+    virt_viewer_file_set_string(self, MAIN_GROUP, "newer-version-url", value);
+    g_object_notify(G_OBJECT(self), "version-url");
+}
+
+
 gchar**
 virt_viewer_file_get_secure_channels(VirtViewerFile* self, gsize* length)
 {
@@ -944,6 +961,9 @@ virt_viewer_file_set_property(GObject* object, guint property_id,
     case PROP_VERSIONS:
         virt_viewer_file_set_versions(self, g_value_get_boxed(value));
         break;
+    case PROP_VERSION_URL:
+        virt_viewer_file_set_version_url(self, g_value_get_string(value));
+        break;
     case PROP_SECURE_CHANNELS:
         strv = g_value_get_boxed(value);
         virt_viewer_file_set_secure_channels(self, (const gchar* const*)strv, g_strv_length(strv));
@@ -1051,6 +1071,9 @@ virt_viewer_file_get_property(GObject* object, guint property_id,
     case PROP_VERSIONS:
         g_value_take_boxed(value, virt_viewer_file_get_versions(self));
         break;
+    case PROP_VERSION_URL:
+        g_value_take_string(value, virt_viewer_file_get_version_url(self));
+        break;
     case PROP_SECURE_CHANNELS:
         g_value_take_boxed(value, virt_viewer_file_get_secure_channels(self, NULL));
         break;
@@ -1203,6 +1226,10 @@ virt_viewer_file_class_init(VirtViewerFileClass* klass)
         g_param_spec_boxed("versions", "versions", "versions", G_TYPE_HASH_TABLE,
                            G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE));
 
+    g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_VERSION_URL,
+        g_param_spec_string("version-url", "version-url", "version-url", NULL,
+                            G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE));
+
     g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_SECURE_CHANNELS,
         g_param_spec_boxed("secure-channels", "secure-channels", "secure-channels", G_TYPE_STRV,
                            G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE));
diff --git a/src/virt-viewer-file.h b/src/virt-viewer-file.h
index 1635507..0eb7966 100644
--- a/src/virt-viewer-file.h
+++ b/src/virt-viewer-file.h
@@ -104,6 +104,8 @@ gchar* virt_viewer_file_get_version(VirtViewerFile* self);
 void virt_viewer_file_set_version(VirtViewerFile* self, const gchar* value);
 GHashTable* virt_viewer_file_get_versions(VirtViewerFile* self);
 void virt_viewer_file_set_versions(VirtViewerFile* self, GHashTable *version_table);
+gchar* virt_viewer_file_get_version_url(VirtViewerFile* self);
+void virt_viewer_file_set_version_url(VirtViewerFile* self, const gchar* value);
 gchar** virt_viewer_file_get_secure_channels(VirtViewerFile* self, gsize* length);
 void virt_viewer_file_set_secure_channels(VirtViewerFile* self, const gchar* const* value, gsize length);
 gint virt_viewer_file_get_delete_this_file(VirtViewerFile* self);
-- 
2.4.2




More information about the virt-tools-list mailing list