My favorites | Sign in
Project Home Downloads Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
#include "ide.h"
//#include "Install.h"

#ifdef PLATFORM_WIN32

String GetShellFolder(const char *name, HKEY type)
{
return GetWinRegString(name, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", type);
}

void DelKey(const char *dir, const char *key)
{
HKEY hkey;
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, dir, 0, KEY_READ, &hkey) != ERROR_SUCCESS)
return;
RegDeleteKey(hkey, key);
RegCloseKey(hkey);
}

void RemoveWindowsItems()
{
DeleteFile(AppendFileName(GetShellFolder("Common Programs", HKEY_LOCAL_MACHINE), "Ultimate++ IDE.lnk"));
DeleteFile(AppendFileName(GetShellFolder("Desktop", HKEY_CURRENT_USER), "TheIde.lnk"));

DelKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Ultimate++", "DisplayName");
DelKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Ultimate++", "UninstallString");
DelKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall", "Ultimate++");
}

void Uninstall()
{
String path = GetExeFilePath();
String bat = AppendFileName(GetShellFolder("Desktop", HKEY_CURRENT_USER), "removepp.bat");
String dir = GetFileFolder(path);
if(!PromptYesNo("[*3 Do you wish to uninstall Ultimate`+`+ development system ?&&]"
"Uninstall will remove [* " + DeQtf(dir) + "] directory and all "
"registry and desktop items associated with Ultimate`+`+.")) return;
DeleteFolderDeep(dir);
RemoveWindowsItems();
SaveFile(bat,
":Repeat\r\n"
"del \"" + path + "\"\r\n"
"if exist \"" + path + "\" goto Repeat\r\n"
"del \"" + GetExeDirFile("theide.log") + "\"\r\n"
"del \"" + GetExeDirFile("dbghelp.dll") + "\"\r\n"
"rmdir \"" + dir + "\"\r\n"
"del \"" + bat + "\"\r\n"
);

STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
char h[512];
strcpy(h, bat);
if(CreateProcess(NULL, h, NULL, NULL, FALSE,
IDLE_PRIORITY_CLASS, NULL, GetShellFolder("Desktop", HKEY_CURRENT_USER),
&si, &pi))
Exclamation("Uninstall successful.");
else
Exclamation("Uninstall failed to remove some files...&" + DeQtf(GetLastErrorMessage()));
}

#define Ptr Ptr_
#define byte byte_
#define CY win32_CY_


#include <winnls.h>
#include <winnetwk.h>

#include <wincon.h>
#include <shlobj.h>

#undef Ptr
#undef byte
#undef CY

bool CreateShellLink(const char *filepath, const char *linkpath, const char *desc, int icon)
{
HRESULT hres;
IShellLink* psl;
IPersistFile* ppf;
CoInitialize(NULL);
hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink,
(PVOID *) &psl);
if(SUCCEEDED(hres)) {
psl->SetPath(filepath);
psl->SetDescription(desc);
if(icon >= 0)
psl->SetIconLocation(filepath, icon);
hres = psl->QueryInterface(IID_IPersistFile, (PVOID *) &ppf);
if (SUCCEEDED(hres)) {
WCHAR szPath[_MAX_PATH] = { 0 };
MultiByteToWideChar(CP_ACP, 0, linkpath, (int)strlen(linkpath), szPath, _MAX_PATH);
hres = ppf->Save(szPath, TRUE);
ppf->Release();
}
}
psl->Release();
CoUninitialize();
return SUCCEEDED(hres);
}

bool InstallDesktopIcon(const char *exe, const char *lnk, const char *desc)
{
return CreateShellLink(exe,
AppendFileName(GetShellFolder("Desktop", HKEY_CURRENT_USER), lnk),
desc, -1);
}

bool InstallProgramGroup(const char *exe, const char *groupname, const char *lnk, int icon = -1)
{
String dir = GetShellFolder("Common Programs", HKEY_LOCAL_MACHINE);
if(groupname) {
dir = AppendFileName(dir, groupname);
CreateDirectory(dir, NULL);
}
return CreateShellLink(exe, AppendFileName(dir, lnk), "", icon);
}

void InstallUninstall(const char *name, const char *dname, const char *cmdline)
{
String path = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + String(name);
SetWinRegString(dname, "DisplayName", path);
SetWinRegString(cmdline, "UninstallString", path);
}

void InstallUninstall(const char *exe, const char *name)
{
InstallUninstall(name, name, String(exe) + " -uninstall");
}

String Rdir(const char *s, const String& dir, const String& dir2)
{
String r;
while(*s) {
if(*s == '#')
r.Cat(dir);
else
if(*s == '@')
r.Cat(dir2);
else
r.Cat(*s);
s++;
}
return r;
}

bool CheckLicense()
{
if(!FileExists((GetExeDirFile("license.chk"))))
return true;
ShowSplash();
Ctrl::ProcessEvents();
Sleep(2000);
HideSplash();
Ctrl::ProcessEvents();
WithLicenseLayout<TopWindow> d;
CtrlLayoutOKCancel(d, "License agreement");
d.license = GetTopic("ide/app/BSD$en-us").text;
d.license.Margins(4);
d.license.SetZoom(Zoom(18, 100));
d.ActiveFocus(d.license);
if(d.Run() != IDOK) {
Uninstall();
return false;
}
DeleteFile(GetExeDirFile("license.chk"));
return true;
}

void BrowseField(EditField *f)
{
FileSel fs;
String s = ~*f;
if(DirectoryExists(s))
fs.ActiveDir(s);
if(fs.ExecuteSelectDir("Select the directory for MyApps"))
*f <<= ~fs;
}

bool Install()
{
{
WithInfoLayout<TopWindow> d;
CtrlLayoutOKCancel(d, "Installation guide");
d.info = GetTopic("ide/app/install$en-us").text;
d.info.Margins(4);
d.info.SetZoom(Zoom(18, 100));
d.ActiveFocus(d.info);
if(d.Run() != IDOK)
return false;
WithInstallLayout<TopWindow> dlg;
CtrlLayoutOKCancel(dlg, "Ultimate++ user-code setup");
String h = GetExeFilePath().Mid(0, 3) + "MyApps";
dlg.myapps <<= h;
dlg.myapps.AddList(h);
dlg.myapps.AddList(GetHomeDirFile("MyApps"));
dlg.browse <<= callback1(BrowseField, &dlg.myapps);
dlg.ActiveFocus(dlg.myapps);
if(dlg.Run() != IDOK)
return false;
String ipp = GetExeDirFile("install.upp");
String exe = GetExeFilePath();
String dir = GetFileFolder(exe);
String dir2 = ~dlg.myapps;
RealizeDirectory(dir2);
FileIn in(ipp);
while(!in.IsEof()) {
Vector<String> ln = Split(in.GetLine(), '|');
if(ln.GetCount() != 4)
break;
SaveFile(AppendFileName(dir, ln[0]),
"UPP = " + AsCString(Rdir(ln[1], dir, dir2)) + ";\r\n"
"COMMON = " + AsCString(Rdir(ln[2], dir, dir2)) + ";\r\n"
"OUTPUT = " + AsCString(Rdir(ln[3], dir, dir2)) + ";\r\n"
);
}
in.Close();
if(dlg.icon)
InstallDesktopIcon(exe, "TheIde.lnk", "Ultimate++ IDE");
InstallProgramGroup(exe, NULL, "Ultimate++ IDE.lnk");
InstallUninstall(exe, "Ultimate++");
DeleteFile(ipp);
}
AutoSetup();
PromptOK("Ultimate`+`+ setup was finished.&Press OK to launch TheIDE.&"
"[* WARNING:] Do not put important files into the install directory as they "
"would be [* deleted] during [* uninstall] or [* upgrade] process!");;
return true;
}

#else

bool CopyFolder(const char *dst, const char *src, Progress *pi)
{
if(strcmp(src, dst) == 0)
return true;
RealizeDirectory(dst);
if(pi)
pi->SetText(dst);
FindFile ff(AppendFileName(src, "*"));
while(ff) {
if(pi && pi->StepCanceled())
return false;
String s = AppendFileName(src, ff.GetName());
String d = AppendFileName(dst, ff.GetName());
if(ff.IsFolder())
if(!CopyFolder(d, s, pi))
return false;
if(ff.IsFile())
SaveFile(d, LoadFile(s));
ff.Next();
}
return true;
}

bool CopyFolder(Progress& pi, const char *dst, const char *src)
{
return CopyFolder(dst, src, &pi);
}

void ChkSupp(const char *s, String& dir)
{
if(IsNull(dir) && FileExists(AppendFileName(s, "GCC.bm")))
dir = s;
}

String DefaultInstallFolder()
{
String DefaultFolder;
String ExeTitle = ToUpper(GetExeTitle());
for(int i = 0 ; i < ExeTitle.GetCount();i++) {
if(ExeTitle[i] >= 'a' && ExeTitle[i] <= 'z')
ExeTitle.Set(i, ExeTitle[i] + 'A'-'a');
}
if(ExeTitle.Find("SVN") >= 0)
DefaultFolder = "upp-svn";
else if(ExeTitle.Find("DEV") >= 0)
DefaultFolder = "upp-dev";
else if(ExeTitle.Find("BETA") >= 0)
DefaultFolder = "upp-beta";
else
DefaultFolder = "upp";

return DefaultFolder;

}

struct XInstallDlg : public WithXInstallLayout<TopWindow> {

private:

FrameRight<Button> pathbrowse;

void FindInstFolder();

public:

typedef XInstallDlg CLASSNAME;

XInstallDlg();

};

void XInstallDlg::FindInstFolder() {
FileSel *fs = &OutputFs();
fs->Set(path);
if(! fs->ExecuteSelectDir("Select output directory ..."))
return;
path <<= ~(*fs);
}

XInstallDlg::XInstallDlg() {
CtrlLayoutOKCancel(*this, "Ultimate++ user setup");
pathbrowse <<= THISBACK(FindInstFolder);
pathbrowse.SetMonoImage(CtrlImg::smallright()).NoWantFocus();
uppsrc = true;
reference = true;
examples = true;
tutorial = true;
bazaar = true;
path.AddFrame(pathbrowse);
if(FileExists(ConfigFile("installpath")))
path <<= LoadFile(ConfigFile("installpath"));
else
path <<= AppendFileName(FromSystemCharset(getenv("HOME")), DefaultInstallFolder());
}

bool Install()
{
if(!(InstallWizard().Run()&(IDOK|IDCANCEL))) return false;

String supp=UpdaterCfg().globalsrc;
FindFile ff(ConfigFile("*.bm"));
if(!ff) {
ff.Search(AppendFileName(supp, "*.bm"));
while(ff) {
FileCopy(ff.GetPath(), ConfigFile(ff.GetName()));
ff.Next();
}
}
// 2008/06/01 -- add valgrind suppression file
String ValgSupp = ConfigFile("valgrind.supp");
if(IsNull(LoadFile(ValgSupp)))
SaveFile(ValgSupp, LoadFile(AppendFileName(supp, "uppsrc/ide/valgrind.supp")));
// 2008/06/01 -- END
//PromptOK("Ultimate`+`+ user setup was finished.&Press OK to launch TheIDE.");
return true;
}

//void Uninstall() {}

#endif

Change log

r4470 by dolik on Jan 26, 2012   Diff
.ide: Support multiple preconfigured *.bm
on first run
Go to: 
Project members, sign in to write a code review

Older revisions

r3307 by dolik on Mar 24, 2011   Diff
theide: new source updating system
r1877 by cxl on Jan 8, 2010   Diff
U++ Win32: Improved installation
(browse button for MyApps, drop button
for MyApps, update link to SDK)
r1116 by cxl on May 1, 2009   Diff
Slight fix of X11 install behaviour
All revisions of this file

File info

Size: 9347 bytes, 357 lines

File properties

svn:eol-style
native
Powered by Google Project Hosting