summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/Clist_modern/modern_cachefuncs.cpp198
-rw-r--r--plugins/Nudge/main.cpp24
-rw-r--r--plugins/StatusPlugins/commonstatus.cpp6
-rw-r--r--plugins/StatusPlugins/confirmdialog.cpp2
-rw-r--r--plugins/TipperYM/subst.cpp13
-rw-r--r--plugins/Variables/trigger_variables.cpp196
6 files changed, 192 insertions, 247 deletions
diff --git a/plugins/Clist_modern/modern_cachefuncs.cpp b/plugins/Clist_modern/modern_cachefuncs.cpp
index 6eb0338acb..9beb1da22d 100644
--- a/plugins/Clist_modern/modern_cachefuncs.cpp
+++ b/plugins/Clist_modern/modern_cachefuncs.cpp
@@ -454,124 +454,104 @@ int Cache_GetLineText(PDNCE pdnce, int type, LPTSTR text, int text_size, TCHAR *
BOOL show_status_if_no_away, BOOL show_listening_if_no_away, BOOL use_name_and_message_for_xstatus,
BOOL pdnce_time_show_only_if_different)
{
- text[0] = '\0';
- switch(type)
- {
- case TEXT_STATUS:
- {
- if (GetStatusName(text, text_size, pdnce, xstatus_has_priority) == -1 && use_name_and_message_for_xstatus)
- {
- DBVARIANT dbv={0};
+ text[0] = '\0';
+ switch(type) {
+ case TEXT_STATUS:
+ if (GetStatusName(text, text_size, pdnce, xstatus_has_priority) == -1 && use_name_and_message_for_xstatus) {
+ DBVARIANT dbv={0};
+
+ // Try to get XStatusMsg
+ if (!DBGetContactSettingTString(pdnce->m_cache_hContact, pdnce->m_cache_cszProto, "XStatusMsg", &dbv)) {
+ if (dbv.ptszVal != NULL && dbv.ptszVal[0] != 0) {
+ TCHAR *tmp = mir_tstrdup(text);
+ mir_sntprintf(text, text_size, TEXT("%s: %s"), tmp, dbv.pszVal);
+ mir_free_and_nill(tmp);
+ CopySkipUnprintableChars(text, text, text_size-1);
+ }
+ db_free(&dbv);
+ }
+ }
- // Try to get XStatusMsg
- if (!DBGetContactSettingTString(pdnce->m_cache_hContact, pdnce->m_cache_cszProto, "XStatusMsg", &dbv))
- {
- if (dbv.ptszVal != NULL && dbv.ptszVal[0] != 0)
- {
- TCHAR *tmp = mir_tstrdup(text);
- mir_sntprintf(text, text_size, TEXT("%s: %s"), tmp, dbv.pszVal);
- mir_free_and_nill(tmp);
- CopySkipUnprintableChars(text, text, text_size-1);
- }
- db_free(&dbv);
- }
- }
+ return TEXT_STATUS;
- return TEXT_STATUS;
- }
- case TEXT_NICKNAME:
- {
- if (pdnce->m_cache_hContact && pdnce->m_cache_cszProto)
- {
- DBVARIANT dbv={0};
- if (!DBGetContactSettingTString(pdnce->m_cache_hContact, pdnce->m_cache_cszProto, "Nick", &dbv))
- {
- lstrcpyn(text, dbv.ptszVal, text_size);
- db_free(&dbv);
- CopySkipUnprintableChars(text, text, text_size-1);
- }
- }
+ case TEXT_NICKNAME:
+ if (pdnce->m_cache_hContact && pdnce->m_cache_cszProto) {
+ DBVARIANT dbv={0};
+ if (!DBGetContactSettingTString(pdnce->m_cache_hContact, pdnce->m_cache_cszProto, "Nick", &dbv)) {
+ lstrcpyn(text, dbv.ptszVal, text_size);
+ db_free(&dbv);
+ CopySkipUnprintableChars(text, text, text_size-1);
+ }
+ }
- return TEXT_NICKNAME;
- }
- case TEXT_STATUS_MESSAGE:
- {
- if (GetStatusMessage(text, text_size, pdnce, xstatus_has_priority) == -1 && use_name_and_message_for_xstatus)
- {
- DBVARIANT dbv={0};
+ return TEXT_NICKNAME;
- // Try to get XStatusName
- if (!DBGetContactSettingTString(pdnce->m_cache_hContact, pdnce->m_cache_cszProto, "XStatusName", &dbv))
- {
- if (dbv.pszVal != NULL && dbv.pszVal[0] != 0)
- {
- TCHAR *tmp = mir_tstrdup(text);
-
- mir_sntprintf(text, text_size, TEXT("%s: %s"), dbv.pszVal, tmp);
- mir_free_and_nill(tmp);
- }
- CopySkipUnprintableChars(text, text, text_size-1);
- db_free(&dbv);
- }
- }
- else if (use_name_and_message_for_xstatus && xstatus_has_priority)
- {
- DBVARIANT dbv={0};
- // Try to get XStatusName
- if (!DBGetContactSettingTString(pdnce->m_cache_hContact, pdnce->m_cache_cszProto, "XStatusName", &dbv))
- {
- if (dbv.pszVal != NULL && dbv.pszVal[0] != 0)
- mir_sntprintf(text, text_size, TEXT("%s"), dbv.pszVal);
- CopySkipUnprintableChars(text, text, text_size-1);
- db_free(&dbv);
- }
- }
+ case TEXT_STATUS_MESSAGE:
+ if (GetStatusMessage(text, text_size, pdnce, xstatus_has_priority) == -1 && use_name_and_message_for_xstatus) {
+ DBVARIANT dbv={0};
- if (text[0] == '\0')
- {
- if (show_listening_if_no_away)
- {
- Cache_GetLineText(pdnce, TEXT_LISTENING_TO, text, text_size, variable_text, xstatus_has_priority, 0, 0, use_name_and_message_for_xstatus, pdnce_time_show_only_if_different);
- if (text[0] != '\0')
- return TEXT_LISTENING_TO;
- }
+ // Try to get XStatusName
+ if (!DBGetContactSettingTString(pdnce->m_cache_hContact, pdnce->m_cache_cszProto, "XStatusName", &dbv)) {
+ if (dbv.pszVal != NULL && dbv.pszVal[0] != 0) {
+ TCHAR *tmp = mir_tstrdup(text);
- if (show_status_if_no_away)
- {
- //re-request status if no away
- return Cache_GetLineText(pdnce, TEXT_STATUS, text, text_size, variable_text, xstatus_has_priority, 0, 0, use_name_and_message_for_xstatus, pdnce_time_show_only_if_different);
- }
- }
- return TEXT_STATUS_MESSAGE;
- }
- case TEXT_LISTENING_TO:
- {
- GetListeningTo(text, text_size, pdnce);
- return TEXT_LISTENING_TO;
- }
- case TEXT_TEXT:
- {
- TCHAR *tmp = variables_parsedup(variable_text, pdnce->m_cache_tcsName, pdnce->m_cache_hContact);
- lstrcpyn(text, tmp, text_size);
- if (tmp) free(tmp);
- CopySkipUnprintableChars(text, text, text_size-1);
+ mir_sntprintf(text, text_size, TEXT("%s: %s"), dbv.pszVal, tmp);
+ mir_free_and_nill(tmp);
+ }
+ CopySkipUnprintableChars(text, text, text_size-1);
+ db_free(&dbv);
+ }
+ }
+ else if (use_name_and_message_for_xstatus && xstatus_has_priority) {
+ DBVARIANT dbv={0};
+ // Try to get XStatusName
+ if (!DBGetContactSettingTString(pdnce->m_cache_hContact, pdnce->m_cache_cszProto, "XStatusName", &dbv)) {
+ if (dbv.pszVal != NULL && dbv.pszVal[0] != 0)
+ mir_sntprintf(text, text_size, TEXT("%s"), dbv.pszVal);
+ CopySkipUnprintableChars(text, text, text_size-1);
+ db_free(&dbv);
+ }
+ }
- return TEXT_TEXT;
- }
- case TEXT_CONTACT_TIME:
- {
- if (pdnce->hTimeZone)
- {
- // Get pdnce time
- text[0] = 0;
- tmi.printDateTime( pdnce->hTimeZone, _T("t"), text, text_size, 0);
- }
+ if (text[0] == '\0') {
+ if (show_listening_if_no_away) {
+ Cache_GetLineText(pdnce, TEXT_LISTENING_TO, text, text_size, variable_text, xstatus_has_priority, 0, 0, use_name_and_message_for_xstatus, pdnce_time_show_only_if_different);
+ if (text[0] != '\0')
+ return TEXT_LISTENING_TO;
+ }
- return TEXT_CONTACT_TIME;
- }
- }
+ if (show_status_if_no_away) {
+ //re-request status if no away
+ return Cache_GetLineText(pdnce, TEXT_STATUS, text, text_size, variable_text, xstatus_has_priority, 0, 0, use_name_and_message_for_xstatus, pdnce_time_show_only_if_different);
+ }
+ }
+ return TEXT_STATUS_MESSAGE;
+
+ case TEXT_LISTENING_TO:
+ GetListeningTo(text, text_size, pdnce);
+ return TEXT_LISTENING_TO;
+
+ case TEXT_TEXT:
+ {
+ TCHAR *tmp = variables_parsedup(variable_text, pdnce->m_cache_tcsName, pdnce->m_cache_hContact);
+ lstrcpyn(text, tmp, text_size);
+ if (tmp)
+ mir_free(tmp);
+ CopySkipUnprintableChars(text, text, text_size-1);
+ }
+ return TEXT_TEXT;
+
+ case TEXT_CONTACT_TIME:
+ if (pdnce->hTimeZone) {
+ // Get pdnce time
+ text[0] = 0;
+ tmi.printDateTime( pdnce->hTimeZone, _T("t"), text, text_size, 0);
+ }
+
+ return TEXT_CONTACT_TIME;
+ }
- return TEXT_EMPTY;
+ return TEXT_EMPTY;
}
/*
diff --git a/plugins/Nudge/main.cpp b/plugins/Nudge/main.cpp
index a66a7b0d5c..1bb2e5b876 100644
--- a/plugins/Nudge/main.cpp
+++ b/plugins/Nudge/main.cpp
@@ -285,33 +285,17 @@ int TriggerActionRecv( DWORD actionID, REPORTINFO *ri)
ShakeClist(NULL,NULL);
if(bshakeChat && (hContact != NULL))
ShakeChat((WPARAM)hContact,NULL);
-
- /* // Actually show the message box
- DBVARIANT dbv;
- TCHAR *tszMsg;
-
- // Retrieve the correct settings for this action ID
- if (!DBGetActionSettingTString(actionID, NULL, MODULENAME, SETTING_TEXT, &dbv)) {
- // Parse by Variables, if available (notice extratext and subject are given).
- tszMsg = variables_parsedup(dbv.ptszVal, ((ri->td!=NULL)&&(ri->td->dFlags&DF_TEXT))?ri->td->tszText:NULL, ((ri->td!=NULL)&&(ri->td->dFlags&DF_CONTACT))?ri->td->hContact:NULL);
- if (tszMsg != NULL) {
- // Show the message box
- MessageBox(NULL, tszMsg, TranslateT("ExampleAction"), MB_OK);
- free(tszMsg);
- }
- DBFreeVariant(&dbv);
- }
- */
}
- if (ri->flags&ACT_CLEANUP) { // request to delete all associated settings
+
+ if (ri->flags&ACT_CLEANUP) // request to delete all associated settings
RemoveAllActionSettings(actionID, "Nudge");
- }
+
return FALSE;
}
int TriggerActionSend( DWORD actionID, REPORTINFO *ri)
{
- if (ri->flags&ACT_PERFORM) {
+ if (ri->flags & ACT_PERFORM) {
HANDLE hContact = ((ri->td!=NULL)&&(ri->td->dFlags&DF_CONTACT))?ri->td->hContact:NULL;
if(hContact != NULL)
NudgeSend((WPARAM)hContact,NULL);
diff --git a/plugins/StatusPlugins/commonstatus.cpp b/plugins/StatusPlugins/commonstatus.cpp
index d1e214b307..c2cc820e9b 100644
--- a/plugins/StatusPlugins/commonstatus.cpp
+++ b/plugins/StatusPlugins/commonstatus.cpp
@@ -335,11 +335,9 @@ static void SetStatusMsg(PROTOCOLSETTINGEX *ps, int newstatus)
TCHAR* szFormattedMsg = variables_parsedup(tszMsg, ps->tszAccName, NULL);
if (szFormattedMsg != NULL) {
- mir_free( tszMsg );
- tszMsg = mir_tstrdup( szFormattedMsg );
- free( szFormattedMsg );
+ mir_free(tszMsg);
+ tszMsg = szFormattedMsg;
}
-
}
log_debugA("CommonStatus sets status message for %s directly", ps->szName);
if ( CALLSERVICE_NOTFOUND == CallProtoService(ps->szName, PS_SETAWAYMSGT, newstatus, (LPARAM)tszMsg )) {
diff --git a/plugins/StatusPlugins/confirmdialog.cpp b/plugins/StatusPlugins/confirmdialog.cpp
index f1a2dbf94b..2d93e181fc 100644
--- a/plugins/StatusPlugins/confirmdialog.cpp
+++ b/plugins/StatusPlugins/confirmdialog.cpp
@@ -146,7 +146,7 @@ static int SetStatusList(HWND hwndDlg)
if ( msg != NULL ) {
TCHAR* fMsg = variables_parsedup( msg, confirmSettings[i].tszAccName, NULL );
ListView_SetItemText(hList, lvItem.iItem, 2, fMsg);
- free(fMsg);
+ mir_free(fMsg);
mir_free(msg);
}
else ListView_SetItemText(hList, lvItem.iItem, 2, TranslateT("<n/a>"));
diff --git a/plugins/TipperYM/subst.cpp b/plugins/TipperYM/subst.cpp
index 531af67200..1d8c8837d9 100644
--- a/plugins/TipperYM/subst.cpp
+++ b/plugins/TipperYM/subst.cpp
@@ -568,8 +568,7 @@ bool GetRawSubstText(HANDLE hContact, char *szRawSpec, TCHAR *buff, int bufflen)
bool ApplySubst(HANDLE hContact, const TCHAR *swzSource, bool parseTipperVarsFirst, TCHAR *swzDest, int iDestLen)
{
// hack - allow empty strings before passing to variables (note - zero length strings return false after this)
- if (swzDest && swzSource && _tcslen(swzSource) == 0)
- {
+ if (swzDest && swzSource && _tcslen(swzSource) == 0) {
swzDest[0] = 0;
return true;
}
@@ -579,7 +578,7 @@ bool ApplySubst(HANDLE hContact, const TCHAR *swzSource, bool parseTipperVarsFir
if (parseTipperVarsFirst == false)
swzVarSrc = variables_parsedup((TCHAR *)swzSource, 0, hContact);
else
- swzVarSrc = _tcsdup(swzSource);
+ swzVarSrc = mir_tstrdup(swzSource);
size_t iSourceLen = _tcslen(swzVarSrc);
size_t si = 0, di = 0, v = 0;
@@ -779,14 +778,14 @@ bool ApplySubst(HANDLE hContact, const TCHAR *swzSource, bool parseTipperVarsFir
di++;
}
- free(swzVarSrc);
+ mir_free(swzVarSrc);
swzDest[di] = 0;
if (parseTipperVarsFirst)
{
swzVarSrc = variables_parsedup((TCHAR *)swzDest, 0, hContact);
_tcscpy(swzDest, swzVarSrc);
- free(swzVarSrc);
+ mir_free(swzVarSrc);
}
@@ -800,13 +799,13 @@ bool ApplySubst(HANDLE hContact, const TCHAR *swzSource, bool parseTipperVarsFir
return false;
empty:
- free(swzVarSrc);
+ mir_free(swzVarSrc);
return false;
error:
swzDest[0] = _T('*');
swzDest[1] = 0;
- free(swzVarSrc);
+ mir_free(swzVarSrc);
return true;
}
diff --git a/plugins/Variables/trigger_variables.cpp b/plugins/Variables/trigger_variables.cpp
index c7d8771fc0..6b90088c4f 100644
--- a/plugins/Variables/trigger_variables.cpp
+++ b/plugins/Variables/trigger_variables.cpp
@@ -27,37 +27,33 @@ static TRG_VAR_CACHE *tvc = NULL;
static int tvcCount = 0;
static unsigned int stringChangeTimerID = 0;
-static int addToCache(DWORD triggerID) {
-
+static int addToCache(DWORD triggerID)
+{
/* triggerID must be in the DB */
DBVARIANT dbv;
- int i;
- for (i=0;i<tvcCount;i++) {
+ 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)) {
- 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);
- }
- else {
+ 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;
}
@@ -76,144 +72,131 @@ static int removeFromCache(DWORD triggerID) {
return 0;
}
-static VOID CALLBACK checkStringsTimer(HWND hwnd,UINT message,UINT_PTR idEvent,DWORD dwTime) {
-
- int i;
- TCHAR *parsedText;
- REPORTINFO ri;
- TRIGGERDATA td;
- DBVARIANT dbv;
- DWORD triggerID;
-
- triggerID = 0;
+static VOID CALLBACK checkStringsTimer(HWND hwnd,UINT message,UINT_PTR idEvent,DWORD dwTime)
+{
+ DWORD triggerID = 0;
do {
triggerID = (DWORD)CallService(MS_TRIGGER_FINDNEXTTRIGGERID, triggerID, (LPARAM)TRIGGERNAME);
if (triggerID == 0) {
continue;
}
- for (i=0;i<tvcCount;i++) {
- if (triggerID != tvc[i].triggerID) {
+ for (int i=0; i < tvcCount; i++) {
+ if (triggerID != tvc[i].triggerID)
continue;
- }
+
+ DBVARIANT dbv;
if (!DBGetTriggerSettingTString(tvc[i].triggerID, NULL, MODULENAME, SETTING_TRIGGERTEXT, &dbv)) {
- parsedText = variables_parsedup(dbv.ptszVal, NULL, NULL);
- if (parsedText == NULL) {
+ TCHAR *parsedText = variables_parsedup(dbv.ptszVal, NULL, NULL);
+ if (parsedText == NULL)
continue;
- }
+
if (!_tcscmp(tvc[i].parsedText, parsedText)) {
mir_free(parsedText);
continue;
}
- else {
- ZeroMemory(&td, sizeof(td));
- td.cbSize = sizeof(td);
- td.dFlags = DF_TEXT;
- td.tszText = parsedText;
+
+ TRIGGERDATA td = { 0 };
+ td.cbSize = sizeof(td);
+ td.dFlags = DF_TEXT;
+ td.tszText = parsedText;
- ZeroMemory(&ri, sizeof(REPORTINFO));
- ri.cbSize = sizeof(REPORTINFO);
- ri.triggerID = tvc[i].triggerID;
- ri.pszName = TRIGGERNAME;
- ri.flags = TRG_PERFORM;
- ri.td = &td;
+ REPORTINFO ri = { 0 };
+ ri.cbSize = sizeof(REPORTINFO);
+ ri.triggerID = tvc[i].triggerID;
+ ri.pszName = TRIGGERNAME;
+ ri.flags = TRG_PERFORM;
+ ri.td = &td;
- CallService(MS_TRIGGER_REPORTEVENT, 0, (LPARAM)&ri);
- mir_free(tvc[i].parsedText);
- tvc[i].parsedText = parsedText;
- }
+ CallService(MS_TRIGGER_REPORTEVENT, 0, (LPARAM)&ri);
+ mir_free(tvc[i].parsedText);
+ tvc[i].parsedText = parsedText;
DBFreeVariant(&dbv);
}
}
- } while (triggerID != 0);
+ }
+ while (triggerID != 0);
}
INT_PTR CALLBACK DlgProcOptsStringChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {
- case WM_INITDIALOG: {
- DBVARIANT dbv;
- DWORD triggerID;
-
+ case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
- triggerID = (DWORD)lParam;
- if (!DBGetTriggerSetting(triggerID, NULL, MODULENAME, SETTING_TRIGGERTEXT, &dbv)) {
- SetDlgItemTextA(hwndDlg, IDC_FORMATTEXT, dbv.pszVal);
- DBFreeVariant(&dbv);
+ {
+ DBVARIANT dbv;
+ DWORD triggerID;
+
+ triggerID = (DWORD)lParam;
+ if (!DBGetTriggerSetting(triggerID, NULL, MODULENAME, SETTING_TRIGGERTEXT, &dbv)) {
+ SetDlgItemTextA(hwndDlg, IDC_FORMATTEXT, dbv.pszVal);
+ DBFreeVariant(&dbv);
+ }
+ variables_skin_helpbutton(hwndDlg, IDC_SHOWHELP);
}
- variables_skin_helpbutton(hwndDlg, IDC_SHOWHELP);
break;
- }
case WM_COMMAND:
switch (LOWORD(wParam)) {
- case IDC_SHOWHELP: {
- variables_showhelp(hwndDlg, IDC_FORMATTEXT, VHF_FULLDLG|VHF_SETLASTSUBJECT, NULL, NULL);
- break;
- }
+ case IDC_SHOWHELP:
+ variables_showhelp(hwndDlg, IDC_FORMATTEXT, VHF_FULLDLG|VHF_SETLASTSUBJECT, NULL, NULL);
+ break;
}
break;
- case TM_ADDTRIGGER: {
+ case TM_ADDTRIGGER:
// wParam = trigger ID
// lParam = (TRIGGERREGISTER *)
- DWORD triggerID;
- TCHAR *tszFormatText;
-
- triggerID = (DWORD)wParam;
- tszFormatText = Hlp_GetDlgItemText(hwndDlg, IDC_FORMATTEXT);
- if (tszFormatText != NULL) {
- DBWriteTriggerSettingTString(triggerID, NULL, MODULENAME, SETTING_TRIGGERTEXT, tszFormatText);
- mir_free(tszFormatText);
+ {
+ DWORD triggerID = (DWORD)wParam;
+ TCHAR *tszFormatText = Hlp_GetDlgItemText(hwndDlg, IDC_FORMATTEXT);
+ if (tszFormatText != NULL) {
+ DBWriteTriggerSettingTString(triggerID, NULL, MODULENAME, SETTING_TRIGGERTEXT, tszFormatText);
+ mir_free(tszFormatText);
+ }
+ addToCache(triggerID);
}
- addToCache(triggerID);
break;
- }
- case TM_DELTRIGGER: {
+ case TM_DELTRIGGER:
// wParam = triggerID
// lParam = (TRIGGEREGISTER *) may be 0
- DWORD triggerID;
- REMOVETRIGGERSETTINGS rts;
-
- triggerID = (DWORD)wParam;
- removeFromCache(triggerID);
- rts.cbSize = sizeof(REMOVETRIGGERSETTINGS);
- rts.prefix = PREFIX_TRIGGERID;
- rts.id = triggerID;
- rts.hContact = NULL;
- rts.szModule = MODULENAME;
- CallService(MS_TRIGGER_REMOVESETTINGS, 0, (LPARAM)&rts);
+ {
+ REMOVETRIGGERSETTINGS rts;
+
+ DWORD triggerID = (DWORD)wParam;
+ removeFromCache(triggerID);
+ rts.cbSize = sizeof(REMOVETRIGGERSETTINGS);
+ rts.prefix = PREFIX_TRIGGERID;
+ rts.id = triggerID;
+ rts.hContact = NULL;
+ rts.szModule = MODULENAME;
+ CallService(MS_TRIGGER_REMOVESETTINGS, 0, (LPARAM)&rts);
+ }
break;
- }
}
- return FALSE;
+ return FALSE;
}
-int initTriggerModule() {
-
- CONDITIONREGISTER cr;
- TRIGGERREGISTER tr;
- ACTIONREGISTER ar;
- int res;
- DWORD triggerID;
-
+int initTriggerModule()
+{
log_debugA("Variables: initTriggerModule");
if (!ServiceExists(MS_TRIGGER_REGISTERTRIGGER)) {
log_debugA("Variables: %s does not exist", MS_TRIGGER_REGISTERTRIGGER);
return -1;
}
- ZeroMemory(&tr, sizeof(tr));
+
+ TRIGGERREGISTER tr = { 0 };
tr.cbSize = sizeof(tr);
tr.pszName = TRIGGERNAME;
tr.hInstance = hInst;
tr.pfnDlgProc = DlgProcOptsStringChange;
tr.pszTemplate = MAKEINTRESOURCEA(IDD_TRG_STRINGCHANGE);
tr.dFlags = DF_TEXT|DF_TCHAR;
- res = CallService(MS_TRIGGER_REGISTERTRIGGER, 0, (LPARAM)&tr);
+ int res = CallService(MS_TRIGGER_REGISTERTRIGGER, 0, (LPARAM)&tr);
log_debugA("Variables: %s registered (%d)", TRIGGERNAME, res);
- ZeroMemory(&ar, sizeof(ACTIONREGISTER));
+ ACTIONREGISTER ar = { 0 };
ar.cbSize = sizeof(ACTIONREGISTER);
ar.pszName = "Variables: Parse string";
ar.hInstance = hInst;
@@ -223,7 +206,7 @@ int initTriggerModule() {
ar.flags = ARF_FUNCTION|ARF_TCHAR;
CallService(MS_TRIGGER_REGISTERACTION, 0, (LPARAM)&ar);
- ZeroMemory(&cr, sizeof(CONDITIONREGISTER));
+ CONDITIONREGISTER cr = { 0 };
cr.cbSize = sizeof(CONDITIONREGISTER);
cr.pszName = "Variables: Condition";
cr.hInstance = hInst;
@@ -234,15 +217,16 @@ int initTriggerModule() {
CallService(MS_TRIGGER_REGISTERCONDITION, 0, (LPARAM)&cr);
// fill cache
- triggerID = 0;
+ DWORD triggerID = 0;
do {
triggerID = (DWORD)CallService(MS_TRIGGER_FINDNEXTTRIGGERID, triggerID, (LPARAM)TRIGGERNAME);
if (triggerID == 0) {
continue;
}
addToCache(triggerID);
- } while (triggerID != 0);
+ }
+ while (triggerID != 0);
+
stringChangeTimerID = SetTimer(NULL, 0, CHECKSTRINGDELAY, checkStringsTimer);
-
return res;
}