sbMacAppDelegate.mm
Go to the documentation of this file.
1 /*
2 //
3 // BEGIN SONGBIRD GPL
4 //
5 // This file is part of the Songbird web player.
6 //
7 // Copyright(c) 2005-2008 POTI, Inc.
8 // http://songbirdnest.com
9 //
10 // This file may be licensed under the terms of of the
11 // GNU General Public License Version 2 (the "GPL").
12 //
13 // Software distributed under the License is distributed
14 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
15 // express or implied. See the GPL for the specific language
16 // governing rights and limitations.
17 //
18 // You should have received a copy of the GPL along with this
19 // program. If not, go to http://www.gnu.org/licenses/gpl.html
20 // or write to the Free Software Foundation, Inc.,
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 // END SONGBIRD GPL
24 //
25 */
26 
27 #include "sbMacAppDelegate.h"
28 #include "../NativeWindowFromNode.h"
29 
30 #include <nsComponentManagerUtils.h>
31 #include <nsServiceManagerUtils.h>
32 #include <nsICategoryManager.h>
33 #include <nsIObserverService.h>
34 #include <nsIWindowMediator.h>
35 #include <nsIDOMWindowInternal.h>
36 #include <nsIDOMWindow.h>
37 #include <nsIDOMDocument.h>
38 #include <nsIDOMElement.h>
39 #include <nsStringAPI.h>
40 #include <nsIStringBundle.h>
41 #include <nsObjCExceptions.h>
42 #include <sbIApplicationController.h>
43 #include <sbIMediacoreManager.h>
44 #include <sbIMediacorePlaybackControl.h>
45 #include <sbIMediacoreSequencer.h>
46 #include <sbIMediacoreVolumeControl.h>
47 #include <sbIMediacoreStatus.h>
48 #include <sbStandardProperties.h>
49 #include <sbIMediaItem.h>
50 
51 #import <AppKit/AppKit.h>
52 
53 //-----------------------------------------------------------------------------
54 
56 
57 - (void)setAppDelegateOverride:(id)aDelegateOverride;
58 
59 @end
60 
61 @interface SBMacAppDelegate : NSObject
62 {
63 }
64 
65 // Menu item event handlers:
66 - (void)onPlayPauseSelected:(id)aSender;
67 - (void)onNextSelected:(id)aSender;
68 - (void)onPreviousSelected:(id)aSender;
69 - (void)onStopSelected:(id)aSender;
70 - (void)onMuteSelected:(id)aSender;
71 
72 @end
73 
75 
76 - (void)_setOverride:(id)aOverrideObj;
77 - (void)_addNowPlayingControls:(NSMenu *)aMenu;
78 - (void)_addPlayerControlMenuItems:(NSMenu *)aMenu;
79 - (void)_appendMenuItem:(NSString *)aTitle
80  action:(SEL)aSelector
81  menu:(NSMenu *)aParentMenu;
82 - (BOOL)_isPlaybackMuted;
83 - (BOOL)_isPlaybackPlaying;
84 - (BOOL)_isPlaybackStoppable;
85 - (NSString *)_stringForLocalizedKey:(const PRUnichar *)aBuffer;
86 
87 @end
88 
89 @implementation SBMacAppDelegate
90 
91 - (id)init
92 {
93  if ((self = [super init])) {
94  [self _setOverride:self];
95  }
96 
97  return self;
98 }
99 
100 - (void)dealloc
101 {
102  [self _setOverride:nil];
103  [super dealloc];
104 }
105 
106 - (void)_setOverride:(id)aOverrideObj
107 {
108  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
109 
110  id delegate = [[NSApplication sharedApplication] delegate];
111  if (delegate &&
112  [delegate respondsToSelector:@selector(setAppDelegateOverride:)])
113  {
114  [delegate setAppDelegateOverride:aOverrideObj];
115  }
116 
117  NS_OBJC_END_TRY_ABORT_BLOCK;
118 }
119 
120 // NSApplication delegate methods
121 - (BOOL)applicationShouldHandleReopen:(NSApplication*)theApp
122  hasVisibleWindows:(BOOL)flag
123 {
124  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
125 
126  nsresult rv;
127  nsCOMPtr<nsIWindowMediator> winMed =
128  do_GetService(NS_WINDOWMEDIATOR_CONTRACTID, &rv);
129  NS_ENSURE_SUCCESS(rv, NO);
130 
131  nsCOMPtr<nsIDOMWindowInternal> domWinInternal;
132  rv = winMed->GetMostRecentWindow(NS_LITERAL_STRING("Songbird:Main").get(),
133  getter_AddRefs(domWinInternal));
134  if (NS_SUCCEEDED(rv) && domWinInternal) {
135  NSWindow *window = NativeWindowFromNode::get(domWinInternal);
136  if (window && [window isMiniaturized]) {
137  [window deminiaturize:self];
138  }
139  }
140 
141  return NO; // don't let |NSApplication| do anything else
142 
143  NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(NO);
144 }
145 
146 - (NSMenu *)applicationDockMenu:(NSApplication *)sender
147 {
148  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
149 
150  nsresult rv;
151  nsCOMPtr<nsIWindowMediator> wm =
152  do_GetService(NS_WINDOWMEDIATOR_CONTRACTID, &rv);
153  NS_ENSURE_SUCCESS(rv, nil);
154 
155  // Get the frontmost window
156  nsCOMPtr<nsISimpleEnumerator> orderedWindowList;
157  rv = wm->GetZOrderDOMWindowEnumerator(nsnull, PR_TRUE,
158  getter_AddRefs(orderedWindowList));
159  NS_ENSURE_SUCCESS(rv, nil);
160  PRBool anyWindows = false;
161  rv = orderedWindowList->HasMoreElements(&anyWindows);
162  NS_ENSURE_SUCCESS(rv, nil);
163  nsCOMPtr<nsISupports> frontWindow;
164  rv = orderedWindowList->GetNext(getter_AddRefs(frontWindow));
165  NS_ENSURE_SUCCESS(rv, nil);
166 
167  // Get our list of windows and prepare to iterate. We use this list, ordered
168  // by window creation date, instead of the z-ordered list because that's what
169  // native apps do.
170  nsCOMPtr<nsISimpleEnumerator> windowList;
171  rv = wm->GetEnumerator(nsnull, getter_AddRefs(windowList));
172  NS_ENSURE_SUCCESS(rv, nil);
173 
174  // Iterate through our list of windows to create our menu
175  NSMenu *menu = [[[NSMenu alloc] initWithTitle:@""] autorelease];
176  PRBool more;
177  while (NS_SUCCEEDED(windowList->HasMoreElements(&more)) && more) {
178  // Get our native window
179  nsCOMPtr<nsISupports> curWindow;
180  rv = windowList->GetNext(getter_AddRefs(curWindow));
181  NS_ENSURE_SUCCESS(rv, nil);
182 
183  nsCOMPtr<nsIDOMWindow> domWindow = do_QueryInterface(curWindow, &rv);
184  if (!domWindow)
185  continue;
186 
187  // Make sure this isn't the Video Window:
188  nsCOMPtr<nsIDOMDocument> document;
189  domWindow->GetDocument(getter_AddRefs(document));
190  if (!document)
191  continue;
192 
193  nsCOMPtr<nsIDOMElement> element;
194  document->GetDocumentElement(getter_AddRefs(element));
195  if (!element)
196  continue;
197 
198  nsString idValue;
199  rv = element->GetAttribute(NS_LITERAL_STRING("id"), idValue);
200  if (idValue.Equals(NS_LITERAL_STRING("video_osd_controls_win")))
201  continue;
202 
203  NSWindow *cocoaWindow = NativeWindowFromNode::get(domWindow);
204  if (!cocoaWindow)
205  continue;
206 
207  NSString *windowTitle = [cocoaWindow title];
208  if (!windowTitle)
209  continue;
210 
211  // Now, create a menu item, and add it to the menu
212  NSMenuItem *menuItem = [[NSMenuItem alloc]
213  initWithTitle:windowTitle
214  action:@selector(dockMenuItemSelected:)
215  keyEquivalent:@""];
216  [menuItem setTarget:[[NSApplication sharedApplication] delegate]];
217  [menuItem setRepresentedObject:cocoaWindow];
218 
219  // If this is the foreground window, put a checkmark next to it
220  if (SameCOMIdentity(domWindow, frontWindow))
221  [menuItem setState:NSOnState];
222 
223  [menu addItem:menuItem];
224  [menuItem release];
225  }
226 
227  [self _addNowPlayingControls:menu];
228  [self _addPlayerControlMenuItems:menu];
229 
230  return menu;
231 
232  NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
233 }
234 
235 - (void)_addNowPlayingControls:(NSMenu *)aMenu
236 {
237  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
238 
239  nsresult rv;
240  nsCOMPtr<sbIMediacoreManager> manager =
241  do_GetService("@songbirdnest.com/Songbird/Mediacore/Manager;1", &rv);
242  if (NS_FAILED(rv)) {
243  return;
244  }
245 
246  nsCOMPtr<sbIMediacoreSequencer> sequencer;
247  rv = manager->GetSequencer(getter_AddRefs(sequencer));
248  if (NS_FAILED(rv)) {
249  return;
250  }
251 
252  nsCOMPtr<sbIMediaItem> curMediaItem;
253  rv = sequencer->GetCurrentItem(getter_AddRefs(curMediaItem));
254  if (NS_FAILED(rv) || !curMediaItem) {
255  return;
256  }
257 
258  nsString trackProp(NS_LITERAL_STRING(SB_PROPERTY_TRACKNAME));
259  nsString artistProp(NS_LITERAL_STRING(SB_PROPERTY_ARTISTNAME));
260 
261  nsString trackName;
262  rv = curMediaItem->GetProperty(trackProp, trackName);
263  if (NS_FAILED(rv)) {
264  return;
265  }
266 
267  nsString artistName;
268  rv = curMediaItem->GetProperty(artistProp, artistName);
269  if (NS_FAILED(rv)) {
270  return;
271  }
272 
273  // Apppend three spaces before the track and artist name
274  trackName.Insert(NS_LITERAL_STRING(" "), 0);
275  artistName.Insert(NS_LITERAL_STRING(" "), 0);
276 
277  NSString *trackStr =
278  [NSString stringWithCharacters:(unichar *)trackName.get()
279  length:trackName.Length()];
280 
281  // Now add the menu items
282  [aMenu addItem:[NSMenuItem separatorItem]];
283 
284  // Now playing item
285  nsString nowPlaying(NS_LITERAL_STRING("albumart.displaypane.title.playing"));
286  [self _appendMenuItem:[self _stringForLocalizedKey:nowPlaying.get()]
287  action:nil
288  menu:aMenu];
289 
290  // Track name
291  [self _appendMenuItem:trackStr action:nil menu:aMenu];
292 
293  // Artist name
294  NSString *artistStr =
295  [NSString stringWithCharacters:(unichar *)artistName.get()
296  length:artistName.Length()];
297  [self _appendMenuItem:artistStr action:nil menu:aMenu];
298 
299  NS_OBJC_END_TRY_ABORT_BLOCK;
300 }
301 
302 - (void)_addPlayerControlMenuItems:(NSMenu *)aMenu
303 {
304  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
305 
306  [aMenu addItem:[NSMenuItem separatorItem]];
307 
308  // Play menu item
309  nsString playPauseCommand;
310  if ([self _isPlaybackPlaying]) {
311  playPauseCommand.AssignLiteral("playback.label.pause");
312  }
313  else {
314  playPauseCommand.AssignLiteral("playback.label.play");
315  }
316  [self _appendMenuItem:[self _stringForLocalizedKey:playPauseCommand.get()]
317  action:@selector(onPlayPauseSelected:)
318  menu:aMenu];
319 
320  // Next menu item
321  nsString nextLabel(NS_LITERAL_STRING("playback.label.next"));
322  [self _appendMenuItem:[self _stringForLocalizedKey:nextLabel.get()]
323  action:@selector(onNextSelected:)
324  menu:aMenu];
325 
326  // Previous menu item
327  nsString previousLabel(NS_LITERAL_STRING("playback.label.previous"));
328  [self _appendMenuItem:[self _stringForLocalizedKey:previousLabel.get()]
329  action:@selector(onPreviousSelected:)
330  menu:aMenu];
331 
332  // Stop menu item
333  nsString stopLabel(NS_LITERAL_STRING("playback.label.stop"));
334  [self _appendMenuItem:[self _stringForLocalizedKey:stopLabel.get()]
335  action:@selector(onStopSelected:)
336  menu:aMenu];
337 
338  // Mute menu item
339  nsString muteLabel(NS_LITERAL_STRING("playback.label.mute"));
340  NSMenuItem *muteMenuItem =
341  [[NSMenuItem alloc] initWithTitle:[self _stringForLocalizedKey:muteLabel.get()]
342  action:@selector(onMuteSelected:)
343  keyEquivalent:@""];
344 
345  int muteState = ([self _isPlaybackMuted] ? NSOnState : NSOffState);
346  [muteMenuItem setState:muteState];
347  [muteMenuItem setTarget:self];
348  [aMenu addItem:muteMenuItem];
349 
350  NS_OBJC_END_TRY_ABORT_BLOCK;
351 }
352 
353 - (void)_appendMenuItem:(NSString *)aTitle
354  action:(SEL)aSelector
355  menu:(NSMenu *)aParentMenu
356 {
357  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
358 
359  NSMenuItem *menuItem =
360  [[NSMenuItem alloc] initWithTitle:aTitle
361  action:aSelector
362  keyEquivalent:@""];
363  [menuItem setTarget:self];
364  [aParentMenu addItem:menuItem];
365  [menuItem release];
366 
367  NS_OBJC_END_TRY_ABORT_BLOCK;
368 }
369 
370 - (void)onPlayPauseSelected:(id)aSender
371 {
372  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
373 
374  nsresult rv;
375  nsCOMPtr<sbIMediacoreManager> manager =
376  do_GetService("@songbirdnest.com/Songbird/Mediacore/Manager;1", &rv);
377  if (NS_FAILED(rv)) {
378  return;
379  }
380 
381  nsCOMPtr<sbIMediacorePlaybackControl> playbackControl;
382  rv = manager->GetPlaybackControl(getter_AddRefs(playbackControl));
383  if (NS_SUCCEEDED(rv) && playbackControl && [self _isPlaybackPlaying]) {
384  playbackControl->Pause();
385  }
386  else {
387  nsCOMPtr<sbIApplicationController> app =
388  do_GetService("@songbirdnest.com/Songbird/ApplicationController;1", &rv);
389  NS_ENSURE_SUCCESS(rv,);
390  rv = app->PlayDefault();
391  NS_ENSURE_SUCCESS(rv,);
392  }
393 
394  NS_OBJC_END_TRY_ABORT_BLOCK;
395 }
396 
397 - (void)onNextSelected:(id)aSender
398 {
399  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
400 
401  nsresult rv;
402  nsCOMPtr<sbIMediacoreManager> manager =
403  do_GetService("@songbirdnest.com/Songbird/Mediacore/Manager;1", &rv);
404  if (NS_FAILED(rv)) {
405  return;
406  }
407 
408  nsCOMPtr<sbIMediacoreSequencer> sequencer;
409  rv = manager->GetSequencer(getter_AddRefs(sequencer));
410  if (NS_FAILED(rv)) {
411  return;
412  }
413 
414  sequencer->Next(PR_FALSE);
415 
416  NS_OBJC_END_TRY_ABORT_BLOCK;
417 }
418 
419 - (void)onPreviousSelected:(id)aSender
420 {
421  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
422 
423  nsresult rv;
424  nsCOMPtr<sbIMediacoreManager> manager =
425  do_GetService("@songbirdnest.com/Songbird/Mediacore/Manager;1", &rv);
426  if (NS_FAILED(rv)) {
427  return;
428  }
429 
430  nsCOMPtr<sbIMediacoreSequencer> sequencer;
431  rv = manager->GetSequencer(getter_AddRefs(sequencer));
432  if (NS_FAILED(rv)) {
433  return;
434  }
435 
436  sequencer->Previous(PR_FALSE);
437 
438  NS_OBJC_END_TRY_ABORT_BLOCK;
439 }
440 
441 - (void)onStopSelected:(id)aSender
442 {
443  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
444 
445  nsresult rv;
446  nsCOMPtr<sbIMediacoreManager> manager =
447  do_GetService("@songbirdnest.com/Songbird/Mediacore/Manager;1", &rv);
448  if (NS_FAILED(rv)) {
449  return;
450  }
451 
452  nsCOMPtr<sbIMediacoreSequencer> sequencer;
453  rv = manager->GetSequencer(getter_AddRefs(sequencer));
454  if (NS_FAILED(rv)) {
455  return;
456  }
457 
458  sequencer->Stop(PR_FALSE);
459 
460  NS_OBJC_END_TRY_ABORT_BLOCK;
461 }
462 
463 - (void)onMuteSelected:(id)aSender
464 {
465  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
466 
467  NSMenuItem *senderItem = (NSMenuItem *)aSender;
468  if (!senderItem) {
469  return;
470  }
471 
472  nsresult rv;
473  nsCOMPtr<sbIMediacoreManager> manager =
474  do_GetService("@songbirdnest.com/Songbird/Mediacore/Manager;1", &rv);
475  if (NS_FAILED(rv)) {
476  return;
477  }
478 
479  nsCOMPtr<sbIMediacoreVolumeControl> volControl;
480  rv = manager->GetVolumeControl(getter_AddRefs(volControl));
481  if (NS_FAILED(rv)) {
482  return;
483  }
484 
485  PRBool isMuted = PR_FALSE;
486  rv = volControl->GetMute(&isMuted);
487  if (NS_FAILED(rv)) {
488  return;
489  }
490 
491  if ([self _isPlaybackMuted]) {
492  volControl->SetMute(PR_FALSE);
493  [senderItem setState:NSOffState];
494  }
495  else {
496  volControl->SetMute(PR_TRUE);
497  [senderItem setState:NSOnState];
498  }
499 
500  NS_OBJC_END_TRY_ABORT_BLOCK;
501 }
502 
503 - (BOOL)_isPlaybackMuted
504 {
505  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
506 
507  // Until bug 13295 is fixed, use the |volume| property to determine muted state.
508  nsresult rv;
509  nsCOMPtr<sbIMediacoreManager> manager =
510  do_GetService("@songbirdnest.com/Songbird/Mediacore/Manager;1", &rv);
511  NS_ENSURE_SUCCESS(rv, NO);
512 
513  nsCOMPtr<sbIMediacoreVolumeControl> volControl;
514  rv = manager->GetVolumeControl(getter_AddRefs(volControl));
515  NS_ENSURE_SUCCESS(rv, NO);
516 
517  PRBool isMuted = PR_FALSE;
518  rv = volControl->GetMute(&isMuted);
519  NS_ENSURE_SUCCESS(rv, NO);
520 
521  return isMuted;
522 
523  NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(NO);
524 }
525 
526 - (BOOL)_isPlaybackPlaying
527 {
528  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
529 
530  nsresult rv;
531  nsCOMPtr<sbIMediacoreManager> manager =
532  do_GetService("@songbirdnest.com/Songbird/Mediacore/Manager;1", &rv);
533  NS_ENSURE_SUCCESS(rv, NO);
534 
535  nsCOMPtr<sbIMediacoreStatus> status;
536  rv = manager->GetStatus(getter_AddRefs(status));
537  NS_ENSURE_SUCCESS(rv, NO);
538 
539  PRUint32 state;
540  rv = status->GetState(&state);
541  NS_ENSURE_SUCCESS(rv, NO);
542 
543  return state == sbIMediacoreStatus::STATUS_PLAYING ||
545 
546  NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(NO);
547 }
548 
549 - (BOOL)_isPlaybackStoppable
550 {
551  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
552 
553  nsresult rv;
554  nsCOMPtr<sbIMediacoreManager> manager =
555  do_GetService("@songbirdnest.com/Songbird/Mediacore/Manager;1", &rv);
556  NS_ENSURE_SUCCESS(rv, NO);
557 
558  nsCOMPtr<sbIMediacoreStatus> status;
559  rv = manager->GetStatus(getter_AddRefs(status));
560  NS_ENSURE_SUCCESS(rv, NO);
561 
562  PRUint32 state;
563  rv = status->GetState(&state);
564  NS_ENSURE_SUCCESS(rv, NO);
565 
566  return state == sbIMediacoreStatus::STATUS_PLAYING ||
569 
570  NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(NO);
571 }
572 
573 - (NSString *)_stringForLocalizedKey:(const PRUnichar *)aBuffer
574 {
575  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
576 
577  nsresult rv;
578  nsCOMPtr<nsIStringBundleService> strBundleService =
579  do_GetService("@mozilla.org/intl/stringbundle;1", &rv);
580  NS_ENSURE_SUCCESS(rv, @"");
581 
582  nsCOMPtr<nsIStringBundle> songbirdBundle;
583  rv = strBundleService->CreateBundle("chrome://songbird/locale/songbird.properties",
584  getter_AddRefs(songbirdBundle));
585  NS_ENSURE_SUCCESS(rv, nil);
586 
587  nsString localizedStr;
588  rv = songbirdBundle->GetStringFromName(aBuffer, getter_Copies(localizedStr));
589  NS_ENSURE_SUCCESS(rv, @"");
590 
591  return [NSString stringWithCharacters:(unichar *)localizedStr.get()
592  length:localizedStr.Length()];
593 
594  NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(@"");
595 }
596 
597 @end
598 
599 //-----------------------------------------------------------------------------
600 
601 NS_IMPL_ISUPPORTS1(sbMacAppDelegateManager, nsIObserver)
602 
603 sbMacAppDelegateManager::sbMacAppDelegateManager()
604  : mDelegate(nil)
605 {
606 }
607 
608 sbMacAppDelegateManager::~sbMacAppDelegateManager()
609 {
610  if (mDelegate) {
611  [mDelegate release];
612  mDelegate = nil;
613  }
614 }
615 
616 NS_IMETHODIMP
618 {
619  nsresult rv;
620  nsCOMPtr<nsIObserverService> observerService =
621  do_GetService("@mozilla.org/observer-service;1", &rv);
622  NS_ENSURE_SUCCESS(rv, rv);
623 
624  rv = observerService->AddObserver(this, "final-ui-startup", PR_FALSE);
625  NS_ENSURE_SUCCESS(rv, rv);
626 
627  rv = observerService->AddObserver(this, "quit-application-granted", PR_FALSE);
628  NS_ENSURE_SUCCESS(rv, rv);
629 
630  return NS_OK;
631 }
632 
633 NS_IMETHODIMP
634 sbMacAppDelegateManager::Observe(nsISupports *aSubject,
635  const char *aTopic,
636  const PRUnichar *aData)
637 {
638  NS_ENSURE_ARG_POINTER(aTopic);
639 
640  if (strcmp(aTopic, "final-ui-startup") == 0) {
641  mDelegate = [[SBMacAppDelegate alloc] init];
642  }
643  else if (strcmp(aTopic, "quit-application-granted") == 0) {
644  nsresult rv;
645  nsCOMPtr<nsIObserverService> observerService =
646  do_GetService("@mozilla.org/observer-service;1", &rv);
647  NS_ENSURE_SUCCESS(rv, rv);
648 
649  rv = observerService->RemoveObserver(this, "final-ui-startup");
650  NS_ENSURE_SUCCESS(rv, rv);
651 
652  rv = observerService->RemoveObserver(this, aTopic);
653  NS_ENSURE_SUCCESS(rv, rv);
654  }
655 
656  return NS_OK;
657 }
658 
659 /* static */ NS_METHOD
660 sbMacAppDelegateManager::RegisterSelf(nsIComponentManager *aCompMgr,
661  nsIFile *aPath,
662  const char *aLoaderStr,
663  const char *aType,
664  const nsModuleComponentInfo *aInfo)
665 {
666  NS_ENSURE_ARG_POINTER(aCompMgr);
667  NS_ENSURE_ARG_POINTER(aPath);
668  NS_ENSURE_ARG_POINTER(aLoaderStr);
669  NS_ENSURE_ARG_POINTER(aType);
670  NS_ENSURE_ARG_POINTER(aInfo);
671 
672  nsresult rv = NS_ERROR_UNEXPECTED;
673  nsCOMPtr<nsICategoryManager> catMgr =
674  do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
675  NS_ENSURE_SUCCESS(rv, rv);
676 
677  rv = catMgr->AddCategoryEntry("app-startup",
679  "service,"
681  PR_TRUE, PR_TRUE, nsnull);
682 
683  return NS_OK;
684 }
685 
return NS_OK
_updateCookies aPath
static nsCOMPtr< nsIObserverService > observerService
Definition: UnityProxy.cpp:6
const unsigned long STATUS_PLAYING
var menuItem
Definition: FeedWriter.js:970
menuItem id
Definition: FeedWriter.js:971
NS_IMPL_ISUPPORTS1(sbDeviceCapabilitiesUtils, sbIDeviceCapabilitiesUtils) sbDeviceCapabilitiesUtils
#define SONGBIRD_MACAPPDELEGATEMANAGER_CONTRACTID
var menu
let window
_window init
Definition: FeedWriter.js:1144
const unsigned long STATUS_BUFFERING
function Init()
static void * get(nsISupports *window)
void _setOverride:(id aOverrideObj)
#define SONGBIRD_MACAPPDELEGATEMANAGER_CLASSNAME
#define SB_PROPERTY_ARTISTNAME
const unsigned long STATUS_PAUSED
#define SB_PROPERTY_TRACKNAME
_updateTextAndScrollDataForFrame aData