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 33 by douglas, 2004-07-20T00:40:43-07:00 vs.
Revision 34 by douglas, 2004-07-20T16:49:06-07:00

# Line 7 | Line 7
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)
10 > Publisher::Publisher(const std::set<Buddy>& buddies, const Database& database, bool start) : buddies(buddies),
11 >        database(database), start(start)
12   {
13 <        if (start)
14 <        {
15 <                publisher.Spawn(etl::Bind<0>(&Publisher::publish, this));
16 <        }
13 >        if (start) publisher.Spawn(etl::Bind<0>(&Publisher::publish, this));
14   }
15  
16   int Publisher::publish()
# Line 24 | Line 21 | int Publisher::publish()
21  
22          while (true)
23          {
24 <                Stamp start, now;
24 >                double next(api::GetWallTimerSeconds() + Hour(1)), now;
25  
26                  update();
27  
# Line 32 | Line 29 | int Publisher::publish()
29                  {
30                          sleep(Minute(1));
31  
32 <                        now = Stamp();
32 >                        now = api::GetWallTimerSeconds();
33                  }
34 <                while (now < start + Hour(1));
34 >                while (now < next);
35          }
36   }
37  
# Line 43 | Line 40 | void Publisher::update()
40          cerr << bright << yellow << "Publisher::update()\n" << reset;
41  
42          Stamp stamp;
43 <        ext::Handle<dbi::Connection> db(dbi::Connect(database.driver, database.host,
44 <                database.user, database.password, database.db));
43 >        ext::Handle<dbi::Connection> db(dbi::Connect(database.driver, database.host, database.user, database.password,
44 >                database.db));
45  
46 <        db->Execute("DELETE FROM messages WHERE stamp<'" + (stamp - Day(30)) + "'");
46 >        db->Execute("DELETE FROM messages WHERE stamp<'" + ext::String(stamp - Day(30)) + "'");
47  
48 <        for (std::set<Buddy>::const_iterator buddy(buddies.begin()); buddy !=
52 <                buddies.end(); ++buddy)
48 >        for (std::set<Buddy>::const_iterator buddy(buddies.begin()); buddy != buddies.end(); ++buddy)
49          {
50 <                ext::Handle<dbi::ResultSet> messages(db->Execute(ext::String("SELECT s")
51 <                        + "tamp, message FROM messages WHERE id='" +
56 <                        lexical_cast<ext::String>(buddy->getId()) + "'"));
50 >                ext::Handle<dbi::ResultSet> messages(db->Execute("SELECT stamp, message FROM messages WHERE id='"
51 >                        + lexical_cast<ext::String>(buddy->getId()) + "'"));
52                  std::vector<AwayMessage> messages_;
53  
54 <                while (messages->MoveNext())
60 <                        messages_.push_back(AwayMessage(messages->GetString("message"),
54 >                while (messages->MoveNext()) messages_.push_back(AwayMessage(messages->GetString("message"),
55                          messages->GetString("stamp")));
56  
57                  Rss rss(*buddy, messages_, stamp);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines