Diffstat (limited to 'noncore/net/mail/accountview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/accountview.cpp | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index 0fe8475..c747a8b 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp | |||
@@ -1,158 +1,157 @@ | |||
1 | 1 | ||
2 | #include "accountview.h" | 2 | #include "accountview.h" |
3 | #include "accountitem.h" | 3 | #include "accountitem.h" |
4 | #include "selectstore.h" | 4 | #include "selectstore.h" |
5 | 5 | ||
6 | #include <libmailwrapper/settings.h> | 6 | #include <libmailwrapper/settings.h> |
7 | #include <libmailwrapper/mailwrapper.h> | 7 | #include <libmailwrapper/mailwrapper.h> |
8 | #include <libmailwrapper/mailtypes.h> | 8 | #include <libmailwrapper/mailtypes.h> |
9 | #include <libmailwrapper/abstractmail.h> | 9 | #include <libmailwrapper/abstractmail.h> |
10 | 10 | ||
11 | /* OPIE */ | 11 | /* OPIE */ |
12 | #include <opie2/odebug.h> | 12 | #include <opie2/odebug.h> |
13 | #include <qpe/qpeapplication.h> | 13 | #include <qpe/qpeapplication.h> |
14 | 14 | ||
15 | /* QT */ | 15 | /* QT */ |
16 | #include <qmessagebox.h> | 16 | #include <qmessagebox.h> |
17 | #include <qpopupmenu.h> | 17 | #include <qpopupmenu.h> |
18 | 18 | ||
19 | using namespace Opie::Core; | 19 | using namespace Opie::Core; |
20 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | 20 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) |
21 | : QListView( parent, name, flags ) | 21 | : QListView( parent, name, flags ) |
22 | { | 22 | { |
23 | connect( this, SIGNAL( selectionChanged(QListViewItem*) ), | 23 | connect( this, SIGNAL( selectionChanged(QListViewItem*) ), |
24 | SLOT( refresh(QListViewItem*) ) ); | 24 | SLOT( refresh(QListViewItem*) ) ); |
25 | connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, | 25 | connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, |
26 | SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) ); | 26 | SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) ); |
27 | setSorting(0); | 27 | setSorting(0); |
28 | } | 28 | } |
29 | 29 | ||
30 | AccountView::~AccountView() | 30 | AccountView::~AccountView() |
31 | { | 31 | { |
32 | imapAccounts.clear(); | 32 | imapAccounts.clear(); |
33 | mhAccounts.clear(); | 33 | mhAccounts.clear(); |
34 | } | 34 | } |
35 | 35 | ||
36 | void AccountView::slotContextMenu(int id) | 36 | void AccountView::slotContextMenu(int id) |
37 | { | 37 | { |
38 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); | 38 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); |
39 | if (!view) return; | 39 | if (!view) return; |
40 | view->contextMenuSelected(id); | 40 | view->contextMenuSelected(id); |
41 | } | 41 | } |
42 | 42 | ||
43 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) | 43 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) |
44 | { | 44 | { |
45 | if (button==1) {return;} | 45 | if (button==1) {return;} |
46 | if (!item) return; | 46 | if (!item) return; |
47 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 47 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
48 | QPopupMenu*m = view->getContextMenu(); | 48 | QPopupMenu*m = view->getContextMenu(); |
49 | if (!m) return; | 49 | if (!m) return; |
50 | connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); | 50 | connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); |
51 | m->setFocus(); | 51 | m->setFocus(); |
52 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 52 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
53 | delete m; | 53 | delete m; |
54 | } | 54 | } |
55 | 55 | ||
56 | void AccountView::populate( QList<Account> list ) | 56 | void AccountView::populate( QList<Account> list ) |
57 | { | 57 | { |
58 | clear(); | 58 | clear(); |
59 | 59 | ||
60 | imapAccounts.clear(); | 60 | imapAccounts.clear(); |
61 | mhAccounts.clear(); | 61 | mhAccounts.clear(); |
62 | |||
63 | mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); | 62 | mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); |
64 | 63 | ||
65 | Account *it; | 64 | Account *it; |
66 | for ( it = list.first(); it; it = list.next() ) { | 65 | for ( it = list.first(); it; it = list.next() ) { |
67 | if ( it->getType() == MAILLIB::A_IMAP ) { | 66 | if ( it->getType() == MAILLIB::A_IMAP ) { |
68 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); | 67 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); |
69 | odebug << "added IMAP " + imap->getAccountName() << oendl; | 68 | odebug << "added IMAP " + imap->getAccountName() << oendl; |
70 | imapAccounts.append(new IMAPviewItem( imap, this )); | 69 | imapAccounts.append(new IMAPviewItem( imap, this )); |
71 | } else if ( it->getType() == MAILLIB::A_POP3 ) { | 70 | } else if ( it->getType() == MAILLIB::A_POP3 ) { |
72 | POP3account *pop3 = static_cast<POP3account *>(it); | 71 | POP3account *pop3 = static_cast<POP3account *>(it); |
73 | odebug << "added POP3 " + pop3->getAccountName() << oendl; | 72 | odebug << "added POP3 " + pop3->getAccountName() << oendl; |
74 | /* must not be hold 'cause it isn't required */ | 73 | /* must not be hold 'cause it isn't required */ |
75 | (void) new POP3viewItem( pop3, this ); | 74 | (void) new POP3viewItem( pop3, this ); |
76 | } else if ( it->getType() == MAILLIB::A_NNTP ) { | 75 | } else if ( it->getType() == MAILLIB::A_NNTP ) { |
77 | NNTPaccount *nntp = static_cast<NNTPaccount *>(it); | 76 | NNTPaccount *nntp = static_cast<NNTPaccount *>(it); |
78 | odebug << "added NNTP " + nntp->getAccountName() << oendl; | 77 | odebug << "added NNTP " + nntp->getAccountName() << oendl; |
79 | /* must not be hold 'cause it isn't required */ | 78 | /* must not be hold 'cause it isn't required */ |
80 | (void) new NNTPviewItem( nntp, this ); | 79 | (void) new NNTPviewItem( nntp, this ); |
81 | } else if ( it->getType() == MAILLIB::A_MH ) { | 80 | } else if ( it->getType() == MAILLIB::A_MH ) { |
82 | } | 81 | } |
83 | } | 82 | } |
84 | } | 83 | } |
85 | 84 | ||
86 | void AccountView::refresh(QListViewItem *item) | 85 | void AccountView::refresh(QListViewItem *item) |
87 | { | 86 | { |
88 | 87 | ||
89 | odebug << "AccountView refresh..." << oendl; | 88 | odebug << "AccountView refresh..." << oendl; |
90 | if ( item ) | 89 | if ( item ) |
91 | { | 90 | { |
92 | m_currentItem = item; | 91 | m_currentItem = item; |
93 | QValueList<RecMailP> headerlist; | 92 | QValueList<RecMailP> headerlist; |
94 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 93 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
95 | view->refresh(headerlist); | 94 | view->refresh(headerlist); |
96 | emit refreshMailview(headerlist); | 95 | emit refreshMailview(headerlist); |
97 | } | 96 | } |
98 | } | 97 | } |
99 | 98 | ||
100 | void AccountView::refreshCurrent() | 99 | void AccountView::refreshCurrent() |
101 | { | 100 | { |
102 | m_currentItem = currentItem(); | 101 | m_currentItem = currentItem(); |
103 | if ( !m_currentItem ) return; | 102 | if ( !m_currentItem ) return; |
104 | QValueList<RecMailP> headerlist; | 103 | QValueList<RecMailP> headerlist; |
105 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); | 104 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); |
106 | view->refresh(headerlist); | 105 | view->refresh(headerlist); |
107 | emit refreshMailview(headerlist); | 106 | emit refreshMailview(headerlist); |
108 | } | 107 | } |
109 | 108 | ||
110 | void AccountView::refreshAll() | 109 | void AccountView::refreshAll() |
111 | { | 110 | { |
112 | } | 111 | } |
113 | 112 | ||
114 | RecBodyP AccountView::fetchBody(const RecMailP&aMail) | 113 | RecBodyP AccountView::fetchBody(const RecMailP&aMail) |
115 | { | 114 | { |
116 | QListViewItem*item = selectedItem (); | 115 | QListViewItem*item = selectedItem (); |
117 | if (!item) return new RecBody(); | 116 | if (!item) return new RecBody(); |
118 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 117 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
119 | return view->fetchBody(aMail); | 118 | return view->fetchBody(aMail); |
120 | } | 119 | } |
121 | 120 | ||
122 | void AccountView::setupFolderselect(Selectstore*sels) | 121 | void AccountView::setupFolderselect(Selectstore*sels) |
123 | { | 122 | { |
124 | QPEApplication::showDialog( sels ); | 123 | QPEApplication::showDialog( sels ); |
125 | QStringList sFolders; | 124 | QStringList sFolders; |
126 | unsigned int i = 0; | 125 | unsigned int i = 0; |
127 | for (i=0; i < mhAccounts.count();++i) | 126 | for (i=0; i < mhAccounts.count();++i) |
128 | { | 127 | { |
129 | mhAccounts[i]->refresh(false); | 128 | mhAccounts[i]->refresh(false); |
130 | sFolders = mhAccounts[i]->subFolders(); | 129 | sFolders = mhAccounts[i]->subFolders(); |
131 | sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); | 130 | sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); |
132 | } | 131 | } |
133 | for (i=0; i < imapAccounts.count();++i) | 132 | for (i=0; i < imapAccounts.count();++i) |
134 | { | 133 | { |
135 | if (imapAccounts[i]->offline()) | 134 | if (imapAccounts[i]->offline()) |
136 | continue; | 135 | continue; |
137 | imapAccounts[i]->refreshFolders(false); | 136 | imapAccounts[i]->refreshFolders(false); |
138 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); | 137 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); |
139 | } | 138 | } |
140 | } | 139 | } |
141 | 140 | ||
142 | void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) | 141 | void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) |
143 | { | 142 | { |
144 | AbstractMail*targetMail = 0; | 143 | AbstractMail*targetMail = 0; |
145 | QString targetFolder = ""; | 144 | QString targetFolder = ""; |
146 | Selectstore sels; | 145 | Selectstore sels; |
147 | setupFolderselect(&sels); | 146 | setupFolderselect(&sels); |
148 | if (!sels.exec()) return; | 147 | if (!sels.exec()) return; |
149 | targetMail = sels.currentMail(); | 148 | targetMail = sels.currentMail(); |
150 | targetFolder = sels.currentFolder(); | 149 | targetFolder = sels.currentFolder(); |
151 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || | 150 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || |
152 | targetFolder.isEmpty()) | 151 | targetFolder.isEmpty()) |
153 | { | 152 | { |
154 | return; | 153 | return; |
155 | } | 154 | } |
156 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 155 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
157 | { | 156 | { |
158 | QMessageBox::critical(0,tr("Error creating new Folder"), | 157 | QMessageBox::critical(0,tr("Error creating new Folder"), |