summaryrefslogtreecommitdiff
path: root/noncore
authorerik <erik>2007-01-24 19:54:07 (UTC)
committer erik <erik>2007-01-24 19:54:07 (UTC)
commit89e81059e832ff77c2f0ac8b9db12f80eafa03fc (patch) (unidiff)
tree99a130fc643d2aeefdecab452f644e7b61a5f50e /noncore
parent035bbc5bf689839c8d8e7be37f347b0dd900fccf (diff)
downloadopie-89e81059e832ff77c2f0ac8b9db12f80eafa03fc.zip
opie-89e81059e832ff77c2f0ac8b9db12f80eafa03fc.tar.gz
opie-89e81059e832ff77c2f0ac8b9db12f80eafa03fc.tar.bz2
Each file in this commit has an instance where a pointer is checked at
one point in the code and then not checked in another point in the code. If it needed to be checked once, it needs to be checked the other time. If not the application could segfault.
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/pcmcia/pcmcia.cpp6
-rw-r--r--noncore/apps/checkbook/mainwindow.cpp7
-rw-r--r--noncore/apps/opie-console/procctl.cpp5
-rw-r--r--noncore/apps/tinykate/libkate/document/katedocument.cpp123
-rw-r--r--noncore/settings/sysinfo/devicesinfo.cpp2
-rw-r--r--noncore/todayplugins/stockticker/libstocks/http.c2
6 files changed, 77 insertions, 68 deletions
diff --git a/noncore/applets/pcmcia/pcmcia.cpp b/noncore/applets/pcmcia/pcmcia.cpp
index 187adc6..c639002 100644
--- a/noncore/applets/pcmcia/pcmcia.cpp
+++ b/noncore/applets/pcmcia/pcmcia.cpp
@@ -143,192 +143,198 @@ enum { EJECT, INSERT, SUSPEND, RESUME, RESET, CONFIGURE, ACTIVATE };
143static const char* actionText[] = { "eject", "insert", "suspend", "resum", "resett", "configur", "activat" }; 143static const char* actionText[] = { "eject", "insert", "suspend", "resum", "resett", "configur", "activat" };
144 144
145void PcmciaManager::mousePressEvent( QMouseEvent* ) 145void PcmciaManager::mousePressEvent( QMouseEvent* )
146{ 146{
147 QPopupMenu* menu = new QPopupMenu( this ); 147 QPopupMenu* menu = new QPopupMenu( this );
148 QStringList cmd; 148 QStringList cmd;
149 bool execute = true; 149 bool execute = true;
150 150
151 OPcmciaSystem* sys = OPcmciaSystem::instance(); 151 OPcmciaSystem* sys = OPcmciaSystem::instance();
152 sys->synchronize(); 152 sys->synchronize();
153 OPcmciaSystem::CardIterator it = sys->iterator(); 153 OPcmciaSystem::CardIterator it = sys->iterator();
154 if ( !sys->count() ) return; 154 if ( !sys->count() ) return;
155 155
156 int i = 0; 156 int i = 0;
157 while ( it.current() ) 157 while ( it.current() )
158 { 158 {
159 QPopupMenu* submenu = new QPopupMenu( menu ); 159 QPopupMenu* submenu = new QPopupMenu( menu );
160 submenu->insertItem( "&Eject", EJECT+i*100 ); 160 submenu->insertItem( "&Eject", EJECT+i*100 );
161 submenu->insertItem( "&Insert", INSERT+i*100 ); 161 submenu->insertItem( "&Insert", INSERT+i*100 );
162 submenu->insertItem( "&Suspend", SUSPEND+i*100 ); 162 submenu->insertItem( "&Suspend", SUSPEND+i*100 );
163 submenu->insertItem( "&Resume", RESUME+i*100 ); 163 submenu->insertItem( "&Resume", RESUME+i*100 );
164 submenu->insertItem( "Rese&t", RESET+i*100 ); 164 submenu->insertItem( "Rese&t", RESET+i*100 );
165 submenu->insertItem( "&Configure", CONFIGURE+i*100 ); 165 submenu->insertItem( "&Configure", CONFIGURE+i*100 );
166 166
167 bool isSuspended = it.current()->isSuspended(); 167 bool isSuspended = it.current()->isSuspended();
168 bool isEmpty = it.current()->isEmpty(); 168 bool isEmpty = it.current()->isEmpty();
169 169
170 submenu->setItemEnabled( EJECT+i*100, !isEmpty ); 170 submenu->setItemEnabled( EJECT+i*100, !isEmpty );
171 submenu->setItemEnabled( INSERT+i*100, isEmpty ); 171 submenu->setItemEnabled( INSERT+i*100, isEmpty );
172 submenu->setItemEnabled( SUSPEND+i*100, !isEmpty && !isSuspended ); 172 submenu->setItemEnabled( SUSPEND+i*100, !isEmpty && !isSuspended );
173 submenu->setItemEnabled( RESUME+i*100, !isEmpty && isSuspended ); 173 submenu->setItemEnabled( RESUME+i*100, !isEmpty && isSuspended );
174 submenu->setItemEnabled( RESET+i*100, !isEmpty && !isSuspended ); 174 submenu->setItemEnabled( RESET+i*100, !isEmpty && !isSuspended );
175 submenu->setItemEnabled( CONFIGURE+i*100, !isEmpty && !configuring ); 175 submenu->setItemEnabled( CONFIGURE+i*100, !isEmpty && !configuring );
176 176
177 connect( submenu, SIGNAL(activated(int)), this, SLOT(userCardAction(int)) ); 177 connect( submenu, SIGNAL(activated(int)), this, SLOT(userCardAction(int)) );
178 menu->insertItem( tr( "%1: %2" ).arg( i++ ).arg( it.current()->identity() ), submenu, 1 ); 178 menu->insertItem( tr( "%1: %2" ).arg( i++ ).arg( it.current()->identity() ), submenu, 1 );
179 ++it; 179 ++it;
180 } 180 }
181 181
182 QPoint p = mapToGlobal( QPoint( 0, 0 ) ); 182 QPoint p = mapToGlobal( QPoint( 0, 0 ) );
183 QSize s = menu->sizeHint(); 183 QSize s = menu->sizeHint();
184 int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), p.y() - s.height() ), 0 ); 184 int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), p.y() - s.height() ), 0 );
185 qDebug( "pcmcia: menu result = %d", opt ); 185 qDebug( "pcmcia: menu result = %d", opt );
186 delete menu; 186 delete menu;
187} 187}
188 188
189 189
190void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) 190void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
191{ 191{
192 odebug << "PcmciaManager::cardMessage( '" << msg << "' )" << oendl; 192 odebug << "PcmciaManager::cardMessage( '" << msg << "' )" << oendl;
193 if ( msg != "stabChanged()" ) return; 193 if ( msg != "stabChanged()" ) return;
194 194
195 /* check if a previously unknown card has been inserted */ 195 /* check if a previously unknown card has been inserted */
196 OPcmciaSystem::instance()->synchronize(); 196 OPcmciaSystem::instance()->synchronize();
197 197
198 if ( !OPcmciaSystem::instance()->cardCount() ) return; 198 if ( !OPcmciaSystem::instance()->cardCount() ) return;
199 199
200 OConfig cfg( "PCMCIA" ); 200 OConfig cfg( "PCMCIA" );
201 cfg.setGroup( "Global" ); 201 cfg.setGroup( "Global" );
202 int nCards = cfg.readNumEntry( "nCards", 0 ); 202 int nCards = cfg.readNumEntry( "nCards", 0 );
203 203
204 OPcmciaSystem* sys = OPcmciaSystem::instance(); 204 OPcmciaSystem* sys = OPcmciaSystem::instance();
205 OPcmciaSystem::CardIterator it = sys->iterator(); 205 OPcmciaSystem::CardIterator it = sys->iterator();
206 206
207 bool newCard = true; 207 bool newCard = true;
208 OPcmciaSocket* theCard = 0; 208 OPcmciaSocket* theCard = 0;
209 209
210 while ( it.current() && newCard ) 210 while ( it.current() && newCard )
211 { 211 {
212 if ( it.current()->isEmpty() ) 212 if ( it.current()->isEmpty() )
213 { 213 {
214 odebug << "pcmcia: skipping empty card in socket " << it.current()->number() << oendl; 214 odebug << "pcmcia: skipping empty card in socket " << it.current()->number() << oendl;
215 ++it; 215 ++it;
216 continue; 216 continue;
217 } 217 }
218 else 218 else
219 { 219 {
220 theCard = it.current(); 220 theCard = it.current();
221 QString cardName = theCard->productIdentity(); 221 QString cardName = theCard->productIdentity();
222 for ( int i = 0; i < nCards; ++i ) 222 for ( int i = 0; i < nCards; ++i )
223 { 223 {
224 QString cardSection = QString( "Card_%1" ).arg( i ); 224 QString cardSection = QString( "Card_%1" ).arg( i );
225 cfg.setGroup( cardSection ); 225 cfg.setGroup( cardSection );
226 QString name = cfg.readEntry( "name" ); 226 QString name = cfg.readEntry( "name" );
227 odebug << "pcmcia: comparing card '" << cardName << "' with known card '" << name << "'" << oendl; 227 odebug << "pcmcia: comparing card '" << cardName << "' with known card '" << name << "'" << oendl;
228 if ( cardName == name ) 228 if ( cardName == name )
229 { 229 {
230 newCard = false; 230 newCard = false;
231 odebug << "pcmcia: we have seen this card before" << oendl; 231 odebug << "pcmcia: we have seen this card before" << oendl;
232 executeAction( theCard, "insert" ); 232 executeAction( theCard, "insert" );
233 break; 233 break;
234 } 234 }
235 } 235 }
236 if ( !newCard ) ++it; else break; 236 if ( !newCard ) ++it; else break;
237 } 237 }
238 } 238 }
239
240 if ( !theCard ) {
241 owarn << "pcmcia: Finished working through cards in PCMCIA system but I do not have a valid card handle" << oendl;
242 return;
243 }
244
239 if ( newCard ) 245 if ( newCard )
240 { 246 {
241 odebug << "pcmcia: unconfigured card detected" << oendl; 247 odebug << "pcmcia: unconfigured card detected" << oendl;
242 QString newCardName = theCard->productIdentity(); 248 QString newCardName = theCard->productIdentity();
243 int result = QMessageBox::information( qApp->desktop(), 249 int result = QMessageBox::information( qApp->desktop(),
244 tr( "PCMCIA/CF Subsystem" ), 250 tr( "PCMCIA/CF Subsystem" ),
245 tr( "<qt>You have inserted the card<br/><b>%1</b><br/>This card is not yet configured. Do you want to configure it now?</qt>" ).arg( newCardName ), 251 tr( "<qt>You have inserted the card<br/><b>%1</b><br/>This card is not yet configured. Do you want to configure it now?</qt>" ).arg( newCardName ),
246 tr( "Yes" ), tr( "No" ), 0, 0, 1 ); 252 tr( "Yes" ), tr( "No" ), 0, 0, 1 );
247 odebug << "pcmcia: result = " << result << oendl; 253 odebug << "pcmcia: result = " << result << oendl;
248 if ( result == 0 ) 254 if ( result == 0 )
249 { 255 {
250 configure( theCard ); 256 configure( theCard );
251 } 257 }
252 else 258 else
253 { 259 {
254 odebug << "pcmcia: user doesn't want to configure " << newCardName << " now." << oendl; 260 odebug << "pcmcia: user doesn't want to configure " << newCardName << " now." << oendl;
255 } 261 }
256 } 262 }
257 else // it's an already configured card 263 else // it's an already configured card
258 { 264 {
259 odebug << "pcmcia: doing nothing... why do we come here?" << oendl; 265 odebug << "pcmcia: doing nothing... why do we come here?" << oendl;
260 } 266 }
261} 267}
262 268
263void PcmciaManager::paintEvent( QPaintEvent * ) 269void PcmciaManager::paintEvent( QPaintEvent * )
264{ 270{
265 QPainter p( this ); 271 QPainter p( this );
266 p.drawPixmap( 0, 0, pm ); 272 p.drawPixmap( 0, 0, pm );
267} 273}
268 274
269int PcmciaManager::position() 275int PcmciaManager::position()
270{ 276{
271 return 7; 277 return 7;
272} 278}
273 279
274void PcmciaManager::execCommand( const QStringList &strList ) 280void PcmciaManager::execCommand( const QStringList &strList )
275{ 281{
276} 282}
277 283
278void PcmciaManager::userCardAction( int action ) 284void PcmciaManager::userCardAction( int action )
279{ 285{
280 odebug << "pcmcia: user action on socket " << action / 100 << " requested. action = " << action << oendl; 286 odebug << "pcmcia: user action on socket " << action / 100 << " requested. action = " << action << oendl;
281 287
282 int socket = action / 100; 288 int socket = action / 100;
283 int what = action % 100; 289 int what = action % 100;
284 bool success = false; 290 bool success = false;
285 291
286 switch ( what ) 292 switch ( what )
287 { 293 {
288 case CONFIGURE: 294 case CONFIGURE:
289 { 295 {
290 QString insertAction; QString resumeAction; QString driver; QString conf; 296 QString insertAction; QString resumeAction; QString driver; QString conf;
291 configure( OPcmciaSystem::instance()->socket( socket ) ); 297 configure( OPcmciaSystem::instance()->socket( socket ) );
292 return; 298 return;
293 } 299 }
294 case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject(); 300 case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject();
295 break; 301 break;
296 case INSERT: success = OPcmciaSystem::instance()->socket( socket )->insert(); 302 case INSERT: success = OPcmciaSystem::instance()->socket( socket )->insert();
297 break; 303 break;
298 case SUSPEND: success = OPcmciaSystem::instance()->socket( socket )->suspend(); 304 case SUSPEND: success = OPcmciaSystem::instance()->socket( socket )->suspend();
299 break; 305 break;
300 case RESUME: success = OPcmciaSystem::instance()->socket( socket )->resume(); 306 case RESUME: success = OPcmciaSystem::instance()->socket( socket )->resume();
301 break; 307 break;
302 case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset(); 308 case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset();
303 break; 309 break;
304 case ACTIVATE: success = true; 310 case ACTIVATE: success = true;
305 break; 311 break;
306 default: odebug << "pcmcia: not yet implemented" << oendl; 312 default: odebug << "pcmcia: not yet implemented" << oendl;
307 } 313 }
308 314
309 if ( success ) 315 if ( success )
310 { 316 {
311 odebug << tr( "Successfully %1ed card in socket #%2" ).arg( actionText[action] ).arg( socket ) << oendl; 317 odebug << tr( "Successfully %1ed card in socket #%2" ).arg( actionText[action] ).arg( socket ) << oendl;
312 popUp( tr( "Successfully %1ed card in socket #%2" ).arg( actionText[action] ).arg( socket ) ); 318 popUp( tr( "Successfully %1ed card in socket #%2" ).arg( actionText[action] ).arg( socket ) );
313 } 319 }
314 else 320 else
315 { 321 {
316 odebug << tr( "Error while %1ing card in socket #%2" ).arg( actionText[action] ).arg( socket ) << oendl; 322 odebug << tr( "Error while %1ing card in socket #%2" ).arg( actionText[action] ).arg( socket ) << oendl;
317 popUp( tr( "Error while %1ing card in socket #%2" ).arg( actionText[action] ).arg( socket ) ); 323 popUp( tr( "Error while %1ing card in socket #%2" ).arg( actionText[action] ).arg( socket ) );
318 } 324 }
319} 325}
320 326
321void PcmciaManager::configure( OPcmciaSocket* card ) 327void PcmciaManager::configure( OPcmciaSocket* card )
322{ 328{
323 configuring = true; 329 configuring = true;
324 ConfigDialog dialog( card, qApp->desktop() ); 330 ConfigDialog dialog( card, qApp->desktop() );
325 int result = QPEApplication::execDialog( &dialog, false ); 331 int result = QPEApplication::execDialog( &dialog, false );
326 configuring = false; 332 configuring = false;
327 odebug << "pcmcia: configresult = " << result << oendl; 333 odebug << "pcmcia: configresult = " << result << oendl;
328 if ( result ) 334 if ( result )
329 { 335 {
330 dialog.writeConfiguration( card ); 336 dialog.writeConfiguration( card );
331 } 337 }
332} 338}
333 339
334void PcmciaManager::executeAction( Opie::Core::OPcmciaSocket* card, const QString& type ) 340void PcmciaManager::executeAction( Opie::Core::OPcmciaSocket* card, const QString& type )
diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp
index d9e2047..8e2e2e3 100644
--- a/noncore/apps/checkbook/mainwindow.cpp
+++ b/noncore/apps/checkbook/mainwindow.cpp
@@ -150,214 +150,213 @@ MainWindow::~MainWindow()
150 150
151// --- buildList -------------------------------------------------------------- 151// --- buildList --------------------------------------------------------------
152void MainWindow::buildList() 152void MainWindow::buildList()
153{ 153{
154 if ( cbList ) 154 if ( cbList )
155 delete cbList; 155 delete cbList;
156 156
157 cbList = new QListView( this ); 157 cbList = new QListView( this );
158 QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) ); 158 QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) );
159 159
160 if ( _cfg.getShowLocks() ) 160 if ( _cfg.getShowLocks() )
161 { 161 {
162 cbList->addColumn( lockIcon, "", 24 ); 162 cbList->addColumn( lockIcon, "", 24 );
163 posName = 1; 163 posName = 1;
164 } 164 }
165 else 165 else
166 { 166 {
167 posName = 0; 167 posName = 0;
168 } 168 }
169 cbList->addColumn( tr( "Checkbook Name" ) ); 169 cbList->addColumn( tr( "Checkbook Name" ) );
170 if ( _cfg.getShowBalances() ) 170 if ( _cfg.getShowBalances() )
171 { 171 {
172 int colnum = cbList->addColumn( tr( "Balance" ) ); 172 int colnum = cbList->addColumn( tr( "Balance" ) );
173 cbList->setColumnAlignment( colnum, Qt::AlignRight ); 173 cbList->setColumnAlignment( colnum, Qt::AlignRight );
174 } 174 }
175 cbList->setAllColumnsShowFocus( TRUE ); 175 cbList->setAllColumnsShowFocus( TRUE );
176 cbList->setSorting( posName ); 176 cbList->setSorting( posName );
177 QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold ); 177 QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold );
178 connect( cbList, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), 178 connect( cbList, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ),
179 this, SLOT( slotEdit() ) ); 179 this, SLOT( slotEdit() ) );
180 setCentralWidget( cbList ); 180 setCentralWidget( cbList );
181 181
182 for ( CBInfo *cb = checkbooks->first(); cb; cb = checkbooks->next() ) 182 for ( CBInfo *cb = checkbooks->first(); cb; cb = checkbooks->next() )
183 { 183 {
184 addCheckbook( cb ); 184 addCheckbook( cb );
185 } 185 }
186} 186}
187 187
188void MainWindow::addCheckbook( CBInfo *cb ) 188void MainWindow::addCheckbook( CBInfo *cb )
189{ 189{
190 QListViewItem *lvi = new QListViewItem( cbList ); 190 QListViewItem *lvi = new QListViewItem( cbList );
191 if ( _cfg.getShowLocks() && !cb->password().isNull() ) 191 if ( _cfg.getShowLocks() && !cb->password().isNull() )
192 { 192 {
193 lvi->setPixmap( 0, lockIcon ); 193 lvi->setPixmap( 0, lockIcon );
194 } 194 }
195 lvi->setText( posName, cb->name() ); 195 lvi->setText( posName, cb->name() );
196 if ( _cfg.getShowBalances() ) 196 if ( _cfg.getShowBalances() )
197 { 197 {
198 QString balance; 198 QString balance;
199 balance.sprintf( "%.2f", cb->balance() ); 199 balance.sprintf( "%.2f", cb->balance() );
200 balance.prepend( _cfg.getCurrencySymbol() ); 200 balance.prepend( _cfg.getCurrencySymbol() );
201 lvi->setText( posName + 1, balance ); 201 lvi->setText( posName + 1, balance );
202 } 202 }
203} 203}
204 204
205void MainWindow::buildFilename( const QString &name ) 205void MainWindow::buildFilename( const QString &name )
206{ 206{
207 tempFilename = cbDir; 207 tempFilename = cbDir;
208 tempFilename.append( name ); 208 tempFilename.append( name );
209 tempFilename.append( ".qcb" ); 209 tempFilename.append( ".qcb" );
210} 210}
211 211
212void MainWindow::slotNew() 212void MainWindow::slotNew()
213{ 213{
214 CBInfo *cb = new CBInfo(); 214 CBInfo *cb = new CBInfo();
215 215
216 Checkbook *currcb = new Checkbook( this, cb, &_cfg ); 216 Checkbook *currcb = new Checkbook( this, cb, &_cfg );
217 if ( QPEApplication::execDialog( currcb ) == QDialog::Accepted ) 217 if ( QPEApplication::execDialog( currcb ) == QDialog::Accepted )
218 { 218 {
219 // Save new checkbook 219 // Save new checkbook
220 buildFilename( cb->name() ); 220 buildFilename( cb->name() );
221 _cfg.setLastBook( cb->name() ); 221 _cfg.setLastBook( cb->name() );
222 cb->setFilename( tempFilename ); 222 cb->setFilename( tempFilename );
223 cb->write(); 223 cb->write();
224 224
225 // Add to listbox 225 // Add to listbox
226 checkbooks->inSort( cb ); 226 checkbooks->inSort( cb );
227 addCheckbook( cb ); 227 addCheckbook( cb );
228 } 228 }
229 delete currcb; 229 delete currcb;
230} 230}
231 231
232// --- slotEdit --------------------------------------------------------------- 232// --- slotEdit ---------------------------------------------------------------
233void MainWindow::slotEdit() 233void MainWindow::slotEdit()
234{ 234{
235 // get name and open it 235 // get name and open it
236 QListViewItem *curritem = cbList->currentItem(); 236 QListViewItem *curritem = cbList->currentItem();
237 if ( !curritem ) 237 if ( !curritem )
238 return; 238 return;
239 openBook( curritem ); 239 openBook( curritem );
240} 240}
241 241
242 242
243// --- openBook --------------------------------------------------------------- 243// --- openBook ---------------------------------------------------------------
244void MainWindow::openBook(QListViewItem *curritem) 244void MainWindow::openBook(QListViewItem *curritem)
245{ 245{
246 if ( !curritem ) return;
246 // find book in List 247 // find book in List
247 QString currname=curritem->text(posName); 248 QString currname=curritem->text(posName);
248 CBInfo *cb = checkbooks->first(); 249 CBInfo *cb = checkbooks->first();
249 while ( cb ) { 250 while ( cb ) {
250 if ( cb->name() == currname ) 251 if ( cb->name() == currname )
251 break; 252 break;
252 cb = checkbooks->next(); 253 cb = checkbooks->next();
253 } 254 }
254 if ( !cb ) return; 255 if ( !cb ) return;
255 256
256 // 257 //
257 buildFilename( currname ); 258 buildFilename( currname );
258 float currbalance = cb->balance(); 259 float currbalance = cb->balance();
259 bool currlock = !cb->password().isNull(); 260 bool currlock = !cb->password().isNull();
260 261
261 if ( currlock ) 262 if ( currlock )
262 { 263 {
263 Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); 264 Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) );
264 if ( pw->exec() != QDialog::Accepted || pw->password != cb->password() ) 265 if ( pw->exec() != QDialog::Accepted || pw->password != cb->password() )
265 { 266 {
266 delete pw; 267 delete pw;
267 return; 268 return;
268 } 269 }
269 delete pw; 270 delete pw;
270 } 271 }
271 272
272 _cfg.setLastBook( currname ); 273 _cfg.setLastBook( currname );
273 Checkbook *currcb = new Checkbook( this, cb, &_cfg ); 274 Checkbook *currcb = new Checkbook( this, cb, &_cfg );
274 if ( QPEApplication::execDialog( currcb ) == QDialog::Accepted ) 275 if ( QPEApplication::execDialog( currcb ) == QDialog::Accepted )
275 { 276 {
276 QString newname = cb->name(); 277 QString newname = cb->name();
277 if ( currname != newname ) 278 if ( currname != newname )
278 { 279 {
279 // Update name if changed 280 // Update name if changed
280 if( curritem ) { 281 curritem->setText( posName, newname );
281 curritem->setText( posName, newname ); 282 cbList->sort();
282 cbList->sort();
283 }
284 _cfg.setLastBook( newname ); 283 _cfg.setLastBook( newname );
285 284
286 // Remove old file 285 // Remove old file
287 QFile f( tempFilename ); 286 QFile f( tempFilename );
288 if ( f.exists() ) 287 if ( f.exists() )
289 f.remove(); 288 f.remove();
290 289
291 // Get new filename 290 // Get new filename
292 buildFilename( newname ); 291 buildFilename( newname );
293 cb->setFilename( tempFilename ); 292 cb->setFilename( tempFilename );
294 } 293 }
295 294
296 cb->write(); 295 cb->write();
297 296
298 // Update lock if changed 297 // Update lock if changed
299 if ( _cfg.getShowLocks() && !cb->password().isNull() != currlock ) 298 if ( _cfg.getShowLocks() && !cb->password().isNull() != currlock )
300 { 299 {
301 if ( !cb->password().isNull() ) 300 if ( !cb->password().isNull() )
302 curritem->setPixmap( 0, lockIcon ); 301 curritem->setPixmap( 0, lockIcon );
303 else 302 else
304 curritem->setPixmap( 0, nullIcon ); 303 curritem->setPixmap( 0, nullIcon );
305 } 304 }
306 305
307 // Update balance if changed 306 // Update balance if changed
308 if ( _cfg.getShowBalances() && cb->balance() != currbalance ) 307 if ( _cfg.getShowBalances() && cb->balance() != currbalance )
309 { 308 {
310 QString tempstr; 309 QString tempstr;
311 tempstr.sprintf( "%.2f", cb->balance() ); 310 tempstr.sprintf( "%.2f", cb->balance() );
312 tempstr.prepend( _cfg.getCurrencySymbol() ); 311 tempstr.prepend( _cfg.getCurrencySymbol() );
313 curritem->setText( posName + 1, tempstr ); 312 curritem->setText( posName + 1, tempstr );
314 } 313 }
315 314
316 // write config, if needed 315 // write config, if needed
317 if( _cfg.isDirty() ) { 316 if( _cfg.isDirty() ) {
318 Config config("checkbook"); 317 Config config("checkbook");
319 _cfg.writeConfig( config ); 318 _cfg.writeConfig( config );
320 } 319 }
321 } 320 }
322 delete currcb; 321 delete currcb;
323} 322}
324 323
325// --- slotDelete ------------------------------------------------------------- 324// --- slotDelete -------------------------------------------------------------
326void MainWindow::slotDelete() 325void MainWindow::slotDelete()
327{ 326{
328 QString currname = cbList->currentItem()->text( posName ); 327 QString currname = cbList->currentItem()->text( posName );
329 328
330 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), currname ) ) 329 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), currname ) )
331 { 330 {
332 buildFilename( currname ); 331 buildFilename( currname );
333 QFile f( tempFilename ); 332 QFile f( tempFilename );
334 if ( f.exists() ) 333 if ( f.exists() )
335 { 334 {
336 f.remove(); 335 f.remove();
337 } 336 }
338 337
339 delete cbList->currentItem(); 338 delete cbList->currentItem();
340 } 339 }
341} 340}
342 341
343// --- slotConfigure ---------------------------------------------------------- 342// --- slotConfigure ----------------------------------------------------------
344void MainWindow::slotConfigure() 343void MainWindow::slotConfigure()
345{ 344{
346 Configuration *cfgdlg = new Configuration( this, _cfg ); 345 Configuration *cfgdlg = new Configuration( this, _cfg );
347 if ( QPEApplication::execDialog( cfgdlg ) == QDialog::Accepted ) 346 if ( QPEApplication::execDialog( cfgdlg ) == QDialog::Accepted )
348 { 347 {
349 // read data from config dialog & save it 348 // read data from config dialog & save it
350 cfgdlg->saveConfig( _cfg ); 349 cfgdlg->saveConfig( _cfg );
351 writeConfig(); 350 writeConfig();
352 buildList(); 351 buildList();
353 } 352 }
354 delete cfgdlg; 353 delete cfgdlg;
355} 354}
356 355
357 356
358// --- writeConfig -------------------------------------------------------------- 357// --- writeConfig --------------------------------------------------------------
359void MainWindow::writeConfig() 358void MainWindow::writeConfig()
360{ 359{
361 Config config("checkbook"); 360 Config config("checkbook");
362 _cfg.writeConfig( config ); 361 _cfg.writeConfig( config );
363} 362}
diff --git a/noncore/apps/opie-console/procctl.cpp b/noncore/apps/opie-console/procctl.cpp
index a44529b..5239e26 100644
--- a/noncore/apps/opie-console/procctl.cpp
+++ b/noncore/apps/opie-console/procctl.cpp
@@ -1,97 +1,100 @@
1#include <sys/wait.h> 1#include <sys/wait.h>
2 2
3#include <fcntl.h> 3#include <fcntl.h>
4#include <unistd.h> 4#include <unistd.h>
5 5
6#include "procctl.h" 6#include "procctl.h"
7 7
8ProcContainer *ProcCtl::m_last = 0; 8ProcContainer *ProcCtl::m_last = 0;
9ProcCtl* ProcCtl::m_self = 0; 9ProcCtl* ProcCtl::m_self = 0;
10 10
11ProcCtl::ProcCtl() { 11ProcCtl::ProcCtl() {
12 signal( SIGCHLD, signal_handler ); 12 signal( SIGCHLD, signal_handler );
13} 13}
14ProcCtl::~ProcCtl() { 14ProcCtl::~ProcCtl() {
15} 15}
16ProcCtl* ProcCtl::self() { 16ProcCtl* ProcCtl::self() {
17 if (!m_self ) { 17 if (!m_self ) {
18 m_self = new ProcCtl; 18 m_self = new ProcCtl;
19 } 19 }
20 return m_self; 20 return m_self;
21} 21}
22void ProcCtl::add(pid_t pi, int fd ) { 22void ProcCtl::add(pid_t pi, int fd ) {
23 ProcContainer * con = new ProcContainer; 23 ProcContainer * con = new ProcContainer;
24 //memset(con, 0, sizeof(con) ); 24 //memset(con, 0, sizeof(con) );
25 con->pid = pi; 25 con->pid = pi;
26 con->fd = fd; 26 con->fd = fd;
27 con->status = 0; 27 con->status = 0;
28 con->prev = m_last; 28 con->prev = m_last;
29 29
30 m_last = con; 30 m_last = con;
31 31
32} 32}
33void ProcCtl::remove( pid_t pi ) { 33void ProcCtl::remove( pid_t pi ) {
34 /* 34 /*
35 * We first check if the last item 35 * We first check if the last item
36 * is equal to pi the we 36 * is equal to pi the we
37 * 37 *
38 */ 38 */
39 ProcContainer* con; 39 ProcContainer* con;
40 if (m_last->pid == pi ) { 40 if (m_last->pid == pi ) {
41 con = m_last; 41 con = m_last;
42 m_last = con->prev; 42 m_last = con->prev;
43 delete con; 43 delete con;
44 return; 44 return;
45 } 45 }
46 46
47 con = m_last; 47 con = m_last;
48 ProcContainer* forw = 0l; 48 ProcContainer* forw = 0l;
49 while (con ) { 49 while (con ) {
50 /* remove it */ 50 /* remove it */
51 if ( pi == con->pid ) { 51 if ( pi == con->pid ) {
52 forw->prev = con->prev; 52 if (forw)
53 forw->prev = con->prev;
54 else
55 forw = con->prev;
53 delete con; 56 delete con;
54 return; 57 return;
55 } 58 }
56 59
57 forw = con; 60 forw = con;
58 con = con->prev; 61 con = con->prev;
59 } 62 }
60 63
61} 64}
62void ProcCtl::remove( ProcContainer con ) { 65void ProcCtl::remove( ProcContainer con ) {
63 remove( con.pid ); 66 remove( con.pid );
64} 67}
65int ProcCtl::status(pid_t pid )const{ 68int ProcCtl::status(pid_t pid )const{
66 ProcContainer *con = m_last; 69 ProcContainer *con = m_last;
67 while (con) { 70 while (con) {
68 if (con->pid == pid ) 71 if (con->pid == pid )
69 return con->status; 72 return con->status;
70 con = con->prev; 73 con = con->prev;
71 } 74 }
72 return -1; 75 return -1;
73} 76}
74void ProcCtl::signal_handler(int) { 77void ProcCtl::signal_handler(int) {
75 int status; 78 int status;
76 signal( SIGCHLD, signal_handler ); 79 signal( SIGCHLD, signal_handler );
77 pid_t pi = waitpid( -1, &status, WNOHANG ); 80 pid_t pi = waitpid( -1, &status, WNOHANG );
78 81
79 /* 82 /*
80 * find the container for pid 83 * find the container for pid
81 * 84 *
82 */ 85 */
83 if ( pi < 0 ) { 86 if ( pi < 0 ) {
84 return; 87 return;
85 } 88 }
86 89
87 ProcContainer* con = m_last; 90 ProcContainer* con = m_last;
88 while (con) { 91 while (con) {
89 if ( con->pid == pi ) { 92 if ( con->pid == pi ) {
90 con->status = status; 93 con->status = status;
91 char result = 1; 94 char result = 1;
92 /* give a 'signal' */ 95 /* give a 'signal' */
93 ::write(con->fd, &result, 1 ); 96 ::write(con->fd, &result, 1 );
94 } 97 }
95 con = con->prev; 98 con = con->prev;
96 } 99 }
97} 100}
diff --git a/noncore/apps/tinykate/libkate/document/katedocument.cpp b/noncore/apps/tinykate/libkate/document/katedocument.cpp
index b82a86a..692fd46 100644
--- a/noncore/apps/tinykate/libkate/document/katedocument.cpp
+++ b/noncore/apps/tinykate/libkate/document/katedocument.cpp
@@ -1922,466 +1922,467 @@ void KateDocument::updateLines(int startLine, int endLine, int flags, int cursor
1922 if (line > 0) ctxNum = getTextLine(line - 1)->getContext(); 1922 if (line > 0) ctxNum = getTextLine(line - 1)->getContext();
1923 do { 1923 do {
1924// kdDebug(13020)<<QString("**************Working on line: %1").arg(line)<<endl; 1924// kdDebug(13020)<<QString("**************Working on line: %1").arg(line)<<endl;
1925 textLine = getTextLine(line); 1925 textLine = getTextLine(line);
1926 if (textLine==0) kdDebug(13020)<<"****updateLines()>> error textLine==0"<<endl; 1926 if (textLine==0) kdDebug(13020)<<"****updateLines()>> error textLine==0"<<endl;
1927 if (line <= endLine && line != cursorY) { 1927 if (line <= endLine && line != cursorY) {
1928 if (flags & KateView::cfRemoveSpaces) textLine->removeSpaces(); 1928 if (flags & KateView::cfRemoveSpaces) textLine->removeSpaces();
1929 updateMaxLength(textLine); 1929 updateMaxLength(textLine);
1930 } 1930 }
1931 endCtx = textLine->getContext(); 1931 endCtx = textLine->getContext();
1932// odebug << "DOHIGHLIGHT" << oendl; 1932// odebug << "DOHIGHLIGHT" << oendl;
1933 1933
1934 ctxNum = m_highlight->doHighlight(ctxNum,textLine); 1934 ctxNum = m_highlight->doHighlight(ctxNum,textLine);
1935 textLine->setContext(ctxNum); 1935 textLine->setContext(ctxNum);
1936 line++; 1936 line++;
1937 } while ((buffer->line(line)!=0) && (line <= endLine || endCtx != ctxNum)); 1937 } while ((buffer->line(line)!=0) && (line <= endLine || endCtx != ctxNum));
1938// kdDebug(13020)<<"updateLines :: while loop left"<<endl; 1938// kdDebug(13020)<<"updateLines :: while loop left"<<endl;
1939 tagLines(startLine, line - 1); 1939 tagLines(startLine, line - 1);
1940} 1940}
1941 1941
1942 1942
1943void KateDocument::updateMaxLength(TextLine::Ptr &textLine) { 1943void KateDocument::updateMaxLength(TextLine::Ptr &textLine) {
1944 int len; 1944 int len;
1945 1945
1946 len = textWidth(textLine,textLine->length()); 1946 len = textWidth(textLine,textLine->length());
1947 1947
1948 if (len > maxLength) { 1948 if (len > maxLength) {
1949 longestLine = textLine; 1949 longestLine = textLine;
1950 maxLength = len; 1950 maxLength = len;
1951 newDocGeometry = true; 1951 newDocGeometry = true;
1952 } else { 1952 } else {
1953 if (!longestLine || (textLine == longestLine && len <= maxLength*3/4)) { 1953 if (!longestLine || (textLine == longestLine && len <= maxLength*3/4)) {
1954 maxLength = -1; 1954 maxLength = -1;
1955 for (int i = 0; i < numLines();i++) { 1955 for (int i = 0; i < numLines();i++) {
1956 textLine = getTextLine(i); 1956 textLine = getTextLine(i);
1957 len = textWidth(textLine,textLine->length()); 1957 len = textWidth(textLine,textLine->length());
1958 if (len > maxLength) { 1958 if (len > maxLength) {
1959 maxLength = len; 1959 maxLength = len;
1960 longestLine = textLine; 1960 longestLine = textLine;
1961 } 1961 }
1962 } 1962 }
1963 newDocGeometry = true; 1963 newDocGeometry = true;
1964 } 1964 }
1965 } 1965 }
1966} 1966}
1967 1967
1968void KateDocument::slotBufferChanged() { 1968void KateDocument::slotBufferChanged() {
1969 newDocGeometry = true; 1969 newDocGeometry = true;
1970 //updateLines();//JW 1970 //updateLines();//JW
1971 updateViews(); 1971 updateViews();
1972} 1972}
1973 1973
1974void KateDocument::slotBufferHighlight(long start,long stop) { 1974void KateDocument::slotBufferHighlight(long start,long stop) {
1975 kdDebug(13020)<<"KateDocument::slotBufferHighlight"<<QString("%1-%2").arg(start).arg(stop)<<endl; 1975 kdDebug(13020)<<"KateDocument::slotBufferHighlight"<<QString("%1-%2").arg(start).arg(stop)<<endl;
1976 updateLines(start,stop); 1976 updateLines(start,stop);
1977// buffer->startLoadTimer(); 1977// buffer->startLoadTimer();
1978} 1978}
1979 1979
1980void KateDocument::updateViews(KateView *exclude) { 1980void KateDocument::updateViews(KateView *exclude) {
1981 KateView *view; 1981 KateView *view;
1982 int flags; 1982 int flags;
1983 bool markState = hasMarkedText(); 1983 bool markState = hasMarkedText();
1984 1984
1985 flags = (newDocGeometry) ? KateView::ufDocGeometry : 0; 1985 flags = (newDocGeometry) ? KateView::ufDocGeometry : 0;
1986 for (view = views.first(); view != 0L; view = views.next() ) { 1986 for (view = views.first(); view != 0L; view = views.next() ) {
1987 if (view != exclude) view->updateView(flags); 1987 if (view != exclude) view->updateView(flags);
1988 1988
1989 // notify every view about the changed mark state.... 1989 // notify every view about the changed mark state....
1990 if (oldMarkState != markState) emit view->newMarkStatus(); 1990 if (oldMarkState != markState) emit view->newMarkStatus();
1991 } 1991 }
1992 oldMarkState = markState; 1992 oldMarkState = markState;
1993 newDocGeometry = false; 1993 newDocGeometry = false;
1994} 1994}
1995 1995
1996QColor &KateDocument::cursorCol(int x, int y) { 1996QColor &KateDocument::cursorCol(int x, int y) {
1997 int attr; 1997 int attr;
1998 Attribute *a; 1998 Attribute *a;
1999 1999
2000 TextLine::Ptr textLine = getTextLine(y); 2000 TextLine::Ptr textLine = getTextLine(y);
2001 attr = textLine->getRawAttr(x); 2001 attr = textLine->getRawAttr(x);
2002 a = &m_attribs[attr & taAttrMask]; 2002 a = &m_attribs[attr & taAttrMask];
2003 if (attr & taSelected) return a->selCol; else return a->col; 2003 if (attr & taSelected) return a->selCol; else return a->col;
2004} 2004}
2005 2005
2006void KateDocument::paintTextLine(QPainter &paint, int line, int xStart, int xEnd, bool showTabs) 2006void KateDocument::paintTextLine(QPainter &paint, int line, int xStart, int xEnd, bool showTabs)
2007{ 2007{
2008 paintTextLine (paint, line, 0, xStart, xEnd, showTabs); 2008 paintTextLine (paint, line, 0, xStart, xEnd, showTabs);
2009} 2009}
2010 2010
2011void KateDocument::paintTextLine(QPainter &paint, int line, int y, int xStart, int xEnd, bool showTabs) 2011void KateDocument::paintTextLine(QPainter &paint, int line, int y, int xStart, int xEnd, bool showTabs)
2012{ 2012{
2013 TextLine::Ptr textLine; 2013 TextLine::Ptr textLine;
2014 int len; 2014 int len;
2015 const QChar *s; 2015 const QChar *s;
2016 int z, x; 2016 int z, x;
2017 QChar ch; 2017 QChar ch;
2018 Attribute *a = 0L; 2018 Attribute *attrptr = 0L;
2019 int attr, nextAttr; 2019 int attr, nextAttr;
2020 int xs; 2020 int xs;
2021 int xc, zc; 2021 int xc, zc;
2022 2022
2023 if (line > lastLine()) { 2023 if (line > lastLine()) {
2024 paint.fillRect(0, y, xEnd - xStart,fontHeight, colors[0]); 2024 paint.fillRect(0, y, xEnd - xStart,fontHeight, colors[0]);
2025 return; 2025 return;
2026 } 2026 }
2027 2027
2028 textLine = getTextLine(line); 2028 textLine = getTextLine(line);
2029 len = textLine->length(); 2029 len = textLine->length();
2030 s = textLine->getText(); 2030 s = textLine->getText();
2031 2031
2032 // skip to first visible character 2032 // skip to first visible character
2033 x = 0; 2033 x = 0;
2034 z = 0; 2034 z = 0;
2035 do { 2035 do {
2036 xc = x; 2036 xc = x;
2037 zc = z; 2037 zc = z;
2038 if (z == len) break; 2038 if (z == len) break;
2039 ch = s[z];//textLine->getChar(z); 2039 ch = s[z];//textLine->getChar(z);
2040 if (ch == '\t') { 2040 if (ch == '\t') {
2041 x += m_tabWidth - (x % m_tabWidth); 2041 x += m_tabWidth - (x % m_tabWidth);
2042 } else { 2042 } else {
2043 a = &m_attribs[textLine->getAttr(z)]; 2043 attrptr = &m_attribs[textLine->getAttr(z)];
2044 2044
2045 if (a->bold && a->italic) 2045 if (attrptr->bold && attrptr->italic)
2046 x += myFontMetricsBI.width(ch); 2046 x += myFontMetricsBI.width(ch);
2047 else if (a->bold) 2047 else if (attrptr->bold)
2048 x += myFontMetricsBold.width(ch); 2048 x += myFontMetricsBold.width(ch);
2049 else if (a->italic) 2049 else if (attrptr->italic)
2050 x += myFontMetricsItalic.width(ch); 2050 x += myFontMetricsItalic.width(ch);
2051 else 2051 else
2052 x += myFontMetrics.width(ch); 2052 x += myFontMetrics.width(ch);
2053 } 2053 }
2054 z++; 2054 z++;
2055 } while (x <= xStart); 2055 } while (x <= xStart);
2056 2056
2057 // draw background 2057 // draw background
2058 xs = xStart; 2058 xs = xStart;
2059 attr = textLine->getRawAttr(zc); 2059 attr = textLine->getRawAttr(zc);
2060 while (x < xEnd) 2060 while (x < xEnd)
2061 { 2061 {
2062 nextAttr = textLine->getRawAttr(z); 2062 nextAttr = textLine->getRawAttr(z);
2063 if ((nextAttr ^ attr) & taSelected) 2063 if ((nextAttr ^ attr) & taSelected)
2064 { 2064 {
2065 if (attr & taSelected) 2065 if (attr & taSelected)
2066 paint.fillRect(xs - xStart, y, x - xs, fontHeight, colors[1]); 2066 paint.fillRect(xs - xStart, y, x - xs, fontHeight, colors[1]);
2067 else 2067 else
2068 paint.fillRect(xs - xStart, y, x - xs, fontHeight, colors[0]); 2068 paint.fillRect(xs - xStart, y, x - xs, fontHeight, colors[0]);
2069 2069
2070 xs = x; 2070 xs = x;
2071 attr = nextAttr; 2071 attr = nextAttr;
2072 } 2072 }
2073 2073
2074 if (z == len) break; 2074 if (z == len) break;
2075 2075
2076 ch = s[z];//textLine->getChar(z); 2076 ch = s[z];//textLine->getChar(z);
2077 2077
2078 if (ch == '\t') 2078 if (ch == '\t')
2079 x += m_tabWidth - (x % m_tabWidth); 2079 x += m_tabWidth - (x % m_tabWidth);
2080 else 2080 else
2081 { 2081 {
2082 a = &m_attribs[textLine->getAttr(z)]; 2082 attrptr = &m_attribs[textLine->getAttr(z)];
2083 2083
2084 if (a->bold && a->italic) 2084 if (attrptr->bold && attrptr->italic)
2085 x += myFontMetricsBI.width(ch); 2085 x += myFontMetricsBI.width(ch);
2086 else if (a->bold) 2086 else if (attrptr->bold)
2087 x += myFontMetricsBold.width(ch); 2087 x += myFontMetricsBold.width(ch);
2088 else if (a->italic) 2088 else if (attrptr->italic)
2089 x += myFontMetricsItalic.width(ch); 2089 x += myFontMetricsItalic.width(ch);
2090 else 2090 else
2091 x += myFontMetrics.width(ch); 2091 x += myFontMetrics.width(ch);
2092 } 2092 }
2093 z++; 2093 z++;
2094 } 2094 }
2095 2095
2096 if (attr & taSelected) 2096 if (attr & taSelected)
2097 paint.fillRect(xs - xStart, y, xEnd - xs, fontHeight, colors[1]); 2097 paint.fillRect(xs - xStart, y, xEnd - xs, fontHeight, colors[1]);
2098 else 2098 else
2099 paint.fillRect(xs - xStart, y, xEnd - xs, fontHeight, colors[0]); 2099 paint.fillRect(xs - xStart, y, xEnd - xs, fontHeight, colors[0]);
2100 2100
2101 len = z; //reduce length to visible length 2101 len = z; //reduce length to visible length
2102 2102
2103 // draw text 2103 // draw text
2104 x = xc; 2104 x = xc;
2105 z = zc; 2105 z = zc;
2106 y += fontAscent;// -1; 2106 y += fontAscent;// -1;
2107 attr = -1; 2107 attr = -1;
2108 while (z < len) { 2108 while (z < len) {
2109 ch = s[z];//textLine->getChar(z); 2109 ch = s[z];//textLine->getChar(z);
2110 if (ch == '\t') { 2110 if (ch == '\t') {
2111 if (z > zc) { 2111 if (z > zc) {
2112 //this should cause no copy at all 2112 //this should cause no copy at all
2113 QConstString str((QChar *) &s[zc], z - zc /*+1*/); 2113 QConstString str((QChar *) &s[zc], z - zc /*+1*/);
2114 QString s = str.string(); 2114 QString s = str.string();
2115 paint.drawText(x - xStart, y, s); 2115 paint.drawText(x - xStart, y, s);
2116 2116
2117 if (a->bold && a->italic) 2117 if (attrptr && attrptr->bold && attrptr->italic)
2118 x += myFontMetricsBI.width(s); 2118 x += myFontMetricsBI.width(s);
2119 else if (a->bold) 2119 else if (attrptr && attrptr->bold)
2120 x += myFontMetricsBold.width(s); 2120 x += myFontMetricsBold.width(s);
2121 else if (a->italic) 2121 else if (attrptr && attrptr->italic)
2122 x += myFontMetricsItalic.width(s); 2122 x += myFontMetricsItalic.width(s);
2123 else 2123 else
2124 x += myFontMetrics.width(s); 2124 x += myFontMetrics.width(s);
2125 } 2125 }
2126 zc = z +1; 2126 zc = z +1;
2127 2127
2128 if (showTabs) { 2128 if (showTabs) {
2129 nextAttr = textLine->getRawAttr(z); 2129 nextAttr = textLine->getRawAttr(z);
2130 if (nextAttr != attr) { 2130 if (nextAttr != attr) {
2131 attr = nextAttr; 2131 attr = nextAttr;
2132 a = &m_attribs[attr & taAttrMask]; 2132 attrptr = &m_attribs[attr & taAttrMask];
2133 2133
2134 if (attr & taSelected) paint.setPen(a->selCol); 2134 if (attr & taSelected) paint.setPen(attrptr->selCol);
2135 else paint.setPen(a->col); 2135 else paint.setPen(attrptr->col);
2136 2136
2137 if (a->bold && a->italic) 2137 if (attrptr->bold && attrptr->italic)
2138 paint.setFont(myFontBI); 2138 paint.setFont(myFontBI);
2139 else if (a->bold) 2139 else if (attrptr->bold)
2140 paint.setFont(myFontBold); 2140 paint.setFont(myFontBold);
2141 else if (a->italic) 2141 else if (attrptr->italic)
2142 paint.setFont(myFontItalic); 2142 paint.setFont(myFontItalic);
2143 else 2143 else
2144 paint.setFont(myFont); 2144 paint.setFont(myFont);
2145 } 2145 }
2146 2146
2147// paint.drawLine(x - xStart, y -2, x - xStart, y);
2148// paint.drawLine(x - xStart, y, x - xStart + 2, y);
2149 paint.drawPoint(x - xStart, y); 2147 paint.drawPoint(x - xStart, y);
2150 paint.drawPoint(x - xStart +1, y); 2148 paint.drawPoint(x - xStart +1, y);
2151 paint.drawPoint(x - xStart, y -1); 2149 paint.drawPoint(x - xStart, y -1);
2152 } 2150 }
2153 x += m_tabWidth - (x % m_tabWidth); 2151 x += m_tabWidth - (x % m_tabWidth);
2154 } else { 2152 } else {
2155 nextAttr = textLine->getRawAttr(z); 2153 nextAttr = textLine->getRawAttr(z);
2156 if (nextAttr != attr) { 2154 if (nextAttr != attr) {
2157 if (z > zc) { 2155 if (z > zc) {
2158 QConstString str((QChar *) &s[zc], z - zc /*+1*/); 2156 QConstString str((QChar *) &s[zc], z - zc /*+1*/);
2159 QString s = str.string(); 2157 QString s = str.string();
2160 paint.drawText(x - xStart, y, s); 2158 paint.drawText(x - xStart, y, s);
2161 2159
2162 if (a->bold && a->italic) 2160 if (attrptr->bold && attrptr->italic)
2163 x += myFontMetricsBI.width(s); 2161 x += myFontMetricsBI.width(s);
2164 else if (a->bold) 2162 else if (attrptr->bold)
2165 x += myFontMetricsBold.width(s); 2163 x += myFontMetricsBold.width(s);
2166 else if (a->italic) 2164 else if (attrptr->italic)
2167 x += myFontMetricsItalic.width(s); 2165 x += myFontMetricsItalic.width(s);
2168 else 2166 else
2169 x += myFontMetrics.width(s); 2167 x += myFontMetrics.width(s);
2170 zc = z; 2168 zc = z;
2171 } 2169 }
2172 attr = nextAttr; 2170 attr = nextAttr;
2173 a = &m_attribs[attr & taAttrMask]; 2171 attrptr = &m_attribs[attr & taAttrMask];
2174 2172
2175 if (attr & taSelected) paint.setPen(a->selCol); 2173 if (attr & taSelected) paint.setPen(attrptr->selCol);
2176 else paint.setPen(a->col); 2174 else paint.setPen(attrptr->col);
2177 2175
2178 if (a->bold && a->italic) 2176 if (attrptr->bold && attrptr->italic)
2179 paint.setFont(myFontBI); 2177 paint.setFont(myFontBI);
2180 else if (a->bold) 2178 else if (attrptr->bold)
2181 paint.setFont(myFontBold); 2179 paint.setFont(myFontBold);
2182 else if (a->italic) 2180 else if (attrptr->italic)
2183 paint.setFont(myFontItalic); 2181 paint.setFont(myFontItalic);
2184 else 2182 else
2185 paint.setFont(myFont); 2183 paint.setFont(myFont);
2186 } 2184 }
2187 } 2185 }
2188 z++; 2186 z++;
2189 } 2187 }
2190 if (z > zc) { 2188 if (z > zc) {
2191 QConstString str((QChar *) &s[zc], z - zc /*+1*/); 2189 QConstString str((QChar *) &s[zc], z - zc /*+1*/);
2192 paint.drawText(x - xStart, y, str.string()); 2190 paint.drawText(x - xStart, y, str.string());
2193 } 2191 }
2194} 2192}
2195 2193
2196// Applies the search context, and returns whether a match was found. If one is, 2194// Applies the search context, and returns whether a match was found. If one is,
2197// the length of the string matched is also returned. 2195// the length of the string matched is also returned.
2198bool KateDocument::doSearch(SConfig &sc, const QString &searchFor) { 2196bool KateDocument::doSearch(SConfig &sc, const QString &searchFor) {
2199 int line, col; 2197 int line, col;
2200 int searchEnd; 2198 int searchEnd;
2201 int bufLen, tlen; 2199 int bufLen, tlen;
2202 QChar *t; 2200 QChar *t;
2203 TextLine::Ptr textLine; 2201 TextLine::Ptr textLine;
2204 int pos, newPos; 2202 int pos, newPos;
2205 2203
2206 if (searchFor.isEmpty()) return false; 2204 if (searchFor.isEmpty()) return false;
2207 2205
2208 bufLen = 0; 2206 bufLen = 0;
2209 t = 0L; 2207 t = 0L;
2210 2208
2211 line = sc.cursor.y; 2209 line = sc.cursor.y;
2212 col = sc.cursor.x; 2210 col = sc.cursor.x;
2213 if (!(sc.flags & KateView::sfBackward)) { 2211 if (!(sc.flags & KateView::sfBackward)) {
2214 //forward search 2212 //forward search
2215 if (sc.flags & KateView::sfSelected) { 2213 if (sc.flags & KateView::sfSelected) {
2216 if (line < selectStart) { 2214 if (line < selectStart) {
2217 line = selectStart; 2215 line = selectStart;
2218 col = 0; 2216 col = 0;
2219 } 2217 }
2220 searchEnd = selectEnd; 2218 searchEnd = selectEnd;
2221 } else searchEnd = lastLine(); 2219 } else searchEnd = lastLine();
2222 2220
2223 while (line <= searchEnd) { 2221 while (line <= searchEnd) {
2224 textLine = getTextLine(line); 2222 textLine = getTextLine(line);
2225 tlen = textLine->length(); 2223 tlen = textLine->length();
2226 if (tlen > bufLen) { 2224 if (tlen > bufLen) {
2227 delete [] t; 2225 delete [] t;
2228 bufLen = (tlen + 255) & (~255); 2226 bufLen = (tlen + 255) & (~255);
2229 t = new QChar[bufLen]; 2227 t = new QChar[bufLen];
2230 } 2228 } else if (!t)
2229 t = new QChar[bufLen];
2230
2231 memcpy(t, textLine->getText(), tlen*sizeof(QChar)); 2231 memcpy(t, textLine->getText(), tlen*sizeof(QChar));
2232 if (sc.flags & KateView::sfSelected) { 2232 if (sc.flags & KateView::sfSelected) {
2233 pos = 0; 2233 pos = 0;
2234 do { 2234 do {
2235 pos = textLine->findSelected(pos); 2235 pos = textLine->findSelected(pos);
2236 newPos = textLine->findUnselected(pos); 2236 newPos = textLine->findUnselected(pos);
2237 memset(&t[pos], 0, (newPos - pos)*sizeof(QChar)); 2237 memset(&t[pos], 0, (newPos - pos)*sizeof(QChar));
2238 pos = newPos; 2238 pos = newPos;
2239 } while (pos < tlen); 2239 } while (pos < tlen);
2240 } 2240 }
2241 2241
2242 QString text(t, tlen); 2242 QString text(t, tlen);
2243 if (sc.flags & KateView::sfWholeWords) { 2243 if (sc.flags & KateView::sfWholeWords) {
2244 // Until the end of the line... 2244 // Until the end of the line...
2245 while (col < tlen) { 2245 while (col < tlen) {
2246 // ...find the next match. 2246 // ...find the next match.
2247 col = sc.search(text, col); 2247 col = sc.search(text, col);
2248 if (col != -1) { 2248 if (col != -1) {
2249 // Is the match delimited correctly? 2249 // Is the match delimited correctly?
2250 if (((col == 0) || (!m_highlight->isInWord(t[col]))) && 2250 if (((col == 0) || (!m_highlight->isInWord(t[col]))) &&
2251 ((col + sc.matchedLength == tlen) || (!m_highlight->isInWord(t[col + sc.matchedLength])))) { 2251 ((col + sc.matchedLength == tlen) || (!m_highlight->isInWord(t[col + sc.matchedLength])))) {
2252 goto found; 2252 goto found;
2253 } 2253 }
2254 else { 2254 else {
2255 // Start again from the next character. 2255 // Start again from the next character.
2256 col++; 2256 col++;
2257 } 2257 }
2258 } 2258 }
2259 else { 2259 else {
2260 // No match. 2260 // No match.
2261 break; 2261 break;
2262 } 2262 }
2263 } 2263 }
2264 } 2264 }
2265 else { 2265 else {
2266 // Non-whole-word search. 2266 // Non-whole-word search.
2267 col = sc.search(text, col); 2267 col = sc.search(text, col);
2268 if (col != -1) 2268 if (col != -1)
2269 goto found; 2269 goto found;
2270 } 2270 }
2271 col = 0; 2271 col = 0;
2272 line++; 2272 line++;
2273 } 2273 }
2274 } else { 2274 } else {
2275 // backward search 2275 // backward search
2276 if (sc.flags & KateView::sfSelected) { 2276 if (sc.flags & KateView::sfSelected) {
2277 if (line > selectEnd) { 2277 if (line > selectEnd) {
2278 line = selectEnd; 2278 line = selectEnd;
2279 col = -1; 2279 col = -1;
2280 } 2280 }
2281 searchEnd = selectStart; 2281 searchEnd = selectStart;
2282 } else searchEnd = 0; 2282 } else searchEnd = 0;
2283 2283
2284 while (line >= searchEnd) { 2284 while (line >= searchEnd) {
2285 textLine = getTextLine(line); 2285 textLine = getTextLine(line);
2286 tlen = textLine->length(); 2286 tlen = textLine->length();
2287 if (tlen > bufLen) { 2287 if (tlen > bufLen) {
2288 delete [] t; 2288 delete [] t;
2289 bufLen = (tlen + 255) & (~255); 2289 bufLen = (tlen + 255) & (~255);
2290 t = new QChar[bufLen]; 2290 t = new QChar[bufLen];
2291 } 2291 } else if (!t)
2292 t = new QChar[bufLen];
2292 memcpy(t, textLine->getText(), tlen*sizeof(QChar)); 2293 memcpy(t, textLine->getText(), tlen*sizeof(QChar));
2293 if (sc.flags & KateView::sfSelected) { 2294 if (sc.flags & KateView::sfSelected) {
2294 pos = 0; 2295 pos = 0;
2295 do { 2296 do {
2296 pos = textLine->findSelected(pos); 2297 pos = textLine->findSelected(pos);
2297 newPos = textLine->findUnselected(pos); 2298 newPos = textLine->findUnselected(pos);
2298 memset(&t[pos], 0, (newPos - pos)*sizeof(QChar)); 2299 memset(&t[pos], 0, (newPos - pos)*sizeof(QChar));
2299 pos = newPos; 2300 pos = newPos;
2300 } while (pos < tlen); 2301 } while (pos < tlen);
2301 } 2302 }
2302 2303
2303 if (col < 0 || col > tlen) col = tlen; 2304 if (col < 0 || col > tlen) col = tlen;
2304 2305
2305 QString text(t, tlen); 2306 QString text(t, tlen);
2306 if (sc.flags & KateView::sfWholeWords) { 2307 if (sc.flags & KateView::sfWholeWords) {
2307 // Until the beginning of the line... 2308 // Until the beginning of the line...
2308 while (col >= 0) { 2309 while (col >= 0) {
2309 // ...find the next match. 2310 // ...find the next match.
2310 col = sc.search(text, col); 2311 col = sc.search(text, col);
2311 if (col != -1) { 2312 if (col != -1) {
2312 // Is the match delimited correctly? 2313 // Is the match delimited correctly?
2313 if (((col == 0) || (!m_highlight->isInWord(t[col]))) && 2314 if (((col == 0) || (!m_highlight->isInWord(t[col]))) &&
2314 ((col + sc.matchedLength == tlen) || (!m_highlight->isInWord(t[col + sc.matchedLength])))) { 2315 ((col + sc.matchedLength == tlen) || (!m_highlight->isInWord(t[col + sc.matchedLength])))) {
2315 goto found; 2316 goto found;
2316 } 2317 }
2317 else { 2318 else {
2318 // Start again from the previous character. 2319 // Start again from the previous character.
2319 col--; 2320 col--;
2320 } 2321 }
2321 } 2322 }
2322 else { 2323 else {
2323 // No match. 2324 // No match.
2324 break; 2325 break;
2325 } 2326 }
2326 } 2327 }
2327 } 2328 }
2328 else { 2329 else {
2329 // Non-whole-word search. 2330 // Non-whole-word search.
2330 col = sc.search(text, col); 2331 col = sc.search(text, col);
2331 if (col != -1) 2332 if (col != -1)
2332 goto found; 2333 goto found;
2333 } 2334 }
2334 col = -1; 2335 col = -1;
2335 line--; 2336 line--;
2336 } 2337 }
2337 } 2338 }
2338 sc.flags |= KateView::sfWrapped; 2339 sc.flags |= KateView::sfWrapped;
2339 return false; 2340 return false;
2340found: 2341found:
2341 if (sc.flags & KateView::sfWrapped) { 2342 if (sc.flags & KateView::sfWrapped) {
2342 if ((line > sc.startCursor.y || (line == sc.startCursor.y && col >= sc.startCursor.x)) 2343 if ((line > sc.startCursor.y || (line == sc.startCursor.y && col >= sc.startCursor.x))
2343 ^ ((sc.flags & KateView::sfBackward) != 0)) return false; 2344 ^ ((sc.flags & KateView::sfBackward) != 0)) return false;
2344 } 2345 }
2345 sc.cursor.x = col; 2346 sc.cursor.x = col;
2346 sc.cursor.y = line; 2347 sc.cursor.y = line;
2347 return true; 2348 return true;
2348} 2349}
2349 2350
2350void KateDocument::tagLine(int line) { 2351void KateDocument::tagLine(int line) {
2351 2352
2352 if (tagStart > line) tagStart = line; 2353 if (tagStart > line) tagStart = line;
2353 if (tagEnd < line) tagEnd = line; 2354 if (tagEnd < line) tagEnd = line;
2354} 2355}
2355 2356
2356void KateDocument::insLine(int line) { 2357void KateDocument::insLine(int line) {
2357 KateView *view; 2358 KateView *view;
2358 2359
2359 if (selectStart >= line) selectStart++; 2360 if (selectStart >= line) selectStart++;
2360 if (selectEnd >= line) selectEnd++; 2361 if (selectEnd >= line) selectEnd++;
2361 if (tagStart >= line) tagStart++; 2362 if (tagStart >= line) tagStart++;
2362 if (tagEnd >= line) tagEnd++; 2363 if (tagEnd >= line) tagEnd++;
2363 2364
2364 newDocGeometry = true; 2365 newDocGeometry = true;
2365 for (view = views.first(); view != 0L; view = views.next() ) { 2366 for (view = views.first(); view != 0L; view = views.next() ) {
2366 view->insLine(line); 2367 view->insLine(line);
2367 } 2368 }
2368} 2369}
2369 2370
2370void KateDocument::delLine(int line) { 2371void KateDocument::delLine(int line) {
2371 KateView *view; 2372 KateView *view;
2372 2373
2373 if (selectStart >= line && selectStart > 0) selectStart--; 2374 if (selectStart >= line && selectStart > 0) selectStart--;
2374 if (selectEnd >= line) selectEnd--; 2375 if (selectEnd >= line) selectEnd--;
2375 if (tagStart >= line && tagStart > 0) tagStart--; 2376 if (tagStart >= line && tagStart > 0) tagStart--;
2376 if (tagEnd >= line) tagEnd--; 2377 if (tagEnd >= line) tagEnd--;
2377 2378
2378 newDocGeometry = true; 2379 newDocGeometry = true;
2379 for (view = views.first(); view != 0L; view = views.next() ) { 2380 for (view = views.first(); view != 0L; view = views.next() ) {
2380 view->delLine(line); 2381 view->delLine(line);
2381 } 2382 }
2382} 2383}
2383 2384
2384void KateDocument::optimizeSelection() { 2385void KateDocument::optimizeSelection() {
2385 TextLine::Ptr textLine; 2386 TextLine::Ptr textLine;
2386 2387
2387 while (selectStart <= selectEnd) { 2388 while (selectStart <= selectEnd) {
diff --git a/noncore/settings/sysinfo/devicesinfo.cpp b/noncore/settings/sysinfo/devicesinfo.cpp
index 164d608..428cfd4 100644
--- a/noncore/settings/sysinfo/devicesinfo.cpp
+++ b/noncore/settings/sysinfo/devicesinfo.cpp
@@ -172,193 +172,193 @@ void CpuCategory::populate()
172 172
173//================================================================================================= 173//=================================================================================================
174InputCategory::InputCategory( DevicesView* parent ) 174InputCategory::InputCategory( DevicesView* parent )
175 :Category( parent, "2. Input Subsystem" ) 175 :Category( parent, "2. Input Subsystem" )
176{ 176{
177} 177}
178 178
179InputCategory::~InputCategory() 179InputCategory::~InputCategory()
180{ 180{
181} 181}
182 182
183void InputCategory::populate() 183void InputCategory::populate()
184{ 184{
185 odebug << "InputCategory::populate()" << oendl; 185 odebug << "InputCategory::populate()" << oendl;
186 OInputSystem* sys = OInputSystem::instance(); 186 OInputSystem* sys = OInputSystem::instance();
187 OInputSystem::DeviceIterator it = sys->iterator(); 187 OInputSystem::DeviceIterator it = sys->iterator();
188 while ( it.current() ) 188 while ( it.current() )
189 { 189 {
190 InputDevice* dev = new InputDevice( this, it.current()->identity() ); 190 InputDevice* dev = new InputDevice( this, it.current()->identity() );
191 dev->setInfo( it.current() ); 191 dev->setInfo( it.current() );
192 ++it; 192 ++it;
193 } 193 }
194} 194}
195 195
196//================================================================================================= 196//=================================================================================================
197CardsCategory::CardsCategory( DevicesView* parent ) 197CardsCategory::CardsCategory( DevicesView* parent )
198 :Category( parent, "3. Removable Cards" ) 198 :Category( parent, "3. Removable Cards" )
199{ 199{
200} 200}
201 201
202CardsCategory::~CardsCategory() 202CardsCategory::~CardsCategory()
203{ 203{
204} 204}
205 205
206void CardsCategory::populate() 206void CardsCategory::populate()
207{ 207{
208 odebug << "CardsCategory::populate()" << oendl; 208 odebug << "CardsCategory::populate()" << oendl;
209 OPcmciaSystem* sys = OPcmciaSystem::instance(); 209 OPcmciaSystem* sys = OPcmciaSystem::instance();
210 OPcmciaSystem::CardIterator it = sys->iterator(); 210 OPcmciaSystem::CardIterator it = sys->iterator();
211 while ( it.current() ) 211 while ( it.current() )
212 { 212 {
213 CardDevice *dev = new CardDevice( this, it.current()->identity() ); 213 CardDevice *dev = new CardDevice( this, it.current()->identity() );
214 dev->setInfo( it.current() ); 214 dev->setInfo( it.current() );
215 ++it; 215 ++it;
216 } 216 }
217} 217}
218 218
219//================================================================================================= 219//=================================================================================================
220UsbCategory::UsbCategory( DevicesView* parent ) 220UsbCategory::UsbCategory( DevicesView* parent )
221 :Category( parent, "4. Universal Serial Bus" ) 221 :Category( parent, "4. Universal Serial Bus" )
222{ 222{
223} 223}
224 224
225UsbCategory::~UsbCategory() 225UsbCategory::~UsbCategory()
226{ 226{
227} 227}
228 228
229void UsbCategory::populate() 229void UsbCategory::populate()
230{ 230{
231 odebug << "UsbCategory::populate()" << oendl; 231 odebug << "UsbCategory::populate()" << oendl;
232 QFile usbinfofile( "/proc/bus/usb/devices" ); 232 QFile usbinfofile( "/proc/bus/usb/devices" );
233 if ( !usbinfofile.exists() || !usbinfofile.open( IO_ReadOnly ) ) 233 if ( !usbinfofile.exists() || !usbinfofile.open( IO_ReadOnly ) )
234 { 234 {
235 new UsbDevice( this, "(no USB found)" ); 235 new UsbDevice( this, "(no USB found)" );
236 return; 236 return;
237 } 237 }
238 QTextStream usbinfo( &usbinfofile ); 238 QTextStream usbinfo( &usbinfofile );
239 239
240 int _bus, _level, _parent, _port, _count, _device, _channels, _power; 240 int _bus, _level, _parent, _port, _count, _device, _channels, _power;
241 float _speed; 241 float _speed;
242 QString _manufacturer, _product, _serial; 242 QString _manufacturer, _product, _serial;
243 243
244 int usbcount = 0; 244 int usbcount = 0;
245 UsbDevice* lastDev = 0; 245 UsbDevice* lastDev = 0;
246 UsbDevice* dev = 0; 246 UsbDevice* dev = 0;
247 while ( !usbinfo.atEnd() ) 247 while ( !usbinfo.atEnd() )
248 { 248 {
249 QString line = usbinfo.readLine(); 249 QString line = usbinfo.readLine();
250 odebug << "got line '" << line << "'" << oendl; 250 odebug << "got line '" << line << "'" << oendl;
251 if ( line.startsWith( "T:" ) ) 251 if ( line.startsWith( "T:" ) )
252 { 252 {
253 sscanf(line.local8Bit().data(), "T: Bus=%2d Lev=%2d Prnt=%2d Port=%d Cnt=%2d Dev#=%3d Spd=%3f MxCh=%2d", &_bus, &_level, &_parent, &_port, &_count, &_device, &_speed, &_channels); 253 sscanf(line.local8Bit().data(), "T: Bus=%2d Lev=%2d Prnt=%2d Port=%d Cnt=%2d Dev#=%3d Spd=%3f MxCh=%2d", &_bus, &_level, &_parent, &_port, &_count, &_device, &_speed, &_channels);
254 254
255 if ( !_level ) 255 if ( !_level )
256 { 256 {
257 odebug << "adding new bus" << oendl; 257 odebug << "adding new bus" << oendl;
258 dev = new UsbDevice( this, QString( "Generic USB Hub Device" ) ); 258 dev = new UsbDevice( this, QString( "Generic USB Hub Device" ) );
259 lastDev = dev; 259 lastDev = dev;
260 } 260 }
261 else 261 else
262 { 262 {
263 odebug << "adding new dev" << oendl; 263 odebug << "adding new dev" << oendl;
264 dev = new UsbDevice( lastDev, QString( "Generic USB Hub Device" ) ); 264 dev = new UsbDevice( lastDev, QString( "Generic USB Hub Device" ) );
265 lastDev = dev; 265 lastDev = dev;
266 } 266 }
267 } 267 }
268 else if ( line.startsWith( "S: Product" ) ) 268 else if ( dev && line.startsWith( "S: Product" ) )
269 { 269 {
270 int dp = line.find( '=' ); 270 int dp = line.find( '=' );
271 dev->setText( 0, dp != -1 ? line.right( line.length()-1-dp ) : "<unknown>" ); 271 dev->setText( 0, dp != -1 ? line.right( line.length()-1-dp ) : "<unknown>" );
272 } 272 }
273 else 273 else
274 { 274 {
275 continue; 275 continue;
276 } 276 }
277 } 277 }
278} 278}
279 279
280 280
281//================================================================================================= 281//=================================================================================================
282Device::Device( Category* parent, const QString& name ) 282Device::Device( Category* parent, const QString& name )
283 :OListViewItem( parent, name ) 283 :OListViewItem( parent, name )
284{ 284{
285 devinfo = static_cast<QWidget*>( listView()->parent() ); 285 devinfo = static_cast<QWidget*>( listView()->parent() );
286} 286}
287 287
288Device::Device( Device* parent, const QString& name ) 288Device::Device( Device* parent, const QString& name )
289 :OListViewItem( parent, name ) 289 :OListViewItem( parent, name )
290{ 290{
291 devinfo = static_cast<QWidget*>( listView()->parent() ); 291 devinfo = static_cast<QWidget*>( listView()->parent() );
292} 292}
293 293
294Device::~Device() 294Device::~Device()
295{ 295{
296} 296}
297 297
298 298
299QWidget* Device::detailsWidget() 299QWidget* Device::detailsWidget()
300{ 300{
301 return details; 301 return details;
302} 302}
303 303
304//================================================================================================= 304//=================================================================================================
305CpuDevice::CpuDevice( Category* parent, const QString& name ) 305CpuDevice::CpuDevice( Category* parent, const QString& name )
306 :Device( parent, name ) 306 :Device( parent, name )
307{ 307{
308 OListView* w = new OListView( devinfo ); 308 OListView* w = new OListView( devinfo );
309 details = w; 309 details = w;
310 w->addColumn( "Info" ); 310 w->addColumn( "Info" );
311 w->addColumn( "Value" ); 311 w->addColumn( "Value" );
312 w->hide(); 312 w->hide();
313} 313}
314 314
315CpuDevice::~CpuDevice() 315CpuDevice::~CpuDevice()
316{ 316{
317} 317}
318 318
319void CpuDevice::addInfo( const QString& info ) 319void CpuDevice::addInfo( const QString& info )
320{ 320{
321 int dp = info.find( ':' ); 321 int dp = info.find( ':' );
322 if ( dp != -1 ) 322 if ( dp != -1 )
323 { 323 {
324 new OListViewItem( (OListView*) details, info.left( dp ), info.right( info.length()-dp ) ); 324 new OListViewItem( (OListView*) details, info.left( dp ), info.right( info.length()-dp ) );
325 } 325 }
326} 326}
327 327
328//================================================================================================= 328//=================================================================================================
329CardDevice::CardDevice( Category* parent, const QString& name ) 329CardDevice::CardDevice( Category* parent, const QString& name )
330 :Device( parent, name ) 330 :Device( parent, name )
331{ 331{
332 OListView* w = new OListView( devinfo ); 332 OListView* w = new OListView( devinfo );
333 details = w; 333 details = w;
334 w->addColumn( "Info" ); 334 w->addColumn( "Info" );
335 w->addColumn( "Value" ); 335 w->addColumn( "Value" );
336 w->hide(); 336 w->hide();
337} 337}
338 338
339void CardDevice::setInfo( const OPcmciaSocket* card ) 339void CardDevice::setInfo( const OPcmciaSocket* card )
340{ 340{
341 QStringList vendorlst = card->productIdentityVector(); 341 QStringList vendorlst = card->productIdentityVector();
342 for( QStringList::Iterator it = vendorlst.begin(); it != vendorlst.end(); ++it ) 342 for( QStringList::Iterator it = vendorlst.begin(); it != vendorlst.end(); ++it )
343 { 343 {
344 new OListViewItem( (OListView*) details, "VendorID", *it ); 344 new OListViewItem( (OListView*) details, "VendorID", *it );
345 } 345 }
346 new OListViewItem( (OListView*) details, "Manufacturer", card->manufacturerIdentity() ); 346 new OListViewItem( (OListView*) details, "Manufacturer", card->manufacturerIdentity() );
347 new OListViewItem( (OListView*) details, "Function", card->function() ); 347 new OListViewItem( (OListView*) details, "Function", card->function() );
348 348
349 QStringList text; 349 QStringList text;
350 OPcmciaSocket::OPcmciaSocketCardStatus status = card->status(); 350 OPcmciaSocket::OPcmciaSocketCardStatus status = card->status();
351 if ( status ) 351 if ( status )
352 { 352 {
353 if ( status & OPcmciaSocket::Occupied ) text += "Occupied"; 353 if ( status & OPcmciaSocket::Occupied ) text += "Occupied";
354 if ( status & OPcmciaSocket::OccupiedCardBus ) text += "CardBus"; 354 if ( status & OPcmciaSocket::OccupiedCardBus ) text += "CardBus";
355 if ( status & OPcmciaSocket::WriteProtected ) text += "WriteProtected"; 355 if ( status & OPcmciaSocket::WriteProtected ) text += "WriteProtected";
356 if ( status & OPcmciaSocket::BatteryLow ) text += "BatteryLow"; 356 if ( status & OPcmciaSocket::BatteryLow ) text += "BatteryLow";
357 if ( status & OPcmciaSocket::BatteryDead ) text += "BatteryDead"; 357 if ( status & OPcmciaSocket::BatteryDead ) text += "BatteryDead";
358 if ( status & OPcmciaSocket::Ready ) text += "Ready"; 358 if ( status & OPcmciaSocket::Ready ) text += "Ready";
359 if ( status & OPcmciaSocket::Suspended ) text += "Suspended"; 359 if ( status & OPcmciaSocket::Suspended ) text += "Suspended";
360 if ( status & OPcmciaSocket::Attention ) text += "Attention"; 360 if ( status & OPcmciaSocket::Attention ) text += "Attention";
361 if ( status & OPcmciaSocket::InsertionInProgress ) text += "InsertionInProgress"; 361 if ( status & OPcmciaSocket::InsertionInProgress ) text += "InsertionInProgress";
362 if ( status & OPcmciaSocket::RemovalInProgress ) text += "RemovalInProgress"; 362 if ( status & OPcmciaSocket::RemovalInProgress ) text += "RemovalInProgress";
363 if ( status & OPcmciaSocket::ThreeVolts ) text += "3V"; 363 if ( status & OPcmciaSocket::ThreeVolts ) text += "3V";
364 if ( status & OPcmciaSocket::SupportsVoltage ) text += "SupportsVoltage"; 364 if ( status & OPcmciaSocket::SupportsVoltage ) text += "SupportsVoltage";
diff --git a/noncore/todayplugins/stockticker/libstocks/http.c b/noncore/todayplugins/stockticker/libstocks/http.c
index 2f38f8a..cc78ab7 100644
--- a/noncore/todayplugins/stockticker/libstocks/http.c
+++ b/noncore/todayplugins/stockticker/libstocks/http.c
@@ -117,187 +117,187 @@ libstocks_return_code http_get(char *http_file, char *http_server, char **pdata)
117#elif __WINDOWS__ 117#elif __WINDOWS__
118 closesocket(s); 118 closesocket(s);
119#endif 119#endif
120 return ERRCONN; 120 return ERRCONN;
121 } 121 }
122 122
123 /* create header */ 123 /* create header */
124 if (http_proxy_server) 124 if (http_proxy_server)
125 { 125 {
126 sprintf(header,"GET http://%.128s:80%.256s HTTP/1.0\015\012\015\012", 126 sprintf(header,"GET http://%.128s:80%.256s HTTP/1.0\015\012\015\012",
127 http_server, http_file); 127 http_server, http_file);
128 } 128 }
129 else 129 else
130 { 130 {
131 sprintf(header,"GET %s HTTP/1.0\015\012\015\012",http_file); 131 sprintf(header,"GET %s HTTP/1.0\015\012\015\012",http_file);
132 } 132 }
133 133
134 hlg=strlen(header); 134 hlg=strlen(header);
135 135
136 /* send header */ 136 /* send header */
137#ifdef __UNIX__ 137#ifdef __UNIX__
138 if (write(s,header,hlg)!=hlg) 138 if (write(s,header,hlg)!=hlg)
139#elif __WINDOWS__ 139#elif __WINDOWS__
140 if (send(s,header,hlg, 0)!=hlg) 140 if (send(s,header,hlg, 0)!=hlg)
141#endif 141#endif
142 { 142 {
143#ifdef DEBUG 143#ifdef DEBUG
144 printf(" send header : NOK\n"); 144 printf(" send header : NOK\n");
145#endif 145#endif
146 return ERRWHEA; 146 return ERRWHEA;
147 } 147 }
148 148
149 data_lgr = 0; 149 data_lgr = 0;
150 r=1; 150 r=1;
151 while(r) 151 while(r)
152 { 152 {
153 /* Clear Buffer */ 153 /* Clear Buffer */
154 memset(buf,0,BUF_SIZE+1); 154 memset(buf,0,BUF_SIZE+1);
155 155
156#ifdef __UNIX__ 156#ifdef __UNIX__
157 r=read(s,buf,BUF_SIZE); 157 r=read(s,buf,BUF_SIZE);
158#elif __WINDOWS__ 158#elif __WINDOWS__
159 r=recv(s,buf,BUF_SIZE,0); 159 r=recv(s,buf,BUF_SIZE,0);
160#endif 160#endif
161 161
162 if (r) 162 if (r)
163 { 163 {
164 if(!data_lgr) 164 if(!data_lgr)
165 { 165 {
166 if((data = malloc(r+1))==NULL) 166 if((data = malloc(r+1))==NULL)
167 { 167 {
168 fprintf(stderr,"Memory allocating error (%s line %d)\n" 168 fprintf(stderr,"Memory allocating error (%s line %d)\n"
169 ,__FILE__, __LINE__); 169 ,__FILE__, __LINE__);
170 exit(1); 170 exit(1);
171 } 171 }
172 172
173 memcpy(data,buf,r); 173 memcpy(data,buf,r);
174 data_lgr = r; 174 data_lgr = r;
175 data[r]=0; 175 data[r]=0;
176 } 176 }
177 else 177 else
178 { 178 {
179 if((temp = malloc(r+data_lgr+1))==NULL) 179 if((temp = malloc(r+data_lgr+1))==NULL)
180 { 180 {
181 fprintf(stderr,"Memory allocating error (%s line %d)\n" 181 fprintf(stderr,"Memory allocating error (%s line %d)\n"
182 ,__FILE__, __LINE__); 182 ,__FILE__, __LINE__);
183 exit(1); 183 exit(1);
184 } 184 }
185 memcpy(temp, data, data_lgr); 185 memcpy(temp, data, data_lgr);
186 memcpy(temp+data_lgr, buf, r); 186 memcpy(temp+data_lgr, buf, r);
187 temp[r+data_lgr]=0; 187 temp[r+data_lgr]=0;
188 data_lgr += r; 188 data_lgr += r;
189 free(data); 189 free(data);
190 data = temp; 190 data = temp;
191 } 191 }
192 } 192 }
193 } 193 }
194 194
195 /* close socket */ 195 /* close socket */
196#ifdef __UNIX__ 196#ifdef __UNIX__
197 close(s); 197 close(s);
198#elif __WINDOWS__ 198#elif __WINDOWS__
199 closesocket(s); 199 closesocket(s);
200#endif 200#endif
201 201
202#ifdef DEBUG 202#ifdef DEBUG
203 printf("%s\n", data); 203 printf("%s\n", data);
204#endif 204#endif
205 205
206 /* get headers to test status line */ 206 /* get headers to test status line */
207 /* and to split headers and content */ 207 /* and to split headers and content */
208 208
209 temp = data; 209 temp = data;
210 header_founded = 0; 210 header_founded = 0;
211 while( !header_founded ) 211 while( !header_founded )
212 { 212 {
213 if (*temp==0) return ERRRHEA; 213 if (!temp || *temp==0) return ERRRHEA;
214 214
215 if( *temp==0x0A ) 215 if( *temp==0x0A )
216 { 216 {
217 /* test if it is the header end */ 217 /* test if it is the header end */
218 temp ++; 218 temp ++;
219 if (*temp == 0x0D) temp++; 219 if (*temp == 0x0D) temp++;
220 if (*temp == 0x0A) header_founded = 1; 220 if (*temp == 0x0A) header_founded = 1;
221 } 221 }
222 else 222 else
223 temp++; 223 temp++;
224 } 224 }
225 225
226 *temp = 0; 226 *temp = 0;
227 temp++; 227 temp++;
228 228
229 sscanf(data,"HTTP/1.%*d %03d",&error_code); 229 sscanf(data,"HTTP/1.%*d %03d",&error_code);
230 230
231 if (error_code != 200) 231 if (error_code != 200)
232 { 232 {
233#ifdef DEBUG 233#ifdef DEBUG
234 printf(" HTTP error code : %d\n", error_code); 234 printf(" HTTP error code : %d\n", error_code);
235#endif 235#endif
236 free(data); 236 free(data);
237 return ERRPAHD; 237 return ERRPAHD;
238 } 238 }
239 239
240 if ((csv_ptr = malloc(strlen(temp)+1))==NULL) 240 if ((csv_ptr = malloc(strlen(temp)+1))==NULL)
241 { 241 {
242 free(data); 242 free(data);
243 fprintf(stderr,"Memory allocating error (%s line %d)\n" 243 fprintf(stderr,"Memory allocating error (%s line %d)\n"
244 ,__FILE__, __LINE__); 244 ,__FILE__, __LINE__);
245 exit(1); 245 exit(1);
246 } 246 }
247 247
248 memcpy(csv_ptr, temp, strlen(temp)+1); 248 memcpy(csv_ptr, temp, strlen(temp)+1);
249 free(data); 249 free(data);
250 250
251#ifdef DEBUG 251#ifdef DEBUG
252 printf(" CSV\n"); 252 printf(" CSV\n");
253 printf("%s,\n", csv_ptr); 253 printf("%s,\n", csv_ptr);
254#endif 254#endif
255 255
256 *pdata = csv_ptr; 256 *pdata = csv_ptr;
257 257
258 return 0; 258 return 0;
259} 259}
260 260
261/******************************************************************************/ 261/******************************************************************************/
262/* Set the proxy server to use */ 262/* Set the proxy server to use */
263/******************************************************************************/ 263/******************************************************************************/
264libstocks_return_code set_proxy(char *proxy) 264libstocks_return_code set_proxy(char *proxy)
265{ 265{
266 char *ptr; 266 char *ptr;
267 char c; 267 char c;
268 268
269#ifdef DEBUG 269#ifdef DEBUG
270 printf("*set_proxy\n"); 270 printf("*set_proxy\n");
271#endif 271#endif
272 272
273 /* Parse the proxy URL - It must start with http:// */ 273 /* Parse the proxy URL - It must start with http:// */
274#ifdef __UNIX__ 274#ifdef __UNIX__
275 if (strncasecmp("http://",proxy,7)) return ERRPROX; 275 if (strncasecmp("http://",proxy,7)) return ERRPROX;
276#elif __WINDOWS__ 276#elif __WINDOWS__
277 if (_mbsnbicmp("http://",proxy,7)) return ERRPROX; 277 if (_mbsnbicmp("http://",proxy,7)) return ERRPROX;
278#endif 278#endif
279 279
280 proxy+=7; 280 proxy+=7;
281 281
282 /* find ":" in the proxy url */ 282 /* find ":" in the proxy url */
283 ptr = proxy; 283 ptr = proxy;
284 for (c=*ptr; (c && c!=':');) c=*ptr++; 284 for (c=*ptr; (c && c!=':');) c=*ptr++;
285 285
286 /* ptr points just after the ":" or at the end of proxy if : not founded */ 286 /* ptr points just after the ":" or at the end of proxy if : not founded */
287 *(ptr-1)=0; /* clear the ":" */ 287 *(ptr-1)=0; /* clear the ":" */
288 288
289 http_proxy_server=strdup(proxy); 289 http_proxy_server=strdup(proxy);
290 290
291#ifdef DEBUG 291#ifdef DEBUG
292 printf("http_proxy_server : %s\n", http_proxy_server); 292 printf("http_proxy_server : %s\n", http_proxy_server);
293#endif 293#endif
294 294
295 /* get the port number of the url */ 295 /* get the port number of the url */
296 if (sscanf(ptr,"%d",&http_proxy_port)!=1) return ERRPROX; 296 if (sscanf(ptr,"%d",&http_proxy_port)!=1) return ERRPROX;
297 297
298#ifdef DEBUG 298#ifdef DEBUG
299 printf("http_proxy_port : %d\n", http_proxy_port); 299 printf("http_proxy_port : %d\n", http_proxy_port);
300#endif 300#endif
301 301
302 return 0; 302 return 0;
303} 303}