libzypp  11.13.5
ServiceRepos.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <sstream>
3 #include "zypp/base/Logger.h"
10 #include "zypp/ExternalProgram.h"
11 
12 using std::stringstream;
13 using std::endl;
14 
15 namespace zypp
16 {
17 namespace repo
18 {
19 
21 {
22 public:
23  Impl()
24  {
25  }
26 
27  virtual ~Impl()
28  {
29  }
30 };
31 
33 {
34 public:
36 
37  RIMServiceRepos(const ServiceInfo &service,
38  const ServiceRepos::ProcessRepo & callback,
40  : _callback(callback)
41  {
42  // repoindex.xml must be fetched always without using cookies (bnc #573897)
43  Url serviceUrl( service.url() );
44  serviceUrl.setQueryParam( "cookies", "0" );
45 
46  // download the repo index file
47  media::MediaManager mediamanager;
48  media::MediaAccessId mid = mediamanager.open( serviceUrl );
49  mediamanager.attach( mid );
50  mediamanager.provideFile( mid, "repo/repoindex.xml" );
51  Pathname path = mediamanager.localPath(mid, "repo/repoindex.xml" );
53  mediamanager.release( mid );
54  mediamanager.close( mid );
55  }
56 
58  {
59 
60  }
61 };
62 
64 {
65 public:
67 
69  const ServiceRepos::ProcessRepo & callback,
71  : _callback(callback)
72  {
73  Url serviceUrl( service.url() );
74  stringstream buffer;
75 
77  args.reserve( 3 );
78  args.push_back( "/bin/sh" );
79  args.push_back( "-c" );
80  args.push_back( serviceUrl.getPathName() );
81  ExternalProgramWithStderr prog( args );
82  prog >> buffer;
83 
84  if ( prog.close() != 0 )
85  {
86  // ServicePluginInformalException:
87  // Ignore this error but we'd like to report it somehow...
88  std::string errbuffer;
89  prog.stderrGetUpTo( errbuffer, '\0' );
90  ERR << "Capture plugin error:[" << endl << errbuffer << endl << ']' << endl;
92  }
93 
94  parser::RepoFileReader parser(buffer, _callback);
95  }
96 
98  {}
99 };
100 
101 
103  const ServiceRepos::ProcessRepo & callback,
104  const ProgressData::ReceiverFnc &progress)
105  : _impl( (service.type() == ServiceType::PLUGIN) ? (ServiceRepos::Impl *)(new PluginServiceRepos(service, callback, progress)) : (ServiceRepos::Impl *)(new RIMServiceRepos(service, callback, progress)))
106 {
107 }
108 
110 {
111 }
112 
113 
114 }
115 }