Changeset 29732 for platform/firefox/FireMobileSimulator/trunk/src
- Timestamp:
- 02/09/09 01:08:35 (4 years ago)
- Location:
- platform/firefox/FireMobileSimulator/trunk/src
- Files:
-
- 7 modified
-
chrome/content/common/carrier.js (modified) (4 diffs)
-
chrome/content/common/util.js (modified) (1 diff)
-
chrome/content/core.js (modified) (8 diffs)
-
chrome/content/options/options.js (modified) (2 diffs)
-
chrome/content/overlay.js (modified) (2 diffs)
-
components/msimModifyHeaders.js (modified) (4 diffs)
-
components/msimStreamConverter.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
platform/firefox/FireMobileSimulator/trunk/src/chrome/content/common/carrier.js
r27325 r29732 107 107 108 108 firemobilesimulator.common.carrier.getSoftBankUserAgent = function(useragent) { 109 var serial = parent.firemobilesimulator.common.pref.copyUnicharPref("msim.config.SB.serial");110 var notifySerial = parent.firemobilesimulator.common.pref.getBoolPref("msim.config.SB.notifyserial");109 var serial = firemobilesimulator.common.pref.copyUnicharPref("msim.config.SB.serial"); 110 var notifySerial = firemobilesimulator.common.pref.getBoolPref("msim.config.SB.notifyserial"); 111 111 var replacement = ""; 112 112 if (true == notifySerial) { … … 114 114 } 115 115 useragent = useragent.replace("[/Serial]", replacement); 116 dump("[msim]SB UA:" + useragent + "\n");116 //dump("[msim]SB UA:" + useragent + "\n"); 117 117 return useragent; 118 118 }; … … 120 120 //firemobilesimulator.common.carrier.getDocomoUserAgent = function(useragent, id) { 121 121 firemobilesimulator.common.carrier.getDoCoMoUserAgent = function(useragent, id) { 122 var type1 = parent.firemobilesimulator.common.pref.copyUnicharPref("msim.devicelist."+id+".type1");123 var cache = parent.firemobilesimulator.common.pref.copyUnicharPref("msim.devicelist."+id+".cache");122 var type1 = firemobilesimulator.common.pref.copyUnicharPref("msim.devicelist."+id+".type1"); 123 var cache = firemobilesimulator.common.pref.copyUnicharPref("msim.devicelist."+id+".cache"); 124 124 if (firemobilesimulator.common.carrier.Type[firemobilesimulator.common.carrier.DOCOMO].DOCOMO_FOMA == type1) { 125 125 //TODO ;TB;WxxHxxの部分も動的に組み立てられるようにする … … 129 129 useragent = useragent + "/c" + cache + "/TB/W24H12)"; 130 130 } 131 dump("[msim]DC UA:" + useragent + "\n");131 //dump("[msim]DC UA:" + useragent + "\n"); 132 132 return useragent; 133 133 }; -
platform/firefox/FireMobileSimulator/trunk/src/chrome/content/common/util.js
r27271 r29732 201 201 return r; 202 202 }; 203 204 firemobilesimulator.common.util.getTabFromHttpChannel = function (httpChannel) { 205 var tab = null; 206 if (httpChannel.notificationCallbacks) { 207 var interfaceRequestor = httpChannel.notificationCallbacks 208 .QueryInterface(Components.interfaces.nsIInterfaceRequestor); 209 var targetDoc = interfaceRequestor 210 .getInterface(Components.interfaces.nsIDOMWindow).document; 211 212 var webNav = httpChannel.notificationCallbacks 213 .getInterface(Components.interfaces.nsIWebNavigation); 214 var mainWindow = webNav.QueryInterface(Components.interfaces.nsIDocShellTreeItem) 215 .rootTreeItem.QueryInterface(Components.interfaces.nsIInterfaceRequestor) 216 .getInterface(Components.interfaces.nsIDOMWindow); 217 218 var gBrowser = mainWindow.getBrowser(); 219 var targetBrowserIndex = gBrowser.getBrowserIndexForDocument(targetDoc); 220 if (targetBrowserIndex != -1) { 221 tab = gBrowser.tabContainer.childNodes[targetBrowserIndex]; 222 } 223 } 224 return tab; 225 } -
platform/firefox/FireMobileSimulator/trunk/src/chrome/content/core.js
r27326 r29732 1 /* ***** BEGIN LICENSE BLOCK Version: GPL 3.0 ***** 2 * FireMobileFimulator is a Firefox add-on that simulate web browsers of 3 * japanese mobile phones. 4 * Copyright (C) 2008 Takahiro Horikawa <horikawa.takahiro@gmail.com> 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 * ***** END LICENSE BLOCK ***** */ 1 /******************************************************************************* 2 * ***** BEGIN LICENSE BLOCK Version: GPL 3.0 FireMobileFimulator is a Firefox 3 * add-on that simulate web browsers of japanese mobile phones. Copyright (C) 4 * 2008 Takahiro Horikawa <horikawa.takahiro@gmail.com> 5 * 6 * This program is free software: you can redistribute it and/or modify it under 7 * the terms of the GNU General Public License as published by the Free Software 8 * Foundation, either version 3 of the License, or (at your option) any later 9 * version. 10 * 11 * This program is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 14 * details. 15 * 16 * You should have received a copy of the GNU General Public License along with 17 * this program. If not, see <http://www.gnu.org/licenses/>. ***** END LICENSE 18 * BLOCK ***** 19 */ 19 20 20 21 var firemobilesimulator; … … 25 26 26 27 firemobilesimulator.core.resetDevice = function(e) { 27 firemobilesimulator.common.pref.deletePref("msim.current.carrier"); 28 firemobilesimulator.common.pref.deletePref("general.useragent.override"); 29 firemobilesimulator.common.pref.deletePref("msim.current.useragent"); 30 firemobilesimulator.common.pref.deletePref("msim.current.id"); 28 var tab = gBrowser.selectedTab; 29 tab.setAttribute("firemobilesimulator-device-id", null); 31 30 firemobilesimulator.core.updateIcon(); 32 31 }; 33 32 34 33 firemobilesimulator.core.setDevice = function(id) { 35 36 //dump("[msim]setDevice:" + carrier + ",id:" + id + "\n"); 34 dump("[msim]setDevice:" + id + "\n"); 37 35 38 36 if (!id) { … … 41 39 } 42 40 43 var pref_prefix = "msim.devicelist." + id; 44 var carrier = firemobilesimulator.common.pref.copyUnicharPref(pref_prefix + ".carrier"); 45 46 firemobilesimulator.common.pref.setUnicharPref("msim.current.carrier", carrier); 47 var useragent = firemobilesimulator.common.pref.copyUnicharPref(pref_prefix 48 + ".useragent"); 49 if (firemobilesimulator.common.carrier.SOFTBANK == carrier) { 50 useragent = firemobilesimulator.common.carrier.getSoftBankUserAgent(useragent); 51 }else if (firemobilesimulator.common.carrier.DOCOMO == carrier) { 52 useragent = firemobilesimulator.common.carrier.getDoCoMoUserAgent(useragent, id); 53 //useragent = firemobilesimulator.common.carrier.getDocomoUserAgent(useragent, id); 54 } 55 56 firemobilesimulator.common.pref.setUnicharPref("general.useragent.override", useragent); 57 firemobilesimulator.common.pref.setUnicharPref("msim.current.useragent", useragent); 58 firemobilesimulator.common.pref.setUnicharPref("msim.current.id", id); 41 var tab = gBrowser.selectedTab; 42 tab.setAttribute("firemobilesimulator-device-id", id); 59 43 firemobilesimulator.core.updateIcon(); 60 44 }; … … 67 51 }); 68 52 69 // 既に使われている端末だったら設定をリセット53 // 既に使われている端末だったら設定をリセット 70 54 if (firemobilesimulator.common.pref.copyUnicharPref("msim.current.id") == deletedId) { 71 55 firemobilesimulator.core.resetDevice(); 72 56 } 73 57 74 // 各端末のidを再計算58 // 各端末のidを再計算 75 59 var count = firemobilesimulator.common.pref.getIntPref("msim.devicelist.count"); 76 60 for (let i=deletedId+1; i<=count; i++) { … … 151 135 if (deviceResults.length == 0) return; 152 136 153 // XMLから端末情報を順次解析137 // XMLから端末情報を順次解析 154 138 var devices = new Array(); 155 139 var i = 0; … … 163 147 let headerElement = null; 164 148 165 // ExtraHeaderエレメントの取得149 // ExtraHeaderエレメントの取得 166 150 let headers = new Array(); 167 151 let j = 0; … … 230 214 }); 231 215 232 // set device count216 // set device count 233 217 firemobilesimulator.common.pref.setIntPref("msim.devicelist.count", currentId); 234 218 return true; … … 282 266 } 283 267 firemobilesimulator.common.pref.deletePref("msim.devicelist.count"); 284 firemobilesimulator.common.pref.deletePref("msim.current.carrier");285 268 firemobilesimulator.common.pref.deletePref("general.useragent.override"); 286 firemobilesimulator.common.pref.deletePref("msim.current.useragent");287 firemobilesimulator.common.pref.deletePref("msim.current.id");288 269 firemobilesimulator.core.resetDevice(); 289 270 }; -
platform/firefox/FireMobileSimulator/trunk/src/chrome/content/options/options.js
r27271 r29732 77 77 if (selectedItem) { 78 78 var id = selectedItem.getAttribute("id"); 79 if (window.openDialog(79 window.openDialog( 80 80 "chrome://msim/content/options/dialogs/device.xul", 81 81 "msim-device-dialog", "centerscreen,chrome,modal,resizable", 82 "edit", id, retVals)) { 83 if (retVals.id) { 84 if (firemobilesimulator.common.pref.copyUnicharPref("msim.current.id") == retVals.id) { 85 firemobilesimulator.core.setDevice(retVals.id); 86 } 87 } 88 } 82 "edit", id, retVals); 89 83 } else { 90 84 dump("[msim]Error : Device is not selected.\n"); … … 238 232 firemobilesimulator.options.optionsDataString["msim.config.SB.serial"] = pageDocument 239 233 .getElementById("msim-textbox-softbank-serial").value; 240 var carrier = firemobilesimulator.common.pref241 .copyUnicharPref("msim.current.carrier");242 if (carrier == firemobilesimulator.common.carrier.SOFTBANK) {243 dump("[msim]Debug : Current Carrier is SoftBank. Replace User-Agent.\n");244 var id = firemobilesimulator.common.pref245 .copyUnicharPref("msim.current.id");246 var useragent = firemobilesimulator.common.pref247 .copyUnicharPref("msim.devicelist." + id + ".useragent");248 var newUserAgent = firemobilesimulator.common.carrier249 .getSoftBankUserAgent(250 useragent,251 firemobilesimulator.options.optionsDataString["msim.config.SB.serial"]);252 firemobilesimulator.options.optionsDataString["general.useragent.override"] = newUserAgent;253 firemobilesimulator.options.optionsDataString["msim.current.useragent"] = newUserAgent;254 }255 234 } else if (iFrameSrc.indexOf("devices") != -1) { 256 235 // Nothing to do -
platform/firefox/FireMobileSimulator/trunk/src/chrome/content/overlay.js
r29358 r29732 134 134 } 135 135 136 var currentMenuId = "msim-device-" 137 + suffix 138 + "-" 139 + firemobilesimulator.common.pref 140 .copyUnicharPref("msim.current.id"); 141 var currentMenu = document.getElementById(currentMenuId); 142 if (!currentMenu) { 143 currentMenu = document.getElementById("msim-default-" + suffix); 144 } 136 var currentMenu = document.getElementById("msim-default-" + suffix); 145 137 currentMenu.setAttribute("checked", true); 146 138 }; … … 187 179 firemobilesimulator.overlay.BrowserOnLoad = function(objEvent) { 188 180 dump("[msim]BrowserOnLoad is fired.\n"); 189 var carrier = firemobilesimulator.common.pref 190 .copyUnicharPref("msim.current.carrier"); 191 var id = firemobilesimulator.common.pref.copyUnicharPref("msim.current.id"); 181 182 var tab = gBrowser.selectedTab; 183 var id = tab.getAttribute("firemobilesimulator-device-id"); 184 var pref_prefix = "msim.devicelist." + id; 185 var carrier = firemobilesimulator.common.pref.copyUnicharPref(pref_prefix + ".carrier"); 192 186 193 187 if (carrier) { -
platform/firefox/FireMobileSimulator/trunk/src/components/msimModifyHeaders.js
r29300 r29732 38 38 39 39 observe : function(subject, topic, data) { 40 var id = firemobilesimulator.common.pref.copyUnicharPref("msim.current.id"); 41 40 if (topic == "app-startup") { 41 dump("msim:topic is app-startup.\n"); 42 var os = Cc["@mozilla.org/observer-service;1"] 43 .getService(Ci.nsIObserverService); 44 os.addObserver(this, "http-on-modify-request", false); 45 os.addObserver(this, "http-on-examine-response", false); 46 os.addObserver(this, "http-on-examine-merged-response", false); 47 return; 48 } 49 50 var httpChannel = subject.QueryInterface(Ci.nsIHttpChannel); 51 var id = null; 52 var tab = firemobilesimulator.common.util.getTabFromHttpChannel(httpChannel); 53 if (tab) { 54 id = tab.getAttribute("firemobilesimulator-device-id"); 55 } 42 56 if (id) { 43 var carrier = firemobilesimulator.common.pref.copyUnicharPref("msim.devicelist."+id+".carrier"); 57 var pref_prefix = "msim.devicelist." + id; 58 var carrier = firemobilesimulator.common.pref.copyUnicharPref(pref_prefix + ".carrier"); 59 var useragent = firemobilesimulator.common.pref.copyUnicharPref(pref_prefix 60 + ".useragent"); 61 if (firemobilesimulator.common.carrier.SOFTBANK == carrier) { 62 useragent = firemobilesimulator.common.carrier.getSoftBankUserAgent(useragent); 63 }else if (firemobilesimulator.common.carrier.DOCOMO == carrier) { 64 useragent = firemobilesimulator.common.carrier.getDoCoMoUserAgent(useragent, id); 65 } 66 44 67 var registerFlag = firemobilesimulator.common.pref.getBoolPref("msim.config.register.enabled"); 45 68 46 69 if (topic == "http-on-modify-request") { 47 var httpChannel = subject.QueryInterface(Ci.nsIHttpChannel); 48 49 // dump("[msim]httpChennel.name:"+httpChannel.name+"\n"); 50 // dump("[msim]httpChannel.asciiSpec:"+httpChannel.URI.asciiSpec+"\n"); 70 71 //dump("[msim]httpChennel.name:"+httpChannel.name+"\n"); 72 //dump("[msim]httpChannel.asciiSpec:"+httpChannel.URI.asciiSpec+"\n"); 51 73 httpChannel.setRequestHeader("x-msim-use", "on", false); 52 74 … … 71 93 .getBoolPref("msim.temp.utnflag"); 72 94 if (true == utnFlag) { 73 var userAgent = firemobilesimulator.common.pref74 .copyUnicharPref("msim.current.useragent");75 76 95 // DoCoMo2.0 77 var userAgentTmp = user Agent96 var userAgentTmp = useragent 78 97 .match(/DoCoMo\/2\.0[^(]+\((?:[^;]*;)*[^)]*(?=\))/); 79 98 if (userAgentTmp) { 80 99 dump("##add utn match1 for DoCoMo2.0##\n"); 81 user Agent = userAgentTmp[0] + ";ser" + ser + ";icc"100 useragent = userAgentTmp[0] + ";ser" + ser + ";icc" 82 101 + icc + ")"; 83 102 } 84 103 85 104 // DoCoMo1.0 86 userAgentTmp = user Agent.match(/DoCoMo\/1\.0\/.+/);105 userAgentTmp = useragent.match(/DoCoMo\/1\.0\/.+/); 87 106 if (userAgentTmp) { 88 107 dump("##add utn match for DoCoMo1.0##\n"); 89 userAgent = userAgentTmp[0] + "/ser" + ser; 90 } 91 httpChannel.setRequestHeader("User-Agent", userAgent, 92 false); 108 useragent = userAgentTmp[0] + "/ser" + ser; 109 } 93 110 } 94 111 … … 192 209 } 193 210 211 httpChannel.setRequestHeader("User-Agent",useragent,false); 194 212 // set extra http headers 195 213 var extraHeaders = firemobilesimulator.common.pref.getListPref("msim.devicelist." + id … … 224 242 }); 225 243 } 226 } else if (topic == "app-startup") {227 // dump("msim:topic is app-startup.\n");228 var os = Cc["@mozilla.org/observer-service;1"]229 .getService(Ci.nsIObserverService);230 os.addObserver(this, "http-on-modify-request", false);231 os.addObserver(this, "http-on-examine-response", false);232 os.addObserver(this, "http-on-examine-merged-response", false);233 return;234 244 } 235 245 }, -
platform/firefox/FireMobileSimulator/trunk/src/components/msimStreamConverter.js
r27325 r29732 37 37 jsLoader.loadSubScript("chrome://msim/content/mpc/softbank.js"); 38 38 jsLoader.loadSubScript("chrome://msim/content/mpc.js"); 39 jsLoader.loadSubScript("chrome://msim/content/common/util.js"); 39 40 40 41 /* text/msim.html -> text/html stream converter */ … … 76 77 dump("[msim]onStopRequest\n"); 77 78 78 var id = firemobilesimulator.common.pref.copyUnicharPref("msim.current.id"); 79 var carrier = firemobilesimulator.common.pref.copyUnicharPref("msim.devicelist."+id+".carrier"); 79 var id = null; 80 var tab = firemobilesimulator.common.util.getTabFromHttpChannel(this.channel); 81 dump(tab+"\n"); 82 if (tab) { 83 dump("getTabId\n"); 84 id = tab.getAttribute("firemobilesimulator-device-id"); 85 dump("["+id+"]\n"); 86 } 87 var pref_prefix = "msim.devicelist." + id; 88 var carrier = firemobilesimulator.common.pref.copyUnicharPref(pref_prefix + ".carrier"); 80 89 81 90 //絵文字変換
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)