-rw-r--r-- | noncore/settings/aqpkg/datamgr.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/settings/aqpkg/datamgr.cpp b/noncore/settings/aqpkg/datamgr.cpp index 7c49621..d929c39 100644 --- a/noncore/settings/aqpkg/datamgr.cpp +++ b/noncore/settings/aqpkg/datamgr.cpp | |||
@@ -25,129 +25,129 @@ using namespace std; | |||
25 | 25 | ||
26 | 26 | ||
27 | DataManager::DataManager() | 27 | DataManager::DataManager() |
28 | { | 28 | { |
29 | activeServer = ""; | 29 | activeServer = ""; |
30 | } | 30 | } |
31 | 31 | ||
32 | DataManager::~DataManager() | 32 | DataManager::~DataManager() |
33 | { | 33 | { |
34 | } | 34 | } |
35 | 35 | ||
36 | Server *DataManager :: getServer( const char *name ) | 36 | Server *DataManager :: getServer( const char *name ) |
37 | { | 37 | { |
38 | Server *s = 0; | 38 | Server *s = 0; |
39 | vector<Server>::iterator it = serverList.begin(); | 39 | vector<Server>::iterator it = serverList.begin(); |
40 | while ( it != serverList.end() && s == 0 ) | 40 | while ( it != serverList.end() && s == 0 ) |
41 | { | 41 | { |
42 | if ( it->getServerName() == name ) | 42 | if ( it->getServerName() == name ) |
43 | s = &(*it); | 43 | s = &(*it); |
44 | 44 | ||
45 | ++it; | 45 | ++it; |
46 | } | 46 | } |
47 | 47 | ||
48 | return s; | 48 | return s; |
49 | } | 49 | } |
50 | 50 | ||
51 | Destination *DataManager :: getDestination( const char *name ) | 51 | Destination *DataManager :: getDestination( const char *name ) |
52 | { | 52 | { |
53 | Destination *d = 0; | 53 | Destination *d = 0; |
54 | vector<Destination>::iterator it = destList.begin(); | 54 | vector<Destination>::iterator it = destList.begin(); |
55 | while ( it != destList.end() && d == 0 ) | 55 | while ( it != destList.end() && d == 0 ) |
56 | { | 56 | { |
57 | if ( it->getDestinationName() == name ) | 57 | if ( it->getDestinationName() == name ) |
58 | d = &(*it); | 58 | d = &(*it); |
59 | 59 | ||
60 | ++it; | 60 | ++it; |
61 | } | 61 | } |
62 | 62 | ||
63 | return d; | 63 | return d; |
64 | } | 64 | } |
65 | 65 | ||
66 | void DataManager :: loadServers() | 66 | void DataManager :: loadServers() |
67 | { | 67 | { |
68 | // First add our local server - not really a server but | 68 | // First add our local server - not really a server but |
69 | // the local config (which packages are installed) | 69 | // the local config (which packages are installed) |
70 | serverList.push_back( Server( LOCAL_SERVER, "" ) ); | 70 | serverList.push_back( Server( LOCAL_SERVER, "" ) ); |
71 | serverList.push_back( Server( LOCAL_IPKGS, "" ) ); | 71 | serverList.push_back( Server( LOCAL_IPKGS, "" ) ); |
72 | 72 | ||
73 | // Read file from /etc/ipkg.conf | 73 | // Read file from /etc/ipkg.conf |
74 | QString ipkg_conf = IPKG_CONF; | 74 | QString ipkg_conf = IPKG_CONF; |
75 | FILE *fp; | 75 | FILE *fp; |
76 | fp = fopen( ipkg_conf, "r" ); | 76 | fp = fopen( ipkg_conf, "r" ); |
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" ) ) | 101 | if ( lineStr.startsWith( "src" ) ) |
102 | s.setActive( true ); | 102 | s.setActive( true ); |
103 | else | 103 | else |
104 | s.setActive( false ); | 104 | s.setActive( false ); |
105 | 105 | ||
106 | serverList.push_back( s ); | 106 | serverList.push_back( s ); |
107 | 107 | ||
108 | } | 108 | } |
109 | else if ( lineStr.startsWith( "dest" ) ) | 109 | else if ( lineStr.startsWith( "dest" ) ) |
110 | { | 110 | { |
111 | char alias[20]; | 111 | char alias[20]; |
112 | char path[50]; | 112 | char path[50]; |
113 | sscanf( lineStr, "%*[^ ] %s %s", alias, path ); | 113 | sscanf( lineStr, "%*[^ ] %s %s", alias, path ); |
114 | Destination d( alias, path ); | 114 | Destination d( alias, path ); |
115 | destList.push_back( d ); | 115 | destList.push_back( d ); |
116 | } | 116 | } |
117 | } | 117 | } |
118 | } | 118 | } |
119 | fclose( fp ); | 119 | fclose( fp ); |
120 | 120 | ||
121 | vector<Server>::iterator it; | 121 | vector<Server>::iterator it; |
122 | for ( it = serverList.begin() ; it != serverList.end() ; ++it ) | 122 | for ( it = serverList.begin() ; it != serverList.end() ; ++it ) |
123 | reloadServerData( it->getServerName() ); | 123 | reloadServerData( it->getServerName() ); |
124 | } | 124 | } |
125 | 125 | ||
126 | void DataManager :: reloadServerData( const char *serverName ) | 126 | void DataManager :: reloadServerData( const char *serverName ) |
127 | { | 127 | { |
128 | Server *s = getServer( serverName ); | 128 | Server *s = getServer( serverName ); |
129 | // 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 |
130 | // 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 |
131 | // status files the number of which depends on how many destinations | 131 | // status files the number of which depends on how many destinations |
132 | // we've set up | 132 | // we've set up |
133 | // The other servers files hold the contents of the server package list | 133 | // The other servers files hold the contents of the server package list |
134 | if ( s->getServerName() == LOCAL_SERVER ) | 134 | if ( s->getServerName() == LOCAL_SERVER ) |
135 | s->readStatusFile( destList ); | 135 | s->readStatusFile( destList ); |
136 | else if ( s->getServerName() == LOCAL_IPKGS ) | 136 | else if ( s->getServerName() == LOCAL_IPKGS ) |
137 | s->readLocalIpks( getServer( LOCAL_SERVER ) ); | 137 | s->readLocalIpks( getServer( LOCAL_SERVER ) ); |
138 | else | 138 | else |
139 | s->readPackageFile( getServer( LOCAL_SERVER ) ); | 139 | s->readPackageFile( getServer( LOCAL_SERVER ) ); |
140 | 140 | ||
141 | } | 141 | } |
142 | 142 | ||
143 | void DataManager :: writeOutIpkgConf() | 143 | void DataManager :: writeOutIpkgConf() |
144 | { | 144 | { |
145 | QString ipkg_conf = IPKG_CONF; | 145 | QString ipkg_conf = IPKG_CONF; |
146 | ofstream out( ipkg_conf ); | 146 | ofstream out( ipkg_conf ); |
147 | 147 | ||
148 | out << "# Written by AQPkg" << endl; | 148 | out << "# Written by AQPkg" << endl; |
149 | out << "# Must have one or more source entries of the form:" << endl; | 149 | out << "# Must have one or more source entries of the form:" << endl; |
150 | out << "#" << endl; | 150 | out << "#" << endl; |
151 | out << "# src <src-name> <source-url>" << endl; | 151 | out << "# src <src-name> <source-url>" << endl; |
152 | out << "#" << endl; | 152 | out << "#" << endl; |
153 | out << "# and one or more destination entries of the form:" << endl; | 153 | out << "# and one or more destination entries of the form:" << endl; |