summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/server.cpp13
-rw-r--r--noncore/settings/aqpkg/server.h3
2 files changed, 11 insertions, 5 deletions
diff --git a/noncore/settings/aqpkg/server.cpp b/noncore/settings/aqpkg/server.cpp
index 0069a60..7d103a2 100644
--- a/noncore/settings/aqpkg/server.cpp
+++ b/noncore/settings/aqpkg/server.cpp
@@ -69,25 +69,25 @@ void Server :: readStatusFile( vector<Destination> &destList )
69 69
70 QString path = dit->getDestinationPath(); 70 QString path = dit->getDestinationPath();
71 if ( path.right( 1 ) != "/" ) 71 if ( path.right( 1 ) != "/" )
72 path += "/"; 72 path += "/";
73 73
74 if ( path == "/" ) 74 if ( path == "/" )
75 { 75 {
76 rootRead = true; 76 rootRead = true;
77 installingToRoot = true; 77 installingToRoot = true;
78 } 78 }
79 79
80 packageFile = path + "usr/lib/ipkg/status"; 80 packageFile = path + "usr/lib/ipkg/status";
81 readPackageFile( 0, false, installingToRoot ); 81 readPackageFile( 0, false, installingToRoot, dit );
82 } 82 }
83 83
84 // Ensure that the root status file is read 84 // Ensure that the root status file is read
85 if ( !rootRead ) 85 if ( !rootRead )
86 { 86 {
87 cout << "Reading status file " << "/usr/lib/ipkg/status" << endl; 87 cout << "Reading status file " << "/usr/lib/ipkg/status" << endl;
88 packageFile = "/usr/lib/ipkg/status"; 88 packageFile = "/usr/lib/ipkg/status";
89 readPackageFile( 0, false, true ); 89 readPackageFile( 0, false, true );
90 } 90 }
91} 91}
92 92
93void Server :: readLocalIpks( Server *local ) 93void Server :: readLocalIpks( Server *local )
@@ -130,25 +130,25 @@ void Server :: readLocalIpks( Server *local )
130 packageList.push_back( Package( tmp ) ); 130 packageList.push_back( Package( tmp ) );
131 int p2 = file.find( "_", p+1 ); 131 int p2 = file.find( "_", p+1 );
132 tmp = file.mid( p+1, p2-(p+1) ); 132 tmp = file.mid( p+1, p2-(p+1) );
133 packageList.back().setVersion( tmp ); 133 packageList.back().setVersion( tmp );
134 packageList.back().setPackageStoredLocally( true ); 134 packageList.back().setPackageStoredLocally( true );
135 } 135 }
136#endif 136#endif
137 137
138 // build local packages 138 // build local packages
139 buildLocalPackages( local ); 139 buildLocalPackages( local );
140} 140}
141 141
142void Server :: readPackageFile( Server *local, bool clearAll, bool installingToRoot ) 142void Server :: readPackageFile( Server *local, bool clearAll, bool installingToRoot, Destination *dest )
143{ 143{
144 ifstream in( packageFile ); 144 ifstream in( packageFile );
145 if ( !in.is_open() ) 145 if ( !in.is_open() )
146 return; 146 return;
147 147
148 char line[1001]; 148 char line[1001];
149 char k[21]; 149 char k[21];
150 char v[1001]; 150 char v[1001];
151 QString key; 151 QString key;
152 QString value; 152 QString value;
153 153
154 if ( clearAll ) 154 if ( clearAll )
@@ -159,38 +159,45 @@ void Server :: readPackageFile( Server *local, bool clearAll, bool installingToR
159 do 159 do
160 { 160 {
161 in.getline( line, 1000 ); 161 in.getline( line, 1000 );
162 if ( in.eof() ) 162 if ( in.eof() )
163 continue; 163 continue;
164 164
165 k[0] = '\0'; 165 k[0] = '\0';
166 v[0] = '\0'; 166 v[0] = '\0';
167 167
168 sscanf( line, "%[^:]: %[^\n]", k, v ); 168 sscanf( line, "%[^:]: %[^\n]", k, v );
169 key = k; 169 key = k;
170 value = v; 170 value = v;
171 key.stripWhiteSpace(); 171 key = key.stripWhiteSpace();
172 value = value.stripWhiteSpace();
172 if ( key == "Package" && newPackage ) 173 if ( key == "Package" && newPackage )
173 { 174 {
174 newPackage = false; 175 newPackage = false;
175 176
176 currPackage = getPackage( value ); 177 currPackage = getPackage( value );
177 if ( !currPackage ) 178 if ( !currPackage )
178 { 179 {
179 packageList.push_back( Package( value ) ); 180 packageList.push_back( Package( value ) );
180 currPackage = &(packageList.back()); 181 currPackage = &(packageList.back());
182 currPackage->setInstalledTo( dest );
181 183
182 if ( installingToRoot ) 184 if ( installingToRoot )
183 currPackage->setInstalledToRoot( true ); 185 currPackage->setInstalledToRoot( true );
184 } 186 }
187 else
188 {
189 if (currPackage->getStatus().find( "deinstall" ) != -1 )
190 currPackage->setInstalledTo( dest );
191 }
185 } 192 }
186 else if ( key == "Version" ) 193 else if ( key == "Version" )
187 { 194 {
188 if ( currPackage ) 195 if ( currPackage )
189 currPackage->setVersion( value ); 196 currPackage->setVersion( value );
190 } 197 }
191 else if ( key == "Status" ) 198 else if ( key == "Status" )
192 { 199 {
193 if ( currPackage ) 200 if ( currPackage )
194 currPackage->setStatus( value ); 201 currPackage->setStatus( value );
195 } 202 }
196 else if ( key == "Description" ) 203 else if ( key == "Description" )
diff --git a/noncore/settings/aqpkg/server.h b/noncore/settings/aqpkg/server.h
index 5f83f75..e9f434c 100644
--- a/noncore/settings/aqpkg/server.h
+++ b/noncore/settings/aqpkg/server.h
@@ -28,39 +28,38 @@ using namespace std;
28class Server 28class Server
29{ 29{
30public: 30public:
31 Server() {} 31 Server() {}
32 Server( const char *name, const char *url ); 32 Server( const char *name, const char *url );
33 Server( const char *name, const char *url, const char *file ); 33 Server( const char *name, const char *url, const char *file );
34 ~Server(); 34 ~Server();
35 35
36 void cleanUp(); 36 void cleanUp();
37 37
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 ); 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
63 vector<Package> packageList; 62 vector<Package> packageList;
64}; 63};
65 64
66#endif 65#endif