summaryrefslogtreecommitdiffabout
path: root/kalarmd/simplealarmdaemonimpl.cpp
Unidiff
Diffstat (limited to 'kalarmd/simplealarmdaemonimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kalarmd/simplealarmdaemonimpl.cpp8
1 files changed, 0 insertions, 8 deletions
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp
index 2acfacf..a0ac232 100644
--- a/kalarmd/simplealarmdaemonimpl.cpp
+++ b/kalarmd/simplealarmdaemonimpl.cpp
@@ -1,682 +1,674 @@
1/* 1/*
2 This file is part of the KOrganizer alarm daemon. 2 This file is part of the KOrganizer alarm daemon.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 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 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 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 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 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. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include "simplealarmdaemonimpl.h" 24#include "simplealarmdaemonimpl.h"
25 25
26#include "alarmdialog.h" 26#include "alarmdialog.h"
27#include <qpopupmenu.h> 27#include <qpopupmenu.h>
28#include <qapp.h> 28#include <qapp.h>
29#include <qdir.h> 29#include <qdir.h>
30#include <qfile.h> 30#include <qfile.h>
31#include <qhbox.h> 31#include <qhbox.h>
32#include <qtimer.h> 32#include <qtimer.h>
33#include <qfile.h> 33#include <qfile.h>
34#include <qdatetime.h> 34#include <qdatetime.h>
35#include <qpushbutton.h> 35#include <qpushbutton.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qlineedit.h> 37#include <qlineedit.h>
38#include <qdialog.h> 38#include <qdialog.h>
39#define protected public 39#define protected public
40#include <qspinbox.h> 40#include <qspinbox.h>
41#undef protected 41#undef protected
42#include <qtextstream.h> 42#include <qtextstream.h>
43#include <qtopia/qcopenvelope_qws.h> 43#include <qtopia/qcopenvelope_qws.h>
44#include <qtopia/alarmserver.h> 44#include <qtopia/alarmserver.h>
45 45
46#include <stdlib.h> 46#include <stdlib.h>
47#include <stdio.h> 47#include <stdio.h>
48#include <unistd.h> 48#include <unistd.h>
49 49
50 50
51SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent ) 51SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent )
52 : QLabel( parent ) 52 : QLabel( parent )
53{ 53{
54 mAlarmDialog = new AlarmDialog( 0 ); 54 mAlarmDialog = new AlarmDialog( 0 );
55 mPopUp = new QPopupMenu( this ); 55 mPopUp = new QPopupMenu( this );
56 mPopUp->insertItem( "What's Next?", this, SLOT ( showWN() ) ); 56 mPopUp->insertItem( "What's Next?", this, SLOT ( showWN() ) );
57 mPopUp->insertItem( "Next Days!", this, SLOT ( showKO() ) ); 57 mPopUp->insertItem( "Next Days!", this, SLOT ( showKO() ) );
58 mPopUp->insertSeparator(); 58 mPopUp->insertSeparator();
59 mPopUp->insertItem( "Todo List", this, SLOT ( showTodo() ) ); 59 mPopUp->insertItem( "Todo List", this, SLOT ( showTodo() ) );
60 mPopUp->insertSeparator(); 60 mPopUp->insertSeparator();
61 mPopUp->insertItem( "Addresses", this, SLOT ( showAdd() ) ); 61 mPopUp->insertItem( "Addresses", this, SLOT ( showAdd() ) );
62 mPopUp->insertSeparator(); 62 mPopUp->insertSeparator();
63 mPopUp->insertItem( "Edit Journal", this, SLOT ( writeJournal() ) ); 63 mPopUp->insertItem( "Edit Journal", this, SLOT ( writeJournal() ) );
64 mPopUp->insertItem( "New Event", this, SLOT ( newEvent() ) ); 64 mPopUp->insertItem( "New Event", this, SLOT ( newEvent() ) );
65 mPopUp->insertItem( "New Todo", this, SLOT ( newTodo() ) ); 65 mPopUp->insertItem( "New Todo", this, SLOT ( newTodo() ) );
66 mPopUp->insertItem( "New Mail", this, SLOT ( newMail() ) ); 66 mPopUp->insertItem( "New Mail", this, SLOT ( newMail() ) );
67 mPopUp->insertSeparator(); 67 mPopUp->insertSeparator();
68 mPopUp->insertItem( "Multi Sync", this, SLOT ( ringSync() ) ); 68 mPopUp->insertItem( "Multi Sync", this, SLOT ( ringSync() ) );
69 mTimerPopUp = new QPopupMenu( this ); 69 mTimerPopUp = new QPopupMenu( this );
70 QFont fon = mTimerPopUp->font();
71 int points = 16;
72 if ( QApplication::desktop()->width() < 480 )
73 points = 12;
74 fon.setPointSize( points );
75 //qDebug("point s %d ", fon.pointSize());
76 mTimerPopUp->setFont( fon );
77 mPopUp->setFont( fon );
78 mBeepPopUp = new QPopupMenu( this ); 70 mBeepPopUp = new QPopupMenu( this );
79 mSoundPopUp = new QPopupMenu( this ); 71 mSoundPopUp = new QPopupMenu( this );
80 mPausePopUp = new QPopupMenu( this ); 72 mPausePopUp = new QPopupMenu( this );
81 QPopupMenu* savePopUp = new QPopupMenu( this ); 73 QPopupMenu* savePopUp = new QPopupMenu( this );
82 savePopUp->insertItem( "Save", 0 ); 74 savePopUp->insertItem( "Save", 0 );
83 savePopUp->insertItem( "Load", 1 ); 75 savePopUp->insertItem( "Load", 1 );
84 mSoundPopUp->insertItem( "Buzzer", 0 ); 76 mSoundPopUp->insertItem( "Buzzer", 0 );
85 mSoundPopUp->insertItem( "Wav file", 1 ); 77 mSoundPopUp->insertItem( "Wav file", 1 );
86 mPausePopUp->insertItem( " 1 sec", 1 ); 78 mPausePopUp->insertItem( " 1 sec", 1 );
87 mPausePopUp->insertItem( " 2 sec", 2 ); 79 mPausePopUp->insertItem( " 2 sec", 2 );
88 mPausePopUp->insertItem( " 3 sec", 3 ); 80 mPausePopUp->insertItem( " 3 sec", 3 );
89 mPausePopUp->insertItem( " 5 sec", 5 ); 81 mPausePopUp->insertItem( " 5 sec", 5 );
90 mPausePopUp->insertItem( "10 sec", 10 ); 82 mPausePopUp->insertItem( "10 sec", 10 );
91 mPausePopUp->insertItem( "30 sec", 30 ); 83 mPausePopUp->insertItem( "30 sec", 30 );
92 mPausePopUp->insertItem( " 1 min", 60 ); 84 mPausePopUp->insertItem( " 1 min", 60 );
93 mPausePopUp->insertItem( " 5 min", 300 ); 85 mPausePopUp->insertItem( " 5 min", 300 );
94 mPausePopUp->insertItem( "10 min", 600 ); 86 mPausePopUp->insertItem( "10 min", 600 );
95 mSuspendPopUp = new QPopupMenu( this ); 87 mSuspendPopUp = new QPopupMenu( this );
96 mSuspendPopUp->insertItem( "Off", 0 ); 88 mSuspendPopUp->insertItem( "Off", 0 );
97 mSuspendPopUp->insertItem( " 1x", 1 ); 89 mSuspendPopUp->insertItem( " 1x", 1 );
98 mSuspendPopUp->insertItem( " 2x", 2 ); 90 mSuspendPopUp->insertItem( " 2x", 2 );
99 mSuspendPopUp->insertItem( " 3x", 3 ); 91 mSuspendPopUp->insertItem( " 3x", 3 );
100 mSuspendPopUp->insertItem( " 5x", 5 ); 92 mSuspendPopUp->insertItem( " 5x", 5 );
101 mSuspendPopUp->insertItem( "10x", 10 ); 93 mSuspendPopUp->insertItem( "10x", 10 );
102 mSuspendPopUp->insertItem( "20x", 20 ); 94 mSuspendPopUp->insertItem( "20x", 20 );
103 mSuspendPopUp->insertItem( "30x", 30 ); 95 mSuspendPopUp->insertItem( "30x", 30 );
104 mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp ); 96 mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp );
105 mBeepPopUp->insertItem( "Beep interval",mPausePopUp ); 97 mBeepPopUp->insertItem( "Beep interval",mPausePopUp );
106 mBeepPopUp->insertItem( "Replay",mSoundPopUp ); 98 mBeepPopUp->insertItem( "Replay",mSoundPopUp );
107 mBeepPopUp->insertItem( "Config",savePopUp ); 99 mBeepPopUp->insertItem( "Config",savePopUp );
108 mBeepPopUp->insertItem( "300", 300 ); 100 mBeepPopUp->insertItem( "300", 300 );
109 mBeepPopUp->insertItem( "180", 180 ); 101 mBeepPopUp->insertItem( "180", 180 );
110 mBeepPopUp->insertItem( "60", 60 ); 102 mBeepPopUp->insertItem( "60", 60 );
111 mBeepPopUp->insertItem( "30", 30 ); 103 mBeepPopUp->insertItem( "30", 30 );
112 mBeepPopUp->insertItem( "10", 10 ); 104 mBeepPopUp->insertItem( "10", 10 );
113 mBeepPopUp->insertItem( "3", 3 ); 105 mBeepPopUp->insertItem( "3", 3 );
114 mBeepPopUp->insertItem( "1", 1 ); 106 mBeepPopUp->insertItem( "1", 1 );
115 mBeepPopUp->insertItem( "Off", 0 ); 107 mBeepPopUp->insertItem( "Off", 0 );
116 mBeepPopUp->insertSeparator(); 108 mBeepPopUp->insertSeparator();
117 mBeepPopUp->insertItem( "Simulate", 1000 ); 109 mBeepPopUp->insertItem( "Simulate", 1000 );
118 mBeepPopUp->setCheckable( true ); 110 mBeepPopUp->setCheckable( true );
119 mPopUp->insertSeparator(); 111 mPopUp->insertSeparator();
120 mPopUp->insertItem( "Play beeps", mBeepPopUp ); 112 mPopUp->insertItem( "Play beeps", mBeepPopUp );
121 mPopUp->insertSeparator(); 113 mPopUp->insertSeparator();
122 mPopUp->insertItem( "Timer", mTimerPopUp ); 114 mPopUp->insertItem( "Timer", mTimerPopUp );
123 //mPopUp->insertSeparator(); 115 //mPopUp->insertSeparator();
124 //mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) ); 116 //mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) );
125 117
126 mPopUp->resize( mPopUp->sizeHint() ); 118 mPopUp->resize( mPopUp->sizeHint() );
127 mPlayBeeps = 60; 119 mPlayBeeps = 60;
128 mBeepPopUp->setItemChecked ( mPlayBeeps, true ); 120 mBeepPopUp->setItemChecked ( mPlayBeeps, true );
129 connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) ); 121 connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) );
130 connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) ); 122 connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) );
131 connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) ); 123 connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) );
132 connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) ); 124 connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) );
133 connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) ); 125 connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) );
134 connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) ); 126 connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) );
135 connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) ); 127 connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) );
136 mTimerTime = 0; 128 mTimerTime = 0;
137 mCustomText = "Custom Text"; 129 mCustomText = "Custom Text";
138 mCustomMinutes = 7; 130 mCustomMinutes = 7;
139 mTimerPopupConf = 1; 131 mTimerPopupConf = 1;
140 fillTimerPopUp(); 132 fillTimerPopUp();
141 mPausePlay = 0; 133 mPausePlay = 0;
142 confPause( 1 ); 134 confPause( 1 );
143 mSuspend = 0; 135 mSuspend = 0;
144 confSuspend( 0 ); 136 confSuspend( 0 );
145 if ( QApplication::desktop()->width() < 480 ) { 137 if ( QApplication::desktop()->width() < 480 ) {
146 wavAlarm = false; 138 wavAlarm = false;
147 mSoundPopUp->setItemChecked ( 0, true ); 139 mSoundPopUp->setItemChecked ( 0, true );
148 } 140 }
149 else { 141 else {
150 wavAlarm = true; 142 wavAlarm = true;
151 mSoundPopUp->setItemChecked ( 1, true ); 143 mSoundPopUp->setItemChecked ( 1, true );
152 } 144 }
153 saveSlot( 1 ); 145 saveSlot( 1 );
154} 146}
155 147
156SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl() 148SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl()
157{ 149{
158 //delete mPopUp; 150 //delete mPopUp;
159 delete mAlarmDialog; 151 delete mAlarmDialog;
160} 152}
161void SimpleAlarmDaemonImpl::saveSlot( int load ) 153void SimpleAlarmDaemonImpl::saveSlot( int load )
162{ 154{
163 QString fileName = QDir::homeDirPath() +"/.kopialarmrc"; 155 QString fileName = QDir::homeDirPath() +"/.kopialarmrc";
164 //qDebug("save %d ", load ); 156 //qDebug("save %d ", load );
165 QFile file( fileName ); 157 QFile file( fileName );
166 if ( load ) { 158 if ( load ) {
167 if( !QFile::exists( fileName) ) 159 if( !QFile::exists( fileName) )
168 return; 160 return;
169 if (!file.open( IO_ReadOnly ) ) { 161 if (!file.open( IO_ReadOnly ) ) {
170 return ; 162 return ;
171 } 163 }
172 QString line; 164 QString line;
173 bool ok; 165 bool ok;
174 int val; 166 int val;
175 int len; 167 int len;
176 while ( file.readLine( line, 1024 ) > 0 ) { 168 while ( file.readLine( line, 1024 ) > 0 ) {
177 //qDebug("read %s ", line.latin1()); 169 //qDebug("read %s ", line.latin1());
178 len = line.length(); 170 len = line.length();
179 if ( line.left(4 ) == "PPAU" ) { 171 if ( line.left(4 ) == "PPAU" ) {
180 val = line.mid( 4,len-5).toInt( &ok ); 172 val = line.mid( 4,len-5).toInt( &ok );
181 if ( ok ) { 173 if ( ok ) {
182 confPause( val ); 174 confPause( val );
183 } 175 }
184 } 176 }
185 if ( line.left(4 ) == "SUCO" ) { 177 if ( line.left(4 ) == "SUCO" ) {
186 val = line.mid( 4,len-5).toInt( &ok ); 178 val = line.mid( 4,len-5).toInt( &ok );
187 if ( ok ) 179 if ( ok )
188 confSuspend ( val ); 180 confSuspend ( val );
189 } 181 }
190 if ( line.left(4 ) == "WAAL" ) { 182 if ( line.left(4 ) == "WAAL" ) {
191 val = line.mid( 4,len-5).toInt( &ok ); 183 val = line.mid( 4,len-5).toInt( &ok );
192 if ( ok ) 184 if ( ok )
193 confSound( val ); 185 confSound( val );
194 186
195 } 187 }
196 if ( line.left(4 ) == "PLBE" ) { 188 if ( line.left(4 ) == "PLBE" ) {
197 val = line.mid( 4,len-5).toInt( &ok ); 189 val = line.mid( 4,len-5).toInt( &ok );
198 if ( ok ) 190 if ( ok )
199 slotPlayBeep( val ); 191 slotPlayBeep( val );
200 192
201 } 193 }
202 if ( line.left(4 ) == "CUTE" ) { 194 if ( line.left(4 ) == "CUTE" ) {
203 mCustomText = line.mid( 5,len-6); 195 mCustomText = line.mid( 5,len-6);
204 // qDebug("text ***%s*** ",mCustomText.latin1() ); 196 // qDebug("text ***%s*** ",mCustomText.latin1() );
205 197
206 } 198 }
207 if ( line.left(4 ) == "CUMI" ) { 199 if ( line.left(4 ) == "CUMI" ) {
208 val = line.mid( 4,len-5).toInt( &ok ); 200 val = line.mid( 4,len-5).toInt( &ok );
209 if ( ok ) 201 if ( ok )
210 mCustomMinutes = val; 202 mCustomMinutes = val;
211 203
212 } 204 }
213 if ( line.left(4 ) == "SUTI" ) { 205 if ( line.left(4 ) == "SUTI" ) {
214 val = line.mid( 4,len-5).toInt( &ok ); 206 val = line.mid( 4,len-5).toInt( &ok );
215 if ( ok ) 207 if ( ok )
216 mAlarmDialog->setSuspendTime( val );; 208 mAlarmDialog->setSuspendTime( val );;
217 209
218 } 210 }
219 } 211 }
220 file.close(); 212 file.close();
221 } else { 213 } else {
222 if (!file.open( IO_WriteOnly ) ) { 214 if (!file.open( IO_WriteOnly ) ) {
223 return; 215 return;
224 } 216 }
225 QString configString ; 217 QString configString ;
226 configString += "PPAU " + QString::number( mPausePlay ) + "\n"; 218 configString += "PPAU " + QString::number( mPausePlay ) + "\n";
227 configString += "SUCO " + QString::number( mSuspend ) + "\n"; 219 configString += "SUCO " + QString::number( mSuspend ) + "\n";
228 configString += "WAAL " + QString::number( wavAlarm ) + "\n"; 220 configString += "WAAL " + QString::number( wavAlarm ) + "\n";
229 configString += "PLBE " + QString::number( mPlayBeeps ) + "\n"; 221 configString += "PLBE " + QString::number( mPlayBeeps ) + "\n";
230 configString += "CUTE " + mCustomText + "\n"; 222 configString += "CUTE " + mCustomText + "\n";
231 configString += "CUMI " + QString::number( mCustomMinutes ) + "\n"; 223 configString += "CUMI " + QString::number( mCustomMinutes ) + "\n";
232 configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n"; 224 configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n";
233 QTextStream ts( &file ); 225 QTextStream ts( &file );
234 ts << configString ; 226 ts << configString ;
235 file.close(); 227 file.close();
236 } 228 }
237 229
238} 230}
239void SimpleAlarmDaemonImpl::confSuspend( int num ) 231void SimpleAlarmDaemonImpl::confSuspend( int num )
240{ 232{
241 mSuspendPopUp->setItemChecked ( mSuspend,false ); 233 mSuspendPopUp->setItemChecked ( mSuspend,false );
242 mSuspend = num; 234 mSuspend = num;
243 mSuspendPopUp->setItemChecked ( mSuspend,true ); 235 mSuspendPopUp->setItemChecked ( mSuspend,true );
244} 236}
245void SimpleAlarmDaemonImpl::confPause( int num ) 237void SimpleAlarmDaemonImpl::confPause( int num )
246{ 238{
247 mPausePopUp->setItemChecked ( mPausePlay,false ); 239 mPausePopUp->setItemChecked ( mPausePlay,false );
248 mPausePlay = num; 240 mPausePlay = num;
249 mPausePopUp->setItemChecked ( mPausePlay,true ); 241 mPausePopUp->setItemChecked ( mPausePlay,true );
250} 242}
251void SimpleAlarmDaemonImpl::confSound( int num ) 243void SimpleAlarmDaemonImpl::confSound( int num )
252{ 244{
253 if ( num == 0 ) { 245 if ( num == 0 ) {
254 wavAlarm = false; 246 wavAlarm = false;
255 mSoundPopUp->setItemChecked ( 0, true ); 247 mSoundPopUp->setItemChecked ( 0, true );
256 mSoundPopUp->setItemChecked ( 1, false ); 248 mSoundPopUp->setItemChecked ( 1, false );
257 } else { 249 } else {
258 wavAlarm = true; 250 wavAlarm = true;
259 mSoundPopUp->setItemChecked ( 0, false ); 251 mSoundPopUp->setItemChecked ( 0, false );
260 mSoundPopUp->setItemChecked ( 1, true ); 252 mSoundPopUp->setItemChecked ( 1, true );
261 } 253 }
262} 254}
263void SimpleAlarmDaemonImpl::slotPlayBeep( int num ) 255void SimpleAlarmDaemonImpl::slotPlayBeep( int num )
264{ 256{
265 if ( num == 1000 ) { 257 if ( num == 1000 ) {
266 simulate(); 258 simulate();
267 return; 259 return;
268 } 260 }
269 mBeepPopUp->setItemChecked ( mPlayBeeps,false ); 261 mBeepPopUp->setItemChecked ( mPlayBeeps,false );
270 mPlayBeeps = num; 262 mPlayBeeps = num;
271 mBeepPopUp->setItemChecked ( mPlayBeeps, true ); 263 mBeepPopUp->setItemChecked ( mPlayBeeps, true );
272} 264}
273 265
274void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& ) 266void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& )
275{ 267{
276 //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data()); 268 //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data());
277 QString mess = QString::fromUtf8(msg.data()); 269 QString mess = QString::fromUtf8(msg.data());
278 mAlarmMessage = mess.mid( 9 ); 270 mAlarmMessage = mess.mid( 9 );
279 QString filename = getenv("QPEDIR") ; 271 QString filename = getenv("QPEDIR") ;
280 filename += "/pics/kdepim/korganizer/koalarm.wav"; 272 filename += "/pics/kdepim/korganizer/koalarm.wav";
281 QString tempfilename; 273 QString tempfilename;
282 if ( mess.left( 13 ) == "suspend_alarm") { 274 if ( mess.left( 13 ) == "suspend_alarm") {
283 bool error = false; 275 bool error = false;
284 int len = mess.mid( 13 ).find("+++"); 276 int len = mess.mid( 13 ).find("+++");
285 if ( len < 2 ) 277 if ( len < 2 )
286 error = true; 278 error = true;
287 else { 279 else {
288 tempfilename = mess.mid( 13, len ); 280 tempfilename = mess.mid( 13, len );
289 if ( !QFile::exists( tempfilename ) ) 281 if ( !QFile::exists( tempfilename ) )
290 error = true; 282 error = true;
291 } 283 }
292 if ( ! error ) { 284 if ( ! error ) {
293 filename = tempfilename; 285 filename = tempfilename;
294 } 286 }
295 mAlarmMessage = mess.mid( 13+len+3 ); 287 mAlarmMessage = mess.mid( 13+len+3 );
296 //qDebug("suspend file %s ",tempfilename.latin1() ); 288 //qDebug("suspend file %s ",tempfilename.latin1() );
297 startAlarm( mAlarmMessage, filename); 289 startAlarm( mAlarmMessage, filename);
298 return; 290 return;
299 } 291 }
300 if ( mess.left( 11 ) == "timer_alarm") { 292 if ( mess.left( 11 ) == "timer_alarm") {
301 mTimerTime = 0; 293 mTimerTime = 0;
302 startAlarm( mess.mid( 11 ), filename ); 294 startAlarm( mess.mid( 11 ), filename );
303 return; 295 return;
304 } 296 }
305 if ( mess.left( 10 ) == "proc_alarm") { 297 if ( mess.left( 10 ) == "proc_alarm") {
306 bool error = false; 298 bool error = false;
307 int len = mess.mid( 10 ).find("+++"); 299 int len = mess.mid( 10 ).find("+++");
308 if ( len < 2 ) 300 if ( len < 2 )
309 error = true; 301 error = true;
310 else { 302 else {
311 tempfilename = mess.mid( 10, len ); 303 tempfilename = mess.mid( 10, len );
312 if ( !QFile::exists( tempfilename ) ) 304 if ( !QFile::exists( tempfilename ) )
313 error = true; 305 error = true;
314 } 306 }
315 if ( error ) { 307 if ( error ) {
316 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 308 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
317 mAlarmMessage += mess.mid( 10+len+3+9 ); 309 mAlarmMessage += mess.mid( 10+len+3+9 );
318 } else { 310 } else {
319 //qDebug("-----system command %s ",tempfilename.latin1() ); 311 //qDebug("-----system command %s ",tempfilename.latin1() );
320 if ( vfork () == 0 ) { 312 if ( vfork () == 0 ) {
321 execl ( tempfilename.latin1(), 0 ); 313 execl ( tempfilename.latin1(), 0 );
322 return; 314 return;
323 } 315 }
324 QTimer::singleShot( 10000, this, SLOT ( writeFile() ) ); 316 QTimer::singleShot( 10000, this, SLOT ( writeFile() ) );
325 return; 317 return;
326 } 318 }
327 319
328 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 320 //qDebug("+++++++system command %s ",tempfilename.latin1() );
329 } 321 }
330 if ( mess.left( 11 ) == "audio_alarm") { 322 if ( mess.left( 11 ) == "audio_alarm") {
331 bool error = false; 323 bool error = false;
332 int len = mess.mid( 11 ).find("+++"); 324 int len = mess.mid( 11 ).find("+++");
333 if ( len < 2 ) 325 if ( len < 2 )
334 error = true; 326 error = true;
335 else { 327 else {
336 tempfilename = mess.mid( 11, len ); 328 tempfilename = mess.mid( 11, len );
337 if ( !QFile::exists( tempfilename ) ) 329 if ( !QFile::exists( tempfilename ) )
338 error = true; 330 error = true;
339 } 331 }
340 if ( ! error ) { 332 if ( ! error ) {
341 filename = tempfilename; 333 filename = tempfilename;
342 } 334 }
343 mAlarmMessage = mess.mid( 11+len+3+9 ); 335 mAlarmMessage = mess.mid( 11+len+3+9 );
344 //qDebug("audio file command %s ",tempfilename.latin1() ); 336 //qDebug("audio file command %s ",tempfilename.latin1() );
345 } 337 }
346 if ( mess.left( 9 ) == "cal_alarm") { 338 if ( mess.left( 9 ) == "cal_alarm") {
347 mAlarmMessage = mess.mid( 9 ) ; 339 mAlarmMessage = mess.mid( 9 ) ;
348 } 340 }
349 341
350 QTimer::singleShot( 10000, this, SLOT ( writeFile() ) ); 342 QTimer::singleShot( 10000, this, SLOT ( writeFile() ) );
351 startAlarm( mAlarmMessage, filename ); 343 startAlarm( mAlarmMessage, filename );
352 344
353} 345}
354 346
355int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) 347int SimpleAlarmDaemonImpl::getFileNameLen( QString mess )
356{ 348{
357 return 0; 349 return 0;
358} 350}
359void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) 351void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename )
360{ 352{
361 //mAlarmDialog->show(); 353 //mAlarmDialog->show();
362 //mAlarmDialog->raise(); 354 //mAlarmDialog->raise();
363 mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); 355 mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend );
364} 356}
365 357
366 358
367void SimpleAlarmDaemonImpl::fillTimerPopUp() 359void SimpleAlarmDaemonImpl::fillTimerPopUp()
368{ 360{
369 361
370 // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); 362 // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime );
371 if ( mTimerPopupConf == mTimerTime ) { 363 if ( mTimerPopupConf == mTimerTime ) {
372 if ( mTimerTime ) { 364 if ( mTimerTime ) {
373 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); 365 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer );
374 QTime t ( secs/3600, (secs/60)%60, secs%60 ); 366 QTime t ( secs/3600, (secs/60)%60, secs%60 );
375 mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)"); 367 mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)");
376 } 368 }
377 else { 369 else {
378 QString text = mCustomText.stripWhiteSpace (); 370 QString text = mCustomText.stripWhiteSpace ();
379 int in = text.find( " " ); 371 int in = text.find( " " );
380 text = text.left ( in ); 372 text = text.left ( in );
381 mTimerPopUp->changeItem ( 3, text ); 373 mTimerPopUp->changeItem ( 3, text );
382 } 374 }
383 return; 375 return;
384 } 376 }
385 mTimerPopupConf = mTimerTime; 377 mTimerPopupConf = mTimerTime;
386 mTimerPopUp->clear(); 378 mTimerPopUp->clear();
387 if ( mTimerTime ) { 379 if ( mTimerTime ) {
388 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); 380 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer );
389 QTime t ( secs/3600, (secs/60)%60, secs%60 ); 381 QTime t ( secs/3600, (secs/60)%60, secs%60 );
390 382
391 383
392 mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 ); 384 mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 );
393 mTimerPopUp->insertItem( t.toString() + " (countdown)",1); 385 mTimerPopUp->insertItem( t.toString() + " (countdown)",1);
394 mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm)",2); 386 mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm)",2);
395 } else { 387 } else {
396 388
397 QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc"; 389 QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc";
398 QFile file( fileName ); 390 QFile file( fileName );
399 if( !QFile::exists( fileName) ) { 391 if( !QFile::exists( fileName) ) {
400 // write defaults 392 // write defaults
401 if (!file.open( IO_WriteOnly ) ) { 393 if (!file.open( IO_WriteOnly ) ) {
402 return; 394 return;
403 } 395 }
404 QString configString ; 396 QString configString ;
405 configString += "#config file for kopi alarm timer\n"; 397 configString += "#config file for kopi alarm timer\n";
406 configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n"; 398 configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n";
407 configString += "24 hours; 1440\n"; 399 configString += "24 hours; 1440\n";
408 configString += "8 hours; 480\n"; 400 configString += "8 hours; 480\n";
409 configString += "5 hours; 300\n"; 401 configString += "5 hours; 300\n";
410 configString += "1 hour; 60\n"; 402 configString += "1 hour; 60\n";
411 configString += "30 min; 30\n"; 403 configString += "30 min; 30\n";
412 configString += "15 min; 15\n"; 404 configString += "15 min; 15\n";
413 configString += "SEPARATOR\n"; 405 configString += "SEPARATOR\n";
414 configString += "Pizza; 22\n"; 406 configString += "Pizza; 22\n";
415 configString += "Nap; 45\n"; 407 configString += "Nap; 45\n";
416 configString += "Tea; 5\n"; 408 configString += "Tea; 5\n";
417 QTextStream ts( &file ); 409 QTextStream ts( &file );
418 ts << configString ; 410 ts << configString ;
419 file.close(); 411 file.close();
420 } 412 }
421 413
422 if (!file.open( IO_ReadOnly ) ) { 414 if (!file.open( IO_ReadOnly ) ) {
423 return ; 415 return ;
424 } 416 }
425 QString line; 417 QString line;
426 bool ok; 418 bool ok;
427 while ( file.readLine( line, 1024 ) > 0 ) { 419 while ( file.readLine( line, 1024 ) > 0 ) {
428 //qDebug("read %s ", line.latin1()); 420 //qDebug("read %s ", line.latin1());
429 if ( line.left(1 ) != "#" ) { 421 if ( line.left(1 ) != "#" ) {
430 // no comment 422 // no comment
431 if ( line.left(9 ) == "SEPARATOR" ) { 423 if ( line.left(9 ) == "SEPARATOR" ) {
432 mTimerPopUp->insertSeparator(); 424 mTimerPopUp->insertSeparator();
433 } else { 425 } else {
434 QStringList li = QStringList::split(";",line); 426 QStringList li = QStringList::split(";",line);
435 ok = false; 427 ok = false;
436 if ( li.count() == 2 ) { 428 if ( li.count() == 2 ) {
437 int val = li[1].toInt( &ok ); 429 int val = li[1].toInt( &ok );
438 if ( ok && val > 0 ) { 430 if ( ok && val > 0 ) {
439 mTimerPopUp->insertItem( li[0], val+10); 431 mTimerPopUp->insertItem( li[0], val+10);
440 } 432 }
441 } 433 }
442 } 434 }
443 } 435 }
444 } 436 }
445 file.close(); 437 file.close();
446#if 0 438#if 0
447 mTimerPopUp->insertItem( "24 hours", 1440 ); 439 mTimerPopUp->insertItem( "24 hours", 1440 );
448 // mTimerPopUp->insertItem( i18n("12 h"), 720 ); 440 // mTimerPopUp->insertItem( i18n("12 h"), 720 );
449 mTimerPopUp->insertItem( " 8 hours", 480 ); 441 mTimerPopUp->insertItem( " 8 hours", 480 );
450 mTimerPopUp->insertItem( " 5 hours", 300 ); 442 mTimerPopUp->insertItem( " 5 hours", 300 );
451 // mTimerPopUp->insertItem( i18n(" 2 h"), 120 ); 443 // mTimerPopUp->insertItem( i18n(" 2 h"), 120 );
452 mTimerPopUp->insertItem( " 1 hour", 60 ); 444 mTimerPopUp->insertItem( " 1 hour", 60 );
453 mTimerPopUp->insertItem( "30 min", 30 ); 445 mTimerPopUp->insertItem( "30 min", 30 );
454 mTimerPopUp->insertItem( "15 min", 15 ); 446 mTimerPopUp->insertItem( "15 min", 15 );
455 mTimerPopUp->insertItem( "10 min", 10 ); 447 mTimerPopUp->insertItem( "10 min", 10 );
456 //mTimerPopUp->insertItem( " 5 min", 5 ); 448 //mTimerPopUp->insertItem( " 5 min", 5 );
457 mTimerPopUp->insertSeparator(); 449 mTimerPopUp->insertSeparator();
458 mTimerPopUp->insertItem( "Pizza", 22 ); 450 mTimerPopUp->insertItem( "Pizza", 22 );
459 mTimerPopUp->insertItem( "Nap", 45 ); 451 mTimerPopUp->insertItem( "Nap", 45 );
460 mTimerPopUp->insertItem( "Tea", 5 ); 452 mTimerPopUp->insertItem( "Tea", 5 );
461#endif 453#endif
462 QString text = mCustomText.stripWhiteSpace (); 454 QString text = mCustomText.stripWhiteSpace ();
463 int in = text.find( " " ); 455 int in = text.find( " " );
464 text = text.left ( in ); 456 text = text.left ( in );
465 mTimerPopUp->insertItem( text, 3 ); 457 mTimerPopUp->insertItem( text, 3 );
466 mTimerPopUp->insertSeparator(); 458 mTimerPopUp->insertSeparator();
467 mTimerPopUp->insertItem( "Customize", 2 ); 459 mTimerPopUp->insertItem( "Customize", 2 );
468 } 460 }
469 461
470} 462}
471 463
472void SimpleAlarmDaemonImpl::showTimer() 464void SimpleAlarmDaemonImpl::showTimer()
473{ 465{
474 fillTimerPopUp(); 466 fillTimerPopUp();
475} 467}
476 468
477void SimpleAlarmDaemonImpl::confTimer( int time ) 469void SimpleAlarmDaemonImpl::confTimer( int time )
478{ 470{
479 //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time ); 471 //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time );
480 int minutes = time; 472 int minutes = time;
481 if ( minutes == 0 ) { 473 if ( minutes == 0 ) {
482 if ( ! mTimerTime ) 474 if ( ! mTimerTime )
483 return; 475 return;
484 476
485 QDialog dia ( 0, ("Stop Timer" ), true ); 477 QDialog dia ( 0, ("Stop Timer" ), true );
486 QLabel lab (("Really stop the timer?\n\n"+ mRunningTimerText+"\n"), &dia ); 478 QLabel lab (("Really stop the timer?\n\n"+ mRunningTimerText+"\n"), &dia );
487 lab.setAlignment( AlignCenter ); 479 lab.setAlignment( AlignCenter );
488 dia.setCaption(("KO/Pi Timer Stop" )); 480 dia.setCaption(("KO/Pi Timer Stop" ));
489 QVBoxLayout lay( &dia ); 481 QVBoxLayout lay( &dia );
490 lay.addWidget( &lab); 482 lay.addWidget( &lab);
491 QPushButton ok ( "Stop timer!", &dia); 483 QPushButton ok ( "Stop timer!", &dia);
492 QFont fo = dia.font(); 484 QFont fo = dia.font();
493 fo.setPointSize( 36 ); 485 fo.setPointSize( 36 );
494 ok.setFont( fo ); 486 ok.setFont( fo );
495 lay.addWidget( &ok); 487 lay.addWidget( &ok);
496 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); 488 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) );
497 QPushButton con ( "Continue timer!", &dia); 489 QPushButton con ( "Continue timer!", &dia);
498 fo.setPointSize( 36 ); 490 fo.setPointSize( 36 );
499 con.setFont( fo ); 491 con.setFont( fo );
500 lay.addWidget( &con); 492 lay.addWidget( &con);
501 connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) ); 493 connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) );
502 lay.setMargin(5); 494 lay.setMargin(5);
503 lay.setSpacing(5); 495 lay.setSpacing(5);
504 dia.resize(dia.sizeHint() ); 496 dia.resize(dia.sizeHint() );
505 497
506 if ( !dia.exec() ) 498 if ( !dia.exec() )
507 return; 499 return;
508 500
509 AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.utf8() ); 501 AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.utf8() );
510 mTimerTime = 0; 502 mTimerTime = 0;
511 return; 503 return;
512 } 504 }
513 if ( mTimerTime ) 505 if ( mTimerTime )
514 return; 506 return;
515 if ( minutes == 1 ) { 507 if ( minutes == 1 ) {
516 return; 508 return;
517 } 509 }
518 QString mess = "timer_alarm"; 510 QString mess = "timer_alarm";
519 mess += ("Timer Alarm!\n"); 511 mess += ("Timer Alarm!\n");
520 if ( minutes == 3 ) { 512 if ( minutes == 3 ) {
521 mess += mCustomText; 513 mess += mCustomText;
522 minutes = mCustomMinutes ; 514 minutes = mCustomMinutes ;
523 mRunningTimerText = mCustomText.stripWhiteSpace (); 515 mRunningTimerText = mCustomText.stripWhiteSpace ();
524 int in = mRunningTimerText.find( " " ); 516 int in = mRunningTimerText.find( " " );
525 mRunningTimerText = mRunningTimerText.left ( in ); 517 mRunningTimerText = mRunningTimerText.left ( in );
526 } 518 }
527 else { 519 else {
528 if ( minutes == 2 ) { 520 if ( minutes == 2 ) {
529 // ask time 521 // ask time
530 QDialog dia ( 0, ("Customize Timer" ), true ); 522 QDialog dia ( 0, ("Customize Timer" ), true );
531 QLabel lab (("Message Text:"), &dia ); 523 QLabel lab (("Message Text:"), &dia );
532 dia.setCaption(("KO/Pi Timer" )); 524 dia.setCaption(("KO/Pi Timer" ));
533 QVBoxLayout lay( &dia ); 525 QVBoxLayout lay( &dia );
534 lay.setMargin(5); 526 lay.setMargin(5);
535 lay.setSpacing(5); 527 lay.setSpacing(5);
536 lay.addWidget( &lab); 528 lay.addWidget( &lab);
537 QLineEdit lEdit( mCustomText, &dia ); 529 QLineEdit lEdit( mCustomText, &dia );
538 lay.addWidget( &lEdit); 530 lay.addWidget( &lEdit);
539 QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia ); 531 QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia );
540 lay.addWidget( &lab2); 532 lay.addWidget( &lab2);
541 QHBox hbox1 ( &dia ); 533 QHBox hbox1 ( &dia );
542 lay.addWidget( &hbox1); 534 lay.addWidget( &hbox1);
543 QLabel lab3 (("Hours"), &hbox1 ); 535 QLabel lab3 (("Hours"), &hbox1 );
544 QLabel lab4 (("Minutes"), &hbox1 ); 536 QLabel lab4 (("Minutes"), &hbox1 );
545 QHBox hbox ( &dia ); 537 QHBox hbox ( &dia );
546 QSpinBox spinh( 0, 24, 1,& hbox ); 538 QSpinBox spinh( 0, 24, 1,& hbox );
547 QFont fo = dia.font(); 539 QFont fo = dia.font();
548 fo.setPointSize( 36 ); 540 fo.setPointSize( 36 );
549 QSpinBox spinm( 0, 59, 1,&hbox ); 541 QSpinBox spinm( 0, 59, 1,&hbox );
550 spinm.setFont( fo ); 542 spinm.setFont( fo );
551 spinh.setFont( fo ); 543 spinh.setFont( fo );
552 spinh.setButtonSymbols( QSpinBox::PlusMinus ); 544 spinh.setButtonSymbols( QSpinBox::PlusMinus );
553 spinm.setButtonSymbols( QSpinBox::PlusMinus ); 545 spinm.setButtonSymbols( QSpinBox::PlusMinus );
554 spinh.upButton ()->setFixedSize( QSize( 48, 30 )); 546 spinh.upButton ()->setFixedSize( QSize( 48, 30 ));
555 spinh.downButton ()->setFixedSize( QSize( 48, 30 )); 547 spinh.downButton ()->setFixedSize( QSize( 48, 30 ));
556 //spinh.editor ()->setFixedSize( QSize( 50, 100 )); 548 //spinh.editor ()->setFixedSize( QSize( 50, 100 ));
557 spinh.setFixedSize( 100,62 ); 549 spinh.setFixedSize( 100,62 );
558 spinm.upButton ()->setFixedSize( QSize( 48, 30 )); 550 spinm.upButton ()->setFixedSize( QSize( 48, 30 ));
559 spinm.downButton ()->setFixedSize( QSize( 48, 30 )); 551 spinm.downButton ()->setFixedSize( QSize( 48, 30 ));
560 spinm.downButton ()->setGeometry( 50,50,50,50); 552 spinm.downButton ()->setGeometry( 50,50,50,50);
561 // spinm.setSuffix( " m" ); 553 // spinm.setSuffix( " m" );
562 //spinh.setSuffix( " h" ); 554 //spinh.setSuffix( " h" );
563 spinm.setWrapping ( true ); 555 spinm.setWrapping ( true );
564 //spinm.editor ()->setFixedSize( QSize( 50, 100 )); 556 //spinm.editor ()->setFixedSize( QSize( 50, 100 ));
565 spinm.setLineStep( 1 ); 557 spinm.setLineStep( 1 );
566 spinm.setFixedSize( 110,62 ); 558 spinm.setFixedSize( 110,62 );
567 lay.addWidget( &hbox); 559 lay.addWidget( &hbox);
568 QLabel lab5 ("Timer fires at:", &dia ); 560 QLabel lab5 ("Timer fires at:", &dia );
569 lab5.setAlignment( AlignCenter ); 561 lab5.setAlignment( AlignCenter );
570 lay.addWidget( &lab5); 562 lay.addWidget( &lab5);
571 KODateLabel dl ( &dia ); 563 KODateLabel dl ( &dia );
572 dl.setAlignment( AlignCenter ); 564 dl.setAlignment( AlignCenter );
573 dl.setFont( fo ); 565 dl.setFont( fo );
574 connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) ); 566 connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) );
575 connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) ); 567 connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) );
576 lay.addWidget( &dl); 568 lay.addWidget( &dl);
577 spinh.setValue( mCustomMinutes/60 ); 569 spinh.setValue( mCustomMinutes/60 );
578 spinm.setValue( mCustomMinutes%60 ); 570 spinm.setValue( mCustomMinutes%60 );
579 QPushButton ok ( "Start timer", &dia); 571 QPushButton ok ( "Start timer", &dia);
580 ok.setDefault( true ); 572 ok.setDefault( true );
581 ok.setFont( fo ); 573 ok.setFont( fo );
582 spinh.setFocus(); 574 spinh.setFocus();
583 lay.addWidget( &ok); 575 lay.addWidget( &ok);
584 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); 576 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) );
585 dia.resize( dia.sizeHint().width(), dia.sizeHint().height() ); 577 dia.resize( dia.sizeHint().width(), dia.sizeHint().height() );
586 578
587 if ( !dia.exec() ) 579 if ( !dia.exec() )
588 return; 580 return;
589 mCustomText = lEdit.text(); 581 mCustomText = lEdit.text();
590 mCustomMinutes = spinh.value()*60+spinm.value(); 582 mCustomMinutes = spinh.value()*60+spinm.value();
591 if ( mCustomMinutes == 0 ) 583 if ( mCustomMinutes == 0 )
592 mCustomMinutes = 1; 584 mCustomMinutes = 1;
593 if ( mCustomMinutes > 1440 ) 585 if ( mCustomMinutes > 1440 )
594 mCustomMinutes = 1440; 586 mCustomMinutes = 1440;
595 mess += mCustomText; 587 mess += mCustomText;
596 minutes = mCustomMinutes; 588 minutes = mCustomMinutes;
597 mRunningTimerText = mCustomText.stripWhiteSpace (); 589 mRunningTimerText = mCustomText.stripWhiteSpace ();
598 int in = mRunningTimerText.find( " " ); 590 int in = mRunningTimerText.find( " " );
599 mRunningTimerText = mRunningTimerText.left ( in ); 591 mRunningTimerText = mRunningTimerText.left ( in );
600 } 592 }
601 else { 593 else {
602 mess += mTimerPopUp->text( minutes ); 594 mess += mTimerPopUp->text( minutes );
603 mRunningTimerText = mTimerPopUp->text( minutes ); 595 mRunningTimerText = mTimerPopUp->text( minutes );
604 minutes -= 10; 596 minutes -= 10;
605 } 597 }
606 } 598 }
607 //minutes = 1; 599 //minutes = 1;
608 600
609 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); 601 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 );
610 timerMesssage = mess; 602 timerMesssage = mess;
611 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.utf8()); 603 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.utf8());
612 mTimerTime = 1; 604 mTimerTime = 1;
613} 605}
614 606
615void SimpleAlarmDaemonImpl::writeFile() 607void SimpleAlarmDaemonImpl::writeFile()
616{ 608{
617 QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 609 QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
618 //QCopEnvelope e("QPE/Application/kopi", "-writeFile"); 610 //QCopEnvelope e("QPE/Application/kopi", "-writeFile");
619} 611}
620void SimpleAlarmDaemonImpl::showWN() 612void SimpleAlarmDaemonImpl::showWN()
621{ 613{
622 QCopEnvelope e("QPE/Application/kopi", "-showWN"); 614 QCopEnvelope e("QPE/Application/kopi", "-showWN");
623} 615}
624void SimpleAlarmDaemonImpl::newTodo() 616void SimpleAlarmDaemonImpl::newTodo()
625{ 617{
626 QCopEnvelope e("QPE/Application/kopi", "-newTodo"); 618 QCopEnvelope e("QPE/Application/kopi", "-newTodo");
627} 619}
628 620
629void SimpleAlarmDaemonImpl::newEvent() 621void SimpleAlarmDaemonImpl::newEvent()
630{ 622{
631 QCopEnvelope e("QPE/Application/kopi", "-newEvent"); 623 QCopEnvelope e("QPE/Application/kopi", "-newEvent");
632 624
633} 625}
634void SimpleAlarmDaemonImpl::newMail() 626void SimpleAlarmDaemonImpl::newMail()
635{ 627{
636 QCopEnvelope e("QPE/Application/ompi", "newMail()"); 628 QCopEnvelope e("QPE/Application/ompi", "newMail()");
637} 629}
638void SimpleAlarmDaemonImpl::showAdd() 630void SimpleAlarmDaemonImpl::showAdd()
639{ 631{
640 QCopEnvelope e("QPE/Application/kapi", "raise()"); 632 QCopEnvelope e("QPE/Application/kapi", "raise()");
641} 633}
642void SimpleAlarmDaemonImpl::ringSync() 634void SimpleAlarmDaemonImpl::ringSync()
643{ 635{
644 QCopEnvelope e("QPE/Application/kopi", "-ringSync"); 636 QCopEnvelope e("QPE/Application/kopi", "-ringSync");
645 637
646} 638}
647void SimpleAlarmDaemonImpl::newCountdown() 639void SimpleAlarmDaemonImpl::newCountdown()
648{ 640{
649 //recieve("cal_alarm", 10 ); 641 //recieve("cal_alarm", 10 );
650} 642}
651void SimpleAlarmDaemonImpl::simulate() 643void SimpleAlarmDaemonImpl::simulate()
652{ 644{
653 QTimer::singleShot( 10000, this, SLOT ( writeFile() ) ); 645 QTimer::singleShot( 10000, this, SLOT ( writeFile() ) );
654 QString filename = getenv("QPEDIR") ; 646 QString filename = getenv("QPEDIR") ;
655 filename += "/pics/kdepim/korganizer/koalarm.wav"; 647 filename += "/pics/kdepim/korganizer/koalarm.wav";
656 startAlarm("Alarm simulation", filename ); 648 startAlarm("Alarm simulation", filename );
657} 649}
658void SimpleAlarmDaemonImpl::showKO() 650void SimpleAlarmDaemonImpl::showKO()
659{ 651{
660 QCopEnvelope e("QPE/Application/kopi", "-showKO"); 652 QCopEnvelope e("QPE/Application/kopi", "-showKO");
661 // testing only 653 // testing only
662 //QCopEnvelope e("QPE/Application/kopi", "nextView()"); 654 //QCopEnvelope e("QPE/Application/kopi", "nextView()");
663 655
664} 656}
665void SimpleAlarmDaemonImpl::showTodo() 657void SimpleAlarmDaemonImpl::showTodo()
666{ 658{
667 QCopEnvelope e("QPE/Application/kopi", "-showTodo"); 659 QCopEnvelope e("QPE/Application/kopi", "-showTodo");
668 660
669} 661}
670void SimpleAlarmDaemonImpl::writeJournal() 662void SimpleAlarmDaemonImpl::writeJournal()
671{ 663{
672 QCopEnvelope e("QPE/Application/kopi", "-showJournal"); 664 QCopEnvelope e("QPE/Application/kopi", "-showJournal");
673 665
674} 666}
675 667
676void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) 668void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * )
677{ 669{
678 670
679 mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); 671 mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() )));
680 672
681} 673}
682 674