svnno****@sourc*****
svnno****@sourc*****
2008年 2月 3日 (日) 00:39:40 JST
Revision: 350 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=bbs2ch&view=rev&rev=350 Author: flyson Date: 2008-02-03 00:39:40 +0900 (Sun, 03 Feb 2008) Log Message: ----------- b2rIGlobalService 化 Modified Paths: -------------- trunk/bbs2chreader/chrome/content/bbs2chreader/board/page.js -------------- next part -------------- Modified: trunk/bbs2chreader/chrome/content/bbs2chreader/board/page.js =================================================================== --- trunk/bbs2chreader/chrome/content/bbs2chreader/board/page.js 2008-02-02 15:28:31 UTC (rev 349) +++ trunk/bbs2chreader/chrome/content/bbs2chreader/board/page.js 2008-02-02 15:39:40 UTC (rev 350) @@ -36,8 +36,8 @@ * ***** END LICENSE BLOCK ***** */ -var gBbs2chService = Cc["@mozilla.org/bbs2ch-service;1"].getService(Ci.nsIBbs2chService); -var gB2rService = Cc["@bbs2ch.sourceforge.jp/b2r-global-service;1"].getService(Ci.b2rIGlobalService); +var gB2rService = XPC.getService("@bbs2ch.sourceforge.jp/b2r-global-service;1", "b2rIGlobalService"); +var gPref = XPC.getService("@mozilla.org/preferences-service;1", "nsIPrefBranch"); var gTreeSubject; var gBoardItems; @@ -77,13 +77,13 @@ loadPersist(); // ツリーの偶数行に色をつける - if(gBbs2chService.pref.getBoolPref("extensions.bbs2chreader.enable_tree_stripe2")) + if(gPref.getBoolPref("extensions.bbs2chreader.enable_tree_stripe2")) gTreeSubject.setAttribute("stripe", "true"); - var b2rStorageService = Cc["@bbs2ch.sourceforge.jp/b2r-storage-service;1"].getService(Ci.b2rIStorageService); + var b2rStorageService = XPC.getService("@bbs2ch.sourceforge.jp/b2r-storage-service;1", "b2rIStorageService"); var boardData = b2rStorageService.getBoardData(gBoardItems.url); - if(gBbs2chService.pref.getBoolPref("extensions.bbs2chreader.board_auto_update")){ + if(gPref.getBoolPref("extensions.bbs2chreader.board_auto_update")){ subjectUpdate(); }else if(!gBoardItems.subjectFile.exists() || gBoardItems.subjectFile.fileSize==0 || !boardData){ subjectUpdate(); @@ -130,7 +130,7 @@ function loadPersist(){ - var persistPref = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService) + var persistPref = XPC.getService("@mozilla.org/preferences-service;1", "nsIPrefService") .getBranch("extensions.bbs2chreader.board_persist."); var prefList = persistPref.getChildList("", {}); for(var i=0; i<prefList.length; i++){ @@ -148,7 +148,7 @@ function savePersist(){ - var persistPref = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService) + var persistPref = XPC.getService("@mozilla.org/preferences-service;1", "nsIPrefService") .getBranch("extensions.bbs2chreader.board_persist."); var xpathResult = document.evaluate("descendant::*[@id][@persist2]", document, null, @@ -263,7 +263,7 @@ return; } - var openAction = gBbs2chService.pref.getIntPref(openActionPref); + var openAction = gPref.getIntPref(openActionPref); if(openAction==1){ openThread(false); }else if(openAction==2){ @@ -298,7 +298,7 @@ function openThread(aAddTab){ var threadURL = getSelectedThreadURL(); if(threadURL){ - gBbs2chService.openURL(threadURL, null, aAddTab); + gB2rService.openURL(threadURL, null, aAddTab); } } @@ -308,12 +308,11 @@ if(index == -1) return null; // スレッド表示数の制限 - var threadViewLimit = Number(gBbs2chService.pref.getIntPref( - "extensions.bbs2chreader.board_thread_view_limit")); + var threadViewLimit = Number(gPref.getIntPref("extensions.bbs2chreader.board_thread_view_limit")); if(isNaN(threadViewLimit) || threadViewLimit == 0){ threadViewLimit = ""; }else{ - if(gBoardItems.type == gBbs2chService.BOARD_TYPE_MACHI){ + if(gBoardItems.type == gB2rService.BOARD_TYPE_MACHI){ threadViewLimit = "&LAST=" + threadViewLimit; }else{ threadViewLimit = "l" + threadViewLimit; @@ -321,7 +320,7 @@ } var url = "/thread/" + gBoardItems.items[index].url + threadViewLimit; - return gBbs2chService.serverURL.resolve(url); + return gB2rService.serverURL.resolve(url); } @@ -370,7 +369,7 @@ if(gTreeSubject.currentIndex == -1) return; var indices = getSelectionIndices(); - var b2rStorageService = Cc["@bbs2ch.sourceforge.jp/b2r-storage-service;1"].getService(Ci.b2rIStorageService); + var b2rStorageService = XPC.getService("@bbs2ch.sourceforge.jp/b2r-storage-service;1", "b2rIStorageService"); for(var i=0; i<indices.length; i++){ var datID = gBoardItems.items[indices[i]].datID; @@ -439,8 +438,7 @@ if(Ci.nsIFormHistory2){ // フォーム履歴に検索文字列を追加 - var formHistory = Cc["@mozilla.org/satchel/form-history;1"] - .getService(Ci.nsIFormHistory2); + var formHistory = XPC.getService("@mozilla.org/satchel/form-history;1", "nsIFormHistory2"); formHistory.addEntry("bbs2ch-board-history", aSearchString); } @@ -463,7 +461,7 @@ // ダウンロード間隔の制限 if(gBoardItems.subjectFile.exists() && gBoardItems.subjectFile.fileSize!=0){ var interval = new Date().getTime() - gBoardItems.subjectFile.lastModifiedTime; - var updateIntervalLimit = gBbs2chService.pref.getIntPref( + var updateIntervalLimit = gPref.getIntPref( "extensions.bbs2chreader.board_update_interval_limit"); // 不正な値や、15 秒以下なら 15 秒にする if(isNaN(parseInt(updateIntervalLimit)) || updateIntervalLimit < 15) @@ -493,7 +491,7 @@ return; } - var b2rStorageService = Cc["@bbs2ch.sourceforge.jp/b2r-storage-service;1"].getService(Ci.b2rIStorageService); + var b2rStorageService = XPC.getService("@bbs2ch.sourceforge.jp/b2r-storage-service;1", "b2rIStorageService"); b2rStorageService.boardSubjectUpdate(gBoardItems.url, gBoardItems.type, gBoardItems.subjectFile.clone()); if(!gBoardItems.settingFile.exists() || gBoardItems.settingFile.fileSize==0){ @@ -531,8 +529,7 @@ * SETTING.TXT をダウンロードする */ function settingUpdate(){ - gSettingDownloader = new b2rDownloader(gBoardItems.settingURL.spec, - gBoardItems.settingFile.path); + gSettingDownloader = new b2rDownloader(gBoardItems.settingURL.spec, gBoardItems.settingFile.path); gSettingDownloader.onStart = function(aDownloader){ setStatus("start: " + this.urlSpec); @@ -561,9 +558,10 @@ function createSettingFile(){ + var bbs2chService = XPC.getService("@mozilla.org/bbs2ch-service;1", "nsIBbs2chService"); + // 板名記入ダイアログ表示 - var promptService = Cc["@mozilla.org/embedcomp/prompt-service;1"] - .getService(Ci.nsIPromptService); + var promptService = XPC.getService("@mozilla.org/embedcomp/prompt-service;1", "nsIPromptService"); var promptTitle = gBoardItems.url.spec + " [bbs2chreader]"; var promptMsg = "Entry This Board Title"; var promptValue = { value: "" }; @@ -572,17 +570,17 @@ var settingContent = ""; if(promptValue.value){ settingContent = "BBS_TITLE=" + promptValue.value + "\n"; - settingContent = gBbs2chService.toType(settingContent, gBoardItems.type); + settingContent = bbs2chService.toType(settingContent, gBoardItems.type); } - gBbs2chService.writeFile(gBoardItems.settingFile.path, settingContent, false); + bbs2chService.writeFile(gBoardItems.settingFile.path, settingContent, false); } function showBrowser(aTab){ if(aTab){ document.getElementById("popTools").hidePopup(); } - gBbs2chService.openURL(gBoardItems.url.spec, null, aTab); + gB2rService.openURL(gBoardItems.url.spec, null, aTab); } function openLogsDir(){ @@ -591,9 +589,8 @@ logDir.reveal(); }catch(ex){ // for Unix - var ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); - var protocolService = Cc["@mozilla.org/uriloader/external-protocol-service;1"] - .getService(Ci.nsIExternalProtocolService); + var ioService = XPC.getService("@mozilla.org/network/io-service;1", "nsIIOService"); + var protocolService = XPC.getService("@mozilla.org/uriloader/external-protocol-service;1", "nsIExternalProtocolService"); var logDirURI = ioService.newFileURI(logDir); protocolService.loadUrl(logDirURI); } @@ -604,7 +601,7 @@ var features = ""; try{ - var instantApply = gBbs2chService.pref.getBoolPref("browser.preferences.instantApply"); + var instantApply = gPref.getBoolPref("browser.preferences.instantApply"); features = "chrome,titlebar,toolbar,centerscreen" + (instantApply ? ",dialog=no" : ",modal"); }catch(ex){ features = "chrome,titlebar,toolbar,centerscreen,modal"; @@ -751,7 +748,7 @@ this._items = aItems; this._rowCount = aItems.length; - var atomService = Cc["@mozilla.org/atom-service;1"].getService(Ci.nsIAtomService); + var atomService = XPC.getService("@mozilla.org/atom-service;1", "nsIAtomService"); this._atom = new Array(); this._atom["s5"] = atomService.getAtom("s5"); this._atom["s4"] = atomService.getAtom("s4");