static void channel_new(SpiceSession *s, SpiceChannel *channel, gpointer data) { struct spice_context *ctx = data; int id; g_object_get(channel, "channel-id", &id, NULL); ctx->channels++; SPICE_DEBUG("new channel (#%d)", id); g_signal_connect(channel, "open-fd", G_CALLBACK(channel_open_fd), ctx); if (SPICE_IS_MAIN_CHANNEL(channel)) { SPICE_DEBUG("new main channel"); g_signal_connect(channel, "channel-event", G_CALLBACK(main_channel_event), ctx); } if (SPICE_IS_DISPLAY_CHANNEL(channel)) { if (ctx->display != NULL) return; SPICE_DEBUG("new display channel (#%d)", id); ctx->display = spice_display_new(ctx, id); ctx->display_channel = id; } if (SPICE_IS_PLAYBACK_CHANNEL(channel)) { SPICE_DEBUG("new audio channel"); spice_audio_get(s, NULL); } }
static void channel_destroy(SpiceSession *s, SpiceChannel *channel, gpointer data) { SpiceDisplay *display = data; SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display); int id; g_object_get(channel, "channel-id", &id, NULL); SPICE_DEBUG("channel_destroy %d", id); if (SPICE_IS_MAIN_CHANNEL(channel)) { disconnect_main(display); return; } if (SPICE_IS_DISPLAY_CHANNEL(channel)) { if (id != d->channel_id) return; disconnect_display(display); return; } if (SPICE_IS_CURSOR_CHANNEL(channel)) { if (id != d->channel_id) return; disconnect_cursor(display); return; } if (SPICE_IS_INPUTS_CHANNEL(channel)) { d->inputs = NULL; return; } }
static void channel_new(SpiceSession *s, SpiceChannel *channel, gpointer data) { //__android_log_write(ANDROID_LOG_DEBUG, TAG, "channel_new"); SpiceDisplay *display = data; SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display); int id; g_object_get(channel, "channel-id", &id, NULL); if (SPICE_IS_MAIN_CHANNEL(channel)) { d->main = SPICE_MAIN_CHANNEL(channel); spice_g_signal_connect_object(channel, "main-mouse-update", G_CALLBACK(update_mouse_mode), display, 0); update_mouse_mode(channel, display); // TODO: For now, connect to this signal with a callback that disables // any secondary displays that crop up. g_signal_connect(channel, "main-agent-update", G_CALLBACK(disable_secondary_displays), display); return; } if (SPICE_IS_DISPLAY_CHANNEL(channel)) { if (id != d->channel_id) return; d->display = channel; g_signal_connect(channel, "display-primary-create", G_CALLBACK(primary_create), display); g_signal_connect(channel, "display-primary-destroy", G_CALLBACK(primary_destroy), display); g_signal_connect(channel, "display-invalidate", G_CALLBACK(invalidate), display); spice_channel_connect(channel); return; } if (SPICE_IS_CURSOR_CHANNEL(channel)) { if (id != d->channel_id) return; d->cursor = SPICE_CURSOR_CHANNEL(channel); g_signal_connect(channel, "cursor-set", G_CALLBACK(cursor_set), display); g_signal_connect(channel, "cursor-hide", G_CALLBACK(cursor_hide), display); g_signal_connect(channel, "cursor-reset", G_CALLBACK(cursor_reset), display); spice_channel_connect(channel); return; } if (SPICE_IS_INPUTS_CHANNEL(channel)) { d->inputs = SPICE_INPUTS_CHANNEL(channel); spice_channel_connect(channel); return; } }
static void channel_new(SpiceSession *s, SpiceChannel *channel, gpointer *data) { int id; if (!SPICE_IS_DISPLAY_CHANNEL(channel)) return; g_object_get(channel, "channel-id", &id, NULL); if (id != 0) return; g_signal_connect(channel, "display-primary-create", G_CALLBACK(primary_create), NULL); g_signal_connect(channel, "display-invalidate", G_CALLBACK(invalidate), NULL); spice_channel_connect(channel); }
static void channel_destroy(SpiceSession *s, SpiceChannel *channel, gpointer data) { __android_log_write(ANDROID_LOG_INFO, "android-spice", "channel_destroy called"); spice_connection *conn = data; int id; g_object_get(channel, "channel-id", &id, NULL); if (SPICE_IS_MAIN_CHANNEL(channel)) { SPICE_DEBUG("zap main channel"); conn->main = NULL; } if (SPICE_IS_DISPLAY_CHANNEL(channel)) { if (id >= SPICE_N_ELEMENTS(conn->wins)) return; if (conn->wins[id] == NULL) return; SPICE_DEBUG("zap display channel (#%d)", id); destroy_spice_window(conn->wins[id]); conn->wins[id] = NULL; } if (SPICE_IS_PLAYBACK_CHANNEL(channel)) { SPICE_DEBUG("zap audio channel"); } if (SPICE_IS_USBREDIR_CHANNEL(channel)) { __android_log_write(ANDROID_LOG_INFO, "android-spice", "Destroyed USB channel."); //update_auto_usbredir_sensitive(conn); } //if (SPICE_IS_PORT_CHANNEL(channel)) { // if (SPICE_PORT_CHANNEL(channel) == stdin_port) // stdin_port = NULL; //} conn->channels--; char buf[100]; snprintf (buf, 100, "Number of channels: %d", conn->channels); __android_log_write(ANDROID_LOG_INFO, "android-spice", buf); if (conn->channels > 0) { return; } connection_destroy(conn); }
static void channel_new(SpiceSession *s, SpiceChannel *channel, gpointer *data) { int id; if (SPICE_IS_MAIN_CHANNEL(channel)) { SPICE_DEBUG("new main channel"); g_signal_connect(channel, "channel-event", G_CALLBACK(main_channel_event), data); } if (SPICE_IS_DISPLAY_CHANNEL(channel)) { g_object_get(channel, "channel-id", &id, NULL); if (id != 0) return; } spice_channel_connect(channel); }
static void channel_new(SpiceSession *s, SpiceChannel *c, gpointer *data) { int id = 0; g_object_get(c, "channel-id", &id, NULL); if (SPICE_IS_MAIN_CHANNEL(c)) { fprintf(stdout, "new main channel\n"); return; } if (SPICE_IS_DISPLAY_CHANNEL(c)) { fprintf(stdout, "new display channel (#%d), creating window\n", id); spice_display = spice_display_new(s, id); gtk_container_add(GTK_CONTAINER(main_window), GTK_WIDGET(spice_display)); gtk_widget_show_all(main_window); return; } }
static void channel_destroy(SpiceSession *s, SpiceChannel *channel, gpointer data) { //__android_log_write(ANDROID_LOG_DEBUG, TAG, "channel_destroy called"); struct spice_context *ctx = data; int id; g_object_get(channel, "channel-id", &id, NULL); if (SPICE_IS_DISPLAY_CHANNEL(channel)) { if (ctx->display && ctx->display_channel == id) { SPICE_DEBUG("zap display channel (#%d)", id); g_object_unref(ctx->display); ctx->display = NULL; } } ctx->channels--; //__android_log_print(ANDROID_LOG_DEBUG, TAG, "Number of channels: %d", ctx->channels); if (ctx->channels == 0) { g_idle_add_full(G_PRIORITY_DEFAULT, destroy_context_callback, ctx, NULL); } }
static void channel_new(SpiceSession *s, SpiceChannel *channel, gpointer data) { __android_log_write(6, "android-spice", "channel_new"); SpiceDisplay *display = data; SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display); int id; g_object_get(channel, "channel-id", &id, NULL); if (SPICE_IS_MAIN_CHANNEL(channel)) { d->main = SPICE_MAIN_CHANNEL(channel); spice_g_signal_connect_object(channel, "main-mouse-update", G_CALLBACK(update_mouse_mode), display, 0); update_mouse_mode(channel, display); // TODO: For now, connect to this signal with a callback that disables // any secondary displays that crop up. g_signal_connect(channel, "main-agent-update", G_CALLBACK(disable_secondary_displays), display); return; } if (SPICE_IS_DISPLAY_CHANNEL(channel)) { if (id != d->channel_id) return; d->display = channel; g_signal_connect(channel, "display-primary-create", G_CALLBACK(primary_create), display); g_signal_connect(channel, "display-primary-destroy", G_CALLBACK(primary_destroy), display); g_signal_connect(channel, "display-invalidate", G_CALLBACK(invalidate), display); g_signal_connect(channel, "display-mark", G_CALLBACK(mark), display); spice_channel_connect(channel); return; } //if (SPICE_IS_CURSOR_CHANNEL(channel)) { // if (id != d->channel_id) // return; // d->cursor = SPICE_CURSOR_CHANNEL(channel); // g_signal_connect(channel, "cursor-set", // G_CALLBACK(cursor_set), display); // g_signal_connect(channel, "cursor-move", // G_CALLBACK(cursor_move), display); // g_signal_connect(channel, "cursor-hide", // G_CALLBACK(cursor_hide), display); // g_signal_connect(channel, "cursor-reset", // G_CALLBACK(cursor_reset), display); // spice_channel_connect(channel); // return; //} if (SPICE_IS_INPUTS_CHANNEL(channel)) { d->inputs = SPICE_INPUTS_CHANNEL(channel); spice_channel_connect(channel); //sync_keyboard_lock_modifiers(display); return; } #ifdef USE_SMARTCARD if (SPICE_IS_SMARTCARD_CHANNEL(channel)) { d->smartcard = SPICE_SMARTCARD_CHANNEL(channel); spice_channel_connect(channel); return; } #endif return; }
static void channel_new(SpiceSession *s, SpiceChannel *channel, gpointer data) { spice_connection *conn = data; int id; g_object_get(channel, "channel-id", &id, NULL); conn->channels++; SPICE_DEBUG("new channel (#%d)", id); if (SPICE_IS_MAIN_CHANNEL(channel)) { SPICE_DEBUG("new main channel"); conn->main = SPICE_MAIN_CHANNEL(channel); g_signal_connect(channel, "channel-event", G_CALLBACK(main_channel_event), conn); //g_signal_connect(channel, "main-mouse-update", // G_CALLBACK(main_mouse_update), conn); //g_signal_connect(channel, "main-agent-update", // G_CALLBACK(main_agent_update), conn); //main_mouse_update(channel, conn); //main_agent_update(channel, conn); } if (SPICE_IS_DISPLAY_CHANNEL(channel)) { if (id >= SPICE_N_ELEMENTS(conn->wins)) return; if (conn->wins[id] != NULL) return; SPICE_DEBUG("new display channel (#%d)", id); conn->wins[id] = create_spice_window(conn, channel, id); //g_signal_connect(channel, "display-mark", // G_CALLBACK(display_mark), conn->wins[id]); //update_auto_usbredir_sensitive(conn); } if (SPICE_IS_INPUTS_CHANNEL(channel)) { SPICE_DEBUG("new inputs channel"); //g_signal_connect(channel, "inputs-modifiers", // G_CALLBACK(inputs_modifiers), conn); } if (soundEnabled && SPICE_IS_PLAYBACK_CHANNEL(channel)) { SPICE_DEBUG("new audio channel"); conn->audio = spice_audio_get(s, NULL); } if (SPICE_IS_USBREDIR_CHANNEL(channel)) { __android_log_write(ANDROID_LOG_INFO, "android-spice", "Created USB channel, attempting to add devices"); SpiceUsbDeviceManager *manager = spice_usb_device_manager_get(s, NULL); GPtrArray *devices = spice_usb_device_manager_get_devices(manager); if (devices) { for (int i = 0; i < devices->len; i++) { __android_log_write(ANDROID_LOG_INFO, "android-spicy", "Devices found, connecting..."); usb_device_added(manager, g_ptr_array_index(devices, i), NULL); } g_ptr_array_unref(devices); } } //if (SPICE_IS_PORT_CHANNEL(channel)) { // g_signal_connect(channel, "notify::port-opened", // G_CALLBACK(port_opened), conn); // g_signal_connect(channel, "port-data", // G_CALLBACK(port_data), conn); // spice_channel_connect(channel); //} }