(kichik) MakeNSIS now sends output directly to MakeNSISw, faster, and no

more problems with foreign languages in the output.


git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1996 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
joostverburg 2002-12-24 20:35:26 +00:00
parent db21b77527
commit 763d9a15b9
5 changed files with 281 additions and 265 deletions

View file

@ -134,7 +134,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
if (num==1) {
DragQueryFile((HDROP)wParam,0,szTmp,MAX_PATH);
if (lstrlen(szTmp)>0) {
g_sdata.script_alloced = true;
g_sdata.script_alloced = true;
g_sdata.script = (char *)GlobalAlloc(GPTR,sizeof(szTmp)+7);
wsprintf(g_sdata.script,"\"%s\"",szTmp);
ResetObjects();
@ -202,6 +202,28 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
break;
}
return TRUE;
case WM_COPYDATA:
{
PCOPYDATASTRUCT cds = PCOPYDATASTRUCT(lParam);
switch (cds->dwData) {
case MAKENSIS_NOTIFY_SCRIPT:
if (g_sdata.input_script) GlobalFree(g_sdata.input_script);
g_sdata.input_script = (char *)GlobalAlloc(GPTR, cds->cbData);
lstrcpy(g_sdata.input_script, (char *)cds->lpData);
break;
case MAKENSIS_NOTIFY_WARNING:
g_sdata.warnings++;
break;
case MAKENSIS_NOTIFY_ERROR:
break;
case MAKENSIS_NOTIFY_OUTPUT:
if (g_sdata.output_exe) GlobalFree(g_sdata.output_exe);
g_sdata.output_exe = (char *)GlobalAlloc(GPTR, cds->cbData);
lstrcpy(g_sdata.output_exe, (char *)cds->lpData);
break;
}
return TRUE;
}
case WM_COMMAND:
{
switch (LOWORD(wParam)) {
@ -237,7 +259,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
ShellExecute(g_sdata.hwnd,"open",NSIS_DEV,NULL,NULL,SW_SHOWNORMAL);
return TRUE;
}
case IDM_FORUM:
case IDM_FORUM:
{
ShellExecute(g_sdata.hwnd,"open",NSIS_FOR,NULL,NULL,SW_SHOWNORMAL);
return TRUE;

View file

@ -58,6 +58,13 @@
#define WM_MAKENSIS_PROCESSCOMPLETE (WM_USER+1001)
enum {
MAKENSIS_NOTIFY_SCRIPT,
MAKENSIS_NOTIFY_WARNING,
MAKENSIS_NOTIFY_ERROR,
MAKENSIS_NOTIFY_OUTPUT
};
// Extern Variables
extern const char* NSISW_VERSION;
@ -79,7 +86,7 @@ typedef struct NSISScriptData {
char *brandingv;
int retcode;
DWORD logLength;
BOOL warnings;
DWORD warnings;
BOOL appended;
HINSTANCE hInstance;
HWND hwnd;

View file

@ -11,11 +11,11 @@
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
@ -30,309 +30,270 @@ LRESULT CALLBACK TipHookProc(int nCode, WPARAM wParam, LPARAM lParam);
extern NSCRIPTDATA g_sdata;
void SetTitle(HWND hwnd,char *substr) {
char title[64];
if (substr==NULL) wsprintf(title,"MakeNSISW");
else wsprintf(title,"MakeNSISW - %s",substr);
SetWindowText(hwnd,title);
char title[64];
if (substr==NULL) wsprintf(title,"MakeNSISW");
else wsprintf(title,"MakeNSISW - %s",substr);
SetWindowText(hwnd,title);
}
void SetBranding(HWND hwnd) {
SetDlgItemText(hwnd, IDC_VERSION, g_sdata.branding);
SetDlgItemText(hwnd, IDC_VERSION, g_sdata.branding);
}
void CopyToClipboard(HWND hwnd) {
if (!hwnd||!OpenClipboard(hwnd)) return;
int len=SendDlgItemMessage(hwnd,IDC_LOGWIN,WM_GETTEXTLENGTH,0,0);
HGLOBAL mem = GlobalAlloc(GMEM_MOVEABLE,len+1);
if (!mem) { CloseClipboard(); return; }
char *existing_text = (char *)GlobalLock(mem);
if (!existing_text) { CloseClipboard(); return; }
EmptyClipboard();
existing_text[0]=0;
GetDlgItemText(hwnd, IDC_LOGWIN, existing_text, len+1);
GlobalUnlock(mem);
SetClipboardData(CF_TEXT,mem);
CloseClipboard();
if (!hwnd||!OpenClipboard(hwnd)) return;
int len=SendDlgItemMessage(hwnd,IDC_LOGWIN,WM_GETTEXTLENGTH,0,0);
HGLOBAL mem = GlobalAlloc(GMEM_MOVEABLE,len+1);
if (!mem) { CloseClipboard(); return; }
char *existing_text = (char *)GlobalLock(mem);
if (!existing_text) { CloseClipboard(); return; }
EmptyClipboard();
existing_text[0]=0;
GetDlgItemText(hwnd, IDC_LOGWIN, existing_text, len+1);
GlobalUnlock(mem);
SetClipboardData(CF_TEXT,mem);
CloseClipboard();
}
void ClearLog(HWND hwnd) {
SetDlgItemText(hwnd, IDC_LOGWIN, "");
SetDlgItemText(hwnd, IDC_LOGWIN, "");
}
void LogMessage(HWND hwnd,const char *str) {
SendDlgItemMessage(hwnd, IDC_LOGWIN, EM_SETSEL, g_sdata.logLength, g_sdata.logLength);
g_sdata.logLength += lstrlen(str);
SendDlgItemMessage(hwnd, IDC_LOGWIN, EM_REPLACESEL, 0, (WPARAM)str);
SendDlgItemMessage(hwnd, IDC_LOGWIN, EM_SCROLLCARET, 0, 0);
SendDlgItemMessage(hwnd, IDC_LOGWIN, EM_SETSEL, g_sdata.logLength, g_sdata.logLength);
g_sdata.logLength += lstrlen(str);
SendDlgItemMessage(hwnd, IDC_LOGWIN, EM_REPLACESEL, 0, (WPARAM)str);
SendDlgItemMessage(hwnd, IDC_LOGWIN, EM_SCROLLCARET, 0, 0);
}
void ErrorMessage(HWND hwnd,const char *str) {
if (!str) return;
char buf[1028];
wsprintf(buf,"[Error] %s\r\n",str);
LogMessage(hwnd,buf);
if (!str) return;
char buf[1028];
wsprintf(buf,"[Error] %s\r\n",str);
LogMessage(hwnd,buf);
}
void DisableItems(HWND hwnd) {
EnableWindow(GetDlgItem(hwnd,IDC_CLOSE),0);
EnableWindow(GetDlgItem(hwnd,IDC_TEST),0);
EnableMenuItem(g_sdata.menu,IDM_SAVE,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_TEST,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_EXIT,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_LOADSCRIPT,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_RECOMPILE,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_COPY,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_COPYSELECTED,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_EDITSCRIPT,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_CLEARLOG,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_BROWSESCR,MF_GRAYED);
EnableWindow(GetDlgItem(hwnd,IDC_CLOSE),0);
EnableWindow(GetDlgItem(hwnd,IDC_TEST),0);
EnableMenuItem(g_sdata.menu,IDM_SAVE,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_TEST,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_EXIT,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_LOADSCRIPT,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_RECOMPILE,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_COPY,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_COPYSELECTED,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_EDITSCRIPT,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_CLEARLOG,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_BROWSESCR,MF_GRAYED);
}
void EnableItems(HWND hwnd) {
HWND hwLog = GetDlgItem(hwnd, IDC_LOGWIN);
#define MSG(a) SendMessage(hwLog,a,0,0)
#define MSG1(a,b) SendMessage(hwLog,a,b,0)
#define MSG2(a,b,c) SendMessage(hwLog,a,b,c)
if (g_sdata.input_script) {
GlobalFree(g_sdata.input_script);
g_sdata.input_script = 0;
}
if (g_sdata.output_exe) {
GlobalFree(g_sdata.output_exe);
g_sdata.output_exe = 0;
}
TEXTRANGE tr;
FINDTEXT ft;
// find input script
ft.chrg.cpMin = 0;
ft.chrg.cpMax = MSG(WM_GETTEXTLENGTH);
ft.lpstrText = "Processing script file: \"";
ft.chrg.cpMin = tr.chrg.cpMin = MSG2(EM_FINDTEXT, 0, (LPARAM)&ft) + lstrlen("Processing script file: \"");
ft.lpstrText = "\"";
tr.chrg.cpMax = MSG2(EM_FINDTEXT, 0, (LPARAM)&ft);
if (tr.chrg.cpMin == lstrlen("Processing script file: \"") - 1) tr.chrg.cpMax = tr.chrg.cpMin = 0;
tr.lpstrText = g_sdata.input_script = (char *)GlobalAlloc(GPTR, tr.chrg.cpMax-tr.chrg.cpMin+1);
MSG2(EM_GETTEXTRANGE, 0, (WPARAM)&tr);
// find output exe
ft.chrg.cpMin = 0;
ft.chrg.cpMax = MSG(WM_GETTEXTLENGTH);
ft.lpstrText = "Output: \"";
ft.chrg.cpMin = tr.chrg.cpMin = MSG2(EM_FINDTEXT, 0, (LPARAM)&ft) + lstrlen("Output: \"");
ft.lpstrText = "\"";
tr.chrg.cpMax = MSG2(EM_FINDTEXT, 0, (LPARAM)&ft);
if (tr.chrg.cpMin == lstrlen("Output: \"") - 1) tr.chrg.cpMax = tr.chrg.cpMin = 0;
tr.lpstrText = g_sdata.output_exe = (char *)GlobalAlloc(GPTR, tr.chrg.cpMax-tr.chrg.cpMin+1);
MSG2(EM_GETTEXTRANGE, 0, (WPARAM)&tr);
g_sdata.warnings = FALSE;
ft.lpstrText = "warning:";
if (MSG2(EM_FINDTEXT, 0, (LPARAM)&ft) != -1) g_sdata.warnings++;
ft.lpstrText = "warnings:";
if (MSG2(EM_FINDTEXT, 0, (LPARAM)&ft) != -1) g_sdata.warnings++;
if (g_sdata.output_exe && !g_sdata.retcode) {
EnableWindow(GetDlgItem(hwnd,IDC_TEST),1);
EnableMenuItem(g_sdata.menu,IDM_TEST,MF_ENABLED);
}
EnableWindow(GetDlgItem(hwnd,IDC_CLOSE),1);
EnableMenuItem(g_sdata.menu,IDM_SAVE,MF_ENABLED);
EnableMenuItem(g_sdata.menu,IDM_EXIT,MF_ENABLED);
EnableMenuItem(g_sdata.menu,IDM_LOADSCRIPT,MF_ENABLED);
EnableMenuItem(g_sdata.menu,IDM_RECOMPILE,MF_ENABLED);
EnableMenuItem(g_sdata.menu,IDM_COPY,MF_ENABLED);
EnableMenuItem(g_sdata.menu,IDM_COPYSELECTED,MF_ENABLED);
EnableMenuItem(g_sdata.menu,IDM_EDITSCRIPT,MF_ENABLED);
EnableMenuItem(g_sdata.menu,IDM_CLEARLOG,MF_ENABLED);
EnableMenuItem(g_sdata.menu,IDM_BROWSESCR,MF_ENABLED);
if (g_sdata.output_exe && !g_sdata.retcode) {
EnableWindow(GetDlgItem(hwnd,IDC_TEST),1);
EnableMenuItem(g_sdata.menu,IDM_TEST,MF_ENABLED);
}
EnableWindow(GetDlgItem(hwnd,IDC_CLOSE),1);
EnableMenuItem(g_sdata.menu,IDM_SAVE,MF_ENABLED);
EnableMenuItem(g_sdata.menu,IDM_EXIT,MF_ENABLED);
EnableMenuItem(g_sdata.menu,IDM_LOADSCRIPT,MF_ENABLED);
EnableMenuItem(g_sdata.menu,IDM_RECOMPILE,MF_ENABLED);
EnableMenuItem(g_sdata.menu,IDM_COPY,MF_ENABLED);
EnableMenuItem(g_sdata.menu,IDM_COPYSELECTED,MF_ENABLED);
EnableMenuItem(g_sdata.menu,IDM_EDITSCRIPT,MF_ENABLED);
EnableMenuItem(g_sdata.menu,IDM_CLEARLOG,MF_ENABLED);
EnableMenuItem(g_sdata.menu,IDM_BROWSESCR,MF_ENABLED);
}
void CompileNSISScript() {
static char *s;
DragAcceptFiles(g_sdata.hwnd,FALSE);
ClearLog(g_sdata.hwnd);
SetTitle(g_sdata.hwnd,NULL);
if (lstrlen(g_sdata.script)==0) {
LogMessage(g_sdata.hwnd,USAGE);
EnableMenuItem(g_sdata.menu,IDM_RECOMPILE,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_EDITSCRIPT,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_TEST,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_BROWSESCR,MF_GRAYED);
EnableWindow(GetDlgItem(g_sdata.hwnd,IDC_TEST),0);
DragAcceptFiles(g_sdata.hwnd,TRUE);
return;
}
if (!g_sdata.appended) {
if (s) GlobalFree(s);
s = (char *)GlobalAlloc(GPTR, lstrlen(g_sdata.script)+sizeof(EXENAME)+2);
wsprintf(s,"%s %s",EXENAME,g_sdata.script);
if (g_sdata.script_alloced) GlobalFree(g_sdata.script);
g_sdata.script_alloced = true;
g_sdata.script = s;
g_sdata.appended = TRUE;
}
g_sdata.logLength = 0;
// Disable buttons during compile
DisableItems(g_sdata.hwnd);
DWORD id;
g_sdata.thread=CreateThread(NULL,0,MakeNSISProc,0,0,&id);
static char *s;
DragAcceptFiles(g_sdata.hwnd,FALSE);
ClearLog(g_sdata.hwnd);
SetTitle(g_sdata.hwnd,NULL);
if (lstrlen(g_sdata.script)==0) {
LogMessage(g_sdata.hwnd,USAGE);
EnableMenuItem(g_sdata.menu,IDM_RECOMPILE,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_EDITSCRIPT,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_TEST,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_BROWSESCR,MF_GRAYED);
EnableWindow(GetDlgItem(g_sdata.hwnd,IDC_TEST),0);
DragAcceptFiles(g_sdata.hwnd,TRUE);
return;
}
if (!g_sdata.appended) {
if (s) GlobalFree(s);
s = (char *)GlobalAlloc(GPTR, lstrlen(g_sdata.script)+sizeof(EXENAME)+sizeof(" /NOTIFYHWND ")+16);
wsprintf(s,"%s /NOTIFYHWND %d %s",EXENAME,g_sdata.hwnd,g_sdata.script);
if (g_sdata.script_alloced) GlobalFree(g_sdata.script);
g_sdata.script_alloced = true;
g_sdata.script = s;
g_sdata.appended = TRUE;
}
GlobalFree(g_sdata.input_script);
GlobalFree(g_sdata.output_exe);
g_sdata.input_script = 0;
g_sdata.output_exe = 0;
g_sdata.warnings = 0;
g_sdata.logLength = 0;
// Disable buttons during compile
DisableItems(g_sdata.hwnd);
DWORD id;
g_sdata.thread=CreateThread(NULL,0,MakeNSISProc,0,0,&id);
}
void RestoreWindowPos(HWND hwnd) {
HKEY hKey;
WINDOWPLACEMENT p;
if (RegOpenKeyEx(REGSEC,REGKEY,0,KEY_READ,&hKey) == ERROR_SUCCESS) {
DWORD l = sizeof(p);
DWORD t;
if ((RegQueryValueEx(hKey,REGLOC,NULL,&t,(unsigned char*)&p,&l)==ERROR_SUCCESS)&&(t == REG_BINARY)&&(l==sizeof(p))) {
p.length = sizeof(p);
SetWindowPlacement(hwnd, &p);
}
RegCloseKey(hKey);
}
HKEY hKey;
WINDOWPLACEMENT p;
if (RegOpenKeyEx(REGSEC,REGKEY,0,KEY_READ,&hKey) == ERROR_SUCCESS) {
DWORD l = sizeof(p);
DWORD t;
if ((RegQueryValueEx(hKey,REGLOC,NULL,&t,(unsigned char*)&p,&l)==ERROR_SUCCESS)&&(t == REG_BINARY)&&(l==sizeof(p))) {
p.length = sizeof(p);
SetWindowPlacement(hwnd, &p);
}
RegCloseKey(hKey);
}
}
void SaveWindowPos(HWND hwnd) {
HKEY hKey;
WINDOWPLACEMENT p;
p.length = sizeof(p);
GetWindowPlacement(hwnd, &p);
if (RegCreateKey(REGSEC,REGKEY,&hKey) == ERROR_SUCCESS) {
RegSetValueEx(hKey,REGLOC,0,REG_BINARY,(unsigned char*)&p,sizeof(p));
RegCloseKey(hKey);
}
HKEY hKey;
WINDOWPLACEMENT p;
p.length = sizeof(p);
GetWindowPlacement(hwnd, &p);
if (RegCreateKey(REGSEC,REGKEY,&hKey) == ERROR_SUCCESS) {
RegSetValueEx(hKey,REGLOC,0,REG_BINARY,(unsigned char*)&p,sizeof(p));
RegCloseKey(hKey);
}
}
void ResetObjects() {
g_sdata.appended = FALSE;
g_sdata.warnings = FALSE;
g_sdata.retcode = -1;
g_sdata.thread = NULL;
g_sdata.appended = FALSE;
g_sdata.warnings = FALSE;
g_sdata.retcode = -1;
g_sdata.thread = NULL;
}
int InitBranding() {
char *s;
s = (char *)GlobalAlloc(GPTR,lstrlen(EXENAME)+10);
wsprintf(s,"%s /version",EXENAME);
{
STARTUPINFO si={sizeof(si),};
SECURITY_ATTRIBUTES sa={sizeof(sa),};
SECURITY_DESCRIPTOR sd={0,};
PROCESS_INFORMATION pi={0,};
HANDLE newstdout=0,read_stdout=0;
char *s;
s = (char *)GlobalAlloc(GPTR,lstrlen(EXENAME)+10);
wsprintf(s,"%s /version",EXENAME);
{
STARTUPINFO si={sizeof(si),};
SECURITY_ATTRIBUTES sa={sizeof(sa),};
SECURITY_DESCRIPTOR sd={0,};
PROCESS_INFORMATION pi={0,};
HANDLE newstdout=0,read_stdout=0;
OSVERSIONINFO osv={sizeof(osv)};
GetVersionEx(&osv);
if (osv.dwPlatformId == VER_PLATFORM_WIN32_NT) {
InitializeSecurityDescriptor(&sd,SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(&sd,true,NULL,false);
sa.lpSecurityDescriptor = &sd;
}
else sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = true;
if (!CreatePipe(&read_stdout,&newstdout,&sa,0)) {
return 0;
}
GetStartupInfo(&si);
si.dwFlags = STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
si.hStdOutput = newstdout;
si.hStdError = newstdout;
if (!CreateProcess(NULL,s,NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&si,&pi)) {
CloseHandle(newstdout);
CloseHandle(read_stdout);
return 0;
}
char szBuf[1024];
DWORD dwRead = 1;
DWORD dwExit = !STILL_ACTIVE;
if (WaitForSingleObject(pi.hProcess,10000)!=WAIT_OBJECT_0) {
return 0;
}
ReadFile(read_stdout, szBuf, sizeof(szBuf)-1, &dwRead, NULL);
szBuf[dwRead] = 0;
if (lstrlen(szBuf)==0) return 0;
g_sdata.branding = (char *)GlobalAlloc(GPTR,lstrlen(szBuf)+6);
wsprintf(g_sdata.branding,"NSIS %s",szBuf);
g_sdata.brandingv = (char *)GlobalAlloc(GPTR,lstrlen(szBuf)+1);
lstrcpy(g_sdata.brandingv,szBuf);
GlobalFree(s);
}
return 1;
OSVERSIONINFO osv={sizeof(osv)};
GetVersionEx(&osv);
if (osv.dwPlatformId == VER_PLATFORM_WIN32_NT) {
InitializeSecurityDescriptor(&sd,SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(&sd,true,NULL,false);
sa.lpSecurityDescriptor = &sd;
}
else sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = true;
if (!CreatePipe(&read_stdout,&newstdout,&sa,0)) {
return 0;
}
GetStartupInfo(&si);
si.dwFlags = STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
si.hStdOutput = newstdout;
si.hStdError = newstdout;
if (!CreateProcess(NULL,s,NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&si,&pi)) {
CloseHandle(newstdout);
CloseHandle(read_stdout);
return 0;
}
char szBuf[1024];
DWORD dwRead = 1;
DWORD dwExit = !STILL_ACTIVE;
if (WaitForSingleObject(pi.hProcess,10000)!=WAIT_OBJECT_0) {
return 0;
}
ReadFile(read_stdout, szBuf, sizeof(szBuf)-1, &dwRead, NULL);
szBuf[dwRead] = 0;
if (lstrlen(szBuf)==0) return 0;
g_sdata.branding = (char *)GlobalAlloc(GPTR,lstrlen(szBuf)+6);
wsprintf(g_sdata.branding,"NSIS %s",szBuf);
g_sdata.brandingv = (char *)GlobalAlloc(GPTR,lstrlen(szBuf)+1);
lstrcpy(g_sdata.brandingv,szBuf);
GlobalFree(s);
}
return 1;
}
void InitTooltips(HWND h) {
if (h == NULL) return;
my_memset(&g_tip,0,sizeof(NTOOLTIP));
g_tip.tip_p = h;
INITCOMMONCONTROLSEX icx;
icx.dwSize = sizeof(icx);
icx.dwICC = ICC_BAR_CLASSES;
InitCommonControlsEx(&icx);
DWORD dwStyle = WS_POPUP | WS_BORDER | TTS_ALWAYSTIP;
DWORD dwExStyle = WS_EX_TOOLWINDOW | WS_EX_TOPMOST;
g_tip.tip = CreateWindowEx(dwExStyle,TOOLTIPS_CLASS,NULL,dwStyle,0,0,0,0,h,NULL,GetModuleHandle(NULL),NULL);
if (!g_tip.tip) return;
g_tip.hook = SetWindowsHookEx(WH_GETMESSAGE,TipHookProc,NULL, GetCurrentThreadId());
AddTip(GetDlgItem(h,IDC_CLOSE),TEXT("Close MakeNSISW"));
AddTip(GetDlgItem(h,IDC_TEST),TEXT("Test the installer generated by MakeNSISW"));
if (h == NULL) return;
my_memset(&g_tip,0,sizeof(NTOOLTIP));
g_tip.tip_p = h;
INITCOMMONCONTROLSEX icx;
icx.dwSize = sizeof(icx);
icx.dwICC = ICC_BAR_CLASSES;
InitCommonControlsEx(&icx);
DWORD dwStyle = WS_POPUP | WS_BORDER | TTS_ALWAYSTIP;
DWORD dwExStyle = WS_EX_TOOLWINDOW | WS_EX_TOPMOST;
g_tip.tip = CreateWindowEx(dwExStyle,TOOLTIPS_CLASS,NULL,dwStyle,0,0,0,0,h,NULL,GetModuleHandle(NULL),NULL);
if (!g_tip.tip) return;
g_tip.hook = SetWindowsHookEx(WH_GETMESSAGE,TipHookProc,NULL, GetCurrentThreadId());
AddTip(GetDlgItem(h,IDC_CLOSE),TEXT("Close MakeNSISW"));
AddTip(GetDlgItem(h,IDC_TEST),TEXT("Test the installer generated by MakeNSISW"));
}
void DestroyTooltips() {
UnhookWindowsHookEx(g_tip.hook);
UnhookWindowsHookEx(g_tip.hook);
}
void AddTip(HWND hWnd,LPSTR lpszToolTip) {
TOOLINFO ti;
ti.cbSize = sizeof(TOOLINFO);
ti.uFlags = TTF_IDISHWND;
ti.hwnd = g_tip.tip_p;
ti.uId = (UINT) hWnd;
ti.lpszText = lpszToolTip;
SendMessage(g_tip.tip, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
TOOLINFO ti;
ti.cbSize = sizeof(TOOLINFO);
ti.uFlags = TTF_IDISHWND;
ti.hwnd = g_tip.tip_p;
ti.uId = (UINT) hWnd;
ti.lpszText = lpszToolTip;
SendMessage(g_tip.tip, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
}
LRESULT CALLBACK TipHookProc(int nCode, WPARAM wParam, LPARAM lParam) {
if (nCode < 0) return CallNextHookEx(g_tip.hook, nCode, wParam, lParam);
switch (((MSG*)lParam)->message) {
case WM_MOUSEMOVE:
if (IsChild(g_tip.tip_p,((MSG*)lParam)->hwnd))
SendMessage(g_tip.tip, TTM_RELAYEVENT, 0,lParam);
break;
default:
break;
}
return CallNextHookEx(g_tip.hook, nCode, wParam, lParam);
if (nCode < 0) return CallNextHookEx(g_tip.hook, nCode, wParam, lParam);
switch (((MSG*)lParam)->message) {
case WM_MOUSEMOVE:
if (IsChild(g_tip.tip_p,((MSG*)lParam)->hwnd))
SendMessage(g_tip.tip, TTM_RELAYEVENT, 0,lParam);
break;
default:
break;
}
return CallNextHookEx(g_tip.hook, nCode, wParam, lParam);
}
void ShowDocs() {
char pathf[MAX_PATH],*path;
GetModuleFileName(NULL,pathf,sizeof(pathf));
path=my_strrchr(pathf,'\\');
if(path!=NULL) *path=0;
lstrcat(pathf,LOCALDOCS);
if ((int)ShellExecute(g_sdata.hwnd,"open",pathf,NULL,NULL,SW_SHOWNORMAL)<=32)
ShellExecute(g_sdata.hwnd,"open",DOCPATH,NULL,NULL,SW_SHOWNORMAL);
char pathf[MAX_PATH],*path;
GetModuleFileName(NULL,pathf,sizeof(pathf));
path=my_strrchr(pathf,'\\');
if(path!=NULL) *path=0;
lstrcat(pathf,LOCALDOCS);
if ((int)ShellExecute(g_sdata.hwnd,"open",pathf,NULL,NULL,SW_SHOWNORMAL)<=32)
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;
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;
}

View file

@ -313,6 +313,8 @@ CEXEBuild::CEXEBuild()
build_last_page_define[0]=0;
ubuild_last_page_define[0]=0;
notify_hwnd=0;
}
int CEXEBuild::getcurdbsize() { return cur_datablock->getlen(); }
@ -1619,6 +1621,7 @@ int CEXEBuild::write_output(void)
{
char buffer[1024],*p;
GetFullPathName(build_output_filename,1024,buffer,&p);
notify(MAKENSIS_NOTIFY_OUTPUT, buffer);
INFO_MSG("\nOutput: \"%s\"\n",buffer);
}
FILE *fp = fopen(build_output_filename,"w+b");
@ -2133,6 +2136,7 @@ void CEXEBuild::warning(const char *s, ...)
vsprintf(buf,s,val);
va_end(val);
m_warnings.add(buf,-1);
notify(MAKENSIS_NOTIFY_WARNING,buf);
if (display_warnings)
{
fprintf(g_output,"warning: %s\n",buf);
@ -2142,15 +2146,19 @@ void CEXEBuild::warning(const char *s, ...)
void CEXEBuild::ERROR_MSG(const char *s, ...)
{
if (display_errors)
if (display_errors || notify_hwnd)
{
char buf[4096];
va_list val;
va_start(val,s);
vsprintf(buf,s,val);
va_end(val);
fprintf(g_output,"%s",buf);
fflush(g_output);
notify(MAKENSIS_NOTIFY_ERROR,buf);
if (display_errors)
{
fprintf(g_output,"%s",buf);
fflush(g_output);
}
}
}
@ -2197,6 +2205,15 @@ void CEXEBuild::print_warnings()
fflush(g_output);
}
void CEXEBuild::notify(int code, char *data)
{
if (notify_hwnd)
{
COPYDATASTRUCT cds = {(DWORD)code, strlen(data)+1, data};
SendMessage(notify_hwnd, WM_COPYDATA, 0, (LPARAM)&cds);
}
}
// Added by Ximon Eighteen 5th August 2002
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
void CEXEBuild::build_plugin_table(void)

View file

@ -41,6 +41,13 @@ extern "C"
#define PS_ERROR 50
#define IS_PS_ELSE(x) (( x ) >= PS_ELSE && ( x ) <= PS_ELSE_IF1)
enum {
MAKENSIS_NOTIFY_SCRIPT,
MAKENSIS_NOTIFY_WARNING,
MAKENSIS_NOTIFY_ERROR,
MAKENSIS_NOTIFY_OUTPUT
};
class CEXEBuild {
public:
CEXEBuild();
@ -75,6 +82,9 @@ class CEXEBuild {
int display_warnings;
int display_info;
HWND notify_hwnd;
void notify(int code, char *data);
private:
// tokens.cpp
int get_commandtoken(char *s, int *np, int *op);
@ -87,15 +97,14 @@ class CEXEBuild {
int do_add_file(const char *lgss, int attrib, int recurse, int linecnt, int *total_files, const char *name_override=0, int generatecode=1, int *data_handle=0);
GrowBuf m_linebuild; // used for concatenating lines
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
// Added by Amir Szekely 9th August 2002
int add_plugins_dir_initializer(void);
#endif //NSIS_CONFIG_PLUGIN_SUPPORT
void ERROR_MSG(const char *s, ...);
void SCRIPT_MSG(const char *s, ...);
void INFO_MSG(const char *s, ...);
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
int add_plugins_dir_initializer(void);
#endif //NSIS_CONFIG_PLUGIN_SUPPORT
// build.cpp functions used mostly by script.cpp
int getcurdbsize();
int add_section(const char *secname, const char *file, int line, const char *defname, int expand);