author | jgf <jgf> | 2003-12-17 19:07:13 (UTC) |
---|---|---|
committer | jgf <jgf> | 2003-12-17 19:07:13 (UTC) |
commit | f3389a1eeedce7be8638ba2f71476240a8a4fe0e (patch) (unidiff) | |
tree | 1e40a61e7def07dc94603a453295f065a748e8ff | |
parent | a928f1fc8469124e10a7042846d258401e41f7d6 (diff) | |
download | opie-f3389a1eeedce7be8638ba2f71476240a8a4fe0e.zip opie-f3389a1eeedce7be8638ba2f71476240a8a4fe0e.tar.gz opie-f3389a1eeedce7be8638ba2f71476240a8a4fe0e.tar.bz2 |
open pop3 folder per default
-rw-r--r-- | noncore/net/mail/accountview.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index b6bf298..bc13336 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp | |||
@@ -1,282 +1,283 @@ | |||
1 | #include "accountview.h" | 1 | #include "accountview.h" |
2 | #include "mailtypes.h" | 2 | #include "mailtypes.h" |
3 | #include "defines.h" | 3 | #include "defines.h" |
4 | 4 | ||
5 | 5 | ||
6 | /** | 6 | /** |
7 | * POP3 Account stuff | 7 | * POP3 Account stuff |
8 | */ | 8 | */ |
9 | 9 | ||
10 | POP3viewItem::POP3viewItem( POP3account *a, QListView *parent ) | 10 | POP3viewItem::POP3viewItem( POP3account *a, QListView *parent ) |
11 | : AccountViewItem( parent ) | 11 | : AccountViewItem( parent ) |
12 | { | 12 | { |
13 | account = a; | 13 | account = a; |
14 | wrapper = AbstractMail::getWrapper( account ); | 14 | wrapper = AbstractMail::getWrapper( account ); |
15 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 15 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
16 | setText( 0, account->getAccountName() ); | 16 | setText( 0, account->getAccountName() ); |
17 | setOpen( true ); | ||
17 | } | 18 | } |
18 | 19 | ||
19 | POP3viewItem::~POP3viewItem() | 20 | POP3viewItem::~POP3viewItem() |
20 | { | 21 | { |
21 | delete wrapper; | 22 | delete wrapper; |
22 | } | 23 | } |
23 | 24 | ||
24 | AbstractMail *POP3viewItem::getWrapper() | 25 | AbstractMail *POP3viewItem::getWrapper() |
25 | { | 26 | { |
26 | return wrapper; | 27 | return wrapper; |
27 | } | 28 | } |
28 | 29 | ||
29 | void POP3viewItem::refresh( QList<RecMail> & ) | 30 | void POP3viewItem::refresh( QList<RecMail> & ) |
30 | { | 31 | { |
31 | QList<Folder> *folders = wrapper->listFolders(); | 32 | QList<Folder> *folders = wrapper->listFolders(); |
32 | QListViewItem *child = firstChild(); | 33 | QListViewItem *child = firstChild(); |
33 | while ( child ) { | 34 | while ( child ) { |
34 | QListViewItem *tmp = child; | 35 | QListViewItem *tmp = child; |
35 | child = child->nextSibling(); | 36 | child = child->nextSibling(); |
36 | delete tmp; | 37 | delete tmp; |
37 | } | 38 | } |
38 | Folder *it; | 39 | Folder *it; |
39 | QListViewItem*item = 0; | 40 | QListViewItem*item = 0; |
40 | for ( it = folders->first(); it; it = folders->next() ) { | 41 | for ( it = folders->first(); it; it = folders->next() ) { |
41 | item = new POP3folderItem( it, this , item ); | 42 | item = new POP3folderItem( it, this , item ); |
42 | item->setSelectable(it->may_select()); | 43 | item->setSelectable(it->may_select()); |
43 | } | 44 | } |
44 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 45 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
45 | folders->setAutoDelete(false); | 46 | folders->setAutoDelete(false); |
46 | delete folders; | 47 | delete folders; |
47 | } | 48 | } |
48 | 49 | ||
49 | RecBody POP3viewItem::fetchBody( const RecMail &mail ) | 50 | RecBody POP3viewItem::fetchBody( const RecMail &mail ) |
50 | { | 51 | { |
51 | qDebug( "POP3 fetchBody" ); | 52 | qDebug( "POP3 fetchBody" ); |
52 | return wrapper->fetchBody( mail ); | 53 | return wrapper->fetchBody( mail ); |
53 | } | 54 | } |
54 | 55 | ||
55 | POP3folderItem::~POP3folderItem() | 56 | POP3folderItem::~POP3folderItem() |
56 | { | 57 | { |
57 | delete folder; | 58 | delete folder; |
58 | } | 59 | } |
59 | 60 | ||
60 | POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after ) | 61 | POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after ) |
61 | : AccountViewItem( parent,after ) | 62 | : AccountViewItem( parent,after ) |
62 | { | 63 | { |
63 | folder = folderInit; | 64 | folder = folderInit; |
64 | pop3 = parent; | 65 | pop3 = parent; |
65 | if (folder->getDisplayName().lower()!="inbox") { | 66 | if (folder->getDisplayName().lower()!="inbox") { |
66 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 67 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
67 | } else { | 68 | } else { |
68 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 69 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
69 | } | 70 | } |
70 | setText( 0, folder->getDisplayName() ); | 71 | setText( 0, folder->getDisplayName() ); |
71 | } | 72 | } |
72 | 73 | ||
73 | void POP3folderItem::refresh(QList<RecMail>&target) | 74 | void POP3folderItem::refresh(QList<RecMail>&target) |
74 | { | 75 | { |
75 | if (folder->may_select()) | 76 | if (folder->may_select()) |
76 | pop3->getWrapper()->listMessages( folder->getName(),target ); | 77 | pop3->getWrapper()->listMessages( folder->getName(),target ); |
77 | } | 78 | } |
78 | 79 | ||
79 | RecBody POP3folderItem::fetchBody(const RecMail&aMail) | 80 | RecBody POP3folderItem::fetchBody(const RecMail&aMail) |
80 | { | 81 | { |
81 | return pop3->getWrapper()->fetchBody(aMail); | 82 | return pop3->getWrapper()->fetchBody(aMail); |
82 | } | 83 | } |
83 | 84 | ||
84 | /** | 85 | /** |
85 | * IMAP Account stuff | 86 | * IMAP Account stuff |
86 | */ | 87 | */ |
87 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) | 88 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) |
88 | : AccountViewItem( parent ) | 89 | : AccountViewItem( parent ) |
89 | { | 90 | { |
90 | account = a; | 91 | account = a; |
91 | wrapper = AbstractMail::getWrapper( account ); | 92 | wrapper = AbstractMail::getWrapper( account ); |
92 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 93 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
93 | setText( 0, account->getAccountName() ); | 94 | setText( 0, account->getAccountName() ); |
94 | setOpen( true ); | 95 | setOpen( true ); |
95 | } | 96 | } |
96 | 97 | ||
97 | IMAPviewItem::~IMAPviewItem() | 98 | IMAPviewItem::~IMAPviewItem() |
98 | { | 99 | { |
99 | delete wrapper; | 100 | delete wrapper; |
100 | } | 101 | } |
101 | 102 | ||
102 | AbstractMail *IMAPviewItem::getWrapper() | 103 | AbstractMail *IMAPviewItem::getWrapper() |
103 | { | 104 | { |
104 | return wrapper; | 105 | return wrapper; |
105 | } | 106 | } |
106 | 107 | ||
107 | void IMAPviewItem::refresh(QList<RecMail>&) | 108 | void IMAPviewItem::refresh(QList<RecMail>&) |
108 | { | 109 | { |
109 | if (childCount()>0) return; | 110 | if (childCount()>0) return; |
110 | QList<Folder> *folders = wrapper->listFolders(); | 111 | QList<Folder> *folders = wrapper->listFolders(); |
111 | 112 | ||
112 | QListViewItem *child = firstChild(); | 113 | QListViewItem *child = firstChild(); |
113 | while ( child ) { | 114 | while ( child ) { |
114 | QListViewItem *tmp = child; | 115 | QListViewItem *tmp = child; |
115 | child = child->nextSibling(); | 116 | child = child->nextSibling(); |
116 | delete tmp; | 117 | delete tmp; |
117 | } | 118 | } |
118 | 119 | ||
119 | Folder *it; | 120 | Folder *it; |
120 | QListViewItem*item = 0; | 121 | QListViewItem*item = 0; |
121 | QListViewItem*titem = 0; | 122 | QListViewItem*titem = 0; |
122 | QListViewItem*inboxitem = 0; | 123 | QListViewItem*inboxitem = 0; |
123 | QString fname,del,search; | 124 | QString fname,del,search; |
124 | int pos; | 125 | int pos; |
125 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 126 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
126 | folders->setAutoDelete(false); | 127 | folders->setAutoDelete(false); |
127 | 128 | ||
128 | for ( it = folders->first(); it; it = folders->next() ) { | 129 | for ( it = folders->first(); it; it = folders->next() ) { |
129 | if (it->getDisplayName().lower()=="inbox") { | 130 | if (it->getDisplayName().lower()=="inbox") { |
130 | inboxitem = new IMAPfolderItem( it, this , item ); | 131 | inboxitem = new IMAPfolderItem( it, this , item ); |
131 | folders->remove(it); | 132 | folders->remove(it); |
132 | qDebug("inbox found"); | 133 | qDebug("inbox found"); |
133 | break; | 134 | break; |
134 | } | 135 | } |
135 | } | 136 | } |
136 | 137 | ||
137 | for ( it = folders->first(); it; it = folders->next() ) { | 138 | for ( it = folders->first(); it; it = folders->next() ) { |
138 | fname = it->getDisplayName(); | 139 | fname = it->getDisplayName(); |
139 | pos = fname.findRev(it->Separator()); | 140 | pos = fname.findRev(it->Separator()); |
140 | if (pos != -1) { | 141 | if (pos != -1) { |
141 | fname = fname.left(pos); | 142 | fname = fname.left(pos); |
142 | qDebug(fname); | 143 | qDebug(fname); |
143 | } | 144 | } |
144 | IMAPfolderItem*pitem = (IMAPfolderItem*)firstChild(); | 145 | IMAPfolderItem*pitem = (IMAPfolderItem*)firstChild(); |
145 | while (pitem) { | 146 | while (pitem) { |
146 | if (pitem->matchName(fname)) { | 147 | if (pitem->matchName(fname)) { |
147 | break; | 148 | break; |
148 | } | 149 | } |
149 | pitem=(IMAPfolderItem*)pitem->nextSibling(); | 150 | pitem=(IMAPfolderItem*)pitem->nextSibling(); |
150 | } | 151 | } |
151 | if (pitem) { | 152 | if (pitem) { |
152 | titem = item; | 153 | titem = item; |
153 | item = new IMAPfolderItem(it,pitem,item,this); | 154 | item = new IMAPfolderItem(it,pitem,item,this); |
154 | item->setSelectable(it->may_select()); | 155 | item->setSelectable(it->may_select()); |
155 | /* setup the short name */ | 156 | /* setup the short name */ |
156 | item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1)); | 157 | item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1)); |
157 | item = titem; | 158 | item = titem; |
158 | } else { | 159 | } else { |
159 | item = new IMAPfolderItem( it, this , (inboxitem?inboxitem:item) ); | 160 | item = new IMAPfolderItem( it, this , (inboxitem?inboxitem:item) ); |
160 | item->setSelectable(it->may_select()); | 161 | item->setSelectable(it->may_select()); |
161 | } | 162 | } |
162 | } | 163 | } |
163 | delete folders; | 164 | delete folders; |
164 | } | 165 | } |
165 | 166 | ||
166 | RecBody IMAPviewItem::fetchBody(const RecMail&) | 167 | RecBody IMAPviewItem::fetchBody(const RecMail&) |
167 | { | 168 | { |
168 | return RecBody(); | 169 | return RecBody(); |
169 | } | 170 | } |
170 | 171 | ||
171 | IMAPfolderItem::~IMAPfolderItem() | 172 | IMAPfolderItem::~IMAPfolderItem() |
172 | { | 173 | { |
173 | delete folder; | 174 | delete folder; |
174 | } | 175 | } |
175 | 176 | ||
176 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) | 177 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) |
177 | : AccountViewItem( parent ) | 178 | : AccountViewItem( parent ) |
178 | { | 179 | { |
179 | folder = folderInit; | 180 | folder = folderInit; |
180 | imap = parent; | 181 | imap = parent; |
181 | if (folder->getDisplayName().lower()!="inbox") { | 182 | if (folder->getDisplayName().lower()!="inbox") { |
182 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 183 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
183 | } else { | 184 | } else { |
184 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 185 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
185 | } | 186 | } |
186 | setText( 0, folder->getDisplayName() ); | 187 | setText( 0, folder->getDisplayName() ); |
187 | } | 188 | } |
188 | 189 | ||
189 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) | 190 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) |
190 | : AccountViewItem( parent,after ) | 191 | : AccountViewItem( parent,after ) |
191 | { | 192 | { |
192 | folder = folderInit; | 193 | folder = folderInit; |
193 | imap = master; | 194 | imap = master; |
194 | if (folder->getDisplayName().lower()!="inbox") { | 195 | if (folder->getDisplayName().lower()!="inbox") { |
195 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 196 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
196 | } else { | 197 | } else { |
197 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 198 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
198 | } | 199 | } |
199 | setText( 0, folder->getDisplayName() ); | 200 | setText( 0, folder->getDisplayName() ); |
200 | } | 201 | } |
201 | 202 | ||
202 | bool IMAPfolderItem::matchName(const QString&name)const | 203 | bool IMAPfolderItem::matchName(const QString&name)const |
203 | { | 204 | { |
204 | return folder->getDisplayName()==name; | 205 | return folder->getDisplayName()==name; |
205 | } | 206 | } |
206 | 207 | ||
207 | void IMAPfolderItem::refresh(QList<RecMail>&target) | 208 | void IMAPfolderItem::refresh(QList<RecMail>&target) |
208 | { | 209 | { |
209 | if (folder->may_select()) | 210 | if (folder->may_select()) |
210 | imap->getWrapper()->listMessages( folder->getName(),target ); | 211 | imap->getWrapper()->listMessages( folder->getName(),target ); |
211 | } | 212 | } |
212 | 213 | ||
213 | RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) | 214 | RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) |
214 | { | 215 | { |
215 | return imap->getWrapper()->fetchBody(aMail); | 216 | return imap->getWrapper()->fetchBody(aMail); |
216 | } | 217 | } |
217 | 218 | ||
218 | /** | 219 | /** |
219 | * Generic stuff | 220 | * Generic stuff |
220 | */ | 221 | */ |
221 | 222 | ||
222 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | 223 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) |
223 | : QListView( parent, name, flags ) | 224 | : QListView( parent, name, flags ) |
224 | { | 225 | { |
225 | connect( this, SIGNAL( selectionChanged( QListViewItem * ) ), | 226 | connect( this, SIGNAL( selectionChanged( QListViewItem * ) ), |
226 | SLOT( refresh( QListViewItem * ) ) ); | 227 | SLOT( refresh( QListViewItem * ) ) ); |
227 | setSorting(0); | 228 | setSorting(0); |
228 | } | 229 | } |
229 | 230 | ||
230 | void AccountView::populate( QList<Account> list ) | 231 | void AccountView::populate( QList<Account> list ) |
231 | { | 232 | { |
232 | clear(); | 233 | clear(); |
233 | 234 | ||
234 | Account *it; | 235 | Account *it; |
235 | for ( it = list.first(); it; it = list.next() ) { | 236 | for ( it = list.first(); it; it = list.next() ) { |
236 | if ( it->getType().compare( "IMAP" ) == 0 ) { | 237 | if ( it->getType().compare( "IMAP" ) == 0 ) { |
237 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); | 238 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); |
238 | qDebug( "added IMAP " + imap->getAccountName() ); | 239 | qDebug( "added IMAP " + imap->getAccountName() ); |
239 | (void) new IMAPviewItem( imap, this ); | 240 | (void) new IMAPviewItem( imap, this ); |
240 | } else if ( it->getType().compare( "POP3" ) == 0 ) { | 241 | } else if ( it->getType().compare( "POP3" ) == 0 ) { |
241 | POP3account *pop3 = static_cast<POP3account *>(it); | 242 | POP3account *pop3 = static_cast<POP3account *>(it); |
242 | qDebug( "added POP3 " + pop3->getAccountName() ); | 243 | qDebug( "added POP3 " + pop3->getAccountName() ); |
243 | (void) new POP3viewItem( pop3, this ); | 244 | (void) new POP3viewItem( pop3, this ); |
244 | } | 245 | } |
245 | } | 246 | } |
246 | } | 247 | } |
247 | 248 | ||
248 | void AccountView::refresh(QListViewItem *item) { | 249 | void AccountView::refresh(QListViewItem *item) { |
249 | 250 | ||
250 | qDebug("AccountView refresh..."); | 251 | qDebug("AccountView refresh..."); |
251 | if ( item ) { | 252 | if ( item ) { |
252 | m_currentItem = item; | 253 | m_currentItem = item; |
253 | QList<RecMail> headerlist; | 254 | QList<RecMail> headerlist; |
254 | headerlist.setAutoDelete(true); | 255 | headerlist.setAutoDelete(true); |
255 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 256 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
256 | view->refresh(headerlist); | 257 | view->refresh(headerlist); |
257 | emit refreshMailview(&headerlist); | 258 | emit refreshMailview(&headerlist); |
258 | } | 259 | } |
259 | } | 260 | } |
260 | 261 | ||
261 | void AccountView::refreshCurrent() | 262 | void AccountView::refreshCurrent() |
262 | { | 263 | { |
263 | if ( !m_currentItem ) return; | 264 | if ( !m_currentItem ) return; |
264 | QList<RecMail> headerlist; | 265 | QList<RecMail> headerlist; |
265 | headerlist.setAutoDelete(true); | 266 | headerlist.setAutoDelete(true); |
266 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); | 267 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); |
267 | view->refresh(headerlist); | 268 | view->refresh(headerlist); |
268 | emit refreshMailview(&headerlist); | 269 | emit refreshMailview(&headerlist); |
269 | } | 270 | } |
270 | 271 | ||
271 | void AccountView::refreshAll() | 272 | void AccountView::refreshAll() |
272 | { | 273 | { |
273 | 274 | ||
274 | } | 275 | } |
275 | 276 | ||
276 | RecBody AccountView::fetchBody(const RecMail&aMail) | 277 | RecBody AccountView::fetchBody(const RecMail&aMail) |
277 | { | 278 | { |
278 | QListViewItem*item = selectedItem (); | 279 | QListViewItem*item = selectedItem (); |
279 | if (!item) return RecBody(); | 280 | if (!item) return RecBody(); |
280 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 281 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
281 | return view->fetchBody(aMail); | 282 | return view->fetchBody(aMail); |
282 | } | 283 | } |