00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include <qpixmap.h>
00031 #include <qstring.h>
00032
00033 #include <qpe/qcopenvelope_qws.h>
00034 #include <opie2/odevicebutton.h>
00035
00036
00037 namespace Opie {
00038 namespace Core {
00039 namespace Internal {
00040
00041 class OQCopMessageData
00042 {
00043 public:
00044 QCString m_channel;
00045 QCString m_message;
00046 QByteArray m_data;
00047 };
00048 }
00049
00050 using namespace Opie::Core;
00051 using Opie::Core::Internal::OQCopMessageData;
00052
00053 OQCopMessage::OQCopMessage()
00054 : d ( 0 )
00055 {
00056 init ( QCString(), QCString(), QByteArray());
00057 }
00058
00059 OQCopMessage::OQCopMessage ( const OQCopMessage © )
00060 : d ( 0 )
00061 {
00062 init ( copy. channel(), copy. message(), copy. data());
00063 }
00064
00065 OQCopMessage &OQCopMessage::operator = ( const OQCopMessage &assign )
00066 {
00067 init ( assign. channel(), assign. message(), assign. data());
00068 return *this;
00069 }
00070
00071 OQCopMessage::OQCopMessage ( const QCString &ch, const QCString &m, const QByteArray &arg )
00072 : d ( 0 )
00073 {
00074 init ( ch, m, arg );
00075 }
00076
00077 void OQCopMessage::init ( const QCString &ch, const QCString &m, const QByteArray &arg )
00078 {
00079 if ( !d )
00080 d = new OQCopMessageData();
00081 d->m_channel = ch;
00082 d->m_message = m;
00083 d->m_data = arg;
00084 }
00085
00086 bool OQCopMessage::send()
00087 {
00088 if ( d->m_channel. isEmpty() || d->m_message. isEmpty() )
00089 return false;
00090
00091 QCopEnvelope e ( d->m_channel, d->m_message );
00092
00093 if ( d->m_data. size())
00094 e. writeRawBytes ( d->m_data. data(), d->m_data. size());
00095
00096 return true;
00097 }
00098
00099 QCString OQCopMessage::channel() const
00100 {
00101 return d->m_channel;
00102 }
00103
00104 QCString OQCopMessage::message() const
00105 {
00106 return d->m_message;
00107 }
00108
00109 QByteArray OQCopMessage::data() const
00110 {
00111 return d->m_data;
00112 }
00113
00114 bool OQCopMessage::isNull() const
00115 {
00116 return d->m_message.isNull() || d->m_channel.isNull();
00117 }
00118 void OQCopMessage::setChannel ( const QCString &ch )
00119 {
00120 d->m_channel = ch;
00121 }
00122
00123 void OQCopMessage::setMessage ( const QCString &m )
00124 {
00125 d->m_message = m;
00126 }
00127
00128 void OQCopMessage::setData ( const QByteArray &data )
00129 {
00130 d->m_data = data;
00131 }
00132
00146 ODeviceButton::ODeviceButton()
00147 {}
00148
00149 ODeviceButton::~ODeviceButton()
00150 {}
00151
00155 ushort ODeviceButton::keycode() const
00156 {
00157 return m_Keycode;
00158 }
00159
00160
00164 QString ODeviceButton::userText() const
00165 {
00166 return m_UserText;
00167 }
00168
00173 QPixmap ODeviceButton::pixmap() const
00174 {
00175 return m_Pixmap;
00176 }
00177
00182 OQCopMessage ODeviceButton::factoryPresetPressedAction() const
00183 {
00184 return m_FactoryPresetPressedAction;
00185 }
00186
00191 OQCopMessage ODeviceButton::pressedAction() const
00192 {
00193 if (m_PressedAction.channel().isEmpty())
00194 return factoryPresetPressedAction();
00195 return m_PressedAction;
00196 }
00197
00202 OQCopMessage ODeviceButton::factoryPresetHeldAction() const
00203 {
00204 return m_FactoryPresetHeldAction;
00205 }
00206
00211 OQCopMessage ODeviceButton::heldAction() const
00212 {
00213 if (m_HeldAction.channel().isEmpty())
00214 return factoryPresetHeldAction();
00215 return m_HeldAction;
00216 }
00217
00218 void ODeviceButton::setKeycode(ushort keycode)
00219 {
00220 m_Keycode = keycode;
00221 }
00222
00223 void ODeviceButton::setUserText(const QString& text)
00224 {
00225 m_UserText = text;
00226 }
00227
00228 void ODeviceButton::setPixmap(const QPixmap& picture)
00229 {
00230 m_Pixmap = picture;
00231 }
00232
00233 void ODeviceButton::setFactoryPresetPressedAction(const OQCopMessage& action)
00234 {
00235 m_FactoryPresetPressedAction = action;
00236 }
00237
00238
00239 void ODeviceButton::setPressedAction(const OQCopMessage& action)
00240 {
00241 m_PressedAction = action;
00242 }
00243
00244 void ODeviceButton::setFactoryPresetHeldAction(const OQCopMessage& action)
00245 {
00246 m_FactoryPresetHeldAction = action;
00247 }
00248
00249 void ODeviceButton::setHeldAction(const OQCopMessage& action)
00250 {
00251 m_HeldAction = action;
00252 }
00253
00254 }
00255 }