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 32 by douglas, 2004-07-20T00:40:43-07:00 vs.
Revision 35 by douglas, 2004-07-21T20:43:31-07:00

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines