[virt-tools-list] [PATCH 2/3]virt-viewer: Register a new signal 'session-cancelled'

Guannan Ren gren at redhat.com
Sun Jan 15 06:29:23 UTC 2012


	*src/virt-viewer-session-spice.c sending out 'session-cancelled'
		when the cancel buttion is clicked.
	*src/virt-viewer-session.c register a the new signal.
	*src/virt-viewer-session.h default callback.
---
 src/virt-viewer-session-spice.c |   10 ++++++----
 src/virt-viewer-session.c       |    9 +++++++++
 src/virt-viewer-session.h       |    1 +
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c
index d0d6e29..3af9350 100644
--- a/src/virt-viewer-session-spice.c
+++ b/src/virt-viewer-session-spice.c
@@ -193,12 +193,14 @@ virt_viewer_session_spice_main_channel_event(SpiceChannel *channel G_GNUC_UNUSED
 		int ret = virt_viewer_auth_collect_credentials("SPICE",
 							       NULL,
 							       NULL, &password);
-		if (ret < 0) {
-			g_signal_emit_by_name(session, "session-auth-refused",
-					      _("Unable to collect credentials"));
-		} else {
+		if (ret == 1) {
 			g_object_set(self->priv->session, "password", password, NULL);
 			spice_session_connect(self->priv->session);
+		} else if (ret == -1) {
+			g_signal_emit_by_name(session, "session-cancelled");
+		} else {
+			g_signal_emit_by_name(session, "session-auth-refused",
+                                              _("Unable to collect credentials"));
 		}
 		break;
 	default:
diff --git a/src/virt-viewer-session.c b/src/virt-viewer-session.c
index d151238..e234042 100644
--- a/src/virt-viewer-session.c
+++ b/src/virt-viewer-session.c
@@ -164,6 +164,15 @@ virt_viewer_session_class_init(VirtViewerSessionClass *class)
 		     G_TYPE_NONE,
 		     0);
 
+	g_signal_new("session-cancelled",
+                     G_OBJECT_CLASS_TYPE(object_class),
+                     G_SIGNAL_RUN_FIRST,
+                     G_STRUCT_OFFSET(VirtViewerSessionClass, session_cancelled),
+                     NULL, NULL,
+                     g_cclosure_marshal_VOID__VOID,
+                     G_TYPE_NONE,
+                     0);
+
 	g_type_class_add_private(object_class, sizeof(VirtViewerSessionPrivate));
 }
 
diff --git a/src/virt-viewer-session.h b/src/virt-viewer-session.h
index 48c8de3..f2f345a 100644
--- a/src/virt-viewer-session.h
+++ b/src/virt-viewer-session.h
@@ -86,6 +86,7 @@ struct _VirtViewerSessionClass {
 
 	void (*session_cut_text)(VirtViewerSession *session, const char *str);
 	void (*session_bell)(VirtViewerSession *session);
+	void (*session_cancelled)(VirtViewerSession *session);
 };
 
 GType virt_viewer_session_get_type(void);
-- 
1.7.7.5




More information about the virt-tools-list mailing list