libzypp  17.31.8
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 
28  { }
29 
32 
38  };
39 
41  { }
42 
44  {
45  static MediaConfig instance;
46  return instance;
47  }
48 
49  bool MediaConfig::setConfigValue( const std::string &section, const std::string &entry, const std::string &value )
50  {
51  Z_D();
52  if ( section == "main" ) {
53  if ( entry == "credentials.global.dir" ) {
54  d->credentials_global_dir_path = Pathname(value);
55  return true;
56  } else if ( entry == "credentials.global.file" ) {
57  d->credentials_global_file_path = Pathname(value);
58  return true;
59 
60  } else if ( entry == "download.max_concurrent_connections" ) {
61  str::strtonum(value, d->download_max_concurrent_connections);
62  return true;
63 
64  } else if ( entry == "download.min_download_speed" ) {
65  str::strtonum(value, d->download_min_download_speed);
66  return true;
67 
68  } else if ( entry == "download.max_download_speed" ) {
69  str::strtonum(value, d->download_max_download_speed);
70  return true;
71 
72  } else if ( entry == "download.max_silent_tries" ) {
73  str::strtonum(value, d->download_max_silent_tries);
74  return true;
75 
76  } else if ( entry == "download.transfer_timeout" ) {
77  str::strtonum(value, d->download_transfer_timeout);
78  if ( d->download_transfer_timeout < 0 ) d->download_transfer_timeout = 0;
79  else if ( d->download_transfer_timeout > 3600 ) d->download_transfer_timeout = 3600;
80  return true;
81  }
82  }
83  return false;
84  }
85 
87  {
88  Z_D();
89  return ( d->credentials_global_dir_path.empty() ?
90  Pathname("/etc/zypp/credentials.d") : d->credentials_global_dir_path );
91  }
92 
94  {
95  Z_D();
96  return ( d->credentials_global_file_path.empty() ?
97  Pathname("/etc/zypp/credentials.cat") : d->credentials_global_file_path );
98  }
99 
101  { return d_func()->download_max_concurrent_connections; }
102 
104  { return d_func()->download_min_download_speed; }
105 
107  { return d_func()->download_max_download_speed; }
108 
110  { return d_func()->download_max_silent_tries; }
111 
113  { return d_func()->download_transfer_timeout; }
114 
116 }
117 
118 
Pathname credentials_global_dir_path
Definition: mediaconfig.cc:30
ZYPP_IMPL_PRIVATE(Provide)
Pathname credentialsGlobalDir() const
Definition: mediaconfig.cc:86
long download_max_silent_tries() const
Definition: mediaconfig.cc:109
long download_max_download_speed() const
Definition: mediaconfig.cc:106
long download_max_concurrent_connections() const
Definition: mediaconfig.cc:100
TInt strtonum(const C_Str &str)
Parsing numbers from string.
Definition: String.h:388
Pathname credentials_global_file_path
Definition: mediaconfig.cc:31
long download_min_download_speed() const
Definition: mediaconfig.cc:103
long download_transfer_timeout() const
Definition: mediaconfig.cc:112
bool setConfigValue(const std::string &section, const std::string &entry, const std::string &value)
Definition: mediaconfig.cc:49
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
Pathname credentialsGlobalFile() const
Definition: mediaconfig.cc:93
static MediaConfig & instance()
Definition: mediaconfig.cc:43