author | eilers <eilers> | 2003-11-03 16:52:18 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-11-03 16:52:18 (UTC) |
commit | d34dc773591a2d467c68875a68a671d6a809f861 (patch) (unidiff) | |
tree | b57e5ae15c51e3d87ca95d57aedfd1ca3db57bfe /library | |
parent | ce84f2d8bdd65c438821f0457cdad6bbbfa73380 (diff) | |
download | opie-d34dc773591a2d467c68875a68a671d6a809f861.zip opie-d34dc773591a2d467c68875a68a671d6a809f861.tar.gz opie-d34dc773591a2d467c68875a68a671d6a809f861.tar.bz2 |
Porting Opie to MacOS-X.
The base system and all platform independent applications and platforms
should work.
Please see $OPIEDIR/development/macosx for details
-rw-r--r-- | library/filemanager.cpp | 43 | ||||
-rw-r--r-- | library/fontdatabase.cpp | 4 | ||||
-rw-r--r-- | library/global.cpp | 4 | ||||
-rw-r--r-- | library/library.pro | 2 | ||||
-rw-r--r-- | library/network.cpp | 4 | ||||
-rw-r--r-- | library/qlibrary_unix.cpp | 113 | ||||
-rw-r--r-- | library/qpeapplication.cpp | 29 | ||||
-rw-r--r-- | library/qpedecoration_qws.cpp | 8 | ||||
-rw-r--r-- | library/sound.cpp | 3 | ||||
-rw-r--r-- | library/storage.cpp | 36 |
10 files changed, 240 insertions, 6 deletions
diff --git a/library/filemanager.cpp b/library/filemanager.cpp index cc657fa..91986a0 100644 --- a/library/filemanager.cpp +++ b/library/filemanager.cpp | |||
@@ -1,82 +1,91 @@ | |||
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 "filemanager.h" | 20 | #include "filemanager.h" |
21 | #include "applnk.h" | 21 | #include "applnk.h" |
22 | 22 | ||
23 | #include <qdir.h> | 23 | #include <qdir.h> |
24 | #include <qfile.h> | 24 | #include <qfile.h> |
25 | #include <qfileinfo.h> | 25 | #include <qfileinfo.h> |
26 | #include <qtextstream.h> | 26 | #include <qtextstream.h> |
27 | #include <qtextcodec.h> | 27 | #include <qtextcodec.h> |
28 | 28 | ||
29 | #include <errno.h> | 29 | #include <errno.h> |
30 | #include <stdlib.h> | 30 | #include <stdlib.h> |
31 | #include <unistd.h> | 31 | #include <unistd.h> |
32 | #include <sys/stat.h> | 32 | #include <sys/stat.h> |
33 | #include <dirent.h> | 33 | #include <dirent.h> |
34 | #ifdef Q_OS_MACX | ||
35 | // MacOS X does not have sendfile.. :( | ||
36 | // But maybe in the future.. !? | ||
37 | # ifdef SENDFILE | ||
38 | # include <sys/types.h> | ||
39 | # include <sys/socket.h> | ||
40 | # endif | ||
41 | #else | ||
34 | #include <sys/sendfile.h> | 42 | #include <sys/sendfile.h> |
43 | #endif /* Q_OS_MACX */ | ||
35 | #include <fcntl.h> | 44 | #include <fcntl.h> |
36 | 45 | ||
37 | /*! | 46 | /*! |
38 | \class FileManager | 47 | \class FileManager |
39 | \brief The FileManager class assists with AppLnk input/output. | 48 | \brief The FileManager class assists with AppLnk input/output. |
40 | */ | 49 | */ |
41 | 50 | ||
42 | /*! | 51 | /*! |
43 | Constructs a FileManager. | 52 | Constructs a FileManager. |
44 | */ | 53 | */ |
45 | FileManager::FileManager() | 54 | FileManager::FileManager() |
46 | { | 55 | { |
47 | } | 56 | } |
48 | 57 | ||
49 | /*! | 58 | /*! |
50 | Destroys a FileManager. | 59 | Destroys a FileManager. |
51 | */ | 60 | */ |
52 | FileManager::~FileManager() | 61 | FileManager::~FileManager() |
53 | { | 62 | { |
54 | 63 | ||
55 | } | 64 | } |
56 | 65 | ||
57 | /*! | 66 | /*! |
58 | Saves \a data as the document specified by \a f. | 67 | Saves \a data as the document specified by \a f. |
59 | 68 | ||
60 | Returns whether the operation succeeded. | 69 | Returns whether the operation succeeded. |
61 | */ | 70 | */ |
62 | bool FileManager::saveFile( const DocLnk &f, const QByteArray &data ) | 71 | bool FileManager::saveFile( const DocLnk &f, const QByteArray &data ) |
63 | { | 72 | { |
64 | QString fn = f.file() + ".new"; | 73 | QString fn = f.file() + ".new"; |
65 | ensurePathExists( fn ); | 74 | ensurePathExists( fn ); |
66 | QFile fl( fn ); | 75 | QFile fl( fn ); |
67 | if ( !fl.open( IO_WriteOnly|IO_Raw ) ) { | 76 | if ( !fl.open( IO_WriteOnly|IO_Raw ) ) { |
68 | qWarning("open failed"); | 77 | qWarning("open failed"); |
69 | return FALSE; | 78 | return FALSE; |
70 | } | 79 | } |
71 | int total_written = fl.writeBlock( data ); | 80 | int total_written = fl.writeBlock( data ); |
72 | fl.close(); | 81 | fl.close(); |
73 | if ( total_written != int(data.size()) || !f.writeLink() ) { | 82 | if ( total_written != int(data.size()) || !f.writeLink() ) { |
74 | QFile::remove( fn ); | 83 | QFile::remove( fn ); |
75 | return FALSE; | 84 | return FALSE; |
76 | } | 85 | } |
77 | qDebug("total written %d out of %d", total_written, data.size()); | 86 | qDebug("total written %d out of %d", total_written, data.size()); |
78 | // else rename the file... | 87 | // else rename the file... |
79 | if ( !renameFile( fn.latin1(), f.file().latin1() ) ) { | 88 | if ( !renameFile( fn.latin1(), f.file().latin1() ) ) { |
80 | qWarning( "problem renaming file %s to %s, errno: %d", fn.latin1(), | 89 | qWarning( "problem renaming file %s to %s, errno: %d", fn.latin1(), |
81 | f.file().latin1(), errno ); | 90 | f.file().latin1(), errno ); |
82 | // remove the file... | 91 | // remove the file... |
@@ -171,128 +180,162 @@ bool FileManager::loadFile( const DocLnk &f, QByteArray &ba ) | |||
171 | */ | 180 | */ |
172 | bool FileManager::copyFile( const AppLnk &src, const AppLnk &dest ) | 181 | bool FileManager::copyFile( const AppLnk &src, const AppLnk &dest ) |
173 | { | 182 | { |
174 | QFile sf( src.file() ); | 183 | QFile sf( src.file() ); |
175 | if ( !sf.open( IO_ReadOnly ) ) | 184 | if ( !sf.open( IO_ReadOnly ) ) |
176 | return FALSE; | 185 | return FALSE; |
177 | 186 | ||
178 | QString fn = dest.file() + ".new"; | 187 | QString fn = dest.file() + ".new"; |
179 | ensurePathExists( fn ); | 188 | ensurePathExists( fn ); |
180 | QFile df( fn ); | 189 | QFile df( fn ); |
181 | if ( !df.open( IO_WriteOnly|IO_Raw ) ) | 190 | if ( !df.open( IO_WriteOnly|IO_Raw ) ) |
182 | return FALSE; | 191 | return FALSE; |
183 | 192 | ||
184 | const int bufsize = 16384; | 193 | const int bufsize = 16384; |
185 | char buffer[bufsize]; | 194 | char buffer[bufsize]; |
186 | bool ok = TRUE; | 195 | bool ok = TRUE; |
187 | int bytesRead = 0; | 196 | int bytesRead = 0; |
188 | while ( ok && !sf.atEnd() ) { | 197 | while ( ok && !sf.atEnd() ) { |
189 | bytesRead = sf.readBlock( buffer, bufsize ); | 198 | bytesRead = sf.readBlock( buffer, bufsize ); |
190 | if ( bytesRead < 0 ) | 199 | if ( bytesRead < 0 ) |
191 | ok = FALSE; | 200 | ok = FALSE; |
192 | while ( ok && bytesRead > 0 ) { | 201 | while ( ok && bytesRead > 0 ) { |
193 | int bytesWritten = df.writeBlock( buffer, bytesRead ); | 202 | int bytesWritten = df.writeBlock( buffer, bytesRead ); |
194 | if ( bytesWritten < 0 ) | 203 | if ( bytesWritten < 0 ) |
195 | ok = FALSE; | 204 | ok = FALSE; |
196 | else | 205 | else |
197 | bytesRead -= bytesWritten; | 206 | bytesRead -= bytesWritten; |
198 | } | 207 | } |
199 | } | 208 | } |
200 | 209 | ||
201 | if ( ok ) | 210 | if ( ok ) |
202 | ok = dest.writeLink(); | 211 | ok = dest.writeLink(); |
203 | 212 | ||
204 | if ( ok ) { | 213 | if ( ok ) { |
205 | // okay now rename the file... | 214 | // okay now rename the file... |
206 | if ( !renameFile( fn.latin1(), dest.file().latin1() ) ) { | 215 | if ( !renameFile( fn.latin1(), dest.file().latin1() ) ) { |
207 | qWarning( "problem renaming file %s to %s, errno: %d", fn.latin1(), | 216 | qWarning( "problem renaming file %s to %s, errno: %d", fn.latin1(), |
208 | dest.file().latin1(), errno ); | 217 | dest.file().latin1(), errno ); |
209 | // remove the tmp file, otherwise, it will just lay around... | 218 | // remove the tmp file, otherwise, it will just lay around... |
210 | QFile::remove( fn.latin1() ); | 219 | QFile::remove( fn.latin1() ); |
211 | } | 220 | } |
212 | } else { | 221 | } else { |
213 | QFile::remove( fn.latin1() ); | 222 | QFile::remove( fn.latin1() ); |
214 | } | 223 | } |
215 | 224 | ||
216 | return ok; | 225 | return ok; |
217 | } | 226 | } |
218 | 227 | ||
228 | |||
229 | |||
219 | bool FileManager::copyFile( const QString & src, const QString & dest ) { | 230 | bool FileManager::copyFile( const QString & src, const QString & dest ) { |
220 | bool success = true; | 231 | bool success = true; |
221 | struct stat status; | 232 | struct stat status; |
222 | int read_fd=0; | 233 | int read_fd=0; |
223 | int write_fd=0; | 234 | int write_fd=0; |
224 | struct stat stat_buf; | 235 | struct stat stat_buf; |
225 | off_t offset = 0; | 236 | off_t offset = 0; |
226 | QFile srcFile(src); | 237 | QFile srcFile(src); |
227 | QFile destFile(dest); | 238 | QFile destFile(dest); |
228 | 239 | ||
229 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { | 240 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { |
230 | return success = false; | 241 | return success = false; |
231 | } | 242 | } |
232 | read_fd = srcFile.handle(); | 243 | read_fd = srcFile.handle(); |
233 | if(read_fd != -1) { | 244 | if(read_fd != -1) { |
234 | fstat (read_fd, &stat_buf); | 245 | fstat (read_fd, &stat_buf); |
235 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) | 246 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) |
236 | return success = false; | 247 | return success = false; |
237 | write_fd = destFile.handle(); | 248 | write_fd = destFile.handle(); |
238 | if(write_fd != -1) { | 249 | if(write_fd != -1) { |
239 | int err=0; | 250 | int err=0; |
240 | QString msg; | 251 | QString msg; |
252 | #ifdef Q_OS_MACX | ||
253 | #ifdef SENDMAIL | ||
254 | /* FreeBSD does support a different kind of | ||
255 | * sendfile. (eilers) | ||
256 | * I took this from Very Secure FTPd | ||
257 | * Licence: GPL | ||
258 | * Author: Chris Evans | ||
259 | * sysdeputil.c | ||
260 | */ | ||
261 | /* XXX - start_pos will truncate on 32-bit machines - can we | ||
262 | * say "start from current pos"? | ||
263 | */ | ||
264 | off_t written = 0; | ||
265 | int retval = 0; | ||
266 | retval = sendfile(read_fd, write_fd, offset, stat_buf.st_size, NULL, | ||
267 | &written, 0); | ||
268 | /* Translate to Linux-like retval */ | ||
269 | if (written > 0) | ||
270 | { | ||
271 | err = (int) written; | ||
272 | } | ||
273 | #else /* SENDMAIL */ | ||
274 | err == -1; | ||
275 | msg = "FAILURE: Using unsupported function \"sendfile()\" Need Workaround !!"; | ||
276 | success = false; | ||
277 | # warning "Need workaround for sendfile!!(eilers)" | ||
278 | #endif /* SENDMAIL */ | ||
279 | |||
280 | #else | ||
241 | err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); | 281 | err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); |
242 | if( err == -1) { | 282 | if( err == -1) { |
243 | switch(err) { | 283 | switch(err) { |
244 | case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; | 284 | case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; |
245 | case EINVAL: msg = "Descriptor is not valid or locked. "; | 285 | case EINVAL: msg = "Descriptor is not valid or locked. "; |
246 | case ENOMEM: msg = "Insufficient memory to read from in_fd."; | 286 | case ENOMEM: msg = "Insufficient memory to read from in_fd."; |
247 | case EIO: msg = "Unspecified error while reading from in_fd."; | 287 | case EIO: msg = "Unspecified error while reading from in_fd."; |
248 | }; | 288 | }; |
249 | success = false; | 289 | success = false; |
250 | } | 290 | } |
291 | #endif /* Q_OS_MACX */ | ||
292 | if( !success ) | ||
293 | qWarning( msg ); | ||
251 | } else { | 294 | } else { |
252 | qWarning("open write failed %s, %s",src.latin1(), dest.latin1()); | 295 | qWarning("open write failed %s, %s",src.latin1(), dest.latin1()); |
253 | success = false; | 296 | success = false; |
254 | } | 297 | } |
255 | } else { | 298 | } else { |
256 | qWarning("open read failed %s, %s",src.latin1(), dest.latin1()); | 299 | qWarning("open read failed %s, %s",src.latin1(), dest.latin1()); |
257 | success = false; | 300 | success = false; |
258 | } | 301 | } |
259 | srcFile.close(); | 302 | srcFile.close(); |
260 | destFile.close(); | 303 | destFile.close(); |
261 | // Set file permissions | 304 | // Set file permissions |
262 | if( stat( (const char *) src, &status ) == 0 ) { | 305 | if( stat( (const char *) src, &status ) == 0 ) { |
263 | chmod( (const char *) dest, status.st_mode ); | 306 | chmod( (const char *) dest, status.st_mode ); |
264 | } | 307 | } |
265 | 308 | ||
266 | return success; | 309 | return success; |
267 | } | 310 | } |
268 | 311 | ||
269 | 312 | ||
270 | bool FileManager::renameFile( const QString & src, const QString & dest ) { | 313 | bool FileManager::renameFile( const QString & src, const QString & dest ) { |
271 | if(copyFile( src, dest )) { | 314 | if(copyFile( src, dest )) { |
272 | if(QFile::remove(src) ) { | 315 | if(QFile::remove(src) ) { |
273 | return true; | 316 | return true; |
274 | } | 317 | } |
275 | } | 318 | } |
276 | return false; | 319 | return false; |
277 | } | 320 | } |
278 | 321 | ||
279 | 322 | ||
280 | /*! | 323 | /*! |
281 | Opens the document specified by \a f as a readable QIODevice. | 324 | Opens the document specified by \a f as a readable QIODevice. |
282 | The caller must delete the return value. | 325 | The caller must delete the return value. |
283 | 326 | ||
284 | Returns 0 if the operation fails. | 327 | Returns 0 if the operation fails. |
285 | */ | 328 | */ |
286 | QIODevice* FileManager::openFile( const DocLnk& f ) | 329 | QIODevice* FileManager::openFile( const DocLnk& f ) |
287 | { | 330 | { |
288 | QString fn = f.file(); | 331 | QString fn = f.file(); |
289 | QFile* fl = new QFile( fn ); | 332 | QFile* fl = new QFile( fn ); |
290 | if ( !fl->open( IO_ReadOnly ) ) { | 333 | if ( !fl->open( IO_ReadOnly ) ) { |
291 | delete fl; | 334 | delete fl; |
292 | fl = 0; | 335 | fl = 0; |
293 | } | 336 | } |
294 | return fl; | 337 | return fl; |
295 | } | 338 | } |
296 | 339 | ||
297 | /*! | 340 | /*! |
298 | Opens the document specified by \a f as a writable QIODevice. | 341 | Opens the document specified by \a f as a writable QIODevice. |
diff --git a/library/fontdatabase.cpp b/library/fontdatabase.cpp index c7a5211..2ad8e95 100644 --- a/library/fontdatabase.cpp +++ b/library/fontdatabase.cpp | |||
@@ -125,97 +125,101 @@ QStringList FontDatabase::families() const | |||
125 | 125 | ||
126 | #ifdef QT_NO_FONTDATABASE | 126 | #ifdef QT_NO_FONTDATABASE |
127 | /*! | 127 | /*! |
128 | Returns a list of standard fontsizes. | 128 | Returns a list of standard fontsizes. |
129 | */ | 129 | */ |
130 | QValueList<int> FontDatabase::standardSizes() | 130 | QValueList<int> FontDatabase::standardSizes() |
131 | { | 131 | { |
132 | static int s[]={ 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, | 132 | static int s[]={ 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, |
133 | 36, 48, 72, 0 }; | 133 | 36, 48, 72, 0 }; |
134 | static bool first = TRUE; | 134 | static bool first = TRUE; |
135 | static QValueList<int> sList; | 135 | static QValueList<int> sList; |
136 | if ( first ) { | 136 | if ( first ) { |
137 | first = FALSE; | 137 | first = FALSE; |
138 | int i = 0; | 138 | int i = 0; |
139 | while( s[i] ) | 139 | while( s[i] ) |
140 | sList.append( s[i++] ); | 140 | sList.append( s[i++] ); |
141 | } | 141 | } |
142 | return sList; | 142 | return sList; |
143 | } | 143 | } |
144 | 144 | ||
145 | #endif | 145 | #endif |
146 | 146 | ||
147 | /*! | 147 | /*! |
148 | Load any font renderer plugins that are available and make the fonts | 148 | Load any font renderer plugins that are available and make the fonts |
149 | that the plugins can read available. | 149 | that the plugins can read available. |
150 | */ | 150 | */ |
151 | void FontDatabase::loadRenderers() | 151 | void FontDatabase::loadRenderers() |
152 | { | 152 | { |
153 | #ifndef QWS | 153 | #ifndef QWS |
154 | return; | 154 | return; |
155 | #else | 155 | #else |
156 | 156 | ||
157 | #ifndef QT_NO_COMPONENT | 157 | #ifndef QT_NO_COMPONENT |
158 | if ( !factoryList ) | 158 | if ( !factoryList ) |
159 | factoryList = new QValueList<FontFactory>; | 159 | factoryList = new QValueList<FontFactory>; |
160 | 160 | ||
161 | QValueList<FontFactory>::Iterator mit; | 161 | QValueList<FontFactory>::Iterator mit; |
162 | for ( mit = factoryList->begin(); mit != factoryList->end(); ++mit ) { | 162 | for ( mit = factoryList->begin(); mit != factoryList->end(); ++mit ) { |
163 | qt_fontmanager->factories.setAutoDelete( false ); | 163 | qt_fontmanager->factories.setAutoDelete( false ); |
164 | qt_fontmanager->factories.removeRef( (*mit).factory ); | 164 | qt_fontmanager->factories.removeRef( (*mit).factory ); |
165 | qt_fontmanager->factories.setAutoDelete( true ); | 165 | qt_fontmanager->factories.setAutoDelete( true ); |
166 | (*mit).interface->release(); | 166 | (*mit).interface->release(); |
167 | (*mit).library->unload(); | 167 | (*mit).library->unload(); |
168 | delete (*mit).library; | 168 | delete (*mit).library; |
169 | } | 169 | } |
170 | factoryList->clear(); | 170 | factoryList->clear(); |
171 | 171 | ||
172 | QString path = QPEApplication::qpeDir() + "/plugins/fontfactories"; | 172 | QString path = QPEApplication::qpeDir() + "/plugins/fontfactories"; |
173 | #ifdef Q_OS_MACX | ||
174 | QDir dir( path, "lib*.dylib" ); | ||
175 | #else | ||
173 | QDir dir( path, "lib*.so" ); | 176 | QDir dir( path, "lib*.so" ); |
177 | #endif | ||
174 | 178 | ||
175 | if ( !dir.exists()) | 179 | if ( !dir.exists()) |
176 | return; | 180 | return; |
177 | 181 | ||
178 | QStringList list = dir.entryList(); | 182 | QStringList list = dir.entryList(); |
179 | QStringList::Iterator it; | 183 | QStringList::Iterator it; |
180 | for ( it = list.begin(); it != list.end(); ++it ) { | 184 | for ( it = list.begin(); it != list.end(); ++it ) { |
181 | FontFactoryInterface *iface = 0; | 185 | FontFactoryInterface *iface = 0; |
182 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 186 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
183 | if ( lib->queryInterface( IID_FontFactory, (QUnknownInterface**)&iface ) == QS_OK ) { | 187 | if ( lib->queryInterface( IID_FontFactory, (QUnknownInterface**)&iface ) == QS_OK ) { |
184 | FontFactory factory; | 188 | FontFactory factory; |
185 | factory.library = lib; | 189 | factory.library = lib; |
186 | factory.interface = iface; | 190 | factory.interface = iface; |
187 | factory.factory = factory.interface->fontFactory(); | 191 | factory.factory = factory.interface->fontFactory(); |
188 | factoryList->append( factory ); | 192 | factoryList->append( factory ); |
189 | qt_fontmanager->factories.append( factory.factory ); | 193 | qt_fontmanager->factories.append( factory.factory ); |
190 | readFonts( factory.factory ); | 194 | readFonts( factory.factory ); |
191 | } else { | 195 | } else { |
192 | delete lib; | 196 | delete lib; |
193 | } | 197 | } |
194 | } | 198 | } |
195 | #endif | 199 | #endif |
196 | #endif | 200 | #endif |
197 | } | 201 | } |
198 | 202 | ||
199 | /*! | 203 | /*! |
200 | \internal | 204 | \internal |
201 | */ | 205 | */ |
202 | void FontDatabase::readFonts( QFontFactory *factory ) | 206 | void FontDatabase::readFonts( QFontFactory *factory ) |
203 | { | 207 | { |
204 | #ifndef QWS | 208 | #ifndef QWS |
205 | return; | 209 | return; |
206 | #else | 210 | #else |
207 | // Load in font definition file | 211 | // Load in font definition file |
208 | QString fn = fontDir() + "fontdir"; | 212 | QString fn = fontDir() + "fontdir"; |
209 | FILE* fontdef=fopen(fn.local8Bit(),"r"); | 213 | FILE* fontdef=fopen(fn.local8Bit(),"r"); |
210 | if(!fontdef) { | 214 | if(!fontdef) { |
211 | QCString temp=fn.local8Bit(); | 215 | QCString temp=fn.local8Bit(); |
212 | qWarning("Cannot find font definition file %s - is $QTDIR set correctly?", | 216 | qWarning("Cannot find font definition file %s - is $QTDIR set correctly?", |
213 | temp.data()); | 217 | temp.data()); |
214 | return; | 218 | return; |
215 | } | 219 | } |
216 | char buf[200]=""; | 220 | char buf[200]=""; |
217 | char name[200]=""; | 221 | char name[200]=""; |
218 | char render[200]=""; | 222 | char render[200]=""; |
219 | char file[200]=""; | 223 | char file[200]=""; |
220 | char flags[200]=""; | 224 | char flags[200]=""; |
221 | char isitalic[10]=""; | 225 | char isitalic[10]=""; |
diff --git a/library/global.cpp b/library/global.cpp index 90954fe..05d23ac 100644 --- a/library/global.cpp +++ b/library/global.cpp | |||
@@ -559,97 +559,101 @@ void Global::invoke(const QString &c) | |||
559 | #if !defined(QT_NO_COP) | 559 | #if !defined(QT_NO_COP) |
560 | QString ap=list[0]; | 560 | QString ap=list[0]; |
561 | // see if the application is already running | 561 | // see if the application is already running |
562 | // XXX should lock file /tmp/qcop-msg-ap | 562 | // XXX should lock file /tmp/qcop-msg-ap |
563 | if ( QCopChannel::isRegistered( ("QPE/Application/" + ap).latin1() ) ) { | 563 | if ( QCopChannel::isRegistered( ("QPE/Application/" + ap).latin1() ) ) { |
564 | // If the channel is already register, the app is already running, so show it. | 564 | // If the channel is already register, the app is already running, so show it. |
565 | { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } | 565 | { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } |
566 | 566 | ||
567 | //QCopEnvelope e("QPE/System", "notBusy(QString)" ); | 567 | //QCopEnvelope e("QPE/System", "notBusy(QString)" ); |
568 | //e << ap; | 568 | //e << ap; |
569 | return; | 569 | return; |
570 | } | 570 | } |
571 | // XXX should unlock file /tmp/qcop-msg-ap | 571 | // XXX should unlock file /tmp/qcop-msg-ap |
572 | //see if it is being started | 572 | //see if it is being started |
573 | if ( StartingAppList::isStarting( ap ) ) { | 573 | if ( StartingAppList::isStarting( ap ) ) { |
574 | // FIXME take it out for now, since it leads to a much to short showing of wait if | 574 | // FIXME take it out for now, since it leads to a much to short showing of wait if |
575 | // some entry is clicked. | 575 | // some entry is clicked. |
576 | // Real cause is that ::execute is called twice for document tab. But it would need some larger changes | 576 | // Real cause is that ::execute is called twice for document tab. But it would need some larger changes |
577 | // to fix that, and with future syncs with qtopia 1.6 it will change anyway big time since somebody there | 577 | // to fix that, and with future syncs with qtopia 1.6 it will change anyway big time since somebody there |
578 | // had the idea that an apploader belongs to the launcher ... | 578 | // had the idea that an apploader belongs to the launcher ... |
579 | //QCopEnvelope e("QPE/System", "notBusy(QString)" ); | 579 | //QCopEnvelope e("QPE/System", "notBusy(QString)" ); |
580 | //e << ap; | 580 | //e << ap; |
581 | return; | 581 | return; |
582 | } | 582 | } |
583 | 583 | ||
584 | #endif | 584 | #endif |
585 | 585 | ||
586 | #ifdef QT_NO_QWS_MULTIPROCESS | 586 | #ifdef QT_NO_QWS_MULTIPROCESS |
587 | QMessageBox::warning( 0, "Error", "Could not find the application " + c, "Ok", 0, 0, 0, 1 ); | 587 | QMessageBox::warning( 0, "Error", "Could not find the application " + c, "Ok", 0, 0, 0, 1 ); |
588 | #else | 588 | #else |
589 | 589 | ||
590 | QStrList slist; | 590 | QStrList slist; |
591 | unsigned int j; | 591 | unsigned int j; |
592 | for ( j = 0; j < list.count(); j++ ) | 592 | for ( j = 0; j < list.count(); j++ ) |
593 | slist.append( list[j].utf8() ); | 593 | slist.append( list[j].utf8() ); |
594 | 594 | ||
595 | const char **args = new (const char *)[slist.count() + 1]; | 595 | const char **args = new (const char *)[slist.count() + 1]; |
596 | for ( j = 0; j < slist.count(); j++ ) | 596 | for ( j = 0; j < slist.count(); j++ ) |
597 | args[j] = slist.at(j); | 597 | args[j] = slist.at(j); |
598 | args[j] = NULL; | 598 | args[j] = NULL; |
599 | 599 | ||
600 | #if !defined(QT_NO_COP) | 600 | #if !defined(QT_NO_COP) |
601 | // an attempt to show a wait... | 601 | // an attempt to show a wait... |
602 | // more logic should be used, but this will be fine for the moment... | 602 | // more logic should be used, but this will be fine for the moment... |
603 | QCopEnvelope ( "QPE/System", "busy()" ); | 603 | QCopEnvelope ( "QPE/System", "busy()" ); |
604 | #endif | 604 | #endif |
605 | 605 | ||
606 | #ifdef HAVE_QUICKEXEC | 606 | #ifdef HAVE_QUICKEXEC |
607 | #ifdef Q_OS_MACX | ||
608 | QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".dylib"; | ||
609 | #else | ||
607 | QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".so"; | 610 | QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".so"; |
611 | #endif | ||
608 | qDebug("libfile = %s", libexe.latin1() ); | 612 | qDebug("libfile = %s", libexe.latin1() ); |
609 | if ( QFile::exists( libexe ) ) { | 613 | if ( QFile::exists( libexe ) ) { |
610 | qDebug("calling quickexec %s", libexe.latin1() ); | 614 | qDebug("calling quickexec %s", libexe.latin1() ); |
611 | quickexecv( libexe.utf8().data(), (const char **)args ); | 615 | quickexecv( libexe.utf8().data(), (const char **)args ); |
612 | } else | 616 | } else |
613 | #endif | 617 | #endif |
614 | { | 618 | { |
615 | bool success = false; | 619 | bool success = false; |
616 | int pfd [2]; | 620 | int pfd [2]; |
617 | if ( ::pipe ( pfd ) < 0 ) | 621 | if ( ::pipe ( pfd ) < 0 ) |
618 | pfd [0] = pfd [1] = -1; | 622 | pfd [0] = pfd [1] = -1; |
619 | 623 | ||
620 | pid_t pid = ::fork ( ); | 624 | pid_t pid = ::fork ( ); |
621 | 625 | ||
622 | if ( pid == 0 ) { // child | 626 | if ( pid == 0 ) { // child |
623 | for ( int fd = 3; fd < 100; fd++ ) { | 627 | for ( int fd = 3; fd < 100; fd++ ) { |
624 | if ( fd != pfd [1] ) | 628 | if ( fd != pfd [1] ) |
625 | ::close ( fd ); | 629 | ::close ( fd ); |
626 | } | 630 | } |
627 | ::setpgid ( ::getpid ( ), ::getppid ( )); | 631 | ::setpgid ( ::getpid ( ), ::getppid ( )); |
628 | 632 | ||
629 | // Closing of fd[1] indicates that the execvp succeeded! | 633 | // Closing of fd[1] indicates that the execvp succeeded! |
630 | if ( pfd [1] >= 0 ) | 634 | if ( pfd [1] >= 0 ) |
631 | ::fcntl ( pfd [1], F_SETFD, FD_CLOEXEC ); | 635 | ::fcntl ( pfd [1], F_SETFD, FD_CLOEXEC ); |
632 | 636 | ||
633 | // Try bindir first, so that foo/bar works too | 637 | // Try bindir first, so that foo/bar works too |
634 | ::execv ( qpeDir ( ) + "/bin/" + args [0], (char * const *) args ); | 638 | ::execv ( qpeDir ( ) + "/bin/" + args [0], (char * const *) args ); |
635 | ::execvp ( args [0], (char * const *) args ); | 639 | ::execvp ( args [0], (char * const *) args ); |
636 | 640 | ||
637 | char resultByte = 1; | 641 | char resultByte = 1; |
638 | if ( pfd [1] >= 0 ) | 642 | if ( pfd [1] >= 0 ) |
639 | ::write ( pfd [1], &resultByte, 1 ); | 643 | ::write ( pfd [1], &resultByte, 1 ); |
640 | ::_exit ( -1 ); | 644 | ::_exit ( -1 ); |
641 | } | 645 | } |
642 | else if ( pid > 0 ) { | 646 | else if ( pid > 0 ) { |
643 | success = true; | 647 | success = true; |
644 | 648 | ||
645 | if ( pfd [1] >= 0 ) | 649 | if ( pfd [1] >= 0 ) |
646 | ::close ( pfd [1] ); | 650 | ::close ( pfd [1] ); |
647 | if ( pfd [0] >= 0 ) { | 651 | if ( pfd [0] >= 0 ) { |
648 | while ( true ) { | 652 | while ( true ) { |
649 | char resultByte; | 653 | char resultByte; |
650 | int n = ::read ( pfd [0], &resultByte, 1 ); | 654 | int n = ::read ( pfd [0], &resultByte, 1 ); |
651 | if ( n == 1 ) { | 655 | if ( n == 1 ) { |
652 | success = false; | 656 | success = false; |
653 | break; | 657 | break; |
654 | } | 658 | } |
655 | if (( n == -1 ) && (( errno == ECHILD ) || ( errno == EINTR ))) | 659 | if (( n == -1 ) && (( errno == ECHILD ) || ( errno == EINTR ))) |
diff --git a/library/library.pro b/library/library.pro index ab1f451..5acfc0c 100644 --- a/library/library.pro +++ b/library/library.pro | |||
@@ -79,79 +79,79 @@ SOURCES = calendar.cpp \ | |||
79 | qcopenvelope_qws.cpp \ | 79 | qcopenvelope_qws.cpp \ |
80 | qpeapplication.cpp \ | 80 | qpeapplication.cpp \ |
81 | qpestyle.cpp \ | 81 | qpestyle.cpp \ |
82 | qpedialog.cpp \ | 82 | qpedialog.cpp \ |
83 | lightstyle.cpp \ | 83 | lightstyle.cpp \ |
84 | config.cpp \ | 84 | config.cpp \ |
85 | applnk.cpp \ | 85 | applnk.cpp \ |
86 | sound.cpp \ | 86 | sound.cpp \ |
87 | tzselect.cpp \ | 87 | tzselect.cpp \ |
88 | qmath.c \ | 88 | qmath.c \ |
89 | datebookdb.cpp \ | 89 | datebookdb.cpp \ |
90 | alarmserver.cpp \ | 90 | alarmserver.cpp \ |
91 | password.cpp \ | 91 | password.cpp \ |
92 | process.cpp \ | 92 | process.cpp \ |
93 | process_unix.cpp \ | 93 | process_unix.cpp \ |
94 | timestring.cpp \ | 94 | timestring.cpp \ |
95 | fontdatabase.cpp \ | 95 | fontdatabase.cpp \ |
96 | power.cpp \ | 96 | power.cpp \ |
97 | storage.cpp \ | 97 | storage.cpp \ |
98 | qpemessagebox.cpp \ | 98 | qpemessagebox.cpp \ |
99 | backend/timeconversion.cpp \ | 99 | backend/timeconversion.cpp \ |
100 | qpedebug.cpp \ | 100 | qpedebug.cpp \ |
101 | qpemenubar.cpp \ | 101 | qpemenubar.cpp \ |
102 | qpetoolbar.cpp \ | 102 | qpetoolbar.cpp \ |
103 | backend/categories.cpp \ | 103 | backend/categories.cpp \ |
104 | backend/stringutil.cpp \ | 104 | backend/stringutil.cpp \ |
105 | backend/palmtoprecord.cpp \ | 105 | backend/palmtoprecord.cpp \ |
106 | backend/task.cpp \ | 106 | backend/task.cpp \ |
107 | backend/event.cpp \ | 107 | backend/event.cpp \ |
108 | backend/contact.cpp \ | 108 | backend/contact.cpp \ |
109 | categorymenu.cpp \ | 109 | categorymenu.cpp \ |
110 | categoryedit_p.cpp \ | 110 | categoryedit_p.cpp \ |
111 | categoryselect.cpp \ | 111 | categoryselect.cpp \ |
112 | categorywidget.cpp \ | 112 | categorywidget.cpp \ |
113 | ir.cpp \ | 113 | ir.cpp \ |
114 | backend/vcc_yacc.cpp \ | 114 | backend/vcc_yacc.cpp \ |
115 | backend/vobject.cpp \ | 115 | backend/vobject.cpp \ |
116 | findwidget_p.cpp \ | 116 | findwidget_p.cpp \ |
117 | finddialog.cpp \ | 117 | finddialog.cpp \ |
118 | lnkproperties.cpp \ | 118 | lnkproperties.cpp \ |
119 | qt_override.cpp | 119 | qt_override.cpp |
120 | 120 | ||
121 | 121 | ||
122 | 122 | ||
123 | # Qt 3 compatibility | 123 | # Qt 3 compatibility |
124 | HEADERS += quuid.h qcom.h qlibrary.h qlibrary_p.h | 124 | HEADERS += quuid.h qcom.h qlibrary.h qlibrary_p.h |
125 | SOURCES += quuid.cpp qlibrary.cpp qlibrary_unix.cpp | 125 | SOURCES += quuid.cpp qlibrary.cpp qlibrary_unix.cpp |
126 | INCLUDEPATH += $(OPIEDIR)/include backend | 126 | INCLUDEPATH += $(OPIEDIR)/include backend |
127 | LIBS += -ldl -lcrypt -lm | 127 | # LIBS += -ldl -lcrypt -lm |
128 | INTERFACES = passwordbase_p.ui categoryeditbase_p.ui findwidgetbase_p.ui lnkpropertiesbase_p.ui | 128 | INTERFACES = passwordbase_p.ui categoryeditbase_p.ui findwidgetbase_p.ui lnkpropertiesbase_p.ui |
129 | TARGET = qpe | 129 | TARGET = qpe |
130 | DESTDIR = $(OPIEDIR)/lib$(PROJMAK) | 130 | DESTDIR = $(OPIEDIR)/lib$(PROJMAK) |
131 | VERSION = 1.5.0.1 | 131 | VERSION = 1.5.0.1 |
132 | 132 | ||
133 | TRANSLATIONS = ../i18n/de/libqpe.ts \ | 133 | TRANSLATIONS = ../i18n/de/libqpe.ts \ |
134 | ../i18n/nl/libqpe.ts \ | 134 | ../i18n/nl/libqpe.ts \ |
135 | ../i18n/xx/libqpe.ts \ | 135 | ../i18n/xx/libqpe.ts \ |
136 | ../i18n/en/libqpe.ts \ | 136 | ../i18n/en/libqpe.ts \ |
137 | ../i18n/es/libqpe.ts \ | 137 | ../i18n/es/libqpe.ts \ |
138 | ../i18n/fr/libqpe.ts \ | 138 | ../i18n/fr/libqpe.ts \ |
139 | ../i18n/hu/libqpe.ts \ | 139 | ../i18n/hu/libqpe.ts \ |
140 | ../i18n/ja/libqpe.ts \ | 140 | ../i18n/ja/libqpe.ts \ |
141 | ../i18n/ko/libqpe.ts \ | 141 | ../i18n/ko/libqpe.ts \ |
142 | ../i18n/no/libqpe.ts \ | 142 | ../i18n/no/libqpe.ts \ |
143 | ../i18n/pl/libqpe.ts \ | 143 | ../i18n/pl/libqpe.ts \ |
144 | ../i18n/pt/libqpe.ts \ | 144 | ../i18n/pt/libqpe.ts \ |
145 | ../i18n/pt_BR/libqpe.ts \ | 145 | ../i18n/pt_BR/libqpe.ts \ |
146 | ../i18n/sl/libqpe.ts \ | 146 | ../i18n/sl/libqpe.ts \ |
147 | ../i18n/zh_CN/libqpe.ts \ | 147 | ../i18n/zh_CN/libqpe.ts \ |
148 | ../i18n/it/libqpe.ts \ | 148 | ../i18n/it/libqpe.ts \ |
149 | ../i18n/zh_TW/libqpe.ts \ | 149 | ../i18n/zh_TW/libqpe.ts \ |
150 | ../i18n/da/libqpe.ts | 150 | ../i18n/da/libqpe.ts |
151 | 151 | ||
152 | 152 | ||
153 | include ( $(OPIEDIR)/include.pro ) | 153 | include ( $(OPIEDIR)/include.pro ) |
154 | 154 | ||
155 | contains( CONFIG, no-override ){ | 155 | contains( CONFIG, no-override ){ |
156 | DEFINES += OPIE_NO_OVERRIDE_QT | 156 | DEFINES += OPIE_NO_OVERRIDE_QT |
157 | } | 157 | } |
diff --git a/library/network.cpp b/library/network.cpp index 3568809..991e11a 100644 --- a/library/network.cpp +++ b/library/network.cpp | |||
@@ -373,72 +373,76 @@ bool Network::networkOnline() | |||
373 | { | 373 | { |
374 | return ns && ns->networkOnline(); | 374 | return ns && ns->networkOnline(); |
375 | } | 375 | } |
376 | 376 | ||
377 | /*! | 377 | /*! |
378 | \internal | 378 | \internal |
379 | */ | 379 | */ |
380 | void Network::createServer(QObject* parent) | 380 | void Network::createServer(QObject* parent) |
381 | { | 381 | { |
382 | ns = new NetworkServer(parent); | 382 | ns = new NetworkServer(parent); |
383 | } | 383 | } |
384 | 384 | ||
385 | /*! | 385 | /*! |
386 | \internal | 386 | \internal |
387 | */ | 387 | */ |
388 | int Network::addStateWidgets(QWidget* parent) | 388 | int Network::addStateWidgets(QWidget* parent) |
389 | { | 389 | { |
390 | int n=0; | 390 | int n=0; |
391 | QStringList l = Network::choices(); | 391 | QStringList l = Network::choices(); |
392 | QVBoxLayout* vb = new QVBoxLayout(parent); | 392 | QVBoxLayout* vb = new QVBoxLayout(parent); |
393 | for (QStringList::ConstIterator it=l.begin(); it!=l.end(); ++it) { | 393 | for (QStringList::ConstIterator it=l.begin(); it!=l.end(); ++it) { |
394 | Config cfg(*it,Config::File); | 394 | Config cfg(*it,Config::File); |
395 | cfg.setGroup("Info"); | 395 | cfg.setGroup("Info"); |
396 | QString type = cfg.readEntry("Type"); | 396 | QString type = cfg.readEntry("Type"); |
397 | NetworkInterface* plugin = Network::loadPlugin(type); | 397 | NetworkInterface* plugin = Network::loadPlugin(type); |
398 | cfg.setGroup("Properties"); | 398 | cfg.setGroup("Properties"); |
399 | if ( plugin ) { | 399 | if ( plugin ) { |
400 | QWidget* w; | 400 | QWidget* w; |
401 | if ( (w=plugin->addStateWidget(parent,cfg)) ) { | 401 | if ( (w=plugin->addStateWidget(parent,cfg)) ) { |
402 | n++; | 402 | n++; |
403 | vb->addWidget(w); | 403 | vb->addWidget(w); |
404 | } | 404 | } |
405 | } | 405 | } |
406 | } | 406 | } |
407 | return n; | 407 | return n; |
408 | } | 408 | } |
409 | 409 | ||
410 | static QDict<NetworkInterface> *ifaces; | 410 | static QDict<NetworkInterface> *ifaces; |
411 | 411 | ||
412 | /*! | 412 | /*! |
413 | \internal | 413 | \internal |
414 | */ | 414 | */ |
415 | NetworkInterface* Network::loadPlugin(const QString& type) | 415 | NetworkInterface* Network::loadPlugin(const QString& type) |
416 | { | 416 | { |
417 | #ifndef QT_NO_COMPONENT | 417 | #ifndef QT_NO_COMPONENT |
418 | if ( !ifaces ) ifaces = new QDict<NetworkInterface>; | 418 | if ( !ifaces ) ifaces = new QDict<NetworkInterface>; |
419 | NetworkInterface *iface = ifaces->find(type); | 419 | NetworkInterface *iface = ifaces->find(type); |
420 | if ( !iface ) { | 420 | if ( !iface ) { |
421 | #ifdef Q_OS_MACX | ||
422 | QString libfile = QPEApplication::qpeDir() + "/plugins/network/lib" + type + ".dylib"; | ||
423 | #else | ||
421 | QString libfile = QPEApplication::qpeDir() + "/plugins/network/lib" + type + ".so"; | 424 | QString libfile = QPEApplication::qpeDir() + "/plugins/network/lib" + type + ".so"; |
425 | #endif | ||
422 | QLibrary lib(libfile); | 426 | QLibrary lib(libfile); |
423 | if ( !lib.queryInterface( IID_Network, (QUnknownInterface**)&iface ) == QS_OK ) | 427 | if ( !lib.queryInterface( IID_Network, (QUnknownInterface**)&iface ) == QS_OK ) |
424 | return 0; | 428 | return 0; |
425 | ifaces->insert(type,iface); | 429 | ifaces->insert(type,iface); |
426 | QStringList langs = Global::languageList(); | 430 | QStringList langs = Global::languageList(); |
427 | for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { | 431 | for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { |
428 | QString lang = *it; | 432 | QString lang = *it; |
429 | QTranslator * trans = new QTranslator(qApp); | 433 | QTranslator * trans = new QTranslator(qApp); |
430 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/lib"+type+".qm"; | 434 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/lib"+type+".qm"; |
431 | if ( trans->load( tfn )) | 435 | if ( trans->load( tfn )) |
432 | qApp->installTranslator( trans ); | 436 | qApp->installTranslator( trans ); |
433 | else | 437 | else |
434 | delete trans; | 438 | delete trans; |
435 | } | 439 | } |
436 | } | 440 | } |
437 | return iface; | 441 | return iface; |
438 | #else | 442 | #else |
439 | return 0; | 443 | return 0; |
440 | #endif | 444 | #endif |
441 | } | 445 | } |
442 | 446 | ||
443 | #include "network.moc" | 447 | #include "network.moc" |
444 | #endif// QT_NO_COP | 448 | #endif// QT_NO_COP |
diff --git a/library/qlibrary_unix.cpp b/library/qlibrary_unix.cpp index 7740321..0229b7b 100644 --- a/library/qlibrary_unix.cpp +++ b/library/qlibrary_unix.cpp | |||
@@ -31,97 +31,208 @@ | |||
31 | It's not too hard to guess what the functions do. | 31 | It's not too hard to guess what the functions do. |
32 | */ | 32 | */ |
33 | #if defined(Q_OS_HPUX) | 33 | #if defined(Q_OS_HPUX) |
34 | // for HP-UX < 11.x and 32 bit | 34 | // for HP-UX < 11.x and 32 bit |
35 | #include <dl.h> | 35 | #include <dl.h> |
36 | 36 | ||
37 | bool QLibraryPrivate::loadLibrary() | 37 | bool QLibraryPrivate::loadLibrary() |
38 | { | 38 | { |
39 | if ( pHnd ) | 39 | if ( pHnd ) |
40 | return TRUE; | 40 | return TRUE; |
41 | 41 | ||
42 | QString filename = library->library(); | 42 | QString filename = library->library(); |
43 | 43 | ||
44 | pHnd = (void*)shl_load( filename.latin1(), BIND_DEFERRED | BIND_NONFATAL | DYNAMIC_PATH, 0 ); | 44 | pHnd = (void*)shl_load( filename.latin1(), BIND_DEFERRED | BIND_NONFATAL | DYNAMIC_PATH, 0 ); |
45 | #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) | 45 | #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) |
46 | if ( !pHnd ) | 46 | if ( !pHnd ) |
47 | qDebug( "Failed to load library %s!", filename.latin1() ); | 47 | qDebug( "Failed to load library %s!", filename.latin1() ); |
48 | #endif | 48 | #endif |
49 | return pHnd != 0; | 49 | return pHnd != 0; |
50 | } | 50 | } |
51 | 51 | ||
52 | bool QLibraryPrivate::freeLibrary() | 52 | bool QLibraryPrivate::freeLibrary() |
53 | { | 53 | { |
54 | if ( !pHnd ) | 54 | if ( !pHnd ) |
55 | return TRUE; | 55 | return TRUE; |
56 | 56 | ||
57 | if ( !shl_unload( (shl_t)pHnd ) ) { | 57 | if ( !shl_unload( (shl_t)pHnd ) ) { |
58 | pHnd = 0; | 58 | pHnd = 0; |
59 | return TRUE; | 59 | return TRUE; |
60 | } | 60 | } |
61 | return FALSE; | 61 | return FALSE; |
62 | } | 62 | } |
63 | 63 | ||
64 | void* QLibraryPrivate::resolveSymbol( const char* symbol ) | 64 | void* QLibraryPrivate::resolveSymbol( const char* symbol ) |
65 | { | 65 | { |
66 | if ( !pHnd ) | 66 | if ( !pHnd ) |
67 | return 0; | 67 | return 0; |
68 | 68 | ||
69 | void* address = 0; | 69 | void* address = 0; |
70 | if ( shl_findsym( (shl_t*)&pHnd, symbol, TYPE_UNDEFINED, address ) < 0 ) { | 70 | if ( shl_findsym( (shl_t*)&pHnd, symbol, TYPE_UNDEFINED, address ) < 0 ) { |
71 | #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) | 71 | #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) |
72 | qDebug( "Couldn't resolve symbol \"%s\"", symbol ); | 72 | qDebug( "Couldn't resolve symbol \"%s\"", symbol ); |
73 | #endif | 73 | #endif |
74 | return 0; | 74 | return 0; |
75 | } | 75 | } |
76 | return address; | 76 | return address; |
77 | } | 77 | } |
78 | 78 | ||
79 | #else // Q_OS_HPUX | 79 | #elif defined(_NULL_LIB_) |
80 | |||
81 | bool QLibraryPrivate::loadLibrary() | ||
82 | { | ||
83 | //qDebug("QLibraryPrivate::loadLibrary\n"); | ||
84 | return FALSE; | ||
85 | } | ||
86 | bool QLibraryPrivate::freeLibrary() | ||
87 | { | ||
88 | //qDebug("QLibraryPrivate::freeLibrary\n"); | ||
89 | return FALSE; | ||
90 | } | ||
91 | void* QLibraryPrivate::resolveSymbol( const char* symbol ) | ||
92 | { | ||
93 | //qDebug("QLibraryPrivate::resolveSymbol\n"); | ||
94 | return FALSE; | ||
95 | } | ||
96 | |||
97 | #elif defined(Q_OS_MACX) | ||
98 | |||
99 | #define ENUM_DYLD_BOOL | ||
100 | enum DYLD_BOOL { | ||
101 | DYLD_FALSE, | ||
102 | DYLD_TRUE | ||
103 | }; | ||
104 | #include <mach-o/dyld.h> | ||
105 | typedef struct { | ||
106 | NSObjectFileImage img; | ||
107 | NSModule mod; | ||
108 | } DyldLibDesc; | ||
109 | |||
110 | bool QLibraryPrivate::loadLibrary() | ||
111 | { | ||
112 | // qDebug("QLibraryPrivate::loadLibrary\n"); | ||
113 | // return FALSE; | ||
114 | if ( pHnd ) | ||
115 | return TRUE; | ||
116 | |||
117 | QString filename = library->library(); | ||
118 | |||
119 | NSObjectFileImage img = 0; | ||
120 | NSModule mod = 0; | ||
121 | NSObjectFileImageReturnCode ret = NSCreateObjectFileImageFromFile( filename.latin1() , &img ); | ||
122 | if ( ret != NSObjectFileImageSuccess ) { | ||
123 | qWarning( "Error in NSCreateObjectFileImageFromFile(): %d; Filename: %s", ret, filename.latin1() ); | ||
124 | if (ret == NSObjectFileImageAccess) { | ||
125 | qWarning ("(NSObjectFileImageAccess)" ); | ||
126 | } | ||
127 | } else { | ||
128 | mod = NSLinkModule(img, filename.latin1(), NSLINKMODULE_OPTION_BINDNOW | | ||
129 | NSLINKMODULE_OPTION_PRIVATE | | ||
130 | NSLINKMODULE_OPTION_RETURN_ON_ERROR); | ||
131 | if (mod == 0) { | ||
132 | qWarning( "Error in NSLinkModule()" ); | ||
133 | NSDestroyObjectFileImage(img); | ||
134 | } | ||
135 | } | ||
136 | DyldLibDesc* desc = 0; | ||
137 | if (img != 0 && mod != 0) { | ||
138 | desc = new DyldLibDesc; | ||
139 | desc->img = img; | ||
140 | desc->mod = mod; | ||
141 | } | ||
142 | pHnd = desc; | ||
143 | return pHnd != 0; | ||
144 | } | ||
145 | |||
146 | bool QLibraryPrivate::freeLibrary() | ||
147 | { | ||
148 | //qDebug("QLibraryPrivate::freeLibrary\n"); | ||
149 | //return FALSE; | ||
150 | if ( !pHnd ) | ||
151 | return TRUE; | ||
152 | |||
153 | DyldLibDesc* desc = (DyldLibDesc*) pHnd; | ||
154 | NSModule mod = desc->mod; | ||
155 | NSObjectFileImage img = desc->img; | ||
156 | DYLD_BOOL success = NSUnLinkModule(mod, NSUNLINKMODULE_OPTION_NONE); | ||
157 | if ( success ) { | ||
158 | NSDestroyObjectFileImage(img); | ||
159 | delete desc; | ||
160 | pHnd = 0; | ||
161 | } | ||
162 | #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) | ||
163 | else { | ||
164 | qWarning( "Error in NSUnLinkModule(): %d", ret ); | ||
165 | } | ||
166 | #endif | ||
167 | return pHnd == 0; | ||
168 | } | ||
169 | |||
170 | void* QLibraryPrivate::resolveSymbol( const char* symbol ) | ||
171 | { | ||
172 | //qDebug("QLibraryPrivate::resolveSymbol\n"); | ||
173 | //return FALSE; | ||
174 | if ( !pHnd ) | ||
175 | return 0; | ||
176 | |||
177 | DyldLibDesc* desc = (DyldLibDesc*) pHnd; | ||
178 | NSSymbol sym = NSLookupSymbolInModule(desc->mod, symbol); | ||
179 | void* address = 0; | ||
180 | if (sym != 0) { | ||
181 | address = NSAddressOfSymbol(sym); | ||
182 | } | ||
183 | #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) | ||
184 | if ( address == 0 ) | ||
185 | qWarning( "Cannot find symbol: %s", symbol ); | ||
186 | #endif | ||
187 | return address; | ||
188 | } | ||
189 | |||
190 | #else | ||
80 | // Something else, assuming POSIX | 191 | // Something else, assuming POSIX |
81 | #include <dlfcn.h> | 192 | #include <dlfcn.h> |
82 | 193 | ||
83 | bool QLibraryPrivate::loadLibrary() | 194 | bool QLibraryPrivate::loadLibrary() |
84 | { | 195 | { |
85 | if ( pHnd ) | 196 | if ( pHnd ) |
86 | return TRUE; | 197 | return TRUE; |
87 | 198 | ||
88 | QString filename = library->library(); | 199 | QString filename = library->library(); |
89 | 200 | ||
90 | pHnd = dlopen( filename.latin1() , RTLD_LAZY ); | 201 | pHnd = dlopen( filename.latin1() , RTLD_LAZY ); |
91 | #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) | 202 | #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) |
92 | if ( !pHnd ) | 203 | if ( !pHnd ) |
93 | qWarning( "%s", dlerror() ); | 204 | qWarning( "%s", dlerror() ); |
94 | #endif | 205 | #endif |
95 | return pHnd != 0; | 206 | return pHnd != 0; |
96 | } | 207 | } |
97 | 208 | ||
98 | bool QLibraryPrivate::freeLibrary() | 209 | bool QLibraryPrivate::freeLibrary() |
99 | { | 210 | { |
100 | if ( !pHnd ) | 211 | if ( !pHnd ) |
101 | return TRUE; | 212 | return TRUE; |
102 | 213 | ||
103 | int ec = dlclose( pHnd ); | 214 | int ec = dlclose( pHnd ); |
104 | if ( !ec ) | 215 | if ( !ec ) |
105 | pHnd = 0; | 216 | pHnd = 0; |
106 | #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) | 217 | #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) |
107 | else { | 218 | else { |
108 | const char* error = dlerror(); | 219 | const char* error = dlerror(); |
109 | if ( error ) | 220 | if ( error ) |
110 | qWarning( "%s", error ); | 221 | qWarning( "%s", error ); |
111 | } | 222 | } |
112 | #endif | 223 | #endif |
113 | return pHnd == 0; | 224 | return pHnd == 0; |
114 | } | 225 | } |
115 | 226 | ||
116 | void* QLibraryPrivate::resolveSymbol( const char* f ) | 227 | void* QLibraryPrivate::resolveSymbol( const char* f ) |
117 | { | 228 | { |
118 | if ( !pHnd ) | 229 | if ( !pHnd ) |
119 | return 0; | 230 | return 0; |
120 | 231 | ||
121 | void* address = dlsym( pHnd, f ); | 232 | void* address = dlsym( pHnd, f ); |
122 | #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) | 233 | #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) |
123 | const char* error = dlerror(); | 234 | const char* error = dlerror(); |
124 | if ( error ) | 235 | if ( error ) |
125 | qWarning( "%s", error ); | 236 | qWarning( "%s", error ); |
126 | #endif | 237 | #endif |
127 | return address; | 238 | return address; |
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index d4734ae..a97efc0 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -1,141 +1,144 @@ | |||
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 | #define QTOPIA_INTERNAL_LANGLIST | 20 | #define QTOPIA_INTERNAL_LANGLIST |
21 | #include <stdlib.h> | 21 | #include <stdlib.h> |
22 | #include <unistd.h> | 22 | #include <unistd.h> |
23 | #ifndef Q_OS_MACX | ||
23 | #include <linux/limits.h> // needed for some toolchains (PATH_MAX) | 24 | #include <linux/limits.h> // needed for some toolchains (PATH_MAX) |
25 | #endif | ||
24 | #include <qfile.h> | 26 | #include <qfile.h> |
25 | #include <qqueue.h> | 27 | #include <qqueue.h> |
26 | #ifdef Q_WS_QWS | 28 | #ifdef Q_WS_QWS |
27 | #ifndef QT_NO_COP | 29 | #ifndef QT_NO_COP |
28 | #if QT_VERSION <= 231 | 30 | #if QT_VERSION <= 231 |
29 | #define private public | 31 | #define private public |
30 | #define sendLocally processEvent | 32 | #define sendLocally processEvent |
31 | #include "qcopenvelope_qws.h" | 33 | #include "qcopenvelope_qws.h" |
32 | #undef private | 34 | #undef private |
33 | #else | 35 | #else |
34 | #include "qcopenvelope_qws.h" | 36 | #include "qcopenvelope_qws.h" |
35 | #endif | 37 | #endif |
36 | #endif | 38 | #endif |
37 | #include <qwindowsystem_qws.h> | 39 | #include <qwindowsystem_qws.h> |
38 | #endif | 40 | #endif |
39 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
40 | #include <qpalette.h> | 42 | #include <qpalette.h> |
41 | #include <qbuffer.h> | 43 | #include <qbuffer.h> |
42 | #include <qptrdict.h> | 44 | #include <qptrdict.h> |
43 | #include <qregexp.h> | 45 | #include <qregexp.h> |
44 | #include <qdir.h> | 46 | #include <qdir.h> |
45 | #include <qlabel.h> | 47 | #include <qlabel.h> |
46 | #include <qdialog.h> | 48 | #include <qdialog.h> |
47 | #include <qdragobject.h> | 49 | #include <qdragobject.h> |
48 | #include <qtextcodec.h> | 50 | #include <qtextcodec.h> |
49 | #include <qevent.h> | 51 | #include <qevent.h> |
50 | #include <qtooltip.h> | 52 | #include <qtooltip.h> |
51 | #include <qsignal.h> | 53 | #include <qsignal.h> |
52 | #include <qmainwindow.h> | 54 | #include <qmainwindow.h> |
53 | #include <qwidgetlist.h> | 55 | #include <qwidgetlist.h> |
54 | #include <qpixmapcache.h> | 56 | #include <qpixmapcache.h> |
55 | 57 | ||
56 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 58 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
57 | #define QTOPIA_INTERNAL_INITAPP | 59 | #define QTOPIA_INTERNAL_INITAPP |
58 | #include "qpeapplication.h" | 60 | #include "qpeapplication.h" |
59 | #include "qpestyle.h" | 61 | #include "qpestyle.h" |
60 | #include "styleinterface.h" | 62 | #include "styleinterface.h" |
61 | #if QT_VERSION >= 300 | 63 | #if QT_VERSION >= 300 |
62 | #include <qstylefactory.h> | 64 | #include <qstylefactory.h> |
63 | #else | 65 | #else |
64 | #include <qplatinumstyle.h> | 66 | #include <qplatinumstyle.h> |
65 | #include <qwindowsstyle.h> | 67 | #include <qwindowsstyle.h> |
66 | #include <qmotifstyle.h> | 68 | #include <qmotifstyle.h> |
67 | #include <qmotifplusstyle.h> | 69 | #include <qmotifplusstyle.h> |
68 | #include "lightstyle.h" | 70 | #include "lightstyle.h" |
69 | 71 | ||
70 | #include <qpe/qlibrary.h> | 72 | #include <qpe/qlibrary.h> |
71 | #endif | 73 | #endif |
72 | #include "global.h" | 74 | #include "global.h" |
73 | #include "resource.h" | 75 | #include "resource.h" |
74 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 76 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
75 | #include "qutfcodec.h" | 77 | #include "qutfcodec.h" |
76 | #endif | 78 | #endif |
77 | #include "config.h" | 79 | #include "config.h" |
78 | #include "network.h" | 80 | #include "network.h" |
79 | #ifdef QWS | 81 | #ifdef QWS |
80 | #include "fontmanager.h" | 82 | #include "fontmanager.h" |
81 | #endif | 83 | #endif |
82 | 84 | ||
83 | #include "alarmserver.h" | 85 | #include "alarmserver.h" |
84 | #include "applnk.h" | 86 | #include "applnk.h" |
85 | #include "qpemenubar.h" | 87 | #include "qpemenubar.h" |
86 | #include "textcodecinterface.h" | 88 | #include "textcodecinterface.h" |
87 | #include "imagecodecinterface.h" | 89 | #include "imagecodecinterface.h" |
88 | 90 | ||
89 | #include <unistd.h> | 91 | #include <unistd.h> |
90 | #include <sys/file.h> | 92 | #include <sys/file.h> |
91 | #include <sys/ioctl.h> | 93 | #include <sys/ioctl.h> |
94 | #ifndef QT_NO_SOUND | ||
92 | #include <sys/soundcard.h> | 95 | #include <sys/soundcard.h> |
93 | 96 | #endif | |
94 | #include "qt_override_p.h" | 97 | #include "qt_override_p.h" |
95 | 98 | ||
96 | 99 | ||
97 | class QPEApplicationData | 100 | class QPEApplicationData |
98 | { | 101 | { |
99 | public: | 102 | public: |
100 | QPEApplicationData ( ) | 103 | QPEApplicationData ( ) |
101 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), | 104 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), |
102 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), | 105 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), |
103 | keep_running( true ), qcopQok( false ), qpe_main_widget( 0 ) | 106 | keep_running( true ), qcopQok( false ), qpe_main_widget( 0 ) |
104 | 107 | ||
105 | {} | 108 | {} |
106 | 109 | ||
107 | int presstimer; | 110 | int presstimer; |
108 | QWidget* presswidget; | 111 | QWidget* presswidget; |
109 | QPoint presspos; | 112 | QPoint presspos; |
110 | 113 | ||
111 | bool rightpressed : 1; | 114 | bool rightpressed : 1; |
112 | bool kbgrabbed : 1; | 115 | bool kbgrabbed : 1; |
113 | bool notbusysent : 1; | 116 | bool notbusysent : 1; |
114 | bool preloaded : 1; | 117 | bool preloaded : 1; |
115 | bool forceshow : 1; | 118 | bool forceshow : 1; |
116 | bool nomaximize : 1; | 119 | bool nomaximize : 1; |
117 | bool keep_running : 1; | 120 | bool keep_running : 1; |
118 | bool qcopQok : 1; | 121 | bool qcopQok : 1; |
119 | 122 | ||
120 | 123 | ||
121 | QStringList langs; | 124 | QStringList langs; |
122 | QString appName; | 125 | QString appName; |
123 | struct QCopRec | 126 | struct QCopRec |
124 | { | 127 | { |
125 | QCopRec( const QCString &ch, const QCString &msg, | 128 | QCopRec( const QCString &ch, const QCString &msg, |
126 | const QByteArray &d ) : | 129 | const QByteArray &d ) : |
127 | channel( ch ), message( msg ), data( d ) | 130 | channel( ch ), message( msg ), data( d ) |
128 | { } | 131 | { } |
129 | 132 | ||
130 | QCString channel; | 133 | QCString channel; |
131 | QCString message; | 134 | QCString message; |
132 | QByteArray data; | 135 | QByteArray data; |
133 | }; | 136 | }; |
134 | QWidget* qpe_main_widget; | 137 | QWidget* qpe_main_widget; |
135 | QGuardedPtr<QWidget> lastraised; | 138 | QGuardedPtr<QWidget> lastraised; |
136 | QQueue<QCopRec> qcopq; | 139 | QQueue<QCopRec> qcopq; |
137 | QString styleName; | 140 | QString styleName; |
138 | QString decorationName; | 141 | QString decorationName; |
139 | 142 | ||
140 | void enqueueQCop( const QCString &ch, const QCString &msg, | 143 | void enqueueQCop( const QCString &ch, const QCString &msg, |
141 | const QByteArray &data ) | 144 | const QByteArray &data ) |
@@ -188,273 +191,289 @@ public: | |||
188 | } | 191 | } |
189 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 192 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
190 | { | 193 | { |
191 | /* | 194 | /* |
192 | // This works but disable it for now until it is safe to apply | 195 | // This works but disable it for now until it is safe to apply |
193 | // What is does is scan the .desktop files of all the apps for | 196 | // What is does is scan the .desktop files of all the apps for |
194 | // the applnk that has the corresponding argv[0] as this program | 197 | // the applnk that has the corresponding argv[0] as this program |
195 | // then it uses the name stored in the .desktop file as the caption | 198 | // then it uses the name stored in the .desktop file as the caption |
196 | // for the main widget. This saves duplicating translations for | 199 | // for the main widget. This saves duplicating translations for |
197 | // the app name in the program and in the .desktop files. | 200 | // the app name in the program and in the .desktop files. |
198 | 201 | ||
199 | AppLnkSet apps( appsPath ); | 202 | AppLnkSet apps( appsPath ); |
200 | 203 | ||
201 | QList<AppLnk> appsList = apps.children(); | 204 | QList<AppLnk> appsList = apps.children(); |
202 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 205 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
203 | if ( (*it)->exec() == appName ) { | 206 | if ( (*it)->exec() == appName ) { |
204 | mw->setCaption( (*it)->name() ); | 207 | mw->setCaption( (*it)->name() ); |
205 | return TRUE; | 208 | return TRUE; |
206 | } | 209 | } |
207 | } | 210 | } |
208 | */ | 211 | */ |
209 | return FALSE; | 212 | return FALSE; |
210 | } | 213 | } |
211 | 214 | ||
212 | 215 | ||
213 | void show(QWidget* mw, bool nomax) | 216 | void show(QWidget* mw, bool nomax) |
214 | { | 217 | { |
215 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 218 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
216 | nomaximize = nomax; | 219 | nomaximize = nomax; |
217 | qpe_main_widget = mw; | 220 | qpe_main_widget = mw; |
218 | qcopQok = TRUE; | 221 | qcopQok = TRUE; |
219 | #ifndef QT_NO_COP | 222 | #ifndef QT_NO_COP |
220 | 223 | ||
221 | sendQCopQ(); | 224 | sendQCopQ(); |
222 | #endif | 225 | #endif |
223 | 226 | ||
224 | if ( preloaded ) { | 227 | if ( preloaded ) { |
225 | if (forceshow) | 228 | if (forceshow) |
226 | show_mx(mw, nomax); | 229 | show_mx(mw, nomax); |
227 | } | 230 | } |
228 | else if ( keep_running ) { | 231 | else if ( keep_running ) { |
229 | show_mx(mw, nomax); | 232 | show_mx(mw, nomax); |
230 | } | 233 | } |
231 | } | 234 | } |
232 | 235 | ||
233 | void loadTextCodecs() | 236 | void loadTextCodecs() |
234 | { | 237 | { |
235 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 238 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; |
239 | #ifdef Q_OS_MACX | ||
240 | QDir dir( path, "lib*.dylib" ); | ||
241 | #else | ||
236 | QDir dir( path, "lib*.so" ); | 242 | QDir dir( path, "lib*.so" ); |
243 | #endif | ||
237 | QStringList list; | 244 | QStringList list; |
238 | if ( dir. exists ( )) | 245 | if ( dir. exists ( )) |
239 | list = dir.entryList(); | 246 | list = dir.entryList(); |
240 | QStringList::Iterator it; | 247 | QStringList::Iterator it; |
241 | for ( it = list.begin(); it != list.end(); ++it ) { | 248 | for ( it = list.begin(); it != list.end(); ++it ) { |
242 | TextCodecInterface *iface = 0; | 249 | TextCodecInterface *iface = 0; |
243 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 250 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
244 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 251 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
245 | QValueList<int> mibs = iface->mibEnums(); | 252 | QValueList<int> mibs = iface->mibEnums(); |
246 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { | 253 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { |
247 | (void)iface->createForMib(*i); | 254 | (void)iface->createForMib(*i); |
248 | // ### it exists now; need to remember if we can delete it | 255 | // ### it exists now; need to remember if we can delete it |
249 | } | 256 | } |
250 | } | 257 | } |
251 | else { | 258 | else { |
252 | lib->unload(); | 259 | lib->unload(); |
253 | delete lib; | 260 | delete lib; |
254 | } | 261 | } |
255 | } | 262 | } |
256 | } | 263 | } |
257 | 264 | ||
258 | void loadImageCodecs() | 265 | void loadImageCodecs() |
259 | { | 266 | { |
260 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; | 267 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; |
268 | #ifdef Q_OS_MACX | ||
269 | QDir dir( path, "lib*.dylib" ); | ||
270 | #else | ||
261 | QDir dir( path, "lib*.so" ); | 271 | QDir dir( path, "lib*.so" ); |
272 | #endif | ||
262 | QStringList list; | 273 | QStringList list; |
263 | if ( dir. exists ( )) | 274 | if ( dir. exists ( )) |
264 | list = dir.entryList(); | 275 | list = dir.entryList(); |
265 | QStringList::Iterator it; | 276 | QStringList::Iterator it; |
266 | for ( it = list.begin(); it != list.end(); ++it ) { | 277 | for ( it = list.begin(); it != list.end(); ++it ) { |
267 | ImageCodecInterface *iface = 0; | 278 | ImageCodecInterface *iface = 0; |
268 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 279 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
269 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 280 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
270 | QStringList formats = iface->keys(); | 281 | QStringList formats = iface->keys(); |
271 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { | 282 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { |
272 | (void)iface->installIOHandler(*i); | 283 | (void)iface->installIOHandler(*i); |
273 | // ### it exists now; need to remember if we can delete it | 284 | // ### it exists now; need to remember if we can delete it |
274 | } | 285 | } |
275 | } | 286 | } |
276 | else { | 287 | else { |
277 | lib->unload(); | 288 | lib->unload(); |
278 | delete lib; | 289 | delete lib; |
279 | } | 290 | } |
280 | } | 291 | } |
281 | } | 292 | } |
282 | }; | 293 | }; |
283 | 294 | ||
284 | class ResourceMimeFactory : public QMimeSourceFactory | 295 | class ResourceMimeFactory : public QMimeSourceFactory |
285 | { | 296 | { |
286 | public: | 297 | public: |
287 | ResourceMimeFactory() : resImage( 0 ) | 298 | ResourceMimeFactory() : resImage( 0 ) |
288 | { | 299 | { |
289 | setFilePath( Global::helpPath() ); | 300 | setFilePath( Global::helpPath() ); |
290 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 301 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
291 | } | 302 | } |
292 | ~ResourceMimeFactory() { | 303 | ~ResourceMimeFactory() { |
293 | delete resImage; | 304 | delete resImage; |
294 | } | 305 | } |
295 | 306 | ||
296 | const QMimeSource* data( const QString& abs_name ) const | 307 | const QMimeSource* data( const QString& abs_name ) const |
297 | { | 308 | { |
298 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 309 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
299 | if ( !r ) { | 310 | if ( !r ) { |
300 | int sl = abs_name.length(); | 311 | int sl = abs_name.length(); |
301 | do { | 312 | do { |
302 | sl = abs_name.findRev( '/', sl - 1 ); | 313 | sl = abs_name.findRev( '/', sl - 1 ); |
303 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 314 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
304 | int dot = name.findRev( '.' ); | 315 | int dot = name.findRev( '.' ); |
305 | if ( dot >= 0 ) | 316 | if ( dot >= 0 ) |
306 | name = name.left( dot ); | 317 | name = name.left( dot ); |
307 | QImage img = Resource::loadImage( name ); | 318 | QImage img = Resource::loadImage( name ); |
308 | if ( !img.isNull() ) { | 319 | if ( !img.isNull() ) { |
309 | delete resImage; | 320 | delete resImage; |
310 | resImage = new QImageDrag( img ); | 321 | resImage = new QImageDrag( img ); |
311 | r = resImage; | 322 | r = resImage; |
312 | } | 323 | } |
313 | } | 324 | } |
314 | while ( !r && sl > 0 ); | 325 | while ( !r && sl > 0 ); |
315 | } | 326 | } |
316 | return r; | 327 | return r; |
317 | } | 328 | } |
318 | private: | 329 | private: |
319 | mutable QImageDrag *resImage; | 330 | mutable QImageDrag *resImage; |
320 | }; | 331 | }; |
321 | 332 | ||
322 | static int& hack(int& i) | 333 | static int& hack(int& i) |
323 | { | 334 | { |
324 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 335 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
325 | // These should be created, but aren't in Qt 2.3.0 | 336 | // These should be created, but aren't in Qt 2.3.0 |
326 | (void)new QUtf8Codec; | 337 | (void)new QUtf8Codec; |
327 | (void)new QUtf16Codec; | 338 | (void)new QUtf16Codec; |
328 | #endif | 339 | #endif |
329 | return i; | 340 | return i; |
330 | } | 341 | } |
331 | 342 | ||
332 | static int muted = 0; | 343 | static int muted = 0; |
333 | static int micMuted = 0; | 344 | static int micMuted = 0; |
334 | 345 | ||
335 | static void setVolume( int t = 0, int percent = -1 ) | 346 | static void setVolume( int t = 0, int percent = -1 ) |
336 | { | 347 | { |
337 | switch ( t ) { | 348 | switch ( t ) { |
338 | case 0: { | 349 | case 0: { |
339 | Config cfg( "qpe" ); | 350 | Config cfg( "qpe" ); |
340 | cfg.setGroup( "Volume" ); | 351 | cfg.setGroup( "Volume" ); |
341 | if ( percent < 0 ) | 352 | if ( percent < 0 ) |
342 | percent = cfg.readNumEntry( "VolumePercent", 50 ); | 353 | percent = cfg.readNumEntry( "VolumePercent", 50 ); |
354 | #ifndef QT_NO_SOUND | ||
343 | int fd = 0; | 355 | int fd = 0; |
344 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 356 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
345 | int vol = muted ? 0 : percent; | 357 | int vol = muted ? 0 : percent; |
346 | // set both channels to same volume | 358 | // set both channels to same volume |
347 | vol |= vol << 8; | 359 | vol |= vol << 8; |
348 | ioctl( fd, MIXER_WRITE( 0 ), &vol ); | 360 | ioctl( fd, MIXER_WRITE( 0 ), &vol ); |
349 | ::close( fd ); | 361 | ::close( fd ); |
350 | } | 362 | } |
363 | #endif | ||
351 | } | 364 | } |
352 | break; | 365 | break; |
353 | } | 366 | } |
354 | } | 367 | } |
355 | 368 | ||
356 | static void setMic( int t = 0, int percent = -1 ) | 369 | static void setMic( int t = 0, int percent = -1 ) |
357 | { | 370 | { |
358 | switch ( t ) { | 371 | switch ( t ) { |
359 | case 0: { | 372 | case 0: { |
360 | Config cfg( "qpe" ); | 373 | Config cfg( "qpe" ); |
361 | cfg.setGroup( "Volume" ); | 374 | cfg.setGroup( "Volume" ); |
362 | if ( percent < 0 ) | 375 | if ( percent < 0 ) |
363 | percent = cfg.readNumEntry( "Mic", 50 ); | 376 | percent = cfg.readNumEntry( "Mic", 50 ); |
364 | 377 | ||
378 | #ifndef QT_NO_SOUND | ||
365 | int fd = 0; | 379 | int fd = 0; |
366 | int mic = micMuted ? 0 : percent; | 380 | int mic = micMuted ? 0 : percent; |
367 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 381 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
368 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); | 382 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); |
369 | ::close( fd ); | 383 | ::close( fd ); |
370 | } | 384 | } |
385 | #endif | ||
371 | } | 386 | } |
372 | break; | 387 | break; |
373 | } | 388 | } |
374 | } | 389 | } |
375 | 390 | ||
376 | 391 | ||
377 | static void setBass( int t = 0, int percent = -1 ) | 392 | static void setBass( int t = 0, int percent = -1 ) |
378 | { | 393 | { |
379 | switch ( t ) { | 394 | switch ( t ) { |
380 | case 0: { | 395 | case 0: { |
381 | Config cfg( "qpe" ); | 396 | Config cfg( "qpe" ); |
382 | cfg.setGroup( "Volume" ); | 397 | cfg.setGroup( "Volume" ); |
383 | if ( percent < 0 ) | 398 | if ( percent < 0 ) |
384 | percent = cfg.readNumEntry( "BassPercent", 50 ); | 399 | percent = cfg.readNumEntry( "BassPercent", 50 ); |
385 | 400 | ||
401 | #ifndef QT_NO_SOUND | ||
386 | int fd = 0; | 402 | int fd = 0; |
387 | int bass = percent; | 403 | int bass = percent; |
388 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 404 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
389 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); | 405 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); |
390 | ::close( fd ); | 406 | ::close( fd ); |
391 | } | 407 | } |
408 | #endif | ||
392 | } | 409 | } |
393 | break; | 410 | break; |
394 | } | 411 | } |
395 | } | 412 | } |
396 | 413 | ||
397 | 414 | ||
398 | static void setTreble( int t = 0, int percent = -1 ) | 415 | static void setTreble( int t = 0, int percent = -1 ) |
399 | { | 416 | { |
400 | switch ( t ) { | 417 | switch ( t ) { |
401 | case 0: { | 418 | case 0: { |
402 | Config cfg( "qpe" ); | 419 | Config cfg( "qpe" ); |
403 | cfg.setGroup( "Volume" ); | 420 | cfg.setGroup( "Volume" ); |
404 | if ( percent < 0 ) | 421 | if ( percent < 0 ) |
405 | percent = cfg.readNumEntry( "TreblePercent", 50 ); | 422 | percent = cfg.readNumEntry( "TreblePercent", 50 ); |
406 | 423 | ||
424 | #ifndef QT_NO_SOUND | ||
407 | int fd = 0; | 425 | int fd = 0; |
408 | int treble = percent; | 426 | int treble = percent; |
409 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 427 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
410 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); | 428 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); |
411 | ::close( fd ); | 429 | ::close( fd ); |
412 | } | 430 | } |
431 | #endif | ||
413 | } | 432 | } |
414 | break; | 433 | break; |
415 | } | 434 | } |
416 | } | 435 | } |
417 | 436 | ||
418 | 437 | ||
419 | /*! | 438 | /*! |
420 | \class QPEApplication qpeapplication.h | 439 | \class QPEApplication qpeapplication.h |
421 | \brief The QPEApplication class implements various system services | 440 | \brief The QPEApplication class implements various system services |
422 | that are available to all Qtopia applications. | 441 | that are available to all Qtopia applications. |
423 | 442 | ||
424 | Simply by using QPEApplication instead of QApplication, a standard Qt | 443 | Simply by using QPEApplication instead of QApplication, a standard Qt |
425 | application becomes a Qtopia application. It automatically follows | 444 | application becomes a Qtopia application. It automatically follows |
426 | style changes, quits and raises, and in the | 445 | style changes, quits and raises, and in the |
427 | case of \link docwidget.html document-oriented\endlink applications, | 446 | case of \link docwidget.html document-oriented\endlink applications, |
428 | changes the currently displayed document in response to the environment. | 447 | changes the currently displayed document in response to the environment. |
429 | 448 | ||
430 | To create a \link docwidget.html document-oriented\endlink | 449 | To create a \link docwidget.html document-oriented\endlink |
431 | application use showMainDocumentWidget(); to create a | 450 | application use showMainDocumentWidget(); to create a |
432 | non-document-oriented application use showMainWidget(). The | 451 | non-document-oriented application use showMainWidget(). The |
433 | keepRunning() function indicates whether the application will | 452 | keepRunning() function indicates whether the application will |
434 | continue running after it's processed the last \link qcop.html | 453 | continue running after it's processed the last \link qcop.html |
435 | QCop\endlink message. This can be changed using setKeepRunning(). | 454 | QCop\endlink message. This can be changed using setKeepRunning(). |
436 | 455 | ||
437 | A variety of signals are emitted when certain events occur, for | 456 | A variety of signals are emitted when certain events occur, for |
438 | example, timeChanged(), clockChanged(), weekChanged(), | 457 | example, timeChanged(), clockChanged(), weekChanged(), |
439 | dateFormatChanged() and volumeChanged(). If the application receives | 458 | dateFormatChanged() and volumeChanged(). If the application receives |
440 | a \link qcop.html QCop\endlink message on the application's | 459 | a \link qcop.html QCop\endlink message on the application's |
441 | QPE/Application/\e{appname} channel, the appMessage() signal is | 460 | QPE/Application/\e{appname} channel, the appMessage() signal is |
442 | emitted. There are also flush() and reload() signals, which | 461 | emitted. There are also flush() and reload() signals, which |
443 | are emitted when synching begins and ends respectively - upon these | 462 | are emitted when synching begins and ends respectively - upon these |
444 | signals, the application should save and reload any data | 463 | signals, the application should save and reload any data |
445 | files that are involved in synching. Most of these signals will initially | 464 | files that are involved in synching. Most of these signals will initially |
446 | be received and unfiltered through the appMessage() signal. | 465 | be received and unfiltered through the appMessage() signal. |
447 | 466 | ||
448 | This class also provides a set of useful static functions. The | 467 | This class also provides a set of useful static functions. The |
449 | qpeDir() and documentDir() functions return the respective paths. | 468 | qpeDir() and documentDir() functions return the respective paths. |
450 | The grabKeyboard() and ungrabKeyboard() functions are used to | 469 | The grabKeyboard() and ungrabKeyboard() functions are used to |
451 | control whether the application takes control of the device's | 470 | control whether the application takes control of the device's |
452 | physical buttons (e.g. application launch keys). The stylus' mode of | 471 | physical buttons (e.g. application launch keys). The stylus' mode of |
453 | operation is set with setStylusOperation() and retrieved with | 472 | operation is set with setStylusOperation() and retrieved with |
454 | stylusOperation(). There are also setInputMethodHint() and | 473 | stylusOperation(). There are also setInputMethodHint() and |
455 | inputMethodHint() functions. | 474 | inputMethodHint() functions. |
456 | 475 | ||
457 | \ingroup qtopiaemb | 476 | \ingroup qtopiaemb |
458 | */ | 477 | */ |
459 | 478 | ||
460 | /*! | 479 | /*! |
@@ -1604,101 +1623,107 @@ bool QPEApplication::keepRunning() const | |||
1604 | { | 1623 | { |
1605 | return d->keep_running; | 1624 | return d->keep_running; |
1606 | } | 1625 | } |
1607 | 1626 | ||
1608 | /*! | 1627 | /*! |
1609 | \internal | 1628 | \internal |
1610 | */ | 1629 | */ |
1611 | void QPEApplication::internalSetStyle( const QString &style ) | 1630 | void QPEApplication::internalSetStyle( const QString &style ) |
1612 | { | 1631 | { |
1613 | #if QT_VERSION >= 300 | 1632 | #if QT_VERSION >= 300 |
1614 | if ( style == "QPE" ) { | 1633 | if ( style == "QPE" ) { |
1615 | setStyle( new QPEStyle ); | 1634 | setStyle( new QPEStyle ); |
1616 | } | 1635 | } |
1617 | else { | 1636 | else { |
1618 | QStyle *s = QStyleFactory::create( style ); | 1637 | QStyle *s = QStyleFactory::create( style ); |
1619 | if ( s ) | 1638 | if ( s ) |
1620 | setStyle( s ); | 1639 | setStyle( s ); |
1621 | } | 1640 | } |
1622 | #else | 1641 | #else |
1623 | if ( style == "Windows" ) { | 1642 | if ( style == "Windows" ) { |
1624 | setStyle( new QWindowsStyle ); | 1643 | setStyle( new QWindowsStyle ); |
1625 | } | 1644 | } |
1626 | else if ( style == "QPE" ) { | 1645 | else if ( style == "QPE" ) { |
1627 | setStyle( new QPEStyle ); | 1646 | setStyle( new QPEStyle ); |
1628 | } | 1647 | } |
1629 | else if ( style == "Light" ) { | 1648 | else if ( style == "Light" ) { |
1630 | setStyle( new LightStyle ); | 1649 | setStyle( new LightStyle ); |
1631 | } | 1650 | } |
1632 | #ifndef QT_NO_STYLE_PLATINUM | 1651 | #ifndef QT_NO_STYLE_PLATINUM |
1633 | else if ( style == "Platinum" ) { | 1652 | else if ( style == "Platinum" ) { |
1634 | setStyle( new QPlatinumStyle ); | 1653 | setStyle( new QPlatinumStyle ); |
1635 | } | 1654 | } |
1636 | #endif | 1655 | #endif |
1637 | #ifndef QT_NO_STYLE_MOTIF | 1656 | #ifndef QT_NO_STYLE_MOTIF |
1638 | else if ( style == "Motif" ) { | 1657 | else if ( style == "Motif" ) { |
1639 | setStyle( new QMotifStyle ); | 1658 | setStyle( new QMotifStyle ); |
1640 | } | 1659 | } |
1641 | #endif | 1660 | #endif |
1642 | #ifndef QT_NO_STYLE_MOTIFPLUS | 1661 | #ifndef QT_NO_STYLE_MOTIFPLUS |
1643 | else if ( style == "MotifPlus" ) { | 1662 | else if ( style == "MotifPlus" ) { |
1644 | setStyle( new QMotifPlusStyle ); | 1663 | setStyle( new QMotifPlusStyle ); |
1645 | } | 1664 | } |
1646 | #endif | 1665 | #endif |
1647 | 1666 | ||
1648 | else { | 1667 | else { |
1649 | QStyle *sty = 0; | 1668 | QStyle *sty = 0; |
1650 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; | 1669 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; |
1651 | 1670 | ||
1671 | #ifdef Q_OS_MACX | ||
1672 | if ( style. find ( ".dylib" ) > 0 ) | ||
1673 | path += style; | ||
1674 | else | ||
1675 | path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility | ||
1676 | #else | ||
1652 | if ( style. find ( ".so" ) > 0 ) | 1677 | if ( style. find ( ".so" ) > 0 ) |
1653 | path += style; | 1678 | path += style; |
1654 | else | 1679 | else |
1655 | path = path + "lib" + style. lower ( ) + ".so"; // compatibility | 1680 | path = path + "lib" + style. lower ( ) + ".so"; // compatibility |
1656 | 1681 | #endif | |
1657 | static QLibrary *lastlib = 0; | 1682 | static QLibrary *lastlib = 0; |
1658 | static StyleInterface *lastiface = 0; | 1683 | static StyleInterface *lastiface = 0; |
1659 | 1684 | ||
1660 | QLibrary *lib = new QLibrary ( path ); | 1685 | QLibrary *lib = new QLibrary ( path ); |
1661 | StyleInterface *iface = 0; | 1686 | StyleInterface *iface = 0; |
1662 | 1687 | ||
1663 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) | 1688 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) |
1664 | sty = iface-> style ( ); | 1689 | sty = iface-> style ( ); |
1665 | 1690 | ||
1666 | if ( sty ) { | 1691 | if ( sty ) { |
1667 | setStyle ( sty ); | 1692 | setStyle ( sty ); |
1668 | 1693 | ||
1669 | if ( lastiface ) | 1694 | if ( lastiface ) |
1670 | lastiface-> release ( ); | 1695 | lastiface-> release ( ); |
1671 | lastiface = iface; | 1696 | lastiface = iface; |
1672 | 1697 | ||
1673 | if ( lastlib ) { | 1698 | if ( lastlib ) { |
1674 | lastlib-> unload ( ); | 1699 | lastlib-> unload ( ); |
1675 | delete lastlib; | 1700 | delete lastlib; |
1676 | } | 1701 | } |
1677 | lastlib = lib; | 1702 | lastlib = lib; |
1678 | } | 1703 | } |
1679 | else { | 1704 | else { |
1680 | if ( iface ) | 1705 | if ( iface ) |
1681 | iface-> release ( ); | 1706 | iface-> release ( ); |
1682 | delete lib; | 1707 | delete lib; |
1683 | 1708 | ||
1684 | setStyle ( new LightStyle ( )); | 1709 | setStyle ( new LightStyle ( )); |
1685 | } | 1710 | } |
1686 | } | 1711 | } |
1687 | #endif | 1712 | #endif |
1688 | } | 1713 | } |
1689 | 1714 | ||
1690 | /*! | 1715 | /*! |
1691 | \internal | 1716 | \internal |
1692 | */ | 1717 | */ |
1693 | void QPEApplication::prepareForTermination( bool willrestart ) | 1718 | void QPEApplication::prepareForTermination( bool willrestart ) |
1694 | { | 1719 | { |
1695 | if ( willrestart ) { | 1720 | if ( willrestart ) { |
1696 | // Draw a big wait icon, the image can be altered in later revisions | 1721 | // Draw a big wait icon, the image can be altered in later revisions |
1697 | // QWidget *d = QApplication::desktop(); | 1722 | // QWidget *d = QApplication::desktop(); |
1698 | QImage img = Resource::loadImage( "launcher/new_wait" ); | 1723 | QImage img = Resource::loadImage( "launcher/new_wait" ); |
1699 | QPixmap pix; | 1724 | QPixmap pix; |
1700 | pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); | 1725 | pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); |
1701 | QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | | 1726 | QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | |
1702 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); | 1727 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); |
1703 | lblWait->setPixmap( pix ); | 1728 | lblWait->setPixmap( pix ); |
1704 | lblWait->setAlignment( QWidget::AlignCenter ); | 1729 | lblWait->setAlignment( QWidget::AlignCenter ); |
diff --git a/library/qpedecoration_qws.cpp b/library/qpedecoration_qws.cpp index 933542d..bac1a75 100644 --- a/library/qpedecoration_qws.cpp +++ b/library/qpedecoration_qws.cpp | |||
@@ -467,101 +467,109 @@ public: | |||
467 | *iface = this; | 467 | *iface = this; |
468 | else if ( uuid == IID_WindowDecoration ) | 468 | else if ( uuid == IID_WindowDecoration ) |
469 | *iface = this; | 469 | *iface = this; |
470 | 470 | ||
471 | if ( *iface ) | 471 | if ( *iface ) |
472 | (*iface)->addRef(); | 472 | (*iface)->addRef(); |
473 | return QS_OK; | 473 | return QS_OK; |
474 | } | 474 | } |
475 | Q_REFCOUNT | 475 | Q_REFCOUNT |
476 | 476 | ||
477 | private: | 477 | private: |
478 | ulong ref; | 478 | ulong ref; |
479 | }; | 479 | }; |
480 | 480 | ||
481 | static WindowDecorationInterface *wdiface = 0; | 481 | static WindowDecorationInterface *wdiface = 0; |
482 | static QLibrary *wdlib = 0; | 482 | static QLibrary *wdlib = 0; |
483 | static QString libname; | 483 | static QString libname; |
484 | 484 | ||
485 | //=========================================================================== | 485 | //=========================================================================== |
486 | 486 | ||
487 | QPEDecoration::QPEDecoration() | 487 | QPEDecoration::QPEDecoration() |
488 | : QWSDefaultDecoration() | 488 | : QWSDefaultDecoration() |
489 | { | 489 | { |
490 | init ( libname ); | 490 | init ( libname ); |
491 | } | 491 | } |
492 | 492 | ||
493 | QPEDecoration::QPEDecoration( const QString &plugin ) | 493 | QPEDecoration::QPEDecoration( const QString &plugin ) |
494 | : QWSDefaultDecoration() | 494 | : QWSDefaultDecoration() |
495 | { | 495 | { |
496 | init ( plugin ); | 496 | init ( plugin ); |
497 | } | 497 | } |
498 | 498 | ||
499 | void QPEDecoration::init ( const QString &plugin ) | 499 | void QPEDecoration::init ( const QString &plugin ) |
500 | { | 500 | { |
501 | libname = plugin; | 501 | libname = plugin; |
502 | 502 | ||
503 | if ( wdlib ) { | 503 | if ( wdlib ) { |
504 | wdiface->release(); | 504 | wdiface->release(); |
505 | wdlib->unload(); | 505 | wdlib->unload(); |
506 | delete wdlib; | 506 | delete wdlib; |
507 | wdlib = 0; | 507 | wdlib = 0; |
508 | } else { | 508 | } else { |
509 | delete wdiface; | 509 | delete wdiface; |
510 | } | 510 | } |
511 | 511 | ||
512 | WindowDecorationInterface *iface = 0; | 512 | WindowDecorationInterface *iface = 0; |
513 | QString path = QPEApplication::qpeDir() + "/plugins/decorations/"; | 513 | QString path = QPEApplication::qpeDir() + "/plugins/decorations/"; |
514 | 514 | ||
515 | #ifdef Q_OS_MACX | ||
516 | if ( plugin.find( ".dylib" ) > 0 ) { | ||
517 | #else | ||
515 | if ( plugin.find( ".so" ) > 0 ) { | 518 | if ( plugin.find( ".so" ) > 0 ) { |
519 | #endif | ||
516 | // full library name supplied | 520 | // full library name supplied |
517 | path += plugin; | 521 | path += plugin; |
518 | } else { | 522 | } else { |
523 | #ifdef Q_OS_MACX | ||
524 | path += "lib" + plugin.lower() + ".dylib"; // compatibility | ||
525 | #else | ||
519 | path += "lib" + plugin.lower() + ".so"; // compatibility | 526 | path += "lib" + plugin.lower() + ".so"; // compatibility |
527 | #endif | ||
520 | } | 528 | } |
521 | 529 | ||
522 | QLibrary *lib = new QLibrary( path ); | 530 | QLibrary *lib = new QLibrary( path ); |
523 | if ( lib->queryInterface( IID_WindowDecoration, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 531 | if ( lib->queryInterface( IID_WindowDecoration, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
524 | wdiface = iface; | 532 | wdiface = iface; |
525 | wdlib = lib; | 533 | wdlib = lib; |
526 | } else { | 534 | } else { |
527 | delete lib; | 535 | delete lib; |
528 | wdiface = new DefaultWindowDecoration; | 536 | wdiface = new DefaultWindowDecoration; |
529 | } | 537 | } |
530 | 538 | ||
531 | helpFile = QString(qApp->argv()[0]) + ".html"; | 539 | helpFile = QString(qApp->argv()[0]) + ".html"; |
532 | QStringList helpPath = Global::helpPath(); | 540 | QStringList helpPath = Global::helpPath(); |
533 | helpExists = FALSE; | 541 | helpExists = FALSE; |
534 | for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !helpExists; ++it) { | 542 | for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !helpExists; ++it) { |
535 | helpExists = QFile::exists( *it + "/" + helpFile ); | 543 | helpExists = QFile::exists( *it + "/" + helpFile ); |
536 | //qDebug ( "Checking %s/%s for help: %d", (*it).latin1(), helpFile.latin1(),helpExists); | 544 | //qDebug ( "Checking %s/%s for help: %d", (*it).latin1(), helpFile.latin1(),helpExists); |
537 | } | 545 | } |
538 | qpeManager = new QPEManager( this ); | 546 | qpeManager = new QPEManager( this ); |
539 | 547 | ||
540 | // Qtopia 1.5 compatibility | 548 | // Qtopia 1.5 compatibility |
541 | imageOk = *okImage ( 15 ); | 549 | imageOk = *okImage ( 15 ); |
542 | imageClose = *closeImage ( 15 ); | 550 | imageClose = *closeImage ( 15 ); |
543 | imageHelp = *helpImage ( 15 ); | 551 | imageHelp = *helpImage ( 15 ); |
544 | } | 552 | } |
545 | 553 | ||
546 | QPEDecoration::~QPEDecoration() | 554 | QPEDecoration::~QPEDecoration() |
547 | { | 555 | { |
548 | delete qpeManager; | 556 | delete qpeManager; |
549 | } | 557 | } |
550 | 558 | ||
551 | const char **QPEDecoration::menuPixmap() | 559 | const char **QPEDecoration::menuPixmap() |
552 | { | 560 | { |
553 | return (const char **)0; | 561 | return (const char **)0; |
554 | } | 562 | } |
555 | 563 | ||
556 | const char **QPEDecoration::closePixmap() | 564 | const char **QPEDecoration::closePixmap() |
557 | { | 565 | { |
558 | return (const char **)qpe_close_xpm; | 566 | return (const char **)qpe_close_xpm; |
559 | } | 567 | } |
560 | 568 | ||
561 | const char **QPEDecoration::minimizePixmap() | 569 | const char **QPEDecoration::minimizePixmap() |
562 | { | 570 | { |
563 | return (const char **)qpe_accept_xpm; | 571 | return (const char **)qpe_accept_xpm; |
564 | } | 572 | } |
565 | 573 | ||
566 | const char **QPEDecoration::maximizePixmap() | 574 | const char **QPEDecoration::maximizePixmap() |
567 | { | 575 | { |
diff --git a/library/sound.cpp b/library/sound.cpp index c8704f9..5b67995 100644 --- a/library/sound.cpp +++ b/library/sound.cpp | |||
@@ -1,79 +1,82 @@ | |||
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 <qpe/resource.h> | 21 | #include <qpe/resource.h> |
22 | #include <qpe/sound.h> | 22 | #include <qpe/sound.h> |
23 | #include <qpe/qcopenvelope_qws.h> | 23 | #include <qpe/qcopenvelope_qws.h> |
24 | 24 | ||
25 | #include <qsound.h> | 25 | #include <qsound.h> |
26 | #include <qfile.h> | 26 | #include <qfile.h> |
27 | 27 | ||
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | #include <fcntl.h> | 29 | #include <fcntl.h> |
30 | #include <sys/ioctl.h> | 30 | #include <sys/ioctl.h> |
31 | |||
32 | #ifndef QT_NO_SOUND | ||
31 | #include <sys/soundcard.h> | 33 | #include <sys/soundcard.h> |
34 | #endif | ||
32 | 35 | ||
33 | #include "config.h" | 36 | #include "config.h" |
34 | #include <qmessagebox.h> | 37 | #include <qmessagebox.h> |
35 | #ifndef QT_NO_SOUND | 38 | #ifndef QT_NO_SOUND |
36 | static int WAVsoundDuration(const QString& filename) | 39 | static int WAVsoundDuration(const QString& filename) |
37 | { | 40 | { |
38 | // bad solution | 41 | // bad solution |
39 | 42 | ||
40 | // most of this is copied from qsoundqss.cpp | 43 | // most of this is copied from qsoundqss.cpp |
41 | 44 | ||
42 | QFile input(filename); | 45 | QFile input(filename); |
43 | if ( !input.open(IO_ReadOnly) ) | 46 | if ( !input.open(IO_ReadOnly) ) |
44 | return 0; | 47 | return 0; |
45 | 48 | ||
46 | struct QRiffChunk { | 49 | struct QRiffChunk { |
47 | char id[4]; | 50 | char id[4]; |
48 | Q_UINT32 size; | 51 | Q_UINT32 size; |
49 | char data[4/*size*/]; | 52 | char data[4/*size*/]; |
50 | } chunk; | 53 | } chunk; |
51 | 54 | ||
52 | struct { | 55 | struct { |
53 | Q_INT16 formatTag; | 56 | Q_INT16 formatTag; |
54 | Q_INT16 channels; | 57 | Q_INT16 channels; |
55 | Q_INT32 samplesPerSec; | 58 | Q_INT32 samplesPerSec; |
56 | Q_INT32 avgBytesPerSec; | 59 | Q_INT32 avgBytesPerSec; |
57 | Q_INT16 blockAlign; | 60 | Q_INT16 blockAlign; |
58 | Q_INT16 wBitsPerSample; | 61 | Q_INT16 wBitsPerSample; |
59 | } chunkdata; | 62 | } chunkdata; |
60 | 63 | ||
61 | int total = 0; | 64 | int total = 0; |
62 | 65 | ||
63 | while(1) { | 66 | while(1) { |
64 | // Keep reading chunks... | 67 | // Keep reading chunks... |
65 | const int n = sizeof(chunk)-sizeof(chunk.data); | 68 | const int n = sizeof(chunk)-sizeof(chunk.data); |
66 | if ( input.readBlock((char*)&chunk,n) != n ) | 69 | if ( input.readBlock((char*)&chunk,n) != n ) |
67 | break; | 70 | break; |
68 | if ( qstrncmp(chunk.id,"data",4) == 0 ) { | 71 | if ( qstrncmp(chunk.id,"data",4) == 0 ) { |
69 | total += chunkdata.avgBytesPerSec ? | 72 | total += chunkdata.avgBytesPerSec ? |
70 | chunk.size * 1000 / chunkdata.avgBytesPerSec : 0; | 73 | chunk.size * 1000 / chunkdata.avgBytesPerSec : 0; |
71 | //qDebug("%d bytes of PCM (%dms)", chunk.size,chunkdata.avgBytesPerSec ? chunk.size * 1000 / chunkdata.avgBytesPerSec : 0); | 74 | //qDebug("%d bytes of PCM (%dms)", chunk.size,chunkdata.avgBytesPerSec ? chunk.size * 1000 / chunkdata.avgBytesPerSec : 0); |
72 | input.at(input.at()+chunk.size-4); | 75 | input.at(input.at()+chunk.size-4); |
73 | } else if ( qstrncmp(chunk.id,"RIFF",4) == 0 ) { | 76 | } else if ( qstrncmp(chunk.id,"RIFF",4) == 0 ) { |
74 | char d[4]; | 77 | char d[4]; |
75 | if ( input.readBlock(d,4) != 4 ) | 78 | if ( input.readBlock(d,4) != 4 ) |
76 | return 0; | 79 | return 0; |
77 | if ( qstrncmp(d,"WAVE",4) != 0 ) { | 80 | if ( qstrncmp(d,"WAVE",4) != 0 ) { |
78 | // skip | 81 | // skip |
79 | //qDebug("skip %.4s RIFF chunk",d); | 82 | //qDebug("skip %.4s RIFF chunk",d); |
diff --git a/library/storage.cpp b/library/storage.cpp index dc5cc22..f8b75d0 100644 --- a/library/storage.cpp +++ b/library/storage.cpp | |||
@@ -1,111 +1,123 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) Holger 'zecke' Freyther <freyther@kde.org> | 2 | ** Copyright (C) Holger 'zecke' Freyther <freyther@kde.org> |
3 | ** Copyright (C) Lorn Potter <llornkcor@handhelds.org> | 3 | ** Copyright (C) Lorn Potter <llornkcor@handhelds.org> |
4 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 4 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
5 | ** | 5 | ** |
6 | ** This file is part of Opie Environment. | 6 | ** This file is part of Opie Environment. |
7 | ** | 7 | ** |
8 | ** This file may be distributed and/or modified under the terms of the | 8 | ** This file may be distributed and/or modified under the terms of the |
9 | ** GNU General Public License version 2 as published by the Free Software | 9 | ** GNU General Public License version 2 as published by the Free Software |
10 | ** Foundation and appearing in the file LICENSE.GPL included in the | 10 | ** Foundation and appearing in the file LICENSE.GPL included in the |
11 | ** packaging of this file. | 11 | ** packaging of this file. |
12 | ** | 12 | ** |
13 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 13 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
14 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 14 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
15 | ** | 15 | ** |
16 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 16 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
17 | ** | 17 | ** |
18 | ** Contact info@trolltech.com if any conditions of this licensing are | 18 | ** Contact info@trolltech.com if any conditions of this licensing are |
19 | ** not clear to you. | 19 | ** not clear to you. |
20 | ** | 20 | ** |
21 | **********************************************************************/ | 21 | **********************************************************************/ |
22 | 22 | ||
23 | #include <qpe/storage.h> | 23 | #include <qpe/storage.h> |
24 | #include <qpe/custom.h> | 24 | #include <qpe/custom.h> |
25 | 25 | ||
26 | #include <qfile.h> | 26 | #include <qfile.h> |
27 | #include <qtimer.h> | 27 | #include <qtimer.h> |
28 | #include <qcopchannel_qws.h> | 28 | #include <qcopchannel_qws.h> |
29 | 29 | ||
30 | #include <stdio.h> | 30 | #include <stdio.h> |
31 | 31 | ||
32 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 32 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
33 | #include <sys/vfs.h> | 33 | #include <sys/vfs.h> |
34 | #include <mntent.h> | 34 | #include <mntent.h> |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | #ifdef Q_OS_MACX | ||
38 | # include <sys/param.h> | ||
39 | # include <sys/ucred.h> | ||
40 | # include <sys/mount.h> | ||
41 | # include <stdio.h> // For strerror() | ||
42 | # include <errno.h> | ||
43 | #endif /* Q_OS_MACX */ | ||
44 | |||
37 | #include <qstringlist.h> | 45 | #include <qstringlist.h> |
38 | 46 | ||
39 | #include <sys/vfs.h> | 47 | // Shouldn't be here ! (eilers) |
40 | #include <mntent.h> | 48 | // #include <sys/vfs.h> |
49 | // #include <mntent.h> | ||
41 | 50 | ||
42 | 51 | ||
43 | static bool isCF(const QString& m) | 52 | static bool isCF(const QString& m) |
44 | { | 53 | { |
54 | |||
55 | #ifndef Q_OS_MACX | ||
45 | FILE* f = fopen("/var/run/stab", "r"); | 56 | FILE* f = fopen("/var/run/stab", "r"); |
46 | if (!f) f = fopen("/var/state/pcmcia/stab", "r"); | 57 | if (!f) f = fopen("/var/state/pcmcia/stab", "r"); |
47 | if (!f) f = fopen("/var/lib/pcmcia/stab", "r"); | 58 | if (!f) f = fopen("/var/lib/pcmcia/stab", "r"); |
48 | if ( f ) { | 59 | if ( f ) { |
49 | char line[1024]; | 60 | char line[1024]; |
50 | char devtype[80]; | 61 | char devtype[80]; |
51 | char devname[80]; | 62 | char devname[80]; |
52 | while ( fgets( line, 1024, f ) ) { | 63 | while ( fgets( line, 1024, f ) ) { |
53 | // 0 ide ide-cs 0 hda 3 0 | 64 | // 0 ide ide-cs 0 hda 3 0 |
54 | if ( sscanf(line,"%*d %s %*s %*s %s", devtype, devname )==2 ) | 65 | if ( sscanf(line,"%*d %s %*s %*s %s", devtype, devname )==2 ) |
55 | { | 66 | { |
56 | if ( QString(devtype) == "ide" && m.find(devname)>0 ) { | 67 | if ( QString(devtype) == "ide" && m.find(devname)>0 ) { |
57 | fclose(f); | 68 | fclose(f); |
58 | return TRUE; | 69 | return TRUE; |
59 | } | 70 | } |
60 | } | 71 | } |
61 | } | 72 | } |
62 | fclose(f); | 73 | fclose(f); |
63 | } | 74 | } |
75 | #endif /* Q_OS_MACX */ | ||
64 | return FALSE; | 76 | return FALSE; |
65 | } | 77 | } |
66 | 78 | ||
67 | /*! \class StorageInfo storage.h | 79 | /*! \class StorageInfo storage.h |
68 | \brief The StorageInfo class describes the disks mounted on the file system. | 80 | \brief The StorageInfo class describes the disks mounted on the file system. |
69 | 81 | ||
70 | This class provides access to the mount information for the Linux | 82 | This class provides access to the mount information for the Linux |
71 | filesystem. Each mount point is represented by the FileSystem class. | 83 | filesystem. Each mount point is represented by the FileSystem class. |
72 | To ensure this class has the most up to date size information, call | 84 | To ensure this class has the most up to date size information, call |
73 | the update() method. Note that this will automatically be signaled | 85 | the update() method. Note that this will automatically be signaled |
74 | by the operating system when a disk has been mounted or unmounted. | 86 | by the operating system when a disk has been mounted or unmounted. |
75 | 87 | ||
76 | \ingroup qtopiaemb | 88 | \ingroup qtopiaemb |
77 | */ | 89 | */ |
78 | 90 | ||
79 | /*! Constructor that determines the current mount points of the filesystem. | 91 | /*! Constructor that determines the current mount points of the filesystem. |
80 | The standard \a parent parameters is passed on to QObject. | 92 | The standard \a parent parameters is passed on to QObject. |
81 | */ | 93 | */ |
82 | StorageInfo::StorageInfo( QObject *parent ) | 94 | StorageInfo::StorageInfo( QObject *parent ) |
83 | : QObject( parent ) | 95 | : QObject( parent ) |
84 | { | 96 | { |
85 | mFileSystems.setAutoDelete( TRUE ); | 97 | mFileSystems.setAutoDelete( TRUE ); |
86 | channel = new QCopChannel( "QPE/Card", this ); | 98 | channel = new QCopChannel( "QPE/Card", this ); |
87 | connect( channel, SIGNAL(received(const QCString &, const QByteArray &)), | 99 | connect( channel, SIGNAL(received(const QCString &, const QByteArray &)), |
88 | this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); | 100 | this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); |
89 | update(); | 101 | update(); |
90 | } | 102 | } |
91 | 103 | ||
92 | /*! Returns the longest matching FileSystem that starts with the | 104 | /*! Returns the longest matching FileSystem that starts with the |
93 | same prefix as \a filename as its mount point. | 105 | same prefix as \a filename as its mount point. |
94 | */ | 106 | */ |
95 | const FileSystem *StorageInfo::fileSystemOf( const QString &filename ) | 107 | const FileSystem *StorageInfo::fileSystemOf( const QString &filename ) |
96 | { | 108 | { |
97 | for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) { | 109 | for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) { |
98 | if ( filename.startsWith( (*i)->path() ) ) | 110 | if ( filename.startsWith( (*i)->path() ) ) |
99 | return (*i); | 111 | return (*i); |
100 | } | 112 | } |
101 | return 0; | 113 | return 0; |
102 | } | 114 | } |
103 | 115 | ||
104 | 116 | ||
105 | void StorageInfo::cardMessage( const QCString& msg, const QByteArray& ) | 117 | void StorageInfo::cardMessage( const QCString& msg, const QByteArray& ) |
106 | { | 118 | { |
107 | if ( msg == "mtabChanged()" ) | 119 | if ( msg == "mtabChanged()" ) |
108 | update(); | 120 | update(); |
109 | } | 121 | } |
110 | 122 | ||
111 | 123 | ||
@@ -161,108 +173,128 @@ void StorageInfo::update() | |||
161 | for (; it!=curdisks.end(); ++it, ++fsit, ++optsIt) { | 173 | for (; it!=curdisks.end(); ++it, ++fsit, ++optsIt) { |
162 | QString opts = *optsIt; | 174 | QString opts = *optsIt; |
163 | 175 | ||
164 | QString disk = *it; | 176 | QString disk = *it; |
165 | QString humanname; | 177 | QString humanname; |
166 | bool removable = FALSE; | 178 | bool removable = FALSE; |
167 | if ( isCF(disk) ) { | 179 | if ( isCF(disk) ) { |
168 | humanname = tr("CF Card"); | 180 | humanname = tr("CF Card"); |
169 | removable = TRUE; | 181 | removable = TRUE; |
170 | } else if ( disk == "/dev/hda1" ) { | 182 | } else if ( disk == "/dev/hda1" ) { |
171 | humanname = tr("Hard Disk"); | 183 | humanname = tr("Hard Disk"); |
172 | } else if ( disk.left(9) == "/dev/mmcd" ) { | 184 | } else if ( disk.left(9) == "/dev/mmcd" ) { |
173 | humanname = tr("SD Card"); | 185 | humanname = tr("SD Card"); |
174 | removable = TRUE; | 186 | removable = TRUE; |
175 | } else if ( disk.left( 14 ) == "/dev/mmc/part1" ) { | 187 | } else if ( disk.left( 14 ) == "/dev/mmc/part1" ) { |
176 | humanname = tr("MMC Card"); | 188 | humanname = tr("MMC Card"); |
177 | removable = TRUE; | 189 | removable = TRUE; |
178 | } else if ( disk.left(7) == "/dev/hd" ) | 190 | } else if ( disk.left(7) == "/dev/hd" ) |
179 | humanname = tr("Hard Disk") + " " + disk; | 191 | humanname = tr("Hard Disk") + " " + disk; |
180 | else if ( disk.left(7) == "/dev/sd" ) | 192 | else if ( disk.left(7) == "/dev/sd" ) |
181 | humanname = tr("SCSI Hard Disk") + " " + disk; | 193 | humanname = tr("SCSI Hard Disk") + " " + disk; |
182 | else if ( disk.left(14) == "/dev/mtdblock6" ) //openzaurus ramfs | 194 | else if ( disk.left(14) == "/dev/mtdblock6" ) //openzaurus ramfs |
183 | humanname = tr("Internal Memory"); | 195 | humanname = tr("Internal Memory"); |
184 | else if ( disk == "/dev/mtdblock1" || humanname == "/dev/mtdblock/1" ) | 196 | else if ( disk == "/dev/mtdblock1" || humanname == "/dev/mtdblock/1" ) |
185 | humanname = tr("Internal Storage"); | 197 | humanname = tr("Internal Storage"); |
186 | else if ( disk.left(14) == "/dev/mtdblock/" ) | 198 | else if ( disk.left(14) == "/dev/mtdblock/" ) |
187 | humanname = tr("Internal Storage") + " " + disk; | 199 | humanname = tr("Internal Storage") + " " + disk; |
188 | else if ( disk.left(13) == "/dev/mtdblock" ) | 200 | else if ( disk.left(13) == "/dev/mtdblock" ) |
189 | humanname = tr("Internal Storage") + " " + disk; | 201 | humanname = tr("Internal Storage") + " " + disk; |
190 | else if ( disk.left(9) == "/dev/root" ) | 202 | else if ( disk.left(9) == "/dev/root" ) |
191 | humanname = tr("Internal Storage") + " " + disk; | 203 | humanname = tr("Internal Storage") + " " + disk; |
192 | else if ( disk.left(5) == "tmpfs" ) //ipaqs /mnt/ramfs | 204 | else if ( disk.left(5) == "tmpfs" ) //ipaqs /mnt/ramfs |
193 | humanname = tr("Internal Memory"); | 205 | humanname = tr("Internal Memory"); |
194 | FileSystem *fs = new FileSystem( disk, *fsit, humanname, removable, opts ); | 206 | FileSystem *fs = new FileSystem( disk, *fsit, humanname, removable, opts ); |
195 | mFileSystems.append( fs ); | 207 | mFileSystems.append( fs ); |
196 | } | 208 | } |
197 | emit disksChanged(); | 209 | emit disksChanged(); |
198 | } else { | 210 | } else { |
199 | // just update them | 211 | // just update them |
200 | for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) | 212 | for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) |
201 | i.current()->update(); | 213 | i.current()->update(); |
202 | } | 214 | } |
203 | #endif | 215 | #endif |
204 | } | 216 | } |
205 | 217 | ||
206 | bool deviceTab( const char *device) { | 218 | bool deviceTab( const char *device) { |
207 | QString name = device; | 219 | QString name = device; |
208 | bool hasDevice=false; | 220 | bool hasDevice=false; |
221 | |||
222 | #ifdef Q_OS_MACX | ||
223 | // Darwin (MacOS X) | ||
224 | struct statfs** mntbufp; | ||
225 | int count = 0; | ||
226 | if ( ( count = getmntinfo( mntbufp, MNT_WAIT ) ) == 0 ){ | ||
227 | qWarning("deviceTab: Error in getmntinfo(): %s",strerror( errno ) ); | ||
228 | hasDevice = false; | ||
229 | } | ||
230 | for( int i = 0; i < count; i++ ){ | ||
231 | QString deviceName = mntbufp[i]->f_mntfromname; | ||
232 | qDebug(deviceName); | ||
233 | if( deviceName.left( name.length() ) == name ) | ||
234 | hasDevice = true; | ||
235 | } | ||
236 | #else | ||
237 | // Linux | ||
209 | struct mntent *me; | 238 | struct mntent *me; |
210 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); | 239 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); |
211 | if ( mntfp ) { | 240 | if ( mntfp ) { |
212 | while ( (me = getmntent( mntfp )) != 0 ) { | 241 | while ( (me = getmntent( mntfp )) != 0 ) { |
213 | QString deviceName = me->mnt_fsname; | 242 | QString deviceName = me->mnt_fsname; |
214 | // qDebug(deviceName); | 243 | // qDebug(deviceName); |
215 | if( deviceName.left(name.length()) == name) { | 244 | if( deviceName.left(name.length()) == name) { |
216 | hasDevice = true; | 245 | hasDevice = true; |
217 | } | 246 | } |
218 | } | 247 | } |
219 | } | 248 | } |
220 | endmntent( mntfp ); | 249 | endmntent( mntfp ); |
250 | #endif /* Q_OS_MACX */ | ||
251 | |||
252 | |||
221 | return hasDevice; | 253 | return hasDevice; |
222 | } | 254 | } |
223 | 255 | ||
224 | /*! | 256 | /*! |
225 | * @fn static bool StorageInfo::hasCf() | 257 | * @fn static bool StorageInfo::hasCf() |
226 | * @brief returns whether device has Cf mounted | 258 | * @brief returns whether device has Cf mounted |
227 | * | 259 | * |
228 | */ | 260 | */ |
229 | bool StorageInfo::hasCf() | 261 | bool StorageInfo::hasCf() |
230 | { | 262 | { |
231 | return deviceTab("/dev/hd"); | 263 | return deviceTab("/dev/hd"); |
232 | } | 264 | } |
233 | 265 | ||
234 | /*! | 266 | /*! |
235 | * @fn static bool StorageInfo::hasSd() | 267 | * @fn static bool StorageInfo::hasSd() |
236 | * @brief returns whether device has SD mounted | 268 | * @brief returns whether device has SD mounted |
237 | * | 269 | * |
238 | */ | 270 | */ |
239 | bool StorageInfo::hasSd() | 271 | bool StorageInfo::hasSd() |
240 | { | 272 | { |
241 | return deviceTab("/dev/mmcd"); | 273 | return deviceTab("/dev/mmcd"); |
242 | } | 274 | } |
243 | 275 | ||
244 | /*! | 276 | /*! |
245 | * @fn static bool StorageInfo::hasMmc() | 277 | * @fn static bool StorageInfo::hasMmc() |
246 | * @brief reutrns whether device has mmc mounted | 278 | * @brief reutrns whether device has mmc mounted |
247 | * | 279 | * |
248 | */ | 280 | */ |
249 | bool StorageInfo::hasMmc() | 281 | bool StorageInfo::hasMmc() |
250 | { | 282 | { |
251 | bool hasMmc=false; | 283 | bool hasMmc=false; |
252 | if( deviceTab("/dev/mmc/part")) | 284 | if( deviceTab("/dev/mmc/part")) |
253 | hasMmc=true; | 285 | hasMmc=true; |
254 | if( deviceTab("/dev/mmcd")) | 286 | if( deviceTab("/dev/mmcd")) |
255 | hasMmc=true; | 287 | hasMmc=true; |
256 | return hasMmc; | 288 | return hasMmc; |
257 | } | 289 | } |
258 | 290 | ||
259 | /*! \fn const QList<FileSystem> &StorageInfo::fileSystems() const | 291 | /*! \fn const QList<FileSystem> &StorageInfo::fileSystems() const |
260 | Returns a list of all available mounted file systems. | 292 | Returns a list of all available mounted file systems. |
261 | 293 | ||
262 | \warning This may change in Qtopia 3.x to return only relevant Qtopia file systems (and ignore mount points such as /tmp) | 294 | \warning This may change in Qtopia 3.x to return only relevant Qtopia file systems (and ignore mount points such as /tmp) |
263 | */ | 295 | */ |
264 | 296 | ||
265 | /*! \fn void StorageInfo::disksChanged() | 297 | /*! \fn void StorageInfo::disksChanged() |
266 | Gets emitted when a disk has been mounted or unmounted, such as when | 298 | Gets emitted when a disk has been mounted or unmounted, such as when |
267 | a CF c | 299 | a CF c |
268 | */ | 300 | */ |