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