29 #include "nsComponentManagerUtils.h"
30 #include "nsServiceManagerUtils.h"
31 #include "nsIObserverService.h"
38 static PRLogModuleInfo* gRemoteAPIServiceLog = nsnull;
42 #define LOG(args) PR_LOG(gRemoteAPIServiceLog, PR_LOG_WARN, args)
51 if (!gRemoteAPIServiceLog) {
52 gRemoteAPIServiceLog = PR_NewLogModule(
"sbRemoteAPIService");
55 LOG((
"sbRemoteAPIService::sbRemoteAPIService()"));
58 sbRemoteAPIService::~sbRemoteAPIService()
60 LOG((
"sbRemoteAPIService::~sbRemoteAPIService()"));
72 const char* remotes[] = {
76 "playback.control.triggered",
81 nsCOMPtr<nsIObserverService> obs =
82 do_GetService(
"@mozilla.org/observer-service;1", &rv );
83 NS_ENSURE_SUCCESS( rv, rv );
84 obs->AddObserver(
this,
"quit-application", PR_FALSE );
86 for (
int i = 0; remotes[
i]; ++
i) {
87 nsCOMPtr<sbIDataRemote> dr =
88 do_CreateInstance(
"@songbirdnest.com/Songbird/DataRemote;1", &rv );
89 NS_ENSURE_SUCCESS( rv, rv );
91 rv = dr->Init( NS_ConvertASCIItoUTF16(remotes[
i]), EmptyString() );
92 NS_ENSURE_SUCCESS( rv, rv );
94 rv = dr->BindObserver(
this, PR_FALSE );
95 NS_ENSURE_SUCCESS( rv, rv );
103 sbRemoteAPIService::HasPlaybackControl(nsIURI *aURI, PRBool *_retval)
106 NS_ENSURE_ARG(_retval);
109 nsCString spec, controllerSpec;
110 nsresult rv = aURI->GetSpec( spec );
111 if ( NS_FAILED(rv) ) {
112 spec.AssignLiteral(
"[unknown spec]");
116 rv = aURI->GetSpec( controllerSpec );
117 if ( NS_FAILED(rv) ) {
118 controllerSpec.AssignLiteral(
"[unknown spec]");
121 controllerSpec.AssignLiteral(
"[no uri]");
124 LOG((
"sbRemoteAPIService::HasPlaybackControl() - \n\t%s\n\t%s",
126 controllerSpec.BeginReading()));
137 sbRemoteAPIService::TakePlaybackControl(nsIURI *aURI, nsIURI **_retval)
142 nsresult rv = aURI->GetSpec( spec );
143 if ( NS_FAILED(rv) ) {
144 spec.AssignLiteral(
"[no spec]");
146 LOG((
"sbRemoteAPIService::TakePlaybackControl() - assigned spec %s",
147 spec.BeginReading() ));
149 LOG((
"sbRemoteAPIService::TakePlaybackControl() - clearing" ));
152 if ( NS_LIKELY(_retval) ) {
167 sbRemoteAPIService::Observe(
nsISupports *aSubject,
169 const PRUnichar *
aData )
171 LOG((
"sbRemoteAPIService::Observe() - %s", aTopic));
174 if (!strcmp(
"quit-application", aTopic ) ) {
180 nsCOMPtr<nsIObserverService> obs =
181 do_GetService(
"@mozilla.org/observer-service;1", &rv );
182 NS_ENSURE_SUCCESS( rv, rv );
183 rv = obs->RemoveObserver(
this,
"quit-application" );
184 NS_ENSURE_SUCCESS( rv, rv );
198 LOG((
"Cleared controller due to observing %s", aTopic ));
NS_IMPL_ISUPPORTS2(sbRemoteAPIService, sbIRemoteAPIService, nsIObserver) sbRemoteAPIService
nsCOMPtr< nsIURI > mPlaybackControllerURI
nsCOMArray< sbIDataRemote > mDataRemotes
_getSelectedPageStyle s i
_updateTextAndScrollDataForFrame aData