-
Notifications
You must be signed in to change notification settings - Fork 0
/
UApp.cpp
144 lines (121 loc) · 3.28 KB
/
UApp.cpp
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
/*
* Copyright © 2015 Matthew Bishop, Alain Laporte, Bernard Krummenacher
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <Alert.h>
#include <String.h>
#include <Roster.h>
#include <AppFileInfo.h>
#include <File.h>
#include "constants.h"
#include "UApp.h"
UApp::UApp(void)
:SpLocaleApp("application/x-vnd.Uninstall")
{
settings = new SettingsFile;
settings->Load();
BPoint orgin;
if(settings->FindPoint("orgin", & orgin) != B_OK)
{
orgin.Set(150, 100);
settings->AddPoint("orgin", orgin);
}
select_win = new SelectWin(settings, orgin);
select_win->Show();
}
void UApp::MessageReceived(BMessage * msg)
{
switch(msg->what)
{
//New language
case MSG_LANGUAGE_CHANGED:
{
settings->Save();
BPoint orgin;
if(settings->FindPoint("orgin", & orgin) != B_OK)
{
orgin.Set(150, 100);
settings->AddPoint("orgin", orgin);
}
select_win->Quit();
select_win = new SelectWin(settings, orgin);
select_win->Show();
break;
}
case LOG_DIR_UPDATED:
{
select_win->Lock();
select_win->Show();
select_win->Unlock();
break;
}
case UNINSTALL_REQUESTED:
{
BString log, path, title, temp;
msg->FindString("log", &log);
temp = log;
temp.RemoveLast(" Install Log");
title << SpTranslate("Uninstalling") << temp;
msg->FindString("path", & path);
path << "/" << log;
BPoint orgin;
settings->FindPoint("orgin", & orgin);
int8 del_non_empty_dir;
if(settings->FindInt8("del_non_empty_dir", & del_non_empty_dir) != B_OK)
{
del_non_empty_dir = DELETE;
settings->ReplaceInt8("del_non_empty_dir", del_non_empty_dir);
}
u_win = new UWin(orgin + BPoint(10, 10), title.String(), path, del_non_empty_dir);
break;
}
case UNINSTALL_COMPLETED:
{
select_win->Lock();
select_win->Show();
select_win->Unlock();
break;
}
default:
{
SpLocaleApp::MessageReceived(msg);
break;
}
}
}
void UApp::AboutRequested()
{
//Get the name and the version of Uninstall
BFile FileApp;
app_info app_InfoTheApp;
BAppFileInfo AppFileInfo;
BString StringAbout("");
version_info version_infoTheApp;
be_app->GetAppInfo(&app_InfoTheApp);
FileApp.SetTo(&app_InfoTheApp.ref, B_READ_ONLY);
AppFileInfo.SetTo(&FileApp);
AppFileInfo.GetVersionInfo(&version_infoTheApp, B_APP_VERSION_KIND);
StringAbout << UNINSTALL_APP_NAME;
StringAbout << " ";
StringAbout << version_infoTheApp.major << "." << version_infoTheApp.middle << "." << version_infoTheApp.minor;
StringAbout << "\n\n";
StringAbout << SpTranslate("Uninstall is developed by Matt Bishop (mrbish@excite.com) and Alain Laporte (betroll@free.fr)");
BAlert * pAlertAbout = new BAlert("About", StringAbout.String(), SpTranslate("Ok"));
pAlertAbout->Go();
}
bool UApp::QuitRequested(void)
{
settings->Save();
return true;
}