libzypp  17.38.17
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 
17 namespace zypp {
18 
20  public:
21 
30  { }
31 
34 
42 
43  };
44 
46  { }
47 
49  {
50  static MediaConfig instance;
51  return instance;
52  }
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
Definition: mediaconfig.cc:32
#define ZYPP_IMPL_PRIVATE(Class)
Definition: zyppglobal.h:85
Pathname credentialsGlobalDir() const
Definition: mediaconfig.cc:101
long download_connect_timeout() const
Definition: mediaconfig.cc:133
long download_max_silent_tries() const
Definition: mediaconfig.cc:127
long download_max_download_speed() const
Definition: mediaconfig.cc:124
#define Z_D()
Definition: zyppglobal.h:98
long download_max_concurrent_connections() const
Definition: mediaconfig.cc:115
TInt strtonum(const C_Str &str)
Parsing numbers from string.
Definition: String.h:459
long download_min_download_speed_time() const
Definition: mediaconfig.cc:121
Pathname credentials_global_file_path
Definition: mediaconfig.cc:33
long download_min_download_speed() const
Definition: mediaconfig.cc:118
long download_transfer_timeout() const
Definition: mediaconfig.cc:130
bool setConfigValue(const std::string &section, const std::string &entry, const std::string &value)
Definition: mediaconfig.cc:54
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
Pathname credentialsGlobalFile() const
Definition: mediaconfig.cc:108
static MediaConfig & instance()
Definition: mediaconfig.cc:48