Fix pkgmgr_client_remove_listen_status
[platform/core/appfw/slp-pkgmgr.git] / client / src / connector.hh
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17
18 #ifndef CLIENT_SRC_CONNECTOR_H_
19 #define CLIENT_SRC_CONNECTOR_H_
20
21 #include <sys/un.h>
22
23 #include <memory>
24 #include <string>
25 #include <vector>
26
27 #include "PkgMgrProxy.h"
28
29 #include "connection_event_listener.hh"
30 #include "signal_receiver.hh"
31
32 namespace pkgmgr {
33 namespace client {
34
35 namespace pkg_proxy = rpc_port::PkgMgrProxy::proxy;
36 namespace pp = rpc_port::PkgMgrProxy;
37
38 class Connector {
39  public:
40   Connector(pkgmgr_client_type pc_type) : pc_type_(pc_type),
41       status_type_(PKGMGR_CLIENT_STATUS_ALL) {}
42   virtual ~Connector();
43
44   virtual pkg_proxy::PkgMgrAdmin* GetAdminProxy();
45   virtual pkg_proxy::PkgMgr* GetInfoProxy();
46   virtual pkg_proxy::PkgMgrForClearCache* GetCacheProxy();
47   virtual pkg_proxy::DelayedResult* GetDelayedResultProxy();
48   virtual const std::unique_ptr<SignalReceiver>& GetSignalReceiver();
49   std::string GenerateRequestId() const;
50   void SetTep(std::string tep_path, bool tep_move);
51   void SetTepArgs();
52   void SetDebugMode();
53   void SetSkipOptimization();
54   void SetStatusType(int status_type);
55   const std::vector<std::string>& GetArgv() const;
56   pkgmgr_client_type GetPcType() const;
57   std::vector<std::string>& GetResRemovePath();
58   std::vector<std::string>& GetResCreateDir();
59   std::vector<pp::ResPath>& GetResCopyPath();
60   const std::string& GetTepPath();
61   bool GetTepMove();
62   void RemoveSignalReceiver();
63
64  private:
65   bool ConnectForAdmin();
66   bool ConnectForInfo();
67   bool ConnectForCache();
68   bool ConnectForDelayedResult();
69
70  private:
71   pkgmgr_client_type pc_type_;
72   int status_type_;
73   std::unique_ptr<pkg_proxy::PkgMgr> info_proxy_;
74   std::unique_ptr<pkg_proxy::PkgMgrForClearCache> cache_proxy_;
75   std::unique_ptr<pkg_proxy::PkgMgrAdmin> admin_proxy_;
76   std::unique_ptr<pkg_proxy::DelayedResult> delayed_result_proxy_;
77   std::vector<std::string> argv_;
78   ConnectionEventListener<pkg_proxy::PkgMgrAdmin> conn_admin_listener_;
79   ConnectionEventListener<pkg_proxy::PkgMgr> conn_info_listener_;
80   ConnectionEventListener<pkg_proxy::PkgMgrForClearCache> conn_cache_listener_;
81   ConnectionEventListener<pkg_proxy::DelayedResult> conn_delayed_result_listener_;
82   std::unique_ptr<SignalReceiver> signal_receiver_;
83   std::vector<std::string> res_remove_path_;
84   std::vector<std::string> res_create_dir_;
85   std::vector<pp::ResPath> res_copy_path_;
86   std::string tep_path_;
87   bool tep_move_ = false;
88 };
89
90 }  // namespace client
91 }  // namespace pkgmgr
92
93 #endif  // CLIENT_SRC_CONNECTOR_H_