From: Michael Andres Date: Thu, 10 Apr 2014 17:19:34 +0000 (+0200) Subject: new JobReportReceiver: propagate libzypp messages X-Git-Tag: upstream/1.11.11~60 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=414f9851e3d8d7a94dc7d149f7e91dddce649269;p=platform%2Fupstream%2Fzypper.git new JobReportReceiver: propagate libzypp messages --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0d48079..1ef51bd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -28,6 +28,7 @@ SET (zypper_HEADERS callbacks/media.h callbacks/rpm.h callbacks/repo.h + callbacks/job.h ) SET( zypper_SRCS diff --git a/src/callbacks/job.h b/src/callbacks/job.h new file mode 100644 index 0000000..24e8a0a --- /dev/null +++ b/src/callbacks/job.h @@ -0,0 +1,67 @@ +/*---------------------------------------------------------------------------*\ + ____ _ _ __ _ __ ___ _ _ + |_ / || | '_ \ '_ \/ -_) '_| + /__|\_, | .__/ .__/\___|_| + |__/|_| |_| +\*---------------------------------------------------------------------------*/ + +#ifndef ZMART_JOB_CALLBACKS_H +#define ZMART_JOB_CALLBACKS_H + +#include + +#include +#include +#include + +#include "Zypper.h" +#include "output/prompt.h" + +/////////////////////////////////////////////////////////////////// +namespace ZmartRecipients +{ + /////////////////////////////////////////////////////////////////// + /// \class JobReportReceiver + /// \brief Receive generic notification callbacks + /////////////////////////////////////////////////////////////////// + struct JobReportReceiver : public callback::ReceiveReport + { + virtual bool message( MsgType type_r, const std::string & msg_r ) const + { + Out & out( Zypper::instance()->out() ); + switch ( type_r.asEnum() ) + { + case MsgType::info: + out.info( msg_r ); + break; + case MsgType::warning: + out.warning( msg_r ); + break; + case MsgType::error: + out.error( msg_r ); + break; + } + return true; + } + }; +} // namespace ZmartRecipients +/////////////////////////////////////////////////////////////////// + +class JobCallbacks +{ + public: + JobCallbacks() + { + _jobReport.connect(); + } + + ~JobCallbacks() + { + _jobReport.disconnect(); + } + + private: + ZmartRecipients::JobReportReceiver _jobReport; +}; + +#endif // ZMART_JOB_CALLBACKS_H diff --git a/src/main.cc b/src/main.cc index 74fea05..681aa8a 100644 --- a/src/main.cc +++ b/src/main.cc @@ -13,6 +13,7 @@ #include "callbacks/repo.h" #include "callbacks/media.h" #include "callbacks/locks.h" +#include "callbacks/job.h" #include "output/OutNormal.h" #include "utils/messages.h" @@ -90,6 +91,7 @@ int main(int argc, char **argv) static KeyRingCallbacks keyring_callbacks; static DigestCallbacks digest_callbacks; static LocksCallbacks locks_callbacks; + static JobCallbacks job_callbacks; } catch (const zypp::Exception & e) {