Update to 0.0.4
authorMichal Novotny <minovotn@redhat.com>
Tue, 13 Dec 2011 15:39:15 +0000 (16:39 +0100)
committerMichal Novotny <minovotn@redhat.com>
Tue, 13 Dec 2011 15:39:15 +0000 (16:39 +0100)
This version includes:
 - Improved version of experimental VNC support
 - Several bugfixes

Signed-off-by: Michal Novotny <minovotn@redhat.com>

classes/language.php
classes/libvirt.php
configure.ac
init.php
lang/cs.php
lang/en.php
pages/details/screenshot.php
pages/new-vm.php
php-virt-control.spec

index 3e4bb58..042a89a 100644 (file)
                                        'net_forward_dev_empty_msg' => 'Leave empty for forwarding to any device/interface',
                                        'net_forward_dev_any' => 'any interface / device',
                                        'net_created' => 'Network has been created successfully',
+                                       'new-vm-created' => 'New virtual machine has been created successfully',
                                        'network-add-ok' => 'Network card has been successfully added to the guest. Changes will take effect on next domain startup.',
                                        'network-add-error' => 'Cannot add NIC to the guest',
                                        'network-generate-mac' => 'Generate new MAC address',
                                        'user_add_btn' => 'Add user',
                                        'user_edit_btn' => 'Edit user',
                                        'password_mismatch' => 'Password mismatch',
+                                       'screenshot-settings-auto-release' => 'Send automatic mouse pointer release event',
+                                       'screenshot-delay' => 'Delay has been changed to %d second(s)',
                                        );
 
                        $this->trans = $trans;
index d3f3557..31ae525 100644 (file)
                        return ($tmp) ? $tmp : $this->_set_last_error();
                }
 
-               function domain_send_pointer_event($domain, $x, $y, $clicked = 1) {
+               function domain_send_pointer_event($domain, $x, $y, $clicked = 1, $release = false) {
                        $dom = $this->get_domain_object($domain);
 
-                       $tmp = libvirt_domain_send_pointer_event($dom, $this->get_hostname(), $x, $y, $clicked, true);
+                       $tmp = libvirt_domain_send_pointer_event($dom, $this->get_hostname(), $x, $y, $clicked, $release);
                        return ($tmp) ? $tmp : $this->_set_last_error();
                }
 
index 897eec4..494bd3b 100644 (file)
@@ -1,4 +1,4 @@
-AC_INIT([php-virt-control], [0.0.3], [http://www.php-virt-control.org])
+AC_INIT([php-virt-control], [0.0.4], [http://www.php-virt-control.org])
 AM_INIT_AUTOMAKE([-Wall -Werror])
 AC_CONFIG_FILES([Makefile tools/Makefile])
 AC_OUTPUT
index 58dc0d9..2c37c58 100644 (file)
--- a/init.php
+++ b/init.php
@@ -5,7 +5,7 @@
        define('PHPVIRTCONTROL_VERSION', '0.0.3');
        define('PHPVIRTCONTROL_WEBSITE', 'http://www.php-virt-control.org');
        define('CONNECT_WITH_NULL_STRING', false);
-       define('ALLOW_EXPERIMENTAL_VNC', false);
+       define('ALLOW_EXPERIMENTAL_VNC', true);
 
        /* User permission defines */
        define('USER_PERMISSION_BASIC', 0x01);
index 19aa4bd..397bff7 100644 (file)
                                        'net_forward_dev_empty_msg' => 'Nevyplňujte pro možnost směrování na jakékoli zařízení',
                                        'net_forward_dev_any' => 'jakékoli zařízení',
                                        'net_created' => 'Síť byla vytvořena úspěšně',
+                                       'new-vm-created' => 'Virtuální stroj byl úspěšně vytvořen',
                                        'network-add-ok' => 'Síťová karta byla úspěšně přidána. Změny se projeví po dalším restartu domény.',
                                        'network-add-error' => 'Nelze přidat síťovou kartu do domény',
                                        'network-generate-mac' => 'Vygenerovat novou MAC adresu',
                                        'login_invalid' => 'Vaše přihlašovací údaje nejsou platné. Prosím zadejte správné údaje pro přihlášení',
                                        'logout' => 'Odhlásit se',
 
-                                        'users' => 'Uživatelé',
-                                        'create-new-user' => 'Vytvořit nového uživatele',
-                                        'user_add' => 'Přidat uživatele',
-                                        'user_edit' => 'Editovat uživatele',
-                                        'user_del' => 'Smazat uživatele',
-                                        'user_del_confirm' => 'Skutečně si přejete daného uživatele smazat?',
-                                        'user_added' => 'Uživatel byl úspěšně přidán',
-                                        'user_edited' => 'Uživatelské informace byly úspěšně upraveny',
-                                        'user_deleted' => 'Uživatel byl úspěšně smazán',
-                                        'confirm_password' => 'Potvrzení hesla',
-                                        'permissions' => 'Oprávnění',
+                                       'users' => 'Uživatelé',
+                                       'create-new-user' => 'Vytvořit nového uživatele',
+                                       'user_add' => 'Přidat uživatele',
+                                       'user_edit' => 'Editovat uživatele',
+                                       'user_del' => 'Smazat uživatele',
+                                       'user_del_confirm' => 'Skutečně si přejete daného uživatele smazat?',
+                                       'user_added' => 'Uživatel byl úspěšně přidán',
+                                       'user_edited' => 'Uživatelské informace byly úspěšně upraveny',
+                                       'user_deleted' => 'Uživatel byl úspěšně smazán',
+                                       'confirm_password' => 'Potvrzení hesla',
+                                       'permissions' => 'Oprávnění',
                                        'permission_basic' => 'Obecný přístup',
-                                        'permission_save_connection' => 'Uložit nastavení',
-                                        'permission_vm_create' => 'Vytvořit virtuální stroj',
-                                        'permission_vm_edit' => 'Upravit virtuální stroj',
-                                        'permission_vm_delete' => 'Smazat virtuální stroj',
-                                        'permission_network_create' => 'Vytvořit virtuální síť',
-                                        'permission_network_edit' => 'Upravit virtuální síť',
-                                        'permission_network_delete' => 'Smazat virtuální síť',
-                                        'permission_user_create' => 'Vytvořit nového uživatele',
-                                        'permission_user_edit' => 'Upravit stávajícího uživatele',
-                                        'permission_user_delete' => 'Smazat uživatele',
-                                        'user_add_btn' => 'Přidat uživatele',
-                                        'user_edit_btn' => 'Upravit uživatele',
+                                       'permission_save_connection' => 'Uložit nastavení',
+                                       'permission_vm_create' => 'Vytvořit virtuální stroj',
+                                       'permission_vm_edit' => 'Upravit virtuální stroj',
+                                       'permission_vm_delete' => 'Smazat virtuální stroj',
+                                       'permission_network_create' => 'Vytvořit virtuální síť',
+                                       'permission_network_edit' => 'Upravit virtuální síť',
+                                       'permission_network_delete' => 'Smazat virtuální síť',
+                                       'permission_user_create' => 'Vytvořit nového uživatele',
+                                       'permission_user_edit' => 'Upravit stávajícího uživatele',
+                                       'permission_user_delete' => 'Smazat uživatele',
+                                       'user_add_btn' => 'Přidat uživatele',
+                                       'user_edit_btn' => 'Upravit uživatele',
                                        'password_mismatch' => 'Heslo nebylo ověřeno',
+                                       'screenshot-settings-auto-release' => 'Automaticky poslat událost uvolnění tlačítka myši',
+                                       'screenshot-delay' => 'Interval byl změněn na %d sekund',
                                        );
 ?>
index 735bf14..4256514 100644 (file)
                                        'net_forward_dev_empty_msg' => 'Leave empty for forwarding to any device/interface',
                                        'net_forward_dev_any' => 'any interface / device',
                                        'net_created' => 'Network has been created successfully',
+                                       'new-vm-created' => 'New virtual machine has been created successfully',
                                        'network-add-ok' => 'Network card has been successfully added to the guest. Changes will take effect on next domain startup.',
                                        'network-add-error' => 'Cannot add NIC to the guest',
                                        'network-generate-mac' => 'Generate new MAC address',
                                        'login_invalid' => 'Your credentials are not valid. Please provide valid credentials',
                                        'logout' => 'Logout',
 
-                                        'users' => 'Users',
-                                        'create-new-user' => 'Create a new user',
-                                        'user_add' => 'Add user',
-                                        'user_edit' => 'Edit user',
-                                        'user_del' => 'Delete user',
-                                        'user_del_confirm' => 'Do you really want to delete selected user?',
-                                        'user_added' => 'User has been successfully added',
-                                        'user_edited' => 'User information has been successfully changed',
-                                        'user_deleted' => 'User has been succesfully deleted',
-                                        'confirm_password' => 'Confirm password',
-                                        'permissions' => 'Permissions',
+                                       'users' => 'Users',
+                                       'create-new-user' => 'Create a new user',
+                                       'user_add' => 'Add user',
+                                       'user_edit' => 'Edit user',
+                                       'user_del' => 'Delete user',
+                                       'user_del_confirm' => 'Do you really want to delete selected user?',
+                                       'user_added' => 'User has been successfully added',
+                                       'user_edited' => 'User information has been successfully changed',
+                                       'user_deleted' => 'User has been succesfully deleted',
+                                       'confirm_password' => 'Confirm password',
+                                       'permissions' => 'Permissions',
                                        'permission_basic' => 'Basic access',
-                                        'permission_save_connection' => 'Save connection',
-                                        'permission_vm_create' => 'Create virtual machine',
-                                        'permission_vm_edit' => 'Edit virtual machine',
-                                        'permission_vm_delete' => 'Delete virtual machine',
-                                        'permission_network_create' => 'Create virtual network',
-                                        'permission_network_edit' => 'Edit virtual network',
-                                        'permission_network_delete' => 'Delete virtual network',
-                                        'permission_user_create' => 'Create user',
-                                        'permission_user_edit' => 'Edit user',
-                                        'permission_user_delete' => 'Delete user',
-                                        'user_add_btn' => 'Add user',
-                                        'user_edit_btn' => 'Edit user',
+                                       'permission_save_connection' => 'Save connection',
+                                       'permission_vm_create' => 'Create virtual machine',
+                                       'permission_vm_edit' => 'Edit virtual machine',
+                                       'permission_vm_delete' => 'Delete virtual machine',
+                                       'permission_network_create' => 'Create virtual network',
+                                       'permission_network_edit' => 'Edit virtual network',
+                                       'permission_network_delete' => 'Delete virtual network',
+                                       'permission_user_create' => 'Create user',
+                                       'permission_user_edit' => 'Edit user',
+                                       'permission_user_delete' => 'Delete user',
+                                       'user_add_btn' => 'Add user',
+                                       'user_edit_btn' => 'Edit user',
                                        'password_mismatch' => 'Password mismatch',
+                                       'screenshot-settings-auto-release' => 'Send automatic mouse pointer release event',
+                                       'screenshot-delay' => 'Delay has been changed to %d second(s)',
                                        );
 ?>
index 83c588c..02f1039 100644 (file)
@@ -1,4 +1,6 @@
 <?php
+  define('MOUSE_POINTER_DEBUG', false);
+
   if (array_key_exists('get-dims', $_GET)) {
     ob_end_clean();
     $tmp = $lv->domain_get_screen_dimensions($name);
@@ -10,7 +12,7 @@
 
   if (array_key_exists('x', $_GET)) {
     ob_end_clean();
-    $tmp = $lv->domain_send_pointer_event($name, $_GET['x'], $_GET['y'], 1, true);
+    $tmp = $lv->domain_send_pointer_event($name, $_GET['x'], $_GET['y'], (int)$_GET['bm'], $_GET['autorelease'] ? true : false);
     if (!$tmp)
        die( 'Error occured while sending pointer event: '.$lv->get_last_error() );
 
@@ -26,7 +28,7 @@
     die('ok');
   }
 
-  $interval = array_key_exists('interval', $_POST) ? $_POST['interval'] : 5;
+  $interval = array_key_exists('interval', $_POST) ? $_POST['interval'] : 1;
   $msg = '';
   if (!$lv->domain_is_running($name))
     $msg = 'Domain is not running';
     if (ALLOW_EXPERIMENTAL_VNC):
 ?>
        var IE = document.all ? true : false;
-       if (!IE) document.captureEvents(Event.MOUSEMOVE)
+       if (!IE) document.captureEvents(Event.MOUSEMOVE || Event.CLICK)
        document.onmousemove = getMouseXY;
+       document.onmousedown = handleMouseClick;
 
+       var gButtonMask = 0;
        var tempX = 0;
        var tempY = 0;
        var screenshotX = 0;
@@ -94,6 +98,7 @@
        var imgY = 0;
        var maxWidth = <?php echo $dims['width'] ?>;
        var maxHeight = <?php echo $dims['height'] ?>;
+       document['onkeypress'] = detectEvent;
        var req_data = false;
 
        function get_time() {
                document.getElementById('ajax-msg').innerHTML = msg;
        }
 
-        function write_error2(msg) {
-                document.getElementById('ajax-msg2').innerHTML = msg;
+        function write_message(msg) {
+                document.getElementById('ajax-msg').innerHTML = msg;
         }
 
        function parseAndSetKeyBoxWidth(data) {
+               if (tmp.indexOf('x') == -1)
+                       return;
+
                tmp = data.split(':')[1];
                data = tmp.split('x');
                maxWidth = parseInt(data[0]);
        }
 
        function sendMouse() {
-               data = request_data('<?php echo $_SERVER['REQUEST_URI'] ?>&x='+imgX+'&y='+imgY);
+<?php
+       if (MOUSE_POINTER_DEBUG):
+?>
+                write_message('Click intercepted on position x = '+imgX+', y = '+imgY+', debugging => screenshot at ['+
+                                screenshotX+', '+screenshotY+'], temp at ['+tempX+', '+tempY+'], buttonMask = '+gButtonMask);
+<?php
+       endif;
+?>
+               autorelease = (document.getElementById('setting-autorelease').checked) ? 1 : 0;
+               data = request_data('<?php echo $_SERVER['REQUEST_URI'] ?>&x='+imgX+'&y='+imgY+'&bm='+gButtonMask+'&autorelease='+autorelease);
                if (!data)
                        return;
 
 
                if (data) {
                        update_screenshot();
-                       write_error(data);
+                       write_message(data);
                }
                else
-                       write_error('Cannot process the request.');
+                       write_message('Cannot process the request.');
+       }
+
+       function handleMouseClick(e) {
+               var rightclick;
+               if (!e) var e = window.event;
+               if (e.which) rightclick = (e.which == 3);
+               else if (e.button) rightclick = (e.button == 2);
+
+               /* For VNC */
+               if (rightclick == true)
+                       gButtonMask = 4;
+               else
+                       gButtonMask = 1;
+
+               if ((imgX <= 0) || (imgY <= 0))
+                       return;
+
+               sendMouse();
        }
 
        function getDimensions() {
                if (tempX < 0) tempX = 0;
                if (tempY < 0) tempY = 0;
 
-               if ((screenshotX == 0) || (screenshotY == 0)) {
-                       setTimeout("getScreenshotPos()", 500);
-                       return false;
-               }
-
                imgX = tempX - screenshotX;
-               imgY = tempY - screenshotY;
+               imgY = maxHeight - (tempY - screenshotY);
+
+<?php
+       if (MOUSE_POINTER_DEBUG):
+?>
+               write_message('Debug: x = '+imgX+', y = '+imgY+', debugging => screenshot at ['+
+                               screenshotX+', '+screenshotY+'], temp at ['+tempX+', '+tempY+']');
+<?php
+       endif;
+?>
 
                if (((imgX > maxWidth) || (imgY > maxHeight))
                        || (imgX < 0) || (imgY < 0)) {
                }
        }
 
-       function screenshotClick() {
-               if ((imgX <= 0) || (imgY <= 0))
-                       return;
-
-               sendMouse();
-       }
-
         function send_keys(hitEnter) {
-               write_error('');
+               write_message('');
                val = document.getElementById('keys').value;
                document.getElementById('keys').value = '';
                if (hitEnter)
                        if (ret == false)
                                ret = 'Cannot process Ajax request';
 
-                       write_error('Error: '+ret);
+                       if (ret.indexOf('ok:') == -1)
+                               write_message('Error: '+ret);
                }
                else
                        update_screenshot();
        }
 
+        function detectEvent(e) {
+                if ((imgX <= 0) || (imgY <= 0))
+                        return true;
+
+                var evt = e || window.event;
+                //alert(evt.type+' -> '+evt.keyCode+' ?= '+evt.charCode);
+
+               var sChar=String.fromCharCode( evt.charCode );
+               ret = request_data('<?php echo $_SERVER['REQUEST_URI'] ?>&send_keys='+sChar);
+               if (ret != 'ok') {
+                       if (ret == false)
+                               ret = 'Cannot process Ajax request';
+                       if (ret.indexOf('ok:') == -1)
+                               write_message('Error: '+ret);
+               }
+               else
+                       update_screenshot();
+        }
+
 <?php
     endif;
 ?>
                 src = src + '&date=' + encodeURIComponent(cDate) + encodeURIComponent(cDate + Math.floor(Math.random() * 11));
                 document.getElementById('screenshot').src = src;
 
+<?php
+    if (ALLOW_EXPERIMENTAL_VNC):
+?>
                getDimensions();
-
+<?php
+    endif;
+?>
                /* Update time specified *after* the screenshot loaded successfully */
                document.getElementById('screenshot').onload = function() {
                        timerID = setTimeout("update_screenshot()", delay);
+
+                       setTimeout("getScreenshotPos()", 250);
                }
         }
 
         function change_interval() {
                 val = document.getElementById('interval').value;
                 delay = val * 1000;
+               alert('<?php echo str_replace('%d', "'+val+'", $lang->get('screenshot-delay')); ?>');
                 alert('Delay has been changed to '+val+' second(s)');
 
                 update_screenshot();
       <div class="value">
        <input type="text" name="interval" value="<?php echo $interval ?>" id="interval">
        <input type="button" value=" <?php echo $lang->get('change') ?> " onclick="change_interval()">
+<?php
+    if (ALLOW_EXPERIMENTAL_VNC):
+?>
+       <input type="checkbox" id="setting-autorelease" value="1" checked="checked" /> <?php echo $lang->get('screenshot-settings-auto-release'); ?>
+<?php
+    endif;
+?>
       </div>
       <div class="nl" />
     </div>
 
     <div class="section"><?php echo $lang->get('dom_screenshot') ?></div>
 
-    <div class="screenshot"><img id="screenshot" src="<?php echo $_SERVER['REQUEST_URI'] ?>&amp;data=png" onclick="screenshotClick()"><br />
+    <div class="screenshot"><img id="screenshot" src="<?php echo $_SERVER['REQUEST_URI'] ?>&amp;data=png" oncontextmenu="return false;" /><br />
 <?php
     if (ALLOW_EXPERIMENTAL_VNC):
 ?>
       </td>
     </tr>
     </div>
-    <div id="ajax-msg2">xxx</div>
+    <div id="ajax-msg2"></div>
 <?php
     endif;
     endif;
index 6f38c73..70c82bf 100644 (file)
@@ -43,7 +43,7 @@
                $msg = $lv->get_last_error();
        else {
                $skip = true;
-               $msg = 'Domain has been created successfully';
+               $msg = $lang->get('new-vm-created');
        }
   }
 
index 326e09c..2cefce8 100644 (file)
@@ -48,6 +48,7 @@ EOF
 %install
 rm -rf %{buildroot}
 mkdir -p %{buildroot}/%{_datadir}/%{name}
+mkdir -p %{buildroot}/%{_datadir}/%{name}/logs
 mkdir -p %{buildroot}/%{_sysconfdir}/httpd/conf.d/
 mkdir -p %{buildroot}/%{_sysconfdir}/%{name}
 
@@ -57,11 +58,13 @@ gcc -o %{buildroot}/%{_bindir}/apache-key-copy tools/apache-key-copy.c
 install -d -m0755 %{buildroot}%{_datadir}/%{name}/
 cp -af *.php %{buildroot}%{_datadir}/%{name}/
 cp -af *.css %{buildroot}%{_datadir}/%{name}/
-cp -af classes/ data/ graphics/ lang/ logs/ pages/ %{buildroot}%{_datadir}/%{name}/
+cp -af classes/ data/ graphics/ lang/ pages/ %{buildroot}%{_datadir}/%{name}/
+cp -af logs/README %{buildroot}%{_datadir}/%{name}/logs
 cp -af config/connection.php %{buildroot}/%{_sysconfdir}/%{name}/connection.php
 cp -af config/mysql-connection.php %{buildroot}/%{_sysconfdir}/%{name}/mysql-connection.php
 install -Dp -m0644 auth/50-org.libvirt-remote-access.pkla %{buildroot}/etc/polkit-1/localauthority/50-local.d/50-org.libvirt-remote-access.pkla
 install -Dp -m0644 php-virt-control.conf %{buildroot}%{_sysconfdir}/httpd/conf.d/php-virt-control.conf
+chmod 777 %{buildroot}%{_datadir}/%{name}/logs
 
 %clean
 rm -rf %{buildroot}