[Spice-devel] [PATCH v2] client: add default agent capabilities

Hans de Goede hdegoede at redhat.com
Tue Aug 31 03:53:31 PDT 2010


Hi,

Sorry, but still no ack...

On 08/31/2010 12:42 PM, Alon Levy wrote:
> v2:
>   use new[]
>
> diff --git a/client/red_client.cpp b/client/red_client.cpp
> index 6c6e066..9a3b0ed 100644
> --- a/client/red_client.cpp
> +++ b/client/red_client.cpp
> @@ -75,6 +75,12 @@ private:
>       RedClient&  _client;
>   };
>
> +uint32_t default_agent_caps[] = {
> +    (1<<  VD_AGENT_CAP_MOUSE_STATE) |
> +    (1<<  VD_AGENT_CAP_MONITORS_CONFIG) |
> +    (1<<  VD_AGENT_CAP_REPLY)
> +    };
> +
>   void ClipboardEvent::response(AbstractProcessLoop&  events_loop)
>   {
>       static_cast<RedClient*>(events_loop.get_owner())->send_agent_clipboard();
> @@ -335,6 +341,9 @@ RedClient::RedClient(Application&  application)
>   {
>       MainChannelLoop* message_loop = static_cast<MainChannelLoop*>(get_message_handler());
>
> +    _agent_caps_size = SPICE_N_ELEMENTS(default_agent_caps);

I assume SPICE_N_ELEMENTS is the same as ARRAY_SIZE in the kernel, but you don't want
the array size, you want the highest bit number and then add 31 and divide by
32. Or better (and much easier) just make _agent_caps_size VD_AGENT_CAPS_SIZE,
this way it will already have the right size when talking to a client of the same
version avoiding a delete / new cycle.

> +    _agent_caps = new uint32_t[_agent_caps_size];
> +    memcpy(_agent_caps, default_agent_caps, _agent_caps_size);
>       message_loop->set_handler(SPICE_MSG_MIGRATE,&RedClient::handle_migrate);
>       message_loop->set_handler(SPICE_MSG_SET_ACK,&RedClient::handle_set_ack);
>       message_loop->set_handler(SPICE_MSG_PING,&RedClient::handle_ping);

Regards,

Hans


More information about the Spice-devel mailing list