Diffstat (limited to 'kmicromail/libmailwrapper/imapwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp index 5441a9b..91332c3 100644 --- a/kmicromail/libmailwrapper/imapwrapper.cpp +++ b/kmicromail/libmailwrapper/imapwrapper.cpp | |||
@@ -78,193 +78,193 @@ bool IMAPwrapper::start_tls(bool force_tls) | |||
78 | 78 | ||
79 | err = mailimap_capability(m_imap,&cap_data); | 79 | err = mailimap_capability(m_imap,&cap_data); |
80 | if (err != MAILIMAP_NO_ERROR) { | 80 | if (err != MAILIMAP_NO_ERROR) { |
81 | Global::statusMessage("error getting capabilities!"); | 81 | Global::statusMessage("error getting capabilities!"); |
82 | return false; | 82 | return false; |
83 | } | 83 | } |
84 | clistiter * cur; | 84 | clistiter * cur; |
85 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { | 85 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { |
86 | struct mailimap_capability * cap; | 86 | struct mailimap_capability * cap; |
87 | cap = (struct mailimap_capability *)clist_content(cur); | 87 | cap = (struct mailimap_capability *)clist_content(cur); |
88 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { | 88 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { |
89 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { | 89 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { |
90 | try_tls = true; | 90 | try_tls = true; |
91 | break; | 91 | break; |
92 | } | 92 | } |
93 | } | 93 | } |
94 | } | 94 | } |
95 | if (cap_data) { | 95 | if (cap_data) { |
96 | mailimap_capability_data_free(cap_data); | 96 | mailimap_capability_data_free(cap_data); |
97 | } | 97 | } |
98 | if (try_tls) { | 98 | if (try_tls) { |
99 | err = mailimap_starttls(m_imap); | 99 | err = mailimap_starttls(m_imap); |
100 | if (err != MAILIMAP_NO_ERROR && force_tls) { | 100 | if (err != MAILIMAP_NO_ERROR && force_tls) { |
101 | Global::statusMessage(tr("Server has no TLS support!")); | 101 | Global::statusMessage(tr("Server has no TLS support!")); |
102 | try_tls = false; | 102 | try_tls = false; |
103 | } else { | 103 | } else { |
104 | mailstream_low * low; | 104 | mailstream_low * low; |
105 | mailstream_low * new_low; | 105 | mailstream_low * new_low; |
106 | low = mailstream_get_low(m_imap->imap_stream); | 106 | low = mailstream_get_low(m_imap->imap_stream); |
107 | if (!low) { | 107 | if (!low) { |
108 | try_tls = false; | 108 | try_tls = false; |
109 | } else { | 109 | } else { |
110 | int fd = mailstream_low_get_fd(low); | 110 | int fd = mailstream_low_get_fd(low); |
111 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { | 111 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { |
112 | mailstream_low_free(low); | 112 | mailstream_low_free(low); |
113 | mailstream_set_low(m_imap->imap_stream, new_low); | 113 | mailstream_set_low(m_imap->imap_stream, new_low); |
114 | } else { | 114 | } else { |
115 | try_tls = false; | 115 | try_tls = false; |
116 | } | 116 | } |
117 | } | 117 | } |
118 | } | 118 | } |
119 | } | 119 | } |
120 | return try_tls; | 120 | return try_tls; |
121 | } | 121 | } |
122 | 122 | ||
123 | void IMAPwrapper::login() | 123 | void IMAPwrapper::login() |
124 | { | 124 | { |
125 | QString server, user, pass; | 125 | QString server, user, pass; |
126 | uint16_t port; | 126 | uint16_t port; |
127 | int err = MAILIMAP_NO_ERROR; | 127 | int err = MAILIMAP_NO_ERROR; |
128 | 128 | ||
129 | if (account->getOffline()) return; | 129 | if (account->getOffline()) return; |
130 | /* we are connected this moment */ | 130 | /* we are connected this moment */ |
131 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ | 131 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ |
132 | if (m_imap) { | 132 | if (m_imap) { |
133 | err = mailimap_noop(m_imap); | 133 | err = mailimap_noop(m_imap); |
134 | if (err!=MAILIMAP_NO_ERROR) { | 134 | if (err!=MAILIMAP_NO_ERROR) { |
135 | logout(); | 135 | logout(); |
136 | } else { | 136 | } else { |
137 | mailstream_flush(m_imap->imap_stream); | 137 | mailstream_flush(m_imap->imap_stream); |
138 | return; | 138 | return; |
139 | } | 139 | } |
140 | } | 140 | } |
141 | server = account->getServer(); | 141 | server = account->getServer(); |
142 | port = account->getPort().toUInt(); | 142 | port = account->getPort().toUInt(); |
143 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 143 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
144 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 144 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
145 | login.show(); | 145 | login.show(); |
146 | if ( QDialog::Accepted == login.exec() ) { | 146 | if ( QDialog::Accepted == login.exec() ) { |
147 | // ok | 147 | // ok |
148 | user = login.getUser(); | 148 | user = login.getUser(); |
149 | pass = login.getPassword(); | 149 | pass = login.getPassword(); |
150 | } else { | 150 | } else { |
151 | // cancel | 151 | // cancel |
152 | return; | 152 | return; |
153 | } | 153 | } |
154 | } else { | 154 | } else { |
155 | user = account->getUser(); | 155 | user = account->getUser(); |
156 | pass = account->getPassword(); | 156 | pass = account->getPassword(); |
157 | } | 157 | } |
158 | 158 | ||
159 | m_imap = mailimap_new( 20, &imap_progress ); | 159 | m_imap = mailimap_new( 20, &imap_progress ); |
160 | 160 | ||
161 | /* connect */ | 161 | /* connect */ |
162 | bool ssl = false; | 162 | bool ssl = false; |
163 | bool try_tls = false; | 163 | bool try_tls = false; |
164 | bool force_tls = false; | 164 | bool force_tls = false; |
165 | 165 | ||
166 | if ( account->ConnectionType() == 2 ) { | 166 | if ( account->ConnectionType() == 2 ) { |
167 | ssl = true; | 167 | ssl = true; |
168 | } | 168 | } |
169 | if (account->ConnectionType()==1) { | 169 | if (account->ConnectionType()==1) { |
170 | force_tls = true; | 170 | force_tls = true; |
171 | } | 171 | } |
172 | 172 | ||
173 | if ( ssl ) { | 173 | if ( ssl ) { |
174 | qDebug("using ssl "); | 174 | //qDebug("using ssl "); |
175 | err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port ); | 175 | err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port ); |
176 | } else { | 176 | } else { |
177 | err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port ); | 177 | err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port ); |
178 | } | 178 | } |
179 | 179 | ||
180 | if ( err != MAILIMAP_NO_ERROR && | 180 | if ( err != MAILIMAP_NO_ERROR && |
181 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && | 181 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && |
182 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { | 182 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { |
183 | QString failure = ""; | 183 | QString failure = ""; |
184 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { | 184 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { |
185 | failure="Connection refused"; | 185 | failure="Connection refused"; |
186 | } else { | 186 | } else { |
187 | failure="Unknown failure"; | 187 | failure="Unknown failure"; |
188 | } | 188 | } |
189 | Global::statusMessage(tr("error connecting imap server: %1").arg(failure)); | 189 | Global::statusMessage(tr("error connecting imap server: %1").arg(failure)); |
190 | mailimap_free( m_imap ); | 190 | mailimap_free( m_imap ); |
191 | m_imap = 0; | 191 | m_imap = 0; |
192 | return; | 192 | return; |
193 | } | 193 | } |
194 | 194 | ||
195 | if (!ssl) { | 195 | if (!ssl) { |
196 | try_tls = start_tls(force_tls); | 196 | try_tls = start_tls(force_tls); |
197 | } | 197 | } |
198 | 198 | ||
199 | bool ok = true; | 199 | bool ok = true; |
200 | if (force_tls && !try_tls) { | 200 | if (force_tls && !try_tls) { |
201 | Global::statusMessage(tr("Server has no TLS support!")); | 201 | Global::statusMessage(tr("Server has no TLS support!")); |
202 | ok = false; | 202 | ok = false; |
203 | } | 203 | } |
204 | 204 | ||
205 | 205 | ||
206 | /* login */ | 206 | /* login */ |
207 | 207 | ||
208 | if (ok) { | 208 | if (ok) { |
209 | err = mailimap_login_simple( m_imap, (char*)user.latin1(), (char*)pass.latin1() ); | 209 | err = mailimap_login_simple( m_imap, (char*)user.latin1(), (char*)pass.latin1() ); |
210 | if ( err != MAILIMAP_NO_ERROR ) { | 210 | if ( err != MAILIMAP_NO_ERROR ) { |
211 | Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response)); | 211 | Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response)); |
212 | ok = false; | 212 | ok = false; |
213 | } | 213 | } |
214 | } | 214 | } |
215 | if (!ok) { | 215 | if (!ok) { |
216 | err = mailimap_close( m_imap ); | 216 | err = mailimap_close( m_imap ); |
217 | mailimap_free( m_imap ); | 217 | mailimap_free( m_imap ); |
218 | m_imap = 0; | 218 | m_imap = 0; |
219 | } | 219 | } |
220 | } | 220 | } |
221 | 221 | ||
222 | void IMAPwrapper::logout() | 222 | void IMAPwrapper::logout() |
223 | { | 223 | { |
224 | int err = MAILIMAP_NO_ERROR; | 224 | int err = MAILIMAP_NO_ERROR; |
225 | if (!m_imap) return; | 225 | if (!m_imap) return; |
226 | err = mailimap_logout( m_imap ); | 226 | err = mailimap_logout( m_imap ); |
227 | err = mailimap_close( m_imap ); | 227 | err = mailimap_close( m_imap ); |
228 | mailimap_free( m_imap ); | 228 | mailimap_free( m_imap ); |
229 | m_imap = 0; | 229 | m_imap = 0; |
230 | m_Lastmbox = ""; | 230 | m_Lastmbox = ""; |
231 | } | 231 | } |
232 | 232 | ||
233 | void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb) | 233 | void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb) |
234 | { | 234 | { |
235 | int err = MAILIMAP_NO_ERROR; | 235 | int err = MAILIMAP_NO_ERROR; |
236 | clist *result = 0; | 236 | clist *result = 0; |
237 | clistcell *current; | 237 | clistcell *current; |
238 | mailimap_fetch_type *fetchType = 0; | 238 | mailimap_fetch_type *fetchType = 0; |
239 | mailimap_set *set = 0; | 239 | mailimap_set *set = 0; |
240 | 240 | ||
241 | login(); | 241 | login(); |
242 | if (!m_imap) { | 242 | if (!m_imap) { |
243 | return; | 243 | return; |
244 | } | 244 | } |
245 | /* select mailbox READONLY for operations */ | 245 | /* select mailbox READONLY for operations */ |
246 | err = selectMbox(mailbox); | 246 | err = selectMbox(mailbox); |
247 | if ( err != MAILIMAP_NO_ERROR ) { | 247 | if ( err != MAILIMAP_NO_ERROR ) { |
248 | return; | 248 | return; |
249 | } | 249 | } |
250 | 250 | ||
251 | int last = m_imap->imap_selection_info->sel_exists; | 251 | int last = m_imap->imap_selection_info->sel_exists; |
252 | 252 | ||
253 | if (last == 0) { | 253 | if (last == 0) { |
254 | Global::statusMessage(tr("Mailbox has no mails")); | 254 | Global::statusMessage(tr("Mailbox has no mails")); |
255 | return; | 255 | return; |
256 | } else { | 256 | } else { |
257 | } | 257 | } |
258 | 258 | ||
259 | Global::statusMessage(tr("Fetching header list")); | 259 | Global::statusMessage(tr("Fetching header list")); |
260 | qApp->processEvents(); | 260 | qApp->processEvents(); |
261 | /* the range has to start at 1!!! not with 0!!!! */ | 261 | /* the range has to start at 1!!! not with 0!!!! */ |
262 | set = mailimap_set_new_interval( 1, last ); | 262 | set = mailimap_set_new_interval( 1, last ); |
263 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); | 263 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); |
264 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); | 264 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); |
265 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); | 265 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); |
266 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); | 266 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); |
267 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); | 267 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); |
268 | 268 | ||
269 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 269 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
270 | mailimap_set_free( set ); | 270 | mailimap_set_free( set ); |
@@ -1154,154 +1154,154 @@ int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,cons | |||
1154 | } | 1154 | } |
1155 | return 1; | 1155 | return 1; |
1156 | } | 1156 | } |
1157 | 1157 | ||
1158 | int IMAPwrapper::deleteMbox(const FolderP&folder) | 1158 | int IMAPwrapper::deleteMbox(const FolderP&folder) |
1159 | { | 1159 | { |
1160 | if (!folder) return 0; | 1160 | if (!folder) return 0; |
1161 | login(); | 1161 | login(); |
1162 | if (!m_imap) {return 0;} | 1162 | if (!m_imap) {return 0;} |
1163 | int res = mailimap_delete(m_imap,folder->getName()); | 1163 | int res = mailimap_delete(m_imap,folder->getName()); |
1164 | if (res != MAILIMAP_NO_ERROR) { | 1164 | if (res != MAILIMAP_NO_ERROR) { |
1165 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); | 1165 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); |
1166 | return 0; | 1166 | return 0; |
1167 | } | 1167 | } |
1168 | return 1; | 1168 | return 1; |
1169 | } | 1169 | } |
1170 | 1170 | ||
1171 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 1171 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) |
1172 | { | 1172 | { |
1173 | mailimap_status_att_list * att_list =0; | 1173 | mailimap_status_att_list * att_list =0; |
1174 | mailimap_mailbox_data_status * status=0; | 1174 | mailimap_mailbox_data_status * status=0; |
1175 | clistiter * cur = 0; | 1175 | clistiter * cur = 0; |
1176 | int r = 0; | 1176 | int r = 0; |
1177 | target_stat.message_count = 0; | 1177 | target_stat.message_count = 0; |
1178 | target_stat.message_unseen = 0; | 1178 | target_stat.message_unseen = 0; |
1179 | target_stat.message_recent = 0; | 1179 | target_stat.message_recent = 0; |
1180 | login(); | 1180 | login(); |
1181 | if (!m_imap) { | 1181 | if (!m_imap) { |
1182 | return; | 1182 | return; |
1183 | } | 1183 | } |
1184 | att_list = mailimap_status_att_list_new_empty(); | 1184 | att_list = mailimap_status_att_list_new_empty(); |
1185 | if (!att_list) return; | 1185 | if (!att_list) return; |
1186 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); | 1186 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); |
1187 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); | 1187 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); |
1188 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); | 1188 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); |
1189 | r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); | 1189 | r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); |
1190 | if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) { | 1190 | if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) { |
1191 | for (cur = clist_begin(status->st_info_list); | 1191 | for (cur = clist_begin(status->st_info_list); |
1192 | cur != NULL ; cur = clist_next(cur)) { | 1192 | cur != NULL ; cur = clist_next(cur)) { |
1193 | mailimap_status_info * status_info; | 1193 | mailimap_status_info * status_info; |
1194 | status_info = (mailimap_status_info *)clist_content(cur); | 1194 | status_info = (mailimap_status_info *)clist_content(cur); |
1195 | switch (status_info->st_att) { | 1195 | switch (status_info->st_att) { |
1196 | case MAILIMAP_STATUS_ATT_MESSAGES: | 1196 | case MAILIMAP_STATUS_ATT_MESSAGES: |
1197 | target_stat.message_count = status_info->st_value; | 1197 | target_stat.message_count = status_info->st_value; |
1198 | break; | 1198 | break; |
1199 | case MAILIMAP_STATUS_ATT_RECENT: | 1199 | case MAILIMAP_STATUS_ATT_RECENT: |
1200 | target_stat.message_recent = status_info->st_value; | 1200 | target_stat.message_recent = status_info->st_value; |
1201 | break; | 1201 | break; |
1202 | case MAILIMAP_STATUS_ATT_UNSEEN: | 1202 | case MAILIMAP_STATUS_ATT_UNSEEN: |
1203 | target_stat.message_unseen = status_info->st_value; | 1203 | target_stat.message_unseen = status_info->st_value; |
1204 | break; | 1204 | break; |
1205 | } | 1205 | } |
1206 | } | 1206 | } |
1207 | } else { | 1207 | } else { |
1208 | // odebug << "Error retrieving status" << oendl; | 1208 | // odebug << "Error retrieving status" << oendl; |
1209 | } | 1209 | } |
1210 | if (status) mailimap_mailbox_data_status_free(status); | 1210 | if (status) mailimap_mailbox_data_status_free(status); |
1211 | if (att_list) mailimap_status_att_list_free(att_list); | 1211 | if (att_list) mailimap_status_att_list_free(att_list); |
1212 | } | 1212 | } |
1213 | 1213 | ||
1214 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) | 1214 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) |
1215 | { | 1215 | { |
1216 | login(); | 1216 | login(); |
1217 | if (!m_imap) return; | 1217 | if (!m_imap) return; |
1218 | if (!msg) return; | 1218 | if (!msg) return; |
1219 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); | 1219 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); |
1220 | if (r != MAILIMAP_NO_ERROR) { | 1220 | if (r != MAILIMAP_NO_ERROR) { |
1221 | Global::statusMessage("Error storing mail!"); | 1221 | Global::statusMessage("Error storing mail!"); |
1222 | } | 1222 | } |
1223 | } | 1223 | } |
1224 | 1224 | ||
1225 | MAILLIB::ATYPE IMAPwrapper::getType()const | 1225 | MAILLIB::ATYPE IMAPwrapper::getType()const |
1226 | { | 1226 | { |
1227 | return account->getType(); | 1227 | return account->getType(); |
1228 | } | 1228 | } |
1229 | 1229 | ||
1230 | const QString&IMAPwrapper::getName()const | 1230 | const QString&IMAPwrapper::getName()const |
1231 | { | 1231 | { |
1232 | // odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl; | 1232 | // odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl; |
1233 | return account->getAccountName(); | 1233 | return account->getAccountName(); |
1234 | } | 1234 | } |
1235 | 1235 | ||
1236 | encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) | 1236 | encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) |
1237 | { | 1237 | { |
1238 | // dummy | 1238 | // dummy |
1239 | QValueList<int> path; | 1239 | QValueList<int> path; |
1240 | return fetchRawPart(mail,path,false); | 1240 | return fetchRawPart(mail,path,false); |
1241 | } | 1241 | } |
1242 | 1242 | ||
1243 | void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, | 1243 | void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, |
1244 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) | 1244 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) |
1245 | { | 1245 | { |
1246 | if (targetWrapper != this || maxSizeInKb > 0 ) { | 1246 | if (targetWrapper != this || maxSizeInKb > 0 ) { |
1247 | mMax = 0; | 1247 | mMax = 0; |
1248 | progress( tr("Copy")); | 1248 | progress( tr("Copy")); |
1249 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit, maxSizeInKb); | 1249 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit, maxSizeInKb); |
1250 | qDebug("IMAPwrapper::mvcpAllMails::Using generic"); | 1250 | //qDebug("IMAPwrapper::mvcpAllMails::Using generic"); |
1251 | // odebug << "Using generic" << oendl; | 1251 | // odebug << "Using generic" << oendl; |
1252 | return; | 1252 | return; |
1253 | } | 1253 | } |
1254 | mailimap_set *set = 0; | 1254 | mailimap_set *set = 0; |
1255 | login(); | 1255 | login(); |
1256 | if (!m_imap) { | 1256 | if (!m_imap) { |
1257 | return; | 1257 | return; |
1258 | } | 1258 | } |
1259 | int err = selectMbox(fromFolder->getName()); | 1259 | int err = selectMbox(fromFolder->getName()); |
1260 | if ( err != MAILIMAP_NO_ERROR ) { | 1260 | if ( err != MAILIMAP_NO_ERROR ) { |
1261 | return; | 1261 | return; |
1262 | } | 1262 | } |
1263 | Global::statusMessage( tr("Copying mails on server...") ); | 1263 | Global::statusMessage( tr("Copying mails on server...") ); |
1264 | int last = m_imap->imap_selection_info->sel_exists; | 1264 | int last = m_imap->imap_selection_info->sel_exists; |
1265 | set = mailimap_set_new_interval( 1, last ); | 1265 | set = mailimap_set_new_interval( 1, last ); |
1266 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | 1266 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); |
1267 | mailimap_set_free( set ); | 1267 | mailimap_set_free( set ); |
1268 | if ( err != MAILIMAP_NO_ERROR ) { | 1268 | if ( err != MAILIMAP_NO_ERROR ) { |
1269 | QString error_msg = tr("Error copy mails: %1").arg(m_imap->imap_response); | 1269 | QString error_msg = tr("Error copy mails: %1").arg(m_imap->imap_response); |
1270 | Global::statusMessage(error_msg); | 1270 | Global::statusMessage(error_msg); |
1271 | // odebug << error_msg << oendl; | 1271 | // odebug << error_msg << oendl; |
1272 | return; | 1272 | return; |
1273 | } | 1273 | } |
1274 | if (moveit) { | 1274 | if (moveit) { |
1275 | deleteAllMail(fromFolder); | 1275 | deleteAllMail(fromFolder); |
1276 | } | 1276 | } |
1277 | } | 1277 | } |
1278 | 1278 | ||
1279 | void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 1279 | void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
1280 | { | 1280 | { |
1281 | if (targetWrapper != this) { | 1281 | if (targetWrapper != this) { |
1282 | // odebug << "Using generic" << oendl; | 1282 | // odebug << "Using generic" << oendl; |
1283 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); | 1283 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); |
1284 | return; | 1284 | return; |
1285 | } | 1285 | } |
1286 | mailimap_set *set = 0; | 1286 | mailimap_set *set = 0; |
1287 | login(); | 1287 | login(); |
1288 | if (!m_imap) { | 1288 | if (!m_imap) { |
1289 | return; | 1289 | return; |
1290 | } | 1290 | } |
1291 | int err = selectMbox(mail->getMbox()); | 1291 | int err = selectMbox(mail->getMbox()); |
1292 | if ( err != MAILIMAP_NO_ERROR ) { | 1292 | if ( err != MAILIMAP_NO_ERROR ) { |
1293 | return; | 1293 | return; |
1294 | } | 1294 | } |
1295 | set = mailimap_set_new_single(mail->getNumber()); | 1295 | set = mailimap_set_new_single(mail->getNumber()); |
1296 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | 1296 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); |
1297 | mailimap_set_free( set ); | 1297 | mailimap_set_free( set ); |
1298 | if ( err != MAILIMAP_NO_ERROR ) { | 1298 | if ( err != MAILIMAP_NO_ERROR ) { |
1299 | QString error_msg = tr("error copy mail: %1").arg(m_imap->imap_response); | 1299 | QString error_msg = tr("error copy mail: %1").arg(m_imap->imap_response); |
1300 | Global::statusMessage(error_msg); | 1300 | Global::statusMessage(error_msg); |
1301 | // odebug << error_msg << oendl; | 1301 | // odebug << error_msg << oendl; |
1302 | return; | 1302 | return; |
1303 | } | 1303 | } |
1304 | if (moveit) { | 1304 | if (moveit) { |
1305 | deleteMail(mail); | 1305 | deleteMail(mail); |
1306 | } | 1306 | } |
1307 | } | 1307 | } |