Skip to content

Commit 76a6453

Browse files
author
Ian Moore
committed
Bug fixes for 5.0
1 parent f8aa009 commit 76a6453

File tree

7 files changed

+95
-80
lines changed

7 files changed

+95
-80
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.project

Diff for: phpvirtualbox/endpoints/lib/vboxconnector.php

+39-36
Original file line numberDiff line numberDiff line change
@@ -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);

Diff for: phpvirtualbox/js/dialogs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,7 @@ function vboxVMsettingsDialog(vm,pane) {
13411341
if(media[i].deviceType != 'HardDisk') continue;
13421342

13431343
var id = vm.name;
1344-
var oldpw = null;
1344+
var oldpw = "";
13451345
var cipher = null;
13461346

13471347
// Check for existing encryption setting

Diff for: phpvirtualbox/js/phpvirtualbox.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2286,7 +2286,7 @@ var vboxMedia = {
22862286
* Get encryption settings for medium
22872287
*/
22882288
getEncryptionSettings: function(m) {
2289-
if(m.encryptionSettings) {
2289+
if(m && m.encryptionSettings) {
22902290
return m.encryptionSettings
22912291
}
22922292
return null;

Diff for: phpvirtualbox/js/utils.js

+4-9
Original file line numberDiff line numberDiff line change
@@ -327,26 +327,21 @@ function vboxMachineStateIcon(state)
327327
{
328328
case "PoweredOff": strIcon = "state_powered_off_16px.png"; break;
329329
case "Saved": strIcon = "state_saved_16px.png"; break;
330-
case "Teleported": strIcon = strNoIcon; break;
330+
case "Saving": strIcon = "state_saving_16px.png"; break;
331+
case "Snapshotting": strIcon = "snapshot_offline_16px.png"; break;
331332
case "LiveSnapshotting": strIcon = "snapshot_online_16px.png"; break;
332333
case "Aborted": strIcon = "state_aborted_16px.png"; break;
333334
case "Running": strIcon = "state_running_16px.png"; break;
334335
case "Paused": strIcon = "state_paused_16px.png"; break;
335336
case "Stuck": strIcon = "state_stuck_16px.png"; break;
336-
case "Teleporting": strIcon = strNoIcon; break;
337-
case "Starting": strIcon = strNoIcon; break;
338-
case "Stopping": strIcon = strNoIcon; break;
339337
case "Saving": strIcon = "state_discarding_16px.png"; break;
340338
case "Restoring": strIcon = "vm_settings_16px.png"; break;
341-
case "TeleportingPausedVM": strIcon = strNoIcon; break;
342-
case "TeleportingIn": strIcon = strNoIcon; break;
343339
case "RestoringSnapshot": strIcon = "discard_cur_state_16px.png"; break;
344340
case "DeletingSnapshot": strIcon = "state_discarding_16px.png"; break;
345-
case "SettingUp": strIcon = strNoIcon; break;
346341
case "Hosting" : strIcon = "vm_settings_16px.png"; break;
347342
case "Inaccessible": strIcon = "state_aborted_16px.png"; break;
348343
default:
349-
break;
344+
strIcon = strNoIcon;
350345
}
351346

352347
return strIcon;
@@ -720,7 +715,7 @@ function vboxProgress(prequest,callback,icon,title,target,blocking) {
720715
'progress' : prequest.progress,
721716
'catcherrs' : prequest.catcherrs
722717
};
723-
718+
724719
// Blocking creates a dialog
725720
if(!blocking) {
726721

Diff for: phpvirtualbox/panes/settingsGeneral.html

+47-31
Original file line numberDiff line numberDiff line change
@@ -340,32 +340,41 @@
340340
$(document.images["vboxOSTypeImg"]).removeClass('vboxDisabled');
341341
}
342342

343-
// Encrypted media
344-
var encIds = vboxMedia.getEncryptedMediaIds(
345-
vboxStorage.getAttachedBaseMedia($('#vboxSettingsDialog').data('vboxMachineData'))
346-
);
347-
348-
var lastCipher = null;
349-
var uniqueCiphers = true;
350-
for(var i = 0; i < encIds.length; i++) {
351-
if(lastCipher && (lastCipher != encIds[i].cipher)) {
352-
uniqueCiphers = false;
353-
break;
343+
/*
344+
* This is a poor way to determine extpack installation status, but the web service can't access IExtPackManager :(
345+
*/
346+
if(!($('#vboxSettingsDialog').data('vboxMachineData').VRDEServer && $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.VRDEExtPack)) {
347+
$('#vboxSettingsTabGeneralEncryption').parent().tabs('disable', 3);
348+
} else {
349+
$('#vboxSettingsTabGeneralEncryption').parent().tabs('enable', 3);
350+
351+
// Encrypted media
352+
var encIds = vboxMedia.getEncryptedMediaIds(
353+
vboxStorage.getAttachedBaseMedia($('#vboxSettingsDialog').data('vboxMachineData'))
354+
);
355+
356+
var lastCipher = null;
357+
var uniqueCiphers = true;
358+
for(var i = 0; i < encIds.length; i++) {
359+
if(lastCipher && (lastCipher != encIds[i].cipher)) {
360+
uniqueCiphers = false;
361+
break;
362+
}
363+
lastCipher = encIds[i].cipher;
354364
}
355-
lastCipher = encIds[i].cipher;
356-
}
365+
$(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked', (encIds.length))
366+
.triggerHandler('click');
357367

358-
$(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked', (encIds.length))
359-
.triggerHandler('click');
360-
361-
if(uniqueCiphers) {
362-
$(document.forms['frmVboxSettings'].vboxSettingsTabGeneralEncryptionCipher).val(lastCipher);
368+
if(uniqueCiphers) {
369+
$(document.forms['frmVboxSettings'].vboxSettingsTabGeneralEncryptionCipher).val(lastCipher);
370+
}
371+
372+
$('#vboxSettingsDialog').data('vboxEncSettings', {
373+
enabled: $(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked'),
374+
uniqueCiphers: $(document.forms['frmVboxSettings'].vboxSettingsTabGeneralEncryptionCipher).val()
375+
});
363376
}
364-
365-
$('#vboxSettingsDialog').data('vboxEncSettings', {
366-
enabled: $(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked'),
367-
uniqueCiphers: $(document.forms['frmVboxSettings'].vboxSettingsTabGeneralEncryptionCipher).val()
368-
});
377+
369378

370379
/* Change general settings onSave() */
371380
}).on('save',function(){
@@ -404,14 +413,21 @@
404413
$('#vboxSettingsDialog').data('vboxMachineData').customIcon = $(document.forms['frmVboxSettings'].vboxSettingsGeneralIcon).val();
405414

406415
var encSettings = $('#vboxSettingsDialog').data('vboxEncSettings');
407-
var encSettingsChanged = (encSettings.enabled != $(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked')) ||
408-
(encSettings.uniqueCiphers != $(document.forms['frmVboxSettings'].vboxSettingsTabGeneralEncryptionCipher).val()) ||
409-
$(document.forms['frmVboxSettings'].vboxGeneralEncryptionPassword).val().length > 0;
410-
411-
$('#vboxSettingsDialog').data('vboxEncSettingsChanged', encSettingsChanged);
412-
$('#vboxSettingsDialog').data('vboxEncEnabled', $(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked'));
413-
$('#vboxSettingsDialog').data('vboxEncCipher', $(document.forms['frmVboxSettings'].vboxSettingsTabGeneralEncryptionCipher).val());
414-
$('#vboxSettingsDialog').data('vboxEncPw', $(document.forms['frmVboxSettings'].vboxGeneralEncryptionPassword).val());
416+
if(encSettings) {
417+
var encSettingsChanged = (encSettings.enabled != $(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked')) ||
418+
(encSettings.uniqueCiphers != $(document.forms['frmVboxSettings'].vboxSettingsTabGeneralEncryptionCipher).val()) ||
419+
$(document.forms['frmVboxSettings'].vboxGeneralEncryptionPassword).val().length > 0;
420+
421+
if(!encSettings.enabled && !$(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked'))
422+
encSettingsChanged = false;
423+
424+
$('#vboxSettingsDialog').data('vboxEncSettingsChanged', encSettingsChanged);
425+
$('#vboxSettingsDialog').data('vboxEncEnabled', $(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked'));
426+
$('#vboxSettingsDialog').data('vboxEncCipher', $(document.forms['frmVboxSettings'].vboxSettingsTabGeneralEncryptionCipher).val());
427+
$('#vboxSettingsDialog').data('vboxEncPw', $(document.forms['frmVboxSettings'].vboxGeneralEncryptionPassword).val());
428+
} else {
429+
$('#vboxSettingsDialog').data('vboxEncSettingsChanged', false);
430+
}
415431

416432
});
417433

Diff for: phpvirtualbox/panes/tabVMSnapshots.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
// callback passed to click()? else Refresh vm list
150150
if(typeof callback == 'function') { callback(pres); }
151151

152-
},'progress_snapshot_create_90px.png',trans('Take a snapshot of the current virtual machine state','VBoxSnapshotsWgt'),
152+
},'progress_snapshot_create_90px.png', trans('Take a snapshot of the current virtual machine state','VBoxSnapshotsWgt'),
153153
vm.name);
154154

155155
} else {
@@ -190,7 +190,7 @@
190190
};
191191
buttons[trans('Cancel','QIMessageBox')] = function() { $(this).dialog('close'); };
192192

193-
$('#vboxSnapshotNew').dialog({'closeOnEscape':false,'width':'400px','height':'auto','buttons':buttons,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/take_snapshot_16px.png" class="vboxDialogTitleIcon" height="16" width="16" /> ' + trans('Take Snapshot of Virtual Machine','VBoxTakeSnapshotDlg')});
193+
$('#vboxSnapshotNew').dialog({'closeOnEscape':false,'width':'400px','height':'auto','buttons':buttons,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/snapshot_take_16px.png" class="vboxDialogTitleIcon" height="16" width="16" /> ' + trans('Take Snapshot of Virtual Machine','VBoxTakeSnapshotDlg')});
194194

195195
}
196196
},

0 commit comments

Comments
 (0)