ProvisioningAttrList* ACDAudioManager::Delete(ProvisioningAttrList& rRequestAttributes) { ProvisioningAttrList* pResponse; UtlString name; osPrintf("{method} = delete\n{object-class} = acd-audio\n"); rRequestAttributes.dumpAttributes(); osPrintf("\n"); // Extract the instance index from the request attributes. rRequestAttributes.getAttribute(AUDIO_NAME_TAG, name); mLock.acquire(); // Verify that the instance has already been created. TiXmlNode* pInstanceNode = findPSInstance(ACD_AUDIO_TAG, AUDIO_NAME_TAG, name); if (pInstanceNode == NULL) { // There is no instance. mLock.release(); pResponse = new ProvisioningAttrList; pResponse->setAttribute("method-name", "delete"); pResponse->setAttribute("result-code", ProvisioningAgent::UNKNOWN_OBJECT); pResponse->setAttribute("result-text", "Unknown instance"); return pResponse; } // If Administrative State == ACTIVE, delete the ACDAudio object // For now - do not allow this to be deleted on fly - for protection #if 0 if (mpAcdServer->getAdministrativeState() == ACDServer::ACTIVE) { deleteACDAudio(name); } #endif // Remove the instance from the configuration file deletePSInstance(ACD_AUDIO_TAG, AUDIO_NAME_TAG, name); // Update the configuration file OsSysLog::add(LOG_FACILITY, PRI_INFO, "ACDAudioManager::Delete - Updating the config file"); mpXmlConfigDoc->SaveFile(); mLock.release(); // Build up the response. pResponse = new ProvisioningAttrList; pResponse->setAttribute("method-name", "delete"); pResponse->setAttribute("result-code", ProvisioningAgent::SUCCESS); pResponse->setAttribute("result-text", "SUCCESS"); return pResponse; }
ProvisioningAttrList* ACDAudioManager::Get(ProvisioningAttrList& rRequestAttributes) { ProvisioningAttrList* pResponse; ProvisioningAttrList* pAudioInstance; UtlString name; UtlSList* pAudioList; osPrintf("{method} = get\n{object-class} = acd-audio\n"); rRequestAttributes.dumpAttributes(); osPrintf("\n"); mLock.acquire(); // Extract the instance index from the request attributes. if (rRequestAttributes.getAttribute(AUDIO_NAME_TAG, name)) { // A specific instance has been specified, verify that it exists ACDAudio* pAudioRef = getAcdAudioReference(name); if (pAudioRef == NULL) { // There is no instance. mLock.release(); pResponse = new ProvisioningAttrList; pResponse->setAttribute("method-name", "get"); pResponse->setAttribute("result-code", ProvisioningAgent::UNKNOWN_OBJECT); pResponse->setAttribute("result-text", "Unknown instance"); return pResponse; } // Call the instance to get the requested attributes pResponse = new ProvisioningAttrList; try { pAudioRef->getAttributes(rRequestAttributes, pResponse); } catch (UtlString error) { // The request for attributes failed, send back the response mLock.release(); pResponse->setAttribute("method-name", "get"); pResponse->setAttribute("result-code", ProvisioningAgent::FAILURE); pResponse->setAttribute("result-text", error); return pResponse; } // Send back the response mLock.release(); pResponse->setAttribute("method-name", "get"); pResponse->setAttribute("result-code", ProvisioningAgent::SUCCESS); pResponse->setAttribute("result-text", "SUCCESS"); pResponse->setAttribute("object-class", ACD_AUDIO_TAG); pResponse->setAttribute(AUDIO_NAME_TAG, name); return pResponse; } else { // No specific instance was requested, send back a list of the available instances // Find the first instance. TiXmlNode* pInstanceNode = findPSInstance(ACD_AUDIO_TAG); pAudioList = new UtlSList; // Build up a list of instances while (pInstanceNode != NULL) { // Read the index parameter getPSAttribute(pInstanceNode, AUDIO_NAME_TAG, name); // Create the list entry pAudioInstance = new ProvisioningAttrList; pAudioInstance->setAttribute("object-class", ACD_AUDIO_TAG); pAudioInstance->setAttribute(AUDIO_NAME_TAG, name); pAudioList->append(pAudioInstance->getData()); // Get the next instance. pInstanceNode = pInstanceNode->NextSibling(); } // Send back the response mLock.release(); pResponse = new ProvisioningAttrList; pResponse->setAttribute("method-name", "get"); pResponse->setAttribute("result-code", ProvisioningAgent::SUCCESS); pResponse->setAttribute("result-text", "SUCCESS"); pResponse->setAttribute("object-class-list", pAudioList); return pResponse; } }
ProvisioningAttrList* ACDAudioManager::Set(ProvisioningAttrList& rRequestAttributes) { ProvisioningAttrList* pResponse; UtlString name; UtlString uriString; UtlString description; bool localStore; osPrintf("{method} = set\n{object-class} = acd-audio\n"); rRequestAttributes.dumpAttributes(); osPrintf("\n"); // Extract the instance index from the request attributes. rRequestAttributes.getAttribute(AUDIO_NAME_TAG, name); mLock.acquire(); // Verify that the instance has already been created. TiXmlNode* pInstanceNode = findPSInstance(ACD_AUDIO_TAG, AUDIO_NAME_TAG, name); if (pInstanceNode == NULL) { // There is no instance. mLock.release(); pResponse = new ProvisioningAttrList; pResponse->setAttribute("method-name", "set"); pResponse->setAttribute("result-code", ProvisioningAgent::UNKNOWN_OBJECT); pResponse->setAttribute("result-text", "Unknown instance"); return pResponse; } // Validate that the attribute types are correct, ignoring any that are missing try { rRequestAttributes.validateAttributeType(AUDIO_URI_TAG, ProvisioningAttrList::STRING); rRequestAttributes.validateAttributeType(AUDIO_DESCRIPTION_TAG, ProvisioningAttrList::STRING); rRequestAttributes.validateAttributeType(AUDIO_LOCAL_STORE_TAG, ProvisioningAttrList::BOOL); } catch (UtlString error) { // One of the attributes is not set to the correct type mLock.release(); pResponse = new ProvisioningAttrList; pResponse->setAttribute("method-name", "set"); pResponse->setAttribute("result-code", ProvisioningAgent::INVALID_ATTR); pResponse->setAttribute("result-text", error); return pResponse; } // If Administrative State == ACTIVE, update the ACDAudio object if (mpAcdServer->getAdministrativeState() == ACDServer::ACTIVE) { // Lookup the instance ACDAudio* pAudioRef = getAcdAudioReference(name); if (pAudioRef == NULL) { // There is no instance. mLock.release(); pResponse = new ProvisioningAttrList; pResponse->setAttribute("method-name", "set"); pResponse->setAttribute("result-code", ProvisioningAgent::UNKNOWN_OBJECT); pResponse->setAttribute("result-text", "Unknown instance"); return pResponse; } // Give the list of changed attributes to the object try { pAudioRef->setAttributes(rRequestAttributes); } catch (UtlString error) { // The object rejected the request, return error. mLock.release(); pResponse = new ProvisioningAttrList; pResponse->setAttribute("method-name", "set"); pResponse->setAttribute("result-code", ProvisioningAgent::INVALID_ATTR); pResponse->setAttribute("result-text", error); return pResponse; } } // Now save the individual attributes // local-store if (rRequestAttributes.getAttribute(AUDIO_LOCAL_STORE_TAG, localStore)) { setPSAttribute(pInstanceNode, AUDIO_LOCAL_STORE_TAG, localStore); } // uri if (rRequestAttributes.getAttribute(AUDIO_URI_TAG, uriString)) { setPSAttribute(pInstanceNode, AUDIO_URI_TAG, uriString); } // description if (rRequestAttributes.getAttribute(AUDIO_DESCRIPTION_TAG, description)) { setPSAttribute(pInstanceNode, AUDIO_DESCRIPTION_TAG, description); } // Update the configuration file OsSysLog::add(LOG_FACILITY, PRI_INFO, "ACDAudioManager::Set - Updating the config file"); mpXmlConfigDoc->SaveFile(); mLock.release(); // Build up the response. pResponse = new ProvisioningAttrList; pResponse->setAttribute("method-name", "set"); pResponse->setAttribute("result-code", ProvisioningAgent::SUCCESS); pResponse->setAttribute("result-text", "SUCCESS"); return pResponse; }
ProvisioningAttrList* ACDAudioManager::Create(ProvisioningAttrList& rRequestAttributes) { ProvisioningAttrList* pResponse; UtlString name; UtlString uriString; UtlString description; bool localStore; osPrintf("{method} = create\n{object-class} = acd-audio\n"); rRequestAttributes.dumpAttributes(); osPrintf("\n"); // Verify that the required set of attributes are there. try { rRequestAttributes.validateAttribute(AUDIO_NAME_TAG, ProvisioningAttrList::STRING); rRequestAttributes.validateAttribute(AUDIO_LOCAL_STORE_TAG, ProvisioningAttrList::BOOL); rRequestAttributes.validateAttribute(AUDIO_URI_TAG, ProvisioningAttrList::STRING); } catch (UtlString error) { // We're missing at least one mandatory attribute. pResponse = new ProvisioningAttrList; pResponse->setAttribute("method-name", "create"); pResponse->setAttribute("result-code", ProvisioningAgent::MISSING_ATTR); pResponse->setAttribute("result-text", error); return pResponse; } // Extract the instance index from the request attributes. rRequestAttributes.getAttribute(AUDIO_NAME_TAG, name); mLock.acquire(); // Verify that an instance of this object has not already been created. TiXmlNode* pInstanceNode = findPSInstance(ACD_AUDIO_TAG, AUDIO_NAME_TAG, name); if (pInstanceNode != NULL) { //The instance has already been created, send back the response. mLock.release(); pResponse = new ProvisioningAttrList; pResponse->setAttribute("method-name", "create"); #ifdef CML pResponse->setAttribute("result-code", ProvisioningAgent::ALREADY_EXISTS); #else pResponse->setAttribute("result-code", ProvisioningAgent::DUPLICATE); #endif pResponse->setAttribute("result-text", "Managed Object Instance already exists"); return pResponse; } // Validate that the optional attribute types are correct, ignoring any that are missing try { rRequestAttributes.validateAttributeType(AUDIO_DESCRIPTION_TAG, ProvisioningAttrList::STRING); } catch (UtlString error) { // One of the optional attributes is not set to the correct type mLock.release(); pResponse = new ProvisioningAttrList; pResponse->setAttribute("method-name", "create"); pResponse->setAttribute("result-code", ProvisioningAgent::INVALID_ATTR); pResponse->setAttribute("result-text", error); return pResponse; } // Create the instance in the configuration file pInstanceNode = createPSInstance(ACD_AUDIO_TAG, AUDIO_NAME_TAG, name); if (pInstanceNode == NULL) { mLock.release(); // Instance creation failed. pResponse = new ProvisioningAttrList; pResponse->setAttribute("method-name", "create"); pResponse->setAttribute("result-code", ProvisioningAgent::UNDEFINED); pResponse->setAttribute("result-text", "Managed Object Instance creation failed"); return pResponse; } // Now save the individual attributes // local-store if (rRequestAttributes.getAttribute(AUDIO_LOCAL_STORE_TAG, localStore)) { setPSAttribute(pInstanceNode, AUDIO_LOCAL_STORE_TAG, localStore); } // uri (optional) if (rRequestAttributes.getAttribute(AUDIO_URI_TAG, uriString)) { setPSAttribute(pInstanceNode, AUDIO_URI_TAG, uriString); } // description (optional) if (rRequestAttributes.getAttribute(AUDIO_DESCRIPTION_TAG, description)) { setPSAttribute(pInstanceNode, AUDIO_DESCRIPTION_TAG, description); } // If Administrative State == ACTIVE, create the ACDAgent if (mpAcdServer->getAdministrativeState() == ACDServer::ACTIVE) { createACDAudio(name, localStore, uriString, description); } // Update the configuration file OsSysLog::add(LOG_FACILITY, PRI_INFO, "ACDAudioManager::Create - Updating the config file"); mpXmlConfigDoc->SaveFile(); mLock.release(); // Build up the response. pResponse = new ProvisioningAttrList; pResponse->setAttribute("method-name", "create"); pResponse->setAttribute("result-code", ProvisioningAgent::SUCCESS); pResponse->setAttribute("result-text", "SUCCESS"); return pResponse; }
ProvisioningAttrList* XmlRpcSignIn::Action(ProvisioningAttrList& rRequestAttributes) { ProvisioningAttrList* pResponse; UtlString uriString; UtlString status; osPrintf("{method} = action\n{object-class} = login\n"); rRequestAttributes.dumpAttributes(); osPrintf("\n"); // Extract the action attribute from the request // operate on either sign-in or sign-out attributes if (rRequestAttributes.getAttribute(XMLRPC_SIGN_IN_TAG, uriString)) { // See if the Agent is not already signed-in Url contactUrl(uriString); mpSipPresenceMonitor->getState(contactUrl, status); if (status.compareTo(STATUS_OPEN) == 0) { // Already signed-in, return error pResponse = new ProvisioningAttrList; pResponse->setAttribute("method-name", "action"); pResponse->setAttribute("result-code", ProvisioningAgent::SUCCESS); pResponse->setAttribute("result-text", "SUCCESS: User already signed-in"); return pResponse; } // Sign-in the Agent mpSipPresenceMonitor->setStatus(contactUrl, StateChangeNotifier::PRESENT); // Build up the response. pResponse = new ProvisioningAttrList; pResponse->setAttribute("method-name", "action"); pResponse->setAttribute("result-code", ProvisioningAgent::SUCCESS); pResponse->setAttribute("result-text", "SUCCESS: sign-in"); return pResponse; } else if (rRequestAttributes.getAttribute(XMLRPC_SIGN_OUT_TAG, uriString)) { // See if the Agent is not already signed-out Url contactUrl(uriString); mpSipPresenceMonitor->getState(contactUrl, status); if (status.compareTo(STATUS_CLOSED) == 0) { // Already signed-out, return error pResponse = new ProvisioningAttrList; pResponse->setAttribute("method-name", "action"); pResponse->setAttribute("result-code", ProvisioningAgent::SUCCESS); pResponse->setAttribute("result-text", "SUCCESS: User already signed-out"); return pResponse; } // Sign-out the Agent mpSipPresenceMonitor->setStatus(contactUrl, StateChangeNotifier::AWAY); // Build up the response. pResponse = new ProvisioningAttrList; pResponse->setAttribute("method-name", "action"); pResponse->setAttribute("result-code", ProvisioningAgent::SUCCESS); pResponse->setAttribute("result-text", "SUCCESS: sign-out"); return pResponse; } else if (rRequestAttributes.getAttribute(XMLRPC_SIGN_IN_STATUS_TAG, uriString)) { // Get the Agent status Url contactUrl(uriString); mpSipPresenceMonitor->getState(contactUrl, status); // Build up the response. pResponse = new ProvisioningAttrList; pResponse->setAttribute("method-name", "action"); pResponse->setAttribute("result-code", ProvisioningAgent::SUCCESS); pResponse->setAttribute("result-text", status); return pResponse; } else { // Unrecognized or missing action-object pResponse = new ProvisioningAttrList; pResponse->setAttribute("method-name", "action"); pResponse->setAttribute("result-code", ProvisioningAgent::FAILURE); pResponse->setAttribute("result-text", "Invalid action operation"); return pResponse; } }