summaryrefslogtreecommitdiff
authorcniehaus <cniehaus>2003-05-18 12:21:27 (UTC)
committer cniehaus <cniehaus>2003-05-18 12:21:27 (UTC)
commit34c5b88459bcf5e02deae6b04e8bc17ee0de74c0 (patch) (unidiff)
tree81fa2cd128c8bb75554f6443eec685f65412e2db
parent76cc1bf740e9134f44a1341d8b01cc9f543a4cd4 (diff)
downloadopie-34c5b88459bcf5e02deae6b04e8bc17ee0de74c0.zip
opie-34c5b88459bcf5e02deae6b04e8bc17ee0de74c0.tar.gz
opie-34c5b88459bcf5e02deae6b04e8bc17ee0de74c0.tar.bz2
fix the fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/mainwindow.cpp6
1 files changed, 0 insertions, 6 deletions
diff --git a/noncore/settings/netsystemtime/mainwindow.cpp b/noncore/settings/netsystemtime/mainwindow.cpp
index 85a46b7..2d240ba 100644
--- a/noncore/settings/netsystemtime/mainwindow.cpp
+++ b/noncore/settings/netsystemtime/mainwindow.cpp
@@ -103,134 +103,128 @@ MainWindow::MainWindow()
103 connect( settingsTab, SIGNAL(ntpDelayChanged(int)), this, SLOT(slotNTPDelayChanged(int)) ); 103 connect( settingsTab, SIGNAL(ntpDelayChanged(int)), this, SLOT(slotNTPDelayChanged(int)) );
104 connect( settingsTab, SIGNAL(displayNTPTab(bool)), this, SLOT(slotDisplayNTPTab(bool)) ); 104 connect( settingsTab, SIGNAL(displayNTPTab(bool)), this, SLOT(slotDisplayNTPTab(bool)) );
105 connect( settingsTab, SIGNAL(displayPredictTab(bool)), this, SLOT(slotDisplayPredictTab(bool)) ); 105 connect( settingsTab, SIGNAL(displayPredictTab(bool)), this, SLOT(slotDisplayPredictTab(bool)) );
106 connect( predictTab, SIGNAL(setTime(const QDateTime &)), this, SLOT(slotSetTime(const QDateTime &)) ); 106 connect( predictTab, SIGNAL(setTime(const QDateTime &)), this, SLOT(slotSetTime(const QDateTime &)) );
107 107
108 // Do initial time server check 108 // Do initial time server check
109 slotNTPDelayChanged( config.readNumEntry( "ntpRefreshFreq", 1440 ) ); 109 slotNTPDelayChanged( config.readNumEntry( "ntpRefreshFreq", 1440 ) );
110 slotCheckNtp( -1 ); 110 slotCheckNtp( -1 );
111 111
112 // Display app 112 // Display app
113 showMaximized(); 113 showMaximized();
114} 114}
115 115
116MainWindow::~MainWindow() 116MainWindow::~MainWindow()
117{ 117{
118 if ( ntpProcess ) 118 if ( ntpProcess )
119 delete ntpProcess; 119 delete ntpProcess;
120} 120}
121 121
122void MainWindow::accept() 122void MainWindow::accept()
123{ 123{
124 // Turn off the screensaver (Note: needs to be encased in { } so that it deconstructs and sends) 124 // Turn off the screensaver (Note: needs to be encased in { } so that it deconstructs and sends)
125 { 125 {
126 QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); 126 QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
127 disableScreenSaver << 0 << 0 << 0; 127 disableScreenSaver << 0 << 0 << 0;
128 } 128 }
129 129
130 // Update the systemtime 130 // Update the systemtime
131 timeTab->saveSettings( TRUE ); 131 timeTab->saveSettings( TRUE );
132 132
133 // Save format options 133 // Save format options
134 formatTab->saveSettings( TRUE ); 134 formatTab->saveSettings( TRUE );
135 135
136 // Save settings options 136 // Save settings options
137 settingsTab->saveSettings(); 137 settingsTab->saveSettings();
138 138
139 // Since time has changed quickly load in the DateBookDB to allow the alarm server to get a better 139 // Since time has changed quickly load in the DateBookDB to allow the alarm server to get a better
140 // grip on itself (example re-trigger alarms for when we travel back in time). 140 // grip on itself (example re-trigger alarms for when we travel back in time).
141 DateBookDB db; 141 DateBookDB db;
142 142
143 // Turn back on the screensaver 143 // Turn back on the screensaver
144 QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); 144 QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
145 enableScreenSaver << -1 << -1 << -1; 145 enableScreenSaver << -1 << -1 << -1;
146 146
147 // Exit app 147 // Exit app
148 qApp->quit(); 148 qApp->quit();
149} 149}
150 150
151void MainWindow::reject() 151void MainWindow::reject()
152{ 152{
153 // Reset time settings 153 // Reset time settings
154 timeTab->saveSettings( FALSE ); 154 timeTab->saveSettings( FALSE );
155 155
156 // Send notifications but do not save settings 156 // Send notifications but do not save settings
157 formatTab->saveSettings( FALSE ); 157 formatTab->saveSettings( FALSE );
158 158
159 // Exit app 159 // Exit app
160 qApp->quit(); 160 qApp->quit();
161} 161}
162 162
163void MainWindow::runNTP() 163void MainWindow::runNTP()
164{ 164{
165 if ( !ntpDelayElapsed() && ntpInteractive ) 165 if ( !ntpDelayElapsed() && ntpInteractive )
166 { 166 {
167 QString msg = tr( "You asked for a delay of " );
168 msg.append( QString::number( ntpDelay ) );
169 msg.append( tr( " minutes, but only " ) );
170 msg.append( QString::number( _lookupDiff / 60 ) );
171 msg.append( tr(" minutes elapsed since last lookup.<br>Continue?") );
172
173 QString msg = tr( "You asked for a delay of %1 minutes, but only %2 minutes elapsed since last lookup.<br>Continue?" ).arg( QString::number( ntpDelay ) ).arg( QString::number( _lookupDiff / 60 ) ); 167 QString msg = tr( "You asked for a delay of %1 minutes, but only %2 minutes elapsed since last lookup.<br>Continue?" ).arg( QString::number( ntpDelay ) ).arg( QString::number( _lookupDiff / 60 ) );
174 168
175 switch ( 169 switch (
176 QMessageBox::warning( this, tr( "Continue?" ), msg, QMessageBox::Yes, QMessageBox::No ) 170 QMessageBox::warning( this, tr( "Continue?" ), msg, QMessageBox::Yes, QMessageBox::No )
177 ) 171 )
178 { 172 {
179 case QMessageBox::Yes: break; 173 case QMessageBox::Yes: break;
180 case QMessageBox::No: return; 174 case QMessageBox::No: return;
181 default: return; 175 default: return;
182 } 176 }
183 } 177 }
184 178
185 QString srv = settingsTab->ntpServer(); 179 QString srv = settingsTab->ntpServer();
186 180
187 // Send information to time server tab if enabled 181 // Send information to time server tab if enabled
188 if ( ntpTabEnabled ) 182 if ( ntpTabEnabled )
189 { 183 {
190 ntpTab->setStartTime( QDateTime::currentDateTime().toString() ); 184 ntpTab->setStartTime( QDateTime::currentDateTime().toString() );
191 QString output = tr( "Running:\nntpdate " ); 185 QString output = tr( "Running:\nntpdate " );
192 output.append( srv ); 186 output.append( srv );
193 ntpTab->addNtpOutput( output ); 187 ntpTab->addNtpOutput( output );
194 } 188 }
195 189
196 if ( !ntpProcess ) 190 if ( !ntpProcess )
197 { 191 {
198 ntpProcess = new OProcess(); 192 ntpProcess = new OProcess();
199 connect( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), 193 connect( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)),
200 this, SLOT(slotNtpOutput(OProcess*,char*,int)) ); 194 this, SLOT(slotNtpOutput(OProcess*,char*,int)) );
201 connect( ntpProcess, SIGNAL(processExited(OProcess*)), 195 connect( ntpProcess, SIGNAL(processExited(OProcess*)),
202 this, SLOT(slotNtpFinished(OProcess*)) ); 196 this, SLOT(slotNtpFinished(OProcess*)) );
203 } 197 }
204 198
205 else 199 else
206 ntpProcess->clearArguments(); 200 ntpProcess->clearArguments();
207 201
208 *ntpProcess << "ntpdate" << srv; 202 *ntpProcess << "ntpdate" << srv;
209 bool ret = ntpProcess->start( OProcess::NotifyOnExit, OProcess::AllOutput ); 203 bool ret = ntpProcess->start( OProcess::NotifyOnExit, OProcess::AllOutput );
210 if ( !ret ) 204 if ( !ret )
211 { 205 {
212 QMessageBox::critical( this, tr( "Error" ), tr( "Error while getting time from network." ) ); 206 QMessageBox::critical( this, tr( "Error" ), tr( "Error while getting time from network." ) );
213 if ( ntpTabEnabled ) 207 if ( ntpTabEnabled )
214 ntpTab->addNtpOutput( tr( "Error while executing ntpdate" ) ); 208 ntpTab->addNtpOutput( tr( "Error while executing ntpdate" ) );
215 } 209 }
216} 210}
217 211
218bool MainWindow::ntpDelayElapsed() 212bool MainWindow::ntpDelayElapsed()
219{ 213{
220 // Determine if time elapsed is greater than time delay 214 // Determine if time elapsed is greater than time delay
221 Config config( "ntp" ); 215 Config config( "ntp" );
222 config.setGroup( "lookups" ); 216 config.setGroup( "lookups" );
223 _lookupDiff = TimeConversion::toUTC( QDateTime::currentDateTime() ) - config.readNumEntry( "time", 0 ); 217 _lookupDiff = TimeConversion::toUTC( QDateTime::currentDateTime() ) - config.readNumEntry( "time", 0 );
224 if ( _lookupDiff < 0 ) 218 if ( _lookupDiff < 0 )
225 return true; 219 return true;
226 return ( _lookupDiff - ( ntpDelay * 60) ) > 0; 220 return ( _lookupDiff - ( ntpDelay * 60) ) > 0;
227} 221}
228 222
229void MainWindow::slotSetTime( const QDateTime &dt ) 223void MainWindow::slotSetTime( const QDateTime &dt )
230{ 224{
231 timeTab->setDateTime( dt ); 225 timeTab->setDateTime( dt );
232} 226}
233 227
234void MainWindow::slotQCopReceive( const QCString &msg, const QByteArray & ) 228void MainWindow::slotQCopReceive( const QCString &msg, const QByteArray & )
235{ 229{
236 if ( msg == "ntpLookup(QString)" ) 230 if ( msg == "ntpLookup(QString)" )