author | mickeyl <mickeyl> | 2004-01-13 15:21:40 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-01-13 15:21:40 (UTC) |
commit | af79bda4c7e51f46abe67124f9c06126eaebb59d (patch) (unidiff) | |
tree | 4e9ad77ec4b2bb3d66ac6553d0a225b0b18f2140 /libopie2/opiecore/device/odevicebutton.cpp | |
parent | 24eb97ec5cda3d72c3541fd120568b8d937025f8 (diff) | |
download | opie-af79bda4c7e51f46abe67124f9c06126eaebb59d.zip opie-af79bda4c7e51f46abe67124f9c06126eaebb59d.tar.gz opie-af79bda4c7e51f46abe67124f9c06126eaebb59d.tar.bz2 |
- split odevice into dedicated files and classes, it has getting much too large
- merge odevice into libopie2
- merge oprocctrl and oprocess into libopie2
Diffstat (limited to 'libopie2/opiecore/device/odevicebutton.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiecore/device/odevicebutton.cpp | 246 |
1 files changed, 246 insertions, 0 deletions
diff --git a/libopie2/opiecore/device/odevicebutton.cpp b/libopie2/opiecore/device/odevicebutton.cpp new file mode 100644 index 0000000..0b593d5 --- a/dev/null +++ b/libopie2/opiecore/device/odevicebutton.cpp | |||
@@ -0,0 +1,246 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
4 | =. | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
29 | |||
30 | #include <qpixmap.h> | ||
31 | #include <qstring.h> | ||
32 | |||
33 | #include <qpe/qcopenvelope_qws.h> | ||
34 | #include <opie2/odevicebutton.h> | ||
35 | |||
36 | using namespace Opie; | ||
37 | |||
38 | class OQCopMessageData | ||
39 | { | ||
40 | public: | ||
41 | QCString m_channel; | ||
42 | QCString m_message; | ||
43 | QByteArray m_data; | ||
44 | }; | ||
45 | |||
46 | |||
47 | OQCopMessage::OQCopMessage() | ||
48 | : d ( 0 ) | ||
49 | { | ||
50 | init ( QCString(), QCString(), QByteArray()); | ||
51 | } | ||
52 | |||
53 | OQCopMessage::OQCopMessage ( const OQCopMessage © ) | ||
54 | : d ( 0 ) | ||
55 | { | ||
56 | init ( copy. channel(), copy. message(), copy. data()); | ||
57 | } | ||
58 | |||
59 | OQCopMessage &OQCopMessage::operator = ( const OQCopMessage &assign ) | ||
60 | { | ||
61 | init ( assign. channel(), assign. message(), assign. data()); | ||
62 | return *this; | ||
63 | } | ||
64 | |||
65 | OQCopMessage::OQCopMessage ( const QCString &ch, const QCString &m, const QByteArray &arg ) | ||
66 | : d ( 0 ) | ||
67 | { | ||
68 | init ( ch, m, arg ); | ||
69 | } | ||
70 | |||
71 | void OQCopMessage::init ( const QCString &ch, const QCString &m, const QByteArray &arg ) | ||
72 | { | ||
73 | if ( !d ) | ||
74 | d = new OQCopMessageData(); | ||
75 | d->m_channel = ch; | ||
76 | d->m_message = m; | ||
77 | d->m_data = arg; | ||
78 | } | ||
79 | |||
80 | bool OQCopMessage::send() | ||
81 | { | ||
82 | if ( d->m_channel. isEmpty() || d->m_message. isEmpty() ) | ||
83 | return false; | ||
84 | |||
85 | QCopEnvelope e ( d->m_channel, d->m_message ); | ||
86 | |||
87 | if ( d->m_data. size()) | ||
88 | e. writeRawBytes ( d->m_data. data(), d->m_data. size()); | ||
89 | |||
90 | return true; | ||
91 | } | ||
92 | |||
93 | QCString OQCopMessage::channel() const | ||
94 | { | ||
95 | return d->m_channel; | ||
96 | } | ||
97 | |||
98 | QCString OQCopMessage::message() const | ||
99 | { | ||
100 | return d->m_message; | ||
101 | } | ||
102 | |||
103 | QByteArray OQCopMessage::data() const | ||
104 | { | ||
105 | return d->m_data; | ||
106 | } | ||
107 | |||
108 | bool OQCopMessage::isNull() const | ||
109 | { | ||
110 | return d->m_message.isNull() || d->m_channel.isNull(); | ||
111 | } | ||
112 | void OQCopMessage::setChannel ( const QCString &ch ) | ||
113 | { | ||
114 | d->m_channel = ch; | ||
115 | } | ||
116 | |||
117 | void OQCopMessage::setMessage ( const QCString &m ) | ||
118 | { | ||
119 | d->m_message = m; | ||
120 | } | ||
121 | |||
122 | void OQCopMessage::setData ( const QByteArray &data ) | ||
123 | { | ||
124 | d->m_data = data; | ||
125 | } | ||
126 | |||
127 | /*! \class Opie::ODeviceButton | ||
128 | \brief The Opie::ODeviceButton class represents a physical user mappable button on a Qtopia device. | ||
129 | |||
130 | This class represents a physical button on a Qtopia device. A | ||
131 | device may have "user programmable" buttons. | ||
132 | The location and number of buttons will vary from device to | ||
133 | device. userText() and pixmap() may be used to describe this button | ||
134 | to the user in help documentation. | ||
135 | |||
136 | \ingroup qtopiaemb | ||
137 | \internal | ||
138 | */ | ||
139 | |||
140 | ODeviceButton::ODeviceButton() | ||
141 | {} | ||
142 | |||
143 | ODeviceButton::~ODeviceButton() | ||
144 | {} | ||
145 | |||
146 | /*! | ||
147 | Returns the button's keycode. | ||
148 | */ | ||
149 | ushort ODeviceButton::keycode() const | ||
150 | { | ||
151 | return m_Keycode; | ||
152 | } | ||
153 | |||
154 | |||
155 | /*! | ||
156 | This function returns a human readable, translated description of the button. | ||
157 | */ | ||
158 | QString ODeviceButton::userText() const | ||
159 | { | ||
160 | return m_UserText; | ||
161 | } | ||
162 | |||
163 | /*! | ||
164 | This function returns the pixmap for this button. If there isn't one | ||
165 | it will return an empty (null) pixmap. | ||
166 | */ | ||
167 | QPixmap ODeviceButton::pixmap() const | ||
168 | { | ||
169 | return m_Pixmap; | ||
170 | } | ||
171 | |||
172 | /*! | ||
173 | This function returns the factory preset (default) action for when this button | ||
174 | is pressed. The return value is a legal QCop message. | ||
175 | */ | ||
176 | OQCopMessage ODeviceButton::factoryPresetPressedAction() const | ||
177 | { | ||
178 | return m_FactoryPresetPressedAction; | ||
179 | } | ||
180 | |||
181 | /*! | ||
182 | This function returns the user assigned action for when this button is pressed. | ||
183 | If no action is assigned, factoryPresetAction() is returned. | ||
184 | */ | ||
185 | OQCopMessage ODeviceButton::pressedAction() const | ||
186 | { | ||
187 | if (m_PressedAction.channel().isEmpty()) | ||
188 | return factoryPresetPressedAction(); | ||
189 | return m_PressedAction; | ||
190 | } | ||
191 | |||
192 | /*! | ||
193 | This function returns the factory preset (default) action for when this button | ||
194 | is pressed and held. The return value is a legal QCop message. | ||
195 | */ | ||
196 | OQCopMessage ODeviceButton::factoryPresetHeldAction() const | ||
197 | { | ||
198 | return m_FactoryPresetHeldAction; | ||
199 | } | ||
200 | |||
201 | /*! | ||
202 | This function returns the user assigned action for when this button is pressed | ||
203 | and held. If no action is assigned, factoryPresetAction() is returned. | ||
204 | */ | ||
205 | OQCopMessage ODeviceButton::heldAction() const | ||
206 | { | ||
207 | if (m_HeldAction.channel().isEmpty()) | ||
208 | return factoryPresetHeldAction(); | ||
209 | return m_HeldAction; | ||
210 | } | ||
211 | |||
212 | void ODeviceButton::setKeycode(ushort keycode) | ||
213 | { | ||
214 | m_Keycode = keycode; | ||
215 | } | ||
216 | |||
217 | void ODeviceButton::setUserText(const QString& text) | ||
218 | { | ||
219 | m_UserText = text; | ||
220 | } | ||
221 | |||
222 | void ODeviceButton::setPixmap(const QPixmap& picture) | ||
223 | { | ||
224 | m_Pixmap = picture; | ||
225 | } | ||
226 | |||
227 | void ODeviceButton::setFactoryPresetPressedAction(const OQCopMessage& action) | ||
228 | { | ||
229 | m_FactoryPresetPressedAction = action; | ||
230 | } | ||
231 | |||
232 | |||
233 | void ODeviceButton::setPressedAction(const OQCopMessage& action) | ||
234 | { | ||
235 | m_PressedAction = action; | ||
236 | } | ||
237 | |||
238 | void ODeviceButton::setFactoryPresetHeldAction(const OQCopMessage& action) | ||
239 | { | ||
240 | m_FactoryPresetHeldAction = action; | ||
241 | } | ||
242 | |||
243 | void ODeviceButton::setHeldAction(const OQCopMessage& action) | ||
244 | { | ||
245 | m_HeldAction = action; | ||
246 | } | ||