summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/mhwrapper.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/kmicromail/libmailwrapper/mhwrapper.cpp b/kmicromail/libmailwrapper/mhwrapper.cpp
index 982d7a6..787e85d 100644
--- a/kmicromail/libmailwrapper/mhwrapper.cpp
+++ b/kmicromail/libmailwrapper/mhwrapper.cpp
@@ -155,85 +155,92 @@ RecBodyP MHwrapper::fetchBody( const RecMailP &mail )
155 155
156void MHwrapper::mbox_progress( size_t current, size_t maximum ) 156void MHwrapper::mbox_progress( size_t current, size_t maximum )
157{ 157{
158 qDebug("MBox Progress %d of %d",current,maximum ); 158 qDebug("MBox Progress %d of %d",current,maximum );
159 //odebug << "MH " << current << " von " << maximum << "" << oendl; 159 //odebug << "MH " << current << " von " << maximum << "" << oendl;
160} 160}
161 161
162QString MHwrapper::buildPath(const QString&p) 162QString MHwrapper::buildPath(const QString&p)
163{ 163{
164 QString f=""; 164 QString f="";
165 if (p.length()==0||p=="/") 165 if (p.length()==0||p=="/")
166 return MHPath; 166 return MHPath;
167 if (!p.startsWith(MHPath)) { 167 if (!p.startsWith(MHPath)) {
168 f+=MHPath; 168 f+=MHPath;
169 } 169 }
170 if (!p.startsWith("/")) { 170 if (!p.startsWith("/")) {
171 f+="/"; 171 f+="/";
172 } 172 }
173 f+=p; 173 f+=p;
174 return f; 174 return f;
175} 175}
176 176
177int MHwrapper::createMbox(const QString&folder,const FolderP&pfolder,const QString&,bool ) 177int MHwrapper::createMbox(const QString&folder,const FolderP&pfolder,const QString&,bool )
178{ 178{
179 init_storage(); 179
180 if (!m_storage) {
181 return 0;
182 }
183 QString f; 180 QString f;
184 if (!pfolder) { 181 if (!pfolder) {
185 // toplevel folder 182 // toplevel folder
186 f = buildPath(folder); 183 f = buildPath(folder);
187 } else { 184 } else {
188 f = pfolder->getName(); 185 f = pfolder->getName();
189 f+="/"; 186 f+="/";
190 f+=folder; 187 f+=folder;
191 } 188 }
192 189 QFileInfo fi ( f );
190 if ( fi. exists () ) {
191 qDebug("folder exists ");
192 return 1;
193 }
194 qDebug("creating folder ---%s--- ",f.latin1() );
195 init_storage();
196 if (!m_storage) {
197 return 0;
198 }
193 int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1()); 199 int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1());
194 if (r != MAIL_NO_ERROR) { 200 if (r != MAIL_NO_ERROR) {
195 qDebug("error creating folder "); 201 qDebug("error %d creating folder %s", r, f.latin1());
196 return 0; 202 return 0;
197 } 203 }
198 return 1; 204 return 1;
199} 205}
200 206
201void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder) 207void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder)
202{ 208{
203 init_storage(); 209 init_storage();
204 if (!m_storage) { 210 if (!m_storage) {
205 return; 211 return;
206 } 212 }
207 QString f = buildPath(Folder); 213 QString f = buildPath(Folder);
208 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); 214 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1());
209 if (r!=MAIL_NO_ERROR) { 215 if (r!=MAIL_NO_ERROR) {
210 qDebug("error selecting folder! "); 216 qDebug("error selecting folder %d", r);
211 return; 217 return;
212 } 218 }
213 r = mailsession_append_message(m_storage->sto_session,(char*)msg,length); 219 r = mailsession_append_message(m_storage->sto_session,(char*)msg,length);
214 if (r!=MAIL_NO_ERROR) { 220 if (r!=MAIL_NO_ERROR) {
215 qDebug("error storing mail "); 221 if ( r != MAIL_ERROR_APPEND )
222 qDebug("error storing mail %d", r);
216 } 223 }
217 return; 224 return;
218} 225}
219 226
220encodedString* MHwrapper::fetchRawBody(const RecMailP&mail) 227encodedString* MHwrapper::fetchRawBody(const RecMailP&mail)
221{ 228{
222 encodedString*result = 0; 229 encodedString*result = 0;
223 init_storage(); 230 init_storage();
224 if (!m_storage) { 231 if (!m_storage) {
225 return result; 232 return result;
226 } 233 }
227 mailmessage * msg = 0; 234 mailmessage * msg = 0;
228 char*data=0; 235 char*data=0;
229 size_t size; 236 size_t size;
230 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); 237 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1());
231 if (r!=MAIL_NO_ERROR) { 238 if (r!=MAIL_NO_ERROR) {
232 qDebug("error selecting folder! "); 239 qDebug("error selecting folder! ");
233 return result; 240 return result;
234 } 241 }
235 r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); 242 r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg);
236 if (r != MAIL_NO_ERROR) { 243 if (r != MAIL_NO_ERROR) {
237 Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); 244 Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber()));
238 return 0; 245 return 0;
239 } 246 }