void testAllNoDefaultPermutations()
      {
         FallbackRulesUrlMapping* urlmap;
         ResultSet registrations;
         UtlString actual;
         UtlString callTag = "UNK";

         CPPUNIT_ASSERT( urlmap = new FallbackRulesUrlMapping() );
         UtlString simpleXml;
         mFileTestContext->inputFilePath("fallbackrules.xml", simpleXml);
         CPPUNIT_ASSERT( urlmap->loadMappings(simpleXml.data() ) == OS_SUCCESS );

         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString("boston"),
                                registrations, callTag
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 2 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("sip:[email protected]",actual);
         getResult( registrations, 1, "contact", actual);
         ASSERT_STR_EQUAL("sip:[email protected]",actual);
         registrations.destroyAll();

         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString("salem"),
                                registrations, callTag
                                ) != OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 0 ,  registrations.getSize() );
         
         delete urlmap;
      }
      void testAllNonMatchingDialstrings()
      {
         FallbackRulesUrlMapping* urlmap;
         ResultSet registrations;
         UtlString actual;
         UtlString callTag = "UNK";

         CPPUNIT_ASSERT( urlmap = new FallbackRulesUrlMapping() );
         UtlString simpleXml;
         mFileTestContext->inputFilePath("fallbackrules.xml", simpleXml);
         CPPUNIT_ASSERT( urlmap->loadMappings(simpleXml.data() ) == OS_SUCCESS );

         // use non-matching host name
         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString("boston"),
                                registrations, callTag
                                ) != OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 0 ,  registrations.getSize() );
         registrations.destroyAll();

         // use non-matching user name
         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString("boston"),
                                registrations, callTag
                                ) != OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 0 ,  registrations.getSize() );
         registrations.destroyAll();

         delete urlmap;         
      }
Esempio n. 3
0
OsStatus
RecycleDeletedMsgsCGI::handleWebRequest( UtlString* out )
{
    UtlString redirectUrl, dynamicHtml;
    MailboxManager* pMailboxManager = MailboxManager::getInstance();
    OsStatus result = pMailboxManager->getMediaserverURLForWeb( redirectUrl ) ;
    if( result == OS_SUCCESS )
    {
        // URL of the result webpage
        redirectUrl +=  UtlString( CGI_URL ) +
                        "?action=playmsg&fromweb=yes&from=gateway" +
                        "&nextblockhandle=" + UtlString( m_nextBlockHandle ) +
                        "&category=deleted";
        if( m_messageids.length() > 0 )
        {
            // Instantiate the mailbox manager
                result = pMailboxManager->recycleDeletedMessages( m_mailboxIdentity, m_messageids );

            // Add status to indicate the status of purge.
                if( result == OS_SUCCESS )
            {
                redirectUrl +=  UtlString( "&status=" ) +
                                RECYCLE_DELETED_MSG_SUCCESSFUL ;
            }
            else
            {
                        redirectUrl +=  UtlString( "&status=" ) +
                                RECYCLE_DELETED_MESSAGES_FAILED ;
            }
        }
        else
        {
            redirectUrl +=  UtlString( "&status=" ) +
                            RECYCLE_DELETED_MSG_NOT_SELECTED ;
        }

        // Script for redirecting to the webpage displaying folder contents
            dynamicHtml  =      HTML_BEGIN \
                        REDIRECT_SCRIPT_BEGIN + redirectUrl + REDIRECT_SCRIPT_END \
                        HTML_END ;
    }
    else
    {
        dynamicHtml =   HTML_BEGIN \
                        PROTOCOL_MISMATCH \
                        HTML_END ;
    }

    if (out)
        {
                out->remove(0);
                out->append(dynamicHtml.data());
        }
        return OS_SUCCESS;
}
PtAddressForwarding::PtAddressForwarding(const char* destinationURL,
                                                                                 int type,
                                                                                 int filterType,
                                                                                 const char* callerURL,
                                                                                 int noAnswerTimeout)
{
   mDestinationUrl = UtlString(destinationURL);
   mForwardingType = type;
   mFilterType = filterType;
   mNoAnswerTimeout = noAnswerTimeout;
   if (callerURL)
   {
           mCallerUrl = UtlString(callerURL);
   }
}
Esempio n. 5
0
void SdpCandidate::toString(UtlString& sdpCandidateString) const
{
   char stringBuffer[512];
   UtlString extensionAttributesString;

   // build extension attributes string
   UtlSListIterator it(mExtensionAttributes);
   SdpCandidateExtensionAttribute* attribute;
   while((attribute = (SdpCandidateExtensionAttribute*) it()))
   {
      extensionAttributesString += attribute->getName() + UtlString("=") + attribute->getValue() + UtlString(", ");
   }
   
   sprintf(stringBuffer, "SdpCandidate: foundation=\'%s\', id=%d, transport=%s, priority=%" FORMAT_INTLL "d, addr=\'%s\', port=%d, type=%s\n"
                         "              relatedAddr=%s, relatedPort=%d, %sinUse=%d\n",
      mFoundation.data(),
      mId,
      SdpCandidateTransportTypeString[mTransport],
      mPriority,
      mConnectionAddress.data(),
      mPort,
      SdpCandidateTypeString[mCandidateType],
      mRelatedAddress.data(),
      mRelatedPort,
      extensionAttributesString.data(),
      mInUse);

   sdpCandidateString = stringBuffer;

}
PtAddressForwarding::PtAddressForwarding(const char* destinationURL,
                                                                                 int type,
                                                                                 const char* callerURL,
                                                                                 int noAnswerTimeout)
{
   mDestinationUrl = UtlString(destinationURL);
   mForwardingType = type;
   mNoAnswerTimeout = noAnswerTimeout;
   if (callerURL)
   {
           mFilterType = SPECIFIC_ADDRESS;
           mCallerUrl = UtlString(callerURL);
   }
   else
           mFilterType = ALL_CALLS;
}
Esempio n. 7
0
OsStatus
LoginCGI::handleWebRequest( UtlString* out )
{
    UtlString redirectUrl, dynamicHtml ;
    MailboxManager* pMailboxManager = MailboxManager::getInstance();
    OsStatus result = pMailboxManager->getMediaserverURLForWeb( redirectUrl ) ;
    if( result == OS_SUCCESS )
    {
            // Validate the mailbox id and extension.
        ValidateMailboxCGIHelper validateMailboxHelper ( m_userid );
        result = validateMailboxHelper.execute( out );
            if ( result == OS_SUCCESS )
                    redirectUrl += CGI_URL + UtlString( "?action=retrieve&fromweb=yes" ) ;
            else
                    redirectUrl += VOICEMAIL_NOT_ENABLED_URL;

            dynamicHtml  =      HTML_BEGIN \
                        REDIRECT_SCRIPT_BEGIN + redirectUrl + REDIRECT_SCRIPT_END \
                        HTML_END ;
    }
    else
    {
        dynamicHtml =   HTML_BEGIN \
                        PROTOCOL_MISMATCH \
                        HTML_END ;
    }

        if (out)
        {
                out->remove(0);
                out->append(dynamicHtml.data());
        }

        return OS_SUCCESS ;
}
Esempio n. 8
0
void ProvisioningAttrList::validateAttribute(const char* pKey, eAttributeType type, bool ignoreMissing)
{
   UtlContainable* attribute;
   UtlString utlKey(pKey);

   attribute = dynamic_cast<const UtlHashMap*>(mpData)->findValue(&utlKey);
   if (attribute == NULL) {
      if (ignoreMissing) {
         // If it is missing, just return
         return;
      }
      else {
         UtlString errorText("Missing attribute: '");
         errorText += pKey;
         errorText += "'";
         throw errorText;
      }
   }

   switch (type) {
      case ProvisioningAttrList::INT:
         if (UtlString(attribute->getContainableType()) != "UtlInt") {
            UtlString errorText("Attribute '");
            errorText += pKey;
            errorText += "' must be of type: INT";
            throw errorText;
         }
         break;
      case ProvisioningAttrList::BOOL:
         if (UtlString(attribute->getContainableType()) != "UtlBool") {
            UtlString errorText("Attribute: '");
            errorText += pKey;
            errorText += "' must be of type: BOOL";
            throw errorText;
         }
         break;
      case ProvisioningAttrList::STRING:
         if (UtlString(attribute->getContainableType()) != "UtlString") {
            UtlString errorText("Attribute: '");
            errorText += pKey;
            errorText += "' must be of type: STRING";
            throw errorText;
         }
         break;
   }
}
Esempio n. 9
0
int TaoTransportAgent::run(void* runArg)
{
        UtlString remoteHostName;
        UtlString viaProtocol;
    UtlString fromIpAddress;

        while (mpSocket && mpSocket->isOk() && !isShuttingDown())
        {
                char          buffer[DEF_TAO_MAX_SOCKET_SIZE];
                unsigned long bytesRead;
                unsigned long cookie ;
                unsigned long length ;

                memset(buffer, 0, (DEF_TAO_MAX_SOCKET_SIZE * sizeof(char)));

                // Look for our next message, it should start with a '1234ABCD' marker
                bytesRead = mpSocket->read((char*) &cookie, sizeof(unsigned long)) ;
                while ((bytesRead > 0) && (cookie != 0x1234ABCD)) {
                        osPrintf("<<**>> Invalid data read from socket, trying to resynchronize...\n") ;
                        bytesRead = readUntilDone(mpSocket, (char*) &cookie, sizeof(unsigned long)) ;
                }
                // Okay, now read length
                if (bytesRead > 0) {
                        bytesRead = readUntilDone(mpSocket, (char*) &length, sizeof(unsigned long)) ;
                }
                // Finally read data
                if (bytesRead > 0) {
                        bytesRead = readUntilDone(mpSocket, buffer, length) ;

                        if (bytesRead != length) {
                                osPrintf("<<**>> TaoTransportAgent READ MISMATCH %lu != %lu\n", bytesRead, length) ;
                                bytesRead = 0 ;
                        }
                }

                if(bytesRead > 0)
                {
                        TaoMessage msg = TaoMessage(UtlString(buffer));
                        msg.setSocket((TaoObjHandle)this);      //stores pointer to this class

                        mpServer->postMessage(msg);
                }
                else if(bytesRead <= 0 || !mpSocket->isOk())
                {
                        // The socket has gone sour close down the client
                        mpSocket->getRemoteHostName(&remoteHostName);
                        osPrintf("Shutting down TaoTransportAgent: %s due to failed socket\n",
                                remoteHostName.data());
                        break;
                }
        }

#ifdef TEST_PRINT
        osPrintf("TaoTransportAgent: %s/%s exiting\r\n", remoteHostName.data(),
                viaName.data());
#endif
        return(0);
}
// Constructor
PtAddressForwarding::PtAddressForwarding(const char* destinationURL,
                                                                                 int type,
                                                                                 int noAnswerTimeout)
{
        mDestinationUrl = UtlString(destinationURL);
        mForwardingType = type;
        mFilterType = ALL_CALLS;
        mNoAnswerTimeout = noAnswerTimeout;
}
Esempio n. 11
0
OsStackTraceLogger::OsStackTraceLogger(const OsSysLogFacility facility,
                    const OsSysLogPriority priority,
                    const char* methodName,
                    const OsStackTraceLogger& oneBackInStack) : 
    mMethodName(methodName),
    mFacility(facility),
    mPriority(priority)
{
    OsTaskId_t tid;
    UtlString taskHex("ENTER FUNC (tid=");
    mMethodName = UtlString(oneBackInStack.mMethodName) + UtlString("->") + mMethodName;
    OsTask::getCurrentTaskId(tid);
    // TODO: should get abstracted into an OsTaskBase method
#ifdef __pingtel_on_posix__
    OsTaskLinux::getIdString_X(taskHex, tid);
#endif
    OsSysLog::add(mFacility, mPriority, "%s) %s\n",
        taskHex.data(), mMethodName.data());
}
Esempio n. 12
0
UtlBoolean PsTaoButton::setInfo(const UtlString& rInfo)
{
        if (mbNotSetBefore || mButtonInfo != rInfo)
        {
                mButtonInfo = UtlString(rInfo);
                mbNotSetBefore = FALSE;
                return TRUE;
        }
        return FALSE;
}
Esempio n. 13
0
int main(int argc, char* argv[])
{
    parseArgs(argc, argv);
    initLogger(argv);

    UtlString urlString = "https://" + UtlString(xmlrpcServer);
    Url url(urlString);
    url.setHostPort(HttpPort);

    // Delay for 5 minutes
//    printf("Wating for start of memcheck ...\n");
//    OsTask::delay(600000);
//    printf("Starting memcheck ...\n");

    // Test run
    // while (1)
    for (int i = 0; i < 10; i++)
    {
        XmlRpcRequest* request = new XmlRpcRequest(url, "addExtension");

        UtlString groupName("*****@*****.**");
        request->addParam(&groupName);

        UtlString extension("*****@*****.**");
        request->addParam(&extension);

        printf("Sending %d ...", i);
        XmlRpcResponse response;
        if (!request->execute(response))
        {
           UtlString reason;
           int code;
           response.getFault(&code,reason);
           printf(" failed\n   %d %s\n", code, reason.data() );
        }
        else
        {
           printf(" ok\n");
        }

        delete request;
        request = NULL;

//        OsTask::delay(2000);
    }
//    printf("Done with memcheck ...\n");

//    while (1)
//    {
//        OsTask::delay(60000);
//    }

    return(1);
}
      void testAllInternationalPermutations()
      {
         FallbackRulesUrlMapping* urlmap;
         ResultSet registrations;
         UtlString actual;
         UtlString callTag = "UNK";

         CPPUNIT_ASSERT( urlmap = new FallbackRulesUrlMapping() );
         UtlString simpleXml;
         mFileTestContext->inputFilePath("fallbackrules.xml", simpleXml);
         CPPUNIT_ASSERT( urlmap->loadMappings(simpleXml.data() ) == OS_SUCCESS );

         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString("Boston"),
                                registrations, callTag
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 1 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("sip:[email protected]",actual);
         registrations.destroyAll();
         
         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString(""),
                                registrations, callTag
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 1 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("sip:[email protected]",actual);
         registrations.destroyAll();
         
         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString("ogden"),
                                registrations, callTag
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 1 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("sip:[email protected]",actual);
         registrations.destroyAll();
         
         delete urlmap;
      }
Esempio n. 15
0
void ProvisioningAttrList::deleteAttrElements(UtlContainable* pAttrElements)
{
   UtlString*         pMemberName;
   UtlContainable*    pMemberValue;

   if (UtlString(pAttrElements->getContainableType()) == "UtlHashMap") {
      UtlHashMapIterator structureIterator(*dynamic_cast<UtlHashMap*>(pAttrElements));
      while ((pMemberName = dynamic_cast<UtlString*>(structureIterator())) != NULL) {
         pMemberValue = dynamic_cast<UtlHashMap*>(pAttrElements)->findValue(pMemberName);
         if (UtlString(pMemberValue->getContainableType()) == "UtlHashMap"
             || UtlString(pMemberValue->getContainableType()) == "UtlSList") {
            deleteAttrElements(pMemberValue);
         }

         delete pMemberName;
         delete pMemberValue;
      }
   }
   else if (UtlString(pAttrElements->getContainableType()) == "UtlSList") {
      UtlSListIterator arrayIterator(*dynamic_cast<UtlSList*>(pAttrElements));
      while ((pMemberValue = arrayIterator()) != NULL) {
         if (UtlString(pMemberValue->getContainableType()) == "UtlHashMap"
             || UtlString(pMemberValue->getContainableType()) == "UtlSList") {
            deleteAttrElements(pMemberValue);
         }

         delete pMemberValue;
      }
   }
}
PtAddressForwarding::PtAddressForwarding(const char* destinationURL,
                                                                                 int type,
                                                                                 PtBoolean internalCalls,
                                                                                 int noAnswerTimeout)
{
   mDestinationUrl = UtlString(destinationURL);
   mForwardingType = type;
   mNoAnswerTimeout = noAnswerTimeout;
   if (internalCalls)
           mFilterType = INTERNAL_CALLS;
   else
           mFilterType = ALL_CALLS;
}
Esempio n. 17
0
bool ProvisioningAttrList::getAttribute(const char* pKey, bool& rValue)
{
   UtlString utlKey(pKey);
   UtlContainable* results;

   results = dynamic_cast<const UtlHashMap*>(mpData)->findValue(&utlKey);
   if (results == NULL) {
      return false;
   }

   if (UtlString(results->getContainableType()) != "UtlBool") {
      return false;
   }

   rValue = dynamic_cast<UtlBool*>(results)->getValue();

   return true;
}
bool ProvisioningAgentXmlRpcAction::execute(const HttpRequestContext&      rContext,
                                            UtlSList&                      rParameters,
                                            void*                          pProvisioningAgentInstance,
                                            XmlRpcResponse&                rResponse,
                                            XmlRpcMethod::ExecutionStatus& rStatus)
{
   rStatus = XmlRpcMethod::OK;

   // Extract the request argument structure from the head of the SList.
   UtlContainable *pRequestArgs = rParameters.at(0);

   // Verify that a parameter list was given
   if (pRequestArgs != NULL) {
      // Verify that the parameter list is a structure ("UtlHashMap").
      if (UtlString(pRequestArgs->getContainableType()) == "UtlHashMap") {
         // Now call the Provisioning Agent.
         ProvisioningAttrList requestAttributes(dynamic_cast<UtlHashMap*>(pRequestArgs));
         ProvisioningAttrList* pResponseAttributes;
         pResponseAttributes = ((ProvisioningAgent*)pProvisioningAgentInstance)->Action(requestAttributes);

         if (pResponseAttributes == NULL) {
            // Method failure.  Report error back to client
            rResponse.setFault(METHOD_DISPATCH_FAULT_CODE, METHOD_DISPATCH_FAULT_STRING);
         }
         else {
            // Encode the response
            rResponse.setResponse(dynamic_cast<UtlContainable*>(pResponseAttributes->getData()));

            // and clean up the responsettributes list.
            delete pResponseAttributes;
         }
      }
      else {
         // Missing parameter list.  Report error back to client
         rResponse.setFault(EXPECTED_STRUCT_FAULT_CODE, EXPECTED_STRUCT_FAULT_STRING);
      }
   }
   else {
      // Bad parameter list.  Report error back to client
      rResponse.setFault(EXPECTED_STRUCT_FAULT_CODE, EXPECTED_STRUCT_FAULT_STRING);
   }

   return true;
}
      void testRouteHeaderPermutations()
      {
         FallbackRulesUrlMapping* urlmap;
         ResultSet registrations;
         UtlString actual;

         CPPUNIT_ASSERT( urlmap = new FallbackRulesUrlMapping() );
         UtlString simpleXml;
         mFileTestContext->inputFilePath("fallbackrules.xml", simpleXml);
         CPPUNIT_ASSERT( urlmap->loadMappings(simpleXml.data() ) == OS_SUCCESS );

         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString("ogden"),
                                registrations
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 1 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("<sip:[email protected]?route=sbc.example.edu>",actual);
         registrations.destroyAll();
         
         delete urlmap;
      }
Esempio n. 20
0
// Constructor
AppearanceAgent::AppearanceAgent(
      SipXecsService* service,
      const UtlString& domainName,
                                       const UtlString& realm,
                                       SipLineMgr* lineMgr,
                                       int tcpPort,
                                       int udpPort,
                                       int tlsPort,
                                       const UtlString& bindIp,
                                       UtlString* appearanceGroupFile,
                                       int refreshInterval,
                                       int resubscribeInterval,
                                       int minResubscribeInterval,
                                       int seizedResubscribeInterval,
                                       int publishingDelay,
                                       int maxRegSubscInGroup,
                                       int serverMinExpiration,
                                       int serverDefaultExpiration,
                                       int serverMaxExpiration,
                                       const UtlString&  subscriptionDbName,
                                       const UtlString&  credentialDbName) :
   mService(service),
   mDomainName(domainName),
   mAppearanceGroupFile(*appearanceGroupFile),
   mRefreshInterval(refreshInterval),
   mResubscribeInterval(resubscribeInterval),
   mMinResubscribeInterval(minResubscribeInterval),
   mSeizedResubscribeInterval(seizedResubscribeInterval),
   mPublishingDelay(publishingDelay),
   mMaxRegSubscInGroup(maxRegSubscInGroup),
   mServerUserAgent(
      tcpPort, // sipTcpPort
      udpPort, // sipUdpPort
      tcpPort, // sipTlsPort
      NULL, // publicAddress
      NULL, // defaultUser
      bindIp, // defaultSipAddress
      domainName.data(), // sipProxyServers (outbound proxy)
      NULL, // sipDirectoryServers
      NULL, // sipRegistryServers
      NULL, // authenicateRealm
      NULL, // authenticateDb
      NULL, // authorizeUserIds
      NULL, // authorizePasswords
      NULL, // lineMgr
      SIP_DEFAULT_RTT, // sipFirstResendTimeout
      TRUE, // defaultToUaTransactions
      -1, // readBufferSize
      OsServerTask::DEF_MAX_MSGS, // queueSize
      FALSE // bUseNextAvailablePort
      ),
   mSubscriptionMgr(SUBSCRIPTION_COMPONENT_SAA, mDomainName, subscriptionDbName),
   mPolicyHolder(domainName, realm, credentialDbName),
   mSubscribeServer(SipSubscribeServer::terminationReasonSilent,
                    mServerUserAgent, mEventPublisher, mSubscriptionMgr,
                    mPolicyHolder),
   mRefreshMgr(mServerUserAgent, mDialogManager),
   mSubscribeClient(mServerUserAgent, mDialogManager, mRefreshMgr),
   mAppearanceAgentTask(this),
   mAppearanceGroupSet(this),
   // Do not set the appearance group file name yet, so the AppearanceGroupFileReader
   // doesn't add elements to the AppearanceGroupSet before we have the
   // SIP tasks set up.
   mAppearanceGroupFileReader(mService, UtlString(""), &mAppearanceGroupSet)
{
   OsSysLog::add(FAC_SAA, PRI_DEBUG,
                 "AppearanceAgent::_ this = %p, mDomainName = '%s', "
                 "mRefreshInterval = %d, mResubscribeInterval = %d",
                 this, mDomainName.data(), mRefreshInterval, mResubscribeInterval);
   OsSysLog::add(FAC_SAA, PRI_DEBUG,
                 "AppearanceAgent::_ this = %p, mPublishingDelay = %d, mMaxRegSubscInGroup = %zu",
                 this, publishingDelay, mMaxRegSubscInGroup);

   // Initialize the call processing objects.

   // contact address to be used in outgoing requests (primarily SUBSCRIBEs)
   mServerFromURI = "sip:sipXsaa@";
   mServerFromURI.append(mDomainName);
   mServerUserAgent.getContactURI(mServerContactURI);

   // Initialize the SipUserAgents.
   // Set the user-agent strings.
   mServerUserAgent.setUserAgentHeaderProperty("sipXecs/saa");

   // Set the subscribe server grant times.
   if (!mSubscriptionMgr.setSubscriptionTimes(serverMinExpiration,
                                              serverDefaultExpiration,
                                              serverMaxExpiration))
   {
      OsSysLog::add(FAC_SAA, PRI_ERR,
                    "AppearanceAgent given unacceptable server subscription times: min = %d, default = %d, max = %d.  Using the default subscription times.",
                    serverMinExpiration,
                    serverDefaultExpiration,
                    serverMaxExpiration);
   }
}
Esempio n. 21
0
   void instantiateAllTestFixtures( UtlString resourceListFile,
                                    //< Name of the resource list to use for the test.  The filename
                                    //< specified mus texist in .../sipXrls/src/test/rlsdata/
                                    UtlString subscriptionDbName, 
                                    //< Specifies the subscription DB to use for the test.  The name 
                                    //< is used to select which of the files in .../sipXrls/src/test/rlsdata/
                                    //< will get used to preload the subscription IMDB.  The name provided here is the 
                                    //< xml file in .../sipXrls/src/test/rlsdata/ without the ".xml" extension.
                                    UtlString credentialDbName,
                                    //< Specifies the credential DB to use for the test.  The name 
                                    //< is used to select which of the files in .../sipXrls/src/test/rlsdata/
                                    //< will get used to preload the credential IMDB.  The name provided here is the 
                                    //< xml file in .../sipXrls/src/test/rlsdata/ without the ".xml" extension.
                                    UtlString domianName,
                                    //< Specify the domain name to use for the test
                                    UtlBoolean routeAllRequestsToRlsServer
                                    //< Send all requests to either the RLS Server UA or the RLS Client UA
                                    //< The Client UA typically deals with the outgoing subscriptions and
                                    //< the Server UA deals witht the incoming subscriptions
                                    )
   {
      mCredentialDbName = credentialDbName;
      // force copy of input files into the 'work' directory
      sipDbContext.inputFile( subscriptionDbName + ".xml" );
      sipDbContext.inputFile( credentialDbName + ".xml" );
      UtlString tempResourceListFile = UtlString(TEST_DATA_DIR) + "/" + resourceListFile;

      pSipUserAgent = new SipUserAgent( 45141, 45141, 45142
                                       ,"127.0.0.1"  // default publicAddress
                                       ,NULL         // default defaultUser
                                       ,"127.0.0.1" );  // default defaultSipAddress

      // Stop SipUserAgent from rejecting all SUBSCRIBEs
      pSipUserAgent->allowMethod(SIP_SUBSCRIBE_METHOD, true);

      SipXecsService* rlsTestService = new SipXecsService("sipxrlsTest", "SIPX_RLS", "TestCase");

      pResourceServerUnderTest = new ResourceListServer(rlsTestService,
                                       domianName, // domain 
                                       "rlstest.test", // realm
                                       NULL, 
                                       DIALOG_EVENT_TYPE, 
                                      DIALOG_EVENT_CONTENT_TYPE,
                                       45140, // TCP port
                                       45140, // UDP port
                                       45140, // TLS port
                                       "127.0.0.1", // Bind IP address
                                       &tempResourceListFile,
                                       (60 * 60), // Default subscription resubscribe interval.
                                       (40 * 60), // Default minimum subscription resubscribe interval.
                                       250,  // publishing delay? 
                                       20,   // The maximum number of reg subscriptions per resource.
                                       20,   // The maximum number of contacts per reg subscription.
                                       20,   // The maximum number of resource instances per contact
                                       20,    // The maximum number of dialogs per resource instance
                                       32, 3600, 86400, // Subscribe server expiration parameters
                                       subscriptionDbName,
                                       credentialDbName );

      pUacOutputProcessor = new OutputProcessorFixture();
      pUasOutputProcessor = new OutputProcessorFixture();
      
      pResourceServerUnderTest->mClientUserAgent.addSipOutputProcessor( pUacOutputProcessor );
      pResourceServerUnderTest->mServerUserAgent.addSipOutputProcessor( pUasOutputProcessor );

      UtlString proxyAddress;
      if(routeAllRequestsToRlsServer)
      {
         proxyAddress = "127.0.0.1:45140";
      }
      else
      {
         int pPort;
         pResourceServerUnderTest->mClientUserAgent.getLocalAddress(&proxyAddress, &pPort);
         proxyAddress.append(':');
         proxyAddress.appendNumber(pPort);
      }

      pSipUserAgent->setProxyServers(proxyAddress.data());

      pResourceServerUnderTest->start();
   }
Esempio n. 22
0
OsStatus
UpdateMessageStatesCGI::handleEmailRequest( UtlString* out )
{
   // Instantiate the mailbox manager
   UtlString redirectUrl, dynamicHtml ;
   MailboxManager* pMailboxManager = MailboxManager::getInstance();
   OsStatus result = pMailboxManager->getMediaserverURLForWeb( redirectUrl ) ;

   if( result == OS_SUCCESS )
   {
      // Strip of the "-dd.wav" from messageIds.
      UtlString messageId = m_messageIds( 0, m_messageIds.length()-7);

      result = pMailboxManager->updateMessageStates(
         m_mailboxIdentity, m_category, messageId);

      if (result == OS_SUCCESS)
      {
         // URL of the message WAV file
         Url url ( m_mailboxIdentity );
         UtlString userId;
         url.getUserId( userId );

         redirectUrl +=  UtlString( URL_SEPARATOR ) + MEDIASERVER_ROOT_ALIAS +
            URL_SEPARATOR + MAILBOX_DIR +
            URL_SEPARATOR + userId +
            URL_SEPARATOR + m_category +
            URL_SEPARATOR + m_messageIds ;

         // Script for playing the WAV file
         dynamicHtml  = HTML_BEGIN \
            EMBED_MEDIAPLAYER_PLUGIN \
            "<SCRIPT language=\"JavaScript\">\n" \
            "<!-- \n"
            "playMsgJs('" + redirectUrl + "'); \n" \
            "// -->\n" \
            "</SCRIPT>\n" \
            "<b class=\"statustext\">Message is now playing. Please make sure your PC speaker is turned on.</b>" \
            HTML_END ;
      }
      else if (result == OS_NOT_FOUND)
      {
         dynamicHtml =   HTML_BEGIN \
            "Message is not found in " + m_category + ", may have been saved or deleted." \
            HTML_END ;
      }
   }
   else
   {
      dynamicHtml =   HTML_BEGIN \
         PROTOCOL_MISMATCH \
         HTML_END ;
   }

   if (out)
   {
      out->remove(0);
      out->append(dynamicHtml.data());
   }
   return OS_SUCCESS;
}
Esempio n. 23
0
void SipDialogEvent::buildBody(int* version) const
{
   UtlString dialogEvent;
   UtlString singleLine;

   // Construct the xml document of dialog event
   dialogEvent = UtlString(XML_VERSION_1_0);

   // Dialog Information Structure
   dialogEvent.append(BEGIN_DIALOG_INFO);

   if (version)
   {
      // Generate the body with the recorded version.
      char buffer[20];
      sprintf(buffer, "%d", mVersion);
      dialogEvent.append(VERSION_EQUAL);
      singleLine = DOUBLE_QUOTE + UtlString(buffer) + DOUBLE_QUOTE;
      dialogEvent += singleLine;
      // Return the XML version.
      *version = mVersion;
   }
   else
   {
      // Generate the body with the substitution placeholder.
      dialogEvent.append(VERSION_EQUAL
                         DOUBLE_QUOTE VERSION_PLACEHOLDER DOUBLE_QUOTE);
   }

   dialogEvent.append(STATE_EQUAL);
   singleLine = DOUBLE_QUOTE + mDialogState + DOUBLE_QUOTE;
   dialogEvent += singleLine;

   dialogEvent.append(ENTITY_EQUAL);
   singleLine = DOUBLE_QUOTE;
   XmlEscape(singleLine, mEntity);
   singleLine += DOUBLE_QUOTE;
   dialogEvent += singleLine;
   dialogEvent.append(END_LINE);

   // Take the lock (we will be modifying the state even though 'this'
   // is read-only).
   (const_cast <SipDialogEvent*> (this))->mLock.acquire();

   // Dialog elements
   UtlSListIterator dialogIterator(mDialogs);
   Dialog* pDialog;
   while ((pDialog = (Dialog *) dialogIterator()))
   {
      UtlString b;
      ssize_t l;
      pDialog->getBytes(b, l);
      dialogEvent.append(b);
   }

   // End of dialog-info element
   dialogEvent.append(END_DIALOG_INFO);

   // Update body text (even though 'this' is read-only).
   (const_cast <SipDialogEvent*> (this))->mBody = dialogEvent;
   (const_cast <SipDialogEvent*> (this))->bodyLength = dialogEvent.length();
   // mVersion is not updated, as that is used only to record
   // the version of parsed events.

   (const_cast <SipDialogEvent*> (this))->mLock.release();

   Os::Logger::instance().log(FAC_SIP, PRI_DEBUG, "SipDialogEvent::buildBody Dialog content = \n%s",
                 mBody.data());
}
Esempio n. 24
0
   void instantiateAllTestFixtures( UtlString AppearanceGroupFile,
                                    //< Name of the appearance group file to use for the test.  The filename
                                    //< specified must exist in .../sipXrls/src/test/saadata/
                                    UtlString subscriptionDbName,
                                    //< Specifies the subscription DB to use for the test.  The name
                                    //< is used to select which of the files in .../sipXrls/src/test/saadata/
                                    //< will get used to preload the subscription IMDB.  The name provided here is the
                                    //< xml file in .../sipXrls/src/test/saadata/ without the ".xml" extension.
                                    UtlString credentialDbName,
                                    //< Specifies the credential DB to use for the test.  The name
                                    //< is used to select which of the files in .../sipXrls/src/test/saadata/
                                    //< will get used to preload the credential IMDB.  The name provided here is the
                                    //< xml file in .../sipXrls/src/test/saadata/ without the ".xml" extension.
                                    UtlString domainName
                                    //< Specify the domain name to use for the test
                                    )
   {
      mCredentialDbName = credentialDbName;
      // force copy of input files into the 'work' directory
      sipDbContext.inputFile( subscriptionDbName + ".xml" );
      sipDbContext.inputFile( credentialDbName + ".xml" );
      UtlString tempAppearanceGroupFile = UtlString(TEST_DATA_DIR) + "/" + AppearanceGroupFile;

      pSipUserAgent = new SipUserAgent( 45141, 45141, 45142
                                       ,"127.0.0.1"  // default publicAddress
                                       ,NULL         // default defaultUser
                                       ,"127.0.0.1" );  // default defaultSipAddress

      // Stop SipUserAgent from rejecting all SUBSCRIBEs
      pSipUserAgent->allowMethod(SIP_SUBSCRIBE_METHOD, true);

      SipXecsService* saaTestService = new SipXecsService("sipxsaaTest", "SIPX_SAA", "TestCase");

      pAppearanceAgentUnderTest = new AppearanceAgent(saaTestService,
                                       domainName, // domain
                                       "rlstest.test", // realm
                                       NULL,  // line manager
                                       45140, // TCP port
                                       45140, // UDP port
                                       45140, // TLS port
                                       "127.0.0.1", // Bind IP address
                                       &tempAppearanceGroupFile,
                                       (24 * 60 * 60), // Default subscription refresh interval
                                       (60 * 60), // Default subscription resubscribe interval.
                                       (40 * 60), // Default minimum subscription resubscribe interval.
                                       (20 * 60), // Default seized subscription resubscribe interval.
                                       250,  // publishing delay?
                                       20,   // The maximum number of reg subscriptions per group.
                                       32, 3600, 86400, // Subscribe server expiration parameters
                                       subscriptionDbName,
                                       credentialDbName );

      pUasOutputProcessor = new OutputProcessorFixture();

      pAppearanceAgentUnderTest->mServerUserAgent.addSipOutputProcessor( pUasOutputProcessor );

      UtlString proxyAddress;
      proxyAddress = "127.0.0.1:45140";

      pSipUserAgent->setProxyServers(proxyAddress.data());

      pAppearanceAgentUnderTest->start();
   }
Esempio n. 25
0
bool XmlRpcResponse::setFault(int faultCode, const char* faultString)
{
   bool result = true;
   mFaultCode = faultCode;
   mFaultString = faultString;

   // Start to construct the XML-RPC body for fault response
   assert(mpResponseBody == NULL);    // response body should only be created once

   mpResponseBody = new XmlRpcBody();
   assert(mpResponseBody != NULL);    // if not true, allocation failed
   
   // Fault response example
   //
   // <methodResponse>
   //   <fault>
   //     <value>
   //       <struct>
   //         <member>
   //           <name>faultCode</name>
   //           <value><int>4</int></value>
   //         </member>
   //         <member>
   //           <name>faultString</name>
   //           <value><string>Too many parameters.</string></value>
   //         </member>
   //       </struct>
   //     </value>
   //   </fault>
   // </methodResponse>

   mpResponseBody->append(BEGIN_RESPONSE);   
   mpResponseBody->append(BEGIN_FAULT);   
   mpResponseBody->append(BEGIN_STRUCT);
      
   mpResponseBody->append(BEGIN_MEMBER);   
   mpResponseBody->append(FAULT_CODE);
   
   char temp[10];
   sprintf(temp, "%d", mFaultCode);
   UtlString paramValue = BEGIN_INT + UtlString(temp) + END_INT;
   mpResponseBody->append(paramValue);
   
   mpResponseBody->append(END_MEMBER);   
   
   mpResponseBody->append(BEGIN_MEMBER);   
   mpResponseBody->append(FAULT_STRING);
   
   paramValue = BEGIN_STRING + mFaultString + END_STRING;
   mpResponseBody->append(paramValue);
   
   mpResponseBody->append(END_MEMBER);   
      
   mpResponseBody->append(END_STRUCT);   
   mpResponseBody->append(END_FAULT);   
   mpResponseBody->append(END_RESPONSE);
      
   UtlString bodyString;
   int bodyLength;
   mpResponseBody->getBytes(&bodyString, &bodyLength);
   OsSysLog::add(FAC_SIP, PRI_DEBUG,
                 "mpResponseBody::setFault XML-RPC response message = \n%s", bodyString.data());

   return result;
}
Esempio n. 26
0
// Constructor
ResourceListServer::ResourceListServer(const UtlString& domainName,
                                       const UtlString& realm,
                                       SipLineMgr* lineMgr,
                                       const char* eventType,
                                       const char* contentType,
                                       int tcpPort,
                                       int udpPort,
                                       int tlsPort,
                                       const UtlString& bindIp,
                                       UtlString* resourceListFile,
                                       int refreshInterval,
                                       int resubscribeInterval,
                                       int minResubscribeInterval,
                                       int publishingDelay,
                                       int maxRegSubscInResource,
                                       int maxContInRegSubsc,
                                       int maxResInstInCont,
                                       int maxDialogsInResInst,
                                       int serverMinExpiration,
                                       int serverDefaultExpiration,
                                       int serverMaxExpiration,
                                       const UtlString&  subscriptionDbName,
                                       const UtlString&  credentialDbName) :
   mDomainName(domainName),
   mEventType(eventType),
   mContentType(contentType),
   mResourceListFile(*resourceListFile),
   mRefreshInterval(refreshInterval),
   mResubscribeInterval(resubscribeInterval),
   mMinResubscribeInterval(minResubscribeInterval),
   mPublishingDelay(publishingDelay),
   mMaxRegSubscInResource(maxRegSubscInResource),
   mMaxContInRegSubsc(maxContInRegSubsc),
   mMaxResInstInCont(maxResInstInCont),
   mMaxDialogsInResInst(maxDialogsInResInst),
   mServerUserAgent(
      tcpPort, // sipTcpPort
      udpPort, // sipUdpPort
      tcpPort, // sipTlsPort
      NULL, // publicAddress
      NULL, // defaultUser
      bindIp, // defaultSipAddress
      NULL, // sipProxyServers
      NULL, // sipDirectoryServers
      NULL, // sipRegistryServers
      NULL, // authenticationScheme
      NULL, // authenicateRealm
      NULL, // authenticateDb
      NULL, // authorizeUserIds
      NULL, // authorizePasswords
      NULL, // lineMgr
      SIP_DEFAULT_RTT, // sipFirstResendTimeout
      TRUE, // defaultToUaTransactions
      -1, // readBufferSize
      OsServerTask::DEF_MAX_MSGS, // queueSize
      FALSE // bUseNextAvailablePort
      ),
   mClientUserAgent(
      PORT_DEFAULT, // sipTcpPort
      PORT_DEFAULT, // sipUdpPort
      PORT_DEFAULT, // sipTlsPort
      NULL, // publicAddress
      NULL, // defaultUser
      bindIp, // defaultSipAddress
      domainName.data(), // sipProxyServers
      NULL, // sipDirectoryServers
      NULL, // sipRegistryServers
      NULL, // authenticationScheme
      NULL, // authenicateRealm
      NULL, // authenticateDb
      NULL, // authorizeUserIds
      NULL, // authorizePasswords
      lineMgr, // lineMgr
      SIP_DEFAULT_RTT, // sipFirstResendTimeout
      TRUE, // defaultToUaTransactions
      -1, // readBufferSize
      OsServerTask::DEF_MAX_MSGS, // queueSize
      FALSE // bUseNextAvailablePort
      ),
   mSubscriptionMgr(SUBSCRIPTION_COMPONENT_RLS, mDomainName, subscriptionDbName),
   mPolicyHolder(domainName, realm, credentialDbName),
   mSubscribeServer(mServerUserAgent, mEventPublisher, mSubscriptionMgr,
                    mPolicyHolder),
   mRefreshMgr(mClientUserAgent, mDialogManager),
   mSubscribeClient(mClientUserAgent, mDialogManager, mRefreshMgr),
   mResourceListTask(this),
   mResourceListSet(this),
   // Do not set the resource list file name yet, so the ResourceListFileReader
   // doesn't add elements to the ResourceListSet before we have the
   // SIP tasks set up.
   mResourceListFileReader(UtlString(""), &mResourceListSet)
{
   OsSysLog::add(FAC_RLS, PRI_DEBUG,
                 "ResourceListServer::_ this = %p, mDomainName = '%s', mEventType = '%s', mContentType = '%s', "
                 "mRefreshInterval = %d, mResubscribeInterval = %d",
                 this, mDomainName.data(), mEventType.data(), mContentType.data(), mRefreshInterval,
                 mResubscribeInterval);
   OsSysLog::add(FAC_RLS, PRI_DEBUG,
                 "ResourceListServer::_ this = %p, mPublishingDelay = %d, mMaxRegSubscInResource = %d, "
                 "mMaxContInRegSubsc = %d, mMaxResInstInCont = %d, mMaxDialogsInResInst = %d",
                 this, publishingDelay, mMaxRegSubscInResource, mMaxContInRegSubsc, mMaxResInstInCont,
                 mMaxDialogsInResInst);

   // Initialize the call processing objects.

   // Construct addresses:
   // our local host-part
   // contact address to be used in client outgoing requests (primarily SUBSCRIBEs)
   {
      // Get our address and the client port.
      UtlString localAddress;
      int localPort;
      mClientUserAgent.getLocalAddress(&localAddress, &localPort);

      char buffer[100];

      // Construct the server's host-part.
      sprintf(buffer, "%s:%d", localAddress.data(), portIsValid(udpPort) ? udpPort : tcpPort);
      mServerLocalHostPart = buffer;

      // Construct the client's From URI.
      sprintf(buffer, "sip:sipXrls@%s:%d", localAddress.data(), localPort);
      mClientFromURI = buffer;

      // Obtain the client's Contact URI.
      mClientUserAgent.getContactURI(mClientContactURI);
   }

   // Initialize the SipUserAgent's.
   // Set the user-agent strings.
   mServerUserAgent.setUserAgentHeaderProperty("sipXecs/rls");
   mClientUserAgent.setUserAgentHeaderProperty("sipXecs/rls");

   // Require the "eventlist" extension in the Resource List clients.
   mServerUserAgent.requireExtension(SIP_EVENTLIST_EXTENSION);

   // Set the subscribe server grant times.
   if (!mSubscriptionMgr.setSubscriptionTimes(serverMinExpiration,
                                              serverDefaultExpiration,
                                              serverMaxExpiration))
   {
      OsSysLog::add(FAC_RLS, PRI_ERR,
                    "ResourceListServer given unacceptable server subscription times: min = %d, default = %d, max = %d.  Using the default subscription times.",
                    serverMinExpiration,
                    serverDefaultExpiration,
                    serverMaxExpiration);
   }
}
OsStatus
ManageNotificationsWebCGI::addEditDeleteNotification(UtlString* out) const
{
    OsStatus result = OS_SUCCESS ;

    // For add and edit, first validate the contact address.
    if( m_action == "addnotification" || m_action == "editnotification" )
        result = validateContactAddress() ;

    if( result == OS_SUCCESS )
    {
        MailboxManager* pMailboxManager = MailboxManager::getInstance();
        result = pMailboxManager->
                            addEditDeleteNotification(   m_mailboxIdentity,
                                                         m_action,
                                                         m_contactAddress,
                                                         m_newContactAddress,
                                                         m_newContactType,
                                                         m_sendAttachments);
    }

    // URL of the result webpage
    UtlString redirectUrl =  m_cgiUrl + "?fromweb=yes&status=";
    if( result == OS_SUCCESS )
    {
        UtlString status ;
        if( m_action == "addnotification" )
            status = ADD_NOTIFICATION_SUCCESS ;
        else if( m_action == "editnotification" )
            status = EDIT_NOTIFICATION_SUCCESS ;
        else if( m_action == "deletenotification" )
            status = DELETE_NOTIFICATION_SUCCESS ;

                redirectUrl +=  status + "&action=managenotifications" ;

    }
    else if( result == OS_NAME_IN_USE )
    {
        redirectUrl +=  UtlString( NOTIFICATION_DUPLICATE_FOUND ) ;
        if( m_action == "addnotification" )
                    redirectUrl +=  "&action=getaddnotificationui" ;
        else if( m_action == "editnotification" )
            redirectUrl +=  "&action=geteditnotificationui" ;
    }
    else if( result == OS_INVALID )
    {
        redirectUrl +=  UtlString( INVALID_NOTIFICATION_ADDRESS ) ;
        if( m_action == "addnotification" )
                    redirectUrl +=  "&action=getaddnotificationui" ;
        else if( m_action == "editnotification" )
            redirectUrl +=  "&action=geteditnotificationui" ;

    }
    else
    {
        if( m_action == "addnotification" )
                    redirectUrl +=  UtlString( ADD_NOTIFICATION_FAILED ) + "&action=getaddnotificationui" ;
        else if( m_action == "editnotification" )
            redirectUrl +=  UtlString( EDIT_NOTIFICATION_FAILED ) + "&action=geteditnotificationui" ;
        else if( m_action == "deletenotification" )
            redirectUrl +=  UtlString( DELETE_NOTIFICATION_FAILED ) + "&action=managenotifications" ;
    }

    redirectUrl +=  "&contact=" + m_contactAddress +
                    "&type=" + m_contactType +
                    "&newcontact=" + m_newContactAddress +
                    "&newtype=" + m_newContactType +
                    "&attachments=" + m_sendAttachments;

    // Script for redirecting to the webpage displaying folder contents
        UtlString dynamicHtml  =        HTML_BEGIN \
                            REDIRECT_SCRIPT_BEGIN + redirectUrl + REDIRECT_SCRIPT_END \
                            HTML_END ;

        if (out)
        {
                out->remove(0);
                out->append(dynamicHtml.data());
        }

    return OS_SUCCESS ;
}
Esempio n. 28
0
/* //////////////////////////// PROTECTED ///////////////////////////////// */
void Connection::postTaoListenerMessage(int state, int newCause, int isLocal)
{
    int eventId = PtEvent::EVENT_INVALID;
    int termEventId = PtEvent::EVENT_INVALID;
    UtlString causeStr;
    causeStr.remove(0);

#ifdef TEST_PRINT
    Os::Logger::instance().log(FAC_CP, PRI_DEBUG, "Connection::postTaoListenerMessage: "
                  "Enter- %s state %d cause %d "
                  "eventid-  %d termeventid %d",
                  (isLocal?"LOCAL":"REMOTE"),
                  state, newCause,
                  eventId, termEventId);
#endif

    switch(state)
    {
    case CONNECTION_IDLE:
        eventId = PtEvent::CONNECTION_CREATED;
        termEventId = PtEvent::TERMINAL_CONNECTION_IDLE;
        break;

    case CONNECTION_INITIATED:
        eventId = PtEvent::CONNECTION_INITIATED;
        termEventId = PtEvent::TERMINAL_CONNECTION_CREATED;
        break;

    case CONNECTION_QUEUED:
        eventId = PtEvent::CONNECTION_QUEUED;
        termEventId = PtEvent::CONNECTION_CREATED;
        break;

    case CONNECTION_OFFERING:
        eventId = PtEvent::CONNECTION_OFFERED;
        break;

    case CONNECTION_DIALING:
        eventId = PtEvent::CONNECTION_DIALING ;
        break;

    case CONNECTION_ALERTING:
        eventId = PtEvent::CONNECTION_ALERTING;
        termEventId = PtEvent::TERMINAL_CONNECTION_RINGING;
        break;

    case CONNECTION_ESTABLISHED:
        eventId = PtEvent::CONNECTION_ESTABLISHED;
        termEventId = PtEvent::TERMINAL_CONNECTION_TALKING;
        break;

    case CONNECTION_FAILED:
        eventId = PtEvent::CONNECTION_FAILED;
        termEventId = PtEvent::TERMINAL_CONNECTION_DROPPED;
        break;

    case CONNECTION_DISCONNECTED:
        eventId = PtEvent::CONNECTION_DISCONNECTED;
        termEventId = PtEvent::TERMINAL_CONNECTION_DROPPED;
        break;

    case PtEvent::TERMINAL_CONNECTION_HELD:
        termEventId = PtEvent::TERMINAL_CONNECTION_HELD;
        break;

    default:
        eventId = PtEvent::CONNECTION_UNKNOWN;
        termEventId = PtEvent::TERMINAL_CONNECTION_UNKNOWN;
        break;

    }

    int cause;
    switch(newCause)
    {
     case CONNECTION_CAUSE_UNKNOWN:
        cause = PtEvent::CAUSE_UNKNOWN;
        causeStr.append("CAUSE_UNKNOWN");
        break;
    case CONNECTION_CAUSE_REDIRECTED:
        cause = PtEvent::CAUSE_REDIRECTED;
        causeStr.append("CAUSE_REDIRECTED");
        break ;

     case CONNECTION_CAUSE_NETWORK_CONGESTION:
        cause = PtEvent::CAUSE_NETWORK_CONGESTION;
        causeStr.append("CAUSE_NETWORK_CONGESTION");
        break;

     case CONNECTION_CAUSE_NETWORK_NOT_OBTAINABLE:
        cause = PtEvent::CAUSE_NETWORK_NOT_OBTAINABLE;
        causeStr.append("CAUSE_NETWORK_NOT_OBTAINABLE");
        break;

     case CONNECTION_CAUSE_DEST_NOT_OBTAINABLE:
        cause = PtEvent::CAUSE_DESTINATION_NOT_OBTAINABLE;
        causeStr.append("CAUSE_DESTINATION_NOT_OBTAINABLE");
        break;

     case CONNECTION_CAUSE_INCOMPATIBLE_DESTINATION:
        cause = PtEvent::CAUSE_INCOMPATIBLE_DESTINATION;
        causeStr.append("CAUSE_INCOMPATIBLE_DESTINATION");
        break;

     case CONNECTION_CAUSE_NOT_ALLOWED:
        cause = PtEvent::CAUSE_NOT_ALLOWED;
        causeStr.append("CAUSE_NOT_ALLOWED");
        break;

     case CONNECTION_CAUSE_NETWORK_NOT_ALLOWED:
        cause = PtEvent::CAUSE_NETWORK_NOT_ALLOWED;
        causeStr.append("CAUSE_NETWORK_NOT_ALLOWED");
        break;

    case CONNECTION_CAUSE_BUSY:
    case CONNECTION_CAUSE_SERVICE_UNAVAILABLE:
        cause = PtEvent::CAUSE_BUSY;
        causeStr.append("CAUSE_BUSY");
        break ;

    case CONNECTION_CAUSE_CANCELLED:
        cause = PtEvent::CAUSE_CALL_CANCELLED;
        causeStr.append("CAUSE_CALL_CANCELLED");
        break ;

    case CONNECTION_CAUSE_TRANSFER:
        cause = PtEvent::CAUSE_TRANSFER;
        causeStr.append("CAUSE_TRANSFER");
        break;

    default:
    case CONNECTION_CAUSE_NORMAL:
        cause = PtEvent::CAUSE_NORMAL;
        causeStr.append("CAUSE_NORMAL");
        break;
    }

    int cnt = 0;
    if (mpListenerCnt)
        cnt = mpListenerCnt->getRef();

    if (cnt > 0)
    {
        TaoObjHandle* pListeners;
        pListeners = new TaoObjHandle[cnt];
        mpListeners->getActiveObjects(pListeners, cnt);

        UtlString callId;

        // Use the connection call id first -- followed by call if
        // unavailable
        getCallId(&callId);                          // arg[0], callId
        if (callId.isNull())
        {
            mpCall->getCallId(callId);
#ifdef TEST_PRINT
            Os::Logger::instance().log(FAC_CP, PRI_DEBUG, "Connection::postTaoListenerMessage: "
                          "Connection call id not found, "
                          "Using CpCall Id = %s ",
                          callId.data());
#endif
        }

        callId += TAOMESSAGE_DELIMITER + mLocalAddress;        // arg[1], localAddress

        UtlString remoteAddress;
        getRemoteAddress(&remoteAddress, TRUE);

        if (remoteAddress.isNull())                            // arg[2], remote address
        {
            callId += TAOMESSAGE_DELIMITER + (UtlString)"UNKNOWN";    // not available yet
        }
        else
        {
            callId += TAOMESSAGE_DELIMITER + remoteAddress;
        }

        char buff[128];
        sprintf(buff, "%d", (int)mRemoteIsCallee);
        callId += TAOMESSAGE_DELIMITER + UtlString(buff);    // arg[3], remoteIsCallee

        sprintf(buff, "%d", cause);
        callId += TAOMESSAGE_DELIMITER + UtlString(buff);    // arg[4], cause

        if (mRemoteIsCallee)
        {
            remoteAddress.insert(0, "foreign-terminal-");
            callId += TAOMESSAGE_DELIMITER + remoteAddress;    // arg[5], remote terminal name
        }
        else
        {
            mpCall->getLocalTerminalId(buff, 127);
            callId += TAOMESSAGE_DELIMITER + UtlString(buff);    // arg[5], local terminal name
        }

        if (isLocal)                                        // TAO_OFFER_PARAM_LOCAL_CONNECTION
        {
            callId += TAOMESSAGE_DELIMITER + "1";            // arg[6], isLocal
        }
        else
        {
            callId += TAOMESSAGE_DELIMITER + "0";            // isLocal
        }

        sprintf(buff, "%d", mResponseCode);
        callId += TAOMESSAGE_DELIMITER + UtlString(buff);    // arg[7], SIP response code

        callId += TAOMESSAGE_DELIMITER + mResponseText;        // arg[8], SIP response text

        int argCnt = 9;
        if(mpCall)
        {
            int metaEventId = 0;
            int metaEventType = PtEvent::META_EVENT_NONE;
            int numCalls = 0;
            const UtlString* metaEventCallIds = NULL;
            mpCall->getMetaEvent(metaEventId, metaEventType, numCalls,
                &metaEventCallIds);
            if (metaEventId != PtEvent::META_EVENT_NONE)
            {
                sprintf(buff, "%d", metaEventId);
                callId += TAOMESSAGE_DELIMITER + UtlString(buff);    // arg[9], meta event id
                sprintf(buff, "%d", metaEventType);
                callId += TAOMESSAGE_DELIMITER + UtlString(buff);    // arg[10], meta code
                argCnt += 2;
                for (int i = 0; i < numCalls; i++)
                {
                    if (metaEventCallIds && metaEventCallIds[i])
                    {
                        callId += TAOMESSAGE_DELIMITER + metaEventCallIds[i];    // meta call ids
                        argCnt++;
                    }
                }
            }
        }

        TaoMessage msg(TaoMessage::EVENT,
                       0,
                       0,
                       eventId,
                       0,
                       argCnt,
                       callId);

        UtlString eventIdStr;
        if (eventId != PtEvent::EVENT_INVALID)
        {
            for (int i = 0; i < cnt; i++) // post connection events
            {
                ((OsServerTask*) pListeners[i])->postMessage((OsMsg&)msg);
            }
            mpCall->getStateString(eventId, &eventIdStr);
            mpCallManager->logCallState(callId.data(), eventIdStr.data(), causeStr);
        }

        if (termEventId != PtEvent::EVENT_INVALID)    // post terminal connection events
        {
            msg.setObjHandle(termEventId);
            for (int i = 0; i < cnt; i++)
            {
                ((OsServerTask*) pListeners[i])->postMessage((OsMsg&)msg);
            }

            mpCall->getStateString(termEventId, &eventIdStr);
            mpCallManager->logCallState(callId.data(), eventIdStr.data(), causeStr);

        }

        delete[] pListeners;
        callId.remove(0);
        eventIdStr.remove(0);
        remoteAddress.remove(0);
    }
#ifdef TEST_PRINT
    Os::Logger::instance().log(FAC_CP, PRI_DEBUG, "Connection::postTaoListenerMessage: "
                  "Leave- %s state %d cause %d "
                  "eventid-  %d termeventid %d",
                  (isLocal?"LOCAL":"REMOTE"),
                  state, newCause,
                  eventId, termEventId);
#endif

    causeStr.remove(0);
}
Esempio n. 29
0
void PsTaoButton::getInfo(UtlString& rInfo)
{
        rInfo = UtlString(mButtonInfo);
}
Esempio n. 30
0
OsStatus
NotificationHelper::send (
    const UtlString& rMailboxIdentity,
    const UtlString& rSMTPServer,
    const Url&      mailboxServiceUrl,
    const UtlString& rContact,
    const UtlString& rFrom,
    const UtlString& rReplyTo,
    const UtlString& rDate,
    const UtlString& rDurationMSecs,
    const UtlString& wavFileName,
    const char*     pAudioData,
    const int&      rAudioDatasize,
    const UtlBoolean& rAttachmentEnabled) const
{
    OsStatus status = OS_SUCCESS;

    // For forwarded messages, duration = aggregate of duration of different
    // messages that make up the forwarded message.
    // Skip duration for forwarded messages in this release (1.1).
    UtlString durationText = "" ;
    if( !wavFileName.contains("-FW") )
    {
        durationText += "Duration " ;
        int iDuration = atoi(rDurationMSecs);
        if( iDuration > 0 )
        {
                        // Convert to seconds
                        iDuration = iDuration / 1000;

                        char temp[10];
                        if( iDuration >= 3600 )
                        {
                                // Retrieve the hour.
                                int hours = iDuration / 3600  ;
                                iDuration = iDuration - (hours * 3600);
                                sprintf( temp, "%02d", hours );
                                durationText = UtlString( temp ) + ":" ;
                        }

                        if( iDuration >= 60 )
                        {
                                // Retrieve the hour.
                                int mins = iDuration / 60  ;
                                iDuration = iDuration - (mins * 60);
                                sprintf( temp, "%02d", mins );

                                durationText += UtlString( temp ) + ":" ;
                        }
                        else
                        {
                                durationText += "00:" ;
                        }

                        // append the seconds
                        sprintf( temp, "%02d", iDuration );
                        durationText += temp;
        }
        else
        {
            durationText = UtlString("00:00") ;
        }
    }

    UtlString strFrom = "Unknown" ;
    if( !rFrom.isNull() && rFrom.length() > 0)
        strFrom = rFrom ;
    UtlString subject = "New Voicemail from " + strFrom ;

    UtlString rawMessageId = wavFileName(0, wavFileName.first('-'));
    UtlString userId = rMailboxIdentity(0, rMailboxIdentity.first('@'));

    UtlString plainBodyText, htmlBodyText;

    MailMessage message ( "Voicemail Notification Service", rReplyTo, rSMTPServer );

    UtlString baseMailboxLink = mailboxServiceUrl.toString();
    baseMailboxLink.append("/").append(userId).append("/inbox");

    UtlString playMessageLink = baseMailboxLink;
    playMessageLink.append("/").append(rawMessageId);
    UtlString deleteMessageLink = baseMailboxLink;
    deleteMessageLink.append("/").append(rawMessageId).append("/delete");
    UtlString showMailboxLink = baseMailboxLink;

    plainBodyText += "On " + rDate + ", " + strFrom + " left new voicemail. " +
        durationText + "\n";
    plainBodyText += "Listen to message " + playMessageLink + "\n";
    plainBodyText += "Show Voicemail Inbox "   + showMailboxLink + "\n";
    plainBodyText += "Delete message " + deleteMessageLink + "\n";

    UtlString playMessageLinkXml ;
    UtlString deleteMessageLinkXml;
    UtlString showMailboxLinkXml;
    XmlEscape(playMessageLinkXml, playMessageLink) ;
    XmlEscape(deleteMessageLinkXml, deleteMessageLink) ;
    XmlEscape(showMailboxLinkXml, showMailboxLink) ;
    // Format the html text if supported by the browser
    htmlBodyText =
        (UtlString)"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\n" +
                  "   \"http://www.w3.org/TR/html4/strict.dtd\">\n" +
                  "<HTML>\n" +
                  "<HEAD>\n" +
                  "<TITLE>Voicemail Notification</TITLE>\n" +
                  "</HEAD>\n<BODY>\n";
    htmlBodyText +=
        "<p>On " + rDate + ", " + strFrom + " left new voicemail. " +
        durationText + "</p>\n";
    htmlBodyText +=
        "<p><a href=\"" + playMessageLinkXml + "\">Listen to message</a></p>\n";
    htmlBodyText +=
        "<p><a href=\"" + showMailboxLinkXml + "\">Show Voicemail Inbox</a></p>\n";
    htmlBodyText +=
        "<p><a href=\"" + deleteMessageLinkXml + "\">Delete message</a></p>\n";
    htmlBodyText +=
        (UtlString)"</BODY>\n" +
                                  "</HTML>\n";

    if ( rAttachmentEnabled == TRUE )
    {
        unsigned char* unsignedAudioData = (unsigned char*) pAudioData;
        message.Attach( unsignedAudioData, rAudioDatasize, wavFileName);
    }

    message.Body( plainBodyText , htmlBodyText );
    message.Subject( subject );
    message.To( rContact, rContact );
    UtlString response = message.Send();
    if ( !response.isNull() )
    {
        if( response.length() > 0 )
        {
            OsSysLog::add(FAC_MEDIASERVER_CGI, PRI_ERR,
                          "NotificationHelper: "
                          "Error sending e-mail to '%s' via SMTP server '%s'\n    %s",
                          rContact.data(), rSMTPServer.data(), response.data());
            OsSysLog::flush();
        }
    }
    return status;
}