-rw-r--r-- | library/alarmserver.cpp | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/library/alarmserver.cpp b/library/alarmserver.cpp index 177a0cb..02bca3d 100644 --- a/library/alarmserver.cpp +++ b/library/alarmserver.cpp | |||
@@ -1,97 +1,95 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include <qdir.h> | 21 | #include <qdir.h> |
22 | #include <qfile.h> | 22 | #include <qfile.h> |
23 | #include <qmessagebox.h> | 23 | #include <qmessagebox.h> |
24 | #include <qtextstream.h> | 24 | #include <qtextstream.h> |
25 | 25 | ||
26 | 26 | ||
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include "global.h" | 28 | #include "global.h" |
29 | #include "resource.h" | 29 | #include "resource.h" |
30 | 30 | ||
31 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | ||
32 | #include <qpe/qcopenvelope_qws.h> | 31 | #include <qpe/qcopenvelope_qws.h> |
33 | #endif | ||
34 | #include "alarmserver.h" | 32 | #include "alarmserver.h" |
35 | #include <qpe/timeconversion.h> | 33 | #include <qpe/timeconversion.h> |
36 | 34 | ||
37 | #include <sys/types.h> | 35 | #include <sys/types.h> |
38 | #include <sys/stat.h> | 36 | #include <sys/stat.h> |
39 | 37 | ||
40 | #include <stdlib.h> | 38 | #include <stdlib.h> |
41 | #include <unistd.h> | 39 | #include <unistd.h> |
42 | 40 | ||
43 | struct timerEventItem { | 41 | struct timerEventItem { |
44 | time_t UTCtime; | 42 | time_t UTCtime; |
45 | QCString channel, message; | 43 | QCString channel, message; |
46 | int data; | 44 | int data; |
47 | bool operator==( const timerEventItem &right ) const | 45 | bool operator==( const timerEventItem &right ) const |
48 | { | 46 | { |
49 | return ( UTCtime == right.UTCtime | 47 | return ( UTCtime == right.UTCtime |
50 | && channel == right.channel | 48 | && channel == right.channel |
51 | && message == right.message | 49 | && message == right.message |
52 | && data == right.data ); | 50 | && data == right.data ); |
53 | } | 51 | } |
54 | }; | 52 | }; |
55 | 53 | ||
56 | class TimerReceiverObject : public QObject | 54 | class TimerReceiverObject : public QObject |
57 | { | 55 | { |
58 | public: | 56 | public: |
59 | TimerReceiverObject() { } | 57 | TimerReceiverObject() { } |
60 | ~TimerReceiverObject() { } | 58 | ~TimerReceiverObject() { } |
61 | void resetTimer(); | 59 | void resetTimer(); |
62 | void setTimerEventItem(); | 60 | void setTimerEventItem(); |
63 | void deleteTimer(); | 61 | void deleteTimer(); |
64 | protected: | 62 | protected: |
65 | void timerEvent( QTimerEvent *te ); | 63 | void timerEvent( QTimerEvent *te ); |
66 | private: | 64 | private: |
67 | QString atfilename; | 65 | QString atfilename; |
68 | }; | 66 | }; |
69 | 67 | ||
70 | TimerReceiverObject *timerEventReceiver = NULL; | 68 | TimerReceiverObject *timerEventReceiver = NULL; |
71 | QList<timerEventItem> timerEventList; | 69 | QList<timerEventItem> timerEventList; |
72 | timerEventItem *nearestTimerEvent = NULL; | 70 | timerEventItem *nearestTimerEvent = NULL; |
73 | 71 | ||
74 | 72 | ||
75 | // set the timer to go off on the next event in the list | 73 | // set the timer to go off on the next event in the list |
76 | void setNearestTimerEvent() | 74 | void setNearestTimerEvent() |
77 | { | 75 | { |
78 | nearestTimerEvent = NULL; | 76 | nearestTimerEvent = NULL; |
79 | QListIterator<timerEventItem> it( timerEventList ); | 77 | QListIterator<timerEventItem> it( timerEventList ); |
80 | if ( *it ) | 78 | if ( *it ) |
81 | nearestTimerEvent = *it; | 79 | nearestTimerEvent = *it; |
82 | for ( ; *it; ++it ) | 80 | for ( ; *it; ++it ) |
83 | if ( (*it)->UTCtime < nearestTimerEvent->UTCtime ) | 81 | if ( (*it)->UTCtime < nearestTimerEvent->UTCtime ) |
84 | nearestTimerEvent = *it; | 82 | nearestTimerEvent = *it; |
85 | if (nearestTimerEvent) | 83 | if (nearestTimerEvent) |
86 | timerEventReceiver->resetTimer(); | 84 | timerEventReceiver->resetTimer(); |
87 | else | 85 | else |
88 | timerEventReceiver->deleteTimer(); | 86 | timerEventReceiver->deleteTimer(); |
89 | } | 87 | } |
90 | 88 | ||
91 | 89 | ||
92 | //store current state to file | 90 | //store current state to file |
93 | //Simple implementation. Should run on a timer. | 91 | //Simple implementation. Should run on a timer. |
94 | 92 | ||
95 | static void saveState() | 93 | static void saveState() |
96 | { | 94 | { |
97 | QString savefilename = Global::applicationFileName( "AlarmServer", "saveFile" ); | 95 | QString savefilename = Global::applicationFileName( "AlarmServer", "saveFile" ); |