From e50eec541098fccea490e449898a9a6bc6a687fa Mon Sep 17 00:00:00 2001 From: mataes2007 Date: Sun, 20 Nov 2011 17:43:06 +0000 Subject: added Flags git-svn-id: http://miranda-plugins.googlecode.com/svn/trunk@190 e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb --- CountryFlags/utils.c | 162 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 CountryFlags/utils.c (limited to 'CountryFlags/utils.c') diff --git a/CountryFlags/utils.c b/CountryFlags/utils.c new file mode 100644 index 0000000..d71b0ac --- /dev/null +++ b/CountryFlags/utils.c @@ -0,0 +1,162 @@ +/* +Miranda IM Country Flags Plugin +Copyright (C) 2006-1007 H. Herkenrath + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (Flags-License.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "flags.h" + +/************************* Buffered Functions *********************/ + +struct BufferedCallData { + DWORD startTick; + UINT uElapse; + BUFFEREDPROC pfnBuffProc; + LPARAM lParam; + #ifdef _DEBUG + const char *pszProcName; + #endif +}; + +static UINT idBufferedTimer; +static struct BufferedCallData *callList; +static int nCallListCount; + +// always gets called in main message loop +static void CALLBACK BufferedProcTimer(HWND hwnd,UINT msg,UINT idTimer,DWORD currentTick) +{ + int i; + struct BufferedCallData *buf; + UINT uElapsed,uElapseNext=USER_TIMER_MAXIMUM; + BUFFEREDPROC pfnBuffProc; + LPARAM lParam; + #ifdef _DEBUG + char szDbgLine[256]; + const char *pszProcName; + #endif + UNREFERENCED_PARAMETER(msg); + + for(i=0;i=callList[i].uElapse) { + /* call elapsed proc */ + pfnBuffProc=callList[i].pfnBuffProc; + lParam=callList[i].lParam; + #ifdef _DEBUG + pszProcName=callList[i].pszProcName; + #endif + /* resize storage array */ + if((i+1)startTick=GetTickCount(); + data->uElapse=uElapse; + data->lParam=lParam; + data->pfnBuffProc=pfnBuffProc; + #ifdef _DEBUG + { char szDbgLine[256]; + data->pszProcName=pszProcName; + mir_snprintf(szDbgLine,sizeof(szDbgLine),"buffered queue: %s(0x%X)\n",pszProcName,lParam); /* all ascii */ + OutputDebugStringA(szDbgLine); + if(!idBufferedTimer) { + mir_snprintf(szDbgLine,sizeof(szDbgLine),"next buffered timeout: %ums\n",uElapse); /* all ascii */ + OutputDebugStringA(szDbgLine); + } + } + #endif + /* set next timer */ + if(idBufferedTimer) uElapse=USER_TIMER_MINIMUM; /* will get recalculated */ + idBufferedTimer=SetTimer(NULL,idBufferedTimer,uElapse,BufferedProcTimer); +} + +// assumes to be called in context of main thread +void PrepareBufferedFunctions(void) +{ + idBufferedTimer=0; + nCallListCount=0; + callList=NULL; +} + +// assumes to be called in context of main thread +void KillBufferedFunctions(void) +{ + if(idBufferedTimer) KillTimer(NULL,idBufferedTimer); + nCallListCount=0; + mir_free(callList); /* does NULL check */ +} -- cgit v1.2.3