// Zoe AIM Away Message RSS Feed Generator // // Seth King and Douglas Thrift // // $Id$ #include "AwayMessage.hpp" #include "Matcher.hpp" ext::String AwayMessage::getLink(const Buddy& buddy) const { return buddy.getLink() + "#z" + stamp.getW3(); } ext::String AwayMessage::getTag(const Buddy& buddy) const { Matcher matcher("^http://([a-zA-Z.\\-0-9]+)(/.*)$"); if (buddy.getLink() == matcher) { return "tag:" + matcher[1] + "," + stamp.get8601() + ":" + matcher[2] + "/z" + stamp.getW3(); } else { cerr << Zoe::program << ": AwayMessage::getTag(" << buddy << ")\n"; exit(1); } } AwayMessage::operator ext::String() const { std::string message(this->message); std::string::size_type begin(0), found; while ((found = message.find('%', begin)) != std::string::npos) { if (message.find_first_of("ndt", found + 1) == found + 1) { switch (message[found + 1]) { case 'n': message.replace(found, 2, "Zoe"); begin = found + 3; break; case 'd': message.replace(found, 2, stamp.getDate()); begin = found + 10; break; case 't': message.replace(found, 2, stamp.getTime()); begin = found + 11; } } else begin = found + 1; } return message; }