Landing unix toolkit exorcism changes. #ifdef-ed OFF for now.
git-svn-id: svn://10.0.0.236/trunk@41820 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -24,19 +24,30 @@ include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
ifdef TOOLKIT_EXORCISM
|
||||
|
||||
DIRS = $(MOZ_WIDGET_TOOLKIT)
|
||||
### XXX ### DIRS = gtk motif xlib
|
||||
### XXX ###
|
||||
### XXX ### LIBRARY_NAME = timer_s
|
||||
### XXX ###
|
||||
### XXX ### REQUIRES=xpcom
|
||||
### XXX ###
|
||||
### XXX ### CPPSRCS =\
|
||||
### XXX ### nsNewTimer.cpp \
|
||||
### XXX ### $(NULL)
|
||||
### XXX ###
|
||||
### XXX ### MKSHLIB =
|
||||
### XXX ### override NO_SHARED_LIB=1
|
||||
### XXX ### override NO_STATIC_LIB=
|
||||
DIRS = gtk motif xlib
|
||||
|
||||
LIBRARY_NAME = timer_s
|
||||
|
||||
REQUIRES=xpcom
|
||||
|
||||
CPPSRCS =\
|
||||
nsNewTimer.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS =\
|
||||
nsUnixTimerCIID.h \
|
||||
$(NULL)
|
||||
|
||||
MKSHLIB =
|
||||
override NO_SHARED_LIB=1
|
||||
override NO_STATIC_LIB=
|
||||
|
||||
else
|
||||
DIRS = $(MOZ_WIDGET_TOOLKIT)
|
||||
|
||||
endif # TOOLKIT_EXORCISM
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
@@ -24,24 +24,32 @@ include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
LIBRARY_NAME = $(TIMER_LIB_NAME)
|
||||
### XXX ### IS_COMPONENT=1
|
||||
ifdef TOOLKIT_EXORCISM
|
||||
|
||||
LIBRARY_NAME = timer_gtk
|
||||
IS_COMPONENT=1
|
||||
REQUIRES=xpcom
|
||||
|
||||
DEFINES += -D_IMPL_NS_TIMER
|
||||
CXXFLAGS += $(TK_CFLAGS)
|
||||
INCLUDES += $(TK_CFLAGS) -I$(srcdir)/..
|
||||
|
||||
CPPSRCS = \
|
||||
nsTimerGtk.cpp \
|
||||
### XXX ### nsTimerGtkFactory.cpp \
|
||||
nsTimerGtkFactory.cpp \
|
||||
$(NULL)
|
||||
|
||||
### XXX ### EXTRA_DSO_LDOPTS += $(TK_LIBS)
|
||||
EXTRA_DSO_LDOPTS += $(TK_LIBS)
|
||||
|
||||
else
|
||||
|
||||
LIBRARY_NAME = $(TIMER_LIB_NAME)
|
||||
REQUIRES = xpcom
|
||||
CXXFLAGS += $(TK_CFLAGS)
|
||||
INCLUDES += $(TK_CFLAGS) -I$(srcdir)/..
|
||||
CPPSRCS = nsTimerGtk.cpp
|
||||
MKSHLIB =
|
||||
override NO_SHARED_LIB=1
|
||||
override NO_STATIC_LIB=
|
||||
|
||||
endif # TOOLKIT_EXORCISM
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
|
||||
static NS_DEFINE_IID(kITimerIID, NS_ITIMER_IID);
|
||||
|
||||
extern "C" int NS_TimeToNextTimeout(struct timeval *aTimer);
|
||||
extern "C" void NS_ProcessTimeouts(void);
|
||||
// extern "C" int NS_TimeToNextTimeout(struct timeval *aTimer);
|
||||
// extern "C" void NS_ProcessTimeouts(void);
|
||||
|
||||
extern "C" gint nsTimerExpired(gpointer aCallData);
|
||||
|
||||
@@ -146,6 +146,7 @@ gint nsTimerExpired(gpointer aCallData)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef TOOLKIT_EXORCISM
|
||||
nsresult NS_NewTimer(nsITimer** aInstancePtrResult)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
@@ -161,8 +162,12 @@ nsresult NS_NewTimer(nsITimer** aInstancePtrResult)
|
||||
return timer->QueryInterface(kITimerIID, (void **) aInstancePtrResult);
|
||||
}
|
||||
|
||||
int NS_TimeToNextTimeout(struct timeval *aTimer) {
|
||||
int NS_TimeToNextTimeout(struct timeval *aTimer)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
void NS_ProcessTimeouts(void) {
|
||||
|
||||
void NS_ProcessTimeouts(void)
|
||||
{
|
||||
}
|
||||
#endif /* TOOLKIT_EXORCISM */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
/* -*- Mode: C++; tab-width: 2; indentT-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "nsTimerGtk.h"
|
||||
|
||||
#include "nsTimerCIID.h"
|
||||
#include "nsUnixTimerCIID.h"
|
||||
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
@@ -24,24 +24,33 @@ include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
LIBRARY_NAME = $(TIMER_LIB_NAME)
|
||||
### XXX ### IS_COMPONENT=1
|
||||
ifdef TOOLKIT_EXORCISM
|
||||
|
||||
LIBRARY_NAME = timer_motif
|
||||
IS_COMPONENT=1
|
||||
REQUIRES=xpcom
|
||||
|
||||
DEFINES += -D_IMPL_NS_TIMER
|
||||
CXXFLAGS += $(TK_CFLAGS)
|
||||
INCLUDES += $(TK_CFLAGS) -I$(srcdir)/..
|
||||
|
||||
CPPSRCS = \
|
||||
nsTimerMotif.cpp \
|
||||
### XXX ### nsTimerMotifFactory.cpp \
|
||||
nsTimerMotifFactory.cpp \
|
||||
$(NULL)
|
||||
|
||||
### XXX ### EXTRA_DSO_LDOPTS += $(TK_LIBS)
|
||||
#EXTRA_DSO_LDOPTS += $(TK_LIBS)
|
||||
EXTRA_DSO_LDOPTS += -L/usr/X11R6/lib -lXt -lX11
|
||||
|
||||
else
|
||||
|
||||
LIBRARY_NAME = $(TIMER_LIB_NAME)
|
||||
REQUIRES = xpcom
|
||||
CXXFLAGS += $(TK_CFLAGS)
|
||||
INCLUDES += $(TK_CFLAGS) -I$(srcdir)/..
|
||||
CPPSRCS = nsTimerMotif.cpp
|
||||
MKSHLIB =
|
||||
override NO_SHARED_LIB=1
|
||||
override NO_STATIC_LIB=
|
||||
|
||||
endif # TOOLKIT_EXORCISM
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
@@ -75,7 +75,7 @@ nsTimerMotif::Init(nsTimerCallbackFunc aFunc,
|
||||
mClosure = aClosure;
|
||||
// mRepeat = aRepeat;
|
||||
|
||||
InitAppContext();
|
||||
EnsureAppContext();
|
||||
|
||||
mTimerId = XtAppAddTimeOut(mAppContext,
|
||||
aDelay,
|
||||
@@ -92,7 +92,7 @@ nsTimerMotif::Init(nsITimerCallback *aCallback,
|
||||
mCallback = aCallback;
|
||||
// mRepeat = aRepeat;
|
||||
|
||||
InitAppContext();
|
||||
EnsureAppContext();
|
||||
|
||||
mTimerId = XtAppAddTimeOut(mAppContext,
|
||||
aDelay,
|
||||
@@ -105,7 +105,7 @@ nsTimerMotif::Init(nsITimerCallback *aCallback,
|
||||
nsresult
|
||||
nsTimerMotif::Init(PRUint32 aDelay)
|
||||
{
|
||||
InitAppContext();
|
||||
EnsureAppContext();
|
||||
|
||||
mDelay = aDelay;
|
||||
NS_ADDREF(this);
|
||||
@@ -129,7 +129,7 @@ void nsTimerExpired(XtPointer aCallData)
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTimerMotif::InitAppContext()
|
||||
nsTimerMotif::EnsureAppContext()
|
||||
{
|
||||
static XtAppContext gsAppContext = nsnull;
|
||||
|
||||
@@ -149,7 +149,7 @@ nsTimerMotif::InitAppContext()
|
||||
|
||||
if (ac_service)
|
||||
{
|
||||
printf("nsTimerMotif::InitAppContext() ac_service = %p\n",ac_service);
|
||||
printf("nsTimerMotif::EnsureAppContext() ac_service = %p\n",ac_service);
|
||||
|
||||
nsresult rv2 = ac_service->GetAppContext(&gsAppContext);
|
||||
|
||||
@@ -159,7 +159,7 @@ nsTimerMotif::InitAppContext()
|
||||
|
||||
NS_RELEASE(ac_service);
|
||||
|
||||
printf("nsTimerMotif::InitAppContext() gsAppContext = %p\n",gsAppContext);
|
||||
printf("nsTimerMotif::EnsureAppContext() gsAppContext = %p\n",gsAppContext);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,6 +168,7 @@ nsTimerMotif::InitAppContext()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifndef TOOLKIT_EXORCISM
|
||||
nsresult NS_NewTimer(nsITimer** aInstancePtrResult)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
@@ -182,3 +183,4 @@ nsresult NS_NewTimer(nsITimer** aInstancePtrResult)
|
||||
|
||||
return timer->QueryInterface(kITimerIID, (void **) aInstancePtrResult);
|
||||
}
|
||||
#endif /* TOOLKIT_EXORCISM */
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
|
||||
private:
|
||||
nsresult Init(PRUint32 aDelay);
|
||||
nsresult InitAppContext();
|
||||
nsresult EnsureAppContext();
|
||||
|
||||
PRUint32 mDelay;
|
||||
nsTimerCallbackFunc mFunc;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "nsTimerMotif.h"
|
||||
|
||||
#include "nsTimerCIID.h"
|
||||
#include "nsUnixTimerCIID.h"
|
||||
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
#include "nsITimer.h"
|
||||
#include "nsUnixTimerCIID.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIUnixToolkitService.h"
|
||||
|
||||
#include "nsCRT.h"
|
||||
#include "prenv.h"
|
||||
|
||||
@@ -51,7 +53,7 @@ static nsresult NewTimer(const nsCID & aClass,nsITimer ** aInstancePtrResult)
|
||||
|
||||
rv = nsComponentManager::CreateInstance(aClass,
|
||||
nsnull,
|
||||
nsITimer::GetIID(),
|
||||
kITimerIID,
|
||||
(void **)& timer);
|
||||
|
||||
|
||||
@@ -72,126 +74,48 @@ static nsresult NewTimer(const nsCID & aClass,nsITimer ** aInstancePtrResult)
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), (const char *) nsAutoCString(message));
|
||||
#endif
|
||||
|
||||
|
||||
if (nsnull == timer)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return timer->QueryInterface(kITimerIID, (void **) aInstancePtrResult);
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
static nsAutoString GetToolkitName()
|
||||
static const nsCID *
|
||||
GetTimerCID()
|
||||
{
|
||||
static const char * sMozillaToolkit = nsnull;
|
||||
static PRBool sFirstTime = PR_TRUE;
|
||||
static const nsCID * sgTimerCID = nsnull;
|
||||
|
||||
// Execute the following code only once.
|
||||
if ((nsnull == sMozillaToolkit) && !sFirstTime)
|
||||
static NS_DEFINE_CID(kCUnixToolkitServiceCID, NS_UNIX_TOOLKIT_SERVICE_CID);
|
||||
|
||||
// For obvious efficiency reasons, do this only once
|
||||
if (nsnull == sgTimerCID)
|
||||
{
|
||||
sFirstTime = PR_FALSE;
|
||||
nsIUnixToolkitService * unixToolkitService = nsnull;
|
||||
|
||||
// Look in the invironment for MOZ_TOOLKIT. A variable
|
||||
// that controls the toolkit the user wants to use.
|
||||
sMozillaToolkit = PR_GetEnv("MOZ_TOOLKIT");
|
||||
nsresult rv =
|
||||
nsComponentManager::CreateInstance(kCUnixToolkitServiceCID,
|
||||
nsnull,
|
||||
nsIUnixToolkitService::GetIID(),
|
||||
(void **) &unixToolkitService);
|
||||
|
||||
NS_ASSERTION(rv == NS_OK,"Cannot obtain unix toolkit service.");
|
||||
|
||||
if (NS_OK == rv && nsnull != unixToolkitService)
|
||||
{
|
||||
nsresult rv2;
|
||||
|
||||
// If MOZ_TOOLKIT is not set, assume gtk
|
||||
if (!sMozillaToolkit)
|
||||
return nsAutoString("gtk");
|
||||
|
||||
// Gtk
|
||||
if (nsCRT::strcasecmp(sMozillaToolkit,"gtk") == 0)
|
||||
return nsAutoString("gtk");
|
||||
|
||||
// Motif
|
||||
if (nsCRT::strcasecmp(sMozillaToolkit,"motif") == 0)
|
||||
return nsAutoString("motif");
|
||||
|
||||
// Xlib
|
||||
if (nsCRT::strcasecmp(sMozillaToolkit,"xlib") == 0)
|
||||
return nsAutoString("xlib");
|
||||
rv2 = unixToolkitService->GetTimerCID((nsCID **) &sgTimerCID);
|
||||
|
||||
NS_ASSERTION(rv2 == NS_OK,"Cannot get timer cid.");
|
||||
|
||||
NS_RELEASE(unixToolkitService);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
printf("Toolkit '%s' is unknown. Assumming Gtk.\n",sMozillaToolkit);
|
||||
#endif
|
||||
|
||||
return nsAutoString("gtk");
|
||||
return sgTimerCID;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
static const nsCID * GetTimerCID()
|
||||
{
|
||||
static const char * sMozillaToolkit = nsnull;
|
||||
static const nsCID * sTimerClassID = 0;
|
||||
static PRBool sDone = PR_FALSE;
|
||||
|
||||
// The following code should execute only once. If the environment
|
||||
// variable is not set, then 'sMozillaToolkit' will still be null
|
||||
// in the second iteration. So, we use the sDone flag to make
|
||||
// sure it executes only once.
|
||||
if ((nsnull == sMozillaToolkit) && !sDone)
|
||||
{
|
||||
sDone = PR_TRUE;
|
||||
|
||||
// Look in the invironment for MOZ_TOOLKIT. A variable
|
||||
// that controls the toolkit the user wants to use.
|
||||
sMozillaToolkit = PR_GetEnv("MOZ_TOOLKIT");
|
||||
|
||||
// If MOZ_TOOLKIT is not set, assume gtk
|
||||
if (!sMozillaToolkit)
|
||||
{
|
||||
sTimerClassID = &kCTimerGtk;
|
||||
#ifdef DEBUG_ramiro
|
||||
sToolkitName = "gtk";
|
||||
#endif
|
||||
}
|
||||
// Otherwise check MOZ_TOOLKIT for the toolkit name
|
||||
else
|
||||
{
|
||||
// Gtk
|
||||
if (nsCRT::strcasecmp(sMozillaToolkit,"gtk") == 0)
|
||||
{
|
||||
sTimerClassID = &kCTimerGtk;
|
||||
#ifdef DEBUG_ramiro
|
||||
sToolkitName = "gtk";
|
||||
#endif
|
||||
}
|
||||
// Motif
|
||||
else if (nsCRT::strcasecmp(sMozillaToolkit,"motif") == 0)
|
||||
{
|
||||
sTimerClassID = &kCTimerMotif;
|
||||
#ifdef DEBUG_ramiro
|
||||
sToolkitName = "motif";
|
||||
#endif
|
||||
}
|
||||
// Xlib
|
||||
else if (nsCRT::strcasecmp(sMozillaToolkit,"xlib") == 0)
|
||||
{
|
||||
sTimerClassID = &kCTimerXlib;
|
||||
#ifdef DEBUG_ramiro
|
||||
sToolkitName = "xlib";
|
||||
#endif
|
||||
}
|
||||
// Default to Gtk
|
||||
else
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
printf("Toolkit '%s' is unknown. Assumming Gtk.\n",
|
||||
sMozillaToolkit);
|
||||
#endif
|
||||
|
||||
sTimerClassID = &kCTimerGtk;
|
||||
#ifdef DEBUG_ramiro
|
||||
sToolkitName = "gtk";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_ramiro
|
||||
printf("NS_NewTimer() - Using '%s' for the X toolkit.\n",
|
||||
sMozillaToolkit);
|
||||
#endif
|
||||
}
|
||||
|
||||
return sTimerClassID;
|
||||
}
|
||||
|
||||
static PRTime sStartTime = 0;
|
||||
static PRTime sEndTime = 0;
|
||||
@@ -204,8 +128,6 @@ nsresult NS_NewTimer(nsITimer ** aInstancePtrResult)
|
||||
|
||||
NS_ASSERTION(nsnull != cid,"Dude! Trying to make a timer with a null CID.");
|
||||
|
||||
// printf("NS_NewTimer(%s)\n",(const char *) nsAutoCString(GetToolkitName()));
|
||||
|
||||
nsresult rv = NewTimer(*cid,aInstancePtrResult);
|
||||
|
||||
sEndTime = PR_Now();
|
||||
|
||||
@@ -21,18 +21,19 @@
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
// {90F55E53-40EB-11d3-B219-000064657374}
|
||||
// {48B62AD1-48D3-11d3-B224-000064657374}
|
||||
#define NS_TIMER_MOTIF_CID \
|
||||
{ 0x90f55e53, 0x40eb, 0x11d3, \
|
||||
{ 0xb2, 0x19, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
|
||||
{ 0x48b62ad1, 0x48d3, 0x11d3, \
|
||||
{ 0xb2, 0x24, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
|
||||
|
||||
// {90F55E54-40EB-11d3-B219-000064657374}
|
||||
// {48B62AD2-48D3-11d3-B224-000064657374}
|
||||
#define NS_TIMER_GTK_CID \
|
||||
{ 0x90f55e54, 0x40eb, 0x11d3, \
|
||||
{ 0xb2, 0x19, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
|
||||
{ 0x48b62ad2, 0x48d3, 0x11d3, \
|
||||
{ 0xb2, 0x24, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
|
||||
|
||||
// {90F55E57-40EB-11d3-B219-000064657374}
|
||||
// {48B62AD3-48D3-11d3-B224-000064657374}
|
||||
#define NS_TIMER_XLIB_CID \
|
||||
{ 0x90f55e57, 0x40eb, 0x11d3, \
|
||||
{ 0xb2, 0x19, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
|
||||
{ 0x48b62ad3, 0x48d3, 0x11d3,
|
||||
{ 0xb2, 0x24, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
|
||||
|
||||
#endif // nsUnixTimerCIID_h__
|
||||
|
||||
@@ -24,24 +24,33 @@ include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
LIBRARY_NAME = $(TIMER_LIB_NAME)
|
||||
### XXX ### IS_COMPONENT=1
|
||||
ifdef TOOLKIT_EXORCISM
|
||||
|
||||
LIBRARY_NAME = timer_xlib
|
||||
IS_COMPONENT=1
|
||||
REQUIRES=xpcom
|
||||
|
||||
DEFINES += -D_IMPL_NS_TIMER
|
||||
CXXFLAGS += $(TK_CFLAGS)
|
||||
INCLUDES += $(TK_CFLAGS) -I$(srcdir)/..
|
||||
|
||||
CPPSRCS = \
|
||||
nsTimerXlib.cpp \
|
||||
### XXX ### nsTimerXlibFactory.cpp \
|
||||
nsTimerXlibFactory.cpp \
|
||||
$(NULL)
|
||||
|
||||
### XXX ### EXTRA_DSO_LDOPTS += $(TK_LIBS)
|
||||
#EXTRA_DSO_LDOPTS += $(TK_LIBS)
|
||||
EXTRA_DSO_LDOPTS += -L/usr/X11R6/lib -lX11
|
||||
|
||||
else
|
||||
|
||||
LIBRARY_NAME = $(TIMER_LIB_NAME)
|
||||
REQUIRES = xpcom
|
||||
CXXFLAGS += $(TK_CFLAGS)
|
||||
INCLUDES += $(TK_CFLAGS) -I$(srcdir)/..
|
||||
CPPSRCS = nsTimerXlib.cpp
|
||||
MKSHLIB =
|
||||
override NO_SHARED_LIB=1
|
||||
override NO_STATIC_LIB=
|
||||
|
||||
endif # TOOLKIT_EXORCISM
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
@@ -18,6 +18,11 @@
|
||||
|
||||
#include "nsTimerXlib.h"
|
||||
|
||||
#ifdef TOOLKIT_EXORCISM
|
||||
#include "nsIXlibWindowService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#endif /* TOOLKIT_EXORCISM */
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -25,8 +30,13 @@
|
||||
|
||||
static NS_DEFINE_IID(kITimerIID, NS_ITIMER_IID);
|
||||
|
||||
#ifdef TOOLKIT_EXORCISM
|
||||
static int NS_TimeToNextTimeout(struct timeval *aTimer);
|
||||
static void NS_ProcessTimeouts(void);
|
||||
#else
|
||||
extern "C" int NS_TimeToNextTimeout(struct timeval *aTimer);
|
||||
extern "C" void NS_ProcessTimeouts(void);
|
||||
#endif /* TOOLKIT_EXORCISM */
|
||||
|
||||
nsTimerXlib *nsTimerXlib::gTimerList = NULL;
|
||||
struct timeval nsTimerXlib::gTimer = {0, 0};
|
||||
@@ -117,6 +127,9 @@ nsTimerXlib::Init(PRUint32 aDelay)
|
||||
}
|
||||
}
|
||||
NS_ADDREF(this);
|
||||
|
||||
EnsureWindowService();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -200,7 +213,53 @@ nsTimerXlib::ProcessTimeouts(struct timeval *aNow)
|
||||
}
|
||||
}
|
||||
|
||||
int NS_TimeToNextTimeout(struct timeval *aTimer) {
|
||||
#ifdef TOOLKIT_EXORCISM
|
||||
static NS_DEFINE_IID(kWindowServiceCID,NS_XLIB_WINDOW_SERVICE_CID);
|
||||
static NS_DEFINE_IID(kWindowServiceIID,NS_XLIB_WINDOW_SERVICE_IID);
|
||||
#endif /* TOOLKIT_EXORCISM */
|
||||
|
||||
nsresult
|
||||
nsTimerXlib::EnsureWindowService()
|
||||
{
|
||||
#ifdef TOOLKIT_EXORCISM
|
||||
nsIXlibWindowService * xlibWindowService = nsnull;
|
||||
|
||||
nsresult rv = nsServiceManager::GetService(kWindowServiceCID,
|
||||
kWindowServiceIID,
|
||||
(nsISupports **)&xlibWindowService);
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv),"Couldn't obtain window service.");
|
||||
|
||||
if (NS_OK == rv && nsnull != xlibWindowService)
|
||||
{
|
||||
xlibWindowService->SetTimeToNextTimeoutFunc(NS_TimeToNextTimeout);
|
||||
xlibWindowService->SetProcessTimeoutsProc(NS_ProcessTimeouts);
|
||||
|
||||
NS_RELEASE(xlibWindowService);
|
||||
}
|
||||
#endif /* TOOLKIT_EXORCISM */
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef TOOLKIT_EXORCISM
|
||||
static
|
||||
#else
|
||||
extern "C"
|
||||
#endif /* TOOLKIT_EXORCISM */
|
||||
int NS_TimeToNextTimeout(struct timeval *aTimer)
|
||||
{
|
||||
#ifdef TOOLKIT_EXORCISM
|
||||
static int once = 1;
|
||||
|
||||
if (once)
|
||||
{
|
||||
once = 0;
|
||||
|
||||
printf("NS_TimeToNextTimeout() lives!\n");
|
||||
}
|
||||
#endif /* TOOLKIT_EXORCISM */
|
||||
|
||||
nsTimerXlib *timer;
|
||||
timer = nsTimerXlib::gTimerList;
|
||||
if (timer) {
|
||||
@@ -231,24 +290,44 @@ int NS_TimeToNextTimeout(struct timeval *aTimer) {
|
||||
}
|
||||
}
|
||||
|
||||
void NS_ProcessTimeouts(void) {
|
||||
#ifdef TOOLKIT_EXORCISM
|
||||
static
|
||||
#else
|
||||
extern "C"
|
||||
#endif /* TOOLKIT_EXORCISM */
|
||||
void
|
||||
NS_ProcessTimeouts(void)
|
||||
{
|
||||
#ifdef TOOLKIT_EXORCISM
|
||||
static int once = 1;
|
||||
|
||||
if (once)
|
||||
{
|
||||
once = 0;
|
||||
|
||||
printf("NS_ProcessTimeouts() lives!\n");
|
||||
}
|
||||
#endif /* TOOLKIT_EXORCISM */
|
||||
|
||||
struct timeval now;
|
||||
now.tv_sec = 0;
|
||||
now.tv_usec = 0;
|
||||
nsTimerXlib::ProcessTimeouts(&now);
|
||||
}
|
||||
|
||||
#ifndef TOOLKIT_EXORCISM
|
||||
nsresult NS_NewTimer(nsITimer** aInstancePtrResult)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
nsTimerXlib *timer = new nsTimerXlib();
|
||||
if (nsnull == timer) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return timer->QueryInterface(kITimerIID, (void **) aInstancePtrResult);
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
nsTimerXlib *timer = new nsTimerXlib();
|
||||
if (nsnull == timer) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return timer->QueryInterface(kITimerIID, (void **) aInstancePtrResult);
|
||||
}
|
||||
#endif /* TOOLKIT_EXORCISM */
|
||||
|
||||
@@ -57,6 +57,7 @@ public:
|
||||
|
||||
private:
|
||||
nsresult Init(PRUint32 aDelay);
|
||||
nsresult EnsureWindowService();
|
||||
|
||||
nsTimerCallbackFunc mFunc;
|
||||
void * mClosure;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "nsTimerXlib.h"
|
||||
|
||||
#include "nsTimerCIID.h"
|
||||
#include "nsUnixTimerCIID.h"
|
||||
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
Reference in New Issue
Block a user