00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00031
00032 #ifdef HAVE_CONFIG_H
00033 #include "autoconfig.h"
00034 #endif
00035
00036 #include "upnp_cds.h"
00037 #include "upnp_xml.h"
00038 #include "ixml.h"
00039 #include "server.h"
00040 #include "storage.h"
00041
00042 using namespace zmm;
00043 using namespace mxml;
00044
00045 void ContentDirectoryService::process_subscription_request(zmm::Ref<SubscriptionRequest> request)
00046 {
00047 int err;
00048 IXML_Document *event = NULL;
00049
00050 Ref<Element> propset, property;
00051
00052 log_debug("start\n");
00053
00054 propset = UpnpXML_CreateEventPropertySet();
00055 property = propset->getFirstElementChild();
00056 property->appendTextChild(_("SystemUpdateID"), _("") + systemUpdateID);
00057 Ref<CdsObject> obj = Storage::getInstance()->loadObject(0);
00058 Ref<CdsContainer> cont = RefCast(obj, CdsContainer);
00059 property->appendTextChild(_("ContainerUpdateIDs"), _("0,") + cont->getUpdateID());
00060 String xml = propset->print();
00061 err = ixmlParseBufferEx(xml.c_str(), &event);
00062 if (err != IXML_SUCCESS)
00063 {
00064 throw UpnpException(UPNP_E_SUBSCRIPTION_FAILED, _("Could not convert property set to ixml"));
00065 }
00066
00067 UpnpAcceptSubscriptionExt(Server::getInstance()->getDeviceHandle(),
00068 ConfigManager::getInstance()->getOption(CFG_SERVER_UDN).c_str(),
00069 serviceID.c_str(), event, request->getSubscriptionID().c_str());
00070
00071 ixmlDocument_free(event);
00072 log_debug("end\n");
00073 }
00074
00075 void ContentDirectoryService::subscription_update(String containerUpdateIDs_CSV)
00076 {
00077 int err;
00078 IXML_Document *event = NULL;
00079
00080 Ref<Element> propset, property;
00081
00082 log_debug("start\n");
00083
00084 systemUpdateID++;
00085
00086 propset = UpnpXML_CreateEventPropertySet();
00087 property = propset->getFirstElementChild();
00088 property->appendTextChild(_("ContainerUpdateIDs"), containerUpdateIDs_CSV);
00089 property->appendTextChild(_("SystemUpdateID"), _("") + systemUpdateID);
00090
00091 String xml = propset->print();
00092
00093 err = ixmlParseBufferEx(xml.c_str(), &event);
00094 if (err != IXML_SUCCESS)
00095 {
00097 throw UpnpException(UPNP_E_SUBSCRIPTION_FAILED, _("Could not convert property set to ixml"));
00098 }
00099
00100 UpnpNotifyExt(Server::getInstance()->getDeviceHandle(),
00101 ConfigManager::getInstance()->getOption(CFG_SERVER_UDN).c_str(),
00102 serviceID.c_str(), event);
00103
00104 ixmlDocument_free(event);
00105
00106 log_debug("end\n");
00107 }