-rw-r--r-- | library/filemanager.cpp | 67 | ||||
-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 | 42 |
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 @@ -10,49 +10,58 @@ ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "filemanager.h" #include "applnk.h" #include <qdir.h> #include <qfile.h> #include <qfileinfo.h> #include <qtextstream.h> #include <qtextcodec.h> #include <errno.h> #include <stdlib.h> #include <unistd.h> #include <sys/stat.h> #include <dirent.h> -#include <sys/sendfile.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> /*! \class FileManager \brief The FileManager class assists with AppLnk input/output. */ /*! Constructs a FileManager. */ FileManager::FileManager() { } /*! Destroys a FileManager. */ FileManager::~FileManager() { } /*! Saves \a data as the document specified by \a f. @@ -195,81 +204,115 @@ bool FileManager::copyFile( const AppLnk &src, const AppLnk &dest ) ok = FALSE; else bytesRead -= bytesWritten; } } if ( ok ) ok = dest.writeLink(); if ( ok ) { // okay now rename the file... if ( !renameFile( fn.latin1(), dest.file().latin1() ) ) { qWarning( "problem renaming file %s to %s, errno: %d", fn.latin1(), dest.file().latin1(), errno ); // remove the tmp file, otherwise, it will just lay around... QFile::remove( fn.latin1() ); } } else { QFile::remove( fn.latin1() ); } return ok; } + + bool FileManager::copyFile( const QString & src, const QString & dest ) { bool success = true; struct stat status; int read_fd=0; int write_fd=0; struct stat stat_buf; off_t offset = 0; QFile srcFile(src); QFile destFile(dest); if(!srcFile.open( IO_ReadOnly|IO_Raw)) { return success = false; } read_fd = srcFile.handle(); if(read_fd != -1) { fstat (read_fd, &stat_buf); if( !destFile.open( IO_WriteOnly|IO_Raw ) ) return success = false; write_fd = destFile.handle(); if(write_fd != -1) { int err=0; QString msg; - err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); - if( err == -1) { - switch(err) { - case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; - case EINVAL: msg = "Descriptor is not valid or locked. "; - case ENOMEM: msg = "Insufficient memory to read from in_fd."; - case EIO: msg = "Unspecified error while reading from in_fd."; - }; - success = false; - } - } else { +#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); + if( err == -1) { + switch(err) { + case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; + case EINVAL: msg = "Descriptor is not valid or locked. "; + case ENOMEM: msg = "Insufficient memory to read from in_fd."; + case EIO: msg = "Unspecified error while reading from in_fd."; + }; + success = false; + } +#endif /* Q_OS_MACX */ + if( !success ) + qWarning( msg ); + } else { qWarning("open write failed %s, %s",src.latin1(), dest.latin1()); success = false; } } else { qWarning("open read failed %s, %s",src.latin1(), dest.latin1()); success = false; } srcFile.close(); destFile.close(); // Set file permissions if( stat( (const char *) src, &status ) == 0 ) { chmod( (const char *) dest, status.st_mode ); } return success; } bool FileManager::renameFile( const QString & src, const QString & dest ) { if(copyFile( src, dest )) { if(QFile::remove(src) ) { return true; } } diff --git a/library/fontdatabase.cpp b/library/fontdatabase.cpp index c7a5211..2ad8e95 100644 --- a/library/fontdatabase.cpp +++ b/library/fontdatabase.cpp @@ -149,49 +149,53 @@ QValueList<int> FontDatabase::standardSizes() that the plugins can read available. */ void FontDatabase::loadRenderers() { #ifndef QWS return; #else #ifndef QT_NO_COMPONENT if ( !factoryList ) factoryList = new QValueList<FontFactory>; QValueList<FontFactory>::Iterator mit; for ( mit = factoryList->begin(); mit != factoryList->end(); ++mit ) { qt_fontmanager->factories.setAutoDelete( false ); qt_fontmanager->factories.removeRef( (*mit).factory ); qt_fontmanager->factories.setAutoDelete( true ); (*mit).interface->release(); (*mit).library->unload(); delete (*mit).library; } factoryList->clear(); QString path = QPEApplication::qpeDir() + "/plugins/fontfactories"; +#ifdef Q_OS_MACX + QDir dir( path, "lib*.dylib" ); +#else QDir dir( path, "lib*.so" ); +#endif if ( !dir.exists()) return; QStringList list = dir.entryList(); QStringList::Iterator it; for ( it = list.begin(); it != list.end(); ++it ) { FontFactoryInterface *iface = 0; QLibrary *lib = new QLibrary( path + "/" + *it ); if ( lib->queryInterface( IID_FontFactory, (QUnknownInterface**)&iface ) == QS_OK ) { FontFactory factory; factory.library = lib; factory.interface = iface; factory.factory = factory.interface->fontFactory(); factoryList->append( factory ); qt_fontmanager->factories.append( factory.factory ); readFonts( factory.factory ); } else { delete lib; } } #endif #endif } diff --git a/library/global.cpp b/library/global.cpp index 90954fe..05d23ac 100644 --- a/library/global.cpp +++ b/library/global.cpp @@ -583,49 +583,53 @@ void Global::invoke(const QString &c) #endif #ifdef QT_NO_QWS_MULTIPROCESS QMessageBox::warning( 0, "Error", "Could not find the application " + c, "Ok", 0, 0, 0, 1 ); #else QStrList slist; unsigned int j; for ( j = 0; j < list.count(); j++ ) slist.append( list[j].utf8() ); const char **args = new (const char *)[slist.count() + 1]; for ( j = 0; j < slist.count(); j++ ) args[j] = slist.at(j); args[j] = NULL; #if !defined(QT_NO_COP) // an attempt to show a wait... // more logic should be used, but this will be fine for the moment... QCopEnvelope ( "QPE/System", "busy()" ); #endif #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() ); if ( QFile::exists( libexe ) ) { qDebug("calling quickexec %s", libexe.latin1() ); quickexecv( libexe.utf8().data(), (const char **)args ); } else #endif { bool success = false; int pfd [2]; if ( ::pipe ( pfd ) < 0 ) pfd [0] = pfd [1] = -1; pid_t pid = ::fork ( ); if ( pid == 0 ) { // child for ( int fd = 3; fd < 100; fd++ ) { if ( fd != pfd [1] ) ::close ( fd ); } ::setpgid ( ::getpid ( ), ::getppid ( )); // Closing of fd[1] indicates that the execvp succeeded! if ( pfd [1] >= 0 ) ::fcntl ( pfd [1], F_SETFD, FD_CLOEXEC ); diff --git a/library/library.pro b/library/library.pro index ab1f451..5acfc0c 100644 --- a/library/library.pro +++ b/library/library.pro @@ -103,49 +103,49 @@ SOURCES = calendar.cpp \ backend/categories.cpp \ backend/stringutil.cpp \ backend/palmtoprecord.cpp \ backend/task.cpp \ backend/event.cpp \ backend/contact.cpp \ categorymenu.cpp \ categoryedit_p.cpp \ categoryselect.cpp \ categorywidget.cpp \ ir.cpp \ backend/vcc_yacc.cpp \ backend/vobject.cpp \ findwidget_p.cpp \ finddialog.cpp \ lnkproperties.cpp \ qt_override.cpp # Qt 3 compatibility HEADERS += quuid.h qcom.h qlibrary.h qlibrary_p.h 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 TARGET = qpe DESTDIR = $(OPIEDIR)/lib$(PROJMAK) VERSION = 1.5.0.1 TRANSLATIONS = ../i18n/de/libqpe.ts \ ../i18n/nl/libqpe.ts \ ../i18n/xx/libqpe.ts \ ../i18n/en/libqpe.ts \ ../i18n/es/libqpe.ts \ ../i18n/fr/libqpe.ts \ ../i18n/hu/libqpe.ts \ ../i18n/ja/libqpe.ts \ ../i18n/ko/libqpe.ts \ ../i18n/no/libqpe.ts \ ../i18n/pl/libqpe.ts \ ../i18n/pt/libqpe.ts \ ../i18n/pt_BR/libqpe.ts \ ../i18n/sl/libqpe.ts \ ../i18n/zh_CN/libqpe.ts \ ../i18n/it/libqpe.ts \ ../i18n/zh_TW/libqpe.ts \ ../i18n/da/libqpe.ts diff --git a/library/network.cpp b/library/network.cpp index 3568809..991e11a 100644 --- a/library/network.cpp +++ b/library/network.cpp @@ -397,48 +397,52 @@ int Network::addStateWidgets(QWidget* parent) NetworkInterface* plugin = Network::loadPlugin(type); cfg.setGroup("Properties"); if ( plugin ) { QWidget* w; if ( (w=plugin->addStateWidget(parent,cfg)) ) { n++; vb->addWidget(w); } } } return n; } static QDict<NetworkInterface> *ifaces; /*! \internal */ NetworkInterface* Network::loadPlugin(const QString& type) { #ifndef QT_NO_COMPONENT if ( !ifaces ) ifaces = new QDict<NetworkInterface>; NetworkInterface *iface = ifaces->find(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); if ( !lib.queryInterface( IID_Network, (QUnknownInterface**)&iface ) == QS_OK ) return 0; ifaces->insert(type,iface); QStringList langs = Global::languageList(); for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { QString lang = *it; QTranslator * trans = new QTranslator(qApp); QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/lib"+type+".qm"; if ( trans->load( tfn )) qApp->installTranslator( trans ); else delete trans; } } return iface; #else return 0; #endif } #include "network.moc" #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 @@ -55,49 +55,160 @@ bool QLibraryPrivate::freeLibrary() return TRUE; if ( !shl_unload( (shl_t)pHnd ) ) { pHnd = 0; return TRUE; } return FALSE; } void* QLibraryPrivate::resolveSymbol( const char* symbol ) { if ( !pHnd ) return 0; void* address = 0; if ( shl_findsym( (shl_t*)&pHnd, symbol, TYPE_UNDEFINED, address ) < 0 ) { #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) qDebug( "Couldn't resolve symbol \"%s\"", symbol ); #endif return 0; } return address; } -#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 #include <dlfcn.h> bool QLibraryPrivate::loadLibrary() { if ( pHnd ) return TRUE; QString filename = library->library(); pHnd = dlopen( filename.latin1() , RTLD_LAZY ); #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) if ( !pHnd ) qWarning( "%s", dlerror() ); #endif return pHnd != 0; } bool QLibraryPrivate::freeLibrary() { if ( !pHnd ) return TRUE; int ec = dlclose( pHnd ); diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index d4734ae..a97efc0 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp @@ -1,47 +1,49 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** */ #define QTOPIA_INTERNAL_LANGLIST #include <stdlib.h> #include <unistd.h> +#ifndef Q_OS_MACX #include <linux/limits.h> // needed for some toolchains (PATH_MAX) +#endif #include <qfile.h> #include <qqueue.h> #ifdef Q_WS_QWS #ifndef QT_NO_COP #if QT_VERSION <= 231 #define private public #define sendLocally processEvent #include "qcopenvelope_qws.h" #undef private #else #include "qcopenvelope_qws.h" #endif #endif #include <qwindowsystem_qws.h> #endif #include <qtextstream.h> #include <qpalette.h> #include <qbuffer.h> #include <qptrdict.h> #include <qregexp.h> #include <qdir.h> #include <qlabel.h> #include <qdialog.h> #include <qdragobject.h> @@ -68,50 +70,51 @@ #include "lightstyle.h" #include <qpe/qlibrary.h> #endif #include "global.h" #include "resource.h" #if QT_VERSION <= 230 && defined(QT_NO_CODECS) #include "qutfcodec.h" #endif #include "config.h" #include "network.h" #ifdef QWS #include "fontmanager.h" #endif #include "alarmserver.h" #include "applnk.h" #include "qpemenubar.h" #include "textcodecinterface.h" #include "imagecodecinterface.h" #include <unistd.h> #include <sys/file.h> #include <sys/ioctl.h> +#ifndef QT_NO_SOUND #include <sys/soundcard.h> - +#endif #include "qt_override_p.h" class QPEApplicationData { public: QPEApplicationData ( ) : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), keep_running( true ), qcopQok( false ), qpe_main_widget( 0 ) {} int presstimer; QWidget* presswidget; QPoint presspos; bool rightpressed : 1; bool kbgrabbed : 1; bool notbusysent : 1; bool preloaded : 1; bool forceshow : 1; bool nomaximize : 1; bool keep_running : 1; @@ -212,74 +215,82 @@ public: void show(QWidget* mw, bool nomax) { setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); nomaximize = nomax; qpe_main_widget = mw; qcopQok = TRUE; #ifndef QT_NO_COP sendQCopQ(); #endif if ( preloaded ) { if (forceshow) show_mx(mw, nomax); } else if ( keep_running ) { show_mx(mw, nomax); } } void loadTextCodecs() { QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; +#ifdef Q_OS_MACX + QDir dir( path, "lib*.dylib" ); +#else QDir dir( path, "lib*.so" ); +#endif QStringList list; if ( dir. exists ( )) list = dir.entryList(); QStringList::Iterator it; for ( it = list.begin(); it != list.end(); ++it ) { TextCodecInterface *iface = 0; QLibrary *lib = new QLibrary( path + "/" + *it ); if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { QValueList<int> mibs = iface->mibEnums(); for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { (void)iface->createForMib(*i); // ### it exists now; need to remember if we can delete it } } else { lib->unload(); delete lib; } } } void loadImageCodecs() { QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; +#ifdef Q_OS_MACX + QDir dir( path, "lib*.dylib" ); +#else QDir dir( path, "lib*.so" ); +#endif QStringList list; if ( dir. exists ( )) list = dir.entryList(); QStringList::Iterator it; for ( it = list.begin(); it != list.end(); ++it ) { ImageCodecInterface *iface = 0; QLibrary *lib = new QLibrary( path + "/" + *it ); if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { QStringList formats = iface->keys(); for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { (void)iface->installIOHandler(*i); // ### it exists now; need to remember if we can delete it } } else { lib->unload(); delete lib; } } } }; class ResourceMimeFactory : public QMimeSourceFactory { @@ -319,118 +330,126 @@ private: mutable QImageDrag *resImage; }; static int& hack(int& i) { #if QT_VERSION <= 230 && defined(QT_NO_CODECS) // These should be created, but aren't in Qt 2.3.0 (void)new QUtf8Codec; (void)new QUtf16Codec; #endif return i; } static int muted = 0; static int micMuted = 0; static void setVolume( int t = 0, int percent = -1 ) { switch ( t ) { case 0: { Config cfg( "qpe" ); cfg.setGroup( "Volume" ); if ( percent < 0 ) percent = cfg.readNumEntry( "VolumePercent", 50 ); +#ifndef QT_NO_SOUND int fd = 0; if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { int vol = muted ? 0 : percent; // set both channels to same volume vol |= vol << 8; ioctl( fd, MIXER_WRITE( 0 ), &vol ); ::close( fd ); } +#endif } break; } } static void setMic( int t = 0, int percent = -1 ) { switch ( t ) { case 0: { Config cfg( "qpe" ); cfg.setGroup( "Volume" ); if ( percent < 0 ) percent = cfg.readNumEntry( "Mic", 50 ); +#ifndef QT_NO_SOUND int fd = 0; int mic = micMuted ? 0 : percent; if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); ::close( fd ); } +#endif } break; } } static void setBass( int t = 0, int percent = -1 ) { switch ( t ) { case 0: { Config cfg( "qpe" ); cfg.setGroup( "Volume" ); if ( percent < 0 ) percent = cfg.readNumEntry( "BassPercent", 50 ); +#ifndef QT_NO_SOUND int fd = 0; int bass = percent; if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); ::close( fd ); } +#endif } break; } } static void setTreble( int t = 0, int percent = -1 ) { switch ( t ) { case 0: { Config cfg( "qpe" ); cfg.setGroup( "Volume" ); if ( percent < 0 ) percent = cfg.readNumEntry( "TreblePercent", 50 ); +#ifndef QT_NO_SOUND int fd = 0; int treble = percent; if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); ::close( fd ); } +#endif } break; } } /*! \class QPEApplication qpeapplication.h \brief The QPEApplication class implements various system services that are available to all Qtopia applications. Simply by using QPEApplication instead of QApplication, a standard Qt application becomes a Qtopia application. It automatically follows style changes, quits and raises, and in the case of \link docwidget.html document-oriented\endlink applications, changes the currently displayed document in response to the environment. To create a \link docwidget.html document-oriented\endlink application use showMainDocumentWidget(); to create a non-document-oriented application use showMainWidget(). The keepRunning() function indicates whether the application will continue running after it's processed the last \link qcop.html QCop\endlink message. This can be changed using setKeepRunning(). @@ -1628,53 +1647,59 @@ void QPEApplication::internalSetStyle( const QString &style ) } else if ( style == "Light" ) { setStyle( new LightStyle ); } #ifndef QT_NO_STYLE_PLATINUM else if ( style == "Platinum" ) { setStyle( new QPlatinumStyle ); } #endif #ifndef QT_NO_STYLE_MOTIF else if ( style == "Motif" ) { setStyle( new QMotifStyle ); } #endif #ifndef QT_NO_STYLE_MOTIFPLUS else if ( style == "MotifPlus" ) { setStyle( new QMotifPlusStyle ); } #endif else { QStyle *sty = 0; QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; +#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 ) path += style; else path = path + "lib" + style. lower ( ) + ".so"; // compatibility - +#endif static QLibrary *lastlib = 0; static StyleInterface *lastiface = 0; QLibrary *lib = new QLibrary ( path ); StyleInterface *iface = 0; if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) sty = iface-> style ( ); if ( sty ) { setStyle ( sty ); if ( lastiface ) lastiface-> release ( ); lastiface = iface; if ( lastlib ) { lastlib-> unload ( ); delete lastlib; } lastlib = lib; } else { if ( iface ) 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 @@ -491,53 +491,61 @@ QPEDecoration::QPEDecoration() } QPEDecoration::QPEDecoration( const QString &plugin ) : QWSDefaultDecoration() { init ( plugin ); } void QPEDecoration::init ( const QString &plugin ) { libname = plugin; if ( wdlib ) { wdiface->release(); wdlib->unload(); delete wdlib; wdlib = 0; } else { delete wdiface; } WindowDecorationInterface *iface = 0; QString path = QPEApplication::qpeDir() + "/plugins/decorations/"; +#ifdef Q_OS_MACX + if ( plugin.find( ".dylib" ) > 0 ) { +#else if ( plugin.find( ".so" ) > 0 ) { +#endif // full library name supplied path += plugin; } else { +#ifdef Q_OS_MACX + path += "lib" + plugin.lower() + ".dylib"; // compatibility +#else path += "lib" + plugin.lower() + ".so"; // compatibility +#endif } QLibrary *lib = new QLibrary( path ); if ( lib->queryInterface( IID_WindowDecoration, (QUnknownInterface**)&iface ) == QS_OK && iface ) { wdiface = iface; wdlib = lib; } else { delete lib; wdiface = new DefaultWindowDecoration; } helpFile = QString(qApp->argv()[0]) + ".html"; QStringList helpPath = Global::helpPath(); helpExists = FALSE; for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !helpExists; ++it) { helpExists = QFile::exists( *it + "/" + helpFile ); //qDebug ( "Checking %s/%s for help: %d", (*it).latin1(), helpFile.latin1(),helpExists); } qpeManager = new QPEManager( this ); // Qtopia 1.5 compatibility imageOk = *okImage ( 15 ); imageClose = *closeImage ( 15 ); imageHelp = *helpImage ( 15 ); diff --git a/library/sound.cpp b/library/sound.cpp index c8704f9..5b67995 100644 --- a/library/sound.cpp +++ b/library/sound.cpp @@ -7,49 +7,52 @@ ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include <qpe/resource.h> #include <qpe/sound.h> #include <qpe/qcopenvelope_qws.h> #include <qsound.h> #include <qfile.h> #include <unistd.h> #include <fcntl.h> #include <sys/ioctl.h> + +#ifndef QT_NO_SOUND #include <sys/soundcard.h> +#endif #include "config.h" #include <qmessagebox.h> #ifndef QT_NO_SOUND static int WAVsoundDuration(const QString& filename) { // bad solution // most of this is copied from qsoundqss.cpp QFile input(filename); if ( !input.open(IO_ReadOnly) ) return 0; struct QRiffChunk { char id[4]; Q_UINT32 size; char data[4/*size*/]; } chunk; struct { Q_INT16 formatTag; Q_INT16 channels; Q_INT32 samplesPerSec; diff --git a/library/storage.cpp b/library/storage.cpp index dc5cc22..f8b75d0 100644 --- a/library/storage.cpp +++ b/library/storage.cpp @@ -8,80 +8,92 @@ ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include <qpe/storage.h> #include <qpe/custom.h> #include <qfile.h> #include <qtimer.h> #include <qcopchannel_qws.h> #include <stdio.h> -#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) +#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) #include <sys/vfs.h> #include <mntent.h> #endif +#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> static bool isCF(const QString& m) { + +#ifndef Q_OS_MACX FILE* f = fopen("/var/run/stab", "r"); if (!f) f = fopen("/var/state/pcmcia/stab", "r"); if (!f) f = fopen("/var/lib/pcmcia/stab", "r"); if ( f ) { char line[1024]; char devtype[80]; char devname[80]; while ( fgets( line, 1024, f ) ) { // 0 ide ide-cs 0 hda 3 0 if ( sscanf(line,"%*d %s %*s %*s %s", devtype, devname )==2 ) { if ( QString(devtype) == "ide" && m.find(devname)>0 ) { fclose(f); return TRUE; } } } fclose(f); } +#endif /* Q_OS_MACX */ return FALSE; } /*! \class StorageInfo storage.h \brief The StorageInfo class describes the disks mounted on the file system. This class provides access to the mount information for the Linux filesystem. Each mount point is represented by the FileSystem class. To ensure this class has the most up to date size information, call the update() method. Note that this will automatically be signaled by the operating system when a disk has been mounted or unmounted. \ingroup qtopiaemb */ /*! Constructor that determines the current mount points of the filesystem. The standard \a parent parameters is passed on to QObject. */ StorageInfo::StorageInfo( QObject *parent ) : QObject( parent ) { mFileSystems.setAutoDelete( TRUE ); channel = new QCopChannel( "QPE/Card", this ); connect( channel, SIGNAL(received(const QCString &, const QByteArray &)), @@ -183,62 +195,82 @@ void StorageInfo::update() humanname = tr("Internal Memory"); else if ( disk == "/dev/mtdblock1" || humanname == "/dev/mtdblock/1" ) humanname = tr("Internal Storage"); else if ( disk.left(14) == "/dev/mtdblock/" ) humanname = tr("Internal Storage") + " " + disk; else if ( disk.left(13) == "/dev/mtdblock" ) humanname = tr("Internal Storage") + " " + disk; else if ( disk.left(9) == "/dev/root" ) humanname = tr("Internal Storage") + " " + disk; else if ( disk.left(5) == "tmpfs" ) //ipaqs /mnt/ramfs humanname = tr("Internal Memory"); FileSystem *fs = new FileSystem( disk, *fsit, humanname, removable, opts ); mFileSystems.append( fs ); } emit disksChanged(); } else { // just update them for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) i.current()->update(); } #endif } bool deviceTab( const char *device) { - QString name = device; - bool hasDevice=false; + QString name = 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; FILE *mntfp = setmntent( "/etc/mtab", "r" ); if ( mntfp ) { while ( (me = getmntent( mntfp )) != 0 ) { QString deviceName = me->mnt_fsname; // qDebug(deviceName); if( deviceName.left(name.length()) == name) { hasDevice = true; } } } endmntent( mntfp ); +#endif /* Q_OS_MACX */ + + return hasDevice; } /*! * @fn static bool StorageInfo::hasCf() * @brief returns whether device has Cf mounted * */ bool StorageInfo::hasCf() { return deviceTab("/dev/hd"); } /*! * @fn static bool StorageInfo::hasSd() * @brief returns whether device has SD mounted * */ bool StorageInfo::hasSd() { return deviceTab("/dev/mmcd"); } /*! |