--- trunk/Publisher.cpp 2004/07/20 04:24:52 30 +++ trunk/Publisher.cpp 2004/08/16 06:40:19 44 @@ -6,45 +6,43 @@ #include "Publisher.hpp" #include "Rss.hpp" +#include "Atom.hpp" -Publisher::Publisher(const std::set& buddies, const Database& database, - bool start) : buddies(buddies), database(database), start(start) +Publisher::Publisher(const std::set& buddies, const Database& database, bool start) : buddies(buddies), + database(database), start(start) { - if (start) - { - publisher.Spawn(etl::Bind<0>(&Publisher::publish, this)); - } + if (start) publish(); } -int Publisher::publish() +void Publisher::publish() { - cerr << bright << green << "Publisher::publish()\n" << reset; - - // publish - - update(); -} + cerr << bright << yellow << "Started updating feeds at " << Stamp() + << ".\n" << reset; -void Publisher::update() -{ Stamp stamp; ext::Handle db(dbi::Connect(database.driver, database.host, database.user, database.password, database.db)); - db->Execute("DELETE FROM messages WHERE stamp<'" + (stamp - 30) + "'"); + db->Execute("DELETE FROM messages WHERE stamp<'" + + ext::String(stamp - Day(30)) + "'"); - for (std::set::const_iterator buddy(buddies.begin()); buddy != - buddies.end(); ++buddy) + for (std::set::const_iterator buddy(buddies.begin()); + buddy != buddies.end(); ++buddy) { - ext::Handle messages(db->Execute(ext::String("SELECT s") - + "tamp, message FROM messages WHERE id='" + - lexical_cast(buddy->getId()) + "'")); + ext::Handle messages(db->Execute("SELECT stamp, message FROM messages WHERE id='" + + lexical_cast(buddy->getId()) + "'")); std::vector messages_; - while (messages->MoveNext()) - messages_.push_back(AwayMessage(messages->GetString("message"), + while (messages->MoveNext()) messages_.push_back(AwayMessage(messages->GetString("message"), messages->GetString("stamp"))); Rss rss(*buddy, messages_, stamp); + Atom atom(*buddy, messages_, stamp); + + cerr << bright << yellow << "Updated feeds for " << blue << *buddy + << yellow << ".\n" << reset; } + + cerr << bright << yellow << "Finished updating feeds at " << Stamp() + << ".\n" << reset; }