// Zoe AIM Away Message RSS Feed Generator // // Seth King and Douglas Thrift // // $Id$ #include "Collector.hpp" #include #include #include Collector::Collector(const ext::String& login, ext::String& password, const std::set& buddies, bool start) : login(login), password(password), buddies(buddies), start(start), prompted(false) { if (start) { if (password.IsEmpty()) prompt(); collector.Spawn(etl::Bind<0>(&Collector::collect, this)); } } int Collector::collect() { cerr << "Collector::collect()\n"; net::Oscar::Session session; net::Oscar::AuthTool auth(session); net::Oscar::BuddyTool buddy(session); net::Oscar::ChatTool chat(session); net::Oscar::IcbmTool icbm(session); net::Oscar::InfoTool info(session); auth.Login(login, password); if (prompted) password.Clear(); this->buddy = &buddy; this->icbm = &icbm; // buddy.OnOnline += etl::Bind<0>(&Collector::status, this); icbm.OnReceive += etl::Bind<0>(&Collector::reply, this); net::Oscar::StringSet buddies; for (std::set::const_iterator buddy(this->buddies.begin()); buddy != this->buddies.end(); ++buddy) buddies.Insert(*buddy); buddy.Insert(buddies); icbm.RequestParams(); net::Oscar::Capabilities capabilities; capabilities.Insert(net::Oscar::ChatCapability); info.SetProfile("I am Zoe. :-*", "Mommy told me not to talk to strangers. O:-)", capabilities); // figure out whether or not we logged in while (true) sleep(60); } void Collector::prompt() { if (!prompted) prompted = true; ext::String prompt(login + "'s AIM Password: "); char* password(getpass(prompt.NullTerminate())); this->password = password; for (size_t index(strlen(password)); index > 0; --index) password[index - 1] = '\0'; } void Collector::reply(const Buddy& buddy, const ext::String& message) { if (buddies.find(buddy) != buddies.end()) { // } else { sleep(1); icbm->Simple(buddy, "Mommy told me not to talk to strangers. O:-)"); } }