Send & receive array of responses and privileges 70/179770/26
authorTomasz Swierczek <t.swierczek@samsung.com>
Tue, 22 May 2018 06:39:33 +0000 (08:39 +0200)
committerTomasz Swierczek <t.swierczek@samsung.com>
Tue, 28 Aug 2018 04:56:17 +0000 (04:56 +0000)
This commit is a preparation for new API with many privileges as input.

Change-Id: I611348de78fa6231eab52c9f8069c957c4aa14a3
Signed-off-by: Ernest Borowski <e.borowski@partner.samsung.com>
13 files changed:
src/capi/test/privacy_privilege_manager_test.cpp
src/client/impl/ApiInterfaceImpl.cpp
src/client/impl/ClientCallbacks.cpp
src/client/impl/ClientCallbacks.h
src/ipc/client-channel.cpp
src/ipc/client-channel.h
src/ipc/message-utils.h
src/ipc/server-channel.cpp
src/ipc/server-channel.h
src/ipc/test/main.cpp
src/notification-daemon/Logic.cpp
src/notification-daemon/ServerCallbacks.cpp
src/notification-daemon/ServerCallbacks.h

index 4187ddc86465f39ad5c514d0030cc902ca0b4c6a..299dffd0fd5e32658257a3ca6851d2b360b40d23 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *  Copyright (c) 2017 - 2018 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
 /**
  * @file        privacy_privilege_manager.c
  * @author      Piotr Sawicki <p.sawicki2@partner.samsung.com>
+ * @author      Tomasz Swierczek <t.swierczek@samsung.com>
  * @brief       This file contains test of CAPI for Privacy Privilege Manager
  */
 
@@ -301,9 +302,9 @@ struct ServerSimulator : public IServerCallbacks {
         }
     }
 
-    virtual void popup(ConnectionFd fd, RequestId id, Privilege &&privilege) {
-        printf("\npopup request fd: %d requestId: %d privilege: \"%s\"\n", fd, id, privilege.c_str());
-        addRequest(fd, id, privilege);
+    virtual void popup(ConnectionFd fd, RequestId id, PrivilegeVector &&privileges) {
+        printf("\npopup request fd: %d requestId: %d privilege: \"%s\"\n", fd, id, privileges[0].c_str());
+        addRequest(fd, id, privileges[0]);
         printPrompt(Mode::SERVER);
     }
 
@@ -335,7 +336,7 @@ struct ServerSimulator : public IServerCallbacks {
         }
 
         if (m_channel) {
-            m_channel->popupResponse(fd, id, response);
+            m_channel->popupResponses(fd, id, {response});
 
             // delete request
             s.erase(reqIt);
@@ -348,7 +349,7 @@ struct ServerSimulator : public IServerCallbacks {
     void respondToAllRequests() {
         for (const auto &reqSet : m_requests) {
             for (const auto &req : reqSet.second) {
-                m_channel->popupResponse(reqSet.first, req.m_id, PRIVACY_PRIVILEGE_MANAGER_REQUEST_RESULT_DENY_ONCE);
+                m_channel->popupResponses(reqSet.first, req.m_id, {PRIVACY_PRIVILEGE_MANAGER_REQUEST_RESULT_DENY_ONCE});
             }
         }
 
index 16e6651be20bea077048597ed082dcc691422005..f7972efcb6611953de0547f2ce0700b980fabeed 100644 (file)
@@ -18,6 +18,7 @@
  * @file        ApiInterfaceImpl.cpp
  * @author      Piotr Sawicki <p.sawicki2@partner.samsung.com>
  * @author      Zofia Grzelewska <z.abramowska@samsung.com>
+ * @author      Ernest Borowski <e.borowski@partner.samsung.com>
  * @brief       The definition of ApiInterfaceImpl.
  */
 
@@ -124,7 +125,8 @@ RequestId ApiInterfaceImpl::popupRequest(const std::string &privilege,
                                          const askuser_popup_response_callback callback,
                                          void *userData)
 {
-    Protocol::ConnectionContext conCtx = m_channel->popupRequest(privilege);
+    std::vector<std::string> privileges({privilege});
+    Protocol::ConnectionContext conCtx = m_channel->popupRequest(std::move(privileges));
 
     auto sameRequest = [&] (const Request &req) {
         return req.m_requestId == conCtx.m_requestId;
index 5c5ca2e20b2917db21a8219bc098a052406cb13e..5ac155100208c82ca0889c01f1325226263e617e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *  Copyright (c) 2017 - 2018 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
 /**
  * @file        ClientCallbacks.cpp
  * @author      Piotr Sawicki <p.sawicki2@partner.samsung.com>
+ * @author      Ernest Borowski <e.borowski@partner.samsung.com>
  * @brief       The definition of ClientCallbacks.
  */
 
@@ -31,9 +32,9 @@ void ClientCallbacks::updateConnection(Protocol::ConnectionFd fd, int mask)
     m_api->updateConnection(fd, mask);
 }
 
-void ClientCallbacks::popupResponse(Protocol::RequestId id, int response)
+void ClientCallbacks::popupResponses(Protocol::RequestId id, const std::vector<int> &responses)
 {
-    m_api->popupResponse(id, response);
+    m_api->popupResponse(id, responses[0]);
 }
 
 } // namespace Client
index a0a8667b7e8cd1a98c3e3dcd64cb517131b4a8d5..c81b38487b0a6af593e6381d4279bbefaa6ef776 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *  Copyright (c) 2017 - 2018 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
 /**
  * @file        ClientCallbacks.h
  * @author      Piotr Sawicki <p.sawicki2@partner.samsung.com>
+ * @author      Ernest Borowski <e.borowski@partner.samsung.com>
  * @brief       The declaration of ClientCallbacks.
  */
 
 #pragma once
 
 #include <client-channel.h>
+#include <vector>
 
 #include "ApiInterfaceImpl.h"
 
@@ -37,7 +39,7 @@ public:
     {}
 
     virtual void updateConnection(Protocol::ConnectionFd fd, int mask);
-    virtual void popupResponse(Protocol::RequestId id, int response);
+    virtual void popupResponses(Protocol::RequestId id, const std::vector<int> &responses);
 
 private:
     ApiInterfaceImpl *m_api;
index 52593b15540256a10debe5db90a76feefd960ad4..a1b3cfb7ae5a2597ba51d15f58a860c192840a12 100644 (file)
@@ -17,6 +17,7 @@
  * @file        client-channel.cpp
  * @author      Bartlomiej Grzelewski <b.grzelewski@samsung.com>
  * @author      Piotr Sawicki <p.sawicki2@partner.samsung.com>
+ * @author      Ernest Borowski <e.borowski@partner.samsung.com>
  * @brief       The implementation of ClientChannel.
  */
 
@@ -58,15 +59,22 @@ AskUser::Protocol::RequestId ClientChannel::generateRequestId() {
     return requestId++;
 }
 
-Protocol::ConnectionContext ClientChannel::popupRequest(const std::string &privilege) {
+Protocol::ConnectionContext ClientChannel::popupRequest(const std::vector<std::string> &privileges) {
     int fd = connect(); // clients use only one connection per request
 
     std::stringstream ss;
     RequestId requestId = generateRequestId();
 
-    ss << MSGID_POPUP << " " << base64Encode(privilege) << " " << requestId << '\n';
+    ss << MSGID_POPUP << " " << requestId << " " << privileges.size() << " ";
+    for (auto &privilege : privileges)
+        ss << base64Encode(privilege) << " ";
+
+    ss << '\n';
 
     std::string str = ss.str();
+
+    ALOGD("popupRequests: sending message: " << str);
+
     std::copy(str.begin(), str.end(), std::back_inserter(m_sockets[fd].output));
 
     m_callbacks->updateConnection(fd, FdMask::READ | FdMask::WRITE);
@@ -87,20 +95,27 @@ int ClientChannel::onReceive(int fd, std::vector<std::string> &&message) {
         return -EINVAL;
     }
 
-    int command = std::stoi(message[0]);
+    int command = std::stoi(message[ASKUSER_MESSAGE_CMD_POS]);
 
     switch (command) {
     case MSGID_POPUP_RESPONSE:
         {
-            if (message.size() != 3) {
+            unsigned int responsesCount;
+            if (message.size() < ASKUSER_MESSAGE_MIN_MSG_PARAM_COUNT ||
+                message.size() != (responsesCount = std::stoul(message[ASKUSER_MESSAGE_PRIVILEGES_COUNT_POS])) +
+                ASKUSER_MESSAGE_MIN_MSG_PARAM_COUNT - 1) {
                 ALOGE("Inappropriate message size for MSGID_POPUP_RESPONSE command, size: " << message.size());
                 return -EINVAL;
             }
+            RequestId id = std::stoi(message[ASKUSER_MESSAGE_REQUESTID_POS]);
+            std::vector<int> responses;
+            responses.reserve(responsesCount);
 
-            RequestId id = std::stoi(message[1]);
-            int response = std::stoi(message[2]);
+            std::transform(std::next(message.begin(), ASKUSER_MESSAGE_FIRST_PRIVILEGE_POS), message.end(),
+                            std::back_inserter(responses),
+                            [](const std::string &response) -> int { return std::stoi(response); });
 
-            m_callbacks->popupResponse(id, response);
+            m_callbacks->popupResponses(id, responses);
 
             // after receiving the response just close the connection
             closeConnection(fd);
index fd1c94d9ec8d3abc935cfe12ca59722b854bd80a..cc63dce40a0c7f7781018b384411df91abfd1e1f 100644 (file)
@@ -17,6 +17,7 @@
  * @file        client-channel.h
  * @author      Bartlomiej Grzelewski <b.grzelewski@samsung.com>
  * @author      Piotr Sawicki <p.sawicki2@partner.samsung.com>
+ * @author      Ernest Borowski <e.borowski@partner.samsung.com>
  * @brief       The declaration of IClientCallbacks and ClientChannel.
  */
 #pragma once
@@ -51,12 +52,12 @@ struct IClientCallbacks {
     virtual void updateConnection(ConnectionFd fd, int mask) = 0;
 
     /**
-     * This function is called when popup response is received.
+     * This function is called when popup responses are received.
      *
      * \param[in] id Request identifier
-     * \param[in] response Response from popup
+     * \param[in] responses Response from popup
      */
-    virtual void popupResponse(RequestId id, int response) = 0;
+    virtual void popupResponses(RequestId id, const std::vector<int> &responses) = 0;
 };
 
 typedef std::unique_ptr<IClientCallbacks> ClientCallbacksPtr;
@@ -66,7 +67,7 @@ public:
     ClientChannel(ClientCallbacksPtr ptr);
     virtual ~ClientChannel();
 
-    virtual ConnectionContext popupRequest(const std::string &privilege);
+    virtual ConnectionContext popupRequest(const std::vector<std::string> &privileges);
 
 private:
     virtual void onAccept(int fd);
index 410665707112da65a43b67aeb9c55382d6f4d4ca..a842433945a0b646aca27735a5d3dbcc110c4f75 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2017 Samsung Electronics Co.
+ *  Copyright (c) 2017 - 2018 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.
@@ -16,6 +16,7 @@
 /**
  * @file        message-utils.h
  * @author      Piotr Sawicki <p.sawicki2@partner.samsung.com>
+ * @author      Tomasz Swierczek <t.swierczek@samsung.com>
  * @brief       The declaration of message handling helpers.
  */
 
@@ -62,6 +63,10 @@ inline std::size_t maxNumberOfChars()
 
 const std::size_t MIN_COMMAND_LENGTH = 1;
 const std::size_t MAX_COMMAND_LENGTH = maxNumberOfChars<int>();
+const std::size_t MIN_PRIVS_NUMBER_LENGTH = 1;
+const std::size_t MAX_PRIVS_NUMBER_LENGTH = maxNumberOfChars<int>();
+const std::size_t MIN_PRIVS_NUMBER = 1;
+const std::size_t MAX_PRIVS_NUMBER = 100;
 const std::size_t MIN_REQUEST_ID_LENGTH = 1;
 const std::size_t MAX_REQUEST_ID_LENGTH = maxNumberOfChars<RequestId>();
 const std::size_t MIN_PRIVILEGE_LENGTH = 1;
@@ -76,33 +81,51 @@ const std::size_t MIN_REQUEST_MESSAGE_LENGTH = MIN_COMMAND_LENGTH +
                                                SEP_LEN + // space
                                                MIN_REQUEST_ID_LENGTH +
                                                SEP_LEN + // space
-                                               MIN_PRIVILEGE_ENC_LENGTH +
-                                               SEP_LEN; // new line
+                                               MIN_PRIVS_NUMBER_LENGTH +
+                                               MIN_PRIVS_NUMBER * (
+                                               SEP_LEN + // space
+                                               MIN_PRIVILEGE_ENC_LENGTH) +
+                                               SEP_LEN;  // new line
 
 const std::size_t MAX_REQUEST_MESSAGE_LENGTH = MAX_COMMAND_LENGTH +
                                                SEP_LEN + // space
                                                MAX_REQUEST_ID_LENGTH +
                                                SEP_LEN + // space
-                                               MAX_PRIVILEGE_ENC_LENGTH +
+                                               MAX_PRIVS_NUMBER_LENGTH +
+                                               MAX_PRIVS_NUMBER * (
+                                               SEP_LEN + // space
+                                               MAX_PRIVILEGE_ENC_LENGTH) +
                                                SEP_LEN; // new line
 
 const std::size_t MIN_RESPONSE_MESSAGE_LENGTH = MIN_COMMAND_LENGTH +
                                                 SEP_LEN + // space
                                                 MIN_REQUEST_ID_LENGTH +
                                                 SEP_LEN + // space
-                                                MIN_RESPONSE_STATUS_LEN +
+                                                MIN_PRIVS_NUMBER_LENGTH +
+                                                MIN_PRIVS_NUMBER * (
+                                                SEP_LEN + // space
+                                                MIN_RESPONSE_STATUS_LEN) +
                                                 SEP_LEN; // new line
 
 const std::size_t MAX_RESPONSE_MESSAGE_LENGTH = MAX_COMMAND_LENGTH +
                                                 SEP_LEN + // space
                                                 MAX_REQUEST_ID_LENGTH +
                                                 SEP_LEN + // space
-                                                MAX_RESPONSE_STATUS_LEN +
+                                                MAX_PRIVS_NUMBER_LENGTH +
+                                                MAX_PRIVS_NUMBER * (
+                                                SEP_LEN + // space
+                                                MAX_RESPONSE_STATUS_LEN) +
                                                 SEP_LEN; // new line
 
 const std::size_t MIN_MESSAGE_LENGTH = std::min(MIN_REQUEST_MESSAGE_LENGTH, MIN_RESPONSE_MESSAGE_LENGTH);
 const std::size_t MAX_MESSAGE_LENGTH = std::max(MAX_REQUEST_MESSAGE_LENGTH, MAX_RESPONSE_MESSAGE_LENGTH);
 
+const unsigned int ASKUSER_MESSAGE_CMD_POS = 0;
+const unsigned int ASKUSER_MESSAGE_REQUESTID_POS = 1;
+const unsigned int ASKUSER_MESSAGE_PRIVILEGES_COUNT_POS = 2;
+const unsigned int ASKUSER_MESSAGE_FIRST_PRIVILEGE_POS = 3;
+const unsigned int ASKUSER_MESSAGE_MIN_MSG_PARAM_COUNT = 4; //cmd, requestId, privilegeCount, privilege
+
 std::string base64Encode(std::string input);
 std::string base64Decode(std::string input);
 
index aaa0431eb5d6b902a4cf5a986260f80ac2613d72..9c839313bfd185c0312b37b7d281b55755aa2679 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2017 Samsung Electronics Co.
+ *  Copyright (c) 2017 - 2018 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.
@@ -17,6 +17,7 @@
  * @file        server-channel.cpp
  * @author      Bartlomiej Grzelewski <b.grzelewski@samsung.com>
  * @author      Piotr Sawicki <p.sawicki2@partner.samsung.com>
+ * @author      Ernest Borowski <e.borowski@partner.samsung.com>
  * @brief       The implementation of ServerChannel.
  */
 
@@ -55,7 +56,7 @@ void ServerChannel::init() {
     m_callbacks->updateConnection(fd, FdMask::READ);
 }
 
-void ServerChannel::popupResponse(ConnectionFd fd, RequestId id, int response) {
+void ServerChannel::popupResponses(ConnectionFd fd, RequestId id, std::vector<int> &&responses) {
     try {
         auto it = m_sockets.find(fd);
         if (it == m_sockets.end()) {
@@ -66,8 +67,15 @@ void ServerChannel::popupResponse(ConnectionFd fd, RequestId id, int response) {
         auto &desc = it->second;
 
         std::stringstream ss;
-        ss << MSGID_POPUP_RESPONSE << " " << id << " " << response << '\n';
+        ss << MSGID_POPUP_RESPONSE << " " << id << " " << responses.size();
+        for (const auto &response: responses) {
+            ss << " " << response;
+        }
+        ss << '\n';
         std::string o = ss.str();
+
+        ALOGD("popupResponse: sending message: " << o);
+
         std::copy(o.begin(), o.end(), std::back_inserter(desc.output));
 
         m_callbacks->updateConnection(fd, FdMask::READ | FdMask::WRITE);
@@ -91,20 +99,30 @@ int ServerChannel::onReceive(int fd, std::vector<std::string> &&message) {
         return -EINVAL;
     }
 
-    int command = std::stoi(message[0]);
+    int command = std::stoi(message[ASKUSER_MESSAGE_CMD_POS]);
 
     switch (command) {
     case MSGID_POPUP:
         {
-            if (message.size() != 3) {
+            unsigned int privilegesCount;
+            if (message.size() < ASKUSER_MESSAGE_MIN_MSG_PARAM_COUNT ||
+                message.size() !=  (privilegesCount = std::stoul(message[ASKUSER_MESSAGE_PRIVILEGES_COUNT_POS])) +
+                ASKUSER_MESSAGE_MIN_MSG_PARAM_COUNT - 1) {
                 ALOGE("Inappropriate message size for MSGID_POPUP command, size: " << message.size());
                 return -EINVAL;
             }
+            ALOGD("privilegesCount:" << privilegesCount);
+            std::vector<std::string> privileges;
+            privileges.reserve(privilegesCount);
+
+            std::transform(std::next(message.begin(), ASKUSER_MESSAGE_FIRST_PRIVILEGE_POS), message.end(),
+                            std::back_inserter(privileges),
+                            [](const std::string &priv) -> std::string {return base64Decode(priv); });
+
+            RequestId requestId = std::stoi(message[ASKUSER_MESSAGE_REQUESTID_POS]);
 
-            std::string privilege = base64Decode(message[1]);
-            RequestId requestId = std::stoi(message[2]);
+            m_callbacks->popup(fd, requestId, std::move(privileges));
 
-            m_callbacks->popup(fd, requestId, std::move(privilege));
             break;
         }
     default :
index cb3e2d538c93d146fe57a01aeb8613f4fd963172..ca0b913568d8048a219d71753de2cafd5755417b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2017 Samsung Electronics Co.
+ *  Copyright (c) 2017 - 2018 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.
@@ -17,6 +17,7 @@
  * @file        server-channel.h
  * @author      Bartlomiej Grzelewski <b.grzelewski@samsung.com>
  * @author      Piotr Sawicki <p.sawicki2@partner.samsung.com>
+ * @author      Ernest Borowski <e.borowski@partner.samsung.com>
  * @brief       The declaration of IServerCallbacks and ServerChannel.
  */
 #pragma once
@@ -64,9 +65,9 @@ struct IServerCallbacks {
      *
      * \param[in] fd Connection file descriptor
      * \param[in] id Request identifier
-     * \param[in] privilege Privilege for which permission is asked for
+     * \param[in] privileges Privileges for which permissions are asked for
      */
-    virtual void popup(ConnectionFd fd, RequestId id, std::string &&privilege) = 0;
+    virtual void popup(ConnectionFd fd, RequestId id, std::vector<std::string> &&privileges) = 0;
 };
 
 typedef std::unique_ptr<IServerCallbacks> ServerCallbacksPtr;
@@ -76,7 +77,7 @@ public:
     ServerChannel(ServerCallbacksPtr ptr);
     virtual ~ServerChannel();
 
-    virtual void popupResponse(ConnectionFd fd, RequestId id, int response);
+    virtual void popupResponses(ConnectionFd fd, RequestId id, std::vector<int> &&responses);
 
 private:
     virtual void onAccept(int fd);
index 5f42c4f170dfe553e13c16ba569ff3ac1c7e7c17..6f130a02b9a2c499073a5f136ad208265b1c2cec 100644 (file)
@@ -17,6 +17,7 @@
  * @file        main.cpp
  * @author      Bartlomiej Grzelewski <b.grzelewski@samsung.com>
  * @author      Piotr Sawicki <p.sawicki2@partner.samsung.com>
+ * @author      Tomasz Swierczek <t.swierczek@samsung.com>
  * @brief
  */
 #include <exception>
@@ -54,10 +55,11 @@ struct ServerCallbacks : public IServerCallbacks {
         m_sockets[fd] = mask;
     }
 
-    virtual void popup(ConnectionFd fd, RequestId id, Privilege &&priv) {
-        printf("call popup %s \n", priv.c_str());
-        if (m_channel)
-            m_channel->popupResponse(fd, id, responseCounter++ % (ASKUSER_ALLOW_FOREVER + 1));
+    virtual void popup(ConnectionFd fd, RequestId id, PrivilegeVector &&priv) {
+        printf("call popup %s \n", priv[0].c_str());
+        if (m_channel) {
+            m_channel->popupResponses(fd, id, { responseCounter++ % (ASKUSER_ALLOW_FOREVER + 1) });
+        }
     }
 
     void setChannel(ServerChannel *ptr) {
@@ -111,8 +113,12 @@ struct ClientCallbacks : public IClientCallbacks {
         m_sockets[fd] = mask;
     }
 
-    virtual void popupResponse(RequestId id, int response) {
-        printf("response from popup id: %d response: %d\n", id, response);
+    virtual void popupResponses(RequestId id, const std::vector<int> &responses) {
+        if (responses.empty()) {
+            printf("Response from popup id: %d is empty\n", id);
+            return;
+        }
+        printf("response from popup id: %d response: %d\n", id, responses[0]);
     }
 
     void setChannel(ClientChannel *ptr) {
@@ -161,7 +167,7 @@ void client() {
                         printf("Invalid argument\n");
                         break;
                     }
-                    chan->popupRequest(privilege);
+                    chan->popupRequest({privilege});
                 }
                 break;
             default:
index 216f0ee01caa11f8ebd1b312397c6ecf948f08dd..009a1e47da957f97c184490d49e8ed806c308d39 100644 (file)
@@ -16,6 +16,7 @@
 /**
  * @file        Logic.cpp
  * @author      Zofia Grzelewska <z.abramowska@samsung.com>
+ * @author      Tomasz Swierczek <t.swierczek@samsung.com>
  * @brief       Declaration of Logic class
  */
 
@@ -238,17 +239,17 @@ void Logic::popup(Protocol::ConnectionFd fd, Protocol::RequestId id, const std::
 
         ALOGD("Privilege policy level calculated to : " << policyLevel);
         if (policyLevel == "Allow") {
-            m_serverChannel->popupResponse(fd, id, ASKUSER_ALLOW_FOREVER);
+            m_serverChannel->popupResponses(fd, id, {ASKUSER_ALLOW_FOREVER});
             return;
         }
         if (policyLevel == "Deny") {
-            m_serverChannel->popupResponse(fd, id, ASKUSER_DENY_FOREVER);
+            m_serverChannel->popupResponses(fd, id, {ASKUSER_DENY_FOREVER});
             return;
         }
         if (policyLevel != "Ask user") {
             ALOGE("Unknown policy set : " << policyLevel << " for (" << conn.appId << ", " << conn.user
                   << ", " << privilege << ")");
-            m_serverChannel->popupResponse(fd, id, ASKUSER_DENY_ONCE);
+            m_serverChannel->popupResponses(fd, id, {ASKUSER_DENY_ONCE});
             return;
         }
 
@@ -256,7 +257,7 @@ void Logic::popup(Protocol::ConnectionFd fd, Protocol::RequestId id, const std::
         if (privacies.empty()) {
             ALOGE("All privacies for privilege " << privilege
                   << " are already allowed");
-            m_serverChannel->popupResponse(fd, id, ASKUSER_ALLOW_FOREVER);
+            m_serverChannel->popupResponses(fd, id, {ASKUSER_ALLOW_FOREVER});
             return;
         }
 
@@ -264,7 +265,7 @@ void Logic::popup(Protocol::ConnectionFd fd, Protocol::RequestId id, const std::
         processEvents();
     } catch (const std::exception &e) {
         ALOGE("Failed to handle popup request : " << e.what());
-        m_serverChannel->popupResponse(fd, id, ASKUSER_DENY_ONCE);
+        m_serverChannel->popupResponses(fd, id, {ASKUSER_DENY_ONCE});
     }
 }
 
@@ -429,9 +430,9 @@ bool Logic::setPolicy(const ConnectionInfo &conn, const std::string &lastPolicy)
 
 void Logic::processResponse(const ConnectionInfo &conn, int clientResponse, const Policy &level) {
     if (!setPolicy(conn, level)) {
-        m_serverChannel->popupResponse(m_currentEvent.fd, m_currentEvent.id, ASKUSER_UNKNOWN_ERROR);
+        m_serverChannel->popupResponses(m_currentEvent.fd, m_currentEvent.id, {ASKUSER_UNKNOWN_ERROR});
     } else {
-        m_serverChannel->popupResponse(m_currentEvent.fd, m_currentEvent.id, clientResponse);
+        m_serverChannel->popupResponses(m_currentEvent.fd, m_currentEvent.id, {clientResponse});
     }
 }
 
index 5f438ba49f5e40c0aed795b506964fc4da4cff77..e830e8415327c126435233b8e8b4acf2339ada4e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2017 Samsung Electronics Co.
+ *  Copyright (c) 2017 - 2018 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.
@@ -16,6 +16,7 @@
 /**
  * @file        src/agent/notification-daemon/ServerCallbacks.cpp
  * @author      Zofia Abramowska <z.abramowska@samsung.com>
+ * @author      Ernest Borowski <e.borowski@partner.samsung.com>
  * @brief       Implementation ServerCallbacks classes
  */
 #include <unistd.h>
@@ -48,8 +49,8 @@ void ServerCallbacks::updateConnection(ConnectionFd fd, int mask) {
         m_service->updateChannelFd(fd, maskToFlags(mask));
 }
 
-void ServerCallbacks::popup(ConnectionFd fd, RequestId id, std::string &&privilege) {
-    m_service->popup(fd, id, privilege);
+void ServerCallbacks::popup(ConnectionFd fd, RequestId id, std::vector<std::string> &&privileges) {
+    m_service->popup(fd, id, privileges[0]);
 }
 
 } /* namespace Notification */
index d22d2b0b2ec591cf7edb3019f49868e5b1ec494f..d8f1c27b73a165c79f524558d75824e842b0dc92 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2017 Samsung Electronics Co.
+ *  Copyright (c) 2017 - 2018 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.
 /**
  * @file        src/agent/notification-daemon/ServerCallbacks.h
  * @author      Zofia Abramowska <z.abramowska@samsung.com>
+ * @author      Ernest Borowski <e.borowski@partner.samsung.com>
  * @brief       Declaration of ServerCallbacks classes
  */
 #pragma once
 
 #include <memory>
+#include <vector>
 
 #include <server-channel.h>
 
@@ -37,7 +39,7 @@ public:
     {}
     virtual void newConnection(ConnectionFd fd, const Credentials &creds);
     virtual void updateConnection(ConnectionFd fd, int mask);
-    virtual void popup(ConnectionFd fd, RequestId id, std::string &&privilege);
+    virtual void popup(ConnectionFd fd, RequestId id, std::vector<std::string> &&privileges);
 
     virtual ~ServerCallbacks() {}
 private: