summaryrefslogtreecommitdiffabout
path: root/kmicromail
authorzautrix <zautrix>2004-10-31 08:38:17 (UTC)
committer zautrix <zautrix>2004-10-31 08:38:17 (UTC)
commitf77a9457e676a11520c8f52b33265cd825db0c79 (patch) (unidiff)
treed35fc3ef29edf54f413c40621ae760407f659d0c /kmicromail
parentc48af43f15e8917a441fc8ca4e1bc3adfd1d822e (diff)
downloadkdepimpi-f77a9457e676a11520c8f52b33265cd825db0c79.zip
kdepimpi-f77a9457e676a11520c8f52b33265cd825db0c79.tar.gz
kdepimpi-f77a9457e676a11520c8f52b33265cd825db0c79.tar.bz2
added delete dir to ompi
Diffstat (limited to 'kmicromail') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/imapwrapper.cpp3
-rw-r--r--kmicromail/libmailwrapper/mhwrapper.cpp57
-rw-r--r--kmicromail/libmailwrapper/mhwrapper.h1
3 files changed, 36 insertions, 25 deletions
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp
index 3aec13d..110583f 100644
--- a/kmicromail/libmailwrapper/imapwrapper.cpp
+++ b/kmicromail/libmailwrapper/imapwrapper.cpp
@@ -80,194 +80,195 @@ bool IMAPwrapper::start_tls(bool force_tls)
80 80
81 err = mailimap_capability(m_imap,&cap_data); 81 err = mailimap_capability(m_imap,&cap_data);
82 if (err != MAILIMAP_NO_ERROR) { 82 if (err != MAILIMAP_NO_ERROR) {
83 Global::statusMessage("error getting capabilities!"); 83 Global::statusMessage("error getting capabilities!");
84 return false; 84 return false;
85 } 85 }
86 clistiter * cur; 86 clistiter * cur;
87 for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { 87 for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) {
88 struct mailimap_capability * cap; 88 struct mailimap_capability * cap;
89 cap = (struct mailimap_capability *)clist_content(cur); 89 cap = (struct mailimap_capability *)clist_content(cur);
90 if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { 90 if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) {
91 if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { 91 if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) {
92 try_tls = true; 92 try_tls = true;
93 break; 93 break;
94 } 94 }
95 } 95 }
96 } 96 }
97 if (cap_data) { 97 if (cap_data) {
98 mailimap_capability_data_free(cap_data); 98 mailimap_capability_data_free(cap_data);
99 } 99 }
100 if (try_tls) { 100 if (try_tls) {
101 err = mailimap_starttls(m_imap); 101 err = mailimap_starttls(m_imap);
102 if (err != MAILIMAP_NO_ERROR && force_tls) { 102 if (err != MAILIMAP_NO_ERROR && force_tls) {
103 Global::statusMessage(i18n("Server has no TLS support!")); 103 Global::statusMessage(i18n("Server has no TLS support!"));
104 try_tls = false; 104 try_tls = false;
105 } else { 105 } else {
106 mailstream_low * low; 106 mailstream_low * low;
107 mailstream_low * new_low; 107 mailstream_low * new_low;
108 low = mailstream_get_low(m_imap->imap_stream); 108 low = mailstream_get_low(m_imap->imap_stream);
109 if (!low) { 109 if (!low) {
110 try_tls = false; 110 try_tls = false;
111 } else { 111 } else {
112 int fd = mailstream_low_get_fd(low); 112 int fd = mailstream_low_get_fd(low);
113 if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { 113 if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) {
114 mailstream_low_free(low); 114 mailstream_low_free(low);
115 mailstream_set_low(m_imap->imap_stream, new_low); 115 mailstream_set_low(m_imap->imap_stream, new_low);
116 } else { 116 } else {
117 try_tls = false; 117 try_tls = false;
118 } 118 }
119 } 119 }
120 } 120 }
121 } 121 }
122 return try_tls; 122 return try_tls;
123} 123}
124 124
125void IMAPwrapper::login() 125void IMAPwrapper::login()
126{ 126{
127 QString server, user, pass; 127 QString server, user, pass;
128 uint16_t port; 128 uint16_t port;
129 int err = MAILIMAP_NO_ERROR; 129 int err = MAILIMAP_NO_ERROR;
130 130
131 if (account->getOffline()) return; 131 if (account->getOffline()) return;
132 /* we are connected this moment */ 132 /* we are connected this moment */
133 /* TODO: setup a timer holding the line or if connection closed - delete the value */ 133 /* TODO: setup a timer holding the line or if connection closed - delete the value */
134 if (m_imap) { 134 if (m_imap) {
135 err = mailimap_noop(m_imap); 135 err = mailimap_noop(m_imap);
136 if (err!=MAILIMAP_NO_ERROR) { 136 if (err!=MAILIMAP_NO_ERROR) {
137 logout(); 137 logout();
138 } else { 138 } else {
139 mailstream_flush(m_imap->imap_stream); 139 mailstream_flush(m_imap->imap_stream);
140 return; 140 return;
141 } 141 }
142 } 142 }
143 server = account->getServer(); 143 server = account->getServer();
144 port = account->getPort().toUInt(); 144 port = account->getPort().toUInt();
145 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { 145 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) {
146 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); 146 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true );
147 login.show(); 147 login.show();
148 if ( QDialog::Accepted == login.exec() ) { 148 if ( QDialog::Accepted == login.exec() ) {
149 // ok 149 // ok
150 user = login.getUser(); 150 user = login.getUser();
151 pass = login.getPassword(); 151 pass = login.getPassword();
152 } else { 152 } else {
153 // cancel 153 // cancel
154 return; 154 return;
155 } 155 }
156 } else { 156 } else {
157 user = account->getUser(); 157 user = account->getUser();
158 pass = account->getPassword(); 158 pass = account->getPassword();
159 } 159 }
160 160
161 m_imap = mailimap_new( 20, &imap_progress ); 161 m_imap = mailimap_new( 20, &imap_progress );
162 162
163 /* connect */ 163 /* connect */
164 bool ssl = false; 164 bool ssl = false;
165 bool try_tls = false; 165 bool try_tls = false;
166 bool force_tls = false; 166 bool force_tls = false;
167 167
168 if ( account->ConnectionType() == 2 ) { 168 if ( account->ConnectionType() == 2 ) {
169 ssl = true; 169 ssl = true;
170 } 170 }
171 if (account->ConnectionType()==1) { 171 if (account->ConnectionType()==1) {
172 force_tls = true; 172 force_tls = true;
173 } 173 }
174 174
175 if ( ssl ) { 175 if ( ssl ) {
176 //qDebug("using ssl "); 176 qDebug("using ssl ");
177 err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port ); 177 err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port );
178 qDebug("back ");
178 } else { 179 } else {
179 err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port ); 180 err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port );
180 } 181 }
181 182
182 if ( err != MAILIMAP_NO_ERROR && 183 if ( err != MAILIMAP_NO_ERROR &&
183 err != MAILIMAP_NO_ERROR_AUTHENTICATED && 184 err != MAILIMAP_NO_ERROR_AUTHENTICATED &&
184 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { 185 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) {
185 QString failure = ""; 186 QString failure = "";
186 if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { 187 if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) {
187 failure="Connection refused"; 188 failure="Connection refused";
188 } else { 189 } else {
189 failure="Unknown failure"; 190 failure="Unknown failure";
190 } 191 }
191 Global::statusMessage(i18n("error connecting imap server: %1").arg(failure)); 192 Global::statusMessage(i18n("error connecting imap server: %1").arg(failure));
192 mailimap_free( m_imap ); 193 mailimap_free( m_imap );
193 m_imap = 0; 194 m_imap = 0;
194 return; 195 return;
195 } 196 }
196 197
197 if (!ssl) { 198 if (!ssl) {
198 try_tls = start_tls(force_tls); 199 try_tls = start_tls(force_tls);
199 } 200 }
200 201
201 bool ok = true; 202 bool ok = true;
202 if (force_tls && !try_tls) { 203 if (force_tls && !try_tls) {
203 Global::statusMessage(i18n("Server has no TLS support!")); 204 Global::statusMessage(i18n("Server has no TLS support!"));
204 ok = false; 205 ok = false;
205 } 206 }
206 207
207 208
208 /* login */ 209 /* login */
209 210
210 if (ok) { 211 if (ok) {
211 err = mailimap_login_simple( m_imap, (char*)user.latin1(), (char*)pass.latin1() ); 212 err = mailimap_login_simple( m_imap, (char*)user.latin1(), (char*)pass.latin1() );
212 if ( err != MAILIMAP_NO_ERROR ) { 213 if ( err != MAILIMAP_NO_ERROR ) {
213 Global::statusMessage(i18n("error logging in imap server: %1").arg(m_imap->imap_response)); 214 Global::statusMessage(i18n("error logging in imap server: %1").arg(m_imap->imap_response));
214 ok = false; 215 ok = false;
215 } 216 }
216 } 217 }
217 if (!ok) { 218 if (!ok) {
218 err = mailimap_close( m_imap ); 219 err = mailimap_close( m_imap );
219 mailimap_free( m_imap ); 220 mailimap_free( m_imap );
220 m_imap = 0; 221 m_imap = 0;
221 } 222 }
222} 223}
223 224
224void IMAPwrapper::logout() 225void IMAPwrapper::logout()
225{ 226{
226 int err = MAILIMAP_NO_ERROR; 227 int err = MAILIMAP_NO_ERROR;
227 if (!m_imap) return; 228 if (!m_imap) return;
228 err = mailimap_logout( m_imap ); 229 err = mailimap_logout( m_imap );
229 err = mailimap_close( m_imap ); 230 err = mailimap_close( m_imap );
230 mailimap_free( m_imap ); 231 mailimap_free( m_imap );
231 m_imap = 0; 232 m_imap = 0;
232 m_Lastmbox = ""; 233 m_Lastmbox = "";
233} 234}
234 235
235void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb) 236void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb)
236{ 237{
237 238
238 int tryAgain = 1; 239 int tryAgain = 1;
239 while ( tryAgain >= 0 ) { 240 while ( tryAgain >= 0 ) {
240 int err = MAILIMAP_NO_ERROR; 241 int err = MAILIMAP_NO_ERROR;
241 clist *result = 0; 242 clist *result = 0;
242 clistcell *current; 243 clistcell *current;
243 mailimap_fetch_type *fetchType = 0; 244 mailimap_fetch_type *fetchType = 0;
244 mailimap_set *set = 0; 245 mailimap_set *set = 0;
245 246
246 login(); 247 login();
247 if (!m_imap) { 248 if (!m_imap) {
248 return; 249 return;
249 } 250 }
250 /* select mailbox READONLY for operations */ 251 /* select mailbox READONLY for operations */
251 err = selectMbox(mailbox); 252 err = selectMbox(mailbox);
252 if ( err != MAILIMAP_NO_ERROR ) { 253 if ( err != MAILIMAP_NO_ERROR ) {
253 return; 254 return;
254 } 255 }
255 256
256 int last = m_imap->imap_selection_info->sel_exists; 257 int last = m_imap->imap_selection_info->sel_exists;
257 258
258 if (last == 0) { 259 if (last == 0) {
259 Global::statusMessage(i18n("Mailbox has no mails")); 260 Global::statusMessage(i18n("Mailbox has no mails"));
260 return; 261 return;
261 } else { 262 } else {
262 } 263 }
263 progress( i18n("Fetch ")); 264 progress( i18n("Fetch "));
264 mMax = last; 265 mMax = last;
265 //qDebug("last %d ", last); 266 //qDebug("last %d ", last);
266 Global::statusMessage(i18n("Fetching header list")); 267 Global::statusMessage(i18n("Fetching header list"));
267 qApp->processEvents(); 268 qApp->processEvents();
268 /* the range has to start at 1!!! not with 0!!!! */ 269 /* the range has to start at 1!!! not with 0!!!! */
269 //LR the access to web.de imap server is no working with value 1 270 //LR the access to web.de imap server is no working with value 1
270 //qDebug("interval %d - %d ", tryAgain, last-1+tryAgain ); 271 //qDebug("interval %d - %d ", tryAgain, last-1+tryAgain );
271 set = mailimap_set_new_interval( tryAgain, last ); 272 set = mailimap_set_new_interval( tryAgain, last );
272 fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); 273 fetchType = mailimap_fetch_type_new_fetch_att_list_empty();
273 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); 274 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope());
diff --git a/kmicromail/libmailwrapper/mhwrapper.cpp b/kmicromail/libmailwrapper/mhwrapper.cpp
index de6d220..90b5d23 100644
--- a/kmicromail/libmailwrapper/mhwrapper.cpp
+++ b/kmicromail/libmailwrapper/mhwrapper.cpp
@@ -206,232 +206,241 @@ void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder)
206 QString f = buildPath(Folder); 206 QString f = buildPath(Folder);
207 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); 207 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1());
208 if (r!=MAIL_NO_ERROR) { 208 if (r!=MAIL_NO_ERROR) {
209 qDebug("error selecting folder! "); 209 qDebug("error selecting folder! ");
210 return; 210 return;
211 } 211 }
212 r = mailsession_append_message(m_storage->sto_session,(char*)msg,length); 212 r = mailsession_append_message(m_storage->sto_session,(char*)msg,length);
213 if (r!=MAIL_NO_ERROR) { 213 if (r!=MAIL_NO_ERROR) {
214 qDebug("error storing mail "); 214 qDebug("error storing mail ");
215 } 215 }
216 return; 216 return;
217} 217}
218 218
219encodedString* MHwrapper::fetchRawBody(const RecMailP&mail) 219encodedString* MHwrapper::fetchRawBody(const RecMailP&mail)
220{ 220{
221 encodedString*result = 0; 221 encodedString*result = 0;
222 init_storage(); 222 init_storage();
223 if (!m_storage) { 223 if (!m_storage) {
224 return result; 224 return result;
225 } 225 }
226 mailmessage * msg = 0; 226 mailmessage * msg = 0;
227 char*data=0; 227 char*data=0;
228 size_t size; 228 size_t size;
229 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); 229 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1());
230 if (r!=MAIL_NO_ERROR) { 230 if (r!=MAIL_NO_ERROR) {
231 qDebug("error selecting folder! "); 231 qDebug("error selecting folder! ");
232 return result; 232 return result;
233 } 233 }
234 r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); 234 r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg);
235 if (r != MAIL_NO_ERROR) { 235 if (r != MAIL_NO_ERROR) {
236 Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); 236 Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber()));
237 return 0; 237 return 0;
238 } 238 }
239 r = mailmessage_fetch(msg,&data,&size); 239 r = mailmessage_fetch(msg,&data,&size);
240 if (r != MAIL_NO_ERROR) { 240 if (r != MAIL_NO_ERROR) {
241 Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); 241 Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber()));
242 if (msg) mailmessage_free(msg); 242 if (msg) mailmessage_free(msg);
243 return 0; 243 return 0;
244 } 244 }
245 result = new encodedString(data,size); 245 result = new encodedString(data,size);
246 if (msg) mailmessage_free(msg); 246 if (msg) mailmessage_free(msg);
247 return result; 247 return result;
248} 248}
249 249
250void MHwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target) 250void MHwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target)
251{ 251{
252 QString f = buildPath(mailbox); 252 QString f = buildPath(mailbox);
253 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); 253 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1());
254 if (r!=MAIL_NO_ERROR) { 254 if (r!=MAIL_NO_ERROR) {
255 qDebug("deleteMails: error selecting folder! "); 255 qDebug("deleteMails: error selecting folder! ");
256 return; 256 return;
257 } 257 }
258 QValueList<RecMailP>::ConstIterator it; 258 QValueList<RecMailP>::ConstIterator it;
259 for (it=target.begin(); it!=target.end();++it) { 259 for (it=target.begin(); it!=target.end();++it) {
260 r = mailsession_remove_message(m_storage->sto_session,(*it)->getNumber()); 260 r = mailsession_remove_message(m_storage->sto_session,(*it)->getNumber());
261 if (r != MAIL_NO_ERROR) { 261 if (r != MAIL_NO_ERROR) {
262 qDebug("error deleting mail "); 262 qDebug("error deleting mail ");
263 break; 263 break;
264 } 264 }
265 } 265 }
266} 266}
267 267
268int MHwrapper::deleteAllMail(const FolderP&tfolder) 268int MHwrapper::deleteAllMail(const FolderP&tfolder)
269{ 269{
270 init_storage(); 270 init_storage();
271 if (!m_storage) { 271 if (!m_storage) {
272 return 0; 272 return 0;
273 } 273 }
274 int res = 1; 274 int res = 1;
275 if (!tfolder) return 0; 275 if (!tfolder) return 0;
276 int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); 276 int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1());
277 if (r!=MAIL_NO_ERROR) { 277 if (r!=MAIL_NO_ERROR) {
278 qDebug("error selecting folder! "); 278 qDebug("error selecting folder! ");
279 return 0; 279 return 0;
280 } 280 }
281 mailmessage_list*l=0; 281 mailmessage_list*l=0;
282 r = mailsession_get_messages_list(m_storage->sto_session,&l); 282 r = mailsession_get_messages_list(m_storage->sto_session,&l);
283 if (r != MAIL_NO_ERROR) { 283 if (r != MAIL_NO_ERROR) {
284 qDebug("Error message list "); 284 qDebug("Error message list ");
285 res = 0; 285 res = 0;
286 } 286 }
287 unsigned j = 0; 287 unsigned j = 0;
288 for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { 288 for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) {
289 mailmessage * msg; 289 mailmessage * msg;
290 msg = (mailmessage*)carray_get(l->msg_tab, i); 290 msg = (mailmessage*)carray_get(l->msg_tab, i);
291 j = msg->msg_index; 291 j = msg->msg_index;
292 r = mailsession_remove_message(m_storage->sto_session,j); 292 r = mailsession_remove_message(m_storage->sto_session,j);
293 if (r != MAIL_NO_ERROR) { 293 if (r != MAIL_NO_ERROR) {
294 Global::statusMessage(i18n("Error deleting mail %1").arg(i+1)); 294 Global::statusMessage(i18n("Error deleting mail %1").arg(i+1));
295 res = 0; 295 res = 0;
296 break; 296 break;
297 } 297 }
298 } 298 }
299 if (l) mailmessage_list_free(l); 299 if (l) mailmessage_list_free(l);
300 return res; 300 return res;
301} 301}
302 302bool MHwrapper::rmDir(QString folder) // absolute path!
303{
304 QDir dir ( folder );
305 if ( !dir.exists() )
306 return false;
307 int i;
308 // qDebug("rmdir %s ",folder.latin1());
309 QStringList list = dir.entryList(QDir::Dirs|QDir::Files|QDir::NoSymLinks|QDir::Hidden );
310 for (i=0; i<list.count(); i++ ) {
311 bool result = true;
312 QString entry = folder+"/"+ list[i] ;
313 //qDebug("entry %s ",entry.latin1() );
314
315 QFileInfo fi ( entry );
316 if ( fi.isFile() ) {
317 //qDebug("file %s ",entry.latin1() );
318 result = QFile::remove ( entry ) ;
319 } else {
320 //qDebug("dir %s ",entry.latin1());
321 if ( list[i] != "." && list[i] != ".." )
322 result = rmDir( entry );
323 }
324 if ( ! result )
325 return false;
326 }
327 //qDebug("removing... ");
328 return QDir::root().rmdir ( folder, true );
329}
303int MHwrapper::deleteMbox(const FolderP&tfolder) 330int MHwrapper::deleteMbox(const FolderP&tfolder)
304{ 331{
305 init_storage(); 332 init_storage();
306 if (!m_storage) { 333 if (!m_storage) {
307 return 0; 334 return 0;
308 } 335 }
309 if (!tfolder) return 0; 336 if (!tfolder) return 0;
310 if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; 337 if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0;
311 338
312 int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); 339 int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1());
313 340
314 if (r != MAIL_NO_ERROR) { 341 if (r != MAIL_NO_ERROR) {
315 qDebug("error deleting mail box "); 342 qDebug("error deleting mail box ");
316 return 0; 343 return 0;
317 } 344 }
318 QString delDir = locateLocal( "apps", "kopiemail")+ "localmail"; 345 //qDebug("*****************\ndel %s %s ", delDir.latin1(),tfolder->getName().latin1() );
319 qDebug("*****************\ndel %s %s ", delDir.latin1(),tfolder->getName().latin1() ); 346 if ( !rmDir( tfolder->getName() )) {
320#if 0 347 qDebug("error deleteing folder %s ",tfolder->getName().latin1());
321 QString cmd = "rm -rf "+tfolder->getName();
322 QStringList command;
323 command << "/bin/sh";
324 command << "-c";
325 command << cmd.latin1();
326 OProcess *process = new OProcess();
327
328 /*
329 connect(process, SIGNAL(processExited(Opie::Core::OProcess*)),
330 this, SLOT( processEnded(Opie::Core::OProcess*)));
331 connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)),
332 this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int)));
333 */
334 *process << command;
335 removeMboxfailed = false;
336 if(!process->start(OProcess::Block, OProcess::All) ) {
337 qDebug("could not start process ");
338 return 0;
339 } 348 }
340#endif 349 else
341 qDebug("mail box deleted "); 350 qDebug("mail box deleted %s ", tfolder->getName().latin1());
342 return 1; 351 return 1;
343} 352}
344 353
345 354
346void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) 355void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox)
347{ 356{
348 init_storage(); 357 init_storage();
349 if (!m_storage) { 358 if (!m_storage) {
350 return; 359 return;
351 } 360 }
352 target_stat.message_count = 0; 361 target_stat.message_count = 0;
353 target_stat.message_unseen = 0; 362 target_stat.message_unseen = 0;
354 target_stat.message_recent = 0; 363 target_stat.message_recent = 0;
355 QString f = buildPath(mailbox); 364 QString f = buildPath(mailbox);
356 int r = mailsession_status_folder(m_storage->sto_session,(char*)f.latin1(),&target_stat.message_count, 365 int r = mailsession_status_folder(m_storage->sto_session,(char*)f.latin1(),&target_stat.message_count,
357 &target_stat.message_recent,&target_stat.message_unseen); 366 &target_stat.message_recent,&target_stat.message_unseen);
358 if (r != MAIL_NO_ERROR) { 367 if (r != MAIL_NO_ERROR) {
359 Global::statusMessage(i18n("Error retrieving status")); 368 Global::statusMessage(i18n("Error retrieving status"));
360 } 369 }
361} 370}
362 371
363MAILLIB::ATYPE MHwrapper::getType()const 372MAILLIB::ATYPE MHwrapper::getType()const
364{ 373{
365 return MAILLIB::A_MH; 374 return MAILLIB::A_MH;
366} 375}
367 376
368const QString&MHwrapper::getName()const 377const QString&MHwrapper::getName()const
369{ 378{
370 return MHName; 379 return MHName;
371} 380}
372void MHwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) 381void MHwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
373{ 382{
374 init_storage(); 383 init_storage();
375 if (!m_storage) { 384 if (!m_storage) {
376 return; 385 return;
377 } 386 }
378 if (targetWrapper != this) { 387 if (targetWrapper != this) {
379 qDebug("Using generic "); 388 qDebug("Using generic ");
380 Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); 389 Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit);
381 return; 390 return;
382 } 391 }
383 qDebug("Using internal routines for move/copy "); 392 qDebug("Using internal routines for move/copy ");
384 QString tf = buildPath(targetFolder); 393 QString tf = buildPath(targetFolder);
385 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); 394 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1());
386 if (r != MAIL_NO_ERROR) { 395 if (r != MAIL_NO_ERROR) {
387 qDebug("Error selecting source mailbox "); 396 qDebug("Error selecting source mailbox ");
388 return; 397 return;
389 } 398 }
390 if (moveit) { 399 if (moveit) {
391 r = mailsession_move_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); 400 r = mailsession_move_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1());
392 } else { 401 } else {
393 r = mailsession_copy_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); 402 r = mailsession_copy_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1());
394 } 403 }
395 if (r != MAIL_NO_ERROR) { 404 if (r != MAIL_NO_ERROR) {
396 qDebug("Error copy/moving mail internal "); 405 qDebug("Error copy/moving mail internal ");
397 } 406 }
398} 407}
399 408
400void MHwrapper::mvcpAllMails(const FolderP&fromFolder, 409void MHwrapper::mvcpAllMails(const FolderP&fromFolder,
401 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) 410 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
402{ 411{
403 init_storage(); 412 init_storage();
404 if (!m_storage) { 413 if (!m_storage) {
405 return; 414 return;
406 } 415 }
407 if (targetWrapper != this) { 416 if (targetWrapper != this) {
408 qDebug("Using generic "); 417 qDebug("Using generic ");
409 Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); 418 Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit);
410 return; 419 return;
411 } 420 }
412 if (!fromFolder) return; 421 if (!fromFolder) return;
413 int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1()); 422 int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1());
414 if (r!=MAIL_NO_ERROR) { 423 if (r!=MAIL_NO_ERROR) {
415 qDebug("error selecting source folder! "); 424 qDebug("error selecting source folder! ");
416 return; 425 return;
417 } 426 }
418 QString tf = buildPath(targetFolder); 427 QString tf = buildPath(targetFolder);
419 mailmessage_list*l=0; 428 mailmessage_list*l=0;
420 r = mailsession_get_messages_list(m_storage->sto_session,&l); 429 r = mailsession_get_messages_list(m_storage->sto_session,&l);
421 if (r != MAIL_NO_ERROR) { 430 if (r != MAIL_NO_ERROR) {
422 qDebug("Error message list "); 431 qDebug("Error message list ");
423 } 432 }
424 unsigned j = 0; 433 unsigned j = 0;
425 for(unsigned int i = 0 ; l!= 0 && i < carray_count(l->msg_tab) ; ++i) { 434 for(unsigned int i = 0 ; l!= 0 && i < carray_count(l->msg_tab) ; ++i) {
426 mailmessage * msg; 435 mailmessage * msg;
427 msg = (mailmessage*)carray_get(l->msg_tab, i); 436 msg = (mailmessage*)carray_get(l->msg_tab, i);
428 j = msg->msg_index; 437 j = msg->msg_index;
429 if (moveit) { 438 if (moveit) {
430 r = mailsession_move_message(m_storage->sto_session,j,(char*)tf.latin1()); 439 r = mailsession_move_message(m_storage->sto_session,j,(char*)tf.latin1());
431 } else { 440 } else {
432 r = mailsession_copy_message(m_storage->sto_session,j,(char*)tf.latin1()); 441 r = mailsession_copy_message(m_storage->sto_session,j,(char*)tf.latin1());
433 } 442 }
434 if (r != MAIL_NO_ERROR) { 443 if (r != MAIL_NO_ERROR) {
435 qDebug("Error copy/moving mail interna "); 444 qDebug("Error copy/moving mail interna ");
436 445
437 break; 446 break;
diff --git a/kmicromail/libmailwrapper/mhwrapper.h b/kmicromail/libmailwrapper/mhwrapper.h
index 87f8ca1..36a443a 100644
--- a/kmicromail/libmailwrapper/mhwrapper.h
+++ b/kmicromail/libmailwrapper/mhwrapper.h
@@ -1,58 +1,59 @@
1// CHANGED 2004-09-31 Lutz Rogowski 1// CHANGED 2004-09-31 Lutz Rogowski
2#ifndef __MH_WRAPPER_H 2#ifndef __MH_WRAPPER_H
3#define __MH_WRAPPER_H 3#define __MH_WRAPPER_H
4 4
5#include "maildefines.h" 5#include "maildefines.h"
6 6
7#include "genericwrapper.h" 7#include "genericwrapper.h"
8#include <qstring.h> 8#include <qstring.h>
9 9
10class encodedString; 10class encodedString;
11struct mailmbox_folder; 11struct mailmbox_folder;
12class MHwrapper : public Genericwrapper 12class MHwrapper : public Genericwrapper
13{ 13{
14 Q_OBJECT 14 Q_OBJECT
15public: 15public:
16 MHwrapper(const QString & dir,const QString&name); 16 MHwrapper(const QString & dir,const QString&name);
17 virtual ~MHwrapper(); 17 virtual ~MHwrapper();
18 18
19 virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 ); 19 virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 );
20 virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); 20 virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders();
21 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); 21 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
22 22
23 virtual void deleteMail(const RecMailP&mail); 23 virtual void deleteMail(const RecMailP&mail);
24 virtual void answeredMail(const RecMailP&mail); 24 virtual void answeredMail(const RecMailP&mail);
25 virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); 25 virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
26 virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, 26 virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder,
27 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); 27 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
28 28
29 virtual int createMbox(const QString&folder,const Opie::Core::OSmartPointer<Folder>&f=0, 29 virtual int createMbox(const QString&folder,const Opie::Core::OSmartPointer<Folder>&f=0,
30 const QString&d="",bool s=false); 30 const QString&d="",bool s=false);
31 virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&); 31 virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&);
32 32
33 virtual void storeMessage(const char*msg,size_t length, const QString&folder); 33 virtual void storeMessage(const char*msg,size_t length, const QString&folder);
34 34
35 virtual RecBodyP fetchBody( const RecMailP &mail ); 35 virtual RecBodyP fetchBody( const RecMailP &mail );
36 static void mbox_progress( size_t current, size_t maximum ); 36 static void mbox_progress( size_t current, size_t maximum );
37 37
38 virtual encodedString* fetchRawBody(const RecMailP&mail); 38 virtual encodedString* fetchRawBody(const RecMailP&mail);
39 virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> > &target); 39 virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> > &target);
40 virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); 40 virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&);
41 virtual MAILLIB::ATYPE getType()const; 41 virtual MAILLIB::ATYPE getType()const;
42 virtual const QString&getName()const; 42 virtual const QString&getName()const;
43 virtual Account* getAccount() { return 0; }; 43 virtual Account* getAccount() { return 0; };
44 44
45public slots: 45public slots:
46 46
47protected: 47protected:
48 QString buildPath(const QString&p); 48 QString buildPath(const QString&p);
49 QString MHPath; 49 QString MHPath;
50 QString MHName; 50 QString MHName;
51 51
52 void init_storage(); 52 void init_storage();
53 void clean_storage(); 53 void clean_storage();
54 bool rmDir(QString folderabspath);
54 55
55 bool removeMboxfailed; 56 bool removeMboxfailed;
56}; 57};
57 58
58#endif 59#endif