-rw-r--r-- | noncore/settings/packagemanager/oipkg.cpp | 5 | ||||
-rw-r--r-- | noncore/settings/packagemanager/oipkg.h | 7 |
2 files changed, 6 insertions, 6 deletions
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp index 127204d..7bc2040 100644 --- a/noncore/settings/packagemanager/oipkg.cpp +++ b/noncore/settings/packagemanager/oipkg.cpp | |||
@@ -1,168 +1,173 @@ | |||
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 | extern "C" { | ||
42 | #include <libipkg.h> | ||
43 | }; | ||
44 | args_t m_ipkgArgs; // libipkg configuration arguments | ||
45 | |||
41 | const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file | 46 | 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 | 47 | 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 | 48 | 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 | 49 | 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 | 50 | const QString IPKG_INFO_PATH = "usr/lib/ipkg/info"; // Package file lists location |
46 | 51 | ||
47 | OIpkg *oipkg; | 52 | OIpkg *oipkg; |
48 | 53 | ||
49 | // Ipkg callback functions | 54 | // Ipkg callback functions |
50 | 55 | ||
51 | int fsignalIpkgMessage( ipkg_conf_t *conf, message_level_t level, char *msg ) | 56 | int fsignalIpkgMessage( ipkg_conf_t *conf, message_level_t level, char *msg ) |
52 | { | 57 | { |
53 | // Display message only if it is below the message level threshold | 58 | // Display message only if it is below the message level threshold |
54 | if ( conf && ( conf->verbosity < level ) ) | 59 | if ( conf && ( conf->verbosity < level ) ) |
55 | return 0; | 60 | return 0; |
56 | else | 61 | else |
57 | oipkg->ipkgMessage( msg ); | 62 | oipkg->ipkgMessage( msg ); |
58 | 63 | ||
59 | return 0; | 64 | return 0; |
60 | } | 65 | } |
61 | 66 | ||
62 | char *fIpkgResponse( char */*question*/ ) | 67 | char *fIpkgResponse( char */*question*/ ) |
63 | { | 68 | { |
64 | return 0l; | 69 | return 0l; |
65 | } | 70 | } |
66 | 71 | ||
67 | int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ ) | 72 | int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ ) |
68 | { | 73 | { |
69 | oipkg->ipkgStatus( desc ); | 74 | oipkg->ipkgStatus( desc ); |
70 | return 0; | 75 | return 0; |
71 | } | 76 | } |
72 | 77 | ||
73 | int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/, | 78 | int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/, |
74 | void */*userdata*/ ) | 79 | void */*userdata*/ ) |
75 | { | 80 | { |
76 | oipkg->ipkgList( desc ); | 81 | oipkg->ipkgList( desc ); |
77 | return 0; | 82 | return 0; |
78 | } | 83 | } |
79 | 84 | ||
80 | OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) | 85 | OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) |
81 | : QObject( parent, name ) | 86 | : QObject( parent, name ) |
82 | , m_config( config ) | 87 | , m_config( config ) |
83 | , m_confInfo( NULL ) | 88 | , m_confInfo( NULL ) |
84 | , m_ipkgExecOptions( 0 ) | 89 | , m_ipkgExecOptions( 0 ) |
85 | , m_ipkgExecVerbosity( 1 ) | 90 | , m_ipkgExecVerbosity( 1 ) |
86 | { | 91 | { |
87 | // Keep pointer to self for the Ipkg callback functions | 92 | // Keep pointer to self for the Ipkg callback functions |
88 | oipkg = this; | 93 | oipkg = this; |
89 | 94 | ||
90 | // Initialize libipkg | 95 | // Initialize libipkg |
91 | ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); | 96 | ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); |
92 | 97 | ||
93 | // Default ipkg run-time arguments | 98 | // Default ipkg run-time arguments |
94 | m_ipkgArgs.noaction = false; | 99 | m_ipkgArgs.noaction = false; |
95 | m_ipkgArgs.force_defaults = true; | 100 | m_ipkgArgs.force_defaults = true; |
96 | } | 101 | } |
97 | 102 | ||
98 | OIpkg::~OIpkg() | 103 | OIpkg::~OIpkg() |
99 | { | 104 | { |
100 | // Upon destruction, ensure that items in config list are deleted with list | 105 | // Upon destruction, ensure that items in config list are deleted with list |
101 | if ( m_confInfo ) | 106 | if ( m_confInfo ) |
102 | m_confInfo->setAutoDelete( true ); | 107 | m_confInfo->setAutoDelete( true ); |
103 | 108 | ||
104 | // Free up libipkg resources | 109 | // Free up libipkg resources |
105 | ipkg_deinit( &m_ipkgArgs ); | 110 | ipkg_deinit( &m_ipkgArgs ); |
106 | } | 111 | } |
107 | 112 | ||
108 | OConfItemList *OIpkg::configItems() | 113 | OConfItemList *OIpkg::configItems() |
109 | { | 114 | { |
110 | // Retrieve all configuration items | 115 | // Retrieve all configuration items |
111 | return filterConfItems(); | 116 | return filterConfItems(); |
112 | } | 117 | } |
113 | 118 | ||
114 | OConfItemList *OIpkg::servers() | 119 | OConfItemList *OIpkg::servers() |
115 | { | 120 | { |
116 | // Retrieve only servers | 121 | // Retrieve only servers |
117 | return filterConfItems( OConfItem::Source ); | 122 | return filterConfItems( OConfItem::Source ); |
118 | } | 123 | } |
119 | 124 | ||
120 | OConfItemList *OIpkg::destinations() | 125 | OConfItemList *OIpkg::destinations() |
121 | { | 126 | { |
122 | // Retrieve only destinations | 127 | // Retrieve only destinations |
123 | return filterConfItems( OConfItem::Destination ); | 128 | return filterConfItems( OConfItem::Destination ); |
124 | } | 129 | } |
125 | 130 | ||
126 | OConfItemList *OIpkg::options() | 131 | OConfItemList *OIpkg::options() |
127 | { | 132 | { |
128 | // Retrieve only destinations | 133 | // Retrieve only destinations |
129 | return filterConfItems( OConfItem::Option ); | 134 | return filterConfItems( OConfItem::Option ); |
130 | } | 135 | } |
131 | 136 | ||
132 | void OIpkg::setConfigItems( OConfItemList *configList ) | 137 | void OIpkg::setConfigItems( OConfItemList *configList ) |
133 | { | 138 | { |
134 | if ( m_confInfo ) | 139 | if ( m_confInfo ) |
135 | delete m_confInfo; | 140 | delete m_confInfo; |
136 | 141 | ||
137 | m_confInfo = configList; | 142 | m_confInfo = configList; |
138 | 143 | ||
139 | // Write out new /etc/ipkg.conf | 144 | // Write out new /etc/ipkg.conf |
140 | QFile confFile( IPKG_CONF ); | 145 | QFile confFile( IPKG_CONF ); |
141 | if ( confFile.open( IO_WriteOnly ) ) | 146 | if ( confFile.open( IO_WriteOnly ) ) |
142 | { | 147 | { |
143 | QTextStream confStream( &confFile ); | 148 | QTextStream confStream( &confFile ); |
144 | confStream << "# Generated by Opie Package Manager\n\n"; | 149 | confStream << "# Generated by Opie Package Manager\n\n"; |
145 | 150 | ||
146 | OConfItemListIterator it( *m_confInfo ); | 151 | OConfItemListIterator it( *m_confInfo ); |
147 | for ( ; it.current(); ++it ) | 152 | for ( ; it.current(); ++it ) |
148 | { | 153 | { |
149 | OConfItem *item = it.current(); | 154 | OConfItem *item = it.current(); |
150 | 155 | ||
151 | // Only write out valid conf items | 156 | // Only write out valid conf items |
152 | if ( item->type() != OConfItem::NotDefined ) | 157 | if ( item->type() != OConfItem::NotDefined ) |
153 | { | 158 | { |
154 | QString confLine; | 159 | QString confLine; |
155 | QString name = item->name(); | 160 | QString name = item->name(); |
156 | if ( !item->active() ) | 161 | if ( !item->active() ) |
157 | confLine = "#"; | 162 | confLine = "#"; |
158 | 163 | ||
159 | switch ( item->type() ) | 164 | switch ( item->type() ) |
160 | { | 165 | { |
161 | case OConfItem::Source : | 166 | case OConfItem::Source : |
162 | { | 167 | { |
163 | if ( item->features().contains( "Compressed" ) ) | 168 | if ( item->features().contains( "Compressed" ) ) |
164 | confLine.append( "src/gz" ); | 169 | confLine.append( "src/gz" ); |
165 | else | 170 | else |
166 | confLine.append( "src" ); | 171 | confLine.append( "src" ); |
167 | } | 172 | } |
168 | break; | 173 | break; |
diff --git a/noncore/settings/packagemanager/oipkg.h b/noncore/settings/packagemanager/oipkg.h index 0263f50..4e390fa 100644 --- a/noncore/settings/packagemanager/oipkg.h +++ b/noncore/settings/packagemanager/oipkg.h | |||
@@ -1,116 +1,111 @@ | |||
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 OIPKG_H | 32 | #ifndef OIPKG_H |
33 | #define OIPKG_H | 33 | #define OIPKG_H |
34 | 34 | ||
35 | #include "oconfitem.h" | 35 | #include "oconfitem.h" |
36 | #include "opackage.h" | 36 | #include "opackage.h" |
37 | 37 | ||
38 | #include <qpe/config.h> | 38 | #include <qpe/config.h> |
39 | 39 | ||
40 | #include <qobject.h> | 40 | #include <qobject.h> |
41 | 41 | ||
42 | extern "C" { | ||
43 | #include <libipkg.h> | ||
44 | }; | ||
45 | |||
46 | // Ipkg execution options (m_ipkgExecOptions) | 42 | // Ipkg execution options (m_ipkgExecOptions) |
47 | #define FORCE_DEPENDS 0x0001 | 43 | #define FORCE_DEPENDS 0x0001 |
48 | #define FORCE_REMOVE 0x0002 | 44 | #define FORCE_REMOVE 0x0002 |
49 | #define FORCE_REINSTALL 0x0004 | 45 | #define FORCE_REINSTALL 0x0004 |
50 | #define FORCE_OVERWRITE 0x0008 | 46 | #define FORCE_OVERWRITE 0x0008 |
51 | 47 | ||
52 | class OConfItemList; | 48 | class OConfItemList; |
53 | 49 | ||
54 | class OIpkg : public QObject | 50 | class OIpkg : public QObject |
55 | { | 51 | { |
56 | Q_OBJECT | 52 | Q_OBJECT |
57 | 53 | ||
58 | public: | 54 | public: |
59 | OIpkg( Config *config = 0l, QObject *parent = 0l, const char *name = 0l ); | 55 | OIpkg( Config *config = 0l, QObject *parent = 0l, const char *name = 0l ); |
60 | ~OIpkg(); | 56 | ~OIpkg(); |
61 | 57 | ||
62 | OConfItemList *configItems(); | 58 | OConfItemList *configItems(); |
63 | OConfItemList *servers(); | 59 | OConfItemList *servers(); |
64 | OConfItemList *destinations(); | 60 | OConfItemList *destinations(); |
65 | OConfItemList *options(); | 61 | OConfItemList *options(); |
66 | 62 | ||
67 | int ipkgExecOptions() { return m_ipkgExecOptions; } | 63 | int ipkgExecOptions() { return m_ipkgExecOptions; } |
68 | int ipkgExecVerbosity() { return m_ipkgExecVerbosity; } | 64 | int ipkgExecVerbosity() { return m_ipkgExecVerbosity; } |
69 | 65 | ||
70 | void setConfigItems( OConfItemList *configList ); | 66 | void setConfigItems( OConfItemList *configList ); |
71 | void setIpkgExecOptions( int options ) { m_ipkgExecOptions = options; } | 67 | void setIpkgExecOptions( int options ) { m_ipkgExecOptions = options; } |
72 | void setIpkgExecVerbosity( int verbosity ) { m_ipkgExecVerbosity = verbosity; } | 68 | void setIpkgExecVerbosity( int verbosity ) { m_ipkgExecVerbosity = verbosity; } |
73 | 69 | ||
74 | void saveSettings(); | 70 | void saveSettings(); |
75 | 71 | ||
76 | OPackageList *availablePackages( const QString &server = QString::null ); | 72 | OPackageList *availablePackages( const QString &server = QString::null ); |
77 | OPackageList *installedPackages( const QString &destName = QString::null, | 73 | OPackageList *installedPackages( const QString &destName = QString::null, |
78 | const QString &destPath = QString::null ); | 74 | const QString &destPath = QString::null ); |
79 | 75 | ||
80 | OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined, | 76 | OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined, |
81 | const QString &name = QString::null ); | 77 | const QString &name = QString::null ); |
82 | 78 | ||
83 | bool executeCommand( OPackage::Command command = OPackage::NotDefined, | 79 | bool executeCommand( OPackage::Command command = OPackage::NotDefined, |
84 | const QStringList ¶meters = QStringList(), | 80 | const QStringList ¶meters = QStringList(), |
85 | const QString &destination = QString::null, | 81 | const QString &destination = QString::null, |
86 | const QObject *receiver = 0l, | 82 | const QObject *receiver = 0l, |
87 | const char *slotOutput = 0l, | 83 | const char *slotOutput = 0l, |
88 | bool rawOutput = true ); | 84 | bool rawOutput = true ); |
89 | void abortCommand(); | 85 | void abortCommand(); |
90 | 86 | ||
91 | void ipkgMessage( char *msg ); | 87 | void ipkgMessage( char *msg ); |
92 | void ipkgStatus( char *status ); | 88 | void ipkgStatus( char *status ); |
93 | void ipkgList( char *filelist ); | 89 | void ipkgList( char *filelist ); |
94 | 90 | ||
95 | private: | 91 | private: |
96 | Config *m_config; // Pointer to application configuration file | 92 | Config *m_config; // Pointer to application configuration file |
97 | args_t m_ipkgArgs; // libipkg configuration arguments | ||
98 | OConfItemList *m_confInfo; // Contains info from all Ipkg configuration files | 93 | OConfItemList *m_confInfo; // Contains info from all Ipkg configuration files |
99 | int m_ipkgExecOptions; // Bit-mapped flags for Ipkg execution options | 94 | int m_ipkgExecOptions; // Bit-mapped flags for Ipkg execution options |
100 | int m_ipkgExecVerbosity; // Ipkg execution verbosity level | 95 | int m_ipkgExecVerbosity; // Ipkg execution verbosity level |
101 | QString m_rootPath; // Directory path where the 'root' destination is located | 96 | QString m_rootPath; // Directory path where the 'root' destination is located |
102 | 97 | ||
103 | void loadConfiguration(); | 98 | void loadConfiguration(); |
104 | OConfItemList *filterConfItems( OConfItem::Type typefilter = OConfItem::NotDefined ); | 99 | OConfItemList *filterConfItems( OConfItem::Type typefilter = OConfItem::NotDefined ); |
105 | const QString &rootPath(); | 100 | const QString &rootPath(); |
106 | void linkPackageDir( const QString &dest = QString::null ); | 101 | void linkPackageDir( const QString &dest = QString::null ); |
107 | void unlinkPackage( const QString &package = QString::null, | 102 | void unlinkPackage( const QString &package = QString::null, |
108 | OConfItemList *destList = 0l ); | 103 | OConfItemList *destList = 0l ); |
109 | 104 | ||
110 | signals: | 105 | signals: |
111 | void signalIpkgMessage( const QString &msg ); | 106 | void signalIpkgMessage( const QString &msg ); |
112 | void signalIpkgStatus( const QString &status ); | 107 | void signalIpkgStatus( const QString &status ); |
113 | void signalIpkgList( const QString &filelist ); | 108 | void signalIpkgList( const QString &filelist ); |
114 | }; | 109 | }; |
115 | 110 | ||
116 | #endif | 111 | #endif |