1 |
// Zoe AIM Away Message RSS Feed Generator |
2 |
// |
3 |
// Seth King and Douglas Thrift |
4 |
// |
5 |
// $Id$ |
6 |
|
7 |
#include "Atom.hpp" |
8 |
|
9 |
Atom::Atom(const Buddy& buddy, const std::vector<AwayMessage>& messages, const Stamp& stamp) |
10 |
{ |
11 |
api::FileOutputStream fout(buddy.getAtom() != "-" ? buddy.getAtom() : "/dev/null"); |
12 |
xml::TextWriter atom(buddy.getAtom() != "-" ? fout : api::Cout.GetStream()); |
13 |
xml::ScopeElement feed(atom, "feed"); |
14 |
|
15 |
atom.SetAttribute("version", "0.3"); |
16 |
atom.SetAttribute("xmlns", "http://purl.org/atom/ns#"); |
17 |
atom.OpenElement("title"); |
18 |
atom.SetAttribute("mode", "escaped"); |
19 |
atom.OutputText(ext::String(buddy) + "'s Away Messages"); |
20 |
atom.CloseElement(); |
21 |
atom.OpenElement("link"); |
22 |
atom.SetAttribute("rel", "alternate"); |
23 |
atom.SetAttribute("type", "text/html"); // XXX |
24 |
atom.SetAttribute("href", "http://computers.douglasthrift.net/zoe.xml"); |
25 |
atom.CloseElement(); |
26 |
atom.OpenElement("author"); |
27 |
atom.OpenElement("name"); |
28 |
atom.OutputText(buddy); |
29 |
atom.CloseElement(); |
30 |
atom.CloseElement(); |
31 |
atom.OpenElement("tagline"); |
32 |
atom.SetAttribute("mode", "escaped"); |
33 |
atom.OutputText(ext::String(buddy) + "'s AIM Away Messages from the past 30 days."); |
34 |
atom.CloseElement(); |
35 |
atom.OpenElement("generator"); |
36 |
atom.SetAttribute("url", Zoe::generator(Zoe::url)); |
37 |
atom.SetAttribute("version", Zoe::generator(Zoe::version)); |
38 |
atom.OutputText(Zoe::generator(Zoe::agent)); |
39 |
atom.CloseElement(); |
40 |
atom.OpenElement("modified"); |
41 |
atom.OutputText(stamp.getW3()); |
42 |
atom.CloseElement(); |
43 |
|
44 |
for (std::vector<AwayMessage>::const_iterator message(messages.begin()); |
45 |
message != messages.end(); ++message) |
46 |
{ |
47 |
xml::ScopeElement entry(atom, "entry"); |
48 |
|
49 |
atom.OpenElement("title"); |
50 |
atom.CloseElement(); |
51 |
atom.OpenElement("link"); |
52 |
atom.SetAttribute("rel", "alternate"); |
53 |
atom.SetAttribute("type", "text/html"); // XXX |
54 |
atom.SetAttribute("href", "http://computers.douglasthrift.net/zoe.xml"); |
55 |
atom.CloseElement(); |
56 |
atom.OpenElement("id"); |
57 |
atom.OutputText("zoe:" + ext::String(buddy) + ":" + message->getStamp().getW3()); |
58 |
atom.CloseElement(); |
59 |
atom.OpenElement("modified"); |
60 |
atom.OutputText(message->getStamp().getW3()); |
61 |
atom.CloseElement(); |
62 |
atom.OpenElement("issued"); |
63 |
atom.OutputText(message->getStamp().getW3()); |
64 |
atom.CloseElement(); |
65 |
atom.OpenElement("content"); |
66 |
atom.SetAttribute("type", "text/html"); |
67 |
atom.SetAttribute("mode", "escaped"); |
68 |
atom.OutputText(*message); |
69 |
atom.CloseElement(); |
70 |
} |
71 |
} |