• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 REQUEST_H
17 #define REQUEST_H
18 
19 #include <list>
20 #include <string>
21 
22 #include "i_locator_callback.h"
23 #include "request_config.h"
24 
25 namespace OHOS {
26 namespace Location {
27 class Request {
28 public:
29     Request();
30     ~Request();
31     pid_t GetUid();
32     pid_t GetPid();
33     std::string GetPackageName();
34     sptr<RequestConfig> GetRequestConfig();
35     sptr<ILocatorCallback> GetLocatorCallBack();
36     std::string GetUuid();
37     void SetUid(pid_t uid);
38     void SetPid(pid_t pid);
39     void SetPackageName(std::string packageName);
40     void SetRequestConfig(RequestConfig& requestConfig);
41     void SetLocatorCallBack(const sptr<ILocatorCallback>& callback);
42     void SetUuid(std::string uuid);
43     std::string ToString() const;
44     void GetProxyName(std::shared_ptr<std::list<std::string>> proxys);
45     bool GetIsRequesting();
46     void SetRequesting(bool state);
47     sptr<Location> GetLastLocation();
48     void SetLastLocation(const std::unique_ptr<Location>& location);
49     uint32_t GetTokenId();
50     uint32_t GetFirstTokenId();
51     void SetTokenId(uint32_t tokenId);
52     void SetFirstTokenId(uint32_t firstTokenId);
53     bool GetLocationPermState();
54     bool GetBackgroundPermState();
55     bool GetApproximatelyPermState();
56     void SetLocationPermState(bool state);
57     void SetBackgroundPermState(bool state);
58     void SetApproximatelyPermState(bool state);
59 private:
60     void GetProxyNameByPriority(std::shared_ptr<std::list<std::string>> proxys);
61 
62     pid_t uid_;
63     pid_t pid_;
64     uint32_t tokenId_;
65     uint32_t firstTokenId_;
66     sptr<Location> lastLocation_;
67     std::string packageName_;
68     std::string uuid_;
69     sptr<RequestConfig> requestConfig_;
70     sptr<ILocatorCallback> callBack_;
71     bool isRequesting_;
72     bool isUsingLocationPerm_;
73     bool isUsingBackgroundPerm_;
74     bool isUsingApproximatelyPerm_;
75 };
76 } // namespace Location
77 } // namespace OHOS
78 #endif // REQUEST_H
79