Update check uses IE's proxy settings
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1435 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
7e2b0ca40e
commit
68f61cc7f1
5 changed files with 57 additions and 8 deletions
|
@ -215,21 +215,32 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||||
int len;
|
int len;
|
||||||
char *response = (char *)GlobalAlloc(GPTR,RSZ);
|
char *response = (char *)GlobalAlloc(GPTR,RSZ);
|
||||||
char url[300];
|
char url[300];
|
||||||
JNL_HTTPGet get;
|
static char pbuf[8192];
|
||||||
|
char *p=NULL;
|
||||||
|
if (getProxyInfo(pbuf)) {
|
||||||
|
p=my_strstr(pbuf,"http=");
|
||||||
|
if (!p) p=pbuf;
|
||||||
|
else {
|
||||||
|
p+=5;
|
||||||
|
char *tp=my_strstr(p,";");
|
||||||
|
if (tp) *tp=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JNL_HTTPGet *get = new JNL_HTTPGet(JNL_CONNECTION_AUTODNS,16384,(p&&p[0])?p:NULL);;
|
||||||
JNL::open_socketlib();
|
JNL::open_socketlib();
|
||||||
lstrcpy(url,NSIS_UPDATE);
|
lstrcpy(url,NSIS_UPDATE);
|
||||||
lstrcat(url,g_sdata.brandingv);
|
lstrcat(url,g_sdata.brandingv);
|
||||||
lstrcpy(response,"0");
|
lstrcpy(response,"0");
|
||||||
get.addheader("User-Agent:Nullsoft Sex (Mozilla)");
|
get->addheader("User-Agent:Nullsoft Sex (Mozilla)");
|
||||||
get.addheader("Accept:*/*");
|
get->addheader("Accept:*/*");
|
||||||
get.connect(url);
|
get->connect(url);
|
||||||
while (1) {
|
while (1) {
|
||||||
int st=get.run();
|
int st=get->run();
|
||||||
if (st<0) break; //error
|
if (st<0) break; //error
|
||||||
if (get.get_status()==2) {
|
if (get->get_status()==2) {
|
||||||
if(len=get.bytes_available()) {
|
if(len=get->bytes_available()) {
|
||||||
if (len>RSZ) len=RSZ;
|
if (len>RSZ) len=RSZ;
|
||||||
len=get.get_bytes(response,len);
|
len=get->get_bytes(response,len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (st==1) break; //closed
|
if (st==1) break; //closed
|
||||||
|
|
|
@ -29,6 +29,22 @@ char *my_strrchr(const char *string, int c) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *my_strstr(char *i, char *s) {
|
||||||
|
if (lstrlen(i)>=lstrlen(s)) while (i[lstrlen(s)-1]) {
|
||||||
|
int l=lstrlen(s)+1;
|
||||||
|
char *ii=i;
|
||||||
|
char *is=s;
|
||||||
|
while (--l>0) {
|
||||||
|
if (*ii != *is) break;
|
||||||
|
ii++;
|
||||||
|
is++;
|
||||||
|
}
|
||||||
|
if (l==0) return i;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void *my_memset(void *dest, int c, size_t count) {
|
void *my_memset(void *dest, int c, size_t count) {
|
||||||
for (size_t i=0; i<count;i++) ((char*)dest)[i]=c;
|
for (size_t i=0; i<count;i++) ((char*)dest)[i]=c;
|
||||||
return dest;
|
return dest;
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#define NOCLIB_H
|
#define NOCLIB_H
|
||||||
|
|
||||||
// kickik's clib methods
|
// kickik's clib methods
|
||||||
|
char *my_strstr(char *i, char *s);
|
||||||
char *my_strrchr(const char *string, int c);
|
char *my_strrchr(const char *string, int c);
|
||||||
void *my_memset(void *dest, int c, size_t count);
|
void *my_memset(void *dest, int c, size_t count);
|
||||||
|
|
||||||
|
|
|
@ -313,3 +313,23 @@ void ShowDocs() {
|
||||||
if ((int)ShellExecute(g_sdata.hwnd,"open",pathf,NULL,NULL,SW_SHOWNORMAL)<=32)
|
if ((int)ShellExecute(g_sdata.hwnd,"open",pathf,NULL,NULL,SW_SHOWNORMAL)<=32)
|
||||||
ShellExecute(g_sdata.hwnd,"open",DOCPATH,NULL,NULL,SW_SHOWNORMAL);
|
ShellExecute(g_sdata.hwnd,"open",DOCPATH,NULL,NULL,SW_SHOWNORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getProxyInfo(char *out) {
|
||||||
|
DWORD v=0;
|
||||||
|
HKEY hKey;
|
||||||
|
if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",0,KEY_READ,&hKey) == ERROR_SUCCESS) {
|
||||||
|
DWORD l = 4;
|
||||||
|
DWORD t;
|
||||||
|
if (RegQueryValueEx(hKey,"ProxyEnable",NULL,&t,(unsigned char *)&v,&l) == ERROR_SUCCESS && t == REG_DWORD) {
|
||||||
|
l=8192;
|
||||||
|
if (RegQueryValueEx(hKey,"ProxyServer",NULL,&t,(unsigned char *)out,&l ) != ERROR_SUCCESS || t != REG_SZ) {
|
||||||
|
v=0;
|
||||||
|
*out=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else v=0;
|
||||||
|
out[8192-1]=0;
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
}
|
|
@ -38,5 +38,6 @@ void InitTooltips(HWND h);
|
||||||
void DestroyTooltips();
|
void DestroyTooltips();
|
||||||
void AddTip(HWND hWnd,LPSTR lpszToolTip);
|
void AddTip(HWND hWnd,LPSTR lpszToolTip);
|
||||||
void ShowDocs();
|
void ShowDocs();
|
||||||
|
int getProxyInfo(char *out);
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Add table
Add a link
Reference in a new issue