29 #include <nsIObserverService.h>
30 #include <nsComponentManagerUtils.h>
31 #include <nsServiceManagerUtils.h>
32 #include <nsICategoryManager.h>
34 #include <sbIApplicationController.h>
35 #include <sbIMediacoreManager.h>
36 #include <sbIMediacorePlaybackControl.h>
37 #include <sbIMediacoreSequencer.h>
38 #include <sbIMediacoreVolumeControl.h>
39 #include <sbIMediacoreStatus.h>
41 #import <AppKit/AppKit.h>
42 #import <IOKit/hidsystem/ev_keymap.h>
43 #import </usr/include/objc/objc-class.h>
50 Method orig_method = nil, alt_method = nil;
53 orig_method = class_getInstanceMethod(aClass, orig_sel);
54 alt_method = class_getInstanceMethod(aClass, alt_sel);
57 if ((orig_method != nil) && (alt_method != nil)) {
61 temp1 = orig_method->method_types;
62 orig_method->method_types = alt_method->method_types;
63 alt_method->method_types = temp1;
65 temp2 = orig_method->method_imp;
66 orig_method->method_imp = alt_method->method_imp;
67 alt_method->method_imp = temp2;
76 nsCOMPtr<sbIMediacoreManager> manager =
77 do_GetService(
"@songbirdnest.com/Songbird/Mediacore/Manager;1", &rv);
78 NS_ENSURE_SUCCESS(rv, PR_FALSE);
80 nsCOMPtr<sbIMediacoreStatus> status;
81 rv = manager->GetStatus(getter_AddRefs(status));
82 NS_ENSURE_SUCCESS(rv, PR_FALSE);
85 rv = status->GetState(&state);
86 NS_ENSURE_SUCCESS(rv, PR_FALSE);
95 nsCOMPtr<sbIMediacoreManager> manager =
96 do_GetService(
"@songbirdnest.com/Songbird/Mediacore/Manager;1", &rv);
101 nsCOMPtr<sbIMediacorePlaybackControl> playbackControl;
102 rv = manager->GetPlaybackControl(getter_AddRefs(playbackControl));
104 playbackControl->Pause();
107 nsCOMPtr<sbIApplicationController> app =
108 do_GetService(
"@songbirdnest.com/Songbird/ApplicationController;1", &rv);
109 NS_ENSURE_SUCCESS(rv,);
110 rv = app->PlayDefault();
111 NS_ENSURE_SUCCESS(rv,);
118 nsCOMPtr<sbIMediacoreManager> manager =
119 do_GetService(
"@songbirdnest.com/Songbird/Mediacore/Manager;1", &rv);
124 nsCOMPtr<sbIMediacoreSequencer> sequencer;
125 rv = manager->GetSequencer(getter_AddRefs(sequencer));
130 sequencer->Previous(PR_FALSE);
136 nsCOMPtr<sbIMediacoreManager> manager =
137 do_GetService(
"@songbirdnest.com/Songbird/Mediacore/Manager;1", &rv);
142 nsCOMPtr<sbIMediacoreSequencer> sequencer;
143 rv = manager->GetSequencer(getter_AddRefs(sequencer));
148 sequencer->Next(PR_FALSE);
157 - (void)sendSongbirdEvent:(NSEvent *)event;
163 - (void)sendSongbirdEvent:(NSEvent *)event
166 if ([
event type] == NSSystemDefined && [
event subtype] == 8) {
167 int keyCode = (([event data1] & 0xFFFF0000) >> 16);
168 int keyFlags = ([event data1] & 0x0000FFFF);
169 int keyState = (((keyFlags & 0xFF00) >> 8)) == 0xA;
176 case NX_KEYTYPE_PLAY:
179 case NX_KEYTYPE_FAST:
180 case NX_KEYTYPE_NEXT:
183 case NX_KEYTYPE_REWIND:
184 case NX_KEYTYPE_PREVIOUS:
197 @selector(sendSongbirdEvent:),
198 @selector(sendEvent:));
200 [
self sendEvent:event];
204 @selector(sendEvent:),
205 @selector(sendSongbirdEvent:));
228 do_GetService(
"@mozilla.org/observer-service;1", &rv);
229 NS_ENSURE_SUCCESS(rv, rv);
231 rv = observerService->AddObserver(
this,
"final-ui-startup", PR_FALSE);
232 NS_ENSURE_SUCCESS(rv, rv);
234 rv = observerService->AddObserver(
this,
"quit-application-granted", PR_FALSE);
235 NS_ENSURE_SUCCESS(rv, rv);
241 sbAppleMediaKeyController::Observe(
nsISupports *aSubject,
243 const PRUnichar *
aData)
245 NS_ENSURE_ARG_POINTER(aTopic);
247 if (strcmp(aTopic,
"final-ui-startup") == 0) {
249 @selector(sendEvent:),
250 @selector(sendSongbirdEvent:));
252 else if (strcmp(aTopic,
"quit-application-granted") == 0) {
255 do_GetService(
"@mozilla.org/observer-service;1", &rv);
256 NS_ENSURE_SUCCESS(rv, rv);
258 rv = observerService->RemoveObserver(
this,
"final-ui-startup");
259 NS_ENSURE_SUCCESS(rv, rv);
261 rv = observerService->RemoveObserver(
this, aTopic);
262 NS_ENSURE_SUCCESS(rv, rv);
271 const char *aLoaderStr,
273 const nsModuleComponentInfo *aInfo)
275 NS_ENSURE_ARG_POINTER(aCompMgr);
276 NS_ENSURE_ARG_POINTER(aFile);
277 NS_ENSURE_ARG_POINTER(aLoaderStr);
278 NS_ENSURE_ARG_POINTER(aType);
279 NS_ENSURE_ARG_POINTER(aInfo);
281 nsresult rv = NS_ERROR_UNEXPECTED;
282 nsCOMPtr<nsICategoryManager> catMgr =
283 do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
284 NS_ENSURE_SUCCESS(rv, rv);
286 rv = catMgr->AddCategoryEntry(
"app-startup",
290 PR_TRUE, PR_TRUE, nsnull);
static nsCOMPtr< nsIObserverService > observerService
NS_IMPL_ISUPPORTS1(sbDeviceCapabilitiesUtils, sbIDeviceCapabilitiesUtils) sbDeviceCapabilitiesUtils
_updateTextAndScrollDataForFrame aData