4 |
|
// |
5 |
|
// $Id$ |
6 |
|
|
7 |
+ |
#include "AwayMessage.hpp" |
8 |
|
#include "Collector.hpp" |
9 |
+ |
#include "Stamp.hpp" |
10 |
|
|
11 |
|
#include <cstring> |
12 |
+ |
|
13 |
+ |
extern "C" |
14 |
+ |
{ |
15 |
|
#include <pwd.h> |
16 |
|
#include <unistd.h> |
17 |
+ |
} |
18 |
|
|
19 |
|
Collector::Collector(const ext::String& login, ext::String& password, const |
20 |
< |
std::set<Buddy>& buddies, bool start) : login(login), password(password), |
20 |
> |
std::set<Buddy>& buddies, const Database& database, bool start) : |
21 |
> |
login(login), password(password), buddies(buddies), database(database), |
22 |
|
start(start), prompted(false) |
23 |
|
{ |
24 |
|
if (start) |
25 |
|
{ |
26 |
|
if (password.IsEmpty()) prompt(); |
27 |
|
|
28 |
< |
collector.Spawn(etl::BindAll(&Collector::collect, this, buddies)); |
28 |
> |
collector.Spawn(etl::Bind<0>(&Collector::collect, this)); |
29 |
|
} |
30 |
|
} |
31 |
|
|
32 |
< |
int Collector::collect(const std::set<Buddy>& buddies) |
32 |
> |
int Collector::collect() |
33 |
|
{ |
34 |
|
cerr << "Collector::collect()\n"; |
35 |
|
|
47 |
|
this->buddy = &buddy; |
48 |
|
this->icbm = &icbm; |
49 |
|
|
50 |
< |
icbm.OnIncomingIcbm += etl::bind<0>(&Collector::reply, this); |
50 |
> |
// buddy.OnOnline += etl::Bind<0>(&Collector::status, this); |
51 |
> |
icbm.OnReceive += etl::Bind<0>(&Collector::reply, this); |
52 |
|
|
53 |
< |
net::Oscar::StringSet buddies_; |
53 |
> |
net::Oscar::StringSet buddies; |
54 |
|
|
55 |
< |
for (std::set<Buddy>::const_iterator buddy(buddies.begin()); buddy != |
56 |
< |
buddies.end(); ++buddy) buddies_.Insert(*buddy); |
55 |
> |
for (std::set<Buddy>::const_iterator buddy(this->buddies.begin()); buddy != |
56 |
> |
this->buddies.end(); ++buddy) buddies.Insert(*buddy); |
57 |
|
|
58 |
< |
buddy.Insert(buddies_); |
58 |
> |
buddy.Insert(buddies); |
59 |
|
icbm.RequestParams(); |
60 |
|
|
61 |
|
net::Oscar::Capabilities capabilities; |
62 |
|
|
63 |
|
capabilities.Insert(net::Oscar::ChatCapability); |
64 |
< |
info.SetProfile("<font size=3>I am <a href=\"http://computers.douglasthrift.net/zoe.xml\">Zoe</a>.</font> :-*", "", capabilities); |
64 |
> |
info.SetProfile("<font size=3>I am <a href=\"http://computers.douglasthrift.net/zoe.xml\">Zoe</a>.</font> :-*", "<font size=3>Mommy told me not to talk to strangers.</font> O:-)", capabilities); |
65 |
|
|
66 |
|
// figure out whether or not we logged in |
67 |
|
|
77 |
|
|
78 |
|
this->password = password; |
79 |
|
|
80 |
< |
for (size_t index(strlen(password)); index > 0; --index) password[index - |
81 |
< |
1] = '\0'; |
80 |
> |
for (size_t index(std::strlen(password)); index > 0; --index) |
81 |
> |
password[index - 1] = '\0'; |
82 |
|
} |
83 |
|
|
84 |
< |
void Collector::reply(const ext::String& login, const ext::String& reply) |
84 |
> |
void Collector::reply(const Buddy& buddy, const ext::String& message) |
85 |
|
{ |
86 |
< |
icbm->Simple(login, reply); |
86 |
> |
if (buddies.find(buddy) != buddies.end()) |
87 |
> |
{ |
88 |
> |
// |
89 |
> |
} |
90 |
> |
else |
91 |
> |
{ |
92 |
> |
sleep(1); |
93 |
> |
|
94 |
> |
icbm->Simple(buddy, "<font size=3>Mommy told me not to talk to strangers. O:-)"); |
95 |
> |
} |
96 |
|
} |