Esempio n. 1
0
void UPnpCMGR::HandleGetCurrentConnectionIDs ( HTTPRequest *pRequest )
{
    NameValues list;

    list.push_back(
        NameValue("ConnectionIDs", GetValue<QString>("CurrentConnectionIDs")));

    pRequest->FormatActionResponse(list);
}
Esempio n. 2
0
void UPnpMSRR::HandleRegisterDevice( HTTPRequest *pRequest )
{
    /* Sure, register, we don't really care */
    VERBOSE(VB_UPNP, QString("UPnpMSRR::HandleRegisterDevice"));
    NameValues list;

    list.push_back(NameValue("Result", "1"));

    pRequest->FormatActionResponse(list);
}
Esempio n. 3
0
void UPnpCMGR::HandleGetFeatureList(HTTPRequest* pRequest)
{
    NameValues list;

    QString sResults = m_features.toXML();

    list.push_back(NameValue("FeatureList", sResults));

    pRequest->FormatActionResponse(list);
}
Esempio n. 4
0
void UPnpCMGR::HandleGetProtocolInfo( HTTPRequest *pRequest )
{
    NameValues list;

    list.push_back(
        NameValue("Source", GetValue<QString>("SourceProtocolInfo")));
    list.push_back(
        NameValue("Sink",   GetValue<QString>("SinkProtocolInfo")));

    pRequest->FormatActionResponse(list);
}
Esempio n. 5
0
void UPnpMSRR::HandleIsAuthorized( HTTPRequest *pRequest )
{
    /* Always tell the user they are authorized to access this data */
    VERBOSE(VB_UPNP, QString("UPnpMSRR::HandleIsAuthorized"));
    NameValues list;

    list.push_back(NameValue("Result", "1"));

    list.back().AddAttribute("xmlns:dt", "urn:schemas-microsoft-com:datatypes");
    list.back().AddAttribute("dt:dt",    "int");

    pRequest->FormatActionResponse(list);
}
Esempio n. 6
0
void UPnpCDS::HandleGetSystemUpdateID( HTTPRequest *pRequest )
{
    NameValues list;

    LOG(VB_UPNP, LOG_INFO,
        QString("UPnpCDS::ProcessRequest : %1 : %2")
            .arg(pRequest->m_sBaseUrl) .arg(pRequest->m_sMethod));

    unsigned short nId = GetValue<unsigned short>("SystemUpdateID");

    list.push_back(NameValue("Id", nId));

    pRequest->FormatActionResponse(list);
}
Esempio n. 7
0
void UPnpMSRR::HandleIsValidated( HTTPRequest *pRequest )
{
    /* You are valid sir */

    VERBOSE(VB_UPNP, QString("UPnpMSRR::HandleIsValidated"));
    NameValues list;

    list.push_back(NameValue("Result", "1"));

    list.back().AddAttribute("xmlns:dt", "urn:schemas-microsoft-com:datatypes");
    list.back().AddAttribute( "dt:dt",   "int");

    pRequest->FormatActionResponse(list);
}
Esempio n. 8
0
void UPnpCDS::HandleGetSortCapabilities( HTTPRequest *pRequest )
{
    NameValues list;

    LOG(VB_UPNP, LOG_INFO,
        QString("UPnpCDS::ProcessRequest : %1 : %2")
            .arg(pRequest->m_sBaseUrl) .arg(pRequest->m_sMethod));

    // -=>TODO: Need to implement based on CDS Extension Capabilities

    list.push_back(
        NameValue("SortCaps",
                  "dc:title,dc:creator,dc:date,upnp:class,res@size"));

    pRequest->FormatActionResponse(list);
}
Esempio n. 9
0
void
XML_Backing_Store::persist (FILE* fp,
                            const Activator_Info& info,
                            const char* tag_prepend,
                            const NameValues& name_values)
{
  ACE_OS::fprintf (fp,"%s<%s", tag_prepend,
    Locator_XMLHandler::ACTIVATOR_INFO_TAG);
  ACE_OS::fprintf( fp," name=\"%s\"", info.name.c_str ());
  ACE_OS::fprintf (fp," token=\"%d\"", info.token);
  ACE_OS::fprintf (fp," ior=\"%s\"", info.ior.c_str ());

  NameValues::const_iterator name_value;
  for (name_value = name_values.begin(); name_value != name_values.end(); ++name_value)
    {
      ACE_OS::fprintf (fp," %s=\"%s\"",
                       name_value->first.c_str(), name_value->second.c_str());
    }

  ACE_OS::fprintf (fp,"/>\n");
}
Esempio n. 10
0
void SSDPExtension::GetDeviceList( HTTPRequest *pRequest )
{
    LOG(VB_UPNP, LOG_DEBUG, "SSDPExtension::GetDeviceList");

    QString     sXML;
    QTextStream os(&sXML, QIODevice::WriteOnly);

    uint nDevCount, nEntryCount;
    SSDPCache::Instance()->OutputXML(os, &nDevCount, &nEntryCount);

    NameValues list;
    list.push_back(
        NameValue("DeviceCount",           (int)nDevCount));
    list.push_back(
        NameValue("DevicesAllocated",      SSDPCacheEntries::g_nAllocated));
    list.push_back(
        NameValue("CacheEntriesFound",     (int)nEntryCount));
    list.push_back(
        NameValue("CacheEntriesAllocated", DeviceLocation::g_nAllocated));
    list.push_back(
        NameValue("DeviceList",            sXML));

    pRequest->FormatActionResponse(list);

    pRequest->m_eResponseType   = ResponseTypeXML;
    pRequest->m_nResponseStatus = 200;
}
Esempio n. 11
0
void UPnpCMGR::HandleGetCurrentConnectionInfo( HTTPRequest *pRequest )
{
    unsigned short nId = pRequest->m_mapParams[ "ConnectionID" ].toUShort();

    if ( nId != 0)
    {
        UPnp::FormatErrorResponse( pRequest, UPnPResult_CMGR_InvalidConnectionRef );
        return;
    }

    NameValues list;

    list.push_back(NameValue( "RcsID"                , "-1"             ));
    list.push_back(NameValue( "AVTransportID"        , "-1"             ));
    list.push_back(NameValue( "ProtocolInfo"         , "http-get:*:*:*" ));
    list.push_back(NameValue( "PeerConnectionManager", "/"              ));
    list.push_back(NameValue( "PeerConnectionID"     , "-1"             ));
    list.push_back(NameValue( "Direction"            , "Output"         ));
    list.push_back(NameValue( "Status"               , "Unknown"        ));
    
    pRequest->FormatActionResponse(list);
}
Esempio n. 12
0
void UPnpCDS::HandleSearch( HTTPRequest *pRequest )
{
    UPnpCDSExtensionResults *pResult  = NULL;
    UPnpCDSRequest           request;

    UPnPResultCode eErrorCode      = UPnPResult_InvalidAction;
    QString       sErrorDesc      = "";
    short         nNumberReturned = 0;
    short         nTotalMatches   = 0;
    short         nUpdateID       = 0;
    QString       sResultXML;

    DetermineClient( pRequest, &request );
    request.m_sObjectId         = pRequest->m_mapParams[ "ObjectID"      ];
    request.m_sContainerID      = pRequest->m_mapParams[ "ContainerID"   ];
    request.m_sFilter           = pRequest->m_mapParams[ "Filter"        ];
    request.m_nStartingIndex    =
        pRequest->m_mapParams[ "StartingIndex" ].toLong();
    request.m_nRequestedCount   =
        pRequest->m_mapParams[ "RequestedCount"].toLong();
    request.m_sSortCriteria     = pRequest->m_mapParams[ "SortCriteria"  ];
    request.m_sSearchCriteria   = pRequest->m_mapParams[ "SearchCriteria"];

    LOG(VB_UPNP, LOG_INFO,
        QString("UPnpCDS::HandleSearch ObjectID=%1, ContainerId=%2")
            .arg(request.m_sObjectId) .arg(request.m_sContainerID));

    // ----------------------------------------------------------------------
    // Break the SearchCriteria into it's parts
    // -=>TODO: This DOES NOT handle ('s or other complex expressions
    // ----------------------------------------------------------------------

    QRegExp  rMatch( "\\b(or|and)\\b" );
    rMatch.setCaseSensitivity(Qt::CaseInsensitive);

    request.m_sSearchList  = request.m_sSearchCriteria.split(
        rMatch, QString::SkipEmptyParts);
    request.m_sSearchClass = "object";  // Default to all objects.

    // ----------------------------------------------------------------------
    // -=>TODO: Need to process all expressions in searchCriteria... for now,
    //          Just focus on the "upnp:class derivedfrom" expression
    // ----------------------------------------------------------------------

    for ( QStringList::Iterator it  = request.m_sSearchList.begin();
                                it != request.m_sSearchList.end();
                              ++it )
    {
        if ((*it).contains("upnp:class derivedfrom", Qt::CaseInsensitive))
        {
            QStringList sParts = (*it).split(' ', QString::SkipEmptyParts);

            if (sParts.count() > 2)
            {
                request.m_sSearchClass = sParts[2].trimmed();
                request.m_sSearchClass.remove( '"' );

                break;
            }
        }
    }

    // ----------------------------------------------------------------------


    LOG(VB_UPNP, LOG_INFO, QString("UPnpCDS::ProcessRequest \n"
                                    ": url            = %1 \n"
                                    ": Method         = %2 \n"
                                    ": ObjectId       = %3 \n"
                                    ": SearchCriteria = %4 \n"
                                    ": Filter         = %5 \n"
                                    ": StartingIndex  = %6 \n"
                                    ": RequestedCount = %7 \n"
                                    ": SortCriteria   = %8 \n"
                                    ": SearchClass    = %9" )
                       .arg( pRequest->m_sBaseUrl     )
                       .arg( pRequest->m_sMethod      )
                       .arg( request.m_sObjectId      )
                       .arg( request.m_sSearchCriteria)
                       .arg( request.m_sFilter        )
                       .arg( request.m_nStartingIndex )
                       .arg( request.m_nRequestedCount)
                       .arg( request.m_sSortCriteria  )
                       .arg( request.m_sSearchClass   ));

#if 0
    bool bSearchDone = false;
#endif

    UPnpCDSExtensionList::iterator it = m_extensions.begin();
    for (; (it != m_extensions.end()) && !pResult; ++it)
        pResult = (*it)->Search(&request);

    if (pResult != NULL)
    {
        eErrorCode  = pResult->m_eErrorCode;
        sErrorDesc  = pResult->m_sErrorDesc;

        if (eErrorCode == UPnPResult_Success)
        {
            FilterMap filter =  (FilterMap) request.m_sFilter.split(',');
            nNumberReturned = pResult->m_List.count();
            nTotalMatches   = pResult->m_nTotalMatches;
            nUpdateID       = pResult->m_nUpdateID;
            sResultXML      = pResult->GetResultXML(filter);
#if 0
            bSearchDone = true;
#endif
        }

        delete pResult;
    }

#if 0
    nUpdateID       = 0;
    LOG(VB_UPNP, LOG_DEBUG, sResultXML);
#endif

    if (eErrorCode == UPnPResult_Success)
    {
        NameValues list;
        QString sResults = DIDL_LITE_BEGIN;
        sResults += sResultXML;
        sResults += DIDL_LITE_END;

        list.push_back(NameValue("Result",         sResults));
        list.push_back(NameValue("NumberReturned", nNumberReturned));
        list.push_back(NameValue("TotalMatches",   nTotalMatches));
        list.push_back(NameValue("UpdateID",       nUpdateID));

        pRequest->FormatActionResponse(list);
    }
    else
        UPnp::FormatErrorResponse( pRequest, eErrorCode, sErrorDesc );
}
Esempio n. 13
0
void UPnpCDS::HandleBrowse( HTTPRequest *pRequest )
{
    UPnpCDSExtensionResults *pResult  = NULL;
    UPnpCDSRequest           request;

    DetermineClient( pRequest, &request );
    request.m_sObjectId         = pRequest->m_mapParams[ "ObjectID"      ];
    request.m_sContainerID      = pRequest->m_mapParams[ "ContainerID"   ];
    request.m_sParentId         = "0";
    request.m_eBrowseFlag       =
        GetBrowseFlag( pRequest->m_mapParams[ "BrowseFlag"    ] );
    request.m_sFilter           = pRequest->m_mapParams[ "Filter"        ];
    request.m_nStartingIndex    =
        pRequest->m_mapParams[ "StartingIndex" ].toLong();
    request.m_nRequestedCount   =
        pRequest->m_mapParams[ "RequestedCount"].toLong();
    request.m_sSortCriteria     = pRequest->m_mapParams[ "SortCriteria"  ];

#if 0
    LOG(VB_UPNP, LOG_DEBUG, QString("UPnpCDS::ProcessRequest \n"
                                    ": url            = %1 \n"
                                    ": Method         = %2 \n"
                                    ": ObjectId       = %3 \n"
                                    ": BrowseFlag     = %4 \n"
                                    ": Filter         = %5 \n"
                                    ": StartingIndex  = %6 \n"
                                    ": RequestedCount = %7 \n"
                                    ": SortCriteria   = %8 " )
                       .arg( pRequest->m_sBaseUrl     )
                       .arg( pRequest->m_sMethod      )
                       .arg( request.m_sObjectId      )
                       .arg( request.m_eBrowseFlag    )
                       .arg( request.m_sFilter        )
                       .arg( request.m_nStartingIndex )
                       .arg( request.m_nRequestedCount)
                       .arg( request.m_sSortCriteria  ));
#endif

    UPnPResultCode eErrorCode      = UPnPResult_CDS_NoSuchObject;
    QString        sErrorDesc      = "";
    short          nNumberReturned = 0;
    short          nTotalMatches   = 0;
    short          nUpdateID       = 0;
    QString        sResultXML;
    FilterMap filter =  (FilterMap) request.m_sFilter.split(',');

    LOG(VB_UPNP, LOG_INFO,
        QString("UPnpCDS::HandleBrowse ObjectID=%1, ContainerId=%2")
            .arg(request.m_sObjectId) .arg(request.m_sContainerID));

    if (request.m_sObjectId == "0")
    {
        // ------------------------------------------------------------------
        // This is for the root object... lets handle it.
        // ------------------------------------------------------------------

        switch( request.m_eBrowseFlag )
        {
            case CDS_BrowseMetadata:
            {
                // -----------------------------------------------------------
                // Return Root Object Only
                // -----------------------------------------------------------

                eErrorCode      = UPnPResult_Success;
                nNumberReturned = 1;
                nTotalMatches   = 1;
                nUpdateID       = m_root.m_nUpdateId;

                m_root.SetChildCount( m_extensions.count() );

                sResultXML      = m_root.toXml(filter);

                break;
            }

            case CDS_BrowseDirectChildren:
            {
                // Loop Through each extension and Build the Root Folders

                // -=>TODO: Need to handle StartingIndex & RequestedCount

                eErrorCode      = UPnPResult_Success;
                nTotalMatches   = m_extensions.count();
                nUpdateID       = m_root.m_nUpdateId;

                if (request.m_nRequestedCount == 0)
                    request.m_nRequestedCount = nTotalMatches;

                short nStart = Max( request.m_nStartingIndex, short( 0 ));
                short nCount = Min( nTotalMatches, request.m_nRequestedCount );

                UPnpCDSRequest       childRequest;

                DetermineClient( pRequest, &request );
                childRequest.m_sParentId         = "0";
                childRequest.m_eBrowseFlag       = CDS_BrowseMetadata;
                childRequest.m_sFilter           = "";
                childRequest.m_nStartingIndex    = 0;
                childRequest.m_nRequestedCount   = 1;
                childRequest.m_sSortCriteria     = "";

                for (uint i = nStart;
                     (i < (uint)m_extensions.size()) &&
                         (nNumberReturned < nCount);
                     i++)
                {
                    UPnpCDSExtension *pExtension = m_extensions[i];
                    childRequest.m_sObjectId = pExtension->m_sExtensionId;

                    pResult = pExtension->Browse( &childRequest );

                    if (pResult != NULL)
                    {
                        if (pResult->m_eErrorCode == UPnPResult_Success)
                        {
                            sResultXML  += pResult->GetResultXML(filter);
                            nNumberReturned ++;
                        }

                        delete pResult;
                    }
                }

                break;
            }
            default: break;
        }
    }
    else
    {
        // ------------------------------------------------------------------
        // Look for a CDS Extension that knows how to handle this ObjectID
        // ------------------------------------------------------------------

        UPnpCDSExtensionList::iterator it = m_extensions.begin();
        for (; (it != m_extensions.end()) && !pResult; ++it)
        {
            LOG(VB_UPNP, LOG_INFO,
                QString("UPNP Browse : Searching for : %1  / ObjectID : %2")
                    .arg((*it)->m_sExtensionId).arg(request.m_sObjectId));

            pResult = (*it)->Browse(&request);
        }

        if (pResult != NULL)
        {
            eErrorCode  = pResult->m_eErrorCode;
            sErrorDesc  = pResult->m_sErrorDesc;

            if (eErrorCode == UPnPResult_Success)
            {
                nNumberReturned = pResult->m_List.count();
                nTotalMatches   = pResult->m_nTotalMatches;
                nUpdateID       = pResult->m_nUpdateID;
                sResultXML      = pResult->GetResultXML(filter);
            }

            delete pResult;
        }
    }

    // ----------------------------------------------------------------------
    // Output Results of Browse Method
    // ----------------------------------------------------------------------

    if (eErrorCode == UPnPResult_Success)
    {
        NameValues list;

        QString sResults = DIDL_LITE_BEGIN;
        sResults += sResultXML;
        sResults += DIDL_LITE_END;

        list.push_back(NameValue("Result",         sResults));
        list.push_back(NameValue("NumberReturned", nNumberReturned));
        list.push_back(NameValue("TotalMatches",   nTotalMatches));
        list.push_back(NameValue("UpdateID",       nUpdateID));

        pRequest->FormatActionResponse(list);
    }
    else
        UPnp::FormatErrorResponse ( pRequest, eErrorCode, sErrorDesc );

}
Esempio n. 14
0
void SSDPExtension::GetDeviceList( HTTPRequest *pRequest )
{
    SSDPCache*    pCache  = SSDPCache::Instance();
    int           nCount = 0;
    NameValues    list;

    VERBOSE( VB_UPNP, "SSDPExtension::GetDeviceList" );

    pCache->Lock();

    QString     sXML = "";
    QTextStream os( &sXML, QIODevice::WriteOnly );

    for (SSDPCacheEntriesMap::Iterator it  = pCache->Begin();
                                       it != pCache->End();
                                     ++it )
    {
        SSDPCacheEntries *pEntries = *it;

        if (pEntries != NULL)
        {
            os << "<Device uri='" << it.key() << "'>" << endl;

            pEntries->Lock();

            EntryMap *pMap = pEntries->GetEntryMap();

            for (EntryMap::Iterator itEntry  = pMap->begin();
                                    itEntry != pMap->end();
                                  ++itEntry )
            {

                DeviceLocation *pEntry = *itEntry;

                if (pEntry != NULL)
                {
                    nCount++;

                    pEntry->AddRef();

                    os << "<Service usn='" << pEntry->m_sUSN 
                       << "' expiresInSecs='" << pEntry->ExpiresInSecs()
                       << "' url='" << pEntry->m_sLocation << "' />" << endl;

                    pEntry->Release();
                }
            }

            os << "</Device>" << endl;

            pEntries->Unlock();
        }
    }
    os << flush;

    list.push_back( NameValue("DeviceCount"          , pCache->Count()               ));
    list.push_back( NameValue("DevicesAllocated"     , SSDPCacheEntries::g_nAllocated));
    list.push_back( NameValue("CacheEntriesFound"    , nCount                        ));
    list.push_back( NameValue("CacheEntriesAllocated", DeviceLocation::g_nAllocated  ));
    list.push_back( NameValue("DeviceList"           , sXML                          ));

    pCache->Unlock();

    pRequest->FormatActionResponse( list );

    pRequest->m_eResponseType   = ResponseTypeXML;
    pRequest->m_nResponseStatus = 200;
}
Esempio n. 15
0
void
XML_Backing_Store::persist (FILE* fp,
                            const Server_Info& info,
                            const char* tag_prepend,
                            const NameValues& name_values)
{
  ACE_CString server_id = ACEXML_escape_string (info.server_id);
  ACE_CString pname = ACEXML_escape_string (info.poa_name);
  ACE_CString keyname = ACEXML_escape_string (info.key_name_);
  ACE_CString altkey = "";
  if (!info.alt_info_.null())
    {
      altkey = ACEXML_escape_string (info.alt_info_->key_name_);
    }

  ACE_CString activator = ACEXML_escape_string (info.activator);
  ACE_CString cmdline = ACEXML_escape_string (info.cmdline);
  ACE_CString wdir = ACEXML_escape_string (info.dir);
  ACE_CString partial_ior = ACEXML_escape_string (info.partial_ior);
  ACE_CString ior = ACEXML_escape_string (info.ior);
  ACE_CString amodestr =
    ImR_Utils::activationModeToString (info.activation_mode_);

  ACE_OS::fprintf (fp,"%s<%s", tag_prepend,
    Locator_XMLHandler::SERVER_INFO_TAG);
  ACE_OS::fprintf (fp, " %s=\"%s\"", Locator_XMLHandler::SERVER_TAG, server_id.c_str ());
  ACE_OS::fprintf (fp, " %s=\"%s\"", Locator_XMLHandler::POANAME_TAG, pname.c_str ());
  ACE_OS::fprintf (fp, " %s=\"%s\"", Locator_XMLHandler::ACTNAME_TAG, activator.c_str ());
  ACE_OS::fprintf (fp, " %s=\"%s\"", Locator_XMLHandler::CMDLINE_TAG, cmdline.c_str ());
  ACE_OS::fprintf (fp, " %s=\"%s\"", Locator_XMLHandler::DIR_TAG, wdir.c_str ());
  ACE_OS::fprintf (fp, " %s=\"%s\"", Locator_XMLHandler::MODE_TAG, amodestr.c_str ());
  ACE_OS::fprintf (fp, " %s=\"%d\"", Locator_XMLHandler::LIMIT_TAG, info.start_limit_);
  ACE_OS::fprintf (fp, " %s=\"%s\"", Locator_XMLHandler::PARTIOR_TAG, partial_ior.c_str ());
  ACE_OS::fprintf (fp, " %s=\"%s\"", Locator_XMLHandler::IOR_TAG, ior.c_str ());
  ACE_OS::fprintf (fp, " %s=\"%d\"", Locator_XMLHandler::STARTED_TAG, !CORBA::is_nil(info.server.in()));
  ACE_OS::fprintf (fp, " %s=\"%d\"", Locator_XMLHandler::JACORB_TAG, info.is_jacorb);
  ACE_OS::fprintf (fp, " %s=\"%d\"", Locator_XMLHandler::PID_TAG, info.pid);
  ACE_OS::fprintf (fp, " %s= \"%s\"", Locator_XMLHandler::KEYNAME_TAG, keyname.c_str ());
  ACE_OS::fprintf (fp, " %s= \"%s\"", Locator_XMLHandler::ALTKEY_TAG, altkey.c_str ());

  NameValues::const_iterator name_value;
  for (name_value = name_values.begin(); name_value != name_values.end(); ++name_value)
    {
      ACE_OS::fprintf (fp," %s=\"%s\"",
                       name_value->first.c_str(), name_value->second.c_str());
    }

  CORBA::ULong elen = info.env_vars.length ();
  CORBA::ULong plen = info.peers.length ();

  if (elen + plen > 0)
    {
      ACE_OS::fprintf (fp,">\n");
      for (CORBA::ULong i = 0; i < elen; ++i)
        {
          ACE_OS::fprintf (fp,"%s\t<%s", tag_prepend,
            Locator_XMLHandler::ENVIRONMENT_TAG);
          ACE_OS::fprintf (fp," name=\"%s\"", info.env_vars[i].name.in ());
          ACE_CString val = ACEXML_escape_string(info.env_vars[i].value.in());
          ACE_OS::fprintf (fp," value=\"%s\"", val.c_str());
          ACE_OS::fprintf (fp,"/>\n");
        }
      for (CORBA::ULong i = 0; i < plen; ++i)
        {
          ACE_OS::fprintf (fp,"%s\t<%s", tag_prepend,
            Locator_XMLHandler::PEER_TAG);
          ACE_CString name = ACEXML_escape_string(info.peers[i].in());
          ACE_OS::fprintf (fp," name=\"%s\"", name.c_str());
          ACE_OS::fprintf (fp,"/>\n");
        }

      ACE_OS::fprintf (fp,"%s</%s>\n", tag_prepend, Locator_XMLHandler::SERVER_INFO_TAG);
    }
  else
    {
      ACE_OS::fprintf (fp,"/>\n");
    }
}