Changeset 46478 in vbox
- Timestamp:
- Jun 10, 2013 4:31:35 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/manual/en_US/SDKRef.xml
r45816 r46478 3448 3448 SOAP case it's possible to create several VirtualBoxManager instances to 3449 3449 communicate with multiple VirtualBox hosts. <programlisting> 3450 import org.virtualbox_ 3_3.*;3450 import org.virtualbox_4_3.*; 3451 3451 .... 3452 3452 VirtualBoxManager mgr = VirtualBoxManager.createInstance(null); … … 3473 3473 </programlisting> For more a complete example, see 3474 3474 <computeroutput>TestVBox.java</computeroutput>, shipped with the 3475 SDK.</para> 3475 SDK. It contains exception handling and error printing code, which 3476 is important for reliable larger scale projects.</para> 3476 3477 </sect1> 3477 3478 </chapter> -
trunk/src/VBox/Frontends/VBoxShell/vboxshell.py
r44649 r46478 2 2 3 3 """ 4 Copyright (C) 2009-201 2Oracle Corporation4 Copyright (C) 2009-2013 Oracle Corporation 5 5 6 6 This file is part of VirtualBox Open Source Edition (OSE), as … … 26 26 ################################################################################ 27 27 28 import os, sys28 import os, sys 29 29 import traceback 30 30 import shlex … … 33 33 import platform 34 34 from optparse import OptionParser 35 36 g_batchmode = False 37 g_scripfile = None 38 g_cmd = None 39 g_hasreadline = True 35 from pprint import pprint 36 37 g_fBatchMode = False 38 g_sScriptFile = None 39 g_sCmd = None 40 g_fHasReadline = True 40 41 try: 41 if g_hasreadline: 42 import readline 43 import rlcompleter 44 except: 45 g_hasreadline = False 46 47 48 g_prompt = "vbox> " 49 50 g_hascolors = True 51 term_colors = { 42 import readline 43 import rlcompleter 44 except ImportError: 45 g_fHasReadline = False 46 47 g_sPrompt = "vbox> " 48 49 g_fHasColors = True 50 g_aTermColors = { 52 51 'red':'\033[31m', 53 52 'blue':'\033[94m', … … 57 56 'cyan':'\033[36m' 58 57 } 59 def colored(string,color): 60 if not g_hascolors: 61 return string 62 global term_colors 63 col = term_colors.get(color,None) 58 def colored(strg, color): 59 """ 60 Translates a string to one including coloring settings, if enabled. 61 """ 62 if not g_fHasColors: 63 return strg 64 col = g_aTermColors.get(color, None) 64 65 if col: 65 return col+str(string)+'\033[0m' 66 else: 67 return string 68 69 if g_hasreadline: 70 import string 71 class CompleterNG(rlcompleter.Completer): 72 def __init__(self, dic, ctx): 73 self.ctx = ctx 74 return rlcompleter.Completer.__init__(self,dic) 75 76 def complete(self, text, state): 77 """ 78 taken from: 79 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496812 80 """ 81 if False and text == "": 82 return ['\t',None][state] 83 else: 84 return rlcompleter.Completer.complete(self,text,state) 85 86 def canBePath(self, phrase,word): 87 return word.startswith('/') 88 89 def canBeCommand(self, phrase, word): 90 spaceIdx = phrase.find(" ") 91 begIdx = readline.get_begidx() 92 firstWord = (spaceIdx == -1 or begIdx < spaceIdx) 93 if firstWord: 94 return True 95 if phrase.startswith('help'): 96 return True 97 return False 98 99 def canBeMachine(self,phrase,word): 100 return not self.canBePath(phrase,word) and not self.canBeCommand(phrase, word) 101 102 def global_matches(self, text): 103 """ 104 Compute matches when text is a simple name. 105 Return a list of all names currently defined 106 in self.namespace that match. 107 """ 108 109 matches = [] 110 phrase = readline.get_line_buffer() 111 112 try: 113 if self.canBePath(phrase,text): 114 (dir,rest) = os.path.split(text) 115 n = len(rest) 116 for word in os.listdir(dir): 117 if n == 0 or word[:n] == rest: 118 matches.append(os.path.join(dir,word)) 119 120 if self.canBeCommand(phrase,text): 121 n = len(text) 122 for list in [ self.namespace ]: 123 for word in list: 124 if word[:n] == text: 66 return col+str(strg)+'\033[0m' 67 else: 68 return strg 69 70 if g_fHasReadline: 71 class CompleterNG(rlcompleter.Completer): 72 def __init__(self, dic, ctx): 73 self.ctx = ctx 74 rlcompleter.Completer.__init__(self, dic) 75 76 def complete(self, text, state): 77 """ 78 taken from: 79 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496812 80 """ 81 if False and text == "": 82 return ['\t', None][state] 83 else: 84 return rlcompleter.Completer.complete(self, text, state) 85 86 def canBePath(self, _phrase, word): 87 return word.startswith('/') 88 89 def canBeCommand(self, phrase, _word): 90 spaceIdx = phrase.find(" ") 91 begIdx = readline.get_begidx() 92 firstWord = (spaceIdx == -1 or begIdx < spaceIdx) 93 if firstWord: 94 return True 95 if phrase.startswith('help'): 96 return True 97 return False 98 99 def canBeMachine(self, phrase, word): 100 return not self.canBePath(phrase, word) and not self.canBeCommand(phrase, word) 101 102 def global_matches(self, text): 103 """ 104 Compute matches when text is a simple name. 105 Return a list of all names currently defined 106 in self.namespace that match. 107 """ 108 109 matches = [] 110 phrase = readline.get_line_buffer() 111 112 try: 113 if self.canBePath(phrase, text): 114 (directory, rest) = os.path.split(text) 115 c = len(rest) 116 for word in os.listdir(directory): 117 if c == 0 or word[:c] == rest: 118 matches.append(os.path.join(directory, word)) 119 120 if self.canBeCommand(phrase, text): 121 c = len(text) 122 for lst in [ self.namespace ]: 123 for word in lst: 124 if word[:c] == text: 125 matches.append(word) 126 127 if self.canBeMachine(phrase, text): 128 c = len(text) 129 for mach in getMachines(self.ctx, False, True): 130 # although it has autoconversion, we need to cast 131 # explicitly for subscripts to work 132 word = re.sub("(?<!\\\\) ", "\\ ", str(mach.name)) 133 if word[:c] == text: 125 134 matches.append(word) 126 127 if self.canBeMachine(phrase,text): 128 n = len(text) 129 for m in getMachines(self.ctx, False, True): 130 # although it has autoconversion, we need to cast 131 # explicitly for subscripts to work 132 word = re.sub("(?<!\\\\) ", "\\ ", str(m.name)) 133 if word[:n] == text: 134 matches.append(word) 135 word = str(m.id) 136 if word[:n] == text: 137 matches.append(word) 138 139 except Exception,e: 140 printErr(e) 141 if g_verbose: 142 traceback.print_exc() 143 144 return matches 145 146 def autoCompletion(commands, ctx): 147 if not g_hasreadline: 148 return 149 150 comps = {} 151 for (k,v) in commands.items(): 152 comps[k] = None 153 completer = CompleterNG(comps, ctx) 154 readline.set_completer(completer.complete) 155 delims = readline.get_completer_delims() 156 readline.set_completer_delims(re.sub("[\\./-]", "", delims)) # remove some of the delimiters 157 readline.parse_and_bind("set editing-mode emacs") 158 # OSX need it 159 if platform.system() == 'Darwin': 160 # see http://www.certif.com/spec_help/readline.html 161 readline.parse_and_bind ("bind ^I rl_complete") 162 readline.parse_and_bind ("bind ^W ed-delete-prev-word") 163 # Doesn't work well 164 # readline.parse_and_bind ("bind ^R em-inc-search-prev") 165 readline.parse_and_bind("tab: complete") 166 167 168 g_verbose = False 135 word = str(mach.id) 136 if word[:c] == text: 137 matches.append(word) 138 139 except Exception, e: 140 printErr(self.ctx, e) 141 if g_fVerbose: 142 traceback.print_exc() 143 144 return matches 145 146 def autoCompletion(cmds, ctx): 147 if not g_fHasReadline: 148 return 149 150 comps = {} 151 for (key, _value) in cmds.items(): 152 comps[key] = None 153 completer = CompleterNG(comps, ctx) 154 readline.set_completer(completer.complete) 155 delims = readline.get_completer_delims() 156 readline.set_completer_delims(re.sub("[\\./-]", "", delims)) # remove some of the delimiters 157 readline.parse_and_bind("set editing-mode emacs") 158 # OSX need it 159 if platform.system() == 'Darwin': 160 # see http://www.certif.com/spec_help/readline.html 161 readline.parse_and_bind ("bind ^I rl_complete") 162 readline.parse_and_bind ("bind ^W ed-delete-prev-word") 163 # Doesn't work well 164 # readline.parse_and_bind ("bind ^R em-inc-search-prev") 165 readline.parse_and_bind("tab: complete") 166 167 168 g_fVerbose = False 169 169 170 170 def split_no_quotes(s): 171 171 return shlex.split(s) 172 172 173 def progressBar(ctx, p,wait=1000):173 def progressBar(ctx, progress, wait=1000): 174 174 try: 175 while not p .completed:176 print "%s %%\r" % (colored(str(p.percent),'red')),175 while not progress.completed: 176 print "%s %%\r" % (colored(str(progress.percent), 'red')), 177 177 sys.stdout.flush() 178 p .waitForCompletion(wait)178 progress.waitForCompletion(wait) 179 179 ctx['global'].waitForEvents(0) 180 if int(p .resultCode) != 0:181 reportError(ctx, p )180 if int(progress.resultCode) != 0: 181 reportError(ctx, progress) 182 182 return 1 183 183 except KeyboardInterrupt: 184 184 print "Interrupted." 185 185 ctx['interrupt'] = True 186 if p .cancelable:186 if progress.cancelable: 187 187 print "Canceling task..." 188 p.cancel() 189 return 0 190 191 def printErr(ctx,e): 192 print colored(str(e), 'red') 193 194 def reportError(ctx,progress): 195 ei = progress.errorInfo 196 if ei: 197 print colored("Error in module '%s': %s" %(ei.component, ei.text), 'red') 198 199 def colCat(ctx,str): 200 return colored(str, 'magenta') 201 202 def colVm(ctx,vm): 203 return colored(vm, 'blue') 204 205 def colPath(ctx,p): 206 return colored(p, 'green') 207 208 def colSize(ctx,m): 209 return colored(m, 'red') 210 211 def colPci(ctx,vm): 212 return colored(vm, 'green') 213 214 def colDev(ctx,vm): 215 return colored(vm, 'cyan') 216 217 def colSizeM(ctx,m): 218 return colored(str(m)+'M', 'red') 219 220 def createVm(ctx,name,kind): 221 mgr = ctx['mgr'] 222 vb = ctx['vb'] 223 mach = vb.createMachine("", name, [], kind, "") 188 progress.cancel() 189 return 0 190 191 def printErr(_ctx, e): 192 print colored(str(e), 'red') 193 194 def reportError(_ctx, progress): 195 errorinfo = progress.errorInfo 196 if errorinfo: 197 print colored("Error in module '%s': %s" % (errorinfo.component, errorinfo.text), 'red') 198 199 def colCat(_ctx, strg): 200 return colored(strg, 'magenta') 201 202 def colVm(_ctx, vmname): 203 return colored(vmname, 'blue') 204 205 def colPath(_ctx, path): 206 return colored(path, 'green') 207 208 def colSize(_ctx, byte): 209 return colored(byte, 'red') 210 211 def colPci(_ctx, pcidev): 212 return colored(pcidev, 'green') 213 214 def colDev(_ctx, pcidev): 215 return colored(pcidev, 'cyan') 216 217 def colSizeM(_ctx, mbyte): 218 return colored(str(mbyte)+'M', 'red') 219 220 def createVm(ctx, name, kind): 221 vbox = ctx['vb'] 222 mach = vbox.createMachine("", name, [], kind, "") 224 223 mach.saveSettings() 225 print "created machine with UUID", mach.id226 vb .registerMachine(mach)224 print "created machine with UUID", mach.id 225 vbox.registerMachine(mach) 227 226 # update cache 228 227 getMachines(ctx, True) 229 228 230 def removeVm(ctx,mach): 231 mgr = ctx['mgr'] 232 vb = ctx['vb'] 233 id = mach.id 234 print "removing machine ",mach.name,"with UUID",id 229 def removeVm(ctx, mach): 230 uuid = mach.id 231 print "removing machine ", mach.name, "with UUID", uuid 235 232 cmdClosedVm(ctx, mach, detachVmDevice, ["ALL"]) 236 233 mach = mach.unregister(ctx['global'].constants.CleanupMode_Full) 237 234 if mach: 238 235 mach.deleteSettings() 239 236 # update cache 240 237 getMachines(ctx, True) 241 238 242 def startVm(ctx, mach,type):239 def startVm(ctx, mach, vmtype): 243 240 mgr = ctx['mgr'] 244 vb = ctx['vb']241 vbox = ctx['vb'] 245 242 perf = ctx['perf'] 246 session = mgr.getSessionObject(vb )247 progress = mach.launchVMProcess(session, type, "")243 session = mgr.getSessionObject(vbox) 244 progress = mach.launchVMProcess(session, vmtype, "") 248 245 if progressBar(ctx, progress, 100) and int(progress.resultCode) == 0: 249 246 # we ignore exceptions to allow starting VM even if 250 247 # perf collector cannot be started 251 248 if perf: 252 try:253 perf.setup(['*'], [mach], 10, 15)254 except Exception,e:255 printErr(ctx, e)256 if g_verbose:257 traceback.print_exc()249 try: 250 perf.setup(['*'], [mach], 10, 15) 251 except Exception, e: 252 printErr(ctx, e) 253 if g_fVerbose: 254 traceback.print_exc() 258 255 session.unlockMachine() 259 256 260 257 class CachedMach: 261 def __init__(self, mach): 258 def __init__(self, mach): 259 if mach.accessible: 262 260 self.name = mach.name 263 self.id = mach.id 264 265 def cacheMachines(ctx,list): 261 else: 262 self.name = '<inaccessible>' 263 self.id = mach.id 264 265 def cacheMachines(_ctx, lst): 266 266 result = [] 267 for m in list: 268 try: 269 elem = CachedMach(m) 270 result.append(elem) 271 except: 272 pass 267 for mach in lst: 268 elem = CachedMach(mach) 269 result.append(elem) 273 270 return result 274 271 … … 277 274 if ctx['_machlist'] is None or invalidate: 278 275 ctx['_machlist'] = ctx['global'].getArray(ctx['vb'], 'machines') 279 ctx['_machlistsimple'] = cacheMachines(ctx, ctx['_machlist'])276 ctx['_machlistsimple'] = cacheMachines(ctx, ctx['_machlist']) 280 277 if simple: 281 278 return ctx['_machlistsimple'] … … 298 295 299 296 def getFacilityStatus(ctx, guest, facilityType): 300 (status, ts) = guest.getFacilityStatus(facilityType)297 (status, _timestamp) = guest.getFacilityStatus(facilityType) 301 298 return asEnumElem(ctx, 'AdditionsFacilityStatus', status) 302 299 … … 310 307 exec cmds 311 308 312 def printMouseEvent( ctx, mev):313 print "Mouse : absolute=%d x=%d y=%d z=%d buttons=%x" % (mev.absolute, mev.x, mev.y, mev.z, mev.buttons)309 def printMouseEvent(_ctx, mev): 310 print "Mouse : absolute=%d x=%d y=%d z=%d buttons=%x" % (mev.absolute, mev.x, mev.y, mev.z, mev.buttons) 314 311 315 312 def printKbdEvent(ctx, kev): 316 313 print "Kbd: ", ctx['global'].getArray(kev, 'scancodes') 317 314 318 def monitorSource(ctx, e s, active, dur):319 def handleEventImpl(ev ):320 type = ev.type321 print "got event: %s %s" %(str(type), asEnumElem(ctx, 'VBoxEventType',type))322 iftype == ctx['global'].constants.VBoxEventType_OnMachineStateChanged:323 scev = ctx['global'].queryInterface(ev, 'IMachineStateChangedEvent')324 325 print "machine state event: mach=%s state=%s" %(scev.machineId, scev.state)326 eliftype == ctx['global'].constants.VBoxEventType_OnGuestPropertyChanged:327 gpcev = ctx['global'].queryInterface(ev, 'IGuestPropertyChangedEvent')328 329 print "guest property change: name=%s value=%s" %(gpcev.name, gpcev.value)330 eliftype == ctx['global'].constants.VBoxEventType_OnMousePointerShapeChanged:331 psev = ctx['global'].queryInterface(ev, 'IMousePointerShapeChangedEvent')332 333 334 335 336 337 print "pointer shape event: w=%d h=%d shape len=%d" %(psev.width, psev.height, len(shape))338 eliftype == ctx['global'].constants.VBoxEventType_OnGuestMouse:339 mev = ctx['global'].queryInterface(ev, 'IGuestMouseEvent')340 341 342 eliftype == ctx['global'].constants.VBoxEventType_OnGuestKeyboard:343 kev = ctx['global'].queryInterface(ev, 'IGuestKeyboardEvent')344 345 315 def monitorSource(ctx, eventSource, active, dur): 316 def handleEventImpl(event): 317 evtype = event.type 318 print "got event: %s %s" % (str(evtype), asEnumElem(ctx, 'VBoxEventType', evtype)) 319 if evtype == ctx['global'].constants.VBoxEventType_OnMachineStateChanged: 320 scev = ctx['global'].queryInterface(event, 'IMachineStateChangedEvent') 321 if scev: 322 print "machine state event: mach=%s state=%s" % (scev.machineId, scev.state) 323 elif evtype == ctx['global'].constants.VBoxEventType_OnGuestPropertyChanged: 324 gpcev = ctx['global'].queryInterface(event, 'IGuestPropertyChangedEvent') 325 if gpcev: 326 print "guest property change: name=%s value=%s" % (gpcev.name, gpcev.value) 327 elif evtype == ctx['global'].constants.VBoxEventType_OnMousePointerShapeChanged: 328 psev = ctx['global'].queryInterface(event, 'IMousePointerShapeChangedEvent') 329 if psev: 330 shape = ctx['global'].getArray(psev, 'shape') 331 if shape is None: 332 print "pointer shape event - empty shape" 333 else: 334 print "pointer shape event: w=%d h=%d shape len=%d" % (psev.width, psev.height, len(shape)) 335 elif evtype == ctx['global'].constants.VBoxEventType_OnGuestMouse: 336 mev = ctx['global'].queryInterface(event, 'IGuestMouseEvent') 337 if mev: 338 printMouseEvent(ctx, mev) 339 elif evtype == ctx['global'].constants.VBoxEventType_OnGuestKeyboard: 340 kev = ctx['global'].queryInterface(event, 'IGuestKeyboardEvent') 341 if kev: 342 printKbdEvent(ctx, kev) 346 343 347 344 class EventListener: 348 def __init__(self, arg):349 pass350 351 def handleEvent(self, ev):352 try:353 # a bit convoluted QI to make it work with MS COM354 handleEventImpl(ctx['global'].queryInterface(ev, 'IEvent'))355 except:356 traceback.print_exc()357 345 def __init__(self, arg): 346 pass 347 348 def handleEvent(self, event): 349 try: 350 # a bit convoluted QI to make it work with MS COM 351 handleEventImpl(ctx['global'].queryInterface(event, 'IEvent')) 352 except: 353 traceback.print_exc() 354 pass 358 355 359 356 if active: 360 357 listener = ctx['global'].createListener(EventListener) 361 358 else: 362 listener = e s.createListener()359 listener = eventSource.createListener() 363 360 registered = False 364 361 if dur == -1: … … 366 363 dur = 100000 367 364 try: 368 e s.registerListener(listener, [ctx['global'].constants.VBoxEventType_Any], active)365 eventSource.registerListener(listener, [ctx['global'].constants.VBoxEventType_Any], active) 369 366 registered = True 370 367 end = time.time() + dur … … 373 370 ctx['global'].waitForEvents(500) 374 371 else: 375 ev = es.getEvent(listener, 500)376 if ev :377 handleEventImpl(ev )372 event = eventSource.getEvent(listener, 500) 373 if event: 374 handleEventImpl(event) 378 375 # otherwise waitable events will leak (active listeners ACK automatically) 379 e s.eventProcessed(listener, ev)376 eventSource.eventProcessed(listener, event) 380 377 # We need to catch all exceptions here, otherwise listener will never be unregistered 381 378 except: … … 383 380 pass 384 381 if listener and registered: 385 e s.unregisterListener(listener)386 387 388 tsLast = 0389 def recordDemo(ctx, console, file , dur):390 demo = open(file , 'w')391 header ="VM="+console.machine.name+"\n"382 eventSource.unregisterListener(listener) 383 384 385 g_tsLast = 0 386 def recordDemo(ctx, console, filename, dur): 387 demo = open(filename, 'w') 388 header = "VM=" + console.machine.name + "\n" 392 389 demo.write(header) 393 390 394 global tsLast395 tsLast = time.time()391 global g_tsLast 392 g_tsLast = time.time() 396 393 397 394 def stamp(): 398 global tsLast395 global g_tsLast 399 396 tsCur = time.time() 400 rv = int((tsCur-tsLast)*1000)401 tsLast = tsCur402 return rv403 404 def handleEventImpl(ev ):405 type = ev.type406 #print "got event: %s %s" %(str(type), asEnumElem(ctx, 'VBoxEventType',type))407 iftype == ctx['global'].constants.VBoxEventType_OnGuestMouse:408 mev = ctx['global'].queryInterface(ev, 'IGuestMouseEvent')409 410 l = "%d: m %d %d %d %d %d %d\n" %(stamp(), mev.absolute, mev.x, mev.y, mev.z, mev.w, mev.buttons)411 demo.write(l)412 eliftype == ctx['global'].constants.VBoxEventType_OnGuestKeyboard:413 kev = ctx['global'].queryInterface(ev, 'IGuestKeyboardEvent')414 415 l = "%d: k %s\n" %(stamp(), str(ctx['global'].getArray(kev, 'scancodes')))416 demo.write(l)397 timePassed = int((tsCur-g_tsLast)*1000) 398 g_tsLast = tsCur 399 return timePassed 400 401 def handleEventImpl(event): 402 evtype = event.type 403 #print "got event: %s %s" % (str(evtype), asEnumElem(ctx, 'VBoxEventType', evtype)) 404 if evtype == ctx['global'].constants.VBoxEventType_OnGuestMouse: 405 mev = ctx['global'].queryInterface(event, 'IGuestMouseEvent') 406 if mev: 407 line = "%d: m %d %d %d %d %d %d\n" % (stamp(), mev.absolute, mev.x, mev.y, mev.z, mev.w, mev.buttons) 408 demo.write(line) 409 elif evtype == ctx['global'].constants.VBoxEventType_OnGuestKeyboard: 410 kev = ctx['global'].queryInterface(event, 'IGuestKeyboardEvent') 411 if kev: 412 line = "%d: k %s\n" % (stamp(), str(ctx['global'].getArray(kev, 'scancodes'))) 413 demo.write(line) 417 414 418 415 listener = console.eventSource.createListener() … … 420 417 # we create an aggregated event source to listen for multiple event sources (keyboard and mouse in our case) 421 418 agg = console.eventSource.createAggregator([console.keyboard.eventSource, console.mouse.eventSource]) 422 demo = open(file , 'w')423 header ="VM="+console.machine.name+"\n"419 demo = open(filename, 'w') 420 header = "VM=" + console.machine.name + "\n" 424 421 demo.write(header) 425 422 if dur == -1: … … 431 428 end = time.time() + dur 432 429 while time.time() < end: 433 ev = agg.getEvent(listener, 1000)434 if ev :435 handleEventImpl(ev )430 event = agg.getEvent(listener, 1000) 431 if event: 432 handleEventImpl(event) 436 433 # keyboard/mouse events aren't waitable, so no need for eventProcessed 437 434 # We need to catch all exceptions here, otherwise listener will never be unregistered … … 444 441 445 442 446 def playbackDemo(ctx, console, file , dur):447 demo = open(file , 'r')443 def playbackDemo(ctx, console, filename, dur): 444 demo = open(filename, 'r') 448 445 449 446 if dur == -1: … … 465 462 if time.time() > end: 466 463 break 467 m = basere.search(line)468 if m is None:464 match = basere.search(line) 465 if match is None: 469 466 continue 470 467 471 dict = m.groupdict()472 stamp = dict['s']473 params = dict['p']474 type =dict['t']468 rdict = match.groupdict() 469 stamp = rdict['s'] 470 params = rdict['p'] 471 rtype = rdict['t'] 475 472 476 473 time.sleep(float(stamp)/1000) 477 474 478 if type == 'k':479 codes =kre.findall(params)480 #print "KBD:", codes475 if rtype == 'k': 476 codes = kre.findall(params) 477 #print "KBD:", codes 481 478 kbd.putScancodes(codes) 482 elif type == 'm':479 elif rtype == 'm': 483 480 mm = mre.search(params) 484 481 if mm is not None: … … 486 483 if mdict['a'] == '1': 487 484 # absolute 488 #print "MA: ", mdict['x'],mdict['y'],mdict['z'],mdict['b']485 #print "MA: ", mdict['x'], mdict['y'], mdict['z'], mdict['b'] 489 486 mouse.putMouseEventAbsolute(int(mdict['x']), int(mdict['y']), int(mdict['z']), int(mdict['w']), int(mdict['b'])) 490 487 else: 491 #print "MR: ", mdict['x'],mdict['y'],mdict['b']488 #print "MR: ", mdict['x'], mdict['y'], mdict['b'] 492 489 mouse.putMouseEvent(int(mdict['x']), int(mdict['y']), int(mdict['z']), int(mdict['w']), int(mdict['b'])) 493 490 … … 501 498 502 499 503 def takeScreenshotOld( ctx,console,args):500 def takeScreenshotOld(_ctx, console, args): 504 501 from PIL import Image 505 502 display = console.display … … 512 509 else: 513 510 screen = 0 514 (fbw, fbh, fbbpp) = display.getScreenResolution(screen)511 (fbw, fbh, _fbbpp) = display.getScreenResolution(screen) 515 512 if len(args) > 1: 516 513 w = int(args[1]) … … 522 519 h = fbh 523 520 524 print "Saving screenshot (%d x %d) screen %d in %s..." % (w,h,screen,f)525 data = display.takeScreenShotToArray(screen, w, h)526 size = (w, h)521 print "Saving screenshot (%d x %d) screen %d in %s..." % (w, h, screen, f) 522 data = display.takeScreenShotToArray(screen, w, h) 523 size = (w, h) 527 524 mode = "RGBA" 528 525 im = Image.frombuffer(mode, size, str(data), "raw", mode, 0, 1) 529 526 im.save(f, "PNG") 530 527 531 def takeScreenshot( ctx,console,args):528 def takeScreenshot(_ctx, console, args): 532 529 display = console.display 533 530 if len(args) > 0: … … 539 536 else: 540 537 screen = 0 541 (fbw, fbh, fbbpp) = display.getScreenResolution(screen)538 (fbw, fbh, _fbbpp) = display.getScreenResolution(screen) 542 539 if len(args) > 1: 543 540 w = int(args[1]) … … 549 546 h = fbh 550 547 551 print "Saving screenshot (%d x %d) screen %d in %s..." %(w,h,screen,f) 552 data = display.takeScreenShotPNGToArray(screen, w,h) 553 size = (w,h) 554 file = open(f, 'wb') 555 file.write(data) 556 file.close() 557 558 def teleport(ctx,session,console,args): 548 print "Saving screenshot (%d x %d) screen %d in %s..." % (w, h, screen, f) 549 data = display.takeScreenShotPNGToArray(screen, w, h) 550 pngfile = open(f, 'wb') 551 pngfile.write(data) 552 pngfile.close() 553 554 def teleport(ctx, _session, console, args): 559 555 if args[0].find(":") == -1: 560 556 print "Use host:port format for teleport target" 561 557 return 562 (host, port) = args[0].split(":")558 (host, port) = args[0].split(":") 563 559 if len(args) > 1: 564 560 passwd = args[1] … … 567 563 568 564 if len(args) > 2: 569 maxDowntime 565 maxDowntime = int(args[2]) 570 566 else: 571 567 maxDowntime = 250 572 568 573 569 port = int(port) 574 print "Teleporting to %s:%d..." % (host,port)570 print "Teleporting to %s:%d..." % (host, port) 575 571 progress = console.teleport(host, port, passwd, maxDowntime) 576 572 if progressBar(ctx, progress, 100) and int(progress.resultCode) == 0: 577 573 print "Success!" 578 574 else: 579 reportError(ctx, progress)580 581 582 def guestStats(ctx, console,args):575 reportError(ctx, progress) 576 577 578 def guestStats(ctx, console, args): 583 579 guest = console.guest 584 580 # we need to set up guest statistics … … 599 595 try: 600 596 val = guest.getStatistic( cpu, all_stats[s]) 601 print "%s: %d" % (s, val)597 print "%s: %d" % (s, val) 602 598 except: 603 599 # likely not implemented 604 600 pass 605 601 606 def plugCpu( ctx,machine,session,args):602 def plugCpu(_ctx, machine, _session, args): 607 603 cpu = int(args[0]) 608 print "Adding CPU %d..." % (cpu)604 print "Adding CPU %d..." % (cpu) 609 605 machine.hotPlugCPU(cpu) 610 606 611 def unplugCpu( ctx,machine,session,args):607 def unplugCpu(_ctx, machine, _session, args): 612 608 cpu = int(args[0]) 613 print "Removing CPU %d..." % (cpu)609 print "Removing CPU %d..." % (cpu) 614 610 machine.hotUnplugCPU(cpu) 615 611 616 def mountIso( ctx,machine,session,args):612 def mountIso(_ctx, machine, _session, args): 617 613 machine.mountMedium(args[0], args[1], args[2], args[3], args[4]) 618 614 machine.saveSettings() 619 615 620 def cond(c, v1,v2):616 def cond(c, v1, v2): 621 617 if c: 622 618 return v1 … … 624 620 return v2 625 621 626 def printHostUsbDev(ctx, ud):627 print " %s: %s (vendorId=%d productId=%d serial=%s) %s" % (ud.id, colored(ud.product,'blue'), ud.vendorId, ud.productId, ud.serialNumber,asEnumElem(ctx, 'USBDeviceState', ud.state))628 629 def printUsbDev( ctx,ud):630 print " %s: %s (vendorId=%d productId=%d serial=%s)" % (ud.id, colored(ud.product,'blue'), ud.vendorId, ud.productId, ud.serialNumber)631 632 def printSf(ctx, sf):633 print " name=%s host=%s %s %s" % (sf.name, colPath(ctx,sf.hostPath), cond(sf.accessible, "accessible", "not accessible"), cond(sf.writable, "writable", "read-only"))634 635 def ginfo(ctx, console,args):622 def printHostUsbDev(ctx, ud): 623 print " %s: %s (vendorId=%d productId=%d serial=%s) %s" % (ud.id, colored(ud.product, 'blue'), ud.vendorId, ud.productId, ud.serialNumber, asEnumElem(ctx, 'USBDeviceState', ud.state)) 624 625 def printUsbDev(_ctx, ud): 626 print " %s: %s (vendorId=%d productId=%d serial=%s)" % (ud.id, colored(ud.product, 'blue'), ud.vendorId, ud.productId, ud.serialNumber) 627 628 def printSf(ctx, sf): 629 print " name=%s host=%s %s %s" % (sf.name, colPath(ctx, sf.hostPath), cond(sf.accessible, "accessible", "not accessible"), cond(sf.writable, "writable", "read-only")) 630 631 def ginfo(ctx, console, _args): 636 632 guest = console.guest 637 633 if guest.additionsRunLevel != ctx['const'].AdditionsRunLevelType_None: 638 print "Additions active, version %s" %(guest.additionsVersion)639 print "Support seamless: %s" %(getFacilityStatus(ctx, guest, ctx['const'].AdditionsFacilityType_Seamless))640 print "Support graphics: %s" %(getFacilityStatus(ctx, guest, ctx['const'].AdditionsFacilityType_Graphics))641 print "Balloon size: %d" %(guest.memoryBalloonSize)642 print "Statistic update interval: %d" % (guest.statisticsUpdateInterval)634 print "Additions active, version %s" % (guest.additionsVersion) 635 print "Support seamless: %s" % (getFacilityStatus(ctx, guest, ctx['const'].AdditionsFacilityType_Seamless)) 636 print "Support graphics: %s" % (getFacilityStatus(ctx, guest, ctx['const'].AdditionsFacilityType_Graphics)) 637 print "Balloon size: %d" % (guest.memoryBalloonSize) 638 print "Statistic update interval: %d" % (guest.statisticsUpdateInterval) 643 639 else: 644 640 print "No additions" … … 646 642 print "Attached USB:" 647 643 for ud in usbs: 648 printUsbDev(ctx,ud)644 printUsbDev(ctx, ud) 649 645 rusbs = ctx['global'].getArray(console, 'remoteUSBDevices') 650 646 print "Remote USB:" 651 647 for ud in rusbs: 652 printHostUsbDev(ctx, ud)648 printHostUsbDev(ctx, ud) 653 649 print "Transient shared folders:" 654 sfs = 650 sfs = rusbs = ctx['global'].getArray(console, 'sharedFolders') 655 651 for sf in sfs: 656 printSf(ctx, sf)657 658 def cmdExistingVm(ctx, mach,cmd,args):652 printSf(ctx, sf) 653 654 def cmdExistingVm(ctx, mach, cmd, args): 659 655 session = None 660 656 try: 661 vb = ctx['vb']662 session = ctx['mgr'].getSessionObject(vb )657 vbox = ctx['vb'] 658 session = ctx['mgr'].getSessionObject(vbox) 663 659 mach.lockMachine(session, ctx['global'].constants.LockType_Shared) 664 except Exception, e:665 printErr(ctx, "Session to '%s' not open: %s" % (mach.name,str(e)))666 if g_ verbose:660 except Exception, e: 661 printErr(ctx, "Session to '%s' not open: %s" % (mach.name, str(e))) 662 if g_fVerbose: 667 663 traceback.print_exc() 668 664 return 669 665 if session.state != ctx['const'].SessionState_Locked: 670 print "Session to '%s' in wrong state: %s" % (mach.name, session.state)666 print "Session to '%s' in wrong state: %s" % (mach.name, session.state) 671 667 session.unlockMachine() 672 668 return … … 677 673 session.unlockMachine() 678 674 return 679 console =session.console680 ops ={'pause': lambda: console.pause(),681 'resume': lambda: console.resume(),682 'powerdown': lambda: console.powerDown(),683 'powerbutton': lambda: console.powerButton(),684 'stats': lambda: perfStats(ctx, mach),685 'guest': lambda: guestExec(ctx, mach, console, args),686 'ginfo': lambda: ginfo(ctx, console, args),687 'guestlambda': lambda: args[0](ctx, mach, console, args[1:]),688 'save': lambda: progressBar(ctx,console.saveState()),689 'screenshot': lambda: takeScreenshot(ctx,console,args),690 'teleport': lambda: teleport(ctx,session,console,args),691 'gueststats': lambda: guestStats(ctx, console, args),692 'plugcpu': lambda: plugCpu(ctx, session.machine, session, args),693 'unplugcpu': lambda: unplugCpu(ctx, session.machine, session, args),694 'mountiso': lambda: mountIso(ctx, session.machine, session, args),695 }675 console = session.console 676 ops = {'pause': lambda: console.pause(), 677 'resume': lambda: console.resume(), 678 'powerdown': lambda: console.powerDown(), 679 'powerbutton': lambda: console.powerButton(), 680 'stats': lambda: perfStats(ctx, mach), 681 'guest': lambda: guestExec(ctx, mach, console, args), 682 'ginfo': lambda: ginfo(ctx, console, args), 683 'guestlambda': lambda: args[0](ctx, mach, console, args[1:]), 684 'save': lambda: progressBar(ctx, console.saveState()), 685 'screenshot': lambda: takeScreenshot(ctx, console, args), 686 'teleport': lambda: teleport(ctx, session, console, args), 687 'gueststats': lambda: guestStats(ctx, console, args), 688 'plugcpu': lambda: plugCpu(ctx, session.machine, session, args), 689 'unplugcpu': lambda: unplugCpu(ctx, session.machine, session, args), 690 'mountiso': lambda: mountIso(ctx, session.machine, session, args), 691 } 696 692 try: 697 693 ops[cmd]() … … 699 695 ctx['interrupt'] = True 700 696 except Exception, e: 701 printErr(ctx, e)702 if g_ verbose:697 printErr(ctx, e) 698 if g_fVerbose: 703 699 traceback.print_exc() 704 700 … … 706 702 707 703 708 def cmdClosedVm(ctx, mach,cmd,args=[],save=True):704 def cmdClosedVm(ctx, mach, cmd, args=[], save=True): 709 705 session = ctx['global'].openMachineSession(mach, True) 710 706 mach = session.machine … … 713 709 except Exception, e: 714 710 save = False 715 printErr(ctx, e)716 if g_ verbose:711 printErr(ctx, e) 712 if g_fVerbose: 717 713 traceback.print_exc() 718 714 if save: … … 720 716 mach.saveSettings() 721 717 except Exception, e: 722 printErr(ctx, e)723 if g_ verbose:718 printErr(ctx, e) 719 if g_fVerbose: 724 720 traceback.print_exc() 725 721 ctx['global'].closeMachineSession(session) 726 722 727 723 728 def cmdAnyVm(ctx, mach,cmd, args=[],save=False):724 def cmdAnyVm(ctx, mach, cmd, args=[], save=False): 729 725 session = ctx['global'].openMachineSession(mach) 730 726 mach = session.machine 731 727 try: 732 728 cmd(ctx, mach, session.console, args) 733 729 except Exception, e: 734 save = False ;735 printErr(ctx, e)736 if g_ verbose:730 save = False 731 printErr(ctx, e) 732 if g_fVerbose: 737 733 traceback.print_exc() 738 734 if save: 739 735 mach.saveSettings() 740 736 ctx['global'].closeMachineSession(session) 741 737 742 def machById(ctx, id):738 def machById(ctx, uuid): 743 739 try: 744 mach = ctx['vb'].getMachine( id)740 mach = ctx['vb'].getMachine(uuid) 745 741 except: 746 mach = ctx['vb'].findMachine( id)742 mach = ctx['vb'].findMachine(uuid) 747 743 return mach 748 744 749 745 class XPathNode: 750 def __init__(self, parent, obj, type):746 def __init__(self, parent, obj, ntype): 751 747 self.parent = parent 752 748 self.obj = obj 753 self. type =type749 self.ntype = ntype 754 750 def lookup(self, subpath): 755 751 children = self.enum() … … 761 757 def enum(self): 762 758 return [] 763 def matches(self, subexp):764 if subexp == self. type:759 def matches(self, subexp): 760 if subexp == self.ntype: 765 761 return True 766 if not subexp.startswith(self. type):762 if not subexp.startswith(self.ntype): 767 763 return False 768 m = re.search(r"@(?P<a>\w+)=(?P<v>[^\'\[\]]+)", subexp)764 match = re.search(r"@(?P<a>\w+)=(?P<v>[^\'\[\]]+)", subexp) 769 765 matches = False 770 766 try: 771 if m is not None:772 dict = m.groupdict()773 attr = dict['a']774 val =dict['v']767 if match is not None: 768 xdict = match.groupdict() 769 attr = xdict['a'] 770 val = xdict['v'] 775 771 matches = (str(getattr(self.obj, attr)) == val) 776 772 except: … … 778 774 return matches 779 775 def apply(self, cmd): 780 exec(cmd, {'obj':self.obj, 'node':self,'ctx':self.getCtx()}, {})776 exec(cmd, {'obj':self.obj, 'node':self, 'ctx':self.getCtx()}, {}) 781 777 def getCtx(self): 782 if hasattr(self, 'ctx'):778 if hasattr(self, 'ctx'): 783 779 return self.ctx 784 780 return self.parent.getCtx() … … 792 788 def enum(self): 793 789 children = [] 794 for n in self.getCtx()['global'].getArray(self.obj, self.attr):795 node = self.heldClass(self, n)796 children.append(node )790 for node in self.getCtx()['global'].getArray(self.obj, self.attr): 791 nodexml = self.heldClass(self, node) 792 children.append(nodexml) 797 793 return children 798 def matches(self, subexp):794 def matches(self, subexp): 799 795 return subexp == self.xpathname 800 796 … … 803 799 XPathNode.__init__(self, parent, obj, 'val '+xpathname) 804 800 self.xpathname = xpathname 805 def matches(self, subexp):801 def matches(self, subexp): 806 802 return subexp == self.xpathname 807 803 … … 813 809 def __init__(self, parent, obj): 814 810 XPathNode.__init__(self, parent, obj, 'vm') 815 #def matches(self, subexp):811 #def matches(self, subexp): 816 812 # return subexp=='vm' 817 813 def enum(self): … … 834 830 def __init__(self, parent, obj): 835 831 XPathNode.__init__(self, parent, obj, 'nic') 836 def matches(self, subexp):837 return subexp =='nic'832 def matches(self, subexp): 833 return subexp == 'nic' 838 834 839 835 class XPathNodeRoot(XPathNode): … … 843 839 def enum(self): 844 840 return [XPathNodeHolderVM(self, self.ctx['vb'])] 845 def matches(self, subexp):841 def matches(self, subexp): 846 842 return True 847 843 848 def eval_xpath(ctx, scope):844 def eval_xpath(ctx, scope): 849 845 pathnames = scope.split("/")[2:] 850 846 nodes = [XPathNodeRoot(ctx)] 851 for p in pathnames:847 for path in pathnames: 852 848 seen = [] 853 849 while len(nodes) > 0: 854 n = nodes.pop()855 seen.append(n )850 node = nodes.pop() 851 seen.append(node) 856 852 for s in seen: 857 matches = s.lookup(p )858 for m in matches:859 nodes.append(m )853 matches = s.lookup(path) 854 for match in matches: 855 nodes.append(match) 860 856 if len(nodes) == 0: 861 857 break 862 858 return nodes 863 859 864 def argsToMach(ctx, args):860 def argsToMach(ctx, args): 865 861 if len(args) < 2: 866 print "usage: %s [vmname|uuid]" % (args[0])862 print "usage: %s [vmname|uuid]" % (args[0]) 867 863 return None 868 id = args[1]869 m = machById(ctx,id)870 if m == None:871 print "Machine '%s' is unknown, use list command to find available machines" % (id)872 return m 873 874 def helpSingleCmd(cmd, h,sp):864 uuid = args[1] 865 mach = machById(ctx, uuid) 866 if mach == None: 867 print "Machine '%s' is unknown, use list command to find available machines" % (uuid) 868 return mach 869 870 def helpSingleCmd(cmd, h, sp): 875 871 if sp != 0: 876 872 spec = " [ext from "+sp+"]" 877 873 else: 878 874 spec = "" 879 print " %s: %s%s" % (colored(cmd,'blue'),h,spec)880 881 def helpCmd( ctx, args):875 print " %s: %s%s" % (colored(cmd, 'blue'), h, spec) 876 877 def helpCmd(_ctx, args): 882 878 if len(args) == 1: 883 879 print "Help page:" … … 890 886 c = commands.get(cmd) 891 887 if c == None: 892 print "Command '%s' not known" % (cmd)888 print "Command '%s' not known" % (cmd) 893 889 else: 894 890 helpSingleCmd(cmd, c[0], c[2]) 895 891 return 0 896 892 897 def asEnumElem(ctx, enum,elem):898 all= ctx['const'].all_values(enum)899 for e in all.keys():900 if str(elem) == str( all[e]):893 def asEnumElem(ctx, enum, elem): 894 enumVals = ctx['const'].all_values(enum) 895 for e in enumVals.keys(): 896 if str(elem) == str(enumVals[e]): 901 897 return colored(e, 'green') 902 898 return colored("<unknown>", 'green') 903 899 904 def enumFromString(ctx, enum,str):905 all= ctx['const'].all_values(enum)906 return all.get(str, None)907 908 def listCmd(ctx, args):909 for m in getMachines(ctx, True):900 def enumFromString(ctx, enum, strg): 901 enumVals = ctx['const'].all_values(enum) 902 return enumVals.get(strg, None) 903 904 def listCmd(ctx, _args): 905 for mach in getMachines(ctx, True): 910 906 try: 911 if m .teleporterEnabled:907 if mach.teleporterEnabled: 912 908 tele = "[T] " 913 909 else: 914 910 tele = " " 915 print "%sMachine '%s' [%s], machineState=%s, sessionState=%s" % (tele,colVm(ctx,m.name),m.id,asEnumElem(ctx, "MachineState", m.state), asEnumElem(ctx,"SessionState", m.sessionState))911 print "%sMachine '%s' [%s], machineState=%s, sessionState=%s" % (tele, colVm(ctx, mach.name), mach.id, asEnumElem(ctx, "MachineState", mach.state), asEnumElem(ctx, "SessionState", mach.sessionState)) 916 912 except Exception, e: 917 printErr(ctx, e)918 if g_ verbose:913 printErr(ctx, e) 914 if g_fVerbose: 919 915 traceback.print_exc() 920 916 return 0 921 917 922 def infoCmd(ctx, args):918 def infoCmd(ctx, args): 923 919 if (len(args) < 2): 924 920 print "usage: info [vmname|uuid]" 925 921 return 0 926 mach = argsToMach(ctx, args)927 if mach == None: 928 return 0 929 os = ctx['vb'].getGuestOSType(mach.OSTypeId)922 mach = argsToMach(ctx, args) 923 if mach == None: 924 return 0 925 vmos = ctx['vb'].getGuestOSType(mach.OSTypeId) 930 926 print " One can use setvar <mach> <var> <value> to change variable, using name in []." 931 print " Name [name]: %s" % (colVm(ctx,mach.name))932 print " Description [description]: %s" % (mach.description)933 print " ID [n/a]: %s" % (mach.id)934 print " OS Type [via OSTypeId]: %s" % (os.description)935 print " Firmware [firmwareType]: %s (%s)" % (asEnumElem(ctx,"FirmwareType", mach.firmwareType),mach.firmwareType)927 print " Name [name]: %s" % (colVm(ctx, mach.name)) 928 print " Description [description]: %s" % (mach.description) 929 print " ID [n/a]: %s" % (mach.id) 930 print " OS Type [via OSTypeId]: %s" % (vmos.description) 931 print " Firmware [firmwareType]: %s (%s)" % (asEnumElem(ctx, "FirmwareType", mach.firmwareType), mach.firmwareType) 936 932 print 937 print " CPUs [CPUCount]: %d" % (mach.CPUCount)938 print " RAM [memorySize]: %dM" % (mach.memorySize)939 print " VRAM [VRAMSize]: %dM" % (mach.VRAMSize)940 print " Monitors [monitorCount]: %d" % (mach.monitorCount)941 print " Chipset [chipsetType]: %s (%s)" % (asEnumElem(ctx,"ChipsetType", mach.chipsetType), mach.chipsetType)933 print " CPUs [CPUCount]: %d" % (mach.CPUCount) 934 print " RAM [memorySize]: %dM" % (mach.memorySize) 935 print " VRAM [VRAMSize]: %dM" % (mach.VRAMSize) 936 print " Monitors [monitorCount]: %d" % (mach.monitorCount) 937 print " Chipset [chipsetType]: %s (%s)" % (asEnumElem(ctx, "ChipsetType", mach.chipsetType), mach.chipsetType) 942 938 print 943 print " Clipboard mode [clipboardMode]: %s (%s)" % (asEnumElem(ctx,"ClipboardMode", mach.clipboardMode), mach.clipboardMode)944 print " Machine status [n/a]: %s (%s)" % (asEnumElem(ctx, "SessionState", mach.sessionState), mach.sessionState)939 print " Clipboard mode [clipboardMode]: %s (%s)" % (asEnumElem(ctx, "ClipboardMode", mach.clipboardMode), mach.clipboardMode) 940 print " Machine status [n/a]: %s (%s)" % (asEnumElem(ctx, "SessionState", mach.sessionState), mach.sessionState) 945 941 print 946 942 if mach.teleporterEnabled: 947 print " Teleport target on port %d (%s)" % (mach.teleporterPort, mach.teleporterPassword)943 print " Teleport target on port %d (%s)" % (mach.teleporterPort, mach.teleporterPassword) 948 944 print 949 945 bios = mach.BIOSSettings 950 print " ACPI [BIOSSettings.ACPIEnabled]: %s" % (asState(bios.ACPIEnabled))951 print " APIC [BIOSSettings.IOAPICEnabled]: %s" % (asState(bios.IOAPICEnabled))946 print " ACPI [BIOSSettings.ACPIEnabled]: %s" % (asState(bios.ACPIEnabled)) 947 print " APIC [BIOSSettings.IOAPICEnabled]: %s" % (asState(bios.IOAPICEnabled)) 952 948 hwVirtEnabled = mach.getHWVirtExProperty(ctx['global'].constants.HWVirtExPropertyType_Enabled) 953 print " Hardware virtualization [guest win machine.setHWVirtExProperty(ctx[\\'const\\'].HWVirtExPropertyType_Enabled, value)]: " + asState(hwVirtEnabled)949 print " Hardware virtualization [guest win machine.setHWVirtExProperty(ctx[\\'const\\'].HWVirtExPropertyType_Enabled, value)]: " + asState(hwVirtEnabled) 954 950 hwVirtVPID = mach.getHWVirtExProperty(ctx['const'].HWVirtExPropertyType_VPID) 955 print " VPID support [guest win machine.setHWVirtExProperty(ctx[\\'const\\'].HWVirtExPropertyType_VPID, value)]: " + asState(hwVirtVPID)951 print " VPID support [guest win machine.setHWVirtExProperty(ctx[\\'const\\'].HWVirtExPropertyType_VPID, value)]: " + asState(hwVirtVPID) 956 952 hwVirtNestedPaging = mach.getHWVirtExProperty(ctx['const'].HWVirtExPropertyType_NestedPaging) 957 print " Nested paging [guest win machine.setHWVirtExProperty(ctx[\\'const\\'].HWVirtExPropertyType_NestedPaging, value)]: " + asState(hwVirtNestedPaging)953 print " Nested paging [guest win machine.setHWVirtExProperty(ctx[\\'const\\'].HWVirtExPropertyType_NestedPaging, value)]: " + asState(hwVirtNestedPaging) 958 954 959 955 print " Hardware 3d acceleration [accelerate3DEnabled]: " + asState(mach.accelerate3DEnabled) 960 956 print " Hardware 2d video acceleration [accelerate2DVideoEnabled]: " + asState(mach.accelerate2DVideoEnabled) 961 957 962 print " Use universal time [RTCUseUTC]: %s" % (asState(mach.RTCUseUTC))963 print " HPET [HPETEnabled]: %s" % (asState(mach.HPETEnabled))958 print " Use universal time [RTCUseUTC]: %s" % (asState(mach.RTCUseUTC)) 959 print " HPET [HPETEnabled]: %s" % (asState(mach.HPETEnabled)) 964 960 if mach.audioAdapter.enabled: 965 print " Audio [via audioAdapter]: chip %s; host driver %s" % (asEnumElem(ctx,"AudioControllerType", mach.audioAdapter.audioController), asEnumElem(ctx,"AudioDriverType", mach.audioAdapter.audioDriver))961 print " Audio [via audioAdapter]: chip %s; host driver %s" % (asEnumElem(ctx, "AudioControllerType", mach.audioAdapter.audioController), asEnumElem(ctx, "AudioDriverType", mach.audioAdapter.audioDriver)) 966 962 if mach.USBController.enabled: 967 print " USB [via USBController]: high speed %s" % (asState(mach.USBController.enabledEHCI))968 print " CPU hotplugging [CPUHotPlugEnabled]: %s" % (asState(mach.CPUHotPlugEnabled))969 970 print " Keyboard [keyboardHIDType]: %s (%s)" % (asEnumElem(ctx,"KeyboardHIDType", mach.keyboardHIDType), mach.keyboardHIDType)971 print " Pointing device [pointingHIDType]: %s (%s)" % (asEnumElem(ctx,"PointingHIDType", mach.pointingHIDType), mach.pointingHIDType)963 print " USB [via USBController]: high speed %s" % (asState(mach.USBController.enabledEHCI)) 964 print " CPU hotplugging [CPUHotPlugEnabled]: %s" % (asState(mach.CPUHotPlugEnabled)) 965 966 print " Keyboard [keyboardHIDType]: %s (%s)" % (asEnumElem(ctx, "KeyboardHIDType", mach.keyboardHIDType), mach.keyboardHIDType) 967 print " Pointing device [pointingHIDType]: %s (%s)" % (asEnumElem(ctx, "PointingHIDType", mach.pointingHIDType), mach.pointingHIDType) 972 968 print " Last changed [n/a]: " + time.asctime(time.localtime(long(mach.lastStateChange)/1000)) 973 969 # OSE has no VRDE 974 970 try: 975 print " VRDE server [VRDEServer.enabled]: %s" % (asState(mach.VRDEServer.enabled))971 print " VRDE server [VRDEServer.enabled]: %s" % (asState(mach.VRDEServer.enabled)) 976 972 except: 977 973 pass 978 974 print 979 print colCat(ctx, " I/O subsystem info:")980 print " Cache enabled [IOCacheEnabled]: %s" % (asState(mach.IOCacheEnabled))981 print " Cache size [IOCacheSize]: %dM" % (mach.IOCacheSize)975 print colCat(ctx, " I/O subsystem info:") 976 print " Cache enabled [IOCacheEnabled]: %s" % (asState(mach.IOCacheEnabled)) 977 print " Cache size [IOCacheSize]: %dM" % (mach.IOCacheSize) 982 978 983 979 controllers = ctx['global'].getArray(mach, 'storageControllers') 984 980 if controllers: 985 981 print 986 print colCat(ctx, " Controllers:")982 print colCat(ctx, " Controllers:") 987 983 for controller in controllers: 988 print " '%s': bus %s type %s" % (controller.name, asEnumElem(ctx, "StorageBus", controller.bus), asEnumElem(ctx,"StorageControllerType", controller.controllerType))984 print " '%s': bus %s type %s" % (controller.name, asEnumElem(ctx, "StorageBus", controller.bus), asEnumElem(ctx, "StorageControllerType", controller.controllerType)) 989 985 990 986 attaches = ctx['global'].getArray(mach, 'mediumAttachments') 991 987 if attaches: 992 988 print 993 print colCat(ctx, " Media:")989 print colCat(ctx, " Media:") 994 990 for a in attaches: 995 print " Controller: '%s' port/device: %d:%d type: %s (%s):" % (a.controller, a.port, a.device, asEnumElem(ctx, "DeviceType", a.type), a.type)996 m = a.medium991 print " Controller: '%s' port/device: %d:%d type: %s (%s):" % (a.controller, a.port, a.device, asEnumElem(ctx, "DeviceType", a.type), a.type) 992 medium = a.medium 997 993 if a.type == ctx['global'].constants.DeviceType_HardDisk: 998 994 print " HDD:" 999 print " Id: %s" % (m.id)1000 print " Location: %s" % (colPath(ctx,m.location))1001 print " Name: %s" %(m.name)1002 print " Format: %s" %(m.format)995 print " Id: %s" % (medium.id) 996 print " Location: %s" % (colPath(ctx, medium.location)) 997 print " Name: %s" % (medium.name) 998 print " Format: %s" % (medium.format) 1003 999 1004 1000 if a.type == ctx['global'].constants.DeviceType_DVD: 1005 1001 print " DVD:" 1006 if m :1007 print " Id: %s" % (m.id)1008 print " Name: %s" % (m.name)1009 if m .hostDrive:1010 print " Host DVD %s" % (colPath(ctx,m.location))1002 if medium: 1003 print " Id: %s" % (medium.id) 1004 print " Name: %s" % (medium.name) 1005 if medium.hostDrive: 1006 print " Host DVD %s" % (colPath(ctx, medium.location)) 1011 1007 if a.passthrough: 1012 1008 print " [passthrough mode]" 1013 1009 else: 1014 print " Virtual image at %s" % (colPath(ctx,m.location))1015 print " Size: %s" % (m.size)1010 print " Virtual image at %s" % (colPath(ctx, medium.location)) 1011 print " Size: %s" % (medium.size) 1016 1012 1017 1013 if a.type == ctx['global'].constants.DeviceType_Floppy: 1018 1014 print " Floppy:" 1019 if m :1020 print " Id: %s" % (m.id)1021 print " Name: %s" % (m.name)1022 if m .hostDrive:1023 print " Host floppy %s" % (colPath(ctx,m.location))1015 if medium: 1016 print " Id: %s" % (medium.id) 1017 print " Name: %s" % (medium.name) 1018 if medium.hostDrive: 1019 print " Host floppy %s" % (colPath(ctx, medium.location)) 1024 1020 else: 1025 print " Virtual image at %s" % (colPath(ctx,m.location))1026 print " Size: %s" % (m.size)1021 print " Virtual image at %s" % (colPath(ctx, medium.location)) 1022 print " Size: %s" % (medium.size) 1027 1023 1028 1024 print 1029 print colCat(ctx, " Shared folders:")1025 print colCat(ctx, " Shared folders:") 1030 1026 for sf in ctx['global'].getArray(mach, 'sharedFolders'): 1031 printSf(ctx, sf)1027 printSf(ctx, sf) 1032 1028 1033 1029 return 0 … … 1037 1033 print "usage: start name <frontend>" 1038 1034 return 0 1039 mach = argsToMach(ctx, args)1035 mach = argsToMach(ctx, args) 1040 1036 if mach == None: 1041 1037 return 0 1042 1038 if len(args) > 2: 1043 type = args[2]1044 else: 1045 type = "gui"1046 startVm(ctx, mach, type)1039 vmtype = args[2] 1040 else: 1041 vmtype = "gui" 1042 startVm(ctx, mach, vmtype) 1047 1043 return 0 1048 1044 … … 1054 1050 oskind = args[2] 1055 1051 try: 1056 1057 except Exception , e:1058 print 'Unknown OS type:', oskind1052 ctx['vb'].getGuestOSType(oskind) 1053 except Exception: 1054 print 'Unknown OS type:', oskind 1059 1055 return 0 1060 1056 createVm(ctx, name, oskind) 1061 1057 return 0 1062 1058 1063 def ginfoCmd(ctx, args):1059 def ginfoCmd(ctx, args): 1064 1060 if (len(args) < 2): 1065 1061 print "usage: ginfo [vmname|uuid]" 1066 1062 return 0 1067 mach = argsToMach(ctx, args)1063 mach = argsToMach(ctx, args) 1068 1064 if mach == None: 1069 1065 return 0 … … 1071 1067 return 0 1072 1068 1073 def execInGuest(ctx, console,args,env,user,passwd,tmo,inputPipe=None,outputPipe=None):1069 def execInGuest(ctx, console, args, env, user, passwd, tmo, inputPipe=None, outputPipe=None): 1074 1070 if len(args) < 1: 1075 1071 print "exec in guest needs at least program name" … … 1079 1075 # shall contain program name as argv[0] 1080 1076 gargs = args 1081 print "executing %s with args %s as %s" % (args[0], gargs, user)1077 print "executing %s with args %s as %s" % (args[0], gargs, user) 1082 1078 flags = 0 1083 1079 if inputPipe is not None: … … 1085 1081 print args[0] 1086 1082 process = guestSession.processCreate(args[0], gargs, env, [], tmo) 1087 print "executed with pid %d" % (process.PID)1083 print "executed with pid %d" % (process.PID) 1088 1084 if pid != 0: 1089 1085 try: … … 1113 1109 if data and len(data) > 0: 1114 1110 if outputPipe is not None: 1115 outputPipe(ctx, data)1111 outputPipe(ctx, data) 1116 1112 else: 1117 1113 sys.stdout.write(data) … … 1125 1121 if progress.cancelable: 1126 1122 progress.cancel() 1127 ( reason, code,flags) = guest.getProcessStatus(pid)1128 print "Exit code: %d" % (code)1123 (_reason, code, _flags) = guest.getProcessStatus(pid) 1124 print "Exit code: %d" % (code) 1129 1125 return 0 1130 1126 else: 1131 1127 reportError(ctx, progress) 1132 1128 1133 def copyToGuest(ctx, console,args,user,passwd):1129 def copyToGuest(ctx, console, args, user, passwd): 1134 1130 src = args[0] 1135 1131 dst = args[1] 1136 1132 flags = 0 1137 print "Copying host %s to guest %s" % (src,dst)1133 print "Copying host %s to guest %s" % (src, dst) 1138 1134 progress = console.guest.copyToGuest(src, dst, user, passwd, flags) 1139 1135 progressBar(ctx, progress) … … 1152 1148 1153 1149 1154 def getCred( ctx):1150 def getCred(_ctx): 1155 1151 import getpass 1156 1152 user = getpass.getuser() 1157 user_inp = nh_raw_input("User (%s): " % (user))1153 user_inp = nh_raw_input("User (%s): " % (user)) 1158 1154 if len (user_inp) > 0: 1159 1155 user = user_inp 1160 1156 passwd = getpass.getpass() 1161 1157 1162 return (user, passwd)1163 1164 def gexecCmd(ctx, args):1158 return (user, passwd) 1159 1160 def gexecCmd(ctx, args): 1165 1161 if (len(args) < 2): 1166 1162 print "usage: gexec [vmname|uuid] command args" 1167 1163 return 0 1168 mach = argsToMach(ctx, args)1164 mach = argsToMach(ctx, args) 1169 1165 if mach == None: 1170 1166 return 0 1171 1167 gargs = args[2:] 1172 1168 env = [] # ["DISPLAY=:0"] 1173 (user, passwd) = getCred(ctx)1174 gargs.insert(0, lambda ctx, mach,console,args: execInGuest(ctx,console,args,env,user,passwd,10000))1169 (user, passwd) = getCred(ctx) 1170 gargs.insert(0, lambda ctx, mach, console, args: execInGuest(ctx, console, args, env, user, passwd, 10000)) 1175 1171 cmdExistingVm(ctx, mach, 'guestlambda', gargs) 1176 1172 return 0 1177 1173 1178 def gcopyCmd(ctx, args):1174 def gcopyCmd(ctx, args): 1179 1175 if (len(args) < 2): 1180 1176 print "usage: gcopy [vmname|uuid] host_path guest_path" 1181 1177 return 0 1182 mach = argsToMach(ctx, args)1178 mach = argsToMach(ctx, args) 1183 1179 if mach == None: 1184 1180 return 0 1185 1181 gargs = args[2:] 1186 (user, passwd) = getCred(ctx)1187 gargs.insert(0, lambda ctx, mach,console,args: copyToGuest(ctx,console,args,user,passwd))1182 (user, passwd) = getCred(ctx) 1183 gargs.insert(0, lambda ctx, mach, console, args: copyToGuest(ctx, console, args, user, passwd)) 1188 1184 cmdExistingVm(ctx, mach, 'guestlambda', gargs) 1189 1185 return 0 1190 1186 1191 def readCmdPipe(ctx, hcmd):1187 def readCmdPipe(ctx, _hcmd): 1192 1188 try: 1193 1189 return ctx['process'].communicate()[0] … … 1195 1191 return None 1196 1192 1197 def gpipeCmd(ctx, args):1193 def gpipeCmd(ctx, args): 1198 1194 if (len(args) < 4): 1199 1195 print "usage: gpipe [vmname|uuid] hostProgram guestProgram, such as gpipe linux '/bin/uname -a' '/bin/sh -c \"/usr/bin/tee; /bin/uname -a\"'" 1200 1196 return 0 1201 mach = argsToMach(ctx, args)1197 mach = argsToMach(ctx, args) 1202 1198 if mach == None: 1203 1199 return 0 1204 1200 hcmd = args[2] 1205 1201 gcmd = args[3] 1206 (user, passwd) = getCred(ctx)1202 (user, passwd) = getCred(ctx) 1207 1203 import subprocess 1208 1204 ctx['process'] = subprocess.Popen(split_no_quotes(hcmd), stdout=subprocess.PIPE) 1209 1205 gargs = split_no_quotes(gcmd) 1210 1206 env = [] 1211 gargs.insert(0, lambda ctx, mach,console,args: execInGuest(ctx,console,args,env,user,passwd, 10000,lambda ctx:readCmdPipe(ctx, hcmd)))1207 gargs.insert(0, lambda ctx, mach, console, args: execInGuest(ctx, console, args, env, user, passwd, 10000, lambda ctx:readCmdPipe(ctx, hcmd))) 1212 1208 cmdExistingVm(ctx, mach, 'guestlambda', gargs) 1213 1209 try: … … 1220 1216 1221 1217 def removeVmCmd(ctx, args): 1222 mach = argsToMach(ctx, args)1218 mach = argsToMach(ctx, args) 1223 1219 if mach == None: 1224 1220 return 0 … … 1227 1223 1228 1224 def pauseCmd(ctx, args): 1229 mach = argsToMach(ctx, args)1225 mach = argsToMach(ctx, args) 1230 1226 if mach == None: 1231 1227 return 0 … … 1234 1230 1235 1231 def powerdownCmd(ctx, args): 1236 mach = argsToMach(ctx, args)1232 mach = argsToMach(ctx, args) 1237 1233 if mach == None: 1238 1234 return 0 … … 1241 1237 1242 1238 def powerbuttonCmd(ctx, args): 1243 mach = argsToMach(ctx, args)1239 mach = argsToMach(ctx, args) 1244 1240 if mach == None: 1245 1241 return 0 … … 1248 1244 1249 1245 def resumeCmd(ctx, args): 1250 mach = argsToMach(ctx, args)1246 mach = argsToMach(ctx, args) 1251 1247 if mach == None: 1252 1248 return 0 … … 1255 1251 1256 1252 def saveCmd(ctx, args): 1257 mach = argsToMach(ctx, args)1253 mach = argsToMach(ctx, args) 1258 1254 if mach == None: 1259 1255 return 0 … … 1262 1258 1263 1259 def statsCmd(ctx, args): 1264 mach = argsToMach(ctx, args)1260 mach = argsToMach(ctx, args) 1265 1261 if mach == None: 1266 1262 return 0 … … 1272 1268 print "usage: guest name commands" 1273 1269 return 0 1274 mach = argsToMach(ctx, args)1270 mach = argsToMach(ctx, args) 1275 1271 if mach == None: 1276 1272 return 0 … … 1285 1281 print "usage: screenshot vm <file> <width> <height> <monitor>" 1286 1282 return 0 1287 mach = argsToMach(ctx, args)1283 mach = argsToMach(ctx, args) 1288 1284 if mach == None: 1289 1285 return 0 … … 1295 1291 print "usage: teleport name host:port <password>" 1296 1292 return 0 1297 mach = argsToMach(ctx, args)1293 mach = argsToMach(ctx, args) 1298 1294 if mach == None: 1299 1295 return 0 … … 1301 1297 return 0 1302 1298 1303 def portalsettings( ctx,mach,args):1299 def portalsettings(_ctx, mach, args): 1304 1300 enabled = args[0] 1305 1301 mach.teleporterEnabled = enabled … … 1314 1310 print "usage: openportal name port <password>" 1315 1311 return 0 1316 mach = argsToMach(ctx, args)1312 mach = argsToMach(ctx, args) 1317 1313 if mach == None: 1318 1314 return 0 … … 1331 1327 print "usage: closeportal name" 1332 1328 return 0 1333 mach = argsToMach(ctx, args)1329 mach = argsToMach(ctx, args) 1334 1330 if mach == None: 1335 1331 return 0 … … 1342 1338 print "usage: gueststats name <check interval>" 1343 1339 return 0 1344 mach = argsToMach(ctx, args)1340 mach = argsToMach(ctx, args) 1345 1341 if mach == None: 1346 1342 return 0 … … 1348 1344 return 0 1349 1345 1350 def plugcpu( ctx,mach,args):1346 def plugcpu(_ctx, mach, args): 1351 1347 plug = args[0] 1352 1348 cpu = args[1] 1353 1349 if plug: 1354 print "Adding CPU %d..." % (cpu)1350 print "Adding CPU %d..." % (cpu) 1355 1351 mach.hotPlugCPU(cpu) 1356 1352 else: 1357 print "Removing CPU %d..." % (cpu)1353 print "Removing CPU %d..." % (cpu) 1358 1354 mach.hotUnplugCPU(cpu) 1359 1355 … … 1362 1358 print "usage: plugcpu name cpuid" 1363 1359 return 0 1364 mach = argsToMach(ctx, args)1360 mach = argsToMach(ctx, args) 1365 1361 if mach == None: 1366 1362 return 0 … … 1376 1372 print "usage: unplugcpu name cpuid" 1377 1373 return 0 1378 mach = argsToMach(ctx, args)1374 mach = argsToMach(ctx, args) 1379 1375 if mach == None: 1380 1376 return 0 … … 1386 1382 return 0 1387 1383 1388 def setvar( ctx,mach,args):1384 def setvar(_ctx, _mach, args): 1389 1385 expr = 'mach.'+args[0]+' = '+args[1] 1390 print "Executing", expr1386 print "Executing", expr 1391 1387 exec expr 1392 1388 … … 1395 1391 print "usage: setvar [vmname|uuid] expr value" 1396 1392 return 0 1397 mach = argsToMach(ctx, args)1393 mach = argsToMach(ctx, args) 1398 1394 if mach == None: 1399 1395 return 0 … … 1401 1397 return 0 1402 1398 1403 def setvmextra( ctx,mach,args):1399 def setvmextra(_ctx, mach, args): 1404 1400 key = args[0] 1405 1401 value = args[1] 1406 print "%s: setting %s to %s" % (mach.name, key, value)1402 print "%s: setting %s to %s" % (mach.name, key, value) 1407 1403 mach.setExtraData(key, value) 1408 1404 … … 1420 1416 return 0 1421 1417 1422 mach = argsToMach(ctx, args)1418 mach = argsToMach(ctx, args) 1423 1419 if mach == None: 1424 1420 return 0 … … 1427 1423 1428 1424 def printExtraKey(obj, key, value): 1429 print "%s: '%s' = '%s'" % (obj, key, value)1425 print "%s: '%s' = '%s'" % (obj, key, value) 1430 1426 1431 1427 def getExtraDataCmd(ctx, args): … … 1441 1437 obj = ctx['vb'] 1442 1438 else: 1443 obj = argsToMach(ctx, args)1439 obj = argsToMach(ctx, args) 1444 1440 if obj == None: 1445 1441 return 0 … … 1454 1450 return 0 1455 1451 1456 def quitCmd( ctx,args):1452 def quitCmd(_ctx, _args): 1457 1453 return 1 1458 1454 … … 1462 1458 return 0 1463 1459 1464 for (k ,v) in aliases.items():1465 print "'%s' is an alias for '%s'" % (k,v)1460 for (key, value) in aliases.items(): 1461 print "'%s' is an alias for '%s'" % (key, value) 1466 1462 return 0 1467 1463 1468 1464 def verboseCmd(ctx, args): 1469 global g_ verbose1465 global g_fVerbose 1470 1466 if (len(args) > 1): 1471 g_ verbose= (args[1]=='on')1472 else: 1473 g_ verbose = not g_verbose1467 g_fVerbose = (args[1]=='on') 1468 else: 1469 g_fVerbose = not g_fVerbose 1474 1470 return 0 1475 1471 1476 1472 def colorsCmd(ctx, args): 1477 global g_ hascolors1473 global g_fHasColors 1478 1474 if (len(args) > 1): 1479 g_ hascolors = (args[1]=='on')1480 else: 1481 g_ hascolors = not g_hascolors1475 g_fHasColors = (args[1] == 'on') 1476 else: 1477 g_fHasColors = not g_fHasColors 1482 1478 return 0 1483 1479 1484 1480 def hostCmd(ctx, args): 1485 vb = ctx['vb'] 1486 print "VirtualBox version %s" %(colored(vb.version, 'blue')) 1487 props = vb.systemProperties 1488 print "Machines: %s" %(colPath(ctx,props.defaultMachineFolder)) 1489 1490 #print "Global shared folders:" 1491 #for ud in ctx['global'].getArray(vb, 'sharedFolders'): 1492 # printSf(ctx,sf) 1493 host = vb.host 1494 cnt = host.processorCount 1495 print colCat(ctx,"Processors:") 1496 print " available/online: %d/%d " %(cnt,host.processorOnlineCount) 1497 for i in range(0,cnt): 1498 print " processor #%d speed: %dMHz %s" %(i,host.getProcessorSpeed(i), host.getProcessorDescription(i)) 1499 1500 print colCat(ctx, "RAM:") 1501 print " %dM (free %dM)" %(host.memorySize, host.memoryAvailable) 1502 print colCat(ctx,"OS:"); 1503 print " %s (%s)" %(host.operatingSystem, host.OSVersion) 1504 if host.acceleration3DAvailable: 1505 print colCat(ctx,"3D acceleration available") 1506 else: 1507 print colCat(ctx,"3D acceleration NOT available") 1508 1509 print colCat(ctx,"Network interfaces:") 1510 for ni in ctx['global'].getArray(host, 'networkInterfaces'): 1511 print " %s (%s)" %(ni.name, ni.IPAddress) 1512 1513 print colCat(ctx,"DVD drives:") 1514 for dd in ctx['global'].getArray(host, 'DVDDrives'): 1515 print " %s - %s" %(dd.name, dd.description) 1516 1517 print colCat(ctx,"Floppy drives:") 1518 for dd in ctx['global'].getArray(host, 'floppyDrives'): 1519 print " %s - %s" %(dd.name, dd.description) 1520 1521 print colCat(ctx,"USB devices:") 1522 for ud in ctx['global'].getArray(host, 'USBDevices'): 1523 printHostUsbDev(ctx,ud) 1524 1525 if ctx['perf']: 1526 for metric in ctx['perf'].query(["*"], [host]): 1527 print metric['name'], metric['values_as_string'] 1528 1529 return 0 1481 vbox = ctx['vb'] 1482 try: 1483 print "VirtualBox version %s" % (colored(vbox.version, 'blue')) 1484 except Exception, e: 1485 printErr(ctx, e) 1486 if g_fVerbose: 1487 traceback.print_exc() 1488 props = vbox.systemProperties 1489 print "Machines: %s" % (colPath(ctx, props.defaultMachineFolder)) 1490 1491 #print "Global shared folders:" 1492 #for ud in ctx['global'].getArray(vbox, 'sharedFolders'): 1493 # printSf(ctx, sf) 1494 host = vbox.host 1495 cnt = host.processorCount 1496 print colCat(ctx, "Processors:") 1497 print " available/online: %d/%d " % (cnt, host.processorOnlineCount) 1498 for i in range(0, cnt): 1499 print " processor #%d speed: %dMHz %s" % (i, host.getProcessorSpeed(i), host.getProcessorDescription(i)) 1500 1501 print colCat(ctx, "RAM:") 1502 print " %dM (free %dM)" % (host.memorySize, host.memoryAvailable) 1503 print colCat(ctx, "OS:") 1504 print " %s (%s)" % (host.operatingSystem, host.OSVersion) 1505 if host.acceleration3DAvailable: 1506 print colCat(ctx, "3D acceleration available") 1507 else: 1508 print colCat(ctx, "3D acceleration NOT available") 1509 1510 print colCat(ctx, "Network interfaces:") 1511 for ni in ctx['global'].getArray(host, 'networkInterfaces'): 1512 print " %s (%s)" % (ni.name, ni.IPAddress) 1513 1514 print colCat(ctx, "DVD drives:") 1515 for dd in ctx['global'].getArray(host, 'DVDDrives'): 1516 print " %s - %s" % (dd.name, dd.description) 1517 1518 print colCat(ctx, "Floppy drives:") 1519 for dd in ctx['global'].getArray(host, 'floppyDrives'): 1520 print " %s - %s" % (dd.name, dd.description) 1521 1522 print colCat(ctx, "USB devices:") 1523 for ud in ctx['global'].getArray(host, 'USBDevices'): 1524 printHostUsbDev(ctx, ud) 1525 1526 if ctx['perf']: 1527 for metric in ctx['perf'].query(["*"], [host]): 1528 print metric['name'], metric['values_as_string'] 1529 1530 return 0 1530 1531 1531 1532 def monitorGuestCmd(ctx, args): … … 1533 1534 print "usage: monitorGuest name (duration)" 1534 1535 return 0 1535 mach = argsToMach(ctx, args)1536 mach = argsToMach(ctx, args) 1536 1537 if mach == None: 1537 1538 return 0 … … 1540 1541 dur = float(args[2]) 1541 1542 active = False 1542 cmdExistingVm(ctx, mach, 'guestlambda', [lambda ctx, mach,console,args: monitorSource(ctx, console.eventSource, active, dur)])1543 cmdExistingVm(ctx, mach, 'guestlambda', [lambda ctx, mach, console, args: monitorSource(ctx, console.eventSource, active, dur)]) 1543 1544 return 0 1544 1545 … … 1547 1548 print "usage: monitorGuestKbd name (duration)" 1548 1549 return 0 1549 mach = argsToMach(ctx, args)1550 mach = argsToMach(ctx, args) 1550 1551 if mach == None: 1551 1552 return 0 … … 1554 1555 dur = float(args[2]) 1555 1556 active = False 1556 cmdExistingVm(ctx, mach, 'guestlambda', [lambda ctx, mach,console,args: monitorSource(ctx, console.keyboard.eventSource, active, dur)])1557 cmdExistingVm(ctx, mach, 'guestlambda', [lambda ctx, mach, console, args: monitorSource(ctx, console.keyboard.eventSource, active, dur)]) 1557 1558 return 0 1558 1559 … … 1561 1562 print "usage: monitorGuestMouse name (duration)" 1562 1563 return 0 1563 mach = argsToMach(ctx, args)1564 mach = argsToMach(ctx, args) 1564 1565 if mach == None: 1565 1566 return 0 … … 1568 1569 dur = float(args[2]) 1569 1570 active = False 1570 cmdExistingVm(ctx, mach, 'guestlambda', [lambda ctx, mach,console,args: monitorSource(ctx, console.mouse.eventSource, active, dur)])1571 cmdExistingVm(ctx, mach, 'guestlambda', [lambda ctx, mach, console, args: monitorSource(ctx, console.mouse.eventSource, active, dur)]) 1571 1572 return 0 1572 1573 … … 1583 1584 return 0 1584 1585 1585 def getAdapterType(ctx, type):1586 if ( type == ctx['global'].constants.NetworkAdapterType_Am79C970A or1587 type == ctx['global'].constants.NetworkAdapterType_Am79C973):1586 def getAdapterType(ctx, natype): 1587 if (natype == ctx['global'].constants.NetworkAdapterType_Am79C970A or 1588 natype == ctx['global'].constants.NetworkAdapterType_Am79C973): 1588 1589 return "pcnet" 1589 elif ( type == ctx['global'].constants.NetworkAdapterType_I82540EM or1590 type == ctx['global'].constants.NetworkAdapterType_I82545EM or1591 type == ctx['global'].constants.NetworkAdapterType_I82543GC):1590 elif (natype == ctx['global'].constants.NetworkAdapterType_I82540EM or 1591 natype == ctx['global'].constants.NetworkAdapterType_I82545EM or 1592 natype == ctx['global'].constants.NetworkAdapterType_I82543GC): 1592 1593 return "e1000" 1593 elif ( type == ctx['global'].constants.NetworkAdapterType_Virtio):1594 elif (natype == ctx['global'].constants.NetworkAdapterType_Virtio): 1594 1595 return "virtio" 1595 elif ( type == ctx['global'].constants.NetworkAdapterType_Null):1596 elif (natype == ctx['global'].constants.NetworkAdapterType_Null): 1596 1597 return None 1597 1598 else: 1598 raise Exception("Unknown adapter type: "+ type)1599 raise Exception("Unknown adapter type: "+natype) 1599 1600 1600 1601 … … 1603 1604 print "usage: portForward <vm> <adapter> <hostPort> <guestPort>" 1604 1605 return 0 1605 mach = argsToMach(ctx, args)1606 mach = argsToMach(ctx, args) 1606 1607 if mach == None: 1607 1608 return 0 … … 1634 1635 print "usage: showLog vm <num>" 1635 1636 return 0 1636 mach = argsToMach(ctx, args)1637 mach = argsToMach(ctx, args) 1637 1638 if mach == None: 1638 1639 return 0 … … 1640 1641 log = 0 1641 1642 if (len(args) > 2): 1642 log= args[2]1643 log = args[2] 1643 1644 1644 1645 uOffset = 0 … … 1657 1658 print "usage: findLog vm pattern <num>" 1658 1659 return 0 1659 mach = argsToMach(ctx, args)1660 mach = argsToMach(ctx, args) 1660 1661 if mach == None: 1661 1662 return 0 … … 1663 1664 log = 0 1664 1665 if (len(args) > 3): 1665 log= args[3]1666 log = args[3] 1666 1667 1667 1668 pattern = args[2] … … 1674 1675 d = str(data).split("\n") 1675 1676 for s in d: 1676 m = re.findall(pattern, s)1677 if len(m ) > 0:1678 for mt in m :1679 s = s.replace(mt, colored(mt, 'red'))1677 match = re.findall(pattern, s) 1678 if len(match) > 0: 1679 for mt in match: 1680 s = s.replace(mt, colored(mt, 'red')) 1680 1681 print s 1681 1682 uOffset += len(data) … … 1688 1689 print "usage: findAssert vm <num>" 1689 1690 return 0 1690 mach = argsToMach(ctx, args)1691 mach = argsToMach(ctx, args) 1691 1692 if mach == None: 1692 1693 return 0 … … 1694 1695 log = 0 1695 1696 if (len(args) > 2): 1696 log= args[2]1697 log = args[2] 1697 1698 1698 1699 uOffset = 0 … … 1714 1715 context = context - 1 1715 1716 continue 1716 m = ere.findall(s)1717 if len(m ) > 0:1717 match = ere.findall(s) 1718 if len(match) > 0: 1718 1719 active = True 1719 1720 context = 50 … … 1724 1725 1725 1726 def evalCmd(ctx, args): 1726 expr = ' '.join(args[1:])1727 try:1727 expr = ' '.join(args[1:]) 1728 try: 1728 1729 exec expr 1729 except Exception, e:1730 printErr(ctx, e)1731 if g_ verbose:1730 except Exception, e: 1731 printErr(ctx, e) 1732 if g_fVerbose: 1732 1733 traceback.print_exc() 1733 return 01734 return 0 1734 1735 1735 1736 def reloadExtCmd(ctx, args): 1736 # maybe will want more args smartness1737 checkUserExtensions(ctx, commands, getHomeFolder(ctx))1738 autoCompletion(commands, ctx)1739 return 01737 # maybe will want more args smartness 1738 checkUserExtensions(ctx, commands, getHomeFolder(ctx)) 1739 autoCompletion(commands, ctx) 1740 return 0 1740 1741 1741 1742 def runScriptCmd(ctx, args): … … 1745 1746 try: 1746 1747 lf = open(args[1], 'r') 1747 except IOError, e:1748 print "cannot open:", args[1], ":",e1748 except IOError, e: 1749 print "cannot open:", args[1], ":", e 1749 1750 return 0 1750 1751 … … 1760 1761 break 1761 1762 1762 except Exception, e:1763 printErr(ctx, e)1764 if g_ verbose:1763 except Exception, e: 1764 printErr(ctx, e) 1765 if g_fVerbose: 1765 1766 traceback.print_exc() 1766 1767 lf.close() … … 1821 1822 vbox = ctx['global'].platform.connect(url, user, passwd) 1822 1823 ctx['vb'] = vbox 1823 print "Running VirtualBox version %s" %(vbox.version) 1824 try: 1825 print "Running VirtualBox version %s" % (vbox.version) 1826 except Exception, e: 1827 printErr(ctx, e) 1828 if g_fVerbose: 1829 traceback.print_exc() 1824 1830 ctx['perf'] = ctx['global'].getPerfCollector(ctx['vb']) 1825 1831 return 0 … … 1853 1859 pass 1854 1860 1855 [url, user,passwd] = ctx['wsinfo']1861 [url, user, passwd] = ctx['wsinfo'] 1856 1862 ctx['vb'] = ctx['global'].platform.connect(url, user, passwd) 1857 print "Running VirtualBox version %s" %(ctx['vb'].version) 1863 try: 1864 print "Running VirtualBox version %s" % (ctx['vb'].version) 1865 except Exception, e: 1866 printErr(ctx, e) 1867 if g_fVerbose: 1868 traceback.print_exc() 1858 1869 return 0 1859 1870 1860 1871 def exportVMCmd(ctx, args): 1861 import sys1862 1863 1872 if len(args) < 3: 1864 1873 print "usage: exportVm <machine> <path> <format> <license>" 1865 1874 return 0 1866 mach = argsToMach(ctx, args)1875 mach = argsToMach(ctx, args) 1867 1876 if mach is None: 1868 1877 return 0 1869 1878 path = args[2] 1870 1879 if (len(args) > 3): 1871 f ormat = args[3]1872 else: 1873 f ormat = "ovf-1.0"1880 fmt = args[3] 1881 else: 1882 fmt = "ovf-1.0" 1874 1883 if (len(args) > 4): 1875 lic ense= args[4]1876 else: 1877 lic ense= "GPL"1884 lic = args[4] 1885 else: 1886 lic = "GPL" 1878 1887 1879 1888 app = ctx['vb'].createAppliance() 1880 1889 desc = mach.export(app) 1881 desc.addDescription(ctx['global'].constants.VirtualSystemDescriptionType_License, lic ense, "")1882 p = app.write(format, path)1883 if (progressBar(ctx, p ) and int(p.resultCode) == 0):1884 print "Exported to %s in format %s" % (path, format)1885 else: 1886 reportError(ctx, p)1890 desc.addDescription(ctx['global'].constants.VirtualSystemDescriptionType_License, lic, "") 1891 progress = app.write(fmt, path) 1892 if (progressBar(ctx, progress) and int(progress.resultCode) == 0): 1893 print "Exported to %s in format %s" % (path, fmt) 1894 else: 1895 reportError(ctx, progress) 1887 1896 return 0 1888 1897 … … 1938 1947 '\n': 0x1c, 1939 1948 '`': 0x29 1940 } ;1949 } 1941 1950 1942 1951 extScancodes = { … … 1978 1987 'DOWN': [0xe0, 0x50], 1979 1988 'RIGHT': [0xe0, 0x4d], 1980 } ;1989 } 1981 1990 1982 1991 def keyDown(ch): … … 1986 1995 extCode = extScancodes.get(ch, []) 1987 1996 if len(extCode) == 0: 1988 print "bad ext", ch1997 print "bad ext", ch 1989 1998 return extCode 1990 1999 … … 1996 2005 1997 2006 def typeInGuest(console, text, delay): 1998 import time1999 2007 pressed = [] 2000 2008 group = False … … 2012 2020 # end group, release all keys 2013 2021 for c in pressed: 2014 2022 kbd.putScancodes(keyUp(c)) 2015 2023 pressed = [] 2016 2024 group = False … … 2058 2066 2059 2067 def typeGuestCmd(ctx, args): 2060 import sys2061 2062 2068 if len(args) < 3: 2063 2069 print "usage: typeGuest <machine> <text> <charDelay>" 2064 2070 return 0 2065 mach = argsToMach(ctx,args)2071 mach = argsToMach(ctx, args) 2066 2072 if mach is None: 2067 2073 return 0 … … 2074 2080 delay = 0.1 2075 2081 2076 gargs = [lambda ctx, mach,console,args: typeInGuest(console, text, delay)]2082 gargs = [lambda ctx, mach, console, args: typeInGuest(console, text, delay)] 2077 2083 cmdExistingVm(ctx, mach, 'guestlambda', gargs) 2078 2084 2079 2085 return 0 2080 2086 2081 def optId(verbose, id):2082 if verbose:2083 return ": "+id2084 else:2085 return ""2086 2087 def asSize(val, inBytes):2088 if inBytes:2089 return int(val)/(1024*1024)2090 else:2091 return int(val)2092 2093 def listMediaCmd(ctx, args):2094 if len(args) > 1:2095 verbose = int(args[1])2096 else:2097 verbose = False2098 hdds = ctx['global'].getArray(ctx['vb'], 'hardDisks')2099 print colCat(ctx,"Hard disks:")2100 for hdd in hdds:2101 if hdd.state != ctx['global'].constants.MediumState_Created:2102 hdd.refreshState()2103 print " %s (%s)%s %s [logical %s]" %(colPath(ctx,hdd.location), hdd.format, optId(verbose,hdd.id),colSizeM(ctx,asSize(hdd.size, True)), colSizeM(ctx,asSize(hdd.logicalSize, True)))2104 2105 dvds = ctx['global'].getArray(ctx['vb'], 'DVDImages')2106 print colCat(ctx,"CD/DVD disks:")2107 for dvd in dvds:2108 if dvd.state != ctx['global'].constants.MediumState_Created:2109 dvd.refreshState()2110 print " %s (%s)%s %s" %(colPath(ctx,dvd.location), dvd.format,optId(verbose,dvd.id),colSizeM(ctx,asSize(dvd.size, True)))2111 2112 floppys = ctx['global'].getArray(ctx['vb'], 'floppyImages')2113 print colCat(ctx,"Floppy disks:")2114 for floppy in floppys:2115 if floppy.state != ctx['global'].constants.MediumState_Created:2116 floppy.refreshState()2117 print " %s (%s)%s %s" %(colPath(ctx,floppy.location), floppy.format,optId(verbose,floppy.id), colSizeM(ctx,asSize(floppy.size, True)))2118 2119 return 02120 2121 def listUsbCmd(ctx, args):2122 if (len(args) > 1):2123 print "usage: listUsb"2124 return 02125 2126 host = ctx['vb'].host2127 for ud in ctx['global'].getArray(host, 'USBDevices'):2128 printHostUsbDev(ctx,ud)2129 2130 return 02131 2132 def findDevOfType(ctx, mach,type):2087 def optId(verbose, uuid): 2088 if verbose: 2089 return ": "+uuid 2090 else: 2091 return "" 2092 2093 def asSize(val, inBytes): 2094 if inBytes: 2095 return int(val)/(1024*1024) 2096 else: 2097 return int(val) 2098 2099 def listMediaCmd(ctx, args): 2100 if len(args) > 1: 2101 verbose = int(args[1]) 2102 else: 2103 verbose = False 2104 hdds = ctx['global'].getArray(ctx['vb'], 'hardDisks') 2105 print colCat(ctx, "Hard disks:") 2106 for hdd in hdds: 2107 if hdd.state != ctx['global'].constants.MediumState_Created: 2108 hdd.refreshState() 2109 print " %s (%s)%s %s [logical %s]" % (colPath(ctx, hdd.location), hdd.format, optId(verbose, hdd.id), colSizeM(ctx, asSize(hdd.size, True)), colSizeM(ctx, asSize(hdd.logicalSize, True))) 2110 2111 dvds = ctx['global'].getArray(ctx['vb'], 'DVDImages') 2112 print colCat(ctx, "CD/DVD disks:") 2113 for dvd in dvds: 2114 if dvd.state != ctx['global'].constants.MediumState_Created: 2115 dvd.refreshState() 2116 print " %s (%s)%s %s" % (colPath(ctx, dvd.location), dvd.format, optId(verbose, dvd.id), colSizeM(ctx, asSize(dvd.size, True))) 2117 2118 floppys = ctx['global'].getArray(ctx['vb'], 'floppyImages') 2119 print colCat(ctx, "Floppy disks:") 2120 for floppy in floppys: 2121 if floppy.state != ctx['global'].constants.MediumState_Created: 2122 floppy.refreshState() 2123 print " %s (%s)%s %s" % (colPath(ctx, floppy.location), floppy.format, optId(verbose, floppy.id), colSizeM(ctx, asSize(floppy.size, True))) 2124 2125 return 0 2126 2127 def listUsbCmd(ctx, args): 2128 if (len(args) > 1): 2129 print "usage: listUsb" 2130 return 0 2131 2132 host = ctx['vb'].host 2133 for ud in ctx['global'].getArray(host, 'USBDevices'): 2134 printHostUsbDev(ctx, ud) 2135 2136 return 0 2137 2138 def findDevOfType(ctx, mach, devtype): 2133 2139 atts = ctx['global'].getArray(mach, 'mediumAttachments') 2134 2140 for a in atts: 2135 if a.type == type:2141 if a.type == devtype: 2136 2142 return [a.controller, a.port, a.device] 2137 2143 return [None, 0, 0] 2138 2144 2139 def createHddCmd(ctx, args):2140 if (len(args) < 3):2141 print "usage: createHdd sizeM location type"2142 return 02143 2144 size = int(args[1])2145 loc = args[2]2146 if len(args) > 3:2147 format = args[3]2148 else:2149 format = "vdi"2150 2151 hdd = ctx['vb'].createHardDisk(format, loc)2152 progress = hdd.createBaseStorage(size, (ctx['global'].constants.MediumVariant_Standard, ))2153 if progressBar(ctx,progress) and hdd.id:2154 print "created HDD at %s as %s" %(colPath(ctx,hdd.location), hdd.id)2155 else:2156 print "cannot create disk (file %s exist?)" %(loc)2157 reportError(ctx,progress)2158 return 02159 2160 return 02161 2162 def registerHddCmd(ctx, args):2163 if (len(args) < 2):2164 print "usage: registerHdd location"2165 return 02166 2167 vb= ctx['vb']2168 loc = args[1]2169 setImageId = False2170 imageId = ""2171 setParentId = False2172 parentId = ""2173 hdd = vb.openMedium(loc, ctx['global'].constants.DeviceType_HardDisk, ctx['global'].constants.AccessMode_ReadWrite, false)2174 print "registered HDD as %s" %(hdd.id)2175 return 02176 2177 def controldevice(ctx, mach,args):2178 [ctr, port,slot,type,id] = args2179 mach.attachDevice(ctr, port, slot, type,id)2180 2181 def attachHddCmd(ctx, args):2182 if (len(args) < 3):2183 print "usage: attachHdd vm hdd controller port:slot"2184 return 02185 2186 mach = argsToMach(ctx,args)2187 if mach is None:2188 return 0 2189 vb= ctx['vb']2190 loc = args[2]2191 try:2192 hdd = vb.openMedium(loc, ctx['global'].constants.DeviceType_HardDisk, ctx['global'].constants.AccessMode_ReadWrite, false)2193 except:2194 print "no HDD with path %s registered" %(loc)2195 return 02196 if len(args) > 3:2197 ctr = args[3]2198 (port,slot) = args[4].split(":")2199 else:2200 [ctr, port, slot] = findDevOfType(ctx, mach, ctx['global'].constants.DeviceType_HardDisk)2201 2202 cmdClosedVm(ctx, mach, lambda ctx,mach,args: mach.attachDevice(ctr, port, slot, ctx['global'].constants.DeviceType_HardDisk,hdd.id))2203 return 02204 2205 def detachVmDevice(ctx, mach,args):2145 def createHddCmd(ctx, args): 2146 if (len(args) < 3): 2147 print "usage: createHdd sizeM location type" 2148 return 0 2149 2150 size = int(args[1]) 2151 loc = args[2] 2152 if len(args) > 3: 2153 fmt = args[3] 2154 else: 2155 fmt = "vdi" 2156 2157 hdd = ctx['vb'].createHardDisk(format, loc) 2158 progress = hdd.createBaseStorage(size, (ctx['global'].constants.MediumVariant_Standard, )) 2159 if progressBar(ctx,progress) and hdd.id: 2160 print "created HDD at %s as %s" % (colPath(ctx,hdd.location), hdd.id) 2161 else: 2162 print "cannot create disk (file %s exist?)" % (loc) 2163 reportError(ctx,progress) 2164 return 0 2165 2166 return 0 2167 2168 def registerHddCmd(ctx, args): 2169 if (len(args) < 2): 2170 print "usage: registerHdd location" 2171 return 0 2172 2173 vbox = ctx['vb'] 2174 loc = args[1] 2175 setImageId = False 2176 imageId = "" 2177 setParentId = False 2178 parentId = "" 2179 hdd = vbox.openMedium(loc, ctx['global'].constants.DeviceType_HardDisk, ctx['global'].constants.AccessMode_ReadWrite, false) 2180 print "registered HDD as %s" % (hdd.id) 2181 return 0 2182 2183 def controldevice(ctx, mach, args): 2184 [ctr, port, slot, devtype, uuid] = args 2185 mach.attachDevice(ctr, port, slot, devtype, uuid) 2186 2187 def attachHddCmd(ctx, args): 2188 if (len(args) < 3): 2189 print "usage: attachHdd vm hdd controller port:slot" 2190 return 0 2191 2192 mach = argsToMach(ctx, args) 2193 if mach is None: 2194 return 0 2195 vbox = ctx['vb'] 2196 loc = args[2] 2197 try: 2198 hdd = vbox.openMedium(loc, ctx['global'].constants.DeviceType_HardDisk, ctx['global'].constants.AccessMode_ReadWrite, false) 2199 except: 2200 print "no HDD with path %s registered" % (loc) 2201 return 0 2202 if len(args) > 3: 2203 ctr = args[3] 2204 (port, slot) = args[4].split(":") 2205 else: 2206 [ctr, port, slot] = findDevOfType(ctx, mach, ctx['global'].constants.DeviceType_HardDisk) 2207 2208 cmdClosedVm(ctx, mach, lambda ctx, mach, args: mach.attachDevice(ctr, port, slot, ctx['global'].constants.DeviceType_HardDisk, hdd.id)) 2209 return 0 2210 2211 def detachVmDevice(ctx, mach, args): 2206 2212 atts = ctx['global'].getArray(mach, 'mediumAttachments') 2207 2213 hid = args[0] … … 2211 2217 mach.detachDevice(a.controller, a.port, a.device) 2212 2218 2213 def detachMedium(ctx, mid,medium):2219 def detachMedium(ctx, mid, medium): 2214 2220 cmdClosedVm(ctx, machById(ctx, mid), detachVmDevice, [medium]) 2215 2221 2216 def detachHddCmd(ctx,args): 2217 if (len(args) < 3): 2218 print "usage: detachHdd vm hdd" 2219 return 0 2220 2221 mach = argsToMach(ctx,args) 2222 if mach is None: 2223 return 0 2224 vb = ctx['vb'] 2225 loc = args[2] 2226 try: 2227 hdd = vb.openMedium(loc, ctx['global'].constants.DeviceType_HardDisk, ctx['global'].constants.AccessMode_ReadWrite, false) 2228 except: 2229 print "no HDD with path %s registered" %(loc) 2230 return 0 2231 2232 detachMedium(ctx, mach.id, hdd) 2233 return 0 2234 2235 def unregisterHddCmd(ctx,args): 2236 if (len(args) < 2): 2237 print "usage: unregisterHdd path <vmunreg>" 2238 return 0 2239 2240 vb = ctx['vb'] 2241 loc = args[1] 2242 if (len(args) > 2): 2243 vmunreg = int(args[2]) 2244 else: 2245 vmunreg = 0 2246 try: 2247 hdd = vb.openMedium(loc, ctx['global'].constants.DeviceType_HardDisk, ctx['global'].constants.AccessMode_ReadWrite, false) 2248 except: 2249 print "no HDD with path %s registered" %(loc) 2250 return 0 2251 2252 if vmunreg != 0: 2253 machs = ctx['global'].getArray(hdd, 'machineIds') 2254 try: 2255 for m in machs: 2256 print "Trying to detach from %s" %(m) 2257 detachMedium(ctx, m, hdd) 2258 except Exception, e: 2259 print 'failed: ',e 2260 return 0 2261 hdd.close() 2262 return 0 2263 2264 def removeHddCmd(ctx,args): 2265 if (len(args) != 2): 2266 print "usage: removeHdd path" 2267 return 0 2268 2269 vb = ctx['vb'] 2270 loc = args[1] 2271 try: 2272 hdd = vb.openMedium(loc, ctx['global'].constants.DeviceType_HardDisk, ctx['global'].constants.AccessMode_ReadWrite, false) 2273 except: 2274 print "no HDD with path %s registered" %(loc) 2275 return 0 2276 2277 progress = hdd.deleteStorage() 2278 progressBar(ctx,progress) 2279 2280 return 0 2281 2282 def registerIsoCmd(ctx,args): 2283 if (len(args) < 2): 2284 print "usage: registerIso location" 2285 return 0 2286 vb = ctx['vb'] 2287 loc = args[1] 2288 iso = vb.openMedium(loc, ctx['global'].constants.DeviceType_DVD, ctx['global'].constants.AccessMode_ReadOnly, false) 2289 print "registered ISO as %s" %(iso.id) 2290 return 0 2291 2292 def unregisterIsoCmd(ctx,args): 2293 if (len(args) != 2): 2294 print "usage: unregisterIso path" 2295 return 0 2296 2297 vb = ctx['vb'] 2298 loc = args[1] 2299 try: 2300 dvd = vb.openMedium(loc, ctx['global'].constants.DeviceType_DVD, ctx['global'].constants.AccessMode_ReadOnly, false) 2301 except: 2302 print "no DVD with path %s registered" %(loc) 2303 return 0 2304 2305 progress = dvd.close() 2306 print "Unregistered ISO at %s" %(colPath(ctx,loc)) 2307 2308 return 0 2309 2310 def removeIsoCmd(ctx,args): 2311 if (len(args) != 2): 2312 print "usage: removeIso path" 2313 return 0 2314 2315 vb = ctx['vb'] 2316 loc = args[1] 2317 try: 2318 dvd = vb.openMedium(loc, ctx['global'].constants.DeviceType_DVD, ctx['global'].constants.AccessMode_ReadOnly, false) 2319 except: 2320 print "no DVD with path %s registered" %(loc) 2321 return 0 2322 2323 progress = dvd.deleteStorage() 2324 if progressBar(ctx,progress): 2325 print "Removed ISO at %s" %(colPath(ctx,dvd.location)) 2326 else: 2327 reportError(ctx,progress) 2328 return 0 2329 2330 def attachIsoCmd(ctx,args): 2331 if (len(args) < 3): 2332 print "usage: attachIso vm iso controller port:slot" 2333 return 0 2334 2335 mach = argsToMach(ctx,args) 2336 if mach is None: 2337 return 0 2338 vb = ctx['vb'] 2339 loc = args[2] 2340 try: 2341 dvd = vb.openMedium(loc, ctx['global'].constants.DeviceType_DVD, ctx['global'].constants.AccessMode_ReadOnly, false) 2342 except: 2343 print "no DVD with path %s registered" %(loc) 2344 return 0 2345 if len(args) > 3: 2346 ctr = args[3] 2347 (port,slot) = args[4].split(":") 2348 else: 2349 [ctr, port, slot] = findDevOfType(ctx, mach, ctx['global'].constants.DeviceType_DVD) 2350 cmdClosedVm(ctx, mach, lambda ctx,mach,args: mach.attachDevice(ctr, port, slot, ctx['global'].constants.DeviceType_DVD, dvd)) 2351 return 0 2352 2353 def detachIsoCmd(ctx,args): 2354 if (len(args) < 3): 2355 print "usage: detachIso vm iso" 2356 return 0 2357 2358 mach = argsToMach(ctx,args) 2359 if mach is None: 2360 return 0 2361 vb = ctx['vb'] 2362 loc = args[2] 2363 try: 2364 dvd = vb.openMedium(loc, ctx['global'].constants.DeviceType_DVD, ctx['global'].constants.AccessMode_ReadOnly, false) 2365 except: 2366 print "no DVD with path %s registered" %(loc) 2367 return 0 2368 2369 detachMedium(ctx, mach.id, dvd) 2370 return 0 2371 2372 def mountIsoCmd(ctx,args): 2373 if (len(args) < 3): 2374 print "usage: mountIso vm iso controller port:slot" 2375 return 0 2376 2377 mach = argsToMach(ctx,args) 2378 if mach is None: 2379 return 0 2380 vb = ctx['vb'] 2381 loc = args[2] 2382 try: 2383 dvd = vb.openMedium(loc, ctx['global'].constants.DeviceType_DVD, ctx['global'].constants.AccessMode_ReadOnly, false) 2384 except: 2385 print "no DVD with path %s registered" %(loc) 2386 return 0 2387 2388 if len(args) > 3: 2389 ctr = args[3] 2390 (port,slot) = args[4].split(":") 2391 else: 2392 # autodetect controller and location, just find first controller with media == DVD 2393 [ctr, port, slot] = findDevOfType(ctx, mach, ctx['global'].constants.DeviceType_DVD) 2394 2395 cmdExistingVm(ctx, mach, 'mountiso', [ctr, port, slot, dvd, True]) 2396 2397 return 0 2398 2399 def unmountIsoCmd(ctx,args): 2400 if (len(args) < 2): 2401 print "usage: unmountIso vm controller port:slot" 2402 return 0 2403 2404 mach = argsToMach(ctx,args) 2405 if mach is None: 2406 return 0 2407 vb = ctx['vb'] 2408 2409 if len(args) > 3: 2410 ctr = args[2] 2411 (port,slot) = args[3].split(":") 2412 else: 2413 # autodetect controller and location, just find first controller with media == DVD 2414 [ctr, port, slot] = findDevOfType(ctx, mach, ctx['global'].constants.DeviceType_DVD) 2415 2416 cmdExistingVm(ctx, mach, 'mountiso', [ctr, port, slot, None, True]) 2417 2418 return 0 2419 2420 def attachCtr(ctx,mach,args): 2421 [name, bus, type] = args 2222 def detachHddCmd(ctx, args): 2223 if (len(args) < 3): 2224 print "usage: detachHdd vm hdd" 2225 return 0 2226 2227 mach = argsToMach(ctx, args) 2228 if mach is None: 2229 return 0 2230 vbox = ctx['vb'] 2231 loc = args[2] 2232 try: 2233 hdd = vbox.openMedium(loc, ctx['global'].constants.DeviceType_HardDisk, ctx['global'].constants.AccessMode_ReadWrite, false) 2234 except: 2235 print "no HDD with path %s registered" % (loc) 2236 return 0 2237 2238 detachMedium(ctx, mach.id, hdd) 2239 return 0 2240 2241 def unregisterHddCmd(ctx, args): 2242 if (len(args) < 2): 2243 print "usage: unregisterHdd path <vmunreg>" 2244 return 0 2245 2246 vbox = ctx['vb'] 2247 loc = args[1] 2248 if (len(args) > 2): 2249 vmunreg = int(args[2]) 2250 else: 2251 vmunreg = 0 2252 try: 2253 hdd = vbox.openMedium(loc, ctx['global'].constants.DeviceType_HardDisk, ctx['global'].constants.AccessMode_ReadWrite, false) 2254 except: 2255 print "no HDD with path %s registered" % (loc) 2256 return 0 2257 2258 if vmunreg != 0: 2259 machs = ctx['global'].getArray(hdd, 'machineIds') 2260 try: 2261 for mach in machs: 2262 print "Trying to detach from %s" % (mach) 2263 detachMedium(ctx, mach, hdd) 2264 except Exception, e: 2265 print 'failed: ', e 2266 return 0 2267 hdd.close() 2268 return 0 2269 2270 def removeHddCmd(ctx, args): 2271 if (len(args) != 2): 2272 print "usage: removeHdd path" 2273 return 0 2274 2275 vbox = ctx['vb'] 2276 loc = args[1] 2277 try: 2278 hdd = vbox.openMedium(loc, ctx['global'].constants.DeviceType_HardDisk, ctx['global'].constants.AccessMode_ReadWrite, false) 2279 except: 2280 print "no HDD with path %s registered" % (loc) 2281 return 0 2282 2283 progress = hdd.deleteStorage() 2284 progressBar(ctx, progress) 2285 2286 return 0 2287 2288 def registerIsoCmd(ctx, args): 2289 if (len(args) < 2): 2290 print "usage: registerIso location" 2291 return 0 2292 2293 vbox = ctx['vb'] 2294 loc = args[1] 2295 iso = vbox.openMedium(loc, ctx['global'].constants.DeviceType_DVD, ctx['global'].constants.AccessMode_ReadOnly, false) 2296 print "registered ISO as %s" % (iso.id) 2297 return 0 2298 2299 def unregisterIsoCmd(ctx, args): 2300 if (len(args) != 2): 2301 print "usage: unregisterIso path" 2302 return 0 2303 2304 vbox = ctx['vb'] 2305 loc = args[1] 2306 try: 2307 dvd = vbox.openMedium(loc, ctx['global'].constants.DeviceType_DVD, ctx['global'].constants.AccessMode_ReadOnly, false) 2308 except: 2309 print "no DVD with path %s registered" % (loc) 2310 return 0 2311 2312 progress = dvd.close() 2313 print "Unregistered ISO at %s" % (colPath(ctx, loc)) 2314 2315 return 0 2316 2317 def removeIsoCmd(ctx, args): 2318 if (len(args) != 2): 2319 print "usage: removeIso path" 2320 return 0 2321 2322 vbox = ctx['vb'] 2323 loc = args[1] 2324 try: 2325 dvd = vbox.openMedium(loc, ctx['global'].constants.DeviceType_DVD, ctx['global'].constants.AccessMode_ReadOnly, false) 2326 except: 2327 print "no DVD with path %s registered" % (loc) 2328 return 0 2329 2330 progress = dvd.deleteStorage() 2331 if progressBar(ctx, progress): 2332 print "Removed ISO at %s" % (colPath(ctx, dvd.location)) 2333 else: 2334 reportError(ctx, progress) 2335 return 0 2336 2337 def attachIsoCmd(ctx, args): 2338 if (len(args) < 3): 2339 print "usage: attachIso vm iso controller port:slot" 2340 return 0 2341 2342 mach = argsToMach(ctx, args) 2343 if mach is None: 2344 return 0 2345 vbox = ctx['vb'] 2346 loc = args[2] 2347 try: 2348 dvd = vbox.openMedium(loc, ctx['global'].constants.DeviceType_DVD, ctx['global'].constants.AccessMode_ReadOnly, false) 2349 except: 2350 print "no DVD with path %s registered" % (loc) 2351 return 0 2352 if len(args) > 3: 2353 ctr = args[3] 2354 (port, slot) = args[4].split(":") 2355 else: 2356 [ctr, port, slot] = findDevOfType(ctx, mach, ctx['global'].constants.DeviceType_DVD) 2357 cmdClosedVm(ctx, mach, lambda ctx, mach, args: mach.attachDevice(ctr, port, slot, ctx['global'].constants.DeviceType_DVD, dvd)) 2358 return 0 2359 2360 def detachIsoCmd(ctx, args): 2361 if (len(args) < 3): 2362 print "usage: detachIso vm iso" 2363 return 0 2364 2365 mach = argsToMach(ctx, args) 2366 if mach is None: 2367 return 0 2368 vbox = ctx['vb'] 2369 loc = args[2] 2370 try: 2371 dvd = vbox.openMedium(loc, ctx['global'].constants.DeviceType_DVD, ctx['global'].constants.AccessMode_ReadOnly, false) 2372 except: 2373 print "no DVD with path %s registered" % (loc) 2374 return 0 2375 2376 detachMedium(ctx, mach.id, dvd) 2377 return 0 2378 2379 def mountIsoCmd(ctx, args): 2380 if (len(args) < 3): 2381 print "usage: mountIso vm iso controller port:slot" 2382 return 0 2383 2384 mach = argsToMach(ctx, args) 2385 if mach is None: 2386 return 0 2387 vbox = ctx['vb'] 2388 loc = args[2] 2389 try: 2390 dvd = vbox.openMedium(loc, ctx['global'].constants.DeviceType_DVD, ctx['global'].constants.AccessMode_ReadOnly, false) 2391 except: 2392 print "no DVD with path %s registered" % (loc) 2393 return 0 2394 2395 if len(args) > 3: 2396 ctr = args[3] 2397 (port, slot) = args[4].split(":") 2398 else: 2399 # autodetect controller and location, just find first controller with media == DVD 2400 [ctr, port, slot] = findDevOfType(ctx, mach, ctx['global'].constants.DeviceType_DVD) 2401 2402 cmdExistingVm(ctx, mach, 'mountiso', [ctr, port, slot, dvd, True]) 2403 2404 return 0 2405 2406 def unmountIsoCmd(ctx, args): 2407 if (len(args) < 2): 2408 print "usage: unmountIso vm controller port:slot" 2409 return 0 2410 2411 mach = argsToMach(ctx, args) 2412 if mach is None: 2413 return 0 2414 vbox = ctx['vb'] 2415 2416 if len(args) > 3: 2417 ctr = args[2] 2418 (port, slot) = args[3].split(":") 2419 else: 2420 # autodetect controller and location, just find first controller with media == DVD 2421 [ctr, port, slot] = findDevOfType(ctx, mach, ctx['global'].constants.DeviceType_DVD) 2422 2423 cmdExistingVm(ctx, mach, 'mountiso', [ctr, port, slot, None, True]) 2424 2425 return 0 2426 2427 def attachCtr(ctx, mach, args): 2428 [name, bus, ctrltype] = args 2422 2429 ctr = mach.addStorageController(name, bus) 2423 if type != None:2424 ctr.controllerType = type2425 2426 def attachCtrCmd(ctx, args):2427 if (len(args) < 4):2428 print "usage: attachCtr vm cname bus <type>"2429 return 02430 2431 if len(args) > 4:2432 type = enumFromString(ctx,'StorageControllerType', args[4])2433 iftype == None:2434 print "Controller type %s unknown" %(args[4])2435 return 02436 else:2437 type = None2438 2439 mach = argsToMach(ctx,args)2440 if mach is None:2441 return 0 2442 bus = enumFromString(ctx,'StorageBus', args[3])2443 if bus is None:2444 print "Bus type %s unknown" %(args[3])2445 return 02446 name = args[2]2447 cmdClosedVm(ctx, mach, attachCtr, [name, bus,type])2448 return 02449 2450 def detachCtrCmd(ctx, args):2451 if (len(args) < 3):2452 print "usage: detachCtr vm name"2453 return 02454 2455 mach = argsToMach(ctx,args)2456 if mach is None:2457 return 0 2458 ctr = args[2]2459 cmdClosedVm(ctx, mach, lambda ctx,mach,args: mach.removeStorageController(ctr))2460 return 02461 2462 def usbctr(ctx, mach,console,args):2430 if ctrltype != None: 2431 ctr.controllerType = ctrltype 2432 2433 def attachCtrCmd(ctx, args): 2434 if (len(args) < 4): 2435 print "usage: attachCtr vm cname bus <type>" 2436 return 0 2437 2438 if len(args) > 4: 2439 ctrltype = enumFromString(ctx, 'StorageControllerType', args[4]) 2440 if ctrltype == None: 2441 print "Controller type %s unknown" % (args[4]) 2442 return 0 2443 else: 2444 ctrltype = None 2445 2446 mach = argsToMach(ctx, args) 2447 if mach is None: 2448 return 0 2449 bus = enumFromString(ctx, 'StorageBus', args[3]) 2450 if bus is None: 2451 print "Bus type %s unknown" % (args[3]) 2452 return 0 2453 name = args[2] 2454 cmdClosedVm(ctx, mach, attachCtr, [name, bus, ctrltype]) 2455 return 0 2456 2457 def detachCtrCmd(ctx, args): 2458 if (len(args) < 3): 2459 print "usage: detachCtr vm name" 2460 return 0 2461 2462 mach = argsToMach(ctx, args) 2463 if mach is None: 2464 return 0 2465 ctr = args[2] 2466 cmdClosedVm(ctx, mach, lambda ctx, mach, args: mach.removeStorageController(ctr)) 2467 return 0 2468 2469 def usbctr(ctx, mach, console, args): 2463 2470 if (args[0]): 2464 2471 console.attachUSBDevice(args[1]) … … 2466 2473 console.detachUSBDevice(args[1]) 2467 2474 2468 def attachUsbCmd(ctx, args):2469 if (len(args) < 3):2470 print "usage: attachUsb vm deviceuid"2471 return 02472 2473 mach = argsToMach(ctx,args)2474 if mach is None:2475 return 0 2476 dev = args[2]2477 cmdExistingVm(ctx, mach, 'guestlambda', [usbctr,True,dev])2478 return 02479 2480 def detachUsbCmd(ctx, args):2481 if (len(args) < 3):2482 print "usage: detachUsb vm deviceuid"2483 return 02484 2485 mach = argsToMach(ctx,args)2486 if mach is None:2487 return 0 2488 dev = args[2]2489 cmdExistingVm(ctx, mach, 'guestlambda', [usbctr,False,dev])2490 return 02491 2492 2493 def guiCmd(ctx, args):2494 if (len(args) > 1):2495 print "usage: gui"2496 return 02497 2498 binDir = ctx['global'].getBinDir()2499 2500 vbox = os.path.join(binDir, 'VirtualBox')2501 try:2475 def attachUsbCmd(ctx, args): 2476 if (len(args) < 3): 2477 print "usage: attachUsb vm deviceuid" 2478 return 0 2479 2480 mach = argsToMach(ctx, args) 2481 if mach is None: 2482 return 0 2483 dev = args[2] 2484 cmdExistingVm(ctx, mach, 'guestlambda', [usbctr, True, dev]) 2485 return 0 2486 2487 def detachUsbCmd(ctx, args): 2488 if (len(args) < 3): 2489 print "usage: detachUsb vm deviceuid" 2490 return 0 2491 2492 mach = argsToMach(ctx, args) 2493 if mach is None: 2494 return 0 2495 dev = args[2] 2496 cmdExistingVm(ctx, mach, 'guestlambda', [usbctr, False, dev]) 2497 return 0 2498 2499 2500 def guiCmd(ctx, args): 2501 if (len(args) > 1): 2502 print "usage: gui" 2503 return 0 2504 2505 binDir = ctx['global'].getBinDir() 2506 2507 vbox = os.path.join(binDir, 'VirtualBox') 2508 try: 2502 2509 os.system(vbox) 2503 except KeyboardInterrupt:2510 except KeyboardInterrupt: 2504 2511 # to allow interruption 2505 2512 pass 2506 return 02507 2508 def shareFolderCmd(ctx, args):2513 return 0 2514 2515 def shareFolderCmd(ctx, args): 2509 2516 if (len(args) < 4): 2510 2517 print "usage: shareFolder vm path name <writable> <persistent>" 2511 2518 return 0 2512 2519 2513 mach = argsToMach(ctx, args)2520 mach = argsToMach(ctx, args) 2514 2521 if mach is None: 2515 2522 return 0 … … 2525 2532 persistent = True 2526 2533 if persistent: 2527 cmdClosedVm(ctx, mach, lambda ctx, mach,args: mach.createSharedFolder(name, path, writable), [])2528 else: 2529 cmdExistingVm(ctx, mach, 'guestlambda', [lambda ctx, mach,console,args: console.createSharedFolder(name, path, writable)])2530 return 0 2531 2532 def unshareFolderCmd(ctx, args):2534 cmdClosedVm(ctx, mach, lambda ctx, mach, args: mach.createSharedFolder(name, path, writable), []) 2535 else: 2536 cmdExistingVm(ctx, mach, 'guestlambda', [lambda ctx, mach, console, args: console.createSharedFolder(name, path, writable)]) 2537 return 0 2538 2539 def unshareFolderCmd(ctx, args): 2533 2540 if (len(args) < 3): 2534 2541 print "usage: unshareFolder vm name" 2535 2542 return 0 2536 2543 2537 mach = argsToMach(ctx, args)2544 mach = argsToMach(ctx, args) 2538 2545 if mach is None: 2539 2546 return 0 … … 2542 2549 for sf in ctx['global'].getArray(mach, 'sharedFolders'): 2543 2550 if sf.name == name: 2544 cmdClosedVm(ctx, mach, lambda ctx, mach,args: mach.removeSharedFolder(name), [])2551 cmdClosedVm(ctx, mach, lambda ctx, mach, args: mach.removeSharedFolder(name), []) 2545 2552 found = True 2546 2553 break 2547 2554 if not found: 2548 cmdExistingVm(ctx, mach, 'guestlambda', [lambda ctx, mach,console,args: console.removeSharedFolder(name)])2549 return 0 2550 2551 2552 def snapshotCmd(ctx, args):2555 cmdExistingVm(ctx, mach, 'guestlambda', [lambda ctx, mach, console, args: console.removeSharedFolder(name)]) 2556 return 0 2557 2558 2559 def snapshotCmd(ctx, args): 2553 2560 if (len(args) < 2 or args[1] == 'help'): 2554 2561 print "Take snapshot: snapshot vm take name <description>" … … 2557 2564 return 0 2558 2565 2559 mach = argsToMach(ctx, args)2566 mach = argsToMach(ctx, args) 2560 2567 if mach is None: 2561 2568 return 0 … … 2570 2577 else: 2571 2578 desc = "" 2572 cmdAnyVm(ctx, mach, lambda ctx, mach,console,args: progressBar(ctx, console.takeSnapshot(name,desc)))2579 cmdAnyVm(ctx, mach, lambda ctx, mach, console, args: progressBar(ctx, console.takeSnapshot(name, desc))) 2573 2580 return 0 2574 2581 … … 2579 2586 name = args[3] 2580 2587 snap = mach.findSnapshot(name) 2581 cmdAnyVm(ctx, mach, lambda ctx, mach,console,args: progressBar(ctx, console.restoreSnapshot(snap)))2588 cmdAnyVm(ctx, mach, lambda ctx, mach, console, args: progressBar(ctx, console.restoreSnapshot(snap))) 2582 2589 return 0 2583 2590 … … 2587 2594 return 0 2588 2595 snap = mach.currentSnapshot() 2589 cmdAnyVm(ctx, mach, lambda ctx, mach,console,args: progressBar(ctx, console.restoreSnapshot(snap)))2596 cmdAnyVm(ctx, mach, lambda ctx, mach, console, args: progressBar(ctx, console.restoreSnapshot(snap))) 2590 2597 return 0 2591 2598 … … 2596 2603 name = args[3] 2597 2604 snap = mach.findSnapshot(name) 2598 cmdAnyVm(ctx, mach, lambda ctx, mach,console,args: progressBar(ctx, console.deleteSnapshot(snap.id)))2599 return 0 2600 2601 print "Command '%s' is unknown" % (cmd)2605 cmdAnyVm(ctx, mach, lambda ctx, mach, console, args: progressBar(ctx, console.deleteSnapshot(snap.id))) 2606 return 0 2607 2608 print "Command '%s' is unknown" % (cmd) 2602 2609 return 0 2603 2610 … … 2637 2644 print natAlias.__doc__ 2638 2645 return (1, None) 2639 nat.aliasMode = int(nat.aliasMode) | alias[args[a]] ;2646 nat.aliasMode = int(nat.aliasMode) | alias[args[a]] 2640 2647 return (0, None) 2641 2648 … … 2648 2655 """ 2649 2656 if len(args) == 1: 2650 (mtu, socksndbuf, sockrcvbuf, tcpsndwnd, tcprcvwnd) = nat.getNetworkSettings() ;2657 (mtu, socksndbuf, sockrcvbuf, tcpsndwnd, tcprcvwnd) = nat.getNetworkSettings() 2651 2658 if mtu == 0: mtu = 1500 2652 2659 if socksndbuf == 0: socksndbuf = 64 … … 2654 2661 if tcpsndwnd == 0: tcpsndwnd = 64 2655 2662 if tcprcvwnd == 0: tcprcvwnd = 64 2656 msg = 'mtu:%s socket(snd:%s, rcv:%s) tcpwnd(snd:%s, rcv:%s)' % (mtu, socksndbuf, sockrcvbuf, tcpsndwnd, tcprcvwnd) ;2663 msg = 'mtu:%s socket(snd:%s, rcv:%s) tcpwnd(snd:%s, rcv:%s)' % (mtu, socksndbuf, sockrcvbuf, tcpsndwnd, tcprcvwnd) 2657 2664 return (0, [msg]) 2658 2665 else: … … 2687 2694 else: 2688 2695 nat.DNSPassDomain = 'passdomain' in args 2689 nat.DNSProxy = 2690 nat.DNSUseHostResolver = 2696 nat.DNSProxy = 'proxy' in args 2697 nat.DNSUseHostResolver = 'usehostresolver' in args 2691 2698 return (0, None) 2692 2699 … … 2704 2711 if server is None: 2705 2712 server = '10.0.%d/24' % (int(nicnum) + 2) 2706 (server, mask) = server.split('/')2713 (server, mask) = server.split('/') 2707 2714 while server.count('.') != 3: 2708 2715 server += '.0' 2709 (a, b,c,d) = server.split('.')2710 server = '%d.%d.%d.4' % (a, b,c)2716 (a, b, c, d) = server.split('.') 2717 server = '%d.%d.%d.4' % (a, b, c) 2711 2718 prefix = nat.TFTPPrefix 2712 2719 if prefix is None: … … 2746 2753 pfs = ctx['global'].getArray(nat, 'redirects') 2747 2754 for pf in pfs: 2748 (pfnme, pfp, pfhip, pfhp, pfgip, pfgp) = str(pf).split(', ')2755 (pfnme, pfp, pfhip, pfhp, pfgip, pfgp) = str(pf).split(', ') 2749 2756 msg.append('%s: %s %s:%s => %s:%s' % (pfnme, proto[int(pfp)], pfhip, pfhp, pfgip, pfgp)) 2750 2757 return (0, msg) # msg is array … … 2841 2848 if len(cmdargs) > 1: 2842 2849 rosession = 0 2843 session = ctx['global'].openMachineSession(mach, False) ;2844 mach = session.machine ;2850 session = ctx['global'].openMachineSession(mach, False) 2851 mach = session.machine 2845 2852 2846 2853 adapter = mach.getNetworkAdapter(nicnum) … … 2884 2891 def nicLineSpeedSubCmd(ctx, vm, nicnum, adapter, args): 2885 2892 if len(args) == 1: 2886 r = '%d kbps'% (adapter.lineSpeed)2893 r = '%d kbps'% (adapter.lineSpeed) 2887 2894 return (0, r) 2888 2895 else: … … 2911 2918 if len(args) == 1: 2912 2919 nictypes = ctx['const'].all_values('NetworkAdapterType') 2913 for nin nictypes.keys():2914 if str(adapter.adapterType) == str(nictypes[ n]):2915 return (0, str( n))2920 for key in nictypes.keys(): 2921 if str(adapter.adapterType) == str(nictypes[key]): 2922 return (0, str(key)) 2916 2923 return (1, None) 2917 2924 else: … … 3014 3021 if len(args) < 3 \ 3015 3022 or int(args[2]) not in range(0, ctx['vb'].systemProperties.getMaxNetworkAdapters(vm.chipsetType)): 3016 print 'please specify adapter num %d isn\'t in range [0-%d]'%(args[2], ctx['vb'].systemProperties.getMaxNetworkAdapters(vm.chipsetType))3017 3023 print 'please specify adapter num %d isn\'t in range [0-%d]'% (args[2], ctx['vb'].systemProperties.getMaxNetworkAdapters(vm.chipsetType)) 3024 return 0 3018 3025 nicnum = int(args[2]) 3019 3026 cmdargs = args[3:] … … 3025 3032 (rc, report) = niccomand[func](ctx, vm, nicnum, adapter, cmdargs) 3026 3033 if rc == 0: 3027 3034 vm.saveSettings() 3028 3035 if report is not None: 3029 3036 print '%s nic %d %s: %s' % (vm.name, nicnum, args[3], report) … … 3034 3041 def promptCmd(ctx, args): 3035 3042 if len(args) < 2: 3036 print "Current prompt: '%s'" % (ctx['prompt'])3043 print "Current prompt: '%s'" % (ctx['prompt']) 3037 3044 return 0 3038 3045 … … 3047 3054 scope = args[1] 3048 3055 cmd = args[2] 3049 elems = eval_xpath(ctx, scope)3056 elems = eval_xpath(ctx, scope) 3050 3057 try: 3051 3058 for e in elems: … … 3062 3069 cmdargs = args[1:] 3063 3070 cmdargs.insert(1, '') 3064 for m in getMachines(ctx):3065 cmdargs[1] = m .id3071 for mach in getMachines(ctx): 3072 cmdargs[1] = mach.id 3066 3073 runCommandArgs(ctx, cmdargs) 3067 3074 return 0 … … 3071 3078 print "usage: recordDemo vm filename (duration)" 3072 3079 return 0 3073 mach = argsToMach(ctx, args)3080 mach = argsToMach(ctx, args) 3074 3081 if mach == None: 3075 3082 return 0 … … 3078 3085 if len(args) > 3: 3079 3086 dur = float(args[3]) 3080 cmdExistingVm(ctx, mach, 'guestlambda', [lambda ctx, mach,console,args: recordDemo(ctx, console, filename, dur)])3087 cmdExistingVm(ctx, mach, 'guestlambda', [lambda ctx, mach, console, args: recordDemo(ctx, console, filename, dur)]) 3081 3088 return 0 3082 3089 … … 3085 3092 print "usage: playbackDemo vm filename (duration)" 3086 3093 return 0 3087 mach = argsToMach(ctx, args)3094 mach = argsToMach(ctx, args) 3088 3095 if mach == None: 3089 3096 return 0 … … 3092 3099 if len(args) > 3: 3093 3100 dur = float(args[3]) 3094 cmdExistingVm(ctx, mach, 'guestlambda', [lambda ctx, mach,console,args: playbackDemo(ctx, console, filename, dur)])3095 return 0 3096 3097 3098 def pciAddr(ctx, addr):3099 str = "%02x:%02x.%d" %(addr >> 8, (addr & 0xff) >> 3, addr & 7)3100 return colPci(ctx, str )3101 cmdExistingVm(ctx, mach, 'guestlambda', [lambda ctx, mach, console, args: playbackDemo(ctx, console, filename, dur)]) 3102 return 0 3103 3104 3105 def pciAddr(ctx, addr): 3106 strg = "%02x:%02x.%d" % (addr >> 8, (addr & 0xff) >> 3, addr & 7) 3107 return colPci(ctx, strg) 3101 3108 3102 3109 def lspci(ctx, console): … … 3104 3111 for a in assigned: 3105 3112 if a.isPhysicalDevice: 3106 print "%s: assigned host device %s guest %s" % (colDev(ctx, a.name), pciAddr(ctx, a.hostAddress), pciAddr(ctx, a.guestAddress))3113 print "%s: assigned host device %s guest %s" % (colDev(ctx, a.name), pciAddr(ctx, a.hostAddress), pciAddr(ctx, a.guestAddress)) 3107 3114 3108 3115 atts = ctx['global'].getArray(console, 'attachedPCIDevices') 3109 3116 for a in atts: 3110 3117 if a.isPhysicalDevice: 3111 print "%s: physical, guest %s, host %s" % (colDev(ctx, a.name), pciAddr(ctx, a.guestAddress), pciAddr(ctx, a.hostAddress))3118 print "%s: physical, guest %s, host %s" % (colDev(ctx, a.name), pciAddr(ctx, a.guestAddress), pciAddr(ctx, a.hostAddress)) 3112 3119 else: 3113 print "%s: virtual, guest %s" % (colDev(ctx, a.name), pciAddr(ctx, a.guestAddress))3120 print "%s: virtual, guest %s" % (colDev(ctx, a.name), pciAddr(ctx, a.guestAddress)) 3114 3121 return 3115 3122 3116 def parsePci(str ):3123 def parsePci(strg): 3117 3124 pcire = re.compile(r'(?P<b>[0-9a-fA-F]+):(?P<d>[0-9a-fA-F]+)\.(?P<f>\d)') 3118 m = pcire.search(str)3119 if m is None:3125 match = pcire.search(strg) 3126 if match is None: 3120 3127 return -1 3121 dict = m.groupdict()3122 return ((int( dict['b'], 16)) << 8) | ((int(dict['d'], 16)) << 3) | int(dict['f'])3128 pdict = match.groupdict() 3129 return ((int(pdict['b'], 16)) << 8) | ((int(pdict['d'], 16)) << 3) | int(pdict['f']) 3123 3130 3124 3131 def lspciCmd(ctx, args): … … 3126 3133 print "usage: lspci vm" 3127 3134 return 0 3128 mach = argsToMach(ctx, args)3129 if mach == None: 3130 return 0 3131 cmdExistingVm(ctx, mach, 'guestlambda', [lambda ctx, mach,console,args: lspci(ctx, console)])3135 mach = argsToMach(ctx, args) 3136 if mach == None: 3137 return 0 3138 cmdExistingVm(ctx, mach, 'guestlambda', [lambda ctx, mach, console, args: lspci(ctx, console)]) 3132 3139 return 0 3133 3140 … … 3136 3143 print "usage: attachpci vm hostpci <guestpci>" 3137 3144 return 0 3138 mach = argsToMach(ctx, args)3145 mach = argsToMach(ctx, args) 3139 3146 if mach == None: 3140 3147 return 0 3141 3148 hostaddr = parsePci(args[2]) 3142 3149 if hostaddr == -1: 3143 print "invalid host PCI %s, accepted format 01:02.3 for bus 1, device 2, function 3" % (args[2])3150 print "invalid host PCI %s, accepted format 01:02.3 for bus 1, device 2, function 3" % (args[2]) 3144 3151 return 0 3145 3152 … … 3147 3154 guestaddr = parsePci(args[3]) 3148 3155 if guestaddr == -1: 3149 print "invalid guest PCI %s, accepted format 01:02.3 for bus 1, device 2, function 3" % (args[3])3156 print "invalid guest PCI %s, accepted format 01:02.3 for bus 1, device 2, function 3" % (args[3]) 3150 3157 return 0 3151 3158 else: 3152 3159 guestaddr = hostaddr 3153 cmdClosedVm(ctx, mach, lambda ctx, mach,a: mach.attachHostPCIDevice(hostaddr, guestaddr, True))3160 cmdClosedVm(ctx, mach, lambda ctx, mach, a: mach.attachHostPCIDevice(hostaddr, guestaddr, True)) 3154 3161 return 0 3155 3162 … … 3158 3165 print "usage: detachpci vm hostpci" 3159 3166 return 0 3160 mach = argsToMach(ctx, args)3167 mach = argsToMach(ctx, args) 3161 3168 if mach == None: 3162 3169 return 0 3163 3170 hostaddr = parsePci(args[2]) 3164 3171 if hostaddr == -1: 3165 print "invalid host PCI %s, accepted format 01:02.3 for bus 1, device 2, function 3" % (args[2])3166 return 0 3167 3168 cmdClosedVm(ctx, mach, lambda ctx, mach,a: mach.detachHostPCIDevice(hostaddr))3172 print "invalid host PCI %s, accepted format 01:02.3 for bus 1, device 2, function 3" % (args[2]) 3173 return 0 3174 3175 cmdClosedVm(ctx, mach, lambda ctx, mach, a: mach.detachHostPCIDevice(hostaddr)) 3169 3176 return 0 3170 3177 … … 3208 3215 'verbose':['Toggle verbosity', verboseCmd, 0], 3209 3216 'setvar':['Set VMs variable: setvar Fedora BIOSSettings.ACPIEnabled True', setvarCmd, 0], 3210 'eval':['Evaluate arbitrary Python construction: eval \'for m in getMachines(ctx): print m.name, "has",m.memorySize,"M"\'', evalCmd, 0],3217 'eval':['Evaluate arbitrary Python construction: eval \'for m in getMachines(ctx): print m.name, "has", m.memorySize, "M"\'', evalCmd, 0], 3211 3218 'quit':['Exits', quitCmd, 0], 3212 3219 'host':['Show host information', hostCmd, 0], … … 3229 3236 'typeGuest':['Type arbitrary text in guest: typeGuest Linux "^lls\\n&UP;&BKSP;ess /etc/hosts\\nq^c" 0.7', typeGuestCmd, 0], 3230 3237 'openportal':['Open portal for teleportation of VM from another box (see teleport): openportal Win 8000 <passwd>', openportalCmd, 0], 3231 'closeportal':['Close teleportation portal (see openportal, teleport): closeportal Win', closeportalCmd, 0],3238 'closeportal':['Close teleportation portal (see openportal, teleport): closeportal Win', closeportalCmd, 0], 3232 3239 'getextra':['Get extra data, empty key lists all: getextra <vm|global> <key>', getExtraDataCmd, 0], 3233 3240 'setextra':['Set extra data, empty value removes key: setextra <vm|global> <key> <value>', setExtraDataCmd, 0], … … 3276 3283 if aliases.get(c, None) != None: 3277 3284 c = aliases[c] 3278 ci = commands.get(c, None)3285 ci = commands.get(c, None) 3279 3286 if ci == None: 3280 print "Unknown command: '%s', type 'help' for list of known commands" % (c)3287 print "Unknown command: '%s', type 'help' for list of known commands" % (c) 3281 3288 return 0 3282 3289 if ctx['remote'] and ctx['vb'] is None: 3283 3290 if c not in ['connect', 'reconnect', 'help', 'quit']: 3284 print "First connect to remote server with %s command." % (colored('connect', 'blue'))3291 print "First connect to remote server with %s command." % (colored('connect', 'blue')) 3285 3292 return 0 3286 3293 return ci[1](ctx, args) … … 3310 3317 # they will also be picked up, so this way one can exchange 3311 3318 # shell extensions easily. 3312 def addExtsFromFile(ctx, cmds, file ):3313 if not os.path.isfile(file ):3319 def addExtsFromFile(ctx, cmds, filename): 3320 if not os.path.isfile(filename): 3314 3321 return 3315 3322 d = {} 3316 3323 try: 3317 execfile(file , d, d)3318 for (k, v) in d['commands'].items():3319 if g_ verbose:3320 print "customize: adding \"%s\" - %s" % (k, v[0])3321 cmds[k] = [v[0], v[1], file ]3324 execfile(filename, d, d) 3325 for (k, v) in d['commands'].items(): 3326 if g_fVerbose: 3327 print "customize: adding \"%s\" - %s" % (k, v[0]) 3328 cmds[k] = [v[0], v[1], filename] 3322 3329 except: 3323 print "Error loading user extensions from %s" % (file)3330 print "Error loading user extensions from %s" % (filename) 3324 3331 traceback.print_exc() 3325 3332 … … 3337 3344 # not editor temporary files, please. 3338 3345 if e.endswith('.py'): 3339 addExtsFromFile(ctx, cmds, os.path.join(shextdir, e))3346 addExtsFromFile(ctx, cmds, os.path.join(shextdir, e)) 3340 3347 3341 3348 def getHomeFolder(ctx): … … 3356 3363 vbox = ctx['vb'] 3357 3364 if vbox is not None: 3358 print "Running VirtualBox version %s" %(vbox.version) 3365 try: 3366 print "Running VirtualBox version %s" % (vbox.version) 3367 except Exception, e: 3368 printErr(ctx, e) 3369 if g_fVerbose: 3370 traceback.print_exc() 3359 3371 ctx['perf'] = None # ctx['global'].getPerfCollector(vbox) 3360 3372 else: … … 3364 3376 checkUserExtensions(ctx, commands, home) 3365 3377 if platform.system() in ['Windows', 'Microsoft']: 3366 global g_ hascolors3367 g_ hascolors = False3368 hist_file =os.path.join(home, ".vboxshellhistory")3378 global g_fHasColors 3379 g_fHasColors = False 3380 hist_file = os.path.join(home, ".vboxshellhistory") 3369 3381 autoCompletion(commands, ctx) 3370 3382 3371 if g_ hasreadline and os.path.exists(hist_file):3383 if g_fHasReadline and os.path.exists(hist_file): 3372 3384 readline.read_history_file(hist_file) 3373 3385 … … 3375 3387 # last 150 secs maximum, (sample every 10 secs and keep up to 15 samples) 3376 3388 if ctx['perf']: 3377 try:3378 ctx['perf'].setup(['*'], [vbox.host], 10, 15)3379 except:3380 pass3389 try: 3390 ctx['perf'].setup(['*'], [vbox.host], 10, 15) 3391 except: 3392 pass 3381 3393 cmds = [] 3382 3394 3383 if g_ cmd is not None:3384 cmds = g_ cmd.split(';')3395 if g_sCmd is not None: 3396 cmds = g_sCmd.split(';') 3385 3397 it = cmds.__iter__() 3386 3398 3387 3399 while True: 3388 3400 try: 3389 if g_ batchmode:3390 cmd = 'runScript %s'% (g_scripfile)3391 elif g_ cmd is not None:3401 if g_fBatchMode: 3402 cmd = 'runScript %s'% (g_sScriptFile) 3403 elif g_sCmd is not None: 3392 3404 cmd = it.next() 3393 3405 else: … … 3395 3407 done = runCommand(ctx, cmd) 3396 3408 if done != 0: break 3397 if g_ batchmode:3409 if g_fBatchMode: 3398 3410 break 3399 3411 except KeyboardInterrupt: … … 3403 3415 except EOFError: 3404 3416 break 3405 except Exception, e:3406 printErr(ctx, e)3407 if g_ verbose:3417 except Exception, e: 3418 printErr(ctx, e) 3419 if g_fVerbose: 3408 3420 traceback.print_exc() 3409 3421 ctx['global'].waitForEvents(0) … … 3411 3423 # There is no need to disable metric collection. This is just an example. 3412 3424 if ct['perf']: 3413 ctx['perf'].disable(['*'], [vbox.host])3425 ctx['perf'].disable(['*'], [vbox.host]) 3414 3426 except: 3415 3427 pass 3416 if g_ hasreadline:3428 if g_fHasReadline: 3417 3429 readline.write_history_file(hist_file) 3418 3430 … … 3421 3433 return runCommandArgs(ctx, args) 3422 3434 3423 def runGuestCommandCb(ctx, id, guestLambda, args):3424 mach = machById(ctx,id)3435 def runGuestCommandCb(ctx, uuid, guestLambda, args): 3436 mach = machById(ctx, uuid) 3425 3437 if mach == None: 3426 3438 return 0 … … 3441 3453 parse.add_option("-c", dest="command_line", help = "command sequence to execute") 3442 3454 parse.add_option("-o", dest="opt_line", help = "option line") 3443 global g_ verbose, g_scripfile, g_batchmode, g_hascolors, g_hasreadline, g_cmd3455 global g_fVerbose, g_sScriptFile, g_fBatchMode, g_fHasColors, g_fHasReadline, g_sCmd 3444 3456 (options, args) = parse.parse_args() 3445 g_ verbose = options.verbose3457 g_fVerbose = options.verbose 3446 3458 style = options.style 3447 3459 if options.batch_file is not None: 3448 g_ batchmode = True3449 g_ hascolors = False3450 g_ hasreadline = False3451 g_s cripfile = options.batch_file3460 g_fBatchMode = True 3461 g_fHasColors = False 3462 g_fHasReadline = False 3463 g_sScriptFile = options.batch_file 3452 3464 if options.command_line is not None: 3453 g_ hascolors = False3454 g_ hasreadline = False3455 g_ cmd = options.command_line3465 g_fHasColors = False 3466 g_fHasReadline = False 3467 g_sCmd = options.command_line 3456 3468 if options.opt_line is not None: 3457 3469 params = {} 3458 3470 strparams = options.opt_line 3459 l= strparams.split(',')3460 for e in l:3461 (k ,v) = e.split('=')3462 params[k ] = v3471 strparamlist = strparams.split(',') 3472 for strparam in strparamlist: 3473 (key, value) = strparam.split('=') 3474 params[key] = value 3463 3475 else: 3464 3476 params = None … … 3469 3481 if vpp is None and (os.path.isfile(os.path.join(cwd, "VirtualBox")) or os.path.isfile(os.path.join(cwd, "VirtualBox.exe"))) : 3470 3482 vpp = cwd 3471 print "Autodetected VBOX_PROGRAM_PATH as", vpp3483 print "Autodetected VBOX_PROGRAM_PATH as", vpp 3472 3484 os.environ["VBOX_PROGRAM_PATH"] = vpp 3473 3485 sys.path.append(os.path.join(vpp, "sdk", "installer")) … … 3478 3490 vsp = os.path.join(vpp, "sdk") 3479 3491 if vsp is not None : 3480 print "Autodetected VBOX_SDK_PATH as", vsp3492 print "Autodetected VBOX_SDK_PATH as", vsp 3481 3493 os.environ["VBOX_SDK_PATH"] = vsp 3482 3494 3483 3495 from vboxapi import VirtualBoxManager 3484 g_virtualBoxManager = VirtualBoxManager(style, params)3485 ctx = {'global': g_virtualBoxManager,3486 'mgr': g_virtualBoxManager.mgr,3487 'vb': g_virtualBoxManager.vbox,3488 'const': g_virtualBoxManager.constants,3489 'remote': g_virtualBoxManager.remote,3490 'type': g_virtualBoxManager.type,3491 'run': lambda cmd, args: runCommandCb(ctx, cmd, args),3492 'guestlambda': lambda id,guestLambda,args: runGuestCommandCb(ctx,id, guestLambda, args),3493 'machById': lambda id: machById(ctx,id),3494 'argsToMach': lambda args: argsToMach(ctx, args),3495 'progressBar': lambda p: progressBar(ctx, p),3496 virtualBoxManager = VirtualBoxManager(style, params) 3497 ctx = {'global':virtualBoxManager, 3498 'mgr':virtualBoxManager.mgr, 3499 'vb':virtualBoxManager.vbox, 3500 'const':virtualBoxManager.constants, 3501 'remote':virtualBoxManager.remote, 3502 'type':virtualBoxManager.type, 3503 'run': lambda cmd, args: runCommandCb(ctx, cmd, args), 3504 'guestlambda': lambda uuid, guestLambda, args: runGuestCommandCb(ctx, uuid, guestLambda, args), 3505 'machById': lambda uuid: machById(ctx, uuid), 3506 'argsToMach': lambda args: argsToMach(ctx, args), 3507 'progressBar': lambda p: progressBar(ctx, p), 3496 3508 'typeInGuest': typeInGuest, 3497 3509 '_machlist': None, 3498 'prompt': g_ prompt,3510 'prompt': g_sPrompt, 3499 3511 'scriptLine': 0, 3500 3512 'interrupt': False 3501 3513 } 3502 3514 interpret(ctx) 3503 g_virtualBoxManager.deinit()3504 del g_virtualBoxManager3515 virtualBoxManager.deinit() 3516 del virtualBoxManager 3505 3517 3506 3518 if __name__ == '__main__': -
trunk/src/VBox/Main/glue/glue-java.xsl
r46123 r46478 1 1 <xsl:stylesheet version = '1.0' 2 3 4 5 2 xmlns:xsl='http://www.w3.org/1999/XSL/Transform' 3 xmlns:vbox="http://www.virtualbox.org/" 4 xmlns:exsl="http://exslt.org/common" 5 extension-element-prefixes="exsl"> 6 6 7 7 <!-- … … 33 33 34 34 <xsl:variable name="G_xsltFilename" select="'glue-java.xsl'" /> 35 <xsl:variable name="G_virtualBoxPackage" select="concat('org.virtualbox',$G_vboxApiSuffix)" /> 36 <xsl:variable name="G_virtualBoxPackageCom" select="concat('org.virtualbox',$G_vboxApiSuffix,'.',$G_vboxGlueStyle)" /> 37 <xsl:variable name="G_virtualBoxWsdl" select="concat(concat('"vboxwebService',$G_vboxApiSuffix), '.wsdl"')" /> 38 <!-- collect all interfaces with "wsmap='suppress'" in a global variable for 39 quick lookup --> 35 <xsl:variable name="G_virtualBoxPackage" select="concat('org.virtualbox', $G_vboxApiSuffix)" /> 36 <xsl:variable name="G_virtualBoxPackageCom" select="concat('org.virtualbox', $G_vboxApiSuffix, '.', $G_vboxGlueStyle)" /> 37 <xsl:variable name="G_virtualBoxWsdl" select="concat('"vboxwebService', $G_vboxApiSuffix, '.wsdl"')" /> 38 <!-- collect all interfaces with "wsmap='suppress'" in a global variable for quick lookup --> 40 39 <xsl:variable name="G_setSuppressedInterfaces" 41 40 select="//interface[@wsmap='suppress']" /> … … 48 47 <xsl:param name="name" /> 49 48 <xsl:text>/* 50 * 49 * Copyright (C) 2010-2013 Oracle Corporation 51 50 * 52 * 53 * 54 * 55 * 56 * 57 * 58 * 59 * 60 * 51 * This file is part of the VirtualBox SDK, as available from 52 * http://www.virtualbox.org. This library is free software; you can 53 * redistribute it and/or modify it under the terms of the GNU Lesser General 54 * Public License as published by the Free Software Foundation, in version 2.1 55 * as it comes in the "COPYING.LIB" file of the VirtualBox SDK distribution. 56 * This library is distributed in the hope that it will be useful, but WITHOUT 57 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 58 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 59 * License for more details. 61 60 * 62 61 </xsl:text> 63 <xsl:value-of select="concat(' * ', $name)"/>62 <xsl:value-of select="concat(' * ', $name)"/> 64 63 <xsl:text> 65 64 * … … 76 75 <xsl:param name="package" /> 77 76 78 <xsl:value-of select="concat(' // ##### BEGINFILE "', $G_vboxDirPrefix, $file, '" ')" />79 <xsl:call-template name="fileheader">80 <xsl:with-param name="name" select="$file" />81 </xsl:call-template>82 83 <xsl:value-of select="concat('package ',$package,'; ')" />84 <xsl:value-of select="concat('import ',$G_virtualBoxPackageCom,'.*; ')" />85 86 77 <xsl:choose> 87 <xsl:when test="$G_vboxGlueStyle='xpcom'"> 88 <xsl:value-of select="'import org.mozilla.interfaces.*; '" /> 89 </xsl:when> 90 91 <xsl:when test="$G_vboxGlueStyle='mscom'"> 92 <xsl:value-of select="'import com.jacob.com.*; '" /> 93 <xsl:value-of select="'import com.jacob.activeX.ActiveXComponent; '" /> 94 </xsl:when> 95 96 <xsl:when test="$G_vboxGlueStyle='jaxws'"> 97 <xsl:value-of select="'import javax.xml.ws.*; '" /> 98 </xsl:when> 99 78 <xsl:when test="$filelistonly=''"> 79 <xsl:value-of select="concat(' // ##### BEGINFILE "', $G_vboxDirPrefix, $file, '" ')" /> 80 <xsl:call-template name="fileheader"> 81 <xsl:with-param name="name" select="$file" /> 82 </xsl:call-template> 83 84 <xsl:value-of select="concat('package ', $package, '; ')" /> 85 <xsl:value-of select="concat('import ', $G_virtualBoxPackageCom, '.*; ')" /> 86 87 <xsl:choose> 88 <xsl:when test="$G_vboxGlueStyle='xpcom'"> 89 <xsl:text>import org.mozilla.interfaces.*; </xsl:text> 90 </xsl:when> 91 92 <xsl:when test="$G_vboxGlueStyle='mscom'"> 93 <xsl:text>import com.jacob.com.*; </xsl:text> 94 <xsl:text>import com.jacob.activeX.ActiveXComponent; </xsl:text> 95 </xsl:when> 96 97 <xsl:when test="$G_vboxGlueStyle='jaxws'"> 98 <xsl:text>import javax.xml.ws.*; </xsl:text> 99 </xsl:when> 100 101 <xsl:otherwise> 102 <xsl:call-template name="fatalError"> 103 <xsl:with-param name="msg" select="'no header rule (startFile)'" /> 104 </xsl:call-template> 105 </xsl:otherwise> 106 </xsl:choose> 107 </xsl:when> 100 108 <xsl:otherwise> 101 <xsl:call-template name="fatalError"> 102 <xsl:with-param name="msg" select="'no header rule (startFile)'" /> 103 </xsl:call-template> 109 <xsl:value-of select="concat('	', $G_vboxDirPrefix, $file, ' \ ')"/> 104 110 </xsl:otherwise> 105 111 </xsl:choose> … … 107 113 108 114 <xsl:template name="endFile"> 109 <xsl:param name="file" /> 110 <xsl:value-of select="concat(' // ##### ENDFILE "', $file, '" ')" /> 115 <xsl:param name="file" /> 116 <xsl:if test="$filelistonly=''"> 117 <xsl:value-of select="concat(' // ##### ENDFILE "', $file, '" ')" /> 118 </xsl:if> 111 119 </xsl:template> 112 120 … … 116 124 <xsl:param name="needle"/> 117 125 <xsl:param name="replacement"/> 126 <xsl:param name="onlyfirst" select="false"/> 118 127 <xsl:choose> 119 <xsl:when test="contains($haystack, $needle)">120 <xsl:value-of select="substring-before($haystack, $needle)"/>128 <xsl:when test="contains($haystack, $needle)"> 129 <xsl:value-of select="substring-before($haystack, $needle)"/> 121 130 <xsl:value-of select="$replacement"/> 122 <xsl:call-template name="string-replace"> 123 <xsl:with-param name="haystack" select="substring-after($haystack,$needle)"/> 124 <xsl:with-param name="needle" select="$needle"/> 125 <xsl:with-param name="replacement" select="$replacement"/> 126 </xsl:call-template> 131 <xsl:choose> 132 <xsl:when test="$onlyfirst = 'true'"> 133 <xsl:value-of select="substring-after($haystack, $needle)"/> 134 </xsl:when> 135 <xsl:otherwise> 136 <xsl:call-template name="string-replace"> 137 <xsl:with-param name="haystack" select="substring-after($haystack, $needle)"/> 138 <xsl:with-param name="needle" select="$needle"/> 139 <xsl:with-param name="replacement" select="$replacement"/> 140 </xsl:call-template> 141 </xsl:otherwise> 142 </xsl:choose> 127 143 </xsl:when> 128 144 <xsl:otherwise> 129 145 <xsl:value-of select="$haystack"/> 146 </xsl:otherwise> 147 </xsl:choose> 148 </xsl:template> 149 150 <xsl:template name="string-trim"> 151 <xsl:param name="text"/> 152 153 <xsl:variable name="begin" select="substring($text, 1, 1)"/> 154 <xsl:choose> 155 <xsl:when test="$begin = ' ' or $begin = ' ' or $begin = ' '"> 156 <xsl:call-template name="string-trim"> 157 <xsl:with-param name="text" select="substring($text, 2)"/> 158 </xsl:call-template> 159 </xsl:when> 160 <xsl:otherwise> 161 <xsl:variable name="end" select="substring($text, string-length($text) - 1, 1)"/> 162 <xsl:choose> 163 <xsl:when test="$end = ' ' or $end = ' ' or $end = ' '"> 164 <xsl:call-template name="string-trim"> 165 <xsl:with-param name="text" select="substring($text, 1, string-length($text) - 1)"/> 166 </xsl:call-template> 167 </xsl:when> 168 <xsl:otherwise> 169 <xsl:choose> 170 <xsl:when test="contains($text, ' ')"> 171 <xsl:variable name="tmptext"> 172 <xsl:call-template name="string-replace"> 173 <xsl:with-param name="haystack" select="$text"/> 174 <xsl:with-param name="needle" select="' '"/> 175 <xsl:with-param name="replacement" select="' '"/> 176 </xsl:call-template> 177 </xsl:variable> 178 <xsl:call-template name="string-trim"> 179 <xsl:with-param name="text" select="$tmptext"/> 180 </xsl:call-template> 181 </xsl:when> 182 <xsl:otherwise> 183 <xsl:value-of select="$text"/> 184 </xsl:otherwise> 185 </xsl:choose> 186 </xsl:otherwise> 187 </xsl:choose> 130 188 </xsl:otherwise> 131 189 </xsl:choose> … … 161 219 </xsl:variable> 162 220 163 <xsl:value-of select="$rep3"/> 221 <xsl:variable name="rep4"> 222 <xsl:call-template name="string-trim"> 223 <xsl:with-param name="text" select="$rep3"/> 224 </xsl:call-template> 225 </xsl:variable> 226 227 <xsl:value-of select="$rep4"/> 164 228 </xsl:template> 165 229 166 230 <!-- 167 * 168 * 231 * all sub-elements that are not explicitly matched are considered to be 232 * html tags and copied w/o modifications 169 233 --> 170 234 <xsl:template match="desc//*"> 171 235 <xsl:variable name="tagname" select="local-name()"/> 172 <xsl:value-of select="concat('<', $tagname,'>')"/>236 <xsl:value-of select="concat('<', $tagname, '>')"/> 173 237 <xsl:apply-templates/> 174 <xsl:value-of select="concat('</', $tagname,'>')"/>238 <xsl:value-of select="concat('</', $tagname, '>')"/> 175 239 </xsl:template> 176 240 … … 215 279 <xsl:otherwise> 216 280 <xsl:call-template name="fatalError"> 217 <xsl:with-param name="msg" select="concat('unknown reference destination in @see/@link: context=', $context,' identifier=',$identifier)" />281 <xsl:with-param name="msg" select="concat('unknown reference destination in @see/@link: context=', $context, ' identifier=', $identifier)" /> 218 282 </xsl:call-template> 219 283 </xsl:otherwise> … … 222 286 223 287 <!-- 224 * 288 * link 225 289 --> 226 290 <xsl:template match="desc//link"> … … 232 296 <xsl:template match="link" mode="middle"> 233 297 <xsl:variable name="linktext"> 234 <xsl:value-of select="translate(@to,'_','#')"/> 298 <xsl:call-template name="string-replace"> 299 <xsl:with-param name="haystack" select="@to"/> 300 <xsl:with-param name="needle" select="'_'"/> 301 <xsl:with-param name="replacement" select="'#'"/> 302 <xsl:with-param name="onlyfirst" select="'true'"/> 303 </xsl:call-template> 235 304 </xsl:variable> 236 305 <xsl:choose> 237 <xsl:when test="substring($linktext, 1,1)='#'">306 <xsl:when test="substring($linktext, 1, 1)='#'"> 238 307 <xsl:variable name="context"> 239 308 <xsl:choose> … … 255 324 <xsl:otherwise> 256 325 <xsl:call-template name="fatalError"> 257 <xsl:with-param name="msg" select="concat('cannot determine context for identifier ', $linktext)" />326 <xsl:with-param name="msg" select="concat('cannot determine context for identifier ', $linktext)" /> 258 327 </xsl:call-template> 259 328 </xsl:otherwise> … … 261 330 </xsl:variable> 262 331 <xsl:variable name="linkname"> 263 <xsl:value-of select="substring($linktext, 2)"/>332 <xsl:value-of select="substring($linktext, 2)"/> 264 333 </xsl:variable> 265 334 <xsl:text>#</xsl:text> … … 269 338 </xsl:call-template> 270 339 </xsl:when> 271 <xsl:when test="contains($linktext, '::')">340 <xsl:when test="contains($linktext, '::')"> 272 341 <xsl:variable name="context"> 273 <xsl:value-of select="substring-before($linktext, '::')"/>342 <xsl:value-of select="substring-before($linktext, '::')"/> 274 343 </xsl:variable> 275 344 <xsl:variable name="linkname"> 276 <xsl:value-of select="substring-after($linktext, '::')"/>345 <xsl:value-of select="substring-after($linktext, '::')"/> 277 346 </xsl:variable> 278 <xsl:value-of select="concat($G_virtualBoxPackage, '.',$context,'#')"/>347 <xsl:value-of select="concat($G_virtualBoxPackage, '.', $context, '#')"/> 279 348 <xsl:call-template name="emit_refsig"> 280 349 <xsl:with-param name="context" select="$context"/> … … 283 352 </xsl:when> 284 353 <xsl:otherwise> 285 <xsl:value-of select="concat($G_virtualBoxPackage, '.',$linktext)"/>354 <xsl:value-of select="concat($G_virtualBoxPackage, '.', $linktext)"/> 286 355 </xsl:otherwise> 287 356 </xsl:choose> 288 357 </xsl:template> 289 358 <!-- 290 * 359 * note 291 360 --> 292 361 <xsl:template match="desc/note"> … … 299 368 300 369 <!-- 301 * 370 * see 302 371 --> 303 372 <xsl:template match="desc/see"> 304 373 <!-- TODO: quirk in our xidl file: only one <see> tag with <link> nested 305 374 into it, translate this to multiple @see lines and strip the rest. 306 Should be replaced in the xidl by multiple <see> without nested tag 375 Should be replaced in the xidl by multiple <see> without nested tag --> 307 376 <xsl:text> </xsl:text> 308 377 <xsl:apply-templates match="link"/> … … 318 387 319 388 <!-- 320 * 389 * common comment prologue (handles group IDs) 321 390 --> 322 391 <xsl:template match="desc" mode="begin"> 323 392 <xsl:param name="id" select="@group | preceding::descGroup[1]/@id"/> 324 <xsl:text> /** </xsl:text>393 <xsl:text> /** </xsl:text> 325 394 <xsl:if test="$id"> 326 <xsl:value-of select="concat(' @ingroup ', $id,' ')"/>395 <xsl:value-of select="concat(' @ingroup ', $id, ' ')"/> 327 396 </xsl:if> 328 397 </xsl:template> 329 398 330 399 <!-- 331 * 400 * common middle part of the comment block 332 401 --> 333 402 <xsl:template match="desc" mode="middle"> … … 338 407 339 408 <!-- 340 * 409 * result part of the comment block 341 410 --> 342 411 <xsl:template match="desc" mode="results"> … … 348 417 <xsl:choose> 349 418 <xsl:when test="ancestor::library/result[@name=current()/@name]"> 350 <xsl:value-of select="concat('<td>@link ::', @name,' ',@name,'</td>')"/>419 <xsl:value-of select="concat('<td>@link ::', @name, ' ', @name, '</td>')"/> 351 420 </xsl:when> 352 421 <xsl:otherwise> 353 <xsl:value-of select="concat('<td>', @name,'</td>')"/>422 <xsl:value-of select="concat('<td>', @name, '</td>')"/> 354 423 </xsl:otherwise> 355 424 </xsl:choose> … … 364 433 365 434 <!-- 366 * 435 * translates the string to uppercase 367 436 --> 368 437 <xsl:template name="uppercase"> 369 438 <xsl:param name="str" select="."/> 370 <xsl:value-of select=" 371 translate($str,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ') 372 "/> 439 <xsl:value-of select="translate($str, $G_lowerCase, $G_upperCase)"/> 373 440 </xsl:template> 374 441 375 442 <!-- 376 * 443 * comment for interfaces 377 444 --> 378 445 <xsl:template match="desc" mode="interface"> … … 387 454 388 455 <!-- 389 * 456 * comment for attribute getters 390 457 --> 391 458 <xsl:template match="desc" mode="attribute_get"> … … 401 468 <xsl:text> </xsl:text> 402 469 <xsl:apply-templates select="see"/> 403 <xsl:text> */ </xsl:text>470 <xsl:text>*/ </xsl:text> 404 471 </xsl:template> 405 472 406 473 <!-- 407 * 474 * comment for attribute setters 408 475 --> 409 476 <xsl:template match="desc" mode="attribute_set"> … … 423 490 424 491 <!-- 425 * 492 * comment for methods 426 493 --> 427 494 <xsl:template match="desc" mode="method"> … … 439 506 440 507 <!-- 441 * 508 * comment for method parameters 442 509 --> 443 510 <xsl:template match="method/param/desc"> … … 459 526 460 527 <!-- 461 * 528 * comment for enums 462 529 --> 463 530 <xsl:template match="desc" mode="enum"> … … 472 539 473 540 <!-- 474 * 541 * comment for enum values 475 542 --> 476 543 <xsl:template match="desc" mode="enum_const"> … … 481 548 482 549 <!-- 483 * 550 * ignore descGroups by default (processed in /idl) 484 551 --> 485 552 <xsl:template match="descGroup"/> … … 498 565 </xsl:call-template> 499 566 500 <xsl:apply-templates select="desc" mode="enum"/> 501 <xsl:value-of select="concat('public enum ', $enumname, ' { ')" /> 502 <xsl:for-each select="const"> 503 <xsl:apply-templates select="desc" mode="enum_const"/> 504 <xsl:variable name="enumconst" select="@name" /> 505 <xsl:value-of select="concat(' ', $enumconst, '(', @value, ')')" /> 506 <xsl:choose> 507 <xsl:when test="not(position()=last())"> 508 <xsl:text>, </xsl:text> 509 </xsl:when> 510 <xsl:otherwise> 511 <xsl:text>; </xsl:text> 512 </xsl:otherwise> 513 </xsl:choose> 514 </xsl:for-each> 515 516 <xsl:text> </xsl:text> 517 <xsl:text> private final int value; </xsl:text> 518 519 <xsl:value-of select="concat(' ', $enumname, '(int v) { ')" /> 520 <xsl:text> value = v; </xsl:text> 521 <xsl:text> } </xsl:text> 522 523 <xsl:text> public int value() { </xsl:text> 524 <xsl:text> return value; </xsl:text> 525 <xsl:text> } </xsl:text> 526 527 <xsl:value-of select="concat(' public static ', $enumname, ' fromValue(long v) { ')" /> 528 <xsl:value-of select="concat(' for (', $enumname, ' c: ', $enumname, '.values()) { ')" /> 529 <xsl:text> if (c.value == (int)v) { </xsl:text> 530 <xsl:text> return c; </xsl:text> 531 <xsl:text> } </xsl:text> 532 <xsl:text> } </xsl:text> 533 <xsl:text> throw new IllegalArgumentException(Long.toString(v)); </xsl:text> 534 <xsl:text> } </xsl:text> 535 536 <xsl:value-of select="concat(' public static ', $enumname, ' fromValue(String v) { ')" /> 537 <xsl:value-of select="concat(' return valueOf(',$enumname, '.class, v); ')" /> 538 <xsl:value-of select=" ' } '" /> 539 540 <xsl:text>} </xsl:text> 567 <xsl:if test="$filelistonly=''"> 568 <xsl:apply-templates select="desc" mode="enum"/> 569 <xsl:value-of select="concat('public enum ', $enumname, ' ')" /> 570 <xsl:text>{ </xsl:text> 571 <xsl:for-each select="const"> 572 <xsl:apply-templates select="desc" mode="enum_const"/> 573 <xsl:variable name="enumconst" select="@name" /> 574 <xsl:value-of select="concat(' ', $enumconst, '(', @value, ')')" /> 575 <xsl:choose> 576 <xsl:when test="not(position()=last())"> 577 <xsl:text>, </xsl:text> 578 </xsl:when> 579 <xsl:otherwise> 580 <xsl:text>; </xsl:text> 581 </xsl:otherwise> 582 </xsl:choose> 583 </xsl:for-each> 584 585 <xsl:text> </xsl:text> 586 <xsl:text> private final int value; </xsl:text> 587 588 <xsl:value-of select="concat(' ', $enumname, '(int v) ')" /> 589 <xsl:text> { </xsl:text> 590 <xsl:text> value = v; </xsl:text> 591 <xsl:text> } </xsl:text> 592 593 <xsl:text> public int value() </xsl:text> 594 <xsl:text> { </xsl:text> 595 <xsl:text> return value; </xsl:text> 596 <xsl:text> } </xsl:text> 597 598 <xsl:value-of select="concat(' public static ', $enumname, ' fromValue(long v) ')" /> 599 <xsl:text> { </xsl:text> 600 <xsl:value-of select="concat(' for (', $enumname, ' c: ', $enumname, '.values()) ')" /> 601 <xsl:text> { </xsl:text> 602 <xsl:text> if (c.value == (int)v) </xsl:text> 603 <xsl:text> { </xsl:text> 604 <xsl:text> return c; </xsl:text> 605 <xsl:text> } </xsl:text> 606 <xsl:text> } </xsl:text> 607 <xsl:text> throw new IllegalArgumentException(Long.toString(v)); </xsl:text> 608 <xsl:text> } </xsl:text> 609 610 <xsl:value-of select="concat(' public static ', $enumname, ' fromValue(String v) ')" /> 611 <xsl:text> { </xsl:text> 612 <xsl:value-of select="concat(' return valueOf(', $enumname, '.class, v); ')" /> 613 <xsl:text> } </xsl:text> 614 <xsl:text>} </xsl:text> 615 </xsl:if> 541 616 542 617 <xsl:call-template name="endFile"> … … 547 622 548 623 <xsl:template name="startExcWrapper"> 549 550 <xsl:value-of select="' try { '" /> 551 624 <xsl:text> try </xsl:text> 625 <xsl:text> { </xsl:text> 552 626 </xsl:template> 553 627 … … 556 630 <xsl:choose> 557 631 <xsl:when test="$G_vboxGlueStyle='xpcom'"> 558 <xsl:value-of select="' } catch (org.mozilla.xpcom.XPCOMException e) { '" /> 559 <xsl:value-of select="' throw new VBoxException(e, e.getMessage()); '" /> 560 <xsl:value-of select="' } '" /> 632 <xsl:text> } </xsl:text> 633 <xsl:text> catch (org.mozilla.xpcom.XPCOMException e) </xsl:text> 634 <xsl:text> { </xsl:text> 635 <xsl:text> throw new VBoxException(e.getMessage(), e); </xsl:text> 636 <xsl:text> } </xsl:text> 561 637 </xsl:when> 562 638 563 639 <xsl:when test="$G_vboxGlueStyle='mscom'"> 564 <xsl:value-of select="' } catch (com.jacob.com.ComException e) { '" /> 565 <xsl:value-of select="' throw new VBoxException(e, e.getMessage()); '" /> 566 <xsl:value-of select="' } '" /> 640 <xsl:text> } </xsl:text> 641 <xsl:text> catch (com.jacob.com.ComException e) </xsl:text> 642 <xsl:text> { </xsl:text> 643 <xsl:text> throw new VBoxException(e.getMessage(), e); </xsl:text> 644 <xsl:text> } </xsl:text> 567 645 </xsl:when> 568 646 569 647 <xsl:when test="$G_vboxGlueStyle='jaxws'"> 570 <xsl:value-of select="' } catch (InvalidObjectFaultMsg e) { '" /> 571 <xsl:value-of select="' throw new VBoxException(e, e.getMessage()); '" /> 572 <xsl:value-of select="' } catch (RuntimeFaultMsg e) { '" /> 573 <xsl:value-of select="' throw new VBoxException(e, e.getMessage()); '" /> 574 <xsl:value-of select="' } '" /> 648 <xsl:text> } </xsl:text> 649 <xsl:text> catch (InvalidObjectFaultMsg e) </xsl:text> 650 <xsl:text> { </xsl:text> 651 <xsl:text> throw new VBoxException(e.getMessage(), e, this.port); </xsl:text> 652 <xsl:text> } </xsl:text> 653 <xsl:text> catch (RuntimeFaultMsg e) </xsl:text> 654 <xsl:text> { </xsl:text> 655 <xsl:text> throw new VBoxException(e.getMessage(), e, this.port); </xsl:text> 656 <xsl:text> } </xsl:text> 575 657 </xsl:when> 576 658 … … 588 670 <xsl:choose> 589 671 <xsl:when test="$G_vboxGlueStyle='xpcom'"> 590 <xsl:value-of select="concat('org.mozilla.interfaces.', $ifname)" />672 <xsl:value-of select="concat('org.mozilla.interfaces.', $ifname)" /> 591 673 </xsl:when> 592 674 593 675 <xsl:when test="$G_vboxGlueStyle='mscom'"> 594 <xsl: value-of select="'com.jacob.com.Dispatch'" />676 <xsl:text>com.jacob.com.Dispatch</xsl:text> 595 677 </xsl:when> 596 678 597 679 <xsl:when test="$G_vboxGlueStyle='jaxws'"> 598 <xsl: value-of select="'String'" />680 <xsl:text>String</xsl:text> 599 681 </xsl:when> 600 682 … … 612 694 <xsl:param name="origname" /> 613 695 <xsl:param name="collPrefix" /> 614 <xsl:choose> 615 <xsl:when test="//enum[@name=$name] or //enum[@name=$origname]"> 616 <xsl:value-of select="concat($G_virtualBoxPackage, concat('.', $name))" /> 617 </xsl:when> 618 <xsl:when test="//interface[@name=$name]"> 619 <xsl:value-of select="concat($G_virtualBoxPackage, concat('.', $name))" /> 620 </xsl:when> 621 <xsl:otherwise> 696 697 <xsl:choose> 698 <xsl:when test="//enum[@name=$name] or //enum[@name=$origname]"> 699 <xsl:value-of select="concat($G_virtualBoxPackage, concat('.', $name))" /> 700 </xsl:when> 701 <xsl:when test="//interface[@name=$name]"> 702 <xsl:value-of select="concat($G_virtualBoxPackage, concat('.', $name))" /> 703 </xsl:when> 704 <xsl:otherwise> 622 705 <xsl:call-template name="fatalError"> 623 706 <xsl:with-param name="msg" select="concat('fullClassName: Type "', $name, '" is not supported.')" /> 624 707 </xsl:call-template> 625 626 708 </xsl:otherwise> 709 </xsl:choose> 627 710 </xsl:template> 628 711 … … 637 720 638 721 <xsl:if test="($needlist)"> 639 <xsl: value-of select="'List'" />722 <xsl:text>List</xsl:text> 640 723 <xsl:if test="not($skiplisttype='yes')"> 641 <xsl: value-of select="'<'" />724 <xsl:text><</xsl:text> 642 725 </xsl:if> 643 726 </xsl:if> … … 665 748 <xsl:when test="($needlist)"> 666 749 <xsl:if test="not($skiplisttype='yes')"> 667 <xsl: value-of select="'>'" />750 <xsl:text>></xsl:text> 668 751 </xsl:if> 669 752 </xsl:when> 670 753 <xsl:when test="($needarray)"> 671 <xsl: value-of select="'[]'" />754 <xsl:text>[]</xsl:text> 672 755 </xsl:when> 673 756 </xsl:choose> … … 688 771 <xsl:choose> 689 772 <xsl:when test="$type='long long'"> 690 <xsl: value-of select="'long'" />773 <xsl:text>long</xsl:text> 691 774 </xsl:when> 692 775 693 776 <xsl:when test="$type='unsigned long'"> 694 <xsl: value-of select="'long'" />777 <xsl:text>long</xsl:text> 695 778 </xsl:when> 696 779 697 780 <xsl:when test="$type='long'"> 698 <xsl: value-of select="'int'" />781 <xsl:text>int</xsl:text> 699 782 </xsl:when> 700 783 701 784 <xsl:when test="$type='unsigned short'"> 702 <xsl: value-of select="'int'" />785 <xsl:text>int</xsl:text> 703 786 </xsl:when> 704 787 705 788 <xsl:when test="$type='short'"> 706 <xsl: value-of select="'short'" />789 <xsl:text>short</xsl:text> 707 790 </xsl:when> 708 791 709 792 <xsl:when test="$type='octet'"> 710 <xsl: value-of select="'byte'" />793 <xsl:text>byte</xsl:text> 711 794 </xsl:when> 712 795 713 796 <xsl:when test="$type='boolean'"> 714 <xsl: value-of select="'boolean'" />797 <xsl:text>boolean</xsl:text> 715 798 </xsl:when> 716 799 717 800 <xsl:when test="$type='$unknown'"> 718 <xsl: value-of select="'nsISupports'"/>801 <xsl:text>nsISupports</xsl:text> 719 802 </xsl:when> 720 803 721 804 <xsl:when test="$type='wstring'"> 722 <xsl: value-of select="'String'" />805 <xsl:text>String</xsl:text> 723 806 </xsl:when> 724 807 725 808 <xsl:when test="$type='uuid'"> 726 <xsl: value-of select="'String'" />809 <xsl:text>String</xsl:text> 727 810 </xsl:when> 728 811 … … 740 823 741 824 <xsl:when test="//enum[@name=$type]"> 742 <xsl: value-of select="'long'" />825 <xsl:text>long</xsl:text> 743 826 </xsl:when> 744 827 … … 751 834 </xsl:choose> 752 835 <xsl:if test="$needarray"> 753 <xsl: value-of select="'[]'" />836 <xsl:text>[]</xsl:text> 754 837 </xsl:if> 755 838 </xsl:when> 756 839 757 840 <xsl:when test="($G_vboxGlueStyle='mscom')"> 758 <xsl: value-of select="'Variant'"/>841 <xsl:text>Variant</xsl:text> 759 842 </xsl:when> 760 843 … … 763 846 764 847 <xsl:if test="$needarray"> 765 <xsl: value-of select="'List<'" />848 <xsl:text>List<</xsl:text> 766 849 </xsl:if> 767 850 <xsl:choose> 768 851 <xsl:when test="$type='$unknown'"> 769 <xsl: value-of select="'String'" />852 <xsl:text>String</xsl:text> 770 853 </xsl:when> 771 854 772 855 <xsl:when test="//interface[@name=$type]/@wsmap='managed'"> 773 <xsl: value-of select="'String'" />856 <xsl:text>String</xsl:text> 774 857 </xsl:when> 775 858 … … 784 867 <!-- we encode byte arrays as Base64 strings. --> 785 868 <xsl:when test="$type='octet'"> 786 <xsl: value-of select="'/*base64*/String'" />869 <xsl:text>/*base64*/String</xsl:text> 787 870 </xsl:when> 788 871 789 872 <xsl:when test="$type='long long'"> 790 <xsl: value-of select="'Long'" />873 <xsl:text>Long</xsl:text> 791 874 </xsl:when> 792 875 793 876 <xsl:when test="$type='unsigned long'"> 794 <xsl: value-of select="'Long'" />877 <xsl:text>Long</xsl:text> 795 878 </xsl:when> 796 879 797 880 <xsl:when test="$type='long'"> 798 <xsl: value-of select="'Integer'" />881 <xsl:text>Integer</xsl:text> 799 882 </xsl:when> 800 883 801 884 <xsl:when test="$type='unsigned short'"> 802 <xsl: value-of select="'Integer'" />885 <xsl:text>Integer</xsl:text> 803 886 </xsl:when> 804 887 805 888 <xsl:when test="$type='short'"> 806 <xsl: value-of select="'Short'" />889 <xsl:text>Short</xsl:text> 807 890 </xsl:when> 808 891 809 892 <xsl:when test="$type='boolean'"> 810 <xsl: value-of select="'Boolean'" />893 <xsl:text>Boolean</xsl:text> 811 894 </xsl:when> 812 895 813 896 <xsl:when test="$type='wstring'"> 814 <xsl: value-of select="'String'" />897 <xsl:text>String</xsl:text> 815 898 </xsl:when> 816 899 817 900 <xsl:when test="$type='uuid'"> 818 <xsl: value-of select="'String'" />901 <xsl:text>String</xsl:text> 819 902 </xsl:when> 820 903 821 904 <xsl:otherwise> 822 905 <xsl:call-template name="fatalError"> 823 <xsl:with-param name="msg" select="concat('Unhandled type ', $type, ' (typeIdl2Back)')" />906 <xsl:with-param name="msg" select="concat('Unhandled type ', $type, ' (typeIdl2Back)')" /> 824 907 </xsl:call-template> 825 908 </xsl:otherwise> … … 828 911 829 912 <xsl:if test="$needarray"> 830 <xsl: value-of select="'>'" />913 <xsl:text>></xsl:text> 831 914 </xsl:if> 832 915 </xsl:when> … … 876 959 </xsl:call-template> 877 960 </xsl:variable> 878 <xsl:value-of select="concat('Helper.wrap2(', $elemgluetype, '.class, ', $elembacktype, '.class, ', $value,')')"/>961 <xsl:value-of select="concat('Helper.wrap2(', $elemgluetype, '.class, ', $elembacktype, '.class, ', $value, ')')"/> 879 962 </xsl:when> 880 963 <xsl:otherwise> 881 <xsl:value-of select="concat('(', $value, ' != null) ? new ', $gluetype, '(', $value,') : null')" />964 <xsl:value-of select="concat('(', $value, ' != null) ? new ', $gluetype, '(', $value, ') : null')" /> 882 965 </xsl:otherwise> 883 966 </xsl:choose> … … 885 968 886 969 <xsl:when test="//enum[@name=$idltype]"> 887 970 <xsl:choose> 888 971 <xsl:when test="$safearray='yes'"> 889 972 <xsl:variable name="elembacktype"> … … 894 977 </xsl:call-template> 895 978 </xsl:variable> 896 <xsl:value-of select="concat('Helper.wrapEnum(', $elemgluetype, '.class, ', $value,')')"/>979 <xsl:value-of select="concat('Helper.wrapEnum(', $elemgluetype, '.class, ', $value, ')')"/> 897 980 </xsl:when> 898 981 <xsl:otherwise> 899 <xsl:value-of select="concat($gluetype, '.fromValue(', $value,')')"/>982 <xsl:value-of select="concat($gluetype, '.fromValue(', $value, ')')"/> 900 983 </xsl:otherwise> 901 984 </xsl:choose> 902 985 </xsl:when> 903 986 … … 908 991 </xsl:when> 909 992 <xsl:when test="$safearray='yes'"> 910 <xsl:value-of select="concat('Helper.wrap(', $value, ')')"/>993 <xsl:value-of select="concat('Helper.wrap(', $value, ')')"/> 911 994 </xsl:when> 912 995 <xsl:otherwise> … … 944 1027 </xsl:when> 945 1028 <xsl:otherwise> 946 <xsl:value-of select="concat('Helper.wrap(', $elemgluetype, '.class, ', $value, '.toSafeArray())')"/>1029 <xsl:value-of select="concat('Helper.wrap(', $elemgluetype, '.class, ', $value, '.toSafeArray())')"/> 947 1030 </xsl:otherwise> 948 1031 </xsl:choose> … … 950 1033 951 1034 <xsl:when test="//interface[@name=$idltype] or $idltype='$unknown'"> 952 <xsl:value-of select="concat('Helper.wrapDispatch(', $gluetype, '.class, ', $value,'.getDispatch())')"/>1035 <xsl:value-of select="concat('Helper.wrapDispatch(', $gluetype, '.class, ', $value, '.getDispatch())')"/> 953 1036 </xsl:when> 954 1037 955 1038 <xsl:when test="//enum[@name=$idltype]"> 956 <xsl:value-of select="concat($gluetype, '.fromValue(', $value,'.getInt())')"/>1039 <xsl:value-of select="concat($gluetype, '.fromValue(', $value, '.getInt())')"/> 957 1040 </xsl:when> 958 1041 959 1042 <xsl:when test="$idltype='wstring'"> 960 <xsl:value-of select="concat($value, '.getString()')"/>1043 <xsl:value-of select="concat($value, '.getString()')"/> 961 1044 </xsl:when> 962 1045 963 1046 <xsl:when test="$idltype='uuid'"> 964 <xsl:value-of select="concat($value, '.getString()')"/>965 </xsl:when> 966 967 968 <xsl:value-of select="concat($value, '.toBoolean()')"/>1047 <xsl:value-of select="concat($value, '.getString()')"/> 1048 </xsl:when> 1049 1050 <xsl:when test="$idltype='boolean'"> 1051 <xsl:value-of select="concat($value, '.toBoolean()')"/> 969 1052 </xsl:when> 970 1053 971 1054 <xsl:when test="$idltype='unsigned short'"> 972 <xsl:value-of select="concat('(int)', $value, '.getShort()')"/>973 </xsl:when> 974 975 976 <xsl:value-of select="concat($value, '.getShort()')"/>1055 <xsl:value-of select="concat('(int)', $value, '.getShort()')"/> 1056 </xsl:when> 1057 1058 <xsl:when test="$idltype='short'"> 1059 <xsl:value-of select="concat($value, '.getShort()')"/> 977 1060 </xsl:when> 978 1061 979 1062 <xsl:when test="$idltype='long'"> 980 <xsl:value-of select="concat($value, '.getInt()')"/>1063 <xsl:value-of select="concat($value, '.getInt()')"/> 981 1064 </xsl:when> 982 1065 983 1066 984 1067 <xsl:when test="$idltype='unsigned long'"> 985 <xsl:value-of select="concat('(long)', $value, '.getInt()')"/>1068 <xsl:value-of select="concat('(long)', $value, '.getInt()')"/> 986 1069 </xsl:when> 987 1070 988 1071 <xsl:when test="$idltype='long'"> 989 <xsl:value-of select="concat($value, '.getInt()')"/>1072 <xsl:value-of select="concat($value, '.getInt()')"/> 990 1073 </xsl:when> 991 1074 992 1075 <xsl:when test="$idltype='long long'"> 993 <xsl:value-of select="concat($value, '.getLong()')"/>1076 <xsl:value-of select="concat($value, '.getLong()')"/> 994 1077 </xsl:when> 995 1078 … … 1036 1119 <xsl:choose> 1037 1120 <xsl:when test="$isstruct"> 1038 <xsl:value-of select="concat('Helper.wrap2(', $elemgluetype, '.class, ', $elembacktype, '.class, port, ', $value,')')"/>1121 <xsl:value-of select="concat('Helper.wrap2(', $elemgluetype, '.class, ', $elembacktype, '.class, port, ', $value, ')')"/> 1039 1122 </xsl:when> 1040 1123 <xsl:when test="//enum[@name=$idltype]"> 1041 <xsl:value-of select="concat('Helper.convertEnums(', $elembacktype, '.class, ', $elemgluetype, '.class, ', $value,')')"/>1124 <xsl:value-of select="concat('Helper.convertEnums(', $elembacktype, '.class, ', $elemgluetype, '.class, ', $value, ')')"/> 1042 1125 </xsl:when> 1043 1126 <xsl:when test="//interface[@name=$idltype] or $idltype='$unknown'"> 1044 <xsl:value-of select="concat('Helper.wrap(', $elemgluetype,'.class, port, ', $value,')')"/>1127 <xsl:value-of select="concat('Helper.wrap(', $elemgluetype, '.class, port, ', $value, ')')"/> 1045 1128 </xsl:when> 1046 1129 <xsl:when test="$idltype='octet'"> 1047 <xsl:value-of select="concat('Helper.decodeBase64(', $value,')')"/>1130 <xsl:value-of select="concat('Helper.decodeBase64(', $value, ')')"/> 1048 1131 </xsl:when> 1049 1132 <xsl:otherwise> 1050 1133 <xsl:value-of select="$value" /> 1051 1134 </xsl:otherwise> 1052 1135 </xsl:choose> … … 1056 1139 <xsl:choose> 1057 1140 <xsl:when test="//enum[@name=$idltype]"> 1058 <xsl:value-of select="concat($gluetype, '.fromValue(', $value,'.value())')"/>1141 <xsl:value-of select="concat($gluetype, '.fromValue(', $value, '.value())')"/> 1059 1142 </xsl:when> 1060 1143 <xsl:when test="$idltype='boolean'"> … … 1086 1169 </xsl:when> 1087 1170 <xsl:when test="$isstruct"> 1088 <xsl:value-of select="concat('(', $value, ' != null) ? new ', $gluetype, '(', $value, ', port) : null')" />1171 <xsl:value-of select="concat('(', $value, ' != null) ? new ', $gluetype, '(', $value, ', port) : null')" /> 1089 1172 </xsl:when> 1090 1173 <xsl:when test="//interface[@name=$idltype] or $idltype='$unknown'"> 1091 1174 <!-- if the MOR string is empty, that means NULL, so return NULL instead of an object then --> 1092 <xsl:value-of select="concat('(', $value, '.length() > 0) ? new ', $gluetype, '(', $value, ', port) : null')" />1175 <xsl:value-of select="concat('(', $value, '.length() > 0) ? new ', $gluetype, '(', $value, ', port) : null')" /> 1093 1176 </xsl:when> 1094 1177 <xsl:otherwise> 1095 1178 <xsl:call-template name="fatalError"> 1096 <xsl:with-param name="msg" select="concat('Unhandled 1179 <xsl:with-param name="msg" select="concat('Unhandled type ', $idltype, ' (cookOutParamJaxws)')" /> 1097 1180 </xsl:call-template> 1098 1181 </xsl:otherwise> … … 1178 1261 </xsl:call-template> 1179 1262 </xsl:variable> 1180 <xsl:value-of select="concat('Helper.unwrap2(', $elemgluetype, '.class, ', $elembacktype, '.class, ', $value,')')"/>1263 <xsl:value-of select="concat('Helper.unwrap2(', $elemgluetype, '.class, ', $elembacktype, '.class, ', $value, ')')"/> 1181 1264 </xsl:when> 1182 1265 <xsl:otherwise> 1183 1266 <xsl:value-of select="concat('(', $value, ' != null) ? ', $value, '.getTypedWrapped() : null')" /> 1184 1267 </xsl:otherwise> 1185 1268 </xsl:choose> 1186 1269 </xsl:when> 1187 1270 1188 1189 1271 <xsl:when test="$idltype='$unknown'"> 1272 <xsl:choose> 1190 1273 <xsl:when test="$safearray='yes'"> 1191 <xsl:value-of select="concat('Helper.unwrap2(', $elemgluetype, '.class, nsISupports.class, ', $value,')')"/>1274 <xsl:value-of select="concat('Helper.unwrap2(', $elemgluetype, '.class, nsISupports.class, ', $value, ')')"/> 1192 1275 </xsl:when> 1193 1276 <xsl:otherwise> 1194 1277 <xsl:value-of select="concat('(', $value, ' != null) ? (nsISupports)', $value, '.getWrapped() : null')" /> 1195 1278 </xsl:otherwise> 1196 1279 </xsl:choose> … … 1200 1283 <xsl:choose> 1201 1284 <xsl:when test="$safearray='yes'"> 1202 <xsl:value-of select="concat('Helper.unwrapEnum(', $elemgluetype, '.class, ', $value,')')"/>1285 <xsl:value-of select="concat('Helper.unwrapEnum(', $elemgluetype, '.class, ', $value, ')')"/> 1203 1286 </xsl:when> 1204 1287 <xsl:otherwise> 1205 <xsl:value-of select="concat($value, '.value()')"/>1288 <xsl:value-of select="concat($value, '.value()')"/> 1206 1289 </xsl:otherwise> 1207 1290 </xsl:choose> … … 1217 1300 <xsl:choose> 1218 1301 <xsl:when test="$idltype='boolean'"> 1219 <xsl:value-of select="concat('Helper.unwrapBoolean(', $value,')')"/>1302 <xsl:value-of select="concat('Helper.unwrapBoolean(', $value, ')')"/> 1220 1303 </xsl:when> 1221 1304 <xsl:when test="($idltype='long') or ($idltype='unsigned long') or ($idltype='integer')"> 1222 <xsl:value-of select="concat('Helper.unwrapInteger(', $value,')')"/>1305 <xsl:value-of select="concat('Helper.unwrapInteger(', $value, ')')"/> 1223 1306 </xsl:when> 1224 1307 <xsl:when test="($idltype='short') or ($idltype='unsigned short')"> 1225 <xsl:value-of select="concat('Helper.unwrapUShort(', $value,')')"/>1308 <xsl:value-of select="concat('Helper.unwrapUShort(', $value, ')')"/> 1226 1309 </xsl:when> 1227 1310 <xsl:when test="($idltype='unsigned long long') or ($idltype='long long')"> 1228 <xsl:value-of select="concat('Helper.unwrapULong(', $value,')')"/>1311 <xsl:value-of select="concat('Helper.unwrapULong(', $value, ')')"/> 1229 1312 </xsl:when> 1230 1313 <xsl:when test="($idltype='wstring') or ($idltype='uuid')"> 1231 <xsl:value-of select="concat('Helper.unwrapStr(', $value,')')"/>1314 <xsl:value-of select="concat('Helper.unwrapStr(', $value, ')')"/> 1232 1315 </xsl:when> 1233 1316 <xsl:otherwise> … … 1284 1367 </xsl:call-template> 1285 1368 </xsl:variable> 1286 <xsl:value-of select="concat('Helper.unwrap2(', $elemgluetype, '.class, ', $elembacktype, '.class, ', $value,')')"/>1369 <xsl:value-of select="concat('Helper.unwrap2(', $elemgluetype, '.class, ', $elembacktype, '.class, ', $value, ')')"/> 1287 1370 </xsl:when> 1288 1371 <xsl:otherwise> 1289 1372 <xsl:value-of select="concat('(', $value, ' != null) ? ', $value, '.getTypedWrapped() : null')" /> 1290 1373 </xsl:otherwise> 1291 1374 </xsl:choose> 1292 1375 </xsl:when> 1293 1376 1294 1295 1377 <xsl:when test="$idltype='$unknown'"> 1378 <xsl:choose> 1296 1379 <xsl:when test="$safearray='yes'"> 1297 <xsl:value-of select="concat('Helper.unwrap2(', $elemgluetype, '.class, Dispatch.class, ', $value,')')"/>1380 <xsl:value-of select="concat('Helper.unwrap2(', $elemgluetype, '.class, Dispatch.class, ', $value, ')')"/> 1298 1381 </xsl:when> 1299 1382 <xsl:otherwise> 1300 1383 <xsl:value-of select="concat('(', $value, ' != null) ? (Dispatch)', $value, '.getWrapped() : null')" /> 1301 1384 </xsl:otherwise> 1302 1385 </xsl:choose> … … 1306 1389 <xsl:choose> 1307 1390 <xsl:when test="$safearray='yes'"> 1308 <xsl:value-of select="concat('Helper.unwrapEnum(', $elemgluetype, '.class, ',$value,')')"/>1391 <xsl:value-of select="concat('Helper.unwrapEnum(', $elemgluetype, '.class, ', $value, ')')"/> 1309 1392 </xsl:when> 1310 1393 <xsl:otherwise> 1311 <xsl:value-of select="concat($value, '.value()')"/>1394 <xsl:value-of select="concat($value, '.value()')"/> 1312 1395 </xsl:otherwise> 1313 1396 </xsl:choose> … … 1317 1400 <xsl:choose> 1318 1401 <xsl:when test="$safearray='yes'"> 1319 <xsl:value-of select="concat('Helper.unwrapBool(', $value,')')"/>1402 <xsl:value-of select="concat('Helper.unwrapBool(', $value, ')')"/> 1320 1403 </xsl:when> 1321 1404 <xsl:otherwise> 1322 <xsl:value-of select="concat('new Variant(', $value,')')"/>1405 <xsl:value-of select="concat('new Variant(', $value, ')')"/> 1323 1406 </xsl:otherwise> 1324 1407 </xsl:choose> … … 1328 1411 <xsl:choose> 1329 1412 <xsl:when test="$safearray='yes'"> 1330 <xsl:value-of select="concat('Helper.unwrapShort(', $value,')')"/>1413 <xsl:value-of select="concat('Helper.unwrapShort(', $value, ')')"/> 1331 1414 </xsl:when> 1332 1415 <xsl:otherwise> 1333 <xsl:value-of select="concat('new Variant(', $value,')')"/>1416 <xsl:value-of select="concat('new Variant(', $value, ')')"/> 1334 1417 </xsl:otherwise> 1335 1418 </xsl:choose> … … 1340 1423 <xsl:choose> 1341 1424 <xsl:when test="$safearray='yes'"> 1342 <xsl:value-of select="concat('Helper.unwrapInt(', $value,')')"/>1425 <xsl:value-of select="concat('Helper.unwrapInt(', $value, ')')"/> 1343 1426 </xsl:when> 1344 1427 <xsl:otherwise> 1345 <xsl:value-of select="concat('new Variant(', $value,')')"/>1428 <xsl:value-of select="concat('new Variant(', $value, ')')"/> 1346 1429 </xsl:otherwise> 1347 1430 </xsl:choose> … … 1351 1434 <xsl:choose> 1352 1435 <xsl:when test="$safearray='yes'"> 1353 <xsl:value-of select="concat('Helper.unwrapString(', $value,')')"/>1436 <xsl:value-of select="concat('Helper.unwrapString(', $value, ')')"/> 1354 1437 </xsl:when> 1355 1438 <xsl:otherwise> 1356 <xsl:value-of select="concat('new Variant(', $value,')')"/>1439 <xsl:value-of select="concat('new Variant(', $value, ')')"/> 1357 1440 </xsl:otherwise> 1358 1441 </xsl:choose> … … 1362 1445 <xsl:choose> 1363 1446 <xsl:when test="$safearray='yes'"> 1364 <xsl:value-of select="concat('Helper.unwrapLong(', $value,')')"/>1447 <xsl:value-of select="concat('Helper.unwrapLong(', $value, ')')"/> 1365 1448 </xsl:when> 1366 1449 <xsl:otherwise> 1367 <xsl:value-of select="concat('new Variant(', $value,'.longValue())')"/>1450 <xsl:value-of select="concat('new Variant(', $value, '.longValue())')"/> 1368 1451 </xsl:otherwise> 1369 1452 </xsl:choose> … … 1371 1454 1372 1455 <xsl:when test="($idltype='octet') and ($safearray='yes')"> 1373 <xsl:value-of select="concat('Helper.encodeBase64(', $value, ')')"/>1456 <xsl:value-of select="concat('Helper.encodeBase64(', $value, ')')"/> 1374 1457 </xsl:when> 1375 1458 … … 1408 1491 1409 1492 <xsl:choose> 1410 1493 <xsl:when test="//interface[@name=$idltype] or $idltype='$unknown'"> 1411 1494 <xsl:choose> 1412 1495 <xsl:when test="@safearray='yes'"> 1413 <xsl:value-of select="concat('Helper.unwrap(', $value,')')"/>1496 <xsl:value-of select="concat('Helper.unwrap(', $value, ')')"/> 1414 1497 </xsl:when> 1415 1498 <xsl:otherwise> … … 1417 1500 </xsl:otherwise> 1418 1501 </xsl:choose> 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 <xsl:value-of select="concat('Helper.convertEnums(', $elemgluetype, '.class,', $elembacktype, '.class,', $value,')')"/>1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 <xsl:value-of select="concat('Helper.encodeBase64(',$value,')')"/>1448 1449 1450 1451 1452 1502 </xsl:when> 1503 1504 <xsl:when test="//enum[@name=$idltype]"> 1505 <xsl:choose> 1506 <xsl:when test="$safearray='yes'"> 1507 <xsl:variable name="elembacktype"> 1508 <xsl:call-template name="typeIdl2Back"> 1509 <xsl:with-param name="type" select="$idltype" /> 1510 <xsl:with-param name="safearray" select="'no'" /> 1511 <xsl:with-param name="forceelem" select="'yes'" /> 1512 </xsl:call-template> 1513 </xsl:variable> 1514 <xsl:value-of select="concat('Helper.convertEnums(', $elemgluetype, '.class, ', $elembacktype, '.class, ', $value, ')')"/> 1515 </xsl:when> 1516 <xsl:otherwise> 1517 <xsl:variable name="backtype"> 1518 <xsl:call-template name="typeIdl2Back"> 1519 <xsl:with-param name="type" select="$idltype" /> 1520 <xsl:with-param name="safearray" select="'no'" /> 1521 <xsl:with-param name="forceelem" select="'yes'" /> 1522 </xsl:call-template> 1523 </xsl:variable> 1524 <xsl:value-of select="concat($backtype, '.fromValue(', $value, '.name())')"/> 1525 </xsl:otherwise> 1526 </xsl:choose> 1527 </xsl:when> 1528 1529 <xsl:when test="($idltype='octet') and ($safearray='yes')"> 1530 <xsl:value-of select="concat('Helper.encodeBase64(', $value, ')')"/> 1531 </xsl:when> 1532 1533 <xsl:otherwise> 1534 <xsl:value-of select="$value"/> 1535 </xsl:otherwise> 1453 1536 </xsl:choose> 1454 1537 … … 1497 1580 <xsl:choose> 1498 1581 <xsl:when test="($G_vboxGlueStyle='xpcom')"> 1499 <xsl: value-of select="' '" />1582 <xsl:text> </xsl:text> 1500 1583 <xsl:if test="param[@dir='return']"> 1501 1584 <xsl:value-of select="concat($retval, ' = ')" /> 1502 1585 </xsl:if> 1503 <xsl:value-of select="concat('getTypedWrapped().', $methodname, '(')"/>1586 <xsl:value-of select="concat('getTypedWrapped().', $methodname, '(')"/> 1504 1587 <xsl:for-each select="param"> 1505 <xsl:choose> 1506 <xsl:when test="@dir='return'"> 1507 <xsl:if test="@safearray='yes'"> 1508 <xsl:value-of select="'null'" /> 1509 </xsl:if> 1510 </xsl:when> 1511 <xsl:when test="@dir='out'"> 1512 <xsl:if test="@safearray='yes'"> 1513 <xsl:value-of select="'null, '" /> 1514 </xsl:if> 1515 <xsl:value-of select="concat('tmp_', @name)" /> 1516 </xsl:when> 1517 <xsl:when test="@dir='in'"> 1518 <xsl:if test="(@safearray='yes') and not(@type = 'octet')"> 1519 <xsl:value-of select="concat(@name,'.size(), ')" /> 1520 </xsl:if> 1521 <xsl:variable name="unwrapped"> 1522 <xsl:call-template name="cookInParam"> 1523 <xsl:with-param name="value" select="@name" /> 1524 <xsl:with-param name="idltype" select="@type" /> 1525 <xsl:with-param name="safearray" select="@safearray" /> 1526 </xsl:call-template> 1527 </xsl:variable> 1528 <xsl:value-of select="$unwrapped"/> 1529 </xsl:when> 1530 <xsl:otherwise> 1531 <xsl:call-template name="fatalError"> 1532 <xsl:with-param name="msg" select="concat('Unsupported param dir: ', @dir, '".')" /> 1588 <xsl:choose> 1589 <xsl:when test="@dir='return'"> 1590 <xsl:if test="@safearray='yes'"> 1591 <xsl:text>null</xsl:text> 1592 </xsl:if> 1593 </xsl:when> 1594 <xsl:when test="@dir='out'"> 1595 <xsl:if test="@safearray='yes'"> 1596 <xsl:text>null, </xsl:text> 1597 </xsl:if> 1598 <xsl:value-of select="concat('tmp_', @name)" /> 1599 </xsl:when> 1600 <xsl:when test="@dir='in'"> 1601 <xsl:if test="(@safearray='yes') and not(@type = 'octet')"> 1602 <xsl:value-of select="concat(@name, '.size(), ')" /> 1603 </xsl:if> 1604 <xsl:variable name="unwrapped"> 1605 <xsl:call-template name="cookInParam"> 1606 <xsl:with-param name="value" select="@name" /> 1607 <xsl:with-param name="idltype" select="@type" /> 1608 <xsl:with-param name="safearray" select="@safearray" /> 1533 1609 </xsl:call-template> 1534 </xsl:otherwise> 1535 </xsl:choose> 1536 <xsl:if test="not(position()=last()) and not(following-sibling::param[1]/@dir='return' and not(following-sibling::param[1]/@safearray='yes'))"> 1537 <xsl:value-of select="', '"/> 1538 </xsl:if> 1610 </xsl:variable> 1611 <xsl:value-of select="$unwrapped"/> 1612 </xsl:when> 1613 <xsl:otherwise> 1614 <xsl:call-template name="fatalError"> 1615 <xsl:with-param name="msg" select="concat('Unsupported param dir: ', @dir, '".')" /> 1616 </xsl:call-template> 1617 </xsl:otherwise> 1618 </xsl:choose> 1619 <xsl:if test="not(position()=last()) and not(following-sibling::param[1]/@dir='return' and not(following-sibling::param[1]/@safearray='yes'))"> 1620 <xsl:text>, </xsl:text> 1621 </xsl:if> 1539 1622 </xsl:for-each> 1540 <xsl: value-of select="'); '"/>1623 <xsl:text>); </xsl:text> 1541 1624 </xsl:when> 1542 1625 1543 1626 <xsl:when test="($G_vboxGlueStyle='mscom')"> 1544 <xsl: value-of select="' '" />1627 <xsl:text> </xsl:text> 1545 1628 <xsl:if test="param[@dir='return']"> 1546 1629 <xsl:value-of select="concat($retval, ' = ')" /> 1547 1630 </xsl:if> 1548 <xsl:value-of select="concat('Helper.invoke(getTypedWrapped(), "', 1631 <xsl:value-of select="concat('Helper.invoke(getTypedWrapped(), "', $methodname, '" ')"/> 1549 1632 <xsl:for-each select="param[not(@dir='return')]"> 1550 <xsl: value-of select="', '"/>1633 <xsl:text>, </xsl:text> 1551 1634 <xsl:choose> 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1635 <xsl:when test="@dir='out'"> 1636 <xsl:value-of select="concat('tmp_', @name)" /> 1637 </xsl:when> 1638 <xsl:when test="@dir='in'"> 1639 <xsl:variable name="unwrapped"> 1640 <xsl:call-template name="cookInParam"> 1641 <xsl:with-param name="value" select="@name" /> 1642 <xsl:with-param name="idltype" select="@type" /> 1643 <xsl:with-param name="safearray" select="@safearray" /> 1644 </xsl:call-template> 1645 </xsl:variable> 1646 <xsl:value-of select="$unwrapped"/> 1647 </xsl:when> 1565 1648 </xsl:choose> 1566 1649 </xsl:for-each> 1567 <xsl: value-of select="'); '"/>1568 </xsl:when> 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 <xsl:value-of select="'obj'"/>1580 1581 1582 1583 1584 <xsl:value-of select="' '" />1585 1586 1587 1588 1589 1590 <xsl:value-of select="', '"/>1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 <xsl:value-of select="', '"/>1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 <xsl:value-of select="', '"/>1637 1638 1639 1640 1641 <xsl:value-of select="'); '"/>1642 1650 <xsl:text>); </xsl:text> 1651 </xsl:when> 1652 1653 <xsl:when test="($G_vboxGlueStyle='jaxws')"> 1654 <xsl:variable name="jaxwsmethod"> 1655 <xsl:call-template name="makeJaxwsMethod"> 1656 <xsl:with-param name="ifname" select="$ifname" /> 1657 <xsl:with-param name="methodname" select="$methodname" /> 1658 </xsl:call-template> 1659 </xsl:variable> 1660 <xsl:variable name="portArg"> 1661 <xsl:if test="not(//interface[@name=$ifname]/@wsmap='global')"> 1662 <xsl:text>obj</xsl:text> 1663 </xsl:if> 1664 </xsl:variable> 1665 <xsl:variable name="paramsinout" select="param[@dir='in' or @dir='out']" /> 1666 1667 <xsl:text> </xsl:text> 1668 <xsl:if test="param[@dir='return'] and not(param[@dir='out'])"> 1669 <xsl:value-of select="concat($retval, ' = ')" /> 1670 </xsl:if> 1671 <xsl:value-of select="concat('port.', $jaxwsmethod, '(', $portArg)" /> 1672 <xsl:if test="$paramsinout and not($portArg='')"> 1673 <xsl:text>, </xsl:text> 1674 </xsl:if> 1675 1676 <!-- jax-ws has an oddity: if both out params and a return value exist, 1677 then the return value is moved to the function's argument list... --> 1678 <xsl:choose> 1679 <xsl:when test="param[@dir='out'] and param[@dir='return']"> 1680 <xsl:for-each select="param"> 1681 <xsl:choose> 1682 <xsl:when test="@dir='return'"> 1683 <xsl:value-of select="$retval"/> 1684 </xsl:when> 1685 <xsl:when test="@dir='out'"> 1686 <xsl:value-of select="concat('tmp_', @name)" /> 1687 </xsl:when> 1688 <xsl:otherwise> 1689 <xsl:call-template name="cookInParam"> 1690 <xsl:with-param name="value" select="@name" /> 1691 <xsl:with-param name="idltype" select="@type" /> 1692 <xsl:with-param name="safearray" select="@safearray" /> 1693 </xsl:call-template> 1694 </xsl:otherwise> 1695 </xsl:choose> 1696 <xsl:if test="not(position()=last())"> 1697 <xsl:text>, </xsl:text> 1698 </xsl:if> 1699 </xsl:for-each> 1700 </xsl:when> 1701 <xsl:otherwise> 1702 <xsl:for-each select="$paramsinout"> 1703 <xsl:choose> 1704 <xsl:when test="@dir='return'"> 1705 <xsl:value-of select="$retval"/> 1706 </xsl:when> 1707 <xsl:when test="@dir='out'"> 1708 <xsl:value-of select="concat('tmp_', @name)" /> 1709 </xsl:when> 1710 <xsl:otherwise> 1711 <xsl:call-template name="cookInParam"> 1712 <xsl:with-param name="value" select="@name" /> 1713 <xsl:with-param name="idltype" select="@type" /> 1714 <xsl:with-param name="safearray" select="@safearray" /> 1715 </xsl:call-template> 1716 </xsl:otherwise> 1717 </xsl:choose> 1718 <xsl:if test="not(position()=last())"> 1719 <xsl:text>, </xsl:text> 1720 </xsl:if> 1721 </xsl:for-each> 1722 </xsl:otherwise> 1723 </xsl:choose> 1724 <xsl:text>); </xsl:text> 1725 </xsl:when> 1643 1726 1644 1727 <xsl:otherwise> … … 1658 1741 1659 1742 <xsl:choose> 1660 1661 <xsl:when test="$G_vboxGlueStyle='xpcom'"> 1662 <xsl:value-of select="concat(' ', $backtype, ' ', $retval,' = getTypedWrapped().', $gettername,'(')" /> 1663 <xsl:if test="@safearray"> 1664 <xsl:value-of select="'null'" /> 1665 </xsl:if> 1666 <xsl:value-of select="'); '" /> 1667 </xsl:when> 1668 1669 <xsl:when test="$G_vboxGlueStyle='mscom'"> 1670 <xsl:value-of select="concat(' ', $backtype, ' ', $retval,' = Dispatch.get(getTypedWrapped(), "', @name,'"); ')" /> 1671 </xsl:when> 1672 1673 <xsl:when test="$G_vboxGlueStyle='jaxws'"> 1674 <xsl:variable name="jaxwsGetter"> 1675 <xsl:call-template name="makeJaxwsMethod"> 1676 <xsl:with-param name="ifname" select="$ifname" /> 1677 <xsl:with-param name="methodname" select="$gettername" /> 1678 </xsl:call-template> 1679 </xsl:variable> 1680 <xsl:value-of select="concat(' ', $backtype, ' ', $retval,' = port.', $jaxwsGetter, '(obj); ')" /> 1681 </xsl:when> 1682 1683 <xsl:otherwise> 1684 <xsl:call-template name="fatalError"> 1685 <xsl:with-param name="msg" select="'Style unknown (genGetterCall)'" /> 1686 </xsl:call-template> 1687 </xsl:otherwise> 1688 1743 <xsl:when test="$G_vboxGlueStyle='xpcom'"> 1744 <xsl:value-of select="concat(' ', $backtype, ' ', $retval, ' = getTypedWrapped().', $gettername, '(')" /> 1745 <xsl:if test="@safearray"> 1746 <xsl:text>null</xsl:text> 1747 </xsl:if> 1748 <xsl:text>); </xsl:text> 1749 </xsl:when> 1750 1751 <xsl:when test="$G_vboxGlueStyle='mscom'"> 1752 <xsl:value-of select="concat(' ', $backtype, ' ', $retval, ' = Dispatch.get(getTypedWrapped(), "', @name, '"); ')" /> 1753 </xsl:when> 1754 1755 <xsl:when test="$G_vboxGlueStyle='jaxws'"> 1756 <xsl:variable name="jaxwsGetter"> 1757 <xsl:call-template name="makeJaxwsMethod"> 1758 <xsl:with-param name="ifname" select="$ifname" /> 1759 <xsl:with-param name="methodname" select="$gettername" /> 1760 </xsl:call-template> 1761 </xsl:variable> 1762 <xsl:value-of select="concat(' ', $backtype, ' ', $retval, ' = port.', $jaxwsGetter, '(obj); ')" /> 1763 </xsl:when> 1764 1765 <xsl:otherwise> 1766 <xsl:call-template name="fatalError"> 1767 <xsl:with-param name="msg" select="'Style unknown (genGetterCall)'" /> 1768 </xsl:call-template> 1769 </xsl:otherwise> 1689 1770 </xsl:choose> 1690 1771 </xsl:template> … … 1696 1777 1697 1778 <xsl:choose> 1698 <xsl:when test="$G_vboxGlueStyle='xpcom'">1699 <xsl:value-of select="concat(' getTypedWrapped().', $settername, '(', $value,'); ')" />1700 </xsl:when>1701 1702 <xsl:when test="$G_vboxGlueStyle='mscom'">1703 <xsl:value-of select="concat(' Dispatch.put(getTypedWrapped(), "', @name,'", ',$value, '); ')" />1704 </xsl:when>1705 1706 <xsl:when test="$G_vboxGlueStyle='jaxws'">1779 <xsl:when test="$G_vboxGlueStyle='xpcom'"> 1780 <xsl:value-of select="concat(' getTypedWrapped().', $settername, '(', $value, '); ')" /> 1781 </xsl:when> 1782 1783 <xsl:when test="$G_vboxGlueStyle='mscom'"> 1784 <xsl:value-of select="concat(' Dispatch.put(getTypedWrapped(), "', @name, '", ', $value, '); ')" /> 1785 </xsl:when> 1786 1787 <xsl:when test="$G_vboxGlueStyle='jaxws'"> 1707 1788 <xsl:variable name="jaxwsSetter"> 1708 1789 <xsl:call-template name="makeJaxwsMethod"> … … 1711 1792 </xsl:call-template> 1712 1793 </xsl:variable> 1713 <xsl:value-of select="concat(' port.', $jaxwsSetter, '(obj, ', $value,'); ')" /> 1714 </xsl:when> 1715 1716 <xsl:otherwise> 1717 <xsl:call-template name="fatalError"> 1718 <xsl:with-param name="msg" select="'Style unknown (genSetterCall)'" /> 1719 </xsl:call-template> 1720 </xsl:otherwise> 1721 1794 <xsl:value-of select="concat(' port.', $jaxwsSetter, '(obj, ', $value, '); ')" /> 1795 </xsl:when> 1796 1797 <xsl:otherwise> 1798 <xsl:call-template name="fatalError"> 1799 <xsl:with-param name="msg" select="'Style unknown (genSetterCall)'" /> 1800 </xsl:call-template> 1801 </xsl:otherwise> 1722 1802 </xsl:choose> 1723 1803 </xsl:template> … … 1726 1806 <xsl:param name="ifname"/> 1727 1807 1728 <xsl:value-of select="concat(' private ', $G_virtualBoxPackageCom,'.',$ifname, ' real; ')"/> 1729 <xsl:value-of select="' private VboxPortType port; '"/> 1730 1731 <xsl:value-of select="concat(' public ', $ifname, '(', $G_virtualBoxPackageCom,'.',$ifname,' real, VboxPortType port) { this.real = real; this.port = port; } ')"/> 1808 <xsl:value-of select="concat(' private ', $G_virtualBoxPackageCom, '.', $ifname, ' real; ')"/> 1809 <xsl:text> private VboxPortType port; </xsl:text> 1810 1811 <xsl:value-of select="concat(' public ', $ifname, '(', $G_virtualBoxPackageCom, '.', $ifname, ' real, VboxPortType port) ')" /> 1812 <xsl:text> { </xsl:text> 1813 <xsl:text> this.real = real; </xsl:text> 1814 <xsl:text> this.port = port; </xsl:text> 1815 <xsl:text> } </xsl:text> 1732 1816 1733 1817 <xsl:for-each select="attribute"> 1734 1818 <xsl:variable name="attrname"><xsl:value-of select="@name" /></xsl:variable> 1735 1819 <xsl:variable name="attrtype"><xsl:value-of select="@type" /></xsl:variable> 1736 <xsl:variable name="attrreadonly"><xsl:value-of select="@readonly" /></xsl:variable>1737 1820 <xsl:variable name="attrsafearray"><xsl:value-of select="@safearray" /></xsl:variable> 1738 1821 1739 <xsl:if test="not($attrreadonly)"> 1740 <xsl:call-template name="fatalError"> 1741 <xsl:with-param name="msg" select="'Non read-only struct (genStructWrapperJaxws)'" /> 1742 </xsl:call-template> 1743 </xsl:if> 1744 1745 <xsl:if test="($G_vboxGlueStyle != 'jaxws') or (@wsmap != 'suppress')"> 1822 <xsl:if test="not(@wsmap = 'suppress')"> 1823 1824 <xsl:if test="not(@readonly = 'yes')"> 1825 <xsl:call-template name="fatalError"> 1826 <xsl:with-param name="msg" select="concat('Non read-only struct (genStructWrapperJaxws) in interface ', $ifname, ', attribute ', $attrname)" /> 1827 </xsl:call-template> 1828 </xsl:if> 1829 1746 1830 <!-- Emit getter --> 1747 1831 <xsl:variable name="backgettername"> … … 1763 1847 </xsl:choose> 1764 1848 </xsl:variable> 1765 1849 1766 1850 <xsl:variable name="gluegettername"> 1767 1851 <xsl:call-template name="makeGetterName"> … … 1776 1860 </xsl:call-template> 1777 1861 </xsl:variable> 1778 1862 1779 1863 <xsl:variable name="backgettertype"> 1780 1864 <xsl:call-template name="typeIdl2Back"> … … 1783 1867 </xsl:call-template> 1784 1868 </xsl:variable> 1785 1786 <xsl:value-of select="concat(' public ', $gluegettertype, ' ', $gluegettername, '() { ')" /> 1787 <xsl:value-of select="concat(' ', $backgettertype, ' retVal = real.', $backgettername, '(); ')" /> 1869 1870 <xsl:apply-templates select="desc" mode="attribute_get"/> 1871 <xsl:value-of select="concat(' public ', $gluegettertype, ' ', $gluegettername, '() ')" /> 1872 <xsl:text> { </xsl:text> 1873 <xsl:value-of select="concat(' ', $backgettertype, ' retVal = real.', $backgettername, '(); ')" /> 1788 1874 <xsl:variable name="wrapped"> 1789 1875 <xsl:call-template name="cookOutParam"> … … 1793 1879 </xsl:call-template> 1794 1880 </xsl:variable> 1795 <xsl:value-of select="concat(' 1796 <xsl: value-of select=" ' } '" />1881 <xsl:value-of select="concat(' return ', $wrapped, '; ')" /> 1882 <xsl:text> } </xsl:text> 1797 1883 </xsl:if> 1798 1884 … … 1834 1920 <xsl:choose> 1835 1921 <xsl:when test="(param[@dir='out']) and ($G_vboxGlueStyle='jaxws')"> 1836 <xsl: value-of select="'retVal.value'"/>1922 <xsl:text>retVal.value</xsl:text> 1837 1923 </xsl:when> 1838 1924 <xsl:otherwise> 1839 <xsl: value-of select="'retVal'"/>1925 <xsl:text>retVal</xsl:text> 1840 1926 </xsl:otherwise> 1841 1927 </xsl:choose> … … 1860 1946 </xsl:choose> 1861 1947 <xsl:if test="not(position()=last())"> 1862 <xsl: value-of select="', '" />1948 <xsl:text>, </xsl:text> 1863 1949 </xsl:if> 1864 1950 </xsl:for-each> 1865 <xsl:value-of select="') { '"/> 1951 <xsl:text>) </xsl:text> 1952 <xsl:text> { </xsl:text> 1866 1953 1867 1954 <xsl:call-template name="startExcWrapper"/> … … 1877 1964 <xsl:choose> 1878 1965 <xsl:when test="$G_vboxGlueStyle='xpcom'"> 1879 <xsl:value-of select="concat(' ', $backouttype, '[] tmp_', @name, ' = (', $backouttype, '[])java.lang.reflect.Array.newInstance(',$backouttype,'.class, 1); ')"/>1966 <xsl:value-of select="concat(' ', $backouttype, '[] tmp_', @name, ' = (', $backouttype, '[])java.lang.reflect.Array.newInstance(', $backouttype, '.class, 1); ')"/> 1880 1967 </xsl:when> 1881 1968 <xsl:when test="$G_vboxGlueStyle='mscom'"> 1882 <xsl:value-of select="concat(' Variant 1969 <xsl:value-of select="concat(' Variant tmp_', @name, ' = new Variant(); ')"/> 1883 1970 </xsl:when> 1884 1971 <xsl:when test="$G_vboxGlueStyle='jaxws'"> 1885 <xsl:value-of select="concat(' javax.xml.ws.Holder<', $backouttype, '> tmp_', @name, ' = new javax.xml.ws.Holder<', $backouttype,'>(); ')"/>1972 <xsl:value-of select="concat(' javax.xml.ws.Holder<', $backouttype, '> tmp_', @name, ' = new javax.xml.ws.Holder<', $backouttype, '>(); ')"/> 1886 1973 </xsl:when> 1887 1974 <xsl:otherwise> … … 1908 1995 </xsl:when> 1909 1996 <xsl:otherwise> 1910 <xsl:value-of select="concat(' ', $backrettype, ' 1997 <xsl:value-of select="concat(' ', $backrettype, ' retVal; ')"/> 1911 1998 </xsl:otherwise> 1912 1999 </xsl:choose> … … 1920 2007 </xsl:call-template> 1921 2008 1922 2009 <!-- return out params --> 1923 2010 <xsl:for-each select="param[@dir='out']"> 1924 2011 <xsl:variable name="varval"> 1925 2012 <xsl:choose> 1926 2013 <xsl:when test="$G_vboxGlueStyle='xpcom'"> 1927 <xsl:value-of select="concat('tmp_', @name,'[0]')" />2014 <xsl:value-of select="concat('tmp_', @name, '[0]')" /> 1928 2015 </xsl:when> 1929 2016 <xsl:when test="$G_vboxGlueStyle='mscom'"> 1930 <xsl:value-of select="concat('tmp_',@name)" />2017 <xsl:value-of select="concat('tmp_', @name)" /> 1931 2018 </xsl:when> 1932 2019 <xsl:when test="$G_vboxGlueStyle='jaxws'"> 1933 <xsl:value-of select="concat('tmp_', @name,'.value')" />2020 <xsl:value-of select="concat('tmp_', @name, '.value')" /> 1934 2021 </xsl:when> 1935 2022 <xsl:otherwise> … … 1947 2034 </xsl:call-template> 1948 2035 </xsl:variable> 1949 <xsl:value-of select="concat(' ', @name, '.value = ', $wrapped,'; ')"/>2036 <xsl:value-of select="concat(' ', @name, '.value = ', $wrapped, '; ')"/> 1950 2037 </xsl:for-each> 1951 2038 … … 1963 2050 <xsl:call-template name="endExcWrapper"/> 1964 2051 1965 <xsl: value-of select="' } '"/>2052 <xsl:text> } </xsl:text> 1966 2053 </xsl:otherwise> 1967 2054 </xsl:choose> … … 2015 2102 </xsl:if> 2016 2103 </xsl:for-each> 2017 <xsl: value-of select="'); '"/>2104 <xsl:text>); </xsl:text> 2018 2105 </xsl:otherwise> 2019 2106 </xsl:choose> … … 2025 2112 <xsl:param name="uuid" /> 2026 2113 2027 <xsl:value-of select="concat(' public static ', $ifname, ' queryInterface(IUnknown obj) { ')" /> 2114 <xsl:value-of select="concat(' public static ', $ifname, ' queryInterface(IUnknown obj) ')" /> 2115 <xsl:text> { </xsl:text> 2028 2116 <xsl:choose> 2029 2117 <xsl:when test="$G_vboxGlueStyle='xpcom'"> … … 2033 2121 </xsl:call-template> 2034 2122 </xsl:variable> 2035 <xsl: value-of select=" ' nsISupports nsobj = obj != null ? (nsISupports)obj.getWrapped() : null; '"/>2036 <xsl: value-of select=" ' if (nsobj == null) return null; '"/>2037 <xsl:value-of select="concat(' ', $backtype, ' qiobj = Helper.queryInterface(nsobj, "{',$uuid,'}", ',$backtype,'.class); ')" />2123 <xsl:text> nsISupports nsobj = obj != null ? (nsISupports)obj.getWrapped() : null; </xsl:text> 2124 <xsl:text> if (nsobj == null) return null; </xsl:text> 2125 <xsl:value-of select="concat(' ', $backtype, ' qiobj = Helper.queryInterface(nsobj, "{', $uuid, '}", ', $backtype, '.class); ')" /> 2038 2126 <xsl:value-of select="concat(' return qiobj == null ? null : new ', $ifname, '(qiobj); ')" /> 2039 2127 </xsl:when> … … 2055 2143 2056 2144 </xsl:choose> 2057 <xsl: value-of select=" ' } '" />2145 <xsl:text> } </xsl:text> 2058 2146 </xsl:template> 2059 2147 … … 2102 2190 <xsl:otherwise> 2103 2191 <xsl:if test="@safearray"> 2104 <xsl:value-of select="concat('long len_', @name,', ')" />2192 <xsl:value-of select="concat('long len_', @name, ', ')" /> 2105 2193 </xsl:if> 2106 2194 <xsl:value-of select="concat($parambacktype, ' ', @name)" /> … … 2111 2199 </xsl:if> 2112 2200 </xsl:for-each> 2113 <xsl:value-of select="') { '"/> 2201 <xsl:text>) </xsl:text> 2202 <xsl:text> { </xsl:text> 2114 2203 </xsl:when> 2115 2204 … … 2121 2210 </xsl:variable> 2122 2211 <xsl:value-of select="concat(' public ', $returnbacktype, ' ', $capsname, '(')" /> 2123 <xsl: value-of select="'Variant _args[]'"/>2124 <xsl: value-of select="') { '"/>2212 <xsl:text>Variant _args[]) </xsl:text> 2213 <xsl:text> { </xsl:text> 2125 2214 <xsl:for-each select="exsl:node-set($paramsinout)"> 2126 2215 <xsl:variable name="parambacktype"> … … 2130 2219 </xsl:call-template> 2131 2220 </xsl:variable> 2132 <xsl:value-of select="concat(' ', $parambacktype, ' ', @name, '=_args[', count(preceding-sibling::param), ']; ')" />2221 <xsl:value-of select="concat(' ', $parambacktype, ' ', @name, '=_args[', count(preceding-sibling::param), ']; ')" /> 2133 2222 </xsl:for-each> 2134 2223 </xsl:when> 2135 2224 2136 <xsl:otherwise> 2137 <xsl:call-template name="fatalError"> 2138 <xsl:with-param name="msg" select="'Style unknown (genSetterCall)'" /> 2139 </xsl:call-template> 2140 </xsl:otherwise> 2141 2225 <xsl:otherwise> 2226 <xsl:call-template name="fatalError"> 2227 <xsl:with-param name="msg" select="'Style unknown (genSetterCall)'" /> 2228 </xsl:call-template> 2229 </xsl:otherwise> 2142 2230 </xsl:choose> 2143 2231 … … 2165 2253 2166 2254 <!-- Method call --> 2167 <xsl:value-of select="concat(' sink.', $methodname, '(')"/>2255 <xsl:value-of select="concat(' sink.', $methodname, '(')"/> 2168 2256 <xsl:for-each select="param[not(@dir='return')]"> 2169 <xsl:choose> 2170 <xsl:when test="@dir='out'"> 2171 <xsl:value-of select="concat('tmp_', @name)" /> 2172 </xsl:when> 2173 <xsl:when test="@dir='in'"> 2174 <xsl:variable name="wrapped"> 2175 <xsl:call-template name="cookOutParam"> 2176 <xsl:with-param name="value" select="@name" /> 2177 <xsl:with-param name="idltype" select="@type" /> 2178 <xsl:with-param name="safearray" select="@safearray" /> 2179 </xsl:call-template> 2180 </xsl:variable> 2181 <xsl:value-of select="$wrapped"/> 2182 </xsl:when> 2183 <xsl:otherwise> 2184 <xsl:call-template name="fatalError"> 2185 <xsl:with-param name="msg" select="concat('Unsupported param dir: ', @dir, '".')" /> 2257 <xsl:choose> 2258 <xsl:when test="@dir='out'"> 2259 <xsl:value-of select="concat('tmp_', @name)" /> 2260 </xsl:when> 2261 <xsl:when test="@dir='in'"> 2262 <xsl:variable name="wrapped"> 2263 <xsl:call-template name="cookOutParam"> 2264 <xsl:with-param name="value" select="@name" /> 2265 <xsl:with-param name="idltype" select="@type" /> 2266 <xsl:with-param name="safearray" select="@safearray" /> 2186 2267 </xsl:call-template> 2187 </xsl:otherwise> 2188 </xsl:choose> 2189 <xsl:if test="not(position()=last())"> 2190 <xsl:value-of select="', '"/> 2191 </xsl:if> 2268 </xsl:variable> 2269 <xsl:value-of select="$wrapped"/> 2270 </xsl:when> 2271 <xsl:otherwise> 2272 <xsl:call-template name="fatalError"> 2273 <xsl:with-param name="msg" select="concat('Unsupported param dir: ', @dir, '".')" /> 2274 </xsl:call-template> 2275 </xsl:otherwise> 2276 </xsl:choose> 2277 <xsl:if test="not(position()=last())"> 2278 <xsl:text>, </xsl:text> 2279 </xsl:if> 2192 2280 </xsl:for-each> 2193 <xsl: value-of select="'); '"/>2194 2195 2281 <xsl:text>); </xsl:text> 2282 2283 <!-- return out params --> 2196 2284 <xsl:for-each select="param[@dir='out']"> 2197 2285 2198 2286 <xsl:variable name="unwrapped"> 2199 2287 <xsl:call-template name="cookInParam"> 2200 <xsl:with-param name="value" select="concat('tmp_', @name,'.value')" />2288 <xsl:with-param name="value" select="concat('tmp_', @name, '.value')" /> 2201 2289 <xsl:with-param name="idltype" select="@type" /> 2202 2290 <xsl:with-param name="safearray" select="@safearray" /> … … 2205 2293 <xsl:choose> 2206 2294 <xsl:when test="$G_vboxGlueStyle='xpcom'"> 2207 <xsl:value-of select="concat(' ', @name, '[0] = ', $unwrapped,'; ')"/>2295 <xsl:value-of select="concat(' ', @name, '[0] = ', $unwrapped, '; ')"/> 2208 2296 </xsl:when> 2209 2297 <xsl:when test="$G_vboxGlueStyle='mscom'"> 2210 <xsl:value-of select="concat(' _args[', count(preceding-sibling::param),'] = ',$unwrapped,'; ')"/>2298 <xsl:value-of select="concat(' _args[', count(preceding-sibling::param), '] = ', $unwrapped, '; ')"/> 2211 2299 </xsl:when> 2212 2300 </xsl:choose> … … 2224 2312 <xsl:value-of select="concat(' return ', $unwrapped, '; ')" /> 2225 2313 </xsl:if> 2226 <xsl: value-of select="' } '"/>2314 <xsl:text> } </xsl:text> 2227 2315 </xsl:otherwise> 2228 2316 </xsl:choose> … … 2242 2330 <xsl:choose> 2243 2331 <xsl:when test="($G_vboxGlueStyle='jaxws')"> 2244 <xsl:value-of select="concat(' public ', $ifname, '(String wrapped, VboxPortType port) { ')" /> 2245 <xsl:value-of select=" ' super(wrapped, port); '"/> 2246 <xsl:value-of select=" ' } '"/> 2332 <xsl:value-of select="concat(' public ', $ifname, '(String wrapped, VboxPortType port) ')" /> 2333 <xsl:text> { </xsl:text> 2334 <xsl:text> super(wrapped, port); </xsl:text> 2335 <xsl:text> } </xsl:text> 2247 2336 </xsl:when> 2248 2337 2249 2338 <xsl:when test="($G_vboxGlueStyle='xpcom') or ($G_vboxGlueStyle='mscom')"> 2250 <xsl:value-of select="concat(' public ', $ifname, '(', $wrappedType,' wrapped) { ')" /> 2251 <xsl:value-of select=" ' super(wrapped); '"/> 2252 <xsl:value-of select=" ' } '"/> 2339 <xsl:value-of select="concat(' public ', $ifname, '(', $wrappedType, ' wrapped) ')" /> 2340 <xsl:text> { </xsl:text> 2341 <xsl:text> super(wrapped); </xsl:text> 2342 <xsl:text> } </xsl:text> 2253 2343 2254 2344 <!-- Typed wrapped object accessor --> 2255 <xsl:value-of select="concat(' public ', $wrappedType, ' getTypedWrapped() { ')" /> 2256 <xsl:value-of select="concat(' return (', $wrappedType, ') getWrapped(); ')" /> 2257 <xsl:value-of select=" ' } '" /> 2345 <xsl:value-of select="concat(' public ', $wrappedType, ' getTypedWrapped() ')" /> 2346 <xsl:text> { </xsl:text> 2347 <xsl:value-of select="concat(' return (', $wrappedType, ') getWrapped(); ')" /> 2348 <xsl:text> } </xsl:text> 2258 2349 </xsl:when> 2259 2350 … … 2268 2359 <xsl:variable name="attrname"><xsl:value-of select="@name" /></xsl:variable> 2269 2360 <xsl:variable name="attrtype"><xsl:value-of select="@type" /></xsl:variable> 2270 <xsl:variable name="attrreadonly"><xsl:value-of select="@readonly" /></xsl:variable>2271 2361 <xsl:variable name="attrsafearray"><xsl:value-of select="@safearray" /></xsl:variable> 2272 2362 2273 2363 <xsl:choose> 2274 2364 <xsl:when test="($G_vboxGlueStyle='jaxws') and ($attrtype=($G_setSuppressedInterfaces/@name))"> 2275 <xsl:value-of select="concat(' // Skipping attribute ', $attrname, ' of suppressed type ', $attrtype, ' ')" />2365 <xsl:value-of select="concat(' // Skipping attribute ', $attrname, ' of suppressed type ', $attrtype, ' ')" /> 2276 2366 </xsl:when> 2277 2367 <xsl:when test="($G_vboxGlueStyle='jaxws') and (@wsmap = 'suppress')" > … … 2306 2396 </xsl:call-template> 2307 2397 </xsl:variable> 2308 <xsl:value-of select="concat(' public ', $gluetype, ' ', $gettername, '() { ')" /> 2398 <xsl:value-of select="concat(' public ', $gluetype, ' ', $gettername, '() ')" /> 2399 <xsl:text> { </xsl:text> 2309 2400 2310 2401 <xsl:call-template name="startExcWrapper"/> … … 2318 2409 </xsl:call-template> 2319 2410 2320 <xsl:value-of select="concat(' return ', $wrapped, '; ')" />2411 <xsl:value-of select="concat(' return ', $wrapped, '; ')" /> 2321 2412 <xsl:call-template name="endExcWrapper"/> 2322 2413 2323 <xsl: value-of select= "' } '" />2324 <xsl:if test="not(@readonly ='yes')">2414 <xsl:text> } </xsl:text> 2415 <xsl:if test="not(@readonly = 'yes')"> 2325 2416 <!-- emit setter method --> 2326 2417 <xsl:apply-templates select="desc" mode="attribute_set"/> … … 2334 2425 </xsl:call-template> 2335 2426 </xsl:variable> 2336 <xsl:value-of select="concat(' public void ', $settername, '(', $gluetype, ' value) { ')" /> 2427 <xsl:value-of select="concat(' public void ', $settername, '(', $gluetype, ' value) ')" /> 2428 <xsl:text> { </xsl:text> 2337 2429 <xsl:call-template name="startExcWrapper"/> 2338 2430 <!-- Actual setter implementation --> … … 2343 2435 </xsl:call-template> 2344 2436 <xsl:call-template name="endExcWrapper"/> 2345 <xsl: value-of select= "' } '" />2437 <xsl:text> } </xsl:text> 2346 2438 </xsl:if> 2347 2439 … … 2378 2470 </xsl:call-template> 2379 2471 2380 <xsl:text>import java.util.List; </xsl:text> 2381 2382 <xsl:apply-templates select="desc" mode="interface"/> 2383 2384 <xsl:choose> 2385 <xsl:when test="($wsmap='struct') and ($G_vboxGlueStyle='jaxws')"> 2386 <xsl:value-of select="concat('public class ', $ifname, ' { ')" /> 2387 <xsl:call-template name="genStructWrapperJaxws"> 2388 <xsl:with-param name="ifname" select="$ifname" /> 2389 </xsl:call-template> 2390 </xsl:when> 2391 2392 <xsl:otherwise> 2393 <xsl:variable name="extends" select="//interface[@name=$ifname]/@extends" /> 2394 <xsl:choose> 2395 <xsl:when test="($extends = '$unknown') or ($extends = '$dispatched') or ($extends = '$errorinfo')"> 2396 <xsl:value-of select="concat('public class ', $ifname, ' extends IUnknown { ')" /> 2397 </xsl:when> 2398 <xsl:when test="//interface[@name=$extends]"> 2399 <xsl:value-of select="concat('public class ', $ifname, ' extends ', $extends, ' { ')" /> 2400 </xsl:when> 2401 <xsl:otherwise> 2402 <xsl:call-template name="fatalError"> 2403 <xsl:with-param name="msg" select="concat('Interface generation: interface "', $ifname, '" has invalid "extends" value ', $extends, '.')" /> 2404 </xsl:call-template> 2405 </xsl:otherwise> 2406 </xsl:choose> 2407 <xsl:call-template name="genIfaceWrapper"> 2408 <xsl:with-param name="ifname" select="$ifname" /> 2409 </xsl:call-template> 2410 </xsl:otherwise> 2411 </xsl:choose> 2412 2413 <!-- end of class --> 2414 <xsl:value-of select="'} '" /> 2472 <xsl:if test="$filelistonly=''"> 2473 <xsl:text>import java.util.List; </xsl:text> 2474 2475 <xsl:apply-templates select="desc" mode="interface"/> 2476 2477 <xsl:choose> 2478 <xsl:when test="($wsmap='struct') and ($G_vboxGlueStyle='jaxws')"> 2479 <xsl:value-of select="concat('public class ', $ifname, ' ')" /> 2480 <xsl:text>{ </xsl:text> 2481 <xsl:call-template name="genStructWrapperJaxws"> 2482 <xsl:with-param name="ifname" select="$ifname" /> 2483 </xsl:call-template> 2484 </xsl:when> 2485 2486 <xsl:otherwise> 2487 <xsl:variable name="extends" select="//interface[@name=$ifname]/@extends" /> 2488 <xsl:choose> 2489 <xsl:when test="($extends = '$unknown') or ($extends = '$dispatched') or ($extends = '$errorinfo')"> 2490 <xsl:value-of select="concat('public class ', $ifname, ' extends IUnknown ')" /> 2491 <xsl:text>{ </xsl:text> 2492 </xsl:when> 2493 <xsl:when test="//interface[@name=$extends]"> 2494 <xsl:value-of select="concat('public class ', $ifname, ' extends ', $extends, ' ')" /> 2495 <xsl:text>{ </xsl:text> 2496 </xsl:when> 2497 <xsl:otherwise> 2498 <xsl:call-template name="fatalError"> 2499 <xsl:with-param name="msg" select="concat('Interface generation: interface "', $ifname, '" has invalid "extends" value ', $extends, '.')" /> 2500 </xsl:call-template> 2501 </xsl:otherwise> 2502 </xsl:choose> 2503 <xsl:call-template name="genIfaceWrapper"> 2504 <xsl:with-param name="ifname" select="$ifname" /> 2505 </xsl:call-template> 2506 </xsl:otherwise> 2507 </xsl:choose> 2508 2509 <!-- end of class --> 2510 <xsl:text>} </xsl:text> 2511 </xsl:if> 2415 2512 2416 2513 <xsl:call-template name="endFile"> … … 2432 2529 <xsl:text>import java.util.List; </xsl:text> 2433 2530 2434 <xsl:value-of select="concat('public interface ', $ifname, ' { ')" /> 2531 <xsl:value-of select="concat('public interface ', $ifname, ' ')" /> 2532 <xsl:text>{ </xsl:text> 2435 2533 2436 2534 <!-- emit methods declarations--> … … 2442 2540 </xsl:for-each> 2443 2541 2444 <xsl: value-of select="'} '" />2542 <xsl:text>} </xsl:text> 2445 2543 2446 2544 <xsl:call-template name="endFile"> … … 2464 2562 <xsl:choose> 2465 2563 <xsl:when test="$G_vboxGlueStyle='xpcom'"> 2466 <xsl:value-of select="concat('class ', $ifname, 'Impl extends nsISupportsBase implements ', $backtype, ' { ')" /> 2564 <xsl:value-of select="concat('class ', $ifname, 'Impl extends nsISupportsBase implements ', $backtype, ' ')" /> 2565 <xsl:text>{ </xsl:text> 2467 2566 </xsl:when> 2468 2567 2469 2568 <xsl:when test="$G_vboxGlueStyle='mscom'"> 2470 <xsl:value-of select="concat('public class ', $ifname, 'Impl { ')" /> 2569 <xsl:value-of select="concat('public class ', $ifname, 'Impl ')" /> 2570 <xsl:text>{ </xsl:text> 2471 2571 </xsl:when> 2472 2572 </xsl:choose> … … 2474 2574 <xsl:value-of select="concat(' ', $ifname, ' sink; ')" /> 2475 2575 2476 <xsl:value-of select="concat(' ', $ifname, 'Impl(', $ifname,' sink) { ')" /> 2477 <xsl:value-of select="' this.sink = sink; '" /> 2478 <xsl:value-of select="' } '" /> 2576 <xsl:value-of select="concat(' ', $ifname, 'Impl(', $ifname, ' sink) ')" /> 2577 <xsl:text> { </xsl:text> 2578 <xsl:text> this.sink = sink; </xsl:text> 2579 <xsl:text> } </xsl:text> 2479 2580 2480 2581 <!-- emit methods implementations --> … … 2486 2587 </xsl:for-each> 2487 2588 2488 <xsl: value-of select="'} '" />2589 <xsl:text>} </xsl:text> 2489 2590 2490 2591 <xsl:call-template name="endFile"> … … 2495 2596 <xsl:template name="emitHandwritten"> 2496 2597 2497 <xsl:call-template name="startFile">2598 <xsl:call-template name="startFile"> 2498 2599 <xsl:with-param name="file" select="'Holder.java'" /> 2499 2600 <xsl:with-param name="package" select="$G_virtualBoxPackage" /> 2500 2601 </xsl:call-template> 2501 2602 2502 <xsl:text><![CDATA[ 2603 <xsl:if test="$filelistonly=''"> 2604 <xsl:text><![CDATA[ 2503 2605 public class Holder<T> 2504 2606 { 2505 public T value;2506 2507 public Holder()2508 {2509 }2510 public Holder(T value)2511 {2512 this.value = value;2513 }2607 public T value; 2608 2609 public Holder() 2610 { 2611 } 2612 public Holder(T value) 2613 { 2614 this.value = value; 2615 } 2514 2616 } 2515 2617 ]]></xsl:text> 2516 2517 <xsl:call-template name="endFile"> 2518 <xsl:with-param name="file" select="'Holder.java'" /> 2519 </xsl:call-template> 2520 2521 <xsl:call-template name="startFile"> 2522 <xsl:with-param name="file" select="'VBoxException.java'" /> 2523 <xsl:with-param name="package" select="$G_virtualBoxPackage" /> 2618 </xsl:if> 2619 2620 <xsl:call-template name="endFile"> 2621 <xsl:with-param name="file" select="'Holder.java'" /> 2524 2622 </xsl:call-template> 2525 2526 <xsl:text><![CDATA[2527 public class VBoxException extends RuntimeException2528 {2529 private Throwable wrapped;2530 private String msg;2531 2532 public VBoxException(Throwable wrapped, String msg)2533 {2534 this.wrapped = wrapped;2535 this.msg = msg;2536 }2537 public Throwable getWrapped()2538 {2539 return wrapped;2540 }2541 public String getMessage()2542 {2543 return msg;2544 }2545 }2546 ]]></xsl:text>2547 2548 <xsl:call-template name="endFile">2549 <xsl:with-param name="file" select="'VBoxException.java'" />2550 </xsl:call-template>2551 2552 2553 2623 </xsl:template> 2554 2624 2555 2625 <xsl:template name="emitHandwrittenXpcom"> 2556 2626 2557 <xsl:call-template name="startFile">2627 <xsl:call-template name="startFile"> 2558 2628 <xsl:with-param name="file" select="'IUnknown.java'" /> 2559 2629 <xsl:with-param name="package" select="$G_virtualBoxPackageCom" /> 2560 2630 </xsl:call-template> 2561 2631 2562 <xsl:text><![CDATA[ 2632 <xsl:if test="$filelistonly=''"> 2633 <xsl:text><![CDATA[ 2563 2634 public class IUnknown 2564 2635 { 2565 private Object obj;2566 public IUnknown(Object obj)2567 {2568 this.obj = obj;2569 }2570 2571 public Object getWrapped()2572 {2573 return this.obj;2574 }2575 2576 public void setWrapped(Object obj)2577 {2578 this.obj = obj;2579 }2636 private Object obj; 2637 public IUnknown(Object obj) 2638 { 2639 this.obj = obj; 2640 } 2641 2642 public Object getWrapped() 2643 { 2644 return this.obj; 2645 } 2646 2647 public void setWrapped(Object obj) 2648 { 2649 this.obj = obj; 2650 } 2580 2651 } 2581 2652 ]]></xsl:text> 2582 2583 <xsl:call-template name="endFile"> 2584 <xsl:with-param name="file" select="'IUnknown.java'" /> 2585 </xsl:call-template> 2586 2587 <xsl:call-template name="startFile"> 2588 <xsl:with-param name="file" select="'Helper.java'" /> 2589 <xsl:with-param name="package" select="$G_virtualBoxPackageCom" /> 2590 </xsl:call-template> 2591 2592 <xsl:text><![CDATA[ 2653 </xsl:if> 2654 2655 <xsl:call-template name="endFile"> 2656 <xsl:with-param name="file" select="'IUnknown.java'" /> 2657 </xsl:call-template> 2658 2659 <xsl:call-template name="startFile"> 2660 <xsl:with-param name="file" select="'Helper.java'" /> 2661 <xsl:with-param name="package" select="$G_virtualBoxPackageCom" /> 2662 </xsl:call-template> 2663 2664 <xsl:if test="$filelistonly=''"> 2665 <xsl:text><![CDATA[ 2593 2666 2594 2667 import java.util.List; … … 2599 2672 import java.lang.reflect.InvocationTargetException; 2600 2673 2601 public class Helper { 2602 public static List<Short> wrap(byte[] vals) { 2603 if (vals==null) 2674 public class Helper 2675 { 2676 public static List<Short> wrap(byte[] values) 2677 { 2678 if (values == null) 2604 2679 return null; 2605 2680 2606 List<Short> ret = new ArrayList<Short>(vals.length); 2607 for (short v : vals) { 2608 ret.add(v); 2681 List<Short> ret = new ArrayList<Short>(values.length); 2682 for (short v : values) 2683 { 2684 ret.add(v); 2609 2685 } 2610 2686 return ret; 2611 2687 } 2612 2688 2613 public static List<Integer> wrap(int[] vals) { 2614 if (vals==null) 2615 return null; 2616 2617 List<Integer> ret = new ArrayList<Integer>(vals.length); 2618 for (int v : vals) { 2619 ret.add(v); 2689 public static List<Integer> wrap(int[] values) 2690 { 2691 if (values == null) 2692 return null; 2693 2694 List<Integer> ret = new ArrayList<Integer>(values.length); 2695 for (int v : values) 2696 { 2697 ret.add(v); 2620 2698 } 2621 2699 return ret; 2622 2700 } 2623 2701 2624 public static List<Long> wrap(long[] vals) { 2625 if (vals==null) 2626 return null; 2627 2628 List<Long> ret = new ArrayList<Long>(vals.length); 2629 for (long v : vals) { 2702 public static List<Long> wrap(long[] values) 2703 { 2704 if (values == null) 2705 return null; 2706 2707 List<Long> ret = new ArrayList<Long>(values.length); 2708 for (long v : values) 2709 { 2630 2710 ret.add(v); 2631 2711 } … … 2633 2713 } 2634 2714 2635 public static List<Boolean> wrap(boolean[] vals) { 2636 if (vals==null) 2715 public static List<Boolean> wrap(boolean[] values) 2716 { 2717 if (values == null) 2637 2718 return null; 2638 2719 2639 List<Boolean> ret = new ArrayList<Boolean>(vals.length); 2640 for (boolean v: vals) { 2641 ret.add(v); 2720 List<Boolean> ret = new ArrayList<Boolean>(values.length); 2721 for (boolean v: values) 2722 { 2723 ret.add(v); 2642 2724 } 2643 2725 return ret; 2644 2726 } 2645 2727 2646 public static List<String> wrap(String[] vals) { 2647 if (vals==null) 2728 public static List<String> wrap(String[] values) 2729 { 2730 if (values == null) 2648 2731 return null; 2649 List<String> ret = new ArrayList<String>(vals.length); 2650 for (String v : vals) { 2732 2733 List<String> ret = new ArrayList<String>(values.length); 2734 for (String v : values) 2735 { 2651 2736 ret.add(v); 2652 2737 } … … 2654 2739 } 2655 2740 2656 public static <T> List<T> wrap(Class<T> wrapperClass, T[] thisPtrs) { 2657 if (thisPtrs==null) 2658 return null; 2659 2660 List<T> ret = new ArrayList<T>(thisPtrs.length); 2661 for (T thisPtr : thisPtrs) { 2662 ret.add(thisPtr); 2741 public static <T> List<T> wrap(Class<T> wrapperClass, T[] values) 2742 { 2743 if (values == null) 2744 return null; 2745 2746 List<T> ret = new ArrayList<T>(values.length); 2747 for (T v : values) 2748 { 2749 ret.add(v); 2663 2750 } 2664 2751 return ret; 2665 2752 } 2666 2753 2667 public static <T> List<T> wrapEnum(Class<T> wrapperClass, long values[]) { 2668 try { 2669 if (values==null) 2670 return null; 2754 public static <T> List<T> wrapEnum(Class<T> wrapperClass, long values[]) 2755 { 2756 try 2757 { 2758 if (values == null) 2759 return null; 2671 2760 Constructor<T> c = wrapperClass.getConstructor(int.class); 2672 2761 List<T> ret = new ArrayList<T>(values.length); 2673 for (long v : values) { 2762 for (long v : values) 2763 { 2674 2764 ret.add(c.newInstance(v)); 2675 2765 } 2676 2766 return ret; 2677 } catch (NoSuchMethodException e) { 2767 } 2768 catch (NoSuchMethodException e) 2769 { 2678 2770 throw new AssertionError(e); 2679 } catch (InstantiationException e) { 2771 } 2772 catch (InstantiationException e) 2773 { 2680 2774 throw new AssertionError(e); 2681 } catch (IllegalAccessException e) { 2775 } 2776 catch (IllegalAccessException e) 2777 { 2682 2778 throw new AssertionError(e); 2683 } catch (InvocationTargetException e) { 2779 } 2780 catch (InvocationTargetException e) 2781 { 2684 2782 throw new AssertionError(e); 2685 2783 } 2686 2784 } 2687 public static short[] unwrapUShort(List<Short> vals) { 2688 if (vals==null) 2689 return null; 2690 2691 short[] ret = new short[vals.size()]; 2785 public static short[] unwrapUShort(List<Short> values) 2786 { 2787 if (values == null) 2788 return null; 2789 2790 short[] ret = new short[values.size()]; 2692 2791 int i = 0; 2693 for (short l : vals) { 2694 ret[i++] = l; 2792 for (short l : values) 2793 { 2794 ret[i++] = l; 2695 2795 } 2696 2796 return ret; 2697 2797 } 2698 2798 2699 public static int[] unwrapInteger(List<Integer> vals) { 2700 if (vals == null) 2701 return null; 2702 2703 int[] ret = new int[vals.size()]; 2799 public static int[] unwrapInteger(List<Integer> values) 2800 { 2801 if (values == null) 2802 return null; 2803 2804 int[] ret = new int[values.size()]; 2704 2805 int i = 0; 2705 for (int l : vals) { 2706 ret[i++] = l; 2806 for (int l : values) 2807 { 2808 ret[i++] = l; 2707 2809 } 2708 2810 return ret; 2709 2811 } 2710 2812 2711 public static long[] unwrapULong(List<Long> vals) { 2712 if (vals == null) 2713 return null; 2714 2715 long[] ret = new long[vals.size()]; 2813 public static long[] unwrapULong(List<Long> values) 2814 { 2815 if (values == null) 2816 return null; 2817 2818 long[] ret = new long[values.size()]; 2716 2819 int i = 0; 2717 for (long l : vals) { 2718 ret[i++] = l; 2820 for (long l : values) 2821 { 2822 ret[i++] = l; 2719 2823 } 2720 2824 return ret; 2721 2825 } 2722 2826 2723 public static boolean[] unwrapBoolean(List<Boolean> vals) { 2724 if (vals==null) 2725 return null; 2726 2727 boolean[] ret = new boolean[vals.size()]; 2827 public static boolean[] unwrapBoolean(List<Boolean> values) 2828 { 2829 if (values == null) 2830 return null; 2831 2832 boolean[] ret = new boolean[values.size()]; 2728 2833 int i = 0; 2729 for (boolean l : vals) { 2730 ret[i++] = l; 2834 for (boolean l : values) 2835 { 2836 ret[i++] = l; 2731 2837 } 2732 2838 return ret; 2733 2839 } 2734 2840 2735 public static String[] unwrapStr(List<String> vals) { 2736 if (vals==null) 2841 public static String[] unwrapStr(List<String> values) 2842 { 2843 if (values == null) 2737 2844 return null; 2738 2845 2739 String[] ret = new String[val s.size()];2846 String[] ret = new String[values.size()]; 2740 2847 int i = 0; 2741 for (String l : vals) { 2742 ret[i++] = l; 2848 for (String l : values) 2849 { 2850 ret[i++] = l; 2743 2851 } 2744 2852 return ret; 2745 2853 } 2746 2854 2747 public static <T extends Enum <T>> long[] unwrapEnum(Class<T> enumClass, List<T> values) { 2748 if (values == null) return null; 2855 public static <T extends Enum <T>> long[] unwrapEnum(Class<T> enumClass, List<T> values) 2856 { 2857 if (values == null) 2858 return null; 2749 2859 2750 2860 long result[] = new long[values.size()]; 2751 try { 2752 java.lang.reflect.Method valueM = enumClass.getMethod("value"); 2753 int i = 0; 2754 for (T v : values) { 2755 result[i++] = (Integer)valueM.invoke(v); 2756 } 2757 return result; 2758 } catch (NoSuchMethodException e) { 2759 throw new AssertionError(e); 2760 } catch(SecurityException e) { 2761 throw new AssertionError(e); 2762 } catch (IllegalAccessException e) { 2763 throw new AssertionError(e); 2764 } catch (IllegalArgumentException e) { 2765 throw new AssertionError(e); 2766 } catch (InvocationTargetException e) { 2767 throw new AssertionError(e); 2768 } 2769 } 2770 2771 public static <T1, T2> List<T1> wrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, T2[] thisPtrs) { 2772 try { 2773 if (thisPtrs==null) 2861 try 2862 { 2863 java.lang.reflect.Method valueM = enumClass.getMethod("value"); 2864 int i = 0; 2865 for (T v : values) 2866 { 2867 result[i++] = (Integer)valueM.invoke(v); 2868 } 2869 return result; 2870 } 2871 catch (NoSuchMethodException e) 2872 { 2873 throw new AssertionError(e); 2874 } 2875 catch(SecurityException e) 2876 { 2877 throw new AssertionError(e); 2878 } 2879 catch (IllegalAccessException e) 2880 { 2881 throw new AssertionError(e); 2882 } 2883 catch (IllegalArgumentException e) 2884 { 2885 throw new AssertionError(e); 2886 } 2887 catch (InvocationTargetException e) 2888 { 2889 throw new AssertionError(e); 2890 } 2891 } 2892 2893 public static <T1, T2> List<T1> wrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, T2[] values) 2894 { 2895 try 2896 { 2897 if (values == null) 2774 2898 return null; 2775 2899 2776 2900 Constructor<T1> c = wrapperClass1.getConstructor(wrapperClass2); 2777 List<T1> ret = new ArrayList<T1>(thisPtrs.length); 2778 for (T2 thisPtr : thisPtrs) { 2779 ret.add(c.newInstance(thisPtr)); 2901 List<T1> ret = new ArrayList<T1>(values.length); 2902 for (T2 v : values) 2903 { 2904 ret.add(c.newInstance(v)); 2780 2905 } 2781 2906 return ret; 2782 } catch (NoSuchMethodException e) { 2907 } 2908 catch (NoSuchMethodException e) 2909 { 2783 2910 throw new AssertionError(e); 2784 } catch (InstantiationException e) { 2911 } 2912 catch (InstantiationException e) 2913 { 2785 2914 throw new AssertionError(e); 2786 } catch (IllegalAccessException e) { 2915 } 2916 catch (IllegalAccessException e) 2917 { 2787 2918 throw new AssertionError(e); 2788 } catch (InvocationTargetException e) { 2919 } 2920 catch (InvocationTargetException e) 2921 { 2789 2922 throw new AssertionError(e); 2790 2923 } … … 2792 2925 2793 2926 @SuppressWarnings( "unchecked") 2794 public static <T> T[] unwrap(Class<T> wrapperClass, List<T> thisPtrs)2795 { 2796 if ( thisPtrs==null)2927 public static <T> T[] unwrap(Class<T> wrapperClass, List<T> values) 2928 { 2929 if (values == null) 2797 2930 return null; 2798 if ( thisPtrs.size() == 0)2931 if (values.size() == 0) 2799 2932 return null; 2800 return (T[]) thisPtrs.toArray((T[])Array.newInstance(wrapperClass, thisPtrs.size()));2933 return (T[])values.toArray((T[])Array.newInstance(wrapperClass, values.size())); 2801 2934 } 2802 2935 … … 2809 2942 public static Object queryInterface(Object obj, String uuid) 2810 2943 { 2811 try { 2812 /* Kind of ugly, but does the job of casting */ 2813 org.mozilla.xpcom.Mozilla moz = org.mozilla.xpcom.Mozilla.getInstance(); 2814 long xpobj = moz.wrapJavaObject(obj, uuid); 2815 return moz.wrapXPCOMObject(xpobj, uuid); 2816 } catch (Exception e) { 2944 try 2945 { 2946 /* Kind of ugly, but does the job of casting */ 2947 org.mozilla.xpcom.Mozilla moz = org.mozilla.xpcom.Mozilla.getInstance(); 2948 long xpobj = moz.wrapJavaObject(obj, uuid); 2949 return moz.wrapXPCOMObject(xpobj, uuid); 2950 } 2951 catch (Exception e) 2952 { 2817 2953 return null; 2818 2954 } … … 2820 2956 2821 2957 @SuppressWarnings("unchecked") 2822 public static <T1 extends IUnknown,T2> T2[] unwrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, List<T1> thisPtrs) 2823 { 2824 if (thisPtrs==null) return null; 2825 2826 T2 ret[] = (T2[])Array.newInstance(wrapperClass2, thisPtrs.size()); 2958 public static <T1 extends IUnknown, T2> T2[] unwrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, List<T1> values) 2959 { 2960 if (values == null) 2961 return null; 2962 2963 T2 ret[] = (T2[])Array.newInstance(wrapperClass2, values.size()); 2827 2964 int i = 0; 2828 for (T1 obj : thisPtrs) { 2829 ret[i++] = (T2)obj.getWrapped(); 2965 for (T1 obj : values) 2966 { 2967 ret[i++] = (T2)obj.getWrapped(); 2830 2968 } 2831 2969 return ret; … … 2833 2971 } 2834 2972 ]]></xsl:text> 2835 2836 <xsl:call-template name="endFile"> 2837 <xsl:with-param name="file" select="'Helper.java'" /> 2838 </xsl:call-template> 2839 2840 <xsl:call-template name="startFile"> 2973 </xsl:if> 2974 2975 <xsl:call-template name="endFile"> 2976 <xsl:with-param name="file" select="'Helper.java'" /> 2977 </xsl:call-template> 2978 2979 <xsl:call-template name="startFile"> 2980 <xsl:with-param name="file" select="'VBoxException.java'" /> 2981 <xsl:with-param name="package" select="$G_virtualBoxPackage" /> 2982 </xsl:call-template> 2983 2984 <xsl:if test="$filelistonly=''"> 2985 <xsl:text> 2986 import org.mozilla.xpcom.*; 2987 2988 public class VBoxException extends RuntimeException 2989 { 2990 private int resultCode; 2991 private IVirtualBoxErrorInfo errorInfo; 2992 2993 public VBoxException(String message) 2994 { 2995 super(message); 2996 resultCode = -1; 2997 errorInfo = null; 2998 } 2999 3000 public VBoxException(String message, Throwable cause) 3001 { 3002 super(message, cause); 3003 if (cause instanceof org.mozilla.xpcom.XPCOMException) 3004 { 3005 resultCode = (int)((org.mozilla.xpcom.XPCOMException)cause).errorcode; 3006 try 3007 { 3008 Mozilla mozilla = Mozilla.getInstance(); 3009 nsIServiceManager sm = mozilla.getServiceManager(); 3010 nsIExceptionService es = (nsIExceptionService)sm.getServiceByContractID("@mozilla.org/exceptionservice;1", nsIExceptionService.NS_IEXCEPTIONSERVICE_IID); 3011 nsIExceptionManager em = es.getCurrentExceptionManager(); 3012 nsIException ex = em.getCurrentException(); 3013 errorInfo = new IVirtualBoxErrorInfo((org.mozilla.interfaces.IVirtualBoxErrorInfo)ex.queryInterface(org.mozilla.interfaces.IVirtualBoxErrorInfo.IVIRTUALBOXERRORINFO_IID)); 3014 } 3015 catch (NullPointerException e) 3016 { 3017 e.printStackTrace(); 3018 // nothing we can do 3019 errorInfo = null; 3020 } 3021 } 3022 else 3023 resultCode = -1; 3024 } 3025 3026 public int getResultCode() 3027 { 3028 return resultCode; 3029 } 3030 3031 public IVirtualBoxErrorInfo getVirtualBoxErrorInfo() 3032 { 3033 return errorInfo; 3034 } 3035 } 3036 </xsl:text> 3037 </xsl:if> 3038 3039 <xsl:call-template name="endFile"> 3040 <xsl:with-param name="file" select="'VBoxException.java'" /> 3041 </xsl:call-template> 3042 3043 <xsl:call-template name="startFile"> 2841 3044 <xsl:with-param name="file" select="'VirtualBoxManager.java'" /> 2842 3045 <xsl:with-param name="package" select="$G_virtualBoxPackage" /> 2843 3046 </xsl:call-template> 2844 3047 2845 <xsl:text><![CDATA[ 3048 <xsl:if test="$filelistonly=''"> 3049 <xsl:text><![CDATA[ 2846 3050 2847 3051 import java.io.File; … … 2852 3056 public class VirtualBoxManager 2853 3057 { 2854 private Mozilla 2855 private IVirtualBox 3058 private Mozilla mozilla; 3059 private IVirtualBox vbox; 2856 3060 private nsIComponentManager componentManager; 2857 3061 … … 2868 3072 public void connect(String url, String username, String passwd) 2869 3073 { 2870 throw new RuntimeException("Connect doesn't make sense for local bindings");3074 throw new VBoxException("Connect doesn't make sense for local bindings"); 2871 3075 } 2872 3076 2873 3077 public void disconnect() 2874 3078 { 2875 throw new RuntimeException("Disconnect doesn't make sense for local bindings");3079 throw new VBoxException("Disconnect doesn't make sense for local bindings"); 2876 3080 } 2877 3081 … … 2915 3119 { 2916 3120 if (hasInstance) 2917 throw new VBoxException( null, "only one instance at thetime allowed");2918 if (home == null || "".equals(home))3121 throw new VBoxException("only one instance of VirtualBoxManager at a time allowed"); 3122 if (home == null || home.equals("")) 2919 3123 home = System.getProperty("vbox.home"); 2920 3124 2921 3125 if (home == null) 2922 throw new RuntimeException("vbox.home Java property must be defined to use XPCOM bridge");3126 throw new VBoxException("vbox.home Java property must be defined to use XPCOM bridge"); 2923 3127 2924 3128 File grePath = new File(home); … … 2927 3131 if (!isMozillaInited) 2928 3132 { 2929 mozilla.initialize(grePath); 2930 try { 2931 mozilla.initXPCOM(grePath, null); 2932 isMozillaInited = true; 2933 } catch (Exception e) { 2934 e.printStackTrace(); 2935 return null; 2936 } 3133 mozilla.initialize(grePath); 3134 try 3135 { 3136 mozilla.initXPCOM(grePath, null); 3137 isMozillaInited = true; 3138 } 3139 catch (Exception e) 3140 { 3141 e.printStackTrace(); 3142 return null; 3143 } 2937 3144 } 2938 3145 … … 2944 3151 public IEventListener createListener(Object sink) 2945 3152 { 2946 return new IEventListener(new EventListenerImpl(sink)); 2947 } 3153 return new IEventListener(new EventListenerImpl(sink)); 3154 } 3155 2948 3156 public void cleanup() 2949 3157 { … … 2956 3164 } 2957 3165 2958 public boolean progressBar(IProgress p, int wait)2959 {2960 long end = System.currentTimeMillis() + wait;2961 while (!p.getCompleted())2962 {2963 mozilla.waitForEvents(0);2964 p.waitForCompletion(wait);2965 if (System.currentTimeMillis() >= end)2966 return false;2967 }2968 2969 return true;2970 }2971 2972 public boolean startVm(String name, String type, int timeout)2973 {2974 IMachine m = vbox.findMachine(name);2975 if (m == null)2976 return false;2977 ISession session = getSessionObject();2978 2979 if (type == null)2980 type = "gui";2981 IProgress p = m.launchVMProcess(session, type, "");2982 progressBar(p, timeout);2983 session.unlockMachine();2984 return true;2985 }2986 2987 3166 public void waitForEvents(long tmo) 2988 3167 { … … 2991 3170 } 2992 3171 ]]></xsl:text> 2993 2994 <xsl:call-template name="endFile"> 2995 <xsl:with-param name="file" select="'VirtualBoxManager.java'" /> 2996 </xsl:call-template> 2997 2998 <xsl:call-template name="startFile"> 2999 <xsl:with-param name="file" select="'EventListenerImpl.java'" /> 3000 <xsl:with-param name="package" select="$G_virtualBoxPackage" /> 3001 </xsl:call-template> 3002 3003 <xsl:text><![CDATA[ 3004 import org.mozilla.interfaces.*; 3005 3006 public class EventListenerImpl extends nsISupportsBase implements org.mozilla.interfaces.IEventListener 3007 { 3172 </xsl:if> 3173 3174 <xsl:call-template name="endFile"> 3175 <xsl:with-param name="file" select="'VirtualBoxManager.java'" /> 3176 </xsl:call-template> 3177 3178 <xsl:call-template name="startFile"> 3179 <xsl:with-param name="file" select="'EventListenerImpl.java'" /> 3180 <xsl:with-param name="package" select="$G_virtualBoxPackage" /> 3181 </xsl:call-template> 3182 3183 <xsl:if test="$filelistonly=''"> 3184 <xsl:text><![CDATA[ 3185 import org.mozilla.interfaces.*; 3186 3187 public class EventListenerImpl extends nsISupportsBase implements org.mozilla.interfaces.IEventListener 3188 { 3008 3189 private Object obj; 3009 3190 private java.lang.reflect.Method handleEvent; 3010 3191 EventListenerImpl(Object obj) 3011 3192 { 3012 this.obj = obj; 3013 try { 3014 this.handleEvent = obj.getClass().getMethod("handleEvent", IEvent.class); 3015 } catch (Exception e) { 3016 e.printStackTrace(); 3017 } 3018 } 3019 public void handleEvent(org.mozilla.interfaces.IEvent ev) 3020 { 3021 try { 3022 if (obj != null && handleEvent != null) 3023 handleEvent.invoke(obj, ev != null ? new IEvent(ev) : null); 3024 } catch (Exception e) { 3025 e.printStackTrace(); 3026 } 3027 } 3028 }]]></xsl:text> 3029 3030 <xsl:call-template name="endFile"> 3031 <xsl:with-param name="file" select="'EventListenerImpl.java'" /> 3032 </xsl:call-template> 3033 3034 <xsl:call-template name="startFile"> 3035 <xsl:with-param name="file" select="'VBoxObjectBase.java'" /> 3036 <xsl:with-param name="package" select="$G_virtualBoxPackage" /> 3037 </xsl:call-template> 3038 3039 <xsl:text><![CDATA[ 3193 this.obj = obj; 3194 try 3195 { 3196 this.handleEvent = obj.getClass().getMethod("handleEvent", IEvent.class); 3197 } 3198 catch (Exception e) 3199 { 3200 e.printStackTrace(); 3201 } 3202 } 3203 public void handleEvent(org.mozilla.interfaces.IEvent ev) 3204 { 3205 try 3206 { 3207 if (obj != null && handleEvent != null) 3208 handleEvent.invoke(obj, ev != null ? new IEvent(ev) : null); 3209 } 3210 catch (Exception e) 3211 { 3212 e.printStackTrace(); 3213 } 3214 } 3215 }]]></xsl:text> 3216 </xsl:if> 3217 3218 <xsl:call-template name="endFile"> 3219 <xsl:with-param name="file" select="'EventListenerImpl.java'" /> 3220 </xsl:call-template> 3221 3222 <xsl:call-template name="startFile"> 3223 <xsl:with-param name="file" select="'VBoxObjectBase.java'" /> 3224 <xsl:with-param name="package" select="$G_virtualBoxPackage" /> 3225 </xsl:call-template> 3226 3227 <xsl:if test="$filelistonly=''"> 3228 <xsl:text><![CDATA[ 3040 3229 abstract class nsISupportsBase implements org.mozilla.interfaces.nsISupports 3041 3230 { 3042 public 3231 public org.mozilla.interfaces.nsISupports queryInterface(String iid) 3043 3232 { 3044 3233 return org.mozilla.xpcom.Mozilla.queryInterface(this, iid); … … 3046 3235 } 3047 3236 3048 ]]></xsl:text><xsl:call-template name="endFile"> 3049 <xsl:with-param name="file" select="'VBoxObjectBase.java'" /> 3050 </xsl:call-template> 3051 3237 ]]></xsl:text> 3238 </xsl:if> 3239 3240 <xsl:call-template name="endFile"> 3241 <xsl:with-param name="file" select="'VBoxObjectBase.java'" /> 3242 </xsl:call-template> 3052 3243 </xsl:template> 3053 3244 … … 3055 3246 <xsl:template name="emitHandwrittenMscom"> 3056 3247 3057 <xsl:call-template name="startFile">3248 <xsl:call-template name="startFile"> 3058 3249 <xsl:with-param name="file" select="'IUnknown.java'" /> 3059 3250 <xsl:with-param name="package" select="$G_virtualBoxPackageCom" /> 3060 3251 </xsl:call-template> 3061 3252 3062 <xsl:text><![CDATA[ 3253 <xsl:if test="$filelistonly=''"> 3254 <xsl:text><![CDATA[ 3063 3255 public class IUnknown 3064 3256 { 3065 private Object obj;3066 public IUnknown(Object obj)3067 {3068 this.obj = obj;3069 }3070 3071 public Object getWrapped()3072 {3073 return this.obj;3074 }3075 3076 public void setWrapped(Object obj)3077 {3078 this.obj = obj;3079 }3257 private Object obj; 3258 public IUnknown(Object obj) 3259 { 3260 this.obj = obj; 3261 } 3262 3263 public Object getWrapped() 3264 { 3265 return this.obj; 3266 } 3267 3268 public void setWrapped(Object obj) 3269 { 3270 this.obj = obj; 3271 } 3080 3272 } 3081 3273 ]]></xsl:text> 3082 3083 <xsl:call-template name="endFile"> 3084 <xsl:with-param name="file" select="'IUnknown.java'" /> 3085 </xsl:call-template> 3086 3087 <xsl:call-template name="startFile"> 3088 <xsl:with-param name="file" select="'Helper.java'" /> 3089 <xsl:with-param name="package" select="$G_virtualBoxPackageCom" /> 3090 </xsl:call-template> 3091 3092 <xsl:text><![CDATA[ 3274 </xsl:if> 3275 3276 <xsl:call-template name="endFile"> 3277 <xsl:with-param name="file" select="'IUnknown.java'" /> 3278 </xsl:call-template> 3279 3280 <xsl:call-template name="startFile"> 3281 <xsl:with-param name="file" select="'Helper.java'" /> 3282 <xsl:with-param name="package" select="$G_virtualBoxPackageCom" /> 3283 </xsl:call-template> 3284 3285 <xsl:if test="$filelistonly=''"> 3286 <xsl:text><![CDATA[ 3093 3287 3094 3288 import java.util.List; … … 3100 3294 import com.jacob.com.*; 3101 3295 3102 public class Helper { 3103 public static List<Short> wrap(short[] vals) { 3104 if (vals==null) return null; 3105 if (vals.length == 0) return Collections.emptyList(); 3106 3107 List<Short> ret = new ArrayList<Short>(vals.length); 3108 for (short v : vals) { 3109 ret.add(v); 3296 public class Helper 3297 { 3298 public static List<Short> wrap(short[] values) 3299 { 3300 if (values == null) 3301 return null; 3302 if (values.length == 0) 3303 return Collections.emptyList(); 3304 3305 List<Short> ret = new ArrayList<Short>(values.length); 3306 for (short v : values) 3307 { 3308 ret.add(v); 3110 3309 } 3111 3310 return ret; 3112 3311 } 3113 3312 3114 public static List<Integer> wrap(int[] vals) { 3115 if (vals == null) return null; 3116 if (vals.length == 0) return Collections.emptyList(); 3117 3118 List<Integer> ret = new ArrayList<Integer>(vals.length); 3119 for (int v : vals) { 3120 ret.add(v); 3313 public static List<Integer> wrap(int[] values) 3314 { 3315 if (values == null) 3316 return null; 3317 if (values.length == 0) 3318 return Collections.emptyList(); 3319 3320 List<Integer> ret = new ArrayList<Integer>(values.length); 3321 for (int v : values) 3322 { 3323 ret.add(v); 3121 3324 } 3122 3325 return ret; 3123 3326 } 3124 3327 3125 public static List<Long> wrap(long[] vals) { 3126 if (vals==null) return null; 3127 if (vals.length == 0) return Collections.emptyList(); 3128 3129 List<Long> ret = new ArrayList<Long>(vals.length); 3130 for (long v : vals) { 3131 ret.add(v); 3328 public static List<Long> wrap(long[] values) 3329 { 3330 if (values == null) 3331 return null; 3332 if (values.length == 0) 3333 return Collections.emptyList(); 3334 3335 List<Long> ret = new ArrayList<Long>(values.length); 3336 for (long v : values) 3337 { 3338 ret.add(v); 3132 3339 } 3133 3340 return ret; 3134 3341 } 3135 3342 3136 public static List<String> wrap(String[] vals) { 3137 if (vals==null) return null; 3138 if (vals.length == 0) return Collections.emptyList(); 3139 3140 List<String> ret = new ArrayList<String>(vals.length); 3141 for (String v : vals) { 3142 ret.add(v); 3343 public static List<String> wrap(String[] values) 3344 { 3345 if (values == null) 3346 return null; 3347 if (values.length == 0) 3348 return Collections.emptyList(); 3349 3350 List<String> ret = new ArrayList<String>(values.length); 3351 for (String v : values) 3352 { 3353 ret.add(v); 3143 3354 } 3144 3355 return ret; … … 3147 3358 public static <T> T wrapDispatch(Class<T> wrapperClass, Dispatch d) 3148 3359 { 3149 try { 3150 if (d == null || d.m_pDispatch == 0) 3151 return null; 3152 Constructor<T> c = wrapperClass.getConstructor(Dispatch.class); 3153 return (T)c.newInstance(d); 3154 } catch (NoSuchMethodException e) { 3155 throw new AssertionError(e); 3156 } catch (InstantiationException e) { 3157 throw new AssertionError(e); 3158 } catch (IllegalAccessException e) { 3159 throw new AssertionError(e); 3160 } catch (InvocationTargetException e) { 3161 throw new AssertionError(e); 3162 } 3360 try 3361 { 3362 if (d == null || d.m_pDispatch == 0) 3363 return null; 3364 Constructor<T> c = wrapperClass.getConstructor(Dispatch.class); 3365 return (T)c.newInstance(d); 3366 } 3367 catch (NoSuchMethodException e) 3368 { 3369 throw new AssertionError(e); 3370 } 3371 catch (InstantiationException e) 3372 { 3373 throw new AssertionError(e); 3374 } 3375 catch (IllegalAccessException e) 3376 { 3377 throw new AssertionError(e); 3378 } 3379 catch (InvocationTargetException e) 3380 { 3381 throw new AssertionError(e); 3382 } 3163 3383 } 3164 3384 … … 3166 3386 public static <T> Object wrapVariant(Class<T> wrapperClass, Variant v) 3167 3387 { 3168 if (v == null) 3169 return null; 3170 3171 short vt = v.getvt(); 3172 switch (vt) 3173 { 3174 case Variant.VariantNull: 3175 return null; 3176 case Variant.VariantBoolean: 3177 return v.getBoolean(); 3178 case Variant.VariantByte: 3179 return v.getByte(); 3180 case Variant.VariantShort: 3181 return v.getShort(); 3182 case Variant.VariantInt: 3183 return v.getInt(); 3184 case Variant.VariantLongInt: 3185 return v.getLong(); 3186 case Variant.VariantString: 3187 return v.getString(); 3188 case Variant.VariantDispatch: 3189 return wrapDispatch(wrapperClass, v.getDispatch()); 3190 default: 3191 throw new RuntimeException("unhandled variant type "+vt); 3192 } 3193 } 3194 3195 public static byte[] wrapBytes(SafeArray sa) { 3196 if (sa==null) return null; 3388 if (v == null) 3389 return null; 3390 3391 short vt = v.getvt(); 3392 switch (vt) 3393 { 3394 case Variant.VariantNull: 3395 return null; 3396 case Variant.VariantBoolean: 3397 return v.getBoolean(); 3398 case Variant.VariantByte: 3399 return v.getByte(); 3400 case Variant.VariantShort: 3401 return v.getShort(); 3402 case Variant.VariantInt: 3403 return v.getInt(); 3404 case Variant.VariantLongInt: 3405 return v.getLong(); 3406 case Variant.VariantString: 3407 return v.getString(); 3408 case Variant.VariantDispatch: 3409 return wrapDispatch(wrapperClass, v.getDispatch()); 3410 default: 3411 throw new VBoxException("unhandled variant type " + vt); 3412 } 3413 } 3414 3415 public static byte[] wrapBytes(SafeArray sa) 3416 { 3417 if (sa == null) 3418 return null; 3197 3419 3198 3420 int saLen = sa.getUBound() - sa.getLBound() + 1; … … 3202 3424 for (int i = sa.getLBound(); i <= sa.getUBound(); i++) 3203 3425 { 3204 Variant v = sa.getVariant(i);3205 // come upowith more effective approach!!!3206 ret[j++] = v.getByte();3426 Variant v = sa.getVariant(i); 3427 // come up with more effective approach!!! 3428 ret[j++] = v.getByte(); 3207 3429 } 3208 3430 return ret; … … 3210 3432 3211 3433 @SuppressWarnings("unchecked") 3212 public static <T> List<T> wrap(Class<T> wrapperClass, SafeArray sa) { 3213 if (sa==null) return null; 3434 public static <T> List<T> wrap(Class<T> wrapperClass, SafeArray sa) 3435 { 3436 if (sa == null) 3437 return null; 3214 3438 3215 3439 int saLen = sa.getUBound() - sa.getLBound() + 1; 3216 if (saLen == 0) return Collections.emptyList(); 3440 if (saLen == 0) 3441 return Collections.emptyList(); 3217 3442 3218 3443 List<T> ret = new ArrayList<T>(saLen); 3219 3444 for (int i = sa.getLBound(); i <= sa.getUBound(); i++) 3220 3445 { 3221 Variant v = sa.getVariant(i);3222 ret.add((T)wrapVariant(wrapperClass, v));3446 Variant v = sa.getVariant(i); 3447 ret.add((T)wrapVariant(wrapperClass, v)); 3223 3448 } 3224 3449 return ret; 3225 3450 } 3226 3451 3227 public static <T> List<T> wrapEnum(Class<T> wrapperClass, SafeArray sa) { 3228 try { 3229 if (sa==null) return null; 3230 3231 int saLen = sa.getUBound() - sa.getLBound() + 1; 3232 if (saLen == 0) return Collections.emptyList(); 3233 List<T> ret = new ArrayList<T>(saLen); 3234 Constructor<T> c = wrapperClass.getConstructor(int.class); 3235 for (int i = sa.getLBound(); i <= sa.getUBound(); i++) 3236 { 3237 Variant v = sa.getVariant(i); 3238 ret.add(c.newInstance(v.getInt())); 3239 } 3240 return ret; 3241 } catch (NoSuchMethodException e) { 3242 throw new AssertionError(e); 3243 } catch (InstantiationException e) { 3244 throw new AssertionError(e); 3245 } catch (IllegalAccessException e) { 3246 throw new AssertionError(e); 3247 } catch (InvocationTargetException e) { 3248 throw new AssertionError(e); 3249 } 3250 } 3251 3252 public static SafeArray unwrapInt(List<Integer> vals) { 3253 if (vals==null) return null; 3254 SafeArray ret = new SafeArray(Variant.VariantInt, vals.size()); 3255 int i = 0; 3256 for (int l : vals) { 3257 ret.setInt(i++, l); 3258 } 3259 return ret; 3260 } 3261 3262 public static SafeArray unwrapLong(List<Long> vals) { 3263 if (vals==null) return null; 3264 SafeArray ret = new SafeArray(Variant.VariantLongInt, vals.size()); 3265 int i = 0; 3266 for (long l : vals) { 3267 ret.setLong(i++, l); 3268 } 3269 return ret; 3270 } 3271 3272 public static SafeArray unwrapBool(List<Boolean> vals) { 3273 if (vals==null) return null; 3274 3275 SafeArray result = new SafeArray(Variant.VariantBoolean, vals.size()); 3276 int i = 0; 3277 for (boolean l : vals) { 3278 result.setBoolean(i++, l); 3279 } 3280 return result; 3281 } 3282 3283 3284 public static SafeArray unwrapBytes(byte[] vals) { 3285 if (vals==null) return null; 3286 3287 SafeArray result = new SafeArray(Variant.VariantByte, vals.length); 3288 int i = 0; 3289 for (byte l : vals) { 3290 result.setByte(i++, l); 3291 } 3292 return result; 3293 } 3294 3295 3296 public static <T extends Enum <T>> SafeArray unwrapEnum(Class<T> enumClass, List<T> values) { 3297 if (values == null) return null; 3298 3299 SafeArray result = new SafeArray(Variant.VariantInt, values.size()); 3300 try { 3301 java.lang.reflect.Method valueM = enumClass.getMethod("value"); 3302 int i = 0; 3303 for (T v : values) { 3304 result.setInt(i++, (Integer)valueM.invoke(v)); 3305 } 3306 return result; 3307 } catch (NoSuchMethodException e) { 3308 throw new AssertionError(e); 3309 } catch(SecurityException e) { 3310 throw new AssertionError(e); 3311 } catch (IllegalAccessException e) { 3312 throw new AssertionError(e); 3313 } catch (IllegalArgumentException e) { 3314 throw new AssertionError(e); 3315 } catch (InvocationTargetException e) { 3316 throw new AssertionError(e); 3317 } 3318 } 3319 public static SafeArray unwrapString(List<String> vals) { 3320 if (vals==null) 3321 return null; 3322 SafeArray result = new SafeArray(Variant.VariantString, vals.size()); 3323 int i = 0; 3324 for (String l : vals) { 3325 result.setString(i++, l); 3326 } 3327 return result; 3328 } 3329 3330 public static <T1, T2> List<T1> wrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, T2[] thisPtrs) { 3331 try { 3332 if (thisPtrs==null) return null; 3333 if (thisPtrs.length == 0) return Collections.emptyList(); 3334 3335 Constructor<T1> c = wrapperClass1.getConstructor(wrapperClass2); 3336 List<T1> ret = new ArrayList<T1>(thisPtrs.length); 3337 for (T2 thisPtr : thisPtrs) { 3338 ret.add(c.newInstance(thisPtr)); 3452 public static <T> List<T> wrapEnum(Class<T> wrapperClass, SafeArray sa) 3453 { 3454 try 3455 { 3456 if (sa == null) 3457 return null; 3458 3459 int saLen = sa.getUBound() - sa.getLBound() + 1; 3460 if (saLen == 0) 3461 return Collections.emptyList(); 3462 List<T> ret = new ArrayList<T>(saLen); 3463 Constructor<T> c = wrapperClass.getConstructor(int.class); 3464 for (int i = sa.getLBound(); i <= sa.getUBound(); i++) 3465 { 3466 Variant v = sa.getVariant(i); 3467 ret.add(c.newInstance(v.getInt())); 3339 3468 } 3340 3469 return ret; 3341 } catch (NoSuchMethodException e) { 3470 } 3471 catch (NoSuchMethodException e) 3472 { 3342 3473 throw new AssertionError(e); 3343 } catch (InstantiationException e) { 3474 } 3475 catch (InstantiationException e) 3476 { 3344 3477 throw new AssertionError(e); 3345 } catch (IllegalAccessException e) { 3478 } 3479 catch (IllegalAccessException e) 3480 { 3346 3481 throw new AssertionError(e); 3347 } catch (InvocationTargetException e) { 3482 } 3483 catch (InvocationTargetException e) 3484 { 3348 3485 throw new AssertionError(e); 3349 3486 } 3350 3487 } 3351 3488 3489 public static SafeArray unwrapInt(List<Integer> values) 3490 { 3491 if (values == null) 3492 return null; 3493 SafeArray ret = new SafeArray(Variant.VariantInt, values.size()); 3494 int i = 0; 3495 for (int l : values) 3496 { 3497 ret.setInt(i++, l); 3498 } 3499 return ret; 3500 } 3501 3502 public static SafeArray unwrapLong(List<Long> values) 3503 { 3504 if (values == null) 3505 return null; 3506 SafeArray ret = new SafeArray(Variant.VariantLongInt, values.size()); 3507 int i = 0; 3508 for (long l : values) 3509 { 3510 ret.setLong(i++, l); 3511 } 3512 return ret; 3513 } 3514 3515 public static SafeArray unwrapBool(List<Boolean> values) 3516 { 3517 if (values == null) 3518 return null; 3519 3520 SafeArray result = new SafeArray(Variant.VariantBoolean, values.size()); 3521 int i = 0; 3522 for (boolean l : values) 3523 { 3524 result.setBoolean(i++, l); 3525 } 3526 return result; 3527 } 3528 3529 3530 public static SafeArray unwrapBytes(byte[] values) 3531 { 3532 if (values == null) 3533 return null; 3534 3535 SafeArray result = new SafeArray(Variant.VariantByte, values.length); 3536 int i = 0; 3537 for (byte l : values) 3538 { 3539 result.setByte(i++, l); 3540 } 3541 return result; 3542 } 3543 3544 3545 public static <T extends Enum <T>> SafeArray unwrapEnum(Class<T> enumClass, List<T> values) 3546 { 3547 if (values == null) 3548 return null; 3549 3550 SafeArray result = new SafeArray(Variant.VariantInt, values.size()); 3551 try 3552 { 3553 java.lang.reflect.Method valueM = enumClass.getMethod("value"); 3554 int i = 0; 3555 for (T v : values) 3556 { 3557 result.setInt(i++, (Integer)valueM.invoke(v)); 3558 } 3559 return result; 3560 } 3561 catch (NoSuchMethodException e) 3562 { 3563 throw new AssertionError(e); 3564 } 3565 catch(SecurityException e) 3566 { 3567 throw new AssertionError(e); 3568 } 3569 catch (IllegalAccessException e) 3570 { 3571 throw new AssertionError(e); 3572 } 3573 catch (IllegalArgumentException e) 3574 { 3575 throw new AssertionError(e); 3576 } 3577 catch (InvocationTargetException e) 3578 { 3579 throw new AssertionError(e); 3580 } 3581 } 3582 public static SafeArray unwrapString(List<String> values) 3583 { 3584 if (values == null) 3585 return null; 3586 SafeArray result = new SafeArray(Variant.VariantString, values.size()); 3587 int i = 0; 3588 for (String l : values) 3589 { 3590 result.setString(i++, l); 3591 } 3592 return result; 3593 } 3594 3595 public static <T1, T2> List<T1> wrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, T2[] values) 3596 { 3597 try 3598 { 3599 if (values == null) 3600 return null; 3601 if (values.length == 0) 3602 return Collections.emptyList(); 3603 3604 Constructor<T1> c = wrapperClass1.getConstructor(wrapperClass2); 3605 List<T1> ret = new ArrayList<T1>(values.length); 3606 for (T2 v : values) 3607 { 3608 ret.add(c.newInstance(v)); 3609 } 3610 return ret; 3611 } 3612 catch (NoSuchMethodException e) 3613 { 3614 throw new AssertionError(e); 3615 } 3616 catch (InstantiationException e) 3617 { 3618 throw new AssertionError(e); 3619 } 3620 catch (IllegalAccessException e) 3621 { 3622 throw new AssertionError(e); 3623 } 3624 catch (InvocationTargetException e) 3625 { 3626 throw new AssertionError(e); 3627 } 3628 } 3629 3352 3630 @SuppressWarnings("unchecked") 3353 public static <T> T[] unwrap(Class<T> wrapperClass, List<T> thisPtrs) { 3354 if (thisPtrs==null) return null; 3355 return (T[])thisPtrs.toArray((T[])Array.newInstance(wrapperClass, thisPtrs.size())); 3631 public static <T> T[] unwrap(Class<T> wrapperClass, List<T> values) 3632 { 3633 if (values == null) 3634 return null; 3635 return (T[])values.toArray((T[])Array.newInstance(wrapperClass, values.size())); 3356 3636 } 3357 3637 3358 3638 @SuppressWarnings("unchecked") 3359 public static <T1 extends IUnknown,T2> T2[] unwrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, List<T1> thisPtrs) { 3360 if (thisPtrs==null) return null; 3361 3362 T2 ret[] = (T2[])Array.newInstance(wrapperClass2, thisPtrs.size()); 3639 public static <T1 extends IUnknown, T2> T2[] unwrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, List<T1> values) 3640 { 3641 if (values == null) 3642 return null; 3643 3644 T2 ret[] = (T2[])Array.newInstance(wrapperClass2, values.size()); 3363 3645 int i = 0; 3364 for (T1 obj : thisPtrs) { 3365 ret[i++] = (T2)obj.getWrapped(); 3646 for (T1 obj : values) 3647 { 3648 ret[i++] = (T2)obj.getWrapped(); 3366 3649 } 3367 3650 return ret; … … 3375 3658 } 3376 3659 ]]></xsl:text> 3377 3378 <xsl:call-template name="endFile"> 3379 <xsl:with-param name="file" select="'Helper.java'" /> 3380 </xsl:call-template> 3381 3382 3383 <xsl:call-template name="startFile"> 3660 </xsl:if> 3661 3662 <xsl:call-template name="endFile"> 3663 <xsl:with-param name="file" select="'Helper.java'" /> 3664 </xsl:call-template> 3665 3666 <xsl:call-template name="startFile"> 3667 <xsl:with-param name="file" select="'VBoxException.java'" /> 3668 <xsl:with-param name="package" select="$G_virtualBoxPackage" /> 3669 </xsl:call-template> 3670 3671 <xsl:if test="$filelistonly=''"> 3672 <xsl:text> 3673 3674 public class VBoxException extends RuntimeException 3675 { 3676 private int resultCode; 3677 private IVirtualBoxErrorInfo errorInfo; 3678 3679 public VBoxException(String message) 3680 { 3681 super(message); 3682 resultCode = -1; 3683 errorInfo = null; 3684 } 3685 3686 public VBoxException(String message, Throwable cause) 3687 { 3688 super(message, cause); 3689 if (cause instanceof com.jacob.com.ComException) 3690 { 3691 resultCode = ((com.jacob.com.ComException)cause).getHResult(); 3692 // JACOB doesn't support calling GetErrorInfo, which 3693 // means there is no way of getting an IErrorInfo reference, 3694 // and that means no way of getting to IVirtualBoxErrorInfo. 3695 errorInfo = null; 3696 } 3697 else 3698 resultCode = -1; 3699 } 3700 3701 public int getResultCode() 3702 { 3703 return resultCode; 3704 } 3705 3706 public IVirtualBoxErrorInfo getVirtualBoxErrorInfo() 3707 { 3708 return errorInfo; 3709 } 3710 } 3711 </xsl:text> 3712 </xsl:if> 3713 3714 <xsl:call-template name="endFile"> 3715 <xsl:with-param name="file" select="'VBoxException.java'" /> 3716 </xsl:call-template> 3717 3718 3719 <xsl:call-template name="startFile"> 3384 3720 <xsl:with-param name="file" select="'VirtualBoxManager.java'" /> 3385 3721 <xsl:with-param name="package" select="$G_virtualBoxPackage" /> 3386 3722 </xsl:call-template> 3387 3723 3388 <xsl:text><![CDATA[ 3724 <xsl:if test="$filelistonly=''"> 3725 <xsl:text><![CDATA[ 3389 3726 3390 3727 import com.jacob.activeX.ActiveXComponent; … … 3397 3734 public class VirtualBoxManager 3398 3735 { 3399 private IVirtualBox 3736 private IVirtualBox vbox; 3400 3737 3401 3738 private VirtualBoxManager() … … 3407 3744 public static void initPerThread() 3408 3745 { 3409 3746 ComThread.InitMTA(); 3410 3747 } 3411 3748 3412 3749 public static void deinitPerThread() 3413 3750 { 3414 3751 ComThread.Release(); 3415 3752 } 3416 3753 3417 3754 public void connect(String url, String username, String passwd) 3418 3755 { 3419 throw new RuntimeException("Connect doesn't make sense for local bindings");3756 throw new VBoxException("Connect doesn't make sense for local bindings"); 3420 3757 } 3421 3758 3422 3759 public void disconnect() 3423 3760 { 3424 throw new RuntimeException("Disconnect doesn't make sense for local bindings");3761 throw new VBoxException("Disconnect doesn't make sense for local bindings"); 3425 3762 } 3426 3763 … … 3453 3790 { 3454 3791 if (hasInstance) 3455 throw new VBoxException(null, "only one instance at thetime allowed");3792 throw new VBoxException("only one instance of VirtualBoxManager at a time allowed"); 3456 3793 3457 3794 hasInstance = true; … … 3465 3802 } 3466 3803 3467 public boolean progressBar(IProgress p, int wait)3468 {3469 long end = System.currentTimeMillis() + wait;3470 while (!p.getCompleted())3471 {3472 p.waitForCompletion(wait);3473 if (System.currentTimeMillis() >= end)3474 return false;3475 }3476 3477 return true;3478 }3479 3480 public boolean startVm(String name, String type, int timeout)3481 {3482 IMachine m = vbox.findMachine(name);3483 if (m == null)3484 return false;3485 ISession session = getSessionObject();3486 if (type == null)3487 type = "gui";3488 IProgress p = m.launchVMProcess(session, type, "");3489 progressBar(p, timeout);3490 session.unlockMachine();3491 return true;3492 }3493 3494 3804 public void waitForEvents(long tmo) 3495 3805 { 3496 3806 // what to do here? 3497 try { 3807 try 3808 { 3498 3809 Thread.sleep(tmo); 3499 } catch (InterruptedException ie) { 3810 } 3811 catch (InterruptedException ie) 3812 { 3500 3813 } 3501 3814 } 3502 3815 } 3503 3816 ]]></xsl:text> 3504 3505 <xsl:call-template name="endFile"> 3506 <xsl:with-param name="file" select="'VirtualBoxManager.java'" />3507 </xsl:call-template>3508 3817 </xsl:if> 3818 3819 <xsl:call-template name="endFile"> 3820 <xsl:with-param name="file" select="'VirtualBoxManager.java'" /> 3821 </xsl:call-template> 3509 3822 </xsl:template> 3510 3823 … … 3516 3829 </xsl:call-template> 3517 3830 3518 <xsl:text><![CDATA[ 3831 <xsl:if test="$filelistonly=''"> 3832 <xsl:text><![CDATA[ 3519 3833 public class IUnknown 3520 3834 { 3521 protected String obj; 3522 protected final VboxPortType port; 3523 3524 public IUnknown(String obj, VboxPortType port) 3525 { 3526 this.obj = obj; 3527 this.port = port; 3528 } 3529 3530 public final String getWrapped() 3531 { 3532 return this.obj; 3533 } 3534 3535 public final VboxPortType getRemoteWSPort() 3536 { 3537 return this.port; 3538 } 3539 3540 public synchronized void releaseRemote() throws WebServiceException 3541 { 3542 if (obj == null) { 3543 return; 3544 } 3545 try { 3546 this.port.iManagedObjectRefRelease(obj); 3547 this.obj = null; 3548 } catch (InvalidObjectFaultMsg e) { 3549 throw new WebServiceException(e); 3550 } catch (RuntimeFaultMsg e) { 3551 throw new WebServiceException(e); 3552 } 3553 } 3835 protected String obj; 3836 protected final VboxPortType port; 3837 3838 public IUnknown(String obj, VboxPortType port) 3839 { 3840 this.obj = obj; 3841 this.port = port; 3842 } 3843 3844 public final String getWrapped() 3845 { 3846 return this.obj; 3847 } 3848 3849 public final VboxPortType getRemoteWSPort() 3850 { 3851 return this.port; 3852 } 3853 3854 public synchronized void releaseRemote() throws WebServiceException 3855 { 3856 if (obj == null) 3857 return; 3858 3859 try 3860 { 3861 this.port.iManagedObjectRefRelease(obj); 3862 this.obj = null; 3863 } 3864 catch (InvalidObjectFaultMsg e) 3865 { 3866 throw new WebServiceException(e); 3867 } 3868 catch (RuntimeFaultMsg e) 3869 { 3870 throw new WebServiceException(e); 3871 } 3872 } 3554 3873 } 3555 3874 ]]></xsl:text> 3556 3557 <xsl:call-template name="endFile"> 3558 <xsl:with-param name="file" select="'IUnknown.java'" /> 3559 </xsl:call-template> 3560 3561 <xsl:call-template name="startFile"> 3562 <xsl:with-param name="file" select="'Helper.java'" /> 3563 <xsl:with-param name="package" select="$G_virtualBoxPackage" /> 3564 </xsl:call-template> 3565 3566 <xsl:text><![CDATA[ 3875 </xsl:if> 3876 3877 <xsl:call-template name="endFile"> 3878 <xsl:with-param name="file" select="'IUnknown.java'" /> 3879 </xsl:call-template> 3880 3881 <xsl:call-template name="startFile"> 3882 <xsl:with-param name="file" select="'Helper.java'" /> 3883 <xsl:with-param name="package" select="$G_virtualBoxPackage" /> 3884 </xsl:call-template> 3885 3886 <xsl:if test="$filelistonly=''"> 3887 <xsl:text><![CDATA[ 3567 3888 3568 3889 import java.util.List; … … 3574 3895 import java.math.BigInteger; 3575 3896 3576 public class Helper { 3577 public static <T> List<T> wrap(Class<T> wrapperClass, VboxPortType pt, List<String> thisPtrs) { 3578 try { 3579 if(thisPtrs==null) return null; 3897 public class Helper 3898 { 3899 public static <T> List<T> wrap(Class<T> wrapperClass, VboxPortType pt, List<String> values) 3900 { 3901 try 3902 { 3903 if (values == null) 3904 return null; 3580 3905 3581 3906 Constructor<T> c = wrapperClass.getConstructor(String.class, VboxPortType.class); 3582 List<T> ret = new ArrayList<T>(thisPtrs.size()); 3583 for (String thisPtr : thisPtrs) { 3584 ret.add(c.newInstance(thisPtr,pt)); 3907 List<T> ret = new ArrayList<T>(values.size()); 3908 for (String v : values) 3909 { 3910 ret.add(c.newInstance(v, pt)); 3585 3911 } 3586 3912 return ret; 3587 } catch (NoSuchMethodException e) { 3913 } 3914 catch (NoSuchMethodException e) 3915 { 3588 3916 throw new AssertionError(e); 3589 } catch (InstantiationException e) { 3917 } 3918 catch (InstantiationException e) 3919 { 3590 3920 throw new AssertionError(e); 3591 } catch (IllegalAccessException e) { 3921 } 3922 catch (IllegalAccessException e) 3923 { 3592 3924 throw new AssertionError(e); 3593 } catch (InvocationTargetException e) { 3925 } 3926 catch (InvocationTargetException e) 3927 { 3594 3928 throw new AssertionError(e); 3595 3929 } 3596 3930 } 3597 3931 3598 public static <T1, T2> List<T1> wrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, VboxPortType pt, List<T2> thisPtrs) { 3599 try { 3600 if(thisPtrs==null) return null; 3932 public static <T1, T2> List<T1> wrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, VboxPortType pt, List<T2> values) 3933 { 3934 try 3935 { 3936 if (values == null) 3937 return null; 3601 3938 3602 3939 Constructor<T1> c = wrapperClass1.getConstructor(wrapperClass2, VboxPortType.class); 3603 List<T1> ret = new ArrayList<T1>(thisPtrs.size()); 3604 for (T2 thisPtr : thisPtrs) { 3605 ret.add(c.newInstance(thisPtr,pt)); 3940 List<T1> ret = new ArrayList<T1>(values.size()); 3941 for (T2 v : values) 3942 { 3943 ret.add(c.newInstance(v, pt)); 3606 3944 } 3607 3945 return ret; 3608 } catch (NoSuchMethodException e) { 3946 } 3947 catch (NoSuchMethodException e) 3948 { 3609 3949 throw new AssertionError(e); 3610 } catch (InstantiationException e) { 3950 } 3951 catch (InstantiationException e) 3952 { 3611 3953 throw new AssertionError(e); 3612 } catch (IllegalAccessException e) { 3954 } 3955 catch (IllegalAccessException e) 3956 { 3613 3957 throw new AssertionError(e); 3614 } catch (InvocationTargetException e) { 3958 } 3959 catch (InvocationTargetException e) 3960 { 3615 3961 throw new AssertionError(e); 3616 3962 } 3617 3963 } 3618 3964 3619 public static <T extends IUnknown> List<String> unwrap(List<T> thisPtrs) { 3620 if (thisPtrs==null) return null; 3621 3622 List<String> ret = new ArrayList<String>(thisPtrs.size()); 3623 for (T obj : thisPtrs) { 3965 public static <T extends IUnknown> List<String> unwrap(List<T> values) 3966 { 3967 if (values == null) 3968 return null; 3969 3970 List<String> ret = new ArrayList<String>(values.size()); 3971 for (T obj : values) 3972 { 3624 3973 ret.add(obj.getWrapped()); 3625 3974 } … … 3630 3979 public static <T1 extends Enum <T1>, T2 extends Enum <T2>> List<T2> convertEnums(Class<T1> fromClass, 3631 3980 Class<T2> toClass, 3632 List<T1> values) { 3633 try { 3634 if (values==null) 3635 return null; 3981 List<T1> values) 3982 { 3983 try 3984 { 3985 if (values == null) 3986 return null; 3636 3987 java.lang.reflect.Method fromValue = toClass.getMethod("fromValue", String.class); 3637 3988 List<T2> ret = new ArrayList<T2>(values.size()); 3638 for (T1 v : values) { 3989 for (T1 v : values) 3990 { 3639 3991 // static method is called with null this 3640 3992 ret.add((T2)fromValue.invoke(null, v.name())); 3641 3993 } 3642 3994 return ret; 3643 } catch (NoSuchMethodException e) { 3995 } 3996 catch (NoSuchMethodException e) 3997 { 3644 3998 throw new AssertionError(e); 3645 } catch (IllegalAccessException e) { 3999 } 4000 catch (IllegalAccessException e) 4001 { 3646 4002 throw new AssertionError(e); 3647 } catch (InvocationTargetException e) { 4003 } 4004 catch (InvocationTargetException e) 4005 { 3648 4006 throw new AssertionError(e); 3649 4007 } … … 3661 4019 3662 4020 for (int i = 0; i < valToChar.length; i++) 3663 charToVal[valToChar[i]] = i;4021 charToVal[valToChar[i]] = i; 3664 4022 3665 4023 charToVal['='] = 0; … … 3715 4073 } 3716 4074 default: 3717 throw new RuntimeException("bug!");4075 throw new VBoxException("bug!"); 3718 4076 } 3719 4077 … … 3751 4109 3752 4110 if ((validChars * 3 % 4) != 0) 3753 throw new RuntimeException("invalid encoded string "+str);4111 throw new VBoxException("invalid base64 encoded string " + str); 3754 4112 3755 4113 int resultLength = validChars * 3 / 4 - padChars; … … 3759 4117 int quadraplets = validChars / 4; 3760 4118 3761 for (int i =0; i<quadraplets; i++)4119 for (int i = 0; i < quadraplets; i++) 3762 4120 { 3763 4121 stringIndex = skipInvalid(str, stringIndex); … … 3782 4140 } 3783 4141 ]]></xsl:text> 3784 3785 <xsl:call-template name="endFile"> 3786 <xsl:with-param name="file" select="'Helper.java'" /> 3787 </xsl:call-template> 3788 3789 <xsl:call-template name="startFile"> 4142 </xsl:if> 4143 4144 <xsl:call-template name="endFile"> 4145 <xsl:with-param name="file" select="'Helper.java'" /> 4146 </xsl:call-template> 4147 4148 <xsl:call-template name="startFile"> 4149 <xsl:with-param name="file" select="'VBoxException.java'" /> 4150 <xsl:with-param name="package" select="$G_virtualBoxPackage" /> 4151 </xsl:call-template> 4152 4153 <xsl:if test="$filelistonly=''"> 4154 <xsl:text> 4155 public class VBoxException extends RuntimeException 4156 { 4157 private int resultCode; 4158 private IVirtualBoxErrorInfo errorInfo; 4159 4160 public VBoxException(String message) 4161 { 4162 super(message); 4163 resultCode = -1; 4164 errorInfo = null; 4165 } 4166 4167 public VBoxException(String message, Throwable cause) 4168 { 4169 super(message, cause); 4170 resultCode = -1; 4171 errorInfo = null; 4172 } 4173 4174 public VBoxException(String message, Throwable cause, VboxPortType port) 4175 { 4176 super(message, cause); 4177 if (cause instanceof RuntimeFaultMsg) 4178 { 4179 RuntimeFaultMsg m = (RuntimeFaultMsg)cause; 4180 RuntimeFault f = m.getFaultInfo(); 4181 resultCode = f.getResultCode(); 4182 String retVal = f.getReturnval(); 4183 errorInfo = (retVal.length() > 0) ? new IVirtualBoxErrorInfo(retVal, port) : null; 4184 } 4185 else 4186 resultCode = -1; 4187 } 4188 4189 public int getResultCode() 4190 { 4191 return resultCode; 4192 } 4193 4194 public IVirtualBoxErrorInfo getVirtualBoxErrorInfo() 4195 { 4196 return errorInfo; 4197 } 4198 } 4199 </xsl:text> 4200 </xsl:if> 4201 4202 <xsl:call-template name="endFile"> 4203 <xsl:with-param name="file" select="'VBoxException.java'" /> 4204 </xsl:call-template> 4205 4206 <xsl:call-template name="startFile"> 3790 4207 <xsl:with-param name="file" select="'VirtualBoxManager.java'" /> 3791 4208 <xsl:with-param name="package" select="$G_virtualBoxPackage" /> 3792 </xsl:call-template> 3793 3794 import java.net.URL; 4209 </xsl:call-template> 4210 4211 <xsl:if test="$filelistonly=''"> 4212 <xsl:text>import java.net.URL; 3795 4213 import java.math.BigInteger; 3796 4214 import java.util.List; … … 3804 4222 class PortPool 3805 4223 { 3806 private final static String wsdlFile = < xsl:value-of select="$G_virtualBoxWsdl" />;3807 3808 <xsl:text><![CDATA[3809 private Map<VboxPortType, Integer> known;4224 private final static String wsdlFile = </xsl:text> 4225 <xsl:value-of select="$G_virtualBoxWsdl" /> 4226 <xsl:text><![CDATA[; 4227 private Map<VboxPortType, Integer> known; 3810 4228 private boolean initStarted; 3811 4229 private VboxService svc; … … 3817 4235 if (usePreinit) 3818 4236 { 3819 new Thread(new Runnable() 3820 { 3821 public void run() 3822 { 3823 // need to sync on something else but 'this' 3824 synchronized (known) 4237 new Thread(new Runnable() 4238 { 4239 public void run() 3825 4240 { 3826 initStarted = true; 3827 known.notify(); 4241 // need to sync on something else but 'this' 4242 synchronized (known) 4243 { 4244 initStarted = true; 4245 known.notify(); 4246 } 4247 4248 preinit(); 3828 4249 } 3829 3830 preinit(); 3831 }3832 }).start();3833 3834 synchronized (known)3835 {3836 while (!initStarted)3837 {3838 try {3839 known.wait();3840 } catch (InterruptedException e){3841 break;3842 }3843 }3844 }4250 }).start(); 4251 4252 synchronized (known) 4253 { 4254 while (!initStarted) 4255 { 4256 try 4257 { 4258 known.wait(); 4259 } 4260 catch (InterruptedException e) 4261 { 4262 break; 4263 } 4264 } 4265 } 3845 4266 } 3846 4267 } … … 3870 4291 if (port == null) 3871 4292 { 3872 if (svc == null) { 4293 if (svc == null) 4294 { 3873 4295 URL wsdl = PortPool.class.getClassLoader().getResource(wsdlFile); 3874 4296 if (wsdl == null) 3875 throw new LinkageError(wsdlFile +" not found, but it should have been in the jar");4297 throw new LinkageError(wsdlFile + " not found, but it should have been in the jar"); 3876 4298 svc = new VboxService(wsdl, 3877 4299 new QName("http://www.virtualbox.org/Service", … … 3917 4339 protected VboxPortType port; 3918 4340 3919 private IVirtualBox 4341 private IVirtualBox vbox; 3920 4342 3921 4343 private VirtualBoxManager() … … 3934 4356 { 3935 4357 this.port = pool.getPort(); 3936 try { 4358 try 4359 { 3937 4360 ((BindingProvider)port).getRequestContext(). 3938 4361 put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url); 3939 4362 String handle = port.iWebsessionManagerLogon(username, passwd); 3940 4363 this.vbox = new IVirtualBox(handle, port); 3941 } catch (Throwable t) { 3942 if (this.port != null && pool != null) { 4364 } 4365 catch (Throwable t) 4366 { 4367 if (this.port != null && pool != null) 4368 { 3943 4369 pool.releasePort(this.port); 3944 4370 this.port = null; 3945 4371 } 3946 4372 // we have to throw smth derived from RuntimeException 3947 throw new VBoxException(t , t.getMessage());4373 throw new VBoxException(t.getMessage(), t, this.port); 3948 4374 } 3949 4375 } … … 3954 4380 this.port = pool.getPort(); 3955 4381 3956 try { 4382 try 4383 { 3957 4384 ((BindingProvider)port).getRequestContext(); 3958 4385 if (requestContext != null) … … 3966 4393 String handle = port.iWebsessionManagerLogon(username, passwd); 3967 4394 this.vbox = new IVirtualBox(handle, port); 3968 } catch (Throwable t) { 3969 if (this.port != null && pool != null) { 4395 } 4396 catch (Throwable t) 4397 { 4398 if (this.port != null && pool != null) 4399 { 3970 4400 pool.releasePort(this.port); 3971 4401 this.port = null; 3972 4402 } 3973 4403 // we have to throw smth derived from RuntimeException 3974 throw new VBoxException(t , t.getMessage());4404 throw new VBoxException(t.getMessage(), t, this.port); 3975 4405 } 3976 4406 } … … 3978 4408 public void disconnect() 3979 4409 { 3980 try { 3981 if ( this.vbox != null 3982 && port != null) 3983 port.iWebsessionManagerLogoff(this.vbox.getWrapped()); 3984 } catch (InvalidObjectFaultMsg e) { 3985 throw new VBoxException(e, e.getMessage()); 3986 } catch (RuntimeFaultMsg e) { 3987 throw new VBoxException(e, e.getMessage()); 3988 } finally { 3989 if (this.port != null) { 4410 if (this.port == null) 4411 return; 4412 4413 try 4414 { 4415 if (this.vbox != null && port != null) 4416 port.iWebsessionManagerLogoff(this.vbox.getWrapped()); 4417 } 4418 catch (InvalidObjectFaultMsg e) 4419 { 4420 throw new VBoxException(e.getMessage(), e, this.port); 4421 } 4422 catch (RuntimeFaultMsg e) 4423 { 4424 throw new VBoxException(e.getMessage(), e, this.port); 4425 } 4426 finally 4427 { 4428 if (this.port != null) 4429 { 3990 4430 pool.releasePort(this.port); 3991 4431 this.port = null; … … 4002 4442 { 4003 4443 if (this.vbox == null) 4004 throw new RuntimeException("connect first"); 4005 try { 4006 String handle = port.iWebsessionManagerGetSessionObject(this.vbox.getWrapped()); 4007 return new ISession(handle, port); 4008 } catch (InvalidObjectFaultMsg e) { 4009 throw new VBoxException(e, e.getMessage()); 4010 } catch (RuntimeFaultMsg e) { 4011 throw new VBoxException(e, e.getMessage()); 4444 throw new VBoxException("connect first"); 4445 try 4446 { 4447 String handle = port.iWebsessionManagerGetSessionObject(this.vbox.getWrapped()); 4448 return new ISession(handle, port); 4449 } 4450 catch (InvalidObjectFaultMsg e) 4451 { 4452 throw new VBoxException(e.getMessage(), e, this.port); 4453 } 4454 catch (RuntimeFaultMsg e) 4455 { 4456 throw new VBoxException(e.getMessage(), e, this.port); 4012 4457 } 4013 4458 } … … 4033 4478 public IEventListener createListener(Object sink) 4034 4479 { 4035 throw new RuntimeException("no active listeners here"); 4036 } 4480 throw new VBoxException("no active listeners here"); 4481 } 4482 4037 4483 public void cleanup() 4038 4484 { … … 4041 4487 } 4042 4488 4043 public boolean progressBar(IProgress p, int wait)4044 {4045 long end = System.currentTimeMillis() + wait;4046 while (!p.getCompleted())4047 {4048 p.waitForCompletion(wait);4049 if (System.currentTimeMillis() >= end)4050 return false;4051 }4052 4053 return true;4054 }4055 4056 public boolean startVm(String name, String type, int timeout)4057 {4058 IMachine m = vbox.findMachine(name);4059 if (m == null)4060 return false;4061 ISession session = getSessionObject();4062 4063 if (type == null)4064 type = "gui";4065 IProgress p = m.launchVMProcess(session, type, "");4066 progressBar(p, timeout);4067 session.unlockMachine();4068 return true;4069 }4070 4071 4489 public void waitForEvents(long tmo) 4072 4490 { 4073 4491 } 4074 4075 protected void finalize() throws Throwable 4076 { 4077 try { 4492 4493 protected void finalize() throws Throwable 4494 { 4495 try 4496 { 4078 4497 cleanup(); 4079 } catch(Exception e) { 4080 } 4081 finally { 4498 } 4499 catch(Exception e) 4500 { 4501 } 4502 finally 4503 { 4082 4504 super.finalize(); 4083 4505 } … … 4085 4507 } 4086 4508 ]]></xsl:text> 4087 4088 <xsl:call-template name="endFile"> 4089 <xsl:with-param name="file" select="'VirtualBoxManager.java'" />4090 </xsl:call-template>4091 4509 </xsl:if> 4510 4511 <xsl:call-template name="endFile"> 4512 <xsl:with-param name="file" select="'VirtualBoxManager.java'" /> 4513 </xsl:call-template> 4092 4514 </xsl:template> 4093 4515 … … 4099 4521 <xsl:with-param name="msg" select="'G_vboxApiSuffix must be given'" /> 4100 4522 </xsl:call-template> 4523 </xsl:if> 4524 4525 <xsl:if test="not($filelistonly='')"> 4526 <xsl:value-of select="concat($filelistonly, ' := \ ')"/> 4101 4527 </xsl:if> 4102 4528 … … 4139 4565 <xsl:choose> 4140 4566 <xsl:when test="$G_vboxGlueStyle='jaxws'"> 4141 <xsl:if test="not($module) and not(@wsmap='suppress') and not(@wsmap='global')">4567 <xsl:if test="not($module) and not(@wsmap='suppress')"> 4142 4568 <xsl:call-template name="genIface"> 4143 4569 <xsl:with-param name="ifname" select="@name" /> … … 4159 4585 </xsl:choose> 4160 4586 </xsl:for-each> 4587 4588 <xsl:if test="not($filelistonly='')"> 4589 <xsl:value-of select="' '"/> 4590 </xsl:if> 4591 4161 4592 </xsl:template> 4162 4593 </xsl:stylesheet> -
trunk/src/VBox/Main/glue/tests/TestVBox.java
r38914 r46478 5 5 6 6 /* 7 * Copyright (C) 2010-201 1Oracle Corporation7 * Copyright (C) 2010-2013 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 15 15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 16 16 */ 17 import org.virtualbox_4_ 2.*;17 import org.virtualbox_4_3.*; 18 18 import java.util.List; 19 19 import java.util.Arrays; … … 26 26 System.out.println("got event: " + ev); 27 27 VBoxEventType type = ev.getType(); 28 System.out.println("type = " +type);28 System.out.println("type = " + type); 29 29 switch (type) 30 30 { … … 35 35 System.out.println("Cannot query an interface"); 36 36 else 37 System.out.println("mid=" +mcse.getMachineId());37 System.out.println("mid=" + mcse.getMachineId()); 38 38 break; 39 39 } … … 64 64 65 65 try { 66 for (int i =0; i<50; i++)66 for (int i = 0; i < 50; i++) 67 67 { 68 68 System.out.print("."); … … 98 98 hwvirtNestedPaging = m.getHWVirtExProperty(HWVirtExPropertyType.NestedPaging); 99 99 paeEnabled = m.getCPUProperty(CPUPropertyType.PAE); 100 String osType = m.getOSTypeId(); 101 IGuestOSType foo = vbox.getGuestOSType(osType); 100 102 } 101 103 catch (VBoxException e) … … 115 117 } 116 118 119 static boolean progressBar(VirtualBoxManager mgr, IProgress p, long waitMillis) 120 { 121 long end = System.currentTimeMillis() + waitMillis; 122 while (!p.getCompleted()) 123 { 124 mgr.waitForEvents(0); 125 p.waitForCompletion(200); 126 if (System.currentTimeMillis() >= end) 127 return false; 128 } 129 return true; 130 } 131 117 132 static void testStart(VirtualBoxManager mgr, IVirtualBox vbox) 118 133 { 119 String m = vbox.getMachines().get(0).getName(); 120 System.out.println("\nAttempting to start VM '" + m + "'"); 121 mgr.startVm(m, null, 7000); 134 IMachine m = vbox.getMachines().get(0); 135 String name = m.getName(); 136 System.out.println("\nAttempting to start VM '" + name + "'"); 137 138 ISession session = mgr.getSessionObject(); 139 IProgress p = m.launchVMProcess(session, "gui", ""); 140 progressBar(mgr, p, 10000); 141 session.unlockMachine(); 122 142 } 123 143 … … 131 151 mgr2.connect("http://main:18083", "", ""); 132 152 133 String mach1 = mgr1.getVBox().getMachines().get(0).getName(); 134 String mach2 = mgr2.getVBox().getMachines().get(0).getName(); 135 136 mgr1.startVm(mach1, null, 7000); 137 mgr2.startVm(mach2, null, 7000); 153 IMachine m1 = mgr1.getVBox().getMachines().get(0); 154 IMachine m2 = mgr2.getVBox().getMachines().get(0); 155 String name1 = m1.getName(); 156 String name2 = m2.getName(); 157 ISession session1 = mgr1.getSessionObject(); 158 ISession session2 = mgr2.getSessionObject(); 159 IProgress p1 = m1.launchVMProcess(session1, "gui", ""); 160 IProgress p2 = m2.launchVMProcess(session2, "gui", ""); 161 progressBar(mgr1, p1, 10000); 162 progressBar(mgr2, p2, 10000); 163 session1.unlockMachine(); 164 session2.unlockMachine(); 138 165 } finally { 139 166 mgr1.cleanup(); … … 158 185 } 159 186 187 static void printErrorInfo(VBoxException e) 188 { 189 System.out.println("VBox error: " + e.getMessage()); 190 System.out.println("Error cause message: " + e.getCause()); 191 System.out.println("Overall result code: " + Integer.toHexString(e.getResultCode())); 192 int i = 1; 193 for (IVirtualBoxErrorInfo ei = e.getVirtualBoxErrorInfo(); ei != null; ei = ei.getNext(), i++) 194 { 195 System.out.println("Detail information #" + i); 196 System.out.println("Error mesage: " + ei.getText()); 197 System.out.println("Result code: " + Integer.toHexString(ei.getResultCode())); 198 // optional, usually provides little additional information: 199 System.out.println("Component: " + ei.getComponent()); 200 System.out.println("Interface ID: " + ei.getInterfaceID()); 201 } 202 } 203 160 204 161 205 public static void main(String[] args) … … 168 212 String passwd = null; 169 213 170 for (int i = 0; i <args.length; i++)171 { 172 if ( "-w".equals(args[i]))214 for (int i = 0; i < args.length; i++) 215 { 216 if (args[i].equals("-w")) 173 217 ws = true; 174 else if ( "-url".equals(args[i]))218 else if (args[i].equals("-url")) 175 219 url = args[++i]; 176 else if ( "-user".equals(args[i]))220 else if (args[i].equals("-user")) 177 221 user = args[++i]; 178 else if ( "-passwd".equals(args[i]))222 else if (args[i].equals("-passwd")) 179 223 passwd = args[++i]; 180 224 } … … 207 251 catch (VBoxException e) 208 252 { 209 System.out.println("VBox error: "+e.getMessage()+" original="+e.getWrapped()); 253 printErrorInfo(e); 254 System.out.println("Java stack trace:"); 255 e.printStackTrace(); 256 } 257 catch (RuntimeException e) 258 { 259 System.out.println("Runtime error: " + e.getMessage()); 210 260 e.printStackTrace(); 211 261 } -
trunk/src/VBox/Main/glue/vboxapi.py
r45473 r46478 11 11 """ 12 12 13 import sys, os13 import sys, os 14 14 import traceback 15 15 16 16 # To set Python bitness on OSX use 'export VERSIONER_PYTHON_PREFER_32_BIT=yes' 17 17 18 V boxBinDir = os.environ.get("VBOX_PROGRAM_PATH", None)19 V boxSdkDir = os.environ.get("VBOX_SDK_PATH", None)20 21 if V boxBinDir is None:18 VBoxBinDir = os.environ.get("VBOX_PROGRAM_PATH", None) 19 VBoxSdkDir = os.environ.get("VBOX_SDK_PATH", None) 20 21 if VBoxBinDir is None: 22 22 # Will be set by the installer 23 V boxBinDir = "%VBOX_INSTALL_PATH%"24 25 if V boxSdkDir is None:23 VBoxBinDir = "%VBOX_INSTALL_PATH%" 24 25 if VBoxSdkDir is None: 26 26 # Will be set by the installer 27 V boxSdkDir = "%VBOX_SDK_PATH%"28 29 os.environ["VBOX_PROGRAM_PATH"] = V boxBinDir30 os.environ["VBOX_SDK_PATH"] = V boxSdkDir31 sys.path.append(V boxBinDir)27 VBoxSdkDir = "%VBOX_SDK_PATH%" 28 29 os.environ["VBOX_PROGRAM_PATH"] = VBoxBinDir 30 os.environ["VBOX_SDK_PATH"] = VBoxSdkDir 31 sys.path.append(VBoxBinDir) 32 32 33 33 from VirtualBox_constants import VirtualBoxReflectionInfo … … 124 124 return getattr(self, k) 125 125 try: 126 return _COMForward['getattr'](self, ComifyName(attr))126 return _COMForward['getattr'](self, ComifyName(attr)) 127 127 except AttributeError: 128 return _COMForward['getattr'](self, attr)128 return _COMForward['getattr'](self, attr) 129 129 130 130 def CustomSetAttr(self, attr, value): … … 173 173 name = attr 174 174 return win32com.client.constants.__getattr__(name) 175 except AttributeError, e:175 except AttributeError, e: 176 176 fake = PlatformMSCOM.ConstantFake(self, attr) 177 177 consts[attr] = fake … … 190 190 try: 191 191 return win32com.client.constants.__getattr__(a) 192 except AttributeError, e:192 except AttributeError, e: 193 193 return self.__dict__['_rootFake'].__getattr__(a) 194 194 … … 199 199 200 200 def __init__(self, params): 201 202 203 204 205 206 207 208 from win32api import GetCurrentThread,GetCurrentThreadId,DuplicateHandle,GetCurrentProcess209 210 211 212 213 214 215 216 217 218 219 220 221 222 201 from win32com import universal 202 from win32com.client import gencache, DispatchBaseClass 203 from win32com.client import constants, getevents 204 import win32com 205 import pythoncom 206 import win32api 207 from win32con import DUPLICATE_SAME_ACCESS 208 from win32api import GetCurrentThread, GetCurrentThreadId, DuplicateHandle, GetCurrentProcess 209 import threading 210 pid = GetCurrentProcess() 211 self.tid = GetCurrentThreadId() 212 handle = DuplicateHandle(pid, GetCurrentThread(), pid, 0, 0, DUPLICATE_SAME_ACCESS) 213 self.handles = [] 214 self.handles.append(handle) 215 _COMForward['getattr'] = DispatchBaseClass.__dict__['__getattr__'] 216 DispatchBaseClass.__dict__['__getattr__'] = CustomGetAttr 217 _COMForward['setattr'] = DispatchBaseClass.__dict__['__setattr__'] 218 DispatchBaseClass.__dict__['__setattr__'] = CustomSetAttr 219 win32com.client.gencache.EnsureDispatch('VirtualBox.Session') 220 win32com.client.gencache.EnsureDispatch('VirtualBox.VirtualBox') 221 self.oIntCv = threading.Condition() 222 self.fInterrupted = False; 223 223 224 224 def getSessionObject(self, vbox): … … 272 272 str += " def __init__(self): BaseClass.__init__(self, arg)\n" 273 273 str += "result = win32com.server.util.wrap(ListenerImpl())\n" 274 exec (str, d,d)274 exec (str, d, d) 275 275 return d['result'] 276 276 … … 288 288 raise Exception("wait for events from the same thread you inited!") 289 289 290 if timeout < 0: cMsTimeout = INFINITE 291 else: cMsTimeout = timeout 290 if timeout < 0: 291 cMsTimeout = INFINITE 292 else: 293 cMsTimeout = timeout 292 294 rc = MsgWaitForMultipleObjects(self.handles, 0, cMsTimeout, QS_ALLINPUT) 293 295 if rc >= WAIT_OBJECT_0 and rc < WAIT_OBJECT_0+len(self.handles): … … 343 345 pass 344 346 345 def queryInterface(self, obj, klazzName):347 def queryInterface(self, obj, className): 346 348 from win32com.client import CastTo 347 return CastTo(obj, klazzName)349 return CastTo(obj, className) 348 350 349 351 class PlatformXPCOM: 350 352 def __init__(self, params): 351 sys.path.append(V boxSdkDir+'/bindings/xpcom/python/')353 sys.path.append(VBoxSdkDir+'/bindings/xpcom/python/') 352 354 import xpcom.vboxxpcom 353 355 import xpcom … … 389 391 str += " def __init__(self): BaseClass.__init__(self, arg)\n" 390 392 str += "result = ListenerImpl()\n" 391 exec (str, d,d)393 exec (str, d, d) 392 394 return d['result'] 393 395 … … 404 406 xpcom._xpcom.DeinitCOM() 405 407 406 def queryInterface(self, obj, klazzName):408 def queryInterface(self, obj, className): 407 409 import xpcom.components 408 return obj.queryInterface(getattr(xpcom.components.interfaces, klazzName))410 return obj.queryInterface(getattr(xpcom.components.interfaces, className)) 409 411 410 412 class PlatformWEBSERVICE: 411 413 def __init__(self, params): 412 sys.path.append(os.path.join(V boxSdkDir,'bindings', 'webservice', 'python', 'lib'))414 sys.path.append(os.path.join(VBoxSdkDir, 'bindings', 'webservice', 'python', 'lib')) 413 415 #import VirtualBox_services 414 416 import VirtualBox_wrappers … … 488 490 pass 489 491 490 def queryInterface(self, obj, klazzName):492 def queryInterface(self, obj, className): 491 493 d = {} 492 494 d['obj'] = obj 493 495 str = "" 494 str += "from VirtualBox_wrappers import "+ klazzName+"\n"495 str += "result = "+ klazzName+"(obj.mgr,obj.handle)\n"496 str += "from VirtualBox_wrappers import "+className+"\n" 497 str += "result = "+className+"(obj.mgr, obj.handle)\n" 496 498 # wrong, need to test if class indeed implements this interface 497 exec (str, d,d)499 exec (str, d, d) 498 500 return d['result'] 499 501 … … 524 526 try: 525 527 self.vbox = self.platform.getVirtualBox() 526 except NameError, ne:528 except NameError, ne: 527 529 print "Installation problem: check that appropriate libs in place" 528 530 traceback.print_exc() 529 531 raise ne 530 except Exception, e:531 print "init exception: ", e532 except Exception, e: 533 print "init exception: ", e 532 534 traceback.print_exc() 533 535 if self.remote: … … 540 542 541 543 def getVirtualBox(self): 542 return 544 return self.platform.getVirtualBox() 543 545 544 546 def __del__(self): … … 604 606 605 607 def getBinDir(self): 606 global V boxBinDir607 return V boxBinDir608 global VBoxBinDir 609 return VBoxBinDir 608 610 609 611 def getSdkDir(self): 610 global V boxSdkDir611 return V boxSdkDir612 613 def queryInterface(self, obj, klazzName):614 return self.platform.queryInterface(obj, klazzName)612 global VBoxSdkDir 613 return VBoxSdkDir 614 615 def queryInterface(self, obj, className): 616 return self.platform.queryInterface(obj, className) -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r46465 r46478 1 <?xml version="1.0" encoding="utf-8"?>1 <?xml version="1.0" encoding="utf-8"?> 2 2 3 3 <!-- … … 1239 1239 <const name="ComboMouse" value="5"> 1240 1240 <desc>Combined device, working as PS/2 or USB mouse, depending on guest behavior. 1241 Using of such device can have negative performance implications. 1241 Using of such device can have negative performance implications.</desc> 1242 1242 </const> 1243 1243 </enum> … … 1261 1261 <const name="ComboKeyboard" value="4"> 1262 1262 <desc>Combined device, working as PS/2 or USB keyboard, depending on guest behavior. 1263 Using of such device can have negative performance implications. 1263 Using of such device can have negative performance implications.</desc> 1264 1264 </const> 1265 1265 </enum> … … 1410 1410 <attribute name="IPv6Prefix" type="wstring"> 1411 1411 <desc> 1412 This a CIDR IPv6 defining prefix for link-local addresses autoconfiguration within network. Note: ignored if attribute ipv6enabled is false. 1412 This a CIDR IPv6 defining prefix for link-local addresses 1413 autoconfiguration within network. Note: ignored if attribute 1414 IPv6Enabled is false. 1413 1415 </desc> 1414 1416 </attribute> … … 3803 3805 <interface 3804 3806 name="IPCIAddress" extends="$unknown" 3805 uuid=" D88B324F-DB19-4D3B-A1A9-BF5B127199A8"3806 wsmap=" struct"3807 uuid="c984d15f-e191-400b-840e-970f3dad7296" 3808 wsmap="managed" 3807 3809 > 3808 3810 … … 4732 4734 Empty or @c null strings do not define a particular default, it is up 4733 4735 to <link to="IMachine::launchVMProcess" /> to select one. See the 4734 description of <link to="IMachine::launchVMProcess" /> 4736 description of <link to="IMachine::launchVMProcess" /> for the valid 4735 4737 frontend types. 4736 4738 … … 14281 14283 Format of the video memory buffer. Constants represented by this enum can 14282 14284 be used to test for particular values of <link 14283 to="IFramebuffer::pixelFormat"/>. See also <link 14284 to="IFramebuffer::requestResize"/>. 14285 to="IFramebuffer::pixelFormat"/>. 14285 14286 14286 14287 See also www.fourcc.org for more information about FOURCC pixel formats. … … 14304 14305 name="IFramebuffer" extends="$unknown" 14305 14306 uuid="e3f122c0-adab-4fc9-a8dc-da112fb48428" 14306 wsmap=" suppress"14307 > 14308 <attribute name="address" type="octet" mod="ptr" readonly="yes" >14307 wsmap="managed" 14308 > 14309 <attribute name="address" type="octet" mod="ptr" readonly="yes" wsmap="suppress"> 14309 14310 <desc>Address of the start byte of the frame buffer.</desc> 14310 14311 </attribute> … … 14339 14340 to="FramebufferPixelFormat"/> or a raw FOURCC code. 14340 14341 <note> 14341 This attribute must never return <link14342 to="FramebufferPixelFormat_Opaque"/> -- the format of the buffer14343 <link to="#address"/> points tomust be always known.14342 This attribute must never (and will never) return <link 14343 to="FramebufferPixelFormat_Opaque"/> -- the format of the frame 14344 buffer must be always known. 14344 14345 </note> 14345 14346 </desc> … … 14349 14350 <desc> 14350 14351 Defines whether this frame buffer uses the virtual video card's memory 14351 buffer (guest VRAM) directly or not. See <link 14352 to="IFramebuffer::requestResize"/> for more information. 14352 buffer (guest VRAM) directly or not. 14353 14353 </desc> 14354 14354 </attribute> … … 14379 14379 </attribute> 14380 14380 14381 <attribute name="winId" type="long long" readonly="yes" >14381 <attribute name="winId" type="long long" readonly="yes" wsmap="suppress"> 14382 14382 <desc> 14383 14383 Platform-dependent identifier of the window where context of this … … 14386 14386 </attribute> 14387 14387 14388 <method name="lock" >14388 <method name="lock" wsmap="suppress"> 14389 14389 <desc> 14390 14390 Locks the frame buffer. … … 14394 14394 </method> 14395 14395 14396 <method name="unlock" >14396 <method name="unlock" wsmap="suppress"> 14397 14397 <desc> 14398 14398 Unlocks the frame buffer. … … 14402 14402 </method> 14403 14403 14404 <method name="notifyUpdate" >14404 <method name="notifyUpdate" wsmap="suppress"> 14405 14405 <desc> 14406 14406 Informs about an update. … … 14414 14414 </method> 14415 14415 14416 <method name="requestResize" >14416 <method name="requestResize" wsmap="suppress"> 14417 14417 <desc> 14418 14418 Requests a size and pixel format change. … … 14549 14549 </method> 14550 14550 14551 <method name="getVisibleRegion" >14551 <method name="getVisibleRegion" wsmap="suppress"> 14552 14552 <desc> 14553 14553 Returns the visible region of this frame buffer. … … 14582 14582 </method> 14583 14583 14584 <method name="setVisibleRegion" >14584 <method name="setVisibleRegion" wsmap="suppress"> 14585 14585 <desc> 14586 14586 Suggests a new visible region to this frame buffer. This region … … 14611 14611 </method> 14612 14612 14613 <method name="processVHWACommand" >14613 <method name="processVHWACommand" wsmap="suppress"> 14614 14614 <desc> 14615 14615 Posts a Video HW Acceleration Command to the frame buffer for processing. … … 14646 14646 name="IFramebufferOverlay" extends="IFramebuffer" 14647 14647 uuid="0bcc1c7e-e415-47d2-bfdb-e4c705fb0f47" 14648 wsmap=" suppress"14648 wsmap="managed" 14649 14649 > 14650 14650 <desc> … … 15941 15941 <attribute name="VM" type="long long" readonly="yes" wsmap="suppress"> 15942 15942 <desc> 15943 Gets the user-mode VM handle, with a reference. 15944 VMR3ReleaseUVM when done. 15943 Gets the user-mode VM handle, with a reference. Must be passed to 15944 VMR3ReleaseUVM when done. This is only for internal use while we carve 15945 15945 the details of this interface. 15946 15946 </desc> … … 18086 18086 </note> 18087 18087 <note> 18088 Data collection continues behind the scenes after call to @c 18089 queryMetricsData. The return data can be seen as the snapshot of the 18090 current state at the time of @c queryMetricsData call. The internally 18091 kept metric values are not cleared by the call. This makes possible 18092 querying different subsets of metrics or aggregates with subsequent 18093 calls. If periodic querying is needed it is highly suggested to query 18094 the values with @c interval*count period to avoid confusion. This way 18095 a completely new set of data values will be provided by each query. 18088 Data collection continues behind the scenes after call to 18089 @c queryMetricsData. The return data can be seen as the snapshot of 18090 the current state at the time of @c queryMetricsData call. The 18091 internally kept metric values are not cleared by the call. This 18092 allows querying different subsets of metrics or aggregates with 18093 subsequent calls. If periodic querying is needed it is highly 18094 suggested to query the values with @c interval*count period to avoid 18095 confusion. This way a completely new set of data values will be 18096 provided by each query. 18096 18097 </note> 18097 18098 </desc> … … 20972 20973 <attribute name="create" type="boolean" readonly="yes"/> 20973 20974 <attribute name="ipv6" type="boolean" readonly="yes"/> 20974 <attribute name="name" 20975 <attribute name="proto" 20976 <attribute name="hostIp" 20977 <attribute name="hostPort" 20978 <attribute name="guestIp" 20979 <attribute name="guestPort" 20975 <attribute name="name" type="wstring" readonly="yes"/> 20976 <attribute name="proto" type="NATProtocol" readonly="yes"/> 20977 <attribute name="hostIp" type="wstring" readonly="yes"/> 20978 <attribute name="hostPort" type="long" readonly="yes"/> 20979 <attribute name="guestIp" type="wstring" readonly="yes"/> 20980 <attribute name="guestPort" type="long" readonly="yes"/> 20980 20981 </interface> 20981 20982 -
trunk/src/VBox/Main/webservice/Makefile.kmk
r45614 r46478 337 337 VBOX_JWS_TARGET := $(PATH_TARGET)/vboxjws-gen 338 338 VBOX_JWS_GEN = $(VBOX_JWS_TARGET)/jwsgen 339 VBOX_JWS_GEN_RAWSRC = $(VBOX_JWS_GEN)/merged.file 339 340 VBOX_JWS_JDEST := $(VBOX_JWS_TARGET)/jdest 340 341 VBOX_JWSDOC_JDEST := $(VBOX_JWS_TARGET)/jdest-doc … … 368 369 ) 369 370 VBoxJWs-inst-jar_BLDDIRS += $(VBOX_JWS_GEN)/java 370 371 $(VBOX_JWS_GEN)/jwsglue.list: \ 371 VBoxJWs-inst-jar_GENERATEDSOURCES = $(addprefix $(VBoxJWs-inst-jar_BLDDIRS)/,$(VBoxJWS_VBOX_JWSGLUEFILES)) 372 373 VBoxJWSGlue_KMK = $(PATH_OUT)/vboxjwsglue.kmk 374 include $(VBoxJWSGlue_KMK) 375 376 $(VBoxJWSGlue_KMK).ts +| $(VBoxJWSGlue_KMK): $(VBOXWEB_IDL_SRC_ORIG) $(VBOX_GLUE_XSLT_DIR)/glue-java.xsl 377 $(call MSG_GENERATE,,$(VBoxJWSGlue_KMK)) 378 $(QUIET)$(RM) -f $@ 379 $(QUIET)$(MKDIR) -p $(@D) 380 $(QUIET)$(VBOX_XSLTPROC) \ 381 --stringparam filelistonly VBoxJWS_VBOX_JWSGLUEFILES \ 382 --stringparam G_vboxApiSuffix $(VBOX_API_SUFFIX) \ 383 --stringparam G_vboxGlueStyle jaxws \ 384 --stringparam G_vboxDirPrefix org/virtualbox$(VBOX_API_SUFFIX)/ \ 385 -o $@ $(VBOX_GLUE_XSLT_DIR)/glue-java.xsl $< 386 $(QUIET)$(CP) --changed -fv $@ $(VBoxJWSGlue_KMK) 387 388 $(VBOX_JWS_GEN_RAWSRC) \ 389 +| $(VBoxJWs-inst-jar_GENERATEDSOURCES): \ 372 390 $(VBOXWEB_IDL_SRC_ORIG) \ 373 391 $(VBOX_GLUE_XSLT_DIR)/glue-java.xsl \ 374 392 $(VBOX_FILESPLIT) \ 375 $(VBOXWEBSERVICE_WSDL) \ 376 $(VBOXWEB_WSDL) \ 377 | $(VBOX_JWS_GEN)/java/ 393 | $$(dir $$@) 378 394 $(call MSG_L1,Generating JAX-WS Java glue files from XIDL) 379 $(QUIET)$(RM) -f $( wildcard $(VBOX_JWS_GEN)/java/*/*/*.java) $(wildcard $(VBOX_JWS_GEN)/java/*/*/*/*.java)395 $(QUIET)$(RM) -f $(filter-out $(VBoxJWs-inst-jar_GENERATEDSOURCES),$(wildcard $(VBOX_JWS_GEN)/java/*/*/*.java)) 380 396 $(QUIET)$(VBOX_XSLTPROC) \ 397 --stringparam filelistonly "" \ 381 398 --stringparam G_vboxApiSuffix $(VBOX_API_SUFFIX) \ 382 399 --stringparam G_vboxGlueStyle jaxws \ 383 400 --stringparam G_vboxDirPrefix org/virtualbox$(VBOX_API_SUFFIX)/ \ 384 -o $(VBOX_JWS_GEN )/merged.file$(VBOX_GLUE_XSLT_DIR)/glue-java.xsl $<401 -o $(VBOX_JWS_GEN_RAWSRC) $(VBOX_GLUE_XSLT_DIR)/glue-java.xsl $< 385 402 $(QUIET)$(MKDIR) -p $(VBOX_JWS_GEN)/java/org/virtualbox$(VBOX_API_SUFFIX) 386 $(QUIET)$(VBOX_FILESPLIT) $(VBOX_JWS_GEN)/merged.file $(VBOX_JWS_GEN)/java 387 $(call MSG_GENERATE,,$@,JAX-WS for Java 1.6 bindings using $(VBOXWEBSERVICE_WSDL)) 403 $(QUIET)$(VBOX_FILESPLIT) $(VBOX_JWS_GEN_RAWSRC) $(VBOX_JWS_GEN)/java 404 405 ## @todo somehow also find out the authoritative list of files generated by 406 # wsimport (before running it), then we could rely on proper dependencies 407 # instead of creating jwsglue.list. Would allow avoiding a lot of unnecessary 408 # compilation with incremental builds, when almost nothing changed in the IDL 409 # file. Currently everything is recompiled if only one file is changed. 410 $(VBOX_JWS_GEN)/jwsglue.list.ts +| $(VBOX_JWS_GEN)/jwsglue.list: \ 411 $(VBOXWEB_IDL_SRC) \ 412 $(VBOX_FILESPLIT) \ 413 $(VBOXWEBSERVICE_WSDL) \ 414 $(VBOXWEB_WSDL) \ 415 $(VBoxJWs-inst-jar_GENERATEDSOURCES) \ 416 | $(VBOX_JWS_GEN)/java/ 417 $(QUIET)$(RM) -f $(wildcard $(VBOX_JWS_GEN)/java/*/*/*/*.java) 418 $(call MSG_GENERATE,,$(VBOX_JWS_GEN)/jwsglue.list,JAX-WS for Java 1.6 bindings using $(VBOXWEBSERVICE_WSDL)) 388 419 $(VBOX_WSIMPORT) -Xnocompile -p $(VBOX_JAVA_PACKAGE).jaxws -d $(VBOX_JWS_GEN)/java $(VBOXWEBSERVICE_WSDL) 389 $(QUIET)echo $(VB OX_JWS_GEN)/java/*/*/*.java> $@420 $(QUIET)echo $(VBoxJWs-inst-jar_GENERATEDSOURCES) > $@ 390 421 $(QUIET)echo $(VBOX_JWS_GEN)/java/*/*/*/*.java >> $@ 422 $(QUIET)$(CP) --changed -fv $@ $(VBOX_JWS_GEN)/jwsglue.list 391 423 392 424 $$(VBOX_JWS_JAR): $(VBOX_JWS_GEN)/jwsglue.list $(VBOXWEB_WSDL) $(VBOXWEBSERVICE_WSDL) $(VBOX_JWS_GEN)/MANIFEST.MF | $$(dir $$@) … … 501 533 VBOXWEB_METRICSAMPLE = $(VBOXWEB_SAMPLES_JAXWS_DIR)/metrictest.java 502 534 503 VBOXWEB_GLUE_JAVA_TMP = $(VBOXWEB_OUT_DIR)/glue-jaxws.java.tmp504 VBOXWEB_PATH_SDK_GLUE_JAVA = $(VBOX_PATH_SDK)/bindings/webservice/java/jax-ws/src505 VBOXWEB_JAVALIB = $(VBOX_PATH_SDK)/bindings/webservice/java/jax-ws/lib506 VBOXWEB_JAVA15_JAR = $(VBOXWEB_JAVALIB)/vboxws_java15.jar507 VBOXWEB_JAVA16_JAR = $(VBOXWEB_JAVALIB)/vboxws_java16.jar508 509 535 define find_java_files 510 536 $(shell find $(1) -name \*.java) … … 565 591 566 592 # generate WSDL from main XIDL file 567 $(VBOXWEB_WSDL): $(VBOXWEB_IDL_SRC) $(VBOX_PATH_WEBSERVICE)/websrv-wsdl.xsl $(VBOX_PATH_IDL)/typemap-shared.inc.xsl $(RECOMPILE_ON_MAKEFILE_CURRENT) ## @todo| $$(dir $$@)593 $(VBOXWEB_WSDL): $(VBOXWEB_IDL_SRC) $(VBOX_PATH_WEBSERVICE)/websrv-wsdl.xsl $(VBOX_PATH_IDL)/typemap-shared.inc.xsl $(RECOMPILE_ON_MAKEFILE_CURRENT) | $$(dir $$@) 568 594 $(call MSG_GENERATE,,$@,$(VBOXWEB_IDL_SRC) using websrv-wsdl.xsl) 569 595 $(QUIET)$(RM) -f -- $@ … … 571 597 $(QUIET)$(VBOX_XSLTPROC) $(VBOXWEB_XSLTPROC_VERBOSE) -o $@ $(VBOX_PATH_WEBSERVICE)/websrv-wsdl.xsl $< 572 598 573 $(VBOXWEBSERVICE_WSDL): $(VBOXWEB_IDL_SRC) $(VBOX_PATH_WEBSERVICE)/websrv-wsdl-service.xsl $(VBOX_PATH_IDL)/typemap-shared.inc.xsl $(RECOMPILE_ON_MAKEFILE_CURRENT) ## @todo| $$(dir $$@)599 $(VBOXWEBSERVICE_WSDL): $(VBOXWEB_IDL_SRC) $(VBOX_PATH_WEBSERVICE)/websrv-wsdl-service.xsl $(VBOX_PATH_IDL)/typemap-shared.inc.xsl $(RECOMPILE_ON_MAKEFILE_CURRENT) | $$(dir $$@) 574 600 $(call MSG_GENERATE,,$@,$(VBOXWEB_IDL_SRC) using websrv-wsdl-service.xsl) 575 601 $(QUIET)$(RM) -f -- $@ -
trunk/src/VBox/Main/webservice/vboxweb.cpp
r45367 r46478 1439 1439 1440 1440 #define DECODE_STR_MAX _1M 1441 void Base64DecodeByteArray(struct soap *soap, std::string& aStr, ComSafeArrayOut(BYTE, aData), const char *pszMethodName, IUnknown *pObj, const com::Guid &iid)1441 void Base64DecodeByteArray(struct soap *soap, const std::string& aStr, ComSafeArrayOut(BYTE, aData), const WSDLT_ID &idThis, const char *pszMethodName, IUnknown *pObj, const com::Guid &iid) 1442 1442 { 1443 1443 const char* pszStr = aStr.c_str(); … … 1447 1447 { 1448 1448 WebLog("Decode string too long.\n"); 1449 RaiseSoapRuntimeFault(soap, pszMethodName, E_INVALIDARG, pObj, iid);1449 RaiseSoapRuntimeFault(soap, idThis, pszMethodName, E_INVALIDARG, pObj, iid); 1450 1450 } 1451 1451 … … 1455 1455 { 1456 1456 WebLog("String Decoding Failed. Error code: %Rrc\n", rc); 1457 RaiseSoapRuntimeFault(soap, pszMethodName, E_INVALIDARG, pObj, iid);1457 RaiseSoapRuntimeFault(soap, idThis, pszMethodName, E_INVALIDARG, pObj, iid); 1458 1458 } 1459 1459 … … 1465 1465 * 1466 1466 * @param soap 1467 * @param idThis 1467 1468 * @param pcszMethodName 1468 1469 * @param apirc … … 1471 1472 */ 1472 1473 void RaiseSoapRuntimeFault(struct soap *soap, 1474 const WSDLT_ID &idThis, 1473 1475 const char *pcszMethodName, 1474 1476 HRESULT apirc, … … 1510 1512 // allocate our own soap fault struct 1511 1513 _vbox__RuntimeFault *ex = soap_new__vbox__RuntimeFault(soap, 1); 1512 // some old vbox methods return errors without setting an error in the error info, 1513 // so use the error info code if it's set and the HRESULT from the method otherwise 1514 if (S_OK == (ex->resultCode = info.getResultCode())) 1515 ex->resultCode = apirc; 1516 ex->text = ConvertComString(info.getText()); 1517 ex->component = ConvertComString(info.getComponent()); 1518 ex->interfaceID = ConvertComString(info.getInterfaceID()); 1514 ComPtr<IVirtualBoxErrorInfo> pVirtualBoxErrorInfo; 1515 info.getVirtualBoxErrorInfo(pVirtualBoxErrorInfo); 1516 ex->resultCode = apirc; 1517 ex->returnval = createOrFindRefFromComPtr(idThis, "IVirtualBoxErrorInfo", pVirtualBoxErrorInfo); 1519 1518 1520 1519 RaiseSoapFault(soap, -
trunk/src/VBox/Main/webservice/vboxweb.h
r44414 r46478 72 72 void RaiseSoapInvalidObjectFault(struct soap *soap, WSDLT_ID obj); 73 73 74 void RaiseSoapRuntimeFault(struct soap *soap, const char *pcszMethodName, HRESULT apirc, IUnknown *pObj, const com::Guid &iid);74 void RaiseSoapRuntimeFault(struct soap *soap, const WSDLT_ID &idThis, const char *pcszMethodName, HRESULT apirc, IUnknown *pObj, const com::Guid &iid); 75 75 76 76 /**************************************************************************** … … 86 86 std::string Base64EncodeByteArray(ComSafeArrayIn(BYTE, aData)); 87 87 88 void Base64DecodeByteArray(struct soap *soap, std::string& aStr, ComSafeArrayOut(BYTE, aData), const char *pszMethodName, IUnknown *pObj, const com::Guid &iid);88 void Base64DecodeByteArray(struct soap *soap, const std::string& aStr, ComSafeArrayOut(BYTE, aData), const WSDLT_ID &idThis, const char *pszMethodName, IUnknown *pObj, const com::Guid &iid); 89 89 /**************************************************************************** 90 90 * -
trunk/src/VBox/Main/webservice/websrv-cpp.xsl
r45483 r46478 274 274 275 275 <xsl:for-each select="//interface[@name=$structname]/attribute"> 276 <xsl:value-of select="concat(' // -- ', $structname, '.', @name)" /> 277 <xsl:call-template name="emitNewline" /> 278 <!-- recurse! --> 279 <xsl:call-template name="emitGetAttributeComCall"> 280 <xsl:with-param name="ifname" select="$structname" /> 281 <xsl:with-param name="object" select="'in'" /> 282 <xsl:with-param name="attrname" select="@name" /> 283 <xsl:with-param name="attrtype" select="@type" /> 284 <xsl:with-param name="callerprefix" select="concat('out', '.')" /> 285 </xsl:call-template> 286 <xsl:call-template name="emitNewline" /> 276 <xsl:if test="not(@wsmap = 'suppress')"> 277 <xsl:value-of select="concat(' // -- ', $structname, '.', @name)" /> 278 <xsl:call-template name="emitNewline" /> 279 <!-- recurse! --> 280 <xsl:call-template name="emitGetAttributeComCall"> 281 <xsl:with-param name="ifname" select="$structname" /> 282 <xsl:with-param name="object" select="'in'" /> 283 <xsl:with-param name="attrname" select="@name" /> 284 <xsl:with-param name="attrtype" select="@type" /> 285 <xsl:with-param name="callerprefix" select="concat('out', '.')" /> 286 </xsl:call-template> 287 <xsl:call-template name="emitNewline" /> 288 </xsl:if> 287 289 </xsl:for-each> 288 290 … … 550 552 <xsl:value-of select="concat('com::SafeArray<BYTE> comcall_',$name, ';')" /> 551 553 <xsl:call-template name="emitNewlineIndent8" /> 552 <xsl:value-of select="concat('Base64DecodeByteArray(soap, ',$structprefix,$name,', ComSafeArrayAsOutParam(comcall_',$name, '), "', $ifname, '::', $methodname, '", ', $object, ', COM_IIDOF(', $ifname, '));')" />554 <xsl:value-of select="concat('Base64DecodeByteArray(soap, ',$structprefix,$name,', ComSafeArrayAsOutParam(comcall_',$name, '), idThis, "', $ifname, '::', $methodname, '", ', $object, ', COM_IIDOF(', $ifname, '));')" /> 553 555 </xsl:when> 554 556 … … 857 859 <xsl:text>{</xsl:text> 858 860 <xsl:call-template name="emitNewlineIndent8" /> 859 <xsl:value-of select="concat(' RaiseSoapRuntimeFault(soap, "', $ifname, '::', $methodname,'", rc, ', $object, ', COM_IIDOF(', $ifname, '));')" />861 <xsl:value-of select="concat(' RaiseSoapRuntimeFault(soap, idThis, "', $ifname, '::', $methodname,'", rc, ', $object, ', COM_IIDOF(', $ifname, '));')" /> 860 862 <xsl:call-template name="emitNewlineIndent8" /> 861 863 <xsl:text> break;</xsl:text> … … 1278 1280 <xsl:choose> 1279 1281 <xsl:when test="( $attrtype=($G_setSuppressedInterfaces/@name) )"> 1280 <xsl:value-of select="concat('// Skipping attribute ', $attrtype, ' for it is of suppressed type ', $attrtype)" /> 1282 <xsl:value-of select="concat('// Skipping attribute ', $attrname, ' for it is of suppressed type ', $attrtype)" /> 1283 </xsl:when> 1284 <xsl:when test="@wsmap = 'suppress'"> 1285 <xsl:value-of select="concat('// Skipping attribute ', $attrname, ' for it is suppressed')" /> 1281 1286 </xsl:when> 1282 1287 <xsl:otherwise> … … 1326 1331 or (param[@mod='ptr'])" > 1327 1332 <xsl:comment><xsl:value-of select="concat('Skipping method ', $methodname, ' for it has parameters with suppressed types')" /></xsl:comment> 1333 </xsl:when> 1334 <xsl:when test="@wsmap = 'suppress'"> 1335 <xsl:comment><xsl:value-of select="concat('Skipping method ', $methodname, ' for it is suppressed')" /></xsl:comment> 1328 1336 </xsl:when> 1329 1337 <xsl:otherwise> -
trunk/src/VBox/Main/webservice/websrv-wsdl.xsl
r45483 r46478 164 164 <xsl:when test="//interface[@name=$type]"> 165 165 <!-- the type is one of our own interfaces: then it must have a wsmap attr --> 166 <xsl:variable name="wsmap" select=" (//interface[@name=$type]/@wsmap) | (//collection[@name=$type]/@wsmap)" />166 <xsl:variable name="wsmap" select="//interface[@name=$type]/@wsmap" /> 167 167 <xsl:choose> 168 168 <xsl:when test="not($wsmap)"> … … 186 186 </xsl:otherwise> 187 187 </xsl:choose> 188 </xsl:when>189 <xsl:when test="//collection[@name=$type]">190 <xsl:value-of select="concat('vbox:ArrayOf', //collection[@name=$type]/@type)" />191 188 </xsl:when> 192 189 <xsl:otherwise> … … 696 693 <xsl:choose> 697 694 <xsl:when test="( $attrtype=($G_setSuppressedInterfaces/@name) )"> 698 <xsl:comment><xsl:value-of select="concat('skipping attribute ', $attrtype, ' for it is of a suppressed type')" /></xsl:comment> 695 <xsl:comment><xsl:value-of select="concat('skipping attribute ', $attrname, ' for it is of a suppressed type')" /></xsl:comment> 696 </xsl:when> 697 <xsl:when test="@wsmap = 'suppress'"> 698 <xsl:comment><xsl:value-of select="concat('skipping attribute ', $attrname, ' for it is suppressed')" /></xsl:comment> 699 699 </xsl:when> 700 700 <xsl:otherwise> … … 737 737 <xsl:comment><xsl:value-of select="concat('skipping method ', $methodname, ' for it has parameters with suppressed types')" /></xsl:comment> 738 738 </xsl:when> 739 <xsl:when test="@wsmap = 'suppress'"> 740 <xsl:comment><xsl:value-of select="concat('skipping method ', $methodname, ' for it is suppressed')" /></xsl:comment> 741 </xsl:when> 739 742 <xsl:otherwise> 740 743 <!-- always emit a request message --> … … 778 781 <!-- skip this attribute if it has parameters of a type that has wsmap="suppress" --> 779 782 <xsl:when test="( $attrtype=($G_setSuppressedInterfaces/@name) )"> 780 <xsl:comment><xsl:value-of select="concat('skipping attribute ', $attrtype, ' for it is of a suppressed type')" /></xsl:comment> 783 <xsl:comment><xsl:value-of select="concat('skipping attribute ', $attrname, ' for it is of a suppressed type')" /></xsl:comment> 784 </xsl:when> 785 <xsl:when test="@wsmap = 'suppress'"> 786 <xsl:comment><xsl:value-of select="concat('skipping attribute ', $attrname, ' for it is suppressed')" /></xsl:comment> 781 787 </xsl:when> 782 788 <xsl:otherwise> … … 812 818 <xsl:comment><xsl:value-of select="concat('skipping method ', $methodname, ' for it has parameters with suppressed types')" /></xsl:comment> 813 819 </xsl:when> 820 <xsl:when test="@wsmap = 'suppress'"> 821 <xsl:comment><xsl:value-of select="concat('skipping method ', $methodname, ' for it is suppressed')" /></xsl:comment> 822 </xsl:when> 814 823 <xsl:otherwise> 815 824 <xsl:call-template name="emitInOutOperation"> … … 838 847 <xsl:choose> 839 848 <xsl:when test="( $attrtype=($G_setSuppressedInterfaces/@name) )"> 840 <xsl:comment><xsl:value-of select="concat('skipping attribute ', $attrtype, ' for it is of a suppressed type')" /></xsl:comment> 849 <xsl:comment><xsl:value-of select="concat('skipping attribute ', $attrname, ' for it is of a suppressed type')" /></xsl:comment> 850 </xsl:when> 851 <xsl:when test="@wsmap = 'suppress'"> 852 <xsl:comment><xsl:value-of select="concat('skipping attribute ', $attrname, ' for it is suppressed')" /></xsl:comment> 841 853 </xsl:when> 842 854 <xsl:otherwise> … … 871 883 <xsl:comment><xsl:value-of select="concat('skipping method ', $methodname, ' for it has parameters with suppressed types')" /></xsl:comment> 872 884 </xsl:when> 885 <xsl:when test="@wsmap = 'suppress'"> 886 <xsl:comment><xsl:value-of select="concat('skipping method ', $methodname, ' for it is suppressed')" /></xsl:comment> 887 </xsl:when> 873 888 <xsl:otherwise> 874 889 <xsl:call-template name="emitInOutOperation"> … … 1025 1040 </xsl:for-each> 1026 1041 1027 <!-- type-define all collections as arrays (complexTypes) -->1028 <xsl:comment>1029 ******************************************************1030 * collections as arrays1031 ******************************************************1032 </xsl:comment>1033 <xsl:for-each select="//collection">1034 <xsl:variable name="type" select="@type" />1035 <xsl:variable name="ifwsmap" select="//interface[@name=$type]/@wsmap" />1036 <xsl:comment><xsl:value-of select="concat(' collection ', @name, ' as array (wsmap: ', $ifwsmap, '): ')" /></xsl:comment>1037 <xsd:complexType>1038 <xsl:attribute name="name"><xsl:value-of select="concat('ArrayOf', @type)" /></xsl:attribute>1039 <xsd:sequence>1040 <xsl:choose>1041 <xsl:when test="($ifwsmap='managed') or ($ifwsmap='explicit')">1042 <xsd:element name="array" minOccurs="0" maxOccurs="unbounded">1043 <xsl:attribute name="type"><xsl:value-of select="$G_typeObjectRef" /></xsl:attribute>1044 </xsd:element>1045 </xsl:when>1046 <xsl:when test="$ifwsmap='struct'">1047 <xsd:element name="array" minOccurs="0" maxOccurs="unbounded">1048 <xsl:attribute name="type"><xsl:value-of select="concat('vbox:', @type)" /></xsl:attribute>1049 </xsd:element>1050 </xsl:when>1051 <xsl:otherwise>1052 <xsl:call-template name="fatalError">1053 <xsl:with-param name="msg" select="concat('library template: collection "', @name, '" uses interface with unsupported wsmap attribute value "', $ifwsmap, '"')" />1054 </xsl:call-template>1055 </xsl:otherwise>1056 </xsl:choose>1057 </xsd:sequence>1058 </xsd:complexType>1059 </xsl:for-each>1060 1061 1042 <!-- for WSDL 'document' style, we need to emit elements since we can't 1062 1043 refer to types in message parts as with RPC style --> … … 1086 1067 <xsl:when test="( $attrtype=($G_setSuppressedInterfaces/@name) )"> 1087 1068 <xsl:comment><xsl:value-of select="concat('skipping attribute ', $attrtype, ' for it is of a suppressed type')" /></xsl:comment> 1069 </xsl:when> 1070 <xsl:when test="@wsmap = 'suppress'"> 1071 <xsl:comment><xsl:value-of select="concat('skipping attribute ', $attrname, ' for it is suppressed')" /></xsl:comment> 1088 1072 </xsl:when> 1089 1073 <xsl:otherwise> … … 1136 1120 <xsl:comment><xsl:value-of select="concat('skipping method ', $methodname, ' for it has parameters with suppressed types')" /></xsl:comment> 1137 1121 </xsl:when> 1122 <xsl:when test="@wsmap = 'suppress'"> 1123 <xsl:comment><xsl:value-of select="concat('skipping method ', $methodname, ' for it is suppressed')" /></xsl:comment> 1124 </xsl:when> 1138 1125 <xsl:otherwise> 1139 1126 <!-- always emit a request message --> … … 1183 1170 <xsd:sequence> 1184 1171 <xsd:element name="resultCode" type="xsd:int" /> 1185 <xsd:element name="interfaceID" type="xsd:string" /> 1186 <xsd:element name="component" type="xsd:string" /> 1187 <xsd:element name="text" type="xsd:string" /> 1172 <xsd:element name="returnval"> 1173 <xsl:attribute name="type"> 1174 <xsl:value-of select="$G_typeObjectRef" /> 1175 </xsl:attribute> 1176 </xsd:element> 1188 1177 </xsd:sequence> 1189 1178 </xsd:complexType> -
trunk/src/VBox/Main/webservice/webtest.cpp
r40130 r46478 4 4 * functionality of VBoxManage for testing purposes. 5 5 * 6 * Copyright (C) 2006-201 2Oracle Corporation6 * Copyright (C) 2006-2013 Oracle Corporation 7 7 * 8 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 58 58 " - webtest setupmetrics <pcref>: IPerformanceCollector::setupMetrics()\n" 59 59 " - webtest querymetricsdata <pcref>: IPerformanceCollector::QueryMetricsData()\n" 60 " - IVirtualBoxErrorInfo:\n" 61 " - webtest errorinfo <eiref>: various IVirtualBoxErrorInfo getters\n" 60 62 " - All managed object references:\n" 61 63 " - webtest getif <ref>: report interface of object.\n" … … 76 78 77 79 int ap; 78 for (ap = 1; ap < =argc; ap++)80 for (ap = 1; ap < argc; ap++) 79 81 { 80 82 if (argv[ap][0] == '-') … … 85 87 { 86 88 ap++; 87 if (ap > argc)89 if (ap >= argc) 88 90 usage(1); 89 91 pcszArgEndpoint = argv[ap]; … … 453 455 } 454 456 } 457 else if (!strcmp(pcszMode, "errorinfo")) 458 { 459 if (argc < 2 + ap) 460 std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n"; 461 else 462 { 463 _vbox__IVirtualBoxErrorInfo_USCOREgetResultCode req; 464 req._USCOREthis = argv[ap + 1]; 465 _vbox__IVirtualBoxErrorInfo_USCOREgetResultCodeResponse resp; 466 if (!(soaprc = soap_call___vbox__IVirtualBoxErrorInfo_USCOREgetResultCode(&soap, 467 pcszArgEndpoint, 468 NULL, 469 &req, 470 &resp))) 471 { 472 std::cout << "ErrorInfo ResultCode: " << std::hex << resp.returnval << "\n"; 473 474 _vbox__IVirtualBoxErrorInfo_USCOREgetText req2; 475 req2._USCOREthis = argv[ap + 1]; 476 _vbox__IVirtualBoxErrorInfo_USCOREgetTextResponse resp2; 477 if (!(soaprc = soap_call___vbox__IVirtualBoxErrorInfo_USCOREgetText(&soap, 478 pcszArgEndpoint, 479 NULL, 480 &req2, 481 &resp2))) 482 { 483 std::cout << "ErrorInfo Text: " << resp2.returnval << "\n"; 484 485 _vbox__IVirtualBoxErrorInfo_USCOREgetNext req3; 486 req3._USCOREthis = argv[ap + 1]; 487 _vbox__IVirtualBoxErrorInfo_USCOREgetNextResponse resp3; 488 if (!(soaprc = soap_call___vbox__IVirtualBoxErrorInfo_USCOREgetNext(&soap, 489 pcszArgEndpoint, 490 NULL, 491 &req3, 492 &resp3))) 493 std::cout << "Next ErrorInfo: " << resp3.returnval << "\n"; 494 } 495 } 496 } 497 } 455 498 else if (!strcmp(pcszMode, "release")) 456 499 { … … 479 522 ) 480 523 { 524 // generic fault message whether the fault is known or not 525 std::cerr << "Generic fault message:\n"; 526 soap_print_fault(&soap, stderr); // display the SOAP fault message on the stderr stream 527 481 528 if (soap.fault->detail->vbox__InvalidObjectFault) 482 529 { 483 std::c out<< "Bad object ID: " << soap.fault->detail->vbox__InvalidObjectFault->badObjectID << "\n";530 std::cerr << "Bad object ID: " << soap.fault->detail->vbox__InvalidObjectFault->badObjectID << "\n"; 484 531 } 485 532 else if (soap.fault->detail->vbox__RuntimeFault) 486 533 { 487 std::cout << "Result code: 0x" << std::hex << soap.fault->detail->vbox__RuntimeFault->resultCode << "\n"; 488 std::cout << "Text: " << std::hex << soap.fault->detail->vbox__RuntimeFault->text << "\n"; 489 std::cout << "Component: " << std::hex << soap.fault->detail->vbox__RuntimeFault->component << "\n"; 490 std::cout << "Interface ID: " << std::hex << soap.fault->detail->vbox__RuntimeFault->interfaceID << "\n"; 491 } 492 else 493 { 494 // generic fault 495 std::cerr << "Generic fault message:\n"; 496 soap_print_fault(&soap, stderr); // display the SOAP fault message on the stderr stream 534 std::cerr << "Result code: 0x" << std::hex << soap.fault->detail->vbox__RuntimeFault->resultCode << "\n"; 535 std::cerr << "ErrorInfo: " << soap.fault->detail->vbox__RuntimeFault->returnval << "\n"; 497 536 } 498 537 } -
trunk/src/libs/xpcom18a4/java/Makefile.kmk
r41477 r46478 174 174 $(QUIET)$(RM) -f $(wildcard $(VBOX_JXPCOM_GEN)/java/glue/*.java) 175 175 $(QUIET)$(VBOX_XSLTPROC) \ 176 --stringparam filelistonly "" \ 176 177 --stringparam G_vboxApiSuffix $(VBOX_API_SUFFIX) \ 177 178 --stringparam G_vboxGlueStyle xpcom \ -
trunk/src/libs/xpcom18a4/java/src/nsJavaInterfaces.cpp
r38636 r46478 380 380 381 381 extern "C" NS_EXPORT jobject JNICALL 382 #ifdef VBOX 383 XPCOM_NATIVE2(getServiceManager) (JNIEnv *env, jobject) 384 #else 382 385 XPCOM_NATIVE(getServiceManager) (JNIEnv *env, jobject) 386 #endif 383 387 { 384 388 // Call XPCOM method -
trunk/src/libs/xpcom18a4/java/src/nsJavaWrapper.cpp
r38904 r46478 1496 1496 { 1497 1497 nsCOMPtr <nsIException> ex; 1498 rc = em->Get ExceptionFromProvider(r, NULL,getter_AddRefs (ex));1498 rc = em->GetCurrentException(getter_AddRefs (ex)); 1499 1499 if (NS_SUCCEEDED (rc) && ex) 1500 1500 { -
trunk/src/libs/xpcom18a4/java/src/org/mozilla/xpcom/XPCOMException.java
r29140 r46478 88 88 */ 89 89 public XPCOMException(long code, String message) { 90 super(message + " 90 super(message + " (0x" + Long.toHexString(code) + ")"); 91 91 this.errorcode = code; 92 92 } -
trunk/src/libs/xpcom18a4/java/tools/genjifaces.xsl
r44529 r46478 8 8 9 9 genjifaces.xsl: 10 XSLT stylesheet that generates Java XPCOM bridge int reface code from VirtualBox.xidl.11 12 Copyright (C) 2010-201 2Oracle Corporation10 XSLT stylesheet that generates Java XPCOM bridge interface code from VirtualBox.xidl. 11 12 Copyright (C) 2010-2013 Oracle Corporation 13 13 14 14 This file is part of VirtualBox Open Source Edition (OSE), as … … 68 68 <xsl:param name="name" /> 69 69 <xsl:text>/** 70 * Copyright (C) 2010 Oracle Corporation70 * Copyright (C) 2010-2013 Oracle Corporation 71 71 * 72 72 * This file is part of VirtualBox Open Source Edition (OSE), as … … 120 120 121 121 public nsISupports queryInterface(String arg1); 122 123 } 124 122 } 125 123 ]]></xsl:text> 126 124 … … 129 127 </xsl:call-template> 130 128 131 <xsl:call-template name="startFile">129 <xsl:call-template name="startFile"> 132 130 <xsl:with-param name="file" select="'nsIComponentManager.java'" /> 133 131 </xsl:call-template> … … 147 145 public nsISupports createInstanceByContractID(String arg1, nsISupports arg2, String arg3); 148 146 } 149 150 147 ]]></xsl:text> 151 148 … … 154 151 </xsl:call-template> 155 152 156 <xsl:call-template name="startFile">153 <xsl:call-template name="startFile"> 157 154 <xsl:with-param name="file" select="'nsIServiceManager.java'" /> 158 155 </xsl:call-template> … … 172 169 public boolean isServiceInstantiatedByContractID(String arg1, String arg2); 173 170 } 174 175 171 ]]></xsl:text> 176 172 … … 179 175 </xsl:call-template> 180 176 181 <xsl:call-template name="startFile"> 177 <xsl:call-template name="startFile"> 178 <xsl:with-param name="file" select="'nsIExceptionManager.java'" /> 179 </xsl:call-template> 180 181 <xsl:text><![CDATA[ 182 public interface nsIExceptionManager extends nsISupports 183 { 184 public static final String NS_IEXCEPTIONMANAGER_IID = 185 "{efc9d00b-231c-4feb-852c-ac017266a415}"; 186 187 public nsIException getCurrentException(); 188 } 189 ]]></xsl:text> 190 191 <xsl:call-template name="endFile"> 192 <xsl:with-param name="file" select="'nsISupports.java'" /> 193 </xsl:call-template> 194 195 <xsl:call-template name="startFile"> 196 <xsl:with-param name="file" select="'nsIExceptionService.java'" /> 197 </xsl:call-template> 198 199 <xsl:text><![CDATA[ 200 public interface nsIExceptionService extends nsIExceptionManager 201 { 202 public static final String NS_IEXCEPTIONSERVICE_IID = 203 "{35a88f54-f267-4414-92a7-191f6454ab52}"; 204 205 public nsIExceptionManager getCurrentExceptionManager(); 206 } 207 ]]></xsl:text> 208 209 <xsl:call-template name="endFile"> 210 <xsl:with-param name="file" select="'nsISupports.java'" /> 211 </xsl:call-template> 212 213 <xsl:call-template name="startFile"> 214 <xsl:with-param name="file" select="'nsIException.java'" /> 215 </xsl:call-template> 216 217 <xsl:text><![CDATA[ 218 public interface nsIException extends nsISupports 219 { 220 public static final String NS_IEXCEPTION_IID = 221 "{f3a8d3b4-c424-4edc-8bf6-8974c983ba78}"; 222 223 // No methods - placeholder 224 } 225 ]]></xsl:text> 226 227 <xsl:call-template name="endFile"> 228 <xsl:with-param name="file" select="'nsISupports.java'" /> 229 </xsl:call-template> 230 231 <xsl:call-template name="startFile"> 182 232 <xsl:with-param name="file" select="'nsIComponentRegistrar.java'" /> 183 233 </xsl:call-template> … … 191 241 // No methods - placeholder 192 242 } 193 194 243 ]]></xsl:text> 195 244 … … 199 248 200 249 201 <xsl:call-template name="startFile">250 <xsl:call-template name="startFile"> 202 251 <xsl:with-param name="file" select="'nsIFile.java'" /> 203 252 </xsl:call-template> … … 211 260 // No methods - placeholder 212 261 } 213 214 262 ]]></xsl:text> 215 263 … … 218 266 </xsl:call-template> 219 267 220 <xsl:call-template name="startFile">268 <xsl:call-template name="startFile"> 221 269 <xsl:with-param name="file" select="'nsILocalFile.java'" /> 222 270 </xsl:call-template> … … 230 278 // No methods - placeholder 231 279 } 232 233 280 ]]></xsl:text> 234 281
Note:
See TracChangeset
for help on using the changeset viewer.