30 |
|
|
31 |
|
int Collector::collect() |
32 |
|
{ |
33 |
< |
cerr << bright << green << "Started collector daemon.\n" << reset; |
33 |
> |
cerr << bright << green << "Started collector daemon at " << Stamp() |
34 |
> |
<< ".\n" << reset; |
35 |
|
|
36 |
|
net::Oscar::Session session; |
37 |
|
net::Oscar::AuthTool auth(session); |
53 |
|
|
54 |
|
net::Oscar::StringSet buddies; |
55 |
|
|
56 |
< |
for (std::set<Buddy>::const_iterator buddy(this->buddies.begin()); buddy != this->buddies.end(); ++buddy) |
57 |
< |
buddies.Insert(*buddy); |
56 |
> |
for (std::set<Buddy>::const_iterator buddy(this->buddies.begin()); |
57 |
> |
buddy != this->buddies.end(); ++buddy) buddies.Insert(*buddy); |
58 |
|
|
59 |
|
buddy.Insert(buddies); |
60 |
|
|
61 |
|
net::Oscar::Capabilities capabilities; |
62 |
|
|
63 |
|
capabilities.Insert(net::Oscar::ChatCapability); |
64 |
< |
info.SetProfile("<font face=\"Tahoma\" size=2>I am <a href=\"http://computers.douglasthrift.net/zoe.xml\">Zoe</a>." |
65 |
< |
"</font> :-*", "<font face=\"Tahoma\" size=2>Mommy told me not to talk to strangers.</font> O:-)", capabilities); |
64 |
> |
info.SetProfile("<font face=\"Tahoma\" size=2>I am <a href=\"" |
65 |
> |
+ Zoe::generator(Zoe::url) + "\">Zoe</a>.</font> :-*", "<font face=\"" |
66 |
> |
"Tahoma\" size=2>Mommy told me not to talk to strangers.</font> O:-)", |
67 |
> |
capabilities); |
68 |
|
|
69 |
|
// figure out whether or not we logged in |
70 |
|
|
71 |
< |
while (true) sleep(Minute(1)); |
71 |
> |
while (true) sleep(Hour(1)); |
72 |
|
} |
73 |
|
|
74 |
|
void Collector::prompt() |
80 |
|
|
81 |
|
this->password = password; |
82 |
|
|
83 |
< |
for (size_t index(std::strlen(password)); index > 0; --index) password[index - 1] = '\0'; |
83 |
> |
for (size_t index(std::strlen(password)); index > 0; --index) |
84 |
> |
password[index - 1] = '\0'; |
85 |
|
} |
86 |
|
|
87 |
|
void Collector::status(const net::Oscar::UserInfo& user) |
91 |
|
|
92 |
|
if (!ext::String(message).IsEmpty()) // XXX |
93 |
|
{ |
94 |
< |
ext::Handle<dbi::Connection> db(dbi::Connect(database.driver, database.host, database.user, database.password, |
95 |
< |
database.db)); |
96 |
< |
ext::Handle<dbi::ResultSet> previous(db->Execute("SELECT message FROM messages " |
97 |
< |
"WHERE stamp=(SELECT MAX(stamp) FROM messages WHERE id='" |
98 |
< |
+ lexical_cast<ext::String>(buddy.getId()) + "') AND id='" |
99 |
< |
+ lexical_cast<ext::String>(buddy.getId()) + "'")); |
94 |
> |
if (Zoe::debug) cerr << "buddy = " << buddy << "\nmessage = " << message |
95 |
> |
<< '\n'; |
96 |
> |
|
97 |
> |
ext::Handle<dbi::Connection> db(dbi::Connect(database.driver, |
98 |
> |
database.host, database.user, database.password, database.db)); |
99 |
> |
ext::Handle<dbi::ResultSet> previous(db->Execute("SELECT message " |
100 |
> |
"FROM messages WHERE stamp=(SELECT MAX(stamp) FROM messages " |
101 |
> |
"WHERE id='" + lexical_cast<ext::String>(buddy.getId()) |
102 |
> |
+ "') AND id='" + lexical_cast<ext::String>(buddy.getId()) + "'")); |
103 |
|
|
104 |
|
if (previous->MoveNext()) |
105 |
|
{ |
111 |
|
+ "', '" + lexical_cast<ext::String>(buddy.getId()) + "')"); |
112 |
|
|
113 |
|
cerr << bright << red << "Collected away message from " << blue << buddy |
114 |
< |
<< red << ".\n" << reset; |
114 |
> |
<< red << " at " << Stamp() << ".\n" << reset; |
115 |
|
} |
116 |
|
} |
117 |
|
|