author | drw <drw> | 2005-02-16 17:22:19 (UTC) |
---|---|---|
committer | drw <drw> | 2005-02-16 17:22:19 (UTC) |
commit | 4556ab6dffdaf9108899a7a1f74d83f54ac4e91a (patch) (unidiff) | |
tree | 70fe735502f0a31d7193621c482b9fafb6bbe006 | |
parent | 7dd436c9a45c1fbd5d57f97bc786d0badc0ef5e5 (diff) | |
download | opie-4556ab6dffdaf9108899a7a1f74d83f54ac4e91a.zip opie-4556ab6dffdaf9108899a7a1f74d83f54ac4e91a.tar.gz opie-4556ab6dffdaf9108899a7a1f74d83f54ac4e91a.tar.bz2 |
Fixed stupid bug where last package in status file was not shown as installed when it should be, and removed some printfs
-rw-r--r-- | noncore/settings/packagemanager/ChangeLog | 7 | ||||
-rw-r--r-- | noncore/settings/packagemanager/oipkg.cpp | 12 | ||||
-rw-r--r-- | noncore/settings/packagemanager/opackagemanager.cpp | 7 |
3 files changed, 16 insertions, 10 deletions
diff --git a/noncore/settings/packagemanager/ChangeLog b/noncore/settings/packagemanager/ChangeLog index 608cd98..38756b1 100644 --- a/noncore/settings/packagemanager/ChangeLog +++ b/noncore/settings/packagemanager/ChangeLog | |||
@@ -1,60 +1,65 @@ | |||
1 | 2005-02-16 Dan Williams <drw@handhelds.org> | ||
2 | |||
3 | * Fixed stupid bug where last package in status file was not shown as installed when it should be | ||
4 | * Removed printf's | ||
5 | |||
1 | 2005-01-02 Dan Williams <drw@handhelds.org> | 6 | 2005-01-02 Dan Williams <drw@handhelds.org> |
2 | 7 | ||
3 | * Released version 0.6.1 | 8 | * Released version 0.6.1 |
4 | * Implemented native package linking code to remove need for ipkg-link | 9 | * Implemented native package linking code to remove need for ipkg-link |
5 | * Implement package in OIpkg (removed from InstallDlg) as this is ipkg specific | 10 | * Implement package in OIpkg (removed from InstallDlg) as this is ipkg specific |
6 | * Many small code tweaks | 11 | * Many small code tweaks |
7 | 12 | ||
8 | 2004-12-21 Dan Williams <drw@handhelds.org> | 13 | 2004-12-21 Dan Williams <drw@handhelds.org> |
9 | 14 | ||
10 | * Released version 0.6.0 | 15 | * Released version 0.6.0 |
11 | * Added support for Ipkg 'src/gz' feeds | 16 | * Added support for Ipkg 'src/gz' feeds |
12 | * Improve server and destination tabs UI's in configuration dialog | 17 | * Improve server and destination tabs UI's in configuration dialog |
13 | * Fix app linking to link all dependent packages as well as selected packages | 18 | * Fix app linking to link all dependent packages as well as selected packages |
14 | * Hide 'Retrive File List' button once list is retrieved in Package Info dialog | 19 | * Hide 'Retrive File List' button once list is retrieved in Package Info dialog |
15 | 20 | ||
16 | 2004-11-18 Dan Williams <drw@handhelds.org> | 21 | 2004-11-18 Dan Williams <drw@handhelds.org> |
17 | 22 | ||
18 | * Released version 0.5.0 | 23 | * Released version 0.5.0 |
19 | * All v1.0 functionality implemented | 24 | * All v1.0 functionality implemented |
20 | * Implemented installation of local packages | 25 | * Implemented installation of local packages |
21 | * Implemented linking of non-root apps (using ipkg-link) | 26 | * Implemented linking of non-root apps (using ipkg-link) |
22 | * Many UI tweaks for installation and filter dialogs | 27 | * Many UI tweaks for installation and filter dialogs |
23 | 28 | ||
24 | 2004-04-21 Dan Williams <drw@handhelds.org> | 29 | 2004-04-21 Dan Williams <drw@handhelds.org> |
25 | 30 | ||
26 | * Released version 0.4.0 | 31 | * Released version 0.4.0 |
27 | * Added saving of ipkg configuration information | 32 | * Added saving of ipkg configuration information |
28 | * Re-initialize ipkg when configuration information changes | 33 | * Re-initialize ipkg when configuration information changes |
29 | * Added QWhatsThis for all UI controls | 34 | * Added QWhatsThis for all UI controls |
30 | * Remove Location from OConfItem as it is not used/needed | 35 | * Remove Location from OConfItem as it is not used/needed |
31 | * Re-ordered includes to follow Opie standards | 36 | * Re-ordered includes to follow Opie standards |
32 | 37 | ||
33 | 2004-02-13 Dan Williams <drw@handhelds.org> | 38 | 2004-02-13 Dan Williams <drw@handhelds.org> |
34 | 39 | ||
35 | * Released version 0.3.0 | 40 | * Released version 0.3.0 |
36 | * Fix handling of filtering options in View menu | 41 | * Fix handling of filtering options in View menu |
37 | * Do proper version string comparison | 42 | * Do proper version string comparison |
38 | * Fix string alignment code in PromptDlg to eliminate QT warning messages | 43 | * Fix string alignment code in PromptDlg to eliminate QT warning messages |
39 | 44 | ||
40 | 2004-02-12 Dan Williams <drw@handhelds.org> | 45 | 2004-02-12 Dan Williams <drw@handhelds.org> |
41 | 46 | ||
42 | * Package information dialog implemented | 47 | * Package information dialog implemented |
43 | * What's This app icon enabled | 48 | * What's This app icon enabled |
44 | * Changed all QDialog::exec() occurences to QPEApplication::execDialog() | 49 | * Changed all QDialog::exec() occurences to QPEApplication::execDialog() |
45 | 50 | ||
46 | 2004-01-23 Dan Williams <drw@handhelds.org> | 51 | 2004-01-23 Dan Williams <drw@handhelds.org> |
47 | 52 | ||
48 | * Added package download functionality | 53 | * Added package download functionality |
49 | * Have Opie update links after install/removal so that apps | 54 | * Have Opie update links after install/removal so that apps |
50 | will display properly in Launcher | 55 | will display properly in Launcher |
51 | 56 | ||
52 | 2004-01-20 Dan Williams <drw@handhelds.org> | 57 | 2004-01-20 Dan Williams <drw@handhelds.org> |
53 | 58 | ||
54 | * Released version 0.2.0 | 59 | * Released version 0.2.0 |
55 | * Converted to use libipkg in place of spawning ipkg process | 60 | * Converted to use libipkg in place of spawning ipkg process |
56 | 61 | ||
57 | 2004-01-13 Dan Williams <drw@handhelds.org> | 62 | 2004-01-13 Dan Williams <drw@handhelds.org> |
58 | 63 | ||
59 | * Released version 0.1.0 | 64 | * Released version 0.1.0 |
60 | * Initial check-in of new package management client to eventually replace AQPkg | 65 | * Initial check-in of new package management client to eventually replace AQPkg |
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp index f2d7e39..e7e292e 100644 --- a/noncore/settings/packagemanager/oipkg.cpp +++ b/noncore/settings/packagemanager/oipkg.cpp | |||
@@ -1,765 +1,769 @@ | |||
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 | #include <unistd.h> | 39 | #include <unistd.h> |
40 | 40 | ||
41 | const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file | 41 | const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file |
42 | const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files | 42 | const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files |
43 | const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists | 43 | const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists |
44 | const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location | 44 | const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location |
45 | const QString IPKG_INFO_PATH = "usr/lib/ipkg/info"; // Package file lists location | 45 | const QString IPKG_INFO_PATH = "usr/lib/ipkg/info"; // Package file lists location |
46 | 46 | ||
47 | OIpkg *oipkg; | 47 | OIpkg *oipkg; |
48 | 48 | ||
49 | // Ipkg callback functions | 49 | // Ipkg callback functions |
50 | 50 | ||
51 | int fsignalIpkgMessage( ipkg_conf_t *conf, message_level_t level, char *msg ) | 51 | int fsignalIpkgMessage( ipkg_conf_t *conf, message_level_t level, char *msg ) |
52 | { | 52 | { |
53 | // Display message only if it is below the message level threshold | 53 | // Display message only if it is below the message level threshold |
54 | if ( conf && ( conf->verbosity < level ) ) | 54 | if ( conf && ( conf->verbosity < level ) ) |
55 | return 0; | 55 | return 0; |
56 | else | 56 | else |
57 | oipkg->ipkgMessage( msg ); | 57 | oipkg->ipkgMessage( msg ); |
58 | 58 | ||
59 | return 0; | 59 | return 0; |
60 | } | 60 | } |
61 | 61 | ||
62 | char *fIpkgResponse( char */*question*/ ) | 62 | char *fIpkgResponse( char */*question*/ ) |
63 | { | 63 | { |
64 | return 0l; | 64 | return 0l; |
65 | } | 65 | } |
66 | 66 | ||
67 | int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ ) | 67 | int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ ) |
68 | { | 68 | { |
69 | oipkg->ipkgStatus( desc ); | 69 | oipkg->ipkgStatus( desc ); |
70 | return 0; | 70 | return 0; |
71 | } | 71 | } |
72 | 72 | ||
73 | int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/, | 73 | int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/, |
74 | void */*userdata*/ ) | 74 | void */*userdata*/ ) |
75 | { | 75 | { |
76 | oipkg->ipkgList( desc ); | 76 | oipkg->ipkgList( desc ); |
77 | return 0; | 77 | return 0; |
78 | } | 78 | } |
79 | 79 | ||
80 | OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) | 80 | OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) |
81 | : QObject( parent, name ) | 81 | : QObject( parent, name ) |
82 | , m_config( config ) | 82 | , m_config( config ) |
83 | , m_confInfo( NULL ) | 83 | , m_confInfo( NULL ) |
84 | , m_ipkgExecOptions( 0 ) | 84 | , m_ipkgExecOptions( 0 ) |
85 | , m_ipkgExecVerbosity( 1 ) | 85 | , m_ipkgExecVerbosity( 1 ) |
86 | { | 86 | { |
87 | // Keep pointer to self for the Ipkg callback functions | 87 | // Keep pointer to self for the Ipkg callback functions |
88 | oipkg = this; | 88 | oipkg = this; |
89 | 89 | ||
90 | // Initialize libipkg | 90 | // Initialize libipkg |
91 | ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); | 91 | ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); |
92 | 92 | ||
93 | // Default ipkg run-time arguments | 93 | // Default ipkg run-time arguments |
94 | m_ipkgArgs.noaction = false; | 94 | m_ipkgArgs.noaction = false; |
95 | m_ipkgArgs.force_defaults = true; | 95 | m_ipkgArgs.force_defaults = true; |
96 | } | 96 | } |
97 | 97 | ||
98 | OIpkg::~OIpkg() | 98 | OIpkg::~OIpkg() |
99 | { | 99 | { |
100 | // Upon destruction, ensure that items in config list are deleted with list | 100 | // Upon destruction, ensure that items in config list are deleted with list |
101 | if ( m_confInfo ) | 101 | if ( m_confInfo ) |
102 | m_confInfo->setAutoDelete( true ); | 102 | m_confInfo->setAutoDelete( true ); |
103 | 103 | ||
104 | // Free up libipkg resources | 104 | // Free up libipkg resources |
105 | ipkg_deinit( &m_ipkgArgs ); | 105 | ipkg_deinit( &m_ipkgArgs ); |
106 | } | 106 | } |
107 | 107 | ||
108 | OConfItemList *OIpkg::configItems() | 108 | OConfItemList *OIpkg::configItems() |
109 | { | 109 | { |
110 | // Retrieve all configuration items | 110 | // Retrieve all configuration items |
111 | return filterConfItems(); | 111 | return filterConfItems(); |
112 | } | 112 | } |
113 | 113 | ||
114 | OConfItemList *OIpkg::servers() | 114 | OConfItemList *OIpkg::servers() |
115 | { | 115 | { |
116 | // Retrieve only servers | 116 | // Retrieve only servers |
117 | return filterConfItems( OConfItem::Source ); | 117 | return filterConfItems( OConfItem::Source ); |
118 | } | 118 | } |
119 | 119 | ||
120 | OConfItemList *OIpkg::destinations() | 120 | OConfItemList *OIpkg::destinations() |
121 | { | 121 | { |
122 | // Retrieve only destinations | 122 | // Retrieve only destinations |
123 | return filterConfItems( OConfItem::Destination ); | 123 | return filterConfItems( OConfItem::Destination ); |
124 | } | 124 | } |
125 | 125 | ||
126 | OConfItemList *OIpkg::options() | 126 | OConfItemList *OIpkg::options() |
127 | { | 127 | { |
128 | // Retrieve only destinations | 128 | // Retrieve only destinations |
129 | return filterConfItems( OConfItem::Option ); | 129 | return filterConfItems( OConfItem::Option ); |
130 | } | 130 | } |
131 | 131 | ||
132 | void OIpkg::setConfigItems( OConfItemList *configList ) | 132 | void OIpkg::setConfigItems( OConfItemList *configList ) |
133 | { | 133 | { |
134 | if ( m_confInfo ) | 134 | if ( m_confInfo ) |
135 | delete m_confInfo; | 135 | delete m_confInfo; |
136 | 136 | ||
137 | m_confInfo = configList; | 137 | m_confInfo = configList; |
138 | 138 | ||
139 | // Write out new /etc/ipkg.conf | 139 | // Write out new /etc/ipkg.conf |
140 | QFile confFile( IPKG_CONF ); | 140 | QFile confFile( IPKG_CONF ); |
141 | if ( confFile.open( IO_WriteOnly ) ) | 141 | if ( confFile.open( IO_WriteOnly ) ) |
142 | { | 142 | { |
143 | QTextStream confStream( &confFile ); | 143 | QTextStream confStream( &confFile ); |
144 | confStream << "# Generated by Opie Package Manager\n\n"; | 144 | confStream << "# Generated by Opie Package Manager\n\n"; |
145 | 145 | ||
146 | OConfItemListIterator it( *m_confInfo ); | 146 | OConfItemListIterator it( *m_confInfo ); |
147 | for ( ; it.current(); ++it ) | 147 | for ( ; it.current(); ++it ) |
148 | { | 148 | { |
149 | OConfItem *item = it.current(); | 149 | OConfItem *item = it.current(); |
150 | 150 | ||
151 | // Only write out valid conf items | 151 | // Only write out valid conf items |
152 | if ( item->type() != OConfItem::NotDefined ) | 152 | if ( item->type() != OConfItem::NotDefined ) |
153 | { | 153 | { |
154 | QString confLine; | 154 | QString confLine; |
155 | if ( !item->active() ) | 155 | if ( !item->active() ) |
156 | confLine = "#"; | 156 | confLine = "#"; |
157 | 157 | ||
158 | switch ( item->type() ) | 158 | switch ( item->type() ) |
159 | { | 159 | { |
160 | case OConfItem::Source : | 160 | case OConfItem::Source : |
161 | { | 161 | { |
162 | if ( item->features().contains( "Compressed" ) ) | 162 | if ( item->features().contains( "Compressed" ) ) |
163 | confLine.append( "src/gz " ); | 163 | confLine.append( "src/gz " ); |
164 | else | 164 | else |
165 | confLine.append( "src " ); | 165 | confLine.append( "src " ); |
166 | } | 166 | } |
167 | break; | 167 | break; |
168 | case OConfItem::Destination : confLine.append( "dest " ); break; | 168 | case OConfItem::Destination : confLine.append( "dest " ); break; |
169 | case OConfItem::Option : confLine.append( "option " ); break; | 169 | case OConfItem::Option : confLine.append( "option " ); break; |
170 | case OConfItem::Arch : confLine.append( "arch " ); break; | 170 | case OConfItem::Arch : confLine.append( "arch " ); break; |
171 | default : break; | 171 | default : break; |
172 | }; | 172 | }; |
173 | 173 | ||
174 | confStream << confLine << " " << item->name() << " " << item->value() << "\n"; | 174 | confStream << confLine << " " << item->name() << " " << item->value() << "\n"; |
175 | } | 175 | } |
176 | } | 176 | } |
177 | 177 | ||
178 | confFile.close(); | 178 | confFile.close(); |
179 | } | 179 | } |
180 | else | 180 | else |
181 | { | 181 | { |
182 | // Problem writing to /etc/ipkg.conf, exit before removing other conf files | 182 | // Problem writing to /etc/ipkg.conf, exit before removing other conf files |
183 | return; | 183 | return; |
184 | } | 184 | } |
185 | 185 | ||
186 | // Delete /etc/ipkg/*.conf files (/etc/ipkg.conf should now have all settings | 186 | // Delete /etc/ipkg/*.conf files (/etc/ipkg.conf should now have all settings |
187 | QStringList confFiles; | 187 | QStringList confFiles; |
188 | QDir confDir( IPKG_CONF_DIR ); | 188 | QDir confDir( IPKG_CONF_DIR ); |
189 | if ( confDir.exists() ) | 189 | if ( confDir.exists() ) |
190 | { | 190 | { |
191 | confDir.setNameFilter( "*.conf" ); | 191 | confDir.setNameFilter( "*.conf" ); |
192 | confDir.setFilter( QDir::Files ); | 192 | confDir.setFilter( QDir::Files ); |
193 | confFiles = confDir.entryList( "*.conf", QDir::Files ); | 193 | confFiles = confDir.entryList( "*.conf", QDir::Files ); |
194 | 194 | ||
195 | QStringList::Iterator lastFile = confFiles.end(); | 195 | QStringList::Iterator lastFile = confFiles.end(); |
196 | for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) | 196 | for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) |
197 | { | 197 | { |
198 | // Create absolute file path if necessary | 198 | // Create absolute file path if necessary |
199 | QString absFile = (*it); | 199 | QString absFile = (*it); |
200 | if ( !absFile.startsWith( "/" ) ) | 200 | if ( !absFile.startsWith( "/" ) ) |
201 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); | 201 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); |
202 | 202 | ||
203 | // Delete file | 203 | // Delete file |
204 | QFile::remove( absFile ); | 204 | QFile::remove( absFile ); |
205 | } | 205 | } |
206 | } | 206 | } |
207 | 207 | ||
208 | // Reinitialize libipkg to pick up new configuration | 208 | // Reinitialize libipkg to pick up new configuration |
209 | ipkg_deinit( &m_ipkgArgs ); | 209 | ipkg_deinit( &m_ipkgArgs ); |
210 | ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); | 210 | ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); |
211 | m_ipkgArgs.noaction = false; | 211 | m_ipkgArgs.noaction = false; |
212 | m_ipkgArgs.force_defaults = true; | 212 | m_ipkgArgs.force_defaults = true; |
213 | } | 213 | } |
214 | 214 | ||
215 | void OIpkg::saveSettings() | 215 | void OIpkg::saveSettings() |
216 | { | 216 | { |
217 | // Save Ipkg execution options to application configuration file | 217 | // Save Ipkg execution options to application configuration file |
218 | if ( m_config ) | 218 | if ( m_config ) |
219 | { | 219 | { |
220 | m_config->setGroup( "Ipkg" ); | 220 | m_config->setGroup( "Ipkg" ); |
221 | m_config->writeEntry( "ExecOptions", m_ipkgExecOptions ); | 221 | m_config->writeEntry( "ExecOptions", m_ipkgExecOptions ); |
222 | m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity ); | 222 | m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity ); |
223 | } | 223 | } |
224 | } | 224 | } |
225 | 225 | ||
226 | OPackageList *OIpkg::availablePackages( const QString &server ) | 226 | OPackageList *OIpkg::availablePackages( const QString &server ) |
227 | { | 227 | { |
228 | // Load Ipkg configuration info if not already cached | 228 | // Load Ipkg configuration info if not already cached |
229 | if ( !m_confInfo ) | 229 | if ( !m_confInfo ) |
230 | loadConfiguration(); | 230 | loadConfiguration(); |
231 | 231 | ||
232 | // Build new server list (caller is responsible for deleting) | 232 | // Build new server list (caller is responsible for deleting) |
233 | OPackageList *pl = new OPackageList; | 233 | OPackageList *pl = new OPackageList; |
234 | 234 | ||
235 | // Open package list file | 235 | // Open package list file |
236 | QFile f( IPKG_PKG_PATH + "/" + server ); | 236 | QFile f( IPKG_PKG_PATH + "/" + server ); |
237 | if ( !f.open( IO_ReadOnly ) ) | 237 | if ( !f.open( IO_ReadOnly ) ) |
238 | return NULL; | 238 | return NULL; |
239 | QTextStream t( &f ); | 239 | QTextStream t( &f ); |
240 | 240 | ||
241 | // Process all information in package list file | 241 | // Process all information in package list file |
242 | OPackage *package = NULL; | 242 | OPackage *package = NULL; |
243 | QString line = t.readLine(); | 243 | QString line = t.readLine(); |
244 | while ( !t.eof() ) | 244 | while ( !t.eof() ) |
245 | { | 245 | { |
246 | // Determine key/value pair | 246 | // Determine key/value pair |
247 | int pos = line.find( ':', 0 ); | 247 | int pos = line.find( ':', 0 ); |
248 | QString key; | 248 | QString key; |
249 | if ( pos > -1 ) | 249 | if ( pos > -1 ) |
250 | key = line.mid( 0, pos ); | 250 | key = line.mid( 0, pos ); |
251 | else | 251 | else |
252 | key = QString::null; | 252 | key = QString::null; |
253 | QString value = line.mid( pos+2, line.length()-pos ); | 253 | QString value = line.mid( pos+2, line.length()-pos ); |
254 | 254 | ||
255 | // Allocate new package and insert into list | 255 | // Allocate new package and insert into list |
256 | if ( package == NULL && !key.isEmpty() ) | 256 | if ( package == NULL && !key.isEmpty() ) |
257 | { | 257 | { |
258 | package = new OPackage( value ); | 258 | package = new OPackage( value ); |
259 | package->setSource( server ); | 259 | package->setSource( server ); |
260 | pl->append( package ); | 260 | pl->append( package ); |
261 | } | 261 | } |
262 | 262 | ||
263 | // Update package data | 263 | // Update package data |
264 | if ( key == "Package" ) | 264 | if ( key == "Package" ) |
265 | package->setName( value ); | 265 | package->setName( value ); |
266 | else if ( key == "Version" ) | 266 | else if ( key == "Version" ) |
267 | package->setVersion( value ); | 267 | package->setVersion( value ); |
268 | else if ( key == "Section" ) | 268 | else if ( key == "Section" ) |
269 | package->setCategory( value ); | 269 | package->setCategory( value ); |
270 | //DataManager::setAvailableCategories( value ); | 270 | //DataManager::setAvailableCategories( value ); |
271 | else if ( key.isEmpty() && value.isEmpty() ) | 271 | else if ( key.isEmpty() && value.isEmpty() ) |
272 | package = NULL; | 272 | package = NULL; |
273 | 273 | ||
274 | // Skip past all description lines | 274 | // Skip past all description lines |
275 | if ( key == "Description" ) | 275 | if ( key == "Description" ) |
276 | { | 276 | { |
277 | line = t.readLine(); | 277 | line = t.readLine(); |
278 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) | 278 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) |
279 | line = t.readLine(); | 279 | line = t.readLine(); |
280 | } | 280 | } |
281 | else | 281 | else |
282 | line = t.readLine(); | 282 | line = t.readLine(); |
283 | } | 283 | } |
284 | 284 | ||
285 | f.close(); | 285 | f.close(); |
286 | 286 | ||
287 | return pl; | 287 | return pl; |
288 | } | 288 | } |
289 | 289 | ||
290 | OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath ) | 290 | OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath ) |
291 | { | 291 | { |
292 | // Load Ipkg configuration info if not already cached | 292 | // Load Ipkg configuration info if not already cached |
293 | if ( !m_confInfo ) | 293 | if ( !m_confInfo ) |
294 | loadConfiguration(); | 294 | loadConfiguration(); |
295 | 295 | ||
296 | // Build new server list (caller is responsible for deleting) | 296 | // Build new server list (caller is responsible for deleting) |
297 | OPackageList *pl = new OPackageList; | 297 | OPackageList *pl = new OPackageList; |
298 | 298 | ||
299 | // Open status file | 299 | // Open status file |
300 | QString path = destPath; | 300 | QString path = destPath; |
301 | if ( path.right( 1 ) != "/" ) | 301 | if ( path.right( 1 ) != "/" ) |
302 | path.append( "/" ); | 302 | path.append( "/" ); |
303 | path.append( IPKG_STATUS_PATH ); | 303 | path.append( IPKG_STATUS_PATH ); |
304 | 304 | ||
305 | QFile f( path ); | 305 | QFile f( path ); |
306 | if ( !f.open( IO_ReadOnly ) ) | 306 | if ( !f.open( IO_ReadOnly ) ) |
307 | return NULL; | 307 | return NULL; |
308 | QTextStream t( &f ); | 308 | QTextStream t( &f ); |
309 | 309 | ||
310 | // Process all information in status file | 310 | // Process all information in status file |
311 | bool newPackage = false; | 311 | bool newPackage = false; |
312 | QString line = t.readLine(); | 312 | QString line = t.readLine(); |
313 | QString name; | 313 | QString name; |
314 | QString version; | 314 | QString version; |
315 | QString status; | 315 | QString status; |
316 | 316 | ||
317 | while ( !t.eof() ) | 317 | while ( !t.eof() ) |
318 | { | 318 | { |
319 | // Determine key/value pair | 319 | // Determine key/value pair |
320 | int pos = line.find( ':', 0 ); | 320 | int pos = line.find( ':', 0 ); |
321 | QString key; | 321 | QString key; |
322 | if ( pos > -1 ) | 322 | if ( pos > -1 ) |
323 | key = line.mid( 0, pos ); | 323 | key = line.mid( 0, pos ); |
324 | else | 324 | else |
325 | key = QString::null; | 325 | key = QString::null; |
326 | QString value = line.mid( pos+2, line.length()-pos ); | 326 | QString value = line.mid( pos+2, line.length()-pos ); |
327 | 327 | ||
328 | // Allocate new package and insert into list | 328 | // Allocate new package and insert into list |
329 | if ( newPackage && !key.isEmpty() ) | 329 | if ( newPackage && !key.isEmpty() ) |
330 | { | 330 | { |
331 | // Add to list only if it has a valid name and is installed | 331 | // Add to list only if it has a valid name and is installed |
332 | if ( !name.isNull() && status.contains( " installed" ) ) | 332 | if ( !name.isNull() && status.contains( " installed" ) ) |
333 | { | 333 | { |
334 | pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); | 334 | pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); |
335 | name = QString::null; | 335 | name = QString::null; |
336 | version = QString::null; | 336 | version = QString::null; |
337 | status = QString::null; | 337 | status = QString::null; |
338 | 338 | ||
339 | newPackage = false; | 339 | newPackage = false; |
340 | } | 340 | } |
341 | } | 341 | } |
342 | 342 | ||
343 | // Update package data | 343 | // Update package data |
344 | if ( key == "Package" ) | 344 | if ( key == "Package" ) |
345 | name = value; | 345 | name = value; |
346 | else if ( key == "Version" ) | 346 | else if ( key == "Version" ) |
347 | version = value; | 347 | version = value; |
348 | else if ( key == "Status" ) | 348 | else if ( key == "Status" ) |
349 | status = value; | 349 | status = value; |
350 | else if ( key.isEmpty() && value.isEmpty() ) | 350 | else if ( key.isEmpty() && value.isEmpty() ) |
351 | newPackage = true; | 351 | newPackage = true; |
352 | 352 | ||
353 | // Skip past all description lines | 353 | // Skip past all description lines |
354 | if ( key == "Description" ) | 354 | if ( key == "Description" ) |
355 | { | 355 | { |
356 | line = t.readLine(); | 356 | line = t.readLine(); |
357 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) | 357 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) |
358 | line = t.readLine(); | 358 | line = t.readLine(); |
359 | } | 359 | } |
360 | else | 360 | else |
361 | line = t.readLine(); | 361 | line = t.readLine(); |
362 | } | 362 | } |
363 | 363 | ||
364 | f.close(); | 364 | f.close(); |
365 | 365 | ||
366 | // Make sure to add to list last entry | ||
367 | if ( !name.isNull() && status.contains( " installed" ) ) | ||
368 | pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); | ||
369 | |||
366 | return pl; | 370 | return pl; |
367 | } | 371 | } |
368 | 372 | ||
369 | OConfItem *OIpkg::findConfItem( OConfItem::Type type, const QString &name ) | 373 | OConfItem *OIpkg::findConfItem( OConfItem::Type type, const QString &name ) |
370 | { | 374 | { |
371 | // Find configuration item in list | 375 | // Find configuration item in list |
372 | OConfItemListIterator configIt( *m_confInfo ); | 376 | OConfItemListIterator configIt( *m_confInfo ); |
373 | OConfItem *config = 0l; | 377 | OConfItem *config = 0l; |
374 | for ( ; configIt.current(); ++configIt ) | 378 | for ( ; configIt.current(); ++configIt ) |
375 | { | 379 | { |
376 | config = configIt.current(); | 380 | config = configIt.current(); |
377 | if ( config->type() == type && config->name() == name ) | 381 | if ( config->type() == type && config->name() == name ) |
378 | break; | 382 | break; |
379 | } | 383 | } |
380 | 384 | ||
381 | if ( config && config->type() == type && config->name() == name ) | 385 | if ( config && config->type() == type && config->name() == name ) |
382 | return config; | 386 | return config; |
383 | 387 | ||
384 | return 0l; | 388 | return 0l; |
385 | } | 389 | } |
386 | 390 | ||
387 | bool OIpkg::executeCommand( OPackage::Command command, const QStringList ¶meters, const QString &destination, | 391 | bool OIpkg::executeCommand( OPackage::Command command, const QStringList ¶meters, const QString &destination, |
388 | const QObject *receiver, const char *slotOutput, bool rawOutput ) | 392 | const QObject *receiver, const char *slotOutput, bool rawOutput ) |
389 | { | 393 | { |
390 | if ( command == OPackage::NotDefined ) | 394 | if ( command == OPackage::NotDefined ) |
391 | return false; | 395 | return false; |
392 | 396 | ||
393 | // Set ipkg run-time options/arguments | 397 | // Set ipkg run-time options/arguments |
394 | m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS ); | 398 | m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS ); |
395 | m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL ); | 399 | m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL ); |
396 | // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE ); | 400 | // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE ); |
397 | m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE ); | 401 | m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE ); |
398 | m_ipkgArgs.verbosity = m_ipkgExecVerbosity; | 402 | m_ipkgArgs.verbosity = m_ipkgExecVerbosity; |
399 | if ( m_ipkgArgs.dest ) | 403 | if ( m_ipkgArgs.dest ) |
400 | free( m_ipkgArgs.dest ); | 404 | free( m_ipkgArgs.dest ); |
401 | if ( !destination.isNull() ) | 405 | if ( !destination.isNull() ) |
402 | { | 406 | { |
403 | int len = destination.length() + 1; | 407 | int len = destination.length() + 1; |
404 | m_ipkgArgs.dest = (char *)malloc( len ); | 408 | m_ipkgArgs.dest = (char *)malloc( len ); |
405 | strncpy( m_ipkgArgs.dest, destination, destination.length() ); | 409 | strncpy( m_ipkgArgs.dest, destination, destination.length() ); |
406 | m_ipkgArgs.dest[ len - 1 ] = '\0'; | 410 | m_ipkgArgs.dest[ len - 1 ] = '\0'; |
407 | } | 411 | } |
408 | else | 412 | else |
409 | m_ipkgArgs.dest = 0l; | 413 | m_ipkgArgs.dest = 0l; |
410 | 414 | ||
411 | // Connect output signal to widget | 415 | // Connect output signal to widget |
412 | 416 | ||
413 | if ( !rawOutput ) | 417 | if ( !rawOutput ) |
414 | { | 418 | { |
415 | // TODO - connect to local slot and parse output before emitting signalIpkgMessage | 419 | // TODO - connect to local slot and parse output before emitting signalIpkgMessage |
416 | } | 420 | } |
417 | 421 | ||
418 | switch( command ) | 422 | switch( command ) |
419 | { | 423 | { |
420 | case OPackage::Update : { | 424 | case OPackage::Update : { |
421 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); | 425 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); |
422 | ipkg_lists_update( &m_ipkgArgs ); | 426 | ipkg_lists_update( &m_ipkgArgs ); |
423 | }; | 427 | }; |
424 | break; | 428 | break; |
425 | case OPackage::Upgrade : { | 429 | case OPackage::Upgrade : { |
426 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); | 430 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); |
427 | ipkg_packages_upgrade( &m_ipkgArgs ); | 431 | ipkg_packages_upgrade( &m_ipkgArgs ); |
428 | 432 | ||
429 | // Re-link non-root destinations to make sure everything is in sync | 433 | // Re-link non-root destinations to make sure everything is in sync |
430 | OConfItemList *destList = destinations(); | 434 | OConfItemList *destList = destinations(); |
431 | OConfItemListIterator it( *destList ); | 435 | OConfItemListIterator it( *destList ); |
432 | for ( ; it.current(); ++it ) | 436 | for ( ; it.current(); ++it ) |
433 | { | 437 | { |
434 | OConfItem *dest = it.current(); | 438 | OConfItem *dest = it.current(); |
435 | if ( dest->name() != "root" ) | 439 | if ( dest->name() != "root" ) |
436 | linkPackageDir( dest->name() ); | 440 | linkPackageDir( dest->name() ); |
437 | } | 441 | } |
438 | delete destList; | 442 | delete destList; |
439 | }; | 443 | }; |
440 | break; | 444 | break; |
441 | case OPackage::Install : { | 445 | case OPackage::Install : { |
442 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); | 446 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); |
443 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) | 447 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) |
444 | { | 448 | { |
445 | ipkg_packages_install( &m_ipkgArgs, (*it) ); | 449 | ipkg_packages_install( &m_ipkgArgs, (*it) ); |
446 | } | 450 | } |
447 | if ( destination != "root" ) | 451 | if ( destination != "root" ) |
448 | linkPackageDir( destination ); | 452 | linkPackageDir( destination ); |
449 | }; | 453 | }; |
450 | break; | 454 | break; |
451 | case OPackage::Remove : { | 455 | case OPackage::Remove : { |
452 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); | 456 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); |
453 | 457 | ||
454 | // Get list of destinations for unlinking of packages not installed to root | 458 | // Get list of destinations for unlinking of packages not installed to root |
455 | OConfItemList *destList = destinations(); | 459 | OConfItemList *destList = destinations(); |
456 | 460 | ||
457 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) | 461 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) |
458 | { | 462 | { |
459 | unlinkPackage( (*it), destList ); | 463 | unlinkPackage( (*it), destList ); |
460 | ipkg_packages_remove( &m_ipkgArgs, (*it), true ); | 464 | ipkg_packages_remove( &m_ipkgArgs, (*it), true ); |
461 | } | 465 | } |
462 | 466 | ||
463 | delete destList; | 467 | delete destList; |
464 | }; | 468 | }; |
465 | break; | 469 | break; |
466 | case OPackage::Download : { | 470 | case OPackage::Download : { |
467 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); | 471 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); |
468 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) | 472 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) |
469 | { | 473 | { |
470 | ipkg_packages_download( &m_ipkgArgs, (*it) ); | 474 | ipkg_packages_download( &m_ipkgArgs, (*it) ); |
471 | } | 475 | } |
472 | }; | 476 | }; |
473 | break; | 477 | break; |
474 | case OPackage::Info : { | 478 | case OPackage::Info : { |
475 | connect( this, SIGNAL(signalIpkgStatus(const QString &)), receiver, slotOutput ); | 479 | connect( this, SIGNAL(signalIpkgStatus(const QString &)), receiver, slotOutput ); |
476 | ipkg_packages_info( &m_ipkgArgs, (*parameters.begin()), &fIpkgStatus, 0l ); | 480 | ipkg_packages_info( &m_ipkgArgs, (*parameters.begin()), &fIpkgStatus, 0l ); |
477 | }; | 481 | }; |
478 | break; | 482 | break; |
479 | case OPackage::Files : { | 483 | case OPackage::Files : { |
480 | connect( this, SIGNAL(signalIpkgList(const QString &)), receiver, slotOutput ); | 484 | connect( this, SIGNAL(signalIpkgList(const QString &)), receiver, slotOutput ); |
481 | ipkg_package_files( &m_ipkgArgs, (*parameters.begin()), &fIpkgFiles, 0l ); | 485 | ipkg_package_files( &m_ipkgArgs, (*parameters.begin()), &fIpkgFiles, 0l ); |
482 | }; | 486 | }; |
483 | break; | 487 | break; |
484 | default : break; | 488 | default : break; |
485 | }; | 489 | }; |
486 | 490 | ||
487 | return true; | 491 | return true; |
488 | } | 492 | } |
489 | 493 | ||
490 | void OIpkg::ipkgMessage( char *msg ) | 494 | void OIpkg::ipkgMessage( char *msg ) |
491 | { | 495 | { |
492 | emit signalIpkgMessage( msg ); | 496 | emit signalIpkgMessage( msg ); |
493 | } | 497 | } |
494 | 498 | ||
495 | void OIpkg::ipkgStatus( char *status ) | 499 | void OIpkg::ipkgStatus( char *status ) |
496 | { | 500 | { |
497 | emit signalIpkgStatus( status ); | 501 | emit signalIpkgStatus( status ); |
498 | } | 502 | } |
499 | 503 | ||
500 | void OIpkg::ipkgList( char *filelist ) | 504 | void OIpkg::ipkgList( char *filelist ) |
501 | { | 505 | { |
502 | emit signalIpkgList( filelist ); | 506 | emit signalIpkgList( filelist ); |
503 | } | 507 | } |
504 | 508 | ||
505 | void OIpkg::loadConfiguration() | 509 | void OIpkg::loadConfiguration() |
506 | { | 510 | { |
507 | if ( m_confInfo ) | 511 | if ( m_confInfo ) |
508 | delete m_confInfo; | 512 | delete m_confInfo; |
509 | 513 | ||
510 | // Load configuration item list | 514 | // Load configuration item list |
511 | m_confInfo = new OConfItemList(); | 515 | m_confInfo = new OConfItemList(); |
512 | 516 | ||
513 | QStringList confFiles; | 517 | QStringList confFiles; |
514 | QDir confDir( IPKG_CONF_DIR ); | 518 | QDir confDir( IPKG_CONF_DIR ); |
515 | if ( confDir.exists() ) | 519 | if ( confDir.exists() ) |
516 | { | 520 | { |
517 | confDir.setNameFilter( "*.conf" ); | 521 | confDir.setNameFilter( "*.conf" ); |
518 | confDir.setFilter( QDir::Files ); | 522 | confDir.setFilter( QDir::Files ); |
519 | confFiles = confDir.entryList( "*.conf", QDir::Files ); | 523 | confFiles = confDir.entryList( "*.conf", QDir::Files ); |
520 | } | 524 | } |
521 | confFiles << IPKG_CONF; | 525 | confFiles << IPKG_CONF; |
522 | 526 | ||
523 | QStringList::Iterator lastFile = confFiles.end(); | 527 | QStringList::Iterator lastFile = confFiles.end(); |
524 | for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) | 528 | for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) |
525 | { | 529 | { |
526 | // Create absolute file path if necessary | 530 | // Create absolute file path if necessary |
527 | QString absFile = (*it); | 531 | QString absFile = (*it); |
528 | if ( !absFile.startsWith( "/" ) ) | 532 | if ( !absFile.startsWith( "/" ) ) |
529 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); | 533 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); |
530 | 534 | ||
531 | // Read in file | 535 | // Read in file |
532 | QFile f( absFile ); | 536 | QFile f( absFile ); |
533 | if ( f.open( IO_ReadOnly ) ) | 537 | if ( f.open( IO_ReadOnly ) ) |
534 | { | 538 | { |
535 | QTextStream s( &f ); | 539 | QTextStream s( &f ); |
536 | while ( !s.eof() ) | 540 | while ( !s.eof() ) |
537 | { | 541 | { |
538 | 542 | ||
539 | QString line = s.readLine().simplifyWhiteSpace(); | 543 | QString line = s.readLine().simplifyWhiteSpace(); |
540 | 544 | ||
541 | // Parse line and save info to the conf options list | 545 | // Parse line and save info to the conf options list |
542 | if ( !line.isEmpty() ) | 546 | if ( !line.isEmpty() ) |
543 | { | 547 | { |
544 | if ( !line.startsWith( "#" ) || | 548 | if ( !line.startsWith( "#" ) || |
545 | line.startsWith( "#src" ) || | 549 | line.startsWith( "#src" ) || |
546 | line.startsWith( "#dest" ) || | 550 | line.startsWith( "#dest" ) || |
547 | line.startsWith( "#arch" ) || | 551 | line.startsWith( "#arch" ) || |
548 | line.startsWith( "#option" ) ) | 552 | line.startsWith( "#option" ) ) |
549 | { | 553 | { |
550 | int pos = line.find( ' ', 1 ); | 554 | int pos = line.find( ' ', 1 ); |
551 | 555 | ||
552 | // Type | 556 | // Type |
553 | QString typeStr = line.left( pos ); | 557 | QString typeStr = line.left( pos ); |
554 | OConfItem::Type type; | 558 | OConfItem::Type type; |
555 | QString features; | 559 | QString features; |
556 | if ( typeStr == "src" || typeStr == "#src" ) | 560 | if ( typeStr == "src" || typeStr == "#src" ) |
557 | type = OConfItem::Source; | 561 | type = OConfItem::Source; |
558 | else if ( typeStr == "src/gz" || typeStr == "#src/gz" ) | 562 | else if ( typeStr == "src/gz" || typeStr == "#src/gz" ) |
559 | { | 563 | { |
560 | type = OConfItem::Source; | 564 | type = OConfItem::Source; |
561 | features = "Compressed"; | 565 | features = "Compressed"; |
562 | } | 566 | } |
563 | else if ( typeStr == "dest" || typeStr == "#dest" ) | 567 | else if ( typeStr == "dest" || typeStr == "#dest" ) |
564 | type = OConfItem::Destination; | 568 | type = OConfItem::Destination; |
565 | else if ( typeStr == "option" || typeStr == "#option" ) | 569 | else if ( typeStr == "option" || typeStr == "#option" ) |
566 | type = OConfItem::Option; | 570 | type = OConfItem::Option; |
567 | else if ( typeStr == "arch" || typeStr == "#arch" ) | 571 | else if ( typeStr == "arch" || typeStr == "#arch" ) |
568 | type = OConfItem::Arch; | 572 | type = OConfItem::Arch; |
569 | else | 573 | else |
570 | type = OConfItem::NotDefined; | 574 | type = OConfItem::NotDefined; |
571 | ++pos; | 575 | ++pos; |
572 | int endpos = line.find( ' ', pos ); | 576 | int endpos = line.find( ' ', pos ); |
573 | 577 | ||
574 | // Name | 578 | // Name |
575 | QString name = line.mid( pos, endpos - pos ); | 579 | QString name = line.mid( pos, endpos - pos ); |
576 | 580 | ||
577 | // Value | 581 | // Value |
578 | QString value = ""; | 582 | QString value = ""; |
579 | if ( endpos > -1 ) | 583 | if ( endpos > -1 ) |
580 | value = line.right( line.length() - endpos - 1 ); | 584 | value = line.right( line.length() - endpos - 1 ); |
581 | 585 | ||
582 | // Active | 586 | // Active |
583 | bool active = !line.startsWith( "#" ); | 587 | bool active = !line.startsWith( "#" ); |
584 | 588 | ||
585 | // Add to list | 589 | // Add to list |
586 | m_confInfo->append( new OConfItem( type, name, value, features, active ) ); | 590 | m_confInfo->append( new OConfItem( type, name, value, features, active ) ); |
587 | } | 591 | } |
588 | } | 592 | } |
589 | } | 593 | } |
590 | 594 | ||
591 | f.close(); | 595 | f.close(); |
592 | } | 596 | } |
593 | } | 597 | } |
594 | 598 | ||
595 | // Load Ipkg execution options from application configuration file | 599 | // Load Ipkg execution options from application configuration file |
596 | if ( m_config ) | 600 | if ( m_config ) |
597 | { | 601 | { |
598 | m_config->setGroup( "Ipkg" ); | 602 | m_config->setGroup( "Ipkg" ); |
599 | m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions ); | 603 | m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions ); |
600 | m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity ); | 604 | m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity ); |
601 | } | 605 | } |
602 | } | 606 | } |
603 | 607 | ||
604 | OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter ) | 608 | OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter ) |
605 | { | 609 | { |
606 | // Load Ipkg configuration info if not already cached | 610 | // Load Ipkg configuration info if not already cached |
607 | if ( !m_confInfo ) | 611 | if ( !m_confInfo ) |
608 | loadConfiguration(); | 612 | loadConfiguration(); |
609 | 613 | ||
610 | // Build new server list (caller is responsible for deleting) | 614 | // Build new server list (caller is responsible for deleting) |
611 | OConfItemList *sl = new OConfItemList; | 615 | OConfItemList *sl = new OConfItemList; |
612 | 616 | ||
613 | // If typefilter is empty, retrieve all items | 617 | // If typefilter is empty, retrieve all items |
614 | bool retrieveAll = ( typefilter == OConfItem::NotDefined ); | 618 | bool retrieveAll = ( typefilter == OConfItem::NotDefined ); |
615 | 619 | ||
616 | // Parse configuration info for servers | 620 | // Parse configuration info for servers |
617 | OConfItemListIterator it( *m_confInfo ); | 621 | OConfItemListIterator it( *m_confInfo ); |
618 | for ( ; it.current(); ++it ) | 622 | for ( ; it.current(); ++it ) |
619 | { | 623 | { |
620 | OConfItem *item = it.current(); | 624 | OConfItem *item = it.current(); |
621 | if ( retrieveAll || item->type() == typefilter ) | 625 | if ( retrieveAll || item->type() == typefilter ) |
622 | { | 626 | { |
623 | sl->append( item ); | 627 | sl->append( item ); |
624 | } | 628 | } |
625 | } | 629 | } |
626 | 630 | ||
627 | return sl; | 631 | return sl; |
628 | } | 632 | } |
629 | 633 | ||
630 | const QString &OIpkg::rootPath() | 634 | const QString &OIpkg::rootPath() |
631 | { | 635 | { |
632 | if ( m_rootPath.isEmpty() ) | 636 | if ( m_rootPath.isEmpty() ) |
633 | { | 637 | { |
634 | OConfItem *rootDest = findConfItem( OConfItem::Destination, "root" ); | 638 | OConfItem *rootDest = findConfItem( OConfItem::Destination, "root" ); |
635 | rootDest ? m_rootPath = rootDest->value() | 639 | rootDest ? m_rootPath = rootDest->value() |
636 | : m_rootPath = '/'; | 640 | : m_rootPath = '/'; |
637 | if ( m_rootPath.right( 1 ) == '/' ) | 641 | if ( m_rootPath.right( 1 ) == '/' ) |
638 | m_rootPath.truncate( m_rootPath.length() - 1 ); | 642 | m_rootPath.truncate( m_rootPath.length() - 1 ); |
639 | } | 643 | } |
640 | return m_rootPath; | 644 | return m_rootPath; |
641 | } | 645 | } |
642 | 646 | ||
643 | void OIpkg::linkPackageDir( const QString &dest ) | 647 | void OIpkg::linkPackageDir( const QString &dest ) |
644 | { | 648 | { |
645 | if ( !dest.isNull() ) | 649 | if ( !dest.isNull() ) |
646 | { | 650 | { |
647 | OConfItem *destConfItem = findConfItem( OConfItem::Destination, dest ); | 651 | OConfItem *destConfItem = findConfItem( OConfItem::Destination, dest ); |
648 | 652 | ||
649 | emit signalIpkgMessage( tr( "Linking packages installed in: %1" ).arg( dest ) ); | 653 | emit signalIpkgMessage( tr( "Linking packages installed in: %1" ).arg( dest ) ); |
650 | 654 | ||
651 | // Set package destination directory | 655 | // Set package destination directory |
652 | QString destDir = destConfItem->value(); | 656 | QString destDir = destConfItem->value(); |
653 | QString destInfoDir = destDir; | 657 | QString destInfoDir = destDir; |
654 | if ( destInfoDir.right( 1 ) != '/' ) | 658 | if ( destInfoDir.right( 1 ) != '/' ) |
655 | destInfoDir.append( '/' ); | 659 | destInfoDir.append( '/' ); |
656 | destInfoDir.append( IPKG_INFO_PATH ); | 660 | destInfoDir.append( IPKG_INFO_PATH ); |
657 | 661 | ||
658 | // Get list of installed packages in destination | 662 | // Get list of installed packages in destination |
659 | QDir packageDir( destInfoDir ); | 663 | QDir packageDir( destInfoDir ); |
660 | QStringList packageFiles; | 664 | QStringList packageFiles; |
661 | if ( packageDir.exists() ) | 665 | if ( packageDir.exists() ) |
662 | { | 666 | { |
663 | packageDir.setNameFilter( "*.list" ); | 667 | packageDir.setNameFilter( "*.list" ); |
664 | packageDir.setFilter( QDir::Files ); | 668 | packageDir.setFilter( QDir::Files ); |
665 | packageFiles = packageDir.entryList( "*.list", QDir::Files ); | 669 | packageFiles = packageDir.entryList( "*.list", QDir::Files ); |
666 | } | 670 | } |
667 | 671 | ||
668 | // Link all files for every package installed in desination | 672 | // Link all files for every package installed in desination |
669 | QStringList::Iterator lastFile = packageFiles.end(); | 673 | QStringList::Iterator lastFile = packageFiles.end(); |
670 | for ( QStringList::Iterator it = packageFiles.begin(); it != lastFile; ++it ) | 674 | for ( QStringList::Iterator it = packageFiles.begin(); it != lastFile; ++it ) |
671 | { | 675 | { |
672 | //emit signalIpkgMessage( QString( "Processing: %1/%2" ).arg( destInfoDir ).arg (*it) ); | 676 | //emit signalIpkgMessage( QString( "Processing: %1/%2" ).arg( destInfoDir ).arg (*it) ); |
673 | QString packageFileName = destInfoDir; | 677 | QString packageFileName = destInfoDir; |
674 | packageFileName.append( '/' ); | 678 | packageFileName.append( '/' ); |
675 | packageFileName.append( (*it) ); | 679 | packageFileName.append( (*it) ); |
676 | QFile packageFile( packageFileName ); | 680 | QFile packageFile( packageFileName ); |
677 | if ( packageFile.open( IO_ReadOnly ) ) | 681 | if ( packageFile.open( IO_ReadOnly ) ) |
678 | { | 682 | { |
679 | QTextStream t( &packageFile ); | 683 | QTextStream t( &packageFile ); |
680 | QString linkFile; | 684 | QString linkFile; |
681 | while ( !t.eof() ) | 685 | while ( !t.eof() ) |
682 | { | 686 | { |
683 | // Get the name of the file to link and build the sym link filename | 687 | // Get the name of the file to link and build the sym link filename |
684 | linkFile = t.readLine(); | 688 | linkFile = t.readLine(); |
685 | QString linkDest( linkFile.right( linkFile.length() - destDir.length() ) ); | 689 | QString linkDest( linkFile.right( linkFile.length() - destDir.length() ) ); |
686 | linkDest.prepend( rootPath() ); | 690 | linkDest.prepend( rootPath() ); |
687 | 691 | ||
688 | // If file installed file is actually symbolic link, use actual file for linking | 692 | // If file installed file is actually symbolic link, use actual file for linking |
689 | QFileInfo fileInfo( linkFile ); | 693 | QFileInfo fileInfo( linkFile ); |
690 | if ( fileInfo.isSymLink() && !fileInfo.readLink().isEmpty() ) | 694 | if ( fileInfo.isSymLink() && !fileInfo.readLink().isEmpty() ) |
691 | linkFile = fileInfo.readLink(); | 695 | linkFile = fileInfo.readLink(); |
692 | 696 | ||
693 | // See if directory exists in 'root', if not, create | 697 | // See if directory exists in 'root', if not, create |
694 | fileInfo.setFile( linkDest ); | 698 | fileInfo.setFile( linkDest ); |
695 | QString linkDestDirName = fileInfo.dirPath( true ); | 699 | QString linkDestDirName = fileInfo.dirPath( true ); |
696 | QDir linkDestDir( linkDestDirName ); | 700 | QDir linkDestDir( linkDestDirName ); |
697 | if ( !linkDestDir.exists() ) | 701 | if ( !linkDestDir.exists() ) |
698 | { | 702 | { |
699 | linkDestDir.mkdir( linkDestDirName ); | 703 | linkDestDir.mkdir( linkDestDirName ); |
700 | } | 704 | } |
701 | else | 705 | else |
702 | { | 706 | { |
703 | // Remove any previous link to make sure we will be pointing to the current version | 707 | // Remove any previous link to make sure we will be pointing to the current version |
704 | if ( QFile::exists( linkDest ) ) | 708 | if ( QFile::exists( linkDest ) ) |
705 | QFile::remove( linkDest ); | 709 | QFile::remove( linkDest ); |
706 | } | 710 | } |
707 | 711 | ||
708 | // Link the file | 712 | // Link the file |
709 | //emit signalIpkgMessage( QString( "Linking '%1' to '%2'" ).arg( linkFile ).arg( linkDest ) ); | 713 | //emit signalIpkgMessage( QString( "Linking '%1' to '%2'" ).arg( linkFile ).arg( linkDest ) ); |
710 | if ( symlink( linkFile, linkDest ) == -1 ) | 714 | if ( symlink( linkFile, linkDest ) == -1 ) |
711 | emit signalIpkgMessage( tr( "Error linkling '%1' to '%2'" ) | 715 | emit signalIpkgMessage( tr( "Error linkling '%1' to '%2'" ) |
712 | .arg( linkFile ) | 716 | .arg( linkFile ) |
713 | .arg( linkDest ) ); | 717 | .arg( linkDest ) ); |
714 | } | 718 | } |
715 | packageFile.close(); | 719 | packageFile.close(); |
716 | } | 720 | } |
717 | } | 721 | } |
718 | } | 722 | } |
719 | } | 723 | } |
720 | 724 | ||
721 | void OIpkg::unlinkPackage( const QString &package, OConfItemList *destList ) | 725 | void OIpkg::unlinkPackage( const QString &package, OConfItemList *destList ) |
722 | { | 726 | { |
723 | if ( !package.isNull() ) | 727 | if ( !package.isNull() ) |
724 | { | 728 | { |
725 | // Find destination package is installed in | 729 | // Find destination package is installed in |
726 | if ( destList ) | 730 | if ( destList ) |
727 | { | 731 | { |
728 | OConfItemListIterator it( *destList ); | 732 | OConfItemListIterator it( *destList ); |
729 | for ( ; it.current(); ++it ) | 733 | for ( ; it.current(); ++it ) |
730 | { | 734 | { |
731 | OConfItem *dest = it.current(); | 735 | OConfItem *dest = it.current(); |
732 | QString destInfoFileName = QString( "%1/%2/%3.list" ).arg( dest->value() ) | 736 | QString destInfoFileName = QString( "%1/%2/%3.list" ).arg( dest->value() ) |
733 | .arg( IPKG_INFO_PATH ) | 737 | .arg( IPKG_INFO_PATH ) |
734 | .arg( package ); | 738 | .arg( package ); |
735 | //emit signalIpkgMessage( QString( "Looking for '%1'" ).arg ( destInfoFileName ) ); | 739 | //emit signalIpkgMessage( QString( "Looking for '%1'" ).arg ( destInfoFileName ) ); |
736 | 740 | ||
737 | // If found and destination is not 'root', remove symbolic links | 741 | // If found and destination is not 'root', remove symbolic links |
738 | if ( QFile::exists( destInfoFileName ) && dest->name() != "root" ) | 742 | if ( QFile::exists( destInfoFileName ) && dest->name() != "root" ) |
739 | { | 743 | { |
740 | QFile destInfoFile( destInfoFileName ); | 744 | QFile destInfoFile( destInfoFileName ); |
741 | if ( destInfoFile.open( IO_ReadOnly ) ) | 745 | if ( destInfoFile.open( IO_ReadOnly ) ) |
742 | { | 746 | { |
743 | QTextStream t( &destInfoFile ); | 747 | QTextStream t( &destInfoFile ); |
744 | QString linkFile; | 748 | QString linkFile; |
745 | while ( !t.eof() ) | 749 | while ( !t.eof() ) |
746 | { | 750 | { |
747 | // Get the name of the file to link and build the sym link filename | 751 | // Get the name of the file to link and build the sym link filename |
748 | linkFile = t.readLine(); | 752 | linkFile = t.readLine(); |
749 | QString linkDest( linkFile.right( linkFile.length() - | 753 | QString linkDest( linkFile.right( linkFile.length() - |
750 | dest->value().length() ) ); | 754 | dest->value().length() ) ); |
751 | linkDest.prepend( rootPath() ); | 755 | linkDest.prepend( rootPath() ); |
752 | 756 | ||
753 | //emit signalIpkgMessage( QString( "Deleting: '%1'" ).arg( linkDest ) ); | 757 | //emit signalIpkgMessage( QString( "Deleting: '%1'" ).arg( linkDest ) ); |
754 | QFile::remove( linkDest ); | 758 | QFile::remove( linkDest ); |
755 | } | 759 | } |
756 | destInfoFile.close(); | 760 | destInfoFile.close(); |
757 | } | 761 | } |
758 | 762 | ||
759 | emit signalIpkgMessage( tr( "Links removed for: %1" ).arg( package ) ); | 763 | emit signalIpkgMessage( tr( "Links removed for: %1" ).arg( package ) ); |
760 | return; | 764 | return; |
761 | } | 765 | } |
762 | } | 766 | } |
763 | } | 767 | } |
764 | } | 768 | } |
765 | } | 769 | } |
diff --git a/noncore/settings/packagemanager/opackagemanager.cpp b/noncore/settings/packagemanager/opackagemanager.cpp index ac16954..c9fdec1 100644 --- a/noncore/settings/packagemanager/opackagemanager.cpp +++ b/noncore/settings/packagemanager/opackagemanager.cpp | |||
@@ -1,397 +1,394 @@ | |||
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 "opackagemanager.h" | 32 | #include "opackagemanager.h" |
33 | #include "oipkgconfigdlg.h" | 33 | #include "oipkgconfigdlg.h" |
34 | 34 | ||
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | 36 | ||
37 | #include <ctype.h> | 37 | #include <ctype.h> |
38 | 38 | ||
39 | OPackageManager::OPackageManager( Config *config, QObject *parent, const char *name ) | 39 | OPackageManager::OPackageManager( Config *config, QObject *parent, const char *name ) |
40 | : QObject( parent, name ) | 40 | : QObject( parent, name ) |
41 | , m_config( config ) | 41 | , m_config( config ) |
42 | , m_ipkg( m_config, this ) | 42 | , m_ipkg( m_config, this ) |
43 | , m_packages( 9973 ) | 43 | , m_packages( 9973 ) |
44 | , m_categories() | 44 | , m_categories() |
45 | { | 45 | { |
46 | m_packages.setAutoDelete( true ); | 46 | m_packages.setAutoDelete( true ); |
47 | } | 47 | } |
48 | 48 | ||
49 | void OPackageManager::loadAvailablePackages() | 49 | void OPackageManager::loadAvailablePackages() |
50 | { | 50 | { |
51 | m_packages.clear(); | 51 | m_packages.clear(); |
52 | 52 | ||
53 | OConfItemList *serverList = m_ipkg.servers(); | 53 | OConfItemList *serverList = m_ipkg.servers(); |
54 | 54 | ||
55 | if ( serverList ) | 55 | if ( serverList ) |
56 | { | 56 | { |
57 | // Initialize status messaging | 57 | // Initialize status messaging |
58 | emit initStatus( serverList->count() ); | 58 | emit initStatus( serverList->count() ); |
59 | int serverCount = 0; | 59 | int serverCount = 0; |
60 | 60 | ||
61 | bool categoryAdded = false; | 61 | bool categoryAdded = false; |
62 | 62 | ||
63 | for ( OConfItemListIterator serverIt( *serverList ); serverIt.current(); ++serverIt ) | 63 | for ( OConfItemListIterator serverIt( *serverList ); serverIt.current(); ++serverIt ) |
64 | { | 64 | { |
65 | OConfItem *server = serverIt.current(); | 65 | OConfItem *server = serverIt.current(); |
66 | 66 | ||
67 | // Process server only if it is active | 67 | // Process server only if it is active |
68 | if ( server->active() ) | 68 | if ( server->active() ) |
69 | { | 69 | { |
70 | // Update status | 70 | // Update status |
71 | QString status = tr( "Reading available packages:\n\t" ); | 71 | QString status = tr( "Reading available packages:\n\t" ); |
72 | status.append( server->name() ); | 72 | status.append( server->name() ); |
73 | emit statusText( status ); | 73 | emit statusText( status ); |
74 | ++serverCount; | 74 | ++serverCount; |
75 | emit statusBar( serverCount ); | 75 | emit statusBar( serverCount ); |
76 | qApp->processEvents(); | 76 | qApp->processEvents(); |
77 | 77 | ||
78 | OPackageList *packageList = m_ipkg.availablePackages( server->name() ); | 78 | OPackageList *packageList = m_ipkg.availablePackages( server->name() ); |
79 | if ( packageList ) | 79 | if ( packageList ) |
80 | { | 80 | { |
81 | for ( OPackageListIterator packageIt( *packageList ); packageIt.current(); ++packageIt ) | 81 | for ( OPackageListIterator packageIt( *packageList ); packageIt.current(); ++packageIt ) |
82 | { | 82 | { |
83 | OPackage *package = packageIt.current(); | 83 | OPackage *package = packageIt.current(); |
84 | 84 | ||
85 | // Load package info | 85 | // Load package info |
86 | if ( !m_packages.find( package->name() ) ) { | 86 | if ( !m_packages.find( package->name() ) ) |
87 | printf( "ADD AVAILABLE '%s'\n", package->name().latin1()); | ||
88 | m_packages.insert( package->name(), package ); | 87 | m_packages.insert( package->name(), package ); |
89 | } else | 88 | else |
90 | { | 89 | { |
91 | // If new package is newer version, replace existing package | 90 | // If new package is newer version, replace existing package |
92 | OPackage *currPackage = m_packages[package->name()]; | 91 | OPackage *currPackage = m_packages[package->name()]; |
93 | if ( compareVersions( package->version(), currPackage->version() ) == 1 ) | 92 | if ( compareVersions( package->version(), currPackage->version() ) == 1 ) |
94 | m_packages.replace( package->name(), package ); | 93 | m_packages.replace( package->name(), package ); |
95 | } | 94 | } |
96 | 95 | ||
97 | // Add category to list if it doesn't already exist | 96 | // Add category to list if it doesn't already exist |
98 | if ( m_categories.grep( package->category() ).isEmpty() ) | 97 | if ( m_categories.grep( package->category() ).isEmpty() ) |
99 | { | 98 | { |
100 | m_categories << package->category(); | 99 | m_categories << package->category(); |
101 | categoryAdded = true; | 100 | categoryAdded = true; |
102 | } | 101 | } |
103 | } | 102 | } |
104 | } | 103 | } |
105 | } | 104 | } |
106 | } | 105 | } |
107 | delete serverList; | 106 | delete serverList; |
108 | 107 | ||
109 | // Sort category list if categories were added | 108 | // Sort category list if categories were added |
110 | if ( categoryAdded ) | 109 | if ( categoryAdded ) |
111 | m_categories.sort(); | 110 | m_categories.sort(); |
112 | } | 111 | } |
113 | } | 112 | } |
114 | 113 | ||
115 | void OPackageManager::loadInstalledPackages() | 114 | void OPackageManager::loadInstalledPackages() |
116 | { | 115 | { |
117 | OConfItemList *destList = m_ipkg.destinations(); | 116 | OConfItemList *destList = m_ipkg.destinations(); |
118 | 117 | ||
119 | if ( destList ) | 118 | if ( destList ) |
120 | { | 119 | { |
121 | // Initialize status messaging | 120 | // Initialize status messaging |
122 | emit initStatus( destList->count() ); | 121 | emit initStatus( destList->count() ); |
123 | int destCount = 0; | 122 | int destCount = 0; |
124 | 123 | ||
125 | bool categoryAdded = false; | 124 | bool categoryAdded = false; |
126 | 125 | ||
127 | for ( OConfItemListIterator destIt( *destList ); destIt.current(); ++destIt ) | 126 | for ( OConfItemListIterator destIt( *destList ); destIt.current(); ++destIt ) |
128 | { | 127 | { |
129 | OConfItem *destination = destIt.current(); | 128 | OConfItem *destination = destIt.current(); |
130 | 129 | ||
131 | // Process destination only if it is active | 130 | // Process destination only if it is active |
132 | if ( destination->active() ) | 131 | if ( destination->active() ) |
133 | { | 132 | { |
134 | // Update status | 133 | // Update status |
135 | QString status = tr( "Reading installed packages:\n\t" ); | 134 | QString status = tr( "Reading installed packages:\n\t" ); |
136 | status.append( destination->name() ); | 135 | status.append( destination->name() ); |
137 | emit statusText( status ); | 136 | emit statusText( status ); |
138 | ++destCount; | 137 | ++destCount; |
139 | emit statusBar( destCount ); | 138 | emit statusBar( destCount ); |
140 | qApp->processEvents(); | 139 | qApp->processEvents(); |
141 | 140 | ||
142 | printf( "DESGTINATION %s\n", destination->name().latin1()); | ||
143 | OPackageList *packageList = m_ipkg.installedPackages( destination->name(), | 141 | OPackageList *packageList = m_ipkg.installedPackages( destination->name(), |
144 | destination->value() ); | 142 | destination->value() ); |
145 | if ( packageList ) | 143 | if ( packageList ) |
146 | { | 144 | { |
147 | for ( OPackageListIterator packageIt( *packageList ); packageIt.current(); ++packageIt ) | 145 | for ( OPackageListIterator packageIt( *packageList ); packageIt.current(); ++packageIt ) |
148 | { | 146 | { |
149 | OPackage *package = packageIt.current(); | 147 | OPackage *package = packageIt.current(); |
150 | OPackage *currPackage = m_packages[package->name()]; | 148 | OPackage *currPackage = m_packages[package->name()]; |
151 | if ( currPackage ) | 149 | if ( currPackage ) |
152 | { | 150 | { |
153 | // Package is in a current feed, update installed version, destination | 151 | // Package is in a current feed, update installed version, destination |
154 | currPackage->setVersionInstalled( package->versionInstalled() ); | 152 | currPackage->setVersionInstalled( package->versionInstalled() ); |
155 | currPackage->setDestination( package->destination() ); | 153 | currPackage->setDestination( package->destination() ); |
156 | 154 | ||
157 | delete package; | 155 | delete package; |
158 | } | 156 | } |
159 | else | 157 | else |
160 | { | 158 | { |
161 | // Package isn't in a current feed, add to list | 159 | // Package isn't in a current feed, add to list |
162 | printf( "ADD INSTALLED '%s'\n", package->name().latin1()); | ||
163 | m_packages.insert( package->name(), package ); | 160 | m_packages.insert( package->name(), package ); |
164 | 161 | ||
165 | // Add category to list if it doesn't already exist | 162 | // Add category to list if it doesn't already exist |
166 | if ( m_categories.grep( package->category() ).isEmpty() ) | 163 | if ( m_categories.grep( package->category() ).isEmpty() ) |
167 | { | 164 | { |
168 | m_categories << package->category(); | 165 | m_categories << package->category(); |
169 | categoryAdded = true; | 166 | categoryAdded = true; |
170 | } | 167 | } |
171 | } | 168 | } |
172 | } | 169 | } |
173 | } | 170 | } |
174 | } | 171 | } |
175 | } | 172 | } |
176 | delete destList; | 173 | delete destList; |
177 | 174 | ||
178 | // Sort category list if categories were added | 175 | // Sort category list if categories were added |
179 | if ( categoryAdded ) | 176 | if ( categoryAdded ) |
180 | m_categories.sort(); | 177 | m_categories.sort(); |
181 | } | 178 | } |
182 | } | 179 | } |
183 | 180 | ||
184 | OPackageList *OPackageManager::packages() | 181 | OPackageList *OPackageManager::packages() |
185 | { | 182 | { |
186 | // TODO - look to see if list is loaded, if not, load available & installed | 183 | // TODO - look to see if list is loaded, if not, load available & installed |
187 | 184 | ||
188 | OPackageList *pl = new OPackageList; | 185 | OPackageList *pl = new OPackageList; |
189 | 186 | ||
190 | for ( QDictIterator<OPackage> packageIt( m_packages ); packageIt.current(); ++packageIt ) | 187 | for ( QDictIterator<OPackage> packageIt( m_packages ); packageIt.current(); ++packageIt ) |
191 | pl->append( packageIt.current() ); | 188 | pl->append( packageIt.current() ); |
192 | 189 | ||
193 | return pl; | 190 | return pl; |
194 | } | 191 | } |
195 | 192 | ||
196 | OPackageList *OPackageManager::filterPackages( const QString &name,const QString &server, | 193 | OPackageList *OPackageManager::filterPackages( const QString &name,const QString &server, |
197 | const QString &destination, Status status, const QString &category ) | 194 | const QString &destination, Status status, const QString &category ) |
198 | { | 195 | { |
199 | // TODO - look to see if list is loaded, if not, load available & installed | 196 | // TODO - look to see if list is loaded, if not, load available & installed |
200 | 197 | ||
201 | OPackageList *pl = new OPackageList; | 198 | OPackageList *pl = new OPackageList; |
202 | for ( QDictIterator<OPackage> packageIt( m_packages ); packageIt.current(); ++packageIt ) | 199 | for ( QDictIterator<OPackage> packageIt( m_packages ); packageIt.current(); ++packageIt ) |
203 | { | 200 | { |
204 | OPackage *package = packageIt.current(); | 201 | OPackage *package = packageIt.current(); |
205 | 202 | ||
206 | bool nameMatch = ( name.isNull() || package->name().contains( name ) ); | 203 | bool nameMatch = ( name.isNull() || package->name().contains( name ) ); |
207 | bool serverMatch = ( server.isNull() || package->source() == server ); | 204 | bool serverMatch = ( server.isNull() || package->source() == server ); |
208 | bool destinationMatch = ( destination.isNull() || package->destination() == destination ); | 205 | bool destinationMatch = ( destination.isNull() || package->destination() == destination ); |
209 | bool statusMatch; | 206 | bool statusMatch; |
210 | switch ( status ) | 207 | switch ( status ) |
211 | { | 208 | { |
212 | case All : statusMatch = true; | 209 | case All : statusMatch = true; |
213 | break; | 210 | break; |
214 | case NotInstalled : statusMatch = package->versionInstalled().isNull(); | 211 | case NotInstalled : statusMatch = package->versionInstalled().isNull(); |
215 | break; | 212 | break; |
216 | case Installed : statusMatch = !package->versionInstalled().isNull(); | 213 | case Installed : statusMatch = !package->versionInstalled().isNull(); |
217 | break; | 214 | break; |
218 | case Updated : statusMatch = ( !package->versionInstalled().isNull() && | 215 | case Updated : statusMatch = ( !package->versionInstalled().isNull() && |
219 | compareVersions( package->version(), package->versionInstalled() ) == 1 ); | 216 | compareVersions( package->version(), package->versionInstalled() ) == 1 ); |
220 | break; | 217 | break; |
221 | default : statusMatch = true; | 218 | default : statusMatch = true; |
222 | break; | 219 | break; |
223 | }; | 220 | }; |
224 | bool categoryMatch = ( category.isNull() || package->category() == category ); | 221 | bool categoryMatch = ( category.isNull() || package->category() == category ); |
225 | 222 | ||
226 | if ( nameMatch && serverMatch && destinationMatch && statusMatch && categoryMatch ) | 223 | if ( nameMatch && serverMatch && destinationMatch && statusMatch && categoryMatch ) |
227 | pl->append( packageIt.current() ); | 224 | pl->append( packageIt.current() ); |
228 | } | 225 | } |
229 | 226 | ||
230 | return pl; | 227 | return pl; |
231 | } | 228 | } |
232 | 229 | ||
233 | QStringList OPackageManager::servers() | 230 | QStringList OPackageManager::servers() |
234 | { | 231 | { |
235 | QStringList sl; | 232 | QStringList sl; |
236 | 233 | ||
237 | OConfItemList *serverList = m_ipkg.servers(); | 234 | OConfItemList *serverList = m_ipkg.servers(); |
238 | if ( serverList ) | 235 | if ( serverList ) |
239 | { | 236 | { |
240 | for ( OConfItemListIterator serverIt( *serverList ); serverIt.current(); ++serverIt ) | 237 | for ( OConfItemListIterator serverIt( *serverList ); serverIt.current(); ++serverIt ) |
241 | { | 238 | { |
242 | OConfItem *server = serverIt.current(); | 239 | OConfItem *server = serverIt.current(); |
243 | 240 | ||
244 | // Add only active servers | 241 | // Add only active servers |
245 | if ( server->active() ) | 242 | if ( server->active() ) |
246 | sl << server->name(); | 243 | sl << server->name(); |
247 | } | 244 | } |
248 | } | 245 | } |
249 | 246 | ||
250 | return sl; | 247 | return sl; |
251 | } | 248 | } |
252 | 249 | ||
253 | QStringList OPackageManager::destinations() | 250 | QStringList OPackageManager::destinations() |
254 | { | 251 | { |
255 | QStringList dl; | 252 | QStringList dl; |
256 | 253 | ||
257 | OConfItemList *destList = m_ipkg.destinations(); | 254 | OConfItemList *destList = m_ipkg.destinations(); |
258 | if ( destList ) | 255 | if ( destList ) |
259 | { | 256 | { |
260 | for ( OConfItemListIterator destIt( *destList ); destIt.current(); ++destIt ) | 257 | for ( OConfItemListIterator destIt( *destList ); destIt.current(); ++destIt ) |
261 | { | 258 | { |
262 | OConfItem *destination = destIt.current(); | 259 | OConfItem *destination = destIt.current(); |
263 | 260 | ||
264 | // Add only active destinations | 261 | // Add only active destinations |
265 | if ( destination->active() ) | 262 | if ( destination->active() ) |
266 | dl << destination->name(); | 263 | dl << destination->name(); |
267 | } | 264 | } |
268 | } | 265 | } |
269 | 266 | ||
270 | return dl; | 267 | return dl; |
271 | } | 268 | } |
272 | 269 | ||
273 | OConfItem *OPackageManager::findConfItem( OConfItem::Type type, const QString &name ) | 270 | OConfItem *OPackageManager::findConfItem( OConfItem::Type type, const QString &name ) |
274 | { | 271 | { |
275 | return m_ipkg.findConfItem( type, name ); | 272 | return m_ipkg.findConfItem( type, name ); |
276 | } | 273 | } |
277 | 274 | ||
278 | OPackage *OPackageManager::findPackage( const QString &name ) | 275 | OPackage *OPackageManager::findPackage( const QString &name ) |
279 | { | 276 | { |
280 | return m_packages[ name ]; | 277 | return m_packages[ name ]; |
281 | } | 278 | } |
282 | 279 | ||
283 | int OPackageManager::compareVersions( const QString &ver1, const QString &ver2 ) | 280 | int OPackageManager::compareVersions( const QString &ver1, const QString &ver2 ) |
284 | { | 281 | { |
285 | // TODO - should this be in OIpkg??? | 282 | // TODO - should this be in OIpkg??? |
286 | 283 | ||
287 | int epoch1, epoch2; | 284 | int epoch1, epoch2; |
288 | QString version1, revision1; | 285 | QString version1, revision1; |
289 | QString version2, revision2; | 286 | QString version2, revision2; |
290 | 287 | ||
291 | parseVersion( ver1, &epoch1, &version1, &revision1 ); | 288 | parseVersion( ver1, &epoch1, &version1, &revision1 ); |
292 | parseVersion( ver2, &epoch2, &version2, &revision2 ); | 289 | parseVersion( ver2, &epoch2, &version2, &revision2 ); |
293 | 290 | ||
294 | if ( epoch1 > epoch2 ) | 291 | if ( epoch1 > epoch2 ) |
295 | return 1; | 292 | return 1; |
296 | else if ( epoch1 < epoch2 ) | 293 | else if ( epoch1 < epoch2 ) |
297 | return -1; | 294 | return -1; |
298 | 295 | ||
299 | int r = verrevcmp( version1.latin1(), version2.latin1() ); | 296 | int r = verrevcmp( version1.latin1(), version2.latin1() ); |
300 | if (r) | 297 | if (r) |
301 | return r; | 298 | return r; |
302 | 299 | ||
303 | r = verrevcmp( revision1.latin1(), revision2.latin1() ); | 300 | r = verrevcmp( revision1.latin1(), revision2.latin1() ); |
304 | return r; | 301 | return r; |
305 | } | 302 | } |
306 | 303 | ||
307 | bool OPackageManager::configureDlg( bool installOptions ) | 304 | bool OPackageManager::configureDlg( bool installOptions ) |
308 | { | 305 | { |
309 | OIpkgConfigDlg dlg( &m_ipkg, installOptions, static_cast<QWidget *>(parent()) ); | 306 | OIpkgConfigDlg dlg( &m_ipkg, installOptions, static_cast<QWidget *>(parent()) ); |
310 | return ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); | 307 | return ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); |
311 | } | 308 | } |
312 | 309 | ||
313 | void OPackageManager::saveSettings() | 310 | void OPackageManager::saveSettings() |
314 | { | 311 | { |
315 | m_ipkg.saveSettings(); | 312 | m_ipkg.saveSettings(); |
316 | } | 313 | } |
317 | 314 | ||
318 | bool OPackageManager::executeCommand( OPackage::Command command, const QStringList &packages, | 315 | bool OPackageManager::executeCommand( OPackage::Command command, const QStringList &packages, |
319 | const QString &destination, const QObject *receiver, | 316 | const QString &destination, const QObject *receiver, |
320 | const char *slotOutput, bool rawOutput ) | 317 | const char *slotOutput, bool rawOutput ) |
321 | { | 318 | { |
322 | return m_ipkg.executeCommand( command, packages, destination, receiver, slotOutput, rawOutput ); | 319 | return m_ipkg.executeCommand( command, packages, destination, receiver, slotOutput, rawOutput ); |
323 | } | 320 | } |
324 | 321 | ||
325 | void OPackageManager::parseVersion( const QString &verstr, int *epoch, QString *version, | 322 | void OPackageManager::parseVersion( const QString &verstr, int *epoch, QString *version, |
326 | QString *revision ) | 323 | QString *revision ) |
327 | { | 324 | { |
328 | *epoch = 0; | 325 | *epoch = 0; |
329 | *revision = QString::null; | 326 | *revision = QString::null; |
330 | 327 | ||
331 | // Version string is in the format "ee:vv-rv", where ee=epoch, vv=version, rv=revision | 328 | // Version string is in the format "ee:vv-rv", where ee=epoch, vv=version, rv=revision |
332 | 329 | ||
333 | // Get epoch | 330 | // Get epoch |
334 | int colonpos = verstr.find( ':' ); | 331 | int colonpos = verstr.find( ':' ); |
335 | if ( colonpos > -1 ) | 332 | if ( colonpos > -1 ) |
336 | { | 333 | { |
337 | *epoch = verstr.left( colonpos ).toInt(); | 334 | *epoch = verstr.left( colonpos ).toInt(); |
338 | } | 335 | } |
339 | 336 | ||
340 | // Get version and revision | 337 | // Get version and revision |
341 | int hyphenpos = verstr.find( '-', colonpos + 1 ); | 338 | int hyphenpos = verstr.find( '-', colonpos + 1 ); |
342 | int verlen = verstr.length(); | 339 | int verlen = verstr.length(); |
343 | if ( hyphenpos > -1 ) | 340 | if ( hyphenpos > -1 ) |
344 | { | 341 | { |
345 | *version = verstr.mid( colonpos + 1, hyphenpos - colonpos - 1 ); | 342 | *version = verstr.mid( colonpos + 1, hyphenpos - colonpos - 1 ); |
346 | *revision = verstr.right( verlen - hyphenpos - 1 ); | 343 | *revision = verstr.right( verlen - hyphenpos - 1 ); |
347 | } | 344 | } |
348 | else | 345 | else |
349 | { | 346 | { |
350 | *version = verstr.right( verlen - colonpos ); | 347 | *version = verstr.right( verlen - colonpos ); |
351 | } | 348 | } |
352 | } | 349 | } |
353 | 350 | ||
354 | /* | 351 | /* |
355 | * libdpkg - Debian packaging suite library routines | 352 | * libdpkg - Debian packaging suite library routines |
356 | * vercmp.c - comparison of version numbers | 353 | * vercmp.c - comparison of version numbers |
357 | * | 354 | * |
358 | * Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk> | 355 | * Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk> |
359 | */ | 356 | */ |
360 | int OPackageManager::verrevcmp( const char *val, const char *ref ) | 357 | int OPackageManager::verrevcmp( const char *val, const char *ref ) |
361 | { | 358 | { |
362 | int vc, rc; | 359 | int vc, rc; |
363 | long vl, rl; | 360 | long vl, rl; |
364 | const char *vp, *rp; | 361 | const char *vp, *rp; |
365 | const char *vsep, *rsep; | 362 | const char *vsep, *rsep; |
366 | 363 | ||
367 | if (!val) val= ""; | 364 | if (!val) val= ""; |
368 | if (!ref) ref= ""; | 365 | if (!ref) ref= ""; |
369 | for (;;) { | 366 | for (;;) { |
370 | vp= val; while (*vp && !isdigit(*vp)) vp++; | 367 | vp= val; while (*vp && !isdigit(*vp)) vp++; |
371 | rp= ref; while (*rp && !isdigit(*rp)) rp++; | 368 | rp= ref; while (*rp && !isdigit(*rp)) rp++; |
372 | for (;;) { | 369 | for (;;) { |
373 | vc= (val == vp) ? 0 : *val++; | 370 | vc= (val == vp) ? 0 : *val++; |
374 | rc= (ref == rp) ? 0 : *ref++; | 371 | rc= (ref == rp) ? 0 : *ref++; |
375 | if (!rc && !vc) break; | 372 | if (!rc && !vc) break; |
376 | if (vc && !isalpha(vc)) vc += 256; /* assumes ASCII character set */ | 373 | if (vc && !isalpha(vc)) vc += 256; /* assumes ASCII character set */ |
377 | if (rc && !isalpha(rc)) rc += 256; | 374 | if (rc && !isalpha(rc)) rc += 256; |
378 | if (vc != rc) return vc - rc; | 375 | if (vc != rc) return vc - rc; |
379 | } | 376 | } |
380 | val= vp; | 377 | val= vp; |
381 | ref= rp; | 378 | ref= rp; |
382 | vl=0; if (isdigit(*vp)) vl= strtol(val,(char**)&val,10); | 379 | vl=0; if (isdigit(*vp)) vl= strtol(val,(char**)&val,10); |
383 | rl=0; if (isdigit(*rp)) rl= strtol(ref,(char**)&ref,10); | 380 | rl=0; if (isdigit(*rp)) rl= strtol(ref,(char**)&ref,10); |
384 | if (vl != rl) return vl - rl; | 381 | if (vl != rl) return vl - rl; |
385 | 382 | ||
386 | vc = *val; | 383 | vc = *val; |
387 | rc = *ref; | 384 | rc = *ref; |
388 | vsep = strchr(".-", vc); | 385 | vsep = strchr(".-", vc); |
389 | rsep = strchr(".-", rc); | 386 | rsep = strchr(".-", rc); |
390 | if (vsep && !rsep) return -1; | 387 | if (vsep && !rsep) return -1; |
391 | if (!vsep && rsep) return +1; | 388 | if (!vsep && rsep) return +1; |
392 | 389 | ||
393 | if (!*val && !*ref) return 0; | 390 | if (!*val && !*ref) return 0; |
394 | if (!*val) return -1; | 391 | if (!*val) return -1; |
395 | if (!*ref) return +1; | 392 | if (!*ref) return +1; |
396 | } | 393 | } |
397 | } | 394 | } |