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

Comparing trunk/Publisher.cpp (file contents):
Revision 21 by douglas, 2004-07-16T23:37:41-07:00 vs.
Revision 30 by douglas, 2004-07-19T21:24:52-07:00

# Line 5 | Line 5
5   // $Id$
6  
7   #include "Publisher.hpp"
8 + #include "Rss.hpp"
9  
10   Publisher::Publisher(const std::set<Buddy>& buddies, const Database& database,
11          bool start) : buddies(buddies), database(database), start(start)
# Line 17 | Line 18 | Publisher::Publisher(const std::set<Budd
18  
19   int Publisher::publish()
20   {
21 <        cerr << "Publisher::publish()\n";
21 >        cerr << bright << green << "Publisher::publish()\n" << reset;
22  
23          // publish
24 +
25 +        update();
26 + }
27 +
28 + void Publisher::update()
29 + {
30 +        Stamp stamp;
31 +        ext::Handle<dbi::Connection> db(dbi::Connect(database.driver, database.host,
32 +                database.user, database.password, database.db));
33 +
34 +        db->Execute("DELETE FROM messages WHERE stamp<'" + (stamp - 30) + "'");
35 +
36 +        for (std::set<Buddy>::const_iterator buddy(buddies.begin()); buddy !=
37 +                buddies.end(); ++buddy)
38 +        {
39 +                ext::Handle<dbi::ResultSet> messages(db->Execute(ext::String("SELECT s")
40 +                        + "tamp, message FROM messages WHERE id='" +
41 +                        lexical_cast<ext::String>(buddy->getId()) + "'"));
42 +                std::vector<AwayMessage> messages_;
43 +
44 +                while (messages->MoveNext())
45 +                        messages_.push_back(AwayMessage(messages->GetString("message"),
46 +                        messages->GetString("stamp")));
47 +
48 +                Rss rss(*buddy, messages_, stamp);
49 +        }
50   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines