summaryrefslogtreecommitdiff
path: root/noncore
Unidiff
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/datamgr.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/noncore/settings/aqpkg/datamgr.cpp b/noncore/settings/aqpkg/datamgr.cpp
index d929c39..089c3e3 100644
--- a/noncore/settings/aqpkg/datamgr.cpp
+++ b/noncore/settings/aqpkg/datamgr.cpp
@@ -1,44 +1,48 @@
1/*************************************************************************** 1/***************************************************************************
2 datamgr.cpp - description 2 datamgr.cpp - 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#include <fstream> 17#include <fstream>
18#include <iostream> 18#include <iostream>
19using namespace std; 19using namespace std;
20 20
21#ifdef QWS
22#include <qpe/config.h>
23#endif
24
21#include <stdio.h> 25#include <stdio.h>
22 26
23#include "datamgr.h" 27#include "datamgr.h"
24#include "global.h" 28#include "global.h"
25 29
26 30
27DataManager::DataManager() 31DataManager::DataManager()
28{ 32{
29 activeServer = ""; 33 activeServer = "";
30} 34}
31 35
32DataManager::~DataManager() 36DataManager::~DataManager()
33{ 37{
34} 38}
35 39
36Server *DataManager :: getServer( const char *name ) 40Server *DataManager :: getServer( const char *name )
37{ 41{
38 Server *s = 0; 42 Server *s = 0;
39 vector<Server>::iterator it = serverList.begin(); 43 vector<Server>::iterator it = serverList.begin();
40 while ( it != serverList.end() && s == 0 ) 44 while ( it != serverList.end() && s == 0 )
41 { 45 {
42 if ( it->getServerName() == name ) 46 if ( it->getServerName() == name )
43 s = &(*it); 47 s = &(*it);
44 48
@@ -49,90 +53,103 @@ Server *DataManager :: getServer( const char *name )
49} 53}
50 54
51Destination *DataManager :: getDestination( const char *name ) 55Destination *DataManager :: getDestination( const char *name )
52{ 56{
53 Destination *d = 0; 57 Destination *d = 0;
54 vector<Destination>::iterator it = destList.begin(); 58 vector<Destination>::iterator it = destList.begin();
55 while ( it != destList.end() && d == 0 ) 59 while ( it != destList.end() && d == 0 )
56 { 60 {
57 if ( it->getDestinationName() == name ) 61 if ( it->getDestinationName() == name )
58 d = &(*it); 62 d = &(*it);
59 63
60 ++it; 64 ++it;
61 } 65 }
62 66
63 return d; 67 return d;
64} 68}
65 69
66void DataManager :: loadServers() 70void DataManager :: loadServers()
67{ 71{
68 // First add our local server - not really a server but 72 // First add our local server - not really a server but
69 // the local config (which packages are installed) 73 // the local config (which packages are installed)
70 serverList.push_back( Server( LOCAL_SERVER, "" ) ); 74 serverList.push_back( Server( LOCAL_SERVER, "" ) );
71 serverList.push_back( Server( LOCAL_IPKGS, "" ) ); 75 serverList.push_back( Server( LOCAL_IPKGS, "" ) );
72 76
77#ifdef QWS
78 Config cfg( "aqpkg" );
79 cfg.setGroup( "destinations" );
80#endif
81
73 // Read file from /etc/ipkg.conf 82 // Read file from /etc/ipkg.conf
74 QString ipkg_conf = IPKG_CONF; 83 QString ipkg_conf = IPKG_CONF;
75 FILE *fp; 84 FILE *fp;
76 fp = fopen( ipkg_conf, "r" ); 85 fp = fopen( ipkg_conf, "r" );
77 char line[130]; 86 char line[130];
78 QString lineStr; 87 QString lineStr;
79 if ( fp == NULL ) 88 if ( fp == NULL )
80 { 89 {
81 cout << "Couldn't open " << ipkg_conf << "! err = " << fp << endl; 90 cout << "Couldn't open " << ipkg_conf << "! err = " << fp << endl;
82 return; 91 return;
83 } 92 }
84 else 93 else
85 { 94 {
86 while ( fgets( line, sizeof line, fp) != NULL ) 95 while ( fgets( line, sizeof line, fp) != NULL )
87 { 96 {
88 lineStr = line; 97 lineStr = line;
89 if ( lineStr.startsWith( "src" ) || lineStr.startsWith( "#src" ) || lineStr.startsWith( "# src" ) ) 98 if ( lineStr.startsWith( "src" ) || lineStr.startsWith( "#src" ) || lineStr.startsWith( "# src" ) )
90 { 99 {
91 char alias[20]; 100 char alias[20];
92 char url[100]; 101 char url[100];
93 102
94 103
95 // Looks a little wierd but read up to the r of src (throwing it away), 104 // Looks a little wierd but read up to the r of src (throwing it away),
96 // then read up to the next space and throw that away, the alias 105 // then read up to the next space and throw that away, the alias
97 // is next. 106 // is next.
98 // Should Handle #src, # src, src, and combinations of 107 // Should Handle #src, # src, src, and combinations of
99 sscanf( lineStr, "%*[^r]%*[^ ] %s %s", alias, url ); 108 sscanf( lineStr, "%*[^r]%*[^ ] %s %s", alias, url );
100 Server s( alias, url ); 109 Server s( alias, url );
101 if ( lineStr.startsWith( "src" ) ) 110 if ( lineStr.startsWith( "src" ) )
102 s.setActive( true ); 111 s.setActive( true );
103 else 112 else
104 s.setActive( false ); 113 s.setActive( false );
105 114
106 serverList.push_back( s ); 115 serverList.push_back( s );
107 116
108 } 117 }
109 else if ( lineStr.startsWith( "dest" ) ) 118 else if ( lineStr.startsWith( "dest" ) )
110 { 119 {
111 char alias[20]; 120 char alias[20];
112 char path[50]; 121 char path[50];
113 sscanf( lineStr, "%*[^ ] %s %s", alias, path ); 122 sscanf( lineStr, "%*[^ ] %s %s", alias, path );
114 Destination d( alias, path ); 123 Destination d( alias, path );
124 bool linkToRoot = true;
125#ifdef QWS
126 QString key = alias;
127 key += "_linkToRoot";
128 linkToRoot = cfg.readBoolEntry( key, true );
129#endif
130 d.linkToRoot( linkToRoot );
131
115 destList.push_back( d ); 132 destList.push_back( d );
116 } 133 }
117 } 134 }
118 } 135 }
119 fclose( fp ); 136 fclose( fp );
120 137
121 vector<Server>::iterator it; 138 vector<Server>::iterator it;
122 for ( it = serverList.begin() ; it != serverList.end() ; ++it ) 139 for ( it = serverList.begin() ; it != serverList.end() ; ++it )
123 reloadServerData( it->getServerName() ); 140 reloadServerData( it->getServerName() );
124} 141}
125 142
126void DataManager :: reloadServerData( const char *serverName ) 143void DataManager :: reloadServerData( const char *serverName )
127{ 144{
128 Server *s = getServer( serverName ); 145 Server *s = getServer( serverName );
129 // Now we've read the config file in we need to read the servers 146 // Now we've read the config file in we need to read the servers
130 // The local server is a special case. This holds the contents of the 147 // The local server is a special case. This holds the contents of the
131 // status files the number of which depends on how many destinations 148 // status files the number of which depends on how many destinations
132 // we've set up 149 // we've set up
133 // The other servers files hold the contents of the server package list 150 // The other servers files hold the contents of the server package list
134 if ( s->getServerName() == LOCAL_SERVER ) 151 if ( s->getServerName() == LOCAL_SERVER )
135 s->readStatusFile( destList ); 152 s->readStatusFile( destList );
136 else if ( s->getServerName() == LOCAL_IPKGS ) 153 else if ( s->getServerName() == LOCAL_IPKGS )
137 s->readLocalIpks( getServer( LOCAL_SERVER ) ); 154 s->readLocalIpks( getServer( LOCAL_SERVER ) );
138 else 155 else