ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/zoe/trunk/Collector.cpp
Revision: 17
Committed: 2004-07-14T23:27:27-07:00 (20 years, 11 months ago) by douglas
File size: 1870 byte(s)
Log Message:
No need to be so static.

File Contents

# User Rev Content
1 douglas 13 // Zoe AIM Away Message RSS Feed Generator
2     //
3     // Seth King and Douglas Thrift
4     //
5     // $Id$
6    
7     #include "Collector.hpp"
8    
9 douglas 16 #include <cstring>
10 douglas 15 #include <pwd.h>
11     #include <unistd.h>
12    
13     Collector::Collector(const ext::String& login, ext::String& password, const
14     std::set<Buddy>& buddies, bool start) : login(login), password(password),
15     start(start)
16 douglas 13 {
17 douglas 15 if (start)
18     {
19     if (password.IsEmpty()) prompt();
20    
21     collector.Spawn(etl::BindAll(&Collector::collect, this, buddies));
22     }
23 douglas 13 }
24 douglas 15
25     int Collector::collect(const std::set<Buddy>& buddies)
26     {
27     cerr << "Collector::collect()\n";
28    
29     net::Oscar::Session session;
30     net::Oscar::AuthTool auth(session);
31     net::Oscar::BuddyTool buddy(session);
32     net::Oscar::ChatTool chat(session);
33     net::Oscar::IcbmTool icbm(session);
34     net::Oscar::InfoTool info(session);
35    
36     auth.Login(login, password);
37    
38 douglas 17 this->buddy = &buddy;
39     this->icbm = &icbm;
40 douglas 16
41 douglas 17 icbm.OnIncomingIcbm += etl::bind<0>(&Collector::reply, this);
42 douglas 16
43     // for (size_t index(password.GetSize()); index > 0; --index) password[index -
44     // 1] = '\0';
45    
46 douglas 15 net::Oscar::StringSet buddies_;
47    
48     for (std::set<Buddy>::const_iterator buddy(buddies.begin()); buddy !=
49     buddies.end(); ++buddy) buddies_.Insert(*buddy);
50    
51     buddy.Insert(buddies_);
52     icbm.RequestParams();
53    
54     net::Oscar::Capabilities capabilities;
55    
56     capabilities.Insert(net::Oscar::ChatCapability);
57     info.SetProfile("<font size=3>I am <a href=\"http://computers.douglasthrift.net/zoe.xml\">Zoe</a>.</font> :-*", "", capabilities);
58    
59     // figure out whether or not we logged in
60    
61 douglas 16 while (true) sleep(60);
62 douglas 15 }
63    
64     void Collector::prompt()
65     {
66 douglas 16 ext::String prompt(login + "'s AIM Password: ");
67     char* password(getpass(prompt.NullTerminate()));
68 douglas 15
69     this->password = password;
70    
71 douglas 16 for (size_t index(strlen(password)); index > 0; --index) password[index -
72     1] = '\0';
73 douglas 15 }
74 douglas 16
75     void Collector::reply(const ext::String& login, const ext::String& reply)
76     {
77     icbm->Simple(login, reply);
78     }

Properties

Name Value
svn:eol-style native
svn:keywords Id