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

Comparing trunk/Buddy.cpp (file contents):
Revision 31 by douglas, 2004-07-20T00:11:56-07:00 vs.
Revision 59 by douglas, 2004-09-13T23:39:30-07:00

# Line 5 | Line 5
5   // $Id$
6  
7   #include "Zoe.hpp"
8 +
9 + ext::String Buddy::getRssLink() const
10 + {
11 +        std::string link(this->link);
12 +        
13 +        return link.substr(0, link.rfind('/')) + '/' + rss;
14 + }
15 +
16 + ext::String Buddy::getAtomLink() const
17 + {
18 +        std::string link(this->link);
19 +
20 +        return link.substr(0, link.rfind('/')) + '/' + atom;
21 + }
22 +
23 + ext::String Buddy::getDisplay(const Database& database) const
24 + {
25 +        ext::Handle<dbi::Driver> driver(dbi::GetDriver(database.driver));
26 +        ext::Handle<dbi::Connection> db(driver->Connect(database.host,
27 +                database.user, database.password, database.db));
28 +        ext::Handle<dbi::ResultSet> display(db->Execute("SELECT display "
29 +                "FROM displays WHERE id='" + lexical_cast<ext::String>(id) + "'"));
30 +
31 +        if (display->MoveNext()) return display->GetString("display");
32 +        else return login;
33 + }
34 +
35 + void Buddy::setDisplay(const ext::String& display, const Database& database) const
36 + {
37 +        ext::Handle<dbi::Driver> driver(dbi::GetDriver(database.driver));
38 +        ext::Handle<dbi::Connection> db(driver->Connect(database.host,
39 +                database.user, database.password, database.db));
40 +        ext::Handle<dbi::ResultSet> update(db->Execute("SELECT * FROM displays "
41 +                "WHERE id = '" + lexical_cast<ext::String>(id) + "'"));
42 +
43 +        if (update->MoveNext()) db->Execute("UPDATE displays SET display='"
44 +                + display + "' WHERE id='" + lexical_cast<ext::String>(id) + "'");
45 +        else db->Execute("INSERT INTO displays (display, id) VALUES ('" + display
46 +                + "', '" + lexical_cast<ext::String>(id) + "')");
47 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines