-
Notifications
You must be signed in to change notification settings - Fork 2
/
ApplicationManager.cpp
114 lines (97 loc) · 3.7 KB
/
ApplicationManager.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
/*
* File: ApplicationManager.cpp
* Author: mike
*
* Created on January 17, 2012, 12:57 PM
*/
#include <iostream>
#include <fstream>
#include <list>
#include <cstdlib>
#include "Parser/XPath.h"
#include "Parser/XMLParser.h"
#include "ApplicationManager.h"
ApplicationManager::ApplicationManager() {
}
ApplicationManager::ApplicationManager(const ApplicationManager& orig) {
}
ApplicationManager::~ApplicationManager() {
}
std::string ApplicationManager::readLine(char* text) {
char* ch = text;
std::string out;
while(*ch!='\n' && *ch!='\r' && *ch!='\0') {
out += *ch;
ch++;
}
return out;
}
ConnectionConfiguration ApplicationManager::loadConfigurationFromFile(std::string filename) {
ConnectionConfiguration cconf;
Parser::XPath* xPath;
Parser::XMLParser* parser;
xPath = new Parser::XPath("/configuration/sip_external_port");
parser = new Parser::XMLParser(filename.c_str(), *xPath);
try { parser->program(); }
catch(char const* err) { std::cout << err << std::endl; }
cconf.sipExternalPort = atoi(parser->getResult().front().c_str());
delete xPath;
delete parser;
xPath = new Parser::XPath("/configuration/sip_internal_port");
parser = new Parser::XMLParser(filename.c_str(), *xPath);
try { parser->program(); }
catch(char const* err) { std::cout << err << std::endl; }
cconf.sipInternalPort = atoi(parser->getResult().front().c_str());
delete xPath;
delete parser;
xPath = new Parser::XPath("/configuration/sip_proxy_port");
parser = new Parser::XMLParser(filename.c_str(), *xPath);
try { parser->program(); }
catch(char const* err) { std::cout << err << std::endl; }
cconf.sipProxyPort = atoi(parser->getResult().front().c_str());
delete xPath;
delete parser;
xPath = new Parser::XPath("/configuration/rtp_external_port");
parser = new Parser::XMLParser(filename.c_str(), *xPath);
try { parser->program(); }
catch(char const* err) { std::cout << err << std::endl; }
cconf.rtpExternalPort = atoi(parser->getResult().front().c_str());
delete xPath;
delete parser;
xPath = new Parser::XPath("/configuration/rtp_internal_port");
parser = new Parser::XMLParser(filename.c_str(), *xPath);
try { parser->program(); }
catch(char const* err) { std::cout << err << std::endl; }
cconf.rtpInternalPort = atoi(parser->getResult().front().c_str());
delete xPath;
delete parser;
xPath = new Parser::XPath("/configuration/sip_proxy_host");
parser = new Parser::XMLParser(filename.c_str(), *xPath);
try { parser->program(); }
catch(char const* err) { std::cout << err << std::endl; }
cconf.sipProxyHost = parser->getResult().front();
delete xPath;
delete parser;
xPath = new Parser::XPath("/configuration/local_ip");
parser = new Parser::XMLParser(filename.c_str(), *xPath);
try { parser->program(); }
catch(char const* err) { std::cout << err << std::endl; }
cconf.localIP= parser->getResult().front();
delete xPath;
delete parser;
xPath = new Parser::XPath("/configuration/rtp_mean");
parser = new Parser::XMLParser(filename.c_str(), *xPath);
try { parser->program(); }
catch(char const* err) { std::cout << err << std::endl; }
cconf.rtpMean = atoi(parser->getResult().front().c_str());
delete xPath;
delete parser;
xPath = new Parser::XPath("/configuration/rtp_std_dev");
parser = new Parser::XMLParser(filename.c_str(), *xPath);
try { parser->program(); }
catch(char const* err) { std::cout << err << std::endl; }
cconf.rtpStdDev = atoi(parser->getResult().front().c_str());
delete xPath;
delete parser;
return cconf;
}