-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfwizard.cc
95 lines (84 loc) · 2.7 KB
/
confwizard.cc
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
#include <openssl/rand.h>
#include <iostream>
#include <string>
using namespace std;
#include "debugbox.h"
#include "tinyxml.h"
#include "base64.h"
#include "confwizard.h"
ConfWizard::ConfWizard(const char * const filename) {
#ifdef DEBUG
debug("ConfWizard: " + string(filename));
#endif
TiXmlDocument xmldoc(filename);
xmldoc.LoadFile();
TiXmlElement* root = xmldoc.FirstChildElement(); // <conference>
if (!root) {
return;
critical("ConfWizard: unable to load conf.xml");
}
a = new Announcement();
a->setOwner(true);
a->setAudio(true);
TiXmlNode* node = root->FirstChild();
TiXmlElement* elem = root->FirstChildElement();
while (node) {
string attr = node->ValueStr();
string value = string(elem->GetText());
if (attr == "confName") {
a->setConfName(value);
} else if (attr == "organizer") {
a->setOrganizer(value);
} else if (attr == "email") {
a->setEmail(value);
} else if (attr == "video") {
if (value == "true" || value == "True") {
a->setVideo(true);
} else {
a->setVideo(false);
}
} else if (attr == "confDesc") {
a->setDesc(value);
} else if (attr == "date") {
a->setDate(value);
} else if (attr == "time") {
a->setTime(value);
} else if (attr == "hours") {
a->setHours(atoi(value.c_str()));
} else if (attr == "minutes") {
a->setMinutes(atoi(value.c_str()));
} else if (attr == "private") {
if (value == "true" || value == "True") {
a->setIsPrivate(true);
unsigned char bytes[32];
RAND_bytes(bytes, 32);
char * qba = base64((unsigned char *) bytes, int(32));
string opaqueName(qba);
free(qba);
a->setOpaqueName(opaqueName);
a->initConferenceKey();
a->initAudioSessionKey();
/*
* TODO
* QSettings settings("UCLA-IRL", "ACTD");
* QString qsCerts = settings.value("qsCerts").toString();
* settings.setValue("qsCerts", "");
* QStringList certs = qsCerts.split(":");
* a->setCerts(certs);
*/
list<string> certs;
a->setCerts(certs);
} else {
a->setIsPrivate(false);
}
}
node = node->NextSibling();
elem = elem->NextSiblingElement();
}
}
ConfWizard::~ConfWizard() {
delete a;
}
Announcement *ConfWizard::getAnnouncement() {
return a;
}