From 86f63478e5217507547dfe92fddbd63108d5490b Mon Sep 17 00:00:00 2001 From: Stephan Sundermann Date: Sat, 6 May 2023 15:16:21 +0200 Subject: [PATCH] Add webos helpers --- CMakeLists.txt | 6 +- include/webos-helpers/libhelpers.h | 69 +++++++++++ share/pkgconfig/helpers.pc | 11 ++ src/helpers.lds | 177 +++++++++++++++++++++++++++++ 4 files changed, 262 insertions(+), 1 deletion(-) create mode 100644 include/webos-helpers/libhelpers.h create mode 100644 share/pkgconfig/helpers.pc create mode 100644 src/helpers.lds diff --git a/CMakeLists.txt b/CMakeLists.txt index 1cba803..7e358ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,11 @@ add_library(AcbAPI SHARED src/dummy.c) set_target_properties(AcbAPI PROPERTIES VERSION 1.0.0 SOVERSION 1) target_link_options(AcbAPI PRIVATE ${CMAKE_SOURCE_DIR}/src/AcbAPI.lds) -install(TARGETS EGL GLESv1_CM GLESv2 NDL_directmedia playerAPIs wayland-egl AcbAPI DESTINATION lib) +add_library(helpers SHARED src/dummy.c) +set_target_properties(helpers PROPERTIES VERSION 2.0.0 SOVERSION 2) +target_link_options(helpers PRIVATE ${CMAKE_SOURCE_DIR}/src/helpers.lds) + +install(TARGETS EGL GLESv1_CM GLESv2 NDL_directmedia playerAPIs wayland-egl AcbAPI helpers DESTINATION lib) install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ DESTINATION include diff --git a/include/webos-helpers/libhelpers.h b/include/webos-helpers/libhelpers.h new file mode 100644 index 0000000..3b5539c --- /dev/null +++ b/include/webos-helpers/libhelpers.h @@ -0,0 +1,69 @@ +/** + * @defgroup helpers helpers + * @brief webOS common helper + */ + +/** + * @ingroup helpers + * @file libhelpers.h + */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct LSHandle LSHandle; +typedef struct LSMessage LSMessage; +typedef unsigned long LSMessageToken; + +typedef bool (*LSFilterFunc) (LSHandle *sh, LSMessage *reply, void *ctx); + + +/** + * @brief Context for luna service calls + */ +typedef struct HContext { + /** + * @brief Callback function called on incoming message. + */ + LSFilterFunc callback; + void* userdata; + void* unknown; + /** + * @brief Whether the call is multiple (like subscription), or one-shot. + */ + int multiple; + /** + * @brief Whether the call is a public call or private call + */ + int pub; + LSMessageToken ret_token; +} HContext; + +/** + * @brief Send luna call + * @param uri + * @param payload + * @param context + * @return 0 if succeeded + */ +int HLunaServiceCall(const char *uri, const char *payload, HContext *context); + +/** + * @brief Unregister a service callback + * @param context Same context used in HLunaServiceCall + * @return 0 if succeeded + */ +int HUnregisterServiceCallback(HContext *context); + +/** + * @brief Get payload message from luna call response + * @param msg + * @return Payload message (JSON string) + */ +const char *HLunaServiceMessage(LSMessage *msg); + +#ifdef __cplusplus +} +#endif diff --git a/share/pkgconfig/helpers.pc b/share/pkgconfig/helpers.pc new file mode 100644 index 0000000..3083f4a --- /dev/null +++ b/share/pkgconfig/helpers.pc @@ -0,0 +1,11 @@ +prefix=/usr +exec_prefix=/usr +datarootdir=${prefix}/share +libdir=${exec_prefix}/lib +includedir=${prefix}/include/webos-helpers + +Name: helpers +Description: webos helpers +Version: 2.0.0 +Libs: -L${libdir} -lhelpers +Cflags: -I${includedir} diff --git a/src/helpers.lds b/src/helpers.lds new file mode 100644 index 0000000..5067e8d --- /dev/null +++ b/src/helpers.lds @@ -0,0 +1,177 @@ +"HApp_GetAppIDFromPath" = "dummy"; +"HApp_GetAppPath" = "dummy"; +"HApp_GetBaseFile" = "dummy"; +"HApp_GetCallingPath" = "dummy"; +"HApp_GetCurrentAppID" = "dummy"; +"HApp_GetDirectoryFromAppID" = "dummy"; +"HApp_GetDirectoryFromExe" = "dummy"; +"HApp_IsJailerActive" = "dummy"; +"HData_alloc" = "dummy"; +"HData_ensure" = "dummy"; +"HData_free" = "dummy"; +"HFile_fileExists" = "dummy"; +"HFile_getFileContents" = "dummy"; +"HFile_getFileContentsAsString" = "dummy"; +"HFile_getFileContentsToBuffer" = "dummy"; +"HFile_getFileSize" = "dummy"; +"HGetError" = "dummy"; +"HHardware_getDisplaySize" = "dummy"; +"HHardware_getMachine" = "dummy"; +"HJson_create" = "dummy"; +"HJson_free" = "dummy"; +"HJson_getBool" = "dummy"; +"HJson_getDouble" = "dummy"; +"HJson_getInt" = "dummy"; +"HJson_getValue" = "dummy"; +"HJson_getValueFromStr" = "dummy"; +"HJson_valueExists" = "dummy"; +"HLunaServiceCall" = "dummy"; +"HLunaServiceMessage" = "dummy"; +"HNDLGetParamBool" = "dummy"; +"HNDLGetParamDouble" = "dummy"; +"HNDLGetParamInt" = "dummy"; +"HNDLGetParamJson" = "dummy"; +"HNDLGetParamString" = "dummy"; +"HNDLParamExists" = "dummy"; +"HNDLServiceCall" = "dummy"; +"HNDLServiceCallWithCallback" = "dummy"; +"HNDLServiceInit" = "dummy"; +"HNDLServiceQuit" = "dummy"; +"HNDLSetLSHandle" = "dummy"; +"HNDLUnregisterServiceCallback" = "dummy"; +"HProcessAppState" = "dummy"; +"HRegisterAppState" = "dummy"; +"HSetError" = "dummy"; +"HString_alloc" = "dummy"; +"HString_append" = "dummy"; +"HString_free" = "dummy"; +"HString_toStr" = "dummy"; +"HTracker_ReInit" = "dummy"; +"HTracker_funcTrack" = "dummy"; +"HTracker_isTracking" = "dummy"; +"HTracker_rawTrack" = "dummy"; +"HUnregisterServiceCallback" = "dummy"; +"_Z10copyBufferPciPKc" = "dummy"; +"_Z10threadLoopPv" = "dummy"; +"_Z11showLSErrorPKcP7LSError" = "dummy"; +"_Z12isWhitespacec" = "dummy"; +"_Z13_getTickCountv" = "dummy"; +"_Z14orphanCallbackiPKcPv" = "dummy"; +"_Z16getStrFromJValueN7pbnjson6JValueE" = "dummy"; +"_Z17HTracker_lazyInitv" = "dummy"; +"_Z18internalLSCallbackP8LSHandleP9LSMessagePv" = "dummy"; +"_Z19HNDLServiceCallProcP8LSHandleP9LSMessagePv" = "dummy"; +"_Z19extractAppinfoFieldPKcS0_Pci" = "dummy"; +"_Z22stripOneDirectoryLevelPc" = "dummy"; +"_Z27extractAppinfoFieldFromPathPKcS0_Pci" = "dummy"; +"_Z9showErrorPKcP7LSError" = "dummy"; +"_Z9threadRunPv" = "dummy"; +"_ZN11HDataReader10checkIdentEv" = "dummy"; +"_ZN11HDataReader10doDumpInfoEPKc" = "dummy"; +"_ZN11HDataReader10doReadDataEPvi" = "dummy"; +"_ZN11HDataReader10readDoubleEv" = "dummy"; +"_ZN11HDataReader11confirmTypeEi" = "dummy"; +"_ZN11HDataReader12allocReadStrEv" = "dummy"; +"_ZN11HDataReader12isSuccessfulEv" = "dummy"; +"_ZN11HDataReader16internalDumpInfoEPKc" = "dummy"; +"_ZN11HDataReader4initEP6_HData" = "dummy"; +"_ZN11HDataReader4initEPvi" = "dummy"; +"_ZN11HDataReader7readIntEv" = "dummy"; +"_ZN11HDataReader7readStrEPci" = "dummy"; +"_ZN11HDataReader8dumpInfoEPKc" = "dummy"; +"_ZN11HDataReader8dumpInfoEPKcP6_HData" = "dummy"; +"_ZN11HDataReader8dumpInfoEPKcPvi" = "dummy"; +"_ZN11HDataReader8readBoolEv" = "dummy"; +"_ZN11HDataReader8readCharEv" = "dummy"; +"_ZN11HDataReader8readDataEPvi" = "dummy"; +"_ZN11HDataReader8readTypeEv" = "dummy"; +"_ZN11HDataReaderC1Ev" = "dummy"; +"_ZN11HDataReaderC2Ev" = "dummy"; +"_ZN11HDataReaderD1Ev" = "dummy"; +"_ZN11HDataReaderD2Ev" = "dummy"; +"_ZN11HDataWriter11doWriteDataEPKvi" = "dummy"; +"_ZN11HDataWriter11writeDoubleEd" = "dummy"; +"_ZN11HDataWriter12isSuccessfulEv" = "dummy"; +"_ZN11HDataWriter16doWriteSizedDataEPKvi" = "dummy"; +"_ZN11HDataWriter4initEP6_HData" = "dummy"; +"_ZN11HDataWriter4initEv" = "dummy"; +"_ZN11HDataWriter5clearEv" = "dummy"; +"_ZN11HDataWriter7getDataEv" = "dummy"; +"_ZN11HDataWriter8writeIntEi" = "dummy"; +"_ZN11HDataWriter8writeStrEPKc" = "dummy"; +"_ZN11HDataWriter9writeBoolEb" = "dummy"; +"_ZN11HDataWriter9writeCharEc" = "dummy"; +"_ZN11HDataWriter9writeDataEPKvi" = "dummy"; +"_ZN11HDataWriter9writeTypeEi" = "dummy"; +"_ZN11HDataWriterC1Ev" = "dummy"; +"_ZN11HDataWriterC2Ev" = "dummy"; +"_ZN11HDataWriterD1Ev" = "dummy"; +"_ZN11HDataWriterD2Ev" = "dummy"; +"_ZN11HLinkedList3getEi" = "dummy"; +"_ZN11HLinkedList4sizeEv" = "dummy"; +"_ZN11HLinkedList5clearEv" = "dummy"; +"_ZN11HLinkedList6appendEPv" = "dummy"; +"_ZN11HLinkedList6insertEiPv" = "dummy"; +"_ZN11HLinkedList6removeEPv" = "dummy"; +"_ZN11HLinkedList6removeEi" = "dummy"; +"_ZN11HLinkedList7prependEPv" = "dummy"; +"_ZN11HLinkedList9getLLElemEPv" = "dummy"; +"_ZN11HLinkedList9getLLElemEi" = "dummy"; +"_ZN11HLinkedListC1Ev" = "dummy"; +"_ZN11HLinkedListC2Ev" = "dummy"; +"_ZN11HLinkedListD0Ev" = "dummy"; +"_ZN11HLinkedListD1Ev" = "dummy"; +"_ZN11HLinkedListD2Ev" = "dummy"; +"_ZN11TrackerData10doneAddingEv" = "dummy"; +"_ZN11TrackerData12addTrackTypeEPKc" = "dummy"; +"_ZN11TrackerData12isWhitespaceEc" = "dummy"; +"_ZN11TrackerData14addPartialTypeEPKc" = "dummy"; +"_ZN11TrackerData16matchesTrackTypeEPKc" = "dummy"; +"_ZN11TrackerData18matchesPartialTypeEPKc" = "dummy"; +"_ZN11TrackerData4initEv" = "dummy"; +"_ZN11TrackerData5clearEv" = "dummy"; +"_ZN11TrackerDataC1Ev" = "dummy"; +"_ZN11TrackerDataC2Ev" = "dummy"; +"_ZN11TrackerDataD1Ev" = "dummy"; +"_ZN11TrackerDataD2Ev" = "dummy"; +"_ZN18HLunaServiceBridge10MakeBridgeEv" = "dummy"; +"_ZN18HLunaServiceBridge12PublicHandleEv" = "dummy"; +"_ZN18HLunaServiceBridge13PrivateHandleEv" = "dummy"; +"_ZN18HLunaServiceBridge15LunaServiceCallEPKcS1_P10__HContext" = "dummy"; +"_ZN18HLunaServiceBridge21LunaServiceCallCancelEP10__HContext" = "dummy"; +"_ZN18HLunaServiceBridge4procEP8LSHandleP9LSMessagePv" = "dummy"; +"_ZN18HLunaServiceBridge8instanceEv" = "dummy"; +"_ZN18HLunaServiceBridgeC1Ev" = "dummy"; +"_ZN18HLunaServiceBridgeC2Ev" = "dummy"; +"_ZN18HLunaServiceBridgeD1Ev" = "dummy"; +"_ZN18HLunaServiceBridgeD2Ev" = "dummy"; +"_ZN5HJson5parseEv" = "dummy"; +"_ZN5HJsonC1EPKc" = "dummy"; +"_ZN5HJsonC2EPKc" = "dummy"; +"_ZN6HMutex7TryLockEv" = "dummy"; +"_ZN6HMutexC1Eb" = "dummy"; +"_ZN6HMutexC2Eb" = "dummy"; +"_ZN7ll_elemC1Ev" = "dummy"; +"_ZN7ll_elemC2Ev" = "dummy"; +"_ZN9HLSCaller12lsCancelCallEi" = "dummy"; +"_ZN9HLSCaller14getContextByIDEi" = "dummy"; +"_ZN9HLSCaller14lsCallInternalEPKcS1_PvPFviS1_S2_Ebb" = "dummy"; +"_ZN9HLSCaller14outputRoleFileEPKcS1_" = "dummy"; +"_ZN9HLSCaller18lsCallWithResponseEPKcS1_bPFviS1_PvES2_" = "dummy"; +"_ZN9HLSCaller18outputRoleFileInfoEv" = "dummy"; +"_ZN9HLSCaller22lsCallWithSubscriptionEPKcS1_bPFviS1_PvES2_" = "dummy"; +"_ZN9HLSCaller4initEP10_GMainLoop" = "dummy"; +"_ZN9HLSCaller6lsCallEPKcS1_b" = "dummy"; +"_ZN9HLSCaller8callbackEPvS0_P24HInternalCallbackContext" = "dummy"; +"_ZN9HLSCallerC1Ev" = "dummy"; +"_ZN9HLSCallerC2Ev" = "dummy"; +"_ZN9HLSCallerD1Ev" = "dummy"; +"_ZN9HLSCallerD2Ev" = "dummy"; +"_ZN9HLSHandle12PublicHandleEv" = "dummy"; +"_ZN9HLSHandle13PrivateHandleEv" = "dummy"; +"_ZN9HLSHandleC1EP10_GMainLoop" = "dummy"; +"_ZN9HLSHandleC2EP10_GMainLoop" = "dummy"; +"_ZN9HLSHandleD1Ev" = "dummy"; +"_ZN9HLSHandleD2Ev" = "dummy"; +"loggerLogEx" = "dummy"; +"loggerLogRaw" = "dummy";