Changeset 808
- Timestamp:
- 2008-02-29 20:59:53 (9 months ago)
- Files:
-
- sandbox/serverswitcher/chrome/content/functions.js (added)
- sandbox/serverswitcher/chrome/content/manager.js (modified) (10 diffs)
- sandbox/serverswitcher/chrome/content/manager.xul (modified) (1 diff)
- sandbox/serverswitcher/chrome/content/paneServerSwitcher.xul (modified) (1 diff)
- sandbox/serverswitcher/install.rdf (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/serverswitcher/chrome/content/manager.js
r742 r808 50 50 this._adjustButton(); 51 51 } 52 else if (prefName. substr(0, SSW_PREF_LIMITS.length) == SSW_PREF_LIMITS) {52 else if (prefName.indexOf(SSW_PREF_LIMITS) == 0) { 53 53 this.loadLimits(); 54 54 } … … 87 87 } 88 88 }, 89 // isn't accurate, but is good enough for this use case90 getHost: function(host) {91 var m = host.match(/([^.]+\.(?:[\w]{2,4}|museum)?(?:\.\w{2})?)$/);92 if (m) {93 return m[1];94 }95 return host;96 },97 89 /*Dialog.*/startNext: function() { 98 90 try { … … 114 106 cset[host] = new SSWItem(host); 115 107 } 116 ++cset[host].n; 108 else { 109 cset[host].inc(); 110 } 117 111 }, 118 112 this 119 113 ); 120 // prepare the other tasks121 for (let d in Tree.all) {122 if (!d.is(QUEUED)) {123 continue;124 }125 let host = d._ssw_host;126 if (!(host in cset)) {127 cset[host] = new SSWItem(host);128 }129 cset[host].downloads.push(d);130 }131 114 for (d in SSW._generator(cset)) { 132 115 if (this._running.length >= Prefs.maxInProgress) { … … 137 120 } 138 121 return rv; 139 } catch(ex){ 122 } 123 catch(ex){ 140 124 Debug.log("ssw_startNext():", ex); 141 125 } … … 143 127 }, 144 128 _generator: function(downloadSet) { 129 for (let d in Tree.all) { 130 if (!d.is(QUEUED)) { 131 continue; 132 } 133 let host = d._ssw_host; 134 if (!(host in downloadSet)) { 135 downloadSet[host] = new SSWItem(host); 136 137 // this host got no item running, so we might simply yield it 138 yield d; 139 continue; 140 } 141 downloadSet[host].push(d); 142 } 145 143 let sorted = []; 146 144 for (let s in downloadSet) { 147 sorted.push(downloadSet[s]); 145 let c = downloadSet[s]; 146 if (!c.available) { 147 continue; 148 } 149 sorted.push(c); 148 150 } 149 151 while (sorted.length) { … … 151 153 for (i in sorted) { 152 154 let s = sorted[i]; 153 let limit = 0; 154 if (s.host in SSW._limits) { 155 limit = SSW._limits[s.host]; 156 } 157 if ((limit && s.n >= limit) || s.downloads.length == 0) { 155 if (!s.available) { 158 156 sorted.splice(i, 1); 159 157 break; 160 158 } 161 yield s.downloads.shift(); 162 ++s.n; 159 yield s.pop(); 163 160 } 164 161 } … … 169 166 function SSWItem(host) { 170 167 this.host = host; 171 this.n = 0; 168 this.limit = 0; 169 if (host in SSW._limits) { 170 this.limit = SSW._limits[host]; 171 } 172 this.n = 1; 172 173 this.downloads = []; 173 174 }; … … 175 176 cmp: function(a, b) { 176 177 return a.n - b.n; 178 }, 179 get available() { 180 return (this.limit == 0 || this.limit < this.n) && this.downloads.length != 0; 181 }, 182 inc: function() { 183 return ++this.n; 184 }, 185 pop: function() { 186 return this.downloads.shift(); 187 }, 188 push: function(d) { 189 this.downloads.push(d); 190 ++this.n; 191 }, 192 toString: function() { 193 return this.host; 177 194 } 178 } 195 }; 179 196 180 197 QueueItem.prototype.__defineGetter__( … … 182 199 function() { 183 200 if (!('_ssw_real_host' in this)) { 184 this._ssw_real_host = SSW .getHost(IOService.newURI(this.urlManager.url, null, null).host);201 this._ssw_real_host = SSW_getBaseDomain(this.urlManager.url.toURI()); 185 202 } 186 203 return this._ssw_real_host; … … 190 207 Dialog.startNext = SSW.startNext; 191 208 192 addEventListener('load', function() { return SSW.load(); }, false); 209 addEventListener( 210 'load', 211 function() { 212 return SSW.load(); 213 }, 214 false 215 ); sandbox/serverswitcher/chrome/content/manager.xul
r664 r808 43 43 ]> 44 44 <overlay id="dtassw" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 45 <script type="application/javascript;version=1.7" src="chrome://dtassw/content/functions.js" /> 45 46 <script type="application/javascript;version=1.7" src="chrome://dtassw/content/manager.js" /> 47 46 48 <toolbar id="tools"> 47 49 <toolbarbutton label="&ssw.switch.label;" tooltiptext="&ssw.switch.tip;" id="toolssw" onclick="SSW.toggle();" insertafter="toolmovebottom" /> sandbox/serverswitcher/chrome/content/paneServerSwitcher.xul
r664 r808 53 53 </prefpane> 54 54 <stringbundle src="chrome://dtassw/locale/paneServerSwitcher.properties"/> 55 56 <script type="application/javascript;version=1.7" src="chrome://dtassw/content/functions.js" /> 55 57 <script type="application/javascript;version=1.7" src="chrome://dtassw/content/paneServerSwitcher.js"/> 58 56 59 </prefwindow> 57 60 </overlay> sandbox/serverswitcher/install.rdf
r742 r808 6 6 <name>DownThemAll! ServerSwitcher</name> 7 7 <description>Processes the queue trying to use different servers where possible</description> 8 <version>0. 3</version>8 <version>0.4</version> 9 9 10 10 <creator>Nils Maier</creator> … … 18 18 <rdf:Description> 19 19 <id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</id> 20 <minVersion>2.0 </minVersion>21 <maxVersion>3.0 .*</maxVersion>20 <minVersion>2.0.0.8</minVersion> 21 <maxVersion>3.0b3</maxVersion> 22 22 </rdf:Description> 23 23 </targetApplication> … … 27 27 <rdf:Description> 28 28 <id>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</id> 29 <minVersion>2.0a </minVersion>30 <maxVersion> 3.0</maxVersion>29 <minVersion>2.0a1</minVersion> 30 <maxVersion>2.0a</maxVersion> 31 31 </rdf:Description> 32 32 </targetApplication> … … 36 36 <rdf:Description> 37 37 <id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</id> 38 <minVersion>2.0 </minVersion>39 <maxVersion>3.0 .*</maxVersion>38 <minVersion>2.0.0.0</minVersion> 39 <maxVersion>3.0a1</maxVersion> 40 40 </rdf:Description> 41 41 </targetApplication> … … 45 45 <rdf:Description> 46 46 <id>{a463f10c-3994-11da-9945-000d60ca027b}</id> 47 <minVersion> 0.8</minVersion>48 <maxVersion>1.0 </maxVersion>47 <minVersion>1.0</minVersion> 48 <maxVersion>1.0.*</maxVersion> 49 49 </rdf:Description> 50 50 </targetApplication> … … 53 53 <rdf:Description> 54 54 <id>dta@downthemall.net</id> 55 <minVersion>1.0 b2</minVersion>55 <minVersion>1.0</minVersion> 56 56 <maxVersion>1.1a*</maxVersion> 57 57 </rdf:Description>
