add finally to dump connection log in IMAP
[org.ibex.mail.git] / src / org / ibex / mail / IMAP.java
index b4b3d30..8f5f3d0 100644 (file)
@@ -237,8 +237,8 @@ public class IMAP {
             for(Mailbox.Iterator it = selected().iterator(q); it.next(); ) {
                 Message message = ((spec & (BODYSTRUCTURE | ENVELOPE | INTERNALDATE | FIELDS | FIELDSNOT | RFC822 |
                                             RFC822TEXT | RFC822SIZE | HEADERNOT | HEADER)) != 0) ? it.cur() : null;
-                int size = message == null ? 0 : message.getLength();
-                client.fetch(it.imapNumber(), it.getFlags(), size, message, it.uid());
+                long size = message == null ? 0 : message.getLength();
+                client.fetch(it.imapNumber(), it.getFlags(), (int)size, message, it.uid());
                 it.setFlags(it.getFlags() & ~Mailbox.Flag.RECENT);
             }
         }
@@ -310,10 +310,10 @@ public class IMAP {
                     case EXPUNGE:      selected(); api.expunge(); break;
                     case UNSELECT:     selected(); api.unselect(); selected = false; break;
                     case CREATE:       api.create(token().astring()); break;
-                    case FETCH:        selected(); fetch(((lastuid=uid)
-                                                          ? Query.uid(token().set(maxn(uid)))
-                                                          : Query.imapNumber(token().set(maxn(uid)))),
-                                                        lastfetch=token().lx(), 0, 0, 0, uid, 0); break;
+                    case FETCH:        selected(); lastuid = uid; fetch((uid
+                                                                         ? Query.uid(token().set(maxn(uid)))
+                                                                         : Query.imapNumber(token().set(maxn(uid)))),
+                                                                        lastfetch=token().lx(), 0, 0, 0, uid, 0); break;
                     case COPY:         selected(); api.copy(uid
                                                             ? Query.uid(token().set(maxn(uid)))
                                                             : Query.imapNumber(token().set(maxn(uid))), token().astring()); break;
@@ -358,7 +358,8 @@ public class IMAP {
                         Date arrival = new Date();
                         Parser.Token t = token();
                         if (t.type == t.LIST)   { flags = t.flags();      t = token(); }
-                        if (t.type != t.QUOTED) { arrival = t.datetime(); t = token(); }
+                        Parser.Token t2 = token(false);
+                        if (t2 != null) { arrival = t.datetime(); t = t2; }
                         api.append(m, flags, arrival, t.q());
                         break; }
                     case STORE: {
@@ -385,7 +386,10 @@ public class IMAP {
                     return;
                 }
             } catch (Server.Bad b) { println(tag==null ? "* BAD Invalid tag":(tag + " Bad " + b.toString())); Log.warn(this,b);
-            } catch (Server.No n)  { println(tag==null?"* BAD Invalid tag":(tag+" No "  + n.toString())); Log.warn(this,n); }
+            } catch (Server.No n)  { println(tag==null?"* BAD Invalid tag":(tag+" No "  + n.toString())); Log.warn(this,n);
+            } finally {
+                Log.warn(this, conn.dumpLog()+"\n");
+            }
         }
 
         private Parser.Token[] lastfetch = null; // hack