VirtualBox

Ignore:
Timestamp:
Jun 15, 2009 6:08:09 PM (16 years ago)
Author:
vboxsync
Message:

Main: implmented waitForEvents(aTimeout) API for XPCOM targets, added command to VBox shell using this API

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxShell/vboxshell.py

    r20332 r20598  
    9696            })
    9797        return out
     98
     99# Simple implementation of IConsoleCallback, one can use it as skeleton
     100# for custom implementations
     101class GuestMonitor:
     102    def __init__(self, mach):
     103        self.mach = mach
     104
     105    def onMousePointerShapeChange(self, visible, alpha, xHot, yHot, width, height, shape):
     106        print  "%s: onMousePointerShapeChange: visible=%d" %(self.mach.name, visible)
     107    def onMouseCapabilityChange(self, supportsAbsolute, needsHostCursor):
     108        print  "%s: onMouseCapabilityChange: needsHostCursor=%d" %(self.mach.name, needsHostCursor)
     109
     110    def onKeyboardLedsChange(self, numLock, capsLock, scrollLock):
     111        print  "%s: onKeyboardLedsChange capsLock=%d"  %(self.mach.name, capsLock)
     112
     113    def onStateChange(self, state):
     114        print  "%s: onStateChange state=%d" %(self.mach.name, state)
     115
     116    def onAdditionsStateChange(self):
     117        print  "%s: onAdditionsStateChange" %(self.mach.name)
     118
     119    def onDVDDriveChange(self):
     120        print  "%s: onDVDDriveChange" %(self.mach.name)
     121
     122    def onFloppyDriveChange(self):
     123        print  "%s: onFloppyDriveChange" %(self.mach.name)
     124
     125    def onNetworkAdapterChange(self, adapter):
     126        print  "%s: onNetworkAdapterChange" %(self.mach.name)
     127
     128    def onSerialPortChange(self, port):
     129        print  "%s: onSerialPortChange" %(self.mach.name)
     130
     131    def onParallelPortChange(self, port):
     132        print  "%s: onParallelPortChange" %(self.mach.name)
     133
     134    def onStorageControllerChange(self):
     135        print  "%s: onStorageControllerChange" %(self.mach.name)
     136
     137    def onVRDPServerChange(self):
     138        print  "%s: onVRDPServerChange" %(self.mach.name)
     139
     140    def onUSBControllerChange(self):
     141        print  "%s: onUSBControllerChange" %(self.mach.name)
     142
     143    def onUSBDeviceStateChange(self, device, attached, error):
     144        print  "%s: onUSBDeviceStateChange" %(self.mach.name)
     145
     146    def onSharedFolderChange(self, scope):
     147        print  "%s: onSharedFolderChange" %(self.mach.name)
     148
     149    def onRuntimeError(self, fatal, id, message):
     150        print  "%s: onRuntimeError fatal=%d message=%s" %(self.mach.name, fatal, message)
     151
     152    def onCanShowWindow(self):
     153        print  "%s: onCanShowWindow" %(self.mach.name)
     154        return true
     155
     156    def onShowWindow(self, winId):
     157        print  "%s: onShowWindow: %d" %(self.mach.name, winId)
    98158
    99159g_hasreadline = 1
     
    242302    exec cmds
    243303
     304def monitorGuest(ctx, machine, console, dur):
     305    import time
     306    cb = ctx['global'].createCallback('IConsoleCallback', GuestMonitor, machine)
     307    console.registerCallback(cb)
     308    if dur == -1:
     309        # not infinity, but close enough
     310        dur = 100000
     311    end = time.clock() + dur
     312    while  time.clock() < end:
     313        ctx['vb'].waitForEvents(100)
     314    console.unregisterCallback(cb)
     315
    244316def cmdExistingVm(ctx,mach,cmd,args):
    245317    mgr=ctx['mgr']
     
    267339         'powerdown':  lambda: console.powerDown(),
    268340         'stats':      lambda: guestStats(ctx, mach),
    269          'guest':      lambda: guestExec(ctx, mach, console, args)
     341         'guest':      lambda: guestExec(ctx, mach, console, args),
     342         'monitorGuest': lambda: monitorGuest(ctx, mach, console, args)
    270343         }
    271344    try:
     
    467540   return 0
    468541
     542
     543def monitorGuestCmd(ctx, args):
     544    if (len(args) < 2):
     545        print "usage: monitorGuest name (duration)"
     546        return 0
     547    mach = argsToMach(ctx,args)
     548    if mach == None:
     549        return 0
     550    dur = 5
     551    if len(args) > 2:
     552        dur = float(args[2])
     553    cmdExistingVm(ctx, mach, 'monitorGuest', dur)
     554    return 0
    469555
    470556def evalCmd(ctx, args):
     
    503589            'host':['Show host information', hostCmd],
    504590            'guest':['Execute command for guest: guest Win32 console.mouse.putMouseEvent(20, 20, 0, 0)', guestCmd],
     591            'monitorGuest':['Monitor what happens with the guest for some time: monitorGuest Win32 10', monitorGuestCmd],
    505592            }
    506593
     
    537624        try:
    538625            cmd = raw_input("vbox> ")
     626            vbox.waitForEvents(0)
    539627            done = runCommand(ctx, cmd)
    540628            if done != 0: break
Note: See TracChangeset for help on using the changeset viewer.

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