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
@@ -71,198 +71,192 @@ MainWindow::MainWindow()
71 mainWidget->addTab( formatTab = new FormatTabWidget( mainWidget ), "netsystemtime/formattab", tr( "Format" ) ); 71 mainWidget->addTab( formatTab = new FormatTabWidget( mainWidget ), "netsystemtime/formattab", tr( "Format" ) );
72 mainWidget->addTab( settingsTab = new SettingsTabWidget( mainWidget ), "SettingsIcon", tr( "Settings" ) ); 72 mainWidget->addTab( settingsTab = new SettingsTabWidget( mainWidget ), "SettingsIcon", tr( "Settings" ) );
73 mainWidget->addTab( predictTab = new PredictTabWidget( mainWidget ), "netsystemtime/predicttab", tr( "Predict" ) ); 73 mainWidget->addTab( predictTab = new PredictTabWidget( mainWidget ), "netsystemtime/predicttab", tr( "Predict" ) );
74 Config config( "ntp" ); 74 Config config( "ntp" );
75 config.setGroup( "settings" ); 75 config.setGroup( "settings" );
76 slotDisplayNTPTab( config.readBoolEntry( "displayNtpTab", FALSE ) ); 76 slotDisplayNTPTab( config.readBoolEntry( "displayNtpTab", FALSE ) );
77 slotDisplayPredictTab( config.readBoolEntry( "displayPredictTab", FALSE ) ); 77 slotDisplayPredictTab( config.readBoolEntry( "displayPredictTab", FALSE ) );
78 78
79 mainWidget->setCurrentTab( tr( "Time" ) ); 79 mainWidget->setCurrentTab( tr( "Time" ) );
80 layout->addWidget( mainWidget ); 80 layout->addWidget( mainWidget );
81 81
82 // Create QCOP channel 82 // Create QCOP channel
83 QCopChannel *channel = new QCopChannel( "QPE/Application/netsystemtime", this ); 83 QCopChannel *channel = new QCopChannel( "QPE/Application/netsystemtime", this );
84 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 84 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
85 this, SLOT(slotQCopReceive(const QCString&, const QByteArray&)) ); 85 this, SLOT(slotQCopReceive(const QCString&, const QByteArray&)) );
86 86
87 // Create NTP socket 87 // Create NTP socket
88 ntpSock = new QSocket( this ); 88 ntpSock = new QSocket( this );
89 connect( ntpSock, SIGNAL(error(int)),SLOT(slotCheckNtp(int)) ); 89 connect( ntpSock, SIGNAL(error(int)),SLOT(slotCheckNtp(int)) );
90 slotProbeNTPServer(); 90 slotProbeNTPServer();
91 91
92 // Create timer for automatic time lookups 92 // Create timer for automatic time lookups
93 ntpTimer = new QTimer( this ); 93 ntpTimer = new QTimer( this );
94 94
95 // Connect everything together 95 // Connect everything together
96 connect( timeTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) ); 96 connect( timeTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) );
97 connect( timeTab, SIGNAL(tzChanged(const QString &)), predictTab, SLOT(slotTZChanged(const QString &)) ); 97 connect( timeTab, SIGNAL(tzChanged(const QString &)), predictTab, SLOT(slotTZChanged(const QString &)) );
98 connect( timeTab, SIGNAL(getPredictedTime()), predictTab, SLOT(slotSetPredictedTime()) ); 98 connect( timeTab, SIGNAL(getPredictedTime()), predictTab, SLOT(slotSetPredictedTime()) );
99 connect( formatTab, SIGNAL(show12HourTime(int)), timeTab, SLOT(slotUse12HourTime( int )) ); 99 connect( formatTab, SIGNAL(show12HourTime(int)), timeTab, SLOT(slotUse12HourTime( int )) );
100 connect( formatTab, SIGNAL(dateFormatChanged(const DateFormat &)), 100 connect( formatTab, SIGNAL(dateFormatChanged(const DateFormat &)),
101 timeTab, SLOT(slotDateFormatChanged(const DateFormat &)) ); 101 timeTab, SLOT(slotDateFormatChanged(const DateFormat &)) );
102 connect( formatTab, SIGNAL(weekStartChanged(int)), timeTab, SLOT(slotWeekStartChanged(int)) ); 102 connect( formatTab, SIGNAL(weekStartChanged(int)), timeTab, SLOT(slotWeekStartChanged(int)) );
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)" )
237 { 231 {
238 ntpInteractive = false; 232 ntpInteractive = false;
239 runNTP(); 233 runNTP();
240 } 234 }
241 if ( msg == "setPredictedTime(QString)" ) 235 if ( msg == "setPredictedTime(QString)" )
242 { 236 {
243 //setPredictTime(); 237 //setPredictTime();
244 } 238 }
245} 239}
246 240
247void MainWindow::slotDisplayNTPTab( bool display ) 241void MainWindow::slotDisplayNTPTab( bool display )
248{ 242{
249 ntpTabEnabled = display; 243 ntpTabEnabled = display;
250 244
251 // Create widget if it hasn't needed 245 // Create widget if it hasn't needed
252 if ( display && !ntpTab ) 246 if ( display && !ntpTab )
253 { 247 {
254 ntpTab = new NTPTabWidget( mainWidget ); 248 ntpTab = new NTPTabWidget( mainWidget );
255 connect( ntpTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) ); 249 connect( ntpTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) );
256 } 250 }
257 251
258 // Display/hide tab 252 // Display/hide tab
259 display ? mainWidget->addTab( ntpTab, "netsystemtime/ntptab", tr( "Time Server" ) ) 253 display ? mainWidget->addTab( ntpTab, "netsystemtime/ntptab", tr( "Time Server" ) )
260 : mainWidget->removePage( ntpTab ); 254 : mainWidget->removePage( ntpTab );
261} 255}
262 256
263void MainWindow::slotDisplayPredictTab( bool display ) 257void MainWindow::slotDisplayPredictTab( bool display )
264{ 258{
265 predictTabEnabled = display; 259 predictTabEnabled = display;
266 260
267 // Create widget if it hasn't needed 261 // Create widget if it hasn't needed
268 if ( display && !predictTab ) 262 if ( display && !predictTab )