Delay server ready timing until creating cache
[platform/core/appfw/pkgmgr-info.git] / src / server / create_cache_request.hh
1 /*
2  * Copyright (c) 2021 - 2022 Samsung Electronics Co., Ltd All Rights Reserved
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 #ifndef SERVER_CREATE_CACHE_REQUEST_HH_
18 #define SERVER_CREATE_CACHE_REQUEST_HH_
19
20 #include <sys/types.h>
21
22 #include "pkg_request.hh"
23 #include "request_type.hh"
24
25 namespace pkgmgr_server {
26
27 #ifndef EXPORT_API
28 #define EXPORT_API __attribute__((visibility("default")))
29 #endif
30
31 class EXPORT_API CreateCacheRequest : public PkgRequest {
32  public:
33   class IEvent {
34    public:
35     virtual ~IEvent() {}
36     virtual void OnCreateCacheDone(bool success) = 0;
37   };
38
39   CreateCacheRequest(uid_t uid, IEvent* listener)
40       : uid_(uid), listener_(listener) {}
41   const unsigned char* GetData() override;
42   int GetSize() override;
43   pid_t GetSenderPID() override;
44   uid_t GetSenderUID() override;
45   pkgmgr_common::ReqType GetRequestType() override;
46   bool SendData(unsigned char* data, int size) override;
47   bool GetPrivilegeChecked() override;
48
49  private:
50   uid_t uid_;
51   IEvent* listener_;
52 };
53
54 }  // namespace pkgmgr_server
55
56 #endif  // SERVER_CREATE_CACHE_REQUEST_HH_