author | andyq <andyq> | 2002-11-23 15:27:45 (UTC) |
---|---|---|
committer | andyq <andyq> | 2002-11-23 15:27:45 (UTC) |
commit | bf0cc4c950f0a96bf7091e730744a2b3eb6cc751 (patch) (unidiff) | |
tree | 97fb1d7337da8659bbcdaf0343de7d76cc4d7d1c | |
parent | 7763c095d81f44cd3012d894da6b17eb0b0cc194 (diff) | |
download | opie-bf0cc4c950f0a96bf7091e730744a2b3eb6cc751.zip opie-bf0cc4c950f0a96bf7091e730744a2b3eb6cc751.tar.gz opie-bf0cc4c950f0a96bf7091e730744a2b3eb6cc751.tar.bz2 |
*** empty log message ***
-rw-r--r-- | noncore/settings/aqpkg/server.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/noncore/settings/aqpkg/server.cpp b/noncore/settings/aqpkg/server.cpp index 2cb0533..fc5ed12 100644 --- a/noncore/settings/aqpkg/server.cpp +++ b/noncore/settings/aqpkg/server.cpp | |||
@@ -39,136 +39,136 @@ using namespace std; | |||
39 | #include "utils.h" | 39 | #include "utils.h" |
40 | 40 | ||
41 | #include "global.h" | 41 | #include "global.h" |
42 | 42 | ||
43 | Server :: Server( const char *name, const char *url ) | 43 | Server :: 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 | active = true; |
49 | packageFile += "lists/" + serverName; | 49 | packageFile += "lists/" + serverName; |
50 | } | 50 | } |
51 | 51 | ||
52 | Server :: ~Server() | 52 | Server :: ~Server() |
53 | { | 53 | { |
54 | cleanUp(); | 54 | cleanUp(); |
55 | } | 55 | } |
56 | 56 | ||
57 | void Server :: cleanUp() | 57 | void Server :: cleanUp() |
58 | { | 58 | { |
59 | packageList.clear(); | 59 | packageList.clear(); |
60 | } | 60 | } |
61 | 61 | ||
62 | void Server :: readStatusFile( vector<Destination> &destList ) | 62 | void Server :: readStatusFile( vector<Destination> &destList ) |
63 | { | 63 | { |
64 | cleanUp(); | 64 | cleanUp(); |
65 | 65 | ||
66 | vector<Destination>::iterator dit; | 66 | vector<Destination>::iterator dit; |
67 | bool rootRead = false; | 67 | bool rootRead = false; |
68 | for ( dit = destList.begin() ; dit != destList.end() ; ++dit ) | 68 | for ( dit = destList.begin() ; dit != destList.end() ; ++dit ) |
69 | { | 69 | { |
70 | bool installingToRoot = false; | 70 | bool installingToRoot = false; |
71 | 71 | ||
72 | QString path = dit->getDestinationPath(); | 72 | QString path = dit->getDestinationPath(); |
73 | if ( path.right( 1 ) != "/" ) | 73 | if ( path.right( 1 ) != "/" ) |
74 | path += "/"; | 74 | path += "/"; |
75 | 75 | ||
76 | if ( path == "/" ) | 76 | if ( path == "/" ) |
77 | { | 77 | { |
78 | rootRead = true; | 78 | rootRead = true; |
79 | installingToRoot = true; | 79 | installingToRoot = true; |
80 | } | 80 | } |
81 | 81 | ||
82 | packageFile = path + "usr/lib/ipkg/status"; | 82 | packageFile = path + "usr/lib/ipkg/status"; |
83 | readPackageFile( 0, false, installingToRoot, &( *dit ) ); | 83 | readPackageFile( 0, false, installingToRoot, &( *dit ) ); |
84 | } | 84 | } |
85 | 85 | ||
86 | // Ensure that the root status file is read | 86 | // Ensure that the root status file is read |
87 | if ( !rootRead ) | 87 | if ( !rootRead ) |
88 | { | 88 | { |
89 | cout << "Reading status file " << "/usr/lib/ipkg/status" << endl; | 89 | cout << "Reading status file " << "/usr/lib/ipkg/status" << endl; |
90 | packageFile = "/usr/lib/ipkg/status"; | 90 | packageFile = "/usr/lib/ipkg/status"; |
91 | readPackageFile( 0, false, true ); | 91 | readPackageFile( 0, false, true ); |
92 | } | 92 | } |
93 | } | 93 | } |
94 | 94 | ||
95 | void Server :: readLocalIpks( Server *local ) | 95 | void Server :: readLocalIpks( Server *local ) |
96 | { | 96 | { |
97 | cleanUp(); | 97 | cleanUp(); |
98 | 98 | ||
99 | #ifdef QWS | 99 | #ifdef QWS |
100 | // First, get any local IPKGs in the documents area | 100 | // First, get any local IPKGs in the documents area |
101 | // Only applicable to Qtopie/Opie | 101 | // Only applicable to Qtopie/Opie |
102 | 102 | ||
103 | DocLnkSet files; | 103 | DocLnkSet files; |
104 | Global::findDocuments( &files, "application/ipkg" ); | 104 | Global::findDocuments( &files, "application/ipkg" ); |
105 | 105 | ||
106 | // Now add the items to the list | 106 | // Now add the items to the list |
107 | QListIterator<DocLnk> it( files.children() ); | 107 | QListIterator<DocLnk> it( files.children() ); |
108 | 108 | ||
109 | for ( ; it.current() ; ++it ) | 109 | for ( ; it.current() ; ++it ) |
110 | { | 110 | { |
111 | // 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 |
112 | // for these are packagename_version_arm.ipk | 112 | // for these are packagename_version_arm.ipk |
113 | QString file = (*it)->file(); | 113 | QString file = (*it)->file(); |
114 | 114 | ||
115 | // Changed to display the filename (excluding the path) | 115 | // Changed to display the filename (excluding the path) |
116 | QString packageName = Utils::getFilenameFromIpkFilename( file ); | 116 | QString packageName = Utils::getFilenameFromIpkFilename( file ); |
117 | QString ver = Utils::getPackageVersionFromIpkFilename( file ); | 117 | QString ver = Utils::getPackageVersionFromIpkFilename( file ); |
118 | packageList.push_back( Package( packageName ) ); | 118 | packageList.push_back( Package( packageName ) ); |
119 | packageList.back().setVersion( ver ); | 119 | packageList.back().setVersion( ver ); |
120 | packageList.back().setFilename( file ); | 120 | packageList.back().setFilename( file ); |
121 | packageList.back().setPackageStoredLocally( true ); | 121 | packageList.back().setPackageStoredLocally( true ); |
122 | 122 | ||
123 | } | 123 | } |
124 | #else | 124 | #else |
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 | 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" }; |
126 | for ( int i = 0 ; i < 4 ; ++i ) | 126 | for ( int i = 0 ; i < 4 ; ++i ) |
127 | { | 127 | { |
128 | // 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 |
129 | // for these are packagename_version_arm.ipk | 129 | // for these are packagename_version_arm.ipk |
130 | QString file = names[i]; | 130 | QString file = names[i]; |
131 | int p = file.find( "_" ); | 131 | int p = file.find( "_" ); |
132 | QString tmp = file.mid( 0, p ); | 132 | QString tmp = file.mid( 0, p ); |
133 | packageList.push_back( Package( tmp ) ); | 133 | packageList.push_back( Package( tmp ) ); |
134 | int p2 = file.find( "_", p+1 ); | 134 | int p2 = file.find( "_", p+1 ); |
135 | tmp = file.mid( p+1, p2-(p+1) ); | 135 | tmp = file.mid( p+1, p2-(p+1) ); |
136 | packageList.back().setVersion( tmp ); | 136 | packageList.back().setVersion( tmp ); |
137 | packageList.back().setPackageStoredLocally( true ); | 137 | packageList.back().setPackageStoredLocally( true ); |
138 | } | 138 | } |
139 | #endif | 139 | #endif |
140 | 140 | ||
141 | // build local packages | 141 | // build local packages |
142 | buildLocalPackages( local ); | 142 | buildLocalPackages( local ); |
143 | } | 143 | } |
144 | 144 | ||
145 | void Server :: readPackageFile( Server *local, bool clearAll, bool installingToRoot, Destination *dest ) | 145 | void Server :: readPackageFile( Server *local, bool clearAll, bool installingToRoot, Destination *dest ) |
146 | { | 146 | { |
147 | ifstream in( packageFile ); | 147 | ifstream in( packageFile ); |
148 | if ( !in.is_open() ) | 148 | if ( !in.is_open() ) |
149 | return; | 149 | return; |
150 | 150 | ||
151 | char line[1001]; | 151 | char line[1001]; |
152 | char k[21]; | 152 | char k[21]; |
153 | char v[1001]; | 153 | char v[1001]; |
154 | QString key; | 154 | QString key; |
155 | QString value; | 155 | QString value; |
156 | 156 | ||
157 | if ( clearAll ) | 157 | if ( clearAll ) |
158 | cleanUp(); | 158 | cleanUp(); |
159 | Package *currPackage = 0; | 159 | Package *currPackage = 0; |
160 | 160 | ||
161 | bool newPackage = true; | 161 | bool newPackage = true; |
162 | do | 162 | do |
163 | { | 163 | { |
164 | in.getline( line, 1000 ); | 164 | in.getline( line, 1000 ); |
165 | if ( in.eof() ) | 165 | if ( in.eof() ) |
166 | continue; | 166 | continue; |
167 | 167 | ||
168 | k[0] = '\0'; | 168 | k[0] = '\0'; |
169 | v[0] = '\0'; | 169 | v[0] = '\0'; |
170 | 170 | ||
171 | sscanf( line, "%[^:]: %[^\n]", k, v ); | 171 | sscanf( line, "%[^:]: %[^\n]", k, v ); |
172 | key = k; | 172 | key = k; |
173 | value = v; | 173 | value = v; |
174 | key = key.stripWhiteSpace(); | 174 | key = key.stripWhiteSpace(); |