summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--phpvirtualbox/endpoints/lib/vboxconnector.php75
-rw-r--r--phpvirtualbox/js/dialogs.js2
-rw-r--r--phpvirtualbox/js/phpvirtualbox.js2
-rw-r--r--phpvirtualbox/js/utils.js13
-rw-r--r--phpvirtualbox/panes/settingsGeneral.html78
-rw-r--r--phpvirtualbox/panes/tabVMSnapshots.html4
7 files changed, 95 insertions, 80 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d8fe4fa
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/.project
diff --git a/phpvirtualbox/endpoints/lib/vboxconnector.php b/phpvirtualbox/endpoints/lib/vboxconnector.php
index 44fc22c..212c58d 100644
--- a/phpvirtualbox/endpoints/lib/vboxconnector.php
+++ b/phpvirtualbox/endpoints/lib/vboxconnector.php
@@ -624,7 +624,8 @@ class vboxconnector {
$machine->releaseRemote();
} catch (Exception $e) {
- // pass
+ // pass
+ $this->errors[] = $e;
}
break;
@@ -723,7 +724,7 @@ class vboxconnector {
// Create and register event listener
$listener = $this->vbox->eventSource->createListener();
- $this->vbox->eventSource->registerListener($listener,array('MachineEvent','SnapshotEvent','OnMediumRegistered','OnExtraDataChanged'), false);
+ $this->vbox->eventSource->registerListener($listener,array('MachineEvent', 'SnapshotEvent', 'OnMediumRegistered', 'OnExtraDataChanged', 'OnSnapshotRestored'), false);
// Add to event listener list
$this->persistentRequest['vboxEventListeners']['vbox'] = array(
@@ -755,7 +756,7 @@ class vboxconnector {
// Convert to parent class
$parentClass = 'I'.substr($data['eventType'],2).'Event';
- $eventDataObject = new $parentClass($this->client, $event->handle);
+ $eventDataObject = new $parentClass($this->client, $event->handle);
// Dedup ID is at least listener key ('vbox' or machine id) and event type
$data['dedupId'] = $listenerKey.'-'.$data['eventType'];
@@ -2368,8 +2369,10 @@ class vboxconnector {
try {
// Force web call to keep session open.
- $this->session = new ISession($this->client, $this->persistentRequest['sessionHandle']);
- if((string)$this->session->state) {}
+ if($this->persistentRequest['sessionHandle']) {
+ $this->session = new ISession($this->client, $this->persistentRequest['sessionHandle']);
+ if((string)$this->session->state) {}
+ }
/* @var $progress IProgress */
$progress = new IProgress($this->client, $args['progress']);
@@ -2489,15 +2492,14 @@ class vboxconnector {
// Close session and logoff
try {
- if(!$this->session)
- $this->session = $this->websessionManager->getSessionObject($this->vbox->handle);
-
- if($this->session && (string)$this->session->state != 'Unlocked') {
- $this->session->unlockMachine();
+ if($this->session->handle) {
+ if((string)$this->session->state != 'Unlocked') {
+ $this->session->unlockMachine();
+ }
+ $this->session->releaseRemote();
+ unset($this->session);
}
- $this->session->releaseRemote();
- unset($this->session);
} catch (Exception $e) {
$this->errors[] = $e;
@@ -3291,7 +3293,7 @@ class vboxconnector {
if($state == 'saveState') {
$progress = $this->session->machine->saveState();
} else {
- $progress = $this->session->console->$state();
+ $progress = $this->session->console->$state();
}
if(!$progress->handle) {
@@ -4700,7 +4702,7 @@ class vboxconnector {
$machine->lockMachine($this->session->handle, ((string)$machine->sessionState == 'Unlocked' ? 'Write' : 'Shared'));
/* @var $progress IProgress */
- $progress = $this->session->machine->takeSnapshot($args['name'], $args['description']);
+ list($progress, $snapshotId) = $this->session->machine->takeSnapshot($args['name'], $args['description']);
// Does an exception exist?
try {
@@ -4717,8 +4719,6 @@ class vboxconnector {
} catch (Exception $e) {
- $this->errors[] = $e;
-
if(!$progress->handle && $this->session->handle) {
try{$this->session->unlockMachine();$this->session=null;}catch(Exception $e){}
}
@@ -4886,11 +4886,11 @@ class vboxconnector {
// Connect to vboxwebsrv
$this->connect();
- $m = $this->vbox->openMedium($args['medium'],'HardDisk');
+ $m = $this->vbox->openMedium($args['medium'], 'HardDisk', 'ReadWrite');
/* @var $progress IProgress */
- $progress = $m->changeEncryption($args['old_pw'],
- $args['cipher'], $args['new_pw'], $args['new_pwid']);
+ $progress = $m->changeEncryption($args['old_password'],
+ $args['cipher'], $args['password'], $args['id']);
// Does an exception exist?
try {
@@ -4927,7 +4927,7 @@ class vboxconnector {
// Connect to vboxwebsrv
$this->connect();
- $m = $this->vbox->openMedium($args['medium'],'HardDisk');
+ $m = $this->vbox->openMedium($args['medium'], 'HardDisk');
/* @var $progress IProgress */
$progress = $m->resize($args['bytes']);
@@ -4965,7 +4965,7 @@ class vboxconnector {
$mid = $target->id;
/* @var $src IMedium */
- $src = $this->vbox->openMedium($args['src'],'HardDisk');
+ $src = $this->vbox->openMedium($args['src'], 'HardDisk');
$type = array(($args['type'] == 'fixed' ? 'Fixed' : 'Standard'));
if($args['split']) $type[] = 'VmdkSplit2G';
@@ -5003,7 +5003,7 @@ class vboxconnector {
$this->connect();
/* @var $m IMedium */
- $m = $this->vbox->openMedium($args['medium'],'HardDisk');
+ $m = $this->vbox->openMedium($args['medium'], 'HardDisk');
$m->type = $args['type'];
$m->releaseRemote();
@@ -5067,7 +5067,7 @@ class vboxconnector {
$this->connect();
/* @var $m IMedium */
- $m = $this->vbox->openMedium($args['path'],$args['type'],'ReadWrite',false);
+ $m = $this->vbox->openMedium($args['path'], $args['type'], 'ReadWrite', false);
$mid = $m->id;
$m->releaseRemote();
@@ -5470,13 +5470,14 @@ class vboxconnector {
if((string)$m->deviceType == 'HardDisk') {
try {
list($id, $cipher) = $m->getEncryptionSettings();
- $encryptionSettings = array(
- 'id' => $id,
- 'cipher' => $cipher,
- );
+ if($id) {
+ $encryptionSettings = array(
+ 'id' => $id,
+ 'cipher' => $cipher,
+ );
+ }
} catch (Exception $e) {
// Pass. Encryption is not configured
- $encryptionSettings = array();
}
}
@@ -5515,9 +5516,11 @@ class vboxconnector {
*/
private function _util_progressStore(&$progress) {
- /* Store vbox handle */
+ /* Store vbox and session handle */
$this->persistentRequest['vboxHandle'] = $this->vbox->handle;
- $this->persistentRequest['sessionHandle'] = $this->session->handle;
+ if($this->session->handle) {
+ $this->persistentRequest['sessionHandle'] = $this->session->handle;
+ }
/* Store server if multiple servers are configured */
if(@is_array($this->settings->servers) && count($this->settings->servers) > 1)
@@ -5559,12 +5562,12 @@ class vboxconnector {
$scs = array();
$scts = array('LsiLogic',
-'BusLogic',
-'IntelAhci',
-'PIIX4',
-'ICH6',
-'I82078',
-'USB');
+ 'BusLogic',
+ 'IntelAhci',
+ 'PIIX4',
+ 'ICH6',
+ 'I82078',
+ 'USB');
foreach($scts as $t) {
$scs[$t] = $sp->getStorageControllerHotplugCapable($t);
diff --git a/phpvirtualbox/js/dialogs.js b/phpvirtualbox/js/dialogs.js
index 7c3f433..1989d6a 100644
--- a/phpvirtualbox/js/dialogs.js
+++ b/phpvirtualbox/js/dialogs.js
@@ -1341,7 +1341,7 @@ function vboxVMsettingsDialog(vm,pane) {
if(media[i].deviceType != 'HardDisk') continue;
var id = vm.name;
- var oldpw = null;
+ var oldpw = "";
var cipher = null;
// Check for existing encryption setting
diff --git a/phpvirtualbox/js/phpvirtualbox.js b/phpvirtualbox/js/phpvirtualbox.js
index cec8a79..c6628ab 100644
--- a/phpvirtualbox/js/phpvirtualbox.js
+++ b/phpvirtualbox/js/phpvirtualbox.js
@@ -2286,7 +2286,7 @@ var vboxMedia = {
* Get encryption settings for medium
*/
getEncryptionSettings: function(m) {
- if(m.encryptionSettings) {
+ if(m && m.encryptionSettings) {
return m.encryptionSettings
}
return null;
diff --git a/phpvirtualbox/js/utils.js b/phpvirtualbox/js/utils.js
index 666cd9c..b5a8262 100644
--- a/phpvirtualbox/js/utils.js
+++ b/phpvirtualbox/js/utils.js
@@ -327,26 +327,21 @@ function vboxMachineStateIcon(state)
{
case "PoweredOff": strIcon = "state_powered_off_16px.png"; break;
case "Saved": strIcon = "state_saved_16px.png"; break;
- case "Teleported": strIcon = strNoIcon; break;
+ case "Saving": strIcon = "state_saving_16px.png"; break;
+ case "Snapshotting": strIcon = "snapshot_offline_16px.png"; break;
case "LiveSnapshotting": strIcon = "snapshot_online_16px.png"; break;
case "Aborted": strIcon = "state_aborted_16px.png"; break;
case "Running": strIcon = "state_running_16px.png"; break;
case "Paused": strIcon = "state_paused_16px.png"; break;
case "Stuck": strIcon = "state_stuck_16px.png"; break;
- case "Teleporting": strIcon = strNoIcon; break;
- case "Starting": strIcon = strNoIcon; break;
- case "Stopping": strIcon = strNoIcon; break;
case "Saving": strIcon = "state_discarding_16px.png"; break;
case "Restoring": strIcon = "vm_settings_16px.png"; break;
- case "TeleportingPausedVM": strIcon = strNoIcon; break;
- case "TeleportingIn": strIcon = strNoIcon; break;
case "RestoringSnapshot": strIcon = "discard_cur_state_16px.png"; break;
case "DeletingSnapshot": strIcon = "state_discarding_16px.png"; break;
- case "SettingUp": strIcon = strNoIcon; break;
case "Hosting" : strIcon = "vm_settings_16px.png"; break;
case "Inaccessible": strIcon = "state_aborted_16px.png"; break;
default:
- break;
+ strIcon = strNoIcon;
}
return strIcon;
@@ -720,7 +715,7 @@ function vboxProgress(prequest,callback,icon,title,target,blocking) {
'progress' : prequest.progress,
'catcherrs' : prequest.catcherrs
};
-
+
// Blocking creates a dialog
if(!blocking) {
diff --git a/phpvirtualbox/panes/settingsGeneral.html b/phpvirtualbox/panes/settingsGeneral.html
index 656adce..38631c6 100644
--- a/phpvirtualbox/panes/settingsGeneral.html
+++ b/phpvirtualbox/panes/settingsGeneral.html
@@ -340,32 +340,41 @@ $('#vboxSettingsDialog').on('dataLoaded', function(){
$(document.images["vboxOSTypeImg"]).removeClass('vboxDisabled');
}
- // Encrypted media
- var encIds = vboxMedia.getEncryptedMediaIds(
- vboxStorage.getAttachedBaseMedia($('#vboxSettingsDialog').data('vboxMachineData'))
- );
-
- var lastCipher = null;
- var uniqueCiphers = true;
- for(var i = 0; i < encIds.length; i++) {
- if(lastCipher && (lastCipher != encIds[i].cipher)) {
- uniqueCiphers = false;
- break;
+ /*
+ * This is a poor way to determine extpack installation status, but the web service can't access IExtPackManager :(
+ */
+ if(!($('#vboxSettingsDialog').data('vboxMachineData').VRDEServer && $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.VRDEExtPack)) {
+ $('#vboxSettingsTabGeneralEncryption').parent().tabs('disable', 3);
+ } else {
+ $('#vboxSettingsTabGeneralEncryption').parent().tabs('enable', 3);
+
+ // Encrypted media
+ var encIds = vboxMedia.getEncryptedMediaIds(
+ vboxStorage.getAttachedBaseMedia($('#vboxSettingsDialog').data('vboxMachineData'))
+ );
+
+ var lastCipher = null;
+ var uniqueCiphers = true;
+ for(var i = 0; i < encIds.length; i++) {
+ if(lastCipher && (lastCipher != encIds[i].cipher)) {
+ uniqueCiphers = false;
+ break;
+ }
+ lastCipher = encIds[i].cipher;
}
- lastCipher = encIds[i].cipher;
- }
+ $(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked', (encIds.length))
+ .triggerHandler('click');
- $(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked', (encIds.length))
- .triggerHandler('click');
-
- if(uniqueCiphers) {
- $(document.forms['frmVboxSettings'].vboxSettingsTabGeneralEncryptionCipher).val(lastCipher);
+ if(uniqueCiphers) {
+ $(document.forms['frmVboxSettings'].vboxSettingsTabGeneralEncryptionCipher).val(lastCipher);
+ }
+
+ $('#vboxSettingsDialog').data('vboxEncSettings', {
+ enabled: $(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked'),
+ uniqueCiphers: $(document.forms['frmVboxSettings'].vboxSettingsTabGeneralEncryptionCipher).val()
+ });
}
-
- $('#vboxSettingsDialog').data('vboxEncSettings', {
- enabled: $(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked'),
- uniqueCiphers: $(document.forms['frmVboxSettings'].vboxSettingsTabGeneralEncryptionCipher).val()
- });
+
/* Change general settings onSave() */
}).on('save',function(){
@@ -404,14 +413,21 @@ $('#vboxSettingsDialog').on('dataLoaded', function(){
$('#vboxSettingsDialog').data('vboxMachineData').customIcon = $(document.forms['frmVboxSettings'].vboxSettingsGeneralIcon).val();
var encSettings = $('#vboxSettingsDialog').data('vboxEncSettings');
- var encSettingsChanged = (encSettings.enabled != $(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked')) ||
- (encSettings.uniqueCiphers != $(document.forms['frmVboxSettings'].vboxSettingsTabGeneralEncryptionCipher).val()) ||
- $(document.forms['frmVboxSettings'].vboxGeneralEncryptionPassword).val().length > 0;
-
- $('#vboxSettingsDialog').data('vboxEncSettingsChanged', encSettingsChanged);
- $('#vboxSettingsDialog').data('vboxEncEnabled', $(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked'));
- $('#vboxSettingsDialog').data('vboxEncCipher', $(document.forms['frmVboxSettings'].vboxSettingsTabGeneralEncryptionCipher).val());
- $('#vboxSettingsDialog').data('vboxEncPw', $(document.forms['frmVboxSettings'].vboxGeneralEncryptionPassword).val());
+ if(encSettings) {
+ var encSettingsChanged = (encSettings.enabled != $(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked')) ||
+ (encSettings.uniqueCiphers != $(document.forms['frmVboxSettings'].vboxSettingsTabGeneralEncryptionCipher).val()) ||
+ $(document.forms['frmVboxSettings'].vboxGeneralEncryptionPassword).val().length > 0;
+
+ if(!encSettings.enabled && !$(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked'))
+ encSettingsChanged = false;
+
+ $('#vboxSettingsDialog').data('vboxEncSettingsChanged', encSettingsChanged);
+ $('#vboxSettingsDialog').data('vboxEncEnabled', $(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked'));
+ $('#vboxSettingsDialog').data('vboxEncCipher', $(document.forms['frmVboxSettings'].vboxSettingsTabGeneralEncryptionCipher).val());
+ $('#vboxSettingsDialog').data('vboxEncPw', $(document.forms['frmVboxSettings'].vboxGeneralEncryptionPassword).val());
+ } else {
+ $('#vboxSettingsDialog').data('vboxEncSettingsChanged', false);
+ }
});
diff --git a/phpvirtualbox/panes/tabVMSnapshots.html b/phpvirtualbox/panes/tabVMSnapshots.html
index 47f07b2..8c071c7 100644
--- a/phpvirtualbox/panes/tabVMSnapshots.html
+++ b/phpvirtualbox/panes/tabVMSnapshots.html
@@ -149,7 +149,7 @@ var vboxSnapshotButtons = [
// callback passed to click()? else Refresh vm list
if(typeof callback == 'function') { callback(pres); }
- },'progress_snapshot_create_90px.png',trans('Take a snapshot of the current virtual machine state','VBoxSnapshotsWgt'),
+ },'progress_snapshot_create_90px.png', trans('Take a snapshot of the current virtual machine state','VBoxSnapshotsWgt'),
vm.name);
} else {
@@ -190,7 +190,7 @@ var vboxSnapshotButtons = [
};
buttons[trans('Cancel','QIMessageBox')] = function() { $(this).dialog('close'); };
- $('#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')});
+ $('#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')});
}
},