[Bbs2ch-cvs 360] [342] b2rIStorageService. getBoardData の実装

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2008年 1月 27日 (日) 23:21:14 JST


Revision: 342
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=bbs2ch&view=rev&rev=342
Author:   flyson
Date:     2008-01-27 23:21:13 +0900 (Sun, 27 Jan 2008)

Log Message:
-----------
b2rIStorageService.getBoardData の実装

Modified Paths:
--------------
    trunk/bbs2chreader/chrome/content/bbs2chreader/components/b2rStorageBoard.js


-------------- next part --------------
Modified: trunk/bbs2chreader/chrome/content/bbs2chreader/components/b2rStorageBoard.js
===================================================================
--- trunk/bbs2chreader/chrome/content/bbs2chreader/components/b2rStorageBoard.js	2008-01-27 13:49:01 UTC (rev 341)
+++ trunk/bbs2chreader/chrome/content/bbs2chreader/components/b2rStorageBoard.js	2008-01-27 14:21:13 UTC (rev 342)
@@ -93,6 +93,9 @@
 				"UPDATE board_data SET url=?1, type=?2, last_modified=?3 WHERE _rowid_=?4;");
 		this._statements["_setBoardData_insert"] = database.createStatement(
 				"INSERT OR REPLACE INTO board_data(board_id, url, type, last_modified) VALUES(?1,?2,?3,?4);");
+
+		this._statements["getBoardData_select"] = database.createStatement(
+				"SELECT board_id, url, type, last_modified, subscribed, post_name, post_mail FROM board_data WHERE board_id=?1");
 	},
 
 
@@ -199,8 +202,34 @@
 		}
 	},
 
-	_getBoardData: function(aBoardID){
-		return null;
+	getBoardData: function(aBoardURL){
+		var b2rService = XPC.getService("@bbs2ch.sourceforge.jp/b2r-global-service;1", "b2rIGlobalService");
+		var boardID = b2rService.threadUtils.getBoardID(aBoardURL);
+		var statement = this._statements["getBoardData_select"];
+		statement.bindStringParameter(0, boardID);
+
+		var result = null;
+		gStorageService.database.beginTransaction();
+		try{
+			if(statement.executeStep()){
+				result = new b2rBoardData(
+					statement.getString(0), // boardID
+					statement.getString(1), // url
+					statement.getInt32(2),  // type
+					statement.getInt64(3),  // last_modified
+					statement.getInt32(4),  // subscribed
+					statement.getString(5), // post_name
+					statement.getString(6)  // post_mail
+				);
+			}
+			statement.reset();
+		}catch(ex){
+			Components.utils.reportError(ex);
+		}finally{
+			gStorageService.database.commitTransaction();
+		}
+
+		return result;
 	}
 
 };
@@ -211,7 +240,7 @@
 	this._url = aURL;
 	this._type = aType;
 	this._lastModified = aLastModified;
-	this._subscribed = aSubscribed;
+	this._subscribed = Boolean(aSubscribed==1);
 	this._postName = aPostName;
 	this._postMail = aPostMail;
 }
@@ -221,7 +250,12 @@
 		return this._boardID;
 	},
 	get url() {
-		return this._url;
+		if(this._url){
+			var ioService = Components.classes["@mozilla.org/network/io-service;1"]
+					.getService(Components.interfaces.nsIIOService);
+			return ioService.newURI(this._url, null, null).QueryInterface(Components.interfaces.nsIURL);
+		}
+		return null;
 	},
 	get type() {
 		return this._type;


bbs2ch-cvs メーリングリストの案内
Back to archive index