[Spice-devel] [PATCH spice-gtk 6/7] spice-session: at a spice_session_has_channel_type method
Hans de Goede
hdegoede at redhat.com
Tue Aug 30 05:52:27 PDT 2011
Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
gtk/map-file | 1 +
gtk/spice-session.c | 28 ++++++++++++++++++++++++++++
gtk/spice-session.h | 1 +
3 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/gtk/map-file b/gtk/map-file
index c192f6c..d9765c0 100644
--- a/gtk/map-file
+++ b/gtk/map-file
@@ -62,6 +62,7 @@ spice_session_connect;
spice_session_disconnect;
spice_session_get_channels;
spice_session_get_type;
+spice_session_has_channel_type;
spice_session_migration_get_type;
spice_session_new;
spice_session_open_fd;
diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index b0bbb14..3ce80d5 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -1176,6 +1176,34 @@ GList *spice_session_get_channels(SpiceSession *session)
return list;
}
+/**
+ * spice_session_has_channel_type:
+ * @session: a #SpiceSession
+ *
+ * See if there is a @type channel in the channels associated with this
+ * @session.
+ *
+ * Returns: TRUE if a @type channel is available otherwise FALSE.
+ **/
+gboolean spice_session_has_channel_type(SpiceSession *session, gint type)
+{
+ SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ struct channel *item;
+ RingItem *ring;
+
+ g_return_val_if_fail(s != NULL, FALSE);
+
+ for (ring = ring_get_head(&s->channels);
+ ring != NULL;
+ ring = ring_next(&s->channels, ring)) {
+ item = SPICE_CONTAINEROF(ring, struct channel, link);
+ if (spice_channel_get_channel_type(item->channel) == type) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
/* ------------------------------------------------------------------ */
/* private functions */
diff --git a/gtk/spice-session.h b/gtk/spice-session.h
index a07d297..72effce 100644
--- a/gtk/spice-session.h
+++ b/gtk/spice-session.h
@@ -92,6 +92,7 @@ gboolean spice_session_connect(SpiceSession *session);
gboolean spice_session_open_fd(SpiceSession *session, int fd);
void spice_session_disconnect(SpiceSession *session);
GList *spice_session_get_channels(SpiceSession *session);
+gboolean spice_session_has_channel_type(SpiceSession *session, gint type);
G_END_DECLS
--
1.7.6.1
More information about the Spice-devel
mailing list