summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2011-01-26 18:46:01 +0100
committerMarc-André Lureau <marcandre.lureau@redhat.com>2011-01-26 19:54:53 +0100
commitcd8a464ea0474557311efd1f8723a4cf7fc597bb (patch)
tree0f99d659ae55b85c7e3b482a01918f449c8dc6ba
parenteda35730d607c02f444bb3c568d9b336b45e488b (diff)
gtk: add "migration-state" enum to make it easier to track migrations
-rw-r--r--gtk/channel-main.c11
-rw-r--r--gtk/map-file1
-rw-r--r--gtk/spice-client-gtk.defs16
-rw-r--r--gtk/spice-session-priv.h3
-rw-r--r--gtk/spice-session.c35
-rw-r--r--gtk/spice-session.h21
-rw-r--r--gtk/spicy.c12
7 files changed, 91 insertions, 8 deletions
diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index 3e6e9fc..35e5376 100644
--- a/gtk/channel-main.c
+++ b/gtk/channel-main.c
@@ -1250,13 +1250,19 @@ static void main_handle_migrate_begin(SpiceChannel *channel, spice_msg_in *in)
static gboolean switch_host_delayed(gpointer data)
{
SpiceChannel *channel = data;
+ SpiceSession *session;
spice_main_channel *c = SPICE_MAIN_CHANNEL(channel)->priv;
g_warn_if_fail(c->switch_host_delayed_id != 0);
-
c->switch_host_delayed_id = 0;
+
+ session = spice_channel_get_session(channel);
+
spice_channel_disconnect(channel, SPICE_CHANNEL_SWITCHING);
+ spice_session_switching_disconnect(session);
+
spice_channel_connect(channel);
+ spice_session_set_migration_state(session, SPICE_SESSION_MIGRATION_NONE);
return FALSE;
}
@@ -1287,8 +1293,7 @@ static void main_handle_migrate_switch_host(SpiceChannel *channel, spice_msg_in
}
session = spice_channel_get_session(channel);
- spice_session_migrate_disconnect(session);
-
+ spice_session_set_migration_state(session, SPICE_SESSION_MIGRATION_SWITCHING);
g_object_set(session, "host", host, NULL);
spice_session_set_port(session, mig->port, FALSE);
spice_session_set_port(session, mig->sport, TRUE);
diff --git a/gtk/map-file b/gtk/map-file
index 18a1ffe..a17ab16 100644
--- a/gtk/map-file
+++ b/gtk/map-file
@@ -55,6 +55,7 @@ spice_session_get_channels;
spice_session_new;
spice_session_open_fd;
spice_session_verify_get_type;
+spice_session_migration_get_type;
spice_util_get_debug;
spice_util_get_version_string;
spice_util_set_debug;
diff --git a/gtk/spice-client-gtk.defs b/gtk/spice-client-gtk.defs
index 0887f0c..6a67dc1 100644
--- a/gtk/spice-client-gtk.defs
+++ b/gtk/spice-client-gtk.defs
@@ -94,6 +94,17 @@
)
)
+(define-enum SessionMigration
+ (in-module "Spice")
+ (c-name "SpiceSessionMigration")
+ (gtype-id "SPICE_TYPE_SESSION_MIGRATION")
+ (values
+ '("none" "SPICE_SESSION_MIGRATION_NONE")
+ '("switching" "SPICE_SESSION_MIGRATION_SWITCHING")
+ '("migrating" "SPICE_SESSION_MIGRATION_MIGRATING")
+ )
+)
+
(define-enum ChannelEvent
(in-module "Spice")
(c-name "SpiceChannelEvent")
@@ -405,6 +416,11 @@
(return-type "GType")
)
+(define-function spice_session_migration_get_type
+ (c-name "spice_session_migration_get_type")
+ (return-type "GType")
+)
+
;; From spice-util.h
diff --git a/gtk/spice-session-priv.h b/gtk/spice-session-priv.h
index 1266e57..d88b508 100644
--- a/gtk/spice-session-priv.h
+++ b/gtk/spice-session-priv.h
@@ -37,9 +37,10 @@ void spice_session_channel_migrate(SpiceSession *session, SpiceChannel *channel)
void spice_session_set_mm_time(SpiceSession *session, guint32 time);
guint32 spice_session_get_mm_time(SpiceSession *session);
-void spice_session_migrate_disconnect(SpiceSession *session);
+void spice_session_switching_disconnect(SpiceSession *session);
void spice_session_set_migration(SpiceSession *session, SpiceSession *migration);
void spice_session_abort_migration(SpiceSession *session);
+void spice_session_set_migration_state(SpiceSession *session, SpiceSessionMigration state);
void spice_session_set_port(SpiceSession *session, int port, gboolean tls);
void spice_session_get_pubkey(SpiceSession *session, guint8 **pubkey, guint *size);
diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index dd95d93..57fa8fb 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -52,6 +52,7 @@ struct spice_session {
guint64 mm_time_at_clock;
SpiceSession *migration;
GList *migration_left;
+ SpiceSessionMigration migration_state;
gboolean disconnecting;
};
@@ -110,6 +111,7 @@ enum {
PROP_PUBKEY,
PROP_CERT_SUBJECT,
PROP_VERIFY,
+ PROP_MIGRATION_STATE,
};
/* signals */
@@ -305,6 +307,9 @@ static void spice_session_get_property(GObject *gobject,
case PROP_VERIFY:
g_value_set_flags(value, s->verify);
break;
+ case PROP_MIGRATION_STATE:
+ g_value_set_enum(value, s->migration_state);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
break;
@@ -367,6 +372,9 @@ static void spice_session_set_property(GObject *gobject,
case PROP_VERIFY:
s->verify = g_value_get_flags(value);
break;
+ case PROP_MIGRATION_STATE:
+ s->migration_state = g_value_get_enum(value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
break;
@@ -485,6 +493,16 @@ static void spice_session_class_init(SpiceSessionClass *klass)
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property
+ (gobject_class, PROP_MIGRATION_STATE,
+ g_param_spec_enum("migration-state",
+ "Migration state",
+ "Migration state",
+ SPICE_TYPE_SESSION_MIGRATION,
+ SPICE_SESSION_MIGRATION_NONE,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
/**
* SpiceSession::channel-new:
* @session: the session that emitted the signal
@@ -623,7 +641,7 @@ gboolean spice_session_get_client_provided_socket(SpiceSession *session)
}
G_GNUC_INTERNAL
-void spice_session_migrate_disconnect(SpiceSession *session)
+void spice_session_switching_disconnect(SpiceSession *session)
{
spice_session *s = SPICE_SESSION_GET_PRIVATE(session);
struct channel *item;
@@ -653,6 +671,8 @@ void spice_session_set_migration(SpiceSession *session, SpiceSession *migration)
g_return_if_fail(s != NULL);
+ spice_session_set_migration_state(session, SPICE_SESSION_MIGRATION_MIGRATING);
+
g_warn_if_fail(s->migration == NULL);
s->migration = g_object_ref(migration);
@@ -732,6 +752,8 @@ void spice_session_abort_migration(SpiceSession *session)
spice_session_disconnect(s->migration);
g_object_unref(s->migration);
s->migration = NULL;
+
+ spice_session_set_migration_state(session, SPICE_SESSION_MIGRATION_NONE);
}
G_GNUC_INTERNAL
@@ -760,6 +782,7 @@ void spice_session_channel_migrate(SpiceSession *session, SpiceChannel *channel)
spice_session_disconnect(s->migration);
g_object_unref(s->migration);
s->migration = NULL;
+ spice_session_set_migration_state(session, SPICE_SESSION_MIGRATION_NONE);
}
}
@@ -1030,3 +1053,13 @@ guint spice_session_get_verify(SpiceSession *session)
g_return_val_if_fail(s != NULL, 0);
return s->verify;
}
+
+G_GNUC_INTERNAL
+void spice_session_set_migration_state(SpiceSession *session, SpiceSessionMigration state)
+{
+ spice_session *s = SPICE_SESSION_GET_PRIVATE(session);
+
+ g_return_if_fail(s != NULL);
+ s->migration_state = state;
+ g_object_notify(G_OBJECT(session), "migration-state");
+}
diff --git a/gtk/spice-session.h b/gtk/spice-session.h
index 690dacc..31db1ec 100644
--- a/gtk/spice-session.h
+++ b/gtk/spice-session.h
@@ -35,9 +35,9 @@ G_BEGIN_DECLS
/**
* SpiceSessionVerify:
*
- * @SPICE_SESSION_VERIFY_PUBKEY:
- * @SPICE_SESSION_VERIFY_HOSTNAME:
- * @SPICE_SESSION_VERIFY_SUBJECT:
+ * @SPICE_SESSION_VERIFY_PUBKEY: verify certificate public key matching
+ * @SPICE_SESSION_VERIFY_HOSTNAME: verify certificate hostname matching
+ * @SPICE_SESSION_VERIFY_SUBJECT: verify certificate subject matching
*
* Peer certificate verification parameters flags.
**/
@@ -47,6 +47,21 @@ typedef enum {
SPICE_SESSION_VERIFY_SUBJECT = (1 << 2),
} SpiceSessionVerify;
+/**
+ * SpiceSessionMigration:
+ *
+ * @SPICE_SESSION_MIGRATION_NONE: no migration going on
+ * @SPICE_SESSION_MIGRATION_SWITCHING: the session is switching host (destroy and reconnect)
+ * @SPICE_SESSION_MIGRATION_MIGRATING: the session is migrating seamlessly (reconnect)
+ *
+ * Session migration state.
+ **/
+typedef enum {
+ SPICE_SESSION_MIGRATION_NONE,
+ SPICE_SESSION_MIGRATION_SWITCHING,
+ SPICE_SESSION_MIGRATION_MIGRATING,
+} SpiceSessionMigration;
+
struct _SpiceSession
{
GObject parent;
diff --git a/gtk/spicy.c b/gtk/spicy.c
index c3e59c9..2375f4b 100644
--- a/gtk/spicy.c
+++ b/gtk/spicy.c
@@ -957,6 +957,16 @@ static void channel_destroy(SpiceSession *s, SpiceChannel *channel, gpointer dat
connection_destroy(conn);
}
+static void migration_state(GObject *session,
+ GParamSpec *pspec, gpointer data)
+{
+ SpiceSessionMigration mig;
+
+ g_object_get(session, "migration-state", &mig, NULL);
+ if (mig == SPICE_SESSION_MIGRATION_SWITCHING)
+ g_message("migrating session");
+}
+
static spice_connection *connection_new(void)
{
spice_connection *conn;
@@ -967,6 +977,8 @@ static spice_connection *connection_new(void)
G_CALLBACK(channel_new), conn);
g_signal_connect(conn->session, "channel-destroy",
G_CALLBACK(channel_destroy), conn);
+ g_signal_connect(conn->session, "notify::migration-state",
+ G_CALLBACK(migration_state), conn);
connections++;
SPICE_DEBUG("%s (%d)", __FUNCTION__, connections);
return conn;