author | drw <drw> | 2005-04-05 23:01:28 (UTC) |
---|---|---|
committer | drw <drw> | 2005-04-05 23:01:28 (UTC) |
commit | 2b0e27b45eb9ff5563f786c5e45d53db49afb9f9 (patch) (unidiff) | |
tree | e5dfb23aa8e0e3778b5fa1f5633f6511789f41f2 /libopie2/opiecore/device/odevice_jornada.cpp | |
parent | 2a9ee3ea1d8d978b735f0ce3f2e54a15e37c87b3 (diff) | |
download | opie-2b0e27b45eb9ff5563f786c5e45d53db49afb9f9.zip opie-2b0e27b45eb9ff5563f786c5e45d53db49afb9f9.tar.gz opie-2b0e27b45eb9ff5563f786c5e45d53db49afb9f9.tar.bz2 |
Use OResource for loading images
Diffstat (limited to 'libopie2/opiecore/device/odevice_jornada.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiecore/device/odevice_jornada.cpp | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/libopie2/opiecore/device/odevice_jornada.cpp b/libopie2/opiecore/device/odevice_jornada.cpp index 3acba03..7dbde48 100644 --- a/libopie2/opiecore/device/odevice_jornada.cpp +++ b/libopie2/opiecore/device/odevice_jornada.cpp | |||
@@ -1,67 +1,69 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | |
4 | Copyright (C)2002-2005 The Opie Team <opie-devel@handhelds.org> | ||
4 | =. | 5 | =. |
5 | .=l. | 6 | .=l. |
6 | .>+-= | 7 | Â Â Â Â Â Â .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
13 | .%`+i> _;_. | 14 | Â Â .%`+i> Â Â Â _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
20 | ++= -. .` .: details. | 21 | ++= Â -. Â Â .` Â Â .: details. |
21 | : = ...= . :.=- | 22 | : Â Â = Â ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
28 | */ | 29 | */ |
29 | 30 | ||
30 | #include "odevice_jornada.h" | 31 | #include "odevice_jornada.h" |
31 | 32 | ||
32 | /* QT */ | 33 | /* QT */ |
33 | #include <qapplication.h> | 34 | #include <qapplication.h> |
34 | #include <qfile.h> | 35 | #include <qfile.h> |
35 | #include <qtextstream.h> | 36 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 37 | #include <qwindowsystem_qws.h> |
37 | 38 | ||
38 | /* OPIE */ | 39 | /* OPIE */ |
39 | #include <qpe/config.h> | 40 | #include <qpe/config.h> |
40 | #include <qpe/resource.h> | ||
41 | #include <qpe/sound.h> | 41 | #include <qpe/sound.h> |
42 | #include <qpe/qcopenvelope_qws.h> | 42 | #include <qpe/qcopenvelope_qws.h> |
43 | 43 | ||
44 | #include <opie2/oresource.h> | ||
45 | |||
44 | /* STD */ | 46 | /* STD */ |
45 | #include <fcntl.h> | 47 | #include <fcntl.h> |
46 | #include <math.h> | 48 | #include <math.h> |
47 | #include <stdlib.h> | 49 | #include <stdlib.h> |
48 | #include <signal.h> | 50 | #include <signal.h> |
49 | #include <sys/ioctl.h> | 51 | #include <sys/ioctl.h> |
50 | #include <sys/time.h> | 52 | #include <sys/time.h> |
51 | #include <unistd.h> | 53 | #include <unistd.h> |
52 | #ifndef QT_NO_SOUND | 54 | #ifndef QT_NO_SOUND |
53 | #include <linux/soundcard.h> | 55 | #include <linux/soundcard.h> |
54 | #endif | 56 | #endif |
55 | 57 | ||
56 | /* KERNEL */ | 58 | /* KERNEL */ |
57 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | 59 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) |
58 | 60 | ||
59 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 61 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
60 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | 62 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
61 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | 63 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) |
62 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | 64 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) |
63 | 65 | ||
64 | typedef struct { | 66 | typedef struct { |
65 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 67 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
66 | unsigned char TotalTime; /* Units of 5 seconds */ | 68 | unsigned char TotalTime; /* Units of 5 seconds */ |
67 | unsigned char OnTime; /* units of 100m/s */ | 69 | unsigned char OnTime; /* units of 100m/s */ |
@@ -91,83 +93,83 @@ struct j_button jornada56x_buttons [] = { | |||
91 | "devicebuttons/jornada56x_contact", | 93 | "devicebuttons/jornada56x_contact", |
92 | "addressbook", "raise()", | 94 | "addressbook", "raise()", |
93 | "addressbook", "beamBusinessCard()" }, | 95 | "addressbook", "beamBusinessCard()" }, |
94 | { Model_Jornada_56x, | 96 | { Model_Jornada_56x, |
95 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Todo Button"), | 97 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Todo Button"), |
96 | "devicebuttons/jornada56x_todo", | 98 | "devicebuttons/jornada56x_todo", |
97 | "todolist", "raise()", | 99 | "todolist", "raise()", |
98 | "todolist", "create()" }, | 100 | "todolist", "create()" }, |
99 | { Model_Jornada_56x, | 101 | { Model_Jornada_56x, |
100 | Qt::Key_F8, QT_TRANSLATE_NOOP("Button", "Home Button"), | 102 | Qt::Key_F8, QT_TRANSLATE_NOOP("Button", "Home Button"), |
101 | "devicebuttons/jornada56x_home", | 103 | "devicebuttons/jornada56x_home", |
102 | "QPE/Launcher", "home()", | 104 | "QPE/Launcher", "home()", |
103 | "buttonsettings", "raise()" }, | 105 | "buttonsettings", "raise()" }, |
104 | { Model_Jornada_56x, | 106 | { Model_Jornada_56x, |
105 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Record Button"), | 107 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Record Button"), |
106 | "devicebuttons/jornada56x_record", | 108 | "devicebuttons/jornada56x_record", |
107 | "QPE/VMemo", "toggleRecord()", | 109 | "QPE/VMemo", "toggleRecord()", |
108 | "sound", "raise()" }, | 110 | "sound", "raise()" }, |
109 | }; | 111 | }; |
110 | 112 | ||
111 | void Jornada::init(const QString& cpu_info) | 113 | void Jornada::init(const QString& cpu_info) |
112 | { | 114 | { |
113 | d->m_vendorstr = "HP"; | 115 | d->m_vendorstr = "HP"; |
114 | d->m_vendor = Vendor_HP; | 116 | d->m_vendor = Vendor_HP; |
115 | 117 | ||
116 | QString model; | 118 | QString model; |
117 | int loc = cpu_info.find( ":" ); | 119 | int loc = cpu_info.find( ":" ); |
118 | if ( loc != -1 ) | 120 | if ( loc != -1 ) |
119 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); | 121 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); |
120 | else | 122 | else |
121 | model = cpu_info; | 123 | model = cpu_info; |
122 | 124 | ||
123 | if ( model == "HP Jornada 56x" ) { | 125 | if ( model == "HP Jornada 56x" ) { |
124 | d->m_modelstr = "Jornada 56x"; | 126 | d->m_modelstr = "Jornada 56x"; |
125 | d->m_model = Model_Jornada_56x; | 127 | d->m_model = Model_Jornada_56x; |
126 | } else if ( model == "HP Jornada 720" ) { | 128 | } else if ( model == "HP Jornada 720" ) { |
127 | d->m_modelstr = "Jornada 720"; | 129 | d->m_modelstr = "Jornada 720"; |
128 | d->m_model = Model_Jornada_720; | 130 | d->m_model = Model_Jornada_720; |
129 | } | 131 | } |
130 | 132 | ||
131 | d->m_rotation = Rot0; //all Jornadas need this rotation | 133 | d->m_rotation = Rot0; //all Jornadas need this rotation |
132 | //Distribution detecting code is now in base class | 134 | //Distribution detecting code is now in base class |
133 | } | 135 | } |
134 | 136 | ||
135 | void Jornada::initButtons() | 137 | void Jornada::initButtons() |
136 | { | 138 | { |
137 | if ( d->m_buttons ) | 139 | if ( d->m_buttons ) |
138 | return; | 140 | return; |
139 | 141 | ||
140 | d->m_buttons = new QValueList <ODeviceButton>; | 142 | d->m_buttons = new QValueList <ODeviceButton>; |
141 | 143 | ||
142 | for ( uint i = 0; i < ( sizeof( jornada56x_buttons ) / sizeof( j_button )); i++ ) { | 144 | for ( uint i = 0; i < ( sizeof( jornada56x_buttons ) / sizeof( j_button )); i++ ) { |
143 | j_button *ib = jornada56x_buttons + i; | 145 | j_button *ib = jornada56x_buttons + i; |
144 | ODeviceButton b; | 146 | ODeviceButton b; |
145 | 147 | ||
146 | if (( ib->model & d->m_model ) == d->m_model ) { | 148 | if (( ib->model & d->m_model ) == d->m_model ) { |
147 | b. setKeycode ( ib->code ); | 149 | b. setKeycode ( ib->code ); |
148 | b. setUserText ( QObject::tr ( "Button", ib->utext )); | 150 | b. setUserText ( QObject::tr ( "Button", ib->utext )); |
149 | b. setPixmap ( Resource::loadPixmap ( ib->pix )); | 151 | b. setPixmap ( OResource::loadPixmap ( ib->pix )); |
150 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); | 152 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); |
151 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); | 153 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); |
152 | 154 | ||
153 | d->m_buttons->append ( b ); | 155 | d->m_buttons->append ( b ); |
154 | } | 156 | } |
155 | } | 157 | } |
156 | reloadButtonMapping(); | 158 | reloadButtonMapping(); |
157 | } | 159 | } |
158 | 160 | ||
159 | int Jornada::displayBrightnessResolution() const | 161 | int Jornada::displayBrightnessResolution() const |
160 | { | 162 | { |
161 | if ( d->m_model == Model_Jornada_56x ) | 163 | if ( d->m_model == Model_Jornada_56x ) |
162 | return 190; | 164 | return 190; |
163 | else if (d->m_model == Model_Jornada_720 ) | 165 | else if (d->m_model == Model_Jornada_720 ) |
164 | return 255; | 166 | return 255; |
165 | else | 167 | else |
166 | return 0; | 168 | return 0; |
167 | } | 169 | } |
168 | 170 | ||
169 | 171 | ||
170 | bool Jornada::setDisplayBrightness( int bright ) | 172 | bool Jornada::setDisplayBrightness( int bright ) |
171 | { | 173 | { |
172 | bool res = false; | 174 | bool res = false; |
173 | 175 | ||
@@ -176,38 +178,38 @@ bool Jornada::setDisplayBrightness( int bright ) | |||
176 | if ( bright < 0 ) | 178 | if ( bright < 0 ) |
177 | bright = 0; | 179 | bright = 0; |
178 | 180 | ||
179 | QString cmdline; | 181 | QString cmdline; |
180 | 182 | ||
181 | if ( d->m_model == Model_Jornada_56x ) { | 183 | if ( d->m_model == Model_Jornada_56x ) { |
182 | if ( !bright ) | 184 | if ( !bright ) |
183 | cmdline = QString::fromLatin1( "echo 4 > /sys/class/backlight/sa1100fb/power"); | 185 | cmdline = QString::fromLatin1( "echo 4 > /sys/class/backlight/sa1100fb/power"); |
184 | else | 186 | else |
185 | cmdline = QString::fromLatin1( "echo 0 > /sys/class/backlight/sa1100fb/power; echo %1 > /sys/class/backlight/sa1100fb/brightness" ).arg( bright ); | 187 | cmdline = QString::fromLatin1( "echo 0 > /sys/class/backlight/sa1100fb/power; echo %1 > /sys/class/backlight/sa1100fb/brightness" ).arg( bright ); |
186 | } else if ( d->m_model == Model_Jornada_720 ) { | 188 | } else if ( d->m_model == Model_Jornada_720 ) { |
187 | cmdline = QString::fromLatin1( "echo %1 > /sys/class/backlight/e1356fb/brightness" ).arg( bright ); | 189 | cmdline = QString::fromLatin1( "echo %1 > /sys/class/backlight/e1356fb/brightness" ).arg( bright ); |
188 | } | 190 | } |
189 | 191 | ||
190 | // No Global::shellQuote as we gurantee it to be sane | 192 | // No Global::shellQuote as we gurantee it to be sane |
191 | res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); | 193 | res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); |
192 | 194 | ||
193 | return res; | 195 | return res; |
194 | } | 196 | } |
195 | 197 | ||
196 | 198 | ||
197 | bool Jornada::setDisplayStatus ( bool on ) | 199 | bool Jornada::setDisplayStatus ( bool on ) |
198 | { | 200 | { |
199 | bool res = false; | 201 | bool res = false; |
200 | 202 | ||
201 | QString cmdline; | 203 | QString cmdline; |
202 | 204 | ||
203 | if ( d->m_model == Model_Jornada_56x ) { | 205 | if ( d->m_model == Model_Jornada_56x ) { |
204 | cmdline = QString::fromLatin1( "echo %1 > /sys/class/lcd/sa1100fb/power; echo %2 > /sys/class/backlight/sa1100fb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" ); | 206 | cmdline = QString::fromLatin1( "echo %1 > /sys/class/lcd/sa1100fb/power; echo %2 > /sys/class/backlight/sa1100fb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" ); |
205 | } else if ( d->m_model == Model_Jornada_720 ) { | 207 | } else if ( d->m_model == Model_Jornada_720 ) { |
206 | cmdline = QString::fromLatin1( "echo %1 > /sys/class/lcd/e1356fb/power").arg( on ? "0" : "4" ); | 208 | cmdline = QString::fromLatin1( "echo %1 > /sys/class/lcd/e1356fb/power").arg( on ? "0" : "4" ); |
207 | } | 209 | } |
208 | 210 | ||
209 | res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); | 211 | res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); |
210 | 212 | ||
211 | return res; | 213 | return res; |
212 | } | 214 | } |
213 | 215 | ||