author | zecke <zecke> | 2002-10-17 16:45:38 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-17 16:45:38 (UTC) |
commit | 0655456f68849bfad9019a7760dec961792d7519 (patch) (side-by-side diff) | |
tree | 4651cad54a144385442a26e78f4a83b57501830f | |
parent | 8511273d7122d50ffea27f78ba13ab72af60326d (diff) | |
download | opie-0655456f68849bfad9019a7760dec961792d7519.zip opie-0655456f68849bfad9019a7760dec961792d7519.tar.gz opie-0655456f68849bfad9019a7760dec961792d7519.tar.bz2 |
Move around some #ifdefs to be able to be built with Qt2/X11
-rw-r--r-- | core/launcher/desktop.cpp | 10 | ||||
-rw-r--r-- | core/launcher/launcher.cpp | 2 | ||||
-rw-r--r-- | core/launcher/main.cpp | 7 | ||||
-rw-r--r-- | core/launcher/qcopbridge.cpp | 2 | ||||
-rw-r--r-- | core/launcher/runningappbar.cpp | 2 | ||||
-rw-r--r-- | core/launcher/transferserver.cpp | 2 |
6 files changed, 12 insertions, 13 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index d74b745..1fd3f6a 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp @@ -123,65 +123,64 @@ public: { currentPriority = INT_MAX; alertCount = 0; } void alert( const QString &text, int priority ); void hideEvent( QHideEvent * ); private: int currentPriority; int alertCount; }; void DesktopPowerAlerter::alert( const QString &text, int priority ) { alertCount++; if ( alertCount < priority ) return ; if ( priority > currentPriority ) return ; currentPriority = priority; setText( text ); show(); } void DesktopPowerAlerter::hideEvent( QHideEvent *e ) { QMessageBox::hideEvent( e ); alertCount = 0; currentPriority = INT_MAX; } - class QPEScreenSaver : public QWSScreenSaver { private: int LcdOn; public: QPEScreenSaver() { m_disable_suspend = 100; m_enable_dim = false; m_enable_lightoff = false; m_enable_onlylcdoff = false; m_lcd_status = true; m_backlight_bright = -1; m_backlight_forcedoff = false; // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) ODevice::inst ( ) -> setDisplayStatus ( true ); } void restore() { if ( !m_lcd_status ) { // We must have turned it off ODevice::inst ( ) -> setDisplayStatus ( true ); m_lcd_status = true; } setBacklight ( -1 ); } bool save( int level ) { @@ -296,65 +295,64 @@ public: bright = m_backlight_bright ? 0 : -1; m_backlight_forcedoff = !bright; } m_backlight_bright = bright; bright = backlight ( ); ODevice::inst ( ) -> setDisplayBrightness ( bright ); m_backlight_bright = bright; } void setDisplayState ( bool on ) { if ( m_lcd_status != on ) { ODevice::inst ( ) -> setDisplayStatus ( on ); m_lcd_status = on; } } private: int m_disable_suspend; bool m_enable_dim; bool m_enable_lightoff; bool m_enable_onlylcdoff; bool m_lcd_status; int m_backlight_bright; bool m_backlight_forcedoff; }; - void DesktopApplication::switchLCD ( bool on ) { if ( qApp ) { DesktopApplication *dapp = (DesktopApplication *) qApp; if ( dapp-> m_screensaver ) { if ( on ) { dapp-> m_screensaver-> setDisplayState ( true ); dapp-> m_screensaver-> setBacklight ( -3 ); } else { dapp-> m_screensaver-> setDisplayState ( false ); } } } } DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) : QPEApplication( argc, argv, appType ) { QTimer * t = new QTimer( this ); connect( t, SIGNAL( timeout() ), this, SLOT( psTimeout() ) ); t->start( 10000 ); ps = new PowerStatus; pa = new DesktopPowerAlerter( 0 ); channel = new QCopChannel( "QPE/Desktop", this ); connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); @@ -613,65 +611,65 @@ Desktop::Desktop() : launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) ); connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) ); int displayw = qApp->desktop() ->width(); int displayh = qApp->desktop() ->height(); QSize sz = tb->sizeHint(); setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); tb->show(); launcher->showMaximized(); launcher->show(); launcher->raise(); #if defined(QPE_HAVE_MEMALERTER) initMemalerter(); #endif // start services startTransferServer(); ( void ) new IrServer( this ); rereadVolumes(); packageSlave = new PackageSlave( this ); connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) ); qApp->installEventFilter( this ); - + qApp-> setMainWidget ( launcher ); } void Desktop::show() { login( TRUE ); QWidget::show(); } Desktop::~Desktop() { delete launcher; delete tb; delete qcopBridge; delete transferServer; } bool Desktop::recoverMemory() { return tb->recoverMemory(); } void Desktop::checkMemory() { #if defined(QPE_HAVE_MEMALERTER) static bool ignoreNormal = FALSE; static bool existingMessage = FALSE; if ( existingMessage ) return ; // don't show a second message while still on first existingMessage = TRUE; @@ -680,101 +678,105 @@ void Desktop::checkMemory() break; case Low: memstate = Unknown; if ( recoverMemory() ) ignoreNormal = TRUE; else QMessageBox::warning( 0 , "Memory Status", "The memory smacks of shortage. \n" "Please save data. " ); break; case Normal: memstate = Unknown; if ( ignoreNormal ) ignoreNormal = FALSE; // else // QMessageBox::information ( 0 , "Memory Status", // "There is enough memory again." ); break; case VeryLow: memstate = Unknown; QMessageBox::critical( 0 , "Memory Status", "The memory is very low. \n" "Please end this application \n" "immediately." ); recoverMemory(); } existingMessage = FALSE; #endif } static bool isVisibleWindow( int wid ) { +#ifdef QWS const QList<QWSWindow> &list = qwsServer->clientWindows(); QWSWindow* w; for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { if ( w->winId() == wid ) return !w->isFullyObscured(); } +#endif return FALSE; } static bool hasVisibleWindow( const QString& clientname ) { +#ifdef QWS const QList<QWSWindow> &list = qwsServer->clientWindows(); QWSWindow* w; for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { if ( w->client() ->identity() == clientname && !w->isFullyObscured() ) return TRUE; } +#endif return FALSE; } void Desktop::raiseLauncher() { Config cfg( "qpe" ); //F12 'Home' cfg.setGroup( "AppsKey" ); QString tempItem; tempItem = cfg.readEntry( "Middle", "Home" ); if ( tempItem == "Home" || tempItem.isEmpty() ) { home ( ); } else { QCopEnvelope e( "QPE/System", "execute(QString)" ); e << tempItem; } } void Desktop::home ( ) -{ +{ if ( isVisibleWindow( launcher->winId() ) ) launcher->nextView(); else launcher->raise(); } void Desktop::executeOrModify( const QString& appLnkFile ) { AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile ); if ( lnk.isValid() ) { QCString app = lnk.exec().utf8(); Global::terminateBuiltin( "calibrate" ); if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) { // MRUList::addTask( &lnk ); if ( hasVisibleWindow( app ) ) QCopChannel::send( "QPE/Application/" + app, "nextView()" ); else QCopChannel::send( "QPE/Application/" + app, "raise()" ); } else { lnk.execute(); } } } void Desktop::raiseDatebook() { Config cfg( "qpe" ); //F9 'Activity' cfg.setGroup( "AppsKey" ); QString tempItem; tempItem = cfg.readEntry( "LeftEnd" , "Calendar" ); if ( tempItem == "Calendar" || tempItem.isEmpty() ) { diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index 66cc3e6..a5955a4 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp @@ -1,59 +1,57 @@ /********************************************************************** ** 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. ** **********************************************************************/ // WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT // have this class. #define QTOPIA_INTERNAL_FSLP -#ifdef QWS #include <qpe/qcopenvelope_qws.h> -#endif #include <qpe/resource.h> #include <qpe/applnk.h> #include <qpe/config.h> #include <qpe/global.h> #include <qpe/qpeapplication.h> #include <qpe/mimetype.h> #include <qpe/storage.h> #include <qpe/palmtoprecord.h> #include <qpe/version.h> #include <qdir.h> #ifdef QWS #include <qwindowsystem_qws.h> #endif #include <qtimer.h> #include <qcombobox.h> #include <qvbox.h> #include <qlayout.h> #include <qstyle.h> #include <qpushbutton.h> #include <qtabbar.h> #include <qwidgetstack.h> #include <qlayout.h> #include <qregexp.h> #include <qmessagebox.h> #include <qframe.h> #include <qpainter.h> #include <qlabel.h> #include <qtextstream.h> #include <qpopupmenu.h> diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp index 073e19a..762a596 100644 --- a/core/launcher/main.cpp +++ b/core/launcher/main.cpp @@ -3,86 +3,87 @@ ** ** This file is part of 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. ** **********************************************************************/ #include "desktop.h" #include "taskbar.h" #include "stabmon.h" #include <qpe/qpeapplication.h> #include <qpe/network.h> #include <qpe/config.h> #if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) #include <qpe/custom.h> #endif #include <opie/odevice.h> #include <qfile.h> +#include <qimage.h> #include <qwindowsystem_qws.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/alarmserver.h> #include <stdlib.h> #include <stdio.h> #include <signal.h> #include <unistd.h> #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) #include "../calibrate/calibrate.h" #endif using namespace Opie; void initEnvironment() { Config config("locale"); config.setGroup( "Location" ); QString tz = config.readEntry( "Timezone", getenv("TZ") ); - // if not timezone set, pick New York + // if not timezone set, pick New York if (tz.isNull()) tz = "America/New_York"; setenv( "TZ", tz, 1 ); config.writeEntry( "Timezone", tz); config.setGroup( "Language" ); QString lang = config.readEntry( "Language", getenv("LANG") ); if ( !lang.isNull() ) setenv( "LANG", lang, 1 ); } int initApplication( int argc, char ** argv ) { initEnvironment(); #if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX) setenv( "QWS_SIZE", "240x320", 0 ); #endif //Don't flicker at startup: QWSServer::setDesktopBackground( QImage() ); DesktopApplication a( argc, argv, QApplication::GuiServer ); ODevice::inst ( )-> setSoftSuspend ( true ); { // init backlight QCopEnvelope e("QPE/System", "setBacklight(int)" ); e << -3; // Forced on } @@ -100,73 +101,73 @@ int initApplication( int argc, char ** argv ) QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) ); QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) ); QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) ); (void)new SysFileMonitor(d); Network::createServer(d); #if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) if ( !QFile::exists( "/etc/pointercal" ) ) { // Make sure calibration widget starts on top. Calibrate *cal = new Calibrate; cal->exec(); delete cal; } #endif d->show(); int rv = a.exec(); delete d; ODevice::inst ( )-> setSoftSuspend ( false ); return rv; } static const char *pidfile_path = "/var/run/opie.pid"; void create_pidfile ( ) { FILE *f; - + if (( f = ::fopen ( pidfile_path, "w" ))) { ::fprintf ( f, "%d", getpid ( )); ::fclose ( f ); } } void remove_pidfile ( ) { ::unlink ( pidfile_path ); } void handle_sigterm ( int /* sig */ ) { if ( qApp ) qApp-> quit ( ); } int main( int argc, char ** argv ) { ::signal ( SIGCHLD, SIG_IGN ); ::signal ( SIGTERM, handle_sigterm ); ::signal ( SIGINT, handle_sigterm ); ::setsid ( ); ::setpgid ( 0, 0 ); - + ::atexit ( remove_pidfile ); create_pidfile ( ); int retVal = initApplication ( argc, argv ); // Kill them. Kill them all. ::kill ( 0, SIGTERM ); ::sleep ( 1 ); ::kill ( 0, SIGKILL ); return retVal; } diff --git a/core/launcher/qcopbridge.cpp b/core/launcher/qcopbridge.cpp index 85993ee..6177a7c 100644 --- a/core/launcher/qcopbridge.cpp +++ b/core/launcher/qcopbridge.cpp @@ -1,58 +1,56 @@ /********************************************************************** ** 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. ** **********************************************************************/ #include "qcopbridge.h" #include "transferserver.h" -#ifdef QWS #include <qpe/qcopenvelope_qws.h> -#endif #include <qpe/qpeapplication.h> #include <qpe/version.h> #include <qdir.h> #include <qfile.h> #include <qtextstream.h> #include <qdatastream.h> #include <qstringlist.h> #include <qfileinfo.h> #include <qregexp.h> #ifdef QWS #include <qcopchannel_qws.h> #endif #define _XOPEN_SOURCE #include <pwd.h> #include <sys/types.h> #include <unistd.h> #if defined(_OS_LINUX_) #include <shadow.h> #endif //#define INSECURE const int block_size = 51200; QCopBridge::QCopBridge( Q_UINT16 port, QObject *parent , const char* name ) : QServerSocket( port, 1, parent, name ), desktopChannel( 0 ), cardChannel( 0 ) diff --git a/core/launcher/runningappbar.cpp b/core/launcher/runningappbar.cpp index b830d1b..c8f45d5 100644 --- a/core/launcher/runningappbar.cpp +++ b/core/launcher/runningappbar.cpp @@ -15,66 +15,68 @@ ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** ********************************************************************** */ #define QTOPIA_INTERNAL_PRELOADACCESS // For "kill" #include <sys/types.h> #include <signal.h> #include <qtimer.h> #include <qpopupmenu.h> #include <qmessagebox.h> #include <qpainter.h> #include "qprocess.h" #include <qpe/qpeapplication.h> #include <qpe/applnk.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/global.h> #include <qwindowsystem_qws.h> #include "runningappbar.h" RunningAppBar::RunningAppBar(QWidget* parent) : QFrame(parent), m_AppLnkSet(0L), m_SelectedAppIndex(-1) { setBackgroundMode( PaletteBackground ); m_AppLnkSet = new AppLnkSet( QPEApplication::qpeDir() + "apps" ); +#ifdef QWS connect(qwsServer, SIGNAL(newChannel(const QString&)), this, SLOT(newQcopChannel(const QString&))); connect(qwsServer, SIGNAL(removedChannel(const QString&)), this, SLOT(removedQcopChannel(const QString&))); +#endif QCopChannel* channel = new QCopChannel( "QPE/System", this ); connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(received(const QCString&, const QByteArray&)) ); spacing = AppLnk::smallIconSize()+3; } RunningAppBar::~RunningAppBar() { } void RunningAppBar::newQcopChannel(const QString& channelName) { QString prefix("QPE/Application/"); if (channelName.startsWith(prefix)) { QString appName = channelName.mid(prefix.length()); // qDebug("App %s just connected!", appName.latin1()); const AppLnk* newGuy = m_AppLnkSet->findExec(appName); if (newGuy && !newGuy->isPreloaded()) { addTask(*newGuy); } } } void RunningAppBar::removedQcopChannel(const QString& channelName) { QString prefix("QPE/Application/"); if (channelName.startsWith(prefix)) { QString appName = channelName.mid(prefix.length()); qDebug("App %s just disconnected!", appName.latin1()); const AppLnk* newGuy = m_AppLnkSet->findExec(appName); if (newGuy) { removeTask(*newGuy); } } diff --git a/core/launcher/transferserver.cpp b/core/launcher/transferserver.cpp index d2f5501..dea140d 100644 --- a/core/launcher/transferserver.cpp +++ b/core/launcher/transferserver.cpp @@ -27,67 +27,65 @@ /* we need the _OS_LINUX stuff first ! */ #include <qglobal.h> #ifndef _OS_LINUX_ extern "C" { #include <uuid/uuid.h> #define UUID_H_INCLUDED } #endif // not defined linux #if defined(_OS_LINUX_) #include <shadow.h> #endif #include <qdir.h> #include <qfile.h> #include <qtextstream.h> #include <qdatastream.h> #include <qmessagebox.h> #include <qstringlist.h> #include <qfileinfo.h> #include <qregexp.h> //#include <qpe/qcopchannel_qws.h> #include <qpe/process.h> #include <qpe/global.h> #include <qpe/config.h> #include <qpe/contact.h> #include <qpe/quuid.h> #include <qpe/version.h> -#ifdef QWS #include <qpe/qcopenvelope_qws.h> -#endif #include "transferserver.h" #include "qprocess.h" const int block_size = 51200; TransferServer::TransferServer( Q_UINT16 port, QObject *parent , const char* name ) : QServerSocket( port, 1, parent, name ) { if ( !ok() ) qWarning( "Failed to bind to port %d", port ); } TransferServer::~TransferServer() { } void TransferServer::newConnection( int socket ) { (void) new ServerPI( socket, this ); } /* * small class in anonymous namespace * to generate a QUUid for us */ namespace { struct UidGen { QString uuid(); }; |