void TMessageSystem::Subscribe(const ComponentHandle& source, const ComponentHandle& listener, const MessageID& messageId, const MessageCallback& callback) { ASSERT(static_cast<bool>(callback) != false, "Wrong callback function."); ASSERT(source != listener, "Can not subscribe component to himself."); auto& listeners = routingTable[source]; const auto it = FindListener(listeners, listener); if (it != listeners.end()) { it->second.emplace_back(messageId, callback); } else { listeners.emplace_back(listener, Subscriptions{ Subscription(messageId, callback) }); } }
AdBlockAddSubscriptionDialog::AdBlockAddSubscriptionDialog(QWidget* parent) : QDialog(parent) , ui(new Ui::AdBlockAddSubscriptionDialog) { ui->setupUi(this); m_knownSubscriptions << Subscription("EasyList (English)", ADBLOCK_EASYLIST_URL) << Subscription("Fanboy's List (English)", "http://www.fanboy.co.nz/adblock/fanboy-adblock.txt") << Subscription("Adversity (English)", "http://adversity.googlecode.com/hg/Adversity.txt") << Subscription("BSI Lista Polska (Polish)", "http://www.bsi.info.pl/filtrABP.txt") << Subscription("Czech List (Czech)", "http://adblock.dajbych.net/adblock.txt") << Subscription("dutchblock (Dutch)", "http://groenewoudt.net/dutchblock/list.txt") << Subscription("Filtros Nauscopicos (Spanish)", "http://abp.mozilla-hispano.org/nauscopio/filtros.txt") << Subscription("hufilter (Hungarian)", "http://www.hufilter.hu/hufilter.txt") << Subscription("IsraelList (Hebrew)", "http://secure.fanboy.co.nz/israelilist/IsraelList.txt") << Subscription("Lista Basa (Polish)", "http://plok.studentlive.pl/abp.txt") << Subscription("NLBlock (Dutch)", "http://www.verzijlbergh.com/adblock/nlblock.txt") << Subscription("Peter Lowe's list (English)", "http://pgl.yoyo.org/adservers/serverlist.php?hostformat=adblockplus&mimetype=plaintext") << Subscription("PLgeneral (Polish)", "http://www.niecko.pl/adblock/adblock.txt") << Subscription("Schacks Adblock Plus liste (Danish)", "http://adblock.schack.dk/block.txt") << Subscription("Xfiles (Italian)", "http://mozilla.gfsolone.com/filtri.txt") << Subscription("EasyPrivacy (English)", "http://easylist-downloads.adblockplus.org/easyprivacy.txt") << Subscription("Antisocial (English)", "http://adversity.googlecode.com/hg/Antisocial.txt") << Subscription("RU Adlist (Russian)", "https://ruadlist.googlecode.com/hg/advblock.txt") << Subscription("ABPindo (Indonesian)", "https://indonesianadblockrules.googlecode.com/hg/subscriptions/abpindo.txt") << Subscription("Easylist China (Chinese)", "https://easylist-downloads.adblockplus.org/easylistchina.txt") << Subscription(tr("Other..."), QString()); foreach (const Subscription &subscription, m_knownSubscriptions) { ui->comboBox->addItem(subscription.title); }
bool Server::Impl::StreamForPath(const util::http::Request *rq, util::http::Response *rs) { LOG(UPNP) << "Got " << rq->verb << " request for " << rq->path << "\n"; const char *path = rq->path.c_str(); const char *usn; if (rq->path == s_description_path) { LOG(UPNP) << "Serving description request\n"; rs->body_source.reset( new util::StringStream(Description(rq->local_ep.addr))); rs->content_type = "text/xml; charset=\"utf-8\""; return true; } else if (prefixcmp(path, "/upnp/event/", &usn)) { if (rq->verb == "SUBSCRIBE") { LOG(UPNP) << "I'm being subscribed at\n" << rq->headers; Service *service = FindService(usn); if (service) { std::string delivery = rq->GetHeader("callback"); if (delivery.size() > 2) { delivery.erase(0,1); delivery.erase(delivery.size()-1); m_subscriptions.push_back(Subscription(service, delivery)); rs->headers["SID"] = delivery; // why not? rs->headers["TIMEOUT"] = "infinite"; rs->body_source.reset(new util::StringStream("")); } } else { TRACE << "Can't find service " << usn << "\n"; } return true; } else if (rq->verb == "UNSUBSCRIBE") { LOG(UPNP) << "I'm being unsubscribed at\n" << rq->headers; Service *service = FindService(usn); if (service) { std::string delivery = rq->GetHeader("SID"); for (subscriptions_t::iterator i = m_subscriptions.begin(); i != m_subscriptions.end(); ++i) { if (i->service == service && i->delivery_url == delivery) { m_subscriptions.erase(i); LOG(UPNP) << "Found and erased subscription\n"; rs->body_source.reset(new util::StringStream("")); break; } } } return true; } } else if (prefixcmp(path, "/upnp/control/", &usn)) { if (rq->verb == "POST") { LOG(UPNP) << "I'm being soaped at\n" << rq->headers; Service *svc = FindService(usn); if (svc) { std::string action_name = rq->GetHeader("SOAPACTION"); if (!action_name.empty()) { action_name.erase(0,action_name.rfind('#')+1); action_name.erase(action_name.rfind('\"')); LOG(UPNP) << "Soap action: " << action_name << "\n"; const upnp::Data *data = svc->GetData(); unsigned int action = data->actions.Find(action_name.c_str()); if (action < data->actions.n) { rs->content_type = "text/xml; charset=\"utf-8\""; rs->body_sink.reset(new SoapReplier(svc, action, rs, rq->local_ep, rq->access, &m_endpoints)); return true; } else { LOG(UPNP) << "Action " << action_name << " not found\n"; } } } else { LOG(UPNP) << "Service " << usn << " not found\n"; } } } return false; }