コード例 #1
0
ファイル: OsConfigDb.cpp プロジェクト: John-Chan/sipXtapi
void OsConfigDb::removeNewlineReturns(UtlString& stringData)
{
    //remove any  \n or \r at the ends of the lines
    size_t remove_char_loc = 0;
    while (remove_char_loc != UTL_NOT_FOUND)
    {
        remove_char_loc = stringData.first('\r');
        if (remove_char_loc != UTL_NOT_FOUND)
        {
            stringData.remove(remove_char_loc,1);
        }
    }

    remove_char_loc = 0;
    while (remove_char_loc != UTL_NOT_FOUND)
    {
        remove_char_loc = stringData.first('\n');
        if (remove_char_loc != UTL_NOT_FOUND)
        {
            stringData.remove(remove_char_loc,1);
        }
    }
}
コード例 #2
0
OsStatus
ValidateMailboxCGIHelper::getUserId( const UtlString& mailboxIdentity,
                                     UtlString& rUserId ) const
{
    // Strip off the domain part from the identity
    if( mailboxIdentity.first( '@' ) == UTL_NOT_FOUND )
    {
        rUserId = mailboxIdentity ;
    }
    else
    {
        // Construct the Url object and get the userid.
        Url url( mailboxIdentity );
        url.getUserId( rUserId ) ;
    }

    return OS_SUCCESS ;
}
コード例 #3
0
UtlBoolean TestRegistrar::handleRegisterRequest(SipMessage message)
{
    UtlBoolean messageProcessed = false;
    SipMessage finalResponse;
    UtlString responseToAddress;
    UtlString protocol;
    int responseToPort;
    int seqNum;
    UtlString method;
    UtlString contactField;
    int expires;
    static int retrySeqNum = 0;
    UtlString callId;

    message.getCallIdField(&callId);

    message.getContactField(0, contactField);
    message.getExpiresField(&expires);

    message.getCSeqField(&seqNum, &method);
    message.getFromAddress(&responseToAddress, &responseToPort, &protocol);

    finalResponse.setContactField(contactField);
    finalResponse.setExpiresField(expires);
    finalResponse.setFromField("sip:127.0.0.1:5070", 5070);
    finalResponse.setSendAddress(contactField, responseToPort);
    finalResponse.setToField(contactField, responseToPort, protocol);
    finalResponse.setUserAgentField("TestRegistrar");
//    finalResponse.setRegisterData(responseToAddress, contactField, "127.0.0.1", contactField, callId, seqNum);

    if (contactField.contains("anon"))      // anonymous user doesnt need authentication, just say ok
    {
        finalResponse.setResponseData(&message, 200, "OK");
    }
    else if (contactField.contains("mike"))  // mike requires registration, say 401
    {
        UtlString realm;

        UtlString requestUser;
        UtlString requestRealm;
        UtlString requestNonce;
        UtlString uriParam;

        // TBD - 25-jan-2010 work might be needed if these tests are re-enabled
        message.getDigestAuthorizationData(
                   &requestUser, &requestRealm, &requestNonce,
                   NULL, NULL, &uriParam,
                   NULL,  // TBD cnonce
                   NULL,  // TBD nonceCount
                   NULL,  // TBD qop
                   HttpMessage::SERVER, 0);

        if (seqNum == retrySeqNum) // if this is a retry response
        {
            // if they've sent any auth field, just accept it.
            // TODO:  figure out if a username and password has been encrypted and sent.
            finalResponse.setCSeqField(++seqNum, SIP_REGISTER_METHOD);
            finalResponse.setResponseData(&message, 200, "OK");
        }
        else
        {
            message.getCSeqField(&seqNum, &method);
            finalResponse.setCSeqField(++seqNum, method);
            retrySeqNum = seqNum;
#ifdef _WIN32
            finalResponse.setAuthenticateData("md5", "TestRegistrar", NULL, NULL, NULL, HttpMessage::HttpEndpointEnum::SERVER );
#else
            finalResponse.setAuthenticateData("md5", "TestRegistrar", NULL, NULL, NULL, HttpMessage::SERVER );
#endif
            finalResponse.setResponseData(&message, 401, "Not authorized");
        }
    }
    else if (contactField.contains("xyzzy"))
    {
        // this is our special username that will cause a response
        // to be echoed back with the 3 digit value after xyzzy.
        // for instance, the contact xyzzy401 will cause a 401 response
        int pos = contactField.first("xyzzy");
        char szCode[4];
        szCode[0] = contactField[pos + 5];
        szCode[1] = contactField[pos + 6];
        szCode[2] = contactField[pos + 7];
        szCode[3] = '\0';

        finalResponse.setResponseData(&message, atoi(szCode), "OK");
    }


    mpUserAgent->send(finalResponse);

    return messageProcessed;
}
コード例 #4
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;
}
コード例 #5
0
void sipXAudioSettingsDlg::OnOk(wxCommandEvent &event)
{
    wxString x;
    wxCheckBox* pCheck;
    wxChoice* pChoice;
    int pos;
    bool b;

    pCheck = (wxCheckBox*)sipXAudioSettingsDlg::FindWindowById(ID_ENABLE_OUT_DTMF, this);
    b = pCheck->GetValue();
    sipXmgr::getInstance().enableOutOfBandDTMF(b);
    sipXezPhoneSettings::getInstance().setEnableOOBDTMF(b);

    pCheck = (wxCheckBox*)sipXAudioSettingsDlg::FindWindowById(ID_ENABLE_AEC, this);
    b = pCheck->GetValue();
    sipXmgr::getInstance().enableAEC(b);
    sipXezPhoneSettings::getInstance().setEnableAEC(b);

    pCheck = (wxCheckBox*)sipXAudioSettingsDlg::FindWindowById(ID_ENABLE_SRTP, this);
    b = pCheck->GetValue();
    sipXmgr::getInstance().enableSRTP(b);
    sipXezPhoneSettings::getInstance().setEnableSRTP(b);

    pChoice = (wxChoice*)sipXAudioSettingsDlg::FindWindowById(ID_BANDWIDTH_CHOICE, this);
    pos = pChoice->GetSelection();

    sipXmgr::getInstance().setCodecPreferences(pos+1);

    // loop through the list box and save each as a selected codec
    int count = codecListControl->GetCount();
    wxString codecName;
    UtlString codecList ;
    UtlString cleanCodecList ;
    for (int i = 0; i < count; i++)
    {
        if (codecListControl->Selected(i))
        {
            codecName = codecListControl->GetString(i);
            codecList.append(codecName) ;
            codecList.append(" " ) ;

            UtlString temp = codecName.c_str() ;
            int index = temp.first(' ') ;
            if (index > 0)
            {
                temp.remove(index) ;
            }

            cleanCodecList.append(temp) ;
            cleanCodecList.append(" ") ;
        }
    }

    sipXmgr::getInstance().setAudioCodecByName((const char *)codecList.data());

    sipXezPhoneSettings::getInstance().setSelectedAudioCodecs(cleanCodecList.data()) ;
    sipXezPhoneSettings::getInstance().setCodecPref(pos+1);
    sipXezPhoneSettings::getInstance().saveSettings();

    event.Skip();
}
コード例 #6
0
ファイル: DepositCGI.cpp プロジェクト: mranga/sipxecs
OsStatus
DepositCGI::execute(UtlString* out)
{
   // Contains the dynamically generated VXML script.
   UtlString dynamicVxml = getVXMLHeader() + "<form> ";

   // Get the base URL of the mediaserver - "http://*****:*****@' ) != UTL_NOT_FOUND )
            {
               useridOrExtension =
                  useridOrExtension(0, useridOrExtension.first( '@' ));
            }
         }
         useridOrExtension.toLower();
         dynamicVxml +=
            "<var name=\"msgurl\" expr=\"'" + useridOrExtension + "'\" />\n" \
            "<var name=\"msgurltype\" expr=\"'alphanumeric'\"/>\n";
      }

      // If mailboxpath/savemessage.vxml exists, use it, otherwise use the 
      // generic version
      UtlString src ;
      UtlString vxmlScript ;
      pMailboxManager->getMailboxPath(m_mailboxIdentity, vxmlScript);
      vxmlScript += OsPath::separator + "savemessage.vxml" ;
      if (OsFileSystem::exists(vxmlScript))
      {
         // use the user specific one 
         pMailboxManager->getMailboxURL(m_mailboxIdentity, src, false);
         src += "/savemessage.vxml" ;
         OsSysLog::add(FAC_MEDIASERVER_CGI, PRI_DEBUG,
                 "DepositCGI::execute: using user specific vxml script %s",
                 src.data()) ;
      }
      else
      {
         // use the generic one
         src =  mediaserverUrl + "/vm_vxml/savemessage.vxml" ;
         OsSysLog::add(FAC_MEDIASERVER_CGI, PRI_DEBUG,
                 "DepositCGI::execute: using generic vxml script %s",
                 src.data()) ;
      }

      // Be careful here as the the vxmlFriendlyFrom will be sent back to us again
      UtlString vxmlFriendlyFrom = m_from.toString();
      MailboxManager::convertUrlStringToXML( vxmlFriendlyFrom );
      // HttpMessage::escape( vxmlFriendlyFrom );

      dynamicVxml +=
         "<subdialog name=\"send_msg\" src=\"" + src + "\">\n" +
         "<param name=\"called_by\" value=\"incoming\"/>\n" \
         "<param name=\"mailbox\" value=\"" + m_mailboxIdentity + "\"/>\n" \
         "<param name=\"from\" value=\"" + vxmlFriendlyFrom + "\"/>\n" \
         "<param name=\"msgurl\" expr=\"msgurl\" />\n" \
         "<param name=\"msgurltype\" expr=\"msgurltype\" />\n" \
         "<param name=\"mediaserverurl\" expr=\"'" + ivrPromptUrl + "'\"/>\n" \
         "<param name=\"securemediaserverurl\" expr=\"'" + secureMediaserverUrl + "'\"/>\n" \
         "</subdialog>";
   } else
   {
      dynamicVxml +=    "<subdialog src=\"" + mediaserverUrl + "/vm_vxml/error_handler.vxml\" >\n" \
         "<param name=\"errortype\" expr=\"'invalidextn'\" />\n" \
         "<param name=\"mediaserverurl\" expr=\"'" + ivrPromptUrl + "'\" />\n" \
         "<param name=\"securemediaserverurl\" expr=\"'" + secureMediaserverUrl + "'\"/>\n" \
         "</subdialog>\n";
   }

   dynamicVxml += "</form>" + UtlString( VXML_END );

   // Write out the dynamic VXML script to be processed by OpenVXI
   if (out)
   {
      out->remove(0);
      UtlString responseHeaders;
      MailboxManager::getResponseHeaders(dynamicVxml.length(), responseHeaders);

      out->append(responseHeaders.data());
      out->append(dynamicVxml.data());
   }

   return OS_SUCCESS;
}