author | alwin <alwin> | 2003-12-14 19:36:09 (UTC) |
---|---|---|
committer | alwin <alwin> | 2003-12-14 19:36:09 (UTC) |
commit | aa2c19611a347a3945d403e20bcef01977d68b6a (patch) (unidiff) | |
tree | 669bf39c587f9ee22e17fe2c61ed0fec78f356d3 | |
parent | 353e1da81b235d7798763bce76428fb473108fb6 (diff) | |
download | opie-aa2c19611a347a3945d403e20bcef01977d68b6a.zip opie-aa2c19611a347a3945d403e20bcef01977d68b6a.tar.gz opie-aa2c19611a347a3945d403e20bcef01977d68b6a.tar.bz2 |
if a mailbox-prefix is set than it will not displayed in folderview
-rw-r--r-- | noncore/net/mail/imapwrapper.cpp | 4 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 4 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailwrapper.cpp | 12 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailwrapper.h | 4 | ||||
-rw-r--r-- | noncore/net/mail/mailwrapper.cpp | 12 | ||||
-rw-r--r-- | noncore/net/mail/mailwrapper.h | 4 |
6 files changed, 32 insertions, 8 deletions
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp index b253b49..0ce2c6c 100644 --- a/noncore/net/mail/imapwrapper.cpp +++ b/noncore/net/mail/imapwrapper.cpp | |||
@@ -139,133 +139,135 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | |||
139 | qDebug("Error fetching headers: %s",m_imap->imap_response); | 139 | qDebug("Error fetching headers: %s",m_imap->imap_response); |
140 | } | 140 | } |
141 | mailimap_fetch_list_free(result); | 141 | mailimap_fetch_list_free(result); |
142 | } | 142 | } |
143 | 143 | ||
144 | QList<Folder>* IMAPwrapper::listFolders() | 144 | QList<Folder>* IMAPwrapper::listFolders() |
145 | { | 145 | { |
146 | const char *path, *mask; | 146 | const char *path, *mask; |
147 | int err = MAILIMAP_NO_ERROR; | 147 | int err = MAILIMAP_NO_ERROR; |
148 | clist *result; | 148 | clist *result; |
149 | clistcell *current; | 149 | clistcell *current; |
150 | 150 | ||
151 | QList<Folder> * folders = new QList<Folder>(); | 151 | QList<Folder> * folders = new QList<Folder>(); |
152 | folders->setAutoDelete( false ); | 152 | folders->setAutoDelete( false ); |
153 | login(); | 153 | login(); |
154 | if (!m_imap) { | 154 | if (!m_imap) { |
155 | return folders; | 155 | return folders; |
156 | } | 156 | } |
157 | 157 | ||
158 | /* | 158 | /* |
159 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. | 159 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. |
160 | * We must not forget to filter them out in next loop! | 160 | * We must not forget to filter them out in next loop! |
161 | * it seems like ugly code. and yes - it is ugly code. but the best way. | 161 | * it seems like ugly code. and yes - it is ugly code. but the best way. |
162 | */ | 162 | */ |
163 | QString temp; | 163 | QString temp; |
164 | mask = "INBOX" ; | 164 | mask = "INBOX" ; |
165 | result = clist_new(); | 165 | result = clist_new(); |
166 | mailimap_mailbox_list *list; | 166 | mailimap_mailbox_list *list; |
167 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); | 167 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); |
168 | if ( err == MAILIMAP_NO_ERROR ) { | 168 | if ( err == MAILIMAP_NO_ERROR ) { |
169 | current = result->first; | 169 | current = result->first; |
170 | for ( int i = result->count; i > 0; i-- ) { | 170 | for ( int i = result->count; i > 0; i-- ) { |
171 | list = (mailimap_mailbox_list *) current->data; | 171 | list = (mailimap_mailbox_list *) current->data; |
172 | // it is better use the deep copy mechanism of qt itself | 172 | // it is better use the deep copy mechanism of qt itself |
173 | // instead of using strdup! | 173 | // instead of using strdup! |
174 | temp = list->mb_name; | 174 | temp = list->mb_name; |
175 | folders->append( new IMAPFolder(temp)); | 175 | folders->append( new IMAPFolder(temp)); |
176 | current = current->next; | 176 | current = current->next; |
177 | } | 177 | } |
178 | } else { | 178 | } else { |
179 | qDebug("error fetching folders: %s",m_imap->imap_response); | 179 | qDebug("error fetching folders: %s",m_imap->imap_response); |
180 | } | 180 | } |
181 | mailimap_list_result_free( result ); | 181 | mailimap_list_result_free( result ); |
182 | 182 | ||
183 | /* | 183 | /* |
184 | * second stage - get the other then inbox folders | 184 | * second stage - get the other then inbox folders |
185 | */ | 185 | */ |
186 | mask = "*" ; | 186 | mask = "*" ; |
187 | path = account->getPrefix().latin1(); | 187 | path = account->getPrefix().latin1(); |
188 | if (!path) path = ""; | 188 | if (!path) path = ""; |
189 | result = clist_new(); | 189 | result = clist_new(); |
190 | qDebug(path); | 190 | qDebug(path); |
191 | bool selectable = true; | 191 | bool selectable = true; |
192 | mailimap_mbx_list_flags*bflags; | 192 | mailimap_mbx_list_flags*bflags; |
193 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); | 193 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); |
194 | if ( err == MAILIMAP_NO_ERROR ) { | 194 | if ( err == MAILIMAP_NO_ERROR ) { |
195 | current = result->first; | 195 | current = result->first; |
196 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { | 196 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { |
197 | list = (mailimap_mailbox_list *) current->data; | 197 | list = (mailimap_mailbox_list *) current->data; |
198 | // it is better use the deep copy mechanism of qt itself | 198 | // it is better use the deep copy mechanism of qt itself |
199 | // instead of using strdup! | 199 | // instead of using strdup! |
200 | temp = list->mb_name; | 200 | temp = list->mb_name; |
201 | if (temp.lower()=="inbox") | 201 | if (temp.lower()=="inbox") |
202 | continue; | 202 | continue; |
203 | if (temp.lower()==account->getPrefix().lower()) | ||
204 | continue; | ||
203 | if ( (bflags = list->mb_flag) ) { | 205 | if ( (bflags = list->mb_flag) ) { |
204 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | 206 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& |
205 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | 207 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); |
206 | } | 208 | } |
207 | folders->append(new IMAPFolder(temp,selectable)); | 209 | folders->append(new IMAPFolder(temp,selectable,account->getPrefix())); |
208 | } | 210 | } |
209 | } else { | 211 | } else { |
210 | qDebug("error fetching folders %s",m_imap->imap_response); | 212 | qDebug("error fetching folders %s",m_imap->imap_response); |
211 | } | 213 | } |
212 | mailimap_list_result_free( result ); | 214 | mailimap_list_result_free( result ); |
213 | return folders; | 215 | return folders; |
214 | } | 216 | } |
215 | 217 | ||
216 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | 218 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) |
217 | { | 219 | { |
218 | RecMail * m = 0; | 220 | RecMail * m = 0; |
219 | mailimap_msg_att_item *item=0; | 221 | mailimap_msg_att_item *item=0; |
220 | clistcell *current,*c,*cf; | 222 | clistcell *current,*c,*cf; |
221 | mailimap_msg_att_dynamic*flist; | 223 | mailimap_msg_att_dynamic*flist; |
222 | mailimap_flag_fetch*cflag; | 224 | mailimap_flag_fetch*cflag; |
223 | int size; | 225 | int size; |
224 | QBitArray mFlags(7); | 226 | QBitArray mFlags(7); |
225 | QStringList addresslist; | 227 | QStringList addresslist; |
226 | 228 | ||
227 | if (!m_att) { | 229 | if (!m_att) { |
228 | return m; | 230 | return m; |
229 | } | 231 | } |
230 | m = new RecMail(); | 232 | m = new RecMail(); |
231 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { | 233 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { |
232 | current = c; | 234 | current = c; |
233 | size = 0; | 235 | size = 0; |
234 | item = (mailimap_msg_att_item*)current->data; | 236 | item = (mailimap_msg_att_item*)current->data; |
235 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 237 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
236 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; | 238 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
237 | if (!flist->att_list) { | 239 | if (!flist->att_list) { |
238 | continue; | 240 | continue; |
239 | } | 241 | } |
240 | cf = flist->att_list->first; | 242 | cf = flist->att_list->first; |
241 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { | 243 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { |
242 | cflag = (mailimap_flag_fetch*)cf->data; | 244 | cflag = (mailimap_flag_fetch*)cf->data; |
243 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { | 245 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { |
244 | switch (cflag->fl_flag->fl_type) { | 246 | switch (cflag->fl_flag->fl_type) { |
245 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ | 247 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ |
246 | mFlags.setBit(FLAG_ANSWERED); | 248 | mFlags.setBit(FLAG_ANSWERED); |
247 | break; | 249 | break; |
248 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ | 250 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ |
249 | mFlags.setBit(FLAG_FLAGGED); | 251 | mFlags.setBit(FLAG_FLAGGED); |
250 | break; | 252 | break; |
251 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ | 253 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ |
252 | mFlags.setBit(FLAG_DELETED); | 254 | mFlags.setBit(FLAG_DELETED); |
253 | break; | 255 | break; |
254 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ | 256 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ |
255 | mFlags.setBit(FLAG_SEEN); | 257 | mFlags.setBit(FLAG_SEEN); |
256 | break; | 258 | break; |
257 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ | 259 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ |
258 | mFlags.setBit(FLAG_DRAFT); | 260 | mFlags.setBit(FLAG_DRAFT); |
259 | break; | 261 | break; |
260 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ | 262 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ |
261 | break; | 263 | break; |
262 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ | 264 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ |
263 | break; | 265 | break; |
264 | default: | 266 | default: |
265 | break; | 267 | break; |
266 | } | 268 | } |
267 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { | 269 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { |
268 | mFlags.setBit(FLAG_RECENT); | 270 | mFlags.setBit(FLAG_RECENT); |
269 | } | 271 | } |
270 | } | 272 | } |
271 | continue; | 273 | continue; |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index b253b49..0ce2c6c 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -139,133 +139,135 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | |||
139 | qDebug("Error fetching headers: %s",m_imap->imap_response); | 139 | qDebug("Error fetching headers: %s",m_imap->imap_response); |
140 | } | 140 | } |
141 | mailimap_fetch_list_free(result); | 141 | mailimap_fetch_list_free(result); |
142 | } | 142 | } |
143 | 143 | ||
144 | QList<Folder>* IMAPwrapper::listFolders() | 144 | QList<Folder>* IMAPwrapper::listFolders() |
145 | { | 145 | { |
146 | const char *path, *mask; | 146 | const char *path, *mask; |
147 | int err = MAILIMAP_NO_ERROR; | 147 | int err = MAILIMAP_NO_ERROR; |
148 | clist *result; | 148 | clist *result; |
149 | clistcell *current; | 149 | clistcell *current; |
150 | 150 | ||
151 | QList<Folder> * folders = new QList<Folder>(); | 151 | QList<Folder> * folders = new QList<Folder>(); |
152 | folders->setAutoDelete( false ); | 152 | folders->setAutoDelete( false ); |
153 | login(); | 153 | login(); |
154 | if (!m_imap) { | 154 | if (!m_imap) { |
155 | return folders; | 155 | return folders; |
156 | } | 156 | } |
157 | 157 | ||
158 | /* | 158 | /* |
159 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. | 159 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. |
160 | * We must not forget to filter them out in next loop! | 160 | * We must not forget to filter them out in next loop! |
161 | * it seems like ugly code. and yes - it is ugly code. but the best way. | 161 | * it seems like ugly code. and yes - it is ugly code. but the best way. |
162 | */ | 162 | */ |
163 | QString temp; | 163 | QString temp; |
164 | mask = "INBOX" ; | 164 | mask = "INBOX" ; |
165 | result = clist_new(); | 165 | result = clist_new(); |
166 | mailimap_mailbox_list *list; | 166 | mailimap_mailbox_list *list; |
167 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); | 167 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); |
168 | if ( err == MAILIMAP_NO_ERROR ) { | 168 | if ( err == MAILIMAP_NO_ERROR ) { |
169 | current = result->first; | 169 | current = result->first; |
170 | for ( int i = result->count; i > 0; i-- ) { | 170 | for ( int i = result->count; i > 0; i-- ) { |
171 | list = (mailimap_mailbox_list *) current->data; | 171 | list = (mailimap_mailbox_list *) current->data; |
172 | // it is better use the deep copy mechanism of qt itself | 172 | // it is better use the deep copy mechanism of qt itself |
173 | // instead of using strdup! | 173 | // instead of using strdup! |
174 | temp = list->mb_name; | 174 | temp = list->mb_name; |
175 | folders->append( new IMAPFolder(temp)); | 175 | folders->append( new IMAPFolder(temp)); |
176 | current = current->next; | 176 | current = current->next; |
177 | } | 177 | } |
178 | } else { | 178 | } else { |
179 | qDebug("error fetching folders: %s",m_imap->imap_response); | 179 | qDebug("error fetching folders: %s",m_imap->imap_response); |
180 | } | 180 | } |
181 | mailimap_list_result_free( result ); | 181 | mailimap_list_result_free( result ); |
182 | 182 | ||
183 | /* | 183 | /* |
184 | * second stage - get the other then inbox folders | 184 | * second stage - get the other then inbox folders |
185 | */ | 185 | */ |
186 | mask = "*" ; | 186 | mask = "*" ; |
187 | path = account->getPrefix().latin1(); | 187 | path = account->getPrefix().latin1(); |
188 | if (!path) path = ""; | 188 | if (!path) path = ""; |
189 | result = clist_new(); | 189 | result = clist_new(); |
190 | qDebug(path); | 190 | qDebug(path); |
191 | bool selectable = true; | 191 | bool selectable = true; |
192 | mailimap_mbx_list_flags*bflags; | 192 | mailimap_mbx_list_flags*bflags; |
193 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); | 193 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); |
194 | if ( err == MAILIMAP_NO_ERROR ) { | 194 | if ( err == MAILIMAP_NO_ERROR ) { |
195 | current = result->first; | 195 | current = result->first; |
196 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { | 196 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { |
197 | list = (mailimap_mailbox_list *) current->data; | 197 | list = (mailimap_mailbox_list *) current->data; |
198 | // it is better use the deep copy mechanism of qt itself | 198 | // it is better use the deep copy mechanism of qt itself |
199 | // instead of using strdup! | 199 | // instead of using strdup! |
200 | temp = list->mb_name; | 200 | temp = list->mb_name; |
201 | if (temp.lower()=="inbox") | 201 | if (temp.lower()=="inbox") |
202 | continue; | 202 | continue; |
203 | if (temp.lower()==account->getPrefix().lower()) | ||
204 | continue; | ||
203 | if ( (bflags = list->mb_flag) ) { | 205 | if ( (bflags = list->mb_flag) ) { |
204 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | 206 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& |
205 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | 207 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); |
206 | } | 208 | } |
207 | folders->append(new IMAPFolder(temp,selectable)); | 209 | folders->append(new IMAPFolder(temp,selectable,account->getPrefix())); |
208 | } | 210 | } |
209 | } else { | 211 | } else { |
210 | qDebug("error fetching folders %s",m_imap->imap_response); | 212 | qDebug("error fetching folders %s",m_imap->imap_response); |
211 | } | 213 | } |
212 | mailimap_list_result_free( result ); | 214 | mailimap_list_result_free( result ); |
213 | return folders; | 215 | return folders; |
214 | } | 216 | } |
215 | 217 | ||
216 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | 218 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) |
217 | { | 219 | { |
218 | RecMail * m = 0; | 220 | RecMail * m = 0; |
219 | mailimap_msg_att_item *item=0; | 221 | mailimap_msg_att_item *item=0; |
220 | clistcell *current,*c,*cf; | 222 | clistcell *current,*c,*cf; |
221 | mailimap_msg_att_dynamic*flist; | 223 | mailimap_msg_att_dynamic*flist; |
222 | mailimap_flag_fetch*cflag; | 224 | mailimap_flag_fetch*cflag; |
223 | int size; | 225 | int size; |
224 | QBitArray mFlags(7); | 226 | QBitArray mFlags(7); |
225 | QStringList addresslist; | 227 | QStringList addresslist; |
226 | 228 | ||
227 | if (!m_att) { | 229 | if (!m_att) { |
228 | return m; | 230 | return m; |
229 | } | 231 | } |
230 | m = new RecMail(); | 232 | m = new RecMail(); |
231 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { | 233 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { |
232 | current = c; | 234 | current = c; |
233 | size = 0; | 235 | size = 0; |
234 | item = (mailimap_msg_att_item*)current->data; | 236 | item = (mailimap_msg_att_item*)current->data; |
235 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 237 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
236 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; | 238 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
237 | if (!flist->att_list) { | 239 | if (!flist->att_list) { |
238 | continue; | 240 | continue; |
239 | } | 241 | } |
240 | cf = flist->att_list->first; | 242 | cf = flist->att_list->first; |
241 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { | 243 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { |
242 | cflag = (mailimap_flag_fetch*)cf->data; | 244 | cflag = (mailimap_flag_fetch*)cf->data; |
243 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { | 245 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { |
244 | switch (cflag->fl_flag->fl_type) { | 246 | switch (cflag->fl_flag->fl_type) { |
245 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ | 247 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ |
246 | mFlags.setBit(FLAG_ANSWERED); | 248 | mFlags.setBit(FLAG_ANSWERED); |
247 | break; | 249 | break; |
248 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ | 250 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ |
249 | mFlags.setBit(FLAG_FLAGGED); | 251 | mFlags.setBit(FLAG_FLAGGED); |
250 | break; | 252 | break; |
251 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ | 253 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ |
252 | mFlags.setBit(FLAG_DELETED); | 254 | mFlags.setBit(FLAG_DELETED); |
253 | break; | 255 | break; |
254 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ | 256 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ |
255 | mFlags.setBit(FLAG_SEEN); | 257 | mFlags.setBit(FLAG_SEEN); |
256 | break; | 258 | break; |
257 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ | 259 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ |
258 | mFlags.setBit(FLAG_DRAFT); | 260 | mFlags.setBit(FLAG_DRAFT); |
259 | break; | 261 | break; |
260 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ | 262 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ |
261 | break; | 263 | break; |
262 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ | 264 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ |
263 | break; | 265 | break; |
264 | default: | 266 | default: |
265 | break; | 267 | break; |
266 | } | 268 | } |
267 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { | 269 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { |
268 | mFlags.setBit(FLAG_RECENT); | 270 | mFlags.setBit(FLAG_RECENT); |
269 | } | 271 | } |
270 | } | 272 | } |
271 | continue; | 273 | continue; |
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.cpp b/noncore/net/mail/libmailwrapper/mailwrapper.cpp index 3ffc274..96602c2 100644 --- a/noncore/net/mail/libmailwrapper/mailwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mailwrapper.cpp | |||
@@ -1,104 +1,114 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <sys/stat.h> | 2 | #include <sys/stat.h> |
3 | #include <sys/types.h> | 3 | #include <sys/types.h> |
4 | #include <unistd.h> | 4 | #include <unistd.h> |
5 | #include <fcntl.h> | 5 | #include <fcntl.h> |
6 | #include <string.h> | 6 | #include <string.h> |
7 | #include <qdir.h> | 7 | #include <qdir.h> |
8 | 8 | ||
9 | #include "mailwrapper.h" | 9 | #include "mailwrapper.h" |
10 | #include "logindialog.h" | 10 | #include "logindialog.h" |
11 | //#include "mail.h" | 11 | //#include "mail.h" |
12 | #include "defines.h" | 12 | #include "defines.h" |
13 | 13 | ||
14 | Attachment::Attachment( DocLnk lnk ) | 14 | Attachment::Attachment( DocLnk lnk ) |
15 | { | 15 | { |
16 | doc = lnk; | 16 | doc = lnk; |
17 | size = QFileInfo( doc.file() ).size(); | 17 | size = QFileInfo( doc.file() ).size(); |
18 | } | 18 | } |
19 | 19 | ||
20 | Folder::Folder(const QString&tmp_name ) | 20 | Folder::Folder(const QString&tmp_name ) |
21 | { | 21 | { |
22 | name = tmp_name; | 22 | name = tmp_name; |
23 | nameDisplay = name; | 23 | nameDisplay = name; |
24 | 24 | ||
25 | for ( int pos = nameDisplay.find( '&' ); pos != -1; | 25 | for ( int pos = nameDisplay.find( '&' ); pos != -1; |
26 | pos = nameDisplay.find( '&' ) ) { | 26 | pos = nameDisplay.find( '&' ) ) { |
27 | int end = nameDisplay.find( '-' ); | 27 | int end = nameDisplay.find( '-' ); |
28 | if ( end == -1 || end <= pos ) break; | 28 | if ( end == -1 || end <= pos ) break; |
29 | QString str64 = nameDisplay.mid( pos + 1, end - pos - 1 ); | 29 | QString str64 = nameDisplay.mid( pos + 1, end - pos - 1 ); |
30 | // TODO: do real base64 decoding here ! | 30 | // TODO: do real base64 decoding here ! |
31 | if ( str64.compare( "APw" ) == 0 ) { | 31 | if ( str64.compare( "APw" ) == 0 ) { |
32 | nameDisplay = nameDisplay.replace( pos, end - pos + 1, "ue" ); | 32 | nameDisplay = nameDisplay.replace( pos, end - pos + 1, "ue" ); |
33 | } else if ( str64.compare( "APY" ) == 0 ) { | 33 | } else if ( str64.compare( "APY" ) == 0 ) { |
34 | nameDisplay = nameDisplay.replace( pos, end - pos + 1, "oe" ); | 34 | nameDisplay = nameDisplay.replace( pos, end - pos + 1, "oe" ); |
35 | } | 35 | } |
36 | } | 36 | } |
37 | |||
38 | qDebug( "folder " + name + " - displayed as " + nameDisplay ); | 37 | qDebug( "folder " + name + " - displayed as " + nameDisplay ); |
39 | } | 38 | } |
40 | 39 | ||
40 | |||
41 | IMAPFolder::IMAPFolder(const QString&name,bool select,const QString&prefix ) | ||
42 | : Folder( name ),m_MaySelect(select) | ||
43 | { | ||
44 | if (prefix.length()>0) { | ||
45 | if (nameDisplay.startsWith(prefix) && nameDisplay.length()>prefix.length()) { | ||
46 | nameDisplay=nameDisplay.right(nameDisplay.length()-prefix.length()); | ||
47 | } | ||
48 | } | ||
49 | } | ||
50 | |||
41 | MailWrapper::MailWrapper( Settings *s ) | 51 | MailWrapper::MailWrapper( Settings *s ) |
42 | : QObject() | 52 | : QObject() |
43 | { | 53 | { |
44 | settings = s; | 54 | settings = s; |
45 | } | 55 | } |
46 | 56 | ||
47 | QString MailWrapper::mailsmtpError( int errnum ) | 57 | QString MailWrapper::mailsmtpError( int errnum ) |
48 | { | 58 | { |
49 | switch ( errnum ) { | 59 | switch ( errnum ) { |
50 | case MAILSMTP_NO_ERROR: | 60 | case MAILSMTP_NO_ERROR: |
51 | return tr( "No error" ); | 61 | return tr( "No error" ); |
52 | case MAILSMTP_ERROR_UNEXPECTED_CODE: | 62 | case MAILSMTP_ERROR_UNEXPECTED_CODE: |
53 | return tr( "Unexpected error code" ); | 63 | return tr( "Unexpected error code" ); |
54 | case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: | 64 | case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: |
55 | return tr( "Service not available" ); | 65 | return tr( "Service not available" ); |
56 | case MAILSMTP_ERROR_STREAM: | 66 | case MAILSMTP_ERROR_STREAM: |
57 | return tr( "Stream error" ); | 67 | return tr( "Stream error" ); |
58 | case MAILSMTP_ERROR_HOSTNAME: | 68 | case MAILSMTP_ERROR_HOSTNAME: |
59 | return tr( "gethostname() failed" ); | 69 | return tr( "gethostname() failed" ); |
60 | case MAILSMTP_ERROR_NOT_IMPLEMENTED: | 70 | case MAILSMTP_ERROR_NOT_IMPLEMENTED: |
61 | return tr( "Not implemented" ); | 71 | return tr( "Not implemented" ); |
62 | case MAILSMTP_ERROR_ACTION_NOT_TAKEN: | 72 | case MAILSMTP_ERROR_ACTION_NOT_TAKEN: |
63 | return tr( "Error, action not taken" ); | 73 | return tr( "Error, action not taken" ); |
64 | case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: | 74 | case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: |
65 | return tr( "Data exceeds storage allocation" ); | 75 | return tr( "Data exceeds storage allocation" ); |
66 | case MAILSMTP_ERROR_IN_PROCESSING: | 76 | case MAILSMTP_ERROR_IN_PROCESSING: |
67 | return tr( "Error in processing" ); | 77 | return tr( "Error in processing" ); |
68 | // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE: | 78 | // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE: |
69 | // return tr( "Insufficient system storage" ); | 79 | // return tr( "Insufficient system storage" ); |
70 | case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: | 80 | case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: |
71 | return tr( "Mailbox unavailable" ); | 81 | return tr( "Mailbox unavailable" ); |
72 | case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: | 82 | case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: |
73 | return tr( "Mailbox name not allowed" ); | 83 | return tr( "Mailbox name not allowed" ); |
74 | case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: | 84 | case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: |
75 | return tr( "Bad command sequence" ); | 85 | return tr( "Bad command sequence" ); |
76 | case MAILSMTP_ERROR_USER_NOT_LOCAL: | 86 | case MAILSMTP_ERROR_USER_NOT_LOCAL: |
77 | return tr( "User not local" ); | 87 | return tr( "User not local" ); |
78 | case MAILSMTP_ERROR_TRANSACTION_FAILED: | 88 | case MAILSMTP_ERROR_TRANSACTION_FAILED: |
79 | return tr( "Transaction failed" ); | 89 | return tr( "Transaction failed" ); |
80 | case MAILSMTP_ERROR_MEMORY: | 90 | case MAILSMTP_ERROR_MEMORY: |
81 | return tr( "Memory error" ); | 91 | return tr( "Memory error" ); |
82 | case MAILSMTP_ERROR_CONNECTION_REFUSED: | 92 | case MAILSMTP_ERROR_CONNECTION_REFUSED: |
83 | return tr( "Connection refused" ); | 93 | return tr( "Connection refused" ); |
84 | default: | 94 | default: |
85 | return tr( "Unknown error code" ); | 95 | return tr( "Unknown error code" ); |
86 | } | 96 | } |
87 | } | 97 | } |
88 | 98 | ||
89 | mailimf_mailbox *MailWrapper::newMailbox(const QString&name, const QString&mail ) | 99 | mailimf_mailbox *MailWrapper::newMailbox(const QString&name, const QString&mail ) |
90 | { | 100 | { |
91 | return mailimf_mailbox_new( strdup( name.latin1() ), | 101 | return mailimf_mailbox_new( strdup( name.latin1() ), |
92 | strdup( mail.latin1() ) ); | 102 | strdup( mail.latin1() ) ); |
93 | } | 103 | } |
94 | 104 | ||
95 | mailimf_address_list *MailWrapper::parseAddresses(const QString&addr ) | 105 | mailimf_address_list *MailWrapper::parseAddresses(const QString&addr ) |
96 | { | 106 | { |
97 | mailimf_address_list *addresses; | 107 | mailimf_address_list *addresses; |
98 | 108 | ||
99 | if ( addr.isEmpty() ) return NULL; | 109 | if ( addr.isEmpty() ) return NULL; |
100 | 110 | ||
101 | addresses = mailimf_address_list_new_empty(); | 111 | addresses = mailimf_address_list_new_empty(); |
102 | 112 | ||
103 | QStringList list = QStringList::split( ',', addr ); | 113 | QStringList list = QStringList::split( ',', addr ); |
104 | QStringList::Iterator it; | 114 | QStringList::Iterator it; |
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.h b/noncore/net/mail/libmailwrapper/mailwrapper.h index 34fd5c5..6994dd8 100644 --- a/noncore/net/mail/libmailwrapper/mailwrapper.h +++ b/noncore/net/mail/libmailwrapper/mailwrapper.h | |||
@@ -15,109 +15,109 @@ | |||
15 | 15 | ||
16 | class Attachment | 16 | class Attachment |
17 | { | 17 | { |
18 | public: | 18 | public: |
19 | Attachment( DocLnk lnk ); | 19 | Attachment( DocLnk lnk ); |
20 | virtual ~Attachment(){} | 20 | virtual ~Attachment(){} |
21 | const QString getFileName()const{ return doc.file(); } | 21 | const QString getFileName()const{ return doc.file(); } |
22 | const QString getName()const{ return doc.name(); } | 22 | const QString getName()const{ return doc.name(); } |
23 | const QString getMimeType()const{ return doc.type(); } | 23 | const QString getMimeType()const{ return doc.type(); } |
24 | const QPixmap getPixmap()const{ return doc.pixmap(); } | 24 | const QPixmap getPixmap()const{ return doc.pixmap(); } |
25 | const int getSize()const { return size; } | 25 | const int getSize()const { return size; } |
26 | DocLnk getDocLnk() { return doc; } | 26 | DocLnk getDocLnk() { return doc; } |
27 | 27 | ||
28 | protected: | 28 | protected: |
29 | DocLnk doc; | 29 | DocLnk doc; |
30 | int size; | 30 | int size; |
31 | 31 | ||
32 | }; | 32 | }; |
33 | 33 | ||
34 | class Mail | 34 | class Mail |
35 | { | 35 | { |
36 | public: | 36 | public: |
37 | Mail(); | 37 | Mail(); |
38 | /* Possible that this destructor must not be declared virtual | 38 | /* Possible that this destructor must not be declared virtual |
39 | * 'cause it seems that it will never have some child classes. | 39 | * 'cause it seems that it will never have some child classes. |
40 | * in this case this object will not get a virtual table -> memory and | 40 | * in this case this object will not get a virtual table -> memory and |
41 | * speed will be a little bit better? | 41 | * speed will be a little bit better? |
42 | */ | 42 | */ |
43 | virtual ~Mail(){} | 43 | virtual ~Mail(){} |
44 | void addAttachment( Attachment *att ) { attList.append( att ); } | 44 | void addAttachment( Attachment *att ) { attList.append( att ); } |
45 | const QList<Attachment>& getAttachments()const { return attList; } | 45 | const QList<Attachment>& getAttachments()const { return attList; } |
46 | void removeAttachment( Attachment *att ) { attList.remove( att ); } | 46 | void removeAttachment( Attachment *att ) { attList.remove( att ); } |
47 | const QString&getName()const { return name; } | 47 | const QString&getName()const { return name; } |
48 | void setName( QString s ) { name = s; } | 48 | void setName( QString s ) { name = s; } |
49 | const QString&getMail()const{ return mail; } | 49 | const QString&getMail()const{ return mail; } |
50 | void setMail( const QString&s ) { mail = s; } | 50 | void setMail( const QString&s ) { mail = s; } |
51 | const QString&getTo()const{ return to; } | 51 | const QString&getTo()const{ return to; } |
52 | void setTo( const QString&s ) { to = s; } | 52 | void setTo( const QString&s ) { to = s; } |
53 | const QString&getCC()const{ return cc; } | 53 | const QString&getCC()const{ return cc; } |
54 | void setCC( const QString&s ) { cc = s; } | 54 | void setCC( const QString&s ) { cc = s; } |
55 | const QString&getBCC()const { return bcc; } | 55 | const QString&getBCC()const { return bcc; } |
56 | void setBCC( const QString&s ) { bcc = s; } | 56 | void setBCC( const QString&s ) { bcc = s; } |
57 | const QString&getMessage()const { return message; } | 57 | const QString&getMessage()const { return message; } |
58 | void setMessage( const QString&s ) { message = s; } | 58 | void setMessage( const QString&s ) { message = s; } |
59 | const QString&getSubject()const { return subject; } | 59 | const QString&getSubject()const { return subject; } |
60 | void setSubject( const QString&s ) { subject = s; } | 60 | void setSubject( const QString&s ) { subject = s; } |
61 | const QString&getReply()const{ return reply; } | 61 | const QString&getReply()const{ return reply; } |
62 | void setReply( const QString&a ) { reply = a; } | 62 | void setReply( const QString&a ) { reply = a; } |
63 | 63 | ||
64 | private: | 64 | private: |
65 | QList<Attachment> attList; | 65 | QList<Attachment> attList; |
66 | QString name, mail, to, cc, bcc, reply, subject, message; | 66 | QString name, mail, to, cc, bcc, reply, subject, message; |
67 | }; | 67 | }; |
68 | 68 | ||
69 | class Folder : public QObject | 69 | class Folder : public QObject |
70 | { | 70 | { |
71 | Q_OBJECT | 71 | Q_OBJECT |
72 | 72 | ||
73 | public: | 73 | public: |
74 | Folder( const QString&init_name ); | 74 | Folder( const QString&init_name ); |
75 | const QString&getDisplayName()const { return nameDisplay; } | 75 | const QString&getDisplayName()const { return nameDisplay; } |
76 | const QString&getName()const { return name; } | 76 | const QString&getName()const { return name; } |
77 | virtual bool may_select()const{return true;}; | 77 | virtual bool may_select()const{return true;}; |
78 | 78 | ||
79 | private: | 79 | protected: |
80 | QString nameDisplay, name; | 80 | QString nameDisplay, name; |
81 | 81 | ||
82 | }; | 82 | }; |
83 | 83 | ||
84 | class IMAPFolder : public Folder | 84 | class IMAPFolder : public Folder |
85 | { | 85 | { |
86 | public: | 86 | public: |
87 | IMAPFolder( QString name,bool select=true ) : Folder( name ),m_MaySelect(select) {} | 87 | IMAPFolder(const QString&name,bool select=true,const QString&prefix="" ); |
88 | virtual bool may_select()const{return m_MaySelect;} | 88 | virtual bool may_select()const{return m_MaySelect;} |
89 | private: | 89 | private: |
90 | bool m_MaySelect; | 90 | bool m_MaySelect; |
91 | }; | 91 | }; |
92 | 92 | ||
93 | class MailWrapper : public QObject | 93 | class MailWrapper : public QObject |
94 | { | 94 | { |
95 | Q_OBJECT | 95 | Q_OBJECT |
96 | 96 | ||
97 | public: | 97 | public: |
98 | MailWrapper( Settings *s ); | 98 | MailWrapper( Settings *s ); |
99 | void sendMail( Mail mail ); | 99 | void sendMail( Mail mail ); |
100 | 100 | ||
101 | private: | 101 | private: |
102 | mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); | 102 | mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); |
103 | mailimf_address_list *parseAddresses(const QString&addr ); | 103 | mailimf_address_list *parseAddresses(const QString&addr ); |
104 | mailimf_fields *createImfFields( Mail *mail ); | 104 | mailimf_fields *createImfFields( Mail *mail ); |
105 | mailmime *buildTxtPart( QString str ); | 105 | mailmime *buildTxtPart( QString str ); |
106 | mailmime *buildFilePart( QString filename, QString mimetype ); | 106 | mailmime *buildFilePart( QString filename, QString mimetype ); |
107 | void addFileParts( mailmime *message, QList<Attachment> files ); | 107 | void addFileParts( mailmime *message, QList<Attachment> files ); |
108 | mailmime *createMimeMail( Mail *mail ); | 108 | mailmime *createMimeMail( Mail *mail ); |
109 | void smtpSend( mailmime *mail ); | 109 | void smtpSend( mailmime *mail ); |
110 | mailimf_field *getField( mailimf_fields *fields, int type ); | 110 | mailimf_field *getField( mailimf_fields *fields, int type ); |
111 | clist *createRcptList( mailimf_fields *fields ); | 111 | clist *createRcptList( mailimf_fields *fields ); |
112 | char *getFrom( mailmime *mail ); | 112 | char *getFrom( mailmime *mail ); |
113 | SMTPaccount *getAccount( QString from ); | 113 | SMTPaccount *getAccount( QString from ); |
114 | void writeToFile( QString file, mailmime *mail ); | 114 | void writeToFile( QString file, mailmime *mail ); |
115 | void readFromFile( QString file, char **data, size_t *size ); | 115 | void readFromFile( QString file, char **data, size_t *size ); |
116 | static QString mailsmtpError( int err ); | 116 | static QString mailsmtpError( int err ); |
117 | static QString getTmpFile(); | 117 | static QString getTmpFile(); |
118 | 118 | ||
119 | Settings *settings; | 119 | Settings *settings; |
120 | 120 | ||
121 | }; | 121 | }; |
122 | 122 | ||
123 | #endif | 123 | #endif |
diff --git a/noncore/net/mail/mailwrapper.cpp b/noncore/net/mail/mailwrapper.cpp index 3ffc274..96602c2 100644 --- a/noncore/net/mail/mailwrapper.cpp +++ b/noncore/net/mail/mailwrapper.cpp | |||
@@ -1,104 +1,114 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <sys/stat.h> | 2 | #include <sys/stat.h> |
3 | #include <sys/types.h> | 3 | #include <sys/types.h> |
4 | #include <unistd.h> | 4 | #include <unistd.h> |
5 | #include <fcntl.h> | 5 | #include <fcntl.h> |
6 | #include <string.h> | 6 | #include <string.h> |
7 | #include <qdir.h> | 7 | #include <qdir.h> |
8 | 8 | ||
9 | #include "mailwrapper.h" | 9 | #include "mailwrapper.h" |
10 | #include "logindialog.h" | 10 | #include "logindialog.h" |
11 | //#include "mail.h" | 11 | //#include "mail.h" |
12 | #include "defines.h" | 12 | #include "defines.h" |
13 | 13 | ||
14 | Attachment::Attachment( DocLnk lnk ) | 14 | Attachment::Attachment( DocLnk lnk ) |
15 | { | 15 | { |
16 | doc = lnk; | 16 | doc = lnk; |
17 | size = QFileInfo( doc.file() ).size(); | 17 | size = QFileInfo( doc.file() ).size(); |
18 | } | 18 | } |
19 | 19 | ||
20 | Folder::Folder(const QString&tmp_name ) | 20 | Folder::Folder(const QString&tmp_name ) |
21 | { | 21 | { |
22 | name = tmp_name; | 22 | name = tmp_name; |
23 | nameDisplay = name; | 23 | nameDisplay = name; |
24 | 24 | ||
25 | for ( int pos = nameDisplay.find( '&' ); pos != -1; | 25 | for ( int pos = nameDisplay.find( '&' ); pos != -1; |
26 | pos = nameDisplay.find( '&' ) ) { | 26 | pos = nameDisplay.find( '&' ) ) { |
27 | int end = nameDisplay.find( '-' ); | 27 | int end = nameDisplay.find( '-' ); |
28 | if ( end == -1 || end <= pos ) break; | 28 | if ( end == -1 || end <= pos ) break; |
29 | QString str64 = nameDisplay.mid( pos + 1, end - pos - 1 ); | 29 | QString str64 = nameDisplay.mid( pos + 1, end - pos - 1 ); |
30 | // TODO: do real base64 decoding here ! | 30 | // TODO: do real base64 decoding here ! |
31 | if ( str64.compare( "APw" ) == 0 ) { | 31 | if ( str64.compare( "APw" ) == 0 ) { |
32 | nameDisplay = nameDisplay.replace( pos, end - pos + 1, "ue" ); | 32 | nameDisplay = nameDisplay.replace( pos, end - pos + 1, "ue" ); |
33 | } else if ( str64.compare( "APY" ) == 0 ) { | 33 | } else if ( str64.compare( "APY" ) == 0 ) { |
34 | nameDisplay = nameDisplay.replace( pos, end - pos + 1, "oe" ); | 34 | nameDisplay = nameDisplay.replace( pos, end - pos + 1, "oe" ); |
35 | } | 35 | } |
36 | } | 36 | } |
37 | |||
38 | qDebug( "folder " + name + " - displayed as " + nameDisplay ); | 37 | qDebug( "folder " + name + " - displayed as " + nameDisplay ); |
39 | } | 38 | } |
40 | 39 | ||
40 | |||
41 | IMAPFolder::IMAPFolder(const QString&name,bool select,const QString&prefix ) | ||
42 | : Folder( name ),m_MaySelect(select) | ||
43 | { | ||
44 | if (prefix.length()>0) { | ||
45 | if (nameDisplay.startsWith(prefix) && nameDisplay.length()>prefix.length()) { | ||
46 | nameDisplay=nameDisplay.right(nameDisplay.length()-prefix.length()); | ||
47 | } | ||
48 | } | ||
49 | } | ||
50 | |||
41 | MailWrapper::MailWrapper( Settings *s ) | 51 | MailWrapper::MailWrapper( Settings *s ) |
42 | : QObject() | 52 | : QObject() |
43 | { | 53 | { |
44 | settings = s; | 54 | settings = s; |
45 | } | 55 | } |
46 | 56 | ||
47 | QString MailWrapper::mailsmtpError( int errnum ) | 57 | QString MailWrapper::mailsmtpError( int errnum ) |
48 | { | 58 | { |
49 | switch ( errnum ) { | 59 | switch ( errnum ) { |
50 | case MAILSMTP_NO_ERROR: | 60 | case MAILSMTP_NO_ERROR: |
51 | return tr( "No error" ); | 61 | return tr( "No error" ); |
52 | case MAILSMTP_ERROR_UNEXPECTED_CODE: | 62 | case MAILSMTP_ERROR_UNEXPECTED_CODE: |
53 | return tr( "Unexpected error code" ); | 63 | return tr( "Unexpected error code" ); |
54 | case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: | 64 | case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: |
55 | return tr( "Service not available" ); | 65 | return tr( "Service not available" ); |
56 | case MAILSMTP_ERROR_STREAM: | 66 | case MAILSMTP_ERROR_STREAM: |
57 | return tr( "Stream error" ); | 67 | return tr( "Stream error" ); |
58 | case MAILSMTP_ERROR_HOSTNAME: | 68 | case MAILSMTP_ERROR_HOSTNAME: |
59 | return tr( "gethostname() failed" ); | 69 | return tr( "gethostname() failed" ); |
60 | case MAILSMTP_ERROR_NOT_IMPLEMENTED: | 70 | case MAILSMTP_ERROR_NOT_IMPLEMENTED: |
61 | return tr( "Not implemented" ); | 71 | return tr( "Not implemented" ); |
62 | case MAILSMTP_ERROR_ACTION_NOT_TAKEN: | 72 | case MAILSMTP_ERROR_ACTION_NOT_TAKEN: |
63 | return tr( "Error, action not taken" ); | 73 | return tr( "Error, action not taken" ); |
64 | case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: | 74 | case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: |
65 | return tr( "Data exceeds storage allocation" ); | 75 | return tr( "Data exceeds storage allocation" ); |
66 | case MAILSMTP_ERROR_IN_PROCESSING: | 76 | case MAILSMTP_ERROR_IN_PROCESSING: |
67 | return tr( "Error in processing" ); | 77 | return tr( "Error in processing" ); |
68 | // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE: | 78 | // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE: |
69 | // return tr( "Insufficient system storage" ); | 79 | // return tr( "Insufficient system storage" ); |
70 | case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: | 80 | case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: |
71 | return tr( "Mailbox unavailable" ); | 81 | return tr( "Mailbox unavailable" ); |
72 | case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: | 82 | case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: |
73 | return tr( "Mailbox name not allowed" ); | 83 | return tr( "Mailbox name not allowed" ); |
74 | case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: | 84 | case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: |
75 | return tr( "Bad command sequence" ); | 85 | return tr( "Bad command sequence" ); |
76 | case MAILSMTP_ERROR_USER_NOT_LOCAL: | 86 | case MAILSMTP_ERROR_USER_NOT_LOCAL: |
77 | return tr( "User not local" ); | 87 | return tr( "User not local" ); |
78 | case MAILSMTP_ERROR_TRANSACTION_FAILED: | 88 | case MAILSMTP_ERROR_TRANSACTION_FAILED: |
79 | return tr( "Transaction failed" ); | 89 | return tr( "Transaction failed" ); |
80 | case MAILSMTP_ERROR_MEMORY: | 90 | case MAILSMTP_ERROR_MEMORY: |
81 | return tr( "Memory error" ); | 91 | return tr( "Memory error" ); |
82 | case MAILSMTP_ERROR_CONNECTION_REFUSED: | 92 | case MAILSMTP_ERROR_CONNECTION_REFUSED: |
83 | return tr( "Connection refused" ); | 93 | return tr( "Connection refused" ); |
84 | default: | 94 | default: |
85 | return tr( "Unknown error code" ); | 95 | return tr( "Unknown error code" ); |
86 | } | 96 | } |
87 | } | 97 | } |
88 | 98 | ||
89 | mailimf_mailbox *MailWrapper::newMailbox(const QString&name, const QString&mail ) | 99 | mailimf_mailbox *MailWrapper::newMailbox(const QString&name, const QString&mail ) |
90 | { | 100 | { |
91 | return mailimf_mailbox_new( strdup( name.latin1() ), | 101 | return mailimf_mailbox_new( strdup( name.latin1() ), |
92 | strdup( mail.latin1() ) ); | 102 | strdup( mail.latin1() ) ); |
93 | } | 103 | } |
94 | 104 | ||
95 | mailimf_address_list *MailWrapper::parseAddresses(const QString&addr ) | 105 | mailimf_address_list *MailWrapper::parseAddresses(const QString&addr ) |
96 | { | 106 | { |
97 | mailimf_address_list *addresses; | 107 | mailimf_address_list *addresses; |
98 | 108 | ||
99 | if ( addr.isEmpty() ) return NULL; | 109 | if ( addr.isEmpty() ) return NULL; |
100 | 110 | ||
101 | addresses = mailimf_address_list_new_empty(); | 111 | addresses = mailimf_address_list_new_empty(); |
102 | 112 | ||
103 | QStringList list = QStringList::split( ',', addr ); | 113 | QStringList list = QStringList::split( ',', addr ); |
104 | QStringList::Iterator it; | 114 | QStringList::Iterator it; |
diff --git a/noncore/net/mail/mailwrapper.h b/noncore/net/mail/mailwrapper.h index 34fd5c5..6994dd8 100644 --- a/noncore/net/mail/mailwrapper.h +++ b/noncore/net/mail/mailwrapper.h | |||
@@ -15,109 +15,109 @@ | |||
15 | 15 | ||
16 | class Attachment | 16 | class Attachment |
17 | { | 17 | { |
18 | public: | 18 | public: |
19 | Attachment( DocLnk lnk ); | 19 | Attachment( DocLnk lnk ); |
20 | virtual ~Attachment(){} | 20 | virtual ~Attachment(){} |
21 | const QString getFileName()const{ return doc.file(); } | 21 | const QString getFileName()const{ return doc.file(); } |
22 | const QString getName()const{ return doc.name(); } | 22 | const QString getName()const{ return doc.name(); } |
23 | const QString getMimeType()const{ return doc.type(); } | 23 | const QString getMimeType()const{ return doc.type(); } |
24 | const QPixmap getPixmap()const{ return doc.pixmap(); } | 24 | const QPixmap getPixmap()const{ return doc.pixmap(); } |
25 | const int getSize()const { return size; } | 25 | const int getSize()const { return size; } |
26 | DocLnk getDocLnk() { return doc; } | 26 | DocLnk getDocLnk() { return doc; } |
27 | 27 | ||
28 | protected: | 28 | protected: |
29 | DocLnk doc; | 29 | DocLnk doc; |
30 | int size; | 30 | int size; |
31 | 31 | ||
32 | }; | 32 | }; |
33 | 33 | ||
34 | class Mail | 34 | class Mail |
35 | { | 35 | { |
36 | public: | 36 | public: |
37 | Mail(); | 37 | Mail(); |
38 | /* Possible that this destructor must not be declared virtual | 38 | /* Possible that this destructor must not be declared virtual |
39 | * 'cause it seems that it will never have some child classes. | 39 | * 'cause it seems that it will never have some child classes. |
40 | * in this case this object will not get a virtual table -> memory and | 40 | * in this case this object will not get a virtual table -> memory and |
41 | * speed will be a little bit better? | 41 | * speed will be a little bit better? |
42 | */ | 42 | */ |
43 | virtual ~Mail(){} | 43 | virtual ~Mail(){} |
44 | void addAttachment( Attachment *att ) { attList.append( att ); } | 44 | void addAttachment( Attachment *att ) { attList.append( att ); } |
45 | const QList<Attachment>& getAttachments()const { return attList; } | 45 | const QList<Attachment>& getAttachments()const { return attList; } |
46 | void removeAttachment( Attachment *att ) { attList.remove( att ); } | 46 | void removeAttachment( Attachment *att ) { attList.remove( att ); } |
47 | const QString&getName()const { return name; } | 47 | const QString&getName()const { return name; } |
48 | void setName( QString s ) { name = s; } | 48 | void setName( QString s ) { name = s; } |
49 | const QString&getMail()const{ return mail; } | 49 | const QString&getMail()const{ return mail; } |
50 | void setMail( const QString&s ) { mail = s; } | 50 | void setMail( const QString&s ) { mail = s; } |
51 | const QString&getTo()const{ return to; } | 51 | const QString&getTo()const{ return to; } |
52 | void setTo( const QString&s ) { to = s; } | 52 | void setTo( const QString&s ) { to = s; } |
53 | const QString&getCC()const{ return cc; } | 53 | const QString&getCC()const{ return cc; } |
54 | void setCC( const QString&s ) { cc = s; } | 54 | void setCC( const QString&s ) { cc = s; } |
55 | const QString&getBCC()const { return bcc; } | 55 | const QString&getBCC()const { return bcc; } |
56 | void setBCC( const QString&s ) { bcc = s; } | 56 | void setBCC( const QString&s ) { bcc = s; } |
57 | const QString&getMessage()const { return message; } | 57 | const QString&getMessage()const { return message; } |
58 | void setMessage( const QString&s ) { message = s; } | 58 | void setMessage( const QString&s ) { message = s; } |
59 | const QString&getSubject()const { return subject; } | 59 | const QString&getSubject()const { return subject; } |
60 | void setSubject( const QString&s ) { subject = s; } | 60 | void setSubject( const QString&s ) { subject = s; } |
61 | const QString&getReply()const{ return reply; } | 61 | const QString&getReply()const{ return reply; } |
62 | void setReply( const QString&a ) { reply = a; } | 62 | void setReply( const QString&a ) { reply = a; } |
63 | 63 | ||
64 | private: | 64 | private: |
65 | QList<Attachment> attList; | 65 | QList<Attachment> attList; |
66 | QString name, mail, to, cc, bcc, reply, subject, message; | 66 | QString name, mail, to, cc, bcc, reply, subject, message; |
67 | }; | 67 | }; |
68 | 68 | ||
69 | class Folder : public QObject | 69 | class Folder : public QObject |
70 | { | 70 | { |
71 | Q_OBJECT | 71 | Q_OBJECT |
72 | 72 | ||
73 | public: | 73 | public: |
74 | Folder( const QString&init_name ); | 74 | Folder( const QString&init_name ); |
75 | const QString&getDisplayName()const { return nameDisplay; } | 75 | const QString&getDisplayName()const { return nameDisplay; } |
76 | const QString&getName()const { return name; } | 76 | const QString&getName()const { return name; } |
77 | virtual bool may_select()const{return true;}; | 77 | virtual bool may_select()const{return true;}; |
78 | 78 | ||
79 | private: | 79 | protected: |
80 | QString nameDisplay, name; | 80 | QString nameDisplay, name; |
81 | 81 | ||
82 | }; | 82 | }; |
83 | 83 | ||
84 | class IMAPFolder : public Folder | 84 | class IMAPFolder : public Folder |
85 | { | 85 | { |
86 | public: | 86 | public: |
87 | IMAPFolder( QString name,bool select=true ) : Folder( name ),m_MaySelect(select) {} | 87 | IMAPFolder(const QString&name,bool select=true,const QString&prefix="" ); |
88 | virtual bool may_select()const{return m_MaySelect;} | 88 | virtual bool may_select()const{return m_MaySelect;} |
89 | private: | 89 | private: |
90 | bool m_MaySelect; | 90 | bool m_MaySelect; |
91 | }; | 91 | }; |
92 | 92 | ||
93 | class MailWrapper : public QObject | 93 | class MailWrapper : public QObject |
94 | { | 94 | { |
95 | Q_OBJECT | 95 | Q_OBJECT |
96 | 96 | ||
97 | public: | 97 | public: |
98 | MailWrapper( Settings *s ); | 98 | MailWrapper( Settings *s ); |
99 | void sendMail( Mail mail ); | 99 | void sendMail( Mail mail ); |
100 | 100 | ||
101 | private: | 101 | private: |
102 | mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); | 102 | mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); |
103 | mailimf_address_list *parseAddresses(const QString&addr ); | 103 | mailimf_address_list *parseAddresses(const QString&addr ); |
104 | mailimf_fields *createImfFields( Mail *mail ); | 104 | mailimf_fields *createImfFields( Mail *mail ); |
105 | mailmime *buildTxtPart( QString str ); | 105 | mailmime *buildTxtPart( QString str ); |
106 | mailmime *buildFilePart( QString filename, QString mimetype ); | 106 | mailmime *buildFilePart( QString filename, QString mimetype ); |
107 | void addFileParts( mailmime *message, QList<Attachment> files ); | 107 | void addFileParts( mailmime *message, QList<Attachment> files ); |
108 | mailmime *createMimeMail( Mail *mail ); | 108 | mailmime *createMimeMail( Mail *mail ); |
109 | void smtpSend( mailmime *mail ); | 109 | void smtpSend( mailmime *mail ); |
110 | mailimf_field *getField( mailimf_fields *fields, int type ); | 110 | mailimf_field *getField( mailimf_fields *fields, int type ); |
111 | clist *createRcptList( mailimf_fields *fields ); | 111 | clist *createRcptList( mailimf_fields *fields ); |
112 | char *getFrom( mailmime *mail ); | 112 | char *getFrom( mailmime *mail ); |
113 | SMTPaccount *getAccount( QString from ); | 113 | SMTPaccount *getAccount( QString from ); |
114 | void writeToFile( QString file, mailmime *mail ); | 114 | void writeToFile( QString file, mailmime *mail ); |
115 | void readFromFile( QString file, char **data, size_t *size ); | 115 | void readFromFile( QString file, char **data, size_t *size ); |
116 | static QString mailsmtpError( int err ); | 116 | static QString mailsmtpError( int err ); |
117 | static QString getTmpFile(); | 117 | static QString getTmpFile(); |
118 | 118 | ||
119 | Settings *settings; | 119 | Settings *settings; |
120 | 120 | ||
121 | }; | 121 | }; |
122 | 122 | ||
123 | #endif | 123 | #endif |