2 * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
4 * Contact: Rafal Krypa <r.krypa@samsung.com>
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License
19 * @file base-service.cpp
20 * @author Lukasz Kostyra <l.kostyra@samsung.com>
21 * @author Rafal Krypa <r.krypa@samsung.com>
22 * @brief Implementation of security-manager base service.
26 #include <unordered_set>
28 #include <dpl/log/log.h>
30 #include "base-service.h"
32 namespace SecurityManager {
34 BaseService::BaseService()
38 void BaseService::accept(const AcceptEvent &event)
40 LogDebug("Accept event. ConnectionID.sock: " << event.connectionID.sock <<
41 " ConnectionID.counter: " << event.connectionID.counter <<
42 " ServiceID: " << event.interfaceID);
44 auto &info = m_connectionInfoMap[event.connectionID.counter];
45 info.interfaceID = event.interfaceID;
48 void BaseService::write(const WriteEvent &event)
50 LogDebug("WriteEvent. ConnectionID: " << event.connectionID.sock <<
51 " Size: " << event.size <<
52 " Left: " << event.left);
55 m_serviceManager->Close(event.connectionID);
58 void BaseService::process(const ReadEvent &event)
60 LogDebug("Read event for counter: " << event.connectionID.counter);
61 auto &info = m_connectionInfoMap[event.connectionID.counter];
62 info.buffer.Push(event.rawBuffer);
64 // We can get several requests in one package.
65 // Extract and process them all
66 while (processOne(event.connectionID, info.buffer, info.interfaceID));
69 void BaseService::close(const CloseEvent &event)
71 LogDebug("CloseEvent. ConnectionID: " << event.connectionID.sock);
72 m_connectionInfoMap.erase(event.connectionID.counter);
75 } // namespace SecurityManager