void RedClient::send_agent_announce_capabilities(bool request) { Message* message = new Message(SPICE_MSGC_MAIN_AGENT_DATA); VDAgentMessage* msg = (VDAgentMessage*) spice_marshaller_reserve_space(message->marshaller(), sizeof(VDAgentMessage)); VDAgentAnnounceCapabilities* caps; msg->protocol = VD_AGENT_PROTOCOL; msg->type = VD_AGENT_ANNOUNCE_CAPABILITIES; msg->opaque = 0; msg->size = sizeof(VDAgentAnnounceCapabilities) + VD_AGENT_CAPS_BYTES; caps = (VDAgentAnnounceCapabilities*) spice_marshaller_reserve_space(message->marshaller(), msg->size); caps->request = request; memset(caps->caps, 0, VD_AGENT_CAPS_BYTES); VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_MOUSE_STATE); VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_MONITORS_CONFIG); VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_REPLY); VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_DISPLAY_CONFIG); VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_CLIPBOARD_BY_DEMAND); ASSERT(_agent_tokens) _agent_tokens--; post_message(message); }
void RedClient::send_agent_monitors_config() { AutoRef<MonitorsQuery > qury(new MonitorsQuery()); push_event(*qury); (*qury)->wait(); if (!(*qury)->success()) { THROW(" monitors query failed"); } double min_distance = INFINITY; int dx = 0; int dy = 0; int i; std::vector<MonitorInfo>& monitors = (*qury)->get_monitors(); std::vector<MonitorInfo>::iterator iter = monitors.begin(); for (; iter != monitors.end(); iter++) { double distance = sqrt(pow((double)(*iter).position.x, 2) + pow((double)(*iter).position.y, 2)); if (distance < min_distance) { min_distance = distance; dx = -(*iter).position.x; dy = -(*iter).position.y; } } Message* message = new Message(SPICE_MSGC_MAIN_AGENT_DATA); VDAgentMessage* msg = (VDAgentMessage*) spice_marshaller_reserve_space(message->marshaller(), sizeof(VDAgentMessage)); msg->protocol = VD_AGENT_PROTOCOL; msg->type = VD_AGENT_MONITORS_CONFIG; msg->opaque = 0; msg->size = sizeof(VDAgentMonitorsConfig) + monitors.size() * sizeof(VDAgentMonConfig); VDAgentMonitorsConfig* mon_config = (VDAgentMonitorsConfig*) spice_marshaller_reserve_space(message->marshaller(), sizeof(VDAgentMonitorsConfig) + monitors.size() * sizeof(VDAgentMonConfig)); mon_config->num_of_monitors = monitors.size(); mon_config->flags = 0; if (Platform::is_monitors_pos_valid()) { mon_config->flags = VD_AGENT_CONFIG_MONITORS_FLAG_USE_POS; } for (iter = monitors.begin(), i = 0; iter != monitors.end(); iter++, i++) { mon_config->monitors[i].depth = (*iter).depth; mon_config->monitors[i].width = (*iter).size.x; mon_config->monitors[i].height = (*iter).size.y; mon_config->monitors[i].x = (*iter).position.x + dx; mon_config->monitors[i].y = (*iter).position.y + dy; } ASSERT(_agent_tokens) _agent_tokens--; post_message(message); _agent_mon_config_sent = true; _agent_reply_wait_type = VD_AGENT_MONITORS_CONFIG; }
void *spice_marshaller_add_int8(SpiceMarshaller *m, int8_t v) { uint8_t *ptr; ptr = spice_marshaller_reserve_space(m, sizeof(int8_t)); write_int8(ptr, v); return (void *)ptr; }
uint8_t *spice_marshaller_add(SpiceMarshaller *m, const uint8_t *data, size_t size) { uint8_t *ptr; ptr = spice_marshaller_reserve_space(m, size); memcpy(ptr, data, size); return ptr; }
void RedClient::send_agent_display_config() { Message* message = new Message(SPICE_MSGC_MAIN_AGENT_DATA); VDAgentMessage* msg = (VDAgentMessage*) spice_marshaller_reserve_space(message->marshaller(), sizeof(VDAgentMessage)); VDAgentDisplayConfig* disp_config; DBG(0,""); msg->protocol = VD_AGENT_PROTOCOL; msg->type = VD_AGENT_DISPLAY_CONFIG; msg->opaque = 0; msg->size = sizeof(VDAgentDisplayConfig); disp_config = (VDAgentDisplayConfig*) spice_marshaller_reserve_space(message->marshaller(), sizeof(VDAgentDisplayConfig)); disp_config->flags = 0; disp_config->depth = 0; if (_display_setting._disable_wallpaper) { disp_config->flags |= VD_AGENT_DISPLAY_CONFIG_FLAG_DISABLE_WALLPAPER; } if (_display_setting._disable_font_smooth) { disp_config->flags |= VD_AGENT_DISPLAY_CONFIG_FLAG_DISABLE_FONT_SMOOTH; } if (_display_setting._disable_animation) { disp_config->flags |= VD_AGENT_DISPLAY_CONFIG_FLAG_DISABLE_ANIMATION; } if (_display_setting._set_color_depth) { disp_config->flags |= VD_AGENT_DISPLAY_CONFIG_FLAG_SET_COLOR_DEPTH; disp_config->depth = _display_setting._color_depth; } ASSERT(_agent_tokens) _agent_tokens--; post_message(message); _agent_disp_config_sent = true; if (!_display_setting.is_empty()) { _agent_reply_wait_type = VD_AGENT_DISPLAY_CONFIG; } }
SpiceMarshaller *spice_marshaller_get_ptr_submarshaller(SpiceMarshaller *m, int is_64bit) { SpiceMarshaller *m2; uint8_t *p; int size; size = is_64bit ? 8 : 4; p = spice_marshaller_reserve_space(m, size); memset(p, 0, size); m2 = spice_marshaller_get_submarshaller(m); m2->pointer_ref.marshaller = m; m2->pointer_ref.item_nr = m->n_items - 1; m2->pointer_ref.offset = m->items[m->n_items - 1].len - size; m2->pointer_ref.is_64bit = is_64bit; return m2; }
void RedClient::do_send_agent_clipboard() { uint32_t size; while (_agent_tokens && (size = MIN(VD_AGENT_MAX_DATA_SIZE, _agent_out_msg_size - _agent_out_msg_pos))) { Message* message = new Message(SPICE_MSGC_MAIN_AGENT_DATA); void* data = spice_marshaller_reserve_space(message->marshaller(), size); memcpy(data, (uint8_t*)_agent_out_msg + _agent_out_msg_pos, size); _agent_tokens--; post_message(message); _agent_out_msg_pos += size; if (_agent_out_msg_pos == _agent_out_msg_size) { delete[] (uint8_t *)_agent_out_msg; _agent_out_msg = NULL; _agent_out_msg_size = 0; _agent_out_msg_pos = 0; } } }
G_GNUC_INTERNAL spice_msg_out *spice_msg_out_new(SpiceChannel *channel, int type) { spice_channel *c = channel->priv; spice_msg_out *out; g_return_val_if_fail(c != NULL, NULL); out = spice_new0(spice_msg_out, 1); out->refcount = 1; out->channel = channel; out->marshallers = c->marshallers; out->marshaller = spice_marshaller_new(); out->header = (SpiceDataHeader *) spice_marshaller_reserve_space(out->marshaller, sizeof(SpiceDataHeader)); spice_marshaller_set_base(out->marshaller, sizeof(SpiceDataHeader)); out->header->serial = c->serial++; out->header->type = type; out->header->sub_list = 0; return out; }
void RedClient::send_agent_clipboard_message(uint32_t message_type, uint32_t size, void* data) { if (!_agent_connected) return; if (!VD_AGENT_HAS_CAPABILITY(_agent_caps, _agent_caps_size, VD_AGENT_CAP_CLIPBOARD_BY_DEMAND)) return; Message* message = new Message(SPICE_MSGC_MAIN_AGENT_DATA); VDAgentMessage* msg = (VDAgentMessage*) spice_marshaller_reserve_space(message->marshaller(), sizeof(VDAgentMessage) + size); msg->protocol = VD_AGENT_PROTOCOL; msg->type = message_type; msg->opaque = 0; msg->size = size; if (size && data) { memcpy(msg->data, data, size); } ASSERT(_agent_tokens) _agent_tokens--; post_message(message); }