author | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
commit | b9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (side-by-side diff) | |
tree | 2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /kalarmd | |
download | kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2 |
Initial revision
-rw-r--r-- | kalarmd/alarmdialog.cpp | 259 | ||||
-rw-r--r-- | kalarmd/alarmdialog.h | 80 | ||||
-rw-r--r-- | kalarmd/alarmdialog.moc | 0 | ||||
-rw-r--r-- | kalarmd/kalarmdE.pro | 20 | ||||
-rw-r--r-- | kalarmd/sharp_char.h | 258 | ||||
-rw-r--r-- | kalarmd/simplealarmdaemon.desktop | 6 | ||||
-rw-r--r-- | kalarmd/simplealarmdaemonapplet.cpp | 58 | ||||
-rw-r--r-- | kalarmd/simplealarmdaemonapplet.h | 26 | ||||
-rw-r--r-- | kalarmd/simplealarmdaemonimpl.cpp | 552 | ||||
-rw-r--r-- | kalarmd/simplealarmdaemonimpl.h | 85 |
10 files changed, 1344 insertions, 0 deletions
diff --git a/kalarmd/alarmdialog.cpp b/kalarmd/alarmdialog.cpp new file mode 100644 index 0000000..b82724f --- a/dev/null +++ b/kalarmd/alarmdialog.cpp @@ -0,0 +1,259 @@ +/* + This file is part of the KDE alarm daemon. + Copyright (c) 2000 Cornelius Schumacher <schumacher@kde.org> + + 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. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + As a special exception, permission is given to link this program + with any edition of Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ + +// $Id$ + +#include <qhbox.h> +#include <qvbox.h> +#include <qapp.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qfile.h> +#include <qtimer.h> +#include <qsound.h> +#include <qpushbutton.h> +#include <qspinbox.h> +#include <stdlib.h> +#ifndef _WIN32_ +#include <unistd.h> +#include <sys/ioctl.h> +#endif +#include <stdio.h> +#include <fcntl.h> + +#ifndef DESKTOP_VERSION +#include <qtopia/alarmserver.h> +#include <qpe/resource.h> +#include <qtopia/sound.h> +#endif + +#include "alarmdialog.h" +#include "alarmdialog.moc" + + +AlarmDialog::AlarmDialog(QWidget *parent,const char *name) + : QDialog (parent, name, true, Qt::WStyle_StaysOnTop ) +{ + setCaption( "KO/Pi Alarm!" ); + QVBoxLayout* layout = new QVBoxLayout( this); + QLabel* l = new QLabel("The following event triggered alarm:",this); + layout->addWidget ( l ); + l->setAlignment( AlignCenter); + mMessage = new QLabel ( " ", this ); + int fs = 18; + int fs2 = 12; + if ( QApplication::desktop()->width() < 480 ) { + setMaximumSize(220, 260); + fs2 = 10; + } + else { + setMaximumSize(440, 440); + } + layout->setSpacing( 3 ); + layout->setMargin( 3 ); + + l->setFont( QFont("helvetica",fs2, QFont::Bold) ); + mMessage->setFont( QFont("helvetica",fs, QFont::Bold) ); + mMessage->setAlignment( AlignCenter); + l = new QLabel("Missed Alarms:",this); + l->setAlignment( AlignCenter); + layout->addWidget ( mMessage ); + layout->addWidget ( l ); + mMissedAlarms= new QLabel ( "", this ); + mMissedAlarms->setAlignment( AlignCenter); + + playSoundTimer = new QTimer( this ); + connect ( playSoundTimer, SIGNAL( timeout() ), this, SLOT (playSound() ) ); + + playSoundTimer->stop(); + + layout->addWidget ( mMissedAlarms ); + QHBox *suspendBox = new QHBox( this ); + suspendBox->setSpacing(3); + layout->addWidget ( suspendBox ); + (void)new QLabel("Suspend duration (minutes):",suspendBox); + mSuspendSpin = new QSpinBox(1,1440,1,suspendBox); + mSuspendSpin->setValue(7); // default suspend duration + QHBox * bbox = new QHBox ( this ); + layout->addWidget ( bbox ); + bbox->layout()->setSpacing( 5 ); + QPushButton* suspend = new QPushButton( "Suspend", bbox); + QPushButton* silen = new QPushButton( " Stop sound ", bbox); + QPushButton* okbut = new QPushButton( "Ok", bbox); + connect (silen , SIGNAL( clicked() ), this, SLOT (silent() ) ); + connect (suspend , SIGNAL( clicked() ), this, SLOT (slotSuspend() ) ); + connect (okbut , SIGNAL( clicked() ), this, SLOT (slotOk() ) ); +#ifndef _WIN32_ + if ( QFile::exists ( "/dev/sharp_led" ) ) + fd_led = open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); + else +#endif + fd_led = 0; + statusLED.which = SHARP_LED_SALARM; + mSilent = false; + mSuspendCounter = 0; + setServerNotification( true ); +} +void AlarmDialog::reject () +{ + QTimer::singleShot ( 3000, this, SLOT (suspend()) ); + slotSuspend(); +} +AlarmDialog::~AlarmDialog() +{ +} +void AlarmDialog::silent () +{ + mSilent = true; +} +void AlarmDialog::accept() +{ + slotOk(); +} + +void AlarmDialog::suspend() +{ +#ifdef DESKTOP_VERSION + +#else + Sound::soundAlarm (); +#endif +} +void AlarmDialog::slotOk() +{ + mStopAlarm = true; + mMissedAlarms->setText(""); + mMessage->setText(""); +#ifndef _WIN32_ + if ( fd_led > 0 ) { + statusLED.status = LED_SALARM_OFF ; + ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED); + } +#endif + QDialog::accept(); +} + +void AlarmDialog::slotSuspend() +{ + //qDebug("AlarmDialog::suspend() "); // emit suspendSignal(mSuspendSpin->value()); + mStopAlarm = true; + QDateTime nextA = QDateTime::currentDateTime().addSecs( mSuspendSpin->value() * 60 ); + QString mess = "suspend_alarm" +mFileName+"+++" ; + if ( mMessage->text().left( 10 ) !="Suspended:" ) + mess += "Suspended:\n"; + mess +=mMessage->text(); +#ifndef DESKTOP_VERSION + if ( mServerNotification ) + AlarmServer::addAlarm ( nextA,"koalarm",mess.latin1()); +#endif + emit addAlarm( nextA , mess ); + slotOk(); +} + +void AlarmDialog::setServerNotification( bool b ) +{ + mServerNotification = b; +} +int AlarmDialog::getSuspendTime( ) +{ + return mSuspendSpin->value(); + +} +void AlarmDialog::setSuspendTime( int val ) +{ + mSuspendSpin->setValue( val ); +} +bool AlarmDialog::eventNotification( QString mess, int replay , QString fn, bool playwav, int pause , int suspendtimes) +{ + if ( mess.left( 9) != "Suspended" ) + mSuspendCounter = suspendtimes; + mPauseCount = pause; + mFileName = fn; + mPlayWav = playwav; + if ( !QFile::exists( fn ) ) + mFileName = ""; + alarmCounter = 0 ; + maxAlarmReplay = replay ; + mStopAlarm = false; + mSilent = false; + if ( mMissedAlarms->text() == "" ) + mMissedAlarms->setText( mMessage->text()); + else + mMissedAlarms->setText( mMessage->text()+ "\n" + mMissedAlarms->text() ); + if ( mMissedAlarms->text().length() > 180 ) + mMissedAlarms->setText(mMissedAlarms->text().left ( 180 )); + mMessage->setText(mess); + int w =sizeHint().width() ; + int h = sizeHint().height() ; + int dw = QApplication::desktop()->width(); + int dh = QApplication::desktop()->height(); + setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); + show(); + raise(); + qApp->processEvents(); + repaint(); + qApp->processEvents(); + +#ifndef _WIN32_ + if ( fd_led > 0 ) { + statusLED.status = LED_SALARM_ON ; + ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED); + } +#endif + playSoundTimer->start( 1000, true ); + return true; + +} + + +void AlarmDialog::playSound () +{ + if (mStopAlarm ) + return; + showNormal(); + setActiveWindow(); + setFocus(); + raise(); + + qApp->processEvents(); + if ( alarmCounter < maxAlarmReplay && ! mSilent) { + ++alarmCounter; + if ( !mPlayWav || mFileName.length() < 2 ) { + +#ifndef DESKTOP_VERSION + Sound::soundAlarm (); +#endif + } else { + QSound::play ( mFileName ); + //qDebug("BEEP!"); + } + } else { + if ( ! mSilent && mSuspendCounter > 0 ) { + --mSuspendCounter; + reject (); + hide(); + return; + } + } + playSoundTimer->start( mPauseCount * 1000, true ); +} diff --git a/kalarmd/alarmdialog.h b/kalarmd/alarmdialog.h new file mode 100644 index 0000000..3155f18 --- a/dev/null +++ b/kalarmd/alarmdialog.h @@ -0,0 +1,80 @@ +/* + This file is part of the KDE alarm daemon. + Copyright (c) 2000 Cornelius Schumacher <schumacher@kde.org> + + 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. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + As a special exception, permission is given to link this program + with any edition of Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ +#ifndef ALARMDIALOG_H +#define ALARMDIALOG_H + + + +#include <qdialog.h> +#include <qdatetime.h> +#include <qstring.h> + +#include "sharp_char.h" + + +class QSpinBox; +class QLabel; +class QString; + +class AlarmDialog : public QDialog { + Q_OBJECT + public: + AlarmDialog( QWidget *parent = 0, const char *name = 0 ); + virtual ~AlarmDialog(); + + bool eventNotification(QString m, int replay , QString m2 , bool, int, int ); + int getSuspendTime( ); + void setSuspendTime( int ); + void setServerNotification( bool b ); + + public slots: + void slotOk(); + void slotSuspend(); + void reject () ; + void silent () ; + void accept(); + void suspend(); + void playSound (); + signals: + // void suspendSignal(int duration); + void addAlarm(const QDateTime &, const QString & ); + + private: + int alarmCounter; + int mPauseCount; + int mSuspendCounter; + int maxAlarmReplay; + QTimer* playSoundTimer; + bool mStopAlarm; + bool mSilent; + bool mPlayWav; + bool mServerNotification; + QLabel* mMessage; + QLabel* mMissedAlarms; + QSpinBox *mSuspendSpin; + QString mFileName; + int fd_led; + sharp_led_status statusLED; +}; + +#endif diff --git a/kalarmd/alarmdialog.moc b/kalarmd/alarmdialog.moc new file mode 100644 index 0000000..e69de29 --- a/dev/null +++ b/kalarmd/alarmdialog.moc diff --git a/kalarmd/kalarmdE.pro b/kalarmd/kalarmdE.pro new file mode 100644 index 0000000..1370ec1 --- a/dev/null +++ b/kalarmd/kalarmdE.pro @@ -0,0 +1,20 @@ +TEMPLATE = lib +CONFIG += qt warn_on +TARGET = kopialarmapplet +OBJECTS_DIR = obj/$(PLATFORM) +MOC_DIR = moc/$(PLATFORM) + +DESTDIR = $(QPEDIR)/plugins/applets + +INTERFACES = \ + +HEADERS = \ + alarmdialog.h \ + simplealarmdaemonapplet.h \ + simplealarmdaemonimpl.h + +SOURCES = \ + alarmdialog.cpp \ + simplealarmdaemonapplet.cpp \ + simplealarmdaemonimpl.cpp + diff --git a/kalarmd/sharp_char.h b/kalarmd/sharp_char.h new file mode 100644 index 0000000..33fabd4 --- a/dev/null +++ b/kalarmd/sharp_char.h @@ -0,0 +1,258 @@ +/* + * linux/include/asm/sharp_char.h + */ + +#ifndef __ASM_SHARP_CHAR_H_INCLUDED +#define __ASM_SHARP_CHAR_H_INCLUDED + +/* + * If SHARPCHAR_USE_MISCDEV defined , misc driver architecture used instead of sharp_char + */ + +#define SHARPCHAR_USE_MISCDEV + +/* + * devices defines... + */ + +#ifndef SHARP_DEV_MAJOR +#define SHARP_DEV_MAJOR 11 +#endif + +#ifndef SHARP_DEV_MINOR_START +#define SHARP_DEV_MINOR_START 210 +#endif + +#define SHARP_DEV_MINOR_MAX 4 /* defines last minor number of SHARP device */ + +#define SHARP_LED_MINOR (SHARP_DEV_MINOR_START+0) +#define SHARP_BUZZER_MINOR (SHARP_DEV_MINOR_START+1) +#define SHARP_GSM_MINOR (SHARP_DEV_MINOR_START+2) +#define SHARP_AUDIOCTL_MINOR (SHARP_DEV_MINOR_START+3) +#define SHARP_KBDCTL_MINOR (SHARP_DEV_MINOR_START+4) + +/* + * ioctl defines... + */ + +#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 + +/* --- for SHARP_LED device --- */ +#define SHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) +#define SHARP_LED_GETSTATUS (SHARP_LED_IOCTL_START) +#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) +#define SHARP_LED_ISUPPORTED (SHARP_LED_IOCTL_START+2) + +typedef struct sharp_led_status { + int which; /* select which LED status is wanted. */ + int status; /* set new led status if you call SHARP_LED_SETSTATUS */ +} sharp_led_status; + +#define SHARP_LED_WHICH_MAX 15 /* last number of LED */ + +/* parameters for 'which' member */ +#define SHARP_LED_PDA 0 /* PDA status */ +#define SHARP_LED_DALARM 1 /* daily alarm */ +#define SHARP_LED_SALARM 2 /* schedule alarm */ +#define SHARP_LED_BATTERY 3 /* main battery status */ +#define SHARP_LED_ACSTATUS 4 /* AC line status */ +#define SHARP_LED_CHARGER 5 /* charger status */ +#define SHARP_LED_PHONE_RSSI 6 /* phone status (RSSI...) */ +#define SHARP_LED_PHONE_DIAL 7 /* phone status (dialing...) */ +#define SHARP_LED_PHONE_IN 8 /* phone status (incoming..) */ +#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ +#define SHARP_LED_MAIL_SEND 10 /* mail status (sending...) */ +#define SHARP_LED_MAIL_QUEUE 11 /* mail to send is in queue */ +#define SHARP_LED_COLLIE_0 12 /* 1st pri. battery LED control */ +#define SHARP_LED_COLLIE_1 13 /* 1st pri. mail LED control */ +#define SHARP_LED_COMM 14 /* communication status */ +#define SHARP_LED_BROWSER 15 /* WWW browser status */ + +/* parameters for 'status' member */ +#define LED_PDA_RUNNING 0 /* for SHARP_LED_RUN */ +#define LED_PDA_SUSPENDED 1 /* for SHARP_LED_RUN */ +#define LED_PDA_OFF 2 /* for SHARP_LED_RUN */ +#define LED_PDA_ERROR 3 /* for SHARP_LED_RUN */ + +#define LED_DALARM_OFF 0 /* for SHARP_LED_DALARM */ +#define LED_DALARM_ON 1 /* for SHARP_LED_DALARM */ + +#define LED_SALARM_OFF 0 /* for SHARP_LED_SALARM */ +#define LED_SALARM_ON 1 /* for SHARP_LED_SALARM */ + +#define LED_BATTERY_GOOD 0 /* for SHARP_LED_BATTERY */ +#define LED_BATTERY_LOW 1 /* for SHARP_LED_BATTERY */ +#define LED_BATTERY_VERY_LOW 2 /* for SHARP_LED_BATTERY */ +#define LED_BATTERY_CRITICAL 3 /* for SHARP_LED_BATTERY */ + +#define LED_CHARGER_OFF 0 /* for SHARP_LED_CHARGER */ +#define LED_CHARGER_CHARGING 1 /* for SHARP_LED_CHARGER */ +#define LED_CHARGER_ERROR 2 /* for SHARP_LED_CHARGER */ + +#define LED_AC_NOT_CONNECTED 0 /* for SHARP_LED_ACSTATUS */ +#define LED_AC_CONNECTED 1 /* for SHARP_LED_ACSTATUS */ + +#define LED_RSSI_OUT 0 /* for SHARP_LED_PHONE_RSSI */ +#define LED_RSSI_IN 1 /* for SHARP_LED_PHONE_RSSI */ + +#define LED_DIAL_OFF 0 /* for SHARP_LED_PHONE_DIAL */ +#define LED_DIAL_DIALING 1 /* for SHARP_LED_PHONE_DIAL */ +#define LED_DIAL_HOLDING 2 /* for SHARP_LED_PHONE_DIAL */ + +#define LED_PHONE_WAITING 0 /* for SHARP_LED_PHONE_IN */ +#define LED_PHONE_INCOMING 1 /* for SHARP_LED_PHONE_IN */ + +#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ +#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ +#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ + +#define LED_SENDMAIL_OFF 0 /* for SHARP_LED_MAIL_SEND */ +#define LED_SENDMAIL_SENDING 1 /* for SHARP_LED_MAIL_SEND */ +#define LED_SENDMAIL_ERROR 2 /* for SHARP_LED_MAIL_SEND */ + +#define LED_MAILQUEUE_NOUNREAD 0 /* for SHARP_LED_MAIL_QUEUE */ +#define LED_MAILQUEUE_NEWMAIL 1 /* for SHARP_LED_MAIL_QUEUE */ +#define LED_MAILQUEUE_UNREAD 2 /* for SHARP_LED_MAIL_QUEUE */ + +#define LED_COLLIE_0_DEFAULT 0 /* for SHARP_LED_COLLIE_0 */ +#define LED_COLLIE_0_OFF 1 /* for SHARP_LED_COLLIE_0 */ +#define LED_COLLIE_0_ON 2 /* for SHARP_LED_COLLIE_0 */ +#define LED_COLLIE_0_FASTBLINK 3 /* for SHARP_LED_COLLIE_0 */ +#define LED_COLLIE_0_SLOWBLINK 4 /* for SHARP_LED_COLLIE_0 */ + +#define LED_COLLIE_1_DEFAULT 0 /* for SHARP_LED_COLLIE_1 */ +#define LED_COLLIE_1_OFF 1 /* for SHARP_LED_COLLIE_1 */ +#define LED_COLLIE_1_ON 2 /* for SHARP_LED_COLLIE_1 */ +#define LED_COLLIE_1_FLASHON 3 /* for SHARP_LED_COLLIE_1 */ +#define LED_COLLIE_1_FLASHOFF 4 /* for SHARP_LED_COLLIE_1 */ +#define LED_COLLIE_1_VFSTBLINK 5 /* for SHARP_LED_COLLIE_1 */ +#define LED_COLLIE_1_FASTBLINK 6 /* for SHARP_LED_COLLIE_1 */ +#define LED_COLLIE_1_NORMBLINK 7 /* for SHARP_LED_COLLIE_1 */ +#define LED_COLLIE_1_SLOWBLINK 8 /* for SHARP_LED_COLLIE_1 */ +#define LED_COLLIE_1_SOFTBLINK 9 /* for SHARP_LED_COLLIE_1 */ +#define LED_COLLIE_1_SOFTFLASH 10 /* for SHARP_LED_COLLIE_1 */ + +#define LED_COMM_OFFLINE 0 /* for SHARP_LED_COMM */ +#define LED_COMM_ONLINE 1 /* for SHARP_LED_COMM */ +#define LED_COMM_ERROR 2 /* for SHARP_LED_COMM */ + +#define LED_BROWSER_OFFLINE 0 /* for SHARP_LED_BROWSER */ +#define LED_BROWSER_ONLINE 1 /* for SHARP_LED_BROWSER */ +#define LED_BROWSER_ERROR 2 /* for SHARP_LED_BROWSER */ + + +/* --- for SHARP_BUZZER device --- */ +#define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) +#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) +#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) +#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) +#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) +#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) +#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) +#define SHARP_BUZZER_SET_BUFFER (SHARP_BUZZER_IOCTL_START+6) + +typedef struct sharp_buzzer_status { /* this struct is used for setvolume/getvolume */ + int which; /* select which LED status is wanted. */ + int volume; /* set new buzzer volume if you call SHARP_BUZZER_SETVOLUME */ + int mute; /* set 1 to MUTE if you call SHARP_BUZZER_SETMUTE */ +} sharp_buzzer_status; + +#define SHARP_BUZ_WHICH_MAX 14 /* last number of buzzer */ + +#define SHARP_BUZ_ALL_SOUNDS -1 /* for setting volumes of ALL sounds at a time */ + +#define SHARP_BUZ_WRITESOUND 0 /* for sound datas through 'write' calls */ +#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ +#define SHARP_BUZ_KEYSOUND 2 /* key sound */ +#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ +#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ +#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ +#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ +#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ +#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ +#define SHARP_PDA_APPSTART 9 /* application start */ +#define SHARP_PDA_APPQUIT 10 /* application ends */ +#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ +#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ +#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ +#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ + +#define SHARP_BUZ_VOLUME_OFF 0 +#define SHARP_BUZ_VOLUME_LOW 33 +#define SHARP_BUZ_VOLUME_MEDIUM 67 +#define SHARP_BUZ_VOLUME_HIGH 100 /* currentry , this is the maximum ... */ +#define SHARP_BUZ_VOLUME_MAX (SHARP_BUZ_VOLUME_HIGH) + +/* --- for SHARP_GSM device --- */ +#define SHARP_GSM_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) +#define SHARP_GSM_GETEXTSTATUS (SHARP_GSM_IOCTL_START+16) +#define SHARP_GSM_INFO_TELL_MODE (SHARP_GSM_IOCTL_START+17) +#define SHARP_IRIS_GETSYNCSTATUS (SHARP_GSM_IOCTL_START+18) +#define SHARP_IRIS_RECHECKDEVICE (SHARP_GSM_IOCTL_START+19) + +#define GSM_PHONE_NO_POWER 0 /* for SHARP_GSM_INFO_TELL_MODE */ +#define GSM_PHONE_NO_CONNECTION 1 /* for SHARP_GSM_INFO_TELL_MODE */ +#define GSM_PHONE_IN_ANALOG_MODE 2 /* for SHARP_GSM_INFO_TELL_MODE */ +#define GSM_PHONE_IN_DATA_MODE 3 /* for SHARP_GSM_INFO_TELL_MODE */ + +typedef struct sharp_gsmext_status { + int carkit; /* be set as 1 , if car-kit is connected */ + int headphone_mic; /* be set as 1 , if head-phone-microphone is inserted */ +} sharp_gsmext_status; + +typedef struct sharp_irisext_status { /* for SHARP_IRIS_GETSYNCSTATUS */ + int usb; + int uart; + int carkit; +} sharp_irisext_status; + +/* --- for SHARP_AUDIOCTL device --- */ +#define SHARP_AUDIOCTL_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) +#define SHARP_AUDIOCTL_ARCH_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START+0x10) +#define SHARP_IRIS_AUFIL_GETVAL (SHARP_AUDIOCTL_ARCH_IOCTL_START+0) +#define SHARP_IRIS_AUFIL_SETVAL (SHARP_AUDIOCTL_ARCH_IOCTL_START+1) +#define SHARP_IRIS_AMP_EXT_ON (SHARP_AUDIOCTL_ARCH_IOCTL_START+2) +#define SHARP_IRIS_AMP_EXT_OFF (SHARP_AUDIOCTL_ARCH_IOCTL_START+3) + + +#define SHARP_IRIS_AUFIL_FILTERON 0x01 /* Iris AudioCtl Specific. Enable Audio Filter */ + +/* --- for SHARP_AUDIOCTL device --- */ +#define SHARP_KBDCTL_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) +#define SHARP_KBDCTL_GETMODIFSTAT (SHARP_KBDCTL_IOCTL_START+0) +#define SHARP_KBDCTL_TOGGLEMODIFSTAT (SHARP_KBDCTL_IOCTL_START+1) +#define SHARP_KBDCTL_SETHOLDTH (SHARP_KBDCTL_IOCTL_START+2) +#define SHARP_KBDCTL_SETHOLDTH_GR (SHARP_KBDCTL_IOCTL_START+3) +#define SHARP_KBDCTL_HOLDINFO_SETHD (SHARP_KBDCTL_IOCTL_START+4) +#define SHARP_KBDCTL_HOLDINFO_SETSL (SHARP_KBDCTL_IOCTL_START+5) +#define SHARP_KBDCTL_HOLDINFO_DELHD (SHARP_KBDCTL_IOCTL_START+6) +#define SHARP_KBDCTL_HOLDINFO_DELSL (SHARP_KBDCTL_IOCTL_START+7) +#define SHARP_KBDCTL_HOLDINFO_RESTHD (SHARP_KBDCTL_IOCTL_START+8) +#define SHARP_KBDCTL_HOLDINFO_RESTSL (SHARP_KBDCTL_IOCTL_START+9) +#define SHARP_KBDCTL_HOLDINFO_RESTFULL (SHARP_KBDCTL_IOCTL_START+10) + +typedef struct sharp_kbdctl_modifstat { + int which; + int stat; +} sharp_kbdctl_modifstat; + +typedef struct sharp_kbdctl_holdstat { + int group; + int timeout; +} sharp_kbdctl_holdstat; + +typedef struct sharp_kbdctl_holdcustom { + int normal_hardcode; + int normal_slcode; + int hold_slcode; +} sharp_kbdctl_holdcustom; + +#define SHARP_EXTMODIF_2ND 0x01 +#define SHARP_EXTMODIF_CAPS 0x02 +#define SHARP_EXTMODIF_NUMLOCK 0x03 + +#define HOLDKEY_GROUP_NORMAL 0 +#define HOLDKEY_GROUP_POWER 1 + +#endif /* __ASM_SHARP_CHAR_H_INCLUDED */ + diff --git a/kalarmd/simplealarmdaemon.desktop b/kalarmd/simplealarmdaemon.desktop new file mode 100644 index 0000000..dae86ba --- a/dev/null +++ b/kalarmd/simplealarmdaemon.desktop @@ -0,0 +1,6 @@ +[Desktop Entry] +Comment=KOrganizer Alarm Daemon +Exec=simplealarmdaemon +Icon=SimpleAlarmDaemon +Type=Application +Name=Alarm Daemon diff --git a/kalarmd/simplealarmdaemonapplet.cpp b/kalarmd/simplealarmdaemonapplet.cpp new file mode 100644 index 0000000..bb89606 --- a/dev/null +++ b/kalarmd/simplealarmdaemonapplet.cpp @@ -0,0 +1,58 @@ +#include "simplealarmdaemonapplet.h" + +#include "simplealarmdaemonimpl.h" + +#include <qpe/global.h> +#include <qcopchannel_qws.h> +#include <qlabel.h> +#include <qapp.h> +#include <qpe/resource.h> +SimpleAlarmDaemonApplet::SimpleAlarmDaemonApplet() + : mApplet( 0 ), ref( 0 ) +{ + +} + +SimpleAlarmDaemonApplet::~SimpleAlarmDaemonApplet() +{ + delete mApplet; +} + + +QWidget *SimpleAlarmDaemonApplet::applet( QWidget *parent ) +{ + if ( !mApplet ) { + mApplet = new SimpleAlarmDaemonImpl( parent ); + if ( QApplication::desktop()->width() < 480 ) + mApplet->setPixmap( Resource::loadPixmap( "ko16" ) ); + else + mApplet->setPixmap( Resource::loadPixmap( "ko24" ) ); + QCopChannel* c = new QCopChannel("koalarm",mApplet , "channel" ) ; + QObject::connect( c, SIGNAL (received ( const QCString &, const QByteArray & )),mApplet, SLOT(recieve( const QCString&, const QByteArray& ))); + mApplet->show(); + } + return mApplet; +} + +int SimpleAlarmDaemonApplet::position() const +{ + return 7; +} + +QRESULT SimpleAlarmDaemonApplet::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) +{ + *iface = 0; + if ( uuid == IID_QUnknown ) + *iface = this; + else if ( uuid == IID_TaskbarApplet ) + *iface = this; + + if ( *iface ) + (*iface)->addRef(); + return QS_OK; +} + +Q_EXPORT_INTERFACE() +{ + Q_CREATE_INSTANCE( SimpleAlarmDaemonApplet ) +} diff --git a/kalarmd/simplealarmdaemonapplet.h b/kalarmd/simplealarmdaemonapplet.h new file mode 100644 index 0000000..a4cbee4 --- a/dev/null +++ b/kalarmd/simplealarmdaemonapplet.h @@ -0,0 +1,26 @@ +#ifndef SIMPLEALARMDAEMONAPPLET_H +#define SIMPLEALARMDAEMONAPPLET_H + +#include <qpe/taskbarappletinterface.h> + +class SimpleAlarmDaemonImpl; +class ScreenshotApplet; + +class SimpleAlarmDaemonApplet : public TaskbarAppletInterface +{ + public: + SimpleAlarmDaemonApplet(); + virtual ~SimpleAlarmDaemonApplet(); + + QRESULT queryInterface( const QUuid&, QUnknownInterface** ); + Q_REFCOUNT + + virtual QWidget *applet( QWidget *parent ); + virtual int position() const; + + private: + SimpleAlarmDaemonImpl *mApplet; + ulong ref; +}; + +#endif diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp new file mode 100644 index 0000000..2bc6643 --- a/dev/null +++ b/kalarmd/simplealarmdaemonimpl.cpp @@ -0,0 +1,552 @@ +/* + This file is part of the KOrganizer alarm daemon. + Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> + + 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. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + As a special exception, permission is given to link this program + with any edition of Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ + +#include "simplealarmdaemonimpl.h" + +#include "alarmdialog.h" +#include <qpopupmenu.h> +#include <qapp.h> +#include <qdir.h> +#include <qfile.h> +#include <qhbox.h> +#include <qtimer.h> +#include <qfile.h> +#include <qlayout.h> +#include <qlineedit.h> +#include <qdialog.h> +#include <qspinbox.h> +#include <qtextstream.h> +#include <qtopia/qcopenvelope_qws.h> +#include <qtopia/alarmserver.h> + +#include <stdlib.h> +#include <stdio.h> +#include <unistd.h> + + +SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent ) + : QLabel( parent ) +{ + mAlarmDialog = new AlarmDialog( 0 ); + mPopUp = new QPopupMenu( 0 ); + mPopUp->insertItem( "Addresses", this, SLOT ( showAdd() ) ); + mPopUp->insertSeparator(); + mPopUp->insertItem( "Multi Sync", this, SLOT ( ringSync() ) ); + mPopUp->insertSeparator(); + mPopUp->insertItem( "What's Next?", this, SLOT ( showWN() ) ); + mPopUp->insertSeparator(); + mPopUp->insertItem( "What's Todo?", this, SLOT ( showTodo() ) ); + mPopUp->insertSeparator(); + mPopUp->insertItem( "Next Days!", this, SLOT ( showKO() ) ); + mPopUp->insertSeparator(); + mPopUp->insertItem( "Edit Journal", this, SLOT ( writeJournal() ) ); + mPopUp->insertSeparator(); + mPopUp->insertItem( "New Event", this, SLOT ( newEvent() ) ); + mPopUp->insertItem( "New Todo", this, SLOT ( newTodo() ) ); + mTimerPopUp = new QPopupMenu( mPopUp ); + + mBeepPopUp = new QPopupMenu( mPopUp ); + mSoundPopUp = new QPopupMenu( mBeepPopUp ); + mPausePopUp = new QPopupMenu( mBeepPopUp ); + QPopupMenu* savePopUp = new QPopupMenu( mBeepPopUp ); + savePopUp->insertItem( "Save", 0 ); + savePopUp->insertItem( "Load", 1 ); + mSoundPopUp->insertItem( "Buzzer", 0 ); + mSoundPopUp->insertItem( "Wav file", 1 ); + mPausePopUp->insertItem( " 1 sec", 1 ); + mPausePopUp->insertItem( " 2 sec", 2 ); + mPausePopUp->insertItem( " 3 sec", 3 ); + mPausePopUp->insertItem( " 5 sec", 5 ); + mPausePopUp->insertItem( "10 sec", 10 ); + mPausePopUp->insertItem( "30 sec", 30 ); + mPausePopUp->insertItem( " 1 min", 60 ); + mPausePopUp->insertItem( " 5 min", 300 ); + mPausePopUp->insertItem( "10 min", 600 ); + mSuspendPopUp = new QPopupMenu( mBeepPopUp ); + mSuspendPopUp->insertItem( "Off", 0 ); + mSuspendPopUp->insertItem( " 1x", 1 ); + mSuspendPopUp->insertItem( " 2x", 2 ); + mSuspendPopUp->insertItem( " 3x", 3 ); + mSuspendPopUp->insertItem( " 5x", 5 ); + mSuspendPopUp->insertItem( "10x", 10 ); + mSuspendPopUp->insertItem( "20x", 20 ); + mSuspendPopUp->insertItem( "30x", 30 ); + mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp ); + mBeepPopUp->insertItem( "Beep interval",mPausePopUp ); + mBeepPopUp->insertItem( "Replay",mSoundPopUp ); + mBeepPopUp->insertItem( "Config",savePopUp ); + mBeepPopUp->insertItem( "300", 300 ); + mBeepPopUp->insertItem( "180", 180 ); + mBeepPopUp->insertItem( "60", 60 ); + mBeepPopUp->insertItem( "30", 30 ); + mBeepPopUp->insertItem( "10", 10 ); + mBeepPopUp->insertItem( "3", 3 ); + mBeepPopUp->insertItem( "1", 1 ); + mBeepPopUp->insertItem( "Off", 0 ); + mBeepPopUp->setCheckable( true ); + mPopUp->insertSeparator(); + mPopUp->insertItem( "Play beeps", mBeepPopUp ); + mPopUp->insertSeparator(); + mPopUp->insertItem( "Timer", mTimerPopUp ); + mPopUp->insertSeparator(); + mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) ); + + mPopUp->resize( mPopUp->sizeHint() ); + mPlayBeeps = 60; + mBeepPopUp->setItemChecked ( mPlayBeeps, true ); + connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) ); + connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) ); + connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) ); + connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) ); + connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) ); + connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) ); + connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) ); + mTimerTime = 0; + mCustomText = "Custom Text"; + mCustomMinutes = 7; + mTimerPopupConf = 1; + fillTimerPopUp(); + mPausePlay = 0; + confPause( 1 ); + mSuspend = 0; + confSuspend( 0 ); + if ( QApplication::desktop()->width() < 480 ) { + wavAlarm = false; + mSoundPopUp->setItemChecked ( 0, true ); + } + else { + wavAlarm = true; + mSoundPopUp->setItemChecked ( 1, true ); + } + saveSlot( 1 ); +} + +SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl() +{ + delete mPopUp; + delete mAlarmDialog; +} +void SimpleAlarmDaemonImpl::saveSlot( int load ) +{ + QString fileName = QDir::homeDirPath() +"/.kopialarmrc"; + //qDebug("save %d ", load ); + QFile file( fileName ); + if ( load ) { + if( !QFile::exists( fileName) ) + return; + if (!file.open( IO_ReadOnly ) ) { + return ; + } + QString line; + bool ok; + int val; + int len; + while ( file.readLine( line, 1024 ) > 0 ) { + //qDebug("read %s ", line.latin1()); + len = line.length(); + if ( line.left(4 ) == "PPAU" ) { + val = line.mid( 4,len-5).toInt( &ok ); + if ( ok ) { + confPause( val ); + } + } + if ( line.left(4 ) == "SUCO" ) { + val = line.mid( 4,len-5).toInt( &ok ); + if ( ok ) + confSuspend ( val ); + } + if ( line.left(4 ) == "WAAL" ) { + val = line.mid( 4,len-5).toInt( &ok ); + if ( ok ) + confSound( val ); + + } + if ( line.left(4 ) == "PLBE" ) { + val = line.mid( 4,len-5).toInt( &ok ); + if ( ok ) + slotPlayBeep( val ); + + } + if ( line.left(4 ) == "CUTE" ) { + mCustomText = line.mid( 5,len-6); + // qDebug("text ***%s*** ",mCustomText.latin1() ); + + } + if ( line.left(4 ) == "CUMI" ) { + val = line.mid( 4,len-5).toInt( &ok ); + if ( ok ) + mCustomMinutes = val; + + } + if ( line.left(4 ) == "SUTI" ) { + val = line.mid( 4,len-5).toInt( &ok ); + if ( ok ) + mAlarmDialog->setSuspendTime( val );; + + } + } + file.close(); + } else { + if (!file.open( IO_WriteOnly ) ) { + return; + } + QString configString ; + configString += "PPAU " + QString::number( mPausePlay ) + "\n"; + configString += "SUCO " + QString::number( mSuspend ) + "\n"; + configString += "WAAL " + QString::number( wavAlarm ) + "\n"; + configString += "PLBE " + QString::number( mPlayBeeps ) + "\n"; + configString += "CUTE " + mCustomText + "\n"; + configString += "CUMI " + QString::number( mCustomMinutes ) + "\n"; + configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n"; + QTextStream ts( &file ); + ts << configString ; + file.close(); + } + +} +void SimpleAlarmDaemonImpl::confSuspend( int num ) +{ + mSuspendPopUp->setItemChecked ( mSuspend,false ); + mSuspend = num; + mSuspendPopUp->setItemChecked ( mSuspend,true ); +} +void SimpleAlarmDaemonImpl::confPause( int num ) +{ + mPausePopUp->setItemChecked ( mPausePlay,false ); + mPausePlay = num; + mPausePopUp->setItemChecked ( mPausePlay,true ); +} +void SimpleAlarmDaemonImpl::confSound( int num ) +{ + if ( num == 0 ) { + wavAlarm = false; + mSoundPopUp->setItemChecked ( 0, true ); + mSoundPopUp->setItemChecked ( 1, false ); + } else { + wavAlarm = true; + mSoundPopUp->setItemChecked ( 0, false ); + mSoundPopUp->setItemChecked ( 1, true ); + } +} +void SimpleAlarmDaemonImpl::slotPlayBeep( int num ) +{ + mBeepPopUp->setItemChecked ( mPlayBeeps,false ); + mPlayBeeps = num; + mBeepPopUp->setItemChecked ( mPlayBeeps, true ); +} + +void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& ) +{ + //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data()); + QString mess = msg; + mAlarmMessage = mess.mid( 9 ); + QString filename = getenv("QPEDIR") ; + filename += "/pics/kdepim/korganizer/koalarm.wav"; + QString tempfilename; + if ( mess.left( 13 ) == "suspend_alarm") { + bool error = false; + int len = mess.mid( 13 ).find("+++"); + if ( len < 2 ) + error = true; + else { + tempfilename = mess.mid( 13, len ); + if ( !QFile::exists( tempfilename ) ) + error = true; + } + if ( ! error ) { + filename = tempfilename; + } + mAlarmMessage = mess.mid( 13+len+3 ); + //qDebug("suspend file %s ",tempfilename.latin1() ); + startAlarm( mAlarmMessage, filename); + return; + } + if ( mess.left( 11 ) == "timer_alarm") { + mTimerTime = 0; + startAlarm( mess.mid( 11 ), filename ); + return; + } + if ( mess.left( 10 ) == "proc_alarm") { + bool error = false; + int len = mess.mid( 10 ).find("+++"); + if ( len < 2 ) + error = true; + else { + tempfilename = mess.mid( 10, len ); + if ( !QFile::exists( tempfilename ) ) + error = true; + } + if ( error ) { + mAlarmMessage = "Procedure Alarm\nError - File not found\n"; + mAlarmMessage += mess.mid( 10+len+3+9 ); + } else { + QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); + //qDebug("-----system command %s ",tempfilename.latin1() ); + if ( vfork () == 0 ) { + execl ( tempfilename.latin1(), 0 ); + return; + } + return; + } + + //qDebug("+++++++system command %s ",tempfilename.latin1() ); + } + if ( mess.left( 11 ) == "audio_alarm") { + bool error = false; + int len = mess.mid( 11 ).find("+++"); + if ( len < 2 ) + error = true; + else { + tempfilename = mess.mid( 11, len ); + if ( !QFile::exists( tempfilename ) ) + error = true; + } + if ( ! error ) { + filename = tempfilename; + } + mAlarmMessage = mess.mid( 11+len+3+9 ); + //qDebug("audio file command %s ",tempfilename.latin1() ); + } + if ( mess.left( 9 ) == "cal_alarm") { + mAlarmMessage = mess.mid( 9 ) ; + } + + writeFile(); + startAlarm( mAlarmMessage, filename ); + +} + +int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) +{ + return 0; +} +void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) +{ + //mAlarmDialog->show(); + //mAlarmDialog->raise(); + mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); +} + + +void SimpleAlarmDaemonImpl::fillTimerPopUp() +{ + + // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); + if ( mTimerPopupConf == mTimerTime ) { + if ( mTimerTime ) { + int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); + QTime t ( secs/3600, (secs/60)%60, secs%60 ); + mTimerPopUp->changeItem ( 1 , t.toString()); + } + else { + QString text = mCustomText.stripWhiteSpace (); + int in = text.find( " " ); + text = text.left ( in ); + mTimerPopUp->changeItem ( 3, text ); + } + return; + } + mTimerPopupConf = mTimerTime; + mTimerPopUp->clear(); + if ( mTimerTime ) { + int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); + QTime t ( secs/3600, (secs/60)%60, secs%60 ); + mTimerPopUp->insertItem( "Stop", 0 ); + mTimerPopUp->insertItem( t.toString(),1); + } else { + mTimerPopUp->insertItem( "24 h", 1440 ); + // mTimerPopUp->insertItem( i18n("12 h"), 720 ); + mTimerPopUp->insertItem( " 8 h", 480 ); + mTimerPopUp->insertItem( " 5 h", 300 ); + // mTimerPopUp->insertItem( i18n(" 2 h"), 120 ); + mTimerPopUp->insertItem( " 1 h", 60 ); + mTimerPopUp->insertItem( "30 min", 30 ); + mTimerPopUp->insertItem( "15 min", 15 ); + mTimerPopUp->insertItem( "10 min", 10 ); + //mTimerPopUp->insertItem( " 5 min", 5 ); + mTimerPopUp->insertSeparator(); + mTimerPopUp->insertItem( "Pizza", 22 ); + mTimerPopUp->insertItem( "Nap", 45 ); + mTimerPopUp->insertItem( "Tea", 5 ); + QString text = mCustomText.stripWhiteSpace (); + int in = text.find( " " ); + text = text.left ( in ); + mTimerPopUp->insertItem( text, 3 ); + mTimerPopUp->insertSeparator(); + mTimerPopUp->insertItem( "Customize", 2 ); + } + +} + +void SimpleAlarmDaemonImpl::showTimer() +{ + fillTimerPopUp(); +} + +void SimpleAlarmDaemonImpl::confTimer( int time ) +{ + //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time ); + int minutes = time; + if ( minutes == 0 ) { + if ( ! mTimerTime ) + return; + + QDialog dia ( 0, ("Stop Timer" ), true ); + QLabel lab (("Really stop the timer?"), &dia ); + dia.setCaption(("KO/Pi Timer Stop" )); + QVBoxLayout lay( &dia ); + lay.setMargin(5); + lay.setSpacing(5); + lay.addWidget( &lab); + dia.resize( 200, dia.sizeHint().height() ); + + if ( !dia.exec() ) + return; + + AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.latin1() ); + mTimerTime = 0; + return; + } + if ( mTimerTime ) + return; + if ( minutes == 1 ) { + return; + } + QString mess = "timer_alarm"; + mess += ("Timer Alarm!\n"); + if ( minutes == 22 ) + mess += ( "Pizza is ready"); + else if ( minutes == 45 ) + mess += ( "Please wake up!"); + else if ( minutes == 5 ) + mess += ( "Tea is ready"); + else if ( minutes == 3 ) { + mess += mCustomText; + minutes = mCustomMinutes ; + } + else { + if ( minutes == 2 ) { + // ask time + QDialog dia ( 0, ("Customize Timer" ), true ); + QLabel lab (("Message Text:"), &dia ); + dia.setCaption(("KO/Pi Timer" )); + QVBoxLayout lay( &dia ); + lay.setMargin(5); + lay.setSpacing(5); + lay.addWidget( &lab); + QLineEdit lEdit( mCustomText, &dia ); + lay.addWidget( &lEdit); + QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia ); + lay.addWidget( &lab2); + QHBox hbox ( &dia ); + QLabel lab3 (("h:"), &hbox ); + QSpinBox spinh( 0, 24, 1,& hbox ); + QLabel lab4 ((" min:"), &hbox ); + QSpinBox spinm( 0, 59, 1,&hbox ); + spinh.setValue( mCustomMinutes/60 ); + spinm.setValue( mCustomMinutes%60 ); + lay.addWidget( &hbox); + dia.resize( dia.sizeHint().width(), dia.sizeHint().height() ); + if ( !dia.exec() ) + return; + mCustomText = lEdit.text(); + mCustomMinutes = spinh.value()*60+spinm.value(); + if ( mCustomMinutes == 0 ) + mCustomMinutes = 1; + if ( mCustomMinutes > 1440 ) + mCustomMinutes = 1440; + mess += mCustomText; + minutes = mCustomMinutes; + } + else + mess+= QString::number ( minutes ) + ( " minutes are past!"); + } + //minutes = 1; + mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); + timerMesssage = mess; + AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.latin1()); + mTimerTime = 1; +} + +void SimpleAlarmDaemonImpl::writeFile() +{ + QCopEnvelope e("QPE/Application/kopi", "-writeFile"); +} +void SimpleAlarmDaemonImpl::showWN() +{ + QCopEnvelope e("QPE/Application/kopi", "-showWN"); +} +void SimpleAlarmDaemonImpl::newTodo() +{ + QCopEnvelope e("QPE/Application/kopi", "-newTodo"); +} + +void SimpleAlarmDaemonImpl::newEvent() +{ + QCopEnvelope e("QPE/Application/kopi", "-newEvent"); + +} + +void SimpleAlarmDaemonImpl::showAdd() +{ + QCopEnvelope e("QPE/Application/kapi", " "); +} +void SimpleAlarmDaemonImpl::ringSync() +{ + QCopEnvelope e("QPE/Application/kopi", "-ringSync"); + +} +void SimpleAlarmDaemonImpl::newCountdown() +{ + //recieve("cal_alarm", 10 ); +} +void SimpleAlarmDaemonImpl::simulate() +{ + writeFile(); + QString filename = getenv("QPEDIR") ; + filename += "/pics/kdepim/korganizer/koalarm.wav"; + startAlarm("Alarm simulation", filename ); +} +void SimpleAlarmDaemonImpl::showKO() +{ + QCopEnvelope e("QPE/Application/kopi", "-showKO"); + +} +void SimpleAlarmDaemonImpl::showTodo() +{ + QCopEnvelope e("QPE/Application/kopi", "-showTodo"); + +} +void SimpleAlarmDaemonImpl::writeJournal() +{ + QCopEnvelope e("QPE/Application/kopi", "-showJournal"); + +} + +void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) +{ + + mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); + +} + diff --git a/kalarmd/simplealarmdaemonimpl.h b/kalarmd/simplealarmdaemonimpl.h new file mode 100644 index 0000000..1c16af8 --- a/dev/null +++ b/kalarmd/simplealarmdaemonimpl.h @@ -0,0 +1,85 @@ +/* + This file is part of the KOrganizer alarm daemon. + Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> + + 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. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + As a special exception, permission is given to link this program + with any edition of Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ +#ifndef SIMPLEALARMDAEMONIMPL_H +#define SIMPLEALARMDAEMONIMPL_H + +//#include "simplealarmdaemon.h" +#include <qdatetime.h> +#include <qlabel.h> + +class QLabel; +class QTimer; +class QPopupMenu; +class AlarmDialog; +class SimpleAlarmDaemonImpl : public QLabel +{ + Q_OBJECT + public: + SimpleAlarmDaemonImpl( QWidget *parent = 0 ); + + ~SimpleAlarmDaemonImpl(); + + protected slots: + void recieve( const QCString& msg, const QByteArray& data ); + void newTodo(); + void newEvent(); + void newCountdown(); + void simulate(); + void showKO(); + void showWN(); + void showAdd(); + void ringSync(); + void showTodo(); + void writeFile(); + void writeJournal(); + void slotPlayBeep( int ); + void showTimer( ); + void confPause( int ); + void confTimer( int ); + void saveSlot( int ); + void confSuspend( int ); + void confSound( int num ); + void startAlarm(QString mess, QString fn ); + + protected: + void mousePressEvent( QMouseEvent * ); + + private: + AlarmDialog *mAlarmDialog; + int mPlayBeeps; + int mPausePlay; + int mSuspend; + QString mAlarmMessage; + int mTimerTime; + int getFileNameLen( QString ); + QPopupMenu* mPopUp, *mBeepPopUp, *mTimerPopUp, *mSoundPopUp,*mPausePopUp,*mSuspendPopUp; + QDateTime mRunningTimer; + void fillTimerPopUp(); + QString timerMesssage; + QString mCustomText; + int mCustomMinutes; + int mTimerPopupConf; + bool wavAlarm; +}; + +#endif |