summaryrefslogtreecommitdiff
path: root/library
Side-by-side diff
Diffstat (limited to 'library') (more/less context) (show whitespace changes)
-rw-r--r--library/filemanager.cpp43
-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.cpp36
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
@@ -33,3 +33,12 @@
#include <dirent.h>
+#ifdef Q_OS_MACX
+// MacOS X does not have sendfile.. :(
+// But maybe in the future.. !?
+# ifdef SENDFILE
+# include <sys/types.h>
+# include <sys/socket.h>
+# endif
+#else
#include <sys/sendfile.h>
+#endif /* Q_OS_MACX */
#include <fcntl.h>
@@ -218,2 +227,4 @@ bool FileManager::copyFile( const AppLnk &src, const AppLnk &dest )
+
+
bool FileManager::copyFile( const QString & src, const QString & dest ) {
@@ -240,2 +251,31 @@ bool FileManager::copyFile( const QString & src, const QString & dest ) {
QString msg;
+#ifdef Q_OS_MACX
+#ifdef SENDMAIL
+ /* FreeBSD does support a different kind of
+ * sendfile. (eilers)
+ * I took this from Very Secure FTPd
+ * Licence: GPL
+ * Author: Chris Evans
+ * sysdeputil.c
+ */
+ /* XXX - start_pos will truncate on 32-bit machines - can we
+ * say "start from current pos"?
+ */
+ off_t written = 0;
+ int retval = 0;
+ retval = sendfile(read_fd, write_fd, offset, stat_buf.st_size, NULL,
+ &written, 0);
+ /* Translate to Linux-like retval */
+ if (written > 0)
+ {
+ err = (int) written;
+ }
+#else /* SENDMAIL */
+ err == -1;
+ msg = "FAILURE: Using unsupported function \"sendfile()\" Need Workaround !!";
+ success = false;
+# warning "Need workaround for sendfile!!(eilers)"
+#endif /* SENDMAIL */
+
+#else
err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size);
@@ -250,2 +290,5 @@ bool FileManager::copyFile( const QString & src, const QString & dest ) {
}
+#endif /* Q_OS_MACX */
+ if( !success )
+ qWarning( msg );
} else {
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()
QString path = QPEApplication::qpeDir() + "/plugins/fontfactories";
+#ifdef Q_OS_MACX
+ QDir dir( path, "lib*.dylib" );
+#else
QDir dir( path, "lib*.so" );
+#endif
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)
#ifdef HAVE_QUICKEXEC
+#ifdef Q_OS_MACX
+ QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".dylib";
+#else
QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".so";
+#endif
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
INCLUDEPATH += $(OPIEDIR)/include backend
-LIBS += -ldl -lcrypt -lm
+# LIBS += -ldl -lcrypt -lm
INTERFACES = 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)
if ( !iface ) {
+#ifdef Q_OS_MACX
+ QString libfile = QPEApplication::qpeDir() + "/plugins/network/lib" + type + ".dylib";
+#else
QString libfile = QPEApplication::qpeDir() + "/plugins/network/lib" + type + ".so";
+#endif
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 )
-#else // Q_OS_HPUX
+#elif defined(_NULL_LIB_)
+
+bool QLibraryPrivate::loadLibrary()
+{
+ //qDebug("QLibraryPrivate::loadLibrary\n");
+ return FALSE;
+}
+bool QLibraryPrivate::freeLibrary()
+{
+ //qDebug("QLibraryPrivate::freeLibrary\n");
+ return FALSE;
+}
+void* QLibraryPrivate::resolveSymbol( const char* symbol )
+{
+ //qDebug("QLibraryPrivate::resolveSymbol\n");
+ return FALSE;
+}
+
+#elif defined(Q_OS_MACX)
+
+#define ENUM_DYLD_BOOL
+enum DYLD_BOOL {
+ DYLD_FALSE,
+ DYLD_TRUE
+};
+#include <mach-o/dyld.h>
+typedef struct {
+ NSObjectFileImage img;
+ NSModule mod;
+} DyldLibDesc;
+
+bool QLibraryPrivate::loadLibrary()
+{
+ // qDebug("QLibraryPrivate::loadLibrary\n");
+ // return FALSE;
+ if ( pHnd )
+ return TRUE;
+
+ QString filename = library->library();
+
+ NSObjectFileImage img = 0;
+ NSModule mod = 0;
+ NSObjectFileImageReturnCode ret = NSCreateObjectFileImageFromFile( filename.latin1() , &img );
+ if ( ret != NSObjectFileImageSuccess ) {
+ qWarning( "Error in NSCreateObjectFileImageFromFile(): %d; Filename: %s", ret, filename.latin1() );
+ if (ret == NSObjectFileImageAccess) {
+ qWarning ("(NSObjectFileImageAccess)" );
+ }
+ } else {
+ mod = NSLinkModule(img, filename.latin1(), NSLINKMODULE_OPTION_BINDNOW |
+ NSLINKMODULE_OPTION_PRIVATE |
+ NSLINKMODULE_OPTION_RETURN_ON_ERROR);
+ if (mod == 0) {
+ qWarning( "Error in NSLinkModule()" );
+ NSDestroyObjectFileImage(img);
+ }
+ }
+ DyldLibDesc* desc = 0;
+ if (img != 0 && mod != 0) {
+ desc = new DyldLibDesc;
+ desc->img = img;
+ desc->mod = mod;
+ }
+ pHnd = desc;
+ return pHnd != 0;
+}
+
+bool QLibraryPrivate::freeLibrary()
+{
+ //qDebug("QLibraryPrivate::freeLibrary\n");
+ //return FALSE;
+ if ( !pHnd )
+ return TRUE;
+
+ DyldLibDesc* desc = (DyldLibDesc*) pHnd;
+ NSModule mod = desc->mod;
+ NSObjectFileImage img = desc->img;
+ DYLD_BOOL success = NSUnLinkModule(mod, NSUNLINKMODULE_OPTION_NONE);
+ if ( success ) {
+ NSDestroyObjectFileImage(img);
+ delete desc;
+ pHnd = 0;
+ }
+#if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT)
+ else {
+ qWarning( "Error in NSUnLinkModule(): %d", ret );
+ }
+#endif
+ return pHnd == 0;
+}
+
+void* QLibraryPrivate::resolveSymbol( const char* symbol )
+{
+ //qDebug("QLibraryPrivate::resolveSymbol\n");
+ //return FALSE;
+ if ( !pHnd )
+ return 0;
+
+ DyldLibDesc* desc = (DyldLibDesc*) pHnd;
+ NSSymbol sym = NSLookupSymbolInModule(desc->mod, symbol);
+ void* address = 0;
+ if (sym != 0) {
+ address = NSAddressOfSymbol(sym);
+ }
+#if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT)
+ if ( address == 0 )
+ qWarning( "Cannot find symbol: %s", symbol );
+#endif
+ return address;
+}
+
+#else
// 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 @@
#include <unistd.h>
+#ifndef Q_OS_MACX
#include <linux/limits.h> // needed for some toolchains (PATH_MAX)
+#endif
#include <qfile.h>
@@ -91,4 +93,5 @@
#include <sys/ioctl.h>
+#ifndef QT_NO_SOUND
#include <sys/soundcard.h>
-
+#endif
#include "qt_override_p.h"
@@ -235,3 +238,7 @@ public:
QString path = QPEApplication::qpeDir() + "/plugins/textcodecs";
+#ifdef Q_OS_MACX
+ QDir dir( path, "lib*.dylib" );
+#else
QDir dir( path, "lib*.so" );
+#endif
QStringList list;
@@ -260,3 +267,7 @@ public:
QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs";
+#ifdef Q_OS_MACX
+ QDir dir( path, "lib*.dylib" );
+#else
QDir dir( path, "lib*.so" );
+#endif
QStringList list;
@@ -342,2 +353,3 @@ static void setVolume( int t = 0, int percent = -1 )
percent = cfg.readNumEntry( "VolumePercent", 50 );
+#ifndef QT_NO_SOUND
int fd = 0;
@@ -350,2 +362,3 @@ static void setVolume( int t = 0, int percent = -1 )
}
+#endif
}
@@ -364,2 +377,3 @@ static void setMic( int t = 0, int percent = -1 )
+#ifndef QT_NO_SOUND
int fd = 0;
@@ -370,2 +384,3 @@ static void setMic( int t = 0, int percent = -1 )
}
+#endif
}
@@ -385,2 +400,3 @@ static void setBass( int t = 0, int percent = -1 )
+#ifndef QT_NO_SOUND
int fd = 0;
@@ -391,2 +407,3 @@ static void setBass( int t = 0, int percent = -1 )
}
+#endif
}
@@ -406,2 +423,3 @@ static void setTreble( int t = 0, int percent = -1 )
+#ifndef QT_NO_SOUND
int fd = 0;
@@ -412,2 +430,3 @@ static void setTreble( int t = 0, int percent = -1 )
}
+#endif
}
@@ -1651,2 +1670,8 @@ void QPEApplication::internalSetStyle( const QString &style )
+#ifdef Q_OS_MACX
+ if ( style. find ( ".dylib" ) > 0 )
+ path += style;
+ else
+ path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility
+#else
if ( style. find ( ".so" ) > 0 )
@@ -1655,3 +1680,3 @@ void QPEApplication::internalSetStyle( const QString &style )
path = path + "lib" + style. lower ( ) + ".so"; // compatibility
-
+#endif
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 )
+#ifdef Q_OS_MACX
+ if ( plugin.find( ".dylib" ) > 0 ) {
+#else
if ( plugin.find( ".so" ) > 0 ) {
+#endif
// full library name supplied
@@ -518,3 +522,7 @@ void QPEDecoration::init ( const QString &plugin )
} else {
+#ifdef Q_OS_MACX
+ path += "lib" + plugin.lower() + ".dylib"; // compatibility
+#else
path += "lib" + plugin.lower() + ".so"; // compatibility
+#endif
}
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 @@
#include <sys/ioctl.h>
+
+#ifndef QT_NO_SOUND
#include <sys/soundcard.h>
+#endif
diff --git a/library/storage.cpp b/library/storage.cpp
index dc5cc22..f8b75d0 100644
--- a/library/storage.cpp
+++ b/library/storage.cpp
@@ -36,6 +36,15 @@
+#ifdef Q_OS_MACX
+# include <sys/param.h>
+# include <sys/ucred.h>
+# include <sys/mount.h>
+# include <stdio.h> // For strerror()
+# include <errno.h>
+#endif /* Q_OS_MACX */
+
#include <qstringlist.h>
-#include <sys/vfs.h>
-#include <mntent.h>
+// Shouldn't be here ! (eilers)
+// #include <sys/vfs.h>
+// #include <mntent.h>
@@ -44,2 +53,4 @@ static bool isCF(const QString& m)
{
+
+#ifndef Q_OS_MACX
FILE* f = fopen("/var/run/stab", "r");
@@ -63,2 +74,3 @@ static bool isCF(const QString& m)
}
+#endif /* Q_OS_MACX */
return FALSE;
@@ -208,2 +220,19 @@ bool deviceTab( const char *device) {
bool hasDevice=false;
+
+#ifdef Q_OS_MACX
+ // Darwin (MacOS X)
+ struct statfs** mntbufp;
+ int count = 0;
+ if ( ( count = getmntinfo( mntbufp, MNT_WAIT ) ) == 0 ){
+ qWarning("deviceTab: Error in getmntinfo(): %s",strerror( errno ) );
+ hasDevice = false;
+ }
+ for( int i = 0; i < count; i++ ){
+ QString deviceName = mntbufp[i]->f_mntfromname;
+ qDebug(deviceName);
+ if( deviceName.left( name.length() ) == name )
+ hasDevice = true;
+ }
+#else
+ // Linux
struct mntent *me;
@@ -220,2 +249,5 @@ bool deviceTab( const char *device) {
endmntent( mntfp );
+#endif /* Q_OS_MACX */
+
+
return hasDevice;