759bd5b0f40afe089408e1af64229f0cb6070fb1
[platform/upstream/libzypp.git] / zypp / media / TransferSettings.h
1
2 #ifndef TRANSFER_SETTINGS_H_
3 #define TRANSFER_SETTINGS_H_
4
5 #include <string>
6 #include <vector>
7 #include "zypp/base/Flags.h"
8 #include "zypp/base/PtrTypes.h"
9 #include "zypp/Pathname.h"
10 #include "zypp/Url.h"
11
12 namespace zypp
13 {
14 namespace media
15 {
16
17 /**
18  * Holds transfer setting
19  */
20 class TransferSettings
21 {
22 public:
23   /**
24    * Constructs a transfer program cmd line access.
25    */
26   TransferSettings();
27
28   /**
29    * Constructs the settings from a url object where.
30    * authentication/proxy  information can be extracted
31    * from the url
32    */
33   TransferSettings( const zypp::Url &url );
34
35   typedef std::vector<std::string> Headers;
36
37   /**
38    * reset the settings to the defaults
39    */
40   void reset();
41
42   /**
43    * add a header, on the form "Foo: Bar"
44    */
45   void addHeader( const std::string &header );
46
47   /**
48    * begin iterators to additional headers
49    */
50   Headers::const_iterator headersBegin() const;
51
52   /**
53    * end iterators to additional headers
54    */
55   Headers::const_iterator headersEnd() const;
56
57   /**
58    * sets the user agent ie: "Mozilla v3"
59    */
60   void setUserAgentString( const std::string &agent );
61
62   /**
63    * user agent string
64    */
65   std::string userAgentString() const;
66
67   /**
68    * sets the auth username
69    */
70   void setUsername( const std::string &username );
71
72   /**
73    * auth username
74    */
75   std::string username() const;
76
77   /**
78    * sets the auth password
79    */
80   void setPassword( const std::string &password );
81
82   /**
83    * auth password
84    */
85   std::string password() const;
86
87   /**
88    * returns the user and password as
89    * a user:pass string
90    */
91   std::string userPassword() const;
92
93   /**
94    * sets anonymous authentication (ie: for ftp)
95    */
96   void setAnonymousAuth();
97
98   /**
99    * whether the proxy is used or not
100    */
101   void setProxyEnabled( bool enabled );
102
103   /**
104    * proxy is enabled
105    */
106   bool proxyEnabled() const;
107
108   /**
109    * proxy to use if it is enabled
110    */
111   void setProxy( const std::string &proxyhost );
112
113   /**
114    * proxy host
115    */
116   std::string proxy() const;
117
118   /**
119    * sets the proxy user
120    */
121   void setProxyUsername( const std::string &proxyuser );
122
123   /**
124    * proxy auth username
125    */
126   std::string proxyUsername() const;
127
128   /**
129    * sets the proxy password
130    */
131   void setProxyPassword( const std::string &proxypass );
132
133   /**
134    * proxy auth password
135    */
136   std::string proxyPassword() const;
137
138   /**
139    * returns the proxy user and password as
140    * a user:pass string
141    */
142   std::string proxyUserPassword() const;
143
144   /**
145    * set the connect timeout
146    */
147   void setConnectTimeout( long t );
148
149   /**
150    * connection timeout
151    */
152   long connectTimeout() const;
153
154   /**
155    * set the transfer timeout
156    */
157   void setTimeout( long t );
158
159   /**
160    * transfer timeout
161    */
162   long timeout() const;
163
164   /**
165    * Maximum number of concurrent connections for a single transfer
166    */
167   long maxConcurrentConnections() const;
168
169   /**
170    * Set maximum number of concurrent connections for a single transfer
171    */
172   void setMaxConcurrentConnections(long v);
173
174   /**
175    * Minimum download speed (bytes per second)
176    * until the connection is dropped
177    */
178   long minDownloadSpeed() const;
179
180   /**
181    * Set minimum download speed (bytes per second)
182    * until the connection is dropped
183    */
184   void setMinDownloadSpeed(long v);
185
186   /**
187    * Maximum download speed (bytes per second)
188    */
189   long maxDownloadSpeed() const;
190
191   /**
192    * Set max download speed (bytes per second)
193    */
194   void setMaxDownloadSpeed(long v);
195
196   /**
197    * Maximum silent retries
198    */
199   long maxSilentTries() const;
200
201   /**
202    * Set maximum silent retries
203    */
204   void setMaxSilentTries(long v);
205
206   /**
207    * Whether to verify host for ssl
208    */
209   bool verifyHostEnabled() const;
210
211   /**
212    * Sets whether to verify host for ssl
213    */
214   void setVerifyHostEnabled( bool enabled );
215
216   /**
217    * Whether to verify peer for ssl
218    */
219   bool verifyPeerEnabled() const;
220
221   /**
222    * Sets whether to verify host for ssl
223    */
224   void setVerifyPeerEnabled( bool enabled );
225
226   /**
227    * SSL certificate authorities path
228    * ( default: /etc/ssl/certs )
229    */
230   Pathname certificateAuthoritiesPath() const;
231
232   /**
233    * Sets the SSL certificate authorities path
234    */
235   void setCertificateAuthoritiesPath( const zypp::Pathname &path );
236
237   /**
238    * set the allowed authentication types
239    */
240   void setAuthType( const std::string &authtype );
241
242   /**
243    * get the allowed authentication types
244    */
245   std::string authType() const;
246
247   /**
248    * set whether HEAD requests are allowed
249    */
250   void setHeadRequestsAllowed(bool allowed);
251
252   /**
253    * whether HEAD requests are allowed
254    */
255   bool headRequestsAllowed() const;
256
257   /**
258    * SSL client certificate file
259    */
260   Pathname clientCertificatePath() const;
261
262   /**
263    * Sets the SSL client certificate file
264    */
265   void setClientCertificatePath( const zypp::Pathname &path );
266
267   /**
268    * SSL client key file
269    */
270   Pathname clientKeyPath() const;
271
272   /**
273    * Sets the SSL client key file
274    */
275   void setClientKeyPath( const zypp::Pathname &path );
276
277 protected:
278   class Impl;
279   RWCOW_pointer<Impl> _impl;
280 };
281
282 } // ns media
283 } // ns zypp
284
285 #endif