Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

few tweaks for objects api #190

Merged
merged 8 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
name: c-core
schema: 1
version: "4.11.2"
version: "4.12.0"
scm: github.com/pubnub/c-core
changelog:
- date: 2024-07-29
version: v4.12.0
changes:
- type: feature
text: "Added `filter` and `sort` parameters to be closer to the other SDKs with object API."
- type: feature
text: "Configurable `bool` type."
- type: bug
text: "Missing features needed for grant token API in CMakeLIsts.txt."
- date: 2024-07-15
version: v4.11.2
changes:
Expand Down Expand Up @@ -819,7 +828,7 @@ sdks:
distribution-type: source code
distribution-repository: GitHub release
package-name: C-Core
location: https://github.com/pubnub/c-core/releases/tag/v4.11.2
location: https://github.com/pubnub/c-core/releases/tag/v4.12.0
requires:
-
name: "miniz"
Expand Down Expand Up @@ -885,7 +894,7 @@ sdks:
distribution-type: source code
distribution-repository: GitHub release
package-name: C-Core
location: https://github.com/pubnub/c-core/releases/tag/v4.11.2
location: https://github.com/pubnub/c-core/releases/tag/v4.12.0
requires:
-
name: "miniz"
Expand Down Expand Up @@ -951,7 +960,7 @@ sdks:
distribution-type: source code
distribution-repository: GitHub release
package-name: C-Core
location: https://github.com/pubnub/c-core/releases/tag/v4.11.2
location: https://github.com/pubnub/c-core/releases/tag/v4.12.0
requires:
-
name: "miniz"
Expand Down Expand Up @@ -1013,7 +1022,7 @@ sdks:
distribution-type: source code
distribution-repository: GitHub release
package-name: C-Core
location: https://github.com/pubnub/c-core/releases/tag/v4.11.2
location: https://github.com/pubnub/c-core/releases/tag/v4.12.0
requires:
-
name: "miniz"
Expand Down Expand Up @@ -1074,7 +1083,7 @@ sdks:
distribution-type: source code
distribution-repository: GitHub release
package-name: C-Core
location: https://github.com/pubnub/c-core/releases/tag/v4.11.2
location: https://github.com/pubnub/c-core/releases/tag/v4.12.0
requires:
-
name: "miniz"
Expand Down Expand Up @@ -1130,7 +1139,7 @@ sdks:
distribution-type: source code
distribution-repository: GitHub release
package-name: C-Core
location: https://github.com/pubnub/c-core/releases/tag/v4.11.2
location: https://github.com/pubnub/c-core/releases/tag/v4.12.0
requires:
-
name: "miniz"
Expand Down Expand Up @@ -1183,7 +1192,7 @@ sdks:
distribution-type: source code
distribution-repository: GitHub release
package-name: C-Core
location: https://github.com/pubnub/c-core/releases/tag/v4.11.2
location: https://github.com/pubnub/c-core/releases/tag/v4.12.0
requires:
-
name: "miniz"
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## v4.12.0
July 29 2024

#### Added
- Added `filter` and `sort` parameters to be closer to the other SDKs with object API.
- Configurable `bool` type.

#### Fixed
- Missing features needed for grant token API in CMakeLIsts.txt.

## v4.11.2
July 15 2024

Expand Down
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ log_set(CUSTOM_OPENSSL_INCLUDE_DIR "include" "OpenSSL include directory relative
log_set(EXAMPLE "all" "Build example with provided name (use 'all' for all examples) [EXAMPLES=ON needed]")
log_set(CGREEN_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/cgreen" "CGreen root directory [UNIT_TEST=ON needed]")
log_set(LOG_LEVEL "WARNING" "Log level [TRACE/DEBUG/INFO/WARNING/ERROR]")
log_set(CUSTOM_BOOL_TYPE "" "Type of bool for platform differences. Select whatever works for you that accepts 0/1 values")

if (${OPENSSL} AND ${MBEDTLS})
message(FATAL_ERROR "You can't use both OpenSSL and mbedTLS at the same time!")
Expand Down Expand Up @@ -143,6 +144,13 @@ if(${WITH_CPP})
endif()
endif()

if(NOT ${CUSTOM_BOOL_TYPE} STREQUAL "")
message(STATUS "Using custom bool type: ${BOOL_TYPE}")
set(FLAGS "\
${FLAGS} \
-D PUBNUB_BOOL_TYPE=${BOOL_TYPE}")
endif()

set(CORE_SOURCEFILES
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_set_state.c
${CMAKE_CURRENT_LIST_DIR}/core/pubnub_pubsubapi.c
Expand Down Expand Up @@ -372,6 +380,9 @@ endif()
if(${USE_GRANT_TOKEN_API})
set(FEATURE_SOURCEFILES
${FEATURE_SOURCEFILES}
${CMAKE_CURRENT_LIST_DIR}/lib/cbor/cborparser.c
${CMAKE_CURRENT_LIST_DIR}/lib/cbor/cborerrorstrings.c
${CMAKE_CURRENT_LIST_DIR}/lib/cbor/cborparser_dup_string.c
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_grant_token_api.c
${CMAKE_CURRENT_LIST_DIR}/core/pubnub_grant_token_api.c)
endif()
Expand Down Expand Up @@ -673,6 +684,16 @@ if(${EXAMPLES})
set(EXAMPLE_LIST
pubnub_crypto_module_sample
${EXAMPLE_LIST})
if (${USE_GRANT_TOKEN_API})
set(EXAMPLE_LIST
pubnub_sync_grant_token_sample
${EXAMPLE_LIST})
endif()
endif()
if (${USE_OBJECTS_API})
set(EXAMPLE_LIST
pubnub_objects_api_sample
${EXAMPLE_LIST})
endif()
endif()
else()
Expand Down
6 changes: 5 additions & 1 deletion core/c99/stdbool.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#define false 0
#define true 1

#ifdef PUBNUB_BOOL_TYPE
#define bool PUBNUB_BOOL_TYPE
#else
#define bool int
#endif

#endif /* !defined __cplusplus */
#endif /* !defined __cplusplus */
54 changes: 54 additions & 0 deletions core/pbcc_objects_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ enum pubnub_res pbcc_getall_uuidmetadata_prep(
char const* start,
char const* end,
enum pubnub_tribool count,
char const* filter,
char const* sort,
enum pubnub_trans pt)
{
char const* const uname = pubnub_uname();
Expand All @@ -102,6 +104,9 @@ enum pubnub_res pbcc_getall_uuidmetadata_prep(

if (count != pbccNotSet) { ADD_URL_PARAM(qparam, count, count == pbccTrue ? "true" : "false"); }

if (NULL != filter) { ADD_URL_PARAM(qparam, filter, filter); }
if (NULL != sort) { ADD_URL_PARAM(qparam, sort, sort); }

if (user_id) { ADD_URL_PARAM(qparam, uuid, user_id); }
#if PUBNUB_CRYPTO_API
if (pb->secret_key == NULL) { ADD_URL_AUTH_PARAM(pb, qparam, auth); }
Expand Down Expand Up @@ -292,6 +297,8 @@ enum pubnub_res pbcc_getall_channelmetadata_prep(struct pbcc_context* pb,
char const* start,
char const* end,
enum pubnub_tribool count,
char const* filter,
char const* sort,
enum pubnub_trans pt)
{
char const* const uname = pubnub_uname();
Expand All @@ -316,6 +323,10 @@ enum pubnub_res pbcc_getall_channelmetadata_prep(struct pbcc_context* pb,
if (end != NULL) { ADD_URL_PARAM(qparam, end, end); }

if (count != pbccNotSet) { ADD_URL_PARAM(qparam, count, count == pbccTrue ? "true" : "false"); }

if (NULL != filter) { ADD_URL_PARAM(qparam, filter, filter); }
if (NULL != sort) { ADD_URL_PARAM(qparam, sort, sort); }

if (user_id) { ADD_URL_PARAM(qparam, uuid, user_id); }
#if PUBNUB_CRYPTO_API
if (pb->secret_key == NULL) { ADD_URL_AUTH_PARAM(pb, qparam, auth); }
Expand Down Expand Up @@ -515,6 +526,8 @@ enum pubnub_res pbcc_get_memberships_prep(struct pbcc_context* pb,
char const* start,
char const* end,
enum pubnub_tribool count,
char const* filter,
char const* sort,
enum pubnub_trans pt)
{
char const* const uname = pubnub_uname();
Expand Down Expand Up @@ -542,6 +555,10 @@ enum pubnub_res pbcc_get_memberships_prep(struct pbcc_context* pb,
if (start) { ADD_URL_PARAM(qparam, start, start); }
if (end) { ADD_URL_PARAM(qparam, end, end); }
if (count != pbccNotSet) { ADD_URL_PARAM(qparam, count, count == pbccTrue ? "true" : "false"); }

if (NULL != filter) { ADD_URL_PARAM(qparam, filter, filter); }
if (NULL != sort) { ADD_URL_PARAM(qparam, sort, sort); }

if (user_id) { ADD_URL_PARAM(qparam, uuid, user_id); }
#if PUBNUB_CRYPTO_API
if (pb->secret_key == NULL) { ADD_URL_AUTH_PARAM(pb, qparam, auth); }
Expand Down Expand Up @@ -574,6 +591,12 @@ enum pubnub_res pbcc_set_memberships_prep(struct pbcc_context* pb,
char const* uuid_metadataid,
char const* include,
char const* set_obj,
char const* filter,
char const* sort,
size_t limit,
char const* start,
char const* end,
enum pubnub_tribool count,
enum pubnub_trans pt)
{
char const* const uname = pubnub_uname();
Expand All @@ -598,6 +621,16 @@ enum pubnub_res pbcc_set_memberships_prep(struct pbcc_context* pb,
URL_PARAMS_INIT(qparam, PUBNUB_MAX_URL_PARAMS);
if (uname) { ADD_URL_PARAM(qparam, pnsdk, uname); }
if (user_id) { ADD_URL_PARAM(qparam, uuid, user_id); }

if (limit > 0) { ADD_URL_PARAM_SIZET(qparam, limit, limit); }
if (NULL != start) { ADD_URL_PARAM(qparam, start, start); }
if (NULL != end) { ADD_URL_PARAM(qparam, end, end); }

if (count != pbccNotSet) { ADD_URL_PARAM(qparam, count, count == pbccTrue ? "true" : "false"); }

if (NULL != filter) { ADD_URL_PARAM(qparam, filter, filter); }
if (NULL != sort) { ADD_URL_PARAM(qparam, sort, sort); }

#if PUBNUB_CRYPTO_API
if (pb->secret_key == NULL) { ADD_URL_AUTH_PARAM(pb, qparam, auth); }
ADD_TS_TO_URL_PARAM();
Expand Down Expand Up @@ -633,6 +666,8 @@ enum pubnub_res pbcc_get_members_prep(struct pbcc_context* pb,
size_t limit,
char const* start,
char const* end,
char const* filter,
char const* sort,
enum pubnub_tribool count,
enum pubnub_trans pt)
{
Expand Down Expand Up @@ -663,6 +698,10 @@ enum pubnub_res pbcc_get_members_prep(struct pbcc_context* pb,
if (start) { ADD_URL_PARAM(qparam, start, start); }
if (end) { ADD_URL_PARAM(qparam, end, end); }
if (count != pbccNotSet) { ADD_URL_PARAM(qparam, count, count == pbccTrue ? "true" : "false"); }

if (NULL != filter) { ADD_URL_PARAM(qparam, filter, filter); }
if (NULL != sort) { ADD_URL_PARAM(qparam, sort, sort); }

if (user_id) { ADD_URL_PARAM(qparam, uuid, user_id); }
#if PUBNUB_CRYPTO_API
if (pb->secret_key == NULL) { ADD_URL_AUTH_PARAM(pb, qparam, auth); }
Expand Down Expand Up @@ -695,6 +734,12 @@ enum pubnub_res pbcc_set_members_prep(struct pbcc_context* pb,
char const* channel_metadataid,
char const* include,
char const* set_obj,
char const* filter,
char const* sort,
size_t limit,
char const* start,
char const* end,
enum pubnub_tribool count,
enum pubnub_trans pt)
{
char const* const uname = pubnub_uname();
Expand All @@ -720,6 +765,15 @@ enum pubnub_res pbcc_set_members_prep(struct pbcc_context* pb,
URL_PARAMS_INIT(qparam, PUBNUB_MAX_URL_PARAMS);
if (uname) { ADD_URL_PARAM(qparam, pnsdk, uname); }
if (user_id) { ADD_URL_PARAM(qparam, uuid, user_id); }

if (limit > 0) { ADD_URL_PARAM_SIZET(qparam, limit, limit); }
if (NULL != start) { ADD_URL_PARAM(qparam, start, start); }
if (NULL != end) { ADD_URL_PARAM(qparam, end, end); }

if (count != pbccNotSet) { ADD_URL_PARAM(qparam, count, count == pbccTrue ? "true" : "false"); }

if (NULL != filter) { ADD_URL_PARAM(qparam, filter, filter); }
if (NULL != sort) { ADD_URL_PARAM(qparam, sort, sort); }
#if PUBNUB_CRYPTO_API
if (pb->secret_key == NULL) { ADD_URL_AUTH_PARAM(pb, qparam, auth); }
ADD_TS_TO_URL_PARAM();
Expand Down
22 changes: 22 additions & 0 deletions core/pbcc_objects_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ enum pubnub_res pbcc_find_objects_id(struct pbcc_context* pb,
char const* file,
int line);

// TODO: maybe we should decrease amount of parameters in these functions

/** Prepares the 'get_users' transaction, mostly by
formatting the URI of the HTTP request.
*/
Expand All @@ -35,6 +37,8 @@ enum pubnub_res pbcc_getall_uuidmetadata_prep(struct pbcc_context* pb,
char const* start,
char const* end,
enum pubnub_tribool count,
char const* filter,
char const* sort,
enum pubnub_trans pt);

/** Prepares the 'set_uuidmetadata' transaction, mostly by
Expand Down Expand Up @@ -70,6 +74,8 @@ enum pubnub_res pbcc_getall_channelmetadata_prep(struct pbcc_context* pb,
char const* start,
char const* end,
enum pubnub_tribool count,
char const* filter,
char const* sort,
enum pubnub_trans pt);


Expand Down Expand Up @@ -108,6 +114,8 @@ enum pubnub_res pbcc_get_memberships_prep(struct pbcc_context* pb,
char const* start,
char const* end,
enum pubnub_tribool count,
char const* filter,
char const* sort,
enum pubnub_trans pt);


Expand All @@ -118,6 +126,12 @@ enum pubnub_res pbcc_set_memberships_prep(struct pbcc_context* pb,
char const* uuid_metadataid,
char const* include,
char const* update_obj,
char const* filter,
char const* sort,
size_t limit,
char const* start,
char const* end,
enum pubnub_tribool count,
enum pubnub_trans pt);

/** Prepares the 'get_members' transaction, mostly by
Expand All @@ -129,6 +143,8 @@ enum pubnub_res pbcc_get_members_prep(struct pbcc_context* pb,
size_t limit,
char const* start,
char const* end,
char const* filter,
char const* sort,
enum pubnub_tribool count,
enum pubnub_trans pt);

Expand All @@ -139,6 +155,12 @@ enum pubnub_res pbcc_set_members_prep(struct pbcc_context* pb,
char const* channel_metadataid,
char const* include,
char const* set_obj,
char const* filter,
char const* sort,
size_t limit,
char const* start,
char const* end,
enum pubnub_tribool count,
enum pubnub_trans pt);


Expand Down
Loading
Loading