@@ -624,7 +624,8 @@ public function remote_getEvents($args) {
624624 $ machine ->releaseRemote ();
625625
626626 } catch (Exception $ e ) {
627- // pass
627+ // pass
628+ $ this ->errors [] = $ e ;
628629 }
629630 break ;
630631
@@ -723,7 +724,7 @@ public function remote_subscribeEvents($args) {
723724
724725 // Create and register event listener
725726 $ listener = $ this ->vbox ->eventSource ->createListener ();
726- $ this ->vbox ->eventSource ->registerListener ($ listener ,array ('MachineEvent ' ,'SnapshotEvent ' ,'OnMediumRegistered ' ,'OnExtraDataChanged ' ), false );
727+ $ this ->vbox ->eventSource ->registerListener ($ listener ,array ('MachineEvent ' , 'SnapshotEvent ' , 'OnMediumRegistered ' , 'OnExtraDataChanged ' , ' OnSnapshotRestored ' ), false );
727728
728729 // Add to event listener list
729730 $ this ->persistentRequest ['vboxEventListeners ' ]['vbox ' ] = array (
@@ -755,7 +756,7 @@ private function _getEventData($event, $listenerKey) {
755756
756757 // Convert to parent class
757758 $ parentClass = 'I ' .substr ($ data ['eventType ' ],2 ).'Event ' ;
758- $ eventDataObject = new $ parentClass ($ this ->client , $ event ->handle );
759+ $ eventDataObject = new $ parentClass ($ this ->client , $ event ->handle );
759760
760761 // Dedup ID is at least listener key ('vbox' or machine id) and event type
761762 $ data ['dedupId ' ] = $ listenerKey .'- ' .$ data ['eventType ' ];
@@ -2368,8 +2369,10 @@ public function remote_progressGet($args) {
23682369 try {
23692370
23702371 // Force web call to keep session open.
2371- $ this ->session = new ISession ($ this ->client , $ this ->persistentRequest ['sessionHandle ' ]);
2372- if ((string )$ this ->session ->state ) {}
2372+ if ($ this ->persistentRequest ['sessionHandle ' ]) {
2373+ $ this ->session = new ISession ($ this ->client , $ this ->persistentRequest ['sessionHandle ' ]);
2374+ if ((string )$ this ->session ->state ) {}
2375+ }
23732376
23742377 /* @var $progress IProgress */
23752378 $ progress = new IProgress ($ this ->client , $ args ['progress ' ]);
@@ -2489,15 +2492,14 @@ private function _util_progressDestroy($pop) {
24892492 // Close session and logoff
24902493 try {
24912494
2492- if (!$ this ->session )
2493- $ this ->session = $ this ->websessionManager ->getSessionObject ($ this ->vbox ->handle );
2494-
2495- if ($ this ->session && (string )$ this ->session ->state != 'Unlocked ' ) {
2496- $ this ->session ->unlockMachine ();
2495+ if ($ this ->session ->handle ) {
2496+ if ((string )$ this ->session ->state != 'Unlocked ' ) {
2497+ $ this ->session ->unlockMachine ();
2498+ }
2499+ $ this ->session ->releaseRemote ();
2500+ unset($ this ->session );
24972501 }
24982502
2499- $ this ->session ->releaseRemote ();
2500- unset($ this ->session );
25012503
25022504 } catch (Exception $ e ) {
25032505 $ this ->errors [] = $ e ;
@@ -3291,7 +3293,7 @@ public function remote_machineSetState($args) {
32913293 if ($ state == 'saveState ' ) {
32923294 $ progress = $ this ->session ->machine ->saveState ();
32933295 } else {
3294- $ progress = $ this ->session ->console ->$ state ();
3296+ $ progress = $ this ->session ->console ->$ state ();
32953297 }
32963298
32973299 if (!$ progress ->handle ) {
@@ -4700,7 +4702,7 @@ public function remote_snapshotTake($args) {
47004702 $ machine ->lockMachine ($ this ->session ->handle , ((string )$ machine ->sessionState == 'Unlocked ' ? 'Write ' : 'Shared ' ));
47014703
47024704 /* @var $progress IProgress */
4703- $ progress = $ this ->session ->machine ->takeSnapshot ($ args ['name ' ], $ args ['description ' ]);
4705+ list ( $ progress, $ snapshotId ) = $ this ->session ->machine ->takeSnapshot ($ args ['name ' ], $ args ['description ' ]);
47044706
47054707 // Does an exception exist?
47064708 try {
@@ -4717,8 +4719,6 @@ public function remote_snapshotTake($args) {
47174719
47184720 } catch (Exception $ e ) {
47194721
4720- $ this ->errors [] = $ e ;
4721-
47224722 if (!$ progress ->handle && $ this ->session ->handle ) {
47234723 try {$ this ->session ->unlockMachine ();$ this ->session =null ;}catch (Exception $ e ){}
47244724 }
@@ -4886,11 +4886,11 @@ public function remote_mediumChangeEncryption($args) {
48864886 // Connect to vboxwebsrv
48874887 $ this ->connect ();
48884888
4889- $ m = $ this ->vbox ->openMedium ($ args ['medium ' ],'HardDisk ' );
4889+ $ m = $ this ->vbox ->openMedium ($ args ['medium ' ], 'HardDisk ' , ' ReadWrite ' );
48904890
48914891 /* @var $progress IProgress */
4892- $ progress = $ m ->changeEncryption ($ args ['old_pw ' ],
4893- $ args ['cipher ' ], $ args ['new_pw ' ], $ args ['new_pwid ' ]);
4892+ $ progress = $ m ->changeEncryption ($ args ['old_password ' ],
4893+ $ args ['cipher ' ], $ args ['password ' ], $ args ['id ' ]);
48944894
48954895 // Does an exception exist?
48964896 try {
@@ -4927,7 +4927,7 @@ public function remote_mediumResize($args) {
49274927 // Connect to vboxwebsrv
49284928 $ this ->connect ();
49294929
4930- $ m = $ this ->vbox ->openMedium ($ args ['medium ' ],'HardDisk ' );
4930+ $ m = $ this ->vbox ->openMedium ($ args ['medium ' ], 'HardDisk ' );
49314931
49324932 /* @var $progress IProgress */
49334933 $ progress = $ m ->resize ($ args ['bytes ' ]);
@@ -4965,7 +4965,7 @@ public function remote_mediumCloneTo($args) {
49654965 $ mid = $ target ->id ;
49664966
49674967 /* @var $src IMedium */
4968- $ src = $ this ->vbox ->openMedium ($ args ['src ' ],'HardDisk ' );
4968+ $ src = $ this ->vbox ->openMedium ($ args ['src ' ], 'HardDisk ' );
49694969
49704970 $ type = array (($ args ['type ' ] == 'fixed ' ? 'Fixed ' : 'Standard ' ));
49714971 if ($ args ['split ' ]) $ type [] = 'VmdkSplit2G ' ;
@@ -5003,7 +5003,7 @@ public function remote_mediumSetType($args) {
50035003 $ this ->connect ();
50045004
50055005 /* @var $m IMedium */
5006- $ m = $ this ->vbox ->openMedium ($ args ['medium ' ],'HardDisk ' );
5006+ $ m = $ this ->vbox ->openMedium ($ args ['medium ' ], 'HardDisk ' );
50075007 $ m ->type = $ args ['type ' ];
50085008 $ m ->releaseRemote ();
50095009
@@ -5067,7 +5067,7 @@ public function remote_mediumAdd($args) {
50675067 $ this ->connect ();
50685068
50695069 /* @var $m IMedium */
5070- $ m = $ this ->vbox ->openMedium ($ args ['path ' ],$ args ['type ' ],'ReadWrite ' ,false );
5070+ $ m = $ this ->vbox ->openMedium ($ args ['path ' ], $ args ['type ' ], 'ReadWrite ' , false );
50715071
50725072 $ mid = $ m ->id ;
50735073 $ m ->releaseRemote ();
@@ -5470,13 +5470,14 @@ private function _mediumGetDetails(&$m) {
54705470 if ((string )$ m ->deviceType == 'HardDisk ' ) {
54715471 try {
54725472 list ($ id , $ cipher ) = $ m ->getEncryptionSettings ();
5473- $ encryptionSettings = array (
5474- 'id ' => $ id ,
5475- 'cipher ' => $ cipher ,
5476- );
5473+ if ($ id ) {
5474+ $ encryptionSettings = array (
5475+ 'id ' => $ id ,
5476+ 'cipher ' => $ cipher ,
5477+ );
5478+ }
54775479 } catch (Exception $ e ) {
54785480 // Pass. Encryption is not configured
5479- $ encryptionSettings = array ();
54805481 }
54815482
54825483 }
@@ -5515,9 +5516,11 @@ private function _mediumGetDetails(&$m) {
55155516 */
55165517 private function _util_progressStore (&$ progress ) {
55175518
5518- /* Store vbox handle */
5519+ /* Store vbox and session handle */
55195520 $ this ->persistentRequest ['vboxHandle ' ] = $ this ->vbox ->handle ;
5520- $ this ->persistentRequest ['sessionHandle ' ] = $ this ->session ->handle ;
5521+ if ($ this ->session ->handle ) {
5522+ $ this ->persistentRequest ['sessionHandle ' ] = $ this ->session ->handle ;
5523+ }
55215524
55225525 /* Store server if multiple servers are configured */
55235526 if (@is_array ($ this ->settings ->servers ) && count ($ this ->settings ->servers ) > 1 )
@@ -5559,12 +5562,12 @@ public function remote_vboxSystemPropertiesGet($args) {
55595562 $ scs = array ();
55605563
55615564 $ scts = array ('LsiLogic ' ,
5562- 'BusLogic ' ,
5563- 'IntelAhci ' ,
5564- 'PIIX4 ' ,
5565- 'ICH6 ' ,
5566- 'I82078 ' ,
5567- 'USB ' );
5565+ 'BusLogic ' ,
5566+ 'IntelAhci ' ,
5567+ 'PIIX4 ' ,
5568+ 'ICH6 ' ,
5569+ 'I82078 ' ,
5570+ 'USB ' );
55685571
55695572 foreach ($ scts as $ t ) {
55705573 $ scs [$ t ] = $ sp ->getStorageControllerHotplugCapable ($ t );
0 commit comments