void setUp()
    {
        testDataForStringList[0].testDescription = "A numeric string(alphabetically first!)" ; 
        testDataForStringList[0].item = new UtlString("123") ; 
        testDataForStringList[0].expectedIndex = 0 ; 

        testDataForStringList[1].testDescription = "An alphabetic string(alphatically second!)" ; 
        testDataForStringList[1].item = new UtlString("Abcd") ; 
        testDataForStringList[1].expectedIndex = 1 ; 

        testDataForStringList[2].testDescription = "An alphabetic string(alphabetically third!)" ; 
        testDataForStringList[2].item = new UtlString("Zyxw") ; 
        testDataForStringList[2].expectedIndex = 2 ; 

        testDataForStringList[3].testDescription = \
                             "An alpha numeric string(alphabetically fourth!)" ; 
        testDataForStringList[3].item = new UtlString("ab#34cd") ; 
        testDataForStringList[3].expectedIndex = 3 ; 

        // Add the strings in a random (non alphabetical order) 
        stringList.insert(testDataForStringList[2].item) ; 
        stringList.insert(testDataForStringList[0].item) ; 
        stringList.insert(testDataForStringList[3].item) ; 
        stringList.insert(testDataForStringList[1].item) ; 

        testDataForIntList[0].testDescription = "A negative integer(first item)" ; 
        testDataForIntList[0].item = new UtlInt(-25023) ; 
        testDataForIntList[0].expectedIndex = 0 ; 
        
        testDataForIntList[1].testDescription = "Integer whose value = 0(second item)" ;  
        testDataForIntList[1].item = new UtlInt(0) ; 
        testDataForIntList[1].expectedIndex = 1 ;

        testDataForIntList[2].testDescription = "Positive integer(third item)" ; 
        testDataForIntList[2].item = new UtlInt(35) ; 
        testDataForIntList[2].expectedIndex = 2 ;

        testDataForIntList[3].testDescription = "A positive integer(fourth item)" ; 
        testDataForIntList[3].item = new UtlInt(25023) ; 
        testDataForIntList[3].expectedIndex = 3 ; 
        
        // Add the ints in a random (non alphabetical order) 
        intList.insert(testDataForIntList[2].item) ; 
        intList.insert(testDataForIntList[0].item) ; 
        intList.insert(testDataForIntList[3].item) ; 
        intList.insert(testDataForIntList[1].item) ; 
    }
    /** Test the findNext method. The various test case
    *   for this are :- 
    *     a) Verify that all the elements can be found
             when the iterator has been reset. 
    *     b) Verify that any element after the current iterator position can be searched.
    &     c)  Verify that any element before the current position is not returned in a search.
    *  Verify htat when there are two similar matches than
    *    either of the items is returned when searching.
    */
    void check_FindNext()
    {
        UtlSortedListIterator iter(stringList);
        const char* message;
        // Search for the first item
        message = "Search for the first item" ;
        UtlContainable* found = iter.findNext(testDataForStringList[0].item) ;
        CPPUNIT_ASSERT_EQUAL_MESSAGE(message, testDataForStringList[0].item, found) ; 

         message = "Search for the last item" ; 
         iter.reset() ;
         found = iter.findNext(testDataForStringList[stringListCount-1].item) ;
         CPPUNIT_ASSERT_EQUAL_MESSAGE(message, testDataForStringList[stringListCount-1].item,  found) ;

         message = "Search for a middle item" ;
         iter.reset() ;
         found = iter.findNext(testDataForStringList[2].item) ;
         CPPUNIT_ASSERT_EQUAL_MESSAGE(message, testDataForStringList[2].item, found);

         message = "When the iterator has not been reset, search for an item that "\
                   "is not yet been read" ;
         iter.reset() ;
         iter() ;
         found = iter.findNext(testDataForStringList[2].item) ; 
         CPPUNIT_ASSERT_EQUAL_MESSAGE(message, testDataForStringList[2].item, found)  ; 

         UtlString dupString1("Mnop") ;
         UtlString dupString2("Mnop");
         stringList.insert(&dupString1) ;
         stringList.insert(&dupString2) ;

         iter.reset();
         found = iter.findNext(&dupString2) ;
         bool isSuccess = (found == &dupString1 || found == &dupString2) ;
         CPPUNIT_ASSERT_MESSAGE(message, isSuccess) ; 
    }
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 ;
}
Пример #4
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 ;
}
Пример #5
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 ;
}