Commit 3f53d5f0 authored by Sylvain Berfini's avatar Sylvain Berfini

Reworked jni layer to be able to set multiple vtables for callbacks in android app

parent 1bb6ebed
......@@ -7025,16 +7025,34 @@ LinphoneCoreVTable *linphone_core_v_table_new() {
return ms_new0(LinphoneCoreVTable,1);
}
void linphone_core_v_table_set_user_data(LinphoneCoreVTable *table, void *data) {
if (table->user_data) {
ms_free(table->user_data);
}
table->user_data = data;
}
void* linphone_core_v_table_get_user_data(LinphoneCoreVTable *table) {
return table->user_data;
}
void linphone_core_v_table_destroy(LinphoneCoreVTable* table) {
if (table->user_data) {
ms_free(table->user_data);
}
ms_free(table);
}
LinphoneCoreVTable *linphone_core_get_current_vtable(LinphoneCore *lc) {
return lc->current_vtable;
}
#define NOTIFY_IF_EXIST(function_name) \
MSList* iterator; \
ms_message ("Linphone core [%p] notifying [%s]",lc,#function_name);\
for (iterator=lc->vtables; iterator!=NULL; iterator=iterator->next) \
if (((LinphoneCoreVTable*)(iterator->data))->function_name)\
if ((lc->current_vtable=((LinphoneCoreVTable*)(iterator->data)))->function_name)\
((LinphoneCoreVTable*)(iterator->data))->function_name
void linphone_core_notify_global_state_changed(LinphoneCore *lc, LinphoneGlobalState gstate, const char *message) {
NOTIFY_IF_EXIST(global_state_changed)(lc,gstate,message);
}
......
......@@ -1558,7 +1558,7 @@ typedef enum _LinphoneCoreLogCollectionUploadState {
* @param gstate the global state
* @param message informational message.
*/
typedef void (*LinphoneCoreGlobalStateChangedCb )(LinphoneCore *lc, LinphoneGlobalState gstate, const char *message);
typedef void (*LinphoneCoreGlobalStateChangedCb)(LinphoneCore *lc, LinphoneGlobalState gstate, const char *message);
/**
* Call state notification callback.
* @param lc the LinphoneCore
......@@ -1809,6 +1809,7 @@ typedef struct _LinphoneCoreVTable{
LinphoneCoreNetworkReachableCb network_reachable; /**< Callback to report IP network status (I.E up/down )*/
LinphoneCoreLogCollectionUploadStateChangedCb log_collection_upload_state_changed; /**< Callback to upload collected logs */
LinphoneCoreLogCollectionUploadProgressIndicationCb log_collection_upload_progress_indication; /**< Callback to indicate log collection upload progress */
void *user_data;
} LinphoneCoreVTable;
/**
......@@ -1817,6 +1818,28 @@ typedef struct _LinphoneCoreVTable{
*/
LINPHONE_PUBLIC LinphoneCoreVTable *linphone_core_v_table_new();
/**
* Sets a user data pointer in the vtable.
* @param table the vtable
* @param data the user data to attach
*/
LINPHONE_PUBLIC void linphone_core_v_table_set_user_data(LinphoneCoreVTable *table, void *data);
/**
* Gets a user data pointer in the vtable.
* @param table the vtable
* @returns the data attached to the vtable
*/
LINPHONE_PUBLIC void* linphone_core_v_table_get_user_data(LinphoneCoreVTable *table);
/**
* Gets the current VTable.
* This is meant only to be called from a callback to be able to get the user_data associated with the vtable that called the callback.
* @param lc the linphonecore
* @returns the vtable that called the last callback
*/
LINPHONE_PUBLIC LinphoneCoreVTable *linphone_core_get_current_vtable(LinphoneCore *lc);
/**
* Destroy a vtable.
* @param vtable to be destroyed
......
This diff is collapsed.
......@@ -784,6 +784,7 @@ struct _LinphoneCore
LinphoneReason chat_deny_code;
const char **supported_formats;
LinphoneContent *log_collection_upload_information;
LinphoneCoreVTable *current_vtable; // the latest vtable to call a callback, see linphone_core_get_current_vtable
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment