author | andyq <andyq> | 2002-11-21 20:16:40 (UTC) |
---|---|---|
committer | andyq <andyq> | 2002-11-21 20:16:40 (UTC) |
commit | 2185394da06d32a3655e71ec022da202477350e7 (patch) (side-by-side diff) | |
tree | b266ddecaa44a1fef5229bb0525c990d5e7cc51a | |
parent | 6d302b82aab909da59852d99a31bcc7726ba9f34 (diff) | |
download | opie-2185394da06d32a3655e71ec022da202477350e7.zip opie-2185394da06d32a3655e71ec022da202477350e7.tar.gz opie-2185394da06d32a3655e71ec022da202477350e7.tar.bz2 |
Re-applied patch for gcc3.2
-rw-r--r-- | noncore/settings/aqpkg/datamgr.cpp | 27 | ||||
-rw-r--r-- | noncore/settings/aqpkg/datamgr.h | 6 | ||||
-rw-r--r-- | noncore/settings/aqpkg/global.h | 2 | ||||
-rw-r--r-- | noncore/settings/aqpkg/installdlgimpl.cpp | 2 | ||||
-rw-r--r-- | noncore/settings/aqpkg/ipkg.cpp | 1 | ||||
-rw-r--r-- | noncore/settings/aqpkg/letterpushbutton.cpp | 2 | ||||
-rw-r--r-- | noncore/settings/aqpkg/mainwin.cpp | 3 | ||||
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 4 | ||||
-rw-r--r-- | noncore/settings/aqpkg/server.cpp | 2 | ||||
-rw-r--r-- | noncore/settings/aqpkg/settingsimpl.cpp | 13 |
10 files changed, 29 insertions, 33 deletions
diff --git a/noncore/settings/aqpkg/datamgr.cpp b/noncore/settings/aqpkg/datamgr.cpp index e7fb75a..96c28c0 100644 --- a/noncore/settings/aqpkg/datamgr.cpp +++ b/noncore/settings/aqpkg/datamgr.cpp @@ -1,262 +1,255 @@ /*************************************************************************** datamgr.cpp - description ------------------- begin : Thu Aug 29 2002 copyright : (C) 2002 by Andy Qua email : andy.qua@blueyonder.co.uk ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include <fstream> #include <iostream> using namespace std; #ifdef QWS #include <qpe/config.h> #endif #include <stdio.h> #include "datamgr.h" #include "global.h" QString DataManager::availableCategories = ""; DataManager::DataManager() { activeServer = ""; availableCategories = "#"; } DataManager::~DataManager() { } -Server *DataManager :: getServer( const char *name ) +vector<Server>::iterator DataManager :: getServer( const char *name ) { - Server *s = 0; vector<Server>::iterator it = serverList.begin(); - while ( it != serverList.end() && s == 0 ) + while ( it != serverList.end() ) { if ( it->getServerName() == name ) - s = &(*it); + return it; ++it; } - return s; + return serverList.end(); } -Destination *DataManager :: getDestination( const char *name ) +vector<Destination>::iterator DataManager :: getDestination( const char *name ) { - Destination *d = 0; vector<Destination>::iterator it = destList.begin(); - while ( it != destList.end() && d == 0 ) + while ( it != destList.end() ) { if ( it->getDestinationName() == name ) - d = &(*it); + return it; ++it; } - return d; + return destList.end(); } void DataManager :: loadServers() { // First add our local server - not really a server but // the local config (which packages are installed) serverList.push_back( Server( LOCAL_SERVER, "" ) ); serverList.push_back( Server( LOCAL_IPKGS, "" ) ); #ifdef QWS Config cfg( "aqpkg" ); cfg.setGroup( "destinations" ); #endif // Read file from /etc/ipkg.conf QString ipkg_conf = IPKG_CONF; FILE *fp; fp = fopen( ipkg_conf, "r" ); char line[130]; QString lineStr; if ( fp == NULL ) { cout << "Couldn't open " << ipkg_conf << "! err = " << fp << endl; return; } else { while ( fgets( line, sizeof line, fp) != NULL ) { lineStr = line; if ( lineStr.startsWith( "src" ) || lineStr.startsWith( "#src" ) || lineStr.startsWith( "# src" ) ) { char alias[20]; char url[100]; // Looks a little wierd but read up to the r of src (throwing it away), // then read up to the next space and throw that away, the alias // is next. // Should Handle #src, # src, src, and combinations of sscanf( lineStr, "%*[^r]%*[^ ] %s %s", alias, url ); Server s( alias, url ); if ( lineStr.startsWith( "src" ) ) s.setActive( true ); else s.setActive( false ); serverList.push_back( s ); } else if ( lineStr.startsWith( "dest" ) ) { char alias[20]; char path[50]; sscanf( lineStr, "%*[^ ] %s %s", alias, path ); Destination d( alias, path ); bool linkToRoot = true; #ifdef QWS QString key = alias; key += "_linkToRoot"; linkToRoot = cfg.readBoolEntry( key, true ); #endif d.linkToRoot( linkToRoot ); destList.push_back( d ); } else if ( lineStr.startsWith( "option" ) ) { char type[20]; char val[100]; sscanf( lineStr, "%*[^ ] %s %s", type, val ); if ( stricmp( type, "http_proxy" ) == 0 ) httpProxy = val; if ( stricmp( type, "ftp_proxy" ) == 0 ) ftpProxy = val; if ( stricmp( type, "proxy_username" ) == 0 ) proxyUsername = val; if ( stricmp( type, "proxy_password" ) == 0 ) proxyPassword = val; } } } fclose( fp ); - cout << "httpProxy = " << httpProxy << endl; - cout << "ftpProxy = " << ftpProxy << endl; - cout << "proxyUsername = " << proxyUsername << endl; - cout << "proxyPassword = " << proxyPassword << endl; - reloadServerData( ); } void DataManager :: reloadServerData( ) { vector<Server>::iterator it = serverList.begin(); for ( it = serverList.begin() ; it != serverList.end() ; ++it ) { // Now we've read the config file in we need to read the servers // The local server is a special case. This holds the contents of the // status files the number of which depends on how many destinations // we've set up // The other servers files hold the contents of the server package list if ( it->getServerName() == LOCAL_SERVER ) it->readStatusFile( destList ); else if ( it->getServerName() == LOCAL_IPKGS ) - it->readLocalIpks( getServer( LOCAL_SERVER ) ); + it->readLocalIpks( &( *getServer( LOCAL_SERVER ) ) ); else - it->readPackageFile( getServer( LOCAL_SERVER ) ); + it->readPackageFile( &( *getServer( LOCAL_SERVER ) ) ); } } void DataManager :: writeOutIpkgConf() { QString ipkg_conf = IPKG_CONF; ofstream out( ipkg_conf ); out << "# Written by AQPkg" << endl; out << "# Must have one or more source entries of the form:" << endl; out << "#" << endl; out << "# src <src-name> <source-url>" << endl; out << "#" << endl; out << "# and one or more destination entries of the form:" << endl; out << "#" << endl; out << "# dest <dest-name> <target-path>" << endl; out << "#" << endl; out << "# where <src-name> and <dest-names> are identifiers that" << endl; out << "# should match [a-zA-Z0-9._-]+, <source-url> should be a" << endl; out << "# URL that points to a directory containing a Familiar" << endl; out << "# Packages file, and <target-path> should be a directory" << endl; out << "# that exists on the target system." << endl << endl; // Write out servers vector<Server>::iterator it = serverList.begin(); while ( it != serverList.end() ) { QString alias = it->getServerName(); // Don't write out local as its a dummy if ( alias != LOCAL_SERVER && alias != LOCAL_IPKGS ) { QString url = it->getServerUrl();; if ( !it->isServerActive() ) out << "#"; out << "src " << alias << " " << url << endl; } it++; } out << endl; // Write out destinations vector<Destination>::iterator it2 = destList.begin(); while ( it2 != destList.end() ) { out << "dest " << it2->getDestinationName() << " " << it2->getDestinationPath() << endl; it2++; } out << "# Proxy Support" << endl; out << "#" << endl; if ( httpProxy == "" ) out << "#option http_proxy http://proxy.tld:3128" << endl; else out << "option http_proxy " << httpProxy << endl; if ( ftpProxy == "" ) out << "#option ftp_proxy http://proxy.tld:3128" << endl; else out << "option ftp_proxy " << ftpProxy << endl; if ( proxyUsername == "" ) out << "#option proxy_username <username>" << endl; else out << "option proxy_username " << proxyUsername << endl; if ( proxyPassword == "" ) out << "#option proxy_password <password>" << endl << endl; else out << "option proxy_password " << proxyPassword << endl<< endl; out << "# Offline mode (for use in constructing flash images offline)" << endl; out << "#option offline_root target" << endl; out.close(); } void DataManager :: setAvailableCategories( QString section ) { section = section.lower(); if ( availableCategories.find( "#" + section + "#" ) == -1 ) availableCategories += section + "#"; } diff --git a/noncore/settings/aqpkg/datamgr.h b/noncore/settings/aqpkg/datamgr.h index 14b0b2f..41833df 100644 --- a/noncore/settings/aqpkg/datamgr.h +++ b/noncore/settings/aqpkg/datamgr.h @@ -1,73 +1,73 @@ /*************************************************************************** datamgr.h - description ------------------- begin : Thu Aug 29 2002 copyright : (C) 2002 by Andy Qua email : andy.qua@blueyonder.co.uk ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef DATAMGR_H #define DATAMGR_H #include <map> using namespace std; #include <qstring.h> #include "server.h" #include "destination.h" #define LOCAL_SERVER "Installed Pkgs" #define LOCAL_IPKGS "local IPKG" /** *@author Andy Qua */ class DataManager { public: DataManager(); ~DataManager(); void setActiveServer( const QString &act ) { activeServer = act; } QString &getActiveServer( ) { return activeServer; } - Server *getLocalServer() { return getServer( LOCAL_SERVER ); } + Server *getLocalServer() { return &( *getServer( LOCAL_SERVER ) ); } vector<Server> &getServerList() { return serverList; } - Server *getServer( const char *name ); + vector<Server>::iterator getServer( const char *name ); vector<Destination> &getDestinationList() { return destList; } - Destination *getDestination( const char *name ); + vector<Destination>::iterator getDestination( const char *name ); void loadServers(); void reloadServerData( ); void writeOutIpkgConf(); static QString getAvailableCategories() { return availableCategories; } static void setAvailableCategories( QString section ); private: static QString availableCategories; QString activeServer; QString httpProxy; QString ftpProxy; QString proxyUsername; QString proxyPassword; vector<Server> serverList; vector<Destination> destList; }; #endif diff --git a/noncore/settings/aqpkg/global.h b/noncore/settings/aqpkg/global.h index fcec643..ddfb3ac 100644 --- a/noncore/settings/aqpkg/global.h +++ b/noncore/settings/aqpkg/global.h @@ -1,80 +1,80 @@ /*************************************************************************** global.h - description ------------------- begin : Mon Aug 26 2002 copyright : (C) 2002 by Andy Qua email : andy.qua@blueyonder.co.uk ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef __GLOBAL_H #define __GLOBAL_H -#define VERSION_TEXT "AQPkg Version 1.3" +#define VERSION_TEXT "AQPkg Version 1.4" // Uncomment the below line to run on a Linux box rather than a Zaurus // box this allows you to change where root is, and where to load config files from // #define X86 // Sets up location of ipkg.conf and root directory #ifdef QWS #ifndef X86 // Running QT/Embedded on an arm processor #define IPKG_CONF "/etc/ipkg.conf" #define ROOT "/" #define IPKG_DIR "/usr/lib/ipkg/" #else // Running QT/Embedded on a X86 linux box #define IPKG_CONF "/home/andy/projects/aqpkg/aqpkg/data/ipkg.conf" #define ROOT "/home/andy/projects/aqpkg/aqpkg/data/root" #define IPKG_DIR "/home/andy/projects/aqpkg/aqpkg/data/" #endif #else // Running QT on a X86 linux box #define IPKG_CONF "/home/andy/projects/aqpkg/aqpkg/data/ipkg.conf" #define ROOT "/home/andy/projects/aqpkg/aqpkg/data/root" #define IPKG_DIR "/home/andy/projects/aqpkg/aqpkg/data/" #endif // Uncomment the below line to turn on memory checking //#define _DEBUG 1 #ifndef __MEMFILE_C #ifdef _DEBUG void * operator new(unsigned int size,const char *file, int line); void operator delete(void *p); #endif #ifdef _DEBUG #define DEBUG_NEW new(__FILE__, __LINE__) //#define DEBUG_NEW new #else #define DEBUG_NEW new #endif #define new DEBUG_NEW #endif void AddTrack(long addr, long asize, const char *fname, long lnum); void RemoveTrack(long addr); void DumpUnfreed(); #endif diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp index b297437..db9a259 100644 --- a/noncore/settings/aqpkg/installdlgimpl.cpp +++ b/noncore/settings/aqpkg/installdlgimpl.cpp @@ -72,171 +72,171 @@ InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *d destination->setCurrentItem( defIndex ); vector<InstallData>::iterator it; // setup package data QString remove = "Remove\n"; QString install = "\nInstall\n"; QString upgrade = "\nUpgrade\n"; for ( it = packageList.begin() ; it != packageList.end() ; ++it ) { InstallData item = *it; if ( item.option == "I" ) { installList.push_back( item ); install += " " + item.packageName + "\n"; } else if ( item.option == "D" ) { removeList.push_back( item ); remove += " " + item.packageName + "\n"; } else if ( item.option == "U" || item.option == "R" ) { updateList.push_back( item ); QString type = " (Upgrade)"; if ( item.option == "R" ) type = " (ReInstall)"; upgrade += " " + item.packageName + type + "\n"; } } output->setText( remove + install + upgrade ); } InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, QWidget *parent, const char *name, bool modal, WFlags fl ) : InstallDlg( parent, name, modal, fl ) { pIpkg = ipkg; output->setText( initialText ); } InstallDlgImpl::~InstallDlgImpl() { } bool InstallDlgImpl :: showDlg() { showMaximized(); bool ret = exec(); return ret; } void InstallDlgImpl :: optionsSelected() { InstallOptionsDlgImpl opt( flags, this, "Option", true ); opt.exec(); // set options selected from dialog flags = 0; if ( opt.forceDepends->isChecked() ) flags |= FORCE_DEPENDS; if ( opt.forceReinstall->isChecked() ) flags |= FORCE_REINSTALL; if ( opt.forceRemove->isChecked() ) flags |= FORCE_REMOVE; if ( opt.forceOverwrite->isChecked() ) flags |= FORCE_OVERWRITE; #ifdef QWS Config cfg( "aqpkg" ); cfg.setGroup( "settings" ); cfg.writeEntry( "installFlags", flags ); #endif } void InstallDlgImpl :: installSelected() { if ( btnInstall->text() == "Close" ) { done( 1 ); return; } btnInstall->setEnabled( false ); if ( pIpkg ) { output->setText( "" ); connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); pIpkg->runIpkg(); } else { output->setText( "" ); - Destination *d = dataMgr->getDestination( destination->currentText() ); + vector<Destination>::iterator d = dataMgr->getDestination( destination->currentText() ); QString dest = d->getDestinationName(); QString destDir = d->getDestinationPath(); int instFlags = flags; if ( d->linkToRoot() ) instFlags |= MAKE_LINKS; #ifdef QWS // Save settings Config cfg( "aqpkg" ); cfg.setGroup( "settings" ); cfg.writeEntry( "dest", dest ); #endif pIpkg = new Ipkg; connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); // First run through the remove list, then the install list then the upgrade list vector<InstallData>::iterator it; pIpkg->setOption( "remove" ); for ( it = removeList.begin() ; it != removeList.end() ; ++it ) { pIpkg->setDestination( it->destination->getDestinationName() ); pIpkg->setDestinationDir( it->destination->getDestinationPath() ); pIpkg->setPackage( it->packageName ); int tmpFlags = flags; if ( it->destination->linkToRoot() ) tmpFlags |= MAKE_LINKS; pIpkg->setFlags( tmpFlags ); pIpkg->runIpkg(); } pIpkg->setOption( "install" ); pIpkg->setDestination( dest ); pIpkg->setDestinationDir( destDir ); pIpkg->setFlags( instFlags ); for ( it = installList.begin() ; it != installList.end() ; ++it ) { pIpkg->setPackage( it->packageName ); pIpkg->runIpkg(); } flags |= FORCE_REINSTALL; for ( it = updateList.begin() ; it != updateList.end() ; ++it ) { if ( it->option == "R" ) pIpkg->setOption( "reinstall" ); else pIpkg->setOption( "upgrade" ); pIpkg->setDestination( it->destination->getDestinationName() ); pIpkg->setDestinationDir( it->destination->getDestinationPath() ); pIpkg->setPackage( it->packageName ); int tmpFlags = flags; if ( it->destination->linkToRoot() && it->recreateLinks ) tmpFlags |= MAKE_LINKS; pIpkg->setFlags( tmpFlags ); pIpkg->runIpkg(); } delete pIpkg; } btnInstall->setEnabled( true ); btnInstall->setText( tr( "Close" ) ); } void InstallDlgImpl :: displayText(const QString &text ) { QString t = output->text() + "\n" + text; output->setText( t ); output->setCursorPosition( output->numLines(), 0 ); } diff --git a/noncore/settings/aqpkg/ipkg.cpp b/noncore/settings/aqpkg/ipkg.cpp index 452eca3..8de3c48 100644 --- a/noncore/settings/aqpkg/ipkg.cpp +++ b/noncore/settings/aqpkg/ipkg.cpp @@ -1,114 +1,115 @@ /*************************************************************************** ipkg.cpp - description ------------------- begin : Sat Aug 31 2002 copyright : (C) 2002 by Andy Qua email : andy.qua@blueyonder.co.uk ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include <fstream> +#include <iostream> using namespace std; #include <stdio.h> #include <unistd.h> #ifdef QWS #include <qpe/qpeapplication.h> #else #include <qapplication.h> #endif #include <qdir.h> #include <qtextstream.h> #include "utils.h" #include "ipkg.h" #include "global.h" Ipkg :: Ipkg() { } Ipkg :: ~Ipkg() { } // Option is what we are going to do - install, upgrade, download, reinstall // package is the package name to install - either a fully qualified path and ipk // file (if stored locally) or just the name of the package (for a network package) // packageName is the package name - (for a network package this will be the same as // package parameter) // dest is the destination alias (from ipk.conf) // destDir is the dir that the destination alias points to (used to link to root) // flags is the ipkg options flags // dir is the directory to run ipkg in (defaults to "") bool Ipkg :: runIpkg( ) { bool ret = false; QDir::setCurrent( "/tmp" ); QString cmd = ""; if ( runtimeDir != "" ) { cmd += "cd "; cmd += runtimeDir; cmd += " ; "; } cmd += "ipkg -force-defaults"; // only set the destination for an install operation if ( option == "install" ) cmd += " -dest "+ destination; if ( option != "update" && option != "download" ) { if ( flags & FORCE_DEPENDS ) cmd += " -force-depends"; if ( flags & FORCE_REINSTALL ) cmd += " -force-reinstall"; if ( flags & FORCE_REMOVE ) cmd += " -force-removal-of-essential-packages"; if ( flags & FORCE_OVERWRITE ) cmd += " -force-overwrite"; // Handle make links // Rules - If make links is switched on, create links to root // if destDir is NOT / if ( flags & MAKE_LINKS ) { // If destDir == / turn off make links as package is being insalled // to root already. if ( destDir == "/" ) flags ^= MAKE_LINKS; } } #ifdef X86 cmd += " -f "; cmd += IPKG_CONF; #endif if ( option == "reinstall" ) cmd += " install"; else cmd += " " + option; if ( package != "" ) cmd += " " + package; cmd += " 2>&1"; if ( package != "" ) emit outputText( QString( "Dealing with package " ) + package ); qApp->processEvents(); diff --git a/noncore/settings/aqpkg/letterpushbutton.cpp b/noncore/settings/aqpkg/letterpushbutton.cpp index afe25d8..ca96c6c 100644 --- a/noncore/settings/aqpkg/letterpushbutton.cpp +++ b/noncore/settings/aqpkg/letterpushbutton.cpp @@ -1,34 +1,34 @@ /*************************************************************************** letterpushbutton.cpp - description ------------------- begin : Wed Oct 16 2002 copyright : (C) 2002 by Andy Qua email : andy.qua@blueyonder.co.uk ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "letterpushbutton.h" -LetterPushButton :: LetterPushButton( const QString &text, QWidget *parent, const char *name=0 ) +LetterPushButton :: LetterPushButton( const QString &text, QWidget *parent, const char *name ) : QPushButton( text, parent, name ) { connect( this, SIGNAL(released()), this, SLOT(released_emmitor()) ); } LetterPushButton :: ~LetterPushButton() { } void LetterPushButton :: released_emmitor() { emit released( text() ); } diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index 0141359..3ddc582 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp @@ -1,150 +1,151 @@ /*************************************************************************** mainwin.cpp - description ------------------- begin : Mon Aug 26 13:32:30 BST 2002 copyright : (C) 2002 by Andy Qua email : andy.qua@blueyonder.co.uk ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include <iostream> +using namespace std; #include <qmenubar.h> #include <qpopupmenu.h> #include <qmessagebox.h> #include "mainwin.h" #include "datamgr.h" #include "networkpkgmgr.h" #include "settingsimpl.h" #include "helpwindow.h" #include "utils.h" #include "global.h" MainWindow :: MainWindow( QWidget *p, char *name ) : QMainWindow( p, name ) { #ifdef QWS showMaximized(); #endif setCaption( "AQPkg - Package Manager" ); // Create our menu help = new QPopupMenu( this ); help->insertItem( "&General", this, SLOT(displayHelp()), Qt::CTRL+Qt::Key_G ); help->insertItem( "&About", this, SLOT(displayAbout()), Qt::CTRL+Qt::Key_A ); settings = new QPopupMenu( this ); settings->insertItem( "&Settings", this, SLOT(displaySettings()), Qt::CTRL+Qt::Key_S ); edit = new QPopupMenu( this ); edit->insertItem( "&Find", this, SLOT(searchForPackage()), Qt::CTRL+Qt::Key_I ); edit->insertItem( "Find &Next", this, SLOT(repeatSearchForPackage()), Qt::CTRL+Qt::Key_N ); filter = new QPopupMenu( this ); - mnuShowUninstalledPkgsId = filter->insertItem( "Show &Uninstalled Packages", this, SLOT(filterUninstalledPackages()), Qt::CTRL+Qt::Key_U ); + mnuShowUninstalledPkgsId = filter->insertItem( "Show &Non-Installed Packages", this, SLOT(filterUninstalledPackages()), Qt::CTRL+Qt::Key_U ); mnuShowInstalledPkgsId = filter->insertItem( "Show In&stalled Packages", this, SLOT(filterInstalledPackages()), Qt::CTRL+Qt::Key_S ); mnuShowUpgradedPkgsId = filter->insertItem( "Show U&pdated Packages", this, SLOT(filterUpgradedPackages()), Qt::CTRL+Qt::Key_P ); filter->insertSeparator(); mnuFilterByCategory = filter->insertItem( "Filter By &Category", this, SLOT(filterCategory()), Qt::CTRL+Qt::Key_C ); mnuSetFilterCategory = filter->insertItem( "Set Filter C&ategory", this, SLOT(setFilterCategory()), Qt::CTRL+Qt::Key_A ); // Create the main menu menu = menuBar(); //new QMenuBar( this ); menu->insertItem( "&Settings", settings ); menu->insertItem( "&Edit", edit ); menu->insertItem( "&Filter", filter ); menu->insertItem( "&Help", help ); mgr = new DataManager(); mgr->loadServers(); stack = new QWidgetStack( this ); networkPkgWindow = new NetworkPackageManager( mgr, stack ); stack->addWidget( networkPkgWindow, 1 ); setCentralWidget( stack ); stack->raiseWidget( networkPkgWindow ); } MainWindow :: ~MainWindow() { delete networkPkgWindow; } void MainWindow :: setDocument( const QString &doc ) { // Remove path from package QString package = Utils::getPackageNameFromIpkFilename( doc ); std::cout << "Selecting package " << package << std::endl; networkPkgWindow->selectLocalPackage( package ); } void MainWindow :: displaySettings() { SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); if ( dlg->showDlg( 0 ) ) networkPkgWindow->updateData(); delete dlg; } void MainWindow :: displayHelp() { HelpWindow *dlg = new HelpWindow( this ); dlg->exec(); delete dlg; } void MainWindow :: searchForPackage() { networkPkgWindow->searchForPackage( false ); } void MainWindow :: repeatSearchForPackage() { networkPkgWindow->searchForPackage( true ); } void MainWindow :: displayAbout() { QMessageBox::about( this, "About AQPkg", VERSION_TEXT ); } void MainWindow :: filterUninstalledPackages() { bool val; if ( filter->isItemChecked( mnuShowUninstalledPkgsId ) ) { val = false; filter->setItemChecked( mnuShowUninstalledPkgsId, false ); } else { val = true; filter->setItemChecked( mnuShowUninstalledPkgsId, true ); } filter->setItemChecked( mnuShowInstalledPkgsId, false ); networkPkgWindow->showOnlyInstalledPackages( false ); filter->setItemChecked( mnuShowUpgradedPkgsId, false ); networkPkgWindow->showUpgradedPackages( false ); networkPkgWindow->showOnlyUninstalledPackages( val ); } void MainWindow :: filterInstalledPackages() { bool val; if ( filter->isItemChecked( mnuShowInstalledPkgsId ) ) diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp index d9e62b6..79a380e 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.cpp +++ b/noncore/settings/aqpkg/networkpkgmgr.cpp @@ -124,193 +124,193 @@ void NetworkPackageManager :: selectLocalPackage( const QString &pkg ) } } serverSelected( 0 ); // Now set the check box of the selected package for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); item != 0 ; item = (QCheckListItem *)item->nextSibling() ) { if ( item->text().startsWith( pkg ) ) { item->setOn( true ); break; } } } void NetworkPackageManager :: initGui() { QLabel *l = new QLabel( "Servers", this ); serversList = new QComboBox( this ); packagesList = new QListView( this ); update = new QPushButton( "Refresh Lists", this ); download = new QPushButton( "Download", this ); upgrade = new QPushButton( "Upgrade", this ); apply = new QPushButton( "Apply", this ); QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" ); QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" ); hbox1->addWidget( l ); hbox1->addWidget( serversList ); QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" ); QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" ); if ( showJumpTo ) { char text[2]; text[1] = '\0'; for ( int i = 0 ; i < 26 ; ++i ) { text[0] = 'A' + i; LetterPushButton *b = new LetterPushButton( text, this ); connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); if ( i < 13 ) hbox3->addWidget( b ); else hbox4->addWidget( b ); } } vbox->addWidget( packagesList ); packagesList->addColumn( "Packages" ); QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" ); hbox2->addWidget( update ); hbox2->addWidget( download ); hbox2->addWidget( upgrade ); hbox2->addWidget( apply ); } void NetworkPackageManager :: setupConnections() { connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) ); connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) ); connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) ); connect( update, SIGNAL(released()), this, SLOT(updateServer()) ); } void NetworkPackageManager :: showProgressDialog( char *initialText ) { if ( !progressDlg ) progressDlg = new ProgressDlg( this, "Progress", false ); progressDlg->setText( initialText ); progressDlg->show(); } void NetworkPackageManager :: serverSelected( int ) { packagesList->clear(); // display packages QString serverName = serversList->currentText(); currentlySelectedServer = serverName; #ifdef QWS // read download directory from config file Config cfg( "aqpkg" ); cfg.setGroup( "settings" ); cfg.writeEntry( "selectedServer", currentlySelectedServer ); #endif - Server *s = dataMgr->getServer( serverName ); + vector<Server>::iterator s = dataMgr->getServer( serverName ); vector<Package> &list = s->getPackageList(); vector<Package>::iterator it; for ( it = list.begin() ; it != list.end() ; ++it ) { QString text = ""; // Apply show only uninstalled packages filter if ( showUninstalledPkgs && it->isInstalled() ) continue; // Apply show only installed packages filter if ( showInstalledPkgs && !it->isInstalled() ) continue; // Apply show only new installed packages filter if ( showUpgradedPkgs ) { if ( !it->isInstalled() || compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 ) continue; } // Apply the section filter if ( categoryFilterEnabled && categoryFilter != "" ) { if ( it->getSection() == "" || categoryFilter.find( it->getSection().lower() ) == -1 ) continue; } // If the local server, only display installed packages if ( serverName == LOCAL_SERVER && !it->isInstalled() ) continue; text += it->getPackageName(); if ( it->isInstalled() ) { text += " (installed)"; // If a different version of package is available, postfix it with an * if ( it->getVersion() != it->getInstalledVersion() ) { if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 ) text += "*"; } } QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); if ( it->isInstalled() ) { QString destName = ""; if ( it->getLocalPackage() ) { if ( it->getLocalPackage()->getInstalledTo() ) destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); } else { if ( it->getInstalledTo() ) destName = it->getInstalledTo()->getDestinationName(); } if ( destName != "" ) new QCheckListItem( item, QString( "Installed To - " ) + destName ); } if ( !it->isPackageStoredLocally() ) { new QCheckListItem( item, QString( "Description - " ) + it->getDescription() ); new QCheckListItem( item, QString( "Size - " ) + it->getPackageSize() ); new QCheckListItem( item, QString( "Section - " ) + it->getSection() ); } else new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); if ( serverName == LOCAL_SERVER ) { new QCheckListItem( item, QString( "V. Installed - " ) + it->getVersion() ); } else { new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); if ( it->getLocalPackage() ) { if ( it->isInstalled() ) new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() ); } } packagesList->insertItem( item ); } // If the local server or the local ipkgs server disable the download button @@ -519,193 +519,193 @@ void NetworkPackageManager :: downloadRemotePackage() QString package = InputDialog::getText( "Install Remote Package", tr( "Enter package location" ), "http://", &ok, this ); if ( !ok || package.isEmpty() ) return; // DownloadRemoteDlgImpl dlg( this, "Install", true ); // if ( dlg.exec() == QDialog::Rejected ) // return; // grab details from dialog // QString package = dlg.getPackageLocation(); InstallData item; item.option = "I"; item.packageName = package; vector<InstallData> workingPackages; workingPackages.push_back( item ); InstallDlgImpl dlg2( workingPackages, dataMgr, this, "Install", true ); dlg2.showDlg(); // Reload data dataMgr->reloadServerData(); serverSelected(-1); #ifdef QWS // Finally let the main system update itself QCopEnvelope e("QPE/System", "linkChanged(QString)"); QString lf = QString::null; e << lf; #endif } void NetworkPackageManager :: applyChanges() { stickyOption = ""; // First, write out ipkg_conf file so that ipkg can use it dataMgr->writeOutIpkgConf(); // Now for each selected item // deal with it vector<InstallData> workingPackages; for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); item != 0 ; item = (QCheckListItem *)item->nextSibling() ) { if ( item->isOn() ) { InstallData data = dealWithItem( item ); workingPackages.push_back( data ); } } if ( workingPackages.size() == 0 ) { // Nothing to do QMessageBox::information( this, "Nothing to do", "No packages selected", "OK" ); return; } // do the stuff InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); dlg.showDlg(); // Reload data dataMgr->reloadServerData(); serverSelected(-1); #ifdef QWS // Finally let the main system update itself QCopEnvelope e("QPE/System", "linkChanged(QString)"); QString lf = QString::null; e << lf; #endif } // decide what to do - either remove, upgrade or install // Current rules: // If not installed - install // If installed and different version available - upgrade // If installed and version up to date - remove InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) { QString name = item->text(); int pos = name.find( "*" ); name.truncate( pos ); // if (there is a (installed), remove it pos = name.find( "(installed)" ); if ( pos > 0 ) name.truncate( pos - 1 ); // Get package - Server *s = dataMgr->getServer( serversList->currentText() ); + vector<Server>::iterator s = dataMgr->getServer( serversList->currentText() ); Package *p = s->getPackage( name ); // If the package has a filename then it is a local file if ( p->isPackageStoredLocally() ) name = p->getFilename(); QString option; QString dest = "root"; if ( !p->isInstalled() ) { InstallData item; item.option = "I"; item.packageName = name; return item; } else { InstallData item; item.option = "D"; if ( !p->isPackageStoredLocally() ) item.packageName = p->getInstalledPackageName(); else item.packageName = name; if ( p->getInstalledTo() ) { item.destination = p->getInstalledTo(); cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; } else { item.destination = p->getLocalPackage()->getInstalledTo(); } // Now see if version is newer or not int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); // If the version requested is older and user selected a local ipk file, then reinstall the file if ( p->isPackageStoredLocally() && val == -1 ) val = 0; if ( val == -2 ) { // Error - should handle } else if ( val == -1 ) { // Version available is older - remove only item.option = "D"; } else { QString caption; QString text; QString secondButton; QString secondOption; if ( val == 0 ) { // Version available is the same - option to remove or reinstall caption = "Do you wish to remove or reinstall\n%s?"; text = "Remove or ReInstall"; secondButton = "ReInstall"; secondOption = "R"; } else if ( val == 1 ) { // Version available is newer - option to remove or upgrade caption = "Do you wish to remove or upgrade\n%s?"; text = "Remove or Upgrade"; secondButton = "Upgrade"; secondOption = "U"; } // Sticky option not implemented yet, but will eventually allow // the user to say something like 'remove all' if ( stickyOption == "" ) { QString msgtext; msgtext.sprintf( caption, (const char *)name ); switch( QMessageBox::information( this, text, msgtext, "Remove", secondButton ) ) { case 0: // Try again or Enter // option 0 = Remove item.option = "D"; break; case 1: // Quit or Escape item.option = secondOption; break; } } else { // item.option = stickyOption; } diff --git a/noncore/settings/aqpkg/server.cpp b/noncore/settings/aqpkg/server.cpp index 58407d5..2cb0533 100644 --- a/noncore/settings/aqpkg/server.cpp +++ b/noncore/settings/aqpkg/server.cpp @@ -1,179 +1,179 @@ /*************************************************************************** server.cpp - description ------------------- begin : Mon Aug 26 2002 copyright : (C) 2002 by Andy Qua email : andy.qua@blueyonder.co.uk description : This class holds details about a server : e.g. all the packages that contained on the server : the installation status ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <iostream> #include <fstream> using namespace std; #include "server.h" #include "datamgr.h" #ifdef QWS #include <qpe/global.h> #include <qpe/applnk.h> #include <qlist.h> #endif #include "utils.h" #include "global.h" Server :: Server( const char *name, const char *url ) { serverName = name; serverUrl = url; packageFile = IPKG_DIR; active = true; packageFile += "lists/" + serverName; } Server :: ~Server() { cleanUp(); } void Server :: cleanUp() { packageList.clear(); } void Server :: readStatusFile( vector<Destination> &destList ) { cleanUp(); vector<Destination>::iterator dit; bool rootRead = false; for ( dit = destList.begin() ; dit != destList.end() ; ++dit ) { bool installingToRoot = false; QString path = dit->getDestinationPath(); if ( path.right( 1 ) != "/" ) path += "/"; if ( path == "/" ) { rootRead = true; installingToRoot = true; } packageFile = path + "usr/lib/ipkg/status"; - readPackageFile( 0, false, installingToRoot, dit ); + readPackageFile( 0, false, installingToRoot, &( *dit ) ); } // Ensure that the root status file is read if ( !rootRead ) { cout << "Reading status file " << "/usr/lib/ipkg/status" << endl; packageFile = "/usr/lib/ipkg/status"; readPackageFile( 0, false, true ); } } void Server :: readLocalIpks( Server *local ) { cleanUp(); #ifdef QWS // First, get any local IPKGs in the documents area // Only applicable to Qtopie/Opie DocLnkSet files; Global::findDocuments( &files, "application/ipkg" ); // Now add the items to the list QListIterator<DocLnk> it( files.children() ); for ( ; it.current() ; ++it ) { // OK, we have a local IPK file, I think the standard naming conventions // for these are packagename_version_arm.ipk QString file = (*it)->file(); // Changed to display the filename (excluding the path) QString packageName = Utils::getFilenameFromIpkFilename( file ); QString ver = Utils::getPackageVersionFromIpkFilename( file ); packageList.push_back( Package( packageName ) ); packageList.back().setVersion( ver ); packageList.back().setFilename( file ); packageList.back().setPackageStoredLocally( true ); } #else QString names[] = { "advancedfm_0.9.1-20020811_arm.ipk", "libopie_0.9.1-20020811_arm.ipk", "libopieobex_0.9.1-20020811.1_arm.ipk", "opie-addressbook_0.9.1-20020811_arm.ipk" }; for ( int i = 0 ; i < 4 ; ++i ) { // OK, we have a local IPK file, I think the standard naming conventions // for these are packagename_version_arm.ipk QString file = names[i]; int p = file.find( "_" ); QString tmp = file.mid( 0, p ); packageList.push_back( Package( tmp ) ); int p2 = file.find( "_", p+1 ); tmp = file.mid( p+1, p2-(p+1) ); packageList.back().setVersion( tmp ); packageList.back().setPackageStoredLocally( true ); } #endif // build local packages buildLocalPackages( local ); } void Server :: readPackageFile( Server *local, bool clearAll, bool installingToRoot, Destination *dest ) { ifstream in( packageFile ); if ( !in.is_open() ) return; char line[1001]; char k[21]; char v[1001]; QString key; QString value; if ( clearAll ) cleanUp(); Package *currPackage = 0; bool newPackage = true; do { in.getline( line, 1000 ); if ( in.eof() ) continue; k[0] = '\0'; v[0] = '\0'; sscanf( line, "%[^:]: %[^\n]", k, v ); key = k; value = v; key = key.stripWhiteSpace(); value = value.stripWhiteSpace(); if ( key == "Package" && newPackage ) { newPackage = false; diff --git a/noncore/settings/aqpkg/settingsimpl.cpp b/noncore/settings/aqpkg/settingsimpl.cpp index a18a178..9dd2206 100644 --- a/noncore/settings/aqpkg/settingsimpl.cpp +++ b/noncore/settings/aqpkg/settingsimpl.cpp @@ -1,245 +1,246 @@ /*************************************************************************** settingsimpl.cpp - description ------------------- begin : Thu Aug 29 2002 copyright : (C) 2002 by Andy Qua email : andy.qua@blueyonder.co.uk ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include <fstream> +#include <algorithm> using namespace std; #include <qlistbox.h> #include <qlineedit.h> #include <qpushbutton.h> #include <qtabwidget.h> #include <qcheckbox.h> #ifdef QWS #include <qpe/config.h> #endif #include "settingsimpl.h" #include "global.h" SettingsImpl :: SettingsImpl( DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) : SettingsBase( parent, name, modal, fl ) { dataMgr = dataManager; setupData(); changed = false; newserver = false; newdestination = false; } SettingsImpl :: ~SettingsImpl() { } bool SettingsImpl :: showDlg( int i ) { TabWidget->setCurrentPage( i ); showMaximized(); exec(); if ( changed ) dataMgr->writeOutIpkgConf(); return changed; } void SettingsImpl :: setupData() { // add servers vector<Server>::iterator it; for ( it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it ) { if ( it->getServerName() == LOCAL_SERVER || it->getServerName() == LOCAL_IPKGS ) continue; servers->insertItem( it->getServerName() ); } // add destinations vector<Destination>::iterator it2; for ( it2 = dataMgr->getDestinationList().begin() ; it2 != dataMgr->getDestinationList().end() ; ++it2 ) destinations->insertItem( it2->getDestinationName() ); #ifdef QWS Config cfg( "aqpkg" ); cfg.setGroup( "settings" ); jumpTo->setChecked( cfg.readBoolEntry( "showJumpTo", "true" ) ); #else jumpTo->setChecked( true ); #endif } //------------------ Servers tab ---------------------- void SettingsImpl :: editServer( int sel ) { currentSelectedServer = sel; - Server *s = dataMgr->getServer( servers->currentText() ); + vector<Server>::iterator s = dataMgr->getServer( servers->currentText() ); serverName = s->getServerName(); servername->setText( s->getServerName() ); serverurl->setText( s->getServerUrl() ); active->setChecked( s->isServerActive() ); } void SettingsImpl :: newServer() { newserver = true; servername->setText( "" ); serverurl->setText( "" ); servername->setFocus(); active->setChecked( true ); } void SettingsImpl :: removeServer() { changed = true; - Server *s = dataMgr->getServer( servers->currentText() ); + vector<Server>::iterator s = dataMgr->getServer( servers->currentText() ); dataMgr->getServerList().erase( s ); servers->removeItem( currentSelectedServer ); } void SettingsImpl :: changeServerDetails() { changed = true; QString newName = servername->text(); if ( !newserver ) { - Server *s = dataMgr->getServer( serverName ); + vector<Server>::iterator s = dataMgr->getServer( servers->currentText() ); // Update url s->setServerUrl( serverurl->text() ); s->setActive( active->isChecked() ); // Check if server name has changed, if it has then we need to replace the key in the map if ( serverName != newName ) { // Update server name s->setServerName( newName ); // See if this server is the active server // if ( dataMgr->getActiveServer() == serverName ) // dataMgr->setActiveServer( newName ); // Update list box servers->changeItem( newName, currentSelectedServer ); } } else { Server s( newName, serverurl->text() ); dataMgr->getServerList().push_back( Server( newName, serverurl->text() ) ); dataMgr->getServerList().end()->setActive( active->isChecked() ); servers->insertItem( newName ); servers->setCurrentItem( servers->count() ); newserver = false; } } //------------------ Destinations tab ---------------------- void SettingsImpl :: editDestination( int sel ) { currentSelectedDestination = sel; - Destination *d = dataMgr->getDestination( destinations->currentText() ); + vector<Destination>::iterator d = dataMgr->getDestination( destinations->currentText() ); destinationName = d->getDestinationName(); destinationname->setText( d->getDestinationName() ); destinationurl->setText( d->getDestinationPath() ); linkToRoot->setChecked( d->linkToRoot() ); } void SettingsImpl :: newDestination() { newdestination = true; destinationname->setText( "" ); destinationurl->setText( "" ); destinationname->setFocus(); linkToRoot->setChecked( true ); } void SettingsImpl :: removeDestination() { changed = true; - Destination *d = dataMgr->getDestination( destinations->currentText() ); + vector<Destination>::iterator d = dataMgr->getDestination( destinations->currentText() ); dataMgr->getDestinationList().erase( d ); destinations->removeItem( currentSelectedDestination ); } void SettingsImpl :: changeDestinationDetails() { changed = true; #ifdef QWS Config cfg( "aqpkg" ); cfg.setGroup( "destinations" ); #endif QString newName = destinationname->text(); if ( !newdestination ) { - Destination *d = dataMgr->getDestination( destinationName ); + vector<Destination>::iterator d = dataMgr->getDestination( destinations->currentText() ); // Update url d->setDestinationPath( destinationurl->text() ); d->linkToRoot( linkToRoot->isChecked() ); // Check if server name has changed, if it has then we need to replace the key in the map if ( destinationName != newName ) { // Update server name d->setDestinationName( newName ); // Update list box destinations->changeItem( newName, currentSelectedDestination ); } #ifdef QWS QString key = newName; key += "_linkToRoot"; int val = d->linkToRoot(); cfg.writeEntry( key, val ); #endif } else { dataMgr->getDestinationList().push_back( Destination( newName, destinationurl->text() ) ); destinations->insertItem( newName ); destinations->setCurrentItem( destinations->count() ); newdestination = false; #ifdef QWS QString key = newName; key += "_linkToRoot"; cfg.writeEntry( key, true ); #endif } } //------------------ General tab ---------------------- void SettingsImpl :: toggleJumpTo( bool val ) { #ifdef QWS Config cfg( "aqpkg" ); cfg.setGroup( "settings" ); cfg.writeEntry( "showJumpTo", val ); #endif } |