4 |
|
// |
5 |
|
// $Id$ |
6 |
|
|
7 |
– |
#include "Zoe.hpp" |
7 |
|
#include "Matcher.hpp" |
8 |
+ |
#include "Buddy.hpp" |
9 |
|
|
10 |
|
int main(int argc, char* argv[]) |
11 |
|
{ |
12 |
< |
// |
12 |
> |
Zoe::program = argv[0]; |
13 |
> |
|
14 |
> |
for (int index(1); index < argc; ++index) |
15 |
> |
{ |
16 |
> |
ext::String arg(argv[index]); |
17 |
> |
Matcher matcher; |
18 |
> |
|
19 |
> |
if (arg == matcher("^-config=(.*)$")) |
20 |
> |
{ |
21 |
> |
Zoe::config = matcher[1]; |
22 |
> |
} |
23 |
> |
else if (arg == "-D") |
24 |
> |
{ |
25 |
> |
if (!Zoe::debug) Zoe::debug = true; |
26 |
> |
} |
27 |
> |
else |
28 |
> |
{ |
29 |
> |
cerr << "Usage: " << Zoe::program << " [-config=config] [-D]\n"; |
30 |
> |
|
31 |
> |
return 1; |
32 |
> |
} |
33 |
> |
} |
34 |
> |
|
35 |
> |
Zoe zoe; |
36 |
|
|
37 |
|
return 0; |
38 |
|
} |
39 |
+ |
|
40 |
+ |
Zoe::Zoe() |
41 |
+ |
{ |
42 |
+ |
configure(); |
43 |
+ |
|
44 |
+ |
// This is just to figure out Jay's XML output, seems to have worked! |
45 |
+ |
// It should really go in Rss.cpp later |
46 |
+ |
/* api::FileOutputStream fout(this->rss != "-" ? this->rss : "/dev/null"); |
47 |
+ |
xml::TextWriter rss(this->rss != "-" ? fout : api::Cout.GetStream()); |
48 |
+ |
xml::ScopeElement root(rss, "rss"); |
49 |
+ |
|
50 |
+ |
rss.SetAttribute("version", "2.0"); |
51 |
+ |
|
52 |
+ |
xml::ScopeElement channel(rss, "channel"); |
53 |
+ |
|
54 |
+ |
rss.OpenElement("title"); |
55 |
+ |
rss.OutputText("Zoe's Away Messages"); |
56 |
+ |
rss.CloseElement(); |
57 |
+ |
rss.OpenElement("link"); |
58 |
+ |
rss.OutputText("http://computers.douglasthrift.net/zoe.xml"); |
59 |
+ |
rss.CloseElement();*/ |
60 |
+ |
} |
61 |
+ |
|
62 |
+ |
bool Zoe::debug(false); |
63 |
+ |
ext::String Zoe::program, Zoe::config("zoe.xml"); |
64 |
+ |
|
65 |
+ |
void Zoe::configure() |
66 |
+ |
{ |
67 |
+ |
ext::Handle<xml::Document> document(xml::Parse(config)); |
68 |
+ |
ext::Handle<xml::Node> zoe(*document/"zoe"); |
69 |
+ |
|
70 |
+ |
login = std::string(*zoe/"login"); |
71 |
+ |
password = std::string(*zoe/"password"); |
72 |
+ |
|
73 |
+ |
xml::NodeSet buddies(*zoe/"buddy"); |
74 |
+ |
|
75 |
+ |
for (xml::NodeSet::Iterator buddy(buddies.Begin()); buddy != buddies.End(); |
76 |
+ |
++buddy) |
77 |
+ |
{ |
78 |
+ |
this->buddies.insert(Buddy(**buddy/"login", **buddy/"rss")); |
79 |
+ |
} |
80 |
+ |
} |