Mercurial > snowl
comparison content/stream.js @ 358:c00b3db58dcf
add 'snowl' to all observer topics to avoid conflicts with other extensions/core code; use the Observers component everywhere
author | Myk Melez <myk@mozilla.org> |
---|---|
date | Tue, 04 Nov 2008 12:11:07 -0800 |
parents | e9d7087abad1 |
children | 57bbbcb76b0b |
comparison
equal
deleted
inserted
replaced
357:1db123f46ed7 | 358:c00b3db58dcf |
---|---|
40 const Cu = Components.utils; | 40 const Cu = Components.utils; |
41 | 41 |
42 // modules that come with Firefox | 42 // modules that come with Firefox |
43 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); | 43 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
44 | 44 |
45 // modules that should come with Firefox | 45 // modules that are generic |
46 Cu.import("resource://snowl/modules/log4moz.js"); | 46 Cu.import("resource://snowl/modules/log4moz.js"); |
47 Cu.import("resource://snowl/modules/Observers.js"); | |
47 Cu.import("resource://snowl/modules/URI.js"); | 48 Cu.import("resource://snowl/modules/URI.js"); |
48 Cu.import("resource://snowl/modules/Observers.js"); | |
49 | 49 |
50 // modules that are Snowl-specific | 50 // modules that are Snowl-specific |
51 Cu.import("resource://snowl/modules/datastore.js"); | 51 Cu.import("resource://snowl/modules/datastore.js"); |
52 Cu.import("resource://snowl/modules/collection.js"); | 52 Cu.import("resource://snowl/modules/collection.js"); |
53 Cu.import("resource://snowl/modules/utils.js"); | 53 Cu.import("resource://snowl/modules/utils.js"); |
81 let faviconSvc = Cc["@mozilla.org/browser/favicon-service;1"]. | 81 let faviconSvc = Cc["@mozilla.org/browser/favicon-service;1"]. |
82 getService(Ci.nsIFaviconService); | 82 getService(Ci.nsIFaviconService); |
83 delete this._faviconSvc; | 83 delete this._faviconSvc; |
84 this._faviconSvc = faviconSvc; | 84 this._faviconSvc = faviconSvc; |
85 return this._faviconSvc; | 85 return this._faviconSvc; |
86 }, | |
87 | |
88 // Observer Service | |
89 get _obsSvc() { | |
90 let obsSvc = Cc["@mozilla.org/observer-service;1"]. | |
91 getService(Ci.nsIObserverService); | |
92 delete this._obsSvc; | |
93 this._obsSvc = obsSvc; | |
94 return this._obsSvc; | |
95 }, | 86 }, |
96 | 87 |
97 _window: null, | 88 _window: null, |
98 _document: null, | 89 _document: null, |
99 | 90 |
137 | 128 |
138 delete this._linkifyRegex; | 129 delete this._linkifyRegex; |
139 return this._linkifyRegex = regex; | 130 return this._linkifyRegex = regex; |
140 }, | 131 }, |
141 | 132 |
142 // nsISupports | |
143 QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, | |
144 Ci.nsISupportsWeakReference]), | |
145 | |
146 | 133 |
147 //**************************************************************************// | 134 //**************************************************************************// |
148 // Initialization & Destruction | 135 // Initialization & Destruction |
149 | 136 |
150 onLoad: function() { | 137 onLoad: function() { |
151 Observers.add(this, "snowl:message:added"); | 138 Observers.add(this, "snowl:message:added"); |
139 Observers.add(this, "snowl:sources:changed"); | |
152 | 140 |
153 this.onResize(); | 141 this.onResize(); |
154 | 142 |
155 // Explicitly wrap |window| in an XPCNativeWrapper to make sure | 143 // Explicitly wrap |window| in an XPCNativeWrapper to make sure |
156 // it's a real native object! This will throw an exception if we | 144 // it's a real native object! This will throw an exception if we |
195 // nsIObserver | 183 // nsIObserver |
196 observe: function(subject, topic, data) { | 184 observe: function(subject, topic, data) { |
197 switch (topic) { | 185 switch (topic) { |
198 case "snowl:message:added": | 186 case "snowl:message:added": |
199 this._onMessageAdded(subject); | 187 this._onMessageAdded(subject); |
188 break; | |
189 case "snowl:sources:changed": | |
190 this._onSourcesChanged(); | |
200 break; | 191 break; |
201 } | 192 } |
202 }, | 193 }, |
203 | 194 |
204 onMidnight: function() { | 195 onMidnight: function() { |
230 let codeStr = "messages.insertBefore(messageBox, messages.firstChild)"; | 221 let codeStr = "messages.insertBefore(messageBox, messages.firstChild)"; |
231 Cu.evalInSandbox(codeStr, this._contentSandbox); | 222 Cu.evalInSandbox(codeStr, this._contentSandbox); |
232 | 223 |
233 this._contentSandbox.messages = null; | 224 this._contentSandbox.messages = null; |
234 this._contentSandbox.messageBox = null; | 225 this._contentSandbox.messageBox = null; |
226 }, | |
227 | |
228 _onSourcesChanged: function() { | |
229 this._rebuildView(); | |
235 }, | 230 }, |
236 | 231 |
237 onToggleGroup: function(event) { | 232 onToggleGroup: function(event) { |
238 event.target.nextSibling.style.display = event.target.checked ? "block" : "none"; | 233 event.target.nextSibling.style.display = event.target.checked ? "block" : "none"; |
239 }, | 234 }, |