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 LOCATION_NAPI_EVENT_H 17 #define LOCATION_NAPI_EVENT_H 18 19 #include <string> 20 #include "cached_locations_callback_host.h" 21 #include "geofence_state.h" 22 #include "gnss_status_callback_host.h" 23 #include "location_switch_callback_host.h" 24 #include "locator_callback_host.h" 25 #include "napi/native_api.h" 26 #include "nmea_message_callback_host.h" 27 #include "request_config.h" 28 #include "want_agent_helper.h" 29 30 namespace OHOS { 31 namespace Location { 32 void SubscribeLocationServiceState(napi_env& env, 33 napi_ref& handlerRef, sptr<LocationSwitchCallbackHost>& switchCallbackHost); 34 void SubscribeGnssStatus(napi_env& env, napi_ref& handlerRef, 35 sptr<GnssStatusCallbackHost>& gnssStatusCallbackHost); 36 void SubscribeNmeaMessage(napi_env& env, napi_ref& handlerRef, 37 sptr<NmeaMessageCallbackHost>& nmeaMessageCallbackHost); 38 void SubscribeLocationChange(napi_env& env, const napi_value& object, 39 napi_ref& handlerRef, sptr<LocatorCallbackHost>& locatorCallbackHost); 40 void SubscribeCacheLocationChange(napi_env& env, const napi_value& object, 41 napi_ref& handlerRef, sptr<CachedLocationsCallbackHost>& cachedCallbackHost); 42 void SubscribeFenceStatusChange(napi_env& env, const napi_value& object, napi_value& handler); 43 void UnSubscribeLocationChange(sptr<ILocatorCallback>& callback); 44 void UnSubscribeFenceStatusChange(napi_env& env, const napi_value& object, napi_value& handler); 45 void UnSubscribeCacheLocationChange(sptr<ICachedLocationsCallback>& callback); 46 void UnSubscribeLocationServiceState(sptr<LocationSwitchCallbackHost>& switchCallbackHost); 47 void UnSubscribeGnssStatus(sptr<GnssStatusCallbackHost>& gnssStatusCallbackHost); 48 void UnSubscribeNmeaMessage(sptr<NmeaMessageCallbackHost>& nmeaMessageCallbackHost); 49 bool IsCallbackEquals(napi_env& env, napi_value& handler, napi_ref& savedCallback); 50 void GenRequestConfig(napi_env& env, const napi_value* argv, 51 size_t& objectArgsNum, std::unique_ptr<RequestConfig>& requestConfig); 52 napi_value RequestLocationOnce(napi_env& env, const size_t argc, const napi_value* argv); 53 napi_value On(napi_env env, napi_callback_info cbinfo); 54 napi_value Off(napi_env env, napi_callback_info cbinfo); 55 napi_value GetCurrentLocation(napi_env env, napi_callback_info cbinfo); 56 } // namespace Location 57 } // namespace OHOS 58 #endif // LOCATION_NAPI_EVENT_H 59