Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

Commit

Permalink
Merge pull request #120 from Melodatron/MOD_DELETED-processing-in-pol…
Browse files Browse the repository at this point in the history
…ling

MOD_DELETED processing in polling
  • Loading branch information
Turupawn authored Jun 11, 2020
2 parents b3ed9fd + 574fc0c commit 23df71b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
13 changes: 7 additions & 6 deletions include/c/ModioC.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ typedef int i32;
#define MODIO_EVENT_USER_TEAM_LEAVE 6
#define MODIO_EVENT_USER_SUBSCRIBE 7
#define MODIO_EVENT_USER_UNSUBSCRIBE 8
#define MODIO_EVENT_MOD_DELETED 9

// Presentation Option Constants
#define MODIO_GRID_VIEW 0
Expand Down Expand Up @@ -266,7 +267,7 @@ extern "C"
char* thumb_640x360;
char* thumb_1280x720;
};

struct ModioIcon
{
char* filename;
Expand Down Expand Up @@ -469,7 +470,7 @@ extern "C"
char* path;
ModioMod mod;
};

struct ModioQueuedModDownload
{
u32 state;
Expand Down Expand Up @@ -689,8 +690,8 @@ extern "C"
void MODIO_DLL modioCancelModDownload(u32 mod_id);
void MODIO_DLL modioResumeDownloads(void);
void MODIO_DLL modioPrioritizeModDownload(u32 mod_id);
void MODIO_DLL modioSetDownloadListener(void (*callback)(u32 response_code, u32 mod_id));
void MODIO_DLL modioSetUploadListener(void (*callback)(u32 response_code, u32 mod_id));
void MODIO_DLL modioSetDownloadListener(void (*callback)(u32 response_code, u32 mod_id));
void MODIO_DLL modioSetUploadListener(void (*callback)(u32 response_code, u32 mod_id));
u32 MODIO_DLL modioGetModDownloadQueueCount(void);
void MODIO_DLL modioGetModDownloadQueue(ModioQueuedModDownload* download_queue);
u32 MODIO_DLL modioGetModfileUploadQueueCount(void);
Expand All @@ -712,7 +713,7 @@ extern "C"
//Comment Methods
void MODIO_DLL modioGetAllModComments(void* object, u32 mod_id, ModioFilterCreator filter, void (*callback)(void* object, ModioResponse response, ModioComment comments[], u32 comments_size));
void MODIO_DLL modioGetAllModCommentsFilterString(void* object, u32 mod_id, char const* filter_string, u32 cache_max_age_seconds, void (*callback)(void* object, ModioResponse response, ModioComment comments[], u32 comments_size));
void MODIO_DLL modioGetModComment(void* object, u32 mod_id, u32 comment_id, void (*callback)(void* object, ModioResponse response, ModioComment comment));
void MODIO_DLL modioGetModComment(void* object, u32 mod_id, u32 comment_id, void (*callback)(void* object, ModioResponse response, ModioComment comment));
void MODIO_DLL modioDeleteModComment(void* object, u32 mod_id, u32 comment_id, void(*callback)(void* object, ModioResponse response));

//Reports Methods
Expand All @@ -728,7 +729,7 @@ extern "C"
void MODIO_DLL modioFreeQueuedModDownload(ModioQueuedModDownload* queued_mod_download);
void MODIO_DLL modioFreeQueuedModfileUpload(ModioQueuedModfileUpload* queued_modfile_upload);

// General Utility Methods
// General Utility Methods
void MODIO_DLL compressFiles(char const* root_directory, char const* const filenames[], u32 filenames_size, char const* zip_path);
void MODIO_DLL extractFiles(char const* zip_path, char const* directory_path);
void MODIO_DLL windowsUTF8ToAnsi(const char* UTF8_string, char* ansi_string);
Expand Down
12 changes: 12 additions & 0 deletions src/ModioUtility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ static void onGetAllEventsPoll(void *object, ModioResponse response, ModioModEve

std::vector<u32> mod_edited_ids;
std::vector<u32> mod_to_download_queue_ids;
std::vector<u32> mod_deleted_ids;
if(events_array_size > 0)
modio::clearCache();
for (size_t i = 0; i < events_array_size; i++)
Expand Down Expand Up @@ -316,11 +317,22 @@ static void onGetAllEventsPoll(void *object, ModioResponse response, ModioModEve
mod_edited_ids.push_back(events_array[i].mod_id);
break;
}
case MODIO_EVENT_MOD_DELETED:
{
modio::writeLogLine("Mod deleted. Mod id: " + modio::toString(events_array[i].mod_id) + " Uninstalling...", MODIO_DEBUGLEVEL_LOG);
mod_deleted_ids.push_back(events_array[i].mod_id);
}
}
}
/* TODO: Re-enable mod profile update? */
//if (mod_edited_ids.size() > 0)
// updateModsCache(mod_edited_ids);
size_t deleted_mod_count = mod_deleted_ids.size();
for (size_t i = 0; i < deleted_mod_count; ++i)
{
modioUninstallMod(mod_deleted_ids[i]);
}

if (mod_to_download_queue_ids.size() > 0)
addModsToDownloadQueue(mod_to_download_queue_ids);

Expand Down
2 changes: 2 additions & 0 deletions src/c/schemas/ModioModEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ extern "C"
event->event_type = MODIO_EVENT_MOD_UNAVAILABLE;
else if(event_json["event_type"] == "MOD_EDITED")
event->event_type = MODIO_EVENT_MOD_EDITED;
else if(event_json["event_type"] == "MOD_DELETED")
event->event_type = MODIO_EVENT_MOD_DELETED;
else if(event_json["event_type"] == "USER_TEAM_JOIN")
event->event_type = MODIO_EVENT_USER_TEAM_JOIN;
else if(event_json["event_type"] == "USER_TEAM_LEAVE")
Expand Down
2 changes: 2 additions & 0 deletions src/c/schemas/ModioUserEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ extern "C"
event->event_type = MODIO_EVENT_MOD_UNAVAILABLE;
else if(event_json["event_type"] == "MOD_EDITED")
event->event_type = MODIO_EVENT_MOD_EDITED;
else if(event_json["event_type"] == "MOD_DELETED")
event->event_type = MODIO_EVENT_MOD_DELETED;
else if(event_json["event_type"] == "USER_TEAM_JOIN")
event->event_type = MODIO_EVENT_USER_TEAM_JOIN;
else if(event_json["event_type"] == "USER_TEAM_LEAVE")
Expand Down

0 comments on commit 23df71b

Please sign in to comment.