[Spice-devel] [PATCH v2 3/3] vdagent: support announce_capabilities
Hans de Goede
hdegoede at redhat.com
Mon Aug 30 03:30:47 PDT 2010
Ack.
On 08/30/2010 01:56 PM, Alon Levy wrote:
>
> diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
> index b1f47c0..4755b19 100644
> --- a/vdagent/vdagent.cpp
> +++ b/vdagent/vdagent.cpp
> @@ -37,6 +37,8 @@ private:
> VDAgent();
> void input_desktop_message_loop();
> bool handle_mouse_event(VDAgentMouseState* state);
> + bool handle_announce_capabilities(
> + VDAgentAnnounceCapabilities* announce_capabilities, uint32_t port);
> bool handle_mon_config(VDAgentMonitorsConfig* mon_config, uint32_t port);
> bool handle_clipboard(VDAgentClipboard* clipboard, uint32_t size);
> bool handle_display_config(VDAgentDisplayConfig* display_config, uint32_t port);
> @@ -56,6 +58,7 @@ private:
> bool send_input();
> void set_display_depth(uint32_t depth);
> void load_display_setting();
> + bool send_announce_capabilities(bool request);
>
> private:
> static VDAgent* _singleton;
> @@ -85,6 +88,9 @@ private:
> bool _display_setting_initialized;
> bool _logon_occured;
>
> + uint32_t *_client_caps;
> + uint32_t _client_caps_size;
> +
> VDLog* _log;
> };
>
> @@ -119,6 +125,8 @@ VDAgent::VDAgent()
> , _logon_desktop (false)
> , _display_setting_initialized (false)
> , _log (NULL)
> + , _client_caps(NULL)
> + , _client_caps_size(NULL)
> {
> TCHAR log_path[MAX_PATH];
> TCHAR temp_path[MAX_PATH];
> @@ -136,6 +144,9 @@ VDAgent::VDAgent()
> VDAgent::~VDAgent()
> {
> delete _log;
> + if (_client_caps != NULL) {
> + delete[] _client_caps;
> + }
> }
>
> DWORD WINAPI VDAgent::event_thread_proc(LPVOID param)
> @@ -210,6 +221,7 @@ bool VDAgent::run()
> delete _desktop_layout;
> return false;
> }
> + send_announce_capabilities(true);
> read_completion(0, 0,&_pipe_state.read.overlap);
> while (_running) {
> input_desktop_message_loop();
> @@ -522,6 +534,81 @@ void VDAgent::load_display_setting()
> _display_setting.load();
> }
>
> +bool VDAgent::send_announce_capabilities(bool request)
> +{
> + DWORD msg_size;
> + VDPipeMessage* caps_pipe_msg;
> + VDAgentMessage* caps_msg;
> + VDAgentAnnounceCapabilities* caps;
> + uint32_t caps_size;
> + uint32_t internal_msg_size = sizeof(VDAgentAnnounceCapabilities) + VD_AGENT_CAPS_BYTES;
> +
> + msg_size = VD_MESSAGE_HEADER_SIZE + internal_msg_size;
> + caps_pipe_msg = (VDPipeMessage*)write_lock(msg_size);
> + if (!caps_pipe_msg) {
> + return false;
> + }
> +
> + caps_size = VD_AGENT_CAPS_SIZE;
> + caps_pipe_msg->type = VD_AGENT_COMMAND;
> + caps_pipe_msg->opaque = VDP_CLIENT_PORT;
> + caps_pipe_msg->size = sizeof(VDAgentMessage) + internal_msg_size;
> + caps_msg = (VDAgentMessage*)caps_pipe_msg->data;
> + caps_msg->protocol = VD_AGENT_PROTOCOL;
> + caps_msg->type = VD_AGENT_ANNOUNCE_CAPABILITIES;
> + caps_msg->opaque = 0;
> + caps_msg->size = internal_msg_size;
> + caps = (VDAgentAnnounceCapabilities*)caps_msg->data;
> + caps->request = request;
> + caps->caps_size = caps_size;
> + memset(caps->caps, 0, caps->caps_size);
> + VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_MOUSE_STATE);
> + VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_MONITORS_CONFIG);
> + VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_REPLY);
> +#ifdef CLIPBOARD_ENABLED
> + VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CLIPBOARD);
> +#endif
> + VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_DISPLAY_CONFIG);
> + VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_ANNOUNCE_CAPABILITIES);
> + vd_printf("sending capabilities:");
> + for (uint32_t i = 0 ; i< caps->caps_size; ++i) {
> + vd_printf("%X", caps->caps[i]);
> + }
> + write_unlock(msg_size);
> + if (!_pending_write) {
> + write_completion(0, 0,&_pipe_state.write.overlap);
> + }
> + return true;
> +}
> +
> +bool VDAgent::handle_announce_capabilities(
> + VDAgentAnnounceCapabilities* announce_capabilities, uint32_t port)
> +{
> + /** Disable/enable any features that are not compatible with client capabilities.
> + */
> + vd_printf("got capabilities");
> + for (uint32_t i = 0 ; i< announce_capabilities->caps_size; ++i) {
> + vd_printf("%X", announce_capabilities->caps[i]);
> + }
> +
> + if (announce_capabilities->caps_size != _client_caps_size) {
> + if (_client_caps != NULL) {
> + delete[] _client_caps;
> + }
> + _client_caps = new uint32_t[announce_capabilities->caps_size];
> + ASSERT(_client_caps != NULL);
> + _client_caps_size = announce_capabilities->caps_size;
> + }
> + memcpy(_client_caps, announce_capabilities->caps,
> + sizeof(_client_caps[0]) * announce_capabilities->caps_size);
> +
> + if (announce_capabilities->request) {
> + send_announce_capabilities(false);
> + }
> +
> + return true;
> +}
> +
> bool VDAgent::handle_display_config(VDAgentDisplayConfig* display_config, uint32_t port)
> {
> DisplaySettingOptions disp_setting_opts;
> @@ -740,7 +827,13 @@ void VDAgent::dispatch_message(VDAgentMessage* msg, uint32_t port)
> if (!a->handle_display_config((VDAgentDisplayConfig*)msg->data, port)) {
> vd_printf("handle_display_config failed");
> a->_running = false;
> - }
> + }
> + break;
> + case VD_AGENT_ANNOUNCE_CAPABILITIES:
> + if (!a->handle_announce_capabilities((VDAgentAnnounceCapabilities*)msg->data, port)) {
> + vd_printf("handle_announce_capabilities failed");
> + a->_running = false;
> + }
> break;
> default:
> vd_printf("Unsupported message type %u size %u", msg->type, msg->size);
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
More information about the Spice-devel
mailing list