summaryrefslogtreecommitdiff
authordrw <drw>2003-04-29 02:28:16 (UTC)
committer drw <drw>2003-04-29 02:28:16 (UTC)
commite096c9d1f2be1ec74ede583fc4221871a56ef508 (patch) (unidiff)
tree1c6f49430179e2f262179951477bbe4bd7d32e71
parent2f26f696ca6acd05aa615e15d891eede9907a1c0 (diff)
downloadopie-e096c9d1f2be1ec74ede583fc4221871a56ef508.zip
opie-e096c9d1f2be1ec74ede583fc4221871a56ef508.tar.gz
opie-e096c9d1f2be1ec74ede583fc4221871a56ef508.tar.bz2
Give aqpkg standard source headers and some minor code clean-up.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/categoryfilterimpl.cpp45
-rw-r--r--noncore/settings/aqpkg/categoryfilterimpl.h44
-rw-r--r--noncore/settings/aqpkg/datamgr.cpp139
-rw-r--r--noncore/settings/aqpkg/datamgr.h44
-rw-r--r--noncore/settings/aqpkg/destination.cpp42
-rw-r--r--noncore/settings/aqpkg/destination.h45
-rw-r--r--noncore/settings/aqpkg/global.h44
-rw-r--r--noncore/settings/aqpkg/inputdlg.cpp45
-rw-r--r--noncore/settings/aqpkg/inputdlg.h44
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.cpp46
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.h43
-rw-r--r--noncore/settings/aqpkg/instoptionsimpl.cpp44
-rw-r--r--noncore/settings/aqpkg/instoptionsimpl.h43
-rw-r--r--noncore/settings/aqpkg/ipkg.cpp44
-rw-r--r--noncore/settings/aqpkg/ipkg.h42
-rw-r--r--noncore/settings/aqpkg/letterpushbutton.cpp42
-rw-r--r--noncore/settings/aqpkg/letterpushbutton.h44
-rw-r--r--noncore/settings/aqpkg/main.cpp47
-rw-r--r--noncore/settings/aqpkg/mainwin.cpp55
-rw-r--r--noncore/settings/aqpkg/mainwin.h42
-rw-r--r--noncore/settings/aqpkg/mem.cpp216
-rw-r--r--noncore/settings/aqpkg/package.cpp44
-rw-r--r--noncore/settings/aqpkg/package.h42
-rw-r--r--noncore/settings/aqpkg/packagewin.cpp7
-rw-r--r--noncore/settings/aqpkg/packagewin.h5
-rw-r--r--noncore/settings/aqpkg/server.cpp52
-rw-r--r--noncore/settings/aqpkg/server.h43
-rw-r--r--noncore/settings/aqpkg/settingsimpl.cpp44
-rw-r--r--noncore/settings/aqpkg/settingsimpl.h42
-rw-r--r--noncore/settings/aqpkg/utils.cpp47
-rw-r--r--noncore/settings/aqpkg/utils.h42
31 files changed, 951 insertions, 617 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 @@
1/*************************************************************************** 1/*
2 categoryfilterimpl.cpp - description 2                This file is part of the OPIE Project
3 ------------------- 3
4 begin : Sun Nov 17 2002 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5 copyright : (C) 2002 by Andy Qua 5             .=l. Dan Williams <drw@handhelds.org>
6 email : andy.qua@blueyonder.co.uk 6           .>+-=
7 ***************************************************************************/ 7 _;:,     .>    :=|. This file is free software; you can
8 8.> <`_,   >  .   <= redistribute it and/or modify it under
9/*************************************************************************** 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10 * * 10.="- .-=="i,     .._ License as published by the Free Software
11 * This program is free software; you can redistribute it and/or modify * 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12 * it under the terms of the GNU General Public License as published by * 12     ._= =}       : or (at your option) any later version.
13 * the Free Software Foundation; either version 2 of the License, or * 13    .%`+i>       _;_.
14 * (at your option) any later version. * 14    .i_,=:_.      -<s. This file is distributed in the hope that
15 * * 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16 ***************************************************************************/ 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
29
17#include <iostream> 30#include <iostream>
18using namespace std; 31using namespace std;
19 32
20#include <qgroupbox.h> 33#include <qgroupbox.h>
21#include <qlayout.h> 34#include <qlayout.h>
22#include <qlistbox.h> 35#include <qlistbox.h>
23#include <qstring.h> 36#include <qstring.h>
24 37
25#include "categoryfilterimpl.h" 38#include "categoryfilterimpl.h"
26 39
27CategoryFilterImpl :: CategoryFilterImpl(const QString &categories, const QString &selectedCategories, QWidget *parent, const char *name ) 40CategoryFilterImpl :: CategoryFilterImpl(const QString &categories, const QString &selectedCategories, QWidget *parent, const char *name )
28 : QDialog( parent, name, true ) 41 : QDialog( parent, name, true )
29{ 42{
30 setCaption( tr( "Category Filter" ) ); 43 setCaption( tr( "Category Filter" ) );
31 44
32 QVBoxLayout *layout = new QVBoxLayout( this ); 45 QVBoxLayout *layout = new QVBoxLayout( this );
33 layout->setMargin( 2 ); 46 layout->setMargin( 2 );
34 layout->setSpacing( 4 ); 47 layout->setSpacing( 4 );
35 48
36 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Select one or more groups" ), this ); 49 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Select one or more groups" ), this );
37 grpbox->layout()->setSpacing( 2 ); 50 grpbox->layout()->setSpacing( 2 );
38 grpbox->layout()->setMargin( 4 ); 51 grpbox->layout()->setMargin( 4 );
39 layout->addWidget( grpbox ); 52 layout->addWidget( grpbox );
40 53
41 QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); 54 QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() );
42 55
43 lstCategories = new QListBox( grpbox ); 56 lstCategories = new QListBox( grpbox );
44 lstCategories->setSelectionMode( QListBox::Multi ); 57 lstCategories->setSelectionMode( QListBox::Multi );
45 grplayout->addWidget( lstCategories ); 58 grplayout->addWidget( lstCategories );
46 59
47 // Split up categories and add them to the listbox 60 // Split up categories and add them to the listbox
48 int start = 1; 61 int start = 1;
49 62
50 QString item; 63 QString item;
51 int end; 64 int end;
52 QString finditem; 65 QString finditem;
53 do 66 do
54 { 67 {
55 end = categories.find( "#", start ); 68 end = categories.find( "#", start );
56 item = categories.mid( start, end - start ); 69 item = categories.mid( start, end - start );
57 if ( item != "" ) 70 if ( item != "" )
58 { 71 {
59 lstCategories->insertItem( item ); 72 lstCategories->insertItem( item );
60 finditem = QString( "#%1#" ).arg( item ); 73 finditem = QString( "#%1#" ).arg( item );
61 if ( selectedCategories.find( finditem ) != -1 ) 74 if ( selectedCategories.find( finditem ) != -1 )
62 lstCategories->setSelected( lstCategories->count()-1, true ); 75 lstCategories->setSelected( lstCategories->count()-1, true );
63 } 76 }
64 77
65 start = end + 1; 78 start = end + 1;
66 } while ( start < (int)categories.length() ); 79 } while ( start < (int)categories.length() );
67 80
68 lstCategories->sort( true ); 81 lstCategories->sort( true );
69 82
70 showMaximized(); 83 showMaximized();
71} 84}
72 85
73CategoryFilterImpl :: ~CategoryFilterImpl() 86CategoryFilterImpl :: ~CategoryFilterImpl()
74{ 87{
75} 88}
76 89
77QString CategoryFilterImpl :: getSelectedFilter() 90QString CategoryFilterImpl :: getSelectedFilter()
78{ 91{
79 // Grab cetegories from listbox 92 // Grab cetegories from listbox
80 QString ret = "#"; 93 QString ret = "#";
81 94
82 for ( int i = 0 ; i < (int)lstCategories->count() ; ++i ) 95 for ( int i = 0 ; i < (int)lstCategories->count() ; ++i )
83 { 96 {
84 if ( lstCategories->isSelected( i ) ) 97 if ( lstCategories->isSelected( i ) )
85 { 98 {
86 ret.append( lstCategories->text( i ) ); 99 ret.append( lstCategories->text( i ) );
87 ret.append( "#" ); 100 ret.append( "#" );
88 } 101 }
89 } 102 }
90 103
91 if ( ret == "#" ) 104 if ( ret == "#" )
92 ret = ""; 105 ret = "";
93 return ret; 106 return ret;
94} 107}
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 @@
1/*************************************************************************** 1/*
2 categoryfilterimpl.h - description 2                This file is part of the OPIE Project
3 ------------------- 3
4 begin : Sun Nov 17 2002 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5 copyright : (C) 2002 by Andy Qua 5             .=l. Dan Williams <drw@handhelds.org>
6 email : andy.qua@blueyonder.co.uk 6           .>+-=
7 ***************************************************************************/ 7 _;:,     .>    :=|. This file is free software; you can
8 8.> <`_,   >  .   <= redistribute it and/or modify it under
9/*************************************************************************** 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10 * * 10.="- .-=="i,     .._ License as published by the Free Software
11 * This program is free software; you can redistribute it and/or modify * 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12 * it under the terms of the GNU General Public License as published by * 12     ._= =}       : or (at your option) any later version.
13 * the Free Software Foundation; either version 2 of the License, or * 13    .%`+i>       _;_.
14 * (at your option) any later version. * 14    .i_,=:_.      -<s. This file is distributed in the hope that
15 * * 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16 ***************************************************************************/ 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
17 29
18#ifndef CATEGORYFILTERIMPL_H 30#ifndef CATEGORYFILTERIMPL_H
19#define CATEGORYFILTERIMPL_H 31#define CATEGORYFILTERIMPL_H
20 32
21#include <qdialog.h> 33#include <qdialog.h>
22 34
23class QListBox; 35class QListBox;
24 36
25/** 37/**
26 *@author Andy Qua 38 *@author Andy Qua
27 */ 39 */
28 40
29class CategoryFilterImpl : public QDialog 41class CategoryFilterImpl : public QDialog
30{ 42{
31 Q_OBJECT 43 Q_OBJECT
32public: 44public:
33 CategoryFilterImpl(const QString &categories, const QString &selectedCategories, QWidget *parent=0, const char *name=0); 45 CategoryFilterImpl(const QString &categories, const QString &selectedCategories, QWidget *parent=0, const char *name=0);
34 ~CategoryFilterImpl(); 46 ~CategoryFilterImpl();
35 47
36 QString getSelectedFilter(); 48 QString getSelectedFilter();
37 49
38private: 50private:
39 QListBox *lstCategories; 51 QListBox *lstCategories;
40 52
41}; 53};
42 54
43#endif 55#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 @@
1/*************************************************************************** 1/*
2 datamgr.cpp - description 2                This file is part of the OPIE Project
3 ------------------- 3
4 begin : Thu Aug 29 2002 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5 copyright : (C) 2002 by Andy Qua 5             .=l. Dan Williams <drw@handhelds.org>
6 email : andy.qua@blueyonder.co.uk 6           .>+-=
7 ***************************************************************************/ 7 _;:,     .>    :=|. This file is free software; you can
8 8.> <`_,   >  .   <= redistribute it and/or modify it under
9/*************************************************************************** 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10 * * 10.="- .-=="i,     .._ License as published by the Free Software
11 * This program is free software; you can redistribute it and/or modify * 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12 * it under the terms of the GNU General Public License as published by * 12     ._= =}       : or (at your option) any later version.
13 * the Free Software Foundation; either version 2 of the License, or * 13    .%`+i>       _;_.
14 * (at your option) any later version. * 14    .i_,=:_.      -<s. This file is distributed in the hope that
15 * * 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16 ***************************************************************************/ 16    : ..    .:,     . . . without even the implied warranty of
17#include <fstream> 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18#include <iostream> 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19using namespace std; 19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
20 29
21#ifdef QWS 30#ifdef QWS
22#include <qpe/config.h> 31#include <qpe/config.h>
23#include <qpe/qpeapplication.h> 32#include <qpe/qpeapplication.h>
24#else 33#else
25#include <qapplication.h> 34#include <qapplication.h>
26#endif 35#endif
27 36
28#include <stdio.h> 37#include <qfile.h>
38#include <qtextstream.h>
29 39
30#include "datamgr.h" 40#include "datamgr.h"
31#include "global.h" 41#include "global.h"
32 42
33 43
34QString DataManager::availableCategories = ""; 44QString DataManager::availableCategories = "";
35DataManager::DataManager() 45DataManager::DataManager()
36 : QObject( 0x0, 0x0 ) 46 : QObject( 0x0, 0x0 )
37{ 47{
38 activeServer = ""; 48 activeServer = "";
39 availableCategories = "#"; 49 availableCategories = "#";
40 50
41 serverList.setAutoDelete( TRUE ); 51 serverList.setAutoDelete( TRUE );
42 destList.setAutoDelete( TRUE ); 52 destList.setAutoDelete( TRUE );
43} 53}
44 54
45DataManager::~DataManager() 55DataManager::~DataManager()
46{ 56{
47} 57}
48 58
49Server *DataManager :: getServer( const char *name ) 59Server *DataManager :: getServer( const char *name )
50{ 60{
51 QListIterator<Server> it( serverList ); 61 QListIterator<Server> it( serverList );
52 while ( it.current() && it.current()->getServerName() != name ) 62 while ( it.current() && it.current()->getServerName() != name )
53 { 63 {
54 ++it; 64 ++it;
55 } 65 }
56 66
57 return it.current(); 67 return it.current();
58} 68}
59 69
60Destination *DataManager :: getDestination( const char *name ) 70Destination *DataManager :: getDestination( const char *name )
61{ 71{
62 QListIterator<Destination> it( destList ); 72 QListIterator<Destination> it( destList );
63 while ( it.current() && it.current()->getDestinationName() != name ) 73 while ( it.current() && it.current()->getDestinationName() != name )
64 { 74 {
65 ++it; 75 ++it;
66 } 76 }
67 77
68 return it.current(); 78 return it.current();
69} 79}
70 80
71void DataManager :: loadServers() 81void DataManager :: loadServers()
72{ 82{
73 // First add our local server - not really a server but 83 // First add our local server - not really a server but
74 // the local config (which packages are installed) 84 // the local config (which packages are installed)
75 serverList.append( new Server( LOCAL_SERVER, "" ) ); 85 serverList.append( new Server( LOCAL_SERVER, "" ) );
76 serverList.append( new Server( LOCAL_IPKGS, "" ) ); 86 serverList.append( new Server( LOCAL_IPKGS, "" ) );
77 87
78#ifdef QWS 88#ifdef QWS
79 Config cfg( "aqpkg" ); 89 Config cfg( "aqpkg" );
80 cfg.setGroup( "destinations" ); 90 cfg.setGroup( "destinations" );
81#endif 91#endif
82 92
83 // Read file from /etc/ipkg.conf 93 // Read file from /etc/ipkg.conf
84 QString ipkg_conf = IPKG_CONF; 94 QString ipkg_conf = IPKG_CONF;
85 FILE *fp; 95 FILE *fp;
86 fp = fopen( ipkg_conf, "r" ); 96 fp = fopen( ipkg_conf, "r" );
87 char line[130]; 97 char line[130];
88 QString lineStr; 98 QString lineStr;
89 if ( fp == NULL ) 99 if ( fp == NULL )
90 { 100 {
91 cout << "Couldn't open " << ipkg_conf << "! err = " << fp << endl;
92 return; 101 return;
93 } 102 }
94 else 103 else
95 { 104 {
96 while ( fgets( line, sizeof line, fp) != NULL ) 105 while ( fgets( line, sizeof line, fp) != NULL )
97 { 106 {
98 lineStr = line; 107 lineStr = line;
99 if ( lineStr.startsWith( "src" ) || lineStr.startsWith( "#src" ) || lineStr.startsWith( "# src" ) ) 108 if ( lineStr.startsWith( "src" ) || lineStr.startsWith( "#src" ) || lineStr.startsWith( "# src" ) )
100 { 109 {
101 char alias[20]; 110 char alias[20];
102 char url[100]; 111 char url[100];
103 112
104 // Looks a little wierd but read up to the r of src (throwing it away), 113 // Looks a little wierd but read up to the r of src (throwing it away),
105 // then read up to the next space and throw that away, the alias 114 // then read up to the next space and throw that away, the alias
106 // is next. 115 // is next.
107 // Should Handle #src, # src, src, and combinations of 116 // Should Handle #src, # src, src, and combinations of
108 sscanf( lineStr, "%*[^r]%*[^ ] %s %s", alias, url ); 117 sscanf( lineStr, "%*[^r]%*[^ ] %s %s", alias, url );
109 Server *s = new Server( alias, url ); 118 Server *s = new Server( alias, url );
110 if ( lineStr.startsWith( "src" ) ) 119 if ( lineStr.startsWith( "src" ) )
111 s->setActive( true ); 120 s->setActive( true );
112 else 121 else
113 s->setActive( false ); 122 s->setActive( false );
114 123
115 serverList.append( s ); 124 serverList.append( s );
116 125
117 } 126 }
118 else if ( lineStr.startsWith( "dest" ) ) 127 else if ( lineStr.startsWith( "dest" ) )
119 { 128 {
120 char alias[20]; 129 char alias[20];
121 char path[50]; 130 char path[50];
122 sscanf( lineStr, "%*[^ ] %s %s", alias, path ); 131 sscanf( lineStr, "%*[^ ] %s %s", alias, path );
123 Destination *d = new Destination( alias, path ); 132 Destination *d = new Destination( alias, path );
124 bool linkToRoot = true; 133 bool linkToRoot = true;
125#ifdef QWS 134#ifdef QWS
126 QString key = alias; 135 QString key = alias;
127 key += "_linkToRoot"; 136 key += "_linkToRoot";
128 linkToRoot = cfg.readBoolEntry( key, true ); 137 linkToRoot = cfg.readBoolEntry( key, true );
129#endif 138#endif
130 d->linkToRoot( linkToRoot ); 139 d->linkToRoot( linkToRoot );
131 140
132 destList.append( d ); 141 destList.append( d );
133 } 142 }
134 else if ( lineStr.startsWith( "option" ) || lineStr.startsWith( "#option" ) ) 143 else if ( lineStr.startsWith( "option" ) || lineStr.startsWith( "#option" ) )
135 { 144 {
136 char type[20]; 145 char type[20];
137 char val[100]; 146 char val[100];
138 sscanf( lineStr, "%*[^ ] %s %s", type, val ); 147 sscanf( lineStr, "%*[^ ] %s %s", type, val );
139 if ( stricmp( type, "http_proxy" ) == 0 ) 148 if ( stricmp( type, "http_proxy" ) == 0 )
140 { 149 {
141 httpProxy = val; 150 httpProxy = val;
142 if ( lineStr.startsWith( "#" ) ) 151 if ( lineStr.startsWith( "#" ) )
143 httpProxyEnabled = false; 152 httpProxyEnabled = false;
144 else 153 else
145 httpProxyEnabled = true; 154 httpProxyEnabled = true;
146 } 155 }
147 if ( stricmp( type, "ftp_proxy" ) == 0 ) 156 if ( stricmp( type, "ftp_proxy" ) == 0 )
148 { 157 {
149 ftpProxy = val; 158 ftpProxy = val;
150 if ( lineStr.startsWith( "#" ) ) 159 if ( lineStr.startsWith( "#" ) )
151 ftpProxyEnabled = false; 160 ftpProxyEnabled = false;
152 else 161 else
153 ftpProxyEnabled = true; 162 ftpProxyEnabled = true;
154 } 163 }
155 if ( stricmp( type, "proxy_username" ) == 0 ) 164 if ( stricmp( type, "proxy_username" ) == 0 )
156 proxyUsername = val; 165 proxyUsername = val;
157 if ( stricmp( type, "proxy_password" ) == 0 ) 166 if ( stricmp( type, "proxy_password" ) == 0 )
158 proxyPassword = val; 167 proxyPassword = val;
159 } 168 }
160 } 169 }
161 } 170 }
162 fclose( fp ); 171 fclose( fp );
163 172
164 reloadServerData( ); 173 reloadServerData( );
165} 174}
166 175
167void DataManager :: reloadServerData( ) 176void DataManager :: reloadServerData( )
168{ 177{
169 emit progressSetSteps( serverList.count() ); 178 emit progressSetSteps( serverList.count() );
170 emit progressSetMessage( tr( "Reading configuration..." ) ); 179 emit progressSetMessage( tr( "Reading configuration..." ) );
171 180
172 QString serverName; 181 QString serverName;
173 int i = 0; 182 int i = 0;
174 183
175 Server *server; 184 Server *server;
176 QListIterator<Server> it( serverList ); 185 QListIterator<Server> it( serverList );
177 for ( ; it.current(); ++it ) 186 for ( ; it.current(); ++it )
178 { 187 {
179 server = it.current(); 188 server = it.current();
180 serverName = server->getServerName(); 189 serverName = server->getServerName();
181 i++; 190 i++;
182 emit progressUpdate( i ); 191 emit progressUpdate( i );
183 qApp->processEvents(); 192 qApp->processEvents();
184 193
185 // Now we've read the config file in we need to read the servers 194 // Now we've read the config file in we need to read the servers
186 // The local server is a special case. This holds the contents of the 195 // The local server is a special case. This holds the contents of the
187 // status files the number of which depends on how many destinations 196 // status files the number of which depends on how many destinations
188 // we've set up 197 // we've set up
189 // The other servers files hold the contents of the server package list 198 // The other servers files hold the contents of the server package list
190 if ( serverName == LOCAL_SERVER ) 199 if ( serverName == LOCAL_SERVER )
191 server->readStatusFile( destList ); 200 server->readStatusFile( destList );
192 else if ( serverName == LOCAL_IPKGS ) 201 else if ( serverName == LOCAL_IPKGS )
193 server->readLocalIpks( getServer( LOCAL_SERVER ) ); 202 server->readLocalIpks( getServer( LOCAL_SERVER ) );
194 else 203 else
195 server->readPackageFile( getServer( LOCAL_SERVER ) ); 204 server->readPackageFile( getServer( LOCAL_SERVER ) );
196 } 205 }
197} 206}
198 207
199void DataManager :: writeOutIpkgConf() 208void DataManager :: writeOutIpkgConf()
200{ 209{
210 QFile f( IPKG_CONF );
211 if ( !f.open( IO_WriteOnly ) )
212 {
213 return;
214 }
215
216 QTextStream t( &f );
217/*
201 QString ipkg_conf = IPKG_CONF; 218 QString ipkg_conf = IPKG_CONF;
202 ofstream out( ipkg_conf ); 219 ofstream out( ipkg_conf );
220*/
221 t << "# Written by AQPkg\n";
222 t << "# Must have one or more source entries of the form:\n";
223 t << "#\n";
224 t << "# src <src-name> <source-url>\n";
225 t << "#\n";
226 t << "# and one or more destination entries of the form:\n";
227 t << "#\n";
228 t << "# dest <dest-name> <target-path>\n";
229 t << "#\n";
230 t << "# where <src-name> and <dest-names> are identifiers that\n";
231 t << "# should match [a-zA-Z0-9._-]+, <source-url> should be a\n";
232 t << "# URL that points to a directory containing a Familiar\n";
233 t << "# Packages file, and <target-path> should be a directory\n";
234 t << "# that exists on the target system.\n\n";
203 235
204 out << "# Written by AQPkg" << endl;
205 out << "# Must have one or more source entries of the form:" << endl;
206 out << "#" << endl;
207 out << "# src <src-name> <source-url>" << endl;
208 out << "#" << endl;
209 out << "# and one or more destination entries of the form:" << endl;
210 out << "#" << endl;
211 out << "# dest <dest-name> <target-path>" << endl;
212 out << "#" << endl;
213 out << "# where <src-name> and <dest-names> are identifiers that" << endl;
214 out << "# should match [a-zA-Z0-9._-]+, <source-url> should be a" << endl;
215 out << "# URL that points to a directory containing a Familiar" << endl;
216 out << "# Packages file, and <target-path> should be a directory" << endl;
217 out << "# that exists on the target system." << endl << endl;
218
219 // Write out servers 236 // Write out servers
220 Server *server; 237 Server *server;
221 QListIterator<Server> it( serverList ); 238 QListIterator<Server> it( serverList );
222 while ( it.current() ) 239 while ( it.current() )
223 { 240 {
224 server = it.current(); 241 server = it.current();
225 QString alias = server->getServerName(); 242 QString alias = server->getServerName();
226 // Don't write out local as its a dummy 243 // Don't write out local as its a dummy
227 if ( alias != LOCAL_SERVER && alias != LOCAL_IPKGS ) 244 if ( alias != LOCAL_SERVER && alias != LOCAL_IPKGS )
228 { 245 {
229 QString url = server->getServerUrl();; 246 QString url = server->getServerUrl();;
230 247
231 if ( !server->isServerActive() ) 248 if ( !server->isServerActive() )
232 out << "#"; 249 t << "#";
233 out << "src " << alias << " " << url << endl; 250 t << "src " << alias << " " << url << endl;
234 } 251 }
235 252
236 ++it; 253 ++it;
237 } 254 }
238 255
239 out << endl; 256 t << endl;
240 257
241 // Write out destinations 258 // Write out destinations
242 QListIterator<Destination> it2( destList ); 259 QListIterator<Destination> it2( destList );
243 while ( it2.current() ) 260 while ( it2.current() )
244 { 261 {
245 out << "dest " << it2.current()->getDestinationName() << " " << it2.current()->getDestinationPath() << endl; 262 t << "dest " << it2.current()->getDestinationName() << " " << it2.current()->getDestinationPath() << endl;
246 ++it2; 263 ++it2;
247 } 264 }
248 265
249 out << endl; 266 t << endl;
250 out << "# Proxy Support" << endl; 267 t << "# Proxy Support\n";
251 268
252 if ( !httpProxyEnabled && httpProxy == "" ) 269 if ( !httpProxyEnabled && httpProxy == "" )
253 out << "#option http_proxy http://proxy.tld:3128" << endl; 270 t << "#option http_proxy http://proxy.tld:3128\n";
254 else 271 else
255 { 272 {
256 if ( !httpProxyEnabled ) 273 if ( !httpProxyEnabled )
257 out << "#"; 274 t << "#";
258 out << "option http_proxy " << httpProxy << endl; 275 t << "option http_proxy " << httpProxy << endl;
259 } 276 }
260 277
261 if ( !ftpProxyEnabled && ftpProxy == "" ) 278 if ( !ftpProxyEnabled && ftpProxy == "" )
262 out << "#option ftp_proxy http://proxy.tld:3128" << endl; 279 t << "#option ftp_proxy http://proxy.tld:3128\n";
263 else 280 else
264 { 281 {
265 if ( !ftpProxyEnabled ) 282 if ( !ftpProxyEnabled )
266 out << "#"; 283 t << "#";
267 out << "option ftp_proxy " << ftpProxy << endl; 284 t << "option ftp_proxy " << ftpProxy << endl;
268 } 285 }
269 if ( proxyUsername == "" || (!httpProxyEnabled && !ftpProxyEnabled) ) 286 if ( proxyUsername == "" || (!httpProxyEnabled && !ftpProxyEnabled) )
270 out << "#option proxy_username <username>" << endl; 287 t << "#option proxy_username <username>\n";
271 else 288 else
272 out << "option proxy_username " << proxyUsername << endl; 289 t << "option proxy_username " << proxyUsername << endl;
273 if ( proxyPassword == "" || (!httpProxyEnabled && !ftpProxyEnabled) ) 290 if ( proxyPassword == "" || (!httpProxyEnabled && !ftpProxyEnabled) )
274 out << "#option proxy_password <password>" << endl << endl; 291 t << "#option proxy_password <password>\n\n";
275 else 292 else
276 out << "option proxy_password " << proxyPassword << endl<< endl; 293 t << "option proxy_password " << proxyPassword << endl<< endl;
277
278 out << "# Offline mode (for use in constructing flash images offline)" << endl;
279 out << "#option offline_root target" << endl;
280 294
295 t << "# Offline mode (for use in constructing flash images offline)\n";
296 t << "#option offline_root target\n";
281 297
282 out.close(); 298 f.close();
283} 299}
284 300
285 301
286void DataManager :: setAvailableCategories( QString section ) 302void DataManager :: setAvailableCategories( QString section )
287{ 303{
288 section = section.lower(); 304 QString sectstr = "#";
289 if ( availableCategories.find( "#" + section + "#" ) == -1 ) 305 sectstr.append( section.lower() );
290 availableCategories += section + "#"; 306 sectstr.append( "#" );
307 if ( availableCategories.find( sectstr ) == -1 )
308 {
309 availableCategories.append( section );
310 availableCategories.append( "#" );
311 }
291} 312}
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 @@
1/*************************************************************************** 1/*
2 datamgr.h - description 2                This file is part of the OPIE Project
3 ------------------- 3
4 begin : Thu Aug 29 2002 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5 copyright : (C) 2002 by Andy Qua 5             .=l. Dan Williams <drw@handhelds.org>
6 email : andy.qua@blueyonder.co.uk 6           .>+-=
7 ***************************************************************************/ 7 _;:,     .>    :=|. This file is free software; you can
8 8.> <`_,   >  .   <= redistribute it and/or modify it under
9/*************************************************************************** 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10 * * 10.="- .-=="i,     .._ License as published by the Free Software
11 * This program is free software; you can redistribute it and/or modify * 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12 * it under the terms of the GNU General Public License as published by * 12     ._= =}       : or (at your option) any later version.
13 * the Free Software Foundation; either version 2 of the License, or * 13    .%`+i>       _;_.
14 * (at your option) any later version. * 14    .i_,=:_.      -<s. This file is distributed in the hope that
15 * * 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16 ***************************************************************************/ 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
17 29
18#ifndef DATAMGR_H 30#ifndef DATAMGR_H
19#define DATAMGR_H 31#define DATAMGR_H
20 32
21#include <map> 33#include <map>
22using namespace std; 34using namespace std;
23 35
24#include <qlist.h> 36#include <qlist.h>
25#include <qobject.h> 37#include <qobject.h>
26#include <qstring.h> 38#include <qstring.h>
27 39
28#include "server.h" 40#include "server.h"
29#include "destination.h" 41#include "destination.h"
30 42
31 #define LOCAL_SERVER "Installed Pkgs" 43 #define LOCAL_SERVER "Installed Pkgs"
32 #define LOCAL_IPKGS "local IPKG" 44 #define LOCAL_IPKGS "local IPKG"
33 45
34/** 46/**
35 *@author Andy Qua 47 *@author Andy Qua
36 */ 48 */
37 49
38 50
39class DataManager : public QObject 51class DataManager : public QObject
40{ 52{
41 Q_OBJECT 53 Q_OBJECT
42public: 54public:
43 DataManager(); 55 DataManager();
44 ~DataManager(); 56 ~DataManager();
45 57
46 void setActiveServer( const QString &act ) { activeServer = act; } 58 void setActiveServer( const QString &act ) { activeServer = act; }
47 QString &getActiveServer( ) { return activeServer; } 59 QString &getActiveServer( ) { return activeServer; }
48 60
49 Server *getLocalServer() { return ( getServer( LOCAL_SERVER ) ); } 61 Server *getLocalServer() { return ( getServer( LOCAL_SERVER ) ); }
50 QList<Server> &getServerList() { return serverList; } 62 QList<Server> &getServerList() { return serverList; }
51 Server *getServer( const char *name ); 63 Server *getServer( const char *name );
52 64
53 QList<Destination> &getDestinationList() { return destList; } 65 QList<Destination> &getDestinationList() { return destList; }
54 Destination *getDestination( const char *name ); 66 Destination *getDestination( const char *name );
55 67
56 void loadServers(); 68 void loadServers();
57 void reloadServerData( ); 69 void reloadServerData( );
58 70
59 void writeOutIpkgConf(); 71 void writeOutIpkgConf();
60 72
61 static QString getAvailableCategories() { return availableCategories; } 73 static QString getAvailableCategories() { return availableCategories; }
62 static void setAvailableCategories( QString section ); 74 static void setAvailableCategories( QString section );
63 75
64 QString getHttpProxy() { return httpProxy; } 76 QString getHttpProxy() { return httpProxy; }
65 QString getFtpProxy() { return ftpProxy; } 77 QString getFtpProxy() { return ftpProxy; }
66 QString getProxyUsername() { return proxyUsername; } 78 QString getProxyUsername() { return proxyUsername; }
67 QString getProxyPassword() { return proxyPassword; } 79 QString getProxyPassword() { return proxyPassword; }
68 80
69 bool getHttpProxyEnabled() { return httpProxyEnabled; } 81 bool getHttpProxyEnabled() { return httpProxyEnabled; }
70 bool getFtpProxyEnabled() { return ftpProxyEnabled; } 82 bool getFtpProxyEnabled() { return ftpProxyEnabled; }
71 83
72 void setHttpProxy( QString proxy ) { httpProxy = proxy; } 84 void setHttpProxy( QString proxy ) { httpProxy = proxy; }
73 void setFtpProxy( QString proxy ) { ftpProxy = proxy; } 85 void setFtpProxy( QString proxy ) { ftpProxy = proxy; }
74 void setProxyUsername( QString name ) { proxyUsername = name; } 86 void setProxyUsername( QString name ) { proxyUsername = name; }
75 void setProxyPassword( QString pword ) { proxyPassword = pword; } 87 void setProxyPassword( QString pword ) { proxyPassword = pword; }
76 88
77 void setHttpProxyEnabled( bool val ) { httpProxyEnabled = val; } 89 void setHttpProxyEnabled( bool val ) { httpProxyEnabled = val; }
78 void setFtpProxyEnabled( bool val ) { ftpProxyEnabled = val; } 90 void setFtpProxyEnabled( bool val ) { ftpProxyEnabled = val; }
79private: 91private:
80 static QString availableCategories; 92 static QString availableCategories;
81 QString activeServer; 93 QString activeServer;
82 QString httpProxy; 94 QString httpProxy;
83 QString ftpProxy; 95 QString ftpProxy;
84 QString proxyUsername; 96 QString proxyUsername;
85 QString proxyPassword; 97 QString proxyPassword;
86 98
87 bool httpProxyEnabled; 99 bool httpProxyEnabled;
88 bool ftpProxyEnabled; 100 bool ftpProxyEnabled;
89 101
90 QList<Server> serverList; 102 QList<Server> serverList;
91 QList<Destination> destList; 103 QList<Destination> destList;
92 104
93signals: 105signals:
94 void progressSetSteps( int ); 106 void progressSetSteps( int );
95 void progressSetMessage( const QString & ); 107 void progressSetMessage( const QString & );
96 void progressUpdate( int ); 108 void progressUpdate( int );
97}; 109};
98 110
99#endif 111#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 @@
1/*************************************************************************** 1/*
2 destination.cpp - description 2                This file is part of the OPIE Project
3 ------------------- 3
4 begin : Mon Aug 26 2002 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5 copyright : (C) 2002 by Andy Qua 5             .=l. Dan Williams <drw@handhelds.org>
6 email : andy.qua@blueyonder.co.uk 6           .>+-=
7 ***************************************************************************/ 7 _;:,     .>    :=|. This file is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This file is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
8 27
9/*************************************************************************** 28*/
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17 29
18#include "destination.h" 30#include "destination.h"
19#include "global.h" 31#include "global.h"
20 32
21Destination::Destination( const char *name, const char *path ) 33Destination::Destination( const char *name, const char *path )
22{ 34{
23 destName = name; 35 destName = name;
24 destPath = path; 36 destPath = path;
25 linkToRootDir = true; 37 linkToRootDir = true;
26} 38}
27 39
28Destination::~Destination() 40Destination::~Destination()
29{ 41{
30} 42}
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 @@
1/*************************************************************************** 1/*
2 destination.h - description 2                This file is part of the OPIE Project
3 ------------------- 3
4 begin : Mon Aug 26 2002 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5 copyright : (C) 2002 by Andy Qua 5             .=l. Dan Williams <drw@handhelds.org>
6 email : andy.qua@blueyonder.co.uk 6           .>+-=
7 ***************************************************************************/ 7 _;:,     .>    :=|. This file is free software; you can
8 8.> <`_,   >  .   <= redistribute it and/or modify it under
9/*************************************************************************** 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10 * * 10.="- .-=="i,     .._ License as published by the Free Software
11 * This program is free software; you can redistribute it and/or modify * 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12 * it under the terms of the GNU General Public License as published by * 12     ._= =}       : or (at your option) any later version.
13 * the Free Software Foundation; either version 2 of the License, or * 13    .%`+i>       _;_.
14 * (at your option) any later version. * 14    .i_,=:_.      -<s. This file is distributed in the hope that
15 * * 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16 ***************************************************************************/ 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
29
17#ifndef DESTINATION_H 30#ifndef DESTINATION_H
18#define DESTINATION_H 31#define DESTINATION_H
19 32
20#include <qstring.h> 33#include <qstring.h>
21 34
22class Destination 35class Destination
23{ 36{
24public: 37public:
25 Destination() {} 38 Destination() {}
26 Destination( const char *name, const char *path ); 39 Destination( const char *name, const char *path );
27 ~Destination(); 40 ~Destination();
28 41
29 void setDestinationName( const QString &name ) { destName = name; } 42 void setDestinationName( const QString &name ) { destName = name; }
30 void setDestinationPath( const QString &path ) { destPath = path; } 43 void setDestinationPath( const QString &path ) { destPath = path; }
31 void linkToRoot( bool val ) { linkToRootDir = val; } 44 void linkToRoot( bool val ) { linkToRootDir = val; }
32 45
33 bool linkToRoot() { return linkToRootDir; } 46 bool linkToRoot() { return linkToRootDir; }
34 QString &getDestinationName() { return destName; } 47 QString &getDestinationName() { return destName; }
35 QString &getDestinationPath() { return destPath; } 48 QString &getDestinationPath() { return destPath; }
36 49
37protected: 50protected:
38 51
39private: 52private:
40 QString destName; 53 QString destName;
41 QString destPath; 54 QString destPath;
42 bool linkToRootDir; 55 bool linkToRootDir;
43}; 56};
44 57
45#endif 58#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 @@
1/*************************************************************************** 1/*
2 global.h - description 2                This file is part of the OPIE Project
3 ------------------- 3
4 begin : Mon Aug 26 2002 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5 copyright : (C) 2002 by Andy Qua 5             .=l. Dan Williams <drw@handhelds.org>
6 email : andy.qua@blueyonder.co.uk 6           .>+-=
7 ***************************************************************************/ 7 _;:,     .>    :=|. This file is free software; you can
8 8.> <`_,   >  .   <= redistribute it and/or modify it under
9/*************************************************************************** 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10 * * 10.="- .-=="i,     .._ License as published by the Free Software
11 * This program is free software; you can redistribute it and/or modify * 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12 * it under the terms of the GNU General Public License as published by * 12     ._= =}       : or (at your option) any later version.
13 * the Free Software Foundation; either version 2 of the License, or * 13    .%`+i>       _;_.
14 * (at your option) any later version. * 14    .i_,=:_.      -<s. This file is distributed in the hope that
15 * * 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16 ***************************************************************************/ 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
17 29
18#ifndef __GLOBAL_H 30#ifndef __GLOBAL_H
19#define __GLOBAL_H 31#define __GLOBAL_H
20 32
21#define VERSION_TEXT "AQPkg Version 1.11" 33#define VERSION_TEXT "AQPkg Version 1.11"
22 34
23// Uncomment the below line to run on a Linux box rather than a Zaurus 35// Uncomment the below line to run on a Linux box rather than a Zaurus
24// box this allows you to change where root is, and where to load config files from 36// box this allows you to change where root is, and where to load config files from
25// #define X86 37// #define X86
26 38
27// Sets up location of ipkg.conf and root directory 39// Sets up location of ipkg.conf and root directory
28#ifdef QWS 40#ifdef QWS
29 41
30#ifndef X86 42#ifndef X86
31 43
32// Running QT/Embedded on an arm processor 44// Running QT/Embedded on an arm processor
33#define IPKG_CONF "/etc/ipkg.conf" 45#define IPKG_CONF "/etc/ipkg.conf"
34#define ROOT "/" 46#define ROOT "/"
35#define IPKG_DIR "/usr/lib/ipkg/" 47#define IPKG_DIR "/usr/lib/ipkg/"
36 48
37#else 49#else
38 50
39// Running QT/Embedded on a X86 linux box 51// Running QT/Embedded on a X86 linux box
40#define IPKG_CONF "/home/andy/projects/aqpkg/data/ipkg.conf" 52#define IPKG_CONF "/home/andy/projects/aqpkg/data/ipkg.conf"
41#define ROOT "/home/andy/projects/aqpkg/data/root" 53#define ROOT "/home/andy/projects/aqpkg/data/root"
42#define IPKG_DIR "/home/andy/projects/aqpkg/data/" 54#define IPKG_DIR "/home/andy/projects/aqpkg/data/"
43 55
44#endif 56#endif
45 57
46#else 58#else
47 59
48// Running QT on a X86 linux box 60// Running QT on a X86 linux box
49#define IPKG_CONF "/home/andy/projects/aqpkg/data/ipkg.conf" 61#define IPKG_CONF "/home/andy/projects/aqpkg/data/ipkg.conf"
50#define ROOT "/home/andy/projects/aqpkg/data/root" 62#define ROOT "/home/andy/projects/aqpkg/data/root"
51#define IPKG_DIR "/home/andy/projects/aqpkg/data/" 63#define IPKG_DIR "/home/andy/projects/aqpkg/data/"
52 64
53#endif 65#endif
54 66
55 67
56// Uncomment the below line to turn on memory checking 68// Uncomment the below line to turn on memory checking
57//#define _DEBUG 1 69//#define _DEBUG 1
58 70
59#ifndef __MEMFILE_C 71#ifndef __MEMFILE_C
60#ifdef _DEBUG 72#ifdef _DEBUG
61void * operator new(unsigned int size,const char *file, int line); 73void * operator new(unsigned int size,const char *file, int line);
62void operator delete(void *p); 74void operator delete(void *p);
63#endif 75#endif
64 76
65#ifdef _DEBUG 77#ifdef _DEBUG
66#define DEBUG_NEW new(__FILE__, __LINE__) 78#define DEBUG_NEW new(__FILE__, __LINE__)
67//#define DEBUG_NEW new 79//#define DEBUG_NEW new
68#else 80#else
69#define DEBUG_NEW new 81#define DEBUG_NEW new
70#endif 82#endif
71 83
72#define new DEBUG_NEW 84#define new DEBUG_NEW
73#endif 85#endif
74 86
75 87
76void AddTrack(long addr, long asize, const char *fname, long lnum); 88void AddTrack(long addr, long asize, const char *fname, long lnum);
77void RemoveTrack(long addr); 89void RemoveTrack(long addr);
78void DumpUnfreed(); 90void DumpUnfreed();
79 91
80#endif 92#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,121 +1,134 @@
1/*************************************************************************** 1/*
2 inputdlg.h - description 2                This file is part of the OPIE Project
3 ------------------- 3
4 begin : Mon Aug 26 2002 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5 copyright : (C) 2002 by Andy Qua 5             .=l. Dan Williams <drw@handhelds.org>
6 email : andy.qua@blueyonder.co.uk 6           .>+-=
7 ***************************************************************************/ 7 _;:,     .>    :=|. This file is free software; you can
8 8.> <`_,   >  .   <= redistribute it and/or modify it under
9/*************************************************************************** 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10 * * 10.="- .-=="i,     .._ License as published by the Free Software
11 * This program is free software; you can redistribute it and/or modify * 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12 * it under the terms of the GNU General Public License as published by * 12     ._= =}       : or (at your option) any later version.
13 * the Free Software Foundation; either version 2 of the License, or * 13    .%`+i>       _;_.
14 * (at your option) any later version. * 14    .i_,=:_.      -<s. This file is distributed in the hope that
15 * * 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16 ***************************************************************************/ 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
29
17#include <qlayout.h> 30#include <qlayout.h>
18#include <qlabel.h> 31#include <qlabel.h>
19#include <qlineedit.h> 32#include <qlineedit.h>
20#include <qpushbutton.h> 33#include <qpushbutton.h>
21#include <qspinbox.h> 34#include <qspinbox.h>
22#include <qcombobox.h> 35#include <qcombobox.h>
23#include <qwidgetstack.h> 36#include <qwidgetstack.h>
24#include <qvalidator.h> 37#include <qvalidator.h>
25#include <qapplication.h> 38#include <qapplication.h>
26 39
27#include "inputdlg.h" 40#include "inputdlg.h"
28#include "global.h" 41#include "global.h"
29 42
30 43
31InputDialog :: InputDialog( const QString &label, QWidget* parent, const char* name, 44InputDialog :: InputDialog( const QString &label, QWidget* parent, const char* name,
32 bool modal ) 45 bool modal )
33 : QDialog( parent, name, modal ) 46 : QDialog( parent, name, modal )
34{ 47{
35 lineEdit = 0; 48 lineEdit = 0;
36 49
37 QVBoxLayout *vbox = new QVBoxLayout( this, 6, 6 ); 50 QVBoxLayout *vbox = new QVBoxLayout( this, 6, 6 );
38 51
39 QLabel* l = new QLabel( label, this ); 52 QLabel* l = new QLabel( label, this );
40 vbox->addWidget( l ); 53 vbox->addWidget( l );
41 54
42 lineEdit = new QLineEdit( this ); 55 lineEdit = new QLineEdit( this );
43 vbox->addWidget( lineEdit ); 56 vbox->addWidget( lineEdit );
44 57
45 QHBoxLayout *hbox = new QHBoxLayout( 6 ); 58 QHBoxLayout *hbox = new QHBoxLayout( 6 );
46 vbox->addLayout( hbox, AlignRight ); 59 vbox->addLayout( hbox, AlignRight );
47 60
48 ok = new QPushButton( tr( "&OK" ), this ); 61 ok = new QPushButton( tr( "&OK" ), this );
49 ok->setDefault( TRUE ); 62 ok->setDefault( TRUE );
50 QPushButton *cancel = new QPushButton( tr( "&Cancel" ), this ); 63 QPushButton *cancel = new QPushButton( tr( "&Cancel" ), this );
51 64
52 QSize bs( ok->sizeHint() ); 65 QSize bs( ok->sizeHint() );
53 if ( cancel->sizeHint().width() > bs.width() ) 66 if ( cancel->sizeHint().width() > bs.width() )
54 bs.setWidth( cancel->sizeHint().width() ); 67 bs.setWidth( cancel->sizeHint().width() );
55 68
56 ok->setFixedSize( bs ); 69 ok->setFixedSize( bs );
57 cancel->setFixedSize( bs ); 70 cancel->setFixedSize( bs );
58 71
59 hbox->addWidget( new QWidget( this ) ); 72 hbox->addWidget( new QWidget( this ) );
60 hbox->addWidget( ok ); 73 hbox->addWidget( ok );
61 hbox->addWidget( cancel ); 74 hbox->addWidget( cancel );
62 75
63 connect( lineEdit, SIGNAL( returnPressed() ), 76 connect( lineEdit, SIGNAL( returnPressed() ),
64 this, SLOT( tryAccept() ) ); 77 this, SLOT( tryAccept() ) );
65 connect( lineEdit, SIGNAL( textChanged( const QString & ) ), 78 connect( lineEdit, SIGNAL( textChanged( const QString & ) ),
66 this, SLOT( textChanged( const QString & ) ) ); 79 this, SLOT( textChanged( const QString & ) ) );
67 80
68 connect( ok, SIGNAL( clicked() ), this, SLOT( accept() ) ); 81 connect( ok, SIGNAL( clicked() ), this, SLOT( accept() ) );
69 connect( cancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); 82 connect( cancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
70 83
71 resize( QMAX( sizeHint().width(), 240 ), sizeHint().height() ); 84 resize( QMAX( sizeHint().width(), 240 ), sizeHint().height() );
72} 85}
73 86
74/*! 87/*!
75 Destructor. 88 Destructor.
76*/ 89*/
77 90
78InputDialog::~InputDialog() 91InputDialog::~InputDialog()
79{ 92{
80} 93}
81 94
82void InputDialog :: setText( const QString &text ) 95void InputDialog :: setText( const QString &text )
83{ 96{
84 lineEdit->setText( text ); 97 lineEdit->setText( text );
85 lineEdit->selectAll(); 98 lineEdit->selectAll();
86} 99}
87 100
88QString InputDialog :: getText() 101QString InputDialog :: getText()
89{ 102{
90 return lineEdit->text(); 103 return lineEdit->text();
91} 104}
92 105
93QString InputDialog::getText( const QString &caption, const QString &label, 106QString InputDialog::getText( const QString &caption, const QString &label,
94 const QString &text, bool *ok, QWidget *parent, 107 const QString &text, bool *ok, QWidget *parent,
95 const char *name ) 108 const char *name )
96{ 109{
97 InputDialog *dlg = new InputDialog( label, parent, name, true ); 110 InputDialog *dlg = new InputDialog( label, parent, name, true );
98 dlg->setCaption( caption ); 111 dlg->setCaption( caption );
99 dlg->setText( text ); 112 dlg->setText( text );
100 113
101 QString result; 114 QString result;
102 *ok = dlg->exec() == QDialog::Accepted; 115 *ok = dlg->exec() == QDialog::Accepted;
103 if ( *ok ) 116 if ( *ok )
104 result = dlg->getText(); 117 result = dlg->getText();
105 118
106 delete dlg; 119 delete dlg;
107 return result; 120 return result;
108} 121}
109 122
110 123
111 124
112void InputDialog :: textChanged( const QString &s ) 125void InputDialog :: textChanged( const QString &s )
113{ 126{
114 ok->setEnabled( !s.isEmpty() ); 127 ok->setEnabled( !s.isEmpty() );
115} 128}
116 129
117void InputDialog :: tryAccept() 130void InputDialog :: tryAccept()
118{ 131{
119 if ( !lineEdit->text().isEmpty() ) 132 if ( !lineEdit->text().isEmpty() )
120 accept(); 133 accept();
121} 134}
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 @@
1/*************************************************************************** 1/*
2 inputdlg.h - description 2                This file is part of the OPIE Project
3 ------------------- 3
4 begin : Mon Aug 26 2002 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5 copyright : (C) 2002 by Andy Qua 5             .=l. Dan Williams <drw@handhelds.org>
6 email : andy.qua@blueyonder.co.uk 6           .>+-=
7 ***************************************************************************/ 7 _;:,     .>    :=|. This file is free software; you can
8 8.> <`_,   >  .   <= redistribute it and/or modify it under
9/*************************************************************************** 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10 * * 10.="- .-=="i,     .._ License as published by the Free Software
11 * This program is free software; you can redistribute it and/or modify * 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12 * it under the terms of the GNU General Public License as published by * 12     ._= =}       : or (at your option) any later version.
13 * the Free Software Foundation; either version 2 of the License, or * 13    .%`+i>       _;_.
14 * (at your option) any later version. * 14    .i_,=:_.      -<s. This file is distributed in the hope that
15 * * 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16 ***************************************************************************/ 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
17 29
18#ifndef INPUTDIALOG_H 30#ifndef INPUTDIALOG_H
19#define INPUTDIALOG_H 31#define INPUTDIALOG_H
20 32
21#include <qdialog.h> 33#include <qdialog.h>
22#include <qstring.h> 34#include <qstring.h>
23#include <qlineedit.h> 35#include <qlineedit.h>
24#include <qpushbutton.h> 36#include <qpushbutton.h>
25 37
26class InputDialog : public QDialog 38class InputDialog : public QDialog
27{ 39{
28 Q_OBJECT 40 Q_OBJECT
29 41
30public: 42public:
31 static QString getText( const QString &caption, const QString &label, const QString &text = QString::null, 43 static QString getText( const QString &caption, const QString &label, const QString &text = QString::null,
32 bool *ok = 0, QWidget *parent = 0, const char *name = 0 ); 44 bool *ok = 0, QWidget *parent = 0, const char *name = 0 );
33 45
34 InputDialog( const QString &label, QWidget* parent = 0, const char* name = 0, 46 InputDialog( const QString &label, QWidget* parent = 0, const char* name = 0,
35 bool modal = TRUE ); 47 bool modal = TRUE );
36 ~InputDialog(); 48 ~InputDialog();
37 49
38 void setText( const QString &text ); 50 void setText( const QString &text );
39 QString getText(); 51 QString getText();
40 52
41private slots: 53private slots:
42 void textChanged( const QString &s ); 54 void textChanged( const QString &s );
43 void tryAccept(); 55 void tryAccept();
44 56
45private: 57private:
46 QLineEdit *lineEdit; 58 QLineEdit *lineEdit;
47 QPushButton *ok; 59 QPushButton *ok;
48}; 60};
49 61
50#endif // INPUTDIALOG_H 62#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,466 +1,478 @@
1/*************************************************************************** 1/*
2 installdlgimpl.cpp - description 2                This file is part of the OPIE Project
3 ------------------- 3
4 begin : Mon Aug 26 2002 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5 copyright : (C) 2002 by Andy Qua 5             .=l. Dan Williams <drw@handhelds.org>
6 email : andy.qua@blueyonder.co.uk 6           .>+-=
7 ***************************************************************************/ 7 _;:,     .>    :=|. This file is free software; you can
8 8.> <`_,   >  .   <= redistribute it and/or modify it under
9/*************************************************************************** 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10 * * 10.="- .-=="i,     .._ License as published by the Free Software
11 * This program is free software; you can redistribute it and/or modify * 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12 * it under the terms of the GNU General Public License as published by * 12     ._= =}       : or (at your option) any later version.
13 * the Free Software Foundation; either version 2 of the License, or * 13    .%`+i>       _;_.
14 * (at your option) any later version. * 14    .i_,=:_.      -<s. This file is distributed in the hope that
15 * * 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16 ***************************************************************************/ 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
17 29
18#include <stdio.h> 30#include <stdio.h>
19 31
20#include <opie/ofiledialog.h> 32#include <opie/ofiledialog.h>
21 33
22#ifdef QWS 34#ifdef QWS
23#include <qpe/config.h> 35#include <qpe/config.h>
24#include <qpe/fileselector.h> 36#include <qpe/fileselector.h>
25#include <qpe/qpeapplication.h> 37#include <qpe/qpeapplication.h>
26#include <qpe/resource.h> 38#include <qpe/resource.h>
27#include <qpe/storage.h> 39#include <qpe/storage.h>
28#endif 40#endif
29 41
30#include <qcheckbox.h> 42#include <qcheckbox.h>
31#include <qcombobox.h> 43#include <qcombobox.h>
32#include <qdialog.h> 44#include <qdialog.h>
33#include <qfileinfo.h> 45#include <qfileinfo.h>
34#include <qgroupbox.h> 46#include <qgroupbox.h>
35#include <qmultilineedit.h> 47#include <qmultilineedit.h>
36#include <qlabel.h> 48#include <qlabel.h>
37#include <qlayout.h> 49#include <qlayout.h>
38#include <qpushbutton.h> 50#include <qpushbutton.h>
39 51
40#include "datamgr.h" 52#include "datamgr.h"
41#include "destination.h" 53#include "destination.h"
42#include "instoptionsimpl.h" 54#include "instoptionsimpl.h"
43#include "installdlgimpl.h" 55#include "installdlgimpl.h"
44#include "ipkg.h" 56#include "ipkg.h"
45#include "utils.h" 57#include "utils.h"
46#include "global.h" 58#include "global.h"
47 59
48enum { 60enum {
49 MAXLINES = 100, 61 MAXLINES = 100,
50}; 62};
51 63
52InstallDlgImpl::InstallDlgImpl( const QList<InstallData> &packageList, DataManager *dataManager, const char *title ) 64InstallDlgImpl::InstallDlgImpl( const QList<InstallData> &packageList, DataManager *dataManager, const char *title )
53 : QWidget( 0, 0, 0 ) 65 : QWidget( 0, 0, 0 )
54{ 66{
55 setCaption( title ); 67 setCaption( title );
56 init( TRUE ); 68 init( TRUE );
57 69
58 pIpkg = 0; 70 pIpkg = 0;
59 upgradePackages = false; 71 upgradePackages = false;
60 dataMgr = dataManager; 72 dataMgr = dataManager;
61 73
62 QString defaultDest = "root"; 74 QString defaultDest = "root";
63#ifdef QWS 75#ifdef QWS
64 Config cfg( "aqpkg" ); 76 Config cfg( "aqpkg" );
65 cfg.setGroup( "settings" ); 77 cfg.setGroup( "settings" );
66 defaultDest = cfg.readEntry( "dest", "root" ); 78 defaultDest = cfg.readEntry( "dest", "root" );
67 79
68 // Grab flags - Turn MAKE_LINKS on by default (if no flags found) 80 // Grab flags - Turn MAKE_LINKS on by default (if no flags found)
69 flags = cfg.readNumEntry( "installFlags", 0 ); 81 flags = cfg.readNumEntry( "installFlags", 0 );
70 infoLevel = cfg.readNumEntry( "infoLevel", 1 ); 82 infoLevel = cfg.readNumEntry( "infoLevel", 1 );
71#else 83#else
72 flags = 0; 84 flags = 0;
73#endif 85#endif
74 86
75 // Output text is read only 87 // Output text is read only
76 output->setReadOnly( true ); 88 output->setReadOnly( true );
77 //QFont f( "helvetica" ); 89 //QFont f( "helvetica" );
78 //f.setPointSize( 10 ); 90 //f.setPointSize( 10 );
79 //output->setFont( f ); 91 //output->setFont( f );
80 92
81 93
82 // setup destination data 94 // setup destination data
83 int defIndex = 0; 95 int defIndex = 0;
84 int i; 96 int i;
85 QListIterator<Destination> dit( dataMgr->getDestinationList() ); 97 QListIterator<Destination> dit( dataMgr->getDestinationList() );
86 for ( i = 0; dit.current(); ++dit, ++i ) 98 for ( i = 0; dit.current(); ++dit, ++i )
87 { 99 {
88 destination->insertItem( dit.current()->getDestinationName() ); 100 destination->insertItem( dit.current()->getDestinationName() );
89 if ( dit.current()->getDestinationName() == defaultDest ) 101 if ( dit.current()->getDestinationName() == defaultDest )
90 defIndex = i; 102 defIndex = i;
91 } 103 }
92 104
93 destination->setCurrentItem( defIndex ); 105 destination->setCurrentItem( defIndex );
94 106
95 QListIterator<InstallData> it( packageList ); 107 QListIterator<InstallData> it( packageList );
96 // setup package data 108 // setup package data
97 QString remove = tr( "Remove\n" ); 109 QString remove = tr( "Remove\n" );
98 QString install = tr( "Install\n" ); 110 QString install = tr( "Install\n" );
99 QString upgrade = tr( "Upgrade\n" ); 111 QString upgrade = tr( "Upgrade\n" );
100 for ( ; it.current(); ++it ) 112 for ( ; it.current(); ++it )
101 { 113 {
102 InstallData *item = it.current(); 114 InstallData *item = it.current();
103 InstallData *newitem = new InstallData(); 115 InstallData *newitem = new InstallData();
104 116
105 newitem->option = item->option; 117 newitem->option = item->option;
106 newitem->packageName = item->packageName; 118 newitem->packageName = item->packageName;
107 newitem->destination = item->destination; 119 newitem->destination = item->destination;
108 newitem->recreateLinks = item->recreateLinks; 120 newitem->recreateLinks = item->recreateLinks;
109 packages.append( newitem ); 121 packages.append( newitem );
110 122
111 if ( item->option == "I" ) 123 if ( item->option == "I" )
112 { 124 {
113 install.append( QString( " %1\n" ).arg( item->packageName ) ); 125 install.append( QString( " %1\n" ).arg( item->packageName ) );
114 } 126 }
115 else if ( item->option == "D" ) 127 else if ( item->option == "D" )
116 { 128 {
117 remove.append( QString( " %1\n" ).arg( item->packageName ) ); 129 remove.append( QString( " %1\n" ).arg( item->packageName ) );
118 } 130 }
119 else if ( item->option == "U" || item->option == "R" ) 131 else if ( item->option == "U" || item->option == "R" )
120 { 132 {
121 QString type; 133 QString type;
122 if ( item->option == "R" ) 134 if ( item->option == "R" )
123 type = tr( "(ReInstall)" ); 135 type = tr( "(ReInstall)" );
124 else 136 else
125 type = tr( "(Upgrade)" ); 137 type = tr( "(Upgrade)" );
126 upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) ); 138 upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) );
127 } 139 }
128 } 140 }
129 141
130 output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) ); 142 output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) );
131 143
132 displayAvailableSpace( destination->currentText() ); 144 displayAvailableSpace( destination->currentText() );
133} 145}
134 146
135InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title ) 147InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title )
136 : QWidget( 0, 0, 0 ) 148 : QWidget( 0, 0, 0 )
137{ 149{
138 setCaption( title ); 150 setCaption( title );
139 init( FALSE ); 151 init( FALSE );
140 pIpkg = ipkg; 152 pIpkg = ipkg;
141 output->setText( initialText ); 153 output->setText( initialText );
142} 154}
143 155
144 156
145InstallDlgImpl::~InstallDlgImpl() 157InstallDlgImpl::~InstallDlgImpl()
146{ 158{
147 if ( pIpkg ) 159 if ( pIpkg )
148 delete pIpkg; 160 delete pIpkg;
149} 161}
150 162
151void InstallDlgImpl :: init( bool displayextrainfo ) 163void InstallDlgImpl :: init( bool displayextrainfo )
152{ 164{
153 QGridLayout *layout = new QGridLayout( this ); 165 QGridLayout *layout = new QGridLayout( this );
154 layout->setSpacing( 4 ); 166 layout->setSpacing( 4 );
155 layout->setMargin( 4 ); 167 layout->setMargin( 4 );
156 168
157 if ( displayextrainfo ) 169 if ( displayextrainfo )
158 { 170 {
159 QLabel *label = new QLabel( tr( "Destination" ), this ); 171 QLabel *label = new QLabel( tr( "Destination" ), this );
160 layout->addWidget( label, 0, 0 ); 172 layout->addWidget( label, 0, 0 );
161 destination = new QComboBox( FALSE, this ); 173 destination = new QComboBox( FALSE, this );
162 layout->addWidget( destination, 0, 1 ); 174 layout->addWidget( destination, 0, 1 );
163 connect( destination, SIGNAL( highlighted( const QString & ) ), 175 connect( destination, SIGNAL( highlighted( const QString & ) ),
164 this, SLOT( displayAvailableSpace( const QString & ) ) ); 176 this, SLOT( displayAvailableSpace( const QString & ) ) );
165 177
166 QLabel *label2 = new QLabel( tr( "Space Avail" ), this ); 178 QLabel *label2 = new QLabel( tr( "Space Avail" ), this );
167 layout->addWidget( label2, 1, 0 ); 179 layout->addWidget( label2, 1, 0 );
168 txtAvailableSpace = new QLabel( "", this ); 180 txtAvailableSpace = new QLabel( "", this );
169 layout->addWidget( txtAvailableSpace, 1, 1 ); 181 layout->addWidget( txtAvailableSpace, 1, 1 );
170 } 182 }
171 else 183 else
172 { 184 {
173 destination = 0x0; 185 destination = 0x0;
174 txtAvailableSpace = 0x0; 186 txtAvailableSpace = 0x0;
175 } 187 }
176 188
177 QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); 189 QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this );
178 GroupBox2->layout()->setSpacing( 0 ); 190 GroupBox2->layout()->setSpacing( 0 );
179 GroupBox2->layout()->setMargin( 4 ); 191 GroupBox2->layout()->setMargin( 4 );
180 192
181 QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() ); 193 QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() );
182 output = new QMultiLineEdit( GroupBox2 ); 194 output = new QMultiLineEdit( GroupBox2 );
183 GroupBox2Layout->addWidget( output ); 195 GroupBox2Layout->addWidget( output );
184 layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 ); 196 layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 );
185 197
186 btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this ); 198 btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this );
187 layout->addWidget( btnInstall, 3, 0 ); 199 layout->addWidget( btnInstall, 3, 0 );
188 connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) ); 200 connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) );
189 201
190 btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this ); 202 btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this );
191 layout->addWidget( btnOptions, 3, 1 ); 203 layout->addWidget( btnOptions, 3, 1 );
192 connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) ); 204 connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) );
193} 205}
194 206
195void InstallDlgImpl :: optionsSelected() 207void InstallDlgImpl :: optionsSelected()
196{ 208{
197 if ( btnOptions->text() == tr( "Options" ) ) 209 if ( btnOptions->text() == tr( "Options" ) )
198 { 210 {
199 InstallOptionsDlgImpl opt( flags, infoLevel, this, "Option", true ); 211 InstallOptionsDlgImpl opt( flags, infoLevel, this, "Option", true );
200 if ( opt.exec() == QDialog::Accepted ) 212 if ( opt.exec() == QDialog::Accepted )
201 { 213 {
202 // set options selected from dialog 214 // set options selected from dialog
203 flags = opt.getFlags(); 215 flags = opt.getFlags();
204 infoLevel = opt.getInfoLevel(); 216 infoLevel = opt.getInfoLevel();
205 217
206#ifdef QWS 218#ifdef QWS
207 Config cfg( "aqpkg" ); 219 Config cfg( "aqpkg" );
208 cfg.setGroup( "settings" ); 220 cfg.setGroup( "settings" );
209 cfg.writeEntry( "installFlags", flags ); 221 cfg.writeEntry( "installFlags", flags );
210 cfg.writeEntry( "infoLevel", infoLevel ); 222 cfg.writeEntry( "infoLevel", infoLevel );
211#endif 223#endif
212 } 224 }
213 } 225 }
214 else // Save output 226 else // Save output
215 { 227 {
216 QMap<QString, QStringList> map; 228 QMap<QString, QStringList> map;
217 map.insert( tr( "All" ), QStringList() ); 229 map.insert( tr( "All" ), QStringList() );
218 QStringList text; 230 QStringList text;
219 text << "text/*"; 231 text << "text/*";
220 map.insert(tr( "Text" ), text ); 232 map.insert(tr( "Text" ), text );
221 text << "*"; 233 text << "*";
222 map.insert( tr( "All" ), text ); 234 map.insert( tr( "All" ), text );
223 235
224 QString filename = OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); 236 QString filename = OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map );
225 if( !filename.isEmpty() ) 237 if( !filename.isEmpty() )
226 { 238 {
227 QString currentFileName = QFileInfo( filename ).fileName(); 239 QString currentFileName = QFileInfo( filename ).fileName();
228 DocLnk doc; 240 DocLnk doc;
229 doc.setType( "text/plain" ); 241 doc.setType( "text/plain" );
230 doc.setFile( filename ); 242 doc.setFile( filename );
231 doc.setName( currentFileName ); 243 doc.setName( currentFileName );
232 FileManager fm; 244 FileManager fm;
233 fm.saveFile( doc, output->text() ); 245 fm.saveFile( doc, output->text() );
234 } 246 }
235 } 247 }
236} 248}
237 249
238void InstallDlgImpl :: installSelected() 250void InstallDlgImpl :: installSelected()
239{ 251{
240 if ( btnInstall->text() == tr( "Abort" ) ) 252 if ( btnInstall->text() == tr( "Abort" ) )
241 { 253 {
242 if ( pIpkg ) 254 if ( pIpkg )
243 { 255 {
244 displayText( tr( "\n**** User Clicked ABORT ***" ) ); 256 displayText( tr( "\n**** User Clicked ABORT ***" ) );
245 pIpkg->abort(); 257 pIpkg->abort();
246 displayText( tr( "**** Process Aborted ****" ) ); 258 displayText( tr( "**** Process Aborted ****" ) );
247 } 259 }
248 260
249 btnInstall->setText( tr( "Close" ) ); 261 btnInstall->setText( tr( "Close" ) );
250 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); 262 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) );
251 return; 263 return;
252 } 264 }
253 else if ( btnInstall->text() == tr( "Close" ) ) 265 else if ( btnInstall->text() == tr( "Close" ) )
254 { 266 {
255 emit reloadData( this ); 267 emit reloadData( this );
256 return; 268 return;
257 } 269 }
258 270
259 // Disable buttons 271 // Disable buttons
260 btnOptions->setEnabled( false ); 272 btnOptions->setEnabled( false );
261// btnInstall->setEnabled( false ); 273// btnInstall->setEnabled( false );
262 274
263 btnInstall->setText( tr( "Abort" ) ); 275 btnInstall->setText( tr( "Abort" ) );
264 btnInstall->setIconSet( Resource::loadPixmap( "close" ) ); 276 btnInstall->setIconSet( Resource::loadPixmap( "close" ) );
265 277
266 if ( pIpkg ) 278 if ( pIpkg )
267 { 279 {
268 output->setText( "" ); 280 output->setText( "" );
269 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 281 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
270 connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished())); 282 connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished()));
271 pIpkg->runIpkg(); 283 pIpkg->runIpkg();
272 } 284 }
273 else 285 else
274 { 286 {
275 output->setText( "" ); 287 output->setText( "" );
276 Destination *d = dataMgr->getDestination( destination->currentText() ); 288 Destination *d = dataMgr->getDestination( destination->currentText() );
277 QString dest = d->getDestinationName(); 289 QString dest = d->getDestinationName();
278 QString destDir = d->getDestinationPath(); 290 QString destDir = d->getDestinationPath();
279 int instFlags = flags; 291 int instFlags = flags;
280 if ( d->linkToRoot() ) 292 if ( d->linkToRoot() )
281 instFlags |= MAKE_LINKS; 293 instFlags |= MAKE_LINKS;
282 294
283#ifdef QWS 295#ifdef QWS
284 // Save settings 296 // Save settings
285 Config cfg( "aqpkg" ); 297 Config cfg( "aqpkg" );
286 cfg.setGroup( "settings" ); 298 cfg.setGroup( "settings" );
287 cfg.writeEntry( "dest", dest ); 299 cfg.writeEntry( "dest", dest );
288#endif 300#endif
289 301
290 pIpkg = new Ipkg; 302 pIpkg = new Ipkg;
291 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 303 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
292 connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished())); 304 connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished()));
293 305
294 firstPackage = TRUE; 306 firstPackage = TRUE;
295 ipkgFinished(); 307 ipkgFinished();
296 308
297 // First run through the remove list, then the install list then the upgrade list 309 // First run through the remove list, then the install list then the upgrade list
298/* 310/*
299 pIpkg->setOption( "remove" ); 311 pIpkg->setOption( "remove" );
300 QListIterator<InstallData> it( removeList ); 312 QListIterator<InstallData> it( removeList );
301 InstallData *idata; 313 InstallData *idata;
302 for ( ; it.current(); ++it ) 314 for ( ; it.current(); ++it )
303 { 315 {
304 idata = it.current(); 316 idata = it.current();
305 pIpkg->setDestination( idata->destination->getDestinationName() ); 317 pIpkg->setDestination( idata->destination->getDestinationName() );
306 pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); 318 pIpkg->setDestinationDir( idata->destination->getDestinationPath() );
307 pIpkg->setPackage( idata->packageName ); 319 pIpkg->setPackage( idata->packageName );
308 320
309 int tmpFlags = flags; 321 int tmpFlags = flags;
310 if ( idata->destination->linkToRoot() ) 322 if ( idata->destination->linkToRoot() )
311 tmpFlags |= MAKE_LINKS; 323 tmpFlags |= MAKE_LINKS;
312 324
313 pIpkg->setFlags( tmpFlags, infoLevel ); 325 pIpkg->setFlags( tmpFlags, infoLevel );
314 pIpkg->runIpkg(); 326 pIpkg->runIpkg();
315 } 327 }
316 328
317 pIpkg->setOption( "install" ); 329 pIpkg->setOption( "install" );
318 pIpkg->setDestination( dest ); 330 pIpkg->setDestination( dest );
319 pIpkg->setDestinationDir( destDir ); 331 pIpkg->setDestinationDir( destDir );
320 pIpkg->setFlags( instFlags, infoLevel ); 332 pIpkg->setFlags( instFlags, infoLevel );
321 QListIterator<InstallData> it2( installList ); 333 QListIterator<InstallData> it2( installList );
322 for ( ; it2.current(); ++it2 ) 334 for ( ; it2.current(); ++it2 )
323 { 335 {
324 pIpkg->setPackage( it2.current()->packageName ); 336 pIpkg->setPackage( it2.current()->packageName );
325 pIpkg->runIpkg(); 337 pIpkg->runIpkg();
326 } 338 }
327 339
328 flags |= FORCE_REINSTALL; 340 flags |= FORCE_REINSTALL;
329 QListIterator<InstallData> it3( updateList ); 341 QListIterator<InstallData> it3( updateList );
330 for ( ; it3.current() ; ++it3 ) 342 for ( ; it3.current() ; ++it3 )
331 { 343 {
332 idata = it3.current(); 344 idata = it3.current();
333 if ( idata->option == "R" ) 345 if ( idata->option == "R" )
334 pIpkg->setOption( "reinstall" ); 346 pIpkg->setOption( "reinstall" );
335 else 347 else
336 pIpkg->setOption( "upgrade" ); 348 pIpkg->setOption( "upgrade" );
337 pIpkg->setDestination( idata->destination->getDestinationName() ); 349 pIpkg->setDestination( idata->destination->getDestinationName() );
338 pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); 350 pIpkg->setDestinationDir( idata->destination->getDestinationPath() );
339 pIpkg->setPackage( idata->packageName ); 351 pIpkg->setPackage( idata->packageName );
340 352
341 int tmpFlags = flags; 353 int tmpFlags = flags;
342 if ( idata->destination->linkToRoot() && idata->recreateLinks ) 354 if ( idata->destination->linkToRoot() && idata->recreateLinks )
343 tmpFlags |= MAKE_LINKS; 355 tmpFlags |= MAKE_LINKS;
344 pIpkg->setFlags( tmpFlags, infoLevel ); 356 pIpkg->setFlags( tmpFlags, infoLevel );
345 pIpkg->runIpkg(); 357 pIpkg->runIpkg();
346 } 358 }
347 359
348 delete pIpkg; 360 delete pIpkg;
349 pIpkg = 0; 361 pIpkg = 0;
350*/ 362*/
351 } 363 }
352} 364}
353 365
354 366
355void InstallDlgImpl :: displayText(const QString &text ) 367void InstallDlgImpl :: displayText(const QString &text )
356{ 368{
357 QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text ); 369 QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text );
358 370
359 /* Set a max line count for the QMultiLineEdit, as users have reported 371 /* Set a max line count for the QMultiLineEdit, as users have reported
360 * performance issues when line count gets extreme. 372 * performance issues when line count gets extreme.
361 */ 373 */
362 if(output->numLines() >= MAXLINES) 374 if(output->numLines() >= MAXLINES)
363 output->removeLine(0); 375 output->removeLine(0);
364 output->setText( newtext ); 376 output->setText( newtext );
365 output->setCursorPosition( output->numLines(), 0 ); 377 output->setCursorPosition( output->numLines(), 0 );
366} 378}
367 379
368 380
369void InstallDlgImpl :: displayAvailableSpace( const QString &text ) 381void InstallDlgImpl :: displayAvailableSpace( const QString &text )
370{ 382{
371 Destination *d = dataMgr->getDestination( text ); 383 Destination *d = dataMgr->getDestination( text );
372 QString destDir = d->getDestinationPath(); 384 QString destDir = d->getDestinationPath();
373 385
374 long blockSize = 0; 386 long blockSize = 0;
375 long totalBlocks = 0; 387 long totalBlocks = 0;
376 long availBlocks = 0; 388 long availBlocks = 0;
377 QString space; 389 QString space;
378 if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) ) 390 if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) )
379 { 391 {
380 long mult = blockSize / 1024; 392 long mult = blockSize / 1024;
381 long div = 1024 / blockSize; 393 long div = 1024 / blockSize;
382 394
383 if ( !mult ) mult = 1; 395 if ( !mult ) mult = 1;
384 if ( !div ) div = 1; 396 if ( !div ) div = 1;
385// long total = totalBlocks * mult / div; 397// long total = totalBlocks * mult / div;
386 long avail = availBlocks * mult / div; 398 long avail = availBlocks * mult / div;
387// long used = total - avail; 399// long used = total - avail;
388 400
389 space.sprintf( "%ld Kb", avail ); 401 space.sprintf( "%ld Kb", avail );
390 } 402 }
391 else 403 else
392 space = tr( "Unknown" ); 404 space = tr( "Unknown" );
393 405
394 if ( txtAvailableSpace ) 406 if ( txtAvailableSpace )
395 txtAvailableSpace->setText( space ); 407 txtAvailableSpace->setText( space );
396} 408}
397 409
398void InstallDlgImpl :: ipkgFinished() 410void InstallDlgImpl :: ipkgFinished()
399{ 411{
400 InstallData *item; 412 InstallData *item;
401 if ( firstPackage ) 413 if ( firstPackage )
402 item = packages.first(); 414 item = packages.first();
403 else 415 else
404 { 416 {
405 // Create symlinks if necessary before moving on to next package 417 // Create symlinks if necessary before moving on to next package
406 pIpkg->createSymLinks(); 418 pIpkg->createSymLinks();
407 419
408 item = packages.next(); 420 item = packages.next();
409 } 421 }
410 422
411 firstPackage = FALSE; 423 firstPackage = FALSE;
412 if ( item ) 424 if ( item )
413 { 425 {
414 pIpkg->setPackage( item->packageName ); 426 pIpkg->setPackage( item->packageName );
415 int tmpFlags = flags; 427 int tmpFlags = flags;
416 428
417 if ( item->option == "I" ) 429 if ( item->option == "I" )
418 { 430 {
419 pIpkg->setOption( "install" ); 431 pIpkg->setOption( "install" );
420 Destination *d = dataMgr->getDestination( destination->currentText() ); 432 Destination *d = dataMgr->getDestination( destination->currentText() );
421 pIpkg->setDestination( d->getDestinationName() ); 433 pIpkg->setDestination( d->getDestinationName() );
422 pIpkg->setDestinationDir( d->getDestinationPath() ); 434 pIpkg->setDestinationDir( d->getDestinationPath() );
423 435
424 if ( d->linkToRoot() ) 436 if ( d->linkToRoot() )
425 tmpFlags |= MAKE_LINKS; 437 tmpFlags |= MAKE_LINKS;
426 } 438 }
427 else if ( item->option == "D" ) 439 else if ( item->option == "D" )
428 { 440 {
429 pIpkg->setOption( "remove" ); 441 pIpkg->setOption( "remove" );
430 pIpkg->setDestination( item->destination->getDestinationName() ); 442 pIpkg->setDestination( item->destination->getDestinationName() );
431 pIpkg->setDestinationDir( item->destination->getDestinationPath() ); 443 pIpkg->setDestinationDir( item->destination->getDestinationPath() );
432 444
433 if ( item->destination->linkToRoot() ) 445 if ( item->destination->linkToRoot() )
434 tmpFlags |= MAKE_LINKS; 446 tmpFlags |= MAKE_LINKS;
435 } 447 }
436 else 448 else
437 { 449 {
438 if ( item->option == "R" ) 450 if ( item->option == "R" )
439 pIpkg->setOption( "reinstall" ); 451 pIpkg->setOption( "reinstall" );
440 else 452 else
441 pIpkg->setOption( "upgrade" ); 453 pIpkg->setOption( "upgrade" );
442 454
443 pIpkg->setDestination( item->destination->getDestinationName() ); 455 pIpkg->setDestination( item->destination->getDestinationName() );
444 pIpkg->setDestinationDir( item->destination->getDestinationPath() ); 456 pIpkg->setDestinationDir( item->destination->getDestinationPath() );
445 pIpkg->setPackage( item->packageName ); 457 pIpkg->setPackage( item->packageName );
446 458
447 tmpFlags |= FORCE_REINSTALL; 459 tmpFlags |= FORCE_REINSTALL;
448 if ( item->destination->linkToRoot() && item->recreateLinks ) 460 if ( item->destination->linkToRoot() && item->recreateLinks )
449 tmpFlags |= MAKE_LINKS; 461 tmpFlags |= MAKE_LINKS;
450 } 462 }
451 pIpkg->setFlags( tmpFlags, infoLevel ); 463 pIpkg->setFlags( tmpFlags, infoLevel );
452 pIpkg->runIpkg(); 464 pIpkg->runIpkg();
453 } 465 }
454 else 466 else
455 { 467 {
456 btnOptions->setEnabled( true ); 468 btnOptions->setEnabled( true );
457 btnInstall->setText( tr( "Close" ) ); 469 btnInstall->setText( tr( "Close" ) );
458 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); 470 btnInstall->setIconSet( Resource::loadPixmap( "enter" ) );
459 471
460 btnOptions->setText( tr( "Save output" ) ); 472 btnOptions->setText( tr( "Save output" ) );
461 btnOptions->setIconSet( Resource::loadPixmap( "save" ) ); 473 btnOptions->setIconSet( Resource::loadPixmap( "save" ) );
462 474
463 if ( destination && destination->currentText() != 0 && destination->currentText() != "" ) 475 if ( destination && destination->currentText() != 0 && destination->currentText() != "" )
464 displayAvailableSpace( destination->currentText() ); 476 displayAvailableSpace( destination->currentText() );
465 } 477 }
466} \ No newline at end of file 478}
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 @@
1/*************************************************************************** 1/*
2 installdlgimpl.h - description 2                This file is part of the OPIE Project
3 ------------------- 3
4 begin : Mon Aug 26 2002 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5 copyright : (C) 2002 by Andy Qua 5             .=l. Dan Williams <drw@handhelds.org>
6 email : andy.qua@blueyonder.co.uk 6           .>+-=
7 ***************************************************************************/ 7 _;:,     .>    :=|. This file is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This file is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
8 29
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#ifndef INSTALLDLGIMPL_H 30#ifndef INSTALLDLGIMPL_H
18#define INSTALLDLGIMPL_H 31#define INSTALLDLGIMPL_H
19 32
20using namespace std; 33using namespace std;
21 34
22#include <qlist.h> 35#include <qlist.h>
23#include <qstring.h> 36#include <qstring.h>
24#include <qwidget.h> 37#include <qwidget.h>
25 38
26class QComboBox; 39class QComboBox;
27class QLabel; 40class QLabel;
28class QMultiLineEdit; 41class QMultiLineEdit;
29class QPushButton; 42class QPushButton;
30 43
31class DataManager; 44class DataManager;
32class Destination; 45class Destination;
33class Ipkg; 46class Ipkg;
34 47
35class InstallData 48class InstallData
36{ 49{
37public: 50public:
38 QString option; // I - install, D - delete, R- reinstall U - upgrade 51 QString option; // I - install, D - delete, R- reinstall U - upgrade
39 QString packageName; 52 QString packageName;
40 Destination *destination; 53 Destination *destination;
41 bool recreateLinks; 54 bool recreateLinks;
42}; 55};
43 56
44class InstallDlgImpl : public QWidget 57class InstallDlgImpl : public QWidget
45{ 58{
46 Q_OBJECT 59 Q_OBJECT
47public: 60public:
48 InstallDlgImpl( const QList<InstallData> &packageList, DataManager *dataManager, const char *title = 0 ); 61 InstallDlgImpl( const QList<InstallData> &packageList, DataManager *dataManager, const char *title = 0 );
49 InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title = 0 ); 62 InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title = 0 );
50 ~InstallDlgImpl(); 63 ~InstallDlgImpl();
51 64
52 bool upgradeServer( QString &server ); 65 bool upgradeServer( QString &server );
53 66
54protected: 67protected:
55 68
56private: 69private:
57 DataManager *dataMgr; 70 DataManager *dataMgr;
58 QList<InstallData> packages; 71 QList<InstallData> packages;
59 bool firstPackage; 72 bool firstPackage;
60 int flags; 73 int flags;
61 int infoLevel; 74 int infoLevel;
62 Ipkg *pIpkg; 75 Ipkg *pIpkg;
63 bool upgradePackages; 76 bool upgradePackages;
64 77
65 QComboBox *destination; 78 QComboBox *destination;
66 QPushButton *btnInstall; 79 QPushButton *btnInstall;
67 QPushButton *btnOptions; 80 QPushButton *btnOptions;
68 QMultiLineEdit *output; 81 QMultiLineEdit *output;
69 QLabel *txtAvailableSpace; 82 QLabel *txtAvailableSpace;
70 83
71 void init( bool ); 84 void init( bool );
72 85
73 bool runIpkg( QString &option, const QString& package, const QString& dest, int flags ); 86 bool runIpkg( QString &option, const QString& package, const QString& dest, int flags );
74 87
75signals: 88signals:
76 void reloadData( InstallDlgImpl * ); 89 void reloadData( InstallDlgImpl * );
77 90
78public slots: 91public slots:
79 void optionsSelected(); 92 void optionsSelected();
80 void installSelected(); 93 void installSelected();
81 void displayText(const QString &text ); 94 void displayText(const QString &text );
82 void displayAvailableSpace( const QString &text); 95 void displayAvailableSpace( const QString &text);
83 void ipkgFinished(); 96 void ipkgFinished();
84}; 97};
85 98
86#endif 99#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,116 +1,128 @@
1/*************************************************************************** 1/*
2 instoptionsimpl.cpp - description 2                This file is part of the OPIE Project
3 ------------------- 3
4 begin : Mon Aug 26 2002 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5 copyright : (C) 2002 by Andy Qua 5             .=l. Dan Williams <drw@handhelds.org>
6 email : andy.qua@blueyonder.co.uk 6           .>+-=
7 ***************************************************************************/ 7 _;:,     .>    :=|. This file is free software; you can
8 8.> <`_,   >  .   <= redistribute it and/or modify it under
9/*************************************************************************** 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10 * * 10.="- .-=="i,     .._ License as published by the Free Software
11 * This program is free software; you can redistribute it and/or modify * 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12 * it under the terms of the GNU General Public License as published by * 12     ._= =}       : or (at your option) any later version.
13 * the Free Software Foundation; either version 2 of the License, or * 13    .%`+i>       _;_.
14 * (at your option) any later version. * 14    .i_,=:_.      -<s. This file is distributed in the hope that
15 * * 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16 ***************************************************************************/ 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
17 29
18#ifdef QWS 30#ifdef QWS
19#include <qpe/config.h> 31#include <qpe/config.h>
20#endif 32#endif
21 33
22#include <qcheckbox.h> 34#include <qcheckbox.h>
23#include <qcombobox.h> 35#include <qcombobox.h>
24#include <qgroupbox.h> 36#include <qgroupbox.h>
25#include <qlabel.h> 37#include <qlabel.h>
26#include <qlayout.h> 38#include <qlayout.h>
27 39
28#include "global.h" 40#include "global.h"
29#include "instoptionsimpl.h" 41#include "instoptionsimpl.h"
30#include "ipkg.h" 42#include "ipkg.h"
31 43
32InstallOptionsDlgImpl::InstallOptionsDlgImpl( int flags, int verb, QWidget * parent, const char* name, bool modal, WFlags fl ) 44InstallOptionsDlgImpl::InstallOptionsDlgImpl( int flags, int verb, QWidget * parent, const char* name, bool modal, WFlags fl )
33 : QDialog( parent, name, modal, fl ) 45 : QDialog( parent, name, modal, fl )
34{ 46{
35 setCaption( tr( "Options" ) ); 47 setCaption( tr( "Options" ) );
36 48
37 QVBoxLayout *layout = new QVBoxLayout( this ); 49 QVBoxLayout *layout = new QVBoxLayout( this );
38 layout->setMargin( 2 ); 50 layout->setMargin( 2 );
39 layout->setSpacing( 4 ); 51 layout->setSpacing( 4 );
40 52
41 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Options" ), this ); 53 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Options" ), this );
42 grpbox->layout()->setSpacing( 2 ); 54 grpbox->layout()->setSpacing( 2 );
43 grpbox->layout()->setMargin( 4 ); 55 grpbox->layout()->setMargin( 4 );
44 layout->addWidget( grpbox ); 56 layout->addWidget( grpbox );
45 57
46 QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); 58 QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() );
47 59
48 forceDepends = new QCheckBox( tr( "Force Depends" ), grpbox ); 60 forceDepends = new QCheckBox( tr( "Force Depends" ), grpbox );
49 grplayout->addWidget( forceDepends ); 61 grplayout->addWidget( forceDepends );
50 62
51 forceReinstall = new QCheckBox( tr( "Force Reinstall" ), grpbox ); 63 forceReinstall = new QCheckBox( tr( "Force Reinstall" ), grpbox );
52 grplayout->addWidget( forceReinstall ); 64 grplayout->addWidget( forceReinstall );
53 65
54 forceRemove = new QCheckBox( tr( "Force Remove" ), grpbox ); 66 forceRemove = new QCheckBox( tr( "Force Remove" ), grpbox );
55 grplayout->addWidget( forceRemove ); 67 grplayout->addWidget( forceRemove );
56 68
57 forceOverwrite = new QCheckBox( tr( "Force Overwrite" ), grpbox ); 69 forceOverwrite = new QCheckBox( tr( "Force Overwrite" ), grpbox );
58 grplayout->addWidget( forceOverwrite ); 70 grplayout->addWidget( forceOverwrite );
59 71
60 QLabel *l = new QLabel( tr( "Information Level" ), grpbox ); 72 QLabel *l = new QLabel( tr( "Information Level" ), grpbox );
61 grplayout->addWidget( l ); 73 grplayout->addWidget( l );
62 74
63 verboseIpkg = new QComboBox( grpbox ); 75 verboseIpkg = new QComboBox( grpbox );
64 verboseIpkg->insertItem( tr( "Errors only" ) ); 76 verboseIpkg->insertItem( tr( "Errors only" ) );
65 verboseIpkg->insertItem( tr( "Normal messages" ) ); 77 verboseIpkg->insertItem( tr( "Normal messages" ) );
66 verboseIpkg->insertItem( tr( "Informative messages" ) ); 78 verboseIpkg->insertItem( tr( "Informative messages" ) );
67 verboseIpkg->insertItem( tr( "Troubleshooting output" ) ); 79 verboseIpkg->insertItem( tr( "Troubleshooting output" ) );
68 verboseIpkg->setCurrentItem( verb ); 80 verboseIpkg->setCurrentItem( verb );
69 grplayout->addWidget( verboseIpkg ); 81 grplayout->addWidget( verboseIpkg );
70 82
71 grplayout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); 83 grplayout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
72 84
73 if ( flags & FORCE_DEPENDS ) 85 if ( flags & FORCE_DEPENDS )
74 forceDepends->setChecked( true ); 86 forceDepends->setChecked( true );
75 if ( flags & FORCE_REINSTALL ) 87 if ( flags & FORCE_REINSTALL )
76 forceReinstall->setChecked( true ); 88 forceReinstall->setChecked( true );
77 if ( flags & FORCE_REMOVE ) 89 if ( flags & FORCE_REMOVE )
78 forceRemove->setChecked( true ); 90 forceRemove->setChecked( true );
79 if ( flags & FORCE_OVERWRITE ) 91 if ( flags & FORCE_OVERWRITE )
80 forceOverwrite->setChecked( true ); 92 forceOverwrite->setChecked( true );
81// if ( flags & VERBOSE_WGET ) 93// if ( flags & VERBOSE_WGET )
82 // verboseWget->setChecked( true ); 94 // verboseWget->setChecked( true );
83// if ( flags & MAKE_LINKS ) 95// if ( flags & MAKE_LINKS )
84 // makeLinks->setChecked( true ); 96 // makeLinks->setChecked( true );
85 97
86 showMaximized(); 98 showMaximized();
87 99
88} 100}
89 101
90InstallOptionsDlgImpl::~InstallOptionsDlgImpl() 102InstallOptionsDlgImpl::~InstallOptionsDlgImpl()
91{ 103{
92} 104}
93 105
94 106
95int InstallOptionsDlgImpl :: getFlags() 107int InstallOptionsDlgImpl :: getFlags()
96{ 108{
97 int flags = 0; 109 int flags = 0;
98 110
99 if ( forceDepends->isChecked() ) 111 if ( forceDepends->isChecked() )
100 flags |= FORCE_DEPENDS; 112 flags |= FORCE_DEPENDS;
101 if ( forceReinstall->isChecked() ) 113 if ( forceReinstall->isChecked() )
102 flags |= FORCE_REINSTALL; 114 flags |= FORCE_REINSTALL;
103 if ( forceRemove->isChecked() ) 115 if ( forceRemove->isChecked() )
104 flags |= FORCE_REMOVE; 116 flags |= FORCE_REMOVE;
105 if ( forceOverwrite->isChecked() ) 117 if ( forceOverwrite->isChecked() )
106 flags |= FORCE_OVERWRITE; 118 flags |= FORCE_OVERWRITE;
107 if ( verboseWget->isChecked() ) 119 if ( verboseWget->isChecked() )
108 flags |= VERBOSE_WGET; 120 flags |= VERBOSE_WGET;
109 121
110 return flags; 122 return flags;
111} 123}
112 124
113int InstallOptionsDlgImpl :: getInfoLevel() 125int InstallOptionsDlgImpl :: getInfoLevel()
114{ 126{
115 return verboseIpkg->currentItem(); 127 return verboseIpkg->currentItem();
116} 128}
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 @@
1/*************************************************************************** 1/*
2 installoptionsimpl.h - description 2                This file is part of the OPIE Project
3 ------------------- 3
4 begin : Mon Aug 26 2002 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5 copyright : (C) 2002 by Andy Qua 5             .=l. Dan Williams <drw@handhelds.org>
6 email : andy.qua@blueyonder.co.uk 6           .>+-=
7 ***************************************************************************/ 7 _;:,     .>    :=|. This file is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This file is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
8 29
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#ifndef INSTALLOPTIONSIMPL_H 30#ifndef INSTALLOPTIONSIMPL_H
18#define INSTALLOPTIONSIMPL_H 31#define INSTALLOPTIONSIMPL_H
19 32
20#include <qdialog.h> 33#include <qdialog.h>
21 34
22class QCheckBox; 35class QCheckBox;
23class QComboBox; 36class QComboBox;
24 37
25class InstallOptionsDlgImpl : public QDialog 38class InstallOptionsDlgImpl : public QDialog
26{ 39{
27 Q_OBJECT 40 Q_OBJECT
28public: 41public:
29 InstallOptionsDlgImpl( int, int, QWidget * = 0, const char * = 0, bool = false, WFlags = 0 ); 42 InstallOptionsDlgImpl( int, int, QWidget * = 0, const char * = 0, bool = false, WFlags = 0 );
30 ~InstallOptionsDlgImpl(); 43 ~InstallOptionsDlgImpl();
31 int getFlags(); 44 int getFlags();
32 int getInfoLevel(); 45 int getInfoLevel();
33 46
34private: 47private:
35 QCheckBox* forceDepends; 48 QCheckBox* forceDepends;
36 QCheckBox* forceReinstall; 49 QCheckBox* forceReinstall;
37 QCheckBox* forceRemove; 50 QCheckBox* forceRemove;
38 QCheckBox* forceOverwrite; 51 QCheckBox* forceOverwrite;
39 QCheckBox* verboseWget; 52 QCheckBox* verboseWget;
40 QComboBox* verboseIpkg; 53 QComboBox* verboseIpkg;
41}; 54};
42 55
43#endif 56#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,575 +1,587 @@
1/*************************************************************************** 1/*
2 ipkg.cpp - description 2                This file is part of the OPIE Project
3 ------------------- 3
4 begin : Sat Aug 31 2002 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5 copyright : (C) 2002 by Andy Qua 5             .=l. Dan Williams <drw@handhelds.org>
6 email : andy.qua@blueyonder.co.uk 6           .>+-=
7 ***************************************************************************/ 7 _;:,     .>    :=|. This file is free software; you can
8 8.> <`_,   >  .   <= redistribute it and/or modify it under
9/*************************************************************************** 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10 * * 10.="- .-=="i,     .._ License as published by the Free Software
11 * This program is free software; you can redistribute it and/or modify * 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12 * it under the terms of the GNU General Public License as published by * 12     ._= =}       : or (at your option) any later version.
13 * the Free Software Foundation; either version 2 of the License, or * 13    .%`+i>       _;_.
14 * (at your option) any later version. * 14    .i_,=:_.      -<s. This file is distributed in the hope that
15 * * 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16 ***************************************************************************/ 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
17 29
18#include <fstream> 30#include <fstream>
19#include <iostream> 31#include <iostream>
20#include <vector> 32#include <vector>
21using namespace std; 33using namespace std;
22 34
23#include <stdio.h> 35#include <stdio.h>
24#include <unistd.h> 36#include <unistd.h>
25 37
26#ifdef QWS 38#ifdef QWS
27#include <qpe/qpeapplication.h> 39#include <qpe/qpeapplication.h>
28#else 40#else
29#include <qapplication.h> 41#include <qapplication.h>
30#endif 42#endif
31#include <qdir.h> 43#include <qdir.h>
32#include <qtextstream.h> 44#include <qtextstream.h>
33 45
34#include <opie/oprocess.h> 46#include <opie/oprocess.h>
35 47
36#include "utils.h" 48#include "utils.h"
37#include "ipkg.h" 49#include "ipkg.h"
38#include "global.h" 50#include "global.h"
39 51
40Ipkg :: Ipkg() 52Ipkg :: Ipkg()
41{ 53{
42 proc = 0; 54 proc = 0;
43} 55}
44 56
45Ipkg :: ~Ipkg() 57Ipkg :: ~Ipkg()
46{ 58{
47} 59}
48 60
49// Option is what we are going to do - install, upgrade, download, reinstall 61// Option is what we are going to do - install, upgrade, download, reinstall
50// package is the package name to install - either a fully qualified path and ipk 62// package is the package name to install - either a fully qualified path and ipk
51// file (if stored locally) or just the name of the package (for a network package) 63// file (if stored locally) or just the name of the package (for a network package)
52// packageName is the package name - (for a network package this will be the same as 64// packageName is the package name - (for a network package this will be the same as
53// package parameter) 65// package parameter)
54// dest is the destination alias (from ipk.conf) 66// dest is the destination alias (from ipk.conf)
55// destDir is the dir that the destination alias points to (used to link to root) 67// destDir is the dir that the destination alias points to (used to link to root)
56// flags is the ipkg options flags 68// flags is the ipkg options flags
57// dir is the directory to run ipkg in (defaults to "") 69// dir is the directory to run ipkg in (defaults to "")
58void Ipkg :: runIpkg() 70void Ipkg :: runIpkg()
59{ 71{
60 error = false; 72 error = false;
61 QStringList commands; 73 QStringList commands;
62 74
63 QDir::setCurrent( "/tmp" ); 75 QDir::setCurrent( "/tmp" );
64 76
65 if ( runtimeDir != "" ) 77 if ( runtimeDir != "" )
66 { 78 {
67 commands << "cd "; 79 commands << "cd ";
68 commands << runtimeDir; 80 commands << runtimeDir;
69 commands << ";"; 81 commands << ";";
70 } 82 }
71 commands << "ipkg" << "-V" << QString::number( infoLevel ) << "-force-defaults"; 83 commands << "ipkg" << "-V" << QString::number( infoLevel ) << "-force-defaults";
72 84
73 // only set the destination for an install operation 85 // only set the destination for an install operation
74 if ( option == "install" ) 86 if ( option == "install" )
75 commands << "-dest" << destination; 87 commands << "-dest" << destination;
76 88
77 89
78 if ( option != "update" && option != "download" ) 90 if ( option != "update" && option != "download" )
79 { 91 {
80 if ( flags & FORCE_DEPENDS ) 92 if ( flags & FORCE_DEPENDS )
81 commands << "-force-depends"; 93 commands << "-force-depends";
82 if ( flags & FORCE_REINSTALL ) 94 if ( flags & FORCE_REINSTALL )
83 commands << "-force-reinstall"; 95 commands << "-force-reinstall";
84 if ( flags & FORCE_REMOVE ) 96 if ( flags & FORCE_REMOVE )
85 commands << "-force-removal-of-essential-packages"; 97 commands << "-force-removal-of-essential-packages";
86 if ( flags & FORCE_OVERWRITE ) 98 if ( flags & FORCE_OVERWRITE )
87 commands << "-force-overwrite"; 99 commands << "-force-overwrite";
88 if ( infoLevel == 3 ) 100 if ( infoLevel == 3 )
89 commands << "-verbose_wget"; 101 commands << "-verbose_wget";
90 102
91 // Handle make links 103 // Handle make links
92 // Rules - If make links is switched on, create links to root 104 // Rules - If make links is switched on, create links to root
93 // if destDir is NOT / 105 // if destDir is NOT /
94 if ( flags & MAKE_LINKS ) 106 if ( flags & MAKE_LINKS )
95 { 107 {
96 // If destDir == / turn off make links as package is being insalled 108 // If destDir == / turn off make links as package is being insalled
97 // to root already. 109 // to root already.
98 if ( destDir == "/" ) 110 if ( destDir == "/" )
99 flags ^= MAKE_LINKS; 111 flags ^= MAKE_LINKS;
100 } 112 }
101 } 113 }
102 114
103#ifdef X86 115#ifdef X86
104 commands << "-f"; 116 commands << "-f";
105 commands << IPKG_CONF; 117 commands << IPKG_CONF;
106#endif 118#endif
107 119
108 120
109 if ( option == "reinstall" ) 121 if ( option == "reinstall" )
110 commands << "install"; 122 commands << "install";
111 else 123 else
112 commands << option; 124 commands << option;
113 if ( package != "" ) 125 if ( package != "" )
114 commands << package; 126 commands << package;
115 127
116 128
117 if ( package != "" ) 129 if ( package != "" )
118 emit outputText( QString( "Dealing with package " ) + package ); 130 emit outputText( QString( "Dealing with package " ) + package );
119 131
120 qApp->processEvents(); 132 qApp->processEvents();
121 133
122 // If we are removing, reinstalling or upgrading packages and make links option is selected 134 // If we are removing, reinstalling or upgrading packages and make links option is selected
123 // create the links 135 // create the links
124 if ( option == "remove" || option == "reinstall" || option == "upgrade" ) 136 if ( option == "remove" || option == "reinstall" || option == "upgrade" )
125 { 137 {
126 createLinks = false; 138 createLinks = false;
127 if ( flags & MAKE_LINKS ) 139 if ( flags & MAKE_LINKS )
128 { 140 {
129 emit outputText( QString( "Removing symbolic links...\n" ) ); 141 emit outputText( QString( "Removing symbolic links...\n" ) );
130 linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); 142 linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir );
131 emit outputText( QString( " " ) ); 143 emit outputText( QString( " " ) );
132 } 144 }
133 } 145 }
134 146
135 // Execute command 147 // Execute command
136 dependantPackages = new QList<QString>; 148 dependantPackages = new QList<QString>;
137 dependantPackages->setAutoDelete( true ); 149 dependantPackages->setAutoDelete( true );
138 150
139 executeIpkgCommand( commands, option ); 151 executeIpkgCommand( commands, option );
140 152
141} 153}
142 154
143void Ipkg :: createSymLinks() 155void Ipkg :: createSymLinks()
144{ 156{
145 if ( option == "install" || option == "reinstall" || option == "upgrade" ) 157 if ( option == "install" || option == "reinstall" || option == "upgrade" )
146 { 158 {
147 // If we are not removing packages and make links option is selected 159 // If we are not removing packages and make links option is selected
148 // create the links 160 // create the links
149 createLinks = true; 161 createLinks = true;
150 if ( flags & MAKE_LINKS ) 162 if ( flags & MAKE_LINKS )
151 { 163 {
152 emit outputText( " " ); 164 emit outputText( " " );
153 emit outputText( QString( "Creating symbolic links for " )+ package ); 165 emit outputText( QString( "Creating symbolic links for " )+ package );
154 166
155 linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); 167 linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir );
156 168
157 // link dependant packages that were installed with this release 169 // link dependant packages that were installed with this release
158 QString *pkg; 170 QString *pkg;
159 for ( pkg = dependantPackages->first(); pkg != 0; pkg = dependantPackages->next() ) 171 for ( pkg = dependantPackages->first(); pkg != 0; pkg = dependantPackages->next() )
160 { 172 {
161 if ( *pkg == package ) 173 if ( *pkg == package )
162 continue; 174 continue;
163 emit outputText( " " ); 175 emit outputText( " " );
164 emit outputText( QString( "Creating symbolic links for " )+ (*pkg) ); 176 emit outputText( QString( "Creating symbolic links for " )+ (*pkg) );
165 linkPackage( Utils::getPackageNameFromIpkFilename( *pkg ), destination, destDir ); 177 linkPackage( Utils::getPackageNameFromIpkFilename( *pkg ), destination, destDir );
166 } 178 }
167 } 179 }
168 } 180 }
169 181
170 delete dependantPackages; 182 delete dependantPackages;
171 183
172 emit outputText( "Finished" ); 184 emit outputText( "Finished" );
173 emit outputText( "" ); 185 emit outputText( "" );
174} 186}
175 187
176void Ipkg :: removeStatusEntry() 188void Ipkg :: removeStatusEntry()
177{ 189{
178 QString statusFile = destDir; 190 QString statusFile = destDir;
179 if ( statusFile.right( 1 ) != "/" ) 191 if ( statusFile.right( 1 ) != "/" )
180 statusFile.append( "/" ); 192 statusFile.append( "/" );
181 statusFile.append( "usr/lib/ipkg/status" ); 193 statusFile.append( "usr/lib/ipkg/status" );
182 QString outStatusFile = statusFile; 194 QString outStatusFile = statusFile;
183 outStatusFile.append( ".tmp" ); 195 outStatusFile.append( ".tmp" );
184 196
185 emit outputText( "" ); 197 emit outputText( "" );
186 emit outputText( "Removing status entry..." ); 198 emit outputText( "Removing status entry..." );
187 QString tempstr = "status file - "; 199 QString tempstr = "status file - ";
188 tempstr.append( statusFile ); 200 tempstr.append( statusFile );
189 emit outputText( tempstr ); 201 emit outputText( tempstr );
190 tempstr = "package - "; 202 tempstr = "package - ";
191 tempstr.append( package ); 203 tempstr.append( package );
192 emit outputText( tempstr ); 204 emit outputText( tempstr );
193 205
194 ifstream in( statusFile ); 206 ifstream in( statusFile );
195 ofstream out( outStatusFile ); 207 ofstream out( outStatusFile );
196 if ( !in.is_open() ) 208 if ( !in.is_open() )
197 { 209 {
198 tempstr = "Couldn't open status file - "; 210 tempstr = "Couldn't open status file - ";
199 tempstr.append( statusFile ); 211 tempstr.append( statusFile );
200 emit outputText( tempstr ); 212 emit outputText( tempstr );
201 return; 213 return;
202 } 214 }
203 215
204 if ( !out.is_open() ) 216 if ( !out.is_open() )
205 { 217 {
206 tempstr = "Couldn't create tempory status file - "; 218 tempstr = "Couldn't create tempory status file - ";
207 tempstr.append( outStatusFile ); 219 tempstr.append( outStatusFile );
208 emit outputText( tempstr ); 220 emit outputText( tempstr );
209 return; 221 return;
210 } 222 }
211 223
212 char line[1001]; 224 char line[1001];
213 char k[21]; 225 char k[21];
214 char v[1001]; 226 char v[1001];
215 QString key; 227 QString key;
216 QString value; 228 QString value;
217 vector<QString> lines; 229 vector<QString> lines;
218 do 230 do
219 { 231 {
220 in.getline( line, 1000 ); 232 in.getline( line, 1000 );
221 if ( in.eof() ) 233 if ( in.eof() )
222 continue; 234 continue;
223 235
224 k[0] = '\0'; 236 k[0] = '\0';
225 v[0] = '\0'; 237 v[0] = '\0';
226 238
227 sscanf( line, "%[^:]: %[^\n]", k, v ); 239 sscanf( line, "%[^:]: %[^\n]", k, v );
228 key = k; 240 key = k;
229 value = v; 241 value = v;
230 key = key.stripWhiteSpace(); 242 key = key.stripWhiteSpace();
231 value = value.stripWhiteSpace(); 243 value = value.stripWhiteSpace();
232 if ( key == "Package" && value == package ) 244 if ( key == "Package" && value == package )
233 { 245 {
234 // Ignore all lines up to next empty 246 // Ignore all lines up to next empty
235 do 247 do
236 { 248 {
237 in.getline( line, 1000 ); 249 in.getline( line, 1000 );
238 if ( in.eof() || QString( line ).stripWhiteSpace() == "" ) 250 if ( in.eof() || QString( line ).stripWhiteSpace() == "" )
239 continue; 251 continue;
240 } while ( !in.eof() && QString( line ).stripWhiteSpace() != "" ); 252 } while ( !in.eof() && QString( line ).stripWhiteSpace() != "" );
241 } 253 }
242 254
243 lines.push_back( QString( line ) ); 255 lines.push_back( QString( line ) );
244 out << line << endl; 256 out << line << endl;
245 } while ( !in.eof() ); 257 } while ( !in.eof() );
246 258
247 // Write lines out 259 // Write lines out
248 vector<QString>::iterator it; 260 vector<QString>::iterator it;
249 for ( it = lines.begin() ; it != lines.end() ; ++it ) 261 for ( it = lines.begin() ; it != lines.end() ; ++it )
250 { 262 {
251 out << (const char *)(*it) << endl; 263 out << (const char *)(*it) << endl;
252 } 264 }
253 265
254 in.close(); 266 in.close();
255 out.close(); 267 out.close();
256 268
257 // Remove old status file and put tmp stats file in its place 269 // Remove old status file and put tmp stats file in its place
258 remove( statusFile ); 270 remove( statusFile );
259 rename( outStatusFile, statusFile ); 271 rename( outStatusFile, statusFile );
260} 272}
261 273
262int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ ) 274int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ )
263{ 275{
264 // If one is already running - should never be but just to be safe 276 // If one is already running - should never be but just to be safe
265 if ( proc ) 277 if ( proc )
266 { 278 {
267 delete proc; 279 delete proc;
268 proc = 0; 280 proc = 0;
269 } 281 }
270 282
271 // OK we're gonna use OProcess to run this thing 283 // OK we're gonna use OProcess to run this thing
272 proc = new OProcess(); 284 proc = new OProcess();
273 aborted = false; 285 aborted = false;
274 286
275 287
276 // Connect up our slots 288 // Connect up our slots
277 connect(proc, SIGNAL(processExited(OProcess *)), 289 connect(proc, SIGNAL(processExited(OProcess *)),
278 this, SLOT( processFinished())); 290 this, SLOT( processFinished()));
279 291
280 connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)), 292 connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)),
281 this, SLOT(commandStdout(OProcess *, char *, int))); 293 this, SLOT(commandStdout(OProcess *, char *, int)));
282 294
283 connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)), 295 connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)),
284 this, SLOT(commandStderr(OProcess *, char *, int))); 296 this, SLOT(commandStderr(OProcess *, char *, int)));
285 297
286 for ( QStringList::Iterator it = cmd.begin(); it != cmd.end(); ++it ) 298 for ( QStringList::Iterator it = cmd.begin(); it != cmd.end(); ++it )
287 { 299 {
288 *proc << (*it).latin1(); 300 *proc << (*it).latin1();
289 } 301 }
290 302
291 // Start the process going 303 // Start the process going
292 finished = false; 304 finished = false;
293 if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) 305 if(!proc->start(OProcess::NotifyOnExit, OProcess::All))
294 { 306 {
295 emit outputText( QString( "Couldn't start ipkg process" ) ); 307 emit outputText( QString( "Couldn't start ipkg process" ) );
296 } 308 }
297} 309}
298 310
299void Ipkg::commandStdout(OProcess*, char *buffer, int buflen) 311void Ipkg::commandStdout(OProcess*, char *buffer, int buflen)
300{ 312{
301 QString lineStr = buffer; 313 QString lineStr = buffer;
302 if ( lineStr[buflen-1] == '\n' ) 314 if ( lineStr[buflen-1] == '\n' )
303 buflen --; 315 buflen --;
304 lineStr = lineStr.left( buflen ); 316 lineStr = lineStr.left( buflen );
305 emit outputText( lineStr ); 317 emit outputText( lineStr );
306 318
307 // check if we are installing dependant packages 319 // check if we are installing dependant packages
308 if ( option == "install" || option == "reinstall" ) 320 if ( option == "install" || option == "reinstall" )
309 { 321 {
310 // Need to keep track of any dependant packages that get installed 322 // Need to keep track of any dependant packages that get installed
311 // so that we can create links to them as necessary 323 // so that we can create links to them as necessary
312 if ( lineStr.startsWith( "Installing " ) ) 324 if ( lineStr.startsWith( "Installing " ) )
313 { 325 {
314 int start = lineStr.find( " " ) + 1; 326 int start = lineStr.find( " " ) + 1;
315 int end = lineStr.find( " ", start ); 327 int end = lineStr.find( " ", start );
316 QString *package = new QString( lineStr.mid( start, end-start ) ); 328 QString *package = new QString( lineStr.mid( start, end-start ) );
317 dependantPackages->append( package ); 329 dependantPackages->append( package );
318 } 330 }
319 } 331 }
320 else if ( option == "remove" && !( flags & FORCE_DEPENDS ) && 332 else if ( option == "remove" && !( flags & FORCE_DEPENDS ) &&
321 lineStr.find( "is depended upon by packages:" ) != -1 ) 333 lineStr.find( "is depended upon by packages:" ) != -1 )
322 { 334 {
323 // Ipkg should send this to STDERR, but doesn't - so trap here 335 // Ipkg should send this to STDERR, but doesn't - so trap here
324 error = true; 336 error = true;
325 } 337 }
326 338
327 buffer[0] = '\0'; 339 buffer[0] = '\0';
328} 340}
329 341
330void Ipkg::commandStderr(OProcess*, char *buffer, int buflen) 342void Ipkg::commandStderr(OProcess*, char *buffer, int buflen)
331{ 343{
332 QString lineStr = buffer; 344 QString lineStr = buffer;
333 if ( lineStr[buflen-1] == '\n' ) 345 if ( lineStr[buflen-1] == '\n' )
334 buflen --; 346 buflen --;
335 lineStr=lineStr.left( buflen ); 347 lineStr=lineStr.left( buflen );
336 emit outputText( lineStr ); 348 emit outputText( lineStr );
337 buffer[0] = '\0'; 349 buffer[0] = '\0';
338 error = true; 350 error = true;
339} 351}
340 352
341void Ipkg::processFinished() 353void Ipkg::processFinished()
342{ 354{
343 // Finally, if we are removing a package, remove its entry from the <destdir>/usr/lib/ipkg/status file 355 // Finally, if we are removing a package, remove its entry from the <destdir>/usr/lib/ipkg/status file
344 // to workaround an ipkg bug which stops reinstall to a different location 356 // to workaround an ipkg bug which stops reinstall to a different location
345 357
346 if ( !error && option == "remove" ) 358 if ( !error && option == "remove" )
347 removeStatusEntry(); 359 removeStatusEntry();
348 360
349 delete proc; 361 delete proc;
350 proc = 0; 362 proc = 0;
351 finished = true; 363 finished = true;
352 364
353 emit ipkgFinished(); 365 emit ipkgFinished();
354} 366}
355 367
356 368
357void Ipkg :: abort() 369void Ipkg :: abort()
358{ 370{
359 if ( proc ) 371 if ( proc )
360 { 372 {
361 proc->kill(); 373 proc->kill();
362 aborted = true; 374 aborted = true;
363 } 375 }
364} 376}
365 377
366/* 378/*
367int Ipkg :: executeIpkgCommand( QString &cmd, const QString option ) 379int Ipkg :: executeIpkgCommand( QString &cmd, const QString option )
368{ 380{
369 FILE *fp = NULL; 381 FILE *fp = NULL;
370 char line[130]; 382 char line[130];
371 QString lineStr, lineStrOld; 383 QString lineStr, lineStrOld;
372 int ret = false; 384 int ret = false;
373 385
374 fp = popen( (const char *) cmd, "r"); 386 fp = popen( (const char *) cmd, "r");
375 if ( fp == NULL ) 387 if ( fp == NULL )
376 { 388 {
377 QString text; 389 QString text;
378 text.sprintf( "Couldn't execute %s! See stdout for error code", (const char *)cmd ); 390 text.sprintf( "Couldn't execute %s! See stdout for error code", (const char *)cmd );
379 emit outputText( text ); 391 emit outputText( text );
380 } 392 }
381 else 393 else
382 { 394 {
383 while ( fgets( line, sizeof line, fp) != NULL ) 395 while ( fgets( line, sizeof line, fp) != NULL )
384 { 396 {
385 lineStr = line; 397 lineStr = line;
386 lineStr=lineStr.left( lineStr.length()-1 ); 398 lineStr=lineStr.left( lineStr.length()-1 );
387 399
388 if ( lineStr != lineStrOld ) 400 if ( lineStr != lineStrOld )
389 { 401 {
390 //See if we're finished 402 //See if we're finished
391 if ( option == "install" || option == "reinstall" ) 403 if ( option == "install" || option == "reinstall" )
392 { 404 {
393 // Need to keep track of any dependant packages that get installed 405 // Need to keep track of any dependant packages that get installed
394 // so that we can create links to them as necessary 406 // so that we can create links to them as necessary
395 if ( lineStr.startsWith( "Installing " ) ) 407 if ( lineStr.startsWith( "Installing " ) )
396 { 408 {
397 int start = lineStr.find( " " ) + 1; 409 int start = lineStr.find( " " ) + 1;
398 int end = lineStr.find( " ", start ); 410 int end = lineStr.find( " ", start );
399 QString *package = new QString( lineStr.mid( start, end-start ) ); 411 QString *package = new QString( lineStr.mid( start, end-start ) );
400 dependantPackages->append( package ); 412 dependantPackages->append( package );
401 } 413 }
402 } 414 }
403 415
404 if ( option == "update" ) 416 if ( option == "update" )
405 { 417 {
406 if (lineStr.contains("Updated list")) 418 if (lineStr.contains("Updated list"))
407 ret = true; 419 ret = true;
408 } 420 }
409 else if ( option == "download" ) 421 else if ( option == "download" )
410 { 422 {
411 if (lineStr.contains("Downloaded")) 423 if (lineStr.contains("Downloaded"))
412 ret = true; 424 ret = true;
413 } 425 }
414 else 426 else
415 { 427 {
416 if (lineStr.contains("Done")) 428 if (lineStr.contains("Done"))
417 ret = true; 429 ret = true;
418 } 430 }
419 431
420 emit outputText( lineStr ); 432 emit outputText( lineStr );
421 } 433 }
422 lineStrOld = lineStr; 434 lineStrOld = lineStr;
423 qApp->processEvents(); 435 qApp->processEvents();
424 } 436 }
425 pclose(fp); 437 pclose(fp);
426 } 438 }
427 439
428 return ret; 440 return ret;
429} 441}
430*/ 442*/
431 443
432void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, const QString &destDir ) 444void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, const QString &destDir )
433{ 445{
434 if ( dest == "root" || dest == "/" ) 446 if ( dest == "root" || dest == "/" )
435 return; 447 return;
436 448
437 qApp->processEvents(); 449 qApp->processEvents();
438 QStringList *fileList = getList( packFileName, destDir ); 450 QStringList *fileList = getList( packFileName, destDir );
439 qApp->processEvents(); 451 qApp->processEvents();
440 processFileList( fileList, destDir ); 452 processFileList( fileList, destDir );
441 delete fileList; 453 delete fileList;
442} 454}
443 455
444QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir ) 456QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir )
445{ 457{
446 QString packageFileDir = destDir; 458 QString packageFileDir = destDir;
447 packageFileDir.append( "/usr/lib/ipkg/info/" ); 459 packageFileDir.append( "/usr/lib/ipkg/info/" );
448 packageFileDir.append( packageFilename ); 460 packageFileDir.append( packageFilename );
449 packageFileDir.append( ".list" ); 461 packageFileDir.append( ".list" );
450 QFile f( packageFileDir ); 462 QFile f( packageFileDir );
451 463
452 if ( !f.open(IO_ReadOnly) ) 464 if ( !f.open(IO_ReadOnly) )
453 { 465 {
454 // Couldn't open from dest, try from / 466 // Couldn't open from dest, try from /
455 f.close(); 467 f.close();
456 468
457 packageFileDir = "/usr/lib/ipkg/info/"; 469 packageFileDir = "/usr/lib/ipkg/info/";
458 packageFileDir.append( packageFilename ); 470 packageFileDir.append( packageFilename );
459 packageFileDir.append( ".list" ); 471 packageFileDir.append( ".list" );
460 f.setName( packageFileDir ); 472 f.setName( packageFileDir );
461 if ( ! f.open(IO_ReadOnly) ) 473 if ( ! f.open(IO_ReadOnly) )
462 { 474 {
463 QString tempstr = "Could not open :"; 475 QString tempstr = "Could not open :";
464 tempstr.append( packageFileDir ); 476 tempstr.append( packageFileDir );
465 emit outputText( tempstr ); 477 emit outputText( tempstr );
466 return (QStringList*)0; 478 return (QStringList*)0;
467 } 479 }
468 } 480 }
469 QStringList *fileList = new QStringList(); 481 QStringList *fileList = new QStringList();
470 QTextStream t( &f ); 482 QTextStream t( &f );
471 while ( !t.eof() ) 483 while ( !t.eof() )
472 *fileList += t.readLine(); 484 *fileList += t.readLine();
473 485
474 f.close(); 486 f.close();
475 return fileList; 487 return fileList;
476} 488}
477 489
478void Ipkg :: processFileList( const QStringList *fileList, const QString &destDir ) 490void Ipkg :: processFileList( const QStringList *fileList, const QString &destDir )
479{ 491{
480 if ( !fileList || fileList->isEmpty() ) 492 if ( !fileList || fileList->isEmpty() )
481 return; 493 return;
482 494
483 QString baseDir = ROOT; 495 QString baseDir = ROOT;
484 496
485 if ( createLinks == true ) 497 if ( createLinks == true )
486 { 498 {
487 for ( uint i=0; i < fileList->count(); i++ ) 499 for ( uint i=0; i < fileList->count(); i++ )
488 { 500 {
489 processLinkDir( (*fileList)[i], baseDir, destDir ); 501 processLinkDir( (*fileList)[i], baseDir, destDir );
490 qApp->processEvents(); 502 qApp->processEvents();
491 } 503 }
492 } 504 }
493 else 505 else
494 { 506 {
495 for ( int i = fileList->count()-1; i >= 0 ; i-- ) 507 for ( int i = fileList->count()-1; i >= 0 ; i-- )
496 { 508 {
497 processLinkDir( (*fileList)[i], baseDir, destDir ); 509 processLinkDir( (*fileList)[i], baseDir, destDir );
498 qApp->processEvents(); 510 qApp->processEvents();
499 } 511 }
500 } 512 }
501} 513}
502 514
503void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const QString &baseDir ) 515void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const QString &baseDir )
504{ 516{
505 517
506 QString sourceFile = baseDir; 518 QString sourceFile = baseDir;
507 sourceFile.append( file ); 519 sourceFile.append( file );
508 520
509 QString linkFile = destDir; 521 QString linkFile = destDir;
510 if ( file.startsWith( "/" ) && destDir.right( 1 ) == "/" ) 522 if ( file.startsWith( "/" ) && destDir.right( 1 ) == "/" )
511 { 523 {
512 linkFile.append( file.mid( 1 ) ); 524 linkFile.append( file.mid( 1 ) );
513 } 525 }
514 else 526 else
515 { 527 {
516 linkFile.append( file ); 528 linkFile.append( file );
517 } 529 }
518 QString text; 530 QString text;
519 if ( createLinks ) 531 if ( createLinks )
520 { 532 {
521 // If this file is a directory (ends with a /) and it doesn't exist, 533 // If this file is a directory (ends with a /) and it doesn't exist,
522 // we need to create it 534 // we need to create it
523 if ( file.right(1) == "/" ) 535 if ( file.right(1) == "/" )
524 { 536 {
525 QFileInfo f( linkFile ); 537 QFileInfo f( linkFile );
526 if ( !f.exists() ) 538 if ( !f.exists() )
527 { 539 {
528 QString tempstr = "Creating directory "; 540 QString tempstr = "Creating directory ";
529 tempstr.append( linkFile ); 541 tempstr.append( linkFile );
530 emit outputText( tempstr ); 542 emit outputText( tempstr );
531 QDir d; 543 QDir d;
532 d.mkdir( linkFile, true ); 544 d.mkdir( linkFile, true );
533 } 545 }
534// else 546// else
535// emit outputText( QString( "Directory " ) + linkFile + " already exists" ); 547// emit outputText( QString( "Directory " ) + linkFile + " already exists" );
536 548
537 } 549 }
538 else 550 else
539 { 551 {
540 int rc = symlink( sourceFile, linkFile ); 552 int rc = symlink( sourceFile, linkFile );
541 text = (rc == 0 ? "Linked " : "Failed to link "); 553 text = (rc == 0 ? "Linked " : "Failed to link ");
542 text.append( sourceFile ); 554 text.append( sourceFile );
543 text.append( " to " ); 555 text.append( " to " );
544 text.append( linkFile ); 556 text.append( linkFile );
545 emit outputText( text ); 557 emit outputText( text );
546 } 558 }
547 } 559 }
548 else 560 else
549 { 561 {
550 QFileInfo f( linkFile ); 562 QFileInfo f( linkFile );
551 if ( f.exists() ) 563 if ( f.exists() )
552 { 564 {
553 if ( f.isFile() ) 565 if ( f.isFile() )
554 { 566 {
555 QFile f( linkFile ); 567 QFile f( linkFile );
556 bool rc = f.remove(); 568 bool rc = f.remove();
557 569
558 text = (rc ? "Removed " : "Failed to remove "); 570 text = (rc ? "Removed " : "Failed to remove ");
559 text.append( linkFile ); 571 text.append( linkFile );
560 emit outputText( text ); 572 emit outputText( text );
561 } 573 }
562 else if ( f.isDir() ) 574 else if ( f.isDir() )
563 { 575 {
564 QDir d; 576 QDir d;
565 bool rc = d.rmdir( linkFile, true ); 577 bool rc = d.rmdir( linkFile, true );
566 if ( rc ) 578 if ( rc )
567 { 579 {
568 text = (rc ? "Removed " : "Failed to remove "); 580 text = (rc ? "Removed " : "Failed to remove ");
569 text.append( linkFile ); 581 text.append( linkFile );
570 emit outputText( text ); 582 emit outputText( text );
571 } 583 }
572 } 584 }
573 } 585 }
574 } 586 }
575} 587}
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 @@
1/*************************************************************************** 1/*
2 ipkg.h - description 2                This file is part of the OPIE Project
3 ------------------- 3
4 begin : Sat Aug 31 2002 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5 copyright : (C) 2002 by Andy Qua 5             .=l. Dan Williams <drw@handhelds.org>
6 email : andy.qua@blueyonder.co.uk 6           .>+-=
7 ***************************************************************************/ 7 _;:,     .>    :=|. This file is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This file is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
8 27
9/*************************************************************************** 28*/
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17 29
18#ifndef IPKG_H 30#ifndef IPKG_H
19#define IPKG_H 31#define IPKG_H
20 32
21 33
22/** 34/**
23 *@author Andy Qua 35 *@author Andy Qua
24 */ 36 */
25 37
26#include <qobject.h> 38#include <qobject.h>
27#include <qstring.h> 39#include <qstring.h>
28#include <qstringlist.h> 40#include <qstringlist.h>
29#include <qlist.h> 41#include <qlist.h>
30 42
31#define FORCE_DEPENDS 0x0001 43#define FORCE_DEPENDS 0x0001
32#define FORCE_REMOVE 0x0002 44#define FORCE_REMOVE 0x0002
33#define FORCE_REINSTALL 0x0004 45#define FORCE_REINSTALL 0x0004
34#define FORCE_OVERWRITE 0x0008 46#define FORCE_OVERWRITE 0x0008
35#define MAKE_LINKS 0x0010 47#define MAKE_LINKS 0x0010
36#define VERBOSE_WGET 0x0020 48#define VERBOSE_WGET 0x0020
37 49
38class OProcess; 50class OProcess;
39 51
40class Ipkg : public QObject 52class Ipkg : public QObject
41{ 53{
42 Q_OBJECT 54 Q_OBJECT
43public: 55public:
44 Ipkg(); 56 Ipkg();
45 ~Ipkg(); 57 ~Ipkg();
46 void runIpkg(); 58 void runIpkg();
47 void createSymLinks(); 59 void createSymLinks();
48 60
49 void setOption( const char *opt ) { option = opt; } 61 void setOption( const char *opt ) { option = opt; }
50 void setPackage( const char *pkg ) { package = pkg; } 62 void setPackage( const char *pkg ) { package = pkg; }
51 void setDestination( const char *dest ) { destination = dest; } 63 void setDestination( const char *dest ) { destination = dest; }
52 void setDestinationDir( const char *dir ) { destDir = dir; } 64 void setDestinationDir( const char *dir ) { destDir = dir; }
53 void setFlags( int fl, int il ) { flags = fl; infoLevel = il; } 65 void setFlags( int fl, int il ) { flags = fl; infoLevel = il; }
54 void setRuntimeDirectory( const char *dir ) { runtimeDir = dir; } 66 void setRuntimeDirectory( const char *dir ) { runtimeDir = dir; }
55 67
56signals: 68signals:
57 void outputText( const QString &text ); 69 void outputText( const QString &text );
58 void ipkgFinished(); 70 void ipkgFinished();
59 71
60public slots: 72public slots:
61 void commandStdout(OProcess*, char *buffer, int buflen); 73 void commandStdout(OProcess*, char *buffer, int buflen);
62 void commandStderr(OProcess*, char *buffer, int buflen); 74 void commandStderr(OProcess*, char *buffer, int buflen);
63 void processFinished(); 75 void processFinished();
64 void abort(); 76 void abort();
65 77
66 78
67private: 79private:
68 bool createLinks; 80 bool createLinks;
69 bool aborted; 81 bool aborted;
70 bool error; 82 bool error;
71 QString option; 83 QString option;
72 QString package; 84 QString package;
73 QString destination; 85 QString destination;
74 QString destDir; 86 QString destDir;
75 QString runtimeDir; 87 QString runtimeDir;
76 OProcess *proc; 88 OProcess *proc;
77 int flags; 89 int flags;
78 int infoLevel; 90 int infoLevel;
79 bool finished; 91 bool finished;
80 92
81 QList<QString> *dependantPackages; 93 QList<QString> *dependantPackages;
82 94
83 int executeIpkgCommand( QStringList &cmd, const QString option ); 95 int executeIpkgCommand( QStringList &cmd, const QString option );
84 void removeStatusEntry(); 96 void removeStatusEntry();
85 void linkPackage( const QString &packFileName, const QString &dest, const QString &destDir ); 97 void linkPackage( const QString &packFileName, const QString &dest, const QString &destDir );
86 QStringList* getList( const QString &packageFilename, const QString &destDir ); 98 QStringList* getList( const QString &packageFilename, const QString &destDir );
87 void processFileList( const QStringList *fileList, const QString &destDir ); 99 void processFileList( const QStringList *fileList, const QString &destDir );
88 void processLinkDir( const QString &file, const QString &baseDir, const QString &destDir ); 100 void processLinkDir( const QString &file, const QString &baseDir, const QString &destDir );
89 101
90}; 102};
91 103
92#endif 104#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 @@
1/*************************************************************************** 1/*
2 letterpushbutton.cpp - description 2                This file is part of the OPIE Project
3 ------------------- 3
4 begin : Wed Oct 16 2002 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5 copyright : (C) 2002 by Andy Qua 5             .=l. Dan Williams <drw@handhelds.org>
6 email : andy.qua@blueyonder.co.uk 6           .>+-=
7 ***************************************************************************/ 7 _;:,     .>    :=|. This file is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This file is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
8 27
9/*************************************************************************** 28*/
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17 29
18#include "letterpushbutton.h" 30#include "letterpushbutton.h"
19 31
20LetterPushButton :: LetterPushButton( const QString &text, QWidget *parent, const char *name ) 32LetterPushButton :: LetterPushButton( const QString &text, QWidget *parent, const char *name )
21 : QPushButton( text, parent, name ) 33 : QPushButton( text, parent, name )
22{ 34{
23 connect( this, SIGNAL(released()), this, SLOT(released_emmitor()) ); 35 connect( this, SIGNAL(released()), this, SLOT(released_emmitor()) );
24} 36}
25 37
26LetterPushButton :: ~LetterPushButton() 38LetterPushButton :: ~LetterPushButton()
27{ 39{
28} 40}
29 41
30void LetterPushButton :: released_emmitor() 42void LetterPushButton :: released_emmitor()
31{ 43{
32 emit released( text() ); 44 emit released( text() );
33} 45}
34 46
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 @@
1/*************************************************************************** 1/*
2 letterpushbutton.h - description 2                This file is part of the OPIE Project
3 ------------------- 3
4 begin : Wed Oct 16 2002 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5 copyright : (C) 2002 by Andy Qua 5             .=l. Dan Williams <drw@handhelds.org>
6 email : andy.qua@blueyonder.co.uk 6           .>+-=
7 ***************************************************************************/ 7 _;:,     .>    :=|. This file is free software; you can
8 8.> <`_,   >  .   <= redistribute it and/or modify it under
9/*************************************************************************** 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10 * * 10.="- .-=="i,     .._ License as published by the Free Software
11 * This program is free software; you can redistribute it and/or modify * 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12 * it under the terms of the GNU General Public License as published by * 12     ._= =}       : or (at your option) any later version.
13 * the Free Software Foundation; either version 2 of the License, or * 13    .%`+i>       _;_.
14 * (at your option) any later version. * 14    .i_,=:_.      -<s. This file is distributed in the hope that
15 * * 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16 ***************************************************************************/ 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
17 29
18#ifndef LETTERPUSHBUTTON_H 30#ifndef LETTERPUSHBUTTON_H
19#define LETTERPUSHBUTTON_H 31#define LETTERPUSHBUTTON_H
20 32
21#include <qpushbutton.h> 33#include <qpushbutton.h>
22 34
23/** 35/**
24 *@author Andy Qua 36 *@author Andy Qua
25 */ 37 */
26 38
27class LetterPushButton : public QPushButton 39class LetterPushButton : public QPushButton
28{ 40{
29 Q_OBJECT 41 Q_OBJECT
30public: 42public:
31 LetterPushButton( const QString & text, QWidget * parent, const char * name=0 ); 43 LetterPushButton( const QString & text, QWidget * parent, const char * name=0 );
32 ~LetterPushButton(); 44 ~LetterPushButton();
33 45
34public slots: 46public slots:
35 void released_emmitor(); 47 void released_emmitor();
36 48
37signals: 49signals:
38 void released( QString text ); 50 void released( QString text );
39}; 51};
40 52
41#endif 53#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 @@
1/*************************************************************************** 1/*
2 main.cpp - description 2                This file is part of the OPIE Project
3 ------------------- 3
4 begin : Mon Aug 26 13:32:30 BST 2002 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5 copyright : (C) 2002 by Andy Qua 5             .=l. Dan Williams <drw@handhelds.org>
6 email : andy.qua@blueyonder.co.uk 6           .>+-=
7 ***************************************************************************/ 7 _;:,     .>    :=|. This file is free software; you can
8 8.> <`_,   >  .   <= redistribute it and/or modify it under
9/*************************************************************************** 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10 * * 10.="- .-=="i,     .._ License as published by the Free Software
11 * This program is free software; you can redistribute it and/or modify * 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12 * it under the terms of the GNU General Public License as published by * 12     ._= =}       : or (at your option) any later version.
13 * the Free Software Foundation; either version 2 of the License, or * 13    .%`+i>       _;_.
14 * (at your option) any later version. * 14    .i_,=:_.      -<s. This file is distributed in the hope that
15 * * 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16 ***************************************************************************/ 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
17 29
18#ifdef QWS 30#ifdef QWS
19#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
20#include <qpe/qcopenvelope_qws.h> 32#include <qpe/qcopenvelope_qws.h>
21#else 33#else
22#include <qapplication.h> 34#include <qapplication.h>
23#endif 35#endif
24 36
25#include <qobjectdefs.h> 37#include <qobjectdefs.h>
26 38
27#include "mainwin.h" 39#include "mainwin.h"
28#include "server.h" 40#include "server.h"
29 41
30#include "global.h" 42#include "global.h"
31 43
32 44
33int main(int argc, char *argv[]) 45int main(int argc, char *argv[])
34{ 46{
35// cout << "Root dir = " << ROOT << endl;
36#ifdef QWS 47#ifdef QWS
37 QPEApplication a( argc, argv ); 48 QPEApplication a( argc, argv );
38#else 49#else
39 QApplication a( argc, argv ); 50 QApplication a( argc, argv );
40#endif 51#endif
41 52
42#ifdef QWS 53#ifdef QWS
43 // Disable suspend mode 54 // Disable suspend mode
44// cout << "Disabling suspend mode" << endl;
45 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; 55 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend;
46#endif 56#endif
47 57
48 MainWindow *win = new MainWindow(); 58 MainWindow *win = new MainWindow();
49 a.setMainWidget(win); 59 a.setMainWidget(win);
50 win->showMaximized(); 60 win->showMaximized();
51 61
52 a.exec(); 62 a.exec();
53 63
54#ifdef QWS 64#ifdef QWS
55 // Reenable suspend mode 65 // Reenable suspend mode
56// cout << "Enabling suspend mode" << endl;
57 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 66 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
58#endif 67#endif
59 #ifdef _DEBUG 68 #ifdef _DEBUG
60 DumpUnfreed(); 69 DumpUnfreed();
61 #endif 70 #endif
62} 71}
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,1165 +1,1166 @@
1/*************************************************************************** 1/*
2 mainwin.cpp - description 2                This file is part of the OPIE Project
3 ------------------- 3
4 begin : Mon Aug 26 13:32:30 BST 2002 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5 copyright : (C) 2002 by Andy Qua 5             .=l. Dan Williams <drw@handhelds.org>
6 email : andy.qua@blueyonder.co.uk 6           .>+-=
7 ***************************************************************************/ 7 _;:,     .>    :=|. This file is free software; you can
8 8.> <`_,   >  .   <= redistribute it and/or modify it under
9/*************************************************************************** 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10 * * 10.="- .-=="i,     .._ License as published by the Free Software
11 * This program is free software; you can redistribute it and/or modify * 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12 * it under the terms of the GNU General Public License as published by * 12     ._= =}       : or (at your option) any later version.
13 * the Free Software Foundation; either version 2 of the License, or * 13    .%`+i>       _;_.
14 * (at your option) any later version. * 14    .i_,=:_.      -<s. This file is distributed in the hope that
15 * * 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16 ***************************************************************************/ 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
17 29
18#include <linux/limits.h> 30#include <linux/limits.h>
19#include <unistd.h> 31#include <unistd.h>
20 32
21#include <qpe/qcopenvelope_qws.h> 33#include <qpe/qcopenvelope_qws.h>
22#include <qmenubar.h> 34#include <qmenubar.h>
23#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
24#include <qtoolbar.h> 36#include <qtoolbar.h>
25#include <qpe/config.h> 37#include <qpe/config.h>
26#include <qpe/resource.h> 38#include <qpe/resource.h>
27 39
28#include <qaction.h> 40#include <qaction.h>
29#include <qcombobox.h> 41#include <qcombobox.h>
30#include <qfile.h> 42#include <qfile.h>
31#include <qlabel.h> 43#include <qlabel.h>
32#include <qlayout.h> 44#include <qlayout.h>
33#include <qlineedit.h> 45#include <qlineedit.h>
34#include <qlistview.h> 46#include <qlistview.h>
35#include <qmenubar.h> 47#include <qmenubar.h>
36#include <qmessagebox.h> 48#include <qmessagebox.h>
37#include <qpopupmenu.h> 49#include <qpopupmenu.h>
38#include <qprogressbar.h> 50#include <qprogressbar.h>
39#include <qtimer.h> 51#include <qtimer.h>
40#include <qwhatsthis.h> 52#include <qwhatsthis.h>
41#include <qwidgetstack.h> 53#include <qwidgetstack.h>
42 54
43#include "categoryfilterimpl.h" 55#include "categoryfilterimpl.h"
44#include "datamgr.h" 56#include "datamgr.h"
45#include "global.h" 57#include "global.h"
46#include "inputdlg.h" 58#include "inputdlg.h"
47#include "ipkg.h" 59#include "ipkg.h"
48#include "installdlgimpl.h" 60#include "installdlgimpl.h"
49#include "letterpushbutton.h" 61#include "letterpushbutton.h"
50#include "mainwin.h" 62#include "mainwin.h"
51#include "packagewin.h" 63#include "packagewin.h"
52#include "settingsimpl.h" 64#include "settingsimpl.h"
53#include "utils.h" 65#include "utils.h"
54 66
55extern int compareVersions( const char *v1, const char *v2 ); 67extern int compareVersions( const char *v1, const char *v2 );
56 68
57MainWindow :: MainWindow() 69MainWindow :: MainWindow()
58 :QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) 70 :QMainWindow( 0x0, 0x0, WStyle_ContextHelp )
59{ 71{
60 setCaption( tr( "AQPkg - Package Manager" ) ); 72 setCaption( tr( "AQPkg - Package Manager" ) );
61 73
62 // Create UI widgets 74 // Create UI widgets
63 initMainWidget(); 75 initMainWidget();
64 initProgressWidget(); 76 initProgressWidget();
65 77
66 // Build menu and tool bars 78 // Build menu and tool bars
67 setToolBarsMovable( FALSE ); 79 setToolBarsMovable( FALSE );
68 80
69 QToolBar *bar = new QToolBar( this ); 81 QToolBar *bar = new QToolBar( this );
70 bar->setHorizontalStretchable( TRUE ); 82 bar->setHorizontalStretchable( TRUE );
71 QMenuBar *mb = new QMenuBar( bar ); 83 QMenuBar *mb = new QMenuBar( bar );
72 mb->setMargin( 0 ); 84 mb->setMargin( 0 );
73 bar = new QToolBar( this ); 85 bar = new QToolBar( this );
74 86
75 // Find toolbar 87 // Find toolbar
76 findBar = new QToolBar( this ); 88 findBar = new QToolBar( this );
77 addToolBar( findBar, QMainWindow::Top, true ); 89 addToolBar( findBar, QMainWindow::Top, true );
78 findBar->setHorizontalStretchable( true ); 90 findBar->setHorizontalStretchable( true );
79 findEdit = new QLineEdit( findBar ); 91 findEdit = new QLineEdit( findBar );
80 QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); 92 QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) );
81 findBar->setStretchableWidget( findEdit ); 93 findBar->setStretchableWidget( findEdit );
82 connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) ); 94 connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) );
83 95
84 // Quick jump toolbar 96 // Quick jump toolbar
85 jumpBar = new QToolBar( this ); 97 jumpBar = new QToolBar( this );
86 addToolBar( jumpBar, QMainWindow::Top, true ); 98 addToolBar( jumpBar, QMainWindow::Top, true );
87 jumpBar->setHorizontalStretchable( true ); 99 jumpBar->setHorizontalStretchable( true );
88 QWidget *w = new QWidget( jumpBar ); 100 QWidget *w = new QWidget( jumpBar );
89 jumpBar->setStretchableWidget( w ); 101 jumpBar->setStretchableWidget( w );
90 102
91 QGridLayout *layout = new QGridLayout( w ); 103 QGridLayout *layout = new QGridLayout( w );
92 104
93 char text[2]; 105 char text[2];
94 text[1] = '\0'; 106 text[1] = '\0';
95 for ( int i = 0 ; i < 26 ; ++i ) 107 for ( int i = 0 ; i < 26 ; ++i )
96 { 108 {
97 text[0] = 'A' + i; 109 text[0] = 'A' + i;
98 LetterPushButton *b = new LetterPushButton( text, w ); 110 LetterPushButton *b = new LetterPushButton( text, w );
99 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); 111 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) );
100 layout->addWidget( b, i / 13, i % 13); 112 layout->addWidget( b, i / 13, i % 13);
101 } 113 }
102 114
103 QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 ); 115 QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 );
104 a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) ); 116 a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) );
105 connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) ); 117 connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) );
106 a->addTo( jumpBar ); 118 a->addTo( jumpBar );
107 jumpBar->hide(); 119 jumpBar->hide();
108 120
109 // Packages menu 121 // Packages menu
110 QPopupMenu *popup = new QPopupMenu( this ); 122 QPopupMenu *popup = new QPopupMenu( this );
111 123
112 a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); 124 a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 );
113 a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); 125 a->setWhatsThis( tr( "Click here to update package lists from servers." ) );
114 connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) ); 126 connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) );
115 a->addTo( popup ); 127 a->addTo( popup );
116 a->addTo( bar ); 128 a->addTo( bar );
117 129
118 actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); 130 actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 );
119 actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); 131 actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) );
120 connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) ); 132 connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) );
121 actionUpgrade->addTo( popup ); 133 actionUpgrade->addTo( popup );
122 actionUpgrade->addTo( bar ); 134 actionUpgrade->addTo( bar );
123 135
124 iconDownload = Resource::loadPixmap( "aqpkg/download" ); 136 iconDownload = Resource::loadPixmap( "aqpkg/download" );
125 iconRemove = Resource::loadPixmap( "aqpkg/remove" ); 137 iconRemove = Resource::loadPixmap( "aqpkg/remove" );
126 actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); 138 actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 );
127 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); 139 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) );
128 connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) ); 140 connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) );
129 actionDownload->addTo( popup ); 141 actionDownload->addTo( popup );
130 actionDownload->addTo( bar ); 142 actionDownload->addTo( bar );
131 143
132 a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); 144 a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 );
133 a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); 145 a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) );
134 connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) ); 146 connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) );
135 a->addTo( popup ); 147 a->addTo( popup );
136 a->addTo( bar ); 148 a->addTo( bar );
137 149
138 popup->insertSeparator(); 150 popup->insertSeparator();
139 151
140 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); 152 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 );
141 a->setWhatsThis( tr( "Click here to configure this application." ) ); 153 a->setWhatsThis( tr( "Click here to configure this application." ) );
142 connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); 154 connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) );
143 a->addTo( popup ); 155 a->addTo( popup );
144 mb->insertItem( tr( "Actions" ), popup ); 156 mb->insertItem( tr( "Actions" ), popup );
145 157
146 // View menu 158 // View menu
147 popup = new QPopupMenu( this ); 159 popup = new QPopupMenu( this );
148 160
149 actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); 161 actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 );
150 actionUninstalled->setToggleAction( TRUE ); 162 actionUninstalled->setToggleAction( TRUE );
151 actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); 163 actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) );
152 connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); 164 connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) );
153 actionUninstalled->addTo( popup ); 165 actionUninstalled->addTo( popup );
154 166
155 actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); 167 actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 );
156 actionInstalled->setToggleAction( TRUE ); 168 actionInstalled->setToggleAction( TRUE );
157 actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); 169 actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) );
158 connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); 170 connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) );
159 actionInstalled->addTo( popup ); 171 actionInstalled->addTo( popup );
160 172
161 actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); 173 actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 );
162 actionUpdated->setToggleAction( TRUE ); 174 actionUpdated->setToggleAction( TRUE );
163 actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); 175 actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) );
164 connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); 176 connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) );
165 actionUpdated->addTo( popup ); 177 actionUpdated->addTo( popup );
166 178
167 popup->insertSeparator(); 179 popup->insertSeparator();
168 180
169 actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 ); 181 actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 );
170 actionFilter->setToggleAction( TRUE ); 182 actionFilter->setToggleAction( TRUE );
171 actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); 183 actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) );
172 connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); 184 connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) );
173 actionFilter->addTo( popup ); 185 actionFilter->addTo( popup );
174 186
175 a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 ); 187 a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 );
176 a->setWhatsThis( tr( "Click here to change package category to used filter." ) ); 188 a->setWhatsThis( tr( "Click here to change package category to used filter." ) );
177 connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); 189 connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) );
178 a->addTo( popup ); 190 a->addTo( popup );
179 191
180 popup->insertSeparator(); 192 popup->insertSeparator();
181 193
182 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); 194 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
183 a->setWhatsThis( tr( "Click here to search for text in package names." ) ); 195 a->setWhatsThis( tr( "Click here to search for text in package names." ) );
184 connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); 196 connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) );
185 a->addTo( popup ); 197 a->addTo( popup );
186 198
187 actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); 199 actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 );
188 actionFindNext->setEnabled( FALSE ); 200 actionFindNext->setEnabled( FALSE );
189 actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); 201 actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) );
190 connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); 202 connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) );
191 actionFindNext->addTo( popup ); 203 actionFindNext->addTo( popup );
192 actionFindNext->addTo( findBar ); 204 actionFindNext->addTo( findBar );
193 205
194 206
195 popup->insertSeparator(); 207 popup->insertSeparator();
196 208
197 a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 ); 209 a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 );
198 a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) ); 210 a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) );
199 connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) ); 211 connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) );
200 a->addTo( popup ); 212 a->addTo( popup );
201 213
202 mb->insertItem( tr( "View" ), popup ); 214 mb->insertItem( tr( "View" ), popup );
203 215
204 // Finish find toolbar creation 216 // Finish find toolbar creation
205 a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 217 a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
206 a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); 218 a->setWhatsThis( tr( "Click here to hide the find toolbar." ) );
207 connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); 219 connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) );
208 a->addTo( findBar ); 220 a->addTo( findBar );
209 findBar->hide(); 221 findBar->hide();
210 222
211 // Create widget stack and add UI widgets 223 // Create widget stack and add UI widgets
212 stack = new QWidgetStack( this ); 224 stack = new QWidgetStack( this );
213 stack->addWidget( progressWindow, 2 ); 225 stack->addWidget( progressWindow, 2 );
214 stack->addWidget( networkPkgWindow, 1 ); 226 stack->addWidget( networkPkgWindow, 1 );
215 setCentralWidget( stack ); 227 setCentralWidget( stack );
216 stack->raiseWidget( progressWindow ); 228 stack->raiseWidget( progressWindow );
217 229
218 // Delayed call to finish initialization 230 // Delayed call to finish initialization
219 QTimer::singleShot( 100, this, SLOT( init() ) ); 231 QTimer::singleShot( 100, this, SLOT( init() ) );
220} 232}
221 233
222MainWindow :: ~MainWindow() 234MainWindow :: ~MainWindow()
223{ 235{
224 delete mgr; 236 delete mgr;
225} 237}
226 238
227void MainWindow :: initMainWidget() 239void MainWindow :: initMainWidget()
228{ 240{
229 networkPkgWindow = new QWidget( this ); 241 networkPkgWindow = new QWidget( this );
230 242
231 QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); 243 QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow );
232 244
233 serversList = new QComboBox( networkPkgWindow ); 245 serversList = new QComboBox( networkPkgWindow );
234 connect( serversList, SIGNAL(activated(int)), this, SLOT(serverSelected(int)) ); 246 connect( serversList, SIGNAL(activated(int)), this, SLOT(serverSelected(int)) );
235 QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); 247 QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) );
236 248
237 installedIcon = Resource::loadPixmap( "installed" ); 249 installedIcon = Resource::loadPixmap( "installed" );
238 updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); 250 updatedIcon = Resource::loadPixmap( "aqpkg/updated" );
239 251
240 packagesList = new QListView( networkPkgWindow ); 252 packagesList = new QListView( networkPkgWindow );
241 packagesList->addColumn( tr( "Packages" ), 225 ); 253 packagesList->addColumn( tr( "Packages" ), 225 );
242 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." ) ); 254 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." ) );
243 QPEApplication::setStylusOperation( packagesList->viewport(), QPEApplication::RightOnHold ); 255 QPEApplication::setStylusOperation( packagesList->viewport(), QPEApplication::RightOnHold );
244 connect( packagesList, SIGNAL(rightButtonPressed(QListViewItem *,const QPoint &,int)), 256 connect( packagesList, SIGNAL(rightButtonPressed(QListViewItem *,const QPoint &,int)),
245 this, SLOT(slotDisplayPackage(QListViewItem *)) ); 257 this, SLOT(slotDisplayPackage(QListViewItem *)) );
246 258
247 QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); 259 QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 );
248 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); 260 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 );
249 hbox1->addWidget( l ); 261 hbox1->addWidget( l );
250 hbox1->addWidget( serversList ); 262 hbox1->addWidget( serversList );
251 263
252 vbox->addWidget( packagesList ); 264 vbox->addWidget( packagesList );
253 265
254 downloadEnabled = TRUE; 266 downloadEnabled = TRUE;
255} 267}
256 268
257void MainWindow :: initProgressWidget() 269void MainWindow :: initProgressWidget()
258{ 270{
259 progressWindow = new QWidget( this ); 271 progressWindow = new QWidget( this );
260 272
261 QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); 273 QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 );
262 274
263 m_status = new QLabel( progressWindow ); 275 m_status = new QLabel( progressWindow );
264 m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); 276 m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
265 layout->addWidget( m_status ); 277 layout->addWidget( m_status );
266 278
267 m_progress = new QProgressBar( progressWindow ); 279 m_progress = new QProgressBar( progressWindow );
268 layout->addWidget( m_progress ); 280 layout->addWidget( m_progress );
269} 281}
270 282
271void MainWindow :: init() 283void MainWindow :: init()
272{ 284{
273#ifdef QWS 285#ifdef QWS
274 // read download directory from config file 286 // read download directory from config file
275 Config cfg( "aqpkg" ); 287 Config cfg( "aqpkg" );
276 cfg.setGroup( "settings" ); 288 cfg.setGroup( "settings" );
277 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); 289 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" );
278// showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); 290// showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" );
279 291
280#endif 292#endif
281 293
282 stack->raiseWidget( progressWindow ); 294 stack->raiseWidget( progressWindow );
283 295
284 mgr = new DataManager(); 296 mgr = new DataManager();
285 connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); 297 connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) );
286 connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), 298 connect( mgr, SIGNAL( progressSetMessage( const QString & ) ),
287 this, SLOT( setProgressMessage( const QString & ) ) ); 299 this, SLOT( setProgressMessage( const QString & ) ) );
288 connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); 300 connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) );
289 mgr->loadServers(); 301 mgr->loadServers();
290 302
291 showUninstalledPkgs = false; 303 showUninstalledPkgs = false;
292 showInstalledPkgs = false; 304 showInstalledPkgs = false;
293 showUpgradedPkgs = false; 305 showUpgradedPkgs = false;
294 categoryFilterEnabled = false; 306 categoryFilterEnabled = false;
295 307
296 updateData(); 308 updateData();
297 309
298 stack->raiseWidget( networkPkgWindow ); 310 stack->raiseWidget( networkPkgWindow );
299} 311}
300 312
301void MainWindow :: setDocument( const QString &doc ) 313void MainWindow :: setDocument( const QString &doc )
302{ 314{
303 // Remove path from package 315 // Remove path from package
304 QString package = Utils::getPackageNameFromIpkFilename( doc ); 316 QString package = Utils::getPackageNameFromIpkFilename( doc );
305// std::cout << "Selecting package " << package << std::endl;
306 317
307 // First select local server 318 // First select local server
308 for ( int i = 0 ; i < serversList->count() ; ++i ) 319 for ( int i = 0 ; i < serversList->count() ; ++i )
309 { 320 {
310 if ( serversList->text( i ) == LOCAL_IPKGS ) 321 if ( serversList->text( i ) == LOCAL_IPKGS )
311 { 322 {
312 serversList->setCurrentItem( i ); 323 serversList->setCurrentItem( i );
313 break; 324 break;
314 } 325 }
315 } 326 }
316 serverSelected( 0 ); 327 serverSelected( 0 );
317 328
318 // Now set the check box of the selected package 329 // Now set the check box of the selected package
319 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 330 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
320 item != 0 ; 331 item != 0 ;
321 item = (QCheckListItem *)item->nextSibling() ) 332 item = (QCheckListItem *)item->nextSibling() )
322 { 333 {
323 if ( item->text().startsWith( package ) ) 334 if ( item->text().startsWith( package ) )
324 { 335 {
325 item->setOn( true ); 336 item->setOn( true );
326 break; 337 break;
327 } 338 }
328 } 339 }
329} 340}
330 341
331void MainWindow :: displaySettings() 342void MainWindow :: displaySettings()
332{ 343{
333 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); 344 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true );
334 if ( dlg->showDlg() ) 345 if ( dlg->showDlg() )
335 { 346 {
336 stack->raiseWidget( progressWindow ); 347 stack->raiseWidget( progressWindow );
337 updateData(); 348 updateData();
338 stack->raiseWidget( networkPkgWindow ); 349 stack->raiseWidget( networkPkgWindow );
339 } 350 }
340 delete dlg; 351 delete dlg;
341} 352}
342 353
343void MainWindow :: closeEvent( QCloseEvent *e ) 354void MainWindow :: closeEvent( QCloseEvent *e )
344{ 355{
345 // If install dialog is visible, return to main view, otherwise close app 356 // If install dialog is visible, return to main view, otherwise close app
346 QWidget *widget = stack->visibleWidget(); 357 QWidget *widget = stack->visibleWidget();
347 358
348 if ( widget != networkPkgWindow && widget != progressWindow ) 359 if ( widget != networkPkgWindow && widget != progressWindow )
349 { 360 {
350 if ( widget ) delete widget; 361 if ( widget ) delete widget;
351 stack->raiseWidget( networkPkgWindow ); 362 stack->raiseWidget( networkPkgWindow );
352 e->ignore(); 363 e->ignore();
353 } 364 }
354 else 365 else
355 { 366 {
356 e->accept(); 367 e->accept();
357 } 368 }
358} 369}
359 370
360void MainWindow :: displayFindBar() 371void MainWindow :: displayFindBar()
361{ 372{
362 findBar->show(); 373 findBar->show();
363 findEdit->setFocus(); 374 findEdit->setFocus();
364} 375}
365 376
366void MainWindow :: displayJumpBar() 377void MainWindow :: displayJumpBar()
367{ 378{
368 jumpBar->show(); 379 jumpBar->show();
369} 380}
370 381
371void MainWindow :: repeatFind() 382void MainWindow :: repeatFind()
372{ 383{
373 searchForPackage( findEdit->text() ); 384 searchForPackage( findEdit->text() );
374} 385}
375 386
376void MainWindow :: findPackage( const QString &text ) 387void MainWindow :: findPackage( const QString &text )
377{ 388{
378 actionFindNext->setEnabled( !text.isEmpty() ); 389 actionFindNext->setEnabled( !text.isEmpty() );
379 searchForPackage( text ); 390 searchForPackage( text );
380} 391}
381 392
382void MainWindow :: hideFindBar() 393void MainWindow :: hideFindBar()
383{ 394{
384 findBar->hide(); 395 findBar->hide();
385} 396}
386 397
387void MainWindow :: hideJumpBar() 398void MainWindow :: hideJumpBar()
388{ 399{
389 jumpBar->hide(); 400 jumpBar->hide();
390} 401}
391 402
392void MainWindow :: filterUninstalledPackages() 403void MainWindow :: filterUninstalledPackages()
393{ 404{
394 showUninstalledPkgs = actionUninstalled->isOn(); 405 showUninstalledPkgs = actionUninstalled->isOn();
395 if ( showUninstalledPkgs ) 406 if ( showUninstalledPkgs )
396 { 407 {
397 showInstalledPkgs = FALSE; 408 showInstalledPkgs = FALSE;
398 showUpgradedPkgs = FALSE; 409 showUpgradedPkgs = FALSE;
399 } 410 }
400 serverSelected( -1 ); 411 serverSelected( -1 );
401 412
402 actionInstalled->setOn( FALSE ); 413 actionInstalled->setOn( FALSE );
403 actionUpdated->setOn( FALSE ); 414 actionUpdated->setOn( FALSE );
404} 415}
405 416
406void MainWindow :: filterInstalledPackages() 417void MainWindow :: filterInstalledPackages()
407{ 418{
408 showInstalledPkgs = actionInstalled->isOn(); 419 showInstalledPkgs = actionInstalled->isOn();
409 if ( showInstalledPkgs ) 420 if ( showInstalledPkgs )
410 { 421 {
411 showUninstalledPkgs = FALSE; 422 showUninstalledPkgs = FALSE;
412 showUpgradedPkgs = FALSE; 423 showUpgradedPkgs = FALSE;
413 } 424 }
414 serverSelected( -1 ); 425 serverSelected( -1 );
415 426
416 actionUninstalled->setOn( FALSE ); 427 actionUninstalled->setOn( FALSE );
417 actionUpdated->setOn( FALSE ); 428 actionUpdated->setOn( FALSE );
418} 429}
419 430
420void MainWindow :: filterUpgradedPackages() 431void MainWindow :: filterUpgradedPackages()
421{ 432{
422 showUpgradedPkgs = actionUpdated->isOn(); 433 showUpgradedPkgs = actionUpdated->isOn();
423 if ( showUpgradedPkgs ) 434 if ( showUpgradedPkgs )
424 { 435 {
425 showUninstalledPkgs = FALSE; 436 showUninstalledPkgs = FALSE;
426 showInstalledPkgs = FALSE; 437 showInstalledPkgs = FALSE;
427 } 438 }
428 serverSelected( -1 ); 439 serverSelected( -1 );
429 440
430 actionUninstalled->setOn( FALSE ); 441 actionUninstalled->setOn( FALSE );
431 actionInstalled->setOn( FALSE ); 442 actionInstalled->setOn( FALSE );
432} 443}
433 444
434bool MainWindow :: setFilterCategory() 445bool MainWindow :: setFilterCategory()
435{ 446{
436 // Get categories; 447 // Get categories;
437 CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); 448 CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this );
438 if ( dlg.exec() == QDialog::Accepted ) 449 if ( dlg.exec() == QDialog::Accepted )
439 { 450 {
440 categoryFilter = dlg.getSelectedFilter(); 451 categoryFilter = dlg.getSelectedFilter();
441 452
442 if ( categoryFilter == "" ) 453 if ( categoryFilter == "" )
443 return false; 454 return false;
444 455
445 categoryFilterEnabled = true; 456 categoryFilterEnabled = true;
446 serverSelected( -1 ); 457 serverSelected( -1 );
447 actionFilter->setOn( TRUE ); 458 actionFilter->setOn( TRUE );
448 return true; 459 return true;
449 } 460 }
450 461
451 return false; 462 return false;
452} 463}
453 464
454void MainWindow :: filterCategory() 465void MainWindow :: filterCategory()
455{ 466{
456 if ( !actionFilter->isOn() ) 467 if ( !actionFilter->isOn() )
457 { 468 {
458 filterByCategory( FALSE ); 469 filterByCategory( FALSE );
459 } 470 }
460 else 471 else
461 { 472 {
462 actionFilter->setOn( filterByCategory( TRUE ) ); 473 actionFilter->setOn( filterByCategory( TRUE ) );
463 } 474 }
464} 475}
465 476
466bool MainWindow :: filterByCategory( bool val ) 477bool MainWindow :: filterByCategory( bool val )
467{ 478{
468 if ( val ) 479 if ( val )
469 { 480 {
470 if ( categoryFilter == "" ) 481 if ( categoryFilter == "" )
471 { 482 {
472 if ( !setFilterCategory() ) 483 if ( !setFilterCategory() )
473 return false; 484 return false;
474 } 485 }
475 486
476 categoryFilterEnabled = true; 487 categoryFilterEnabled = true;
477 serverSelected( -1 ); 488 serverSelected( -1 );
478 return true; 489 return true;
479 } 490 }
480 else 491 else
481 { 492 {
482 // Turn off filter 493 // Turn off filter
483 categoryFilterEnabled = false; 494 categoryFilterEnabled = false;
484 serverSelected( -1 ); 495 serverSelected( -1 );
485 return false; 496 return false;
486 } 497 }
487} 498}
488 499
489void MainWindow :: raiseMainWidget() 500void MainWindow :: raiseMainWidget()
490{ 501{
491 stack->raiseWidget( networkPkgWindow ); 502 stack->raiseWidget( networkPkgWindow );
492} 503}
493 504
494void MainWindow :: raiseProgressWidget() 505void MainWindow :: raiseProgressWidget()
495{ 506{
496 stack->raiseWidget( progressWindow ); 507 stack->raiseWidget( progressWindow );
497} 508}
498 509
499void MainWindow :: enableUpgrade( bool enabled ) 510void MainWindow :: enableUpgrade( bool enabled )
500{ 511{
501 actionUpgrade->setEnabled( enabled ); 512 actionUpgrade->setEnabled( enabled );
502} 513}
503 514
504void MainWindow :: enableDownload( bool enabled ) 515void MainWindow :: enableDownload( bool enabled )
505{ 516{
506 if ( enabled ) 517 if ( enabled )
507 { 518 {
508 actionDownload->setIconSet( iconDownload ); 519 actionDownload->setIconSet( iconDownload );
509 actionDownload->setText( tr( "Download" ) ); 520 actionDownload->setText( tr( "Download" ) );
510 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); 521 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) );
511 } 522 }
512 else 523 else
513 { 524 {
514 actionDownload->setIconSet( iconRemove ); 525 actionDownload->setIconSet( iconRemove );
515 actionDownload->setText( tr( "Remove" ) ); 526 actionDownload->setText( tr( "Remove" ) );
516 actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); 527 actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) );
517 } 528 }
518} 529}
519 530
520void MainWindow :: setProgressSteps( int numsteps ) 531void MainWindow :: setProgressSteps( int numsteps )
521{ 532{
522 m_progress->setTotalSteps( numsteps ); 533 m_progress->setTotalSteps( numsteps );
523} 534}
524 535
525void MainWindow :: setProgressMessage( const QString &msg ) 536void MainWindow :: setProgressMessage( const QString &msg )
526{ 537{
527 m_status->setText( msg ); 538 m_status->setText( msg );
528} 539}
529 540
530void MainWindow :: updateProgress( int progress ) 541void MainWindow :: updateProgress( int progress )
531{ 542{
532 m_progress->setProgress( progress ); 543 m_progress->setProgress( progress );
533} 544}
534 545
535void MainWindow :: updateData() 546void MainWindow :: updateData()
536{ 547{
537 m_progress->setTotalSteps( mgr->getServerList().count() ); 548 m_progress->setTotalSteps( mgr->getServerList().count() );
538 549
539 serversList->clear(); 550 serversList->clear();
540 packagesList->clear(); 551 packagesList->clear();
541 552
542 int activeItem = -1; 553 int activeItem = -1;
543 int i = 0; 554 int i = 0;
544 QString serverName; 555 QString serverName;
545 556
546 QListIterator<Server> it( mgr->getServerList() ); 557 QListIterator<Server> it( mgr->getServerList() );
547 Server *server; 558 Server *server;
548 559
549 for ( ; it.current(); ++it, ++i ) 560 for ( ; it.current(); ++it, ++i )
550 { 561 {
551 server = it.current(); 562 server = it.current();
552 serverName = server->getServerName(); 563 serverName = server->getServerName();
553 m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); 564 m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) );
554 m_progress->setProgress( i ); 565 m_progress->setProgress( i );
555 qApp->processEvents(); 566 qApp->processEvents();
556 567
557// cout << "Adding " << it->getServerName() << " to combobox" << endl;
558 if ( !server->isServerActive() ) 568 if ( !server->isServerActive() )
559 { 569 {
560// cout << serverName << " is not active" << endl;
561 i--; 570 i--;
562 continue; 571 continue;
563 } 572 }
564 573
565 serversList->insertItem( serverName ); 574 serversList->insertItem( serverName );
566 if ( serverName == currentlySelectedServer ) 575 if ( serverName == currentlySelectedServer )
567 activeItem = i; 576 activeItem = i;
568 } 577 }
569 578
570 // set selected server to be active server 579 // set selected server to be active server
571 if ( activeItem != -1 ) 580 if ( activeItem != -1 )
572 serversList->setCurrentItem( activeItem ); 581 serversList->setCurrentItem( activeItem );
573 serverSelected( 0, FALSE ); 582 serverSelected( 0, FALSE );
574} 583}
575 584
576void MainWindow :: serverSelected( int index ) 585void MainWindow :: serverSelected( int index )
577{ 586{
578 serverSelected( index, TRUE ); 587 serverSelected( index, TRUE );
579} 588}
580 589
581void MainWindow :: serverSelected( int, bool raiseProgress ) 590void MainWindow :: serverSelected( int, bool raiseProgress )
582{ 591{
583 QPixmap nullIcon( installedIcon.size() ); 592 QPixmap nullIcon( installedIcon.size() );
584 nullIcon.fill( colorGroup().base() ); 593 nullIcon.fill( colorGroup().base() );
585 594
586 // display packages 595 // display packages
587 QString serverName = serversList->currentText(); 596 QString serverName = serversList->currentText();
588 currentlySelectedServer = serverName; 597 currentlySelectedServer = serverName;
589 598
590 Server *s = mgr->getServer( serverName ); 599 Server *s = mgr->getServer( serverName );
591 600
592 QList<Package> &list = s->getPackageList(); 601 QList<Package> &list = s->getPackageList();
593 QListIterator<Package> it( list ); 602 QListIterator<Package> it( list );
594 603
595 // Display progress widget while loading list 604 // Display progress widget while loading list
596 bool doProgress = ( list.count() > 200 ); 605 bool doProgress = ( list.count() > 200 );
597 if ( doProgress ) 606 if ( doProgress )
598 { 607 {
599 if ( raiseProgress ) 608 if ( raiseProgress )
600 { 609 {
601 stack->raiseWidget( progressWindow ); 610 stack->raiseWidget( progressWindow );
602 } 611 }
603 m_progress->setTotalSteps( list.count() ); 612 m_progress->setTotalSteps( list.count() );
604 m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); 613 m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) );
605 } 614 }
606 615
607 packagesList->clear(); 616 packagesList->clear();
608 617
609#ifdef QWS 618#ifdef QWS
610 // read download directory from config file 619 // read download directory from config file
611 Config cfg( "aqpkg" ); 620 Config cfg( "aqpkg" );
612 cfg.setGroup( "settings" ); 621 cfg.setGroup( "settings" );
613 cfg.writeEntry( "selectedServer", currentlySelectedServer ); 622 cfg.writeEntry( "selectedServer", currentlySelectedServer );
614#endif 623#endif
615 624
616 int i = 0; 625 int i = 0;
617 Package *package; 626 Package *package;
618 for ( ; it.current(); ++it ) 627 for ( ; it.current(); ++it )
619 { 628 {
620 // Update progress after every 100th package (arbitrary value, seems to give good balance) 629 // Update progress after every 100th package (arbitrary value, seems to give good balance)
621 i++; 630 i++;
622 if ( ( i % 100 ) == 0 ) 631 if ( ( i % 100 ) == 0 )
623 { 632 {
624 if ( doProgress ) 633 if ( doProgress )
625 { 634 {
626 m_progress->setProgress( i ); 635 m_progress->setProgress( i );
627 } 636 }
628 qApp->processEvents(); 637 qApp->processEvents();
629 } 638 }
630 639
631 QString text = ""; 640 QString text = "";
632 641
633 package = it.current(); 642 package = it.current();
634 643
635 // Apply show only uninstalled packages filter 644 // Apply show only uninstalled packages filter
636 if ( showUninstalledPkgs && package->isInstalled() ) 645 if ( showUninstalledPkgs && package->isInstalled() )
637 continue; 646 continue;
638 647
639 // Apply show only installed packages filter 648 // Apply show only installed packages filter
640 if ( showInstalledPkgs && !package->isInstalled() ) 649 if ( showInstalledPkgs && !package->isInstalled() )
641 continue; 650 continue;
642 651
643 // Apply show only new installed packages filter 652 // Apply show only new installed packages filter
644 if ( showUpgradedPkgs ) 653 if ( showUpgradedPkgs )
645 { 654 {
646 if ( !package->isInstalled() || !package->getNewVersionAvailable() ) 655 if ( !package->isInstalled() || !package->getNewVersionAvailable() )
647 continue; 656 continue;
648 } 657 }
649 658
650 // Apply the section filter 659 // Apply the section filter
651 if ( categoryFilterEnabled && categoryFilter != "" ) 660 if ( categoryFilterEnabled && categoryFilter != "" )
652 { 661 {
653 if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 ) 662 if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 )
654 continue; 663 continue;
655 } 664 }
656 665
657 // If the local server, only display installed packages 666 // If the local server, only display installed packages
658 if ( serverName == LOCAL_SERVER && !package->isInstalled() ) 667 if ( serverName == LOCAL_SERVER && !package->isInstalled() )
659 continue; 668 continue;
660 669
661 670
662 QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), 671 QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(),
663 QCheckListItem::CheckBox ); 672 QCheckListItem::CheckBox );
664 673
665 if ( package->isInstalled() ) 674 if ( package->isInstalled() )
666 { 675 {
667 // If a different version of package is available, show update available icon 676 // If a different version of package is available, show update available icon
668 // Otherwise, show installed icon 677 // Otherwise, show installed icon
669 if ( package->getNewVersionAvailable()) 678 if ( package->getNewVersionAvailable())
670 { 679 {
671 680
672 item->setPixmap( 0, updatedIcon ); 681 item->setPixmap( 0, updatedIcon );
673 } 682 }
674 else 683 else
675 { 684 {
676 item->setPixmap( 0, installedIcon ); 685 item->setPixmap( 0, installedIcon );
677 } 686 }
678 } 687 }
679 else 688 else
680 { 689 {
681 item->setPixmap( 0, nullIcon ); 690 item->setPixmap( 0, nullIcon );
682 } 691 }
683 692
684 packagesList->insertItem( item ); 693 packagesList->insertItem( item );
685 } 694 }
686 695
687 // If the local server or the local ipkgs server disable the download button 696 // If the local server or the local ipkgs server disable the download button
688 if ( serverName == LOCAL_SERVER ) 697 if ( serverName == LOCAL_SERVER )
689 { 698 {
690 downloadEnabled = TRUE; 699 downloadEnabled = TRUE;
691 actionUpgrade->setEnabled( FALSE ); 700 actionUpgrade->setEnabled( FALSE );
692 } 701 }
693 else if ( serverName == LOCAL_IPKGS ) 702 else if ( serverName == LOCAL_IPKGS )
694 { 703 {
695 downloadEnabled = FALSE; 704 downloadEnabled = FALSE;
696 actionUpgrade->setEnabled( FALSE ); 705 actionUpgrade->setEnabled( FALSE );
697 } 706 }
698 else 707 else
699 { 708 {
700 downloadEnabled = TRUE; 709 downloadEnabled = TRUE;
701 actionUpgrade->setEnabled( TRUE ); 710 actionUpgrade->setEnabled( TRUE );
702 } 711 }
703 enableDownload( downloadEnabled ); 712 enableDownload( downloadEnabled );
704 713
705 // Display this widget once everything is done 714 // Display this widget once everything is done
706 if ( doProgress && raiseProgress ) 715 if ( doProgress && raiseProgress )
707 { 716 {
708 stack->raiseWidget( networkPkgWindow ); 717 stack->raiseWidget( networkPkgWindow );
709 } 718 }
710} 719}
711 720
712void MainWindow :: searchForPackage( const QString &text ) 721void MainWindow :: searchForPackage( const QString &text )
713{ 722{
714 if ( !text.isEmpty() ) 723 if ( !text.isEmpty() )
715 { 724 {
716// cout << "searching for " << text << endl;
717 // look through package list for text startng at current position 725 // look through package list for text startng at current position
718// vector<InstallData> workingPackages;
719 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); 726 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
720// if ( start != 0 )
721// start = (QCheckListItem *)start->nextSibling();
722 727
723 if ( start == 0 ) 728 if ( start == 0 )
724 start = (QCheckListItem *)packagesList->firstChild(); 729 start = (QCheckListItem *)packagesList->firstChild();
725 730
726 for ( QCheckListItem *item = start; item != 0 ; 731 for ( QCheckListItem *item = start; item != 0 ;
727 item = (QCheckListItem *)item->nextSibling() ) 732 item = (QCheckListItem *)item->nextSibling() )
728 { 733 {
729// cout << "checking " << item->text().lower() << endl;
730 if ( item->text().lower().find( text ) != -1 ) 734 if ( item->text().lower().find( text ) != -1 )
731 { 735 {
732// cout << "matched " << item->text() << endl;
733 packagesList->ensureItemVisible( item ); 736 packagesList->ensureItemVisible( item );
734 packagesList->setCurrentItem( item ); 737 packagesList->setCurrentItem( item );
735 break; 738 break;
736 } 739 }
737 } 740 }
738 } 741 }
739} 742}
740 743
741void MainWindow :: updateServer() 744void MainWindow :: updateServer()
742{ 745{
743 QString serverName = serversList->currentText(); 746 QString serverName = serversList->currentText();
744 747
745 // Update the current server 748 // Update the current server
746 // Display dialog 749 // Display dialog
747 750
748 // Disable buttons to stop silly people clicking lots on them :) 751 // Disable buttons to stop silly people clicking lots on them :)
749 752
750 // First, write out ipkg_conf file so that ipkg can use it 753 // First, write out ipkg_conf file so that ipkg can use it
751 mgr->writeOutIpkgConf(); 754 mgr->writeOutIpkgConf();
752 755
753 Ipkg *ipkg = new Ipkg; 756 Ipkg *ipkg = new Ipkg;
754 ipkg->setOption( "update" ); 757 ipkg->setOption( "update" );
755 758
756 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), 759 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ),
757 tr( "Update lists" ) ); 760 tr( "Update lists" ) );
758 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 761 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
759 reloadDocuments = FALSE; 762 reloadDocuments = FALSE;
760 stack->addWidget( dlg, 3 ); 763 stack->addWidget( dlg, 3 );
761 stack->raiseWidget( dlg ); 764 stack->raiseWidget( dlg );
762 765
763// delete progDlg; 766// delete progDlg;
764} 767}
765 768
766void MainWindow :: upgradePackages() 769void MainWindow :: upgradePackages()
767{ 770{
768 // We're gonna do an upgrade of all packages 771 // We're gonna do an upgrade of all packages
769 // First warn user that this isn't recommended 772 // First warn user that this isn't recommended
770 // TODO - ODevice???? 773 // TODO - ODevice????
771 QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); 774 QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" );
772 QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, 775 QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning,
773 QMessageBox::Yes, 776 QMessageBox::Yes,
774 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , 777 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default ,
775 0, this ); 778 0, this );
776 warn.adjustSize(); 779 warn.adjustSize();
777 780
778 if ( warn.exec() == QMessageBox::Yes ) 781 if ( warn.exec() == QMessageBox::Yes )
779 { 782 {
780 // First, write out ipkg_conf file so that ipkg can use it 783 // First, write out ipkg_conf file so that ipkg can use it
781 mgr->writeOutIpkgConf(); 784 mgr->writeOutIpkgConf();
782 785
783 // Now run upgrade 786 // Now run upgrade
784 Ipkg *ipkg = new Ipkg; 787 Ipkg *ipkg = new Ipkg;
785 ipkg->setOption( "upgrade" ); 788 ipkg->setOption( "upgrade" );
786 789
787 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ), 790 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ),
788 tr ( "Upgrade" ) ); 791 tr ( "Upgrade" ) );
789 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 792 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
790 reloadDocuments = TRUE; 793 reloadDocuments = TRUE;
791 stack->addWidget( dlg, 3 ); 794 stack->addWidget( dlg, 3 );
792 stack->raiseWidget( dlg ); 795 stack->raiseWidget( dlg );
793 } 796 }
794} 797}
795 798
796void MainWindow :: downloadPackage() 799void MainWindow :: downloadPackage()
797{ 800{
798 bool doUpdate = true; 801 bool doUpdate = true;
799 if ( downloadEnabled ) 802 if ( downloadEnabled )
800 { 803 {
801 // See if any packages are selected 804 // See if any packages are selected
802 bool found = false; 805 bool found = false;
803 if ( serversList->currentText() != LOCAL_SERVER ) 806 if ( serversList->currentText() != LOCAL_SERVER )
804 { 807 {
805 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 808 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
806 item != 0 && !found; 809 item != 0 && !found;
807 item = (QCheckListItem *)item->nextSibling() ) 810 item = (QCheckListItem *)item->nextSibling() )
808 { 811 {
809 if ( item->isOn() ) 812 if ( item->isOn() )
810 found = true; 813 found = true;
811 } 814 }
812 } 815 }
813 816
814 // If user selected some packages then download the and store the locally 817 // If user selected some packages then download the and store the locally
815 // otherwise, display dialog asking user what package to download from an http server 818 // otherwise, display dialog asking user what package to download from an http server
816 // and whether to install it 819 // and whether to install it
817 if ( found ) 820 if ( found )
818 downloadSelectedPackages(); 821 downloadSelectedPackages();
819 else 822 else
820 downloadRemotePackage(); 823 downloadRemotePackage();
821 824
822 } 825 }
823 else 826 else
824 { 827 {
825 doUpdate = false; 828 doUpdate = false;
826 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 829 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
827 item != 0 ; 830 item != 0 ;
828 item = (QCheckListItem *)item->nextSibling() ) 831 item = (QCheckListItem *)item->nextSibling() )
829 { 832 {
830 if ( item->isOn() ) 833 if ( item->isOn() )
831 { 834 {
832 QString name = item->text(); 835 QString name = item->text();
833 int pos = name.find( "*" ); 836 int pos = name.find( "*" );
834 name.truncate( pos ); 837 name.truncate( pos );
835 838
836 // if (there is a (installed), remove it 839 // if (there is a (installed), remove it
837 pos = name.find( "(installed)" ); 840 pos = name.find( "(installed)" );
838 if ( pos > 0 ) 841 if ( pos > 0 )
839 name.truncate( pos - 1 ); 842 name.truncate( pos - 1 );
840 843
841 Package *p = mgr->getServer( serversList->currentText() )->getPackage( name ); 844 Package *p = mgr->getServer( serversList->currentText() )->getPackage( name );
842 845
843 QString msgtext; 846 QString msgtext;
844 msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() ); 847 msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() );
845 if ( QMessageBox::information( this, tr( "Are you sure?" ), 848 if ( QMessageBox::information( this, tr( "Are you sure?" ),
846 msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) 849 msgtext, tr( "No" ), tr( "Yes" ) ) == 1 )
847 { 850 {
848 doUpdate = true; 851 doUpdate = true;
849 QFile f( p->getFilename() ); 852 QFile f( p->getFilename() );
850 f.remove(); 853 f.remove();
851 } 854 }
852 } 855 }
853 } 856 }
854 } 857 }
855 858
856 if ( doUpdate ) 859 if ( doUpdate )
857 { 860 {
858 reloadData( 0x0 ); 861 reloadData( 0x0 );
859 } 862 }
860} 863}
861 864
862void MainWindow :: downloadSelectedPackages() 865void MainWindow :: downloadSelectedPackages()
863{ 866{
864 // First, write out ipkg_conf file so that ipkg can use it 867 // First, write out ipkg_conf file so that ipkg can use it
865 mgr->writeOutIpkgConf(); 868 mgr->writeOutIpkgConf();
866 869
867 // Display dialog to user asking where to download the files to 870 // Display dialog to user asking where to download the files to
868 bool ok = FALSE; 871 bool ok = FALSE;
869 QString dir = ""; 872 QString dir = "";
870#ifdef QWS 873#ifdef QWS
871 // read download directory from config file 874 // read download directory from config file
872 Config cfg( "aqpkg" ); 875 Config cfg( "aqpkg" );
873 cfg.setGroup( "settings" ); 876 cfg.setGroup( "settings" );
874 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); 877 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" );
875#endif 878#endif
876 879
877 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); 880 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this );
878 if ( ok && !text.isEmpty() ) 881 if ( ok && !text.isEmpty() )
879 dir = text; // user entered something and pressed ok 882 dir = text; // user entered something and pressed ok
880 else 883 else
881 return; // user entered nothing or pressed cancel 884 return; // user entered nothing or pressed cancel
882 885
883#ifdef QWS 886#ifdef QWS
884 // Store download directory in config file 887 // Store download directory in config file
885 cfg.writeEntry( "downloadDir", dir ); 888 cfg.writeEntry( "downloadDir", dir );
886#endif 889#endif
887 890
888 // Get starting directory 891 // Get starting directory
889 char initDir[PATH_MAX]; 892 char initDir[PATH_MAX];
890 getcwd( initDir, PATH_MAX ); 893 getcwd( initDir, PATH_MAX );
891 894
892 // Download each package 895 // Download each package
893 Ipkg ipkg; 896 Ipkg ipkg;
894 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 897 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
895 898
896 ipkg.setOption( "download" ); 899 ipkg.setOption( "download" );
897 ipkg.setRuntimeDirectory( dir ); 900 ipkg.setRuntimeDirectory( dir );
898 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 901 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
899 item != 0 ; 902 item != 0 ;
900 item = (QCheckListItem *)item->nextSibling() ) 903 item = (QCheckListItem *)item->nextSibling() )
901 { 904 {
902 if ( item->isOn() ) 905 if ( item->isOn() )
903 { 906 {
904 ipkg.setPackage( item->text() ); 907 ipkg.setPackage( item->text() );
905 ipkg.runIpkg( ); 908 ipkg.runIpkg( );
906 } 909 }
907 } 910 }
908} 911}
909 912
910void MainWindow :: downloadRemotePackage() 913void MainWindow :: downloadRemotePackage()
911{ 914{
912 // Display dialog 915 // Display dialog
913 bool ok; 916 bool ok;
914 QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); 917 QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this );
915 if ( !ok || package.isEmpty() ) 918 if ( !ok || package.isEmpty() )
916 return; 919 return;
917// DownloadRemoteDlgImpl dlg( this, "Install", true ); 920// DownloadRemoteDlgImpl dlg( this, "Install", true );
918// if ( dlg.exec() == QDialog::Rejected ) 921// if ( dlg.exec() == QDialog::Rejected )
919// return; 922// return;
920 923
921 // grab details from dialog 924 // grab details from dialog
922// QString package = dlg.getPackageLocation(); 925// QString package = dlg.getPackageLocation();
923 926
924 InstallData *item = new InstallData(); 927 InstallData *item = new InstallData();
925 item->option = "I"; 928 item->option = "I";
926 item->packageName = package; 929 item->packageName = package;
927 QList<InstallData> workingPackages; 930 QList<InstallData> workingPackages;
928 workingPackages.setAutoDelete( TRUE ); 931 workingPackages.setAutoDelete( TRUE );
929 workingPackages.append( item ); 932 workingPackages.append( item );
930 933
931 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); 934 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) );
932 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 935 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
933 reloadDocuments = TRUE; 936 reloadDocuments = TRUE;
934 stack->addWidget( dlg, 3 ); 937 stack->addWidget( dlg, 3 );
935 stack->raiseWidget( dlg ); 938 stack->raiseWidget( dlg );
936} 939}
937 940
938 941
939void MainWindow :: applyChanges() 942void MainWindow :: applyChanges()
940{ 943{
941 stickyOption = ""; 944 stickyOption = "";
942 945
943 // First, write out ipkg_conf file so that ipkg can use it 946 // First, write out ipkg_conf file so that ipkg can use it
944 mgr->writeOutIpkgConf(); 947 mgr->writeOutIpkgConf();
945 948
946 // Now for each selected item 949 // Now for each selected item
947 // deal with it 950 // deal with it
948 951
949 QList<InstallData> workingPackages; 952 QList<InstallData> workingPackages;
950 workingPackages.setAutoDelete( TRUE ); 953 workingPackages.setAutoDelete( TRUE );
951 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 954 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
952 item != 0 ; 955 item != 0 ;
953 item = (QCheckListItem *)item->nextSibling() ) 956 item = (QCheckListItem *)item->nextSibling() )
954 { 957 {
955 if ( item->isOn() ) 958 if ( item->isOn() )
956 { 959 {
957 workingPackages.append( dealWithItem( item ) ); 960 workingPackages.append( dealWithItem( item ) );
958 } 961 }
959 } 962 }
960 963
961 if ( workingPackages.count() == 0 ) 964 if ( workingPackages.count() == 0 )
962 { 965 {
963 // Nothing to do 966 // Nothing to do
964 QMessageBox::information( this, tr( "Nothing to do" ), 967 QMessageBox::information( this, tr( "Nothing to do" ),
965 tr( "No packages selected" ), tr( "OK" ) ); 968 tr( "No packages selected" ), tr( "OK" ) );
966 969
967 return; 970 return;
968 } 971 }
969 972
970 // do the stuff 973 // do the stuff
971 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); 974 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) );
972 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 975 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
973 reloadDocuments = TRUE; 976 reloadDocuments = TRUE;
974 stack->addWidget( dlg, 3 ); 977 stack->addWidget( dlg, 3 );
975 stack->raiseWidget( dlg ); 978 stack->raiseWidget( dlg );
976} 979}
977 980
978// decide what to do - either remove, upgrade or install 981// decide what to do - either remove, upgrade or install
979// Current rules: 982// Current rules:
980// If not installed - install 983// If not installed - install
981// If installed and different version available - upgrade 984// If installed and different version available - upgrade
982// If installed and version up to date - remove 985// If installed and version up to date - remove
983InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) 986InstallData *MainWindow :: dealWithItem( QCheckListItem *item )
984{ 987{
985 QString name = item->text(); 988 QString name = item->text();
986 989
987 // Get package 990 // Get package
988 Server *s = mgr->getServer( serversList->currentText() ); 991 Server *s = mgr->getServer( serversList->currentText() );
989 Package *p = s->getPackage( name ); 992 Package *p = s->getPackage( name );
990 993
991 // If the package has a filename then it is a local file 994 // If the package has a filename then it is a local file
992 if ( p->isPackageStoredLocally() ) 995 if ( p->isPackageStoredLocally() )
993 name = p->getFilename(); 996 name = p->getFilename();
994 997
995 QString option; 998 QString option;
996 QString dest = "root"; 999 QString dest = "root";
997 if ( !p->isInstalled() ) 1000 if ( !p->isInstalled() )
998 { 1001 {
999 InstallData *newitem = new InstallData(); 1002 InstallData *newitem = new InstallData();
1000 newitem->option = "I"; 1003 newitem->option = "I";
1001 newitem->packageName = name; 1004 newitem->packageName = name;
1002 return newitem; 1005 return newitem;
1003 } 1006 }
1004 else 1007 else
1005 { 1008 {
1006 InstallData *newitem = new InstallData(); 1009 InstallData *newitem = new InstallData();
1007 newitem->option = "D"; 1010 newitem->option = "D";
1008 if ( !p->isPackageStoredLocally() ) 1011 if ( !p->isPackageStoredLocally() )
1009 newitem->packageName = p->getInstalledPackageName(); 1012 newitem->packageName = p->getInstalledPackageName();
1010 else 1013 else
1011 newitem->packageName = name; 1014 newitem->packageName = name;
1012 1015
1013 if ( p->getInstalledTo() ) 1016 if ( p->getInstalledTo() )
1014 { 1017 {
1015 newitem->destination = p->getInstalledTo(); 1018 newitem->destination = p->getInstalledTo();
1016// cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl;
1017// cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl;
1018 } 1019 }
1019 else 1020 else
1020 { 1021 {
1021 newitem->destination = p->getLocalPackage()->getInstalledTo(); 1022 newitem->destination = p->getLocalPackage()->getInstalledTo();
1022 } 1023 }
1023 1024
1024 // Now see if version is newer or not 1025 // Now see if version is newer or not
1025 int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); 1026 int val = compareVersions( p->getInstalledVersion(), p->getVersion() );
1026 1027
1027 // If the version requested is older and user selected a local ipk file, then reinstall the file 1028 // If the version requested is older and user selected a local ipk file, then reinstall the file
1028 if ( p->isPackageStoredLocally() && val == -1 ) 1029 if ( p->isPackageStoredLocally() && val == -1 )
1029 val = 0; 1030 val = 0;
1030 1031
1031 if ( val == -2 ) 1032 if ( val == -2 )
1032 { 1033 {
1033 // Error - should handle 1034 // Error - should handle
1034 } 1035 }
1035 else if ( val == -1 ) 1036 else if ( val == -1 )
1036 { 1037 {
1037 // Version available is older - remove only 1038 // Version available is older - remove only
1038 newitem->option = "D"; 1039 newitem->option = "D";
1039 } 1040 }
1040 else 1041 else
1041 { 1042 {
1042 QString caption; 1043 QString caption;
1043 QString text; 1044 QString text;
1044 QString secondButton; 1045 QString secondButton;
1045 QString secondOption; 1046 QString secondOption;
1046 if ( val == 0 ) 1047 if ( val == 0 )
1047 { 1048 {
1048 // Version available is the same - option to remove or reinstall 1049 // Version available is the same - option to remove or reinstall
1049 caption = tr( "Do you wish to remove or reinstall\n%1?" ); 1050 caption = tr( "Do you wish to remove or reinstall\n%1?" );
1050 text = tr( "Remove or ReInstall" ); 1051 text = tr( "Remove or ReInstall" );
1051 secondButton = tr( "ReInstall" ); 1052 secondButton = tr( "ReInstall" );
1052 secondOption = tr( "R" ); 1053 secondOption = tr( "R" );
1053 } 1054 }
1054 else if ( val == 1 ) 1055 else if ( val == 1 )
1055 { 1056 {
1056 // Version available is newer - option to remove or upgrade 1057 // Version available is newer - option to remove or upgrade
1057 caption = tr( "Do you wish to remove or upgrade\n%1?" ); 1058 caption = tr( "Do you wish to remove or upgrade\n%1?" );
1058 text = tr( "Remove or Upgrade" ); 1059 text = tr( "Remove or Upgrade" );
1059 secondButton = tr( "Upgrade" ); 1060 secondButton = tr( "Upgrade" );
1060 secondOption = tr( "U" ); 1061 secondOption = tr( "U" );
1061 } 1062 }
1062 1063
1063 // Sticky option not implemented yet, but will eventually allow 1064 // Sticky option not implemented yet, but will eventually allow
1064 // the user to say something like 'remove all' 1065 // the user to say something like 'remove all'
1065 if ( stickyOption == "" ) 1066 if ( stickyOption == "" )
1066 { 1067 {
1067 QString msgtext; 1068 QString msgtext;
1068 msgtext = caption.arg( ( const char * )name ); 1069 msgtext = caption.arg( ( const char * )name );
1069 switch( QMessageBox::information( this, text, 1070 switch( QMessageBox::information( this, text,
1070 msgtext, tr( "Remove" ), secondButton ) ) 1071 msgtext, tr( "Remove" ), secondButton ) )
1071 { 1072 {
1072 case 0: // Try again or Enter 1073 case 0: // Try again or Enter
1073 // option 0 = Remove 1074 // option 0 = Remove
1074 newitem->option = "D"; 1075 newitem->option = "D";
1075 break; 1076 break;
1076 case 1: // Quit or Escape 1077 case 1: // Quit or Escape
1077 newitem->option = secondOption; 1078 newitem->option = secondOption;
1078 break; 1079 break;
1079 } 1080 }
1080 } 1081 }
1081 else 1082 else
1082 { 1083 {
1083// newitem->option = stickyOption; 1084// newitem->option = stickyOption;
1084 } 1085 }
1085 } 1086 }
1086 1087
1087 1088
1088 // Check if we are reinstalling the same version 1089 // Check if we are reinstalling the same version
1089 if ( newitem->option != "R" ) 1090 if ( newitem->option != "R" )
1090 newitem->recreateLinks = true; 1091 newitem->recreateLinks = true;
1091 else 1092 else
1092 newitem->recreateLinks = false; 1093 newitem->recreateLinks = false;
1093 1094
1094 // User hit cancel (on dlg - assume remove) 1095 // User hit cancel (on dlg - assume remove)
1095 return newitem; 1096 return newitem;
1096 } 1097 }
1097} 1098}
1098 1099
1099void MainWindow :: reloadData( InstallDlgImpl *dlg ) 1100void MainWindow :: reloadData( InstallDlgImpl *dlg )
1100{ 1101{
1101 stack->raiseWidget( progressWindow ); 1102 stack->raiseWidget( progressWindow );
1102 1103
1103 if ( dlg ) 1104 if ( dlg )
1104 { 1105 {
1105 dlg->close(); 1106 dlg->close();
1106 delete dlg; 1107 delete dlg;
1107 } 1108 }
1108 1109
1109 mgr->reloadServerData(); 1110 mgr->reloadServerData();
1110 serverSelected( -1, FALSE ); 1111 serverSelected( -1, FALSE );
1111 1112
1112#ifdef QWS 1113#ifdef QWS
1113 if ( reloadDocuments ) 1114 if ( reloadDocuments )
1114 { 1115 {
1115 m_status->setText( tr( "Updating Launcher..." ) ); 1116 m_status->setText( tr( "Updating Launcher..." ) );
1116 1117
1117 // Finally let the main system update itself 1118 // Finally let the main system update itself
1118 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 1119 QCopEnvelope e("QPE/System", "linkChanged(QString)");
1119 QString lf = QString::null; 1120 QString lf = QString::null;
1120 e << lf; 1121 e << lf;
1121 } 1122 }
1122#endif 1123#endif
1123 1124
1124 stack->raiseWidget( networkPkgWindow ); 1125 stack->raiseWidget( networkPkgWindow );
1125} 1126}
1126 1127
1127void MainWindow :: letterPushed( QString t ) 1128void MainWindow :: letterPushed( QString t )
1128{ 1129{
1129 QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); 1130 QCheckListItem *top = (QCheckListItem *)packagesList->firstChild();
1130 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); 1131 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
1131 if ( packagesList->firstChild() == 0 ) 1132 if ( packagesList->firstChild() == 0 )
1132 return; 1133 return;
1133 1134
1134 QCheckListItem *item; 1135 QCheckListItem *item;
1135 if ( start == 0 ) 1136 if ( start == 0 )
1136 { 1137 {
1137 item = (QCheckListItem *)packagesList->firstChild(); 1138 item = (QCheckListItem *)packagesList->firstChild();
1138 start = top; 1139 start = top;
1139 } 1140 }
1140 else 1141 else
1141 item = (QCheckListItem *)start->nextSibling(); 1142 item = (QCheckListItem *)start->nextSibling();
1142 1143
1143 if ( item == 0 ) 1144 if ( item == 0 )
1144 item = (QCheckListItem *)packagesList->firstChild(); 1145 item = (QCheckListItem *)packagesList->firstChild();
1145 do 1146 do
1146 { 1147 {
1147 if ( item->text().lower().startsWith( t.lower() ) ) 1148 if ( item->text().lower().startsWith( t.lower() ) )
1148 { 1149 {
1149 packagesList->setSelected( item, true ); 1150 packagesList->setSelected( item, true );
1150 packagesList->ensureItemVisible( item ); 1151 packagesList->ensureItemVisible( item );
1151 break; 1152 break;
1152 } 1153 }
1153 1154
1154 item = (QCheckListItem *)item->nextSibling(); 1155 item = (QCheckListItem *)item->nextSibling();
1155 if ( !item ) 1156 if ( !item )
1156 item = (QCheckListItem *)packagesList->firstChild(); 1157 item = (QCheckListItem *)packagesList->firstChild();
1157 } while ( item != start); 1158 } while ( item != start);
1158} 1159}
1159 1160
1160void MainWindow :: slotDisplayPackage( QListViewItem *item ) 1161void MainWindow :: slotDisplayPackage( QListViewItem *item )
1161{ 1162{
1162 QString itemstr( ((QCheckListItem*)item)->text() ); 1163 QString itemstr( ((QCheckListItem*)item)->text() );
1163 PackageWindow *p = new PackageWindow( mgr->getServer( serversList->currentText() )->getPackage( itemstr ) ); 1164 PackageWindow *p = new PackageWindow( mgr->getServer( serversList->currentText() )->getPackage( itemstr ) );
1164 p->showMaximized(); 1165 p->showMaximized();
1165} 1166}
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,142 +1,154 @@
1/*************************************************************************** 1/*
2 mainwin.h - description 2                This file is part of the OPIE Project
3 ------------------- 3
4 begin : Mon Aug 26 13:32:30 BST 2002 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5 copyright : (C) 2002 by Andy Qua 5             .=l. Dan Williams <drw@handhelds.org>
6 email : andy.qua@blueyonder.co.uk 6           .>+-=
7 ***************************************************************************/ 7 _;:,     .>    :=|. This file is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This file is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
8 27
9/*************************************************************************** 28*/
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17 29
18#ifndef MAINWIN_H 30#ifndef MAINWIN_H
19#define MAINWIN_H 31#define MAINWIN_H
20 32
21#include <qmainwindow.h> 33#include <qmainwindow.h>
22#include <qpixmap.h> 34#include <qpixmap.h>
23 35
24class DataManager; 36class DataManager;
25class InstallData; 37class InstallData;
26class InstallDlgImpl; 38class InstallDlgImpl;
27 39
28class QAction; 40class QAction;
29class QCheckListItem; 41class QCheckListItem;
30class QComboBox; 42class QComboBox;
31class QLabel; 43class QLabel;
32class QLineEdit; 44class QLineEdit;
33class QListView; 45class QListView;
34class QListViewItem; 46class QListViewItem;
35class QToolBar; 47class QToolBar;
36class QProgressBar; 48class QProgressBar;
37class QWidgetStack; 49class QWidgetStack;
38 50
39class MainWindow :public QMainWindow 51class MainWindow :public QMainWindow
40{ 52{
41 Q_OBJECT 53 Q_OBJECT
42public: 54public:
43 55
44 MainWindow(); 56 MainWindow();
45 ~MainWindow(); 57 ~MainWindow();
46 58
47protected: 59protected:
48 void closeEvent( QCloseEvent* e ); 60 void closeEvent( QCloseEvent* e );
49 61
50private: 62private:
51 DataManager *mgr; 63 DataManager *mgr;
52 64
53 QWidgetStack *stack; 65 QWidgetStack *stack;
54 66
55 QToolBar *findBar; 67 QToolBar *findBar;
56 QToolBar *jumpBar; 68 QToolBar *jumpBar;
57 QLineEdit *findEdit; 69 QLineEdit *findEdit;
58 QAction *actionFindNext; 70 QAction *actionFindNext;
59 QAction *actionFilter; 71 QAction *actionFilter;
60 QAction *actionUpgrade; 72 QAction *actionUpgrade;
61 QAction *actionDownload; 73 QAction *actionDownload;
62 QAction *actionUninstalled; 74 QAction *actionUninstalled;
63 QAction *actionInstalled; 75 QAction *actionInstalled;
64 QAction *actionUpdated; 76 QAction *actionUpdated;
65 77
66 QPixmap iconDownload; 78 QPixmap iconDownload;
67 QPixmap iconRemove; 79 QPixmap iconRemove;
68 80
69 int mnuShowUninstalledPkgsId; 81 int mnuShowUninstalledPkgsId;
70 int mnuShowInstalledPkgsId; 82 int mnuShowInstalledPkgsId;
71 int mnuShowUpgradedPkgsId; 83 int mnuShowUpgradedPkgsId;
72 int mnuFilterByCategory; 84 int mnuFilterByCategory;
73 int mnuSetFilterCategory; 85 int mnuSetFilterCategory;
74 86
75 // Main package list widget 87 // Main package list widget
76 QWidget *networkPkgWindow; 88 QWidget *networkPkgWindow;
77 QComboBox *serversList; 89 QComboBox *serversList;
78 QListView *packagesList; 90 QListView *packagesList;
79 QPixmap installedIcon; 91 QPixmap installedIcon;
80 QPixmap updatedIcon; 92 QPixmap updatedIcon;
81 QString currentlySelectedServer; 93 QString currentlySelectedServer;
82 QString categoryFilter; 94 QString categoryFilter;
83 QString stickyOption; 95 QString stickyOption;
84 96
85 bool categoryFilterEnabled; 97 bool categoryFilterEnabled;
86 bool showJumpTo; 98 bool showJumpTo;
87 bool showUninstalledPkgs; 99 bool showUninstalledPkgs;
88 bool showInstalledPkgs; 100 bool showInstalledPkgs;
89 bool showUpgradedPkgs; 101 bool showUpgradedPkgs;
90 bool downloadEnabled; 102 bool downloadEnabled;
91 bool reloadDocuments; 103 bool reloadDocuments;
92 104
93 void initMainWidget(); 105 void initMainWidget();
94 void updateData(); 106 void updateData();
95 void serverSelected( int index, bool showProgress ); 107 void serverSelected( int index, bool showProgress );
96 void searchForPackage( const QString & ); 108 void searchForPackage( const QString & );
97 bool filterByCategory( bool val ); 109 bool filterByCategory( bool val );
98 void downloadSelectedPackages(); 110 void downloadSelectedPackages();
99 void downloadRemotePackage(); 111 void downloadRemotePackage();
100 InstallData *dealWithItem( QCheckListItem *item ); 112 InstallData *dealWithItem( QCheckListItem *item );
101 113
102 // Progress widget 114 // Progress widget
103 QWidget *progressWindow; 115 QWidget *progressWindow;
104 QLabel *m_status; 116 QLabel *m_status;
105 QProgressBar *m_progress; 117 QProgressBar *m_progress;
106 118
107 void initProgressWidget(); 119 void initProgressWidget();
108 120
109public slots: 121public slots:
110 void setDocument( const QString &doc ); 122 void setDocument( const QString &doc );
111 void displayFindBar(); 123 void displayFindBar();
112 void displayJumpBar(); 124 void displayJumpBar();
113 void repeatFind(); 125 void repeatFind();
114 void findPackage( const QString & ); 126 void findPackage( const QString & );
115 void hideFindBar(); 127 void hideFindBar();
116 void hideJumpBar(); 128 void hideJumpBar();
117 void displaySettings(); 129 void displaySettings();
118 void filterUninstalledPackages(); 130 void filterUninstalledPackages();
119 void filterInstalledPackages(); 131 void filterInstalledPackages();
120 void filterUpgradedPackages(); 132 void filterUpgradedPackages();
121 void filterCategory(); 133 void filterCategory();
122 bool setFilterCategory(); 134 bool setFilterCategory();
123 void raiseMainWidget(); 135 void raiseMainWidget();
124 void raiseProgressWidget(); 136 void raiseProgressWidget();
125 void enableUpgrade( bool ); 137 void enableUpgrade( bool );
126 void enableDownload( bool ); 138 void enableDownload( bool );
127 void reloadData( InstallDlgImpl * ); 139 void reloadData( InstallDlgImpl * );
128 140
129private slots: 141private slots:
130 void init(); 142 void init();
131 void setProgressSteps( int ); 143 void setProgressSteps( int );
132 void setProgressMessage( const QString & ); 144 void setProgressMessage( const QString & );
133 void updateProgress( int ); 145 void updateProgress( int );
134 void serverSelected( int index ); 146 void serverSelected( int index );
135 void updateServer(); 147 void updateServer();
136 void upgradePackages(); 148 void upgradePackages();
137 void downloadPackage(); 149 void downloadPackage();
138 void applyChanges(); 150 void applyChanges();
139 void letterPushed( QString t ); 151 void letterPushed( QString t );
140 void slotDisplayPackage( QListViewItem * ); 152 void slotDisplayPackage( QListViewItem * );
141}; 153};
142#endif 154#endif
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 @@
1/*************************************************************************** 1/*
2 mem.h - description 2                This file is part of the OPIE Project
3 ------------------- 3
4 begin : Mon Aug 26 2002 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5 copyright : (C) 2002 by Andy Qua 5             .=l. Dan Williams <drw@handhelds.org>
6 email : andy.qua@blueyonder.co.uk 6           .>+-=
7 ***************************************************************************/ 7 _;:,     .>    :=|. This file is free software; you can
8 8.> <`_,   >  .   <= redistribute it and/or modify it under
9/*************************************************************************** 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10 * * 10.="- .-=="i,     .._ License as published by the Free Software
11 * This program is free software; you can redistribute it and/or modify * 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12 * it under the terms of the GNU General Public License as published by * 12     ._= =}       : or (at your option) any later version.
13 * the Free Software Foundation; either version 2 of the License, or * 13    .%`+i>       _;_.
14 * (at your option) any later version. * 14    .i_,=:_.      -<s. This file is distributed in the hope that
15 * * 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16 ***************************************************************************/ 16    : ..    .:,     . . . without even the implied warranty of
17#include <stdio.h> 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18#include <fstream> 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19#include <iostream> 19..}^=.=       =       ; Public License for more details.
20#include <list> 20++=   -.     .`     .:
21using namespace std; 21 :     =  ...= . :.=- You should have received a copy of the GNU
22 22 -.   .:....=;==+<; General Public License along with this file;
23#define __MEMFILE_C 23  -_. . .   )=.  = see the file COPYING. If not, write to the
24#include "global.h" 24    --        :-=` Free Software Foundation, Inc.,
25 25 59 Temple Place - Suite 330,
26#ifdef _DEBUG 26 Boston, MA 02111-1307, USA.
27 27
28void __cdecl *operator new( unsigned int size, const char *file, int line ) 28*/
29{ 29
30 void *ptr = (void *)malloc(size); 30#include <stdio.h>
31 AddTrack((long)ptr, size, file, line); 31#include <list>
32 return(ptr); 32using namespace std;
33} 33
34 34#define __MEMFILE_C
35void operator delete(void *p) 35#include "global.h"
36{ 36
37 RemoveTrack((long)p); 37#ifdef _DEBUG
38 free(p); 38
39} 39void __cdecl *operator new( unsigned int size, const char *file, int line )
40 40{
41#endif 41 void *ptr = (void *)malloc(size);
42 42 AddTrack((long)ptr, size, file, line);
43 43 return(ptr);
44typedef struct { 44}
45 longaddress; 45
46 longsize; 46void operator delete(void *p)
47 charfile[64]; 47{
48 longline; 48 RemoveTrack((long)p);
49} ALLOC_INFO; 49 free(p);
50 50}
51typedef list<ALLOC_INFO*> AllocList; 51
52 52#endif
53AllocList allocList; 53
54 54
55 55typedef struct {
56 56 longaddress;
57void AddTrack(long addr, long asize, const char *fname, long lnum) 57 longsize;
58{ 58 charfile[64];
59 ALLOC_INFO *info; 59 longline;
60 60} ALLOC_INFO;
61 61
62 info = (ALLOC_INFO *)malloc(sizeof( ALLOC_INFO )); 62typedef list<ALLOC_INFO*> AllocList;
63 info->address = addr; 63
64 strncpy(info->file, fname, 63); 64AllocList allocList;
65 info->line = lnum; 65
66 info->size = asize; 66
67 allocList.insert(allocList.begin(), info); 67
68}; 68void AddTrack(long addr, long asize, const char *fname, long lnum)
69 69{
70void RemoveTrack(long addr) 70 ALLOC_INFO *info;
71{ 71
72 AllocList::iterator i; 72
73 73 info = (ALLOC_INFO *)malloc(sizeof( ALLOC_INFO ));
74 bool found = false; 74 info->address = addr;
75 for(i = allocList.begin(); i != allocList.end(); i++) 75 strncpy(info->file, fname, 63);
76 { 76 info->line = lnum;
77 if((*i)->address == addr) 77 info->size = asize;
78 { 78 allocList.insert(allocList.begin(), info);
79 allocList.remove((*i)); 79};
80 found = true; 80
81 break; 81void RemoveTrack(long addr)
82 } 82{
83 } 83 AllocList::iterator i;
84} 84
85 85 bool found = false;
86void DumpUnfreed() 86 for(i = allocList.begin(); i != allocList.end(); i++)
87{ 87 {
88 AllocList::iterator i; 88 if((*i)->address == addr)
89 long totalSize = 0; 89 {
90 char buf[1024]; 90 allocList.remove((*i));
91 91 found = true;
92 92 break;
93// if(!allocList) 93 }
94 // return; 94 }
95 95}
96 for(i = allocList.begin(); i != allocList.end(); i++) { 96
97 sprintf(buf, "%-15s: LINE %ld, ADDRESS %ld %ld unfreed", 97void DumpUnfreed()
98 (*i)->file, (*i)->line, (*i)->address, (*i)->size); 98{
99 cout <<buf << endl; 99 AllocList::iterator i;
100 totalSize += (*i)->size; 100 long totalSize = 0;
101 } 101 char buf[1024];
102 sprintf(buf, "-----------------------------------------------------------\n"); 102
103 cout <<buf << endl; 103 for(i = allocList.begin(); i != allocList.end(); i++) {
104 sprintf(buf, "Total Unfreed: %ld bytes\n", totalSize); 104 sprintf(buf, "%-15s: LINE %ld, ADDRESS %ld %ld unfreed",
105 cout <<buf << endl; 105 (*i)->file, (*i)->line, (*i)->address, (*i)->size);
106}; 106 totalSize += (*i)->size;
107 }
108 sprintf(buf, "-----------------------------------------------------------\n");
109 sprintf(buf, "Total Unfreed: %ld bytes\n", totalSize);
110};
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,145 +1,157 @@
1/*************************************************************************** 1/*
2 package.cpp - description 2                This file is part of the OPIE Project
3 ------------------- 3
4 begin : Mon Aug 26 2002 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5 copyright : (C) 2002 by Andy Qua 5             .=l. Dan Williams <drw@handhelds.org>
6 email : andy.qua@blueyonder.co.uk 6           .>+-=
7 ***************************************************************************/ 7 _;:,     .>    :=|. This file is free software; you can
8 8.> <`_,   >  .   <= redistribute it and/or modify it under
9/*************************************************************************** 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10 * * 10.="- .-=="i,     .._ License as published by the Free Software
11 * This program is free software; you can redistribute it and/or modify * 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12 * it under the terms of the GNU General Public License as published by * 12     ._= =}       : or (at your option) any later version.
13 * the Free Software Foundation; either version 2 of the License, or * 13    .%`+i>       _;_.
14 * (at your option) any later version. * 14    .i_,=:_.      -<s. This file is distributed in the hope that
15 * * 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16 ***************************************************************************/ 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
17 29
18#include "package.h" 30#include "package.h"
19#include "global.h" 31#include "global.h"
20 32
21Package::Package( QString &name ) 33Package::Package( QString &name )
22{ 34{
23 packageName = name; 35 packageName = name;
24 36
25 version = "N/A"; 37 version = "N/A";
26 description = "N/A"; 38 description = "N/A";
27 packageSize = "N/A"; 39 packageSize = "N/A";
28 section = "N/A"; 40 section = "N/A";
29 41
30 localPackage = 0; 42 localPackage = 0;
31 installed = false; 43 installed = false;
32 packageStoredLocally = false; 44 packageStoredLocally = false;
33 installedToRoot = false; 45 installedToRoot = false;
34 installed = false; 46 installed = false;
35 installedTo = 0; 47 installedTo = 0;
36} 48}
37 49
38Package::Package( char *name ) 50Package::Package( char *name )
39{ 51{
40 packageName = name; 52 packageName = name;
41 53
42 version = "N/A"; 54 version = "N/A";
43 description = "N/A"; 55 description = "N/A";
44 packageSize = "N/A"; 56 packageSize = "N/A";
45 section = "N/A"; 57 section = "N/A";
46 58
47 localPackage = 0; 59 localPackage = 0;
48 installed = false; 60 installed = false;
49 packageStoredLocally = false; 61 packageStoredLocally = false;
50 installedToRoot = false; 62 installedToRoot = false;
51 installed = false; 63 installed = false;
52 installedTo = 0; 64 installedTo = 0;
53 differentVersionAvailable = false; 65 differentVersionAvailable = false;
54} 66}
55 67
56Package::~Package() 68Package::~Package()
57{ 69{
58} 70}
59 71
60QString Package :: toString() 72QString Package :: toString()
61{ 73{
62 QString ret = "Package - " + getPackageName() + 74 QString ret = "Package - " + getPackageName() +
63 "\n version - " + getVersion(); 75 "\n version - " + getVersion();
64 76
65 if ( localPackage ) 77 if ( localPackage )
66 ret += "\n inst version - " + localPackage->getVersion(); 78 ret += "\n inst version - " + localPackage->getVersion();
67 79
68 80
69 return ret; 81 return ret;
70} 82}
71 83
72void Package :: setStatus( const QString &s ) 84void Package :: setStatus( const QString &s )
73{ 85{
74 QString state_status; 86 QString state_status;
75 int two, three; 87 int two, three;
76 88
77 status = s.simplifyWhiteSpace( ); 89 status = s.simplifyWhiteSpace( );
78 90
79 two = status.find( " " ); // find second column 91 two = status.find( " " ); // find second column
80 three = status.find( " ", two + 1 ); // find third column 92 three = status.find( " ", two + 1 ); // find third column
81 93
82 state_status = status.mid( three ).stripWhiteSpace( ); 94 state_status = status.mid( three ).stripWhiteSpace( );
83 95
84 if ( state_status == "installed" ) 96 if ( state_status == "installed" )
85 installed = true; 97 installed = true;
86} 98}
87 99
88void Package :: setLocalPackage( Package *p ) 100void Package :: setLocalPackage( Package *p )
89{ 101{
90 localPackage = p; 102 localPackage = p;
91 103
92 if ( localPackage ) 104 if ( localPackage )
93 if ( localPackage->getVersion() < getVersion() && !installed ) 105 if ( localPackage->getVersion() < getVersion() && !installed )
94 differentVersionAvailable = true; 106 differentVersionAvailable = true;
95 else 107 else
96 differentVersionAvailable = false; 108 differentVersionAvailable = false;
97} 109}
98 110
99void Package :: setVersion( const QString &v ) 111void Package :: setVersion( const QString &v )
100{ 112{
101 version = v; 113 version = v;
102 114
103 if ( localPackage ) 115 if ( localPackage )
104 if ( localPackage->getVersion() < getVersion() && !installed ) 116 if ( localPackage->getVersion() < getVersion() && !installed )
105 differentVersionAvailable = true; 117 differentVersionAvailable = true;
106 else 118 else
107 differentVersionAvailable = false; 119 differentVersionAvailable = false;
108} 120}
109 121
110void Package :: setPackageName( const QString &name ) 122void Package :: setPackageName( const QString &name )
111{ 123{
112 packageName = name; 124 packageName = name;
113} 125}
114 126
115void Package :: setDescription( const QString &d ) 127void Package :: setDescription( const QString &d )
116{ 128{
117 description = d; 129 description = d;
118} 130}
119 131
120void Package :: setFilename( const QString &f ) 132void Package :: setFilename( const QString &f )
121{ 133{
122 filename = f; 134 filename = f;
123} 135}
124 136
125 137
126QString Package :: getInstalledVersion() 138QString Package :: getInstalledVersion()
127{ 139{
128 if ( localPackage ) 140 if ( localPackage )
129 return localPackage->getVersion(); 141 return localPackage->getVersion();
130 else 142 else
131 return getVersion(); 143 return getVersion();
132} 144}
133 145
134QString Package :: getInstalledPackageName() 146QString Package :: getInstalledPackageName()
135{ 147{
136 if ( localPackage ) 148 if ( localPackage )
137 return localPackage->getPackageName(); 149 return localPackage->getPackageName();
138 else 150 else
139 return getPackageName(); 151 return getPackageName();
140} 152}
141 153
142bool Package :: isInstalled() 154bool Package :: isInstalled()
143{ 155{
144 return installed || ( localPackage && localPackage->isInstalled() ); 156 return installed || ( localPackage && localPackage->isInstalled() );
145} 157}
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 @@
1/*************************************************************************** 1/*
2 package.h - description 2                This file is part of the OPIE Project
3 ------------------- 3
4 begin : Mon Aug 26 2002 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5 copyright : (C) 2002 by Andy Qua 5             .=l. Dan Williams <drw@handhelds.org>
6 email : andy.qua@blueyonder.co.uk 6           .>+-=
7 ***************************************************************************/ 7 _;:,     .>    :=|. This file is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This file is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
8 27
9/*************************************************************************** 28*/
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17 29
18#ifndef PACKAGE_H 30#ifndef PACKAGE_H
19#define PACKAGE_H 31#define PACKAGE_H
20 32
21#include <stdlib.h> 33#include <stdlib.h>
22 34
23/** 35/**
24 *@author Andy Qua 36 *@author Andy Qua
25 */ 37 */
26 38
27#include <qstring.h> 39#include <qstring.h>
28#include "destination.h" 40#include "destination.h"
29 41
30class Package 42class Package
31{ 43{
32public: 44public:
33 Package( QString &name ); 45 Package( QString &name );
34 Package( char *name ); 46 Package( char *name );
35 ~Package(); 47 ~Package();
36 48
37 void setLocalPackage( Package *p ); 49 void setLocalPackage( Package *p );
38 void setPackageName( const QString &name ); 50 void setPackageName( const QString &name );
39 void setVersion( const QString &v ); 51 void setVersion( const QString &v );
40 void setStatus( const QString &s ); 52 void setStatus( const QString &s );
41 void setDescription( const QString &d ); 53 void setDescription( const QString &d );
42 void setFilename( const QString &f ); 54 void setFilename( const QString &f );
43 void setPackageStoredLocally( bool local ){ packageStoredLocally = local; } 55 void setPackageStoredLocally( bool local ){ packageStoredLocally = local; }
44 void setInstalledToRoot( bool root ) { installedToRoot = root; } 56 void setInstalledToRoot( bool root ) { installedToRoot = root; }
45 void setInstalledTo( Destination *d ) { installedTo = d; } 57 void setInstalledTo( Destination *d ) { installedTo = d; }
46 void setDependancies( QString &deps ) { dependancies = deps; } 58 void setDependancies( QString &deps ) { dependancies = deps; }
47 void setPackageSize( const QString &size ) { packageSize = size; } 59 void setPackageSize( const QString &size ) { packageSize = size; }
48 void setSection( const QString &sect) { section = sect; } 60 void setSection( const QString &sect) { section = sect; }
49 61
50 Package *getLocalPackage() { return localPackage; } 62 Package *getLocalPackage() { return localPackage; }
51 QString getPackageName() { return packageName; } 63 QString getPackageName() { return packageName; }
52 QString getVersion() { return version; } 64 QString getVersion() { return version; }
53 QString getStatus() { return status; } 65 QString getStatus() { return status; }
54 QString getDescription() { return description; } 66 QString getDescription() { return description; }
55 QString getFilename() { return filename; } 67 QString getFilename() { return filename; }
56 QString getDependancies() { return dependancies; } 68 QString getDependancies() { return dependancies; }
57 QString getPackageSize() { return packageSize; } 69 QString getPackageSize() { return packageSize; }
58 QString getSection() { return section; } 70 QString getSection() { return section; }
59 bool getNewVersionAvailable() { return differentVersionAvailable; } 71 bool getNewVersionAvailable() { return differentVersionAvailable; }
60 72
61 bool isInstalled(); 73 bool isInstalled();
62 bool isPackageStoredLocally(){ return packageStoredLocally; } 74 bool isPackageStoredLocally(){ return packageStoredLocally; }
63 bool isInstalledToRoot() { return installedToRoot; } 75 bool isInstalledToRoot() { return installedToRoot; }
64 QString getInstalledVersion(); 76 QString getInstalledVersion();
65 QString getInstalledPackageName(); 77 QString getInstalledPackageName();
66 Destination *getInstalledTo() { return installedTo; } 78 Destination *getInstalledTo() { return installedTo; }
67 79
68 QString toString(); 80 QString toString();
69 81
70 82
71private: 83private:
72 Package *localPackage; 84 Package *localPackage;
73 85
74 QString packageName; 86 QString packageName;
75 QString version; 87 QString version;
76 QString status; 88 QString status;
77 QString description; 89 QString description;
78 QString filename; 90 QString filename;
79 bool packageStoredLocally; 91 bool packageStoredLocally;
80 bool installedToRoot; 92 bool installedToRoot;
81 bool installed; 93 bool installed;
82 bool differentVersionAvailable; 94 bool differentVersionAvailable;
83 QString dependancies; 95 QString dependancies;
84 QString packageSize; 96 QString packageSize;
85 QString section; 97 QString section;
86 98
87 Destination *installedTo; 99 Destination *installedTo;
88}; 100};
89 101
90#endif 102#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 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 =. 3
4             .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5             .=l. Dan Williams <drw@handhelds.org>
5           .>+-= 6           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 7 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 13    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 14    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 19..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 20++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 21 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 22 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 23  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 24    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 25 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
26 27
27*/ 28*/
28 29
29#include "packagewin.h" 30#include "packagewin.h"
30#include "package.h" 31#include "package.h"
31#include "datamgr.h" 32#include "datamgr.h"
32 33
33#include <qpe/resource.h> 34#include <qpe/resource.h>
34 35
35#include <qlayout.h> 36#include <qlayout.h>
36#include <qpushbutton.h> 37#include <qpushbutton.h>
37#include <qstring.h> 38#include <qstring.h>
38#include <qtextview.h> 39#include <qtextview.h>
39 40
40PackageWindow::PackageWindow( Package *package, const QString &server ) 41PackageWindow::PackageWindow( Package *package, const QString &server )
41 : QWidget( 0, 0, 0 ) 42 : QWidget( 0, 0, 0 )
42{ 43{
43 QString str; 44 QString str;
44 if ( package ) 45 if ( package )
45 { 46 {
46 setCaption( package->getPackageName() ); 47 setCaption( package->getPackageName() );
47 QString destName; 48 QString destName;
48 if ( package->getLocalPackage() ) 49 if ( package->getLocalPackage() )
49 { 50 {
50 if ( package->getLocalPackage()->getInstalledTo() ) 51 if ( package->getLocalPackage()->getInstalledTo() )
51 destName = package->getLocalPackage()->getInstalledTo()->getDestinationName(); 52 destName = package->getLocalPackage()->getInstalledTo()->getDestinationName();
52 } 53 }
53 else 54 else
54 { 55 {
55 if ( package->getInstalledTo() ) 56 if ( package->getInstalledTo() )
56 destName = package->getInstalledTo()->getDestinationName(); 57 destName = package->getInstalledTo()->getDestinationName();
57 } 58 }
58 59
59 if ( !package->isPackageStoredLocally() ) 60 if ( !package->isPackageStoredLocally() )
60 { 61 {
61 str.append( tr( "<b>Description</b> - " ) ); 62 str.append( tr( "<b>Description</b> - " ) );
62 str.append( package->getDescription() ); 63 str.append( package->getDescription() );
63 if ( !destName.isNull() ) 64 if ( !destName.isNull() )
64 { 65 {
65 str.append( tr( "<p><b>Installed To</b> - " ) ); 66 str.append( tr( "<p><b>Installed To</b> - " ) );
66 str.append( destName ); 67 str.append( destName );
67 } 68 }
68 str.append( tr( "<p><b>Size</b> - " ) ); 69 str.append( tr( "<p><b>Size</b> - " ) );
69 str.append( package->getPackageSize() ); 70 str.append( package->getPackageSize() );
70 str.append( tr( "<p><b>Section</b> - " ) ); 71 str.append( tr( "<p><b>Section</b> - " ) );
71 str.append( package->getSection() ); 72 str.append( package->getSection() );
72 } 73 }
73 else 74 else
74 { 75 {
75 str.append( tr( "<p><b>Filename</b> - " ) ); 76 str.append( tr( "<p><b>Filename</b> - " ) );
76 str.append( package->getFilename() ); 77 str.append( package->getFilename() );
77 } 78 }
78 79
79 if ( server == LOCAL_SERVER ) 80 if ( server == LOCAL_SERVER )
80 { 81 {
81 str.append( tr( "<p><b>Version Installed</b> - " ) ); 82 str.append( tr( "<p><b>Version Installed</b> - " ) );
82 str.append( package->getVersion() ); 83 str.append( package->getVersion() );
83 } 84 }
84 else 85 else
85 { 86 {
86 str.append( tr( "<p><b>Version Available</b> - " ) ); 87 str.append( tr( "<p><b>Version Available</b> - " ) );
87 str.append( package->getVersion() ); 88 str.append( package->getVersion() );
88 if ( package->getLocalPackage() ) 89 if ( package->getLocalPackage() )
89 { 90 {
90 if ( package->isInstalled() ) 91 if ( package->isInstalled() )
91 { 92 {
92 str.append( tr( "<p><b>Version Installed</b> - " ) ); 93 str.append( tr( "<p><b>Version Installed</b> - " ) );
93 str.append( package->getInstalledVersion() ); 94 str.append( package->getInstalledVersion() );
94 } 95 }
95 } 96 }
96 } 97 }
97 } 98 }
98 else 99 else
99 { 100 {
100 setCaption( tr( "Package Information" ) ); 101 setCaption( tr( "Package Information" ) );
101 str = tr( "Package information is unavailable" ); 102 str = tr( "Package information is unavailable" );
102 } 103 }
103 104
104 QVBoxLayout *layout = new QVBoxLayout( this, 4, 4 ); 105 QVBoxLayout *layout = new QVBoxLayout( this, 4, 4 );
105 106
106 QTextView *l = new QTextView( str, QString::null, this ); 107 QTextView *l = new QTextView( str, QString::null, this );
107 //l->setTextFormat( Qt::RichText );
108 //l->setAlignment( Qt::AlignLeft | Qt::AlignVCenter | Qt::WordBreak );
109 layout->addWidget( l ); 108 layout->addWidget( l );
110 109
111 QPushButton *btn = new QPushButton( Resource::loadPixmap( "enter" ), tr( "Close" ), this ); 110 QPushButton *btn = new QPushButton( Resource::loadPixmap( "enter" ), tr( "Close" ), this );
112 layout->addWidget( btn ); 111 layout->addWidget( btn );
113 connect( btn, SIGNAL( clicked() ), this, SLOT( close() ) ); 112 connect( btn, SIGNAL( clicked() ), this, SLOT( close() ) );
114 113
115} 114}
116 115
117PackageWindow::~PackageWindow() 116PackageWindow::~PackageWindow()
118{ 117{
119} 118}
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 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 =. 3
4             .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5             .=l. Dan Williams <drw@handhelds.org>
5           .>+-= 6           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 7 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 13    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 14    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 19..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 20++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 21 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 22 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 23  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 24    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 25 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
26 27
27*/ 28*/
28 29
29#ifndef PACKAGEWIN_H 30#ifndef PACKAGEWIN_H
30#define PACKAGEWIN_H 31#define PACKAGEWIN_H
31 32
32#include <qwidget.h> 33#include <qwidget.h>
33 34
34class Package; 35class Package;
35 36
36class PackageWindow :public QWidget 37class PackageWindow :public QWidget
37{ 38{
38 Q_OBJECT 39 Q_OBJECT
39 40
40public: 41public:
41 PackageWindow( Package * = 0x0, const QString & = QString::null ); 42 PackageWindow( Package * = 0x0, const QString & = QString::null );
42 ~PackageWindow(); 43 ~PackageWindow();
43}; 44};
44 45
45#endif 46#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,307 +1,315 @@
1/*************************************************************************** 1/*
2 server.cpp - description 2                This file is part of the OPIE Project
3 ------------------- 3
4 begin : Mon Aug 26 2002 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5 copyright : (C) 2002 by Andy Qua 5             .=l. Dan Williams <drw@handhelds.org>
6 email : andy.qua@blueyonder.co.uk 6           .>+-=
7 description : This class holds details about a server 7 _;:,     .>    :=|. This file is free software; you can
8 : e.g. all the packages that contained on the server 8.> <`_,   >  .   <= redistribute it and/or modify it under
9 : the installation status 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10 ***************************************************************************/ 10.="- .-=="i,     .._ License as published by the Free Software
11 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12/*************************************************************************** 12     ._= =}       : or (at your option) any later version.
13 * * 13    .%`+i>       _;_.
14 * This program is free software; you can redistribute it and/or modify * 14    .i_,=:_.      -<s. This file is distributed in the hope that
15 * it under the terms of the GNU General Public License as published by * 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16 * the Free Software Foundation; either version 2 of the License, or * 16    : ..    .:,     . . . without even the implied warranty of
17 * (at your option) any later version. * 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18 * * 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19 ***************************************************************************/ 19..}^=.=       =       ; Public License for more details.
20 20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
21 29
22#include "server.h" 30#include "server.h"
23#include "datamgr.h" 31#include "datamgr.h"
24 32
25#include <qfile.h> 33#include <qfile.h>
26#include <qtextstream.h> 34#include <qtextstream.h>
27 35
28#ifdef QWS 36#ifdef QWS
29#include <qpe/global.h> 37#include <qpe/global.h>
30#include <qpe/applnk.h> 38#include <qpe/applnk.h>
31#include <qlist.h> 39#include <qlist.h>
32#endif 40#endif
33 41
34#include "utils.h" 42#include "utils.h"
35 43
36#include "global.h" 44#include "global.h"
37 45
38Server :: Server( const char *name, const char *url ) 46Server :: Server( const char *name, const char *url )
39{ 47{
40 serverName = name; 48 serverName = name;
41 serverUrl = url; 49 serverUrl = url;
42 packageFile = IPKG_DIR; 50 packageFile = IPKG_DIR;
43 active = true; 51 active = true;
44 packageFile += "lists/" + serverName; 52 packageFile.append( "lists/" );
53 packageFile.append( serverName );
45} 54}
46 55
47Server :: ~Server() 56Server :: ~Server()
48{ 57{
49 cleanUp(); 58 cleanUp();
50} 59}
51 60
52void Server :: cleanUp() 61void Server :: cleanUp()
53{ 62{
54 packageList.clear(); 63 packageList.clear();
55} 64}
56 65
57void Server :: readStatusFile( QList<Destination> &destList ) 66void Server :: readStatusFile( QList<Destination> &destList )
58{ 67{
59 cleanUp(); 68 cleanUp();
60 69
61 Destination *dest; 70 Destination *dest;
62 QListIterator<Destination> dit( destList ); 71 QListIterator<Destination> dit( destList );
63 bool rootRead = false; 72 bool rootRead = false;
64 for ( ; dit.current(); ++dit ) 73 for ( ; dit.current(); ++dit )
65 { 74 {
66 dest = dit.current(); 75 dest = dit.current();
67 bool installingToRoot = false; 76 bool installingToRoot = false;
68 77
69 QString path = dest->getDestinationPath(); 78 QString path = dest->getDestinationPath();
70 if ( path.right( 1 ) != "/" ) 79 if ( path.right( 1 ) != "/" )
71 path.append( "/" ); 80 path.append( "/" );
72 81
73 if ( path == "/" ) 82 if ( path == "/" )
74 { 83 {
75 rootRead = true; 84 rootRead = true;
76 installingToRoot = true; 85 installingToRoot = true;
77 } 86 }
78 87
79 packageFile = path; 88 packageFile = path;
80 packageFile.append( "usr/lib/ipkg/status" ); 89 packageFile.append( "usr/lib/ipkg/status" );
81 readPackageFile( 0, false, installingToRoot, &( *dest ) ); 90 readPackageFile( 0, false, installingToRoot, &( *dest ) );
82 } 91 }
83 92
84 // Ensure that the root status file is read 93 // Ensure that the root status file is read
85 if ( !rootRead ) 94 if ( !rootRead )
86 { 95 {
87 //cout << "Reading status file " << "/usr/lib/ipkg/status" << endl;
88 packageFile = "/usr/lib/ipkg/status"; 96 packageFile = "/usr/lib/ipkg/status";
89 readPackageFile( 0, false, true ); 97 readPackageFile( 0, false, true );
90 } 98 }
91} 99}
92 100
93void Server :: readLocalIpks( Server *local ) 101void Server :: readLocalIpks( Server *local )
94{ 102{
95 cleanUp(); 103 cleanUp();
96 104
97#ifdef QWS 105#ifdef QWS
98 // First, get any local IPKGs in the documents area 106 // First, get any local IPKGs in the documents area
99 // Only applicable to Qtopie/Opie 107 // Only applicable to Qtopie/Opie
100 108
101 DocLnkSet files; 109 DocLnkSet files;
102 Global::findDocuments( &files, "application/ipkg" ); 110 Global::findDocuments( &files, "application/ipkg" );
103 111
104 // Now add the items to the list 112 // Now add the items to the list
105 QListIterator<DocLnk> it( files.children() ); 113 QListIterator<DocLnk> it( files.children() );
106 114
107 for ( ; it.current() ; ++it ) 115 for ( ; it.current() ; ++it )
108 { 116 {
109 // OK, we have a local IPK file, I think the standard naming conventions 117 // OK, we have a local IPK file, I think the standard naming conventions
110 // for these are packagename_version_arm.ipk 118 // for these are packagename_version_arm.ipk
111 QString file = (*it)->file(); 119 QString file = (*it)->file();
112 120
113 // Changed to display the filename (excluding the path) 121 // Changed to display the filename (excluding the path)
114 QString packageName = Utils::getFilenameFromIpkFilename( file ); 122 QString packageName = Utils::getFilenameFromIpkFilename( file );
115 QString ver = Utils::getPackageVersionFromIpkFilename( file ); 123 QString ver = Utils::getPackageVersionFromIpkFilename( file );
116 Package *package = new Package( packageName ); 124 Package *package = new Package( packageName );
117 package->setVersion( ver ); 125 package->setVersion( ver );
118 package->setFilename( file ); 126 package->setFilename( file );
119 package->setPackageStoredLocally( true ); 127 package->setPackageStoredLocally( true );
120 packageList.append( package ); 128 packageList.append( package );
121 } 129 }
122#else 130#else
123 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" }; 131 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" };
124 for ( int i = 0 ; i < 4 ; ++i ) 132 for ( int i = 0 ; i < 4 ; ++i )
125 { 133 {
126 // OK, we have a local IPK file, I think the standard naming conventions 134 // OK, we have a local IPK file, I think the standard naming conventions
127 // for these are packagename_version_arm.ipk 135 // for these are packagename_version_arm.ipk
128 QString file = names[i]; 136 QString file = names[i];
129 int p = file.find( "_" ); 137 int p = file.find( "_" );
130 QString tmp = file.mid( 0, p ); 138 QString tmp = file.mid( 0, p );
131 packageList.push_back( Package( tmp ) ); 139 packageList.push_back( Package( tmp ) );
132 int p2 = file.find( "_", p+1 ); 140 int p2 = file.find( "_", p+1 );
133 tmp = file.mid( p+1, p2-(p+1) ); 141 tmp = file.mid( p+1, p2-(p+1) );
134 packageList.back().setVersion( tmp ); 142 packageList.back().setVersion( tmp );
135 packageList.back().setPackageStoredLocally( true ); 143 packageList.back().setPackageStoredLocally( true );
136 } 144 }
137#endif 145#endif
138 146
139 // build local packages 147 // build local packages
140 buildLocalPackages( local ); 148 buildLocalPackages( local );
141} 149}
142 150
143void Server :: readPackageFile( Server *local, bool clearAll, bool installingToRoot, Destination *dest ) 151void Server :: readPackageFile( Server *local, bool clearAll, bool installingToRoot, Destination *dest )
144{ 152{
145 QFile f( packageFile ); 153 QFile f( packageFile );
146 if ( !f.open( IO_ReadOnly ) ) 154 if ( !f.open( IO_ReadOnly ) )
147 return; 155 return;
148 QTextStream t( &f ); 156 QTextStream t( &f );
149 157
150 QString line; 158 QString line;
151 QString key; 159 QString key;
152 QString value; 160 QString value;
153 int pos; 161 int pos;
154 162
155 if ( clearAll ) 163 if ( clearAll )
156 cleanUp(); 164 cleanUp();
157 Package *currPackage = 0; 165 Package *currPackage = 0;
158 166
159 bool newPackage = true; 167 bool newPackage = true;
160 while ( !t.eof() ) 168 while ( !t.eof() )
161 { 169 {
162 line = t.readLine(); 170 line = t.readLine();
163 171
164 pos = line.find( ':', 0 ); 172 pos = line.find( ':', 0 );
165 if ( pos > -1 ) 173 if ( pos > -1 )
166 key = line.mid( 0, pos ).stripWhiteSpace(); 174 key = line.mid( 0, pos ).stripWhiteSpace();
167 else 175 else
168 key = QString::null; 176 key = QString::null;
169 value = line.mid( pos+1, line.length()-pos ).stripWhiteSpace(); 177 value = line.mid( pos+1, line.length()-pos ).stripWhiteSpace();
170 178
171 if ( key == "Package" && newPackage ) 179 if ( key == "Package" && newPackage )
172 { 180 {
173 newPackage = false; 181 newPackage = false;
174 182
175 currPackage = getPackage( value ); 183 currPackage = getPackage( value );
176 if ( !currPackage ) 184 if ( !currPackage )
177 { 185 {
178 Package *package = new Package( value ); 186 Package *package = new Package( value );
179 packageList.append( package ); 187 packageList.append( package );
180 currPackage = package; 188 currPackage = package;
181 currPackage->setInstalledTo( dest ); 189 currPackage->setInstalledTo( dest );
182 if ( installingToRoot ) 190 if ( installingToRoot )
183 currPackage->setInstalledToRoot( true ); 191 currPackage->setInstalledToRoot( true );
184 } 192 }
185 else 193 else
186 { 194 {
187 if ( currPackage->isInstalled() ) 195 if ( currPackage->isInstalled() )
188 currPackage->setInstalledTo( dest ); 196 currPackage->setInstalledTo( dest );
189 } 197 }
190 } 198 }
191 else if ( key == "Version" ) 199 else if ( key == "Version" )
192 { 200 {
193 if ( currPackage ) 201 if ( currPackage )
194 currPackage->setVersion( value ); 202 currPackage->setVersion( value );
195 } 203 }
196 else if ( key == "Status" ) 204 else if ( key == "Status" )
197 { 205 {
198 if ( currPackage ) 206 if ( currPackage )
199 currPackage->setStatus( value ); 207 currPackage->setStatus( value );
200 } 208 }
201 else if ( key == "Description" ) 209 else if ( key == "Description" )
202 { 210 {
203 if ( currPackage ) 211 if ( currPackage )
204 currPackage->setDescription( value ); 212 currPackage->setDescription( value );
205 } 213 }
206 else if ( key == "Filename" ) 214 else if ( key == "Filename" )
207 { 215 {
208 if ( currPackage ) 216 if ( currPackage )
209 currPackage->setFilename( value ); 217 currPackage->setFilename( value );
210 } 218 }
211 else if ( key == "Size" ) 219 else if ( key == "Size" )
212 { 220 {
213 if ( currPackage ) 221 if ( currPackage )
214 currPackage->setPackageSize( value ); 222 currPackage->setPackageSize( value );
215 } 223 }
216 else if ( key == "Section" ) 224 else if ( key == "Section" )
217 { 225 {
218 if ( currPackage ) 226 if ( currPackage )
219 currPackage->setSection( value ); 227 currPackage->setSection( value );
220 228
221 DataManager::setAvailableCategories( value ); 229 DataManager::setAvailableCategories( value );
222 } 230 }
223 else if ( key == QString::null ) 231 else if ( key == QString::null )
224 { 232 {
225 newPackage = true; 233 newPackage = true;
226 } 234 }
227 } 235 }
228 236
229 f.close(); 237 f.close();
230 238
231 // build local packages 239 // build local packages
232 buildLocalPackages( local ); 240 buildLocalPackages( local );
233} 241}
234 242
235void Server :: buildLocalPackages( Server *local ) 243void Server :: buildLocalPackages( Server *local )
236{ 244{
237 Package *curr; 245 Package *curr;
238 QListIterator<Package> it( packageList ); 246 QListIterator<Package> it( packageList );
239 for ( ; it.current(); ++it ) 247 for ( ; it.current(); ++it )
240 { 248 {
241 curr = it.current(); 249 curr = it.current();
242 QString name = curr->getPackageName(); 250 QString name = curr->getPackageName();
243 251
244 // If the package name is an ipk name, then convert the filename to a package name 252 // If the package name is an ipk name, then convert the filename to a package name
245 if ( name.find( ".ipk" ) != -1 ) 253 if ( name.find( ".ipk" ) != -1 )
246 name = Utils::getPackageNameFromIpkFilename( curr->getFilename() ); 254 name = Utils::getPackageNameFromIpkFilename( curr->getFilename() );
247 255
248 if ( local ) 256 if ( local )
249 { 257 {
250 Package *p = local->getPackage( name ); 258 Package *p = local->getPackage( name );
251 curr->setLocalPackage( p ); 259 curr->setLocalPackage( p );
252 if ( p ) 260 if ( p )
253 { 261 {
254 // Set some default stuff like size and things 262 // Set some default stuff like size and things
255 if ( p->getInstalledVersion() == curr->getVersion() ) 263 if ( p->getInstalledVersion() == curr->getVersion() )
256 { 264 {
257 p->setPackageSize( curr->getPackageSize() ); 265 p->setPackageSize( curr->getPackageSize() );
258 p->setSection( curr->getSection() ); 266 p->setSection( curr->getSection() );
259 p->setDescription( curr->getDescription() ); 267 p->setDescription( curr->getDescription() );
260 } 268 }
261 } 269 }
262 270
263 } 271 }
264 else 272 else
265 curr->setLocalPackage( 0 ); 273 curr->setLocalPackage( 0 );
266 } 274 }
267 275
268} 276}
269 277
270Package *Server :: getPackage( QString &name ) 278Package *Server :: getPackage( QString &name )
271{ 279{
272 return getPackage( (const char *)name ); 280 return getPackage( (const char *)name );
273} 281}
274 282
275Package *Server :: getPackage( const char *name ) 283Package *Server :: getPackage( const char *name )
276{ 284{
277 Package *ret = 0; 285 Package *ret = 0;
278 286
279 QListIterator<Package> it( packageList ); 287 QListIterator<Package> it( packageList );
280 for ( ; it.current(); ++it ) 288 for ( ; it.current(); ++it )
281 { 289 {
282 if ( it.current()->getPackageName() == name ) 290 if ( it.current()->getPackageName() == name )
283 ret = it.current(); 291 ret = it.current();
284 } 292 }
285 293
286 return ret; 294 return ret;
287} 295}
288 296
289QString Server :: toString() 297QString Server :: toString()
290{ 298{
291 QString ret = QString( "Server\n name - %1\n url - %2\n" ).arg( serverName ).arg( serverUrl ); 299 QString ret = QString( "Server\n name - %1\n url - %2\n" ).arg( serverName ).arg( serverUrl );
292 300
293 QListIterator<Package> it( packageList ); 301 QListIterator<Package> it( packageList );
294 for ( ; it.current(); ++it ) 302 for ( ; it.current(); ++it )
295 { 303 {
296 ret.append( QString( "\n %1" ).arg( it.current()->toString() ) ); 304 ret.append( QString( "\n %1" ).arg( it.current()->toString() ) );
297 } 305 }
298 306
299 307
300 return ret; 308 return ret;
301} 309}
302 310
303QList<Package> &Server::getPackageList() 311QList<Package> &Server::getPackageList()
304{ 312{
305 return packageList; 313 return packageList;
306} 314}
307 315
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 @@
1/*************************************************************************** 1/*
2 server.h - description 2                This file is part of the OPIE Project
3 ------------------- 3
4 begin : Mon Aug 26 2002 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5 copyright : (C) 2002 by Andy Qua 5             .=l. Dan Williams <drw@handhelds.org>
6 email : andy.qua@blueyonder.co.uk 6           .>+-=
7 ***************************************************************************/ 7 _;:,     .>    :=|. This file is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This file is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
8 29
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#ifndef SERVER_H 30#ifndef SERVER_H
18#define SERVER_H 31#define SERVER_H
19 32
20#include <qlist.h> 33#include <qlist.h>
21#include <qstring.h> 34#include <qstring.h>
22 35
23using namespace std; 36using namespace std;
24 37
25#include "package.h" 38#include "package.h"
26#include "destination.h" 39#include "destination.h"
27 40
28class Server 41class Server
29{ 42{
30public: 43public:
31 Server() {} 44 Server() {}
32 Server( const char *name, const char *url ); 45 Server( const char *name, const char *url );
33 Server( const char *name, const char *url, const char *file ); 46 Server( const char *name, const char *url, const char *file );
34 ~Server(); 47 ~Server();
35 48
36 void cleanUp(); 49 void cleanUp();
37 50
38 void readStatusFile( QList<Destination> &v ); 51 void readStatusFile( QList<Destination> &v );
39 void readLocalIpks( Server *local ); 52 void readLocalIpks( Server *local );
40 void readPackageFile( Server *local = 0, bool clearAll = true, bool installedToRoot= false, Destination *dest = 0 ); 53 void readPackageFile( Server *local = 0, bool clearAll = true, bool installedToRoot= false, Destination *dest = 0 );
41 void buildLocalPackages( Server *local ); 54 void buildLocalPackages( Server *local );
42 Package *getPackage( const char *name ); 55 Package *getPackage( const char *name );
43 Package *getPackage( QString &name ); 56 Package *getPackage( QString &name );
44 QString toString(); 57 QString toString();
45 QList<Package> &getPackageList(); 58 QList<Package> &getPackageList();
46 bool isServerActive() { return active; } 59 bool isServerActive() { return active; }
47 60
48 void setServerName( const QString &name ) { serverName = name; } 61 void setServerName( const QString &name ) { serverName = name; }
49 void setServerUrl( const QString &url ) { serverUrl = url; } 62 void setServerUrl( const QString &url ) { serverUrl = url; }
50 void setActive( bool val ) { active = val; } 63 void setActive( bool val ) { active = val; }
51 QString &getServerName() { return serverName; } 64 QString &getServerName() { return serverName; }
52 QString &getServerUrl() { return serverUrl; } 65 QString &getServerUrl() { return serverUrl; }
53 66
54protected: 67protected:
55 68
56private: 69private:
57 QString serverName; 70 QString serverName;
58 QString serverUrl; 71 QString serverUrl;
59 QString packageFile; 72 QString packageFile;
60 bool active; 73 bool active;
61 74
62 75
63 QList<Package> packageList; 76 QList<Package> packageList;
64}; 77};
65 78
66#endif 79#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,481 +1,493 @@
1/*************************************************************************** 1/*
2 settingsimpl.cpp - description 2                This file is part of the OPIE Project
3 ------------------- 3
4 begin : Thu Aug 29 2002 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5 copyright : (C) 2002 by Andy Qua 5             .=l. Dan Williams <drw@handhelds.org>
6 email : andy.qua@blueyonder.co.uk 6           .>+-=
7 ***************************************************************************/ 7 _;:,     .>    :=|. This file is free software; you can
8 8.> <`_,   >  .   <= redistribute it and/or modify it under
9/*************************************************************************** 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10 * * 10.="- .-=="i,     .._ License as published by the Free Software
11 * This program is free software; you can redistribute it and/or modify * 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12 * it under the terms of the GNU General Public License as published by * 12     ._= =}       : or (at your option) any later version.
13 * the Free Software Foundation; either version 2 of the License, or * 13    .%`+i>       _;_.
14 * (at your option) any later version. * 14    .i_,=:_.      -<s. This file is distributed in the hope that
15 * * 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16 ***************************************************************************/ 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
17 29
18#include <fstream> 30#include <fstream>
19#include <algorithm> 31#include <algorithm>
20using namespace std; 32using namespace std;
21 33
22#include <qcheckbox.h> 34#include <qcheckbox.h>
23#include <qgroupbox.h> 35#include <qgroupbox.h>
24#include <qlabel.h> 36#include <qlabel.h>
25#include <qlayout.h> 37#include <qlayout.h>
26#include <qlineedit.h> 38#include <qlineedit.h>
27#include <qlistbox.h> 39#include <qlistbox.h>
28#include <qpushbutton.h> 40#include <qpushbutton.h>
29 41
30#include <opie/otabwidget.h> 42#include <opie/otabwidget.h>
31 43
32#ifdef QWS 44#ifdef QWS
33#include <qpe/config.h> 45#include <qpe/config.h>
34#include <qpe/resource.h> 46#include <qpe/resource.h>
35#endif 47#endif
36 48
37#include "settingsimpl.h" 49#include "settingsimpl.h"
38 50
39#include "global.h" 51#include "global.h"
40 52
41SettingsImpl :: SettingsImpl( DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) 53SettingsImpl :: SettingsImpl( DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl )
42 : QDialog( parent, name, modal, fl ) 54 : QDialog( parent, name, modal, fl )
43{ 55{
44 setCaption( tr( "Configuration" ) ); 56 setCaption( tr( "Configuration" ) );
45 57
46 // Setup layout to make everything pretty 58 // Setup layout to make everything pretty
47 QVBoxLayout *layout = new QVBoxLayout( this ); 59 QVBoxLayout *layout = new QVBoxLayout( this );
48 layout->setMargin( 2 ); 60 layout->setMargin( 2 );
49 layout->setSpacing( 4 ); 61 layout->setSpacing( 4 );
50 62
51 // Setup tabs for all info 63 // Setup tabs for all info
52 OTabWidget *tabwidget = new OTabWidget( this ); 64 OTabWidget *tabwidget = new OTabWidget( this );
53 layout->addWidget( tabwidget ); 65 layout->addWidget( tabwidget );
54 66
55 tabwidget->addTab( initServerTab(), "aqpkg/servertab", tr( "Servers" ) ); 67 tabwidget->addTab( initServerTab(), "aqpkg/servertab", tr( "Servers" ) );
56 tabwidget->addTab( initDestinationTab(), "aqpkg/desttab", tr( "Destinations" ) ); 68 tabwidget->addTab( initDestinationTab(), "aqpkg/desttab", tr( "Destinations" ) );
57 tabwidget->addTab( initProxyTab(), "aqpkg/proxytab", tr( "Proxies" ) ); 69 tabwidget->addTab( initProxyTab(), "aqpkg/proxytab", tr( "Proxies" ) );
58 tabwidget->setCurrentTab( tr( "Servers" ) ); 70 tabwidget->setCurrentTab( tr( "Servers" ) );
59 71
60 dataMgr = dataManager; 72 dataMgr = dataManager;
61 setupData(); 73 setupData();
62 changed = false; 74 changed = false;
63 newserver = false; 75 newserver = false;
64 newdestination = false; 76 newdestination = false;
65} 77}
66 78
67SettingsImpl :: ~SettingsImpl() 79SettingsImpl :: ~SettingsImpl()
68{ 80{
69 81
70} 82}
71 83
72bool SettingsImpl :: showDlg() 84bool SettingsImpl :: showDlg()
73{ 85{
74 showMaximized(); 86 showMaximized();
75 exec(); 87 exec();
76 88
77 if ( changed ) 89 if ( changed )
78 dataMgr->writeOutIpkgConf(); 90 dataMgr->writeOutIpkgConf();
79 91
80 return changed; 92 return changed;
81} 93}
82 94
83QWidget *SettingsImpl :: initServerTab() 95QWidget *SettingsImpl :: initServerTab()
84{ 96{
85 QWidget *control = new QWidget( this ); 97 QWidget *control = new QWidget( this );
86 98
87 QVBoxLayout *vb = new QVBoxLayout( control ); 99 QVBoxLayout *vb = new QVBoxLayout( control );
88 100
89 QScrollView *sv = new QScrollView( control ); 101 QScrollView *sv = new QScrollView( control );
90 vb->addWidget( sv, 0, 0 ); 102 vb->addWidget( sv, 0, 0 );
91 sv->setResizePolicy( QScrollView::AutoOneFit ); 103 sv->setResizePolicy( QScrollView::AutoOneFit );
92 sv->setFrameStyle( QFrame::NoFrame ); 104 sv->setFrameStyle( QFrame::NoFrame );
93 105
94 QWidget *container = new QWidget( sv->viewport() ); 106 QWidget *container = new QWidget( sv->viewport() );
95 sv->addChild( container ); 107 sv->addChild( container );
96 108
97 QGridLayout *layout = new QGridLayout( container ); 109 QGridLayout *layout = new QGridLayout( container );
98 layout->setSpacing( 2 ); 110 layout->setSpacing( 2 );
99 layout->setMargin( 4 ); 111 layout->setMargin( 4 );
100 112
101 servers = new QListBox( container ); 113 servers = new QListBox( container );
102 servers->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); 114 servers->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
103 connect( servers, SIGNAL( highlighted( int ) ), this, SLOT( editServer( int ) ) ); 115 connect( servers, SIGNAL( highlighted( int ) ), this, SLOT( editServer( int ) ) );
104 layout->addMultiCellWidget( servers, 0, 0, 0, 1 ); 116 layout->addMultiCellWidget( servers, 0, 0, 0, 1 );
105 117
106 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); 118 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container );
107 connect( btn, SIGNAL( clicked() ), this, SLOT( newServer() ) ); 119 connect( btn, SIGNAL( clicked() ), this, SLOT( newServer() ) );
108 layout->addWidget( btn, 1, 0 ); 120 layout->addWidget( btn, 1, 0 );
109 121
110 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); 122 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container );
111 connect( btn, SIGNAL( clicked() ), this, SLOT( removeServer() ) ); 123 connect( btn, SIGNAL( clicked() ), this, SLOT( removeServer() ) );
112 layout->addWidget( btn, 1, 1 ); 124 layout->addWidget( btn, 1, 1 );
113 125
114 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); 126 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container );
115 grpbox->layout()->setSpacing( 2 ); 127 grpbox->layout()->setSpacing( 2 );
116 grpbox->layout()->setMargin( 4 ); 128 grpbox->layout()->setMargin( 4 );
117 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); 129 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 );
118 130
119 QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); 131 QGridLayout *grplayout = new QGridLayout( grpbox->layout() );
120 132
121 QLabel *label = new QLabel( tr( "Name:" ), grpbox ); 133 QLabel *label = new QLabel( tr( "Name:" ), grpbox );
122 grplayout->addWidget( label, 0, 0 ); 134 grplayout->addWidget( label, 0, 0 );
123 servername = new QLineEdit( grpbox ); 135 servername = new QLineEdit( grpbox );
124 grplayout->addWidget( servername, 0, 1 ); 136 grplayout->addWidget( servername, 0, 1 );
125 137
126 label = new QLabel( tr( "Address:" ), grpbox ); 138 label = new QLabel( tr( "Address:" ), grpbox );
127 grplayout->addWidget( label, 1, 0 ); 139 grplayout->addWidget( label, 1, 0 );
128 serverurl = new QLineEdit( grpbox ); 140 serverurl = new QLineEdit( grpbox );
129 grplayout->addWidget( serverurl, 1, 1 ); 141 grplayout->addWidget( serverurl, 1, 1 );
130 142
131 active = new QCheckBox( tr( "Active Server" ), grpbox ); 143 active = new QCheckBox( tr( "Active Server" ), grpbox );
132 grplayout->addMultiCellWidget( active, 2, 2, 0, 1 ); 144 grplayout->addMultiCellWidget( active, 2, 2, 0, 1 );
133 145
134 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); 146 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox );
135 connect( btn, SIGNAL( clicked() ), this, SLOT( changeServerDetails() ) ); 147 connect( btn, SIGNAL( clicked() ), this, SLOT( changeServerDetails() ) );
136 grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); 148 grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 );
137 149
138 return control; 150 return control;
139} 151}
140 152
141QWidget *SettingsImpl :: initDestinationTab() 153QWidget *SettingsImpl :: initDestinationTab()
142{ 154{
143 QWidget *control = new QWidget( this ); 155 QWidget *control = new QWidget( this );
144 156
145 QVBoxLayout *vb = new QVBoxLayout( control ); 157 QVBoxLayout *vb = new QVBoxLayout( control );
146 158
147 QScrollView *sv = new QScrollView( control ); 159 QScrollView *sv = new QScrollView( control );
148 vb->addWidget( sv, 0, 0 ); 160 vb->addWidget( sv, 0, 0 );
149 sv->setResizePolicy( QScrollView::AutoOneFit ); 161 sv->setResizePolicy( QScrollView::AutoOneFit );
150 sv->setFrameStyle( QFrame::NoFrame ); 162 sv->setFrameStyle( QFrame::NoFrame );
151 163
152 QWidget *container = new QWidget( sv->viewport() ); 164 QWidget *container = new QWidget( sv->viewport() );
153 sv->addChild( container ); 165 sv->addChild( container );
154 166
155 QGridLayout *layout = new QGridLayout( container ); 167 QGridLayout *layout = new QGridLayout( container );
156 layout->setSpacing( 2 ); 168 layout->setSpacing( 2 );
157 layout->setMargin( 4 ); 169 layout->setMargin( 4 );
158 170
159 destinations = new QListBox( container ); 171 destinations = new QListBox( container );
160 destinations->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); 172 destinations->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
161 connect( destinations, SIGNAL( highlighted( int ) ), this, SLOT( editDestination( int ) ) ); 173 connect( destinations, SIGNAL( highlighted( int ) ), this, SLOT( editDestination( int ) ) );
162 layout->addMultiCellWidget( destinations, 0, 0, 0, 1 ); 174 layout->addMultiCellWidget( destinations, 0, 0, 0, 1 );
163 175
164 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); 176 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container );
165 connect( btn, SIGNAL( clicked() ), this, SLOT( newDestination() ) ); 177 connect( btn, SIGNAL( clicked() ), this, SLOT( newDestination() ) );
166 layout->addWidget( btn, 1, 0 ); 178 layout->addWidget( btn, 1, 0 );
167 179
168 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); 180 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container );
169 connect( btn, SIGNAL( clicked() ), this, SLOT( removeDestination() ) ); 181 connect( btn, SIGNAL( clicked() ), this, SLOT( removeDestination() ) );
170 layout->addWidget( btn, 1, 1 ); 182 layout->addWidget( btn, 1, 1 );
171 183
172 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Destination" ), container ); 184 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Destination" ), container );
173 grpbox->layout()->setSpacing( 2 ); 185 grpbox->layout()->setSpacing( 2 );
174 grpbox->layout()->setMargin( 4 ); 186 grpbox->layout()->setMargin( 4 );
175 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); 187 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 );
176 188
177 QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); 189 QGridLayout *grplayout = new QGridLayout( grpbox->layout() );
178 190
179 QLabel *label = new QLabel( tr( "Name:" ), grpbox ); 191 QLabel *label = new QLabel( tr( "Name:" ), grpbox );
180 grplayout->addWidget( label, 0, 0 ); 192 grplayout->addWidget( label, 0, 0 );
181 destinationname = new QLineEdit( grpbox ); 193 destinationname = new QLineEdit( grpbox );
182 grplayout->addWidget( destinationname, 0, 1 ); 194 grplayout->addWidget( destinationname, 0, 1 );
183 195
184 label = new QLabel( tr( "Location:" ), grpbox ); 196 label = new QLabel( tr( "Location:" ), grpbox );
185 grplayout->addWidget( label, 1, 0 ); 197 grplayout->addWidget( label, 1, 0 );
186 destinationurl = new QLineEdit( grpbox ); 198 destinationurl = new QLineEdit( grpbox );
187 grplayout->addWidget( destinationurl, 1, 1 ); 199 grplayout->addWidget( destinationurl, 1, 1 );
188 200
189 linkToRoot = new QCheckBox( tr( "Link to root" ), grpbox ); 201 linkToRoot = new QCheckBox( tr( "Link to root" ), grpbox );
190 grplayout->addMultiCellWidget( linkToRoot, 2, 2, 0, 1 ); 202 grplayout->addMultiCellWidget( linkToRoot, 2, 2, 0, 1 );
191 203
192 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); 204 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox );
193 connect( btn, SIGNAL( clicked() ), this, SLOT( changeDestinationDetails() ) ); 205 connect( btn, SIGNAL( clicked() ), this, SLOT( changeDestinationDetails() ) );
194 grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); 206 grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 );
195 207
196 return control; 208 return control;
197} 209}
198 210
199QWidget *SettingsImpl :: initProxyTab() 211QWidget *SettingsImpl :: initProxyTab()
200{ 212{
201 QWidget *control = new QWidget( this ); 213 QWidget *control = new QWidget( this );
202 214
203 QVBoxLayout *vb = new QVBoxLayout( control ); 215 QVBoxLayout *vb = new QVBoxLayout( control );
204 216
205 QScrollView *sv = new QScrollView( control ); 217 QScrollView *sv = new QScrollView( control );
206 vb->addWidget( sv, 0, 0 ); 218 vb->addWidget( sv, 0, 0 );
207 sv->setResizePolicy( QScrollView::AutoOneFit ); 219 sv->setResizePolicy( QScrollView::AutoOneFit );
208 sv->setFrameStyle( QFrame::NoFrame ); 220 sv->setFrameStyle( QFrame::NoFrame );
209 221
210 QWidget *container = new QWidget( sv->viewport() ); 222 QWidget *container = new QWidget( sv->viewport() );
211 sv->addChild( container ); 223 sv->addChild( container );
212 224
213 QGridLayout *layout = new QGridLayout( container ); 225 QGridLayout *layout = new QGridLayout( container );
214 layout->setSpacing( 2 ); 226 layout->setSpacing( 2 );
215 layout->setMargin( 4 ); 227 layout->setMargin( 4 );
216 228
217 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container ); 229 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container );
218 grpbox->layout()->setSpacing( 2 ); 230 grpbox->layout()->setSpacing( 2 );
219 grpbox->layout()->setMargin( 4 ); 231 grpbox->layout()->setMargin( 4 );
220 layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 ); 232 layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 );
221 QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); 233 QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() );
222 txtHttpProxy = new QLineEdit( grpbox ); 234 txtHttpProxy = new QLineEdit( grpbox );
223 grplayout->addWidget( txtHttpProxy ); 235 grplayout->addWidget( txtHttpProxy );
224 chkHttpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); 236 chkHttpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox );
225 grplayout->addWidget( chkHttpProxyEnabled ); 237 grplayout->addWidget( chkHttpProxyEnabled );
226 238
227 grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container ); 239 grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container );
228 grpbox->layout()->setSpacing( 2 ); 240 grpbox->layout()->setSpacing( 2 );
229 grpbox->layout()->setMargin( 4 ); 241 grpbox->layout()->setMargin( 4 );
230 layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 ); 242 layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 );
231 grplayout = new QVBoxLayout( grpbox->layout() ); 243 grplayout = new QVBoxLayout( grpbox->layout() );
232 txtFtpProxy = new QLineEdit( grpbox ); 244 txtFtpProxy = new QLineEdit( grpbox );
233 grplayout->addWidget( txtFtpProxy ); 245 grplayout->addWidget( txtFtpProxy );
234 chkFtpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); 246 chkFtpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox );
235 grplayout->addWidget( chkFtpProxyEnabled ); 247 grplayout->addWidget( chkFtpProxyEnabled );
236 248
237 QLabel *label = new QLabel( tr( "Username:" ), container ); 249 QLabel *label = new QLabel( tr( "Username:" ), container );
238 layout->addWidget( label, 2, 0 ); 250 layout->addWidget( label, 2, 0 );
239 txtUsername = new QLineEdit( container ); 251 txtUsername = new QLineEdit( container );
240 layout->addWidget( txtUsername, 2, 1 ); 252 layout->addWidget( txtUsername, 2, 1 );
241 253
242 label = new QLabel( tr( "Password:" ), container ); 254 label = new QLabel( tr( "Password:" ), container );
243 layout->addWidget( label, 3, 0 ); 255 layout->addWidget( label, 3, 0 );
244 txtPassword = new QLineEdit( container ); 256 txtPassword = new QLineEdit( container );
245 layout->addWidget( txtPassword, 3, 1 ); 257 layout->addWidget( txtPassword, 3, 1 );
246 258
247 QPushButton *btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), container ); 259 QPushButton *btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), container );
248 connect( btn, SIGNAL( clicked() ), this, SLOT( proxyApplyChanges() ) ); 260 connect( btn, SIGNAL( clicked() ), this, SLOT( proxyApplyChanges() ) );
249 layout->addMultiCellWidget( btn, 4, 4, 0, 1 ); 261 layout->addMultiCellWidget( btn, 4, 4, 0, 1 );
250 262
251 return control; 263 return control;
252} 264}
253 265
254void SettingsImpl :: setupData() 266void SettingsImpl :: setupData()
255{ 267{
256 // add servers 268 // add servers
257 QString serverName; 269 QString serverName;
258 QListIterator<Server> it( dataMgr->getServerList() ); 270 QListIterator<Server> it( dataMgr->getServerList() );
259 for ( ; it.current(); ++it ) 271 for ( ; it.current(); ++it )
260 { 272 {
261 serverName = it.current()->getServerName(); 273 serverName = it.current()->getServerName();
262 if ( serverName == LOCAL_SERVER || serverName == LOCAL_IPKGS ) 274 if ( serverName == LOCAL_SERVER || serverName == LOCAL_IPKGS )
263 continue; 275 continue;
264 276
265 servers->insertItem( serverName ); 277 servers->insertItem( serverName );
266 } 278 }
267 279
268 280
269 // add destinations 281 // add destinations
270 QListIterator<Destination> it2( dataMgr->getDestinationList() ); 282 QListIterator<Destination> it2( dataMgr->getDestinationList() );
271 for ( ; it2.current(); ++it2 ) 283 for ( ; it2.current(); ++it2 )
272 destinations->insertItem( it2.current()->getDestinationName() ); 284 destinations->insertItem( it2.current()->getDestinationName() );
273 285
274 // setup proxy tab 286 // setup proxy tab
275 txtHttpProxy->setText( dataMgr->getHttpProxy() ); 287 txtHttpProxy->setText( dataMgr->getHttpProxy() );
276 txtFtpProxy->setText( dataMgr->getFtpProxy() ); 288 txtFtpProxy->setText( dataMgr->getFtpProxy() );
277 txtUsername->setText( dataMgr->getProxyUsername() ); 289 txtUsername->setText( dataMgr->getProxyUsername() );
278 txtPassword->setText( dataMgr->getProxyPassword() ); 290 txtPassword->setText( dataMgr->getProxyPassword() );
279 chkHttpProxyEnabled->setChecked( dataMgr->getHttpProxyEnabled() ); 291 chkHttpProxyEnabled->setChecked( dataMgr->getHttpProxyEnabled() );
280 chkFtpProxyEnabled->setChecked( dataMgr->getFtpProxyEnabled() ); 292 chkFtpProxyEnabled->setChecked( dataMgr->getFtpProxyEnabled() );
281} 293}
282 294
283//------------------ Servers tab ---------------------- 295//------------------ Servers tab ----------------------
284 296
285void SettingsImpl :: editServer( int sel ) 297void SettingsImpl :: editServer( int sel )
286{ 298{
287 currentSelectedServer = sel; 299 currentSelectedServer = sel;
288 Server *s = dataMgr->getServer( servers->currentText() ); 300 Server *s = dataMgr->getServer( servers->currentText() );
289 if ( s ) 301 if ( s )
290 { 302 {
291 serverName = s->getServerName(); 303 serverName = s->getServerName();
292 servername->setText( s->getServerName() ); 304 servername->setText( s->getServerName() );
293 serverurl->setText( s->getServerUrl() ); 305 serverurl->setText( s->getServerUrl() );
294 active->setChecked( s->isServerActive() ); 306 active->setChecked( s->isServerActive() );
295 } 307 }
296 else 308 else
297 { 309 {
298 serverName = ""; 310 serverName = "";
299 servername->setText( "" ); 311 servername->setText( "" );
300 serverurl->setText( "" ); 312 serverurl->setText( "" );
301 active->setChecked( false ); 313 active->setChecked( false );
302 } 314 }
303} 315}
304 316
305void SettingsImpl :: newServer() 317void SettingsImpl :: newServer()
306{ 318{
307 newserver = true; 319 newserver = true;
308 servername->setText( "" ); 320 servername->setText( "" );
309 serverurl->setText( "" ); 321 serverurl->setText( "" );
310 servername->setFocus(); 322 servername->setFocus();
311 active->setChecked( true ); 323 active->setChecked( true );
312} 324}
313 325
314void SettingsImpl :: removeServer() 326void SettingsImpl :: removeServer()
315{ 327{
316 changed = true; 328 changed = true;
317 Server *s = dataMgr->getServer( servers->currentText() ); 329 Server *s = dataMgr->getServer( servers->currentText() );
318 if ( s ) 330 if ( s )
319 { 331 {
320 dataMgr->getServerList().removeRef( s ); 332 dataMgr->getServerList().removeRef( s );
321 servers->removeItem( currentSelectedServer ); 333 servers->removeItem( currentSelectedServer );
322 } 334 }
323} 335}
324 336
325void SettingsImpl :: changeServerDetails() 337void SettingsImpl :: changeServerDetails()
326{ 338{
327 changed = true; 339 changed = true;
328 340
329 QString newName = servername->text(); 341 QString newName = servername->text();
330 342
331 // Convert any spaces to underscores 343 // Convert any spaces to underscores
332 char *tmpStr = new char[newName.length() + 1]; 344 char *tmpStr = new char[newName.length() + 1];
333 for ( unsigned int i = 0 ; i < newName.length() ; ++i ) 345 for ( unsigned int i = 0 ; i < newName.length() ; ++i )
334 { 346 {
335 if ( newName[i] == ' ' ) 347 if ( newName[i] == ' ' )
336 tmpStr[i] = '_'; 348 tmpStr[i] = '_';
337 else 349 else
338 tmpStr[i] = newName[i].latin1(); 350 tmpStr[i] = newName[i].latin1();
339 } 351 }
340 tmpStr[newName.length()] = '\0'; 352 tmpStr[newName.length()] = '\0';
341 353
342 newName = tmpStr; 354 newName = tmpStr;
343 delete tmpStr; 355 delete tmpStr;
344 356
345 if ( !newserver ) 357 if ( !newserver )
346 { 358 {
347 Server *s = dataMgr->getServer( servers->currentText() ); 359 Server *s = dataMgr->getServer( servers->currentText() );
348 if ( s ) 360 if ( s )
349 { 361 {
350 // Update url 362 // Update url
351 s->setServerUrl( serverurl->text() ); 363 s->setServerUrl( serverurl->text() );
352 s->setActive( active->isChecked() ); 364 s->setActive( active->isChecked() );
353 365
354 // Check if server name has changed, if it has then we need to replace the key in the map 366 // Check if server name has changed, if it has then we need to replace the key in the map
355 if ( serverName != newName ) 367 if ( serverName != newName )
356 { 368 {
357 // Update server name 369 // Update server name
358 s->setServerName( newName ); 370 s->setServerName( newName );
359 } 371 }
360 372
361 // Update list box 373 // Update list box
362 servers->changeItem( newName, currentSelectedServer ); 374 servers->changeItem( newName, currentSelectedServer );
363 } 375 }
364 } 376 }
365 else 377 else
366 { 378 {
367 Server s( newName, serverurl->text() ); 379 Server s( newName, serverurl->text() );
368 dataMgr->getServerList().append( new Server( newName, serverurl->text() ) ); 380 dataMgr->getServerList().append( new Server( newName, serverurl->text() ) );
369 dataMgr->getServerList().last()->setActive( active->isChecked() ); 381 dataMgr->getServerList().last()->setActive( active->isChecked() );
370 servers->insertItem( newName ); 382 servers->insertItem( newName );
371 servers->setCurrentItem( servers->count() ); 383 servers->setCurrentItem( servers->count() );
372 newserver = false; 384 newserver = false;
373 } 385 }
374} 386}
375 387
376//------------------ Destinations tab ---------------------- 388//------------------ Destinations tab ----------------------
377 389
378void SettingsImpl :: editDestination( int sel ) 390void SettingsImpl :: editDestination( int sel )
379{ 391{
380 currentSelectedDestination = sel; 392 currentSelectedDestination = sel;
381 Destination *d = dataMgr->getDestination( destinations->currentText() ); 393 Destination *d = dataMgr->getDestination( destinations->currentText() );
382 if ( d ) 394 if ( d )
383 { 395 {
384 destinationName = d->getDestinationName(); 396 destinationName = d->getDestinationName();
385 destinationname->setText( d->getDestinationName() ); 397 destinationname->setText( d->getDestinationName() );
386 destinationurl->setText( d->getDestinationPath() ); 398 destinationurl->setText( d->getDestinationPath() );
387 linkToRoot->setChecked( d->linkToRoot() ); 399 linkToRoot->setChecked( d->linkToRoot() );
388 } 400 }
389 else 401 else
390 { 402 {
391 destinationName = ""; 403 destinationName = "";
392 destinationname->setText( "" ); 404 destinationname->setText( "" );
393 destinationurl->setText( "" ); 405 destinationurl->setText( "" );
394 linkToRoot->setChecked( false ); 406 linkToRoot->setChecked( false );
395 } 407 }
396} 408}
397 409
398void SettingsImpl :: newDestination() 410void SettingsImpl :: newDestination()
399{ 411{
400 newdestination = true; 412 newdestination = true;
401 destinationname->setText( "" ); 413 destinationname->setText( "" );
402 destinationurl->setText( "" ); 414 destinationurl->setText( "" );
403 destinationname->setFocus(); 415 destinationname->setFocus();
404 linkToRoot->setChecked( true ); 416 linkToRoot->setChecked( true );
405} 417}
406 418
407void SettingsImpl :: removeDestination() 419void SettingsImpl :: removeDestination()
408{ 420{
409 changed = true; 421 changed = true;
410 Destination *d = dataMgr->getDestination( destinations->currentText() ); 422 Destination *d = dataMgr->getDestination( destinations->currentText() );
411 if ( d ) 423 if ( d )
412 { 424 {
413 dataMgr->getDestinationList().removeRef( d ); 425 dataMgr->getDestinationList().removeRef( d );
414 destinations->removeItem( currentSelectedDestination ); 426 destinations->removeItem( currentSelectedDestination );
415 } 427 }
416} 428}
417 429
418void SettingsImpl :: changeDestinationDetails() 430void SettingsImpl :: changeDestinationDetails()
419{ 431{
420 changed = true; 432 changed = true;
421 433
422#ifdef QWS 434#ifdef QWS
423 Config cfg( "aqpkg" ); 435 Config cfg( "aqpkg" );
424 cfg.setGroup( "destinations" ); 436 cfg.setGroup( "destinations" );
425#endif 437#endif
426 438
427 QString newName = destinationname->text(); 439 QString newName = destinationname->text();
428 if ( !newdestination ) 440 if ( !newdestination )
429 { 441 {
430 Destination *d = dataMgr->getDestination( destinations->currentText() ); 442 Destination *d = dataMgr->getDestination( destinations->currentText() );
431 if ( d ) 443 if ( d )
432 { 444 {
433 // Update url 445 // Update url
434 d->setDestinationPath( destinationurl->text() ); 446 d->setDestinationPath( destinationurl->text() );
435 d->linkToRoot( linkToRoot->isChecked() ); 447 d->linkToRoot( linkToRoot->isChecked() );
436 448
437 // Check if server name has changed, if it has then we need to replace the key in the map 449 // Check if server name has changed, if it has then we need to replace the key in the map
438 if ( destinationName != newName ) 450 if ( destinationName != newName )
439 { 451 {
440 // Update server name 452 // Update server name
441 d->setDestinationName( newName ); 453 d->setDestinationName( newName );
442 454
443 // Update list box 455 // Update list box
444 destinations->changeItem( newName, currentSelectedDestination ); 456 destinations->changeItem( newName, currentSelectedDestination );
445 } 457 }
446 458
447#ifdef QWS 459#ifdef QWS
448 QString key = newName; 460 QString key = newName;
449 key += "_linkToRoot"; 461 key += "_linkToRoot";
450 int val = d->linkToRoot(); 462 int val = d->linkToRoot();
451 cfg.writeEntry( key, val ); 463 cfg.writeEntry( key, val );
452#endif 464#endif
453 } 465 }
454 } 466 }
455 else 467 else
456 { 468 {
457 dataMgr->getDestinationList().append( new Destination( newName, destinationurl->text() ) ); 469 dataMgr->getDestinationList().append( new Destination( newName, destinationurl->text() ) );
458 destinations->insertItem( newName ); 470 destinations->insertItem( newName );
459 destinations->setCurrentItem( destinations->count() ); 471 destinations->setCurrentItem( destinations->count() );
460 newdestination = false; 472 newdestination = false;
461 473
462#ifdef QWS 474#ifdef QWS
463 QString key = newName; 475 QString key = newName;
464 key += "_linkToRoot"; 476 key += "_linkToRoot";
465 cfg.writeEntry( key, true ); 477 cfg.writeEntry( key, true );
466#endif 478#endif
467 } 479 }
468} 480}
469 481
470//------------------ Proxy tab ---------------------- 482//------------------ Proxy tab ----------------------
471void SettingsImpl :: proxyApplyChanges() 483void SettingsImpl :: proxyApplyChanges()
472{ 484{
473 changed = true; 485 changed = true;
474 dataMgr->setHttpProxy( txtHttpProxy->text() ); 486 dataMgr->setHttpProxy( txtHttpProxy->text() );
475 dataMgr->setFtpProxy( txtFtpProxy->text() ); 487 dataMgr->setFtpProxy( txtFtpProxy->text() );
476 dataMgr->setProxyUsername( txtUsername->text() ); 488 dataMgr->setProxyUsername( txtUsername->text() );
477 dataMgr->setProxyPassword( txtPassword->text() ); 489 dataMgr->setProxyPassword( txtPassword->text() );
478 490
479 dataMgr->setHttpProxyEnabled( chkHttpProxyEnabled->isChecked() ); 491 dataMgr->setHttpProxyEnabled( chkHttpProxyEnabled->isChecked() );
480 dataMgr->setFtpProxyEnabled( chkFtpProxyEnabled->isChecked() ); 492 dataMgr->setFtpProxyEnabled( chkFtpProxyEnabled->isChecked() );
481} 493}
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 @@
1/*************************************************************************** 1/*
2 settingsimpl.h - description 2                This file is part of the OPIE Project
3 ------------------- 3
4 begin : Thu Aug 29 2002 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5 copyright : (C) 2002 by Andy Qua 5             .=l. Dan Williams <drw@handhelds.org>
6 email : andy.qua@blueyonder.co.uk 6           .>+-=
7 ***************************************************************************/ 7 _;:,     .>    :=|. This file is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This file is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
8 27
9/*************************************************************************** 28*/
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17 29
18#include "datamgr.h" 30#include "datamgr.h"
19 31
20#include <qdialog.h> 32#include <qdialog.h>
21 33
22class QCheckBox; 34class QCheckBox;
23class QLineEdit; 35class QLineEdit;
24class QListBox; 36class QListBox;
25 37
26class SettingsImpl : public QDialog 38class SettingsImpl : public QDialog
27{ 39{
28 Q_OBJECT 40 Q_OBJECT
29public: 41public:
30 SettingsImpl( DataManager *dataManager, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); 42 SettingsImpl( DataManager *dataManager, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
31 ~SettingsImpl(); 43 ~SettingsImpl();
32 44
33 bool showDlg(); 45 bool showDlg();
34 46
35private: 47private:
36 QListBox *servers; 48 QListBox *servers;
37 QLineEdit *servername; 49 QLineEdit *servername;
38 QLineEdit *serverurl; 50 QLineEdit *serverurl;
39 QCheckBox *active; 51 QCheckBox *active;
40 QListBox *destinations; 52 QListBox *destinations;
41 QLineEdit *destinationname; 53 QLineEdit *destinationname;
42 QLineEdit *destinationurl; 54 QLineEdit *destinationurl;
43 QCheckBox *linkToRoot; 55 QCheckBox *linkToRoot;
44 QLineEdit *txtHttpProxy; 56 QLineEdit *txtHttpProxy;
45 QCheckBox *chkHttpProxyEnabled; 57 QCheckBox *chkHttpProxyEnabled;
46 QLineEdit *txtFtpProxy; 58 QLineEdit *txtFtpProxy;
47 QCheckBox *chkFtpProxyEnabled; 59 QCheckBox *chkFtpProxyEnabled;
48 QLineEdit *txtUsername; 60 QLineEdit *txtUsername;
49 QLineEdit *txtPassword; 61 QLineEdit *txtPassword;
50 62
51 DataManager *dataMgr; 63 DataManager *dataMgr;
52 QString serverName; 64 QString serverName;
53 QString destinationName; 65 QString destinationName;
54 int currentSelectedServer; 66 int currentSelectedServer;
55 int currentSelectedDestination; 67 int currentSelectedDestination;
56 bool changed; 68 bool changed;
57 bool newserver; 69 bool newserver;
58 bool newdestination; 70 bool newdestination;
59 71
60 QWidget *initServerTab(); 72 QWidget *initServerTab();
61 QWidget *initDestinationTab(); 73 QWidget *initDestinationTab();
62 QWidget *initProxyTab(); 74 QWidget *initProxyTab();
63 75
64 void setupConnections(); 76 void setupConnections();
65 void setupData(); 77 void setupData();
66 78
67public slots: 79public slots:
68 void editServer( int s ); 80 void editServer( int s );
69 void changeServerDetails(); 81 void changeServerDetails();
70 void newServer(); 82 void newServer();
71 void removeServer(); 83 void removeServer();
72 void editDestination( int s ); 84 void editDestination( int s );
73 void changeDestinationDetails(); 85 void changeDestinationDetails();
74 void newDestination(); 86 void newDestination();
75 void removeDestination(); 87 void removeDestination();
76 void proxyApplyChanges(); 88 void proxyApplyChanges();
77}; 89};
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 @@
1/*************************************************************************** 1/*
2 utils.cpp - description 2                This file is part of the OPIE Project
3 ------------------- 3
4 begin : Sat Sep 7 2002 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5 copyright : (C) 2002 by Andy Qua 5             .=l. Dan Williams <drw@handhelds.org>
6 email : andy.qua@blueyonder.co.uk 6           .>+-=
7 ***************************************************************************/ 7 _;:,     .>    :=|. This file is free software; you can
8 8.> <`_,   >  .   <= redistribute it and/or modify it under
9/*************************************************************************** 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10 * * 10.="- .-=="i,     .._ License as published by the Free Software
11 * This program is free software; you can redistribute it and/or modify * 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12 * it under the terms of the GNU General Public License as published by * 12     ._= =}       : or (at your option) any later version.
13 * the Free Software Foundation; either version 2 of the License, or * 13    .%`+i>       _;_.
14 * (at your option) any later version. * 14    .i_,=:_.      -<s. This file is distributed in the hope that
15 * * 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16 ***************************************************************************/ 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
17 29
18#include <stdio.h> 30#include <stdio.h>
19#include <sys/vfs.h> 31#include <sys/vfs.h>
20//#include <mntent.h>
21 32
22#include "utils.h" 33#include "utils.h"
23#include "global.h" 34#include "global.h"
24 35
25Utils :: Utils() 36Utils :: Utils()
26{ 37{
27} 38}
28 39
29Utils :: ~Utils() 40Utils :: ~Utils()
30{ 41{
31} 42}
32 43
33
34QString Utils :: getPathfromIpkFilename( const QString &file ) 44QString Utils :: getPathfromIpkFilename( const QString &file )
35{ 45{
36 int p = file.findRev( "/" ); 46 int p = file.findRev( "/" );
37 QString path = ""; 47 QString path = "";
38 if ( p != -1 ) 48 if ( p != -1 )
39 path = file.left( p ); 49 path = file.left( p );
40 50
41 return path; 51 return path;
42 52
43} 53}
44 54
45QString Utils :: getFilenameFromIpkFilename( const QString &file ) 55QString Utils :: getFilenameFromIpkFilename( const QString &file )
46{ 56{
47 int p = file.findRev( "/" ); 57 int p = file.findRev( "/" );
48 QString name = file; 58 QString name = file;
49 if ( p != -1 ) 59 if ( p != -1 )
50 name = name.mid( p + 1 ); 60 name = name.mid( p + 1 );
51 61
52 62
53 return name; 63 return name;
54} 64}
55 65
56QString Utils :: getPackageNameFromIpkFilename( const QString &file ) 66QString Utils :: getPackageNameFromIpkFilename( const QString &file )
57{ 67{
58 int p = file.findRev( "/" ); 68 int p = file.findRev( "/" );
59 QString name = file; 69 QString name = file;
60 if ( p != -1 ) 70 if ( p != -1 )
61 name = name.mid( p + 1 ); 71 name = name.mid( p + 1 );
62 p = name.find( "_" ); 72 p = name.find( "_" );
63 QString packageName = name.mid( 0, p ); 73 QString packageName = name.mid( 0, p );
64 return packageName; 74 return packageName;
65} 75}
66 76
67QString Utils :: getPackageVersionFromIpkFilename( const QString &file ) 77QString Utils :: getPackageVersionFromIpkFilename( const QString &file )
68{ 78{
69 int p = file.findRev( "/" ); 79 int p = file.findRev( "/" );
70 QString name = file; 80 QString name = file;
71 if ( p != -1 ) 81 if ( p != -1 )
72 name = name.mid( p + 1 ); 82 name = name.mid( p + 1 );
73 p = name.find( "_" ) + 1; 83 p = name.find( "_" ) + 1;
74 int p2 = name.find( "_", p ); 84 int p2 = name.find( "_", p );
75 QString version = name.mid( p, p2 - p ); 85 QString version = name.mid( p, p2 - p );
76 return version; 86 return version;
77} 87}
78 88
79 89
80bool Utils :: getStorageSpace( const char *path, long *blockSize, long *totalBlocks, long *availBlocks ) 90bool Utils :: getStorageSpace( const char *path, long *blockSize, long *totalBlocks, long *availBlocks )
81{ 91{
82 bool ret = false; 92 bool ret = false;
83 93
84// qDebug( "Reading from path %s", path );
85 struct statfs fs; 94 struct statfs fs;
86 if ( !statfs( path, &fs ) ) 95 if ( !statfs( path, &fs ) )
87 { 96 {
88 *blockSize = fs.f_bsize; 97 *blockSize = fs.f_bsize;
89 *totalBlocks = fs.f_blocks; 98 *totalBlocks = fs.f_blocks;
90 *availBlocks = fs.f_bavail; 99 *availBlocks = fs.f_bavail;
91 ret = true; 100 ret = true;
92 } 101 }
93 102
94 return ret; 103 return ret;
95} 104}
96 105
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 @@
1/*************************************************************************** 1/*
2 utils.h - description 2                This file is part of the OPIE Project
3 ------------------- 3
4 begin : Sat Sep 7 2002 4 =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
5 copyright : (C) 2002 by Andy Qua 5             .=l. Dan Williams <drw@handhelds.org>
6 email : andy.qua@blueyonder.co.uk 6           .>+-=
7 ***************************************************************************/ 7 _;:,     .>    :=|. This file is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This file is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
8 27
9/*************************************************************************** 28*/
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17 29
18#ifndef UTILS_H 30#ifndef UTILS_H
19#define UTILS_H 31#define UTILS_H
20 32
21#include <qstring.h> 33#include <qstring.h>
22 34
23/** 35/**
24 *@author Andy Qua 36 *@author Andy Qua
25 */ 37 */
26 38
27class Utils { 39class Utils {
28public: 40public:
29 Utils(); 41 Utils();
30 ~Utils(); 42 ~Utils();
31 43
32 static QString getPathfromIpkFilename( const QString &file ); 44 static QString getPathfromIpkFilename( const QString &file );
33 static QString getFilenameFromIpkFilename( const QString &file ); 45 static QString getFilenameFromIpkFilename( const QString &file );
34 static QString getPackageNameFromIpkFilename( const QString &file ); 46 static QString getPackageNameFromIpkFilename( const QString &file );
35 static QString getPackageVersionFromIpkFilename( const QString &file ); 47 static QString getPackageVersionFromIpkFilename( const QString &file );
36 static bool getStorageSpace( const char *path, long *blockSize, long *totalBlocks, long *availBlocks ); 48 static bool getStorageSpace( const char *path, long *blockSize, long *totalBlocks, long *availBlocks );
37}; 49};
38 50
39#endif 51#endif