From c72a0b6171fca66ba363ec7148a1cc03459a0c2f Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Sat, 28 Sep 2013 18:23:38 +0000 Subject: ac.dll support removed coz nobody use it and it is too old git-svn-id: http://svn.miranda-ng.org/main/trunk@6261 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Variables/docs/Variables.txt | 7 -- plugins/Variables/src/ac/ac.h | 183 ------------------------------- plugins/Variables/src/parse_external.cpp | 111 ------------------- plugins/Variables/src/parse_external.h | 4 - plugins/Variables/src/variables.cpp | 1 - plugins/Variables/src/variables.h | 2 - 6 files changed, 308 deletions(-) delete mode 100644 plugins/Variables/src/ac/ac.h diff --git a/plugins/Variables/docs/Variables.txt b/plugins/Variables/docs/Variables.txt index 14b37e0a48..af25cbf0fa 100644 --- a/plugins/Variables/docs/Variables.txt +++ b/plugins/Variables/docs/Variables.txt @@ -360,13 +360,6 @@ PCRE is available from the "external" folder in this package and/or from http://www.pcre.org/ 4) -The variables amipvar and amipformat are only available if you have -ac.dll in your miranda directory (or system32). ac.dll is available -from the "external" folder in this package and/or from -http://amip.tools-for.net/ (part of amip_sdk). You'll also need to -install one of the AMIP servers from http://amip.tools-for.net/ - -5) Variables v0.2.0.0 syntax is inspired by the TAGZ system used in Foobar2000, http://www.foobar2000.org/. diff --git a/plugins/Variables/src/ac/ac.h b/plugins/Variables/src/ac/ac.h deleted file mode 100644 index 7d0790f32b..0000000000 --- a/plugins/Variables/src/ac/ac.h +++ /dev/null @@ -1,183 +0,0 @@ -// AMIP public API -#ifndef _AC_H_ -#define _AC_H_ - -enum ac_StartMode { - AC_START_ALL = 0, - AC_START_CLIENT, - AC_START_SERVER, - AC_START_NONE -}; - -enum ac_ErrorCode { - AC_ERR_NOERROR = 0, - AC_ERR_CLIENTISNULL, - AC_ERR_EXCEPTION, - AC_ERR_CONNECTIONFAILED, - AC_ERR_SERVERNOTRUNNING -}; - -#define AC_BUFFER_SIZE 2048 - -// flags for event listener -#define AC_EVT_PLAY 0x0001 -#define AC_EVT_PAUSE 0x0002 -#define AC_EVT_STOP 0x0004 -#define AC_EVT_START 0x0008 -#define AC_EVT_EXIT 0x0010 - -#define AC_EVT_TIMER 0x0020 -#define AC_EVT_MSG 0x0040 - -#define AC_EVT_CHANGE 0x0080 - -#define AC_EVT_PLCHANGE 0x0100 -#define AC_EVT_PLREADY 0x0200 - -// doesn't include AC_EVT_TIMER, because it can be expensive and usually not necessary to use -// doesn't include AC_EVT_MSG. It's delivered to the message callback function and is never delivered to -// event callback function -#define AC_EVT_ALL AC_EVT_PLAY | AC_EVT_PAUSE | AC_EVT_STOP | AC_EVT_START | AC_EVT_EXIT | AC_EVT_CHANGE | AC_EVT_PLCHANGE | AC_EVT_PLREADY - -typedef VOID (CALLBACK* AC_MSG_CALLBACK) (const char *); -typedef VOID (CALLBACK* AC_EVT_CALLBACK) (int); - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - // Initializes client part of the component. Parameters specify host and port client - // should connect to (where AMIP is running), connection timeout in milliseconds, number - // of seconds (dsec) to suspend connections for if failed to connect dcount times. - // returns 1 if client was initialized properly, 0 otherwise - int WINAPI ac_init_client(const char *host, int port, int timeout, int dsec, int dcount); - - // Initializes and starts the server part of the component. Server part listens for - // incoming connections from AMIP, it receives messages and events on specified host and port. - // returns 1 if server was started successfully, 0 otherwise - int WINAPI ac_init_server(const char *host, int port); - - // Alternative method to start services, differs from 2 specified above in the way - // where it gets the configuration data. Startup data is read from the ac.ini file. - // Don't use ac_init() together with ac_init_client() and ac_init_server()! - // Call to start services (AC_START_ALL to start both client and server) - // AC_START_CLIENT will start client only (you can query and control AMIP) - // AC_START_SERVER will start server only (you can accept song announcements from AMIP) - void WINAPI ac_init(int mode); - - // Call when you finished working with AMIP (e.g. on exit) - void WINAPI ac_uninit(); - - // Useful if you need to uninit the client to init it later with different options - void WINAPI ac_uninit_client(); - - // Stops the server, you can start it again with different options later - // Subsequent calls to ac_uninit_client() and ac_stop_server() can be replaced with the - // single call to ac_uninit() - void WINAPI ac_stop_server(); - - // Passes command to AMIP. For the list of commands see AMIP Help. - // Remove '/dde mplug' prefix to get the real command, for instance - // in the help you see '/dde mplug announce preset 1' command, this - // function will accept 'announce preset 1' as the parameter - int WINAPI ac_exec(const char *cmd); - - // Evaluates AMIP's variable and puts the result into the result buffer - // cmd can be var_, where variable is any of the AMIP variables - // without %, for instance %name becomes var_name. Also cfg_ - // variables are supported (cfg_enabled, cfg_rmienabled, etc.) - // Basically, all the $dde variables from help can be evaluated via this - // function ('$dde mplug format "%name"' becomes 'format "%name"') - // Warning: result buffer must have AC_BUFFER_SIZE capacity - int WINAPI ac_eval(const char *cmd, char *result); - - // same as ac_eval but takes a format spec string and evaluates it all, the format - // spec may look like "%1 - %2 (%br~kbps)" - int WINAPI ac_format(const char *cmd, char *result); - // ac_exec and ac_eval return one of the AC_ERR_* codes - // if function succeeds, the return code is AC_ERR_NOERROR (0) - // if ac_eval fails, empty string is placed into the result buffer - - // Registers callback function which will receive all messages from AMIP. - // Pass address of your function taking char* as an argument and it will - // be called every time AMIP has something to say you - void WINAPI ac_register_msg_callback(AC_MSG_CALLBACK); - - // Event callback will accept events from AMIP if listener for events was added - void WINAPI ac_register_evt_callback(AC_EVT_CALLBACK); - - // Adds listener to AMIP, AMIP will notify host:port about the events specified by flags - // until listener is removed or fail_count limit is reached. If notification fails - // fail_count times, AMIP automatically removes listener for the specified host:port. - // AMIP keeps listeners even between restarts (in plugin.ini file) - int WINAPI ac_add_event_listener(const char *host, int port, int timeout, UINT flags, UINT fail_count); - - // You must unregister all listeners that you have registered before your application exits - int WINAPI ac_remove_event_listener(const char *host, int port); - - - // Ping server on the specified address and port - // returns true if there is AMIP server running - // returns false if server cannot be reached within the specified timeout (ms) - BOOL WINAPI ac_pingServer(const char *host, int port, int timeout); - - - // Playlist related functions: - // Gets playlist from AMIP and caches it, you should use this function every time playlist changes - // (AC_EVT_PLCHANGE event received) and before using any other playlist related functions. - // The correct usage sequence: - // 1. Register listener for AC_EVT_PLCHANGE and AC_EVT_PLREADY events - // 2. When you receive AC_EVT_PLCHANGE event via callback or upon first usage you must re-index playlist - // using ac_exec("reindexq") function call (AMIP builds playlist cache) - // 3. When playlist is re-indexed, you will receive AC_EVT_PLREADY event, only at this moment you should - // call ac_get_pl() function (this function gets cached playlist from AMIP) - // Return code is the same as for ac_exec and ac_eval functions, see ac_ErrorCode enum - int WINAPI ac_get_pl(); - - // Returns the size of playlist cached by client. You can compare it with the size of real playlist, the - // size of playlist cached by AMIP and do re-index and ac_get_pl to be in sync if necessary - int WINAPI ac_get_plsize(); - - // Returns 1 if title is not NULL and within playlist bounds, 0 otherwise - // Title with the specified zero-based idx is copied to buff. buff must have at least AC_BUFFER_SIZE size - // Make sure to prepare playlist first, see ac_get_pl() function comments, use ac_get_plsize() to determine - // playlist size - int WINAPI ac_get_title(UINT idx, char *buff); - - - // configuring Client - // AMIP port client will try to connect to (default 60333) - void WINAPI ac_setDestPort(int port); - - // AMIP host client will try to connect to (default 127.0.0.1) - void WINAPI ac_setDestHost(const char *host); - - // Client timeout - void WINAPI ac_setTimeout(int ms); - - // Source port the client will listen for AMIP commands on (default 60334) - void WINAPI ac_setSrcPort(int port); - - // Source host interface which will accept AMIP connections (default 127.0.0.1) - void WINAPI ac_setSrcHost(const char *host); - - // get configuration - int WINAPI ac_getSrcPort(); - int WINAPI ac_getDestPort(); - void WINAPI ac_getSrcHost(char *out_host); - void WINAPI ac_getDestHost(char *out_host); - - // Reload the configuration and restart services - void WINAPI ac_rehash(); - - // Returns the major part of API version (for ac 1.2 will return 1) - int WINAPI ac_version_major(); - - // Returns the mainor part of API version (for ac 1.2 will return 2) - int WINAPI ac_version_minor(); - -#ifdef __cplusplus -} -#endif /*__cplusplus*/ - -#endif /*_AC_H_*/ diff --git a/plugins/Variables/src/parse_external.cpp b/plugins/Variables/src/parse_external.cpp index 2cb408c777..152684dc5b 100644 --- a/plugins/Variables/src/parse_external.cpp +++ b/plugins/Variables/src/parse_external.cpp @@ -19,13 +19,6 @@ #include "variables.h" -static int (WINAPI *acEval)(const char *, char *) = NULL; -static int (WINAPI *acFormat)(const char *, char *) = NULL; -static int (WINAPI *acInitClient)(const char *, int, int, int, int) = NULL; -static void (WINAPI *acUninit)() = NULL; - -static unsigned int lastAMIPFailure = -1; - static TCHAR *getFullWinampTitleText() { HWND hwndWinamp = FindWindow(_T("STUDIO"), NULL); @@ -109,114 +102,10 @@ static TCHAR *parseWinampState(ARGUMENTSINFO *ai) return mir_tstrdup(_T("Playing")); } -static unsigned int checkAMIP() -{ - if (lastAMIPFailure == 0) { - log_debugA("AMIP initialized"); - return 0; - } - if (GetTickCount() - lastAMIPFailure < AMIP_TIMEOUT) { - log_debugA("AMIP not initialized, not attempting"); - return -1; - } - if (acInitClient("127.0.0.1", 60333, 1000, 5, 1)) { - lastAMIPFailure = 0; - log_debugA("AMIP now initialized"); - return 0; // success - } - log_debugA("AMIP failed to initialized"); - - /* if this is the first failure after a succesful init, call uninit for a cleanup (maybe it'll help for the next try ;)) */ - if (lastAMIPFailure == 0) - acUninit(); - - lastAMIPFailure = GetTickCount(); - return -1; -} - -static TCHAR *parseAMIPEval(ARGUMENTSINFO *ai) -{ - if (ai->argc != 2) - return NULL; - - char *cmd = mir_t2a(ai->targv[1]); - if (checkAMIP() != 0) { - log_debugA("checkAMIP failed"); - return NULL; - } - - TCHAR *tszRes = NULL; - char szRes[AC_BUFFER_SIZE]; - ZeroMemory(&szRes, sizeof(szRes)); - if (AC_ERR_NOERROR == acEval(cmd, szRes)) - tszRes = mir_a2t(szRes); - else - lastAMIPFailure = GetTickCount(); - - mir_free(cmd); - return tszRes; -} - -static TCHAR *parseAMIPFormat(ARGUMENTSINFO *ai) -{ - if (ai->argc != 2) - return NULL; - - char *cmd = mir_t2a(ai->targv[1]); - if (checkAMIP() != 0) - return NULL; - - TCHAR *tszRes = NULL; - char szRes[AC_BUFFER_SIZE]; - if (AC_ERR_NOERROR == acFormat(cmd, szRes)) - tszRes = mir_a2t(szRes); - else - lastAMIPFailure = GetTickCount(); - - mir_free(cmd); - return tszRes; -} - -static int initAMIP() -{ - HMODULE hModule = LoadLibrary(_T("ac.dll")); - if (hModule == NULL) { - TCHAR path[MAX_PATH]; - GetModuleFileName(NULL, path, MAX_PATH); - TCHAR *cur = _tcsrchr(path, '\\'); - if (cur != NULL) - _tcscpy(cur+1, _T("ac.dll")); - else - _tcscpy(cur, _T("ac.dll")); - hModule = LoadLibrary(path); - } - if (hModule == NULL) - return -1; - - acInitClient = (int (__stdcall *)(const char *,int ,int ,int ,int ))GetProcAddress(hModule, "ac_init_client"); - acEval = (int (__stdcall *)(const char *,char *))GetProcAddress(hModule, "ac_eval"); - acFormat = (int (__stdcall *)(const char *,char *))GetProcAddress(hModule, "ac_format"); - acUninit = (void (__stdcall *)())GetProcAddress(hModule, "ac_uninit"); - return 0; -} - int registerExternalTokens() { registerIntToken(_T(WINAMPSONG), parseWinampSong, TRF_FIELD, LPGEN("External Applications")"\t"LPGEN("retrieves song name of the song currently playing in Winamp")); registerIntToken(_T(WINAMPSTATE), parseWinampState, TRF_FIELD, LPGEN("External Applications")"\t"LPGEN("retrieves current Winamp state (Playing/Paused/Stopped)")); - if (!initAMIP()) { - registerIntToken(_T(AMIPEVAL), parseAMIPEval, TRF_FUNCTION, LPGEN("External Applications")"\t(x)\t"LPGEN("retrieves info from AMIP (x is var_ with any AMIP variable)")); - registerIntToken(_T(AMIPFORMAT), parseAMIPFormat, TRF_FUNCTION|TRF_UNPARSEDARGS, LPGEN("External Applications")"\t(x)\t"LPGEN("retrieves info from AMIP (x is AMIP format string)")); - } - else log_infoA("Variables: ac.dll for AMIP not found"); - return 0; -} - -int deInitExternal() -{ - if (acUninit != NULL) - acUninit(); - return 0; } \ No newline at end of file diff --git a/plugins/Variables/src/parse_external.h b/plugins/Variables/src/parse_external.h index 51e05ac242..463aa73ecc 100644 --- a/plugins/Variables/src/parse_external.h +++ b/plugins/Variables/src/parse_external.h @@ -20,7 +20,3 @@ #define WINAMPSONG "winampsong" #define WINAMPSTATE "winampstate" #define DEF_WINAMPTITLE "Winamp3" - -#define AMIPEVAL "amipvar" -#define AMIPFORMAT "amipformat" -#define AMIP_TIMEOUT 5000 diff --git a/plugins/Variables/src/variables.cpp b/plugins/Variables/src/variables.cpp index deed9115e5..e84c5aa843 100644 --- a/plugins/Variables/src/variables.cpp +++ b/plugins/Variables/src/variables.cpp @@ -566,7 +566,6 @@ int UnloadVarModule() { DestroyServiceFunction(hGetIconService); DestroyCursor(hCurSplitNS); deinitContactModule(); - deInitExternal(); deinitTokenRegister(); unregisterAliasTokens(); unregisterVariablesTokens(); diff --git a/plugins/Variables/src/variables.h b/plugins/Variables/src/variables.h index aa9fd51526..d74a602034 100644 --- a/plugins/Variables/src/variables.h +++ b/plugins/Variables/src/variables.h @@ -46,7 +46,6 @@ #include "..\helpers\gen_helpers.h" -#include "ac\ac.h" #include "pcre\include\pcre.h" #include "resource.h" @@ -160,7 +159,6 @@ void unregisterAliasTokens(); int registerSystemTokens(); // external int registerExternalTokens(); -int deInitExternal(); // miranda int registerMirandaTokens(); // str -- cgit v1.2.3