author | chicken <chicken> | 2004-03-01 16:12:01 (UTC) |
---|---|---|
committer | chicken <chicken> | 2004-03-01 16:12:01 (UTC) |
commit | 9bc70bb8a0bdd3a7bc0013f2cacce7c039b88b38 (patch) (side-by-side diff) | |
tree | 62527c430eb2f6c62ac01c11cdfea06494101a0e | |
parent | 931c55406a043195712955c732a875e17899df90 (diff) | |
download | opie-9bc70bb8a0bdd3a7bc0013f2cacce7c039b88b38.zip opie-9bc70bb8a0bdd3a7bc0013f2cacce7c039b88b38.tar.gz opie-9bc70bb8a0bdd3a7bc0013f2cacce7c039b88b38.tar.bz2 |
fix includes
28 files changed, 1 insertions, 110 deletions
diff --git a/core/applets/batteryapplet/battery.cpp b/core/applets/batteryapplet/battery.cpp index fed9b34..b2cef55 100644 --- a/core/applets/batteryapplet/battery.cpp +++ b/core/applets/batteryapplet/battery.cpp @@ -1,124 +1,123 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** 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 "battery.h" #include "batterystatus.h" /* OPIE */ #include <opie2/otaskbarapplet.h> #include <qpe/applnk.h> #include <qpe/config.h> #include <qpe/power.h> -#include <qpe/qpeapplication.h> /* QT */ #include <qpainter.h> #include <qtimer.h> BatteryMeter::BatteryMeter( QWidget *parent ) : QWidget( parent ), charging(false) { ps = new PowerStatus; startTimer( 10000 ); setFixedWidth( QMAX(AppLnk::smallIconSize()*3/4, 6) ); setFixedHeight( AppLnk::smallIconSize() ); chargeTimer = new QTimer( this ); connect( chargeTimer, SIGNAL(timeout()), this, SLOT(chargeTimeout()) ); timerEvent(0); QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); Config c( "qpe" ); c.setGroup( "Battery" ); style = c.readNumEntry( "Style", 0 ); } BatteryMeter::~BatteryMeter() { delete ps; } QSize BatteryMeter::sizeHint() const { return QSize(QMAX(AppLnk::smallIconSize()*3/4, 6), height() ); } void BatteryMeter::mousePressEvent( QMouseEvent* e ) { if ( e->button() == RightButton ) { style = 1-style; Config c( "qpe" ); c.setGroup( "Battery" ); c.writeEntry( "Style", style ); repaint( true ); } QWidget::mousePressEvent( e ); } void BatteryMeter::mouseReleaseEvent( QMouseEvent* /*e*/ ) { if ( batteryView && batteryView->isVisible() ) { delete (QWidget *) batteryView; } else { if ( !batteryView ) batteryView = new BatteryStatus( ps ); QPEApplication::showWidget( batteryView ); batteryView->raise(); batteryView->show(); } } void BatteryMeter::timerEvent( QTimerEvent * ) { PowerStatus prev = *ps; *ps = PowerStatusManager::readStatus(); if ( prev != *ps ) { percent = ps->batteryPercentRemaining(); if ( !charging && ps->batteryStatus() == PowerStatus::Charging ) { percent = 0; charging = true; chargeTimer->start( 500 ); } else if ( charging && ps->batteryStatus() != PowerStatus::Charging ) { charging = false; chargeTimer->stop(); if ( batteryView ) batteryView->updatePercent( percent ); } repaint( style != 0 ); if ( batteryView ) batteryView->repaint(); } } void BatteryMeter::chargeTimeout() { percent += 20; if ( percent > 100 ) percent = 0; repaint(FALSE); if ( batteryView ) batteryView->updatePercent( percent ); } void BatteryMeter::paintEvent( QPaintEvent* ) { diff --git a/core/applets/batteryapplet/batterystatus.cpp b/core/applets/batteryapplet/batterystatus.cpp index b9ca7b5..ea11495 100644 --- a/core/applets/batteryapplet/batterystatus.cpp +++ b/core/applets/batteryapplet/batterystatus.cpp @@ -1,111 +1,109 @@ #include "batterystatus.h" /* OPIE */ #include <opie2/odevice.h> #include <qpe/power.h> /* QT */ -#include <qpainter.h> #include <qpushbutton.h> #include <qdrawutil.h> #include <qfile.h> #include <qlayout.h> #include <qtextstream.h> -#include <qapplication.h> #include <qmessagebox.h> using namespace Opie; BatteryStatus::BatteryStatus( const PowerStatus *p, QWidget *parent ) : QWidget( parent, 0, WDestructiveClose), ps(p), bat2(false) { setCaption( tr("Battery status") ); setMinimumSize( 150, 200 ); QPushButton *pb = new QPushButton( tr("Close"), this ); QVBoxLayout *layout = new QVBoxLayout ( this ); jackPercent = 0; pb->setMaximumSize( 120, 40 ); pb->show(); layout->addStretch(); layout->addWidget( pb ); if ( ODevice::inst ( )-> series ( ) == Model_iPAQ ) { getProcApmStatusIpaq(); } connect( pb, SIGNAL( clicked() ), this, SLOT( close() ) ); percent = ps->batteryPercentRemaining(); show(); } BatteryStatus::~BatteryStatus() { } /* * Make use of the advanced apm interface of the ipaq */ bool BatteryStatus::getProcApmStatusIpaq() { bat2 = false; QFile procApmIpaq("/proc/hal/battery"); if (procApmIpaq.open(IO_ReadOnly) ) { QStringList list; // since it is /proc we _must_ use QTextStream QTextStream stream ( &procApmIpaq); QString streamIn; streamIn = stream.read(); list = QStringList::split("\n", streamIn); for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) { // not nice, need a rewrite later if( (*line).startsWith(" Percentage") ){ if (bat2 == true) { perc2 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2); } else { perc1 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2); } }else if( (*line).startsWith(" Life") ){ if (bat2 == true) { sec2 = (*line).mid(((*line).find(':')+2), 5 ); } else { sec1 = (*line).mid(((*line).find(':')+2), 5 ); } }else if( (*line).startsWith("Battery #1") ){ bat2 = true; }else if( (*line).startsWith(" Status") ){ if (bat2 == true) { jackStatus = (*line).mid((*line).find('(')+1, (*line).find(')')-(*line).find('(')-1); } else { ipaqStatus = (*line).mid((*line).find('(')+1, (*line).find(')')-(*line).find('(')-1); } }else if( (*line).startsWith(" Chemistry") ) { if (bat2 == true) { jackChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1); } else { ipaqChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1); } } } } else { QMessageBox::warning(this, tr("Failure"),tr("could not open file")); } procApmIpaq.close(); jackPercent = perc2.toInt(); ipaqPercent = perc1.toInt(); if (perc2.isEmpty()) { perc2 = tr("no data"); } else { perc2 += " %"; } diff --git a/core/applets/cardmon/cardmon.cpp b/core/applets/cardmon/cardmon.cpp index 8ffaada..7625545 100644 --- a/core/applets/cardmon/cardmon.cpp +++ b/core/applets/cardmon/cardmon.cpp @@ -1,127 +1,125 @@ /* * cardmon.cpp * * --------------------- * * copyright : (c) 2002 by Maximilian Reiss * email : max.reiss@gmx.de * based on two apps by Devin Butterfield */ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "cardmon.h" /* OPIE */ #include <opie2/odevice.h> #include <opie2/otaskbarapplet.h> #include <qpe/applnk.h> #include <qpe/resource.h> /* QT */ -#include <qapplication.h> #include <qcopchannel_qws.h> #include <qpainter.h> -#include <qmessagebox.h> #include <qfile.h> #include <qtextstream.h> #include <qsound.h> #include <qtimer.h> /* STD */ #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) #include <sys/vfs.h> #include <mntent.h> #endif using namespace Opie; CardMonitor::CardMonitor( QWidget * parent ) : QWidget( parent ), pm( Resource::loadPixmap( "cardmon/pcmcia" ) ) { QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); connect( pcmciaChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), this, SLOT( cardMessage( const QCString &, const QByteArray & ) ) ); QCopChannel *sdChannel = new QCopChannel( "QPE/Card", this ); connect( sdChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), this, SLOT( cardMessage( const QCString &, const QByteArray & ) ) ); cardInPcmcia0 = FALSE; cardInPcmcia1 = FALSE; cardInSd = FALSE; setFocusPolicy( NoFocus ); setFixedWidth ( AppLnk::smallIconSize() ); setFixedHeight ( AppLnk::smallIconSize() ); getStatusPcmcia( TRUE ); getStatusSd( TRUE ); repaint( FALSE ); popupMenu = 0; } CardMonitor::~CardMonitor() { if ( popupMenu ) { delete popupMenu; } } void CardMonitor::popUp( QString message, QString icon ) { if ( !popupMenu ) { popupMenu = new QPopupMenu( this ); } popupMenu->clear(); if ( icon.isEmpty() ) { popupMenu->insertItem( message, 0 ); } else { popupMenu->insertItem( QIconSet( Resource::loadPixmap( icon ) ), message, 0 ); } QPoint p = mapToGlobal( QPoint( 0, 0 ) ); QSize s = popupMenu->sizeHint(); popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), p.y() - s.height() ), 0 ); QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) ); } void CardMonitor::popupTimeout() { popupMenu->hide(); } void CardMonitor::mousePressEvent( QMouseEvent * ) { QPopupMenu * menu = new QPopupMenu( this ); QString cmd; int err = 0; if ( cardInSd ) { menu->insertItem( QIconSet( Resource::loadPixmap( "cardmon/ide" ) ), diff --git a/core/applets/homeapplet/home.cpp b/core/applets/homeapplet/home.cpp index 455575f..8a930be 100644 --- a/core/applets/homeapplet/home.cpp +++ b/core/applets/homeapplet/home.cpp @@ -1,87 +1,85 @@ #include <qpe/resource.h> #include <qpe/qcopenvelope_qws.h> #include <qapplication.h> -#include <qiconset.h> -#include <qpopupmenu.h> #include "home.h" HomeApplet::HomeApplet ( ) : QObject ( 0, "HomeApplet" ) { } HomeApplet::~HomeApplet ( ) { } int HomeApplet::position ( ) const { return 4; } QString HomeApplet::name ( ) const { return tr( "Home shortcut" ); } QString HomeApplet::text ( ) const { return tr( "Desktop" ); } QString HomeApplet::tr( const char* s ) const { return qApp->translate( "HomeApplet", s, 0 ); } QString HomeApplet::tr( const char* s, const char* p ) const { return qApp->translate( "HomeApplet", s, p ); } QIconSet HomeApplet::icon ( ) const { QPixmap pix; QImage img = Resource::loadImage ( "home" ); if ( !img. isNull ( )) pix. convertFromImage ( img. smoothScale ( 14, 14 )); return pix; } QPopupMenu *HomeApplet::popup ( QWidget * ) const { return 0; } void HomeApplet::activated ( ) { // to desktop (home) QCopEnvelope ( "QPE/Application/qpe", "raise()" ); } QRESULT HomeApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) { *iface = 0; if ( uuid == IID_QUnknown ) *iface = this; else if ( uuid == IID_MenuApplet ) *iface = this; else return QS_FALSE; if ( *iface ) (*iface)-> addRef ( ); return QS_OK; } Q_EXPORT_INTERFACE( ) { Q_CREATE_INSTANCE( HomeApplet ) } diff --git a/core/applets/irdaapplet/irda.cpp b/core/applets/irdaapplet/irda.cpp index f850424..a47f33d 100644 --- a/core/applets/irdaapplet/irda.cpp +++ b/core/applets/irdaapplet/irda.cpp @@ -1,125 +1,120 @@ /********************************************************************** ** Copyright (C) 2002 David Woodhouse <dwmw2@infradead.org> ** Max Reiss <harlekin@handhelds.org> [trivial stuff] ** Robert Griebl <sandman@handhelds.org> ** Holger Freyther <zecke@handhelds.org> QCOP Interface ** ** 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. ** **********************************************************************/ -#include <qcopchannel_qws.h> -#include <qpe/qpeapplication.h> #include <qpe/resource.h> -#include <qpe/ir.h> #include <qpe/qcopenvelope_qws.h> -#include <qpe/sound.h> #include <qpainter.h> #include <qfile.h> #include <qtimer.h> #include <qtextstream.h> -#include <qpopupmenu.h> #include <unistd.h> #include <net/if.h> #include <netinet/in.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/ioctl.h> #include "irda.h" //=========================================================================== IrdaApplet::IrdaApplet ( QWidget *parent, const char *name ) : QWidget ( parent, name ) { setFixedHeight ( 18 ); setFixedWidth ( 14 ); m_sockfd = ::socket ( PF_INET, SOCK_DGRAM, IPPROTO_IP ); m_irdaOnPixmap = Resource::loadPixmap( "irdaapplet/irdaon" ); m_irdaOffPixmap = Resource::loadPixmap( "irdaapplet/irdaoff" ); m_irdaDiscoveryOnPixmap = Resource::loadPixmap( "irdaapplet/magglass" ); m_receiveActivePixmap = Resource::loadPixmap( "irdaapplet/receive" ); m_irda_active = false; m_irda_discovery_active = false; m_receive_active = false; m_receive_state_changed = false; m_popup = 0; m_wasOn = false; m_wasDiscover = false; QCopChannel* chan = new QCopChannel("QPE/IrDaApplet", this ); connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), this, SLOT(slotMessage(const QCString&, const QByteArray& ) ) ); } void IrdaApplet::show() { QWidget::show ( ); startTimer ( 2000 ); } IrdaApplet::~IrdaApplet() { if ( m_sockfd >= 0 ) ::close ( m_sockfd ); } void IrdaApplet::popup ( QString message, QString icon ) { if ( !m_popup ) m_popup = new QPopupMenu ( this ); m_popup-> clear ( ); if ( icon. isEmpty ( )) m_popup-> insertItem ( message, 0 ); else m_popup-> insertItem ( QIconSet ( Resource::loadPixmap ( icon )), message, 0 ); QPoint p = mapToGlobal ( QPoint ( 0, 0 )); QSize s = m_popup-> sizeHint ( ); m_popup-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( ))); QTimer::singleShot ( 2000, this, SLOT( popupTimeout ( ))); } void IrdaApplet::popupTimeout ( ) { m_popup-> hide ( ); } bool IrdaApplet::checkIrdaStatus ( ) { struct ifreq ifr; strcpy ( ifr. ifr_name, "irda0" ); if ( ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 ) return false; return ( ifr. ifr_flags & IFF_UP ); } bool IrdaApplet::setIrdaStatus ( bool b ) { struct ifreq ifr; strcpy ( ifr. ifr_name, "irda0" ); if ( ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 ) return false; if ( b ) { ifr. ifr_flags |= IFF_UP; diff --git a/core/applets/logoutapplet/logout.cpp b/core/applets/logoutapplet/logout.cpp index 92222c9..0ac0067 100644 --- a/core/applets/logoutapplet/logout.cpp +++ b/core/applets/logoutapplet/logout.cpp @@ -1,102 +1,100 @@ #include <qpe/resource.h> #include <qpe/qcopenvelope_qws.h> #include <qapplication.h> -#include <qiconset.h> -#include <qpopupmenu.h> #include <qmessagebox.h> #include <unistd.h> #include "logout.h" LogoutApplet::LogoutApplet ( ) : QObject ( 0, "LogoutApplet" ) { } LogoutApplet::~LogoutApplet ( ) { } int LogoutApplet::position ( ) const { return 0; } QString LogoutApplet::name ( ) const { return tr( "Logout shortcut" ); } QString LogoutApplet::text ( ) const { return tr( "Logout" ); } QString LogoutApplet::tr( const char* s ) const { return qApp->translate( "LogoutApplet", s, 0 ); } QString LogoutApplet::tr( const char* s, const char* p ) const { return qApp->translate( "LogoutApplet", s, p ); } QIconSet LogoutApplet::icon ( ) const { QPixmap pix; QImage img = Resource::loadImage ( "logout" ); if ( !img. isNull ( )) pix. convertFromImage ( img. smoothScale ( 14, 14 )); return pix; } QPopupMenu *LogoutApplet::popup ( QWidget * ) const { return 0; } // This is a workaround for a Qt bug // clipboard applet has to stop its poll timer, or Qt/E // will hang on quit() right before it emits aboutToQuit() class HackApplication : public QApplication { public: HackApplication ( ) : QApplication ( dummy, 0 ) { } void emit_about_to_quit ( ) { emit aboutToQuit ( ); } int dummy; }; void LogoutApplet::activated ( ) { QMessageBox mb ( tr( "Logout" ), tr( "Do you really want to\nend this session ?" ), QMessageBox::NoIcon, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape, QMessageBox::NoButton ); mb. setButtonText ( QMessageBox::Yes, "Yes" ); mb. setButtonText ( QMessageBox::No, "No" ); mb. setIconPixmap ( icon ( ). pixmap ( )); if ( mb. exec ( ) == QMessageBox::Yes ) { { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); } qApp-> processEvents ( ); // ensure the message goes out. sleep ( 1 ); // You have 1 second to comply. ((HackApplication *) qApp )-> emit_about_to_quit ( ); qApp-> quit(); diff --git a/core/applets/multikeyapplet/multikey.cpp b/core/applets/multikeyapplet/multikey.cpp index b36ee12..b17498d 100644 --- a/core/applets/multikeyapplet/multikey.cpp +++ b/core/applets/multikeyapplet/multikey.cpp @@ -1,124 +1,118 @@ /********************************************************************** ** Copyright (C) 2004 Anton Kachalov mouse@altlinux.ru ** All rights reserved. ** ** 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. ** **********************************************************************/ #include "multikey.h" /* OPIE */ #include <opie2/otaskbarapplet.h> -#include <qpe/global.h> -#include <qpe/config.h> #include <qpe/qcopenvelope_qws.h> -#include <qpe/qpeapplication.h> /* QT */ -#include <qlabel.h> #include <qdir.h> -#include <qfileinfo.h> -#include <qcopchannel_qws.h> Multikey::Multikey(QWidget *parent) : QLabel(parent), popupMenu(this), current("EN") { QCopChannel* swChannel = new QCopChannel("MultiKey/Switcher", this); connect( swChannel, SIGNAL(received(const QCString &, const QByteArray &)), this, SLOT(message(const QCString &, const QByteArray &))); setFont( QFont( "Helvetica", 10, QFont::Normal ) ); QPEApplication::setStylusOperation(this, QPEApplication::RightOnHold); lang = 0; QCopEnvelope e("MultiKey/Keyboard", "getmultikey()"); setText("EN"); popupMenu.insertItem("EN", 0); show(); } void Multikey::mousePressEvent(QMouseEvent *ev) { if (!sw_maps.count()) return; if (ev->button() == RightButton) { QPoint p = mapToGlobal(QPoint(0, 0)); QSize s = popupMenu.sizeHint(); int opt = popupMenu.exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), p.y() - s.height()), 0); if (opt == -1) return; lang = opt; QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); e << sw_maps[lang]; setText(labels[lang]); } QWidget::mousePressEvent(ev); } void Multikey::mouseReleaseEvent(QMouseEvent *ev) { if (!sw_maps.count()) return; lang = lang < sw_maps.count()-1 ? lang+1 : 0; QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); //qDebug("Lang=%d, count=%d, lab=%s", lang, sw_maps.count(), labels[lang].ascii()); e << sw_maps[lang]; setText(labels[lang]); } void Multikey::message(const QCString &message, const QByteArray &data) { if ( message == "setsw(QString,QString)" ) { QDataStream stream(data, IO_ReadOnly); QString maps, current_map; stream >> maps >> current_map; QStringList sw = QStringList::split(QChar('|'), maps); sw.append(current_map); QDir map_dir(QPEApplication::qpeDir() + "/share/multikey/", "*.keymap"); lang = 0; labels.clear(); sw_maps.clear(); popupMenu.clear(); for (uint i = 0; i < sw.count(); ++i) { QString keymap_map; if (sw[i][0] != '/') { keymap_map = map_dir.absPath() + "/" + sw[i]; } else { if ((map_dir.exists(QFileInfo(sw[i]).fileName(), false) && i != sw.count()-1) || !QFile::exists(sw[i])) { continue; } keymap_map = sw[i]; } QFile map(keymap_map); if (map.open(IO_ReadOnly)) { QString line; map.readLine(line, 1024); while (!map.atEnd()) { if (line.find(QRegExp("^sw\\s*=\\s*")) != -1) { if (i != sw.count()-1) { if (keymap_map == current_map) { lang = i; } sw_maps.append(keymap_map); labels.append(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); diff --git a/core/launcher/applauncher.cpp b/core/launcher/applauncher.cpp index c3584ad..7d3c032 100644 --- a/core/launcher/applauncher.cpp +++ b/core/launcher/applauncher.cpp @@ -1,156 +1,152 @@ /********************************************************************** ** 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. ** **********************************************************************/ #ifndef QTOPIA_INTERNAL_PRELOADACCESS #define QTOPIA_INTERNAL_PRELOADACCESS #endif #ifndef QTOPIA_INTERNAL_FILEOPERATIONS #define QTOPIA_INTERNAL_FILEOPERATIONS #endif #ifndef QTOPIA_PROGRAM_MONITOR #define QTOPIA_PROGRAM_MONITOR #endif #include <opie2/oglobal.h> #ifndef Q_OS_WIN32 #include <sys/stat.h> #include <sys/wait.h> #include <sys/file.h> #include <unistd.h> #include <sys/time.h> #include <sys/resource.h> #include <errno.h> #else #include <process.h> #include <windows.h> #include <winbase.h> #endif #include <signal.h> #include <sys/types.h> #include <stdlib.h> #include <qtimer.h> #include <qwindowsystem_qws.h> #include <qmessagebox.h> -#include <qfile.h> #include <qfileinfo.h> #include <qtopia/qcopenvelope_qws.h> -#include <qtopia/applnk.h> #include <qtopia/qpeapplication.h> -#include <qtopia/config.h> -#include <qtopia/global.h> #include "applauncher.h" #include "documentlist.h" const int AppLauncher::RAISE_TIMEOUT_MS = 5000; //--------------------------------------------------------------------------- static AppLauncher* appLauncherPtr; const int appStopEventID = 1290; class AppStoppedEvent : public QCustomEvent { public: AppStoppedEvent(int pid, int status) : QCustomEvent( appStopEventID ), mPid(pid), mStatus(status) { } int pid() { return mPid; } int status() { return mStatus; } private: int mPid, mStatus; }; AppLauncher::AppLauncher(QObject *parent, const char *name) : QObject(parent, name), qlPid(0), qlReady(FALSE), appKillerBox(0) { connect(qwsServer, SIGNAL(newChannel(const QString&)), this, SLOT(newQcopChannel(const QString&))); connect(qwsServer, SIGNAL(removedChannel(const QString&)), this, SLOT(removedQcopChannel(const QString&))); QCopChannel* channel = new QCopChannel( "QPE/System", this ); connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(received(const QCString&, const QByteArray&)) ); channel = new QCopChannel( "QPE/Server", this ); connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(received(const QCString&, const QByteArray&)) ); #ifndef Q_OS_WIN32 signal(SIGCHLD, signalHandler); #else runningAppsProc.setAutoDelete( TRUE ); #endif QString tmp = qApp->argv()[0]; int pos = tmp.findRev('/'); if ( pos > -1 ) tmp = tmp.mid(++pos); runningApps[::getpid()] = tmp; appLauncherPtr = this; QTimer::singleShot( 1000, this, SLOT(createQuickLauncher()) ); } AppLauncher::~AppLauncher() { appLauncherPtr = 0; #ifndef Q_OS_WIN32 signal(SIGCHLD, SIG_DFL); #endif if ( qlPid ) { int status; ::kill( qlPid, SIGTERM ); waitpid( qlPid, &status, 0 ); } } /* We use the QCopChannel of the app as an indicator of when it has been launched so that we can disable the busy indicators */ void AppLauncher::newQcopChannel(const QString& channelName) { // qDebug("channel %s added", channelName.data() ); QString prefix("QPE/Application/"); if (channelName.startsWith(prefix)) { { QCopEnvelope e("QPE/System", "newChannel(QString)"); e << channelName; } QString appName = channelName.mid(prefix.length()); if ( appName != "quicklauncher" ) { emit connected( appName ); QCopEnvelope e("QPE/System", "notBusy(QString)"); e << appName; } } else if (channelName.startsWith("QPE/QuickLauncher-")) { qDebug("Registered %s", channelName.latin1()); int pid = channelName.mid(18).toInt(); if (pid == qlPid) qlReady = TRUE; } } void AppLauncher::removedQcopChannel(const QString& channelName) { if (channelName.startsWith("QPE/Application/")) { diff --git a/core/launcher/firstuse.cpp b/core/launcher/firstuse.cpp index e07920f..50ae6c2 100644 --- a/core/launcher/firstuse.cpp +++ b/core/launcher/firstuse.cpp @@ -1,157 +1,149 @@ /********************************************************************** ** 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. ** **********************************************************************/ // I need access to some things you don't normally get access to. #ifndef _MSC_VER //### revise to allow removal of translators under MSVC #define private public #define protected public #endif #include "firstuse.h" #include "inputmethods.h" #include "applauncher.h" #include "serverapp.h" //#include <qtopia/custom.h> #include "calibrate.h" #include "documentlist.h" #include <qtopia/resource.h> #include <qtopia/qcopenvelope_qws.h> -#include <qtopia/qpeapplication.h> #include <qtopia/config.h> -#include <qtopia/applnk.h> -#include <qtopia/mimetype.h> #include <qtopia/fontmanager.h> -#include <qapplication.h> #include <qfile.h> #include <qpainter.h> -#include <qcstring.h> #include <qsimplerichtext.h> -#include <qcolor.h> #include <qpushbutton.h> -#include <qhbox.h> #include <qlabel.h> #include <qtimer.h> #if defined( Q_WS_QWS ) #include <qwsdisplay_qws.h> #include <qgfx_qws.h> #endif -#include <qwindowsystem_qws.h> #include <stdlib.h> #include <sys/types.h> #if defined(Q_OS_LINUX) || defined(_OS_LINUX_) #include <unistd.h> #endif struct { bool enabled; const char *app; const char *start; const char *stop; const char *desc; } settingsTable [] = { { FALSE, "language", "raise()", "accept()", // No tr QT_TR_NOOP("Language") }, { FALSE, "doctab", "raise()", "accept()", // No tr QT_TR_NOOP("DocTab") }, #ifndef Q_OS_WIN32 { FALSE, "systemtime", "raise()", "accept()", // No tr QT_TR_NOOP("Time and Date") }, #endif { FALSE, "addressbook", "editPersonalAndClose()", "accept()", // No tr QT_TR_NOOP("Personal Information") }, { FALSE, 0, 0, 0, 0 } }; FirstUse::FirstUse(QWidget* parent, const char * name, WFlags wf) : QDialog( parent, name, TRUE, wf), transApp(0), transLib(0), needCalibrate(FALSE), currApp(-1), waitForExit(-1), waitingForLaunch(FALSE), needRestart(FALSE) { ServerApplication::allowRestart = FALSE; // we force our height beyound the maximum (which we set anyway) QRect desk = qApp->desktop()->geometry(); setGeometry( 0, 0, desk.width(), desk.height() ); connect(qwsServer, SIGNAL(newChannel(const QString&)), this, SLOT(newQcopChannel(const QString&))); // Create a DocumentList so appLauncher has appLnkSet to search docList = new DocumentList( 0, FALSE ); appLauncher = new AppLauncher( this ); connect( appLauncher, SIGNAL(terminated(int, const QString&)), this, SLOT(terminated(int, const QString&)) ); // more hackery // I will be run as either the main server or as part of the main server QWSServer::setScreenSaverIntervals(0); loadPixmaps(); //check if there is a language program #ifndef Q_OS_WIN32 QString exeSuffix; #else QString exeSuffix(".exe"); #endif for ( int i = 0; settingsTable[i].app; i++ ) { QString file = QPEApplication::qpeDir() + "bin/"; file += settingsTable[i].app; file += exeSuffix; if ( QFile::exists(file) ) settingsTable[i].enabled = TRUE; } setFocusPolicy(NoFocus); taskBar = new QWidget(0, 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop | WGroupLeader); inputMethods = new InputMethods(taskBar); connect(inputMethods, SIGNAL(inputToggled(bool)), this, SLOT(calcMaxWindowRect())); back = new QPushButton(tr("<< Back"), taskBar); back->setFocusPolicy(NoFocus); connect(back, SIGNAL(clicked()), this, SLOT(previousDialog()) ); next = new QPushButton(tr("Next >>"), taskBar); next->setFocusPolicy(NoFocus); connect(next, SIGNAL(clicked()), this, SLOT(nextDialog()) ); // need to set the geom to lower corner QSize sz = inputMethods->sizeHint(); int buttonWidth = (width() - sz.width()) / 2; int x = 0; controlHeight = back->sizeHint().height(); inputMethods->setGeometry(0,0, sz.width(), controlHeight ); x += sz.width(); diff --git a/core/launcher/inputmethods.cpp b/core/launcher/inputmethods.cpp index 5d8faf7..683f1e2 100644 --- a/core/launcher/inputmethods.cpp +++ b/core/launcher/inputmethods.cpp @@ -1,134 +1,128 @@ /********************************************************************** ** 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 "inputmethods.h" #include <qtopia/config.h> #include <qtopia/qpeapplication.h> -#include <qtopia/inputmethodinterface.h> -#include <qtopia/global.h> #include <qpopupmenu.h> -#include <qpushbutton.h> #include <qtoolbutton.h> #include <qwidgetstack.h> -#include <qwidget.h> #include <qlayout.h> -#include <qtimer.h> #include <qdir.h> #include <stdlib.h> -#include <qtranslator.h> #include <qtl.h> #ifdef Q_WS_QWS #include <qwindowsystem_qws.h> #include <qwsevent_qws.h> #include <qcopchannel_qws.h> #endif /* ### SingleFloppy if someone is interested? */ #if 0 #ifdef QT_NO_COMPONENT #include "../plugins/inputmethods/handwriting/handwritingimpl.h" #include "../plugins/inputmethods/keyboard/keyboardimpl.h" #include "../3rdparty/plugins/inputmethods/pickboard/pickboardimpl.h" #endif #endif /* XPM */ static const char * tri_xpm[]={ "9 9 2 1", "a c #000000", ". c None", ".........", ".........", ".........", "....a....", "...aaa...", "..aaaaa..", ".aaaaaaa.", ".........", "........."}; int InputMethod::operator <(const InputMethod& o) const { return name() < o.name(); } int InputMethod::operator >(const InputMethod& o) const { return name() > o.name(); } int InputMethod::operator <=(const InputMethod& o) const { return name() <= o.name(); } /* Slightly hacky: We use WStyle_Tool as a flag to say "this widget belongs to the IM system, so clicking it should not cause a reset". */ class IMToolButton : public QToolButton { public: IMToolButton::IMToolButton( QWidget *parent ) : QToolButton( parent ) { setWFlags( WStyle_Tool ); } }; InputMethods::InputMethods( QWidget *parent ) : QWidget( parent, "InputMethods", WStyle_Tool | WStyle_Customize ), mkeyboard(0), imethod(0) { Config cfg( "Launcher" ); cfg.setGroup( "InputMethods" ); inputWidgetStyle = QWidget::WStyle_Customize | QWidget::WStyle_StaysOnTop | QWidget::WGroupLeader | QWidget::WStyle_Tool; inputWidgetStyle |= cfg.readBoolEntry( "Float", false ) ? QWidget::WStyle_DialogBorder : 0; inputWidgetWidth = cfg.readNumEntry( "Width", 100 ); setBackgroundMode( PaletteBackground ); QHBoxLayout *hbox = new QHBoxLayout( this ); kbdButton = new IMToolButton( this); kbdButton->setFocusPolicy(NoFocus); kbdButton->setToggleButton( TRUE ); if (parent->sizeHint().height() > 0) kbdButton->setFixedHeight( parent->sizeHint().height() ); kbdButton->setFixedWidth( 32 ); kbdButton->setAutoRaise( TRUE ); kbdButton->setUsesBigPixmap( TRUE ); hbox->addWidget( kbdButton ); connect( kbdButton, SIGNAL(toggled(bool)), this, SLOT(showKbd(bool)) ); kbdChoice = new IMToolButton( this ); kbdChoice->setFocusPolicy(NoFocus); kbdChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); if (parent->sizeHint().height() > 0) kbdChoice->setFixedHeight( parent->sizeHint().height() ); kbdChoice->setFixedWidth( 13 ); kbdChoice->setAutoRaise( TRUE ); hbox->addWidget( kbdChoice ); connect( kbdChoice, SIGNAL(clicked()), this, SLOT(chooseKbd()) ); connect( (QPEApplication*)qApp, SIGNAL(clientMoused()), this, SLOT(resetStates()) ); diff --git a/core/launcher/irserver.cpp b/core/launcher/irserver.cpp index 63f8d05..a0e9c16 100644 --- a/core/launcher/irserver.cpp +++ b/core/launcher/irserver.cpp @@ -1,77 +1,76 @@ /********************************************************************** ** 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 "irserver.h" #include <qtopia/qlibrary.h> #include <qtopia/qpeapplication.h> -#include <qtranslator.h> #include "obexinterface.h" #include <qdir.h> IrServer::IrServer( QObject *parent, const char *name ) : QObject( parent, name ), obexIface(0) { lib = 0; obexIface = 0; QString path = QPEApplication::qpeDir() + "/plugins/obex/"; #ifdef Q_OS_MACX QDir dir( path, "lib*.dylib" ); #else QDir dir( path, "lib*.so" ); #endif /* Q_OS_MACX */ QStringList list = dir.entryList(); QStringList::Iterator it; for ( it = list.begin(); it != list.end(); ++it ) { QLibrary *trylib = new QLibrary( path + *it ); //qDebug("trying lib %s", (path + (*it)).latin1() ); if ( trylib->queryInterface( IID_ObexInterface, (QUnknownInterface**)&obexIface ) == QS_OK ) { lib = trylib; //qDebug("found obex lib" ); QString lang = getenv( "LANG" ); QTranslator * trans = new QTranslator(qApp); QString type = (*it).left( (*it).find(".") ); QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; //qDebug("tr fpr obex: %s", tfn.latin1() ); if ( trans->load( tfn )) qApp->installTranslator( trans ); else delete trans; break; } else { delete lib; } } if ( !lib ) qDebug("could not load IR plugin" ); } IrServer::~IrServer() { if ( obexIface ) obexIface->release(); delete lib; } diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index 984a57d..54efb0b 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp @@ -1,142 +1,140 @@ /********************************************************************** ** 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 <qtopia/global.h> #ifdef Q_WS_QWS #include <qtopia/qcopenvelope_qws.h> #endif #include <qtopia/resource.h> #include <qtopia/applnk.h> #include <qtopia/config.h> -#include <qtopia/global.h> #include <qtopia/qpeapplication.h> #include <qtopia/mimetype.h> #include <qtopia/private/categories.h> //#include <qtopia/custom.h> #include <qdir.h> #ifdef Q_WS_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> #include "startmenu.h" #include "taskbar.h" #include "serverinterface.h" #include "launcherview.h" #include "launcher.h" #include "server.h" #define QTOPIA_INTERNAL_FSLP #include <qtopia/lnkproperties.h> #include <stdlib.h> #include <assert.h> #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) #include <unistd.h> #include <stdio.h> #include <sys/vfs.h> #include <mntent.h> #endif #ifdef Q_WS_QWS #include <qkeyboard_qws.h> #include <qpe/lnkproperties.h> #endif static bool isVisibleWindow( int ); //=========================================================================== LauncherTabWidget::LauncherTabWidget( Launcher* parent ) : QVBox( parent ), docview( 0 ) { docLoadingWidgetEnabled = false; docLoadingWidget = 0; docLoadingWidgetProgress = 0; launcher = parent; categoryBar = new LauncherTabBar( this ); QPalette pal = categoryBar->palette(); pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); categoryBar->setPalette( pal ); stack = new QWidgetStack(this); connect( categoryBar, SIGNAL(selected(int)), this, SLOT(raiseTabWidget()) ); categoryBar->show(); stack->show(); #if defined(Q_WS_QWS) && !defined(QT_NO_COP) QCopChannel *channel = new QCopChannel( "QPE/Launcher", this ); connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(launcherMessage(const QCString&, const QByteArray&)) ); connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), this, SLOT(appMessage(const QCString&, const QByteArray&))); #endif createDocLoadingWidget(); } void LauncherTabWidget::createDocLoadingWidget() { // Construct the 'doc loading widget' shown when finding documents // ### LauncherView class needs changing to be more generic so // this widget can change its background similar to the iconviews // so the background for this matches docLoadingWidget = new LauncherView( stack ); docLoadingWidget->hideIcons(); QVBox *docLoadingVBox = new QVBox( docLoadingWidget ); docLoadingVBox->setSpacing( 20 ); docLoadingVBox->setMargin( 10 ); QWidget *space1 = new QWidget( docLoadingVBox ); docLoadingVBox->setStretchFactor( space1, 1 ); QLabel *waitPixmap = new QLabel( docLoadingVBox ); waitPixmap->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, waitPixmap->sizePolicy().hasHeightForWidth() ) ); waitPixmap->setPixmap( Resource::loadPixmap( "bigwait" ) ); waitPixmap->setAlignment( int( QLabel::AlignCenter ) ); Config cfg( "Launcher" ); cfg.setGroup( "DocTab" ); bool docTabEnabled = cfg.readBoolEntry( "Enable", true ); QLabel *textLabel = new QLabel( docLoadingVBox ); textLabel->setAlignment( int( QLabel::AlignCenter ) ); docLoadingWidgetProgress = new QProgressBar( docLoadingVBox ); docLoadingWidgetProgress->setProgress( 0 ); docLoadingWidgetProgress->setCenterIndicator( TRUE ); diff --git a/core/launcher/launcherglobal.cpp b/core/launcher/launcherglobal.cpp index 84caa93..9abcae9 100644 --- a/core/launcher/launcherglobal.cpp +++ b/core/launcher/launcherglobal.cpp @@ -1,83 +1,79 @@ /* * GPLv2 only * * TT 2002-2002,2003 */ -#include <qstring.h> -#include <qcstring.h> -#include <qwidget.h> -#include <qguardedptr.h> #include <qfile.h> #include <qtextstream.h> #include <qtopia/mimetype.h> #include "launcherglobal.h" bool Opie::Global::isAppLnkFileName( const QString& file ) { if ( file.right(1) == "/" ) return FALSE; return file.find(MimeType::appsFolderName()+"/")==0; } QString Opie::Global::tempDir() { return QString::fromLatin1("/tmp/"); } Global::Command* Opie::Global::builtinCommands() { return builtin; } QGuardedPtr<QWidget>* Opie::Global::builtinRunning() { return running; } QString Opie::Global::uuid() { QFile file( "/proc/sys/kernel/random/uuid" ); if (!file.open(IO_ReadOnly ) ) return QString::null; QTextStream stream(&file); return "{" + stream.read().stripWhiteSpace() + "}"; } QByteArray Opie::Global::encodeBase64(const QByteArray& origData ) { // follows simple algorithm from rsync code uchar *in = (uchar*)origData.data(); int inbytes = origData.size(); int outbytes = ((inbytes * 8) + 5) / 6; int padding = 4-outbytes%4; if ( padding == 4 ) padding = 0; QByteArray outbuf(outbytes+padding); uchar* out = (uchar*)outbuf.data(); const char *b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; for (int i = 0; i < outbytes; i++) { int byte = (i * 6) / 8; int bit = (i * 6) % 8; if (bit < 3) { if (byte < inbytes) *out = (b64[(in[byte] >> (2 - bit)) & 0x3F]); } else { if (byte + 1 == inbytes) { *out = (b64[(in[byte] << (bit - 2)) & 0x3F]); } else { *out = (b64[(in[byte] << (bit - 2) | in[byte + 1] >> (10 - bit)) & 0x3F]); } } ++out; } ASSERT(out == (uchar*)outbuf.data() + outbuf.size() - padding); while ( padding-- ) *out++='='; return outbuf; } diff --git a/core/launcher/launchertab.cpp b/core/launcher/launchertab.cpp index 10cfd5f..710f259 100644 --- a/core/launcher/launchertab.cpp +++ b/core/launcher/launchertab.cpp @@ -1,120 +1,117 @@ /********************************************************************** ** 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 "launchertab.h" #include <qapplication.h> -#include <qstyle.h> -#include <qpainter.h> -#include <qbitmap.h> LauncherTabBar::LauncherTabBar( QWidget *parent, const char *name ) : QTabBar( parent, name ) { setFocusPolicy( NoFocus ); connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) ); } LauncherTabBar::~LauncherTabBar() { } void LauncherTabBar::insertTab( LauncherTab *t, int index ) { if ( index < 0 ) items.append( t ); else items.insert( (uint)index, t ); tabs.insert( t->type, t ); QTabBar::insertTab( t, index ); } void LauncherTabBar::removeTab( QTab *tab ) { LauncherTab *t = (LauncherTab *)tab; tabs.remove( t->type ); items.remove( t ); QTabBar::removeTab( t ); } void LauncherTabBar::prevTab() { int n = count(); int tab = currentTab(); if ( tab >= 0 ) setCurrentTab( (tab - 1 + n)%n ); } void LauncherTabBar::nextTab() { int n = count(); int tab = currentTab(); setCurrentTab( (tab + 1)%n ); } void LauncherTabBar::showTab( const QString& id ) { setCurrentTab( tabs[id] ); } void LauncherTabBar::layoutTabs() { if ( !count() ) return; int available = width()-1; QFontMetrics fm = fontMetrics(); int hiddenTabWidth = -12; LauncherTab *current = currentLauncherTab(); int hframe, vframe, overlap; style().tabbarMetrics( this, hframe, vframe, overlap ); int x = 0; QRect r; LauncherTab *t; QListIterator< LauncherTab > it( items ); int required = 0; int eventabwidth = (width()-1)/count(); enum Mode { HideBackText, Pack, Even } mode=Even; for (it.toFirst(); it.current(); ++it ) { t = it.current(); if ( !t ) continue; int iw = fm.width( t->text() ) + hframe - overlap; if ( t != current ) { available -= hiddenTabWidth + hframe - overlap; if ( t->iconSet() != 0 ) available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); } if ( t->iconSet() != 0 ) iw += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); required += iw; // As space gets tight, packed looks better than even. "10" must be at least 0. if ( iw >= eventabwidth-10 ) mode = Pack; } if ( mode == Pack && required > width()-1 ) mode = HideBackText; for ( it.toFirst(); it.current(); ++it ) { t = it.current(); if ( !t ) continue; if ( mode != HideBackText ) { int w = fm.width( t->text() ); int ih = 0; diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp index 62c678d..513b1bd 100644 --- a/core/launcher/launcherview.cpp +++ b/core/launcher/launcherview.cpp @@ -1,142 +1,128 @@ /********************************************************************** ** 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 "launcherview.h" #include <qtopia/qpeapplication.h> -#include <qtopia/applnk.h> -#include <qtopia/qpedebug.h> #include <qtopia/private/categories.h> #include <qtopia/categoryselect.h> -#include <qtopia/menubutton.h> #include <qtopia/mimetype.h> #include <qtopia/resource.h> -#include <qtopia/qpetoolbar.h> //#include <qtopia/private/palmtoprecord.h> #include <qtimer.h> -#include <qtextstream.h> -#include <qdict.h> -#include <qfile.h> #include <qfileinfo.h> -#include <qhbox.h> #include <qiconview.h> -#include <qwidgetstack.h> -#include <qpainter.h> -#include <qregexp.h> -#include <qtoolbutton.h> -#include <qimage.h> -#include <qlabel.h> #include <qobjectlist.h> // These define how the busy icon is animated and highlighted #define BRIGHTEN_BUSY_ICON //#define ALPHA_FADE_BUSY_ICON //#define USE_ANIMATED_BUSY_ICON_OVERLAY #define BOUNCE_BUSY_ICON class BgPixmap { public: BgPixmap( const QPixmap &p ) : pm(p), ref(1) {} QPixmap pm; int ref; }; static QMap<QString,BgPixmap*> *bgCache = 0; static void cleanup_cache() { QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); while ( it != bgCache->end() ) { QMap<QString,BgPixmap*>::Iterator curr = it; ++it; delete (*curr); bgCache->remove( curr ); } delete bgCache; bgCache = 0; } class LauncherItem : public QIconViewItem { public: LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE ); ~LauncherItem(); AppLnk *appLnk() const { return app; } AppLnk *takeAppLnk() { AppLnk* r=app; app=0; return r; } void animateIcon(); void resetIcon(); virtual int compare ( QIconViewItem * i ) const; void paintItem( QPainter *p, const QColorGroup &cg ); void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } protected: bool isBigIcon; int iteration; AppLnk* app; private: void paintAnimatedIcon( QPainter *p ); BusyIndicatorType busyType; }; class LauncherIconView : public QIconView { public: LauncherIconView( QWidget* parent, const char* name=0 ) : QIconView(parent,name), tf(""), cf(0), bsy(0), busyTimer(0), bigIcns(TRUE), bgColor(white) { sortmeth = Name; hidden.setAutoDelete(TRUE); ike = FALSE; calculateGrid( Bottom ); } ~LauncherIconView() { #if 0 // debuggery QListIterator<AppLnk> it(hidden); AppLnk* l; while ((l=it.current())) { ++it; //qDebug("%p: hidden (should remove)",l); } #endif } QIconViewItem* busyItem() const { return bsy; } #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY QPixmap busyPixmap() const { return busyPix; } #endif void setBigIcons( bool bi ) { bigIcns = bi; diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp index 9e53bb0..c136bd9 100644 --- a/core/launcher/main.cpp +++ b/core/launcher/main.cpp @@ -1,135 +1,130 @@ /********************************************************************** ** 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. ** **********************************************************************/ #ifndef QTOPIA_INTERNAL_FILEOPERATIONS #define QTOPIA_INTERNAL_FILEOPERATIONS #endif #include "server.h" #include "serverapp.h" -#include "taskbar.h" #include "stabmon.h" -#include "launcher.h" #include "firstuse.h" #include <opie2/oglobal.h> -#include <qtopia/qpeapplication.h> #include <qtopia/network.h> -#include <qtopia/config.h> //#include <qtopia/custom.h> -#include <qfile.h> #include <qdir.h> #ifdef QWS #include <qwindowsystem_qws.h> #include <qtopia/qcopenvelope_qws.h> #endif #include <qtopia/alarmserver.h> #include <stdlib.h> #include <stdio.h> #include <signal.h> #ifndef Q_OS_WIN32 #include <unistd.h> #else #include <process.h> #endif #include "calibrate.h" #ifdef QT_QWS_LOGIN #include "../login/qdmdialogimpl.h" #endif #ifdef Q_WS_QWS #include <qkeyboard_qws.h> #endif #include <qmessagebox.h> #include <opie2/odevice.h> using namespace Opie; static void cleanup() { QDir dir( "/tmp", "qcop-msg-*" ); QStringList stale = dir.entryList(); QStringList::Iterator it; for ( it = stale.begin(); it != stale.end(); ++it ) { dir.remove( *it ); } } static void refreshTimeZoneConfig() { /* ### FIXME timezone handling */ #if 0 // We need to help WorldTime in setting up its configuration for // the current translation // BEGIN no tr const char *defaultTz[] = { "America/New_York", "America/Los_Angeles", "Europe/Oslo", "Asia/Tokyo", "Asia/Hong_Kong", "Australia/Brisbane", 0 }; // END no tr TimeZone curZone; QString zoneID; int zoneIndex; Config cfg = Config( "WorldTime" ); cfg.setGroup( "TimeZones" ); if (!cfg.hasKey( "Zone0" )){ // We have no existing timezones use the defaults which are untranslated strings QString currTz = TimeZone::current().id(); QStringList zoneDefaults; zoneDefaults.append( currTz ); for ( int i = 0; defaultTz[i] && zoneDefaults.count() < 6; i++ ) { if ( defaultTz[i] != currTz ) zoneDefaults.append( defaultTz[i] ); } zoneIndex = 0; for (QStringList::Iterator it = zoneDefaults.begin(); it != zoneDefaults.end() ; ++it){ cfg.writeEntry( "Zone" + QString::number( zoneIndex ) , *it); zoneIndex++; } } // We have an existing list of timezones refresh the // translations of TimeZone name zoneIndex = 0; while (cfg.hasKey( "Zone"+ QString::number( zoneIndex ))){ zoneID = cfg.readEntry( "Zone" + QString::number( zoneIndex )); curZone = TimeZone( zoneID ); if ( !curZone.isValid() ){ qDebug( "initEnvironment() Invalid TimeZone %s", zoneID.latin1() ); break; } cfg.writeEntry( "ZoneName" + QString::number( zoneIndex ), curZone.city() ); zoneIndex++; } #endif diff --git a/core/launcher/packageslave.cpp b/core/launcher/packageslave.cpp index bf34368..321b5dd 100644 --- a/core/launcher/packageslave.cpp +++ b/core/launcher/packageslave.cpp @@ -1,130 +1,128 @@ /********************************************************************** ** 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 "packageslave.h" #include <qtopia/qprocess.h> #ifdef Q_WS_QWS #include <qtopia/qcopenvelope_qws.h> #endif -#include <qdatastream.h> #ifdef Q_WS_QWS #include <qcopchannel_qws.h> #endif #include <qtextstream.h> -#include <qdir.h> #include <stdlib.h> #include <sys/stat.h> // mkdir() #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) #include <unistd.h> #include <sys/vfs.h> #include <mntent.h> #elif defined(Q_OS_WIN32) #include <windows.h> #include <winbase.h> #elif defined(Q_OS_MACX) #include <unistd.h> #endif PackageHandler::PackageHandler( QObject *parent, char* name ) : QObject( parent, name ), packageChannel( 0 ), currentProcess( 0 ), mNoSpaceLeft( FALSE ) { // setup qcop channel #ifndef QT_NO_COP packageChannel = new QCopChannel( "QPE/Package", this ); connect( packageChannel, SIGNAL( received(const QCString &, const QByteArray &) ), this, SLOT( qcopMessage( const QCString &, const QByteArray &) ) ); #endif } void PackageHandler::qcopMessage( const QCString &msg, const QByteArray &data ) { QDataStream stream( data, IO_ReadOnly ); if ( msg == "installPackage(QString)" ) { QString file; stream >> file; installPackage( file ); } else if ( msg == "removePackage(QString)" ) { QString file; stream >> file; removePackage( file ); } else if ( msg == "addPackageFiles(QString,QString)" ) { QString location, listfile; stream >> location >> listfile; addPackageFiles( location, listfile); } else if ( msg == "addPackages(QString)" ) { QString location; stream >> location; addPackages( location ); } else if ( msg == "cleanupPackageFiles(QString)" ) { QString listfile; stream >> listfile; cleanupPackageFiles( listfile ); } else if ( msg == "cleanupPackages(QString)" ) { QString location; stream >> location; cleanupPackages( location ); } else if ( msg == "prepareInstall(QString,QString)" ) { QString size, path; stream >> size; stream >> path; prepareInstall( size, path ); } } void PackageHandler::installPackage( const QString &package ) { if ( mNoSpaceLeft ) { mNoSpaceLeft = FALSE; // Don't emit that for now, I still couldn't test it (Wener) //sendReply( "installFailed(QString)", package ); //return; } currentProcess = new QProcess( QStringList() << "ipkg" << "install" << package ); // No tr connect( currentProcess, SIGNAL( processExited() ), SLOT( iProcessExited() ) ); connect( currentProcess, SIGNAL( readyReadStdout() ), SLOT( readyReadStdout() ) ); connect( currentProcess, SIGNAL( readyReadStderr() ), SLOT( readyReadStderr() ) ); currentPackage = package; currentProcessError=""; sendReply( "installStarted(QString)", package ); currentProcess->start(); } void PackageHandler::removePackage( const QString &package ) { currentProcess = new QProcess( QStringList() << "ipkg" << "remove" << package ); // No tr connect( currentProcess, SIGNAL( processExited() ), SLOT( rmProcessExited() ) ); connect( currentProcess, SIGNAL( readyReadStdout() ), SLOT( readyReadStdout() ) ); connect( currentProcess, SIGNAL( readyReadStderr() ), SLOT( readyReadStderr() ) ); currentPackage = package; currentProcessError=""; sendReply( "removeStarted(QString)", package ); currentProcess->start(); } diff --git a/core/launcher/qcopbridge.cpp b/core/launcher/qcopbridge.cpp index 9bca360..24f471d 100644 --- a/core/launcher/qcopbridge.cpp +++ b/core/launcher/qcopbridge.cpp @@ -1,137 +1,129 @@ /********************************************************************** ** 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" #include <opie2/oglobal.h> #ifdef Q_WS_QWS #include <qtopia/qcopenvelope_qws.h> #endif #include <qtopia/qpeapplication.h> #include <qtopia/version.h> -#include <qtopia/config.h> -#include <qdir.h> -#include <qfile.h> #include <qtextstream.h> -#include <qdatastream.h> -#include <qcstring.h> -#include <qstringlist.h> -#include <qfileinfo.h> -#include <qregexp.h> #include <qtimer.h> #ifdef Q_WS_QWS #include <qcopchannel_qws.h> #endif #ifndef _XOPEN_SOURCE #define _XOPEN_SOURCE #endif #ifndef Q_OS_WIN32 #include <pwd.h> #include <unistd.h> #include <sys/types.h> #endif #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 ) { if ( !ok() ) qWarning( "Failed to bind to port %d", port ); else { #ifndef QT_NO_COP desktopChannel = new QCopChannel( "QPE/Desktop", this ); connect( desktopChannel, SIGNAL(received(const QCString &, const QByteArray &)), this, SLOT(desktopMessage( const QCString &, const QByteArray &)) ); cardChannel = new QCopChannel( "QPE/Card", this ); connect( cardChannel, SIGNAL(received(const QCString &, const QByteArray &)), this, SLOT(desktopMessage( const QCString &, const QByteArray &)) ); #endif } sendSync = FALSE; openConnections.setAutoDelete( TRUE ); authorizeConnections(); } QCopBridge::~QCopBridge() { #ifndef QT_NO_COP delete desktopChannel; #endif } void QCopBridge::authorizeConnections() { Config cfg("Security"); cfg.setGroup("SyncMode"); m_mode = Mode(cfg.readNumEntry("Mode", Sharp )); QListIterator<QCopBridgePI> it(openConnections); while ( it.current() ) { if ( !it.current()->verifyAuthorised() ) { disconnect ( it.current(), SIGNAL( connectionClosed( QCopBridgePI *) ), this, SLOT( closed( QCopBridgePI *) ) ); openConnections.removeRef( it.current() ); } else ++it; } } void QCopBridge::newConnection( int socket ) { QCopBridgePI *pi = new QCopBridgePI( socket, this ); openConnections.append( pi ); connect ( pi, SIGNAL( connectionClosed( QCopBridgePI *) ), this, SLOT( closed( QCopBridgePI *) ) ); /* ### libqtopia merge FIXME */ #if 0 QPEApplication::setTempScreenSaverMode( QPEApplication::DisableSuspend ); #endif #ifndef QT_NO_COP QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; #endif if ( sendSync ) { pi ->startSync(); sendSync = FALSE; } } void QCopBridge::closed( QCopBridgePI *pi ) { emit connectionClosed( pi->peerAddress() ); openConnections.removeRef( pi ); if ( openConnections.count() == 0 ) { /* ### FIXME libqtopia merge */ #if 0 QPEApplication::setTempScreenSaverMode( QPEApplication::Enable ); diff --git a/core/launcher/runningappbar.cpp b/core/launcher/runningappbar.cpp index 1fda5a4..11d10dc 100644 --- a/core/launcher/runningappbar.cpp +++ b/core/launcher/runningappbar.cpp @@ -1,131 +1,124 @@ /********************************************************************** ** 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_PRELOADACCESS -#include <qtopia/global.h> #include <stdlib.h> -#include <qtimer.h> -#include <qpopupmenu.h> #include <qpainter.h> -#include <qmessagebox.h> -#include <qtopia/qpeapplication.h> -#include <qtopia/applnk.h> #include <qtopia/qcopenvelope_qws.h> -#include <qtopia/mimetype.h> #include "runningappbar.h" #include "serverinterface.h" RunningAppBar::RunningAppBar(QWidget* parent) : QFrame(parent), selectedAppIndex(-1) { 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::received(const QCString& msg, const QByteArray& data) { // Since fast apps appear and disappear without disconnecting from their // channel we need to watch for the showing/hiding events and update according. QDataStream stream( data, IO_ReadOnly ); if ( msg == "fastAppShowing(QString)") { QString appName; stream >> appName; // qDebug("fastAppShowing %s", appName.data() ); const AppLnk* f = ServerInterface::appLnks().findExec(appName); if ( f ) addTask(*f); } else if ( msg == "fastAppHiding(QString)") { QString appName; stream >> appName; const AppLnk* f = ServerInterface::appLnks().findExec(appName); if ( f ) removeTask(*f); } } void RunningAppBar::addTask(const AppLnk& appLnk) { qDebug("Added %s to app list.", appLnk.name().latin1()); AppLnk* newApp = new AppLnk(appLnk); newApp->setExec(appLnk.exec()); appList.prepend(newApp); update(); } void RunningAppBar::removeTask(const AppLnk& appLnk) { unsigned int i = 0; for (; i < appList.count() ; i++) { AppLnk* target = appList.at(i); if (target->exec() == appLnk.exec()) { qDebug("Removing %s from app list.", appLnk.name().latin1()); appList.remove(); delete target; } } update(); } void RunningAppBar::mousePressEvent(QMouseEvent *e) { // Find out if the user is clicking on an app icon... // If so, snag the index so when we repaint we show it // as highlighed. selectedAppIndex = 0; int x=0; QListIterator<AppLnk> it( appList ); for ( ; it.current(); ++it,++selectedAppIndex,x+=spacing ) { if ( x + spacing <= width() ) { if ( e->x() >= x && e->x() < x+spacing ) { if ( selectedAppIndex < (int)appList.count() ) { repaint(FALSE); return; } } } else { break; } } selectedAppIndex = -1; repaint( FALSE ); } void RunningAppBar::mouseReleaseEvent(QMouseEvent *e) { if (e->button() == QMouseEvent::RightButton) return; if ( selectedAppIndex >= 0 ) { QString app = appList.at(selectedAppIndex)->exec(); QCopEnvelope e("QPE/System", "raise(QString)"); e << app; selectedAppIndex = -1; update(); } } void RunningAppBar::paintEvent( QPaintEvent * ) { diff --git a/core/launcher/screensaver.cpp b/core/launcher/screensaver.cpp index 1146dcd..e544c61 100644 --- a/core/launcher/screensaver.cpp +++ b/core/launcher/screensaver.cpp @@ -1,101 +1,100 @@ #include "screensaver.h" #include <qpe/config.h> -#include <qpe/power.h> #include <qpe/network.h> #include <opie2/odevice.h> using namespace Opie; OpieScreenSaver::OpieScreenSaver ( ) : QObject ( 0, "screensaver" ), QWSScreenSaver ( ) { m_disable_suspend = 100; m_enable_dim = false; m_enable_lightoff = false; m_enable_suspend = false; m_onlylcdoff = false; m_enable_dim_ac = false; m_enable_lightoff_ac = false; m_enable_suspend_ac = false; m_onlylcdoff_ac = false; m_use_light_sensor = false; m_backlight_sensor = -1; ::memset ( m_sensordata, 0xff, LS_Count * sizeof( m_sensordata [0] )); m_lcd_status = true; m_backlight_normal = -1; m_backlight_current = -1; m_backlight_forcedoff = false; m_on_ac = false; m_level = -1; // 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 ); setBacklight ( -1 ); } /** * Stops the screen saver */ void OpieScreenSaver::restore() { m_level = -1; if ( !m_lcd_status ) { // We must have turned it off ODevice::inst ( ) -> setDisplayStatus ( true ); m_lcd_status = true; } setBacklightInternal ( -1 ); } /** * Starts the screen saver * * @param level what level of screen saving should happen (0=lowest non-off, 1=off, * 2=suspend whole machine) * @returns true on success */ bool OpieScreenSaver::save( int level ) { m_level = level; switch ( level ) { case 0: if (( m_on_ac && m_enable_dim_ac ) || ( !m_on_ac && m_enable_dim )) { if (( m_disable_suspend > 0 ) && ( m_backlight_current > 1 ) && !m_use_light_sensor ) setBacklightInternal ( 1 ); // lowest non-off } return true; break; case 1: if (( m_on_ac && m_enable_lightoff_ac ) || ( !m_on_ac && m_enable_lightoff )) { if ( m_disable_suspend > 1 ) setBacklightInternal ( 0 ); // off } return true; break; case 2: if (( m_on_ac && !m_enable_suspend_ac ) || ( !m_on_ac && !m_enable_suspend )) { return true; } if (( m_on_ac && m_onlylcdoff_ac ) || diff --git a/core/launcher/server.cpp b/core/launcher/server.cpp index 32fcdd0..068d716 100644 --- a/core/launcher/server.cpp +++ b/core/launcher/server.cpp @@ -1,128 +1,127 @@ /********************************************************************** ** 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 "server.h" #include "serverapp.h" -#include "launcher.h" #include "startmenu.h" +#include "launcher.h" #include "transferserver.h" #include "qcopbridge.h" #include "irserver.h" #include "packageslave.h" #include "calibrate.h" #include "qrsync.h" #include "syncdialog.h" -#include "launcher.h" #include "shutdownimpl.h" #include "applauncher.h" #if 0 #include "suspendmonitor.h" #endif #include "documentlist.h" #include <qtopia/applnk.h> #include <qtopia/private/categories.h> #include <qtopia/mimetype.h> #include <qtopia/config.h> #include <qtopia/resource.h> #include <qtopia/version.h> #include <qtopia/storage.h> #include <qtopia/qcopenvelope_qws.h> #include <qwindowsystem_qws.h> #include <qgfx_qws.h> #include <qtopia/global.h> //#include <qtopia/custom.h> #include <opie2/odevicebutton.h> #include <opie2/odevice.h> #include <unistd.h> #include <qmainwindow.h> #include <qmessagebox.h> #include <qtimer.h> #include <qtextstream.h> #include <stdlib.h> extern QRect qt_maxWindowRect; using namespace Opie; static QWidget *calibrate(bool) { #ifdef Q_WS_QWS Calibrate *c = new Calibrate; c->show(); return c; #else return 0; #endif } #define FACTORY(T) \ static QWidget *new##T( bool maximized ) { \ QWidget *w = new T( 0, 0, QWidget::WDestructiveClose | QWidget::WGroupLeader ); \ if ( maximized ) { \ if ( qApp->desktop()->width() <= 350 ) { \ w->showMaximized(); \ } else { \ w->resize( QSize( 300, 300 ) ); \ } \ } \ w->show(); \ return w; \ } #ifdef SINGLE_APP #define APP(a,b,c,d) FACTORY(b) #include "apps.h" #undef APP #endif // SINGLE_APP static Global::Command builtins[] = { #ifdef SINGLE_APP #define APP(a,b,c,d) { a, new##b, c, d }, #include "apps.h" #undef APP #endif /* FIXME defines need to be defined*/ #if !defined(OPIE_NO_BUILTIN_CALIBRATE) { "calibrate", calibrate, 1, 0 }, // No tr #endif #if !defined(OPIE_NO_BUILTIN_SHUTDOWN) { "shutdown", Global::shutdown, 1, 0 }, // No tr // { "run", run, 1, 0 }, // No tr #endif { 0, calibrate, 0, 0 }, }; //--------------------------------------------------------------------------- //=========================================================================== Server::Server() : QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), diff --git a/core/launcher/shutdownimpl.cpp b/core/launcher/shutdownimpl.cpp index 899d9ac..f43a2a3 100644 --- a/core/launcher/shutdownimpl.cpp +++ b/core/launcher/shutdownimpl.cpp @@ -1,128 +1,127 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** 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 "shutdownimpl.h" #include <qpe/global.h> #include <qpe/qcopenvelope_qws.h> #include <qtimer.h> #include <qprogressbar.h> #include <qpushbutton.h> #include <qbuttongroup.h> #include <qlabel.h> #include <qlayout.h> -#include <qpalette.h> static void changeButtonColor ( QPushButton *btn, const QColor &col ) { QPalette pal = btn-> palette ( ); pal. setColor ( QPalette::Active, QColorGroup::Button, col ); pal. setColor ( QPalette::Disabled, QColorGroup::Button, col ); pal. setColor ( QPalette::Inactive, QColorGroup::Button, col ); btn-> setPalette ( pal ); } ShutdownImpl::ShutdownImpl( QWidget* parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl ) { setCaption ( tr( "Shutdown..." ) ); QVBoxLayout *vbox = new QVBoxLayout ( this ); vbox-> setSpacing ( 3 ); vbox-> setMargin ( 6 ); QButtonGroup *btngrp = new QButtonGroup ( this ); btngrp-> setTitle ( tr( "Terminate" ) ); btngrp-> setColumnLayout ( 0, Qt::Vertical ); btngrp-> layout ( ) -> setSpacing ( 0 ); btngrp-> layout ( ) -> setMargin ( 0 ); QGridLayout *grid = new QGridLayout ( btngrp-> layout ( ) ); grid-> setAlignment ( Qt::AlignTop ); grid-> setSpacing ( 3 ); grid-> setMargin ( 7 ); QPushButton *quit = new QPushButton ( tr( "Terminate Opie" ), btngrp, "quit" ); changeButtonColor ( quit, QColor ( 236, 236, 179 ) ); btngrp-> insert ( quit, 4 ); grid-> addWidget ( quit, 1, 1 ); QPushButton *reboot = new QPushButton ( tr( "Reboot" ), btngrp, "reboot" ); changeButtonColor ( reboot, QColor( 236, 183, 181 ) ); btngrp-> insert ( reboot, 2 ); grid-> addWidget( reboot, 1, 0 ); QPushButton *restart = new QPushButton ( tr( "Restart Opie" ), btngrp, "restart" ); changeButtonColor ( restart, QColor( 236, 236, 179 ) ); btngrp-> insert ( restart, 3 ); grid-> addWidget ( restart, 0, 1 ); QPushButton *shutdown = new QPushButton( tr( "Shutdown" ), btngrp, "shutdown" ); changeButtonColor ( shutdown, QColor( 236, 183, 181 ) ); btngrp-> insert ( shutdown, 1 ); grid-> addWidget ( shutdown, 0, 0 ); vbox-> addWidget ( btngrp ); m_info = new QLabel ( this, "info" ); m_info-> setText( tr( "<p>\n" "These termination options are provided primarily for use while developing and testing the Opie system. In a normal environment, these concepts are unnecessary." ) ); vbox-> addWidget ( m_info ); m_progress = new QProgressBar ( this, "progressBar" ); m_progress-> setFrameShape ( QProgressBar::Panel ); m_progress-> setFrameShadow ( QProgressBar::Sunken ); m_progress-> setTotalSteps ( 20 ); m_progress-> setIndicatorFollowsStyle ( false ); vbox-> addWidget ( m_progress ); vbox-> addItem ( new QSpacerItem ( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); QPushButton *cancel = new QPushButton ( tr( "Cancel" ), this, "cancel" ); changeButtonColor ( cancel, QColor( 181, 222, 178 ) ); cancel-> setDefault ( true ); cancel-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding, cancel-> sizePolicy ( ). hasHeightForWidth ( ) ) ); vbox-> addWidget ( cancel ); m_timer = new QTimer ( this ); connect ( m_timer, SIGNAL( timeout ( ) ), this, SLOT( timeout ( ) ) ); connect ( btngrp, SIGNAL( clicked ( int ) ), this, SLOT( buttonClicked ( int ) ) ); connect ( cancel, SIGNAL( clicked ( ) ), this, SLOT( cancelClicked ( ) ) ); m_progress-> hide ( ); Global::hideInputMethod ( ); } void ShutdownImpl::buttonClicked ( int b ) { m_counter = 0; switch ( b ) { case 1: m_operation = ShutdownSystem; break; case 2: m_operation = RebootSystem; diff --git a/core/launcher/stabmon.cpp b/core/launcher/stabmon.cpp index 4e5f290..f2d694b 100644 --- a/core/launcher/stabmon.cpp +++ b/core/launcher/stabmon.cpp @@ -1,102 +1,101 @@ /********************************************************************** ** 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 "stabmon.h" #ifdef QWS #include <qtopia/qcopenvelope_qws.h> #endif #include <qfile.h> -#include <qcstring.h> #include <sys/stat.h> #if defined(Q_OS_LINUX) || defined(_OS_LINUX_) #include <unistd.h> #endif #include <stdlib.h> SysFileMonitor::SysFileMonitor(QObject* parent) : QObject(parent) { startTimer(2000); } const char * stab0 = "/var/run/stab"; const char * stab1 = "/var/state/pcmcia/stab"; const char * stab2 = "/var/lib/pcmcia/stab"; void SysFileMonitor::timerEvent(QTimerEvent*) { struct stat s; static const char * tab [] = { stab0, stab1, stab2 }; static const int nstab = sizeof(tab)/sizeof(const char *); static int last[nstab]; bool ch = FALSE; for ( int i=0; i<nstab; i++ ) { if ( ::stat(tab[i], &s)==0 && (long)s.st_mtime != last[i] ) { last[i] = (long)s.st_mtime; ch=TRUE; } if ( ch ) { #ifndef QT_NO_COP QCopEnvelope("QPE/Card", "stabChanged()" ); #endif break; } } // st_size is no use, it's 0 for /proc/mounts too. Read it all. static int mtabSize = 0; QFile f( "/proc/mounts" ); if ( f.open(IO_ReadOnly) ) { #if 0 // readAll does not work correctly on sequential devices (as eg. /proc files) QByteArray ba = f.readAll(); if ( (int)ba.size() != mtabSize ) { mtabSize = (int)ba.size(); #ifndef QT_NO_COP QCopEnvelope("QPE/Card", "mtabChanged()" ); #endif } #else QString s; while( !f.atEnd() ) { QString tmp; f.readLine( tmp, 1024 ); s += tmp; } if ( (int)s.length() != mtabSize ) { mtabSize = (int)s.length(); #ifndef QT_NO_COP QCopEnvelope("QPE/Card", "mtabChanged()" ); #endif } #endif } } diff --git a/core/launcher/startmenu.cpp b/core/launcher/startmenu.cpp index c199063..f3a7651 100644 --- a/core/launcher/startmenu.cpp +++ b/core/launcher/startmenu.cpp @@ -1,135 +1,131 @@ /**********************************************************************
** 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.
**
**********************************************************************/
// TODO. During startup
// Launcher::typeAdded
// is called for each new tab and calls then each time the refresh of startmenu
// suboptimal
#define INCLUDE_MENUITEM_DEF
#include "startmenu.h"
#include <qtopia/qpeapplication.h>
#include <qtopia/config.h>
-#include <qtopia/applnk.h>
-#include <qtopia/global.h>
#include <qtopia/resource.h>
#include <qtopia/mimetype.h>
#include <qtopia/qlibrary.h>
-#include <qdict.h>
-#include <qdir.h>
//#include <qpainter.h>
//#include <stdlib.h>
#define APPLNK_ID_OFFSET 250
#define NO_ID -1
void StartPopupMenu::keyPressEvent( QKeyEvent *e )
{
if ( e->key() == Key_F33 || e->key() == Key_Space ) {
// "OK" button, little hacky
QKeyEvent ke(QEvent::KeyPress, Key_Enter, 13, 0);
QPopupMenu::keyPressEvent( &ke );
} else {
QPopupMenu::keyPressEvent( e );
}
}
//---------------------------------------------------------------------------
StartMenu::StartMenu(QWidget *parent) : QLabel( parent )
{
startButtonPixmap = "go"; // No tr
int sz = AppLnk::smallIconSize()+3;
QPixmap pm;
pm.convertFromImage(Resource::loadImage( startButtonPixmap).smoothScale( sz,sz) );
setPixmap(pm);
setFocusPolicy( NoFocus );
useWidePopupMenu = true;
launchMenu = 0;
refreshMenu();
}
void StartMenu::mousePressEvent( QMouseEvent * )
{
launch();
}
StartMenu::~StartMenu()
{
clearApplets();
}
void StartMenu::createMenu()
{
clearApplets();
delete launchMenu;
launchMenu = new StartPopupMenu( this );
loadMenu( launchMenu );
loadApplets();
bool result = currentItem || menuApplets.count();
if ( result )
connect( launchMenu, SIGNAL(activated(int)), SLOT(itemSelected(int)) );
}
void StartMenu::refreshMenu()
{
Config cfg( "StartMenu" );
cfg.setGroup( "Menu" );
bool ltabs = cfg.readBoolEntry( "LauncherTabs", TRUE );
bool lot = cfg.readBoolEntry( "LauncherOther", TRUE );
useWidePopupMenu = cfg.readBoolEntry( "LauncherSubPopup", TRUE );
if ( launchMenu && !(ltabs || lot) ) return; // nothing to do
createMenu();
}
void StartMenu::itemSelected( int id )
{
if ( id == NO_ID ) return;
if ( id < 0 ) {
MenuApplet *applet = menuApplets.find( id );
if ( applet ) {
applet->iface->activated();
}
} else if ( id >= APPLNK_ID_OFFSET ) {
AppLnk * appLnk = appLnks.find( id );
if ( appLnk ) {
appLnk->execute();
}
} else {
QString *tabName = tabNames.find( id );
if ( tabName ) {
emit tabSelected( *tabName );
}
}
diff --git a/core/launcher/syncdialog.cpp b/core/launcher/syncdialog.cpp index 6f6c781..4a2b8ff 100644 --- a/core/launcher/syncdialog.cpp +++ b/core/launcher/syncdialog.cpp @@ -1,121 +1,120 @@ /********************************************************************** ** 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 "syncdialog.h" #include <qtopia/resource.h> -#include <qimage.h> #include <qpainter.h> #include <qapplication.h> #include <qpushbutton.h> #include <qfile.h> SyncDialog::SyncDialog( QWidget *parent, const QString &w ) : QDialog( parent, "SyncDialog", FALSE, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop ), what(w), nextPt(0), rev(FALSE), hideDot(TRUE) { QFont f( font() ); f.setPointSize( 16 ); setFont(f); loadPath(); QSize ds = qApp->desktop()->size(); setGeometry( 0, 0, ds.width(), ds.height() ); img = Resource::loadImage( "SyncScreen" ); if ( img.width() > ds.width() || img.height() > ds.height() ) { path = scalePath( path, ds.width(), img.width(), ds.height(), img.height() ); img = img.smoothScale( ds.width(), ds.height() ); } dot = Resource::loadImage( "syncdot" ); setBackgroundColor( white ); QPushButton *pb = new QPushButton( tr("Abort"), this, "CancelSync" ); QSize bs = pb->sizeHint(); bs.rwidth() += 10; bs.rheight() += 5; pb->setGeometry( (ds.width()-bs.width())/2, 4*ds.height()/5, bs.width(), bs.height() ); connect( pb, SIGNAL(clicked()), this, SIGNAL(cancel()) ); if ( path.count() >= 2 ) { path = generatePath( path, 8 ); startTimer( 200 ); } } void SyncDialog::paintEvent( QPaintEvent *pe ) { QPainter p(this ); p.setClipRect( pe->rect() ); int ox = (width() - img.width())/2; int oy = (height() - img.height())/2; QRect ir = QRect(ox, oy, img.width(), img.height()) & pe->rect(); if ( ir.isValid() ) p.drawImage( ir.x(), ir.y(), img, ir.x()-ox, ir.y()-oy, ir.width(), ir.height() ); QString syncMsg = tr("Syncing:"); p.setPen( black ); QRect r( 0, 0, width()/2-5, QMAX(oy,80) ); p.drawText( r, AlignRight | AlignVCenter, syncMsg ); r.moveBy( width()/2, 0 ); QFont f( font() ); f.setWeight( QFont::Bold ); p.setFont( f ); p.drawText( r, AlignLeft | AlignVCenter, what ); if ( !hideDot ) p.drawImage( ox+path[nextPt].x()-dot.width()/2, oy+path[nextPt].y()-dot.height()/2, dot ); } void SyncDialog::timerEvent( QTimerEvent * ) { int ox = (width() - img.width())/2; int oy = (height() - img.height())/2; int oldPt = nextPt; if ( !rev ) { nextPt++; if ( nextPt == (int)path.count() ) { nextPt -= 2; rev = TRUE; } } else { nextPt--; if ( nextPt < 0 ) { nextPt = 1; rev = FALSE; } } hideDot = FALSE; repaint( ox+path[nextPt].x()-dot.width()/2, oy+path[nextPt].y()-dot.height()/2, dot.width(), dot.height() ); hideDot = TRUE; repaint( ox+path[oldPt].x()-dot.width()/2, oy+path[oldPt].y()-dot.height()/2, dot.width(), dot.height() ); } void SyncDialog::loadPath() { diff --git a/core/launcher/systray.cpp b/core/launcher/systray.cpp index 691f6b8..6cc1446 100644 --- a/core/launcher/systray.cpp +++ b/core/launcher/systray.cpp @@ -1,124 +1,122 @@ /********************************************************************** ** 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 <qtopia/qpeapplication.h> #include <qtopia/qlibrary.h> #include <qtopia/config.h> #include <qlayout.h> #include <qdir.h> -#include <qmessagebox.h> -#include <qtranslator.h> #include "systray.h" #include <stdlib.h> /* ### Single build floppies ### */ #if 0 #ifdef QT_NO_COMPONENTS #include "../plugins/applets/clockapplet/clockappletimpl.h" #endif #endif SysTray::SysTray( QWidget *parent ) : QFrame( parent ), layout(0) { //setFrameStyle( QFrame::Panel | QFrame::Sunken ); loadApplets(); } SysTray::~SysTray() { clearApplets(); } static int compareAppletPositions(const void *a, const void *b) { const TaskbarApplet* aa = *(const TaskbarApplet**)a; const TaskbarApplet* ab = *(const TaskbarApplet**)b; int d = ab->iface->position() - aa->iface->position(); if ( d ) return d; return QString::compare(ab->name,aa->name); } void SysTray::loadApplets() { hide(); clearApplets(); addApplets(); } void SysTray::clearApplets() { #ifndef QT_NO_COMPONENTS /* * Note on clearing. SOme applets delete their * applets themselves some don't do it * and on restart this can crash. If we delete it * here we might end up in a double deletion. We could * use QGuardedPtr but that would be one QOBject * for every applet more but only useful for restart */ QValueList<TaskbarApplet>::Iterator mit; for ( mit = appletList.begin(); mit != appletList.end(); ++mit ) { (*mit).iface->release(); (*mit).library->unload(); delete (*mit).library; } #endif appletList.clear(); if ( layout ) delete layout; layout = new QHBoxLayout( this, 0, 1 ); layout->setAutoAdd(TRUE); } void SysTray::addApplets() { hide(); #ifndef QT_NO_COMPONENTS Config cfg( "Taskbar" ); cfg.setGroup( "Applets" ); QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); QString lang = getenv( "LANG" ); QString path = QPEApplication::qpeDir() + "/plugins/applets"; #ifdef Q_OS_MACX QDir dir( path, "lib*.dylib" ); #else QDir dir( path, "lib*.so" ); #endif /* Q_OS_MACX */ QStringList list = dir.entryList(); QStringList::Iterator it; int napplets=0; TaskbarApplet* *applets = new TaskbarApplet*[list.count()]; for ( it = list.begin(); it != list.end(); ++it ) { if ( exclude.find( *it ) != exclude.end() ) continue; qWarning( "Found Applet: %s", (*it).latin1() ); TaskbarAppletInterface *iface = 0; QLibrary *lib = new QLibrary( path + "/" + *it ); if (( lib->queryInterface( IID_TaskbarApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) { TaskbarApplet *applet = new TaskbarApplet; applets[napplets++] = applet; applet->library = lib; applet->iface = iface; diff --git a/core/launcher/transferserver.cpp b/core/launcher/transferserver.cpp index 8367a62..b998e95 100644 --- a/core/launcher/transferserver.cpp +++ b/core/launcher/transferserver.cpp @@ -1,156 +1,146 @@ /********************************************************************** ** 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 _XOPEN_SOURCE #include <opie2/oglobal.h> -#include <qtopia/qpeapplication.h> #ifndef Q_OS_WIN32 #include <pwd.h> #include <sys/types.h> #include <unistd.h> #include <stdlib.h> #include <time.h> #ifndef Q_OS_MACX #include <shadow.h> #include <crypt.h> #endif /* Q_OS_MACX */ #else #include <stdlib.h> #include <time.h> #endif #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 <qtopia/qcopchannel_qws.h> #include <qtopia/process.h> -#include <qtopia/global.h> -#include <qtopia/config.h> #include <qtopia/private/contact.h> -#include <qtopia/quuid.h> #include <qtopia/version.h> #ifdef Q_WS_QWS #include <qtopia/qcopenvelope_qws.h> #endif #include "transferserver.h" #include <qtopia/qprocess.h> const int block_size = 51200; TransferServer::TransferServer( Q_UINT16 port, QObject *parent, const char* name) : QServerSocket( port, 1, parent, name ) { connections.setAutoDelete( TRUE ); if ( !ok() ) qWarning( "Failed to bind to port %d", port ); } void TransferServer::authorizeConnections() { QListIterator<ServerPI> it(connections); while ( it.current() ) { if ( !it.current()->verifyAuthorised() ) { disconnect( it.current(), SIGNAL(connectionClosed(ServerPI *)), this, SLOT( closed(ServerPI *)) ); connections.removeRef( it.current() ); } else ++it; } } void TransferServer::closed(ServerPI *item) { connections.removeRef(item); } TransferServer::~TransferServer() { } void TransferServer::newConnection( int socket ) { ServerPI *ptr = new ServerPI( socket, this ); connect( ptr, SIGNAL(connectionClosed(ServerPI *)), this, SLOT( closed(ServerPI *)) ); connections.append( ptr ); } QString SyncAuthentication::serverId() { Config cfg("Security"); cfg.setGroup("Sync"); QString r = cfg.readEntry("serverid"); if ( r.isEmpty() ) { r = OGlobal::generateUuid(); cfg.writeEntry("serverid", r ); } return r; } QString SyncAuthentication::ownerName() { QString vfilename = Global::applicationFileName("addressbook", "businesscard.vcf"); if (QFile::exists(vfilename)) { Contact c; c = Contact::readVCard( vfilename )[0]; return c.fullName(); } return QString::null; } QString SyncAuthentication::loginName() { struct passwd *pw = 0L; #ifndef Q_OS_WIN32 pw = getpwuid( geteuid() ); return QString::fromLocal8Bit( pw->pw_name ); #else //### revise return QString(); #endif } int SyncAuthentication::isAuthorized(QHostAddress peeraddress) { Config cfg("Security"); cfg.setGroup("Sync"); // QString allowedstr = cfg.readEntry("auth_peer","192.168.1.0"); uint auth_peer = cfg.readNumEntry("auth_peer", 0xc0a80100); // QHostAddress allowed; // allowed.setAddress(allowedstr); // uint auth_peer = allowed.ip4Addr(); diff --git a/core/launcher/wait.cpp b/core/launcher/wait.cpp index 34ffd1a..4148e57 100644 --- a/core/launcher/wait.cpp +++ b/core/launcher/wait.cpp @@ -1,78 +1,74 @@ /********************************************************************** ** 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 "wait.h" -#include <qtopia/resource.h> #include <qtopia/config.h> #include <opie2/owait.h> -#include <qwidget.h> -#include <qpixmap.h> -#include <qpainter.h> Wait *lastWaitObject = NULL; Wait::Wait( QWidget *parent ) : QWidget( parent ), pm( Resource::loadPixmap( "wait" ) ), waiting( FALSE ) { setFixedSize( pm.size() ); lastWaitObject = this; m_centralWait = new OWait( 0l ); m_centralWait->hide(); hide(); } Wait *Wait::getWaitObject() { return lastWaitObject; } void Wait::setWaiting( bool w ) { Config cfg ( "Launcher" ); cfg.setGroup("GUI"); waiting = w; if ( w ) { if ( cfg. readBoolEntry( "BigBusy" ) ) m_centralWait->show(); else show(); }else{ m_centralWait->hide(); hide(); } } void Wait::paintEvent( QPaintEvent * ) { QPainter p( this ); p.drawPixmap( 0, 0, pm ); } |