00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef InstSrcManagerCallbacks_h
00022 #define InstSrcManagerCallbacks_h
00023
00024 #include <iosfwd>
00025
00026 #include <y2util/Url.h>
00027
00028 #include <y2pm/PMCallbacks.h>
00029 #include <y2pm/InstSrcPtr.h>
00030 #include <y2pm/InstSrcDescrPtr.h>
00031
00033 namespace InstSrcManagerCallbacks {
00035
00037
00039 struct MediaChangeCallback : public RedirectCallback<MediaChangeCallback> {
00043 virtual bool isSet() = 0;
00051 virtual std::string changeMedia( constInstSrcDescrPtr descr,
00052 const Url & currentUrl,
00053 int expectedMedianr,
00054 PMError error ) = 0;
00055
00067 virtual std::string changeMedia( const std::string & error,
00068 const std::string & url,
00069 const std::string & product,
00070 int current,
00071 const std::string & currentLabel,
00072 int expected,
00073 const std::string & expectedLabel,
00074 bool doublesided ) = 0;
00075 };
00076
00077 class MediaChangeReport : public Report<MediaChangeCallback> {
00078 virtual bool isSet() {
00079 return MediaChangeCallback::isSet();
00080 }
00081 virtual std::string changeMedia( constInstSrcDescrPtr descr,
00082 const Url & currentUrl,
00083 int expectedMedianr,
00084 PMError error ) {
00085 return MediaChangeCallback::changeMedia( descr, currentUrl,
00086 expectedMedianr, error );
00087 }
00091 virtual std::string changeMedia( const std::string & error,
00092 const std::string & url,
00093 const std::string & product,
00094 int current,
00095 const std::string & currentLabel,
00096 int expected,
00097 const std::string & expectedLabel,
00098 bool doublesided ) {
00099 return MediaChangeCallback::changeMedia( error, url, product,
00100 current, currentLabel,
00101 expected, expectedLabel,
00102 doublesided );
00103 }
00104 };
00105
00106 extern MediaChangeReport mediaChangeReport;
00107
00109
00111 struct SourceRefreshCallback : public RedirectCallback<SourceRefreshCallback> {
00112 enum Result
00113 {
00114 SUCCESS = 0,
00115 RETRY,
00116 SKIP_REFRESH,
00117 DISABLE_SOURCE
00118 };
00119 std::string asString( Result val_r ) const;
00120 enum Cause
00121 {
00122 REFRESH_SKIP_CD_DVD,
00123 REFRESH_NOT_SUPPORTED_BY_SOURCE,
00124 SOURCE_IS_UPTODATE,
00125 SOURCE_REFRESHED,
00126 USERREQUEST
00127 };
00128 std::string asString( Cause val_r ) const;
00129 enum Error
00130 {
00131 NO_SOURCE_FOUND,
00132 INCOMPLETE_SOURCE_DATA
00133 };
00134 std::string asString( Error val_r ) const;
00135
00136 virtual void start( constInstSrcDescrPtr descr_r ) = 0;
00137 virtual Result error( Error error_r,
00138 const std::string & detail = std::string() ) = 0;
00139 virtual void stop( Result result_r, Cause cause_r,
00140 const std::string & detail = std::string() ) = 0;
00141 };
00142
00143 class SourceRefreshReport : public Report<SourceRefreshCallback> {
00144 virtual void start( constInstSrcDescrPtr descr_r ) {
00145 SourceRefreshCallback::start( descr_r );
00146 }
00147 virtual Result error( Error error_r,
00148 const std::string & detail = std::string() ) {
00149 return SourceRefreshCallback::error( error_r, detail );
00150 }
00151 virtual void stop( Result result_r, Cause cause_r,
00152 const std::string & detail = std::string() ) {
00153 SourceRefreshCallback::stop( result_r, cause_r, detail );
00154 }
00155 };
00156
00157 extern SourceRefreshReport sourceRefreshReport;
00158
00159 #if 0
00160
00161
00163 struct @Callback : public RedirectCallback<@Callback> {
00164 virtual void start() = 0;
00165 virtual void progress( const ProgressData & prg ) = 0;
00166 virtual void stop( PMError error ) = 0;
00167 };
00168
00169 class @Report : public Report<@Callback> {
00170 virtual void start() {
00171 @Callback::start();
00172 }
00173 virtual void progress( const ProgressData & prg ) {
00174 @Callback::progress( prg );
00175 }
00176 virtual void stop( PMError error ) {
00177 @Callback::stop( error );
00178 }
00179 };
00180
00181 extern @Report @Report;
00182 #endif
00183
00185 }
00187
00188 #endif // InstSrcManagerCallbacks_h