Hey

I implemented one of the missing options in InternetSetOption. Any
feedback about the way i implemented it would be appreciated. If it is
alright i will implement the other missing options too

regards
Victor Pelt
diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c
index f52103d..d1ec52a 100644
--- a/dlls/wininet/internet.c
+++ b/dlls/wininet/internet.c
@@ -2361,6 +2361,44 @@ BOOL WINAPI InternetQueryOptionA(HINTERN
     return INET_QueryOptionHelper(FALSE, hInternet, dwOption, lpBuffer, lpdwBufferLength);
 }
 
+/* Helper function to get the unix socket from a LPWININETHEADER */
+int INET_getSocketHelper(LPWININETHANDLEHEADER lpwhh) {
+  int nSocket = -1;
+
+  switch (lpwhh->htype) {
+  case WH_HFILE:
+    nSocket = ((LPWININETFILE)lpwhh)->nDataSocket;
+    break;
+  case WH_HHTTPSESSION:
+  case WH_HHTTPREQ:
+    nSocket = (&((LPWININETHTTPREQW)lpwhh)->netConnection)->socketFD;
+    break;
+  default:
+    ERR("Handle type isn't supported(%u)\n",lpwhh->htype);
+    break;
+  }
+
+  return nSocket;
+}
+
+/* Helper function to get the unix proticolflag from a LPWININETHEADER */
+int INET_getProtocolHelper(LPWININETHANDLEHEADER lpwhh){
+  int protocol = SOL_SOCKET;
+
+  switch (lpwhh->htype){
+  case WH_HHTTPSESSION:
+  case WH_HFILE: 
+  case WH_HHTTPREQ:
+    /* FIXME hardcode tcp protocol, maybe we should do something smarter here */
+    protocol = 6;
+    break;
+  default:
+    ERR("Handle type isn't supported(%u)\n",lpwhh->htype);
+    break;
+  }
+  return protocol;
+}
+
 
 /***********************************************************************
  *           InternetSetOptionW (WININET.@)
@@ -2447,7 +2485,18 @@ BOOL WINAPI InternetSetOptionW(HINTERNET
 	TRACE("Option INTERNET_OPTION_DISABLE_PASSPORT_AUTH: harmless stub, since not enabled\n");
 	break;
     case INTERNET_OPTION_RECEIVE_TIMEOUT:
-        FIXME("Option INTERNET_OPTION_RECEIVE_TIMEOUT: STUB\n");
+      {
+	unsigned long conns=*(unsigned long*)lpBuffer;
+	/* have HINTERNET hInternet , handle where to set the options */
+	int result = setsockopt(INET_getSocketHelper(lpwhh), INET_getProtocolHelper(lpwhh), SO_RCVTIMEO, lpBuffer, (int)sizeof(lpBuffer));
+
+	if (result == 0) {
+	  ret = TRUE;
+        } else {
+	  /* Translate the result in the right error to return */
+	  ret = FALSE;
+        }
+      }
         break;
     case INTERNET_OPTION_SEND_TIMEOUT:
         FIXME("Option INTERNET_OPTION_SEND_TIMEOUT: STUB\n");
@@ -2455,6 +2504,9 @@ BOOL WINAPI InternetSetOptionW(HINTERNET
     case INTERNET_OPTION_CONNECT_RETRIES:
         FIXME("Option INTERNET_OPTION_CONNECT_RETRIES: STUB\n");
         break;
+    case INTERNET_OPTION_CONTEXT_VALUE:
+	FIXME("Option INTERNET_OPTION_CONTEXT_VALUE; STUB\n");
+	break;
     default:
         FIXME("Option %ld STUB\n",dwOption);
         INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
diff --git a/dlls/wininet/internet.h b/dlls/wininet/internet.h
index 6df7e31..37cac89 100644
--- a/dlls/wininet/internet.h
+++ b/dlls/wininet/internet.h
@@ -494,4 +494,9 @@ typedef struct
     const char* name;
 } wininet_flag_info;
 
+/* Helper functions to get unix backend stuff based in windows handles (LPWININETHANDLEHEADER s) */
+int INET_getSocketHelper(LPWININETHANDLEHEADER);
+int INET_getProtocolHelper(LPWININETHANDLEHEADER);
+
 #endif /* _WINE_INTERNET_H_ */
+


Reply via email to