27 #include <nsIAppStartupNotifier.h>
28 #include <nsICategoryManager.h>
29 #include <nsIGenericFactory.h>
30 #include <nsIObserverService.h>
32 #include <nsServiceManagerUtils.h>
41 static PRLogModuleInfo* gBaseScreenSaverSuppressor = nsnull;
42 #define TRACE(args) PR_LOG(gBaseScreenSaverSuppressor , PR_LOG_DEBUG, args)
43 #define LOG(args) PR_LOG(gBaseScreenSaverSuppressor , PR_LOG_WARN, args)
45 #define __FUNCTION__ __PRETTY_FUNCTION__
58 , mUserSetting(PR_FALSE)
59 , mHasUserSetting(PR_FALSE)
62 if (!gBaseScreenSaverSuppressor)
63 gBaseScreenSaverSuppressor =
64 PR_NewLogModule(
"sbBaseScreenSaverSuppressor");
75 const char* aLoaderStr,
77 const nsModuleComponentInfo *aInfo)
79 nsresult rv = NS_ERROR_UNEXPECTED;
80 nsCOMPtr<nsICategoryManager> categoryManager =
81 do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
82 NS_ENSURE_SUCCESS(rv, rv);
84 rv = categoryManager->AddCategoryEntry(APPSTARTUP_CATEGORY,
88 PR_TRUE, PR_TRUE, nsnull);
89 NS_ENSURE_SUCCESS(rv, rv);
97 nsresult rv = NS_ERROR_UNEXPECTED;
99 do_GetService(
"@mozilla.org/observer-service;1", &rv);
100 NS_ENSURE_SUCCESS(rv, rv);
102 rv = observerService->AddObserver(
this,
"xpcom-shutdown", PR_FALSE);
103 NS_ENSURE_SUCCESS(rv, rv);
114 sbBaseScreenSaverSuppressor::Suppress(PRBool aSuppress, PRInt32 *aSuppressionCount)
116 TRACE((
"[sbBaseScreenSaverSuppressor] - Suppress"));
118 nsresult rv = NS_ERROR_UNEXPECTED;
119 PRBool shouldCallOnSuppress = PR_FALSE;
123 shouldCallOnSuppress = PR_TRUE;
135 shouldCallOnSuppress = PR_TRUE;
139 if(shouldCallOnSuppress) {
141 NS_ENSURE_SUCCESS(rv, rv);
143 LOG((
"[sbBaseScreenSaverSuppressor] - OnSuppress Succeeded - Suppressed? %s",
144 aSuppress ?
"true" :
"false"));
158 sbBaseScreenSaverSuppressor::Observe(
nsISupports* aSubject,
160 const PRUnichar*
aData)
162 if(!strcmp(aTopic,
"xpcom-shutdown")) {
164 TRACE((
"[sbBaseScreenSaverSuppressor] - Observe (%s)", aTopic));
166 nsresult rv = NS_ERROR_UNEXPECTED;
168 do_GetService(
"@mozilla.org/observer-service;1", &rv);
169 NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
170 "Failed to get observer service, observer will not removed");
172 if(NS_SUCCEEDED(rv)) {
173 rv = observerService->RemoveObserver(
this,
"xpcom-shutdown");
174 NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
"Failed to remove observer");
178 NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
"Failed to unsuppress screen saver!");
static nsCOMPtr< nsIObserverService > observerService
Get/Set Screen Saver Suppression.
#define SB_BASE_SCREEN_SAVER_SUPPRESSOR_DESC
virtual ~sbBaseScreenSaverSuppressor()
static NS_METHOD RegisterSelf(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *aLoaderStr, const char *aType, const nsModuleComponentInfo *aInfo)
#define SB_BASE_SCREEN_SAVER_SUPPRESSOR_CONTRACTID
NS_IMPL_ISUPPORTS2(sbBaseScreenSaverSuppressor, sbIScreenSaverSuppressor, nsIObserver) sbBaseScreenSaverSuppressor
virtual nsresult OnSuppress(PRBool aSuppress)=0
_updateTextAndScrollDataForFrame aData