summaryrefslogtreecommitdiff
path: root/noncore/graphics
Unidiff
Diffstat (limited to 'noncore/graphics') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/config.in4
-rw-r--r--noncore/graphics/opie-eye/impl/dir/dir_ifaceinfo.cpp14
-rw-r--r--noncore/graphics/opie-eye/impl/dir/dir_lister.cpp8
-rw-r--r--noncore/graphics/opie-eye/lib/slavemaster.cpp12
-rw-r--r--noncore/graphics/opie-eye/phunk_view.pro2
-rw-r--r--noncore/graphics/opie-eye/slave/jpeg_slave.cpp18
-rw-r--r--noncore/graphics/opie-eye/slave/main.cpp16
-rw-r--r--noncore/graphics/opie-eye/slave/slave.pro6
-rw-r--r--noncore/graphics/opie-eye/slave/slavereciever.cpp22
-rw-r--r--noncore/graphics/opie-eye/slave/thumbnailtool.cpp11
10 files changed, 68 insertions, 45 deletions
diff --git a/noncore/graphics/opie-eye/config.in b/noncore/graphics/opie-eye/config.in
index 996dcf3..d7f9963 100644
--- a/noncore/graphics/opie-eye/config.in
+++ b/noncore/graphics/opie-eye/config.in
@@ -1,9 +1,9 @@
1 config OPIE_EYE 1 config OPIE_EYE
2 boolean "opie-eye The Image Viewer and Browser" 2 boolean "opie-eye The Image Viewer and Browser"
3 default "y" 3 default "y"
4 depends on ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2UI 4 depends on ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI
5 5
6 config OPIE_EYE_SLAVE 6 config OPIE_EYE_SLAVE
7 boolean 7 boolean
8 default "y" if OPIE_EYE 8 default "y" if OPIE_EYE
9 depends on ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2UI 9 depends on ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI
diff --git a/noncore/graphics/opie-eye/impl/dir/dir_ifaceinfo.cpp b/noncore/graphics/opie-eye/impl/dir/dir_ifaceinfo.cpp
index 79f4510..5599ad1 100644
--- a/noncore/graphics/opie-eye/impl/dir/dir_ifaceinfo.cpp
+++ b/noncore/graphics/opie-eye/impl/dir/dir_ifaceinfo.cpp
@@ -1,47 +1,51 @@
1/* 1/*
2 * GPLv2 2 * GPLv2
3 * zecke@handhelds.org 3 * zecke@handhelds.org
4 */ 4 */
5 5
6#include "dir_ifaceinfo.h"
7
8/* OPIE */
9#include <opie2/odebug.h>
10#include <qpe/config.h>
11using namespace Opie::Core;
12
13/* QT */
6#include <qwidget.h> 14#include <qwidget.h>
7#include <qcheckbox.h> 15#include <qcheckbox.h>
8#include <qhbox.h> 16#include <qhbox.h>
9#include <qlabel.h> 17#include <qlabel.h>
10 18
11#include <qpe/config.h>
12
13#include "dir_ifaceinfo.h"
14
15namespace { 19namespace {
16 class DirImageWidget : public QHBox { 20 class DirImageWidget : public QHBox {
17 public: 21 public:
18 DirImageWidget() { 22 DirImageWidget() {
19 chkbox = new QCheckBox( QObject::tr("Show all files"), this ); 23 chkbox = new QCheckBox( QObject::tr("Show all files"), this );
20 } 24 }
21 ~DirImageWidget() {} 25 ~DirImageWidget() {}
22 QCheckBox* chkbox; 26 QCheckBox* chkbox;
23 }; 27 };
24} 28}
25 29
26 30
27DirInterfaceInfo::DirInterfaceInfo() { 31DirInterfaceInfo::DirInterfaceInfo() {
28} 32}
29DirInterfaceInfo::~DirInterfaceInfo() { 33DirInterfaceInfo::~DirInterfaceInfo() {
30} 34}
31 35
32QString DirInterfaceInfo::name()const { 36QString DirInterfaceInfo::name()const {
33 return QString::fromLatin1(QObject::tr("DirView" )); 37 return QString::fromLatin1(QObject::tr("DirView" ));
34} 38}
35 39
36QWidget* DirInterfaceInfo::configWidget(const Config& cfg) { 40QWidget* DirInterfaceInfo::configWidget(const Config& cfg) {
37 DirImageWidget* wid = new DirImageWidget(); 41 DirImageWidget* wid = new DirImageWidget();
38 wid->chkbox->setChecked( cfg.readBoolEntry("Dir_Check_All_Files", true) ); 42 wid->chkbox->setChecked( cfg.readBoolEntry("Dir_Check_All_Files", true) );
39 43
40 return wid; 44 return wid;
41} 45}
42 46
43void DirInterfaceInfo::writeConfig( QWidget* _wid, Config& cfg) { 47void DirInterfaceInfo::writeConfig( QWidget* _wid, Config& cfg) {
44 qWarning( "Write Config" ); 48 owarn << "Write Config" << oendl;
45 DirImageWidget* wid = static_cast<DirImageWidget*>(_wid); 49 DirImageWidget* wid = static_cast<DirImageWidget*>(_wid);
46 cfg.writeEntry("Dir_Check_All_Files", wid->chkbox->isChecked() ); 50 cfg.writeEntry("Dir_Check_All_Files", wid->chkbox->isChecked() );
47} 51}
diff --git a/noncore/graphics/opie-eye/impl/dir/dir_lister.cpp b/noncore/graphics/opie-eye/impl/dir/dir_lister.cpp
index ffea29e..0a5cff4 100644
--- a/noncore/graphics/opie-eye/impl/dir/dir_lister.cpp
+++ b/noncore/graphics/opie-eye/impl/dir/dir_lister.cpp
@@ -1,45 +1,47 @@
1/* 1/*
2 * GPLv2 zecke@handhelds.org 2 * GPLv2 zecke@handhelds.org
3 */ 3 */
4 4
5#include "dir_lister.h" 5#include "dir_lister.h"
6 6
7#include <lib/slavemaster.h> 7#include <lib/slavemaster.h>
8 8
9 9/* OPIE */
10#include <opie2/odebug.h>
10#include <qpe/config.h> 11#include <qpe/config.h>
11#include <qpe/qpeapplication.h> 12#include <qpe/qpeapplication.h>
13using namespace Opie::Core;
12 14
15/* QT */
13#include <qdir.h> 16#include <qdir.h>
14#include <qfileinfo.h> 17#include <qfileinfo.h>
15 18
16
17Dir_DirLister::Dir_DirLister( bool list ) 19Dir_DirLister::Dir_DirLister( bool list )
18 : PDirLister( "dir_dir_lister" ) 20 : PDirLister( "dir_dir_lister" )
19{ 21{
20 m_allFiles = list; 22 m_allFiles = list;
21 qWarning("All Files %d", m_allFiles ); 23 owarn << "All Files " << m_allFiles << "" << oendl;
22 24
23 SlaveMaster* master = SlaveMaster::self(); 25 SlaveMaster* master = SlaveMaster::self();
24 connect( master, SIGNAL(sig_start()), this, SIGNAL(sig_start()) ); 26 connect( master, SIGNAL(sig_start()), this, SIGNAL(sig_start()) );
25 connect( master, SIGNAL(sig_end()), this, SIGNAL(sig_end()) ); 27 connect( master, SIGNAL(sig_end()), this, SIGNAL(sig_end()) );
26 connect( master, SIGNAL(sig_thumbInfo(const QString&, const QString&)), 28 connect( master, SIGNAL(sig_thumbInfo(const QString&, const QString&)),
27 this, SIGNAL(sig_thumbInfo(const QString&, const QString&)) ); 29 this, SIGNAL(sig_thumbInfo(const QString&, const QString&)) );
28 connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)), 30 connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)),
29 this, SIGNAL(sig_fullInfo(const QString&, const QString&)) ); 31 this, SIGNAL(sig_fullInfo(const QString&, const QString&)) );
30 connect( master, SIGNAL(sig_thumbNail(const QString&, const QPixmap&)), 32 connect( master, SIGNAL(sig_thumbNail(const QString&, const QPixmap&)),
31 this, SIGNAL(sig_thumbNail(const QString&, const QPixmap&)) ); 33 this, SIGNAL(sig_thumbNail(const QString&, const QPixmap&)) );
32 34
33} 35}
34 36
35QString Dir_DirLister::defaultPath()const { 37QString Dir_DirLister::defaultPath()const {
36 return QPEApplication::documentDir(); 38 return QPEApplication::documentDir();
37} 39}
38 40
39QString Dir_DirLister::setStartPath( const QString& path ) { 41QString Dir_DirLister::setStartPath( const QString& path ) {
40 m_currentDir.cd( path ); 42 m_currentDir.cd( path );
41 if (!m_currentDir.exists() ) 43 if (!m_currentDir.exists() )
42 m_currentDir.cd(defaultPath()); 44 m_currentDir.cd(defaultPath());
43 45
44 46
45 return m_currentDir.absPath(); 47 return m_currentDir.absPath();
diff --git a/noncore/graphics/opie-eye/lib/slavemaster.cpp b/noncore/graphics/opie-eye/lib/slavemaster.cpp
index 4e28535..5bb7ab8 100644
--- a/noncore/graphics/opie-eye/lib/slavemaster.cpp
+++ b/noncore/graphics/opie-eye/lib/slavemaster.cpp
@@ -1,50 +1,54 @@
1#include "slavemaster.h" 1#include "slavemaster.h"
2 2
3/* OPIE */
4#include <opie2/odebug.h>
3#include <qpe/qpeapplication.h> 5#include <qpe/qpeapplication.h>
4#include <qpe/qcopenvelope_qws.h> 6#include <qpe/qcopenvelope_qws.h>
7using namespace Opie::Core;
5 8
9/* QT */
6#include <qcopchannel_qws.h> 10#include <qcopchannel_qws.h>
7#include <qtimer.h> 11#include <qtimer.h>
8 12
9QDataStream & operator << (QDataStream & str, bool b) 13QDataStream & operator << (QDataStream & str, bool b)
10{ 14{
11 str << Q_INT8(b); 15 str << Q_INT8(b);
12 return str; 16 return str;
13} 17}
14QDataStream & operator >> (QDataStream & str, bool & b) 18QDataStream & operator >> (QDataStream & str, bool & b)
15{ 19{
16 Q_INT8 l; 20 Q_INT8 l;
17 str >> l; 21 str >> l;
18 b = bool(l); 22 b = bool(l);
19 return str; 23 return str;
20} 24}
21 25
22/* 26/*
23 * ! We don't put a Pixmap in!!!! 27 * ! We don't put a Pixmap in!!!!
24 */ 28 */
25QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { 29QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) {
26 qWarning( "Image request is %s %d %d", inf.file.latin1(), inf.width, inf.height ); 30 owarn << "Image request is " << inf.file.latin1() << " " << inf.width << " " << inf.height << "" << oendl;
27 return s << inf.file << inf.width << inf.height; 31 return s << inf.file << inf.width << inf.height;
28} 32}
29QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { 33QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) {
30 s >> inf.file >> inf.pixmap >> inf.width >> inf.height; 34 s >> inf.file >> inf.pixmap >> inf.width >> inf.height;
31 return s; 35 return s;
32} 36}
33QDataStream &operator<<( QDataStream& s, const ImageInfo& i) { 37QDataStream &operator<<( QDataStream& s, const ImageInfo& i) {
34 return s << i.kind << i.file << i.info; 38 return s << i.kind << i.file << i.info;
35} 39}
36QDataStream &operator>>( QDataStream& s, ImageInfo& i ) { 40QDataStream &operator>>( QDataStream& s, ImageInfo& i ) {
37 s >> i.kind >> i.file >> i.info; 41 s >> i.kind >> i.file >> i.info;
38 return s; 42 return s;
39} 43}
40 44
41 45
42 46
43SlaveMaster* SlaveMaster::m_master = 0; 47SlaveMaster* SlaveMaster::m_master = 0;
44 48
45SlaveMaster::SlaveMaster() 49SlaveMaster::SlaveMaster()
46 : m_started( false ) 50 : m_started( false )
47{ 51{
48 QCopChannel *chan= new QCopChannel( "QPE/opie-eye",this ); 52 QCopChannel *chan= new QCopChannel( "QPE/opie-eye",this );
49 connect(chan, SIGNAL(received(const QCString&,const QByteArray&)), 53 connect(chan, SIGNAL(received(const QCString&,const QByteArray&)),
50 this, SLOT(recieve(const QCString&,const QByteArray&)) ); 54 this, SLOT(recieve(const QCString&,const QByteArray&)) );
@@ -57,76 +61,76 @@ SlaveMaster* SlaveMaster::self() {
57 if ( !m_master ) 61 if ( !m_master )
58 m_master = new SlaveMaster; 62 m_master = new SlaveMaster;
59 return m_master; 63 return m_master;
60} 64}
61 65
62void SlaveMaster::thumbInfo( const QString& str) { 66void SlaveMaster::thumbInfo( const QString& str) {
63 m_inThumbInfo.append( str ); 67 m_inThumbInfo.append( str );
64 68
65 if ( !m_started ) { 69 if ( !m_started ) {
66 QTimer::singleShot( 0, this, SLOT(slotTimerStart())); 70 QTimer::singleShot( 0, this, SLOT(slotTimerStart()));
67 m_started = true; 71 m_started = true;
68 } 72 }
69} 73}
70 74
71void SlaveMaster::imageInfo( const QString& str ) { 75void SlaveMaster::imageInfo( const QString& str ) {
72 m_inImageInfo.append( str ); 76 m_inImageInfo.append( str );
73 if ( !m_started ) { 77 if ( !m_started ) {
74 QTimer::singleShot( 0, this, SLOT(slotTimerStart())); 78 QTimer::singleShot( 0, this, SLOT(slotTimerStart()));
75 m_started = true; 79 m_started = true;
76 } 80 }
77} 81}
78 82
79void SlaveMaster::thumbNail( const QString& str, int w, int h ) { 83void SlaveMaster::thumbNail( const QString& str, int w, int h ) {
80 if ( str.isEmpty() ) { 84 if ( str.isEmpty() ) {
81 qWarning( "Asking for empty nail" ); 85 owarn << "Asking for empty nail" << oendl;
82 return; 86 return;
83 } 87 }
84 qWarning( "Asking for thumbNail in size %d %d" + str, w,h ); 88 owarn << "Asking for thumbNail in size " << w << " " << h << "" + str << oendl;
85 PixmapInfo item; 89 PixmapInfo item;
86 item.file = str; item.width = w; item.height = h; 90 item.file = str; item.width = w; item.height = h;
87 item.pixmap = QPixmap(); 91 item.pixmap = QPixmap();
88 m_inThumbNail.append( item ); 92 m_inThumbNail.append( item );
89 93
90 if ( !m_started ) { 94 if ( !m_started ) {
91 QTimer::singleShot( 0, this, SLOT(slotTimerStart())); 95 QTimer::singleShot( 0, this, SLOT(slotTimerStart()));
92 m_started = true; 96 m_started = true;
93 } 97 }
94} 98}
95 99
96 100
97void SlaveMaster::recieve( const QCString& str, const QByteArray& at) { 101void SlaveMaster::recieve( const QCString& str, const QByteArray& at) {
98 102
99 ImageInfos infos; 103 ImageInfos infos;
100 PixmapInfos pixinfos; 104 PixmapInfos pixinfos;
101 105
102 QDataStream stream( at, IO_ReadOnly ); 106 QDataStream stream( at, IO_ReadOnly );
103 if ( str == "pixmapsHandled(PixmapList)" ) 107 if ( str == "pixmapsHandled(PixmapList)" )
104 stream >> pixinfos; 108 stream >> pixinfos;
105 else if ( str == "pixmapsHandled(StringList)" ) 109 else if ( str == "pixmapsHandled(StringList)" )
106 stream >> infos; 110 stream >> infos;
107 111
108 qWarning( "PixInfos %d", pixinfos.count() ); 112 owarn << "PixInfos " << pixinfos.count() << "" << oendl;
109 113
110 bool got_data = ( !infos.isEmpty() || !pixinfos.isEmpty() ); 114 bool got_data = ( !infos.isEmpty() || !pixinfos.isEmpty() );
111 if ( got_data ) { 115 if ( got_data ) {
112 emit sig_start(); 116 emit sig_start();
113 for ( ImageInfos::Iterator _it = infos.begin(); _it != infos.end(); ++_it ) { 117 for ( ImageInfos::Iterator _it = infos.begin(); _it != infos.end(); ++_it ) {
114 if ( (*_it).kind ) 118 if ( (*_it).kind )
115 emit sig_fullInfo( (*_it).file, (*_it).info ); 119 emit sig_fullInfo( (*_it).file, (*_it).info );
116 else 120 else
117 emit sig_thumbInfo( (*_it).file, (*_it).info ); 121 emit sig_thumbInfo( (*_it).file, (*_it).info );
118 } 122 }
119 123
120 for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) 124 for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it )
121 emit sig_thumbNail( (*it).file, (*it).pixmap ); 125 emit sig_thumbNail( (*it).file, (*it).pixmap );
122 emit sig_end(); 126 emit sig_end();
123 } 127 }
124} 128}
125 129
126void SlaveMaster::slotTimerStart() { 130void SlaveMaster::slotTimerStart() {
127 m_started = false; 131 m_started = false;
128 132
129 if ( !m_inThumbInfo.isEmpty() ) { 133 if ( !m_inThumbInfo.isEmpty() ) {
130 QCopEnvelope env("QPE/opie-eye_slave", "thumbInfos(QStringList)" ); 134 QCopEnvelope env("QPE/opie-eye_slave", "thumbInfos(QStringList)" );
131 env << m_inThumbInfo; 135 env << m_inThumbInfo;
132 } 136 }
diff --git a/noncore/graphics/opie-eye/phunk_view.pro b/noncore/graphics/opie-eye/phunk_view.pro
index 17fa22c..0e2202a 100644
--- a/noncore/graphics/opie-eye/phunk_view.pro
+++ b/noncore/graphics/opie-eye/phunk_view.pro
@@ -10,27 +10,27 @@ HEADERS = gui/iconview.h gui/filesystem.h gui/mainwindow.h \
10 impl/dir/dir_lister.h impl/dir/dir_ifaceinfo.h \ 10 impl/dir/dir_lister.h impl/dir/dir_ifaceinfo.h \
11 lib/slavemaster.h \ 11 lib/slavemaster.h \
12 iface/slaveiface.h \ 12 iface/slaveiface.h \
13 gui/imageinfoui.h 13 gui/imageinfoui.h
14 14
15# A list header files 15# A list header files
16 16
17 17
18SOURCES = gui/iconview.cpp gui/filesystem.cpp gui/mainwindow.cpp \ 18SOURCES = gui/iconview.cpp gui/filesystem.cpp gui/mainwindow.cpp \
19 lib/imagecache.cpp lib/viewmap.cpp \ 19 lib/imagecache.cpp lib/viewmap.cpp \
20 impl/dir/dir_dirview.cpp iface/dirlister.cpp \ 20 impl/dir/dir_dirview.cpp iface/dirlister.cpp \
21 iface/dirview.cpp impl/dir/dir_lister.cpp \ 21 iface/dirview.cpp impl/dir/dir_lister.cpp \
22 impl/dir/dir_ifaceinfo.cpp lib/slavemaster.cpp \ 22 impl/dir/dir_ifaceinfo.cpp lib/slavemaster.cpp \
23 gui/imageinfoui.cpp 23 gui/imageinfoui.cpp
24# A list of source files 24# A list of source files
25 25
26INTERFACES = 26INTERFACES =
27# list of ui files 27# list of ui files
28 28
29INCLUDEPATH += . $(OPIEDIR)/include 29INCLUDEPATH += . $(OPIEDIR)/include
30DEPENDPATH += $(OPIEDIR)/include 30DEPENDPATH += $(OPIEDIR)/include
31 31
32 32
33 33
34LIBS += -lqpe -lopieui2 34LIBS += -lqpe -lopiecore2 -lopieui2
35 35
36include ( $(OPIEDIR)/include.pro ) 36include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/graphics/opie-eye/slave/jpeg_slave.cpp b/noncore/graphics/opie-eye/slave/jpeg_slave.cpp
index 086b47f..fb7d5de 100644
--- a/noncore/graphics/opie-eye/slave/jpeg_slave.cpp
+++ b/noncore/graphics/opie-eye/slave/jpeg_slave.cpp
@@ -1,31 +1,35 @@
1#include "jpeg_slave.h" 1#include "jpeg_slave.h"
2
3#include "thumbnailtool.h" 2#include "thumbnailtool.h"
4 3
5PHUNK_VIEW_INTERFACE( "JPEG", JpegSlave ) 4PHUNK_VIEW_INTERFACE( "JPEG", JpegSlave )
6 5
7#include <qtopia/timestring.h> 6/* OPIE */
7#include <opie2/odebug.h>
8#include <qpe/timestring.h>
9using namespace Opie::Core;
10
11/* QT */
8#include <qobject.h> 12#include <qobject.h>
9#include <qimage.h> 13#include <qimage.h>
10 14
11/** 15/**
12 exif.h 16 exif.h
13*/ 17*/
14 18
15#include <stdio.h> 19#include <stdio.h>
16#include <stdlib.h> 20#include <stdlib.h>
17#include <math.h> 21#include <math.h>
18#include <time.h> 22#include <time.h>
19 23
20#include <qstring.h> 24#include <qstring.h>
21#include <qfile.h> 25#include <qfile.h>
22#include <qimage.h> 26#include <qimage.h>
23 27
24typedef enum { 28typedef enum {
25 READ_EXIF = 1, 29 READ_EXIF = 1,
26 READ_IMAGE = 2, 30 READ_IMAGE = 2,
27 READ_ALL = 3 31 READ_ALL = 3
28}ReadMode_t; 32}ReadMode_t;
29 33
30//-------------------------------------------------------------------------- 34//--------------------------------------------------------------------------
31// This structure is used to store jpeg file sections in memory. 35// This structure is used to store jpeg file sections in memory.
@@ -98,49 +102,49 @@ public:
98 int getProcess() { return Process; } 102 int getProcess() { return Process; }
99 int getFlashUsed() { return FlashUsed; } 103 int getFlashUsed() { return FlashUsed; }
100 float getFocalLength() { return FocalLength; } 104 float getFocalLength() { return FocalLength; }
101 float getExposureTime() { return ExposureTime; } 105 float getExposureTime() { return ExposureTime; }
102 float getApertureFNumber() { return ApertureFNumber; } 106 float getApertureFNumber() { return ApertureFNumber; }
103 float getDistance() { return Distance; } 107 float getDistance() { return Distance; }
104 int getWhitebalance() { return Whitebalance; } 108 int getWhitebalance() { return Whitebalance; }
105 int getMeteringMode() { return MeteringMode; } 109 int getMeteringMode() { return MeteringMode; }
106 float getCCDWidth() { return CCDWidth; } 110 float getCCDWidth() { return CCDWidth; }
107 float getExposureBias() { return ExposureBias; } 111 float getExposureBias() { return ExposureBias; }
108 int getExposureProgram() { return ExposureProgram; } 112 int getExposureProgram() { return ExposureProgram; }
109 int getISOequivalent() { return ISOequivalent; } 113 int getISOequivalent() { return ISOequivalent; }
110 int getCompressionLevel() { return CompressionLevel; } 114 int getCompressionLevel() { return CompressionLevel; }
111 QString getUserComment() { return UserComment; } 115 QString getUserComment() { return UserComment; }
112 QString getComment() { return Comment; } 116 QString getComment() { return Comment; }
113 QImage getThumbnail(); 117 QImage getThumbnail();
114 bool isThumbnailSane(); 118 bool isThumbnailSane();
115 bool isNullThumbnail() { return !isThumbnailSane(); } 119 bool isNullThumbnail() { return !isThumbnailSane(); }
116}; 120};
117 121
118class FatalError { 122class FatalError {
119 const char* ex; 123 const char* ex;
120public: 124public:
121 FatalError(const char* s) { ex = s; } 125 FatalError(const char* s) { ex = s; }
122 void debug_print() const { qWarning("exception: %s", ex ); } 126 void debug_print() const { owarn << "exception: " << ex << "" << oendl; }
123}; 127};
124 128
125 129
126 130
127static unsigned char * LastExifRefd; 131static unsigned char * LastExifRefd;
128static int ExifSettingsLength; 132static int ExifSettingsLength;
129static double FocalplaneXRes; 133static double FocalplaneXRes;
130static double FocalplaneUnits; 134static double FocalplaneUnits;
131static int MotorolaOrder = 0; 135static int MotorolaOrder = 0;
132static int SectionsRead; 136static int SectionsRead;
133//static int HaveAll; 137//static int HaveAll;
134 138
135//-------------------------------------------------------------------------- 139//--------------------------------------------------------------------------
136// Table of Jpeg encoding process names 140// Table of Jpeg encoding process names
137 141
138#define M_SOF0 0xC0 // Start Of Frame N 142#define M_SOF0 0xC0 // Start Of Frame N
139#define M_SOF1 0xC1 // N indicates which compression process 143#define M_SOF1 0xC1 // N indicates which compression process
140#define M_SOF2 0xC2 // Only SOF0-SOF2 are now in common use 144#define M_SOF2 0xC2 // Only SOF0-SOF2 are now in common use
141#define M_SOF3 0xC3 145#define M_SOF3 0xC3
142#define M_SOF5 0xC5 // NB: codes C4 and CC are NOT SOF markers 146#define M_SOF5 0xC5 // NB: codes C4 and CC are NOT SOF markers
143#define M_SOF6 0xC6 147#define M_SOF6 0xC6
144#define M_SOF7 0xC7 148#define M_SOF7 0xC7
145#define M_SOF9 0xC9 149#define M_SOF9 0xC9
146#define M_SOF10 0xCA 150#define M_SOF10 0xCA
@@ -241,49 +245,49 @@ static int BytesPerFormat[] = {0,1,1,2,4,8,1,1,2,4,8,4,8};
241//-------------------------------------------------------------------------- 245//--------------------------------------------------------------------------
242int ExifData::ReadJpegSections (QFile & infile, ReadMode_t ReadMode) 246int ExifData::ReadJpegSections (QFile & infile, ReadMode_t ReadMode)
243{ 247{
244 int a; 248 int a;
245 249
246 a = infile.getch(); 250 a = infile.getch();
247 251
248 if (a != 0xff || infile.getch() != M_SOI) { 252 if (a != 0xff || infile.getch() != M_SOI) {
249 SectionsRead = 0; 253 SectionsRead = 0;
250 return false; 254 return false;
251 } 255 }
252 for(SectionsRead = 0; SectionsRead < MAX_SECTIONS-1; ){ 256 for(SectionsRead = 0; SectionsRead < MAX_SECTIONS-1; ){
253 int marker = 0; 257 int marker = 0;
254 int got; 258 int got;
255 unsigned int ll,lh; 259 unsigned int ll,lh;
256 unsigned int itemlen; 260 unsigned int itemlen;
257 uchar * Data; 261 uchar * Data;
258 262
259 for (a=0;a<7;a++){ 263 for (a=0;a<7;a++){
260 marker = infile.getch(); 264 marker = infile.getch();
261 if (marker != 0xff) break; 265 if (marker != 0xff) break;
262 266
263 if (a >= 6){ 267 if (a >= 6){
264 268
265 qWarning( "too many padding bytes" ); 269 owarn << "too many padding bytes" << oendl;
266 return false; 270 return false;
267 271
268 } 272 }
269 } 273 }
270 274
271 if (marker == 0xff){ 275 if (marker == 0xff){
272 // 0xff is legal padding, but if we get that many, something's wrong. 276 // 0xff is legal padding, but if we get that many, something's wrong.
273 return false; 277 return false;
274 } 278 }
275 279
276 Sections[SectionsRead].Type = marker; 280 Sections[SectionsRead].Type = marker;
277 281
278 // Read the length of the section. 282 // Read the length of the section.
279 lh = (uchar) infile.getch(); 283 lh = (uchar) infile.getch();
280 ll = (uchar) infile.getch(); 284 ll = (uchar) infile.getch();
281 285
282 itemlen = (lh << 8) | ll; 286 itemlen = (lh << 8) | ll;
283 287
284 if (itemlen < 2) { 288 if (itemlen < 2) {
285 return false;; 289 return false;;
286 } 290 }
287 291
288 Sections[SectionsRead].Size = itemlen; 292 Sections[SectionsRead].Size = itemlen;
289 293
@@ -306,49 +310,49 @@ int ExifData::ReadJpegSections (QFile & infile, ReadMode_t ReadMode)
306 // If reading entire image is requested, read the rest of the data. 310 // If reading entire image is requested, read the rest of the data.
307 if (ReadMode & READ_IMAGE){ 311 if (ReadMode & READ_IMAGE){
308 unsigned long size; 312 unsigned long size;
309 313
310 size = QMAX( 0ul, infile.size()-infile.at() ); 314 size = QMAX( 0ul, infile.size()-infile.at() );
311 Data = (uchar *)malloc(size); 315 Data = (uchar *)malloc(size);
312 if (Data == NULL){ 316 if (Data == NULL){
313 return false; 317 return false;
314 } 318 }
315 319
316 got = infile.readBlock((char*)Data, size); 320 got = infile.readBlock((char*)Data, size);
317 if (( unsigned ) got != size){ 321 if (( unsigned ) got != size){
318 return false; 322 return false;
319 } 323 }
320 324
321 Sections[SectionsRead].Data = Data; 325 Sections[SectionsRead].Data = Data;
322 Sections[SectionsRead].Size = size; 326 Sections[SectionsRead].Size = size;
323 Sections[SectionsRead].Type = PSEUDO_IMAGE_MARKER; 327 Sections[SectionsRead].Type = PSEUDO_IMAGE_MARKER;
324 SectionsRead ++; 328 SectionsRead ++;
325 //HaveAll = 1; 329 //HaveAll = 1;
326 } 330 }
327 return true; 331 return true;
328 332
329 case M_EOI: // in case it's a tables-only JPEG stream 333 case M_EOI: // in case it's a tables-only JPEG stream
330 qWarning( "No image in jpeg!" ); 334 owarn << "No image in jpeg!" << oendl;
331 return false; 335 return false;
332 336
333 case M_COM: // Comment section 337 case M_COM: // Comment section
334 // pieczy 2002-02-12 338 // pieczy 2002-02-12
335 // now the User comment goes to UserComment 339 // now the User comment goes to UserComment
336 // so we can store a Comment section also in READ_EXIF mode 340 // so we can store a Comment section also in READ_EXIF mode
337 process_COM(Data, itemlen); 341 process_COM(Data, itemlen);
338 break; 342 break;
339 343
340 case M_JFIF: 344 case M_JFIF:
341 // Regular jpegs always have this tag, exif images have the exif 345 // Regular jpegs always have this tag, exif images have the exif
342 // marker instead, althogh ACDsee will write images with both markers. 346 // marker instead, althogh ACDsee will write images with both markers.
343 // this program will re-create this marker on absence of exif marker. 347 // this program will re-create this marker on absence of exif marker.
344 // hence no need to keep the copy from the file. 348 // hence no need to keep the copy from the file.
345 free(Sections[--SectionsRead].Data); 349 free(Sections[--SectionsRead].Data);
346 break; 350 break;
347 351
348 case M_EXIF: 352 case M_EXIF:
349 // Seen files from some 'U-lead' software with Vivitar scanner 353 // Seen files from some 'U-lead' software with Vivitar scanner
350 // that uses marker 31 for non exif stuff. Thus make sure 354 // that uses marker 31 for non exif stuff. Thus make sure
351 // it says 'Exif' in the section before treating it as exif. 355 // it says 'Exif' in the section before treating it as exif.
352 if ((ReadMode & READ_EXIF) && memcmp(Data+2, "Exif", 4) == 0){ 356 if ((ReadMode & READ_EXIF) && memcmp(Data+2, "Exif", 4) == 0){
353 process_EXIF((uchar *)Data, itemlen); 357 process_EXIF((uchar *)Data, itemlen);
354 }else{ 358 }else{
@@ -705,49 +709,49 @@ void ExifData::ProcessExifDir(unsigned char * DirStart, unsigned char * OffsetBa
705 ProcessExifDir(SubdirStart, OffsetBase, ExifLength); 709 ProcessExifDir(SubdirStart, OffsetBase, ExifLength);
706 continue; 710 continue;
707 } 711 }
708 } 712 }
709 713
710 { 714 {
711 // In addition to linking to subdirectories via exif tags, 715 // In addition to linking to subdirectories via exif tags,
712 // there's also a potential link to another directory at the end of each 716 // there's also a potential link to another directory at the end of each
713 // directory. this has got to be the result of a comitee! 717 // directory. this has got to be the result of a comitee!
714 unsigned char * SubdirStart; 718 unsigned char * SubdirStart;
715 unsigned Offset; 719 unsigned Offset;
716 720
717 if (DIR_ENTRY_ADDR(DirStart, NumDirEntries) + 4 <= OffsetBase+ExifLength){ 721 if (DIR_ENTRY_ADDR(DirStart, NumDirEntries) + 4 <= OffsetBase+ExifLength){
718 Offset = Get32u(DIR_ENTRY_ADDR(DirStart, NumDirEntries)); 722 Offset = Get32u(DIR_ENTRY_ADDR(DirStart, NumDirEntries));
719 // There is at least one jpeg from an HP camera having an Offset of almost MAXUINT. 723 // There is at least one jpeg from an HP camera having an Offset of almost MAXUINT.
720 // Adding OffsetBase to it produces an overflow, so compare with ExifLength here. 724 // Adding OffsetBase to it produces an overflow, so compare with ExifLength here.
721 // See http://bugs.kde.org/show_bug.cgi?id=54542 725 // See http://bugs.kde.org/show_bug.cgi?id=54542
722 if (Offset && Offset < ExifLength){ 726 if (Offset && Offset < ExifLength){
723 SubdirStart = OffsetBase + Offset; 727 SubdirStart = OffsetBase + Offset;
724 if (SubdirStart > OffsetBase+ExifLength){ 728 if (SubdirStart > OffsetBase+ExifLength){
725 if (SubdirStart < OffsetBase+ExifLength+20){ 729 if (SubdirStart < OffsetBase+ExifLength+20){
726 // Jhead 1.3 or earlier would crop the whole directory! 730 // Jhead 1.3 or earlier would crop the whole directory!
727 // As Jhead produces this form of format incorrectness, 731 // As Jhead produces this form of format incorrectness,
728 // I'll just let it pass silently 732 // I'll just let it pass silently
729 qWarning( "Thumbnail removed with Jhead 1.3 or earlier" ); 733 owarn << "Thumbnail removed with Jhead 1.3 or earlier" << oendl;
730 }else{ 734 }else{
731 return; 735 return;
732 } 736 }
733 }else{ 737 }else{
734 if (SubdirStart <= OffsetBase+ExifLength){ 738 if (SubdirStart <= OffsetBase+ExifLength){
735 ProcessExifDir(SubdirStart, OffsetBase, ExifLength); 739 ProcessExifDir(SubdirStart, OffsetBase, ExifLength);
736 } 740 }
737 } 741 }
738 } 742 }
739 }else{ 743 }else{
740 // The exif header ends before the last next directory pointer. 744 // The exif header ends before the last next directory pointer.
741 } 745 }
742 } 746 }
743 747
744 if (ThumbnailSize && ThumbnailOffset){ 748 if (ThumbnailSize && ThumbnailOffset){
745 if (ThumbnailSize + ThumbnailOffset <= ExifLength){ 749 if (ThumbnailSize + ThumbnailOffset <= ExifLength){
746 // The thumbnail pointer appears to be valid. Store it. 750 // The thumbnail pointer appears to be valid. Store it.
747 Thumbnail.loadFromData(OffsetBase + ThumbnailOffset, ThumbnailSize, "JPEG"); 751 Thumbnail.loadFromData(OffsetBase + ThumbnailOffset, ThumbnailSize, "JPEG");
748 } 752 }
749 } 753 }
750} 754}
751 755
752//-------------------------------------------------------------------------- 756//--------------------------------------------------------------------------
753// Process a COM marker. We want to leave the bytes unchanged. The 757// Process a COM marker. We want to leave the bytes unchanged. The
@@ -892,49 +896,49 @@ ExifData::ExifData()
892 ExposureTime = 0; 896 ExposureTime = 0;
893 ApertureFNumber = 0; 897 ApertureFNumber = 0;
894 Distance = 0; 898 Distance = 0;
895 CCDWidth = 0; 899 CCDWidth = 0;
896 ExposureBias = 0; 900 ExposureBias = 0;
897 ExposureProgram = 0; 901 ExposureProgram = 0;
898 ISOequivalent = 0; 902 ISOequivalent = 0;
899 CompressionLevel = 0; 903 CompressionLevel = 0;
900} 904}
901 905
902//-------------------------------------------------------------------------- 906//--------------------------------------------------------------------------
903// process a EXIF jpeg file 907// process a EXIF jpeg file
904//-------------------------------------------------------------------------- 908//--------------------------------------------------------------------------
905bool ExifData::scan(const QString & path) 909bool ExifData::scan(const QString & path)
906{ 910{
907 int ret; 911 int ret;
908 912
909 QFile f(path); 913 QFile f(path);
910 f.open(IO_ReadOnly); 914 f.open(IO_ReadOnly);
911 915
912 // Scan the JPEG headers. 916 // Scan the JPEG headers.
913 ret = ReadJpegSections(f, READ_EXIF); 917 ret = ReadJpegSections(f, READ_EXIF);
914 918
915 if (ret == false){ 919 if (ret == false){
916 qWarning( "Not JPEG file!" ); 920 owarn << "Not JPEG file!" << oendl;
917 DiscardData(); 921 DiscardData();
918 f.close(); 922 f.close();
919 return false; 923 return false;
920 } 924 }
921 f.close(); 925 f.close();
922 DiscardData(); 926 DiscardData();
923 927
924 //now make the strings clean, 928 //now make the strings clean,
925 // for exmaple my Casio is a "QV-4000 " 929 // for exmaple my Casio is a "QV-4000 "
926 CameraMake = CameraMake.stripWhiteSpace(); 930 CameraMake = CameraMake.stripWhiteSpace();
927 CameraModel = CameraModel.stripWhiteSpace(); 931 CameraModel = CameraModel.stripWhiteSpace();
928 UserComment = UserComment.stripWhiteSpace(); 932 UserComment = UserComment.stripWhiteSpace();
929 Comment = Comment.stripWhiteSpace(); 933 Comment = Comment.stripWhiteSpace();
930 return true; 934 return true;
931} 935}
932 936
933//-------------------------------------------------------------------------- 937//--------------------------------------------------------------------------
934// Does the embedded thumbnail match the jpeg image? 938// Does the embedded thumbnail match the jpeg image?
935//-------------------------------------------------------------------------- 939//--------------------------------------------------------------------------
936#ifndef JPEG_TOL 940#ifndef JPEG_TOL
937#define JPEG_TOL 0.02 941#define JPEG_TOL 0.02
938#endif 942#endif
939bool ExifData::isThumbnailSane() { 943bool ExifData::isThumbnailSane() {
940 if (Thumbnail.isNull()) return false; 944 if (Thumbnail.isNull()) return false;
diff --git a/noncore/graphics/opie-eye/slave/main.cpp b/noncore/graphics/opie-eye/slave/main.cpp
index 37020e6..5b90483 100644
--- a/noncore/graphics/opie-eye/slave/main.cpp
+++ b/noncore/graphics/opie-eye/slave/main.cpp
@@ -10,50 +10,50 @@
10 10
11#include <qpixmap.h> 11#include <qpixmap.h>
12#include <qcopchannel_qws.h> 12#include <qcopchannel_qws.h>
13 13
14#include <qtopia/qpeapplication.h> 14#include <qtopia/qpeapplication.h>
15 15
16int main( int argc, char* argv[] ) { 16int main( int argc, char* argv[] ) {
17 QPEApplication app( argc, argv ); 17 QPEApplication app( argc, argv );
18 SlaveReciever rec( 0 ); 18 SlaveReciever rec( 0 );
19 19
20 QCopChannel chan( "QPE/opie-eye_slave" ); 20 QCopChannel chan( "QPE/opie-eye_slave" );
21 QObject::connect(&chan,SIGNAL(received(const QCString&, const QByteArray&)), 21 QObject::connect(&chan,SIGNAL(received(const QCString&, const QByteArray&)),
22 &rec, SLOT(recieveAnswer(const QCString&,const QByteArray&))); 22 &rec, SLOT(recieveAnswer(const QCString&,const QByteArray&)));
23 QObject::connect(qApp,SIGNAL(appMessage(const QCString&, const QByteArray&)), 23 QObject::connect(qApp,SIGNAL(appMessage(const QCString&, const QByteArray&)),
24 &rec, SLOT(recieveAnswer(const QCString&,const QByteArray&))); 24 &rec, SLOT(recieveAnswer(const QCString&,const QByteArray&)));
25 25
26 return app.exec(); 26 return app.exec();
27} 27}
28 28
29#ifdef DEBUG_IT 29#ifdef DEBUG_IT
30int main( int argc, char* argv[] ) { 30int main( int argc, char* argv[] ) {
31 QString str = QString::fromLatin1(argv[2] ); 31 QString str = QString::fromLatin1(argv[2] );
32 QApplication app( argc, argv ); 32 QApplication app( argc, argv );
33 GifSlave slave; 33 GifSlave slave;
34 qWarning( str +" "+slave.iconViewName(str ) ); 34 owarn << str +" "+slave.iconViewName(str ) << oendl;
35 qWarning( str+" "+slave.fullImageInfo( str ) ); 35 owarn << str+" "+slave.fullImageInfo( str ) << oendl;
36 36
37 PNGSlave pngslave; 37 PNGSlave pngslave;
38 qWarning( str + " " + pngslave.iconViewName(str) ); 38 owarn << str + " " + pngslave.iconViewName(str) << oendl;
39 qWarning( str + " " + pngslave.fullImageInfo(str)); 39 owarn << str + " " + pngslave.fullImageInfo(str) << oendl;
40 40
41 41
42 JpegSlave jpgslave; 42 JpegSlave jpgslave;
43 qWarning( str + " " + jpgslave.iconViewName(str ) ); 43 owarn << str + " " + jpgslave.iconViewName(str ) << oendl;
44 qWarning( str + " " + jpgslave.fullImageInfo( str ) ); 44 owarn << str + " " + jpgslave.fullImageInfo( str ) << oendl;
45//return app.exec(); 45//return app.exec();
46 QPixmap pix = ThumbNailTool::getThumb( str, 24, 24 ); 46 QPixmap pix = ThumbNailTool::getThumb( str, 24, 24 );
47 if ( pix.isNull() ) { 47 if ( pix.isNull() ) {
48 qWarning( "No Thumbnail" ); 48 owarn << "No Thumbnail" << oendl;
49 pix = slave.pixmap(str, 24, 24); 49 pix = slave.pixmap(str, 24, 24);
50 } 50 }
51 51
52 if (!pix.isNull() ) { 52 if (!pix.isNull() ) {
53 qWarning( "Saving Thumbnail" ); 53 owarn << "Saving Thumbnail" << oendl;
54 ThumbNailTool::putThumb( str, pix, 24, 24 ); 54 ThumbNailTool::putThumb( str, pix, 24, 24 );
55 } 55 }
56 56
57} 57}
58 58
59#endif 59#endif
diff --git a/noncore/graphics/opie-eye/slave/slave.pro b/noncore/graphics/opie-eye/slave/slave.pro
index 3f42495..903d667 100644
--- a/noncore/graphics/opie-eye/slave/slave.pro
+++ b/noncore/graphics/opie-eye/slave/slave.pro
@@ -1,18 +1,18 @@
1CONFIG += qte 1CONFIG = qt
2TEMPLATE = app 2TEMPLATE = app
3TARGET = opie-eye_slave 3TARGET = opie-eye_slave
4DESTDIR = $(OPIEDIR)/bin 4DESTDIR = $(OPIEDIR)/bin
5 5
6HEADERS = gif_slave.h slaveiface.h slavereciever.h \ 6HEADERS = gif_slave.h slaveiface.h slavereciever.h \
7 thumbnailtool.h png_slave.h jpeg_slave.h \ 7 thumbnailtool.h png_slave.h jpeg_slave.h \
8 ../iface/slaveiface.h 8 ../iface/slaveiface.h
9SOURCES = main.cpp gif_slave.cpp slavereciever.cpp \ 9SOURCES = main.cpp gif_slave.cpp slavereciever.cpp \
10 slaveiface.cpp thumbnailtool.cpp png_slave.cpp \ 10 slaveiface.cpp thumbnailtool.cpp png_slave.cpp \
11 jpeg_slave.cpp 11 jpeg_slave.cpp
12 12
13INCLUDEPATH += $(OPIEDIR)/include ../ 13INCLUDEPATH += $(OPIEDIR)/include ../
14DEPENDSPATH += $(OPIEDIR)/include 14DEPENDSPATH += $(OPIEDIR)/include
15 15
16LIBS += -lqpe 16LIBS += -lqpe -lopiecore2
17 17
18include ( $(OPIEDIR)/include.pro ) \ No newline at end of file 18include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/graphics/opie-eye/slave/slavereciever.cpp b/noncore/graphics/opie-eye/slave/slavereciever.cpp
index bbbbb30..82b3d23 100644
--- a/noncore/graphics/opie-eye/slave/slavereciever.cpp
+++ b/noncore/graphics/opie-eye/slave/slavereciever.cpp
@@ -1,144 +1,148 @@
1/* 1/*
2 * GPLv2 zecke@handhelds.org 2 * GPLv2 zecke@handhelds.org
3 */ 3 */
4 4
5#include "slavereciever.h" 5#include "slavereciever.h"
6#include "slaveiface.h" 6#include "slaveiface.h"
7 7
8/* OPIE */
9#include <opie2/odebug.h>
8#include <qpe/qcopenvelope_qws.h> 10#include <qpe/qcopenvelope_qws.h>
9#include <qpe/qpeapplication.h> 11#include <qpe/qpeapplication.h>
12using namespace Opie::Core;
10 13
14/* QT */
11#include <qtimer.h> 15#include <qtimer.h>
12 16
13static SlaveObjects* _slaveObj = 0; 17static SlaveObjects* _slaveObj = 0;
14 18
15QDataStream & operator << (QDataStream & str, bool b) 19QDataStream & operator << (QDataStream & str, bool b)
16{ 20{
17 str << Q_INT8(b); 21 str << Q_INT8(b);
18 return str; 22 return str;
19} 23}
20 24
21QDataStream & operator >> (QDataStream & str, bool & b) 25QDataStream & operator >> (QDataStream & str, bool & b)
22{ 26{
23 Q_INT8 l; 27 Q_INT8 l;
24 str >> l; 28 str >> l;
25 b = bool(l); 29 b = bool(l);
26 return str; 30 return str;
27} 31}
28 32
29 33
30 34
31QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { 35QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) {
32 return s << inf.file << inf.pixmap << inf.width << inf.height; 36 return s << inf.file << inf.pixmap << inf.width << inf.height;
33} 37}
34 38
35/* 39/*
36 * GUI sends no QPIxmap!!! 40 * GUI sends no QPIxmap!!!
37 */ 41 */
38QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { 42QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) {
39 s >> inf.file >> inf.width >> inf.height; 43 s >> inf.file >> inf.width >> inf.height;
40 qWarning( "Recieved %s %d %d", inf.file.latin1(), inf.width, inf.height ); 44 owarn << "Recieved " << inf.file.latin1() << " " << inf.width << " " << inf.height << "" << oendl;
41 return s; 45 return s;
42} 46}
43QDataStream &operator<<( QDataStream& s, const ImageInfo& i) { 47QDataStream &operator<<( QDataStream& s, const ImageInfo& i) {
44 return s << i.kind << i.file << i.info; 48 return s << i.kind << i.file << i.info;
45} 49}
46QDataStream &operator>>( QDataStream& s, ImageInfo& i ) { 50QDataStream &operator>>( QDataStream& s, ImageInfo& i ) {
47 s >> i.kind >> i.file >> i.info; 51 s >> i.kind >> i.file >> i.info;
48 return s; 52 return s;
49} 53}
50 54
51 55
52 56
53SlaveObjects* slaveObjects() { 57SlaveObjects* slaveObjects() {
54 if ( !_slaveObj ) 58 if ( !_slaveObj )
55 _slaveObj = new SlaveObjects; 59 _slaveObj = new SlaveObjects;
56 return _slaveObj; 60 return _slaveObj;
57} 61}
58 62
59SlaveReciever::SlaveReciever( QObject* par) 63SlaveReciever::SlaveReciever( QObject* par)
60 : QObject( par ), m_refs( 0 ) 64 : QObject( par ), m_refs( 0 )
61{ 65{
62 m_inf = new QTimer(this); 66 m_inf = new QTimer(this);
63 connect(m_inf,SIGNAL(timeout()), 67 connect(m_inf,SIGNAL(timeout()),
64 this, SLOT(slotImageInfo())); 68 this, SLOT(slotImageInfo()));
65 m_pix = new QTimer(this); 69 m_pix = new QTimer(this);
66 connect(m_pix,SIGNAL(timeout()), 70 connect(m_pix,SIGNAL(timeout()),
67 this, SLOT(slotThumbNail())); 71 this, SLOT(slotThumbNail()));
68 72
69 m_out = new QTimer(this); 73 m_out = new QTimer(this);
70 connect(m_out,SIGNAL(timeout()), 74 connect(m_out,SIGNAL(timeout()),
71 this, SLOT(slotSend())); 75 this, SLOT(slotSend()));
72 76
73 SlaveObjects *obj = slaveObjects(); // won't be changed 77 SlaveObjects *obj = slaveObjects(); // won't be changed
74 SlaveMap::Iterator it; 78 SlaveMap::Iterator it;
75 SlaveMap* map = slaveMap(); // SlaveMap won't be changed during execution!!! 79 SlaveMap* map = slaveMap(); // SlaveMap won't be changed during execution!!!
76 for(it = map->begin(); it != map->end(); ++it ) { 80 for(it = map->begin(); it != map->end(); ++it ) {
77 obj->insert( it.key(), (*it.data())() ); 81 obj->insert( it.key(), (*it.data())() );
78 } 82 }
79} 83}
80 84
81SlaveReciever::~SlaveReciever() { 85SlaveReciever::~SlaveReciever() {
82} 86}
83 87
84void SlaveReciever::recieveAnswer( const QCString& string, const QByteArray& ar) { 88void SlaveReciever::recieveAnswer( const QCString& string, const QByteArray& ar) {
85 qWarning( "String is %s", string.data() ); 89 owarn << "String is " << string.data() << "" << oendl;
86 QDataStream stream(ar, IO_ReadOnly ); 90 QDataStream stream(ar, IO_ReadOnly );
87 QStringList lst; 91 QStringList lst;
88 static ImageInfo inf; 92 static ImageInfo inf;
89 static PixmapInfo pix; 93 static PixmapInfo pix;
90 94
91 if ( string == "thumbInfo(QString)" ) { 95 if ( string == "thumbInfo(QString)" ) {
92 stream >> inf.file; 96 stream >> inf.file;
93 m_inList.append(inf); 97 m_inList.append(inf);
94 }else if ( string == "thumbInfos(QStringList)" ) { 98 }else if ( string == "thumbInfos(QStringList)" ) {
95 stream >> lst; 99 stream >> lst;
96 for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { 100 for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) {
97 qWarning( "Adding thumbinfo for file "+ *it ); 101 owarn << "Adding thumbinfo for file "+ *it << oendl;
98 inf.file = (*it); 102 inf.file = (*it);
99 m_inList.append(inf); 103 m_inList.append(inf);
100 } 104 }
101 }else if ( string == "fullInfo(QString)" ) { 105 }else if ( string == "fullInfo(QString)" ) {
102 inf.kind = true; 106 inf.kind = true;
103 stream >> inf.file; 107 stream >> inf.file;
104 m_inList.append(inf); 108 m_inList.append(inf);
105 }else if ( string == "fullInfos(QStringList)" ) { 109 }else if ( string == "fullInfos(QStringList)" ) {
106 stream >> lst; 110 stream >> lst;
107 for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { 111 for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) {
108 qWarning( "Adding fullInfo for"+ *it ); 112 owarn << "Adding fullInfo for"+ *it << oendl;
109 inf.file = (*it); 113 inf.file = (*it);
110 inf.kind = true; 114 inf.kind = true;
111 m_inList.append(inf); 115 m_inList.append(inf);
112 } 116 }
113 }else if ( string == "pixmapInfo(QString,int,int)" ) { 117 }else if ( string == "pixmapInfo(QString,int,int)" ) {
114 stream >> pix.file >> pix.width >> pix.height; 118 stream >> pix.file >> pix.width >> pix.height;
115 m_inPix.append(pix); 119 m_inPix.append(pix);
116 }else if ( string == "pixmapInfos(PixmapInfos)" ) { 120 }else if ( string == "pixmapInfos(PixmapInfos)" ) {
117 PixmapList list; 121 PixmapList list;
118 stream >> list; 122 stream >> list;
119 for(PixmapList::Iterator it = list.begin(); it != list.end(); ++it ) { 123 for(PixmapList::Iterator it = list.begin(); it != list.end(); ++it ) {
120 qWarning( "Got %d %d " + (*it).file, (*it).width , (*it).height ); 124 owarn << "Got " << (*it).width << " " << (*it).height << " " + (*it).file << oendl;
121 m_inPix.append(*it); 125 m_inPix.append(*it);
122 } 126 }
123 }else if ( string == "refUp()" ) { 127 }else if ( string == "refUp()" ) {
124 m_refs++; 128 m_refs++;
125 }else if ( string == "refDown()" ) { 129 }else if ( string == "refDown()" ) {
126 m_refs--; 130 m_refs--;
127 } 131 }
128 132
129 if (!m_inf->isActive() && !m_inList.isEmpty() ) 133 if (!m_inf->isActive() && !m_inList.isEmpty() )
130 m_inf->start(5); 134 m_inf->start(5);
131 135
132 if (!m_pix->isActive() && !m_inPix.isEmpty() ) 136 if (!m_pix->isActive() && !m_inPix.isEmpty() )
133 m_pix->start(5); 137 m_pix->start(5);
134 138
135 if ( m_refs ) 139 if ( m_refs )
136 QPEApplication::setKeepRunning(); 140 QPEApplication::setKeepRunning();
137 else 141 else
138 qApp->quit(); 142 qApp->quit();
139 143
140} 144}
141 145
142PixmapList SlaveReciever::outPix()const { 146PixmapList SlaveReciever::outPix()const {
143 return m_outPix; 147 return m_outPix;
144} 148}
@@ -160,67 +164,67 @@ void SlaveReciever::slotImageInfo() {
160 inf.info = (*it)->fullImageInfo( inf.file ); 164 inf.info = (*it)->fullImageInfo( inf.file );
161 else 165 else
162 inf.info = (*it)->iconViewName( inf.file ); 166 inf.info = (*it)->iconViewName( inf.file );
163 m_outList.append( inf ); 167 m_outList.append( inf );
164 break; 168 break;
165 } 169 }
166 } 170 }
167 171
168 if (m_inList.isEmpty() ) 172 if (m_inList.isEmpty() )
169 m_inf->stop(); 173 m_inf->stop();
170 if (!m_out->isActive() && !m_outList.isEmpty() ) 174 if (!m_out->isActive() && !m_outList.isEmpty() )
171 m_out->start( 100 ); 175 m_out->start( 100 );
172} 176}
173 177
174void SlaveReciever::slotThumbNail() { 178void SlaveReciever::slotThumbNail() {
175 PixmapInfo inf = m_inPix.first(); 179 PixmapInfo inf = m_inPix.first();
176 m_inPix.remove( inf ); 180 m_inPix.remove( inf );
177 181
178 static SlaveObjects::Iterator it; 182 static SlaveObjects::Iterator it;
179 static SlaveObjects* map = slaveObjects(); // SlaveMap won't be changed during execution!!! 183 static SlaveObjects* map = slaveObjects(); // SlaveMap won't be changed during execution!!!
180 for(it = map->begin(); it != map->end(); ++it ) { 184 for(it = map->begin(); it != map->end(); ++it ) {
181 SlaveInterface* iface = it.data(); 185 SlaveInterface* iface = it.data();
182 if( iface->supports(inf.file ) ) { 186 if( iface->supports(inf.file ) ) {
183 /* pixmap */ 187 /* pixmap */
184 qWarning( "Asking for thumbNail in size %d %d for "+inf.file, inf.width, inf.height ); 188 owarn << "Asking for thumbNail in size " << inf.width << " " << inf.height << " for "+inf.file << oendl;
185 inf.pixmap = iface->pixmap(inf.file, 64, 64); 189 inf.pixmap = iface->pixmap(inf.file, 64, 64);
186 m_outPix.append( inf ); 190 m_outPix.append( inf );
187 break; 191 break;
188 } 192 }
189 } 193 }
190 194
191 195
192 196
193 if(m_inPix.isEmpty() ) 197 if(m_inPix.isEmpty() )
194 m_pix->stop(); 198 m_pix->stop();
195 if(!m_out->isActive() && !m_outPix.isEmpty() ) 199 if(!m_out->isActive() && !m_outPix.isEmpty() )
196 m_out->start(100); 200 m_out->start(100);
197} 201}
198 202
199void SlaveReciever::slotSend() { 203void SlaveReciever::slotSend() {
200 204
201 m_out->stop(); 205 m_out->stop();
202 206
203 qWarning( "Sending %d %d", outPix().count(), outInf().count() ); 207 owarn << "Sending " << outPix().count() << " " << outInf().count() << "" << oendl;
204 /* queue it and send */ 208 /* queue it and send */
205 /* if this ever gets a service introduce request queues 209 /* if this ever gets a service introduce request queues
206 * so we can differinatate between different clients 210 * so we can differinatate between different clients
207 */ 211 */
208 if (! m_outPix.isEmpty() ) { 212 if (! m_outPix.isEmpty() ) {
209 QCopEnvelope answer("QPE/opie-eye", "pixmapsHandled(PixmapList)" ); 213 QCopEnvelope answer("QPE/opie-eye", "pixmapsHandled(PixmapList)" );
210 answer << outPix(); 214 answer << outPix();
211 for ( PixmapList::Iterator it = m_outPix.begin();it!=m_outPix.end();++it ) { 215 for ( PixmapList::Iterator it = m_outPix.begin();it!=m_outPix.end();++it ) {
212 qWarning( "Sending out %s %d %d", (*it).file.latin1(), (*it).width, (*it).height ); 216 owarn << "Sending out " << (*it).file.latin1() << " " << (*it).width << " " << (*it).height << "" << oendl;
213 } 217 }
214 } 218 }
215 if ( !m_outList.isEmpty() ) { 219 if ( !m_outList.isEmpty() ) {
216 QCopEnvelope answer("QPE/opie-eye", "pixmapsHandled(StringList)" ); 220 QCopEnvelope answer("QPE/opie-eye", "pixmapsHandled(StringList)" );
217 answer << outInf(); 221 answer << outInf();
218 for ( StringList::Iterator it = m_outList.begin();it!=m_outList.end();++it ) { 222 for ( StringList::Iterator it = m_outList.begin();it!=m_outList.end();++it ) {
219 qWarning( "Sending out2 " + (*it).file ); 223 owarn << "Sending out2 " + (*it).file << oendl;
220 } 224 }
221 } 225 }
222 226
223 m_outList.clear(); 227 m_outList.clear();
224 m_outPix.clear(); 228 m_outPix.clear();
225} 229}
226 230
diff --git a/noncore/graphics/opie-eye/slave/thumbnailtool.cpp b/noncore/graphics/opie-eye/slave/thumbnailtool.cpp
index a202457..d2e169c 100644
--- a/noncore/graphics/opie-eye/slave/thumbnailtool.cpp
+++ b/noncore/graphics/opie-eye/slave/thumbnailtool.cpp
@@ -1,61 +1,66 @@
1#include "thumbnailtool.h" 1#include "thumbnailtool.h"
2 2
3/* OPIE */
4#include <opie2/odebug.h>
5using namespace Opie::Core;
6
7/* QT */
3#include <qfileinfo.h> 8#include <qfileinfo.h>
4#include <qdir.h> 9#include <qdir.h>
5#include <qimage.h> 10#include <qimage.h>
6#include <qpixmap.h> 11#include <qpixmap.h>
7#include <qstring.h> 12#include <qstring.h>
8 13
9static bool makeThumbDir( const QFileInfo& inf, bool make = false) { 14static bool makeThumbDir( const QFileInfo& inf, bool make = false) {
10 QDir dir( inf.dirPath()+ "/.opie-eye" ); 15 QDir dir( inf.dirPath()+ "/.opie-eye" );
11 if ( !dir.exists() ) 16 if ( !dir.exists() )
12 if ( make ) 17 if ( make )
13 return dir.mkdir(QString::null); 18 return dir.mkdir(QString::null);
14 else 19 else
15 return false; 20 return false;
16 return true; 21 return true;
17} 22}
18 23
19 24
20/* 25/*
21 * check if the Opie opie-eye dir exists 26 * check if the Opie opie-eye dir exists
22 * check if a thumbnail exists 27 * check if a thumbnail exists
23 * load the thumbnail 28 * load the thumbnail
24 * /foo/bar/imagefoo.gif 29 * /foo/bar/imagefoo.gif
25 * check for a png in /foo/bar/.opie-eye/%dx%d-imagefoo.gif 30 * check for a png in /foo/bar/.opie-eye/%dx%d-imagefoo.gif
26 */ 31 */
27QPixmap ThumbNailTool::getThumb( const QString& path, int width, int height ) { 32QPixmap ThumbNailTool::getThumb( const QString& path, int width, int height ) {
28 QFileInfo inf( path ); 33 QFileInfo inf( path );
29 qWarning( "Get Thumb" ); 34 owarn << "Get Thumb" << oendl;
30 if ( !makeThumbDir( inf ) ) { 35 if ( !makeThumbDir( inf ) ) {
31 QPixmap pix; 36 QPixmap pix;
32 return pix; 37 return pix;
33 } 38 }
34 QString str = QString( "/.opie-eye/%1x%2-%3" ).arg( width ).arg( height ).arg( inf.fileName() ); 39 QString str = QString( "/.opie-eye/%1x%2-%3" ).arg( width ).arg( height ).arg( inf.fileName() );
35 qWarning( inf.dirPath()+str ); 40 owarn << inf.dirPath()+str << oendl;
36 return QPixmap( inf.dirPath()+str,"PNG" ); 41 return QPixmap( inf.dirPath()+str,"PNG" );
37 42
38} 43}
39 44
40void ThumbNailTool::putThumb( const QString& path, const QPixmap& pix, int width, int height ) { 45void ThumbNailTool::putThumb( const QString& path, const QPixmap& pix, int width, int height ) {
41 QFileInfo inf( path ); 46 QFileInfo inf( path );
42 makeThumbDir( inf, true ); 47 makeThumbDir( inf, true );
43 QString str = QString( "/.opie-eye/%1x%2-%3" ).arg( width ).arg( height ).arg( inf.fileName() ); 48 QString str = QString( "/.opie-eye/%1x%2-%3" ).arg( width ).arg( height ).arg( inf.fileName() );
44 qWarning( inf.dirPath()+str ); 49 owarn << inf.dirPath()+str << oendl;
45 pix.save( inf.dirPath()+str, "PNG" ); 50 pix.save( inf.dirPath()+str, "PNG" );
46} 51}
47 52
48 53
49QPixmap ThumbNailTool::scaleImage( QImage& img, int w, int h ) { 54QPixmap ThumbNailTool::scaleImage( QImage& img, int w, int h ) {
50 double hs = (double)h / (double)img.height() ; 55 double hs = (double)h / (double)img.height() ;
51 double ws = (double)w / (double)img.width() ; 56 double ws = (double)w / (double)img.width() ;
52 double scaleFactor = (hs > ws) ? ws : hs; 57 double scaleFactor = (hs > ws) ? ws : hs;
53 int smoothW = (int)(scaleFactor * img.width()); 58 int smoothW = (int)(scaleFactor * img.width());
54 int smoothH = (int)(scaleFactor * img.height()); 59 int smoothH = (int)(scaleFactor * img.height());
55 QPixmap pixmap; 60 QPixmap pixmap;
56 if ( img.width() <= w && img.height() <= h ) 61 if ( img.width() <= w && img.height() <= h )
57 pixmap.convertFromImage( img ); 62 pixmap.convertFromImage( img );
58 else 63 else
59 pixmap.convertFromImage( img.smoothScale( smoothW, smoothH) ); 64 pixmap.convertFromImage( img.smoothScale( smoothW, smoothH) );
60 return pixmap; 65 return pixmap;
61} 66}