summaryrefslogtreecommitdiff
path: root/library
Unidiff
Diffstat (limited to 'library') (more/less context) (ignore whitespace changes)
-rw-r--r--library/filemanager.cpp67
-rw-r--r--library/fontdatabase.cpp4
-rw-r--r--library/global.cpp4
-rw-r--r--library/library.pro2
-rw-r--r--library/network.cpp4
-rw-r--r--library/qlibrary_unix.cpp113
-rw-r--r--library/qpeapplication.cpp29
-rw-r--r--library/qpedecoration_qws.cpp8
-rw-r--r--library/sound.cpp3
-rw-r--r--library/storage.cpp42
10 files changed, 255 insertions, 21 deletions
diff --git a/library/filemanager.cpp b/library/filemanager.cpp
index cc657fa..91986a0 100644
--- a/library/filemanager.cpp
+++ b/library/filemanager.cpp
@@ -33,3 +33,12 @@
33#include <dirent.h> 33#include <dirent.h>
34#include <sys/sendfile.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
42# include <sys/sendfile.h>
43#endif /* Q_OS_MACX */
35#include <fcntl.h> 44#include <fcntl.h>
@@ -218,2 +227,4 @@ bool FileManager::copyFile( const AppLnk &src, const AppLnk &dest )
218 227
228
229
219bool FileManager::copyFile( const QString & src, const QString & dest ) { 230bool FileManager::copyFile( const QString & src, const QString & dest ) {
@@ -240,13 +251,45 @@ bool FileManager::copyFile( const QString & src, const QString & dest ) {
240 QString msg; 251 QString msg;
241 err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); 252#ifdef Q_OS_MACX
242 if( err == -1) { 253#ifdef SENDMAIL
243 switch(err) { 254 /* FreeBSD does support a different kind of
244 case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; 255 * sendfile. (eilers)
245 case EINVAL: msg = "Descriptor is not valid or locked. "; 256 * I took this from Very Secure FTPd
246 case ENOMEM: msg = "Insufficient memory to read from in_fd."; 257 * Licence: GPL
247 case EIO: msg = "Unspecified error while reading from in_fd."; 258 * Author: Chris Evans
248 }; 259 * sysdeputil.c
249 success = false; 260 */
250 } 261 /* XXX - start_pos will truncate on 32-bit machines - can we
251 } else { 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
281 err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size);
282 if( err == -1) {
283 switch(err) {
284 case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. ";
285 case EINVAL: msg = "Descriptor is not valid or locked. ";
286 case ENOMEM: msg = "Insufficient memory to read from in_fd.";
287 case EIO: msg = "Unspecified error while reading from in_fd.";
288 };
289 success = false;
290 }
291#endif /* Q_OS_MACX */
292 if( !success )
293 qWarning( msg );
294 } else {
252 qWarning("open write failed %s, %s",src.latin1(), dest.latin1()); 295 qWarning("open write failed %s, %s",src.latin1(), dest.latin1());
diff --git a/library/fontdatabase.cpp b/library/fontdatabase.cpp
index c7a5211..2ad8e95 100644
--- a/library/fontdatabase.cpp
+++ b/library/fontdatabase.cpp
@@ -172,3 +172,7 @@ void FontDatabase::loadRenderers()
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
diff --git a/library/global.cpp b/library/global.cpp
index 90954fe..05d23ac 100644
--- a/library/global.cpp
+++ b/library/global.cpp
@@ -606,3 +606,7 @@ void Global::invoke(const QString &c)
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() );
diff --git a/library/library.pro b/library/library.pro
index ab1f451..5acfc0c 100644
--- a/library/library.pro
+++ b/library/library.pro
@@ -126,3 +126,3 @@ SOURCES += quuid.cpp qlibrary.cpp qlibrary_unix.cpp
126INCLUDEPATH += $(OPIEDIR)/include backend 126INCLUDEPATH += $(OPIEDIR)/include backend
127 LIBS += -ldl -lcrypt -lm 127 # LIBS += -ldl -lcrypt -lm
128INTERFACES = passwordbase_p.ui categoryeditbase_p.ui findwidgetbase_p.ui lnkpropertiesbase_p.ui 128INTERFACES = passwordbase_p.ui categoryeditbase_p.ui findwidgetbase_p.ui lnkpropertiesbase_p.ui
diff --git a/library/network.cpp b/library/network.cpp
index 3568809..991e11a 100644
--- a/library/network.cpp
+++ b/library/network.cpp
@@ -420,3 +420,7 @@ NetworkInterface* Network::loadPlugin(const QString& 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);
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
@@ -78,3 +78,114 @@ void* QLibraryPrivate::resolveSymbol( const char* symbol )
78 78
79#else // Q_OS_HPUX 79#elif defined(_NULL_LIB_)
80
81bool QLibraryPrivate::loadLibrary()
82{
83 //qDebug("QLibraryPrivate::loadLibrary\n");
84 return FALSE;
85}
86bool QLibraryPrivate::freeLibrary()
87{
88 //qDebug("QLibraryPrivate::freeLibrary\n");
89 return FALSE;
90}
91void* 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
100enum DYLD_BOOL {
101 DYLD_FALSE,
102 DYLD_TRUE
103};
104#include <mach-o/dyld.h>
105typedef struct {
106 NSObjectFileImage img;
107 NSModule mod;
108} DyldLibDesc;
109
110bool 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
146bool 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
170void* 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
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index d4734ae..a97efc0 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -22,3 +22,5 @@
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>
@@ -91,4 +93,5 @@
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"
@@ -235,3 +238,7 @@ public:
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;
@@ -260,3 +267,7 @@ public:
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;
@@ -342,2 +353,3 @@ static void setVolume( int t = 0, int percent = -1 )
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;
@@ -350,2 +362,3 @@ static void setVolume( int t = 0, int percent = -1 )
350 } 362 }
363#endif
351 } 364 }
@@ -364,2 +377,3 @@ static void setMic( int t = 0, int percent = -1 )
364 377
378#ifndef QT_NO_SOUND
365 int fd = 0; 379 int fd = 0;
@@ -370,2 +384,3 @@ static void setMic( int t = 0, int percent = -1 )
370 } 384 }
385#endif
371 } 386 }
@@ -385,2 +400,3 @@ static void setBass( int t = 0, int percent = -1 )
385 400
401#ifndef QT_NO_SOUND
386 int fd = 0; 402 int fd = 0;
@@ -391,2 +407,3 @@ static void setBass( int t = 0, int percent = -1 )
391 } 407 }
408#endif
392 } 409 }
@@ -406,2 +423,3 @@ static void setTreble( int t = 0, int percent = -1 )
406 423
424#ifndef QT_NO_SOUND
407 int fd = 0; 425 int fd = 0;
@@ -412,2 +430,3 @@ static void setTreble( int t = 0, int percent = -1 )
412 } 430 }
431#endif
413 } 432 }
@@ -1651,2 +1670,8 @@ void QPEApplication::internalSetStyle( const QString &style )
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 )
@@ -1655,3 +1680,3 @@ void QPEApplication::internalSetStyle( const QString &style )
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;
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
@@ -514,3 +514,7 @@ void QPEDecoration::init ( const QString &plugin )
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
@@ -518,3 +522,7 @@ void QPEDecoration::init ( const QString &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 }
diff --git a/library/sound.cpp b/library/sound.cpp
index c8704f9..5b67995 100644
--- a/library/sound.cpp
+++ b/library/sound.cpp
@@ -30,3 +30,6 @@
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
diff --git a/library/storage.cpp b/library/storage.cpp
index dc5cc22..f8b75d0 100644
--- a/library/storage.cpp
+++ b/library/storage.cpp
@@ -31,3 +31,3 @@
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>
@@ -36,6 +36,15 @@
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
@@ -44,2 +53,4 @@ 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");
@@ -63,2 +74,3 @@ static bool isCF(const QString& m)
63 } 74 }
75#endif /* Q_OS_MACX */
64 return FALSE; 76 return FALSE;
@@ -206,4 +218,21 @@ void StorageInfo::update()
206bool deviceTab( const char *device) { 218bool 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;
@@ -220,2 +249,5 @@ bool deviceTab( const char *device) {
220 endmntent( mntfp ); 249 endmntent( mntfp );
250#endif /* Q_OS_MACX */
251
252
221 return hasDevice; 253 return hasDevice;