1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef ISESSION_SERVICE_H 17 #define ISESSION_SERVICE_H 18 19 #include <shared_mutex> 20 #include "CommDefs.h" 21 #include "ISessionListener.h" 22 #include "Session.h" 23 24 namespace Communication { 25 namespace SoftBus { 26 class COMM_EXPORT ISessionService { 27 public: 28 static std::shared_ptr<ISessionService> GetInstance(); 29 30 ISessionService() = default; 31 virtual ~ISessionService() = default; 32 33 virtual int CreateSessionServer(const std::string &pkgName, const std::string &sessionName, 34 std::shared_ptr<ISessionListener> listener) = 0; 35 36 virtual int RemoveSessionServer(const std::string &pkgName, const std::string &sessionName) = 0; 37 38 virtual std::shared_ptr<Session> OpenSession(const std::string &mySessionName, const std::string &peerSessionName, 39 const std::string &peerNetworkId, const std::string &groupId, int flags) = 0; 40 41 virtual int CloseSession(std::shared_ptr<Session> session) = 0; 42 43 virtual int GrantPermission(int uid, int pid, const std::string &busName) = 0; 44 45 virtual int RemovePermission(const std::string &busName) = 0; 46 47 private: 48 NO_COPY_AND_ASSIGN(ISessionService); 49 static std::shared_ptr<ISessionService> instance_; 50 static std::shared_mutex instanceMutex_; 51 }; 52 } // namespace SoftBus 53 } // namespace Communication 54 55 #endif // ISESSION_SERVICE_H 56