<div dir="ltr">Hi,<div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jul 29, 2013 at 4:43 AM, Fedor Lyakhov <span dir="ltr"><<a href="mailto:fedor.lyakhov@gmail.com" target="_blank">fedor.lyakhov@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">---<br>
 src/vdagentd-proto-strings.h |  1 +<br>
 src/vdagentd-proto.h         |  3 ++-<br>
 src/vdagentd.c               | 38 ++++++++++++++++++++++++++++++++++++++<br>
 3 files changed, 41 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/src/vdagentd-proto-strings.h b/src/vdagentd-proto-strings.h<br>
index e76cb3b..7ea7195 100644<br>
--- a/src/vdagentd-proto-strings.h<br>
+++ b/src/vdagentd-proto-strings.h<br>
@@ -34,6 +34,7 @@ static const char * const vdagentd_messages[] = {<br>
         "file xfer status",<br>
         "file xfer data",<br>
         "client disconnected",<br>
+        "display config"<br></blockquote><div>Adding a comma at the end will be better, so next time someone don't need to change this line when they add something.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

 };<br>
<br>
 #endif<br>
diff --git a/src/vdagentd-proto.h b/src/vdagentd-proto.h<br>
index 25e6a36..6a09e49 100644<br>
--- a/src/vdagentd-proto.h<br>
+++ b/src/vdagentd-proto.h<br>
@@ -39,7 +39,8 @@ enum {<br>
     VDAGENTD_FILE_XFER_START,<br>
     VDAGENTD_FILE_XFER_STATUS,<br>
     VDAGENTD_FILE_XFER_DATA,<br>
-    VDAGENTD_CLIENT_DISCONNECTED,  /* daemon -> client */<br>
+    VDAGENTD_CLIENT_DISCONNECTED,  /* daemon -> client */<br>
+    VDAGENTD_DISPLAY_CONFIG, /* daemon -> client, VDAgentDisplayConfig */<br>
     VDAGENTD_NO_MESSAGES /* Must always be last */<br>
 };<br>
<br>
diff --git a/src/vdagentd.c b/src/vdagentd.c<br>
index f4cea44..c9df401 100644<br>
--- a/src/vdagentd.c<br>
+++ b/src/vdagentd.c<br>
@@ -91,6 +91,7 @@ static void send_capabilities(struct<br>
vdagent_virtio_port *vport,<br>
     caps->request = request;<br>
     VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_MOUSE_STATE);<br>
     VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_MONITORS_CONFIG);<br>
+    VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_DISPLAY_CONFIG);<br>
     VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_REPLY);<br>
     VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_CLIPBOARD_BY_DEMAND);<br>
     VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_CLIPBOARD_SELECTION);<br>
@@ -151,6 +152,38 @@ static void do_client_monitors(struct<br>
vdagent_virtio_port *vport, int port_nr,<br>
                               (uint8_t *)&reply, sizeof(reply));<br>
 }<br>
<br>
+static void do_client_display(struct vdagent_virtio_port *vport, int port_nr,<br>
+    VDAgentMessage *message_header, VDAgentDisplayConfig *disp)<br>
+{<br>
+    VDAgentReply reply;<br>
+    VDAgentDisplayConfig *display_config;<br>
+    uint32_t size;<br>
+<br>
+    size = sizeof(VDAgentDisplayConfig);<br>
+    if (message_header->size != size) {<br>
+        syslog(LOG_ERR, "invalid message size for VDAgentDisplayConfig");<br>
+        return;<br>
+    }<br>
+<br>
+    display_config = malloc(size);</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
+    if (!display_config) {<br>
+        syslog(LOG_ERR, "oom allocating display config");<br>
+        size = 0;<br>
+    }<br>
+    memcpy(display_config, disp, size);<br>
+<br>
+    /* Send display config to currently active agent */<br>
+    if (active_session_conn)<br>
+        udscs_write(active_session_conn, VDAGENTD_DISPLAY_CONFIG, 0, 0,<br>
+                    (uint8_t *)display_config, size);<br></blockquote><div>display_config will be leaked, why not just use the "disp"?</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

+<br>
+    /* Acknowledge reception of display config to spice server / client */<br>
+    reply.type  = VD_AGENT_DISPLAY_CONFIG;<br>
+    reply.error = VD_AGENT_SUCCESS;<br>
+    vdagent_virtio_port_write(vport, port_nr, VD_AGENT_REPLY, 0,<br>
+                              (uint8_t *)&reply, sizeof(reply));<br>
+}<br>
+<br>
 static void do_client_capabilities(struct vdagent_virtio_port *vport,<br>
     VDAgentMessage *message_header,<br>
     VDAgentAnnounceCapabilities *caps)<br>
@@ -330,6 +363,11 @@ int virtio_port_read_complete(<br>
         do_client_monitors(vport, port_nr, message_header,<br>
                     (VDAgentMonitorsConfig *)data);<br>
         break;<br>
+    case VD_AGENT_DISPLAY_CONFIG:<br>
+        if (message_header->size < sizeof(VDAgentDisplayConfig))<br>
+            goto size_error;<br>
+        do_client_display(vport, port_nr, message_header,<br>
+                    (VDAgentDisplayConfig *)data);<br>
     case VD_AGENT_ANNOUNCE_CAPABILITIES:<br>
         if (message_header->size < sizeof(VDAgentAnnounceCapabilities))<br>
             goto size_error;<br>
<span class=""><font color="#888888">--<br>
1.8.1.4<br>
_______________________________________________<br>
Spice-devel mailing list<br>
<a href="mailto:Spice-devel@lists.freedesktop.org">Spice-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/spice-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/spice-devel</a><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Best Regards,<div><br>Dunrong Huang <div><br><div>Homepage: <a href="http://mathslinux.org" target="_blank">http://mathslinux.org</a></div>
</div></div></div>
</div></div>