#include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif #ifndef WX_PRECOMP #include "wx/wx.h" #endif #include "wx/resource.h" #include "install.h" #include "instsup.h" #include #if !defined(__EMX__) && !defined(__OS2__) && !defined(WIN32) && !defined(WINNT) #define stricmp strcasecmp #endif #ifdef __cplusplus extern "C" { #endif extern char installdir[]; #ifdef __cplusplus } #endif typedef struct _wxCommands { int id; char file[50]; } wxCommands; #define COMMANDMAX 20 wxCommands wxcommands[COMMANDMAX]; char finishedscript[256] = ""; char percentname[256] = ""; class MyApp: public wxApp { public: MyApp(); virtual bool OnInit(); virtual ~MyApp(); }; class MyDialog : public wxDialog { public: void handle_button(wxCommandEvent& event); }; class MyThread : public wxThread { public: virtual void *Entry(); }; void *MyThread::Entry() { install_thread(NULL); return NULL; } MyDialog *dialog = NULL; IMPLEMENT_APP(MyApp) MyApp::MyApp() { } wxCondition *InstCond = NULL; void updatepercent(void) { wxGauge *tmp = (wxGauge *)wxFindWindowByName(percentname, dialog); if(tmp) { unsigned long sliderpos; int pixels = 100; extern int current_file, files; sliderpos = (unsigned long)(((float)(current_file)/(float)files)*pixels); tmp->SetValue(sliderpos); } } int parse_ini(char *filename) { FILE *f; int b; for(b=0;bLoadFromResource(NULL, "dialog1"); dialog->Show(TRUE); /*MyApp::SetTopWindow(dialog);*/ } else if(stricmp(entry, "closeold") == 0) { if(dialog) dialog->Destroy(); dialog = NULL; } else if(stricmp(entry, "getcheck") == 0) { wxCheckBox *tmp = (wxCheckBox *)wxFindWindowByName(entrydata, dialog); if(tmp) { if(!tmp->GetValue()) { parse_ini(entrydata2); bytesread = 0; } } } else if(stricmp(entry, "gettext") == 0) { wxTextCtrl *tmp = (wxTextCtrl *)wxFindWindowByName(entrydata, dialog); wxString bleah; if(tmp) { if((bleah = tmp->GetValue())) strcpy(installdir, bleah); } } else if(stricmp(entry, "settext") == 0) { wxTextCtrl *tmp = (wxTextCtrl *)wxFindWindowByName(entrydata, dialog); if(tmp) tmp->SetValue(installdir); } else if(stricmp(entry, "message") == 0) mesg(entrydata); else if(stricmp(entry, "disable") == 0) { wxButton *tmp = (wxButton *)wxFindWindowByName(entrydata, dialog); if(tmp) tmp->Disable(); } else if(stricmp(entry, "grabfile") == 0) grabfile(entrydata); else if(stricmp(entry, "remove") == 0) remove(entrydata); else if(stricmp(entry, "system") == 0) wxExecute(entrydata); else if(stricmp(entry, "startinst") == 0) { strcpy(percentname, entrydata); strcpy(finishedscript, entrydata2); /* I couldn't get it working with threads, even when using conditions it blocked the message loop making it unreadable, so I am going with wxYield for the moment. */ #if 0 MyThread *thread = new MyThread(); if ( thread->Create() != wxTHREAD_NO_ERROR ) { error("Can't create thread!"); } strcpy(finishedscript, entrydata); InstCond = new wxCondition(); thread->Run(); wxMutex *test = new wxMutex(); InstCond->Wait(*test); #endif install_thread(NULL); create_wps_objects(); parse_ini(finishedscript); } else if(stricmp(entry, "mleview") == 0) { FILE *f; unsigned long bytes; char buffer[1025]; wxTextCtrl *tmp = (wxTextCtrl *)wxFindWindowByName(entrydata, dialog); if(tmp) { grabfile(entrydata2); if((f = fopen(entrydata2, "rb"))!= NULL) { while(!feof(f)) { memset(buffer, 0, 1025); bytes = fread(buffer, 1, 1024, f); *tmp << buffer; } fclose(f); } remove(entrydata2); tmp->ShowPosition(0); } } else if(stricmp(entry, "setbutton") == 0) { for(b=0;bConnect( atol(entrydata), -1, wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) &MyDialog::handle_button); } } fclose(f); remove(filename); return TRUE; } remove(filename); return FALSE; } void MyDialog::handle_button(wxCommandEvent& event ) { int b; for(b=0;b