summaryrefslogtreecommitdiff
path: root/libopie/odevicebutton.cpp
Unidiff
Diffstat (limited to 'libopie/odevicebutton.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevicebutton.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/libopie/odevicebutton.cpp b/libopie/odevicebutton.cpp
index 2270343..4b22358 100644
--- a/libopie/odevicebutton.cpp
+++ b/libopie/odevicebutton.cpp
@@ -1,234 +1,235 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the 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 <qpixmap.h> 21#include <qpixmap.h>
22#include <qstring.h> 22#include <qstring.h>
23 23
24#include <qpe/qcopenvelope_qws.h> 24#include <qpe/qcopenvelope_qws.h>
25#include <opie/odevicebutton.h> 25#include <opie/odevicebutton.h>
26 26
27using namespace Opie; 27using namespace Opie;
28 28
29 29
30class OQCopMessageData { 30class OQCopMessageData {
31 public: 31 public:
32 QCString m_channel; 32 QCString m_channel;
33 QCString m_message; 33 QCString m_message;
34 QByteArray m_data; 34 QByteArray m_data;
35}; 35};
36 36
37 37
38OQCopMessage::OQCopMessage ( ) 38OQCopMessage::OQCopMessage ( )
39 : d ( 0 ) 39 : d ( 0 )
40{ 40{
41 init ( QCString ( ), QCString ( ), QByteArray ( )); 41 init ( QCString ( ), QCString ( ), QByteArray ( ));
42} 42}
43 43
44OQCopMessage::OQCopMessage ( const OQCopMessage &copy ) 44OQCopMessage::OQCopMessage ( const OQCopMessage &copy )
45 : d ( 0 ) 45 : d ( 0 )
46{ 46{
47 init ( copy. channel ( ), copy. message ( ), copy. data ( )); 47 init ( copy. channel ( ), copy. message ( ), copy. data ( ));
48} 48}
49 49
50OQCopMessage &OQCopMessage::operator = ( const OQCopMessage &assign ) 50OQCopMessage &OQCopMessage::operator = ( const OQCopMessage &assign )
51{ 51{
52 init ( assign. channel ( ), assign. message ( ), assign. data ( )); 52 init ( assign. channel ( ), assign. message ( ), assign. data ( ));
53 return *this; 53 return *this;
54} 54}
55 55
56OQCopMessage::OQCopMessage ( const QCString &ch, const QCString &m, const QByteArray &arg ) 56OQCopMessage::OQCopMessage ( const QCString &ch, const QCString &m, const QByteArray &arg )
57 : d ( 0 ) 57 : d ( 0 )
58{ 58{
59 init ( ch, m, arg ); 59 init ( ch, m, arg );
60} 60}
61 61
62void OQCopMessage::init ( const QCString &ch, const QCString &m, const QByteArray &arg ) 62void OQCopMessage::init ( const QCString &ch, const QCString &m, const QByteArray &arg )
63{ 63{
64 if ( !d ) 64 if ( !d )
65 d = new OQCopMessageData ( ); 65 d = new OQCopMessageData ( );
66 d-> m_channel = ch; 66 d-> m_channel = ch;
67 d-> m_message = m; 67 d-> m_message = m;
68 d-> m_data = arg; 68 d-> m_data = arg;
69} 69}
70 70
71bool OQCopMessage::send ( ) 71bool OQCopMessage::send ( )
72{ 72{
73 if ( d-> m_channel. isEmpty ( ) || d-> m_message. isEmpty ( )) 73 if ( d-> m_channel. isEmpty ( ) || d-> m_message. isEmpty ( ) )
74 return false; 74 return false;
75 75
76 QCopEnvelope e ( d-> m_channel, d-> m_message ); 76 QCopEnvelope e ( d-> m_channel, d-> m_message );
77 77
78 if ( d-> m_data. size ( )) 78 if ( d-> m_data. size ( ))
79 e. writeRawBytes ( d-> m_data. data ( ), d-> m_data. size ( )); 79 e. writeRawBytes ( d-> m_data. data ( ), d-> m_data. size ( ));
80 80
81 return true; 81 return true;
82} 82}
83 83
84QCString OQCopMessage::channel ( ) const 84QCString OQCopMessage::channel ( ) const
85{ 85{
86 return d-> m_channel; 86 return d-> m_channel;
87} 87}
88 88
89QCString OQCopMessage::message ( ) const 89QCString OQCopMessage::message ( ) const
90{ 90{
91 return d-> m_message; 91 return d-> m_message;
92} 92}
93 93
94QByteArray OQCopMessage::data ( ) const 94QByteArray OQCopMessage::data ( ) const
95{ 95{
96 return d-> m_data; 96 return d-> m_data;
97} 97}
98 98
99void OQCopMessage::setChannel ( const QCString &ch ) 99void OQCopMessage::setChannel ( const QCString &ch )
100{ 100{
101 d-> m_channel = ch; 101 d-> m_channel = ch;
102} 102}
103 103
104void OQCopMessage::setMessage ( const QCString &m ) 104void OQCopMessage::setMessage ( const QCString &m )
105{ 105{
106 d-> m_message = m; 106 d-> m_message = m;
107} 107}
108 108
109void OQCopMessage::setData ( const QByteArray &data ) 109void OQCopMessage::setData ( const QByteArray &data )
110{ 110{
111 d-> m_data = data; 111 d-> m_data = data;
112} 112}
113 113
114/*! \class ODeviceButton 114/*! \class ODeviceButton
115 \brief The ODeviceButton class represents a physical user mappable button on a Qtopia device. 115 \brief The ODeviceButton class represents a physical user mappable button on a Qtopia device.
116 116
117 This class represents a physical button on a Qtopia device. A 117 This class represents a physical button on a Qtopia device. A
118 device may have "user programmable" buttons. 118 device may have "user programmable" buttons.
119 The location and number of buttons will vary from device to 119 The location and number of buttons will vary from device to
120 device. userText() and pixmap() may be used to describe this button 120 device. userText() and pixmap() may be used to describe this button
121 to the user in help documentation. 121 to the user in help documentation.
122 122
123 \ingroup qtopiaemb 123 \ingroup qtopiaemb
124 \internal 124 \internal
125*/ 125*/
126 126
127ODeviceButton::ODeviceButton() 127ODeviceButton::ODeviceButton()
128{ 128{
129} 129}
130 130
131ODeviceButton::~ODeviceButton() 131ODeviceButton::~ODeviceButton()
132{ 132{
133} 133}
134 134
135/*! 135/*!
136 Returns the button's keycode. 136 Returns the button's keycode.
137 */ 137 */
138ushort ODeviceButton::keycode() const 138ushort ODeviceButton::keycode() const
139{ 139{
140 return m_Keycode; 140 return m_Keycode;
141} 141}
142 142
143 143
144/*! 144/*!
145 This function returns a human readable, translated description of the button. 145 This function returns a human readable, translated description of the button.
146 */ 146 */
147QString ODeviceButton::userText() const 147QString ODeviceButton::userText() const
148{ 148{
149 return m_UserText; 149 return m_UserText;
150} 150}
151 151
152/*! 152/*!
153 This function returns the pixmap for this button. If there isn't one 153 This function returns the pixmap for this button. If there isn't one
154 it will return an empty (null) pixmap. 154 it will return an empty (null) pixmap.
155 */ 155 */
156QPixmap ODeviceButton::pixmap() const 156QPixmap ODeviceButton::pixmap() const
157{ 157{
158 return m_Pixmap; 158 return m_Pixmap;
159} 159}
160 160
161/*! 161/*!
162 This function returns the factory preset (default) action for when this button 162 This function returns the factory preset (default) action for when this button
163 is pressed. The return value is a legal QCop message. 163 is pressed. The return value is a legal QCop message.
164 */ 164 */
165OQCopMessage ODeviceButton::factoryPresetPressedAction() const 165OQCopMessage ODeviceButton::factoryPresetPressedAction() const
166{ 166{
167 return m_FactoryPresetPressedAction; 167 return m_FactoryPresetPressedAction;
168} 168}
169 169
170/*! 170/*!
171 This function returns the user assigned action for when this button is pressed. 171 This function returns the user assigned action for when this button is pressed.
172 If no action is assigned, factoryPresetAction() is returned. 172 If no action is assigned, factoryPresetAction() is returned.
173 */ 173 */
174OQCopMessage ODeviceButton::pressedAction() const 174OQCopMessage ODeviceButton::pressedAction() const
175{ 175{
176 if (m_PressedAction.channel().isEmpty()) 176 if (m_PressedAction.channel().isEmpty())
177 return factoryPresetPressedAction(); 177 return factoryPresetPressedAction();
178 return m_PressedAction; 178 return m_PressedAction;
179} 179}
180 180
181/*! 181/*!
182 This function returns the factory preset (default) action for when this button 182 This function returns the factory preset (default) action for when this button
183 is pressed and held. The return value is a legal QCop message. 183 is pressed and held. The return value is a legal QCop message.
184 */ 184 */
185OQCopMessage ODeviceButton::factoryPresetHeldAction() const 185OQCopMessage ODeviceButton::factoryPresetHeldAction() const
186{ 186{
187 return m_FactoryPresetHeldAction; 187 return m_FactoryPresetHeldAction;
188} 188}
189 189
190/*! 190/*!
191 This function returns the user assigned action for when this button is pressed 191 This function returns the user assigned action for when this button is pressed
192 and held. If no action is assigned, factoryPresetAction() is returned. 192 and held. If no action is assigned, factoryPresetAction() is returned.
193 */ 193 */
194OQCopMessage ODeviceButton::heldAction() const 194OQCopMessage ODeviceButton::heldAction() const
195{ 195{
196 if (m_HeldAction.channel().isEmpty()) 196 if (m_HeldAction.channel().isEmpty())
197 return factoryPresetHeldAction(); 197 return factoryPresetHeldAction();
198 return m_HeldAction; 198 return m_HeldAction;
199} 199}
200 200
201void ODeviceButton::setKeycode(ushort keycode) 201void ODeviceButton::setKeycode(ushort keycode)
202{ 202{
203 m_Keycode = keycode; 203 m_Keycode = keycode;
204} 204}
205 205
206void ODeviceButton::setUserText(const QString& text) 206void ODeviceButton::setUserText(const QString& text)
207{ 207{
208 m_UserText = text; 208 m_UserText = text;
209} 209}
210 210
211void ODeviceButton::setPixmap(const QPixmap& picture) 211void ODeviceButton::setPixmap(const QPixmap& picture)
212{ 212{
213 m_Pixmap = picture; 213 m_Pixmap = picture;
214} 214}
215 215
216void ODeviceButton::setFactoryPresetPressedAction(const OQCopMessage& action) 216void ODeviceButton::setFactoryPresetPressedAction(const OQCopMessage& action)
217{ 217{
218 m_FactoryPresetPressedAction = action; 218 m_FactoryPresetPressedAction = action;
219} 219}
220 220
221
221void ODeviceButton::setPressedAction(const OQCopMessage& action) 222void ODeviceButton::setPressedAction(const OQCopMessage& action)
222{ 223{
223 m_PressedAction = action; 224 m_PressedAction = action;
224} 225}
225 226
226void ODeviceButton::setFactoryPresetHeldAction(const OQCopMessage& action) 227void ODeviceButton::setFactoryPresetHeldAction(const OQCopMessage& action)
227{ 228{
228 m_FactoryPresetHeldAction = action; 229 m_FactoryPresetHeldAction = action;
229} 230}
230 231
231void ODeviceButton::setHeldAction(const OQCopMessage& action) 232void ODeviceButton::setHeldAction(const OQCopMessage& action)
232{ 233{
233 m_HeldAction = action; 234 m_HeldAction = action;
234} 235}