Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

PMYouServers.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                                                                      |
00003 |                      __   __    ____ _____ ____                      |
00004 |                      \ \ / /_ _/ ___|_   _|___ \                     |
00005 |                       \ V / _` \___ \ | |   __) |                    |
00006 |                        | | (_| |___) || |  / __/                     |
00007 |                        |_|\__,_|____/ |_| |_____|                    |
00008 |                                                                      |
00009 |                               core system                            |
00010 |                                                    (C) SuSE Linux AG |
00011 \----------------------------------------------------------------------/
00012 
00013   File:       PMYouServers.h
00014 
00015   Author:     Cornelius Schumacher <cschum@suse.de>
00016   Maintainer: Cornelius Schumacher <cschum@suse.de>
00017 
00018   Purpose: Class providing path information for YOU patches.
00019 
00020 /-*/
00021 #ifndef PMYouServers_h
00022 #define PMYouServers_h
00023 
00024 #include <list>
00025 #include <string>
00026 
00027 #include <y2util/Url.h>
00028 #include <y2util/Pathname.h>
00029 
00030 #include <y2pm/PMError.h>
00031 #include <y2pm/PMPackagePtr.h>
00032 #include <y2pm/PkgArch.h>
00033 #include <y2pm/PMYouSettingsPtr.h>
00034 
00035 #include <y2pm/PMYouServersPtr.h>
00036 
00037 class SysConfig;
00038 
00042 class PMYouServer
00043 {
00044   public:
00054     enum Type { Default, Custom, Local, Remote, Slp, Unknown };
00055   
00056     PMYouServer();
00057     PMYouServer( const std::string &, Type type = Unknown );
00058     PMYouServer( const Url &url, const std::string &name,
00059                  const std::string &directory, Type type )
00060       : _url( url ), _name( name ), _directory( directory ), _type( type ) {}
00061 
00062     void setUrl( const Url &url ) { _url = url; }
00063     void setUrl( const std::string &url ) { _url = Url( url ); }
00064     Url url() const { return _url; }
00065 
00066     void setUsernamePassword( const std::string &username,
00067                               const std::string &password );
00068   
00069     void setName( const std::string &name ) { _name = name; }
00070     std::string name() const { return _name; }
00071     
00072     void setDirectory( const std::string &dir ) { _directory = dir; }
00073     std::string directory() const { return _directory; }
00074 
00075     void setType( Type type ) { _type = type; }
00076     Type type() const { return _type; }
00077     std::string typeAsString() const;
00078 
00079     static std::string typeToString( Type );
00080     static Type typeFromString( std::string );
00081 
00082     bool operator==( const PMYouServer &server ) const;
00083 
00084     bool fromString( const std::string & );
00085     std::string toString() const;
00086 
00087   private:
00088     Url _url;
00089     std::string _name;
00090     std::string _directory;
00091     Type _type;
00092 };
00093 
00097 class PMYouServers : public CountedRep
00098 {
00099   REP_BODY(PMYouServers);
00100 
00101   public:
00105     PMYouServers( const PMYouSettingsPtr & );
00106 
00110     ~PMYouServers();
00111 
00116     Pathname localSuseServers();
00117 
00121     Pathname localYouServers();
00122 
00127     Pathname cachedYouServers();
00128 
00134     PMError requestServers( bool check = false );
00135 
00139     std::list<PMYouServer> servers();
00140     
00144     PMYouServer defaultServer();
00145 
00149     PMYouServer currentServer();
00150 
00154     bool addSLPServers( );
00155 
00159     void addServer( const PMYouServer & );
00160 
00161   protected:
00162     std::string encodeUrl( const std::string &url );
00163 
00164     void addPackageVersion( const std::string &pkgName, std::string &url );
00165 
00166     PMError readServers( const Pathname &, PMYouServer::Type );
00167 
00168   private:
00169     PMYouSettingsPtr _settings;
00170 
00171     std::list<PMYouServer> _servers;
00172 };
00173 
00175 
00176 #endif // PMYouServers_h

Generated on Fri Nov 9 14:30:31 2007 for yast2-packagemanager by doxygen 1.3.6