offlineimap rev 557

"Automatic Subversion Change Mailer" <[email protected]> Tue, 12 Aug 2003 15:09:29 -0500 (CDT)
Newsgroups gmane.mail.imap.offlineimap.subversion
Message-ID <[email protected]>
You are receiving this message because
all commits get sent to this address.

Author: jgoerzen
Date: 2003-08-12 15:09:10 -0500 (Tue, 12 Aug 2003)
New Revision: 557

Modified:
  offlineimap/branches/twisted/offlineimap/folder/IMAP.py
  offlineimap/branches/twisted/twistedfixes/imap4.diff

Log:
It can now copy messages up to the remote.


Diff:
Modified: offlineimap/branches/twisted/offlineimap/folder/IMAP.py
===================================================================
--- offlineimap/branches/twisted/offlineimap/folder/IMAP.py	2003-08-05 20:58:49 UTC (rev 556)
+++ offlineimap/branches/twisted/offlineimap/folder/IMAP.py	2003-08-12 20:09:10 UTC (rev 557)
@@ -23,6 +23,7 @@
 from StringIO import StringIO
 from copy import copy
 from twisted.internet import defer
+from twisted.protocols.imap4 import Query
 from offlineimap.imaputil import rd
 
 class IMAPFolder(BaseFolder, imaputil.AcquireMixin):
@@ -121,7 +122,6 @@
         return d
 
     def _getmessage_process(self, message):
-        print "***** _getmessage_process: got", message
         key = message.keys()[0]
         data = message[key][0]
         i = data.index('BODY') + 1
@@ -170,22 +170,27 @@
         ui.debug('imap', 'savemessage_searchforheader called for %s: %s' % \
                  (headername, headervalue))
         # Now find the UID it got.
-        headervalue = imapobj._quote(headervalue)
         query = Query(header = (headername, headervalue))
         d = imapobj.search(query, uid = 1)
-        ## FIXME: START HERE
-        matchinguids = imapobj.uid('search', None,
-                                       '(HEADER %s %s)' % (headername, headervalue))[1][0]
+        d.addCallback(self._savemessage_searchforheader_2, imapobj, headername,
+                      headervalue)
+        return d
+
+    def _savemessage_searchforheader_2(self, matchinguids, imapobj, headername,
+                                       headervalue):
+        ui = UIBase.getglobalui()
         # FIXME
         #except imapobj.error:
         #    # IMAP server doesn't implement search or had a problem.
         #    return 0
-        ui.debug('imap', 'savemessage_searchforheader got initial matchinguids: ' + repr(matchinguids))
+        ui.debug('imap',
+                 'savemessage_searchforheader got initial matchinguids: ' \
+                 + repr(matchinguids))
                
-        matchinguids = matchinguids.split(' ')
         ui.debug('imap', 'savemessage_searchforheader: matchinguids now ' + \
                  repr(matchinguids))
-        if len(matchinguids) != 1 or matchinguids[0] == None:
+        if matchinguids == None or \
+               len(matchinguids) != 1 or matchinguids[0] == None:
             raise ValueError, "While attempting to find UID for message with header %s, got wrong-sized matchinguids of %s" % (headername, str(matchinguids))
         matchinguids.sort()
         return long(matchinguids[0])
@@ -272,6 +277,7 @@
             return self.savemessage_register(None, uid, flags)
 
     def savemessage_register(self, ignore, uid, flags):
+        ui = UIBase.getglobalui()
         print "This is savemessage_register"
         #self.imapserver.releaseconnection(imapobj)
         self.messagelist[uid] = {'uid': uid, 'flags': flags}

Added: offlineimap/branches/twisted/twistedfixes/imap4.diff
===================================================================
--- offlineimap/branches/twisted/twistedfixes/imap4.diff	2003-08-05 20:58:49 UTC (rev 556)
+++ offlineimap/branches/twisted/twistedfixes/imap4.diff	2003-08-12 20:09:10 UTC (rev 557)
@@ -0,0 +1,22 @@
+--- /home/jgoerzen/tree/Twisted/twisted/protocols/imap4.py	2003-07-25 16:04:29.000000000 -0500
++++ imap4.py	2003-08-05 15:42:49.000000000 -0500
+@@ -2189,6 +2189,10 @@
+                     raise IllegalServerResponse('(%s %s): %s' % (k, status[k], str(e)))
+         return status
+ 
++    def sendLine(self, line):
++        print 'C:', repr(line)
++        return basic.LineReceiver.sendLine(self, line)
++
+     def append(self, mailbox, message, flags = (), date = None):
+         """Add the given message to the currently selected mailbox
+ 
+@@ -2858,7 +2862,7 @@
+         store = uid and 'UID STORE' or 'STORE'
+         args = ' '.join((messages, cmd, '(%s)' % ' '.join(flags)))
+         d = self.sendCommand(Command(store, args, wantResponse=('FETCH',)))
+-        d.addCallback(self.__cbFetch, lookFor='FLAGS')
++        d.addCallback(self.__cbFetch)
+         return d
+     
+     def copy(self, messages, mailbox, uid):