blob: 148a7fd1c2a46b8d8f7d580c0e99d6a6e55c9977 (
plain) (
blame)
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
|
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "RemoteMntFrm.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TRemoteMntForm *RemoteMntForm;
class TRemoteSource : public TObject {
public:
string name;
string machine;
string dir;
TRemoteSource(const char *confEnt) {
char *buf = new char [ strlen(confEnt) + 1 ];
strcpy(buf, confEnt);
name = strtok(buf, "|");
machine = strtok(0, "|");
dir = strtok(0, "|");
delete [] buf;
}
string getConfEnt() {
return name +"|" + machine + "|" + dir;
}
};
//---------------------------------------------------------------------------
__fastcall TRemoteMntForm::TRemoteMntForm(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TRemoteMntForm::FormShow(TObject *Sender)
{
ConfigEntMap::iterator loop, end;
config = new SWConfig("./InstallMgr.conf");
ListBox1->Clear();
loop = config->Sections["Sources"].lower_bound("FTPSource");
end = config->Sections["Sources"].upper_bound("FTPSource");
while (loop != end) {
TRemoteSource *rs = new TRemoteSource(loop->second.c_str());
ListBox1->Items->AddObject(rs->name.c_str(), rs);
loop++;
}
ListBox1->ItemIndex = 0;
ListBox1Click(0);
CheckBox1->Checked = (!stricmp((*config)["General"]["PassiveFTP"].c_str(), "true"));
checkDisabled();
}
void TRemoteMntForm::checkDisabled() {
bool enabled = ListBox1->Items->Count;
NameEdit->Enabled = enabled;
MachineEdit->Enabled = enabled;
DirEdit->Enabled = enabled;
}
//---------------------------------------------------------------------------
void __fastcall TRemoteMntForm::FormClose(TObject *Sender,
TCloseAction &Action)
{
delete config;
}
void __fastcall TRemoteMntForm::SpeedButton4Click(TObject *Sender)
{
ModalResult = mrCancel;
}
void __fastcall TRemoteMntForm::ListBox1Click(TObject *Sender)
{
if (ListBox1->ItemIndex >= 0) {
TRemoteSource *rs = (TRemoteSource *)ListBox1->Items->Objects[ListBox1->ItemIndex];
NameEdit->Text = rs->name.c_str();
MachineEdit->Text = rs->machine.c_str();
DirEdit->Text = rs->dir.c_str();
}
else {
NameEdit->Text = "";
MachineEdit->Text = "";
DirEdit->Text = "";
}
}
void __fastcall TRemoteMntForm::NameEditChange(TObject *Sender)
{
if (ListBox1->ItemIndex < 0)
return;
TRemoteSource *rs = (TRemoteSource *)ListBox1->Items->Objects[ListBox1->ItemIndex];
rs->name = NameEdit->Text.c_str();
ListBox1->Items->Strings[ListBox1->ItemIndex] = rs->name.c_str();
}
void __fastcall TRemoteMntForm::MachineEditChange(TObject *Sender)
{
if (ListBox1->ItemIndex < 0)
return;
TRemoteSource *rs = (TRemoteSource *)ListBox1->Items->Objects[ListBox1->ItemIndex];
rs->machine = MachineEdit->Text.c_str();
}
void __fastcall TRemoteMntForm::DirEditChange(TObject *Sender)
{
if (ListBox1->ItemIndex < 0)
return;
TRemoteSource *rs = (TRemoteSource *)ListBox1->Items->Objects[ListBox1->ItemIndex];
rs->dir = DirEdit->Text.c_str();
}
void __fastcall TRemoteMntForm::SpeedButton2Click(TObject *Sender)
{
if (ListBox1->ItemIndex < 0)
return;
int delItem = ListBox1->ItemIndex;
ListBox1->Items->Delete(delItem);
ListBox1->ItemIndex = (delItem < ListBox1->Items->Count) ? delItem : delItem - 1;
checkDisabled();
ListBox1Click(0);
}
//---------------------------------------------------------------------------
void __fastcall TRemoteMntForm::SpeedButton1Click(TObject *Sender)
{
TRemoteSource *rs = new TRemoteSource("[New Remote Site]|ftp.domain.org|/pub/sword/raw/");
ListBox1->ItemIndex = ListBox1->Items->AddObject(rs->name.c_str(), rs);
checkDisabled();
ListBox1Click(0);
}
//---------------------------------------------------------------------------
void __fastcall TRemoteMntForm::SpeedButton3Click(TObject *Sender)
{
TRemoteSource *rs;
config->Sections["Sources"].erase("FTPSource");
for (int i = 0; i < ListBox1->Items->Count; i++) {
rs = (TRemoteSource *)ListBox1->Items->Objects[i];
config->Sections["Sources"].insert(ConfigEntMap::value_type("FTPSource", rs->getConfEnt().c_str()));
}
(*config)["General"]["PassiveFTP"] = (CheckBox1->Checked) ? "true" : "false";
config->Save();
ModalResult = mrOk;
}
//---------------------------------------------------------------------------
|