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