/*MT* MediaTomb - http://www.mediatomb.cc/ upnp_cm_subscriptions.cc - this file is part of MediaTomb. Copyright (C) 2005 Gena Batyan , Sergey 'Jin' Bostandzhyan Copyright (C) 2006-2007 Gena Batyan , Sergey 'Jin' Bostandzhyan , Leonhard Wimmer MediaTomb is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. MediaTomb is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License version 2 along with MediaTomb; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. $Id: upnp_cm_subscriptions.cc 1124 2007-02-17 21:49:15Z lww $ */ /// \file upnp_cm_subscriptions.cc #ifdef HAVE_CONFIG_H #include "autoconfig.h" #endif #include "tools.h" #include "upnp_cm.h" #include "server.h" #include "upnp_xml.h" #include "ixml.h" #include "storage.h" using namespace zmm; using namespace mxml; void ConnectionManagerService::process_subscription_request(zmm::Ref request) { int err; IXML_Document *event = NULL; Ref propset, property; Ref > mimeTypes = Storage::getInstance()->getMimeTypes(); String CSV = mime_types_to_CSV(mimeTypes); propset = UpnpXML_CreateEventPropertySet(); property = propset->getFirstChild(); property->appendTextChild(_("CurrentConnectionIDs"), _("0")); property->appendTextChild(_("SinkProtocolInfo"), _("")); property->appendTextChild(_("SourceProtocolInfo"), CSV); String xml = propset->print(); err = ixmlParseBufferEx(xml.c_str(), &event); if (err != IXML_SUCCESS) { throw UpnpException(UPNP_E_SUBSCRIPTION_FAILED, _("Could not convert property set to ixml")); } UpnpAcceptSubscriptionExt(Server::getInstance()->getDeviceHandle(), ConfigManager::getInstance()->getOption(_("/server/udn")).c_str(), serviceID.c_str(), event, request->getSubscriptionID().c_str()); ixmlDocument_free(event); } void ConnectionManagerService::subscription_update(String sourceProtocol_CSV) { int err; IXML_Document *event = NULL; Ref propset, property; propset = UpnpXML_CreateEventPropertySet(); property = propset->getFirstChild(); property->appendTextChild(_("SourceProtocolInfo"), sourceProtocol_CSV); String xml = propset->print(); err = ixmlParseBufferEx(xml.c_str(), &event); if (err != IXML_SUCCESS) { /// \todo add another error code throw UpnpException(UPNP_E_SUBSCRIPTION_FAILED, _("Could not convert property set to ixml")); } UpnpNotifyExt(Server::getInstance()->getDeviceHandle(), ConfigManager::getInstance()->getOption(_("/server/udn")).c_str(), serviceID.c_str(), event); ixmlDocument_free(event); }