1- /*
2- FIXME: License, since this header may be distributed independently from
3- other headers.
4- */
1+ /* ************************************************************************
2+ *
3+ * Copyright 2024 Realm Inc.
4+ *
5+ * Licensed under the Apache License, Version 2.0 (the "License");
6+ * you may not use this file except in compliance with the License.
7+ * You may obtain a copy of the License at
8+ *
9+ * http://www.apache.org/licenses/LICENSE-2.0
10+ *
11+ * Unless required by applicable law or agreed to in writing, software
12+ * distributed under the License is distributed on an "AS IS" BASIS,
13+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ * See the License for the specific language governing permissions and
15+ * limitations under the License.
16+ *
17+ **************************************************************************/
518
619#ifndef REALM_H
720#define REALM_H
@@ -2861,16 +2874,39 @@ RLM_API realm_http_transport_t* realm_http_transport_new(realm_http_request_func
28612874RLM_API void realm_http_transport_complete_request (void * request_context, const realm_http_response_t * response);
28622875
28632876/* App */
2864- typedef struct realm_app realm_app_t ;
2865- typedef struct realm_app_credentials realm_app_credentials_t ;
28662877typedef struct realm_user realm_user_t ;
2867-
28682878typedef enum realm_user_state {
28692879 RLM_USER_STATE_LOGGED_OUT,
28702880 RLM_USER_STATE_LOGGED_IN,
28712881 RLM_USER_STATE_REMOVED
28722882} realm_user_state_e;
28732883
2884+ // This type should never be returned from a function.
2885+ // It's only meant as an asynchronous callback argument.
2886+ // Pointers to this struct and its pointer members are only valid inside the scope
2887+ // of the callback they were passed to.
2888+ typedef struct realm_app_error {
2889+ realm_errno_e error;
2890+ realm_error_categories categories;
2891+ const char * message;
2892+
2893+ /* *
2894+ * The underlying HTTP status code returned by the server,
2895+ * otherwise zero.
2896+ */
2897+ int http_status_code;
2898+
2899+ /* *
2900+ * A link to MongoDB Realm server logs related to the error,
2901+ * or NULL if error response didn't contain log information.
2902+ */
2903+ const char * link_to_server_logs;
2904+ } realm_app_error_t ;
2905+
2906+ #if REALM_APP_SERVICES
2907+ typedef struct realm_app realm_app_t ;
2908+ typedef struct realm_app_credentials realm_app_credentials_t ;
2909+
28742910typedef enum realm_auth_provider {
28752911 RLM_AUTH_PROVIDER_ANONYMOUS,
28762912 RLM_AUTH_PROVIDER_ANONYMOUS_NO_REUSE,
@@ -2896,28 +2932,6 @@ typedef struct realm_app_user_apikey {
28962932 bool disabled;
28972933} realm_app_user_apikey_t ;
28982934
2899- // This type should never be returned from a function.
2900- // It's only meant as an asynchronous callback argument.
2901- // Pointers to this struct and its pointer members are only valid inside the scope
2902- // of the callback they were passed to.
2903- typedef struct realm_app_error {
2904- realm_errno_e error;
2905- realm_error_categories categories;
2906- const char * message;
2907-
2908- /* *
2909- * The underlying HTTP status code returned by the server,
2910- * otherwise zero.
2911- */
2912- int http_status_code;
2913-
2914- /* *
2915- * A link to MongoDB Realm server logs related to the error,
2916- * or NULL if error response didn't contain log information.
2917- */
2918- const char * link_to_server_logs;
2919- } realm_app_error_t ;
2920-
29212935typedef struct realm_user_identity {
29222936 /* *
29232937 * Ptr to null terminated string representing user identity (memory has to be freed by SDK)
@@ -3391,19 +3405,6 @@ RLM_API void realm_app_sync_client_wait_for_sessions_to_terminate(realm_app_t*)
33913405 */
33923406RLM_API char * realm_app_sync_client_get_default_file_path_for_realm (const realm_sync_config_t *,
33933407 const char * custom_filename);
3394- /* *
3395- * Return the identiy for the user passed as argument
3396- * @param user ptr to the user for which the identiy has to be retrieved
3397- * @return a ptr to the identity string. This must be manually released with realm_free().
3398- */
3399- RLM_API char * realm_user_get_identity (const realm_user_t * user) RLM_API_NOEXCEPT;
3400-
3401- /* *
3402- * Retrieve the state for the user passed as argument
3403- * @param user ptr to the user for which the state has to be retrieved
3404- * @return realm_user_state_e value
3405- */
3406- RLM_API realm_user_state_e realm_user_get_state (const realm_user_t * user) RLM_API_NOEXCEPT;
34073408
34083409/* *
34093410 * Get the list of identities of this @a user.
@@ -3430,8 +3431,6 @@ RLM_API char* realm_user_get_device_id(const realm_user_t*) RLM_API_NOEXCEPT;
34303431 */
34313432RLM_API bool realm_user_log_out (realm_user_t *);
34323433
3433- RLM_API bool realm_user_is_logged_in (const realm_user_t *) RLM_API_NOEXCEPT;
3434-
34353434/* *
34363435 * Get the custom user data from the user's access token.
34373436 *
@@ -3452,24 +3451,65 @@ RLM_API char* realm_user_get_custom_data(const realm_user_t*) RLM_API_NOEXCEPT;
34523451 */
34533452RLM_API char * realm_user_get_profile_data (const realm_user_t *);
34543453
3454+ typedef struct realm_app_user_subscription_token realm_app_user_subscription_token_t ;
3455+ typedef void (*realm_sync_on_user_state_changed_t )(realm_userdata_t userdata, realm_user_state_e s);
34553456/* *
3456- * Return the access token associated with the user.
3457- * @return a string that rapresents the access token
3457+ * @return a notification token object. Dispose it to stop receiving notifications.
34583458 */
3459- RLM_API char * realm_user_get_access_token (const realm_user_t *);
3459+ RLM_API realm_app_user_subscription_token_t *
3460+ realm_sync_user_on_state_change_register_callback (realm_user_t *, realm_sync_on_user_state_changed_t ,
3461+ realm_userdata_t userdata,
3462+ realm_free_userdata_func_t userdata_free);
34603463
34613464/* *
3462- * Return the refresh token associated with the user.
3463- * @return a string that represents the refresh token
3465+ * In case manual reset is needed, run this function in order to reset sync client files.
3466+ * The sync_path is going to passed into realm_sync_error_handler_func_t, if manual reset is needed.
3467+ * This function is supposed to be called inside realm_sync_error_handler_func_t callback, if sync client reset is
3468+ * needed
3469+ * @param realm_app ptr to realm app.
3470+ * @param sync_path path where the sync files are.
3471+ * @param did_run ptr to bool, which will be set to true if operation was successful
3472+ * @return true if operation was successful
34643473 */
3465- RLM_API char * realm_user_get_refresh_token (const realm_user_t *);
3474+ RLM_API bool realm_sync_immediately_run_file_actions (realm_app_t * realm_app, const char * sync_path,
3475+ bool * did_run) RLM_API_NOEXCEPT;
34663476
34673477/* *
34683478 * Return the realm app for the user passed as parameter.
34693479 * @return a ptr to the app for the user.
34703480 */
34713481RLM_API realm_app_t * realm_user_get_app (const realm_user_t *) RLM_API_NOEXCEPT;
34723482
3483+ #endif // REALM_APP_SERVICES
3484+
3485+ /* *
3486+ * Return the identiy for the user passed as argument
3487+ * @param user ptr to the user for which the identiy has to be retrieved
3488+ * @return a ptr to the identity string. This must be manually released with realm_free().
3489+ */
3490+ RLM_API char * realm_user_get_identity (const realm_user_t * user) RLM_API_NOEXCEPT;
3491+
3492+ /* *
3493+ * Retrieve the state for the user passed as argument
3494+ * @param user ptr to the user for which the state has to be retrieved
3495+ * @return realm_user_state_e value
3496+ */
3497+ RLM_API realm_user_state_e realm_user_get_state (const realm_user_t * user) RLM_API_NOEXCEPT;
3498+
3499+ RLM_API bool realm_user_is_logged_in (const realm_user_t *) RLM_API_NOEXCEPT;
3500+
3501+ /* *
3502+ * Return the access token associated with the user.
3503+ * @return a string that rapresents the access token
3504+ */
3505+ RLM_API char * realm_user_get_access_token (const realm_user_t *);
3506+
3507+ /* *
3508+ * Return the refresh token associated with the user.
3509+ * @return a string that represents the refresh token
3510+ */
3511+ RLM_API char * realm_user_get_refresh_token (const realm_user_t *);
3512+
34733513
34743514/* Sync */
34753515typedef enum realm_sync_client_reconnect_mode {
@@ -3601,13 +3641,10 @@ typedef enum realm_flx_sync_subscription_set_state {
36013641typedef void (*realm_sync_on_subscription_state_changed_t )(realm_userdata_t userdata,
36023642 realm_flx_sync_subscription_set_state_e state);
36033643
3604- typedef void (*realm_sync_on_user_state_changed_t )(realm_userdata_t userdata, realm_user_state_e s);
3605-
36063644
36073645typedef struct realm_async_open_task_progress_notification_token realm_async_open_task_progress_notification_token_t ;
36083646typedef struct realm_sync_session_connection_state_notification_token
36093647 realm_sync_session_connection_state_notification_token_t ;
3610- typedef struct realm_app_user_subscription_token realm_app_user_subscription_token_t ;
36113648
36123649/* *
36133650 * Callback function invoked by the async open task once the realm is open and fully synchronized.
@@ -3976,18 +4013,6 @@ RLM_API void realm_sync_session_resume(realm_sync_session_t*) RLM_API_NOEXCEPT;
39764013RLM_API void realm_sync_session_get_file_ident (realm_sync_session_t *,
39774014 realm_salted_file_ident_t * out) RLM_API_NOEXCEPT;
39784015
3979- /* *
3980- * In case manual reset is needed, run this function in order to reset sync client files.
3981- * The sync_path is going to passed into realm_sync_error_handler_func_t, if manual reset is needed.
3982- * This function is supposed to be called inside realm_sync_error_handler_func_t callback, if sync client reset is
3983- * needed
3984- * @param realm_app ptr to realm app.
3985- * @param sync_path path where the sync files are.
3986- * @param did_run ptr to bool, which will be set to true if operation was successful
3987- * @return true if operation was successful
3988- */
3989- RLM_API bool realm_sync_immediately_run_file_actions (realm_app_t * realm_app, const char * sync_path,
3990- bool * did_run) RLM_API_NOEXCEPT;
39914016
39924017/* *
39934018 * Register a callback that will be invoked every time the session's connection state changes.
@@ -4014,14 +4039,6 @@ RLM_API realm_sync_session_connection_state_notification_token_t* realm_sync_ses
40144039 realm_userdata_t userdata, realm_free_userdata_func_t userdata_free) RLM_API_NOEXCEPT;
40154040
40164041
4017- /* *
4018- * @return a notification token object. Dispose it to stop receiving notifications.
4019- */
4020- RLM_API realm_app_user_subscription_token_t *
4021- realm_sync_user_on_state_change_register_callback (realm_user_t *, realm_sync_on_user_state_changed_t ,
4022- realm_userdata_t userdata,
4023- realm_free_userdata_func_t userdata_free);
4024-
40254042/* *
40264043 * Register a callback that will be invoked when all pending downloads have completed.
40274044 */
@@ -4057,6 +4074,9 @@ RLM_API void realm_sync_session_handle_error_for_testing(const realm_sync_sessio
40574074 */
40584075RLM_API void realm_register_user_code_callback_error (realm_userdata_t usercode_error) RLM_API_NOEXCEPT;
40594076
4077+
4078+ #if REALM_APP_SERVICES
4079+
40604080typedef struct realm_mongodb_collection realm_mongodb_collection_t ;
40614081
40624082typedef struct realm_mongodb_find_options {
@@ -4275,6 +4295,8 @@ RLM_API bool realm_mongo_collection_find_one_and_delete(realm_mongodb_collection
42754295 realm_userdata_t data, realm_free_userdata_func_t delete_data,
42764296 realm_mongodb_callback_t callback);
42774297
4298+ #endif // REALM_APP_SERVICES
4299+
42784300/* *
42794301 * Creates a new sync socket instance for the Sync Client that handles the operations for a custom
42804302 * websocket and event loop implementation.
0 commit comments