author | alwin <alwin> | 2005-03-09 14:40:43 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-03-09 14:40:43 (UTC) |
commit | 84f237fb3b83400a031bf7c2d3025f78c02f28a8 (patch) (side-by-side diff) | |
tree | fbe8992bea9ddda02129d4c3aa4facc4ec38e00c /noncore/net/mail/accountitem.cpp | |
parent | e62e4a9111d9f5cfe4f004f1b21d377b92018b33 (diff) | |
download | opie-84f237fb3b83400a031bf7c2d3025f78c02f28a8.zip opie-84f237fb3b83400a031bf7c2d3025f78c02f28a8.tar.gz opie-84f237fb3b83400a031bf7c2d3025f78c02f28a8.tar.bz2 |
cleanups/fixed potential crashers
context menus are displayed in mainmenu, too.
Diffstat (limited to 'noncore/net/mail/accountitem.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/accountitem.cpp | 155 |
1 files changed, 86 insertions, 69 deletions
diff --git a/noncore/net/mail/accountitem.cpp b/noncore/net/mail/accountitem.cpp index c1574fd..4869df8 100644 --- a/noncore/net/mail/accountitem.cpp +++ b/noncore/net/mail/accountitem.cpp @@ -76,29 +76,29 @@ void POP3viewItem::refresh() } delete folders; } RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) { - odebug << "POP3 fetchBody" << oendl; + odebug << "POP3 fetchBody" << oendl; return wrapper->fetchBody( mail ); } QPopupMenu * POP3viewItem::getContextMenu() { QPopupMenu *m = new QPopupMenu(0); if (m) { if (!account->getOffline()) { - m->insertItem(QObject::tr("Disconnect",contextName),0); - m->insertItem(QObject::tr("Set offline",contextName),1); + m->insertItem(QObject::tr("Disconnect",contextName),SERVER_MENU_DISCONNECT); + m->insertItem(QObject::tr("Set offline",contextName),SERVER_MENU_OFFLINE); } else { - m->insertItem(QObject::tr("Set online",contextName),1); + m->insertItem(QObject::tr("Set online",contextName),SERVER_MENU_OFFLINE); } } return m; } void POP3viewItem::disconnect() @@ -126,16 +126,16 @@ void POP3viewItem::setOnOffline() } void POP3viewItem::contextMenuSelected(int which) { switch (which) { - case 0: + case SERVER_MENU_DISCONNECT: disconnect(); break; - case 1: + case SERVER_MENU_OFFLINE: setOnOffline(); break; } } POP3folderItem::~POP3folderItem() @@ -169,15 +169,15 @@ RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) QPopupMenu * POP3folderItem::getContextMenu() { QPopupMenu *m = new QPopupMenu(0); if (m) { - m->insertItem(QObject::tr("Refresh header list",contextName),0); - m->insertItem(QObject::tr("Delete all mails",contextName),1); - m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); + m->insertItem(QObject::tr("Refresh header list",contextName),FOLDER_MENU_REFRESH_HEADER); + m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS); + m->insertItem(QObject::tr("Move/Copie all mails",contextName),FOLDER_MENU_MOVE_MAILS); } return m; } void POP3folderItem::downloadMails() { @@ -188,21 +188,21 @@ void POP3folderItem::downloadMails() void POP3folderItem::contextMenuSelected(int which) { AccountView * view = (AccountView*)listView(); switch (which) { - case 0: + case FOLDER_MENU_REFRESH_HEADER: /* must be 'cause pop3 lists are cached */ pop3->getWrapper()->logout(); view->refreshCurrent(); break; - case 1: + case FOLDER_MENU_DELETE_ALL_MAILS: deleteAllMail(pop3->getWrapper(),folder); break; - case 2: + case FOLDER_MENU_MOVE_MAILS: downloadMails(); break; default: break; } } @@ -267,30 +267,30 @@ void NNTPviewItem::refresh() } delete folders; } RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail ) { - odebug << "NNTP fetchBody" << oendl; + odebug << "NNTP fetchBody" << oendl; return wrapper->fetchBody( mail ); } QPopupMenu * NNTPviewItem::getContextMenu() { QPopupMenu *m = new QPopupMenu(0); if (m) { if (!account->getOffline()) { - m->insertItem(QObject::tr("Disconnect",contextName),0); - m->insertItem(QObject::tr("Set offline",contextName),1); - m->insertItem(QObject::tr("(Un-)Subscribe groups",contextName),2); + m->insertItem(QObject::tr("Disconnect",contextName),SERVER_MENU_DISCONNECT); + m->insertItem(QObject::tr("Set offline",contextName),SERVER_MENU_OFFLINE); + m->insertItem(QObject::tr("(Un-)Subscribe groups",contextName),SERVER_MENU_SUBSCRIBE); } else { - m->insertItem(QObject::tr("Set online",contextName),1); + m->insertItem(QObject::tr("Set online",contextName),SERVER_MENU_OFFLINE); } } return m; } void NNTPviewItem::subscribeGroups() @@ -327,19 +327,19 @@ void NNTPviewItem::setOnOffline() } void NNTPviewItem::contextMenuSelected(int which) { switch (which) { - case 0: + case SERVER_MENU_DISCONNECT: disconnect(); break; - case 1: + case SERVER_MENU_OFFLINE: setOnOffline(); break; - case 2: + case SERVER_MENU_SUBSCRIBE: subscribeGroups(); break; } } NNTPfolderItem::~NNTPfolderItem() @@ -373,14 +373,14 @@ RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail) QPopupMenu * NNTPfolderItem::getContextMenu() { QPopupMenu *m = new QPopupMenu(0); if (m) { - m->insertItem(QObject::tr("Refresh header list",contextName),0); - m->insertItem(QObject::tr("Copy all postings",contextName),1); + m->insertItem(QObject::tr("Refresh header list",contextName),FOLDER_MENU_REFRESH_HEADER); + m->insertItem(QObject::tr("Copy all postings",contextName),FOLDER_MENU_MOVE_MAILS); } return m; } void NNTPfolderItem::downloadMails() { @@ -391,18 +391,18 @@ void NNTPfolderItem::downloadMails() void NNTPfolderItem::contextMenuSelected(int which) { AccountView * view = (AccountView*)listView(); switch (which) { - case 0: - /* must be 'cause pop3 lists are cached */ + case FOLDER_MENU_REFRESH_HEADER: + /* must be 'cause nntp lists are cached */ nntp->getWrapper()->logout(); view->refreshCurrent(); break; - case 1: + case FOLDER_MENU_MOVE_MAILS: downloadMails(); break; default: break; } } @@ -458,13 +458,13 @@ void IMAPviewItem::refreshFolders(bool force) for ( it = folders->begin(); it!=folders->end(); ++it) { if ((*it)->getDisplayName().lower()=="inbox") { item = new IMAPfolderItem( (*it), this , item ); folders->remove(it); - odebug << "inbox found" << oendl; + odebug << "inbox found" << oendl; break; } } for ( it = folders->begin(); it!=folders->end(); ++it) { fname = (*it)->getDisplayName(); @@ -495,21 +495,21 @@ QPopupMenu * IMAPviewItem::getContextMenu() { QPopupMenu *m = new QPopupMenu(0); if (m) { if (!account->getOffline()) { - m->insertItem(QObject::tr("Refresh folder list",contextName),0); - m->insertItem(QObject::tr("Create new folder",contextName),1); + m->insertItem(QObject::tr("Disconnect",contextName),SERVER_MENU_DISCONNECT); + m->insertItem(QObject::tr("Set offline",contextName),SERVER_MENU_OFFLINE); m->insertSeparator(); - m->insertItem(QObject::tr("Disconnect",contextName),2); - m->insertItem(QObject::tr("Set offline",contextName),3); + m->insertItem(QObject::tr("Refresh folder list",contextName),SERVER_MENU_REFRESH_FOLDER); + m->insertItem(QObject::tr("Create new folder",contextName),SERVER_MENU_CREATE_FOLDER); } else { - m->insertItem(QObject::tr("Set online",contextName),3); + m->insertItem(QObject::tr("Set online",contextName),SERVER_MENU_OFFLINE); } } return m; } void IMAPviewItem::createNewFolder() @@ -531,26 +531,26 @@ void IMAPviewItem::createNewFolder() } } } void IMAPviewItem::contextMenuSelected(int id) { - odebug << "Id selected: " << id << "" << oendl; + odebug << "Id selected: " << id << "" << oendl; switch (id) { - case 0: + case SERVER_MENU_REFRESH_FOLDER: refreshFolders(true); break; - case 1: + case SERVER_MENU_CREATE_FOLDER: createNewFolder(); break; - case 2: + case SERVER_MENU_DISCONNECT: removeChilds(); wrapper->logout(); break; - case 3: + case SERVER_MENU_OFFLINE: if (account->getOffline()==false) { removeChilds(); wrapper->logout(); } account->setOffline(!account->getOffline()); @@ -632,23 +632,23 @@ QPopupMenu * IMAPfolderItem::getContextMenu() { QPopupMenu *m = new QPopupMenu(0); if (m) { if (folder->may_select()) { - m->insertItem(QObject::tr("Refresh header list",contextName),0); - m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); - m->insertItem(QObject::tr("Delete all mails",contextName),1); + m->insertItem(QObject::tr("Refresh header list",contextName),FOLDER_MENU_REFRESH_HEADER); + m->insertItem(QObject::tr("Move/Copy all mails",contextName),FOLDER_MENU_MOVE_MAILS); + m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS); } if (folder->no_inferior()==false) { - m->insertItem(QObject::tr("Create new subfolder",contextName),2); + m->insertItem(QObject::tr("Create new subfolder",contextName),FOLDER_MENU_NEW_SUBFOLDER); } if (folder->getDisplayName().lower()!="inbox") { - m->insertItem(QObject::tr("Delete folder",contextName),3); + m->insertItem(QObject::tr("Delete folder",contextName),FOLDER_MENU_DELETE_FOLDER); } } return m; } void IMAPfolderItem::createNewFolder() @@ -669,13 +669,13 @@ void IMAPfolderItem::createNewFolder() void IMAPfolderItem::deleteFolder() { int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), QObject::tr("Yes",contextName), QObject::tr("No",contextName),QString::null,1,1); - odebug << "Auswahl: " << yesno << "" << oendl; + odebug << "Auswahl: " << yesno << "" << oendl; if (yesno == 0) { if (imap->getWrapper()->deleteMbox(folder)) { QListView*v=listView(); IMAPviewItem * box = imap; @@ -696,29 +696,33 @@ void IMAPfolderItem::downloadMails() if (!bl) return; bl->downloadMails(folder,imap->getWrapper()); } void IMAPfolderItem::contextMenuSelected(int id) { - odebug << "Selected id: " << id << "" << oendl; + odebug << "Selected id: " << id << "" << oendl; AccountView * view = (AccountView*)listView(); switch(id) { - case 0: + case FOLDER_MENU_REFRESH_HEADER: view->refreshCurrent(); break; - case 1: + case FOLDER_MENU_DELETE_ALL_MAILS: deleteAllMail(imap->getWrapper(),folder); break; - case 2: - createNewFolder(); + case FOLDER_MENU_NEW_SUBFOLDER: + if (folder->no_inferior()==false) { + createNewFolder(); + } break; - case 3: - deleteFolder(); + case FOLDER_MENU_DELETE_FOLDER: + if (folder->getDisplayName().lower()!="inbox") { + deleteFolder(); + } break; - case 4: + case FOLDER_MENU_MOVE_MAILS: downloadMails(); break; default: break; } } @@ -756,12 +760,13 @@ void MHviewItem::refresh( QValueList<RecMailP> & target) getWrapper()->listMessages( "",target ); } void MHviewItem::refresh(bool force) { if (childCount()>0 && force==false) return; + odebug << "Refresh mh folders" << oendl; removeChilds(); currentFolders.clear(); QValueList<FolderP> *folders = wrapper->listFolders(); QValueList<FolderP>::ConstIterator it; MHfolderItem*item = 0; MHfolderItem*pmaster = 0; @@ -800,25 +805,25 @@ void MHviewItem::refresh(bool force) } delete folders; } RECBODYP MHviewItem::fetchBody( const RecMailP &mail ) { - odebug << "MH fetchBody" << oendl; + odebug << "MH fetchBody" << oendl; return wrapper->fetchBody( mail ); } QPopupMenu * MHviewItem::getContextMenu() { QPopupMenu *m = new QPopupMenu(0); if (m) { - m->insertItem(QObject::tr("Refresh folder list",contextName),0); - m->insertItem(QObject::tr("Create new folder",contextName),1); - m->insertItem(QObject::tr("Delete all mails",contextName),2); - m->insertItem(QObject::tr("Move/Copie all mails",contextName),3); + m->insertItem(QObject::tr("Refresh folder list",contextName),SERVER_MENU_REFRESH_FOLDER); + m->insertItem(QObject::tr("Create new folder",contextName),FOLDER_MENU_NEW_SUBFOLDER); + m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS); + m->insertItem(QObject::tr("Move/Copie all mails",contextName),FOLDER_MENU_MOVE_MAILS); } return m; } void MHviewItem::createFolder() { @@ -844,26 +849,32 @@ QStringList MHviewItem::subFolders() { return currentFolders; } void MHviewItem::contextMenuSelected(int which) { + AccountView*view = 0; + switch (which) { - case 0: + case SERVER_MENU_REFRESH_FOLDER: refresh(true); break; - case 1: + case FOLDER_MENU_NEW_SUBFOLDER: createFolder(); break; - case 2: + case FOLDER_MENU_DELETE_ALL_MAILS: deleteAllMail(getWrapper(),folder); break; - case 3: + case FOLDER_MENU_MOVE_MAILS: downloadMails(); break; + case FOLDER_MENU_REFRESH_HEADER: + view = (AccountView*)listView(); + if (view) view->refreshCurrent(); + break; default: break; } } MHfolderItem::~MHfolderItem() @@ -930,13 +941,13 @@ RECBODYP MHfolderItem::fetchBody(const RecMailP&aMail) void MHfolderItem::deleteFolder() { int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), QObject::tr("Yes",contextName), QObject::tr("No",contextName),QString::null,1,1); - odebug << "Auswahl: " << yesno << "" << oendl; + odebug << "Auswahl: " << yesno << "" << oendl; if (yesno == 0) { if (mbox->getWrapper()->deleteMbox(folder)) { QListView*v=listView(); MHviewItem * box = mbox; @@ -953,16 +964,17 @@ void MHfolderItem::deleteFolder() QPopupMenu * MHfolderItem::getContextMenu() { QPopupMenu *m = new QPopupMenu(0); if (m) { - m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); - m->insertItem(QObject::tr("Delete all mails",contextName),0); - m->insertItem(QObject::tr("Create new subfolder",contextName),3); - m->insertItem(QObject::tr("Delete folder",contextName),1); + m->insertItem(QObject::tr("Create new subfolder",contextName),FOLDER_MENU_NEW_SUBFOLDER); + m->insertItem(QObject::tr("Refresh header list",contextName),FOLDER_MENU_REFRESH_HEADER); + m->insertItem(QObject::tr("Move/Copie all mails",contextName),FOLDER_MENU_MOVE_MAILS); + m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS); + m->insertItem(QObject::tr("Delete folder",contextName),FOLDER_MENU_DELETE_FOLDER); } return m; } void MHfolderItem::downloadMails() { @@ -991,26 +1003,31 @@ void MHfolderItem::createFolder() } } } void MHfolderItem::contextMenuSelected(int which) { + AccountView*view = 0; switch(which) { - case 0: + case FOLDER_MENU_DELETE_ALL_MAILS: deleteAllMail(mbox->getWrapper(),folder); break; - case 1: + case FOLDER_MENU_DELETE_FOLDER: deleteFolder(); break; - case 2: + case FOLDER_MENU_MOVE_MAILS: downloadMails(); break; - case 3: + case FOLDER_MENU_NEW_SUBFOLDER: createFolder(); break; + case FOLDER_MENU_REFRESH_HEADER: + view = (AccountView*)listView(); + if (view) view->refreshCurrent(); + break; default: break; } } bool MHfolderItem::isDraftfolder() @@ -1072,13 +1089,13 @@ void AccountViewItem::deleteAllMail(AbstractMail*wrapper,const FolderP&folder) if (folder) fname = folder->getDisplayName(); int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). arg(fname), QObject::tr("Yes",contextName), QObject::tr("No",contextName),QString::null,1,1); - odebug << "Auswahl: " << yesno << "" << oendl; + odebug << "Auswahl: " << yesno << "" << oendl; if (yesno == 0) { if (wrapper->deleteAllMail(folder)) { AccountView * view = (AccountView*)listView(); if (view) view->refreshCurrent(); |