libzypp 17.31.23
mediaconfig.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
13#include "mediaconfig.h"
14#include <zypp-core/Pathname.h>
15#include <zypp-core/base/String.h>
16
17namespace zypp {
18
20 public:
21
29 { }
30
33
40
41 };
42
44 { }
45
47 {
48 static MediaConfig instance;
49 return instance;
50 }
51
52 bool MediaConfig::setConfigValue( const std::string &section, const std::string &entry, const std::string &value )
53 {
54 Z_D();
55 if ( section == "main" ) {
56 if ( entry == "credentials.global.dir" ) {
57 d->credentials_global_dir_path = Pathname(value);
58 return true;
59 } else if ( entry == "credentials.global.file" ) {
60 d->credentials_global_file_path = Pathname(value);
61 return true;
62
63 } else if ( entry == "download.max_concurrent_connections" ) {
64 str::strtonum(value, d->download_max_concurrent_connections);
65 return true;
66
67 } else if ( entry == "download.min_download_speed" ) {
68 str::strtonum(value, d->download_min_download_speed);
69 return true;
70
71 } else if ( entry == "download.max_download_speed" ) {
72 str::strtonum(value, d->download_max_download_speed);
73 return true;
74
75 } else if ( entry == "download.max_silent_tries" ) {
76 str::strtonum(value, d->download_max_silent_tries);
77 return true;
78
79 } else if ( entry == "download.connect_timeout" ) {
80 str::strtonum(value, d->download_connect_timeout);
81 if ( d->download_connect_timeout < 0 )
82 d->download_connect_timeout = 0;
83 return true;
84
85 } else if ( entry == "download.transfer_timeout" ) {
86 str::strtonum(value, d->download_transfer_timeout);
87 if ( d->download_transfer_timeout < 0 ) d->download_transfer_timeout = 0;
88 else if ( d->download_transfer_timeout > 3600 ) d->download_transfer_timeout = 3600;
89 return true;
90 }
91 }
92 return false;
93 }
94
96 {
97 Z_D();
98 return ( d->credentials_global_dir_path.empty() ?
99 Pathname("/etc/zypp/credentials.d") : d->credentials_global_dir_path );
100 }
101
103 {
104 Z_D();
105 return ( d->credentials_global_file_path.empty() ?
106 Pathname("/etc/zypp/credentials.cat") : d->credentials_global_file_path );
107 }
108
110 { return d_func()->download_max_concurrent_connections; }
111
113 { return d_func()->download_min_download_speed; }
114
116 { return d_func()->download_max_download_speed; }
117
119 { return d_func()->download_max_silent_tries; }
120
122 { return d_func()->download_transfer_timeout; }
123
125 { return d_func()->download_connect_timeout; }
126
127 ZYPP_IMPL_PRIVATE(MediaConfig)
128}
129
130
Pathname credentials_global_dir_path
Definition: mediaconfig.cc:31
Pathname credentials_global_file_path
Definition: mediaconfig.cc:32
Pathname credentialsGlobalFile() const
Definition: mediaconfig.cc:102
long download_max_download_speed() const
Definition: mediaconfig.cc:115
Pathname credentialsGlobalDir() const
Definition: mediaconfig.cc:95
long download_min_download_speed() const
Definition: mediaconfig.cc:112
long download_connect_timeout() const
Definition: mediaconfig.cc:124
long download_max_concurrent_connections() const
Definition: mediaconfig.cc:109
bool setConfigValue(const std::string &section, const std::string &entry, const std::string &value)
Definition: mediaconfig.cc:52
static MediaConfig & instance()
Definition: mediaconfig.cc:46
long download_transfer_timeout() const
Definition: mediaconfig.cc:121
long download_max_silent_tries() const
Definition: mediaconfig.cc:118
TInt strtonum(const C_Str &str)
Parsing numbers from string.
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2