1 /*
2  * Copyright (c) 2023 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 ARK_LOCATION_ADAPTER_H
17 #define ARK_LOCATION_ADAPTER_H
18 #pragma once
19 
20 #include "base/include/ark_web_base_ref_counted.h"
21 #include "base/include/ark_web_types.h"
22 
23 namespace OHOS::ArkWeb {
24 
25 /*--ark web(source=webview)--*/
26 class ArkLocationRequestConfig : public virtual ArkWebBaseRefCounted {
27 public:
28     /*--ark web()--*/
29     virtual void SetScenario(int32_t scenario) = 0;
30 
31     /*--ark web()--*/
32     virtual void SetFixNumber(int32_t number) = 0;
33 
34     /*--ark web()--*/
35     virtual void SetMaxAccuracy(int32_t maxAccuary) = 0;
36 
37     /*--ark web()--*/
38     virtual void SetDistanceInterval(int32_t disInterval) = 0;
39 
40     /*--ark web()--*/
41     virtual void SetTimeInterval(int32_t timeInterval) = 0;
42 
43     /*--ark web()--*/
44     virtual void SetPriority(int32_t priority) = 0;
45 };
46 
47 /*--ark web(source=webview)--*/
48 class ArkLocationInfo : public virtual ArkWebBaseRefCounted {
49 public:
50     /*--ark web()--*/
51     virtual double GetLatitude() = 0;
52 
53     /*--ark web()--*/
54     virtual double GetLongitude() = 0;
55 
56     /*--ark web()--*/
57     virtual double GetAltitude() = 0;
58 
59     /*--ark web()--*/
60     virtual float GetAccuracy() = 0;
61 
62     /*--ark web()--*/
63     virtual float GetSpeed() = 0;
64 
65     /*--ark web()--*/
66     virtual double GetDirection() = 0;
67 
68     /*--ark web()--*/
69     virtual int64_t GetTimeStamp() = 0;
70 
71     /*--ark web()--*/
72     virtual int64_t GetTimeSinceBoot() = 0;
73 
74     /*--ark web()--*/
75     virtual ArkWebStringVector GetAdditions() = 0;
76 };
77 
78 /*--ark web(source=webcore)--*/
79 class ArkLocationCallbackAdapter : public virtual ArkWebBaseRefCounted {
80 public:
81     /*--ark web()--*/
82     virtual void OnLocationReport(const ArkWebRefPtr<ArkLocationInfo> location) = 0;
83 
84     /*--ark web()--*/
85     virtual void OnLocatingStatusChange(const int status) = 0;
86 
87     /*--ark web()--*/
88     virtual void OnErrorReport(const int errorCode) = 0;
89 };
90 
91 /*--ark web(source=webview)--*/
92 class ArkLocationProxyAdapter : public virtual ArkWebBaseRefCounted {
93 public:
94     /*--ark web()--*/
95     virtual int32_t StartLocating(
96         ArkWebRefPtr<ArkLocationRequestConfig> requestConfig, ArkWebRefPtr<ArkLocationCallbackAdapter> callback) = 0;
97 
98     /*--ark web()--*/
99     virtual bool StopLocating(int32_t callbackId) = 0;
100 
101     /*--ark web()--*/
102     virtual bool EnableAbility(bool isEnabled) = 0;
103 
104     /*--ark web()--*/
105     virtual bool IsLocationEnabled() = 0;
106 };
107 
108 /*--ark web(source=webview)--*/
109 class ArkLocationInstance : public virtual ArkWebBaseRefCounted {
110 public:
111     /*--ark web()--*/
112     static ArkWebRefPtr<ArkLocationInstance> GetInstance();
113 
114     /*--ark web()--*/
115     virtual ArkWebRefPtr<ArkLocationProxyAdapter> CreateLocationProxyAdapter() = 0;
116 
117     /*--ark web()--*/
118     virtual ArkWebRefPtr<ArkLocationRequestConfig> CreateLocationRequestConfig() = 0;
119 };
120 
121 } // namespace OHOS::ArkWeb
122 
123 #endif
124