Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Mar 30th, 2011  |  syntax: Diff  |  size: 11.29 KB  |  hits: 27  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. diff --git a/content/reddit/redditBar.xml b/content/reddit/redditBar.xml
  2. index 8865d47..02d0f50 100644
  3. --- a/content/reddit/redditBar.xml
  4. +++ b/content/reddit/redditBar.xml
  5. @@ -5,6 +5,7 @@
  6.  
  7.    <binding id="reddit-content-ui" extends="chrome://socialite/content/socialiteBar.xml#socialite-site-content-ui">
  8.      <content>
  9. +  
  10.        <xul:hbox anonid="reddit-content-ui-container" class="socialite-login-state" xbl:inherits="isloggedin" flex="1" align="center">
  11.          <xul:box tooltip="_child">
  12.            <!-- A parent box element seems to be necessary to make tooltips work.-->
  13. @@ -14,6 +15,7 @@
  14.          <xul:description anonid="descriptionTitle" class="socialite-title" flex="1"/>
  15.          <xul:label anonid="labelSubreddit" class="reddit-subreddit"/>
  16.          <xul:spacer flex="9999"/>
  17. +        
  18.          <xul:hbox anonid="boxButtons" class="buttonbox" align="stretch">
  19.            <xul:button anonid="buttonLike" class="socialite-notification-button socialite-logged-in" type="checkbox" label="&like.label;" accesskey="&like.accesskey;" autoCheck="false"/>
  20.            <xul:button anonid="buttonDislike" class="socialite-notification-button socialite-logged-in" type="checkbox" label="&dislike.label;" accesskey="&dislike.accesskey;" autoCheck="false"/>
  21. @@ -31,13 +33,14 @@
  22.          </xul:hbox>
  23.        </xul:hbox>
  24.      </content>
  25. -    
  26. -    <resources>
  27. +  
  28. +   <resources>
  29.        <stylesheet src="chrome://global/skin/button.css"/>
  30.        <stylesheet src="chrome://socialite/skin/socialite.css"/>
  31.        <stylesheet src="chrome://socialite/skin/socialite_platform.css"/>
  32.        <stylesheet src="chrome://socialite/skin/reddit.css"/>
  33. -    </resources>
  34. +    </resources>
  35. +  
  36.      
  37.      <implementation>
  38.        <field name="afterBound"/>
  39. @@ -174,6 +177,7 @@
  40.            
  41.            // Like button
  42.            if (this.linkInfo.localState.isLiked == true) {
  43. +          
  44.              this.buttonLike.image = "chrome://socialite/content/reddit/upmod.png";
  45.              this.buttonLike.checked = true;
  46.            } else {
  47. @@ -210,13 +214,14 @@
  48.            // Helper for similar buttons to follow
  49.            var self = this;
  50.            function updateButton(button, image, text) {
  51. +          
  52.              if (self.compactDisplay) {
  53.                if (button._oldClassName == null) {
  54.                  button._oldClassName = button.className;
  55.                  button.className = button.className + " socialite-button-compact socialite-button-iconic";
  56.                }
  57.                if (text) { button.tooltipText = text; }
  58. -              if (image) { button.image = image; }
  59. +              if (image) {button.image = image;}
  60.              } else {
  61.                if (button._oldClassName != null) {
  62.                  button.className = button._oldClassName;
  63. @@ -269,11 +274,12 @@
  64.          <children/>
  65.        </xul:hbox>
  66.      </content>
  67. -    
  68. +
  69.      <resources>
  70.        <stylesheet src="chrome://socialite/skin/socialite.css"/>
  71.        <stylesheet src="chrome://socialite/skin/reddit.css"/>
  72.      </resources>
  73. +
  74.      
  75.      <implementation>
  76.        <field name="afterBound"/>
  77. diff --git a/content/siteInfoBox.xml b/content/siteInfoBox.xml
  78. index e2bdde5..883d12d 100644
  79. --- a/content/siteInfoBox.xml
  80. +++ b/content/siteInfoBox.xml
  81. @@ -39,16 +39,17 @@
  82.          }
  83.        </constructor>
  84.        
  85. -      <destructor>
  86. -        this.destroySiteInfoBox();
  87. -      </destructor>
  88. -      
  89. -      <method name="destroySiteInfoBox">
  90. +       <method name="destroySiteInfoBox">
  91.          <body>
  92.            if (this._removeFaviconWatch) { this._removeFaviconWatch(); }
  93.          </body>
  94.        </method>
  95.        
  96. +      <destructor>
  97. +        this.destroySiteInfoBox();
  98. +      </destructor>
  99. +  
  100. +      
  101.        <method name="updateSiteName">
  102.          <body>
  103.            this.name = this.site.siteName;
  104. @@ -141,4 +142,4 @@
  105.        </handler>
  106.      </handlers>
  107.    </binding>
  108. -</bindings>
  109. \ No newline at end of file
  110. +</bindings>
  111. diff --git a/content/socialiteBar.xml b/content/socialiteBar.xml
  112. index 57bfd23..585b713 100644
  113. --- a/content/socialiteBar.xml
  114. +++ b/content/socialiteBar.xml
  115. @@ -27,7 +27,7 @@
  116.                             oncommand="document.getBindingParent(this).closeClicked();"/>
  117.        </xul:hbox>
  118.      </content>
  119. -    
  120. +
  121.      <resources>
  122.        <stylesheet src="chrome://global/skin/notification.css"/>
  123.      </resources>
  124. @@ -114,11 +114,11 @@
  125.                             oncommand="document.getBindingParent(this).closeClicked();"/>
  126.        </xul:hbox>
  127.      </content>
  128. -    
  129. +
  130.      <resources>
  131.        <stylesheet src="chrome://socialite/skin/socialite.css"/>
  132.      </resources>
  133. -    
  134. +  
  135.      <implementation>
  136.        <field name="url"/>
  137.        
  138. @@ -262,11 +262,11 @@
  139.                             oncommand="document.getBindingParent(this).closeClicked();"/>
  140.        </xul:hbox>
  141.      </content>
  142. -    
  143. +
  144.      <resources>
  145.        <stylesheet src="chrome://socialite/skin/socialite.css"/>
  146.      </resources>
  147. -    
  148. +  
  149.      <implementation>
  150.        <field name="url"/>
  151.              
  152. @@ -320,10 +320,11 @@
  153.    </binding>
  154.    
  155.    <binding id="socialite-site-ui">
  156. +
  157.      <resources>
  158.        <stylesheet src="chrome://socialite/skin/socialite_platform.css"/>
  159.      </resources>
  160. -
  161. +  
  162.      <implementation>
  163.        <field name="siteID"/>
  164.        
  165. @@ -380,13 +381,13 @@
  166.          </xul:toolbarbutton>
  167.        </xul:hbox>
  168.      </content>
  169. -    
  170. +  
  171.      <resources>
  172.        <stylesheet src="chrome://socialite/skin/socialite.css"/>
  173.        <stylesheet src="chrome://socialite/skin/socialite_platform.css"/>
  174.        <stylesheet src="chrome://global/skin/notification.css"/>
  175.      </resources>
  176. -    
  177. +  
  178.      <implementation>
  179.        <field name="siteItems"/>
  180.        <field name="selectedSite"/>
  181. diff --git a/install.rdf b/install.rdf
  182. index 90a9555..4fe031c 100644
  183. --- a/install.rdf
  184. +++ b/install.rdf
  185. @@ -5,10 +5,10 @@
  186.    <RDF:Description RDF:about="rdf:#$tddXp3"
  187.                     em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
  188.                     em:minVersion="3.0"
  189. -                   em:maxVersion="3.5.*" />
  190. +                   em:maxVersion="4.*" />
  191.    <RDF:Description RDF:about="urn:mozilla:install-manifest"
  192.                     em:id="socialite@chromakode"
  193. -                   em:version="1.3.3.8pre1"
  194. +                   em:version="1.4"
  195.                     em:type="2"
  196.                     em:iconURL="chrome://socialite/skin/socialite.png"
  197.                     em:optionsURL="chrome://socialite/content/socialitePreferences.xul">
  198. diff --git a/modules/migration.jsm b/modules/migration.jsm
  199. index 5b3a058..c18e21d 100644
  200. --- a/modules/migration.jsm
  201. +++ b/modules/migration.jsm
  202. @@ -7,16 +7,20 @@ let versionCompare = Components.classes["@mozilla.org/xpcom/version-comparator;1
  203.                                          .getService(Components.interfaces.nsIVersionComparator)
  204.                                          .compare;
  205.  
  206. -let extensionManager = Components.classes["@mozilla.org/extensions/manager;1"]
  207. -                                           .getService(Components.interfaces.nsIExtensionManager);
  208. +let extensionManager =null;
  209. +try{
  210. +  extensionManager = Components.classes["@mozilla.org/extensions/manager;1"]
  211. +                                           .getService(Components.interfaces.nsIExtensionManager);  
  212. +}catch(err){
  213. +  Components.utils.import("resource://gre/modules/AddonManager.jsm");
  214. +}
  215. +
  216.  
  217.  let EXTENSION_ID = "socialite@chromakode";
  218.  
  219. -var SocialiteMigration = {
  220. -  perform: function() {  
  221. -    let currentVersion = extensionManager.getItemForID(EXTENSION_ID).version;
  222. -    
  223. -    let lastVersion;
  224. +
  225. +function migrate(currentVersion){
  226. +   let lastVersion;
  227.      if (Socialite.preferences.prefHasUserValue("lastVersion")) {
  228.        lastVersion = Socialite.preferences.getCharPref("lastVersion");
  229.      } else {
  230. @@ -49,5 +53,18 @@ var SocialiteMigration = {
  231.        // Update the record of the last version seen
  232.        Socialite.preferences.setCharPref("lastVersion", currentVersion);
  233.      }
  234. +}
  235. +
  236. +function callback(addon){
  237. +migrate(addon.version);
  238. +}
  239. +
  240. +var SocialiteMigration = {
  241. +  perform: function() {  
  242. +     try{
  243. +        AddonManager.getAddonByID(EXTENSION_ID,callback);
  244. +    }catch(err){
  245. +       migrate(extensionManager.getItemForID(EXTENSION_ID).version);
  246. +     }
  247.    }
  248. -};
  249. \ No newline at end of file
  250. +};
  251. diff --git a/modules/reddit/authentication.jsm b/modules/reddit/authentication.jsm
  252. index f6121fa..6d55972 100644
  253. --- a/modules/reddit/authentication.jsm
  254. +++ b/modules/reddit/authentication.jsm
  255. @@ -101,28 +101,31 @@ function extractAuthInfo(document) {
  256.      username: extractUsername(document),
  257.      modhash:  extractModHash(document)
  258.    };
  259. +  
  260.    authInfo.isLoggedIn = (authInfo.username != false) && (authInfo.username != null) && (authInfo.modhash != "");
  261.    return authInfo;
  262.  }
  263.  
  264.  function extractModHash(document) {
  265.    try {
  266. -    let globalsCode = document.getElementsByTagName("script")[0].textContent;
  267. +    let globalsCode = document.getElementsByTagName("script")[1].textContent;
  268.      const getModHash = /modhash\s*(?:\:|=)\s*'(\w*)'/;
  269.      
  270.      return globalsCode.match(getModHash)[1];
  271.    } catch (e)  {
  272. +  
  273.      logger.log("reddit_auth", this.siteURL, "Unable to parse page for user hash: " + e.toString());
  274.      return null;
  275.    }
  276.  }
  277.  
  278.  function extractUsername(document) {
  279. +      
  280.    // Get the username
  281.    try {
  282. -    let globalsCode = document.getElementsByTagName("script")[0].textContent;
  283. +    let globalsCode = document.getElementsByTagName("script")[1].textContent;
  284.      const getUsername = /logged\s*(?:\:|=)\s*('(\w+)'|false)/;
  285. -    
  286. +  
  287.      let username;
  288.      let [match, outer, inner] = globalsCode.match(getUsername);
  289.      if (outer == "false") {
  290. diff --git a/modules/utils/action/action.jsm b/modules/utils/action/action.jsm
  291. index 4937c89..aaec9a7 100644
  292. --- a/modules/utils/action/action.jsm
  293. +++ b/modules/utils/action/action.jsm
  294. @@ -64,6 +64,7 @@ ActionType.prototype = {
  295.    
  296.    addToArgs: function(args) {
  297.      // Arguments contain the arguments passed to this function, with this action object at the end.
  298. +      
  299.      var newargs = Array.prototype.splice.call(args, 0) || [];
  300.      if ((newargs.length == 0) || (newargs[newargs.length-1] != this)) {
  301.        newargs.push(this);
  302. @@ -88,14 +89,14 @@ ActionType.prototype = {
  303.    success: function() {
  304.      logger.log("action", this.name + " succeeded");
  305.      let result = this.doCallback(this.successCallback, arguments);
  306. -    this.doCallback(this.finallyCallback);
  307. +    this.doCallback(this.finallyCallback,arguments);
  308.      return result;
  309.    },
  310.    
  311.    failure: function() {
  312.      logger.log("action", this.name + " failed");
  313.      let result = this.doCallback(this.failureCallback, arguments);
  314. -    this.doCallback(this.finallyCallback);
  315. +    this.doCallback(this.finallyCallback,arguments);
  316.      return result;
  317.    },
  318.    
  319. diff --git a/modules/utils/log.jsm b/modules/utils/log.jsm
  320. index c0d1749..37c7ad3 100644
  321. --- a/modules/utils/log.jsm
  322. +++ b/modules/utils/log.jsm
  323. @@ -12,6 +12,7 @@ logSettings = null;
  324.  logHistory = [];
  325.  
  326.  function init(appname, settings) {
  327. +
  328.    if (!logInitialized) {
  329.      if (settings) {
  330.        logSettings = settings;
  331. @@ -42,6 +43,7 @@ function log() {
  332.    } else if (arguments.length == 3) {
  333.      entry = {section: arguments[0], identifier: arguments[1], msg: arguments[2]};
  334.    }
  335. +  
  336.  
  337.    if (logSettings.enabled) {
  338.      let logText = formatEntry(entry);