summaryrefslogtreecommitdiffstats
path: root/kdeprint/kdeprintfax
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit4aed2c8219774f5d797760606b8489a92ddc5163 (patch)
tree3f8c130f7d269626bf6a9447407ef6c35954426a /kdeprint/kdeprintfax
downloadtdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz
tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdeprint/kdeprintfax')
-rw-r--r--kdeprint/kdeprintfax/Makefile.am23
-rwxr-xr-xkdeprint/kdeprintfax/anytops98
-rw-r--r--kdeprint/kdeprintfax/conffax.cpp80
-rw-r--r--kdeprint/kdeprintfax/conffax.h40
-rw-r--r--kdeprint/kdeprintfax/conffilters.cpp192
-rw-r--r--kdeprint/kdeprintfax/conffilters.h48
-rw-r--r--kdeprint/kdeprintfax/confgeneral.cpp90
-rw-r--r--kdeprint/kdeprintfax/confgeneral.h43
-rw-r--r--kdeprint/kdeprintfax/configdlg.cpp75
-rw-r--r--kdeprint/kdeprintfax/configdlg.h48
-rw-r--r--kdeprint/kdeprintfax/confsystem.cpp199
-rw-r--r--kdeprint/kdeprintfax/confsystem.h50
-rw-r--r--kdeprint/kdeprintfax/cr16-action-abentry.pngbin0 -> 864 bytes
-rw-r--r--kdeprint/kdeprintfax/defcmds.cpp38
-rw-r--r--kdeprint/kdeprintfax/defcmds.h32
-rw-r--r--kdeprint/kdeprintfax/faxab.cpp212
-rw-r--r--kdeprint/kdeprintfax/faxab.h64
-rw-r--r--kdeprint/kdeprintfax/faxctrl.cpp669
-rw-r--r--kdeprint/kdeprintfax/faxctrl.h73
-rw-r--r--kdeprint/kdeprintfax/faxfilters3
-rw-r--r--kdeprint/kdeprintfax/filterdlg.cpp72
-rw-r--r--kdeprint/kdeprintfax/filterdlg.h41
-rw-r--r--kdeprint/kdeprintfax/hi128-app-kdeprintfax.pngbin0 -> 10612 bytes
-rw-r--r--kdeprint/kdeprintfax/hi16-app-kdeprintfax.pngbin0 -> 787 bytes
-rw-r--r--kdeprint/kdeprintfax/hi22-app-kdeprintfax.pngbin0 -> 1241 bytes
-rw-r--r--kdeprint/kdeprintfax/hi32-app-kdeprintfax.pngbin0 -> 1928 bytes
-rw-r--r--kdeprint/kdeprintfax/hi48-app-kdeprintfax.pngbin0 -> 3352 bytes
-rw-r--r--kdeprint/kdeprintfax/hi64-app-kdeprintfax.pngbin0 -> 4669 bytes
-rw-r--r--kdeprint/kdeprintfax/hisc-app-kdeprintfax.svgzbin0 -> 11876 bytes
-rw-r--r--kdeprint/kdeprintfax/kdeprintfax.cpp607
-rw-r--r--kdeprint/kdeprintfax/kdeprintfax.desktop97
-rw-r--r--kdeprint/kdeprintfax/kdeprintfax.h115
-rw-r--r--kdeprint/kdeprintfax/kdeprintfaxui.rc31
-rw-r--r--kdeprint/kdeprintfax/main.cpp78
34 files changed, 3118 insertions, 0 deletions
diff --git a/kdeprint/kdeprintfax/Makefile.am b/kdeprint/kdeprintfax/Makefile.am
new file mode 100644
index 000000000..c2b072049
--- /dev/null
+++ b/kdeprint/kdeprintfax/Makefile.am
@@ -0,0 +1,23 @@
+INCLUDES= $(all_includes)
+
+bin_PROGRAMS = kdeprintfax
+kdeprintfax_SOURCES = main.cpp kdeprintfax.cpp faxab.cpp faxctrl.cpp confgeneral.cpp configdlg.cpp \
+ conffax.cpp confsystem.cpp conffilters.cpp filterdlg.cpp defcmds.cpp
+kdeprintfax_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+kdeprintfax_LDADD = $(LIB_KDEUI) $(LIB_KIO) $(LIB_KDEPRINT) -lkabc
+kdeprintfax_METASOURCES = AUTO
+
+xdg_apps_DATA = kdeprintfax.desktop
+
+uidir = $(kde_datadir)/kdeprintfax
+ui_DATA = kdeprintfaxui.rc faxfilters
+
+private_SCRIPTS = anytops
+privatedir = $(kde_datadir)/kdeprintfax
+
+messages: rc.cpp
+ $(XGETTEXT) `find . -name \*.h -o -name \*.cpp -o -name \*.cc` -o $(podir)/kdeprintfax.pot
+
+KDE_ICON = kdeprintfax
+pic_ICON = abentry
+picdir = $(kde_datadir)/kdeprintfax/icons
diff --git a/kdeprint/kdeprintfax/anytops b/kdeprint/kdeprintfax/anytops
new file mode 100755
index 000000000..4e67b49e9
--- /dev/null
+++ b/kdeprint/kdeprintfax/anytops
@@ -0,0 +1,98 @@
+#!/bin/sh
+
+FAXFILTERS=./faxfilters
+MIMETYPE=
+PAGE="letter"
+
+usage() {
+ echo "Usage: anytops [-m <filters>] [--mime=<mime-type>] [-p <page>] [--help] <infile> <outfile>"
+ 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 <kdeprint@swing.be>";
+ echo "Small script to convert any file type into PS. Part of kdeprintfax."
+ 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/kdeprint/kdeprintfax/conffax.cpp b/kdeprint/kdeprintfax/conffax.cpp
new file mode 100644
index 000000000..c88184595
--- /dev/null
+++ b/kdeprint/kdeprintfax/conffax.cpp
@@ -0,0 +1,80 @@
+/*
+ * kdeprintfax - 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 <qcombobox.h>
+#include <qlineedit.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qprinter.h>
+
+#include <kglobal.h>
+#include <kconfig.h>
+#include <klocale.h>
+#include <kseparator.h>
+
+#include <stdlib.h>
+
+ConfFax::ConfFax(QWidget *parent, const char *name)
+: QWidget(parent, name)
+{
+ m_resolution = new QComboBox(this);
+ m_resolution->setMinimumHeight(25);
+ m_pagesize = new QComboBox(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"));
+ QLabel *m_resolutionlabel = new QLabel(i18n("&Resolution:"), this);
+ m_resolutionlabel->setBuddy(m_resolution);
+ QLabel *m_pagesizelabel = new QLabel(i18n("&Paper size:"), this);
+ m_pagesizelabel->setBuddy(m_pagesize);
+
+ QGridLayout *l0 = new QGridLayout(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");
+ QString v = conf->readEntry("Page", KGlobal::locale()->pageSize() == QPrinter::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/kdeprint/kdeprintfax/conffax.h b/kdeprint/kdeprintfax/conffax.h
new file mode 100644
index 000000000..ffcd125ae
--- /dev/null
+++ b/kdeprint/kdeprintfax/conffax.h
@@ -0,0 +1,40 @@
+/*
+ * kdeprintfax - 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 <qwidget.h>
+
+class QComboBox;
+
+class ConfFax : public QWidget
+{
+public:
+ ConfFax(QWidget *parent = 0, const char *name = 0);
+
+ void load();
+ void save();
+
+private:
+ QComboBox *m_resolution, *m_pagesize;
+};
+
+#endif
diff --git a/kdeprint/kdeprintfax/conffilters.cpp b/kdeprint/kdeprintfax/conffilters.cpp
new file mode 100644
index 000000000..ab828c582
--- /dev/null
+++ b/kdeprint/kdeprintfax/conffilters.cpp
@@ -0,0 +1,192 @@
+/*
+ * kdeprintfax - 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 <qpushbutton.h>
+#include <qlayout.h>
+#include <qtooltip.h>
+#include <qfile.h>
+#include <qtextstream.h>
+#include <qregexp.h>
+#include <qheader.h>
+
+#include <klocale.h>
+#include <klistview.h>
+#include <kiconloader.h>
+#include <kstandarddirs.h>
+#include <kmessagebox.h>
+
+ConfFilters::ConfFilters(QWidget *parent, const char *name)
+: QWidget(parent, name)
+{
+ m_filters = new KListView(this);
+ m_filters->addColumn(i18n("Mime Type"));
+ m_filters->addColumn(i18n("Command"));
+ m_filters->setFrameStyle(QFrame::WinPanel|QFrame::Sunken);
+ m_filters->setLineWidth(1);
+ m_filters->setSorting(-1);
+ m_filters->header()->setStretchEnabled(true, 1);
+ connect(m_filters, SIGNAL(doubleClicked(QListViewItem*)), SLOT(slotChange()));
+
+ m_add = new QPushButton(this);
+ m_add->setPixmap(BarIcon("filenew"));
+ m_remove = new QPushButton(this);
+ m_remove->setIconSet(BarIconSet("remove"));
+ m_change = new QPushButton(this);
+ m_change->setIconSet(BarIconSet("filter"));
+ m_up = new QPushButton(this);
+ m_up->setIconSet(BarIconSet("up"));
+ m_down = new QPushButton(this);
+ m_down->setIconSet(BarIconSet("down"));
+ connect(m_add, SIGNAL(clicked()), SLOT(slotAdd()));
+ connect(m_change, SIGNAL(clicked()), SLOT(slotChange()));
+ connect(m_remove, SIGNAL(clicked()), SLOT(slotRemove()));
+ connect(m_up, SIGNAL(clicked()), SLOT(slotUp()));
+ connect(m_down, SIGNAL(clicked()), SLOT(slotDown()));
+ QToolTip::add(m_add, i18n("Add filter"));
+ QToolTip::add(m_change, i18n("Modify filter"));
+ QToolTip::add(m_remove, i18n("Remove filter"));
+ QToolTip::add(m_up, i18n("Move filter up"));
+ QToolTip::add(m_down, i18n("Move filter down"));
+
+ QHBoxLayout *l0 = new QHBoxLayout(this, 10, 10);
+ QVBoxLayout *l1 = new QVBoxLayout(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, SIGNAL(selectionChanged ()),SLOT(updateButton()));
+}
+
+void ConfFilters::load()
+{
+ QFile f(locate("data","kdeprintfax/faxfilters"));
+ if (f.exists() && f.open(IO_ReadOnly))
+ {
+ QTextStream t(&f);
+ QString line;
+ int p(-1);
+ QListViewItem *item(0);
+ while (!t.eof())
+ {
+ line = t.readLine().stripWhiteSpace();
+ if ((p=line.find(QRegExp("\\s"))) != -1)
+ {
+ QString mime(line.left(p)), cmd(line.right(line.length()-p-1).stripWhiteSpace());
+ if (!mime.isEmpty() && !cmd.isEmpty())
+ item = new QListViewItem(m_filters, item, mime, cmd);
+ }
+ }
+ }
+}
+
+void ConfFilters::save()
+{
+ QListViewItem *item = m_filters->firstChild();
+ QFile f(locateLocal("data","kdeprintfax/faxfilters"));
+ if (f.open(IO_WriteOnly))
+ {
+ QTextStream t(&f);
+ while (item)
+ {
+ t << item->text(0) << ' ' << item->text(1) << endl;
+ item = item->nextSibling();
+ }
+ }
+}
+
+void ConfFilters::slotAdd()
+{
+ QString mime, cmd;
+ if (FilterDlg::doIt(this, &mime, &cmd))
+ if (!mime.isEmpty() && !cmd.isEmpty())
+ {
+ new QListViewItem(m_filters, m_filters->currentItem(), mime, cmd);
+ updateButton();
+ }
+ else
+ KMessageBox::error(this, i18n("Empty parameters."));
+}
+
+void ConfFilters::slotRemove()
+{
+ QListViewItem *item = m_filters->currentItem();
+ if (item)
+ delete item;
+ updateButton();
+}
+
+void ConfFilters::slotChange()
+{
+ QListViewItem *item = m_filters->currentItem();
+ if (item)
+ {
+ QString 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()
+{
+ QListViewItem *item = m_filters->currentItem();
+ if (item && item->itemAbove())
+ {
+ m_filters->moveItem(item, 0, item->itemAbove()->itemAbove());
+ m_filters->setCurrentItem(item);
+ updateButton();
+ }
+}
+
+void ConfFilters::slotDown()
+{
+ QListViewItem *item = m_filters->currentItem();
+ if (item && item->itemBelow())
+ {
+ m_filters->moveItem(item, 0, item->itemBelow());
+ m_filters->setCurrentItem(item);
+ updateButton();
+ }
+}
+
+void ConfFilters::updateButton()
+{
+ QListViewItem *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/kdeprint/kdeprintfax/conffilters.h b/kdeprint/kdeprintfax/conffilters.h
new file mode 100644
index 000000000..38f564b1f
--- /dev/null
+++ b/kdeprint/kdeprintfax/conffilters.h
@@ -0,0 +1,48 @@
+/*
+ * kdeprintfax - 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 <qwidget.h>
+#include <qpushbutton.h>
+class KListView;
+
+class ConfFilters : public QWidget
+{
+ Q_OBJECT
+public:
+ ConfFilters(QWidget *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;
+ QPushButton *m_add,*m_remove,*m_up,*m_down,*m_change;
+};
+
+#endif
diff --git a/kdeprint/kdeprintfax/confgeneral.cpp b/kdeprint/kdeprintfax/confgeneral.cpp
new file mode 100644
index 000000000..3f592e694
--- /dev/null
+++ b/kdeprint/kdeprintfax/confgeneral.cpp
@@ -0,0 +1,90 @@
+/*
+ * kdeprintfax - 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 <qlineedit.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qcheckbox.h>
+
+#include <kglobal.h>
+#include <kconfig.h>
+#include <klocale.h>
+#include <kseparator.h>
+
+#include <stdlib.h>
+
+ConfGeneral::ConfGeneral(QWidget *parent, const char *name)
+: QWidget(parent, name)
+{
+ m_name = new QLineEdit(this);
+ m_company = new QLineEdit(this);
+ m_number = new QLineEdit(this);
+ QLabel *m_namelabel = new QLabel(i18n("&Name:"), this);
+ m_namelabel->setBuddy(m_name);
+ QLabel *m_companylabel = new QLabel(i18n("&Company:"), this);
+ m_companylabel->setBuddy(m_company);
+ QLabel *m_numberlabel = new QLabel(i18n("N&umber:"), this);
+ m_numberlabel->setBuddy(m_number);
+ KSeparator *sep = new KSeparator( this );
+ m_replace_int_char = new QCheckBox( i18n( "Replace international prefix '+' with:" ), this );
+ m_replace_int_char_val = new QLineEdit( this );
+ m_replace_int_char_val->setEnabled( false );
+
+ connect( m_replace_int_char, SIGNAL( toggled( bool ) ), m_replace_int_char_val, SLOT( setEnabled( bool ) ) );
+
+ QGridLayout *l0 = new QGridLayout(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 );
+ QHBoxLayout *l1 = new QHBoxLayout( 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/kdeprint/kdeprintfax/confgeneral.h b/kdeprint/kdeprintfax/confgeneral.h
new file mode 100644
index 000000000..5f88106d8
--- /dev/null
+++ b/kdeprint/kdeprintfax/confgeneral.h
@@ -0,0 +1,43 @@
+/*
+ * kdeprintfax - 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 <qwidget.h>
+
+class QLineEdit;
+class QCheckBox;
+
+class ConfGeneral : public QWidget
+{
+public:
+ ConfGeneral(QWidget *parent = 0, const char *name = 0);
+
+ void load();
+ void save();
+
+private:
+ QLineEdit *m_name, *m_company, *m_number;
+ QCheckBox *m_replace_int_char;
+ QLineEdit *m_replace_int_char_val;
+};
+
+#endif
diff --git a/kdeprint/kdeprintfax/configdlg.cpp b/kdeprint/kdeprintfax/configdlg.cpp
new file mode 100644
index 000000000..669d8c200
--- /dev/null
+++ b/kdeprint/kdeprintfax/configdlg.cpp
@@ -0,0 +1,75 @@
+/*
+ * kdeprintfax - 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 <qvbox.h>
+#include <klocale.h>
+#include <kiconloader.h>
+
+ConfigDlg::ConfigDlg(QWidget *parent, const char *name)
+: KDialogBase(IconList, i18n("Configuration"), Ok|Cancel, Ok, parent, name, true)
+{
+ QVBox *page1 = addVBoxPage(i18n("Personal"), i18n("Personal Settings"), DesktopIcon("kdmconfig"));
+ m_general = new ConfGeneral(page1, "Personal");
+
+ QVBox *page2 = addVBoxPage(i18n("Page setup"), i18n("Page Setup"), DesktopIcon("editcopy"));
+ m_fax = new ConfFax(page2, "Fax");
+
+ QVBox *page3 = addVBoxPage(i18n("System"), i18n("Fax System Selection"), DesktopIcon("kdeprintfax"));
+ m_system = new ConfSystem(page3, "System");
+
+ QVBox *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(QWidget *parent)
+{
+ ConfigDlg dlg(parent);
+ dlg.load();
+ if (dlg.exec())
+ {
+ dlg.save();
+ return true;
+ }
+ return false;
+}
diff --git a/kdeprint/kdeprintfax/configdlg.h b/kdeprint/kdeprintfax/configdlg.h
new file mode 100644
index 000000000..f4bba762d
--- /dev/null
+++ b/kdeprint/kdeprintfax/configdlg.h
@@ -0,0 +1,48 @@
+/*
+ * kdeprintfax - 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 <kdialogbase.h>
+
+class ConfGeneral;
+class ConfFax;
+class ConfSystem;
+class ConfFilters;
+
+class ConfigDlg : public KDialogBase
+{
+public:
+ static bool configure(QWidget *parent = 0);
+
+protected:
+ ConfigDlg(QWidget *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/kdeprint/kdeprintfax/confsystem.cpp b/kdeprint/kdeprintfax/confsystem.cpp
new file mode 100644
index 000000000..02ee7e66d
--- /dev/null
+++ b/kdeprint/kdeprintfax/confsystem.cpp
@@ -0,0 +1,199 @@
+/*
+ * kdeprintfax - 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 <qlineedit.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qcombobox.h>
+
+#include <kglobal.h>
+#include <kconfig.h>
+#include <klocale.h>
+#include <kseparator.h>
+
+#include <stdlib.h>
+
+#define EFAX_ID 0
+#define HYLAFAX_ID 1
+#define MGETTY_ID 2
+#define OTHER_ID 3
+
+ConfSystem::ConfSystem(QWidget *parent, const char *name)
+: QWidget(parent, name)
+{
+ m_system = new QComboBox(this);
+ m_system->insertItem("EFax");
+ m_system->insertItem("HylaFax");
+ m_system->insertItem("Mgetty-sendfax");
+ m_system->insertItem( "Other" );
+ m_command = new QLineEdit(this);
+ QLabel *syslabel = new QLabel(i18n("F&ax system:"), this);
+ QLabel *cmdlabel = new QLabel(i18n("Co&mmand:"), this);
+ syslabel->setBuddy(m_system);
+ cmdlabel->setBuddy(m_command);
+ connect(m_system, SIGNAL(activated(int)), SLOT(slotSystemChanged(int)));
+ m_current = 0;
+ m_system->setCurrentItem(m_current);
+
+ QWidget *m_dummy1 = new QWidget(this), *m_dummy2 = new QWidget(this);
+ m_server = new QLineEdit(m_dummy1);
+ m_device = new QComboBox(m_dummy2);
+ QLabel *srvlabel = new QLabel(i18n("Fax &server (if any):"), m_dummy1);
+ QLabel *devlabel = new QLabel(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(i18n("Serial Port #%1").arg(i));
+ m_device->insertItem( i18n( "Other" ) );
+ connect( m_device, SIGNAL( activated( int ) ), SLOT( slotDeviceChanged( int ) ) );
+ m_device_edit = new QLineEdit( m_dummy2 );
+ slotDeviceChanged( 0 );
+
+ KSeparator *sep = new KSeparator(this);
+ sep->setMinimumHeight(10);
+
+ QVBoxLayout *l0 = new QVBoxLayout(this, 10, 10);
+ QGridLayout *l1 = new QGridLayout(0, 2, 2, 0, 10);
+ l0->addLayout(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);
+ QHBoxLayout *l4 = new QHBoxLayout(m_dummy1, 0, 10);
+ l4->addWidget(srvlabel, 0);
+ l4->addWidget(m_server, 1);
+ QGridLayout *l5 = new QGridLayout( 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", QString::null );
+ QString 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 ? QString("modem") : QString("ttyS%1").arg(m_device->currentItem()-1));
+ else
+ {
+ QString 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/kdeprint/kdeprintfax/confsystem.h b/kdeprint/kdeprintfax/confsystem.h
new file mode 100644
index 000000000..202e5f7a0
--- /dev/null
+++ b/kdeprint/kdeprintfax/confsystem.h
@@ -0,0 +1,50 @@
+/*
+ * kdeprintfax - 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 <qwidget.h>
+#include <qstringlist.h>
+
+class QLineEdit;
+class QComboBox;
+
+class ConfSystem : public QWidget
+{
+ Q_OBJECT
+public:
+ ConfSystem(QWidget *parent = 0, const char *name = 0);
+
+ void load();
+ void save();
+
+protected slots:
+ void slotSystemChanged(int);
+ void slotDeviceChanged(int);
+
+private:
+ QComboBox *m_system, *m_device;
+ QLineEdit *m_command, *m_server, *m_device_edit;
+ QStringList m_commands;
+ int m_current;
+};
+
+#endif
diff --git a/kdeprint/kdeprintfax/cr16-action-abentry.png b/kdeprint/kdeprintfax/cr16-action-abentry.png
new file mode 100644
index 000000000..b6b1011f3
--- /dev/null
+++ b/kdeprint/kdeprintfax/cr16-action-abentry.png
Binary files differ
diff --git a/kdeprint/kdeprintfax/defcmds.cpp b/kdeprint/kdeprintfax/defcmds.cpp
new file mode 100644
index 000000000..b9fc8beee
--- /dev/null
+++ b/kdeprint/kdeprintfax/defcmds.cpp
@@ -0,0 +1,38 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be>
+ *
+ * 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 <qregexp.h>
+#include <kstandarddirs.h>
+
+QString defaultCommand(const QString& cmd)
+{
+ QString str(cmd);
+ QRegExp r("%exe_(\\w+)");
+ int p(-1);
+ if ((p=r.search(str)) != -1)
+ {
+ QString 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/kdeprint/kdeprintfax/defcmds.h b/kdeprint/kdeprintfax/defcmds.h
new file mode 100644
index 000000000..6502250d3
--- /dev/null
+++ b/kdeprint/kdeprintfax/defcmds.h
@@ -0,0 +1,32 @@
+/*
+ * kdeprintfax - 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 <qstring.h>
+
+#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 -}"
+
+QString defaultCommand(const QString& cmd);
+
+#endif
diff --git a/kdeprint/kdeprintfax/faxab.cpp b/kdeprint/kdeprintfax/faxab.cpp
new file mode 100644
index 000000000..28ba4e5c8
--- /dev/null
+++ b/kdeprint/kdeprintfax/faxab.cpp
@@ -0,0 +1,212 @@
+/*
+ * kdeprintfax - 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 <qlabel.h>
+#include <qlayout.h>
+#include <kpushbutton.h>
+#include <klistview.h>
+#include <qheader.h>
+#include <klocale.h>
+#include <kabc/stdaddressbook.h>
+#include <kmessagebox.h>
+#include <kiconloader.h>
+#include <krun.h>
+#include <kstdguiitem.h>
+#include <kglobal.h>
+#include <kconfig.h>
+
+FaxAB::FaxAB(QWidget *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 );
+ QLabel *m_listlabel = new QLabel(i18n("Entries:"), this);
+ m_ok = new KPushButton(KStdGuiItem::ok(), this);
+ QPushButton *m_cancel = new KPushButton(KStdGuiItem::cancel(), this);
+ QPushButton *m_ab = new KPushButton(KGuiItem(i18n("&Edit Addressbook"), "contents"), this);
+ connect(m_ok, SIGNAL(clicked()), SLOT(accept()));
+ connect(m_cancel, SIGNAL(clicked()), SLOT(reject()));
+ connect(m_ab, SIGNAL(clicked()), SLOT(slotEditAb()));
+ m_ok->setDefault(true);
+
+ QVBoxLayout *l0 = new QVBoxLayout(this, 10, 10);
+ l0->addWidget( m_listlabel );
+ l0->addWidget( m_list );
+ QHBoxLayout *l2 = new QHBoxLayout(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" );
+ QSize defsize( 400, 200 );
+ resize( conf->readSizeEntry( "ABSize", &defsize ) );
+
+ initialize();
+ connect(KABC::StdAddressBook::self(), SIGNAL(addressBookChanged(AddressBook*)), 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 (QValueList<KABC::PhoneNumber>::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
+ {
+ QString 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 (QMap<QString,FaxABEntry>::ConstIterator it=m_entries.begin(); it!=m_entries.end(); ++it)
+ {
+ QCheckListItem *item = new QCheckListItem( m_list, it.key(), QCheckListItem::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(QStringList& number, QStringList& name, QStringList& enterprise, QWidget *parent)
+{
+ FaxAB kab(parent);
+ if (!kab.isValid())
+ {
+ KMessageBox::error(parent, i18n("No fax number found in your address book."));
+ return false;
+ }
+ if (kab.exec())
+ {
+ QListViewItemIterator it( kab.m_list, QListViewItemIterator::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 QString& number, QString& name, QString& enterprise)
+{
+ KABC::AddressBook *bk = KABC::StdAddressBook::self();
+ for (KABC::AddressBook::Iterator it=bk->begin(); it!=bk->end(); ++it)
+ {
+ KABC::PhoneNumber::List numbers = (*it).phoneNumbers();
+ QStringList filteredNumbers;
+ for (QValueList<KABC::PhoneNumber>::Iterator nit=numbers.begin(); nit!=numbers.end(); ++nit)
+ {
+ if (((*nit).type() & KABC::PhoneNumber::Fax) )
+ {
+ QString 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/kdeprint/kdeprintfax/faxab.h b/kdeprint/kdeprintfax/faxab.h
new file mode 100644
index 000000000..c72662055
--- /dev/null
+++ b/kdeprint/kdeprintfax/faxab.h
@@ -0,0 +1,64 @@
+/*
+ * kdeprintfax - 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 <kdialog.h>
+#include <qmap.h>
+#include <qstringlist.h>
+#include <kabc/phonenumber.h>
+
+class KListView;
+class AddressBook;
+class QPushButton;
+
+class FaxAB : public KDialog
+{
+ Q_OBJECT
+public:
+ FaxAB(QWidget *parent = 0, const char *name = 0);
+ ~FaxAB();
+ bool isValid();
+
+ static bool getEntry(QStringList& number, QStringList& name, QStringList& enterprise, QWidget *parent = 0);
+ static bool getEntryByNumber(const QString& number, QString& name, QString& enterprise);
+
+protected slots:
+ void slotEditAb();
+ void slotAbChanged(AddressBook*);
+
+protected:
+ void initialize();
+
+private:
+ struct FaxABEntry
+ {
+ QString m_name;
+ KABC::PhoneNumber m_number;
+ QString m_enterprise;
+ };
+
+ KListView* m_list;
+ QMap<QString,FaxABEntry> m_entries;
+ QPushButton* m_ok;
+};
+
+#endif
diff --git a/kdeprint/kdeprintfax/faxctrl.cpp b/kdeprint/kdeprintfax/faxctrl.cpp
new file mode 100644
index 000000000..4cb5f3bc7
--- /dev/null
+++ b/kdeprint/kdeprintfax/faxctrl.cpp
@@ -0,0 +1,669 @@
+/*
+ * kdeprintfax - 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 "kdeprintfax.h"
+#include "defcmds.h"
+
+#include <ktextedit.h>
+#include <qfile.h>
+#include <qtextstream.h>
+#include <kpushbutton.h>
+#include <qlayout.h>
+#include <qregexp.h>
+#include <kprinter.h>
+#include <qsimplerichtext.h>
+#include <qpainter.h>
+#include <qpaintdevicemetrics.h>
+#include <qvaluestack.h>
+#include <qstylesheet.h>
+
+#include <kprocess.h>
+#include <kglobal.h>
+#include <kconfig.h>
+#include <klocale.h>
+#include <kdialogbase.h>
+#include <kmimetype.h>
+#include <kstandarddirs.h>
+#include <kapplication.h>
+#include <kwin.h>
+#include <kemailsettings.h>
+#include <kdebug.h>
+#include <kstdguiitem.h>
+#include <kfiledialog.h>
+#include <kmessagebox.h>
+
+#include <stdlib.h>
+#include <stdarg.h>
+
+#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 QPrinter::PageSize
+ * @return a pointer to a static string for the name of the page size.
+ */
+char const* pageSizeText(int size)
+{
+ switch(size)
+ {
+ case QPrinter::A4: return "a4";
+ case QPrinter::Legal: return "legal";
+ case QPrinter::Letter: return "letter";
+ default: return "letter";
+ }
+}
+
+/** \brief Return the default page size.
+ */
+static QString pageSize()
+{
+ KConfig *conf = KGlobal::config();
+ conf->setGroup("Fax");
+ return conf->readEntry("Page", pageSizeText(KGlobal::locale()->pageSize()));
+}
+
+static QString stripNumber( const QString& s )
+{
+ KConfig *conf = KGlobal::config();
+ conf->setGroup( "Personal" );
+
+ // removes any non-numeric character, except ('+','*','#') (hope it's supported by faxing tools)
+ QString strip_s = s;
+ strip_s.replace( QRegExp( "[^\\d+*#]" ), "" );
+ if ( strip_s.find( '+' ) != -1 && conf->readBoolEntry( "ReplaceIntChar", false ) )
+ strip_s.replace( "+", conf->readEntry( "ReplaceIntCharVal" ) );
+ return strip_s;
+}
+
+static QString tagList( int n, ... )
+{
+ QString t;
+
+ va_list ap;
+ va_start( ap, n );
+ for ( int i=0; i<n; i++ )
+ {
+ QString tag = va_arg( ap, const char* );
+ tag.append( "(_(\\w|\\{[^\\}]*\\}))?" );
+ if ( t.isEmpty() )
+ t = tag;
+ else
+ t.append( "|" ).append( tag );
+ }
+
+ return t;
+}
+
+/** Process a @c %variable that has a boolean value.
+ * The format is <tt>%name_{iftrue??iffalse}</tt>. 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 <tt>%res_{??-l}</tt>,
+ * and if it uses high resolution, use <tt>%res_{-h??}</tt>. As an
+ * abbreviation, omit the trailing <tt>?</tt>, e.g., <tt>%res_{-h}</tt>.
+ *
+ * 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 QString processTag( const QString& match, bool value)
+{
+ QString 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 QString processTag( const QString& match, const QString& value )
+{
+ QString 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 QString& m, const QString& t )
+{
+ return ( m == t || m.startsWith( t+"_" ) );
+}
+
+static QString replaceTags( const QString& s, const QString& tags, KdeprintFax *fax = NULL, const KdeprintFax::FaxItem& item = KdeprintFax::FaxItem() )
+{
+ // unquote variables (they will be replaced with quoted values later)
+
+ QValueStack<bool> stack;
+ KConfig *conf = KGlobal::config();
+
+ QString cmd = s;
+
+ bool issinglequote=false;
+ bool isdoublequote=false;
+ QRegExp re_noquote("(\\$\\(|\\)|\\(|\"|'|\\\\|`|"+tags+")");
+ QRegExp re_singlequote("('|"+tags+")");
+ QRegExp 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, "$(");
+ QRegExp 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
+ {
+ QString 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 = QString::fromLatin1("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(QWidget *parent, const char *name)
+: QObject(parent, name)
+{
+ m_process = new KProcess();
+ m_process->setUseShell(true);
+ connect(m_process, SIGNAL(receivedStdout(KProcess*,char*,int)), SLOT(slotReceivedStdout(KProcess*,char*,int)));
+ connect(m_process, SIGNAL(receivedStderr(KProcess*,char*,int)), SLOT(slotReceivedStdout(KProcess*,char*,int)));
+ connect(m_process, SIGNAL(processExited(KProcess*)), SLOT(slotProcessExited(KProcess*)));
+ connect(this, SIGNAL(faxSent(bool)), 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 = QString::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)
+{
+ QCString str(buffer, len);
+ kdDebug() << "Received stdout: " << str << endl;
+ addLog(QString(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);
+ }
+}
+
+QString FaxCtrl::faxCommand()
+{
+ KConfig *conf = KGlobal::config();
+ conf->setGroup("System");
+ QString sys = conf->readPathEntry("System", "efax");
+ QString 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", QString::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
+ QString filestr;
+ for (QStringList::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 ) );
+
+ QString 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)
+ {
+ QString 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
+ {
+ QString tmp = locateLocal("tmp","kdeprintfax_") + kapp->randomString(8);
+ m_filteredfiles.prepend(tmp);
+ m_tempfiles.append(tmp);
+ m_process->clearArguments();
+ *m_process << locate("data","kdeprintfax/anytops") << "-m" << KProcess::quote(locate("data","kdeprintfax/faxfilters"))
+ << QString::fromLatin1("--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(QWidget *)
+{
+ if (!m_logview)
+ {
+ QWidget *topView = new QWidget(0, "LogView", WType_TopLevel|WStyle_DialogBorder|WDestructiveClose);
+ m_logview = new KTextEdit(topView);
+ m_logview->setTextFormat( Qt::LogText );
+ m_logview->setWordWrap( QTextEdit::WidgetWidth );
+ m_logview->setPaper( Qt::white );
+ //m_logview->setReadOnly(true);
+ //m_logview->setWordWrap(QTextEdit::NoWrap);
+ QPushButton *m_clear = new KPushButton(KStdGuiItem::clear(), topView);
+ QPushButton *m_close = new KPushButton(KStdGuiItem::close(), topView);
+ QPushButton *m_print = new KPushButton( KStdGuiItem::print(), topView );
+ QPushButton *m_save = new KPushButton( KStdGuiItem::saveAs(), topView );
+ m_close->setDefault(true);
+ connect(m_clear, SIGNAL(clicked()), SLOT(slotClearLog()));
+ connect(m_close, SIGNAL(clicked()), SLOT(slotCloseLog()));
+ connect(m_logview, SIGNAL(destroyed()), SLOT(slotCloseLog()));
+ connect( m_print, SIGNAL( clicked() ), SLOT( slotPrintLog() ) );
+ connect( m_save, SIGNAL( clicked() ), SLOT( slotSaveLog() ) );
+
+ QVBoxLayout *l0 = new QVBoxLayout(topView, 10, 10);
+ l0->addWidget(m_logview);
+ QHBoxLayout *l1 = new QHBoxLayout(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 QString& s )
+{
+ QString t( s );
+ t.prepend( '\n' ).append( '\n' );
+ addLog( t, true );
+}
+
+void FaxCtrl::addLog(const QString& s, bool isTitle)
+{
+ QString t = QStyleSheet::escape(s);
+ if ( isTitle )
+ t.prepend( "<font color=red><b>" ).append( "</b></font>" );
+ m_log.append( t + '\n' );
+ if (m_logview)
+ m_logview->append(t);
+}
+
+QString FaxCtrl::faxSystem()
+{
+ KConfig *conf = KGlobal::config();
+ conf->setGroup("System");
+ QString s = conf->readEntry("System", "efax");
+ s[0] = s[0].upper();
+ return s;
+}
+
+void FaxCtrl::cleanTempFiles()
+{
+ for (QStringList::ConstIterator it=m_tempfiles.begin(); it!=m_tempfiles.end(); ++it)
+ QFile::remove(*it);
+ m_tempfiles.clear();
+}
+
+void FaxCtrl::slotClearLog()
+{
+ m_log = QString::null;
+ if (m_logview)
+ m_logview->clear();
+}
+
+void FaxCtrl::slotCloseLog()
+{
+ const QObject *obj = sender();
+ if (m_logview)
+ {
+ QTextEdit *view = m_logview;
+ m_logview = 0;
+ if (obj && obj->inherits("QPushButton"))
+ 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->topLevelWidget(), i18n( "Fax Log" ) ) )
+ {
+ QPainter painter( &printer );
+ QPaintDeviceMetrics metric( &printer );
+ QRect body( 0, 0, metric.width(), metric.height() ), view( body );
+ //QString txt = m_logview->text();
+ QString txt = m_log;
+
+ txt.replace( '\n', "<br>" );
+ txt.prepend( "<h2>" + i18n( "KDEPrint Fax Tool Log" ) + "</h2>" );
+
+ kdDebug() << "Log: " << txt << endl;
+ QSimpleRichText richText( txt, m_logview->font() );
+
+ richText.setWidth( &painter, body.width() );
+ do
+ {
+ richText.draw( &painter, body.left(), body.top(), view, m_logview->colorGroup() );
+ 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 )
+ {
+ QString filename = KFileDialog::getSaveFileName( QString::null, QString::null, m_logview );
+ if ( !filename.isEmpty() )
+ {
+ QFile f( filename );
+ if ( f.open( IO_WriteOnly ) )
+ {
+ QTextStream 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/kdeprint/kdeprintfax/faxctrl.h b/kdeprint/kdeprintfax/faxctrl.h
new file mode 100644
index 000000000..d3d8086a9
--- /dev/null
+++ b/kdeprint/kdeprintfax/faxctrl.h
@@ -0,0 +1,73 @@
+/*
+ * kdeprintfax - 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 <qobject.h>
+#include <qstring.h>
+#include <qstringlist.h>
+
+#include "kdeprintfax.h"
+
+class KProcess;
+class QTextEdit;
+
+class FaxCtrl : public QObject
+{
+ Q_OBJECT
+public:
+ FaxCtrl(QWidget *parent = 0, const char *name = 0);
+ ~FaxCtrl();
+
+ bool send(KdeprintFax *f);
+ bool abort();
+ void viewLog(QWidget *parent = 0);
+ QString faxSystem();
+ QString faxCommand();
+
+signals:
+ void message(const QString&);
+ 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 QString&, bool = false);
+ void addLogTitle( const QString& );
+
+private:
+ KProcess *m_process;
+ QString m_log, m_command;
+ QStringList m_files, m_filteredfiles, m_tempfiles;
+ QTextEdit *m_logview;
+ KdeprintFax::FaxItemList m_faxlist;
+};
+
+#endif
diff --git a/kdeprint/kdeprintfax/faxfilters b/kdeprint/kdeprintfax/faxfilters
new file mode 100644
index 000000000..73e96a14e
--- /dev/null
+++ b/kdeprint/kdeprintfax/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/kdeprint/kdeprintfax/filterdlg.cpp b/kdeprint/kdeprintfax/filterdlg.cpp
new file mode 100644
index 000000000..563c37a7d
--- /dev/null
+++ b/kdeprint/kdeprintfax/filterdlg.cpp
@@ -0,0 +1,72 @@
+/*
+ * kdeprintfax - 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 <qlineedit.h>
+#include <qlabel.h>
+#include <qlayout.h>
+
+#include <klocale.h>
+
+FilterDlg::FilterDlg(QWidget *parent, const char *name)
+: KDialogBase(parent, name, true, i18n("Filter Parameters"), Ok|Cancel, Ok)
+{
+ QWidget *w = new QWidget(this);
+
+ m_mime = new QLineEdit(w);
+ m_cmd = new QLineEdit(w);
+ QLabel *m_mimelabel = new QLabel(i18n("MIME type:"), w);
+ QLabel *m_cmdlabel = new QLabel(i18n("Command:"), w);
+
+ QGridLayout *l0 = new QGridLayout(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, SIGNAL(textChanged ( const QString & )),this, SLOT(slotTextFilterChanged()));
+ connect(m_cmd, SIGNAL(textChanged ( const QString & )),this, SLOT(slotTextFilterChanged()));
+ slotTextFilterChanged();
+}
+
+void FilterDlg::slotTextFilterChanged( )
+{
+ enableButtonOK(!m_mime->text().isEmpty() && !m_cmd->text().isEmpty());
+}
+
+bool FilterDlg::doIt(QWidget *parent, QString *mime, QString *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/kdeprint/kdeprintfax/filterdlg.h b/kdeprint/kdeprintfax/filterdlg.h
new file mode 100644
index 000000000..f1010a2c6
--- /dev/null
+++ b/kdeprint/kdeprintfax/filterdlg.h
@@ -0,0 +1,41 @@
+/*
+ * kdeprintfax - 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 <kdialogbase.h>
+
+class QLineEdit;
+
+class FilterDlg : public KDialogBase
+{
+ Q_OBJECT
+public:
+ FilterDlg(QWidget *parent = 0, const char *name = 0);
+
+ static bool doIt(QWidget *parent = 0, QString* mime = 0, QString *cmd = 0);
+protected slots:
+ void slotTextFilterChanged();
+private:
+ QLineEdit *m_mime, *m_cmd;
+};
+
+#endif
diff --git a/kdeprint/kdeprintfax/hi128-app-kdeprintfax.png b/kdeprint/kdeprintfax/hi128-app-kdeprintfax.png
new file mode 100644
index 000000000..ad29adba7
--- /dev/null
+++ b/kdeprint/kdeprintfax/hi128-app-kdeprintfax.png
Binary files differ
diff --git a/kdeprint/kdeprintfax/hi16-app-kdeprintfax.png b/kdeprint/kdeprintfax/hi16-app-kdeprintfax.png
new file mode 100644
index 000000000..bb676f8b7
--- /dev/null
+++ b/kdeprint/kdeprintfax/hi16-app-kdeprintfax.png
Binary files differ
diff --git a/kdeprint/kdeprintfax/hi22-app-kdeprintfax.png b/kdeprint/kdeprintfax/hi22-app-kdeprintfax.png
new file mode 100644
index 000000000..90fc64b0b
--- /dev/null
+++ b/kdeprint/kdeprintfax/hi22-app-kdeprintfax.png
Binary files differ
diff --git a/kdeprint/kdeprintfax/hi32-app-kdeprintfax.png b/kdeprint/kdeprintfax/hi32-app-kdeprintfax.png
new file mode 100644
index 000000000..7330eb41f
--- /dev/null
+++ b/kdeprint/kdeprintfax/hi32-app-kdeprintfax.png
Binary files differ
diff --git a/kdeprint/kdeprintfax/hi48-app-kdeprintfax.png b/kdeprint/kdeprintfax/hi48-app-kdeprintfax.png
new file mode 100644
index 000000000..3f58c3695
--- /dev/null
+++ b/kdeprint/kdeprintfax/hi48-app-kdeprintfax.png
Binary files differ
diff --git a/kdeprint/kdeprintfax/hi64-app-kdeprintfax.png b/kdeprint/kdeprintfax/hi64-app-kdeprintfax.png
new file mode 100644
index 000000000..47e156d5f
--- /dev/null
+++ b/kdeprint/kdeprintfax/hi64-app-kdeprintfax.png
Binary files differ
diff --git a/kdeprint/kdeprintfax/hisc-app-kdeprintfax.svgz b/kdeprint/kdeprintfax/hisc-app-kdeprintfax.svgz
new file mode 100644
index 000000000..f46fd4401
--- /dev/null
+++ b/kdeprint/kdeprintfax/hisc-app-kdeprintfax.svgz
Binary files differ
diff --git a/kdeprint/kdeprintfax/kdeprintfax.cpp b/kdeprint/kdeprintfax/kdeprintfax.cpp
new file mode 100644
index 000000000..e10416bef
--- /dev/null
+++ b/kdeprint/kdeprintfax/kdeprintfax.cpp
@@ -0,0 +1,607 @@
+/*
+ * kdeprintfax - 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 "kdeprintfax.h"
+#include "faxab.h"
+#include "faxctrl.h"
+#include "configdlg.h"
+
+#include <qcheckbox.h>
+#include <qlineedit.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qpushbutton.h>
+#include <qtextedit.h>
+#include <qdatetimeedit.h>
+#include <qcombobox.h>
+#include <qtooltip.h>
+
+#include <kapplication.h>
+#include <kstdaction.h>
+#include <kmenubar.h>
+#include <ktoolbar.h>
+#include <kaction.h>
+#include <klistbox.h>
+#include <klistview.h>
+#include <qheader.h>
+#include <klocale.h>
+#include <kiconloader.h>
+#include <kio/netaccess.h>
+#include <kmessagebox.h>
+#include <kfiledialog.h>
+#include <kmimetype.h>
+#include <kseparator.h>
+#include <ksystemtray.h>
+#include <kstatusbar.h>
+#include <ksqueezedtextlabel.h>
+#include <krun.h>
+#include <kopenwith.h>
+#include <kpushbutton.h>
+#include <kurldrag.h>
+#include <kdebug.h>
+
+KdeprintFax::KdeprintFax(QWidget *parent, const char *name)
+: KMainWindow(parent, name)
+{
+ m_faxctrl = new FaxCtrl(this);
+ m_quitAfterSend = false;
+ connect(m_faxctrl, SIGNAL(message(const QString&)), SLOT(slotMessage(const QString&)));
+ connect(m_faxctrl, SIGNAL(faxSent(bool)), SLOT(slotFaxSent(bool)));
+
+ QWidget *mainw = new QWidget(this);
+ setCentralWidget(mainw);
+ m_files = new KListBox(mainw);
+ connect( m_files, SIGNAL( currentChanged( QListBoxItem* ) ), SLOT( slotCurrentChanged() ) );
+ m_upbtn = new KPushButton( mainw );
+ m_upbtn->setIconSet( SmallIconSet( "up" ) );
+ QToolTip::add( m_upbtn, i18n( "Move up" ) );
+ connect( m_upbtn, SIGNAL( clicked() ), SLOT( slotMoveUp() ) );
+ m_upbtn->setEnabled( false );
+ m_downbtn = new KPushButton( mainw );
+ m_downbtn->setIconSet( SmallIconSet( "down" ) );
+ QToolTip::add( m_downbtn, i18n( "Move down" ) );
+ connect( m_downbtn, SIGNAL( clicked() ), SLOT( slotMoveDown() ) );
+ m_downbtn->setEnabled( false );
+ QLabel *m_filelabel = new QLabel(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( QListView::Extended );
+ connect( m_numbers, SIGNAL( selectionChanged() ), SLOT( slotFaxSelectionChanged() ) );
+ connect( m_numbers, SIGNAL( executed( QListViewItem* ) ), SLOT( slotFaxExecuted( QListViewItem* ) ) );
+ m_newbtn = new KPushButton( mainw );
+ m_newbtn->setPixmap( SmallIcon( "edit" ) );
+ QToolTip::add( m_newbtn, i18n( "Add fax number" ) );
+ connect( m_newbtn, SIGNAL( clicked() ), SLOT( slotFaxAdd() ) );
+ m_abbtn = new KPushButton( mainw );
+ m_abbtn->setPixmap( SmallIcon( "kaddressbook" ) );
+ QToolTip::add( m_abbtn, i18n( "Add fax number from addressbook" ) );
+ connect( m_abbtn, SIGNAL( clicked() ), SLOT( slotKab() ) );
+ m_delbtn = new KPushButton( mainw );
+ m_delbtn->setIconSet( SmallIconSet( "edittrash" ) );
+ QToolTip::add( m_delbtn, i18n( "Remove fax number" ) );
+ m_delbtn->setEnabled( false );
+ connect( m_delbtn, SIGNAL( clicked() ), SLOT( slotFaxRemove() ) );
+ QLabel *m_commentlabel = new QLabel(i18n("&Comment:"), mainw);
+ KSystemTray *m_tray = new KSystemTray(this);
+ m_tray->setPixmap(SmallIcon("kdeprintfax"));
+ m_tray->show();
+ m_comment = new QTextEdit(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(QTextEdit::NoWrap);
+ m_comment->setLineWidth(1);
+ m_commentlabel->setBuddy(m_comment);
+ QLabel *m_timelabel = new QLabel(i18n("Sched&ule:"), mainw);
+ m_timecombo = new QComboBox(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 QTimeEdit(mainw);
+ m_time->setTime(QTime::currentTime());
+ m_time->setEnabled(false);
+ connect(m_timecombo, SIGNAL(activated(int)), SLOT(slotTimeComboActivated(int)));
+ m_cover = new QCheckBox(i18n("Send Co&ver Sheet"), mainw);
+ connect(m_cover, SIGNAL(toggled(bool)), SLOT(slotCoverToggled(bool)));
+ m_subject = new QLineEdit( mainw );
+ QLabel *m_subjectlabel = new QLabel( i18n( "Su&bject:" ), mainw );
+ m_subjectlabel->setBuddy( m_subject );
+
+ QGridLayout *l0 = new QGridLayout(mainw, 10, 2, 10, 5);
+ l0->setColStretch(1,1);
+ l0->addWidget(m_filelabel, 0, 0, Qt::AlignLeft|Qt::AlignTop);
+ QHBoxLayout *l2 = new QHBoxLayout( 0, 0, 10 );
+ QVBoxLayout *l3 = new QVBoxLayout( 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);
+ QHBoxLayout *l5 = new QHBoxLayout( 0, 0, 10 );
+ QVBoxLayout *l6 = new QVBoxLayout( 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);
+ QHBoxLayout *l1 = new QHBoxLayout(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);
+ QWidget *d = 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, this, SLOT(slotAdd()), actionCollection(), "file_add");
+ new KAction(i18n("&Remove File"), "remove", Qt::Key_Delete, this, SLOT(slotRemove()), actionCollection(), "file_remove");
+ new KAction(i18n("&Send Fax"), "connect_established", Qt::Key_Return, this, SLOT(slotFax()), actionCollection(), "fax_send");
+ new KAction(i18n("A&bort"), "stop", Qt::Key_Escape, this, SLOT(slotAbort()), actionCollection(), "fax_stop");
+ new KAction(i18n("A&ddress Book"), "kaddressbook", Qt::CTRL+Qt::Key_A, this, SLOT(slotKab()), actionCollection(), "fax_ab");
+ new KAction(i18n("V&iew Log"), "contents", Qt::CTRL+Qt::Key_L, this, SLOT(slotViewLog()), actionCollection(), "fax_log");
+ new KAction(i18n("Vi&ew File"), "filefind", Qt::CTRL+Qt::Key_O, this, SLOT(slotView()), actionCollection(), "file_view");
+ new KAction( i18n( "&New Fax Recipient..." ), "edit", Qt::CTRL+Qt::Key_N, this, SLOT( slotFaxAdd() ), actionCollection(), "fax_add" );
+
+ KStdAction::quit(this, SLOT(slotQuit()), actionCollection());
+ setStandardToolBarMenuEnabled(true);
+ KStdAction::showMenubar(this, SLOT(slotToggleMenuBar()), actionCollection());
+ KStdAction::preferences(this, SLOT(slotConfigure()), actionCollection());
+ KStdAction::keyBindings(guiFactory(), SLOT(configureShortcuts()),
+actionCollection());
+ actionCollection()->action("fax_stop")->setEnabled(false);
+ connect(actionCollection()->action("file_remove"), SIGNAL(enabled(bool)), actionCollection()->action("file_view"), 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(QString::null, QString::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()
+{
+ QStringList number, name, enterprise;
+ if (FaxAB::getEntry(number, name, enterprise, this))
+ {
+ for ( unsigned int i = 0; i<number.count(); i++ )
+ new QListViewItem( m_numbers, number[ i ], name[ i ], enterprise[ i ] );
+ }
+}
+
+void KdeprintFax::addURL(KURL url)
+{
+ QString target;
+ if (KIO::NetAccess::download(url,target,this))
+ {
+ m_files->insertItem(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(QString phone)
+{
+ QString name, enterprise;
+ FaxAB::getEntryByNumber(phone, name, enterprise);
+ new QListViewItem( m_numbers, phone, name, enterprise );
+}
+
+void KdeprintFax::sendFax( bool quitAfterSend )
+{
+ slotFax();
+ m_quitAfterSend = quitAfterSend;
+}
+
+void KdeprintFax::dragEnterEvent(QDragEnterEvent *e)
+{
+ e->accept(KURLDrag::canDecode(e));
+}
+
+void KdeprintFax::dropEvent(QDropEvent *e)
+{
+ KURL::List l;
+ if (KURLDrag::decode(e, l))
+ {
+ for (KURL::List::ConstIterator it = l.begin(); it != l.end(); ++it)
+ addURL(*it);
+ }
+}
+
+QStringList KdeprintFax::files()
+{
+ QStringList l;
+ for (uint i=0; i<m_files->count(); i++)
+ l.append(m_files->text(i));
+ return l;
+}
+
+
+int KdeprintFax::faxCount() const
+{
+ return m_numbers->childCount();
+}
+
+/*
+QListViewItem* KdeprintFax::faxItem( int i ) const
+{
+ QListViewItem *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;
+}
+
+QString KdeprintFax::number( int i ) const
+{
+ QListViewItem *item = faxItem( i );
+ return ( item ? item->text( 0 ) : QString::null );
+}
+
+QString KdeprintFax::name( int i ) const
+{
+ QListViewItem *item = faxItem( i );
+ return ( item ? item->text( 1 ) : QString::null );
+}
+
+QString KdeprintFax::enterprise( int i ) const
+{
+ QListViewItem *item = faxItem( i );
+ return ( item ? item->text( 2 ) : QString::null );
+}
+*/
+
+KdeprintFax::FaxItemList KdeprintFax::faxList() const
+{
+ FaxItemList list;
+ QListViewItemIterator 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;
+}
+
+QString KdeprintFax::comment() const
+{
+ return m_comment->text();
+}
+
+bool KdeprintFax::cover() const
+{
+ return m_cover->isChecked();
+}
+
+QString KdeprintFax::subject() const
+{
+ return m_subject->text();
+}
+
+void KdeprintFax::slotMessage(const QString& 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(QString::null);
+ }
+}
+
+void KdeprintFax::slotViewLog()
+{
+ m_faxctrl->viewLog(this);
+}
+
+void KdeprintFax::slotConfigure()
+{
+ if (ConfigDlg::configure(this))
+ updateState();
+}
+
+void KdeprintFax::updateState()
+{
+ QString 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() ? colorGroup().brush(QColorGroup::Base) : colorGroup().brush(QColorGroup::Background));
+ if (!m_comment->isEnabled())
+ {
+ m_comment->setText("");
+ m_comment->setPaper( colorGroup().background() );
+ }
+ else
+ m_comment->setPaper( colorGroup().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);
+}
+
+QString KdeprintFax::time() const
+{
+ if (!m_time->isEnabled())
+ return QString::null;
+ return m_time->time().toString("hh:mm");
+}
+
+void KdeprintFax::slotMoveUp()
+{
+ int index = m_files->currentItem();
+ if ( index > 0 )
+ {
+ QListBoxItem *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 )
+ {
+ QListBoxItem *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()
+{
+ QListViewItemIterator it( m_numbers, QListViewItemIterator::Selected );
+ m_delbtn->setEnabled( it.current() != NULL );
+}
+
+void KdeprintFax::slotFaxRemove()
+{
+ QListViewItemIterator it( m_numbers, QListViewItemIterator::Selected );
+ QPtrList<QListViewItem> 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()
+{
+ QString number, name, enterprise;
+ if ( manualFaxDialog( number, name, enterprise ) )
+ {
+ new QListViewItem( m_numbers, number, name, enterprise );
+ }
+}
+
+void KdeprintFax::slotFaxExecuted( QListViewItem *item )
+{
+ if ( item )
+ {
+ QString 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( QString& number, QString& name, QString& enterprise )
+{
+ /* dialog construction */
+ KDialogBase dlg( this, "manualFaxDialog", true, i18n( "Fax Number" ), KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok, true );
+ QWidget *mainw = new QWidget( &dlg );
+ QLabel *lab0 = new QLabel( i18n( "Enter recipient fax properties." ), mainw );
+ QLabel *lab1 = new QLabel( i18n( "&Number:" ), mainw );
+ QLabel *lab2 = new QLabel( i18n( "N&ame:" ), mainw );
+ QLabel *lab3 = new QLabel( i18n( "&Enterprise:" ), mainw );
+ QLineEdit *edit_number = new QLineEdit( number, mainw );
+ QLineEdit *edit_name = new QLineEdit( name, mainw );
+ QLineEdit *edit_enterprise = new QLineEdit( enterprise, mainw );
+ lab1->setBuddy( edit_number );
+ lab2->setBuddy( edit_name );
+ lab3->setBuddy( edit_enterprise );
+ QGridLayout *l0 = new QGridLayout( 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 "kdeprintfax.moc"
diff --git a/kdeprint/kdeprintfax/kdeprintfax.desktop b/kdeprint/kdeprintfax/kdeprintfax.desktop
new file mode 100644
index 000000000..a33f9292f
--- /dev/null
+++ b/kdeprint/kdeprintfax/kdeprintfax.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=kdeprintfax -caption "%c" %i %m %u
+Icon=kdeprintfax
+Terminal=false
+X-DCOP-ServiceType=Multi
+Categories=Qt;KDE;Utility;X-KDE-Utilities-Peripherals;
diff --git a/kdeprint/kdeprintfax/kdeprintfax.h b/kdeprint/kdeprintfax/kdeprintfax.h
new file mode 100644
index 000000000..795521e82
--- /dev/null
+++ b/kdeprint/kdeprintfax/kdeprintfax.h
@@ -0,0 +1,115 @@
+/*
+ * kdeprintfax - 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 <kmainwindow.h>
+#include <kurl.h>
+
+class KListBox;
+class KListView;
+class QLineEdit;
+class QTextEdit;
+class FaxCtrl;
+class QCheckBox;
+class QLabel;
+class QTimeEdit;
+class QComboBox;
+class QPushButton;
+class QListViewItem;
+
+class KdeprintFax : public KMainWindow
+{
+ Q_OBJECT
+public:
+ struct FaxItem
+ {
+ QString number;
+ QString name;
+ QString enterprise;
+ };
+ typedef QValueList<FaxItem> FaxItemList;
+ typedef QValueList<FaxItem>::ConstIterator FaxItemListIterator;
+
+ KdeprintFax(QWidget *parent = 0, const char *name = 0);
+ ~KdeprintFax();
+
+ void addURL(KURL url);
+ void setPhone(QString phone);
+ void sendFax( bool quitAfterSend );
+ QStringList files();
+ int faxCount() const;
+ //QString number( int i = 0 ) const;
+ //QString name( int i = 0 ) const;
+ //QString enterprise( int i = 0 ) const;
+ FaxItemList faxList() const;
+ QString comment() const;
+ QString time() const;
+ QString subject() const;
+ bool cover() const;
+
+protected slots:
+ void slotToggleMenuBar();
+ void slotKab();
+ void slotAdd();
+ void slotRemove();
+ void slotFax();
+ void slotAbort();
+ void slotMessage(const QString&);
+ 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( QListViewItem* );
+ void slotCoverToggled(bool toggle);
+
+protected:
+ void initActions();
+ void dragEnterEvent(QDragEnterEvent*);
+ void dropEvent(QDropEvent*);
+ void updateState();
+ bool manualFaxDialog( QString& number, QString& name, QString& enterprise );
+ //QListViewItem* faxItem( int i = 0 ) const;
+
+private:
+ KListBox *m_files;
+ KListView *m_numbers;
+ QLineEdit *m_subject;
+ QTextEdit *m_comment;
+ FaxCtrl *m_faxctrl;
+ QCheckBox *m_cover;
+ QLabel *m_msglabel;
+ QTimeEdit *m_time;
+ QComboBox *m_timecombo;
+ QPushButton *m_upbtn, *m_downbtn;
+ QPushButton *m_newbtn, *m_abbtn, *m_delbtn;
+ bool m_quitAfterSend;
+};
+
+#endif
diff --git a/kdeprint/kdeprintfax/kdeprintfaxui.rc b/kdeprint/kdeprintfax/kdeprintfaxui.rc
new file mode 100644
index 000000000..09c2be6f2
--- /dev/null
+++ b/kdeprint/kdeprintfax/kdeprintfaxui.rc
@@ -0,0 +1,31 @@
+<!DOCTYPE kpartgui>
+<kpartgui name="kdeprintfax">
+<MenuBar>
+ <Menu name="file"><text>&amp;File</text>
+ <Action name="file_add" />
+ <Action name="file_remove" />
+ <Separator />
+ <Action name="file_view" />
+ </Menu>
+ <Menu name="fax"><text>Fa&amp;x</text>
+ <Action name="fax_send" />
+ <Action name="fax_stop" />
+ <Separator />
+ <Action name="fax_add" />
+ <Action name="fax_ab" />
+ <Separator />
+ <Action name="fax_log" />
+ </Menu>
+</MenuBar>
+<ToolBar name="mainToolBar">
+ <Action name="file_add" />
+ <Action name="file_remove" />
+ <Action name="file_view" />
+ <Separator />
+ <Action name="fax_send" />
+ <Action name="fax_stop" />
+ <Action name="fax_ab" />
+ <Separator />
+ <Action name="fax_log" />
+</ToolBar>
+</kpartgui>
diff --git a/kdeprint/kdeprintfax/main.cpp b/kdeprint/kdeprintfax/main.cpp
new file mode 100644
index 000000000..a4dd3030f
--- /dev/null
+++ b/kdeprint/kdeprintfax/main.cpp
@@ -0,0 +1,78 @@
+/*
+ * kdeprintfax - 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 "kdeprintfax.h"
+
+#include <qfile.h>
+#include <kcmdlineargs.h>
+#include <kaboutdata.h>
+#include <klocale.h>
+#include <kapplication.h>
+
+QString debugFlag;
+int oneShotFlag = false;
+
+static const char description[] =
+ I18N_NOOP("A small fax utility to be used with kdeprint.");
+// 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( "kdeprintfax", I18N_NOOP("KdeprintFax"),
+ "1.0", description, KAboutData::License_GPL,
+ "(c), 2001 Michael Goffioul", 0, "http://printing.kde.org");
+ aboutData.addAuthor("Michael Goffioul",0, "kdeprint@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;i<args->count();i++)
+ w->addURL(args->url(i));
+
+ QString phone = args->getOption( "phone" );
+ if( !phone.isEmpty() ) {
+ w->setPhone( phone );
+ }
+
+ if( args->isSet( "immediate" ) ) {
+ w->sendFax( args->isSet( "batch" ) );
+ }
+
+ args->clear();
+ return a.exec();
+}