ApiInterfaceImpl::ApiInterfaceImpl(const StatusCallbackClosure &statusClosure)
: m_statusClosure(statusClosure)
-, m_channel(std::move(Protocol::ClientCallbacksPtr(new ClientCallbacks(this))))
{
+ Protocol::ClientCallbacksPtr callbacks(new ClientCallbacks(this));
+ std::unique_ptr<Protocol::ClientChannel> channel(new Protocol::ClientChannel(std::move(callbacks)));
+ m_channel = std::move(channel);
}
ApiInterfaceImpl::~ApiInterfaceImpl()
}
m_callbacks.clear();
+ m_channel.reset();
}
int ApiInterfaceImpl::process(int fd, int events)
{
- return m_channel.process(fd, eventsToAskUserMask(events));
+ return m_channel->process(fd, eventsToAskUserMask(events));
}
askuser_check_result ApiInterfaceImpl::checkPrivilege(const std::string &privilege)
RequestId ApiInterfaceImpl::popupRequest(const PopupCallbackClosure &closure,
const std::string &privilege)
{
- Client::RequestId id = static_cast<Client::RequestId>(m_channel.popupRequest(privilege));
+ Client::RequestId id = static_cast<Client::RequestId>(m_channel->popupRequest(privilege));
auto it = m_callbacks.find(id);
if (it != m_callbacks.end()) {
private:
StatusCallbackClosure m_statusClosure;
- Protocol::ClientChannel m_channel;
+ std::unique_ptr<Protocol::ClientChannel> m_channel;
std::map<RequestId, PopupCallbackClosure> m_callbacks;
};
addEvent({fd, id}, new EventPopupCheck(&m_popupper, pkgId, privilege));
}
+Logic::~Logic()
+{
+ m_serverChannel.reset();
+}
+
bool Logic::isEventProcessed() {
return m_currentEvent.fd != Protocol::INVALID_FD;
}
void popup(Protocol::ConnectionFd fd, Protocol::RequestId id, const std::string &privilege);
- ~Logic() {}
+ ~Logic();
private:
struct EventId {
EventId() : fd(Protocol::INVALID_FD), id(Protocol::INVALID_ID) {}