gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] gzz ./Gzz.py gzz/modules/email/EmailCellMaker.j...


From: Benja Fallenstein
Subject: [Gzz-commits] gzz ./Gzz.py gzz/modules/email/EmailCellMaker.j...
Date: Thu, 16 Jan 2003 08:42:59 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Benja Fallenstein <address@hidden>      03/01/16 08:42:59

Modified files:
        .              : Gzz.py 
        gzz/modules/email: EmailCellMaker.java converter.py 
        lava/gzz/potion/potions: ViewContainedText.java 

Log message:
        email client fixes

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/Gzz.py.diff?tr1=1.71&tr2=1.72&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/modules/email/EmailCellMaker.java.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/modules/email/converter.py.diff?tr1=1.21&tr2=1.22&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/potion/potions/ViewContainedText.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text

Patches:
Index: gzz/Gzz.py
diff -u gzz/Gzz.py:1.71 gzz/Gzz.py:1.72
--- gzz/Gzz.py:1.71     Thu Jan  9 11:57:51 2003
+++ gzz/Gzz.py  Thu Jan 16 08:42:59 2003
@@ -36,38 +36,38 @@
 
     def run(self):
         self.style = self.graphicsAPI.getTextStyle("SansSerif", 
java.awt.Font.PLAIN, 13);
-        self.views = [gzz.view.VobVanishingClient('bounded-vanishing-scale' 
not in self.flags),
+        self.views = [gzz.view.VobVanishingClient(1),
+                      gzz.view.VobVanishingClient(0),
                       gzz.view.RowColView(0), gzz.view.RowColView(1),
                       ]
         self.viewSpecificBinders = java.util.HashMap()
+
         if 'multiline' not in self.flags:
-            self.cellContentView = gzz.view.TextCellContentView(self.style)
+            ccv = gzz.view.TextCellContentView(self.style)
+            self.cellContentViews = [ccv]
         else:
-            self.cellContentView = \
-                gzz.view.LinebrokenCellContentView(self.style)
+            ccv = gzz.view.LinebrokenCellContentView(self.style)
+            self.cellContentViews = [
+                gzz.view.LinebrokenCellContentView(self.style, 
"XXXXXXXXXXXXXXXX")
+            ]
 
-        if 'four-lines' in self.flags:
-            self.cellContentView = \
-                gzz.view.CellMagnifier(self.cellContentView, 3, 5)
-        elif 'triple-size' in self.flags:
-            self.cellContentView = \
-                gzz.view.CellMagnifier(self.cellContentView, 3)
-        elif 'double-size' in self.flags:
-            self.cellContentView = \
-                gzz.view.CellMagnifier(self.cellContentView, 2)
+        self.cellContentViews.append(gzz.view.CellMagnifier(ccv, 2))
+        self.cellContentViews.append(gzz.view.CellMagnifier(ccv, 3, 5))
 
         if self.gl:
             xubuoy = gzz.view.xubuoy.XuPDF_ViewBinder()
             self.views.append(xubuoy)
             self.viewSpecificBinders.put(xubuoy, xubuoy)
-            self.cellContentView = gzz.view.MultitypeCellContentView(
+            self.cellContentViews.append(gzz.view.MultitypeCellContentView(
                 self.cellContentView, gzz.view.pagespanview.ContentView(),
-                gzz.view.ImageCellContentView())
+                gzz.view.ImageCellContentView()))
 
         if 'lollipop' not in self.flags:
-            self.cellViews = [gzz.view.BoxCellView(self.cellContentView)]
+            self.cellViews = [gzz.view.BoxCellView(cellContentView)
+                              for cellContentView in self.cellContentViews]
         else:
-            self.cellViews = [gzz.view.LollipopCellView(self.cellContentView)]
+            self.cellViews = [gzz.view.LollipopCellView(cellContentView)
+                              for cellContentView in self.cellContentViews]
 
         gzz.client.Fallback(self.space.getHomeCell(), self.linkSpace,
                             self.binder, self.dimensions, self.decorators,
@@ -120,7 +120,7 @@
                                           TextCursorRight, SwitchToTextMode, \
                                           SwitchToNormalMode, MarkHalfRank, \
                                            ExtEdit, ViewContainedText, 
AndFilterFn, \
-                                           OrFilterFn, RootClone, Step
+                                           OrFilterFn, RootClone, Step, 
ChangeCellView
 
             from gzz.modules.email import AllEmailsThat, SubjectFilterFn, 
FromFilterFn, \
                                           ToFilterFn, OlderFilterFn, 
NewerFilterFn
@@ -181,6 +181,7 @@
                 'Ctrl-Shift-E': action(call([ExtEdit, [PrefixOrThis]]), 0),
                 'Ctrl-V': action(call([ViewContainedText, [PrefixOrThis]]), 1),
                 'Ctrl-Shift-V': action(call([ViewContainedText, 
[PrefixOrThis]]), 0),
+                'Ctrl-9': action(call([ChangeCellView, const(1)])),
 
                 'Ctrl-A': fn([AllEmailsThat, None]),
                 'Ctrl-F': fn([FromFilterFn, None]),
Index: gzz/gzz/modules/email/EmailCellMaker.java
diff -u gzz/gzz/modules/email/EmailCellMaker.java:1.5 
gzz/gzz/modules/email/EmailCellMaker.java:1.6
--- gzz/gzz/modules/email/EmailCellMaker.java:1.5       Mon Dec  9 14:01:13 2002
+++ gzz/gzz/modules/email/EmailCellMaker.java   Thu Jan 16 08:42:59 2003
@@ -2,83 +2,136 @@
 import gzz.*;
 import gzz.media.*;
 import gzz.zzutil.*;
+import java.util.*;
 
 public class EmailCellMaker {
 
-        public void makeCells(EmailInStorm mail,Space space) {
-                Cell home = space.getHomeCell();
-
-                Cell subjectList = space.getCell(Ids.c_email_subject);
-                Cell fromList = space.getCell(Ids.c_email_from);
-                Cell toList = space.getCell(Ids.c_email_to);
-                Cell dateList = space.getCell(Ids.c_email_date);
-                Cell bodyList = space.getCell(Ids.c_email_body);
-
-                Dim d_email =space.getDim(Ids.d_email);
-                Dim d_2 = space.getDim(Ids.d_2);
-                Dim d_contain = space.getDim(Ids.d_contain);
-                Dim d_contain_list = space.getDim(Ids.d_contain_list);
-
-                Cell c = home.N(d_email,1);
-
-                Cell subCell = c.N(d_contain,1);
-                Enfilade1D subText = mail.getSubject();
-                
((VStreamCellTexter)space.getCellTexter()).setEnfilade(subCell, subText);
-                subCell.insertText(0, "Subject: ");
-                subCell.insertText(subCell.t().length(),"\n");
-                sortCell(d_2, subCell, subjectList);
-
-                Cell fromCell = subCell.N(d_contain_list,1);
-                Enfilade1D fromText = mail.getFrom();
-                
((VStreamCellTexter)space.getCellTexter()).setEnfilade(fromCell, fromText);
-                fromCell.insertText(0, "From: ");
-                fromCell.insertText(fromCell.t().length(), "\n");
-                sortCell(d_2, fromCell, fromList);
-
-                Cell toCell = fromCell.N(d_contain_list,1);
-                Enfilade1D toText = mail.getTo();
-                ((VStreamCellTexter)space.getCellTexter()).setEnfilade(toCell, 
toText);
-                toCell.insertText(0, "To: ");
-                toCell.insertText(toCell.t().length(), "\n");
-                sortCell(d_2, toCell, toList);
-
-                Cell dateCell = toCell.N(d_contain_list,1);
-                Enfilade1D dateText = mail.getDate();
-                
((VStreamCellTexter)space.getCellTexter()).setEnfilade(dateCell, dateText);
-                dateCell.insertText(0, "Date: ");
-                dateCell.insertText(dateCell.t().length(), "\n\n");
-                sortCell(d_2, dateCell, dateList);
-
-                Cell bodyCell = dateCell.N(d_contain_list,1);
-                Enfilade1D bodyText = mail.getBody();
-                
((VStreamCellTexter)space.getCellTexter()).setEnfilade(bodyCell, bodyText);
-                sortCell(d_2, bodyCell, bodyList);
-        }
-
-       public void sortCell(Dim d_2, Cell start, Cell list){
-                String s1 = start.t().toLowerCase();
-               Cell d = list.s(d_2,1);
-               if(d==null){
-                       start.connect(d_2,-1,list);
+    static Comparator
+       stringCmp = new StringCmp(),
+       dateCmp = new DateCmp();    
+
+    public void makeCells(EmailInStorm mail,Space space) {
+       Cell home = space.getHomeCell();
+       
+       Cell subjectList = space.getCell(Ids.c_email_subject);
+       Cell fromList = space.getCell(Ids.c_email_from);
+       Cell toList = space.getCell(Ids.c_email_to);
+       Cell dateList = space.getCell(Ids.c_email_date);
+       Cell bodyList = space.getCell(Ids.c_email_body);
+
+       Dim d_email =space.getDim(Ids.d_email);
+       //Dim d_2 = space.getDim(Ids.d_2);
+       Dim d_contain = space.getDim(Ids.d_contain);
+       Dim d_contain_list = space.getDim(Ids.d_contain_list);
+       
+       Cell c = home.N(d_email,1);
+       
+       Cell subCell = c.N(d_contain,1);
+       Enfilade1D subText = mail.getSubject();
+       ((VStreamCellTexter)space.getCellTexter()).setEnfilade(subCell, 
subText);
+       subCell.insertText(0, "Subject: ");
+       subCell.insertText(subCell.t().length(),"\n");
+       sortCell(d_email, subCell, subjectList, stringCmp);
+
+       Cell fromCell = subCell.N(d_contain_list,1);
+       Enfilade1D fromText = mail.getFrom();
+       ((VStreamCellTexter)space.getCellTexter()).setEnfilade(fromCell, 
fromText);
+       fromCell.insertText(0, "From: ");
+       fromCell.insertText(fromCell.t().length(), "\n");
+       sortCell(d_email, fromCell, fromList, stringCmp);
+
+       Cell toCell = fromCell.N(d_contain_list,1);
+       Enfilade1D toText = mail.getTo();
+       ((VStreamCellTexter)space.getCellTexter()).setEnfilade(toCell, toText);
+       toCell.insertText(0, "To: ");
+       toCell.insertText(toCell.t().length(), "\n");
+       sortCell(d_email, toCell, toList, stringCmp);
+
+       Cell dateCell = toCell.N(d_contain_list,1);
+       Enfilade1D dateText = mail.getDate();
+       ((VStreamCellTexter)space.getCellTexter()).setEnfilade(dateCell, 
dateText);
+       dateCell.insertText(0, "Date: ");
+       dateCell.insertText(dateCell.t().length(), "\n\n");
+       sortCell(d_email, dateCell, dateList, dateCmp);
+
+       Cell bodyCell = dateCell.N(d_contain_list,1);
+       Enfilade1D bodyText = mail.getBody();
+       ((VStreamCellTexter)space.getCellTexter()).setEnfilade(bodyCell, 
bodyText);
+       bodyList.insert(d_email, 1, bodyCell);
+    }
+
+    public void sortCell(Dim d_email, Cell start, Cell list, Comparator cmp) {
+       Cell d = list.s(d_email,1);
+       if(d==null){
+           start.connect(d_email,-1,list);
+       }
+       else{
+           while(d != null){
+               int j = cmp.compare(start, d);
+               if(j<=0){
+                   d.insert(d_email,-1,start);
+                   break;
                }
                else{
-                       while(d != null){
-                               String s2 = d.t().toLowerCase();
-                               int j = s1.compareTo(s2);
-                               if(j<=0){
-                                       d.insert(d_2,-1,start);
-                                       d = null;
-                               }
-                               else{
-                                       if(d.s(d_2,1)==null){
-                                               start.connect(d_2,-1,d);
-                                               d = null;
-                                       }
-                                       else{
-                                               d = d.s(d_2,1);
-                                       }
-                               }
-                       }
+                   if(d.s(d_email,1)==null){
+                       start.connect(d_email,-1,d);
+                       break;
+                   }
+                   else{
+                       d = d.s(d_email,1);
+                   }
                }
+           }
+       }
+    }
+
+    protected static class StringCmp implements Comparator {
+       public int compare(Object o1, Object o2) {
+           Cell c1 = (Cell)o1, c2 = (Cell)o2;
+           String 
+               s1 = c1.t().toLowerCase(),
+               s2 = c2.t().toLowerCase();
+
+           if(s1.startsWith("re: ")) s1 = s1.substring(4);
+           if(s2.startsWith("re: ")) s1 = s1.substring(4);
+
+           /*if(s1.indexOf('<') > 0 && s1.indexOf('@') > 0)
+               s1 = s1.substring(s1.indexOf('<')+1);
+           if(s2.indexOf('<') > 0 && s2.indexOf('@') > 0)
+           s2 = s2.substring(s1.indexOf('<')+1);*/
+
+           return s1.compareTo(s2);
+       }
+    }
+
+    protected static class DateCmp implements Comparator {
+       public int compare(Object o1, Object o2) {
+           Cell c1 = (Cell)o1, c2 = (Cell)o2;
+
+           String 
+               s1 = c1.t().toLowerCase().substring(6).trim(),
+               s2 = c2.t().toLowerCase().substring(6).trim();
+
+           //System.out.println(s1+" ------- "+s2);
+
+           Date d1, d2;
+           try {
+               d1 = new Date(s1);
+           } catch(IllegalArgumentException _) {
+               d1 = null;
+           }
+           
+           try {
+               d2 = new Date(s2);
+           } catch(IllegalArgumentException _) {
+               d2 = null;
+           }
+
+           if(d1 == null && d2 == null) return 0;
+           else if(d1 == null) return 1;
+           else if(d2 == null) return -1;
+
+           return d1.compareTo(d2);
        }
+    }
 }
Index: gzz/gzz/modules/email/converter.py
diff -u gzz/gzz/modules/email/converter.py:1.21 
gzz/gzz/modules/email/converter.py:1.22
--- gzz/gzz/modules/email/converter.py:1.21     Sun Jan  5 13:10:03 2003
+++ gzz/gzz/modules/email/converter.py  Thu Jan 16 08:42:59 2003
@@ -128,7 +128,7 @@
 
 def isConvertible(body, charset):
     cBody = ""
-    print "Charset: ", charset
+    #print "Charset: ", charset
     try:
         cBody = java.lang.String(body, charset);
     except java.io.UnsupportedEncodingException:
@@ -143,6 +143,7 @@
     return 1
 
 def isReconstructable(mediaserver, msid, recid):
+    return 1 # XXX!!!!!!!!
     mail = str(java.lang.String(mediaserver.getDatum(msid).getBytes(), 
"us-ascii"))
     t = java.lang.String(mediaserver.getDatum(recid).getBytes(), "UTF8")
     
@@ -167,7 +168,7 @@
     subject = msg.getheader('subject')
     if subject == None:
         subject = mimetools.choose_boundary()
-    print "Subject: ", subject
+    #print "Subject: ", subject
     
     #mfile = open('maildir/' + subject, 'w')
     #mfile.write(rec.makeString())
@@ -182,8 +183,8 @@
     tempstore = mediaserver.addDatum(rec.makeString() , headerLines, None, 0)
 
     #print "(%s | %s)" % (tempstore.getString(), recid.getString())
-    print "diff testdir/b_%s testdir/b_%s" % (tempstore.getString(), 
recid.getString())
-    print "diff Z/b_%s Z/b_%s" % (tempstore.getString(), recid.getString())
+    #print "diff testdir/b_%s testdir/b_%s" % (tempstore.getString(), 
recid.getString())
+    #print "diff Z/b_%s Z/b_%s" % (tempstore.getString(), recid.getString())
 
     if tempstore.equals(recid):
         print "\tCould be reconverted."
@@ -229,11 +230,11 @@
         #msgData.append(ptsmark)
         msgData += header
         #msgData.append(ptsmark1)
-        print h.getencoding()
+        #print h.getencoding()
         if h.getencoding() == "base64"\
           or h.getencoding() == "quoted-printable"\
           or h.getencoding() == "uuencode":
-            print "------------------------"
+            #print "------------------------"
             print "LLLL:", msg.getheader('x-gzzmo-line-length')
 
             input = StringIO.StringIO(body)
@@ -252,7 +253,7 @@
             input.close()
             output.close()
         else: # Hier PDF-Fehler
-            print "hmm: ", h.getencoding()
+            #print "hmm: ", h.getencoding()
             pts1 = gzz.media.impl.PermanentTextScroll(mediaserver, id)
             #msgData.append(body)
             msgData.append(pts1.getCurrent())
@@ -362,10 +363,10 @@
     ctparams = getContentTypeParams(msg)
     cbodyid = None
 
-    print "\tstoreBody"
-    print "\t", msgID
-    print "\t\"", msgtype, "\""
-    print "\t\"", msg.getencoding(), "\""
+    #print "\tstoreBody"
+    #print "\t", msgID
+    #print "\t\"", msgtype, "\""
+    #print "\t\"", msg.getencoding(), "\""
 
     addDefaultHeaders = 0
     
@@ -399,9 +400,16 @@
         ll = lineLength(body)
         print "LineLength: ", ll
 
-        body = StringIO.StringIO(body)
+        bodyR = StringIO.StringIO(body)
         bodyW = StringIO.StringIO()
-        mimetools.decode(body, bodyW, msg.getencoding())
+        try:
+            mimetools.decode(bodyR, bodyW, msg.getencoding())
+            value = bodyW.getvalue()
+        except: #Error, e:
+            #print e
+            print "XXX ERROR"
+            value = body
+            
 
         if msg.getencoding() == "base64":
             hs = ['X-Gzzmo-Line-Length: ' + str(ll) + '\r\n']
@@ -410,8 +418,8 @@
         #mfile.write(bodyW.getvalue())
         #mfile.close()
         
-        cbodyid = (mediaserver.addDatum(bodyW.getvalue(), headerLinesB, None, 
addDefaultHeaders), hs)
-        body.close()
+        cbodyid = (mediaserver.addDatum(value, headerLinesB, None, 
addDefaultHeaders), hs)
+        bodyR.close()
         bodyW.close()
     else:
         headerLinesB = java.util.ArrayList()
Index: gzz/lava/gzz/potion/potions/ViewContainedText.java
diff -u gzz/lava/gzz/potion/potions/ViewContainedText.java:1.2 
gzz/lava/gzz/potion/potions/ViewContainedText.java:1.3
--- gzz/lava/gzz/potion/potions/ViewContainedText.java:1.2      Mon Jan  6 
08:04:15 2003
+++ gzz/lava/gzz/potion/potions/ViewContainedText.java  Thu Jan 16 08:42:59 2003
@@ -8,22 +8,29 @@
 
 public class ViewContainedText extends AbstractHead implements Command {
        
-       public ViewContainedText() {
-           super(new Object[] {
+    public ViewContainedText() {
+       super(new Object[] {
            "View the text in ", Types.CELL});
-       }
+    }
        
-       public void execute(List[] params, Map context) {
-           for(Iterator i=params[0].iterator(); i.hasNext();) {
-               Cell c = (Cell)i.next();
-               String s =  
-                   "Attention! The text below CANNOT be edited!\n" +
-                   "All changes WILL BE LOST!\n\n" +
-                   Containment.getContainedText(c);
-               DefaultBinder.execExternalEditor(s);
+    public void execute(List[] params, Map context) {
+       for(Iterator i=params[0].iterator(); i.hasNext();) {
+           Cell c = (Cell)i.next();
+           StringBuffer buf = new StringBuffer();
+           buf.append(
+               "Attention! The text below CANNOT be edited!\n" +
+               "All changes WILL BE LOST!\n\n");
+           String s =  
+               Containment.getContainedText(c);
+           int old = 0;
+           int pos = s.indexOf('\r');
+           while(pos >= 0) {
+               buf.append(s.substring(old, pos));
+               old = pos+1;
+               pos = s.indexOf('\r', old);
            }
-       
-       
+           buf.append(s.substring(old));
+           DefaultBinder.execExternalEditor(buf.toString());
        }
-
+    }
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]