#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "app.h" using namespace aptFront; using namespace aptFront::cache; using namespace adept; App::App( TDECmdLineArgs *args ) { setMainWidget( this ); initialize(); TQString qs_pkgname; updating = false; enum { None, Remove, Install } m = None; for(int i = 0; i < args->count(); i++) { TQCString a = args->arg( i ); if (m == None || cache().packages().packageByName( std::string( a ) ).valid()) { if ( m == Install ) { kdDebug() << "installing " << a << endl; cache().packages().packageByName( std::string( a ) ).markInstall(); } else if ( m == Remove ) { kdDebug() << "removing " << a << endl; cache().packages().packageByName( std::string( a ) ).markRemove(); } if ( m == None && a == "install" ) { m = Install; } if ( m == None && a == "remove" ) { m = Remove; } if ( m == None && a == "update" ) { updating = true; } } else { qs_pkgname = a; kdDebug() << "The package '"<(); m_all = new TQVBox( this ); m_stack = new TQWidgetStack( m_all ); m_stack->addWidget( m_progress = new adept::AcqProgressWidget( m_stack ) ); m_stack->addWidget( m_commitProgress = new CommitProgress( m_stack ) ); connect(this, TQT_SIGNAL( imDone() ), this, TQT_SLOT( handleDone() )); setStandardToolBarMenuEnabled( false ); createStandardStatusBarAction(); setupGUI( Keys|StatusBar|Save|Create ); delete toolBar(); Application::setStatusBar( statusBar() ); TQTimer::singleShot( 0, this, TQT_SLOT( delayed() ) ); m_stack->raiseWidget( m_progress ); setCentralWidget( m_all ); } void App::delayed() { statusBar()->clear(); kdDebug() << "App::delayed starting commit" << endl; aptFront::Manager m; m.setProgressCallback( m_progress->callback() ); m.setUpdateInterval( 100000 ); try { if (updating) { m_stack->raiseWidget( m_progress ); m.update(); } else { m_stack->raiseWidget( m_progress ); m.download(); m_stack->raiseWidget( m_commitProgress ); m.commit(); } emit imDone(); } catch ( exception::OperationCancelled ) { emit imDone(); } catch ( ... ) { KMessageBox::sorry( this, i18n( "There was an error commiting changes. " "Possibly there was a problem downloading some " "packages or the commit would break packages. " ), i18n( "Could not commit changes" ) ); emit imDone(); } } void App::handleDone() { kdDebug() << "I'm done here" << endl; close(); } #include "app.moc"