INCLUDE_DIRECTORIES(
${ASKUSER_PATH}
${ASKUSER_PATH}/common
+ ${ASKUSER_PATH}/common/protocol
)
SET(ASKUSER_NOTIFICATION_SOURCES
${NOTIF_PATH}/main.cpp
${NOTIF_PATH}/GuiRunner.cpp
${NOTIF_PATH}/AskUserTalker.cpp
+ ${NOTIF_PATH}/ServerCallbacks.cpp
${NOTIF_PATH}/ui/Po.cpp
${ASKUSER_PATH}/common/log/alog.cpp
${ASKUSER_PATH}/common/socket/Socket.cpp
TARGET_LINK_LIBRARIES(${TARGET_ASKUSER_NOTIFICATION}
${ASKUSER_NOTIFICATION_DEP_LIBRARIES}
${TARGET_ASKUSER_COMMON}
+ ${TARGET_ASKUSER_NOTIFICATION_LIB}
-pie
)
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+/**
+ * @file src/agent/notification-daemon/ServerCallbacks.cpp
+ * @author Zofia Abramowska <z.abramowska@samsung.com>
+ * @brief Implementation ServerCallbacks classes
+ */
+#include <unistd.h>
+
+#include "ServerCallbacks.h"
+#include "event/Event.h"
+
+namespace {
+Ecore_Fd_Handler_Flags maskToFlags(int mask) {
+ int flags = ECORE_FD_ERROR;
+ if (mask & AskUser::Protocol::READ)
+ flags |= static_cast<int>(ECORE_FD_READ);
+ if (mask & AskUser::Protocol::WRITE)
+ flags |= static_cast<int>(ECORE_FD_WRITE);
+ return static_cast<Ecore_Fd_Handler_Flags>(flags);
+}
+}
+
+namespace AskUser {
+namespace Protocol {
+
+void ServerCallbacks::updateFd(int fd, int mask) {
+ if (mask == 0)
+ m_service->removeChannelFd(fd);
+ else
+ m_service->addChannelFd(fd, maskToFlags(mask));
+}
+
+void ServerCallbacks::popup_launch(int requestId, const std::string &pkgName,
+ const std::string &appName, uid_t,
+ const AskUser::Protocol::PrivilegeVector &privileges)
+{
+ m_service->addEvent(new AskUser::Notification::EventPopupLaunch(m_popupper, requestId, appName, pkgName, privileges));
+}
+void ServerCallbacks::toast_deny(const std::string &pkgName, const std::string &appName,
+ uid_t, const AskUser::Protocol::Privilege &privilege)
+{
+ m_service->addEvent(new AskUser::Notification::EventToastDeny(m_popupper, 0, appName, pkgName, privilege));
+}
+void ServerCallbacks::toast_fail_launch(const std::string &pkgName, const std::string &appName,
+ uid_t)
+{
+ m_service->addEvent(new AskUser::Notification::EventToastFail(m_popupper, 0, appName, pkgName));
+}
+
+} /* namespace Notification */
+} /* namespace Askuser */
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+/**
+ * @file src/agent/notification-daemon/ServerCallbacks.h
+ * @author Zofia Abramowska <z.abramowska@samsung.com>
+ * @brief Declaration of ServerCallbacks classes
+ */
+#pragma once
+
+#include <memory>
+
+#include <askuser-notification/ask-user-service.h>
+
+#include "Logic.h"
+#include "ui/Popupper.h"
+
+namespace AskUser {
+namespace Protocol {
+
+class ServerCallbacks : public IServerCallbacks {
+public:
+ ServerCallbacks(AskUser::Notification::Logic *logic, AskUser::Notification::Popupper *popupper)
+ : m_service(logic), m_popupper(popupper)
+ {}
+ virtual void updateFd(int fd, int mask);
+ virtual void popup_launch(int requestId, const std::string &pkgName,
+ const std::string &appName, uid_t uid,
+ const AskUser::Protocol::PrivilegeVector &privileges);
+ virtual void toast_deny(const std::string &pkgName, const std::string &appName,
+ uid_t uid, const AskUser::Protocol::Privilege &privilege);
+ virtual void toast_fail_launch(const std::string &pkgName, const std::string &appName,
+ uid_t uid);
+ virtual ~ServerCallbacks() {}
+private:
+ AskUser::Notification::Logic *m_service;
+ AskUser::Notification::Popupper *m_popupper;
+};
+
+} /* namespace Notification */
+} /* namespace Askuser */
+