Skip to content

Commit 4789b71

Browse files
authored
few tweaks for objects api (#190)
feat: add filter and sort parameters to be closer to the other SDKs with object API. Added filter and sort parameters to be closer to the other SDKs with object API. feat: configurable `bool` type. Configurable `bool` type. fix: missing features needed for grant token API in CMakeLIsts.txt Missing features needed for grant token API in CMakeLIsts.txt
1 parent 90e283a commit 4789b71

12 files changed

+1449
-66
lines changed

.pubnub.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
name: c-core
22
schema: 1
3-
version: "4.11.2"
3+
version: "4.12.0"
44
scm: github.com/pubnub/c-core
55
changelog:
6+
- date: 2024-07-29
7+
version: v4.12.0
8+
changes:
9+
- type: feature
10+
text: "Added `filter` and `sort` parameters to be closer to the other SDKs with object API."
11+
- type: feature
12+
text: "Configurable `bool` type."
13+
- type: bug
14+
text: "Missing features needed for grant token API in CMakeLIsts.txt."
615
- date: 2024-07-15
716
version: v4.11.2
817
changes:
@@ -819,7 +828,7 @@ sdks:
819828
distribution-type: source code
820829
distribution-repository: GitHub release
821830
package-name: C-Core
822-
location: https://github.com/pubnub/c-core/releases/tag/v4.11.2
831+
location: https://github.com/pubnub/c-core/releases/tag/v4.12.0
823832
requires:
824833
-
825834
name: "miniz"
@@ -885,7 +894,7 @@ sdks:
885894
distribution-type: source code
886895
distribution-repository: GitHub release
887896
package-name: C-Core
888-
location: https://github.com/pubnub/c-core/releases/tag/v4.11.2
897+
location: https://github.com/pubnub/c-core/releases/tag/v4.12.0
889898
requires:
890899
-
891900
name: "miniz"
@@ -951,7 +960,7 @@ sdks:
951960
distribution-type: source code
952961
distribution-repository: GitHub release
953962
package-name: C-Core
954-
location: https://github.com/pubnub/c-core/releases/tag/v4.11.2
963+
location: https://github.com/pubnub/c-core/releases/tag/v4.12.0
955964
requires:
956965
-
957966
name: "miniz"
@@ -1013,7 +1022,7 @@ sdks:
10131022
distribution-type: source code
10141023
distribution-repository: GitHub release
10151024
package-name: C-Core
1016-
location: https://github.com/pubnub/c-core/releases/tag/v4.11.2
1025+
location: https://github.com/pubnub/c-core/releases/tag/v4.12.0
10171026
requires:
10181027
-
10191028
name: "miniz"
@@ -1074,7 +1083,7 @@ sdks:
10741083
distribution-type: source code
10751084
distribution-repository: GitHub release
10761085
package-name: C-Core
1077-
location: https://github.com/pubnub/c-core/releases/tag/v4.11.2
1086+
location: https://github.com/pubnub/c-core/releases/tag/v4.12.0
10781087
requires:
10791088
-
10801089
name: "miniz"
@@ -1130,7 +1139,7 @@ sdks:
11301139
distribution-type: source code
11311140
distribution-repository: GitHub release
11321141
package-name: C-Core
1133-
location: https://github.com/pubnub/c-core/releases/tag/v4.11.2
1142+
location: https://github.com/pubnub/c-core/releases/tag/v4.12.0
11341143
requires:
11351144
-
11361145
name: "miniz"
@@ -1183,7 +1192,7 @@ sdks:
11831192
distribution-type: source code
11841193
distribution-repository: GitHub release
11851194
package-name: C-Core
1186-
location: https://github.com/pubnub/c-core/releases/tag/v4.11.2
1195+
location: https://github.com/pubnub/c-core/releases/tag/v4.12.0
11871196
requires:
11881197
-
11891198
name: "miniz"

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## v4.12.0
2+
July 29 2024
3+
4+
#### Added
5+
- Added `filter` and `sort` parameters to be closer to the other SDKs with object API.
6+
- Configurable `bool` type.
7+
8+
#### Fixed
9+
- Missing features needed for grant token API in CMakeLIsts.txt.
10+
111
## v4.11.2
212
July 15 2024
313

CMakeLists.txt

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

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

147+
if(NOT ${CUSTOM_BOOL_TYPE} STREQUAL "")
148+
message(STATUS "Using custom bool type: ${BOOL_TYPE}")
149+
set(FLAGS "\
150+
${FLAGS} \
151+
-D PUBNUB_BOOL_TYPE=${BOOL_TYPE}")
152+
endif()
153+
146154
set(CORE_SOURCEFILES
147155
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_set_state.c
148156
${CMAKE_CURRENT_LIST_DIR}/core/pubnub_pubsubapi.c
@@ -372,6 +380,9 @@ endif()
372380
if(${USE_GRANT_TOKEN_API})
373381
set(FEATURE_SOURCEFILES
374382
${FEATURE_SOURCEFILES}
383+
${CMAKE_CURRENT_LIST_DIR}/lib/cbor/cborparser.c
384+
${CMAKE_CURRENT_LIST_DIR}/lib/cbor/cborerrorstrings.c
385+
${CMAKE_CURRENT_LIST_DIR}/lib/cbor/cborparser_dup_string.c
375386
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_grant_token_api.c
376387
${CMAKE_CURRENT_LIST_DIR}/core/pubnub_grant_token_api.c)
377388
endif()
@@ -673,6 +684,16 @@ if(${EXAMPLES})
673684
set(EXAMPLE_LIST
674685
pubnub_crypto_module_sample
675686
${EXAMPLE_LIST})
687+
if (${USE_GRANT_TOKEN_API})
688+
set(EXAMPLE_LIST
689+
pubnub_sync_grant_token_sample
690+
${EXAMPLE_LIST})
691+
endif()
692+
endif()
693+
if (${USE_OBJECTS_API})
694+
set(EXAMPLE_LIST
695+
pubnub_objects_api_sample
696+
${EXAMPLE_LIST})
676697
endif()
677698
endif()
678699
else()

core/c99/stdbool.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
#define false 0
66
#define true 1
77

8+
#ifdef PUBNUB_BOOL_TYPE
9+
#define bool PUBNUB_BOOL_TYPE
10+
#else
811
#define bool int
12+
#endif
913

10-
#endif /* !defined __cplusplus */
14+
#endif /* !defined __cplusplus */

core/pbcc_objects_api.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ enum pubnub_res pbcc_getall_uuidmetadata_prep(
7777
char const* start,
7878
char const* end,
7979
enum pubnub_tribool count,
80+
char const* filter,
81+
char const* sort,
8082
enum pubnub_trans pt)
8183
{
8284
char const* const uname = pubnub_uname();
@@ -102,6 +104,9 @@ enum pubnub_res pbcc_getall_uuidmetadata_prep(
102104

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

107+
if (NULL != filter) { ADD_URL_PARAM(qparam, filter, filter); }
108+
if (NULL != sort) { ADD_URL_PARAM(qparam, sort, sort); }
109+
105110
if (user_id) { ADD_URL_PARAM(qparam, uuid, user_id); }
106111
#if PUBNUB_CRYPTO_API
107112
if (pb->secret_key == NULL) { ADD_URL_AUTH_PARAM(pb, qparam, auth); }
@@ -292,6 +297,8 @@ enum pubnub_res pbcc_getall_channelmetadata_prep(struct pbcc_context* pb,
292297
char const* start,
293298
char const* end,
294299
enum pubnub_tribool count,
300+
char const* filter,
301+
char const* sort,
295302
enum pubnub_trans pt)
296303
{
297304
char const* const uname = pubnub_uname();
@@ -316,6 +323,10 @@ enum pubnub_res pbcc_getall_channelmetadata_prep(struct pbcc_context* pb,
316323
if (end != NULL) { ADD_URL_PARAM(qparam, end, end); }
317324

318325
if (count != pbccNotSet) { ADD_URL_PARAM(qparam, count, count == pbccTrue ? "true" : "false"); }
326+
327+
if (NULL != filter) { ADD_URL_PARAM(qparam, filter, filter); }
328+
if (NULL != sort) { ADD_URL_PARAM(qparam, sort, sort); }
329+
319330
if (user_id) { ADD_URL_PARAM(qparam, uuid, user_id); }
320331
#if PUBNUB_CRYPTO_API
321332
if (pb->secret_key == NULL) { ADD_URL_AUTH_PARAM(pb, qparam, auth); }
@@ -515,6 +526,8 @@ enum pubnub_res pbcc_get_memberships_prep(struct pbcc_context* pb,
515526
char const* start,
516527
char const* end,
517528
enum pubnub_tribool count,
529+
char const* filter,
530+
char const* sort,
518531
enum pubnub_trans pt)
519532
{
520533
char const* const uname = pubnub_uname();
@@ -542,6 +555,10 @@ enum pubnub_res pbcc_get_memberships_prep(struct pbcc_context* pb,
542555
if (start) { ADD_URL_PARAM(qparam, start, start); }
543556
if (end) { ADD_URL_PARAM(qparam, end, end); }
544557
if (count != pbccNotSet) { ADD_URL_PARAM(qparam, count, count == pbccTrue ? "true" : "false"); }
558+
559+
if (NULL != filter) { ADD_URL_PARAM(qparam, filter, filter); }
560+
if (NULL != sort) { ADD_URL_PARAM(qparam, sort, sort); }
561+
545562
if (user_id) { ADD_URL_PARAM(qparam, uuid, user_id); }
546563
#if PUBNUB_CRYPTO_API
547564
if (pb->secret_key == NULL) { ADD_URL_AUTH_PARAM(pb, qparam, auth); }
@@ -574,6 +591,12 @@ enum pubnub_res pbcc_set_memberships_prep(struct pbcc_context* pb,
574591
char const* uuid_metadataid,
575592
char const* include,
576593
char const* set_obj,
594+
char const* filter,
595+
char const* sort,
596+
size_t limit,
597+
char const* start,
598+
char const* end,
599+
enum pubnub_tribool count,
577600
enum pubnub_trans pt)
578601
{
579602
char const* const uname = pubnub_uname();
@@ -598,6 +621,16 @@ enum pubnub_res pbcc_set_memberships_prep(struct pbcc_context* pb,
598621
URL_PARAMS_INIT(qparam, PUBNUB_MAX_URL_PARAMS);
599622
if (uname) { ADD_URL_PARAM(qparam, pnsdk, uname); }
600623
if (user_id) { ADD_URL_PARAM(qparam, uuid, user_id); }
624+
625+
if (limit > 0) { ADD_URL_PARAM_SIZET(qparam, limit, limit); }
626+
if (NULL != start) { ADD_URL_PARAM(qparam, start, start); }
627+
if (NULL != end) { ADD_URL_PARAM(qparam, end, end); }
628+
629+
if (count != pbccNotSet) { ADD_URL_PARAM(qparam, count, count == pbccTrue ? "true" : "false"); }
630+
631+
if (NULL != filter) { ADD_URL_PARAM(qparam, filter, filter); }
632+
if (NULL != sort) { ADD_URL_PARAM(qparam, sort, sort); }
633+
601634
#if PUBNUB_CRYPTO_API
602635
if (pb->secret_key == NULL) { ADD_URL_AUTH_PARAM(pb, qparam, auth); }
603636
ADD_TS_TO_URL_PARAM();
@@ -633,6 +666,8 @@ enum pubnub_res pbcc_get_members_prep(struct pbcc_context* pb,
633666
size_t limit,
634667
char const* start,
635668
char const* end,
669+
char const* filter,
670+
char const* sort,
636671
enum pubnub_tribool count,
637672
enum pubnub_trans pt)
638673
{
@@ -663,6 +698,10 @@ enum pubnub_res pbcc_get_members_prep(struct pbcc_context* pb,
663698
if (start) { ADD_URL_PARAM(qparam, start, start); }
664699
if (end) { ADD_URL_PARAM(qparam, end, end); }
665700
if (count != pbccNotSet) { ADD_URL_PARAM(qparam, count, count == pbccTrue ? "true" : "false"); }
701+
702+
if (NULL != filter) { ADD_URL_PARAM(qparam, filter, filter); }
703+
if (NULL != sort) { ADD_URL_PARAM(qparam, sort, sort); }
704+
666705
if (user_id) { ADD_URL_PARAM(qparam, uuid, user_id); }
667706
#if PUBNUB_CRYPTO_API
668707
if (pb->secret_key == NULL) { ADD_URL_AUTH_PARAM(pb, qparam, auth); }
@@ -695,6 +734,12 @@ enum pubnub_res pbcc_set_members_prep(struct pbcc_context* pb,
695734
char const* channel_metadataid,
696735
char const* include,
697736
char const* set_obj,
737+
char const* filter,
738+
char const* sort,
739+
size_t limit,
740+
char const* start,
741+
char const* end,
742+
enum pubnub_tribool count,
698743
enum pubnub_trans pt)
699744
{
700745
char const* const uname = pubnub_uname();
@@ -720,6 +765,15 @@ enum pubnub_res pbcc_set_members_prep(struct pbcc_context* pb,
720765
URL_PARAMS_INIT(qparam, PUBNUB_MAX_URL_PARAMS);
721766
if (uname) { ADD_URL_PARAM(qparam, pnsdk, uname); }
722767
if (user_id) { ADD_URL_PARAM(qparam, uuid, user_id); }
768+
769+
if (limit > 0) { ADD_URL_PARAM_SIZET(qparam, limit, limit); }
770+
if (NULL != start) { ADD_URL_PARAM(qparam, start, start); }
771+
if (NULL != end) { ADD_URL_PARAM(qparam, end, end); }
772+
773+
if (count != pbccNotSet) { ADD_URL_PARAM(qparam, count, count == pbccTrue ? "true" : "false"); }
774+
775+
if (NULL != filter) { ADD_URL_PARAM(qparam, filter, filter); }
776+
if (NULL != sort) { ADD_URL_PARAM(qparam, sort, sort); }
723777
#if PUBNUB_CRYPTO_API
724778
if (pb->secret_key == NULL) { ADD_URL_AUTH_PARAM(pb, qparam, auth); }
725779
ADD_TS_TO_URL_PARAM();

core/pbcc_objects_api.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ enum pubnub_res pbcc_find_objects_id(struct pbcc_context* pb,
2626
char const* file,
2727
int line);
2828

29+
// TODO: maybe we should decrease amount of parameters in these functions
30+
2931
/** Prepares the 'get_users' transaction, mostly by
3032
formatting the URI of the HTTP request.
3133
*/
@@ -35,6 +37,8 @@ enum pubnub_res pbcc_getall_uuidmetadata_prep(struct pbcc_context* pb,
3537
char const* start,
3638
char const* end,
3739
enum pubnub_tribool count,
40+
char const* filter,
41+
char const* sort,
3842
enum pubnub_trans pt);
3943

4044
/** Prepares the 'set_uuidmetadata' transaction, mostly by
@@ -70,6 +74,8 @@ enum pubnub_res pbcc_getall_channelmetadata_prep(struct pbcc_context* pb,
7074
char const* start,
7175
char const* end,
7276
enum pubnub_tribool count,
77+
char const* filter,
78+
char const* sort,
7379
enum pubnub_trans pt);
7480

7581

@@ -108,6 +114,8 @@ enum pubnub_res pbcc_get_memberships_prep(struct pbcc_context* pb,
108114
char const* start,
109115
char const* end,
110116
enum pubnub_tribool count,
117+
char const* filter,
118+
char const* sort,
111119
enum pubnub_trans pt);
112120

113121

@@ -118,6 +126,12 @@ enum pubnub_res pbcc_set_memberships_prep(struct pbcc_context* pb,
118126
char const* uuid_metadataid,
119127
char const* include,
120128
char const* update_obj,
129+
char const* filter,
130+
char const* sort,
131+
size_t limit,
132+
char const* start,
133+
char const* end,
134+
enum pubnub_tribool count,
121135
enum pubnub_trans pt);
122136

123137
/** Prepares the 'get_members' transaction, mostly by
@@ -129,6 +143,8 @@ enum pubnub_res pbcc_get_members_prep(struct pbcc_context* pb,
129143
size_t limit,
130144
char const* start,
131145
char const* end,
146+
char const* filter,
147+
char const* sort,
132148
enum pubnub_tribool count,
133149
enum pubnub_trans pt);
134150

@@ -139,6 +155,12 @@ enum pubnub_res pbcc_set_members_prep(struct pbcc_context* pb,
139155
char const* channel_metadataid,
140156
char const* include,
141157
char const* set_obj,
158+
char const* filter,
159+
char const* sort,
160+
size_t limit,
161+
char const* start,
162+
char const* end,
163+
enum pubnub_tribool count,
142164
enum pubnub_trans pt);
143165

144166

0 commit comments

Comments
 (0)