[PATCH] [vd_agent] fix bug: display error when dragging file with CJK characters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I submitted a patch several months ago about this issue,

I check it again, and find that the value of g_key_file_to_data(keyfile,...) is always utf-8,
for the value of g_uri_list_extract_uris() is utf8 urlencode.

So the display problem is caused by vd_agent, but how it displays depends on the
language of system, the following two screenshots show the difference:

---
 vdagent/file_xfer.cpp | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/vdagent/file_xfer.cpp b/vdagent/file_xfer.cpp
index e402eb2..6e70d63 100644
--- a/vdagent/file_xfer.cpp
+++ b/vdagent/file_xfer.cpp
@@ -46,6 +46,7 @@ void FileXfer::handle_start(VDAgentFileXferStartMessage* start,
     uint64_t file_size;
     HANDLE handle;
     AsUser as_user;
+    int wlen;

     status->id = start->id;
     status->result = VD_AGENT_FILE_XFER_STATUS_ERROR;
@@ -81,7 +82,14 @@ void FileXfer::handle_start(VDAgentFileXferStartMessage* start,

     strcat(file_path, "\\");
     strcat(file_path, file_name);
-    handle = CreateFileA(file_path, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL);
+    if((wlen = MultiByteToWideChar(CP_UTF8, 0, file_path, -1, NULL, 0)) == 0)
+        return;
+    TCHAR *wfile_path = (TCHAR*)malloc(sizeof(TCHAR) * (wlen + 1));
+    if (MultiByteToWideChar(CP_UTF8, 0, file_path, -1, wfile_path, wlen) == 0)
+        return;
+    handle = CreateFile(wfile_path, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL);
+    if (wfile_path)
+        free(wfile_path);
     if (handle == INVALID_HANDLE_VALUE) {
         vd_printf("failed creating %s %lu", file_path, GetLastError());
         return;
--
1.9.3


--
QSBDT0RFUiBGUk9NIFJJRVNUIE9GIENUU0VV
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]