Changes in / [481:487]

Show
Ignore:
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • /trunk/defaults/preferences/dta.js

    r464 r483  
    4242pref("extensions.dta.saveTemp", true); 
    4343pref("extensions.dta.downloadWin", true); 
    44 pref("extensions.dta.existing", 3); 
     44pref("extensions.dta.conflictresolution", 3); 
    4545pref("extensions.dta.ntask", 4); 
    4646pref("extensions.dta.timeout", 300); 
  • /trunk/chrome/locale/en-US/manager.properties

    r469 r482  
    1616verify=Verifying... 
    1717verifyerrortitle=Verification error 
    18 verifyerrortext=The checksums of the download didn't match.\nThis means the download is corrupt or compromised, unless the provided checksum was bad in the first place.\nTherefore it is recommend not to use the downloaded data.\n\nWhat would you like to do with the downloaded file?\n\nProvided:\n%S\nActual:\n%S 
     18verifyerrortext=The checksums of the download didn't match.\nThis means the download is corrupt or compromised, unless the provided checksum was bad in the first place.\nTherefore it is recommend not to use the downloaded data.\n\nWhat would you like to do with the downloaded file? 
    1919failed=Download of %S failed. 
    20 alreadyexists=A file called \"%S\" already exists on directory \"%S\". 
    21 whatdoyouwith=What do you want to do with download \"%S\"? 
    22 reninto=Rename into \"%S\" 
    23 overwrite=Overwrite 
    24 skip=Skip 
    25 samedestination=Download \"%S\" has the same destination \"%S\" as another currently running download \"%S\". 
    26 whatdoyou=What do you want to do? 
    27 renfirst=Rename the first one into \"%S\" 
    28 skipfirst=Skip the first one 
    29 cancelsecond=Cancel the second one 
    30 whatdoyoucomplete=What do you want to do with the completed download \"%S\"? 
    3120cancel=Cancel 
    3221skipped=Skipped 
  • /trunk/chrome/content/preferences/mainPane.xul

    r395 r483  
    2020 
    2121                <preferences> 
    22                   <preference id="dtaexisting" name="extensions.dta.existing" type="int"/> 
     22                  <preference id="dtaexisting" name="extensions.dta.conflictresolution" type="int"/> 
    2323                  <preference id="dtantask" name="extensions.dta.ntask" type="int"/> 
    2424                  <preference id="dtaalert" name="extensions.dta.alertbox" type="int"/> 
  • /trunk/chrome/content/dta/manager.js

    r481 r487  
    172172                } 
    173173        }, 
     174        checkSameName: function D_checkSameName(download, name) { 
     175                for (let i = 0; i < this._running.length; ++i) { 
     176                        if (this._running[i].d == download) { 
     177                                continue; 
     178                        } 
     179                        if (this._running[i].d.destinationName == name) { 
     180                                return true; 
     181                        } 
     182                } 
     183                return false; 
     184        }, 
    174185        startNext: function D_startNext() { 
    175186                try { 
     
    980991                        return; 
    981992                } 
    982  
    983                 try { 
    984                         if (!this.checkNameConflict()) { 
    985                                 return; 
    986                         } 
     993                ConflictManager.resolve(this, 'continueMoveCompleted'); 
     994        }, 
     995        continueMoveCompleted: function QI_continueMoveCompleted() { 
     996                if (this.is(CANCELED)) { 
     997                        return; 
     998                }                
     999                try { 
    9871000                        // safeguard against some failed chunks. 
    9881001                        this.chunks.forEach(function(c) { c.close(); }); 
     
    11931206                this._destinationFile = this.destinationPath + this.destinationName; 
    11941207                this._icon = null; 
    1195                 this.checkNameConflict();                
    1196         }, 
    1197  
    1198         checkNameConflict: function  QI_checkFileNameConflict() { 
    1199  
    1200                 function askForRenaming(t, s1, s2, s3) { 
    1201                         if (Prefs.onConflictingFilenames == 3) { 
    1202                                 if (Prefs.askEveryTime) { 
    1203                                         var passingArguments = new Object(); 
    1204                                         passingArguments.text = t; 
    1205                                         passingArguments.s1 = s1; 
    1206                                         passingArguments.s2 = s2; 
    1207                                         passingArguments.s3 = s3; 
    1208                  
    1209                                         window.openDialog( 
    1210                                                 "chrome://dta/content/dta/dialog.xul","_blank","chrome,centerscreen,resizable=no,dialog,modal,close=no,dependent", 
    1211                                                 passingArguments 
    1212                                         ); 
    1213  
    1214                                         Dialog.fixTimeouts(); 
    1215                  
    1216                                         Prefs.askEveryTime = (passingArguments.temp == 0) ? true : false; 
    1217                                         Prefs.sessionPreference = passingArguments.scelta; 
    1218                                 } 
    1219                                 return Prefs.sessionPreference; 
    1220                         } 
    1221                         return Prefs.onConflictingFilenames; 
    1222                 } 
    1223                  
    1224                 let dn = this._destinationName, ds = this._destinationPath, df = this._destinationFile; 
    1225                 let dest = new FileFactory(this.destinationFile), newDest = new FileFactory(df); 
    1226                 if (!this.is(RUNNING, FINISHING) || !dest.exists()) { 
    1227                         return true; 
    1228                 } 
    1229                          
    1230                 let basename = dn, ext = '', pos = basename.lastIndexOf('.'); 
    1231                 if (pos != -1) { 
    1232                         ext = basename.slice(pos); 
    1233                         basename = basename.slice(0, pos); 
    1234                 } 
    1235                 for (let i = 1;; ++i) { 
    1236                         newDest.leafName = basename + "_" +  Utils.formatNumber(i) + ext; 
    1237                         if (!newDest.exists()) { 
    1238                                 break; 
    1239                         } 
    1240                 } 
    1241                 newDest = newDest.leafName; 
    1242  
    1243                 var shortUrl = this.urlManager.usable.cropCenter(70); 
    1244  
    1245                 function mc(aCaption, aValue) { 
    1246                         return {caption: aCaption, value: aValue}; 
    1247                 } 
    1248  
    1249                 var s = -1, p; 
    1250                 s = askForRenaming( 
    1251                         _('alreadyexists', [dn, ds]) + " " + _('whatdoyouwith', [shortUrl]), 
    1252                         mc(_('reninto', [newDest]), 0), 
    1253                         mc(_('overwrite'), 1), 
    1254                         mc(_('skip'), 2) 
    1255                 ); 
    1256                  
    1257                 switch (s) { 
    1258                         case 0: this.destinationName = newDest; return true; 
    1259                         case 1: return true; 
    1260                         /*case 3: inProgressList[p].d.cancel(); return true;*/ 
    1261                         default: this.cancel(_('skipped')); return false; 
    1262                 } 
    12631208        }, 
    12641209 
     
    20401985                                } 
    20411986                                c.end = d.totalSize - 1; 
    2042                                 delete this.getInfo; 
     1987                                delete this.isStarter; 
     1988                                ConflictManager.resolve(d);                              
    20431989                        } 
    20441990                         
     
    21182064                        let d = this.d; 
    21192065                         
    2120                         if (this.reexamine && (this.reexamine = this.onStartRequest(aRequest, aContext))) { 
    2121                                 return;                           
     2066                        if (this.reexamine) { 
     2067                                Debug.dump("reexamine"); 
     2068                                this.onStartRequest(aRequest, aContext); 
     2069                                if (this.reexamine) { 
     2070                                        return; 
     2071                                } 
    21222072                        } 
    21232073 
     
    22252175        'init' 
    22262176); 
     2177 
     2178var ConflictManager = { 
     2179        _items: [], 
     2180        resolve: function(download, reentry) { 
     2181                if (!this._check(download)) { 
     2182                        if (reentry) { 
     2183                                download[reentry](); 
     2184                        } 
     2185                        return; 
     2186                } 
     2187                for (let i = 0; i < this._items.length; ++i) { 
     2188                        if (this._items[i].download == download) { 
     2189                                Debug.dump("conflict resolution updated to: " + reentry); 
     2190                                 
     2191                                this._items[i].reentry = reentry; 
     2192                                return; 
     2193                        } 
     2194                } 
     2195                Debug.dump("conflict resolution queued to: " + reentry); 
     2196                this._items.push({download: download, reentry: reentry}); 
     2197                this._process(); 
     2198        }, 
     2199        _check: function(download) { 
     2200                let dest = new FileFactory(download.destinationFile); 
     2201                let sn = false; 
     2202                if (download.is(RUNNING)) { 
     2203                        sn = Dialog.checkSameName(download, download.destinationName); 
     2204                } 
     2205                Debug.dump("conflict check: " + sn + "/" + dest.exists() + " for " + download.destinationFile); 
     2206                return dest.exists() || sn; 
     2207        }, 
     2208        _process: function() { 
     2209                if (this._processing) { 
     2210                        return; 
     2211                } 
     2212                while (this._items.length) { 
     2213                        let cur = this._items[0]; 
     2214                        if (!this._check(cur.download)) { 
     2215                                if (reentry) { 
     2216                                        download[reentry](); 
     2217                                } 
     2218                                this._items.shift(); 
     2219                                continue; 
     2220                        } 
     2221                        break; 
     2222                } 
     2223                if (!this._items.length) { 
     2224                        return; 
     2225                } 
     2226                let cur = this._items[0]; 
     2227                let download = cur.download; 
     2228                let basename = download._destinationName, ext = '', pos = basename.lastIndexOf('.'); 
     2229                if (pos != -1) { 
     2230                        ext = basename.slice(pos); 
     2231                        basename = basename.slice(0, pos); 
     2232                } 
     2233                let newDest = new FileFactory(download.destinationFile); 
     2234                for (let i = 1;; ++i) { 
     2235                        newDest.leafName = basename + "_" +  Utils.formatNumber(i) + ext; 
     2236                        if (!newDest.exists() && (!download.is(RUNNING) || !Dialog.checkSameName(this, newDest.leafName))) { 
     2237                                break; 
     2238                        } 
     2239                } 
     2240                cur.newDest = newDest.leafName; 
     2241         
     2242                if (Prefs.conflictResolution != 3) { 
     2243                        this._return(Prefs.conflictResolution); 
     2244                        return; 
     2245                } 
     2246                if (this._sessionSetting) { 
     2247                        this._return(this._sessionSetting); 
     2248                        return; 
     2249                } 
     2250 
     2251                var options = { 
     2252                        url: download.urlManager.usable.cropCenter(45), 
     2253                        fn: download.destinationName.cropCenter(45), 
     2254                        newDest: cur.newDest.cropCenter(45) 
     2255                }; 
     2256                 
     2257                this._processing = true; 
     2258                 
     2259                window.openDialog( 
     2260                        "chrome://dta/content/dta/manager/conflicts.xul", 
     2261                        "_blank", 
     2262                        "chrome,centerscreen,resizable=no,dialog,close=no,dependent", 
     2263                        options, this 
     2264                ); 
     2265        }, 
     2266        _returnFromDialog: function(option, type) { 
     2267                if (type == 1) { 
     2268                        this._sessionSetting = option; 
     2269                } 
     2270                if (type == 2) { 
     2271                        Preferences.setDTA('conflictresolution', option); 
     2272                }                
     2273                this._return(option); 
     2274        }, 
     2275        _return: function(option) { 
     2276                let cur = this._items[0]; 
     2277                switch (option) { 
     2278                        /* rename */    case 0: cur.download.destinationName = cur.newDest; break; 
     2279                        /* overwrite */ case 1: break; 
     2280                        /* skip */      default: cur.download.cancel(_('skipped')); break; 
     2281                } 
     2282                if (cur.reentry) { 
     2283                        cur.download[cur.reentry](); 
     2284                } 
     2285                this._items.shift(); 
     2286                this._processing = false; 
     2287                this._process(); 
     2288        } 
     2289}; 
  • /trunk/chrome/content/dta/select.xul

    r467 r484  
    4949                <key keycode="VK_ESCAPE" oncommand="self.close();"/> 
    5050                <key id="kMacEsc" modifiers="accel" key="W" oncommand="self.close();"/> 
     51                <key modifiers="accel" key="A" oncommand="Dialog.selectAll();"/> 
    5152                <key keycode="VK_RETURN" oncommand="Dialog.download(true);"/> 
    5253                <key keycode="VK_ENTER" oncommand="Dialog.download(true);"/> 
  • /trunk/chrome/content/dta/manager/verificator.js

    r480 r482  
    105105                this.hash = hexdigest(this.hash.finish(false)); 
    106106                if (this.hash != this.download.hash.sum) { 
    107                         var act = DTA_confirm(_('verifyerrortitle'), _('verifyerrortext', [this.download.hash.sum, this.hash]), _('retry'), _('delete'), _('keep')); 
     107                        var act = DTA_confirm(_('verifyerrortitle'), _('verifyerrortext'), _('retry'), _('delete'), _('keep')); 
    108108                        switch (act) { 
    109109                                case 0: this._delete(); this.download.retry(); return; 
  • /trunk/chrome/content/dta/manager/prefs.js

    r461 r482  
    4141        showOnlyFilenames: true, 
    4242        alertingSystem: (SYSTEMSLASH == '\\') ? 1 : 0, 
    43  
    44         // conflict filenames preference for this session (-1 not setted) 
    45         askEveryTime: true, 
    46         sessionPreference: -1, 
    47         onConflictingFilenames: 3, 
     43        conflictResolution: 3, 
    4844 
    4945        maxInProgress: 5, 
     
    9692                        'setTime', 
    9793                        'showOnlyFilenames', 
    98                         ['onConflictingFilenames', 'existing']
     94                        'conflictResolution'
    9995                        ['alertingSystem', 'alertbox'], 
    10096                        'finishEvent'