aboutsummaryrefslogtreecommitdiffstats
path: root/kde2
diff options
context:
space:
mode:
authorFritz Elfert <felfert@to.com>2001-02-06 01:01:46 +0000
committerFritz Elfert <felfert@to.com>2001-02-06 01:01:46 +0000
commita9fe8f28a4a9aaf1d9b84dbc6907849ace87f66e (patch)
tree0dd290cdf04cfd17a4ab4d0eb86bcb48137a02cb /kde2
parenta8787d39b2bf1851cdea64a5e0eccc2aff7f15de (diff)
downloadplptools-a9fe8f28a4a9aaf1d9b84dbc6907849ace87f66e.tar.gz
plptools-a9fe8f28a4a9aaf1d9b84dbc6907849ace87f66e.tar.bz2
plptools-a9fe8f28a4a9aaf1d9b84dbc6907849ace87f66e.zip
- Added KDE2 PropsDialog Plugin (incomplete)
- Fixed some KDE related autoconf stuff - Added PlpDrive class for returning results from rfsv:devinfo - Added auto-watch in ppsocket and finally got rid of the nasty SIGPIPE bug. Now it's no more necessary to ignore SIGPIPE in applications. - Made constructors of rfsv16, rfsv32, rpcs16 and rpcs32 private to enforce use of the factories. - Removed error output in the factories and replaced that by error codes which can be retrieved and evaluated by an application.
Diffstat (limited to 'kde2')
-rw-r--r--kde2/Makefile.am3
-rw-r--r--kde2/kioslave/Makefile.am22
-rw-r--r--kde2/kioslave/kio_plp.cpp101
-rw-r--r--kde2/kioslave/kio_plp.h1
-rw-r--r--kde2/mime/Makefile.am27
-rw-r--r--kde2/mime/icons/Makefile.am2
-rw-r--r--kde2/mime/x-psion-drive.desktop7
-rw-r--r--kde2/plugins/.cvsignore4
-rw-r--r--kde2/plugins/Makefile.am26
-rw-r--r--kde2/plugins/pie3dpiece.cpp30
-rw-r--r--kde2/plugins/pie3dpiece.h45
-rw-r--r--kde2/plugins/pie3dwidget.cpp120
-rw-r--r--kde2/plugins/pie3dwidget.h56
-rw-r--r--kde2/plugins/plpprops.cc441
-rw-r--r--kde2/plugins/plpprops.desktop40
-rw-r--r--kde2/plugins/plpprops.h144
-rw-r--r--kde2/plugins/plppropsFactory.cc37
-rw-r--r--kde2/plugins/plppropsFactory.h19
18 files changed, 1087 insertions, 38 deletions
diff --git a/kde2/Makefile.am b/kde2/Makefile.am
index fe79aad..c1186d6 100644
--- a/kde2/Makefile.am
+++ b/kde2/Makefile.am
@@ -1,9 +1,8 @@
# $Id$
#
-SUBDIRS = kioslave
+SUBDIRS = kioslave plugins mime
-TMPDEST=
#
# remove all intermediate files that can be recreated using
# Makefile.cvs
diff --git a/kde2/kioslave/Makefile.am b/kde2/kioslave/Makefile.am
index 1b573d9..b527f09 100644
--- a/kde2/kioslave/Makefile.am
+++ b/kde2/kioslave/Makefile.am
@@ -1,26 +1,18 @@
-## Makefile.am of kdebase/kioslave/plp
+# $Id$
INCLUDES = $(all_includes) -I$(top_srcdir)/lib
LDFLAGS = $(all_libraries) $(KDE_RPATH)
-####### Files
-
-kio_plp_la_LDFLAGS = -module -avoid-version -no-undefined
-
-if BUILD_KDE
-
-myprotodir = $(kde_servicesdir)
+kio_plp_la_LDFLAGS = -module -avoid-version
lib_LTLIBRARIES = kio_plp.la
kio_plp_la_SOURCES = kio_plp.cpp
-kio_plp_la_LIBADD = -L$(top_srcdir)/lib -lplp -lkio
-noinst_HEADERS = kio_plp.h
-
-myproto_DATA = psion.protocol
+kio_plp_la_LIBADD = -L$(top_srcdir)/lib -lplp $(LIB_KIO)
-METASOURCES = AUTO
+noinst_HEADERS = kio_plp.h
-bin_SCRIPTS =
+services_DATA = psion.protocol
+servicesdir = $(kde_servicesdir)
-endif
+EXTRA_DIST = $(services_DATA)
diff --git a/kde2/kioslave/kio_plp.cpp b/kde2/kioslave/kio_plp.cpp
index e0464bd..4b9fb49 100644
--- a/kde2/kioslave/kio_plp.cpp
+++ b/kde2/kioslave/kio_plp.cpp
@@ -144,14 +144,6 @@ PLPProtocol::PLPProtocol (const QCString &pool, const QCString &app)
sscanf(uit.key().data(), "uid-%08X-%08X-%08X", &u1, &u2, &u3);
puids.insert(PlpUID(u1, u2, u3), uit.data());
}
-#if 0
- cout << "uids:" << endl;
- for (UidMap::Iterator it = puids.begin(); it != puids.end(); it++) {
- cout << "UID: " << hex << setw(8) << setfill('0') << it.key().uid[0]
- << it.key().uid[1] << it.key().uid[2] << dec << "->" <<
- it.data() << endl;
- }
-#endif
}
PLPProtocol::~PLPProtocol() {
@@ -218,20 +210,20 @@ openConnection() {
plpRfsvSocket = new ppsocket();
if (!plpRfsvSocket->connect((char *)(currentHost.data()), currentPort)) {
- error(ERR_COULD_NOT_CONNECT, i18n("Could not connect to ncpd"));
+ QString tmp = i18n("Could not connect to ncpd at %1:%2").arg(currentHost).arg(currentPort);
+ error(ERR_COULD_NOT_CONNECT, tmp);
return;
}
rfsvfactory factory(plpRfsvSocket);
plpRfsv = factory.create(false);
- if (plpRfsv == 0) {
- error(ERR_COULD_NOT_CONNECT, i18n("Could not read version info"));
+ if (plpRfsv == 0L) {
+ error(ERR_COULD_NOT_CONNECT, i18n("Could not read version info."));
return;
}
/* If we have a S5, get the Psion's Owner- and Mach- info.
* This implicitely sets the Timezone info of the Psion also.
*/
-
ppsocket rpcsSocket;
if (rpcsSocket.connect((char *)(currentHost.data()), currentPort)) {
rpcsfactory factory(&rpcsSocket);
@@ -252,12 +244,10 @@ openConnection() {
if ((res = plpRfsv->devlist(devbits)) == rfsv::E_PSI_GEN_NONE) {
for (int i = 0; i < 26; i++) {
- string vname;
- u_int32_t vtotal, vfree, vattr, vuniqueid;
-
if ((devbits & 1) != 0) {
- if (plpRfsv->devinfo(i, vfree, vtotal, vattr, vuniqueid,
- vname) == rfsv::E_PSI_GEN_NONE) {
+ PlpDrive drive;
+ if (plpRfsv->devinfo(i, drive) == rfsv::E_PSI_GEN_NONE) {
+ string vname = drive.getName();
QString name;
if (!vname.empty())
@@ -374,17 +364,21 @@ createVirtualDirEntry(UDSEntry & entry, bool rdonly) {
atom.m_uds = KIO::UDS_FILE_TYPE;
atom.m_long = S_IFDIR;
- entry.append( atom );
+ entry.append(atom);
atom.m_uds = KIO::UDS_ACCESS;
atom.m_long = S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
if (!rdonly)
atom.m_long |= (S_IWUSR | S_IWGRP | S_IWOTH);
- entry.append( atom );
+ entry.append(atom);
atom.m_uds = KIO::UDS_SIZE;
atom.m_long = 0;
- entry.append( atom );
+ entry.append(atom);
+
+ //atom.m_uds = KIO::UDS_MIME_TYPE;
+ //atom.m_str = QString("inode/x-psion-drive");
+ //entry.append(atom);
}
bool PLPProtocol::
@@ -506,7 +500,7 @@ completeUDSEntry(UDSEntry& entry, PlpDirent &e, bool rom) {
atom.m_long = (attr & rfsv::PSI_A_DIR) ? S_IFDIR : S_IFREG;
entry.append(atom);
-#if 1
+#if 0
KIO::UDSEntry::ConstIterator it = entry.begin();
for( ; it != entry.end(); it++ ) {
switch ((*it).m_uds) {
@@ -891,3 +885,68 @@ copy( const KURL &src, const KURL &dest, int _mode, bool _overwrite ) {
return;
finished();
}
+
+void PLPProtocol::
+special(const QByteArray &a) {
+ kdDebug(PLP_DEBUGAREA) << "special()" << endl;
+
+ QDataStream stream(a, IO_ReadOnly);
+ int tmp;
+ UDSEntry entry;
+ UDSAtom atom;
+
+ stream >> tmp;
+
+ switch (tmp) {
+ case 1: {
+ QString param;
+ PlpDrive drive;
+
+ Enum<rfsv::errs> res;
+ int drv;
+
+ stream >> param;
+
+ if (!isDrive(QString("/") + param)) {
+ error(ERR_PROTOCOL_IS_NOT_A_FILESYSTEM, param);
+ return;
+ }
+ drv = drivechars[param] - 'A';
+ res = plpRfsv->devinfo(drv, drive);
+ if (res != rfsv::E_PSI_GEN_NONE) {
+ error(ERR_COULD_NOT_STAT, param);
+ return;
+ }
+
+ string mtype;
+ drive.getMediaType(mtype);
+
+ // DriveLetter
+ atom.m_uds = KIO::UDS_USER;
+ atom.m_str = QString("%1").arg(drivechars[param]);
+ entry.append(atom);
+ // TypeName
+ atom.m_uds = KIO::UDS_NAME;
+ atom.m_str = QString(mtype.c_str());
+ entry.append(atom);
+ // Total capacity
+ atom.m_uds = KIO::UDS_SIZE;
+ atom.m_long = drive.getSize();
+ entry.append(atom);
+ // Free capacity
+ atom.m_uds = KIO::UDS_MODIFICATION_TIME;
+ atom.m_long = drive.getSpace();
+ entry.append(atom);
+ // UID
+ atom.m_uds = KIO::UDS_CREATION_TIME;
+ atom.m_long = drive.getUID();
+ entry.append(atom);
+ statEntry(entry);
+ }
+ break;
+ default:
+ error(ERR_UNSUPPORTED_PROTOCOL, QString(i18n("Code: %1")).arg(tmp));
+ return;
+ }
+ finished();
+}
diff --git a/kde2/kioslave/kio_plp.h b/kde2/kioslave/kio_plp.h
index c17436e..6768e10 100644
--- a/kde2/kioslave/kio_plp.h
+++ b/kde2/kioslave/kio_plp.h
@@ -52,6 +52,7 @@ public:
virtual void chmod(const KURL& url, int permissions);
virtual void rename(const KURL &src, const KURL &dest, bool overwrite);
virtual void copy(const KURL& src, const KURL &dest, int mode, bool overwrite );
+ virtual void special(const QByteArray &a);
void calcprogress(long total);
private:
diff --git a/kde2/mime/Makefile.am b/kde2/mime/Makefile.am
new file mode 100644
index 0000000..4f52cb1
--- /dev/null
+++ b/kde2/mime/Makefile.am
@@ -0,0 +1,27 @@
+# $Id$
+#
+
+SUBDIRS = icons
+
+EXTRA_DIST = $(wildcard *.desktop)
+
+maintainer-clean-local:
+ rm -f Makefile.in
+
+devmimedir = $(kde_mimedir)/inode
+devmime_DATA = x-psion-drive.desktop
+
+appmimedir = $(kde_mimedir)/application
+appmime_DATA = \
+ x-psion-agenda.desktop \
+ x-psion-backlite.desktop \
+ x-psion-comms.desktop \
+ x-psion-data.desktop \
+ x-psion-encryptit.desktop \
+ x-psion-opl.desktop \
+ x-psion-opo.desktop \
+ x-psion-record.desktop \
+ x-psion-record2.desktop \
+ x-psion-sheet.desktop \
+ x-psion-sketch.desktop \
+ x-psion-word.desktop
diff --git a/kde2/mime/icons/Makefile.am b/kde2/mime/icons/Makefile.am
index 2dffabc..1f5f243 100644
--- a/kde2/mime/icons/Makefile.am
+++ b/kde2/mime/icons/Makefile.am
@@ -5,3 +5,5 @@ maintainer-clean-local:
rm -f Makefile.in
KDE_ICON = AUTO
+
+EXTRA_DIST = $(wildcard *.png)
diff --git a/kde2/mime/x-psion-drive.desktop b/kde2/mime/x-psion-drive.desktop
new file mode 100644
index 0000000..d3b350c
--- /dev/null
+++ b/kde2/mime/x-psion-drive.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Comment=Psion Drive
+Comment[de]=Psion Laufwerk
+Icon=psion_drive
+Type=MimeType
+MimeType=inode/x-psion-drive
+Patterns=
diff --git a/kde2/plugins/.cvsignore b/kde2/plugins/.cvsignore
new file mode 100644
index 0000000..fcada82
--- /dev/null
+++ b/kde2/plugins/.cvsignore
@@ -0,0 +1,4 @@
+*.closure
+*.moc
+Makefile.in
+Makefile
diff --git a/kde2/plugins/Makefile.am b/kde2/plugins/Makefile.am
new file mode 100644
index 0000000..9ef736d
--- /dev/null
+++ b/kde2/plugins/Makefile.am
@@ -0,0 +1,26 @@
+
+AM_CPPFLAGS = -DQT_NO_CAST_ASCII
+
+INCLUDES = $(all_includes) -I$(top_srcdir)/lib
+LDFLAGS = $(all_libraries) $(KDE_RPATH)
+
+libplpprops_la_LDFLAGS = $(LIBDEBUG) $(all_libraries) -module -no-undefined -version-info $(LIBVERSION)
+
+METASOURCES = AUTO
+
+lib_LTLIBRARIES = libplpprops.la
+
+libplpprops_la_SOURCES = plpprops.cc plppropsFactory.cc pie3dpiece.cpp \
+ pie3dwidget.cpp
+libplpprops_la_LIBADD = -L$(top_srcdir)/lib -lplp $(LIB_KIO) $(LIB_KFILE)
+noinst_HEADERS = plpprops.h plppropsFactory.h pie3dpiece.h pie3dwidget.h
+
+services_DATA = plpprops.desktop
+servicesdir = $(kde_servicesdir)
+
+#
+# remove all intermediate files that can be recreated using
+# Makefile.cvs
+#
+maintainer-clean-local:
+ rm -f Makefile.in *.closure
diff --git a/kde2/plugins/pie3dpiece.cpp b/kde2/plugins/pie3dpiece.cpp
new file mode 100644
index 0000000..19c98b9
--- /dev/null
+++ b/kde2/plugins/pie3dpiece.cpp
@@ -0,0 +1,30 @@
+/*
+ * This file is part of the KDE System Control Tool,
+ * Copyright (C)1999 Thorsten Westheider <twesthei@physik.uni-bielefeld.de>
+ *
+ * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ ****************************************************************************/
+
+#include "pie3dpiece.h"
+
+
+Pie3DPiece::Pie3DPiece(int size, const QColor& color) : _size(size),
+ _color(color)
+{
+
+}
+
+
diff --git a/kde2/plugins/pie3dpiece.h b/kde2/plugins/pie3dpiece.h
new file mode 100644
index 0000000..b64fe2a
--- /dev/null
+++ b/kde2/plugins/pie3dpiece.h
@@ -0,0 +1,45 @@
+/*
+ * This file is part of the KDE System Control Tool,
+ * Copyright (C)1999 Thorsten Westheider <twesthei@physik.uni-bielefeld.de>
+ *
+ * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ ****************************************************************************/
+
+#ifndef __PIE3DPIECE_H
+#define __PIE3DPIECE_H
+
+#include <qcolor.h>
+
+
+class Pie3DPiece
+{
+ public:
+
+ Pie3DPiece(int size, const QColor&);
+ Pie3DPiece() {}
+
+ int size() const { return _size; }
+ const QColor& color() const { return _color; }
+
+ private:
+
+ int _size;
+ QColor _color;
+};
+
+
+#endif
+
diff --git a/kde2/plugins/pie3dwidget.cpp b/kde2/plugins/pie3dwidget.cpp
new file mode 100644
index 0000000..72a4578
--- /dev/null
+++ b/kde2/plugins/pie3dwidget.cpp
@@ -0,0 +1,120 @@
+/*
+ * This file is part of the KDE System Control Tool,
+ * Copyright (C)1999 Thorsten Westheider <twesthei@physik.uni-bielefeld.de>
+ *
+ * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Pie3DWidget was inspired by Christian Poulter's KDiskFree
+ *
+ ****************************************************************************/
+
+#include <qpainter.h>
+
+#include "pie3dwidget.h"
+
+
+Pie3DWidget::Pie3DWidget(QWidget *parent, const char *name) : QWidget(parent, name),
+ _totalsize(0)
+{
+ _piecelist.setAutoDelete(true);
+ _piecelist.clear();
+}
+
+
+void Pie3DWidget::addPiece(int size, const QColor& color)
+{
+ _totalsize += size;
+
+ _piecelist.append(new Pie3DPiece(size, color));
+
+ repaint();
+}
+
+
+int Pie3DWidget::heightForWidth(int w) const
+{
+ return (int) (w*0.6);
+}
+
+
+QSize Pie3DWidget::minimumSizeHint() const
+{
+ return QSize(60, 40);
+}
+
+
+QSize Pie3DWidget::sizeHint() const
+{
+ return QSize(width(), width()*0.6);
+}
+
+
+/*
+ * Protected methods
+ ********************/
+
+void Pie3DWidget::paintEvent(QPaintEvent *ev)
+{
+ QPainter p;
+ QColor widgetbg = palette().normal().background();
+ QColor black = QColor(black);
+ int w = width();
+ int h = height();
+ int pieh = h/4;
+ int halfrot = 180*16;
+ int fullrot = 360*16;
+ int bowpos = 0;
+ int i, bowlen, bowcut;
+
+ if (_piecelist.isEmpty()) return;
+
+ p.begin(this);
+ p.setClipRegion(ev->region());
+
+ for (Pie3DPiece *piece = _piecelist.first(); piece; piece = _piecelist.next())
+ {
+ QPalette piecepal(piece->color(), widgetbg);
+
+ bowlen = (int) (((double) piece->size())/_totalsize*fullrot);
+
+ p.setPen((_piecelist.count() > 1) ? black : _piecelist.first()->color());
+ p.setBrush(piecepal.normal().button());
+ p.drawPie(0, 0, w, h-pieh, bowpos, bowlen);
+
+ if (bowpos+bowlen >= halfrot) // Part of the footer is visible
+ {
+ bowcut = (bowpos < halfrot) ? halfrot-bowpos : 0;
+ bowpos += bowcut;
+ bowlen -= bowcut;
+
+ p.setPen(piecepal.normal().mid());
+
+ for (i = 0; i < pieh; i++) p.drawArc(0, i, w, h-pieh, bowpos, bowlen);
+ }
+
+ bowpos += bowlen;
+ }
+
+ p.setPen(black);
+
+ p.drawArc(0, 0, w, h-pieh, 0, fullrot);
+ p.drawArc(0, pieh-1, w, h-pieh, 0, -halfrot);
+
+ p.drawLine(0, (h-pieh)/2, 0, (h+pieh)/2-1);
+ p.drawLine(w-1, (h-pieh)/2, w-1, (h+pieh)/2-1);
+
+ p.end();
+}
+
diff --git a/kde2/plugins/pie3dwidget.h b/kde2/plugins/pie3dwidget.h
new file mode 100644
index 0000000..cda0868
--- /dev/null
+++ b/kde2/plugins/pie3dwidget.h
@@ -0,0 +1,56 @@
+/*
+ * This file is part of the KDE System Control Tool,
+ * Copyright (C)1999 Thorsten Westheider <twesthei@physik.uni-bielefeld.de>
+ *
+ * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Pie3DWidget was inspired by Christian Poulter's KDiskFree
+ *
+ ****************************************************************************/
+
+#ifndef __PIE3DWIDGET_H
+#define __PIE3DWIDGET_H
+
+#include <qwidget.h>
+#include <qlist.h>
+
+#include "pie3dpiece.h"
+
+
+class Pie3DWidget : public QWidget
+{
+ public:
+
+ Pie3DWidget(QWidget *parent = 0L, const char *name = 0L);
+ ~Pie3DWidget() {}
+
+ void addPiece(int size, const QColor&);
+
+ virtual int heightForWidth(int w) const;
+ virtual QSize minimumSizeHint() const;
+ virtual QSize sizeHint() const;
+
+ protected:
+
+ virtual void paintEvent(QPaintEvent *);
+
+ private:
+
+ int _totalsize;
+ QList<Pie3DPiece> _piecelist;
+};
+
+
+#endif
diff --git a/kde2/plugins/plpprops.cc b/kde2/plugins/plpprops.cc
new file mode 100644
index 0000000..bd4a2f5
--- /dev/null
+++ b/kde2/plugins/plpprops.cc
@@ -0,0 +1,441 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stream.h>
+#include <errno.h>
+#include <assert.h>
+
+#include <qfile.h>
+#include <qapplication.h>
+#include <qdir.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qcheckbox.h>
+#include <qstrlist.h>
+#include <qstringlist.h>
+#include <qtextstream.h>
+#include <qpainter.h>
+#include <qlayout.h>
+#include <qcombobox.h>
+#include <qgroupbox.h>
+
+#include <kdialog.h>
+#include <kdirsize.h>
+#include <kdirwatch.h>
+#include <kdebug.h>
+#include <kdesktopfile.h>
+#include <kicondialog.h>
+#include <kurl.h>
+#include <kurlrequester.h>
+#include <klocale.h>
+#include <kglobal.h>
+#include <kglobalsettings.h>
+#include <kstddirs.h>
+#include <kio/job.h>
+#include <kio/renamedlg.h>
+#include <kfiledialog.h>
+#include <kmimetype.h>
+#include <kmessagebox.h>
+#include <kservice.h>
+#include <kglobal.h>
+#include <kcompletion.h>
+#include <klineedit.h>
+//#include <klibloader.h>
+//#include <ktrader.h>
+#include <kio/slaveinterface.h>
+
+#include "plpprops.h"
+#include "pie3dwidget.h"
+
+#include <qobjectlist.h>
+#include <qtabwidget.h>
+
+#define KIO_ARGS QByteArray packedArgs; \
+QDataStream stream( packedArgs, IO_WriteOnly ); stream
+
+class PlpPropsPlugin::PlpPropsPluginPrivate {
+public:
+ PlpPropsPluginPrivate() { }
+ ~PlpPropsPluginPrivate() { }
+
+ QFrame *m_frame;
+};
+
+/*
+ * A VERY UGLY HACK for removing the Permissions-Page from
+ * the Properties dialog.
+ */
+static void
+removePermsPage(QWidget *theDialog) {
+ QObject *qtabwidget = 0L;
+ QFrame *permframe = 0L;
+
+ //
+ // First, find the QTabWidget in the dialog.
+ // This is easy, cause there's only one.
+ //
+ QObjectList *l = theDialog->queryList("QTabWidget");
+ QObjectListIt it(*l);
+ QObject * obj;
+ while ((obj=it.current()) != 0) {
+ ++it;
+ qtabwidget = obj;
+ }
+ delete l;
+
+ // Now, walk thru all Childs of the QTabWidget which are
+ // inherited from class QFrame.
+ //
+ if (qtabwidget != 0L) {
+ l = qtabwidget->queryList("QFrame");
+ QObjectListIt it(*l);
+
+ while ((obj = it.current()) != 0) {
+ QObjectList *l2 = obj->queryList();
+ QObjectListIt it2(*l2);
+ QObject *o2;
+ int qvbl, qgb, qgl, ql, qcb;
+ qvbl = qgb = qgl = ql = qcb = 0;
+
+ // If we found a QFrame, count it's children
+ // by className. We must rely on the numbers,
+ // because not a single child has been given
+ // a name.
+ while ((o2 = it2.current()) != 0) {
+ if (o2->isA("QVBoxLayout"))
+ qvbl++;
+ if (o2->isA("QGroupBox"))
+ qgb++;
+ if (o2->isA("QGridLayout"))
+ qgl++;
+ if (o2->isA("QLabel"))
+ ql++;
+ if (o2->isA("QCheckBox"))
+ qcb++;
+ ++it2;
+ }
+ delete l2;
+
+ // The PermissionsPage is build out of:
+ //
+ // 1 QVBoxLayout, 2 QGroupboxes, 2 QGridLayouts,
+ // 15 QLabels and 12 QCheckBoxes
+ //
+ if ((qvbl == 1) &&
+ (qgb == 2) &&
+ (qgl == 2) &&
+ (ql == 15) &&
+ (qcb == 12)) {
+ permframe = (QFrame *)obj;
+ break;
+ }
+ ++it;
+ }
+ delete l;
+
+ // If we found it, remove it.
+ if (permframe != 0)
+ ((QTabWidget *)qtabwidget)->removePage(permframe);
+ }
+}
+
+PlpPropsPlugin::PlpPropsPlugin(KPropertiesDialog *_props)
+ : KPropsDlgPlugin( _props )
+{
+ d = new PlpPropsPluginPrivate;
+ bool removePerms = false;
+
+ if (!supports(properties->items()))
+ return;
+
+ if (PlpFileAttrPage::supports(properties->items())) {
+ PlpFileAttrPage *p = new PlpFileAttrPage(_props);
+ removePerms = true;
+ }
+ if (PlpDriveAttrPage::supports(properties->items())) {
+ PlpDriveAttrPage *p = new PlpDriveAttrPage(_props);
+ removePerms = true;
+ }
+ if (PlpMachinePage::supports(properties->items())) {
+ PlpMachinePage *p = new PlpMachinePage(_props);
+ }
+ if (PlpOwnerPage::supports(properties->items())) {
+ PlpOwnerPage *p = new PlpOwnerPage(_props);
+ }
+ if (removePerms)
+ removePermsPage(properties->dialog());
+}
+
+PlpPropsPlugin::~PlpPropsPlugin() {
+ delete d;
+}
+
+bool PlpPropsPlugin::supports(KFileItemList _items) {
+ for (KFileItemListIterator it(_items); it.current(); ++it) {
+ KFileItem *fi = it.current();
+
+ if (fi->url().protocol() != QString::fromLatin1("psion"))
+ return false;
+ }
+ return true;
+}
+
+void PlpPropsPlugin::applyChanges() {
+ kdDebug(250) << "PlpFileAttrPlugin::applyChanges" << endl;
+}
+
+void PlpPropsPlugin::postApplyChanges() {
+}
+
+class PlpFileAttrPage::PlpFileAttrPagePrivate {
+public:
+ PlpFileAttrPagePrivate() { }
+ ~PlpFileAttrPagePrivate() { }
+
+ QFrame *m_frame;
+};
+
+PlpFileAttrPage::PlpFileAttrPage(KPropertiesDialog *_props)
+ : KPropsDlgPlugin( _props ) {
+ d = new PlpFileAttrPagePrivate;
+ d->m_frame = properties->dialog()->addPage(i18n("Psion &Attributes"));
+}
+
+PlpFileAttrPage::~PlpFileAttrPage() {
+ delete d;
+}
+
+bool PlpFileAttrPage::supports(KFileItemList _items) {
+ for (KFileItemListIterator it(_items); it.current(); ++it) {
+ KFileItem *fi = it.current();
+
+ QString path = fi->url().path(-1);
+ if (path.contains('/') == 1)
+ return false;
+ }
+ return true;
+}
+
+void PlpFileAttrPage::applyChanges() {
+}
+
+class PlpDriveAttrPage::PlpDriveAttrPagePrivate {
+public:
+ PlpDriveAttrPagePrivate() { }
+ ~PlpDriveAttrPagePrivate() { }
+
+ QFrame *m_frame;
+};
+
+PlpDriveAttrPage::PlpDriveAttrPage(KPropertiesDialog *_props)
+ : KPropsDlgPlugin( _props ) {
+
+ d = new PlpDriveAttrPagePrivate;
+ d->m_frame = properties->dialog()->addPage(i18n("Psion &Drive"));
+
+ QBoxLayout *box = new QVBoxLayout( d->m_frame, KDialog::spacingHint() );
+ QLabel *l;
+ QGridLayout *gl;
+
+ KIO_ARGS << int(1) << properties->item()->name();
+ KIO::StatJob *job = new KIO::StatJob(KURL("psion:/"), KIO::CMD_SPECIAL, packedArgs, false);
+ connect(job, SIGNAL(result(KIO::Job *)), SLOT(slotSpecialFinished(KIO::Job *)));
+
+
+ long total = 33267;
+ long free = 12345;
+
+ gb = new QGroupBox(i18n("Information"), d->m_frame);
+ box->addWidget(gb);
+
+ gl = new QGridLayout(gb, 7, 4, 15);
+ gl->addRowSpacing(0, 10);
+
+ l = new QLabel(i18n("Type"), gb);
+ gl->addWidget(l, 1, 0);
+
+ typeLabel = new QLabel(gb);
+ gl->addWidget(typeLabel, 2, 0);
+
+ l = new QLabel(i18n("Total capacity"), gb);
+ gl->addWidget (l, 1, 1);
+
+ totalLabel = new QLabel(gb);
+ gl->addWidget(totalLabel, 2, 1);
+
+ l = new QLabel(i18n("Free space"), gb);
+ gl->addWidget (l, 1, 2);
+
+ freeLabel = new QLabel(gb);
+ gl->addWidget(freeLabel, 2, 2);
+
+ l = new QLabel(i18n("Unique ID"), gb);
+ gl->addWidget (l, 1, 3);
+
+ uidLabel = new QLabel(gb);
+ gl->addWidget(uidLabel, 2, 3);
+
+ pie = new Pie3DWidget(gb, "pie");
+
+ gl->addMultiCellWidget(pie, 3, 4, 1, 2);
+
+ l = new QLabel(i18n("Used space"), gb);
+ gl->addWidget (l, 5, 2);
+
+ l = new QLabel(i18n(" "), gb);
+ l->setBackgroundColor(QColor(219, 58, 197));
+ gl->addWidget (l, 5, 3);
+
+ l = new QLabel(i18n("Free space"), gb);
+ gl->addWidget (l, 6, 2);
+
+ l = new QLabel(i18n(" "), gb);
+ l->setBackgroundColor(QColor(39, 56, 167));
+
+ gl->addWidget (l, 6, 3);
+
+ box->addStretch(10);
+}
+
+PlpDriveAttrPage::~PlpDriveAttrPage() {
+ delete d;
+}
+
+bool PlpDriveAttrPage::supports(KFileItemList _items) {
+ for (KFileItemListIterator it(_items); it.current(); ++it) {
+ KFileItem *fi = it.current();
+
+ QString path = fi->url().path(-1);
+ if (path.contains('/') != 1)
+ return false;
+ }
+ return true;
+}
+
+void PlpDriveAttrPage::applyChanges() {
+}
+
+void PlpDriveAttrPage::slotSpecialFinished(KIO::Job *job) {
+ KIO::StatJob *sJob = static_cast<KIO::StatJob *>(job);
+
+ if (sJob->error())
+ job->showErrorDialog(properties->dialog());
+ else {
+ KIO::UDSEntry e = sJob->statResult();
+ bool total_found = false;
+ bool free_found = false;
+
+ for (KIO::UDSEntry::ConstIterator it = e.begin(); it != e.end(); ++it) {
+ if ((*it).m_uds == KIO::UDS_SIZE) {
+ total_found = true;
+ total = (unsigned long)((*it).m_long);
+ }
+ if ((*it).m_uds == KIO::UDS_MODIFICATION_TIME) {
+ free_found = true;
+ unused = (unsigned long)((*it).m_long);
+ }
+ if ((*it).m_uds == KIO::UDS_CREATION_TIME) {
+ unsigned long uid = (unsigned long)((*it).m_long);
+ uidLabel->setText(QString::fromLatin1("%1").arg(uid, 8, 16));
+ }
+ if ((*it).m_uds == KIO::UDS_NAME) {
+ QString name = ((*it).m_str);
+ typeLabel->setText(name);
+ }
+ if ((*it).m_uds == KIO::UDS_USER) {
+ QString name = ((*it).m_str);
+ gb->setTitle(QString(i18n("Information for Psion drive %1: (%2)")).arg(name).arg(properties->item()->name()));
+ }
+ }
+ if (total_found && free_found) {
+ totalLabel->setText(QString::fromLatin1("%1 (%2)").arg(KIO::convertSize(total)).arg(KGlobal::locale()->formatNumber(total, 0)));
+ freeLabel->setText(QString::fromLatin1("%1 (%2)").arg(KIO::convertSize(unused)).arg(KGlobal::locale()->formatNumber(unused, 0)));
+ pie->addPiece(total - unused, QColor(219, 58, 197));
+ pie->addPiece(unused, QColor(39, 56, 167));
+ }
+ }
+}
+
+class PlpMachinePage::PlpMachinePagePrivate {
+public:
+ PlpMachinePagePrivate() { }
+ ~PlpMachinePagePrivate() { }
+
+ QFrame *m_frame;
+};
+
+PlpMachinePage::PlpMachinePage( KPropertiesDialog *_props )
+ : KPropsDlgPlugin( _props ) {
+
+ d = new PlpMachinePagePrivate;
+ d->m_frame = properties->dialog()->addPage(i18n("Psion &Machine"));
+
+ QVBoxLayout * mainlayout = new QVBoxLayout( d->m_frame, KDialog::spacingHint());
+
+ // Now the widgets in the top layout
+
+ QLabel* l;
+ l = new QLabel(d->m_frame, "Label_1" );
+ l->setText( i18n("Machine UID:") );
+ mainlayout->addWidget(l, 1);
+
+ mainlayout->addStretch(2);
+}
+
+PlpMachinePage::~PlpMachinePage() {
+ delete d;
+}
+
+bool PlpMachinePage::supports(KFileItemList _items) {
+ for (KFileItemListIterator it(_items); it.current(); ++it) {
+ KFileItem *fi = it.current();
+
+ QString path = fi->url().path(-1);
+ if (path.contains('/') != 1)
+ return false;
+ if (fi->mimetype() != QString::fromLatin1("application/x-psion-machine"))
+ return false;
+ }
+ return true;
+}
+
+void PlpMachinePage::applyChanges() {
+}
+
+
+class PlpOwnerPage::PlpOwnerPagePrivate
+{
+public:
+ PlpOwnerPagePrivate() { }
+ ~PlpOwnerPagePrivate() { }
+
+ QFrame *m_frame;
+};
+
+PlpOwnerPage::PlpOwnerPage( KPropertiesDialog *_props ) : KPropsDlgPlugin( _props ) {
+ d = new PlpOwnerPagePrivate;
+ d->m_frame = properties->dialog()->addPage(i18n("Psion &Owner"));
+}
+
+PlpOwnerPage::~PlpOwnerPage() {
+ delete d;
+}
+
+bool PlpOwnerPage::supports(KFileItemList _items) {
+ for (KFileItemListIterator it(_items); it.current(); ++it) {
+ KFileItem *fi = it.current();
+
+ QString path = fi->url().path(-1);
+ if (path.contains('/') != 1)
+ return false;
+ if (fi->mimetype() != QString::fromLatin1("application/x-psion-owner"))
+ return false;
+ }
+ return true;
+}
+
+void PlpOwnerPage::applyChanges() {
+}
+
+#include "plpprops.moc"
diff --git a/kde2/plugins/plpprops.desktop b/kde2/plugins/plpprops.desktop
new file mode 100644
index 0000000..9fc8b2f
--- /dev/null
+++ b/kde2/plugins/plpprops.desktop
@@ -0,0 +1,40 @@
+[Desktop Entry]
+Type=Service
+X-KDE-Library=libplpprops
+Name=Psion Property Dialog Plugin
+ServiceTypes=KPropsDlg/Plugin,all/all
+Comment=Plugin for the Properties Dialog
+Comment[ca]=Endollat pel diàleg de propietats
+Comment[cs]=Modul pro dialog vlastností
+Comment[da]=Plugin til egenskabsdialog
+Comment[de]=Plugin für den Eigenschaften-Dialog
+Comment[el]=Πρόσθετο για το Διάλογο Ιδιοτήτων
+Comment[eo]=Internaĵo por la Eco-dialogo
+Comment[es]=Plugin para el Diálogo de Propiedades
+Comment[et]=Plugina omaduste dialoog
+Comment[fi]=Sovelma asetusikkunalle
+Comment[fr]=Module pour la boîte de dialogue des Propriétés
+Comment[gl]=Plugin para o Diálogo de Propiedades
+Comment[he]=םינייפאמה חיש-ודל עקת ןקתה
+Comment[hu]=Beépülő modul a tulajdonságok párbeszédablakhoz
+Comment[is]=Íhlutur fyrir stillingarforritið
+Comment[it]=Plugin per la finestra delle proprietà
+Comment[ja]=設定ダイアログプラグイン
+Comment[mk]=Плагин за дијалогот за параметри
+Comment[nl]=Plugin voor het 'Eigenschappen'dialoog
+Comment[no]=Plugginn for egenskaper-dialogen
+Comment[no_NY]=Tillegg til eigenskapar-dialogen
+Comment[pl]=Wtyczka do Dialogu Właściwości
+Comment[pt]='Plugin' para o diálogo de propriedades
+Comment[pt_BR]=Plug-in para a janela de Propriedades
+Comment[ro]=Modul pentru dialogul de proprietăţi
+Comment[ru]=Модуль для диалога настроек
+Comment[sk]=Zásuvný modul pre panel Nastavení
+Comment[sl]=Vstavek za pogovorno okno z lastnostmi
+Comment[sr]=Plugin za dijalog sa svojstvima
+Comment[sv]=Insticksprogram för egenskapsdialogen
+Comment[ta]=¦º¡òÐì¸û ¯¨Ã¡¼Öì¸¡É ¦ºÕ¸ø
+Comment[tr]=Özellikler İletişim Kutusu İçin Eklenti
+Comment[uk]=Додаток для діалогу властивостей
+Comment[zh_CN.GB2312]=属性对话的插件
+Comment[zh_TW.Big5]=外掛內容對話框
diff --git a/kde2/plugins/plpprops.h b/kde2/plugins/plpprops.h
new file mode 100644
index 0000000..86f3514
--- /dev/null
+++ b/kde2/plugins/plpprops.h
@@ -0,0 +1,144 @@
+/* $Id$
+ *
+ * This file holds the definitions for all classes used to
+ * display a Psion related properties dialog.
+ */
+
+#ifndef _PLPPROPS_H_
+#define _PLPPROPS_H_
+
+#include <qstring.h>
+#include <qlist.h>
+#include <qgroupbox.h>
+
+#include <kurl.h>
+#include <kfileitem.h>
+#include <kdialogbase.h>
+#include <kpropsdlg.h>
+
+#include "pie3dwidget.h"
+
+namespace KIO { class Job; }
+
+class PlpPropsPlugin : public KPropsDlgPlugin {
+ Q_OBJECT
+ public:
+ /**
+ * Constructor
+ */
+ PlpPropsPlugin( KPropertiesDialog *_props );
+ virtual ~PlpPropsPlugin();
+
+ /**
+ * Applies all changes made.
+ */
+ virtual void applyChanges();
+
+ /**
+ * Tests whether the files specified by _items need a 'General' plugin.
+ */
+ static bool supports(KFileItemList _items);
+
+ /**
+ * Called after all plugins applied their changes
+ */
+ void postApplyChanges();
+
+ private:
+ class PlpPropsPluginPrivate;
+ PlpPropsPluginPrivate *d;
+};
+
+class PlpFileAttrPage : public KPropsDlgPlugin {
+ Q_OBJECT
+ public:
+ /**
+ * Constructor
+ */
+ PlpFileAttrPage(KPropertiesDialog *_props);
+ virtual ~PlpFileAttrPage();
+
+ virtual void applyChanges();
+
+ static bool supports(KFileItemList _items);
+
+ private:
+ class PlpFileAttrPagePrivate;
+ PlpFileAttrPagePrivate *d;
+};
+
+class PlpDriveAttrPage : public KPropsDlgPlugin {
+ Q_OBJECT
+ public:
+ /**
+ * Constructor
+ */
+ PlpDriveAttrPage(KPropertiesDialog *_props);
+ virtual ~PlpDriveAttrPage();
+
+ virtual void applyChanges();
+
+ static bool supports(KFileItemList _items);
+
+ private slots:
+ void slotSpecialFinished(KIO::Job *job);
+
+ private:
+ class PlpDriveAttrPagePrivate;
+ PlpDriveAttrPagePrivate *d;
+
+ unsigned long total;
+ unsigned long unused;
+
+ QGroupBox *gb;
+ QLabel *uidLabel;
+ QLabel *typeLabel;
+ QLabel *totalLabel;
+ QLabel *freeLabel;
+ Pie3DWidget *pie;
+};
+
+
+/**
+ * Used to view/edit machine info.
+ */
+class PlpMachinePage : public KPropsDlgPlugin {
+ Q_OBJECT
+ public:
+ /**
+ * Constructor
+ */
+ PlpMachinePage(KPropertiesDialog *_props);
+ virtual ~PlpMachinePage();
+
+ virtual void applyChanges();
+
+ static bool supports(KFileItemList _items);
+
+ private:
+ class PlpMachinePagePrivate;
+ PlpMachinePagePrivate *d;
+};
+
+/**
+ * Used to view/edit owner info
+ */
+class PlpOwnerPage : public KPropsDlgPlugin {
+ Q_OBJECT
+ public:
+ /**
+ * Constructor
+ */
+ PlpOwnerPage(KPropertiesDialog *_props);
+ virtual ~PlpOwnerPage();
+
+ virtual void applyChanges();
+
+ static bool supports(KFileItemList _items);
+
+ private:
+ class PlpOwnerPagePrivate;
+ PlpOwnerPagePrivate *d;
+};
+
+#endif
diff --git a/kde2/plugins/plppropsFactory.cc b/kde2/plugins/plppropsFactory.cc
new file mode 100644
index 0000000..2c553cf
--- /dev/null
+++ b/kde2/plugins/plppropsFactory.cc
@@ -0,0 +1,37 @@
+#include "plppropsFactory.h"
+#include "plpprops.h"
+
+#include <stream.h>
+#include <kdebug.h>
+#include <klocale.h>
+
+extern "C" {
+ void *init_libplpprops() {
+ return new plppropsFactory();
+ }
+};
+
+plppropsFactory::plppropsFactory(QObject *parent, const char *name)
+ : KLibFactory(parent, name) {
+ s_global = new KInstance("plpprops");
+ // Install the translations
+ //KGlobal::locale()->insertCatalogue("plpprops");
+}
+
+plppropsFactory::~plppropsFactory() {
+ delete s_global;
+}
+
+QObject* plppropsFactory::createObject(QObject* parent, const char *name, const char *classname, const QStringList & ) {
+
+ QObject *obj = 0L;
+
+ cout << "plppropsFactory: name=" << name << " class=" << classname << endl;
+ if ((strcmp(classname, "KPropsDlgPlugin") == 0) &&
+ parent &&
+ parent->inherits("KPropertiesDialog"))
+ obj = new PlpPropsPlugin(static_cast<KPropertiesDialog *>(parent));
+ return obj;
+}
+
+#include <plppropsFactory.moc>
diff --git a/kde2/plugins/plppropsFactory.h b/kde2/plugins/plppropsFactory.h
new file mode 100644
index 0000000..1226560
--- /dev/null
+++ b/kde2/plugins/plppropsFactory.h
@@ -0,0 +1,19 @@
+#ifndef _PLPPROPSFACTORY_H_
+#define _PLPPROPSFACTORY_H_
+
+#include <klibloader.h>
+
+class plppropsFactory : public KLibFactory {
+ Q_OBJECT
+ public:
+ plppropsFactory(QObject *parent = 0, const char *name = 0);
+ virtual ~plppropsFactory();
+
+ virtual QObject* createObject(QObject* parent = 0, const char* name = 0, const char* classname = "QObject", const QStringList &args = QStringList());
+
+ private:
+ KInstance *s_global;
+
+};
+
+#endif