summaryrefslogtreecommitdiff
authorandyq <andyq>2002-11-17 20:03:25 (UTC)
committer andyq <andyq>2002-11-17 20:03:25 (UTC)
commitd94c9d39ab6e744f848a04c07eac03f20c91987c (patch) (unidiff)
treea9f32cca7c59ae565ab9caa3caf567100ed07cb4
parenta94877f543bf0ebc2ec9c4c931cb5f21713b7872 (diff)
downloadopie-d94c9d39ab6e744f848a04c07eac03f20c91987c.zip
opie-d94c9d39ab6e744f848a04c07eac03f20c91987c.tar.gz
opie-d94c9d39ab6e744f848a04c07eac03f20c91987c.tar.bz2
Added filter by category, and added extra fields to package display (Section and size)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/aqpkg.pro9
-rw-r--r--noncore/settings/aqpkg/categoryfilter.ui118
-rw-r--r--noncore/settings/aqpkg/categoryfilterimpl.cpp71
-rw-r--r--noncore/settings/aqpkg/categoryfilterimpl.h40
-rw-r--r--noncore/settings/aqpkg/datamgr.cpp12
-rw-r--r--noncore/settings/aqpkg/datamgr.h5
-rw-r--r--noncore/settings/aqpkg/global.h160
-rw-r--r--noncore/settings/aqpkg/mainwin.cpp395
-rw-r--r--noncore/settings/aqpkg/mainwin.h131
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp63
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.h4
-rw-r--r--noncore/settings/aqpkg/package.h8
-rw-r--r--noncore/settings/aqpkg/server.cpp21
-rw-r--r--noncore/settings/aqpkg/server.h1
14 files changed, 696 insertions, 342 deletions
diff --git a/noncore/settings/aqpkg/aqpkg.pro b/noncore/settings/aqpkg/aqpkg.pro
index 301f4f2..6cc5a23 100644
--- a/noncore/settings/aqpkg/aqpkg.pro
+++ b/noncore/settings/aqpkg/aqpkg.pro
@@ -1,44 +1,47 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on debug 2 CONFIG = qt warn_on debug
3 HEADERS = global.h \ 3 HEADERS = global.h \
4 mainwin.h \ 4 mainwin.h \
5 datamgr.h \ 5 datamgr.h \
6 settingsimpl.h \ 6 settingsimpl.h \
7 ipkg.h \ 7 ipkg.h \
8 networkpkgmgr.h \ 8 networkpkgmgr.h \
9 package.h \ 9 package.h \
10 progressdlg.h \ 10 progressdlg.h \
11 installdlgimpl.h \ 11 installdlgimpl.h \
12 instoptionsimpl.h \ 12 instoptionsimpl.h \
13 destination.h \ 13 destination.h \
14 utils.h \ 14 utils.h \
15 server.h \ 15 server.h \
16 helpwindow.h \ 16 helpwindow.h \
17 letterpushbutton.h \ 17 letterpushbutton.h \
18 inputdlg.h 18 inputdlg.h \
19 categoryfilterimpl.h
19 SOURCES = mainwin.cpp \ 20 SOURCES = mainwin.cpp \
20 datamgr.cpp \ 21 datamgr.cpp \
21 mem.cpp \ 22 mem.cpp \
22 settingsimpl.cpp \ 23 settingsimpl.cpp \
23 ipkg.cpp \ 24 ipkg.cpp \
24 networkpkgmgr.cpp \ 25 networkpkgmgr.cpp \
25 main.cpp \ 26 main.cpp \
26 package.cpp \ 27 package.cpp \
27 progressdlg.cpp \ 28 progressdlg.cpp \
28 installdlgimpl.cpp \ 29 installdlgimpl.cpp \
29 instoptionsimpl.cpp \ 30 instoptionsimpl.cpp \
30 destination.cpp \ 31 destination.cpp \
31 utils.cpp \ 32 utils.cpp \
32 server.cpp \ 33 server.cpp \
33 helpwindow.cpp \ 34 helpwindow.cpp \
34 letterpushbutton.cpp \ 35 letterpushbutton.cpp \
35 inputdlg.cpp \ 36 inputdlg.cpp \
36 version.cpp 37 version.cpp \
38 categoryfilterimpl.cpp
37 INTERFACES= settings.ui \ 39 INTERFACES= settings.ui \
38 install.ui \ 40 install.ui \
39 instoptions.ui 41 instoptions.ui \
42 categoryfilter.ui
40 TARGET = aqpkg 43 TARGET = aqpkg
41INCLUDEPATH += $(OPIEDIR)/include 44INCLUDEPATH += $(OPIEDIR)/include
42DEPENDPATH += $(OPIEDIR)/include 45DEPENDPATH += $(OPIEDIR)/include
43LIBS += -lqpe -lstdc++ 46LIBS += -lqpe -lstdc++
44DESTDIR = $(OPIEDIR)/bin 47DESTDIR = $(OPIEDIR)/bin
diff --git a/noncore/settings/aqpkg/categoryfilter.ui b/noncore/settings/aqpkg/categoryfilter.ui
new file mode 100644
index 0000000..3416243
--- a/dev/null
+++ b/noncore/settings/aqpkg/categoryfilter.ui
@@ -0,0 +1,118 @@
1<!DOCTYPE UI><UI>
2<class>CategoryFilterDlg</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>CategoryFilterDlg</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>215</width>
15 <height>295</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Category Filter</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="1" column="0" >
32 <class>QLayoutWidget</class>
33 <property stdset="1">
34 <name>name</name>
35 <cstring>Layout4</cstring>
36 </property>
37 <grid>
38 <property stdset="1">
39 <name>margin</name>
40 <number>0</number>
41 </property>
42 <property stdset="1">
43 <name>spacing</name>
44 <number>6</number>
45 </property>
46 <widget row="0" column="1" >
47 <class>QPushButton</class>
48 <property stdset="1">
49 <name>name</name>
50 <cstring>btnOK</cstring>
51 </property>
52 <property stdset="1">
53 <name>text</name>
54 <string>&amp;OK</string>
55 </property>
56 </widget>
57 <widget row="0" column="0" >
58 <class>QPushButton</class>
59 <property stdset="1">
60 <name>name</name>
61 <cstring>btnCancel</cstring>
62 </property>
63 <property stdset="1">
64 <name>text</name>
65 <string>&amp;Cancel</string>
66 </property>
67 </widget>
68 </grid>
69 </widget>
70 <widget row="0" column="0" >
71 <class>QGroupBox</class>
72 <property stdset="1">
73 <name>name</name>
74 <cstring>GroupBox1</cstring>
75 </property>
76 <property stdset="1">
77 <name>title</name>
78 <string>Select groups to show</string>
79 </property>
80 <grid>
81 <property stdset="1">
82 <name>margin</name>
83 <number>11</number>
84 </property>
85 <property stdset="1">
86 <name>spacing</name>
87 <number>6</number>
88 </property>
89 <widget row="0" column="0" >
90 <class>QListBox</class>
91 <property stdset="1">
92 <name>name</name>
93 <cstring>lstCategories</cstring>
94 </property>
95 <property stdset="1">
96 <name>selectionMode</name>
97 <enum>Multi</enum>
98 </property>
99 </widget>
100 </grid>
101 </widget>
102 </grid>
103</widget>
104<connections>
105 <connection>
106 <sender>btnCancel</sender>
107 <signal>clicked()</signal>
108 <receiver>CategoryFilterDlg</receiver>
109 <slot>reject()</slot>
110 </connection>
111 <connection>
112 <sender>btnOK</sender>
113 <signal>clicked()</signal>
114 <receiver>CategoryFilterDlg</receiver>
115 <slot>accept()</slot>
116 </connection>
117</connections>
118</UI>
diff --git a/noncore/settings/aqpkg/categoryfilterimpl.cpp b/noncore/settings/aqpkg/categoryfilterimpl.cpp
new file mode 100644
index 0000000..0746da6
--- a/dev/null
+++ b/noncore/settings/aqpkg/categoryfilterimpl.cpp
@@ -0,0 +1,71 @@
1/***************************************************************************
2 categoryfilterimpl.cpp - description
3 -------------------
4 begin : Sun Nov 17 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 <iostream>
18using namespace std;
19
20#include <qlistbox.h>
21#include <qstring.h>
22
23#include "categoryfilterimpl.h"
24
25CategoryFilterImpl :: CategoryFilterImpl(const QString &categories, const QString &selectedCategories, QWidget *parent, const char *name )
26 : CategoryFilterDlg(parent,name, true)
27{
28 // Split up categories and add them to the listbox
29 int start = 1;
30
31 QString item;
32 int end;
33 do
34 {
35 end = categories.find( "#", start );
36 item = categories.mid( start, end - start );
37 if ( item != "" )
38 {
39 lstCategories->insertItem( item );
40
41 if ( selectedCategories.find( "#" + item + "#" ) != -1 )
42 lstCategories->setSelected( lstCategories->count()-1, true );
43 }
44
45 start = end + 1;
46 } while ( start < (int)categories.length() );
47
48 lstCategories->sort( true );
49
50 showMaximized();
51}
52
53CategoryFilterImpl :: ~CategoryFilterImpl()
54{
55}
56
57QString CategoryFilterImpl :: getSelectedFilter()
58{
59 // Grab cetegories from listbox
60 QString ret = "#";
61
62 for ( int i = 0 ; i < (int)lstCategories->count() ; ++i )
63 {
64 if ( lstCategories->isSelected( i ) )
65 ret += lstCategories->text( i ) + "#";
66 }
67
68 if ( ret == "#" )
69 ret = "";
70 return ret;
71}
diff --git a/noncore/settings/aqpkg/categoryfilterimpl.h b/noncore/settings/aqpkg/categoryfilterimpl.h
new file mode 100644
index 0000000..b6b4fd5
--- a/dev/null
+++ b/noncore/settings/aqpkg/categoryfilterimpl.h
@@ -0,0 +1,40 @@
1/***************************************************************************
2 categoryfilterimpl.h - description
3 -------------------
4 begin : Sun Nov 17 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 CATEGORYFILTERIMPL_H
19#define CATEGORYFILTERIMPL_H
20
21#include <qwidget.h>
22#include <qstring.h>
23
24#include "categoryfilter.h"
25
26/**
27 *@author Andy Qua
28 */
29
30class CategoryFilterImpl : public CategoryFilterDlg
31{
32 Q_OBJECT
33public:
34 CategoryFilterImpl(const QString &categories, const QString &selectedCategories, QWidget *parent=0, const char *name=0);
35 ~CategoryFilterImpl();
36
37 QString getSelectedFilter();
38};
39
40#endif
diff --git a/noncore/settings/aqpkg/datamgr.cpp b/noncore/settings/aqpkg/datamgr.cpp
index f342aff..1420242 100644
--- a/noncore/settings/aqpkg/datamgr.cpp
+++ b/noncore/settings/aqpkg/datamgr.cpp
@@ -7,51 +7,53 @@
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 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 * 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 * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17#include <fstream> 17#include <fstream>
18#include <iostream> 18#include <iostream>
19using namespace std; 19using namespace std;
20 20
21#ifdef QWS 21#ifdef QWS
22#include <qpe/config.h> 22#include <qpe/config.h>
23#endif 23#endif
24 24
25#include <stdio.h> 25#include <stdio.h>
26 26
27#include "datamgr.h" 27#include "datamgr.h"
28#include "global.h" 28#include "global.h"
29 29
30 30
31QString DataManager::availableCategories = "";
31DataManager::DataManager() 32DataManager::DataManager()
32{ 33{
33 activeServer = ""; 34 activeServer = "";
35 availableCategories = "#";
34} 36}
35 37
36DataManager::~DataManager() 38DataManager::~DataManager()
37{ 39{
38} 40}
39 41
40Server *DataManager :: getServer( const char *name ) 42Server *DataManager :: getServer( const char *name )
41{ 43{
42 Server *s = 0; 44 Server *s = 0;
43 vector<Server>::iterator it = serverList.begin(); 45 vector<Server>::iterator it = serverList.begin();
44 while ( it != serverList.end() && s == 0 ) 46 while ( it != serverList.end() && s == 0 )
45 { 47 {
46 if ( it->getServerName() == name ) 48 if ( it->getServerName() == name )
47 s = &(*it); 49 s = &(*it);
48 50
49 ++it; 51 ++it;
50 } 52 }
51 53
52 return s; 54 return s;
53} 55}
54 56
55Destination *DataManager :: getDestination( const char *name ) 57Destination *DataManager :: getDestination( const char *name )
56{ 58{
57 Destination *d = 0; 59 Destination *d = 0;
@@ -186,24 +188,32 @@ void DataManager :: writeOutIpkgConf()
186 if ( alias != LOCAL_SERVER && alias != LOCAL_IPKGS ) 188 if ( alias != LOCAL_SERVER && alias != LOCAL_IPKGS )
187 { 189 {
188 QString url = it->getServerUrl();; 190 QString url = it->getServerUrl();;
189 191
190 if ( !it->isServerActive() ) 192 if ( !it->isServerActive() )
191 out << "#"; 193 out << "#";
192 out << "src " << alias << " " << url << endl; 194 out << "src " << alias << " " << url << endl;
193 } 195 }
194 196
195 it++; 197 it++;
196 } 198 }
197 199
198 out << endl; 200 out << endl;
199 201
200 // Write out destinations 202 // Write out destinations
201 vector<Destination>::iterator it2 = destList.begin(); 203 vector<Destination>::iterator it2 = destList.begin();
202 while ( it2 != destList.end() ) 204 while ( it2 != destList.end() )
203 { 205 {
204 out << "dest " << it2->getDestinationName() << " " << it2->getDestinationPath() << endl; 206 out << "dest " << it2->getDestinationName() << " " << it2->getDestinationPath() << endl;
205 it2++; 207 it2++;
206 } 208 }
207 209
208 out.close(); 210 out.close();
209} 211}
212
213
214void DataManager :: setAvailableCategories( QString section )
215{
216 section = section.lower();
217 if ( availableCategories.find( "#" + section + "#" ) == -1 )
218 availableCategories += section + "#";
219}
diff --git a/noncore/settings/aqpkg/datamgr.h b/noncore/settings/aqpkg/datamgr.h
index 8c6fb0d..3a64d92 100644
--- a/noncore/settings/aqpkg/datamgr.h
+++ b/noncore/settings/aqpkg/datamgr.h
@@ -1,64 +1,69 @@
1/*************************************************************************** 1/***************************************************************************
2 datamgr.h - description 2 datamgr.h - description
3 ------------------- 3 -------------------
4 begin : Thu Aug 29 2002 4 begin : Thu Aug 29 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 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 * 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 * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#ifndef DATAMGR_H 18#ifndef DATAMGR_H
19#define DATAMGR_H 19#define DATAMGR_H
20 20
21#include <map> 21#include <map>
22using namespace std; 22using namespace std;
23 23
24#include <qstring.h>
25
24#include "server.h" 26#include "server.h"
25#include "destination.h" 27#include "destination.h"
26 28
27 #define LOCAL_SERVER "Installed Pkgs" 29 #define LOCAL_SERVER "Installed Pkgs"
28 #define LOCAL_IPKGS "local IPKG" 30 #define LOCAL_IPKGS "local IPKG"
29 31
30/** 32/**
31 *@author Andy Qua 33 *@author Andy Qua
32 */ 34 */
33 35
34 36
35class DataManager 37class DataManager
36{ 38{
37public: 39public:
38 DataManager(); 40 DataManager();
39 ~DataManager(); 41 ~DataManager();
40 42
41 void setActiveServer( const QString &act ) { activeServer = act; } 43 void setActiveServer( const QString &act ) { activeServer = act; }
42 QString &getActiveServer( ) { return activeServer; } 44 QString &getActiveServer( ) { return activeServer; }
43 45
44 Server *getLocalServer() { return getServer( LOCAL_SERVER ); } 46 Server *getLocalServer() { return getServer( LOCAL_SERVER ); }
45 vector<Server> &getServerList() { return serverList; } 47 vector<Server> &getServerList() { return serverList; }
46 Server *getServer( const char *name ); 48 Server *getServer( const char *name );
47 49
48 vector<Destination> &getDestinationList() { return destList; } 50 vector<Destination> &getDestinationList() { return destList; }
49 Destination *getDestination( const char *name ); 51 Destination *getDestination( const char *name );
50 52
51 void loadServers(); 53 void loadServers();
52 void reloadServerData( ); 54 void reloadServerData( );
53 55
54 void writeOutIpkgConf(); 56 void writeOutIpkgConf();
55 57
58 static QString getAvailableCategories() { return availableCategories; }
59 static void setAvailableCategories( QString section );
56 60
57private: 61private:
62 static QString availableCategories;
58 QString activeServer; 63 QString activeServer;
59 64
60 vector<Server> serverList; 65 vector<Server> serverList;
61 vector<Destination> destList; 66 vector<Destination> destList;
62}; 67};
63 68
64#endif 69#endif
diff --git a/noncore/settings/aqpkg/global.h b/noncore/settings/aqpkg/global.h
index e65e2a0..609e1e8 100644
--- a/noncore/settings/aqpkg/global.h
+++ b/noncore/settings/aqpkg/global.h
@@ -1,80 +1,80 @@
1/*************************************************************************** 1/***************************************************************************
2 global.h - description 2 global.h - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 2002 4 begin : Mon Aug 26 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 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 * 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 * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#ifndef __GLOBAL_H 18#ifndef __GLOBAL_H
19#define __GLOBAL_H 19#define __GLOBAL_H
20 20
21#define VERSION_TEXT "AQPkg Version 1.0" 21#define VERSION_TEXT "AQPkg Version 1.1"
22 22
23// Uncomment the below line to run on a Linux box rather than a Zaurus 23// Uncomment the below line to run on a Linux box rather than a Zaurus
24// box this allows you to change where root is, and where to load config files from 24// box this allows you to change where root is, and where to load config files from
25// #define X86 25// #define X86
26 26
27// Sets up location of ipkg.conf and root directory 27// Sets up location of ipkg.conf and root directory
28#ifdef QWS 28#ifdef QWS
29 29
30#ifndef X86 30#ifndef X86
31 31
32// Running QT/Embedded on an arm processor 32// Running QT/Embedded on an arm processor
33#define IPKG_CONF "/etc/ipkg.conf" 33#define IPKG_CONF "/etc/ipkg.conf"
34#define ROOT "/" 34#define ROOT "/"
35#define IPKG_DIR "/usr/lib/ipkg/" 35#define IPKG_DIR "/usr/lib/ipkg/"
36 36
37#else 37#else
38 38
39// Running QT/Embedded on a X86 linux box 39// Running QT/Embedded on a X86 linux box
40#define IPKG_CONF "/home/andy/projects/aqpkg/aqpkg/data/ipkg.conf" 40#define IPKG_CONF "/home/andy/projects/aqpkg/aqpkg/data/ipkg.conf"
41#define ROOT "/home/andy/projects/aqpkg/aqpkg/data/root" 41#define ROOT "/home/andy/projects/aqpkg/aqpkg/data/root"
42#define IPKG_DIR "/home/andy/projects/aqpkg/aqpkg/data/" 42#define IPKG_DIR "/home/andy/projects/aqpkg/aqpkg/data/"
43 43
44#endif 44#endif
45 45
46#else 46#else
47 47
48// Running QT on a X86 linux box 48// Running QT on a X86 linux box
49#define IPKG_CONF "/home/andy/projects/aqpkg/aqpkg/data/ipkg.conf" 49#define IPKG_CONF "/home/andy/projects/aqpkg/aqpkg/data/ipkg.conf"
50#define ROOT "/home/andy/projects/aqpkg/aqpkg/data/root" 50#define ROOT "/home/andy/projects/aqpkg/aqpkg/data/root"
51#define IPKG_DIR "/home/andy/projects/aqpkg/aqpkg/data/" 51#define IPKG_DIR "/home/andy/projects/aqpkg/aqpkg/data/"
52 52
53#endif 53#endif
54 54
55 55
56// Uncomment the below line to turn on memory checking 56// Uncomment the below line to turn on memory checking
57//#define _DEBUG 1 57//#define _DEBUG 1
58 58
59#ifndef __MEMFILE_C 59#ifndef __MEMFILE_C
60#ifdef _DEBUG 60#ifdef _DEBUG
61void * operator new(unsigned int size,const char *file, int line); 61void * operator new(unsigned int size,const char *file, int line);
62void operator delete(void *p); 62void operator delete(void *p);
63#endif 63#endif
64 64
65#ifdef _DEBUG 65#ifdef _DEBUG
66#define DEBUG_NEW new(__FILE__, __LINE__) 66#define DEBUG_NEW new(__FILE__, __LINE__)
67//#define DEBUG_NEW new 67//#define DEBUG_NEW new
68#else 68#else
69#define DEBUG_NEW new 69#define DEBUG_NEW new
70#endif 70#endif
71 71
72#define new DEBUG_NEW 72#define new DEBUG_NEW
73#endif 73#endif
74 74
75 75
76void AddTrack(long addr, long asize, const char *fname, long lnum); 76void AddTrack(long addr, long asize, const char *fname, long lnum);
77void RemoveTrack(long addr); 77void RemoveTrack(long addr);
78void DumpUnfreed(); 78void DumpUnfreed();
79 79
80#endif 80#endif
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp
index 5ccd3c3..0141359 100644
--- a/noncore/settings/aqpkg/mainwin.cpp
+++ b/noncore/settings/aqpkg/mainwin.cpp
@@ -1,186 +1,209 @@
1/*************************************************************************** 1/***************************************************************************
2 mainwin.cpp - description 2 mainwin.cpp - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 13:32:30 BST 2002 4 begin : Mon Aug 26 13:32:30 BST 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 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 * 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 * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include <iostream> 18#include <iostream>
19 19
20#include <qmenubar.h> 20#include <qmenubar.h>
21#include <qpopupmenu.h> 21#include <qpopupmenu.h>
22#include <qmessagebox.h> 22#include <qmessagebox.h>
23 23
24#include "mainwin.h" 24#include "mainwin.h"
25#include "datamgr.h" 25#include "datamgr.h"
26#include "networkpkgmgr.h" 26#include "networkpkgmgr.h"
27#include "settingsimpl.h" 27#include "settingsimpl.h"
28#include "helpwindow.h" 28#include "helpwindow.h"
29#include "utils.h" 29#include "utils.h"
30#include "global.h" 30#include "global.h"
31 31
32MainWindow :: MainWindow( QWidget *p, char *name ) 32MainWindow :: MainWindow( QWidget *p, char *name )
33 :QMainWindow( p, name ) 33 :QMainWindow( p, name )
34{ 34{
35#ifdef QWS 35#ifdef QWS
36 showMaximized(); 36 showMaximized();
37#endif 37#endif
38 38
39 setCaption( "AQPkg - Package Manager" ); 39 setCaption( "AQPkg - Package Manager" );
40 40
41 // Create our menu 41 // Create our menu
42 help = new QPopupMenu( this ); 42 help = new QPopupMenu( this );
43 help->insertItem( "&General", this, SLOT(displayHelp()), Qt::CTRL+Qt::Key_G ); 43 help->insertItem( "&General", this, SLOT(displayHelp()), Qt::CTRL+Qt::Key_G );
44 help->insertItem( "&About", this, SLOT(displayAbout()), Qt::CTRL+Qt::Key_A ); 44 help->insertItem( "&About", this, SLOT(displayAbout()), Qt::CTRL+Qt::Key_A );
45 45
46 settings = new QPopupMenu( this ); 46 settings = new QPopupMenu( this );
47 settings->insertItem( "&Settings", this, SLOT(displaySettings()), Qt::CTRL+Qt::Key_S ); 47 settings->insertItem( "&Settings", this, SLOT(displaySettings()), Qt::CTRL+Qt::Key_S );
48 48
49 edit = new QPopupMenu( this ); 49 edit = new QPopupMenu( this );
50 edit->insertItem( "&Find", this, SLOT(searchForPackage()), Qt::CTRL+Qt::Key_I ); 50 edit->insertItem( "&Find", this, SLOT(searchForPackage()), Qt::CTRL+Qt::Key_I );
51 edit->insertItem( "Find &Next", this, SLOT(repeatSearchForPackage()), Qt::CTRL+Qt::Key_N ); 51 edit->insertItem( "Find &Next", this, SLOT(repeatSearchForPackage()), Qt::CTRL+Qt::Key_N );
52 52
53 filter = new QPopupMenu( this ); 53 filter = new QPopupMenu( this );
54 mnuShowUninstalledPkgsId = filter->insertItem( "Show &Uninstalled Packages", this, SLOT(filterUninstalledPackages()), Qt::CTRL+Qt::Key_U ); 54 mnuShowUninstalledPkgsId = filter->insertItem( "Show &Uninstalled Packages", this, SLOT(filterUninstalledPackages()), Qt::CTRL+Qt::Key_U );
55 mnuShowInstalledPkgsId = filter->insertItem( "Show In&stalled Packages", this, SLOT(filterInstalledPackages()), Qt::CTRL+Qt::Key_S ); 55 mnuShowInstalledPkgsId = filter->insertItem( "Show In&stalled Packages", this, SLOT(filterInstalledPackages()), Qt::CTRL+Qt::Key_S );
56 mnuShowUpgradedPkgsId = filter->insertItem( "Show U&pdated Packages", this, SLOT(filterUpgradedPackages()), Qt::CTRL+Qt::Key_P ); 56 mnuShowUpgradedPkgsId = filter->insertItem( "Show U&pdated Packages", this, SLOT(filterUpgradedPackages()), Qt::CTRL+Qt::Key_P );
57 57 filter->insertSeparator();
58 // Create the main menu 58 mnuFilterByCategory = filter->insertItem( "Filter By &Category", this, SLOT(filterCategory()), Qt::CTRL+Qt::Key_C );
59 menu = menuBar(); //new QMenuBar( this ); 59 mnuSetFilterCategory = filter->insertItem( "Set Filter C&ategory", this, SLOT(setFilterCategory()), Qt::CTRL+Qt::Key_A );
60 menu->insertItem( "&Settings", settings ); 60
61 menu->insertItem( "&Edit", edit ); 61 // Create the main menu
62 menu->insertItem( "&Filter", filter ); 62 menu = menuBar(); //new QMenuBar( this );
63 menu->insertItem( "&Help", help ); 63 menu->insertItem( "&Settings", settings );
64 64 menu->insertItem( "&Edit", edit );
65 mgr = new DataManager(); 65 menu->insertItem( "&Filter", filter );
66 mgr->loadServers(); 66 menu->insertItem( "&Help", help );
67 67
68 stack = new QWidgetStack( this ); 68 mgr = new DataManager();
69 69 mgr->loadServers();
70 networkPkgWindow = new NetworkPackageManager( mgr, stack ); 70
71 stack->addWidget( networkPkgWindow, 1 ); 71 stack = new QWidgetStack( this );
72 72
73 setCentralWidget( stack ); 73 networkPkgWindow = new NetworkPackageManager( mgr, stack );
74 stack->raiseWidget( networkPkgWindow ); 74 stack->addWidget( networkPkgWindow, 1 );
75} 75
76 76 setCentralWidget( stack );
77MainWindow :: ~MainWindow() 77 stack->raiseWidget( networkPkgWindow );
78{ 78}
79 delete networkPkgWindow; 79
80} 80MainWindow :: ~MainWindow()
81 81{
82void MainWindow :: setDocument( const QString &doc ) 82 delete networkPkgWindow;
83{ 83}
84 // Remove path from package 84
85 QString package = Utils::getPackageNameFromIpkFilename( doc ); 85void MainWindow :: setDocument( const QString &doc )
86 std::cout << "Selecting package " << package << std::endl; 86{
87 networkPkgWindow->selectLocalPackage( package ); 87 // Remove path from package
88} 88 QString package = Utils::getPackageNameFromIpkFilename( doc );
89 89 std::cout << "Selecting package " << package << std::endl;
90void MainWindow :: displaySettings() 90 networkPkgWindow->selectLocalPackage( package );
91{ 91}
92 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); 92
93 if ( dlg->showDlg( 0 ) ) 93void MainWindow :: displaySettings()
94 networkPkgWindow->updateData(); 94{
95 delete dlg; 95 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true );
96} 96 if ( dlg->showDlg( 0 ) )
97 97 networkPkgWindow->updateData();
98void MainWindow :: displayHelp() 98 delete dlg;
99{ 99}
100 HelpWindow *dlg = new HelpWindow( this ); 100
101 dlg->exec(); 101void MainWindow :: displayHelp()
102 delete dlg; 102{
103} 103 HelpWindow *dlg = new HelpWindow( this );
104 104 dlg->exec();
105void MainWindow :: searchForPackage() 105 delete dlg;
106{ 106}
107 networkPkgWindow->searchForPackage( false ); 107
108} 108void MainWindow :: searchForPackage()
109 109{
110void MainWindow :: repeatSearchForPackage() 110 networkPkgWindow->searchForPackage( false );
111{ 111}
112 networkPkgWindow->searchForPackage( true ); 112
113} 113void MainWindow :: repeatSearchForPackage()
114 114{
115void MainWindow :: displayAbout() 115 networkPkgWindow->searchForPackage( true );
116{ 116}
117 QMessageBox::about( this, "About AQPkg", VERSION_TEXT ); 117
118} 118void MainWindow :: displayAbout()
119 119{
120 120 QMessageBox::about( this, "About AQPkg", VERSION_TEXT );
121void MainWindow :: filterUninstalledPackages() 121}
122{ 122
123 bool val; 123
124 if ( filter->isItemChecked( mnuShowUninstalledPkgsId ) ) 124void MainWindow :: filterUninstalledPackages()
125 { 125{
126 val = false; 126 bool val;
127 filter->setItemChecked( mnuShowUninstalledPkgsId, false ); 127 if ( filter->isItemChecked( mnuShowUninstalledPkgsId ) )
128 } 128 {
129 else 129 val = false;
130 { 130 filter->setItemChecked( mnuShowUninstalledPkgsId, false );
131 val = true; 131 }
132 filter->setItemChecked( mnuShowUninstalledPkgsId, true ); 132 else
133 } 133 {
134 134 val = true;
135 filter->setItemChecked( mnuShowInstalledPkgsId, false ); 135 filter->setItemChecked( mnuShowUninstalledPkgsId, true );
136 networkPkgWindow->showOnlyInstalledPackages( false ); 136 }
137 filter->setItemChecked( mnuShowUpgradedPkgsId, false ); 137
138 networkPkgWindow->showUpgradedPackages( false ); 138 filter->setItemChecked( mnuShowInstalledPkgsId, false );
139 139 networkPkgWindow->showOnlyInstalledPackages( false );
140 networkPkgWindow->showOnlyUninstalledPackages( val ); 140 filter->setItemChecked( mnuShowUpgradedPkgsId, false );
141 141 networkPkgWindow->showUpgradedPackages( false );
142} 142
143 143 networkPkgWindow->showOnlyUninstalledPackages( val );
144void MainWindow :: filterInstalledPackages() 144
145{ 145}
146 bool val; 146
147 if ( filter->isItemChecked( mnuShowInstalledPkgsId ) ) 147void MainWindow :: filterInstalledPackages()
148 { 148{
149 val = false; 149 bool val;
150 filter->setItemChecked( mnuShowInstalledPkgsId, false ); 150 if ( filter->isItemChecked( mnuShowInstalledPkgsId ) )
151 } 151 {
152 else 152 val = false;
153 { 153 filter->setItemChecked( mnuShowInstalledPkgsId, false );
154 val = true; 154 }
155 filter->setItemChecked( mnuShowInstalledPkgsId, true ); 155 else
156 } 156 {
157 157 val = true;
158 filter->setItemChecked( mnuShowUninstalledPkgsId, false ); 158 filter->setItemChecked( mnuShowInstalledPkgsId, true );
159 networkPkgWindow->showOnlyUninstalledPackages( false ); 159 }
160 filter->setItemChecked( mnuShowUpgradedPkgsId, false ); 160
161 networkPkgWindow->showUpgradedPackages( false ); 161 filter->setItemChecked( mnuShowUninstalledPkgsId, false );
162 162 networkPkgWindow->showOnlyUninstalledPackages( false );
163 networkPkgWindow->showOnlyInstalledPackages( val ); 163 filter->setItemChecked( mnuShowUpgradedPkgsId, false );
164} 164 networkPkgWindow->showUpgradedPackages( false );
165 165
166void MainWindow :: filterUpgradedPackages() 166 networkPkgWindow->showOnlyInstalledPackages( val );
167{ 167}
168 bool val; 168
169 if ( filter->isItemChecked( mnuShowUpgradedPkgsId ) ) 169void MainWindow :: filterUpgradedPackages()
170 { 170{
171 val = false; 171 bool val;
172 filter->setItemChecked( mnuShowUpgradedPkgsId, false ); 172 if ( filter->isItemChecked( mnuShowUpgradedPkgsId ) )
173 } 173 {
174 else 174 val = false;
175 { 175 filter->setItemChecked( mnuShowUpgradedPkgsId, false );
176 val = true; 176 }
177 filter->setItemChecked( mnuShowUpgradedPkgsId, true ); 177 else
178 } 178 {
179 179 val = true;
180 filter->setItemChecked( mnuShowUninstalledPkgsId, false ); 180 filter->setItemChecked( mnuShowUpgradedPkgsId, true );
181 networkPkgWindow->showOnlyUninstalledPackages( false ); 181 }
182 filter->setItemChecked( mnuShowInstalledPkgsId, false ); 182
183 networkPkgWindow->showOnlyInstalledPackages( false ); 183 filter->setItemChecked( mnuShowUninstalledPkgsId, false );
184 184 networkPkgWindow->showOnlyUninstalledPackages( false );
185 networkPkgWindow->showUpgradedPackages( val ); 185 filter->setItemChecked( mnuShowInstalledPkgsId, false );
186} 186 networkPkgWindow->showOnlyInstalledPackages( false );
187
188 networkPkgWindow->showUpgradedPackages( val );
189}
190
191void MainWindow :: setFilterCategory()
192{
193 if ( networkPkgWindow->setFilterCategory( ) )
194 filter->setItemChecked( mnuFilterByCategory, true );
195}
196
197void MainWindow :: filterCategory()
198{
199 if ( filter->isItemChecked( mnuFilterByCategory ) )
200 {
201 networkPkgWindow->filterByCategory( false );
202 filter->setItemChecked( mnuFilterByCategory, false );
203 }
204 else
205 {
206 if ( networkPkgWindow->filterByCategory( true ) )
207 filter->setItemChecked( mnuFilterByCategory, true );
208 }
209} \ No newline at end of file
diff --git a/noncore/settings/aqpkg/mainwin.h b/noncore/settings/aqpkg/mainwin.h
index 7b6e0ba..92aba4d 100644
--- a/noncore/settings/aqpkg/mainwin.h
+++ b/noncore/settings/aqpkg/mainwin.h
@@ -1,63 +1,68 @@
1/*************************************************************************** 1/***************************************************************************
2 mainwin.h - description 2 mainwin.h - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 13:32:30 BST 2002 4 begin : Mon Aug 26 13:32:30 BST 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 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 * 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 * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#ifndef MAINWIN_H 18#ifndef MAINWIN_H
19#define MAINWIN_H 19#define MAINWIN_H
20 20
21#include <qmainwindow.h> 21#include <qmainwindow.h>
22#include <qwidgetstack.h> 22#include <qwidgetstack.h>
23 23
24 24
25class NetworkPackageManager; 25class NetworkPackageManager;
26class DataManager; 26class DataManager;
27 27
28class MainWindow :public QMainWindow 28class MainWindow :public QMainWindow
29{ 29{
30 Q_OBJECT 30 Q_OBJECT
31public: 31public:
32 32
33 MainWindow( QWidget *p = 0, char *name = 0 ); 33 MainWindow( QWidget *p = 0, char *name = 0 );
34 ~MainWindow(); 34 ~MainWindow();
35 35
36private: 36private:
37 DataManager *mgr; 37 DataManager *mgr;
38 38
39 QMenuBar *menu; 39 QMenuBar *menu;
40 QPopupMenu *help; 40 QPopupMenu *help;
41 QPopupMenu *settings; 41 QPopupMenu *settings;
42 QPopupMenu *edit; 42 QPopupMenu *edit;
43 QPopupMenu *filter; 43 QPopupMenu *filter;
44 QWidgetStack *stack; 44 QWidgetStack *stack;
45 45
46 NetworkPackageManager *networkPkgWindow; 46 NetworkPackageManager *networkPkgWindow;
47 47
48 int mnuShowUninstalledPkgsId; 48 int mnuShowUninstalledPkgsId;
49 int mnuShowInstalledPkgsId; 49 int mnuShowInstalledPkgsId;
50 int mnuShowUpgradedPkgsId; 50 int mnuShowUpgradedPkgsId;
51 51 int mnuFilterByCategory;
52public slots: 52 int mnuSetFilterCategory;
53 void setDocument( const QString &doc ); 53
54 void displayHelp(); 54public slots:
55 void searchForPackage(); 55 void setDocument( const QString &doc );
56 void repeatSearchForPackage(); 56 void displayHelp();
57 void displayAbout(); 57 void searchForPackage();
58 void displaySettings(); 58 void repeatSearchForPackage();
59 void filterUninstalledPackages(); 59 void displayAbout();
60 void filterInstalledPackages(); 60 void displaySettings();
61 void filterUpgradedPackages(); 61 void filterUninstalledPackages();
62}; 62 void filterInstalledPackages();
63#endif 63 void filterUpgradedPackages();
64 void filterCategory();
65 void setFilterCategory();
66
67};
68#endif
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp
index 188f90d..0814121 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.cpp
+++ b/noncore/settings/aqpkg/networkpkgmgr.cpp
@@ -19,71 +19,72 @@
19#include <iostream> 19#include <iostream>
20using namespace std; 20using namespace std;
21 21
22#include <unistd.h> 22#include <unistd.h>
23#include <stdlib.h> 23#include <stdlib.h>
24#include <linux/limits.h> 24#include <linux/limits.h>
25 25
26#ifdef QWS 26#ifdef QWS
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qpe/qcopenvelope_qws.h> 28#include <qpe/qcopenvelope_qws.h>
29#include <qpe/config.h> 29#include <qpe/config.h>
30#else 30#else
31#include <qapplication.h> 31#include <qapplication.h>
32#endif 32#endif
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qmessagebox.h> 35#include <qmessagebox.h>
36 36
37#include "datamgr.h" 37#include "datamgr.h"
38#include "networkpkgmgr.h" 38#include "networkpkgmgr.h"
39#include "installdlgimpl.h" 39#include "installdlgimpl.h"
40#include "ipkg.h" 40#include "ipkg.h"
41#include "inputdlg.h" 41#include "inputdlg.h"
42#include "letterpushbutton.h" 42#include "letterpushbutton.h"
43#include "categoryfilterimpl.h"
43 44
44#include "global.h" 45#include "global.h"
45 46
46extern int compareVersions( const char *v1, const char *v2 ); 47extern int compareVersions( const char *v1, const char *v2 );
47 48
48NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) 49NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name)
49 : QWidget(parent, name) 50 : QWidget(parent, name)
50{ 51{
51 dataMgr = dataManager; 52 dataMgr = dataManager;
52 53
53#ifdef QWS 54#ifdef QWS
54 // read download directory from config file 55 // read download directory from config file
55 Config cfg( "aqpkg" ); 56 Config cfg( "aqpkg" );
56 cfg.setGroup( "settings" ); 57 cfg.setGroup( "settings" );
57 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); 58 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" );
58 showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); 59 showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" );
59 60
60#endif 61#endif
61 62
62 showUninstalledPkgs = false; 63 showUninstalledPkgs = false;
63 showInstalledPkgs = false; 64 showInstalledPkgs = false;
64 showUpgradedPkgs = false; 65 showUpgradedPkgs = false;
65 66 categoryFilterEnabled = false;
66 67
67 initGui(); 68 initGui();
68 setupConnections(); 69 setupConnections();
69 70
70 updateData(); 71 updateData();
71} 72}
72 73
73NetworkPackageManager::~NetworkPackageManager() 74NetworkPackageManager::~NetworkPackageManager()
74{ 75{
75} 76}
76 77
77void NetworkPackageManager :: timerEvent ( QTimerEvent * ) 78void NetworkPackageManager :: timerEvent ( QTimerEvent * )
78{ 79{
79 killTimer( timerId ); 80 killTimer( timerId );
80 81
81 // Add server names to listbox 82 // Add server names to listbox
82 updateData(); 83 updateData();
83} 84}
84 85
85void NetworkPackageManager :: updateData() 86void NetworkPackageManager :: updateData()
86{ 87{
87 serversList->clear(); 88 serversList->clear();
88 packagesList->clear(); 89 packagesList->clear();
89 90
@@ -218,48 +219,55 @@ void NetworkPackageManager :: serverSelected( int )
218 219
219 vector<Package> &list = s->getPackageList(); 220 vector<Package> &list = s->getPackageList();
220 vector<Package>::iterator it; 221 vector<Package>::iterator it;
221 for ( it = list.begin() ; it != list.end() ; ++it ) 222 for ( it = list.begin() ; it != list.end() ; ++it )
222 { 223 {
223 224
224 QString text = ""; 225 QString text = "";
225 226
226 // Apply show only uninstalled packages filter 227 // Apply show only uninstalled packages filter
227 if ( showUninstalledPkgs && it->isInstalled() ) 228 if ( showUninstalledPkgs && it->isInstalled() )
228 continue; 229 continue;
229 230
230 // Apply show only installed packages filter 231 // Apply show only installed packages filter
231 if ( showInstalledPkgs && !it->isInstalled() ) 232 if ( showInstalledPkgs && !it->isInstalled() )
232 continue; 233 continue;
233 234
234 // Apply show only new installed packages filter 235 // Apply show only new installed packages filter
235 if ( showUpgradedPkgs ) 236 if ( showUpgradedPkgs )
236 { 237 {
237 if ( !it->isInstalled() || 238 if ( !it->isInstalled() ||
238 compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 ) 239 compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 )
239 continue; 240 continue;
240 } 241 }
241 242
243 // Apply the section filter
244 if ( categoryFilterEnabled && categoryFilter != "" )
245 {
246 if ( it->getSection() == "" || categoryFilter.find( it->getSection().lower() ) == -1 )
247 continue;
248 }
249
242 // If the local server, only display installed packages 250 // If the local server, only display installed packages
243 if ( serverName == LOCAL_SERVER && !it->isInstalled() ) 251 if ( serverName == LOCAL_SERVER && !it->isInstalled() )
244 continue; 252 continue;
245 253
246 254
247 text += it->getPackageName(); 255 text += it->getPackageName();
248 if ( it->isInstalled() ) 256 if ( it->isInstalled() )
249 { 257 {
250 text += " (installed)"; 258 text += " (installed)";
251 259
252 // If a different version of package is available, postfix it with an * 260 // If a different version of package is available, postfix it with an *
253 if ( it->getVersion() != it->getInstalledVersion() ) 261 if ( it->getVersion() != it->getInstalledVersion() )
254 { 262 {
255 263
256 if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 ) 264 if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 )
257 text += "*"; 265 text += "*";
258 } 266 }
259 } 267 }
260 268
261 QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); 269 QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox );
262 270
263 if ( it->isInstalled() ) 271 if ( it->isInstalled() )
264 { 272 {
265 QString destName = ""; 273 QString destName = "";
@@ -274,82 +282,81 @@ void NetworkPackageManager :: serverSelected( int )
274 destName = it->getInstalledTo()->getDestinationName(); 282 destName = it->getInstalledTo()->getDestinationName();
275 } 283 }
276 if ( destName != "" ) 284 if ( destName != "" )
277 new QCheckListItem( item, QString( "Installed To - " ) + destName ); 285 new QCheckListItem( item, QString( "Installed To - " ) + destName );
278 } 286 }
279 287
280 if ( !it->isPackageStoredLocally() ) 288 if ( !it->isPackageStoredLocally() )
281 new QCheckListItem( item, QString( "Description - " ) + it->getDescription() ); 289 new QCheckListItem( item, QString( "Description - " ) + it->getDescription() );
282 else 290 else
283 new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); 291 new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() );
284 292
285 if ( serverName == LOCAL_SERVER ) 293 if ( serverName == LOCAL_SERVER )
286 { 294 {
287 new QCheckListItem( item, QString( "V. Installed - " ) + it->getVersion() ); 295 new QCheckListItem( item, QString( "V. Installed - " ) + it->getVersion() );
288 } 296 }
289 else 297 else
290 { 298 {
291 new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); 299 new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() );
292 if ( it->getLocalPackage() ) 300 if ( it->getLocalPackage() )
293 { 301 {
294 if ( it->isInstalled() ) 302 if ( it->isInstalled() )
295 new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() ); 303 new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() );
296 } 304 }
297 } 305 }
306
307 new QCheckListItem( item, QString( "Size - " ) + it->getPackageSize() );
308 new QCheckListItem( item, QString( "Section - " ) + it->getSection() );
298 packagesList->insertItem( item ); 309 packagesList->insertItem( item );
299 } 310 }
300 311
301 // If the local server or the local ipkgs server disable the download button 312 // If the local server or the local ipkgs server disable the download button
302 if ( serverName == LOCAL_SERVER ) 313 if ( serverName == LOCAL_SERVER )
303 { 314 {
304 upgrade->setEnabled( false ); 315 upgrade->setEnabled( false );
305 download->setText( "Download" ); 316 download->setText( "Download" );
306 download->setEnabled( true ); 317 download->setEnabled( true );
307 } 318 }
308 else if ( serverName == LOCAL_IPKGS ) 319 else if ( serverName == LOCAL_IPKGS )
309 { 320 {
310 upgrade->setEnabled( false ); 321 upgrade->setEnabled( false );
311 download->setEnabled( true ); 322 download->setEnabled( true );
312 download->setText( "Remove" ); 323 download->setText( "Remove" );
313 } 324 }
314 else 325 else
315 { 326 {
316 upgrade->setEnabled( true ); 327 upgrade->setEnabled( true );
317 download->setEnabled( true ); 328 download->setEnabled( true );
318 download->setText( "Download" ); 329 download->setText( "Download" );
319 } 330 }
320} 331}
321 332
322void NetworkPackageManager :: updateServer() 333void NetworkPackageManager :: updateServer()
323{ 334{
324 QString serverName = serversList->currentText(); 335 QString serverName = serversList->currentText();
325 336
326 // Update the current server 337 // Update the current server
327 // Display dialog 338 // Display dialog
328// ProgressDlg *progDlg = new ProgressDlg( this );
329// QString status = "Updating package lists...";
330// progDlg->show();
331// progDlg->setText( status );
332 339
333 // Disable buttons to stop silly people clicking lots on them :) 340 // Disable buttons to stop silly people clicking lots on them :)
334 341
335 // First, write out ipkg_conf file so that ipkg can use it 342 // First, write out ipkg_conf file so that ipkg can use it
336 dataMgr->writeOutIpkgConf(); 343 dataMgr->writeOutIpkgConf();
337 344
338 Ipkg ipkg; 345 Ipkg ipkg;
339 ipkg.setOption( "update" ); 346 ipkg.setOption( "update" );
340 347
341 InstallDlgImpl dlg( &ipkg, "Refreshing server package lists", this, "Upgrade", true ); 348 InstallDlgImpl dlg( &ipkg, "Refreshing server package lists", this, "Upgrade", true );
342 dlg.showDlg(); 349 dlg.showDlg();
343 350
344 // Reload data 351 // Reload data
345 dataMgr->reloadServerData(); 352 dataMgr->reloadServerData();
346 serverSelected(-1); 353 serverSelected(-1);
347// delete progDlg; 354// delete progDlg;
348} 355}
349 356
350void NetworkPackageManager :: upgradePackages() 357void NetworkPackageManager :: upgradePackages()
351{ 358{
352 // We're gonna do an upgrade of all packages 359 // We're gonna do an upgrade of all packages
353 // First warn user that this isn't recommended 360 // First warn user that this isn't recommended
354 QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n"; 361 QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n";
355 QMessageBox warn("Warning", text, QMessageBox::Warning, 362 QMessageBox warn("Warning", text, QMessageBox::Warning,
@@ -665,49 +672,49 @@ InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item )
665 caption = "Do you wish to remove or reinstall\n%s?"; 672 caption = "Do you wish to remove or reinstall\n%s?";
666 text = "Remove or ReInstall"; 673 text = "Remove or ReInstall";
667 secondButton = "ReInstall"; 674 secondButton = "ReInstall";
668 secondOption = "R"; 675 secondOption = "R";
669 } 676 }
670 else if ( val == 1 ) 677 else if ( val == 1 )
671 { 678 {
672 // Version available is newer - option to remove or upgrade 679 // Version available is newer - option to remove or upgrade
673 caption = "Do you wish to remove or upgrade\n%s?"; 680 caption = "Do you wish to remove or upgrade\n%s?";
674 text = "Remove or Upgrade"; 681 text = "Remove or Upgrade";
675 secondButton = "Upgrade"; 682 secondButton = "Upgrade";
676 secondOption = "U"; 683 secondOption = "U";
677 } 684 }
678 685
679 // Sticky option not implemented yet, but will eventually allow 686 // Sticky option not implemented yet, but will eventually allow
680 // the user to say something like 'remove all' 687 // the user to say something like 'remove all'
681 if ( stickyOption == "" ) 688 if ( stickyOption == "" )
682 { 689 {
683 QString msgtext; 690 QString msgtext;
684 msgtext.sprintf( caption, (const char *)name ); 691 msgtext.sprintf( caption, (const char *)name );
685 switch( QMessageBox::information( this, text, 692 switch( QMessageBox::information( this, text,
686 msgtext, "Remove", secondButton ) ) 693 msgtext, "Remove", secondButton ) )
687 { 694 {
688 case 0: // Try again or Enter 695 case 0: // Try again or Enter
689 // option 0 = Remove 696 // option 0 = Remove
690 item.option = "D"; 697 item.option = "D";
691 break; 698 break;
692 case 1: // Quit or Escape 699 case 1: // Quit or Escape
693 item.option = secondOption; 700 item.option = secondOption;
694 break; 701 break;
695 } 702 }
696 } 703 }
697 else 704 else
698 { 705 {
699// item.option = stickyOption; 706// item.option = stickyOption;
700 } 707 }
701 } 708 }
702 709
703 710
704 // Check if we are reinstalling the same version 711 // Check if we are reinstalling the same version
705 if ( item.option != "R" ) 712 if ( item.option != "R" )
706 item.recreateLinks = true; 713 item.recreateLinks = true;
707 else 714 else
708 item.recreateLinks = false; 715 item.recreateLinks = false;
709 716
710 // User hit cancel (on dlg - assume remove) 717 // User hit cancel (on dlg - assume remove)
711 return item; 718 return item;
712 } 719 }
713} 720}
@@ -722,49 +729,49 @@ void NetworkPackageManager :: letterPushed( QString t )
722{ 729{
723 QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); 730 QCheckListItem *top = (QCheckListItem *)packagesList->firstChild();
724 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); 731 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
725 if ( packagesList->firstChild() == 0 ) 732 if ( packagesList->firstChild() == 0 )
726 return; 733 return;
727 734
728 QCheckListItem *item; 735 QCheckListItem *item;
729 if ( start == 0 ) 736 if ( start == 0 )
730 { 737 {
731 item = (QCheckListItem *)packagesList->firstChild(); 738 item = (QCheckListItem *)packagesList->firstChild();
732 start = top; 739 start = top;
733 } 740 }
734 else 741 else
735 item = (QCheckListItem *)start->nextSibling(); 742 item = (QCheckListItem *)start->nextSibling();
736 743
737 if ( item == 0 ) 744 if ( item == 0 )
738 item = (QCheckListItem *)packagesList->firstChild(); 745 item = (QCheckListItem *)packagesList->firstChild();
739 do 746 do
740 { 747 {
741 if ( item->text().lower().startsWith( t.lower() ) ) 748 if ( item->text().lower().startsWith( t.lower() ) )
742 { 749 {
743 packagesList->setSelected( item, true ); 750 packagesList->setSelected( item, true );
744 packagesList->ensureItemVisible( item ); 751 packagesList->ensureItemVisible( item );
745 break; 752 break;
746 } 753 }
747 754
748 item = (QCheckListItem *)item->nextSibling(); 755 item = (QCheckListItem *)item->nextSibling();
749 if ( !item ) 756 if ( !item )
750 item = (QCheckListItem *)packagesList->firstChild(); 757 item = (QCheckListItem *)packagesList->firstChild();
751 } while ( item != start); 758 } while ( item != start);
752} 759}
753 760
754 761
755void NetworkPackageManager :: searchForPackage( bool findNext ) 762void NetworkPackageManager :: searchForPackage( bool findNext )
756{ 763{
757 bool ok = false; 764 bool ok = false;
758 if ( !findNext || lastSearchText.isEmpty() ) 765 if ( !findNext || lastSearchText.isEmpty() )
759 lastSearchText = InputDialog::getText( "Search for package", "Enter package to search for", lastSearchText, &ok, this ).lower(); 766 lastSearchText = InputDialog::getText( "Search for package", "Enter package to search for", lastSearchText, &ok, this ).lower();
760 else 767 else
761 ok = true; 768 ok = true;
762 769
763 if ( ok && !lastSearchText.isEmpty() ) 770 if ( ok && !lastSearchText.isEmpty() )
764 { 771 {
765 cout << "searching for " << lastSearchText << endl; 772 cout << "searching for " << lastSearchText << endl;
766 // look through package list for text startng at current position 773 // look through package list for text startng at current position
767 vector<InstallData> workingPackages; 774 vector<InstallData> workingPackages;
768 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); 775 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
769 if ( start != 0 ) 776 if ( start != 0 )
770 start = (QCheckListItem *)start->nextSibling(); 777 start = (QCheckListItem *)start->nextSibling();
@@ -783,24 +790,66 @@ void NetworkPackageManager :: searchForPackage( bool findNext )
783 packagesList->setCurrentItem( item ); 790 packagesList->setCurrentItem( item );
784 break; 791 break;
785 } 792 }
786 } 793 }
787 } 794 }
788} 795}
789 796
790void NetworkPackageManager :: showOnlyUninstalledPackages( bool val ) 797void NetworkPackageManager :: showOnlyUninstalledPackages( bool val )
791{ 798{
792 showUninstalledPkgs = val; 799 showUninstalledPkgs = val;
793 serverSelected( -1 ); 800 serverSelected( -1 );
794} 801}
795 802
796void NetworkPackageManager :: showOnlyInstalledPackages( bool val ) 803void NetworkPackageManager :: showOnlyInstalledPackages( bool val )
797{ 804{
798 showInstalledPkgs = val; 805 showInstalledPkgs = val;
799 serverSelected( -1 ); 806 serverSelected( -1 );
800} 807}
801 808
802void NetworkPackageManager :: showUpgradedPackages( bool val ) 809void NetworkPackageManager :: showUpgradedPackages( bool val )
803{ 810{
804 showUpgradedPkgs = val; 811 showUpgradedPkgs = val;
805 serverSelected( -1 ); 812 serverSelected( -1 );
806} 813}
814
815bool NetworkPackageManager :: filterByCategory( bool val )
816{
817 if ( val )
818 {
819 if ( categoryFilter == "" )
820 {
821 if ( !setFilterCategory() )
822 return false;
823 }
824
825 categoryFilterEnabled = true;
826 serverSelected( -1 );
827 return true;
828 }
829 else
830 {
831 // Turn off filter
832 categoryFilterEnabled = false;
833 serverSelected( -1 );
834 return false;
835 }
836}
837
838bool NetworkPackageManager :: setFilterCategory( )
839{
840 // Get categories;
841 CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this );
842 if ( dlg.exec() == QDialog::Accepted )
843 {
844 categoryFilter = dlg.getSelectedFilter();
845
846 if ( categoryFilter == "" )
847 return false;
848
849 categoryFilterEnabled = true;
850 serverSelected( -1 );
851 return true;
852 }
853
854 return false;
855}
diff --git a/noncore/settings/aqpkg/networkpkgmgr.h b/noncore/settings/aqpkg/networkpkgmgr.h
index 937c9b4..46919d7 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.h
+++ b/noncore/settings/aqpkg/networkpkgmgr.h
@@ -23,63 +23,67 @@
23#include <qwidget.h> 23#include <qwidget.h>
24#include <qcombobox.h> 24#include <qcombobox.h>
25#include <qlistview.h> 25#include <qlistview.h>
26 26
27#include "datamgr.h" 27#include "datamgr.h"
28#include "progressdlg.h" 28#include "progressdlg.h"
29class InstallData; 29class InstallData;
30 30
31/** NetworkPackageManager is the base class of the project */ 31/** NetworkPackageManager is the base class of the project */
32class NetworkPackageManager : public QWidget 32class NetworkPackageManager : public QWidget
33{ 33{
34 Q_OBJECT 34 Q_OBJECT
35public: 35public:
36 /** construtor */ 36 /** construtor */
37 NetworkPackageManager( DataManager *dataManager, QWidget* parent=0, const char *name=0); 37 NetworkPackageManager( DataManager *dataManager, QWidget* parent=0, const char *name=0);
38 /** destructor */ 38 /** destructor */
39 ~NetworkPackageManager(); 39 ~NetworkPackageManager();
40 40
41 void selectLocalPackage( const QString &pkg ); 41 void selectLocalPackage( const QString &pkg );
42 void updateData(); 42 void updateData();
43 void searchForPackage( bool findNext ); 43 void searchForPackage( bool findNext );
44 void showOnlyUninstalledPackages( bool val ); 44 void showOnlyUninstalledPackages( bool val );
45 void showOnlyInstalledPackages( bool val ); 45 void showOnlyInstalledPackages( bool val );
46 void showUpgradedPackages( bool val ); 46 void showUpgradedPackages( bool val );
47 bool filterByCategory( bool val );
48 bool setFilterCategory();
47 49
48private: 50private:
49 DataManager *dataMgr; 51 DataManager *dataMgr;
50 52
51 QComboBox *serversList; 53 QComboBox *serversList;
52 QListView *packagesList; 54 QListView *packagesList;
53 QPushButton *update; 55 QPushButton *update;
54 QPushButton *upgrade; 56 QPushButton *upgrade;
55 QPushButton *download; 57 QPushButton *download;
56 QPushButton *apply; 58 QPushButton *apply;
57 59
58 ProgressDlg *progressDlg; 60 ProgressDlg *progressDlg;
59 QString currentlySelectedServer; 61 QString currentlySelectedServer;
60 QString lastSearchText; 62 QString lastSearchText;
63 QString categoryFilter;
61 64
65 bool categoryFilterEnabled;
62 bool showJumpTo; 66 bool showJumpTo;
63 bool showUninstalledPkgs; 67 bool showUninstalledPkgs;
64 bool showInstalledPkgs; 68 bool showInstalledPkgs;
65 bool showUpgradedPkgs; 69 bool showUpgradedPkgs;
66 int timerId; 70 int timerId;
67 71
68 void timerEvent ( QTimerEvent * ); 72 void timerEvent ( QTimerEvent * );
69 73
70 void initGui(); 74 void initGui();
71 void setupConnections(); 75 void setupConnections();
72 void showProgressDialog( char *initialText ); 76 void showProgressDialog( char *initialText );
73 void downloadSelectedPackages(); 77 void downloadSelectedPackages();
74 void downloadRemotePackage(); 78 void downloadRemotePackage();
75 InstallData dealWithItem( QCheckListItem *item ); 79 InstallData dealWithItem( QCheckListItem *item );
76 QString stickyOption; 80 QString stickyOption;
77 81
78public slots: 82public slots:
79 void serverSelected( int index ); 83 void serverSelected( int index );
80 void applyChanges(); 84 void applyChanges();
81 void upgradePackages(); 85 void upgradePackages();
82 void downloadPackage(); 86 void downloadPackage();
83 void updateServer(); 87 void updateServer();
84 void displayText( const QString &t ); 88 void displayText( const QString &t );
85 void letterPushed( QString t ); 89 void letterPushed( QString t );
diff --git a/noncore/settings/aqpkg/package.h b/noncore/settings/aqpkg/package.h
index 56ef874..7545818 100644
--- a/noncore/settings/aqpkg/package.h
+++ b/noncore/settings/aqpkg/package.h
@@ -23,61 +23,67 @@
23/** 23/**
24 *@author Andy Qua 24 *@author Andy Qua
25 */ 25 */
26 26
27#include <qstring.h> 27#include <qstring.h>
28#include "destination.h" 28#include "destination.h"
29 29
30class Package 30class Package
31{ 31{
32public: 32public:
33 Package( QString &name ); 33 Package( QString &name );
34 Package( char *name ); 34 Package( char *name );
35 ~Package(); 35 ~Package();
36 36
37 void setLocalPackage( Package *p ); 37 void setLocalPackage( Package *p );
38 void setPackageName( QString &name ); 38 void setPackageName( QString &name );
39 void setVersion( QString &v ); 39 void setVersion( QString &v );
40 void setStatus( QString &s ); 40 void setStatus( QString &s );
41 void setDescription( QString &d ); 41 void setDescription( QString &d );
42 void setFilename( QString &f ); 42 void setFilename( QString &f );
43 void setPackageStoredLocally( bool local ){ packageStoredLocally = local; } 43 void setPackageStoredLocally( bool local ){ packageStoredLocally = local; }
44 void setInstalledToRoot( bool root ) { installedToRoot = root; } 44 void setInstalledToRoot( bool root ) { installedToRoot = root; }
45 void setInstalledTo( Destination *d ) { installedTo = d; } 45 void setInstalledTo( Destination *d ) { installedTo = d; }
46 void setDependancies( QString &deps ) { dependancies = deps; } 46 void setDependancies( QString &deps ) { dependancies = deps; }
47 void setPackageSize( QString size ) { packageSize = size; }
48 void setSection( QString sect) { section = sect; }
47 49
48 Package *getLocalPackage() { return localPackage; } 50 Package *getLocalPackage() { return localPackage; }
49 QString getPackageName() { return packageName; } 51 QString getPackageName() { return packageName; }
50 QString getVersion() { return version; } 52 QString getVersion() { return version; }
51 QString getStatus() { return status; } 53 QString getStatus() { return status; }
52 QString getDescription() { return description; } 54 QString getDescription() { return description; }
53 QString getFilename() { return filename; } 55 QString getFilename() { return filename; }
54 QString getDependancies() { return dependancies; } 56 QString getDependancies() { return dependancies; }
57 QString getPackageSize() { return packageSize; }
58 QString getSection() { return section; }
55 59
56 bool isInstalled(); 60 bool isInstalled();
57 bool isPackageStoredLocally(){ return packageStoredLocally; } 61 bool isPackageStoredLocally(){ return packageStoredLocally; }
58 bool isInstalledToRoot() { return installedToRoot; } 62 bool isInstalledToRoot() { return installedToRoot; }
59 QString getInstalledVersion(); 63 QString getInstalledVersion();
60 QString getInstalledPackageName(); 64 QString getInstalledPackageName();
61 Destination *getInstalledTo() { return installedTo; } 65 Destination *getInstalledTo() { return installedTo; }
62 66
63 QString toString(); 67 QString toString();
64 68
65 69
66private: 70private:
67 Package *localPackage; 71 Package *localPackage;
68 72
69 QString packageName; 73 QString packageName;
70 QString version; 74 QString version;
71 QString status; 75 QString status;
72 QString description; 76 QString description;
73 QString filename; 77 QString filename;
74 bool packageStoredLocally; 78 bool packageStoredLocally;
75 bool installedToRoot; 79 bool installedToRoot;
76 bool installed; 80 bool installed;
77 bool differentVersionAvailable; 81 bool differentVersionAvailable;
78 QString dependancies; 82 QString dependancies;
83 QString packageSize;
84 QString section;
79 85
80 Destination *installedTo; 86 Destination *installedTo;
81}; 87};
82 88
83#endif 89#endif
diff --git a/noncore/settings/aqpkg/server.cpp b/noncore/settings/aqpkg/server.cpp
index 539ebf0..7c3257b 100644
--- a/noncore/settings/aqpkg/server.cpp
+++ b/noncore/settings/aqpkg/server.cpp
@@ -7,48 +7,49 @@
7 description : This class holds details about a server 7 description : This class holds details about a server
8 : e.g. all the packages that contained on the server 8 : e.g. all the packages that contained on the server
9 : the installation status 9 : the installation status
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12/*************************************************************************** 12/***************************************************************************
13 * * 13 * *
14 * This program is free software; you can redistribute it and/or modify * 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 * 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 * 16 * the Free Software Foundation; either version 2 of the License, or *
17 * (at your option) any later version. * 17 * (at your option) any later version. *
18 * * 18 * *
19 ***************************************************************************/ 19 ***************************************************************************/
20 20
21 21
22#include <stdio.h> 22#include <stdio.h>
23#include <string.h> 23#include <string.h>
24#include <stdlib.h> 24#include <stdlib.h>
25 25
26#include <iostream> 26#include <iostream>
27#include <fstream> 27#include <fstream>
28using namespace std; 28using namespace std;
29 29
30#include "server.h" 30#include "server.h"
31#include "datamgr.h"
31 32
32#ifdef QWS 33#ifdef QWS
33#include <qpe/global.h> 34#include <qpe/global.h>
34#include <qpe/applnk.h> 35#include <qpe/applnk.h>
35#include <qlist.h> 36#include <qlist.h>
36#endif 37#endif
37 38
38#include "utils.h" 39#include "utils.h"
39 40
40#include "global.h" 41#include "global.h"
41 42
42Server :: Server( const char *name, const char *url ) 43Server :: Server( const char *name, const char *url )
43{ 44{
44 serverName = name; 45 serverName = name;
45 serverUrl = url; 46 serverUrl = url;
46 packageFile = IPKG_DIR; 47 packageFile = IPKG_DIR;
47 packageFile += "lists/" + serverName; 48 packageFile += "lists/" + serverName;
48} 49}
49 50
50Server :: ~Server() 51Server :: ~Server()
51{ 52{
52 cleanUp(); 53 cleanUp();
53} 54}
54 55
@@ -189,49 +190,61 @@ void Server :: readPackageFile( Server *local, bool clearAll, bool installingToR
189 { 190 {
190 if (currPackage->getStatus().find( "deinstall" ) != -1 ) 191 if (currPackage->getStatus().find( "deinstall" ) != -1 )
191 currPackage->setInstalledTo( dest ); 192 currPackage->setInstalledTo( dest );
192 } 193 }
193 } 194 }
194 else if ( key == "Version" ) 195 else if ( key == "Version" )
195 { 196 {
196 if ( currPackage ) 197 if ( currPackage )
197 currPackage->setVersion( value ); 198 currPackage->setVersion( value );
198 } 199 }
199 else if ( key == "Status" ) 200 else if ( key == "Status" )
200 { 201 {
201 if ( currPackage ) 202 if ( currPackage )
202 currPackage->setStatus( value ); 203 currPackage->setStatus( value );
203 } 204 }
204 else if ( key == "Description" ) 205 else if ( key == "Description" )
205 { 206 {
206 if ( currPackage ) 207 if ( currPackage )
207 currPackage->setDescription( value ); 208 currPackage->setDescription( value );
208 } 209 }
209 else if ( key == "Filename" ) 210 else if ( key == "Filename" )
210 { 211 {
211 if ( currPackage ) 212 if ( currPackage )
212 currPackage->setFilename( value ); 213 currPackage->setFilename( value );
213 } 214 }
215 else if ( key == "Size" )
216 {
217 if ( currPackage )
218 currPackage->setPackageSize( value );
219 }
220 else if ( key == "Section" )
221 {
222 if ( currPackage )
223 currPackage->setSection( value );
224
225 DataManager::setAvailableCategories( value );
226 }
214 else if ( key == "" ) 227 else if ( key == "" )
215 { 228 {
216 newPackage = true; 229 newPackage = true;
217 } 230 }
218 } while ( !in.eof() ); 231 } while ( !in.eof() );
219 232
220 in.close(); 233 in.close();
221 234
222 // build local packages 235 // build local packages
223 buildLocalPackages( local ); 236 buildLocalPackages( local );
224} 237}
225 238
226void Server :: buildLocalPackages( Server *local ) 239void Server :: buildLocalPackages( Server *local )
227{ 240{
228 for ( unsigned int i = 0 ; i < packageList.size() ; ++i ) 241 for ( unsigned int i = 0 ; i < packageList.size() ; ++i )
229 { 242 {
230 QString name = packageList[i].getPackageName(); 243 QString name = packageList[i].getPackageName();
231 244
232 // If the package name is an ipk name, then convert the filename to a package name 245 // If the package name is an ipk name, then convert the filename to a package name
233 if ( name.find( ".ipk" ) != -1 ) 246 if ( name.find( ".ipk" ) != -1 )
234 name = Utils::getPackageNameFromIpkFilename( packageList[i].getFilename() ); 247 name = Utils::getPackageNameFromIpkFilename( packageList[i].getFilename() );
235 248
236 if ( local ) 249 if ( local )
237 packageList[i].setLocalPackage( local->getPackage( name ) ); 250 packageList[i].setLocalPackage( local->getPackage( name ) );
@@ -249,31 +262,37 @@ Package *Server :: getPackage( QString &name )
249Package *Server :: getPackage( const char *name ) 262Package *Server :: getPackage( const char *name )
250{ 263{
251 Package *ret = 0; 264 Package *ret = 0;
252 265
253 for ( unsigned int i = 0 ; i < packageList.size() && ret == 0; ++i ) 266 for ( unsigned int i = 0 ; i < packageList.size() && ret == 0; ++i )
254 { 267 {
255 if ( packageList[i].getPackageName() == name ) 268 if ( packageList[i].getPackageName() == name )
256 ret = &packageList[i]; 269 ret = &packageList[i];
257 } 270 }
258 271
259 return ret; 272 return ret;
260} 273}
261 274
262QString Server :: toString() 275QString Server :: toString()
263{ 276{
264 QString ret = "Server\n name - " + serverName + 277 QString ret = "Server\n name - " + serverName +
265 "\n url - " + serverUrl + 278 "\n url - " + serverUrl +
266 "\n"; 279 "\n";
267 280
268 for ( unsigned int i = 0 ; i < packageList.size() ; ++i ) 281 for ( unsigned int i = 0 ; i < packageList.size() ; ++i )
269 ret += "\n " + packageList[i].toString(); 282 ret += "\n " + packageList[i].toString();
270 283
271 284
272 return ret; 285 return ret;
286} /*
287void addAvailableSection( QString section )
288{
289 if ( DataManager::availableCategories.find( value ) == -1 )
290// DataManager::availableCategories += "#" + value;
273} 291}
292*/
274 293
275vector<Package> &Server::getPackageList() 294vector<Package> &Server::getPackageList()
276{ 295{
277 return packageList; 296 return packageList;
278} 297}
279 298
diff --git a/noncore/settings/aqpkg/server.h b/noncore/settings/aqpkg/server.h
index e9f434c..f585b8f 100644
--- a/noncore/settings/aqpkg/server.h
+++ b/noncore/settings/aqpkg/server.h
@@ -38,28 +38,29 @@ public:
38 void readStatusFile( vector<Destination> &v ); 38 void readStatusFile( vector<Destination> &v );
39 void readLocalIpks( Server *local ); 39 void readLocalIpks( Server *local );
40 void readPackageFile( Server *local = 0, bool clearAll = true, bool installedToRoot= false, Destination *dest = 0 ); 40 void readPackageFile( Server *local = 0, bool clearAll = true, bool installedToRoot= false, Destination *dest = 0 );
41 void buildLocalPackages( Server *local ); 41 void buildLocalPackages( Server *local );
42 Package *getPackage( const char *name ); 42 Package *getPackage( const char *name );
43 Package *getPackage( QString &name ); 43 Package *getPackage( QString &name );
44 QString toString(); 44 QString toString();
45 vector<Package> &getPackageList(); 45 vector<Package> &getPackageList();
46 bool isServerActive() { return active; } 46 bool isServerActive() { return active; }
47 47
48 void setServerName( const QString &name ) { serverName = name; } 48 void setServerName( const QString &name ) { serverName = name; }
49 void setServerUrl( const QString &url ) { serverUrl = url; } 49 void setServerUrl( const QString &url ) { serverUrl = url; }
50 void setActive( bool val ) { active = val; } 50 void setActive( bool val ) { active = val; }
51 QString &getServerName() { return serverName; } 51 QString &getServerName() { return serverName; }
52 QString &getServerUrl() { return serverUrl; } 52 QString &getServerUrl() { return serverUrl; }
53 53
54protected: 54protected:
55 55
56private: 56private:
57 QString serverName; 57 QString serverName;
58 QString serverUrl; 58 QString serverUrl;
59 QString packageFile; 59 QString packageFile;
60 bool active; 60 bool active;
61 61
62
62 vector<Package> packageList; 63 vector<Package> packageList;
63}; 64};
64 65
65#endif 66#endif