author | alwin <alwin> | 2004-10-24 00:55:14 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-10-24 00:55:14 (UTC) |
commit | 9755bc969d17fc683791abc5c6fbd50fa3112486 (patch) (unidiff) | |
tree | 0fdcf7b52b2f4627dd3efcd7330b116c4d9c4d98 /noncore/net/mail/libmailwrapper/mhwrapper.cpp | |
parent | 12eed25c7f18285f0e342d49fd3c41eb4b14e151 (diff) | |
download | opie-9755bc969d17fc683791abc5c6fbd50fa3112486.zip opie-9755bc969d17fc683791abc5c6fbd50fa3112486.tar.gz opie-9755bc969d17fc683791abc5c6fbd50fa3112486.tar.bz2 |
new options for pop3 accounts
KATE eated a lot of last spaces in files
some tryouts
Diffstat (limited to 'noncore/net/mail/libmailwrapper/mhwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/mhwrapper.cpp | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.cpp b/noncore/net/mail/libmailwrapper/mhwrapper.cpp index 403afcf..765a21c 100644 --- a/noncore/net/mail/libmailwrapper/mhwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mhwrapper.cpp | |||
@@ -8,50 +8,50 @@ | |||
8 | #include <qpe/global.h> | 8 | #include <qpe/global.h> |
9 | #include <opie2/oprocess.h> | 9 | #include <opie2/oprocess.h> |
10 | #include <opie2/odebug.h> | 10 | #include <opie2/odebug.h> |
11 | 11 | ||
12 | using namespace Opie::Core; | 12 | using namespace Opie::Core; |
13 | MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) | 13 | MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) |
14 | : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) | 14 | : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) |
15 | { | 15 | { |
16 | if (MHPath.length()>0) { | 16 | if (MHPath.length()>0) { |
17 | if (MHPath[MHPath.length()-1]=='/') { | 17 | if (MHPath[MHPath.length()-1]=='/') { |
18 | MHPath=MHPath.left(MHPath.length()-1); | 18 | MHPath=MHPath.left(MHPath.length()-1); |
19 | } | 19 | } |
20 | odebug << MHPath << oendl; | 20 | odebug << MHPath << oendl; |
21 | QDir dir(MHPath); | 21 | QDir dir(MHPath); |
22 | if (!dir.exists()) { | 22 | if (!dir.exists()) { |
23 | dir.mkdir(MHPath); | 23 | dir.mkdir(MHPath); |
24 | } | 24 | } |
25 | init_storage(); | 25 | init_storage(); |
26 | } | 26 | } |
27 | } | 27 | } |
28 | 28 | ||
29 | void MHwrapper::init_storage() | 29 | void MHwrapper::init_storage() |
30 | { | 30 | { |
31 | int r; | 31 | int r; |
32 | QString pre = MHPath; | 32 | QString pre = MHPath; |
33 | if (!m_storage) { | 33 | if (!m_storage) { |
34 | m_storage = mailstorage_new(NULL); | 34 | m_storage = mailstorage_new(NULL); |
35 | r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); | 35 | r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); |
36 | if (r != MAIL_NO_ERROR) { | 36 | if (r != MAIL_NO_ERROR) { |
37 | odebug << "error initializing storage" << oendl; | 37 | odebug << "error initializing storage" << oendl; |
38 | mailstorage_free(m_storage); | 38 | mailstorage_free(m_storage); |
39 | m_storage = 0; | 39 | m_storage = 0; |
40 | return; | 40 | return; |
41 | } | 41 | } |
42 | } | 42 | } |
43 | r = mailstorage_connect(m_storage); | 43 | r = mailstorage_connect(m_storage); |
44 | if (r!=MAIL_NO_ERROR) { | 44 | if (r!=MAIL_NO_ERROR) { |
45 | odebug << "error connecting storage" << oendl; | 45 | odebug << "error connecting storage" << oendl; |
46 | mailstorage_free(m_storage); | 46 | mailstorage_free(m_storage); |
47 | m_storage = 0; | 47 | m_storage = 0; |
48 | } | 48 | } |
49 | } | 49 | } |
50 | 50 | ||
51 | void MHwrapper::clean_storage() | 51 | void MHwrapper::clean_storage() |
52 | { | 52 | { |
53 | if (m_storage) { | 53 | if (m_storage) { |
54 | mailstorage_disconnect(m_storage); | 54 | mailstorage_disconnect(m_storage); |
55 | mailstorage_free(m_storage); | 55 | mailstorage_free(m_storage); |
56 | m_storage = 0; | 56 | m_storage = 0; |
57 | } | 57 | } |
@@ -62,105 +62,105 @@ MHwrapper::~MHwrapper() | |||
62 | clean_storage(); | 62 | clean_storage(); |
63 | } | 63 | } |
64 | 64 | ||
65 | void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) | 65 | void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) |
66 | { | 66 | { |
67 | init_storage(); | 67 | init_storage(); |
68 | if (!m_storage) { | 68 | if (!m_storage) { |
69 | return; | 69 | return; |
70 | } | 70 | } |
71 | QString f = buildPath(mailbox); | 71 | QString f = buildPath(mailbox); |
72 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 72 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
73 | if (r!=MAIL_NO_ERROR) { | 73 | if (r!=MAIL_NO_ERROR) { |
74 | odebug << "listMessages: error selecting folder!" << oendl; | 74 | odebug << "listMessages: error selecting folder!" << oendl; |
75 | return; | 75 | return; |
76 | } | 76 | } |
77 | parseList(target,m_storage->sto_session,f); | 77 | parseList(target,m_storage->sto_session,f); |
78 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); | 78 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); |
79 | } | 79 | } |
80 | 80 | ||
81 | QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() | 81 | QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() |
82 | { | 82 | { |
83 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); | 83 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); |
84 | /* this is needed! */ | 84 | /* this is needed! */ |
85 | if (m_storage) mailstorage_disconnect(m_storage); | 85 | if (m_storage) mailstorage_disconnect(m_storage); |
86 | init_storage(); | 86 | init_storage(); |
87 | if (!m_storage) { | 87 | if (!m_storage) { |
88 | return folders; | 88 | return folders; |
89 | } | 89 | } |
90 | mail_list*flist = 0; | 90 | mail_list*flist = 0; |
91 | clistcell*current=0; | 91 | clistcell*current=0; |
92 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); | 92 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); |
93 | if (r != MAIL_NO_ERROR || !flist) { | 93 | if (r != MAIL_NO_ERROR || !flist) { |
94 | odebug << "error getting folder list" << oendl; | 94 | odebug << "error getting folder list" << oendl; |
95 | return folders; | 95 | return folders; |
96 | } | 96 | } |
97 | for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { | 97 | for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { |
98 | QString t = (char*)current->data; | 98 | QString t = (char*)current->data; |
99 | t.replace(0,MHPath.length(),""); | 99 | t.replace(0,MHPath.length(),""); |
100 | folders->append(new MHFolder(t,MHPath)); | 100 | folders->append(new MHFolder(t,MHPath)); |
101 | } | 101 | } |
102 | mail_list_free(flist); | 102 | mail_list_free(flist); |
103 | return folders; | 103 | return folders; |
104 | } | 104 | } |
105 | 105 | ||
106 | void MHwrapper::deleteMail(const RecMailP&mail) | 106 | void MHwrapper::deleteMail(const RecMailP&mail) |
107 | { | 107 | { |
108 | init_storage(); | 108 | init_storage(); |
109 | if (!m_storage) { | 109 | if (!m_storage) { |
110 | return; | 110 | return; |
111 | } | 111 | } |
112 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 112 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
113 | if (r!=MAIL_NO_ERROR) { | 113 | if (r!=MAIL_NO_ERROR) { |
114 | odebug << "error selecting folder!" << oendl; | 114 | odebug << "error selecting folder!" << oendl; |
115 | return; | 115 | return; |
116 | } | 116 | } |
117 | r = mailsession_remove_message(m_storage->sto_session,mail->getNumber()); | 117 | r = mailsession_remove_message(m_storage->sto_session,mail->getNumber()); |
118 | if (r != MAIL_NO_ERROR) { | 118 | if (r != MAIL_NO_ERROR) { |
119 | odebug << "error deleting mail" << oendl; | 119 | odebug << "error deleting mail" << oendl; |
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | void MHwrapper::answeredMail(const RecMailP&) | 123 | void MHwrapper::answeredMail(const RecMailP&) |
124 | { | 124 | { |
125 | } | 125 | } |
126 | 126 | ||
127 | RecBodyP MHwrapper::fetchBody( const RecMailP &mail ) | 127 | RecBodyP MHwrapper::fetchBody( const RecMailP &mail ) |
128 | { | 128 | { |
129 | RecBodyP body = new RecBody(); | 129 | RecBodyP body = new RecBody(); |
130 | init_storage(); | 130 | init_storage(); |
131 | if (!m_storage) { | 131 | if (!m_storage) { |
132 | return body; | 132 | return body; |
133 | } | 133 | } |
134 | mailmessage * msg; | 134 | mailmessage * msg; |
135 | char*data=0; | 135 | char*data=0; |
136 | 136 | ||
137 | /* mail should hold the complete path! */ | 137 | /* mail should hold the complete path! */ |
138 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 138 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
139 | if (r != MAIL_NO_ERROR) { | 139 | if (r != MAIL_NO_ERROR) { |
140 | return body; | 140 | return body; |
141 | } | 141 | } |
142 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); | 142 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); |
143 | if (r != MAIL_NO_ERROR) { | 143 | if (r != MAIL_NO_ERROR) { |
144 | odebug << "Error fetching mail " << mail->getNumber() << "" << oendl; | 144 | odebug << "Error fetching mail " << mail->getNumber() << "" << oendl; |
145 | return body; | 145 | return body; |
146 | } | 146 | } |
147 | body = parseMail(msg); | 147 | body = parseMail(msg); |
148 | mailmessage_fetch_result_free(msg,data); | 148 | mailmessage_fetch_result_free(msg,data); |
149 | return body; | 149 | return body; |
150 | } | 150 | } |
151 | 151 | ||
152 | void MHwrapper::mbox_progress( size_t current, size_t maximum ) | 152 | void MHwrapper::mbox_progress( size_t current, size_t maximum ) |
153 | { | 153 | { |
154 | odebug << "MH " << current << " von " << maximum << "" << oendl; | 154 | odebug << "MH " << current << " von " << maximum << "" << oendl; |
155 | } | 155 | } |
156 | 156 | ||
157 | QString MHwrapper::buildPath(const QString&p) | 157 | QString MHwrapper::buildPath(const QString&p) |
158 | { | 158 | { |
159 | QString f=""; | 159 | QString f=""; |
160 | if (p.length()==0||p=="/") | 160 | if (p.length()==0||p=="/") |
161 | return MHPath; | 161 | return MHPath; |
162 | if (!p.startsWith(MHPath)) { | 162 | if (!p.startsWith(MHPath)) { |
163 | f+=MHPath; | 163 | f+=MHPath; |
164 | } | 164 | } |
165 | if (!p.startsWith("/")) { | 165 | if (!p.startsWith("/")) { |
166 | f+="/"; | 166 | f+="/"; |
@@ -175,119 +175,119 @@ int MHwrapper::createMbox(const QString&folder,const FolderP&pfolder,const QStri | |||
175 | if (!m_storage) { | 175 | if (!m_storage) { |
176 | return 0; | 176 | return 0; |
177 | } | 177 | } |
178 | QString f; | 178 | QString f; |
179 | if (!pfolder) { | 179 | if (!pfolder) { |
180 | // toplevel folder | 180 | // toplevel folder |
181 | f = buildPath(folder); | 181 | f = buildPath(folder); |
182 | } else { | 182 | } else { |
183 | f = pfolder->getName(); | 183 | f = pfolder->getName(); |
184 | f+="/"; | 184 | f+="/"; |
185 | f+=folder; | 185 | f+=folder; |
186 | } | 186 | } |
187 | odebug << f << oendl; | 187 | odebug << f << oendl; |
188 | int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1()); | 188 | int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1()); |
189 | if (r != MAIL_NO_ERROR) { | 189 | if (r != MAIL_NO_ERROR) { |
190 | odebug << "error creating folder " << r << "" << oendl; | 190 | odebug << "error creating folder " << r << "" << oendl; |
191 | return 0; | 191 | return 0; |
192 | } | 192 | } |
193 | odebug << "Folder created" << oendl; | 193 | odebug << "Folder created" << oendl; |
194 | return 1; | 194 | return 1; |
195 | } | 195 | } |
196 | 196 | ||
197 | void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder) | 197 | void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder) |
198 | { | 198 | { |
199 | init_storage(); | 199 | init_storage(); |
200 | if (!m_storage) { | 200 | if (!m_storage) { |
201 | return; | 201 | return; |
202 | } | 202 | } |
203 | QString f = buildPath(Folder); | 203 | QString f = buildPath(Folder); |
204 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 204 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
205 | if (r!=MAIL_NO_ERROR) { | 205 | if (r!=MAIL_NO_ERROR) { |
206 | odebug << "error selecting folder!" << oendl; | 206 | odebug << "error selecting folder!" << oendl; |
207 | return; | 207 | return; |
208 | } | 208 | } |
209 | r = mailsession_append_message(m_storage->sto_session,(char*)msg,length); | 209 | r = mailsession_append_message(m_storage->sto_session,(char*)msg,length); |
210 | if (r!=MAIL_NO_ERROR) { | 210 | if (r!=MAIL_NO_ERROR) { |
211 | odebug << "error storing mail" << oendl; | 211 | odebug << "error storing mail" << oendl; |
212 | } | 212 | } |
213 | return; | 213 | return; |
214 | } | 214 | } |
215 | 215 | ||
216 | encodedString* MHwrapper::fetchRawBody(const RecMailP&mail) | 216 | encodedString* MHwrapper::fetchRawBody(const RecMailP&mail) |
217 | { | 217 | { |
218 | encodedString*result = 0; | 218 | encodedString*result = 0; |
219 | init_storage(); | 219 | init_storage(); |
220 | if (!m_storage) { | 220 | if (!m_storage) { |
221 | return result; | 221 | return result; |
222 | } | 222 | } |
223 | mailmessage * msg = 0; | 223 | mailmessage * msg = 0; |
224 | char*data=0; | 224 | char*data=0; |
225 | size_t size; | 225 | size_t size; |
226 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 226 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
227 | if (r!=MAIL_NO_ERROR) { | 227 | if (r!=MAIL_NO_ERROR) { |
228 | odebug << "error selecting folder!" << oendl; | 228 | odebug << "error selecting folder!" << oendl; |
229 | return result; | 229 | return result; |
230 | } | 230 | } |
231 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); | 231 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); |
232 | if (r != MAIL_NO_ERROR) { | 232 | if (r != MAIL_NO_ERROR) { |
233 | Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); | 233 | Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); |
234 | return 0; | 234 | return 0; |
235 | } | 235 | } |
236 | r = mailmessage_fetch(msg,&data,&size); | 236 | r = mailmessage_fetch(msg,&data,&size); |
237 | if (r != MAIL_NO_ERROR) { | 237 | if (r != MAIL_NO_ERROR) { |
238 | Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); | 238 | Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); |
239 | if (msg) mailmessage_free(msg); | 239 | if (msg) mailmessage_free(msg); |
240 | return 0; | 240 | return 0; |
241 | } | 241 | } |
242 | result = new encodedString(data,size); | 242 | result = new encodedString(data,size); |
243 | if (msg) mailmessage_free(msg); | 243 | if (msg) mailmessage_free(msg); |
244 | return result; | 244 | return result; |
245 | } | 245 | } |
246 | 246 | ||
247 | void MHwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target) | 247 | void MHwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target) |
248 | { | 248 | { |
249 | QString f = buildPath(mailbox); | 249 | QString f = buildPath(mailbox); |
250 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 250 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
251 | if (r!=MAIL_NO_ERROR) { | 251 | if (r!=MAIL_NO_ERROR) { |
252 | odebug << "deleteMails: error selecting folder!" << oendl; | 252 | odebug << "deleteMails: error selecting folder!" << oendl; |
253 | return; | 253 | return; |
254 | } | 254 | } |
255 | QValueList<RecMailP>::ConstIterator it; | 255 | QValueList<RecMailP>::ConstIterator it; |
256 | for (it=target.begin(); it!=target.end();++it) { | 256 | for (it=target.begin(); it!=target.end();++it) { |
257 | r = mailsession_remove_message(m_storage->sto_session,(*it)->getNumber()); | 257 | r = mailsession_remove_message(m_storage->sto_session,(*it)->getNumber()); |
258 | if (r != MAIL_NO_ERROR) { | 258 | if (r != MAIL_NO_ERROR) { |
259 | odebug << "error deleting mail" << oendl; | 259 | odebug << "error deleting mail" << oendl; |
260 | break; | 260 | break; |
261 | } | 261 | } |
262 | } | 262 | } |
263 | } | 263 | } |
264 | 264 | ||
265 | int MHwrapper::deleteAllMail(const FolderP&tfolder) | 265 | int MHwrapper::deleteAllMail(const FolderP&tfolder) |
266 | { | 266 | { |
267 | init_storage(); | 267 | init_storage(); |
268 | if (!m_storage) { | 268 | if (!m_storage) { |
269 | return 0; | 269 | return 0; |
270 | } | 270 | } |
271 | int res = 1; | 271 | int res = 1; |
272 | if (!tfolder) return 0; | 272 | if (!tfolder) return 0; |
273 | int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); | 273 | int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); |
274 | if (r!=MAIL_NO_ERROR) { | 274 | if (r!=MAIL_NO_ERROR) { |
275 | odebug << "error selecting folder!" << oendl; | 275 | odebug << "error selecting folder!" << oendl; |
276 | return 0; | 276 | return 0; |
277 | } | 277 | } |
278 | mailmessage_list*l=0; | 278 | mailmessage_list*l=0; |
279 | r = mailsession_get_messages_list(m_storage->sto_session,&l); | 279 | r = mailsession_get_messages_list(m_storage->sto_session,&l); |
280 | if (r != MAIL_NO_ERROR) { | 280 | if (r != MAIL_NO_ERROR) { |
281 | odebug << "Error message list" << oendl; | 281 | odebug << "Error message list" << oendl; |
282 | res = 0; | 282 | res = 0; |
283 | } | 283 | } |
284 | unsigned j = 0; | 284 | unsigned j = 0; |
285 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { | 285 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { |
286 | mailmessage * msg; | 286 | mailmessage * msg; |
287 | msg = (mailmessage*)carray_get(l->msg_tab, i); | 287 | msg = (mailmessage*)carray_get(l->msg_tab, i); |
288 | j = msg->msg_index; | 288 | j = msg->msg_index; |
289 | r = mailsession_remove_message(m_storage->sto_session,j); | 289 | r = mailsession_remove_message(m_storage->sto_session,j); |
290 | if (r != MAIL_NO_ERROR) { | 290 | if (r != MAIL_NO_ERROR) { |
291 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | 291 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); |
292 | res = 0; | 292 | res = 0; |
293 | break; | 293 | break; |
@@ -300,46 +300,46 @@ int MHwrapper::deleteAllMail(const FolderP&tfolder) | |||
300 | int MHwrapper::deleteMbox(const FolderP&tfolder) | 300 | int MHwrapper::deleteMbox(const FolderP&tfolder) |
301 | { | 301 | { |
302 | init_storage(); | 302 | init_storage(); |
303 | if (!m_storage) { | 303 | if (!m_storage) { |
304 | return 0; | 304 | return 0; |
305 | } | 305 | } |
306 | if (!tfolder) return 0; | 306 | if (!tfolder) return 0; |
307 | if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; | 307 | if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; |
308 | 308 | ||
309 | int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); | 309 | int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); |
310 | 310 | ||
311 | if (r != MAIL_NO_ERROR) { | 311 | if (r != MAIL_NO_ERROR) { |
312 | odebug << "error deleting mail box" << oendl; | 312 | odebug << "error deleting mail box" << oendl; |
313 | return 0; | 313 | return 0; |
314 | } | 314 | } |
315 | QString cmd = "rm -rf "+tfolder->getName(); | 315 | QString cmd = "rm -rf "+tfolder->getName(); |
316 | QStringList command; | 316 | QStringList command; |
317 | command << "/bin/sh"; | 317 | command << "/bin/sh"; |
318 | command << "-c"; | 318 | command << "-c"; |
319 | command << cmd.latin1(); | 319 | command << cmd.latin1(); |
320 | OProcess *process = new OProcess(); | 320 | OProcess *process = new OProcess(); |
321 | 321 | ||
322 | connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), | 322 | connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), |
323 | this, SLOT( processEnded(Opie::Core::OProcess*))); | 323 | this, SLOT( processEnded(Opie::Core::OProcess*))); |
324 | connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), | 324 | connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), |
325 | this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int))); | 325 | this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int))); |
326 | 326 | ||
327 | *process << command; | 327 | *process << command; |
328 | removeMboxfailed = false; | 328 | removeMboxfailed = false; |
329 | if(!process->start(OProcess::Block, OProcess::All) ) { | 329 | if(!process->start(OProcess::Block, OProcess::All) ) { |
330 | odebug << "could not start process" << oendl; | 330 | odebug << "could not start process" << oendl; |
331 | return 0; | 331 | return 0; |
332 | } | 332 | } |
333 | odebug << "mail box deleted" << oendl; | 333 | odebug << "mail box deleted" << oendl; |
334 | return 1; | 334 | return 1; |
335 | } | 335 | } |
336 | 336 | ||
337 | void MHwrapper::processEnded(OProcess *p) | 337 | void MHwrapper::processEnded(OProcess *p) |
338 | { | 338 | { |
339 | if (p) delete p; | 339 | if (p) delete p; |
340 | } | 340 | } |
341 | 341 | ||
342 | void MHwrapper::oprocessStderr(OProcess*, char *buffer, int ) | 342 | void MHwrapper::oprocessStderr(OProcess*, char *buffer, int ) |
343 | { | 343 | { |
344 | QString lineStr = buffer; | 344 | QString lineStr = buffer; |
345 | QMessageBox::warning( 0, tr("Error"), lineStr ,tr("Ok") ); | 345 | QMessageBox::warning( 0, tr("Error"), lineStr ,tr("Ok") ); |
@@ -370,74 +370,74 @@ MAILLIB::ATYPE MHwrapper::getType()const | |||
370 | 370 | ||
371 | const QString&MHwrapper::getName()const | 371 | const QString&MHwrapper::getName()const |
372 | { | 372 | { |
373 | return MHName; | 373 | return MHName; |
374 | } | 374 | } |
375 | void MHwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 375 | void MHwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
376 | { | 376 | { |
377 | init_storage(); | 377 | init_storage(); |
378 | if (!m_storage) { | 378 | if (!m_storage) { |
379 | return; | 379 | return; |
380 | } | 380 | } |
381 | if (targetWrapper != this) { | 381 | if (targetWrapper != this) { |
382 | odebug << "Using generic" << oendl; | 382 | odebug << "Using generic" << oendl; |
383 | Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); | 383 | Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); |
384 | return; | 384 | return; |
385 | } | 385 | } |
386 | odebug << "Using internal routines for move/copy" << oendl; | 386 | odebug << "Using internal routines for move/copy" << oendl; |
387 | QString tf = buildPath(targetFolder); | 387 | QString tf = buildPath(targetFolder); |
388 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 388 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
389 | if (r != MAIL_NO_ERROR) { | 389 | if (r != MAIL_NO_ERROR) { |
390 | odebug << "Error selecting source mailbox" << oendl; | 390 | odebug << "Error selecting source mailbox" << oendl; |
391 | return; | 391 | return; |
392 | } | 392 | } |
393 | if (moveit) { | 393 | if (moveit) { |
394 | r = mailsession_move_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); | 394 | r = mailsession_move_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); |
395 | } else { | 395 | } else { |
396 | r = mailsession_copy_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); | 396 | r = mailsession_copy_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); |
397 | } | 397 | } |
398 | if (r != MAIL_NO_ERROR) { | 398 | if (r != MAIL_NO_ERROR) { |
399 | odebug << "Error copy/moving mail internal (" << r << ")" << oendl; | 399 | odebug << "Error copy/moving mail internal (" << r << ")" << oendl; |
400 | } | 400 | } |
401 | } | 401 | } |
402 | 402 | ||
403 | void MHwrapper::mvcpAllMails(const FolderP&fromFolder, | 403 | void MHwrapper::mvcpAllMails(const FolderP&fromFolder, |
404 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 404 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
405 | { | 405 | { |
406 | init_storage(); | 406 | init_storage(); |
407 | if (!m_storage) { | 407 | if (!m_storage) { |
408 | return; | 408 | return; |
409 | } | 409 | } |
410 | if (targetWrapper != this) { | 410 | if (targetWrapper != this) { |
411 | odebug << "Using generic" << oendl; | 411 | odebug << "Using generic" << oendl; |
412 | Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); | 412 | Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); |
413 | return; | 413 | return; |
414 | } | 414 | } |
415 | if (!fromFolder) return; | 415 | if (!fromFolder) return; |
416 | int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1()); | 416 | int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1()); |
417 | if (r!=MAIL_NO_ERROR) { | 417 | if (r!=MAIL_NO_ERROR) { |
418 | odebug << "error selecting source folder!" << oendl; | 418 | odebug << "error selecting source folder!" << oendl; |
419 | return; | 419 | return; |
420 | } | 420 | } |
421 | QString tf = buildPath(targetFolder); | 421 | QString tf = buildPath(targetFolder); |
422 | mailmessage_list*l=0; | 422 | mailmessage_list*l=0; |
423 | r = mailsession_get_messages_list(m_storage->sto_session,&l); | 423 | r = mailsession_get_messages_list(m_storage->sto_session,&l); |
424 | if (r != MAIL_NO_ERROR) { | 424 | if (r != MAIL_NO_ERROR) { |
425 | odebug << "Error message list" << oendl; | 425 | odebug << "Error message list" << oendl; |
426 | } | 426 | } |
427 | unsigned j = 0; | 427 | unsigned j = 0; |
428 | for(unsigned int i = 0 ; l!= 0 && i < carray_count(l->msg_tab) ; ++i) { | 428 | for(unsigned int i = 0 ; l!= 0 && i < carray_count(l->msg_tab) ; ++i) { |
429 | mailmessage * msg; | 429 | mailmessage * msg; |
430 | msg = (mailmessage*)carray_get(l->msg_tab, i); | 430 | msg = (mailmessage*)carray_get(l->msg_tab, i); |
431 | j = msg->msg_index; | 431 | j = msg->msg_index; |
432 | if (moveit) { | 432 | if (moveit) { |
433 | r = mailsession_move_message(m_storage->sto_session,j,(char*)tf.latin1()); | 433 | r = mailsession_move_message(m_storage->sto_session,j,(char*)tf.latin1()); |
434 | } else { | 434 | } else { |
435 | r = mailsession_copy_message(m_storage->sto_session,j,(char*)tf.latin1()); | 435 | r = mailsession_copy_message(m_storage->sto_session,j,(char*)tf.latin1()); |
436 | } | 436 | } |
437 | if (r != MAIL_NO_ERROR) { | 437 | if (r != MAIL_NO_ERROR) { |
438 | odebug << "Error copy/moving mail internal (" << r << ")" << oendl; | 438 | odebug << "Error copy/moving mail internal (" << r << ")" << oendl; |
439 | break; | 439 | break; |
440 | } | 440 | } |
441 | } | 441 | } |
442 | if (l) mailmessage_list_free(l); | 442 | if (l) mailmessage_list_free(l); |
443 | } | 443 | } |