Skip to content
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
63 changes: 54 additions & 9 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
name: c-core
version: 2.10.2
schema: 1
version: 2.11.0
scm: github.com/pubnub/c-core
changelog:
- version: v2.11.0
date: Oct 20, 2019
changes:
- type: enhancement
text: Introduce Actions API
- type: bug
text: Fix stopwatch not working after 25 days
- type: ehnancement
text: Add 'include_meta' parameter to pubnub_history_ex()
- version: v2.10.2
date: Oct 18, 2019
changes:
Expand Down Expand Up @@ -111,9 +121,9 @@ changelog:
- type: enhancement
text: Update Qt functional tests and make them reliable
- type: enhancement
text: UUID is now part of the Pubnub context (instead of a pointer to it). This makes handling its lifetime easier, yet doesn't incur much memory increase
text: UUID is now part of the Pubnub context (instead of a pointer to it). This makes handling its lifetime easier, yet does not incur much memory increase
- type: bug
text: C++ wrapper and Qt did not have proper multithreading support as they did not protect _their_ data. Now that's fixed.
text: C++ wrapper and Qt did not have proper multithreading support as they did not protect _their_ data. Now that is fixed.
- version: v2.6.2
date: Dec 20, 2018
changes:
Expand Down Expand Up @@ -372,37 +382,72 @@ features:
- PUBLISH-RAW-JSON
- PUBLISH-WITH-METADATA
- PUBLISH-GET
- PUBLISH-POST
- PUBLISH-SYNC
- PUBLISH-ASYNC
- SIGNAL-SEND
- PUBLISH-FIRE
- PUBLISH-REPLICATION-FLAG
storage:
- STORAGE-INCLUDE-TIMETOKEN
- STORAGE-COUNT
- STORAGE-REVERSE
- STORAGE-START-END
- STORAGE-MESSAGE-COUNT
time:
- TIME-TIME
- STORAGE-HISTORY-WITH-META
- STORAGE-FETCH-WITH-META
- STORAGE-FETCH-WITH-MESSAGE-ACTIONS
subscribe:
- SUBSCRIBE-CHANNELS
- SUBSCRIBE-CHANNEL-GROUPS
- SUBSCRIBE-PRESENCE-CHANNELS
- SUBSCRIBE-PRESENCE-CHANNELS-GROUPS
- SUBSCRIBE-WILDCARD
- SUBSCRIBE-FILTER-EXPRESSION
- SUBSCRIBE-SIGNAL-LISTENER
- SUBSCRIBE-USER-LISTENER
- SUBSCRIBE-SPACE-LISTENER
- SUBSCRIBE-MEMBERSHIP-LISTENER
- SUBSCRIBE-MESSAGE-ACTIONS-LISTENER
signal:
- SIGNAL-SEND
objects:
- OBJECTS-GET-USER
- OBJECTS-GET-USERS
- OBJECTS-CREATE-USER
- OBJECTS-UPDATE-USER
- OBJECTS-DELETE-USER
- OBJECTS-GET-SPACE
- OBJECTS-GET-SPACES
- OBJECTS-CREATE-SPACE
- OBJECTS-UPDATE-SPACE
- OBJECTS-DELETE-SPACE
- OBJECTS-GET-MEMBERSHIPS
- OBJECTS-JOIN-SPACES
- OBJECTS-UPDATE-MEMBERSHIPS
- OBJECTS-LEAVE-SPACES
- OBJECTS-GET-MEMBERS
- OBJECTS-ADD-MEMBERS
- OBJECTS-UPDATE-MEMBERS
- OBJECTS-REMOVE-MEMBERS
message-actions:
- MESSAGE-ACTIONS-GET
- MESSAGE-ACTIONS-ADD
- MESSAGE-ACTIONS-REMOVE
time:
- TIME-TIME
supported-platforms:
-
version: PubNub POSIX C SDK
platforms:
- Most modern Unix-derived OSes support enough of POSIX to work. For some, like MacOS (OSX) we have special support to handle them not being fully POSIX compliant. Basically, if the OS is released in last 3/4 years, it will most probably work.
- Some older OSes, like Ubuntu 12.04 or older, may need a few tweaks to work.
- For TLS/SSL support, we use OpenSSL, and a recent version, 0.9.8 or higher should work. If the user doesn't wish to use TLS/SSL, she doesn't need OpenSSL at all.
- For TLS/SSL support, we use OpenSSL, and a recent version, 0.9.8 or higher should work. If the user doe snot wish to use TLS/SSL, she does not need OpenSSL at all.
-
version: PubNub POSIX C++ SDK
platforms:
- Most modern Unix-derived OSes support enough of POSIX to work. For some, like MacOS (OSX) we have special support to handle them not being fully POSIX compliant. Basically, if the OS is released in last 3/4 years, it will most probably work.
- Some older OSes, like Ubuntu 12.04 or older, may need a few tweaks to work.
- For TLS/SSL support, we use OpenSSL, and a recent version, 0.9.8 or higher should work. If the user doesn't wish to use TLS/SSL, she doesn't need OpenSSL at all.
- For TLS/SSL support, we use OpenSSL, and a recent version, 0.9.8 or higher should work. If the user does not wish to use TLS/SSL, she does not need OpenSSL at all.
- Some features require C++11 or newer compliant compiler, if you do not have such a compiler you will not be able to use those features (but will be able to use the rest of the POSIX C++ SDK)
-
version: PubNub Windows C SDK
Expand All @@ -413,7 +458,7 @@ supported-platforms:
version: PubNub Windows C++ SDK
platforms:
- Windows 7 or newer with Visual Studio 2008 or newer should work. Newer versions of Clang for Windows and GCC (MINGW or Cygwin) should also work.
- For TLS/SSL support, we use OpenSSL, and a recent version, 0.9.8 or higher should work. If the user doesn't wish to use TLS/SSL, she doesn't need OpenSSL at all.
- For TLS/SSL support, we use OpenSSL, and a recent version, 0.9.8 or higher should work. If the user doesn't wish to use TLS/SSL, she does not need OpenSSL at all.
- Some features require C++11 or newer compliant compiler, if you do not have such a compiler you will not be able to use those features (but will be able to use the rest of the Windows C++ SDK)
-
version: PubNub FreeRTOS SDK
Expand Down
84 changes: 63 additions & 21 deletions core/pbcc_actions_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,22 @@ enum pubnub_res pbcc_form_the_action_object(struct pbcc_context* pb,
char* obj_buffer,
size_t buffer_size,
enum pubnub_action_type actype,
char const** json)
char const** val)
{
char const* uuid = pbcc_uuid_get(pb);
char const* type_literal;
if (NULL == uuid) {
PUBNUB_LOG_ERROR("pbcc_form_the_action_object(pbcc=%p) - uuid not set.\n", pb);
return PNR_INVALID_PARAMETERS;
}
if (('\"' != **val) || ('\"' != *(*val + pb_strnlen_s(*val, PUBNUB_MAX_OBJECT_LENGTH) - 1))) {
PUBNUB_LOG_ERROR("pbcc_form_the_action_object(pbcc=%p) - "
"quotation marks on value ends are missing: "
"value = %s\n",
pb,
*val);
return PNR_INVALID_PARAMETERS;
}
switch(actype) {
case pbactypReaction:
type_literal = "reaction";
Expand All @@ -47,7 +55,7 @@ enum pubnub_res pbcc_form_the_action_object(struct pbcc_context* pb,
}
if (buffer_size < sizeof("{\"type\":\"\",\"value\":,\"uuid\":\"\"}") +
pb_strnlen_s(type_literal, sizeof "reaction") +
pb_strnlen_s(*json, PUBNUB_MAX_OBJECT_LENGTH) +
pb_strnlen_s(*val, PUBNUB_MAX_OBJECT_LENGTH) +
pb_strnlen_s(uuid, sizeof pb->uuid)) {
PUBNUB_LOG_ERROR("pbcc_form_the_action_object(pbcc=%p) - "
"buffer size is too small: "
Expand All @@ -57,17 +65,17 @@ enum pubnub_res pbcc_form_the_action_object(struct pbcc_context* pb,
(unsigned long)buffer_size,
(unsigned long)(sizeof("{\"type\":\"\",\"value\":,\"uuid\":\"\"}") +
pb_strnlen_s(type_literal, sizeof "reaction") +
pb_strnlen_s(*json, PUBNUB_MAX_OBJECT_LENGTH) +
pb_strnlen_s(*val, PUBNUB_MAX_OBJECT_LENGTH) +
pb_strnlen_s(uuid, sizeof pb->uuid)));
return PNR_TX_BUFF_TOO_SMALL;
}
snprintf(obj_buffer,
buffer_size,
"{\"type\":\"%s\",\"value\":%s,\"uuid\":\"%s\"}",
type_literal,
*json,
*val,
uuid);
*json = obj_buffer;
*val = obj_buffer;

return PNR_OK;
}
Expand All @@ -89,7 +97,7 @@ enum pubnub_res pbcc_add_action_prep(struct pbcc_context* pb,
pb->msg_ofs = pb->msg_end = 0;
pb->http_buf_len = snprintf(pb->http_buf,
sizeof pb->http_buf,
"/v1/actions/%s/channel/",
"/v1/message-actions/%s/channel/",
pb->subscribe_key);
APPEND_URL_ENCODED_M(pb, channel);
APPEND_URL_LITERAL_M(pb, "/message/");
Expand Down Expand Up @@ -189,27 +197,48 @@ pubnub_chamebl_t pbcc_get_action_timetoken(struct pbcc_context* pb)

enum pubnub_res pbcc_remove_action_prep(struct pbcc_context* pb,
char const* channel,
char const* message_timetoken,
char const* action_timetoken)
pubnub_chamebl_t message_timetoken,
pubnub_chamebl_t action_timetoken)
{
char const* const uname = pubnub_uname();
char const* uuid = pbcc_uuid_get(pb);

PUBNUB_ASSERT_OPT(channel != NULL);
PUBNUB_ASSERT_OPT(message_timetoken != NULL);
PUBNUB_ASSERT_OPT(action_timetoken != NULL);
PUBNUB_ASSERT_OPT(message_timetoken.ptr != NULL);
PUBNUB_ASSERT_OPT(action_timetoken.ptr != NULL);

if ((*message_timetoken.ptr != '\"') ||
(*(message_timetoken.ptr + message_timetoken.size - 1) != '\"')) {
PUBNUB_LOG_ERROR("pbcc_remove_action_prep(pbcc=%p) - "
"message timetoken is missing quotation marks: "
"message_timetoken = %.*s\n",
pb,
(int)message_timetoken.size,
message_timetoken.ptr);
return PNR_INVALID_PARAMETERS;
}
if ((*action_timetoken.ptr != '\"') ||
(*(action_timetoken.ptr + action_timetoken.size - 1) != '\"')) {
PUBNUB_LOG_ERROR("pbcc_remove_action_prep(pbcc=%p) - "
"action timetoken is missing quotation marks: "
"action_timetoken = %.*s\n",
pb,
(int)action_timetoken.size,
action_timetoken.ptr);
return PNR_INVALID_PARAMETERS;
}

pb->http_content_len = 0;
pb->msg_ofs = pb->msg_end = 0;
pb->http_buf_len = snprintf(pb->http_buf,
sizeof pb->http_buf,
"/v1/actions/%s/channel/",
"/v1/message-actions/%s/channel/",
pb->subscribe_key);
APPEND_URL_ENCODED_M(pb, channel);
APPEND_URL_LITERAL_M(pb, "/message/");
APPEND_URL_ENCODED_M(pb, message_timetoken);
APPEND_URL_STRING_M(pb, message_timetoken.ptr + 1, message_timetoken.size - 2);
APPEND_URL_LITERAL_M(pb, "/action/");
APPEND_URL_ENCODED_M(pb, action_timetoken);
APPEND_URL_STRING_M(pb, action_timetoken.ptr + 1, action_timetoken.size - 2);
APPEND_URL_PARAM_M(pb, "pnsdk", uname, '?');
APPEND_URL_PARAM_M(pb, "uuid", uuid, '&');
APPEND_URL_PARAM_M(pb, "auth", pb->auth, '&');
Expand All @@ -228,21 +257,23 @@ enum pubnub_res pbcc_get_actions_prep(struct pbcc_context* pb,
char const* uuid = pbcc_uuid_get(pb);

PUBNUB_ASSERT_OPT(channel != NULL);
PUBNUB_ASSERT_OPT(limit < MAX_ACTIONS_LIMIT);
PUBNUB_ASSERT_OPT(limit <= MAX_ACTIONS_LIMIT);

pb->http_content_len = 0;
pb->msg_ofs = pb->msg_end = 0;
pb->http_buf_len = snprintf(pb->http_buf,
sizeof pb->http_buf,
"/v1/actions/%s/channel/",
"/v1/message-actions/%s/channel/",
pb->subscribe_key);
APPEND_URL_ENCODED_M(pb, channel);
APPEND_URL_PARAM_M(pb, "pnsdk", uname, '?');
APPEND_URL_PARAM_M(pb, "uuid", uuid, '&');
APPEND_URL_PARAM_M(pb, "auth", pb->auth, '&');
APPEND_URL_PARAM_M(pb, "start", start, '&');
APPEND_URL_PARAM_M(pb, "end", end, '&');
APPEND_URL_PARAM_UNSIGNED_M(pb, "limit", (unsigned)limit, '&');
if (limit != 0) {
APPEND_URL_PARAM_UNSIGNED_M(pb, "limit", (unsigned)limit, '&');
}

return PNR_STARTED;
}
Expand Down Expand Up @@ -282,13 +313,22 @@ enum pubnub_res pbcc_get_actions_more_prep(struct pbcc_context* pb)

return PNR_FORMAT_ERROR;
}
json_rslt = pbjson_get_object_value(&parsed, "url", &elem);
if (json_rslt != jonmpOK) {
PUBNUB_LOG_ERROR("pbcc_get_actions_more_prep(pbcc=%p) - Invalid response: "
"pbjson_get_object_value(\"url\") reported an error: %s\n",
pb,
pbjson_object_name_parse_result_2_string(json_rslt));

return PNR_FORMAT_ERROR;
}
pb->http_content_len = 0;
pb->msg_ofs = pb->msg_end = 0;
pb->http_buf_len = snprintf(pb->http_buf,
sizeof pb->http_buf,
"%.*s",
(int)(parsed.end - parsed.start - 2),
parsed.start + 1);
(int)(elem.end - elem.start - 2),
elem.start + 1);
APPEND_URL_PARAM_M(pb, "pnsdk", uname, '&');
APPEND_URL_PARAM_M(pb, "uuid", uuid, '&');
APPEND_URL_PARAM_M(pb, "auth", pb->auth, '&');
Expand All @@ -307,21 +347,23 @@ enum pubnub_res pbcc_history_with_actions_prep(struct pbcc_context* pb,
char const* uuid = pbcc_uuid_get(pb);

PUBNUB_ASSERT_OPT(channel != NULL);
PUBNUB_ASSERT_OPT(limit < MAX_ACTIONS_LIMIT);
PUBNUB_ASSERT_OPT(limit <= MAX_ACTIONS_LIMIT);

pb->http_content_len = 0;
pb->msg_ofs = pb->msg_end = 0;
pb->http_buf_len = snprintf(pb->http_buf,
sizeof pb->http_buf,
"/v1/history-with-actions/%s/channel/",
"/v3/history-with-actions/sub-key/%s/channel/",
pb->subscribe_key);
APPEND_URL_ENCODED_M(pb, channel);
APPEND_URL_PARAM_M(pb, "pnsdk", uname, '?');
APPEND_URL_PARAM_M(pb, "uuid", uuid, '&');
APPEND_URL_PARAM_M(pb, "auth", pb->auth, '&');
APPEND_URL_PARAM_M(pb, "start", start, '&');
APPEND_URL_PARAM_M(pb, "end", end, '&');
APPEND_URL_PARAM_UNSIGNED_M(pb, "limit", (unsigned)limit, '&');
if (limit != 0) {
APPEND_URL_PARAM_UNSIGNED_M(pb, "limit", (unsigned)limit, '&');
}

return PNR_STARTED;
}
Expand Down
4 changes: 2 additions & 2 deletions core/pbcc_actions_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ pubnub_chamebl_t pbcc_get_action_timetoken(struct pbcc_context* pb);
*/
enum pubnub_res pbcc_remove_action_prep(struct pbcc_context* pb,
char const* channel,
char const* message_timetoken,
char const* action_timetoken);
pubnub_chamebl_t message_timetoken,
pubnub_chamebl_t action_timetoken);

/** Prepares the 'get_actions' transaction, mostly by
formatting the URI of the HTTP request.
Expand Down
Loading