author | zautrix <zautrix> | 2005-09-18 13:50:46 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-09-18 13:50:46 (UTC) |
commit | c6e493d4e5b9eafcc3402c39e30c4283ce8cc8e5 (patch) (unidiff) | |
tree | 94e7bdc361b68a3a569eebe14f66458b3795dd6a /kalarmd | |
parent | e7cd095ea9e80e26c90cbc2d3bf36921b7541c19 (diff) | |
download | kdepimpi-c6e493d4e5b9eafcc3402c39e30c4283ce8cc8e5.zip kdepimpi-c6e493d4e5b9eafcc3402c39e30c4283ce8cc8e5.tar.gz kdepimpi-c6e493d4e5b9eafcc3402c39e30c4283ce8cc8e5.tar.bz2 |
delay
-rw-r--r-- | kalarmd/simplealarmdaemonimpl.cpp | 8 |
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,461 +1,453 @@ | |||
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 | ||
51 | SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent ) | 51 | SimpleAlarmDaemonImpl::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 | ||
156 | SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl() | 148 | SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl() |
157 | { | 149 | { |
158 | //delete mPopUp; | 150 | //delete mPopUp; |
159 | delete mAlarmDialog; | 151 | delete mAlarmDialog; |
160 | } | 152 | } |
161 | void SimpleAlarmDaemonImpl::saveSlot( int load ) | 153 | void 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 | } |
239 | void SimpleAlarmDaemonImpl::confSuspend( int num ) | 231 | void 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 | } |
245 | void SimpleAlarmDaemonImpl::confPause( int num ) | 237 | void 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 | } |
251 | void SimpleAlarmDaemonImpl::confSound( int num ) | 243 | void 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 | } |
263 | void SimpleAlarmDaemonImpl::slotPlayBeep( int num ) | 255 | void 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 | ||
274 | void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& ) | 266 | void 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 | ||
355 | int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) | 347 | int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) |
356 | { | 348 | { |
357 | return 0; | 349 | return 0; |
358 | } | 350 | } |
359 | void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) | 351 | void 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 | ||
367 | void SimpleAlarmDaemonImpl::fillTimerPopUp() | 359 | void 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 |