summaryrefslogtreecommitdiff
authorandyq <andyq>2002-09-28 23:22:41 (UTC)
committer andyq <andyq>2002-09-28 23:22:41 (UTC)
commit8ebc71609e5263d096f7331a5e0fa95b41eb1d77 (patch) (unidiff)
treeb51cc78a419a8735d4bc447229b4561b5c6edbe5
parente78460a23cb8bea25f45cdd01f74e8c1d07da1a8 (diff)
downloadopie-8ebc71609e5263d096f7331a5e0fa95b41eb1d77.zip
opie-8ebc71609e5263d096f7331a5e0fa95b41eb1d77.tar.gz
opie-8ebc71609e5263d096f7331a5e0fa95b41eb1d77.tar.bz2
*** empty log message ***
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/aqpkg.pro41
-rw-r--r--noncore/settings/aqpkg/datamgr.cpp197
-rw-r--r--noncore/settings/aqpkg/datamgr.h64
-rw-r--r--noncore/settings/aqpkg/destination.cpp29
-rw-r--r--noncore/settings/aqpkg/destination.h41
-rw-r--r--noncore/settings/aqpkg/doc.txt49
-rw-r--r--noncore/settings/aqpkg/global.h78
-rw-r--r--noncore/settings/aqpkg/helpwindow.cpp95
-rw-r--r--noncore/settings/aqpkg/helpwindow.h34
-rw-r--r--noncore/settings/aqpkg/inputdlg.cpp121
-rw-r--r--noncore/settings/aqpkg/inputdlg.h50
-rw-r--r--noncore/settings/aqpkg/install.ui118
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.cpp193
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.h54
-rw-r--r--noncore/settings/aqpkg/instoptions.ui132
-rw-r--r--noncore/settings/aqpkg/instoptionsimpl.cpp49
-rw-r--r--noncore/settings/aqpkg/instoptionsimpl.h33
-rw-r--r--noncore/settings/aqpkg/ipkg.cpp345
-rw-r--r--noncore/settings/aqpkg/ipkg.h72
-rw-r--r--noncore/settings/aqpkg/main.cpp61
-rw-r--r--noncore/settings/aqpkg/mainwin.cpp85
-rw-r--r--noncore/settings/aqpkg/mainwin.h47
-rw-r--r--noncore/settings/aqpkg/mem.cpp105
-rw-r--r--noncore/settings/aqpkg/moc_aqpkg.cpp95
-rw-r--r--noncore/settings/aqpkg/moc_qinputdialog.cpp88
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp395
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.h70
-rw-r--r--noncore/settings/aqpkg/package.cpp109
-rw-r--r--noncore/settings/aqpkg/package.h75
-rw-r--r--noncore/settings/aqpkg/progressdlg.cpp65
-rw-r--r--noncore/settings/aqpkg/progressdlg.h37
-rw-r--r--noncore/settings/aqpkg/server.cpp266
-rw-r--r--noncore/settings/aqpkg/server.h63
-rw-r--r--noncore/settings/aqpkg/settings.ui531
-rw-r--r--noncore/settings/aqpkg/settingsimpl.cpp195
-rw-r--r--noncore/settings/aqpkg/settingsimpl.h52
-rw-r--r--noncore/settings/aqpkg/utils.cpp74
-rw-r--r--noncore/settings/aqpkg/utils.h38
38 files changed, 4246 insertions, 0 deletions
diff --git a/noncore/settings/aqpkg/aqpkg.pro b/noncore/settings/aqpkg/aqpkg.pro
new file mode 100644
index 0000000..01f9eff
--- a/dev/null
+++ b/noncore/settings/aqpkg/aqpkg.pro
@@ -0,0 +1,41 @@
1 TEMPLATE= app
2 CONFIG = qt warn_on debug
3 HEADERS = global.h \
4 mainwin.h \
5 datamgr.h \
6 settingsimpl.h \
7 ipkg.h \
8 networkpkgmgr.h \
9 package.h \
10 progressdlg.h \
11 installdlgimpl.h \
12 instoptionsimpl.h \
13 destination.h \
14 utils.h \
15 server.h \
16 helpwindow.h \
17 inputdlg.h
18 SOURCES = mainwin.cpp \
19 datamgr.cpp \
20 mem.cpp \
21 settingsimpl.cpp \
22 ipkg.cpp \
23 networkpkgmgr.cpp \
24 main.cpp \
25 package.cpp \
26 progressdlg.cpp \
27 installdlgimpl.cpp \
28 instoptionsimpl.cpp \
29 destination.cpp \
30 utils.cpp \
31 server.cpp \
32 helpwindow.cpp \
33 inputdlg.cpp
34 INTERFACES= settings.ui \
35 install.ui \
36 instoptions.ui
37 TARGET = aqpkg
38INCLUDEPATH += $(QPEDIR)/include
39DEPENDPATH += $(QPEDIR)/include
40LIBS += -lqpe -lstdc++
41
diff --git a/noncore/settings/aqpkg/datamgr.cpp b/noncore/settings/aqpkg/datamgr.cpp
new file mode 100644
index 0000000..7f724af
--- a/dev/null
+++ b/noncore/settings/aqpkg/datamgr.cpp
@@ -0,0 +1,197 @@
1/***************************************************************************
2 datamgr.cpp - description
3 -------------------
4 begin : Thu Aug 29 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#include <fstream>
18#include <iostream>
19using namespace std;
20
21#include <stdio.h>
22
23#include "datamgr.h"
24#include "global.h"
25
26
27DataManager::DataManager()
28{
29 activeServer = "";
30}
31
32DataManager::~DataManager()
33{
34}
35
36Server *DataManager :: getServer( const char *name )
37{
38 Server *s = 0;
39 vector<Server>::iterator it = serverList.begin();
40 while ( it != serverList.end() && s == 0 )
41 {
42 if ( it->getServerName() == name )
43 s = &(*it);
44
45 ++it;
46 }
47
48 return s;
49}
50
51Destination *DataManager :: getDestination( const char *name )
52{
53 Destination *d = 0;
54 vector<Destination>::iterator it = destList.begin();
55 while ( it != destList.end() && d == 0 )
56 {
57 if ( it->getDestinationName() == name )
58 d = &(*it);
59
60 ++it;
61 }
62
63 return d;
64}
65
66void DataManager :: loadServers()
67{
68 // First add our local server - not really a server but
69 // the local config (which packages are installed)
70 serverList.push_back( Server( LOCAL_SERVER, "" ) );
71 serverList.push_back( Server( LOCAL_IPKGS, "" ) );
72
73 // Read file from /etc/ipkg.conf
74 QString ipkg_conf = IPKG_CONF;
75 FILE *fp;
76 fp = fopen( ipkg_conf, "r" );
77 char line[130];
78 QString lineStr;
79 if ( fp == NULL )
80 {
81 cout << "Couldn't open " << ipkg_conf << "! err = " << fp << endl;
82 return;
83 }
84 else
85 {
86 while ( fgets( line, sizeof line, fp) != NULL )
87 {
88 lineStr = line;
89 if ( lineStr.startsWith( "src" ) || lineStr.startsWith( "#src" ) )
90 {
91 char alias[20];
92 char url[100];
93 sscanf( lineStr, "%*[^ ] %s %s", alias, url );
94 Server s( alias, url );
95 serverList.push_back( s );
96
97 if ( lineStr.startsWith( "src" ) )
98 setActiveServer( alias );
99 }
100 else if ( lineStr.startsWith( "dest" ) )
101 {
102 char alias[20];
103 char path[50];
104 sscanf( lineStr, "%*[^ ] %s %s", alias, path );
105 Destination d( alias, path );
106 destList.push_back( d );
107 }
108 }
109 }
110 fclose( fp );
111
112 // Go through the server destination list and add root, cf and card if they
113 // don't already exist
114 vector<Destination>::iterator dit;
115 bool foundRoot = false;
116 bool foundCF = false;
117 bool foundCard = false;
118 for ( dit = destList.begin() ; dit != destList.end() ; ++dit )
119 {
120 if ( dit->getDestinationPath() == "/" )
121 foundRoot = true;
122 if ( dit->getDestinationPath() == "/mnt/cf" )
123 foundCF = true;
124 if ( dit->getDestinationPath() == "/mnt/card" )
125 foundCard = true;
126 }
127
128 // If running on a Zaurus (arm) then if we didn't find root, CF or card
129 // destinations, add them as default
130#ifdef QWS
131#ifndef X86
132 if ( !foundRoot )
133 destList.push_back( Destination( "root", "/" ) );
134 if ( !foundCF )
135 destList.push_back( Destination( "cf", "/mnt/cf" ) );
136 if ( !foundCF )
137 destList.push_back( Destination( "card", "/mnt/card" ) );
138#endif
139#endif
140
141 vector<Server>::iterator it;
142 for ( it = serverList.begin() ; it != serverList.end() ; ++it )
143 reloadServerData( it->getServerName() );
144}
145
146void DataManager :: reloadServerData( const char *serverName )
147{
148 Server *s = getServer( serverName );
149 // Now we've read the config file in we need to read the servers
150 // The local server is a special case. This holds the contents of the
151 // status files the number of which depends on how many destinations
152 // we've set up
153 // The other servers files hold the contents of the server package list
154 if ( s->getServerName() == LOCAL_SERVER )
155 s->readStatusFile( destList );
156 else if ( s->getServerName() == LOCAL_IPKGS )
157 s->readLocalIpks( getServer( LOCAL_SERVER ) );
158 else
159 s->readPackageFile( getServer( LOCAL_SERVER ) );
160
161}
162
163void DataManager :: writeOutIpkgConf()
164{
165 QString ipkg_conf = IPKG_CONF;
166 ofstream out( ipkg_conf );
167
168 out << "# Written by NetworkPackageManager Package Manager" << endl;
169
170 // Write out servers
171 vector<Server>::iterator it = serverList.begin();
172 while ( it != serverList.end() )
173 {
174 QString alias = it->getServerName();
175 // Don't write out local as its a dummy
176 if ( alias != LOCAL_SERVER && alias != LOCAL_IPKGS )
177 {
178 QString url = it->getServerUrl();;
179
180 if ( !activeServer || alias != activeServer )
181 out << "#";
182 out << "src " << alias << " " << url << endl;
183 }
184
185 it++;
186 }
187
188 // Write out destinations
189 vector<Destination>::iterator it2 = destList.begin();
190 while ( it2 != destList.end() )
191 {
192 out << "dest " << it2->getDestinationName() << " " << it2->getDestinationPath() << endl;
193 it2++;
194 }
195
196 out.close();
197}
diff --git a/noncore/settings/aqpkg/datamgr.h b/noncore/settings/aqpkg/datamgr.h
new file mode 100644
index 0000000..94989a9
--- a/dev/null
+++ b/noncore/settings/aqpkg/datamgr.h
@@ -0,0 +1,64 @@
1/***************************************************************************
2 datamgr.h - description
3 -------------------
4 begin : Thu Aug 29 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef DATAMGR_H
19#define DATAMGR_H
20
21#include <map>
22using namespace std;
23
24#include "server.h"
25#include "destination.h"
26
27 #define LOCAL_SERVER "local"
28 #define LOCAL_IPKGS "local IPKG"
29
30/**
31 *@author Andy Qua
32 */
33
34
35class DataManager
36{
37public:
38 DataManager();
39 ~DataManager();
40
41 void setActiveServer( const QString &act ) { activeServer = act; }
42 QString &getActiveServer( ) { return activeServer; }
43
44 Server *getLocalServer() { return getServer( LOCAL_SERVER ); }
45 vector<Server> &getServerList() { return serverList; }
46 Server *getServer( const char *name );
47
48 vector<Destination> &getDestinationList() { return destList; }
49 Destination *getDestination( const char *name );
50
51 void loadServers();
52 void reloadServerData( const char *sn );
53
54 void writeOutIpkgConf();
55
56
57private:
58 QString activeServer;
59
60 vector<Server> serverList;
61 vector<Destination> destList;
62};
63
64#endif
diff --git a/noncore/settings/aqpkg/destination.cpp b/noncore/settings/aqpkg/destination.cpp
new file mode 100644
index 0000000..ff50e6e
--- a/dev/null
+++ b/noncore/settings/aqpkg/destination.cpp
@@ -0,0 +1,29 @@
1/***************************************************************************
2 destination.cpp - description
3 -------------------
4 begin : Mon Aug 26 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include "destination.h"
19#include "global.h"
20
21Destination::Destination( const char *name, const char *path )
22{
23 destName = name;
24 destPath = path;
25}
26
27Destination::~Destination()
28{
29}
diff --git a/noncore/settings/aqpkg/destination.h b/noncore/settings/aqpkg/destination.h
new file mode 100644
index 0000000..63999d6
--- a/dev/null
+++ b/noncore/settings/aqpkg/destination.h
@@ -0,0 +1,41 @@
1/***************************************************************************
2 destination.h - description
3 -------------------
4 begin : Mon Aug 26 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#ifndef DESTINATION_H
18#define DESTINATION_H
19
20#include <qstring.h>
21
22class Destination
23{
24public:
25 Destination() {}
26 Destination( const char *name, const char *path );
27 ~Destination();
28
29 void setDestinationName( const QString &name ) { destName = name; }
30 void setDestinationPath( const QString &path ) { destPath = path; }
31 QString &getDestinationName() { return destName; }
32 QString &getDestinationPath() { return destPath; }
33
34protected:
35
36private:
37 QString destName;
38 QString destPath;
39};
40
41#endif
diff --git a/noncore/settings/aqpkg/doc.txt b/noncore/settings/aqpkg/doc.txt
new file mode 100644
index 0000000..7722c07
--- a/dev/null
+++ b/noncore/settings/aqpkg/doc.txt
@@ -0,0 +1,49 @@
1<qt><h1>Documentation for AQPkg</h1><p>
2AQPkg is a package manager for the Sharp Zaurus.<br>
3Basic Instructions:<br>
4On startup, you will be shown a window. The main part of the window is taken up
5by a list box showing packages. The packages shown will depend on the server selected.<br>
6The servers list contains network servers containing feeds of packages that can be downloaded
7and installed onto your Zaurus. These are held in the file /etc/ipkg.conf and can be maintained
8using AQPkg. In addition to the servers defined in ipkg.conf file, there are two other servers -
9local and local IPKGs. These are not network servers but views of yours Zaurus.<br>
10The local server shows all installed packages, and the local IPKGs server shows all ipks
11that are stored on your Zaurus.<br>
12On the local server, you can only remove packages. On the local IPKGs server you can only
13install and delete packages - removing installed packages is currently not working. On all other
14servers you can install, uninstall, upgrade and download packages.<br>
15To get the latest package list for a server (or refresh the view), select the server you
16wish to update and click the Refresh List button.<br>
17To download a package from a remote server, select the server (any except local and local IPKGs),
18then select the package(s) you wish to download (by tapping in the box next to the package
19name so that a tick appears in the box) and click the Download button. Enter the path where you
20want the package to be downloaded to and click OK to download the package.<br>
21To install, upgrade or remove a package select the packages you wish to install and click the Apply
22button. You will then be shown a dialog which allows you to select which destination you wish
23to install the package to, which packages will be installed, removed and upgraded. You can also
24set various options. (for the moment, see the documentation for IPKG for more details on these
25options). To start the process, click Start. This will perform the necessary operations and
26will show you what is happening. Once everything has completed click the Close button.<br>
27Note: Currently, the operation to perform for a package is automatically decided based on the
28following rules:<br>
29If a package isn't installed, then it will be installed.<br>
30If a package is installed and there isn't a later version available then it will be removed.<br>
31If a package is installed and a different version is available then it will be upgraded. (Note,
32I haven't yet found a way to determine if an available package is newer or older than the one
33currently installed so it is possible that a package may be downgraded).<br>
34As previously mentioned, a package can be explicitly removed by using the local server.<br><br>
35A couple of last notes, in the main window, the following may be useful:<br>
36If a package is installed then it will have (installed) after it.<br>
37If a different version is available then it will have a * after the package name.<br>
38You can view details of a package by tapping twice (quickly) on the package name (NOT the
39box next to the package name). This will show you a brief description of the package, the
40version installed (if it is installed), and the version available for download/installation
41(if a different on is available).<br><br><br>
42Well, hope you enjoy using this program. If you have any ideas/suggestions/ideas for improvements
43then please let me know at andy.qua@blueyonder.co.uk.<br><br>
44Thanks for using this.
45Andy.
46</p></qt>
47
48
49
diff --git a/noncore/settings/aqpkg/global.h b/noncore/settings/aqpkg/global.h
new file mode 100644
index 0000000..be3ede4
--- a/dev/null
+++ b/noncore/settings/aqpkg/global.h
@@ -0,0 +1,78 @@
1/***************************************************************************
2 global.h - description
3 -------------------
4 begin : Mon Aug 26 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef __GLOBAL_H
19#define __GLOBAL_H
20
21// Uncomment the below line to run on a Linux box rather than a Zaurus
22// box this allows you to change where root is, and where to load config files from
23//#define X86
24
25// Sets up location of ipkg.conf and root directory
26#ifdef QWS
27
28#ifndef X86
29
30// Running QT/Embedded on an arm processor
31#define IPKG_CONF "/etc/ipkg.conf"
32#define ROOT "/"
33#define IPKG_DIR "/usr/lib/ipkg/"
34
35#else
36
37// Running QT/Embedded on a X86 linux box
38#define IPKG_DIR "/home/andy/projects/aqpkg/aqpkg/data"
39#define IPKG_CONF "/home/andy/projects/aqpkg/aqpkg/data/ipkg.conf"
40#define ROOT "/home/andy/projects/aqpkg/aqpkg/data/root"
41
42#endif
43
44#else
45
46// Running QT on a X86 linux box
47#define IPKG_CONF "/home/andy/projects/aqpkg/aqpkg/data/ipkg.conf"
48#define ROOT "/home/andy/projects/aqpkg/aqpkg/data/root"
49#define IPKG_DIR "/home/andy/projects/aqpkg/aqpkg/data"
50
51#endif
52
53
54// Uncomment the below line to turn on memory checking
55//#define _DEBUG 1
56
57#ifndef __MEMFILE_C
58#ifdef _DEBUG
59void * operator new(unsigned int size,const char *file, int line);
60void operator delete(void *p);
61#endif
62
63#ifdef _DEBUG
64#define DEBUG_NEW new(__FILE__, __LINE__)
65//#define DEBUG_NEW new
66#else
67#define DEBUG_NEW new
68#endif
69
70#define new DEBUG_NEW
71#endif
72
73
74void AddTrack(long addr, long asize, const char *fname, long lnum);
75void RemoveTrack(long addr);
76void DumpUnfreed();
77
78#endif
diff --git a/noncore/settings/aqpkg/helpwindow.cpp b/noncore/settings/aqpkg/helpwindow.cpp
new file mode 100644
index 0000000..0302b3f
--- a/dev/null
+++ b/noncore/settings/aqpkg/helpwindow.cpp
@@ -0,0 +1,95 @@
1/***************************************************************************
2 helpwindow.cpp - description
3 -------------------
4 begin : Sun Sep 8 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include <qwidget.h>
19#include <qlayout.h>
20#include <qstring.h>
21#include <qtextview.h>
22
23#include "helpwindow.h"
24#include "global.h"
25
26
27#define HELP_TEXT \
28"<qt><h1>Documentation for AQPkg</h1><p> " \
29"AQPkg is a package manager for the Sharp Zaurus.<br><br> " \
30"Basic Instructions:<br><br> " \
31"On startup, you will be shown a window. The main part of the window is taken up " \
32"by a list box showing packages. The packages shown will depend on the server selected.<br><br> " \
33"The servers list contains network servers containing feeds of packages that can be downloaded " \
34"and installed onto your Zaurus. These are held in the file /etc/ipkg.conf and can be maintained " \
35"using AQPkg. In addition to the servers defined in ipkg.conf file, there are two other servers - " \
36"local and local IPKGs. These are not network servers but views of yours Zaurus.<br><br> " \
37"The local server shows all installed packages, and the local IPKGs server shows all ipks " \
38"that are stored on your Zaurus.<br><br> " \
39"On the local server, you can only remove packages. On the local IPKGs server you can only " \
40"install and delete packages - removing installed packages is currently not working. On all other " \
41"servers you can install, uninstall, upgrade and download packages.<br><br> " \
42"To get the latest package list for a server (or refresh the view), select the server you " \
43"wish to update and click the Refresh List button.<br><br> " \
44"To download a package from a remote server, select the server (any except local and local IPKGs), " \
45"then select the package(s) you wish to download (by tapping in the box next to the package " \
46"name so that a tick appears in the box) and click the Download button. Enter the path where you " \
47"want the package to be downloaded to and click OK to download the package.<br><br> " \
48"To install, upgrade or remove a package select the packages you wish to install and click the Apply " \
49"button. You will then be shown a dialog which allows you to select which destination you wish " \
50"to install the package to, which packages will be installed, removed and upgraded. You can also " \
51"set various options. (for the moment, see the documentation for IPKG for more details on these " \
52"options). To start the process, click Start. This will perform the necessary operations and " \
53"will show you what is happening. Once everything has completed click the Close button.<br><br> " \
54"Note: Currently, the operation to perform for a package is automatically decided based on the " \
55"following rules:<br><br> " \
56" If a package isn't installed, then it will be installed.<br> " \
57" If a package is installed and there isn't a later version available then it will be removed.<br> " \
58" If a package is installed and a different version is available then it will be upgraded. (Note, " \
59"I haven't yet found a way to determine if an available package is newer or older than the one " \
60"currently installed so it is possible that a package may be downgraded).<br><br> " \
61"As previously mentioned, a package can be explicitly removed by using the local server.<br><br> " \
62"A couple of last notes, in the main window, the following may be useful:<br><br> " \
63"If a package is installed then it will have (installed) after it.<br><br> " \
64"If a different version is available then it will have a * after the package name.<br><br> " \
65"You can view details of a package by tapping twice (quickly) on the package name (NOT the " \
66"box next to the package name). This will show you a brief description of the package, the " \
67"version installed (if it is installed), and the version available for download or installation " \
68"(if a different on is available).<br><br> " \
69"Well, hope you enjoy using this program. If you have any ideas/suggestions/ideas for improvements " \
70"then please let me know at andy.qua@blueyonder.co.uk.<br><br> " \
71"Thanks for using this. " \
72"Andy. " \
73"</p></qt>"
74
75
76HelpWindow::HelpWindow( QWidget *parent, const char *name, bool modal, WFlags flags )
77 : QDialog( parent, name, modal, flags )
78{
79// resize( 230, 280 );
80
81 setCaption( "Help for AQPkg" );
82
83 QVBoxLayout *layout = new QVBoxLayout( this );
84 QString text = HELP_TEXT;;
85 QTextView *view = new QTextView( text, 0, this, "view" );
86 layout->insertSpacing( -1, 5 );
87 layout->insertWidget( -1, view );
88 layout->insertSpacing( -1, 5 );
89
90 showMaximized();
91}
92
93HelpWindow::~HelpWindow()
94{
95}
diff --git a/noncore/settings/aqpkg/helpwindow.h b/noncore/settings/aqpkg/helpwindow.h
new file mode 100644
index 0000000..edc1b6e
--- a/dev/null
+++ b/noncore/settings/aqpkg/helpwindow.h
@@ -0,0 +1,34 @@
1/***************************************************************************
2 helpwindow.h - description
3 -------------------
4 begin : Sun Sep 8 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef HELPWINDOW_H
19#define HELPWINDOW_H
20
21#include <qdialog.h>
22
23/**
24 *@author Andy Qua
25 */
26
27class HelpWindow : public QDialog
28{
29public:
30 HelpWindow( QWidget *parent = 0, const char *name = 0, bool modal = true, WFlags flags = 0 );
31 ~HelpWindow();
32};
33
34#endif
diff --git a/noncore/settings/aqpkg/inputdlg.cpp b/noncore/settings/aqpkg/inputdlg.cpp
new file mode 100644
index 0000000..724a891
--- a/dev/null
+++ b/noncore/settings/aqpkg/inputdlg.cpp
@@ -0,0 +1,121 @@
1/***************************************************************************
2 inputdlg.h - description
3 -------------------
4 begin : Mon Aug 26 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#include <qlayout.h>
18#include <qlabel.h>
19#include <qlineedit.h>
20#include <qpushbutton.h>
21#include <qspinbox.h>
22#include <qcombobox.h>
23#include <qwidgetstack.h>
24#include <qvalidator.h>
25#include <qapplication.h>
26
27#include "inputdlg.h"
28#include "global.h"
29
30
31InputDialog :: InputDialog( const QString &label, QWidget* parent, const char* name,
32 bool modal )
33 : QDialog( parent, name, modal )
34{
35 lineEdit = 0;
36
37 QVBoxLayout *vbox = new QVBoxLayout( this, 6, 6 );
38
39 QLabel* l = new QLabel( label, this );
40 vbox->addWidget( l );
41
42 lineEdit = new QLineEdit( this );
43 vbox->addWidget( lineEdit );
44
45 QHBoxLayout *hbox = new QHBoxLayout( 6 );
46 vbox->addLayout( hbox, AlignRight );
47
48 ok = new QPushButton( tr( "&OK" ), this );
49 ok->setDefault( TRUE );
50 QPushButton *cancel = new QPushButton( tr( "&Cancel" ), this );
51
52 QSize bs( ok->sizeHint() );
53 if ( cancel->sizeHint().width() > bs.width() )
54 bs.setWidth( cancel->sizeHint().width() );
55
56 ok->setFixedSize( bs );
57 cancel->setFixedSize( bs );
58
59 hbox->addWidget( new QWidget( this ) );
60 hbox->addWidget( ok );
61 hbox->addWidget( cancel );
62
63 connect( lineEdit, SIGNAL( returnPressed() ),
64 this, SLOT( tryAccept() ) );
65 connect( lineEdit, SIGNAL( textChanged( const QString & ) ),
66 this, SLOT( textChanged( const QString & ) ) );
67
68 connect( ok, SIGNAL( clicked() ), this, SLOT( accept() ) );
69 connect( cancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
70
71 resize( QMAX( sizeHint().width(), 240 ), sizeHint().height() );
72}
73
74/*!
75 Destructor.
76*/
77
78InputDialog::~InputDialog()
79{
80}
81
82void InputDialog :: setText( const QString &text )
83{
84 lineEdit->setText( text );
85 lineEdit->selectAll();
86}
87
88QString InputDialog :: getText()
89{
90 return lineEdit->text();
91}
92
93QString InputDialog::getText( const QString &caption, const QString &label,
94 const QString &text, bool *ok, QWidget *parent,
95 const char *name )
96{
97 InputDialog *dlg = new InputDialog( label, parent, name, true );
98 dlg->setCaption( caption );
99 dlg->setText( text );
100
101 QString result;
102 *ok = dlg->exec() == QDialog::Accepted;
103 if ( *ok )
104 result = dlg->getText();
105
106 delete dlg;
107 return result;
108}
109
110
111
112void InputDialog :: textChanged( const QString &s )
113{
114 ok->setEnabled( !s.isEmpty() );
115}
116
117void InputDialog :: tryAccept()
118{
119 if ( !lineEdit->text().isEmpty() )
120 accept();
121}
diff --git a/noncore/settings/aqpkg/inputdlg.h b/noncore/settings/aqpkg/inputdlg.h
new file mode 100644
index 0000000..1e0c5bc
--- a/dev/null
+++ b/noncore/settings/aqpkg/inputdlg.h
@@ -0,0 +1,50 @@
1/***************************************************************************
2 inputdlg.h - description
3 -------------------
4 begin : Mon Aug 26 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef INPUTDIALOG_H
19#define INPUTDIALOG_H
20
21#include <qdialog.h>
22#include <qstring.h>
23#include <qlineedit.h>
24#include <qpushbutton.h>
25
26class InputDialog : public QDialog
27{
28 Q_OBJECT
29
30public:
31 static QString getText( const QString &caption, const QString &label, const QString &text = QString::null,
32 bool *ok = 0, QWidget *parent = 0, const char *name = 0 );
33
34 InputDialog( const QString &label, QWidget* parent = 0, const char* name = 0,
35 bool modal = TRUE );
36 ~InputDialog();
37
38 void setText( const QString &text );
39 QString getText();
40
41private slots:
42 void textChanged( const QString &s );
43 void tryAccept();
44
45private:
46 QLineEdit *lineEdit;
47 QPushButton *ok;
48};
49
50#endif // INPUTDIALOG_H
diff --git a/noncore/settings/aqpkg/install.ui b/noncore/settings/aqpkg/install.ui
new file mode 100644
index 0000000..daa0ff6
--- a/dev/null
+++ b/noncore/settings/aqpkg/install.ui
@@ -0,0 +1,118 @@
1<!DOCTYPE UI><UI>
2<class>InstallDlg</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>InstallDlg</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>196</width>
15 <height>271</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Install</string>
21 </property>
22 <grid>
23 <property stdset="1">
24 <name>margin</name>
25 <number>11</number>
26 </property>
27 <property stdset="1">
28 <name>spacing</name>
29 <number>6</number>
30 </property>
31 <widget row="0" column="0" >
32 <class>QLabel</class>
33 <property stdset="1">
34 <name>name</name>
35 <cstring>TextLabel1</cstring>
36 </property>
37 <property stdset="1">
38 <name>text</name>
39 <string>Destination</string>
40 </property>
41 </widget>
42 <widget row="0" column="1" >
43 <class>QComboBox</class>
44 <property stdset="1">
45 <name>name</name>
46 <cstring>destination</cstring>
47 </property>
48 </widget>
49 <widget row="1" column="0" rowspan="1" colspan="2" >
50 <class>QGroupBox</class>
51 <property stdset="1">
52 <name>name</name>
53 <cstring>GroupBox2</cstring>
54 </property>
55 <property stdset="1">
56 <name>title</name>
57 <string>Output</string>
58 </property>
59 <grid>
60 <property stdset="1">
61 <name>margin</name>
62 <number>11</number>
63 </property>
64 <property stdset="1">
65 <name>spacing</name>
66 <number>6</number>
67 </property>
68 <widget row="0" column="0" >
69 <class>QMultiLineEdit</class>
70 <property stdset="1">
71 <name>name</name>
72 <cstring>output</cstring>
73 </property>
74 </widget>
75 </grid>
76 </widget>
77 <widget row="2" column="0" >
78 <class>QPushButton</class>
79 <property stdset="1">
80 <name>name</name>
81 <cstring>btnInstall</cstring>
82 </property>
83 <property stdset="1">
84 <name>text</name>
85 <string>Start</string>
86 </property>
87 </widget>
88 <widget row="2" column="1" >
89 <class>QPushButton</class>
90 <property stdset="1">
91 <name>name</name>
92 <cstring>btnOptions</cstring>
93 </property>
94 <property stdset="1">
95 <name>text</name>
96 <string>Options</string>
97 </property>
98 </widget>
99 </grid>
100</widget>
101<connections>
102 <connection>
103 <sender>btnOptions</sender>
104 <signal>clicked()</signal>
105 <receiver>InstallDlg</receiver>
106 <slot>optionsSelected()</slot>
107 </connection>
108 <connection>
109 <sender>btnInstall</sender>
110 <signal>clicked()</signal>
111 <receiver>InstallDlg</receiver>
112 <slot>installSelected()</slot>
113 </connection>
114 <slot access="public">installSelected()</slot>
115 <slot access="public">displayText(const QString &amp;)</slot>
116 <slot access="public">optionsSelected()</slot>
117</connections>
118</UI>
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp
new file mode 100644
index 0000000..31be213
--- a/dev/null
+++ b/noncore/settings/aqpkg/installdlgimpl.cpp
@@ -0,0 +1,193 @@
1/***************************************************************************
2 installdlgimpl.cpp - description
3 -------------------
4 begin : Mon Aug 26 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifdef QWS
19#include <qpe/config.h>
20#endif
21
22#include <qmultilineedit.h>
23#include <qdialog.h>
24#include <qcombobox.h>
25#include <qcheckbox.h>
26#include <qpushbutton.h>
27
28
29#include "datamgr.h"
30#include "instoptionsimpl.h"
31#include "destination.h"
32#include "installdlgimpl.h"
33#include "global.h"
34
35InstallDlgImpl::InstallDlgImpl( vector<QString> &packageList, DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl )
36 : InstallDlg( parent, name, modal, fl )
37{
38 dataMgr = dataManager;
39 vector<Destination>::iterator dit;
40
41 QString defaultDest = "root";
42#ifdef QWS
43 Config cfg( "aqpkg" );
44 cfg.setGroup( "settings" );
45 defaultDest = cfg.readEntry( "dest", "root" );
46
47 // Grab flags - Turn MAKE_LINKS on by default (if no flags found)
48 flags = cfg.readNumEntry( "installFlags", MAKE_LINKS );
49#else
50 flags = 0;
51#endif
52
53 // Output text is read only
54 output->setReadOnly( true );
55
56 // setup destination data
57 int defIndex = 0;
58 int i;
59 for ( i = 0 , dit = dataMgr->getDestinationList().begin() ; dit != dataMgr->getDestinationList().end() ; ++dit, ++i )
60 {
61 destination->insertItem( dit->getDestinationName() );
62 if ( dit->getDestinationName() == defaultDest )
63 defIndex = i;
64 }
65
66 destination->setCurrentItem( defIndex );
67
68 vector<QString>::iterator it;
69 // setup package data
70 QString remove = "Remove\n";
71 QString install = "\nInstall\n";
72 QString upgrade = "\nUpgrade\n";
73 for ( it = packageList.begin() ; it != packageList.end() ; ++it )
74 {
75 QString name = *it;
76 if ( name.startsWith( "I" ) )
77 {
78 installList.push_back( name.mid(1) );
79 install += " " + name.mid(1) + "\n";
80 }
81 else if ( name.startsWith( "D" ) )
82 {
83 removeList.push_back( name.mid(1) );
84 remove += " " + name.mid(1) + "\n";
85 }
86 else if ( name.startsWith( "U" ) )
87 {
88 updateList.push_back( name.mid(1) );
89 upgrade += " " + name.mid(1) + "\n";
90 }
91 }
92
93 output->setText( remove + install + upgrade );
94
95 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
96}
97
98InstallDlgImpl::~InstallDlgImpl()
99{
100}
101
102bool InstallDlgImpl :: showDlg()
103{
104 showMaximized();
105 bool ret = exec();
106
107 return ret;
108}
109
110void InstallDlgImpl :: optionsSelected()
111{
112 InstallOptionsDlgImpl opt( flags, this, "Option", true );
113 opt.exec();
114
115 // set options selected from dialog
116 flags = 0;
117 if ( opt.forceDepends->isChecked() )
118 flags |= FORCE_DEPENDS;
119 if ( opt.forceReinstall->isChecked() )
120 flags |= FORCE_REINSTALL;
121 if ( opt.forceRemove->isChecked() )
122 flags |= FORCE_REMOVE;
123 if ( opt.forceOverwrite->isChecked() )
124 flags |= FORCE_OVERWRITE;
125 if ( opt.makeLinks->isChecked() )
126 flags |= MAKE_LINKS;
127
128#ifdef QWS
129 Config cfg( "aqpkg" );
130 cfg.setGroup( "settings" );
131 cfg.writeEntry( "installFlags", flags );
132#endif
133}
134
135void InstallDlgImpl :: installSelected()
136{
137 if ( btnInstall->text() == "Close" )
138 {
139 done( 1 );
140 return;
141 }
142
143 btnInstall->setEnabled( false );
144
145 output->setText( "" );
146 Destination *d = dataMgr->getDestination( destination->currentText() );
147 QString dest = d->getDestinationName();
148 QString destDir = d->getDestinationPath();
149
150#ifdef QWS
151 // Save settings
152 Config cfg( "aqpkg" );
153 cfg.setGroup( "settings" );
154 cfg.writeEntry( "dest", dest );
155#endif
156
157 // First run through the remove list, then the install list then the upgrade list
158 vector<QString>::iterator it;
159 ipkg.setOption( "remove" );
160 ipkg.setDestination( dest );
161 ipkg.setDestinationDir( destDir );
162 ipkg.setFlags( flags );
163 for ( it = removeList.begin() ; it != removeList.end() ; ++it )
164 {
165 ipkg.setPackage( *it );
166 ipkg.runIpkg();
167 }
168
169 ipkg.setOption( "install" );
170 for ( it = installList.begin() ; it != installList.end() ; ++it )
171 {
172 ipkg.setPackage( *it );
173 ipkg.runIpkg();
174 }
175
176 flags |= FORCE_REINSTALL;
177 ipkg.setFlags( flags );
178 for ( it = updateList.begin() ; it != updateList.end() ; ++it )
179 {
180 ipkg.setPackage( *it );
181 ipkg.runIpkg();
182 }
183
184 btnInstall->setEnabled( true );
185 btnInstall->setText( tr( "Close" ) );
186}
187
188void InstallDlgImpl :: displayText(const QString &text )
189{
190 QString t = output->text() + "\n" + text;
191 output->setText( t );
192 output->setCursorPosition( output->numLines(), 0 );
193}
diff --git a/noncore/settings/aqpkg/installdlgimpl.h b/noncore/settings/aqpkg/installdlgimpl.h
new file mode 100644
index 0000000..195616d
--- a/dev/null
+++ b/noncore/settings/aqpkg/installdlgimpl.h
@@ -0,0 +1,54 @@
1/***************************************************************************
2 installdlgimpl.h - description
3 -------------------
4 begin : Mon Aug 26 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#ifndef INSTALLDLGIMPL_H
18#define INSTALLDLGIMPL_H
19
20#include <vector>
21using namespace std;
22
23#include <qstring.h>
24
25#include "ipkg.h"
26#include "install.h"
27
28class InstallDlgImpl : public InstallDlg
29{
30public:
31 InstallDlgImpl( vector<QString> &packageList, DataManager *dataManager, QWidget * parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 );
32 ~InstallDlgImpl();
33
34 bool showDlg();
35 bool upgradeServer( QString &server );
36
37protected:
38
39private:
40 DataManager *dataMgr;
41 vector<QString> installList;
42 vector<QString> removeList;
43 vector<QString> updateList;
44 int flags;
45 Ipkg ipkg;
46
47 bool runIpkg( QString &option, const QString& package, const QString& dest, int flags );
48
49 void optionsSelected();
50 void installSelected();
51 void displayText(const QString &text );
52};
53
54#endif
diff --git a/noncore/settings/aqpkg/instoptions.ui b/noncore/settings/aqpkg/instoptions.ui
new file mode 100644
index 0000000..d4a3548
--- a/dev/null
+++ b/noncore/settings/aqpkg/instoptions.ui
@@ -0,0 +1,132 @@
1<!DOCTYPE UI><UI>
2<class>InstallOptionsDlg</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>InstallOptionsDlg</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>158</width>
15 <height>205</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Options</string>
21 </property>
22 <property stdset="1">
23 <name>sizeGripEnabled</name>
24 <bool>false</bool>
25 </property>
26 <grid>
27 <property stdset="1">
28 <name>margin</name>
29 <number>11</number>
30 </property>
31 <property stdset="1">
32 <name>spacing</name>
33 <number>6</number>
34 </property>
35 <widget row="0" column="0" >
36 <class>QGroupBox</class>
37 <property stdset="1">
38 <name>name</name>
39 <cstring>GroupBox1</cstring>
40 </property>
41 <property stdset="1">
42 <name>title</name>
43 <string>Options</string>
44 </property>
45 <grid>
46 <property stdset="1">
47 <name>margin</name>
48 <number>11</number>
49 </property>
50 <property stdset="1">
51 <name>spacing</name>
52 <number>6</number>
53 </property>
54 <widget row="0" column="0" >
55 <class>QCheckBox</class>
56 <property stdset="1">
57 <name>name</name>
58 <cstring>forceDepends</cstring>
59 </property>
60 <property stdset="1">
61 <name>text</name>
62 <string>Force Depends</string>
63 </property>
64 </widget>
65 <widget row="1" column="0" >
66 <class>QCheckBox</class>
67 <property stdset="1">
68 <name>name</name>
69 <cstring>forceReinstall</cstring>
70 </property>
71 <property stdset="1">
72 <name>text</name>
73 <string>Force Reinstall</string>
74 </property>
75 </widget>
76 <widget row="2" column="0" >
77 <class>QCheckBox</class>
78 <property stdset="1">
79 <name>name</name>
80 <cstring>forceRemove</cstring>
81 </property>
82 <property stdset="1">
83 <name>text</name>
84 <string>Force Remove</string>
85 </property>
86 </widget>
87 <widget row="3" column="0" >
88 <class>QCheckBox</class>
89 <property stdset="1">
90 <name>name</name>
91 <cstring>forceOverwrite</cstring>
92 </property>
93 <property stdset="1">
94 <name>text</name>
95 <string>Force Overwrite</string>
96 </property>
97 </widget>
98 <widget row="4" column="0" >
99 <class>QCheckBox</class>
100 <property stdset="1">
101 <name>name</name>
102 <cstring>makeLinks</cstring>
103 </property>
104 <property stdset="1">
105 <name>text</name>
106 <string>Link to root</string>
107 </property>
108 </widget>
109 </grid>
110 </widget>
111 <widget row="1" column="0" >
112 <class>QPushButton</class>
113 <property stdset="1">
114 <name>name</name>
115 <cstring>btnOK</cstring>
116 </property>
117 <property stdset="1">
118 <name>text</name>
119 <string>OK</string>
120 </property>
121 </widget>
122 </grid>
123</widget>
124<connections>
125 <connection>
126 <sender>btnOK</sender>
127 <signal>clicked()</signal>
128 <receiver>InstallOptionsDlg</receiver>
129 <slot>accept()</slot>
130 </connection>
131</connections>
132</UI>
diff --git a/noncore/settings/aqpkg/instoptionsimpl.cpp b/noncore/settings/aqpkg/instoptionsimpl.cpp
new file mode 100644
index 0000000..d9d2be9
--- a/dev/null
+++ b/noncore/settings/aqpkg/instoptionsimpl.cpp
@@ -0,0 +1,49 @@
1/***************************************************************************
2 instoptionsimpl.cpp - description
3 -------------------
4 begin : Mon Aug 26 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifdef QWS
19#include <qpe/config.h>
20#endif
21
22#include <qdialog.h>
23#include <qcheckbox.h>
24
25#include "instoptionsimpl.h"
26#include "ipkg.h"
27#include "global.h"
28
29InstallOptionsDlgImpl::InstallOptionsDlgImpl( int flags, QWidget * parent, const char* name, bool modal, WFlags fl )
30 : InstallOptionsDlg( parent, name, modal, fl )
31{
32 if ( flags & FORCE_DEPENDS )
33 forceDepends->setChecked( true );
34 if ( flags & FORCE_REINSTALL )
35 forceReinstall->setChecked( true );
36 if ( flags & FORCE_REMOVE )
37 forceRemove->setChecked( true );
38 if ( flags & FORCE_OVERWRITE )
39 forceOverwrite->setChecked( true );
40 if ( flags & MAKE_LINKS )
41 makeLinks->setChecked( true );
42
43 showMaximized();
44
45}
46
47InstallOptionsDlgImpl::~InstallOptionsDlgImpl()
48{
49}
diff --git a/noncore/settings/aqpkg/instoptionsimpl.h b/noncore/settings/aqpkg/instoptionsimpl.h
new file mode 100644
index 0000000..08ec616
--- a/dev/null
+++ b/noncore/settings/aqpkg/instoptionsimpl.h
@@ -0,0 +1,33 @@
1/***************************************************************************
2 installoptionsimpl.h - description
3 -------------------
4 begin : Mon Aug 26 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#ifndef INSTALLOPTIONSIMPL_H
18#define INSTALLOPTIONSIMPL_H
19
20#include "instoptions.h"
21
22class InstallOptionsDlgImpl : public InstallOptionsDlg
23{
24public:
25 InstallOptionsDlgImpl( int flags, QWidget * parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 );
26 ~InstallOptionsDlgImpl();
27
28protected:
29
30private:
31};
32
33#endif
diff --git a/noncore/settings/aqpkg/ipkg.cpp b/noncore/settings/aqpkg/ipkg.cpp
new file mode 100644
index 0000000..d5157eb
--- a/dev/null
+++ b/noncore/settings/aqpkg/ipkg.cpp
@@ -0,0 +1,345 @@
1/***************************************************************************
2 ipkg.cpp - description
3 -------------------
4 begin : Sat Aug 31 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include <fstream>
19using namespace std;
20
21#include <stdio.h>
22#include <unistd.h>
23
24#ifdef QWS
25#include <qpe/qpeapplication.h>
26#else
27#include <qapplication.h>
28#endif
29#include <qdir.h>
30#include <qtextstream.h>
31
32#include "utils.h"
33#include "ipkg.h"
34#include "global.h"
35
36Ipkg :: Ipkg()
37{
38}
39
40Ipkg :: ~Ipkg()
41{
42}
43
44// Option is what we are going to do - install, upgrade, download
45// package is the package name to install - either a fully qualified path and ipk
46// file (if stored locally) or just the name of the package (for a network package)
47// packageName is the package name - (for a network package this will be the same as
48// package parameter)
49// dest is the destination alias (from ipk.conf)
50// destDir is the dir that the destination alias points to (used to link to root)
51// flags is the ipkg options flags
52// dir is the directory to run ipkg in (defaults to "")
53bool Ipkg :: runIpkg( )
54{
55 bool ret = false;
56
57 QDir::setCurrent( "/tmp" );
58 QString cmd = "";
59
60 if ( runtimeDir != "" )
61 {
62 cmd += "cd ";
63 cmd += runtimeDir;
64 cmd += " ; ";
65 }
66 cmd += "ipkg";
67
68 if ( option != "update" && option != "download" )
69 {
70 cmd += " -dest "+ destination;
71 cmd += " -force-defaults";
72
73 if ( flags & FORCE_DEPENDS )
74 cmd += " -force-depends";
75 if ( flags & FORCE_REINSTALL )
76 cmd += " -force-reinstall";
77 if ( flags & FORCE_REMOVE )
78 cmd += " -force-removal-of-essential-packages";
79 if ( flags & FORCE_OVERWRITE )
80 cmd += " -force-overwrite";
81
82 // Handle make links
83 // Rules - If make links is switched on, create links to root
84 // if destDir is NOT /
85 if ( flags & MAKE_LINKS )
86 {
87 // If destDir == / turn off make links as package is being insalled
88 // to root already.
89 if ( destDir == "/" )
90 flags ^= MAKE_LINKS;
91 }
92
93 }
94
95#ifdef X86
96 cmd += " -f ";
97 cmd += IPKG_CONF;
98#endif
99
100 cmd += " " + option + " " + package + " 2>&1";
101
102 qApp->processEvents();
103
104 // If we are removing packages and make links option is selected
105 // create the links
106 if ( option == "remove" )
107 {
108 createLinks = false;
109 if ( flags & MAKE_LINKS )
110 {
111 emit outputText( QString( "Removing symbolic links...\n" ) );
112 linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir );
113 }
114 }
115
116 emit outputText( cmd );
117
118 // Execute command
119 dependantPackages = new QList<QString>;
120 dependantPackages->setAutoDelete( true );
121 ret = executeIpkgCommand( cmd, option );
122
123 if ( option == "install" )
124 {
125 // If we are not removing packages and make links option is selected
126 // create the links
127 createLinks = true;
128 if ( flags & MAKE_LINKS )
129 {
130 emit outputText( " " );
131 emit outputText( QString( "Creating symbolic links for " )+ package );
132
133 linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir );
134
135 // link dependant packages that were installed with this release
136 QString *pkg;
137 for ( pkg = dependantPackages->first(); pkg != 0; pkg = dependantPackages->next() )
138 {
139 emit outputText( " " );
140 emit outputText( QString( "Creating symbolic links for " )+ (*pkg) );
141 linkPackage( Utils::getPackageNameFromIpkFilename( *pkg ), destination, destDir );
142 }
143 }
144 }
145
146 delete dependantPackages;
147
148 emit outputText( QString( "Finished - status=" ) + (ret ? "success" : "failure") );
149 return ret;
150}
151
152
153int Ipkg :: executeIpkgCommand( QString &cmd, const QString option )
154{
155 FILE *fp = NULL;
156 char line[130];
157 QString lineStr, lineStrOld;
158 int ret = false;
159
160 fp = popen( (const char *) cmd, "r");
161 if ( fp == NULL )
162 {
163 cout << "Couldn't execute " << cmd << "! err = " << fp << endl;
164 QString text;
165 text.sprintf( "Couldn't execute %s! See stdout for error code", (const char *)cmd );
166 emit outputText( text );
167 }
168 else
169 {
170 while ( fgets( line, sizeof line, fp) != NULL )
171 {
172 lineStr = line;
173 lineStr=lineStr.left( lineStr.length()-1 );
174
175 if ( lineStr != lineStrOld )
176 {
177 //See if we're finished
178 if ( option == "install" )
179 {
180 // Need to keep track of any dependant packages that get installed
181 // so that we can create links to them as necessary
182 if ( lineStr.startsWith( "Installing " ) )
183 {
184 cout << "LineStr = " << lineStr << endl;
185 int start = lineStr.find( " " ) + 1;
186 int end = lineStr.find( " ", start );
187 QString *package = new QString( lineStr.mid( start, end-start ) );
188 dependantPackages->append( package );
189 cout << "installing dependant package <" << *package << ">" << endl;
190 }
191 }
192
193 if ( option == "update" )
194 {
195 if (lineStr.contains("Updated list"))
196 ret = true;
197 }
198 else if ( option == "download" )
199 {
200 if (lineStr.contains("Downloaded"))
201 ret = true;
202 }
203 else
204 {
205 if (lineStr.contains("Done"))
206 ret = true;
207 }
208
209 emit outputText( lineStr );
210 }
211 lineStrOld = lineStr;
212 qApp->processEvents();
213 }
214 pclose(fp);
215 }
216
217 return ret;
218}
219
220
221void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, const QString &destDir )
222{
223 if ( dest == "root" || dest == "/" )
224 return;
225
226 qApp->processEvents();
227 QStringList *fileList = getList( packFileName, destDir );
228 qApp->processEvents();
229 processFileList( fileList, destDir );
230 delete fileList;
231}
232
233QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir )
234{
235 QString packageFileDir = destDir+"/usr/lib/ipkg/info/"+packageFilename+".list";
236 QFile f( packageFileDir );
237
238 cout << "Try to open " << packageFileDir.latin1() << endl;
239 if ( !f.open(IO_ReadOnly) )
240 {
241 // Couldn't open from dest, try from /
242// cout << "Could not open:" << packageFileDir << endl;
243 f.close();
244
245 packageFileDir = "/usr/lib/ipkg/info/"+packageFilename+".list";
246 f.setName( packageFileDir );
247// cout << "Try to open " << packageFileDir.latin1() << endl;
248 if ( ! f.open(IO_ReadOnly) )
249 {
250 cout << "Could not open:" << packageFileDir << endl;
251 emit outputText( QString( "Could not open :" ) + packageFileDir );
252 return (QStringList*)0;
253 }
254 }
255 QStringList *fileList = new QStringList();
256 QTextStream t( &f );
257 while ( !t.eof() )
258 *fileList += t.readLine();
259
260 f.close();
261 return fileList;
262}
263
264void Ipkg :: processFileList( const QStringList *fileList, const QString &destDir )
265{
266 if ( !fileList || fileList->isEmpty() )
267 return;
268
269 QString baseDir = ROOT;
270
271 if ( createLinks == true )
272 {
273 for ( uint i=0; i < fileList->count(); i++ )
274 {
275 processLinkDir( (*fileList)[i], baseDir, destDir );
276 qApp->processEvents();
277 }
278 }
279 else
280 {
281 for ( int i = fileList->count()-1; i >= 0 ; i-- )
282 {
283 cout << "i = " << i << ", Dealing with " << (*fileList)[i] << endl;
284 processLinkDir( (*fileList)[i], baseDir, destDir );
285 qApp->processEvents();
286 }
287 }
288}
289
290void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const QString &baseDir )
291{
292 QString sourceFile = baseDir + file;
293 QString linkFile = destDir + file;
294 QString text;
295 if ( createLinks )
296 {
297 // If this file is a directory (ends with a /) and it doesn't exist,
298 // we need to create it
299 if ( file.right(1) == "/" )
300 {
301 QFileInfo f( linkFile );
302 if ( !f.exists() )
303 {
304 emit outputText( QString( "Creating directory " ) + linkFile );
305 QDir d;
306 d.mkdir( linkFile, true );
307 }
308 else
309 emit outputText( QString( "Directory " ) + linkFile + " exists" );
310
311 }
312 else
313 {
314 int rc = symlink( sourceFile, linkFile );
315 text = (rc == 0 ? "Linked " : "Failed to link ");
316 text += sourceFile + " to " + linkFile;
317 emit outputText( text );
318 }
319 }
320 else
321 {
322 QFileInfo f( linkFile );
323 if ( f.exists() )
324 {
325 if ( f.isFile() )
326 {
327 QFile f( linkFile );
328 bool rc = f.remove();
329
330 text = (rc ? "Removed " : "Failed to remove ");
331 text += linkFile;
332 emit outputText( text );
333 }
334 else if ( f.isDir() )
335 {
336 QDir d;
337 bool rc = d.rmdir( linkFile, true );
338 text = (rc ? "Removed " : "Failed to remove ");
339 text += linkFile;
340 emit outputText( text );
341 }
342 }
343 }
344
345}
diff --git a/noncore/settings/aqpkg/ipkg.h b/noncore/settings/aqpkg/ipkg.h
new file mode 100644
index 0000000..63588c4
--- a/dev/null
+++ b/noncore/settings/aqpkg/ipkg.h
@@ -0,0 +1,72 @@
1/***************************************************************************
2 ipkg.h - description
3 -------------------
4 begin : Sat Aug 31 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef IPKG_H
19#define IPKG_H
20
21
22/**
23 *@author Andy Qua
24 */
25
26#include <qobject.h>
27#include <qstring.h>
28#include <qlist.h>
29
30#define FORCE_DEPENDS 0x0001
31#define FORCE_REMOVE 0x0002
32#define FORCE_REINSTALL 0x0004
33#define FORCE_OVERWRITE 0x0008
34#define MAKE_LINKS 0x0010
35
36class Ipkg : public QObject
37{
38 Q_OBJECT
39public:
40 Ipkg();
41 ~Ipkg();
42 bool runIpkg( );
43
44 void setOption( const char *opt ) { option = opt; }
45 void setPackage( const char *pkg ) { package = pkg; }
46 void setDestination( const char *dest ) { destination = dest; }
47 void setDestinationDir( const char *dir ) { destDir = dir; }
48 void setFlags( int fl ) { flags = fl; }
49 void setRuntimeDirectory( const char *dir ) { runtimeDir = dir; }
50
51signals:
52 void outputText( const QString &text );
53
54private:
55 bool createLinks;
56 QString option;
57 QString package;
58 QString destination;
59 QString destDir;
60 int flags;
61 QString runtimeDir;
62
63 QList<QString> *dependantPackages;
64
65 int executeIpkgCommand( QString &cmd, const QString option );
66 void linkPackage( const QString &packFileName, const QString &dest, const QString &destDir );
67 QStringList* getList( const QString &packageFilename, const QString &destDir );
68 void processFileList( const QStringList *fileList, const QString &destDir );
69 void processLinkDir( const QString &file, const QString &baseDir, const QString &destDir );
70};
71
72#endif
diff --git a/noncore/settings/aqpkg/main.cpp b/noncore/settings/aqpkg/main.cpp
new file mode 100644
index 0000000..e943e49
--- a/dev/null
+++ b/noncore/settings/aqpkg/main.cpp
@@ -0,0 +1,61 @@
1/***************************************************************************
2 main.cpp - description
3 -------------------
4 begin : Mon Aug 26 13:32:30 BST 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifdef QWS
19#include <qpe/qpeapplication.h>
20#else
21#include <qapplication.h>
22#endif
23
24#include <qobjectdefs.h>
25
26#include "mainwin.h"
27#include "server.h"
28
29#include "global.h"
30
31
32/*
33int main2(int argc, char *argv[])
34{
35 Server local( "local", "", "status" );
36 local.readPackageFile();
37
38 Server s( "opiecvs", "aaa" );
39 s.readPackageFile( &local );
40
41}
42*/
43
44int main(int argc, char *argv[])
45{
46#ifdef QWS
47 QPEApplication a( argc, argv );
48#else
49 QApplication a( argc, argv );
50#endif
51
52 MainWindow *win = new MainWindow();
53 a.setMainWidget(win);
54 win->show();
55
56 a.exec();
57
58 #ifdef _DEBUG
59 DumpUnfreed();
60 #endif
61}
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp
new file mode 100644
index 0000000..5de4dc9
--- a/dev/null
+++ b/noncore/settings/aqpkg/mainwin.cpp
@@ -0,0 +1,85 @@
1/***************************************************************************
2 mainwin.cpp - description
3 -------------------
4 begin : Mon Aug 26 13:32:30 BST 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include <qmenubar.h>
19#include <qpopupmenu.h>
20
21#include "mainwin.h"
22#include "datamgr.h"
23#include "networkpkgmgr.h"
24#include "settingsimpl.h"
25#include "helpwindow.h"
26#include "global.h"
27
28MainWindow :: MainWindow( QWidget *p, char *name )
29 :QMainWindow( p, name )
30{
31#ifdef QWS
32 showMaximized();
33#endif
34
35 setCaption( "AQPkg - Package Manager" );
36
37 // Create our menu
38 QPopupMenu *help = new QPopupMenu( this );
39 help->insertItem( "&General", this, SLOT(displayHelp()), Qt::CTRL+Qt::Key_H );
40 help->insertItem( "&About", this, SLOT(displayAbout()), Qt::CTRL+Qt::Key_A );
41
42 QPopupMenu *settings = new QPopupMenu( this );
43 settings->insertItem( "&Settings", this, SLOT(displaySettings()), Qt::CTRL+Qt::Key_S );
44
45 // Create the main menu
46 QMenuBar *menu = menuBar(); //new QMenuBar( this );
47 menu->insertItem( "&Settings", settings );
48 menu->insertItem( "&Help", help );
49
50 mgr = new DataManager();
51 mgr->loadServers();
52
53 stack = new QWidgetStack( this );
54
55 networkPkgWindow = new NetworkPackageManager( mgr, stack );
56 stack->addWidget( networkPkgWindow, 1 );
57
58 setCentralWidget( stack );
59 stack->raiseWidget( networkPkgWindow );
60}
61
62MainWindow :: ~MainWindow()
63{
64 delete networkPkgWindow;
65}
66
67void MainWindow :: displaySettings()
68{
69 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true );
70 if ( dlg->showDlg( 0 ) )
71 networkPkgWindow->updateData();
72 delete dlg;
73}
74
75void MainWindow :: displayHelp()
76{
77 HelpWindow *dlg = new HelpWindow( this );
78 dlg->exec();
79 delete dlg;
80}
81
82void MainWindow :: displayAbout()
83{
84
85}
diff --git a/noncore/settings/aqpkg/mainwin.h b/noncore/settings/aqpkg/mainwin.h
new file mode 100644
index 0000000..2a182fc
--- a/dev/null
+++ b/noncore/settings/aqpkg/mainwin.h
@@ -0,0 +1,47 @@
1/***************************************************************************
2 mainwin.h - description
3 -------------------
4 begin : Mon Aug 26 13:32:30 BST 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef MAINWIN_H
19#define MAINWIN_H
20
21#include <qmainwindow.h>
22#include <qwidgetstack.h>
23
24
25class NetworkPackageManager;
26class DataManager;
27
28class MainWindow :public QMainWindow
29{
30 Q_OBJECT
31public:
32
33 MainWindow( QWidget *p = 0, char *name = 0 );
34 ~MainWindow();
35
36private:
37 DataManager *mgr;
38
39 QWidgetStack *stack;
40 NetworkPackageManager *networkPkgWindow;
41
42public slots:
43 void displayHelp();
44 void displayAbout();
45 void displaySettings();
46};
47#endif
diff --git a/noncore/settings/aqpkg/mem.cpp b/noncore/settings/aqpkg/mem.cpp
new file mode 100644
index 0000000..76ce35c
--- a/dev/null
+++ b/noncore/settings/aqpkg/mem.cpp
@@ -0,0 +1,105 @@
1/***************************************************************************
2 mem.h - description
3 -------------------
4 begin : Mon Aug 26 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#include <stdio.h>
18#include <fstream>
19#include <list>
20using namespace std;
21
22#define __MEMFILE_C
23#include "global.h"
24
25#ifdef _DEBUG
26
27void __cdecl *operator new( unsigned int size, const char *file, int line )
28{
29 void *ptr = (void *)malloc(size);
30 AddTrack((long)ptr, size, file, line);
31 return(ptr);
32}
33
34void operator delete(void *p)
35{
36 RemoveTrack((long)p);
37 free(p);
38}
39
40#endif
41
42
43typedef struct {
44 longaddress;
45 longsize;
46 charfile[64];
47 longline;
48} ALLOC_INFO;
49
50typedef list<ALLOC_INFO*> AllocList;
51
52AllocList allocList;
53
54
55
56void AddTrack(long addr, long asize, const char *fname, long lnum)
57{
58 ALLOC_INFO *info;
59
60
61 info = (ALLOC_INFO *)malloc(sizeof( ALLOC_INFO ));
62 info->address = addr;
63 strncpy(info->file, fname, 63);
64 info->line = lnum;
65 info->size = asize;
66 allocList.insert(allocList.begin(), info);
67};
68
69void RemoveTrack(long addr)
70{
71 AllocList::iterator i;
72
73 bool found = false;
74 for(i = allocList.begin(); i != allocList.end(); i++)
75 {
76 if((*i)->address == addr)
77 {
78 allocList.remove((*i));
79 found = true;
80 break;
81 }
82 }
83}
84
85void DumpUnfreed()
86{
87 AllocList::iterator i;
88 long totalSize = 0;
89 char buf[1024];
90
91
92// if(!allocList)
93 // return;
94
95 for(i = allocList.begin(); i != allocList.end(); i++) {
96 sprintf(buf, "%-15s: LINE %ld, ADDRESS %ld %ld unfreed",
97 (*i)->file, (*i)->line, (*i)->address, (*i)->size);
98 cout <<buf << endl;
99 totalSize += (*i)->size;
100 }
101 sprintf(buf, "-----------------------------------------------------------\n");
102 cout <<buf << endl;
103 sprintf(buf, "Total Unfreed: %ld bytes\n", totalSize);
104 cout <<buf << endl;
105};
diff --git a/noncore/settings/aqpkg/moc_aqpkg.cpp b/noncore/settings/aqpkg/moc_aqpkg.cpp
new file mode 100644
index 0000000..751d3a2
--- a/dev/null
+++ b/noncore/settings/aqpkg/moc_aqpkg.cpp
@@ -0,0 +1,95 @@
1/****************************************************************************
2** Aqpkg meta object code from reading C++ file 'aqpkg.h'
3**
4** Created: Thu Aug 29 13:01:06 2002
5** by: The Qt MOC ($Id$)
6**
7** WARNING! All changes made in this file will be lost!
8*****************************************************************************/
9
10#if !defined(Q_MOC_OUTPUT_REVISION)
11#define Q_MOC_OUTPUT_REVISION 9
12#elif Q_MOC_OUTPUT_REVISION != 9
13#error "Moc format conflict - please regenerate all moc files"
14#endif
15
16#include "aqpkg.h"
17#include <qmetaobject.h>
18#include <qapplication.h>
19
20
21
22const char *Aqpkg::className() const
23{
24 return "Aqpkg";
25}
26
27QMetaObject *Aqpkg::metaObj = 0;
28
29void Aqpkg::initMetaObject()
30{
31 if ( metaObj )
32 return;
33 if ( qstrcmp(QWidget::className(), "QWidget") != 0 )
34 badSuperclassWarning("Aqpkg","QWidget");
35 (void) staticMetaObject();
36}
37
38#ifndef QT_NO_TRANSLATION
39
40QString Aqpkg::tr(const char* s)
41{
42 return qApp->translate( "Aqpkg", s, 0 );
43}
44
45QString Aqpkg::tr(const char* s, const char * c)
46{
47 return qApp->translate( "Aqpkg", s, c );
48}
49
50#endif // QT_NO_TRANSLATION
51
52QMetaObject* Aqpkg::staticMetaObject()
53{
54 if ( metaObj )
55 return metaObj;
56 (void) QWidget::staticMetaObject();
57#ifndef QT_NO_PROPERTIES
58#endif // QT_NO_PROPERTIES
59 typedef void (Aqpkg::*m1_t0)(int);
60 typedef void (QObject::*om1_t0)(int);
61 typedef void (Aqpkg::*m1_t1)();
62 typedef void (QObject::*om1_t1)();
63 typedef void (Aqpkg::*m1_t2)();
64 typedef void (QObject::*om1_t2)();
65 m1_t0 v1_0 = &Aqpkg::serverSelected;
66 om1_t0 ov1_0 = (om1_t0)v1_0;
67 m1_t1 v1_1 = &Aqpkg::applyChanges;
68 om1_t1 ov1_1 = (om1_t1)v1_1;
69 m1_t2 v1_2 = &Aqpkg::updateServer;
70 om1_t2 ov1_2 = (om1_t2)v1_2;
71 QMetaData *slot_tbl = QMetaObject::new_metadata(3);
72 QMetaData::Access *slot_tbl_access = QMetaObject::new_metaaccess(3);
73 slot_tbl[0].name = "serverSelected(int)";
74 slot_tbl[0].ptr = (QMember)ov1_0;
75 slot_tbl_access[0] = QMetaData::Public;
76 slot_tbl[1].name = "applyChanges()";
77 slot_tbl[1].ptr = (QMember)ov1_1;
78 slot_tbl_access[1] = QMetaData::Public;
79 slot_tbl[2].name = "updateServer()";
80 slot_tbl[2].ptr = (QMember)ov1_2;
81 slot_tbl_access[2] = QMetaData::Public;
82 metaObj = QMetaObject::new_metaobject(
83 "Aqpkg", "QWidget",
84 slot_tbl, 3,
85 0, 0,
86#ifndef QT_NO_PROPERTIES
87 0, 0,
88 0, 0,
89#endif // QT_NO_PROPERTIES
90 0, 0 );
91 metaObj->set_slot_access( slot_tbl_access );
92#ifndef QT_NO_PROPERTIES
93#endif // QT_NO_PROPERTIES
94 return metaObj;
95}
diff --git a/noncore/settings/aqpkg/moc_qinputdialog.cpp b/noncore/settings/aqpkg/moc_qinputdialog.cpp
new file mode 100644
index 0000000..ab98a7e
--- a/dev/null
+++ b/noncore/settings/aqpkg/moc_qinputdialog.cpp
@@ -0,0 +1,88 @@
1/****************************************************************************
2** QInputDialog meta object code from reading C++ file 'qinputdialog.h'
3**
4** Created: Sun Sep 8 17:28:15 2002
5** by: The Qt MOC ($Id$)
6**
7** WARNING! All changes made in this file will be lost!
8*****************************************************************************/
9
10#if !defined(Q_MOC_OUTPUT_REVISION)
11#define Q_MOC_OUTPUT_REVISION 9
12#elif Q_MOC_OUTPUT_REVISION != 9
13#error "Moc format conflict - please regenerate all moc files"
14#endif
15
16#include "qinputdialog.h"
17#include <qmetaobject.h>
18#include <qapplication.h>
19
20
21
22const char *QInputDialog::className() const
23{
24 return "QInputDialog";
25}
26
27QMetaObject *QInputDialog::metaObj = 0;
28
29void QInputDialog::initMetaObject()
30{
31 if ( metaObj )
32 return;
33 if ( qstrcmp(QDialog::className(), "QDialog") != 0 )
34 badSuperclassWarning("QInputDialog","QDialog");
35 (void) staticMetaObject();
36}
37
38#ifndef QT_NO_TRANSLATION
39
40QString QInputDialog::tr(const char* s)
41{
42 return qApp->translate( "QInputDialog", s, 0 );
43}
44
45QString QInputDialog::tr(const char* s, const char * c)
46{
47 return qApp->translate( "QInputDialog", s, c );
48}
49
50#endif // QT_NO_TRANSLATION
51
52QMetaObject* QInputDialog::staticMetaObject()
53{
54 if ( metaObj )
55 return metaObj;
56 (void) QDialog::staticMetaObject();
57#ifndef QT_NO_PROPERTIES
58#endif // QT_NO_PROPERTIES
59 typedef void (QInputDialog::*m1_t0)(const QString&);
60 typedef void (QObject::*om1_t0)(const QString&);
61 typedef void (QInputDialog::*m1_t1)();
62 typedef void (QObject::*om1_t1)();
63 m1_t0 v1_0 = &QInputDialog::textChanged;
64 om1_t0 ov1_0 = (om1_t0)v1_0;
65 m1_t1 v1_1 = &QInputDialog::tryAccept;
66 om1_t1 ov1_1 = (om1_t1)v1_1;
67 QMetaData *slot_tbl = QMetaObject::new_metadata(2);
68 QMetaData::Access *slot_tbl_access = QMetaObject::new_metaaccess(2);
69 slot_tbl[0].name = "textChanged(const QString&)";
70 slot_tbl[0].ptr = (QMember)ov1_0;
71 slot_tbl_access[0] = QMetaData::Private;
72 slot_tbl[1].name = "tryAccept()";
73 slot_tbl[1].ptr = (QMember)ov1_1;
74 slot_tbl_access[1] = QMetaData::Private;
75 metaObj = QMetaObject::new_metaobject(
76 "QInputDialog", "QDialog",
77 slot_tbl, 2,
78 0, 0,
79#ifndef QT_NO_PROPERTIES
80 0, 0,
81 0, 0,
82#endif // QT_NO_PROPERTIES
83 0, 0 );
84 metaObj->set_slot_access( slot_tbl_access );
85#ifndef QT_NO_PROPERTIES
86#endif // QT_NO_PROPERTIES
87 return metaObj;
88}
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp
new file mode 100644
index 0000000..91a318c
--- a/dev/null
+++ b/noncore/settings/aqpkg/networkpkgmgr.cpp
@@ -0,0 +1,395 @@
1/***************************************************************************
2 networkpkgmgr.cpp - description
3 -------------------
4 begin : Mon Aug 26 13:32:30 BST 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include <fstream>
19#include <iostream>
20using namespace std;
21
22#include <unistd.h>
23#include <stdlib.h>
24
25#ifdef QWS
26#include <qpe/qpeapplication.h>
27#include <qpe/qcopenvelope_qws.h>
28#include <qpe/config.h>
29#else
30#include <qapplication.h>
31#endif
32#include <qlabel.h>
33#include <qfile.h>
34
35#include "datamgr.h"
36#include "networkpkgmgr.h"
37#include "installdlgimpl.h"
38#include "ipkg.h"
39#include "inputdlg.h"
40
41#include "global.h"
42
43NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name)
44 : QWidget(parent, name)
45{
46 dataMgr = dataManager;
47
48 initGui();
49 setupConnections();
50
51 progressDlg = 0;
52 timerId = startTimer( 100 );
53}
54
55NetworkPackageManager::~NetworkPackageManager()
56{
57}
58
59void NetworkPackageManager :: timerEvent ( QTimerEvent * )
60{
61 killTimer( timerId );
62
63// showProgressDialog();
64 // Add server names to listbox
65 updateData();
66
67// progressDlg->hide();
68}
69
70void NetworkPackageManager :: updateData()
71{
72 serversList->clear();
73 packagesList->clear();
74
75 vector<Server>::iterator it;
76 int activeItem = -1;
77 int i;
78 for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i )
79 {
80 serversList->insertItem( it->getServerName() );
81 if ( it->getServerName() == dataMgr->getActiveServer() )
82 activeItem = i;
83 }
84
85 // set selected server to be active server
86 if ( activeItem != -1 )
87 serversList->setCurrentItem( activeItem );
88 serverSelected( 0 );
89}
90
91
92void NetworkPackageManager :: initGui()
93{
94 QLabel *l = new QLabel( "Servers", this );
95 serversList = new QComboBox( this );
96 packagesList = new QListView( this );
97 update = new QPushButton( "Refresh List", this );
98 download = new QPushButton( "Download", this );
99 apply = new QPushButton( "Apply", this );
100
101 QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" );
102 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" );
103 hbox1->addWidget( l );
104 hbox1->addWidget( serversList );
105
106 vbox->addWidget( packagesList );
107 packagesList->addColumn( "Packages" );
108
109 QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" );
110 hbox2->addWidget( update );
111 hbox2->addWidget( download );
112 hbox2->addWidget( apply );
113}
114
115void NetworkPackageManager :: setupConnections()
116{
117 connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int )));
118 connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) );
119 connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) );
120 connect( update, SIGNAL(released()), this, SLOT(updateServer()) );
121}
122
123void NetworkPackageManager :: showProgressDialog()
124{
125 if ( !progressDlg )
126 progressDlg = new ProgressDlg( this, "Progress", false );
127 progressDlg->setText( "Reading installed packages" );
128 progressDlg->show();
129}
130
131
132void NetworkPackageManager :: serverSelected( int )
133{
134 packagesList->clear();
135
136 // display packages
137 QString serverName = serversList->currentText();
138 Server *s = dataMgr->getServer( serverName );
139 dataMgr->setActiveServer( serverName );
140
141 vector<Package> &list = s->getPackageList();
142 vector<Package>::iterator it;
143 for ( it = list.begin() ; it != list.end() ; ++it )
144 {
145 QString text = "";
146
147 // If the local server, only display installed packages
148 if ( serverName == LOCAL_SERVER && !it->isInstalled() )
149 continue;
150
151 text += it->getPackageName();
152 if ( it->isInstalled() )
153 {
154 text += " (installed)";
155
156 // If a different version of package is available, postfix it with an *
157 if ( it->getVersion() != it->getInstalledVersion() )
158 text += "*";
159 }
160
161 QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox );
162 if ( !it->isPackageStoredLocally() )
163 new QCheckListItem( item, QString( "Description - " ) + it->getDescription() );
164 else
165 new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() );
166
167 new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() );
168 if ( it->getLocalPackage() )
169 {
170 if ( it->isInstalled() )
171 new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() );
172 }
173 packagesList->insertItem( item );
174 }
175
176 // If the local server or the local ipkgs server disable the download button
177 download->setText( "Download" );
178 if ( serverName == LOCAL_SERVER )
179 download->setEnabled( false );
180 else if ( serverName == LOCAL_IPKGS )
181 {
182 download->setEnabled( true );
183 download->setText( "Remove" );
184 }
185 else
186 download->setEnabled( true );
187}
188
189void NetworkPackageManager :: updateServer()
190{
191 QString serverName = serversList->currentText();
192
193 // Update the current server
194 // Display dialog
195 ProgressDlg *dlg = new ProgressDlg( this );
196 QString status = "Updating package list for ";
197 status += serverName;
198 dlg->show();
199 dlg->setText( status );
200
201 // Disable buttons to stop silly people clicking lots on them :)
202
203 // First, write out ipkg_conf file so that ipkg can use it
204 dataMgr->writeOutIpkgConf();
205
206 if ( serverName == LOCAL_SERVER )
207 ;
208 else if ( serverName == LOCAL_IPKGS )
209 ;
210 else
211 {
212 QString option = "update";
213 QString dummy = "";
214 Ipkg ipkg;
215 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
216 ipkg.setOption( option );
217
218 ipkg.runIpkg( );
219 }
220
221 // Reload data
222 dataMgr->reloadServerData( serversList->currentText() );
223 serverSelected(-1);
224 delete dlg;
225}
226
227
228void NetworkPackageManager :: downloadPackage()
229{
230 if ( download->text() == "Download" )
231 {
232 // First, write out ipkg_conf file so that ipkg can use it
233 dataMgr->writeOutIpkgConf();
234
235 // Display dialog to user asking where to download the files to
236 bool ok = FALSE;
237 QString dir = "";
238#ifdef QWS
239 // read download directory from config file
240 Config cfg( "aqpkg" );
241 cfg.setGroup( "settings" );
242 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" );
243#endif
244
245 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this );
246 if ( ok && !text.isEmpty() )
247 dir = text; // user entered something and pressed ok
248 else
249 return; // user entered nothing or pressed cancel
250
251#ifdef QWS
252 // Store download directory in config file
253 cfg.writeEntry( "downloadDir", dir );
254#endif
255
256 // Get starting directory
257 char initDir[PATH_MAX];
258 getcwd( initDir, PATH_MAX );
259
260 // Download each package
261 Ipkg ipkg;
262 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
263
264 QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
265 ipkg.setOption( "download" );
266 ipkg.setRuntimeDirectory( initDir );
267 do
268 {
269 if ( item->isOn() )
270 {
271 QString name = item->text();
272 int pos = name.find( "*" );
273 name.truncate( pos );
274
275 // if (there is a (installed), remove it
276 pos = name.find( "(installed)" );
277 if ( pos > 0 )
278 name.truncate( pos - 1 );
279
280 ipkg.setPackage( name );
281 ipkg.runIpkg( );
282 }
283
284 item = (QCheckListItem *)item->nextSibling();
285 } while ( item );
286 }
287 else if ( download->text() == "Remove" )
288 {
289 QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
290 do
291 {
292 if ( item->isOn() )
293 {
294 QString name = item->text();
295 int pos = name.find( "*" );
296 name.truncate( pos );
297
298 // if (there is a (installed), remove it
299 pos = name.find( "(installed)" );
300 if ( pos > 0 )
301 name.truncate( pos - 1 );
302
303 Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name );
304 QFile f( p->getFilename() );
305 f.remove();
306 }
307 item = (QCheckListItem *)item->nextSibling();
308 } while ( item );
309 }
310
311 dataMgr->reloadServerData( LOCAL_IPKGS );
312 serverSelected( -1 );
313}
314
315
316void NetworkPackageManager :: applyChanges()
317{
318 // Disable buttons to stop silly people clicking lots on them :)
319
320 // First, write out ipkg_conf file so that ipkg can use it
321 dataMgr->writeOutIpkgConf();
322
323 // Now for each selected item
324 // deal with it
325
326 vector<QString> workingPackages;
327 QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
328 do
329 {
330 if ( item->isOn() )
331 {
332 QString p = dealWithItem( item );
333 workingPackages.push_back( p );
334 }
335
336 item = (QCheckListItem *)item->nextSibling();
337 } while ( item );
338
339 // do the stuff
340 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true );
341 dlg.showDlg();
342
343 // Reload data
344 dataMgr->reloadServerData( LOCAL_SERVER );
345 dataMgr->reloadServerData( serversList->currentText() );
346 serverSelected(-1);
347
348#ifdef QWS
349 // Finally let the main system update itself
350 QCopEnvelope e("QPE/System", "linkChanged(QString)");
351 QString lf = QString::null;
352 e << lf;
353#endif
354}
355
356// decide what to do - either remove, upgrade or install
357// Current rules:
358// If not installed - install
359// If installed and different version available - upgrade
360// If installed and version up to date - remove
361QString NetworkPackageManager :: dealWithItem( QCheckListItem *item )
362{
363 QString name = item->text();
364 int pos = name.find( "*" );
365 name.truncate( pos );
366
367 // if (there is a (installed), remove it
368 pos = name.find( "(installed)" );
369 if ( pos > 0 )
370 name.truncate( pos - 1 );
371
372 // Get package
373 Server *s = dataMgr->getServer( serversList->currentText() );
374 Package *p = s->getPackage( name );
375
376 // If the package has a filename then it is a local file
377 if ( p->isPackageStoredLocally() )
378 name = p->getFilename();
379 QString option;
380 QString dest = "root";
381 if ( !p->isInstalled() )
382 return QString( "I" ) + name;
383 else
384 {
385 if ( p->getVersion() == p->getInstalledVersion() )
386 return QString( "D" ) + name;
387 else
388 return QString( "U" ) + name;
389 }
390}
391
392void NetworkPackageManager :: displayText( const QString &t )
393{
394 cout << t << endl;
395}
diff --git a/noncore/settings/aqpkg/networkpkgmgr.h b/noncore/settings/aqpkg/networkpkgmgr.h
new file mode 100644
index 0000000..874b1bd
--- a/dev/null
+++ b/noncore/settings/aqpkg/networkpkgmgr.h
@@ -0,0 +1,70 @@
1/***************************************************************************
2 networkpkgmgr.h - description
3 -------------------
4 begin : Mon Aug 26 13:32:30 BST 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef NETWORKPKGMGR_H
19#define NETWORKPKGMGR_H
20
21#include <qlayout.h>
22#include <qpushbutton.h>
23#include <qwidget.h>
24#include <qcombobox.h>
25#include <qlistview.h>
26
27#include "datamgr.h"
28#include "progressdlg.h"
29
30/** NetworkPackageManager is the base class of the project */
31class NetworkPackageManager : public QWidget
32{
33 Q_OBJECT
34public:
35 /** construtor */
36 NetworkPackageManager( DataManager *dataManager, QWidget* parent=0, const char *name=0);
37 /** destructor */
38 ~NetworkPackageManager();
39
40 void updateData();
41
42private:
43 DataManager *dataMgr;
44
45 QComboBox *serversList;
46 QListView *packagesList;
47 QPushButton *update;
48 QPushButton *download;
49 QPushButton *apply;
50
51 ProgressDlg *progressDlg;
52
53 int timerId;
54
55 void timerEvent ( QTimerEvent * );
56
57 void initGui();
58 void setupConnections();
59 void showProgressDialog();
60 QString dealWithItem( QCheckListItem *item );
61
62public slots:
63 void serverSelected( int index );
64 void applyChanges();
65 void downloadPackage();
66 void updateServer();
67 void displayText( const QString &t );
68};
69
70#endif
diff --git a/noncore/settings/aqpkg/package.cpp b/noncore/settings/aqpkg/package.cpp
new file mode 100644
index 0000000..48b6934
--- a/dev/null
+++ b/noncore/settings/aqpkg/package.cpp
@@ -0,0 +1,109 @@
1/***************************************************************************
2 package.cpp - description
3 -------------------
4 begin : Mon Aug 26 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include "package.h"
19#include "global.h"
20
21Package::Package( QString &name )
22{
23 packageName = name;
24 localPackage = 0;
25 installed = false;
26 packageStoredLocally = false;
27 installedToRoot = false;
28}
29
30Package::Package( char *name )
31{
32 packageName = name;
33 localPackage = 0;
34}
35
36Package::~Package()
37{
38}
39
40QString Package :: toString()
41{
42 QString ret = "Package - " + getPackageName() +
43 "\n version - " + getVersion();
44
45 if ( localPackage )
46 ret += "\n inst version - " + localPackage->getVersion();
47
48
49 return ret;
50}
51
52void Package :: setStatus( QString &s )
53{
54 status = s;
55
56 if ( status.find( "installed" ) != -1 )
57 installed = true;
58}
59
60void Package :: setLocalPackage( Package *p )
61{
62 localPackage = p;
63
64 if ( localPackage )
65 if ( localPackage->getVersion() != getVersion() )
66 differentVersionAvailable = true;
67 else
68 differentVersionAvailable = false;
69}
70
71void Package :: setVersion( QString &v )
72{
73 version = v;
74
75 if ( localPackage )
76 if ( localPackage->getVersion() != getVersion() )
77 differentVersionAvailable = true;
78 else
79 differentVersionAvailable = false;
80}
81
82void Package :: setPackageName( QString &name )
83{
84 packageName = name;
85}
86
87void Package :: setDescription( QString &d )
88{
89 description = d;
90}
91
92void Package :: setFilename( QString &f )
93{
94 filename = f;
95}
96
97
98QString Package :: getInstalledVersion()
99{
100 if ( localPackage )
101 return localPackage->getVersion();
102 else
103 return getVersion();
104}
105
106bool Package :: isInstalled()
107{
108 return installed || ( localPackage && localPackage->isInstalled() );
109}
diff --git a/noncore/settings/aqpkg/package.h b/noncore/settings/aqpkg/package.h
new file mode 100644
index 0000000..d885ab6
--- a/dev/null
+++ b/noncore/settings/aqpkg/package.h
@@ -0,0 +1,75 @@
1/***************************************************************************
2 package.h - description
3 -------------------
4 begin : Mon Aug 26 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef PACKAGE_H
19#define PACKAGE_H
20
21#include <stdlib.h>
22
23/**
24 *@author Andy Qua
25 */
26
27#include <qstring.h>
28
29class Package
30{
31public:
32 Package( QString &name );
33 Package( char *name );
34 ~Package();
35
36 void setLocalPackage( Package *p );
37 void setPackageName( QString &name );
38 void setVersion( QString &v );
39 void setStatus( QString &s );
40 void setDescription( QString &d );
41 void setFilename( QString &f );
42 void setPackageStoredLocally( bool local ){ packageStoredLocally = local; }
43 void setInstalledToRoot( bool root ) { installedToRoot = root; }
44
45 Package *getLocalPackage() { return localPackage; }
46 QString getPackageName() { return packageName; }
47 QString getVersion() { return version; }
48 QString getStatus() { return status; }
49 QString getDescription() { return description; }
50 QString getFilename() { return filename; }
51
52 bool isInstalled();
53 bool isPackageStoredLocally(){ return packageStoredLocally; }
54 bool isInstalledToRoot() { return installedToRoot; }
55 QString getInstalledVersion();
56
57 QString toString();
58
59
60private:
61 Package *localPackage;
62
63 QString packageName;
64 QString version;
65 QString status;
66 QString description;
67 QString filename;
68 QString installedTo;
69 bool packageStoredLocally;
70 bool installedToRoot;
71 bool installed;
72 bool differentVersionAvailable;
73};
74
75#endif
diff --git a/noncore/settings/aqpkg/progressdlg.cpp b/noncore/settings/aqpkg/progressdlg.cpp
new file mode 100644
index 0000000..3fa4367
--- a/dev/null
+++ b/noncore/settings/aqpkg/progressdlg.cpp
@@ -0,0 +1,65 @@
1/***************************************************************************
2 progressdlg.h - description
3 -------------------
4 begin : Mon Aug 26 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include "progressdlg.h"
19
20#include <qlabel.h>
21#include <qlayout.h>
22#include <qvariant.h>
23#include <qtooltip.h>
24#include <qwhatsthis.h>
25
26#include "global.h"
27/*
28 * Constructs a ProgressDlg which is a child of 'parent', with the
29 * name 'name' and widget flags set to 'f'
30 *
31 * The dialog will by default be modeless, unless you set 'modal' to
32 * TRUE to construct a modal dialog.
33 */
34ProgressDlg::ProgressDlg( QWidget* parent, const char* name, bool modal, WFlags fl )
35 : QDialog( parent, name, modal, fl )
36{
37 if ( !name )
38 setName( "ProgressDlg" );
39 resize( 240, 73 );
40 setCaption( tr( "Progress" ) );
41
42 TextLabel2 = new QLabel( this, "TextLabel2" );
43 TextLabel2->setGeometry( QRect( 10, 10, 240, 50 ) );
44 TextLabel2->setFrameShape( QLabel::Box );
45 TextLabel2->setText( tr( "Text" ) );
46 TextLabel2->setAlignment( QLabel::WordBreak | QLabel::AlignHCenter | QLabel::AlignVCenter );
47}
48
49/*
50 * Destroys the object and frees any allocated resources
51 */
52ProgressDlg::~ProgressDlg()
53{
54 // no need to delete child widgets, Qt does it all for us
55}
56
57void ProgressDlg :: setText( QString &text )
58{
59 TextLabel2->setText( text );
60}
61
62void ProgressDlg :: setText( const char *text )
63{
64 TextLabel2->setText( text );
65}
diff --git a/noncore/settings/aqpkg/progressdlg.h b/noncore/settings/aqpkg/progressdlg.h
new file mode 100644
index 0000000..3e83455
--- a/dev/null
+++ b/noncore/settings/aqpkg/progressdlg.h
@@ -0,0 +1,37 @@
1/***************************************************************************
2 progressdlg.h - description
3 -------------------
4 begin : Mon Aug 26 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/#ifndef PROGRESSDLG_H
17#define PROGRESSDLG_H
18
19#include <qdialog.h>
20
21class QLabel;
22
23class ProgressDlg : public QDialog
24{
25 Q_OBJECT
26
27public:
28 ProgressDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
29 ~ProgressDlg();
30
31 QLabel* TextLabel2;
32
33 void setText( QString &text );
34 void setText( const char *text );
35};
36
37#endif // PROGRESSDLG_H
diff --git a/noncore/settings/aqpkg/server.cpp b/noncore/settings/aqpkg/server.cpp
new file mode 100644
index 0000000..0069a60
--- a/dev/null
+++ b/noncore/settings/aqpkg/server.cpp
@@ -0,0 +1,266 @@
1/***************************************************************************
2 server.cpp - description
3 -------------------
4 begin : Mon Aug 26 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 description : This class holds details about a server
8 : e.g. all the packages that contained on the server
9 : the installation status
10 ***************************************************************************/
11
12/***************************************************************************
13 * *
14 * This program is free software; you can redistribute it and/or modify *
15 * it under the terms of the GNU General Public License as published by *
16 * the Free Software Foundation; either version 2 of the License, or *
17 * (at your option) any later version. *
18 * *
19 ***************************************************************************/
20
21
22#include <stdio.h>
23#include <string.h>
24#include <stdlib.h>
25
26#include <iostream>
27#include <fstream>
28using namespace std;
29
30#include "server.h"
31
32#ifdef QWS
33#include <qpe/global.h>
34#include <qpe/applnk.h>
35#include <qlist.h>
36#endif
37
38#include "utils.h"
39
40#include "global.h"
41
42Server :: Server( const char *name, const char *url )
43{
44 serverName = name;
45 serverUrl = url;
46 packageFile = IPKG_DIR;
47 packageFile += "lists/" + serverName;
48}
49
50Server :: ~Server()
51{
52 cleanUp();
53}
54
55void Server :: cleanUp()
56{
57 packageList.clear();
58}
59
60void Server :: readStatusFile( vector<Destination> &destList )
61{
62 cleanUp();
63
64 vector<Destination>::iterator dit;
65 bool rootRead = false;
66 for ( dit = destList.begin() ; dit != destList.end() ; ++dit )
67 {
68 bool installingToRoot = false;
69
70 QString path = dit->getDestinationPath();
71 if ( path.right( 1 ) != "/" )
72 path += "/";
73
74 if ( path == "/" )
75 {
76 rootRead = true;
77 installingToRoot = true;
78 }
79
80 packageFile = path + "usr/lib/ipkg/status";
81 readPackageFile( 0, false, installingToRoot );
82 }
83
84 // Ensure that the root status file is read
85 if ( !rootRead )
86 {
87 cout << "Reading status file " << "/usr/lib/ipkg/status" << endl;
88 packageFile = "/usr/lib/ipkg/status";
89 readPackageFile( 0, false, true );
90 }
91}
92
93void Server :: readLocalIpks( Server *local )
94{
95 cleanUp();
96
97#ifdef QWS
98 // First, get any local IPKGs in the documents area
99 // Only applicable to Qtopie/Opie
100
101 DocLnkSet files;
102 Global::findDocuments( &files, "application/ipkg" );
103
104 // Now add the items to the list
105 QListIterator<DocLnk> it( files.children() );
106
107 for ( ; it.current() ; ++it )
108 {
109 // OK, we have a local IPK file, I think the standard naming conventions
110 // for these are packagename_version_arm.ipk
111 QString file = (*it)->file();
112
113 QString packageName = Utils::getPackageNameFromIpkFilename( file );
114 QString ver = Utils::getPackageVersionFromIpkFilename( file );
115 packageList.push_back( Package( packageName ) );
116 packageList.back().setVersion( ver );
117 packageList.back().setFilename( file );
118 packageList.back().setPackageStoredLocally( true );
119
120 }
121#else
122 QString names[] = { "advancedfm_0.9.1-20020811_arm.ipk", "libopie_0.9.1-20020811_arm.ipk", "libopieobex_0.9.1-20020811.1_arm.ipk", "opie-addressbook_0.9.1-20020811_arm.ipk" };
123 for ( int i = 0 ; i < 4 ; ++i )
124 {
125 // OK, we have a local IPK file, I think the standard naming conventions
126 // for these are packagename_version_arm.ipk
127 QString file = names[i];
128 int p = file.find( "_" );
129 QString tmp = file.mid( 0, p );
130 packageList.push_back( Package( tmp ) );
131 int p2 = file.find( "_", p+1 );
132 tmp = file.mid( p+1, p2-(p+1) );
133 packageList.back().setVersion( tmp );
134 packageList.back().setPackageStoredLocally( true );
135 }
136#endif
137
138 // build local packages
139 buildLocalPackages( local );
140}
141
142void Server :: readPackageFile( Server *local, bool clearAll, bool installingToRoot )
143{
144 ifstream in( packageFile );
145 if ( !in.is_open() )
146 return;
147
148 char line[1001];
149 char k[21];
150 char v[1001];
151 QString key;
152 QString value;
153
154 if ( clearAll )
155 cleanUp();
156 Package *currPackage = 0;
157
158 bool newPackage = true;
159 do
160 {
161 in.getline( line, 1000 );
162 if ( in.eof() )
163 continue;
164
165 k[0] = '\0';
166 v[0] = '\0';
167
168 sscanf( line, "%[^:]: %[^\n]", k, v );
169 key = k;
170 value = v;
171 key.stripWhiteSpace();
172 if ( key == "Package" && newPackage )
173 {
174 newPackage = false;
175
176 currPackage = getPackage( value );
177 if ( !currPackage )
178 {
179 packageList.push_back( Package( value ) );
180 currPackage = &(packageList.back());
181
182 if ( installingToRoot )
183 currPackage->setInstalledToRoot( true );
184 }
185 }
186 else if ( key == "Version" )
187 {
188 if ( currPackage )
189 currPackage->setVersion( value );
190 }
191 else if ( key == "Status" )
192 {
193 if ( currPackage )
194 currPackage->setStatus( value );
195 }
196 else if ( key == "Description" )
197 {
198 if ( currPackage )
199 currPackage->setDescription( value );
200 }
201 else if ( key == "Filename" )
202 {
203 if ( currPackage )
204 currPackage->setFilename( value );
205 }
206 else if ( key == "" )
207 {
208 newPackage = true;
209 }
210 } while ( !in.eof() );
211
212 in.close();
213
214 // build local packages
215 buildLocalPackages( local );
216}
217
218void Server :: buildLocalPackages( Server *local )
219{
220 for ( unsigned int i = 0 ; i < packageList.size() ; ++i )
221 {
222 QString name = packageList[i].getPackageName();
223 if ( local )
224 packageList[i].setLocalPackage( local->getPackage( name ) );
225 else
226 packageList[i].setLocalPackage( 0 );
227 }
228
229}
230
231Package *Server :: getPackage( QString &name )
232{
233 return getPackage( (const char *)name );
234}
235
236Package *Server :: getPackage( const char *name )
237{
238 Package *ret = 0;
239
240 for ( unsigned int i = 0 ; i < packageList.size() && ret == 0; ++i )
241 {
242 if ( packageList[i].getPackageName() == name )
243 ret = &packageList[i];
244 }
245
246 return ret;
247}
248
249QString Server :: toString()
250{
251 QString ret = "Server\n name - " + serverName +
252 "\n url - " + serverUrl +
253 "\n";
254
255 for ( unsigned int i = 0 ; i < packageList.size() ; ++i )
256 ret += "\n " + packageList[i].toString();
257
258
259 return ret;
260}
261
262vector<Package> &Server::getPackageList()
263{
264 return packageList;
265}
266
diff --git a/noncore/settings/aqpkg/server.h b/noncore/settings/aqpkg/server.h
new file mode 100644
index 0000000..8f8d384
--- a/dev/null
+++ b/noncore/settings/aqpkg/server.h
@@ -0,0 +1,63 @@
1/***************************************************************************
2 server.h - description
3 -------------------
4 begin : Mon Aug 26 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#ifndef SERVER_H
18#define SERVER_H
19
20#include <qstring.h>
21
22#include <vector>
23using namespace std;
24
25#include "package.h"
26#include "destination.h"
27
28class Server
29{
30public:
31 Server() {}
32 Server( const char *name, const char *url );
33 Server( const char *name, const char *url, const char *file );
34 ~Server();
35
36 void cleanUp();
37
38 void readStatusFile( vector<Destination> &v );
39 void readLocalIpks( Server *local );
40 void readPackageFile( Server *local = 0, bool clearAll = true, bool installedToRoot= false );
41 void buildLocalPackages( Server *local );
42 Package *getPackage( const char *name );
43 Package *getPackage( QString &name );
44 QString toString();
45 vector<Package> &getPackageList();
46
47 void setServerName( const QString &name ) { serverName = name; }
48 void setServerUrl( const QString &url ) { serverUrl = url; }
49 QString &getServerName() { return serverName; }
50 QString &getServerUrl() { return serverUrl; }
51
52protected:
53
54private:
55 QString serverName;
56 QString serverUrl;
57 QString packageFile;
58
59
60 vector<Package> packageList;
61};
62
63#endif
diff --git a/noncore/settings/aqpkg/settings.ui b/noncore/settings/aqpkg/settings.ui
new file mode 100644
index 0000000..eb99cf7
--- a/dev/null
+++ b/noncore/settings/aqpkg/settings.ui
@@ -0,0 +1,531 @@
1<!DOCTYPE UI><UI>
2<class>SettingsBase</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>Settings</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>331</width>
15 <height>456</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Package Servers</string>
21 </property>
22 <property>
23 <name>layoutMargin</name>
24 </property>
25 <property>
26 <name>layoutSpacing</name>
27 </property>
28 <grid>
29 <property stdset="1">
30 <name>margin</name>
31 <number>11</number>
32 </property>
33 <property stdset="1">
34 <name>spacing</name>
35 <number>6</number>
36 </property>
37 <widget row="0" column="0" >
38 <class>QTabWidget</class>
39 <property stdset="1">
40 <name>name</name>
41 <cstring>TabWidget</cstring>
42 </property>
43 <property stdset="1">
44 <name>enabled</name>
45 <bool>true</bool>
46 </property>
47 <property>
48 <name>layoutMargin</name>
49 </property>
50 <property>
51 <name>layoutSpacing</name>
52 </property>
53 <widget>
54 <class>QWidget</class>
55 <property stdset="1">
56 <name>name</name>
57 <cstring>tab</cstring>
58 </property>
59 <attribute>
60 <name>title</name>
61 <string>Servers</string>
62 </attribute>
63 <grid>
64 <property stdset="1">
65 <name>margin</name>
66 <number>11</number>
67 </property>
68 <property stdset="1">
69 <name>spacing</name>
70 <number>6</number>
71 </property>
72 <widget row="0" column="0" rowspan="1" colspan="2" >
73 <class>QLayoutWidget</class>
74 <property stdset="1">
75 <name>name</name>
76 <cstring>Layout2</cstring>
77 </property>
78 <hbox>
79 <property stdset="1">
80 <name>margin</name>
81 <number>0</number>
82 </property>
83 <property stdset="1">
84 <name>spacing</name>
85 <number>6</number>
86 </property>
87 <widget>
88 <class>QLabel</class>
89 <property stdset="1">
90 <name>name</name>
91 <cstring>Servers</cstring>
92 </property>
93 <property stdset="1">
94 <name>text</name>
95 <string>Servers</string>
96 </property>
97 </widget>
98 <spacer>
99 <property>
100 <name>name</name>
101 <cstring>Spacer2</cstring>
102 </property>
103 <property stdset="1">
104 <name>orientation</name>
105 <enum>Horizontal</enum>
106 </property>
107 <property stdset="1">
108 <name>sizeType</name>
109 <enum>Expanding</enum>
110 </property>
111 <property>
112 <name>sizeHint</name>
113 <size>
114 <width>20</width>
115 <height>20</height>
116 </size>
117 </property>
118 </spacer>
119 </hbox>
120 </widget>
121 <widget row="1" column="0" rowspan="1" colspan="2" >
122 <class>QListBox</class>
123 <property stdset="1">
124 <name>name</name>
125 <cstring>servers</cstring>
126 </property>
127 <property stdset="1">
128 <name>selectionMode</name>
129 <enum>Extended</enum>
130 </property>
131 </widget>
132 <widget row="2" column="1" >
133 <class>QPushButton</class>
134 <property stdset="1">
135 <name>name</name>
136 <cstring>removeserver</cstring>
137 </property>
138 <property stdset="1">
139 <name>enabled</name>
140 <bool>true</bool>
141 </property>
142 <property stdset="1">
143 <name>text</name>
144 <string>Remove</string>
145 </property>
146 <property stdset="1">
147 <name>autoDefault</name>
148 <bool>false</bool>
149 </property>
150 </widget>
151 <widget row="2" column="0" >
152 <class>QPushButton</class>
153 <property stdset="1">
154 <name>name</name>
155 <cstring>newserver</cstring>
156 </property>
157 <property stdset="1">
158 <name>enabled</name>
159 <bool>true</bool>
160 </property>
161 <property stdset="1">
162 <name>text</name>
163 <string>New</string>
164 </property>
165 <property stdset="1">
166 <name>autoDefault</name>
167 <bool>false</bool>
168 </property>
169 </widget>
170 <widget row="3" column="0" rowspan="1" colspan="2" >
171 <class>QLayoutWidget</class>
172 <property stdset="1">
173 <name>name</name>
174 <cstring>Layout10</cstring>
175 </property>
176 <grid>
177 <property stdset="1">
178 <name>margin</name>
179 <number>0</number>
180 </property>
181 <property stdset="1">
182 <name>spacing</name>
183 <number>6</number>
184 </property>
185 <widget row="1" column="1" >
186 <class>QLineEdit</class>
187 <property stdset="1">
188 <name>name</name>
189 <cstring>serverurl</cstring>
190 </property>
191 </widget>
192 <widget row="1" column="0" >
193 <class>QLabel</class>
194 <property stdset="1">
195 <name>name</name>
196 <cstring>TextLabel2_3</cstring>
197 </property>
198 <property stdset="1">
199 <name>text</name>
200 <string>URL:</string>
201 </property>
202 </widget>
203 <widget row="0" column="1" >
204 <class>QLineEdit</class>
205 <property stdset="1">
206 <name>name</name>
207 <cstring>servername</cstring>
208 </property>
209 </widget>
210 <widget row="0" column="0" >
211 <class>QLabel</class>
212 <property stdset="1">
213 <name>name</name>
214 <cstring>TextLabel1_3</cstring>
215 </property>
216 <property stdset="1">
217 <name>text</name>
218 <string>Name:</string>
219 </property>
220 </widget>
221 <widget row="2" column="1" >
222 <class>QPushButton</class>
223 <property stdset="1">
224 <name>name</name>
225 <cstring>btnChangeServer</cstring>
226 </property>
227 <property stdset="1">
228 <name>text</name>
229 <string>Change</string>
230 </property>
231 </widget>
232 </grid>
233 </widget>
234 </grid>
235 </widget>
236 <widget>
237 <class>QWidget</class>
238 <property stdset="1">
239 <name>name</name>
240 <cstring>tab</cstring>
241 </property>
242 <attribute>
243 <name>title</name>
244 <string>Destinations</string>
245 </attribute>
246 <grid>
247 <property stdset="1">
248 <name>margin</name>
249 <number>11</number>
250 </property>
251 <property stdset="1">
252 <name>spacing</name>
253 <number>6</number>
254 </property>
255 <widget row="0" column="0" >
256 <class>QLayoutWidget</class>
257 <property stdset="1">
258 <name>name</name>
259 <cstring>Layout3</cstring>
260 </property>
261 <hbox>
262 <property stdset="1">
263 <name>margin</name>
264 <number>0</number>
265 </property>
266 <property stdset="1">
267 <name>spacing</name>
268 <number>6</number>
269 </property>
270 <widget>
271 <class>QLabel</class>
272 <property stdset="1">
273 <name>name</name>
274 <cstring>Destinations</cstring>
275 </property>
276 <property stdset="1">
277 <name>text</name>
278 <string>Destinations</string>
279 </property>
280 </widget>
281 <spacer>
282 <property>
283 <name>name</name>
284 <cstring>Spacer2_2</cstring>
285 </property>
286 <property stdset="1">
287 <name>orientation</name>
288 <enum>Horizontal</enum>
289 </property>
290 <property stdset="1">
291 <name>sizeType</name>
292 <enum>Expanding</enum>
293 </property>
294 <property>
295 <name>sizeHint</name>
296 <size>
297 <width>20</width>
298 <height>20</height>
299 </size>
300 </property>
301 </spacer>
302 </hbox>
303 </widget>
304 <widget row="2" column="0" >
305 <class>QLayoutWidget</class>
306 <property stdset="1">
307 <name>name</name>
308 <cstring>Layout5</cstring>
309 </property>
310 <hbox>
311 <property stdset="1">
312 <name>margin</name>
313 <number>0</number>
314 </property>
315 <property stdset="1">
316 <name>spacing</name>
317 <number>6</number>
318 </property>
319 <widget>
320 <class>QPushButton</class>
321 <property stdset="1">
322 <name>name</name>
323 <cstring>newdestination</cstring>
324 </property>
325 <property stdset="1">
326 <name>enabled</name>
327 <bool>true</bool>
328 </property>
329 <property stdset="1">
330 <name>text</name>
331 <string>New</string>
332 </property>
333 <property stdset="1">
334 <name>autoDefault</name>
335 <bool>false</bool>
336 </property>
337 </widget>
338 <widget>
339 <class>QPushButton</class>
340 <property stdset="1">
341 <name>name</name>
342 <cstring>removedestination</cstring>
343 </property>
344 <property stdset="1">
345 <name>enabled</name>
346 <bool>true</bool>
347 </property>
348 <property stdset="1">
349 <name>text</name>
350 <string>Remove</string>
351 </property>
352 <property stdset="1">
353 <name>autoDefault</name>
354 <bool>false</bool>
355 </property>
356 </widget>
357 </hbox>
358 </widget>
359 <spacer row="0" column="0" >
360 <property>
361 <name>name</name>
362 <cstring>Spacer3</cstring>
363 </property>
364 <property stdset="1">
365 <name>orientation</name>
366 <enum>Horizontal</enum>
367 </property>
368 <property stdset="1">
369 <name>sizeType</name>
370 <enum>Expanding</enum>
371 </property>
372 <property>
373 <name>sizeHint</name>
374 <size>
375 <width>20</width>
376 <height>20</height>
377 </size>
378 </property>
379 </spacer>
380 <widget row="1" column="0" >
381 <class>QListBox</class>
382 <property stdset="1">
383 <name>name</name>
384 <cstring>destinations</cstring>
385 </property>
386 <property stdset="1">
387 <name>selectionMode</name>
388 <enum>Single</enum>
389 </property>
390 </widget>
391 <widget row="3" column="0" >
392 <class>QLayoutWidget</class>
393 <property stdset="1">
394 <name>name</name>
395 <cstring>Layout8</cstring>
396 </property>
397 <grid>
398 <property stdset="1">
399 <name>margin</name>
400 <number>0</number>
401 </property>
402 <property stdset="1">
403 <name>spacing</name>
404 <number>6</number>
405 </property>
406 <widget row="0" column="1" >
407 <class>QLineEdit</class>
408 <property stdset="1">
409 <name>name</name>
410 <cstring>destinationname</cstring>
411 </property>
412 </widget>
413 <widget row="1" column="1" >
414 <class>QLineEdit</class>
415 <property stdset="1">
416 <name>name</name>
417 <cstring>destinationurl</cstring>
418 </property>
419 </widget>
420 <widget row="2" column="1" >
421 <class>QPushButton</class>
422 <property stdset="1">
423 <name>name</name>
424 <cstring>btnChangeDest</cstring>
425 </property>
426 <property stdset="1">
427 <name>text</name>
428 <string>Change</string>
429 </property>
430 </widget>
431 <widget row="0" column="0" >
432 <class>QLabel</class>
433 <property stdset="1">
434 <name>name</name>
435 <cstring>TextLabel1_3_2</cstring>
436 </property>
437 <property stdset="1">
438 <name>text</name>
439 <string>Name:</string>
440 </property>
441 </widget>
442 <widget row="1" column="0" >
443 <class>QLabel</class>
444 <property stdset="1">
445 <name>name</name>
446 <cstring>TextLabel1_3_2_2</cstring>
447 </property>
448 <property stdset="1">
449 <name>text</name>
450 <string>URL:</string>
451 </property>
452 </widget>
453 </grid>
454 </widget>
455 </grid>
456 </widget>
457 </widget>
458 </grid>
459</widget>
460<connections>
461 <connection>
462 <sender>newserver</sender>
463 <signal>clicked()</signal>
464 <receiver>Settings</receiver>
465 <slot>newServer()</slot>
466 </connection>
467 <connection>
468 <sender>removeserver</sender>
469 <signal>clicked()</signal>
470 <receiver>Settings</receiver>
471 <slot>removeServer()</slot>
472 </connection>
473 <connection>
474 <sender>newdestination</sender>
475 <signal>clicked()</signal>
476 <receiver>Settings</receiver>
477 <slot>newDestination()</slot>
478 </connection>
479 <connection>
480 <sender>removedestination</sender>
481 <signal>clicked()</signal>
482 <receiver>Settings</receiver>
483 <slot>removeDestination()</slot>
484 </connection>
485 <connection>
486 <sender>servers</sender>
487 <signal>highlighted(int)</signal>
488 <receiver>Settings</receiver>
489 <slot>editServer(int)</slot>
490 </connection>
491 <connection>
492 <sender>destinations</sender>
493 <signal>highlighted(int)</signal>
494 <receiver>Settings</receiver>
495 <slot>editDestination(int)</slot>
496 </connection>
497 <connection>
498 <sender>btnChangeServer</sender>
499 <signal>clicked()</signal>
500 <receiver>Settings</receiver>
501 <slot>changeServerDetails()</slot>
502 </connection>
503 <connection>
504 <sender>btnChangeDest</sender>
505 <signal>clicked()</signal>
506 <receiver>Settings</receiver>
507 <slot>changeDestinationDetails()</slot>
508 </connection>
509 <slot access="public">activeServerChanged()</slot>
510 <slot access="public">changeServerDetails()</slot>
511 <slot access="public">createLinksToDest()</slot>
512 <slot access="public">destNameChanged(const QString&amp;)</slot>
513 <slot access="public">destUrlChanged(const QString&amp;)</slot>
514 <slot access="public">editDestination(int)</slot>
515 <slot access="public">editServer(int)</slot>
516 <slot access="public">installationSettingChange(int)</slot>
517 <slot access="public">installationSettingSetName(const QString &amp;)</slot>
518 <slot access="public">linkEnabled(bool)</slot>
519 <slot access="public">newDestination()</slot>
520 <slot access="public">newInstallationSetting()</slot>
521 <slot access="public">newServer()</slot>
522 <slot access="public">changeDestinationDetails()</slot>
523 <slot access="public">removeDestination()</slot>
524 <slot access="public">removeInstallationSetting()</slot>
525 <slot access="public">removeLinksToDest()</slot>
526 <slot access="public">removeServer()</slot>
527 <slot access="public">renameInstallationSetting()</slot>
528 <slot access="public">serverNameChanged(const QString&amp;)</slot>
529 <slot access="public">serverUrlChanged(const QString&amp;)</slot>
530</connections>
531</UI>
diff --git a/noncore/settings/aqpkg/settingsimpl.cpp b/noncore/settings/aqpkg/settingsimpl.cpp
new file mode 100644
index 0000000..81e89ed
--- a/dev/null
+++ b/noncore/settings/aqpkg/settingsimpl.cpp
@@ -0,0 +1,195 @@
1/***************************************************************************
2 settingsimpl.cpp - description
3 -------------------
4 begin : Thu Aug 29 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include <fstream>
19using namespace std;
20
21#include <qlistbox.h>
22#include <qlineedit.h>
23#include <qpushbutton.h>
24#include <qtabwidget.h>
25
26#include "settingsimpl.h"
27
28#include "global.h"
29
30SettingsImpl :: SettingsImpl( DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl )
31 : SettingsBase( parent, name, modal, fl )
32{
33 dataMgr = dataManager;
34
35 setupData();
36 changed = false;
37 newserver = false;
38 newdestination = false;
39}
40
41SettingsImpl :: ~SettingsImpl()
42{
43
44}
45
46bool SettingsImpl :: showDlg( int i )
47{
48 TabWidget->setCurrentPage( i );
49 showMaximized();
50 exec();
51
52 if ( changed )
53 dataMgr->writeOutIpkgConf();
54
55 return changed;
56}
57
58void SettingsImpl :: setupData()
59{
60 // add servers
61 vector<Server>::iterator it;
62 for ( it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it )
63 {
64 if ( it->getServerName() == LOCAL_SERVER || it->getServerName() == LOCAL_IPKGS )
65 continue;
66
67 servers->insertItem( it->getServerName() );
68 }
69
70 // add destinations
71 vector<Destination>::iterator it2;
72 for ( it2 = dataMgr->getDestinationList().begin() ; it2 != dataMgr->getDestinationList().end() ; ++it2 )
73 destinations->insertItem( it2->getDestinationName() );
74
75}
76
77//------------------ Servers tab ----------------------
78
79void SettingsImpl :: editServer( int sel )
80{
81 currentSelectedServer = sel;
82 Server *s = dataMgr->getServer( servers->currentText() );
83 serverName = s->getServerName();
84 servername->setText( s->getServerName() );
85 serverurl->setText( s->getServerUrl() );
86}
87
88void SettingsImpl :: newServer()
89{
90 newserver = true;
91 servername->setText( "" );
92 serverurl->setText( "" );
93 servername->setFocus();
94}
95
96void SettingsImpl :: removeServer()
97{
98 changed = true;
99 Server *s = dataMgr->getServer( servers->currentText() );
100 dataMgr->getServerList().erase( s );
101 servers->removeItem( currentSelectedServer );
102}
103
104void SettingsImpl :: changeServerDetails()
105{
106 changed = true;
107
108 QString newName = servername->text();
109 if ( !newserver )
110 {
111 Server *s = dataMgr->getServer( serverName );
112
113 // Update url
114 s->setServerUrl( serverurl->text() );
115
116 // Check if server name has changed, if it has then we need to replace the key in the map
117 if ( serverName != newName )
118 {
119 // Update server name
120 s->setServerName( newName );
121
122 // See if this server is the active server
123 if ( dataMgr->getActiveServer() == serverName )
124 dataMgr->setActiveServer( newName );
125
126 // Update list box
127 servers->changeItem( newName, currentSelectedServer );
128 }
129 }
130 else
131 {
132 dataMgr->getServerList().push_back( Server( newName, serverurl->text() ) );
133 servers->insertItem( newName );
134 servers->setCurrentItem( servers->count() );
135 newserver = false;
136 }
137}
138
139//------------------ Destinations tab ----------------------
140
141void SettingsImpl :: editDestination( int sel )
142{
143 currentSelectedDestination = sel;
144 Destination *s = dataMgr->getDestination( destinations->currentText() );
145 destinationName = s->getDestinationName();
146 destinationname->setText( s->getDestinationName() );
147 destinationurl->setText( s->getDestinationPath() );
148}
149
150void SettingsImpl :: newDestination()
151{
152 newdestination = true;
153 destinationname->setText( "" );
154 destinationurl->setText( "" );
155 destinationname->setFocus();
156}
157
158void SettingsImpl :: removeDestination()
159{
160 changed = true;
161 Destination *d = dataMgr->getDestination( destinations->currentText() );
162 dataMgr->getDestinationList().erase( d );
163 destinations->removeItem( currentSelectedDestination );
164}
165
166void SettingsImpl :: changeDestinationDetails()
167{
168 changed = true;
169
170 QString newName = destinationname->text();
171 if ( !newdestination )
172 {
173 Destination *d = dataMgr->getDestination( destinationName );
174
175 // Update url
176 d->setDestinationPath( destinationurl->text() );
177
178 // Check if server name has changed, if it has then we need to replace the key in the map
179 if ( destinationName != newName )
180 {
181 // Update server name
182 d->setDestinationName( newName );
183
184 // Update list box
185 destinations->changeItem( newName, currentSelectedDestination );
186 }
187 }
188 else
189 {
190 dataMgr->getDestinationList().push_back( Destination( newName, destinationurl->text() ) );
191 destinations->insertItem( newName );
192 destinations->setCurrentItem( destinations->count() );
193 newdestination = false;
194 }
195}
diff --git a/noncore/settings/aqpkg/settingsimpl.h b/noncore/settings/aqpkg/settingsimpl.h
new file mode 100644
index 0000000..bc231a1
--- a/dev/null
+++ b/noncore/settings/aqpkg/settingsimpl.h
@@ -0,0 +1,52 @@
1/***************************************************************************
2 settingsimpl.h - description
3 -------------------
4 begin : Thu Aug 29 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include "settings.h"
19
20#include "datamgr.h"
21
22class SettingsImpl : public SettingsBase
23{
24public:
25 SettingsImpl( DataManager *dataManager, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
26 ~SettingsImpl();
27
28 bool showDlg( int i );
29
30private:
31 DataManager *dataMgr;
32 QString serverName;
33 QString destinationName;
34 int currentSelectedServer;
35 int currentSelectedDestination;
36 bool changed;
37 bool newserver;
38 bool newdestination;
39
40 void setupConnections();
41 void setupData();
42
43 void editServer( int s );
44 void changeServerDetails();
45 void newServer();
46 void removeServer();
47
48 void editDestination( int s );
49 void changeDestinationDetails();
50 void newDestination();
51 void removeDestination();
52};
diff --git a/noncore/settings/aqpkg/utils.cpp b/noncore/settings/aqpkg/utils.cpp
new file mode 100644
index 0000000..77d82d4
--- a/dev/null
+++ b/noncore/settings/aqpkg/utils.cpp
@@ -0,0 +1,74 @@
1/***************************************************************************
2 utils.cpp - description
3 -------------------
4 begin : Sat Sep 7 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include "utils.h"
19#include "global.h"
20
21Utils :: Utils()
22{
23}
24
25Utils :: ~Utils()
26{
27}
28
29
30QString Utils :: getPathfromIpkFilename( const QString &file )
31{
32 int p = file.findRev( "/" );
33 QString path = "";
34 if ( p != -1 )
35 path = file.left( p );
36
37 return path;
38
39}
40
41QString Utils :: getFilenameFromIpkFilename( const QString &file )
42{
43 int p = file.findRev( "/" );
44 QString name = file;
45 if ( p != -1 )
46 name = name.mid( p + 1 );
47
48
49 return name;
50}
51
52QString Utils :: getPackageNameFromIpkFilename( const QString &file )
53{
54 int p = file.findRev( "/" );
55 QString name = file;
56 if ( p != -1 )
57 name = name.mid( p + 1 );
58 p = name.find( "_" );
59 QString packageName = name.mid( 0, p );
60 return packageName;
61}
62
63QString Utils :: getPackageVersionFromIpkFilename( const QString &file )
64{
65 int p = file.findRev( "/" );
66 QString name = file;
67 if ( p != -1 )
68 name = name.mid( p + 1 );
69 p = name.find( "_" ) + 1;
70 int p2 = name.find( "_", p );
71 QString version = name.mid( p, p2 - p );
72 return version;
73}
74
diff --git a/noncore/settings/aqpkg/utils.h b/noncore/settings/aqpkg/utils.h
new file mode 100644
index 0000000..15ee4e6
--- a/dev/null
+++ b/noncore/settings/aqpkg/utils.h
@@ -0,0 +1,38 @@
1/***************************************************************************
2 utils.h - description
3 -------------------
4 begin : Sat Sep 7 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef UTILS_H
19#define UTILS_H
20
21#include <qstring.h>
22
23/**
24 *@author Andy Qua
25 */
26
27class Utils {
28public:
29 Utils();
30 ~Utils();
31
32 static QString getPathfromIpkFilename( const QString &file );
33 static QString getFilenameFromIpkFilename( const QString &file );
34 static QString getPackageNameFromIpkFilename( const QString &file );
35 static QString getPackageVersionFromIpkFilename( const QString &file );
36};
37
38#endif