<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="Generator" content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style></head><body lang="CS" link="blue" vlink="#954F72"><div class="WordSection1"><p class="MsoNormal">Hi.</p><p class="MsoNormal"> </p><div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm"><p class="MsoNormal" style="border:none;padding:0cm"><b>From: </b><a href="mailto:lists@victortoso.com">Victor Toso</a><br><b>Sent: </b>pátek 8. dubna 2016 9:12<br><b>To: </b><a href="mailto:lvenhoda@redhat.com">Lukas Venhoda</a><br><b>Cc: </b><a href="mailto:spice-devel@lists.freedesktop.org">spice-devel@lists.freedesktop.org</a><br><b>Subject: </b>Re: [Spice-devel] [phodav PATCH 3/3 v5] spice-webdavd-windows: Dismount shared folder on service stop</p></div><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif"> </span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">> @@ -749,6 +749,7 @@ typedef enum _MapDriveEnum<br>><br>>  typedef struct _MapDriveData<br>>  {<br>> +  gchar * drive_letter;<br><br>I think it is fine to use a gchar instead of gchar* here..</span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif"> </span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">   -I’m using gchar* so that it points to the same gchar as ServiceData.</span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">   -Since it is set in a different thread, I can’t use gchar, and copy the data back to ServiceData.<br><br>>    GCancellable * cancel_map;<br>>  } MapDriveData;<br>><br>>  static void<br>> +unmap_drive(const gchar drive_letter)<br>> +{<br>> +  gchar local_name[MAX_DRIVE_LETTER_SIZE];<br>> +  guint32 errn;<br>> +<br>> +  g_snprintf(local_name, MAX_DRIVE_LETTER_SIZE, "%c:", drive_letter);<br>> +  errn = WNetCancelConnection2(local_name, CONNECT_UPDATE_PROFILE, TRUE);<br>> +<br>> +  if (errn == NO_ERROR) {<br>> +    g_debug ("Shared folder unmapped succesfully");<br>> +  } else if (errn == ERROR_NOT_CONNECTED) {<br>> +    g_debug ("Drive %c is not connected", drive_letter);<br>> +  } else {<br>> +    g_warning ("map_drive error %d", errn);<br><br>I'm guessing we can't get a string for the error?</span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif"> </span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">   -Glib doesn’t support this kind of error code</span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">   -Usually with Windows error codes we call GetLastError, which returns a code,</span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">   -and pass it to g_win32_error_message() to translate i to a string.</span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">   -With WNet code, we already have the error code, and need to pass it to</span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">   -WNetGetLastError, which doesn’t handle strings correctly, and needs</span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">   -a complete wrapper function for allocation, and reallocation of the error string.<br><br>> +  }<br>> +<br>> +  return;<br><br>No need to return here<br><br>> +//Parameter service_data is only used on windows when started as a service<br>>  static void<br>> -run_service (void)<br>> +run_service (ServiceData * service_data G_GNUC_UNUSED)<br><br>ServiceData is defined inside the #ifdef windows but it is being used on linux<br>as well here, making the build fail on linux with<br><br><gcc><br>    spice/spice-webdavd.c: At top level:<br>    spice/spice-webdavd.c:926:14: error: unknown type name ‘ServiceData’<br>     run_service (ServiceData * service_data G_GNUC_UNUSED)<br></gcc><br><br>My suggestion is to create all the structures that you need together before the<br>functions (top of the file). For the error above, I guess is enough to put the<br>drive_letter field with #ifdef... or don't. It'll never be used anyway by the<br>linux daemon.<br><br>I'll do some tests later on, I think we need to open a few bugs that could be<br>closed once that this is integrated with spice-vdagent.<br><br>Thanks for your work on this,<br>  toso<br><br></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">   -My bad. I used a gpointer before, but then I thought, that I will be using the structure anyway.</span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">   -I can either define the structure outside ifdef, and ifdef the contents, or fallback to the gpopinter.</span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">   -I think that gpointer would be better suited.</span></p><div style="border:none;border-bottom:solid windowtext 1.0pt;padding:0cm 0cm 1.0pt 0cm"><p class="MsoNormal" style="border:none;padding:0cm"><span style="font-size:12.0pt;font-family:"Times New Roman",serif"> </span></p></div><p class="MsoNormal">Lukas Venhoda</p></div></body></html>