summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/rotateapplet/rotate.cpp4
-rw-r--r--core/applets/rotateapplet/rotate.h1
-rw-r--r--core/applets/screenshotapplet/inputDialog.cpp3
-rw-r--r--core/applets/screenshotapplet/screenshot.cpp1
-rw-r--r--core/applets/suspendapplet/suspend.cpp2
-rw-r--r--core/applets/volumeapplet/oledbox.cpp1
-rw-r--r--core/applets/volumeapplet/volume.cpp4
-rw-r--r--core/applets/volumeapplet/volumeappletimpl.cpp2
-rw-r--r--core/applets/vtapplet/vt.cpp3
-rw-r--r--core/apps/calibrate/main.cpp1
-rw-r--r--core/obex/obex.cc4
-rw-r--r--core/obex/obexhandler.cpp1
-rw-r--r--core/obex/obexsend.cpp4
-rw-r--r--core/obex/receiver.cpp4
14 files changed, 0 insertions, 35 deletions
diff --git a/core/applets/rotateapplet/rotate.cpp b/core/applets/rotateapplet/rotate.cpp
index cf3f28b..dcbf809 100644
--- a/core/applets/rotateapplet/rotate.cpp
+++ b/core/applets/rotateapplet/rotate.cpp
@@ -1,256 +1,252 @@
1/* 1/*
2 This file is part of the OPIE Project 2 This file is part of the OPIE Project
3 Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org> 3 Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org>
4 Copyright (C) 2003 Greg Gilbert <ggilbert@treke.net> 4 Copyright (C) 2003 Greg Gilbert <ggilbert@treke.net>
5               =. Copyright (C) 2004 Michael Lauer <mickey@Vanille.de> 5               =. Copyright (C) 2004 Michael Lauer <mickey@Vanille.de>
6             .=l. 6             .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This library is free software; you can 8 _;:,     .>    :=|. This library is free software; you can
9.> <,   >  .   <= redistribute it and/or modify it under 9.> <,   >  .   <= redistribute it and/or modify it under
10:=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%+i>       _;_. 14    .%+i>       _;_.
15    .i_,=:_.      -<s. This library is distributed in the hope that 15    .i_,=:_.      -<s. This library is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .     .: details. 21++=   -.     .     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-= this library; see the file COPYING.LIB. 25    --        :-= this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include "rotate.h" 31#include "rotate.h"
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie/odevice.h> 34#include <opie/odevice.h>
35#include <qpe/applnk.h>
36#include <qpe/config.h> 35#include <qpe/config.h>
37#include <qpe/power.h> 36#include <qpe/power.h>
38#include <qpe/qpeapplication.h>
39#include <qpe/qcopenvelope_qws.h> 37#include <qpe/qcopenvelope_qws.h>
40#include <qpe/resource.h> 38#include <qpe/resource.h>
41using namespace Opie; 39using namespace Opie;
42 40
43/* QT */ 41/* QT */
44#include <qiconset.h>
45#include <qpopupmenu.h>
46 42
47#include <time.h> 43#include <time.h>
48 44
49RotateApplet::RotateApplet() 45RotateApplet::RotateApplet()
50 :QObject( 0, "RotateApplet" ), m_flipped( false ) 46 :QObject( 0, "RotateApplet" ), m_flipped( false )
51{ 47{
52 48
53#if !defined(QT_NO_COP) 49#if !defined(QT_NO_COP)
54 QCopChannel *rotateChannel = new QCopChannel( "QPE/Rotation" , this ); 50 QCopChannel *rotateChannel = new QCopChannel( "QPE/Rotation" , this );
55 connect ( rotateChannel, SIGNAL( received( const QCString &, const QByteArray &) ), 51 connect ( rotateChannel, SIGNAL( received( const QCString &, const QByteArray &) ),
56 this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); 52 this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) );
57#endif 53#endif
58 54
59} 55}
60 56
61RotateApplet::~RotateApplet ( ) 57RotateApplet::~RotateApplet ( )
62{} 58{}
63 59
64/** 60/**
65 * Qcop receive method. 61 * Qcop receive method.
66 */ 62 */
67void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data ) 63void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data )
68{ 64{
69 qDebug( "RotateApplet::channelReceived( '%s' )", (const char*) msg ); 65 qDebug( "RotateApplet::channelReceived( '%s' )", (const char*) msg );
70 66
71 if ( ODevice::inst()->hasHingeSensor() ) 67 if ( ODevice::inst()->hasHingeSensor() )
72 { 68 {
73 struct timespec interval; 69 struct timespec interval;
74 struct timespec remain; 70 struct timespec remain;
75 interval.tv_sec = 0; 71 interval.tv_sec = 0;
76 interval.tv_nsec = 600000; 72 interval.tv_nsec = 600000;
77 ::nanosleep( &interval, &remain ); 73 ::nanosleep( &interval, &remain );
78 OHingeStatus status = ODevice::inst()->readHingeSensor(); 74 OHingeStatus status = ODevice::inst()->readHingeSensor();
79 qDebug( "RotateApplet::readHingeSensor = %d", (int) status ); 75 qDebug( "RotateApplet::readHingeSensor = %d", (int) status );
80 76
81 Config cfg( "apm" ); 77 Config cfg( "apm" );
82 cfg.setGroup( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online ? "AC" : "Battery" ); 78 cfg.setGroup( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online ? "AC" : "Battery" );
83 int action = cfg.readNumEntry( "CloseHingeAction", 0 ); 79 int action = cfg.readNumEntry( "CloseHingeAction", 0 );
84 80
85 if ( status == CASE_CLOSED ) 81 if ( status == CASE_CLOSED )
86 { 82 {
87 switch ( action ) 83 switch ( action )
88 { 84 {
89 case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 0 ); break; 85 case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 0 ); break;
90 case 2: /* SUSPEND */ ODevice::inst()->suspend(); break; 86 case 2: /* SUSPEND */ ODevice::inst()->suspend(); break;
91 default: /* IGNORE */ break; 87 default: /* IGNORE */ break;
92 } 88 }
93 } 89 }
94 else /* status != CASE_CLOSED */ 90 else /* status != CASE_CLOSED */
95 { 91 {
96 switch ( action ) 92 switch ( action )
97 { 93 {
98 case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 127 ); break; 94 case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 127 ); break;
99 case 2: /* SUSPEND */ /* How to wake up the device from kernel? */; break; 95 case 2: /* SUSPEND */ /* How to wake up the device from kernel? */; break;
100 default: /* IGNORE */ break; 96 default: /* IGNORE */ break;
101 } 97 }
102 } 98 }
103 qDebug( "RotateApplet::switchAction %d performed.", cfg.readNumEntry( "CloseHingeAction", 0 ) ); 99 qDebug( "RotateApplet::switchAction %d performed.", cfg.readNumEntry( "CloseHingeAction", 0 ) );
104 } 100 }
105 101
106 QDataStream stream( data, IO_ReadOnly ); 102 QDataStream stream( data, IO_ReadOnly );
107 if ( msg == "flip()" ) 103 if ( msg == "flip()" )
108 { 104 {
109 activated ( ); 105 activated ( );
110 } 106 }
111 else if ( msg == "rotateDefault()") 107 else if ( msg == "rotateDefault()")
112 { 108 {
113 rotateDefault(); 109 rotateDefault();
114 } 110 }
115} 111}
116 112
117int RotateApplet::position() const 113int RotateApplet::position() const
118{ 114{
119 return 3; 115 return 3;
120} 116}
121 117
122QString RotateApplet::name() const 118QString RotateApplet::name() const
123{ 119{
124 return tr( "Rotate shortcut" ); 120 return tr( "Rotate shortcut" );
125} 121}
126 122
127QString RotateApplet::text() const 123QString RotateApplet::text() const
128{ 124{
129 return tr( "Rotate" ); 125 return tr( "Rotate" );
130} 126}
131 127
132/*QString RotateApplet::tr( const char* s ) const 128/*QString RotateApplet::tr( const char* s ) const
133{ 129{
134 return qApp->translate( "RotateApplet", s, 0 ); 130 return qApp->translate( "RotateApplet", s, 0 );
135} 131}
136 132
137QString RotateApplet::tr( const char* s, const char* p ) const 133QString RotateApplet::tr( const char* s, const char* p ) const
138{ 134{
139 return qApp->translate( "RotateApplet", s, p ); 135 return qApp->translate( "RotateApplet", s, p );
140} 136}
141*/ 137*/
142 138
143QIconSet RotateApplet::icon() const 139QIconSet RotateApplet::icon() const
144{ 140{
145 QPixmap pix; 141 QPixmap pix;
146 QImage img = Resource::loadImage( "Rotation" ); 142 QImage img = Resource::loadImage( "Rotation" );
147 if ( !img.isNull() ) 143 if ( !img.isNull() )
148 pix.convertFromImage( img.smoothScale( 14, 14 ) ); 144 pix.convertFromImage( img.smoothScale( 14, 14 ) );
149 return pix; 145 return pix;
150} 146}
151 147
152QPopupMenu* RotateApplet::popup(QWidget*) const 148QPopupMenu* RotateApplet::popup(QWidget*) const
153{ 149{
154 return 0; 150 return 0;
155} 151}
156 152
157void RotateApplet::rotateDefault() 153void RotateApplet::rotateDefault()
158{ 154{
159 int rot = ODevice::inst()->rotation(); 155 int rot = ODevice::inst()->rotation();
160 156
161 switch (rot) 157 switch (rot)
162 { 158 {
163 case Rot0: rot=0; break; 159 case Rot0: rot=0; break;
164 case Rot90: rot=90; break; 160 case Rot90: rot=90; break;
165 case Rot180: rot=180; break; 161 case Rot180: rot=180; break;
166 case Rot270: rot=270; break; 162 case Rot270: rot=270; break;
167 default: rot=0; break; 163 default: rot=0; break;
168 } 164 }
169 165
170 Config cfg( "qpe" ); 166 Config cfg( "qpe" );
171 cfg.setGroup( "Appearance" ); 167 cfg.setGroup( "Appearance" );
172 168
173 bool rotateEnabled = cfg.readBoolEntry( "rotateEnabled",true ); 169 bool rotateEnabled = cfg.readBoolEntry( "rotateEnabled",true );
174 170
175 if ( !rotateEnabled) return; 171 if ( !rotateEnabled) return;
176 172
177 // hide inputs methods before rotation 173 // hide inputs methods before rotation
178 QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); 174 QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" );
179 175
180 QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); 176 QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" );
181 env << rot; 177 env << rot;
182 178
183 m_flipped = false; 179 m_flipped = false;
184 180
185} 181}
186void RotateApplet::activated() 182void RotateApplet::activated()
187{ 183{
188 int defaultRotation = QPEApplication::defaultRotation(); 184 int defaultRotation = QPEApplication::defaultRotation();
189 int newRotation = defaultRotation; 185 int newRotation = defaultRotation;
190 186
191 Config cfg( "qpe" ); 187 Config cfg( "qpe" );
192 cfg.setGroup( "Appearance" ); 188 cfg.setGroup( "Appearance" );
193 189
194 int rotDirection = cfg.readNumEntry( "rotatedir" ); 190 int rotDirection = cfg.readNumEntry( "rotatedir" );
195 ODirection rot = CW; 191 ODirection rot = CW;
196 192
197 if (rotDirection == -1) 193 if (rotDirection == -1)
198 { 194 {
199 rot = ODevice::inst()->direction(); 195 rot = ODevice::inst()->direction();
200 } 196 }
201 else 197 else
202 { 198 {
203 rot = (ODirection) rotDirection; 199 rot = (ODirection) rotDirection;
204 } 200 }
205 201
206 // hide inputs methods before rotation 202 // hide inputs methods before rotation
207 QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); 203 QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" );
208 204
209 if ( m_flipped ) 205 if ( m_flipped )
210 { 206 {
211 // if flipped, flip back to the original state, 207 // if flipped, flip back to the original state,
212 // regardless of rotation direction 208 // regardless of rotation direction
213 newRotation = defaultRotation; 209 newRotation = defaultRotation;
214 } 210 }
215 else 211 else
216 { 212 {
217 if ( rot == CCW ) 213 if ( rot == CCW )
218 { 214 {
219 newRotation = ( defaultRotation + 90 ) % 360; 215 newRotation = ( defaultRotation + 90 ) % 360;
220 } 216 }
221 else if ( rot == CW ) 217 else if ( rot == CW )
222 { 218 {
223 newRotation = ( defaultRotation + 270 ) % 360; 219 newRotation = ( defaultRotation + 270 ) % 360;
224 } 220 }
225 else if ( rot == Flip ) 221 else if ( rot == Flip )
226 { 222 {
227 newRotation = ( defaultRotation + 180 ) % 360; 223 newRotation = ( defaultRotation + 180 ) % 360;
228 } 224 }
229 } 225 }
230 226
231 QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); 227 QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" );
232 env << newRotation; 228 env << newRotation;
233 229
234 m_flipped = !m_flipped; 230 m_flipped = !m_flipped;
235} 231}
236 232
237 233
238QRESULT RotateApplet::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) 234QRESULT RotateApplet::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
239{ 235{
240 *iface = 0; 236 *iface = 0;
241 if ( uuid == IID_QUnknown ) 237 if ( uuid == IID_QUnknown )
242 *iface = this; 238 *iface = this;
243 else if ( uuid == IID_MenuApplet ) 239 else if ( uuid == IID_MenuApplet )
244 *iface = this; 240 *iface = this;
245 else 241 else
246 return QS_FALSE; 242 return QS_FALSE;
247 243
248 if ( *iface ) 244 if ( *iface )
249 (*iface)->addRef(); 245 (*iface)->addRef();
250 return QS_OK; 246 return QS_OK;
251} 247}
252 248
253Q_EXPORT_INTERFACE() 249Q_EXPORT_INTERFACE()
254{ 250{
255 Q_CREATE_INSTANCE( RotateApplet ) 251 Q_CREATE_INSTANCE( RotateApplet )
256} 252}
diff --git a/core/applets/rotateapplet/rotate.h b/core/applets/rotateapplet/rotate.h
index 2396993..bdccea0 100644
--- a/core/applets/rotateapplet/rotate.h
+++ b/core/applets/rotateapplet/rotate.h
@@ -1,71 +1,70 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2003 Maximilian Reiss <harlekin@handhelds.org> 3             .=l. Copyright (c) 2003 Maximilian Reiss <harlekin@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <_,   >  .   <= redistribute it and/or modify it under 6.> <_,   >  .   <= redistribute it and/or modify it under
7:=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%+i>       _;_. 11    .%+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .     .: details. 18++=   -.     .     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-= this library; see the file COPYING.LIB. 22    --        :-= this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29 29
30 30
31#ifndef __OPIE_ROTATE_APPLET_H__ 31#ifndef __OPIE_ROTATE_APPLET_H__
32#define __OPIE_ROTATE_APPLET_H__ 32#define __OPIE_ROTATE_APPLET_H__
33 33
34#include <qpe/menuappletinterface.h> 34#include <qpe/menuappletinterface.h>
35#include <qobject.h> 35#include <qobject.h>
36 36
37#include <qobject.h>
38 37
39class RotateApplet : public QObject, public MenuAppletInterface 38class RotateApplet : public QObject, public MenuAppletInterface
40{ 39{
41 40
42 Q_OBJECT 41 Q_OBJECT
43 42
44public: 43public:
45 RotateApplet ( ); 44 RotateApplet ( );
46 virtual ~RotateApplet ( ); 45 virtual ~RotateApplet ( );
47 46
48 QRESULT queryInterface( const QUuid&, QUnknownInterface** ); 47 QRESULT queryInterface( const QUuid&, QUnknownInterface** );
49 Q_REFCOUNT 48 Q_REFCOUNT
50 49
51 virtual int position() const; 50 virtual int position() const;
52 51
53 virtual QString name ( ) const; 52 virtual QString name ( ) const;
54 virtual QIconSet icon ( ) const; 53 virtual QIconSet icon ( ) const;
55 virtual QString text ( ) const; 54 virtual QString text ( ) const;
56 /* virtual QString tr( const char* ) const; 55 /* virtual QString tr( const char* ) const;
57 virtual QString tr( const char*, const char* ) const; 56 virtual QString tr( const char*, const char* ) const;
58 */ 57 */
59 virtual QPopupMenu *popup ( QWidget *parent ) const; 58 virtual QPopupMenu *popup ( QWidget *parent ) const;
60 virtual void activated ( ); 59 virtual void activated ( );
61 virtual void rotateDefault ( ); 60 virtual void rotateDefault ( );
62 61
63private slots: 62private slots:
64 void channelReceived( const QCString &msg, const QByteArray & data ); 63 void channelReceived( const QCString &msg, const QByteArray & data );
65 64
66private: 65private:
67 bool m_flipped : 1; 66 bool m_flipped : 1;
68 67
69}; 68};
70 69
71#endif 70#endif
diff --git a/core/applets/screenshotapplet/inputDialog.cpp b/core/applets/screenshotapplet/inputDialog.cpp
index f506dfd..73ec773 100644
--- a/core/applets/screenshotapplet/inputDialog.cpp
+++ b/core/applets/screenshotapplet/inputDialog.cpp
@@ -1,67 +1,64 @@
1/**************************************************************************** 1/****************************************************************************
2** Form implementation generated from reading ui file 'inputDialog.ui' 2** Form implementation generated from reading ui file 'inputDialog.ui'
3** 3**
4** Created: Sat Mar 2 07:55:03 2002 4** Created: Sat Mar 2 07:55:03 2002
5** by: The User Interface Compiler (uic) 5** by: The User Interface Compiler (uic)
6** 6**
7** WARNING! All changes made in this file will be lost! 7** WARNING! All changes made in this file will be lost!
8****************************************************************************/ 8****************************************************************************/
9#include "inputDialog.h" 9#include "inputDialog.h"
10 10
11#include <qpe/resource.h> 11#include <qpe/resource.h>
12 12
13#include <opie2/ofiledialog.h> 13#include <opie2/ofiledialog.h>
14 14
15#include <qlineedit.h> 15#include <qlineedit.h>
16#include <qlayout.h>
17#include <qvariant.h>
18#include <qpushbutton.h> 16#include <qpushbutton.h>
19#include <qwhatsthis.h>
20 17
21InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 18InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
22 : QDialog( parent, name, modal, fl ) 19 : QDialog( parent, name, modal, fl )
23{ 20{
24 if ( !name ) 21 if ( !name )
25 setName( "InputDialog" ); 22 setName( "InputDialog" );
26 resize( 234, 115); 23 resize( 234, 115);
27 setMaximumSize( QSize( 240, 40)); 24 setMaximumSize( QSize( 240, 40));
28 setCaption( tr(name ) ); 25 setCaption( tr(name ) );
29 26
30 QPushButton *browserButton; 27 QPushButton *browserButton;
31 browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton"); 28 browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton");
32 browserButton->setGeometry( QRect( 205, 10, 22, 22)); 29 browserButton->setGeometry( QRect( 205, 10, 22, 22));
33 connect( browserButton, SIGNAL(released()),this,SLOT(browse())); 30 connect( browserButton, SIGNAL(released()),this,SLOT(browse()));
34 LineEdit1 = new QLineEdit( this, "LineEdit1" ); 31 LineEdit1 = new QLineEdit( this, "LineEdit1" );
35 LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) ); 32 LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) );
36} 33}
37 34
38/* 35/*
39 * Destroys the object and frees any allocated resources 36 * Destroys the object and frees any allocated resources
40 */ 37 */
41InputDialog::~InputDialog() 38InputDialog::~InputDialog()
42{ 39{
43 inputText= LineEdit1->text(); 40 inputText= LineEdit1->text();
44 41
45} 42}
46 43
47void InputDialog::browse() { 44void InputDialog::browse() {
48 45
49 MimeTypes types; 46 MimeTypes types;
50 QStringList audio, video, all; 47 QStringList audio, video, all;
51 audio << "audio/*"; 48 audio << "audio/*";
52 audio << "playlist/plain"; 49 audio << "playlist/plain";
53 audio << "audio/x-mpegurl"; 50 audio << "audio/x-mpegurl";
54 51
55 video << "video/*"; 52 video << "video/*";
56 video << "playlist/plain"; 53 video << "playlist/plain";
57 54
58 all += audio; 55 all += audio;
59 all += video; 56 all += video;
60 types.insert("All Media Files", all ); 57 types.insert("All Media Files", all );
61 types.insert("Audio", audio ); 58 types.insert("Audio", audio );
62 types.insert("Video", video ); 59 types.insert("Video", video );
63 60
64 QString str = Opie::OFileDialog::getOpenFileName( 1,"/","", types, 0 ); 61 QString str = Opie::OFileDialog::getOpenFileName( 1,"/","", types, 0 );
65 LineEdit1->setText(str); 62 LineEdit1->setText(str);
66} 63}
67 64
diff --git a/core/applets/screenshotapplet/screenshot.cpp b/core/applets/screenshotapplet/screenshot.cpp
index 5f83539..56a031c 100644
--- a/core/applets/screenshotapplet/screenshot.cpp
+++ b/core/applets/screenshotapplet/screenshot.cpp
@@ -1,531 +1,530 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 L.J. Potter ljp@llornkcor.com 2** Copyright (C) 2002 L.J. Potter ljp@llornkcor.com
3** All rights reserved. 3** All rights reserved.
4** 4**
5** This file may be distributed and/or modified under the terms of the 5** This file may be distributed and/or modified under the terms of the
6** GNU General Public License version 2 as published by the Free Software 6** GNU General Public License version 2 as published by the Free Software
7** Foundation and appearing in the file LICENSE.GPL included in the 7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file. 8** packaging of this file.
9** 9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12** 12**
13**********************************************************************/ 13**********************************************************************/
14 14
15#include "screenshot.h" 15#include "screenshot.h"
16#include "inputDialog.h" 16#include "inputDialog.h"
17 17
18#include <stdlib.h> 18#include <stdlib.h>
19#include <sys/socket.h> 19#include <sys/socket.h>
20#include <netinet/in.h> 20#include <netinet/in.h>
21#include <netdb.h> 21#include <netdb.h>
22#include <unistd.h> 22#include <unistd.h>
23 23
24#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
25#include <qpe/applnk.h> 25#include <qpe/applnk.h>
26 26
27#include <qlineedit.h> 27#include <qlineedit.h>
28#include <qdir.h> 28#include <qdir.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31#include <qpainter.h> 31#include <qpainter.h>
32#include <qspinbox.h> 32#include <qspinbox.h>
33#include <qlayout.h> 33#include <qlayout.h>
34#include <qcheckbox.h> 34#include <qcheckbox.h>
35#include <qmessagebox.h> 35#include <qmessagebox.h>
36#include <qimage.h>
37 36
38 37
39/* XPM */ 38/* XPM */
40static char * snapshot_xpm[] = { 39static char * snapshot_xpm[] = {
41"32 32 177 2", 40"32 32 177 2",
42 " c None", 41 " c None",
43 ". c #042045", 42 ". c #042045",
44 "+ c #0D2B47", 43 "+ c #0D2B47",
45 "@ c #0E325E", 44 "@ c #0E325E",
46 "# c #0D2E50", 45 "# c #0D2E50",
47 "$ c #0A1C32", 46 "$ c #0A1C32",
48 "% c #0F3A69", 47 "% c #0F3A69",
49 "& c #164680", 48 "& c #164680",
50 "* c #165EAE", 49 "* c #165EAE",
51 "= c #134D89", 50 "= c #134D89",
52 "- c #0A3A6E", 51 "- c #0A3A6E",
53 "; c #031024", 52 "; c #031024",
54 "> c #031B36", 53 "> c #031B36",
55 ", c #1A5EA3", 54 ", c #1A5EA3",
56 "' c #1862B1", 55 "' c #1862B1",
57 ") c #1866B9", 56 ") c #1866B9",
58 "! c #0F5AAC", 57 "! c #0F5AAC",
59 "~ c #0F56A8", 58 "~ c #0F56A8",
60 "{ c #0C4C96", 59 "{ c #0C4C96",
61 "] c #030918", 60 "] c #030918",
62 "^ c #060206", 61 "^ c #060206",
63 "/ c #20242C", 62 "/ c #20242C",
64 "( c #3E3B3B", 63 "( c #3E3B3B",
65 "_ c #186ABD", 64 "_ c #186ABD",
66 ": c #115EB3", 65 ": c #115EB3",
67 "< c #082644", 66 "< c #082644",
68 "[ c #222C38", 67 "[ c #222C38",
69 "} c #5A5859", 68 "} c #5A5859",
70 "| c #091921", 69 "| c #091921",
71 "1 c #1E7EDE", 70 "1 c #1E7EDE",
72 "2 c #1A7ADA", 71 "2 c #1A7ADA",
73 "3 c #1970CD", 72 "3 c #1970CD",
74 "4 c #1758A1", 73 "4 c #1758A1",
75 "5 c #0E529A", 74 "5 c #0E529A",
76 "6 c #094388", 75 "6 c #094388",
77 "7 c #22364E", 76 "7 c #22364E",
78 "8 c #384454", 77 "8 c #384454",
79 "9 c #04162C", 78 "9 c #04162C",
80 "0 c #123451", 79 "0 c #123451",
81 "a c #3296B4", 80 "a c #3296B4",
82 "b c #298AB1", 81 "b c #298AB1",
83 "c c #2484AC", 82 "c c #2484AC",
84 "d c #033D86", 83 "d c #033D86",
85 "e c #033677", 84 "e c #033677",
86 "f c #072C58", 85 "f c #072C58",
87 "g c #525862", 86 "g c #525862",
88 "h c #5E5E5E", 87 "h c #5E5E5E",
89 "i c #23492A", 88 "i c #23492A",
90 "j c #4FBD3F", 89 "j c #4FBD3F",
91 "k c #50B24C", 90 "k c #50B24C",
92 "l c #51C72E", 91 "l c #51C72E",
93 "m c #42C64A", 92 "m c #42C64A",
94 "n c #2686CA", 93 "n c #2686CA",
95 "o c #0B52A4", 94 "o c #0B52A4",
96 "p c #054A9A", 95 "p c #054A9A",
97 "q c #053B7C", 96 "q c #053B7C",
98 "r c #2B2325", 97 "r c #2B2325",
99 "s c #6E7070", 98 "s c #6E7070",
100 "t c #0D240E", 99 "t c #0D240E",
101 "u c #1E423E", 100 "u c #1E423E",
102 "v c #468ABE", 101 "v c #468ABE",
103 "w c #6A8AC2", 102 "w c #6A8AC2",
104 "x c #7EAA8E", 103 "x c #7EAA8E",
105 "y c #84BE4E", 104 "y c #84BE4E",
106 "z c #65C639", 105 "z c #65C639",
107 "A c #064EA0", 106 "A c #064EA0",
108 "B c #0A4DA0", 107 "B c #0A4DA0",
109 "C c #4E5242", 108 "C c #4E5242",
110 "D c #62362E", 109 "D c #62362E",
111 "E c #721A1A", 110 "E c #721A1A",
112 "F c #6E0A0A", 111 "F c #6E0A0A",
113 "G c #3E0E0E", 112 "G c #3E0E0E",
114 "H c #6AB85E", 113 "H c #6AB85E",
115 "I c #7E8ECA", 114 "I c #7E8ECA",
116 "J c #929CD4", 115 "J c #929CD4",
117 "K c #9EAECA", 116 "K c #9EAECA",
118 "L c #9EBEAE", 117 "L c #9EBEAE",
119 "M c #8EC26A", 118 "M c #8EC26A",
120 "N c #32A276", 119 "N c #32A276",
121 "O c #20518C", 120 "O c #20518C",
122 "P c #46566E", 121 "P c #46566E",
123 "Q c #614A51", 122 "Q c #614A51",
124 "R c #AE2A26", 123 "R c #AE2A26",
125 "S c #C41C1A", 124 "S c #C41C1A",
126 "T c #CE0A0A", 125 "T c #CE0A0A",
127 "U c #A60606", 126 "U c #A60606",
128 "V c #921616", 127 "V c #921616",
129 "W c #863735", 128 "W c #863735",
130 "X c #866A66", 129 "X c #866A66",
131 "Y c #9E9EA2", 130 "Y c #9E9EA2",
132 "Z c #1E5212", 131 "Z c #1E5212",
133 "` c #7EC652", 132 "` c #7EC652",
134 " .c #B2B2F2", 133 " .c #B2B2F2",
135 "..c #CACAF6", 134 "..c #CACAF6",
136 "+.c #AECEC6", 135 "+.c #AECEC6",
137 "@.c #92CE72", 136 "@.c #92CE72",
138 "#.c #42AA86", 137 "#.c #42AA86",
139 "$.c #365E96", 138 "$.c #365E96",
140 "%.c #B82420", 139 "%.c #B82420",
141 "&.c #E20E0E", 140 "&.c #E20E0E",
142 "*.c #EF0E0B", 141 "*.c #EF0E0B",
143 "=.c #566A86", 142 "=.c #566A86",
144 "-.c #92929A", 143 "-.c #92929A",
145 ";.c #16260E", 144 ";.c #16260E",
146 ">.c #2E571A", 145 ">.c #2E571A",
147 ",.c #7ED64E", 146 ",.c #7ED64E",
148 "'.c #9ECEB2", 147 "'.c #9ECEB2",
149 ").c #C6D5EF", 148 ").c #C6D5EF",
150 "!.c #E2E0FE", 149 "!.c #E2E0FE",
151 "~.c #A2DE8A", 150 "~.c #A2DE8A",
152 "{.c #4AAA5B", 151 "{.c #4AAA5B",
153 "].c #2A6AB2", 152 "].c #2A6AB2",
154 "^.c #9A7A6E", 153 "^.c #9A7A6E",
155 "/.c #D25A52", 154 "/.c #D25A52",
156 "(.c #F62626", 155 "(.c #F62626",
157 "_.c #FA0206", 156 "_.c #FA0206",
158 ":.c #DE1E16", 157 ":.c #DE1E16",
159 "<.c #B63A26", 158 "<.c #B63A26",
160 "[.c #865A2E", 159 "[.c #865A2E",
161 "}.c #26568E", 160 "}.c #26568E",
162 "|.c #435F7D", 161 "|.c #435F7D",
163 "1.c #7AE246", 162 "1.c #7AE246",
164 "2.c #96EA6E", 163 "2.c #96EA6E",
165 "3.c #BEEAAE", 164 "3.c #BEEAAE",
166 "4.c #D0EADC", 165 "4.c #D0EADC",
167 "5.c #B6CEFE", 166 "5.c #B6CEFE",
168 "6.c #9ADE8A", 167 "6.c #9ADE8A",
169 "7.c #2A609A", 168 "7.c #2A609A",
170 "8.c #7E623E", 169 "8.c #7E623E",
171 "9.c #CA7A72", 170 "9.c #CA7A72",
172 "0.c #F26E6E", 171 "0.c #F26E6E",
173 "a.c #FE5252", 172 "a.c #FE5252",
174 "b.c #FA3638", 173 "b.c #FA3638",
175 "c.c #DA2E28", 174 "c.c #DA2E28",
176 "d.c #9E3E3A", 175 "d.c #9E3E3A",
177 "e.c #3E7656", 176 "e.c #3E7656",
178 "f.c #76CB3A", 177 "f.c #76CB3A",
179 "g.c #90DE44", 178 "g.c #90DE44",
180 "h.c #A2EE6A", 179 "h.c #A2EE6A",
181 "i.c #9EEA9A", 180 "i.c #9EEA9A",
182 "j.c #92BEDE", 181 "j.c #92BEDE",
183 "k.c #7ADA7E", 182 "k.c #7ADA7E",
184 "l.c #5ECE52", 183 "l.c #5ECE52",
185 "m.c #6A5E52", 184 "m.c #6A5E52",
186 "n.c #A83238", 185 "n.c #A83238",
187 "o.c #FA5656", 186 "o.c #FA5656",
188 "p.c #F29A92", 187 "p.c #F29A92",
189 "q.c #D29E92", 188 "q.c #D29E92",
190 "r.c #8A7A62", 189 "r.c #8A7A62",
191 "s.c #05336B", 190 "s.c #05336B",
192 "t.c #59C631", 191 "t.c #59C631",
193 "u.c #8AD23A", 192 "u.c #8AD23A",
194 "v.c #66E242", 193 "v.c #66E242",
195 "w.c #1D6FC1", 194 "w.c #1D6FC1",
196 "x.c #E61212", 195 "x.c #E61212",
197 "y.c #CA261E", 196 "y.c #CA261E",
198 "z.c #5A763E", 197 "z.c #5A763E",
199 "A.c #1E6E9A", 198 "A.c #1E6E9A",
200 "B.c #023272", 199 "B.c #023272",
201 "C.c #329696", 200 "C.c #329696",
202 "D.c #2074B6", 201 "D.c #2074B6",
203 "E.c #3E4E76", 202 "E.c #3E4E76",
204 "F.c #5A525E", 203 "F.c #5A525E",
205 "G.c #425868", 204 "G.c #425868",
206 "H.c #04448E", 205 "H.c #04448E",
207 "I.c #28828A", 206 "I.c #28828A",
208 "J.c #2D8593", 207 "J.c #2D8593",
209 "K.c #12427A", 208 "K.c #12427A",
210 "L.c #054696", 209 "L.c #054696",
211 "M.c #042B5E", 210 "M.c #042B5E",
212 "N.c #134F95", 211 "N.c #134F95",
213 "O.c #1E6ABB", 212 "O.c #1E6ABB",
214 "P.c #1A5E96", 213 "P.c #1A5E96",
215 "Q.c #022E67", 214 "Q.c #022E67",
216 "R.c #0C3E7C", 215 "R.c #0C3E7C",
217 "S.c #023E8A", 216 "S.c #023E8A",
218 "T.c #021A3E", 217 "T.c #021A3E",
219" ", 218" ",
220" ", 219" ",
221" ", 220" ",
222" . + @ # + ", 221" . + @ # + ",
223" $ # % & * * = - # $ ", 222" $ # % & * * = - # $ ",
224"; > % @ = , ' ) ' ! ~ { % @ . ] ^ / ( ", 223"; > % @ = , ' ) ' ! ~ { % @ . ] ^ / ( ",
225"; + ' * ) _ ) ) ' : : ! { { % < . [ ( } ", 224"; + ' * ) _ ) ) ' : : ! { { % < . [ ( } ",
226"| @ 1 2 3 _ _ ) ' : : : : 4 5 6 6 # 7 8 } ", 225"| @ 1 2 3 _ _ ) ' : : : : 4 5 6 6 # 7 8 } ",
227"9 0 a b b b c _ ) : : ! ! ~ ~ 5 ~ d e f [ 8 g h h } ", 226"9 0 a b b b c _ ) : : ! ! ~ ~ 5 ~ d e f [ 8 g h h } ",
228"| i j k j l m n 3 ) : ! ! ! ~ o o o p 6 q f / r r r s ", 227"| i j k j l m n 3 ) : ! ! ! ~ o o o p 6 q f / r r r s ",
229"t u v w x y y z a 1 3 ' : ! ~ A A B A p = C D E F G ( s ", 228"t u v w x y y z a 1 3 ' : ! ~ A A B A p = C D E F G ( s ",
230"| u H I J K L M H k N 3 3 : ~ o o 5 O P Q R S T T U V W X Y ", 229"| u H I J K L M H k N 3 3 : ~ o o 5 O P Q R S T T U V W X Y ",
231"| Z ` J .....+.@.z #.3 _ 3 3 ) $.P W %.S &.*.*.&.S W Q P =.-. ", 230"| Z ` J .....+.@.z #.3 _ 3 3 ) $.P W %.S &.*.*.&.S W Q P =.-. ",
232";.>.,.'.).!.!.).~.,.{.) : ) 3 ].h ^./.(._._._.:.<.[.g }.= & |. ", 231";.>.,.'.).!.!.).~.,.{.) : ) 3 ].h ^./.(._._._.:.<.[.g }.= & |. ",
233";.>.1.2.3.4.4.5.6.,.{._ : : : 7.8.9.0.a.b.b.c.d.} e.4 = 6 q # ", 232";.>.1.2.3.4.4.5.6.,.{._ : : : 7.8.9.0.a.b.b.c.d.} e.4 = 6 q # ",
234";.>.z f.g.h.i.j.k.l.N ) : ! ! 4 m.n.c.o.p.q.r.|.5 { d e e s.. ", 233";.>.z f.g.h.i.j.k.l.N ) : ! ! 4 m.n.c.o.p.q.r.|.5 { d e e s.. ",
235"t Z l t.f.u.g.1.v.#.w.' : ! ~ ~ 7.|.n.x.y.z.A.A q - e e e B.> ", 234"t Z l t.f.u.g.1.v.#.w.' : ! ~ ~ 7.|.n.x.y.z.A.A q - e e e B.> ",
236"| 0 c k t.t.l l C.D.) * * ! 5 { B o E.F.F.G.= H.e e e e q B.. ", 235"| 0 c k t.t.l l C.D.) * * ! 5 { B o E.F.F.G.= H.e e e e q B.. ",
237"; + D.I.J.I.I.I.w.) : : * o K.7 - L.= O = }.6 6 e q q e q s.> ", 236"; + D.I.J.I.I.I.w.) : : * o K.7 - L.= O = }.6 6 e q q e q s.> ",
238"9 + ) ) ) ) ' ' , * : ! ! ! K.< . M.q 6 B N.{ d q e e e e s.9 ", 237"9 + ) ) ) ) ' ' , * : ! ! ! K.< . M.q 6 B N.{ d q e e e e s.9 ",
239"9 # O.) ) ' , , P.* ! ! ! ! = % . . M.e d p L.d B.B.e B.B.Q.9 ", 238"9 # O.) ) ' , , P.* ! ! ! ! = % . . M.e d p L.d B.B.e B.B.Q.9 ",
240"; < ' ' ' ' , , 4 4 ~ ! ! ~ ! 5 e q e e q A H.d q q e e B.Q.9 ", 239"; < ' ' ' ' , , 4 4 ~ ! ! ~ ! 5 e q e e q A H.d q q e e B.Q.9 ",
241"; $ R.K.5 4 4 ' ! ! 4 ~ ! ~ ~ ~ o { B o A A L.S.B.B.B.B.B.Q.> ", 240"; $ R.K.5 4 4 ' ! ! 4 ~ ! ~ ~ ~ o { B o A A L.S.B.B.B.B.B.Q.> ",
242" ] $ 0 R.= ' ' 4 4 5 4 5 5 o B o B p A A L.d e e B.B.B.Q.9 ", 241" ] $ 0 R.= ' ' 4 4 5 4 5 5 o B o B p A A L.d e e B.B.B.Q.9 ",
243" # + - { 4 4 ~ ! o { o L.p p p p p H.S.B.B.s.Q.Q.M.T. ", 242" # + - { 4 4 ~ ! o { o L.p p p p p H.S.B.B.s.Q.Q.M.T. ",
244" + s.6 B o o 5 B p L.p p L.p H.q B.Q.Q.Q.Q.M.; ", 243" + s.6 B o o 5 B p L.p p L.p H.q B.Q.Q.Q.Q.M.; ",
245" < # s.- B o B p p L.L.H.L.H.d B.Q.Q.Q.Q.Q.9 ", 244" < # s.- B o B p p L.L.H.L.H.d B.Q.Q.Q.Q.Q.9 ",
246" $ . s.d 6 B A p H.S.L.H.q B.Q.Q.M.M.. ; ", 245" $ . s.d 6 B A p H.S.L.H.q B.Q.Q.M.M.. ; ",
247" ; 9 . 6 L.p L.d L.H.d Q.M.M.. 9 ; ] ", 246" ; 9 . 6 L.p L.d L.H.d Q.M.M.. 9 ; ] ",
248" | > e L.d L.H.e M.. ; ] ] ", 247" | > e L.d L.H.e M.. ; ] ] ",
249" > 9 . S.Q.. ; ] ", 248" > 9 . S.Q.. ; ] ",
250" T.; ] "}; 249" T.; ] "};
251 250
252static const char *SCAP_hostname = "www.handhelds.org"; 251static const char *SCAP_hostname = "www.handhelds.org";
253static const int SCAP_port = 80; 252static const int SCAP_port = 80;
254 253
255 254
256ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name ) 255ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name )
257 : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) 256 : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup )
258{ 257{
259 setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); 258 setFrameStyle( QFrame::PopupPanel | QFrame::Raised );
260 QVBoxLayout *vbox = new QVBoxLayout ( this, 5, 3 ); 259 QVBoxLayout *vbox = new QVBoxLayout ( this, 5, 3 );
261 QHBoxLayout *hbox; 260 QHBoxLayout *hbox;
262 261
263 hbox = new QHBoxLayout ( vbox ); 262 hbox = new QHBoxLayout ( vbox );
264 263
265 QLabel *l = new QLabel ( tr( "Delay" ), this ); 264 QLabel *l = new QLabel ( tr( "Delay" ), this );
266 hbox-> addWidget ( l ); 265 hbox-> addWidget ( l );
267 266
268 delaySpin = new QSpinBox( 0, 60, 1, this, "Spinner" ); 267 delaySpin = new QSpinBox( 0, 60, 1, this, "Spinner" );
269 delaySpin-> setButtonSymbols ( QSpinBox::PlusMinus ); 268 delaySpin-> setButtonSymbols ( QSpinBox::PlusMinus );
270 delaySpin-> setSuffix ( tr( "sec" )); 269 delaySpin-> setSuffix ( tr( "sec" ));
271 delaySpin-> setFocusPolicy( QWidget::NoFocus ); 270 delaySpin-> setFocusPolicy( QWidget::NoFocus );
272 delaySpin-> setValue ( 1 ); 271 delaySpin-> setValue ( 1 );
273 hbox-> addWidget ( delaySpin ); 272 hbox-> addWidget ( delaySpin );
274 273
275 saveNamedCheck = new QCheckBox ( tr( "Save named" ), this); 274 saveNamedCheck = new QCheckBox ( tr( "Save named" ), this);
276 saveNamedCheck-> setFocusPolicy ( QWidget::NoFocus ); 275 saveNamedCheck-> setFocusPolicy ( QWidget::NoFocus );
277 vbox->addWidget( saveNamedCheck); 276 vbox->addWidget( saveNamedCheck);
278 277
279 vbox-> addSpacing ( 3 ); 278 vbox-> addSpacing ( 3 );
280 279
281 l = new QLabel ( tr( "Save screenshot as..." ), this ); 280 l = new QLabel ( tr( "Save screenshot as..." ), this );
282 vbox-> addWidget ( l, AlignCenter ); 281 vbox-> addWidget ( l, AlignCenter );
283 282
284 hbox = new QHBoxLayout ( vbox ); 283 hbox = new QHBoxLayout ( vbox );
285 284
286 grabItButton = new QPushButton( tr( "File" ), this, "GrabButton" ); 285 grabItButton = new QPushButton( tr( "File" ), this, "GrabButton" );
287 grabItButton ->setFocusPolicy( QWidget::TabFocus ); 286 grabItButton ->setFocusPolicy( QWidget::TabFocus );
288 hbox-> addWidget ( grabItButton ); 287 hbox-> addWidget ( grabItButton );
289 288
290 scapButton = new QPushButton( tr( "Scap" ), this, "ScapButton" ); 289 scapButton = new QPushButton( tr( "Scap" ), this, "ScapButton" );
291 scapButton ->setFocusPolicy( QWidget::TabFocus ); 290 scapButton ->setFocusPolicy( QWidget::TabFocus );
292 hbox-> addWidget ( scapButton ); 291 hbox-> addWidget ( scapButton );
293 292
294 setFixedSize ( sizeHint ( )); 293 setFixedSize ( sizeHint ( ));
295 setFocusPolicy ( QWidget::NoFocus ); 294 setFocusPolicy ( QWidget::NoFocus );
296 295
297 296
298 grabTimer = new QTimer ( this, "grab timer"); 297 grabTimer = new QTimer ( this, "grab timer");
299 298
300 connect ( grabTimer, SIGNAL( timeout ( )), this, SLOT( performGrab ( ))); 299 connect ( grabTimer, SIGNAL( timeout ( )), this, SLOT( performGrab ( )));
301 connect ( grabItButton, SIGNAL( clicked ( )), SLOT( slotGrab ( ))); 300 connect ( grabItButton, SIGNAL( clicked ( )), SLOT( slotGrab ( )));
302 connect ( scapButton, SIGNAL( clicked ( )), SLOT( slotScap ( ))); 301 connect ( scapButton, SIGNAL( clicked ( )), SLOT( slotScap ( )));
303} 302}
304 303
305void ScreenshotControl::slotGrab() 304void ScreenshotControl::slotGrab()
306{ 305{
307 buttonPushed = 1; 306 buttonPushed = 1;
308 hide(); 307 hide();
309 308
310 setFileName = FALSE; 309 setFileName = FALSE;
311 if ( saveNamedCheck->isChecked()) { 310 if ( saveNamedCheck->isChecked()) {
312 setFileName = TRUE; 311 setFileName = TRUE;
313 InputDialog *fileDlg; 312 InputDialog *fileDlg;
314 313
315 fileDlg = new InputDialog( 0 , tr("Name of screenshot "), TRUE, 0); 314 fileDlg = new InputDialog( 0 , tr("Name of screenshot "), TRUE, 0);
316 fileDlg->exec(); 315 fileDlg->exec();
317 fileDlg->raise(); 316 fileDlg->raise();
318 QString fileName, list; 317 QString fileName, list;
319 if ( fileDlg->result() == 1 ) { 318 if ( fileDlg->result() == 1 ) {
320 fileName = fileDlg->LineEdit1->text(); 319 fileName = fileDlg->LineEdit1->text();
321 320
322 if (fileName.find("/", 0, TRUE) == -1) 321 if (fileName.find("/", 0, TRUE) == -1)
323 FileNamePath = QDir::homeDirPath() + "/Documents/image/png/" + fileName; 322 FileNamePath = QDir::homeDirPath() + "/Documents/image/png/" + fileName;
324 else 323 else
325 FileNamePath = fileName; 324 FileNamePath = fileName;
326 325
327 } 326 }
328 delete fileDlg; 327 delete fileDlg;
329 } 328 }
330 329
331 if ( delaySpin->value() ) 330 if ( delaySpin->value() )
332 grabTimer->start( delaySpin->value() * 1000, true ); 331 grabTimer->start( delaySpin->value() * 1000, true );
333 else 332 else
334 show(); 333 show();
335} 334}
336 335
337void ScreenshotControl::slotScap() 336void ScreenshotControl::slotScap()
338{ 337{
339 buttonPushed = 2; 338 buttonPushed = 2;
340 hide(); 339 hide();
341 340
342 if ( delaySpin->value() ) 341 if ( delaySpin->value() )
343 grabTimer->start( delaySpin->value() * 1000, true ); 342 grabTimer->start( delaySpin->value() * 1000, true );
344 else 343 else
345 show(); 344 show();
346} 345}
347 346
348 347
349void ScreenshotControl::savePixmap() 348void ScreenshotControl::savePixmap()
350{ 349{
351 DocLnk lnk; 350 DocLnk lnk;
352 QString fileName; 351 QString fileName;
353 352
354 if ( setFileName) { 353 if ( setFileName) {
355 fileName = FileNamePath; 354 fileName = FileNamePath;
356 //not sure why this is needed here, but it forgets fileName 355 //not sure why this is needed here, but it forgets fileName
357 // if this is below the braces 356 // if this is below the braces
358 357
359 if (fileName.right(3) != "png") 358 if (fileName.right(3) != "png")
360 fileName = fileName + ".png"; 359 fileName = fileName + ".png";
361 lnk.setFile(fileName); //sets File property 360 lnk.setFile(fileName); //sets File property
362 qDebug("saving file " + fileName); 361 qDebug("saving file " + fileName);
363 snapshot.save( fileName, "PNG"); 362 snapshot.save( fileName, "PNG");
364 QFileInfo fi( fileName); 363 QFileInfo fi( fileName);
365 lnk.setName( fi.fileName()); //sets file name 364 lnk.setName( fi.fileName()); //sets file name
366 365
367 if (!lnk.writeLink()) 366 if (!lnk.writeLink())
368 qDebug("Writing doclink did not work"); 367 qDebug("Writing doclink did not work");
369 } 368 }
370 else { 369 else {
371 370
372 fileName = "sc_" + QDateTime::currentDateTime().toString(); 371 fileName = "sc_" + QDateTime::currentDateTime().toString();
373 fileName.replace(QRegExp("'"), ""); 372 fileName.replace(QRegExp("'"), "");
374 fileName.replace(QRegExp(" "), "_"); 373 fileName.replace(QRegExp(" "), "_");
375 fileName.replace(QRegExp(":"), "."); 374 fileName.replace(QRegExp(":"), ".");
376 fileName.replace(QRegExp(","), ""); 375 fileName.replace(QRegExp(","), "");
377 QString dirName = QDir::homeDirPath() + "/Documents/image/png/"; 376 QString dirName = QDir::homeDirPath() + "/Documents/image/png/";
378 377
379 if ( !QDir( dirName).exists() ) { 378 if ( !QDir( dirName).exists() ) {
380 qDebug("making dir " + dirName); 379 qDebug("making dir " + dirName);
381 QString msg = "mkdir -p " + dirName; 380 QString msg = "mkdir -p " + dirName;
382 system(msg.latin1()); 381 system(msg.latin1());
383 } 382 }
384 fileName = dirName + fileName; 383 fileName = dirName + fileName;
385 if (fileName.right(3) != "png") 384 if (fileName.right(3) != "png")
386 fileName = fileName + ".png"; 385 fileName = fileName + ".png";
387 lnk.setFile(fileName); //sets File property 386 lnk.setFile(fileName); //sets File property
388 qDebug("saving file " + fileName); 387 qDebug("saving file " + fileName);
389 snapshot.save( fileName, "PNG"); 388 snapshot.save( fileName, "PNG");
390 QFileInfo fi( fileName); 389 QFileInfo fi( fileName);
391 lnk.setName( fi.fileName()); //sets file name 390 lnk.setName( fi.fileName()); //sets file name
392 391
393 if (!lnk.writeLink()) 392 if (!lnk.writeLink())
394 qDebug("Writing doclink did not work"); 393 qDebug("Writing doclink did not work");
395 394
396 } 395 }
397 396
398 QPEApplication::beep(); 397 QPEApplication::beep();
399} 398}
400 399
401void ScreenshotControl::performGrab() 400void ScreenshotControl::performGrab()
402{ 401{
403 snapshot = QPixmap::grabWindow( QPEApplication::desktop()->winId(), 0, 0, QApplication::desktop()->width(), QApplication::desktop()->height() ); 402 snapshot = QPixmap::grabWindow( QPEApplication::desktop()->winId(), 0, 0, QApplication::desktop()->width(), QApplication::desktop()->height() );
404 403
405 if (buttonPushed == 1) { 404 if (buttonPushed == 1) {
406 qDebug("grabbing screen"); 405 qDebug("grabbing screen");
407 grabTimer->stop(); 406 grabTimer->stop();
408 show(); 407 show();
409 qApp->processEvents(); 408 qApp->processEvents();
410 savePixmap(); 409 savePixmap();
411 } else { 410 } else {
412 grabTimer->stop(); 411 grabTimer->stop();
413 412
414 struct sockaddr_in raddr; 413 struct sockaddr_in raddr;
415 struct hostent *rhost_info; 414 struct hostent *rhost_info;
416 int sock = -1; 415 int sock = -1;
417 bool ok = false; 416 bool ok = false;
418 417
419 QString displayEnv = getenv("QWS_DISPLAY"); 418 QString displayEnv = getenv("QWS_DISPLAY");
420 qDebug(displayEnv); 419 qDebug(displayEnv);
421 420
422 if(( displayEnv.left(2) != ":0" ) && (!displayEnv.isEmpty())) { 421 if(( displayEnv.left(2) != ":0" ) && (!displayEnv.isEmpty())) {
423 422
424 if (( rhost_info = (struct hostent *) ::gethostbyname ((char *) SCAP_hostname )) != 0 ) { 423 if (( rhost_info = (struct hostent *) ::gethostbyname ((char *) SCAP_hostname )) != 0 ) {
425 ::memset ( &raddr, 0, sizeof (struct sockaddr_in)); 424 ::memset ( &raddr, 0, sizeof (struct sockaddr_in));
426 ::memcpy ( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); 425 ::memcpy ( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length );
427 raddr. sin_family = rhost_info-> h_addrtype; 426 raddr. sin_family = rhost_info-> h_addrtype;
428 raddr. sin_port = htons ( SCAP_port ); 427 raddr. sin_port = htons ( SCAP_port );
429 428
430 if (( sock = ::socket ( AF_INET, SOCK_STREAM, 0 )) >= 0 ) { 429 if (( sock = ::socket ( AF_INET, SOCK_STREAM, 0 )) >= 0 ) {
431 if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) { 430 if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) {
432 431
433 QString header; 432 QString header;
434 433
435 QPixmap pix; 434 QPixmap pix;
436 435
437 QString SCAP_model=""; 436 QString SCAP_model="";
438#warning FIXME: model string should be filled with actual device model 437#warning FIXME: model string should be filled with actual device model
439 if( snapshot.width() > 320) 438 if( snapshot.width() > 320)
440 SCAP_model ="Corgi"; 439 SCAP_model ="Corgi";
441 440
442 if(displayEnv == "QVFb:0") {//set this if you plan on using this app in qvfb!! 441 if(displayEnv == "QVFb:0") {//set this if you plan on using this app in qvfb!!
443 pix = snapshot.xForm(QWMatrix().rotate(90)); 442 pix = snapshot.xForm(QWMatrix().rotate(90));
444 } else 443 } else
445 pix = ( snapshot.width() > snapshot.height() ) ? snapshot : snapshot.xForm( QWMatrix().rotate(90) ); 444 pix = ( snapshot.width() > snapshot.height() ) ? snapshot : snapshot.xForm( QWMatrix().rotate(90) );
446 445
447 QImage img = pix.convertToImage().convertDepth( 16 ); // could make that also depth independent, if hh.org/scap can handle it 446 QImage img = pix.convertToImage().convertDepth( 16 ); // could make that also depth independent, if hh.org/scap can handle it
448 447
449 header = "POST /scap/capture.cgi?%1+%2 HTTP/1.1\n" // 1: model / 2: user 448 header = "POST /scap/capture.cgi?%1+%2 HTTP/1.1\n" // 1: model / 2: user
450 "Content-length: %3\n" // 3: content length 449 "Content-length: %3\n" // 3: content length
451 "Content-Type: image/png\n" 450 "Content-Type: image/png\n"
452 "Host: %4\n" // 4: scap host 451 "Host: %4\n" // 4: scap host
453 "\n"; 452 "\n";
454 453
455 454
456 header = header.arg( SCAP_model).arg( ::getenv( "USER" ) ).arg( img.numBytes() ).arg( SCAP_hostname ); 455 header = header.arg( SCAP_model).arg( ::getenv( "USER" ) ).arg( img.numBytes() ).arg( SCAP_hostname );
457 qDebug(header); 456 qDebug(header);
458 457
459 if ( !pix.isNull() ) { 458 if ( !pix.isNull() ) {
460 const char *ascii = header.latin1( ); 459 const char *ascii = header.latin1( );
461 uint ascii_len = ::strlen( ascii ); 460 uint ascii_len = ::strlen( ascii );
462 ::write ( sock, ascii, ascii_len ); 461 ::write ( sock, ascii, ascii_len );
463 ::write ( sock, img.bits(), img.numBytes() ); 462 ::write ( sock, img.bits(), img.numBytes() );
464 463
465 ok = true; 464 ok = true;
466 } 465 }
467 } 466 }
468 ::close ( sock ); 467 ::close ( sock );
469 } 468 }
470 } 469 }
471 if ( ok ) { 470 if ( ok ) {
472 QMessageBox::information( 0, tr( "Success" ), QString( "<p>%1</p>" ).arg ( tr( "Screenshot was uploaded to %1" )).arg( SCAP_hostname )); 471 QMessageBox::information( 0, tr( "Success" ), QString( "<p>%1</p>" ).arg ( tr( "Screenshot was uploaded to %1" )).arg( SCAP_hostname ));
473 } else { 472 } else {
474 QMessageBox::warning( 0, tr( "Error" ), QString( "<p>%1</p>" ).arg( tr( "Connection to %1 failed." )).arg( SCAP_hostname )); 473 QMessageBox::warning( 0, tr( "Error" ), QString( "<p>%1</p>" ).arg( tr( "Connection to %1 failed." )).arg( SCAP_hostname ));
475 } 474 }
476 } else { 475 } else {
477 QMessageBox::warning( 0, tr( "Error" ),tr("Please set <b>QWS_DISPLAY</b> environmental variable.")); 476 QMessageBox::warning( 0, tr( "Error" ),tr("Please set <b>QWS_DISPLAY</b> environmental variable."));
478 } 477 }
479 } 478 }
480 479
481} 480}
482 481
483 482
484 483
485//=========================================================================== 484//===========================================================================
486 485
487ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name ) 486ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name )
488 : QWidget( parent, name ) 487 : QWidget( parent, name )
489{ 488{
490 setFixedWidth( AppLnk::smallIconSize()); 489 setFixedWidth( AppLnk::smallIconSize());
491 490
492 QImage img = (const char **)snapshot_xpm; 491 QImage img = (const char **)snapshot_xpm;
493 img = img.smoothScale(AppLnk::smallIconSize(), AppLnk::smallIconSize()); 492 img = img.smoothScale(AppLnk::smallIconSize(), AppLnk::smallIconSize());
494 m_icon.convertFromImage(img); 493 m_icon.convertFromImage(img);
495} 494}
496 495
497ScreenshotApplet::~ScreenshotApplet() 496ScreenshotApplet::~ScreenshotApplet()
498{ 497{
499} 498}
500 499
501void ScreenshotApplet::mousePressEvent( QMouseEvent *) 500void ScreenshotApplet::mousePressEvent( QMouseEvent *)
502{ 501{
503 ScreenshotControl *sc = new ScreenshotControl ( ); 502 ScreenshotControl *sc = new ScreenshotControl ( );
504 QPoint curPos = mapToGlobal ( QPoint ( 0, 0 )); 503 QPoint curPos = mapToGlobal ( QPoint ( 0, 0 ));
505 504
506 // windowPosX is the windows position centered above the applets icon. 505 // windowPosX is the windows position centered above the applets icon.
507 // If the icon is near the edge of the screen, the window would leave the visible area 506 // If the icon is near the edge of the screen, the window would leave the visible area
508 // so we check the position against the screen width and correct the difference if needed 507 // so we check the position against the screen width and correct the difference if needed
509 508
510 int screenWidth = qApp->desktop()->width(); 509 int screenWidth = qApp->desktop()->width();
511 int windowPosX = curPos. x ( ) - ( sc-> sizeHint ( ). width ( ) - width ( )) / 2 ; 510 int windowPosX = curPos. x ( ) - ( sc-> sizeHint ( ). width ( ) - width ( )) / 2 ;
512 int ZwindowPosX, XwindowPosX; 511 int ZwindowPosX, XwindowPosX;
513 512
514 // the window would be placed beyond the screen wich doesn't look tooo good 513 // the window would be placed beyond the screen wich doesn't look tooo good
515 if ( (windowPosX + sc-> sizeHint ( ). width ( )) > screenWidth ) { 514 if ( (windowPosX + sc-> sizeHint ( ). width ( )) > screenWidth ) {
516 XwindowPosX = windowPosX + sc-> sizeHint ( ). width ( ) - screenWidth; 515 XwindowPosX = windowPosX + sc-> sizeHint ( ). width ( ) - screenWidth;
517 ZwindowPosX = windowPosX - XwindowPosX - 1; 516 ZwindowPosX = windowPosX - XwindowPosX - 1;
518 } else { 517 } else {
519 ZwindowPosX = windowPosX; 518 ZwindowPosX = windowPosX;
520 } 519 }
521 520
522 sc-> move ( ZwindowPosX, curPos. y ( ) - sc-> sizeHint ( ). height ( ) ); 521 sc-> move ( ZwindowPosX, curPos. y ( ) - sc-> sizeHint ( ). height ( ) );
523 sc-> show ( ); 522 sc-> show ( );
524} 523}
525 524
526void ScreenshotApplet::paintEvent( QPaintEvent* ) 525void ScreenshotApplet::paintEvent( QPaintEvent* )
527{ 526{
528 QPainter p ( this ); 527 QPainter p ( this );
529 p.drawPixmap( 0,0, m_icon ); 528 p.drawPixmap( 0,0, m_icon );
530} 529}
531 530
diff --git a/core/applets/suspendapplet/suspend.cpp b/core/applets/suspendapplet/suspend.cpp
index e17142b..0eb94cb 100644
--- a/core/applets/suspendapplet/suspend.cpp
+++ b/core/applets/suspendapplet/suspend.cpp
@@ -1,87 +1,85 @@
1#include <qpe/resource.h> 1#include <qpe/resource.h>
2#include <qpe/qcopenvelope_qws.h> 2#include <qpe/qcopenvelope_qws.h>
3 3
4#include <qapplication.h> 4#include <qapplication.h>
5#include <qiconset.h>
6#include <qpopupmenu.h>
7 5
8#include "suspend.h" 6#include "suspend.h"
9 7
10 8
11SuspendApplet::SuspendApplet ( ) 9SuspendApplet::SuspendApplet ( )
12 : QObject ( 0, "SuspendApplet" ) 10 : QObject ( 0, "SuspendApplet" )
13{ 11{
14} 12}
15 13
16SuspendApplet::~SuspendApplet ( ) 14SuspendApplet::~SuspendApplet ( )
17{ 15{
18} 16}
19 17
20int SuspendApplet::position ( ) const 18int SuspendApplet::position ( ) const
21{ 19{
22 return 2; 20 return 2;
23} 21}
24 22
25QString SuspendApplet::name ( ) const 23QString SuspendApplet::name ( ) const
26{ 24{
27 return tr( "Suspend shortcut" ); 25 return tr( "Suspend shortcut" );
28} 26}
29 27
30QString SuspendApplet::text ( ) const 28QString SuspendApplet::text ( ) const
31{ 29{
32 return tr( "Suspend" ); 30 return tr( "Suspend" );
33} 31}
34 32
35QString SuspendApplet::tr( const char* s ) const 33QString SuspendApplet::tr( const char* s ) const
36{ 34{
37 return qApp->translate( "SuspendApplet", s, 0 ); 35 return qApp->translate( "SuspendApplet", s, 0 );
38} 36}
39 37
40QString SuspendApplet::tr( const char* s, const char* p ) const 38QString SuspendApplet::tr( const char* s, const char* p ) const
41{ 39{
42 return qApp->translate( "SuspendApplet", s, p ); 40 return qApp->translate( "SuspendApplet", s, p );
43} 41}
44 42
45QIconSet SuspendApplet::icon ( ) const 43QIconSet SuspendApplet::icon ( ) const
46{ 44{
47 QPixmap pix; 45 QPixmap pix;
48 QImage img = Resource::loadImage ( "suspend" ); 46 QImage img = Resource::loadImage ( "suspend" );
49 47
50 if ( !img. isNull ( )) 48 if ( !img. isNull ( ))
51 pix. convertFromImage ( img. smoothScale ( 14, 14 )); 49 pix. convertFromImage ( img. smoothScale ( 14, 14 ));
52 return pix; 50 return pix;
53} 51}
54 52
55QPopupMenu *SuspendApplet::popup ( QWidget * ) const 53QPopupMenu *SuspendApplet::popup ( QWidget * ) const
56{ 54{
57 return 0; 55 return 0;
58} 56}
59 57
60void SuspendApplet::activated ( ) 58void SuspendApplet::activated ( )
61{ 59{
62 // suspend 60 // suspend
63 QCopEnvelope ( "QPE/System", "suspend()" ); 61 QCopEnvelope ( "QPE/System", "suspend()" );
64} 62}
65 63
66 64
67QRESULT SuspendApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) 65QRESULT SuspendApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface )
68{ 66{
69 *iface = 0; 67 *iface = 0;
70 if ( uuid == IID_QUnknown ) 68 if ( uuid == IID_QUnknown )
71 *iface = this; 69 *iface = this;
72 else if ( uuid == IID_MenuApplet ) 70 else if ( uuid == IID_MenuApplet )
73 *iface = this; 71 *iface = this;
74 else 72 else
75 return QS_FALSE; 73 return QS_FALSE;
76 74
77 if ( *iface ) 75 if ( *iface )
78 (*iface)-> addRef ( ); 76 (*iface)-> addRef ( );
79 return QS_OK; 77 return QS_OK;
80} 78}
81 79
82Q_EXPORT_INTERFACE( ) 80Q_EXPORT_INTERFACE( )
83{ 81{
84 Q_CREATE_INSTANCE( SuspendApplet ) 82 Q_CREATE_INSTANCE( SuspendApplet )
85} 83}
86 84
87 85
diff --git a/core/applets/volumeapplet/oledbox.cpp b/core/applets/volumeapplet/oledbox.cpp
index 7547287..bf275a9 100644
--- a/core/applets/volumeapplet/oledbox.cpp
+++ b/core/applets/volumeapplet/oledbox.cpp
@@ -1,275 +1,274 @@
1 1
2#include <qpixmap.h>
3#include <qbitmap.h> 2#include <qbitmap.h>
4#include <qpainter.h> 3#include <qpainter.h>
5 4
6#include "oledbox.h" 5#include "oledbox.h"
7 6
8 7
9#ifdef _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC 8#ifdef _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC
10 9
11/* XPM */ 10/* XPM */
12static const char * ledborder_xpm[] = { 11static const char * ledborder_xpm[] = {
13"16 16 11 1", 12"16 16 11 1",
14 " c None", 13 " c None",
15 ".c #626562", 14 ".c #626562",
16 "+c #7B7D7B", 15 "+c #7B7D7B",
17 "@c #949594", 16 "@c #949594",
18 "#c #ACAEAC", 17 "#c #ACAEAC",
19 "$c #CDCACD", 18 "$c #CDCACD",
20 "%c #CDCECD", 19 "%c #CDCECD",
21 ";c #E6E6E6", 20 ";c #E6E6E6",
22 ">c #FFFFFF", 21 ">c #FFFFFF",
23 ",c #E6E2E6", 22 ",c #E6E2E6",
24 "'c #FFFAFF", 23 "'c #FFFAFF",
25" .++@@# ", 24" .++@@# ",
26" ...++@@##$ ", 25" ...++@@##$ ",
27" .....+@##$$% ", 26" .....+@##$$% ",
28" ..... #$%%% ", 27" ..... #$%%% ",
29" ... %%; ", 28" ... %%; ",
30".... ;;;;", 29".... ;;;;",
31"++. ;>>", 30"++. ;>>",
32"+++ >>>", 31"+++ >>>",
33"@@@ >>>", 32"@@@ >>>",
34"@@# >>>", 33"@@# >>>",
35"#### >>>>", 34"#### >>>>",
36" #$$ >>> ", 35" #$$ >>> ",
37" $$,,' >>>>> ", 36" $$,,' >>>>> ",
38" ,,,''>>>>>>> ", 37" ,,,''>>>>>>> ",
39" ,''>>>>>>> ", 38" ,''>>>>>>> ",
40" '>>>>> "}; 39" '>>>>> "};
41 40
42 41
43QPixmap *OLedBox::s_border_pix = 0; 42QPixmap *OLedBox::s_border_pix = 0;
44 43
45#endif 44#endif
46 45
47 46
48OLedBox::OLedBox ( const QColor &col, QWidget *parent, const char *name ) : QWidget ( parent, name ) 47OLedBox::OLedBox ( const QColor &col, QWidget *parent, const char *name ) : QWidget ( parent, name )
49{ 48{
50 m_color = col; 49 m_color = col;
51 m_on = false; 50 m_on = false;
52 51
53 m_pix [ 0 ] = m_pix [ 1 ] = false; 52 m_pix [ 0 ] = m_pix [ 1 ] = false;
54 53
55 setBackgroundMode ( PaletteBackground ); 54 setBackgroundMode ( PaletteBackground );
56 55
57#ifdef _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC 56#ifdef _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC
58 if ( !s_border_pix ) 57 if ( !s_border_pix )
59 s_border_pix = new QPixmap ( ledborder_xpm ); 58 s_border_pix = new QPixmap ( ledborder_xpm );
60#endif 59#endif
61} 60}
62 61
63OLedBox::~OLedBox ( ) 62OLedBox::~OLedBox ( )
64{ 63{
65 delete m_pix [ 0 ]; 64 delete m_pix [ 0 ];
66 delete m_pix [ 1 ]; 65 delete m_pix [ 1 ];
67} 66}
68 67
69QSize OLedBox::sizeHint ( ) const 68QSize OLedBox::sizeHint ( ) const
70{ 69{
71 return QSize ( 16, 16 ); 70 return QSize ( 16, 16 );
72} 71}
73 72
74bool OLedBox::isOn ( ) const 73bool OLedBox::isOn ( ) const
75{ 74{
76 return m_on; 75 return m_on;
77} 76}
78 77
79QColor OLedBox::color ( ) const 78QColor OLedBox::color ( ) const
80{ 79{
81 return m_color; 80 return m_color;
82} 81}
83 82
84void OLedBox::setOn ( bool b ) 83void OLedBox::setOn ( bool b )
85{ 84{
86 if ( m_on != b ) { 85 if ( m_on != b ) {
87 m_on = b; 86 m_on = b;
88 update ( ); 87 update ( );
89 } 88 }
90} 89}
91 90
92void OLedBox::toggle ( ) 91void OLedBox::toggle ( )
93{ 92{
94 setOn ( !isOn ( ) ); 93 setOn ( !isOn ( ) );
95} 94}
96 95
97void OLedBox::setColor ( const QColor &col ) 96void OLedBox::setColor ( const QColor &col )
98{ 97{
99 if ( m_color != col ) { 98 if ( m_color != col ) {
100 m_color = col; 99 m_color = col;
101 100
102 delete m_pix [ 0 ]; 101 delete m_pix [ 0 ];
103 delete m_pix [ 1 ]; 102 delete m_pix [ 1 ];
104 103
105 update ( ); 104 update ( );
106 } 105 }
107} 106}
108 107
109void OLedBox::mousePressEvent ( QMouseEvent *e ) 108void OLedBox::mousePressEvent ( QMouseEvent *e )
110{ 109{
111 if ( e-> button ( ) == LeftButton ) { 110 if ( e-> button ( ) == LeftButton ) {
112 m_on = !m_on; 111 m_on = !m_on;
113 update ( ); 112 update ( );
114 emit toggled ( m_on ); 113 emit toggled ( m_on );
115 } 114 }
116} 115}
117 116
118 117
119void OLedBox::resizeEvent ( QResizeEvent * ) 118void OLedBox::resizeEvent ( QResizeEvent * )
120{ 119{
121 delete m_pix [ 0 ]; 120 delete m_pix [ 0 ];
122 delete m_pix [ 1 ]; 121 delete m_pix [ 1 ];
123 122
124 update ( ); 123 update ( );
125} 124}
126 125
127void OLedBox::paintEvent ( QPaintEvent *e ) 126void OLedBox::paintEvent ( QPaintEvent *e )
128{ 127{
129 int ind = m_on ? 1 : 0; 128 int ind = m_on ? 1 : 0;
130 129
131 if ( !m_pix [ ind ] ) { 130 if ( !m_pix [ ind ] ) {
132 m_pix [ ind ] = new QPixmap ( size ( )); 131 m_pix [ ind ] = new QPixmap ( size ( ));
133 132
134 drawLed ( m_pix [ ind ], m_on ? m_color : m_color. dark ( 300 ) ); 133 drawLed ( m_pix [ ind ], m_on ? m_color : m_color. dark ( 300 ) );
135 } 134 }
136 if ( !e-> erased ( )) 135 if ( !e-> erased ( ))
137 erase ( ); 136 erase ( );
138 137
139 QPainter p ( this ); 138 QPainter p ( this );
140 p. drawPixmap ( 0, 0, *m_pix [ ind ] ); 139 p. drawPixmap ( 0, 0, *m_pix [ ind ] );
141} 140}
142 141
143// From KDE libkdeui / led.cpp 142// From KDE libkdeui / led.cpp
144 143
145void OLedBox::drawLed ( QPixmap *pix, const QColor &col ) // paint a ROUND SUNKEN led lamp 144void OLedBox::drawLed ( QPixmap *pix, const QColor &col ) // paint a ROUND SUNKEN led lamp
146{ 145{
147 QPainter paint; 146 QPainter paint;
148 QColor color; 147 QColor color;
149 QBrush brush; 148 QBrush brush;
150 QPen pen; 149 QPen pen;
151 150
152 pix-> fill ( black ); 151 pix-> fill ( black );
153 152
154 // First of all we want to know what area should be updated 153 // First of all we want to know what area should be updated
155 // Initialize coordinates, width, and height of the LED 154 // Initialize coordinates, width, and height of the LED
156 int width = pix-> width ( ); 155 int width = pix-> width ( );
157 156
158 // Make sure the LED is round! 157 // Make sure the LED is round!
159 if ( width > pix-> height ( )) 158 if ( width > pix-> height ( ))
160 width = pix-> height ( ); 159 width = pix-> height ( );
161 width -= 2; // leave one pixel border 160 width -= 2; // leave one pixel border
162 if ( width < 0 ) 161 if ( width < 0 )
163 width = 0; 162 width = 0;
164 163
165 // maybe we could stop HERE, if width <=0 ? 164 // maybe we could stop HERE, if width <=0 ?
166 165
167 // start painting widget 166 // start painting widget
168 // 167 //
169 paint.begin( pix ); 168 paint.begin( pix );
170 169
171 // Set the color of the LED according to given parameters 170 // Set the color of the LED according to given parameters
172 color = col; 171 color = col;
173 172
174 // Set the brush to SolidPattern, this fills the entire area 173 // Set the brush to SolidPattern, this fills the entire area
175 // of the ellipse which is drawn first 174 // of the ellipse which is drawn first
176 brush.setStyle( QBrush::SolidPattern ); 175 brush.setStyle( QBrush::SolidPattern );
177 brush.setColor( color ); 176 brush.setColor( color );
178 paint.setBrush( brush ); // Assign the brush to the painter 177 paint.setBrush( brush ); // Assign the brush to the painter
179 178
180 // Draws a "flat" LED with the given color: 179 // Draws a "flat" LED with the given color:
181 paint.drawEllipse( 1, 1, width, width ); 180 paint.drawEllipse( 1, 1, width, width );
182 181
183 // Draw the bright light spot of the LED now, using modified "old" 182 // Draw the bright light spot of the LED now, using modified "old"
184 // painter routine taken from KDEUIs KLed widget: 183 // painter routine taken from KDEUIs KLed widget:
185 184
186 // Setting the new width of the pen is essential to avoid "pixelized" 185 // Setting the new width of the pen is essential to avoid "pixelized"
187 // shadow like it can be observed with the old LED code 186 // shadow like it can be observed with the old LED code
188 pen.setWidth( 2 ); 187 pen.setWidth( 2 );
189 188
190 // shrink the light on the LED to a size about 2/3 of the complete LED 189 // shrink the light on the LED to a size about 2/3 of the complete LED
191 int pos = width / 5 + 1; 190 int pos = width / 5 + 1;
192 int light_width = width; 191 int light_width = width;
193 light_width *= 2; 192 light_width *= 2;
194 light_width /= 3; 193 light_width /= 3;
195 194
196 // Calculate the LEDs "light factor": 195 // Calculate the LEDs "light factor":
197 int light_quote = ( 130 * 2 / ( light_width ? light_width : 1 ) ) + 100; 196 int light_quote = ( 130 * 2 / ( light_width ? light_width : 1 ) ) + 100;
198 197
199 // Now draw the bright spot on the LED: 198 // Now draw the bright spot on the LED:
200 while ( light_width ) 199 while ( light_width )
201 { 200 {
202 color = color.light( light_quote ); // make color lighter 201 color = color.light( light_quote ); // make color lighter
203 pen.setColor( color ); // set color as pen color 202 pen.setColor( color ); // set color as pen color
204 paint.setPen( pen ); // select the pen for drawing 203 paint.setPen( pen ); // select the pen for drawing
205 paint.drawEllipse( pos, pos, light_width, light_width ); // draw the ellipse (circle) 204 paint.drawEllipse( pos, pos, light_width, light_width ); // draw the ellipse (circle)
206 light_width--; 205 light_width--;
207 if ( !light_width ) 206 if ( !light_width )
208 break; 207 break;
209 paint.drawEllipse( pos, pos, light_width, light_width ); 208 paint.drawEllipse( pos, pos, light_width, light_width );
210 light_width--; 209 light_width--;
211 if ( !light_width ) 210 if ( !light_width )
212 break; 211 break;
213 paint.drawEllipse( pos, pos, light_width, light_width ); 212 paint.drawEllipse( pos, pos, light_width, light_width );
214 pos++; 213 pos++;
215 light_width--; 214 light_width--;
216 } 215 }
217 216
218 // Drawing of bright spot finished, now draw a thin border 217 // Drawing of bright spot finished, now draw a thin border
219 // around the LED which resembles a shadow with light coming 218 // around the LED which resembles a shadow with light coming
220 // from the upper left. 219 // from the upper left.
221 220
222#ifdef _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC 221#ifdef _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC
223 paint. drawPixmap ( 0, 0, *s_border_pix ); 222 paint. drawPixmap ( 0, 0, *s_border_pix );
224 paint. end ( ); 223 paint. end ( );
225 224
226 pix-> setMask ( pix-> createHeuristicMask ( )); 225 pix-> setMask ( pix-> createHeuristicMask ( ));
227 226
228#else 227#else
229 pen.setWidth( 3 ); 228 pen.setWidth( 3 );
230 brush.setStyle( QBrush::NoBrush ); // Switch off the brush 229 brush.setStyle( QBrush::NoBrush ); // Switch off the brush
231 paint.setBrush( brush ); // This avoids filling of the ellipse 230 paint.setBrush( brush ); // This avoids filling of the ellipse
232 231
233 // Set the initial color value to 200 (bright) and start 232 // Set the initial color value to 200 (bright) and start
234 // drawing the shadow border at 45 (45*16 = 720). 233 // drawing the shadow border at 45 (45*16 = 720).
235 int shadow_color = 200, angle; 234 int shadow_color = 200, angle;
236 235
237 for ( angle = 720; angle < 6480; angle += 240 ) 236 for ( angle = 720; angle < 6480; angle += 240 )
238 { 237 {
239 color.setRgb( shadow_color, shadow_color, shadow_color ); 238 color.setRgb( shadow_color, shadow_color, shadow_color );
240 pen.setColor( color ); 239 pen.setColor( color );
241 paint.setPen( pen ); 240 paint.setPen( pen );
242 paint.drawArc( 0, 0, width+2, width+2, angle, 240 ); 241 paint.drawArc( 0, 0, width+2, width+2, angle, 240 );
243 paint.drawArc( 1, 1, width, width, angle, 240 ); 242 paint.drawArc( 1, 1, width, width, angle, 240 );
244 paint.drawArc( 2, 2, width-2, width-2, angle, 240 ); 243 paint.drawArc( 2, 2, width-2, width-2, angle, 240 );
245 if ( angle < 2320 ) { 244 if ( angle < 2320 ) {
246 shadow_color -= 25; // set color to a darker value 245 shadow_color -= 25; // set color to a darker value
247 if ( shadow_color < 100 ) 246 if ( shadow_color < 100 )
248 shadow_color = 100; 247 shadow_color = 100;
249 } 248 }
250 else if ( ( angle > 2320 ) && ( angle < 5760 ) ) { 249 else if ( ( angle > 2320 ) && ( angle < 5760 ) ) {
251 shadow_color += 25; // set color to a brighter value 250 shadow_color += 25; // set color to a brighter value
252 if ( shadow_color > 255 ) 251 if ( shadow_color > 255 )
253 shadow_color = 255; 252 shadow_color = 255;
254 } 253 }
255 else { 254 else {
256 shadow_color -= 25; // set color to a darker value again 255 shadow_color -= 25; // set color to a darker value again
257 if ( shadow_color < 100 ) 256 if ( shadow_color < 100 )
258 shadow_color = 100; 257 shadow_color = 100;
259 } // end if ( angle < 2320 ) 258 } // end if ( angle < 2320 )
260 } // end for ( angle = 720; angle < 6480; angle += 160 ) 259 } // end for ( angle = 720; angle < 6480; angle += 160 )
261 paint.end(); 260 paint.end();
262 // 261 //
263 // painting done 262 // painting done
264 263
265 QBitmap mask ( pix-> width ( ), pix-> height ( ), true ); 264 QBitmap mask ( pix-> width ( ), pix-> height ( ), true );
266 QPainter mp ( &mask ); 265 QPainter mp ( &mask );
267 mp. setPen ( Qt::NoPen ); 266 mp. setPen ( Qt::NoPen );
268 mp. setBrush ( Qt::color1 ); 267 mp. setBrush ( Qt::color1 );
269 mp. drawEllipse ( 0, 0, width + 2, width + 2 ); 268 mp. drawEllipse ( 0, 0, width + 2, width + 2 );
270 mp. end ( ); 269 mp. end ( );
271 270
272 pix-> setMask ( mask ); 271 pix-> setMask ( mask );
273#endif 272#endif
274} 273}
275 274
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp
index 38f827e..c736437 100644
--- a/core/applets/volumeapplet/volume.cpp
+++ b/core/applets/volumeapplet/volume.cpp
@@ -1,783 +1,779 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include <stdio.h> 21#include <stdio.h>
22 22
23#include "volume.h" 23#include "volume.h"
24 24
25#include <qpe/resource.h> 25#include <qpe/resource.h>
26#include <qpe/qpeapplication.h>
27#include <qpe/applnk.h> 26#include <qpe/applnk.h>
28#include <qpe/config.h> 27#include <qpe/config.h>
29#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 28#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
30#include <qpe/qcopenvelope_qws.h> 29#include <qpe/qcopenvelope_qws.h>
31#endif 30#endif
32 31
33#include <qpainter.h> 32#include <qpainter.h>
34#include <qcheckbox.h> 33#include <qcheckbox.h>
35#include <qslider.h> 34#include <qslider.h>
36#include <qlayout.h> 35#include <qlayout.h>
37#include <qframe.h>
38#include <qpixmap.h>
39#include <qvbox.h> 36#include <qvbox.h>
40#include <qlabel.h> 37#include <qlabel.h>
41 38
42#include <qtoolbutton.h>
43#include <qpushbutton.h> 39#include <qpushbutton.h>
44#include <qtimer.h> 40#include <qtimer.h>
45 41
46#include <opie/odevice.h> 42#include <opie/odevice.h>
47 43
48#include "oledbox.h" 44#include "oledbox.h"
49 45
50using namespace Opie; 46using namespace Opie;
51 47
52#define RATE_TIMER_INTERVAL 100 48#define RATE_TIMER_INTERVAL 100
53// Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time 49// Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time
54// results in "hanging" buttons on the iPAQ due to quite high CPU consumption. 50// results in "hanging" buttons on the iPAQ due to quite high CPU consumption.
55 51
56 52
57/* XPM */ 53/* XPM */
58static const char * vol_xpm[] = { 54static const char * vol_xpm[] = {
59"20 20 3 1", 55"20 20 3 1",
60" c None", 56" c None",
61". c #0000FF", 57". c #0000FF",
62"+ c #000000", 58"+ c #000000",
63" ", 59" ",
64" . ", 60" . ",
65" . . . . ", 61" . . . . ",
66" . . . . . . ", 62" . . . . . . ",
67" . . . . . . . ", 63" . . . . . . . ",
68" . . ..... . . ", 64" . . ..... . . ",
69" . ... ..... ... ", 65" . ... ..... ... ",
70" ........... .... ", 66" ........... .... ",
71" ................. ", 67" ................. ",
72"++++++++++++++++++++", 68"++++++++++++++++++++",
73" .................. ", 69" .................. ",
74" . ............. . ", 70" . ............. . ",
75" . ..... ....... ", 71" . ..... ....... ",
76" . ... ..... . ", 72" . ... ..... . ",
77" . ... ..... . ", 73" . ... ..... . ",
78" . ... ..... ", 74" . ... ..... ",
79" . . . . . ", 75" . . . . . ",
80" . . . ", 76" . . . ",
81" . . . ", 77" . . . ",
82" "}; 78" "};
83/* XPM */ 79/* XPM */
84static const char * mic_xpm[] = { 80static const char * mic_xpm[] = {
85"20 20 21 1", 81"20 20 21 1",
86" c None", 82" c None",
87". c #000000", 83". c #000000",
88"+ c #EEEEEE", 84"+ c #EEEEEE",
89"@ c #B4B6B4", 85"@ c #B4B6B4",
90"# c #8B8D8B", 86"# c #8B8D8B",
91"$ c #D5D6D5", 87"$ c #D5D6D5",
92"% c #E6E6E6", 88"% c #E6E6E6",
93"& c #9C9D9C", 89"& c #9C9D9C",
94"* c #6A696A", 90"* c #6A696A",
95"= c #E6E2E6", 91"= c #E6E2E6",
96"- c #F6F2F6", 92"- c #F6F2F6",
97"; c #CDC6CD", 93"; c #CDC6CD",
98"> c #737573", 94"> c #737573",
99", c #4A484A", 95", c #4A484A",
100"' c #DEDEDE", 96"' c #DEDEDE",
101") c #F6EEF6", 97") c #F6EEF6",
102"! c #414041", 98"! c #414041",
103"~ c #202020", 99"~ c #202020",
104"{ c #ACAEAC", 100"{ c #ACAEAC",
105"] c #838583", 101"] c #838583",
106"^ c #6A656A", 102"^ c #6A656A",
107" ", 103" ",
108" .... ", 104" .... ",
109" .+@+#. ", 105" .+@+#. ",
110" ..$%&%*. ", 106" ..$%&%*. ",
111" .=-.;=>=,. ", 107" .=-.;=>=,. ",
112" .'+).&+!+. ", 108" .'+).&+!+. ",
113" .+;+;.~+~. ", 109" .+;+;.~+~. ",
114" ..%{%,.... ", 110" ..%{%,.... ",
115" ..&=>=~.. ", 111" ..&=>=~.. ",
116" .+..]^,.. ", 112" .+..]^,.. ",
117" .+....... ", 113" .+....... ",
118" .%... ", 114" .%... ",
119" .=... ", 115" .=... ",
120" .+... ", 116" .+... ",
121" .+... ", 117" .+... ",
122" .... ", 118" .... ",
123" .... ", 119" .... ",
124" .. ", 120" .. ",
125" . ", 121" . ",
126". "}; 122". "};
127 123
128 124
129static const char * bass_xpm[] = { 125static const char * bass_xpm[] = {
130"20 20 3 1", 126"20 20 3 1",
131" c None", 127" c None",
132". c #000000", 128". c #000000",
133"+ c #0000FF", 129"+ c #0000FF",
134" ", 130" ",
135" ", 131" ",
136" ", 132" ",
137"..... +++ ......", 133"..... +++ ......",
138" +++++++ ", 134" +++++++ ",
139" ++ ++ ", 135" ++ ++ ",
140"... ++ ... ++ ++ .", 136"... ++ ... ++ ++ .",
141" +++ ++ ++ ", 137" +++ ++ ++ ",
142" ++++ ++ ", 138" ++++ ++ ",
143"... ++++ .. ++ .....", 139"... ++++ .. ++ .....",
144" ++ ++ ", 140" ++ ++ ",
145" ++ ++ ", 141" ++ ++ ",
146"..........++ ++ .", 142"..........++ ++ .",
147" ++ ", 143" ++ ",
148" ++ ", 144" ++ ",
149"...... ++ .........", 145"...... ++ .........",
150" + ", 146" + ",
151" ", 147" ",
152" ", 148" ",
153" "}; 149" "};
154 150
155 151
156static const char * treble_xpm[] = { 152static const char * treble_xpm[] = {
157"20 20 3 1", 153"20 20 3 1",
158" c None", 154" c None",
159". c #0000FF", 155". c #0000FF",
160"+ c #000000", 156"+ c #000000",
161" .. ", 157" .. ",
162" . .. ", 158" . .. ",
163" . .. ", 159" . .. ",
164"++++++++ . .. ++++++", 160"++++++++ . .. ++++++",
165" . . ", 161" . . ",
166" ... ", 162" ... ",
167"++++++++ . +++++++", 163"++++++++ . +++++++",
168" .. ", 164" .. ",
169" .. . ", 165" .. . ",
170"+++ .. ... +++++++", 166"+++ .. ... +++++++",
171" .. .. .. ", 167" .. .. .. ",
172" .. . . .. ", 168" .. . . .. ",
173"+++ .. . . + . +++++", 169"+++ .. . . + . +++++",
174" .. . .. ", 170" .. . .. ",
175" .. . .. ", 171" .. . .. ",
176"++++ ...... +++++++", 172"++++ ...... +++++++",
177" . ", 173" . ",
178" .. . ", 174" .. . ",
179" .. . ", 175" .. . ",
180" .. "}; 176" .. "};
181 177
182 178
183 179
184 180
185/* XPM */ 181/* XPM */
186static const char * alarm_xpm[] = { 182static const char * alarm_xpm[] = {
187"20 20 33 1", 183"20 20 33 1",
188" c None", 184" c None",
189". c #080602", 185". c #080602",
190"+ c #AAA602", 186"+ c #AAA602",
191"@ c #252002", 187"@ c #252002",
192"# c #434202", 188"# c #434202",
193"$ c #795602", 189"$ c #795602",
194"% c #C3C20D", 190"% c #C3C20D",
195"& c #DADAC2", 191"& c #DADAC2",
196"* c #826002", 192"* c #826002",
197"= c #740502", 193"= c #740502",
198"- c #D6D602", 194"- c #D6D602",
199"; c #322E02", 195"; c #322E02",
200"> c #826A02", 196"> c #826A02",
201", c #F1F195", 197", c #F1F195",
202"' c #959215", 198"' c #959215",
203") c #423602", 199") c #423602",
204"! c #4B0302", 200"! c #4B0302",
205"~ c #844315", 201"~ c #844315",
206"{ c #AAAA2A", 202"{ c #AAAA2A",
207"] c #E2DE42", 203"] c #E2DE42",
208"^ c #BA7E04", 204"^ c #BA7E04",
209"/ c #7F7502", 205"/ c #7F7502",
210"( c #828276", 206"( c #828276",
211"_ c #FEFE4E", 207"_ c #FEFE4E",
212": c #7D1902", 208": c #7D1902",
213"< c #989656", 209"< c #989656",
214"[ c #260B02", 210"[ c #260B02",
215"} c #F7F7D8", 211"} c #F7F7D8",
216"| c #DCDA5A", 212"| c #DCDA5A",
217"1 c #823102", 213"1 c #823102",
218"2 c #B1AC6B", 214"2 c #B1AC6B",
219"3 c #F7F710", 215"3 c #F7F710",
220"4 c #838204", 216"4 c #838204",
221" ", 217" ",
222" ", 218" ",
223" 4'4/ ", 219" 4'4/ ",
224" /-^= ", 220" /-^= ",
225" 42{4>4 ", 221" 42{4>4 ",
226" '2|+*$44 ", 222" '2|+*$44 ",
227" +2&3+$1*44 ", 223" +2&3+$1*44 ",
228" (%_}_+/$:>/4 ", 224" (%_}_+/$:>/4 ",
229" 4%_}3+#;>:*4 ", 225" 4%_}3+#;>:*4 ",
230" 4%_}&+#[1$/4 ", 226" 4%_}&+#[1$/4 ",
231" 4%_,2')[~~>4 ", 227" 4%_,2')[~~>4 ",
232" 4%33'4#@~1>4 ", 228" 4%33'4#@~1>4 ",
233" 4%3344#[:>/4 ", 229" 4%3344#[:>/4 ",
234" 42&_3'4#@>:*44 ", 230" 42&_3'4#@>:*44 ",
235" 42|}}3'4#[;$)$44 ", 231" 42|}}3'4#[;$)$44 ",
236"444{]]2^~~:!!#.@##/ ", 232"444{]]2^~~:!!#.@##/ ",
237"4444-%*:==!!=...../ ", 233"4444-%*:==!!=...../ ",
238" /:[.. ", 234" /:[.. ",
239" /@. ", 235" /@. ",
240" "}; 236" "};
241 237
242VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name ) 238VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name )
243 : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup ) 239 : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup )
244{ 240{
245 m_icon = icon; 241 m_icon = icon;
246 242
247 bool has_wav_alarm = true; 243 bool has_wav_alarm = true;
248 bool has_bass = true; 244 bool has_bass = true;
249 bool has_treble = true; 245 bool has_treble = true;
250 246
251 switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually 247 switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually
252 case Model_Zaurus_SL5000: 248 case Model_Zaurus_SL5000:
253 has_wav_alarm = false; //poor guys probably feeling left out... 249 has_wav_alarm = false; //poor guys probably feeling left out...
254 break; 250 break;
255 default: 251 default:
256 break; 252 break;
257 } 253 }
258 254
259 if ( !ODevice::inst ( )-> series ( ) == Model_iPAQ ) { 255 if ( !ODevice::inst ( )-> series ( ) == Model_iPAQ ) {
260 has_bass = false; 256 has_bass = false;
261 has_treble = false; 257 has_treble = false;
262 } 258 }
263 259
264 260
265 setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); 261 setFrameStyle ( QFrame::PopupPanel | QFrame::Raised );
266 262
267 QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 ); 263 QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 );
268 grid-> setSpacing ( 4 ); 264 grid-> setSpacing ( 4 );
269 grid-> setMargin ( 6 ); 265 grid-> setMargin ( 6 );
270 266
271 QVBoxLayout *vbox; 267 QVBoxLayout *vbox;
272 QLabel *l; 268 QLabel *l;
273 269
274 vbox = new QVBoxLayout ( ); 270 vbox = new QVBoxLayout ( );
275 vbox-> setSpacing ( 4 ); 271 vbox-> setSpacing ( 4 );
276 grid-> addLayout ( vbox, 1, 0 ); 272 grid-> addLayout ( vbox, 1, 0 );
277 273
278 upButton = new QPushButton ( this ); 274 upButton = new QPushButton ( this );
279 upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); 275 upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding ));
280 upButton-> setPixmap ( Resource::loadPixmap ( "up" )); 276 upButton-> setPixmap ( Resource::loadPixmap ( "up" ));
281 upButton-> setFocusPolicy ( QWidget::NoFocus ); 277 upButton-> setFocusPolicy ( QWidget::NoFocus );
282 278
283 vbox-> addWidget ( upButton ); 279 vbox-> addWidget ( upButton );
284 280
285 downButton = new QPushButton ( this ); 281 downButton = new QPushButton ( this );
286 downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); 282 downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding ));
287 downButton-> setPixmap ( Resource::loadPixmap ( "down" )); 283 downButton-> setPixmap ( Resource::loadPixmap ( "down" ));
288 downButton-> setFocusPolicy ( QWidget::NoFocus ); 284 downButton-> setFocusPolicy ( QWidget::NoFocus );
289 285
290 vbox-> addWidget ( downButton ); 286 vbox-> addWidget ( downButton );
291 287
292 volSlider = new QSlider ( this ); 288 volSlider = new QSlider ( this );
293 volSlider-> setRange ( 0, 100 ); 289 volSlider-> setRange ( 0, 100 );
294 volSlider-> setTickmarks ( QSlider::Both ); 290 volSlider-> setTickmarks ( QSlider::Both );
295 volSlider-> setTickInterval ( 20 ); 291 volSlider-> setTickInterval ( 20 );
296 volSlider-> setFocusPolicy ( QWidget::NoFocus ); 292 volSlider-> setFocusPolicy ( QWidget::NoFocus );
297 293
298 l = new QLabel ( this ); 294 l = new QLabel ( this );
299 l-> setPixmap ( QPixmap ( vol_xpm )); 295 l-> setPixmap ( QPixmap ( vol_xpm ));
300 296
301 grid-> addWidget ( l, 0, 1, AlignCenter ); 297 grid-> addWidget ( l, 0, 1, AlignCenter );
302 grid-> addWidget ( volSlider, 1, 1, AlignCenter ); 298 grid-> addWidget ( volSlider, 1, 1, AlignCenter );
303 299
304 volLed = new OLedBox ( green, this ); 300 volLed = new OLedBox ( green, this );
305 volLed-> setFocusPolicy ( QWidget::NoFocus ); 301 volLed-> setFocusPolicy ( QWidget::NoFocus );
306 volLed-> setFixedSize ( 16, 16 ); 302 volLed-> setFixedSize ( 16, 16 );
307 303
308 grid-> addWidget ( volLed, 2, 1, AlignCenter ); 304 grid-> addWidget ( volLed, 2, 1, AlignCenter );
309 305
310 QVBox *basstrebleBox = new QVBox( this ); 306 QVBox *basstrebleBox = new QVBox( this );
311 307
312 trebleSlider = new QSlider ( basstrebleBox ); 308 trebleSlider = new QSlider ( basstrebleBox );
313 trebleSlider-> setRange ( 0, 100 ); 309 trebleSlider-> setRange ( 0, 100 );
314 trebleSlider-> setTickmarks ( QSlider::Both ); 310 trebleSlider-> setTickmarks ( QSlider::Both );
315 trebleSlider-> setTickInterval ( 20 ); 311 trebleSlider-> setTickInterval ( 20 );
316 trebleSlider->setMaximumHeight( 40 ); 312 trebleSlider->setMaximumHeight( 40 );
317 trebleSlider-> setFocusPolicy ( QWidget::NoFocus ); 313 trebleSlider-> setFocusPolicy ( QWidget::NoFocus );
318 314
319 bassSlider = new QSlider ( basstrebleBox ); 315 bassSlider = new QSlider ( basstrebleBox );
320 bassSlider-> setRange ( 0, 100 ); 316 bassSlider-> setRange ( 0, 100 );
321 bassSlider-> setTickmarks ( QSlider::Both ); 317 bassSlider-> setTickmarks ( QSlider::Both );
322 bassSlider-> setTickInterval ( 20 ); 318 bassSlider-> setTickInterval ( 20 );
323 bassSlider->setMaximumHeight( 40 ); 319 bassSlider->setMaximumHeight( 40 );
324 bassSlider-> setFocusPolicy ( QWidget::NoFocus ); 320 bassSlider-> setFocusPolicy ( QWidget::NoFocus );
325 321
326 QLabel *bassLabel = new QLabel ( this ); 322 QLabel *bassLabel = new QLabel ( this );
327 bassLabel-> setPixmap ( QPixmap ( bass_xpm )); 323 bassLabel-> setPixmap ( QPixmap ( bass_xpm ));
328 324
329 QLabel *trebleLabel = new QLabel( this ); 325 QLabel *trebleLabel = new QLabel( this );
330 trebleLabel->setPixmap( QPixmap ( treble_xpm ) ); 326 trebleLabel->setPixmap( QPixmap ( treble_xpm ) );
331 327
332 grid->addWidget( trebleLabel, 0, 4, AlignCenter ); 328 grid->addWidget( trebleLabel, 0, 4, AlignCenter );
333 grid->addWidget( basstrebleBox, 1, 4, AlignCenter ); 329 grid->addWidget( basstrebleBox, 1, 4, AlignCenter );
334 grid-> addWidget ( bassLabel, 2, 4, AlignCenter ); 330 grid-> addWidget ( bassLabel, 2, 4, AlignCenter );
335 331
336 if ( !has_bass ) { 332 if ( !has_bass ) {
337 bassSlider->hide(); 333 bassSlider->hide();
338 bassLabel->hide(); 334 bassLabel->hide();
339 } 335 }
340 336
341 if ( !has_treble ) { 337 if ( !has_treble ) {
342 trebleSlider->hide(); 338 trebleSlider->hide();
343 trebleLabel->hide(); 339 trebleLabel->hide();
344 } 340 }
345 341
346 micSlider = new QSlider ( this ); 342 micSlider = new QSlider ( this );
347 micSlider-> setRange ( 0, 100 ); 343 micSlider-> setRange ( 0, 100 );
348 micSlider-> setTickmarks ( QSlider::Both ); 344 micSlider-> setTickmarks ( QSlider::Both );
349 micSlider-> setTickInterval ( 20 ); 345 micSlider-> setTickInterval ( 20 );
350 micSlider-> setFocusPolicy ( QWidget::NoFocus ); 346 micSlider-> setFocusPolicy ( QWidget::NoFocus );
351 347
352 l = new QLabel ( this ); 348 l = new QLabel ( this );
353 l-> setPixmap ( QPixmap ( mic_xpm )); 349 l-> setPixmap ( QPixmap ( mic_xpm ));
354 350
355 grid-> addWidget ( l, 0, 2, AlignCenter ); 351 grid-> addWidget ( l, 0, 2, AlignCenter );
356 grid-> addWidget ( micSlider, 1, 2, AlignCenter ); 352 grid-> addWidget ( micSlider, 1, 2, AlignCenter );
357 353
358 micLed = new OLedBox ( red, this ); 354 micLed = new OLedBox ( red, this );
359 micLed-> setFocusPolicy ( QWidget::NoFocus ); 355 micLed-> setFocusPolicy ( QWidget::NoFocus );
360 micLed-> setFixedSize ( 16, 16 ); 356 micLed-> setFixedSize ( 16, 16 );
361 357
362 grid-> addWidget ( micLed, 2, 2, AlignCenter ); 358 grid-> addWidget ( micLed, 2, 2, AlignCenter );
363 359
364 alarmSlider = new QSlider ( this ); 360 alarmSlider = new QSlider ( this );
365 alarmSlider-> setRange ( 0, 100 ); 361 alarmSlider-> setRange ( 0, 100 );
366 alarmSlider-> setTickmarks ( QSlider::Both ); 362 alarmSlider-> setTickmarks ( QSlider::Both );
367 alarmSlider-> setTickInterval ( 20 ); 363 alarmSlider-> setTickInterval ( 20 );
368 alarmSlider-> setFocusPolicy ( QWidget::NoFocus ); 364 alarmSlider-> setFocusPolicy ( QWidget::NoFocus );
369 365
370 QLabel *alarmLabel = new QLabel ( this ); 366 QLabel *alarmLabel = new QLabel ( this );
371 alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); 367 alarmLabel-> setPixmap ( QPixmap ( alarm_xpm ));
372 368
373 grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); 369 grid-> addWidget ( alarmLabel, 0, 3, AlignCenter );
374 grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); 370 grid-> addWidget ( alarmSlider, 1, 3, AlignCenter );
375 371
376 alarmLed = new OLedBox ( yellow, this ); 372 alarmLed = new OLedBox ( yellow, this );
377 alarmLed-> setFocusPolicy ( QWidget::NoFocus ); 373 alarmLed-> setFocusPolicy ( QWidget::NoFocus );
378 alarmLed-> setFixedSize ( 16, 16 ); 374 alarmLed-> setFixedSize ( 16, 16 );
379 375
380 grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); 376 grid-> addWidget ( alarmLed, 2, 3, AlignCenter );
381 377
382 if ( !has_wav_alarm ) { 378 if ( !has_wav_alarm ) {
383 alarmSlider-> hide ( ); 379 alarmSlider-> hide ( );
384 alarmLabel-> hide ( ); 380 alarmLabel-> hide ( );
385 alarmLed-> hide ( ); 381 alarmLed-> hide ( );
386 } 382 }
387 383
388 grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 6, AlignVCenter | AlignLeft ); 384 grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 6, AlignVCenter | AlignLeft );
389 385
390 vbox = new QVBoxLayout ( ); 386 vbox = new QVBoxLayout ( );
391 vbox-> setSpacing ( 4 ); 387 vbox-> setSpacing ( 4 );
392 grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 ); 388 grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 );
393 389
394 tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); 390 tapBox = new QCheckBox ( tr( "Screen Taps" ), this );
395 tapBox-> setFocusPolicy ( QWidget::NoFocus ); 391 tapBox-> setFocusPolicy ( QWidget::NoFocus );
396 392
397 vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft ); 393 vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft );
398 394
399 keyBox = new QCheckBox ( tr( "Key Clicks" ), this ); 395 keyBox = new QCheckBox ( tr( "Key Clicks" ), this );
400 keyBox-> setFocusPolicy ( QWidget::NoFocus ); 396 keyBox-> setFocusPolicy ( QWidget::NoFocus );
401 397
402 vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft ); 398 vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft );
403 399
404 alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this ); 400 alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this );
405 alarmBox-> setFocusPolicy ( QWidget::NoFocus ); 401 alarmBox-> setFocusPolicy ( QWidget::NoFocus );
406 402
407 vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft ); 403 vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft );
408 404
409 if ( has_wav_alarm ) { 405 if ( has_wav_alarm ) {
410 alarmBox-> hide ( ); 406 alarmBox-> hide ( );
411 } 407 }
412 408
413 vbox-> addStretch ( 100 ); 409 vbox-> addStretch ( 100 );
414 410
415 setFixedSize ( sizeHint ( )); 411 setFixedSize ( sizeHint ( ));
416 setFocusPolicy ( QWidget::NoFocus ); 412 setFocusPolicy ( QWidget::NoFocus );
417 413
418 rateTimer = new QTimer( this ); 414 rateTimer = new QTimer( this );
419 connect ( rateTimer, SIGNAL( timeout ( )), this, SLOT( rateTimerDone ( ))); 415 connect ( rateTimer, SIGNAL( timeout ( )), this, SLOT( rateTimerDone ( )));
420 416
421 connect ( upButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); 417 connect ( upButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( )));
422 connect ( upButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); 418 connect ( upButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( )));
423 connect ( downButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); 419 connect ( downButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( )));
424 connect ( downButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); 420 connect ( downButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( )));
425 421
426 connect ( micSlider, SIGNAL( valueChanged ( int )), this, SLOT( micMoved( int ))); 422 connect ( micSlider, SIGNAL( valueChanged ( int )), this, SLOT( micMoved( int )));
427 connect ( volSlider, SIGNAL( valueChanged ( int )), this, SLOT( volMoved( int ))); 423 connect ( volSlider, SIGNAL( valueChanged ( int )), this, SLOT( volMoved( int )));
428 connect ( alarmSlider, SIGNAL( valueChanged ( int )), this, SLOT( alarmMoved( int ))); 424 connect ( alarmSlider, SIGNAL( valueChanged ( int )), this, SLOT( alarmMoved( int )));
429 connect ( bassSlider, SIGNAL( valueChanged ( int )), this, SLOT( bassMoved( int ))); 425 connect ( bassSlider, SIGNAL( valueChanged ( int )), this, SLOT( bassMoved( int )));
430 connect ( trebleSlider, SIGNAL( valueChanged ( int )), this, SLOT( trebleMoved( int ))); 426 connect ( trebleSlider, SIGNAL( valueChanged ( int )), this, SLOT( trebleMoved( int )));
431 427
432 428
433 connect ( volLed, SIGNAL( toggled ( bool )), this, SLOT( volMuteToggled ( bool ))); 429 connect ( volLed, SIGNAL( toggled ( bool )), this, SLOT( volMuteToggled ( bool )));
434 connect ( micLed, SIGNAL( toggled ( bool )), this, SLOT( micMuteToggled ( bool ))); 430 connect ( micLed, SIGNAL( toggled ( bool )), this, SLOT( micMuteToggled ( bool )));
435 connect ( alarmLed, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); 431 connect ( alarmLed, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool )));
436 432
437 connect ( alarmBox, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); 433 connect ( alarmBox, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool )));
438 connect ( keyBox, SIGNAL( toggled ( bool )), this, SLOT( keyClickToggled ( bool ))); 434 connect ( keyBox, SIGNAL( toggled ( bool )), this, SLOT( keyClickToggled ( bool )));
439 connect ( tapBox, SIGNAL( toggled ( bool )), this, SLOT( screenTapToggled ( bool ))); 435 connect ( tapBox, SIGNAL( toggled ( bool )), this, SLOT( screenTapToggled ( bool )));
440 436
441 // initialize variables 437 // initialize variables
442 438
443 readConfig ( true ); 439 readConfig ( true );
444 440
445 // initialize the config file, in case some entries are missing 441 // initialize the config file, in case some entries are missing
446 442
447 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); 443 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None );
448 writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None ); 444 writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None );
449 writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None ); 445 writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None );
450 writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); 446 writeConfigEntry ( "Mute", m_vol_muted, UPD_None );
451 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); 447 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None );
452 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); 448 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None );
453 writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); 449 writeConfigEntry ( "KeySound", m_snd_key, UPD_None );
454 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); 450 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol );
455 451
456 writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); 452 writeConfigEntry ( "Mic", m_mic_percent, UPD_None );
457 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); 453 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic );
458} 454}
459 455
460bool VolumeControl::volMuted ( ) const 456bool VolumeControl::volMuted ( ) const
461{ 457{
462 return m_vol_muted; 458 return m_vol_muted;
463} 459}
464 460
465int VolumeControl::volPercent ( ) const 461int VolumeControl::volPercent ( ) const
466{ 462{
467 return m_vol_percent; 463 return m_vol_percent;
468} 464}
469 465
470void VolumeControl::keyPressEvent ( QKeyEvent *e ) 466void VolumeControl::keyPressEvent ( QKeyEvent *e )
471{ 467{
472 switch ( e-> key ( )) { 468 switch ( e-> key ( )) {
473 case Key_Up: 469 case Key_Up:
474 volSlider-> subtractStep ( ); 470 volSlider-> subtractStep ( );
475 break; 471 break;
476 case Key_Down: 472 case Key_Down:
477 volSlider-> addStep ( ); 473 volSlider-> addStep ( );
478 break; 474 break;
479 case Key_Space: 475 case Key_Space:
480 volLed-> toggle ( ); 476 volLed-> toggle ( );
481 break; 477 break;
482 case Key_Escape: 478 case Key_Escape:
483 hide ( ); 479 hide ( );
484 break; 480 break;
485 } 481 }
486} 482}
487 483
488void VolumeControl::buttonChanged ( ) 484void VolumeControl::buttonChanged ( )
489{ 485{
490 if ( upButton-> isDown ( ) || downButton->isDown ( )) { 486 if ( upButton-> isDown ( ) || downButton->isDown ( )) {
491 rateTimerDone ( ); // Call it one time manually, otherwise it wont get 487 rateTimerDone ( ); // Call it one time manually, otherwise it wont get
492 // called at all when a button is pressed for a time 488 // called at all when a button is pressed for a time
493 // shorter than RATE_TIMER_INTERVAL. 489 // shorter than RATE_TIMER_INTERVAL.
494 rateTimer-> start ( RATE_TIMER_INTERVAL, false ); 490 rateTimer-> start ( RATE_TIMER_INTERVAL, false );
495 } 491 }
496 else 492 else
497 rateTimer-> stop ( ); 493 rateTimer-> stop ( );
498} 494}
499 495
500void VolumeControl::rateTimerDone ( ) 496void VolumeControl::rateTimerDone ( )
501{ 497{
502 if ( upButton-> isDown ( )) 498 if ( upButton-> isDown ( ))
503 volSlider-> setValue ( volSlider-> value ( ) - 2 ); 499 volSlider-> setValue ( volSlider-> value ( ) - 2 );
504 else // if ( downButton-> isDown ( )) 500 else // if ( downButton-> isDown ( ))
505 volSlider-> setValue ( volSlider-> value ( ) + 2 ); 501 volSlider-> setValue ( volSlider-> value ( ) + 2 );
506} 502}
507 503
508void VolumeControl::show ( bool /*showMic*/ ) 504void VolumeControl::show ( bool /*showMic*/ )
509{ 505{
510 readConfig ( ); 506 readConfig ( );
511 507
512 QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); 508 QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 ));
513 509
514 int w = sizeHint ( ). width ( ); 510 int w = sizeHint ( ). width ( );
515 int x = curPos.x ( ) - ( w / 2 ); 511 int x = curPos.x ( ) - ( w / 2 );
516 512
517 if (( x + w ) > QPEApplication::desktop ( )-> width ( )) 513 if (( x + w ) > QPEApplication::desktop ( )-> width ( ))
518 x = QPEApplication::desktop ( )-> width ( ) - w; 514 x = QPEApplication::desktop ( )-> width ( ) - w;
519 515
520 move ( x, curPos. y ( ) - sizeHint ( ). height ( )); 516 move ( x, curPos. y ( ) - sizeHint ( ). height ( ));
521 QFrame::show ( ); 517 QFrame::show ( );
522 518
523} 519}
524 520
525void VolumeControl::readConfig ( bool force ) 521void VolumeControl::readConfig ( bool force )
526{ 522{
527 Config cfg ( "qpe" ); 523 Config cfg ( "qpe" );
528 cfg. setGroup ( "Volume" ); 524 cfg. setGroup ( "Volume" );
529 525
530 int old_vp = m_vol_percent; 526 int old_vp = m_vol_percent;
531 int old_mp = m_mic_percent; 527 int old_mp = m_mic_percent;
532 int old_bass = m_bass_percent; 528 int old_bass = m_bass_percent;
533 int old_treble = m_treble_percent; 529 int old_treble = m_treble_percent;
534 bool old_vm = m_vol_muted; 530 bool old_vm = m_vol_muted;
535 bool old_mm = m_mic_muted; 531 bool old_mm = m_mic_muted;
536 bool old_sk = m_snd_key; 532 bool old_sk = m_snd_key;
537 bool old_st = m_snd_touch; 533 bool old_st = m_snd_touch;
538 bool old_sa = m_snd_alarm; 534 bool old_sa = m_snd_alarm;
539 int old_ap = m_alarm_percent; 535 int old_ap = m_alarm_percent;
540 536
541 m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 ); 537 m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 );
542 m_mic_percent = cfg. readNumEntry ( "Mic", 50 ); 538 m_mic_percent = cfg. readNumEntry ( "Mic", 50 );
543 m_bass_percent = cfg. readNumEntry ( "BassPercent", 50 ); 539 m_bass_percent = cfg. readNumEntry ( "BassPercent", 50 );
544 m_treble_percent = cfg. readNumEntry ( "TreblePercent", 50 ); 540 m_treble_percent = cfg. readNumEntry ( "TreblePercent", 50 );
545 m_vol_muted = cfg. readBoolEntry ( "Mute", 0 ); 541 m_vol_muted = cfg. readBoolEntry ( "Mute", 0 );
546 m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 ); 542 m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 );
547 m_snd_key = cfg. readBoolEntry ( "KeySound", 0 ); 543 m_snd_key = cfg. readBoolEntry ( "KeySound", 0 );
548 m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 ); 544 m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 );
549 m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 ); 545 m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 );
550 m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 ); 546 m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 );
551 547
552 if ( force || ( m_vol_percent != old_vp )) 548 if ( force || ( m_vol_percent != old_vp ))
553 volSlider-> setValue ( 100 - m_vol_percent ); 549 volSlider-> setValue ( 100 - m_vol_percent );
554 if ( force || ( m_mic_percent != old_mp )) 550 if ( force || ( m_mic_percent != old_mp ))
555 micSlider-> setValue ( 100 - m_mic_percent ); 551 micSlider-> setValue ( 100 - m_mic_percent );
556 if ( force || ( m_alarm_percent != old_ap )) 552 if ( force || ( m_alarm_percent != old_ap ))
557 alarmSlider-> setValue ( 100 - m_alarm_percent ); 553 alarmSlider-> setValue ( 100 - m_alarm_percent );
558 if ( force || ( m_bass_percent != old_bass )) 554 if ( force || ( m_bass_percent != old_bass ))
559 bassSlider-> setValue ( 100 - m_bass_percent ); 555 bassSlider-> setValue ( 100 - m_bass_percent );
560 if ( force || ( m_treble_percent != old_treble )) 556 if ( force || ( m_treble_percent != old_treble ))
561 trebleSlider-> setValue ( 100 - m_treble_percent ); 557 trebleSlider-> setValue ( 100 - m_treble_percent );
562 558
563 559
564 if ( force || ( m_vol_muted != old_vm )) 560 if ( force || ( m_vol_muted != old_vm ))
565 volLed-> setOn ( !m_vol_muted ); 561 volLed-> setOn ( !m_vol_muted );
566 if ( force || ( m_mic_muted != old_mm )) 562 if ( force || ( m_mic_muted != old_mm ))
567 micLed-> setOn ( !m_mic_muted ); 563 micLed-> setOn ( !m_mic_muted );
568 if ( force || ( m_snd_alarm != old_sa )) 564 if ( force || ( m_snd_alarm != old_sa ))
569 alarmLed-> setOn ( m_snd_alarm ); 565 alarmLed-> setOn ( m_snd_alarm );
570 566
571 if ( force || ( m_snd_key != old_sk )) 567 if ( force || ( m_snd_key != old_sk ))
572 keyBox-> setChecked ( m_snd_key ); 568 keyBox-> setChecked ( m_snd_key );
573 if ( force || ( m_snd_touch != old_st )) 569 if ( force || ( m_snd_touch != old_st ))
574 tapBox-> setChecked ( m_snd_touch ); 570 tapBox-> setChecked ( m_snd_touch );
575 if ( force || ( m_snd_alarm != old_sa )) 571 if ( force || ( m_snd_alarm != old_sa ))
576 alarmBox-> setChecked ( m_snd_alarm ); 572 alarmBox-> setChecked ( m_snd_alarm );
577} 573}
578 574
579 575
580void VolumeControl::volumeChanged ( bool /*nowMuted*/ ) 576void VolumeControl::volumeChanged ( bool /*nowMuted*/ )
581{ 577{
582 int prevVol = m_vol_percent; 578 int prevVol = m_vol_percent;
583 bool prevMute = m_vol_muted; 579 bool prevMute = m_vol_muted;
584 580
585 readConfig ( ); 581 readConfig ( );
586 582
587 // Handle case where muting it toggled 583 // Handle case where muting it toggled
588 if ( m_vol_muted != prevMute ) 584 if ( m_vol_muted != prevMute )
589 m_icon-> redraw ( true ); 585 m_icon-> redraw ( true );
590 else if ( prevVol != m_vol_percent ) // Avoid over repainting 586 else if ( prevVol != m_vol_percent ) // Avoid over repainting
591 m_icon-> redraw ( false ); 587 m_icon-> redraw ( false );
592} 588}
593 589
594void VolumeControl::micChanged ( bool nowMuted ) 590void VolumeControl::micChanged ( bool nowMuted )
595{ 591{
596 if ( !nowMuted ) 592 if ( !nowMuted )
597 readConfig ( ); 593 readConfig ( );
598 m_mic_muted = nowMuted; 594 m_mic_muted = nowMuted;
599} 595}
600 596
601void VolumeControl::screenTapToggled ( bool b ) 597void VolumeControl::screenTapToggled ( bool b )
602{ 598{
603 m_snd_touch = b; 599 m_snd_touch = b;
604 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol ); 600 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol );
605} 601}
606 602
607void VolumeControl::keyClickToggled ( bool b ) 603void VolumeControl::keyClickToggled ( bool b )
608{ 604{
609 m_snd_key = b; 605 m_snd_key = b;
610 writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol ); 606 writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol );
611} 607}
612 608
613void VolumeControl::alarmSoundToggled ( bool b ) 609void VolumeControl::alarmSoundToggled ( bool b )
614{ 610{
615 m_snd_alarm = b; 611 m_snd_alarm = b;
616 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); 612 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol );
617} 613}
618 614
619void VolumeControl::volMuteToggled ( bool b ) 615void VolumeControl::volMuteToggled ( bool b )
620{ 616{
621 m_vol_muted = !b; 617 m_vol_muted = !b;
622 618
623 m_icon-> redraw ( true ); 619 m_icon-> redraw ( true );
624 620
625 writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); 621 writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol );
626} 622}
627 623
628void VolumeControl::micMuteToggled ( bool b ) 624void VolumeControl::micMuteToggled ( bool b )
629{ 625{
630 m_mic_muted = !b; 626 m_mic_muted = !b;
631 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); 627 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic );
632} 628}
633 629
634 630
635void VolumeControl::volMoved ( int percent ) 631void VolumeControl::volMoved ( int percent )
636{ 632{
637 m_vol_percent = 100 - percent; 633 m_vol_percent = 100 - percent;
638 634
639 // clamp volume percent to be between 0 and 100 635 // clamp volume percent to be between 0 and 100
640 m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent ); 636 m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent );
641 // repaint just the little volume rectangle 637 // repaint just the little volume rectangle
642 m_icon-> redraw ( false ); 638 m_icon-> redraw ( false );
643 639
644 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); 640 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol );
645} 641}
646 642
647void VolumeControl::micMoved ( int percent ) 643void VolumeControl::micMoved ( int percent )
648{ 644{
649 m_mic_percent = 100 - percent; 645 m_mic_percent = 100 - percent;
650 646
651 // clamp volume percent to be between 0 and 100 647 // clamp volume percent to be between 0 and 100
652 m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent ); 648 m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent );
653 649
654 writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic ); 650 writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic );
655} 651}
656 652
657void VolumeControl::alarmMoved ( int percent ) 653void VolumeControl::alarmMoved ( int percent )
658{ 654{
659 m_alarm_percent = 100 - percent; 655 m_alarm_percent = 100 - percent;
660 656
661 // clamp volume percent to be between 0 and 100 657 // clamp volume percent to be between 0 and 100
662 m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent ); 658 m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent );
663 659
664 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); 660 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None );
665} 661}
666 662
667 663
668void VolumeControl::bassMoved ( int percent ) 664void VolumeControl::bassMoved ( int percent )
669{ 665{
670 m_bass_percent = 100 - percent; 666 m_bass_percent = 100 - percent;
671 667
672 // clamp bass percent to be between 0 and 100 668 // clamp bass percent to be between 0 and 100
673 m_bass_percent = ( m_bass_percent < 0 ) ? 0 : (( m_bass_percent > 100 ) ? 100 : m_bass_percent ); 669 m_bass_percent = ( m_bass_percent < 0 ) ? 0 : (( m_bass_percent > 100 ) ? 100 : m_bass_percent );
674 670
675 writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass ); 671 writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass );
676} 672}
677 673
678 674
679 675
680void VolumeControl::trebleMoved ( int percent ) 676void VolumeControl::trebleMoved ( int percent )
681{ 677{
682 m_treble_percent = 100 - percent; 678 m_treble_percent = 100 - percent;
683 679
684 // clamp treble percent to be between 0 and 100 680 // clamp treble percent to be between 0 and 100
685 m_treble_percent = ( m_treble_percent < 0 ) ? 0 : (( m_treble_percent > 100 ) ? 100 : m_treble_percent ); 681 m_treble_percent = ( m_treble_percent < 0 ) ? 0 : (( m_treble_percent > 100 ) ? 100 : m_treble_percent );
686 682
687 writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble ); 683 writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble );
688} 684}
689 685
690 686
691 687
692void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) 688void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd )
693{ 689{
694 Config cfg ( "qpe" ); 690 Config cfg ( "qpe" );
695 cfg. setGroup ( "Volume" ); 691 cfg. setGroup ( "Volume" );
696 cfg. writeEntry ( entry, val ); 692 cfg. writeEntry ( entry, val );
697// cfg. write ( ); 693// cfg. write ( );
698 694
699#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 695#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
700 switch ( upd ) { 696 switch ( upd ) {
701 case UPD_Vol: { 697 case UPD_Vol: {
702 QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; 698 QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted;
703 break; 699 break;
704 } 700 }
705 case UPD_Mic: { 701 case UPD_Mic: {
706 QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; 702 QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted;
707 break; 703 break;
708 } 704 }
709 case UPD_Bass: { 705 case UPD_Bass: {
710 QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true; 706 QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true;
711 break; 707 break;
712 } 708 }
713 case UPD_Treble: { 709 case UPD_Treble: {
714 QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true; 710 QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true;
715 break; 711 break;
716 } 712 }
717 713
718 case UPD_None: 714 case UPD_None:
719 break; 715 break;
720 } 716 }
721#endif 717#endif
722} 718}
723 719
724//=========================================================================== 720//===========================================================================
725 721
726VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) 722VolumeApplet::VolumeApplet( QWidget *parent, const char *name )
727 : QWidget( parent, name ) 723 : QWidget( parent, name )
728{ 724{
729 setFixedWidth ( AppLnk::smallIconSize() ); 725 setFixedWidth ( AppLnk::smallIconSize() );
730 setFixedHeight ( AppLnk::smallIconSize()+4 ); 726 setFixedHeight ( AppLnk::smallIconSize()+4 );
731 727
732 m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" )); 728 m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" ));
733 m_dialog = new VolumeControl ( this, true, this, "volumecontrol" ); 729 m_dialog = new VolumeControl ( this, true, this, "volumecontrol" );
734 730
735 connect ( qApp, SIGNAL( volumeChanged ( bool )), m_dialog, SLOT( volumeChanged( bool ))); 731 connect ( qApp, SIGNAL( volumeChanged ( bool )), m_dialog, SLOT( volumeChanged( bool )));
736 connect ( qApp, SIGNAL( micChanged ( bool )), m_dialog, SLOT ( micChanged( bool ))); 732 connect ( qApp, SIGNAL( micChanged ( bool )), m_dialog, SLOT ( micChanged( bool )));
737} 733}
738 734
739VolumeApplet::~VolumeApplet() 735VolumeApplet::~VolumeApplet()
740{ 736{
741 delete m_pixmap; 737 delete m_pixmap;
742} 738}
743 739
744 740
745void VolumeApplet::mousePressEvent ( QMouseEvent * ) 741void VolumeApplet::mousePressEvent ( QMouseEvent * )
746{ 742{
747 if ( m_dialog-> isVisible ( )) 743 if ( m_dialog-> isVisible ( ))
748 m_dialog-> hide ( ); 744 m_dialog-> hide ( );
749 else 745 else
750 m_dialog-> show ( true ); 746 m_dialog-> show ( true );
751} 747}
752 748
753void VolumeApplet::redraw ( bool all ) 749void VolumeApplet::redraw ( bool all )
754{ 750{
755 if ( all ) 751 if ( all )
756 repaint ( true ); 752 repaint ( true );
757 else 753 else
758 repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); 754 repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false );
759} 755}
760 756
761 757
762void VolumeApplet::paintEvent ( QPaintEvent * ) 758void VolumeApplet::paintEvent ( QPaintEvent * )
763{ 759{
764 QPainter p ( this ); 760 QPainter p ( this );
765 761
766 p. drawPixmap ( (width()- m_pixmap->width())/2, QMAX( (height()-4-m_pixmap->height() )/2, 1), *m_pixmap ); 762 p. drawPixmap ( (width()- m_pixmap->width())/2, QMAX( (height()-4-m_pixmap->height() )/2, 1), *m_pixmap );
767 p. setPen ( darkGray ); 763 p. setPen ( darkGray );
768 p. drawRect ( 1, height() - 4, width() - 2, 4 ); 764 p. drawRect ( 1, height() - 4, width() - 2, 4 );
769 765
770 int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100; 766 int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100;
771 p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); 767 p. fillRect ( 2, height() - 3, pixelsWide, 2, red );
772 p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); 768 p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray );
773 769
774 if ( m_dialog-> volMuted ( )) { 770 if ( m_dialog-> volMuted ( )) {
775 p. setPen ( red ); 771 p. setPen ( red );
776 p. drawLine ( 1, 2, width() - 2, height() - 5 ); 772 p. drawLine ( 1, 2, width() - 2, height() - 5 );
777 p. drawLine ( 1, 3, width() - 2, height() - 4 ); 773 p. drawLine ( 1, 3, width() - 2, height() - 4 );
778 p. drawLine ( width() - 2, 2, 1, height() - 5 ); 774 p. drawLine ( width() - 2, 2, 1, height() - 5 );
779 p. drawLine ( width() - 2, 3, 1, height() - 4 ); 775 p. drawLine ( width() - 2, 3, 1, height() - 4 );
780 } 776 }
781} 777}
782 778
783 779
diff --git a/core/applets/volumeapplet/volumeappletimpl.cpp b/core/applets/volumeapplet/volumeappletimpl.cpp
index 4cbab31..9c7dea3 100644
--- a/core/applets/volumeapplet/volumeappletimpl.cpp
+++ b/core/applets/volumeapplet/volumeappletimpl.cpp
@@ -1,67 +1,65 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "volume.h" 20#include "volume.h"
21#include "volumeappletimpl.h" 21#include "volumeappletimpl.h"
22#include <qpe/qcopenvelope_qws.h>
23#include <qpe/config.h>
24 22
25VolumeAppletImpl::VolumeAppletImpl() 23VolumeAppletImpl::VolumeAppletImpl()
26 : volume(0) 24 : volume(0)
27{ 25{
28} 26}
29 27
30VolumeAppletImpl::~VolumeAppletImpl() 28VolumeAppletImpl::~VolumeAppletImpl()
31{ 29{
32 delete volume; 30 delete volume;
33} 31}
34 32
35QWidget *VolumeAppletImpl::applet( QWidget *parent ) 33QWidget *VolumeAppletImpl::applet( QWidget *parent )
36{ 34{
37 if ( !volume ) 35 if ( !volume )
38 volume = new VolumeApplet( parent ); 36 volume = new VolumeApplet( parent );
39 return volume; 37 return volume;
40} 38}
41 39
42int VolumeAppletImpl::position() const 40int VolumeAppletImpl::position() const
43{ 41{
44 return 6; 42 return 6;
45} 43}
46 44
47QRESULT VolumeAppletImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) 45QRESULT VolumeAppletImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
48{ 46{
49 *iface = 0; 47 *iface = 0;
50 if ( uuid == IID_QUnknown ) 48 if ( uuid == IID_QUnknown )
51 *iface = this; 49 *iface = this;
52 else if ( uuid == IID_TaskbarApplet ) 50 else if ( uuid == IID_TaskbarApplet )
53 *iface = this; 51 *iface = this;
54 else 52 else
55 return QS_FALSE; 53 return QS_FALSE;
56 54
57 if ( *iface ) 55 if ( *iface )
58 (*iface)->addRef(); 56 (*iface)->addRef();
59 return QS_OK; 57 return QS_OK;
60} 58}
61 59
62Q_EXPORT_INTERFACE() 60Q_EXPORT_INTERFACE()
63{ 61{
64 Q_CREATE_INSTANCE( VolumeAppletImpl ) 62 Q_CREATE_INSTANCE( VolumeAppletImpl )
65} 63}
66 64
67 65
diff --git a/core/applets/vtapplet/vt.cpp b/core/applets/vtapplet/vt.cpp
index 881eb41..bd39093 100644
--- a/core/applets/vtapplet/vt.cpp
+++ b/core/applets/vtapplet/vt.cpp
@@ -1,164 +1,161 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** Contact me @ mickeyl@handhelds.org 4** Contact me @ mickeyl@handhelds.org
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#include <qpe/resource.h> 16#include <qpe/resource.h>
17#include <qpe/qcopenvelope_qws.h>
18 17
19#include <qapplication.h>
20#include <qiconset.h>
21#include <qpopupmenu.h> 18#include <qpopupmenu.h>
22 19
23#include <fcntl.h> 20#include <fcntl.h>
24#include <unistd.h> 21#include <unistd.h>
25#include <sys/types.h> 22#include <sys/types.h>
26#include <sys/stat.h> 23#include <sys/stat.h>
27#include <sys/ioctl.h> 24#include <sys/ioctl.h>
28#include <linux/vt.h> 25#include <linux/vt.h>
29 26
30#include "vt.h" 27#include "vt.h"
31 28
32VTApplet::VTApplet ( ) 29VTApplet::VTApplet ( )
33 : QObject ( 0, "VTApplet" ) 30 : QObject ( 0, "VTApplet" )
34{ 31{
35} 32}
36 33
37VTApplet::~VTApplet ( ) 34VTApplet::~VTApplet ( )
38{ 35{
39} 36}
40 37
41int VTApplet::position ( ) const 38int VTApplet::position ( ) const
42{ 39{
43 return 2; 40 return 2;
44} 41}
45 42
46QString VTApplet::name ( ) const 43QString VTApplet::name ( ) const
47{ 44{
48 return tr( "VT shortcut" ); 45 return tr( "VT shortcut" );
49} 46}
50 47
51QString VTApplet::text ( ) const 48QString VTApplet::text ( ) const
52{ 49{
53 return tr( "Terminal" ); 50 return tr( "Terminal" );
54} 51}
55 52
56/* 53/*
57QString VTApplet::tr( const char* s ) const 54QString VTApplet::tr( const char* s ) const
58{ 55{
59 return qApp->translate( "VTApplet", s, 0 ); 56 return qApp->translate( "VTApplet", s, 0 );
60} 57}
61 58
62QString VTApplet::tr( const char* s, const char* p ) const 59QString VTApplet::tr( const char* s, const char* p ) const
63{ 60{
64 return qApp->translate( "VTApplet", s, p ); 61 return qApp->translate( "VTApplet", s, p );
65} 62}
66*/ 63*/
67 64
68QIconSet VTApplet::icon ( ) const 65QIconSet VTApplet::icon ( ) const
69{ 66{
70 QPixmap pix; 67 QPixmap pix;
71 QImage img = Resource::loadImage ( "terminal" ); 68 QImage img = Resource::loadImage ( "terminal" );
72 69
73 if ( !img. isNull ( )) 70 if ( !img. isNull ( ))
74 pix. convertFromImage ( img. smoothScale ( 14, 14 )); 71 pix. convertFromImage ( img. smoothScale ( 14, 14 ));
75 return pix; 72 return pix;
76} 73}
77 74
78QPopupMenu *VTApplet::popup ( QWidget* parent ) const 75QPopupMenu *VTApplet::popup ( QWidget* parent ) const
79{ 76{
80 qDebug( "VTApplet::popup" ); 77 qDebug( "VTApplet::popup" );
81 78
82 struct vt_stat vtstat; 79 struct vt_stat vtstat;
83 int fd = ::open( "/dev/tty0", O_RDWR ); 80 int fd = ::open( "/dev/tty0", O_RDWR );
84 if ( fd == -1 ) return 0; 81 if ( fd == -1 ) return 0;
85 if ( ioctl( fd, VT_GETSTATE, &vtstat ) == -1 ) return 0; 82 if ( ioctl( fd, VT_GETSTATE, &vtstat ) == -1 ) return 0;
86 83
87 m_subMenu = new QPopupMenu( parent ); 84 m_subMenu = new QPopupMenu( parent );
88 m_subMenu->setCheckable( true ); 85 m_subMenu->setCheckable( true );
89 for ( int i = 1; i < 10; ++i ) 86 for ( int i = 1; i < 10; ++i )
90 { 87 {
91 int id = m_subMenu->insertItem( QString::number( i ), 500+i ); 88 int id = m_subMenu->insertItem( QString::number( i ), 500+i );
92 m_subMenu->setItemChecked( id, id-500 == vtstat.v_active ); 89 m_subMenu->setItemChecked( id, id-500 == vtstat.v_active );
93 } 90 }
94 ::close( fd ); 91 ::close( fd );
95 92
96 connect( m_subMenu, SIGNAL( activated(int) ), this, SLOT( changeVT(int) ) ); 93 connect( m_subMenu, SIGNAL( activated(int) ), this, SLOT( changeVT(int) ) );
97 connect( m_subMenu, SIGNAL( aboutToShow() ), this, SLOT( updateMenu() ) ); 94 connect( m_subMenu, SIGNAL( aboutToShow() ), this, SLOT( updateMenu() ) );
98 95
99 return m_subMenu; 96 return m_subMenu;
100} 97}
101 98
102 99
103void VTApplet::changeVT( int index ) 100void VTApplet::changeVT( int index )
104{ 101{
105 //qDebug( "VTApplet::changeVT( %d )", index-500 ); 102 //qDebug( "VTApplet::changeVT( %d )", index-500 );
106 103
107 int fd = ::open("/dev/tty0", O_RDWR); 104 int fd = ::open("/dev/tty0", O_RDWR);
108 if ( fd == -1 ) return; 105 if ( fd == -1 ) return;
109 ioctl( fd, VT_ACTIVATE, index-500 ); 106 ioctl( fd, VT_ACTIVATE, index-500 );
110} 107}
111 108
112 109
113void VTApplet::updateMenu() 110void VTApplet::updateMenu()
114{ 111{
115 //qDebug( "VTApplet::updateMenu()" ); 112 //qDebug( "VTApplet::updateMenu()" );
116 113
117 int fd = ::open( "/dev/console", O_RDONLY ); 114 int fd = ::open( "/dev/console", O_RDONLY );
118 if ( fd == -1 ) return; 115 if ( fd == -1 ) return;
119 116
120 for ( int i = 1; i < 10; ++i ) 117 for ( int i = 1; i < 10; ++i )
121 { 118 {
122 int result = ioctl( fd, VT_DISALLOCATE, i ); 119 int result = ioctl( fd, VT_DISALLOCATE, i );
123 120
124 /* 121 /*
125 if ( result == -1 ) 122 if ( result == -1 )
126 qDebug( "VT %d disallocated == free", i ); 123 qDebug( "VT %d disallocated == free", i );
127 else 124 else
128 qDebug( "VT %d _not_ disallocated == busy", i ); 125 qDebug( "VT %d _not_ disallocated == busy", i );
129 */ 126 */
130 127
131 m_subMenu->setItemEnabled( 500+i, result == -1 ); 128 m_subMenu->setItemEnabled( 500+i, result == -1 );
132 } 129 }
133 130
134 ::close( fd ); 131 ::close( fd );
135} 132}
136 133
137 134
138void VTApplet::activated() 135void VTApplet::activated()
139{ 136{
140 qDebug( "VTApplet::activated()" ); 137 qDebug( "VTApplet::activated()" );
141} 138}
142 139
143 140
144QRESULT VTApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) 141QRESULT VTApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface )
145{ 142{
146 *iface = 0; 143 *iface = 0;
147 if ( uuid == IID_QUnknown ) 144 if ( uuid == IID_QUnknown )
148 *iface = this; 145 *iface = this;
149 else if ( uuid == IID_MenuApplet ) 146 else if ( uuid == IID_MenuApplet )
150 *iface = this; 147 *iface = this;
151 else 148 else
152 return QS_FALSE; 149 return QS_FALSE;
153 150
154 if ( *iface ) 151 if ( *iface )
155 (*iface)-> addRef ( ); 152 (*iface)-> addRef ( );
156 return QS_OK; 153 return QS_OK;
157} 154}
158 155
159Q_EXPORT_INTERFACE( ) 156Q_EXPORT_INTERFACE( )
160{ 157{
161 Q_CREATE_INSTANCE( VTApplet ) 158 Q_CREATE_INSTANCE( VTApplet )
162} 159}
163 160
164 161
diff --git a/core/apps/calibrate/main.cpp b/core/apps/calibrate/main.cpp
index ec9b5ec..0da0fe0 100644
--- a/core/apps/calibrate/main.cpp
+++ b/core/apps/calibrate/main.cpp
@@ -1,47 +1,46 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "calibrate.h" 21#include "calibrate.h"
22 22
23#include <qfile.h>
24#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
25 24
26#ifdef QWS 25#ifdef QWS
27#include <qwindowsystem_qws.h> 26#include <qwindowsystem_qws.h>
28#endif 27#endif
29 28
30int main( int argc, char ** argv ) 29int main( int argc, char ** argv )
31{ 30{
32 QPEApplication a( argc, argv ); 31 QPEApplication a( argc, argv );
33 int retval = 0; 32 int retval = 0;
34 33
35#ifdef QWS 34#ifdef QWS
36 if ( QWSServer::mouseHandler() && 35 if ( QWSServer::mouseHandler() &&
37 QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) { 36 QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) {
38#endif 37#endif
39 // Make sure calibration widget starts on top. 38 // Make sure calibration widget starts on top.
40 Calibrate cal; 39 Calibrate cal;
41 a.setMainWidget(&cal); 40 a.setMainWidget(&cal);
42 a.showMainWidget(&cal); 41 a.showMainWidget(&cal);
43 return a.exec(); 42 return a.exec();
44#ifdef QWS 43#ifdef QWS
45 } 44 }
46#endif 45#endif
47} 46}
diff --git a/core/obex/obex.cc b/core/obex/obex.cc
index 2a306de..50e5201 100644
--- a/core/obex/obex.cc
+++ b/core/obex/obex.cc
@@ -1,203 +1,199 @@
1 1
2#include <qapplication.h>
3#include <qfile.h>
4#include <qfileinfo.h> 2#include <qfileinfo.h>
5#include <qtextcodec.h>
6 3
7#include <qpe/qcopenvelope_qws.h>
8 4
9#include <opie/oprocess.h> 5#include <opie/oprocess.h>
10#include "obex.h" 6#include "obex.h"
11 7
12using namespace OpieObex; 8using namespace OpieObex;
13 9
14/* TRANSLATOR OpieObex::Obex */ 10/* TRANSLATOR OpieObex::Obex */
15 11
16Obex::Obex( QObject *parent, const char* name ) 12Obex::Obex( QObject *parent, const char* name )
17 : QObject(parent, name ) 13 : QObject(parent, name )
18{ 14{
19 m_rec = 0; 15 m_rec = 0;
20 m_send=0; 16 m_send=0;
21 m_count = 0; 17 m_count = 0;
22 m_receive = false; 18 m_receive = false;
23 connect( this, SIGNAL(error(int) ), // for recovering to receive 19 connect( this, SIGNAL(error(int) ), // for recovering to receive
24 SLOT(slotError() ) ); 20 SLOT(slotError() ) );
25 connect( this, SIGNAL(sent(bool) ), 21 connect( this, SIGNAL(sent(bool) ),
26 SLOT(slotError() ) ); 22 SLOT(slotError() ) );
27}; 23};
28Obex::~Obex() { 24Obex::~Obex() {
29 delete m_rec; 25 delete m_rec;
30 delete m_send; 26 delete m_send;
31} 27}
32void Obex::receive() { 28void Obex::receive() {
33 m_receive = true; 29 m_receive = true;
34 m_outp = QString::null; 30 m_outp = QString::null;
35 qWarning("Receive" ); 31 qWarning("Receive" );
36 m_rec = new OProcess(); 32 m_rec = new OProcess();
37 *m_rec << "irobex_palm3"; 33 *m_rec << "irobex_palm3";
38 // connect to the necessary slots 34 // connect to the necessary slots
39 connect(m_rec, SIGNAL(processExited(OProcess*) ), 35 connect(m_rec, SIGNAL(processExited(OProcess*) ),
40 this, SLOT(slotExited(OProcess*) ) ); 36 this, SLOT(slotExited(OProcess*) ) );
41 37
42 connect(m_rec, SIGNAL(receivedStdout(OProcess*, char*, int ) ), 38 connect(m_rec, SIGNAL(receivedStdout(OProcess*, char*, int ) ),
43 this, SLOT(slotStdOut(OProcess*, char*, int) ) ); 39 this, SLOT(slotStdOut(OProcess*, char*, int) ) );
44 40
45 if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { 41 if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
46 qWarning("could not start :("); 42 qWarning("could not start :(");
47 emit done( false ); 43 emit done( false );
48 delete m_rec; 44 delete m_rec;
49 m_rec = 0; 45 m_rec = 0;
50 } 46 }
51// emit currentTry(m_count ); 47// emit currentTry(m_count );
52 48
53} 49}
54void Obex::send( const QString& fileName) { // if currently receiving stop it send receive 50void Obex::send( const QString& fileName) { // if currently receiving stop it send receive
55 m_count = 0; 51 m_count = 0;
56 m_file = fileName; 52 m_file = fileName;
57 qWarning("send %s", fileName.latin1() ); 53 qWarning("send %s", fileName.latin1() );
58 if (m_rec != 0 ) { 54 if (m_rec != 0 ) {
59 qWarning("running"); 55 qWarning("running");
60 if (m_rec->isRunning() ) { 56 if (m_rec->isRunning() ) {
61 emit error(-1 ); 57 emit error(-1 );
62 qWarning("is running"); 58 qWarning("is running");
63 delete m_rec; 59 delete m_rec;
64 m_rec = 0; 60 m_rec = 0;
65 61
66 }else{ 62 }else{
67 qWarning("is not running"); 63 qWarning("is not running");
68 emit error( -1 ); // we did not delete yet but it's not running slotExited is pending 64 emit error( -1 ); // we did not delete yet but it's not running slotExited is pending
69 return; 65 return;
70 } 66 }
71 } 67 }
72 sendNow(); 68 sendNow();
73} 69}
74void Obex::sendNow(){ 70void Obex::sendNow(){
75 qWarning("sendNow"); 71 qWarning("sendNow");
76 if ( m_count >= 25 ) { // could not send 72 if ( m_count >= 25 ) { // could not send
77 emit error(-1 ); 73 emit error(-1 );
78 emit sent(false); 74 emit sent(false);
79 return; 75 return;
80 } 76 }
81 // OProcess inititialisation 77 // OProcess inititialisation
82 m_send = new OProcess(); 78 m_send = new OProcess();
83 *m_send << "irobex_palm3"; 79 *m_send << "irobex_palm3";
84 *m_send << QFile::encodeName(m_file); 80 *m_send << QFile::encodeName(m_file);
85 81
86 // connect to slots Exited and and StdOut 82 // connect to slots Exited and and StdOut
87 connect(m_send, SIGNAL(processExited(OProcess*) ), 83 connect(m_send, SIGNAL(processExited(OProcess*) ),
88 this, SLOT(slotExited(OProcess*)) ); 84 this, SLOT(slotExited(OProcess*)) );
89 connect(m_send, SIGNAL(receivedStdout(OProcess*, char*, int )), 85 connect(m_send, SIGNAL(receivedStdout(OProcess*, char*, int )),
90 this, SLOT(slotStdOut(OProcess*, char*, int) ) ); 86 this, SLOT(slotStdOut(OProcess*, char*, int) ) );
91 87
92 // now start it 88 // now start it
93 if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) { 89 if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) {
94 qWarning("could not send" ); 90 qWarning("could not send" );
95 m_count = 25; 91 m_count = 25;
96 emit error(-1 ); 92 emit error(-1 );
97 delete m_send; 93 delete m_send;
98 m_send=0; 94 m_send=0;
99 } 95 }
100 // end 96 // end
101 m_count++; 97 m_count++;
102 emit currentTry( m_count ); 98 emit currentTry( m_count );
103} 99}
104 100
105void Obex::slotExited(OProcess* proc ){ 101void Obex::slotExited(OProcess* proc ){
106 if (proc == m_rec ) { // receive process 102 if (proc == m_rec ) { // receive process
107 received(); 103 received();
108 }else if ( proc == m_send ) { 104 }else if ( proc == m_send ) {
109 sendEnd(); 105 sendEnd();
110 } 106 }
111} 107}
112void Obex::slotStdOut(OProcess* proc, char* buf, int len){ 108void Obex::slotStdOut(OProcess* proc, char* buf, int len){
113 if ( proc == m_rec ) { // only receive 109 if ( proc == m_rec ) { // only receive
114 QByteArray ar( len ); 110 QByteArray ar( len );
115 memcpy( ar.data(), buf, len ); 111 memcpy( ar.data(), buf, len );
116 qWarning("parsed: %s", ar.data() ); 112 qWarning("parsed: %s", ar.data() );
117 m_outp.append( ar ); 113 m_outp.append( ar );
118 } 114 }
119} 115}
120 116
121void Obex::received() { 117void Obex::received() {
122 if (m_rec->normalExit() ) { 118 if (m_rec->normalExit() ) {
123 if ( m_rec->exitStatus() == 0 ) { // we got one 119 if ( m_rec->exitStatus() == 0 ) { // we got one
124 QString filename = parseOut(); 120 QString filename = parseOut();
125 qWarning("ACHTUNG %s", filename.latin1() ); 121 qWarning("ACHTUNG %s", filename.latin1() );
126 emit receivedFile( filename ); 122 emit receivedFile( filename );
127 } 123 }
128 }else{ 124 }else{
129 emit done(false); 125 emit done(false);
130 }; 126 };
131 delete m_rec; 127 delete m_rec;
132 m_rec = 0; 128 m_rec = 0;
133 receive(); 129 receive();
134} 130}
135 131
136void Obex::sendEnd() { 132void Obex::sendEnd() {
137 if (m_send->normalExit() ) { 133 if (m_send->normalExit() ) {
138 if ( m_send->exitStatus() == 0 ) { 134 if ( m_send->exitStatus() == 0 ) {
139 delete m_send; 135 delete m_send;
140 m_send=0; 136 m_send=0;
141 qWarning("done" ); 137 qWarning("done" );
142 emit sent(true); 138 emit sent(true);
143 }else if (m_send->exitStatus() == 255 ) { // it failed maybe the other side wasn't ready 139 }else if (m_send->exitStatus() == 255 ) { // it failed maybe the other side wasn't ready
144 // let's try it again 140 // let's try it again
145 delete m_send; 141 delete m_send;
146 m_send = 0; 142 m_send = 0;
147 qWarning("try sending again" ); 143 qWarning("try sending again" );
148 sendNow(); 144 sendNow();
149 } 145 }
150 }else { 146 }else {
151 emit error( -1 ); 147 emit error( -1 );
152 delete m_send; 148 delete m_send;
153 m_send = 0; 149 m_send = 0;
154 } 150 }
155} 151}
156QString Obex::parseOut( ){ 152QString Obex::parseOut( ){
157 QString path; 153 QString path;
158 QStringList list = QStringList::split("\n", m_outp); 154 QStringList list = QStringList::split("\n", m_outp);
159 QStringList::Iterator it; 155 QStringList::Iterator it;
160 for (it = list.begin(); it != list.end(); ++it ) { 156 for (it = list.begin(); it != list.end(); ++it ) {
161 if ( (*it).startsWith("Wrote" ) ) { 157 if ( (*it).startsWith("Wrote" ) ) {
162 int pos = (*it).findRev('(' ); 158 int pos = (*it).findRev('(' );
163 if ( pos > 0 ) { 159 if ( pos > 0 ) {
164 qWarning( "%d %s", pos, (*it).mid(6 ).latin1() ) ; 160 qWarning( "%d %s", pos, (*it).mid(6 ).latin1() ) ;
165 qWarning("%d %d", (*it).length(), (*it).length()-pos ); 161 qWarning("%d %d", (*it).length(), (*it).length()-pos );
166 162
167 path = (*it).remove( pos, (*it).length() - pos ); 163 path = (*it).remove( pos, (*it).length() - pos );
168 qWarning("%s", path.latin1() ); 164 qWarning("%s", path.latin1() );
169 path = path.mid(6 ); 165 path = path.mid(6 );
170 path = path.stripWhiteSpace(); 166 path = path.stripWhiteSpace();
171 qWarning("path %s", path.latin1() ); 167 qWarning("path %s", path.latin1() );
172 } 168 }
173 } 169 }
174 } 170 }
175 return path; 171 return path;
176} 172}
177/** 173/**
178 * when sent is done slotError is called we will start receive again 174 * when sent is done slotError is called we will start receive again
179 */ 175 */
180void Obex::slotError() { 176void Obex::slotError() {
181 qWarning("slotError"); 177 qWarning("slotError");
182 if ( m_receive ) 178 if ( m_receive )
183 receive(); 179 receive();
184}; 180};
185void Obex::setReceiveEnabled( bool receive ) { 181void Obex::setReceiveEnabled( bool receive ) {
186 if ( !receive ) { // 182 if ( !receive ) { //
187 m_receive = false; 183 m_receive = false;
188 shutDownReceive(); 184 shutDownReceive();
189 } 185 }
190} 186}
191 187
192void Obex::shutDownReceive() { 188void Obex::shutDownReceive() {
193 if (m_rec != 0 ) { 189 if (m_rec != 0 ) {
194 qWarning("running"); 190 qWarning("running");
195 if (m_rec->isRunning() ) { 191 if (m_rec->isRunning() ) {
196 emit error(-1 ); 192 emit error(-1 );
197 qWarning("is running"); 193 qWarning("is running");
198 delete m_rec; 194 delete m_rec;
199 m_rec = 0; 195 m_rec = 0;
200 } 196 }
201 } 197 }
202 198
203} 199}
diff --git a/core/obex/obexhandler.cpp b/core/obex/obexhandler.cpp
index c237555..4034560 100644
--- a/core/obex/obexhandler.cpp
+++ b/core/obex/obexhandler.cpp
@@ -1,68 +1,67 @@
1#include <qcopchannel_qws.h>
2 1
3#include <qpe/qcopenvelope_qws.h> 2#include <qpe/qcopenvelope_qws.h>
4#include <qpe/qpeapplication.h> 3#include <qpe/qpeapplication.h>
5 4
6#include "obexsend.h" 5#include "obexsend.h"
7#include "receiver.h" 6#include "receiver.h"
8#include "obexhandler.h" 7#include "obexhandler.h"
9 8
10using namespace OpieObex; 9using namespace OpieObex;
11 10
12/* TRANSLATOR OpieObex::ObexHandler */ 11/* TRANSLATOR OpieObex::ObexHandler */
13 12
14ObexHandler::ObexHandler() { 13ObexHandler::ObexHandler() {
15 m_wasRec = false; 14 m_wasRec = false;
16 m_sender = 0l; 15 m_sender = 0l;
17 m_receiver = 0l; 16 m_receiver = 0l;
18 QCopChannel* chan = new QCopChannel("QPE/Obex"); 17 QCopChannel* chan = new QCopChannel("QPE/Obex");
19 connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ), 18 connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ),
20 this, SLOT(irdaMessage(const QCString&, const QByteArray& ) ) ); 19 this, SLOT(irdaMessage(const QCString&, const QByteArray& ) ) );
21} 20}
22ObexHandler::~ObexHandler() { 21ObexHandler::~ObexHandler() {
23 delete m_sender; 22 delete m_sender;
24 delete m_receiver; 23 delete m_receiver;
25} 24}
26void ObexHandler::doSend(const QString& str, const QString& desc) { 25void ObexHandler::doSend(const QString& str, const QString& desc) {
27 delete m_sender; 26 delete m_sender;
28 m_sender = new SendWidget; 27 m_sender = new SendWidget;
29 m_sender->raise(); 28 m_sender->raise();
30 QPEApplication::showWidget( m_sender ); 29 QPEApplication::showWidget( m_sender );
31 connect(m_sender, SIGNAL(done() ), 30 connect(m_sender, SIGNAL(done() ),
32 this, SLOT(slotSent() ) ); 31 this, SLOT(slotSent() ) );
33 m_sender->send( str, desc ); 32 m_sender->send( str, desc );
34} 33}
35void ObexHandler::doReceive(bool b) { 34void ObexHandler::doReceive(bool b) {
36 if (m_receiver && b ) return; // we should enable receiver and it is on 35 if (m_receiver && b ) return; // we should enable receiver and it is on
37 else if (!m_receiver && !b ) return; // we should disbale receiver and it is off 36 else if (!m_receiver && !b ) return; // we should disbale receiver and it is off
38 else if (m_receiver && !b ) { 37 else if (m_receiver && !b ) {
39 delete m_receiver; 38 delete m_receiver;
40 m_receiver=0; 39 m_receiver=0;
41 }else if (!m_receiver && b ) { 40 }else if (!m_receiver && b ) {
42 m_receiver= new Receiver; 41 m_receiver= new Receiver;
43 } 42 }
44} 43}
45void ObexHandler::slotSent() { 44void ObexHandler::slotSent() {
46 QString file = m_sender->file(); 45 QString file = m_sender->file();
47 delete m_sender; 46 delete m_sender;
48 m_sender = 0; 47 m_sender = 0;
49 QCopEnvelope e ("QPE/Obex", "done(QString)" ); 48 QCopEnvelope e ("QPE/Obex", "done(QString)" );
50 e << file; 49 e << file;
51 doReceive(m_wasRec ); 50 doReceive(m_wasRec );
52 m_wasRec = false; 51 m_wasRec = false;
53} 52}
54void ObexHandler::irdaMessage( const QCString& msg, const QByteArray& data) { 53void ObexHandler::irdaMessage( const QCString& msg, const QByteArray& data) {
55 QDataStream stream( data, IO_ReadOnly ); 54 QDataStream stream( data, IO_ReadOnly );
56 if ( msg == "send(QString,QString,QString)" ) { 55 if ( msg == "send(QString,QString,QString)" ) {
57 QString name, desc; 56 QString name, desc;
58 stream >> desc; 57 stream >> desc;
59 stream >> name; 58 stream >> name;
60 m_wasRec = (m_receiver != 0 ); 59 m_wasRec = (m_receiver != 0 );
61 doReceive( false ); 60 doReceive( false );
62 doSend(name, desc); 61 doSend(name, desc);
63 }else if (msg == "receive(int)") { 62 }else if (msg == "receive(int)") {
64 int rec; 63 int rec;
65 stream >> rec; 64 stream >> rec;
66 doReceive(rec); 65 doReceive(rec);
67 } 66 }
68} 67}
diff --git a/core/obex/obexsend.cpp b/core/obex/obexsend.cpp
index cf5d958..6b8d467 100644
--- a/core/obex/obexsend.cpp
+++ b/core/obex/obexsend.cpp
@@ -1,297 +1,293 @@
1#include <qpushbutton.h> 1#include <qpushbutton.h>
2#include <qlabel.h> 2#include <qlabel.h>
3#include <qhbox.h>
4#include <qlayout.h> 3#include <qlayout.h>
5#include <qtimer.h> 4#include <qtimer.h>
6#include <qtl.h>
7 5
8#include <qcopchannel_qws.h>
9 6
10#include <qpe/resource.h>
11#include <qpe/qcopenvelope_qws.h> 7#include <qpe/qcopenvelope_qws.h>
12 8
13#include "obex.h" 9#include "obex.h"
14#include "obexsend.h" 10#include "obexsend.h"
15 11
16using namespace OpieObex; 12using namespace OpieObex;
17 13
18/* TRANSLATOR OpieObex::SendWidget */ 14/* TRANSLATOR OpieObex::SendWidget */
19 15
20 16
21SendWidget::SendWidget( QWidget* parent, const char* name ) 17SendWidget::SendWidget( QWidget* parent, const char* name )
22 : QWidget( parent, name ) { 18 : QWidget( parent, name ) {
23 initUI(); 19 initUI();
24} 20}
25SendWidget::~SendWidget() { 21SendWidget::~SendWidget() {
26} 22}
27void SendWidget::initUI() { 23void SendWidget::initUI() {
28 m_obex = new Obex(this, "obex"); 24 m_obex = new Obex(this, "obex");
29 connect(m_obex, SIGNAL(error(int) ), 25 connect(m_obex, SIGNAL(error(int) ),
30 this, SLOT(slotIrError(int) ) ); 26 this, SLOT(slotIrError(int) ) );
31 connect(m_obex, SIGNAL(sent(bool) ), 27 connect(m_obex, SIGNAL(sent(bool) ),
32 this, SLOT(slotIrSent(bool) ) ); 28 this, SLOT(slotIrSent(bool) ) );
33 connect(m_obex, SIGNAL(currentTry(unsigned int ) ), 29 connect(m_obex, SIGNAL(currentTry(unsigned int ) ),
34 this, SLOT(slotIrTry(unsigned int ) ) ); 30 this, SLOT(slotIrTry(unsigned int ) ) );
35 31
36 QCopChannel* chan = new QCopChannel("QPE/IrDaAppletBack", this ); 32 QCopChannel* chan = new QCopChannel("QPE/IrDaAppletBack", this );
37 connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ), 33 connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ),
38 this, SLOT(dispatchIrda(const QCString&, const QByteArray& ) ) ); 34 this, SLOT(dispatchIrda(const QCString&, const QByteArray& ) ) );
39 35
40 chan = new QCopChannel("QPE/BluetoothBack", this ); 36 chan = new QCopChannel("QPE/BluetoothBack", this );
41 connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ), 37 connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ),
42 this, SLOT(dispatchBt(const QCString&, const QByteArray& ) ) ); 38 this, SLOT(dispatchBt(const QCString&, const QByteArray& ) ) );
43 39
44 QVBoxLayout* lay = new QVBoxLayout(this); 40 QVBoxLayout* lay = new QVBoxLayout(this);
45 41
46 QHBox* nameBox = new QHBox(this); 42 QHBox* nameBox = new QHBox(this);
47 QLabel* name = new QLabel(nameBox); 43 QLabel* name = new QLabel(nameBox);
48 name->setText( tr("<qt><h1>Sending:</h1></qt>") ); 44 name->setText( tr("<qt><h1>Sending:</h1></qt>") );
49 name->setAlignment( AlignLeft | AlignTop ); 45 name->setAlignment( AlignLeft | AlignTop );
50 m_lblFile = new QLabel(nameBox); 46 m_lblFile = new QLabel(nameBox);
51 lay->addWidget(nameBox, 0); 47 lay->addWidget(nameBox, 0);
52 48
53 QFrame* frame = new QFrame(this); 49 QFrame* frame = new QFrame(this);
54 frame->setFrameShape( QFrame::HLine ); 50 frame->setFrameShape( QFrame::HLine );
55 frame->setFrameShadow( QFrame::Sunken ); 51 frame->setFrameShadow( QFrame::Sunken );
56 lay->addWidget(frame, 10); 52 lay->addWidget(frame, 10);
57 53
58 QLabel* devices = new QLabel(this); 54 QLabel* devices = new QLabel(this);
59 devices->setText("<qt><b>Devices:</b></qt>"); 55 devices->setText("<qt><b>Devices:</b></qt>");
60 devices->setAlignment( AlignLeft | AlignTop ); 56 devices->setAlignment( AlignLeft | AlignTop );
61 lay->addWidget( devices,10 ); 57 lay->addWidget( devices,10 );
62 58
63 m_devBox = new DeviceBox(this); 59 m_devBox = new DeviceBox(this);
64 lay->addWidget( m_devBox, 50 ); 60 lay->addWidget( m_devBox, 50 );
65 connect(m_devBox, SIGNAL(selectedDevice(int, int ) ), 61 connect(m_devBox, SIGNAL(selectedDevice(int, int ) ),
66 this, SLOT(slotSelectedDevice(int, int) ) ); 62 this, SLOT(slotSelectedDevice(int, int) ) );
67 63
68 QPushButton *but = new QPushButton(this); 64 QPushButton *but = new QPushButton(this);
69 but->setText(tr("Done") ); 65 but->setText(tr("Done") );
70 connect(but, SIGNAL(clicked() ), 66 connect(but, SIGNAL(clicked() ),
71 this, SLOT(slotDone() ) ); 67 this, SLOT(slotDone() ) );
72 68
73 lay->addWidget( but ); 69 lay->addWidget( but );
74 m_lay = lay; 70 m_lay = lay;
75 71
76 // QT does not like if you add items to an layout which already exits.... 72 // QT does not like if you add items to an layout which already exits....
77 // and was layouted invalidate() does not help too 73 // and was layouted invalidate() does not help too
78 // so we use RichText.... 74 // so we use RichText....
79} 75}
80 76
81/* 77/*
82 * in send we'll first set everything up 78 * in send we'll first set everything up
83 * and then wait for a list of devices. 79 * and then wait for a list of devices.
84 */ 80 */
85void SendWidget::send( const QString& file, const QString& desc ) { 81void SendWidget::send( const QString& file, const QString& desc ) {
86 m_file = file; 82 m_file = file;
87 m_irDa.clear(); 83 m_irDa.clear();
88 m_start = 0; 84 m_start = 0;
89 m_lblFile->setText(desc.isEmpty() ? file : desc ); 85 m_lblFile->setText(desc.isEmpty() ? file : desc );
90 86
91 if ( !QCopChannel::isRegistered("QPE/IrDaApplet") ) { 87 if ( !QCopChannel::isRegistered("QPE/IrDaApplet") ) {
92 m_irDeSearch = m_devBox->addDevice( tr("IrDa is not enabled!"), DeviceBox::Error ); 88 m_irDeSearch = m_devBox->addDevice( tr("IrDa is not enabled!"), DeviceBox::Error );
93 m_start++; 89 m_start++;
94 }else 90 }else
95 m_irDeSearch = m_devBox->addDevice( tr("Searching for IrDa Devices."), DeviceBox::Search ); 91 m_irDeSearch = m_devBox->addDevice( tr("Searching for IrDa Devices."), DeviceBox::Search );
96 92
97 if ( !QCopChannel::isRegistered("QPE/Bluetooth") ) { 93 if ( !QCopChannel::isRegistered("QPE/Bluetooth") ) {
98 m_btDeSearch = m_devBox->addDevice( tr("Bluetooth is not available"), DeviceBox::Error ); 94 m_btDeSearch = m_devBox->addDevice( tr("Bluetooth is not available"), DeviceBox::Error );
99 m_start++; 95 m_start++;
100 }else 96 }else
101 m_btDeSearch = m_devBox->addDevice( tr("Searching for bluetooth Devices."), DeviceBox::Search ); 97 m_btDeSearch = m_devBox->addDevice( tr("Searching for bluetooth Devices."), DeviceBox::Search );
102 98
103 if (m_start != 2 ) { 99 if (m_start != 2 ) {
104 QCopEnvelope e0("QPE/IrDaApplet", "enableIrda()"); 100 QCopEnvelope e0("QPE/IrDaApplet", "enableIrda()");
105 QCopEnvelope e1("QPE/Bluetooth", "enableBluetooth()"); 101 QCopEnvelope e1("QPE/Bluetooth", "enableBluetooth()");
106 QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); 102 QCopEnvelope e2("QPE/IrDaApplet", "listDevices()");
107 QCopEnvelope e3("QPE/Bluetooth", "listDevices()"); 103 QCopEnvelope e3("QPE/Bluetooth", "listDevices()");
108 } 104 }
109} 105}
110void SendWidget::slotIrDaDevices( const QStringList& list) { 106void SendWidget::slotIrDaDevices( const QStringList& list) {
111 qWarning("slot it irda devices "); 107 qWarning("slot it irda devices ");
112 for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) { 108 for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) {
113 int id = m_devBox->addDevice( (*it), DeviceBox::IrDa, tr("Scheduling for beam.") ); 109 int id = m_devBox->addDevice( (*it), DeviceBox::IrDa, tr("Scheduling for beam.") );
114 m_irDa.insert( id, (*it) ); 110 m_irDa.insert( id, (*it) );
115 } 111 }
116 m_devBox->removeDevice( m_irDeSearch ); 112 m_devBox->removeDevice( m_irDeSearch );
117 m_irDaIt = m_irDa.begin(); 113 m_irDaIt = m_irDa.begin();
118 114
119 slotStartIrda(); 115 slotStartIrda();
120} 116}
121 117
122void SendWidget::slotBTDevices( const QMap<QString, QString>& str ) { 118void SendWidget::slotBTDevices( const QMap<QString, QString>& str ) {
123 for(QMap<QString, QString>::ConstIterator it = str.begin(); it != str.end(); ++it ) { 119 for(QMap<QString, QString>::ConstIterator it = str.begin(); it != str.end(); ++it ) {
124 int id = m_devBox->addDevice( it.key(), DeviceBox::BT, tr("Click to beam") ); 120 int id = m_devBox->addDevice( it.key(), DeviceBox::BT, tr("Click to beam") );
125 m_bt.insert( id, Pair( it.key(), it.data() ) ); 121 m_bt.insert( id, Pair( it.key(), it.data() ) );
126 } 122 }
127 m_devBox->removeDevice( m_btDeSearch ); 123 m_devBox->removeDevice( m_btDeSearch );
128} 124}
129void SendWidget::slotSelectedDevice( int name, int dev ) { 125void SendWidget::slotSelectedDevice( int name, int dev ) {
130 qWarning("Start beam? %d %d", name, dev ); 126 qWarning("Start beam? %d %d", name, dev );
131 if ( name == m_irDeSearch ) { 127 if ( name == m_irDeSearch ) {
132 for (QMap<int, QString>::Iterator it= m_irDa.begin(); it != m_irDa.end(); ++it ) 128 for (QMap<int, QString>::Iterator it= m_irDa.begin(); it != m_irDa.end(); ++it )
133 m_devBox->removeDevice( it.key() ); 129 m_devBox->removeDevice( it.key() );
134 130
135 QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); 131 QCopEnvelope e2("QPE/IrDaApplet", "listDevices()");
136 } 132 }
137} 133}
138void SendWidget::dispatchIrda( const QCString& str, const QByteArray& ar ) { 134void SendWidget::dispatchIrda( const QCString& str, const QByteArray& ar ) {
139 qWarning("dispatch irda %s", str.data() ); 135 qWarning("dispatch irda %s", str.data() );
140 if ( str == "devices(QStringList)" ) { 136 if ( str == "devices(QStringList)" ) {
141 QDataStream stream( ar, IO_ReadOnly ); 137 QDataStream stream( ar, IO_ReadOnly );
142 QStringList list; 138 QStringList list;
143 stream >> list; 139 stream >> list;
144 slotIrDaDevices( list ); 140 slotIrDaDevices( list );
145 } 141 }
146} 142}
147void SendWidget::dispatchBt( const QCString&, const QByteArray& ) { 143void SendWidget::dispatchBt( const QCString&, const QByteArray& ) {
148 144
149} 145}
150void SendWidget::slotIrError( int ) { 146void SendWidget::slotIrError( int ) {
151 147
152} 148}
153void SendWidget::slotIrSent( bool b) { 149void SendWidget::slotIrSent( bool b) {
154 qWarning("irda sent!!"); 150 qWarning("irda sent!!");
155 QString text = b ? tr("Sent") : tr("Failure"); 151 QString text = b ? tr("Sent") : tr("Failure");
156 m_devBox->setStatus( m_irDaIt.key(), text ); 152 m_devBox->setStatus( m_irDaIt.key(), text );
157 ++m_irDaIt; 153 ++m_irDaIt;
158 slotStartIrda(); 154 slotStartIrda();
159} 155}
160void SendWidget::slotIrTry(unsigned int trI) { 156void SendWidget::slotIrTry(unsigned int trI) {
161 m_devBox->setStatus( m_irDaIt.key(), tr("Try %1").arg( QString::number( trI ) ) ); 157 m_devBox->setStatus( m_irDaIt.key(), tr("Try %1").arg( QString::number( trI ) ) );
162} 158}
163void SendWidget::slotStartIrda() { 159void SendWidget::slotStartIrda() {
164 if (m_irDaIt == m_irDa.end() ) { 160 if (m_irDaIt == m_irDa.end() ) {
165 m_irDeSearch = m_devBox->addDevice(tr("Search again for IrDa."), DeviceBox::Search ); 161 m_irDeSearch = m_devBox->addDevice(tr("Search again for IrDa."), DeviceBox::Search );
166 return; 162 return;
167 } 163 }
168 m_devBox->setStatus( m_irDaIt.key(), tr("Start sending") ); 164 m_devBox->setStatus( m_irDaIt.key(), tr("Start sending") );
169 m_obex->send( m_file ); 165 m_obex->send( m_file );
170} 166}
171void SendWidget::closeEvent( QCloseEvent* e) { 167void SendWidget::closeEvent( QCloseEvent* e) {
172 e->accept(); // make sure 168 e->accept(); // make sure
173 QTimer::singleShot(0, this, SLOT(slotDone() ) ); 169 QTimer::singleShot(0, this, SLOT(slotDone() ) );
174} 170}
175void SendWidget::slotDone() { 171void SendWidget::slotDone() {
176 QCopEnvelope e0("QPE/IrDaApplet", "disableIrda()"); 172 QCopEnvelope e0("QPE/IrDaApplet", "disableIrda()");
177 QCopEnvelope e1("QPE/Bluetooth", "disableBluetooth()"); 173 QCopEnvelope e1("QPE/Bluetooth", "disableBluetooth()");
178 emit done(); 174 emit done();
179} 175}
180QString SendWidget::file()const { 176QString SendWidget::file()const {
181 return m_file; 177 return m_file;
182} 178}
183DeviceBox::DeviceBox( QWidget* parent ) 179DeviceBox::DeviceBox( QWidget* parent )
184 : QTextBrowser( parent ) { 180 : QTextBrowser( parent ) {
185 181
186} 182}
187DeviceBox::~DeviceBox() { 183DeviceBox::~DeviceBox() {
188 184
189} 185}
190int DeviceBox::addDevice( const QString& name, int dev, const QString& status ) { 186int DeviceBox::addDevice( const QString& name, int dev, const QString& status ) {
191 /* return a id for a range of devices */ 187 /* return a id for a range of devices */
192 int id = idFor ( dev ); 188 int id = idFor ( dev );
193 DeviceItem item( name, status, dev,id ); 189 DeviceItem item( name, status, dev,id );
194 m_dev.insert( id, item ); 190 m_dev.insert( id, item );
195 setText( allText() ); 191 setText( allText() );
196 192
197 return id; 193 return id;
198} 194}
199void DeviceBox::removeDevice( int id ) { 195void DeviceBox::removeDevice( int id ) {
200 if (!m_dev.contains(id) ) return; 196 if (!m_dev.contains(id) ) return;
201 197
202 m_dev.remove( id ); 198 m_dev.remove( id );
203 setText( allText() ); 199 setText( allText() );
204} 200}
205void DeviceBox::setStatus( int id, const QString& status ) { 201void DeviceBox::setStatus( int id, const QString& status ) {
206 if ( !m_dev.contains(id) ) return; 202 if ( !m_dev.contains(id) ) return;
207 m_dev[id].setStatus(status ); 203 m_dev[id].setStatus(status );
208 setText( allText() ); 204 setText( allText() );
209} 205}
210void DeviceBox::setSource( const QString& str ) { 206void DeviceBox::setSource( const QString& str ) {
211 qWarning("SetSource:%d", str.toInt() ); 207 qWarning("SetSource:%d", str.toInt() );
212 int id = str.toInt(); 208 int id = str.toInt();
213 emit selectedDevice( id, m_dev[id].device() ); 209 emit selectedDevice( id, m_dev[id].device() );
214} 210}
215int DeviceBox::idFor ( int id ) { 211int DeviceBox::idFor ( int id ) {
216 static int irId = 1501; 212 static int irId = 1501;
217 static int irBT = 1001; 213 static int irBT = 1001;
218 static int irSr = 501; 214 static int irSr = 501;
219 static int irEr = 0; 215 static int irEr = 0;
220 216
221 int ret = -1; 217 int ret = -1;
222 switch(id ) { 218 switch(id ) {
223 case IrDa: 219 case IrDa:
224 ret = irId; 220 ret = irId;
225 irId++; 221 irId++;
226 break; 222 break;
227 case BT: 223 case BT:
228 ret = irBT; 224 ret = irBT;
229 irBT++; 225 irBT++;
230 break; 226 break;
231 case Search: 227 case Search:
232 ret = irSr; 228 ret = irSr;
233 irSr++; 229 irSr++;
234 break; 230 break;
235 case Error: 231 case Error:
236 ret = irEr; 232 ret = irEr;
237 irEr++; 233 irEr++;
238 break; 234 break;
239 } 235 }
240 return ret; 236 return ret;
241} 237}
242QString DeviceBox::allText() { 238QString DeviceBox::allText() {
243 QString str; 239 QString str;
244 typedef QMap<int, DeviceItem> DeviceMap; 240 typedef QMap<int, DeviceItem> DeviceMap;
245 241
246 for (QMap<int, DeviceItem>::Iterator it = m_dev.begin(); it != m_dev.end(); ++it ) { 242 for (QMap<int, DeviceItem>::Iterator it = m_dev.begin(); it != m_dev.end(); ++it ) {
247 str += it.data().toString() + "<br>"; 243 str += it.data().toString() + "<br>";
248 } 244 }
249 return str; 245 return str;
250} 246}
251 247
252DeviceItem::DeviceItem( const QString& name, 248DeviceItem::DeviceItem( const QString& name,
253 const QString& status, int dev, int id) 249 const QString& status, int dev, int id)
254{ 250{
255 m_name = name; 251 m_name = name;
256 m_status = status; 252 m_status = status;
257 m_dev = dev; 253 m_dev = dev;
258 m_id = id; 254 m_id = id;
259} 255}
260int DeviceItem::id()const { 256int DeviceItem::id()const {
261 return m_id; 257 return m_id;
262} 258}
263QString DeviceItem::name()const { 259QString DeviceItem::name()const {
264 return m_name; 260 return m_name;
265} 261}
266QString DeviceItem::status()const { 262QString DeviceItem::status()const {
267 return m_status; 263 return m_status;
268} 264}
269int DeviceItem::device()const { 265int DeviceItem::device()const {
270 return m_dev; 266 return m_dev;
271} 267}
272QString DeviceItem::pixmap()const{ 268QString DeviceItem::pixmap()const{
273 QString str; 269 QString str;
274 switch(m_dev) { 270 switch(m_dev) {
275 case DeviceBox::IrDa: 271 case DeviceBox::IrDa:
276 str ="obex/irda"; 272 str ="obex/irda";
277 break; 273 break;
278 case DeviceBox::BT: 274 case DeviceBox::BT:
279 str ="obex/bt"; 275 str ="obex/bt";
280 break; 276 break;
281 case DeviceBox::Search: 277 case DeviceBox::Search:
282 str = "mag"; 278 str = "mag";
283 break; 279 break;
284 case DeviceBox::Error: 280 case DeviceBox::Error:
285 str = "editdelete"; 281 str = "editdelete";
286 break; 282 break;
287 }; 283 };
288 return str; 284 return str;
289} 285}
290DeviceItem::~DeviceItem() { 286DeviceItem::~DeviceItem() {
291} 287}
292void DeviceItem::setStatus(const QString& status ) { 288void DeviceItem::setStatus(const QString& status ) {
293 m_status = status; 289 m_status = status;
294} 290}
295QString DeviceItem::toString()const { 291QString DeviceItem::toString()const {
296 return "<p><a href=\""+QString::number(m_id) +"\" ><img src=\""+pixmap()+"\" >"+m_name+" "+m_status+" </a></p>" ; 292 return "<p><a href=\""+QString::number(m_id) +"\" ><img src=\""+pixmap()+"\" >"+m_name+" "+m_status+" </a></p>" ;
297} 293}
diff --git a/core/obex/receiver.cpp b/core/obex/receiver.cpp
index bf9e30c..7d9f7ec 100644
--- a/core/obex/receiver.cpp
+++ b/core/obex/receiver.cpp
@@ -1,203 +1,199 @@
1#include <sys/types.h> 1#include <sys/types.h>
2#include <sys/stat.h> 2#include <sys/stat.h>
3#include <sys/mman.h> 3#include <sys/mman.h>
4#include <stdlib.h> // int system 4#include <stdlib.h> // int system
5#include <unistd.h> 5#include <unistd.h>
6 6
7#include <fcntl.h> 7#include <fcntl.h>
8 8
9#include <qfile.h>
10#include <qfileinfo.h> 9#include <qfileinfo.h>
11#include <qlabel.h> 10#include <qlabel.h>
12#include <qhbox.h>
13#include <qregexp.h>
14#include <qtextview.h> 11#include <qtextview.h>
15#include <qpushbutton.h> 12#include <qpushbutton.h>
16 13
17#include <qpe/applnk.h> 14#include <qpe/applnk.h>
18#include <qpe/qpeapplication.h> 15#include <qpe/qpeapplication.h>
19#include <qpe/qcopenvelope_qws.h> 16#include <qpe/qcopenvelope_qws.h>
20#include <qpe/global.h>
21 17
22#include "obex.h" 18#include "obex.h"
23#include "receiver.h" 19#include "receiver.h"
24 20
25using namespace OpieObex; 21using namespace OpieObex;
26 22
27/* TRANSLATOR OpieObex::Receiver */ 23/* TRANSLATOR OpieObex::Receiver */
28 24
29Receiver::Receiver() { 25Receiver::Receiver() {
30 m_obex = new Obex(this, "Receiver"); 26 m_obex = new Obex(this, "Receiver");
31 connect(m_obex, SIGNAL(receivedFile(const QString& ) ), 27 connect(m_obex, SIGNAL(receivedFile(const QString& ) ),
32 this, SLOT(slotReceived(const QString& ) ) ); 28 this, SLOT(slotReceived(const QString& ) ) );
33 m_obex->receive(); 29 m_obex->receive();
34} 30}
35Receiver::~Receiver() { 31Receiver::~Receiver() {
36 m_obex->setReceiveEnabled( false ); 32 m_obex->setReceiveEnabled( false );
37 delete m_obex; 33 delete m_obex;
38} 34}
39void Receiver::slotReceived( const QString& _file ) { 35void Receiver::slotReceived( const QString& _file ) {
40 QString file = _file; 36 QString file = _file;
41 int check = checkFile(file); 37 int check = checkFile(file);
42 if ( check == AddressBook ) 38 if ( check == AddressBook )
43 handleAddr( file ); 39 handleAddr( file );
44 else if ( check == Datebook ) 40 else if ( check == Datebook )
45 handleDateTodo( file ); 41 handleDateTodo( file );
46 else 42 else
47 handleOther( file ); 43 handleOther( file );
48} 44}
49void Receiver::handleAddr( const QString& str ) { 45void Receiver::handleAddr( const QString& str ) {
50 QCopEnvelope e("QPE/Application/addressbook", "setDocument(QString)" ); 46 QCopEnvelope e("QPE/Application/addressbook", "setDocument(QString)" );
51 e << str; 47 e << str;
52} 48}
53/* we can not say for sure if it's a VEevent ot VTodo */ 49/* we can not say for sure if it's a VEevent ot VTodo */
54void Receiver::handleDateTodo( const QString& str ) { 50void Receiver::handleDateTodo( const QString& str ) {
55 QCopEnvelope e0("QPE/Application/todolist", "setDocument(QString)"); 51 QCopEnvelope e0("QPE/Application/todolist", "setDocument(QString)");
56 e0 << str; 52 e0 << str;
57 QCopEnvelope e1("QPE/Application/datebook", "setDocument(QString)" ); 53 QCopEnvelope e1("QPE/Application/datebook", "setDocument(QString)" );
58 e1 << str; 54 e1 << str;
59} 55}
60/* 56/*
61 * Handle other asks if it should accept the 57 * Handle other asks if it should accept the
62 * beamed object and creates a DocLnk 58 * beamed object and creates a DocLnk
63 */ 59 */
64void Receiver::handleOther( const QString& other ) { 60void Receiver::handleOther( const QString& other ) {
65 OtherHandler* hand = new OtherHandler(); 61 OtherHandler* hand = new OtherHandler();
66 hand->handle( other ); 62 hand->handle( other );
67} 63}
68void Receiver::tidyUp( QString& _file, const QString& ending) { 64void Receiver::tidyUp( QString& _file, const QString& ending) {
69 /* libversit fails on BASE64 encoding we try to sed it away */ 65 /* libversit fails on BASE64 encoding we try to sed it away */
70 QString file = _file; 66 QString file = _file;
71 char foo[24]; // big enough 67 char foo[24]; // big enough
72 (void)::strcpy(foo, "/tmp/opie-XXXXXX"); 68 (void)::strcpy(foo, "/tmp/opie-XXXXXX");
73 69
74 int fd = ::mkstemp(foo); 70 int fd = ::mkstemp(foo);
75 71
76 if ( fd == -1 ) 72 if ( fd == -1 )
77 return; 73 return;
78 74
79 (void)::strncat( foo, ending.latin1(), 4 ); 75 (void)::strncat( foo, ending.latin1(), 4 );
80 _file = QString::fromLatin1( foo ); 76 _file = QString::fromLatin1( foo );
81 QString cmd = QString("sed -e \"s/^\\(X-MICROSOFT-BODYINK\\)\\;/\\1:/;\" < %2 > %2 ").arg( Global::shellQuote(file)).arg( Global::shellQuote(_file) ); 77 QString cmd = QString("sed -e \"s/^\\(X-MICROSOFT-BODYINK\\)\\;/\\1:/;\" < %2 > %2 ").arg( Global::shellQuote(file)).arg( Global::shellQuote(_file) );
82 qWarning("Executing: %s", cmd.latin1() ); 78 qWarning("Executing: %s", cmd.latin1() );
83 (void)::system( cmd.latin1() ); 79 (void)::system( cmd.latin1() );
84 80
85 cmd = QString("rm %1").arg( Global::shellQuote(file) ); 81 cmd = QString("rm %1").arg( Global::shellQuote(file) );
86 (void)::system( cmd.latin1() ); 82 (void)::system( cmd.latin1() );
87} 83}
88int Receiver::checkFile( QString& file ) { 84int Receiver::checkFile( QString& file ) {
89 qWarning("check file!! %s", file.latin1() ); 85 qWarning("check file!! %s", file.latin1() );
90 int ret; 86 int ret;
91 QString ending; 87 QString ending;
92 88
93 if (file.right(4) == ".vcs" ) { 89 if (file.right(4) == ".vcs" ) {
94 ret = Datebook; 90 ret = Datebook;
95 ending = QString::fromLatin1(".vcs"); 91 ending = QString::fromLatin1(".vcs");
96 }else if ( file.right(4) == ".vcf") { 92 }else if ( file.right(4) == ".vcf") {
97 ret = AddressBook; 93 ret = AddressBook;
98 ending = QString::fromLatin1(".vcf"); 94 ending = QString::fromLatin1(".vcf");
99 }else 95 }else
100 ret = Other; 96 ret = Other;
101 97
102 98
103 if (ending.isEmpty() ) 99 if (ending.isEmpty() )
104 return ret; 100 return ret;
105 101
106 /** 102 /**
107 * currently the parser is broken in regard of BASE64 encoding 103 * currently the parser is broken in regard of BASE64 encoding
108 * and M$ likes to send that. So we will executed a small 104 * and M$ likes to send that. So we will executed a small
109 * tidy up system sed script 105 * tidy up system sed script
110 * At this point we can also remove umlaute from the filename 106 * At this point we can also remove umlaute from the filename
111 */ 107 */
112 tidyUp( file, ending ); 108 tidyUp( file, ending );
113 109
114 qWarning("check it now %d", ret ); 110 qWarning("check it now %d", ret );
115 return ret; 111 return ret;
116} 112}
117 113
118/* TRANSLATOR OpieObex::OtherHandler */ 114/* TRANSLATOR OpieObex::OtherHandler */
119 115
120OtherHandler::OtherHandler() 116OtherHandler::OtherHandler()
121 : QVBox() 117 : QVBox()
122{ 118{
123 QHBox* box = new QHBox(this); 119 QHBox* box = new QHBox(this);
124 QLabel* lbl = new QLabel(box); 120 QLabel* lbl = new QLabel(box);
125 lbl->setText(tr("<qt><b>Received:</b></qt>")); 121 lbl->setText(tr("<qt><b>Received:</b></qt>"));
126 m_na = new QLabel(box); 122 m_na = new QLabel(box);
127 123
128 QFrame* frame = new QFrame(this); 124 QFrame* frame = new QFrame(this);
129 frame->setFrameShape( QFrame::HLine ); 125 frame->setFrameShape( QFrame::HLine );
130 frame->setFrameShadow( QFrame::Sunken ); 126 frame->setFrameShadow( QFrame::Sunken );
131 127
132 m_view = new QTextView(this); 128 m_view = new QTextView(this);
133 129
134 box = new QHBox(this); 130 box = new QHBox(this);
135 QPushButton *but = new QPushButton(box); 131 QPushButton *but = new QPushButton(box);
136 but->setText(tr("Accept") ); 132 but->setText(tr("Accept") );
137 connect(but, SIGNAL(clicked() ), 133 connect(but, SIGNAL(clicked() ),
138 this, SLOT(accept()) ); 134 this, SLOT(accept()) );
139 135
140 but = new QPushButton(box); 136 but = new QPushButton(box);
141 but->setText(tr("Deny") ); 137 but->setText(tr("Deny") );
142 connect(but, SIGNAL(clicked() ), 138 connect(but, SIGNAL(clicked() ),
143 this, SLOT(deny() ) ); 139 this, SLOT(deny() ) );
144 140
145 raise(); 141 raise();
146 showMaximized(); 142 showMaximized();
147} 143}
148OtherHandler::~OtherHandler() { 144OtherHandler::~OtherHandler() {
149 145
150} 146}
151void OtherHandler::handle( const QString& file ) { 147void OtherHandler::handle( const QString& file ) {
152 m_file = file; 148 m_file = file;
153 m_na->setText(file); 149 m_na->setText(file);
154 DocLnk lnk(file); 150 DocLnk lnk(file);
155 qWarning(" %s %s", lnk.type().latin1(), lnk.icon().latin1() ); 151 qWarning(" %s %s", lnk.type().latin1(), lnk.icon().latin1() );
156 152
157 QString str = tr("<p>You received a file of type %1 (<img src=\"%2\"> )What do you want to do?").arg(lnk.type() ).arg(lnk.icon() ); 153 QString str = tr("<p>You received a file of type %1 (<img src=\"%2\"> )What do you want to do?").arg(lnk.type() ).arg(lnk.icon() );
158 m_view->setText( str ); 154 m_view->setText( str );
159} 155}
160 156
161/* 157/*
162 * hehe evil evil mmap ahead :) 158 * hehe evil evil mmap ahead :)
163 * we quickly copy the file and then we'll create a DocLnk for it 159 * we quickly copy the file and then we'll create a DocLnk for it
164 */ 160 */
165void OtherHandler::accept() { 161void OtherHandler::accept() {
166 QString na = targetName( m_file ); 162 QString na = targetName( m_file );
167 copy(m_file, na ); 163 copy(m_file, na );
168 DocLnk lnk(na); 164 DocLnk lnk(na);
169 lnk.writeLink(); 165 lnk.writeLink();
170 QFile::remove(m_file); 166 QFile::remove(m_file);
171 delete this; 167 delete this;
172} 168}
173void OtherHandler::deny() { 169void OtherHandler::deny() {
174 QFile::remove( m_file ); 170 QFile::remove( m_file );
175 delete this; 171 delete this;
176} 172}
177QString OtherHandler::targetName( const QString& file ) { 173QString OtherHandler::targetName( const QString& file ) {
178 QFileInfo info( file ); 174 QFileInfo info( file );
179 175
180 /* $HOME needs to be set!!!! */ 176 /* $HOME needs to be set!!!! */
181 Global::createDocDir(); 177 Global::createDocDir();
182 178
183 QString newFile = QPEApplication::documentDir()+ "/"+ info.baseName(); 179 QString newFile = QPEApplication::documentDir()+ "/"+ info.baseName();
184 QString newFileBase = newFile; 180 QString newFileBase = newFile;
185 181
186 int trie = 0; 182 int trie = 0;
187 while (QFile::exists(newFile + "."+info.extension() ) ) { 183 while (QFile::exists(newFile + "."+info.extension() ) ) {
188 newFile = newFileBase + "_"+QString::number(trie) ; 184 newFile = newFileBase + "_"+QString::number(trie) ;
189 trie++; 185 trie++;
190 } 186 }
191 newFile += "." + info.extension(); 187 newFile += "." + info.extension();
192 188
193 return newFile; 189 return newFile;
194} 190}
195 191
196/* fast cpy */ 192/* fast cpy */
197void OtherHandler::copy(const QString& src, const QString& file) { 193void OtherHandler::copy(const QString& src, const QString& file) {
198 qWarning("src %s, dest %s", src.latin1(),file.latin1() ); 194 qWarning("src %s, dest %s", src.latin1(),file.latin1() );
199 QString cmd = QString("mv %1 %2").arg( Global::shellQuote( src )). 195 QString cmd = QString("mv %1 %2").arg( Global::shellQuote( src )).
200 arg( Global::shellQuote( file ) ); 196 arg( Global::shellQuote( file ) );
201 ::system( cmd.latin1() ); 197 ::system( cmd.latin1() );
202 // done 198 // done
203} 199}