VirtualBox

Changeset 18998 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Apr 17, 2009 4:27:28 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
46090
Message:

cbinding: added event queues for callback support

Location:
trunk/src/VBox/Main/cbinding
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/cbinding/Makefile.kmk

    r18895 r18998  
    3434XpComCSamples_SOURCES = \
    3535        tstXPCOMCGlue.c \
     36        tstXPCOMCCall.c \
    3637        makefile.tstXPCOMCGlue=>Makefile
    3738
  • trunk/src/VBox/Main/cbinding/VBoxXPCOMC.cpp

    r18895 r18998  
    3535using namespace std;
    3636
    37 static ISession            *Session;
    38 static IVirtualBox         *Ivirtualbox;
    39 static nsIServiceManager   *serviceManager;
    40 static nsIComponentManager *manager;
     37static ISession            *Session        = NULL;
     38static IVirtualBox         *Ivirtualbox    = NULL;
     39static nsIServiceManager   *serviceManager = NULL;
     40static nsIComponentManager *manager        = NULL;
     41static nsIEventQueue       *eventQ         = NULL;
    4142
    4243static void VBoxComUninitialize(void);
     
    9899    {
    99100        Log(("Cbinding: Could not get component manager! rc=%Rhrc\n",rc));
     101        VBoxComUninitialize();
     102        return;
     103    }
     104
     105    rc = NS_GetMainEventQ (&eventQ);
     106    if (NS_FAILED(rc))
     107    {
     108        Log(("Cbinding: Could not get xpcom event queue! rc=%Rhrc\n",rc));
    100109        VBoxComUninitialize();
    101110        return;
     
    136145    if (Ivirtualbox)
    137146        NS_RELEASE(Ivirtualbox);    // decrement refcount
     147    if (eventQ)
     148        NS_RELEASE(eventQ);         // decrement refcount
    138149    if (manager)
    139150        NS_RELEASE(manager);        // decrement refcount
     
    144155}
    145156
     157static void
     158VBoxGetEventQueue(nsIEventQueue **eventQueue)
     159{
     160    *eventQueue = eventQ;
     161}
     162
    146163static uint32_t
    147164VBoxVersion(void)
     
    175192        VBoxUtf8ToUtf16,
    176193
     194        VBoxGetEventQueue,
     195
    177196        VBOX_XPCOMC_VERSION
    178197    };
  • trunk/src/VBox/Main/cbinding/makefile.tstXPCOMCGlue

    r18527 r18998  
    2828
    2929.PHONY: all
    30 all: tstXPCOMCGlue
     30all: tstXPCOMCGlue tstXPCOMCCall
    3131
    3232.PHONY: clean
    3333clean:
    34         rm -f tstXPCOMCGlue.o tstXPCOMCGlue VBoxXPCOMCGlue.o
     34        rm -f tstXPCOMCGlue.o tstXPCOMCGlue VBoxXPCOMCGlue.o tstXPCOMCCall.o tstXPCOMCCall
    3535
    3636tstXPCOMCGlue: tstXPCOMCGlue.o VBoxXPCOMCGlue.o
     
    4040        $(CC) $(CFLAGS) $(INCS_XPCOM) $(GLUE_INC) -o $@ -c $<
    4141
     42tstXPCOMCCall: tstXPCOMCCall.o VBoxXPCOMCGlue.o
     43        $(CC) -o $@ $^ -ldl -lpthread
     44
     45tstXPCOMCCall.o: tstXPCOMCCall.c
     46        $(CC) $(CFLAGS) $(INCS_XPCOM) $(GLUE_INC) -o $@ -c $<
     47
    4248VBoxXPCOMCGlue.o: $(GLUE_DIR)/VBoxXPCOMCGlue.c
    4349        $(CC) $(CFLAGS) $(INCS_XPCOM) $(GLUE_INC) -o $@ -c $<
    44 
  • trunk/src/VBox/Main/cbinding/tstXPCOMCCall.c

    r18891 r18998  
    3232
    3333static char *nsIDToString(nsID *guid);
    34 static void listVMs(IVirtualBox *virtualBox, ISession *session);
     34static void listVMs(IVirtualBox *virtualBox, ISession *session, nsIEventQueue *queue);
     35static void registerCallBack(IVirtualBox *virtualBox, ISession *session, nsID *machineId, nsIEventQueue *queue);
     36static void startVM(IVirtualBox *virtualBox, ISession *session, nsID *id, nsIEventQueue *queue);
    3537
    3638int volatile g_refcount = 0;
     
    5961}
    6062
     63/**
     64 * Callback functions
     65 */
    6166static const char *GetStateName(PRUint32 machineState)
    6267{
     
    9095    PRUint8 * shape
    9196) {
    92     printf("%d here\n",__LINE__);
     97    printf("OnMousePointerShapeChange\n");
    9398    return 0;
    9499}
     
    99104    PRBool needsHostCursor
    100105) {
    101     printf("%d here\n",__LINE__);
     106    printf("OnMouseCapabilityChange\n");
    102107    return 0;
    103108}
     
    109114    PRBool scrollLock
    110115) {
    111     printf("%d here\n",__LINE__);
     116    printf("OnMouseCapabilityChange\n");
    112117    return 0;
    113118}
     
    117122    PRUint32 state
    118123) {
    119     printf("%d here\n",__LINE__);
    120124    printf("OnStateChange: %s\n", GetStateName(state));
    121125    fflush(stdout);
     
    125129static nsresult OnAdditionsStateChange(IConsoleCallback *pThis )
    126130{
    127     printf("%d here\n",__LINE__);
     131    printf("OnAdditionsStateChange\n");
    128132    return 0;
    129133}
     
    131135static nsresult OnDVDDriveChange(IConsoleCallback *pThis )
    132136{
    133     printf("%d here\n",__LINE__);
     137    printf("OnDVDDriveChange \n");
    134138    return 0;
    135139}
     
    137141static nsresult OnFloppyDriveChange(IConsoleCallback *pThis )
    138142{
    139     printf("%d here\n",__LINE__);
     143    printf("OnFloppyDriveChange \n");
    140144    return 0;
    141145}
     
    145149    INetworkAdapter * networkAdapter
    146150) {
    147     printf("%d here\n",__LINE__);
     151    printf("OnNetworkAdapterChange\n");
    148152    return 0;
    149153}
     
    153157    ISerialPort * serialPort
    154158) {
    155     printf("%d here\n",__LINE__);
     159    printf("OnSerialPortChange\n");
    156160    return 0;
    157161}
     
    161165    IParallelPort * parallelPort
    162166) {
    163     printf("%d here\n",__LINE__);
     167    printf("OnParallelPortChange\n");
    164168    return 0;
    165169}
     
    167171static nsresult OnStorageControllerChange(IConsoleCallback *pThis )
    168172{
    169     printf("%d here\n",__LINE__);
     173    printf("OnStorageControllerChange\n");
    170174    return 0;
    171175}
     
    173177static nsresult OnVRDPServerChange(IConsoleCallback *pThis )
    174178{
    175     printf("%d here\n",__LINE__);
     179    printf("OnVRDPServerChange\n");
    176180    return 0;
    177181}
     
    179183static nsresult OnUSBControllerChange(IConsoleCallback *pThis )
    180184{
    181     printf("%d here\n",__LINE__);
     185    printf("OnUSBControllerChange\n");
    182186    return 0;
    183187}
     
    189193    IVirtualBoxErrorInfo * error
    190194) {
    191     printf("%d here\n",__LINE__);
     195    printf("OnUSBDeviceStateChange\n");
    192196    return 0;
    193197}
     
    197201    PRUint32 scope
    198202) {
    199     printf("%d here\n",__LINE__);
     203    printf("OnSharedFolderChange\n");
    200204    return 0;
    201205}
     
    207211    PRUnichar * message
    208212) {
    209     printf("%d here\n",__LINE__);
     213    printf("OnRuntimeError\n");
    210214    return 0;
    211215}
     
    215219    PRBool * canShow
    216220) {
    217     printf("%d here\n",__LINE__);
     221    printf("OnCanShowWindow\n");
    218222    return 0;
    219223}
     
    223227    PRUint64 * winId
    224228) {
    225     printf("%d here\n",__LINE__);
     229    printf("OnShowWindow\n");
    226230    return 0;
    227231}
     
    246250    {
    247251        /* delete object */
    248 #if 1 /* test */
    249252        free(pThis->vtbl);
    250253        free(pThis);
    251 #endif
    252254    }
    253255    return c;
     
    265267}
    266268
    267 static void registerCallBack(IVirtualBox *virtualBox, ISession *session, nsID *machineId)
     269/**
     270 * Register callback functions for the selected VM.
     271 *
     272 * @param   virtualBox ptr to IVirtualBox object
     273 * @param   session    ptr to ISession object
     274 * @param   id         identifies the machine to start
     275 * @param   queue      handle to the event queue
     276 */
     277static void registerCallBack(IVirtualBox *virtualBox, ISession *session, nsID *machineId, nsIEventQueue *queue)
    268278{
    269279    IConsole *console = NULL;
     
    303313            g_refcount = 1;
    304314
    305             printf("%d here\n",__LINE__);
    306315            console->vtbl->RegisterCallback(console, consoleCallback);
    307             printf("%d here\n",__LINE__);
    308316
    309317            {
    310                 int run = 10;
     318                /* crude way to show how it works, but any
     319                 * great ideas anyone?
     320                 */
     321                int run = 10000000;
    311322                while (run-- > 0) {
    312                     sleep(1);
    313                     printf("waiting here:%d\n",run);
    314                     fflush(stdout);
     323                    queue->vtbl->ProcessPendingEvents(queue);
    315324                }
    316325            }
    317326            console->vtbl->UnregisterCallback(console, consoleCallback);
    318327        }
    319         /*consoleCallback->vtbl->Release(consoleCallback);*/
     328        consoleCallback->vtbl->nsisupports.Release((nsISupports *)consoleCallback);
    320329    }
    321330    session->vtbl->Close((void *)session);
     
    327336 * @param   virtualBox ptr to IVirtualBox object
    328337 * @param   session    ptr to ISession object
     338 * @param   queue      handle to the event queue
    329339 */
    330 static void listVMs(IVirtualBox *virtualBox, ISession *session)
     340static void listVMs(IVirtualBox *virtualBox, ISession *session, nsIEventQueue *queue)
    331341{
    332342    nsresult rc;
     
    463473
    464474            machine->vtbl->GetId(machine, &iid);
    465             /*startVM(virtualBox, session, iid);*/
    466             registerCallBack(virtualBox, session, iid);
     475            startVM(virtualBox, session, iid, queue);
    467476
    468477            g_pVBoxFuncs->pfnComUnallocMem(iid);
     
    491500 * @param   session    ptr to ISession object
    492501 * @param   id         identifies the machine to start
     502 * @param   queue      handle to the event queue
    493503 */
    494 #if 0
    495 static void startVM(IVirtualBox *virtualBox, ISession *session, nsID *id)
     504
     505static void startVM(IVirtualBox *virtualBox, ISession *session, nsID *id, nsIEventQueue *queue)
    496506{
    497507    nsresult rc;
     
    558568        {
    559569            fprintf(stderr, "Remote session has been successfully opened.\n");
     570            registerCallBack(virtualBox, session, id, queue);
    560571        }
    561572        progress->vtbl->nsisupports.Release((void *)progress);
     
    565576    machine->vtbl->nsisupports.Release((void *)machine);
    566577}
    567 #endif
    568578
    569579/* Main - Start the ball rolling. */
     
    571581int main(int argc, char **argv)
    572582{
    573     IVirtualBox *vbox           = NULL;
     583    IVirtualBox *vbox            = NULL;
    574584    ISession   *session          = NULL;
     585    nsIEventQueue *queue         = NULL;
    575586    PRUint32    revision         = 0;
    576587    PRUnichar  *versionUtf16     = NULL;
     
    604615        return EXIT_FAILURE;
    605616    }
     617    g_pVBoxFuncs->pfnGetEventQueue(&queue);
     618    printf("Got the event queue: %p\n", queue);
    606619
    607620    /*
     
    660673    }
    661674
    662     listVMs(vbox, session);
     675    listVMs(vbox, session, queue);
    663676    session->vtbl->Close(session);
    664677
  • trunk/src/VBox/Main/cbinding/xpcidl.xsl

    r18821 r18998  
    388388#define NS_SUCCEEDED(_nsresult) (NS_LIKELY(!((_nsresult) &amp; 0x80000000)))
    389389
     390#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
     391# define PR_IntervalNow VBoxNsprPR_IntervalNow
     392# define PR_TicksPerSecond VBoxNsprPR_TicksPerSecond
     393# define PR_SecondsToInterval VBoxNsprPR_SecondsToInterval
     394# define PR_MillisecondsToInterval VBoxNsprPR_MillisecondsToInterval
     395# define PR_MicrosecondsToInterval VBoxNsprPR_MicrosecondsToInterval
     396# define PR_IntervalToSeconds VBoxNsprPR_IntervalToSeconds
     397# define PR_IntervalToMilliseconds VBoxNsprPR_IntervalToMilliseconds
     398# define PR_IntervalToMicroseconds VBoxNsprPR_IntervalToMicroseconds
     399# define PR_EnterMonitor VBoxNsprPR_EnterMonitor
     400# define PR_ExitMonitor VBoxNsprPR_ExitMonitor
     401# define PR_Notify VBoxNsprPR_Notify
     402# define PR_NotifyAll VBoxNsprPR_NotifyAll
     403# define PR_Wait VBoxNsprPR_Wait
     404# define PR_NewMonitor VBoxNsprPR_NewMonitor
     405# define PR_DestroyMonitor VBoxNsprPR_DestroyMonitor
     406#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
     407
     408typedef PRUint32 PRIntervalTime;
     409
     410#define PR_INTERVAL_MIN 1000UL
     411#define PR_INTERVAL_MAX 100000UL
     412#define PR_INTERVAL_NO_WAIT 0UL
     413#define PR_INTERVAL_NO_TIMEOUT 0xffffffffUL
     414
     415NSPR_API(PRIntervalTime) PR_IntervalNow(void);
     416NSPR_API(PRUint32) PR_TicksPerSecond(void);
     417NSPR_API(PRIntervalTime) PR_SecondsToInterval(PRUint32 seconds);
     418NSPR_API(PRIntervalTime) PR_MillisecondsToInterval(PRUint32 milli);
     419NSPR_API(PRIntervalTime) PR_MicrosecondsToInterval(PRUint32 micro);
     420NSPR_API(PRUint32) PR_IntervalToSeconds(PRIntervalTime ticks);
     421NSPR_API(PRUint32) PR_IntervalToMilliseconds(PRIntervalTime ticks);
     422NSPR_API(PRUint32) PR_IntervalToMicroseconds(PRIntervalTime ticks);
     423
     424typedef struct PRMonitor PRMonitor;
     425
     426NSPR_API(PRMonitor*) PR_NewMonitor(void);
     427NSPR_API(void) PR_DestroyMonitor(PRMonitor *mon);
     428NSPR_API(void) PR_EnterMonitor(PRMonitor *mon);
     429NSPR_API(PRStatus) PR_ExitMonitor(PRMonitor *mon);
     430NSPR_API(PRStatus) PR_Wait(PRMonitor *mon, PRIntervalTime ticks);
     431NSPR_API(PRStatus) PR_Notify(PRMonitor *mon);
     432NSPR_API(PRStatus) PR_NotifyAll(PRMonitor *mon);
     433
     434#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
     435# define PR_CreateThread VBoxNsprPR_CreateThread
     436# define PR_JoinThread VBoxNsprPR_JoinThread
     437# define PR_Sleep VBoxNsprPR_Sleep
     438# define PR_GetCurrentThread VBoxNsprPR_GetCurrentThread
     439# define PR_GetThreadState VBoxNsprPR_GetThreadState
     440# define PR_SetThreadPrivate VBoxNsprPR_SetThreadPrivate
     441# define PR_GetThreadPrivate VBoxNsprPR_GetThreadPrivate
     442# define PR_NewThreadPrivateIndex VBoxNsprPR_NewThreadPrivateIndex
     443# define PR_GetThreadPriority VBoxNsprPR_GetThreadPriority
     444# define PR_SetThreadPriority VBoxNsprPR_SetThreadPriority
     445# define PR_Interrupt VBoxNsprPR_Interrupt
     446# define PR_ClearInterrupt VBoxNsprPR_ClearInterrupt
     447# define PR_BlockInterrupt VBoxNsprPR_BlockInterrupt
     448# define PR_UnblockInterrupt VBoxNsprPR_UnblockInterrupt
     449# define PR_GetThreadScope VBoxNsprPR_GetThreadScope
     450# define PR_GetThreadType VBoxNsprPR_GetThreadType
     451#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
     452
     453typedef struct PRThread PRThread;
     454typedef struct PRThreadStack PRThreadStack;
     455
     456typedef enum PRThreadType {
     457    PR_USER_THREAD,
     458    PR_SYSTEM_THREAD
     459} PRThreadType;
     460
     461typedef enum PRThreadScope {
     462    PR_LOCAL_THREAD,
     463    PR_GLOBAL_THREAD,
     464    PR_GLOBAL_BOUND_THREAD
     465} PRThreadScope;
     466
     467typedef enum PRThreadState {
     468    PR_JOINABLE_THREAD,
     469    PR_UNJOINABLE_THREAD
     470} PRThreadState;
     471
     472typedef enum PRThreadPriority
     473{
     474    PR_PRIORITY_FIRST = 0,      /* just a placeholder */
     475    PR_PRIORITY_LOW = 0,        /* the lowest possible priority */
     476    PR_PRIORITY_NORMAL = 1,     /* most common expected priority */
     477    PR_PRIORITY_HIGH = 2,       /* slightly more aggressive scheduling */
     478    PR_PRIORITY_URGENT = 3,     /* it does little good to have more than one */
     479    PR_PRIORITY_LAST = 3        /* this is just a placeholder */
     480} PRThreadPriority;
     481
     482NSPR_API(PRThread*) PR_CreateThread(PRThreadType type,
     483                     void (PR_CALLBACK *start)(void *arg),
     484                     void *arg,
     485                     PRThreadPriority priority,
     486                     PRThreadScope scope,
     487                     PRThreadState state,
     488                     PRUint32 stackSize);
     489NSPR_API(PRStatus) PR_JoinThread(PRThread *thread);
     490NSPR_API(PRThread*) PR_GetCurrentThread(void);
     491#ifndef NO_NSPR_10_SUPPORT
     492#define PR_CurrentThread() PR_GetCurrentThread() /* for nspr1.0 compat. */
     493#endif /* NO_NSPR_10_SUPPORT */
     494NSPR_API(PRThreadPriority) PR_GetThreadPriority(const PRThread *thread);
     495NSPR_API(void) PR_SetThreadPriority(PRThread *thread, PRThreadPriority priority);
     496
     497typedef void (PR_CALLBACK *PRThreadPrivateDTOR)(void *priv);
     498
     499NSPR_API(PRStatus) PR_NewThreadPrivateIndex(
     500    PRUintn *newIndex, PRThreadPrivateDTOR destructor);
     501NSPR_API(PRStatus) PR_SetThreadPrivate(PRUintn tpdIndex, void *priv);
     502NSPR_API(void*) PR_GetThreadPrivate(PRUintn tpdIndex);
     503NSPR_API(PRStatus) PR_Interrupt(PRThread *thread);
     504NSPR_API(void) PR_ClearInterrupt(void);
     505NSPR_API(void) PR_BlockInterrupt(void);
     506NSPR_API(void) PR_UnblockInterrupt(void);
     507NSPR_API(PRStatus) PR_Sleep(PRIntervalTime ticks);
     508NSPR_API(PRThreadScope) PR_GetThreadScope(const PRThread *thread);
     509NSPR_API(PRThreadType) PR_GetThreadType(const PRThread *thread);
     510NSPR_API(PRThreadState) PR_GetThreadState(const PRThread *thread);
     511
     512#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
     513# define PR_DestroyLock VBoxNsprPR_DestroyLock
     514# define PR_Lock VBoxNsprPR_Lock
     515# define PR_NewLock VBoxNsprPR_NewLock
     516# define PR_Unlock VBoxNsprPR_Unlock
     517#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
     518
     519typedef struct PRLock PRLock;
     520
     521NSPR_API(PRLock*) PR_NewLock(void);
     522NSPR_API(void) PR_DestroyLock(PRLock *lock);
     523NSPR_API(void) PR_Lock(PRLock *lock);
     524NSPR_API(PRStatus) PR_Unlock(PRLock *lock);
     525
     526#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
     527# define PR_NewCondVar VBoxNsprPR_NewCondVar
     528# define PR_DestroyCondVar VBoxNsprPR_DestroyCondVar
     529# define PR_WaitCondVar VBoxNsprPR_WaitCondVar
     530# define PR_NotifyCondVar VBoxNsprPR_NotifyCondVar
     531# define PR_NotifyAllCondVar VBoxNsprPR_NotifyAllCondVar
     532#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
     533
     534typedef struct PRCondVar PRCondVar;
     535
     536NSPR_API(PRCondVar*) PR_NewCondVar(PRLock *lock);
     537NSPR_API(void) PR_DestroyCondVar(PRCondVar *cvar);
     538NSPR_API(PRStatus) PR_WaitCondVar(PRCondVar *cvar, PRIntervalTime timeout);
     539NSPR_API(PRStatus) PR_NotifyCondVar(PRCondVar *cvar);
     540NSPR_API(PRStatus) PR_NotifyAllCondVar(PRCondVar *cvar);
     541
     542typedef struct PRCListStr PRCList;
     543
     544struct PRCListStr {
     545    PRCList     *next;
     546    PRCList     *prev;
     547};
     548
     549#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
     550# define PL_DestroyEvent VBoxNsplPL_DestroyEvent
     551# define PL_HandleEvent VBoxNsplPL_HandleEvent
     552# define PL_InitEvent VBoxNsplPL_InitEvent
     553# define PL_CreateEventQueue VBoxNsplPL_CreateEventQueue
     554# define PL_CreateMonitoredEventQueue VBoxNsplPL_CreateMonitoredEventQueue
     555# define PL_CreateNativeEventQueue VBoxNsplPL_CreateNativeEventQueue
     556# define PL_DequeueEvent VBoxNsplPL_DequeueEvent
     557# define PL_DestroyEventQueue VBoxNsplPL_DestroyEventQueue
     558# define PL_EventAvailable VBoxNsplPL_EventAvailable
     559# define PL_EventLoop VBoxNsplPL_EventLoop
     560# define PL_GetEvent VBoxNsplPL_GetEvent
     561# define PL_GetEventOwner VBoxNsplPL_GetEventOwner
     562# define PL_GetEventQueueMonitor VBoxNsplPL_GetEventQueueMonitor
     563# define PL_GetEventQueueSelectFD VBoxNsplPL_GetEventQueueSelectFD
     564# define PL_MapEvents VBoxNsplPL_MapEvents
     565# define PL_PostEvent VBoxNsplPL_PostEvent
     566# define PL_PostSynchronousEvent VBoxNsplPL_PostSynchronousEvent
     567# define PL_ProcessEventsBeforeID VBoxNsplPL_ProcessEventsBeforeID
     568# define PL_ProcessPendingEvents VBoxNsplPL_ProcessPendingEvents
     569# define PL_RegisterEventIDFunc VBoxNsplPL_RegisterEventIDFunc
     570# define PL_RevokeEvents VBoxNsplPL_RevokeEvents
     571# define PL_UnregisterEventIDFunc VBoxNsplPL_UnregisterEventIDFunc
     572# define PL_WaitForEvent VBoxNsplPL_WaitForEvent
     573# define PL_IsQueueNative VBoxNsplPL_IsQueueNative
     574# define PL_IsQueueOnCurrentThread VBoxNsplPL_IsQueueOnCurrentThread
     575# define PL_FavorPerformanceHint VBoxNsplPL_FavorPerformanceHint
     576#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
     577
     578typedef struct PLEvent PLEvent;
     579typedef struct PLEventQueue PLEventQueue;
     580
     581PR_EXTERN(PLEventQueue*)
     582PL_CreateEventQueue(const char* name, PRThread* handlerThread);
     583PR_EXTERN(PLEventQueue *)
     584    PL_CreateNativeEventQueue(
     585        const char *name,
     586        PRThread *handlerThread
     587    );
     588PR_EXTERN(PLEventQueue *)
     589    PL_CreateMonitoredEventQueue(
     590        const char *name,
     591        PRThread *handlerThread
     592    );
     593PR_EXTERN(void)
     594PL_DestroyEventQueue(PLEventQueue* self);
     595PR_EXTERN(PRMonitor*)
     596PL_GetEventQueueMonitor(PLEventQueue* self);
     597
     598#define PL_ENTER_EVENT_QUEUE_MONITOR(queue)     \
     599        PR_EnterMonitor(PL_GetEventQueueMonitor(queue))
     600
     601#define PL_EXIT_EVENT_QUEUE_MONITOR(queue)      \
     602        PR_ExitMonitor(PL_GetEventQueueMonitor(queue))
     603
     604PR_EXTERN(PRStatus) PL_PostEvent(PLEventQueue* self, PLEvent* event);
     605PR_EXTERN(void*) PL_PostSynchronousEvent(PLEventQueue* self, PLEvent* event);
     606PR_EXTERN(PLEvent*) PL_GetEvent(PLEventQueue* self);
     607PR_EXTERN(PRBool) PL_EventAvailable(PLEventQueue* self);
     608
     609typedef void (PR_CALLBACK *PLEventFunProc)(PLEvent* event, void* data, PLEventQueue* queue);
     610
     611PR_EXTERN(void) PL_MapEvents(PLEventQueue* self, PLEventFunProc fun, void* data);
     612PR_EXTERN(void) PL_RevokeEvents(PLEventQueue* self, void* owner);
     613PR_EXTERN(void) PL_ProcessPendingEvents(PLEventQueue* self);
     614PR_EXTERN(PLEvent*) PL_WaitForEvent(PLEventQueue* self);
     615PR_EXTERN(void) PL_EventLoop(PLEventQueue* self);
     616PR_EXTERN(PRInt32) PL_GetEventQueueSelectFD(PLEventQueue* self);
     617PR_EXTERN(PRBool) PL_IsQueueOnCurrentThread( PLEventQueue *queue );
     618PR_EXTERN(PRBool) PL_IsQueueNative(PLEventQueue *queue);
     619
     620typedef void* (PR_CALLBACK *PLHandleEventProc)(PLEvent* self);
     621typedef void (PR_CALLBACK *PLDestroyEventProc)(PLEvent* self);
     622PR_EXTERN(void)
     623PL_InitEvent(PLEvent* self, void* owner,
     624                         PLHandleEventProc handler,
     625                         PLDestroyEventProc destructor);
     626PR_EXTERN(void*) PL_GetEventOwner(PLEvent* self);
     627PR_EXTERN(void) PL_HandleEvent(PLEvent* self);
     628PR_EXTERN(void) PL_DestroyEvent(PLEvent* self);
     629PR_EXTERN(void) PL_DequeueEvent(PLEvent* self, PLEventQueue* queue);
     630PR_EXTERN(void) PL_FavorPerformanceHint(PRBool favorPerformanceOverEventStarvation, PRUint32 starvationDelay);
     631
     632struct PLEvent {
     633    PRCList                             link;
     634    PLHandleEventProc   handler;
     635    PLDestroyEventProc  destructor;
     636    void*                               owner;
     637    void*                               synchronousResult;
     638    PRLock*             lock;
     639    PRCondVar*          condVar;
     640    PRBool              handled;
     641#ifdef PL_POST_TIMINGS
     642    PRIntervalTime      postTime;
     643#endif
     644#ifdef XP_UNIX
     645    unsigned long       id;
     646#endif /* XP_UNIX */
     647    /* other fields follow... */
     648};
     649
     650#if defined(XP_WIN) || defined(XP_OS2)
     651
     652PR_EXTERN(HWND)
     653    PL_GetNativeEventReceiverWindow(
     654        PLEventQueue *eqp
     655    );
     656#endif /* XP_WIN || XP_OS2 */
     657
     658#ifdef XP_UNIX
     659
     660PR_EXTERN(PRInt32)
     661PL_ProcessEventsBeforeID(PLEventQueue *aSelf, unsigned long aID);
     662
     663typedef unsigned long (PR_CALLBACK *PLGetEventIDFunc)(void *aClosure);
     664
     665PR_EXTERN(void)
     666PL_RegisterEventIDFunc(PLEventQueue *aSelf, PLGetEventIDFunc aFunc,
     667                       void *aClosure);
     668PR_EXTERN(void) PL_UnregisterEventIDFunc(PLEventQueue *aSelf);
     669
     670#endif /* XP_UNIX */
     671
     672
     673
    390674/**
    391675 * An "interface id" which can be used to uniquely identify a given
     
    565849};
    566850
     851/* starting interface:    nsIEventTarget */
     852#define NS_IEVENTTARGET_IID_STR "ea99ad5b-cc67-4efb-97c9-2ef620a59f2a"
     853
     854#define NS_IEVENTTARGET_IID \
     855  {0xea99ad5b, 0xcc67, 0x4efb, \
     856    { 0x97, 0xc9, 0x2e, 0xf6, 0x20, 0xa5, 0x9f, 0x2a }}
     857
     858struct nsIEventTarget;
     859typedef struct nsIEventTarget nsIEventTarget;
     860
     861struct nsIEventTarget_vtbl {
     862
     863    struct nsISupports_vtbl nsisupports;
     864
     865    nsresult (*PostEvent)(nsIEventTarget *pThis, PLEvent * aEvent);
     866
     867    nsresult (*IsOnCurrentThread)(nsIEventTarget *pThis, PRBool *_retval);
     868
     869};
     870
     871struct nsIEventTarget {
     872    struct nsIEventTarget_vtbl *vtbl;
     873};
     874
     875/* starting interface:    nsIEventQueue */
     876#define NS_IEVENTQUEUE_IID_STR "176afb41-00a4-11d3-9f2a-00400553eef0"
     877
     878#define NS_IEVENTQUEUE_IID \
     879  {0x176afb41, 0x00a4, 0x11d3, \
     880    { 0x9f, 0x2a, 0x00, 0x40, 0x05, 0x53, 0xee, 0xf0 }}
     881
     882struct nsIEventQueue;
     883typedef struct nsIEventQueue nsIEventQueue;
     884
     885struct nsIEventQueue_vtbl {
     886
     887    struct nsIEventTarget_vtbl nsieventtarget;
     888
     889    nsresult (*InitEvent)(nsIEventQueue *pThis, PLEvent * aEvent, void * owner, PLHandleEventProc handler, PLDestroyEventProc destructor);
     890
     891    nsresult (*PostSynchronousEvent)(nsIEventQueue *pThis, PLEvent * aEvent, void * *aResult);
     892
     893    nsresult (*PendingEvents)(nsIEventQueue *pThis, PRBool *_retval);
     894
     895    nsresult (*ProcessPendingEvents)(nsIEventQueue *pThis);
     896
     897    nsresult (*EventLoop)(nsIEventQueue *pThis);
     898
     899    nsresult (*EventAvailable)(nsIEventQueue *pThis, PRBool *aResult);
     900
     901    nsresult (*GetEvent)(nsIEventQueue *pThis, PLEvent * *_retval);
     902
     903    nsresult (*HandleEvent)(nsIEventQueue *pThis, PLEvent * aEvent);
     904
     905    nsresult (*WaitForEvent)(nsIEventQueue *pThis, PLEvent * *_retval);
     906
     907    PRInt32 (*GetEventQueueSelectFD)(nsIEventQueue *pThis);
     908
     909    nsresult (*Init)(nsIEventQueue *pThis, PRBool aNative);
     910
     911    nsresult (*InitFromPRThread)(nsIEventQueue *pThis, PRThread * thread, PRBool aNative);
     912
     913    nsresult (*InitFromPLQueue)(nsIEventQueue *pThis, PLEventQueue * aQueue);
     914
     915    nsresult (*EnterMonitor)(nsIEventQueue *pThis);
     916
     917    nsresult (*ExitMonitor)(nsIEventQueue *pThis);
     918
     919    nsresult (*RevokeEvents)(nsIEventQueue *pThis, void * owner);
     920
     921    nsresult (*GetPLEventQueue)(nsIEventQueue *pThis, PLEventQueue * *_retval);
     922
     923    nsresult (*IsQueueNative)(nsIEventQueue *pThis, PRBool *_retval);
     924
     925    nsresult (*StopAcceptingEvents)(nsIEventQueue *pThis);
     926
     927};
     928
     929struct nsIEventQueue {
     930    struct nsIEventQueue_vtbl *vtbl;
     931};
     932
    567933</xsl:text>
    568934 <xsl:apply-templates/>
     
    604970    int   (*pfnUtf8ToUtf16)(const char *pszString, PRUnichar **ppwszString);
    605971
     972    void  (*pfnGetEventQueue)(nsIEventQueue **eventQueue);
     973
    606974    /** Tail version, same as uVersion. */
    607975    unsigned uEndVersion;
     
    613981 * For use with VBoxGetXPCOMCFunctions and to be found in
    614982 * VBOXXPCOMC::uVersion. */
    615 #define VBOX_XPCOMC_VERSION     0x00010000U
     983#define VBOX_XPCOMC_VERSION     0x00020000U
    616984
    617985VBOXXPCOMC_DECL(PCVBOXXPCOM) VBoxGetXPCOMCFunctions(unsigned uVersion);
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette