The agent will send an information about its version to the client when VD_AGENT_CAP_GUEST_VERSION is set. --- depends on http://lists.freedesktop.org/archives/spice-devel/2014-October/017669.html --- vdagent/vdagent.cpp | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp index aa44383..2e14f17 100644 --- a/vdagent/vdagent.cpp +++ b/vdagent/vdagent.cpp @@ -14,7 +14,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ - +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif #include "vdcommon.h" #include "desktop_layout.h" #include "display_setting.h" @@ -122,6 +124,7 @@ private: void set_display_depth(uint32_t depth); void load_display_setting(); bool send_announce_capabilities(bool request); + void send_version(); void cleanup_in_msg(); void cleanup(); @@ -835,12 +838,48 @@ bool VDAgent::handle_announce_capabilities(VDAgentAnnounceCapabilities* announce _client_caps_size = caps_size; } memcpy(_client_caps, announce_capabilities->caps, sizeof(_client_caps[0]) * caps_size); + send_version(); if (announce_capabilities->request) { return send_announce_capabilities(false); } return true; } +void VDAgent::send_version() +{ + wchar_t *tmp; + char *version_utf8; + int wlen, len; + + if (VD_AGENT_HAS_CAPABILITY(_client_caps, _client_caps_size, VD_AGENT_CAP_GUEST_VERSION)) { + /* conversion from locale to utf8 */ + if (!(wlen = MultiByteToWideChar(CP_ACP, 0, VERSION, strlen(VERSION), NULL, 0))) + return; + tmp = new wchar_t[wlen+1]; + tmp[wlen] = 0; + if (!(wlen = MultiByteToWideChar(CP_ACP, 0, VERSION, strlen(VERSION), tmp, wlen))) { + delete [] tmp; + return; + } + if (!(len = WideCharToMultiByte(CP_UTF8, 0, tmp, wlen, NULL, 0, NULL, NULL))) { + delete [] tmp; + return; + } + version_utf8 = new char[len+1]; + version_utf8[len] = 0; + if (!(len = WideCharToMultiByte(CP_UTF8, 0, tmp, wlen, version_utf8, len, NULL, NULL))) { + delete [] tmp; + delete [] version_utf8; + return; + } + delete [] tmp; + + vd_printf("Sending agent version"); + write_message(VD_AGENT_GUEST_VERSION, len + 1, version_utf8); + delete[] version_utf8; + } +} + bool VDAgent::handle_display_config(VDAgentDisplayConfig* display_config, uint32_t port) { DisplaySettingOptions disp_setting_opts; -- 1.9.3 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel