author | drw <drw> | 2003-04-29 02:28:16 (UTC) |
---|---|---|
committer | drw <drw> | 2003-04-29 02:28:16 (UTC) |
commit | e096c9d1f2be1ec74ede583fc4221871a56ef508 (patch) (side-by-side diff) | |
tree | 1c6f49430179e2f262179951477bbe4bd7d32e71 | |
parent | 2f26f696ca6acd05aa615e15d891eede9907a1c0 (diff) | |
download | opie-e096c9d1f2be1ec74ede583fc4221871a56ef508.zip opie-e096c9d1f2be1ec74ede583fc4221871a56ef508.tar.gz opie-e096c9d1f2be1ec74ede583fc4221871a56ef508.tar.bz2 |
Give aqpkg standard source headers and some minor code clean-up.
31 files changed, 875 insertions, 541 deletions
diff --git a/noncore/settings/aqpkg/categoryfilterimpl.cpp b/noncore/settings/aqpkg/categoryfilterimpl.cpp index e8ce7e7..61e1f93 100644 --- a/noncore/settings/aqpkg/categoryfilterimpl.cpp +++ b/noncore/settings/aqpkg/categoryfilterimpl.cpp @@ -1,94 +1,107 @@ -/*************************************************************************** - categoryfilterimpl.cpp - description - ------------------- - begin : Sun Nov 17 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. * - * * - ***************************************************************************/ +/* + This file is part of the OPIE Project + + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + #include <iostream> using namespace std; #include <qgroupbox.h> #include <qlayout.h> #include <qlistbox.h> #include <qstring.h> #include "categoryfilterimpl.h" CategoryFilterImpl :: CategoryFilterImpl(const QString &categories, const QString &selectedCategories, QWidget *parent, const char *name ) : QDialog( parent, name, true ) { setCaption( tr( "Category Filter" ) ); QVBoxLayout *layout = new QVBoxLayout( this ); layout->setMargin( 2 ); layout->setSpacing( 4 ); QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Select one or more groups" ), this ); grpbox->layout()->setSpacing( 2 ); grpbox->layout()->setMargin( 4 ); layout->addWidget( grpbox ); QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); lstCategories = new QListBox( grpbox ); lstCategories->setSelectionMode( QListBox::Multi ); grplayout->addWidget( lstCategories ); // Split up categories and add them to the listbox int start = 1; QString item; int end; QString finditem; do { end = categories.find( "#", start ); item = categories.mid( start, end - start ); if ( item != "" ) { lstCategories->insertItem( item ); finditem = QString( "#%1#" ).arg( item ); if ( selectedCategories.find( finditem ) != -1 ) lstCategories->setSelected( lstCategories->count()-1, true ); } start = end + 1; } while ( start < (int)categories.length() ); lstCategories->sort( true ); showMaximized(); } CategoryFilterImpl :: ~CategoryFilterImpl() { } QString CategoryFilterImpl :: getSelectedFilter() { // Grab cetegories from listbox QString ret = "#"; for ( int i = 0 ; i < (int)lstCategories->count() ; ++i ) { if ( lstCategories->isSelected( i ) ) { ret.append( lstCategories->text( i ) ); ret.append( "#" ); } } if ( ret == "#" ) ret = ""; return ret; } diff --git a/noncore/settings/aqpkg/categoryfilterimpl.h b/noncore/settings/aqpkg/categoryfilterimpl.h index a85fce4..78d39db 100644 --- a/noncore/settings/aqpkg/categoryfilterimpl.h +++ b/noncore/settings/aqpkg/categoryfilterimpl.h @@ -1,43 +1,55 @@ -/*************************************************************************** - categoryfilterimpl.h - description - ------------------- - begin : Sun Nov 17 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. * - * * - ***************************************************************************/ +/* + This file is part of the OPIE Project + + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #ifndef CATEGORYFILTERIMPL_H #define CATEGORYFILTERIMPL_H #include <qdialog.h> class QListBox; /** *@author Andy Qua */ class CategoryFilterImpl : public QDialog { Q_OBJECT public: CategoryFilterImpl(const QString &categories, const QString &selectedCategories, QWidget *parent=0, const char *name=0); ~CategoryFilterImpl(); QString getSelectedFilter(); private: QListBox *lstCategories; }; #endif diff --git a/noncore/settings/aqpkg/datamgr.cpp b/noncore/settings/aqpkg/datamgr.cpp index 79f36e1..cd0c78f 100644 --- a/noncore/settings/aqpkg/datamgr.cpp +++ b/noncore/settings/aqpkg/datamgr.cpp @@ -1,291 +1,312 @@ -/*************************************************************************** - 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; +/* + This file is part of the OPIE Project + + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #ifdef QWS #include <qpe/config.h> #include <qpe/qpeapplication.h> #else #include <qapplication.h> #endif -#include <stdio.h> +#include <qfile.h> +#include <qtextstream.h> #include "datamgr.h" #include "global.h" QString DataManager::availableCategories = ""; DataManager::DataManager() : QObject( 0x0, 0x0 ) { activeServer = ""; availableCategories = "#"; serverList.setAutoDelete( TRUE ); destList.setAutoDelete( TRUE ); } DataManager::~DataManager() { } Server *DataManager :: getServer( const char *name ) { QListIterator<Server> it( serverList ); while ( it.current() && it.current()->getServerName() != name ) { ++it; } return it.current(); } Destination *DataManager :: getDestination( const char *name ) { QListIterator<Destination> it( destList ); while ( it.current() && it.current()->getDestinationName() != name ) { ++it; } return it.current(); } void DataManager :: loadServers() { // First add our local server - not really a server but // the local config (which packages are installed) serverList.append( new Server( LOCAL_SERVER, "" ) ); serverList.append( new 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 = new Server( alias, url ); if ( lineStr.startsWith( "src" ) ) s->setActive( true ); else s->setActive( false ); serverList.append( s ); } else if ( lineStr.startsWith( "dest" ) ) { char alias[20]; char path[50]; sscanf( lineStr, "%*[^ ] %s %s", alias, path ); Destination *d = new Destination( alias, path ); bool linkToRoot = true; #ifdef QWS QString key = alias; key += "_linkToRoot"; linkToRoot = cfg.readBoolEntry( key, true ); #endif d->linkToRoot( linkToRoot ); destList.append( d ); } else if ( lineStr.startsWith( "option" ) || lineStr.startsWith( "#option" ) ) { char type[20]; char val[100]; sscanf( lineStr, "%*[^ ] %s %s", type, val ); if ( stricmp( type, "http_proxy" ) == 0 ) { httpProxy = val; if ( lineStr.startsWith( "#" ) ) httpProxyEnabled = false; else httpProxyEnabled = true; } if ( stricmp( type, "ftp_proxy" ) == 0 ) { ftpProxy = val; if ( lineStr.startsWith( "#" ) ) ftpProxyEnabled = false; else ftpProxyEnabled = true; } if ( stricmp( type, "proxy_username" ) == 0 ) proxyUsername = val; if ( stricmp( type, "proxy_password" ) == 0 ) proxyPassword = val; } } } fclose( fp ); reloadServerData( ); } void DataManager :: reloadServerData( ) { emit progressSetSteps( serverList.count() ); emit progressSetMessage( tr( "Reading configuration..." ) ); QString serverName; int i = 0; Server *server; QListIterator<Server> it( serverList ); for ( ; it.current(); ++it ) { server = it.current(); serverName = server->getServerName(); i++; emit progressUpdate( i ); qApp->processEvents(); // 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 ( serverName == LOCAL_SERVER ) server->readStatusFile( destList ); else if ( serverName == LOCAL_IPKGS ) server->readLocalIpks( getServer( LOCAL_SERVER ) ); else server->readPackageFile( getServer( LOCAL_SERVER ) ); } } void DataManager :: writeOutIpkgConf() { + QFile f( IPKG_CONF ); + if ( !f.open( IO_WriteOnly ) ) + { + return; + } + + QTextStream t( &f ); +/* 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; +*/ + t << "# Written by AQPkg\n"; + t << "# Must have one or more source entries of the form:\n"; + t << "#\n"; + t << "# src <src-name> <source-url>\n"; + t << "#\n"; + t << "# and one or more destination entries of the form:\n"; + t << "#\n"; + t << "# dest <dest-name> <target-path>\n"; + t << "#\n"; + t << "# where <src-name> and <dest-names> are identifiers that\n"; + t << "# should match [a-zA-Z0-9._-]+, <source-url> should be a\n"; + t << "# URL that points to a directory containing a Familiar\n"; + t << "# Packages file, and <target-path> should be a directory\n"; + t << "# that exists on the target system.\n\n"; // Write out servers Server *server; QListIterator<Server> it( serverList ); while ( it.current() ) { server = it.current(); QString alias = server->getServerName(); // Don't write out local as its a dummy if ( alias != LOCAL_SERVER && alias != LOCAL_IPKGS ) { QString url = server->getServerUrl();; if ( !server->isServerActive() ) - out << "#"; - out << "src " << alias << " " << url << endl; + t << "#"; + t << "src " << alias << " " << url << endl; } ++it; } - out << endl; + t << endl; // Write out destinations QListIterator<Destination> it2( destList ); while ( it2.current() ) { - out << "dest " << it2.current()->getDestinationName() << " " << it2.current()->getDestinationPath() << endl; + t << "dest " << it2.current()->getDestinationName() << " " << it2.current()->getDestinationPath() << endl; ++it2; } - out << endl; - out << "# Proxy Support" << endl; + t << endl; + t << "# Proxy Support\n"; if ( !httpProxyEnabled && httpProxy == "" ) - out << "#option http_proxy http://proxy.tld:3128" << endl; + t << "#option http_proxy http://proxy.tld:3128\n"; else { if ( !httpProxyEnabled ) - out << "#"; - out << "option http_proxy " << httpProxy << endl; + t << "#"; + t << "option http_proxy " << httpProxy << endl; } if ( !ftpProxyEnabled && ftpProxy == "" ) - out << "#option ftp_proxy http://proxy.tld:3128" << endl; + t << "#option ftp_proxy http://proxy.tld:3128\n"; else { if ( !ftpProxyEnabled ) - out << "#"; - out << "option ftp_proxy " << ftpProxy << endl; + t << "#"; + t << "option ftp_proxy " << ftpProxy << endl; } if ( proxyUsername == "" || (!httpProxyEnabled && !ftpProxyEnabled) ) - out << "#option proxy_username <username>" << endl; + t << "#option proxy_username <username>\n"; else - out << "option proxy_username " << proxyUsername << endl; + t << "option proxy_username " << proxyUsername << endl; if ( proxyPassword == "" || (!httpProxyEnabled && !ftpProxyEnabled) ) - out << "#option proxy_password <password>" << endl << endl; + t << "#option proxy_password <password>\n\n"; 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; + t << "option proxy_password " << proxyPassword << endl<< endl; + t << "# Offline mode (for use in constructing flash images offline)\n"; + t << "#option offline_root target\n"; - out.close(); + f.close(); } void DataManager :: setAvailableCategories( QString section ) { - section = section.lower(); - if ( availableCategories.find( "#" + section + "#" ) == -1 ) - availableCategories += section + "#"; + QString sectstr = "#"; + sectstr.append( section.lower() ); + sectstr.append( "#" ); + if ( availableCategories.find( sectstr ) == -1 ) + { + availableCategories.append( section ); + availableCategories.append( "#" ); + } } diff --git a/noncore/settings/aqpkg/datamgr.h b/noncore/settings/aqpkg/datamgr.h index 7fa42c1..32a1e57 100644 --- a/noncore/settings/aqpkg/datamgr.h +++ b/noncore/settings/aqpkg/datamgr.h @@ -1,99 +1,111 @@ -/*************************************************************************** - 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. * - * * - ***************************************************************************/ +/* + This file is part of the OPIE Project + + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #ifndef DATAMGR_H #define DATAMGR_H #include <map> using namespace std; #include <qlist.h> #include <qobject.h> #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 QObject { Q_OBJECT public: DataManager(); ~DataManager(); void setActiveServer( const QString &act ) { activeServer = act; } QString &getActiveServer( ) { return activeServer; } Server *getLocalServer() { return ( getServer( LOCAL_SERVER ) ); } QList<Server> &getServerList() { return serverList; } Server *getServer( const char *name ); QList<Destination> &getDestinationList() { return destList; } Destination *getDestination( const char *name ); void loadServers(); void reloadServerData( ); void writeOutIpkgConf(); static QString getAvailableCategories() { return availableCategories; } static void setAvailableCategories( QString section ); QString getHttpProxy() { return httpProxy; } QString getFtpProxy() { return ftpProxy; } QString getProxyUsername() { return proxyUsername; } QString getProxyPassword() { return proxyPassword; } bool getHttpProxyEnabled() { return httpProxyEnabled; } bool getFtpProxyEnabled() { return ftpProxyEnabled; } void setHttpProxy( QString proxy ) { httpProxy = proxy; } void setFtpProxy( QString proxy ) { ftpProxy = proxy; } void setProxyUsername( QString name ) { proxyUsername = name; } void setProxyPassword( QString pword ) { proxyPassword = pword; } void setHttpProxyEnabled( bool val ) { httpProxyEnabled = val; } void setFtpProxyEnabled( bool val ) { ftpProxyEnabled = val; } private: static QString availableCategories; QString activeServer; QString httpProxy; QString ftpProxy; QString proxyUsername; QString proxyPassword; bool httpProxyEnabled; bool ftpProxyEnabled; QList<Server> serverList; QList<Destination> destList; signals: void progressSetSteps( int ); void progressSetMessage( const QString & ); void progressUpdate( int ); }; #endif diff --git a/noncore/settings/aqpkg/destination.cpp b/noncore/settings/aqpkg/destination.cpp index 45bdb48..6423894 100644 --- a/noncore/settings/aqpkg/destination.cpp +++ b/noncore/settings/aqpkg/destination.cpp @@ -1,30 +1,42 @@ -/*************************************************************************** - destination.cpp - description - ------------------- - begin : Mon Aug 26 2002 - copyright : (C) 2002 by Andy Qua - email : andy.qua@blueyonder.co.uk - ***************************************************************************/ +/* + This file is part of the OPIE Project -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #include "destination.h" #include "global.h" Destination::Destination( const char *name, const char *path ) { destName = name; destPath = path; linkToRootDir = true; } Destination::~Destination() { } diff --git a/noncore/settings/aqpkg/destination.h b/noncore/settings/aqpkg/destination.h index 646fae9..4a7f706 100644 --- a/noncore/settings/aqpkg/destination.h +++ b/noncore/settings/aqpkg/destination.h @@ -1,45 +1,58 @@ -/*************************************************************************** - destination.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. * - * * - ***************************************************************************/ +/* + This file is part of the OPIE Project + + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + #ifndef DESTINATION_H #define DESTINATION_H #include <qstring.h> class Destination { public: Destination() {} Destination( const char *name, const char *path ); ~Destination(); void setDestinationName( const QString &name ) { destName = name; } void setDestinationPath( const QString &path ) { destPath = path; } void linkToRoot( bool val ) { linkToRootDir = val; } bool linkToRoot() { return linkToRootDir; } QString &getDestinationName() { return destName; } QString &getDestinationPath() { return destPath; } protected: private: QString destName; QString destPath; bool linkToRootDir; }; #endif diff --git a/noncore/settings/aqpkg/global.h b/noncore/settings/aqpkg/global.h index 920b090..4fdd51d 100644 --- a/noncore/settings/aqpkg/global.h +++ b/noncore/settings/aqpkg/global.h @@ -1,80 +1,92 @@ -/*************************************************************************** - 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. * - * * - ***************************************************************************/ +/* + This file is part of the OPIE Project + + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #ifndef __GLOBAL_H #define __GLOBAL_H #define VERSION_TEXT "AQPkg Version 1.11" // 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/data/ipkg.conf" #define ROOT "/home/andy/projects/aqpkg/data/root" #define IPKG_DIR "/home/andy/projects/aqpkg/data/" #endif #else // Running QT on a X86 linux box #define IPKG_CONF "/home/andy/projects/aqpkg/data/ipkg.conf" #define ROOT "/home/andy/projects/aqpkg/data/root" #define IPKG_DIR "/home/andy/projects/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/inputdlg.cpp b/noncore/settings/aqpkg/inputdlg.cpp index 724a891..06e934c 100644 --- a/noncore/settings/aqpkg/inputdlg.cpp +++ b/noncore/settings/aqpkg/inputdlg.cpp @@ -1,112 +1,125 @@ -/*************************************************************************** - inputdlg.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. * - * * - ***************************************************************************/ +/* + This file is part of the OPIE Project + + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + #include <qlayout.h> #include <qlabel.h> #include <qlineedit.h> #include <qpushbutton.h> #include <qspinbox.h> #include <qcombobox.h> #include <qwidgetstack.h> #include <qvalidator.h> #include <qapplication.h> #include "inputdlg.h" #include "global.h" InputDialog :: InputDialog( const QString &label, QWidget* parent, const char* name, bool modal ) : QDialog( parent, name, modal ) { lineEdit = 0; QVBoxLayout *vbox = new QVBoxLayout( this, 6, 6 ); QLabel* l = new QLabel( label, this ); vbox->addWidget( l ); lineEdit = new QLineEdit( this ); vbox->addWidget( lineEdit ); QHBoxLayout *hbox = new QHBoxLayout( 6 ); vbox->addLayout( hbox, AlignRight ); ok = new QPushButton( tr( "&OK" ), this ); ok->setDefault( TRUE ); QPushButton *cancel = new QPushButton( tr( "&Cancel" ), this ); QSize bs( ok->sizeHint() ); if ( cancel->sizeHint().width() > bs.width() ) bs.setWidth( cancel->sizeHint().width() ); ok->setFixedSize( bs ); cancel->setFixedSize( bs ); hbox->addWidget( new QWidget( this ) ); hbox->addWidget( ok ); hbox->addWidget( cancel ); connect( lineEdit, SIGNAL( returnPressed() ), this, SLOT( tryAccept() ) ); connect( lineEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( textChanged( const QString & ) ) ); connect( ok, SIGNAL( clicked() ), this, SLOT( accept() ) ); connect( cancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); resize( QMAX( sizeHint().width(), 240 ), sizeHint().height() ); } /*! Destructor. */ InputDialog::~InputDialog() { } void InputDialog :: setText( const QString &text ) { lineEdit->setText( text ); lineEdit->selectAll(); } QString InputDialog :: getText() { return lineEdit->text(); } QString InputDialog::getText( const QString &caption, const QString &label, const QString &text, bool *ok, QWidget *parent, const char *name ) { InputDialog *dlg = new InputDialog( label, parent, name, true ); dlg->setCaption( caption ); dlg->setText( text ); QString result; *ok = dlg->exec() == QDialog::Accepted; if ( *ok ) result = dlg->getText(); delete dlg; return result; } void InputDialog :: textChanged( const QString &s ) diff --git a/noncore/settings/aqpkg/inputdlg.h b/noncore/settings/aqpkg/inputdlg.h index 1e0c5bc..260201e 100644 --- a/noncore/settings/aqpkg/inputdlg.h +++ b/noncore/settings/aqpkg/inputdlg.h @@ -1,50 +1,62 @@ -/*************************************************************************** - inputdlg.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. * - * * - ***************************************************************************/ +/* + This file is part of the OPIE Project + + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #ifndef INPUTDIALOG_H #define INPUTDIALOG_H #include <qdialog.h> #include <qstring.h> #include <qlineedit.h> #include <qpushbutton.h> class InputDialog : public QDialog { Q_OBJECT public: static QString getText( const QString &caption, const QString &label, const QString &text = QString::null, bool *ok = 0, QWidget *parent = 0, const char *name = 0 ); InputDialog( const QString &label, QWidget* parent = 0, const char* name = 0, bool modal = TRUE ); ~InputDialog(); void setText( const QString &text ); QString getText(); private slots: void textChanged( const QString &s ); void tryAccept(); private: QLineEdit *lineEdit; QPushButton *ok; }; #endif // INPUTDIALOG_H diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp index 896e370..17f7b08 100644 --- a/noncore/settings/aqpkg/installdlgimpl.cpp +++ b/noncore/settings/aqpkg/installdlgimpl.cpp @@ -1,112 +1,124 @@ -/*************************************************************************** - installdlgimpl.cpp - 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. * - * * - ***************************************************************************/ +/* + This file is part of the OPIE Project + + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #include <stdio.h> #include <opie/ofiledialog.h> #ifdef QWS #include <qpe/config.h> #include <qpe/fileselector.h> #include <qpe/qpeapplication.h> #include <qpe/resource.h> #include <qpe/storage.h> #endif #include <qcheckbox.h> #include <qcombobox.h> #include <qdialog.h> #include <qfileinfo.h> #include <qgroupbox.h> #include <qmultilineedit.h> #include <qlabel.h> #include <qlayout.h> #include <qpushbutton.h> #include "datamgr.h" #include "destination.h" #include "instoptionsimpl.h" #include "installdlgimpl.h" #include "ipkg.h" #include "utils.h" #include "global.h" enum { MAXLINES = 100, }; InstallDlgImpl::InstallDlgImpl( const QList<InstallData> &packageList, DataManager *dataManager, const char *title ) : QWidget( 0, 0, 0 ) { setCaption( title ); init( TRUE ); pIpkg = 0; upgradePackages = false; dataMgr = dataManager; QString defaultDest = "root"; #ifdef QWS Config cfg( "aqpkg" ); cfg.setGroup( "settings" ); defaultDest = cfg.readEntry( "dest", "root" ); // Grab flags - Turn MAKE_LINKS on by default (if no flags found) flags = cfg.readNumEntry( "installFlags", 0 ); infoLevel = cfg.readNumEntry( "infoLevel", 1 ); #else flags = 0; #endif // Output text is read only output->setReadOnly( true ); // QFont f( "helvetica" ); // f.setPointSize( 10 ); // output->setFont( f ); // setup destination data int defIndex = 0; int i; QListIterator<Destination> dit( dataMgr->getDestinationList() ); for ( i = 0; dit.current(); ++dit, ++i ) { destination->insertItem( dit.current()->getDestinationName() ); if ( dit.current()->getDestinationName() == defaultDest ) defIndex = i; } destination->setCurrentItem( defIndex ); QListIterator<InstallData> it( packageList ); // setup package data QString remove = tr( "Remove\n" ); QString install = tr( "Install\n" ); QString upgrade = tr( "Upgrade\n" ); for ( ; it.current(); ++it ) { InstallData *item = it.current(); InstallData *newitem = new InstallData(); newitem->option = item->option; newitem->packageName = item->packageName; newitem->destination = item->destination; newitem->recreateLinks = item->recreateLinks; packages.append( newitem ); if ( item->option == "I" ) { diff --git a/noncore/settings/aqpkg/installdlgimpl.h b/noncore/settings/aqpkg/installdlgimpl.h index 9a7dbff..894465a 100644 --- a/noncore/settings/aqpkg/installdlgimpl.h +++ b/noncore/settings/aqpkg/installdlgimpl.h @@ -1,86 +1,99 @@ -/*************************************************************************** - installdlgimpl.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. * - * * - ***************************************************************************/ +/* + This file is part of the OPIE Project + + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + #ifndef INSTALLDLGIMPL_H #define INSTALLDLGIMPL_H using namespace std; #include <qlist.h> #include <qstring.h> #include <qwidget.h> class QComboBox; class QLabel; class QMultiLineEdit; class QPushButton; class DataManager; class Destination; class Ipkg; class InstallData { public: QString option; // I - install, D - delete, R- reinstall U - upgrade QString packageName; Destination *destination; bool recreateLinks; }; class InstallDlgImpl : public QWidget { Q_OBJECT public: InstallDlgImpl( const QList<InstallData> &packageList, DataManager *dataManager, const char *title = 0 ); InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title = 0 ); ~InstallDlgImpl(); bool upgradeServer( QString &server ); protected: private: DataManager *dataMgr; QList<InstallData> packages; bool firstPackage; int flags; int infoLevel; Ipkg *pIpkg; bool upgradePackages; QComboBox *destination; QPushButton *btnInstall; QPushButton *btnOptions; QMultiLineEdit *output; QLabel *txtAvailableSpace; void init( bool ); bool runIpkg( QString &option, const QString& package, const QString& dest, int flags ); signals: void reloadData( InstallDlgImpl * ); public slots: void optionsSelected(); void installSelected(); void displayText(const QString &text ); void displayAvailableSpace( const QString &text); void ipkgFinished(); }; #endif diff --git a/noncore/settings/aqpkg/instoptionsimpl.cpp b/noncore/settings/aqpkg/instoptionsimpl.cpp index 72d794f..9d52013 100644 --- a/noncore/settings/aqpkg/instoptionsimpl.cpp +++ b/noncore/settings/aqpkg/instoptionsimpl.cpp @@ -1,112 +1,124 @@ -/*************************************************************************** - instoptionsimpl.cpp - 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. * - * * - ***************************************************************************/ +/* + This file is part of the OPIE Project + + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #ifdef QWS #include <qpe/config.h> #endif #include <qcheckbox.h> #include <qcombobox.h> #include <qgroupbox.h> #include <qlabel.h> #include <qlayout.h> #include "global.h" #include "instoptionsimpl.h" #include "ipkg.h" InstallOptionsDlgImpl::InstallOptionsDlgImpl( int flags, int verb, QWidget * parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl ) { setCaption( tr( "Options" ) ); QVBoxLayout *layout = new QVBoxLayout( this ); layout->setMargin( 2 ); layout->setSpacing( 4 ); QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Options" ), this ); grpbox->layout()->setSpacing( 2 ); grpbox->layout()->setMargin( 4 ); layout->addWidget( grpbox ); QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); forceDepends = new QCheckBox( tr( "Force Depends" ), grpbox ); grplayout->addWidget( forceDepends ); forceReinstall = new QCheckBox( tr( "Force Reinstall" ), grpbox ); grplayout->addWidget( forceReinstall ); forceRemove = new QCheckBox( tr( "Force Remove" ), grpbox ); grplayout->addWidget( forceRemove ); forceOverwrite = new QCheckBox( tr( "Force Overwrite" ), grpbox ); grplayout->addWidget( forceOverwrite ); QLabel *l = new QLabel( tr( "Information Level" ), grpbox ); grplayout->addWidget( l ); verboseIpkg = new QComboBox( grpbox ); verboseIpkg->insertItem( tr( "Errors only" ) ); verboseIpkg->insertItem( tr( "Normal messages" ) ); verboseIpkg->insertItem( tr( "Informative messages" ) ); verboseIpkg->insertItem( tr( "Troubleshooting output" ) ); verboseIpkg->setCurrentItem( verb ); grplayout->addWidget( verboseIpkg ); grplayout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); if ( flags & FORCE_DEPENDS ) forceDepends->setChecked( true ); if ( flags & FORCE_REINSTALL ) forceReinstall->setChecked( true ); if ( flags & FORCE_REMOVE ) forceRemove->setChecked( true ); if ( flags & FORCE_OVERWRITE ) forceOverwrite->setChecked( true ); // if ( flags & VERBOSE_WGET ) // verboseWget->setChecked( true ); // if ( flags & MAKE_LINKS ) // makeLinks->setChecked( true ); showMaximized(); } InstallOptionsDlgImpl::~InstallOptionsDlgImpl() { } int InstallOptionsDlgImpl :: getFlags() { int flags = 0; if ( forceDepends->isChecked() ) flags |= FORCE_DEPENDS; if ( forceReinstall->isChecked() ) flags |= FORCE_REINSTALL; if ( forceRemove->isChecked() ) flags |= FORCE_REMOVE; if ( forceOverwrite->isChecked() ) flags |= FORCE_OVERWRITE; if ( verboseWget->isChecked() ) flags |= VERBOSE_WGET; return flags; } diff --git a/noncore/settings/aqpkg/instoptionsimpl.h b/noncore/settings/aqpkg/instoptionsimpl.h index 1312afd..e68a3dc 100644 --- a/noncore/settings/aqpkg/instoptionsimpl.h +++ b/noncore/settings/aqpkg/instoptionsimpl.h @@ -1,43 +1,56 @@ -/*************************************************************************** - installoptionsimpl.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. * - * * - ***************************************************************************/ +/* + This file is part of the OPIE Project + + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + #ifndef INSTALLOPTIONSIMPL_H #define INSTALLOPTIONSIMPL_H #include <qdialog.h> class QCheckBox; class QComboBox; class InstallOptionsDlgImpl : public QDialog { Q_OBJECT public: InstallOptionsDlgImpl( int, int, QWidget * = 0, const char * = 0, bool = false, WFlags = 0 ); ~InstallOptionsDlgImpl(); int getFlags(); int getInfoLevel(); private: QCheckBox* forceDepends; QCheckBox* forceReinstall; QCheckBox* forceRemove; QCheckBox* forceOverwrite; QCheckBox* verboseWget; QComboBox* verboseIpkg; }; #endif diff --git a/noncore/settings/aqpkg/ipkg.cpp b/noncore/settings/aqpkg/ipkg.cpp index 34999ad..08ae386 100644 --- a/noncore/settings/aqpkg/ipkg.cpp +++ b/noncore/settings/aqpkg/ipkg.cpp @@ -1,112 +1,124 @@ -/*************************************************************************** - 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. * - * * - ***************************************************************************/ +/* + This file is part of the OPIE Project + + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #include <fstream> #include <iostream> #include <vector> 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 <opie/oprocess.h> #include "utils.h" #include "ipkg.h" #include "global.h" Ipkg :: Ipkg() { proc = 0; } 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 "") void Ipkg :: runIpkg() { error = false; QStringList commands; QDir::setCurrent( "/tmp" ); if ( runtimeDir != "" ) { commands << "cd "; commands << runtimeDir; commands << ";"; } commands << "ipkg" << "-V" << QString::number( infoLevel ) << "-force-defaults"; // only set the destination for an install operation if ( option == "install" ) commands << "-dest" << destination; if ( option != "update" && option != "download" ) { if ( flags & FORCE_DEPENDS ) commands << "-force-depends"; if ( flags & FORCE_REINSTALL ) commands << "-force-reinstall"; if ( flags & FORCE_REMOVE ) commands << "-force-removal-of-essential-packages"; if ( flags & FORCE_OVERWRITE ) commands << "-force-overwrite"; if ( infoLevel == 3 ) commands << "-verbose_wget"; // 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 commands << "-f"; commands << IPKG_CONF; #endif if ( option == "reinstall" ) commands << "install"; else commands << option; diff --git a/noncore/settings/aqpkg/ipkg.h b/noncore/settings/aqpkg/ipkg.h index a0d38e3..8f254f9 100644 --- a/noncore/settings/aqpkg/ipkg.h +++ b/noncore/settings/aqpkg/ipkg.h @@ -1,92 +1,104 @@ -/*************************************************************************** - ipkg.h - 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. * - * * - ***************************************************************************/ +/* + This file is part of the OPIE Project + + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #ifndef IPKG_H #define IPKG_H /** *@author Andy Qua */ #include <qobject.h> #include <qstring.h> #include <qstringlist.h> #include <qlist.h> #define FORCE_DEPENDS 0x0001 #define FORCE_REMOVE 0x0002 #define FORCE_REINSTALL 0x0004 #define FORCE_OVERWRITE 0x0008 #define MAKE_LINKS 0x0010 #define VERBOSE_WGET 0x0020 class OProcess; class Ipkg : public QObject { Q_OBJECT public: Ipkg(); ~Ipkg(); void runIpkg(); void createSymLinks(); void setOption( const char *opt ) { option = opt; } void setPackage( const char *pkg ) { package = pkg; } void setDestination( const char *dest ) { destination = dest; } void setDestinationDir( const char *dir ) { destDir = dir; } void setFlags( int fl, int il ) { flags = fl; infoLevel = il; } void setRuntimeDirectory( const char *dir ) { runtimeDir = dir; } signals: void outputText( const QString &text ); void ipkgFinished(); public slots: void commandStdout(OProcess*, char *buffer, int buflen); void commandStderr(OProcess*, char *buffer, int buflen); void processFinished(); void abort(); private: bool createLinks; bool aborted; bool error; QString option; QString package; QString destination; QString destDir; QString runtimeDir; OProcess *proc; int flags; int infoLevel; bool finished; QList<QString> *dependantPackages; int executeIpkgCommand( QStringList &cmd, const QString option ); void removeStatusEntry(); void linkPackage( const QString &packFileName, const QString &dest, const QString &destDir ); QStringList* getList( const QString &packageFilename, const QString &destDir ); void processFileList( const QStringList *fileList, const QString &destDir ); void processLinkDir( const QString &file, const QString &baseDir, const QString &destDir ); }; #endif diff --git a/noncore/settings/aqpkg/letterpushbutton.cpp b/noncore/settings/aqpkg/letterpushbutton.cpp index ca96c6c..c8b43e9 100644 --- a/noncore/settings/aqpkg/letterpushbutton.cpp +++ b/noncore/settings/aqpkg/letterpushbutton.cpp @@ -1,34 +1,46 @@ -/*************************************************************************** - letterpushbutton.cpp - description - ------------------- - begin : Wed Oct 16 2002 - copyright : (C) 2002 by Andy Qua - email : andy.qua@blueyonder.co.uk - ***************************************************************************/ +/* + This file is part of the OPIE Project -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #include "letterpushbutton.h" 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/letterpushbutton.h b/noncore/settings/aqpkg/letterpushbutton.h index e45b89d..452d68e 100644 --- a/noncore/settings/aqpkg/letterpushbutton.h +++ b/noncore/settings/aqpkg/letterpushbutton.h @@ -1,41 +1,53 @@ -/*************************************************************************** - letterpushbutton.h - 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. * - * * - ***************************************************************************/ +/* + This file is part of the OPIE Project + + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #ifndef LETTERPUSHBUTTON_H #define LETTERPUSHBUTTON_H #include <qpushbutton.h> /** *@author Andy Qua */ class LetterPushButton : public QPushButton { Q_OBJECT public: LetterPushButton( const QString & text, QWidget * parent, const char * name=0 ); ~LetterPushButton(); public slots: void released_emmitor(); signals: void released( QString text ); }; #endif diff --git a/noncore/settings/aqpkg/main.cpp b/noncore/settings/aqpkg/main.cpp index 15ef9d6..066d79f 100644 --- a/noncore/settings/aqpkg/main.cpp +++ b/noncore/settings/aqpkg/main.cpp @@ -1,62 +1,71 @@ -/*************************************************************************** - main.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. * - * * - ***************************************************************************/ +/* + This file is part of the OPIE Project + + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #ifdef QWS #include <qpe/qpeapplication.h> #include <qpe/qcopenvelope_qws.h> #else #include <qapplication.h> #endif #include <qobjectdefs.h> #include "mainwin.h" #include "server.h" #include "global.h" int main(int argc, char *argv[]) { -// cout << "Root dir = " << ROOT << endl; #ifdef QWS QPEApplication a( argc, argv ); #else QApplication a( argc, argv ); #endif #ifdef QWS // Disable suspend mode -// cout << "Disabling suspend mode" << endl; QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; #endif MainWindow *win = new MainWindow(); a.setMainWidget(win); win->showMaximized(); a.exec(); #ifdef QWS // Reenable suspend mode -// cout << "Enabling suspend mode" << endl; QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; #endif #ifdef _DEBUG DumpUnfreed(); #endif } diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index f0e8e48..0102292 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp @@ -1,112 +1,124 @@ -/*************************************************************************** - 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. * - * * - ***************************************************************************/ +/* + This file is part of the OPIE Project + + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #include <linux/limits.h> #include <unistd.h> #include <qpe/qcopenvelope_qws.h> #include <qmenubar.h> #include <qpe/qpeapplication.h> #include <qtoolbar.h> #include <qpe/config.h> #include <qpe/resource.h> #include <qaction.h> #include <qcombobox.h> #include <qfile.h> #include <qlabel.h> #include <qlayout.h> #include <qlineedit.h> #include <qlistview.h> #include <qmenubar.h> #include <qmessagebox.h> #include <qpopupmenu.h> #include <qprogressbar.h> #include <qtimer.h> #include <qwhatsthis.h> #include <qwidgetstack.h> #include "categoryfilterimpl.h" #include "datamgr.h" #include "global.h" #include "inputdlg.h" #include "ipkg.h" #include "installdlgimpl.h" #include "letterpushbutton.h" #include "mainwin.h" #include "packagewin.h" #include "settingsimpl.h" #include "utils.h" extern int compareVersions( const char *v1, const char *v2 ); MainWindow :: MainWindow() : QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) { setCaption( tr( "AQPkg - Package Manager" ) ); // Create UI widgets initMainWidget(); initProgressWidget(); // Build menu and tool bars setToolBarsMovable( FALSE ); QToolBar *bar = new QToolBar( this ); bar->setHorizontalStretchable( TRUE ); QMenuBar *mb = new QMenuBar( bar ); mb->setMargin( 0 ); bar = new QToolBar( this ); // Find toolbar findBar = new QToolBar( this ); addToolBar( findBar, QMainWindow::Top, true ); findBar->setHorizontalStretchable( true ); findEdit = new QLineEdit( findBar ); QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); findBar->setStretchableWidget( findEdit ); connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) ); // Quick jump toolbar jumpBar = new QToolBar( this ); addToolBar( jumpBar, QMainWindow::Top, true ); jumpBar->setHorizontalStretchable( true ); QWidget *w = new QWidget( jumpBar ); jumpBar->setStretchableWidget( w ); QGridLayout *layout = new QGridLayout( w ); char text[2]; text[1] = '\0'; for ( int i = 0 ; i < 26 ; ++i ) { text[0] = 'A' + i; LetterPushButton *b = new LetterPushButton( text, w ); connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); layout->addWidget( b, i / 13, i % 13); } QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 ); a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) ); connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) ); a->addTo( jumpBar ); jumpBar->hide(); // Packages menu QPopupMenu *popup = new QPopupMenu( this ); a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); @@ -209,193 +221,192 @@ MainWindow :: MainWindow() findBar->hide(); // Create widget stack and add UI widgets stack = new QWidgetStack( this ); stack->addWidget( progressWindow, 2 ); stack->addWidget( networkPkgWindow, 1 ); setCentralWidget( stack ); stack->raiseWidget( progressWindow ); // Delayed call to finish initialization QTimer::singleShot( 100, this, SLOT( init() ) ); } MainWindow :: ~MainWindow() { delete mgr; } void MainWindow :: initMainWidget() { networkPkgWindow = new QWidget( this ); QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); serversList = new QComboBox( networkPkgWindow ); connect( serversList, SIGNAL(activated(int)), this, SLOT(serverSelected(int)) ); QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); installedIcon = Resource::loadPixmap( "installed" ); updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); packagesList = new QListView( networkPkgWindow ); packagesList->addColumn( tr( "Packages" ), 225 ); QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) ); QPEApplication::setStylusOperation( packagesList->viewport(), QPEApplication::RightOnHold ); connect( packagesList, SIGNAL(rightButtonPressed(QListViewItem *,const QPoint &,int)), this, SLOT(slotDisplayPackage(QListViewItem *)) ); QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); hbox1->addWidget( l ); hbox1->addWidget( serversList ); vbox->addWidget( packagesList ); downloadEnabled = TRUE; } void MainWindow :: initProgressWidget() { progressWindow = new QWidget( this ); QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); m_status = new QLabel( progressWindow ); m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); layout->addWidget( m_status ); m_progress = new QProgressBar( progressWindow ); layout->addWidget( m_progress ); } void MainWindow :: init() { #ifdef QWS // read download directory from config file Config cfg( "aqpkg" ); cfg.setGroup( "settings" ); currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); // showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); #endif stack->raiseWidget( progressWindow ); mgr = new DataManager(); connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), this, SLOT( setProgressMessage( const QString & ) ) ); connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); mgr->loadServers(); showUninstalledPkgs = false; showInstalledPkgs = false; showUpgradedPkgs = false; categoryFilterEnabled = false; updateData(); stack->raiseWidget( networkPkgWindow ); } void MainWindow :: setDocument( const QString &doc ) { // Remove path from package QString package = Utils::getPackageNameFromIpkFilename( doc ); -// std::cout << "Selecting package " << package << std::endl; // First select local server for ( int i = 0 ; i < serversList->count() ; ++i ) { if ( serversList->text( i ) == LOCAL_IPKGS ) { serversList->setCurrentItem( i ); break; } } 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( package ) ) { item->setOn( true ); break; } } } void MainWindow :: displaySettings() { SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); if ( dlg->showDlg() ) { stack->raiseWidget( progressWindow ); updateData(); stack->raiseWidget( networkPkgWindow ); } delete dlg; } void MainWindow :: closeEvent( QCloseEvent *e ) { // If install dialog is visible, return to main view, otherwise close app QWidget *widget = stack->visibleWidget(); if ( widget != networkPkgWindow && widget != progressWindow ) { if ( widget ) delete widget; stack->raiseWidget( networkPkgWindow ); e->ignore(); } else { e->accept(); } } void MainWindow :: displayFindBar() { findBar->show(); findEdit->setFocus(); } void MainWindow :: displayJumpBar() { jumpBar->show(); } void MainWindow :: repeatFind() { searchForPackage( findEdit->text() ); } void MainWindow :: findPackage( const QString &text ) { actionFindNext->setEnabled( !text.isEmpty() ); searchForPackage( text ); } void MainWindow :: hideFindBar() { findBar->hide(); } void MainWindow :: hideJumpBar() { jumpBar->hide(); } void MainWindow :: filterUninstalledPackages() { showUninstalledPkgs = actionUninstalled->isOn(); if ( showUninstalledPkgs ) { showInstalledPkgs = FALSE; showUpgradedPkgs = FALSE; } serverSelected( -1 ); @@ -461,368 +472,360 @@ void MainWindow :: filterCategory() { actionFilter->setOn( filterByCategory( TRUE ) ); } } bool MainWindow :: filterByCategory( bool val ) { if ( val ) { if ( categoryFilter == "" ) { if ( !setFilterCategory() ) return false; } categoryFilterEnabled = true; serverSelected( -1 ); return true; } else { // Turn off filter categoryFilterEnabled = false; serverSelected( -1 ); return false; } } void MainWindow :: raiseMainWidget() { stack->raiseWidget( networkPkgWindow ); } void MainWindow :: raiseProgressWidget() { stack->raiseWidget( progressWindow ); } void MainWindow :: enableUpgrade( bool enabled ) { actionUpgrade->setEnabled( enabled ); } void MainWindow :: enableDownload( bool enabled ) { if ( enabled ) { actionDownload->setIconSet( iconDownload ); actionDownload->setText( tr( "Download" ) ); actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); } else { actionDownload->setIconSet( iconRemove ); actionDownload->setText( tr( "Remove" ) ); actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); } } void MainWindow :: setProgressSteps( int numsteps ) { m_progress->setTotalSteps( numsteps ); } void MainWindow :: setProgressMessage( const QString &msg ) { m_status->setText( msg ); } void MainWindow :: updateProgress( int progress ) { m_progress->setProgress( progress ); } void MainWindow :: updateData() { m_progress->setTotalSteps( mgr->getServerList().count() ); serversList->clear(); packagesList->clear(); int activeItem = -1; int i = 0; QString serverName; QListIterator<Server> it( mgr->getServerList() ); Server *server; for ( ; it.current(); ++it, ++i ) { server = it.current(); serverName = server->getServerName(); m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); m_progress->setProgress( i ); qApp->processEvents(); -// cout << "Adding " << it->getServerName() << " to combobox" << endl; if ( !server->isServerActive() ) { -// cout << serverName << " is not active" << endl; i--; continue; } serversList->insertItem( serverName ); if ( serverName == currentlySelectedServer ) activeItem = i; } // set selected server to be active server if ( activeItem != -1 ) serversList->setCurrentItem( activeItem ); serverSelected( 0, FALSE ); } void MainWindow :: serverSelected( int index ) { serverSelected( index, TRUE ); } void MainWindow :: serverSelected( int, bool raiseProgress ) { QPixmap nullIcon( installedIcon.size() ); nullIcon.fill( colorGroup().base() ); // display packages QString serverName = serversList->currentText(); currentlySelectedServer = serverName; Server *s = mgr->getServer( serverName ); QList<Package> &list = s->getPackageList(); QListIterator<Package> it( list ); // Display progress widget while loading list bool doProgress = ( list.count() > 200 ); if ( doProgress ) { if ( raiseProgress ) { stack->raiseWidget( progressWindow ); } m_progress->setTotalSteps( list.count() ); m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); } packagesList->clear(); #ifdef QWS // read download directory from config file Config cfg( "aqpkg" ); cfg.setGroup( "settings" ); cfg.writeEntry( "selectedServer", currentlySelectedServer ); #endif int i = 0; Package *package; for ( ; it.current(); ++it ) { // Update progress after every 100th package (arbitrary value, seems to give good balance) i++; if ( ( i % 100 ) == 0 ) { if ( doProgress ) { m_progress->setProgress( i ); } qApp->processEvents(); } QString text = ""; package = it.current(); // Apply show only uninstalled packages filter if ( showUninstalledPkgs && package->isInstalled() ) continue; // Apply show only installed packages filter if ( showInstalledPkgs && !package->isInstalled() ) continue; // Apply show only new installed packages filter if ( showUpgradedPkgs ) { if ( !package->isInstalled() || !package->getNewVersionAvailable() ) continue; } // Apply the section filter if ( categoryFilterEnabled && categoryFilter != "" ) { if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 ) continue; } // If the local server, only display installed packages if ( serverName == LOCAL_SERVER && !package->isInstalled() ) continue; QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), QCheckListItem::CheckBox ); if ( package->isInstalled() ) { // If a different version of package is available, show update available icon // Otherwise, show installed icon if ( package->getNewVersionAvailable()) { item->setPixmap( 0, updatedIcon ); } else { item->setPixmap( 0, installedIcon ); } } else { item->setPixmap( 0, nullIcon ); } packagesList->insertItem( item ); } // If the local server or the local ipkgs server disable the download button if ( serverName == LOCAL_SERVER ) { downloadEnabled = TRUE; actionUpgrade->setEnabled( FALSE ); } else if ( serverName == LOCAL_IPKGS ) { downloadEnabled = FALSE; actionUpgrade->setEnabled( FALSE ); } else { downloadEnabled = TRUE; actionUpgrade->setEnabled( TRUE ); } enableDownload( downloadEnabled ); // Display this widget once everything is done if ( doProgress && raiseProgress ) { stack->raiseWidget( networkPkgWindow ); } } void MainWindow :: searchForPackage( const QString &text ) { if ( !text.isEmpty() ) { -// cout << "searching for " << text << endl; // look through package list for text startng at current position -// vector<InstallData> workingPackages; QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); -// if ( start != 0 ) -// start = (QCheckListItem *)start->nextSibling(); if ( start == 0 ) start = (QCheckListItem *)packagesList->firstChild(); for ( QCheckListItem *item = start; item != 0 ; item = (QCheckListItem *)item->nextSibling() ) { -// cout << "checking " << item->text().lower() << endl; if ( item->text().lower().find( text ) != -1 ) { -// cout << "matched " << item->text() << endl; packagesList->ensureItemVisible( item ); packagesList->setCurrentItem( item ); break; } } } } void MainWindow :: updateServer() { QString serverName = serversList->currentText(); // Update the current server // Display dialog // Disable buttons to stop silly people clicking lots on them :) // First, write out ipkg_conf file so that ipkg can use it mgr->writeOutIpkgConf(); Ipkg *ipkg = new Ipkg; ipkg->setOption( "update" ); InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), tr( "Update lists" ) ); connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); reloadDocuments = FALSE; stack->addWidget( dlg, 3 ); stack->raiseWidget( dlg ); // delete progDlg; } void MainWindow :: upgradePackages() { // We're gonna do an upgrade of all packages // First warn user that this isn't recommended // TODO - ODevice???? QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , 0, this ); warn.adjustSize(); if ( warn.exec() == QMessageBox::Yes ) { // First, write out ipkg_conf file so that ipkg can use it mgr->writeOutIpkgConf(); // Now run upgrade Ipkg *ipkg = new Ipkg; ipkg->setOption( "upgrade" ); InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ), tr ( "Upgrade" ) ); connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); reloadDocuments = TRUE; stack->addWidget( dlg, 3 ); stack->raiseWidget( dlg ); } } void MainWindow :: downloadPackage() { bool doUpdate = true; if ( downloadEnabled ) { // See if any packages are selected bool found = false; if ( serversList->currentText() != LOCAL_SERVER ) { for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); item != 0 && !found; item = (QCheckListItem *)item->nextSibling() ) { if ( item->isOn() ) found = true; } } // If user selected some packages then download the and store the locally // otherwise, display dialog asking user what package to download from an http server // and whether to install it if ( found ) downloadSelectedPackages(); else downloadRemotePackage(); } else { doUpdate = false; for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); item != 0 ; item = (QCheckListItem *)item->nextSibling() ) @@ -920,194 +923,192 @@ void MainWindow :: downloadRemotePackage() // grab details from dialog // QString package = dlg.getPackageLocation(); InstallData *item = new InstallData(); item->option = "I"; item->packageName = package; QList<InstallData> workingPackages; workingPackages.setAutoDelete( TRUE ); workingPackages.append( item ); InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); reloadDocuments = TRUE; stack->addWidget( dlg, 3 ); stack->raiseWidget( dlg ); } void MainWindow :: applyChanges() { stickyOption = ""; // First, write out ipkg_conf file so that ipkg can use it mgr->writeOutIpkgConf(); // Now for each selected item // deal with it QList<InstallData> workingPackages; workingPackages.setAutoDelete( TRUE ); for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); item != 0 ; item = (QCheckListItem *)item->nextSibling() ) { if ( item->isOn() ) { workingPackages.append( dealWithItem( item ) ); } } if ( workingPackages.count() == 0 ) { // Nothing to do QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); return; } // do the stuff InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); reloadDocuments = TRUE; stack->addWidget( dlg, 3 ); stack->raiseWidget( dlg ); } // 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 *MainWindow :: dealWithItem( QCheckListItem *item ) { QString name = item->text(); // Get package Server *s = mgr->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 *newitem = new InstallData(); newitem->option = "I"; newitem->packageName = name; return newitem; } else { InstallData *newitem = new InstallData(); newitem->option = "D"; if ( !p->isPackageStoredLocally() ) newitem->packageName = p->getInstalledPackageName(); else newitem->packageName = name; if ( p->getInstalledTo() ) { newitem->destination = p->getInstalledTo(); -// cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; -// cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; } else { newitem->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 newitem->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 = tr( "Do you wish to remove or reinstall\n%1?" ); text = tr( "Remove or ReInstall" ); secondButton = tr( "ReInstall" ); secondOption = tr( "R" ); } else if ( val == 1 ) { // Version available is newer - option to remove or upgrade caption = tr( "Do you wish to remove or upgrade\n%1?" ); text = tr( "Remove or Upgrade" ); secondButton = tr( "Upgrade" ); secondOption = tr( "U" ); } // Sticky option not implemented yet, but will eventually allow // the user to say something like 'remove all' if ( stickyOption == "" ) { QString msgtext; msgtext = caption.arg( ( const char * )name ); switch( QMessageBox::information( this, text, msgtext, tr( "Remove" ), secondButton ) ) { case 0: // Try again or Enter // option 0 = Remove newitem->option = "D"; break; case 1: // Quit or Escape newitem->option = secondOption; break; } } else { // newitem->option = stickyOption; } } // Check if we are reinstalling the same version if ( newitem->option != "R" ) newitem->recreateLinks = true; else newitem->recreateLinks = false; // User hit cancel (on dlg - assume remove) return newitem; } } void MainWindow :: reloadData( InstallDlgImpl *dlg ) { stack->raiseWidget( progressWindow ); if ( dlg ) { dlg->close(); delete dlg; } mgr->reloadServerData(); serverSelected( -1, FALSE ); #ifdef QWS if ( reloadDocuments ) diff --git a/noncore/settings/aqpkg/mainwin.h b/noncore/settings/aqpkg/mainwin.h index f95c332..9f48321 100644 --- a/noncore/settings/aqpkg/mainwin.h +++ b/noncore/settings/aqpkg/mainwin.h @@ -1,112 +1,124 @@ -/*************************************************************************** - mainwin.h - 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. * - * * - ***************************************************************************/ +/* + This file is part of the OPIE Project + + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #ifndef MAINWIN_H #define MAINWIN_H #include <qmainwindow.h> #include <qpixmap.h> class DataManager; class InstallData; class InstallDlgImpl; class QAction; class QCheckListItem; class QComboBox; class QLabel; class QLineEdit; class QListView; class QListViewItem; class QToolBar; class QProgressBar; class QWidgetStack; class MainWindow :public QMainWindow { Q_OBJECT public: MainWindow(); ~MainWindow(); protected: void closeEvent( QCloseEvent* e ); private: DataManager *mgr; QWidgetStack *stack; QToolBar *findBar; QToolBar *jumpBar; QLineEdit *findEdit; QAction *actionFindNext; QAction *actionFilter; QAction *actionUpgrade; QAction *actionDownload; QAction *actionUninstalled; QAction *actionInstalled; QAction *actionUpdated; QPixmap iconDownload; QPixmap iconRemove; int mnuShowUninstalledPkgsId; int mnuShowInstalledPkgsId; int mnuShowUpgradedPkgsId; int mnuFilterByCategory; int mnuSetFilterCategory; // Main package list widget QWidget *networkPkgWindow; QComboBox *serversList; QListView *packagesList; QPixmap installedIcon; QPixmap updatedIcon; QString currentlySelectedServer; QString categoryFilter; QString stickyOption; bool categoryFilterEnabled; bool showJumpTo; bool showUninstalledPkgs; bool showInstalledPkgs; bool showUpgradedPkgs; bool downloadEnabled; bool reloadDocuments; void initMainWidget(); void updateData(); void serverSelected( int index, bool showProgress ); void searchForPackage( const QString & ); bool filterByCategory( bool val ); void downloadSelectedPackages(); void downloadRemotePackage(); InstallData *dealWithItem( QCheckListItem *item ); // Progress widget QWidget *progressWindow; QLabel *m_status; QProgressBar *m_progress; void initProgressWidget(); public slots: void setDocument( const QString &doc ); void displayFindBar(); void displayJumpBar(); diff --git a/noncore/settings/aqpkg/mem.cpp b/noncore/settings/aqpkg/mem.cpp index 405aada..5f32a26 100644 --- a/noncore/settings/aqpkg/mem.cpp +++ b/noncore/settings/aqpkg/mem.cpp @@ -1,106 +1,110 @@ -/***************************************************************************
- mem.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. *
- * *
- ***************************************************************************/
+/* + This file is part of the OPIE Project + + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + #include <stdio.h>
-#include <fstream>
-#include <iostream>
#include <list>
using namespace std;
#define __MEMFILE_C
#include "global.h"
#ifdef _DEBUG
void __cdecl *operator new( unsigned int size, const char *file, int line )
{
void *ptr = (void *)malloc(size);
AddTrack((long)ptr, size, file, line);
return(ptr);
}
void operator delete(void *p)
{
RemoveTrack((long)p);
free(p);
}
#endif
typedef struct {
long address;
long size;
char file[64];
long line;
} ALLOC_INFO;
typedef list<ALLOC_INFO*> AllocList;
AllocList allocList;
void AddTrack(long addr, long asize, const char *fname, long lnum)
{
ALLOC_INFO *info;
info = (ALLOC_INFO *)malloc(sizeof( ALLOC_INFO ));
info->address = addr;
strncpy(info->file, fname, 63);
info->line = lnum;
info->size = asize;
allocList.insert(allocList.begin(), info);
};
void RemoveTrack(long addr)
{
AllocList::iterator i;
bool found = false;
for(i = allocList.begin(); i != allocList.end(); i++)
{
if((*i)->address == addr)
{
allocList.remove((*i));
found = true;
break;
}
}
}
void DumpUnfreed()
{
AllocList::iterator i;
long totalSize = 0;
char buf[1024];
-
-// if(!allocList)
-// return;
-
for(i = allocList.begin(); i != allocList.end(); i++) {
sprintf(buf, "%-15s: LINE %ld, ADDRESS %ld %ld unfreed",
(*i)->file, (*i)->line, (*i)->address, (*i)->size);
- cout <<buf << endl;
totalSize += (*i)->size;
}
sprintf(buf, "-----------------------------------------------------------\n");
- cout <<buf << endl;
sprintf(buf, "Total Unfreed: %ld bytes\n", totalSize);
- cout <<buf << endl;
};
diff --git a/noncore/settings/aqpkg/package.cpp b/noncore/settings/aqpkg/package.cpp index 3395870..4c27c65 100644 --- a/noncore/settings/aqpkg/package.cpp +++ b/noncore/settings/aqpkg/package.cpp @@ -1,112 +1,124 @@ -/*************************************************************************** - package.cpp - 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. * - * * - ***************************************************************************/ +/* + This file is part of the OPIE Project + + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #include "package.h" #include "global.h" Package::Package( QString &name ) { packageName = name; version = "N/A"; description = "N/A"; packageSize = "N/A"; section = "N/A"; localPackage = 0; installed = false; packageStoredLocally = false; installedToRoot = false; installed = false; installedTo = 0; } Package::Package( char *name ) { packageName = name; version = "N/A"; description = "N/A"; packageSize = "N/A"; section = "N/A"; localPackage = 0; installed = false; packageStoredLocally = false; installedToRoot = false; installed = false; installedTo = 0; differentVersionAvailable = false; } Package::~Package() { } QString Package :: toString() { QString ret = "Package - " + getPackageName() + "\n version - " + getVersion(); if ( localPackage ) ret += "\n inst version - " + localPackage->getVersion(); return ret; } void Package :: setStatus( const QString &s ) { QString state_status; int two, three; status = s.simplifyWhiteSpace( ); two = status.find( " " ); // find second column three = status.find( " ", two + 1 ); // find third column state_status = status.mid( three ).stripWhiteSpace( ); if ( state_status == "installed" ) installed = true; } void Package :: setLocalPackage( Package *p ) { localPackage = p; if ( localPackage ) if ( localPackage->getVersion() < getVersion() && !installed ) differentVersionAvailable = true; else differentVersionAvailable = false; } void Package :: setVersion( const QString &v ) { version = v; if ( localPackage ) if ( localPackage->getVersion() < getVersion() && !installed ) differentVersionAvailable = true; else differentVersionAvailable = false; } void Package :: setPackageName( const QString &name ) { packageName = name; diff --git a/noncore/settings/aqpkg/package.h b/noncore/settings/aqpkg/package.h index 110ae91..c72f8b3 100644 --- a/noncore/settings/aqpkg/package.h +++ b/noncore/settings/aqpkg/package.h @@ -1,90 +1,102 @@ -/*************************************************************************** - package.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. * - * * - ***************************************************************************/ +/* + This file is part of the OPIE Project + + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #ifndef PACKAGE_H #define PACKAGE_H #include <stdlib.h> /** *@author Andy Qua */ #include <qstring.h> #include "destination.h" class Package { public: Package( QString &name ); Package( char *name ); ~Package(); void setLocalPackage( Package *p ); void setPackageName( const QString &name ); void setVersion( const QString &v ); void setStatus( const QString &s ); void setDescription( const QString &d ); void setFilename( const QString &f ); void setPackageStoredLocally( bool local ) { packageStoredLocally = local; } void setInstalledToRoot( bool root ) { installedToRoot = root; } void setInstalledTo( Destination *d ) { installedTo = d; } void setDependancies( QString &deps ) { dependancies = deps; } void setPackageSize( const QString &size ) { packageSize = size; } void setSection( const QString §) { section = sect; } Package *getLocalPackage() { return localPackage; } QString getPackageName() { return packageName; } QString getVersion() { return version; } QString getStatus() { return status; } QString getDescription() { return description; } QString getFilename() { return filename; } QString getDependancies() { return dependancies; } QString getPackageSize() { return packageSize; } QString getSection() { return section; } bool getNewVersionAvailable() { return differentVersionAvailable; } bool isInstalled(); bool isPackageStoredLocally() { return packageStoredLocally; } bool isInstalledToRoot() { return installedToRoot; } QString getInstalledVersion(); QString getInstalledPackageName(); Destination *getInstalledTo() { return installedTo; } QString toString(); private: Package *localPackage; QString packageName; QString version; QString status; QString description; QString filename; bool packageStoredLocally; bool installedToRoot; bool installed; bool differentVersionAvailable; QString dependancies; QString packageSize; QString section; Destination *installedTo; }; #endif diff --git a/noncore/settings/aqpkg/packagewin.cpp b/noncore/settings/aqpkg/packagewin.cpp index 7971ccc..9553cd1 100644 --- a/noncore/settings/aqpkg/packagewin.cpp +++ b/noncore/settings/aqpkg/packagewin.cpp @@ -1,119 +1,118 @@ /* This file is part of the OPIE Project - =. - .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> + + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "packagewin.h" #include "package.h" #include "datamgr.h" #include <qpe/resource.h> #include <qlayout.h> #include <qpushbutton.h> #include <qstring.h> #include <qtextview.h> PackageWindow::PackageWindow( Package *package, const QString &server ) : QWidget( 0, 0, 0 ) { QString str; if ( package ) { setCaption( package->getPackageName() ); QString destName; if ( package->getLocalPackage() ) { if ( package->getLocalPackage()->getInstalledTo() ) destName = package->getLocalPackage()->getInstalledTo()->getDestinationName(); } else { if ( package->getInstalledTo() ) destName = package->getInstalledTo()->getDestinationName(); } if ( !package->isPackageStoredLocally() ) { str.append( tr( "<b>Description</b> - " ) ); str.append( package->getDescription() ); if ( !destName.isNull() ) { str.append( tr( "<p><b>Installed To</b> - " ) ); str.append( destName ); } str.append( tr( "<p><b>Size</b> - " ) ); str.append( package->getPackageSize() ); str.append( tr( "<p><b>Section</b> - " ) ); str.append( package->getSection() ); } else { str.append( tr( "<p><b>Filename</b> - " ) ); str.append( package->getFilename() ); } if ( server == LOCAL_SERVER ) { str.append( tr( "<p><b>Version Installed</b> - " ) ); str.append( package->getVersion() ); } else { str.append( tr( "<p><b>Version Available</b> - " ) ); str.append( package->getVersion() ); if ( package->getLocalPackage() ) { if ( package->isInstalled() ) { str.append( tr( "<p><b>Version Installed</b> - " ) ); str.append( package->getInstalledVersion() ); } } } } else { setCaption( tr( "Package Information" ) ); str = tr( "Package information is unavailable" ); } QVBoxLayout *layout = new QVBoxLayout( this, 4, 4 ); QTextView *l = new QTextView( str, QString::null, this ); - //l->setTextFormat( Qt::RichText ); - //l->setAlignment( Qt::AlignLeft | Qt::AlignVCenter | Qt::WordBreak ); layout->addWidget( l ); QPushButton *btn = new QPushButton( Resource::loadPixmap( "enter" ), tr( "Close" ), this ); layout->addWidget( btn ); connect( btn, SIGNAL( clicked() ), this, SLOT( close() ) ); } PackageWindow::~PackageWindow() { } diff --git a/noncore/settings/aqpkg/packagewin.h b/noncore/settings/aqpkg/packagewin.h index b4fdcad..83f3849 100644 --- a/noncore/settings/aqpkg/packagewin.h +++ b/noncore/settings/aqpkg/packagewin.h @@ -1,45 +1,46 @@ /* This file is part of the OPIE Project - =. - .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> + + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef PACKAGEWIN_H #define PACKAGEWIN_H #include <qwidget.h> class Package; class PackageWindow :public QWidget { Q_OBJECT public: PackageWindow( Package * = 0x0, const QString & = QString::null ); ~PackageWindow(); }; #endif diff --git a/noncore/settings/aqpkg/server.cpp b/noncore/settings/aqpkg/server.cpp index e2b8096..4693db1 100644 --- a/noncore/settings/aqpkg/server.cpp +++ b/noncore/settings/aqpkg/server.cpp @@ -1,183 +1,191 @@ -/*************************************************************************** - 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. * - * * - ***************************************************************************/ - +/* + This file is part of the OPIE Project + + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #include "server.h" #include "datamgr.h" #include <qfile.h> #include <qtextstream.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; + packageFile.append( "lists/" ); + packageFile.append( serverName ); } Server :: ~Server() { cleanUp(); } void Server :: cleanUp() { packageList.clear(); } void Server :: readStatusFile( QList<Destination> &destList ) { cleanUp(); Destination *dest; QListIterator<Destination> dit( destList ); bool rootRead = false; for ( ; dit.current(); ++dit ) { dest = dit.current(); bool installingToRoot = false; QString path = dest->getDestinationPath(); if ( path.right( 1 ) != "/" ) path.append( "/" ); if ( path == "/" ) { rootRead = true; installingToRoot = true; } packageFile = path; packageFile.append( "usr/lib/ipkg/status" ); readPackageFile( 0, false, installingToRoot, &( *dest ) ); } // 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 ); Package *package = new Package( packageName ); package->setVersion( ver ); package->setFilename( file ); package->setPackageStoredLocally( true ); packageList.append( package ); } #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 ) { QFile f( packageFile ); if ( !f.open( IO_ReadOnly ) ) return; QTextStream t( &f ); QString line; QString key; QString value; int pos; if ( clearAll ) cleanUp(); Package *currPackage = 0; bool newPackage = true; while ( !t.eof() ) { line = t.readLine(); pos = line.find( ':', 0 ); if ( pos > -1 ) key = line.mid( 0, pos ).stripWhiteSpace(); else key = QString::null; value = line.mid( pos+1, line.length()-pos ).stripWhiteSpace(); if ( key == "Package" && newPackage ) { newPackage = false; currPackage = getPackage( value ); if ( !currPackage ) { Package *package = new Package( value ); packageList.append( package ); currPackage = package; currPackage->setInstalledTo( dest ); if ( installingToRoot ) currPackage->setInstalledToRoot( true ); diff --git a/noncore/settings/aqpkg/server.h b/noncore/settings/aqpkg/server.h index 02746e0..f524ed6 100644 --- a/noncore/settings/aqpkg/server.h +++ b/noncore/settings/aqpkg/server.h @@ -1,66 +1,79 @@ -/*************************************************************************** - server.h - description - ------------------- - begin : Mon Aug 26 2002 - copyright : (C) 2002 by Andy Qua - email : andy.qua@blueyonder.co.uk - ***************************************************************************/ +/* + This file is part of the OPIE Project + + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ -/*************************************************************************** - * * - * 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 SERVER_H #define SERVER_H #include <qlist.h> #include <qstring.h> using namespace std; #include "package.h" #include "destination.h" class Server { public: Server() {} Server( const char *name, const char *url ); Server( const char *name, const char *url, const char *file ); ~Server(); void cleanUp(); void readStatusFile( QList<Destination> &v ); void readLocalIpks( Server *local ); void readPackageFile( Server *local = 0, bool clearAll = true, bool installedToRoot= false, Destination *dest = 0 ); void buildLocalPackages( Server *local ); Package *getPackage( const char *name ); Package *getPackage( QString &name ); QString toString(); QList<Package> &getPackageList(); bool isServerActive() { return active; } void setServerName( const QString &name ) { serverName = name; } void setServerUrl( const QString &url ) { serverUrl = url; } void setActive( bool val ) { active = val; } QString &getServerName() { return serverName; } QString &getServerUrl() { return serverUrl; } protected: private: QString serverName; QString serverUrl; QString packageFile; bool active; QList<Package> packageList; }; #endif diff --git a/noncore/settings/aqpkg/settingsimpl.cpp b/noncore/settings/aqpkg/settingsimpl.cpp index e2afada..4887ceb 100644 --- a/noncore/settings/aqpkg/settingsimpl.cpp +++ b/noncore/settings/aqpkg/settingsimpl.cpp @@ -1,112 +1,124 @@ -/*************************************************************************** - 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. * - * * - ***************************************************************************/ +/* + This file is part of the OPIE Project + + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #include <fstream> #include <algorithm> using namespace std; #include <qcheckbox.h> #include <qgroupbox.h> #include <qlabel.h> #include <qlayout.h> #include <qlineedit.h> #include <qlistbox.h> #include <qpushbutton.h> #include <opie/otabwidget.h> #ifdef QWS #include <qpe/config.h> #include <qpe/resource.h> #endif #include "settingsimpl.h" #include "global.h" SettingsImpl :: SettingsImpl( DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl ) { setCaption( tr( "Configuration" ) ); // Setup layout to make everything pretty QVBoxLayout *layout = new QVBoxLayout( this ); layout->setMargin( 2 ); layout->setSpacing( 4 ); // Setup tabs for all info OTabWidget *tabwidget = new OTabWidget( this ); layout->addWidget( tabwidget ); tabwidget->addTab( initServerTab(), "aqpkg/servertab", tr( "Servers" ) ); tabwidget->addTab( initDestinationTab(), "aqpkg/desttab", tr( "Destinations" ) ); tabwidget->addTab( initProxyTab(), "aqpkg/proxytab", tr( "Proxies" ) ); tabwidget->setCurrentTab( tr( "Servers" ) ); dataMgr = dataManager; setupData(); changed = false; newserver = false; newdestination = false; } SettingsImpl :: ~SettingsImpl() { } bool SettingsImpl :: showDlg() { showMaximized(); exec(); if ( changed ) dataMgr->writeOutIpkgConf(); return changed; } QWidget *SettingsImpl :: initServerTab() { QWidget *control = new QWidget( this ); QVBoxLayout *vb = new QVBoxLayout( control ); QScrollView *sv = new QScrollView( control ); vb->addWidget( sv, 0, 0 ); sv->setResizePolicy( QScrollView::AutoOneFit ); sv->setFrameStyle( QFrame::NoFrame ); QWidget *container = new QWidget( sv->viewport() ); sv->addChild( container ); QGridLayout *layout = new QGridLayout( container ); layout->setSpacing( 2 ); layout->setMargin( 4 ); servers = new QListBox( container ); servers->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); connect( servers, SIGNAL( highlighted( int ) ), this, SLOT( editServer( int ) ) ); layout->addMultiCellWidget( servers, 0, 0, 0, 1 ); QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); connect( btn, SIGNAL( clicked() ), this, SLOT( newServer() ) ); layout->addWidget( btn, 1, 0 ); btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); connect( btn, SIGNAL( clicked() ), this, SLOT( removeServer() ) ); layout->addWidget( btn, 1, 1 ); diff --git a/noncore/settings/aqpkg/settingsimpl.h b/noncore/settings/aqpkg/settingsimpl.h index 9ffc259..1530ce1 100644 --- a/noncore/settings/aqpkg/settingsimpl.h +++ b/noncore/settings/aqpkg/settingsimpl.h @@ -1,77 +1,89 @@ -/*************************************************************************** - settingsimpl.h - description - ------------------- - begin : Thu Aug 29 2002 - copyright : (C) 2002 by Andy Qua - email : andy.qua@blueyonder.co.uk - ***************************************************************************/ +/* + This file is part of the OPIE Project -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #include "datamgr.h" #include <qdialog.h> class QCheckBox; class QLineEdit; class QListBox; class SettingsImpl : public QDialog { Q_OBJECT public: SettingsImpl( DataManager *dataManager, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); ~SettingsImpl(); bool showDlg(); private: QListBox *servers; QLineEdit *servername; QLineEdit *serverurl; QCheckBox *active; QListBox *destinations; QLineEdit *destinationname; QLineEdit *destinationurl; QCheckBox *linkToRoot; QLineEdit *txtHttpProxy; QCheckBox *chkHttpProxyEnabled; QLineEdit *txtFtpProxy; QCheckBox *chkFtpProxyEnabled; QLineEdit *txtUsername; QLineEdit *txtPassword; DataManager *dataMgr; QString serverName; QString destinationName; int currentSelectedServer; int currentSelectedDestination; bool changed; bool newserver; bool newdestination; QWidget *initServerTab(); QWidget *initDestinationTab(); QWidget *initProxyTab(); void setupConnections(); void setupData(); public slots: void editServer( int s ); void changeServerDetails(); void newServer(); void removeServer(); void editDestination( int s ); void changeDestinationDetails(); void newDestination(); void removeDestination(); void proxyApplyChanges(); }; diff --git a/noncore/settings/aqpkg/utils.cpp b/noncore/settings/aqpkg/utils.cpp index 446ce39..00607dd 100644 --- a/noncore/settings/aqpkg/utils.cpp +++ b/noncore/settings/aqpkg/utils.cpp @@ -1,96 +1,105 @@ -/*************************************************************************** - utils.cpp - description - ------------------- - begin : Sat Sep 7 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. * - * * - ***************************************************************************/ +/* + This file is part of the OPIE Project + + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #include <stdio.h> #include <sys/vfs.h> -//#include <mntent.h> #include "utils.h" #include "global.h" Utils :: Utils() { } Utils :: ~Utils() { } - QString Utils :: getPathfromIpkFilename( const QString &file ) { int p = file.findRev( "/" ); QString path = ""; if ( p != -1 ) path = file.left( p ); return path; } QString Utils :: getFilenameFromIpkFilename( const QString &file ) { int p = file.findRev( "/" ); QString name = file; if ( p != -1 ) name = name.mid( p + 1 ); return name; } QString Utils :: getPackageNameFromIpkFilename( const QString &file ) { int p = file.findRev( "/" ); QString name = file; if ( p != -1 ) name = name.mid( p + 1 ); p = name.find( "_" ); QString packageName = name.mid( 0, p ); return packageName; } QString Utils :: getPackageVersionFromIpkFilename( const QString &file ) { int p = file.findRev( "/" ); QString name = file; if ( p != -1 ) name = name.mid( p + 1 ); p = name.find( "_" ) + 1; int p2 = name.find( "_", p ); QString version = name.mid( p, p2 - p ); return version; } bool Utils :: getStorageSpace( const char *path, long *blockSize, long *totalBlocks, long *availBlocks ) { bool ret = false; -// qDebug( "Reading from path %s", path ); struct statfs fs; if ( !statfs( path, &fs ) ) { *blockSize = fs.f_bsize; *totalBlocks = fs.f_blocks; *availBlocks = fs.f_bavail; ret = true; } return ret; } diff --git a/noncore/settings/aqpkg/utils.h b/noncore/settings/aqpkg/utils.h index c572f7b..6e5116e 100644 --- a/noncore/settings/aqpkg/utils.h +++ b/noncore/settings/aqpkg/utils.h @@ -1,39 +1,51 @@ -/*************************************************************************** - utils.h - description - ------------------- - begin : Sat Sep 7 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. * - * * - ***************************************************************************/ +/* + This file is part of the OPIE Project + + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> + .=l. Dan Williams <drw@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #ifndef UTILS_H #define UTILS_H #include <qstring.h> /** *@author Andy Qua */ class Utils { public: Utils(); ~Utils(); static QString getPathfromIpkFilename( const QString &file ); static QString getFilenameFromIpkFilename( const QString &file ); static QString getPackageNameFromIpkFilename( const QString &file ); static QString getPackageVersionFromIpkFilename( const QString &file ); static bool getStorageSpace( const char *path, long *blockSize, long *totalBlocks, long *availBlocks ); }; #endif |