Mercurial > wgsdk
changeset 4:59bf702b2b21
*: stylistic changes
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Sun, 14 Aug 2022 13:17:32 -0400 |
parents | 8df8af626dca |
children | 3dee72fffe97 |
files | src/config.c src/dirtools.c src/include/config.h src/include/dialog.rc src/main.c |
diffstat | 5 files changed, 22 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/src/config.c Sun Aug 07 22:47:41 2022 -0400 +++ b/src/config.c Sun Aug 14 13:17:32 2022 -0400 @@ -13,7 +13,7 @@ #include <windowsx.h> #define MAX_LINE_LENGTH 128 -extern struct config_t config; // from main +extern struct config config; // from main static unsigned int crc32b(unsigned char *message) { int i, j; @@ -33,7 +33,7 @@ return ~crc; } -int cfg_load(struct config_t* config) { +int cfg_load(struct config* config) { char line[MAX_LINE_LENGTH] = {0}, *path = dirtools_concat_paths(getenv("APPDATA"), "Winamp\\Plugins\\wgsdk\\config.txt"); FILE* config_fp; @@ -58,7 +58,7 @@ return 0; } -int cfg_save(struct config_t config) { +int cfg_save(struct config config) { char* path = dirtools_concat_paths(getenv("APPDATA"), "Winamp\\Plugins\\wgsdk"); FILE* config_fp; assert(!dirtools_create_directory(path));
--- a/src/dirtools.c Sun Aug 07 22:47:41 2022 -0400 +++ b/src/dirtools.c Sun Aug 14 13:17:32 2022 -0400 @@ -13,10 +13,11 @@ } int dirtools_create_directory(char* path) { - char* alltoks = calloc(strlen(path), sizeof(char)), *tok; + char* alltoks = calloc(strlen(path)+2, sizeof(char)), *tok; for (tok = strtok(path, "\\"); tok != NULL; tok = strtok(NULL, "\\")) { strcat(alltoks, tok); + strcat(alltoks, "\\"); if (dirtools_directory_exists(path)) { if (!CreateDirectoryA(alltoks, NULL)) { if (GetLastError() == ERROR_PATH_NOT_FOUND) {
--- a/src/include/config.h Sun Aug 07 22:47:41 2022 -0400 +++ b/src/include/config.h Sun Aug 14 13:17:32 2022 -0400 @@ -4,12 +4,12 @@ # define WIN32_LEAN_AND_MEAN #endif #include <windows.h> -struct config_t { +struct config { int display_title; int show_elapsed_time; }; -int cfg_load(struct config_t* config); -int cfg_save(struct config_t config); +int cfg_load(struct config* config); +int cfg_save(struct config config); BOOL CALLBACK cfg_win_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); #endif \ No newline at end of file
--- a/src/include/dialog.rc Sun Aug 07 22:47:41 2022 -0400 +++ b/src/include/dialog.rc Sun Aug 14 13:17:32 2022 -0400 @@ -1,5 +1,5 @@ +#include <winres.h> #include "resource.h" -#include "winres.h" LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US @@ -11,6 +11,5 @@ DEFPUSHBUTTON "OK",IDOK,149,50,50,14 PUSHBUTTON "Cancel",IDCANCEL,205,50,50,14 CONTROL "Show title in details",TITLE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,7,77,10 - CONTROL "Show elapsed time in presence",ELAPSED_TIME_CHECK, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,20,114,10 + CONTROL "Show elapsed time in presence",ELAPSED_TIME_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,33,114,10 END
--- a/src/main.c Sun Aug 07 22:47:41 2022 -0400 +++ b/src/main.c Sun Aug 14 13:17:32 2022 -0400 @@ -32,7 +32,7 @@ WNDPROC g_lpWndProcOld = 0; struct timer_t timer_callbacks = { .interval = 16 }; -struct config_t config = { +struct config config = { .display_title = 1, .show_elapsed_time = 1 }; @@ -71,15 +71,14 @@ activity.timestamps.start = 0; } - char* detailsMessage = calloc(256, sizeof(char)); + char* details_message = calloc(256, sizeof(char)); if (config.display_title) { wchar_t* title = (wchar_t*)SendMessageW(g_plugin.hwndParent, WM_WA_IPC, 0, IPC_GET_PLAYING_TITLE); - assert(WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, title, -1, detailsMessage, 256, NULL, NULL)); - } else { - strcpy(activity.details, ""); + assert(WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, title, -1, details_message, 256, NULL, NULL)); + free(title); } - strcpy(activity.details, detailsMessage); - free(detailsMessage); + strcpy(activity.details, details_message); + free(details_message); app.activities->update_activity(app.activities, &activity, &app, update_activity_callback); } @@ -97,16 +96,14 @@ LONG isPlayingResult = SendMessageW(g_plugin.hwndParent, WM_WA_IPC, 0, IPC_ISPLAYING); switch (isPlayingResult) { - case 1: - report_current_song_status(1); - break; - case 3: - report_current_song_status(3); - break; case 0: report_idle_status(); break; - default: break; + case 1: + case 3: + report_current_song_status(isPlayingResult); + default: + break; } } @@ -164,7 +161,7 @@ } void conf() { - DialogBoxW(g_plugin.hDllInstance, (LPWSTR)DIALOG_CONFIG, g_plugin.hwndParent, &cfg_win_proc); + DialogBoxW(g_plugin.hDllInstance, (LPWSTR)DIALOG_CONFIG, g_plugin.hwndParent, (DLGPROC)cfg_win_proc); } __declspec(dllexport) winamp_general_purpose_plugin* winampGetGeneralPurposePlugin() {