home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 December / PCWDEC06.iso / Software / Freeware / Gmail Manager 0.5.1 / gmanager051.xpi / components / gmService.js < prev    next >
Encoding:
Text File  |  2006-08-28  |  2.6 KB  |  96 lines

  1. // Gmail Manager
  2. // By Todd Long <longfocus@gmail.com>
  3. // http://www.longfocus.com/firefox/gmanager/
  4.  
  5. const GM_CC = Components.classes;
  6. const GM_CI = Components.interfaces;
  7.  
  8. function gmService() {}
  9. gmService.prototype = {
  10.   _type: null,
  11.   _email: null,
  12.   _password: null,
  13.   _remember: null,
  14.   _alias: null,
  15.   _node: null,
  16.   _prefs: null,
  17.   
  18.   get type() { return this._type; },
  19.   get email() { return this._email; },
  20.   get password() { return this._password; },
  21.   get remember() { return this._remember; },
  22.   get alias() { return this._alias; },
  23.   get prefs() { return this._prefs; },
  24.   
  25.   set type(aType) { this._type = aType; },
  26.   set email(aEmail) { this._email = aEmail; },
  27.   set password(aPassword) { this._password = aPassword; },
  28.   set remember(aRemember) { this._remember = aRemember; },
  29.   set alias(aAlias) { this._alias = aAlias; },
  30.   set prefs(aPrefs) { this._prefs = aPrefs; },
  31.   
  32.   getValue: function(aId)
  33.   {
  34.     return this._prefs[aId].value;
  35.   },
  36.   
  37.   getBoolValue: function(aId)
  38.   {
  39.     return (this.getValue(aId) == "true" ? true : false);
  40.   },
  41.   
  42.   getIntValue: function(aId)
  43.   {
  44.     return parseInt(this.getValue(aId));
  45.   },
  46.   
  47.   QueryInterface: function(iid)
  48.   {
  49.     if (!iid.equals(GM_CI.gmIService) && 
  50.         !iid.equals(GM_CI.nsISupports))
  51.       throw Components.results.NS_ERROR_NO_INTERFACE;
  52.     return this;
  53.   }
  54. }
  55.  
  56. var myModule = {
  57.   firstTime: true,
  58.   
  59.   myCID: Components.ID("{4ed92670-fbb4-11da-974d-0800200c9a66}"),
  60.   myDesc: "Mail account service",
  61.   myProgID: "@longfocus.com/gmanager/service;1",
  62.   myFactory: {
  63.     createInstance: function (outer, iid) {
  64.       if (outer != null)
  65.         throw Components.results.NS_ERROR_NO_AGGREGATION;
  66.       
  67.       return (new gmService()).QueryInterface(iid);
  68.     }
  69.   },
  70.  
  71.   registerSelf: function (compMgr, fileSpec, location, type)
  72.   {
  73.     if (this.firstTime) {
  74.       this.firstTime = false;
  75.       throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
  76.     }
  77.     
  78.     compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
  79.     compMgr.registerFactoryLocation(this.myCID, this.myDesc, this.myProgID, fileSpec, location, type);
  80.   },
  81.  
  82.   getClassObject: function (compMgr, cid, iid)
  83.   {
  84.     if (!cid.equals(this.myCID))
  85.       throw Components.results.NS_ERROR_NO_INTERFACE;
  86.     
  87.     if (!iid.equals(Components.interfaces.nsIFactory))
  88.       throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
  89.     
  90.     return this.myFactory;
  91.   },
  92.   
  93.   canUnload: function(compMgr) { return true; }
  94. };
  95.  
  96. function NSGetModule(compMgr, fileSpec) { return myModule; }