From 3ab937971b6d84275813bf4efc1a0106068c54a7 Mon Sep 17 00:00:00 2001 From: Fritz Elfert Date: Sat, 26 May 2001 03:18:01 +0000 Subject: - Bumped up version. - Added klipsi subpackage to rpm specfile - Added capability to copy images in klipsi (currently Psion -> PC only). --- configure.in | 2 +- etc/plptools.spec.in | 35 +++++++++++-- kde2/klipsi/toplevel.cpp | 130 +++++++++++++++++++++++++++++++++++++++++++++-- kde2/klipsi/toplevel.h | 1 + po/de.po | 2 +- 5 files changed, 158 insertions(+), 12 deletions(-) diff --git a/configure.in b/configure.in index 942d07c..8f17acb 100644 --- a/configure.in +++ b/configure.in @@ -4,7 +4,7 @@ AC_CONFIG_AUX_DIR(conf) AC_INIT(Makefile.am) AC_CANONICAL_SYSTEM AM_CONFIG_HEADER(include/config.h) -AM_INIT_AUTOMAKE(plptools, 0.9) +AM_INIT_AUTOMAKE(plptools, 0.10) AM_PROG_LIBTOOL PLP_SET_LIBVERSION diff --git a/etc/plptools.spec.in b/etc/plptools.spec.in index f2bfa46..86679bf 100644 --- a/etc/plptools.spec.in +++ b/etc/plptools.spec.in @@ -1,6 +1,6 @@ Summary: Connectivity for psion series 5. Name: plptools -%define version @@VERSION@@ +%define version @VERSION@ Version: %{version} Release: 1 Vendor: The plptools project @@ -78,7 +78,23 @@ Psion drives. Dieses Packet enthält ein KDE werkzeug zum Backup, Restore und Formatieren von Psion Laufwerken. +%package -n klipsi +Summary: Psion remote clipboard utility for KDE 2.1. +Group: User Interface/Desktops +Requires: %{name} = %{version} kdelibs >= 2.1 qt >= 2.2.4 + +%description -n klipsi +This package contains a KDE utility for using the Psion's remote clipboard +function. + +%description -l de -n klipsi +Dieses Packet enthält ein KDE Werkzeug zum Transfer der Zwischenablage +zwischen Psion und Rechner. + %changelog +* Fri May 25 2001 Fritz Elfert +- Added klipsi subpackage + * Thu May 17 2001 Fritz Elfert - Official release of version 0.8 @@ -155,9 +171,18 @@ fi %files -n kpsion %{_bindir}/kpsion %{_libdir}/libkpsion.* -%{_datadir}/applnk/*/* -%{_datadir}/apps/*/* -%{_datadir}/icons/*/*/apps/* -%{_datadir}/icons/*/*/actions/* +%{_datadir}/applnk/*/kpsion* +%{_datadir}/apps/kpsion/* +%{_datadir}/apps/konqueror/* +%{_datadir}/icons/*/*/apps/kpsion* +%{_datadir}/icons/*/*/actions/psion* %{_datadir}/locale/*/LC_MESSAGES/kpsion.mo %{_datadir}/doc/HTML/*/kpsion + +%files -n klipsi +%{_bindir}/klipsi +%{_libdir}/klipsi.* +%{_datadir}/apps/klipsi/* +%{_datadir}/icons/*/*/apps/klipsi* +%{_datadir}/icons/*/*/actions/klipsi* +%{_datadir}/locale/*/LC_MESSAGES/klipsi.mo diff --git a/kde2/klipsi/toplevel.cpp b/kde2/klipsi/toplevel.cpp index 444502d..3c75afb 100644 --- a/kde2/klipsi/toplevel.cpp +++ b/kde2/klipsi/toplevel.cpp @@ -326,12 +326,119 @@ putClipData(char *data) { closeConnection(); } +#define splitByte(v) \ +do { \ + int j; \ + \ + if (x < bytesPerLine) \ + for (j = 0; j < pixelsPerByte; j++) { \ + if (j && ((oidx % xPixels) == 0)) \ + break; \ + else \ + if (oidx >= picsize) \ + return 0; \ + else { \ + out.addByte((v & mask) * grayVal); \ + v >>= bitsPerPixel; \ + oidx++; \ + } \ + } \ + if (++x >= linelen) \ + x = 0; \ +} while (0) + +QImage *TopLevel:: +decode_image(unsigned char *p) +{ + bufferStore out; + u_int32_t totlen = *((u_int32_t*)p); p += 4; + u_int32_t hdrlen = *((u_int32_t*)p); p += 4; + u_int32_t datlen = totlen - hdrlen; + u_int32_t xPixels = *((u_int32_t*)p); p += 4; + u_int32_t yPixels = *((u_int32_t*)p); p += 4; + u_int32_t xTwips = *((u_int32_t*)p); p += 4; + u_int32_t yTwips = *((u_int32_t*)p); p += 4; + u_int32_t bitsPerPixel = *((u_int32_t*)p); p += 4; + u_int32_t unknown1 = *((u_int32_t*)p); p += 4; + u_int32_t unknown2 = *((u_int32_t*)p); p += 4; + u_int32_t RLEflag = *((u_int32_t*)p); p += 4; + + QString hdr = QString("P5\n%1 %2\n255\n").arg(xPixels).arg(yPixels); + out.addString(hdr.latin1()); + + u_int32_t picsize = xPixels * yPixels; + u_int32_t linelen; + int pixelsPerByte = (8 / bitsPerPixel); + int nColors = 1 << bitsPerPixel; + int grayVal = 255 / (nColors - 1); + int bytesPerLine = (xPixels + pixelsPerByte - 1) / pixelsPerByte; + int mask = (bitsPerPixel << 1) - 1; + + int oidx = 0; + int x = 0; + int y = 0; + int offset = 0; + + if (RLEflag) { + int i = 0; + + while (offset < datlen) { + unsigned char b = *(p + offset); + if (b >= 0x80) { + offset += 0x100 - b + 1; + i += 0x100 - b; + } else { + offset += 2; + i += b + 1; + } + } + linelen = i / yPixels; + offset = 0; + while (offset < datlen) { + unsigned char b = *(p + offset++); + if (b >= 0x80) { + for (i = 0; i < 0x100 - b; i++, offset++) { + if (offset >= datlen) + return 0; // data corrupted + unsigned char b2 = *(p + offset); + splitByte(b2); + } + } else { + if (offset >= datlen) + return 0; + else { + unsigned char b2 = *(p + offset); + unsigned char bs = b2; + for (i = 0; i <= b; i++) { + splitByte(b2); + b2 = bs; + } + } + offset++; + } + } + } else { + linelen = datlen / yPixels; + while (offset < datlen) { + unsigned char b = *(p + offset++); + splitByte(b); + } + } + QImage *img = new QImage(xPixels, yPixels, 8); + if (!img->loadFromData((const uchar *)out.getString(0), out.getLen())) { + delete img; + img = 0L; + } + return img; +} + void TopLevel:: getClipData() { Enum res; PlpDirent de; u_int32_t fh; - QString clipData; + QString clipText; + QImage *clipImg = 0L; res = rf->fgeteattr(CLIPFILE, de); if (res == rfsv::E_PSI_GEN_NONE) { @@ -380,13 +487,21 @@ getClipData() { u_int32_t *td = (u_int32_t*)p; while (lcount > 0) { - if (*td++ == 0x10000033) { + u_int32_t sType = *td++; + if (sType == 0x10000033) { // An ASCII section p = buf + *td; len = *((u_int32_t*)p); p += 4; psiText2ascii(p, len); - clipData += (char *)p; + clipText += (char *)p; + } + if (sType == 0x1000003d) { + // A paint data section + p = buf + *td; + if (clipImg) + delete clipImg; + clipImg = decode_image((unsigned char *)p); } td++; lcount -= 2; @@ -400,9 +515,14 @@ getClipData() { } else closeConnection(); - if (!clipData.isEmpty()) { + if (!clipText.isEmpty()) { + inSetting = true; + clip->setText(clipText); + inSetting = false; + KNotifyClient::event("data received"); + } else if (clipImg) { inSetting = true; - clip->setText(clipData); + clip->setImage(*clipImg); inSetting = false; KNotifyClient::event("data received"); } diff --git a/kde2/klipsi/toplevel.h b/kde2/klipsi/toplevel.h index 1080e49..8121c43 100644 --- a/kde2/klipsi/toplevel.h +++ b/kde2/klipsi/toplevel.h @@ -78,6 +78,7 @@ private: void getClipData(); void closeConnection(); bool checkConnection(); + QImage *decode_image(unsigned char *); QClipboard *clip; KPopupMenu *menu; diff --git a/po/de.po b/po/de.po index b7cbedc..e7a2063 100644 --- a/po/de.po +++ b/po/de.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2001-05-21 23:57+0200\n" +"POT-Creation-Date: 2001-05-21 17:29+0200\n" "PO-Revision-Date: 2001-02-28 02:44CET\n" "Last-Translator: Fritz Elfert \n" "Language-Team: Deutsch \n" -- cgit v1.2.3