From aa700f245d7c8ea96728266237f42691836baf74 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Arto=20Hyv=C3=A4ttinen?= Date: Mon, 21 Jun 2010 23:26:45 +0300 Subject: [PATCH] Initial: added urpo files! --- src/Makefile | 363 ++++++++++++++++++++ src/cerrdebugmonitor.cpp | 15 + src/cerrdebugmonitor.h | 30 ++ src/debugconsole.cpp | 37 ++ src/debugconsole.h | 53 +++ src/help/gpl.html | 723 ++++++++++++++++++++++++++++++++++++++++ src/help/index.html | 134 ++++++++ src/help/index_fi.html | 86 +++++ src/main.cpp | 37 ++ src/printerlistjob.cpp | 85 +++++ src/printerlistjob.h | 64 ++++ src/printjob.cpp | 185 ++++++++++ src/printjob.h | 90 +++++ src/printwidget.cpp | 185 ++++++++++ src/printwidget.h | 97 ++++++ src/settingsdialog.cpp | 155 +++++++++ src/settingsdialog.h | 71 ++++ src/urpo.pro | 53 +++ src/urpo.pro.user | 309 +++++++++++++++++ src/urpo.pro.user.1.3 | 245 ++++++++++++++ src/urpo.qrc | 8 + src/urpo_fi.qm | Bin 0 -> 4784 bytes src/urpo_fi.ts | 267 +++++++++++++++ src/urpoconnection.cpp | 63 ++++ src/urpoconnection.h | 102 ++++++ src/urpoconnectionsettings.cpp | 84 +++++ src/urpoconnectionsettings.h | 72 ++++ src/urpojob.cpp | 65 ++++ src/urpojob.h | 109 ++++++ src/urpomainwindow.cpp | 242 ++++++++++++++ src/urpomainwindow.h | 83 +++++ src/urpoprocess.cpp | 130 ++++++++ src/urpoprocess.h | 207 ++++++++++++ 33 files changed, 4449 insertions(+) create mode 100644 src/Makefile create mode 100644 src/cerrdebugmonitor.cpp create mode 100644 src/cerrdebugmonitor.h create mode 100644 src/debugconsole.cpp create mode 100644 src/debugconsole.h create mode 100644 src/help/gpl.html create mode 100644 src/help/index.html create mode 100644 src/help/index_fi.html create mode 100644 src/main.cpp create mode 100644 src/printerlistjob.cpp create mode 100644 src/printerlistjob.h create mode 100644 src/printjob.cpp create mode 100644 src/printjob.h create mode 100644 src/printwidget.cpp create mode 100644 src/printwidget.h create mode 100644 src/settingsdialog.cpp create mode 100644 src/settingsdialog.h create mode 100644 src/urpo.pro create mode 100644 src/urpo.pro.user create mode 100644 src/urpo.pro.user.1.3 create mode 100644 src/urpo.qrc create mode 100644 src/urpo_fi.qm create mode 100644 src/urpo_fi.ts create mode 100644 src/urpoconnection.cpp create mode 100644 src/urpoconnection.h create mode 100644 src/urpoconnectionsettings.cpp create mode 100644 src/urpoconnectionsettings.h create mode 100644 src/urpojob.cpp create mode 100644 src/urpojob.h create mode 100644 src/urpomainwindow.cpp create mode 100644 src/urpomainwindow.h create mode 100644 src/urpoprocess.cpp create mode 100644 src/urpoprocess.h diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..9178c70 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,363 @@ +############################################################################# +# Makefile for building: urpo +# Generated by qmake (2.01a) (Qt 4.6.2) on: ma kesä 21 21:28:22 2010 +# Project: urpo.pro +# Template: app +# Command: /usr/bin/qmake-qt4 -spec /usr/share/qt4/mkspecs/linux-g++ -unix CONFIG+=debug -o Makefile urpo.pro +############################################################################# + +####### Compiler, tools and options + +CC = gcc +CXX = g++ +DEFINES = -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED +CFLAGS = -pipe -g -Wall -W -D_REENTRANT $(DEFINES) +CXXFLAGS = -pipe -g -Wall -W -D_REENTRANT $(DEFINES) +INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. +LINK = g++ +LFLAGS = +LIBS = $(SUBLIBS) -L/usr/lib -lQtGui -lQtCore -lpthread +AR = ar cqs +RANLIB = +QMAKE = /usr/bin/qmake-qt4 +TAR = tar -cf +COMPRESS = gzip -9f +COPY = cp -f +SED = sed +COPY_FILE = $(COPY) +COPY_DIR = $(COPY) -r +STRIP = strip +INSTALL_FILE = install -m 644 -p +INSTALL_DIR = $(COPY_DIR) +INSTALL_PROGRAM = install -m 755 -p +DEL_FILE = rm -f +SYMLINK = ln -f -s +DEL_DIR = rmdir +MOVE = mv -f +CHK_DIR_EXISTS= test -d +MKDIR = mkdir -p + +####### Output directory + +OBJECTS_DIR = ./ + +####### Files + +SOURCES = main.cpp \ + urpomainwindow.cpp \ + urpoconnection.cpp \ + urpoconnectionsettings.cpp \ + urpoprocess.cpp \ + urpojob.cpp \ + printerlistjob.cpp \ + cerrdebugmonitor.cpp \ + printwidget.cpp \ + debugconsole.cpp \ + settingsdialog.cpp \ + printjob.cpp moc_urpomainwindow.cpp \ + moc_urpoprocess.cpp \ + moc_urpojob.cpp \ + moc_printerlistjob.cpp \ + moc_cerrdebugmonitor.cpp \ + moc_printwidget.cpp \ + moc_debugconsole.cpp \ + moc_settingsdialog.cpp \ + moc_printjob.cpp \ + qrc_urpo.cpp +OBJECTS = main.o \ + urpomainwindow.o \ + urpoconnection.o \ + urpoconnectionsettings.o \ + urpoprocess.o \ + urpojob.o \ + printerlistjob.o \ + cerrdebugmonitor.o \ + printwidget.o \ + debugconsole.o \ + settingsdialog.o \ + printjob.o \ + moc_urpomainwindow.o \ + moc_urpoprocess.o \ + moc_urpojob.o \ + moc_printerlistjob.o \ + moc_cerrdebugmonitor.o \ + moc_printwidget.o \ + moc_debugconsole.o \ + moc_settingsdialog.o \ + moc_printjob.o \ + qrc_urpo.o +DIST = /usr/share/qt4/mkspecs/common/g++.conf \ + /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/debug.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + urpo.pro +QMAKE_TARGET = urpo +DESTDIR = +TARGET = urpo + +first: all +####### Implicit rules + +.SUFFIXES: .o .c .cpp .cc .cxx .C + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" + +####### Build rules + +all: Makefile $(TARGET) + +$(TARGET): $(OBJECTS) + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) + +Makefile: urpo.pro /usr/share/qt4/mkspecs/linux-g++/qmake.conf /usr/share/qt4/mkspecs/common/g++.conf \ + /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/debug.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + /usr/lib/libQtGui.prl \ + /usr/lib/libQtCore.prl + $(QMAKE) -spec /usr/share/qt4/mkspecs/linux-g++ -unix CONFIG+=debug -o Makefile urpo.pro +/usr/share/qt4/mkspecs/common/g++.conf: +/usr/share/qt4/mkspecs/common/unix.conf: +/usr/share/qt4/mkspecs/common/linux.conf: +/usr/share/qt4/mkspecs/qconfig.pri: +/usr/share/qt4/mkspecs/features/qt_functions.prf: +/usr/share/qt4/mkspecs/features/qt_config.prf: +/usr/share/qt4/mkspecs/features/exclusive_builds.prf: +/usr/share/qt4/mkspecs/features/default_pre.prf: +/usr/share/qt4/mkspecs/features/debug.prf: +/usr/share/qt4/mkspecs/features/default_post.prf: +/usr/share/qt4/mkspecs/features/warn_on.prf: +/usr/share/qt4/mkspecs/features/qt.prf: +/usr/share/qt4/mkspecs/features/unix/thread.prf: +/usr/share/qt4/mkspecs/features/moc.prf: +/usr/share/qt4/mkspecs/features/resources.prf: +/usr/share/qt4/mkspecs/features/uic.prf: +/usr/share/qt4/mkspecs/features/yacc.prf: +/usr/share/qt4/mkspecs/features/lex.prf: +/usr/share/qt4/mkspecs/features/include_source_dir.prf: +/usr/lib/libQtGui.prl: +/usr/lib/libQtCore.prl: +qmake: FORCE + @$(QMAKE) -spec /usr/share/qt4/mkspecs/linux-g++ -unix CONFIG+=debug -o Makefile urpo.pro + +dist: + @$(CHK_DIR_EXISTS) .tmp/urpo1.0.0 || $(MKDIR) .tmp/urpo1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/urpo1.0.0/ && $(COPY_FILE) --parents urpomainwindow.h urpoconnection.h urpoconnectionsettings.h urpoprocess.h urpojob.h printerlistjob.h cerrdebugmonitor.h printwidget.h debugconsole.h settingsdialog.h printjob.h .tmp/urpo1.0.0/ && $(COPY_FILE) --parents urpo.qrc .tmp/urpo1.0.0/ && $(COPY_FILE) --parents main.cpp urpomainwindow.cpp urpoconnection.cpp urpoconnectionsettings.cpp urpoprocess.cpp urpojob.cpp printerlistjob.cpp cerrdebugmonitor.cpp printwidget.cpp debugconsole.cpp settingsdialog.cpp printjob.cpp .tmp/urpo1.0.0/ && $(COPY_FILE) --parents urpo_fi.ts .tmp/urpo1.0.0/ && (cd `dirname .tmp/urpo1.0.0` && $(TAR) urpo1.0.0.tar urpo1.0.0 && $(COMPRESS) urpo1.0.0.tar) && $(MOVE) `dirname .tmp/urpo1.0.0`/urpo1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/urpo1.0.0 + + +clean:compiler_clean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + + +####### Sub-libraries + +distclean: clean + -$(DEL_FILE) $(TARGET) + -$(DEL_FILE) Makefile + + +mocclean: compiler_moc_header_clean compiler_moc_source_clean + +mocables: compiler_moc_header_make_all compiler_moc_source_make_all + +compiler_moc_header_make_all: moc_urpomainwindow.cpp moc_urpoprocess.cpp moc_urpojob.cpp moc_printerlistjob.cpp moc_cerrdebugmonitor.cpp moc_printwidget.cpp moc_debugconsole.cpp moc_settingsdialog.cpp moc_printjob.cpp +compiler_moc_header_clean: + -$(DEL_FILE) moc_urpomainwindow.cpp moc_urpoprocess.cpp moc_urpojob.cpp moc_printerlistjob.cpp moc_cerrdebugmonitor.cpp moc_printwidget.cpp moc_debugconsole.cpp moc_settingsdialog.cpp moc_printjob.cpp +moc_urpomainwindow.cpp: urpomainwindow.h + /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) urpomainwindow.h -o moc_urpomainwindow.cpp + +moc_urpoprocess.cpp: urpoprocess.h + /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) urpoprocess.h -o moc_urpoprocess.cpp + +moc_urpojob.cpp: urpoprocess.h \ + urpojob.h + /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) urpojob.h -o moc_urpojob.cpp + +moc_printerlistjob.cpp: urpojob.h \ + urpoprocess.h \ + printerlistjob.h + /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) printerlistjob.h -o moc_printerlistjob.cpp + +moc_cerrdebugmonitor.cpp: cerrdebugmonitor.h + /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) cerrdebugmonitor.h -o moc_cerrdebugmonitor.cpp + +moc_printwidget.cpp: printwidget.h + /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) printwidget.h -o moc_printwidget.cpp + +moc_debugconsole.cpp: debugconsole.h + /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) debugconsole.h -o moc_debugconsole.cpp + +moc_settingsdialog.cpp: settingsdialog.h + /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) settingsdialog.h -o moc_settingsdialog.cpp + +moc_printjob.cpp: urpojob.h \ + urpoprocess.h \ + printjob.h + /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) printjob.h -o moc_printjob.cpp + +compiler_rcc_make_all: qrc_urpo.cpp +compiler_rcc_clean: + -$(DEL_FILE) qrc_urpo.cpp +qrc_urpo.cpp: urpo.qrc \ + urpo_fi.qm \ + help/gpl.html \ + help/index.html \ + help/index_fi.html + /usr/bin/rcc -name urpo urpo.qrc -o qrc_urpo.cpp + +compiler_image_collection_make_all: qmake_image_collection.cpp +compiler_image_collection_clean: + -$(DEL_FILE) qmake_image_collection.cpp +compiler_moc_source_make_all: +compiler_moc_source_clean: +compiler_uic_make_all: +compiler_uic_clean: +compiler_yacc_decl_make_all: +compiler_yacc_decl_clean: +compiler_yacc_impl_make_all: +compiler_yacc_impl_clean: +compiler_lex_make_all: +compiler_lex_clean: +compiler_clean: compiler_moc_header_clean compiler_rcc_clean + +####### Compile + +main.o: main.cpp urpomainwindow.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp + +urpomainwindow.o: urpomainwindow.cpp urpomainwindow.h \ + urpoconnectionsettings.h \ + urpoconnection.h \ + printerlistjob.h \ + urpojob.h \ + urpoprocess.h \ + debugconsole.h \ + printwidget.h \ + printjob.h \ + settingsdialog.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o urpomainwindow.o urpomainwindow.cpp + +urpoconnection.o: urpoconnection.cpp urpoconnection.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o urpoconnection.o urpoconnection.cpp + +urpoconnectionsettings.o: urpoconnectionsettings.cpp urpoconnectionsettings.h \ + urpoconnection.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o urpoconnectionsettings.o urpoconnectionsettings.cpp + +urpoprocess.o: urpoprocess.cpp urpoprocess.h \ + urpoconnection.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o urpoprocess.o urpoprocess.cpp + +urpojob.o: urpojob.cpp urpojob.h \ + urpoprocess.h \ + urpoconnection.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o urpojob.o urpojob.cpp + +printerlistjob.o: printerlistjob.cpp printerlistjob.h \ + urpojob.h \ + urpoprocess.h \ + urpoconnection.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o printerlistjob.o printerlistjob.cpp + +cerrdebugmonitor.o: cerrdebugmonitor.cpp cerrdebugmonitor.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o cerrdebugmonitor.o cerrdebugmonitor.cpp + +printwidget.o: printwidget.cpp printwidget.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o printwidget.o printwidget.cpp + +debugconsole.o: debugconsole.cpp debugconsole.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debugconsole.o debugconsole.cpp + +settingsdialog.o: settingsdialog.cpp settingsdialog.h \ + urpoconnectionsettings.h \ + urpoconnection.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o settingsdialog.o settingsdialog.cpp + +printjob.o: printjob.cpp printjob.h \ + urpojob.h \ + urpoprocess.h \ + urpoconnection.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o printjob.o printjob.cpp + +moc_urpomainwindow.o: moc_urpomainwindow.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_urpomainwindow.o moc_urpomainwindow.cpp + +moc_urpoprocess.o: moc_urpoprocess.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_urpoprocess.o moc_urpoprocess.cpp + +moc_urpojob.o: moc_urpojob.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_urpojob.o moc_urpojob.cpp + +moc_printerlistjob.o: moc_printerlistjob.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_printerlistjob.o moc_printerlistjob.cpp + +moc_cerrdebugmonitor.o: moc_cerrdebugmonitor.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_cerrdebugmonitor.o moc_cerrdebugmonitor.cpp + +moc_printwidget.o: moc_printwidget.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_printwidget.o moc_printwidget.cpp + +moc_debugconsole.o: moc_debugconsole.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_debugconsole.o moc_debugconsole.cpp + +moc_settingsdialog.o: moc_settingsdialog.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_settingsdialog.o moc_settingsdialog.cpp + +moc_printjob.o: moc_printjob.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_printjob.o moc_printjob.cpp + +qrc_urpo.o: qrc_urpo.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o qrc_urpo.o qrc_urpo.cpp + +####### Install + +install: FORCE + +uninstall: FORCE + +FORCE: + diff --git a/src/cerrdebugmonitor.cpp b/src/cerrdebugmonitor.cpp new file mode 100644 index 0000000..ed12c77 --- /dev/null +++ b/src/cerrdebugmonitor.cpp @@ -0,0 +1,15 @@ +#include "cerrdebugmonitor.h" +#include + +CerrDebugMonitor::CerrDebugMonitor(QObject *parent) : + QObject(parent) +{ + +} + +void CerrDebugMonitor::debugMessage(QString message) +{ + std::cout << message.toStdString(); + std::cout << "\n"; + std::cout.flush(); +} diff --git a/src/cerrdebugmonitor.h b/src/cerrdebugmonitor.h new file mode 100644 index 0000000..1415c0a --- /dev/null +++ b/src/cerrdebugmonitor.h @@ -0,0 +1,30 @@ +#ifndef CERRDEBUGMONITOR_H +#define CERRDEBUGMONITOR_H + +#include + +/*! Debug monitor to stardart output (cout) + + Temperary, not used in final program + + @see DebugConsole + + @author Arto Hyvättinen + @version 0 + @date 2010-06-12 + + */ +class CerrDebugMonitor : public QObject +{ + Q_OBJECT +public: + explicit CerrDebugMonitor(QObject *parent = 0); + +signals: + +public slots: + void debugMessage(QString message); + +}; + +#endif // CERRDEBUGMONITOR_H diff --git a/src/debugconsole.cpp b/src/debugconsole.cpp new file mode 100644 index 0000000..10c3f5d --- /dev/null +++ b/src/debugconsole.cpp @@ -0,0 +1,37 @@ +/************************************************************************** + + URPO + + Unix Remote Printing Operation + Copyright (c) Arto Hyvättinen 2010 + + This file is part of URPO. + + URPO 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 3 of the License, or + (at your option) any later version. + + URPO 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. + + +**************************************************************************/ + +#include "debugconsole.h" + +DebugConsole::DebugConsole(QWidget *parent) : + QTextBrowser(parent) +{ + // Set window + setWindowTitle("URPO Debug"); + append( tr("This window shows information for resolving error situations\n")); +} + +void DebugConsole::debugMessage(QString message) +{ + // Show everything sent by this slot. + append( message ); +} diff --git a/src/debugconsole.h b/src/debugconsole.h new file mode 100644 index 0000000..84d6799 --- /dev/null +++ b/src/debugconsole.h @@ -0,0 +1,53 @@ +/************************************************************************** + + URPO + + Unix Remote Printing Operation + Copyright (c) Arto Hyvättinen 2010 + + This file is part of URPO. + + URPO 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 3 of the License, or + (at your option) any later version. + + URPO 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. + + +**************************************************************************/ + +#ifndef DEBUGCONSOLE_H +#define DEBUGCONSOLE_H + +#include + +/*! Show debug messages + + @author Arto Hyvättinen + @date 2010-06-13 + @version 0.1 + + Show debug messages in QTextBrowser. + Show everything received via debugMessage() slot. + + + */ + +class DebugConsole : public QTextBrowser +{ + Q_OBJECT +public: + explicit DebugConsole(QWidget *parent = 0); + +signals: + +public slots: + void debugMessage(QString message); + +}; + +#endif // DEBUGCONSOLE_H diff --git a/src/help/gpl.html b/src/help/gpl.html new file mode 100644 index 0000000..3d317b6 --- /dev/null +++ b/src/help/gpl.html @@ -0,0 +1,723 @@ + + + + + + GNU General Public License - GNU Project - Free Software +Foundation (FSF) + + +

GNU GENERAL PUBLIC LICENSE

+

Version 3, 29 June 2007

+ +

Copyright © 2007 Free Software Foundation, Inc. + <http://fsf.org/>

+ Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed.

+ +

Preamble

+ +

The GNU General Public License is a free, copyleft license for +software and other kinds of works.

+ +

The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too.

+ +

When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things.

+ +

To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others.

+ +

For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights.

+ +

Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it.

+ +

For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions.

+ +

Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users.

+ +

Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free.

+ +

The precise terms and conditions for copying, distribution and +modification follow.

+ +

TERMS AND CONDITIONS

+ +

0. Definitions.

+ +

“This License” refers to version 3 of the GNU General Public License.

+ +

“Copyright” also means copyright-like laws that apply to other kinds +of +works, such as semiconductor masks.

+ +

“The Program” refers to any copyrightable work licensed under this +License. Each licensee is addressed as “you”. “Licensees” and +“recipients” may be individuals or organizations.

+ +

To “modify” a work means to copy from or adapt all or part of the +work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a “modified version” of the +earlier work or a work “based on” the earlier work.

+ +

A “covered work” means either the unmodified Program or a work based +on the Program.

+ +

To “propagate” a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well.

+ +

To “convey” a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying.

+ +

An interactive user interface displays “Appropriate Legal Notices” +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion.

+ +

1. Source Code.

+ +

The “source code” for a work means the preferred form of the work +for making modifications to it. “Object code” means any non-source +form of a work.

+ +

A “Standard Interface” means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language.

+ +

The “System Libraries” of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +“Major Component”, in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it.

+ +

The “Corresponding Source” for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work.

+ +

The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source.

+ +

The Corresponding Source for a work in source code form is that +same work.

+ +

2. Basic Permissions.

+ +

All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law.

+ +

You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you.

+ +

Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary.

+ +

3. Protecting Users' Legal Rights From +Anti-Circumvention Law.

+ +

No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures.

+ +

When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures.

+ +

4. Conveying Verbatim Copies.

+ +

You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program.

+ +

You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee.

+ +

5. Conveying Modified Source Versions.

+ +

You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions:

+ +
    +
  • a) The work must carry prominent notices stating that you modified + it, and giving a relevant date.
  • + +
  • b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + “keep intact all notices”.
  • + +
  • c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it.
  • + +
  • d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so.
  • +
+ +

A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +“aggregate” if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate.

+ +

6. Conveying Non-Source Forms.

+ +

You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways:

+ +
    +
  • a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange.
  • + +
  • b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge.
  • + +
  • c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b.
  • + +
  • d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements.
  • + +
  • e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d.
  • +
+ +

A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work.

+ +

A “User Product” is either (1) a “consumer product”, which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for +incorporation +into a dwelling. In determining whether a product is a consumer +product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, “normally used” refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product.

+ +

“Installation Information” for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product +from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made.

+ +

If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM).

+ +

The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network.

+ +

Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying.

+ +

7. Additional Terms.

+ +

“Additional permissions” are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions.

+ +

When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission.

+ +

Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders +of +that material) supplement the terms of this License with terms:

+ +
    +
  • a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or
  • + +
  • b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or
  • + +
  • c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or
  • + +
  • d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or
  • + +
  • e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or
  • + +
  • f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors.
  • +
+ +

All other non-permissive additional terms are considered “further +restrictions” within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying.

+ +

If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms.

+ +

Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way.

+ +

8. Termination.

+ +

You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11).

+ +

However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation.

+ +

Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice.

+ +

Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10.

+ +

9. Acceptance Not Required for Having Copies.

+ +

You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so.

+ +

10. Automatic Licensing of Downstream +Recipients.

+ +

Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License.

+ +

An “entity transaction” is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts.

+ +

You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it.

+ +

11. Patents.

+ +

A “contributor” is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's “contributor version”.

+ +

A contributor's “essential patent claims” are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, “control” includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License.

+ +

Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version.

+ +

In the following three paragraphs, a “patent license” is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To “grant” such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party.

+ +

If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. “Knowingly relying” means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid.

+ +

If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it.

+ +

A patent license is “discriminatory” if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007.

+ +

Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law.

+ +

12. No Surrender of Others' Freedom.

+ +

If conditions are imposed on you (whether by court order, agreement +or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may +not convey it at all. For example, if you agree to terms that obligate +you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program.

+ +

13. Use with the GNU Affero General Public +License.

+ +

Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such.

+ +

14. Revised Versions of this License.

+ +

The Free Software Foundation may publish revised and/or new versions +of +the GNU General Public License from time to time. Such new versions +will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns.

+ +

Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License “or any later version” applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation.

+ +

If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program.

+ +

Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version.

+ +

15. Disclaimer of Warranty.

+ +

THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT +WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

+ +

16. Limitation of Liability.

+ +

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR +CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING +ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS +OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR +THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY +OF +SUCH DAMAGES.

+ +

17. Interpretation of Sections 15 and 16.

+ +

If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee.

+ +

END OF TERMS AND CONDITIONS

+ +

How to Apply These Terms to Your New Programs

+ +

If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these +terms.

+ +

To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the “copyright” line and a pointer to where the full notice is found.

+ +
    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    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 3 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, see <http://www.gnu.org/licenses/>.
+
+ +

Also add information on how to contact you by electronic and paper +mail.

+ +

If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode:

+ +
    <program>  Copyright (C) <year>  <name of author>
+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+ +

The hypothetical commands `show w' and `show c' should show the +appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an “about box”.

+ +

You should also get your employer (if you work as a programmer) or +school, +if any, to sign a “copyright disclaimer” for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, +see +<http://www.gnu.org/licenses/>.

+ +

The GNU General Public License does not permit incorporating your +program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications +with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>.

+ + \ No newline at end of file diff --git a/src/help/index.html b/src/help/index.html new file mode 100644 index 0000000..d69b8ae --- /dev/null +++ b/src/help/index.html @@ -0,0 +1,134 @@ + + + + + URPO help + + + +

URPO 0.9

+ +
+ +Features  Requirements  +Generating SSH-keys  Settings  +Printing  Debug
+ +
+ +Unix Remote Printing Operation
+ +A Program for printing files via a server
+ +© Arto Hyvättinen 2010
+ +
+ +URPO is free to use according to GPL 3. No guarantees. See the lisence.
+ +

Features
+

+ +With URPO you can print files to a printer attached to a +linux/unix-computer. URPO uses the CUPS-system +on the computer for printing. It is designed for use on a Maemo 5 +device.
+ +
+ +You can print files in all formats supported by CUPS:
+ +
    + +
  • Text files
  • +
  • PDF
  • +
  • PostScript
  • +
  • HP-GL/2
  • +
  • Image files: BMP, GIF, JPG, PhotoCD, PIX, PNG, PNM, TIFF
  • +
+ +

Requirements
+

+ +You need an openssh-program on your maemo +device.
+ +On the computer to which the printer is attached to, you need the cups and ssh-servers. +CUPS (Common Unix Printing System) is a printing server, installed by +default in several linux distributions. The ssh server is needed to +safely connect to the computer. The port 22 needs to be opened from the +computer's firewall. There is no need to open a port for cups.
+ +

Generating SSH-keys

+ +A SSH key pair is needed to identify the user. The key pair is created +in the maemo device:
+ +ssh-keygen -t rsa
+ +The password is left empty. Remember where you have saved the keys! You +cannot save them in the MyDocs folder, since the private key must not +be accessible to others than the user.
+ +
+ +The access rights of the file need to be set:
+ +chmod 600 ~/.ssh/id_urpo
+ +
+ +The public key is added to the server (computer) in the home +folder's  .ssh folder's file  authorized_keys . You can use +ssh for transferring it:
+ +cat ~/.ssh/id_urpo | ssh user@computer 'cat >> +~./ssh/authorized_keys'
+ +
+ +The location of the private key is set in the settings of URPO.
+ +

Settings
+

+ +When used for the first time URPO asks for settings. You can access +these settings later by choosing "Settings"  from the menu.
+ +Host name or ip address: The +computer's  (server's) ip address, or its name if the device can +find it by name.
+ +Username: The user account on +the server .
+ +Identity file: The private +ssh-key.
+ +

Printing

+ +Choose the file to be printed (Browse).
+ +Choose the printer.
+ +If desired, limit what pages are to be printed, e.g 1,2 or 3-6 or 1,5-7 +.
+ +You can choose 1, 2 or 4 pages to be printed per sheet.
+ +You can print 1-99 copies.
+ +Printing is started with the Print-button.
+ +
+ +

Debug-window

+ +When "Debug" is chosen from the +menu, a debug window opens. Information useful in solving problems, +such as the commands given to server trough ssh and their output, is +printed on that window.
+ +
+ + \ No newline at end of file diff --git a/src/help/index_fi.html b/src/help/index_fi.html new file mode 100644 index 0000000..bad86f6 --- /dev/null +++ b/src/help/index_fi.html @@ -0,0 +1,86 @@ + + + + + + + URPO help +

URPO 0.9

+Ominaisuudet  Vaatimukset  Avainten luonti  Asetukset  Tulostaminen  Debug
+
+Unix Remote Printing Operation
+ + +Ohjelmisto tiedostojen tulostamiseen palvelimella
+ + +© Arto Hyvättinen 2010
+ + +
+ + +URPO on GPL 3:n mukaan vapaasti käytettävä ohjelmisto. Ohjelmalle ei anneta takuuta. Katso lisenssi.
+ + + +

Mitä URPOlla tehdään?

+ + + +Urpolla voit tulostaa tiedostoja linux/unix-tietokoneeseen liitettyyn +kirjoittimeen. Urpo käyttää tulostimeen tietokoneen CUPS-järjestelmää. Urpo on suunniteltu käytettäväksi Maemo 5-laitteella.
+ +
+ +Voit tulostaa kaikkia CUPS:n tukemia tiedostomuotoja:
+ +
    +
  • Tekstitiedostot
  • PDF
  • PostScript
  • HP-GL/2
  • Kuvatiedostoja: BMP, GIF, JPG, PhotoCD, PIX, PNG, PNM, TIFF
  • +
+ + + +

Tarvittavat ohjelmat
+

+ +Tähän laitteeseen tarvitset openssh-ohjelmiston.
+ +Tietokoneeseen, johon tulostin on liitetty, tarvitset cups ja ssh-palvelimet. +CUPS (Common Unix Printing System) on tulostuspalvelin, joka on +oletuksena useissa linux-jakeluissa; ssh on suojattuun pääteyhteyteen +tarvittava palvelin. Tietokoneen palomuurista on avattava ssh-portti 22, cups:in porttia ei tarvitse avata.
+ +

SSH-avaimen luominen

+Käyttäjän tunnistamista varten tarvitaan ssh-avainpari. Avainpari luodaan maemo-laitteessa:
+ssh-keygen -t rsa
+Salasana jätetään tyhjäksi. Muista, minne avaimet tallennetaan! Avainta +ei voi tallettaa MyDocs-hakemistoon, koska avain ei saa olla muiden +kuin käyttäjän luettavissa.
+chmod 600 ~/.ssh/id_urpo
+Julkinen avain lisätään palvelimelle (tietokoneelle) kotihakemiston +.ssh-hakemiston tiedostoon authorized_keys. Voit käyttää ssh:ta avaimen +siirtämiseen.
+cat ~/.ssh/id_urpo | ssh käyttäjä@tietokone 'cat >> ~./ssh/authorized_keys'
+Yksityisen avaimen sijainti asetetaan URPOn asetuksissa.
+

Asetukset

+Käynnistyessään ensimmäistä kertaa Urpo kysyy asetuksia. Asetuksiin pääsee myöhemmin valikon Asetukset -valinnalla.
+Tietokoneen nimi tai ip-osoite: Tietokoneen (palvelin) ip-osoite tai nimi, jos laite löytää tietokoneen nimellä.
+Käyttäjätunnus: Käyttäjätunnus palvelimessa.
+Yksityinen avaintiedosto: Yksityinen ssh-avaintiedosto (private key).
+

Tulostaminen

+Valitse tulostettava tiedosto (Selaa).
+Valitse tulostin.
+Rajaa halutessasi tulostettavia sivuja, esim. 1,2 tai 3-6 tai 1,5-7 .
+Voit valita 1,2 tai 4 sivua tulostettavaksi yhdelle arkille.
+Voit tulostaa kerralla 1-99 kopiota
+Tulostus käynnistyy Tulosta-napilla.
+
+

Debug-ikkuna

+Valikon Debug-valinnalla aukeaa +ikkuna, jonne tulostuu ongelmien ratkaisemisessa hyödyllistä tietoa, +kuten ssh:n kautta ajettavien ohjelmien käynnistyskomennot ja +tulostukset.
+
+
+ \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..b3d18c3 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,37 @@ +#include +#include +#include "urpomainwindow.h" +#include + +/*! @mainpage Urpo - Unix Remote Printing Operation + + + @author Arto Hyvättinen + @version 0.9 + @date 2010-06 + + Urpo prints to remote computer via cups and ssh. Urpo is designed for Maemo. + + Urpo uses Qt library. It it translated into Finnish. + + */ + + + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + + QTranslator appTranslator; + appTranslator.load("urpo_" + QLocale::system().name(),":/"); + a.installTranslator(&appTranslator); + + UrpoMainWindow w; +#if defined(Q_WS_S60) + w.showMaximized(); +#else + w.show(); +#endif + + return a.exec(); +} diff --git a/src/printerlistjob.cpp b/src/printerlistjob.cpp new file mode 100644 index 0000000..ff2b7a5 --- /dev/null +++ b/src/printerlistjob.cpp @@ -0,0 +1,85 @@ +/************************************************************************** + + URPO + + Unix Remote Printing Operation + Copyright (c) Arto Hyvättinen 2010 + + This file is part of URPO. + + URPO 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 3 of the License, or + (at your option) any later version. + + URPO 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. + + +**************************************************************************/ + +#include "printerlistjob.h" +#include "urpoconnection.h" + +PrinterListJob::PrinterListJob(UrpoConnection* connection) : + UrpoJob(connection) +{ + process_=0; +} + + +void PrinterListJob::startJob() +{ + process_= newProcess(); + + // ssh command getting printers of cups + QString command = "ssh "; + command.append(getConnection()->getKeyOption()); + command.append(getConnection()->getHostString()); + command.append(" env LANG=en lpstat -p"); + + // When finished, call doList + connect( process_, SIGNAL(finished(bool)), this, SLOT(doList(bool))); + process_->start(command); +} + +void PrinterListJob::cancelJob() +{ + if(process_) + process_->terminate(); + finish(Cancelled); +} + +void PrinterListJob::doList(bool success) +{ + if( process_ && success ) + { + foreach(QString line, process_->getOutput()) + { + if(!line.section(' ',1,1).isEmpty()) + printers_.append( line.section(' ',1,1)); + // List of printers! + } + finish(Successed); + } + else + { + // Error! + // Set error message + switch( process_->getError() ) + { + case UrpoProcess::ProcessError : + fail( tr("Failed to run ssh client.")); break; + case UrpoProcess::ConnectionError: + fail( tr("Failed to connect host")); break; + case UrpoProcess::Timeout: + fail( tr("Time out or authentication error")); break; + case UrpoProcess::Cancelled: + fail( tr("User cancelled")); break; + default: + fail( tr("Connection failed")); + } + } +} diff --git a/src/printerlistjob.h b/src/printerlistjob.h new file mode 100644 index 0000000..a4cb8c0 --- /dev/null +++ b/src/printerlistjob.h @@ -0,0 +1,64 @@ +/************************************************************************** + + URPO + + Unix Remote Printing Operation + Copyright (c) Arto Hyvättinen 2010 + + This file is part of URPO. + + URPO 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 3 of the License, or + (at your option) any later version. + + URPO 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. + + +**************************************************************************/ + +#ifndef PRINTERLISTJOB_H +#define PRINTERLISTJOB_H + + +#include "urpojob.h" +#include + +/*! Get list of available printers + + @author Arto Hyvättinen + @version 0 + @date 2010-06-11 + + connect finished() and call start(). + getPrinters() tell printers of remote host. + + */ + +class PrinterListJob : public UrpoJob +{ + Q_OBJECT +public: + explicit PrinterListJob(UrpoConnection* connection); + /*! List of printers in system */ + QStringList getPrinters() const { return printers_; } + +signals: + +public slots: + /*! Read output and do printer list */ + void doList(bool success); + +protected: + void startJob(); + void cancelJob(); + +private: + QStringList printers_; + UrpoProcess* process_; +}; + +#endif // PRINTERLISTJOB_H diff --git a/src/printjob.cpp b/src/printjob.cpp new file mode 100644 index 0000000..1ea7146 --- /dev/null +++ b/src/printjob.cpp @@ -0,0 +1,185 @@ +/************************************************************************** + + URPO + + Unix Remote Printing Operation + Copyright (c) Arto Hyvättinen 2010 + + This file is part of URPO. + + URPO 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 3 of the License, or + (at your option) any later version. + + URPO 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. + + +**************************************************************************/ + +#include "printjob.h" +#include "urpoconnection.h" +#include +#include // Thowing execption for start() +#include // For random numbers generating temp file name + +PrintJob::PrintJob(UrpoConnection* connection) : + UrpoJob(connection) +{ + currentProcess_ = 0; +} + +PrintJob::~PrintJob() +{ + if( currentProcess_ ) + delete currentProcess_; +} + + +void PrintJob::freeProcess() +{ + if( currentProcess_) + { + // Delete current process when event loop + // + // If we are processing a signal from this process + // (process is finished), we can't delete process + // (actually, we can delete, but we get null pointer + // and segmentation fault !) + currentProcess_->deleteLater(); + + // disvalidate pointer + currentProcess_ = 0; + } +} + +void PrintJob::startJob() +{ + // See API documentation on header... + throw( new std::logic_error("PrintJob::starJob() NOT for use!") ); +} + + +void PrintJob::printFile(const QString& path, const QString& printOptions) +{ + // Get information about file + QFileInfo fileInfo(path); + if( fileInfo.exists() == false) + { + // File not found! + sendDebugMessage( tr("File %1 not exists.").arg(path)); + fail( tr("File not found") ); + return; + } + + // new process for use + freeProcess(); + currentProcess_= newProcess(); + + + // Copy temperary file to temperary directory + pathToPrint_ = "/var/tmp/urpo-"; + + // Securing unique of temperary files, add random + // number between 0 and ffffff + pathToPrint_.append( QString::number( rand() % 0xffffff, 16)); + + // In server path, replace space with _ + pathToPrint_.append( fileInfo.fileName().replace(QChar(' '),QChar('_'))); + + printOptions_ = printOptions; + + // Copy command + QString command = "scp "; + command.append( getConnection()->getKeyOption()); + command.append(fileInfo.absoluteFilePath().replace(QString(" "),QString("\\ ")) ); + command.append(" "); + command.append( getConnection()->getHostString() ); + command.append(":"); + command.append(pathToPrint_); + + // Next Copy Ready + connect( currentProcess_, SIGNAL(finished(bool)), this, SLOT(copyReady(bool))); + + currentProcess_->start(command); +} + +void PrintJob::copyReady(bool success) +{ + freeProcess(); + + if( success == false) + { + fail( tr("Failed copying file")); + return; + } + + // Running remote printing command + currentProcess_ = newProcess(); + QString command = " ssh "; + command.append( getConnection()->getKeyOption()) ; + command.append(getConnection()->getHostString()); + command.append(" lp "); + command.append(printOptions_); + command.append(" "); + command.append(pathToPrint_); + + // Next print ready + connect( currentProcess_, SIGNAL(finished(bool)), this, SLOT(printReady(bool))); + currentProcess_->start(command); + +} + +void PrintJob::printReady(bool success) +{ + // Print step is ready + freeProcess(); + + if( success == false ) + { + fail( tr("Print failed")); + return; + } + + // delete temperary file + currentProcess_ = newProcess(); + QString command = " ssh "; + command.append( getConnection()->getKeyOption()) ; + command.append(getConnection()->getHostString()); + command.append(" rm "); + command.append(pathToPrint_); + + // Next delete ready + connect( currentProcess_, SIGNAL(finished(bool)),this,SLOT(deleteReady(bool))); + currentProcess_->start(command); +} + +void PrintJob::deleteReady(bool success) +{ + // All done! + freeProcess(); + if( success == false ) + { + fail(tr("Failed deleting file")); + } + else + { + // Successed !!! + finish( Successed ); + } +} + +void PrintJob::cancelJob() +{ + // Cancelled by user. + if( currentProcess_ ) + { + currentProcess_->terminate(); + freeProcess(); + } + finish( Cancelled ); +} + diff --git a/src/printjob.h b/src/printjob.h new file mode 100644 index 0000000..01d6f7e --- /dev/null +++ b/src/printjob.h @@ -0,0 +1,90 @@ +/************************************************************************** + + URPO + + Unix Remote Printing Operation + Copyright (c) Arto Hyvättinen 2010 + + This file is part of URPO. + + URPO 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 3 of the License, or + (at your option) any later version. + + URPO 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. + + +**************************************************************************/ + +#ifndef PRINTJOB_H +#define PRINTJOB_H + +#include + + +/*! File printing job' + + @author Arto Hyvättinen + @date 2010-06-17 + @version 0.1 + + Job for printing files. + First, connect finished()-signal (called when ready) + Then, printFile() + + @note start() is not for use! + + */ +class PrintJob : public UrpoJob +{ + Q_OBJECT +public: + explicit PrintJob(UrpoConnection* connection); + ~PrintJob(); + +signals: + +public slots: + /*! When file has copied (internal use only) */ + void copyReady(bool success); + /*! When files has printed (internal use only) */ + void printReady(bool success); + /*! When file has deleted (internal use only) */ + void deleteReady(bool success); + + /*! Print sigle file + + @arg path Path to file + @arg printOptions cups print options for lp command + + When finished, emit finished() signal + + */ + void printFile(const QString& path, const QString& printOptions); + + /*! Do not use, thows execption! + + This function exits only because of bad class planning. + @note Do NOT use! + + @throw std::logic_error Thow error becouse this function is not for use!*/ + void startJob(); + /*! Cancel printing job */ + void cancelJob(); + +private: + inline void freeProcess(); + +private: + UrpoProcess* currentProcess_; + QString pathToPrint_; + QString printOptions_; + + +}; + +#endif // PRINTJOB_H diff --git a/src/printwidget.cpp b/src/printwidget.cpp new file mode 100644 index 0000000..2be7c4e --- /dev/null +++ b/src/printwidget.cpp @@ -0,0 +1,185 @@ +/************************************************************************** + + URPO + + Unix Remote Printing Operation + Copyright (c) Arto Hyvättinen 2010 + + This file is part of URPO. + + URPO 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 3 of the License, or + (at your option) any later version. + + URPO 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. + + +**************************************************************************/ + +#include "printwidget.h" + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +PrintWidget::PrintWidget(QWidget *parent) : + QWidget(parent) +{ + + filenameEdit = new QLineEdit(); + browseButton = new QPushButton( tr("Browse")); + connect(browseButton, SIGNAL(clicked()), this, SLOT(browseFile())); + + printerCombo = new QComboBox(); + printerCombo->setEnabled(false); + + rangeEdit = new QLineEdit(); + // Page ranges in format 1-3,5,8-10 + // Valid characters: 0123456789 , + + QRegExpValidator* rangeSensor = new QRegExpValidator( QRegExp("[0-9\\-,]+"), this ); + rangeEdit->setValidator( rangeSensor); + + // Copies: Spin 0..99 + copiesSpin = new QSpinBox(); + copiesSpin->setRange(1,99); + copiesSpin->setValue(1); + + // Pages per sheet + persheetCombo = new QComboBox(); + persheetCombo->insertItem(0,"1",1); + persheetCombo->insertItem(1,"2",2); + persheetCombo->insertItem(2,"4",4); + + printButton = new QPushButton( tr("Print")); + printButton->setEnabled(false); + connect( printButton, SIGNAL(clicked()), this, SLOT(doPrint())); + + statusLabel = new QLabel(); + progressBar = new QProgressBar(); + progressBar->setRange(0,0); + cancelButton = new QPushButton(tr("Cancel")); + connect(cancelButton,SIGNAL(clicked()),this,SIGNAL(cancel())); + + reconnectButton = new QPushButton( tr("Reconnect")); + connect(reconnectButton, SIGNAL(clicked()), this, SIGNAL(reconnect())); + + + QVBoxLayout* mainLayout = new QVBoxLayout(); + QHBoxLayout* fileLayout = new QHBoxLayout(); + fileLayout->addWidget( new QLabel( tr ("File") )); + fileLayout->addWidget(filenameEdit); + fileLayout->addWidget(browseButton); + mainLayout->addLayout(fileLayout); + + QHBoxLayout* printerLayout = new QHBoxLayout(); + printerLayout->addWidget(new QLabel( tr("Printer"))); + printerLayout->addWidget(printerCombo); + printerLayout->addStretch(); + mainLayout->addLayout(printerLayout); + + QHBoxLayout* rangeLayout = new QHBoxLayout(); + rangeLayout->addWidget(new QLabel(tr("Page range"))); + rangeLayout->addWidget(rangeEdit); + mainLayout->addLayout(rangeLayout); + + QHBoxLayout* sheetLayout = new QHBoxLayout(); + sheetLayout->addWidget( new QLabel(tr("Pages per sheet")) ); + sheetLayout->addWidget(persheetCombo); + sheetLayout->addStretch(); + sheetLayout->addWidget(new QLabel(tr("Copies"))); + sheetLayout->addWidget(copiesSpin); + mainLayout->addLayout(sheetLayout); + + mainLayout->addStretch(); + + mainLayout->addWidget(statusLabel); + QHBoxLayout* barLayout = new QHBoxLayout; + barLayout->addWidget(progressBar); + barLayout->addStretch(); + barLayout->addWidget(cancelButton); + barLayout->addWidget(reconnectButton); + barLayout->addWidget(printButton); + mainLayout->addLayout(barLayout); + + setLayout(mainLayout); + + progressBar->setVisible(false); + +} + +void PrintWidget::setStatus(QString message, bool busy) +{ + statusLabel->setText(message); + if(busy) + { + // Busy: show progress bar, enable Cancel, disable others. + progressBar->setVisible(true); + cancelButton->setEnabled(true); + reconnectButton->setEnabled(false); + } + else + { + progressBar->setVisible(false); + reconnectButton->setEnabled(true); + cancelButton->setEnabled(false); + } +} + +void PrintWidget::setPrinters(QStringList printers) +{ + printerCombo->clear(); + if(printers.isEmpty()) + { + printerCombo->setEnabled(false); + } + else + { + printerCombo->addItems(printers); + printerCombo->setEnabled(true); + printerCombo->setCurrentIndex(0); + } +} + +void PrintWidget::setReady(bool ready) +{ + if(ready) + { + setStatus( tr("Ready"), false); + printButton->setEnabled(true); + } + else + printButton->setEnabled(false); +} + + +void PrintWidget::browseFile() +{ + QString path = QFileDialog::getOpenFileName(this, tr("Print file")); + if(!path.isNull()) + filenameEdit->setText(path); + +} + +void PrintWidget::doPrint() +{ + // Make cups lp options + QString options = QString("-d %1 -o number-up=").arg(printerCombo->currentText()); + options.append(persheetCombo->currentText()); + if( !rangeEdit->text().isEmpty()) + options += " -o page-ranges=" + rangeEdit->text(); + if( copiesSpin->value() > 1) + options += QString(" -n %1").arg(copiesSpin->value()); + emit print(filenameEdit->text(), options); +} diff --git a/src/printwidget.h b/src/printwidget.h new file mode 100644 index 0000000..0e72a5f --- /dev/null +++ b/src/printwidget.h @@ -0,0 +1,97 @@ +/************************************************************************** + + URPO + + Unix Remote Printing Operation + Copyright (c) Arto Hyvättinen 2010 + + This file is part of URPO. + + URPO 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 3 of the License, or + (at your option) any later version. + + URPO 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. + + +**************************************************************************/ + +#ifndef PRINTWIDGET_H +#define PRINTWIDGET_H + +#include + +class QLineEdit; +class QPushButton; +class QComboBox; +class QProgressBar; +class QLabel; +class QSpinBox; + +/*! GUI Widget of Urpo printing + + @author Arto Hyvättinen + @date 2010-06-17 + @version 0.1 + + + */ +class PrintWidget : public QWidget +{ + Q_OBJECT +public: + explicit PrintWidget(QWidget *parent = 0); + /*! Set printers + + Set printers and enable printing if printer exists + + @arg printers List of printer names + */ + void setPrinters(QStringList printers); + +signals: + /*! User press Cancel button */ + void cancel(); + /*! User press Reconnect button */ + void reconnect(); + /*! User press Print button */ + void print(QString file, QString options); + +public slots: + /*! Set status information + + @arg message Message to show. Use html tags for red error color + @arg busy Show busy progress bar + */ + void setStatus(QString message=QString(), bool busy=false); + /*! Set ready to print + + Enable print button and set status message to ready + + @arg ready Is ready to print + */ + void setReady(bool ready); + void browseFile(); /*! Press browse button */ + void doPrint(); /*! Press print button */ + void doCancel() { emit cancel(); } /*! Press cancel button */ + + +private: + QLineEdit* filenameEdit; + QPushButton* browseButton; + QComboBox* printerCombo; + QComboBox* persheetCombo; + QLineEdit* rangeEdit; + QSpinBox* copiesSpin; + QPushButton* printButton; + QLabel* statusLabel; + QProgressBar* progressBar; + QPushButton* cancelButton; + QPushButton* reconnectButton; +}; + +#endif // PRINTWIDGET_H diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp new file mode 100644 index 0000000..fa0e278 --- /dev/null +++ b/src/settingsdialog.cpp @@ -0,0 +1,155 @@ +/************************************************************************** + + URPO + + Unix Remote Printing Operation + Copyright (c) Arto Hyvättinen 2010 + + This file is part of URPO. + + URPO 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 3 of the License, or + (at your option) any later version. + + URPO 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. + + +**************************************************************************/ + +#include "settingsdialog.h" + +#include +#include +#include +#include +#include +#include +#include +#include "urpoconnectionsettings.h" + +SettingsDialog::SettingsDialog(QWidget *parent) : + QDialog(parent) +{ + settings_ = 0; + helpWidget_ = 0; + + + setWindowTitle(tr("Urpo Settings")); + + serverEdit = new QLineEdit; + connect(serverEdit, SIGNAL(textChanged(QString)), this, SLOT(serverChanged(QString))); + + userEdit = new QLineEdit; + identityEdit = new QLineEdit; + + browseButton = new QPushButton(tr("Browse")); + connect(browseButton, SIGNAL(clicked()),this,SLOT(browse())); + okButton = new QPushButton(tr("Done")); + connect(okButton, SIGNAL(clicked()), this, SLOT(okay()) ); + okButton->setEnabled(false); + + helpButton = new QPushButton( tr("Help")); + + + QVBoxLayout* mainLayout = new QVBoxLayout; + + QHBoxLayout* helpLayout = new QHBoxLayout; + helpLayout->addWidget( new QLabel(tr("Remote printing utility " + "via ssh and cups. " + "Please read help."))); + helpLayout->addWidget(helpButton); + QGroupBox* helpBox = new QGroupBox(); + helpBox->setLayout(helpLayout); + helpBox->setFlat(false); + mainLayout->addWidget(helpBox); + + + QHBoxLayout* serverLayout = new QHBoxLayout; + serverLayout->addWidget( new QLabel(tr("Host name or ip address"))); + serverLayout->addWidget( serverEdit ); + mainLayout->addLayout(serverLayout); + + QHBoxLayout* userLayout = new QHBoxLayout; + userLayout->addWidget( new QLabel(tr("Username"))); + userLayout->addWidget( userEdit ); + mainLayout->addLayout(userLayout); + + QHBoxLayout* idLayout = new QHBoxLayout; + idLayout->addWidget( new QLabel( tr("Identity file"))); + idLayout->addWidget(identityEdit); + idLayout->addWidget( browseButton); + mainLayout->addLayout(idLayout); + + mainLayout->addStretch(); + + QHBoxLayout* okLayout = new QHBoxLayout; + okLayout->addStretch(); + okLayout->addWidget(okButton); + mainLayout->addLayout(okLayout); + + setLayout(mainLayout); + +} + + +void SettingsDialog::setSettings(UrpoConnectionSettings *settings) +{ + // Init dialog from UrpoConnectionSetting + settings_ = settings; + serverEdit->setText( settings_->getHost()); + userEdit->setText(settings_->getUserid()); + identityEdit->setText(settings_->getIdentity()); + +} + +void SettingsDialog::setHelp(QTextBrowser *helpWidget) +{ + // Set widget activated in help button + helpWidget_ = helpWidget; + connect( helpButton, SIGNAL(clicked()), this, SLOT(showHelp())); +} + +void SettingsDialog::okay() +{ + if( settings_ ) + { + // Store settings + settings_->setHost( serverEdit->text()); + settings_->setUserid( userEdit->text()); + settings_->setIdentity( identityEdit->text()); + + settings_->store(); + + done(QDialog::Accepted); + } + else + done(QDialog::Rejected); +} + +void SettingsDialog::showHelp() +{ + // Activate help window + helpWidget_->home(); + helpWidget_->show(); + helpWidget_->raise(); + helpWidget_->activateWindow(); +} + +void SettingsDialog::serverChanged(const QString& text) +{ + // If there is a server setting, dialog will be accepted + // (if you have same userid in server and ssh key defined...) + + okButton->setDisabled( text.isEmpty() ); +} + +void SettingsDialog::browse() +{ + QString path = QFileDialog::getOpenFileName(this, tr("Identity file")); + if(!path.isNull()) + identityEdit->setText(path); +} diff --git a/src/settingsdialog.h b/src/settingsdialog.h new file mode 100644 index 0000000..b858f9d --- /dev/null +++ b/src/settingsdialog.h @@ -0,0 +1,71 @@ +/************************************************************************** + + URPO + + Unix Remote Printing Operation + Copyright (c) Arto Hyvättinen 2010 + + This file is part of URPO. + + URPO 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 3 of the License, or + (at your option) any later version. + + URPO 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. + + +**************************************************************************/ + +#ifndef SETTINGSDIALOG_H +#define SETTINGSDIALOG_H + +#include +#include +class QLineEdit; +class QPushButton; +class UrpoConnectionSettings; + +/*! GUI dialog for Urpo Setting + + @author Arto Hyvättinen + @date 2010-06-13 + @version 0.1 + + Dialog for settings. Remember to set setSettings() and setHelp(). + Designed for modeless use (in modal can't show help + + */ +class SettingsDialog : public QDialog +{ + Q_OBJECT +public: + explicit SettingsDialog(QWidget *parent = 0); + /*! Set UrpoConnection having connection settings */ + void setSettings(UrpoConnectionSettings* settings); + /*! Set QTextBrowser showing help */ + void setHelp(QTextBrowser* helpWidget); +signals: + +public slots: + void okay(); + void serverChanged(const QString& text); + void browse(); + void showHelp(); + +private: + QLineEdit* serverEdit; + QLineEdit* userEdit; + QLineEdit* identityEdit; + QPushButton* browseButton; + QPushButton* okButton; + QPushButton* helpButton; + UrpoConnectionSettings* settings_; + QTextBrowser* helpWidget_; + +}; + +#endif // SETTINGSDIALOG_H diff --git a/src/urpo.pro b/src/urpo.pro new file mode 100644 index 0000000..a5f0355 --- /dev/null +++ b/src/urpo.pro @@ -0,0 +1,53 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2010-06-11T18:32:51 +# +#------------------------------------------------- + +QT += core gui + +TARGET = urpo +TEMPLATE = app + + +SOURCES += main.cpp\ + urpomainwindow.cpp \ + urpoconnection.cpp \ + urpoconnectionsettings.cpp \ + urpoprocess.cpp \ + urpojob.cpp \ + printerlistjob.cpp \ + cerrdebugmonitor.cpp \ + printwidget.cpp \ + debugconsole.cpp \ + settingsdialog.cpp \ + printjob.cpp + +HEADERS += urpomainwindow.h \ + urpoconnection.h \ + urpoconnectionsettings.h \ + urpoprocess.h \ + urpojob.h \ + printerlistjob.h \ + cerrdebugmonitor.h \ + printwidget.h \ + debugconsole.h \ + settingsdialog.h \ + printjob.h + +CONFIG += mobility +MOBILITY = + +symbian { + TARGET.UID3 = 0xece65166 + # TARGET.CAPABILITY += + TARGET.EPOCSTACKSIZE = 0x14000 + TARGET.EPOCHEAPSIZE = 0x020000 0x800000 +} + +OTHER_FILES += + +RESOURCES += \ + urpo.qrc + +TRANSLATIONS = urpo_fi.ts diff --git a/src/urpo.pro.user b/src/urpo.pro.user new file mode 100644 index 0000000..50516f0 --- /dev/null +++ b/src/urpo.pro.user @@ -0,0 +1,309 @@ + + + + ProjectExplorer.Project.ActiveTarget + 1 + + + ProjectExplorer.Project.EditorSettings + + System + + + + ProjectExplorer.Project.Target.0 + + Desktop + Qt4ProjectManager.Target.DesktopTarget + 0 + 0 + + + + QtProjectManager.QMakeBuildStep + + + + + Qt4ProjectManager.MakeStep + false + + + + 2 + + + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /holvi/arto/ohjelmointi/urpo-0.0/urpo-build-desktop + 2 + 0 + true + + + + + QtProjectManager.QMakeBuildStep + + + + + Qt4ProjectManager.MakeStep + false + + + + 2 + + + Qt4ProjectManager.MakeStep + true + + + + 1 + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /holvi/arto/ohjelmointi/urpo-0.0/urpo-build-desktop + 2 + 0 + true + + 2 + + urpo + Qt4ProjectManager.Qt4RunConfiguration + 2 + + urpo.pro + false + false + + false + false + + + 1 + + + + ProjectExplorer.Project.Target.1 + + Maemo + Qt4ProjectManager.Target.MaemoDeviceTarget + 1 + 0 + + + qmake + QtProjectManager.QMakeBuildStep + + + + Make + Qt4ProjectManager.MakeStep + false + + + + + + Qt4ProjectManager.MaemoPackageCreationStep + + false + /usr/local/bin/urpo + + + 3 + + Make + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /holvi/arto/ohjelmointi/urpo-0.0/urpo-build-maemo + 5 + 9 + true + + + + qmake + QtProjectManager.QMakeBuildStep + + + + Make + Qt4ProjectManager.MakeStep + false + + + + + + Qt4ProjectManager.MaemoPackageCreationStep + + false + /home/opt/urpo + + + 3 + + Make + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /holvi/arto/ohjelmointi/urpo-0.0/urpo-build-maemo + 5 + 9 + true + + 2 + + urpo.pro + New Maemo Run Configuration + Qt4ProjectManager.MaemoRunConfiguration + + + 1 + + 2010-06-18T10:35:02 + + + 1 + + + + ProjectExplorer.Project.Target.2 + + Qt Simulator + Qt4ProjectManager.Target.QtSimulatorTarget + 0 + 0 + + + qmake + QtProjectManager.QMakeBuildStep + + + + Make + Qt4ProjectManager.MakeStep + false + + + + 2 + + Make + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /holvi/arto/ohjelmointi/urpo-0.0/urpo-build-simulator + 4 + 0 + true + + + + qmake + QtProjectManager.QMakeBuildStep + + + + Make + Qt4ProjectManager.MakeStep + false + + + + 2 + + Make + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /holvi/arto/ohjelmointi/urpo-0.0/urpo-build-simulator + 4 + 0 + true + + 2 + + urpo + Qt4ProjectManager.Qt4RunConfiguration + 2 + + urpo.pro + false + false + + false + false + + + 1 + + + + ProjectExplorer.Project.TargetCount + 3 + + + ProjectExplorer.Project.Updater.FileVersion + 4 + + diff --git a/src/urpo.pro.user.1.3 b/src/urpo.pro.user.1.3 new file mode 100644 index 0000000..450d054 --- /dev/null +++ b/src/urpo.pro.user.1.3 @@ -0,0 +1,245 @@ + + + + RunConfiguration0-BaseEnvironmentBase + 2 + + + RunConfiguration0-CommandLineArguments + + + + RunConfiguration0-ProFile + urpo.pro + + + RunConfiguration0-RunConfiguration.name + urpo + + + RunConfiguration0-UseDyldImageSuffix + false + + + RunConfiguration0-UseTerminal + false + + + RunConfiguration0-UserEnvironmentChanges + + + + RunConfiguration0-UserSetName + false + + + RunConfiguration0-UserSetWorkingDirectory + false + + + RunConfiguration0-UserWorkingDirectory + + + + RunConfiguration0-type + Qt4ProjectManager.Qt4RunConfiguration + + + activeRunConfiguration + 0 + + + activebuildconfiguration + Debug + + + buildConfiguration-Debug + + Debug + 0 + 0 + 2 + + + + buildConfiguration-Release + + Release + 0 + 0 + + + + buildconfiguration-Debug-buildstep0 + + Debug + + DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-WltRgqY6FP,guid=04ecfc95bb3bd6fe64c843cb4c132539 + DESKTOP_SESSION=default + DISPLAY=:0.0 + DM_CONTROL=/var/run/xdmctl + GS_LIB=/home/arto/.fonts + GTK2_RC_FILES=/etc/gtk-2.0/gtkrc:/home/arto/.gtkrc-2.0:/home/arto/.gtkrc-2.0-kde4:/home/arto/.kde/share/config/gtkrc-2.0 + GTK_MODULES=canberra-gtk-module + GTK_RC_FILES=/etc/gtk/gtkrc:/home/arto/.gtkrc::/home/arto/.kde/share/config/gtkrc + HOME=/home/arto + KDE_FULL_SESSION=true + KDE_MULTIHEAD=false + KDE_SESSION_UID=1000 + KDE_SESSION_VERSION=4 + LANG=fi_FI.UTF-8 + LD_LIBRARY_PATH=/usr/lib/qtcreator: + LIBGL_DRIVERS_PATH=/usr/lib/fglrx/dri:/usr/lib32/fglrx/dri + LOGNAME=arto + PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games + PWD=/home/arto/Asiakirjat + QTDIR=/usr/share/qt4 + QT_PLUGIN_PATH=/home/arto/.kde/lib/kde4/plugins/:/usr/lib/kde4/plugins/ + SESSION_MANAGER=local/pantteri:@/tmp/.ICE-unix/1475,unix/pantteri:/tmp/.ICE-unix/1475 + SHELL=/bin/bash + SHLVL=0 + SSH_AGENT_PID=1336 + SSH_AUTH_SOCK=/tmp/ssh-pRlSkS1289/agent.1289 + USER=arto + WINDOWPATH=7 + XCURSOR_THEME=oxy-white + XDG_DATA_DIRS=/usr/share:/usr/share:/usr/local/share + XDG_SESSION_COOKIE=cb827d99e40c6d02e87590704bdc168b-1276323128.888201-1168136822 + XDM_MANAGED=method=classic + + + /holvi/arto/ohjelmointi/urpo-0.0/urpo/urpo.pro + -spec + linux-g++ + -r + CONFIG+=debug + + /usr/bin/qmake-qt4 + false + /holvi/arto/ohjelmointi/urpo-0.0/urpo + + + + buildconfiguration-Debug-buildstep1 + + Debug + + DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-WltRgqY6FP,guid=04ecfc95bb3bd6fe64c843cb4c132539 + DESKTOP_SESSION=default + DISPLAY=:0.0 + DM_CONTROL=/var/run/xdmctl + GS_LIB=/home/arto/.fonts + GTK2_RC_FILES=/etc/gtk-2.0/gtkrc:/home/arto/.gtkrc-2.0:/home/arto/.gtkrc-2.0-kde4:/home/arto/.kde/share/config/gtkrc-2.0 + GTK_MODULES=canberra-gtk-module + GTK_RC_FILES=/etc/gtk/gtkrc:/home/arto/.gtkrc::/home/arto/.kde/share/config/gtkrc + HOME=/home/arto + KDE_FULL_SESSION=true + KDE_MULTIHEAD=false + KDE_SESSION_UID=1000 + KDE_SESSION_VERSION=4 + LANG=fi_FI.UTF-8 + LD_LIBRARY_PATH=/usr/lib/qtcreator: + LIBGL_DRIVERS_PATH=/usr/lib/fglrx/dri:/usr/lib32/fglrx/dri + LOGNAME=arto + PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games + PWD=/home/arto/Asiakirjat + QTDIR=/usr/share/qt4 + QT_PLUGIN_PATH=/home/arto/.kde/lib/kde4/plugins/:/usr/lib/kde4/plugins/ + SESSION_MANAGER=local/pantteri:@/tmp/.ICE-unix/1475,unix/pantteri:/tmp/.ICE-unix/1475 + SHELL=/bin/bash + SHLVL=0 + SSH_AGENT_PID=1336 + SSH_AUTH_SOCK=/tmp/ssh-pRlSkS1289/agent.1289 + USER=arto + WINDOWPATH=7 + XCURSOR_THEME=oxy-white + XDG_DATA_DIRS=/usr/share:/usr/share:/usr/local/share + XDG_SESSION_COOKIE=cb827d99e40c6d02e87590704bdc168b-1276323128.888201-1168136822 + XDM_MANAGED=method=classic + + false + + -w + + /usr/bin/make + true + /holvi/arto/ohjelmointi/urpo-0.0/urpo + + + + buildconfiguration-Debug-cleanstep0 + + Debug + true + + clean + + + + + buildconfiguration-Release-buildstep0 + + Release + + + + buildconfiguration-Release-buildstep1 + + Release + + + + buildconfiguration-Release-cleanstep0 + + Release + + + + buildconfigurations + + Debug + Release + + + + buildstep0 + + + + + + + buildstep1 + + + + + + buildsteps + + trolltech.qt4projectmanager.qmake + trolltech.qt4projectmanager.make + + + + cleanstep0 + + + true + + + + cleansteps + + trolltech.qt4projectmanager.make + + + + defaultFileEncoding + System + + + project + + + diff --git a/src/urpo.qrc b/src/urpo.qrc new file mode 100644 index 0000000..80f27a0 --- /dev/null +++ b/src/urpo.qrc @@ -0,0 +1,8 @@ + + + help/gpl.html + help/index_fi.html + help/index.html + urpo_fi.qm + + diff --git a/src/urpo_fi.qm b/src/urpo_fi.qm new file mode 100644 index 0000000000000000000000000000000000000000..569104699c7496d3016569b0da0168bf779ad2e0 GIT binary patch literal 4784 zcma)ATZ|J`82*=Sx83e;SztvJLXO--17(3k6Sizzmdk<&%Vj|@0jBMt9hjY|b15{& zMBj{wiIHH`5CaL(2NOeL!bLGWC{erx#TOrV!F}+7NJv0Uh{o?f(@tADU7%@a&zbYz z|Nr~{L;8Gf)_1o~9RKl&IhPKc`ttf3qPEv4a&{e2>|2UlT}afvpCUK=vA*X&dsfrZ z+w+M!uhO%QOVoReHoW^aQPB2dpo-W$`_D-Tmie5Z-0nZzB>gJzB-Iv;4+5@_T zobvId{~+f|``&+U5G5ztb8mf0)Umq#QtVfvDQ@KPA zdJgOZeQeZ!_Fn6`{_|Yw*(pkA6}L4M#s~^c>^mQR4%wPe_q*CP@Hsi z-o!hp&S-I{Lml|8-dWHcaYQ$B))C_b4%#`&4z}trRz>Wy#;ghJEwM9!9TOj2o%Ki$ zbepkW(+!yuS*uuP@dvSDiSbceH{DHEMoC)}Dy^vGuyl>al|-q0JGsQZio~2Wq}y8L zk|vQHjD@sZnZ$+}^cR)kfHI}(%z^%5;c{VGu8>D{$8}Q8<}3*1&0(wK8t_c6XP(UP zpyiplW_F9gj`PKjga;o#$m`w8yW*hoeKW%Z?LgQ#{c1_nvBpN?sMvHV>fL%SFI^R$ zB#q*{4JAAdMxc4eux4hZ!2+6Sdg*y6TuqinDyyhVrv=r0X&14vJ7 zY*4L69913;B@vAzknclDP>6vBiAs=L`K7mk6ACt4k%_z<)zHEUjs(8#8W-7H9aeYK7HyH5nSTnPNHLeAKQ@V(Pov{T<0q?Nut7ec;UEOcA>H zd-YRK3bt=W@=H7m(6gjq!>2Mp#rxF~sWsn$?Q-05r6}^~z@6Q5b%PZy>6%J<&BUPL z6`hnAHKgVMfnj4far{JDLH*#`55CNAvwFi$ zGvT^w`Z9`aP9Q3n*0e+`1NXd=&J2#3`cY8{x59G{_f|Ap zA5t)YrI%#})5XDI%$2sDFSue6kC+2u$OagXluL^=Z`>H*x|gO{(Z9SOhd1k4X*zP1 z*dR@?GQ_BtG4!mc?2FP$6%h{g3z}~3Rugq)0;)9-q-mgQbSMMRYehAu4g&n--UeT; zf}iT=p}689wzXt4w~0+PXB!zMd`7H(YmMrAHK#gXG)zkIC$Org+E~qeD&?0>h))u< z77@%KuK9p6sxA_(q)&#RAp&?ruc3^OnLLoy57LZsCRbdb!n7@xj}X#!Y7=!bg#SDw zJCBLXlgAZh3W}=kRu^!cj^r~%j;~4F>iM43%F3AyYBT#r@A{)M5_%HfPKRo(peWve zLLqkbHDFo=M*~YbnL-4eD}+7;;mxg|I~J?NWzHUJ9s>G?S~UJH7BXsESu`$HPK)mw z8S8mB+r0SA*;~pv;uEw*LX} + + + + DebugConsole + + + This window shows information for resolving error situations + + Tässä ikkunassa on tietoa, jonka avulla voi selvittää virhetilanteita + + + + PrintJob + + + File %1 not exists. + Tiedostoa %1 ei löydy. + + + + File not found + Tiedostoa ei löydy + + + + Failed copying file + Tiedoston kopiointi epäonnistui + + + + Print failed + Tulostus epäonnistui + + + + Failed deleting file + Tiedoston poistaminen epäonnistui + + + + PrintWidget + + + Browse + Selaa + + + + Print + Tulosta + + + + Cancel + Peruuta + + + + Reconnect + Yhdistä uudelleen + + + + File + Tiedosto + + + + Printer + Tulostin + + + + Page range + Tulostettavat sivut + + + + Pages per sheet + Sivuja arkilla + + + + Copies + Kopioita + + + + Ready + Valmis + + + + Print file + Tulosta tiedosto + + + + PrinterListJob + + + Failed to run ssh client. + ssh-ohjelman suorittaminen epäonnistui. + + + + Failed to connect host + Tietokoneeseen yhdistäminen epäonnistui + + + + Time out or authentication error + Aikakatkaisu tai autentikointivirhe + + + + User cancelled + Peruutettu + + + + Connection failed + Yhteys epäonnistui + + + + SettingsDialog + + + Urpo Settings + Urpon asetukset + + + + Browse + Selaa + + + + Done + Valmis + + + + Help + Ohje + + + + Remote printing utility via ssh and cups. Please read help. + Etätulostus ssh:n ja cups:n avulla. Ole hyvä ja lue ohje. + + + + Host name or ip address + Tietokoneen nimi tai ip-osoite + + + + Username + Käyttäjätunnus + + + + + Identity file + Yksityinen avaintiedosto + + + + UrpoMainWindow + + + Connecting... + Yhdistetään... + + + + Settings + Asetukset + + + + Debug + Debug + + + + Open debug console + Avaa debug-ikkuna + + + + About + Tietoja + + + + About Qt + Tietoja Qt:sta + + + + Help + Ohje + + + + Urpo Help + Urpon ohje + + + + No printers found + Tulostimia ei löytynyt + + + + About Urpo + Tietoja Urposta + + + + <b>Unix Remote Printing Operation %1 </b><p>Copyright &copy; Arto Hyv&auml;ttinen 2010<p>License: General Public License v3 + <b>Etätulostus Unix-järjestelmille %1</b><p>Copyright &copy; Arto Hyvättinen 2010<p>Linsenssoitu General Public License v3 + + + + Printing... + Tulostaa... + + + + UrpoProcess + + + Process exited with code %1 + Prosessi päättyi paluuarvolla %1 + + + + External program calling error + Ohjelman suorittamisessa virhe + + + + Connection error + Yhdistämisessä virhe + + + + Authentication error + Autentikoimisessa virhe + + + + Time out + Aikakatkaisu + + + + User cancelled + Peruttu + + + diff --git a/src/urpoconnection.cpp b/src/urpoconnection.cpp new file mode 100644 index 0000000..c2e91dc --- /dev/null +++ b/src/urpoconnection.cpp @@ -0,0 +1,63 @@ +/************************************************************************** + + URPO + + Unix Remote Printing Operation + Copyright (c) Arto Hyvättinen 2010 + + This file is part of URPO. + + URPO 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 3 of the License, or + (at your option) any later version. + + URPO 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. + + +**************************************************************************/ + +#include "urpoconnection.h" + + +UrpoConnection::UrpoConnection() +{ + debugMonitor_ = 0; +} + +UrpoConnection::~UrpoConnection() +{ + +} + + +QObject* UrpoConnection::getDebugMonitor() const +{ + return debugMonitor_; +} + +void UrpoConnection::setDebugMonitor(QObject *monitor) +{ + debugMonitor_ = monitor; +} + +QString UrpoConnection::getHostString() +{ + // Get string user@host OR host (if userid empty) + QString hostString; + if( !getUserid().isEmpty()) + hostString=getUserid() + "@"; + hostString.append( getHost()); + return hostString; +} + +QString UrpoConnection::getKeyOption() +{ + if( getIdentity().isEmpty()) + return QString(); // No identity + else + return QString("-i ").append(getIdentity() + " "); +} diff --git a/src/urpoconnection.h b/src/urpoconnection.h new file mode 100644 index 0000000..c647de7 --- /dev/null +++ b/src/urpoconnection.h @@ -0,0 +1,102 @@ +/************************************************************************** + + URPO + + Unix Remote Printing Operation + Copyright (c) Arto Hyvättinen 2010 + + This file is part of URPO. + + URPO 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 3 of the License, or + (at your option) any later version. + + URPO 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. + + +**************************************************************************/ + +#ifndef URPOCONNECTION_H +#define URPOCONNECTION_H + + +#include +class QObject; + +/*! Information about ssh connection (abstract) + +@author Arto Hyvättinen +@date 2010-06-11 +@version 1 +@abstract + + + */ +class UrpoConnection +{ +protected: + UrpoConnection(); +public: + virtual ~UrpoConnection(); + + /*! Host name or ip address + + @return Server host name of ip address */ + virtual QString getHost() const = 0; + + /*! Userid in server + + @return userid in server */ + virtual QString getUserid() const = 0; + + /*! Identity file + + ssh identity file (private key) + + @return ssh identity file path */ + virtual QString getIdentity() const = 0; + + /*! Default time out in connection + + Connection fais if connecting or commanding lasts + more than timeout. + + @return default timeout in msecs */ + + + /*! Set Debug monitor + + Debug monitor is QObject receiving debugMsg(QString&) signals. + @param monitor QObject receiving debug messages */ + void setDebugMonitor(QObject* monitor); + + /*! Get pointer to Debug monitor + + Debug monitor is QObject receiving debugMsg(QString&) signals. + @return QObject receiving debug messages */ + QObject* getDebugMonitor() const; + + /*! user@@host -string + + + @return user@@host -string + */ + QString getHostString(); + + /*! Key option needed for ssh + + + @return -i key_file or empty if no keyfile + */ + QString getKeyOption(); + +private: + /*! Receiver for debugMsg(QString&) signals */ + QObject* debugMonitor_; +}; + +#endif // URPOCONNECTION_H diff --git a/src/urpoconnectionsettings.cpp b/src/urpoconnectionsettings.cpp new file mode 100644 index 0000000..d245b43 --- /dev/null +++ b/src/urpoconnectionsettings.cpp @@ -0,0 +1,84 @@ +/************************************************************************** + + URPO + + Unix Remote Printing Operation + Copyright (c) Arto Hyvättinen 2010 + + This file is part of URPO. + + URPO 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 3 of the License, or + (at your option) any later version. + + URPO 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. + + +**************************************************************************/ + +#include "urpoconnectionsettings.h" +#include + + +UrpoConnectionSettings::UrpoConnectionSettings(const QString organization, const QString application) +{ + storePassword_ = false; + organization_ = organization; + application_ = application; +} + +QString UrpoConnectionSettings::getHost() const +{ + return host_; +} + +QString UrpoConnectionSettings::getIdentity() const +{ + return identity_; +} + +QString UrpoConnectionSettings::getUserid() const +{ + return userid_; +} + +void UrpoConnectionSettings::setHost(const QString &host) +{ + host_ = host; +} + +void UrpoConnectionSettings::setIdentity(const QString &identity) +{ + identity_ = identity; +} + +void UrpoConnectionSettings::setUserid(const QString &userid) +{ + userid_ = userid; +} + +void UrpoConnectionSettings::store() const +{ + // Store settings using QSettings + QSettings settings(organization_, application_); + settings.setValue("host",host_); + settings.setValue("userid",userid_); + settings.setValue("identity",identity_); + +} + +void UrpoConnectionSettings::load() +{ + // Load settings using QSettings + QSettings settings(organization_,application_); + + host_ = settings.value("host").toString(); + userid_ = settings.value("userid").toString(); + identity_ = settings.value("identity").toString(); + + +} diff --git a/src/urpoconnectionsettings.h b/src/urpoconnectionsettings.h new file mode 100644 index 0000000..d518a1a --- /dev/null +++ b/src/urpoconnectionsettings.h @@ -0,0 +1,72 @@ +/************************************************************************** + + URPO + + Unix Remote Printing Operation + Copyright (c) Arto Hyvättinen 2010 + + This file is part of URPO. + + URPO 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 3 of the License, or + (at your option) any later version. + + URPO 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. + + +**************************************************************************/ + +#ifndef URPOCONNECTIONSETTINGS_H +#define URPOCONNECTIONSETTINGS_H + +#include "urpoconnection.h" + +/*! Connection information, support storing settings + + Setting are stored/loaded using QSettings + + @author Arto Hyvättinen + @date 2010-06-11 + @version 1 + */ +class UrpoConnectionSettings : public UrpoConnection +{ +public: + /*! + @param organization Organization key for storing settings + @param application Application key for storing settings + */ + UrpoConnectionSettings(const QString organization = QString(), const QString application=QString()); + + + QString getHost() const; + QString getIdentity() const; + QString getUserid() const; + + void setHost(const QString &host); + void setIdentity(const QString &password); + void setUserid(const QString &userid); + + /*! Store settings via QSettings */ + void store() const; + /*! Load settings via QSettings */ + void load(); + +private: + QString host_; /*! Host name or ip address */ + QString identity_; /*! Identity (private key) file path */ + QString userid_; /*! Userid in remote host */ + + bool storePassword_; /*! Allow to store password */ + + QString organization_; /*! Organization key storing settings */ + QString application_; /*! Application key storing settings */ + + +}; + +#endif // URPOCONNECTIONSETTINGS_H diff --git a/src/urpojob.cpp b/src/urpojob.cpp new file mode 100644 index 0000000..726f3e5 --- /dev/null +++ b/src/urpojob.cpp @@ -0,0 +1,65 @@ +/************************************************************************** + + URPO + + Unix Remote Printing Operation + Copyright (c) Arto Hyvättinen 2010 + + This file is part of URPO. + + URPO 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 3 of the License, or + (at your option) any later version. + + URPO 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. + + +**************************************************************************/ + +#include "urpojob.h" + +#include "urpoconnection.h" + +UrpoJob::UrpoJob(UrpoConnection* connection) : + QObject(0) +{ + connection_=connection; + // Connect debug monitor + if( connection_->getDebugMonitor()) + connect(this,SIGNAL(debugMessage(QString)),connection_->getDebugMonitor(),SLOT(debugMessage(QString))); + + status_ = Ready; +} + + +void UrpoJob::sendDebugMessage(QString message) +{ + emit debugMessage(message); +} + +UrpoProcess* UrpoJob::newProcess() +{ + UrpoProcess* process = new UrpoProcess( this ); + // Connect debug monitor + connect( process, SIGNAL(debugMessage(QString)), connection_->getDebugMonitor(), SLOT(debugMessage(QString))); + return process; +} + +void UrpoJob::finish(JobStatus status) +{ + setStatus( status ); + if( status == Successed ) + emit finished(true); + else + emit finished(false); +} + +void UrpoJob::fail(QString errorString) +{ + setStatus( Failed ); + emit finished(false, errorString); +} diff --git a/src/urpojob.h b/src/urpojob.h new file mode 100644 index 0000000..29ae203 --- /dev/null +++ b/src/urpojob.h @@ -0,0 +1,109 @@ +/************************************************************************** + + URPO + + Unix Remote Printing Operation + Copyright (c) Arto Hyvättinen 2010 + + This file is part of URPO. + + URPO 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 3 of the License, or + (at your option) any later version. + + URPO 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. + + +**************************************************************************/ + +#ifndef URPOJOB_H +#define URPOJOB_H + +#include + +#include "urpoprocess.h" +class UrpoConnection; + +/*! Base class for jobs (abstract) + + @author Arto Hyvättinen + @version 0 + @date 2010-06-11 + + + + */ +class UrpoJob : public QObject +{ + Q_OBJECT +public: + explicit UrpoJob(UrpoConnection* connection); + + + enum JobStatus { + Ready, + Running, + Successed, + Failed, + Cancelled + }; + + /*! Job status + + @return Job status (Ready, Running, Successed, Failed + */ + JobStatus getStatus() const { return status_; } + +signals: + void debugMessage(QString message); + /*! Job finished (successed of failed) + + @param successed True if job successed, false if failed */ + void finished(bool successed, QString errorStr = QString()); + +public slots: + /*! Start job */ + void start() { startJob(); } + /*! Cancel job */ + void cancel() { cancelJob(); } + + +protected: + virtual void startJob() = 0; + virtual void cancelJob() = 0; + /*! Finish job + @arg status Job status (Successed, Failed, Cancelled) */ + void finish(JobStatus status); + /*! Finish failed job + + emit finished() with error status and message */ + void fail(QString errorString); + /*! Get connection pointer */ + UrpoConnection* getConnection() { return connection_; } + + /*! Send debug message + + @param message Message to debug monitor + + If debug monitor has been connected, send message to debug monitor + + */ + void sendDebugMessage(QString message); + + /*! Create new UrpoProcess */ + UrpoProcess* newProcess(); + + /*! Set job status */ + void setStatus(JobStatus status) { status_ = status; } + +private: + UrpoConnection* connection_; + JobStatus status_; + +}; + +#endif // URPOJOB_H diff --git a/src/urpomainwindow.cpp b/src/urpomainwindow.cpp new file mode 100644 index 0000000..b251b8a --- /dev/null +++ b/src/urpomainwindow.cpp @@ -0,0 +1,242 @@ +/************************************************************************** + + URPO + + Unix Remote Printing Operation + Copyright (c) Arto Hyvättinen 2010 + + This file is part of URPO. + + URPO 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 3 of the License, or + (at your option) any later version. + + URPO 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. + + +**************************************************************************/ + +#include "urpomainwindow.h" + + +#include "urpoconnectionsettings.h" +#include "printerlistjob.h" +#include "debugconsole.h" +#include "printwidget.h" +#include "printjob.h" + +#include +#include +#include +#include +#include +#include +#include +#include "settingsdialog.h" + +#define VERSION "0.9" /*! Program version */ + +UrpoMainWindow::UrpoMainWindow(QWidget *parent) + : QMainWindow(parent) +{ + setWindowTitle(QString("URPO ") + VERSION ); + + // Load connection settings + settings_ = new UrpoConnectionSettings("Urpo","Urpo"); + settings_->load(); + + // Connect to debug monitor + monitor_ = new DebugConsole(); + settings_->setDebugMonitor(monitor_); + + // Init central widget + printWidget_ = new PrintWidget; + setCentralWidget(printWidget_); + + // Init Help + initHelp(); + // Init menu + initMenu(); + + // Connect buttons + connect( printWidget_, SIGNAL(reconnect()), this, SLOT(getPrinters())); + connect( printWidget_, SIGNAL(print(QString,QString)), this, SLOT(print(QString,QString))); + + // Init jobs + + // Init printers list job to get printers list + printerListJob_ = new PrinterListJob( settings_); + // Connect finished to printersReceives: + // - if success, enable printing + // - if fail, go to Settings dialog + connect( printerListJob_, SIGNAL(finished(bool,QString)), this, SLOT(printersReceived(bool,QString))); + + // Init print job + printJob_ = new PrintJob(settings_); + connect( printJob_, SIGNAL(finished(bool,QString)), this, SLOT(printFinished(bool,QString))); + + if( settings_->getHost().isEmpty()) + // If no host settings, go first to settings + settings(); + else + // Try to get printers list + getPrinters(); + + +} + +UrpoMainWindow::~UrpoMainWindow() +{ + +} + +void UrpoMainWindow::getPrinters() +{ + + printWidget_->setStatus(tr("Connecting..."),true); + connect(printWidget_, SIGNAL(cancel()), printerListJob_, SLOT(cancel())); + printerListJob_->start(); + +} + + +void UrpoMainWindow::initMenu() +{ + + QAction* settingsAction = new QAction( tr("Settings"), this); + connect(settingsAction, SIGNAL(triggered()), this, SLOT(settings()) ); + menuBar()->addAction(settingsAction); + + QAction* debugAction = new QAction( tr("Debug"), this); + debugAction->setStatusTip(tr("Open debug console")); + connect(debugAction, SIGNAL(triggered()), this, SLOT(debugWindow() )); + menuBar()->addAction(debugAction); + + QAction* aboutAction = new QAction( tr("About"), this); + connect(aboutAction, SIGNAL(triggered()), this, SLOT(about())); + menuBar()->addAction(aboutAction); + + QAction* aboutQtAction = new QAction( tr("About Qt"), this ); + connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); + menuBar()->addAction(aboutQtAction); + + + QAction* helpAction = new QAction( tr("Help"), this ); + connect( helpAction, SIGNAL(triggered()), this, SLOT(helpWindow())); + menuBar()->addAction(helpAction); + +} + +void UrpoMainWindow::initHelp() +{ + + // Init help + helpBrowser_ = new QTextBrowser(); + helpBrowser_->setWindowTitle(tr("Urpo Help")); + + // Load help file + // Try to load locale version index_fi etc. + QString language=QLocale::system().name().left(2); + QString helpfilename = QString(":/help/index_") + language + QString(".html"); + + QFile helpfile( helpfilename ); + if( helpfile.exists() ) + helpBrowser_->setSource(QUrl( QString("qrc") + helpfilename )); + else + // Not find, load general + helpBrowser_->setSource(QUrl("qrc:/help/index.html")); + + helpBrowser_->setOpenExternalLinks(true); + +} + +void UrpoMainWindow::printersReceived(bool success, QString error) +{ + // Disconnect cancel button out of printerListJob + disconnect(printWidget_, SIGNAL(cancel()), printerListJob_, SLOT(cancel())); + if(success) + { + // PrinterListJob successed + printWidget_->setPrinters( printerListJob_->getPrinters()); + if( printerListJob_->getPrinters().isEmpty()) + { + // No printers, can't print + printWidget_->setStatus( QString("") + tr("No printers found") + QString(""),false); + printWidget_->setReady(false); + } + else + { + // Ready to print + printWidget_->setReady( true ); + } + + } + else + { + // Unsuccess! + printWidget_->setStatus( QString("") + error + QString("") ); + printWidget_->setReady(false); + } +} + +void UrpoMainWindow::about() +{ + QMessageBox::about(this, tr("About Urpo"), + tr("Unix Remote Printing Operation %1 " + "

Copyright © Arto Hyvättinen 2010" + "

License: General Public License v3" + ).arg(VERSION)); +} + +void UrpoMainWindow::settings() +{ + printWidget_->doCancel(); // Cancel current process + + SettingsDialog* dialog = new SettingsDialog(this); + dialog->setSettings(settings_); + dialog->setHelp(helpBrowser_); + dialog->show(); + + // Dialog done -> get printers + connect( dialog, SIGNAL(accepted()), this, SLOT(getPrinters())); + +} + +void UrpoMainWindow::debugWindow() +{ + monitor_->show(); + monitor_->raise(); + monitor_->activateWindow(); +} + +void UrpoMainWindow::helpWindow() +{ + + // Show help + helpBrowser_->home(); + helpBrowser_->show(); + helpBrowser_->raise(); + helpBrowser_->activateWindow(); +} + +void UrpoMainWindow::print(QString file, QString options) +{ + printWidget_->setStatus( tr("Printing..."), true ); + connect( printWidget_, SIGNAL(cancel()), printJob_, SLOT(cancel())); + printJob_->printFile(file,options); +} + +void UrpoMainWindow::printFinished(bool success, QString errorStr) +{ + disconnect( printWidget_, SIGNAL(cancel()), printJob_, SLOT(cancel())); + printWidget_->setReady(true); // Ready to print again! + if( success == false ) // Error -- set error message! + { + printWidget_->setReady(true); + printWidget_->setStatus( QString("") + errorStr + QString("")); + } +} diff --git a/src/urpomainwindow.h b/src/urpomainwindow.h new file mode 100644 index 0000000..0dc55ae --- /dev/null +++ b/src/urpomainwindow.h @@ -0,0 +1,83 @@ +/************************************************************************** + + URPO + + Unix Remote Printing Operation + Copyright (c) Arto Hyvättinen 2010 + + This file is part of URPO. + + URPO 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 3 of the License, or + (at your option) any later version. + + URPO 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. + + +**************************************************************************/ + +#ifndef URPOMAINWINDOW_H +#define URPOMAINWINDOW_H + +#include + +class PrintWidget; +class PrintJob; +class PrinterListJob; +class UrpoConnectionSettings; +class DebugConsole; +class QTextBrowser; + +/*! GUI class for URPO main window + + @author Arto Hyvättinen + @version 0.1 + @date 2010-06-17 + + */ +class UrpoMainWindow : public QMainWindow +{ + Q_OBJECT + +public: + UrpoMainWindow(QWidget *parent = 0); + ~UrpoMainWindow(); + +public slots: + /*! Populate printer QCombo and enable printing */ + void printersReceived(bool success, QString error); + /*! Start printers getting */ + void getPrinters(); + /*! Show about dialog */ + void about(); + /*! Show settings dialog */ + void settings(); + /*! Show help window */ + void helpWindow(); + /*! Show debug window */ + void debugWindow(); + /*! Print file */ + void print(QString file, QString options); + /*! Print finished, enable buttons */ + void printFinished(bool success, QString errorStr); + +private: + void initMenu(); + void initHelp(); + +private: + PrintWidget* printWidget_; + PrinterListJob* printerListJob_; + PrintJob* printJob_; + UrpoConnectionSettings* settings_; + DebugConsole* monitor_; + QTextBrowser* helpBrowser_; + + +}; + +#endif // URPOMAINWINDOW_H diff --git a/src/urpoprocess.cpp b/src/urpoprocess.cpp new file mode 100644 index 0000000..600e306 --- /dev/null +++ b/src/urpoprocess.cpp @@ -0,0 +1,130 @@ +/************************************************************************** + + URPO + + Unix Remote Printing Operation + Copyright (c) Arto Hyvättinen 2010 + + This file is part of URPO. + + URPO 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 3 of the License, or + (at your option) any later version. + + URPO 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. + + +**************************************************************************/ + +#include "urpoprocess.h" +#include "urpoconnection.h" +#include + + +int const UrpoProcess::DEFAULTTIMEOUT; + +UrpoProcess::UrpoProcess(QObject* parent) : + QObject(parent) +{ + status_ = Ready; + error_ = NoError; + setTimeout( DEFAULTTIMEOUT ); +} + +void UrpoProcess::terminate() +{ + fail(Cancelled); +} + +QStringList UrpoProcess::getOutput() +{ + return output_; +} + +void UrpoProcess::fail(UrpoError error) +{ + status_=Failed; + error_=error; + qprocess_.terminate(); + emit finished(false); + sendDebugMessage( getErrorString() ); +} + + +void UrpoProcess::timeout() +{ + // If process is still running, it means timeout! + if( status_ == Running) + fail(Timeout); +} + +void UrpoProcess::start(const QString &command) +{ + sendDebugMessage(QString("[Running command %1 ]").arg(command)); + + // Process finished handling + connect( &qprocess_, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processFinished(int,QProcess::ExitStatus))); + + // Timer for timeout + // use UrpoConnection's default timeout settings + QTimer::singleShot( getTimeout(), this, SLOT(timeout()) ); + + // Start process + status_ = Running; + + qprocess_.start(command); + +} + +void UrpoProcess::processFinished(int exitCode,QProcess::ExitStatus exitStatus) +{ + if( exitCode) + { + sendDebugMessage( QString( tr("Process exited with code %1") ).arg(exitCode)); + // Get data from ssh server + QByteArray newData = qprocess_.readAllStandardError(); + sendDebugMessage( QString(newData) ); + + fail(ConnectionError); + } + else if( exitStatus == QProcess::CrashExit) + // Process failed + fail(ProcessError); + else + { + // Read output + QByteArray bytes = qprocess_.readAllStandardOutput(); + QString string(bytes); + sendDebugMessage(string); + // Split to lines and store to output_ + output_=string.split("\n"); + status_=Successed; + emit finished(true); + } +} + +QString UrpoProcess::getErrorString() const +{ + switch( getError() ) + { + case NoError: + return QString(); + case ProcessError: + return tr("External program calling error"); + case ConnectionError: + return tr("Connection error"); + case AuthError: + return tr("Authentication error"); + case Timeout: + return tr("Time out"); + case Cancelled: + return tr("User cancelled"); + } + return QString(); +} + + diff --git a/src/urpoprocess.h b/src/urpoprocess.h new file mode 100644 index 0000000..6a3d07a --- /dev/null +++ b/src/urpoprocess.h @@ -0,0 +1,207 @@ +/************************************************************************** + + URPO + + Unix Remote Printing Operation + Copyright (c) Arto Hyvättinen 2010 + + This file is part of URPO. + + URPO 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 3 of the License, or + (at your option) any later version. + + URPO 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. + + +**************************************************************************/ + +#ifndef URPOPROCESS_H +#define URPOPROCESS_H + +#include +#include +#include +class UrpoConnection; + +/*! Process running ssh/scp command + + @author Arto Hyvättinen + @version 0 + @date 2010-06-11 - 2010-06-12 + + Run ssh/scp etc. command. + + Read setting using UrpoConnect settings information object. + Support debug monitoring using debugMessage-signals, monitor defined in settings object + + First, connect finished()-signal. Then, run command. + Command is run asynchronosly. + + @code + ... + // Get list of available printers + + QString command = "ssh "; + command.append(getConnection()->getKeyOption()); + command.append(getConnection()->getHostString()); + command.append(" env LANG=en lpstat -p"); + + process = new UrpoProcess( connect ); + + connect( process, SIGNAL(finished(bool)), this, SLOT( readOutput(bool) ) ); + process.start(command); + + ... + ::readOutput(bool success) + { + if( success ) + { + foreach(QString line, process->getOutput() ) + cout << line << "\n"; + } + else + cout << "Error " << process->getError(); + } + @endcode + + @see UrpoConnect + + */ +class UrpoProcess : public QObject +{ + Q_OBJECT +public: + /*! + @param connection Pointer to connection settings information + */ + explicit UrpoProcess(QObject* parent = 0); + + + enum UrpoStatus { + Ready /*! Ready for connecting */ = 0, + Running /*! Command running */ = 1, + Successed /*! Command successed */ = 2, + Failed /*! Command failed */ = 3 + }; + + enum UrpoError { + NoError /*! No errors happends */ = 0, + ProcessError /*! Error running process */ = 1, + ConnectionError /*! Error connecting host */ = 2, + AuthError /*! Authentication failed */ = 3, + Timeout /*! Timed out */ = 4, + Cancelled /*! User cancelled operation */ = 5 + }; + + /*! Get output of command + @return Output of command, list of QStrings + */ + QStringList getOutput(); + + /*! Run command + + Start process running command. When process finish + (successed/failed), finished() signal will be emitted + + @param command Command to execute + */ + void start(const QString& command); + + /*! Error of process + + If process failed, get error code + @return Error code + */ + UrpoError getError() const { return error_; } + /*! Error of process (in string) + + If process failed, return error string readable by user + + @return Error string + + */ + QString getErrorString() const; + + /*! Process status + + @return Status (Ready, Running, Successed, Failed) + */ + UrpoStatus getStatus() const { return status_; } + + + /*! Send debug message + + @param message Message to debug monitor + + If debug monitor has been connected, send message to debug monitor + + */ + void sendDebugMessage(QString message) { emit debugMessage(message); } + + /*! Set timeout + + Process time out, if running command last more than timeout + + + @param msecs Timeout in msecs + */ + void setTimeout(int msecs) { timeout_=msecs; } + + /*! Return timeout + + @return Timeout in msecs */ + int getTimeout() { return timeout_; } + +signals: + /*! Process finished (successed of failed) + + @param success True if process successed, false if failed + + Emitted when process finished. + Output of process can be reader throught getOutput() */ + void finished(bool success); + /** Send debug messages + + UrpoConnection can set up a debug monitor, a QObject receiving + debugMsg signals. Debug messages contains information about + process output, errors etc. + + @param message Message send to debug monitor */ + void debugMessage(QString message); + +public slots: + /*! Cancel process + + Terminate process. Emit finished(false) signal and set Cancelled error */ + void terminate(); + + /*! SSH client has finished */ + void processFinished(int exitCode,QProcess::ExitStatus exitStatus); + /*! Timeout during connecting */ + void timeout(); + + +protected: + + +private: + + static int const DEFAULTTIMEOUT = 15000; + + void fail(UrpoError error); + + QStringList output_; + + QProcess qprocess_; + + UrpoStatus status_; + UrpoError error_; + int timeout_; /*! Timeout in msecs */ +}; + +#endif // URPOPROCESS_H -- 1.7.9.5