libzypp 17.38.17
mediaconfig.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12
13#include "mediaconfig.h"
14#include <zypp-core/Pathname.h>
16
17namespace zypp {
18
44
47
53
54 bool MediaConfig::setConfigValue( const std::string &section, const std::string &entry, const std::string &value )
55 {
56 Z_D();
57 if ( section == "main" ) {
58 if ( entry == "credentials.global.dir" ) {
59 d->credentials_global_dir_path = Pathname(value);
60 return true;
61 } else if ( entry == "credentials.global.file" ) {
62 d->credentials_global_file_path = Pathname(value);
63 return true;
64
65 } else if ( entry == "download.max_concurrent_connections" ) {
66 str::strtonum(value, d->download_max_concurrent_connections);
67 return true;
68
69 } else if ( entry == "download.min_download_speed" ) {
70 str::strtonum(value, d->download_min_download_speed);
71 return true;
72
73 } else if ( entry == "download.min_download_speed_time" ) {
74 str::strtonum(value, d->download_min_download_speed_time);
75 return true;
76
77 } else if ( entry == "download.max_download_speed" ) {
78 str::strtonum(value, d->download_max_download_speed);
79 return true;
80
81 } else if ( entry == "download.max_silent_tries" ) {
82 str::strtonum(value, d->download_max_silent_tries);
83 return true;
84
85 } else if ( entry == "download.connect_timeout" ) {
86 str::strtonum(value, d->download_connect_timeout);
87 if ( d->download_connect_timeout < 0 )
88 d->download_connect_timeout = 0;
89 return true;
90
91 } else if ( entry == "download.transfer_timeout" ) {
92 str::strtonum(value, d->download_transfer_timeout);
93 if ( d->download_transfer_timeout < 0 ) d->download_transfer_timeout = 0;
94 else if ( d->download_transfer_timeout > 3600 ) d->download_transfer_timeout = 3600;
95 return true;
96 }
97 }
98 return false;
99 }
100
102 {
103 Z_D();
104 return ( d->credentials_global_dir_path.empty() ?
105 Pathname("/etc/zypp/credentials.d") : d->credentials_global_dir_path );
106 }
107
109 {
110 Z_D();
111 return ( d->credentials_global_file_path.empty() ?
112 Pathname("/etc/zypp/credentials.cat") : d->credentials_global_file_path );
113 }
114
116 { return d_func()->download_max_concurrent_connections; }
117
119 { return d_func()->download_min_download_speed; }
120
122 { return d_func()->download_min_download_speed_time; }
123
125 { return d_func()->download_max_download_speed; }
126
128 { return d_func()->download_max_silent_tries; }
129
131 { return d_func()->download_transfer_timeout; }
132
134 { return d_func()->download_connect_timeout; }
135
137}
138
139
Pathname credentials_global_dir_path
Pathname credentials_global_file_path
Pathname credentialsGlobalFile() const
long download_max_download_speed() const
Pathname credentialsGlobalDir() const
long download_min_download_speed() const
long download_connect_timeout() const
long download_max_concurrent_connections() const
std::unique_ptr< MediaConfigPrivate > d_ptr
bool setConfigValue(const std::string &section, const std::string &entry, const std::string &value)
static MediaConfig & instance()
long download_min_download_speed_time() const
long download_transfer_timeout() const
long download_max_silent_tries() const
Pathname()
Default ctor: an empty path.
Definition Pathname.h:51
TInt strtonum(const C_Str &str)
Parsing numbers from string.
Easy-to use interface to the ZYPP dependency resolver.
#define ZYPP_IMPL_PRIVATE(Class)
Definition zyppglobal.h:85
#define Z_D()
Definition zyppglobal.h:98