twingle/twingle/content twingle.js,1.3,1.4

[email protected] Thu, 6 Mar 2003 13:37:44 -0700 (MST)
Newsgroups gmane.comp.cms.oscom.twingle.cvs
Message-ID <[email protected]>
Update of /cvs/root/twingle/twingle/content
In directory alpha.oscom.org:/tmp/cvs-serv14092

Modified Files:
	twingle.js 
Log Message:
Moved to a moztop-style RDF wrapper

Index: twingle.js
===================================================================
RCS file: /cvs/root/twingle/twingle/content/twingle.js,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** twingle.js	6 Mar 2003 18:09:49 -0000	1.3
--- twingle.js	6 Mar 2003 20:37:42 -0000	1.4
***************
*** 1,7 ****
  
- /* Some globals */
- var ncns ="http://home.netscape.com/NC-rdf#";
- var subitemsprop = ncns + "subitems";
- 
  /* Declare, but don't initialize, some global variables */
  var sitesds = null;
--- 1,3 ----
***************
*** 10,17 ****
  {
      /* First let's get the sites datasource set */
!     var profileurl = getProfileDirURL();
!     sitesds = new RDFDataSource(profileurl + "/twinglesites.rdf");
!     initializeProfileDatabases();
! 
  }
  
--- 6,10 ----
  {
      /* First let's get the sites datasource set */
!     initNavigator();
  }
  
***************
*** 32,90 ****
  /*  ====  Utility functions  ====   */
  
- function getProfileDirURL ()
- 
- {
- 
-     // First get the directory service and query interface it to
-     // nsIProperties
-     var dirService = Components.
- 	classes['@mozilla.org/file/directory_service;1'].
- 	getService(Components.interfaces.nsIProperties);
- 
-     // Next get the "ProfD" property of type nsIFile from the directory
-     // service, FYI this constant is defined in
-     // mozilla/xpcom/io/nsAppDirectoryServiceDefs.h
- 
-     const NS_APP_USER_PROFILE_50_DIR = "ProfD";
-     profileDir = dirService.get(NS_APP_USER_PROFILE_50_DIR,
- 				Components.interfaces.nsIFile);
- 
-     // Now that we have it we can show it's path. See nsIFile for the
-     // other things you that can be done with profileDir
- 
-     var io_service =
- 	Components.classes["@mozilla.org/network/io-service;1"].
- 	getService(Components.interfaces.nsIIOService);
-    
-     var url = io_service.newFileURI(profileDir)
- 	.QueryInterface(Components.interfaces.nsIFileURL);
-    
-     return url.spec;
- }
- 
- 
- function initializeProfileDatabases ()
- {
- 
-     /* Are there databases in profile dir?  If so, log a message and return */
-     var allres = sitesds.getAllResources();
-     if (allres.hasMoreElements()) {
- 	dump("\nFound existing twingle databases");
- 	dump("\n" + sitesds.serializeToString());
- 	return;
-     }
- 
- 
-     /* If we make it here, it means we need to create twingle databases */
-     var rootnode = sitesds.getNode("urn:twingle:sites");
-     var subitems = sitesds.getNode("urn:twingle:sites:subitems");
-     subitems.makeSeq();
-     rootnode.addTarget(this.subitemsprop,subitems);
- 
-     sitesds.save();
-     dump("\nCreated new twingle databases");
-     dump("\n" + sitesds.serializeToString());
-   
- 
-     return;
- }
--- 25,26 ----