summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-10-30 03:18:28 (UTC)
committer zautrix <zautrix>2005-10-30 03:18:28 (UTC)
commit760f042066478106b87a63d6aba1ac1473a58dae (patch) (unidiff)
treeefa26bd696cd152e36552317e2d26a615db0866a
parent54d04eb1b2cb8ec4a3b2cf3dfdfbade45dc7ae7a (diff)
downloadkdepimpi-760f042066478106b87a63d6aba1ac1473a58dae.zip
kdepimpi-760f042066478106b87a63d6aba1ac1473a58dae.tar.gz
kdepimpi-760f042066478106b87a63d6aba1ac1473a58dae.tar.bz2
fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/phonenumber.cpp2
-rw-r--r--kalarmd/simplealarmdaemonimpl.cpp8
2 files changed, 5 insertions, 5 deletions
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp
index 897c56d..12b9b09 100644
--- a/kabc/phonenumber.cpp
+++ b/kabc/phonenumber.cpp
@@ -1,374 +1,374 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#include <kapplication.h> 28#include <kapplication.h>
29#include <klocale.h> 29#include <klocale.h>
30 30
31#include "phonenumber.h" 31#include "phonenumber.h"
32 32
33using namespace KABC; 33using namespace KABC;
34 34
35PhoneNumber::PhoneNumber() : 35PhoneNumber::PhoneNumber() :
36 mType( Home ) 36 mType( Home )
37{ 37{
38 init(); 38 init();
39} 39}
40 40
41PhoneNumber::PhoneNumber( const QString &number, int type ) : 41PhoneNumber::PhoneNumber( const QString &number, int type ) :
42 mType( type ), mNumber( number ) 42 mType( type ), mNumber( number )
43{ 43{
44 init(); 44 init();
45} 45}
46 46
47PhoneNumber::~PhoneNumber() 47PhoneNumber::~PhoneNumber()
48{ 48{
49} 49}
50 50
51void PhoneNumber::init() 51void PhoneNumber::init()
52{ 52{
53 mId = KApplication::randomString( 8 ); 53 mId = KApplication::randomString( 8 );
54} 54}
55 55
56bool PhoneNumber::operator==( const PhoneNumber &p ) const 56bool PhoneNumber::operator==( const PhoneNumber &p ) const
57{ 57{
58 if ( mNumber != p.mNumber ) return false; 58 if ( mNumber != p.mNumber ) return false;
59 if ( mType != p.mType ) return false; 59 if ( mType != p.mType ) return false;
60 60
61 return true; 61 return true;
62} 62}
63 63
64bool PhoneNumber::operator!=( const PhoneNumber &p ) const 64bool PhoneNumber::operator!=( const PhoneNumber &p ) const
65{ 65{
66 return !( p == *this ); 66 return !( p == *this );
67} 67}
68void PhoneNumber::makeCompat() 68void PhoneNumber::makeCompat()
69{ 69{
70 mType = getCompatType( mType ); 70 mType = getCompatType( mType );
71} 71}
72int PhoneNumber::getCompatType( int type ) 72int PhoneNumber::getCompatType( int type )
73{ 73{
74 74
75 if ((type & Cell) == Cell) { 75 if ((type & Cell) == Cell) {
76 if ((type & Work) == Work) 76 if ((type & Work) == Work)
77 return Car; 77 return Car;
78 return Cell; 78 return Cell;
79 } 79 }
80 if ((type & Home) == Home) { 80 if ((type & Home) == Home) {
81 if ((type & Pref) == Pref) 81 if ((type & Pref) == Pref)
82 return (Home | Pref); 82 return (Home | Pref);
83 if ((type & Fax) == Fax) 83 if ((type & Fax) == Fax)
84 return (Home | Fax); 84 return (Home | Fax);
85 return (Home); 85 return (Home);
86 } 86 }
87 if ((type & Work) == Work) { 87 if ((type & Work) == Work) {
88 if ((type & Pref) == Pref) 88 if ((type & Pref) == Pref)
89 return (Work| Pref); 89 return (Work| Pref);
90 if ((type & Fax) == Fax) 90 if ((type & Fax) == Fax)
91 return (Fax |Work); 91 return (Fax |Work);
92 if ((type & Msg) == Msg) { 92 if ((type & Msg) == Msg) {
93 if ((type & Voice) == Voice) 93 if ((type & Voice) == Voice)
94 return ( Msg | Voice |Work); 94 return ( Msg | Voice |Work);
95 return ( Msg | Work); 95 return ( Msg | Work);
96 } 96 }
97 return Work; 97 return Work;
98 } 98 }
99 if ((type & Pcs) == Pcs) { 99 if ((type & Pcs) == Pcs) {
100 if ((type & Pref) == Pref) 100 if ((type & Pref) == Pref)
101 return Pcs | Pref; 101 return Pcs | Pref;
102 if ((type & Voice) == Voice) 102 if ((type & Voice) == Voice)
103 return Pcs | Voice; 103 return Pcs | Voice;
104 return Pcs; 104 return Pcs;
105 } 105 }
106 if ((type & Car) == Car) 106 if ((type & Car) == Car)
107 return Car; 107 return Car;
108 if ((type & Pager) == Pager) 108 if ((type & Pager) == Pager)
109 return Pager; 109 return Pager;
110 if ((type & Isdn) == Isdn) 110 if ((type & Isdn) == Isdn)
111 return Isdn; 111 return Isdn;
112#if 0 112#if 0
113 if ((type & Video) == Video) 113 if ((type & Video) == Video)
114 return Video; 114 return Video;
115#endif 115#endif
116 if ((type & Msg) == Msg) 116 if ((type & Msg) == Msg)
117 return Msg; 117 return Msg;
118 if ((type & Fax) == Fax) 118 if ((type & Fax) == Fax)
119 return Fax; 119 return Fax;
120 120
121 if ((type & Pref) == Pref) 121 if ((type & Pref) == Pref)
122 return Pref; 122 return Pref;
123 123
124 return Voice; 124 return Voice;
125 125
126} 126}
127bool PhoneNumber::simplifyNumber() 127bool PhoneNumber::simplifyNumber()
128{ 128{
129 QString Number; 129 QString Number;
130 int i; 130 int i;
131 Number = mNumber.stripWhiteSpace (); 131 Number = mNumber.stripWhiteSpace ();
132 mNumber = ""; 132 mNumber = "";
133 for ( i = 0; i < Number.length(); ++i) { 133 for ( i = 0; i < Number.length(); ++i) {
134 if ( Number.at(i).isDigit() || Number.at(i) == '+'|| Number.at(i) == '*'|| Number.at(i) == '#' ) 134 if ( Number.at(i).isDigit() || Number.at(i) == '+'|| Number.at(i) == '*'|| Number.at(i) == '#' )
135 mNumber += Number.at(i); 135 mNumber += Number.at(i);
136 } 136 }
137 return ( mNumber.length() > 0 ); 137 return ( mNumber.length() > 0 );
138} 138}
139// make cellphone compatible 139// make cellphone compatible
140void PhoneNumber::simplifyType() 140void PhoneNumber::simplifyType()
141{ 141{
142 if ( mType & Fax ) mType = Fax; 142 if ( mType & Fax ) mType = Fax;
143 else if ( mType & Cell ) mType = Cell; 143 else if ( mType & Cell ) mType = Cell;
144 else if ( mType & Work ) mType = Work ; 144 else if ( mType & Work ) mType = Work ;
145 else if ( mType & Home ) mType = Home; 145 else if ( mType & Home ) mType = Home;
146 else mType = Pref; 146 else mType = Pref;
147} 147}
148bool PhoneNumber::contains( const PhoneNumber &p ) 148bool PhoneNumber::contains( const PhoneNumber &p )
149{ 149{
150 PhoneNumber myself; 150 PhoneNumber myself;
151 PhoneNumber other; 151 PhoneNumber other;
152 myself = *this; 152 myself = *this;
153 other = p; 153 other = p;
154 myself.simplifyNumber(); 154 myself.simplifyNumber();
155 other.simplifyNumber(); 155 other.simplifyNumber();
156 if ( myself.number() != other.number ()) 156 if ( myself.number() != other.number ())
157 return false; 157 return false;
158 myself.simplifyType(); 158 myself.simplifyType();
159 other.simplifyType(); 159 other.simplifyType();
160 if ( myself.type() == other.type()) 160 if ( myself.type() == other.type())
161 return true; 161 return true;
162 return false; 162 return false;
163} 163}
164 164
165void PhoneNumber::setId( const QString &id ) 165void PhoneNumber::setId( const QString &id )
166{ 166{
167 mId = id; 167 mId = id;
168} 168}
169 169
170QString PhoneNumber::id() const 170QString PhoneNumber::id() const
171{ 171{
172 return mId; 172 return mId;
173} 173}
174 174
175void PhoneNumber::setNumber( const QString &number ) 175void PhoneNumber::setNumber( const QString &number )
176{ 176{
177 mNumber = number; 177 mNumber = number;
178} 178}
179 179
180QString PhoneNumber::number() const 180QString PhoneNumber::number() const
181{ 181{
182 return mNumber; 182 return mNumber;
183} 183}
184 184
185void PhoneNumber::setType( int type ) 185void PhoneNumber::setType( int type )
186{ 186{
187 mType = type; 187 mType = type;
188} 188}
189 189
190int PhoneNumber::type() const 190int PhoneNumber::type() const
191{ 191{
192 return mType; 192 return mType;
193} 193}
194 194
195QString PhoneNumber::typeLabel() const 195QString PhoneNumber::typeLabel() const
196{ 196{
197 QString label; 197 QString label;
198 bool first = true; 198 bool first = true;
199 199
200 TypeList list = typeList(); 200 TypeList list = typeList();
201 201
202 TypeList::Iterator it; 202 TypeList::Iterator it;
203 for ( it = list.begin(); it != list.end(); ++it ) { 203 for ( it = list.begin(); it != list.end(); ++it ) {
204 if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { 204 if ( ( type() & (*it) ) && ( (*it) != Pref ) ) {
205 label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); 205 label.append( ( first ? "" : "/" ) + typeLabel( *it ) );
206 if ( first ) 206 if ( first )
207 first = false; 207 first = false;
208 } 208 }
209 } 209 }
210 210
211 return label; 211 return label;
212} 212}
213 213
214QString PhoneNumber::label() const 214QString PhoneNumber::label() const
215{ 215{
216 return typeLabel( type() ); 216 return typeLabel( type() );
217} 217}
218 218
219PhoneNumber::TypeList PhoneNumber::typeList() 219PhoneNumber::TypeList PhoneNumber::typeList()
220{ 220{
221 TypeList list; 221 TypeList list;
222 222
223 list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video 223 list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video
224 << Bbs << Modem << Car << Isdn << Pcs << Pager; 224 << Bbs << Modem << Car << Isdn << Pcs << Pager;
225 225
226 return list; 226 return list;
227} 227}
228PhoneNumber::TypeList PhoneNumber::supportedTypeList() 228PhoneNumber::TypeList PhoneNumber::supportedTypeList()
229{ 229{
230 static TypeList list; 230 static TypeList list;
231 if ( list.count() == 0 ) 231 if ( list.count() == 0 )
232 list << (Home| Pref) << (Work| Pref) << Cell <<(Pcs|Pref)<< (Pcs|Voice)<< Home << Work << Car << Pcs <<(Work| Msg | Voice) << (Work| Msg) << (Home | Fax) << (Work| Fax) << Fax<< Pager << Isdn << Msg << Pref << Voice; 232 list << (Home| Pref) << (Work| Pref) << Cell <<(Pcs|Pref)<< (Pcs|Voice)<< Home << Work << Car << Pcs <<(Work| Msg | Voice) << (Work| Msg) << (Home | Fax) << (Work| Fax) << Fax<< Pager << Isdn << Msg << Pref << Voice;
233 return list; 233 return list;
234} 234}
235QStringList PhoneNumber::supportedTypeListNames() 235QStringList PhoneNumber::supportedTypeListNames()
236{ 236{
237 static QStringList list; 237 static QStringList list;
238 if ( list.count() == 0 ) 238 if ( list.count() == 0 )
239 list << i18n("Home") << i18n("Work") << i18n("Mobile") << i18n("SIP") << i18n("VoIP") <<i18n("Home2")<< i18n("Work2") << i18n("Mobile2") << i18n("SIP2") << i18n("Assistent") << i18n("Company") << i18n("Fax (Home)") << i18n("Fax (Work)") << i18n("Fax (Other)") << i18n("Pager") << i18n("ISDN") << i18n("Callback") << i18n("Primary")<< i18n("Other"); 239 list << i18n("Home") << i18n("Work") << i18n("Mobile") << i18n("SiP") << i18n("VoIP") <<i18n("Home2")<< i18n("Work2") << i18n("Mobile2") << i18n("SiP2") << i18n("Assistent") << i18n("Company") << i18n("Fax (Home)") << i18n("Fax (Work)") << i18n("Fax (Other)") << i18n("Pager") << i18n("ISDN") << i18n("Callback") << i18n("Primary")<< i18n("Other");
240 return list; 240 return list;
241} 241}
242 242
243int PhoneNumber::typeListIndex4Type(int type ) 243int PhoneNumber::typeListIndex4Type(int type )
244{ 244{
245 TypeList list = supportedTypeList(); 245 TypeList list = supportedTypeList();
246 int i = 0; 246 int i = 0;
247 while ( i < list.count() ) { 247 while ( i < list.count() ) {
248 if ( list [i] == type ) 248 if ( list [i] == type )
249 return i; 249 return i;
250 ++i; 250 ++i;
251 } 251 }
252 return list.count()-1; 252 return list.count()-1;
253} 253}
254 254
255QString PhoneNumber::label( int type ) 255QString PhoneNumber::label( int type )
256{ 256{
257 return typeLabel( type ); 257 return typeLabel( type );
258} 258}
259 259
260QString PhoneNumber::typeLabel( int type ) 260QString PhoneNumber::typeLabel( int type )
261{ 261{
262 if ((type & Cell) == Cell) 262 if ((type & Cell) == Cell)
263 return i18n("Mobile"); 263 return i18n("Mobile");
264 if ((type & Home) == Home) { 264 if ((type & Home) == Home) {
265 if ((type & Pref) == Pref) 265 if ((type & Pref) == Pref)
266 return i18n("Home"); 266 return i18n("Home");
267 if ((type & Fax) == Fax) 267 if ((type & Fax) == Fax)
268 return i18n("Fax (Home)"); 268 return i18n("Fax (Home)");
269 return i18n("Home2"); 269 return i18n("Home2");
270 } 270 }
271 271
272 if ((type & Work) == Work) { 272 if ((type & Work) == Work) {
273 if ((type & Pref) == Pref) 273 if ((type & Pref) == Pref)
274 return i18n("Work"); 274 return i18n("Work");
275 if ((type & Fax) == Fax) 275 if ((type & Fax) == Fax)
276 return i18n("Fax (Work)"); 276 return i18n("Fax (Work)");
277 if ((type & Msg) == Msg) { 277 if ((type & Msg) == Msg) {
278 if ((type & Voice) == Voice) 278 if ((type & Voice) == Voice)
279 return i18n("Assistent"); 279 return i18n("Assistent");
280 return i18n("Company"); 280 return i18n("Company");
281 } 281 }
282 return i18n("Work2"); 282 return i18n("Work2");
283 } 283 }
284 if ((type & Pcs) == Pcs) { 284 if ((type & Pcs) == Pcs) {
285 if ((type & Pref) == Pref) 285 if ((type & Pref) == Pref)
286 return i18n("SiP"); 286 return i18n("SiP");
287 if ((type & Voice) == Voice) 287 if ((type & Voice) == Voice)
288 return i18n("VoIP"); 288 return i18n("VoIP");
289 return i18n("SiP2"); 289 return i18n("SiP2");
290 } 290 }
291 if ((type & Car) == Car) 291 if ((type & Car) == Car)
292 return i18n("Mobile2"); 292 return i18n("Mobile2");
293 if ((type & Pager) == Pager) 293 if ((type & Pager) == Pager)
294 return i18n("Pager"); 294 return i18n("Pager");
295 if ((type & Isdn) == Isdn) 295 if ((type & Isdn) == Isdn)
296 return i18n("ISDN"); 296 return i18n("ISDN");
297 if ((type & Video) == Video) 297 if ((type & Video) == Video)
298 return i18n("Video"); 298 return i18n("Video");
299 299
300 if ((type & Msg) == Msg) 300 if ((type & Msg) == Msg)
301 return i18n("Callback"); 301 return i18n("Callback");
302 if ((type & Fax) == Fax) 302 if ((type & Fax) == Fax)
303 return i18n("Fax (Other)"); 303 return i18n("Fax (Other)");
304 304
305 if ((type & Pref) == Pref) 305 if ((type & Pref) == Pref)
306 return i18n("Primary"); 306 return i18n("Primary");
307 307
308 308
309 return i18n("Other"); 309 return i18n("Other");
310 310
311 311
312#if 0 312#if 0
313 313
314 314
315 315
316 QString typeString; 316 QString typeString;
317 317
318 318
319 if ((type & Cell) == Cell) 319 if ((type & Cell) == Cell)
320 typeString += i18n("Mobile") +" "; 320 typeString += i18n("Mobile") +" ";
321 if ((type & Home) == Home) 321 if ((type & Home) == Home)
322 typeString += i18n("Home")+" "; 322 typeString += i18n("Home")+" ";
323 else if ((type & Work) == Work) 323 else if ((type & Work) == Work)
324 typeString += i18n("Work")+" "; 324 typeString += i18n("Work")+" ";
325 325
326 if ((type & Sip) == Sip) 326 if ((type & Sip) == Sip)
327 typeString += i18n("SIP")+" "; 327 typeString += i18n("SIP")+" ";
328 if ((type & Car) == Car) 328 if ((type & Car) == Car)
329 typeString += i18n("Car")+" "; 329 typeString += i18n("Car")+" ";
330 330
331 if ((type & Fax) == Fax) 331 if ((type & Fax) == Fax)
332 typeString += i18n("Fax"); 332 typeString += i18n("Fax");
333 else if ((type & Msg) == Msg) 333 else if ((type & Msg) == Msg)
334 typeString += i18n("Messenger"); 334 typeString += i18n("Messenger");
335 else if ((type & Video) == Video) 335 else if ((type & Video) == Video)
336 typeString += i18n("Video"); 336 typeString += i18n("Video");
337 else if ((type & Bbs) == Bbs) 337 else if ((type & Bbs) == Bbs)
338 typeString += i18n("Mailbox"); 338 typeString += i18n("Mailbox");
339 else if ((type & Modem) == Modem) 339 else if ((type & Modem) == Modem)
340 typeString += i18n("Modem"); 340 typeString += i18n("Modem");
341 else if ((type & Isdn) == Isdn) 341 else if ((type & Isdn) == Isdn)
342 typeString += i18n("ISDN"); 342 typeString += i18n("ISDN");
343 else if ((type & Pcs) == Pcs) 343 else if ((type & Pcs) == Pcs)
344 typeString += i18n("PCS"); 344 typeString += i18n("PCS");
345 else if ((type & Pager) == Pager) 345 else if ((type & Pager) == Pager)
346 typeString += i18n("Pager"); 346 typeString += i18n("Pager");
347 // add the prefered flag 347 // add the prefered flag
348 /* 348 /*
349 if ((type & Pref) == Pref) 349 if ((type & Pref) == Pref)
350 typeString += i18n("(p)"); 350 typeString += i18n("(p)");
351 */ 351 */
352 //if we still have no match, return "other" 352 //if we still have no match, return "other"
353 if (typeString.isEmpty()) { 353 if (typeString.isEmpty()) {
354 if ((type & Voice) == Voice) 354 if ((type & Voice) == Voice)
355 return i18n("Voice"); 355 return i18n("Voice");
356 else 356 else
357 return i18n("Other"); 357 return i18n("Other");
358 } 358 }
359 359
360 return typeString.stripWhiteSpace(); 360 return typeString.stripWhiteSpace();
361#endif 361#endif
362} 362}
363 363
364QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone ) 364QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone )
365{ 365{
366 return s << phone.mId << phone.mType << phone.mNumber; 366 return s << phone.mId << phone.mType << phone.mNumber;
367} 367}
368 368
369QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone ) 369QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone )
370{ 370{
371 s >> phone.mId >> phone.mType >> phone.mNumber; 371 s >> phone.mId >> phone.mType >> phone.mNumber;
372 372
373 return s; 373 return s;
374} 374}
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp
index fe9ff5a..141a9ce 100644
--- a/kalarmd/simplealarmdaemonimpl.cpp
+++ b/kalarmd/simplealarmdaemonimpl.cpp
@@ -1,734 +1,734 @@
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 70
71 mBeepPopUp = new QPopupMenu( this ); 71 mBeepPopUp = new QPopupMenu( this );
72 mSoundPopUp = new QPopupMenu( this ); 72 mSoundPopUp = new QPopupMenu( this );
73 mPausePopUp = new QPopupMenu( this ); 73 mPausePopUp = new QPopupMenu( this );
74 mFontsizePopup = new QPopupMenu( this ); 74 mFontsizePopup = new QPopupMenu( this );
75 mFontsizePopup->insertItem( "10", 10 ); 75 mFontsizePopup->insertItem( "10", 10 );
76 mFontsizePopup->insertItem( "12", 12 ); 76 mFontsizePopup->insertItem( "12", 12 );
77 mFontsizePopup->insertItem( "14", 14 ); 77 mFontsizePopup->insertItem( "14", 14 );
78 mFontsizePopup->insertItem( "16", 16 ); 78 mFontsizePopup->insertItem( "16", 16 );
79 mFontsizePopup->insertItem( "18", 18 ); 79 mFontsizePopup->insertItem( "18", 18 );
80 mFontsizePopup->insertItem( "20", 20 ); 80 mFontsizePopup->insertItem( "20", 20 );
81 mFontsizePopup->insertItem( "22", 22 ); 81 mFontsizePopup->insertItem( "22", 22 );
82 mFontsizePopup->insertItem( "24", 24 ); 82 mFontsizePopup->insertItem( "24", 24 );
83 mFontsizePopup->insertItem( "26", 26 ); 83 mFontsizePopup->insertItem( "26", 26 );
84 mFontsizePopup->insertItem( "28", 28 ); 84 mFontsizePopup->insertItem( "28", 28 );
85 mFontsizePopup->insertItem( "30", 30 ); 85 mFontsizePopup->insertItem( "30", 30 );
86 mFontsizePopup->insertItem( "32", 32 ); 86 mFontsizePopup->insertItem( "32", 32 );
87 mFontsizePopup->insertItem( "36", 36 ); 87 mFontsizePopup->insertItem( "36", 36 );
88 QPopupMenu* savePopUp = new QPopupMenu( this ); 88 QPopupMenu* savePopUp = new QPopupMenu( this );
89 savePopUp->insertItem( "Save", 0 ); 89 savePopUp->insertItem( "Save", 0 );
90 savePopUp->insertItem( "Load", 1 ); 90 savePopUp->insertItem( "Load", 1 );
91 mSoundPopUp->insertItem( "Buzzer", 0 ); 91 mSoundPopUp->insertItem( "Buzzer", 0 );
92 mSoundPopUp->insertItem( "Wav file", 1 ); 92 mSoundPopUp->insertItem( "Wav file", 1 );
93 mPausePopUp->insertItem( " 1 sec", 1 ); 93 mPausePopUp->insertItem( " 1 sec", 1 );
94 mPausePopUp->insertItem( " 2 sec", 2 ); 94 mPausePopUp->insertItem( " 2 sec", 2 );
95 mPausePopUp->insertItem( " 3 sec", 3 ); 95 mPausePopUp->insertItem( " 3 sec", 3 );
96 mPausePopUp->insertItem( " 5 sec", 5 ); 96 mPausePopUp->insertItem( " 5 sec", 5 );
97 mPausePopUp->insertItem( "10 sec", 10 ); 97 mPausePopUp->insertItem( "10 sec", 10 );
98 mPausePopUp->insertItem( "15 sec", 15 );
98 mPausePopUp->insertItem( "30 sec", 30 ); 99 mPausePopUp->insertItem( "30 sec", 30 );
99 mPausePopUp->insertItem( " 1 min", 60 ); 100 mPausePopUp->insertItem( " 1 min", 60 );
100 mPausePopUp->insertItem( " 5 min", 300 ); 101 mPausePopUp->insertItem( " 5 min", 300 );
101 mPausePopUp->insertItem( "10 min", 600 );
102 mSuspendPopUp = new QPopupMenu( this ); 102 mSuspendPopUp = new QPopupMenu( this );
103 mSuspendPopUp->insertItem( "Off", 0 ); 103 mSuspendPopUp->insertItem( "Off", 0 );
104 mSuspendPopUp->insertItem( " 1x", 1 ); 104 mSuspendPopUp->insertItem( " 1x", 1 );
105 mSuspendPopUp->insertItem( " 2x", 2 ); 105 mSuspendPopUp->insertItem( " 2x", 2 );
106 mSuspendPopUp->insertItem( " 3x", 3 ); 106 mSuspendPopUp->insertItem( " 3x", 3 );
107 mSuspendPopUp->insertItem( " 5x", 5 ); 107 mSuspendPopUp->insertItem( " 5x", 5 );
108 mSuspendPopUp->insertItem( "10x", 10 ); 108 mSuspendPopUp->insertItem( "10x", 10 );
109 mSuspendPopUp->insertItem( "20x", 20 ); 109 mSuspendPopUp->insertItem( "20x", 20 );
110 mSuspendPopUp->insertItem( "30x", 30 ); 110 mSuspendPopUp->insertItem( "30x", 30 );
111 mBeepPopUp->insertItem( "Config",savePopUp ); 111 mBeepPopUp->insertItem( "Config",savePopUp );
112 mBeepPopUp->insertItem( "Replay",mSoundPopUp ); 112 mBeepPopUp->insertItem( "Replay",mSoundPopUp );
113 mBeepPopUp->insertItem( "Font Size",mFontsizePopup ); 113 mBeepPopUp->insertItem( "Font Size",mFontsizePopup );
114 mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp ); 114 mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp );
115 mBeepPopUp->insertItem( "Beep interval",mPausePopUp ); 115 mBeepPopUp->insertItem( "Beep interval",mPausePopUp );
116 mBeepPopUp->insertItem( "180", 180 ); 116 mBeepPopUp->insertItem( "100", 100 );
117 mBeepPopUp->insertItem( "60", 60 ); 117 mBeepPopUp->insertItem( "50", 50 );
118 mBeepPopUp->insertItem( "30", 30 ); 118 mBeepPopUp->insertItem( "25", 25 );
119 mBeepPopUp->insertItem( "17", 17 ); 119 mBeepPopUp->insertItem( "17", 17 );
120 mBeepPopUp->insertItem( "10", 10 ); 120 mBeepPopUp->insertItem( "10", 10 );
121 mBeepPopUp->insertItem( "3", 3 ); 121 mBeepPopUp->insertItem( "3", 3 );
122 mBeepPopUp->insertItem( "1", 1 ); 122 mBeepPopUp->insertItem( "1", 1 );
123 mBeepPopUp->insertItem( "Off", 0 ); 123 mBeepPopUp->insertItem( "Off", 0 );
124 mBeepPopUp->insertSeparator(); 124 mBeepPopUp->insertSeparator();
125 mBeepPopUp->insertItem( "Simulate", 1000 ); 125 mBeepPopUp->insertItem( "Simulate", 1000 );
126 mBeepPopUp->setCheckable( true ); 126 mBeepPopUp->setCheckable( true );
127 mPopUp->insertSeparator(); 127 mPopUp->insertSeparator();
128 mPopUp->insertItem( "Play beeps", mBeepPopUp ); 128 mPopUp->insertItem( "Play beeps", mBeepPopUp );
129 mPopUp->insertSeparator(); 129 mPopUp->insertSeparator();
130 mPopUp->insertItem( "Timer", mTimerPopUp ); 130 mPopUp->insertItem( "Timer", mTimerPopUp );
131 //mPopUp->insertSeparator(); 131 //mPopUp->insertSeparator();
132 //mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) ); 132 //mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) );
133 133
134 mPopUp->resize( mPopUp->sizeHint() ); 134 mPopUp->resize( mPopUp->sizeHint() );
135 mPlayBeeps = 60; 135 mPlayBeeps = 60;
136 mBeepPopUp->setItemChecked ( mPlayBeeps, true ); 136 mBeepPopUp->setItemChecked ( mPlayBeeps, true );
137 connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) ); 137 connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) );
138 connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) ); 138 connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) );
139 connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) ); 139 connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) );
140 connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) ); 140 connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) );
141 connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) ); 141 connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) );
142 connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) ); 142 connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) );
143 connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) ); 143 connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) );
144 connect ( mFontsizePopup, SIGNAL( activated ( int ) ), this, SLOT (confFontSize( int ) ) ); 144 connect ( mFontsizePopup, SIGNAL( activated ( int ) ), this, SLOT (confFontSize( int ) ) );
145 mTimerTime = 0; 145 mTimerTime = 0;
146 mCustomText = "Custom Text"; 146 mCustomText = "Custom Text";
147 mCustomMinutes = 7; 147 mCustomMinutes = 7;
148 mTimerPopupConf = 1; 148 mTimerPopupConf = 1;
149 fillTimerPopUp(); 149 fillTimerPopUp();
150 mPausePlay = 0; 150 mPausePlay = 0;
151 confPause( 1 ); 151 confPause( 1 );
152 mSuspend = 0; 152 mSuspend = 0;
153 confSuspend( 0 ); 153 confSuspend( 0 );
154 if ( QApplication::desktop()->width() < 480 ) { 154 if ( QApplication::desktop()->width() < 480 ) {
155 wavAlarm = false; 155 wavAlarm = false;
156 mSoundPopUp->setItemChecked ( 0, true ); 156 mSoundPopUp->setItemChecked ( 0, true );
157 } 157 }
158 else { 158 else {
159 wavAlarm = true; 159 wavAlarm = true;
160 mSoundPopUp->setItemChecked ( 1, true ); 160 mSoundPopUp->setItemChecked ( 1, true );
161 } 161 }
162 mTimerStartLabel = new QLabel( 0, 0, WType_Popup ); 162 mTimerStartLabel = new QLabel( 0, 0, WType_Popup );
163 //mTimerStartLabel->setCaption( "Timer started!"); 163 //mTimerStartLabel->setCaption( "Timer started!");
164 mTimerStartLabel->setAlignment ( Qt::AlignCenter ) ; 164 mTimerStartLabel->setAlignment ( Qt::AlignCenter ) ;
165 saveSlot( 1 ); 165 saveSlot( 1 );
166 166
167 167
168 168
169} 169}
170 170
171SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl() 171SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl()
172{ 172{
173 //delete mPopUp; 173 //delete mPopUp;
174 delete mAlarmDialog; 174 delete mAlarmDialog;
175 delete mTimerStartLabel; 175 delete mTimerStartLabel;
176} 176}
177 177
178void SimpleAlarmDaemonImpl::saveSlot( int load ) 178void SimpleAlarmDaemonImpl::saveSlot( int load )
179{ 179{
180 QString fileName = QDir::homeDirPath() +"/.kopialarmrc"; 180 QString fileName = QDir::homeDirPath() +"/.kopialarmrc";
181 //qDebug("save %d ", load ); 181 //qDebug("save %d ", load );
182 QFile file( fileName ); 182 QFile file( fileName );
183 if ( load ) { 183 if ( load ) {
184 mPopupFontSize = mTimerPopUp->font().pointSize(); 184 mPopupFontSize = mTimerPopUp->font().pointSize();
185 confFontSize( mPopupFontSize ); 185 confFontSize( mPopupFontSize );
186 if( !QFile::exists( fileName) ) 186 if( !QFile::exists( fileName) )
187 return; 187 return;
188 if (!file.open( IO_ReadOnly ) ) { 188 if (!file.open( IO_ReadOnly ) ) {
189 return ; 189 return ;
190 } 190 }
191 QString line; 191 QString line;
192 bool ok; 192 bool ok;
193 int val; 193 int val;
194 int len; 194 int len;
195 while ( file.readLine( line, 1024 ) > 0 ) { 195 while ( file.readLine( line, 1024 ) > 0 ) {
196 //qDebug("read %s ", line.latin1()); 196 //qDebug("read %s ", line.latin1());
197 len = line.length(); 197 len = line.length();
198 if ( line.left(4 ) == "PPAU" ) { 198 if ( line.left(4 ) == "PPAU" ) {
199 val = line.mid( 4,len-5).toInt( &ok ); 199 val = line.mid( 4,len-5).toInt( &ok );
200 if ( ok ) { 200 if ( ok ) {
201 confPause( val ); 201 confPause( val );
202 } 202 }
203 } 203 }
204 if ( line.left(4 ) == "POFO" ) { 204 if ( line.left(4 ) == "POFO" ) {
205 val = line.mid( 4,len-5).toInt( &ok ); 205 val = line.mid( 4,len-5).toInt( &ok );
206 if ( ok ) { 206 if ( ok ) {
207 confFontSize( val ); 207 confFontSize( val );
208 } 208 }
209 } 209 }
210 if ( line.left(4 ) == "SUCO" ) { 210 if ( line.left(4 ) == "SUCO" ) {
211 val = line.mid( 4,len-5).toInt( &ok ); 211 val = line.mid( 4,len-5).toInt( &ok );
212 if ( ok ) 212 if ( ok )
213 confSuspend ( val ); 213 confSuspend ( val );
214 } 214 }
215 if ( line.left(4 ) == "WAAL" ) { 215 if ( line.left(4 ) == "WAAL" ) {
216 val = line.mid( 4,len-5).toInt( &ok ); 216 val = line.mid( 4,len-5).toInt( &ok );
217 if ( ok ) 217 if ( ok )
218 confSound( val ); 218 confSound( val );
219 219
220 } 220 }
221 if ( line.left(4 ) == "PLBE" ) { 221 if ( line.left(4 ) == "PLBE" ) {
222 val = line.mid( 4,len-5).toInt( &ok ); 222 val = line.mid( 4,len-5).toInt( &ok );
223 if ( ok ) 223 if ( ok )
224 slotPlayBeep( val ); 224 slotPlayBeep( val );
225 225
226 } 226 }
227 if ( line.left(4 ) == "CUTE" ) { 227 if ( line.left(4 ) == "CUTE" ) {
228 mCustomText = line.mid( 5,len-6); 228 mCustomText = line.mid( 5,len-6);
229 // qDebug("text ***%s*** ",mCustomText.latin1() ); 229 // qDebug("text ***%s*** ",mCustomText.latin1() );
230 230
231 } 231 }
232 if ( line.left(4 ) == "CUMI" ) { 232 if ( line.left(4 ) == "CUMI" ) {
233 val = line.mid( 4,len-5).toInt( &ok ); 233 val = line.mid( 4,len-5).toInt( &ok );
234 if ( ok ) 234 if ( ok )
235 mCustomMinutes = val; 235 mCustomMinutes = val;
236 236
237 } 237 }
238 if ( line.left(4 ) == "SUTI" ) { 238 if ( line.left(4 ) == "SUTI" ) {
239 val = line.mid( 4,len-5).toInt( &ok ); 239 val = line.mid( 4,len-5).toInt( &ok );
240 if ( ok ) 240 if ( ok )
241 mAlarmDialog->setSuspendTime( val );; 241 mAlarmDialog->setSuspendTime( val );;
242 242
243 } 243 }
244 } 244 }
245 file.close(); 245 file.close();
246 } else { 246 } else {
247 if (!file.open( IO_WriteOnly ) ) { 247 if (!file.open( IO_WriteOnly ) ) {
248 return; 248 return;
249 } 249 }
250 QString configString ; 250 QString configString ;
251 configString += "PPAU " + QString::number( mPausePlay ) + "\n"; 251 configString += "PPAU " + QString::number( mPausePlay ) + "\n";
252 configString += "SUCO " + QString::number( mSuspend ) + "\n"; 252 configString += "SUCO " + QString::number( mSuspend ) + "\n";
253 configString += "POFO " + QString::number( mPopupFontSize ) + "\n"; 253 configString += "POFO " + QString::number( mPopupFontSize ) + "\n";
254 configString += "WAAL " + QString::number( wavAlarm ) + "\n"; 254 configString += "WAAL " + QString::number( wavAlarm ) + "\n";
255 configString += "PLBE " + QString::number( mPlayBeeps ) + "\n"; 255 configString += "PLBE " + QString::number( mPlayBeeps ) + "\n";
256 configString += "CUTE " + mCustomText + "\n"; 256 configString += "CUTE " + mCustomText + "\n";
257 configString += "CUMI " + QString::number( mCustomMinutes ) + "\n"; 257 configString += "CUMI " + QString::number( mCustomMinutes ) + "\n";
258 configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n"; 258 configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n";
259 QTextStream ts( &file ); 259 QTextStream ts( &file );
260 ts << configString ; 260 ts << configString ;
261 file.close(); 261 file.close();
262 } 262 }
263 263
264} 264}
265void SimpleAlarmDaemonImpl::confSuspend( int num ) 265void SimpleAlarmDaemonImpl::confSuspend( int num )
266{ 266{
267 mSuspendPopUp->setItemChecked ( mSuspend,false ); 267 mSuspendPopUp->setItemChecked ( mSuspend,false );
268 mSuspend = num; 268 mSuspend = num;
269 mSuspendPopUp->setItemChecked ( mSuspend,true ); 269 mSuspendPopUp->setItemChecked ( mSuspend,true );
270} 270}
271void SimpleAlarmDaemonImpl::confPause( int num ) 271void SimpleAlarmDaemonImpl::confPause( int num )
272{ 272{
273 mPausePopUp->setItemChecked ( mPausePlay,false ); 273 mPausePopUp->setItemChecked ( mPausePlay,false );
274 mPausePlay = num; 274 mPausePlay = num;
275 mPausePopUp->setItemChecked ( mPausePlay,true ); 275 mPausePopUp->setItemChecked ( mPausePlay,true );
276} 276}
277void SimpleAlarmDaemonImpl::confSound( int num ) 277void SimpleAlarmDaemonImpl::confSound( int num )
278{ 278{
279 if ( num == 0 ) { 279 if ( num == 0 ) {
280 wavAlarm = false; 280 wavAlarm = false;
281 mSoundPopUp->setItemChecked ( 0, true ); 281 mSoundPopUp->setItemChecked ( 0, true );
282 mSoundPopUp->setItemChecked ( 1, false ); 282 mSoundPopUp->setItemChecked ( 1, false );
283 } else { 283 } else {
284 wavAlarm = true; 284 wavAlarm = true;
285 mSoundPopUp->setItemChecked ( 0, false ); 285 mSoundPopUp->setItemChecked ( 0, false );
286 mSoundPopUp->setItemChecked ( 1, true ); 286 mSoundPopUp->setItemChecked ( 1, true );
287 } 287 }
288} 288}
289void SimpleAlarmDaemonImpl::slotPlayBeep( int num ) 289void SimpleAlarmDaemonImpl::slotPlayBeep( int num )
290{ 290{
291 if ( num == 1000 ) { 291 if ( num == 1000 ) {
292 simulate(); 292 simulate();
293 return; 293 return;
294 } 294 }
295 mBeepPopUp->setItemChecked ( mPlayBeeps,false ); 295 mBeepPopUp->setItemChecked ( mPlayBeeps,false );
296 mPlayBeeps = num; 296 mPlayBeeps = num;
297 mBeepPopUp->setItemChecked ( mPlayBeeps, true ); 297 mBeepPopUp->setItemChecked ( mPlayBeeps, true );
298} 298}
299 299
300void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& ) 300void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& )
301{ 301{
302 //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data()); 302 //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data());
303 QString mess = QString::fromUtf8(msg.data()); 303 QString mess = QString::fromUtf8(msg.data());
304 mAlarmMessage = mess.mid( 9 ); 304 mAlarmMessage = mess.mid( 9 );
305 QString filename = getenv("QPEDIR") ; 305 QString filename = getenv("QPEDIR") ;
306 filename += "/pics/kdepim/korganizer/koalarm.wav"; 306 filename += "/pics/kdepim/korganizer/koalarm.wav";
307 QString tempfilename; 307 QString tempfilename;
308 if ( mess.left( 13 ) == "suspend_alarm") { 308 if ( mess.left( 13 ) == "suspend_alarm") {
309 bool error = false; 309 bool error = false;
310 int len = mess.mid( 13 ).find("+++"); 310 int len = mess.mid( 13 ).find("+++");
311 if ( len < 2 ) 311 if ( len < 2 )
312 error = true; 312 error = true;
313 else { 313 else {
314 tempfilename = mess.mid( 13, len ); 314 tempfilename = mess.mid( 13, len );
315 if ( !QFile::exists( tempfilename ) ) 315 if ( !QFile::exists( tempfilename ) )
316 error = true; 316 error = true;
317 } 317 }
318 if ( ! error ) { 318 if ( ! error ) {
319 filename = tempfilename; 319 filename = tempfilename;
320 } 320 }
321 mAlarmMessage = mess.mid( 13+len+3 ); 321 mAlarmMessage = mess.mid( 13+len+3 );
322 //qDebug("suspend file %s ",tempfilename.latin1() ); 322 //qDebug("suspend file %s ",tempfilename.latin1() );
323 startAlarm( mAlarmMessage, filename); 323 startAlarm( mAlarmMessage, filename);
324 return; 324 return;
325 } 325 }
326 if ( mess.left( 11 ) == "timer_alarm") { 326 if ( mess.left( 11 ) == "timer_alarm") {
327 mTimerTime = 0; 327 mTimerTime = 0;
328 startAlarm( mess.mid( 11 ), filename ); 328 startAlarm( mess.mid( 11 ), filename );
329 return; 329 return;
330 } 330 }
331 if ( mess.left( 10 ) == "proc_alarm") { 331 if ( mess.left( 10 ) == "proc_alarm") {
332 bool error = false; 332 bool error = false;
333 int len = mess.mid( 10 ).find("+++"); 333 int len = mess.mid( 10 ).find("+++");
334 if ( len < 2 ) 334 if ( len < 2 )
335 error = true; 335 error = true;
336 else { 336 else {
337 tempfilename = mess.mid( 10, len ); 337 tempfilename = mess.mid( 10, len );
338 if ( !QFile::exists( tempfilename ) ) 338 if ( !QFile::exists( tempfilename ) )
339 error = true; 339 error = true;
340 } 340 }
341 if ( error ) { 341 if ( error ) {
342 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 342 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
343 mAlarmMessage += mess.mid( 10+len+3+9 ); 343 mAlarmMessage += mess.mid( 10+len+3+9 );
344 } else { 344 } else {
345 //qDebug("-----system command %s ",tempfilename.latin1() ); 345 //qDebug("-----system command %s ",tempfilename.latin1() );
346 if ( vfork () == 0 ) { 346 if ( vfork () == 0 ) {
347 execl ( tempfilename.latin1(), 0 ); 347 execl ( tempfilename.latin1(), 0 );
348 return; 348 return;
349 } 349 }
350 QTimer::singleShot( 2000, this, SLOT ( writeFile() ) ); 350 QTimer::singleShot( 2000, this, SLOT ( writeFile() ) );
351 return; 351 return;
352 } 352 }
353 353
354 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 354 //qDebug("+++++++system command %s ",tempfilename.latin1() );
355 } 355 }
356 if ( mess.left( 11 ) == "audio_alarm") { 356 if ( mess.left( 11 ) == "audio_alarm") {
357 bool error = false; 357 bool error = false;
358 int len = mess.mid( 11 ).find("+++"); 358 int len = mess.mid( 11 ).find("+++");
359 if ( len < 2 ) 359 if ( len < 2 )
360 error = true; 360 error = true;
361 else { 361 else {
362 tempfilename = mess.mid( 11, len ); 362 tempfilename = mess.mid( 11, len );
363 if ( !QFile::exists( tempfilename ) ) 363 if ( !QFile::exists( tempfilename ) )
364 error = true; 364 error = true;
365 } 365 }
366 if ( ! error ) { 366 if ( ! error ) {
367 filename = tempfilename; 367 filename = tempfilename;
368 } 368 }
369 mAlarmMessage = mess.mid( 11+len+3+9 ); 369 mAlarmMessage = mess.mid( 11+len+3+9 );
370 //qDebug("audio file command %s ",tempfilename.latin1() ); 370 //qDebug("audio file command %s ",tempfilename.latin1() );
371 } 371 }
372 if ( mess.left( 9 ) == "cal_alarm") { 372 if ( mess.left( 9 ) == "cal_alarm") {
373 mAlarmMessage = mess.mid( 9 ) ; 373 mAlarmMessage = mess.mid( 9 ) ;
374 } 374 }
375 375
376 QTimer::singleShot( 2000, this, SLOT ( writeFile() ) ); 376 QTimer::singleShot( 2000, this, SLOT ( writeFile() ) );
377 startAlarm( mAlarmMessage, filename ); 377 startAlarm( mAlarmMessage, filename );
378 378
379} 379}
380 380
381int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) 381int SimpleAlarmDaemonImpl::getFileNameLen( QString mess )
382{ 382{
383 return 0; 383 return 0;
384} 384}
385void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) 385void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename )
386{ 386{
387 //mAlarmDialog->show(); 387 //mAlarmDialog->show();
388 //mAlarmDialog->raise(); 388 //mAlarmDialog->raise();
389 mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); 389 mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend );
390} 390}
391 391
392 392
393void SimpleAlarmDaemonImpl::fillTimerPopUp() 393void SimpleAlarmDaemonImpl::fillTimerPopUp()
394{ 394{
395 395
396 // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); 396 // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime );
397 if ( mTimerPopupConf == mTimerTime ) { 397 if ( mTimerPopupConf == mTimerTime ) {
398 if ( mTimerTime ) { 398 if ( mTimerTime ) {
399 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); 399 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer );
400 QTime t ( secs/3600, (secs/60)%60, secs%60 ); 400 QTime t ( secs/3600, (secs/60)%60, secs%60 );
401 mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)"); 401 mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)");
402 } 402 }
403 else { 403 else {
404 QString text = mCustomText.stripWhiteSpace (); 404 QString text = mCustomText.stripWhiteSpace ();
405 int in = text.find( " " ); 405 int in = text.find( " " );
406 text = text.left ( in ); 406 text = text.left ( in );
407 mTimerPopUp->changeItem ( 3, text ); 407 mTimerPopUp->changeItem ( 3, text );
408 } 408 }
409 return; 409 return;
410 } 410 }
411 mTimerPopupConf = mTimerTime; 411 mTimerPopupConf = mTimerTime;
412 mTimerPopUp->clear(); 412 mTimerPopUp->clear();
413 if ( mTimerTime ) { 413 if ( mTimerTime ) {
414 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); 414 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer );
415 QTime t ( secs/3600, (secs/60)%60, secs%60 ); 415 QTime t ( secs/3600, (secs/60)%60, secs%60 );
416 416
417 417
418 mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 ); 418 mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 );
419 mTimerPopUp->insertItem( t.toString() + " (countdown)",1); 419 mTimerPopUp->insertItem( t.toString() + " (countdown)",1);
420 mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm)",2); 420 mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm)",2);
421 } else { 421 } else {
422 422
423 QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc"; 423 QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc";
424 QFile file( fileName ); 424 QFile file( fileName );
425 if( !QFile::exists( fileName) ) { 425 if( !QFile::exists( fileName) ) {
426 // write defaults 426 // write defaults
427 if (!file.open( IO_WriteOnly ) ) { 427 if (!file.open( IO_WriteOnly ) ) {
428 return; 428 return;
429 } 429 }
430 QString configString ; 430 QString configString ;
431 configString += "#config file for kopi alarm timer\n"; 431 configString += "#config file for kopi alarm timer\n";
432 configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n"; 432 configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n";
433 configString += "24 hours; 1440\n"; 433 configString += "24 hours; 1440\n";
434 configString += "9 hours; 540\n"; 434 configString += "9 hours; 540\n";
435 configString += "8 hours; 480\n"; 435 configString += "8 hours; 480\n";
436 configString += "1 hour; 60\n"; 436 configString += "1 hour; 60\n";
437 configString += "30 min; 30\n"; 437 configString += "30 min; 30\n";
438 configString += "15 min; 15\n"; 438 configString += "15 min; 15\n";
439 configString += "SEPARATOR\n"; 439 configString += "SEPARATOR\n";
440 configString += "Pizza; 22\n"; 440 configString += "Pizza; 22\n";
441 configString += "Nap; 45\n"; 441 configString += "Nap; 45\n";
442 configString += "Tea; 5\n"; 442 configString += "Tea; 5\n";
443 QTextStream ts( &file ); 443 QTextStream ts( &file );
444 ts << configString ; 444 ts << configString ;
445 file.close(); 445 file.close();
446 } 446 }
447 447
448 if (!file.open( IO_ReadOnly ) ) { 448 if (!file.open( IO_ReadOnly ) ) {
449 return ; 449 return ;
450 } 450 }
451 QString line; 451 QString line;
452 bool ok; 452 bool ok;
453 while ( file.readLine( line, 1024 ) > 0 ) { 453 while ( file.readLine( line, 1024 ) > 0 ) {
454 //qDebug("read %s ", line.latin1()); 454 //qDebug("read %s ", line.latin1());
455 if ( line.left(1 ) != "#" ) { 455 if ( line.left(1 ) != "#" ) {
456 // no comment 456 // no comment
457 if ( line.left(9 ) == "SEPARATOR" ) { 457 if ( line.left(9 ) == "SEPARATOR" ) {
458 mTimerPopUp->insertSeparator(); 458 mTimerPopUp->insertSeparator();
459 } else { 459 } else {
460 QStringList li = QStringList::split(";",line); 460 QStringList li = QStringList::split(";",line);
461 ok = false; 461 ok = false;
462 if ( li.count() == 2 ) { 462 if ( li.count() == 2 ) {
463 int val = li[1].toInt( &ok ); 463 int val = li[1].toInt( &ok );
464 if ( ok && val > 0 ) { 464 if ( ok && val > 0 ) {
465 mTimerPopUp->insertItem( li[0], val+10); 465 mTimerPopUp->insertItem( li[0], val+10);
466 } 466 }
467 } 467 }
468 } 468 }
469 } 469 }
470 } 470 }
471 file.close(); 471 file.close();
472#if 0 472#if 0
473 mTimerPopUp->insertItem( "24 hours", 1440 ); 473 mTimerPopUp->insertItem( "24 hours", 1440 );
474 // mTimerPopUp->insertItem( i18n("12 h"), 720 ); 474 // mTimerPopUp->insertItem( i18n("12 h"), 720 );
475 mTimerPopUp->insertItem( " 8 hours", 480 ); 475 mTimerPopUp->insertItem( " 8 hours", 480 );
476 mTimerPopUp->insertItem( " 5 hours", 300 ); 476 mTimerPopUp->insertItem( " 5 hours", 300 );
477 // mTimerPopUp->insertItem( i18n(" 2 h"), 120 ); 477 // mTimerPopUp->insertItem( i18n(" 2 h"), 120 );
478 mTimerPopUp->insertItem( " 1 hour", 60 ); 478 mTimerPopUp->insertItem( " 1 hour", 60 );
479 mTimerPopUp->insertItem( "30 min", 30 ); 479 mTimerPopUp->insertItem( "30 min", 30 );
480 mTimerPopUp->insertItem( "15 min", 15 ); 480 mTimerPopUp->insertItem( "15 min", 15 );
481 mTimerPopUp->insertItem( "10 min", 10 ); 481 mTimerPopUp->insertItem( "10 min", 10 );
482 //mTimerPopUp->insertItem( " 5 min", 5 ); 482 //mTimerPopUp->insertItem( " 5 min", 5 );
483 mTimerPopUp->insertSeparator(); 483 mTimerPopUp->insertSeparator();
484 mTimerPopUp->insertItem( "Pizza", 22 ); 484 mTimerPopUp->insertItem( "Pizza", 22 );
485 mTimerPopUp->insertItem( "Nap", 45 ); 485 mTimerPopUp->insertItem( "Nap", 45 );
486 mTimerPopUp->insertItem( "Tea", 5 ); 486 mTimerPopUp->insertItem( "Tea", 5 );
487#endif 487#endif
488 QString text = mCustomText.stripWhiteSpace (); 488 QString text = mCustomText.stripWhiteSpace ();
489 int in = text.find( " " ); 489 int in = text.find( " " );
490 text = text.left ( in ); 490 text = text.left ( in );
491 mTimerPopUp->insertItem( text, 3 ); 491 mTimerPopUp->insertItem( text, 3 );
492 mTimerPopUp->insertSeparator(); 492 mTimerPopUp->insertSeparator();
493 mTimerPopUp->insertItem( "Customize", 2 ); 493 mTimerPopUp->insertItem( "Customize", 2 );
494 } 494 }
495 495
496} 496}
497 497
498void SimpleAlarmDaemonImpl::showTimer() 498void SimpleAlarmDaemonImpl::showTimer()
499{ 499{
500 fillTimerPopUp(); 500 fillTimerPopUp();
501} 501}
502 502
503void SimpleAlarmDaemonImpl::confTimer( int time ) 503void SimpleAlarmDaemonImpl::confTimer( int time )
504{ 504{
505 //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time ); 505 //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time );
506 int minutes = time; 506 int minutes = time;
507 if ( minutes == 0 ) { 507 if ( minutes == 0 ) {
508 if ( ! mTimerTime ) 508 if ( ! mTimerTime )
509 return; 509 return;
510 510
511 QDialog dia ( 0, ("Stop Timer" ), true ); 511 QDialog dia ( 0, ("Stop Timer" ), true );
512 QLabel lab (("Really stop the timer?\n\n"+ mRunningTimerText+"\n"), &dia ); 512 QLabel lab (("Really stop the timer?\n\n"+ mRunningTimerText+"\n"), &dia );
513 lab.setAlignment( AlignCenter ); 513 lab.setAlignment( AlignCenter );
514 dia.setCaption(("KO/Pi Timer Stop" )); 514 dia.setCaption(("KO/Pi Timer Stop" ));
515 QVBoxLayout lay( &dia ); 515 QVBoxLayout lay( &dia );
516 lay.addWidget( &lab); 516 lay.addWidget( &lab);
517 QPushButton ok ( "Stop timer!", &dia); 517 QPushButton ok ( "Stop timer!", &dia);
518 QFont fo = dia.font(); 518 QFont fo = dia.font();
519 fo.setPointSize( 36 ); 519 fo.setPointSize( 36 );
520 ok.setFont( fo ); 520 ok.setFont( fo );
521 lay.addWidget( &ok); 521 lay.addWidget( &ok);
522 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); 522 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) );
523 QPushButton con ( "Continue timer!", &dia); 523 QPushButton con ( "Continue timer!", &dia);
524 fo.setPointSize( 36 ); 524 fo.setPointSize( 36 );
525 con.setFont( fo ); 525 con.setFont( fo );
526 lay.addWidget( &con); 526 lay.addWidget( &con);
527 connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) ); 527 connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) );
528 lay.setMargin(5); 528 lay.setMargin(5);
529 lay.setSpacing(5); 529 lay.setSpacing(5);
530 dia.resize(dia.sizeHint() ); 530 dia.resize(dia.sizeHint() );
531 531
532 if ( !dia.exec() ) 532 if ( !dia.exec() )
533 return; 533 return;
534 534
535 AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.utf8() ); 535 AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.utf8() );
536 mTimerTime = 0; 536 mTimerTime = 0;
537 return; 537 return;
538 } 538 }
539 if ( mTimerTime ) 539 if ( mTimerTime )
540 return; 540 return;
541 if ( minutes == 1 ) { 541 if ( minutes == 1 ) {
542 return; 542 return;
543 } 543 }
544 QString mess = "timer_alarm"; 544 QString mess = "timer_alarm";
545 QString disp; 545 QString disp;
546 mess += ("Timer Alarm!\n"); 546 mess += ("Timer Alarm!\n");
547 if ( minutes == 3 ) { 547 if ( minutes == 3 ) {
548 mess += mCustomText; 548 mess += mCustomText;
549 minutes = mCustomMinutes ; 549 minutes = mCustomMinutes ;
550 mRunningTimerText = mCustomText.stripWhiteSpace (); 550 mRunningTimerText = mCustomText.stripWhiteSpace ();
551 int in = mRunningTimerText.find( " " ); 551 int in = mRunningTimerText.find( " " );
552 mRunningTimerText = mRunningTimerText.left ( in ); 552 mRunningTimerText = mRunningTimerText.left ( in );
553 disp = mCustomText; 553 disp = mCustomText;
554 } 554 }
555 else { 555 else {
556 if ( minutes == 2 ) { 556 if ( minutes == 2 ) {
557 // ask time 557 // ask time
558 QDialog dia ( 0, ("Customize Timer" ), true ); 558 QDialog dia ( 0, ("Customize Timer" ), true );
559 QLabel lab (("Message Text:"), &dia ); 559 QLabel lab (("Message Text:"), &dia );
560 dia.setCaption(("KO/Pi Timer" )); 560 dia.setCaption(("KO/Pi Timer" ));
561 QVBoxLayout lay( &dia ); 561 QVBoxLayout lay( &dia );
562 lay.setMargin(5); 562 lay.setMargin(5);
563 lay.setSpacing(5); 563 lay.setSpacing(5);
564 lay.addWidget( &lab); 564 lay.addWidget( &lab);
565 QLineEdit lEdit( mCustomText, &dia ); 565 QLineEdit lEdit( mCustomText, &dia );
566 lay.addWidget( &lEdit); 566 lay.addWidget( &lEdit);
567 QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia ); 567 QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia );
568 lay.addWidget( &lab2); 568 lay.addWidget( &lab2);
569 QHBox hbox1 ( &dia ); 569 QHBox hbox1 ( &dia );
570 lay.addWidget( &hbox1); 570 lay.addWidget( &hbox1);
571 QLabel lab3 (("Hours"), &hbox1 ); 571 QLabel lab3 (("Hours"), &hbox1 );
572 QLabel lab4 (("Minutes"), &hbox1 ); 572 QLabel lab4 (("Minutes"), &hbox1 );
573 QHBox hbox ( &dia ); 573 QHBox hbox ( &dia );
574 QSpinBox spinh( 0, 24, 1,& hbox ); 574 QSpinBox spinh( 0, 24, 1,& hbox );
575 QFont fo = dia.font(); 575 QFont fo = dia.font();
576 fo.setPointSize( 36 ); 576 fo.setPointSize( 36 );
577 QSpinBox spinm( 0, 59, 1,&hbox ); 577 QSpinBox spinm( 0, 59, 1,&hbox );
578 spinm.setFont( fo ); 578 spinm.setFont( fo );
579 spinh.setFont( fo ); 579 spinh.setFont( fo );
580 spinh.setButtonSymbols( QSpinBox::PlusMinus ); 580 spinh.setButtonSymbols( QSpinBox::PlusMinus );
581 spinm.setButtonSymbols( QSpinBox::PlusMinus ); 581 spinm.setButtonSymbols( QSpinBox::PlusMinus );
582 spinh.upButton ()->setFixedSize( QSize( 48, 30 )); 582 spinh.upButton ()->setFixedSize( QSize( 48, 30 ));
583 spinh.downButton ()->setFixedSize( QSize( 48, 30 )); 583 spinh.downButton ()->setFixedSize( QSize( 48, 30 ));
584 //spinh.editor ()->setFixedSize( QSize( 50, 100 )); 584 //spinh.editor ()->setFixedSize( QSize( 50, 100 ));
585 spinh.setFixedSize( 100,62 ); 585 spinh.setFixedSize( 100,62 );
586 spinm.upButton ()->setFixedSize( QSize( 48, 30 )); 586 spinm.upButton ()->setFixedSize( QSize( 48, 30 ));
587 spinm.downButton ()->setFixedSize( QSize( 48, 30 )); 587 spinm.downButton ()->setFixedSize( QSize( 48, 30 ));
588 spinm.downButton ()->setGeometry( 50,50,50,50); 588 spinm.downButton ()->setGeometry( 50,50,50,50);
589 // spinm.setSuffix( " m" ); 589 // spinm.setSuffix( " m" );
590 //spinh.setSuffix( " h" ); 590 //spinh.setSuffix( " h" );
591 spinm.setWrapping ( true ); 591 spinm.setWrapping ( true );
592 //spinm.editor ()->setFixedSize( QSize( 50, 100 )); 592 //spinm.editor ()->setFixedSize( QSize( 50, 100 ));
593 spinm.setLineStep( 1 ); 593 spinm.setLineStep( 1 );
594 spinm.setFixedSize( 110,62 ); 594 spinm.setFixedSize( 110,62 );
595 lay.addWidget( &hbox); 595 lay.addWidget( &hbox);
596 QLabel lab5 ("Timer fires at:", &dia ); 596 QLabel lab5 ("Timer fires at:", &dia );
597 lab5.setAlignment( AlignCenter ); 597 lab5.setAlignment( AlignCenter );
598 lay.addWidget( &lab5); 598 lay.addWidget( &lab5);
599 KODateLabel dl ( &dia ); 599 KODateLabel dl ( &dia );
600 dl.setAlignment( AlignCenter ); 600 dl.setAlignment( AlignCenter );
601 dl.setFont( fo ); 601 dl.setFont( fo );
602 connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) ); 602 connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) );
603 connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) ); 603 connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) );
604 lay.addWidget( &dl); 604 lay.addWidget( &dl);
605 spinh.setValue( mCustomMinutes/60 ); 605 spinh.setValue( mCustomMinutes/60 );
606 spinm.setValue( mCustomMinutes%60 ); 606 spinm.setValue( mCustomMinutes%60 );
607 QPushButton ok ( "Start timer", &dia); 607 QPushButton ok ( "Start timer", &dia);
608 ok.setDefault( true ); 608 ok.setDefault( true );
609 ok.setFont( fo ); 609 ok.setFont( fo );
610 spinh.setFocus(); 610 spinh.setFocus();
611 lay.addWidget( &ok); 611 lay.addWidget( &ok);
612 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); 612 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) );
613 dia.resize( dia.sizeHint().width(), dia.sizeHint().height() ); 613 dia.resize( dia.sizeHint().width(), dia.sizeHint().height() );
614 614
615 if ( !dia.exec() ) 615 if ( !dia.exec() )
616 return; 616 return;
617 mCustomText = lEdit.text(); 617 mCustomText = lEdit.text();
618 mCustomMinutes = spinh.value()*60+spinm.value(); 618 mCustomMinutes = spinh.value()*60+spinm.value();
619 if ( mCustomMinutes == 0 ) 619 if ( mCustomMinutes == 0 )
620 mCustomMinutes = 1; 620 mCustomMinutes = 1;
621 if ( mCustomMinutes > 1440 ) 621 if ( mCustomMinutes > 1440 )
622 mCustomMinutes = 1440; 622 mCustomMinutes = 1440;
623 mess += mCustomText; 623 mess += mCustomText;
624 disp = mCustomText; 624 disp = mCustomText;
625 minutes = mCustomMinutes; 625 minutes = mCustomMinutes;
626 mRunningTimerText = mCustomText.stripWhiteSpace (); 626 mRunningTimerText = mCustomText.stripWhiteSpace ();
627 int in = mRunningTimerText.find( " " ); 627 int in = mRunningTimerText.find( " " );
628 mRunningTimerText = mRunningTimerText.left ( in ); 628 mRunningTimerText = mRunningTimerText.left ( in );
629 } 629 }
630 else { 630 else {
631 mess += mTimerPopUp->text( minutes ); 631 mess += mTimerPopUp->text( minutes );
632 disp = mTimerPopUp->text( minutes ); 632 disp = mTimerPopUp->text( minutes );
633 mRunningTimerText = mTimerPopUp->text( minutes ); 633 mRunningTimerText = mTimerPopUp->text( minutes );
634 minutes -= 10; 634 minutes -= 10;
635 } 635 }
636 } 636 }
637 //minutes = 1; 637 //minutes = 1;
638 638
639 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); 639 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 );
640 timerMesssage = mess; 640 timerMesssage = mess;
641 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.utf8()); 641 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.utf8());
642 mTimerStartLabel->setText( disp + "\n\nTimer started!" ); 642 mTimerStartLabel->setText( disp + "\n\nTimer started!" );
643 int w = mTimerStartLabel->sizeHint().width()+20; 643 int w = mTimerStartLabel->sizeHint().width()+20;
644 int h = mTimerStartLabel->sizeHint().height()+40 ; 644 int h = mTimerStartLabel->sizeHint().height()+40 ;
645 int dw = QApplication::desktop()->width(); 645 int dw = QApplication::desktop()->width();
646 int dh = QApplication::desktop()->height(); 646 int dh = QApplication::desktop()->height();
647 mTimerStartLabel->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 647 mTimerStartLabel->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
648 mTimerStartLabel->show(); 648 mTimerStartLabel->show();
649 QTimer::singleShot( 4000, mTimerStartLabel, SLOT ( hide() ) ); 649 QTimer::singleShot( 4000, mTimerStartLabel, SLOT ( hide() ) );
650 mTimerTime = 1; 650 mTimerTime = 1;
651} 651}
652 652
653void SimpleAlarmDaemonImpl::confFontSize( int size ) 653void SimpleAlarmDaemonImpl::confFontSize( int size )
654{ 654{
655 655
656 mFontsizePopup->setItemChecked( mPopupFontSize, false ); 656 mFontsizePopup->setItemChecked( mPopupFontSize, false );
657 mPopupFontSize = size; 657 mPopupFontSize = size;
658 mFontsizePopup->setItemChecked( mPopupFontSize, true ); 658 mFontsizePopup->setItemChecked( mPopupFontSize, true );
659 QFont fon = mTimerPopUp->font(); 659 QFont fon = mTimerPopUp->font();
660 fon.setPointSize( mPopupFontSize ); 660 fon.setPointSize( mPopupFontSize );
661 mTimerPopUp->setFont( fon ); 661 mTimerPopUp->setFont( fon );
662 mPopUp->setFont( fon ); 662 mPopUp->setFont( fon );
663 fon.setBold( true ); 663 fon.setBold( true );
664 fon.setPointSize( mPopupFontSize * 2 ); 664 fon.setPointSize( mPopupFontSize * 2 );
665 mTimerStartLabel->setFont( fon ); 665 mTimerStartLabel->setFont( fon );
666} 666}
667void SimpleAlarmDaemonImpl::writeFile() 667void SimpleAlarmDaemonImpl::writeFile()
668{ 668{
669 QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 669 QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
670 //QCopEnvelope e("QPE/Application/kopi", "-writeFile"); 670 //QCopEnvelope e("QPE/Application/kopi", "-writeFile");
671} 671}
672void SimpleAlarmDaemonImpl::showWN() 672void SimpleAlarmDaemonImpl::showWN()
673{ 673{
674 QCopEnvelope e("QPE/Application/kopi", "-showWN"); 674 QCopEnvelope e("QPE/Application/kopi", "-showWN");
675} 675}
676void SimpleAlarmDaemonImpl::newTodo() 676void SimpleAlarmDaemonImpl::newTodo()
677{ 677{
678 QCopEnvelope e("QPE/Application/kopi", "-newTodo"); 678 QCopEnvelope e("QPE/Application/kopi", "-newTodo");
679} 679}
680 680
681void SimpleAlarmDaemonImpl::newEvent() 681void SimpleAlarmDaemonImpl::newEvent()
682{ 682{
683 QCopEnvelope e("QPE/Application/kopi", "-newEvent"); 683 QCopEnvelope e("QPE/Application/kopi", "-newEvent");
684 684
685} 685}
686void SimpleAlarmDaemonImpl::newMail() 686void SimpleAlarmDaemonImpl::newMail()
687{ 687{
688 QCopEnvelope e("QPE/Application/ompi", "newMail()"); 688 QCopEnvelope e("QPE/Application/ompi", "newMail()");
689} 689}
690void SimpleAlarmDaemonImpl::showAdd() 690void SimpleAlarmDaemonImpl::showAdd()
691{ 691{
692 QCopEnvelope e("QPE/Application/kapi", "raise()"); 692 QCopEnvelope e("QPE/Application/kapi", "raise()");
693} 693}
694void SimpleAlarmDaemonImpl::ringSync() 694void SimpleAlarmDaemonImpl::ringSync()
695{ 695{
696 QCopEnvelope e("QPE/Application/kopi", "-ringSync"); 696 QCopEnvelope e("QPE/Application/kopi", "-ringSync");
697 697
698} 698}
699void SimpleAlarmDaemonImpl::newCountdown() 699void SimpleAlarmDaemonImpl::newCountdown()
700{ 700{
701 //recieve("cal_alarm", 10 ); 701 //recieve("cal_alarm", 10 );
702} 702}
703void SimpleAlarmDaemonImpl::simulate() 703void SimpleAlarmDaemonImpl::simulate()
704{ 704{
705 QTimer::singleShot( 2000, this, SLOT ( writeFile() ) ); 705 QTimer::singleShot( 2000, this, SLOT ( writeFile() ) );
706 QString filename = getenv("QPEDIR") ; 706 QString filename = getenv("QPEDIR") ;
707 filename += "/pics/kdepim/korganizer/koalarm.wav"; 707 filename += "/pics/kdepim/korganizer/koalarm.wav";
708 startAlarm("Alarm simulation", filename ); 708 startAlarm("Alarm simulation", filename );
709} 709}
710void SimpleAlarmDaemonImpl::showKO() 710void SimpleAlarmDaemonImpl::showKO()
711{ 711{
712 QCopEnvelope e("QPE/Application/kopi", "-showKO"); 712 QCopEnvelope e("QPE/Application/kopi", "-showKO");
713 // testing only 713 // testing only
714 //QCopEnvelope e("QPE/Application/kopi", "nextView()"); 714 //QCopEnvelope e("QPE/Application/kopi", "nextView()");
715 715
716} 716}
717void SimpleAlarmDaemonImpl::showTodo() 717void SimpleAlarmDaemonImpl::showTodo()
718{ 718{
719 QCopEnvelope e("QPE/Application/kopi", "-showTodo"); 719 QCopEnvelope e("QPE/Application/kopi", "-showTodo");
720 720
721} 721}
722void SimpleAlarmDaemonImpl::writeJournal() 722void SimpleAlarmDaemonImpl::writeJournal()
723{ 723{
724 QCopEnvelope e("QPE/Application/kopi", "-showJournal"); 724 QCopEnvelope e("QPE/Application/kopi", "-showJournal");
725 725
726} 726}
727 727
728void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) 728void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * )
729{ 729{
730 730
731 mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); 731 mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() )));
732 732
733} 733}
734 734