summaryrefslogtreecommitdiff
authordrw <drw>2004-12-21 00:37:22 (UTC)
committer drw <drw>2004-12-21 00:37:22 (UTC)
commit769f2a09ccfcc639a87600ecb046e9140fe2f691 (patch) (unidiff)
tree27f74b9403d9d41be40e759b7ce238d601b6ef45
parent8c316a01b28879b9f4fc6df736773245c8358ffc (diff)
downloadopie-769f2a09ccfcc639a87600ecb046e9140fe2f691.zip
opie-769f2a09ccfcc639a87600ecb046e9140fe2f691.tar.gz
opie-769f2a09ccfcc639a87600ecb046e9140fe2f691.tar.bz2
Preliminary support for src/gz feeds, it works if you manually update ipkg.conf. Still need to add configuration option on server config dialog tab.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/packagemanager/oconfitem.cpp47
-rw-r--r--noncore/settings/packagemanager/oconfitem.h14
-rw-r--r--noncore/settings/packagemanager/oipkg.cpp17
-rw-r--r--noncore/settings/packagemanager/oipkgconfigdlg.cpp15
4 files changed, 57 insertions, 36 deletions
diff --git a/noncore/settings/packagemanager/oconfitem.cpp b/noncore/settings/packagemanager/oconfitem.cpp
index a90730c..ffa936e 100644
--- a/noncore/settings/packagemanager/oconfitem.cpp
+++ b/noncore/settings/packagemanager/oconfitem.cpp
@@ -1,41 +1,42 @@
1/* 1/*
2                This file is part of the Opie Project 2 This file is part of the Opie Project
3 3
4              Copyright (c) 2003 Dan Williams <drw@handhelds.org> 4 Copyright (c) 2003 Dan Williams <drw@handhelds.org>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7 .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8_;:, .> :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_, > . <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i, .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12- . .-<_> .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13 ._= =} : or (at your option) any later version.
14    .%`+i>       _;_. 14 .%`+i> _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15 .i_,=:_. -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17 : .. .:, . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.= = ; Library General Public License for more
21++=   -.     .`     .: details. 21++= -. .` .: details.
22 :     =  ...= . :.=- 22: = ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23-. .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24 -_. . . )=. = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25 -- :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#include "oconfitem.h" 32#include "oconfitem.h"
33 33
34OConfItem::OConfItem( Type type, const QString &name, 34OConfItem::OConfItem( Type type, const QString &name, const QString &value,
35 const QString &value, bool active ) 35 const QString &features, bool active )
36 : m_type( type ) 36 : m_type( type )
37 , m_name( name ) 37 , m_name( name )
38 , m_value( value ) 38 , m_value( value )
39 , m_features( features )
39 , m_active( active ) 40 , m_active( active )
40{ 41{
41} 42}
diff --git a/noncore/settings/packagemanager/oconfitem.h b/noncore/settings/packagemanager/oconfitem.h
index 7c158c9..9972c00 100644
--- a/noncore/settings/packagemanager/oconfitem.h
+++ b/noncore/settings/packagemanager/oconfitem.h
@@ -1,92 +1,96 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 3
4 Copyright (c) 2003 Dan Williams <drw@handhelds.org> 4 Copyright (c) 2003 Dan Williams <drw@handhelds.org>
5 =. 5 =.
6 .=l. 6 .=l.
7 .>+-= 7 .>+-=
8_;:, .> :=|. This program is free software; you can 8_;:, .> :=|. This program is free software; you can
9.> <`_, > . <= redistribute it and/or modify it under 9.> <`_, > . <= redistribute it and/or modify it under
10:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 10:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
11.="- .-=="i, .._ License as published by the Free Software 11.="- .-=="i, .._ License as published by the Free Software
12- . .-<_> .<> Foundation; either version 2 of the License, 12- . .-<_> .<> Foundation; either version 2 of the License,
13 ._= =} : or (at your option) any later version. 13 ._= =} : or (at your option) any later version.
14 .%`+i> _;_. 14 .%`+i> _;_.
15 .i_,=:_. -<s. This program is distributed in the hope that 15 .i_,=:_. -<s. This program is distributed in the hope that
16 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 16 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
17 : .. .:, . . . without even the implied warranty of 17 : .. .:, . . . without even the implied warranty of
18 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 18 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
19 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 19 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.= = ; Library General Public License for more 20..}^=.= = ; Library General Public License for more
21++= -. .` .: details. 21++= -. .` .: details.
22: = ...= . :.=- 22: = ...= . :.=-
23-. .:....=;==+<; You should have received a copy of the GNU 23-. .:....=;==+<; You should have received a copy of the GNU
24 -_. . . )=. = Library General Public License along with 24 -_. . . )=. = Library General Public License along with
25 -- :-=` this library; see the file COPYING.LIB. 25 -- :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#ifndef OCONFITEM_H 32#ifndef OCONFITEM_H
33#define OCONFITEM_H 33#define OCONFITEM_H
34 34
35#include <qlist.h> 35#include <qlist.h>
36#include <qstring.h> 36#include <qstring.h>
37 37
38class OConfItem 38class OConfItem
39{ 39{
40public: 40public:
41 enum Type { Source, Destination, Option, Arch, NotDefined }; 41 enum Type { Source, Destination, Option, Arch, NotDefined };
42 42
43 OConfItem( Type type = NotDefined, const QString &name = QString::null, 43 OConfItem( Type type = NotDefined, const QString &name = QString::null,
44 const QString &value = QString::null, bool active = true ); 44 const QString &value = QString::null, const QString &features = QString::null,
45 bool active = true );
45 46
46 Type type() { return m_type; } 47 Type type() { return m_type; }
47 const QString &name() { return m_name; } 48 const QString &name() { return m_name; }
48 const QString &value() { return m_value; } 49 const QString &value() { return m_value; }
50 const QString &features() { return m_features; }
49 bool active() { return m_active; } 51 bool active() { return m_active; }
50 52
51 void setType( Type type ) { m_type = type; } 53 void setType( Type type ) { m_type = type; }
52 void setName( const QString &name ) { m_name = name; } 54 void setName( const QString &name ) { m_name = name; }
53 void setValue( const QString &value ) { m_value = value; } 55 void setValue( const QString &value ) { m_value = value; }
54 void setActive( bool active ) { m_active = active; } 56 void setFeatures( const QString &features ) { m_features = features; }
57 void setActive( bool active ) { m_active = active; }
55 58
56private: 59private:
57 Type m_type; // Type of configuration item 60 Type m_type; // Type of configuration item
58 QString m_name; // Name of item 61 QString m_name; // Name of item
59 QString m_value; // Value of item 62 QString m_value; // Value of item
63 QString m_features; // Comma-deliminated list of features this item supports
60 bool m_active; // Indicates whether item is currently active 64 bool m_active; // Indicates whether item is currently active
61}; 65};
62 66
63class OConfItemList : public QList<OConfItem> 67class OConfItemList : public QList<OConfItem>
64{ 68{
65private: 69private:
66 70
67 int compareItems( QCollection::Item item1, QCollection::Item item2 ) 71 int compareItems( QCollection::Item item1, QCollection::Item item2 )
68 { 72 {
69 // Sort by OConfItem location then by type 73 // Sort by OConfItem location then by type
70 OConfItem::Type type1 = reinterpret_cast<OConfItem*>(item1)->type(); 74 OConfItem::Type type1 = reinterpret_cast<OConfItem*>(item1)->type();
71 OConfItem::Type type2 = reinterpret_cast<OConfItem*>(item2)->type(); 75 OConfItem::Type type2 = reinterpret_cast<OConfItem*>(item2)->type();
72 if ( type1 < type2 ) 76 if ( type1 < type2 )
73 return -1; 77 return -1;
74 else if ( type1 == type2 ) 78 else if ( type1 == type2 )
75 { 79 {
76 QString name1 = reinterpret_cast<OConfItem*>(item1)->name(); 80 QString name1 = reinterpret_cast<OConfItem*>(item1)->name();
77 QString name2 = reinterpret_cast<OConfItem*>(item2)->name(); 81 QString name2 = reinterpret_cast<OConfItem*>(item2)->name();
78 if ( name1 < name2 ) 82 if ( name1 < name2 )
79 return -1; 83 return -1;
80 else if ( name1 == name2 ) 84 else if ( name1 == name2 )
81 return 0; 85 return 0;
82 else /*if ( name1 > name2 )*/ 86 else /*if ( name1 > name2 )*/
83 return 1; 87 return 1;
84 } 88 }
85 else /*if ( type1 > type2 )*/ 89 else /*if ( type1 > type2 )*/
86 return 1; 90 return 1;
87 } 91 }
88}; 92};
89 93
90typedef QListIterator<OConfItem> OConfItemListIterator; 94typedef QListIterator<OConfItem> OConfItemListIterator;
91 95
92#endif 96#endif
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp
index b0cc94d..a66bd51 100644
--- a/noncore/settings/packagemanager/oipkg.cpp
+++ b/noncore/settings/packagemanager/oipkg.cpp
@@ -1,578 +1,591 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 3
4 Copyright (c) 2003 Dan Williams <drw@handhelds.org> 4 Copyright (c) 2003 Dan Williams <drw@handhelds.org>
5 =. 5 =.
6 .=l. 6 .=l.
7 .>+-= 7 .>+-=
8_;:, .> :=|. This program is free software; you can 8_;:, .> :=|. This program is free software; you can
9.> <`_, > . <= redistribute it and/or modify it under 9.> <`_, > . <= redistribute it and/or modify it under
10:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 10:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
11.="- .-=="i, .._ License as published by the Free Software 11.="- .-=="i, .._ License as published by the Free Software
12- . .-<_> .<> Foundation; either version 2 of the License, 12- . .-<_> .<> Foundation; either version 2 of the License,
13 ._= =} : or (at your option) any later version. 13 ._= =} : or (at your option) any later version.
14 .%`+i> _;_. 14 .%`+i> _;_.
15 .i_,=:_. -<s. This program is distributed in the hope that 15 .i_,=:_. -<s. This program is distributed in the hope that
16 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 16 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
17 : .. .:, . . . without even the implied warranty of 17 : .. .:, . . . without even the implied warranty of
18 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 18 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
19 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 19 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.= = ; Library General Public License for more 20..}^=.= = ; Library General Public License for more
21++= -. .` .: details. 21++= -. .` .: details.
22: = ...= . :.=- 22: = ...= . :.=-
23-. .:....=;==+<; You should have received a copy of the GNU 23-. .:....=;==+<; You should have received a copy of the GNU
24 -_. . . )=. = Library General Public License along with 24 -_. . . )=. = Library General Public License along with
25 -- :-=` this library; see the file COPYING.LIB. 25 -- :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#include "oipkg.h" 32#include "oipkg.h"
33 33
34#include <qdir.h> 34#include <qdir.h>
35#include <qfile.h> 35#include <qfile.h>
36#include <qtextstream.h> 36#include <qtextstream.h>
37 37
38#include <stdlib.h> 38#include <stdlib.h>
39 39
40const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file 40const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file
41const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files 41const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files
42const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists 42const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists
43const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location 43const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location
44 44
45OIpkg *oipkg; 45OIpkg *oipkg;
46 46
47// Ipkg callback functions 47// Ipkg callback functions
48 48
49int fsignalIpkgMessage( ipkg_conf_t *conf, message_level_t level, char *msg ) 49int fsignalIpkgMessage( ipkg_conf_t *conf, message_level_t level, char *msg )
50{ 50{
51 if ( conf && ( conf->verbosity < level ) ) 51 if ( conf && ( conf->verbosity < level ) )
52 return 0; 52 return 0;
53 else 53 else
54 oipkg->ipkgMessage( msg ); 54 oipkg->ipkgMessage( msg );
55 55
56 return 0; 56 return 0;
57} 57}
58 58
59char *fIpkgResponse( char */*question*/ ) 59char *fIpkgResponse( char */*question*/ )
60{ 60{
61 return 0x0; 61 return 0x0;
62} 62}
63 63
64int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ ) 64int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ )
65{ 65{
66 oipkg->ipkgStatus( desc ); 66 oipkg->ipkgStatus( desc );
67 return 0; 67 return 0;
68} 68}
69 69
70int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/, 70int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/,
71 void */*userdata*/ ) 71 void */*userdata*/ )
72{ 72{
73 oipkg->ipkgList( desc ); 73 oipkg->ipkgList( desc );
74 return 0; 74 return 0;
75} 75}
76 76
77OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) 77OIpkg::OIpkg( Config *config, QObject *parent, const char *name )
78 : QObject( parent, name ) 78 : QObject( parent, name )
79 , m_config( config ) 79 , m_config( config )
80 , m_confInfo( NULL ) 80 , m_confInfo( NULL )
81 , m_ipkgExecOptions( 0 ) 81 , m_ipkgExecOptions( 0 )
82 , m_ipkgExecVerbosity( 1 ) 82 , m_ipkgExecVerbosity( 1 )
83{ 83{
84 oipkg = this; 84 oipkg = this;
85 85
86 // Initialize libipkg 86 // Initialize libipkg
87 ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); 87 ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs );
88 88
89 // Default ipkg run-time arguments 89 // Default ipkg run-time arguments
90 m_ipkgArgs.noaction = false; 90 m_ipkgArgs.noaction = false;
91 m_ipkgArgs.force_defaults = true; 91 m_ipkgArgs.force_defaults = true;
92} 92}
93 93
94OIpkg::~OIpkg() 94OIpkg::~OIpkg()
95{ 95{
96 // Upon destruction, ensure that items in config list are deleted with list 96 // Upon destruction, ensure that items in config list are deleted with list
97 if ( m_confInfo ) 97 if ( m_confInfo )
98 m_confInfo->setAutoDelete( true ); 98 m_confInfo->setAutoDelete( true );
99 99
100 // Free up libipkg resources 100 // Free up libipkg resources
101 ipkg_deinit( &m_ipkgArgs ); 101 ipkg_deinit( &m_ipkgArgs );
102} 102}
103 103
104OConfItemList *OIpkg::configItems() 104OConfItemList *OIpkg::configItems()
105{ 105{
106 // Retrieve all configuration items 106 // Retrieve all configuration items
107 return filterConfItems(); 107 return filterConfItems();
108} 108}
109 109
110OConfItemList *OIpkg::servers() 110OConfItemList *OIpkg::servers()
111{ 111{
112 // Retrieve only servers 112 // Retrieve only servers
113 return filterConfItems( OConfItem::Source ); 113 return filterConfItems( OConfItem::Source );
114} 114}
115 115
116OConfItemList *OIpkg::destinations() 116OConfItemList *OIpkg::destinations()
117{ 117{
118 // Retrieve only destinations 118 // Retrieve only destinations
119 return filterConfItems( OConfItem::Destination ); 119 return filterConfItems( OConfItem::Destination );
120} 120}
121 121
122OConfItemList *OIpkg::options() 122OConfItemList *OIpkg::options()
123{ 123{
124 // Retrieve only destinations 124 // Retrieve only destinations
125 return filterConfItems( OConfItem::Option ); 125 return filterConfItems( OConfItem::Option );
126} 126}
127 127
128void OIpkg::setConfigItems( OConfItemList *configList ) 128void OIpkg::setConfigItems( OConfItemList *configList )
129{ 129{
130 if ( m_confInfo ) 130 if ( m_confInfo )
131 delete m_confInfo; 131 delete m_confInfo;
132 132
133 m_confInfo = configList; 133 m_confInfo = configList;
134 134
135 // Write out new /etc/ipkg.conf 135 // Write out new /etc/ipkg.conf
136 QFile confFile( IPKG_CONF ); 136 QFile confFile( IPKG_CONF );
137 if ( confFile.open( IO_WriteOnly ) ) 137 if ( confFile.open( IO_WriteOnly ) )
138 { 138 {
139 QTextStream confStream( &confFile ); 139 QTextStream confStream( &confFile );
140 confStream << "# Generated by Opie Package Manager\n\n"; 140 confStream << "# Generated by Opie Package Manager\n\n";
141 141
142 OConfItemListIterator it( *m_confInfo ); 142 OConfItemListIterator it( *m_confInfo );
143 for ( ; it.current(); ++it ) 143 for ( ; it.current(); ++it )
144 { 144 {
145 OConfItem *item = it.current(); 145 OConfItem *item = it.current();
146 146
147 // Only write out valid conf items 147 // Only write out valid conf items
148 if ( item->type() != OConfItem::NotDefined ) 148 if ( item->type() != OConfItem::NotDefined )
149 { 149 {
150 QString confLine; 150 QString confLine;
151 if ( !item->active() ) 151 if ( !item->active() )
152 confLine = "#"; 152 confLine = "#";
153 153
154 switch ( item->type() ) 154 switch ( item->type() )
155 { 155 {
156 case OConfItem::Source : confLine.append( "src " ); break; 156 case OConfItem::Source :
157 {
158 if ( item->features().contains( "Compressed" ) )
159 confLine.append( "src/gz " );
160 else
161 confLine.append( "src " );
162 }
163 break;
157 case OConfItem::Destination : confLine.append( "dest " ); break; 164 case OConfItem::Destination : confLine.append( "dest " ); break;
158 case OConfItem::Option : confLine.append( "option " ); break; 165 case OConfItem::Option : confLine.append( "option " ); break;
159 case OConfItem::Arch : confLine.append( "arch " ); break; 166 case OConfItem::Arch : confLine.append( "arch " ); break;
160 default : break; 167 default : break;
161 }; 168 };
162 169
163 confStream << confLine << " " << item->name() << " " << item->value() << "\n"; 170 confStream << confLine << " " << item->name() << " " << item->value() << "\n";
164 } 171 }
165 } 172 }
166 173
167 confFile.close(); 174 confFile.close();
168 } 175 }
169 else 176 else
170 { 177 {
171 // Problem writing to /etc/ipkg.conf, exit before removing other conf files 178 // Problem writing to /etc/ipkg.conf, exit before removing other conf files
172 return; 179 return;
173 } 180 }
174 181
175 // Delete /etc/ipkg/*.conf files (/etc/ipkg.conf should now have all settings 182 // Delete /etc/ipkg/*.conf files (/etc/ipkg.conf should now have all settings
176 QStringList confFiles; 183 QStringList confFiles;
177 QDir confDir( IPKG_CONF_DIR ); 184 QDir confDir( IPKG_CONF_DIR );
178 if ( confDir.exists() ) 185 if ( confDir.exists() )
179 { 186 {
180 confDir.setNameFilter( "*.conf" ); 187 confDir.setNameFilter( "*.conf" );
181 confDir.setFilter( QDir::Files ); 188 confDir.setFilter( QDir::Files );
182 confFiles = confDir.entryList( "*.conf", QDir::Files ); 189 confFiles = confDir.entryList( "*.conf", QDir::Files );
183 190
184 QStringList::Iterator lastFile = confFiles.end(); 191 QStringList::Iterator lastFile = confFiles.end();
185 for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) 192 for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it )
186 { 193 {
187 // Create absolute file path if necessary 194 // Create absolute file path if necessary
188 QString absFile = (*it); 195 QString absFile = (*it);
189 if ( !absFile.startsWith( "/" ) ) 196 if ( !absFile.startsWith( "/" ) )
190 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); 197 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" );
191 198
192 // Delete file 199 // Delete file
193 QFile::remove( absFile ); 200 QFile::remove( absFile );
194 } 201 }
195 } 202 }
196 203
197 // Reinitialize libipkg to pick up new configuration 204 // Reinitialize libipkg to pick up new configuration
198 ipkg_deinit( &m_ipkgArgs ); 205 ipkg_deinit( &m_ipkgArgs );
199 ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); 206 ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs );
200 m_ipkgArgs.noaction = false; 207 m_ipkgArgs.noaction = false;
201 m_ipkgArgs.force_defaults = true; 208 m_ipkgArgs.force_defaults = true;
202} 209}
203 210
204void OIpkg::saveSettings() 211void OIpkg::saveSettings()
205{ 212{
206 // Save Ipkg execution options to application configuration file 213 // Save Ipkg execution options to application configuration file
207 if ( m_config ) 214 if ( m_config )
208 { 215 {
209 m_config->setGroup( "Ipkg" ); 216 m_config->setGroup( "Ipkg" );
210 m_config->writeEntry( "ExecOptions", m_ipkgExecOptions ); 217 m_config->writeEntry( "ExecOptions", m_ipkgExecOptions );
211 m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity ); 218 m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity );
212 } 219 }
213} 220}
214 221
215OPackageList *OIpkg::availablePackages( const QString &server ) 222OPackageList *OIpkg::availablePackages( const QString &server )
216{ 223{
217 // Load Ipkg configuration info if not already cached 224 // Load Ipkg configuration info if not already cached
218 if ( !m_confInfo ) 225 if ( !m_confInfo )
219 loadConfiguration(); 226 loadConfiguration();
220 227
221 // Build new server list (caller is responsible for deleting) 228 // Build new server list (caller is responsible for deleting)
222 OPackageList *pl = new OPackageList; 229 OPackageList *pl = new OPackageList;
223 230
224 // Open package list file 231 // Open package list file
225 QFile f( IPKG_PKG_PATH + "/" + server ); 232 QFile f( IPKG_PKG_PATH + "/" + server );
226 if ( !f.open( IO_ReadOnly ) ) 233 if ( !f.open( IO_ReadOnly ) )
227 return NULL; 234 return NULL;
228 QTextStream t( &f ); 235 QTextStream t( &f );
229 236
230 // Process all information in package list file 237 // Process all information in package list file
231 OPackage *package = NULL; 238 OPackage *package = NULL;
232 QString line = t.readLine(); 239 QString line = t.readLine();
233 while ( !t.eof() ) 240 while ( !t.eof() )
234 { 241 {
235 // Determine key/value pair 242 // Determine key/value pair
236 int pos = line.find( ':', 0 ); 243 int pos = line.find( ':', 0 );
237 QString key; 244 QString key;
238 if ( pos > -1 ) 245 if ( pos > -1 )
239 key = line.mid( 0, pos ); 246 key = line.mid( 0, pos );
240 else 247 else
241 key = QString::null; 248 key = QString::null;
242 QString value = line.mid( pos+2, line.length()-pos ); 249 QString value = line.mid( pos+2, line.length()-pos );
243 250
244 // Allocate new package and insert into list 251 // Allocate new package and insert into list
245 if ( package == NULL && !key.isEmpty() ) 252 if ( package == NULL && !key.isEmpty() )
246 { 253 {
247 package = new OPackage( value ); 254 package = new OPackage( value );
248 package->setSource( server ); 255 package->setSource( server );
249 pl->append( package ); 256 pl->append( package );
250 } 257 }
251 258
252 // Update package data 259 // Update package data
253 if ( key == "Package" ) 260 if ( key == "Package" )
254 package->setName( value ); 261 package->setName( value );
255 else if ( key == "Version" ) 262 else if ( key == "Version" )
256 package->setVersion( value ); 263 package->setVersion( value );
257 else if ( key == "Section" ) 264 else if ( key == "Section" )
258 package->setCategory( value ); 265 package->setCategory( value );
259 //DataManager::setAvailableCategories( value ); 266 //DataManager::setAvailableCategories( value );
260 else if ( key.isEmpty() && value.isEmpty() ) 267 else if ( key.isEmpty() && value.isEmpty() )
261 package = NULL; 268 package = NULL;
262 269
263 // Skip past all description lines 270 // Skip past all description lines
264 if ( key == "Description" ) 271 if ( key == "Description" )
265 { 272 {
266 line = t.readLine(); 273 line = t.readLine();
267 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) 274 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() )
268 line = t.readLine(); 275 line = t.readLine();
269 } 276 }
270 else 277 else
271 line = t.readLine(); 278 line = t.readLine();
272 } 279 }
273 280
274 f.close(); 281 f.close();
275 282
276 return pl; 283 return pl;
277} 284}
278 285
279OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath ) 286OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath )
280{ 287{
281 // Load Ipkg configuration info if not already cached 288 // Load Ipkg configuration info if not already cached
282 if ( !m_confInfo ) 289 if ( !m_confInfo )
283 loadConfiguration(); 290 loadConfiguration();
284 291
285 // Build new server list (caller is responsible for deleting) 292 // Build new server list (caller is responsible for deleting)
286 OPackageList *pl = new OPackageList; 293 OPackageList *pl = new OPackageList;
287 294
288 // Open status file 295 // Open status file
289 QString path = destPath; 296 QString path = destPath;
290 if ( path.right( 1 ) != "/" ) 297 if ( path.right( 1 ) != "/" )
291 path.append( "/" ); 298 path.append( "/" );
292 path.append( IPKG_STATUS_PATH ); 299 path.append( IPKG_STATUS_PATH );
293 300
294 QFile f( path ); 301 QFile f( path );
295 if ( !f.open( IO_ReadOnly ) ) 302 if ( !f.open( IO_ReadOnly ) )
296 return NULL; 303 return NULL;
297 QTextStream t( &f ); 304 QTextStream t( &f );
298 305
299 // Process all information in status file 306 // Process all information in status file
300 bool newPackage = false; 307 bool newPackage = false;
301 QString line = t.readLine(); 308 QString line = t.readLine();
302 QString name; 309 QString name;
303 QString version; 310 QString version;
304 QString status; 311 QString status;
305 312
306 while ( !t.eof() ) 313 while ( !t.eof() )
307 { 314 {
308 // Determine key/value pair 315 // Determine key/value pair
309 int pos = line.find( ':', 0 ); 316 int pos = line.find( ':', 0 );
310 QString key; 317 QString key;
311 if ( pos > -1 ) 318 if ( pos > -1 )
312 key = line.mid( 0, pos ); 319 key = line.mid( 0, pos );
313 else 320 else
314 key = QString::null; 321 key = QString::null;
315 QString value = line.mid( pos+2, line.length()-pos ); 322 QString value = line.mid( pos+2, line.length()-pos );
316 323
317 // Allocate new package and insert into list 324 // Allocate new package and insert into list
318 if ( newPackage && !key.isEmpty() ) 325 if ( newPackage && !key.isEmpty() )
319 { 326 {
320 // Add to list only if it has a valid name and is installed 327 // Add to list only if it has a valid name and is installed
321 if ( !name.isNull() && status.contains( " installed" ) ) 328 if ( !name.isNull() && status.contains( " installed" ) )
322 { 329 {
323 pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); 330 pl->append( new OPackage( name, QString::null, version, QString::null, destName ) );
324 name = QString::null; 331 name = QString::null;
325 version = QString::null; 332 version = QString::null;
326 status = QString::null; 333 status = QString::null;
327 334
328 newPackage = false; 335 newPackage = false;
329 } 336 }
330 } 337 }
331 338
332 // Update package data 339 // Update package data
333 if ( key == "Package" ) 340 if ( key == "Package" )
334 name = value; 341 name = value;
335 else if ( key == "Version" ) 342 else if ( key == "Version" )
336 version = value; 343 version = value;
337 else if ( key == "Status" ) 344 else if ( key == "Status" )
338 status = value; 345 status = value;
339 else if ( key.isEmpty() && value.isEmpty() ) 346 else if ( key.isEmpty() && value.isEmpty() )
340 newPackage = true; 347 newPackage = true;
341 348
342 // Skip past all description lines 349 // Skip past all description lines
343 if ( key == "Description" ) 350 if ( key == "Description" )
344 { 351 {
345 line = t.readLine(); 352 line = t.readLine();
346 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) 353 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() )
347 line = t.readLine(); 354 line = t.readLine();
348 } 355 }
349 else 356 else
350 line = t.readLine(); 357 line = t.readLine();
351 } 358 }
352 359
353 f.close(); 360 f.close();
354 361
355 return pl; 362 return pl;
356} 363}
357 364
358bool OIpkg::executeCommand( OPackage::Command command, const QStringList &parameters, const QString &destination, 365bool OIpkg::executeCommand( OPackage::Command command, const QStringList &parameters, const QString &destination,
359 const QObject *receiver, const char *slotOutput, bool rawOutput ) 366 const QObject *receiver, const char *slotOutput, bool rawOutput )
360{ 367{
361 if ( command == OPackage::NotDefined ) 368 if ( command == OPackage::NotDefined )
362 return false; 369 return false;
363 370
364 // Set ipkg run-time options/arguments 371 // Set ipkg run-time options/arguments
365 m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS ); 372 m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS );
366 m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL ); 373 m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL );
367 // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE ); 374 // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE );
368 m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE ); 375 m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE );
369 m_ipkgArgs.verbosity = m_ipkgExecVerbosity; 376 m_ipkgArgs.verbosity = m_ipkgExecVerbosity;
370 if ( m_ipkgArgs.dest ) 377 if ( m_ipkgArgs.dest )
371 free( m_ipkgArgs.dest ); 378 free( m_ipkgArgs.dest );
372 if ( !destination.isNull() ) 379 if ( !destination.isNull() )
373 { 380 {
374 int len = destination.length() + 1; 381 int len = destination.length() + 1;
375 m_ipkgArgs.dest = (char *)malloc( len ); 382 m_ipkgArgs.dest = (char *)malloc( len );
376 strncpy( m_ipkgArgs.dest, destination, destination.length() ); 383 strncpy( m_ipkgArgs.dest, destination, destination.length() );
377 m_ipkgArgs.dest[ len - 1 ] = '\0'; 384 m_ipkgArgs.dest[ len - 1 ] = '\0';
378 } 385 }
379 else 386 else
380 m_ipkgArgs.dest = 0x0; 387 m_ipkgArgs.dest = 0x0;
381 388
382 // Connect output signal to widget 389 // Connect output signal to widget
383 390
384 if ( rawOutput ) 391 if ( rawOutput )
385 { 392 {
386// if ( slotOutput ) 393// if ( slotOutput )
387// connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); 394// connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
388 } 395 }
389 else 396 else
390 { 397 {
391 // TODO - connect to local slot and parse output before emitting signalIpkgMessage 398 // TODO - connect to local slot and parse output before emitting signalIpkgMessage
392 } 399 }
393 400
394 switch( command ) 401 switch( command )
395 { 402 {
396 case OPackage::Update : { 403 case OPackage::Update : {
397 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); 404 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
398 ipkg_lists_update( &m_ipkgArgs ); 405 ipkg_lists_update( &m_ipkgArgs );
399 }; 406 };
400 break; 407 break;
401 case OPackage::Upgrade : { 408 case OPackage::Upgrade : {
402 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); 409 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
403 ipkg_packages_upgrade( &m_ipkgArgs ); 410 ipkg_packages_upgrade( &m_ipkgArgs );
404 }; 411 };
405 break; 412 break;
406 case OPackage::Install : { 413 case OPackage::Install : {
407 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); 414 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
408 for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) 415 for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it )
409 { 416 {
410 ipkg_packages_install( &m_ipkgArgs, (*it) ); 417 ipkg_packages_install( &m_ipkgArgs, (*it) );
411 } 418 }
412 }; 419 };
413 break; 420 break;
414 case OPackage::Remove : { 421 case OPackage::Remove : {
415 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); 422 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
416 for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) 423 for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it )
417 { 424 {
418 ipkg_packages_remove( &m_ipkgArgs, (*it), true ); 425 ipkg_packages_remove( &m_ipkgArgs, (*it), true );
419 } 426 }
420 }; 427 };
421 break; 428 break;
422 case OPackage::Download : { 429 case OPackage::Download : {
423 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); 430 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
424 for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) 431 for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it )
425 { 432 {
426 ipkg_packages_download( &m_ipkgArgs, (*it) ); 433 ipkg_packages_download( &m_ipkgArgs, (*it) );
427 } 434 }
428 }; 435 };
429 break; 436 break;
430 case OPackage::Info : { 437 case OPackage::Info : {
431 connect( this, SIGNAL(signalIpkgStatus(char*)), receiver, slotOutput ); 438 connect( this, SIGNAL(signalIpkgStatus(char*)), receiver, slotOutput );
432 ipkg_packages_info( &m_ipkgArgs, (*parameters.begin()), &fIpkgStatus, 0x0 ); 439 ipkg_packages_info( &m_ipkgArgs, (*parameters.begin()), &fIpkgStatus, 0x0 );
433 }; 440 };
434 break; 441 break;
435 case OPackage::Files : { 442 case OPackage::Files : {
436 connect( this, SIGNAL(signalIpkgList(char*)), receiver, slotOutput ); 443 connect( this, SIGNAL(signalIpkgList(char*)), receiver, slotOutput );
437 ipkg_package_files( &m_ipkgArgs, (*parameters.begin()), &fIpkgFiles, 0x0 ); 444 ipkg_package_files( &m_ipkgArgs, (*parameters.begin()), &fIpkgFiles, 0x0 );
438 }; 445 };
439 break; 446 break;
440 default : break; 447 default : break;
441 }; 448 };
442 449
443 return true; 450 return true;
444} 451}
445 452
446void OIpkg::ipkgMessage( char *msg ) 453void OIpkg::ipkgMessage( char *msg )
447{ 454{
448 emit signalIpkgMessage( msg ); 455 emit signalIpkgMessage( msg );
449} 456}
450 457
451void OIpkg::ipkgStatus( char *status ) 458void OIpkg::ipkgStatus( char *status )
452{ 459{
453 emit signalIpkgStatus( status ); 460 emit signalIpkgStatus( status );
454} 461}
455 462
456void OIpkg::ipkgList( char *filelist ) 463void OIpkg::ipkgList( char *filelist )
457{ 464{
458 emit signalIpkgList( filelist ); 465 emit signalIpkgList( filelist );
459} 466}
460 467
461void OIpkg::loadConfiguration() 468void OIpkg::loadConfiguration()
462{ 469{
463 if ( m_confInfo ) 470 if ( m_confInfo )
464 delete m_confInfo; 471 delete m_confInfo;
465 472
466 // Load configuration item list 473 // Load configuration item list
467 m_confInfo = new OConfItemList(); 474 m_confInfo = new OConfItemList();
468 475
469 QStringList confFiles; 476 QStringList confFiles;
470 QDir confDir( IPKG_CONF_DIR ); 477 QDir confDir( IPKG_CONF_DIR );
471 if ( confDir.exists() ) 478 if ( confDir.exists() )
472 { 479 {
473 confDir.setNameFilter( "*.conf" ); 480 confDir.setNameFilter( "*.conf" );
474 confDir.setFilter( QDir::Files ); 481 confDir.setFilter( QDir::Files );
475 confFiles = confDir.entryList( "*.conf", QDir::Files ); 482 confFiles = confDir.entryList( "*.conf", QDir::Files );
476 } 483 }
477 confFiles << IPKG_CONF; 484 confFiles << IPKG_CONF;
478 485
479 QStringList::Iterator lastFile = confFiles.end(); 486 QStringList::Iterator lastFile = confFiles.end();
480 for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) 487 for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it )
481 { 488 {
482 // Create absolute file path if necessary 489 // Create absolute file path if necessary
483 QString absFile = (*it); 490 QString absFile = (*it);
484 if ( !absFile.startsWith( "/" ) ) 491 if ( !absFile.startsWith( "/" ) )
485 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); 492 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" );
486 493
487 // Read in file 494 // Read in file
488 QFile f( absFile ); 495 QFile f( absFile );
489 if ( f.open( IO_ReadOnly ) ) 496 if ( f.open( IO_ReadOnly ) )
490 { 497 {
491 QTextStream s( &f ); 498 QTextStream s( &f );
492 while ( !s.eof() ) 499 while ( !s.eof() )
493 { 500 {
494 501
495 QString line = s.readLine().simplifyWhiteSpace(); 502 QString line = s.readLine().simplifyWhiteSpace();
496 503
497 // Parse line and save info to the conf options list 504 // Parse line and save info to the conf options list
498 if ( !line.isEmpty() ) 505 if ( !line.isEmpty() )
499 { 506 {
500 if ( !line.startsWith( "#" ) || 507 if ( !line.startsWith( "#" ) ||
501 line.startsWith( "#src" ) || 508 line.startsWith( "#src" ) ||
502 line.startsWith( "#dest" ) || 509 line.startsWith( "#dest" ) ||
503 line.startsWith( "#arch" ) || 510 line.startsWith( "#arch" ) ||
504 line.startsWith( "#option" ) ) 511 line.startsWith( "#option" ) )
505 { 512 {
506 int pos = line.find( ' ', 1 ); 513 int pos = line.find( ' ', 1 );
507 514
508 // Type 515 // Type
509 QString typeStr = line.left( pos ); 516 QString typeStr = line.left( pos );
510 OConfItem::Type type; 517 OConfItem::Type type;
518 QString features;
511 if ( typeStr == "src" || typeStr == "#src" ) 519 if ( typeStr == "src" || typeStr == "#src" )
512 type = OConfItem::Source; 520 type = OConfItem::Source;
521 else if ( typeStr == "src/gz" || typeStr == "#src/gz" )
522 {
523 type = OConfItem::Source;
524 features = "Compressed";
525 }
513 else if ( typeStr == "dest" || typeStr == "#dest" ) 526 else if ( typeStr == "dest" || typeStr == "#dest" )
514 type = OConfItem::Destination; 527 type = OConfItem::Destination;
515 else if ( typeStr == "option" || typeStr == "#option" ) 528 else if ( typeStr == "option" || typeStr == "#option" )
516 type = OConfItem::Option; 529 type = OConfItem::Option;
517 else if ( typeStr == "arch" || typeStr == "#arch" ) 530 else if ( typeStr == "arch" || typeStr == "#arch" )
518 type = OConfItem::Arch; 531 type = OConfItem::Arch;
519 else 532 else
520 type = OConfItem::NotDefined; 533 type = OConfItem::NotDefined;
521 ++pos; 534 ++pos;
522 int endpos = line.find( ' ', pos ); 535 int endpos = line.find( ' ', pos );
523 536
524 // Name 537 // Name
525 QString name = line.mid( pos, endpos - pos ); 538 QString name = line.mid( pos, endpos - pos );
526 539
527 // Value 540 // Value
528 QString value = ""; 541 QString value = "";
529 if ( endpos > -1 ) 542 if ( endpos > -1 )
530 value = line.right( line.length() - endpos - 1 ); 543 value = line.right( line.length() - endpos - 1 );
531 544
532 // Active 545 // Active
533 bool active = !line.startsWith( "#" ); 546 bool active = !line.startsWith( "#" );
534 547
535 // Add to list 548 // Add to list
536 m_confInfo->append( new OConfItem( type, name, value, active ) ); 549 m_confInfo->append( new OConfItem( type, name, value, features, active ) );
537 } 550 }
538 } 551 }
539 } 552 }
540 553
541 f.close(); 554 f.close();
542 } 555 }
543 } 556 }
544 557
545 // Load Ipkg execution options from application configuration file 558 // Load Ipkg execution options from application configuration file
546 if ( m_config ) 559 if ( m_config )
547 { 560 {
548 m_config->setGroup( "Ipkg" ); 561 m_config->setGroup( "Ipkg" );
549 m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions ); 562 m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions );
550 m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity ); 563 m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity );
551 } 564 }
552} 565}
553 566
554OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter ) 567OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter )
555{ 568{
556 // Load Ipkg configuration info if not already cached 569 // Load Ipkg configuration info if not already cached
557 if ( !m_confInfo ) 570 if ( !m_confInfo )
558 loadConfiguration(); 571 loadConfiguration();
559 572
560 // Build new server list (caller is responsible for deleting) 573 // Build new server list (caller is responsible for deleting)
561 OConfItemList *sl = new OConfItemList; 574 OConfItemList *sl = new OConfItemList;
562 575
563 // If typefilter is empty, retrieve all items 576 // If typefilter is empty, retrieve all items
564 bool retrieveAll = ( typefilter == OConfItem::NotDefined ); 577 bool retrieveAll = ( typefilter == OConfItem::NotDefined );
565 578
566 // Parse configuration info for servers 579 // Parse configuration info for servers
567 OConfItemListIterator it( *m_confInfo ); 580 OConfItemListIterator it( *m_confInfo );
568 for ( ; it.current(); ++it ) 581 for ( ; it.current(); ++it )
569 { 582 {
570 OConfItem *item = it.current(); 583 OConfItem *item = it.current();
571 if ( retrieveAll || item->type() == typefilter ) 584 if ( retrieveAll || item->type() == typefilter )
572 { 585 {
573 sl->append( item ); 586 sl->append( item );
574 } 587 }
575 } 588 }
576 589
577 return sl; 590 return sl;
578} 591}
diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.cpp b/noncore/settings/packagemanager/oipkgconfigdlg.cpp
index 886430f..d9a67f3 100644
--- a/noncore/settings/packagemanager/oipkgconfigdlg.cpp
+++ b/noncore/settings/packagemanager/oipkgconfigdlg.cpp
@@ -1,306 +1,308 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 3
4 Copyright (c) 2003 Dan Williams <drw@handhelds.org> 4 Copyright (c) 2003 Dan Williams <drw@handhelds.org>
5 =. 5 =.
6 .=l. 6 .=l.
7 .>+-= 7 .>+-=
8_;:, .> :=|. This program is free software; you can 8_;:, .> :=|. This program is free software; you can
9.> <`_, > . <= redistribute it and/or modify it under 9.> <`_, > . <= redistribute it and/or modify it under
10:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 10:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
11.="- .-=="i, .._ License as published by the Free Software 11.="- .-=="i, .._ License as published by the Free Software
12- . .-<_> .<> Foundation; either version 2 of the License, 12- . .-<_> .<> Foundation; either version 2 of the License,
13 ._= =} : or (at your option) any later version. 13 ._= =} : or (at your option) any later version.
14 .%`+i> _;_. 14 .%`+i> _;_.
15 .i_,=:_. -<s. This program is distributed in the hope that 15 .i_,=:_. -<s. This program is distributed in the hope that
16 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 16 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
17 : .. .:, . . . without even the implied warranty of 17 : .. .:, . . . without even the implied warranty of
18 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 18 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
19 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 19 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.= = ; Library General Public License for more 20..}^=.= = ; Library General Public License for more
21++= -. .` .: details. 21++= -. .` .: details.
22: = ...= . :.=- 22: = ...= . :.=-
23-. .:....=;==+<; You should have received a copy of the GNU 23-. .:....=;==+<; You should have received a copy of the GNU
24 -_. . . )=. = Library General Public License along with 24 -_. . . )=. = Library General Public License along with
25 -- :-=` this library; see the file COPYING.LIB. 25 -- :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#include "oipkgconfigdlg.h" 32#include "oipkgconfigdlg.h"
33 33
34#include <opie2/ofiledialog.h> 34#include <opie2/ofiledialog.h>
35 35
36#include <qpe/resource.h> 36#include <qpe/resource.h>
37 37
38#include <qcheckbox.h> 38#include <qcheckbox.h>
39#include <qcombobox.h> 39#include <qcombobox.h>
40#include <qgroupbox.h> 40#include <qgroupbox.h>
41#include <qlabel.h> 41#include <qlabel.h>
42#include <qlineedit.h> 42#include <qlineedit.h>
43#include <qlistbox.h> 43#include <qlistbox.h>
44#include <qpushbutton.h> 44#include <qpushbutton.h>
45#include <qscrollview.h> 45#include <qscrollview.h>
46#include <qwhatsthis.h> 46#include <qwhatsthis.h>
47 47
48OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *parent ) 48OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *parent )
49 : QDialog( parent, QString::null, true, WStyle_ContextHelp ) 49 : QDialog( parent, QString::null, true, WStyle_ContextHelp )
50 , m_ipkg( ipkg ) 50 , m_ipkg( ipkg )
51 , m_configs( 0x0 ) 51 , m_configs( 0x0 )
52 , m_installOptions( installOptions ) 52 , m_installOptions( installOptions )
53 , m_serverNew( false ) 53 , m_serverNew( false )
54 , m_serverCurrent( -1 ) 54 , m_serverCurrent( -1 )
55 , m_destNew( false ) 55 , m_destNew( false )
56 , m_destCurrent( -1 ) 56 , m_destCurrent( -1 )
57 , m_layout( this, 2, 4 ) 57 , m_layout( this, 2, 4 )
58 , m_tabWidget( this ) 58 , m_tabWidget( this )
59{ 59{
60 setCaption( tr( "Configuration" ) ); 60 setCaption( tr( "Configuration" ) );
61 61
62 // Initialize configuration widgets 62 // Initialize configuration widgets
63 if ( !installOptions ) 63 if ( !installOptions )
64 { 64 {
65 initServerWidget(); 65 initServerWidget();
66 initDestinationWidget(); 66 initDestinationWidget();
67 initProxyWidget(); 67 initProxyWidget();
68 } 68 }
69 initOptionsWidget(); 69 initOptionsWidget();
70 70
71 // Load configuration information 71 // Load configuration information
72 initData(); 72 initData();
73 73
74 // Setup tabs for all info 74 // Setup tabs for all info
75 m_layout.addWidget( &m_tabWidget ); 75 m_layout.addWidget( &m_tabWidget );
76 if ( !m_installOptions ) 76 if ( !m_installOptions )
77 { 77 {
78 m_tabWidget.addTab( m_serverWidget, "packagemanager/servertab", tr( "Servers" ) ); 78 m_tabWidget.addTab( m_serverWidget, "packagemanager/servertab", tr( "Servers" ) );
79 m_tabWidget.addTab( m_destWidget, "packagemanager/desttab", tr( "Destinations" ) ); 79 m_tabWidget.addTab( m_destWidget, "packagemanager/desttab", tr( "Destinations" ) );
80 m_tabWidget.addTab( m_proxyWidget, "packagemanager/proxytab", tr( "Proxies" ) ); 80 m_tabWidget.addTab( m_proxyWidget, "packagemanager/proxytab", tr( "Proxies" ) );
81 m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) ); 81 m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) );
82 m_tabWidget.setCurrentTab( tr( "Servers" ) ); 82 m_tabWidget.setCurrentTab( tr( "Servers" ) );
83 } 83 }
84 else 84 else
85 { 85 {
86 m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) ); 86 m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) );
87 } 87 }
88} 88}
89 89
90void OIpkgConfigDlg::accept() 90void OIpkgConfigDlg::accept()
91{ 91{
92 // Save server, destination and proxy configuration 92 // Save server, destination and proxy configuration
93 if ( !m_installOptions ) 93 if ( !m_installOptions )
94 { 94 {
95 // Update proxy information before saving settings 95 // Update proxy information before saving settings
96 OConfItem *confItem = findConfItem( OConfItem::Option, "http_proxy" ); 96 OConfItem *confItem = findConfItem( OConfItem::Option, "http_proxy" );
97 if ( confItem ) 97 if ( confItem )
98 { 98 {
99 confItem->setValue( m_proxyHttpServer->text() ); 99 confItem->setValue( m_proxyHttpServer->text() );
100 confItem->setActive( m_proxyHttpActive->isChecked() ); 100 confItem->setActive( m_proxyHttpActive->isChecked() );
101 } 101 }
102 else 102 else
103 m_configs->append( new OConfItem( OConfItem::Option, "http_proxy", 103 m_configs->append( new OConfItem( OConfItem::Option, "http_proxy",
104 m_proxyHttpServer->text(), m_proxyHttpActive->isChecked() ) ); 104 m_proxyHttpServer->text(), QString::null,
105 m_proxyHttpActive->isChecked() ) );
105 106
106 confItem = findConfItem( OConfItem::Option, "ftp_proxy" ); 107 confItem = findConfItem( OConfItem::Option, "ftp_proxy" );
107 if ( confItem ) 108 if ( confItem )
108 { 109 {
109 confItem->setValue( m_proxyFtpServer->text() ); 110 confItem->setValue( m_proxyFtpServer->text() );
110 confItem->setActive( m_proxyFtpActive->isChecked() ); 111 confItem->setActive( m_proxyFtpActive->isChecked() );
111 } 112 }
112 else 113 else
113 m_configs->append( new OConfItem( OConfItem::Option, "ftp_proxy", 114 m_configs->append( new OConfItem( OConfItem::Option, "ftp_proxy",
114 m_proxyFtpServer->text(), m_proxyFtpActive->isChecked() ) ); 115 m_proxyFtpServer->text(), QString::null,
116 m_proxyFtpActive->isChecked() ) );
115 117
116 confItem = findConfItem( OConfItem::Option, "proxy_username" ); 118 confItem = findConfItem( OConfItem::Option, "proxy_username" );
117 if ( confItem ) 119 if ( confItem )
118 confItem->setValue( m_proxyUsername->text() ); 120 confItem->setValue( m_proxyUsername->text() );
119 else 121 else
120 m_configs->append( new OConfItem( OConfItem::Option, "proxy_username", 122 m_configs->append( new OConfItem( OConfItem::Option, "proxy_username",
121 m_proxyUsername->text() ) ); 123 m_proxyUsername->text() ) );
122 124
123 confItem = findConfItem( OConfItem::Option, "proxy_password" ); 125 confItem = findConfItem( OConfItem::Option, "proxy_password" );
124 if ( confItem ) 126 if ( confItem )
125 confItem->setValue( m_proxyPassword->text() ); 127 confItem->setValue( m_proxyPassword->text() );
126 else 128 else
127 m_configs->append( new OConfItem( OConfItem::Option, "proxy_password", 129 m_configs->append( new OConfItem( OConfItem::Option, "proxy_password",
128 m_proxyPassword->text() ) ); 130 m_proxyPassword->text() ) );
129 131
130 m_ipkg->setConfigItems( m_configs ); 132 m_ipkg->setConfigItems( m_configs );
131 } 133 }
132 134
133 // Save options configuration 135 // Save options configuration
134 int options = 0; 136 int options = 0;
135 if ( m_optForceDepends->isChecked() ) 137 if ( m_optForceDepends->isChecked() )
136 options |= FORCE_DEPENDS; 138 options |= FORCE_DEPENDS;
137 if ( m_optForceReinstall->isChecked() ) 139 if ( m_optForceReinstall->isChecked() )
138 options |= FORCE_REINSTALL; 140 options |= FORCE_REINSTALL;
139 if ( m_optForceRemove->isChecked() ) 141 if ( m_optForceRemove->isChecked() )
140 options |= FORCE_REMOVE; 142 options |= FORCE_REMOVE;
141 if ( m_optForceOverwrite->isChecked() ) 143 if ( m_optForceOverwrite->isChecked() )
142 options |= FORCE_OVERWRITE; 144 options |= FORCE_OVERWRITE;
143 m_ipkg->setIpkgExecOptions( options ); 145 m_ipkg->setIpkgExecOptions( options );
144 m_ipkg->setIpkgExecVerbosity( m_optVerboseIpkg->currentItem() ); 146 m_ipkg->setIpkgExecVerbosity( m_optVerboseIpkg->currentItem() );
145 147
146 QDialog::accept(); 148 QDialog::accept();
147} 149}
148 150
149void OIpkgConfigDlg::reject() 151void OIpkgConfigDlg::reject()
150{ 152{
151 if ( m_configs ) 153 if ( m_configs )
152 delete m_configs; 154 delete m_configs;
153} 155}
154 156
155void OIpkgConfigDlg::initServerWidget() 157void OIpkgConfigDlg::initServerWidget()
156{ 158{
157 m_serverWidget = new QWidget( this ); 159 m_serverWidget = new QWidget( this );
158 160
159 // Initialize UI 161 // Initialize UI
160 QVBoxLayout *vb = new QVBoxLayout( m_serverWidget ); 162 QVBoxLayout *vb = new QVBoxLayout( m_serverWidget );
161 QScrollView *sv = new QScrollView( m_serverWidget ); 163 QScrollView *sv = new QScrollView( m_serverWidget );
162 vb->addWidget( sv, 0, 0 ); 164 vb->addWidget( sv, 0, 0 );
163 sv->setResizePolicy( QScrollView::AutoOneFit ); 165 sv->setResizePolicy( QScrollView::AutoOneFit );
164 sv->setFrameStyle( QFrame::NoFrame ); 166 sv->setFrameStyle( QFrame::NoFrame );
165 QWidget *container = new QWidget( sv->viewport() ); 167 QWidget *container = new QWidget( sv->viewport() );
166 sv->addChild( container ); 168 sv->addChild( container );
167 QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 ); 169 QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 );
168 170
169 m_serverList = new QListBox( container ); 171 m_serverList = new QListBox( container );
170 QWhatsThis::add( m_serverList, tr( "This is a list of all servers configured. Select one here to edit or delete, or add a new one below." ) ); 172 QWhatsThis::add( m_serverList, tr( "This is a list of all servers configured. Select one here to edit or delete, or add a new one below." ) );
171 m_serverList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); 173 m_serverList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
172 connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerEdit(int)) ); 174 connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerEdit(int)) );
173 layout->addMultiCellWidget( m_serverList, 0, 0, 0, 1 ); 175 layout->addMultiCellWidget( m_serverList, 0, 0, 0, 1 );
174 176
175 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); 177 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container );
176 QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) ); 178 QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) );
177 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerNew()) ); 179 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerNew()) );
178 layout->addWidget( btn, 1, 0 ); 180 layout->addWidget( btn, 1, 0 );
179 181
180 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); 182 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container );
181 QWhatsThis::add( btn, tr( "Tap here to delete the entry selected above." ) ); 183 QWhatsThis::add( btn, tr( "Tap here to delete the entry selected above." ) );
182 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerDelete()) ); 184 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerDelete()) );
183 layout->addWidget( btn, 1, 1 ); 185 layout->addWidget( btn, 1, 1 );
184 186
185 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); 187 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container );
186 grpbox->layout()->setSpacing( 2 ); 188 grpbox->layout()->setSpacing( 2 );
187 grpbox->layout()->setMargin( 4 ); 189 grpbox->layout()->setMargin( 4 );
188 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); 190 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 );
189 191
190 QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); 192 QGridLayout *grplayout = new QGridLayout( grpbox->layout() );
191 193
192 QLabel *label = new QLabel( tr( "Name:" ), grpbox ); 194 QLabel *label = new QLabel( tr( "Name:" ), grpbox );
193 QWhatsThis::add( label, tr( "Enter the name of this entry here." ) ); 195 QWhatsThis::add( label, tr( "Enter the name of this entry here." ) );
194 grplayout->addWidget( label, 0, 0 ); 196 grplayout->addWidget( label, 0, 0 );
195 m_serverName = new QLineEdit( grpbox ); 197 m_serverName = new QLineEdit( grpbox );
196 QWhatsThis::add( m_serverName, tr( "Enter the name of this entry here." ) ); 198 QWhatsThis::add( m_serverName, tr( "Enter the name of this entry here." ) );
197 grplayout->addWidget( m_serverName, 0, 1 ); 199 grplayout->addWidget( m_serverName, 0, 1 );
198 200
199 label = new QLabel( tr( "Address:" ), grpbox ); 201 label = new QLabel( tr( "Address:" ), grpbox );
200 QWhatsThis::add( label, tr( "Enter the URL address of this entry here." ) ); 202 QWhatsThis::add( label, tr( "Enter the URL address of this entry here." ) );
201 grplayout->addWidget( label, 1, 0 ); 203 grplayout->addWidget( label, 1, 0 );
202 m_serverLocation = new QLineEdit( grpbox ); 204 m_serverLocation = new QLineEdit( grpbox );
203 QWhatsThis::add( m_serverLocation, tr( "Enter the URL address of this entry here." ) ); 205 QWhatsThis::add( m_serverLocation, tr( "Enter the URL address of this entry here." ) );
204 grplayout->addWidget( m_serverLocation, 1, 1 ); 206 grplayout->addWidget( m_serverLocation, 1, 1 );
205 207
206 m_serverActive = new QCheckBox( tr( "Active" ), grpbox ); 208 m_serverActive = new QCheckBox( tr( "Active" ), grpbox );
207 QWhatsThis::add( m_serverActive, tr( "Tap here to indicate whether this entry is active or not." ) ); 209 QWhatsThis::add( m_serverActive, tr( "Tap here to indicate whether this entry is active or not." ) );
208 grplayout->addMultiCellWidget( m_serverActive, 2, 2, 0, 1 ); 210 grplayout->addMultiCellWidget( m_serverActive, 2, 2, 0, 1 );
209 211
210 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); 212 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox );
211 QWhatsThis::add( btn, tr( "Tap here to update the entry's information." ) ); 213 QWhatsThis::add( btn, tr( "Tap here to update the entry's information." ) );
212 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerUpdate()) ); 214 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerUpdate()) );
213 grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); 215 grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 );
214} 216}
215 217
216void OIpkgConfigDlg::initDestinationWidget() 218void OIpkgConfigDlg::initDestinationWidget()
217{ 219{
218 m_destWidget = new QWidget( this ); 220 m_destWidget = new QWidget( this );
219 221
220 // Initialize UI 222 // Initialize UI
221 QVBoxLayout *vb = new QVBoxLayout( m_destWidget ); 223 QVBoxLayout *vb = new QVBoxLayout( m_destWidget );
222 QScrollView *sv = new QScrollView( m_destWidget ); 224 QScrollView *sv = new QScrollView( m_destWidget );
223 vb->addWidget( sv, 0, 0 ); 225 vb->addWidget( sv, 0, 0 );
224 sv->setResizePolicy( QScrollView::AutoOneFit ); 226 sv->setResizePolicy( QScrollView::AutoOneFit );
225 sv->setFrameStyle( QFrame::NoFrame ); 227 sv->setFrameStyle( QFrame::NoFrame );
226 QWidget *container = new QWidget( sv->viewport() ); 228 QWidget *container = new QWidget( sv->viewport() );
227 sv->addChild( container ); 229 sv->addChild( container );
228 QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 ); 230 QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 );
229 231
230 m_destList = new QListBox( container ); 232 m_destList = new QListBox( container );
231 QWhatsThis::add( m_destList, tr( "This is a list of all destinations configured for this device. Select one here to edit or delete, or add a new one below." ) ); 233 QWhatsThis::add( m_destList, tr( "This is a list of all destinations configured for this device. Select one here to edit or delete, or add a new one below." ) );
232 m_destList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); 234 m_destList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
233 connect( m_destList, SIGNAL(highlighted(int)), this, SLOT(slotDestEdit(int)) ); 235 connect( m_destList, SIGNAL(highlighted(int)), this, SLOT(slotDestEdit(int)) );
234 layout->addMultiCellWidget( m_destList, 0, 0, 0, 1 ); 236 layout->addMultiCellWidget( m_destList, 0, 0, 0, 1 );
235 237
236 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); 238 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container );
237 QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) ); 239 QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) );
238 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestNew()) ); 240 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestNew()) );
239 layout->addWidget( btn, 1, 0 ); 241 layout->addWidget( btn, 1, 0 );
240 242
241 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); 243 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container );
242 QWhatsThis::add( btn, tr( "Tap here to delete the entry selected above." ) ); 244 QWhatsThis::add( btn, tr( "Tap here to delete the entry selected above." ) );
243 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestDelete()) ); 245 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestDelete()) );
244 layout->addWidget( btn, 1, 1 ); 246 layout->addWidget( btn, 1, 1 );
245 247
246 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Destination" ), container ); 248 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Destination" ), container );
247 grpbox->layout()->setSpacing( 2 ); 249 grpbox->layout()->setSpacing( 2 );
248 grpbox->layout()->setMargin( 4 ); 250 grpbox->layout()->setMargin( 4 );
249 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); 251 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 );
250 252
251 QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); 253 QGridLayout *grplayout = new QGridLayout( grpbox->layout() );
252 254
253 QLabel *label = new QLabel( tr( "Name:" ), grpbox ); 255 QLabel *label = new QLabel( tr( "Name:" ), grpbox );
254 QWhatsThis::add( label, tr( "Enter the name of this entry here." ) ); 256 QWhatsThis::add( label, tr( "Enter the name of this entry here." ) );
255 grplayout->addWidget( label, 0, 0 ); 257 grplayout->addWidget( label, 0, 0 );
256 m_destName = new QLineEdit( grpbox ); 258 m_destName = new QLineEdit( grpbox );
257 QWhatsThis::add( m_destName, tr( "Enter the name of this entry here." ) ); 259 QWhatsThis::add( m_destName, tr( "Enter the name of this entry here." ) );
258 grplayout->addMultiCellWidget( m_destName, 0, 0, 1, 2 ); 260 grplayout->addMultiCellWidget( m_destName, 0, 0, 1, 2 );
259 261
260 label = new QLabel( tr( "Location:" ), grpbox ); 262 label = new QLabel( tr( "Location:" ), grpbox );
261 QWhatsThis::add( label, tr( "Enter the absolute directory path of this entry here." ) ); 263 QWhatsThis::add( label, tr( "Enter the absolute directory path of this entry here." ) );
262 grplayout->addWidget( label, 1, 0 ); 264 grplayout->addWidget( label, 1, 0 );
263 m_destLocation = new QLineEdit( grpbox ); 265 m_destLocation = new QLineEdit( grpbox );
264 QWhatsThis::add( m_destLocation, tr( "Enter the absolute directory path of this entry here." ) ); 266 QWhatsThis::add( m_destLocation, tr( "Enter the absolute directory path of this entry here." ) );
265 grplayout->addWidget( m_destLocation, 1, 1 ); 267 grplayout->addWidget( m_destLocation, 1, 1 );
266 btn = new QPushButton( Resource::loadPixmap( "folder" ), QString::null, grpbox ); 268 btn = new QPushButton( Resource::loadPixmap( "folder" ), QString::null, grpbox );
267 btn->setMaximumWidth( btn->height() ); 269 btn->setMaximumWidth( btn->height() );
268 QWhatsThis::add( btn, tr( "Tap here to select the desired location." ) ); 270 QWhatsThis::add( btn, tr( "Tap here to select the desired location." ) );
269 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestSelectPath()) ); 271 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestSelectPath()) );
270 grplayout->addWidget( btn, 1, 2 ); 272 grplayout->addWidget( btn, 1, 2 );
271 273
272 m_destActive = new QCheckBox( tr( "Active" ), grpbox ); 274 m_destActive = new QCheckBox( tr( "Active" ), grpbox );
273 QWhatsThis::add( m_destActive, tr( "Tap here to indicate whether this entry is active or not." ) ); 275 QWhatsThis::add( m_destActive, tr( "Tap here to indicate whether this entry is active or not." ) );
274 grplayout->addMultiCellWidget( m_destActive, 2, 2, 0, 2 ); 276 grplayout->addMultiCellWidget( m_destActive, 2, 2, 0, 2 );
275 277
276 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); 278 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox );
277 QWhatsThis::add( btn, tr( "Tap here to update the entry's information." ) ); 279 QWhatsThis::add( btn, tr( "Tap here to update the entry's information." ) );
278 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestUpdate()) ); 280 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestUpdate()) );
279 grplayout->addMultiCellWidget( btn, 3, 3, 0, 2 ); 281 grplayout->addMultiCellWidget( btn, 3, 3, 0, 2 );
280} 282}
281 283
282void OIpkgConfigDlg::initProxyWidget() 284void OIpkgConfigDlg::initProxyWidget()
283{ 285{
284 m_proxyWidget = new QWidget( this ); 286 m_proxyWidget = new QWidget( this );
285 287
286 // Initialize UI 288 // Initialize UI
287 QVBoxLayout *vb = new QVBoxLayout( m_proxyWidget ); 289 QVBoxLayout *vb = new QVBoxLayout( m_proxyWidget );
288 QScrollView *sv = new QScrollView( m_proxyWidget ); 290 QScrollView *sv = new QScrollView( m_proxyWidget );
289 vb->addWidget( sv, 0, 0 ); 291 vb->addWidget( sv, 0, 0 );
290 sv->setResizePolicy( QScrollView::AutoOneFit ); 292 sv->setResizePolicy( QScrollView::AutoOneFit );
291 sv->setFrameStyle( QFrame::NoFrame ); 293 sv->setFrameStyle( QFrame::NoFrame );
292 QWidget *container = new QWidget( sv->viewport() ); 294 QWidget *container = new QWidget( sv->viewport() );
293 sv->addChild( container ); 295 sv->addChild( container );
294 QGridLayout *layout = new QGridLayout( container, 4, 2, 2, 4 ); 296 QGridLayout *layout = new QGridLayout( container, 4, 2, 2, 4 );
295 297
296 // HTTP proxy server configuration 298 // HTTP proxy server configuration
297 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container ); 299 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container );
298 grpbox->layout()->setSpacing( 2 ); 300 grpbox->layout()->setSpacing( 2 );
299 grpbox->layout()->setMargin( 4 ); 301 grpbox->layout()->setMargin( 4 );
300 layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 ); 302 layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 );
301 QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); 303 QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() );
302 m_proxyHttpServer = new QLineEdit( grpbox ); 304 m_proxyHttpServer = new QLineEdit( grpbox );
303 QWhatsThis::add( m_proxyHttpServer, tr( "Enter the URL address of the HTTP proxy server here." ) ); 305 QWhatsThis::add( m_proxyHttpServer, tr( "Enter the URL address of the HTTP proxy server here." ) );
304 grplayout->addWidget( m_proxyHttpServer ); 306 grplayout->addWidget( m_proxyHttpServer );
305 m_proxyHttpActive = new QCheckBox( tr( "Enabled" ), grpbox ); 307 m_proxyHttpActive = new QCheckBox( tr( "Enabled" ), grpbox );
306 QWhatsThis::add( m_proxyHttpActive, tr( "Tap here to enable or disable the HTTP proxy server." ) ); 308 QWhatsThis::add( m_proxyHttpActive, tr( "Tap here to enable or disable the HTTP proxy server." ) );
@@ -346,295 +348,296 @@ void OIpkgConfigDlg::initOptionsWidget()
346 sv->setResizePolicy( QScrollView::AutoOneFit ); 348 sv->setResizePolicy( QScrollView::AutoOneFit );
347 sv->setFrameStyle( QFrame::NoFrame ); 349 sv->setFrameStyle( QFrame::NoFrame );
348 QWidget *container = new QWidget( sv->viewport() ); 350 QWidget *container = new QWidget( sv->viewport() );
349 sv->addChild( container ); 351 sv->addChild( container );
350 QVBoxLayout *layout = new QVBoxLayout( container, 2, 4 ); 352 QVBoxLayout *layout = new QVBoxLayout( container, 2, 4 );
351 353
352 m_optForceDepends = new QCheckBox( tr( "Force Depends" ), container ); 354 m_optForceDepends = new QCheckBox( tr( "Force Depends" ), container );
353 QWhatsThis::add( m_optForceDepends, tr( "Tap here to enable or disable the '-force-depends' option for Ipkg." ) ); 355 QWhatsThis::add( m_optForceDepends, tr( "Tap here to enable or disable the '-force-depends' option for Ipkg." ) );
354 layout->addWidget( m_optForceDepends ); 356 layout->addWidget( m_optForceDepends );
355 357
356 m_optForceReinstall = new QCheckBox( tr( "Force Reinstall" ), container ); 358 m_optForceReinstall = new QCheckBox( tr( "Force Reinstall" ), container );
357 QWhatsThis::add( m_optForceReinstall, tr( "Tap here to enable or disable the '-force-reinstall' option for Ipkg." ) ); 359 QWhatsThis::add( m_optForceReinstall, tr( "Tap here to enable or disable the '-force-reinstall' option for Ipkg." ) );
358 layout->addWidget( m_optForceReinstall ); 360 layout->addWidget( m_optForceReinstall );
359 361
360 m_optForceRemove = new QCheckBox( tr( "Force Remove" ), container ); 362 m_optForceRemove = new QCheckBox( tr( "Force Remove" ), container );
361 QWhatsThis::add( m_optForceRemove, tr( "Tap here to enable or disable the '-force-removal-of-dependent-packages' option for Ipkg." ) ); 363 QWhatsThis::add( m_optForceRemove, tr( "Tap here to enable or disable the '-force-removal-of-dependent-packages' option for Ipkg." ) );
362 layout->addWidget( m_optForceRemove ); 364 layout->addWidget( m_optForceRemove );
363 365
364 m_optForceOverwrite = new QCheckBox( tr( "Force Overwrite" ), container ); 366 m_optForceOverwrite = new QCheckBox( tr( "Force Overwrite" ), container );
365 QWhatsThis::add( m_optForceOverwrite, tr( "Tap here to enable or disable the '-force-overwrite' option for Ipkg." ) ); 367 QWhatsThis::add( m_optForceOverwrite, tr( "Tap here to enable or disable the '-force-overwrite' option for Ipkg." ) );
366 layout->addWidget( m_optForceOverwrite ); 368 layout->addWidget( m_optForceOverwrite );
367 369
368 QLabel *l = new QLabel( tr( "Information Level" ), container ); 370 QLabel *l = new QLabel( tr( "Information Level" ), container );
369 QWhatsThis::add( l, tr( "Select information level for Ipkg." ) ); 371 QWhatsThis::add( l, tr( "Select information level for Ipkg." ) );
370 layout->addWidget( l ); 372 layout->addWidget( l );
371 373
372 m_optVerboseIpkg = new QComboBox( container ); 374 m_optVerboseIpkg = new QComboBox( container );
373 QWhatsThis::add( m_optVerboseIpkg, tr( "Select information level for Ipkg." ) ); 375 QWhatsThis::add( m_optVerboseIpkg, tr( "Select information level for Ipkg." ) );
374 m_optVerboseIpkg->insertItem( tr( "Errors only" ) ); 376 m_optVerboseIpkg->insertItem( tr( "Errors only" ) );
375 m_optVerboseIpkg->insertItem( tr( "Normal messages" ) ); 377 m_optVerboseIpkg->insertItem( tr( "Normal messages" ) );
376 m_optVerboseIpkg->insertItem( tr( "Informative messages" ) ); 378 m_optVerboseIpkg->insertItem( tr( "Informative messages" ) );
377 m_optVerboseIpkg->insertItem( tr( "Troubleshooting output" ) ); 379 m_optVerboseIpkg->insertItem( tr( "Troubleshooting output" ) );
378 layout->addWidget( m_optVerboseIpkg ); 380 layout->addWidget( m_optVerboseIpkg );
379 381
380 layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); 382 layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
381} 383}
382 384
383void OIpkgConfigDlg::initData() 385void OIpkgConfigDlg::initData()
384{ 386{
385 // Read ipkg configuration (server/destination/proxy) information 387 // Read ipkg configuration (server/destination/proxy) information
386 if ( m_ipkg && !m_installOptions ) 388 if ( m_ipkg && !m_installOptions )
387 { 389 {
388 m_configs = m_ipkg->configItems(); 390 m_configs = m_ipkg->configItems();
389 if ( m_configs ) 391 if ( m_configs )
390 { 392 {
391 for ( OConfItemListIterator configIt( *m_configs ); configIt.current(); ++configIt ) 393 for ( OConfItemListIterator configIt( *m_configs ); configIt.current(); ++configIt )
392 { 394 {
393 OConfItem *config = configIt.current(); 395 OConfItem *config = configIt.current();
394 396
395 // Add configuration item to the appropriate dialog controls 397 // Add configuration item to the appropriate dialog controls
396 if ( config ) 398 if ( config )
397 { 399 {
398 if ( config->type() == OConfItem::Source ) 400 if ( config->type() == OConfItem::Source )
399 { 401 {
400 m_serverList->insertItem( config->name() ); 402 m_serverList->insertItem( config->name() );
401 } 403 }
402 else if ( config->type() == OConfItem::Destination ) 404 else if ( config->type() == OConfItem::Destination )
403 { 405 {
404 m_destList->insertItem( config->name() ); 406 m_destList->insertItem( config->name() );
405 } 407 }
406 else if ( config->type() == OConfItem::Option ) 408 else if ( config->type() == OConfItem::Option )
407 { 409 {
408 if ( config->name() == "http_proxy" ) 410 if ( config->name() == "http_proxy" )
409 { 411 {
410 m_proxyHttpServer->setText( config->value() ); 412 m_proxyHttpServer->setText( config->value() );
411 m_proxyHttpActive->setChecked( config->active() ); 413 m_proxyHttpActive->setChecked( config->active() );
412 } 414 }
413 else if ( config->name() == "ftp_proxy" ) 415 else if ( config->name() == "ftp_proxy" )
414 { 416 {
415 m_proxyFtpServer->setText( config->value() ); 417 m_proxyFtpServer->setText( config->value() );
416 m_proxyFtpActive->setChecked( config->active() ); 418 m_proxyFtpActive->setChecked( config->active() );
417 } 419 }
418 else if ( config->name() == "proxy_username" ) 420 else if ( config->name() == "proxy_username" )
419 { 421 {
420 m_proxyUsername->setText( config->value() ); 422 m_proxyUsername->setText( config->value() );
421 } 423 }
422 else if ( config->name() == "proxy_password" ) 424 else if ( config->name() == "proxy_password" )
423 { 425 {
424 m_proxyPassword->setText( config->value() ); 426 m_proxyPassword->setText( config->value() );
425 } 427 }
426 } 428 }
427 } 429 }
428 } 430 }
429 } 431 }
430 } 432 }
431 433
432 // Get Ipkg execution options 434 // Get Ipkg execution options
433 int options = m_ipkg->ipkgExecOptions(); 435 int options = m_ipkg->ipkgExecOptions();
434 if ( options & FORCE_DEPENDS ) 436 if ( options & FORCE_DEPENDS )
435 m_optForceDepends->setChecked( true ); 437 m_optForceDepends->setChecked( true );
436 if ( options & FORCE_REINSTALL ) 438 if ( options & FORCE_REINSTALL )
437 m_optForceReinstall->setChecked( true ); 439 m_optForceReinstall->setChecked( true );
438 if ( options & FORCE_REMOVE ) 440 if ( options & FORCE_REMOVE )
439 m_optForceRemove->setChecked( true ); 441 m_optForceRemove->setChecked( true );
440 if ( options & FORCE_OVERWRITE ) 442 if ( options & FORCE_OVERWRITE )
441 m_optForceOverwrite->setChecked( true ); 443 m_optForceOverwrite->setChecked( true );
442 444
443 m_optVerboseIpkg->setCurrentItem( m_ipkg->ipkgExecVerbosity() ); 445 m_optVerboseIpkg->setCurrentItem( m_ipkg->ipkgExecVerbosity() );
444} 446}
445 447
446OConfItem *OIpkgConfigDlg::findConfItem( OConfItem::Type type, const QString &name ) 448OConfItem *OIpkgConfigDlg::findConfItem( OConfItem::Type type, const QString &name )
447{ 449{
448 // Find selected server in list 450 // Find selected server in list
449 OConfItemListIterator configIt( *m_configs ); 451 OConfItemListIterator configIt( *m_configs );
450 OConfItem *config = 0x0; 452 OConfItem *config = 0x0;
451 for ( ; configIt.current(); ++configIt ) 453 for ( ; configIt.current(); ++configIt )
452 { 454 {
453 config = configIt.current(); 455 config = configIt.current();
454 if ( config->type() == type && config->name() == name ) 456 if ( config->type() == type && config->name() == name )
455 break; 457 break;
456 } 458 }
457 459
458 if ( config && config->type() == type && config->name() == name ) 460 if ( config && config->type() == type && config->name() == name )
459 return config; 461 return config;
460 462
461 return 0x0; 463 return 0x0;
462} 464}
463 465
464void OIpkgConfigDlg::slotServerEdit( int index ) 466void OIpkgConfigDlg::slotServerEdit( int index )
465{ 467{
466 m_serverNew = false; 468 m_serverNew = false;
467 m_serverCurrent = index; 469 m_serverCurrent = index;
468 470
469 // Find selected server in list 471 // Find selected server in list
470 OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() ); 472 OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() );
471 473
472 // Display server details 474 // Display server details
473 if ( server ) 475 if ( server )
474 { 476 {
475 m_serverCurrName = server->name(); 477 m_serverCurrName = server->name();
476 m_serverName->setText( server->name() ); 478 m_serverName->setText( server->name() );
477 m_serverLocation->setText( server->value() ); 479 m_serverLocation->setText( server->value() );
478 m_serverActive->setChecked( server->active() ); 480 m_serverActive->setChecked( server->active() );
479 m_serverName->setFocus(); 481 m_serverName->setFocus();
480 } 482 }
481} 483}
482 484
483void OIpkgConfigDlg::slotServerNew() 485void OIpkgConfigDlg::slotServerNew()
484{ 486{
485 m_serverNew = true; 487 m_serverNew = true;
486 488
487 m_serverName->setText( QString::null ); 489 m_serverName->setText( QString::null );
488 m_serverLocation->setText( QString::null ); 490 m_serverLocation->setText( QString::null );
489 m_serverActive->setChecked( true ); 491 m_serverActive->setChecked( true );
490 m_serverName->setFocus(); 492 m_serverName->setFocus();
491} 493}
492 494
493void OIpkgConfigDlg::slotServerDelete() 495void OIpkgConfigDlg::slotServerDelete()
494{ 496{
495 // Find selected server in list 497 // Find selected server in list
496 OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() ); 498 OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() );
497 499
498 // Delete server 500 // Delete server
499 if ( server ) 501 if ( server )
500 { 502 {
501 m_configs->removeRef( server ); 503 m_configs->removeRef( server );
502 m_serverList->removeItem( m_serverCurrent ); 504 m_serverList->removeItem( m_serverCurrent );
503 } 505 }
504} 506}
505 507
506void OIpkgConfigDlg::slotServerUpdate() 508void OIpkgConfigDlg::slotServerUpdate()
507{ 509{
508 QString newName = m_serverName->text(); 510 QString newName = m_serverName->text();
509 511
510 // Convert any spaces to underscores 512 // Convert any spaces to underscores
511 newName.replace( QRegExp( " " ), "_" ); 513 newName.replace( QRegExp( " " ), "_" );
512 514
513 if ( !m_serverNew ) 515 if ( !m_serverNew )
514 { 516 {
515 // Find selected server in list 517 // Find selected server in list
516 OConfItem *server = findConfItem( OConfItem::Source, m_serverCurrName ); 518 OConfItem *server = findConfItem( OConfItem::Source, m_serverCurrName );
517 519
518 // Delete server 520 // Delete server
519 if ( server ) 521 if ( server )
520 { 522 {
521 // Update url 523 // Update url
522 server->setValue( m_serverLocation->text() ); 524 server->setValue( m_serverLocation->text() );
523 server->setActive( m_serverActive->isChecked() ); 525 server->setActive( m_serverActive->isChecked() );
524 526
525 // Check if server name has changed, if it has then we need to replace the key in the map 527 // Check if server name has changed, if it has then we need to replace the key in the map
526 if ( m_serverCurrName != newName ) 528 if ( m_serverCurrName != newName )
527 { 529 {
528 // Update server name 530 // Update server name
529 server->setName( newName ); 531 server->setName( newName );
530 532
531 // Update list box 533 // Update list box
532 m_serverList->changeItem( newName, m_serverCurrent ); 534 m_serverList->changeItem( newName, m_serverCurrent );
533 } 535 }
534 } 536 }
535 } 537 }
536 else 538 else
537 { 539 {
538 // Add new destination to configuration list 540 // Add new server to configuration list
539 m_configs->append( new OConfItem( OConfItem::Source, newName, 541 // TODO - support src/gz
540 m_serverLocation->text(), m_serverActive->isChecked() ) ); 542 m_configs->append( new OConfItem( OConfItem::Source, newName, m_serverLocation->text(),
543 QString::null, m_serverActive->isChecked() ) );
541 m_configs->sort(); 544 m_configs->sort();
542 545
543 m_serverList->insertItem( newName ); 546 m_serverList->insertItem( newName );
544 m_serverList->setCurrentItem( m_serverList->count() ); 547 m_serverList->setCurrentItem( m_serverList->count() );
545 m_serverNew = false; 548 m_serverNew = false;
546 } 549 }
547} 550}
548 551
549void OIpkgConfigDlg::slotDestEdit( int index ) 552void OIpkgConfigDlg::slotDestEdit( int index )
550{ 553{
551 m_destNew = false; 554 m_destNew = false;
552 m_destCurrent = index; 555 m_destCurrent = index;
553 556
554 // Find selected destination in list 557 // Find selected destination in list
555 OConfItem *destination = findConfItem( OConfItem::Destination, m_destList->currentText() ); 558 OConfItem *destination = findConfItem( OConfItem::Destination, m_destList->currentText() );
556 559
557 // Display destination details 560 // Display destination details
558 if ( destination ) 561 if ( destination )
559 { 562 {
560 m_destCurrName = destination->name(); 563 m_destCurrName = destination->name();
561 m_destName->setText( destination->name() ); 564 m_destName->setText( destination->name() );
562 m_destLocation->setText( destination->value() ); 565 m_destLocation->setText( destination->value() );
563 m_destActive->setChecked( destination->active() ); 566 m_destActive->setChecked( destination->active() );
564 m_destName->setFocus(); 567 m_destName->setFocus();
565 } 568 }
566} 569}
567 570
568void OIpkgConfigDlg::slotDestNew() 571void OIpkgConfigDlg::slotDestNew()
569{ 572{
570 m_destNew = true; 573 m_destNew = true;
571 574
572 m_destName->setText( QString::null ); 575 m_destName->setText( QString::null );
573 m_destLocation->setText( QString::null ); 576 m_destLocation->setText( QString::null );
574 m_destActive->setChecked( true ); 577 m_destActive->setChecked( true );
575 m_destName->setFocus(); 578 m_destName->setFocus();
576} 579}
577 580
578void OIpkgConfigDlg::slotDestDelete() 581void OIpkgConfigDlg::slotDestDelete()
579{ 582{
580 // Find selected destination in list 583 // Find selected destination in list
581 OConfItem *destination = findConfItem( OConfItem::Destination, m_destList->currentText() ); 584 OConfItem *destination = findConfItem( OConfItem::Destination, m_destList->currentText() );
582 585
583 // Delete destination 586 // Delete destination
584 if ( destination ) 587 if ( destination )
585 { 588 {
586 m_configs->removeRef( destination ); 589 m_configs->removeRef( destination );
587 m_destList->removeItem( m_destCurrent ); 590 m_destList->removeItem( m_destCurrent );
588 } 591 }
589} 592}
590 593
591void OIpkgConfigDlg::slotDestSelectPath() 594void OIpkgConfigDlg::slotDestSelectPath()
592{ 595{
593 QString path = Opie::Ui::OFileDialog::getDirectory( 0, m_destLocation->text() ); 596 QString path = Opie::Ui::OFileDialog::getDirectory( 0, m_destLocation->text() );
594 if ( path.at( path.length() - 1 ) == '/' ) 597 if ( path.at( path.length() - 1 ) == '/' )
595 path.truncate( path.length() - 1 ); 598 path.truncate( path.length() - 1 );
596 m_destLocation->setText( path ); 599 m_destLocation->setText( path );
597} 600}
598 601
599void OIpkgConfigDlg::slotDestUpdate() 602void OIpkgConfigDlg::slotDestUpdate()
600{ 603{
601 QString newName = m_destName->text(); 604 QString newName = m_destName->text();
602 605
603 // Convert any spaces to underscores 606 // Convert any spaces to underscores
604 newName.replace( QRegExp( " " ), "_" ); 607 newName.replace( QRegExp( " " ), "_" );
605 608
606 if ( !m_destNew ) 609 if ( !m_destNew )
607 { 610 {
608 // Find selected destination in list 611 // Find selected destination in list
609 OConfItem *destination = findConfItem( OConfItem::Destination, m_destCurrName ); 612 OConfItem *destination = findConfItem( OConfItem::Destination, m_destCurrName );
610 613
611 // Display destination details 614 // Display destination details
612 if ( destination ) 615 if ( destination )
613 { 616 {
614 // Update url 617 // Update url
615 destination->setValue( m_destLocation->text() ); 618 destination->setValue( m_destLocation->text() );
616 destination->setActive( m_destActive->isChecked() ); 619 destination->setActive( m_destActive->isChecked() );
617 620
618 // Check if destination name has changed, if it has then we need to replace the key in the map 621 // Check if destination name has changed, if it has then we need to replace the key in the map
619 if ( m_destCurrName != newName ) 622 if ( m_destCurrName != newName )
620 { 623 {
621 // Update destination name 624 // Update destination name
622 destination->setName( newName ); 625 destination->setName( newName );
623 626
624 // Update list box 627 // Update list box
625 m_destList->changeItem( newName, m_destCurrent ); 628 m_destList->changeItem( newName, m_destCurrent );
626 } 629 }
627 } 630 }
628 } 631 }
629 else 632 else
630 { 633 {
631 // Add new destination to configuration list 634 // Add new destination to configuration list
632 m_configs->append( new OConfItem( OConfItem::Destination, newName, 635 m_configs->append( new OConfItem( OConfItem::Destination, newName,
633 m_destLocation->text(), m_destActive->isChecked() ) ); 636 m_destLocation->text(), QString::null, m_destActive->isChecked() ) );
634 m_configs->sort(); 637 m_configs->sort();
635 638
636 m_destList->insertItem( newName ); 639 m_destList->insertItem( newName );
637 m_destList->setCurrentItem( m_destList->count() ); 640 m_destList->setCurrentItem( m_destList->count() );
638 m_destNew = false; 641 m_destNew = false;
639 } 642 }
640} 643}