void VimeoTransfer::listStreams() { if (!m_streamsRequest) { m_streamsRequest = new QVimeo::StreamsRequest(this); connect(m_streamsRequest, SIGNAL(finished()), this, SLOT(onStreamsRequestFinished())); } m_streamsRequest->list(resourceId()); }
void PluginTransfer::listSubtitles() { if (!m_subtitlesRequest) { m_subtitlesRequest = new ResourcesRequest(this); connect(m_subtitlesRequest, SIGNAL(finished()), this, SLOT(onSubtitlesRequestFinished())); } m_subtitlesRequest->setService(service()); m_subtitlesRequest->list(Resources::SUBTITLE, resourceId()); }
void PluginTransfer::listStreams() { if (!m_streamsRequest) { m_streamsRequest = new ResourcesRequest(this); connect(m_streamsRequest, SIGNAL(finished()), this, SLOT(onStreamsRequestFinished())); } m_streamsRequest->setService(service()); m_streamsRequest->list(Resources::STREAM, resourceId()); }
void VimeoTransfer::listSubtitles() { if (!m_subtitlesRequest) { m_subtitlesRequest = new QVimeo::ResourcesRequest(this); m_subtitlesRequest->setClientId(Vimeo::instance()->clientId()); m_subtitlesRequest->setClientSecret(Vimeo::instance()->clientSecret()); m_subtitlesRequest->setAccessToken(Vimeo::instance()->accessToken()); connect(m_subtitlesRequest, SIGNAL(finished()), this, SLOT(onSubtitlesRequestFinished())); } m_subtitlesRequest->list(QString("/videos/%1/texttracks").arg(resourceId())); }
SharedResourcePtr GraphicsResourceManager::getResourceAsset(const URI &id, GraphicsResource::Type resourceType) { WeakResourcePtr curWeakPtr; SharedResourcePtr curSharedPtr; if (ResourceManager::getSingleton().isMHashScheme(id)) { try { curWeakPtr = getResource(RemoteFileId(id).fingerprint().convertToHexString()); curSharedPtr = curWeakPtr.lock(); } catch (std::invalid_argument &ia) { } } if (!curSharedPtr) { curWeakPtr = getResource(id.toString()); curSharedPtr = curWeakPtr.lock(); } if (curSharedPtr) return curSharedPtr; else { try { if (ResourceManager::getSingleton().isMHashScheme(id)) { // std::invalid_argument may be thrown, but is caught by the "catch" below. RemoteFileId resourceId(id); if (resourceType == GraphicsResource::MESH) { curSharedPtr = GraphicsResource::construct<GraphicsResourceMesh>(resourceId); } else if (resourceType == GraphicsResource::MATERIAL) { curSharedPtr = GraphicsResource::construct<GraphicsResourceMaterial>(resourceId); } else if (resourceType == GraphicsResource::TEXTURE) { curSharedPtr = GraphicsResource::construct<GraphicsResourceTexture>(resourceId); } else if (resourceType == GraphicsResource::SHADER) { curSharedPtr = GraphicsResource::construct<GraphicsResourceShader>(resourceId); } else { assert(false); } } else { curSharedPtr = GraphicsResource::construct<GraphicsResourceName>(id, resourceType); } mIDResourceMap[curSharedPtr->getID()] = curSharedPtr; mResources.insert(curSharedPtr.get()); } catch (std::invalid_argument& exc) { } return curSharedPtr; } }
// -------------------------------------------------------------------------- // CMSBrowseView::SetTitlePaneTextL() // -------------------------------------------------------------------------- // void CMSBrowseView::SetTitlePaneTextL( TCmMediaType aMediaType ) { LOG(_L("[MediaServant]\t CMSBrowseView::SetTitlePaneTextL")); TInt resourceId(0); switch ( aMediaType ) { case ECmImage: { resourceId = R_MS_STORE_TITLE_PHONE_IMAGES; break; } case ECmOtherImage: { resourceId = R_MS_STORE_TITLE_IMAGES; break; } case ECmVideo: { resourceId = R_MS_STORE_TITLE_PHONE_VIDEOS; break; } case ECmOtherVideo: { resourceId = R_MS_STORE_TITLE_VIDEOS; break; } case ECmAudio: { resourceId = R_MS_STORE_TITLE_MUSIC; break; } default: { LOG(_L("[MediaServant]\t CMSBrowseView::SetTitlePaneTextL \ mediatype not found")); break; } } if ( resourceId ) { HBufC* titleText = StringLoader::LoadLC( resourceId ); CMSBaseView::SetTitlePaneTextL( *titleText ); CleanupStack::PopAndDestroy( titleText ); } }
void subscribeMwiClientTest() { smClientExpiration = -1; smNumClientNotifiesReceived = 0; smLastClientNotifyReceived = NULL; smNumClientSubResponsesReceived = 0; smLastClientSubResponseReceived = NULL; UtlString resourceId("[email protected]:"); UtlString eventTypeKey("message-summary"); UtlString eventType(eventTypeKey); UtlString from("Frida<sip:111@localhost:"); UtlString to("Tia<sip:222@localhost:"); UtlString contact("sip:[email protected]:"); char portString[20]; sprintf(portString, "%d", UNIT_TEST_SIP_PORT); resourceId.append(portString); from.append(portString); from.append('>'); to.append(portString); to.append('>'); contact.append(portString); SipUserAgent* userAgent = new SipUserAgent(UNIT_TEST_SIP_PORT, UNIT_TEST_SIP_PORT); userAgent->start(); // Set up the subscribe client SipDialogMgr* clientDialogMgr = new SipDialogMgr(); SipRefreshManager* refreshMgr = new SipRefreshManager(*userAgent, *clientDialogMgr); refreshMgr->start(); SipSubscribeClient* subClient = new SipSubscribeClient(*userAgent, *clientDialogMgr, *refreshMgr); subClient->start(); // Set up the subscribe server SipSubscribeServer* subServer = SipSubscribeServer::buildBasicServer(*userAgent, eventType); SipSubscriptionMgr* subMgr = subServer->getSubscriptionMgr(eventType); SipDialogMgr* serverDialogMgr = subMgr->getDialogMgr(); SipPublishContentMgr* contentMgr = subServer->getPublishMgr(eventType); HttpBody* preexistingBodyPtr = NULL; UtlBoolean isDefaultContent; subServer->start(); // Enable the handler for the MWI server subServer->enableEventType(eventType, userAgent); //CPPUNIT_ASSERT(TRUE); //ASSERT_STR_EQUAL("a", "a"); // Create a crude Subscription server/observer OsMsgQ incomingServerMsgQueue; // Register an interest in SUBSCRIBE requests // for this event type userAgent->addMessageObserver(incomingServerMsgQueue, SIP_SUBSCRIBE_METHOD, TRUE, // requests FALSE, // no reponses TRUE, // incoming FALSE, // no outgoing eventType, NULL, NULL); OsMsgQ incomingClientMsgQueue; userAgent->addMessageObserver(incomingClientMsgQueue, SIP_SUBSCRIBE_METHOD, FALSE, // no requests TRUE, // reponses TRUE, // incoming FALSE, // no outgoing eventType, NULL, NULL); // Should not be any pre-existing content CPPUNIT_ASSERT(!contentMgr->getContent(resourceId, eventTypeKey, NULL, preexistingBodyPtr, isDefaultContent)); int numDefaultContent = -1; int numResourceSpecificContent = -1; int numCallbacksRegistered = -1; contentMgr->getStats(numDefaultContent, numResourceSpecificContent, numCallbacksRegistered); CPPUNIT_ASSERT(numDefaultContent == 0); CPPUNIT_ASSERT(numResourceSpecificContent == 0); CPPUNIT_ASSERT(numCallbacksRegistered == 1); // Create a subscribe request, send it and keep it refreshed UtlString earlyDialogHandle; CPPUNIT_ASSERT(subClient->addSubscription(resourceId, eventType, from, to, contact, 60, // seconds expiration this, subStateCallback, notifyCallback, earlyDialogHandle)); contentMgr->getStats(numDefaultContent, numResourceSpecificContent, numCallbacksRegistered); CPPUNIT_ASSERT(numDefaultContent == 0); CPPUNIT_ASSERT(numResourceSpecificContent == 0); CPPUNIT_ASSERT(numCallbacksRegistered == 1); // See if a subscribe was sent and received /*OsTime messageTimeout(5, 0); // 5 seconds OsMsg* osMessage = NULL; const SipMessage* subscribeResponse = NULL; const SipMessage* notifyRequest = NULL; incomingServerMsgQueue.receive(osMessage, messageTimeout); CPPUNIT_ASSERT(osMessage); int msgType = osMessage->getMsgType(); int msgSubType = osMessage->getMsgSubType(); CPPUNIT_ASSERT(msgType == OsMsg::PHONE_APP); CPPUNIT_ASSERT(msgSubType == SipMessage::NET_SIP_MESSAGE); const SipMessage* sipMessage = ((SipMessageEvent*)osMessage)->getMessage(); int messageType = ((SipMessageEvent*)osMessage)->getMessageStatus(); CPPUNIT_ASSERT(sipMessage); CPPUNIT_ASSERT(messageType == SipMessageEvent::APPLICATION);*/ const SipMessage* serverSideSubRequest = NULL; CPPUNIT_ASSERT(removeMessage(incomingServerMsgQueue, 5000, // milliseconds serverSideSubRequest)); CPPUNIT_ASSERT(serverSideSubRequest); // Sub request got to server const SipMessage* clientSideSubResponse = NULL; CPPUNIT_ASSERT(removeMessage(incomingClientMsgQueue, 5000, // milliseconds clientSideSubResponse)); CPPUNIT_ASSERT(clientSideSubResponse); //UtlString clientStateString; //subClient->dumpStates(clientStateString); //printf("client states:\n%s\n", clientStateString.data()); int waitIterations = 0; while(smLastClientNotifyReceived == NULL || smLastClientSubResponseReceived == NULL) { OsTask::delay(100); waitIterations++; if(waitIterations >= 100) { break; } } CPPUNIT_ASSERT(smLastClientSubResponseReceived); CPPUNIT_ASSERT(smLastClientNotifyReceived); SipMessage* firstSubResponse = smLastClientSubResponseReceived; smLastClientSubResponseReceived = NULL; int firstSubCseq; firstSubResponse->getCSeqField(&firstSubCseq, NULL); SipMessage* firstNotifyRequest = smLastClientNotifyReceived; smLastClientNotifyReceived = NULL; int firstNotifyCseq; firstNotifyRequest->getCSeqField(&firstNotifyCseq, NULL); CPPUNIT_ASSERT(firstSubCseq == 1); CPPUNIT_ASSERT(firstNotifyCseq == 0); //subClient->dumpStates(clientStateString); //printf("client states:\n%s\n", clientStateString.data()); //UtlString dialogMgrDumpString; //clientDialogMgr.toString(dialogMgrDumpString); //printf("Client Dialog manager dump 1:\n%s\n", // dialogMgrDumpString.data()); // The refresh manager should re-SUBSCRIBE // Wait for the next notify request and subscribe response int secondMessageWait = 60; int resendTimeout = 0.55 * secondMessageWait; if(resendTimeout < 40) { resendTimeout = 40; } for(int i = 0; i < secondMessageWait - 1; i++) { if(i == resendTimeout - 1) { printf("v"); } else { printf("="); } } printf("v\n"); SipMessage* secondSubResponse = NULL; SipMessage* secondNotifyRequest = NULL; while(secondNotifyRequest == NULL || secondSubResponse == NULL) { OsTask::delay(1000); if(smLastClientSubResponseReceived) { secondSubResponse = smLastClientSubResponseReceived; smLastClientSubResponseReceived = NULL; } if(smLastClientNotifyReceived) { secondNotifyRequest = smLastClientNotifyReceived; smLastClientNotifyReceived = NULL; } printf("."); waitIterations++; if(waitIterations >= secondMessageWait) { printf("\n"); break; } } //subClient->dumpStates(clientStateString); //printf("client states:\n%s\n", clientStateString.data()); //clientDialogMgr.toString(dialogMgrDumpString); //printf("Client Dialog manager dump 2:\n%s\n", // dialogMgrDumpString.data()); CPPUNIT_ASSERT(removeMessage(incomingServerMsgQueue, 5000, // milliseconds serverSideSubRequest)); CPPUNIT_ASSERT(serverSideSubRequest); // Sub request got to server //UtlString subRequestDump; //int len; //serverSideSubRequest->getBytes(&subRequestDump, &len); //printf("server side sub request:\n%s\n", // subRequestDump.data()); CPPUNIT_ASSERT(removeMessage(incomingClientMsgQueue, 5000, // milliseconds clientSideSubResponse)); CPPUNIT_ASSERT(clientSideSubResponse); // Sub respon got to client //UtlString subResponseDump; //clientSideSubResponse->getBytes(&subResponseDump, &len); //printf("client side sub response:\n%s\n", // subResponseDump.data()); CPPUNIT_ASSERT(secondNotifyRequest); CPPUNIT_ASSERT(secondSubResponse); int secondSubCseq = -1; int secondNotifyCseq = -1; smLastClientSubResponseReceived = NULL; secondSubResponse->getCSeqField(&secondSubCseq, NULL); smLastClientNotifyReceived = NULL; secondNotifyRequest->getCSeqField(&secondNotifyCseq, NULL); CPPUNIT_ASSERT(firstSubCseq < secondSubCseq); CPPUNIT_ASSERT(firstNotifyCseq < secondNotifyCseq); // Unregister the queues so we stop receiving messages on them userAgent->removeMessageObserver(incomingServerMsgQueue); userAgent->removeMessageObserver(incomingClientMsgQueue); refreshMgr->requestShutdown(); subClient->requestShutdown(); }
bool ConsoleCommandParserResource::performParsing (const NetworkId & userId, const StringVector_t & argv, const String_t & originalCommand, String_t & result, const CommandParser * node) { NOT_NULL (node); UNREF (userId); UNREF(originalCommand); //----------------------------------------------------------------- if (isCommand( argv [0], "activate")) { CachedNetworkId harvester(Unicode::wideToNarrow (argv[1])); ServerObject* harvesterObject = safe_cast<ServerObject*>(harvester.getObject()); if (harvesterObject == NULL) { result += getErrorMessage (argv [0], ERR_INVALID_OBJECT); return true; } Controller *const controller = harvesterObject->getController(); NOT_NULL(controller); controller->appendMessage(static_cast<int>(CM_activateInstallation),0.0f,new MessageQueueActivateInstallation(), GameControllerMessageFlags::SEND | GameControllerMessageFlags::RELIABLE | GameControllerMessageFlags::DEST_AUTH_SERVER); result += getErrorMessage(argv[0], ERR_SUCCESS); } else if (isCommand( argv [0], "harvest")) { CachedNetworkId harvester(Unicode::wideToNarrow (argv[1])); ServerObject* harvesterObject = safe_cast<ServerObject*>(harvester.getObject()); if (harvesterObject == NULL) { result += getErrorMessage (argv [0], ERR_INVALID_OBJECT); return true; } //TODO: Make all of these into function calls instead of sending messages Controller *const controller = harvesterObject->getController(); NOT_NULL(controller); controller->appendMessage(static_cast<int>(CM_installationHarvest),0.0f,new MessageQueueInstallationHarvest(), GameControllerMessageFlags::SEND | GameControllerMessageFlags::RELIABLE | GameControllerMessageFlags::DEST_AUTH_SERVER); result += getErrorMessage(argv[0], ERR_SUCCESS); } else if (isCommand( argv [0], "discardHopper")) { CachedNetworkId harvester(Unicode::wideToNarrow (argv[1])); HarvesterInstallationObject* harvesterObject = dynamic_cast<HarvesterInstallationObject*>(harvester.getObject()); if (!harvesterObject) { result += getErrorMessage (argv [0], ERR_INVALID_OBJECT); return true; } harvesterObject->discardAllHopperContents (); result += getErrorMessage(argv[0], ERR_SUCCESS); } else if (isCommand( argv [0], "deactivate")) { CachedNetworkId harvester(Unicode::wideToNarrow (argv[1])); ServerObject* harvesterObject = safe_cast<ServerObject*>(harvester.getObject()); if (harvesterObject == NULL) { result += getErrorMessage (argv [0], ERR_INVALID_OBJECT); return true; } Controller *const controller = harvesterObject->getController(); NOT_NULL(controller); controller->appendMessage(static_cast<int>(CM_deactivateInstallation),0.0f,new MessageQueueDeactivateInstallation(), GameControllerMessageFlags::SEND | GameControllerMessageFlags::RELIABLE | GameControllerMessageFlags::DEST_AUTH_SERVER); result += getErrorMessage(argv[0], ERR_SUCCESS); } else if (isCommand( argv [0], "tree")) { ServerUniverse & universe = ServerUniverse::getInstance(); ResourceClassObject * root = 0; if (argv.size () > 1) root = universe.getResourceClassByName (Unicode::wideToNarrow (argv [1])); else root = universe.getResourceTreeRoot(); if (root) { std::string temp; root->debugOutput(temp); result += Unicode::narrowToWide(temp); result += getErrorMessage(argv[0], ERR_SUCCESS); } else result += getErrorMessage (argv [0], ERR_INVALID_OBJECT); } else if (isCommand( argv [0], "pools")) { PlanetObject* planet=ServerUniverse::getInstance().getPlanetByName(Unicode::wideToNarrow(argv[1])); if (planet) { std::string temp; planet->debugOutputPools(temp); result += Unicode::narrowToWide(temp); result += getErrorMessage(argv[0], ERR_SUCCESS); } else { result += getErrorMessage (argv [0], ERR_INVALID_OBJECT); } } else if (isCommand( argv [0], "name")) { NetworkId resourceId(Unicode::wideToNarrow (argv[1])); ResourceTypeObject * const resource = ServerUniverse::getInstance().getResourceTypeById(resourceId); if (resource) { resource->setName(Unicode::wideToNarrow(argv[2])); result += getErrorMessage(argv[0], ERR_SUCCESS); } else { result += getErrorMessage (argv [0], ERR_INVALID_OBJECT); } } else if (isCommand( argv [0], "viewcontainer")) { CachedNetworkId contId (Unicode::wideToNarrow (argv[1])); ResourceContainerObject* container=dynamic_cast<ResourceContainerObject*>(contId.getObject()); if (container) { result += Unicode::narrowToWide(container->debugPrint()+'\n'); result += getErrorMessage(argv[0], ERR_SUCCESS); } else { result += getErrorMessage (argv [0], ERR_INVALID_OBJECT); } } else if (isCommand( argv [0], "addtocontainer")) { NetworkId const contId (Unicode::wideToNarrow (argv[1])); ResourceContainerObject * const container = dynamic_cast<ResourceContainerObject*>(NetworkIdManager::getObjectById(contId)); std::string const & resourcePath = Unicode::wideToNarrow(argv[2]); ResourceTypeObject * const resType = ServerUniverse::getInstance().getResourceTypeByName(resourcePath); int const amount = strtol(Unicode::wideToNarrow (argv[3]).c_str (), NULL, 10); NetworkId const source(Unicode::wideToNarrow (argv[4])); if (container && resType) { if (container->addResource(CachedNetworkId(resType->getNetworkId()),amount, source)) result += getErrorMessage(argv[0], ERR_SUCCESS); else result += getErrorMessage(argv[0], ERR_INVALID_CONTAINER_TRANSFER); } else { result += getErrorMessage (argv [0], ERR_INVALID_OBJECT); } } else if (isCommand( argv [0], "fillcontainer")) { NetworkId contId (Unicode::wideToNarrow (argv[1])); ResourceContainerObject* container=dynamic_cast<ResourceContainerObject*>(NetworkIdManager::getObjectById(contId)); if (container != NULL) { NetworkId sourceId; if (argv.size() >= 3) sourceId = NetworkId(Unicode::wideToNarrow (argv[2])); if (container->addResource(container->getResourceType(), container->getMaxQuantity() - container->getQuantity(), sourceId)) { result += getErrorMessage(argv[0], ERR_SUCCESS); } else result += getErrorMessage(argv[0], ERR_INVALID_CONTAINER_TRANSFER); } else result += getErrorMessage (argv [0], ERR_INVALID_OBJECT); } else if (isCommand( argv [0], "recycle")) { NetworkId contId (Unicode::wideToNarrow (argv[1])); ResourceContainerObject* container=dynamic_cast<ResourceContainerObject*>(NetworkIdManager::getObjectById(contId)); if (container != NULL) { if (container->debugRecycle()) result += getErrorMessage(argv[0], ERR_SUCCESS); else result += Unicode::narrowToWide("The resource in the container could not be recycled.\n"); } else result += getErrorMessage (argv [0], ERR_INVALID_OBJECT); } else if (isCommand( argv [0], "removefromcontainer")) { CachedNetworkId contId (Unicode::wideToNarrow (argv[1])); ResourceContainerObject* container=dynamic_cast<ResourceContainerObject*>(contId.getObject()); ResourceTypeObject *resType=ServerUniverse::getInstance().getResourceTypeByName(Unicode::wideToNarrow(argv[2])); int amount=strtol(Unicode::wideToNarrow (argv[3]).c_str (), NULL, 10); if (container && resType) { NetworkId sourcePlayer(NetworkId::cms_invalid); typedef std::vector<std::pair<NetworkId, int> > SourcesType; SourcesType sources; if (container->removeResource(resType->getNetworkId(),amount,&sources)) { char buffer[50]; for(SourcesType::iterator i=sources.begin(); i!=sources.end(); ++i) { IGNORE_RETURN(snprintf(buffer,50,"%i",i->second)); result += Unicode::narrowToWide(std::string("Removed ") + buffer + " resources harvested by player " + i->first.getValueString() + '\n'); } result += getErrorMessage(argv[0], ERR_SUCCESS); } else result += getErrorMessage(argv[0], ERR_INVALID_CONTAINER_TRANSFER); } else { result += getErrorMessage (argv [0], ERR_INVALID_OBJECT); } } else if (isCommand( argv [0], "getSurveyList")) { std::string parentResourceClassName(Unicode::wideToNarrow(argv[1])); CachedNetworkId tool(Unicode::wideToNarrow (argv[2])); SurveySystem::getInstance().requestResourceListForSurvey(userId, tool, parentResourceClassName); result += getErrorMessage(argv[0], ERR_SUCCESS); } else if (isCommand( argv [0], "survey")) { const std::string parentResourceClassName (Unicode::wideToNarrow(argv[1])); const std::string resourceTypeName (Unicode::wideToNarrow(argv[2])); const int surveyRange = strtol(Unicode::wideToNarrow(argv[3]).c_str(),NULL,10); const int numPoints = strtol(Unicode::wideToNarrow(argv[4]).c_str(),NULL,10); const Object * player = NetworkIdManager::getObjectById(userId); if (player) { SurveySystem::getInstance().requestSurvey(userId, parentResourceClassName, resourceTypeName, player->getPosition_w(), surveyRange, numPoints); result += getErrorMessage(argv[0], ERR_SUCCESS); } else result += getErrorMessage(argv [0], ERR_INVALID_OBJECT); } else if (isCommand( argv [0], "deplete")) { NetworkId resourceId (Unicode::wideToNarrow (argv[1])); if (ServerUniverse::getInstance().manualDepleteResource(resourceId)) result += getErrorMessage(argv[0], ERR_SUCCESS); else result += getErrorMessage (argv [0], ERR_INVALID_OBJECT); } return true; } // ConsoleCommandParserResource::performParsing