summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp3
-rw-r--r--noncore/settings/aqpkg/server.cpp1
2 files changed, 3 insertions, 1 deletions
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp
index 0814121..cf94628 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.cpp
+++ b/noncore/settings/aqpkg/networkpkgmgr.cpp
@@ -1,192 +1,193 @@
1/*************************************************************************** 1/***************************************************************************
2 networkpkgmgr.cpp - description 2 networkpkgmgr.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 <fstream> 18#include <fstream>
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#include "categoryfilterimpl.h"
44 44
45#include "global.h" 45#include "global.h"
46 46
47extern int compareVersions( const char *v1, const char *v2 ); 47extern int compareVersions( const char *v1, const char *v2 );
48 48
49NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) 49NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name)
50 : QWidget(parent, name) 50 : QWidget(parent, name)
51{ 51{
52 dataMgr = dataManager; 52 dataMgr = dataManager;
53 53
54#ifdef QWS 54#ifdef QWS
55 // read download directory from config file 55 // read download directory from config file
56 Config cfg( "aqpkg" ); 56 Config cfg( "aqpkg" );
57 cfg.setGroup( "settings" ); 57 cfg.setGroup( "settings" );
58 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); 58 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" );
59 showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); 59 showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" );
60 60
61#endif 61#endif
62 62
63 showUninstalledPkgs = false; 63 showUninstalledPkgs = false;
64 showInstalledPkgs = false; 64 showInstalledPkgs = false;
65 showUpgradedPkgs = false; 65 showUpgradedPkgs = false;
66 categoryFilterEnabled = false; 66 categoryFilterEnabled = false;
67 67
68 initGui(); 68 initGui();
69 setupConnections(); 69 setupConnections();
70 70
71 updateData(); 71 updateData();
72} 72}
73 73
74NetworkPackageManager::~NetworkPackageManager() 74NetworkPackageManager::~NetworkPackageManager()
75{ 75{
76} 76}
77 77
78void NetworkPackageManager :: timerEvent ( QTimerEvent * ) 78void NetworkPackageManager :: timerEvent ( QTimerEvent * )
79{ 79{
80 killTimer( timerId ); 80 killTimer( timerId );
81 81
82 // Add server names to listbox 82 // Add server names to listbox
83 updateData(); 83 updateData();
84} 84}
85 85
86void NetworkPackageManager :: updateData() 86void NetworkPackageManager :: updateData()
87{ 87{
88 serversList->clear(); 88 serversList->clear();
89 packagesList->clear(); 89 packagesList->clear();
90 90
91 91
92 vector<Server>::iterator it; 92 vector<Server>::iterator it;
93 int activeItem = -1; 93 int activeItem = -1;
94 int i; 94 int i;
95 for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i ) 95 for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i )
96 { 96 {
97 cout << "Adding " << it->getServerName() << " to combobox" << endl;
97 if ( !it->isServerActive() ) 98 if ( !it->isServerActive() )
98 { 99 {
99 i--; 100 i--;
100 continue; 101 continue;
101 } 102 }
102 serversList->insertItem( it->getServerName() ); 103 serversList->insertItem( it->getServerName() );
103 if ( it->getServerName() == currentlySelectedServer ) 104 if ( it->getServerName() == currentlySelectedServer )
104 activeItem = i; 105 activeItem = i;
105 } 106 }
106 107
107 // set selected server to be active server 108 // set selected server to be active server
108 if ( activeItem != -1 ) 109 if ( activeItem != -1 )
109 serversList->setCurrentItem( activeItem ); 110 serversList->setCurrentItem( activeItem );
110 serverSelected( 0 ); 111 serverSelected( 0 );
111} 112}
112 113
113void NetworkPackageManager :: selectLocalPackage( const QString &pkg ) 114void NetworkPackageManager :: selectLocalPackage( const QString &pkg )
114{ 115{
115 // First select local server 116 // First select local server
116 for ( int i = 0 ; i < serversList->count() ; ++i ) 117 for ( int i = 0 ; i < serversList->count() ; ++i )
117 { 118 {
118 if ( serversList->text( i ) == LOCAL_IPKGS ) 119 if ( serversList->text( i ) == LOCAL_IPKGS )
119 { 120 {
120 serversList->setCurrentItem( i ); 121 serversList->setCurrentItem( i );
121 break; 122 break;
122 } 123 }
123 } 124 }
124 serverSelected( 0 ); 125 serverSelected( 0 );
125 126
126 // Now set the check box of the selected package 127 // Now set the check box of the selected package
127 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 128 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
128 item != 0 ; 129 item != 0 ;
129 item = (QCheckListItem *)item->nextSibling() ) 130 item = (QCheckListItem *)item->nextSibling() )
130 { 131 {
131 if ( item->text().startsWith( pkg ) ) 132 if ( item->text().startsWith( pkg ) )
132 { 133 {
133 item->setOn( true ); 134 item->setOn( true );
134 break; 135 break;
135 } 136 }
136 } 137 }
137} 138}
138 139
139 140
140void NetworkPackageManager :: initGui() 141void NetworkPackageManager :: initGui()
141{ 142{
142 QLabel *l = new QLabel( "Servers", this ); 143 QLabel *l = new QLabel( "Servers", this );
143 serversList = new QComboBox( this ); 144 serversList = new QComboBox( this );
144 packagesList = new QListView( this ); 145 packagesList = new QListView( this );
145 update = new QPushButton( "Refresh Lists", this ); 146 update = new QPushButton( "Refresh Lists", this );
146 download = new QPushButton( "Download", this ); 147 download = new QPushButton( "Download", this );
147 upgrade = new QPushButton( "Upgrade", this ); 148 upgrade = new QPushButton( "Upgrade", this );
148 apply = new QPushButton( "Apply", this ); 149 apply = new QPushButton( "Apply", this );
149 150
150 QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" ); 151 QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" );
151 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" ); 152 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" );
152 hbox1->addWidget( l ); 153 hbox1->addWidget( l );
153 hbox1->addWidget( serversList ); 154 hbox1->addWidget( serversList );
154 155
155 QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" ); 156 QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" );
156 QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" ); 157 QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" );
157 158
158 159
159 if ( showJumpTo ) 160 if ( showJumpTo )
160 { 161 {
161 char text[2]; 162 char text[2];
162 text[1] = '\0'; 163 text[1] = '\0';
163 for ( int i = 0 ; i < 26 ; ++i ) 164 for ( int i = 0 ; i < 26 ; ++i )
164 { 165 {
165 text[0] = 'A' + i; 166 text[0] = 'A' + i;
166 LetterPushButton *b = new LetterPushButton( text, this ); 167 LetterPushButton *b = new LetterPushButton( text, this );
167 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); 168 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) );
168 if ( i < 13 ) 169 if ( i < 13 )
169 hbox3->addWidget( b ); 170 hbox3->addWidget( b );
170 else 171 else
171 hbox4->addWidget( b ); 172 hbox4->addWidget( b );
172 } 173 }
173 } 174 }
174 175
175 vbox->addWidget( packagesList ); 176 vbox->addWidget( packagesList );
176 packagesList->addColumn( "Packages" ); 177 packagesList->addColumn( "Packages" );
177 178
178 QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" ); 179 QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" );
179 hbox2->addWidget( update ); 180 hbox2->addWidget( update );
180 hbox2->addWidget( download ); 181 hbox2->addWidget( download );
181 hbox2->addWidget( upgrade ); 182 hbox2->addWidget( upgrade );
182 hbox2->addWidget( apply ); 183 hbox2->addWidget( apply );
183} 184}
184 185
185void NetworkPackageManager :: setupConnections() 186void NetworkPackageManager :: setupConnections()
186{ 187{
187 connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); 188 connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int )));
188 connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) ); 189 connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) );
189 connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) ); 190 connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) );
190 connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) ); 191 connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) );
191 connect( update, SIGNAL(released()), this, SLOT(updateServer()) ); 192 connect( update, SIGNAL(released()), this, SLOT(updateServer()) );
192} 193}
diff --git a/noncore/settings/aqpkg/server.cpp b/noncore/settings/aqpkg/server.cpp
index 726cf00..58407d5 100644
--- a/noncore/settings/aqpkg/server.cpp
+++ b/noncore/settings/aqpkg/server.cpp
@@ -1,143 +1,144 @@
1/*************************************************************************** 1/***************************************************************************
2 server.cpp - description 2 server.cpp - 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 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#include "datamgr.h"
32 32
33#ifdef QWS 33#ifdef QWS
34#include <qpe/global.h> 34#include <qpe/global.h>
35#include <qpe/applnk.h> 35#include <qpe/applnk.h>
36#include <qlist.h> 36#include <qlist.h>
37#endif 37#endif
38 38
39#include "utils.h" 39#include "utils.h"
40 40
41#include "global.h" 41#include "global.h"
42 42
43Server :: Server( const char *name, const char *url ) 43Server :: Server( const char *name, const char *url )
44{ 44{
45 serverName = name; 45 serverName = name;
46 serverUrl = url; 46 serverUrl = url;
47 packageFile = IPKG_DIR; 47 packageFile = IPKG_DIR;
48 active = true;
48 packageFile += "lists/" + serverName; 49 packageFile += "lists/" + serverName;
49} 50}
50 51
51Server :: ~Server() 52Server :: ~Server()
52{ 53{
53 cleanUp(); 54 cleanUp();
54} 55}
55 56
56void Server :: cleanUp() 57void Server :: cleanUp()
57{ 58{
58 packageList.clear(); 59 packageList.clear();
59} 60}
60 61
61void Server :: readStatusFile( vector<Destination> &destList ) 62void Server :: readStatusFile( vector<Destination> &destList )
62{ 63{
63 cleanUp(); 64 cleanUp();
64 65
65 vector<Destination>::iterator dit; 66 vector<Destination>::iterator dit;
66 bool rootRead = false; 67 bool rootRead = false;
67 for ( dit = destList.begin() ; dit != destList.end() ; ++dit ) 68 for ( dit = destList.begin() ; dit != destList.end() ; ++dit )
68 { 69 {
69 bool installingToRoot = false; 70 bool installingToRoot = false;
70 71
71 QString path = dit->getDestinationPath(); 72 QString path = dit->getDestinationPath();
72 if ( path.right( 1 ) != "/" ) 73 if ( path.right( 1 ) != "/" )
73 path += "/"; 74 path += "/";
74 75
75 if ( path == "/" ) 76 if ( path == "/" )
76 { 77 {
77 rootRead = true; 78 rootRead = true;
78 installingToRoot = true; 79 installingToRoot = true;
79 } 80 }
80 81
81 packageFile = path + "usr/lib/ipkg/status"; 82 packageFile = path + "usr/lib/ipkg/status";
82 readPackageFile( 0, false, installingToRoot, dit ); 83 readPackageFile( 0, false, installingToRoot, dit );
83 } 84 }
84 85
85 // Ensure that the root status file is read 86 // Ensure that the root status file is read
86 if ( !rootRead ) 87 if ( !rootRead )
87 { 88 {
88 cout << "Reading status file " << "/usr/lib/ipkg/status" << endl; 89 cout << "Reading status file " << "/usr/lib/ipkg/status" << endl;
89 packageFile = "/usr/lib/ipkg/status"; 90 packageFile = "/usr/lib/ipkg/status";
90 readPackageFile( 0, false, true ); 91 readPackageFile( 0, false, true );
91 } 92 }
92} 93}
93 94
94void Server :: readLocalIpks( Server *local ) 95void Server :: readLocalIpks( Server *local )
95{ 96{
96 cleanUp(); 97 cleanUp();
97 98
98#ifdef QWS 99#ifdef QWS
99 // First, get any local IPKGs in the documents area 100 // First, get any local IPKGs in the documents area
100 // Only applicable to Qtopie/Opie 101 // Only applicable to Qtopie/Opie
101 102
102 DocLnkSet files; 103 DocLnkSet files;
103 Global::findDocuments( &files, "application/ipkg" ); 104 Global::findDocuments( &files, "application/ipkg" );
104 105
105 // Now add the items to the list 106 // Now add the items to the list
106 QListIterator<DocLnk> it( files.children() ); 107 QListIterator<DocLnk> it( files.children() );
107 108
108 for ( ; it.current() ; ++it ) 109 for ( ; it.current() ; ++it )
109 { 110 {
110 // OK, we have a local IPK file, I think the standard naming conventions 111 // OK, we have a local IPK file, I think the standard naming conventions
111 // for these are packagename_version_arm.ipk 112 // for these are packagename_version_arm.ipk
112 QString file = (*it)->file(); 113 QString file = (*it)->file();
113 114
114 // Changed to display the filename (excluding the path) 115 // Changed to display the filename (excluding the path)
115 QString packageName = Utils::getFilenameFromIpkFilename( file ); 116 QString packageName = Utils::getFilenameFromIpkFilename( file );
116 QString ver = Utils::getPackageVersionFromIpkFilename( file ); 117 QString ver = Utils::getPackageVersionFromIpkFilename( file );
117 packageList.push_back( Package( packageName ) ); 118 packageList.push_back( Package( packageName ) );
118 packageList.back().setVersion( ver ); 119 packageList.back().setVersion( ver );
119 packageList.back().setFilename( file ); 120 packageList.back().setFilename( file );
120 packageList.back().setPackageStoredLocally( true ); 121 packageList.back().setPackageStoredLocally( true );
121 122
122 } 123 }
123#else 124#else
124 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" }; 125 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" };
125 for ( int i = 0 ; i < 4 ; ++i ) 126 for ( int i = 0 ; i < 4 ; ++i )
126 { 127 {
127 // OK, we have a local IPK file, I think the standard naming conventions 128 // OK, we have a local IPK file, I think the standard naming conventions
128 // for these are packagename_version_arm.ipk 129 // for these are packagename_version_arm.ipk
129 QString file = names[i]; 130 QString file = names[i];
130 int p = file.find( "_" ); 131 int p = file.find( "_" );
131 QString tmp = file.mid( 0, p ); 132 QString tmp = file.mid( 0, p );
132 packageList.push_back( Package( tmp ) ); 133 packageList.push_back( Package( tmp ) );
133 int p2 = file.find( "_", p+1 ); 134 int p2 = file.find( "_", p+1 );
134 tmp = file.mid( p+1, p2-(p+1) ); 135 tmp = file.mid( p+1, p2-(p+1) );
135 packageList.back().setVersion( tmp ); 136 packageList.back().setVersion( tmp );
136 packageList.back().setPackageStoredLocally( true ); 137 packageList.back().setPackageStoredLocally( true );
137 } 138 }
138#endif 139#endif
139 140
140 // build local packages 141 // build local packages
141 buildLocalPackages( local ); 142 buildLocalPackages( local );
142} 143}
143 144