-rw-r--r-- | core/launcher/desktop.cpp | 41 | ||||
-rw-r--r-- | core/launcher/desktop.h | 2 | ||||
-rw-r--r-- | core/launcher/launcher.cpp | 82 | ||||
-rw-r--r-- | core/pim/today/today.cpp | 27 | ||||
-rw-r--r-- | core/pim/today/todayconfig.cpp | 57 | ||||
-rw-r--r-- | core/pim/today/todayconfig.h | 39 |
6 files changed, 150 insertions, 98 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index cf33011..43006f1 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp @@ -30,16 +30,17 @@ #include "irserver.h" #include "packageslave.h" #include <qpe/applnk.h> #include <qpe/mimetype.h> #include <qpe/password.h> #include <qpe/config.h> #include <qpe/power.h> +#include <qpe/timeconversion.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/global.h> #ifdef QT_QWS_CUSTOM #include "qpe/custom.h" #endif #include <qgfx_qws.h> #include <qmainwindow.h> @@ -51,17 +52,17 @@ #include <stdlib.h> #include <unistd.h> class QCopKeyRegister { public: QCopKeyRegister() : keyCode(0) { } - QCopKeyRegister(int k, const QString &c, const QString &m) + QCopKeyRegister(int k, const QString &c, const QString &m) : keyCode(k), channel(c), message(m) { } int getKeyCode() const { return keyCode; } QString getChannel() const { return channel; } QString getMessage() const { return message; } private: int keyCode; @@ -163,24 +164,24 @@ void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) if (msg == "keyRegister(int key, QString channel, QString message)") { int k; QString c, m; stream >> k; stream >> c; stream >> m; - + qWarning("KeyRegisterRecieved: %i, %s, %s", k, (const char*)c, (const char *)m); keyRegisterList.append(QCopKeyRegister(k,c,m)); - } + } else if (msg == "suspend()"){ emit power(); } - + } enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; #ifdef Q_WS_QWS bool DesktopApplication::qwsEventFilter( QWSEvent *e ) { qpedesktop->checkMemory(); @@ -272,17 +273,17 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e ) up = FALSE; qpedesktop->screenClick(); } } else { up = TRUE; } } } - + return QPEApplication::qwsEventFilter( e ); } #endif void DesktopApplication::psTimeout() { qpedesktop->checkMemory(); // in case no events are being generated @@ -542,24 +543,31 @@ void Desktop::raiseEmail() if(tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty()) executeOrModify("Applications/qtmail.desktop"); else { QCopEnvelope e("QPE/System","execute(QString)"); e << tempItem; } } // autoStarts apps on resume and start -void Desktop::execAutoStart() -{ - QString appName; - Config cfg( "autostart" ); - cfg.setGroup( "AutoStart" ); - appName = cfg.readEntry("Apps", ""); - QCopEnvelope e("QPE/System", "execute(QString)"); - e << QString(appName); +void Desktop::execAutoStart() { + QString appName; + int delay; + QDateTime now = QDateTime::currentDateTime(); + Config cfg( "autostart" ); + cfg.setGroup( "AutoStart" ); + appName = cfg.readEntry("Apps", ""); + delay = (cfg.readEntry("Delay", "0" )).toInt(); + // If the time between suspend and resume was longer then the + // value saved as delay, start the app + if ( suspendTime.secsTo(now) >= (delay*60) ) { + QCopEnvelope e("QPE/System", "execute(QString)"); + e << QString(appName); + } else { + } } #if defined(QPE_HAVE_TOGGLELIGHT) #include <qpe/config.h> #include <sys/ioctl.h> #include <sys/types.h> #include <fcntl.h> @@ -588,23 +596,24 @@ static void darkScreen() qpe_setBacklight(0); // force off } void Desktop::togglePower() { bool wasloggedin = loggedin; loggedin=0; + suspendTime = QDateTime::currentDateTime(); darkScreen(); if ( wasloggedin ) blankScreen(); - + system("apm --suspend"); - - + + QWSServer::screenSaverActivate( FALSE ); { QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep QCopEnvelope e("QPE/System", "setBacklight(int)"); e << -3; // Force on } if ( wasloggedin ) { diff --git a/core/launcher/desktop.h b/core/launcher/desktop.h index de0dbf0..e094dc0 100644 --- a/core/launcher/desktop.h +++ b/core/launcher/desktop.h @@ -22,16 +22,17 @@ #define __DESKTOP_H__ #include "shutdownimpl.h" #include <qpe/qpeapplication.h> #include <qwidget.h> +#include <qdatetime.h> class Background; class Launcher; class TaskBar; class PowerStatus; class QCopBridge; class TransferServer; class DesktopPowerAlerter; @@ -121,14 +122,15 @@ protected: private: void startTransferServer(); bool recoverMemory(); QCopBridge *qcopBridge; TransferServer *transferServer; PackageSlave *packageSlave; + QDateTime suspendTime; bool keyclick,touchclick; }; #endif // __DESKTOP_H__ diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index 1449269..979eee6 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp @@ -92,17 +92,17 @@ namespace { tmpMime = cfg->readBoolEntry("image", true ); if(tmpMime ) mimes.append("image//*" ); tmpMime = cfg->readBoolEntry("text", true ); if(tmpMime ) mimes.append("text//*"); - + tmpMime = cfg->readBoolEntry("video", true ); if(tmpMime ) mimes.append("video//*" ); } return mimes; } } @@ -544,20 +544,20 @@ void Launcher::loadDocs() // ok here comes a hack belonging to Global:: qWarning("new DocLnkSet" ); DocLnkSet *tmp = 0; QString home = QString(getenv("HOME")) + "/Documents"; tmp = new DocLnkSet( home , QString::null); docsFolder->appendFrom( *tmp ); delete tmp; // find out wich filesystems are new in this round // We will do this by having a timestamp inside each mountpoint - // if the current timestamp doesn't match this is a new file system and + // if the current timestamp doesn't match this is a new file system and // come up with our MediumMountGui :) let the hacking begin int stamp = uidgen.generate(); - + QString newStamp = QString::number( stamp ); // generates newtime Stamp StorageInfo storage; const QList<FileSystem> &fileSystems = storage.fileSystems(); QListIterator<FileSystem> it ( fileSystems ); for ( ; it.current(); ++it ) { if ( (*it)->isRemovable() ) { // let's find out if we should search on it qWarning("%s is removeable", (*it)->path().latin1() ); OConfig cfg( (*it)->path() + "/.opiestorage.cf"); @@ -586,17 +586,17 @@ void Launcher::loadDocs() // ok here comes a hack belonging to Global:: cfg.setGroup("main" ); bool check = cfg.readBoolEntry("autocheck", true ); if( check ){ // find the documents tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") ); docsFolder->appendFrom( *tmp ); delete tmp; } } - } + } } } m_timeStamp = newStamp; } void Launcher::updateTabs() { MimeType::updateApplications(); // ### reads all applnks twice @@ -682,17 +682,17 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data) QDataStream stream( data, IO_ReadOnly ); if ( msg == "closing(QString)" ){ QString app; stream >> app; qWarning("app closed %s", app.latin1() ); MRUList::removeTask( app ); }else if ( msg == "linkChanged(QString)" ) { QString link; - stream >> link; + stream >> link; if ( in_lnk_props ) { got_lnk_change = TRUE; lnk_change = link; } else { updateLink(link); } } else if ( msg == "busy()" ) { emit busy(); @@ -736,44 +736,58 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data) QString home = getenv( "HOME" ); QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); e << home; int locked = (int) Desktop::screenLocked(); e << locked; // register an app for autostart // if clear is send the list is cleared. } else if ( msg == "autoStart(QString)" ) { - QString appName; - stream >> appName; - Config cfg( "autostart" ); - cfg.setGroup( "AutoStart" ); - if ( appName.compare("clear") == 0){ - cfg.writeEntry("Apps", ""); - } + QString appName; + stream >> appName; + Config cfg( "autostart" ); + cfg.setGroup( "AutoStart" ); + if ( appName.compare("clear") == 0){ + cfg.writeEntry("Apps", ""); + } } else if ( msg == "autoStart(QString,QString)" ) { - QString modifier, appName; - stream >> modifier >> appName; - Config cfg( "autostart" ); - cfg.setGroup( "AutoStart" ); - if ( modifier.compare("add") == 0 ){ - // only add it appname is entered - if (!appName.isEmpty()) { - cfg.writeEntry("Apps", appName); - } - } else if (modifier.compare("remove") == 0 ) { - // need to change for multiple entries - // actually remove is right now simular to clear, but in future there - // should be multiple apps in autostart possible. - QString checkName; - checkName = cfg.readEntry("Apps", ""); - if (checkName == appName) { - cfg.writeEntry("Apps", ""); - } - } - } else if ( msg == "sendCardInfo()" ) { + QString modifier, appName; + stream >> modifier >> appName; + Config cfg( "autostart" ); + cfg.setGroup( "AutoStart" ); + if ( modifier.compare("add") == 0 ){ + // only add if appname is entered + if (!appName.isEmpty()) { + cfg.writeEntry("Apps", appName); + } + } else if (modifier.compare("remove") == 0 ) { + // need to change for multiple entries + // actually remove is right now simular to clear, but in future there + // should be multiple apps in autostart possible. + QString checkName; + checkName = cfg.readEntry("Apps", ""); + if (checkName == appName) { + cfg.writeEntry("Apps", ""); + } + } + // case the autostart feature should be delayed + } else if ( msg == "autoStart(QString, QString, QString)") { + QString modifier, appName, delay; + stream >> modifier >> appName >> delay; + Config cfg( "autostart" ); + cfg.setGroup( "AutoStart" ); + if ( modifier.compare("add") == 0 ){ + // only add it appname is entered + if (!appName.isEmpty()) { + cfg.writeEntry("Apps", appName); + cfg.writeEntry("Delay", delay); + } + } else { + } + } else if ( msg == "sendCardInfo()" ) { QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); const QList<FileSystem> &fs = storage->fileSystems(); QListIterator<FileSystem> it ( fs ); QString s; QString homeDir = getenv("HOME"); QString hardDiskHome; for ( ; it.current(); ++it ) { if ( (*it)->isRemovable() ) @@ -818,17 +832,17 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data) stream >> what; delete syncDialog; syncDialog = 0; syncDialog = new SyncDialog( this, "syncProgress", FALSE, WStyle_Tool | WStyle_Customize | Qt::WStyle_StaysOnTop ); syncDialog->showMaximized(); syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); connect( syncDialog->buttonCancel, SIGNAL( clicked() ), - SLOT( cancelSync() ) ); + SLOT( cancelSync() ) ); } else if ( msg == "stopSync()") { delete syncDialog; syncDialog = 0; } else if ( msg == "getAllDocLinks()" ) { loadDocs(); QString contents; @@ -857,17 +871,17 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data) contents += "Type = "+doc->type()+"\n"; } contents += QString("Size = %1\n").arg( fi.size() ); } //qDebug( "sending length %d", contents.length() ); QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); e << contents; - + qDebug( "================ \n\n%s\n\n===============", contents.latin1() ); delete docsFolder; docsFolder = 0; } } diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index 61bd0c4..f5ed8d2 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp @@ -17,49 +17,50 @@ * * ***************************************************************************/ #include "today.h" #include <qpe/timestring.h> #include <qpe/config.h> #include <qpe/qcopenvelope_qws.h> -#include <qpe/qprocess.h> +//#include <qpe/qprocess.h> #include <qpe/resource.h> #include <qpe/contact.h> #include <qpe/global.h> #include <qpe/qpeapplication.h> #include <qdir.h> #include <qfile.h> #include <qdatetime.h> #include <qtextstream.h> #include <qcheckbox.h> #include <qspinbox.h> #include <qpushbutton.h> #include <qlabel.h> #include <qtimer.h> #include <qpixmap.h> -#include <qfileinfo.h> +//#include <qfileinfo.h> #include <qlayout.h> #include <qtl.h> //#include <iostream.h> #include <unistd.h> #include <stdlib.h> int MAX_LINES_TASK; int MAX_CHAR_CLIP; int MAX_LINES_MEET; int SHOW_LOCATION; int SHOW_NOTES; // show only later dates int ONLY_LATER; int AUTOSTART; int NEW_START=1; +QString AUTOSTART_TIMER; /* * Constructs a Example which is a child of 'parent', with the * name 'name' and widget flags set to 'f' */ Today::Today( QWidget* parent, const char* name, WFlags fl ) : TodayBase( parent, name, fl ), AllDateBookEvents(NULL) { QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) ); @@ -121,25 +122,27 @@ void Today::setOwnerField(QString &message) { } } /* * Autostart, uses the new (opie only) autostart method in the launcher code. * If registered against that today ist started on each resume. */ void Today::autoStart() { - Config cfg("today"); - cfg.setGroup("Autostart"); - AUTOSTART = cfg.readNumEntry("autostart",1); + // Config cfg("today"); + //cfg.setGroup("Autostart"); + //AUTOSTART = cfg.readNumEntry("autostart",1); + if (AUTOSTART) { - QCopEnvelope e("QPE/System", "autoStart(QString,QString)"); + QCopEnvelope e("QPE/System", "autoStart(QString, QString, QString)"); e << QString("add"); e << QString("today"); + e << AUTOSTART_TIMER; } else { - QCopEnvelope e("QPE/System", "autoStart(QString,QString)"); + QCopEnvelope e("QPE/System", "autoStart(QString, QString)"); e << QString("remove"); e << QString("today"); } } /* * Repaint method. Reread all fields. */ @@ -207,16 +210,20 @@ void Today::init() { MAX_LINES_MEET = cfg.readNumEntry("maxlinesmeet",5); // If location is to be showed too, 1 to activate it. SHOW_LOCATION = cfg.readNumEntry("showlocation",1); // if notes should be shown SHOW_NOTES = cfg.readNumEntry("shownotes",0); // should only later appointments be shown or all for the current day. ONLY_LATER = cfg.readNumEntry("onlylater",1); + cfg.setGroup("Autostart"); + AUTOSTART = cfg.readNumEntry("autostart",1); + AUTOSTART_TIMER = cfg.readEntry("autostartdelay", "0"); + //db = new DateBookDB; } /* * The method for the configuration dialog. */ void Today::startConfig() { @@ -235,35 +242,39 @@ void Today::startConfig() { // task lines conf->SpinBox2->setValue(MAX_LINES_TASK); // clip when? conf->SpinBox7->setValue(MAX_CHAR_CLIP); // only later conf->CheckBox3->setChecked(ONLY_LATER); // if today should be autostarted conf->CheckBoxAuto->setChecked(AUTOSTART); + // autostart only if device has been suspended for X minutes + conf->SpinBoxTime->setValue( AUTOSTART_TIMER.toInt() ); conf->exec(); int maxlinestask = conf->SpinBox2->value(); int maxmeet = conf->SpinBox1->value(); int location = conf->CheckBox1->isChecked(); int notes = conf->CheckBox2->isChecked(); int maxcharclip = conf->SpinBox7->value(); int onlylater = conf->CheckBox3->isChecked(); - int autostart =conf->CheckBoxAuto->isChecked(); + int autostart = conf->CheckBoxAuto->isChecked(); + int autostartdelay = conf->SpinBoxTime->value(); cfg.writeEntry("maxlinestask",maxlinestask); cfg.writeEntry("maxcharclip", maxcharclip); cfg.writeEntry("maxlinesmeet",maxmeet); cfg.writeEntry("showlocation",location); cfg.writeEntry("shownotes", notes); cfg.writeEntry("onlylater", onlylater); cfg.setGroup("Autostart"); cfg.writeEntry("autostart", autostart); + cfg.writeEntry("autostartdelay", autostartdelay); // sync it to "disk" cfg.write(); NEW_START=1; draw(); autoStart(); } diff --git a/core/pim/today/todayconfig.cpp b/core/pim/today/todayconfig.cpp index 500e8fb..905ec4b 100644 --- a/core/pim/today/todayconfig.cpp +++ b/core/pim/today/todayconfig.cpp @@ -1,40 +1,43 @@ -/**************************************************************************** -** Form implementation generated from reading ui file 'todayconfig.ui' -** -** Created: Thu Feb 14 15:04:33 2002 -** by: The User Interface Compiler (uic) -** -** WARNING! All changes made in this file will be lost! -****************************************************************************/ +/* + * todayconfig.cpp + * + * --------------------- + * + * begin : Sun 10 17:20:00 CEST 2002 + * copyright : (c) 2002 by Maximilian Reiß + * email : max.reiss@gmx.de + * + */ +/*************************************************************************** + * * + * 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 "todayconfig.h" #include <qcheckbox.h> #include <qframe.h> #include <qlabel.h> #include <qspinbox.h> #include <qtabwidget.h> #include <qwidget.h> #include <qlayout.h> #include <qvariant.h> -#include <qwhatsthis.h> +//#include <qwhatsthis.h> -/* - * Constructs a todayconfig which is a child of 'parent', with the - * name 'name' and widget flags set to 'f' - * - * The dialog will by default be modeless, unless you set 'modal' to - * TRUE to construct a modal dialog. - */ todayconfig::todayconfig( QWidget* parent, const char* name, bool modal, WFlags fl ) - : QDialog( parent, name, modal, fl ) -{ + : QDialog( parent, name, modal, fl ) { if ( !name ) - setName( "todayconfig" ); + setName( "todayconfig" ); resize( 175, 232 ); setCaption( tr( "Today config" ) ); TabWidget3 = new QTabWidget( this, "TabWidget3" ); TabWidget3->setGeometry( QRect( 0, 0, 220, 320 ) ); TabWidget3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, TabWidget3->sizePolicy().hasHeightForWidth() ) ); TabWidget3->setAutoMask( FALSE ); TabWidget3->setTabShape( QTabWidget::Rounded ); @@ -115,32 +118,34 @@ todayconfig::todayconfig( QWidget* parent, const char* name, bool modal, WFlags TextLabel1 = new QLabel( Frame14, "TextLabel1" ); TextLabel1->setGeometry( QRect( 20, 20, 100, 30 ) ); TextLabel1->setText( tr( "Clip after how\n" "many letters" ) ); SpinBox7 = new QSpinBox( Frame14, "SpinBox7" ); SpinBox7->setGeometry( QRect( 115, 20, 58, 25 ) ); SpinBox7->setMaxValue( 80 ); - SpinBox7->setValue( 30 ); TextLabel2 = new QLabel( Frame14, "AutoStart" ); TextLabel2->setGeometry( QRect( 20, 60, 100, 45 ) ); TextLabel2->setText( tr( "Should today be\n" "autostarted on\n" "resume?" " (Opie only)" ) ); CheckBoxAuto = new QCheckBox (Frame14, "CheckBoxAuto" ); CheckBoxAuto->setGeometry( QRect( 158, 60, 27, 21 ) ); + TimeLabel = new QLabel( Frame14, "TimeLabel" ); + TimeLabel->setGeometry( QRect ( 20, 120, 120, 45 ) ); + TimeLabel->setText( tr( "Activate the \n" + "autostart after how\n" + "many minutes?" ) ); + SpinBoxTime = new QSpinBox( Frame14, "TimeSpinner"); + SpinBoxTime->setGeometry( QRect( 115, 120, 58, 25 ) ); + TabWidget3->insertTab( tab_3, tr( "Misc" ) ); } -/* - * Destroys the object and frees any allocated resources - */ -todayconfig::~todayconfig() -{ - // no need to delete child widgets, Qt does it all for us +todayconfig::~todayconfig() { } diff --git a/core/pim/today/todayconfig.h b/core/pim/today/todayconfig.h index 4739b5a..2986c4c 100644 --- a/core/pim/today/todayconfig.h +++ b/core/pim/today/todayconfig.h @@ -1,33 +1,42 @@ -/**************************************************************************** -** Form interface generated from reading ui file 'todayconfig.ui' -** -** Created: Thu Feb 14 15:04:33 2002 -** by: The User Interface Compiler (uic) -** -** WARNING! All changes made in this file will be lost! -****************************************************************************/ +/* + * todayconfig.h + * + * --------------------- + * + * begin : Sun 10 17:20:00 CEST 2002 + * copyright : (c) 2002 by Maximilian Reiß + * email : max.reiss@gmx.de + * + */ +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ #ifndef TODAYCONFIG_H #define TODAYCONFIG_H #include <qvariant.h> #include <qdialog.h> -//class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; +//class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; class QCheckBox; class QFrame; class QLabel; class QSpinBox; class QTabWidget; class QWidget; -class todayconfig : public QDialog -{ +class todayconfig : public QDialog { Q_OBJECT public: todayconfig( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); ~todayconfig(); QTabWidget* TabWidget3; QWidget* tab; @@ -44,12 +53,14 @@ public: QWidget* tab_2; QFrame* Frame9; QLabel* TextLabel6; QSpinBox* SpinBox2; QWidget* tab_3; QFrame* Frame14; QLabel* TextLabel1; QSpinBox* SpinBox7; + QLabel* TimeLabel; + QSpinBox* SpinBoxTime; }; -#endif // TODAYCONFIG_H +#endif |