ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/zoe/trunk/Zoe.cpp
(Generate patch)

Comparing trunk/Zoe.cpp (file contents):
Revision 8 by douglas, 2004-07-09T18:13:27-07:00 vs.
Revision 15 by douglas, 2004-07-13T20:14:49-07:00

# Line 4 | Line 4
4   //
5   // $Id$
6  
7 #include "Zoe.hpp"
7   #include "Matcher.hpp"
8 + #include "Collector.hpp"
9 + #include "Publisher.hpp"
10 +
11 + enum Color { reset, bright, dim, underscore = 4, blink, reverse = 7, hidden,
12 +        black = 30, red, green, yellow, blue, magenta, cyan, white, _black = 40,
13 +        _red, _green, _yellow, _blue, _magenta, _cyan, _white };
14 +
15 + inline std::ostream& operator<<(std::ostream& sout, Color color)
16 + {
17 +        sout << "\033[" << unsigned(color) << 'm';
18 +
19 +        return sout;
20 + }
21  
22   int main(int argc, char* argv[])
23   {
# Line 20 | Line 32 | int main(int argc, char* argv[])
32                  {
33                          Zoe::config = matcher[1];
34                  }
35 +                else if (arg == "-collector")
36 +                {
37 +                        if (!Zoe::collector) Zoe::collector = true;
38 +                }
39 +                else if (arg == "-publisher")
40 +                {
41 +                        if (!Zoe::publisher) Zoe::publisher = true;
42 +                }
43                  else if (arg == "-D")
44                  {
45                          if (!Zoe::debug) Zoe::debug = true;
46                  }
47                  else
48                  {
49 <                        cerr << "Usage: " << Zoe::program << " [-config=config] [-D]\n";
49 >                        cerr << bright << "Usage: " << cyan << Zoe::program << reset << " ["
50 >                                << bright << blue <<  "-config=" << yellow << "config" << reset
51 >                                << "] [" << bright << blue << "-collector" << reset << "] ["
52 >                                << bright << blue << "-publisher" << reset << "] [" << bright
53 >                                << blue << "-D" << reset << "]\n";
54 >
55 >                        return 1;
56                  }
57          }
58  
# Line 35 | Line 61 | int main(int argc, char* argv[])
61          return 0;
62   }
63  
64 < Zoe::Zoe() : rss("zoe.rss")
64 > Zoe::Zoe()
65   {
66          configure();
67  
68 <        // This is just to figure out Jay's XML output, seems to have worked!
69 <        xml::TextWriter rss(api::Cout.GetStream());
44 <        xml::ScopeElement root(rss, "rss");
45 <
46 <        rss.SetAttribute("version", "2.0");
47 <
48 <        xml::ScopeElement channel(rss, "channel");
49 <
50 <        rss.OpenElement("title");
51 <        rss.OutputText("Zoe's Away Messages");
52 <        rss.CloseElement();
53 <        rss.OpenElement("link");
54 <        rss.OutputText("http://computers.douglasthrift.net/zoe.xml");
55 <        rss.CloseElement();
68 >        Collector collector(login, password, buddies, Zoe::collector);
69 >        Publisher publisher(buddies, Zoe::publisher);
70   }
71  
72 < bool Zoe::debug(false);
72 > bool Zoe::debug(false), Zoe::collector(false), Zoe::publisher(false);
73   ext::String Zoe::program, Zoe::config("zoe.xml");
74  
75   void Zoe::configure()
# Line 63 | Line 77 | void Zoe::configure()
77          ext::Handle<xml::Document> document(xml::Parse(config));
78          ext::Handle<xml::Node> zoe(*document/"zoe");
79  
80 <        login = *zoe/"login";
81 <        password = *zoe/"password";
80 >        login = std::string(*zoe/"login");
81 >        password = std::string(*zoe/"password");
82 >
83 >        xml::NodeSet buddies(*zoe/"buddy");
84 >
85 >        for (xml::NodeSet::Iterator buddy(buddies.Begin()); buddy != buddies.End();
86 >                ++buddy)
87 >        {
88 >                this->buddies.insert(Buddy(**buddy/"login", **buddy/"rss"));
89 >        }
90  
91 <        if (!(*zoe/"rss").IsEmpty()) rss = *zoe/"rss";
91 >        if (!collector && !publisher)
92 >        {
93 >                collector = true;
94 >                publisher = true;
95 >        }
96   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines