refactor pcallbacks into pqevent and ptevent

This commit is contained in:
Levi Neely 2025-03-01 14:43:07 +01:00
parent 4733b575a4
commit c2cc0e9590
13 changed files with 156 additions and 154 deletions

View File

@ -43,8 +43,7 @@
#include "papi.h"
#include "pbusinessaccount.h"
#include "pcache.h"
#include "pcallbacks.h"
#include "pfile.h"
#include "pqevent.h"
#include "pcontacts.h"
#include "pdevice.h"
#include "pdiff.h"
@ -1766,7 +1765,7 @@ static void process_modifyuserinfo(const binresult *entry) {
psync_sql_bind_uint(q, 2, crstat);
psync_sql_run(q);
psync_sql_free_result(q);
psync_send_eventid(PEVENT_USERINFO_CHANGED);
pqevent_queue_eventid(PEVENT_USERINFO_CHANGED);
}
static void send_share_notify(psync_eventtype_t eventid, const binresult *share,
@ -1925,7 +1924,7 @@ static void send_share_notify(psync_eventtype_t eventid, const binresult *share,
} else {
fill_str(e->toemail, email, emaillen);
fill_str(e->fromemail, email, emaillen);
psync_send_eventdata(eventid, e);
pqevent_queue_event(eventid, e);
}
}
@ -1948,7 +1947,7 @@ static void do_send_eventdata(void *param) {
if (email) {
psync_diff_lock();
psync_send_eventdata(data->eventid, data->event_data);
pqevent_queue_event(data->eventid, data->event_data);
psync_diff_unlock();
}
@ -2517,7 +2516,7 @@ static uint64_t process_entries(const binresult *entries, uint64_t newdiffid) {
used_quota =
psync_sql_cellint("SELECT value FROM setting WHERE id='usedquota'", 0);
if (oused_quota != used_quota)
psync_send_eventid(PEVENT_USEDQUOTA_CHANGED);
pqevent_queue_eventid(PEVENT_USEDQUOTA_CHANGED);
return psync_sql_cellint("SELECT value FROM setting WHERE id='diffid'", 0);
}
@ -2836,7 +2835,7 @@ static int psync_diff_check_quota(psock_t *sock) {
debug(D_WARNING, "corrected locally calculated quota from %lu to %lu",
(unsigned long)oused_quota, (unsigned long)used_quota);
psync_set_uint_value("usedquota", used_quota);
psync_send_eventid(PEVENT_USEDQUOTA_CHANGED);
pqevent_queue_eventid(PEVENT_USEDQUOTA_CHANGED);
}
uq = papi_find_result2(papi_find_result2(res, "apiserver", PARAM_HASH),
"binapi", PARAM_ARRAY);

View File

@ -40,7 +40,7 @@
#include <mbedtls/ssl.h>
#include "papi.h"
#include "pcallbacks.h"
#include "pqevent.h"
#include "pdownload.h"
#include "pfolder.h"
#include "plibs.h"
@ -244,7 +244,7 @@ static int call_func_for_folder(psync_folderid_t localfolderid,
if (likely(localpath)) {
res = func(localpath);
if (!res) {
psync_send_event_by_id(event, syncid, localpath, folderid);
pqevent_queue_sync_event_id(event, syncid, localpath, folderid);
if (updatemtime)
update_local_folder_mtime(localpath, localfolderid);
psync_decrease_local_folder_taskcnt(localfolderid);
@ -271,7 +271,7 @@ static int call_func_for_folder_name(psync_folderid_t localfolderid,
if (likely(localpath)) {
res = func(localpath);
if (!res) {
psync_send_event_by_path(event, syncid, localpath, folderid, name);
pqevent_queue_sync_event_path(event, syncid, localpath, folderid, name);
if (updatemtime)
update_local_folder_mtime(localpath, localfolderid);
psync_decrease_local_folder_taskcnt(localfolderid);
@ -394,7 +394,7 @@ static int task_renamefolder(psync_syncid_t newsyncid,
else {
psync_decrease_local_folder_taskcnt(localfolderid);
psync_sql_commit_transaction();
psync_send_event_by_id(PEVENT_LOCAL_FOLDER_RENAMED, newsyncid, newpath,
pqevent_queue_sync_event_id(PEVENT_LOCAL_FOLDER_RENAMED, newsyncid, newpath,
folderid);
debug(D_NOTICE, "local folder renamed from %s to %s", oldpath, newpath);
}
@ -688,7 +688,7 @@ static int task_download_file(download_task_t *dt) {
if (dt->dwllist.stop)
return 0;
// psync_send_event_by_id(PEVENT_FILE_DOWNLOAD_STARTED, syncid, name,
// pqevent_queue_sync_event_id(PEVENT_FILE_DOWNLOAD_STARTED, syncid, name,
// fileid);
if (serversize >= PSYNC_MIN_SIZE_FOR_P2P) {
rt = psync_p2p_check_download(dt->dwllist.fileid, serverhashhex, serversize,
@ -865,7 +865,7 @@ static int task_download_file(download_task_t *dt) {
}
if (rename_and_create_local(dt, serverhashhex, serversize, hash))
goto err0;
// psync_send_event_by_id(PEVENT_FILE_DOWNLOAD_FINISHED, syncid, name,
// pqevent_queue_sync_event_id(PEVENT_FILE_DOWNLOAD_FINISHED, syncid, name,
// fileid);
debug(D_NOTICE, "file downloaded %s", dt->localname);
psync_list_for_each_element_call(&ranges, psync_range_list_t, list,
@ -925,7 +925,7 @@ static int task_delete_file(psync_syncid_t syncid, psync_fileid_t fileid,
debug(D_NOTICE, "local file %s deleted", name);
// threre are some reports about crashes here, comment out for now as
// events are not fully implemented anyway
// psync_send_event_by_path(PEVENT_LOCAL_FILE_DELETED, row[1], name,
// pqevent_queue_sync_event_path(PEVENT_LOCAL_FILE_DELETED, row[1], name,
// fileid, remotepath);
psync_free(name);
}

View File

@ -59,7 +59,7 @@
#include "pupload.h"
#include "putil.h"
#include "pcallbacks.h"
#include "pqevent.h"
typedef struct {
@ -1650,7 +1650,7 @@ static int handle_rename_folder_api_error(uint64_t result,
"folder at once.");
psync_fstask_folder_renamed(task->folderid, task->id, task->text1,
task->int1);
psync_send_eventid(PEVENT_SHARE_RENAME_F);
pqevent_queue_eventid(PEVENT_SHARE_RENAME_F);
return 0;
}

View File

@ -27,12 +27,10 @@
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "pcallbacks.h"
#include "pfile.h"
#include "pqevent.h"
#include "pfolder.h"
#include "plibs.h"
#include "plist.h"
#include "prunratelimit.h"
#include "prun.h"
#include "psys.h"
#include <string.h>
@ -41,6 +39,8 @@
#define DONT_SHOW_TIME_IF_SEC_OVER (2 * 86400)
#define DONT_SHOW_TIME_IF_SPEED_BELOW (4 * 1024)
#define cat_const(src, app) cat_lstr(src, app, sizeof(app) - 1)
static pthread_mutex_t statusmutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t statuscond = PTHREAD_COND_INITIALIZER;
static int statuschanges = 0;
@ -100,8 +100,6 @@ format10:
return src;
}
#define cat_const(src, app) cat_lstr(src, app, sizeof(app) - 1)
static char *fill_formatted_bytes(char *str, uint64_t bytes) {
const static char *sizes[] = {"Bytes", "KB", "MB", "GB", "TB"};
uint32_t rem, sz;
@ -254,12 +252,6 @@ static void status_fill_formatted_str(pstatus_t *status, char *downloadstr,
status->uploadstr = uploadstr;
}
void psync_callbacks_get_status(pstatus_t *status) {
static char downloadstr[MAX_STATUS_STR_LEN], uploadstr[MAX_STATUS_STR_LEN];
memcpy(status, &psync_status, sizeof(pstatus_t));
status_fill_formatted_str(status, downloadstr, uploadstr);
}
static void status_change_thread(void *ptr) {
char downloadstr[MAX_STATUS_STR_LEN], uploadstr[MAX_STATUS_STR_LEN];
pstatus_change_callback_t callback = (pstatus_change_callback_t)ptr;
@ -298,25 +290,7 @@ static void status_change_thread(void *ptr) {
}
}
void psync_set_status_callback(pstatus_change_callback_t callback) {
pthread_mutex_lock(&statusmutex);
statusthreadrunning = 1;
pthread_mutex_unlock(&statusmutex);
prun_thread1("status change", status_change_thread, callback);
}
void psync_send_status_update() {
if (statusthreadrunning) {
pthread_mutex_lock(&statusmutex);
if (++statuschanges == 0) {
statuschanges++;
pthread_cond_signal(&statuscond);
}
pthread_mutex_unlock(&statusmutex);
}
}
static void event_thread(void *ptr) {
static void proc_send_event(void *ptr) {
pevent_callback_t callback = (pevent_callback_t)ptr;
event_list_t *event;
@ -342,15 +316,39 @@ static void event_thread(void *ptr) {
}
}
void psync_set_event_callback(pevent_callback_t callback) {
void psync_callbacks_get_status(pstatus_t *status) {
static char downloadstr[MAX_STATUS_STR_LEN], uploadstr[MAX_STATUS_STR_LEN];
memcpy(status, &psync_status, sizeof(pstatus_t));
status_fill_formatted_str(status, downloadstr, uploadstr);
}
void psync_set_status_callback(pstatus_change_callback_t callback) {
pthread_mutex_lock(&statusmutex);
statusthreadrunning = 1;
pthread_mutex_unlock(&statusmutex);
prun_thread1("status change", status_change_thread, callback);
}
void psync_send_status_update() {
if (statusthreadrunning) {
pthread_mutex_lock(&statusmutex);
if (++statuschanges == 0) {
statuschanges++;
pthread_cond_signal(&statuscond);
}
pthread_mutex_unlock(&statusmutex);
}
}
void pqevent_process(pevent_callback_t callback) {
pthread_mutex_lock(&statusmutex);
eventthreadrunning = 1;
pthread_mutex_unlock(&statusmutex);
psync_list_init(&eventlist);
prun_thread1("event", event_thread, callback);
prun_thread1("event", proc_send_event, callback);
}
void psync_send_event_by_id(psync_eventtype_t eventid, psync_syncid_t syncid,
void pqevent_queue_sync_event_id(psync_eventtype_t eventid, psync_syncid_t syncid,
const char *localpath,
psync_fileorfolderid_t remoteid) {
if (eventthreadrunning) {
@ -361,12 +359,12 @@ void psync_send_event_by_id(psync_eventtype_t eventid, psync_syncid_t syncid,
remotepath = psync_get_path_by_fileid(remoteid, NULL);
if (unlikely_log(!remotepath))
return;
psync_send_event_by_path(eventid, syncid, localpath, remoteid, remotepath);
pqevent_queue_sync_event_path(eventid, syncid, localpath, remoteid, remotepath);
psync_free(remotepath);
}
}
void psync_send_event_by_path(psync_eventtype_t eventid, psync_syncid_t syncid,
void pqevent_queue_sync_event_path(psync_eventtype_t eventid, psync_syncid_t syncid,
const char *localpath,
psync_fileorfolderid_t remoteid,
const char *remotepath) {
@ -414,7 +412,7 @@ void psync_send_event_by_path(psync_eventtype_t eventid, psync_syncid_t syncid,
}
}
void psync_send_eventid(psync_eventtype_t eventid) {
void pqevent_queue_eventid(psync_eventtype_t eventid) {
if (eventthreadrunning) {
event_list_t *event;
@ -430,7 +428,7 @@ void psync_send_eventid(psync_eventtype_t eventid) {
}
}
void psync_send_eventdata(psync_eventtype_t eventid, void *eventdata) {
void pqevent_queue_event(psync_eventtype_t eventid, void *eventdata) {
if (eventthreadrunning) {
event_list_t *event;
@ -446,49 +444,3 @@ void psync_send_eventdata(psync_eventtype_t eventid, void *eventdata) {
} else
psync_free(eventdata);
}
data_event_callback data_event_fptr = NULL;
void psync_init_data_event(void *ptr) {
data_event_fptr = (data_event_callback)ptr;
debug(D_NOTICE, "Data event handler set.");
}
void data_event_thread(void *ptr) {
event_data_struct *data = (event_data_struct *)ptr;
debug(D_NOTICE,
"Sending data event Event id: [%d] Str1: [%s], Str1: [%s], Uint1:[%lu] "
"Uint2:[%lu]",
data->eventid, data->str1, data->str2, data->uint1, data->uint2);
data_event_fptr(data->eventid, (char *)data->str1, (char *)data->str2,
data->uint1, data->uint2);
psync_free(ptr);
}
void psync_send_data_event(event_data_struct *data) {
event_data_struct *event_data;
if (data_event_fptr) {
event_data = psync_new(event_data_struct);
event_data->eventid = data->eventid;
event_data->uint1 = data->uint1;
event_data->uint2 = data->uint2;
event_data->str1 = strdup(data->str1);
event_data->str2 = strdup(data->str2);
prun_thread1("Data Event", data_event_thread, event_data);
} else {
debug(D_ERROR, "Data event callback function not set.");
}
}
void psync_data_event_test(int eventid, char *str1, char *str2, uint64_t uint1,
uint64_t uint2) {
debug(D_NOTICE,
"Test Data event callback. eventid [%d]. String1: [%s], String2: [%s], "
"uInt1: [%lu] uInt2: [%lu]",
eventid, str1, str2, uint1, uint2);
}

16
pclsync/pqevent.h Normal file
View File

@ -0,0 +1,16 @@
// pqevent is a queue-based event system that processes events sequentially.
// Events are added to a queue and handled by a single consumer thread.
// Supports various event data types through a union structure.
#ifndef __PQEVENT_H
#define __PQEVENT_H
#include "psynclib.h"
void pqevent_process(pevent_callback_t callback);
void pqevent_queue_eventid(psync_eventtype_t eventid);
void pqevent_queue_event(psync_eventtype_t eventid, void *eventdata);
void pqevent_queue_sync_event_id(psync_eventtype_t eventid, psync_syncid_t syncid, const char *localpath, psync_fileorfolderid_t remoteid);
void pqevent_queue_sync_event_path(psync_eventtype_t eventid, psync_syncid_t syncid, const char *localpath, psync_fileorfolderid_t remoteid, const char *remotepath);
#endif

View File

@ -31,7 +31,6 @@
#include "pfile.h"
#include "pstatus.h"
#include "pcallbacks.h"
#include "pfstasks.h"
#include "plibs.h"
#include "prunratelimit.h"
@ -46,7 +45,7 @@ static uint32_t statuses[PSTATUS_NUM_STATUSES] = {
PSTATUS_INVALID, PSTATUS_ACCFULL_QUOTAOK,
PSTATUS_DISKFULL_OK, PSTATUS_LOCALSCAN_SCANNING};
static pthread_mutex_t statusmutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t status_internal_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t statuscond = PTHREAD_COND_INITIALIZER;
static unsigned long status_waiters = 0;
@ -245,14 +244,14 @@ void psync_status_recalc_to_upload_async() {
}
uint32_t psync_status_get(uint32_t statusid) {
pthread_mutex_lock(&statusmutex);
pthread_mutex_lock(&status_internal_mutex);
statusid = statuses[statusid];
pthread_mutex_unlock(&statusmutex);
pthread_mutex_unlock(&status_internal_mutex);
return statusid;
}
void psync_set_status(uint32_t statusid, uint32_t status) {
pthread_mutex_lock(&statusmutex);
pthread_mutex_lock(&status_internal_mutex);
statuses[statusid] = status;
if (status_waiters)
pthread_cond_broadcast(&statuscond);
@ -260,7 +259,7 @@ void psync_set_status(uint32_t statusid, uint32_t status) {
(statuses[PSTATUS_TYPE_ACCFULL] == PSTATUS_ACCFULL_OVERQUOTA);
psync_status.localisfull =
(statuses[PSTATUS_TYPE_DISKFULL] == PSTATUS_DISKFULL_FULL);
pthread_mutex_unlock(&statusmutex);
pthread_mutex_unlock(&status_internal_mutex);
status = psync_calc_status();
if (psync_status.status != status) {
psync_status.status = status;
@ -269,13 +268,13 @@ void psync_set_status(uint32_t statusid, uint32_t status) {
}
void psync_wait_status(uint32_t statusid, uint32_t status) {
pthread_mutex_lock(&statusmutex);
pthread_mutex_lock(&status_internal_mutex);
while ((statuses[statusid] & status) == 0 && psync_do_run) {
status_waiters++;
pthread_cond_wait(&statuscond, &statusmutex);
pthread_cond_wait(&statuscond, &status_internal_mutex);
status_waiters--;
}
pthread_mutex_unlock(&statusmutex);
pthread_mutex_unlock(&status_internal_mutex);
if (unlikely(!psync_do_run)) {
debug(D_NOTICE, "exiting");
pthread_exit(NULL);
@ -283,15 +282,15 @@ void psync_wait_status(uint32_t statusid, uint32_t status) {
}
void psync_terminate_status_waiters() {
pthread_mutex_lock(&statusmutex);
pthread_mutex_lock(&status_internal_mutex);
if (status_waiters)
pthread_cond_broadcast(&statuscond);
pthread_mutex_unlock(&statusmutex);
pthread_mutex_unlock(&status_internal_mutex);
}
void psync_wait_statuses_array(const uint32_t *combinedstatuses, uint32_t cnt) {
uint32_t waited, i, statusid, status;
pthread_mutex_lock(&statusmutex);
pthread_mutex_lock(&status_internal_mutex);
do {
waited = 0;
for (i = 0; i < cnt; i++) {
@ -300,12 +299,12 @@ void psync_wait_statuses_array(const uint32_t *combinedstatuses, uint32_t cnt) {
while ((statuses[statusid] & status) == 0) {
waited = 1;
status_waiters++;
pthread_cond_wait(&statuscond, &statusmutex);
pthread_cond_wait(&statuscond, &status_internal_mutex);
status_waiters--;
}
}
} while (waited);
pthread_mutex_unlock(&statusmutex);
pthread_mutex_unlock(&status_internal_mutex);
}
void psync_wait_statuses(uint32_t first, ...) {
@ -323,16 +322,16 @@ void psync_wait_statuses(uint32_t first, ...) {
int psync_statuses_ok_array(const uint32_t *combinedstatuses, uint32_t cnt) {
uint32_t i, statusid, status;
pthread_mutex_lock(&statusmutex);
pthread_mutex_lock(&status_internal_mutex);
for (i = 0; i < cnt; i++) {
statusid = combinedstatuses[i] >> 24;
status = combinedstatuses[i] & 0x00ffffff;
if ((statuses[statusid] & status) == 0) {
pthread_mutex_unlock(&statusmutex);
pthread_mutex_unlock(&status_internal_mutex);
return 0;
}
}
pthread_mutex_unlock(&statusmutex);
pthread_mutex_unlock(&status_internal_mutex);
return 1;
}

View File

@ -33,6 +33,9 @@
#include <stdint.h>
#include "ptevent.h"
#include "psynclib.h"
#define PSTATUS_NUM_STATUSES 6
#define PSTATUS_TYPE_RUN 0
@ -76,6 +79,7 @@
#define PSTATUS_COMBINE(type, statuses) (((type) << 24) + (statuses))
void psync_status_init();
void psync_status_recalc_to_download();
void psync_status_recalc_to_download_async();
@ -95,6 +99,12 @@ void psync_status_set_upload_speed(uint32_t speed);
void psync_status_send_update();
void psync_callbacks_get_status(pstatus_t *status);
void psync_set_status_callback(pstatus_change_callback_t callback);
void psync_send_status_update();
void ptevent_process(event_data_struct *data);
static inline int psync_status_is_offline() {
return psync_status_get(PSTATUS_TYPE_ONLINE) == PSTATUS_ONLINE_OFFLINE;
}

View File

@ -37,7 +37,6 @@
#include <pthread.h>
#include <stddef.h>
#include "pcallbacks.h"
#include "pdownload.h"
#include "pfile.h"
#include "pfolder.h"

View File

@ -44,7 +44,8 @@
#include "papi.h"
#include "pbusinessaccount.h"
#include "pcache.h"
#include "pcallbacks.h"
#include "ptevent.h"
#include "pqevent.h"
#include "pcloudcrypto.h"
#include "pcontacts.h"
#include "pdevice.h"
@ -323,7 +324,7 @@ void psync_start_sync(pstatus_change_callback_t status_callback,
if (status_callback)
psync_set_status_callback(status_callback);
if (event_callback)
psync_set_event_callback(event_callback);
pqevent_process(event_callback);
psync_syncer_init();
psync_diff_init();
psync_upload_init();
@ -3052,7 +3053,7 @@ void psync_async_delete_sync(void *ptr) {
debug(D_NOTICE, "Backup stopped on the Web.");
if (res == 0) {
psync_send_eventid(PEVENT_BACKUP_STOP);
pqevent_queue_eventid(PEVENT_BACKUP_STOP);
}
}
@ -3064,7 +3065,7 @@ void psync_async_ui_callback(void *ptr) {
(lastBupDelEventTime == 0)) {
debug(D_NOTICE, "Send event to UI. Event id: [%d]", eventId);
psync_send_eventid(eventId);
pqevent_queue_eventid(eventId);
lastBupDelEventTime = currTime;
}
@ -3121,9 +3122,9 @@ void psync_send_backup_del_event(psync_fileorfolderid_t remoteFId) {
if (((currTime - lastBupDelEventTime) > bupNotifDelay) ||
(lastBupDelEventTime == 0)) {
if (remoteFId == 0) {
psync_send_eventid(PEVENT_BKUP_F_DEL_NOTSYNCED);
pqevent_queue_eventid(PEVENT_BKUP_F_DEL_NOTSYNCED);
} else {
psync_send_eventid(PEVENT_BKUP_F_DEL_SYNCED);
pqevent_queue_eventid(PEVENT_BKUP_F_DEL_SYNCED);
}
lastBupDelEventTime = currTime;
@ -3227,7 +3228,7 @@ int psync_create_backend_event(const char *category, const char *action,
P_OS_ID, rawtime, &params, &err);
}
void psync_init_data_event_handler(void *ptr) { psync_init_data_event(ptr); }
void psync_init_data_event_handler(void *ptr) { ptevent_init(ptr); }
// moved from pdiff
void psync_delete_cached_crypto_keys() {

View File

@ -41,7 +41,6 @@
#include <pthread.h>
#include "papi.h"
#include "pcallbacks.h"
#include "pcompression.h"
#include "pdownload.h"
#include "pfile.h"

42
pclsync/ptevent.c Normal file
View File

@ -0,0 +1,42 @@
#include "ptevent.h"
#include "plibs.h"
#include "prun.h"
data_event_callback data_event_fptr = NULL;
static void proc_send_data_event(void *ptr) {
event_data_struct *data = (event_data_struct *)ptr;
debug(D_NOTICE,
"Sending data event Event id: [%d] Str1: [%s], Str1: [%s], Uint1:[%lu] "
"Uint2:[%lu]",
data->eventid, data->str1, data->str2, data->uint1, data->uint2);
data_event_fptr(data->eventid, (char *)data->str1, (char *)data->str2,
data->uint1, data->uint2);
psync_free(ptr);
}
void ptevent_init(void *ptr) {
data_event_fptr = (data_event_callback)ptr;
debug(D_NOTICE, "Data event handler set.");
}
void ptevent_process(event_data_struct *data) {
event_data_struct *event_data;
if (data_event_fptr) {
event_data = psync_new(event_data_struct);
event_data->eventid = data->eventid;
event_data->uint1 = data->uint1;
event_data->uint2 = data->uint2;
event_data->str1 = strdup(data->str1);
event_data->str2 = strdup(data->str2);
prun_thread1("Data Event", proc_send_data_event, event_data);
} else {
debug(D_ERROR, "Data event callback function not set.");
}
}

View File

@ -27,14 +27,16 @@
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _PSYNC_CALLBACKS_H
#define _PSYNC_CALLBACKS_H
// ptevent is a thread-based event system that processes each event in parallel.
// Each event spawns its own thread, allowing for concurrent event handling.
// Primarily used for events containing string/numeric data.
#include "psynclib.h"
#ifndef __PTEVENT_H
#define __PTEVENT_H
typedef void(/*_cdecl*/ *data_event_callback)(int eventId, char *str1,
char *str2, uint64_t uint1,
uint64_t uint2);
#include <stdint.h>
#define PEVENT_SYNC_RENAME_F 1
typedef struct {
int eventid;
@ -44,26 +46,9 @@ typedef struct {
uint64_t uint2;
} event_data_struct;
void psync_callbacks_get_status(pstatus_t *status);
void psync_set_status_callback(pstatus_change_callback_t callback);
void psync_send_status_update();
void psync_set_event_callback(pevent_callback_t callback);
void psync_send_event_by_id(psync_eventtype_t eventid, psync_syncid_t syncid,
const char *localpath,
psync_fileorfolderid_t remoteid);
void psync_send_event_by_path(psync_eventtype_t eventid, psync_syncid_t syncid,
const char *localpath,
psync_fileorfolderid_t remoteid,
const char *remotepath);
void psync_send_eventid(psync_eventtype_t eventid);
void psync_send_eventdata(psync_eventtype_t eventid, void *eventdata);
typedef void(*data_event_callback)(int eventId, char *str1, char *str2, uint64_t uint1, uint64_t uint2);
#define PEVENT_SYNC_RENAME_F 1
void ptevent_init(void *ptr);
void ptevent_process(event_data_struct *data);
void psync_init_data_event(void *ptr);
void psync_send_data_event(event_data_struct *data);
void psync_data_event_test(int eventid, char *str1, char *str2, uint64_t uint1,
uint64_t uint2);
#endif
#endif

View File

@ -38,7 +38,7 @@
#include <stddef.h>
#include "papi.h"
#include "pcallbacks.h"
#include "ptevent.h"
#include "pfile.h"
#include "pcompiler.h"
#include "pdiff.h"
@ -373,7 +373,7 @@ int handle_api_errors(sync_err_struct *err_struct) {
psync_delete_sync(syncId);
psync_send_data_event(event_data);
ptevent_process(event_data);
psync_free(event_data);
break;