Diffstat (limited to 'noncore/graphics/opie-eye/slave/slavereciever.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/graphics/opie-eye/slave/slavereciever.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/noncore/graphics/opie-eye/slave/slavereciever.cpp b/noncore/graphics/opie-eye/slave/slavereciever.cpp index 951f3df..c8e33d4 100644 --- a/noncore/graphics/opie-eye/slave/slavereciever.cpp +++ b/noncore/graphics/opie-eye/slave/slavereciever.cpp | |||
@@ -1,131 +1,136 @@ | |||
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 | #include <qpe/qcopenvelope_qws.h> | 8 | #include <qpe/qcopenvelope_qws.h> |
9 | #include <qpe/qpeapplication.h> | 9 | #include <qpe/qpeapplication.h> |
10 | 10 | ||
11 | #include <qtimer.h> | 11 | #include <qtimer.h> |
12 | 12 | ||
13 | static SlaveObjects* _slaveObj = 0; | 13 | static SlaveObjects* _slaveObj = 0; |
14 | 14 | ||
15 | QDataStream & operator << (QDataStream & str, bool b) | 15 | QDataStream & operator << (QDataStream & str, bool b) |
16 | { | 16 | { |
17 | str << Q_INT8(b); | 17 | str << Q_INT8(b); |
18 | return str; | 18 | return str; |
19 | } | 19 | } |
20 | 20 | ||
21 | QDataStream & operator >> (QDataStream & str, bool & b) | 21 | QDataStream & operator >> (QDataStream & str, bool & b) |
22 | { | 22 | { |
23 | Q_INT8 l; | 23 | Q_INT8 l; |
24 | str >> l; | 24 | str >> l; |
25 | b = bool(l); | 25 | b = bool(l); |
26 | return str; | 26 | return str; |
27 | } | 27 | } |
28 | 28 | ||
29 | 29 | ||
30 | 30 | ||
31 | QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { | 31 | QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { |
32 | return s << inf.file << inf.pixmap << inf.width << inf.height; | 32 | return s << inf.file << inf.pixmap << inf.width << inf.height; |
33 | } | 33 | } |
34 | |||
35 | /* | ||
36 | * GUI sends no QPIxmap!!! | ||
37 | */ | ||
34 | QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { | 38 | QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { |
35 | s >> inf.file >> inf.pixmap >> inf.width >> inf.height; | 39 | s >> inf.file >> inf.width >> inf.height; |
40 | qWarning( "Recieved %s %d %d", inf.file.latin1(), inf.width, inf.height ); | ||
36 | return s; | 41 | return s; |
37 | } | 42 | } |
38 | QDataStream &operator<<( QDataStream& s, const ImageInfo& i) { | 43 | QDataStream &operator<<( QDataStream& s, const ImageInfo& i) { |
39 | return s << i.kind << i.file << i.info; | 44 | return s << i.kind << i.file << i.info; |
40 | } | 45 | } |
41 | QDataStream &operator>>( QDataStream& s, ImageInfo& i ) { | 46 | QDataStream &operator>>( QDataStream& s, ImageInfo& i ) { |
42 | s >> i.kind >> i.file >> i.info; | 47 | s >> i.kind >> i.file >> i.info; |
43 | return s; | 48 | return s; |
44 | } | 49 | } |
45 | 50 | ||
46 | 51 | ||
47 | 52 | ||
48 | SlaveObjects* slaveObjects() { | 53 | SlaveObjects* slaveObjects() { |
49 | if ( !_slaveObj ) | 54 | if ( !_slaveObj ) |
50 | _slaveObj = new SlaveObjects; | 55 | _slaveObj = new SlaveObjects; |
51 | return _slaveObj; | 56 | return _slaveObj; |
52 | } | 57 | } |
53 | 58 | ||
54 | SlaveReciever::SlaveReciever( QObject* par) | 59 | SlaveReciever::SlaveReciever( QObject* par) |
55 | : QObject( par ) | 60 | : QObject( par ) |
56 | { | 61 | { |
57 | m_inf = new QTimer(this); | 62 | m_inf = new QTimer(this); |
58 | connect(m_inf,SIGNAL(timeout()), | 63 | connect(m_inf,SIGNAL(timeout()), |
59 | this, SLOT(slotImageInfo())); | 64 | this, SLOT(slotImageInfo())); |
60 | m_pix = new QTimer(this); | 65 | m_pix = new QTimer(this); |
61 | connect(m_pix,SIGNAL(timeout()), | 66 | connect(m_pix,SIGNAL(timeout()), |
62 | this, SLOT(slotThumbNail())); | 67 | this, SLOT(slotThumbNail())); |
63 | 68 | ||
64 | m_out = new QTimer(this); | 69 | m_out = new QTimer(this); |
65 | connect(m_out,SIGNAL(timeout()), | 70 | connect(m_out,SIGNAL(timeout()), |
66 | this, SLOT(slotSend())); | 71 | this, SLOT(slotSend())); |
67 | 72 | ||
68 | SlaveObjects *obj = slaveObjects(); // won't be changed | 73 | SlaveObjects *obj = slaveObjects(); // won't be changed |
69 | SlaveMap::Iterator it; | 74 | SlaveMap::Iterator it; |
70 | SlaveMap* map = slaveMap(); // SlaveMap won't be changed during execution!!! | 75 | SlaveMap* map = slaveMap(); // SlaveMap won't be changed during execution!!! |
71 | for(it = map->begin(); it != map->end(); ++it ) { | 76 | for(it = map->begin(); it != map->end(); ++it ) { |
72 | obj->insert( it.key(), (*it.data())() ); | 77 | obj->insert( it.key(), (*it.data())() ); |
73 | } | 78 | } |
74 | } | 79 | } |
75 | 80 | ||
76 | SlaveReciever::~SlaveReciever() { | 81 | SlaveReciever::~SlaveReciever() { |
77 | } | 82 | } |
78 | 83 | ||
79 | void SlaveReciever::recieveAnswer( const QCString& string, const QByteArray& ar) { | 84 | void SlaveReciever::recieveAnswer( const QCString& string, const QByteArray& ar) { |
80 | qWarning( "String is %s", string.data() ); | 85 | qWarning( "String is %s", string.data() ); |
81 | QDataStream stream(ar, IO_ReadOnly ); | 86 | QDataStream stream(ar, IO_ReadOnly ); |
82 | QStringList lst; | 87 | QStringList lst; |
83 | static ImageInfo inf; | 88 | static ImageInfo inf; |
84 | static PixmapInfo pix; | 89 | static PixmapInfo pix; |
85 | 90 | ||
86 | if ( string == "thumbInfo(QString)" ) { | 91 | if ( string == "thumbInfo(QString)" ) { |
87 | stream >> inf.file; | 92 | stream >> inf.file; |
88 | m_inList.append(inf); | 93 | m_inList.append(inf); |
89 | }else if ( string == "thumbInfos(QStringList)" ) { | 94 | }else if ( string == "thumbInfos(QStringList)" ) { |
90 | stream >> lst; | 95 | stream >> lst; |
91 | for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { | 96 | for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { |
92 | qWarning( "Adding thumbinfo for file "+ *it ); | 97 | qWarning( "Adding thumbinfo for file "+ *it ); |
93 | inf.file = (*it); | 98 | inf.file = (*it); |
94 | m_inList.append(inf); | 99 | m_inList.append(inf); |
95 | } | 100 | } |
96 | }else if ( string == "fullInfo(QString)" ) { | 101 | }else if ( string == "fullInfo(QString)" ) { |
97 | inf.kind = true; | 102 | inf.kind = true; |
98 | stream >> inf.file; | 103 | stream >> inf.file; |
99 | m_inList.append(inf); | 104 | m_inList.append(inf); |
100 | }else if ( string == "fullInfos(QStringList)" ) { | 105 | }else if ( string == "fullInfos(QStringList)" ) { |
101 | stream >> lst; | 106 | stream >> lst; |
102 | for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { | 107 | for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { |
103 | qWarning( "Adding fullInfo for"+ *it ); | 108 | qWarning( "Adding fullInfo for"+ *it ); |
104 | inf.file = (*it); | 109 | inf.file = (*it); |
105 | inf.kind = true; | 110 | inf.kind = true; |
106 | m_inList.append(inf); | 111 | m_inList.append(inf); |
107 | } | 112 | } |
108 | }else if ( string == "pixmapInfo(QString,int,int)" ) { | 113 | }else if ( string == "pixmapInfo(QString,int,int)" ) { |
109 | stream >> pix.file >> pix.width >> pix.height; | 114 | stream >> pix.file >> pix.width >> pix.height; |
110 | m_inPix.append(pix); | 115 | m_inPix.append(pix); |
111 | }else if ( string == "pixmapInfos(PixmapInfos)" ) { | 116 | }else if ( string == "pixmapInfos(PixmapInfos)" ) { |
112 | PixmapList list; | 117 | PixmapList list; |
113 | stream >> list; | 118 | stream >> list; |
114 | for(PixmapList::Iterator it = list.begin(); it != list.end(); ++it ) { | 119 | for(PixmapList::Iterator it = list.begin(); it != list.end(); ++it ) { |
115 | qWarning( "Got %d %d " + (*it).file, (*it).width , (*it).height ); | 120 | qWarning( "Got %d %d " + (*it).file, (*it).width , (*it).height ); |
116 | m_inPix.append(*it); | 121 | m_inPix.append(*it); |
117 | } | 122 | } |
118 | } | 123 | } |
119 | 124 | ||
120 | if (!m_inf->isActive() && !m_inList.isEmpty() ) | 125 | if (!m_inf->isActive() && !m_inList.isEmpty() ) |
121 | m_inf->start(5); | 126 | m_inf->start(5); |
122 | 127 | ||
123 | if (!m_pix->isActive() && !m_inPix.isEmpty() ) | 128 | if (!m_pix->isActive() && !m_inPix.isEmpty() ) |
124 | m_pix->start(5); | 129 | m_pix->start(5); |
125 | 130 | ||
126 | QPEApplication::setKeepRunning(); | 131 | QPEApplication::setKeepRunning(); |
127 | 132 | ||
128 | } | 133 | } |
129 | 134 | ||
130 | PixmapList SlaveReciever::outPix()const { | 135 | PixmapList SlaveReciever::outPix()const { |
131 | return m_outPix; | 136 | return m_outPix; |