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 21 by douglas, 2004-07-16T23:37:41-07:00 vs.
Revision 63 by douglas, 2004-09-17T16:35:17-07:00

# Line 6 | Line 6
6  
7   #include "Zoe.hpp"
8  
9 < std::ostream& operator<<(std::ostream& sout, const Buddy& buddy)
9 > ext::String Buddy::getRssLink() const
10   {
11 <        sout << buddy.login << '(' << buddy.rss << ')';
11 >        ext::String link(this->link);
12 >        
13 >        return ext::String(link.Begin(), link.FindLast('/')) + "/" + rss;
14 > }
15 >
16 > ext::String Buddy::getAtomLink() const
17 > {
18 >        ext::String link(this->link);
19 >
20 >        return ext::String(link.Begin(), link.FindLast('/')) + "/" + 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 <        return sout;
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