Skip to content

Commit

Permalink
all wrappers
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavrax committed Oct 5, 2023
1 parent d71adab commit f5bd7f5
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 1 deletion.
3 changes: 3 additions & 0 deletions core/pbcc_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,6 @@ pubnub_bymebl_t pbcc_base64_decode(const char* buffer) {
return pbbase64_decode_alloc_std_str(buffer);
}

void pbcc_set_crypto_module(struct pbcc_context *ctx, struct pubnub_crypto_provider_t *crypto_provider) {
ctx->crypto_module = crypto_provider;
}
13 changes: 13 additions & 0 deletions core/pbcc_crypto.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* -*- c-file-style:"stroustrup"; indent-tabs-mode: nil -*- */

#include "pubnub_ccore_pubsub.h"
#ifdef PUBNUB_CRYPTO_API
#ifndef PBCC_CRYPTO_H
#define PBCC_CRYPTO_H
Expand Down Expand Up @@ -272,6 +273,18 @@ const char* pbcc_base64_encode(pubnub_bymebl_t buffer);
@return The decoded string or NULL on error
*/
pubnub_bymebl_t pbcc_base64_decode(const char* buffer);


/**
Set the crypto module to be used by the pubnub context.
This function sets the crypto module to be used by the pubnub context
for the encryption and decryption of the messages.
@param pubnub Pointer to the pubnub context.
@param crypto_provider Pointer to the crypto provider to use.
*/
void pbcc_set_crypto_module(struct pbcc_context *ctx, struct pubnub_crypto_provider_t *crypto_provider);

#endif /* PBCC_CRYPTO_H */
#endif /* PUBNUB_CRYPTO_API */
2 changes: 1 addition & 1 deletion core/pubnub_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,6 @@ static pubnub_bymebl_t provider_decrypt(struct pubnub_crypto_provider_t const* p
}

void pubnub_set_crypto_module(pubnub_t *pubnub, struct pubnub_crypto_provider_t *crypto_provider) {
pubnub->core.crypto_module = crypto_provider;
pbcc_set_crypto_module(&pubnub->core, crypto_provider);
}

12 changes: 12 additions & 0 deletions cpp/pubnub_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1849,6 +1849,18 @@ class context {
#endif
}

#if PUBNUB_CRYPTO_API
/// Set the crypto module to be sued byt the context
///
/// This function sets the crypto module to be used by the context
/// for encryption and decryption of messages.
/// @see pubnub_set_crypto_module()
void set_crypto_module(pubnub_crypto* crypto)
{
pubnub_set_crypto_module(d_pb, crypto);
}
#endif /* PUBNUB_CRYPTO_API */

~context()
{
if (d_pb) {
Expand Down
15 changes: 15 additions & 0 deletions qt/pubnub_qt.h
Original file line number Diff line number Diff line change
Expand Up @@ -1756,6 +1756,21 @@ class pubnub_qt : public QObject
t.fromMSecsSinceStartOfDay(transaction_timeout_get());
}

#if PUBNUB_CRYPTO_API
/**
Set the crypto module to be used by the pubnub.
This function sets the crypto module to be used by the pubnub context
for the encryption and decryption of the messages.
@see pubnub_set_crypto_module()
*/
void set_crypto_module(pubnub_bymeblow_crypto* crypto) {
pbcc_set_crypto_module(crypto);
}
#endif /* PUBNUB_CRYPTO_API */


private slots:
void httpFinished();
void transactionTimeout();
Expand Down

0 comments on commit f5bd7f5

Please sign in to comment.