From 171e81205e357e0d54283a63997ed58ff97d54a9 Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Tue, 24 Jul 2012 11:48:31 +0000 Subject: UserInfoEx, Variables: changed folder structure git-svn-id: http://svn.miranda-ng.org/main/trunk@1160 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Variables/src/trigger_variables.cpp | 232 ++++++++++++++++++++++++++++ 1 file changed, 232 insertions(+) create mode 100644 plugins/Variables/src/trigger_variables.cpp (limited to 'plugins/Variables/src/trigger_variables.cpp') diff --git a/plugins/Variables/src/trigger_variables.cpp b/plugins/Variables/src/trigger_variables.cpp new file mode 100644 index 0000000000..6b90088c4f --- /dev/null +++ b/plugins/Variables/src/trigger_variables.cpp @@ -0,0 +1,232 @@ +/* + Variables Plugin for Miranda-IM (www.miranda-im.org) + Copyright 2003-2006 P. Boon + + This program is mir_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; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +#include "variables.h" +#include "m_trigger.h" +#include "trigger_variables.h" +#include "resource.h" + +extern HINSTANCE hInst; + +static TRG_VAR_CACHE *tvc = NULL; +static int tvcCount = 0; +static unsigned int stringChangeTimerID = 0; + +static int addToCache(DWORD triggerID) +{ + /* triggerID must be in the DB */ + DBVARIANT dbv; + + for (int i=0; i < tvcCount; i++) { + if (tvc[i].triggerID == triggerID) { + mir_free(tvc[i].parsedText); + MoveMemory(&tvc[i], &tvc[tvcCount-1], sizeof(TRG_VAR_CACHE)); + tvcCount -= 1; + } + } + if ( DBGetTriggerSettingTString(triggerID, NULL, MODULENAME, SETTING_TRIGGERTEXT, &dbv)) + return -1; + + tvc = ( TRG_VAR_CACHE* )mir_realloc(tvc, (tvcCount+1)*sizeof(TRG_VAR_CACHE)); + if (tvc == NULL) + return -1; + + tvc[tvcCount].triggerID = triggerID; + tvc[tvcCount].parsedText = variables_parsedup(dbv.ptszVal, NULL, NULL); + // it stays in our own mem space! + if (tvc[tvcCount].parsedText == NULL) + return -1; + + tvcCount += 1; + DBFreeVariant(&dbv); + return 0; +} + +static int removeFromCache(DWORD triggerID) { + + int i; + + for (i=0;i