-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathRtnResources.cpp
113 lines (91 loc) · 3.67 KB
/
RtnResources.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
#include "StdAfx.h"
#include "RtnResources.h"
#include "Utils.h"
#include "Logger.h"
static const std::wstring& lpAppName = L"options";
static std::wstring iniFileName;
void RtnResources::Init(const wstring& fileName) {
iniFileName = IO::GetFilePath(fileName);
}
bool RtnResources::IsDebugLoggingEnabled() {
wstring debug = RtnResources::GetOption(L"debug.enabled", L"false");
return debug.compare(L"true") == 0;
}
std::wstring RtnResources::GetOption(const wstring& propertyName, const wstring& defaultValue) {
TCHAR value[1024];
GetPrivateProfileString(lpAppName.c_str(), propertyName.c_str(), defaultValue.c_str(),
value, sizeof(value)/sizeof(value[0]), iniFileName.c_str());
return value;
}
int RtnResources::GetOptionInt(const wstring& propertyName, const int defaultValue) {
return GetPrivateProfileInt(lpAppName.c_str(), propertyName.c_str(), defaultValue, iniFileName.c_str());
}
wstring RtnResources::GetServerType() {
wstring serverType = GetOption(L"application.server.type", L"jboss4");
if (L"auto" == serverType) {
LOG_DEBUG("determining server type");
serverType = IO::GetServerTypeByUrl("/version/");
LOG_DEBUG_W(L"server type is '" + serverType + L"'");
}
if (L"jboss4" != serverType && L"jboss7" != serverType) {
throw L"Unknown server type: '" + serverType + L"'";
}
return serverType;
}
wstring RtnResources::GetServerVersion() {
wstring serverVersion = GetOption(L"server.version", L"auto");
if (L"auto" == serverVersion) {
LOG_DEBUG("determining server version");
serverVersion = IO::GetRunaVersionByUrl("/wfe/version");
LOG_DEBUG_W(L"server version is '" + serverVersion + L"'");
}
return serverVersion;
}
wstring RtnResources::GetWebServiceURL(wstring serverType, wstring serverVersion, wstring serviceName) {
wstring serverName = GetOption(L"server.name", L"localhost");
wstring serverPort = GetOption(L"server.port", L"8080");
wstring result;
if (L"jboss4" == serverType) {
result = L"http://" + serverName + L":" + serverPort + L"/runawfe-wfe-service-" + serverVersion + L"/" + serviceName + L"ServiceBean";
} else {
result = L"http://" + serverName + L":" + serverPort + L"/wfe-service-" + serverVersion + L"/" + serviceName + L"WebService/" + serviceName + L"API";
}
return result;
}
wstring RtnResources::GetBrowserStartURL() {
const wstring serverName = RtnResources::GetOption(L"server.name", L"localhost");
const wstring serverPort = RtnResources::GetOption(L"server.port", L"8080");
const wstring loginRelativeURL = RtnResources::GetOption(L"login.relative.url", L"/login.do");
return L"http://" + serverName + L":" + serverPort + L"/wfe" + loginRelativeURL;
}
wstring RtnResources::GetLogFile() {
return GetOption(L"debug.log.file", L"");
}
wstring RtnResources::GetApplicationTitle() {
return GetOption(L"application.title", L"RunaWFE tasks notifier");
}
bool RtnResources::GetUserInputLoginSilenty(){
wstring debug = RtnResources::GetOption(L"userinput.login.silently", L"false");
return debug.compare(L"true") == 0;
}
wstring RtnResources::GetUserInputDefaultLogin(){
return GetOption(L"userinput.default.login", L"Administrator");
}
wstring RtnResources::GetUserInputDefaultPassword(){
return GetOption(L"userinput.default.password", L"wf");
}
wstring RtnResources::GetAuthenticationType(){
return GetOption(L"authentication.type", L"userinput");
}
wstring RtnResources::GetButtonLoginText(){
return GetOption(L"button.login", L"Enter");
}
wstring RtnResources::GetLabelLoginText(){
return GetOption(L"label.login ", L"Login");
}
wstring RtnResources::GetLabelPasswordText(){
return GetOption(L"label.password", L"Password");
}
wstring RtnResources::GetLabelLoginTitle(){
return GetOption(L"label.login.title", L"Please log in");
}