Example #1
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 ;
}
OsStatus
UpdateMessageStatesCGI::handleOpenVXIRequest( UtlString* out )
{
    // Instantiate the mailbox manager
    MailboxManager* pMailboxManager = MailboxManager::getInstance();
        OsStatus result = pMailboxManager->updateMessageStates(m_mailboxIdentity, m_category, m_messageIds);

        UtlString dynamicVxml = getVXMLHeader();

        if( result == OS_SUCCESS )
        {
                dynamicVxml += VXML_SUCCESS_SNIPPET;
        }
        else
        {
                dynamicVxml += VXML_FAILURE_SNIPPET;
        }

        dynamicVxml += 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;
}
OsStatus
ManageNotificationsWebCGI::execute(UtlString* out)
{

        // Validate the mailbox id and extension.
    ValidateMailboxCGIHelper validateMailboxHelper ( m_mailboxIdentity );
    OsStatus result = validateMailboxHelper.execute( out );
    if ( result == OS_SUCCESS )
    {
        // Get the base URL for the Mediaserver
        MailboxManager* pMailboxManager = MailboxManager::getInstance();
        result = pMailboxManager->getMediaserverURLForWeb( m_cgiUrl ) ;
        if( result == OS_SUCCESS )
        {
            // Construct the base URL for the CGI
            m_cgiUrl += CGI_URL ;

            // Get the actual mailbox identity.
            validateMailboxHelper.getMailboxIdentity( m_mailboxIdentity );

            // Call appropriate methods based on the action parameter
            if( m_action == "managenotifications" )
            {
                result = getManageNotificationsUI(out) ;
            }
            else if( m_action == "geteditnotificationui" ||
                     m_action == "getaddnotificationui" )
            {
                result = getAddEditNotificationsUI(out);
            }
            else if(m_action == "addnotification" ||
                    m_action == "editnotification" ||
                    m_action == "deletenotification" )
            {
                result = addEditDeleteNotification( out );
            }
            else
            {
                result = OS_FAILED ;
            }
        }
        else
        {
            UtlString dynamicHtml =  HTML_BEGIN \
                                    PROTOCOL_MISMATCH \
                                    HTML_END ;
            if( out )
            {
                out->remove(0);
                out->append( dynamicHtml.data() );
            }

            result = OS_SUCCESS ;
        }

    }

    return result ;
}
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;
}
OsStatus
UpdateMessageStatesCGI::handleWebRequest( UtlString* out )
{
    // Instantiate the mailbox manager
    UtlString redirectUrl, dynamicHtml ;
    MailboxManager* pMailboxManager = MailboxManager::getInstance();
    OsStatus result = pMailboxManager->getMediaserverURLForWeb( redirectUrl ) ;

    if( result == OS_SUCCESS )
    {
       // We have revised the links that invoke this CGI pathway
       // so that the messageId parameter is now just the eight-digit
       // message ID.
       UtlString messageId = m_messageIds;

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

       // URL of the message WAV file
       Url url ( m_mailboxIdentity );
       UtlString userId;
       url.getUserId( userId );

       // Null HTML file.
       dynamicHtml  =   HTML_BEGIN \
          HTML_END ;
    }
    else
    {
        dynamicHtml =   HTML_BEGIN \
                        PROTOCOL_MISMATCH \
                        HTML_END ;
    }

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

    OsSysLog::add(FAC_MEDIASERVER_CGI, PRI_DEBUG,
                  "UpdateMessageStatesCGI::handleWebRequest: out = '%s'",
                  out->data());
    return OS_SUCCESS;
}
OsStatus
SaveSystemPromptsCGI::execute(UtlString* out)
{
    OsStatus result = OS_SUCCESS;
    MailboxManager* pMailboxManager =
        MailboxManager::getInstance();

    // Forward call to Mailbox Manager
    result = pMailboxManager->saveSystemPrompts(
                m_promptType, m_data, m_datasize );

        UtlString dynamicVxml = getVXMLHeader();

        if( result == OS_SUCCESS )
        {
                dynamicVxml += VXML_SUCCESS_SNIPPET;
        }
        else
        {
                dynamicVxml += VXML_FAILURE_SNIPPET;
        }

        dynamicVxml += 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;
}
Example #7
0
OsStatus
LoginCGI::handleOpenVXIRequest( UtlString* out )
{
    OsStatus result = OS_FAILED;

    // Instantiate the mailbox manager
    MailboxManager* pMailboxManager =
        MailboxManager::getInstance();

        UtlString dynamicVxml = getVXMLHeader();

        // Update the m_mailbox if valid
    result = pMailboxManager->doLogin(
                m_userid,           // this is an extension
                m_password,         // this is actually a PIN
                m_mailboxIdentity,  // filld in on return
                m_extension );      // filled in on return

        if ( result == OS_SUCCESS )
        {
                // Stores the number of unheard messages in inbox.
                UtlString       rUnheardCount;

                // Stores the total number of mesages in inbox
                UtlString       rTotalCount;

                // Stores the total number of messages in saved folder.
                UtlString       rSavedCount;

                // Stores the total number of unheard messages in saved folder.
                // Note: This is not used.
                UtlString       rSavedUnheardCount;

                // Call the method on Mailbox Manager to get the mailbox status
                result = pMailboxManager->getMailboxStatus( m_mailboxIdentity,
                                                           "inbox",
                                                           rUnheardCount,
                                                           rTotalCount );

                result = pMailboxManager->getMailboxStatus( m_mailboxIdentity,
                                                           "saved",
                                                           rSavedUnheardCount,
                                                           rSavedCount );

        // Check if this user has permission to record system prompts.
        Url mailboxUrl ( m_mailboxIdentity );
        UtlBoolean bHasRecordSystemPromptsPermission = PermissionDB::getInstance()->
                        hasPermission( mailboxUrl, RECORD_SYSTEM_PROMPTS_PERMISSION );

        UtlString strRecordEnabled = "no" ;
        if( bHasRecordSystemPromptsPermission )
            strRecordEnabled = "yes" ;

        // Check if this user has permission to access voicemail options
        UtlBoolean bHasVoicemailPermission = PermissionDB::getInstance()->
                        hasPermission( mailboxUrl, VOICEMAIL_PERMISSION );
        UtlString strVoicemailEnabled = "no" ;
        if( bHasVoicemailPermission ) {
            strVoicemailEnabled = "yes" ;
        }

                dynamicVxml += "<form>\n<block>\n";
                dynamicVxml += "<var name=\"result\" expr=\"'success'\"/>\n";

                // Construct the VXML scriptlet.
                if( result == OS_SUCCESS )
                {
                        dynamicVxml +=  "<var name=\"unheard\" expr=\"" + rUnheardCount + "\"/>\n"\
                                                        "<var name=\"total\" expr=\"" + rTotalCount + "\"/>\n"\
                                                        "<var name=\"saved\" expr=\"" + rSavedCount + "\"/>\n"\
                                                        "<var name=\"mailboxid\" expr=\"'" + m_mailboxIdentity + "'\"/>\n" \
                                                        "<var name=\"extension\" expr=\"'" + m_extension + "'\"/>\n" \
                            "<var name=\"isRecordSystemPromptsEnabled\" expr=\"'" + strRecordEnabled + "'\"/>\n" \
                            "<var name=\"isVoicemailEnabled\" expr=\"'" + strVoicemailEnabled + "'\"/>\n" ;

        } else
                {
                        dynamicVxml +=  "<var name=\"unheard\" expr=\"0\"/>"\
                                                        "<var name=\"total\" expr=\"0\"/>"\
                                                        "<var name=\"saved\" expr=\"0\"/>"\
                                                        "<var name=\"mailboxid\" expr=\"'" + m_mailboxIdentity + "'\"/>\n" \
                                                        "<var name=\"extension\" expr=\"'" + m_extension + "'\"/>\n" \
                            "<var name=\"isRecordSystemPromptsEnabled\" expr=\"'" + strRecordEnabled + "'\"/>\n" \
                            "<var name=\"isVoicemailEnabled\" expr=\"'" + strVoicemailEnabled + "'\"/>\n" ;
                }
                dynamicVxml +=  "<return namelist=\"result unheard total saved mailboxid extension isRecordSystemPromptsEnabled isVoicemailEnabled\"/>\n"\
                                                "</block>\n</form>\n";
        }
        else
        {
                dynamicVxml += VXML_FAILURE_SNIPPET;
        }

        dynamicVxml += 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 ;

}
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;
}
OsStatus
ManageNotificationsWebCGI::getManageNotificationsUI(UtlString* out)
{
    // Construct the status message
    UtlString statusStr = "&nbsp";
    if( m_status == ADD_NOTIFICATION_SUCCESS )
        statusStr = "Email address added successfully" ;
    else if( m_status == EDIT_NOTIFICATION_SUCCESS )
        statusStr = "Email address modified successfully" ;
    else if( m_status == DELETE_NOTIFICATION_SUCCESS )
        statusStr = "Email address deleted successfully" ;
    else if( m_status == DELETE_NOTIFICATION_FAILED )
        statusStr = "Failed to delete the email address. Please try again." ;

    UtlString dynamicHtml =  HTML_BEGIN \
                            WEBPAGE_SNIPPET1 \
                            "Manage Notifications" \
                            WEBPAGE_SNIPPET2 \
                            "notify_by_email_page.htm" \
                            WEBPAGE_SNIPPET3 ;


    MailboxManager* pMailboxManager = MailboxManager::getInstance();

    if( TRUE ) // email notification is always enabled now
    {
        // Get the list of contacts
        UtlBoolean contactsFound = FALSE ;

        UtlHashMap contactsHashDictionary;
        pMailboxManager->getNotificationContactList (
            m_mailboxIdentity,
            &contactsHashDictionary );

        if( contactsHashDictionary.entries() > 0 )
        {
            // Get the sorted contacts list
            // Get the sorted list of contacts.
            UtlSortedList* contactList = (UtlSortedList*) contactsHashDictionary.
                    findValue( new UtlString("sortedcontacts") );

            if (contactList != NULL)
            {
                if( contactList->entries() > 0)
                {
                    contactsFound = TRUE ;

                    // Add code for displaying the status and
                    // the table header for listing the contacts.
                    dynamicHtml +=  statusStr +
                                WEBPAGE_SNIPPET4 +
                                "<tr> \n" \
                                  "<th>Email Address</th>\n" \
                                  "<th width=\"15%\">Edit</th>\n" \
                                  "<th width=\"15%\">Delete</th>\n" \
                                "</tr>\n" ;
                }

                while( contactList->entries() > 0 )
                {

                    UtlString* rwAddress =
                        (UtlString*) contactList->removeAt(0);
                    UtlString address = rwAddress->data();

                    if( contactsHashDictionary.findValue( rwAddress ) != NULL )
                    {
                        UtlHashMap* contactDetails = (UtlHashMap*) contactsHashDictionary.
                                                findValue( rwAddress );

                        // Construct the HTML code
                        UtlString htmlCode ;
                        getNotificationsUIHtmlCode( address, contactDetails, htmlCode ) ;
                        dynamicHtml += htmlCode ;
                    }

                }
                delete contactList ;
            }
        }

        if( !contactsFound )
        {
            statusStr += "<br><br>Notifications can be sent to your email when you receive a new voicemail.<br>Click on the button below to specify your email address";
            dynamicHtml += statusStr + "</td></tr>" ;
        }

        dynamicHtml +=  "</table>\n" \
                        "</td></tr>\n" \
                        "<tr>\n" \
                            "<td colspan=\"2\"> \n" \
                               "<form action=\"" + m_cgiUrl + "\" method=\"post\">\n" \
                               "<input type=\"hidden\" name=\"action\" value=\"getaddnotificationui\">\n" \
                               "<input type=\"hidden\" name=\"fromweb\" value=\"yes\">\n" \
                               "<input type=\"submit\" value=\"Add Notification\">\n" \
                               "</form>\n" \
                            "</td> \n" \
                        "</tr> \n" ;
    }
    else
    {
        dynamicHtml +=  "<br><br>Email notification feature has not been enabled. Please contact your SIPxchange administrator." \
                        "</table>\n" \
                        "</td></tr>\n" ;
    }

    dynamicHtml +=  "</table>\n" \
                    "</td>\n" \
                    "</tr>\n" \
                    "</table>\n" \
                    HTML_END ;

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

    return OS_SUCCESS ;
}
Example #10
0
OsStatus
ManageFoldersWebCGI::execute(UtlString* out)
{

        // Validate the mailbox id and extension.
    ValidateMailboxCGIHelper validateMailboxHelper ( m_mailboxIdentity );
    OsStatus result = validateMailboxHelper.execute( out );
    if ( result == OS_SUCCESS )
    {
        MailboxManager* pMailboxManager = MailboxManager::getInstance();
        result = pMailboxManager->getMediaserverURLForWeb( m_cgiUrl ) ;
        if( result == OS_SUCCESS )
        {
            m_cgiUrl += CGI_URL ;

            // unescape the folder names
            HttpMessage::unescape( m_newFolder );
            HttpMessage::unescape( m_oldFolder );

            validateMailboxHelper.getMailboxIdentity( m_mailboxIdentity );

            if( m_action == "getpersonalfolders" )
            {
                result = getPersonalFolders(out) ;
            }
            else if( m_action == "getfolders" )
            {
                result = getAllFolders( out );
            }
            else if(m_action == "addfolder" ||
                    m_action == "editfolder" ||
                    m_action == "deletefolder" )
            {
                result = addEditDeleteFolder( out );
            }
            else if(m_action == "getaddfolderui" ||
                    m_action == "geteditfolderui" )
            {
                result = getAddEditFolderUI( out );
            }
            else
            {
                result = OS_FAILED ;
            }
        }
        else
        {
            UtlString dynamicHtml =  HTML_BEGIN \
                                    PROTOCOL_MISMATCH \
                                    HTML_END ;
            if( out )
            {
                out->remove(0);
                out->append( dynamicHtml.data() );
            }

            result = OS_SUCCESS ;
        }

    }

    return result ;
}
Example #11
0
OsStatus
ManageFoldersWebCGI::addEditDeleteFolder(UtlString* out)
{
    // URL of the result webpage
    UtlString redirectUrl =  m_cgiUrl + "?fromweb=yes&status=";

    MailboxManager* pMailboxManager = MailboxManager::getInstance();
    OsStatus result = OS_FAILED ;
    if( m_action == "addfolder" )
    {
        result = pMailboxManager->addFolder( m_mailboxIdentity,
                                             m_newFolder );

            if( result == OS_SUCCESS )
                    redirectUrl +=  UtlString( ADD_FOLDER_SUCCESS ) + "&action=getfolders" ;
        else
        {
            UtlString escapedNewFolder = m_newFolder ;
            HttpMessage::escape( escapedNewFolder );
            redirectUrl +=  UtlString( ADD_FOLDER_FAILED ) + "&action=getaddfolderui&newfoldername=" + escapedNewFolder ;
        }

        result = OS_SUCCESS ;
    }
    else if( m_action == "deletefolder" )
    {
        result = pMailboxManager->deleteFolder( m_mailboxIdentity,
                                                m_oldFolder );
            if( result == OS_SUCCESS )
                    redirectUrl +=  UtlString( DELETE_FOLDER_SUCCESS ) + "&action=getfolders" ;
        else
            redirectUrl +=  UtlString( DELETE_FOLDER_FAILED ) + "&action=getfolders";

        result = OS_SUCCESS ;
    }
    else if( m_action == "editfolder" )
    {
        result = pMailboxManager->editFolder(   m_mailboxIdentity,
                                                m_oldFolder,
                                                m_newFolder );

        // Add status to indicate that the move operation failed
            if( result == OS_SUCCESS )
                    redirectUrl +=  UtlString( EDIT_FOLDER_SUCCESS ) + "&action=getfolders";
        else
        {
            UtlString escapedNewFolder = m_newFolder ;
            HttpMessage::escape( escapedNewFolder );
            UtlString escapedOldFolder = m_oldFolder ;
            HttpMessage::escape( escapedOldFolder );

            redirectUrl +=  UtlString( EDIT_FOLDER_FAILED ) + "&action=geteditfolderui&newfoldername=" + escapedNewFolder + "&oldfoldername=" + escapedOldFolder;
        }

        result = OS_SUCCESS ;
    }

    if( result == OS_SUCCESS )
    {
        // 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 result ;
}
Example #12
0
OsStatus
ManageFoldersWebCGI::getAllFolders(UtlString* out)
{

    UtlString statusStr = "&nbsp";
    if( m_status == ADD_FOLDER_SUCCESS )
        statusStr = "Folder added successfully" ;
    else if( m_status == EDIT_FOLDER_SUCCESS )
        statusStr = "Folder edited successfully" ;
    else if( m_status == DELETE_FOLDER_SUCCESS )
        statusStr = "Folder deleted successfully" ;
    else if( m_status == DELETE_FOLDER_FAILED )
        statusStr = "Failed to delete folder. Please try again." ;

    // Get the folder names
    UtlSortedList folderList;
    MailboxManager* pMailboxManager = MailboxManager::getInstance();
        pMailboxManager->getMailboxFolders( m_mailboxIdentity, folderList );

    // Check if mailbox has folders other than the standard 3
    UtlString dynamicHtml =  HTML_BEGIN \
                            WEBPAGE_SNIPPET1 \
                            "Manage Folders" \
                            WEBPAGE_SNIPPET2 \
                            "manage_folders_page.htm" \
                            WEBPAGE_SNIPPET3 ;


    UtlString personalFolders ;
    bool personalFoldersFound = false ;

    while( folderList.entries() > 0 )
    {
        // Show the list of folders so that the user can pick the one they want
        UtlString* rwFolderName =
            (UtlString*) folderList.removeAt(0);
        UtlString folderName = rwFolderName->data();
        delete rwFolderName ;

        UtlString editStr = "&nbsp;" ;
        UtlString deleteStr = "&nbsp;" ;

        if( (folderName.compareTo("inbox", UtlString::ignoreCase) != 0) &&
            (folderName.compareTo("saved", UtlString::ignoreCase) != 0) &&
            (folderName.compareTo("deleted", UtlString::ignoreCase) != 0)
        )
        {
            personalFoldersFound = true;

            // escape the folder name
            UtlString escapedFolderName = folderName ;
            HttpMessage::escape( escapedFolderName );

            UtlString redirectUrl =
                m_cgiUrl + "?fromweb=yes&oldfoldername=" + escapedFolderName + "&action=" ;

            editStr = "<a href=\"" + redirectUrl + "geteditfolderui\"><img src=\"/images/editicon.gif\" width=\"12\" height=\"12\" border=\"0\"></a>";
            deleteStr = "<a href=\"" + redirectUrl + "deletefolder\" onClick=\"return confirm('" + DELETE_CONFIRMATION + "');\"><img src=\"/images/del.gif\" width=\"12\" height=\"12\" border=\"0\"></a>";

            if( personalFolders.isNull() )
            {
                personalFolders =   statusStr +
                                    WEBPAGE_SNIPPET4 +
                                    "<tr> \n" \
                                      "<th>Personal Folder</th>\n" \
                                      "<th width=\"15%\">Edit</th>\n" \
                                      "<th width=\"15%\">Delete</th>\n" \
                                    "</tr>\n" ;
            }
            personalFolders += "<tr> \n" \
                                  "<td>" + folderName + "</td> \n" \
                                  "<td align=\"center\">" + editStr + "</td> \n" \
                                  "<td align=\"center\">" + deleteStr + "</td> \n" \
                                "</tr> \n" ;

        }
    }

    if( !personalFoldersFound )
    {
        statusStr += "<br><br>There are no personal folders associated with this mailbox.";
        dynamicHtml += statusStr + "</td></tr>" ;
    }
    else
    {
        dynamicHtml +=  personalFolders ;
    }

    dynamicHtml +=  "</table>\n" \
                    "</td></tr>\n" \
                    "<tr>\n" \
                        "<td colspan=\"2\"> \n" \
                           "<form action=\"" + m_cgiUrl + "\" method=\"post\">\n" \
                           "<input type=\"hidden\" name=\"action\" value=\"getaddfolderui\">\n" \
                           "<input type=\"hidden\" name=\"fromweb\" value=\"yes\">\n" \
                           "<input type=\"submit\" value=\"Create Folder\">\n" \
                           "</form>\n" \
                        "</td> \n" \
                    "</tr> \n" \
                    "</table>\n" \
                      "</td>\n" \
                    "</tr>\n" \
                  "</table>\n" \
                   HTML_END ;

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

    return OS_SUCCESS ;
}
Example #13
0
OsStatus
ManageFoldersWebCGI::getPersonalFolders(UtlString* out)
{

    UtlString dynamicHtml( HTML_BEGIN );
        UtlString redirectUrl =  m_cgiUrl ;

    // Get the folder names
    UtlSortedList folderList;
    MailboxManager* pMailboxManager = MailboxManager::getInstance();
        pMailboxManager->getMailboxFolders( m_mailboxIdentity, folderList );

    // Check if mailbox has folders other than the standard 3
    if ( folderList.entries() > 3 )
    {
        if( folderList.entries() == 4 )
        {
            // Just one custom folder is available.
            // Redirect to the CGI for displaying contents of the folder
            while( folderList.entries() > 0 )
            {
                UtlString* rwFolderName =
                    (UtlString*) folderList.removeAt(0);
                UtlString folderName = rwFolderName->data();
                delete rwFolderName ;

                if( (folderName.compareTo("inbox", UtlString::ignoreCase) != 0) &&
                    (folderName.compareTo("saved", UtlString::ignoreCase) != 0) &&
                    (folderName.compareTo("deleted", UtlString::ignoreCase) != 0)
                )
                {
                    // escape the folder name
                    UtlString escapedFolderName = folderName;
                    HttpMessage::escape( escapedFolderName );

                    redirectUrl += "?action=playmsg&fromweb=yes&[email protected]&nextblockhandle=-1&category=" + escapedFolderName;
                    break;
                }
            }

            dynamicHtml +=  REDIRECT_SCRIPT_BEGIN + redirectUrl + REDIRECT_SCRIPT_END \
                            HTML_END ;
        }
        else
        {
            dynamicHtml += "<form action=\"" + redirectUrl + "\">\n " +
                            WEBPAGE_SNIPPET1 +
                            "Personal Folders" +
                            WEBPAGE_SNIPPET2 +
                            "all_folders_managing_messages.htm" +
                            WEBPAGE_SNIPPET3 +
                            "Select the folder you want to view" +
                            "</td></tr> \n"+
                            "<tr> \n" \
                                "<td colspan=\"2\" class=\"notetext\"> \n" ;

            while( folderList.entries() > 0 )
            {
                // Show the list of folders so that the user can pick the one they want
                UtlString* rwFolderName =
                    (UtlString*) folderList.removeAt(0);
                UtlString folderName = rwFolderName->data();
                delete rwFolderName ;

                if( (folderName.compareTo("inbox", UtlString::ignoreCase) != 0) &&
                    (folderName.compareTo("saved", UtlString::ignoreCase) != 0) &&
                    (folderName.compareTo("deleted", UtlString::ignoreCase) != 0)
                )
                {
                    UtlString escapedFolderName = folderName ;
                    HttpMessage::escape(escapedFolderName);
                    dynamicHtml += "<input type=\"radio\" name=\"category\" value=\"" + escapedFolderName + "\">" + folderName + "<br>\n" ;
                }
            }

            dynamicHtml += "</td></tr>\n" \
                           "</table>\n" \
                           "<input type=\"hidden\" name=\"action\" value=\"playmsg\">\n" \
                           "<input type=\"hidden\" name=\"fromweb\" value=\"yes\">\n" \
                           "<input type=\"hidden\" name=\"from\" value=\"[email protected]\">\n" \
                           "<input type=\"hidden\" name=\"nextblockhandle\" value=\"-1\">\n" \
                           "<input type=\"submit\" value=\"View\">\n" \
                           "</form>\n" \
                           HTML_END ;

        }
    }
    else
    {
        // User does not have any personal folder.
        dynamicHtml +=  WEBPAGE_SNIPPET1 \
                        "Personal Folders" \
                        WEBPAGE_SNIPPET2 \
                        "all_folders_managing_messages.htm" \
                        WEBPAGE_SNIPPET3 \
                        "<br>You do not have any personal folders set up.<br><br>To add a personal folder, click Manage Folders." \
                        "</td></tr>\n" \
                        "</table> \n" \
                        HTML_END ;
    }

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

    return OS_SUCCESS ;
}
Example #14
0
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;
}