Changeset 474

Show
Ignore:
Timestamp:
2007-07-05 20:49:31 (2 years ago)
Author:
MaierMan
Message:

return of Thunderbird support (closing source tab not yet handled)
features a fix for url lists not really unique

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/chrome.manifest

    r463 r474  
    2626overlay chrome://browser/content/sanitize.xul   chrome://dta/content/privacy/overlaySanitizeUI.xul application={ec8030f7-c20a-464f-9b0e-13a3a9e97384} 
    2727overlay chrome://browser/content/sanitize.xul   chrome://dta/content/privacy/overlaySanitizeCode.xul application={ec8030f7-c20a-464f-9b0e-13a3a9e97384} 
     28overlay chrome:///content/downloads/unknownContentType.xul      chrome://dta/content/integration/saveas.xul 
    2829 
    2930## Seamonkey ## 
     
    3334style   chrome://navigator/content/navigator.xul chrome://dta/skin/integration/style.css application={92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a} 
    3435 
     36## Thunderbird ## 
     37overlay chrome://messenger/content/messenger.xul chrome://dta/content/integration/thunderbird.xul application={3550f703-e582-4d05-9a08-453d09bdfdc6} 
     38overlay chrome://messenger/content/messageWindow.xul chrome://dta/content/integration/thunderbird.xul application={3550f703-e582-4d05-9a08-453d09bdfdc6} 
     39overlay chrome://dta/content/integration/thunderbird.xul chrome://dta/content/integration/elements.xul application={3550f703-e582-4d05-9a08-453d09bdfdc6} 
     40style   chrome://messenger/content/messenger.xul chrome://dta/skin/integration/style.css application={3550f703-e582-4d05-9a08-453d09bdfdc6} 
     41style   chrome://messenger/content/messageWindow.xul chrome://dta/skin/integration/style.css application={3550f703-e582-4d05-9a08-453d09bdfdc6} 
     42style   chrome://global/content/customizeToolbar.xul chrome://dta/skin/integration/style.css application={3550f703-e582-4d05-9a08-453d09bdfdc6} 
     43 
    3544## toolkit ## 
    3645overlay chrome://mozapps/content/downloads/unknownContentType.xul       chrome://dta/content/integration/saveas.xul 
  • trunk/chrome/content/common/internalFunctions.js

    r461 r474  
    310310                } 
    311311                 
    312                 var units = ['TB','GB','MB','KB']; 
     312                var units = [['TB', 3], ['GB', 2], ['MB', 2], ['KB', 1]]; 
    313313                var unit; 
    314314                 
     
    318318                } 
    319319                 
    320                 return aNumber.toFixed(2) + " " + unit
     320                return aNumber.toFixed(unit[1]) + " " + unit[0]
    321321        }, 
    322322         
  • trunk/chrome/content/common/overlayFunctions.js

    r461 r474  
    329329DTA_DropProcessor.prototype = { 
    330330        getSupportedFlavours: function() { 
    331                 var flavours = new FlavourSet (); 
     331                var flavours = new FlavourSet(); 
    332332                flavours.appendFlavour("text/x-moz-url"); 
    333333                return flavours; 
    334334        }, 
    335         onDragOver: function(evt,flavour,session) { 
    336         }, 
     335        onDragOver: function(evt,flavour,session) {}, 
    337336        onDrop: function (evt,dropdata,session) { 
    338337                if (!dropdata) { 
    339338                        return; 
    340339                } 
    341                 var url = transferUtils.retrieveURLFromData(dropdata.data, dropdata.flavour.contentType); 
     340                try { 
     341                        var url = transferUtils.retrieveURLFromData(dropdata.data, dropdata.flavour.contentType); 
     342                } 
     343                catch (ex) { 
     344                        return; 
     345                } 
    342346                var doc = document.commandDispatcher.focusedWindow.document; 
    343347                url = new DTA_URL(url, doc.characterSet); 
    344                 var ref = doc.URL; 
    345                 if (!ref) { 
    346                         ref = DTA_Mediator.getMostRecentURL(); 
    347                 } 
     348                var ref = DTA_AddingFunctions.getRef(doc); 
    348349                this.func(url, ref); 
    349350        } 
     
    421422                return this.ios.newURI(rel, doc.characterSet, this.ios.newURI(base, doc.characterSet, null)).spec; 
    422423        }, 
     424         
     425        getRef: function(doc) { 
     426                var ref = doc.URL; 
     427                if (!this.isLinkOpenable(ref)) { 
     428                        var b = doc.getElementsByTagName('base'); 
     429                        for (var i = 0; i < b.length; ++i) { 
     430                                if (!b[i].hasAttribute('href')) { 
     431                                        continue; 
     432                                } 
     433                                try { 
     434                                        ref = this.composeURL(doc, b[i].getAttribute('href')); 
     435                                } 
     436                                catch (ex) { 
     437                                        continue; 
     438                                } 
     439                                break; 
     440                        } 
     441                } 
     442                return this.isLinkOpenable(ref) ? ref: ''; 
     443        },       
    423444 
    424445        saveSingleLink : function(turbo, url, referrer, description) { 
     
    540561        openManager : function (quite) { 
    541562                try { 
    542                         var win = DTA_Mediator.get("chrome://dta/content/dta/manager.xul"); 
     563                        var win = DTA_Mediator.getByUrl("chrome://dta/content/dta/manager.xul"); 
    543564                        if (win) { 
    544565                                if (!quite) { 
     
    552573                                "chrome, centerscreen, resizable=yes, dialog=no, all, modal=no, dependent=no" 
    553574                        ); 
    554                         return DTA_Mediator.get("chrome://dta/content/dta/manager.xul"); 
     575                        return DTA_Mediator.getByUrl("chrome://dta/content/dta/manager.xul"); 
    555576                } catch(ex) { 
    556577                        DTA_debug.dump("openManager():", ex); 
     
    560581 
    561582        sendToDown : function(notQueue, links) { 
    562                 var win = DTA_Mediator.get("chrome://dta/content/dta/manager.xul"); 
     583                var win = DTA_Mediator.getByUrl("chrome://dta/content/dta/manager.xul"); 
    563584                if (win) { 
    564585                        win.self.startnewDownloads(notQueue, links); 
     
    577598 
    578599        getMostRecent: function(name)   { 
    579                 var rv = this._m.getMostRecentWindow(name ? name : "navigator:browser"); 
    580                 return rv ? rv : null; 
    581         }, 
    582         getMostRecentURL: function() { 
    583                 var rv = this.getMostRecent(); 
    584                 return rv ? rv.content.document.location : ""; 
    585         }, 
    586         'get': function(url) { 
     600                var names = ['navigator:browser', 'mail:messageWindow', 'mail:3pane']; 
     601                if (name) { 
     602                        names.unshift(name); 
     603                } 
     604                var rv = null; 
     605                names.some( 
     606                        function(name) { 
     607                                rv = this._m.getMostRecentWindow(name); 
     608                                return rv; 
     609                        }, 
     610                        this 
     611                ); 
     612                return rv; 
     613        }, 
     614        getByUrl: function(url) { 
    587615                if (!url) { 
    588616                        return null; 
     
    602630                } 
    603631                return null; 
     632        }, 
     633        getAllByType: function(type) { 
     634                var rv = []; 
     635                var enumerator = this._m.getEnumerator(type); 
     636                while (enumerator.hasMoreElements()) { 
     637                        rv.push(enumerator.getNext()); 
     638                } 
     639                return rv; 
    604640        }, 
    605641        openTab: function WM_openTab(url, ref) { 
  • trunk/chrome/content/integration/elements.js

    r463 r474  
    5858         
    5959        addLinksToArray: function(lnks, urls, doc) { 
    60                 var ref = doc.URL; 
    61                 if (!('length' in lnks)) { 
     60                if (!lnks || !lnks.length) { 
    6261                        return; 
    6362                } 
    64                 var known = {}; 
     63                 
     64                var ref = DTA_AddingFunctions.getRef(doc); 
     65                 
    6566                for (var i = 0; i < lnks.length; ++i) { 
    6667                        // remove anchor from url 
     
    6869                        var plink = link.href.replace(/#.*$/gi, ""); 
    6970                        // if it's valid and it's new 
    70                         if (!DTA_AddingFunctions.isLinkOpenable(plink) || plink in known) { 
     71                        if (!DTA_AddingFunctions.isLinkOpenable(plink)) { 
    7172                                continue; 
    7273                        } 
     
    8586                                'hash': DTA_getLinkPrintHash(link.hash) 
    8687                        }); 
    87                         known[plink] = null; 
    8888                         
    8989                        var ml = DTA_getLinkPrintMetalink(link.hash); 
     
    9696                                        'metalink': true 
    9797                                }); 
    98                                 known[ml] = null; 
    9998                        } 
    10099                } 
     
    102101         
    103102        addImagesToArray: function(lnks, images, doc)   { 
    104                 var ref = doc.URL; 
    105                  
    106103                if (!lnks || !lnks.length) { 
    107104                        return; 
    108105                } 
    109                 var known = {}; 
    110                  
     106 
     107                var ref = DTA_AddingFunctions.getRef(doc); 
     108 
    111109                for (var i = 0; i < lnks.length; ++i) { 
    112110                        var src = lnks[i].src; 
     
    122120                        // if it's valid and it's new 
    123121                        // better double check :p 
    124                         if (!DTA_AddingFunctions.isLinkOpenable(src) || src in known) { 
     122                        if (!DTA_AddingFunctions.isLinkOpenable(src)) { 
    125123                                continue; 
    126124                        } 
     
    137135                                'description': desc 
    138136                        }); 
    139                         known[src] = null; 
    140137                } 
    141138        }, 
     
    171168                        var sel = aWin.getSelection(); 
    172169                        if (honorSelection && sel && !sel.isCollapsed) { 
    173                                 [links, images, embeds, inputs].forEach( 
     170                                DTA_debug.dump("selection only"); 
     171                                [links, images, embeds, inputs] = [links, images, embeds, inputs].map( 
    174172                                        function(e) { 
    175                                                 e = filterElements(e, sel); 
     173                                                return filterElements(e, sel); 
    176174                                        } 
    177175                                ); 
     
    203201        }, 
    204202         
     203        findWindowsNavigator: function(all) { 
     204                var windows = []; 
     205                if (!all) { 
     206                        var sel = document.commandDispatcher.focusedWindow.getSelection(); 
     207                        if (sel.isCollapsed) { 
     208                                windows.push(DTA_Mediator.getMostRecent().getBrowser().selectedBrowser.contentWindow.top); 
     209                        } 
     210                        else { 
     211                                windows.push(document.commandDispatcher.focusedWindow); 
     212                        } 
     213                } 
     214                else { 
     215                        var win = DTA_Mediator.getMostRecent().getBrowser(); 
     216                        win.browsers.forEach( 
     217                                function(e) { 
     218                                        windows.push(e.contentWindow.top); 
     219                                } 
     220                        ); 
     221                } 
     222                return windows; 
     223        }, 
     224        findWindowsMail: function(all) { 
     225                var windows = []; 
     226                if (document.documentElement.getAttribute('windowtype') == 'mail:3pane') { 
     227                        windows.push(document.getElementById('messagepane').contentWindow); 
     228                } 
     229                else if (!all) { 
     230                        windows.push(document.commandDispatcher.focusedWindow); 
     231                } 
     232                else { 
     233                        windows = DTA_Mediator 
     234                                .getAllByType('mail:messageWindow') 
     235                                .map(function(w) { 
     236                                        return w.content; 
     237                                }); 
     238                } 
     239                return windows; 
     240        }, 
     241         
    205242        findLinks: function(turbo, all) { 
    206243                try { 
     244                         
     245                        function makeUnique(i) { 
     246                                var known = {}; 
     247                                return i.filter( 
     248                                        function(e) { 
     249                                                var url = e.url.url; 
     250                                                if (url in known) { 
     251                                                        return false; 
     252                                                } 
     253                                                known[url] = null; 
     254                                                return true; 
     255                                        } 
     256                                ); 
     257                        }                
     258                         
    207259                        if (turbo) { 
    208260                                DTA_debug.dump("findLinks(): DtaOneClick request from the user"); 
     
    211263                        } 
    212264 
    213                         var windows = []; 
    214                         if (!all) { 
    215                                 var sel = document.commandDispatcher.focusedWindow.getSelection(); 
    216                                 if (sel.isCollapsed) { 
    217                                         windows.push(DTA_Mediator.getMostRecent().getBrowser().selectedBrowser.contentWindow.top); 
    218                                 } 
    219                                 else { 
    220                                         windows.push(document.commandDispatcher.focusedWindow); 
    221                                 } 
    222                         } 
    223                         else { 
    224                                 var win = DTA_Mediator.getMostRecent().getBrowser(); 
    225                                 win.browsers.forEach( 
    226                                         function(e) { 
    227                                                 windows.push(e.contentWindow.top); 
    228                                         } 
    229                                 ); 
    230                         } 
    231                                  
    232  
     265                        var wt = document.documentElement.getAttribute('windowtype');  
     266                        var windows = ( 
     267                                wt.match(/^mail:/) 
     268                                ? this.findWindowsMail 
     269                                : this.findWindowsNavigator 
     270                        )(all); 
     271                         
    233272                        var urls = []; 
    234273                        var images = []; 
     
    239278                                this 
    240279                        ); 
     280                        urls = makeUnique(urls); 
     281                        images = makeUnique(images); 
     282 
    241283                        if (!urls.length && !images.length) { 
    242284                                DTA_alert(this.getString('error'), this.getString('errornolinks')); 
     
    265307                        var cur = gContextMenu.target; 
    266308                         
    267                         if (gContextMenu.onLink) 
    268                                 var tofind = /^a$/i; 
    269                         else 
    270                                 var tofind = /^img$/i; 
    271                                  
     309                        var tofind = gContextMenu.onLink ? /^a$/i : /^img$/i;  
     310                 
    272311                        while (!("tagName" in cur) || !tofind.test(cur.tagName)) { 
    273312                                cur = cur.parentNode; 
    274313                        } 
    275                          
    276314                        var url = gContextMenu.onLink ? cur.href : cur.src; 
    277315                         
     
    282320                         
    283321                        url = new DTA_URL(url, win.document.characterSet); 
    284                         var ref = document.commandDispatcher.focusedWindow.document.URL
     322                        var ref = DTA_AddingFunctions.getRef(document.commandDispatcher.focusedWindow.document)
    285323                        var desc = this.extractDescription(cur); 
    286324                        if (turbo) { 
     
    394432                         
    395433                        // general setup 
    396                         var base = document.getElementById('context-sep-selectall'); 
     434                        var base = document.getElementById(this.ctxBase.getAttribute('insertafter')); 
    397435                        if (compact) { 
    398436                                this.ctxBase.hidden = false; 
     
    411449                                if (compact) { 
    412450                                        this.ctxMenu.insertBefore(cur, this.ctxMenu.firstChild); 
    413                                 } else { 
     451                                } 
     452                                else { 
    414453                                        base.parentNode.insertBefore(cur, base); 
    415454                                        base = cur; 
  • trunk/chrome/content/integration/firefox.xul

    r463 r474  
    1313 
    1414        <popup id="contentAreaContextMenu"> 
    15                 <menu id="dtaCtxCompact" insertafter="context-sep-selectall"/> 
     15                <menu id="dtaCtxCompact" insertafter="context-sep-selectall"/> 
    1616        </popup> 
    1717 
  • trunk/install.rdf

    r463 r474  
    2525                        <rdf:Description> 
    2626                                <id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</id> 
    27                                 <minVersion>2.0.</minVersion> 
     27                                <minVersion>2.0</minVersion> 
    2828                                <maxVersion>3.0.*</maxVersion> 
    2929                        </rdf:Description> 
     
    3737                                <maxVersion>3.0</maxVersion> 
    3838                        </rdf:Description> 
    39                 </targetApplication>                     
     39                </targetApplication> 
     40                 
     41                <!-- Thunderbird --> 
     42                <targetApplication> 
     43                        <rdf:Description> 
     44                                <id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</id> 
     45                                <minVersion>2.0</minVersion> 
     46                                <maxVersion>3.0.*</maxVersion> 
     47                        </rdf:Description> 
     48                </targetApplication> 
    4049 
    4150        </rdf:Description>