/**
 * spice_display_new:
 * @session: a #SpiceSession
 * @id: the display channel ID to associate with #SpiceDisplay
 *
 * Returns: a new #SpiceDisplay widget.
 **/
SpiceDisplay *spice_display_new(SpiceSession *session, int id)
{
    SpiceDisplay *display;
    SpiceDisplayPrivate *d;
    GList *list;
    GList *it;

    display = g_object_new(SPICE_TYPE_DISPLAY, NULL);
    d = SPICE_DISPLAY_GET_PRIVATE(display);
    d->session = g_object_ref(session);
    d->channel_id = id;
    SPICE_DEBUG("channel_id:%d",d->channel_id);

    g_signal_connect(session, "channel-new",
                     G_CALLBACK(channel_new), display);
    g_signal_connect(session, "channel-destroy",
                     G_CALLBACK(channel_destroy), display);
    list = spice_session_get_channels(session);
    for (it = g_list_first(list); it != NULL; it = g_list_next(it)) {
        channel_new(session, it->data, (gpointer*)display);
    }
    g_list_free(list);

    return display;
}
예제 #2
0
static GObject *
spice_gtk_session_constructor(GType                  gtype,
                              guint                  n_properties,
                              GObjectConstructParam *properties)
{
    GObject *obj;
    SpiceGtkSession *self;
    SpiceGtkSessionPrivate *s;
    GList *list;
    GList *it;

    {
        /* Always chain up to the parent constructor */
        GObjectClass *parent_class;
        parent_class = G_OBJECT_CLASS(spice_gtk_session_parent_class);
        obj = parent_class->constructor(gtype, n_properties, properties);
    }

    self = SPICE_GTK_SESSION(obj);
    s = self->priv;
    if (!s->session)
        g_error("SpiceGtKSession constructed without a session");

    g_signal_connect(s->session, "channel-new",
                     G_CALLBACK(channel_new), self);
    g_signal_connect(s->session, "channel-destroy",
                     G_CALLBACK(channel_destroy), self);
    list = spice_session_get_channels(s->session);
    for (it = g_list_first(list); it != NULL; it = g_list_next(it)) {
        channel_new(s->session, it->data, (gpointer*)self);
    }
    g_list_free(list);

    return obj;
}
예제 #3
0
int main(int argc, char *argv[])
{
    GError *error = NULL;
    GOptionContext *context;

    signal(SIGINT, signal_handler);

    /* parse opts */
    context = g_option_context_new(NULL);
    g_option_context_set_summary(context, "A Spice client used for testing and measurements.");
    g_option_context_set_description(context, "Report bugs to " PACKAGE_BUGREPORT ".");
    g_option_context_set_main_group(context, spice_cmdline_get_option_group());
    g_option_context_add_main_entries(context, app_entries, NULL);
    if (!g_option_context_parse (context, &argc, &argv, &error)) {
        g_print("option parsing failed: %s\n", error->message);
        exit(1);
    }

    if (version) {
        g_print("spicy-stats " PACKAGE_VERSION "\n");
        exit(0);
    }

    mainloop = g_main_loop_new(NULL, false);

    session = spice_session_new();
    g_signal_connect(session, "channel-new",
                     G_CALLBACK(channel_new), NULL);
    spice_cmdline_session_setup(session);

    if (!spice_session_connect(session)) {
        fprintf(stderr, "spice_session_connect failed\n");
        exit(1);
    }

    g_main_loop_run(mainloop);
    {
        GList *iter, *list = spice_session_get_channels(session);
        gulong total_read_bytes;
        gint  channel_type;
        printf("total bytes read:\n");
        for (iter = list ; iter ; iter = iter->next) {
            g_object_get(iter->data,
                "total-read-bytes", &total_read_bytes,
                "channel-type", &channel_type,
                NULL);
            printf("%s: %lu\n",
                   spice_channel_type_to_string(channel_type),
                   total_read_bytes);
        }
        g_list_free(list);
    }
    return 0;
}
static void virt_viewer_session_spice_clear_displays(VirtViewerSessionSpice *self)
{
    SpiceSession *session = self->priv->session;
    GList *l;
    GList *channels;

    channels = spice_session_get_channels(session);
    for (l = channels; l != NULL; l = l->next) {
        SpiceChannel *channel = SPICE_CHANNEL(l->data);

        g_object_set_data(G_OBJECT(channel), "virt-viewer-displays", NULL);
    }
    g_list_free(channels);
    virt_viewer_session_clear_displays(VIRT_VIEWER_SESSION(self));
}