summaryrefslogtreecommitdiffabout
path: root/kalarmd
Unidiff
Diffstat (limited to 'kalarmd') (more/less context) (show whitespace changes)
-rw-r--r--kalarmd/alarmdialog.cpp259
-rw-r--r--kalarmd/alarmdialog.h80
-rw-r--r--kalarmd/alarmdialog.moc0
-rw-r--r--kalarmd/kalarmdE.pro20
-rw-r--r--kalarmd/sharp_char.h258
-rw-r--r--kalarmd/simplealarmdaemon.desktop6
-rw-r--r--kalarmd/simplealarmdaemonapplet.cpp58
-rw-r--r--kalarmd/simplealarmdaemonapplet.h26
-rw-r--r--kalarmd/simplealarmdaemonimpl.cpp552
-rw-r--r--kalarmd/simplealarmdaemonimpl.h85
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 @@
1/*
2 This file is part of the KDE alarm daemon.
3 Copyright (c) 2000 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24// $Id$
25
26#include <qhbox.h>
27#include <qvbox.h>
28#include <qapp.h>
29#include <qlabel.h>
30#include <qlayout.h>
31#include <qfile.h>
32#include <qtimer.h>
33#include <qsound.h>
34#include <qpushbutton.h>
35#include <qspinbox.h>
36#include <stdlib.h>
37#ifndef _WIN32_
38#include <unistd.h>
39#include <sys/ioctl.h>
40#endif
41#include <stdio.h>
42#include <fcntl.h>
43
44#ifndef DESKTOP_VERSION
45#include <qtopia/alarmserver.h>
46#include <qpe/resource.h>
47#include <qtopia/sound.h>
48#endif
49
50#include "alarmdialog.h"
51#include "alarmdialog.moc"
52
53
54AlarmDialog::AlarmDialog(QWidget *parent,const char *name)
55 : QDialog (parent, name, true, Qt::WStyle_StaysOnTop )
56{
57 setCaption( "KO/Pi Alarm!" );
58 QVBoxLayout* layout = new QVBoxLayout( this);
59 QLabel* l = new QLabel("The following event triggered alarm:",this);
60 layout->addWidget ( l );
61 l->setAlignment( AlignCenter);
62 mMessage = new QLabel ( " ", this );
63 int fs = 18;
64 int fs2 = 12;
65 if ( QApplication::desktop()->width() < 480 ) {
66 setMaximumSize(220, 260);
67 fs2 = 10;
68 }
69 else {
70 setMaximumSize(440, 440);
71 }
72 layout->setSpacing( 3 );
73 layout->setMargin( 3 );
74
75 l->setFont( QFont("helvetica",fs2, QFont::Bold) );
76 mMessage->setFont( QFont("helvetica",fs, QFont::Bold) );
77 mMessage->setAlignment( AlignCenter);
78 l = new QLabel("Missed Alarms:",this);
79 l->setAlignment( AlignCenter);
80 layout->addWidget ( mMessage );
81 layout->addWidget ( l );
82 mMissedAlarms= new QLabel ( "", this );
83 mMissedAlarms->setAlignment( AlignCenter);
84
85 playSoundTimer = new QTimer( this );
86 connect ( playSoundTimer, SIGNAL( timeout() ), this, SLOT (playSound() ) );
87
88 playSoundTimer->stop();
89
90 layout->addWidget ( mMissedAlarms );
91 QHBox *suspendBox = new QHBox( this );
92 suspendBox->setSpacing(3);
93 layout->addWidget ( suspendBox );
94 (void)new QLabel("Suspend duration (minutes):",suspendBox);
95 mSuspendSpin = new QSpinBox(1,1440,1,suspendBox);
96 mSuspendSpin->setValue(7); // default suspend duration
97 QHBox * bbox = new QHBox ( this );
98 layout->addWidget ( bbox );
99 bbox->layout()->setSpacing( 5 );
100 QPushButton* suspend = new QPushButton( "Suspend", bbox);
101 QPushButton* silen = new QPushButton( " Stop sound ", bbox);
102 QPushButton* okbut = new QPushButton( "Ok", bbox);
103 connect (silen , SIGNAL( clicked() ), this, SLOT (silent() ) );
104 connect (suspend , SIGNAL( clicked() ), this, SLOT (slotSuspend() ) );
105 connect (okbut , SIGNAL( clicked() ), this, SLOT (slotOk() ) );
106#ifndef _WIN32_
107 if ( QFile::exists ( "/dev/sharp_led" ) )
108 fd_led = open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
109 else
110#endif
111 fd_led = 0;
112 statusLED.which = SHARP_LED_SALARM;
113 mSilent = false;
114 mSuspendCounter = 0;
115 setServerNotification( true );
116}
117void AlarmDialog::reject ()
118{
119 QTimer::singleShot ( 3000, this, SLOT (suspend()) );
120 slotSuspend();
121}
122AlarmDialog::~AlarmDialog()
123{
124}
125void AlarmDialog::silent ()
126{
127 mSilent = true;
128}
129void AlarmDialog::accept()
130{
131 slotOk();
132}
133
134void AlarmDialog::suspend()
135{
136#ifdef DESKTOP_VERSION
137
138#else
139 Sound::soundAlarm ();
140#endif
141}
142void AlarmDialog::slotOk()
143{
144 mStopAlarm = true;
145 mMissedAlarms->setText("");
146 mMessage->setText("");
147#ifndef _WIN32_
148 if ( fd_led > 0 ) {
149 statusLED.status = LED_SALARM_OFF ;
150 ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED);
151 }
152#endif
153 QDialog::accept();
154}
155
156void AlarmDialog::slotSuspend()
157{
158 //qDebug("AlarmDialog::suspend() "); // emit suspendSignal(mSuspendSpin->value());
159 mStopAlarm = true;
160 QDateTime nextA = QDateTime::currentDateTime().addSecs( mSuspendSpin->value() * 60 );
161 QString mess = "suspend_alarm" +mFileName+"+++" ;
162 if ( mMessage->text().left( 10 ) !="Suspended:" )
163 mess += "Suspended:\n";
164 mess +=mMessage->text();
165#ifndef DESKTOP_VERSION
166 if ( mServerNotification )
167 AlarmServer::addAlarm ( nextA,"koalarm",mess.latin1());
168#endif
169 emit addAlarm( nextA , mess );
170 slotOk();
171}
172
173void AlarmDialog::setServerNotification( bool b )
174{
175 mServerNotification = b;
176}
177int AlarmDialog::getSuspendTime( )
178{
179 return mSuspendSpin->value();
180
181}
182void AlarmDialog::setSuspendTime( int val )
183{
184 mSuspendSpin->setValue( val );
185}
186bool AlarmDialog::eventNotification( QString mess, int replay , QString fn, bool playwav, int pause , int suspendtimes)
187{
188 if ( mess.left( 9) != "Suspended" )
189 mSuspendCounter = suspendtimes;
190 mPauseCount = pause;
191 mFileName = fn;
192 mPlayWav = playwav;
193 if ( !QFile::exists( fn ) )
194 mFileName = "";
195 alarmCounter = 0 ;
196 maxAlarmReplay = replay ;
197 mStopAlarm = false;
198 mSilent = false;
199 if ( mMissedAlarms->text() == "" )
200 mMissedAlarms->setText( mMessage->text());
201 else
202 mMissedAlarms->setText( mMessage->text()+ "\n" + mMissedAlarms->text() );
203 if ( mMissedAlarms->text().length() > 180 )
204 mMissedAlarms->setText(mMissedAlarms->text().left ( 180 ));
205 mMessage->setText(mess);
206 int w =sizeHint().width() ;
207 int h = sizeHint().height() ;
208 int dw = QApplication::desktop()->width();
209 int dh = QApplication::desktop()->height();
210 setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
211 show();
212 raise();
213 qApp->processEvents();
214 repaint();
215 qApp->processEvents();
216
217#ifndef _WIN32_
218 if ( fd_led > 0 ) {
219 statusLED.status = LED_SALARM_ON ;
220 ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED);
221 }
222#endif
223 playSoundTimer->start( 1000, true );
224 return true;
225
226}
227
228
229void AlarmDialog::playSound ()
230{
231 if (mStopAlarm )
232 return;
233 showNormal();
234 setActiveWindow();
235 setFocus();
236 raise();
237
238 qApp->processEvents();
239 if ( alarmCounter < maxAlarmReplay && ! mSilent) {
240 ++alarmCounter;
241 if ( !mPlayWav || mFileName.length() < 2 ) {
242
243#ifndef DESKTOP_VERSION
244 Sound::soundAlarm ();
245#endif
246 } else {
247 QSound::play ( mFileName );
248 //qDebug("BEEP!");
249 }
250 } else {
251 if ( ! mSilent && mSuspendCounter > 0 ) {
252 --mSuspendCounter;
253 reject ();
254 hide();
255 return;
256 }
257 }
258 playSoundTimer->start( mPauseCount * 1000, true );
259}
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 @@
1/*
2 This file is part of the KDE alarm daemon.
3 Copyright (c) 2000 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23#ifndef ALARMDIALOG_H
24#define ALARMDIALOG_H
25
26
27
28#include <qdialog.h>
29#include <qdatetime.h>
30#include <qstring.h>
31
32#include "sharp_char.h"
33
34
35class QSpinBox;
36class QLabel;
37class QString;
38
39class AlarmDialog : public QDialog {
40 Q_OBJECT
41 public:
42 AlarmDialog( QWidget *parent = 0, const char *name = 0 );
43 virtual ~AlarmDialog();
44
45 bool eventNotification(QString m, int replay , QString m2 , bool, int, int );
46 int getSuspendTime( );
47 void setSuspendTime( int );
48 void setServerNotification( bool b );
49
50 public slots:
51 void slotOk();
52 void slotSuspend();
53 void reject () ;
54 void silent () ;
55 void accept();
56 void suspend();
57 void playSound ();
58 signals:
59 // void suspendSignal(int duration);
60 void addAlarm(const QDateTime &, const QString & );
61
62 private:
63 int alarmCounter;
64 int mPauseCount;
65 int mSuspendCounter;
66 int maxAlarmReplay;
67 QTimer* playSoundTimer;
68 bool mStopAlarm;
69 bool mSilent;
70 bool mPlayWav;
71 bool mServerNotification;
72 QLabel* mMessage;
73 QLabel* mMissedAlarms;
74 QSpinBox *mSuspendSpin;
75 QString mFileName;
76 int fd_led;
77 sharp_led_status statusLED;
78};
79
80#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 @@
1 TEMPLATE= lib
2 CONFIG += qt warn_on
3 TARGET = kopialarmapplet
4OBJECTS_DIR = obj/$(PLATFORM)
5MOC_DIR = moc/$(PLATFORM)
6
7DESTDIR = $(QPEDIR)/plugins/applets
8
9INTERFACES = \
10
11HEADERS = \
12 alarmdialog.h \
13 simplealarmdaemonapplet.h \
14 simplealarmdaemonimpl.h
15
16SOURCES = \
17 alarmdialog.cpp \
18 simplealarmdaemonapplet.cpp \
19 simplealarmdaemonimpl.cpp
20
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 @@
1/*
2 * linux/include/asm/sharp_char.h
3 */
4
5#ifndef __ASM_SHARP_CHAR_H_INCLUDED
6#define __ASM_SHARP_CHAR_H_INCLUDED
7
8/*
9 * If SHARPCHAR_USE_MISCDEV defined , misc driver architecture used instead of sharp_char
10 */
11
12#define SHARPCHAR_USE_MISCDEV
13
14/*
15 * devices defines...
16 */
17
18#ifndef SHARP_DEV_MAJOR
19#define SHARP_DEV_MAJOR 11
20#endif
21
22#ifndef SHARP_DEV_MINOR_START
23#define SHARP_DEV_MINOR_START 210
24#endif
25
26#define SHARP_DEV_MINOR_MAX 4 /* defines last minor number of SHARP device */
27
28#define SHARP_LED_MINOR (SHARP_DEV_MINOR_START+0)
29#define SHARP_BUZZER_MINOR (SHARP_DEV_MINOR_START+1)
30#define SHARP_GSM_MINOR (SHARP_DEV_MINOR_START+2)
31#define SHARP_AUDIOCTL_MINOR (SHARP_DEV_MINOR_START+3)
32#define SHARP_KBDCTL_MINOR (SHARP_DEV_MINOR_START+4)
33
34/*
35 * ioctl defines...
36 */
37
38#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
39
40/* --- for SHARP_LED device --- */
41 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
42#define SHARP_LED_GETSTATUS (SHARP_LED_IOCTL_START)
43#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
44#define SHARP_LED_ISUPPORTED (SHARP_LED_IOCTL_START+2)
45
46typedef struct sharp_led_status {
47 int which; /* select which LED status is wanted. */
48 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
49} sharp_led_status;
50
51#define SHARP_LED_WHICH_MAX 15 /* last number of LED */
52
53/* parameters for 'which' member */
54#define SHARP_LED_PDA 0 /* PDA status */
55#define SHARP_LED_DALARM 1 /* daily alarm */
56#define SHARP_LED_SALARM 2 /* schedule alarm */
57#define SHARP_LED_BATTERY 3 /* main battery status */
58#define SHARP_LED_ACSTATUS 4 /* AC line status */
59#define SHARP_LED_CHARGER 5 /* charger status */
60#define SHARP_LED_PHONE_RSSI 6 /* phone status (RSSI...) */
61#define SHARP_LED_PHONE_DIAL 7 /* phone status (dialing...) */
62#define SHARP_LED_PHONE_IN 8 /* phone status (incoming..) */
63#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
64#define SHARP_LED_MAIL_SEND 10 /* mail status (sending...) */
65#define SHARP_LED_MAIL_QUEUE 11 /* mail to send is in queue */
66#define SHARP_LED_COLLIE_0 12 /* 1st pri. battery LED control */
67#define SHARP_LED_COLLIE_1 13 /* 1st pri. mail LED control */
68#define SHARP_LED_COMM 14 /* communication status */
69#define SHARP_LED_BROWSER 15 /* WWW browser status */
70
71/* parameters for 'status' member */
72#define LED_PDA_RUNNING 0 /* for SHARP_LED_RUN */
73#define LED_PDA_SUSPENDED 1 /* for SHARP_LED_RUN */
74#define LED_PDA_OFF 2 /* for SHARP_LED_RUN */
75#define LED_PDA_ERROR 3 /* for SHARP_LED_RUN */
76
77#define LED_DALARM_OFF 0 /* for SHARP_LED_DALARM */
78#define LED_DALARM_ON 1 /* for SHARP_LED_DALARM */
79
80#define LED_SALARM_OFF 0 /* for SHARP_LED_SALARM */
81#define LED_SALARM_ON 1 /* for SHARP_LED_SALARM */
82
83#define LED_BATTERY_GOOD 0 /* for SHARP_LED_BATTERY */
84#define LED_BATTERY_LOW 1 /* for SHARP_LED_BATTERY */
85#define LED_BATTERY_VERY_LOW 2 /* for SHARP_LED_BATTERY */
86#define LED_BATTERY_CRITICAL 3 /* for SHARP_LED_BATTERY */
87
88#define LED_CHARGER_OFF 0 /* for SHARP_LED_CHARGER */
89#define LED_CHARGER_CHARGING 1 /* for SHARP_LED_CHARGER */
90#define LED_CHARGER_ERROR 2 /* for SHARP_LED_CHARGER */
91
92#define LED_AC_NOT_CONNECTED 0 /* for SHARP_LED_ACSTATUS */
93#define LED_AC_CONNECTED 1 /* for SHARP_LED_ACSTATUS */
94
95#define LED_RSSI_OUT 0 /* for SHARP_LED_PHONE_RSSI */
96#define LED_RSSI_IN 1 /* for SHARP_LED_PHONE_RSSI */
97
98#define LED_DIAL_OFF 0 /* for SHARP_LED_PHONE_DIAL */
99#define LED_DIAL_DIALING 1 /* for SHARP_LED_PHONE_DIAL */
100#define LED_DIAL_HOLDING 2 /* for SHARP_LED_PHONE_DIAL */
101
102#define LED_PHONE_WAITING 0 /* for SHARP_LED_PHONE_IN */
103#define LED_PHONE_INCOMING 1 /* for SHARP_LED_PHONE_IN */
104
105#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
106#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
107#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
108
109#define LED_SENDMAIL_OFF 0 /* for SHARP_LED_MAIL_SEND */
110#define LED_SENDMAIL_SENDING 1 /* for SHARP_LED_MAIL_SEND */
111#define LED_SENDMAIL_ERROR 2 /* for SHARP_LED_MAIL_SEND */
112
113#define LED_MAILQUEUE_NOUNREAD 0 /* for SHARP_LED_MAIL_QUEUE */
114#define LED_MAILQUEUE_NEWMAIL 1 /* for SHARP_LED_MAIL_QUEUE */
115#define LED_MAILQUEUE_UNREAD 2 /* for SHARP_LED_MAIL_QUEUE */
116
117 #define LED_COLLIE_0_DEFAULT 0 /* for SHARP_LED_COLLIE_0 */
118#define LED_COLLIE_0_OFF 1 /* for SHARP_LED_COLLIE_0 */
119 #define LED_COLLIE_0_ON 2 /* for SHARP_LED_COLLIE_0 */
120 #define LED_COLLIE_0_FASTBLINK 3 /* for SHARP_LED_COLLIE_0 */
121 #define LED_COLLIE_0_SLOWBLINK 4 /* for SHARP_LED_COLLIE_0 */
122
123#define LED_COLLIE_1_DEFAULT 0 /* for SHARP_LED_COLLIE_1 */
124#define LED_COLLIE_1_OFF 1 /* for SHARP_LED_COLLIE_1 */
125#define LED_COLLIE_1_ON 2 /* for SHARP_LED_COLLIE_1 */
126#define LED_COLLIE_1_FLASHON 3 /* for SHARP_LED_COLLIE_1 */
127#define LED_COLLIE_1_FLASHOFF 4 /* for SHARP_LED_COLLIE_1 */
128#define LED_COLLIE_1_VFSTBLINK 5 /* for SHARP_LED_COLLIE_1 */
129#define LED_COLLIE_1_FASTBLINK 6 /* for SHARP_LED_COLLIE_1 */
130#define LED_COLLIE_1_NORMBLINK 7 /* for SHARP_LED_COLLIE_1 */
131#define LED_COLLIE_1_SLOWBLINK 8 /* for SHARP_LED_COLLIE_1 */
132#define LED_COLLIE_1_SOFTBLINK 9 /* for SHARP_LED_COLLIE_1 */
133#define LED_COLLIE_1_SOFTFLASH 10 /* for SHARP_LED_COLLIE_1 */
134
135#define LED_COMM_OFFLINE 0 /* for SHARP_LED_COMM */
136#define LED_COMM_ONLINE 1 /* for SHARP_LED_COMM */
137#define LED_COMM_ERROR 2 /* for SHARP_LED_COMM */
138
139#define LED_BROWSER_OFFLINE 0 /* for SHARP_LED_BROWSER */
140#define LED_BROWSER_ONLINE 1 /* for SHARP_LED_BROWSER */
141#define LED_BROWSER_ERROR 2 /* for SHARP_LED_BROWSER */
142
143
144/* --- for SHARP_BUZZER device --- */
145 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
146#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
147#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
148#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
149#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
150#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
151#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
152#define SHARP_BUZZER_SET_BUFFER (SHARP_BUZZER_IOCTL_START+6)
153
154typedef struct sharp_buzzer_status { /* this struct is used for setvolume/getvolume */
155 int which; /* select which LED status is wanted. */
156 int volume; /* set new buzzer volume if you call SHARP_BUZZER_SETVOLUME */
157 int mute; /* set 1 to MUTE if you call SHARP_BUZZER_SETMUTE */
158} sharp_buzzer_status;
159
160#define SHARP_BUZ_WHICH_MAX 14 /* last number of buzzer */
161
162#define SHARP_BUZ_ALL_SOUNDS -1 /* for setting volumes of ALL sounds at a time */
163
164#define SHARP_BUZ_WRITESOUND 0 /* for sound datas through 'write' calls */
165#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
166#define SHARP_BUZ_KEYSOUND 2 /* key sound */
167#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
168#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
169#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
170#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
171#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
172#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
173#define SHARP_PDA_APPSTART 9 /* application start */
174#define SHARP_PDA_APPQUIT 10 /* application ends */
175#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
176#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
177#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
178#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
179
180#define SHARP_BUZ_VOLUME_OFF 0
181#define SHARP_BUZ_VOLUME_LOW 33
182#define SHARP_BUZ_VOLUME_MEDIUM 67
183#define SHARP_BUZ_VOLUME_HIGH 100 /* currentry , this is the maximum ... */
184#define SHARP_BUZ_VOLUME_MAX (SHARP_BUZ_VOLUME_HIGH)
185
186/* --- for SHARP_GSM device --- */
187 #defineSHARP_GSM_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
188#define SHARP_GSM_GETEXTSTATUS (SHARP_GSM_IOCTL_START+16)
189#define SHARP_GSM_INFO_TELL_MODE (SHARP_GSM_IOCTL_START+17)
190#define SHARP_IRIS_GETSYNCSTATUS (SHARP_GSM_IOCTL_START+18)
191#define SHARP_IRIS_RECHECKDEVICE (SHARP_GSM_IOCTL_START+19)
192
193#define GSM_PHONE_NO_POWER 0 /* for SHARP_GSM_INFO_TELL_MODE */
194#define GSM_PHONE_NO_CONNECTION 1 /* for SHARP_GSM_INFO_TELL_MODE */
195#define GSM_PHONE_IN_ANALOG_MODE 2 /* for SHARP_GSM_INFO_TELL_MODE */
196#define GSM_PHONE_IN_DATA_MODE 3 /* for SHARP_GSM_INFO_TELL_MODE */
197
198typedef struct sharp_gsmext_status {
199 int carkit; /* be set as 1 , if car-kit is connected */
200 int headphone_mic; /* be set as 1 , if head-phone-microphone is inserted */
201} sharp_gsmext_status;
202
203typedef struct sharp_irisext_status { /* for SHARP_IRIS_GETSYNCSTATUS */
204 int usb;
205 int uart;
206 int carkit;
207} sharp_irisext_status;
208
209/* --- for SHARP_AUDIOCTL device --- */
210 #defineSHARP_AUDIOCTL_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
211 #defineSHARP_AUDIOCTL_ARCH_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START+0x10)
212#define SHARP_IRIS_AUFIL_GETVAL (SHARP_AUDIOCTL_ARCH_IOCTL_START+0)
213#define SHARP_IRIS_AUFIL_SETVAL (SHARP_AUDIOCTL_ARCH_IOCTL_START+1)
214#define SHARP_IRIS_AMP_EXT_ON (SHARP_AUDIOCTL_ARCH_IOCTL_START+2)
215#define SHARP_IRIS_AMP_EXT_OFF (SHARP_AUDIOCTL_ARCH_IOCTL_START+3)
216
217
218#define SHARP_IRIS_AUFIL_FILTERON 0x01 /* Iris AudioCtl Specific. Enable Audio Filter */
219
220/* --- for SHARP_AUDIOCTL device --- */
221 #defineSHARP_KBDCTL_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
222#define SHARP_KBDCTL_GETMODIFSTAT (SHARP_KBDCTL_IOCTL_START+0)
223#define SHARP_KBDCTL_TOGGLEMODIFSTAT (SHARP_KBDCTL_IOCTL_START+1)
224#define SHARP_KBDCTL_SETHOLDTH (SHARP_KBDCTL_IOCTL_START+2)
225#define SHARP_KBDCTL_SETHOLDTH_GR (SHARP_KBDCTL_IOCTL_START+3)
226#define SHARP_KBDCTL_HOLDINFO_SETHD (SHARP_KBDCTL_IOCTL_START+4)
227#define SHARP_KBDCTL_HOLDINFO_SETSL (SHARP_KBDCTL_IOCTL_START+5)
228#define SHARP_KBDCTL_HOLDINFO_DELHD (SHARP_KBDCTL_IOCTL_START+6)
229#define SHARP_KBDCTL_HOLDINFO_DELSL (SHARP_KBDCTL_IOCTL_START+7)
230#define SHARP_KBDCTL_HOLDINFO_RESTHD (SHARP_KBDCTL_IOCTL_START+8)
231#define SHARP_KBDCTL_HOLDINFO_RESTSL (SHARP_KBDCTL_IOCTL_START+9)
232#define SHARP_KBDCTL_HOLDINFO_RESTFULL (SHARP_KBDCTL_IOCTL_START+10)
233
234typedef struct sharp_kbdctl_modifstat {
235 int which;
236 int stat;
237} sharp_kbdctl_modifstat;
238
239typedef struct sharp_kbdctl_holdstat {
240 int group;
241 int timeout;
242} sharp_kbdctl_holdstat;
243
244typedef struct sharp_kbdctl_holdcustom {
245 int normal_hardcode;
246 int normal_slcode;
247 int hold_slcode;
248} sharp_kbdctl_holdcustom;
249
250#define SHARP_EXTMODIF_2ND 0x01
251#define SHARP_EXTMODIF_CAPS 0x02
252#define SHARP_EXTMODIF_NUMLOCK 0x03
253
254#define HOLDKEY_GROUP_NORMAL 0
255#define HOLDKEY_GROUP_POWER 1
256
257#endif /* __ASM_SHARP_CHAR_H_INCLUDED */
258
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 @@
1[Desktop Entry]
2Comment=KOrganizer Alarm Daemon
3Exec=simplealarmdaemon
4Icon=SimpleAlarmDaemon
5Type=Application
6Name=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 @@
1#include "simplealarmdaemonapplet.h"
2
3#include "simplealarmdaemonimpl.h"
4
5#include <qpe/global.h>
6#include <qcopchannel_qws.h>
7#include <qlabel.h>
8#include <qapp.h>
9#include <qpe/resource.h>
10SimpleAlarmDaemonApplet::SimpleAlarmDaemonApplet()
11 : mApplet( 0 ), ref( 0 )
12{
13
14}
15
16SimpleAlarmDaemonApplet::~SimpleAlarmDaemonApplet()
17{
18 delete mApplet;
19}
20
21
22QWidget *SimpleAlarmDaemonApplet::applet( QWidget *parent )
23{
24 if ( !mApplet ) {
25 mApplet = new SimpleAlarmDaemonImpl( parent );
26 if ( QApplication::desktop()->width() < 480 )
27 mApplet->setPixmap( Resource::loadPixmap( "ko16" ) );
28 else
29 mApplet->setPixmap( Resource::loadPixmap( "ko24" ) );
30 QCopChannel* c = new QCopChannel("koalarm",mApplet , "channel" ) ;
31 QObject::connect( c, SIGNAL (received ( const QCString &, const QByteArray & )),mApplet, SLOT(recieve( const QCString&, const QByteArray& )));
32 mApplet->show();
33 }
34 return mApplet;
35}
36
37int SimpleAlarmDaemonApplet::position() const
38{
39 return 7;
40}
41
42QRESULT SimpleAlarmDaemonApplet::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
43{
44 *iface = 0;
45 if ( uuid == IID_QUnknown )
46 *iface = this;
47 else if ( uuid == IID_TaskbarApplet )
48 *iface = this;
49
50 if ( *iface )
51 (*iface)->addRef();
52 return QS_OK;
53}
54
55Q_EXPORT_INTERFACE()
56{
57 Q_CREATE_INSTANCE( SimpleAlarmDaemonApplet )
58}
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 @@
1#ifndef SIMPLEALARMDAEMONAPPLET_H
2#define SIMPLEALARMDAEMONAPPLET_H
3
4#include <qpe/taskbarappletinterface.h>
5
6class SimpleAlarmDaemonImpl;
7class ScreenshotApplet;
8
9class SimpleAlarmDaemonApplet : public TaskbarAppletInterface
10{
11 public:
12 SimpleAlarmDaemonApplet();
13 virtual ~SimpleAlarmDaemonApplet();
14
15 QRESULT queryInterface( const QUuid&, QUnknownInterface** );
16 Q_REFCOUNT
17
18 virtual QWidget *applet( QWidget *parent );
19 virtual int position() const;
20
21 private:
22 SimpleAlarmDaemonImpl *mApplet;
23 ulong ref;
24};
25
26#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 @@
1/*
2 This file is part of the KOrganizer alarm daemon.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24#include "simplealarmdaemonimpl.h"
25
26#include "alarmdialog.h"
27#include <qpopupmenu.h>
28#include <qapp.h>
29#include <qdir.h>
30#include <qfile.h>
31#include <qhbox.h>
32#include <qtimer.h>
33#include <qfile.h>
34#include <qlayout.h>
35#include <qlineedit.h>
36#include <qdialog.h>
37#include <qspinbox.h>
38#include <qtextstream.h>
39#include <qtopia/qcopenvelope_qws.h>
40#include <qtopia/alarmserver.h>
41
42#include <stdlib.h>
43#include <stdio.h>
44#include <unistd.h>
45
46
47SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent )
48 : QLabel( parent )
49{
50 mAlarmDialog = new AlarmDialog( 0 );
51 mPopUp = new QPopupMenu( 0 );
52 mPopUp->insertItem( "Addresses", this, SLOT ( showAdd() ) );
53 mPopUp->insertSeparator();
54 mPopUp->insertItem( "Multi Sync", this, SLOT ( ringSync() ) );
55 mPopUp->insertSeparator();
56 mPopUp->insertItem( "What's Next?", this, SLOT ( showWN() ) );
57 mPopUp->insertSeparator();
58 mPopUp->insertItem( "What's Todo?", this, SLOT ( showTodo() ) );
59 mPopUp->insertSeparator();
60 mPopUp->insertItem( "Next Days!", this, SLOT ( showKO() ) );
61 mPopUp->insertSeparator();
62 mPopUp->insertItem( "Edit Journal", this, SLOT ( writeJournal() ) );
63 mPopUp->insertSeparator();
64 mPopUp->insertItem( "New Event", this, SLOT ( newEvent() ) );
65 mPopUp->insertItem( "New Todo", this, SLOT ( newTodo() ) );
66 mTimerPopUp = new QPopupMenu( mPopUp );
67
68 mBeepPopUp = new QPopupMenu( mPopUp );
69 mSoundPopUp = new QPopupMenu( mBeepPopUp );
70 mPausePopUp = new QPopupMenu( mBeepPopUp );
71 QPopupMenu* savePopUp = new QPopupMenu( mBeepPopUp );
72 savePopUp->insertItem( "Save", 0 );
73 savePopUp->insertItem( "Load", 1 );
74 mSoundPopUp->insertItem( "Buzzer", 0 );
75 mSoundPopUp->insertItem( "Wav file", 1 );
76 mPausePopUp->insertItem( " 1 sec", 1 );
77 mPausePopUp->insertItem( " 2 sec", 2 );
78 mPausePopUp->insertItem( " 3 sec", 3 );
79 mPausePopUp->insertItem( " 5 sec", 5 );
80 mPausePopUp->insertItem( "10 sec", 10 );
81 mPausePopUp->insertItem( "30 sec", 30 );
82 mPausePopUp->insertItem( " 1 min", 60 );
83 mPausePopUp->insertItem( " 5 min", 300 );
84 mPausePopUp->insertItem( "10 min", 600 );
85 mSuspendPopUp = new QPopupMenu( mBeepPopUp );
86 mSuspendPopUp->insertItem( "Off", 0 );
87 mSuspendPopUp->insertItem( " 1x", 1 );
88 mSuspendPopUp->insertItem( " 2x", 2 );
89 mSuspendPopUp->insertItem( " 3x", 3 );
90 mSuspendPopUp->insertItem( " 5x", 5 );
91 mSuspendPopUp->insertItem( "10x", 10 );
92 mSuspendPopUp->insertItem( "20x", 20 );
93 mSuspendPopUp->insertItem( "30x", 30 );
94 mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp );
95 mBeepPopUp->insertItem( "Beep interval",mPausePopUp );
96 mBeepPopUp->insertItem( "Replay",mSoundPopUp );
97 mBeepPopUp->insertItem( "Config",savePopUp );
98 mBeepPopUp->insertItem( "300", 300 );
99 mBeepPopUp->insertItem( "180", 180 );
100 mBeepPopUp->insertItem( "60", 60 );
101 mBeepPopUp->insertItem( "30", 30 );
102 mBeepPopUp->insertItem( "10", 10 );
103 mBeepPopUp->insertItem( "3", 3 );
104 mBeepPopUp->insertItem( "1", 1 );
105 mBeepPopUp->insertItem( "Off", 0 );
106 mBeepPopUp->setCheckable( true );
107 mPopUp->insertSeparator();
108 mPopUp->insertItem( "Play beeps", mBeepPopUp );
109 mPopUp->insertSeparator();
110 mPopUp->insertItem( "Timer", mTimerPopUp );
111 mPopUp->insertSeparator();
112 mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) );
113
114 mPopUp->resize( mPopUp->sizeHint() );
115 mPlayBeeps = 60;
116 mBeepPopUp->setItemChecked ( mPlayBeeps, true );
117 connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) );
118 connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) );
119 connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) );
120 connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) );
121 connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) );
122 connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) );
123 connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) );
124 mTimerTime = 0;
125 mCustomText = "Custom Text";
126 mCustomMinutes = 7;
127 mTimerPopupConf = 1;
128 fillTimerPopUp();
129 mPausePlay = 0;
130 confPause( 1 );
131 mSuspend = 0;
132 confSuspend( 0 );
133 if ( QApplication::desktop()->width() < 480 ) {
134 wavAlarm = false;
135 mSoundPopUp->setItemChecked ( 0, true );
136 }
137 else {
138 wavAlarm = true;
139 mSoundPopUp->setItemChecked ( 1, true );
140 }
141 saveSlot( 1 );
142}
143
144SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl()
145{
146 delete mPopUp;
147 delete mAlarmDialog;
148}
149void SimpleAlarmDaemonImpl::saveSlot( int load )
150{
151 QString fileName = QDir::homeDirPath() +"/.kopialarmrc";
152 //qDebug("save %d ", load );
153 QFile file( fileName );
154 if ( load ) {
155 if( !QFile::exists( fileName) )
156 return;
157 if (!file.open( IO_ReadOnly ) ) {
158 return ;
159 }
160 QString line;
161 bool ok;
162 int val;
163 int len;
164 while ( file.readLine( line, 1024 ) > 0 ) {
165 //qDebug("read %s ", line.latin1());
166 len = line.length();
167 if ( line.left(4 ) == "PPAU" ) {
168 val = line.mid( 4,len-5).toInt( &ok );
169 if ( ok ) {
170 confPause( val );
171 }
172 }
173 if ( line.left(4 ) == "SUCO" ) {
174 val = line.mid( 4,len-5).toInt( &ok );
175 if ( ok )
176 confSuspend ( val );
177 }
178 if ( line.left(4 ) == "WAAL" ) {
179 val = line.mid( 4,len-5).toInt( &ok );
180 if ( ok )
181 confSound( val );
182
183 }
184 if ( line.left(4 ) == "PLBE" ) {
185 val = line.mid( 4,len-5).toInt( &ok );
186 if ( ok )
187 slotPlayBeep( val );
188
189 }
190 if ( line.left(4 ) == "CUTE" ) {
191 mCustomText = line.mid( 5,len-6);
192 // qDebug("text ***%s*** ",mCustomText.latin1() );
193
194 }
195 if ( line.left(4 ) == "CUMI" ) {
196 val = line.mid( 4,len-5).toInt( &ok );
197 if ( ok )
198 mCustomMinutes = val;
199
200 }
201 if ( line.left(4 ) == "SUTI" ) {
202 val = line.mid( 4,len-5).toInt( &ok );
203 if ( ok )
204 mAlarmDialog->setSuspendTime( val );;
205
206 }
207 }
208 file.close();
209 } else {
210 if (!file.open( IO_WriteOnly ) ) {
211 return;
212 }
213 QString configString ;
214 configString += "PPAU " + QString::number( mPausePlay ) + "\n";
215 configString += "SUCO " + QString::number( mSuspend ) + "\n";
216 configString += "WAAL " + QString::number( wavAlarm ) + "\n";
217 configString += "PLBE " + QString::number( mPlayBeeps ) + "\n";
218 configString += "CUTE " + mCustomText + "\n";
219 configString += "CUMI " + QString::number( mCustomMinutes ) + "\n";
220 configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n";
221 QTextStream ts( &file );
222 ts << configString ;
223 file.close();
224 }
225
226}
227void SimpleAlarmDaemonImpl::confSuspend( int num )
228{
229 mSuspendPopUp->setItemChecked ( mSuspend,false );
230 mSuspend = num;
231 mSuspendPopUp->setItemChecked ( mSuspend,true );
232}
233void SimpleAlarmDaemonImpl::confPause( int num )
234{
235 mPausePopUp->setItemChecked ( mPausePlay,false );
236 mPausePlay = num;
237 mPausePopUp->setItemChecked ( mPausePlay,true );
238}
239void SimpleAlarmDaemonImpl::confSound( int num )
240{
241 if ( num == 0 ) {
242 wavAlarm = false;
243 mSoundPopUp->setItemChecked ( 0, true );
244 mSoundPopUp->setItemChecked ( 1, false );
245 } else {
246 wavAlarm = true;
247 mSoundPopUp->setItemChecked ( 0, false );
248 mSoundPopUp->setItemChecked ( 1, true );
249 }
250}
251void SimpleAlarmDaemonImpl::slotPlayBeep( int num )
252{
253 mBeepPopUp->setItemChecked ( mPlayBeeps,false );
254 mPlayBeeps = num;
255 mBeepPopUp->setItemChecked ( mPlayBeeps, true );
256}
257
258void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& )
259{
260 //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data());
261 QString mess = msg;
262 mAlarmMessage = mess.mid( 9 );
263 QString filename = getenv("QPEDIR") ;
264 filename += "/pics/kdepim/korganizer/koalarm.wav";
265 QString tempfilename;
266 if ( mess.left( 13 ) == "suspend_alarm") {
267 bool error = false;
268 int len = mess.mid( 13 ).find("+++");
269 if ( len < 2 )
270 error = true;
271 else {
272 tempfilename = mess.mid( 13, len );
273 if ( !QFile::exists( tempfilename ) )
274 error = true;
275 }
276 if ( ! error ) {
277 filename = tempfilename;
278 }
279 mAlarmMessage = mess.mid( 13+len+3 );
280 //qDebug("suspend file %s ",tempfilename.latin1() );
281 startAlarm( mAlarmMessage, filename);
282 return;
283 }
284 if ( mess.left( 11 ) == "timer_alarm") {
285 mTimerTime = 0;
286 startAlarm( mess.mid( 11 ), filename );
287 return;
288 }
289 if ( mess.left( 10 ) == "proc_alarm") {
290 bool error = false;
291 int len = mess.mid( 10 ).find("+++");
292 if ( len < 2 )
293 error = true;
294 else {
295 tempfilename = mess.mid( 10, len );
296 if ( !QFile::exists( tempfilename ) )
297 error = true;
298 }
299 if ( error ) {
300 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
301 mAlarmMessage += mess.mid( 10+len+3+9 );
302 } else {
303 QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
304 //qDebug("-----system command %s ",tempfilename.latin1() );
305 if ( vfork () == 0 ) {
306 execl ( tempfilename.latin1(), 0 );
307 return;
308 }
309 return;
310 }
311
312 //qDebug("+++++++system command %s ",tempfilename.latin1() );
313 }
314 if ( mess.left( 11 ) == "audio_alarm") {
315 bool error = false;
316 int len = mess.mid( 11 ).find("+++");
317 if ( len < 2 )
318 error = true;
319 else {
320 tempfilename = mess.mid( 11, len );
321 if ( !QFile::exists( tempfilename ) )
322 error = true;
323 }
324 if ( ! error ) {
325 filename = tempfilename;
326 }
327 mAlarmMessage = mess.mid( 11+len+3+9 );
328 //qDebug("audio file command %s ",tempfilename.latin1() );
329 }
330 if ( mess.left( 9 ) == "cal_alarm") {
331 mAlarmMessage = mess.mid( 9 ) ;
332 }
333
334 writeFile();
335 startAlarm( mAlarmMessage, filename );
336
337}
338
339int SimpleAlarmDaemonImpl::getFileNameLen( QString mess )
340{
341 return 0;
342}
343void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename )
344{
345 //mAlarmDialog->show();
346 //mAlarmDialog->raise();
347 mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend );
348}
349
350
351void SimpleAlarmDaemonImpl::fillTimerPopUp()
352{
353
354 // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime );
355 if ( mTimerPopupConf == mTimerTime ) {
356 if ( mTimerTime ) {
357 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer );
358 QTime t ( secs/3600, (secs/60)%60, secs%60 );
359 mTimerPopUp->changeItem ( 1 , t.toString());
360 }
361 else {
362 QString text = mCustomText.stripWhiteSpace ();
363 int in = text.find( " " );
364 text = text.left ( in );
365 mTimerPopUp->changeItem ( 3, text );
366 }
367 return;
368 }
369 mTimerPopupConf = mTimerTime;
370 mTimerPopUp->clear();
371 if ( mTimerTime ) {
372 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer );
373 QTime t ( secs/3600, (secs/60)%60, secs%60 );
374 mTimerPopUp->insertItem( "Stop", 0 );
375 mTimerPopUp->insertItem( t.toString(),1);
376 } else {
377 mTimerPopUp->insertItem( "24 h", 1440 );
378 // mTimerPopUp->insertItem( i18n("12 h"), 720 );
379 mTimerPopUp->insertItem( " 8 h", 480 );
380 mTimerPopUp->insertItem( " 5 h", 300 );
381 // mTimerPopUp->insertItem( i18n(" 2 h"), 120 );
382 mTimerPopUp->insertItem( " 1 h", 60 );
383 mTimerPopUp->insertItem( "30 min", 30 );
384 mTimerPopUp->insertItem( "15 min", 15 );
385 mTimerPopUp->insertItem( "10 min", 10 );
386 //mTimerPopUp->insertItem( " 5 min", 5 );
387 mTimerPopUp->insertSeparator();
388 mTimerPopUp->insertItem( "Pizza", 22 );
389 mTimerPopUp->insertItem( "Nap", 45 );
390 mTimerPopUp->insertItem( "Tea", 5 );
391 QString text = mCustomText.stripWhiteSpace ();
392 int in = text.find( " " );
393 text = text.left ( in );
394 mTimerPopUp->insertItem( text, 3 );
395 mTimerPopUp->insertSeparator();
396 mTimerPopUp->insertItem( "Customize", 2 );
397 }
398
399}
400
401void SimpleAlarmDaemonImpl::showTimer()
402{
403 fillTimerPopUp();
404}
405
406void SimpleAlarmDaemonImpl::confTimer( int time )
407{
408 //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time );
409 int minutes = time;
410 if ( minutes == 0 ) {
411 if ( ! mTimerTime )
412 return;
413
414 QDialog dia ( 0, ("Stop Timer" ), true );
415 QLabel lab (("Really stop the timer?"), &dia );
416 dia.setCaption(("KO/Pi Timer Stop" ));
417 QVBoxLayout lay( &dia );
418 lay.setMargin(5);
419 lay.setSpacing(5);
420 lay.addWidget( &lab);
421 dia.resize( 200, dia.sizeHint().height() );
422
423 if ( !dia.exec() )
424 return;
425
426 AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.latin1() );
427 mTimerTime = 0;
428 return;
429 }
430 if ( mTimerTime )
431 return;
432 if ( minutes == 1 ) {
433 return;
434 }
435 QString mess = "timer_alarm";
436 mess += ("Timer Alarm!\n");
437 if ( minutes == 22 )
438 mess += ( "Pizza is ready");
439 else if ( minutes == 45 )
440 mess += ( "Please wake up!");
441 else if ( minutes == 5 )
442 mess += ( "Tea is ready");
443 else if ( minutes == 3 ) {
444 mess += mCustomText;
445 minutes = mCustomMinutes ;
446 }
447 else {
448 if ( minutes == 2 ) {
449 // ask time
450 QDialog dia ( 0, ("Customize Timer" ), true );
451 QLabel lab (("Message Text:"), &dia );
452 dia.setCaption(("KO/Pi Timer" ));
453 QVBoxLayout lay( &dia );
454 lay.setMargin(5);
455 lay.setSpacing(5);
456 lay.addWidget( &lab);
457 QLineEdit lEdit( mCustomText, &dia );
458 lay.addWidget( &lEdit);
459 QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia );
460 lay.addWidget( &lab2);
461 QHBox hbox ( &dia );
462 QLabel lab3 (("h:"), &hbox );
463 QSpinBox spinh( 0, 24, 1,& hbox );
464 QLabel lab4 ((" min:"), &hbox );
465 QSpinBox spinm( 0, 59, 1,&hbox );
466 spinh.setValue( mCustomMinutes/60 );
467 spinm.setValue( mCustomMinutes%60 );
468 lay.addWidget( &hbox);
469 dia.resize( dia.sizeHint().width(), dia.sizeHint().height() );
470 if ( !dia.exec() )
471 return;
472 mCustomText = lEdit.text();
473 mCustomMinutes = spinh.value()*60+spinm.value();
474 if ( mCustomMinutes == 0 )
475 mCustomMinutes = 1;
476 if ( mCustomMinutes > 1440 )
477 mCustomMinutes = 1440;
478 mess += mCustomText;
479 minutes = mCustomMinutes;
480 }
481 else
482 mess+= QString::number ( minutes ) + ( " minutes are past!");
483 }
484 //minutes = 1;
485 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 );
486 timerMesssage = mess;
487 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.latin1());
488 mTimerTime = 1;
489}
490
491void SimpleAlarmDaemonImpl::writeFile()
492{
493 QCopEnvelope e("QPE/Application/kopi", "-writeFile");
494}
495void SimpleAlarmDaemonImpl::showWN()
496{
497 QCopEnvelope e("QPE/Application/kopi", "-showWN");
498}
499void SimpleAlarmDaemonImpl::newTodo()
500{
501 QCopEnvelope e("QPE/Application/kopi", "-newTodo");
502}
503
504void SimpleAlarmDaemonImpl::newEvent()
505{
506 QCopEnvelope e("QPE/Application/kopi", "-newEvent");
507
508}
509
510void SimpleAlarmDaemonImpl::showAdd()
511{
512 QCopEnvelope e("QPE/Application/kapi", " ");
513}
514void SimpleAlarmDaemonImpl::ringSync()
515{
516 QCopEnvelope e("QPE/Application/kopi", "-ringSync");
517
518}
519void SimpleAlarmDaemonImpl::newCountdown()
520{
521 //recieve("cal_alarm", 10 );
522}
523void SimpleAlarmDaemonImpl::simulate()
524{
525 writeFile();
526 QString filename = getenv("QPEDIR") ;
527 filename += "/pics/kdepim/korganizer/koalarm.wav";
528 startAlarm("Alarm simulation", filename );
529}
530void SimpleAlarmDaemonImpl::showKO()
531{
532 QCopEnvelope e("QPE/Application/kopi", "-showKO");
533
534}
535void SimpleAlarmDaemonImpl::showTodo()
536{
537 QCopEnvelope e("QPE/Application/kopi", "-showTodo");
538
539}
540void SimpleAlarmDaemonImpl::writeJournal()
541{
542 QCopEnvelope e("QPE/Application/kopi", "-showJournal");
543
544}
545
546void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * )
547{
548
549 mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() )));
550
551}
552
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 @@
1/*
2 This file is part of the KOrganizer alarm daemon.
3 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23#ifndef SIMPLEALARMDAEMONIMPL_H
24#define SIMPLEALARMDAEMONIMPL_H
25
26//#include "simplealarmdaemon.h"
27#include <qdatetime.h>
28#include <qlabel.h>
29
30class QLabel;
31class QTimer;
32class QPopupMenu;
33class AlarmDialog;
34class SimpleAlarmDaemonImpl : public QLabel
35{
36 Q_OBJECT
37 public:
38 SimpleAlarmDaemonImpl( QWidget *parent = 0 );
39
40 ~SimpleAlarmDaemonImpl();
41
42 protected slots:
43 void recieve( const QCString& msg, const QByteArray& data );
44 void newTodo();
45 void newEvent();
46 void newCountdown();
47 void simulate();
48 void showKO();
49 void showWN();
50 void showAdd();
51 void ringSync();
52 void showTodo();
53 void writeFile();
54 void writeJournal();
55 void slotPlayBeep( int );
56 void showTimer( );
57 void confPause( int );
58 void confTimer( int );
59 void saveSlot( int );
60 void confSuspend( int );
61 void confSound( int num );
62 void startAlarm(QString mess, QString fn );
63
64 protected:
65 void mousePressEvent( QMouseEvent * );
66
67 private:
68 AlarmDialog *mAlarmDialog;
69 int mPlayBeeps;
70 int mPausePlay;
71 int mSuspend;
72 QString mAlarmMessage;
73 int mTimerTime;
74 int getFileNameLen( QString );
75 QPopupMenu* mPopUp, *mBeepPopUp, *mTimerPopUp, *mSoundPopUp,*mPausePopUp,*mSuspendPopUp;
76 QDateTime mRunningTimer;
77 void fillTimerPopUp();
78 QString timerMesssage;
79 QString mCustomText;
80 int mCustomMinutes;
81 int mTimerPopupConf;
82 bool wavAlarm;
83};
84
85#endif