diff --git a/Makefile b/Makefile index cab057c..05993cd 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,7 @@ res: pyuic4 -o qubesmanager/ui_restoredlg.py restoredlg.ui pyuic4 -o qubesmanager/ui_backupdlg.py backupdlg.ui pyuic4 -o qubesmanager/ui_globalsettingsdlg.py globalsettingsdlg.ui + pyuic4 -o qubesmanager/ui_logdlg.py logdlg.ui update-repo-current: ln -f $(RPMS_DIR)/x86_64/qubes-manager-*$(VERSION)*.rpm ../yum/current-release/current/dom0/rpm/ diff --git a/logdlg.ui b/logdlg.ui new file mode 100644 index 0000000..6e8bbe2 --- /dev/null +++ b/logdlg.ui @@ -0,0 +1,122 @@ + + + LogDialog + + + + 0 + 0 + 750 + 450 + + + + Dialog + + + + + + Copy Dom0 clipboard to Qubes clipboard + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + Qt::TabFocus + + + Copy clipboard to Qubes clipboard + + + + :/copy.png:/copy.png + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + + + + + + + + + + + buttonBox + rejected() + LogDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + buttonBox + accepted() + LogDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + diff --git a/qubesmanager/log_dialog.py b/qubesmanager/log_dialog.py new file mode 100644 index 0000000..a694fda --- /dev/null +++ b/qubesmanager/log_dialog.py @@ -0,0 +1,89 @@ +#!/usr/bin/python2.6 +# +# The Qubes OS Project, http://www.qubes-os.org +# +# Copyright (C) 2012 Agnieszka Kostrzewa +# Copyright (C) 2012 Marek Marczykowski +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# + +import sys +import os +import fcntl +from PyQt4.QtCore import * +from PyQt4.QtGui import * + +from qubes.qubes import QubesException + +import qubesmanager.resources_rc + +from ui_logdlg import * + + +class LogDialog(Ui_LogDialog, QDialog): + + def __init__(self, app, log_path, parent=None): + super(LogDialog, self).__init__(parent) + + self.app = app + self.log_path = log_path + + self.setupUi(self) + self.setWindowTitle(log_path) + + self.connect(self.copy_to_qubes_clipboard, SIGNAL("clicked()"), self.copy_to_qubes_clipboard_triggered) + + self.__init_log_text__() + + def __init_log_text__(self): + log = open(self.log_path) + text = log.read() + log.close() + self.log_text.setText(text) + + + def copy_to_qubes_clipboard_triggered(self): + clipboard = self.app.clipboard().text() + copy_text_to_qubes_clipboard(clipboard) + +########################COPY TEXT TO QUBES CLIPBOARD + +def copy_text_to_qubes_clipboard(text): + #inter-appviewer lock + + try: + fd = os.open("/var/run/qubes/appviewer.lock", os.O_RDWR|os.O_CREAT, 0600); + fcntl.flock(fd, fcntl.LOCK_EX); + except IOError: + QMessageBox.warning (None, "Warning!", "Error while accessing Qubes clipboard!") + return + + qubes_clipboard = open("/var/run/qubes/qubes_clipboard.bin", 'w') + qubes_clipboard.write(text) + qubes_clipboard.close() + + qubes_clip_source = open("/var/run/qubes/qubes_clipboard.bin.source", 'w') + qubes_clip_source.write("dom0") + qubes_clip_source.close() + + try: + fcntl.flock(fd, fcntl.LOCK_UN) + os.close(fd) + except IOError: + QMessageBox.warning (None, "Warning!", "Error while writing to Qubes clipboard!") + return + diff --git a/qubesmanager/main.py b/qubesmanager/main.py index 5b1fac2..9df1a82 100755 --- a/qubesmanager/main.py +++ b/qubesmanager/main.py @@ -44,6 +44,7 @@ from settings import VMSettingsWindow from restore import RestoreVMsWindow from backup import BackupVMsWindow from global_settings import GlobalSettingsWindow +from log_dialog import LogDialog, copy_text_to_qubes_clipboard from thread_monitor import * from pyinotify import WatchManager, Notifier, ThreadedNotifier, EventsCodes, ProcessEvent @@ -1514,29 +1515,7 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow): @pyqtSlot(name='on_action_copy_clipboard_triggered') def action_copy_clipboard_triggered(self): clipboard = app.clipboard().text() - - #inter-appviewer lock - try: - fd = os.open("/var/run/qubes/appviewer.lock", os.O_RDWR|os.O_CREAT, 0600); - fcntl.flock(fd, fcntl.LOCK_EX); - except IOError: - QMessageBox.warning (None, "Warning!", "Error while accessing Qubes clipboard!") - return - - qubes_clipboard = open("/var/run/qubes/qubes_clipboard.bin", 'w') - qubes_clipboard.write(clipboard) - qubes_clipboard.close() - - qubes_clip_source = open("/var/run/qubes/qubes_clipboard.bin.source", 'w') - qubes_clip_source.write("dom0") - qubes_clip_source.close() - - try: - fcntl.flock(fd, fcntl.LOCK_UN) - os.close(fd) - except IOError: - QMessageBox.warning (None, "Warning!", "Error while writing to Qubes clipboard!") - return + copy_text_to_qubes_clipboard(clipboard) def createPopupMenu(self): @@ -1620,9 +1599,8 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow): @pyqtSlot('QAction *') def show_log(self, action): log = str(action.data().toString()) - - cmd = ['kdialog', '--textbox', log, '700', '450', '--title', log] - subprocess.Popen(cmd) + log_dialog = LogDialog(app, log) + log_dialog.exec_() @pyqtSlot('QAction *') diff --git a/rpm_spec/qmgr.spec b/rpm_spec/qmgr.spec index aac95da..e14fd7a 100644 --- a/rpm_spec/qmgr.spec +++ b/rpm_spec/qmgr.spec @@ -44,6 +44,7 @@ cp qubesmanager/global_settings.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubes cp qubesmanager/multiselectwidget.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager cp qubesmanager/restore.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager cp qubesmanager/settings.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager +cp qubesmanager/log_dialog.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager cp qubesmanager/thread_monitor.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager cp qubesmanager/resources_rc.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager cp qubesmanager/__init__.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager @@ -56,6 +57,7 @@ cp qubesmanager/ui_newappvmdlg.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesm cp qubesmanager/ui_newfwruledlg.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager cp qubesmanager/ui_restoredlg.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager cp qubesmanager/ui_settingsdlg.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager +cp qubesmanager/ui_logdlg.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager mkdir -p $RPM_BUILD_ROOT/usr/share/applications cp qubes-manager.desktop $RPM_BUILD_ROOT/usr/share/applications @@ -139,6 +141,9 @@ rm -rf $RPM_BUILD_ROOT %{python_sitearch}/qubesmanager/ui_settingsdlg.py %{python_sitearch}/qubesmanager/ui_settingsdlg.pyc %{python_sitearch}/qubesmanager/ui_settingsdlg.pyo +%{python_sitearch}/qubesmanager/ui_logdlg.py +%{python_sitearch}/qubesmanager/ui_logdlg.pyc +%{python_sitearch}/qubesmanager/ui_logdlg.pyo /usr/share/applications/qubes-manager.desktop