-rw-r--r-- | noncore/settings/aqpkg/datamgr.cpp | 19 | ||||
-rw-r--r-- | noncore/settings/aqpkg/datamgr.h | 8 | ||||
-rw-r--r-- | noncore/settings/aqpkg/global.h | 4 | ||||
-rw-r--r-- | noncore/settings/aqpkg/installdlgimpl.cpp | 4 | ||||
-rw-r--r-- | noncore/settings/aqpkg/ipkg.cpp | 139 | ||||
-rw-r--r-- | noncore/settings/aqpkg/main.cpp | 9 | ||||
-rw-r--r-- | noncore/settings/aqpkg/mainwin.cpp | 6 | ||||
-rw-r--r-- | noncore/settings/aqpkg/mem.cpp | 2 | ||||
-rw-r--r-- | noncore/settings/aqpkg/package.cpp | 35 | ||||
-rw-r--r-- | noncore/settings/aqpkg/version.cpp | 39 |
10 files changed, 107 insertions, 158 deletions
diff --git a/noncore/settings/aqpkg/datamgr.cpp b/noncore/settings/aqpkg/datamgr.cpp index cd0c78f..67f90a3 100644 --- a/noncore/settings/aqpkg/datamgr.cpp +++ b/noncore/settings/aqpkg/datamgr.cpp @@ -1,15 +1,15 @@ /* 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; @@ -31,32 +31,35 @@ #include <qpe/config.h> #include <qpe/qpeapplication.h> #else #include <qapplication.h> #endif #include <qfile.h> #include <qtextstream.h> #include "datamgr.h" #include "global.h" +QString LOCAL_SERVER; +QString LOCAL_IPKGS; + 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 ) @@ -128,25 +131,25 @@ void DataManager :: loadServers() { 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; @@ -171,57 +174,57 @@ void DataManager :: loadServers() 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 ) ); + 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 ); */ 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"; @@ -285,25 +288,25 @@ void DataManager :: writeOutIpkgConf() } if ( proxyUsername == "" || (!httpProxyEnabled && !ftpProxyEnabled) ) t << "#option proxy_username <username>\n"; else t << "option proxy_username " << proxyUsername << endl; if ( proxyPassword == "" || (!httpProxyEnabled && !ftpProxyEnabled) ) t << "#option proxy_password <password>\n\n"; else t << "option proxy_password " << proxyPassword << endl<< endl; t << "# Offline mode (for use in constructing flash images offline)\n"; t << "#option offline_root target\n"; - + f.close(); } void DataManager :: setAvailableCategories( QString section ) { QString sectstr = "#"; sectstr.append( section.lower() ); sectstr.append( "#" ); if ( availableCategories.find( sectstr ) == -1 ) { availableCategories.append( section ); diff --git a/noncore/settings/aqpkg/datamgr.h b/noncore/settings/aqpkg/datamgr.h index 32a1e57..9f8920d 100644 --- a/noncore/settings/aqpkg/datamgr.h +++ b/noncore/settings/aqpkg/datamgr.h @@ -1,15 +1,15 @@ /* 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; @@ -31,26 +31,28 @@ #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" +//#define LOCAL_SERVER "Installed Pkgs" +//#define LOCAL_IPKGS "local IPKG" +extern QString LOCAL_SERVER; +extern QString LOCAL_IPKGS; /** *@author Andy Qua */ class DataManager : public QObject { Q_OBJECT public: DataManager(); ~DataManager(); diff --git a/noncore/settings/aqpkg/global.h b/noncore/settings/aqpkg/global.h index 4fdd51d..0325a59 100644 --- a/noncore/settings/aqpkg/global.h +++ b/noncore/settings/aqpkg/global.h @@ -1,15 +1,15 @@ /* 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; @@ -21,25 +21,25 @@ : = ...= . :.=- 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" +//extern QString VERSION_TEXT; // 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" diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp index 17f7b08..ea2c47f 100644 --- a/noncore/settings/aqpkg/installdlgimpl.cpp +++ b/noncore/settings/aqpkg/installdlgimpl.cpp @@ -385,29 +385,27 @@ void InstallDlgImpl :: displayAvailableSpace( const QString &text ) long blockSize = 0; long totalBlocks = 0; long availBlocks = 0; QString space; if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) ) { long mult = blockSize / 1024; long div = 1024 / blockSize; if ( !mult ) mult = 1; if ( !div ) div = 1; -// long total = totalBlocks * mult / div; long avail = availBlocks * mult / div; -// long used = total - avail; - space.sprintf( "%ld Kb", avail ); + space = tr( "%1 Kb" ).arg( avail ); } else space = tr( "Unknown" ); if ( txtAvailableSpace ) txtAvailableSpace->setText( space ); } void InstallDlgImpl :: ipkgFinished() { InstallData *item; if ( firstPackage ) diff --git a/noncore/settings/aqpkg/ipkg.cpp b/noncore/settings/aqpkg/ipkg.cpp index 3df569b..43eaaae 100644 --- a/noncore/settings/aqpkg/ipkg.cpp +++ b/noncore/settings/aqpkg/ipkg.cpp @@ -1,15 +1,15 @@ /* 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; @@ -102,129 +102,129 @@ void Ipkg :: runIpkg() // 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; if ( package != "" ) commands << package; if ( package != "" ) - emit outputText( QString( "Dealing with package " ) + package ); + emit outputText( tr( "Dealing with package %1" ).arg( package) ); qApp->processEvents(); // If we are removing, reinstalling or upgrading packages and make links option is selected // create the links if ( option == "remove" || option == "reinstall" || option == "upgrade" ) { createLinks = false; if ( flags & MAKE_LINKS ) { - emit outputText( QString( "Removing symbolic links...\n" ) ); + emit outputText( tr( "Removing symbolic links...\n" ) ); linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); emit outputText( QString( " " ) ); } } - + // Execute command dependantPackages = new QList<QString>; dependantPackages->setAutoDelete( true ); executeIpkgCommand( commands, option ); } void Ipkg :: createSymLinks() { if ( option == "install" || option == "reinstall" || option == "upgrade" ) { // If we are not removing packages and make links option is selected // create the links createLinks = true; if ( flags & MAKE_LINKS ) { emit outputText( " " ); - emit outputText( QString( "Creating symbolic links for " )+ package ); + emit outputText( tr( "Creating symbolic links for %1." ).arg( package) ); linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); // link dependant packages that were installed with this release QString *pkg; for ( pkg = dependantPackages->first(); pkg != 0; pkg = dependantPackages->next() ) { if ( *pkg == package ) continue; emit outputText( " " ); - emit outputText( QString( "Creating symbolic links for " )+ (*pkg) ); + emit outputText( tr( "Creating symbolic links for %1" ).arg( *pkg ) ); linkPackage( Utils::getPackageNameFromIpkFilename( *pkg ), destination, destDir ); } } } delete dependantPackages; - emit outputText( "Finished" ); + emit outputText( tr("Finished") ); emit outputText( "" ); } void Ipkg :: removeStatusEntry() { QString statusFile = destDir; if ( statusFile.right( 1 ) != "/" ) statusFile.append( "/" ); statusFile.append( "usr/lib/ipkg/status" ); QString outStatusFile = statusFile; outStatusFile.append( ".tmp" ); emit outputText( "" ); - emit outputText( "Removing status entry..." ); - QString tempstr = "status file - "; + emit outputText( tr("Removing status entry...") ); + QString tempstr = tr("status file - "); tempstr.append( statusFile ); emit outputText( tempstr ); - tempstr = "package - "; + tempstr = tr("package - "); tempstr.append( package ); emit outputText( tempstr ); - + ifstream in( statusFile ); ofstream out( outStatusFile ); if ( !in.is_open() ) { - tempstr = "Couldn't open status file - "; + tempstr = tr("Couldn't open status file - "); tempstr.append( statusFile ); emit outputText( tempstr ); return; } if ( !out.is_open() ) { - tempstr = "Couldn't create tempory status file - "; + tempstr = tr("Couldn't create tempory status file - "); tempstr.append( outStatusFile ); emit outputText( tempstr ); return; } char line[1001]; char k[21]; char v[1001]; QString key; QString value; vector<QString> lines; int i = 0; @@ -247,84 +247,84 @@ void Ipkg :: removeStatusEntry() // Ignore all lines up to next empty do { in.getline( line, 1000 ); if ( in.eof() || QString( line ).stripWhiteSpace() == "" ) continue; } while ( !in.eof() && QString( line ).stripWhiteSpace() != "" ); } lines.push_back( QString( line ) ); out << line << endl; - // Improve UI responsiveness + // Improve UI responsiveness i++; if ( ( i % 50 ) == 0 ) qApp->processEvents(); } while ( !in.eof() ); // Write lines out vector<QString>::iterator it; for ( it = lines.begin() ; it != lines.end() ; ++it ) { out << (const char *)(*it) << endl; - - // Improve UI responsiveness + + // Improve UI responsiveness i++; if ( ( i % 50 ) == 0 ) qApp->processEvents(); } - + in.close(); out.close(); // Remove old status file and put tmp stats file in its place remove( statusFile ); rename( outStatusFile, statusFile ); } int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ ) { // If one is already running - should never be but just to be safe if ( proc ) { delete proc; proc = 0; } - + // OK we're gonna use OProcess to run this thing proc = new OProcess(); aborted = false; // Connect up our slots connect(proc, SIGNAL(processExited(OProcess *)), this, SLOT( processFinished())); connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)), this, SLOT(commandStdout(OProcess *, char *, int))); connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)), this, SLOT(commandStderr(OProcess *, char *, int))); - + for ( QStringList::Iterator it = cmd.begin(); it != cmd.end(); ++it ) { *proc << (*it).latin1(); } // Start the process going finished = false; if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) { - emit outputText( QString( "Couldn't start ipkg process" ) ); + emit outputText( tr("Couldn't start ipkg process" ) ); } } void Ipkg::commandStdout(OProcess*, char *buffer, int buflen) { QString lineStr = buffer; if ( lineStr[buflen-1] == '\n' ) buflen --; lineStr = lineStr.left( buflen ); emit outputText( lineStr ); // check if we are installing dependant packages @@ -337,162 +337,96 @@ void Ipkg::commandStdout(OProcess*, char *buffer, int buflen) int start = lineStr.find( " " ) + 1; int end = lineStr.find( " ", start ); QString *package = new QString( lineStr.mid( start, end-start ) ); dependantPackages->append( package ); } } else if ( option == "remove" && !( flags & FORCE_DEPENDS ) && lineStr.find( "is depended upon by packages:" ) != -1 ) { // Ipkg should send this to STDERR, but doesn't - so trap here error = true; } - + buffer[0] = '\0'; } void Ipkg::commandStderr(OProcess*, char *buffer, int buflen) { QString lineStr = buffer; if ( lineStr[buflen-1] == '\n' ) buflen --; lineStr=lineStr.left( buflen ); emit outputText( lineStr ); buffer[0] = '\0'; error = true; } void Ipkg::processFinished() { // Finally, if we are removing a package, remove its entry from the <destdir>/usr/lib/ipkg/status file // to workaround an ipkg bug which stops reinstall to a different location if ( !error && option == "remove" ) removeStatusEntry(); - + delete proc; proc = 0; finished = true; emit ipkgFinished(); } void Ipkg :: abort() { if ( proc ) { proc->kill(); aborted = true; } } -/* -int Ipkg :: executeIpkgCommand( QString &cmd, const QString option ) -{ - FILE *fp = NULL; - char line[130]; - QString lineStr, lineStrOld; - int ret = false; - - fp = popen( (const char *) cmd, "r"); - if ( fp == NULL ) - { - QString text; - text.sprintf( "Couldn't execute %s! See stdout for error code", (const char *)cmd ); - emit outputText( text ); - } - else - { - while ( fgets( line, sizeof line, fp) != NULL ) - { - lineStr = line; - lineStr=lineStr.left( lineStr.length()-1 ); - - if ( lineStr != lineStrOld ) - { - //See if we're finished - if ( option == "install" || option == "reinstall" ) - { - // Need to keep track of any dependant packages that get installed - // so that we can create links to them as necessary - if ( lineStr.startsWith( "Installing " ) ) - { - int start = lineStr.find( " " ) + 1; - int end = lineStr.find( " ", start ); - QString *package = new QString( lineStr.mid( start, end-start ) ); - dependantPackages->append( package ); - } - } - - if ( option == "update" ) - { - if (lineStr.contains("Updated list")) - ret = true; - } - else if ( option == "download" ) - { - if (lineStr.contains("Downloaded")) - ret = true; - } - else - { - if (lineStr.contains("Done")) - ret = true; - } - - emit outputText( lineStr ); - } - lineStrOld = lineStr; - qApp->processEvents(); - } - pclose(fp); - } - - return ret; -} -*/ - void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, const QString &destDir ) { if ( dest == "root" || dest == "/" ) return; - + qApp->processEvents(); QStringList *fileList = getList( packFileName, destDir ); qApp->processEvents(); processFileList( fileList, destDir ); delete fileList; } QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir ) { QString packageFileDir = destDir; packageFileDir.append( "/usr/lib/ipkg/info/" ); packageFileDir.append( packageFilename ); packageFileDir.append( ".list" ); QFile f( packageFileDir ); if ( !f.open(IO_ReadOnly) ) { // Couldn't open from dest, try from / f.close(); - + packageFileDir = "/usr/lib/ipkg/info/"; packageFileDir.append( packageFilename ); packageFileDir.append( ".list" ); f.setName( packageFileDir ); if ( ! f.open(IO_ReadOnly) ) { - QString tempstr = "Could not open :"; + QString tempstr = tr("Could not open :"); tempstr.append( packageFileDir ); emit outputText( tempstr ); return (QStringList*)0; } } QStringList *fileList = new QStringList(); QTextStream t( &f ); while ( !t.eof() ) *fileList += t.readLine(); f.close(); return fileList; @@ -519,80 +453,77 @@ void Ipkg :: processFileList( const QStringList *fileList, const QString &destDi { processLinkDir( (*fileList)[i], baseDir, destDir ); qApp->processEvents(); } } } void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const QString &baseDir ) { QString sourceFile = baseDir; sourceFile.append( file ); - + QString linkFile = destDir; if ( file.startsWith( "/" ) && destDir.right( 1 ) == "/" ) { linkFile.append( file.mid( 1 ) ); - } + } else { linkFile.append( file ); } QString text; if ( createLinks ) { // If this file is a directory (ends with a /) and it doesn't exist, // we need to create it if ( file.right(1) == "/" ) { QFileInfo f( linkFile ); if ( !f.exists() ) { - QString tempstr = "Creating directory "; + QString tempstr = tr("Creating directory "); tempstr.append( linkFile ); emit outputText( tempstr ); QDir d; d.mkdir( linkFile, true ); } // else // emit outputText( QString( "Directory " ) + linkFile + " already exists" ); - + } else { int rc = symlink( sourceFile, linkFile ); - text = (rc == 0 ? "Linked " : "Failed to link "); - text.append( sourceFile ); - text.append( " to " ); - text.append( linkFile ); + text = ( rc == 0 ? tr( "Linked %1 to %2" ) : tr( "Failed to link %1 to %2" ) ). + arg( sourceFile ). + arg( linkFile ); emit outputText( text ); } } else { QFileInfo f( linkFile ); if ( f.exists() ) { if ( f.isFile() ) { QFile f( linkFile ); bool rc = f.remove(); - text = (rc ? "Removed " : "Failed to remove "); - text.append( linkFile ); + text = ( rc ? tr( "Removed %1" ) : tr( "Failed to remove %1" ) ).arg( linkFile ); emit outputText( text ); } else if ( f.isDir() ) { QDir d; bool rc = d.rmdir( linkFile, true ); if ( rc ) { - text = (rc ? "Removed " : "Failed to remove "); - text.append( linkFile ); + text = ( rc ? tr( "Removed " ) : tr( "Failed to remove " ) ).arg( linkFile ); emit outputText( text ); } } } } } diff --git a/noncore/settings/aqpkg/main.cpp b/noncore/settings/aqpkg/main.cpp index 066d79f..b7f8b7b 100644 --- a/noncore/settings/aqpkg/main.cpp +++ b/noncore/settings/aqpkg/main.cpp @@ -1,15 +1,15 @@ /* 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; @@ -33,37 +33,44 @@ #else #include <qapplication.h> #endif #include <qobjectdefs.h> #include "mainwin.h" #include "server.h" #include "global.h" +/* be less intrusive for translation -zecke */ +extern QString LOCAL_SERVER; +extern QString LOCAL_IPKGS; + int main(int argc, char *argv[]) { #ifdef QWS QPEApplication a( argc, argv ); #else QApplication a( argc, argv ); #endif #ifdef QWS // Disable suspend mode QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; #endif + LOCAL_SERVER = QObject::tr( "Installed packages" ); + LOCAL_IPKGS = QObject::tr( "Local packages" ); + MainWindow *win = new MainWindow(); a.setMainWidget(win); win->showMaximized(); a.exec(); #ifdef QWS // Reenable suspend mode QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; #endif #ifdef _DEBUG DumpUnfreed(); diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index 0efa1e0..45a6663 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp @@ -1045,43 +1045,41 @@ InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) 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" ); + secondOption = "R"; // Internal action code, do not translate } 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" ); + secondOption = "U"; // Internal action code, do not translate } // 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 ) ) QuestionDlg dlg( text, msgtext, secondButton ); switch( dlg.exec() ) { case 0: // Cancel delete newitem; return 0x0; break; case 1: // Remove newitem->option = "D"; break; case 2: // Reinstall or Upgrade newitem->option = secondOption; diff --git a/noncore/settings/aqpkg/mem.cpp b/noncore/settings/aqpkg/mem.cpp index 5f32a26..4c6117b 100644 --- a/noncore/settings/aqpkg/mem.cpp +++ b/noncore/settings/aqpkg/mem.cpp @@ -90,21 +90,21 @@ void RemoveTrack(long addr) allocList.remove((*i)); found = true; break; } } } void DumpUnfreed() { AllocList::iterator i; long totalSize = 0; char buf[1024]; - + // Debug output, okay to leave untranslated 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); totalSize += (*i)->size; } sprintf(buf, "-----------------------------------------------------------\n"); sprintf(buf, "Total Unfreed: %ld bytes\n", totalSize); }; diff --git a/noncore/settings/aqpkg/package.cpp b/noncore/settings/aqpkg/package.cpp index 4c27c65..adda832 100644 --- a/noncore/settings/aqpkg/package.cpp +++ b/noncore/settings/aqpkg/package.cpp @@ -1,15 +1,15 @@ /* 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; @@ -21,82 +21,87 @@ : = ...= . :.=- 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" +#include <qobject.h> + Package::Package( QString &name ) { packageName = name; - version = "N/A"; - description = "N/A"; - packageSize = "N/A"; - section = "N/A"; - + QString tempstr = QObject::tr( "N/A" ); + version = tempstr; + description = tempstr; + packageSize = tempstr; + section = tempstr; + 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"; - + QString tempstr = QObject::tr( "N/A" ); + version = tempstr; + description = tempstr; + packageSize = tempstr; + section = tempstr; + 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(); + QString ret = QObject::tr( "Package - %1\n version - %2" ). + arg( getPackageName() ). + arg( getVersion() ); if ( localPackage ) - ret += "\n inst version - " + localPackage->getVersion(); + ret.append( QObject::tr( "\n inst version - %1" ).arg( 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; diff --git a/noncore/settings/aqpkg/version.cpp b/noncore/settings/aqpkg/version.cpp index e836da1..59e6f3f 100644 --- a/noncore/settings/aqpkg/version.cpp +++ b/noncore/settings/aqpkg/version.cpp @@ -14,53 +14,55 @@ * 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 dpkg; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> -# define _(Text) Text +#include <qobject.h> + +//# define _(Text) Text class versionrevision { public: versionrevision() { version = 0; } ~versionrevision() { if ( version ) delete version; } void setVersion( const char *str ) { version = new char[(strlen(str)+1)]; strcpy( version, str ); } - + unsigned long epoch; char *version; const char *revision; const char *familiar_revision; -}; +}; -static int verrevcmp(const char *val, const char *ref) +static int verrevcmp(const char *val, const char *ref) { int vc, rc; long vl, rl; const char *vp, *rp; if (!val) val= ""; if (!ref) ref= ""; for (;;) { vp= val; while (*vp && !isdigit(*vp)) vp++; rp= ref; while (*rp && !isdigit(*rp)) rp++; for (;;) { vc= val == vp ? 0 : *val++; @@ -73,68 +75,71 @@ static int verrevcmp(const char *val, const char *ref) val= vp; ref= rp; vl=0; if (isdigit(*vp)) vl= strtol(val,(char**)&val,10); rl=0; if (isdigit(*rp)) rl= strtol(ref,(char**)&ref,10); if (vl != rl) return vl - rl; if (!*val && !*ref) return 0; if (!*val) return -1; if (!*ref) return +1; } } int versioncompare(const struct versionrevision *version, - const struct versionrevision *refversion) + const struct versionrevision *refversion) { int r; if (version->epoch > refversion->epoch) return 1; if (version->epoch < refversion->epoch) return -1; r= verrevcmp(version->version,refversion->version); if (r) return r; r= verrevcmp(version->revision,refversion->revision); if (r) return r; return verrevcmp(version->familiar_revision,refversion->familiar_revision); } int versionsatisfied3(const struct versionrevision *it, const struct versionrevision *ref, - const char *op) + const char *op) { int r; r= versioncompare(it,ref); if (strcmp(op, "<=") == 0 || strcmp(op, "<") == 0) return r <= 0; if (strcmp(op, ">=") == 0 || strcmp(op, ">") == 0) return r >= 0; if (strcmp(op, "<<") == 0) return r < 0; if (strcmp(op, ">>") == 0) return r > 0; if (strcmp(op, "=") == 0) return r == 0; - fprintf(stderr, "unknown operator: %s", op); +// fprintf(stderr, "unknown operator: %s", op); exit(1); } -const char *parseversion(struct versionrevision *rversion, const char *string) +const char *parseversion(struct versionrevision *rversion, const char *string) { char *hyphen, *colon, *eepochcolon; unsigned long epoch; - if (!*string) return _("version string is empty"); - + if ( !*string ) + return QObject::tr( "Version string is empty." ); + colon= strchr(string,':'); if (colon) { epoch= strtoul(string,&eepochcolon,10); - if (colon != eepochcolon) return _("epoch in version is not number"); - if (!*++colon) return _("nothing after colon in version number"); + if ( colon != eepochcolon ) + return QObject::tr( "Epoch in version is not number." ); + if ( !*++colon ) + return QObject::tr( "Nothing after colon in version number." ); string= colon; rversion->epoch= epoch; } else { rversion->epoch= 0; } rversion->revision = ""; rversion->familiar_revision = ""; rversion->setVersion( string ); hyphen= strrchr(rversion->version,'-'); if (hyphen) { @@ -147,68 +152,68 @@ const char *parseversion(struct versionrevision *rversion, const char *string) rversion->revision = hyphen; } } else { rversion->revision = hyphen; } } /* fprintf(stderr,"Parsed version: %lu, %s, %s, %s\n", rversion->epoch, rversion->version, rversion->revision, rversion->familiar_revision); -*/ +*/ return 0; } int compareVersions( const char *v1, const char *v2 ) { const char *err; versionrevision ver, ref; err = parseversion(&ref, v1); if (err) { - fprintf(stderr, "Invalid version `%s': %s\n", v2, err); +// fprintf(stderr, "Invalid version `%s': %s\n", v2, err); return -2; } err = parseversion(&ver, v2); if (err) { - fprintf(stderr, "Invalid version `%s': %s\n", v1, err); +// fprintf(stderr, "Invalid version `%s': %s\n", v1, err); return -2; } if ( versionsatisfied3( &ver, &ref, "=" ) ) return 0; else if ( versionsatisfied3( &ver, &ref, "<" ) ) return -1; else return 1; } /* -int main(int argc, char *argv[]) +int main(int argc, char *argv[]) { const char *err; versionrevision ver, ref; if (argc < 4) { fprintf(stderr, "usage: %s: version op refversion\n", argv[0]); return 2; } err = parseversion(&ver, argv[1]); if (err) { fprintf(stderr, "Invalid version `%s': %s\n", argv[1], err); return 2; } - + err = parseversion(&ref, argv[3]); if (err) { fprintf(stderr, "Invalid version `%s': %s\n", argv[3], err); return 2; } printf( "Result: %d\n", versionsatisfied3(&ver, &ref, argv[2]) ); } */ |