This repository has been archived by the owner on Apr 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsection.cpp
148 lines (134 loc) · 4.34 KB
/
section.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
145
146
147
148
#include "stdafx.h"
#include "konnekt/kupdate.h"
#include "update.h"
#include "interface.h"
namespace kUpdate {
cPackBase * cSection::ByName(CStdString name) {
if (this->name == name) return this;
cPackBase * found = 0;
for (tData::iterator i = data.begin(); i!=data.end(); i++)
if ((found = (*i)->ByName(name))) return found;
return 0;
}
bool cSection::HasSelected(bool maximize) {
if (cPackBase::HasSelected(maximize)) return true;
for (tData::iterator i = data.begin(); i!=data.end(); i++)
if ((*i)->HasSelected(maximize)) return true;
return false;
}
bool cSection::NeedRestart() {
for (tData::iterator i = data.begin(); i!=data.end(); i++)
if ((*i)->NeedRestart()) return true;
return false;
}
bool cSection::Check(bool recursive) {
bool sel = cPackBase::Check(recursive);
if (sel || recursive) {
for (tData::iterator i = data.begin(); i!=data.end(); i++)
if (recursive || (*i)->selection==inherit)
if ((*i)->Check(recursive)) sel=true;
}
return sel;
}
int cSection::GetSize() {
int size = 0;
for (tData::iterator i = data.begin(); i!=data.end(); i++)
size+=(*i)->GetSize();
return size;
}
void cSection::AutoSelect(AutoSelection::nType type , bool recurse) {
cPackBase::AutoSelect(type , recurse);
if (!recurse) return;
for (tData::iterator i = data.begin(); i!=data.end(); i++)
(*i)->AutoSelect(type , recurse);
}
CStdString cSection::GetSectionName() {
CStdString parentName = parent->GetSectionName();
if (parentName.empty())
return this->name;
else
return parentName + "/" + this->name;
}
void cSection::Download() {
for (tData::iterator i = data.begin(); i!=data.end(); i++)
(*i)->Download();
}
void cSection::CreateScript(ofstream &f) {
//f << "echo \"----- Sekcja "<< this->name <<"\""<< endl;
for (tData::iterator i = data.begin(); i!=data.end(); i++)
(*i)->CreateScript(f);
}
void cSectionBranch::CreateScript(ofstream & f) {
f << "echo \"--------------------------------\"" << endl;
f << "echo \"Zestaw - " << this->name << " - '" << this->title << "'\"" << endl;
f << "echo \"Rewizja - " << this->revision << " / " << this->revisionDate << "\"" << endl;
f << "echo \"--------------------------------\"" << endl;
cSection::CreateScript(f);
}
bool cSection::ReadNode(const CStdString & node) {
Stamina::SXML XML;
// Wczytujemy info o sekcji...
XML.loadSource(node);
this->info = XML.getText("section/info");
XML.prepareNode("section" , true);
this->name = XML.getAttrib("name");
this->url = XML.getAttrib("url");
this->title = XML.getAttrib("title");
this->dlUrl = XML.getAttrib("dlURL");
this->path = XML.getAttrib("path");
// wczytujemy sekcje...
CStdString item;
XML.loadSource(XML.getContent().c_str());
while (!(item = XML.getNode("section")).empty()) {
cSection * section = new cSection(this);
if (!section->ReadNode(item))
delete section;
else
this->data.push_back(section);
XML.next();
}
XML.restart();
// a teraz paczki
while (!(item = XML.getNode("pack")).empty()) {
cPackBase * pack;
XML.prepareNode("pack",true);
pack = XML.getAttrib("single") == "1" ? (cPackBase*)new cPackSingle(this) : (cPackBase*)new cPackFiles(this);
if (!pack->ReadNode(item))
delete pack;
else
this->data.push_back(pack);
XML.next();
}
return true;
}
bool cSectionBranch::ReadNode(const CStdString & node) {
Stamina::SXML XML;
XML.loadSource(node);
XML.prepareNode("update");
this->revision = XML.getAttrib("revision");
this->revisionDate = XML.getAttrib("date");
// normalnie czytamy sekcjê...
cSection::ReadNode(XML.getNode("update/section"));
this->info = InfoValue("Aktualizacja" , revision) + InfoValue("Data" , revisionDate) + this->info;
return true;
}
CStdString cSection::GetRevLog(__time64_t since) {
CStdString revs;
/* paczki */
for (tData::iterator i = data.begin(); i!=data.end(); i++) {
if ((*i)->Type() < nType::pack) continue;
CStdString rev = (*i)->GetRevLog(since);
if (!rev.empty())
rev = "<div class='rev_p'>" + (*i)->title + "</div>" + rev;
revs += rev;
}
for (tData::iterator i = data.begin(); i!=data.end(); i++) {
if ((*i)->Type() >= nType::pack) continue;
CStdString rev = (*i)->GetRevLog(since);
if (!rev.empty())
rev = "<div class='rev_s'>" + (*i)->title + "</div>" + rev;
revs += rev;
}
return revs;
}
};