Skip to content

Commit

Permalink
Save
Browse files Browse the repository at this point in the history
  • Loading branch information
bzeller committed Nov 13, 2024
1 parent 9e7fb17 commit 56db9ad
Show file tree
Hide file tree
Showing 65 changed files with 1,426 additions and 727 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -440,10 +440,10 @@ ELSE ( ENABLE_BUILD_TRANS )
ADD_SUBDIRECTORY( po EXCLUDE_FROM_ALL )
ENDIF ( ENABLE_BUILD_TRANS )

IF ( ENABLE_BUILD_TESTS )
ADD_SUBDIRECTORY( tests )
ELSE ( ENABLE_BUILD_TESTS )
#IF ( ENABLE_BUILD_TESTS )
# ADD_SUBDIRECTORY( tests )
#ELSE ( ENABLE_BUILD_TESTS )
ADD_SUBDIRECTORY( tests EXCLUDE_FROM_ALL )
ENDIF ( ENABLE_BUILD_TESTS )
#ENDIF ( ENABLE_BUILD_TESTS )
INCLUDE(CTest)
ENABLE_TESTING()
1 change: 1 addition & 0 deletions libzypp.spec.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ BuildRequires: libxml2-devel
BuildRequires: yaml-cpp-devel

BuildRequires: gobject-introspection-devel
BuildRequires: gtk-doc

# we are loading libproxy dynamically, however we have
# a failsafe unit test that links against libproxy to make
Expand Down
5 changes: 2 additions & 3 deletions zypp-core/zyppng/base/eventdispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,11 @@ class EventDispatcher : public Base
* \brief Convenience function to schedule a callback to be called later.
* \param callback a std::function that is called after all other events have been processed
*/
template< typename T = IdleFunction >
static void invokeOnIdle ( T &&callback )
static void invokeOnIdle ( IdleFunction &&callback )
{
auto ev = instance();
if ( ev )
ev->invokeOnIdleImpl( std::forward<T>(callback) );
ev->invokeOnIdleImpl( std::move(callback) );
}

/*!
Expand Down
2 changes: 2 additions & 0 deletions zypp-core/zyppng/base/threaddata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ namespace zyppng
if (!sp) {
MIL << "Creating the Event Dispatcher for thread: " << name() << "("<<_threadId<<")" << std::endl;
_dispatcher = sp = EventDispatcherPrivate::create( ctx );
} else {
if ( ctx && ctx != sp->glibContext() ) MIL << "Ignoring passed GMainContext, because a Zypp Event Dispatcher was created before. This might be a bug!" << std::endl;
}
return sp;
}
Expand Down
5 changes: 4 additions & 1 deletion zypp-core/zyppng/pipelines/expected.h
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,10 @@ namespace zyppng {
namespace detail {
template <typename Fun>
struct transform_collect_helper {
template <typename F = Fun>
transform_collect_helper( F &&cb ) : _callback( std::forward<F>(cb)) {}
Fun _callback;

template <typename T>
auto operator() ( T &&in ) {
return transform_collect( std::forward<T>(in), _callback );
Expand All @@ -634,7 +637,7 @@ namespace zyppng {
namespace operators {
template <typename Transformation>
auto transform_collect( Transformation &&f ) {
return detail::transform_collect_helper{ std::forward<Transformation>(f)};
return detail::transform_collect_helper<Transformation>( std::forward<Transformation>(f) );
}
}

Expand Down
2 changes: 1 addition & 1 deletion zypp-core/zyppng/pipelines/mtry.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace zyppng {
namespace operators {
template <typename Fun>
auto mtry ( Fun && function ) {
return detail::mtry_helper<Fun> {
return zyppng::detail::mtry_helper<Fun> {
std::forward<Fun>(function)
};
}
Expand Down
21 changes: 19 additions & 2 deletions zypp-core/zyppng/ui/progressobserver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ namespace zyppng {
return;
}

child.d_func()->_parent.reset();

const auto idx = std::distance ( _children.begin (), i );
_children.erase(i);
_childInfo.erase( _childInfo.begin () + idx );
Expand Down Expand Up @@ -195,6 +197,11 @@ namespace zyppng {
return d_func()->_counterValue;
}

ProgressObserverRef ProgressObserver::parent() const
{
return d_func()->_parent.lock();
}

const std::vector<ProgressObserverRef> &ProgressObserver::children()
{
return d_func()->_children;
Expand Down Expand Up @@ -240,6 +247,11 @@ namespace zyppng {
return d_func()->_sigNewSubprogress;
}

SignalProxy<void ( ProgressObserver &sender, UserRequestRef event)> ProgressObserver::sigEvent()
{
return d_func()->_sigEvent;
}

void ProgressObserver::setBaseSteps(int steps)
{
Z_D();
Expand All @@ -260,6 +272,8 @@ namespace zyppng {
void ProgressObserver::setCurrent(double curr)
{
Z_D();
if ( !d->_started ) start();

auto set = std::max<double>(0, std::min<double>( curr, d->_baseSteps ) );
if ( set == d->_baseValue )
return;
Expand All @@ -282,12 +296,12 @@ namespace zyppng {
// others we have to manually remove
while ( d->_children.size() ) {
auto back = d->_children.back();
bool remove = !back->started ();
back->setFinished( result );
bool remove = !back->started ();
if ( remove ) d->_children.pop_back();
}

if ( result != Error )
if ( d->_started && result != Error )
setCurrent( d->_baseSteps );

if ( d->_started )
Expand Down Expand Up @@ -318,6 +332,7 @@ namespace zyppng {
}
, adjustedWeight
});
child->d_func ()->_parent = weak_this<ProgressObserver>();
d->_sigNewSubprogress.emit( *this, child );

// if the child has been started already, we also need to start()
Expand Down Expand Up @@ -363,6 +378,8 @@ namespace zyppng {
d->_sigEvent.emit( *this, event );
if ( !event->accepted () ) {
// our receivers did not handle the request, we need to bubble up!
auto p = d->_parent.lock();
if ( p ) p->sendUserRequest( event );
}
}

Expand Down
2 changes: 1 addition & 1 deletion zypp-core/zyppng/ui/progressobserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ namespace zyppng {
double progress() const;
double current() const;

ProgressObserverRef parent() const;

inline static ProgressObserverRef makeSubTask( ProgressObserverRef parentProgress, float weight = 1.0, const std::string &label = std::string(), int steps = 100 ) {
if ( parentProgress ) return parentProgress->makeSubTask( weight, label, steps );
Expand Down Expand Up @@ -107,7 +108,6 @@ namespace zyppng {

zypp::ProgressData::ReceiverFnc makeProgressDataReceiver ();


void sendUserRequest( const UserRequestRef& event );

SignalProxy<void ( ProgressObserver &sender )> sigStarted ();
Expand Down
15 changes: 15 additions & 0 deletions zypp-core/zyppng/ui/userrequest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@ namespace zyppng
return _userData;
}

void UserRequest::accept()
{
_accepted = true;
}

void UserRequest::ignore()
{
_accepted = false;
}

bool UserRequest::accepted() const
{
return _accepted;
}

ZYPP_IMPL_PRIVATE_CONSTR_ARGS(ShowMessageRequest, std::string message, MType mType, UserData data )
: UserRequest( std::move(data) )
, _type( mType )
Expand Down
7 changes: 0 additions & 7 deletions zypp-core/zyppng/ui/userrequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,11 @@ namespace zyppng {
using UserData = zypp::callback::UserData;
using ContentType = zypp::ContentType;


ZYPP_FWD_DECL_TYPE_WITH_REFS( UserRequest );
ZYPP_FWD_DECL_TYPE_WITH_REFS( ShowMessageRequest );
ZYPP_FWD_DECL_TYPE_WITH_REFS( ListChoiceRequest );
ZYPP_FWD_DECL_TYPE_WITH_REFS( BooleanChoiceRequest );

/*
constexpr std::string_view CTYPE_SHOW_MESSAGE_REQUEST ("userreq/show-message");
constexpr std::string_view CTYPE_LIST_CHOICE_REQUEST ("userreq/list-choice");
constexpr std::string_view CTYPE_BOOLEAN_COICE_REQUEST("userreq/boolean-choice");
*/


// keep in sync with glib wrapper code
enum class UserRequestType : uint {
Expand Down
10 changes: 7 additions & 3 deletions zypp-glib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ INCLUDE_DIRECTORIES ( ${LIBZYPP_SOURCE_DIR} ${LIBZYPP_BINARY_DIR} )
ADD_DEFINITIONS( -DLOCALEDIR="${CMAKE_INSTALL_PREFIX}/share/locale" -DTEXTDOMAIN="zypp" -DZYPP_DLL )

SET( zypp_glib_HEADERS
application.h
context.h
error.h
expected.h
Expand All @@ -44,6 +45,7 @@ SET( zypp_glib_ui_HEADERS

SET( zypp_glib_private_HEADERS
private/context_p.h
private/error_p.h
private/expected_p.h
private/globals_p.h
private/infobase_p.h
Expand All @@ -66,6 +68,7 @@ SET( zypp_glib_private_HEADERS
)

SET( zypp_glib_SRCS
application.cc
context.cc
error.cc
expected.cc
Expand All @@ -77,6 +80,7 @@ SET( zypp_glib_SRCS
repomanager.cc
repository.cc
serviceinfo.cc
zypp-glib.cc
ui/booleanchoicerequest.cc
ui/listchoicerequest.cc
ui/showmessagerequest.cc
Expand Down Expand Up @@ -128,7 +132,7 @@ ADD_LIBRARY( zypp-glib SHARED ${zypp_glib_lib_SRCS} ${zypp_glib_lib_HEADERS} )
target_link_libraries( zypp-glib zypp_lib_compiler_flags )
TARGET_LINK_LIBRARIES( zypp-glib zypp-allsym )
target_link_libraries( zypp-glib ${LIBGOBJECT_LIBRARIES} )
#target_link_libraries( zypp-glib ${LIBGIO_LIBRARIES} )
target_link_libraries( zypp-glib ${LIBGIO_LIBRARIES} )

INSTALL(TARGETS zypp-glib LIBRARY DESTINATION ${LIB_INSTALL_DIR} )

Expand All @@ -142,12 +146,12 @@ GENERATE_EXPORT_HEADER(

gobject_introspection(
FILENAME Zypp-1.0.gir
PACKAGES glib-2.0 gobject-2.0
PACKAGES glib-2.0 gobject-2.0 gio-2.0
NAMESPACE Zypp
LIBRARY zypp-glib
#QUIET
SCANNER_ARGS --add-include-path=${CMAKE_CURRENT_SOURCE_DIR}
--include=GLib-2.0 --include=GObject-2.0
--include=GLib-2.0 --include=GObject-2.0 --include=Gio-2.0
COMPILER_ARGS --includedir=${CMAKE_CURRENT_SOURCE_DIR}
SYMBOL_PREFIXES zypp
SOURCES ${zypp_glib_public_HEADERS}
Expand Down
Loading

0 comments on commit 56db9ad

Please sign in to comment.