Show
Ignore:
Timestamp:
02/09/09 01:08:35 (4 years ago)
Author:
thorikawa
Message:

タブごと端末設定対応(途中)

Location:
platform/firefox/FireMobileSimulator/trunk/src
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • platform/firefox/FireMobileSimulator/trunk/src/chrome/content/common/carrier.js

    r27325 r29732  
    107107 
    108108firemobilesimulator.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"); 
    111111        var replacement  = ""; 
    112112        if (true == notifySerial) { 
     
    114114        } 
    115115        useragent = useragent.replace("[/Serial]", replacement); 
    116         dump("[msim]SB UA:" + useragent + "\n"); 
     116        //dump("[msim]SB UA:" + useragent + "\n"); 
    117117        return useragent; 
    118118}; 
     
    120120//firemobilesimulator.common.carrier.getDocomoUserAgent = function(useragent, id) { 
    121121firemobilesimulator.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"); 
    124124        if (firemobilesimulator.common.carrier.Type[firemobilesimulator.common.carrier.DOCOMO].DOCOMO_FOMA == type1) { 
    125125                //TODO ;TB;WxxHxxの部分も動的に組み立てられるようにする 
     
    129129                useragent = useragent + "/c" + cache + "/TB/W24H12)"; 
    130130        } 
    131         dump("[msim]DC UA:" + useragent + "\n"); 
     131        //dump("[msim]DC UA:" + useragent + "\n"); 
    132132        return useragent; 
    133133}; 
  • platform/firefox/FireMobileSimulator/trunk/src/chrome/content/common/util.js

    r27271 r29732  
    201201        return r; 
    202202}; 
     203 
     204firemobilesimulator.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 */ 
    1920 
    2021var firemobilesimulator; 
     
    2526 
    2627firemobilesimulator.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);  
    3130        firemobilesimulator.core.updateIcon(); 
    3231}; 
    3332 
    3433firemobilesimulator.core.setDevice = function(id) { 
    35  
    36         //dump("[msim]setDevice:" + carrier + ",id:" + id + "\n"); 
     34        dump("[msim]setDevice:" + id + "\n"); 
    3735 
    3836        if (!id) { 
     
    4139        } 
    4240 
    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);  
    5943        firemobilesimulator.core.updateIcon(); 
    6044}; 
     
    6751        }); 
    6852 
    69         //既に使われている端末だったら設定をリセット 
     53        // 既に使われている端末だったら設定をリセット 
    7054        if (firemobilesimulator.common.pref.copyUnicharPref("msim.current.id") == deletedId) { 
    7155                firemobilesimulator.core.resetDevice(); 
    7256        } 
    7357 
    74         //各端末のidを再計算 
     58        // 各端末のidを再計算 
    7559        var count = firemobilesimulator.common.pref.getIntPref("msim.devicelist.count"); 
    7660        for (let i=deletedId+1; i<=count; i++) { 
     
    151135        if (deviceResults.length == 0) return; 
    152136 
    153         //XMLから端末情報を順次解析 
     137        // XMLから端末情報を順次解析 
    154138        var devices = new Array(); 
    155139        var i = 0; 
     
    163147                                let headerElement = null; 
    164148 
    165                                 //ExtraHeaderエレメントの取得 
     149                                // ExtraHeaderエレメントの取得 
    166150                                let headers = new Array(); 
    167151                                let j = 0; 
     
    230214        }); 
    231215 
    232         //set device count 
     216        // set device count 
    233217        firemobilesimulator.common.pref.setIntPref("msim.devicelist.count", currentId); 
    234218        return true; 
     
    282266        } 
    283267        firemobilesimulator.common.pref.deletePref("msim.devicelist.count"); 
    284         firemobilesimulator.common.pref.deletePref("msim.current.carrier"); 
    285268        firemobilesimulator.common.pref.deletePref("general.useragent.override"); 
    286         firemobilesimulator.common.pref.deletePref("msim.current.useragent"); 
    287         firemobilesimulator.common.pref.deletePref("msim.current.id"); 
    288269        firemobilesimulator.core.resetDevice(); 
    289270}; 
  • platform/firefox/FireMobileSimulator/trunk/src/chrome/content/options/options.js

    r27271 r29732  
    7777        if (selectedItem) { 
    7878                var id = selectedItem.getAttribute("id"); 
    79                 if (window.openDialog( 
     79                window.openDialog( 
    8080                                "chrome://msim/content/options/dialogs/device.xul", 
    8181                                "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); 
    8983        } else { 
    9084                dump("[msim]Error : Device is not selected.\n"); 
     
    238232                firemobilesimulator.options.optionsDataString["msim.config.SB.serial"] = pageDocument 
    239233                                .getElementById("msim-textbox-softbank-serial").value; 
    240                 var carrier = firemobilesimulator.common.pref 
    241                                 .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.pref 
    245                                         .copyUnicharPref("msim.current.id"); 
    246                         var useragent = firemobilesimulator.common.pref 
    247                                         .copyUnicharPref("msim.devicelist." + id + ".useragent"); 
    248                         var newUserAgent = firemobilesimulator.common.carrier 
    249                                         .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                 } 
    255234        } else if (iFrameSrc.indexOf("devices") != -1) { 
    256235                // Nothing to do 
  • platform/firefox/FireMobileSimulator/trunk/src/chrome/content/overlay.js

    r29358 r29732  
    134134        } 
    135135 
    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); 
    145137        currentMenu.setAttribute("checked", true); 
    146138}; 
     
    187179firemobilesimulator.overlay.BrowserOnLoad = function(objEvent) { 
    188180        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"); 
    192186 
    193187        if (carrier) { 
  • platform/firefox/FireMobileSimulator/trunk/src/components/msimModifyHeaders.js

    r29300 r29732  
    3838 
    3939        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                } 
    4256                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 
    4467                        var registerFlag = firemobilesimulator.common.pref.getBoolPref("msim.config.register.enabled"); 
    4568 
    4669                        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"); 
    5173                                httpChannel.setRequestHeader("x-msim-use", "on", false); 
    5274 
     
    7193                                                        .getBoolPref("msim.temp.utnflag"); 
    7294                                        if (true == utnFlag) { 
    73                                                 var userAgent = firemobilesimulator.common.pref 
    74                                                                 .copyUnicharPref("msim.current.useragent"); 
    75  
    7695                                                // DoCoMo2.0 
    77                                                 var userAgentTmp = userAgent 
     96                                                var userAgentTmp = useragent 
    7897                                                                .match(/DoCoMo\/2\.0[^(]+\((?:[^;]*;)*[^)]*(?=\))/); 
    7998                                                if (userAgentTmp) { 
    8099                                                        dump("##add utn match1 for DoCoMo2.0##\n"); 
    81                                                         userAgent = userAgentTmp[0] + ";ser" + ser + ";icc" 
     100                                                        useragent = userAgentTmp[0] + ";ser" + ser + ";icc" 
    82101                                                                        + icc + ")"; 
    83102                                                } 
    84103 
    85104                                                // DoCoMo1.0 
    86                                                 userAgentTmp = userAgent.match(/DoCoMo\/1\.0\/.+/); 
     105                                                userAgentTmp = useragent.match(/DoCoMo\/1\.0\/.+/); 
    87106                                                if (userAgentTmp) { 
    88107                                                        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                                                } 
    93110                                        } 
    94111 
     
    192209                                } 
    193210 
     211                                httpChannel.setRequestHeader("User-Agent",useragent,false); 
    194212                                // set extra http headers 
    195213                                var extraHeaders = firemobilesimulator.common.pref.getListPref("msim.devicelist." + id 
     
    224242                                }); 
    225243                        } 
    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; 
    234244                } 
    235245        }, 
  • platform/firefox/FireMobileSimulator/trunk/src/components/msimStreamConverter.js

    r27325 r29732  
    3737jsLoader.loadSubScript("chrome://msim/content/mpc/softbank.js"); 
    3838jsLoader.loadSubScript("chrome://msim/content/mpc.js"); 
     39jsLoader.loadSubScript("chrome://msim/content/common/util.js"); 
    3940 
    4041/* text/msim.html -> text/html stream converter */ 
     
    7677        dump("[msim]onStopRequest\n"); 
    7778 
    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"); 
    8089 
    8190        //絵文字変換