Dobby  3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
Classes | Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
SDBusIpcService Class Reference
Inheritance diagram for SDBusIpcService:
Inheritance graph
[legend]
Collaboration diagram for SDBusIpcService:
Collaboration graph
[legend]

Classes

struct  Executor
 
struct  RegisteredMethod
 
struct  RegisteredSignal
 

Public Types

enum  BusType { SessionBus , SystemBus }
 

Public Member Functions

 SDBusIpcService (BusType busType, const std::string &serviceName, int defaultTimeoutMs=-1)
 
 SDBusIpcService (const std::string &busAddress, const std::string &serviceName, int defaultTimeoutMs=-1)
 
bool isValid () const override
 Returns true if we initialised ourselves successfully. More...
 
std::shared_ptr< AI_IPC::IAsyncReplyGetterinvokeMethod (const AI_IPC::Method &method, const AI_IPC::VariantList &args, int timeoutMs) override
 
bool invokeMethod (const AI_IPC::Method &method, const AI_IPC::VariantList &args, AI_IPC::VariantList &replyArgs, int timeoutMs) override
 
bool emitSignal (const AI_IPC::Signal &signal, const AI_IPC::VariantList &args) override
 
std::string registerMethodHandler (const AI_IPC::Method &method, const AI_IPC::MethodHandler &handler) override
 
std::string registerSignalHandler (const AI_IPC::Signal &signal, const AI_IPC::SignalHandler &handler) override
 
bool unregisterHandler (const std::string &regId) override
 
bool enableMonitor (const std::set< std::string > &matchRules, const AI_IPC::MonitorHandler &handler) override
 
bool disableMonitor () override
 
void flush () override
 
bool start () override
 
bool stop () override
 
bool isServiceAvailable (const std::string &serviceName) const override
 
std::string getBusAddress () const override
 

Private Member Functions

void freeMethodReply (uint32_t replyId)
 
bool sendMethodReply (uint32_t replyId, const AI_IPC::VariantList &replyArgs)
 
uid_t getSenderUid (const std::string &senderName)
 
bool init (const std::string &serviceName, int defaultTimeoutMs)
 
void eventLoopThread ()
 
bool runOnEventLoopThread (std::function< void()> &&fn) const
 

Static Private Member Functions

static int onExecCall (sd_event_source *s, int fd, uint32_t revents, void *userdata)
 
static int onRuleMatch (sd_bus_message *m, void *userData, void *retError)
 
static int onMethodCall (sd_bus_message *reply, void *userData, void *retError)
 
static int onMethodReply (sd_bus_message *reply, void *userData, void *retError)
 

Private Attributes

uint64_t mDefaultTimeoutUsecs
 
std::thread mThread
 
sd_bus * mSDBus
 
std::atomic< bool > mStarted
 
bool mValid
 
uint64_t mHandlerTag
 
std::map< std::string, RegisteredMethodmMethodHandlers
 
std::map< std::string, RegisteredSignalmSignalHandlers
 
uint64_t mExecCounter
 
uint64_t mLastExecTag
 
int mExecEventFd
 
std::mutex mExecLock
 
std::condition_variable mExecCond
 
std::deque< ExecutormExecQueue
 
std::map< uint64_t, std::shared_ptr< SDBusAsyncReplyGetter > > mCalls
 
std::map< uint32_t, sd_bus_message * > mCallReplies
 
std::queue< uint32_t > mReplyIdentifiers
 

Friends

class SDBusAsyncReplySender
 

Member Function Documentation

◆ disableMonitor()

bool SDBusIpcService::disableMonitor ( )
overridevirtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Implements AI_IPC::IIpcService.

◆ emitSignal()

bool SDBusIpcService::emitSignal ( const AI_IPC::Signal signal,
const AI_IPC::VariantList &  args 
)
overridevirtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Implements AI_IPC::IIpcService.

◆ enableMonitor()

bool SDBusIpcService::enableMonitor ( const std::set< std::string > &  matchRules,
const AI_IPC::MonitorHandler &  handler 
)
overridevirtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Implements AI_IPC::IIpcService.

◆ flush()

void SDBusIpcService::flush ( )
overridevirtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

This is a NOP for the SDBus implementation.

Implements AI_IPC::IIpcService.

◆ getBusAddress()

std::string SDBusIpcService::getBusAddress ( ) const
overridevirtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Implements AI_IPC::IIpcService.

◆ invokeMethod() [1/2]

bool SDBusIpcService::invokeMethod ( const AI_IPC::Method method,
const AI_IPC::VariantList &  args,
AI_IPC::VariantList &  replyArgs,
int  timeoutMs 
)
overridevirtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Implements AI_IPC::IIpcService.

◆ invokeMethod() [2/2]

std::shared_ptr< IAsyncReplyGetter > SDBusIpcService::invokeMethod ( const AI_IPC::Method method,
const AI_IPC::VariantList &  args,
int  timeoutMs 
)
overridevirtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Implements AI_IPC::IIpcService.

◆ isServiceAvailable()

bool SDBusIpcService::isServiceAvailable ( const std::string &  serviceName) const
overridevirtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Checks if the service with the given name serviceName is registered on the bus and therefore available.

Implements AI_IPC::IIpcService.

◆ isValid()

bool SDBusIpcService::isValid ( ) const
overridevirtual

Returns true if we initialised ourselves successfully.

Returns
True if the service was initialised successfully. False if we failed to initialise

Implements AI_IPC::IIpcService.

◆ registerMethodHandler()

std::string SDBusIpcService::registerMethodHandler ( const AI_IPC::Method method,
const AI_IPC::MethodHandler &  handler 
)
overridevirtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Implements AI_IPC::IIpcService.

◆ registerSignalHandler()

std::string SDBusIpcService::registerSignalHandler ( const AI_IPC::Signal signal,
const AI_IPC::SignalHandler &  handler 
)
overridevirtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Implements AI_IPC::IIpcService.

◆ start()

bool SDBusIpcService::start ( )
overridevirtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Starts the IpcService, this is a bit of NOP for sd-bus, it just sets a flag to say that handlers will now be called.

Implements AI_IPC::IIpcService.

◆ stop()

bool SDBusIpcService::stop ( )
overridevirtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Stops the IpcService by terminating the event loop thread.

Implements AI_IPC::IIpcService.

◆ unregisterHandler()

bool SDBusIpcService::unregisterHandler ( const std::string &  regId)
overridevirtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Implements AI_IPC::IIpcService.


The documentation for this class was generated from the following files: