summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/aqpkg/datamgr.cpp45
-rw-r--r--noncore/settings/aqpkg/datamgr.h4
2 files changed, 48 insertions, 1 deletions
diff --git a/noncore/settings/aqpkg/datamgr.cpp b/noncore/settings/aqpkg/datamgr.cpp
index 1420242..e7fb75a 100644
--- a/noncore/settings/aqpkg/datamgr.cpp
+++ b/noncore/settings/aqpkg/datamgr.cpp
@@ -93,25 +93,24 @@ void DataManager :: loadServers()
93 return; 93 return;
94 } 94 }
95 else 95 else
96 { 96 {
97 while ( fgets( line, sizeof line, fp) != NULL ) 97 while ( fgets( line, sizeof line, fp) != NULL )
98 { 98 {
99 lineStr = line; 99 lineStr = line;
100 if ( lineStr.startsWith( "src" ) || lineStr.startsWith( "#src" ) || lineStr.startsWith( "# src" ) ) 100 if ( lineStr.startsWith( "src" ) || lineStr.startsWith( "#src" ) || lineStr.startsWith( "# src" ) )
101 { 101 {
102 char alias[20]; 102 char alias[20];
103 char url[100]; 103 char url[100];
104 104
105
106 // Looks a little wierd but read up to the r of src (throwing it away), 105 // Looks a little wierd but read up to the r of src (throwing it away),
107 // then read up to the next space and throw that away, the alias 106 // then read up to the next space and throw that away, the alias
108 // is next. 107 // is next.
109 // Should Handle #src, # src, src, and combinations of 108 // Should Handle #src, # src, src, and combinations of
110 sscanf( lineStr, "%*[^r]%*[^ ] %s %s", alias, url ); 109 sscanf( lineStr, "%*[^r]%*[^ ] %s %s", alias, url );
111 Server s( alias, url ); 110 Server s( alias, url );
112 if ( lineStr.startsWith( "src" ) ) 111 if ( lineStr.startsWith( "src" ) )
113 s.setActive( true ); 112 s.setActive( true );
114 else 113 else
115 s.setActive( false ); 114 s.setActive( false );
116 115
117 serverList.push_back( s ); 116 serverList.push_back( s );
@@ -124,28 +123,47 @@ void DataManager :: loadServers()
124 sscanf( lineStr, "%*[^ ] %s %s", alias, path ); 123 sscanf( lineStr, "%*[^ ] %s %s", alias, path );
125 Destination d( alias, path ); 124 Destination d( alias, path );
126 bool linkToRoot = true; 125 bool linkToRoot = true;
127#ifdef QWS 126#ifdef QWS
128 QString key = alias; 127 QString key = alias;
129 key += "_linkToRoot"; 128 key += "_linkToRoot";
130 linkToRoot = cfg.readBoolEntry( key, true ); 129 linkToRoot = cfg.readBoolEntry( key, true );
131#endif 130#endif
132 d.linkToRoot( linkToRoot ); 131 d.linkToRoot( linkToRoot );
133 132
134 destList.push_back( d ); 133 destList.push_back( d );
135 } 134 }
135 else if ( lineStr.startsWith( "option" ) )
136 {
137 char type[20];
138 char val[100];
139 sscanf( lineStr, "%*[^ ] %s %s", type, val );
140 if ( stricmp( type, "http_proxy" ) == 0 )
141 httpProxy = val;
142 if ( stricmp( type, "ftp_proxy" ) == 0 )
143 ftpProxy = val;
144 if ( stricmp( type, "proxy_username" ) == 0 )
145 proxyUsername = val;
146 if ( stricmp( type, "proxy_password" ) == 0 )
147 proxyPassword = val;
148 }
136 } 149 }
137 } 150 }
138 fclose( fp ); 151 fclose( fp );
139 152
153 cout << "httpProxy = " << httpProxy << endl;
154 cout << "ftpProxy = " << ftpProxy << endl;
155 cout << "proxyUsername = " << proxyUsername << endl;
156 cout << "proxyPassword = " << proxyPassword << endl;
157
140 reloadServerData( ); 158 reloadServerData( );
141} 159}
142 160
143void DataManager :: reloadServerData( ) 161void DataManager :: reloadServerData( )
144{ 162{
145 vector<Server>::iterator it = serverList.begin(); 163 vector<Server>::iterator it = serverList.begin();
146 for ( it = serverList.begin() ; it != serverList.end() ; ++it ) 164 for ( it = serverList.begin() ; it != serverList.end() ; ++it )
147 { 165 {
148 // Now we've read the config file in we need to read the servers 166 // Now we've read the config file in we need to read the servers
149 // The local server is a special case. This holds the contents of the 167 // The local server is a special case. This holds the contents of the
150 // status files the number of which depends on how many destinations 168 // status files the number of which depends on how many destinations
151 // we've set up 169 // we've set up
@@ -198,22 +216,47 @@ void DataManager :: writeOutIpkgConf()
198 } 216 }
199 217
200 out << endl; 218 out << endl;
201 219
202 // Write out destinations 220 // Write out destinations
203 vector<Destination>::iterator it2 = destList.begin(); 221 vector<Destination>::iterator it2 = destList.begin();
204 while ( it2 != destList.end() ) 222 while ( it2 != destList.end() )
205 { 223 {
206 out << "dest " << it2->getDestinationName() << " " << it2->getDestinationPath() << endl; 224 out << "dest " << it2->getDestinationName() << " " << it2->getDestinationPath() << endl;
207 it2++; 225 it2++;
208 } 226 }
209 227
228 out << "# Proxy Support" << endl;
229 out << "#" << endl;
230
231 if ( httpProxy == "" )
232 out << "#option http_proxy http://proxy.tld:3128" << endl;
233 else
234 out << "option http_proxy " << httpProxy << endl;
235
236 if ( ftpProxy == "" )
237 out << "#option ftp_proxy http://proxy.tld:3128" << endl;
238 else
239 out << "option ftp_proxy " << ftpProxy << endl;
240 if ( proxyUsername == "" )
241 out << "#option proxy_username <username>" << endl;
242 else
243 out << "option proxy_username " << proxyUsername << endl;
244 if ( proxyPassword == "" )
245 out << "#option proxy_password <password>" << endl << endl;
246 else
247 out << "option proxy_password " << proxyPassword << endl<< endl;
248
249 out << "# Offline mode (for use in constructing flash images offline)" << endl;
250 out << "#option offline_root target" << endl;
251
252
210 out.close(); 253 out.close();
211} 254}
212 255
213 256
214void DataManager :: setAvailableCategories( QString section ) 257void DataManager :: setAvailableCategories( QString section )
215{ 258{
216 section = section.lower(); 259 section = section.lower();
217 if ( availableCategories.find( "#" + section + "#" ) == -1 ) 260 if ( availableCategories.find( "#" + section + "#" ) == -1 )
218 availableCategories += section + "#"; 261 availableCategories += section + "#";
219} 262}
diff --git a/noncore/settings/aqpkg/datamgr.h b/noncore/settings/aqpkg/datamgr.h
index 3a64d92..14b0b2f 100644
--- a/noncore/settings/aqpkg/datamgr.h
+++ b/noncore/settings/aqpkg/datamgr.h
@@ -52,18 +52,22 @@ public:
52 52
53 void loadServers(); 53 void loadServers();
54 void reloadServerData( ); 54 void reloadServerData( );
55 55
56 void writeOutIpkgConf(); 56 void writeOutIpkgConf();
57 57
58 static QString getAvailableCategories() { return availableCategories; } 58 static QString getAvailableCategories() { return availableCategories; }
59 static void setAvailableCategories( QString section ); 59 static void setAvailableCategories( QString section );
60 60
61private: 61private:
62 static QString availableCategories; 62 static QString availableCategories;
63 QString activeServer; 63 QString activeServer;
64 QString httpProxy;
65 QString ftpProxy;
66 QString proxyUsername;
67 QString proxyPassword;
64 68
65 vector<Server> serverList; 69 vector<Server> serverList;
66 vector<Destination> destList; 70 vector<Destination> destList;
67}; 71};
68 72
69#endif 73#endif