author | ar <ar> | 2004-05-02 21:32:48 (UTC) |
---|---|---|
committer | ar <ar> | 2004-05-02 21:32:48 (UTC) |
commit | 0a4cac124105a5732e55cb34c6b37be75083a395 (patch) (unidiff) | |
tree | 33b4d2cab08c9b58893540b4ddee089b69fc9c61 | |
parent | 109ed5f2a1cdfeb3680c9ec057a1083fcf8fab95 (diff) | |
download | opie-0a4cac124105a5732e55cb34c6b37be75083a395.zip opie-0a4cac124105a5732e55cb34c6b37be75083a395.tar.gz opie-0a4cac124105a5732e55cb34c6b37be75083a395.tar.bz2 |
- convert qWarning to owarn
-rw-r--r-- | core/launcher/launcher.cpp | 296 | ||||
-rw-r--r-- | core/launcher/packageslave.cpp | 191 | ||||
-rw-r--r-- | core/launcher/transferserver.cpp | 3 | ||||
-rw-r--r-- | core/obex/obex.cc | 47 | ||||
-rw-r--r-- | core/opie-login/loginapplication.cpp | 315 | ||||
-rw-r--r-- | core/pim/addressbook/namelineedit.cpp | 6 | ||||
-rw-r--r-- | core/qws/transferserver.cpp | 6 |
7 files changed, 439 insertions, 425 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index 6afbcd8..779fe54 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp | |||
@@ -77,49 +77,49 @@ static bool isVisibleWindow( int ); | |||
77 | //=========================================================================== | 77 | //=========================================================================== |
78 | 78 | ||
79 | LauncherTabWidget::LauncherTabWidget( Launcher* parent ) : | 79 | LauncherTabWidget::LauncherTabWidget( Launcher* parent ) : |
80 | QVBox( parent ), docview( 0 ) | 80 | QVBox( parent ), docview( 0 ) |
81 | { | 81 | { |
82 | docLoadingWidgetEnabled = false; | 82 | docLoadingWidgetEnabled = false; |
83 | docLoadingWidget = 0; | 83 | docLoadingWidget = 0; |
84 | docLoadingWidgetProgress = 0; | 84 | docLoadingWidgetProgress = 0; |
85 | launcher = parent; | 85 | launcher = parent; |
86 | categoryBar = new LauncherTabBar( this ); | 86 | categoryBar = new LauncherTabBar( this ); |
87 | QPalette pal = categoryBar->palette(); | 87 | QPalette pal = categoryBar->palette(); |
88 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); | 88 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); |
89 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); | 89 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); |
90 | categoryBar->setPalette( pal ); | 90 | categoryBar->setPalette( pal ); |
91 | stack = new QWidgetStack(this); | 91 | stack = new QWidgetStack(this); |
92 | connect( categoryBar, SIGNAL(selected(int)), this, SLOT(raiseTabWidget()) ); | 92 | connect( categoryBar, SIGNAL(selected(int)), this, SLOT(raiseTabWidget()) ); |
93 | categoryBar->show(); | 93 | categoryBar->show(); |
94 | stack->show(); | 94 | stack->show(); |
95 | 95 | ||
96 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 96 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
97 | QCopChannel *channel = new QCopChannel( "QPE/Launcher", this ); | 97 | QCopChannel *channel = new QCopChannel( "QPE/Launcher", this ); |
98 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), | 98 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
99 | this, SLOT(launcherMessage(const QCString&,const QByteArray&)) ); | 99 | this, SLOT(launcherMessage(const QCString&,const QByteArray&)) ); |
100 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), | 100 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), |
101 | this, SLOT(appMessage(const QCString&,const QByteArray&))); | 101 | this, SLOT(appMessage(const QCString&,const QByteArray&))); |
102 | #endif | 102 | #endif |
103 | 103 | ||
104 | createDocLoadingWidget(); | 104 | createDocLoadingWidget(); |
105 | } | 105 | } |
106 | 106 | ||
107 | void LauncherTabWidget::createDocLoadingWidget() | 107 | void LauncherTabWidget::createDocLoadingWidget() |
108 | { | 108 | { |
109 | // Construct the 'doc loading widget' shown when finding documents | 109 | // Construct the 'doc loading widget' shown when finding documents |
110 | 110 | ||
111 | // ### LauncherView class needs changing to be more generic so | 111 | // ### LauncherView class needs changing to be more generic so |
112 | // this widget can change its background similar to the iconviews | 112 | // this widget can change its background similar to the iconviews |
113 | // so the background for this matches | 113 | // so the background for this matches |
114 | docLoadingWidget = new LauncherView( stack ); | 114 | docLoadingWidget = new LauncherView( stack ); |
115 | docLoadingWidget->hideIcons(); | 115 | docLoadingWidget->hideIcons(); |
116 | QVBox *docLoadingVBox = new QVBox( docLoadingWidget ); | 116 | QVBox *docLoadingVBox = new QVBox( docLoadingWidget ); |
117 | 117 | ||
118 | docLoadingVBox->setSpacing( 20 ); | 118 | docLoadingVBox->setSpacing( 20 ); |
119 | docLoadingVBox->setMargin( 10 ); | 119 | docLoadingVBox->setMargin( 10 ); |
120 | 120 | ||
121 | QWidget *space1 = new QWidget( docLoadingVBox ); | 121 | QWidget *space1 = new QWidget( docLoadingVBox ); |
122 | docLoadingVBox->setStretchFactor( space1, 1 ); | 122 | docLoadingVBox->setStretchFactor( space1, 1 ); |
123 | 123 | ||
124 | QLabel *waitPixmap = new QLabel( docLoadingVBox ); | 124 | QLabel *waitPixmap = new QLabel( docLoadingVBox ); |
125 | waitPixmap->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, waitPixmap->sizePolicy().hasHeightForWidth() ) ); | 125 | waitPixmap->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, waitPixmap->sizePolicy().hasHeightForWidth() ) ); |
@@ -148,294 +148,294 @@ void LauncherTabWidget::createDocLoadingWidget() | |||
148 | "Use Settings->Launcher->DocTab<p>to reenable it.</b></center>" ) ); | 148 | "Use Settings->Launcher->DocTab<p>to reenable it.</b></center>" ) ); |
149 | docLoadingWidgetProgress->hide(); | 149 | docLoadingWidgetProgress->hide(); |
150 | docLoadingWidgetEnabled = true; | 150 | docLoadingWidgetEnabled = true; |
151 | } | 151 | } |
152 | 152 | ||
153 | QWidget *space2 = new QWidget( docLoadingVBox ); | 153 | QWidget *space2 = new QWidget( docLoadingVBox ); |
154 | docLoadingVBox->setStretchFactor( space2, 1 ); | 154 | docLoadingVBox->setStretchFactor( space2, 1 ); |
155 | 155 | ||
156 | cfg.setGroup( "Tab Documents" ); // No tr | 156 | cfg.setGroup( "Tab Documents" ); // No tr |
157 | setTabViewAppearance( docLoadingWidget, cfg ); | 157 | setTabViewAppearance( docLoadingWidget, cfg ); |
158 | 158 | ||
159 | stack->addWidget( docLoadingWidget, 0 ); | 159 | stack->addWidget( docLoadingWidget, 0 ); |
160 | } | 160 | } |
161 | 161 | ||
162 | void LauncherTabWidget::initLayout() | 162 | void LauncherTabWidget::initLayout() |
163 | { | 163 | { |
164 | layout()->activate(); | 164 | layout()->activate(); |
165 | docView()->setFocus(); | 165 | docView()->setFocus(); |
166 | categoryBar->showTab("Documents"); | 166 | categoryBar->showTab("Documents"); |
167 | } | 167 | } |
168 | 168 | ||
169 | void LauncherTabWidget::appMessage(const QCString& message, const QByteArray&) | 169 | void LauncherTabWidget::appMessage(const QCString& message, const QByteArray&) |
170 | { | 170 | { |
171 | if ( message == "nextView()" ) | 171 | if ( message == "nextView()" ) |
172 | categoryBar->nextTab(); | 172 | categoryBar->nextTab(); |
173 | } | 173 | } |
174 | 174 | ||
175 | void LauncherTabWidget::raiseTabWidget() | 175 | void LauncherTabWidget::raiseTabWidget() |
176 | { | 176 | { |
177 | if ( categoryBar->currentView() == docView() | 177 | if ( categoryBar->currentView() == docView() |
178 | && docLoadingWidgetEnabled ) { | 178 | && docLoadingWidgetEnabled ) { |
179 | stack->raiseWidget( docLoadingWidget ); | 179 | stack->raiseWidget( docLoadingWidget ); |
180 | docLoadingWidget->updateGeometry(); | 180 | docLoadingWidget->updateGeometry(); |
181 | } else { | 181 | } else { |
182 | stack->raiseWidget( categoryBar->currentView() ); | 182 | stack->raiseWidget( categoryBar->currentView() ); |
183 | } | 183 | } |
184 | } | 184 | } |
185 | 185 | ||
186 | void LauncherTabWidget::tabProperties() | 186 | void LauncherTabWidget::tabProperties() |
187 | { | 187 | { |
188 | LauncherView *view = categoryBar->currentView(); | 188 | LauncherView *view = categoryBar->currentView(); |
189 | QPopupMenu *m = new QPopupMenu( this ); | 189 | QPopupMenu *m = new QPopupMenu( this ); |
190 | m->insertItem( tr("Icon View"), LauncherView::Icon ); | 190 | m->insertItem( tr("Icon View"), LauncherView::Icon ); |
191 | m->insertItem( tr("List View"), LauncherView::List ); | 191 | m->insertItem( tr("List View"), LauncherView::List ); |
192 | m->setItemChecked( (int)view->viewMode(), TRUE ); | 192 | m->setItemChecked( (int)view->viewMode(), TRUE ); |
193 | int rv = m->exec( QCursor::pos() ); | 193 | int rv = m->exec( QCursor::pos() ); |
194 | if ( rv >= 0 && rv != view->viewMode() ) { | 194 | if ( rv >= 0 && rv != view->viewMode() ) { |
195 | view->setViewMode( (LauncherView::ViewMode)rv ); | 195 | view->setViewMode( (LauncherView::ViewMode)rv ); |
196 | } | 196 | } |
197 | 197 | ||
198 | delete m; | 198 | delete m; |
199 | } | 199 | } |
200 | 200 | ||
201 | void LauncherTabWidget::deleteView( const QString& id ) | 201 | void LauncherTabWidget::deleteView( const QString& id ) |
202 | { | 202 | { |
203 | LauncherTab *t = categoryBar->launcherTab(id); | 203 | LauncherTab *t = categoryBar->launcherTab(id); |
204 | if ( t ) { | 204 | if ( t ) { |
205 | stack->removeWidget( t->view ); | 205 | stack->removeWidget( t->view ); |
206 | delete t->view; | 206 | delete t->view; |
207 | categoryBar->removeTab( t ); | 207 | categoryBar->removeTab( t ); |
208 | } | 208 | } |
209 | } | 209 | } |
210 | 210 | ||
211 | LauncherView* LauncherTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) | 211 | LauncherView* LauncherTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) |
212 | { | 212 | { |
213 | LauncherView* view = new LauncherView( stack ); | 213 | LauncherView* view = new LauncherView( stack ); |
214 | connect( view, SIGNAL(clicked(const AppLnk*)), | 214 | connect( view, SIGNAL(clicked(const AppLnk*)), |
215 | this, SIGNAL(clicked(const AppLnk*))); | 215 | this, SIGNAL(clicked(const AppLnk*))); |
216 | connect( view, SIGNAL(rightPressed(AppLnk*)), | 216 | connect( view, SIGNAL(rightPressed(AppLnk*)), |
217 | this, SIGNAL(rightPressed(AppLnk*))); | 217 | this, SIGNAL(rightPressed(AppLnk*))); |
218 | 218 | ||
219 | int n = categoryBar->count(); | 219 | int n = categoryBar->count(); |
220 | stack->addWidget( view, n ); | 220 | stack->addWidget( view, n ); |
221 | 221 | ||
222 | LauncherTab *tab = new LauncherTab( id, view, pm, label ); | 222 | LauncherTab *tab = new LauncherTab( id, view, pm, label ); |
223 | categoryBar->insertTab( tab, n-1 ); | 223 | categoryBar->insertTab( tab, n-1 ); |
224 | 224 | ||
225 | if ( id == "Documents" ) | 225 | if ( id == "Documents" ) |
226 | docview = view; | 226 | docview = view; |
227 | 227 | ||
228 | odebug << "inserting " << id << " at " << n-1 << "" << oendl; | 228 | odebug << "inserting " << id << " at " << n-1 << "" << oendl; |
229 | 229 | ||
230 | Config cfg("Launcher"); | 230 | Config cfg("Launcher"); |
231 | setTabAppearance( tab, cfg ); | 231 | setTabAppearance( tab, cfg ); |
232 | 232 | ||
233 | cfg.setGroup( "GUI" ); | 233 | cfg.setGroup( "GUI" ); |
234 | view->setBusyIndicatorType( cfg.readEntry( "BusyType", QString::null ) ); | 234 | view->setBusyIndicatorType( cfg.readEntry( "BusyType", QString::null ) ); |
235 | 235 | ||
236 | return view; | 236 | return view; |
237 | } | 237 | } |
238 | 238 | ||
239 | LauncherView *LauncherTabWidget::view( const QString &id ) | 239 | LauncherView *LauncherTabWidget::view( const QString &id ) |
240 | { | 240 | { |
241 | LauncherTab *t = categoryBar->launcherTab(id); | 241 | LauncherTab *t = categoryBar->launcherTab(id); |
242 | if ( !t ) | 242 | if ( !t ) |
243 | return 0; | 243 | return 0; |
244 | return t->view; | 244 | return t->view; |
245 | } | 245 | } |
246 | 246 | ||
247 | LauncherView *LauncherTabWidget::docView() | 247 | LauncherView *LauncherTabWidget::docView() |
248 | { | 248 | { |
249 | return docview; | 249 | return docview; |
250 | } | 250 | } |
251 | 251 | ||
252 | void LauncherTabWidget::setLoadingWidgetEnabled( bool v ) | 252 | void LauncherTabWidget::setLoadingWidgetEnabled( bool v ) |
253 | { | 253 | { |
254 | if ( v != docLoadingWidgetEnabled && docLoadingWidget ) { | 254 | if ( v != docLoadingWidgetEnabled && docLoadingWidget ) { |
255 | docLoadingWidgetEnabled = v; | 255 | docLoadingWidgetEnabled = v; |
256 | raiseTabWidget(); | 256 | raiseTabWidget(); |
257 | } | 257 | } |
258 | } | 258 | } |
259 | 259 | ||
260 | void LauncherTabWidget::setLoadingProgress( int percent ) | 260 | void LauncherTabWidget::setLoadingProgress( int percent ) |
261 | { | 261 | { |
262 | docLoadingWidgetProgress->setProgress( (percent / 4) * 4 ); | 262 | docLoadingWidgetProgress->setProgress( (percent / 4) * 4 ); |
263 | } | 263 | } |
264 | 264 | ||
265 | // ### this function could more to LauncherView | 265 | // ### this function could more to LauncherView |
266 | void LauncherTabWidget::setTabViewAppearance( LauncherView *v, Config &cfg ) | 266 | void LauncherTabWidget::setTabViewAppearance( LauncherView *v, Config &cfg ) |
267 | { | 267 | { |
268 | // View | 268 | // View |
269 | QString view = cfg.readEntry( "View", "Icon" ); | 269 | QString view = cfg.readEntry( "View", "Icon" ); |
270 | if ( view == "List" ) // No tr | 270 | if ( view == "List" ) // No tr |
271 | v->setViewMode( LauncherView::List ); | 271 | v->setViewMode( LauncherView::List ); |
272 | QString bgType = cfg.readEntry( "BackgroundType", "Image" ); | 272 | QString bgType = cfg.readEntry( "BackgroundType", "Image" ); |
273 | if ( bgType == "Image" ) { // No tr | 273 | if ( bgType == "Image" ) { // No tr |
274 | QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" ); | 274 | QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" ); |
275 | v->setBackgroundType( LauncherView::Image, pm ); | 275 | v->setBackgroundType( LauncherView::Image, pm ); |
276 | } else if ( bgType == "SolidColor" ) { | 276 | } else if ( bgType == "SolidColor" ) { |
277 | QString c = cfg.readEntry( "BackgroundColor" ); | 277 | QString c = cfg.readEntry( "BackgroundColor" ); |
278 | v->setBackgroundType( LauncherView::SolidColor, c ); | 278 | v->setBackgroundType( LauncherView::SolidColor, c ); |
279 | } else { | 279 | } else { |
280 | v->setBackgroundType( LauncherView::Ruled, QString::null ); | 280 | v->setBackgroundType( LauncherView::Ruled, QString::null ); |
281 | } | 281 | } |
282 | QString textCol = cfg.readEntry( "TextColor" ); | 282 | QString textCol = cfg.readEntry( "TextColor" ); |
283 | if ( textCol.isEmpty() ) | 283 | if ( textCol.isEmpty() ) |
284 | v->setTextColor( QColor() ); | 284 | v->setTextColor( QColor() ); |
285 | else | 285 | else |
286 | v->setTextColor( QColor(textCol) ); | 286 | v->setTextColor( QColor(textCol) ); |
287 | // bool customFont = cfg.readBoolEntry( "CustomFont", FALSE ); | 287 | // bool customFont = cfg.readBoolEntry( "CustomFont", FALSE ); |
288 | 288 | ||
289 | 289 | ||
290 | QStringList font = cfg.readListEntry( "Font", ',' ); | 290 | QStringList font = cfg.readListEntry( "Font", ',' ); |
291 | if ( font.count() == 4 ) | 291 | if ( font.count() == 4 ) |
292 | v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) ); | 292 | v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) ); |
293 | 293 | ||
294 | // ### FIXME TabColor TabTextColor | 294 | // ### FIXME TabColor TabTextColor |
295 | 295 | ||
296 | } | 296 | } |
297 | 297 | ||
298 | // ### Could move to LauncherTab | 298 | // ### Could move to LauncherTab |
299 | void LauncherTabWidget::setTabAppearance( LauncherTab *tab, Config &cfg ) | 299 | void LauncherTabWidget::setTabAppearance( LauncherTab *tab, Config &cfg ) |
300 | { | 300 | { |
301 | cfg.setGroup( QString( "Tab %1" ).arg(tab->type) ); // No tr | 301 | cfg.setGroup( QString( "Tab %1" ).arg(tab->type) ); // No tr |
302 | 302 | ||
303 | setTabViewAppearance( tab->view, cfg ); | 303 | setTabViewAppearance( tab->view, cfg ); |
304 | 304 | ||
305 | // Tabs | 305 | // Tabs |
306 | QString tabCol = cfg.readEntry( "TabColor" ); | 306 | QString tabCol = cfg.readEntry( "TabColor" ); |
307 | if ( tabCol.isEmpty() ) | 307 | if ( tabCol.isEmpty() ) |
308 | tab->bgColor = QColor(); | 308 | tab->bgColor = QColor(); |
309 | else | 309 | else |
310 | tab->bgColor = QColor(tabCol); | 310 | tab->bgColor = QColor(tabCol); |
311 | QString tabTextCol = cfg.readEntry( "TabTextColor" ); | 311 | QString tabTextCol = cfg.readEntry( "TabTextColor" ); |
312 | if ( tabTextCol.isEmpty() ) | 312 | if ( tabTextCol.isEmpty() ) |
313 | tab->fgColor = QColor(); | 313 | tab->fgColor = QColor(); |
314 | else | 314 | else |
315 | tab->fgColor = QColor(tabTextCol); | 315 | tab->fgColor = QColor(tabTextCol); |
316 | } | 316 | } |
317 | 317 | ||
318 | void LauncherTabWidget::paletteChange( const QPalette &p ) | 318 | void LauncherTabWidget::paletteChange( const QPalette &p ) |
319 | { | 319 | { |
320 | QVBox::paletteChange( p ); | 320 | QVBox::paletteChange( p ); |
321 | QPalette pal = palette(); | 321 | QPalette pal = palette(); |
322 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); | 322 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); |
323 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); | 323 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); |
324 | categoryBar->setPalette( pal ); | 324 | categoryBar->setPalette( pal ); |
325 | categoryBar->update(); | 325 | categoryBar->update(); |
326 | } | 326 | } |
327 | 327 | ||
328 | void LauncherTabWidget::styleChange( QStyle & ) | 328 | void LauncherTabWidget::styleChange( QStyle & ) |
329 | { | 329 | { |
330 | QTimer::singleShot( 0, this, SLOT(setProgressStyle()) ); | 330 | QTimer::singleShot( 0, this, SLOT(setProgressStyle()) ); |
331 | } | 331 | } |
332 | 332 | ||
333 | void LauncherTabWidget::setProgressStyle() | 333 | void LauncherTabWidget::setProgressStyle() |
334 | { | 334 | { |
335 | if (docLoadingWidgetProgress) { | 335 | if (docLoadingWidgetProgress) { |
336 | docLoadingWidgetProgress->setFrameShape( QProgressBar::Box ); | 336 | docLoadingWidgetProgress->setFrameShape( QProgressBar::Box ); |
337 | docLoadingWidgetProgress->setFrameShadow( QProgressBar::Plain ); | 337 | docLoadingWidgetProgress->setFrameShadow( QProgressBar::Plain ); |
338 | docLoadingWidgetProgress->setMargin( 1 ); | 338 | docLoadingWidgetProgress->setMargin( 1 ); |
339 | docLoadingWidgetProgress->setLineWidth( 1 ); | 339 | docLoadingWidgetProgress->setLineWidth( 1 ); |
340 | } | 340 | } |
341 | } | 341 | } |
342 | 342 | ||
343 | void LauncherTabWidget::setBusy(bool on) | 343 | void LauncherTabWidget::setBusy(bool on) |
344 | { | 344 | { |
345 | if ( on ) | 345 | if ( on ) |
346 | currentView()->setBusy(TRUE); | 346 | currentView()->setBusy(TRUE); |
347 | else { | 347 | else { |
348 | for ( int i = 0; i < categoryBar->count(); i++ ) { | 348 | for ( int i = 0; i < categoryBar->count(); i++ ) { |
349 | LauncherView *view = ((LauncherTab *)categoryBar->tab(i))->view; | 349 | LauncherView *view = ((LauncherTab *)categoryBar->tab(i))->view; |
350 | view->setBusy( FALSE ); | 350 | view->setBusy( FALSE ); |
351 | } | 351 | } |
352 | } | 352 | } |
353 | } | 353 | } |
354 | 354 | ||
355 | void LauncherTabWidget::setBusyIndicatorType( const QString& str ) { | 355 | void LauncherTabWidget::setBusyIndicatorType( const QString& str ) { |
356 | for (int i = 0; i < categoryBar->count(); i++ ) { | 356 | for (int i = 0; i < categoryBar->count(); i++ ) { |
357 | LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view; | 357 | LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view; |
358 | view->setBusyIndicatorType( str ); | 358 | view->setBusyIndicatorType( str ); |
359 | } | 359 | } |
360 | } | 360 | } |
361 | 361 | ||
362 | LauncherView *LauncherTabWidget::currentView(void) | 362 | LauncherView *LauncherTabWidget::currentView(void) |
363 | { | 363 | { |
364 | return (LauncherView*)stack->visibleWidget(); | 364 | return (LauncherView*)stack->visibleWidget(); |
365 | } | 365 | } |
366 | 366 | ||
367 | 367 | ||
368 | 368 | ||
369 | void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data) | 369 | void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data) |
370 | { | 370 | { |
371 | QDataStream stream( data, IO_ReadOnly ); | 371 | QDataStream stream( data, IO_ReadOnly ); |
372 | if ( msg == "setTabView(QString,int)" ) { | 372 | if ( msg == "setTabView(QString,int)" ) { |
373 | QString id; | 373 | QString id; |
374 | stream >> id; | 374 | stream >> id; |
375 | int mode; | 375 | int mode; |
376 | stream >> mode; | 376 | stream >> mode; |
377 | if ( view(id) ) | 377 | if ( view(id) ) |
378 | view(id)->setViewMode( (LauncherView::ViewMode)mode ); | 378 | view(id)->setViewMode( (LauncherView::ViewMode)mode ); |
379 | } else if ( msg == "setTabBackground(QString,int,QString)" ) { | 379 | } else if ( msg == "setTabBackground(QString,int,QString)" ) { |
380 | QString id; | 380 | QString id; |
381 | stream >> id; | 381 | stream >> id; |
382 | int mode; | 382 | int mode; |
383 | stream >> mode; | 383 | stream >> mode; |
384 | QString pixmapOrColor; | 384 | QString pixmapOrColor; |
385 | stream >> pixmapOrColor; | 385 | stream >> pixmapOrColor; |
386 | if ( view(id) ) | 386 | if ( view(id) ) |
387 | view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); | 387 | view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); |
388 | if ( id == "Documents" ) | 388 | if ( id == "Documents" ) |
389 | docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); | 389 | docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); |
390 | } else if ( msg == "setTextColor(QString,QString)" ) { | 390 | } else if ( msg == "setTextColor(QString,QString)" ) { |
391 | QString id; | 391 | QString id; |
392 | stream >> id; | 392 | stream >> id; |
393 | QString color; | 393 | QString color; |
394 | stream >> color; | 394 | stream >> color; |
395 | if ( view(id) ) | 395 | if ( view(id) ) |
396 | view(id)->setTextColor( QColor(color) ); | 396 | view(id)->setTextColor( QColor(color) ); |
397 | if ( id == "Documents" ) | 397 | if ( id == "Documents" ) |
398 | docLoadingWidget->setTextColor( QColor(color) ); | 398 | docLoadingWidget->setTextColor( QColor(color) ); |
399 | } else if ( msg == "setFont(QString,QString,int,int,int)" ) { | 399 | } else if ( msg == "setFont(QString,QString,int,int,int)" ) { |
400 | QString id; | 400 | QString id; |
401 | stream >> id; | 401 | stream >> id; |
402 | QString fam; | 402 | QString fam; |
403 | stream >> fam; | 403 | stream >> fam; |
404 | int size; | 404 | int size; |
405 | stream >> size; | 405 | stream >> size; |
406 | int weight; | 406 | int weight; |
407 | stream >> weight; | 407 | stream >> weight; |
408 | int italic; | 408 | int italic; |
409 | stream >> italic; | 409 | stream >> italic; |
410 | if ( view(id) ) { | 410 | if ( view(id) ) { |
411 | if ( !fam.isEmpty() ) { | 411 | if ( !fam.isEmpty() ) { |
412 | view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); | 412 | view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); |
413 | odebug << "setFont: " << fam << ", " << size << ", " << weight << ", " << italic << "" << oendl; | 413 | odebug << "setFont: " << fam << ", " << size << ", " << weight << ", " << italic << "" << oendl; |
414 | } else { | 414 | } else { |
415 | view(id)->clearViewFont(); | 415 | view(id)->clearViewFont(); |
416 | } | 416 | } |
417 | } | 417 | } |
418 | }else if ( msg == "setBusyIndicatorType(QString)" ) { | 418 | }else if ( msg == "setBusyIndicatorType(QString)" ) { |
419 | QString type; | 419 | QString type; |
420 | stream >> type; | 420 | stream >> type; |
421 | setBusyIndicatorType( type ); | 421 | setBusyIndicatorType( type ); |
422 | }else if ( msg == "home()" ) { | 422 | }else if ( msg == "home()" ) { |
423 | if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) { | 423 | if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) { |
424 | if (categoryBar) | 424 | if (categoryBar) |
425 | categoryBar->nextTab(); | 425 | categoryBar->nextTab(); |
426 | }else | 426 | }else |
427 | static_cast<QWidget*>(parent())->raise(); | 427 | static_cast<QWidget*>(parent())->raise(); |
428 | } | 428 | } |
429 | } | 429 | } |
430 | 430 | ||
431 | 431 | ||
432 | 432 | ||
433 | //--------------------------------------------------------------------------- | 433 | //--------------------------------------------------------------------------- |
434 | 434 | ||
435 | Launcher::Launcher() | 435 | Launcher::Launcher() |
436 | : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader ) | 436 | : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader ) |
437 | { | 437 | { |
438 | tabs = 0; | 438 | tabs = 0; |
439 | tb = 0; | 439 | tb = 0; |
440 | Config cfg( "Launcher" ); | 440 | Config cfg( "Launcher" ); |
441 | cfg.setGroup( "DocTab" ); | 441 | cfg.setGroup( "DocTab" ); |
@@ -443,344 +443,344 @@ Launcher::Launcher() | |||
443 | } | 443 | } |
444 | 444 | ||
445 | void Launcher::createGUI() | 445 | void Launcher::createGUI() |
446 | { | 446 | { |
447 | setCaption( tr("Launcher") ); | 447 | setCaption( tr("Launcher") ); |
448 | 448 | ||
449 | // we have a pretty good idea how big we'll be | 449 | // we have a pretty good idea how big we'll be |
450 | setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); | 450 | setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); |
451 | 451 | ||
452 | tb = new TaskBar; | 452 | tb = new TaskBar; |
453 | tabs = new LauncherTabWidget( this ); | 453 | tabs = new LauncherTabWidget( this ); |
454 | setCentralWidget( tabs ); | 454 | setCentralWidget( tabs ); |
455 | 455 | ||
456 | ServerInterface::dockWidget( tb, ServerInterface::Bottom ); | 456 | ServerInterface::dockWidget( tb, ServerInterface::Bottom ); |
457 | tb->show(); | 457 | tb->show(); |
458 | 458 | ||
459 | qApp->installEventFilter( this ); | 459 | qApp->installEventFilter( this ); |
460 | 460 | ||
461 | 461 | ||
462 | connect( qApp, SIGNAL(symbol()), this, SLOT(toggleSymbolInput()) ); | 462 | connect( qApp, SIGNAL(symbol()), this, SLOT(toggleSymbolInput()) ); |
463 | connect( qApp, SIGNAL(numLockStateToggle()), this, SLOT(toggleNumLockState()) ); | 463 | connect( qApp, SIGNAL(numLockStateToggle()), this, SLOT(toggleNumLockState()) ); |
464 | connect( qApp, SIGNAL(capsLockStateToggle()), this, SLOT(toggleCapsLockState()) ); | 464 | connect( qApp, SIGNAL(capsLockStateToggle()), this, SLOT(toggleCapsLockState()) ); |
465 | 465 | ||
466 | connect( tb, SIGNAL(tabSelected(const QString&)), | 466 | connect( tb, SIGNAL(tabSelected(const QString&)), |
467 | this, SLOT(showTab(const QString&)) ); | 467 | this, SLOT(showTab(const QString&)) ); |
468 | connect( tabs, SIGNAL(selected(const QString&)), | 468 | connect( tabs, SIGNAL(selected(const QString&)), |
469 | this, SLOT(viewSelected(const QString&)) ); | 469 | this, SLOT(viewSelected(const QString&)) ); |
470 | connect( tabs, SIGNAL(clicked(const AppLnk*)), | 470 | connect( tabs, SIGNAL(clicked(const AppLnk*)), |
471 | this, SLOT(select(const AppLnk*))); | 471 | this, SLOT(select(const AppLnk*))); |
472 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), | 472 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), |
473 | this, SLOT(properties(AppLnk*))); | 473 | this, SLOT(properties(AppLnk*))); |
474 | 474 | ||
475 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 475 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
476 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); | 476 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); |
477 | connect( sysChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 477 | connect( sysChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
478 | this, SLOT(systemMessage(const QCString&,const QByteArray&)) ); | 478 | this, SLOT(systemMessage(const QCString&,const QByteArray&)) ); |
479 | #endif | 479 | #endif |
480 | 480 | ||
481 | // all documents | 481 | // all documents |
482 | QImage img( Resource::loadImage( "DocsIcon" ) ); | 482 | QImage img( Resource::loadImage( "DocsIcon" ) ); |
483 | QPixmap pm; | 483 | QPixmap pm; |
484 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); | 484 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); |
485 | // It could add this itself if it handles docs | 485 | // It could add this itself if it handles docs |
486 | 486 | ||
487 | tabs->newView("Documents", pm, tr("Documents") )->setToolsEnabled( TRUE ); | 487 | tabs->newView("Documents", pm, tr("Documents") )->setToolsEnabled( TRUE ); |
488 | 488 | ||
489 | QTimer::singleShot( 0, tabs, SLOT( initLayout() ) ); | 489 | QTimer::singleShot( 0, tabs, SLOT( initLayout() ) ); |
490 | qApp->setMainWidget( this ); | 490 | qApp->setMainWidget( this ); |
491 | QTimer::singleShot( 500, this, SLOT( makeVisible() ) ); | 491 | QTimer::singleShot( 500, this, SLOT( makeVisible() ) ); |
492 | } | 492 | } |
493 | 493 | ||
494 | Launcher::~Launcher() | 494 | Launcher::~Launcher() |
495 | { | 495 | { |
496 | if ( tb ) | 496 | if ( tb ) |
497 | destroyGUI(); | 497 | destroyGUI(); |
498 | } | 498 | } |
499 | 499 | ||
500 | bool Launcher::requiresDocuments() const | 500 | bool Launcher::requiresDocuments() const |
501 | { | 501 | { |
502 | Config cfg( "Launcher" ); | 502 | Config cfg( "Launcher" ); |
503 | cfg.setGroup( "DocTab" ); | 503 | cfg.setGroup( "DocTab" ); |
504 | return cfg.readBoolEntry( "Enable", true ); | 504 | return cfg.readBoolEntry( "Enable", true ); |
505 | } | 505 | } |
506 | 506 | ||
507 | void Launcher::makeVisible() | 507 | void Launcher::makeVisible() |
508 | { | 508 | { |
509 | showMaximized(); | 509 | showMaximized(); |
510 | } | 510 | } |
511 | 511 | ||
512 | void Launcher::destroyGUI() | 512 | void Launcher::destroyGUI() |
513 | { | 513 | { |
514 | delete tb; | 514 | delete tb; |
515 | tb = 0; | 515 | tb = 0; |
516 | delete tabs; | 516 | delete tabs; |
517 | tabs =0; | 517 | tabs =0; |
518 | } | 518 | } |
519 | 519 | ||
520 | bool Launcher::eventFilter( QObject*, QEvent *ev ) | 520 | bool Launcher::eventFilter( QObject*, QEvent *ev ) |
521 | { | 521 | { |
522 | #ifdef QT_QWS_CUSTOM | 522 | #ifdef QT_QWS_CUSTOM |
523 | if ( ev->type() == QEvent::KeyPress ) { | 523 | if ( ev->type() == QEvent::KeyPress ) { |
524 | QKeyEvent *ke = (QKeyEvent *)ev; | 524 | QKeyEvent *ke = (QKeyEvent *)ev; |
525 | if ( ke->key() == Qt::Key_F11 ) { // menu key | 525 | if ( ke->key() == Qt::Key_F11 ) { // menu key |
526 | QWidget *active = qApp->activeWindow(); | 526 | QWidget *active = qApp->activeWindow(); |
527 | if ( active && active->isPopup() ) | 527 | if ( active && active->isPopup() ) |
528 | active->close(); | 528 | active->close(); |
529 | else { | 529 | else { |
530 | Global::terminateBuiltin("calibrate"); // No tr | 530 | Global::terminateBuiltin("calibrate"); // No tr |
531 | tb->launchStartMenu(); | 531 | tb->launchStartMenu(); |
532 | } | 532 | } |
533 | return TRUE; | 533 | return TRUE; |
534 | } | 534 | } |
535 | } | 535 | } |
536 | #else | 536 | #else |
537 | Q_UNUSED(ev); | 537 | Q_UNUSED(ev); |
538 | #endif | 538 | #endif |
539 | return FALSE; | 539 | return FALSE; |
540 | } | 540 | } |
541 | 541 | ||
542 | void Launcher::toggleSymbolInput() | 542 | void Launcher::toggleSymbolInput() |
543 | { | 543 | { |
544 | tb->toggleSymbolInput(); | 544 | tb->toggleSymbolInput(); |
545 | } | 545 | } |
546 | 546 | ||
547 | void Launcher::toggleNumLockState() | 547 | void Launcher::toggleNumLockState() |
548 | { | 548 | { |
549 | tb->toggleNumLockState(); | 549 | tb->toggleNumLockState(); |
550 | } | 550 | } |
551 | 551 | ||
552 | void Launcher::toggleCapsLockState() | 552 | void Launcher::toggleCapsLockState() |
553 | { | 553 | { |
554 | tb->toggleCapsLockState(); | 554 | tb->toggleCapsLockState(); |
555 | } | 555 | } |
556 | 556 | ||
557 | static bool isVisibleWindow(int wid) | 557 | static bool isVisibleWindow(int wid) |
558 | { | 558 | { |
559 | #ifdef Q_WS_QWS | 559 | #ifdef Q_WS_QWS |
560 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 560 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
561 | QWSWindow* w; | 561 | QWSWindow* w; |
562 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 562 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
563 | if ( w->winId() == wid ) | 563 | if ( w->winId() == wid ) |
564 | return !w->isFullyObscured(); | 564 | return !w->isFullyObscured(); |
565 | } | 565 | } |
566 | #endif | 566 | #endif |
567 | return FALSE; | 567 | return FALSE; |
568 | } | 568 | } |
569 | 569 | ||
570 | void Launcher::viewSelected(const QString& s) | 570 | void Launcher::viewSelected(const QString& s) |
571 | { | 571 | { |
572 | setCaption( s + tr(" - Launcher") ); | 572 | setCaption( s + tr(" - Launcher") ); |
573 | } | 573 | } |
574 | 574 | ||
575 | void Launcher::showTab(const QString& id) | 575 | void Launcher::showTab(const QString& id) |
576 | { | 576 | { |
577 | tabs->categoryBar->showTab(id); | 577 | tabs->categoryBar->showTab(id); |
578 | raise(); | 578 | raise(); |
579 | } | 579 | } |
580 | 580 | ||
581 | void Launcher::select( const AppLnk *appLnk ) | 581 | void Launcher::select( const AppLnk *appLnk ) |
582 | { | 582 | { |
583 | if ( appLnk->type() == "Folder" ) { // No tr | 583 | if ( appLnk->type() == "Folder" ) { // No tr |
584 | // Not supported: flat is simpler for the user | 584 | // Not supported: flat is simpler for the user |
585 | } else { | 585 | } else { |
586 | if ( appLnk->exec().isNull() ) { | 586 | if ( appLnk->exec().isNull() ) { |
587 | int i = QMessageBox::information(this,tr("No application"), | 587 | int i = QMessageBox::information(this,tr("No application"), |
588 | tr("<p>No application is defined for this document." | 588 | tr("<p>No application is defined for this document." |
589 | "<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1); | 589 | "<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1); |
590 | 590 | ||
591 | /* ### Fixme */ | 591 | /* ### Fixme */ |
592 | if ( i == 1 ) | 592 | if ( i == 1 ) |
593 | Global::execute("textedit",appLnk->file()); | 593 | Global::execute("textedit",appLnk->file()); |
594 | 594 | ||
595 | return; | 595 | return; |
596 | } | 596 | } |
597 | tabs->setBusy(TRUE); | 597 | tabs->setBusy(TRUE); |
598 | emit executing( appLnk ); | 598 | emit executing( appLnk ); |
599 | appLnk->execute(); | 599 | appLnk->execute(); |
600 | } | 600 | } |
601 | } | 601 | } |
602 | 602 | ||
603 | void Launcher::properties( AppLnk *appLnk ) | 603 | void Launcher::properties( AppLnk *appLnk ) |
604 | { | 604 | { |
605 | if ( appLnk->type() == "Folder" ) { // No tr | 605 | if ( appLnk->type() == "Folder" ) { // No tr |
606 | // Not supported: flat is simpler for the user | 606 | // Not supported: flat is simpler for the user |
607 | } else { | 607 | } else { |
608 | /* ### libqtopia FIXME also moving docLnks... */ | 608 | /* ### libqtopia FIXME also moving docLnks... */ |
609 | LnkProperties prop(appLnk,0 ); | 609 | LnkProperties prop(appLnk,0 ); |
610 | 610 | ||
611 | QPEApplication::execDialog( &prop ); | 611 | QPEApplication::execDialog( &prop ); |
612 | } | 612 | } |
613 | } | 613 | } |
614 | 614 | ||
615 | void Launcher::storageChanged( const QList<FileSystem> &fs ) | 615 | void Launcher::storageChanged( const QList<FileSystem> &fs ) |
616 | { | 616 | { |
617 | // ### update combo boxes if we had a combo box for the storage type | 617 | // ### update combo boxes if we had a combo box for the storage type |
618 | } | 618 | } |
619 | 619 | ||
620 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) | 620 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) |
621 | { | 621 | { |
622 | QDataStream stream( data, IO_ReadOnly ); | 622 | QDataStream stream( data, IO_ReadOnly ); |
623 | if ( msg == "busy()" ) { | 623 | if ( msg == "busy()" ) { |
624 | tb->startWait(); | 624 | tb->startWait(); |
625 | } else if ( msg == "notBusy(QString)" ) { | 625 | } else if ( msg == "notBusy(QString)" ) { |
626 | QString app; | 626 | QString app; |
627 | stream >> app; | 627 | stream >> app; |
628 | tabs->setBusy(FALSE); | 628 | tabs->setBusy(FALSE); |
629 | tb->stopWait(app); | 629 | tb->stopWait(app); |
630 | } else if (msg == "applyStyle()") { | 630 | } else if (msg == "applyStyle()") { |
631 | tabs->currentView()->relayout(); | 631 | tabs->currentView()->relayout(); |
632 | } | 632 | } |
633 | } | 633 | } |
634 | 634 | ||
635 | // These are the update functions from the server | 635 | // These are the update functions from the server |
636 | void Launcher::typeAdded( const QString& type, const QString& name, | 636 | void Launcher::typeAdded( const QString& type, const QString& name, |
637 | const QPixmap& pixmap, const QPixmap& ) | 637 | const QPixmap& pixmap, const QPixmap& ) |
638 | { | 638 | { |
639 | tabs->newView( type, pixmap, name ); | 639 | tabs->newView( type, pixmap, name ); |
640 | ids.append( type ); | 640 | ids.append( type ); |
641 | /* this will be called in applicationScanningProgress with value 100! */ | 641 | /* this will be called in applicationScanningProgress with value 100! */ |
642 | // tb->refreshStartMenu(); | 642 | // tb->refreshStartMenu(); |
643 | 643 | ||
644 | static bool first = TRUE; | 644 | static bool first = TRUE; |
645 | if ( first ) { | 645 | if ( first ) { |
646 | first = FALSE; | 646 | first = FALSE; |
647 | tabs->categoryBar->showTab(type); | 647 | tabs->categoryBar->showTab(type); |
648 | } | 648 | } |
649 | 649 | ||
650 | tabs->view( type )->setUpdatesEnabled( FALSE ); | 650 | tabs->view( type )->setUpdatesEnabled( FALSE ); |
651 | tabs->view( type )->setSortEnabled( FALSE ); | 651 | tabs->view( type )->setSortEnabled( FALSE ); |
652 | } | 652 | } |
653 | 653 | ||
654 | void Launcher::typeRemoved( const QString& type ) | 654 | void Launcher::typeRemoved( const QString& type ) |
655 | { | 655 | { |
656 | tabs->view( type )->removeAllItems(); | 656 | tabs->view( type )->removeAllItems(); |
657 | tabs->deleteView( type ); | 657 | tabs->deleteView( type ); |
658 | ids.remove( type ); | 658 | ids.remove( type ); |
659 | /* this will be called in applicationScanningProgress with value 100! */ | 659 | /* this will be called in applicationScanningProgress with value 100! */ |
660 | // tb->refreshStartMenu(); | 660 | // tb->refreshStartMenu(); |
661 | } | 661 | } |
662 | 662 | ||
663 | void Launcher::applicationAdded( const QString& type, const AppLnk& app ) | 663 | void Launcher::applicationAdded( const QString& type, const AppLnk& app ) |
664 | { | 664 | { |
665 | if ( app.type() == "Separator" ) // No tr | 665 | if ( app.type() == "Separator" ) // No tr |
666 | return; | 666 | return; |
667 | 667 | ||
668 | LauncherView *view = tabs->view( type ); | 668 | LauncherView *view = tabs->view( type ); |
669 | if ( view ) | 669 | if ( view ) |
670 | view->addItem( new AppLnk( app ), FALSE ); | 670 | view->addItem( new AppLnk( app ), FALSE ); |
671 | else | 671 | else |
672 | qWarning("addAppLnk: No view for type %s. Can't add app %s!", | 672 | owarn << "addAppLnk: No view for type " << type.latin1() << ". Can't add app " |
673 | type.latin1(),app.name().latin1() ); | 673 | << app.name().latin1() << "!", |
674 | 674 | ||
675 | MimeType::registerApp( app ); | 675 | MimeType::registerApp( app ); |
676 | } | 676 | } |
677 | 677 | ||
678 | void Launcher::applicationRemoved( const QString& type, const AppLnk& app ) | 678 | void Launcher::applicationRemoved( const QString& type, const AppLnk& app ) |
679 | { | 679 | { |
680 | LauncherView *view = tabs->view( type ); | 680 | LauncherView *view = tabs->view( type ); |
681 | if ( view ) | 681 | if ( view ) |
682 | view->removeLink( app.linkFile() ); | 682 | view->removeLink( app.linkFile() ); |
683 | else | 683 | else |
684 | owarn << "removeAppLnk: No view for " << type << "!" << oendl; | 684 | owarn << "removeAppLnk: No view for " << type << "!" << oendl; |
685 | } | 685 | } |
686 | 686 | ||
687 | void Launcher::allApplicationsRemoved() | 687 | void Launcher::allApplicationsRemoved() |
688 | { | 688 | { |
689 | MimeType::clear(); | 689 | MimeType::clear(); |
690 | for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) | 690 | for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) |
691 | tabs->view( (*it) )->removeAllItems(); | 691 | tabs->view( (*it) )->removeAllItems(); |
692 | } | 692 | } |
693 | 693 | ||
694 | void Launcher::documentAdded( const DocLnk& doc ) | 694 | void Launcher::documentAdded( const DocLnk& doc ) |
695 | { | 695 | { |
696 | tabs->docView()->addItem( new DocLnk( doc ), FALSE ); | 696 | tabs->docView()->addItem( new DocLnk( doc ), FALSE ); |
697 | } | 697 | } |
698 | 698 | ||
699 | void Launcher::aboutToAddBegin() | 699 | void Launcher::aboutToAddBegin() |
700 | { | 700 | { |
701 | tabs->docView()->setUpdatesEnabled( false ); | 701 | tabs->docView()->setUpdatesEnabled( false ); |
702 | } | 702 | } |
703 | 703 | ||
704 | void Launcher::aboutToAddEnd() | 704 | void Launcher::aboutToAddEnd() |
705 | { | 705 | { |
706 | tabs->docView()->setUpdatesEnabled( true ); | 706 | tabs->docView()->setUpdatesEnabled( true ); |
707 | } | 707 | } |
708 | 708 | ||
709 | void Launcher::showLoadingDocs() | 709 | void Launcher::showLoadingDocs() |
710 | { | 710 | { |
711 | tabs->docView()->hide(); | 711 | tabs->docView()->hide(); |
712 | } | 712 | } |
713 | 713 | ||
714 | void Launcher::showDocTab() | 714 | void Launcher::showDocTab() |
715 | { | 715 | { |
716 | if ( tabs->categoryBar->currentView() == tabs->docView() ) | 716 | if ( tabs->categoryBar->currentView() == tabs->docView() ) |
717 | tabs->docView()->show(); | 717 | tabs->docView()->show(); |
718 | } | 718 | } |
719 | 719 | ||
720 | void Launcher::documentRemoved( const DocLnk& doc ) | 720 | void Launcher::documentRemoved( const DocLnk& doc ) |
721 | { | 721 | { |
722 | tabs->docView()->removeLink( doc.linkFile() ); | 722 | tabs->docView()->removeLink( doc.linkFile() ); |
723 | } | 723 | } |
724 | 724 | ||
725 | void Launcher::documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc ) | 725 | void Launcher::documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc ) |
726 | { | 726 | { |
727 | documentRemoved( oldDoc ); | 727 | documentRemoved( oldDoc ); |
728 | documentAdded( newDoc ); | 728 | documentAdded( newDoc ); |
729 | } | 729 | } |
730 | 730 | ||
731 | void Launcher::allDocumentsRemoved() | 731 | void Launcher::allDocumentsRemoved() |
732 | { | 732 | { |
733 | tabs->docView()->removeAllItems(); | 733 | tabs->docView()->removeAllItems(); |
734 | } | 734 | } |
735 | 735 | ||
736 | void Launcher::applicationStateChanged( const QString& name, ApplicationState state ) | 736 | void Launcher::applicationStateChanged( const QString& name, ApplicationState state ) |
737 | { | 737 | { |
738 | tb->setApplicationState( name, state ); | 738 | tb->setApplicationState( name, state ); |
739 | } | 739 | } |
740 | 740 | ||
741 | void Launcher::applicationScanningProgress( int percent ) | 741 | void Launcher::applicationScanningProgress( int percent ) |
742 | { | 742 | { |
743 | switch ( percent ) { | 743 | switch ( percent ) { |
744 | case 0: { | 744 | case 0: { |
745 | for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { | 745 | for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { |
746 | tabs->view( (*it) )->setUpdatesEnabled( FALSE ); | 746 | tabs->view( (*it) )->setUpdatesEnabled( FALSE ); |
747 | tabs->view( (*it) )->setSortEnabled( FALSE ); | 747 | tabs->view( (*it) )->setSortEnabled( FALSE ); |
748 | } | 748 | } |
749 | break; | 749 | break; |
750 | } | 750 | } |
751 | case 100: { | 751 | case 100: { |
752 | for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { | 752 | for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { |
753 | tabs->view( (*it) )->setUpdatesEnabled( TRUE ); | 753 | tabs->view( (*it) )->setUpdatesEnabled( TRUE ); |
754 | tabs->view( (*it) )->setSortEnabled( TRUE ); | 754 | tabs->view( (*it) )->setSortEnabled( TRUE ); |
755 | } | 755 | } |
756 | tb->refreshStartMenu(); | 756 | tb->refreshStartMenu(); |
757 | break; | 757 | break; |
758 | } | 758 | } |
759 | default: | 759 | default: |
760 | break; | 760 | break; |
761 | } | 761 | } |
762 | } | 762 | } |
763 | 763 | ||
764 | void Launcher::documentScanningProgress( int percent ) | 764 | void Launcher::documentScanningProgress( int percent ) |
765 | { | 765 | { |
766 | switch ( percent ) { | 766 | switch ( percent ) { |
767 | case 0: { | 767 | case 0: { |
768 | tabs->setLoadingProgress( 0 ); | 768 | tabs->setLoadingProgress( 0 ); |
769 | tabs->setLoadingWidgetEnabled( TRUE ); | 769 | tabs->setLoadingWidgetEnabled( TRUE ); |
770 | tabs->docView()->setUpdatesEnabled( FALSE ); | 770 | tabs->docView()->setUpdatesEnabled( FALSE ); |
771 | tabs->docView()->setSortEnabled( FALSE ); | 771 | tabs->docView()->setSortEnabled( FALSE ); |
772 | break; | 772 | break; |
773 | } | 773 | } |
774 | case 100: { | 774 | case 100: { |
775 | tabs->docView()->updateTools(); | 775 | tabs->docView()->updateTools(); |
776 | tabs->docView()->setSortEnabled( TRUE ); | 776 | tabs->docView()->setSortEnabled( TRUE ); |
777 | tabs->docView()->setUpdatesEnabled( TRUE ); | 777 | tabs->docView()->setUpdatesEnabled( TRUE ); |
778 | tabs->setLoadingWidgetEnabled( FALSE ); | 778 | tabs->setLoadingWidgetEnabled( FALSE ); |
779 | break; | 779 | break; |
780 | } | 780 | } |
781 | default: | 781 | default: |
782 | tabs->setLoadingProgress( percent ); | 782 | tabs->setLoadingProgress( percent ); |
783 | break; | 783 | break; |
784 | } | 784 | } |
785 | } | 785 | } |
786 | 786 | ||
diff --git a/core/launcher/packageslave.cpp b/core/launcher/packageslave.cpp index a11ac86..0461432 100644 --- a/core/launcher/packageslave.cpp +++ b/core/launcher/packageslave.cpp | |||
@@ -32,308 +32,307 @@ using namespace Opie::Core; | |||
32 | #ifdef Q_WS_QWS | 32 | #ifdef Q_WS_QWS |
33 | #include <qcopchannel_qws.h> | 33 | #include <qcopchannel_qws.h> |
34 | #endif | 34 | #endif |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | 36 | ||
37 | /* STD */ | 37 | /* STD */ |
38 | #include <stdlib.h> | 38 | #include <stdlib.h> |
39 | #include <sys/stat.h> // mkdir() | 39 | #include <sys/stat.h> // mkdir() |
40 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 40 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
41 | #include <unistd.h> | 41 | #include <unistd.h> |
42 | #include <sys/vfs.h> | 42 | #include <sys/vfs.h> |
43 | #include <mntent.h> | 43 | #include <mntent.h> |
44 | #elif defined(Q_OS_MACX) | 44 | #elif defined(Q_OS_MACX) |
45 | #include <unistd.h> | 45 | #include <unistd.h> |
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | 48 | ||
49 | PackageHandler::PackageHandler( QObject *parent, char* name ) | 49 | PackageHandler::PackageHandler( QObject *parent, char* name ) |
50 | : QObject( parent, name ), packageChannel( 0 ), currentProcess( 0 ), mNoSpaceLeft( FALSE ) | 50 | : QObject( parent, name ), packageChannel( 0 ), currentProcess( 0 ), mNoSpaceLeft( FALSE ) |
51 | { | 51 | { |
52 | // setup qcop channel | 52 | // setup qcop channel |
53 | #ifndef QT_NO_COP | 53 | #ifndef QT_NO_COP |
54 | packageChannel = new QCopChannel( "QPE/Package", this ); | 54 | packageChannel = new QCopChannel( "QPE/Package", this ); |
55 | connect( packageChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 55 | connect( packageChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
56 | this, SLOT( qcopMessage(const QCString&,const QByteArray&) ) ); | 56 | this, SLOT( qcopMessage(const QCString&,const QByteArray&) ) ); |
57 | #endif | 57 | #endif |
58 | } | 58 | } |
59 | 59 | ||
60 | void PackageHandler::qcopMessage( const QCString &msg, const QByteArray &data ) | 60 | void PackageHandler::qcopMessage( const QCString &msg, const QByteArray &data ) |
61 | { | 61 | { |
62 | QDataStream stream( data, IO_ReadOnly ); | 62 | QDataStream stream( data, IO_ReadOnly ); |
63 | 63 | ||
64 | if ( msg == "installPackage(QString)" ) { | 64 | if ( msg == "installPackage(QString)" ) { |
65 | QString file; | 65 | QString file; |
66 | stream >> file; | 66 | stream >> file; |
67 | installPackage( file ); | 67 | installPackage( file ); |
68 | } else if ( msg == "removePackage(QString)" ) { | 68 | } else if ( msg == "removePackage(QString)" ) { |
69 | QString file; | 69 | QString file; |
70 | stream >> file; | 70 | stream >> file; |
71 | removePackage( file ); | 71 | removePackage( file ); |
72 | } else if ( msg == "addPackageFiles(QString,QString)" ) { | 72 | } else if ( msg == "addPackageFiles(QString,QString)" ) { |
73 | QString location, listfile; | 73 | QString location, listfile; |
74 | stream >> location >> listfile; | 74 | stream >> location >> listfile; |
75 | addPackageFiles( location, listfile); | 75 | addPackageFiles( location, listfile); |
76 | } else if ( msg == "addPackages(QString)" ) { | 76 | } else if ( msg == "addPackages(QString)" ) { |
77 | QString location; | 77 | QString location; |
78 | stream >> location; | 78 | stream >> location; |
79 | addPackages( location ); | 79 | addPackages( location ); |
80 | } else if ( msg == "cleanupPackageFiles(QString)" ) { | 80 | } else if ( msg == "cleanupPackageFiles(QString)" ) { |
81 | QString listfile; | 81 | QString listfile; |
82 | stream >> listfile; | 82 | stream >> listfile; |
83 | cleanupPackageFiles( listfile ); | 83 | cleanupPackageFiles( listfile ); |
84 | } else if ( msg == "cleanupPackages(QString)" ) { | 84 | } else if ( msg == "cleanupPackages(QString)" ) { |
85 | QString location; | 85 | QString location; |
86 | stream >> location; | 86 | stream >> location; |
87 | cleanupPackages( location ); | 87 | cleanupPackages( location ); |
88 | } else if ( msg == "prepareInstall(QString,QString)" ) { | 88 | } else if ( msg == "prepareInstall(QString,QString)" ) { |
89 | QString size, path; | 89 | QString size, path; |
90 | stream >> size; | 90 | stream >> size; |
91 | stream >> path; | 91 | stream >> path; |
92 | prepareInstall( size, path ); | 92 | prepareInstall( size, path ); |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | void PackageHandler::installPackage( const QString &package ) | 96 | void PackageHandler::installPackage( const QString &package ) |
97 | { | 97 | { |
98 | if ( mNoSpaceLeft ) { | 98 | if ( mNoSpaceLeft ) { |
99 | mNoSpaceLeft = FALSE; | 99 | mNoSpaceLeft = FALSE; |
100 | // Don't emit that for now, I still couldn't test it (Wener) | 100 | // Don't emit that for now, I still couldn't test it (Wener) |
101 | //sendReply( "installFailed(QString)", package ); | 101 | //sendReply( "installFailed(QString)", package ); |
102 | //return; | 102 | //return; |
103 | } | 103 | } |
104 | 104 | ||
105 | currentProcess = new QProcess( QStringList() << "ipkg" << "install" << package ); // No tr | 105 | currentProcess = new QProcess( QStringList() << "ipkg" << "install" << package ); // No tr |
106 | connect( currentProcess, SIGNAL( processExited() ), SLOT( iProcessExited() ) ); | 106 | connect( currentProcess, SIGNAL( processExited() ), SLOT( iProcessExited() ) ); |
107 | connect( currentProcess, SIGNAL( readyReadStdout() ), SLOT( readyReadStdout() ) ); | 107 | connect( currentProcess, SIGNAL( readyReadStdout() ), SLOT( readyReadStdout() ) ); |
108 | connect( currentProcess, SIGNAL( readyReadStderr() ), SLOT( readyReadStderr() ) ); | 108 | connect( currentProcess, SIGNAL( readyReadStderr() ), SLOT( readyReadStderr() ) ); |
109 | currentPackage = package; | 109 | currentPackage = package; |
110 | 110 | ||
111 | currentProcessError=""; | 111 | currentProcessError=""; |
112 | sendReply( "installStarted(QString)", package ); | 112 | sendReply( "installStarted(QString)", package ); |
113 | currentProcess->start(); | 113 | currentProcess->start(); |
114 | } | 114 | } |
115 | 115 | ||
116 | void PackageHandler::removePackage( const QString &package ) | 116 | void PackageHandler::removePackage( const QString &package ) |
117 | { | 117 | { |
118 | currentProcess = new QProcess( QStringList() << "ipkg" << "remove" << package ); // No tr | 118 | currentProcess = new QProcess( QStringList() << "ipkg" << "remove" << package ); // No tr |
119 | connect( currentProcess, SIGNAL( processExited() ), SLOT( rmProcessExited() ) ); | 119 | connect( currentProcess, SIGNAL( processExited() ), SLOT( rmProcessExited() ) ); |
120 | connect( currentProcess, SIGNAL( readyReadStdout() ), SLOT( readyReadStdout() ) ); | 120 | connect( currentProcess, SIGNAL( readyReadStdout() ), SLOT( readyReadStdout() ) ); |
121 | connect( currentProcess, SIGNAL( readyReadStderr() ), SLOT( readyReadStderr() ) ); | 121 | connect( currentProcess, SIGNAL( readyReadStderr() ), SLOT( readyReadStderr() ) ); |
122 | currentPackage = package; | 122 | currentPackage = package; |
123 | 123 | ||
124 | currentProcessError=""; | 124 | currentProcessError=""; |
125 | sendReply( "removeStarted(QString)", package ); | 125 | sendReply( "removeStarted(QString)", package ); |
126 | currentProcess->start(); | 126 | currentProcess->start(); |
127 | } | 127 | } |
128 | 128 | ||
129 | void PackageHandler::sendReply( const QCString& msg, const QString& arg ) | 129 | void PackageHandler::sendReply( const QCString& msg, const QString& arg ) |
130 | { | 130 | { |
131 | #ifndef QT_NO_COP | 131 | #ifndef QT_NO_COP |
132 | QCopEnvelope e( "QPE/Desktop", msg ); | 132 | QCopEnvelope e( "QPE/Desktop", msg ); |
133 | e << arg; | 133 | e << arg; |
134 | #endif | 134 | #endif |
135 | } | 135 | } |
136 | 136 | ||
137 | void PackageHandler::addPackageFiles( const QString &location, | 137 | void PackageHandler::addPackageFiles( const QString &location, |
138 | const QString &listfile ) | 138 | const QString &listfile ) |
139 | { | 139 | { |
140 | QFile f(listfile); | 140 | QFile f(listfile); |
141 | #ifndef Q_OS_WIN32 | 141 | #ifndef Q_OS_WIN32 |
142 | //make a copy so we can remove the symlinks later | 142 | //make a copy so we can remove the symlinks later |
143 | mkdir( ("/usr/lib/ipkg/info/"+location).ascii(), 0777 ); | 143 | mkdir( ("/usr/lib/ipkg/info/"+location).ascii(), 0777 ); |
144 | system(("cp " + f.name() + " /usr/lib/ipkg/info/"+location).ascii()); | 144 | system(("cp " + f.name() + " /usr/lib/ipkg/info/"+location).ascii()); |
145 | #else | 145 | #else |
146 | QDir d; | 146 | QDir d; |
147 | //#### revise | 147 | //#### revise |
148 | odebug << "Copy file at " << __FILE__ << ": " << __LINE__ << "" << oendl; | 148 | odebug << "Copy file at " << __FILE__ << ": " << __LINE__ << "" << oendl; |
149 | d.mkdir(("/usr/lib/ipkg/info/" + location).ascii()); | 149 | d.mkdir(("/usr/lib/ipkg/info/" + location).ascii()); |
150 | system(("copy " + f.name() + " /usr/lib/ipkg/info/"+location).ascii()); | 150 | system(("copy " + f.name() + " /usr/lib/ipkg/info/"+location).ascii()); |
151 | #endif | 151 | #endif |
152 | 152 | ||
153 | |||
154 | if ( f.open(IO_ReadOnly) ) { | ||
155 | QTextStream ts(&f); | ||
156 | 153 | ||
157 | QString s; | 154 | if ( f.open(IO_ReadOnly) ) { |
158 | while ( !ts.eof() ) { // until end of file... | 155 | QTextStream ts(&f); |
159 | s = ts.readLine(); // line of text excluding '\n' | 156 | |
160 | // for s, do link/mkdir. | 157 | QString s; |
161 | if ( s.right(1) == "/" ) { | 158 | while ( !ts.eof() ) { // until end of file... |
159 | s = ts.readLine(); // line of text excluding '\n' | ||
160 | // for s, do link/mkdir. | ||
161 | if ( s.right(1) == "/" ) { | ||
162 | odebug << "do mkdir for " << s.ascii() << "" << oendl; | 162 | odebug << "do mkdir for " << s.ascii() << "" << oendl; |
163 | #ifndef Q_OS_WIN32 | 163 | #ifndef Q_OS_WIN32 |
164 | mkdir( s.ascii(), 0777 ); | 164 | mkdir( s.ascii(), 0777 ); |
165 | //possible optimization: symlink directories | 165 | //possible optimization: symlink directories |
166 | //that don't exist already. -- Risky. | 166 | //that don't exist already. -- Risky. |
167 | #else | 167 | #else |
168 | d.mkdir( s.ascii()); | 168 | d.mkdir( s.ascii()); |
169 | #endif | 169 | #endif |
170 | 170 | ||
171 | } else { | 171 | } else { |
172 | #ifndef Q_OS_WIN32 | 172 | #ifndef Q_OS_WIN32 |
173 | odebug << "do symlink for " << s.ascii() << "" << oendl; | 173 | odebug << "do symlink for " << s.ascii() << "" << oendl; |
174 | symlink( (location + s).ascii(), s.ascii() ); | 174 | symlink( (location + s).ascii(), s.ascii() ); |
175 | #else | 175 | #else |
176 | odebug << "Copy file instead of a symlink for WIN32" << oendl; | 176 | odebug << "Copy file instead of a symlink for WIN32" << oendl; |
177 | if (!CopyFile((TCHAR*)qt_winTchar((location + s), TRUE), (TCHAR*)qt_winTchar(s, TRUE), FALSE)) | 177 | if (!CopyFile((TCHAR*)qt_winTchar((location + s), TRUE), (TCHAR*)qt_winTchar(s, TRUE), FALSE)) |
178 | qWarning("Unable to create symlinkfor %s", | 178 | owarn << "Unable to create symlinkfor " << (location + s).ascii() << oendl; |
179 | (location + s).ascii()); | ||
180 | #endif | 179 | #endif |
181 | } | 180 | } |
182 | } | 181 | } |
183 | f.close(); | 182 | f.close(); |
184 | } | 183 | } |
185 | } | 184 | } |
186 | 185 | ||
187 | void PackageHandler::addPackages( const QString &location ) | 186 | void PackageHandler::addPackages( const QString &location ) |
188 | { | 187 | { |
189 | // get list of *.list in location/usr/lib/ipkg/info/*.list | 188 | // get list of *.list in location/usr/lib/ipkg/info/*.list |
190 | QDir dir(location + "/usr/lib/ipkg/info", "*.list", // No tr | 189 | QDir dir(location + "/usr/lib/ipkg/info", "*.list", // No tr |
191 | QDir::Name, QDir::Files); | 190 | QDir::Name, QDir::Files); |
192 | if ( !dir.exists() ) | 191 | if ( !dir.exists() ) |
193 | return; | 192 | return; |
194 | 193 | ||
195 | QStringList packages = dir.entryList(); | 194 | QStringList packages = dir.entryList(); |
196 | for ( QStringList::Iterator it = packages.begin(); | 195 | for ( QStringList::Iterator it = packages.begin(); |
197 | it != packages.end(); ++it ) { | 196 | it != packages.end(); ++it ) { |
198 | addPackageFiles( location, *it ); | 197 | addPackageFiles( location, *it ); |
199 | } | 198 | } |
200 | } | 199 | } |
201 | 200 | ||
202 | 201 | ||
203 | void PackageHandler::cleanupPackageFiles( const QString &listfile ) | 202 | void PackageHandler::cleanupPackageFiles( const QString &listfile ) |
204 | { | 203 | { |
205 | QFile f(listfile); | 204 | QFile f(listfile); |
206 | 205 | ||
207 | if ( f.open(IO_ReadOnly) ) { | 206 | if ( f.open(IO_ReadOnly) ) { |
208 | QTextStream ts(&f); | 207 | QTextStream ts(&f); |
209 | 208 | ||
210 | QString s; | 209 | QString s; |
211 | while ( !ts.eof() ) { // until end of file... | 210 | while ( !ts.eof() ) { // until end of file... |
212 | s = ts.readLine(); // line of text excluding '\n' | 211 | s = ts.readLine(); // line of text excluding '\n' |
213 | // for s, do link/mkdir. | 212 | // for s, do link/mkdir. |
214 | if ( s.right(1) == "/" ) { | 213 | if ( s.right(1) == "/" ) { |
215 | //should rmdir if empty, after all files have been removed | 214 | //should rmdir if empty, after all files have been removed |
216 | } else { | 215 | } else { |
217 | #ifndef Q_OS_WIN32 | 216 | #ifndef Q_OS_WIN32 |
218 | odebug << "remove symlink for " << s.ascii() << "" << oendl; | 217 | odebug << "remove symlink for " << s.ascii() << "" << oendl; |
219 | //check if it is a symlink first (don't remove /etc/passwd...) | 218 | //check if it is a symlink first (don't remove /etc/passwd...) |
220 | char buf[10]; //we don't care about the contents | 219 | char buf[10]; //we don't care about the contents |
221 | if ( ::readlink( s.ascii(),buf, 10 >= 0 ) ) | 220 | if ( ::readlink( s.ascii(),buf, 10 >= 0 ) ) |
222 | ::unlink( s.ascii() ); | 221 | ::unlink( s.ascii() ); |
223 | #else | 222 | #else |
224 | // ### revise | 223 | // ### revise |
225 | owarn << "Unable to remove symlink " << __FILE__ << ":" << __LINE__ << "" << oendl; | 224 | owarn << "Unable to remove symlink " << __FILE__ << ":" << __LINE__ << "" << oendl; |
226 | #endif | 225 | #endif |
227 | } | 226 | } |
228 | } | 227 | } |
229 | f.close(); | 228 | f.close(); |
230 | 229 | ||
231 | //remove the list file | 230 | //remove the list file |
232 | ::unlink( listfile.ascii() ); | 231 | ::unlink( listfile.ascii() ); |
233 | 232 | ||
234 | } | 233 | } |
235 | } | 234 | } |
236 | 235 | ||
237 | void PackageHandler::cleanupPackages( const QString &location ) | 236 | void PackageHandler::cleanupPackages( const QString &location ) |
238 | { | 237 | { |
239 | // get list of *.list in location/usr/lib/ipkg/info/*.list | 238 | // get list of *.list in location/usr/lib/ipkg/info/*.list |
240 | QDir dir( "/usr/lib/ipkg/info/"+location, "*.list", // No tr | 239 | QDir dir( "/usr/lib/ipkg/info/"+location, "*.list", // No tr |
241 | QDir::Name, QDir::Files); | 240 | QDir::Name, QDir::Files); |
242 | if ( !dir.exists() ) | 241 | if ( !dir.exists() ) |
243 | return; | 242 | return; |
244 | 243 | ||
245 | QStringList packages = dir.entryList(); | 244 | QStringList packages = dir.entryList(); |
246 | for ( QStringList::Iterator it = packages.begin(); | 245 | for ( QStringList::Iterator it = packages.begin(); |
247 | it != packages.end(); ++it ) { | 246 | it != packages.end(); ++it ) { |
248 | cleanupPackageFiles( *it ); | 247 | cleanupPackageFiles( *it ); |
249 | } | 248 | } |
250 | 249 | ||
251 | //remove the backup directory | 250 | //remove the backup directory |
252 | //### | 251 | //### |
253 | } | 252 | } |
254 | 253 | ||
255 | void PackageHandler::prepareInstall( const QString& size, const QString& path ) | 254 | void PackageHandler::prepareInstall( const QString& size, const QString& path ) |
256 | { | 255 | { |
257 | // Check whether there will be enough space to install the next package. | 256 | // Check whether there will be enough space to install the next package. |
258 | bool ok; | 257 | bool ok; |
259 | unsigned int s = size.toUInt( &ok ); | 258 | unsigned int s = size.toUInt( &ok ); |
260 | 259 | ||
261 | if ( !ok ) | 260 | if ( !ok ) |
262 | return; | 261 | return; |
263 | 262 | ||
264 | // Shamelessly stolen from the sysinfo application (Werner) | 263 | // Shamelessly stolen from the sysinfo application (Werner) |
265 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 264 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
266 | struct statfs fs; | 265 | struct statfs fs; |
267 | if ( statfs( path.latin1(), &fs ) == 0 ) | 266 | if ( statfs( path.latin1(), &fs ) == 0 ) |
268 | if ( s > fs.f_bsize * fs.f_bavail ) { | 267 | if ( s > fs.f_bsize * fs.f_bavail ) { |
269 | //odebug << "############### Not enough space left ###############" << oendl; | 268 | //odebug << "############### Not enough space left ###############" << oendl; |
270 | mNoSpaceLeft = TRUE; | 269 | mNoSpaceLeft = TRUE; |
271 | } | 270 | } |
272 | #endif | 271 | #endif |
273 | } | 272 | } |
274 | 273 | ||
275 | void PackageHandler::iProcessExited() | 274 | void PackageHandler::iProcessExited() |
276 | { | 275 | { |
277 | if ( currentProcess->normalExit() && currentProcess->exitStatus() == 0 ) | 276 | if ( currentProcess->normalExit() && currentProcess->exitStatus() == 0 ) |
278 | sendReply( "installDone(QString)", currentPackage ); | 277 | sendReply( "installDone(QString)", currentPackage ); |
279 | else { | 278 | else { |
280 | #ifndef QT_NO_COP | 279 | #ifndef QT_NO_COP |
281 | QCopEnvelope e( "QPE/Desktop", "installFailed(QString,int,QString)" ); | 280 | QCopEnvelope e( "QPE/Desktop", "installFailed(QString,int,QString)" ); |
282 | e << currentPackage << currentProcess->exitStatus() | 281 | e << currentPackage << currentProcess->exitStatus() |
283 | << currentProcessError; | 282 | << currentProcessError; |
284 | #endif | 283 | #endif |
285 | } | 284 | } |
286 | 285 | ||
287 | delete currentProcess; | 286 | delete currentProcess; |
288 | currentProcess = 0; | 287 | currentProcess = 0; |
289 | 288 | ||
290 | #ifndef QT_NO_COP | 289 | #ifndef QT_NO_COP |
291 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 290 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
292 | QString lf = QString::null; | 291 | QString lf = QString::null; |
293 | e << lf; | 292 | e << lf; |
294 | #endif | 293 | #endif |
295 | unlink( currentPackage ); | 294 | unlink( currentPackage ); |
296 | } | 295 | } |
297 | 296 | ||
298 | void PackageHandler::rmProcessExited() | 297 | void PackageHandler::rmProcessExited() |
299 | { | 298 | { |
300 | if ( currentProcess->normalExit() && currentProcess->exitStatus() == 0 ) | 299 | if ( currentProcess->normalExit() && currentProcess->exitStatus() == 0 ) |
301 | sendReply( "removeDone(QString)", currentPackage ); | 300 | sendReply( "removeDone(QString)", currentPackage ); |
302 | else | 301 | else |
303 | sendReply( "removeFailed(QString)", currentPackage ); | 302 | sendReply( "removeFailed(QString)", currentPackage ); |
304 | 303 | ||
305 | #ifndef QT_NO_COP | 304 | #ifndef QT_NO_COP |
306 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 305 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
307 | QString lf = QString::null; | 306 | QString lf = QString::null; |
308 | e << lf; | 307 | e << lf; |
309 | #endif | 308 | #endif |
310 | } | 309 | } |
311 | 310 | ||
312 | void PackageHandler::readyReadStdout() | 311 | void PackageHandler::readyReadStdout() |
313 | { | 312 | { |
314 | while ( currentProcess->canReadLineStdout() ) { | 313 | while ( currentProcess->canReadLineStdout() ) { |
315 | QString line = currentProcess->readLineStdout(); | 314 | QString line = currentProcess->readLineStdout(); |
316 | currentProcessError.append("OUT:"+line); | 315 | currentProcessError.append("OUT:"+line); |
317 | if ( line.contains( "Unpacking" ) ) // No tr | 316 | if ( line.contains( "Unpacking" ) ) // No tr |
318 | sendReply( "installStep(QString)", "one" ); // No tr | 317 | sendReply( "installStep(QString)", "one" ); // No tr |
319 | else if ( line.contains( "Configuring" ) ) // No tr | 318 | else if ( line.contains( "Configuring" ) ) // No tr |
320 | sendReply( "installStep(QString)", "two" ); // No tr | 319 | sendReply( "installStep(QString)", "two" ); // No tr |
321 | } | 320 | } |
322 | } | 321 | } |
323 | 322 | ||
324 | void PackageHandler::readyReadStderr() | 323 | void PackageHandler::readyReadStderr() |
325 | { | 324 | { |
326 | while ( currentProcess->canReadLineStderr() ) { | 325 | while ( currentProcess->canReadLineStderr() ) { |
327 | QString line = currentProcess->readLineStderr(); | 326 | QString line = currentProcess->readLineStderr(); |
328 | currentProcessError.append("ERR:"+line); | 327 | currentProcessError.append("ERR:"+line); |
329 | } | 328 | } |
330 | } | 329 | } |
331 | 330 | ||
332 | void PackageHandler::redoPackages() | 331 | void PackageHandler::redoPackages() |
333 | { | 332 | { |
334 | //get list of filesystems | 333 | //get list of filesystems |
335 | 334 | ||
336 | //call cleanupPackages for the ones that have disappeared | 335 | //call cleanupPackages for the ones that have disappeared |
337 | 336 | ||
338 | //call addPackageFiles for the new ones | 337 | //call addPackageFiles for the new ones |
339 | } | 338 | } |
diff --git a/core/launcher/transferserver.cpp b/core/launcher/transferserver.cpp index c3f936e..1d4ca40 100644 --- a/core/launcher/transferserver.cpp +++ b/core/launcher/transferserver.cpp | |||
@@ -1135,50 +1135,49 @@ void ServerDTP::connected() | |||
1135 | //make sure it doesn't hang on empty files | 1135 | //make sure it doesn't hang on empty files |
1136 | file.close(); | 1136 | file.close(); |
1137 | emit completed(); | 1137 | emit completed(); |
1138 | mode = Idle; | 1138 | mode = Idle; |
1139 | } else { | 1139 | } else { |
1140 | // Don't write more if there is plenty buffered already. | 1140 | // Don't write more if there is plenty buffered already. |
1141 | if ( bytesToWrite() <= block_size && !file.atEnd() ) { | 1141 | if ( bytesToWrite() <= block_size && !file.atEnd() ) { |
1142 | QCString s; | 1142 | QCString s; |
1143 | s.resize( block_size ); | 1143 | s.resize( block_size ); |
1144 | int bytes = file.readBlock( s.data(), block_size ); | 1144 | int bytes = file.readBlock( s.data(), block_size ); |
1145 | writeBlock( s.data(), bytes ); | 1145 | writeBlock( s.data(), bytes ); |
1146 | } | 1146 | } |
1147 | } | 1147 | } |
1148 | break; | 1148 | break; |
1149 | case SendGzipFile: | 1149 | case SendGzipFile: |
1150 | if ( createTargzProc->isRunning() ) { | 1150 | if ( createTargzProc->isRunning() ) { |
1151 | // SHOULDN'T GET HERE, BUT DOING A SAFETY CHECK ANYWAY | 1151 | // SHOULDN'T GET HERE, BUT DOING A SAFETY CHECK ANYWAY |
1152 | owarn << "Previous tar --gzip process is still running; killing it..." << oendl; | 1152 | owarn << "Previous tar --gzip process is still running; killing it..." << oendl; |
1153 | createTargzProc->kill(); | 1153 | createTargzProc->kill(); |
1154 | } | 1154 | } |
1155 | 1155 | ||
1156 | bytes_written = 0; | 1156 | bytes_written = 0; |
1157 | odebug << "==>start send tar process" << oendl; | 1157 | odebug << "==>start send tar process" << oendl; |
1158 | if ( !createTargzProc->start() ) | 1158 | if ( !createTargzProc->start() ) |
1159 | qWarning("Error starting %s", | 1159 | owarn << "Error starting " << createTargzProc->arguments().join(" ").latin1() << oendl; |
1160 | createTargzProc->arguments().join(" ").latin1()); | ||
1161 | break; | 1160 | break; |
1162 | case SendBuffer: | 1161 | case SendBuffer: |
1163 | if ( !buf.open( IO_ReadOnly) ) { | 1162 | if ( !buf.open( IO_ReadOnly) ) { |
1164 | emit failed(); | 1163 | emit failed(); |
1165 | mode = Idle; | 1164 | mode = Idle; |
1166 | return; | 1165 | return; |
1167 | } | 1166 | } |
1168 | 1167 | ||
1169 | // odebug << "Debug: Sending byte array" << oendl; | 1168 | // odebug << "Debug: Sending byte array" << oendl; |
1170 | bytes_written = 0; | 1169 | bytes_written = 0; |
1171 | while( !buf.atEnd() ) | 1170 | while( !buf.atEnd() ) |
1172 | putch( buf.getch() ); | 1171 | putch( buf.getch() ); |
1173 | buf.close(); | 1172 | buf.close(); |
1174 | break; | 1173 | break; |
1175 | case RetrieveFile: | 1174 | case RetrieveFile: |
1176 | // retrieve file mode | 1175 | // retrieve file mode |
1177 | if ( file.exists() && !file.remove() ) { | 1176 | if ( file.exists() && !file.remove() ) { |
1178 | emit failed(); | 1177 | emit failed(); |
1179 | mode = Idle; | 1178 | mode = Idle; |
1180 | return; | 1179 | return; |
1181 | } | 1180 | } |
1182 | 1181 | ||
1183 | if ( !file.open( IO_WriteOnly) ) { | 1182 | if ( !file.open( IO_WriteOnly) ) { |
1184 | emit failed(); | 1183 | emit failed(); |
diff --git a/core/obex/obex.cc b/core/obex/obex.cc index 3c99af6..7c40b90 100644 --- a/core/obex/obex.cc +++ b/core/obex/obex.cc | |||
@@ -1,200 +1,205 @@ | |||
1 | 1 | ||
2 | #include "obex.h" | ||
3 | |||
4 | /* OPIE */ | ||
5 | #include <opie2/oprocess.h> | ||
6 | #include <opie2/odebug.h> | ||
7 | |||
8 | /* QT */ | ||
2 | #include <qfileinfo.h> | 9 | #include <qfileinfo.h> |
3 | 10 | ||
4 | 11 | ||
5 | #include <opie2/oprocess.h> | ||
6 | #include "obex.h" | ||
7 | 12 | ||
8 | using namespace OpieObex; | 13 | using namespace OpieObex; |
9 | 14 | ||
10 | using namespace Opie::Core; | 15 | using namespace Opie::Core; |
11 | /* TRANSLATOR OpieObex::Obex */ | 16 | /* TRANSLATOR OpieObex::Obex */ |
12 | 17 | ||
13 | Obex::Obex( QObject *parent, const char* name ) | 18 | Obex::Obex( QObject *parent, const char* name ) |
14 | : QObject(parent, name ) | 19 | : QObject(parent, name ) |
15 | { | 20 | { |
16 | m_rec = 0; | 21 | m_rec = 0; |
17 | m_send=0; | 22 | m_send=0; |
18 | m_count = 0; | 23 | m_count = 0; |
19 | m_receive = false; | 24 | m_receive = false; |
20 | connect( this, SIGNAL(error(int) ), // for recovering to receive | 25 | connect( this, SIGNAL(error(int) ), // for recovering to receive |
21 | SLOT(slotError() ) ); | 26 | SLOT(slotError() ) ); |
22 | connect( this, SIGNAL(sent(bool) ), | 27 | connect( this, SIGNAL(sent(bool) ), |
23 | SLOT(slotError() ) ); | 28 | SLOT(slotError() ) ); |
24 | }; | 29 | }; |
25 | Obex::~Obex() { | 30 | Obex::~Obex() { |
26 | delete m_rec; | 31 | delete m_rec; |
27 | delete m_send; | 32 | delete m_send; |
28 | } | 33 | } |
29 | void Obex::receive() { | 34 | void Obex::receive() { |
30 | m_receive = true; | 35 | m_receive = true; |
31 | m_outp = QString::null; | 36 | m_outp = QString::null; |
32 | qWarning("Receive" ); | 37 | owarn << "Receive" << oendl; |
33 | m_rec = new OProcess(); | 38 | m_rec = new OProcess(); |
34 | *m_rec << "irobex_palm3"; | 39 | *m_rec << "irobex_palm3"; |
35 | // connect to the necessary slots | 40 | // connect to the necessary slots |
36 | connect(m_rec, SIGNAL(processExited(Opie::Core::OProcess*) ), | 41 | connect(m_rec, SIGNAL(processExited(Opie::Core::OProcess*) ), |
37 | this, SLOT(slotExited(Opie::Core::OProcess*) ) ); | 42 | this, SLOT(slotExited(Opie::Core::OProcess*) ) ); |
38 | 43 | ||
39 | connect(m_rec, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ), | 44 | connect(m_rec, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ), |
40 | this, SLOT(slotStdOut(Opie::Core::OProcess*, char*, int) ) ); | 45 | this, SLOT(slotStdOut(Opie::Core::OProcess*, char*, int) ) ); |
41 | 46 | ||
42 | if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { | 47 | if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { |
43 | qWarning("could not start :("); | 48 | owarn << "could not start :(" oendl; |
44 | emit done( false ); | 49 | emit done( false ); |
45 | delete m_rec; | 50 | delete m_rec; |
46 | m_rec = 0; | 51 | m_rec = 0; |
47 | } | 52 | } |
48 | // emit currentTry(m_count ); | 53 | // emit currentTry(m_count ); |
49 | 54 | ||
50 | } | 55 | } |
51 | void Obex::send( const QString& fileName) { // if currently receiving stop it send receive | 56 | void Obex::send( const QString& fileName) { // if currently receiving stop it send receive |
52 | m_count = 0; | 57 | m_count = 0; |
53 | m_file = fileName; | 58 | m_file = fileName; |
54 | qWarning("send %s", fileName.latin1() ); | 59 | owarn << "send " << fileName.latin1() << oendl; |
55 | if (m_rec != 0 ) { | 60 | if (m_rec != 0 ) { |
56 | qWarning("running"); | 61 | owarn << "running" oendl; |
57 | if (m_rec->isRunning() ) { | 62 | if (m_rec->isRunning() ) { |
58 | emit error(-1 ); | 63 | emit error(-1 ); |
59 | qWarning("is running"); | 64 | owarn << "is running" << oendl; |
60 | delete m_rec; | 65 | delete m_rec; |
61 | m_rec = 0; | 66 | m_rec = 0; |
62 | 67 | ||
63 | }else{ | 68 | }else{ |
64 | qWarning("is not running"); | 69 | owarn << "is not running" << oendl; |
65 | emit error( -1 ); // we did not delete yet but it's not running slotExited is pending | 70 | emit error( -1 ); // we did not delete yet but it's not running slotExited is pending |
66 | return; | 71 | return; |
67 | } | 72 | } |
68 | } | 73 | } |
69 | sendNow(); | 74 | sendNow(); |
70 | } | 75 | } |
71 | void Obex::sendNow(){ | 76 | void Obex::sendNow(){ |
72 | qWarning("sendNow"); | 77 | owarn << "sendNow" << oendl; |
73 | if ( m_count >= 25 ) { // could not send | 78 | if ( m_count >= 25 ) { // could not send |
74 | emit error(-1 ); | 79 | emit error(-1 ); |
75 | emit sent(false); | 80 | emit sent(false); |
76 | return; | 81 | return; |
77 | } | 82 | } |
78 | // OProcess inititialisation | 83 | // OProcess inititialisation |
79 | m_send = new OProcess(); | 84 | m_send = new OProcess(); |
80 | *m_send << "irobex_palm3"; | 85 | *m_send << "irobex_palm3"; |
81 | *m_send << QFile::encodeName(m_file); | 86 | *m_send << QFile::encodeName(m_file); |
82 | 87 | ||
83 | // connect to slots Exited and and StdOut | 88 | // connect to slots Exited and and StdOut |
84 | connect(m_send, SIGNAL(processExited(Opie::Core::OProcess*) ), | 89 | connect(m_send, SIGNAL(processExited(Opie::Core::OProcess*) ), |
85 | this, SLOT(slotExited(Opie::Core::OProcess*)) ); | 90 | this, SLOT(slotExited(Opie::Core::OProcess*)) ); |
86 | connect(m_send, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int )), | 91 | connect(m_send, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int )), |
87 | this, SLOT(slotStdOut(Opie::Core::OProcess*, char*, int) ) ); | 92 | this, SLOT(slotStdOut(Opie::Core::OProcess*, char*, int) ) ); |
88 | 93 | ||
89 | // now start it | 94 | // now start it |
90 | if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) { | 95 | if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) { |
91 | qWarning("could not send" ); | 96 | owarn << "could not send" << oendl; |
92 | m_count = 25; | 97 | m_count = 25; |
93 | emit error(-1 ); | 98 | emit error(-1 ); |
94 | delete m_send; | 99 | delete m_send; |
95 | m_send=0; | 100 | m_send=0; |
96 | } | 101 | } |
97 | // end | 102 | // end |
98 | m_count++; | 103 | m_count++; |
99 | emit currentTry( m_count ); | 104 | emit currentTry( m_count ); |
100 | } | 105 | } |
101 | 106 | ||
102 | void Obex::slotExited(OProcess* proc ){ | 107 | void Obex::slotExited(OProcess* proc ){ |
103 | if (proc == m_rec ) { // receive process | 108 | if (proc == m_rec ) { // receive process |
104 | received(); | 109 | received(); |
105 | }else if ( proc == m_send ) { | 110 | }else if ( proc == m_send ) { |
106 | sendEnd(); | 111 | sendEnd(); |
107 | } | 112 | } |
108 | } | 113 | } |
109 | void Obex::slotStdOut(OProcess* proc, char* buf, int len){ | 114 | void Obex::slotStdOut(OProcess* proc, char* buf, int len){ |
110 | if ( proc == m_rec ) { // only receive | 115 | if ( proc == m_rec ) { // only receive |
111 | QByteArray ar( len ); | 116 | QByteArray ar( len ); |
112 | memcpy( ar.data(), buf, len ); | 117 | memcpy( ar.data(), buf, len ); |
113 | qWarning("parsed: %s", ar.data() ); | 118 | owarn << "parsed: " << ar.data() << oendl; |
114 | m_outp.append( ar ); | 119 | m_outp.append( ar ); |
115 | } | 120 | } |
116 | } | 121 | } |
117 | 122 | ||
118 | void Obex::received() { | 123 | void Obex::received() { |
119 | if (m_rec->normalExit() ) { | 124 | if (m_rec->normalExit() ) { |
120 | if ( m_rec->exitStatus() == 0 ) { // we got one | 125 | if ( m_rec->exitStatus() == 0 ) { // we got one |
121 | QString filename = parseOut(); | 126 | QString filename = parseOut(); |
122 | qWarning("ACHTUNG %s", filename.latin1() ); | 127 | owarn << "ACHTUNG " << filename.latin1() << oendl; |
123 | emit receivedFile( filename ); | 128 | emit receivedFile( filename ); |
124 | } | 129 | } |
125 | }else{ | 130 | }else{ |
126 | emit done(false); | 131 | emit done(false); |
127 | }; | 132 | }; |
128 | delete m_rec; | 133 | delete m_rec; |
129 | m_rec = 0; | 134 | m_rec = 0; |
130 | receive(); | 135 | receive(); |
131 | } | 136 | } |
132 | 137 | ||
133 | void Obex::sendEnd() { | 138 | void Obex::sendEnd() { |
134 | if (m_send->normalExit() ) { | 139 | if (m_send->normalExit() ) { |
135 | if ( m_send->exitStatus() == 0 ) { | 140 | if ( m_send->exitStatus() == 0 ) { |
136 | delete m_send; | 141 | delete m_send; |
137 | m_send=0; | 142 | m_send=0; |
138 | qWarning("done" ); | 143 | owarn << "done" << oendl; |
139 | emit sent(true); | 144 | emit sent(true); |
140 | }else if (m_send->exitStatus() == 255 ) { // it failed maybe the other side wasn't ready | 145 | }else if (m_send->exitStatus() == 255 ) { // it failed maybe the other side wasn't ready |
141 | // let's try it again | 146 | // let's try it again |
142 | delete m_send; | 147 | delete m_send; |
143 | m_send = 0; | 148 | m_send = 0; |
144 | qWarning("try sending again" ); | 149 | owarn << "try sending again" << oendl; |
145 | sendNow(); | 150 | sendNow(); |
146 | } | 151 | } |
147 | }else { | 152 | }else { |
148 | emit error( -1 ); | 153 | emit error( -1 ); |
149 | delete m_send; | 154 | delete m_send; |
150 | m_send = 0; | 155 | m_send = 0; |
151 | } | 156 | } |
152 | } | 157 | } |
153 | QString Obex::parseOut( ){ | 158 | QString Obex::parseOut( ){ |
154 | QString path; | 159 | QString path; |
155 | QStringList list = QStringList::split("\n", m_outp); | 160 | QStringList list = QStringList::split("\n", m_outp); |
156 | QStringList::Iterator it; | 161 | QStringList::Iterator it; |
157 | for (it = list.begin(); it != list.end(); ++it ) { | 162 | for (it = list.begin(); it != list.end(); ++it ) { |
158 | if ( (*it).startsWith("Wrote" ) ) { | 163 | if ( (*it).startsWith("Wrote" ) ) { |
159 | int pos = (*it).findRev('(' ); | 164 | int pos = (*it).findRev('(' ); |
160 | if ( pos > 0 ) { | 165 | if ( pos > 0 ) { |
161 | qWarning( "%d %s", pos, (*it).mid(6 ).latin1() ) ; | 166 | owarn << pos << " " << (*it).mid(6 ).latin1() << oendl; |
162 | qWarning("%d %d", (*it).length(), (*it).length()-pos ); | 167 | owarn << (*it).length() << " " << (*it).length()-pos << oendl; |
163 | 168 | ||
164 | path = (*it).remove( pos, (*it).length() - pos ); | 169 | path = (*it).remove( pos, (*it).length() - pos ); |
165 | qWarning("%s", path.latin1() ); | 170 | owarn << path.latin1() << oendl; |
166 | path = path.mid(6 ); | 171 | path = path.mid(6 ); |
167 | path = path.stripWhiteSpace(); | 172 | path = path.stripWhiteSpace(); |
168 | qWarning("path %s", path.latin1() ); | 173 | owarn << "path " << path.latin1() << oendl; |
169 | } | 174 | } |
170 | } | 175 | } |
171 | } | 176 | } |
172 | return path; | 177 | return path; |
173 | } | 178 | } |
174 | /** | 179 | /** |
175 | * when sent is done slotError is called we will start receive again | 180 | * when sent is done slotError is called we will start receive again |
176 | */ | 181 | */ |
177 | void Obex::slotError() { | 182 | void Obex::slotError() { |
178 | qWarning("slotError"); | 183 | owarn << "slotError" << oendl; |
179 | if ( m_receive ) | 184 | if ( m_receive ) |
180 | receive(); | 185 | receive(); |
181 | }; | 186 | }; |
182 | void Obex::setReceiveEnabled( bool receive ) { | 187 | void Obex::setReceiveEnabled( bool receive ) { |
183 | if ( !receive ) { // | 188 | if ( !receive ) { // |
184 | m_receive = false; | 189 | m_receive = false; |
185 | shutDownReceive(); | 190 | shutDownReceive(); |
186 | } | 191 | } |
187 | } | 192 | } |
188 | 193 | ||
189 | void Obex::shutDownReceive() { | 194 | void Obex::shutDownReceive() { |
190 | if (m_rec != 0 ) { | 195 | if (m_rec != 0 ) { |
191 | qWarning("running"); | 196 | owarn << "running" << oendl; |
192 | if (m_rec->isRunning() ) { | 197 | if (m_rec->isRunning() ) { |
193 | emit error(-1 ); | 198 | emit error(-1 ); |
194 | qWarning("is running"); | 199 | owarn << "is running" << oendl; |
195 | delete m_rec; | 200 | delete m_rec; |
196 | m_rec = 0; | 201 | m_rec = 0; |
197 | } | 202 | } |
198 | } | 203 | } |
199 | 204 | ||
200 | } | 205 | } |
diff --git a/core/opie-login/loginapplication.cpp b/core/opie-login/loginapplication.cpp index 1facf2d..764b24b 100644 --- a/core/opie-login/loginapplication.cpp +++ b/core/opie-login/loginapplication.cpp | |||
@@ -4,278 +4,285 @@ | |||
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This file is free software; you can | 5 | _;:, .> :=|. This file is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This file is distributed in the hope that | 12 | .i_,=:_. -<s. This file is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
17 | ..}^=.= = ; Public License for more details. | 17 | ..}^=.= = ; Public License for more details. |
18 | ++= -. .` .: | 18 | ++= -. .` .: |
19 | : = ...= . :.=- You should have received a copy of the GNU | 19 | : = ...= . :.=- You should have received a copy of the GNU |
20 | -. .:....=;==+<; General Public License along with this file; | 20 | -. .:....=;==+<; General Public License along with this file; |
21 | -_. . . )=. = see the file COPYING. If not, write to the | 21 | -_. . . )=. = see the file COPYING. If not, write to the |
22 | -- :-=` Free Software Foundation, Inc., | 22 | -- :-=` Free Software Foundation, Inc., |
23 | 59 Temple Place - Suite 330, | 23 | 59 Temple Place - Suite 330, |
24 | Boston, MA 02111-1307, USA. | 24 | Boston, MA 02111-1307, USA. |
25 | 25 | ||
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include "loginapplication.h" | ||
29 | |||
30 | /* OPIE */ | ||
31 | #include <opie2/odebug.h> | ||
32 | |||
33 | /* QT */ | ||
34 | |||
35 | /* STD */ | ||
28 | #include <pwd.h> | 36 | #include <pwd.h> |
29 | #include <grp.h> | 37 | #include <grp.h> |
30 | #include <unistd.h> | 38 | #include <unistd.h> |
31 | #include <stdlib.h> | 39 | #include <stdlib.h> |
32 | #include <signal.h> | 40 | #include <signal.h> |
33 | #include <sys/stat.h> | 41 | #include <sys/stat.h> |
34 | #include <sys/wait.h> | 42 | #include <sys/wait.h> |
35 | 43 | ||
36 | #ifdef USEPAM | 44 | #ifdef USEPAM |
37 | extern "C" { | 45 | extern "C" { |
38 | #include <security/pam_appl.h> | 46 | #include <security/pam_appl.h> |
39 | } | 47 | } |
40 | #else | 48 | #else |
41 | #include <crypt.h> | 49 | #include <crypt.h> |
42 | #include <shadow.h> | 50 | #include <shadow.h> |
43 | #endif | 51 | #endif |
44 | 52 | ||
45 | #include "loginapplication.h" | ||
46 | 53 | ||
47 | LoginApplication *lApp; | 54 | LoginApplication *lApp; |
48 | 55 | ||
49 | LoginApplication::LoginApplication ( int &argc, char **argv, pid_t parentpid ) | 56 | LoginApplication::LoginApplication ( int &argc, char **argv, pid_t parentpid ) |
50 | : QPEApplication ( argc, argv, GuiServer ) | 57 | : QPEApplication ( argc, argv, GuiServer ) |
51 | { | 58 | { |
52 | lApp = this; | 59 | lApp = this; |
53 | m_parentpid = parentpid; | 60 | m_parentpid = parentpid; |
54 | } | 61 | } |
55 | 62 | ||
56 | const char *LoginApplication::s_username = 0; | 63 | const char *LoginApplication::s_username = 0; |
57 | 64 | ||
58 | #ifdef USEPAM | 65 | #ifdef USEPAM |
59 | 66 | ||
60 | const char *LoginApplication::s_pam_password = 0; | 67 | const char *LoginApplication::s_pam_password = 0; |
61 | 68 | ||
62 | int LoginApplication::pam_helper ( int num_msg, const struct pam_message **msg, struct pam_response **resp, void * ) | 69 | int LoginApplication::pam_helper ( int num_msg, const struct pam_message **msg, struct pam_response **resp, void * ) |
63 | { | 70 | { |
64 | int replies = 0; | 71 | int replies = 0; |
65 | struct pam_response *reply = 0; | 72 | struct pam_response *reply = 0; |
66 | int size = sizeof( struct pam_response ); | 73 | int size = sizeof( struct pam_response ); |
67 | 74 | ||
68 | for ( int i = 0; i < num_msg; i++ ) { | 75 | for ( int i = 0; i < num_msg; i++ ) { |
69 | switch ( msg [i]-> msg_style ) { | 76 | switch ( msg [i]-> msg_style ) { |
70 | case PAM_PROMPT_ECHO_ON: // user name given to PAM already | 77 | case PAM_PROMPT_ECHO_ON: // user name given to PAM already |
71 | return PAM_CONV_ERR; | 78 | return PAM_CONV_ERR; |
72 | 79 | ||
73 | case PAM_PROMPT_ECHO_OFF: // wants password | 80 | case PAM_PROMPT_ECHO_OFF: // wants password |
74 | reply = (struct pam_response *) ::realloc ( reply, size ); | 81 | reply = (struct pam_response *) ::realloc ( reply, size ); |
75 | if ( !reply ) | 82 | if ( !reply ) |
76 | return PAM_CONV_ERR; | 83 | return PAM_CONV_ERR; |
77 | size += sizeof( struct pam_response ); | 84 | size += sizeof( struct pam_response ); |
78 | 85 | ||
79 | reply [replies]. resp_retcode = PAM_SUCCESS; | 86 | reply [replies]. resp_retcode = PAM_SUCCESS; |
80 | reply [replies]. resp = ::strdup ( s_pam_password ); | 87 | reply [replies]. resp = ::strdup ( s_pam_password ); |
81 | replies++; // PAM frees resp | 88 | replies++; // PAM frees resp |
82 | break; | 89 | break; |
83 | 90 | ||
84 | case PAM_TEXT_INFO: | 91 | case PAM_TEXT_INFO: |
85 | break; | 92 | break; |
86 | 93 | ||
87 | default: | 94 | default: |
88 | /* unknown or PAM_ERROR_MSG */ | 95 | /* unknown or PAM_ERROR_MSG */ |
89 | if ( reply ) | 96 | if ( reply ) |
90 | ::free ( reply ); | 97 | ::free ( reply ); |
91 | return PAM_CONV_ERR; | 98 | return PAM_CONV_ERR; |
92 | } | 99 | } |
93 | } | 100 | } |
94 | if ( reply ) | 101 | if ( reply ) |
95 | *resp = reply; | 102 | *resp = reply; |
96 | return PAM_SUCCESS; | 103 | return PAM_SUCCESS; |
97 | } | 104 | } |
98 | 105 | ||
99 | 106 | ||
100 | bool LoginApplication::checkPassword ( const char *user, const char *pass ) | 107 | bool LoginApplication::checkPassword ( const char *user, const char *pass ) |
101 | { | 108 | { |
102 | static struct pam_conv conv = { &LoginApplication::pam_helper, 0 }; | 109 | static struct pam_conv conv = { &LoginApplication::pam_helper, 0 }; |
103 | 110 | ||
104 | int pam_error; | 111 | int pam_error; |
105 | pam_handle_t *pamh = 0; | 112 | pam_handle_t *pamh = 0; |
106 | 113 | ||
107 | pam_error = ::pam_start( "xdm", user, &conv, &pamh ); | 114 | pam_error = ::pam_start( "xdm", user, &conv, &pamh ); |
108 | if ( pam_error == PAM_SUCCESS ) { | 115 | if ( pam_error == PAM_SUCCESS ) { |
109 | s_pam_password = pass; | 116 | s_pam_password = pass; |
110 | pam_error = ::pam_authenticate ( pamh, 0 ); | 117 | pam_error = ::pam_authenticate ( pamh, 0 ); |
111 | s_pam_password = 0; | 118 | s_pam_password = 0; |
112 | } | 119 | } |
113 | ::pam_end ( pamh, pam_error ); | 120 | ::pam_end ( pamh, pam_error ); |
114 | return ( pam_error == PAM_SUCCESS ); | 121 | return ( pam_error == PAM_SUCCESS ); |
115 | } | 122 | } |
116 | 123 | ||
117 | #else | 124 | #else |
118 | 125 | ||
119 | bool LoginApplication::checkPassword ( const char *user, const char *pass ) | 126 | bool LoginApplication::checkPassword ( const char *user, const char *pass ) |
120 | { | 127 | { |
121 | char *encrypted, *correct; | 128 | char *encrypted, *correct; |
122 | struct passwd *pw; | 129 | struct passwd *pw; |
123 | 130 | ||
124 | if ( !user || !pass ) | 131 | if ( !user || !pass ) |
125 | return false; | 132 | return false; |
126 | 133 | ||
127 | pw = ::getpwnam ( user ); | 134 | pw = ::getpwnam ( user ); |
128 | 135 | ||
129 | if ( !pw ) | 136 | if ( !pw ) |
130 | return false; | 137 | return false; |
131 | 138 | ||
132 | if (( ::strcmp ( pw-> pw_passwd, "x" ) == 0 ) || ( ::strcmp ( pw-> pw_passwd, "*" ) == 0 )) { | 139 | if (( ::strcmp ( pw-> pw_passwd, "x" ) == 0 ) || ( ::strcmp ( pw-> pw_passwd, "*" ) == 0 )) { |
133 | struct spwd *sp = ::getspnam ( pw-> pw_name ); | 140 | struct spwd *sp = ::getspnam ( pw-> pw_name ); |
134 | 141 | ||
135 | if ( !sp ) | 142 | if ( !sp ) |
136 | return false; | 143 | return false; |
137 | 144 | ||
138 | correct = sp-> sp_pwdp; | 145 | correct = sp-> sp_pwdp; |
139 | } | 146 | } |
140 | else | 147 | else |
141 | correct = pw-> pw_passwd; | 148 | correct = pw-> pw_passwd; |
142 | 149 | ||
143 | if ( correct == 0 || correct[0] == '\0' ) | 150 | if ( correct == 0 || correct[0] == '\0' ) |
144 | return true; | 151 | return true; |
145 | 152 | ||
146 | encrypted = ::crypt ( pass, correct ); | 153 | encrypted = ::crypt ( pass, correct ); |
147 | return ( ::strcmp ( encrypted, correct ) == 0 ); | 154 | return ( ::strcmp ( encrypted, correct ) == 0 ); |
148 | } | 155 | } |
149 | 156 | ||
150 | #endif | 157 | #endif |
151 | 158 | ||
152 | bool LoginApplication::changeIdentity ( ) | 159 | bool LoginApplication::changeIdentity ( ) |
153 | { | 160 | { |
154 | const char *DEFAULT_LOGIN_PATH = "/bin:/usr/bin"; | 161 | const char *DEFAULT_LOGIN_PATH = "/bin:/usr/bin"; |
155 | const char *DEFAULT_ROOT_LOGIN_PATH = "/usr/sbin:/bin:/usr/bin:/sbin"; | 162 | const char *DEFAULT_ROOT_LOGIN_PATH = "/usr/sbin:/bin:/usr/bin:/sbin"; |
156 | 163 | ||
157 | if ( !s_username ) | 164 | if ( !s_username ) |
158 | return false; | 165 | return false; |
159 | struct passwd *pw = ::getpwnam ( s_username ); | 166 | struct passwd *pw = ::getpwnam ( s_username ); |
160 | if ( !pw ) | 167 | if ( !pw ) |
161 | return false; | 168 | return false; |
162 | 169 | ||
163 | // we are still root at this point - try to run the pre-session script | 170 | // we are still root at this point - try to run the pre-session script |
164 | if ( !runRootScript ( "OPIEDIR", "share/opie-login/pre-session", s_username )) | 171 | if ( !runRootScript ( "OPIEDIR", "share/opie-login/pre-session", s_username )) |
165 | qWarning ( "failed to run $OPIEDIR/share/opie-login/pre-session" ); | 172 | owarn << "failed to run $OPIEDIR/share/opie-login/pre-session" << oendl; |
166 | 173 | ||
167 | bool fail = false; | 174 | bool fail = false; |
168 | fail |= ( ::initgroups ( pw-> pw_name, pw-> pw_gid )); | 175 | fail |= ( ::initgroups ( pw-> pw_name, pw-> pw_gid )); |
169 | ::endgrent ( ); | 176 | ::endgrent ( ); |
170 | fail |= ( ::setgid ( pw-> pw_gid )); | 177 | fail |= ( ::setgid ( pw-> pw_gid )); |
171 | fail |= ( ::setuid ( pw-> pw_uid )); | 178 | fail |= ( ::setuid ( pw-> pw_uid )); |
172 | 179 | ||
173 | fail |= ( ::chdir ( pw-> pw_dir ) && ::chdir ( "/" )); | 180 | fail |= ( ::chdir ( pw-> pw_dir ) && ::chdir ( "/" )); |
174 | 181 | ||
175 | fail |= ( ::setenv ( "HOME", pw-> pw_dir, 1 )); | 182 | fail |= ( ::setenv ( "HOME", pw-> pw_dir, 1 )); |
176 | fail |= ( ::setenv ( "SHELL", pw-> pw_shell, 1 )); | 183 | fail |= ( ::setenv ( "SHELL", pw-> pw_shell, 1 )); |
177 | fail |= ( ::setenv ( "USER", pw-> pw_name, 1 )); | 184 | fail |= ( ::setenv ( "USER", pw-> pw_name, 1 )); |
178 | fail |= ( ::setenv ( "LOGNAME", pw-> pw_name, 1 )); | 185 | fail |= ( ::setenv ( "LOGNAME", pw-> pw_name, 1 )); |
179 | fail |= ( ::setenv ( "PATH", ( pw-> pw_uid ? DEFAULT_LOGIN_PATH : DEFAULT_ROOT_LOGIN_PATH ), 1 )); | 186 | fail |= ( ::setenv ( "PATH", ( pw-> pw_uid ? DEFAULT_LOGIN_PATH : DEFAULT_ROOT_LOGIN_PATH ), 1 )); |
180 | 187 | ||
181 | return !fail; | 188 | return !fail; |
182 | } | 189 | } |
183 | 190 | ||
184 | bool LoginApplication::login ( ) | 191 | bool LoginApplication::login ( ) |
185 | { | 192 | { |
186 | execUserScript ( "HOME", ".opie-session" ); | 193 | execUserScript ( "HOME", ".opie-session" ); |
187 | execUserScript ( "OPIEDIR", "share/opie-login/opie-session" ); | 194 | execUserScript ( "OPIEDIR", "share/opie-login/opie-session" ); |
188 | execUserScript ( "OPIEDIR", "bin/qpe" ); | 195 | execUserScript ( "OPIEDIR", "bin/qpe" ); |
189 | 196 | ||
190 | qWarning ( "failed to start an Opie session" ); | 197 | owarn << "failed to start an Opie session" << oendl; |
191 | return false; | 198 | return false; |
192 | } | 199 | } |
193 | 200 | ||
194 | void LoginApplication::logout ( ) | 201 | void LoginApplication::logout ( ) |
195 | { | 202 | { |
196 | // we are now root again - try to run the post-session script | 203 | // we are now root again - try to run the post-session script |
197 | if ( !runRootScript ( "OPIEDIR", "share/opie-login/post-session" )) | 204 | if ( !runRootScript ( "OPIEDIR", "share/opie-login/post-session" )) |
198 | qWarning ( "failed to run $OPIEDIR/scripts/post-session" ); | 205 | owarn << "failed to run $OPIEDIR/scripts/post-session" << oendl; |
199 | } | 206 | } |
200 | 207 | ||
201 | 208 | ||
202 | static char *buildarg ( const char *base, const char *script ) | 209 | static char *buildarg ( const char *base, const char *script ) |
203 | { | 210 | { |
204 | const char *dir = base ? ::getenv ( base ) : "/"; | 211 | const char *dir = base ? ::getenv ( base ) : "/"; |
205 | char *arg = new char [::strlen ( dir ) + ::strlen ( script ) + 2]; | 212 | char *arg = new char [::strlen ( dir ) + ::strlen ( script ) + 2]; |
206 | 213 | ||
207 | ::strcpy ( arg, dir ); | 214 | ::strcpy ( arg, dir ); |
208 | ::strcat ( arg, "/" ); | 215 | ::strcat ( arg, "/" ); |
209 | ::strcat ( arg, script ); | 216 | ::strcat ( arg, script ); |
210 | 217 | ||
211 | return arg; | 218 | return arg; |
212 | } | 219 | } |
213 | 220 | ||
214 | bool LoginApplication::runRootScript ( const char *base, const char *script, const char *param ) | 221 | bool LoginApplication::runRootScript ( const char *base, const char *script, const char *param ) |
215 | { | 222 | { |
216 | bool res = false; | 223 | bool res = false; |
217 | char *arg = buildarg ( base, script ); | 224 | char *arg = buildarg ( base, script ); |
218 | 225 | ||
219 | struct stat st; | 226 | struct stat st; |
220 | if (( ::stat ( arg, &st ) == 0 ) && ( st. st_uid == 0 )) { | 227 | if (( ::stat ( arg, &st ) == 0 ) && ( st. st_uid == 0 )) { |
221 | pid_t child = ::fork ( ); | 228 | pid_t child = ::fork ( ); |
222 | 229 | ||
223 | if ( child == 0 ) { | 230 | if ( child == 0 ) { |
224 | ::execl ( "/bin/sh", "-sh", arg, param, 0 ); | 231 | ::execl ( "/bin/sh", "-sh", arg, param, 0 ); |
225 | ::_exit ( -1 ); | 232 | ::_exit ( -1 ); |
226 | } | 233 | } |
227 | else if ( child > 0 ) { | 234 | else if ( child > 0 ) { |
228 | int status = 0; | 235 | int status = 0; |
229 | 236 | ||
230 | while ( ::waitpid ( child, &status, 0 ) < 0 ) { } | 237 | while ( ::waitpid ( child, &status, 0 ) < 0 ) { } |
231 | res = ( WIFEXITED( status )) && ( WEXITSTATUS( status ) == 0 ); | 238 | res = ( WIFEXITED( status )) && ( WEXITSTATUS( status ) == 0 ); |
232 | } | 239 | } |
233 | } | 240 | } |
234 | 241 | ||
235 | delete [] arg; | 242 | delete [] arg; |
236 | return res; | 243 | return res; |
237 | } | 244 | } |
238 | 245 | ||
239 | void LoginApplication::execUserScript ( const char *base, const char *script ) | 246 | void LoginApplication::execUserScript ( const char *base, const char *script ) |
240 | { | 247 | { |
241 | char *arg = buildarg ( base, script ); | 248 | char *arg = buildarg ( base, script ); |
242 | 249 | ||
243 | struct stat st; | 250 | struct stat st; |
244 | if ( ::stat ( arg, &st ) == 0 ) { | 251 | if ( ::stat ( arg, &st ) == 0 ) { |
245 | if ( st. st_mode & S_IXUSR ) | 252 | if ( st. st_mode & S_IXUSR ) |
246 | ::execl ( "/bin/sh", "-sh", "-c", arg, 0 ); | 253 | ::execl ( "/bin/sh", "-sh", "-c", arg, 0 ); |
247 | else | 254 | else |
248 | ::execl ( "/bin/sh", "-sh", arg, 0 ); | 255 | ::execl ( "/bin/sh", "-sh", arg, 0 ); |
249 | } | 256 | } |
250 | } | 257 | } |
251 | 258 | ||
252 | const char *LoginApplication::loginAs ( ) | 259 | const char *LoginApplication::loginAs ( ) |
253 | { | 260 | { |
254 | return s_username; | 261 | return s_username; |
255 | } | 262 | } |
256 | 263 | ||
257 | void LoginApplication::setLoginAs ( const char *name ) | 264 | void LoginApplication::setLoginAs ( const char *name ) |
258 | { | 265 | { |
259 | s_username = name; | 266 | s_username = name; |
260 | } | 267 | } |
261 | 268 | ||
262 | QStringList LoginApplication::allUsers ( ) | 269 | QStringList LoginApplication::allUsers ( ) |
263 | { | 270 | { |
264 | struct passwd *pwd; | 271 | struct passwd *pwd; |
265 | QStringList sl; | 272 | QStringList sl; |
266 | 273 | ||
267 | while (( pwd = ::getpwent ( ))) { | 274 | while (( pwd = ::getpwent ( ))) { |
268 | if (( pwd-> pw_uid == 0 ) || ( pwd-> pw_uid >= 500 && pwd-> pw_uid < 65534 )) | 275 | if (( pwd-> pw_uid == 0 ) || ( pwd-> pw_uid >= 500 && pwd-> pw_uid < 65534 )) |
269 | sl << QString ( pwd-> pw_name ); | 276 | sl << QString ( pwd-> pw_name ); |
270 | } | 277 | } |
271 | 278 | ||
272 | ::endpwent ( ); | 279 | ::endpwent ( ); |
273 | 280 | ||
274 | return sl; | 281 | return sl; |
275 | } | 282 | } |
276 | 283 | ||
277 | void LoginApplication::quitToConsole ( ) | 284 | void LoginApplication::quitToConsole ( ) |
278 | { | 285 | { |
279 | QPEApplication::quit ( ); | 286 | QPEApplication::quit ( ); |
280 | ::kill ( m_parentpid, SIGTERM ); | 287 | ::kill ( m_parentpid, SIGTERM ); |
281 | } | 288 | } |
diff --git a/core/pim/addressbook/namelineedit.cpp b/core/pim/addressbook/namelineedit.cpp index ba16e2c..81b959b 100644 --- a/core/pim/addressbook/namelineedit.cpp +++ b/core/pim/addressbook/namelineedit.cpp | |||
@@ -1,49 +1,53 @@ | |||
1 | #include "namelineedit.h" | 1 | #include "namelineedit.h" |
2 | 2 | ||
3 | /* OPIE */ | ||
4 | #include <opie2/odebug.h> | ||
5 | |||
6 | |||
3 | namespace ABOOK { | 7 | namespace ABOOK { |
4 | NameLineEdit::NameLineEdit( QWidget* parent, const char* name ) | 8 | NameLineEdit::NameLineEdit( QWidget* parent, const char* name ) |
5 | : QLineEdit( parent, name ), m_prevSpace( true ) { | 9 | : QLineEdit( parent, name ), m_prevSpace( true ) { |
6 | } | 10 | } |
7 | 11 | ||
8 | NameLineEdit::NameLineEdit( const QString& str, QWidget* par, | 12 | NameLineEdit::NameLineEdit( const QString& str, QWidget* par, |
9 | const char* name ) | 13 | const char* name ) |
10 | : QLineEdit( str, par, name ),m_prevSpace( true ) { | 14 | : QLineEdit( str, par, name ),m_prevSpace( true ) { |
11 | } | 15 | } |
12 | 16 | ||
13 | NameLineEdit::~NameLineEdit() { | 17 | NameLineEdit::~NameLineEdit() { |
14 | } | 18 | } |
15 | 19 | ||
16 | void NameLineEdit::keyPressEvent( QKeyEvent* ev ) { | 20 | void NameLineEdit::keyPressEvent( QKeyEvent* ev ) { |
17 | QString t = ev->text(); | 21 | QString t = ev->text(); |
18 | int key = ev->key(); | 22 | int key = ev->key(); |
19 | int ascii = ev->ascii(); | 23 | int ascii = ev->ascii(); |
20 | 24 | ||
21 | // ### FIXME with composed events | 25 | // ### FIXME with composed events |
22 | if ( !t.isEmpty() && ( !ev->ascii() || ev->ascii()>=32 ) && | 26 | if ( !t.isEmpty() && ( !ev->ascii() || ev->ascii()>=32 ) && |
23 | key != Key_Delete && key != Key_Backspace && | 27 | key != Key_Delete && key != Key_Backspace && |
24 | key != Key_Return && key != Key_Enter ) { | 28 | key != Key_Return && key != Key_Enter ) { |
25 | qWarning( "str " + ev->text() + " %d", m_prevSpace ); | 29 | owarn << "str " << ev->text() << " " << m_prevSpace << oendl; |
26 | 30 | ||
27 | if ( m_prevSpace ) { | 31 | if ( m_prevSpace ) { |
28 | t = t.upper(); | 32 | t = t.upper(); |
29 | m_prevSpace = false; | 33 | m_prevSpace = false; |
30 | } | 34 | } |
31 | if ( key == Key_Space ) | 35 | if ( key == Key_Space ) |
32 | m_prevSpace = true; | 36 | m_prevSpace = true; |
33 | 37 | ||
34 | 38 | ||
35 | QKeyEvent nEv(ev->type(), key, ascii, ev->state(), | 39 | QKeyEvent nEv(ev->type(), key, ascii, ev->state(), |
36 | t, ev->isAutoRepeat(), ev->count() ); | 40 | t, ev->isAutoRepeat(), ev->count() ); |
37 | QLineEdit::keyPressEvent( &nEv ); | 41 | QLineEdit::keyPressEvent( &nEv ); |
38 | if ( !nEv.isAccepted() ) | 42 | if ( !nEv.isAccepted() ) |
39 | ev->ignore(); | 43 | ev->ignore(); |
40 | }else { | 44 | }else { |
41 | QLineEdit::keyPressEvent( ev ); | 45 | QLineEdit::keyPressEvent( ev ); |
42 | /* if key was a backspace lets see if we should | 46 | /* if key was a backspace lets see if we should |
43 | * capitalize the next letter | 47 | * capitalize the next letter |
44 | */ | 48 | */ |
45 | if ( key == Key_Backspace ) { | 49 | if ( key == Key_Backspace ) { |
46 | QString te = text(); | 50 | QString te = text(); |
47 | /* if string is empty capitalize the first letter */ | 51 | /* if string is empty capitalize the first letter */ |
48 | /* else see if we're at the end of the string */ | 52 | /* else see if we're at the end of the string */ |
49 | if ( te.isEmpty() || cursorPosition() == te.length() ) | 53 | if ( te.isEmpty() || cursorPosition() == te.length() ) |
diff --git a/core/qws/transferserver.cpp b/core/qws/transferserver.cpp index 777c384..7bf6719 100644 --- a/core/qws/transferserver.cpp +++ b/core/qws/transferserver.cpp | |||
@@ -1,47 +1,48 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | /* OPIE */ | 21 | /* OPIE */ |
22 | #include <opie2/odebug.h> | 22 | #include <opie2/odebug.h> |
23 | 23 | ||
24 | /* STD */ | ||
24 | #define _XOPEN_SOURCE | 25 | #define _XOPEN_SOURCE |
25 | #include <pwd.h> | 26 | #include <pwd.h> |
26 | #include <sys/types.h> | 27 | #include <sys/types.h> |
27 | #include <unistd.h> | 28 | #include <unistd.h> |
28 | #include <stdlib.h> | 29 | #include <stdlib.h> |
29 | #include <time.h> | 30 | #include <time.h> |
30 | 31 | ||
31 | #ifndef Q_OS_MACX | 32 | #ifndef Q_OS_MACX |
32 | #include <shadow.h> | 33 | #include <shadow.h> |
33 | #endif /* Q_OS_MACX */ | 34 | #endif /* Q_OS_MACX */ |
34 | 35 | ||
35 | /* we need the _OS_LINUX stuff first ! */ | 36 | /* we need the _OS_LINUX stuff first ! */ |
36 | 37 | ||
37 | #ifndef _OS_LINUX_ | 38 | #ifndef _OS_LINUX_ |
38 | // Is anybody able to review this ? The include "uuid/uuid.h" couldn't be found | 39 | // Is anybody able to review this ? The include "uuid/uuid.h" couldn't be found |
39 | // anywhere ? Therfore I removed it completely.. | 40 | // anywhere ? Therfore I removed it completely.. |
40 | // I think it should be made permanentyl !? (eilers) | 41 | // I think it should be made permanentyl !? (eilers) |
41 | #warning "Where should uuid/uuid.h be found ? Removed this part .. (eilers)" | 42 | #warning "Where should uuid/uuid.h be found ? Removed this part .. (eilers)" |
42 | #if 0 | 43 | #if 0 |
43 | 44 | ||
44 | extern "C" | 45 | extern "C" |
45 | { | 46 | { |
46 | #include <uuid/uuid.h> | 47 | #include <uuid/uuid.h> |
47 | #define UUID_H_INCLUDED | 48 | #define UUID_H_INCLUDED |
@@ -1106,51 +1107,50 @@ void ServerDTP::connected() | |||
1106 | file.close(); | 1107 | file.close(); |
1107 | emit completed(); | 1108 | emit completed(); |
1108 | mode = Idle; | 1109 | mode = Idle; |
1109 | } | 1110 | } |
1110 | else { | 1111 | else { |
1111 | 1112 | ||
1112 | if ( !file.atEnd() ) { | 1113 | if ( !file.atEnd() ) { |
1113 | QCString s; | 1114 | QCString s; |
1114 | s.resize( block_size ); | 1115 | s.resize( block_size ); |
1115 | int bytes = file.readBlock( s.data(), block_size ); | 1116 | int bytes = file.readBlock( s.data(), block_size ); |
1116 | writeBlock( s.data(), bytes ); | 1117 | writeBlock( s.data(), bytes ); |
1117 | } | 1118 | } |
1118 | } | 1119 | } |
1119 | break; | 1120 | break; |
1120 | case SendGzipFile: | 1121 | case SendGzipFile: |
1121 | if ( createTargzProc->isRunning() ) { | 1122 | if ( createTargzProc->isRunning() ) { |
1122 | // SHOULDN'T GET HERE, BUT DOING A SAFETY CHECK ANYWAY | 1123 | // SHOULDN'T GET HERE, BUT DOING A SAFETY CHECK ANYWAY |
1123 | owarn << "Previous tar --gzip process is still running; killing it..." << oendl; | 1124 | owarn << "Previous tar --gzip process is still running; killing it..." << oendl; |
1124 | createTargzProc->kill(); | 1125 | createTargzProc->kill(); |
1125 | } | 1126 | } |
1126 | 1127 | ||
1127 | bytes_written = 0; | 1128 | bytes_written = 0; |
1128 | odebug << "==>start send tar process" << oendl; | 1129 | odebug << "==>start send tar process" << oendl; |
1129 | if ( !createTargzProc->start(Opie::Core::OProcess::NotifyOnExit, Opie::Core::OProcess::Stdout) ) | 1130 | if ( !createTargzProc->start(Opie::Core::OProcess::NotifyOnExit, Opie::Core::OProcess::Stdout) ) |
1130 | qWarning("Error starting %s or %s", | 1131 | owarn << "Error starting " << createTargzProc->args()[0].data() |
1131 | createTargzProc->args()[0].data(), | 1132 | << " or " << gzipProc->args()[0].data() << oendl; |
1132 | gzipProc->args()[0].data()); | ||
1133 | break; | 1133 | break; |
1134 | case SendBuffer: | 1134 | case SendBuffer: |
1135 | if ( !buf.open( IO_ReadOnly) ) { | 1135 | if ( !buf.open( IO_ReadOnly) ) { |
1136 | emit failed(); | 1136 | emit failed(); |
1137 | mode = Idle; | 1137 | mode = Idle; |
1138 | return ; | 1138 | return ; |
1139 | } | 1139 | } |
1140 | 1140 | ||
1141 | // odebug << "Debug: Sending byte array" << oendl; | 1141 | // odebug << "Debug: Sending byte array" << oendl; |
1142 | bytes_written = 0; | 1142 | bytes_written = 0; |
1143 | while ( !buf.atEnd() ) | 1143 | while ( !buf.atEnd() ) |
1144 | putch( buf.getch() ); | 1144 | putch( buf.getch() ); |
1145 | buf.close(); | 1145 | buf.close(); |
1146 | break; | 1146 | break; |
1147 | case RetrieveFile: | 1147 | case RetrieveFile: |
1148 | // retrieve file mode | 1148 | // retrieve file mode |
1149 | if ( file.exists() && !file.remove() ) { | 1149 | if ( file.exists() && !file.remove() ) { |
1150 | emit failed(); | 1150 | emit failed(); |
1151 | mode = Idle; | 1151 | mode = Idle; |
1152 | return ; | 1152 | return ; |
1153 | } | 1153 | } |
1154 | 1154 | ||
1155 | if ( !file.open( IO_WriteOnly) ) { | 1155 | if ( !file.open( IO_WriteOnly) ) { |
1156 | emit failed(); | 1156 | emit failed(); |