Update check now uses its own thread. The messagebox is now modal. Also checks for alphas/betas. Adds new version string to messagebox.
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1437 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
1404987ad6
commit
64c9fe013b
2 changed files with 72 additions and 41 deletions
|
@ -211,47 +211,8 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||||
}
|
}
|
||||||
case IDM_UPDATE:
|
case IDM_UPDATE:
|
||||||
{
|
{
|
||||||
#define RSZ 5
|
DWORD dwThreadId;
|
||||||
int len;
|
CloseHandle(CreateThread(NULL,0,UpdateThread,(LPVOID)NULL,0,&dwThreadId));
|
||||||
char *response = (char *)GlobalAlloc(GPTR,RSZ);
|
|
||||||
char url[300];
|
|
||||||
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();
|
|
||||||
lstrcpy(url,NSIS_UPDATE);
|
|
||||||
lstrcat(url,g_sdata.brandingv);
|
|
||||||
lstrcpy(response,"0");
|
|
||||||
get->addheader("User-Agent:Nullsoft Sex (Mozilla)");
|
|
||||||
get->addheader("Accept:*/*");
|
|
||||||
get->connect(url);
|
|
||||||
while (1) {
|
|
||||||
int st=get->run();
|
|
||||||
if (st<0) break; //error
|
|
||||||
if (get->get_status()==2) {
|
|
||||||
if(len=get->bytes_available()) {
|
|
||||||
if (len>RSZ) len=RSZ;
|
|
||||||
len=get->get_bytes(response,len);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (st==1) break; //closed
|
|
||||||
}
|
|
||||||
JNL::close_socketlib();
|
|
||||||
if (*response=='1') {
|
|
||||||
if (MessageBox(0,"A new version of NSIS is now available. Would you like to download it now?","NSIS Update",MB_YESNO|MB_ICONINFORMATION)==IDYES) {
|
|
||||||
ShellExecute(g_sdata.hwnd,"open",NSIS_URL,NULL,NULL,SW_SHOWNORMAL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else MessageBox(0,"There is no update available for NSIS at this time.","NSIS Update",MB_OK|MB_ICONINFORMATION);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IDM_ABOUT:
|
case IDM_ABOUT:
|
||||||
|
@ -550,3 +511,71 @@ BOOL CALLBACK AboutProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DWORD CALLBACK UpdateThread(LPVOID v) {
|
||||||
|
#define RSZ 30
|
||||||
|
int len;
|
||||||
|
char *response = (char *)GlobalAlloc(GPTR,RSZ);
|
||||||
|
char *r;
|
||||||
|
char url[300];
|
||||||
|
static char pbuf[8192];
|
||||||
|
char *p=NULL;
|
||||||
|
*response = 0;
|
||||||
|
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,8192,(p&&p[0])?p:NULL);;
|
||||||
|
JNL::open_socketlib();
|
||||||
|
lstrcpy(url,NSIS_UPDATE);
|
||||||
|
lstrcat(url,g_sdata.brandingv);
|
||||||
|
lstrcpy(response,"");
|
||||||
|
get->addheader("User-Agent:Nullsoft Sex (Mozilla)");
|
||||||
|
get->addheader("Accept:*/*");
|
||||||
|
get->connect(url);
|
||||||
|
while (1) {
|
||||||
|
int st=get->run();
|
||||||
|
if (st<0) break; //error
|
||||||
|
if (get->get_status()==2) {
|
||||||
|
while(len=get->bytes_available()) {
|
||||||
|
char b[RSZ];
|
||||||
|
if (len>RSZ) len=RSZ;
|
||||||
|
if (lstrlen(response)+len>RSZ) break;
|
||||||
|
len=get->get_bytes(b,len);
|
||||||
|
b[len]=0;
|
||||||
|
lstrcat(response,b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (st==1) break; //closed
|
||||||
|
}
|
||||||
|
JNL::close_socketlib();
|
||||||
|
r = response;
|
||||||
|
while (r&&*r) {
|
||||||
|
if (*r=='\n') { *r = 0; break; }
|
||||||
|
r++;
|
||||||
|
}
|
||||||
|
if (*response=='1'&&lstrlen(response)>2) {
|
||||||
|
char buf[200];
|
||||||
|
response+=2;
|
||||||
|
wsprintf(buf,"NSIS %s is now available. Would you like to download it now?",response);
|
||||||
|
if (MessageBox(g_sdata.hwnd,buf,"NSIS Update",MB_YESNO|MB_ICONINFORMATION)==IDYES) {
|
||||||
|
ShellExecute(g_sdata.hwnd,"open",NSIS_URL,NULL,NULL,SW_SHOWNORMAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (*response=='2'&&lstrlen(response)>2) {
|
||||||
|
char buf[200];
|
||||||
|
response+=2;
|
||||||
|
wsprintf(buf,"NSIS %s is now available. Would you like to download this preview release now?",response);
|
||||||
|
if (MessageBox(g_sdata.hwnd,buf,"NSIS Update",MB_YESNO|MB_ICONINFORMATION)==IDYES) {
|
||||||
|
ShellExecute(g_sdata.hwnd,"open",NSIS_DDL,NULL,NULL,SW_SHOWNORMAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else MessageBox(g_sdata.hwnd,"There is no update available for NSIS at this time.","NSIS Update",MB_OK|MB_ICONINFORMATION);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -35,6 +35,7 @@
|
||||||
#define NSIS_DEV "http://nsis.sourceforge.net/"
|
#define NSIS_DEV "http://nsis.sourceforge.net/"
|
||||||
#define NSIS_URL "http://www.nullsoft.com/free/nsis/"
|
#define NSIS_URL "http://www.nullsoft.com/free/nsis/"
|
||||||
#define NSIS_UPDATE "http://nsis.sourceforge.net/update.php?version="
|
#define NSIS_UPDATE "http://nsis.sourceforge.net/update.php?version="
|
||||||
|
#define NSIS_DDL "http://sourceforge.net/project/showfiles.php?group_id=22049"
|
||||||
#define USAGE "Usage:\r\n\r\n - File | Load Script...\r\n - Drag the .nsi file into this window\r\n - Right click the .nsi file and choose \"Compile NSI\""
|
#define USAGE "Usage:\r\n\r\n - File | Load Script...\r\n - Drag the .nsi file into this window\r\n - Right click the .nsi file and choose \"Compile NSI\""
|
||||||
#define COPYRIGHT "Copyright © 2002 Robert Rainwater"
|
#define COPYRIGHT "Copyright © 2002 Robert Rainwater"
|
||||||
#define CONTRIB "Fritz Elfert, Justin Frankel, Amir Szekely"
|
#define CONTRIB "Fritz Elfert, Justin Frankel, Amir Szekely"
|
||||||
|
@ -66,6 +67,7 @@ BOOL CALLBACK DialogResize(HWND hWnd, LPARAM /* unused*/);
|
||||||
BOOL CALLBACK AboutNSISProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
|
BOOL CALLBACK AboutNSISProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
BOOL CALLBACK AboutProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
|
BOOL CALLBACK AboutProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
void CompileNSISScript();
|
void CompileNSISScript();
|
||||||
|
DWORD CALLBACK UpdateThread(LPVOID v);
|
||||||
|
|
||||||
typedef struct NSISScriptData {
|
typedef struct NSISScriptData {
|
||||||
char *script;
|
char *script;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue