summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/datamgr.cpp45
1 files changed, 7 insertions, 38 deletions
diff --git a/noncore/settings/aqpkg/datamgr.cpp b/noncore/settings/aqpkg/datamgr.cpp
index bb86766..7c49621 100644
--- a/noncore/settings/aqpkg/datamgr.cpp
+++ b/noncore/settings/aqpkg/datamgr.cpp
@@ -77,87 +77,56 @@ void DataManager :: loadServers()
77 char line[130]; 77 char line[130];
78 QString lineStr; 78 QString lineStr;
79 if ( fp == NULL ) 79 if ( fp == NULL )
80 { 80 {
81 cout << "Couldn't open " << ipkg_conf << "! err = " << fp << endl; 81 cout << "Couldn't open " << ipkg_conf << "! err = " << fp << endl;
82 return; 82 return;
83 } 83 }
84 else 84 else
85 { 85 {
86 while ( fgets( line, sizeof line, fp) != NULL ) 86 while ( fgets( line, sizeof line, fp) != NULL )
87 { 87 {
88 lineStr = line; 88 lineStr = line;
89 if ( lineStr.startsWith( "src" ) || lineStr.startsWith( "#src" ) || lineStr.startsWith( "# src" ) ) 89 if ( lineStr.startsWith( "src" ) ) //|| lineStr.startsWith( "#src" ) || lineStr.startsWith( "# src" ) )
90 { 90 {
91 char alias[20]; 91 char alias[20];
92 char url[100]; 92 char url[100];
93 93
94 94
95 // Looks a little wierd but read up to the r of src (throwing it away), 95 // 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 96 // then read up to the next space and throw that away, the alias
97 // is next. 97 // is next.
98 // Should Handle #src, # src, src, and combinations of 98 // Should Handle #src, # src, src, and combinations of
99 sscanf( lineStr, "%*[^r]%*[^ ] %s %s", alias, url ); 99 sscanf( lineStr, "%*[^r]%*[^ ] %s %s", alias, url );
100 Server s( alias, url ); 100 Server s( alias, url );
101 if ( lineStr.startsWith( "src" ) )
102 s.setActive( true );
103 else
104 s.setActive( false );
105
101 serverList.push_back( s ); 106 serverList.push_back( s );
102 107
103 if ( lineStr.startsWith( "src" ) )
104 setActiveServer( alias );
105 } 108 }
106 else if ( lineStr.startsWith( "dest" ) ) 109 else if ( lineStr.startsWith( "dest" ) )
107 { 110 {
108 char alias[20]; 111 char alias[20];
109 char path[50]; 112 char path[50];
110 sscanf( lineStr, "%*[^ ] %s %s", alias, path ); 113 sscanf( lineStr, "%*[^ ] %s %s", alias, path );
111 Destination d( alias, path ); 114 Destination d( alias, path );
112 destList.push_back( d ); 115 destList.push_back( d );
113 } 116 }
114 } 117 }
115 } 118 }
116 fclose( fp ); 119 fclose( fp );
117 120
118 // Go through the server destination list and add root, cf and card if they
119 // don't already exist
120/* AQ - commented out as if you don't have a CF or SD card in then
121 * this causes IPKG to try to create directories on non existant devices
122 * (which of course fails), gives a nasty error message and can cause ipkg
123 * to seg fault.
124 *
125 vector<Destination>::iterator dit;
126 bool foundRoot = false;
127 bool foundCF = false;
128 bool foundCard = false;
129 for ( dit = destList.begin() ; dit != destList.end() ; ++dit )
130 {
131 if ( dit->getDestinationPath() == "/" )
132 foundRoot = true;
133 if ( dit->getDestinationPath() == "/mnt/cf" )
134 foundCF = true;
135 if ( dit->getDestinationPath() == "/mnt/card" )
136 foundCard = true;
137 }
138
139 // If running on a Zaurus (arm) then if we didn't find root, CF or card
140 // destinations, add them as default
141#ifdef QWS
142#ifndef X86
143 if ( !foundRoot )
144 destList.push_back( Destination( "root", "/" ) );
145 if ( !foundCF )
146 destList.push_back( Destination( "cf", "/mnt/cf" ) );
147 if ( !foundCF )
148 destList.push_back( Destination( "card", "/mnt/card" ) );
149#endif
150#endif
151*/
152 vector<Server>::iterator it; 121 vector<Server>::iterator it;
153 for ( it = serverList.begin() ; it != serverList.end() ; ++it ) 122 for ( it = serverList.begin() ; it != serverList.end() ; ++it )
154 reloadServerData( it->getServerName() ); 123 reloadServerData( it->getServerName() );
155} 124}
156 125
157void DataManager :: reloadServerData( const char *serverName ) 126void DataManager :: reloadServerData( const char *serverName )
158{ 127{
159 Server *s = getServer( serverName ); 128 Server *s = getServer( serverName );
160 // Now we've read the config file in we need to read the servers 129 // Now we've read the config file in we need to read the servers
161 // The local server is a special case. This holds the contents of the 130 // The local server is a special case. This holds the contents of the
162 // status files the number of which depends on how many destinations 131 // status files the number of which depends on how many destinations
163 // we've set up 132 // we've set up
@@ -192,25 +161,25 @@ void DataManager :: writeOutIpkgConf()
192 out << "# that exists on the target system." << endl << endl; 161 out << "# that exists on the target system." << endl << endl;
193 162
194 // Write out servers 163 // Write out servers
195 vector<Server>::iterator it = serverList.begin(); 164 vector<Server>::iterator it = serverList.begin();
196 while ( it != serverList.end() ) 165 while ( it != serverList.end() )
197 { 166 {
198 QString alias = it->getServerName(); 167 QString alias = it->getServerName();
199 // Don't write out local as its a dummy 168 // Don't write out local as its a dummy
200 if ( alias != LOCAL_SERVER && alias != LOCAL_IPKGS ) 169 if ( alias != LOCAL_SERVER && alias != LOCAL_IPKGS )
201 { 170 {
202 QString url = it->getServerUrl();; 171 QString url = it->getServerUrl();;
203 172
204 if ( !activeServer || alias != activeServer ) 173 if ( !it->isServerActive() )
205 out << "#"; 174 out << "#";
206 out << "src " << alias << " " << url << endl; 175 out << "src " << alias << " " << url << endl;
207 } 176 }
208 177
209 it++; 178 it++;
210 } 179 }
211 180
212 out << endl; 181 out << endl;
213 182
214 // Write out destinations 183 // Write out destinations
215 vector<Destination>::iterator it2 = destList.begin(); 184 vector<Destination>::iterator it2 = destList.begin();
216 while ( it2 != destList.end() ) 185 while ( it2 != destList.end() )