From b529f046c9a64ac5fcfa60747af940cf972b3ebc Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 6 Nov 2011 15:56:34 -0600 Subject: Actually move the kde files that were renamed in the last commit --- tdeprint/tdeprintfax/CMakeLists.txt | 42 ++ tdeprint/tdeprintfax/Makefile.am | 23 + tdeprint/tdeprintfax/anytops | 98 ++++ tdeprint/tdeprintfax/conffax.cpp | 80 +++ tdeprint/tdeprintfax/conffax.h | 40 ++ tdeprint/tdeprintfax/conffilters.cpp | 192 +++++++ tdeprint/tdeprintfax/conffilters.h | 48 ++ tdeprint/tdeprintfax/confgeneral.cpp | 90 ++++ tdeprint/tdeprintfax/confgeneral.h | 43 ++ tdeprint/tdeprintfax/configdlg.cpp | 75 +++ tdeprint/tdeprintfax/configdlg.h | 48 ++ tdeprint/tdeprintfax/confsystem.cpp | 199 ++++++++ tdeprint/tdeprintfax/confsystem.h | 50 ++ tdeprint/tdeprintfax/cr16-action-abentry.png | Bin 0 -> 864 bytes tdeprint/tdeprintfax/defcmds.cpp | 38 ++ tdeprint/tdeprintfax/defcmds.h | 32 ++ tdeprint/tdeprintfax/faxab.cpp | 212 ++++++++ tdeprint/tdeprintfax/faxab.h | 64 +++ tdeprint/tdeprintfax/faxctrl.cpp | 669 +++++++++++++++++++++++++ tdeprint/tdeprintfax/faxctrl.h | 73 +++ tdeprint/tdeprintfax/faxfilters | 3 + tdeprint/tdeprintfax/filterdlg.cpp | 72 +++ tdeprint/tdeprintfax/filterdlg.h | 41 ++ tdeprint/tdeprintfax/hi128-app-tdeprintfax.png | Bin 0 -> 10612 bytes tdeprint/tdeprintfax/hi16-app-tdeprintfax.png | Bin 0 -> 787 bytes tdeprint/tdeprintfax/hi22-app-tdeprintfax.png | Bin 0 -> 1241 bytes tdeprint/tdeprintfax/hi32-app-tdeprintfax.png | Bin 0 -> 1928 bytes tdeprint/tdeprintfax/hi48-app-tdeprintfax.png | Bin 0 -> 3352 bytes tdeprint/tdeprintfax/hi64-app-tdeprintfax.png | Bin 0 -> 4669 bytes tdeprint/tdeprintfax/hisc-app-tdeprintfax.svgz | Bin 0 -> 11876 bytes tdeprint/tdeprintfax/main.cpp | 78 +++ tdeprint/tdeprintfax/tdeprintfax.cpp | 607 ++++++++++++++++++++++ tdeprint/tdeprintfax/tdeprintfax.desktop | 97 ++++ tdeprint/tdeprintfax/tdeprintfax.h | 115 +++++ tdeprint/tdeprintfax/tdeprintfaxui.rc | 31 ++ 35 files changed, 3160 insertions(+) create mode 100644 tdeprint/tdeprintfax/CMakeLists.txt create mode 100644 tdeprint/tdeprintfax/Makefile.am create mode 100755 tdeprint/tdeprintfax/anytops create mode 100644 tdeprint/tdeprintfax/conffax.cpp create mode 100644 tdeprint/tdeprintfax/conffax.h create mode 100644 tdeprint/tdeprintfax/conffilters.cpp create mode 100644 tdeprint/tdeprintfax/conffilters.h create mode 100644 tdeprint/tdeprintfax/confgeneral.cpp create mode 100644 tdeprint/tdeprintfax/confgeneral.h create mode 100644 tdeprint/tdeprintfax/configdlg.cpp create mode 100644 tdeprint/tdeprintfax/configdlg.h create mode 100644 tdeprint/tdeprintfax/confsystem.cpp create mode 100644 tdeprint/tdeprintfax/confsystem.h create mode 100644 tdeprint/tdeprintfax/cr16-action-abentry.png create mode 100644 tdeprint/tdeprintfax/defcmds.cpp create mode 100644 tdeprint/tdeprintfax/defcmds.h create mode 100644 tdeprint/tdeprintfax/faxab.cpp create mode 100644 tdeprint/tdeprintfax/faxab.h create mode 100644 tdeprint/tdeprintfax/faxctrl.cpp create mode 100644 tdeprint/tdeprintfax/faxctrl.h create mode 100644 tdeprint/tdeprintfax/faxfilters create mode 100644 tdeprint/tdeprintfax/filterdlg.cpp create mode 100644 tdeprint/tdeprintfax/filterdlg.h create mode 100644 tdeprint/tdeprintfax/hi128-app-tdeprintfax.png create mode 100644 tdeprint/tdeprintfax/hi16-app-tdeprintfax.png create mode 100644 tdeprint/tdeprintfax/hi22-app-tdeprintfax.png create mode 100644 tdeprint/tdeprintfax/hi32-app-tdeprintfax.png create mode 100644 tdeprint/tdeprintfax/hi48-app-tdeprintfax.png create mode 100644 tdeprint/tdeprintfax/hi64-app-tdeprintfax.png create mode 100644 tdeprint/tdeprintfax/hisc-app-tdeprintfax.svgz create mode 100644 tdeprint/tdeprintfax/main.cpp create mode 100644 tdeprint/tdeprintfax/tdeprintfax.cpp create mode 100644 tdeprint/tdeprintfax/tdeprintfax.desktop create mode 100644 tdeprint/tdeprintfax/tdeprintfax.h create mode 100644 tdeprint/tdeprintfax/tdeprintfaxui.rc (limited to 'tdeprint/tdeprintfax') diff --git a/tdeprint/tdeprintfax/CMakeLists.txt b/tdeprint/tdeprintfax/CMakeLists.txt new file mode 100644 index 000000000..538719474 --- /dev/null +++ b/tdeprint/tdeprintfax/CMakeLists.txt @@ -0,0 +1,42 @@ +################################################# +# +# (C) 2010-2011 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +##### other data ################################ + +tde_install_icons( tdeprintfax ) +tde_install_icons( abentry DESTINATION ${DATA_INSTALL_DIR}/tdeprintfax/icons ) +install( FILES tdeprintfax.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} ) +install( FILES tdeprintfaxui.rc faxfilters DESTINATION ${DATA_INSTALL_DIR}/tdeprintfax ) +install( PROGRAMS anytops DESTINATION ${DATA_INSTALL_DIR}/tdeprintfax ) + + +##### tdeprintfax (executable) ################## + +tde_add_executable( tdeprintfax AUTOMOC + SOURCES + main.cpp tdeprintfax.cpp faxab.cpp faxctrl.cpp + confgeneral.cpp configdlg.cpp conffax.cpp + confsystem.cpp conffilters.cpp filterdlg.cpp + defcmds.cpp + LINK kabc-shared tdeprint-shared + DESTINATION ${BIN_INSTALL_DIR} +) diff --git a/tdeprint/tdeprintfax/Makefile.am b/tdeprint/tdeprintfax/Makefile.am new file mode 100644 index 000000000..cd0d39900 --- /dev/null +++ b/tdeprint/tdeprintfax/Makefile.am @@ -0,0 +1,23 @@ +INCLUDES= $(all_includes) + +bin_PROGRAMS = tdeprintfax +tdeprintfax_SOURCES = main.cpp tdeprintfax.cpp faxab.cpp faxctrl.cpp confgeneral.cpp configdlg.cpp \ + conffax.cpp confsystem.cpp conffilters.cpp filterdlg.cpp defcmds.cpp +tdeprintfax_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_KDECORE) $(LIB_KDEUI) -ltdefx $(LIB_KIO) -lktexteditor +tdeprintfax_LDADD = $(LIB_KDEUI) $(LIB_KIO) $(LIB_KDEPRINT) -lkabc +tdeprintfax_METASOURCES = AUTO + +xdg_apps_DATA = tdeprintfax.desktop + +uidir = $(kde_datadir)/tdeprintfax +ui_DATA = tdeprintfaxui.rc faxfilters + +private_SCRIPTS = anytops +privatedir = $(kde_datadir)/tdeprintfax + +messages: rc.cpp + $(XGETTEXT) `find . -name \*.h -o -name \*.cpp -o -name \*.cc` -o $(podir)/tdeprintfax.pot + +KDE_ICON = tdeprintfax +pic_ICON = abentry +picdir = $(kde_datadir)/tdeprintfax/icons diff --git a/tdeprint/tdeprintfax/anytops b/tdeprint/tdeprintfax/anytops new file mode 100755 index 000000000..9718831dc --- /dev/null +++ b/tdeprint/tdeprintfax/anytops @@ -0,0 +1,98 @@ +#!/bin/sh + +FAXFILTERS=./faxfilters +MIMETYPE= +PAGE="letter" + +usage() { + echo "Usage: anytops [-m ] [--mime=] [-p ] [--help] " + exit $1 +} + +while true; do + case "$1" in + --help) + usage 0 + ;; + -m) + shift + FAXFILTERS="$1" + shift + ;; + --mime=*) + MIMETYPE=${1#--mime=} + shift + ;; + -p) + shift + PAGE="$1" + shift + ;; + -v) + echo "Anytops v1.0: (c) 2001, Michael Goffioul "; + echo "Small script to convert any file type into PS. Part of tdeprintfax." + exit 0 + ;; + *) + break; + ;; + esac +done + +INFILE=$1 +OUTFILE=$2 + +if [ -z "$INFILE" -o -z "$OUTFILE" -o ! -f "$INFILE" ]; then + usage 1; +fi + +if [ -z "$MIMETYPE" ]; then + MAGIC=$KDEDIR + if [ -z "$MAGIC" ]; then + MAGIC=/usr + fi + MAGIC=$MAGIC/share/mimelnk/magic + + if [ ! -f "$MAGIC" ]; then + echo "KDE magic file not found. Check your installation." + exit 1; + fi + + MIMETYPE=`file -b -m $MAGIC "$INFILE" 2> /dev/null` + MIMETYPE=${MIMETYPE%%;*} +fi + +echo "Mime type: $MIMETYPE" +MIMETYPE_BASE=`echo $MIMETYPE | cut -f 1 -d "/"` +MIMETYPE_TYPE=`echo $MIMETYPE | cut -f 2- -d "/"` + +get_command() { + while read mime command; do + mimebase=`echo $mime | cut -f 1 -d "/"` + mimefile=`echo $mime | cut -f 2- -d "/"` + if test "$mimebase" = "$MIMETYPE_BASE" || test "$mimebase" = "*"; then + if test "$mimefile" = "$MIMETYPE_TYPE" || test "$mimefile" = "*"; then + echo $command + break; + fi + fi +# PATTERN=`echo $MIMETYPE | grep $mime` +# if [ "$PATTERN" = "$MIMETYPE" ]; then +# echo $command +# break; +# fi + done +} + +COMMAND=`cat $FAXFILTERS | get_command` + +if [ -z "$COMMAND" ]; then + echo "$MIMETYPE: file type not handled" + exit 1; +fi + +echo "Command: $COMMAND" + +PAGEUP="`echo $PAGE | cut -c 1 | tr [:lower:] [:upper:]``echo $PAGE | cut -c 2-`" +EXECCOMMAND=`echo $COMMAND | sed -e "s,%in,\"$INFILE\"," -e "s,%out,\"$OUTFILE\"," -e "s,%psl,$PAGE," -e "s,%psu,$PAGEUP,"` +eval "$EXECCOMMAND" diff --git a/tdeprint/tdeprintfax/conffax.cpp b/tdeprint/tdeprintfax/conffax.cpp new file mode 100644 index 000000000..1f3b8c3c5 --- /dev/null +++ b/tdeprint/tdeprintfax/conffax.cpp @@ -0,0 +1,80 @@ +/* + * tdeprintfax - a small fax utility + * Copyright (C) 2001 Michael Goffioul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "conffax.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +ConfFax::ConfFax(TQWidget *parent, const char *name) +: TQWidget(parent, name) +{ + m_resolution = new TQComboBox(this); + m_resolution->setMinimumHeight(25); + m_pagesize = new TQComboBox(this); + m_pagesize->setMinimumHeight(25); + m_resolution->insertItem(i18n("High (204x196 dpi)")); + m_resolution->insertItem(i18n("Low (204x98 dpi)")); + m_pagesize->insertItem(i18n("A4")); + m_pagesize->insertItem(i18n("Letter")); + m_pagesize->insertItem(i18n("Legal")); + TQLabel *m_resolutionlabel = new TQLabel(i18n("&Resolution:"), this); + m_resolutionlabel->setBuddy(m_resolution); + TQLabel *m_pagesizelabel = new TQLabel(i18n("&Paper size:"), this); + m_pagesizelabel->setBuddy(m_pagesize); + + TQGridLayout *l0 = new TQGridLayout(this, 3, 2, 10, 10); + l0->setColStretch(1, 1); + l0->setRowStretch(2, 1); + l0->addWidget(m_resolutionlabel, 0, 0); + l0->addWidget(m_pagesizelabel, 1, 0); + l0->addWidget(m_resolution, 0, 1); + l0->addWidget(m_pagesize, 1, 1); +} + +void ConfFax::load() +{ + KConfig *conf = KGlobal::config(); + conf->setGroup("Fax"); + TQString v = conf->readEntry("Page", KGlobal::locale()->pageSize() == TQPrinter::A4 ? "a4" : "letter"); + if (v == "letter") m_pagesize->setCurrentItem(1); + else if (v == "legal") m_pagesize->setCurrentItem(2); + else m_pagesize->setCurrentItem(0); + v = conf->readEntry("Resolution", "High"); + m_resolution->setCurrentItem((v == "Low" ? 1 : 0)); +} + +void ConfFax::save() +{ + KConfig *conf = KGlobal::config(); + conf->setGroup("Fax"); + conf->writeEntry("Resolution", (m_resolution->currentItem() == 0 ? "High" : "Low")); + conf->writeEntry("Page", (m_pagesize->currentItem() == 0 ? "a4" : (m_pagesize->currentItem() == 1 ? "letter" : "legal"))); +} diff --git a/tdeprint/tdeprintfax/conffax.h b/tdeprint/tdeprintfax/conffax.h new file mode 100644 index 000000000..cf76f2b71 --- /dev/null +++ b/tdeprint/tdeprintfax/conffax.h @@ -0,0 +1,40 @@ +/* + * tdeprintfax - a small fax utility + * Copyright (C) 2001 Michael Goffioul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef CONFFAX_H +#define CONFFAX_H + +#include + +class TQComboBox; + +class ConfFax : public TQWidget +{ +public: + ConfFax(TQWidget *parent = 0, const char *name = 0); + + void load(); + void save(); + +private: + TQComboBox *m_resolution, *m_pagesize; +}; + +#endif diff --git a/tdeprint/tdeprintfax/conffilters.cpp b/tdeprint/tdeprintfax/conffilters.cpp new file mode 100644 index 000000000..d32f33ea8 --- /dev/null +++ b/tdeprint/tdeprintfax/conffilters.cpp @@ -0,0 +1,192 @@ +/* + * tdeprintfax - a small fax utility + * Copyright (C) 2001 Michael Goffioul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "conffilters.h" +#include "filterdlg.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +ConfFilters::ConfFilters(TQWidget *parent, const char *name) +: TQWidget(parent, name) +{ + m_filters = new KListView(this); + m_filters->addColumn(i18n("Mime Type")); + m_filters->addColumn(i18n("Command")); + m_filters->setFrameStyle(TQFrame::WinPanel|TQFrame::Sunken); + m_filters->setLineWidth(1); + m_filters->setSorting(-1); + m_filters->header()->setStretchEnabled(true, 1); + connect(m_filters, TQT_SIGNAL(doubleClicked(TQListViewItem*)), TQT_SLOT(slotChange())); + + m_add = new TQPushButton(this); + m_add->setPixmap(BarIcon("filenew")); + m_remove = new TQPushButton(this); + m_remove->setIconSet(BarIconSet("remove")); + m_change = new TQPushButton(this); + m_change->setIconSet(BarIconSet("filter")); + m_up = new TQPushButton(this); + m_up->setIconSet(BarIconSet("up")); + m_down = new TQPushButton(this); + m_down->setIconSet(BarIconSet("down")); + connect(m_add, TQT_SIGNAL(clicked()), TQT_SLOT(slotAdd())); + connect(m_change, TQT_SIGNAL(clicked()), TQT_SLOT(slotChange())); + connect(m_remove, TQT_SIGNAL(clicked()), TQT_SLOT(slotRemove())); + connect(m_up, TQT_SIGNAL(clicked()), TQT_SLOT(slotUp())); + connect(m_down, TQT_SIGNAL(clicked()), TQT_SLOT(slotDown())); + TQToolTip::add(m_add, i18n("Add filter")); + TQToolTip::add(m_change, i18n("Modify filter")); + TQToolTip::add(m_remove, i18n("Remove filter")); + TQToolTip::add(m_up, i18n("Move filter up")); + TQToolTip::add(m_down, i18n("Move filter down")); + + TQHBoxLayout *l0 = new TQHBoxLayout(this, 10, 10); + TQVBoxLayout *l1 = new TQVBoxLayout(0, 0, 0); + l0->addWidget(m_filters, 1); + l0->addLayout(l1, 0); + l1->addWidget(m_add); + l1->addWidget(m_change); + l1->addWidget(m_remove); + l1->addSpacing(10); + l1->addWidget(m_up); + l1->addWidget(m_down); + l1->addStretch(1); + updateButton(); + connect(m_filters, TQT_SIGNAL(selectionChanged ()),TQT_SLOT(updateButton())); +} + +void ConfFilters::load() +{ + TQFile f(locate("data","tdeprintfax/faxfilters")); + if (f.exists() && f.open(IO_ReadOnly)) + { + TQTextStream t(&f); + TQString line; + int p(-1); + TQListViewItem *item(0); + while (!t.eof()) + { + line = t.readLine().stripWhiteSpace(); + if ((p=line.find(TQRegExp("\\s"))) != -1) + { + TQString mime(line.left(p)), cmd(line.right(line.length()-p-1).stripWhiteSpace()); + if (!mime.isEmpty() && !cmd.isEmpty()) + item = new TQListViewItem(m_filters, item, mime, cmd); + } + } + } +} + +void ConfFilters::save() +{ + TQListViewItem *item = m_filters->firstChild(); + TQFile f(locateLocal("data","tdeprintfax/faxfilters")); + if (f.open(IO_WriteOnly)) + { + TQTextStream t(&f); + while (item) + { + t << item->text(0) << ' ' << item->text(1) << endl; + item = item->nextSibling(); + } + } +} + +void ConfFilters::slotAdd() +{ + TQString mime, cmd; + if (FilterDlg::doIt(this, &mime, &cmd)) + if (!mime.isEmpty() && !cmd.isEmpty()) + { + new TQListViewItem(m_filters, m_filters->currentItem(), mime, cmd); + updateButton(); + } + else + KMessageBox::error(this, i18n("Empty parameters.")); +} + +void ConfFilters::slotRemove() +{ + TQListViewItem *item = m_filters->currentItem(); + if (item) + delete item; + updateButton(); +} + +void ConfFilters::slotChange() +{ + TQListViewItem *item = m_filters->currentItem(); + if (item) + { + TQString mime(item->text(0)), cmd(item->text(1)); + if (FilterDlg::doIt(this, &mime, &cmd)) + { + item->setText(0, mime); + item->setText(1, cmd); + } + } +} + +void ConfFilters::slotUp() +{ + TQListViewItem *item = m_filters->currentItem(); + if (item && item->itemAbove()) + { + m_filters->moveItem(item, 0, item->itemAbove()->itemAbove()); + m_filters->setCurrentItem(item); + updateButton(); + } +} + +void ConfFilters::slotDown() +{ + TQListViewItem *item = m_filters->currentItem(); + if (item && item->itemBelow()) + { + m_filters->moveItem(item, 0, item->itemBelow()); + m_filters->setCurrentItem(item); + updateButton(); + } +} + +void ConfFilters::updateButton() +{ + TQListViewItem *item = m_filters->currentItem(); + + bool state=item && item->itemBelow(); + m_remove->setEnabled(item); + m_down->setEnabled(state); + state=item && item->itemAbove(); + m_up->setEnabled(state); + m_change->setEnabled(item); +} + +#include "conffilters.moc" diff --git a/tdeprint/tdeprintfax/conffilters.h b/tdeprint/tdeprintfax/conffilters.h new file mode 100644 index 000000000..871b44bec --- /dev/null +++ b/tdeprint/tdeprintfax/conffilters.h @@ -0,0 +1,48 @@ +/* + * tdeprintfax - a small fax utility + * Copyright (C) 2001 Michael Goffioul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef CONFFILTERS_H +#define CONFFILTERS_H + +#include +#include +class KListView; + +class ConfFilters : public TQWidget +{ + Q_OBJECT +public: + ConfFilters(TQWidget *parent = 0, const char *name = 0); + + void load(); + void save(); +protected slots: + void slotAdd(); + void slotRemove(); + void slotChange(); + void slotUp(); + void slotDown(); + void updateButton(); +private: + KListView *m_filters; + TQPushButton *m_add,*m_remove,*m_up,*m_down,*m_change; +}; + +#endif diff --git a/tdeprint/tdeprintfax/confgeneral.cpp b/tdeprint/tdeprintfax/confgeneral.cpp new file mode 100644 index 000000000..db3ef916a --- /dev/null +++ b/tdeprint/tdeprintfax/confgeneral.cpp @@ -0,0 +1,90 @@ +/* + * tdeprintfax - a small fax utility + * Copyright (C) 2001 Michael Goffioul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "confgeneral.h" + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +ConfGeneral::ConfGeneral(TQWidget *parent, const char *name) +: TQWidget(parent, name) +{ + m_name = new TQLineEdit(this); + m_company = new TQLineEdit(this); + m_number = new TQLineEdit(this); + TQLabel *m_namelabel = new TQLabel(i18n("&Name:"), this); + m_namelabel->setBuddy(m_name); + TQLabel *m_companylabel = new TQLabel(i18n("&Company:"), this); + m_companylabel->setBuddy(m_company); + TQLabel *m_numberlabel = new TQLabel(i18n("N&umber:"), this); + m_numberlabel->setBuddy(m_number); + KSeparator *sep = new KSeparator( this ); + m_replace_int_char = new TQCheckBox( i18n( "Replace international prefix '+' with:" ), this ); + m_replace_int_char_val = new TQLineEdit( this ); + m_replace_int_char_val->setEnabled( false ); + + connect( m_replace_int_char, TQT_SIGNAL( toggled( bool ) ), m_replace_int_char_val, TQT_SLOT( setEnabled( bool ) ) ); + + TQGridLayout *l0 = new TQGridLayout(this, 6, 2, 10, 10); + l0->setColStretch(1, 1); + l0->setRowStretch(5, 1); + l0->addWidget(m_namelabel, 0, 0); + l0->addWidget(m_companylabel, 1, 0); + l0->addWidget(m_numberlabel, 2, 0); + l0->addWidget(m_name, 0, 1); + l0->addWidget(m_company, 1, 1); + l0->addWidget(m_number, 2, 1); + l0->addMultiCellWidget( sep, 3, 3, 0, 1 ); + TQHBoxLayout *l1 = new TQHBoxLayout( this, 0, 10 ); + l0->addMultiCellLayout( l1, 4, 4, 0, 1 ); + l1->addWidget( m_replace_int_char ); + l1->addWidget( m_replace_int_char_val ); +} + +void ConfGeneral::load() +{ + KConfig *conf = KGlobal::config(); + conf->setGroup("Personal"); + m_name->setText(conf->readEntry("Name", getenv("USER"))); + m_number->setText(conf->readEntry("Number")); + m_company->setText(conf->readEntry("Company")); + m_replace_int_char->setChecked( conf->readBoolEntry( "ReplaceIntChar", false ) ); + m_replace_int_char_val->setText( conf->readEntry( "ReplaceIntCharVal" ) ); +} + +void ConfGeneral::save() +{ + KConfig *conf = KGlobal::config(); + conf->setGroup("Personal"); + conf->writeEntry("Name", m_name->text()); + conf->writeEntry("Number", m_number->text()); + conf->writeEntry("Company", m_company->text()); + conf->writeEntry( "ReplaceIntChar", m_replace_int_char->isChecked() ); + conf->writeEntry( "ReplaceIntCharVal", m_replace_int_char_val->text() ); +} diff --git a/tdeprint/tdeprintfax/confgeneral.h b/tdeprint/tdeprintfax/confgeneral.h new file mode 100644 index 000000000..2962b0b0b --- /dev/null +++ b/tdeprint/tdeprintfax/confgeneral.h @@ -0,0 +1,43 @@ +/* + * tdeprintfax - a small fax utility + * Copyright (C) 2001 Michael Goffioul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef CONFGENERAL_H +#define CONFGENERAL_H + +#include + +class TQLineEdit; +class TQCheckBox; + +class ConfGeneral : public TQWidget +{ +public: + ConfGeneral(TQWidget *parent = 0, const char *name = 0); + + void load(); + void save(); + +private: + TQLineEdit *m_name, *m_company, *m_number; + TQCheckBox *m_replace_int_char; + TQLineEdit *m_replace_int_char_val; +}; + +#endif diff --git a/tdeprint/tdeprintfax/configdlg.cpp b/tdeprint/tdeprintfax/configdlg.cpp new file mode 100644 index 000000000..526b767ff --- /dev/null +++ b/tdeprint/tdeprintfax/configdlg.cpp @@ -0,0 +1,75 @@ +/* + * tdeprintfax - a small fax utility + * Copyright (C) 2001 Michael Goffioul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "configdlg.h" +#include "confgeneral.h" +#include "conffax.h" +#include "confsystem.h" +#include "conffilters.h" + +#include +#include +#include + +ConfigDlg::ConfigDlg(TQWidget *parent, const char *name) +: KDialogBase(IconList, i18n("Configuration"), Ok|Cancel, Ok, parent, name, true) +{ + TQVBox *page1 = addVBoxPage(i18n("Personal"), i18n("Personal Settings"), DesktopIcon("kdmconfig")); + m_general = new ConfGeneral(page1, "Personal"); + + TQVBox *page2 = addVBoxPage(i18n("Page setup"), i18n("Page Setup"), DesktopIcon("editcopy")); + m_fax = new ConfFax(page2, "Fax"); + + TQVBox *page3 = addVBoxPage(i18n("System"), i18n("Fax System Selection"), DesktopIcon("tdeprintfax")); + m_system = new ConfSystem(page3, "System"); + + TQVBox *page4 = addVBoxPage(i18n("Filters"), i18n("Filters Configuration"), DesktopIcon("filter")); + m_filters = new ConfFilters(page4, "Filters"); + + resize(450, 300); +} + +void ConfigDlg::load() +{ + m_general->load(); + m_fax->load(); + m_system->load(); + m_filters->load(); +} + +void ConfigDlg::save() +{ + m_general->save(); + m_fax->save(); + m_system->save(); + m_filters->save(); +} + +bool ConfigDlg::configure(TQWidget *parent) +{ + ConfigDlg dlg(parent); + dlg.load(); + if (dlg.exec()) + { + dlg.save(); + return true; + } + return false; +} diff --git a/tdeprint/tdeprintfax/configdlg.h b/tdeprint/tdeprintfax/configdlg.h new file mode 100644 index 000000000..6fabd2011 --- /dev/null +++ b/tdeprint/tdeprintfax/configdlg.h @@ -0,0 +1,48 @@ +/* + * tdeprintfax - a small fax utility + * Copyright (C) 2001 Michael Goffioul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef CONFIGDLG_H +#define CONFIGDLG_H + +#include + +class ConfGeneral; +class ConfFax; +class ConfSystem; +class ConfFilters; + +class ConfigDlg : public KDialogBase +{ +public: + static bool configure(TQWidget *parent = 0); + +protected: + ConfigDlg(TQWidget *parent = 0, const char *name = 0); + void load(); + void save(); + +private: + ConfGeneral *m_general; + ConfFax *m_fax; + ConfSystem *m_system; + ConfFilters *m_filters; +}; + +#endif diff --git a/tdeprint/tdeprintfax/confsystem.cpp b/tdeprint/tdeprintfax/confsystem.cpp new file mode 100644 index 000000000..91c23adb6 --- /dev/null +++ b/tdeprint/tdeprintfax/confsystem.cpp @@ -0,0 +1,199 @@ +/* + * tdeprintfax - a small fax utility + * Copyright (C) 2001 Michael Goffioul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "confsystem.h" +#include "defcmds.h" + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#define EFAX_ID 0 +#define HYLAFAX_ID 1 +#define MGETTY_ID 2 +#define OTHER_ID 3 + +ConfSystem::ConfSystem(TQWidget *parent, const char *name) +: TQWidget(parent, name) +{ + m_system = new TQComboBox(this); + m_system->insertItem("EFax"); + m_system->insertItem("HylaFax"); + m_system->insertItem("Mgetty-sendfax"); + m_system->insertItem( "Other" ); + m_command = new TQLineEdit(this); + TQLabel *syslabel = new TQLabel(i18n("F&ax system:"), this); + TQLabel *cmdlabel = new TQLabel(i18n("Co&mmand:"), this); + syslabel->setBuddy(m_system); + cmdlabel->setBuddy(m_command); + connect(m_system, TQT_SIGNAL(activated(int)), TQT_SLOT(slotSystemChanged(int))); + m_current = 0; + m_system->setCurrentItem(m_current); + + TQWidget *m_dummy1 = new TQWidget(this), *m_dummy2 = new TQWidget(this); + m_server = new TQLineEdit(m_dummy1); + m_device = new TQComboBox(m_dummy2); + TQLabel *srvlabel = new TQLabel(i18n("Fax &server (if any):"), m_dummy1); + TQLabel *devlabel = new TQLabel(i18n("&Fax/Modem device:"), m_dummy2); + srvlabel->setBuddy(m_server); + devlabel->setBuddy(m_device); + m_device->insertItem(i18n("Standard Modem Port")); + for (int i=0; i<10; i++) + m_device->insertItem(TQString(i18n("Serial Port #%1").arg(i))); + m_device->insertItem( i18n( "Other" ) ); + connect( m_device, TQT_SIGNAL( activated( int ) ), TQT_SLOT( slotDeviceChanged( int ) ) ); + m_device_edit = new TQLineEdit( m_dummy2 ); + slotDeviceChanged( 0 ); + + KSeparator *sep = new KSeparator(this); + sep->setMinimumHeight(10); + + TQVBoxLayout *l0 = new TQVBoxLayout(this, 10, 10); + TQGridLayout *l1 = new TQGridLayout(0, 2, 2, 0, 10); + l0->addLayout(TQT_TQLAYOUT(l1)); + l1->setColStretch(1, 1); + l1->addWidget(syslabel, 0, 0); + l1->addWidget(cmdlabel, 1, 0); + l1->addWidget(m_system, 0, 1); + l1->addWidget(m_command, 1, 1); + l0->addWidget(sep); + l0->addWidget(m_dummy1); + l0->addWidget(m_dummy2); + l0->addStretch(1); + TQHBoxLayout *l4 = new TQHBoxLayout(m_dummy1, 0, 10); + l4->addWidget(srvlabel, 0); + l4->addWidget(m_server, 1); + TQGridLayout *l5 = new TQGridLayout( m_dummy2, 2, 2, 0, 10 ); + l5->setColStretch( 1, 1 ); + l5->addWidget(devlabel, 0, 0); + l5->addWidget(m_device, 0, 1); + l5->addWidget( m_device_edit, 1, 1 ); +} + +void ConfSystem::load() +{ + KConfig *conf = KGlobal::config(); + conf->setGroup("System"); + m_commands << conf->readPathEntry("EFax", defaultCommand(efax_default_cmd)); + m_commands << conf->readPathEntry("HylaFax", defaultCommand(hylafax_default_cmd)); + m_commands << conf->readPathEntry("Mgetty", defaultCommand(mgetty_default_cmd)); + m_commands << conf->readPathEntry( "Other", TQString::null ); + TQString v = conf->readEntry("System", "efax"); + if (v == "mgetty") m_current = MGETTY_ID; + else if (v == "hylafax") m_current = HYLAFAX_ID; + else if ( v == "other" ) m_current = OTHER_ID; + else m_current = EFAX_ID; + conf->setGroup("Fax"); + m_server->setText(conf->readEntry("Server", getenv("FAXSERVER"))); + v = conf->readEntry("Device", "modem"); + if (v.startsWith("ttyS")) + m_device->setCurrentItem(v.right(v.length()-4).toInt()+1); + else if ( v == "modem" ) + m_device->setCurrentItem(0); + else + { + m_device->setCurrentItem( m_device->count()-1 ); + m_device_edit->setText( "/dev/" + v ); + slotDeviceChanged( m_device->count()-1 ); + } + + m_system->setCurrentItem(m_current); + m_command->setText(m_commands[m_current]); + slotSystemChanged(m_current); +} + +void ConfSystem::save() +{ + m_commands[ m_current ] = m_command->text(); + KConfig *conf = KGlobal::config(); + conf->setGroup("System"); + if (m_commands[EFAX_ID] != defaultCommand(efax_default_cmd)) + conf->writePathEntry("EFax", m_commands[EFAX_ID]); + else + conf->deleteEntry("EFax"); + if (m_commands[HYLAFAX_ID] != defaultCommand(hylafax_default_cmd)) + conf->writePathEntry("HylaFax", m_commands[HYLAFAX_ID]); + else + conf->deleteEntry("HylaFax"); + if (m_commands[MGETTY_ID] != defaultCommand(mgetty_default_cmd)) + conf->writePathEntry("Mgetty", m_commands[MGETTY_ID]); + else + conf->deleteEntry("Mgetty"); + if ( !m_commands[ OTHER_ID ].isEmpty() ) + conf->writeEntry( "Other", m_commands[ OTHER_ID ] ); + else + conf->deleteEntry( "Other" ); + int ID = m_system->currentItem(); + switch (ID) + { + case EFAX_ID: conf->writeEntry("System", "efax"); break; + case HYLAFAX_ID: conf->writeEntry("System", "hylafax"); break; + case MGETTY_ID: conf->writeEntry("System", "mgetty"); break; + case OTHER_ID: conf->writeEntry( "System", "other" ); break; + } + conf->setGroup("Fax"); + if ( m_device->currentItem() != ( m_device->count()-1 ) ) + conf->writeEntry("Device", m_device->currentItem() == 0 ? TQString("modem") : TQString(TQString("ttyS%1").arg(m_device->currentItem()-1))); + else + { + TQString dev = m_device_edit->text(); + // strip leading "/dev/" + if ( dev.startsWith( "/dev/" ) ) + dev = dev.mid( 5 ); + conf->writeEntry( "Device", dev ); + } + if (m_server->text().isEmpty()) + conf->deleteEntry("Server"); + else + conf->writeEntry("Server", m_server->text()); +} + +void ConfSystem::slotSystemChanged(int ID) +{ + m_commands[m_current] = m_command->text(); + m_current = ID; + if (ID == EFAX_ID) + m_device->parentWidget()->show(); + else + m_device->parentWidget()->hide(); + if (ID == HYLAFAX_ID) + m_server->parentWidget()->show(); + else + m_server->parentWidget()->hide(); + m_command->setText(m_commands[m_current]); +} + +void ConfSystem::slotDeviceChanged( int ID ) +{ + if ( ID != ( m_device->count()-1 ) ) + m_device_edit->hide(); + else + m_device_edit->show(); +} + +#include "confsystem.moc" diff --git a/tdeprint/tdeprintfax/confsystem.h b/tdeprint/tdeprintfax/confsystem.h new file mode 100644 index 000000000..0ce8971f0 --- /dev/null +++ b/tdeprint/tdeprintfax/confsystem.h @@ -0,0 +1,50 @@ +/* + * tdeprintfax - a small fax utility + * Copyright (C) 2001 Michael Goffioul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef CONFSYSTEM_H +#define CONFSYSTEM_H + +#include +#include + +class TQLineEdit; +class TQComboBox; + +class ConfSystem : public TQWidget +{ + Q_OBJECT +public: + ConfSystem(TQWidget *parent = 0, const char *name = 0); + + void load(); + void save(); + +protected slots: + void slotSystemChanged(int); + void slotDeviceChanged(int); + +private: + TQComboBox *m_system, *m_device; + TQLineEdit *m_command, *m_server, *m_device_edit; + TQStringList m_commands; + int m_current; +}; + +#endif diff --git a/tdeprint/tdeprintfax/cr16-action-abentry.png b/tdeprint/tdeprintfax/cr16-action-abentry.png new file mode 100644 index 000000000..b6b1011f3 Binary files /dev/null and b/tdeprint/tdeprintfax/cr16-action-abentry.png differ diff --git a/tdeprint/tdeprintfax/defcmds.cpp b/tdeprint/tdeprintfax/defcmds.cpp new file mode 100644 index 000000000..a2d58c17e --- /dev/null +++ b/tdeprint/tdeprintfax/defcmds.cpp @@ -0,0 +1,38 @@ +/* + * This file is part of the KDE libraries + * Copyright (c) 2001 Michael Goffioul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + **/ + +#include "defcmds.h" + +#include +#include + +TQString defaultCommand(const TQString& cmd) +{ + TQString str(cmd); + TQRegExp r("%exe_(\\w+)"); + int p(-1); + if ((p=r.search(str)) != -1) + { + TQString exe = KStandardDirs::findExe(r.cap(1)); + if (exe.isEmpty()) + exe = "/usr/bin/"+r.cap(1); + str.replace(p, r.matchedLength(), exe); + } + return str; +} diff --git a/tdeprint/tdeprintfax/defcmds.h b/tdeprint/tdeprintfax/defcmds.h new file mode 100644 index 000000000..90d67b83f --- /dev/null +++ b/tdeprint/tdeprintfax/defcmds.h @@ -0,0 +1,32 @@ +/* + * tdeprintfax - a small fax utility + * Copyright (C) 2001 Michael Goffioul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef DEFCMDS_H +#define DEFCMDS_H + +#include + +#define efax_default_cmd "%exe_fax %user_{NAME=\"@@\"} %dev_{DEV=@@} PAGE=%page %from_{FROM=\"@@\"} %res_{?\?-l} send %number %files" +#define hylafax_default_cmd "%exe_sendfax %cover_{?\?-n} %server_h %res_{-m?\?-l} %subject_r %time_a %enterprise_x %comment_c %email_f %from_W %page_s -d %name_{@@@}%number %files" +#define mgetty_default_cmd "%exe_faxspool %user_F %email_f %name_D %time_t %number %files %res_{?\?-n} %cover_{?\?-C -}" + +TQString defaultCommand(const TQString& cmd); + +#endif diff --git a/tdeprint/tdeprintfax/faxab.cpp b/tdeprint/tdeprintfax/faxab.cpp new file mode 100644 index 000000000..ad50ac9fb --- /dev/null +++ b/tdeprint/tdeprintfax/faxab.cpp @@ -0,0 +1,212 @@ +/* + * tdeprintfax - a small fax utility + * Copyright (C) 2001 Michael Goffioul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "faxab.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +FaxAB::FaxAB(TQWidget *parent, const char *name) +: KDialog(parent, name, true) +{ + m_list = new KListView( this ); + m_list->addColumn( i18n( "Name" ) ); + m_list->addColumn( i18n( "Fax Number" ) ); + m_list->header()->setStretchEnabled( true, 0 ); + TQLabel *m_listlabel = new TQLabel(i18n("Entries:"), this); + m_ok = new KPushButton(KStdGuiItem::ok(), this); + TQPushButton *m_cancel = new KPushButton(KStdGuiItem::cancel(), this); + TQPushButton *m_ab = new KPushButton(KGuiItem(i18n("&Edit Addressbook"), "contents"), this); + connect(m_ok, TQT_SIGNAL(clicked()), TQT_SLOT(accept())); + connect(m_cancel, TQT_SIGNAL(clicked()), TQT_SLOT(reject())); + connect(m_ab, TQT_SIGNAL(clicked()), TQT_SLOT(slotEditAb())); + m_ok->setDefault(true); + + TQVBoxLayout *l0 = new TQVBoxLayout(this, 10, 10); + l0->addWidget( m_listlabel ); + l0->addWidget( m_list ); + TQHBoxLayout *l2 = new TQHBoxLayout(0, 0, 10); + l0->addLayout(l2, 0); + l2->addWidget(m_ab, 0); + l2->addStretch(1); + l2->addWidget(m_ok, 0); + l2->addWidget(m_cancel, 0); + + KConfig *conf = KGlobal::config(); + conf->setGroup( "General" ); + TQSize defsize( 400, 200 ); + resize( conf->readSizeEntry( "ABSize", &defsize ) ); + + initialize(); + connect(KABC::StdAddressBook::self(), TQT_SIGNAL(addressBookChanged(AddressBook*)), TQT_SLOT(slotAbChanged(AddressBook*))); +} + +FaxAB::~FaxAB() +{ + KConfig *conf = KGlobal::config(); + conf->setGroup( "General" ); + conf->writeEntry( "ABSize", size() ); +} + +void FaxAB::initialize() +{ + m_entries.clear(); + m_list->clear(); + + KABC::AddressBook *bk = KABC::StdAddressBook::self(); + for (KABC::AddressBook::Iterator it=bk->begin(); it!=bk->end(); ++it) + { + KABC::PhoneNumber::List numbers = (*it).phoneNumbers(); + KABC::PhoneNumber::List faxNumbers; + for (TQValueList::Iterator nit=numbers.begin(); nit!=numbers.end(); ++nit) + { + if (((*nit).type() & KABC::PhoneNumber::Fax) && !(*nit).number().isEmpty()) + faxNumbers << ( *nit ); + } + if (faxNumbers.count() > 0) + { + for ( KABC::PhoneNumber::List::ConstIterator nit = faxNumbers.begin(); nit != faxNumbers.end(); ++nit ) + { + FaxABEntry entry; + entry.m_number = ( *nit ); + entry.m_enterprise = ( *it ).organization(); + if ( !( *it ).formattedName().isEmpty() ) + entry.m_name = ( *it ).formattedName(); + else + { + TQString key = ( *it ).familyName(); + if ( !( *it ).givenName().isEmpty() ) + { + if ( !key.isEmpty() ) + key.append( " " ); + key.append( ( *it ).givenName() ); + } + entry.m_name = key; + } + entry.m_name += ( " (" + ( *nit ).typeLabel() + ")" ); + m_entries[ entry.m_name ] = entry; + } + } + } + + if (m_entries.count() > 0) + { + for (TQMap::ConstIterator it=m_entries.begin(); it!=m_entries.end(); ++it) + { + TQCheckListItem *item = new TQCheckListItem( m_list, it.key(), TQCheckListItem::CheckBox ); + item->setText( 1, ( *it ).m_number.number() ); + item->setText( 2, ( *it ).m_enterprise ); + } + m_list->sort(); + m_ok->setEnabled(true); + } + else + m_ok->setDisabled(true); +} + +void FaxAB::slotEditAb() +{ + KRun::runCommand("kaddressbook"); +} + +void FaxAB::slotAbChanged(AddressBook*) +{ + initialize(); +} + +bool FaxAB::getEntry(TQStringList& number, TQStringList& name, TQStringList& enterprise, TQWidget *parent) +{ + FaxAB kab(parent); + if (!kab.isValid()) + { + KMessageBox::error(parent, i18n("No fax number found in your address book.")); + return false; + } + if (kab.exec()) + { + TQListViewItemIterator it( kab.m_list, TQListViewItemIterator::Checked ); + while ( it.current() ) + { + number << it.current()->text( 1 ); + name << it.current()->text( 0 ); + enterprise << it.current()->text( 2 ); + ++it; + } + /* + number = kab.m_fax->currentText(); + name = kab.m_name->currentText(); + if (kab.m_entries.contains(name)) + { + enterprise = kab.m_entries[name][0]; + } + */ + return true; + } + + return false; +} + +bool FaxAB::getEntryByNumber(const TQString& number, TQString& name, TQString& enterprise) +{ + KABC::AddressBook *bk = KABC::StdAddressBook::self(); + for (KABC::AddressBook::Iterator it=bk->begin(); it!=bk->end(); ++it) + { + KABC::PhoneNumber::List numbers = (*it).phoneNumbers(); + TQStringList filteredNumbers; + for (TQValueList::Iterator nit=numbers.begin(); nit!=numbers.end(); ++nit) + { + if (((*nit).type() & KABC::PhoneNumber::Fax) ) + { + TQString strippedNumber; + for (uint i = 0; i < (*nit).number().length(); ++i) + if ((*nit).number()[i].isDigit() || ( *nit ).number()[ i ] == '+') + strippedNumber.append((*nit).number()[i]); + + if ( strippedNumber == number) + { + enterprise = (*it).organization(); + name = (*it).formattedName(); + return true; + } + } + } + } + + return false; +} + +bool FaxAB::isValid() +{ + return true; + //return (m_name->count() > 0); +} + +#include "faxab.moc" diff --git a/tdeprint/tdeprintfax/faxab.h b/tdeprint/tdeprintfax/faxab.h new file mode 100644 index 000000000..8b50c204a --- /dev/null +++ b/tdeprint/tdeprintfax/faxab.h @@ -0,0 +1,64 @@ +/* + * tdeprintfax - a small fax utility + * Copyright (C) 2001 Michael Goffioul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef FAXAB_H +#define FAXAB_H + +#include +#include +#include +#include + +class KListView; +class AddressBook; +class TQPushButton; + +class FaxAB : public KDialog +{ + Q_OBJECT +public: + FaxAB(TQWidget *parent = 0, const char *name = 0); + ~FaxAB(); + bool isValid(); + + static bool getEntry(TQStringList& number, TQStringList& name, TQStringList& enterprise, TQWidget *parent = 0); + static bool getEntryByNumber(const TQString& number, TQString& name, TQString& enterprise); + +protected slots: + void slotEditAb(); + void slotAbChanged(AddressBook*); + +protected: + void initialize(); + +private: + struct FaxABEntry + { + TQString m_name; + KABC::PhoneNumber m_number; + TQString m_enterprise; + }; + + KListView* m_list; + TQMap m_entries; + TQPushButton* m_ok; +}; + +#endif diff --git a/tdeprint/tdeprintfax/faxctrl.cpp b/tdeprint/tdeprintfax/faxctrl.cpp new file mode 100644 index 000000000..c1b1b1a0d --- /dev/null +++ b/tdeprint/tdeprintfax/faxctrl.cpp @@ -0,0 +1,669 @@ +/* + * tdeprintfax - a small fax utility + * Copyright (C) 2001 Michael Goffioul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "faxctrl.h" +#include "tdeprintfax.h" +#include "defcmds.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#define quote(x) KProcess::quote(x) + +/** \brief Return a string for the page size. + * + * @param size the page size, which is actually of type @c TQPrinter::PageSize + * @return a pointer to a static string for the name of the page size. + */ +char const* pageSizeText(int size) +{ + switch(size) + { + case TQPrinter::A4: return "a4"; + case TQPrinter::Legal: return "legal"; + case TQPrinter::Letter: return "letter"; + default: return "letter"; + } +} + +/** \brief Return the default page size. + */ +static TQString pageSize() +{ + KConfig *conf = KGlobal::config(); + conf->setGroup("Fax"); + return conf->readEntry("Page", pageSizeText(KGlobal::locale()->pageSize())); +} + +static TQString stripNumber( const TQString& s ) +{ + KConfig *conf = KGlobal::config(); + conf->setGroup( "Personal" ); + + // removes any non-numeric character, except ('+','*','#') (hope it's supported by faxing tools) + TQString strip_s = s; + strip_s.replace( TQRegExp( "[^\\d+*#]" ), "" ); + if ( strip_s.find( '+' ) != -1 && conf->readBoolEntry( "ReplaceIntChar", false ) ) + strip_s.replace( "+", conf->readEntry( "ReplaceIntCharVal" ) ); + return strip_s; +} + +static TQString tagList( int n, ... ) +{ + TQString t; + + va_list ap; + va_start( ap, n ); + for ( int i=0; i%name_{iftrue??iffalse}. Either + * @em iftrue or @em iffalse can be empty (or both, but that would + * be silly). For example, if the fax software uses the + * option @c -l for low resolution, you might use %res_{??-l}, + * and if it uses high resolution, use %res_{-h??}. As an + * abbreviation, omit the trailing ?, e.g., %res_{-h}. + * + * By the way, when using multiple, adjacent question marks, + * always be careful about inadvertently using trigraphs. + * Always escape the second and subsequent question marks, to be safe. + * I suppose question marks are not the best string to use, + * but I think they work well for the end-user. + * + * @param match the string to process + * @param value the Boolean value to control the processing + * @return the new value of the tag + */ +static TQString processTag( const TQString& match, bool value) +{ + TQString v; + int p = match.find( '_' ); + if ( p != -1 && match[ p+1 ] == '{' ) + { + // Find the ?? that separates the iftrue from the iffalse parts. + int q = match.find( "?\?", p+2 ); + if ( q == -1 ) + { + // No iffalse part + if (value) + v = match.mid( p+2 ); + // else value is false, so leave v empty. + } + else if ( value ) + // Extract only the iftrue part + v = match.mid( p+2, q-p-2 ); + else + // Extract only the iffalse part + v = match.mid( q+2, match.length()-q-3 ); + } + // Else the string is malformed: no _ or no { after the _ + // In either case, there isn't much the program can do, + // so just leave the result string empty. + + return v; +} + +static TQString processTag( const TQString& match, const TQString& value ) +{ + TQString v; + int p = match.find( '_' ); + if ( p != -1 ) + { + if ( value.isEmpty() ) + v = ""; + else + { + if ( match[ p+1 ] == '{' ) + { + v = match.mid( p+2, match.length()-p-3 ); + v.replace( "@@", quote( value ) ); + } + else + v = ( "-" + match.mid( p+1 ) + " " + quote( value ) ); + } + } + else + v = quote( value ); + return v; +} + +static bool isTag( const TQString& m, const TQString& t ) +{ + return ( m == t || m.startsWith( t+"_" ) ); +} + +static TQString replaceTags( const TQString& s, const TQString& tags, KdeprintFax *fax = NULL, const KdeprintFax::FaxItem& item = KdeprintFax::FaxItem() ) +{ + // unquote variables (they will be replaced with quoted values later) + + TQValueStack stack; + KConfig *conf = KGlobal::config(); + + TQString cmd = s; + + bool issinglequote=false; + bool isdoublequote=false; + TQRegExp re_noquote("(\\$\\(|\\)|\\(|\"|'|\\\\|`|"+tags+")"); + TQRegExp re_singlequote("('|"+tags+")"); + TQRegExp re_doublequote("(\\$\\(|\"|\\\\|`|"+tags+")"); + for ( int i = re_noquote.search(cmd); + i != -1; + i = (issinglequote?re_singlequote.search(cmd,i) + :isdoublequote?re_doublequote.search(cmd,i) + :re_noquote.search(cmd,i)) + ) + { + if (cmd[i]=='(') // (...) + { + // assert(isdoublequote == false) + stack.push(isdoublequote); + i++; + } + else if (cmd[i]=='$') // $(...) + { + stack.push(isdoublequote); + isdoublequote = false; + i+=2; + } + else if (cmd[i]==')') // $(...) or (...) + { + if (!stack.isEmpty()) + isdoublequote = stack.pop(); + else + qWarning("Parse error."); + i++; + } + else if (cmd[i]=='\'') + { + issinglequote=!issinglequote; + i++; + } + else if (cmd[i]=='"') + { + isdoublequote=!isdoublequote; + i++; + } + else if (cmd[i]=='\\') + i+=2; + else if (cmd[i]=='`') + { + // Replace all `...` with safer $(...) + cmd.replace (i, 1, "$("); + TQRegExp re_backticks("(`|\\\\`|\\\\\\\\|\\\\\\$)"); + for ( int i2=re_backticks.search(cmd,i+2); + i2!=-1; + i2=re_backticks.search(cmd,i2) + ) + { + if (cmd[i2] == '`') + { + cmd.replace (i2, 1, ")"); + i2=cmd.length(); // leave loop + } + else + { // remove backslash and ignore following character + cmd.remove (i2, 1); + i2++; + } + } + // Leave i unchanged! We need to process "$(" + } + else + { + TQString match, v; + + // get match + if (issinglequote) + match=re_singlequote.cap(); + else if (isdoublequote) + match=re_doublequote.cap(); + else + match=re_noquote.cap(); + + // substitute %variables + // settings + if ( isTag( match, "%dev" ) ) + { + conf->setGroup("Fax"); + v = processTag( match, conf->readEntry("Device", "modem") ); + + } + else if (isTag( match, "%server" )) + { + conf->setGroup( "Fax" ); + v = conf->readEntry("Server"); + if (v.isEmpty()) + v = getenv("FAXSERVER"); + if (v.isEmpty()) + v = TQString::tqfromLatin1("localhost"); + v = processTag( match, v ); + } + else if (isTag( match, "%page" )) + { + conf->setGroup( "Fax" ); + v = processTag( match, pageSize() ); + } + else if (isTag( match, "%res" )) + { + conf->setGroup( "Fax" ); + v = processTag(match, conf->readEntry("Resolution", "High") == "High"); + } + else if (isTag( match, "%user" )) + { + conf->setGroup("Personal"); + v = processTag(match, conf->readEntry("Name", getenv("USER"))); + } + else if (isTag( match, "%from" )) + { + conf->setGroup( "Personal" ); + v = processTag(match, conf->readEntry("Number")); + } + else if (isTag( match, "%email" )) + { + KEMailSettings e; + v = processTag(match, e.getSetting(KEMailSettings::EmailAddress)); + } + // arguments + else if (isTag( match, "%number" )) + v = processTag( match, stripNumber( item.number) ); + else if (isTag( match, "%rawnumber" )) + v = processTag( match, item.number ); + else if (isTag( match, "%name" )) + v = processTag(match, item.name); + else if (isTag( match, "%comment" )) + v = processTag(match, fax->comment()); + else if (isTag( match, "%enterprise" )) + v = processTag(match, item.enterprise); + else if ( isTag( match, "%time" ) ) + v = processTag( match, fax->time() ); + else if ( isTag( match, "%subject" ) ) + v = processTag( match, fax->subject() ); + else if (isTag( match, "%cover" )) + v = processTag(match, fax->cover()); + + // %variable inside of a quote? + if (isdoublequote) + v='"'+v+'"'; + else if (issinglequote) + v="'"+v+"'"; + + cmd.replace (i, match.length(), v); + i+=v.length(); + } + } + + return cmd; +} + +FaxCtrl::FaxCtrl(TQWidget *parent, const char *name) +: TQObject(parent, name) +{ + m_process = new KProcess(); + m_process->setUseShell(true); + connect(m_process, TQT_SIGNAL(receivedStdout(KProcess*,char*,int)), TQT_SLOT(slotReceivedStdout(KProcess*,char*,int))); + connect(m_process, TQT_SIGNAL(receivedStderr(KProcess*,char*,int)), TQT_SLOT(slotReceivedStdout(KProcess*,char*,int))); + connect(m_process, TQT_SIGNAL(processExited(KProcess*)), TQT_SLOT(slotProcessExited(KProcess*))); + connect(this, TQT_SIGNAL(faxSent(bool)), TQT_SLOT(cleanTempFiles())); + m_logview = 0; +} + +FaxCtrl::~FaxCtrl() +{ + slotCloseLog(); + delete m_process; +} + +bool FaxCtrl::send(KdeprintFax *f) +{ + m_command = faxCommand(); + if (m_command.isEmpty()) + return false; + + // replace tags common to all fax "operations" + m_command = replaceTags( m_command, tagList( 11, "%dev", "%server", "%page", "%res", "%user", "%from", "%email", "%comment", "%time", "%subject", "%cover" ), f ); + + m_log = TQString::null; + m_filteredfiles.clear(); + cleanTempFiles(); + m_files = f->files(); + m_faxlist = f->faxList(); + + addLogTitle( i18n( "Converting input files to PostScript" ) ); + filter(); + + return true; +} + +void FaxCtrl::slotReceivedStdout(KProcess*, char *buffer, int len) +{ + TQCString str(buffer, len); + kdDebug() << "Received stdout: " << str << endl; + addLog(TQString(str)); +} + +void FaxCtrl::slotProcessExited(KProcess*) +{ + // we exited a process: if there's still entries in m_files, this was a filter + // process, else this was the fax process + bool ok = (m_process->normalExit() && ((m_process->exitStatus() & (m_files.count() > 0 ? 0x1 : 0xFFFFFFFF)) == 0)); + if ( ok ) + { + if ( m_files.count() > 0 ) + { + // remove first element + m_files.remove(m_files.begin()); + if (m_files.count() > 0) + filter(); + else + sendFax(); + } + else if ( !m_faxlist.isEmpty() ) + sendFax(); + else + faxSent( true ); + } + else + { + emit faxSent(false); + } +} + +TQString FaxCtrl::faxCommand() +{ + KConfig *conf = KGlobal::config(); + conf->setGroup("System"); + TQString sys = conf->readPathEntry("System", "efax"); + TQString cmd; + if (sys == "hylafax") + cmd = conf->readPathEntry("HylaFax", hylafax_default_cmd); + else if (sys == "mgetty") + cmd = conf->readPathEntry("Mgetty", mgetty_default_cmd); + else if ( sys == "other" ) + cmd = conf->readPathEntry( "Other", TQString::null ); + else + cmd = conf->readPathEntry("EFax", efax_default_cmd); + if (cmd.startsWith("%exe_")) + cmd = defaultCommand(cmd); + return cmd; +} + +void FaxCtrl::sendFax() +{ + if ( m_command.find( "%files" ) != -1 ) + { + // replace %files tag + TQString filestr; + for (TQStringList::ConstIterator it=m_filteredfiles.begin(); it!=m_filteredfiles.end(); ++it) + filestr += (quote(*it)+" "); + m_command.replace("%files", filestr); + } + + if ( !m_faxlist.isEmpty() ) + { + KdeprintFax::FaxItem item = m_faxlist.first(); + m_faxlist.remove(m_faxlist.begin()); + + addLogTitle( i18n( "Sending fax to %1 (%2)" ).arg( item.number ).arg( item.name ) ); + + TQString cmd = replaceTags( m_command, tagList( 4, "%number", "%name", "%enterprise", "%rawnumber" ), NULL, item ); + m_process->clearArguments(); + *m_process << cmd; + addLog(i18n("Sending to fax using: %1").arg(cmd)); + if (!m_process->start(KProcess::NotifyOnExit, KProcess::AllOutput)) + emit faxSent(false); + else + emit message(i18n("Sending fax to %1...").arg( item.number )); + } +} + +void FaxCtrl::filter() +{ + if (m_files.count() > 0) + { + TQString mimeType = KMimeType::findByURL(KURL(m_files[0]), 0, true)->name(); + if (mimeType == "application/postscript" || mimeType == "image/tiff") + { + emit message(i18n("Skipping %1...").arg(m_files[0])); + m_filteredfiles.prepend(m_files[0]); + m_files.remove(m_files.begin()); + filter(); + } + else + { + TQString tmp = locateLocal("tmp","tdeprintfax_") + kapp->randomString(8); + m_filteredfiles.prepend(tmp); + m_tempfiles.append(tmp); + m_process->clearArguments(); + *m_process << locate("data","tdeprintfax/anytops") << "-m" << KProcess::quote(locate("data","tdeprintfax/faxfilters")) + << TQString::tqfromLatin1("--mime=%1").arg(mimeType) + << "-p" << pageSize() + << KProcess::quote(m_files[0]) << KProcess::quote(tmp); + if (!m_process->start(KProcess::NotifyOnExit, KProcess::AllOutput)) + emit faxSent(false); + else + emit message(i18n("Filtering %1...").arg(m_files[0])); + } + } + else + { + sendFax(); + } +} + +bool FaxCtrl::abort() +{ + if (m_process->isRunning()) + return m_process->kill(); + else + return false; +} + +void FaxCtrl::viewLog(TQWidget *) +{ + if (!m_logview) + { + TQWidget *topView = new TQWidget(0, "LogView", (WFlags)(WType_TopLevel|WStyle_DialogBorder|WDestructiveClose)); + m_logview = new KTextEdit(topView); + m_logview->setTextFormat( TQt::LogText ); + m_logview->setWordWrap( TQTextEdit::WidgetWidth ); + m_logview->setPaper( Qt::white ); + //m_logview->setReadOnly(true); + //m_logview->setWordWrap(TQTextEdit::NoWrap); + TQPushButton *m_clear = new KPushButton(KStdGuiItem::clear(), topView); + TQPushButton *m_close = new KPushButton(KStdGuiItem::close(), topView); + TQPushButton *m_print = new KPushButton( KStdGuiItem::print(), topView ); + TQPushButton *m_save = new KPushButton( KStdGuiItem::saveAs(), topView ); + m_close->setDefault(true); + connect(m_clear, TQT_SIGNAL(clicked()), TQT_SLOT(slotClearLog())); + connect(m_close, TQT_SIGNAL(clicked()), TQT_SLOT(slotCloseLog())); + connect(m_logview, TQT_SIGNAL(destroyed()), TQT_SLOT(slotCloseLog())); + connect( m_print, TQT_SIGNAL( clicked() ), TQT_SLOT( slotPrintLog() ) ); + connect( m_save, TQT_SIGNAL( clicked() ), TQT_SLOT( slotSaveLog() ) ); + + TQVBoxLayout *l0 = new TQVBoxLayout(topView, 10, 10); + l0->addWidget(m_logview); + TQHBoxLayout *l1 = new TQHBoxLayout(0, 0, 10); + l0->addLayout(l1); + l1->addStretch(1); + l1->addWidget( m_save ); + l1->addWidget( m_print ); + l1->addWidget(m_clear); + l1->addWidget(m_close); + + m_logview->setText(m_log); + + topView->resize(450, 350); + topView->show(); + } + else + { + KWin::activateWindow(m_logview->parentWidget()->winId()); + } +} + +void FaxCtrl::addLogTitle( const TQString& s ) +{ + TQString t( s ); + t.prepend( '\n' ).append( '\n' ); + addLog( t, true ); +} + +void FaxCtrl::addLog(const TQString& s, bool isTitle) +{ + TQString t = TQStyleSheet::escape(s); + if ( isTitle ) + t.prepend( "" ).append( "" ); + m_log.append( t + '\n' ); + if (m_logview) + m_logview->append(t); +} + +TQString FaxCtrl::faxSystem() +{ + KConfig *conf = KGlobal::config(); + conf->setGroup("System"); + TQString s = conf->readEntry("System", "efax"); + s[0] = s[0].upper(); + return s; +} + +void FaxCtrl::cleanTempFiles() +{ + for (TQStringList::ConstIterator it=m_tempfiles.begin(); it!=m_tempfiles.end(); ++it) + TQFile::remove(*it); + m_tempfiles.clear(); +} + +void FaxCtrl::slotClearLog() +{ + m_log = TQString::null; + if (m_logview) + m_logview->clear(); +} + +void FaxCtrl::slotCloseLog() +{ + const TQObject *obj = TQT_TQOBJECT_CONST(sender()); + if (m_logview) + { + TQTextEdit *view = m_logview; + m_logview = 0; + if (obj && obj->inherits(TQPUSHBUTTON_OBJECT_NAME_STRING)) + delete view->parentWidget(); +kdDebug() << "slotClose()" << endl; + } +} + +void FaxCtrl::slotPrintLog() +{ + if ( m_logview ) + { + KPrinter printer; + printer.setDocName( i18n( "Fax log" ) ); + printer.setDocFileName( "faxlog" ); + if ( printer.setup( m_logview->tqtopLevelWidget(), i18n( "Fax Log" ) ) ) + { + TQPainter painter( &printer ); + TQPaintDeviceMetrics metric( &printer ); + TQRect body( 0, 0, metric.width(), metric.height() ), view( body ); + //TQString txt = m_logview->text(); + TQString txt = m_log; + + txt.replace( '\n', "
" ); + txt.prepend( "

" + i18n( "KDEPrint Fax Tool Log" ) + "

" ); + + kdDebug() << "Log: " << txt << endl; + TQSimpleRichText richText( txt, m_logview->font() ); + + richText.setWidth( &painter, body.width() ); + do + { + richText.draw( &painter, body.left(), body.top(), view, m_logview->tqcolorGroup() ); + view.moveBy( 0, body.height() ); + painter.translate( 0, -body.height() ); + if ( view.top() >= richText.height() ) + break; + printer.newPage(); + } while ( true ); + } + } +} + +void FaxCtrl::slotSaveLog() +{ + if ( m_logview ) + { + TQString filename = KFileDialog::getSaveFileName( TQString::null, TQString::null, m_logview ); + if ( !filename.isEmpty() ) + { + TQFile f( filename ); + if ( f.open( IO_WriteOnly ) ) + { + TQTextStream t( &f ); + t << i18n( "KDEPrint Fax Tool Log" ) << endl; + t << m_logview->text() << endl; + f.close(); + } + else + KMessageBox::error( m_logview, i18n( "Cannot open file for writing." ) ); + } + } +} + +#include "faxctrl.moc" diff --git a/tdeprint/tdeprintfax/faxctrl.h b/tdeprint/tdeprintfax/faxctrl.h new file mode 100644 index 000000000..a7e16a850 --- /dev/null +++ b/tdeprint/tdeprintfax/faxctrl.h @@ -0,0 +1,73 @@ +/* + * tdeprintfax - a small fax utility + * Copyright (C) 2001 Michael Goffioul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef FAXCTRL_H +#define FAXCTRL_H + +#include +#include +#include + +#include "tdeprintfax.h" + +class KProcess; +class TQTextEdit; + +class FaxCtrl : public TQObject +{ + Q_OBJECT +public: + FaxCtrl(TQWidget *parent = 0, const char *name = 0); + ~FaxCtrl(); + + bool send(KdeprintFax *f); + bool abort(); + void viewLog(TQWidget *parent = 0); + TQString faxSystem(); + TQString faxCommand(); + +signals: + void message(const TQString&); + void faxSent(bool); + +protected slots: + void slotReceivedStdout(KProcess*, char*, int); + void slotProcessExited(KProcess*); + void cleanTempFiles(); + void slotClearLog(); + void slotCloseLog(); + void slotPrintLog(); + void slotSaveLog(); + +protected: + void filter(); + void sendFax(); + void addLog(const TQString&, bool = false); + void addLogTitle( const TQString& ); + +private: + KProcess *m_process; + TQString m_log, m_command; + TQStringList m_files, m_filteredfiles, m_tempfiles; + TQTextEdit *m_logview; + KdeprintFax::FaxItemList m_faxlist; +}; + +#endif diff --git a/tdeprint/tdeprintfax/faxfilters b/tdeprint/tdeprintfax/faxfilters new file mode 100644 index 000000000..73e96a14e --- /dev/null +++ b/tdeprint/tdeprintfax/faxfilters @@ -0,0 +1,3 @@ +text/* enscript -M %psu -E -p %out %in +image/* imagetops -gray -noturn %in > %out +*/* cat %in > %out diff --git a/tdeprint/tdeprintfax/filterdlg.cpp b/tdeprint/tdeprintfax/filterdlg.cpp new file mode 100644 index 000000000..0324863bc --- /dev/null +++ b/tdeprint/tdeprintfax/filterdlg.cpp @@ -0,0 +1,72 @@ +/* + * tdeprintfax - a small fax utility + * Copyright (C) 2001 Michael Goffioul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "filterdlg.h" +#include "filterdlg.moc" + +#include +#include +#include + +#include + +FilterDlg::FilterDlg(TQWidget *parent, const char *name) +: KDialogBase(parent, name, true, i18n("Filter Parameters"), Ok|Cancel, Ok) +{ + TQWidget *w = new TQWidget(this); + + m_mime = new TQLineEdit(w); + m_cmd = new TQLineEdit(w); + TQLabel *m_mimelabel = new TQLabel(i18n("MIME type:"), w); + TQLabel *m_cmdlabel = new TQLabel(i18n("Command:"), w); + + TQGridLayout *l0 = new TQGridLayout(w, 2, 2, 10, 5); + l0->setColStretch(1, 1); + l0->addWidget(m_mimelabel, 0, 0); + l0->addWidget(m_cmdlabel, 1, 0); + l0->addWidget(m_mime, 0, 1); + l0->addWidget(m_cmd, 1, 1); + + setMainWidget(w); + m_mime->setFocus(); + resize(300, 100); + connect(m_mime, TQT_SIGNAL(textChanged ( const TQString & )),this, TQT_SLOT(slotTextFilterChanged())); + connect(m_cmd, TQT_SIGNAL(textChanged ( const TQString & )),this, TQT_SLOT(slotTextFilterChanged())); + slotTextFilterChanged(); +} + +void FilterDlg::slotTextFilterChanged( ) +{ + enableButtonOK(!m_mime->text().isEmpty() && !m_cmd->text().isEmpty()); +} + +bool FilterDlg::doIt(TQWidget *parent, TQString *mime, TQString *cmd) +{ + FilterDlg dlg(parent); + if (mime) dlg.m_mime->setText(*mime); + if (cmd) dlg.m_cmd->setText(*cmd); + if (dlg.exec()) + { + if (mime) *mime = dlg.m_mime->text(); + if (cmd) *cmd = dlg.m_cmd->text(); + return true; + } + return false; +} diff --git a/tdeprint/tdeprintfax/filterdlg.h b/tdeprint/tdeprintfax/filterdlg.h new file mode 100644 index 000000000..ab4fd0406 --- /dev/null +++ b/tdeprint/tdeprintfax/filterdlg.h @@ -0,0 +1,41 @@ +/* + * tdeprintfax - a small fax utility + * Copyright (C) 2001 Michael Goffioul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef FILTERDLG_H +#define FILTERDLG_H + +#include + +class TQLineEdit; + +class FilterDlg : public KDialogBase +{ + Q_OBJECT +public: + FilterDlg(TQWidget *parent = 0, const char *name = 0); + + static bool doIt(TQWidget *parent = 0, TQString* mime = 0, TQString *cmd = 0); +protected slots: + void slotTextFilterChanged(); +private: + TQLineEdit *m_mime, *m_cmd; +}; + +#endif diff --git a/tdeprint/tdeprintfax/hi128-app-tdeprintfax.png b/tdeprint/tdeprintfax/hi128-app-tdeprintfax.png new file mode 100644 index 000000000..ad29adba7 Binary files /dev/null and b/tdeprint/tdeprintfax/hi128-app-tdeprintfax.png differ diff --git a/tdeprint/tdeprintfax/hi16-app-tdeprintfax.png b/tdeprint/tdeprintfax/hi16-app-tdeprintfax.png new file mode 100644 index 000000000..bb676f8b7 Binary files /dev/null and b/tdeprint/tdeprintfax/hi16-app-tdeprintfax.png differ diff --git a/tdeprint/tdeprintfax/hi22-app-tdeprintfax.png b/tdeprint/tdeprintfax/hi22-app-tdeprintfax.png new file mode 100644 index 000000000..90fc64b0b Binary files /dev/null and b/tdeprint/tdeprintfax/hi22-app-tdeprintfax.png differ diff --git a/tdeprint/tdeprintfax/hi32-app-tdeprintfax.png b/tdeprint/tdeprintfax/hi32-app-tdeprintfax.png new file mode 100644 index 000000000..7330eb41f Binary files /dev/null and b/tdeprint/tdeprintfax/hi32-app-tdeprintfax.png differ diff --git a/tdeprint/tdeprintfax/hi48-app-tdeprintfax.png b/tdeprint/tdeprintfax/hi48-app-tdeprintfax.png new file mode 100644 index 000000000..3f58c3695 Binary files /dev/null and b/tdeprint/tdeprintfax/hi48-app-tdeprintfax.png differ diff --git a/tdeprint/tdeprintfax/hi64-app-tdeprintfax.png b/tdeprint/tdeprintfax/hi64-app-tdeprintfax.png new file mode 100644 index 000000000..47e156d5f Binary files /dev/null and b/tdeprint/tdeprintfax/hi64-app-tdeprintfax.png differ diff --git a/tdeprint/tdeprintfax/hisc-app-tdeprintfax.svgz b/tdeprint/tdeprintfax/hisc-app-tdeprintfax.svgz new file mode 100644 index 000000000..f46fd4401 Binary files /dev/null and b/tdeprint/tdeprintfax/hisc-app-tdeprintfax.svgz differ diff --git a/tdeprint/tdeprintfax/main.cpp b/tdeprint/tdeprintfax/main.cpp new file mode 100644 index 000000000..4fe22a3b6 --- /dev/null +++ b/tdeprint/tdeprintfax/main.cpp @@ -0,0 +1,78 @@ +/* + * tdeprintfax - a interface to fax-packages + * Copyright (C) 2001 Michael Goffioul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "tdeprintfax.h" + +#include +#include +#include +#include +#include + +TQString debugFlag; +int oneShotFlag = false; + +static const char description[] = + I18N_NOOP("A small fax utility to be used with tdeprint."); +// INSERT A DESCRIPTION FOR YOUR APPLICATION HERE + + +static KCmdLineOptions options[] = +{ + { "phone ", I18N_NOOP("Phone number to fax to"), 0 }, + { "immediate", I18N_NOOP("Send fax immediately"), 0 }, + { "batch", I18N_NOOP("Exit after sending"), 0 }, + { "+[file]", I18N_NOOP("File to fax (added to the file list)"), 0 }, + KCmdLineLastOption + // INSERT YOUR COMMANDLINE OPTIONS HERE +}; + +int main(int argc, char *argv[]) +{ + + KAboutData aboutData( "tdeprintfax", I18N_NOOP("KdeprintFax"), + "1.0", description, KAboutData::License_GPL, + "(c), 2001 Michael Goffioul", 0, "http://printing.kde.org"); + aboutData.addAuthor("Michael Goffioul",0, "tdeprint@swing.be"); + KCmdLineArgs::init( argc, argv, &aboutData ); + KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. + KApplication::addCmdLineOptions(); + + KApplication a; + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + + KdeprintFax *w = new KdeprintFax; + a.setMainWidget(w); + w->show(); + for (int i=0;icount();i++) + w->addURL(args->url(i)); + + TQString phone = args->getOption( "phone" ); + if( !phone.isEmpty() ) { + w->setPhone( phone ); + } + + if( args->isSet( "immediate" ) ) { + w->sendFax( args->isSet( "batch" ) ); + } + + args->clear(); + return a.exec(); +} diff --git a/tdeprint/tdeprintfax/tdeprintfax.cpp b/tdeprint/tdeprintfax/tdeprintfax.cpp new file mode 100644 index 000000000..24ad58a0e --- /dev/null +++ b/tdeprint/tdeprintfax/tdeprintfax.cpp @@ -0,0 +1,607 @@ +/* + * tdeprintfax - a small fax utility + * Copyright (C) 2001 Michael Goffioul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "tdeprintfax.h" +#include "faxab.h" +#include "faxctrl.h" +#include "configdlg.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +KdeprintFax::KdeprintFax(TQWidget *parent, const char *name) +: KMainWindow(parent, name) +{ + m_faxctrl = new FaxCtrl(this); + m_quitAfterSend = false; + connect(m_faxctrl, TQT_SIGNAL(message(const TQString&)), TQT_SLOT(slotMessage(const TQString&))); + connect(m_faxctrl, TQT_SIGNAL(faxSent(bool)), TQT_SLOT(slotFaxSent(bool))); + + TQWidget *mainw = new TQWidget(this); + setCentralWidget(mainw); + m_files = new KListBox(mainw); + connect( m_files, TQT_SIGNAL( currentChanged( TQListBoxItem* ) ), TQT_SLOT( slotCurrentChanged() ) ); + m_upbtn = new KPushButton( mainw ); + m_upbtn->setIconSet( SmallIconSet( "up" ) ); + TQToolTip::add( m_upbtn, i18n( "Move up" ) ); + connect( m_upbtn, TQT_SIGNAL( clicked() ), TQT_SLOT( slotMoveUp() ) ); + m_upbtn->setEnabled( false ); + m_downbtn = new KPushButton( mainw ); + m_downbtn->setIconSet( SmallIconSet( "down" ) ); + TQToolTip::add( m_downbtn, i18n( "Move down" ) ); + connect( m_downbtn, TQT_SIGNAL( clicked() ), TQT_SLOT( slotMoveDown() ) ); + m_downbtn->setEnabled( false ); + TQLabel *m_filelabel = new TQLabel(i18n("F&iles:"), mainw); + m_filelabel->setBuddy(m_files); + KSeparator*m_line = new KSeparator( KSeparator::HLine, mainw); + KSeparator *m_line2 = new KSeparator( KSeparator::HLine, mainw ); + m_numbers = new KListView( mainw ); + m_numbers->addColumn( i18n("Fax Number") ); + m_numbers->addColumn( i18n("Name") ); + m_numbers->addColumn( i18n("Enterprise") ); + m_numbers->header()->setStretchEnabled( true ); + m_numbers->setSelectionMode( TQListView::Extended ); + connect( m_numbers, TQT_SIGNAL( selectionChanged() ), TQT_SLOT( slotFaxSelectionChanged() ) ); + connect( m_numbers, TQT_SIGNAL( executed( TQListViewItem* ) ), TQT_SLOT( slotFaxExecuted( TQListViewItem* ) ) ); + m_newbtn = new KPushButton( mainw ); + m_newbtn->setPixmap( SmallIcon( "edit" ) ); + TQToolTip::add( m_newbtn, i18n( "Add fax number" ) ); + connect( m_newbtn, TQT_SIGNAL( clicked() ), TQT_SLOT( slotFaxAdd() ) ); + m_abbtn = new KPushButton( mainw ); + m_abbtn->setPixmap( SmallIcon( "kaddressbook" ) ); + TQToolTip::add( m_abbtn, i18n( "Add fax number from addressbook" ) ); + connect( m_abbtn, TQT_SIGNAL( clicked() ), TQT_SLOT( slotKab() ) ); + m_delbtn = new KPushButton( mainw ); + m_delbtn->setIconSet( SmallIconSet( "edittrash" ) ); + TQToolTip::add( m_delbtn, i18n( "Remove fax number" ) ); + m_delbtn->setEnabled( false ); + connect( m_delbtn, TQT_SIGNAL( clicked() ), TQT_SLOT( slotFaxRemove() ) ); + TQLabel *m_commentlabel = new TQLabel(i18n("&Comment:"), mainw); + KSystemTray *m_tray = new KSystemTray(this); + m_tray->setPixmap(SmallIcon("tdeprintfax")); + m_tray->show(); + m_comment = new TQTextEdit(mainw); +// I don't understand why anyone would want to turn off word wrap. It makes +// the text hard to read and write. It provides no benefit. Therefore, +// I commented out the next line. [Ray Lischner] +// m_comment->setWordWrap(TQTextEdit::NoWrap); + m_comment->setLineWidth(1); + m_commentlabel->setBuddy(m_comment); + TQLabel *m_timelabel = new TQLabel(i18n("Sched&ule:"), mainw); + m_timecombo = new TQComboBox(mainw); + m_timecombo->insertItem(i18n("Now")); + m_timecombo->insertItem(i18n("At Specified Time")); + m_timecombo->setCurrentItem(0); + m_timelabel->setBuddy(m_timecombo); + m_time = new TQTimeEdit(mainw); + m_time->setTime(TQTime::currentTime()); + m_time->setEnabled(false); + connect(m_timecombo, TQT_SIGNAL(activated(int)), TQT_SLOT(slotTimeComboActivated(int))); + m_cover = new TQCheckBox(i18n("Send Co&ver Sheet"), mainw); + connect(m_cover, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotCoverToggled(bool))); + m_subject = new TQLineEdit( mainw ); + TQLabel *m_subjectlabel = new TQLabel( i18n( "Su&bject:" ), mainw ); + m_subjectlabel->setBuddy( m_subject ); + + TQGridLayout *l0 = new TQGridLayout(mainw, 10, 2, 10, 5); + l0->setColStretch(1,1); + l0->addWidget(m_filelabel, 0, 0, Qt::AlignLeft|Qt::AlignTop); + TQHBoxLayout *l2 = new TQHBoxLayout( 0, 0, 10 ); + TQVBoxLayout *l3 = new TQVBoxLayout( 0, 0, 5 ); + l0->addLayout( l2, 0, 1 ); + l2->addWidget( m_files ); + l2->addLayout( l3 ); + //l3->addStretch( 1 ); + l3->addWidget( m_upbtn ); + l3->addWidget( m_downbtn ); + l3->addStretch( 1 ); + l0->addMultiCellWidget(m_line, 1, 1, 0, 1); + l0->addRowSpacing(1, 10); + TQHBoxLayout *l5 = new TQHBoxLayout( 0, 0, 10 ); + TQVBoxLayout *l6 = new TQVBoxLayout( 0, 0, 5 ); + l0->addMultiCellLayout( l5, 2, 4, 0, 1 ); + l5->addWidget( m_numbers ); + l5->addLayout( l6 ); + l6->addWidget( m_newbtn ); + l6->addWidget( m_delbtn ); + l6->addWidget( m_abbtn ); + l6->addStretch( 1 ); + l0->addMultiCellWidget( m_line2, 5, 5, 0, 1 ); + l0->addRowSpacing( 5, 10 ); + l0->addWidget( m_cover, 6, 1 ); + l0->addWidget( m_subjectlabel, 7, 0 ); + l0->addWidget( m_subject, 7, 1 ); + l0->addWidget(m_commentlabel, 8, 0, Qt::AlignTop|Qt::AlignLeft); + l0->addWidget(m_comment, 8, 1); + l0->addWidget(m_timelabel, 9, 0); + TQHBoxLayout *l1 = new TQHBoxLayout(0, 0, 5); + l0->addLayout(l1, 9, 1); + l1->addWidget(m_timecombo, 1); + l1->addWidget(m_time, 0); + + m_msglabel = new KSqueezedTextLabel(statusBar()); + statusBar()->addWidget(m_msglabel, 1); + statusBar()->insertFixedItem(i18n("Processing..."), 1); + statusBar()->changeItem(i18n("Idle"), 1); + statusBar()->insertFixedItem("hylafax/efax", 2); + initActions(); + setAcceptDrops(true); + setCaption(i18n("Send to Fax")); + updateState(); + + resize(550,500); + TQWidget *d = TQT_TQWIDGET(kapp->desktop()); + move((d->width()-width())/2, (d->height()-height())/2); +} + +KdeprintFax::~KdeprintFax() +{ +} + +void KdeprintFax::initActions() +{ + new KAction(i18n("&Add File..."), "filenew", Qt::Key_Insert, TQT_TQOBJECT(this), TQT_SLOT(slotAdd()), actionCollection(), "file_add"); + new KAction(i18n("&Remove File"), "remove", Qt::Key_Delete, TQT_TQOBJECT(this), TQT_SLOT(slotRemove()), actionCollection(), "file_remove"); + new KAction(i18n("&Send Fax"), "connect_established", Qt::Key_Return, TQT_TQOBJECT(this), TQT_SLOT(slotFax()), actionCollection(), "fax_send"); + new KAction(i18n("A&bort"), "stop", Qt::Key_Escape, TQT_TQOBJECT(this), TQT_SLOT(slotAbort()), actionCollection(), "fax_stop"); + new KAction(i18n("A&ddress Book"), "kaddressbook", Qt::CTRL+Qt::Key_A, TQT_TQOBJECT(this), TQT_SLOT(slotKab()), actionCollection(), "fax_ab"); + new KAction(i18n("V&iew Log"), "contents", Qt::CTRL+Qt::Key_L, TQT_TQOBJECT(this), TQT_SLOT(slotViewLog()), actionCollection(), "fax_log"); + new KAction(i18n("Vi&ew File"), "filefind", Qt::CTRL+Qt::Key_O, TQT_TQOBJECT(this), TQT_SLOT(slotView()), actionCollection(), "file_view"); + new KAction( i18n( "&New Fax Recipient..." ), "edit", Qt::CTRL+Qt::Key_N, TQT_TQOBJECT(this), TQT_SLOT( slotFaxAdd() ), actionCollection(), "fax_add" ); + + KStdAction::quit(TQT_TQOBJECT(this), TQT_SLOT(slotQuit()), actionCollection()); + setStandardToolBarMenuEnabled(true); + KStdAction::showMenubar(TQT_TQOBJECT(this), TQT_SLOT(slotToggleMenuBar()), actionCollection()); + KStdAction::preferences(TQT_TQOBJECT(this), TQT_SLOT(slotConfigure()), actionCollection()); + KStdAction::keyBindings(guiFactory(), TQT_SLOT(configureShortcuts()), +actionCollection()); + actionCollection()->action("fax_stop")->setEnabled(false); + connect(actionCollection()->action("file_remove"), TQT_SIGNAL(enabled(bool)), actionCollection()->action("file_view"), TQT_SLOT(setEnabled(bool))); + actionCollection()->action("file_remove")->setEnabled(false); + + createGUI(); +} + +void KdeprintFax::slotToggleMenuBar() +{ + if (menuBar()->isVisible()) menuBar()->hide(); + else menuBar()->show(); +} + +void KdeprintFax::slotAdd() +{ + KURL url = KFileDialog::getOpenURL(TQString::null, TQString::null, this); + if (!url.isEmpty()) + addURL(url); +} + +void KdeprintFax::slotRemove() +{ + if (m_files->currentItem() >= 0) + m_files->removeItem(m_files->currentItem()); + if (m_files->count() == 0) + actionCollection()->action("file_remove")->setEnabled(false); +} + +void KdeprintFax::slotView() +{ + if (m_files->currentItem() >= 0) + { + new KRun(KURL( m_files->currentText() )); + } +} + +void KdeprintFax::slotFax() +{ + if (m_files->count() == 0) + KMessageBox::error(this, i18n("No file to fax.")); + else if ( m_numbers->childCount() == 0 ) + KMessageBox::error(this, i18n("No fax number specified.")); + else if (m_faxctrl->send(this)) + { + actionCollection()->action("fax_send")->setEnabled(false); + actionCollection()->action("fax_stop")->setEnabled(true); + statusBar()->changeItem(i18n("Processing..."), 1); + } + else + KMessageBox::error(this, i18n("Unable to start Fax process.")); +} + +void KdeprintFax::slotAbort() +{ + if (!m_faxctrl->abort()) + KMessageBox::error(this, i18n("Unable to stop Fax process.")); +} + +void KdeprintFax::slotKab() +{ + TQStringList number, name, enterprise; + if (FaxAB::getEntry(number, name, enterprise, this)) + { + for ( unsigned int i = 0; iinsertItem(KMimeType::pixmapForURL(url,0,KIcon::Small),target); + actionCollection()->action("file_remove")->setEnabled(true); + slotCurrentChanged(); + } + else + KMessageBox::error(this, i18n("Unable to retrieve %1.").arg(url.prettyURL())); +} + +void KdeprintFax::setPhone(TQString phone) +{ + TQString name, enterprise; + FaxAB::getEntryByNumber(phone, name, enterprise); + new TQListViewItem( m_numbers, phone, name, enterprise ); +} + +void KdeprintFax::sendFax( bool quitAfterSend ) +{ + slotFax(); + m_quitAfterSend = quitAfterSend; +} + +void KdeprintFax::dragEnterEvent(TQDragEnterEvent *e) +{ + e->accept(KURLDrag::canDecode(e)); +} + +void KdeprintFax::dropEvent(TQDropEvent *e) +{ + KURL::List l; + if (KURLDrag::decode(e, l)) + { + for (KURL::List::ConstIterator it = l.begin(); it != l.end(); ++it) + addURL(*it); + } +} + +TQStringList KdeprintFax::files() +{ + TQStringList l; + for (uint i=0; icount(); i++) + l.append(m_files->text(i)); + return l; +} + + +int KdeprintFax::faxCount() const +{ + return m_numbers->childCount(); +} + +/* +TQListViewItem* KdeprintFax::faxItem( int i ) const +{ + TQListViewItem *item = m_numbers->firstChild(); + while ( i && item && item->nextSibling() ) + { + item = item->nextSibling(); + i--; + } + if ( i || !item ) + kdError() << "KdeprintFax::faxItem(" << i << ") => fax item index out of bound" << endl; + return item; +} + +TQString KdeprintFax::number( int i ) const +{ + TQListViewItem *item = faxItem( i ); + return ( item ? item->text( 0 ) : TQString::null ); +} + +TQString KdeprintFax::name( int i ) const +{ + TQListViewItem *item = faxItem( i ); + return ( item ? item->text( 1 ) : TQString::null ); +} + +TQString KdeprintFax::enterprise( int i ) const +{ + TQListViewItem *item = faxItem( i ); + return ( item ? item->text( 2 ) : TQString::null ); +} +*/ + +KdeprintFax::FaxItemList KdeprintFax::faxList() const +{ + FaxItemList list; + TQListViewItemIterator it( m_numbers ); + while ( it.current() ) + { + FaxItem item; + item.number = it.current()->text( 0 ); + item.name = it.current()->text( 1 ); + item.enterprise = it.current()->text( 2 ); + list << item; + ++it; + } + return list; +} + +TQString KdeprintFax::comment() const +{ + return m_comment->text(); +} + +bool KdeprintFax::cover() const +{ + return m_cover->isChecked(); +} + +TQString KdeprintFax::subject() const +{ + return m_subject->text(); +} + +void KdeprintFax::slotMessage(const TQString& msg) +{ + m_msglabel->setText(msg); +} + +void KdeprintFax::slotFaxSent(bool status) +{ + actionCollection()->action("fax_send")->setEnabled(true); + actionCollection()->action("fax_stop")->setEnabled(false); + statusBar()->changeItem(i18n("Idle"), 1); + + if( m_quitAfterSend ) { + slotQuit(); + } + else { + if (!status) + KMessageBox::error(this, i18n("Fax error: see log message for more information.")); + slotMessage(TQString::null); + } +} + +void KdeprintFax::slotViewLog() +{ + m_faxctrl->viewLog(this); +} + +void KdeprintFax::slotConfigure() +{ + if (ConfigDlg::configure(this)) + updateState(); +} + +void KdeprintFax::updateState() +{ + TQString cmd = m_faxctrl->faxCommand(); + m_cover->setEnabled(cmd.find("%cover") != -1); + if ( !m_cover->isEnabled() ) + m_cover->setChecked(false); + m_comment->setEnabled(cmd.find("%comment") != -1 && m_cover->isChecked()); + //m_comment->setPaper(m_comment->isEnabled() ? tqcolorGroup().brush(TQColorGroup::Base) : tqcolorGroup().brush(TQColorGroup::Background)); + if (!m_comment->isEnabled()) + { + m_comment->setText(""); + m_comment->setPaper( tqcolorGroup().background() ); + } + else + m_comment->setPaper( tqcolorGroup().base() ); + /* + m_enterprise->setEnabled(cmd.find("%enterprise") != -1); + if (!m_enterprise->isEnabled()) + m_enterprise->setText(""); + */ + if (cmd.find("%time") == -1) + { + m_timecombo->setCurrentItem(0); + m_timecombo->setEnabled(false); + slotTimeComboActivated(0); + } + else + m_timecombo->setEnabled( true ); + /*m_name->setEnabled( cmd.find( "%name" ) != -1 );*/ + m_subject->setEnabled( cmd.find( "%subject" ) != -1 && m_cover->isChecked() ); + statusBar()->changeItem(m_faxctrl->faxSystem(), 2); +} + +void KdeprintFax::slotQuit() +{ + close(true); +} + +void KdeprintFax::slotTimeComboActivated(int ID) +{ + m_time->setEnabled(ID == 1); +} + +TQString KdeprintFax::time() const +{ + if (!m_time->isEnabled()) + return TQString::null; + return m_time->time().toString("hh:mm"); +} + +void KdeprintFax::slotMoveUp() +{ + int index = m_files->currentItem(); + if ( index > 0 ) + { + TQListBoxItem *item = m_files->item( index ); + m_files->takeItem( item ); + m_files->insertItem( item, index-1 ); + m_files->setCurrentItem( index-1 ); + } +} + +void KdeprintFax::slotMoveDown() +{ + int index = m_files->currentItem(); + if ( index >= 0 && index < ( int )m_files->count()-1 ) + { + TQListBoxItem *item = m_files->item( index ); + m_files->takeItem( item ); + m_files->insertItem( item, index+1 ); + m_files->setCurrentItem( index+1 ); + } +} + +/** The user or program toggled the "Cover Sheet" check box. + * Update the state of the other controls to reflect the + * new status. + */ +void KdeprintFax::slotCoverToggled(bool) +{ + updateState(); +} + +void KdeprintFax::slotCurrentChanged() +{ + int index = m_files->currentItem(); + m_upbtn->setEnabled( index > 0 ); + m_downbtn->setEnabled( index >=0 && index < ( int )m_files->count()-1 ); +} + +void KdeprintFax::slotFaxSelectionChanged() +{ + TQListViewItemIterator it( m_numbers, TQListViewItemIterator::Selected ); + m_delbtn->setEnabled( it.current() != NULL ); +} + +void KdeprintFax::slotFaxRemove() +{ + TQListViewItemIterator it( m_numbers, TQListViewItemIterator::Selected ); + TQPtrList items; + items.setAutoDelete( true ); + while ( it.current() ) + { + items.append( it.current() ); + ++it; + } + items.clear(); + /* force this slot to be called, to update buttons state */ + slotFaxSelectionChanged(); +} + +void KdeprintFax::slotFaxAdd() +{ + TQString number, name, enterprise; + if ( manualFaxDialog( number, name, enterprise ) ) + { + new TQListViewItem( m_numbers, number, name, enterprise ); + } +} + +void KdeprintFax::slotFaxExecuted( TQListViewItem *item ) +{ + if ( item ) + { + TQString number = item->text( 0 ), name = item->text( 1 ), enterprise = item->text( 2 ); + if ( manualFaxDialog( number, name, enterprise ) ) + { + item->setText( 0, number ); + item->setText( 1, name ); + item->setText( 2, enterprise ); + } + } +} + +bool KdeprintFax::manualFaxDialog( TQString& number, TQString& name, TQString& enterprise ) +{ + /* dialog construction */ + KDialogBase dlg( this, "manualFaxDialog", true, i18n( "Fax Number" ), KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok, true ); + TQWidget *mainw = new TQWidget( &dlg ); + TQLabel *lab0 = new TQLabel( i18n( "Enter recipient fax properties." ), mainw ); + TQLabel *lab1 = new TQLabel( i18n( "&Number:" ), mainw ); + TQLabel *lab2 = new TQLabel( i18n( "N&ame:" ), mainw ); + TQLabel *lab3 = new TQLabel( i18n( "&Enterprise:" ), mainw ); + TQLineEdit *edit_number = new TQLineEdit( number, mainw ); + TQLineEdit *edit_name = new TQLineEdit( name, mainw ); + TQLineEdit *edit_enterprise = new TQLineEdit( enterprise, mainw ); + lab1->setBuddy( edit_number ); + lab2->setBuddy( edit_name ); + lab3->setBuddy( edit_enterprise ); + TQGridLayout *l0 = new TQGridLayout( mainw, 5, 2, 0, 5 ); + l0->setColStretch( 1, 1 ); + l0->addMultiCellWidget( lab0, 0, 0, 0, 1 ); + l0->setRowSpacing( 1, 10 ); + l0->addWidget( lab1, 2, 0 ); + l0->addWidget( lab2, 3, 0 ); + l0->addWidget( lab3, 4, 0 ); + l0->addWidget( edit_number, 2, 1 ); + l0->addWidget( edit_name, 3, 1 ); + l0->addWidget( edit_enterprise, 4, 1 ); + dlg.setMainWidget( mainw ); + dlg.resize( 300, 10 ); + + /* dialog execution */ + while ( 1 ) + if ( dlg.exec() ) + { + if ( edit_number->text().isEmpty() ) + { + KMessageBox::error( this, i18n( "Invalid fax number." ) ); + } + else + { + number = edit_number->text(); + name = edit_name->text(); + enterprise = edit_enterprise->text(); + return true; + } + } + else + return false; +} + +#include "tdeprintfax.moc" diff --git a/tdeprint/tdeprintfax/tdeprintfax.desktop b/tdeprint/tdeprintfax/tdeprintfax.desktop new file mode 100644 index 000000000..dc9c90bab --- /dev/null +++ b/tdeprint/tdeprintfax/tdeprintfax.desktop @@ -0,0 +1,97 @@ +[Desktop Entry] +Name=KdeprintFax +Name[cy]=KdeargraffuFfacs +Name[eo]=Presfakso +Name[hi]=केडीई-प्रिंट-फ़ैक्स +Name[lo]=ອິນເຕີເນັດ +Name[ne]=Kdeprint फ्याक्स +Name[nso]=Fax ya kgatiso ya kde +Name[pa]=Kde ਫੈਕਸ ਛਾਪਣ +Name[rw]=Kde-gucapaFagisi +Name[sv]=KDE:s skriv ut fax +Name[ta]=Kdeஅச்சுபாக்ஸ் +Name[th]=KDEprintFax +Name[vi]=In và Fax của KDE +GenericName=Fax Utility +GenericName[af]=Faks Program +GenericName[ar]=أداة الفاكس +GenericName[be]=Праграма працы з факсам +GenericName[bg]=Програма за факс +GenericName[bn]=ফ্যাক্স টুল +GenericName[br]=Maveg ar faks +GenericName[bs]=Alat za faxove +GenericName[ca]=Utilitat de fax +GenericName[cs]=Faxový nástroj +GenericName[csb]=Faks +GenericName[cy]=Cyfleuster Ffacs +GenericName[da]=FAX-værktøj +GenericName[de]=Fax-Programm +GenericName[el]=Εργαλείο φαξ +GenericName[eo]=Faxutilaĵo +GenericName[es]=Aplicación de fax +GenericName[et]=Faksimise utiliit +GenericName[eu]=Fax tresna +GenericName[fa]=برنامۀ سودمند دورنگار +GenericName[fi]=Faksityökalu +GenericName[fr]=Outil de fax +GenericName[fy]=Faksprogramma +GenericName[ga]=Uirlis Facs +GenericName[gl]=Utilidade de Fax +GenericName[he]=כלי פקסים +GenericName[hi]=फ़ैक्स यूटिलिटी +GenericName[hr]=Alat za fakseve +GenericName[hu]=Faxprogram +GenericName[is]=Faxtól +GenericName[it]=Fax +GenericName[ja]=ファクスユーティリティ +GenericName[ka]=ფაქსთან სამუშაო უტილიტა +GenericName[kk]=Факс утилитасы +GenericName[km]=ឧបករណ៍​ទូរសារ +GenericName[lo]=ເຄື່ອງມືໂທລະສານ +GenericName[lt]=Pagalbinė fakso programėlė +GenericName[lv]=Faksa utilīta +GenericName[mk]=Алатка за факс +GenericName[mn]=Fax-програм +GenericName[ms]=Kemudahan Faks +GenericName[mt]=Għodda tal-faks +GenericName[nb]=Faksverktøy +GenericName[nds]=Faxwarktüüch +GenericName[ne]=फ्याक्स युटिलिटी +GenericName[nl]=Faxprogramma +GenericName[nn]=Faksverktøy +GenericName[nso]=Sebereka sa Fax +GenericName[pa]=ਫੈਕਸ ਸਹੂਲਤ +GenericName[pl]=Faks +GenericName[pt]=Utilitário de Fax +GenericName[pt_BR]=Utilitário de Fax +GenericName[ro]=Utilitar pentru FAX +GenericName[ru]=Утилита работы с факсами +GenericName[rw]=Nkemurabibazo Fagisi +GenericName[se]=Fáksenreaidu +GenericName[sk]=Faxový nástroj +GenericName[sl]=Pripomoček za faks +GenericName[sr]=Факс програм +GenericName[sr@Latn]=Faks program +GenericName[sv]=Faxverktyg +GenericName[ta]=தொலைநகலி கருவி +GenericName[tg]=Обзори дурнамо +GenericName[th]=เครื่องมือโทรสาร +GenericName[tr]=Faks Görüntüleyici +GenericName[tt]=Faks Qoralı +GenericName[uk]=Утиліта факсу +GenericName[uz]=Faks vositasi +GenericName[uz@cyrillic]=Факс воситаси +GenericName[ven]=Tshishumiswa tsha Fax +GenericName[vi]=Các tiện ích Fax +GenericName[wa]=Usteye di facs +GenericName[xh]=Uncedo lwe Fax +GenericName[zh_CN]=传真工具 +GenericName[zh_TW]=傳真工具 +GenericName[zu]=Isisebenzi se-Fax + +Type=Application +Exec=tdeprintfax -caption "%c" %i %m %u +Icon=tdeprintfax +Terminal=false +X-DCOP-ServiceType=Multi +Categories=Qt;KDE;Utility;X-KDE-Utilities-Peripherals; diff --git a/tdeprint/tdeprintfax/tdeprintfax.h b/tdeprint/tdeprintfax/tdeprintfax.h new file mode 100644 index 000000000..fc1a02f7f --- /dev/null +++ b/tdeprint/tdeprintfax/tdeprintfax.h @@ -0,0 +1,115 @@ +/* + * tdeprintfax - a small fax utility + * Copyright (C) 2001 Michael Goffioul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef KDEPRINTFAX_H +#define KDEPRINTFAX_H + +#include +#include + +class KListBox; +class KListView; +class TQLineEdit; +class TQTextEdit; +class FaxCtrl; +class TQCheckBox; +class TQLabel; +class TQTimeEdit; +class TQComboBox; +class TQPushButton; +class TQListViewItem; + +class KdeprintFax : public KMainWindow +{ + Q_OBJECT +public: + struct FaxItem + { + TQString number; + TQString name; + TQString enterprise; + }; + typedef TQValueList FaxItemList; + typedef TQValueList::ConstIterator FaxItemListIterator; + + KdeprintFax(TQWidget *parent = 0, const char *name = 0); + ~KdeprintFax(); + + void addURL(KURL url); + void setPhone(TQString phone); + void sendFax( bool quitAfterSend ); + TQStringList files(); + int faxCount() const; + //TQString number( int i = 0 ) const; + //TQString name( int i = 0 ) const; + //TQString enterprise( int i = 0 ) const; + FaxItemList faxList() const; + TQString comment() const; + TQString time() const; + TQString subject() const; + bool cover() const; + +protected slots: + void slotToggleMenuBar(); + void slotKab(); + void slotAdd(); + void slotRemove(); + void slotFax(); + void slotAbort(); + void slotMessage(const TQString&); + void slotFaxSent(bool); + void slotViewLog(); + void slotConfigure(); + void slotQuit(); + void slotView(); + void slotTimeComboActivated(int); + void slotMoveUp(); + void slotMoveDown(); + void slotCurrentChanged(); + void slotFaxSelectionChanged(); + void slotFaxRemove(); + void slotFaxAdd(); + void slotFaxExecuted( TQListViewItem* ); + void slotCoverToggled(bool toggle); + +protected: + void initActions(); + void dragEnterEvent(TQDragEnterEvent*); + void dropEvent(TQDropEvent*); + void updateState(); + bool manualFaxDialog( TQString& number, TQString& name, TQString& enterprise ); + //TQListViewItem* faxItem( int i = 0 ) const; + +private: + KListBox *m_files; + KListView *m_numbers; + TQLineEdit *m_subject; + TQTextEdit *m_comment; + FaxCtrl *m_faxctrl; + TQCheckBox *m_cover; + TQLabel *m_msglabel; + TQTimeEdit *m_time; + TQComboBox *m_timecombo; + TQPushButton *m_upbtn, *m_downbtn; + TQPushButton *m_newbtn, *m_abbtn, *m_delbtn; + bool m_quitAfterSend; +}; + +#endif diff --git a/tdeprint/tdeprintfax/tdeprintfaxui.rc b/tdeprint/tdeprintfax/tdeprintfaxui.rc new file mode 100644 index 000000000..ae233a6da --- /dev/null +++ b/tdeprint/tdeprintfax/tdeprintfaxui.rc @@ -0,0 +1,31 @@ + + + + &File + + + + + + Fa&x + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.1