author | kergoth <kergoth> | 2002-11-06 04:50:40 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2002-11-06 04:50:40 (UTC) |
commit | 21f27ec4a1f18321ac00d28d93cb1cb7dc957d1f (patch) (unidiff) | |
tree | bbe53dd1f3749541be4f1616f20d9a0d9ee6ea0b /library/alarmserver.cpp | |
parent | ac1509552bf764ff136690e0e7014d37a59d073e (diff) | |
download | opie-21f27ec4a1f18321ac00d28d93cb1cb7dc957d1f.zip opie-21f27ec4a1f18321ac00d28d93cb1cb7dc957d1f.tar.gz opie-21f27ec4a1f18321ac00d28d93cb1cb7dc957d1f.tar.bz2 |
Changing sharp define. if someone doesnt like it, let me know :)
-rw-r--r-- | library/alarmserver.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/library/alarmserver.cpp b/library/alarmserver.cpp index 02bca3d..7e6e515 100644 --- a/library/alarmserver.cpp +++ b/library/alarmserver.cpp | |||
@@ -97,129 +97,129 @@ static void saveState() | |||
97 | unlink( savefilename ); | 97 | unlink( savefilename ); |
98 | return; | 98 | return; |
99 | } | 99 | } |
100 | 100 | ||
101 | QFile savefile(savefilename+".new"); | 101 | QFile savefile(savefilename+".new"); |
102 | if ( savefile.open(IO_WriteOnly) ) { | 102 | if ( savefile.open(IO_WriteOnly) ) { |
103 | QDataStream ds( &savefile ); | 103 | QDataStream ds( &savefile ); |
104 | 104 | ||
105 | //save | 105 | //save |
106 | 106 | ||
107 | QListIterator<timerEventItem> it( timerEventList ); | 107 | QListIterator<timerEventItem> it( timerEventList ); |
108 | for ( ; *it; ++it ) { | 108 | for ( ; *it; ++it ) { |
109 | ds << it.current()->UTCtime; | 109 | ds << it.current()->UTCtime; |
110 | ds << it.current()->channel; | 110 | ds << it.current()->channel; |
111 | ds << it.current()->message; | 111 | ds << it.current()->message; |
112 | ds << it.current()->data; | 112 | ds << it.current()->data; |
113 | } | 113 | } |
114 | 114 | ||
115 | 115 | ||
116 | savefile.close(); | 116 | savefile.close(); |
117 | unlink( savefilename ); | 117 | unlink( savefilename ); |
118 | QDir d; d.rename(savefilename+".new",savefilename); | 118 | QDir d; d.rename(savefilename+".new",savefilename); |
119 | 119 | ||
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | /*! | 123 | /*! |
124 | Sets up the alarm server. Restoring to previous state (session management). | 124 | Sets up the alarm server. Restoring to previous state (session management). |
125 | */ | 125 | */ |
126 | void AlarmServer::initialize() | 126 | void AlarmServer::initialize() |
127 | { | 127 | { |
128 | //read autosave file and put events in timerEventList | 128 | //read autosave file and put events in timerEventList |
129 | 129 | ||
130 | QString savefilename = Global::applicationFileName( "AlarmServer", "saveFile" ); | 130 | QString savefilename = Global::applicationFileName( "AlarmServer", "saveFile" ); |
131 | 131 | ||
132 | QFile savefile(savefilename); | 132 | QFile savefile(savefilename); |
133 | if ( savefile.open(IO_ReadOnly) ) { | 133 | if ( savefile.open(IO_ReadOnly) ) { |
134 | QDataStream ds( &savefile ); | 134 | QDataStream ds( &savefile ); |
135 | while ( !ds.atEnd() ) { | 135 | while ( !ds.atEnd() ) { |
136 | timerEventItem *newTimerEventItem = new timerEventItem; | 136 | timerEventItem *newTimerEventItem = new timerEventItem; |
137 | ds >> newTimerEventItem->UTCtime; | 137 | ds >> newTimerEventItem->UTCtime; |
138 | ds >> newTimerEventItem->channel; | 138 | ds >> newTimerEventItem->channel; |
139 | ds >> newTimerEventItem->message; | 139 | ds >> newTimerEventItem->message; |
140 | ds >> newTimerEventItem->data; | 140 | ds >> newTimerEventItem->data; |
141 | timerEventList.append( newTimerEventItem ); | 141 | timerEventList.append( newTimerEventItem ); |
142 | } | 142 | } |
143 | savefile.close(); | 143 | savefile.close(); |
144 | if (!timerEventReceiver) | 144 | if (!timerEventReceiver) |
145 | timerEventReceiver = new TimerReceiverObject; | 145 | timerEventReceiver = new TimerReceiverObject; |
146 | setNearestTimerEvent(); | 146 | setNearestTimerEvent(); |
147 | } | 147 | } |
148 | } | 148 | } |
149 | 149 | ||
150 | 150 | ||
151 | 151 | ||
152 | 152 | ||
153 | static const char* atdir = "/var/spool/at/"; | 153 | static const char* atdir = "/var/spool/at/"; |
154 | 154 | ||
155 | static bool triggerAtd( bool writeHWClock = FALSE ) | 155 | static bool triggerAtd( bool writeHWClock = FALSE ) |
156 | { | 156 | { |
157 | QFile trigger(QString(atdir) + "trigger"); | 157 | QFile trigger(QString(atdir) + "trigger"); |
158 | if ( trigger.open(IO_WriteOnly|IO_Raw) ) { | 158 | if ( trigger.open(IO_WriteOnly|IO_Raw) ) { |
159 | 159 | ||
160 | const char* data = | 160 | const char* data = |
161 | #ifdef QT_QWS_CUSTOM | 161 | #ifdef QT_QWS_SHARP |
162 | //custom atd only writes HW Clock if we write a 'W' | 162 | //custom atd only writes HW Clock if we write a 'W' |
163 | ( writeHWClock ) ? "W\n" : | 163 | ( writeHWClock ) ? "W\n" : |
164 | #endif | 164 | #endif |
165 | data = "\n"; | 165 | data = "\n"; |
166 | int len = strlen(data); | 166 | int len = strlen(data); |
167 | int total_written = trigger.writeBlock(data,len); | 167 | int total_written = trigger.writeBlock(data,len); |
168 | if ( total_written != len ) { | 168 | if ( total_written != len ) { |
169 | QMessageBox::critical( 0, QObject::tr( "Out of Space" ), | 169 | QMessageBox::critical( 0, QObject::tr( "Out of Space" ), |
170 | QObject::tr( "Unable to schedule alarm.\nFree some memory and try again." ) ); | 170 | QObject::tr( "Unable to schedule alarm.\nFree some memory and try again." ) ); |
171 | trigger.close(); | 171 | trigger.close(); |
172 | QFile::remove( trigger.name() ); | 172 | QFile::remove( trigger.name() ); |
173 | return FALSE; | 173 | return FALSE; |
174 | } | 174 | } |
175 | return TRUE; | 175 | return TRUE; |
176 | } | 176 | } |
177 | return FALSE; | 177 | return FALSE; |
178 | } | 178 | } |
179 | 179 | ||
180 | void TimerReceiverObject::deleteTimer() | 180 | void TimerReceiverObject::deleteTimer() |
181 | { | 181 | { |
182 | if ( !atfilename.isEmpty() ) { | 182 | if ( !atfilename.isEmpty() ) { |
183 | unlink( atfilename ); | 183 | unlink( atfilename ); |
184 | atfilename = QString::null; | 184 | atfilename = QString::null; |
185 | triggerAtd( FALSE ); | 185 | triggerAtd( FALSE ); |
186 | } | 186 | } |
187 | } | 187 | } |
188 | 188 | ||
189 | void TimerReceiverObject::resetTimer() | 189 | void TimerReceiverObject::resetTimer() |
190 | { | 190 | { |
191 | const int maxsecs = 2147000; | 191 | const int maxsecs = 2147000; |
192 | int total_written; | 192 | int total_written; |
193 | QDateTime nearest = TimeConversion::fromUTC(nearestTimerEvent->UTCtime); | 193 | QDateTime nearest = TimeConversion::fromUTC(nearestTimerEvent->UTCtime); |
194 | QDateTime now = QDateTime::currentDateTime(); | 194 | QDateTime now = QDateTime::currentDateTime(); |
195 | if ( nearest < now ) | 195 | if ( nearest < now ) |
196 | nearest = now; | 196 | nearest = now; |
197 | int secs = TimeConversion::secsTo( now, nearest ); | 197 | int secs = TimeConversion::secsTo( now, nearest ); |
198 | if ( secs > maxsecs ) { | 198 | if ( secs > maxsecs ) { |
199 | // too far for millisecond timing | 199 | // too far for millisecond timing |
200 | secs = maxsecs; | 200 | secs = maxsecs; |
201 | } | 201 | } |
202 | 202 | ||
203 | // System timer (needed so that we wake from deep sleep), | 203 | // System timer (needed so that we wake from deep sleep), |
204 | // from the Epoch in seconds. | 204 | // from the Epoch in seconds. |
205 | // | 205 | // |
206 | int at_secs = TimeConversion::toUTC(nearest); | 206 | int at_secs = TimeConversion::toUTC(nearest); |
207 | // qDebug("reset timer to %d seconds from Epoch",at_secs); | 207 | // qDebug("reset timer to %d seconds from Epoch",at_secs); |
208 | QString fn = atdir + QString::number(at_secs) + "." | 208 | QString fn = atdir + QString::number(at_secs) + "." |
209 | + QString::number(getpid()); | 209 | + QString::number(getpid()); |
210 | if ( fn != atfilename ) { | 210 | if ( fn != atfilename ) { |
211 | QFile atfile(fn+".new"); | 211 | QFile atfile(fn+".new"); |
212 | if ( atfile.open(IO_WriteOnly|IO_Raw) ) { | 212 | if ( atfile.open(IO_WriteOnly|IO_Raw) ) { |
213 | // just wake up and delete the at file | 213 | // just wake up and delete the at file |
214 | QString cmd = "#!/bin/sh\nrm " + fn; | 214 | QString cmd = "#!/bin/sh\nrm " + fn; |
215 | total_written = atfile.writeBlock(cmd.latin1(),cmd.length()); | 215 | total_written = atfile.writeBlock(cmd.latin1(),cmd.length()); |
216 | if ( total_written != int(cmd.length()) ) { | 216 | if ( total_written != int(cmd.length()) ) { |
217 | QMessageBox::critical( 0, tr("Out of Space"), | 217 | QMessageBox::critical( 0, tr("Out of Space"), |
218 | tr("Unable to schedule alarm.\n" | 218 | tr("Unable to schedule alarm.\n" |
219 | "Please free up space and try again") ); | 219 | "Please free up space and try again") ); |
220 | atfile.close(); | 220 | atfile.close(); |
221 | QFile::remove( atfile.name() ); | 221 | QFile::remove( atfile.name() ); |
222 | return; | 222 | return; |
223 | } | 223 | } |
224 | atfile.close(); | 224 | atfile.close(); |
225 | unlink( atfilename ); | 225 | unlink( atfilename ); |