OsStatus ManageFoldersWebCGI::getAllFolders(UtlString* out) { UtlString statusStr = " "; 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 = " " ; UtlString deleteStr = " " ; 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 ; }
OsStatus ManageNotificationsWebCGI::getManageNotificationsUI(UtlString* out) { // Construct the status message UtlString statusStr = " "; 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 ; }
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 ; }