diff options
Diffstat (limited to 'plugins/QuickReplies/src/events.cpp')
-rw-r--r-- | plugins/QuickReplies/src/events.cpp | 68 |
1 files changed, 33 insertions, 35 deletions
diff --git a/plugins/QuickReplies/src/events.cpp b/plugins/QuickReplies/src/events.cpp index f570d52306..b3dd97fdc2 100644 --- a/plugins/QuickReplies/src/events.cpp +++ b/plugins/QuickReplies/src/events.cpp @@ -42,18 +42,18 @@ int OnModulesLoaded(WPARAM wParam, LPARAM lParam) iNumber = 0;
hQuickRepliesService = CreateServiceFunction(MS_QUICKREPLIES_SERVICE, QuickRepliesService);
}
- else iNumber = db_get_b(NULL, MODULE_NAME, "InstancesCount", 0);
- db_set_b(NULL, MODULE_NAME, "InstancesCount", iNumber + 1);
+ else iNumber = db_get_b(NULL, MODULE, "InstancesCount", 0);
+ db_set_b(NULL, MODULE, "InstancesCount", iNumber + 1);
- hOnOptInitialized = HookEvent(ME_OPT_INITIALISE, OnOptInitialized);
- hOnButtonPressed = HookEvent(ME_MSG_BUTTONPRESSED, OnButtonPressed);
+ hOnOptInitialized = HookEvent(ME_OPT_INITIALISE, OnOptInitialized);
+ hOnButtonPressed = HookEvent(ME_MSG_BUTTONPRESSED, OnButtonPressed);
if ( ServiceExists(MS_BB_ADDBUTTON)) {
Icon_Register(hInstance, "TabSRMM/Quick Replies", &icon, 1);
char buttonNameTranslated[32], buttonName[32];
- mir_snprintf(buttonNameTranslated, SIZEOF(buttonNameTranslated), "%s %x",Translate("Button"), iNumber + 1);
- mir_snprintf(buttonName, SIZEOF(buttonName), MODULE_NAME" %x", iNumber + 1);
+ mir_snprintf(buttonNameTranslated, SIZEOF(buttonNameTranslated), "%s %x", Translate("Button"), iNumber + 1);
+ mir_snprintf(buttonName, SIZEOF(buttonName), MODULE" %x", iNumber + 1);
BBButton bbd = {0};
bbd.cbSize = sizeof(BBButton);
@@ -77,24 +77,24 @@ int OnButtonPressed(WPARAM wParam, LPARAM lParam) int count = 0;
HMENU hMenu = NULL;
char buttonName[32];
- tString replies = _T("");
- vector<tString> replyList;
+ CMString replies;
+ LIST<wchar_t> replyList(1);
CustomButtonClickData *cbcd = (CustomButtonClickData *)lParam;
- mir_snprintf(buttonName, SIZEOF(buttonName), MODULE_NAME" %x", iNumber + 1);
+ mir_snprintf(buttonName, SIZEOF(buttonName), MODULE" %x", iNumber + 1);
if (strcmp(cbcd->pszModule, buttonName))
return 0;
- if (cbcd->dwButtonId != iNumber)
+ if (cbcd->dwButtonId != iNumber)
return 1;
- mir_snprintf(key, 64, "RepliesCount_%x", iNumber);
- count = db_get_w(NULL, MODULE_NAME, key, 0);
-
- {
+ mir_snprintf(key, SIZEOF(key), "RepliesCount_%x", iNumber);
+ count = db_get_w(NULL, MODULE, key, 0);
+
+ {
if (count == 0 || cbcd->flags & BBCF_RIGHTBUTTON)
{
- mir_snprintf(buttonName, SIZEOF(buttonName), "Button %x", iNumber + 1);
+ mir_snprintf(buttonName, SIZEOF(buttonName), "%s %x", Translate("Button"), iNumber + 1);
OPENOPTIONSDIALOG ood = {0};
ood.cbSize = sizeof(ood);
@@ -107,48 +107,46 @@ int OnButtonPressed(WPARAM wParam, LPARAM lParam) hMenu = CreatePopupMenu();
- DBVARIANT dbv = {0};
-
for (int i = 0; i < count; i++)
{
- mir_snprintf(key, 64, "Reply_%x_%x", iNumber, i);
- db_get_ts(NULL, MODULE_NAME, key, &dbv);
+ mir_snprintf(key, SIZEOF(key), "Reply_%x_%x", iNumber, i);
+ wchar_t *value = db_get_wsa(NULL, MODULE, key);
- if (dbv.ptszVal == NULL)
- replyList.push_back(_T(""));
+ if (!value)
+ replyList.insert(mir_wstrdup(_T("")));
else
- replyList.push_back((TCHAR*)variables_parsedup(dbv.ptszVal, 0, wParam));
+ replyList.insert(variables_parsedup(value, 0, wParam));
- if (_tcscmp(dbv.ptszVal, _T("---")))
- AppendMenu((HMENU)hMenu, MF_STRING, i + 1, replyList[i].c_str());
+ if (!lstrcmp(value, _T("---")))
+ AppendMenu((HMENU)hMenu, MF_SEPARATOR, i + 1, NULL);
else
- AppendMenu((HMENU)hMenu, MF_SEPARATOR, i + 1, NULL);
- }
+ AppendMenu((HMENU)hMenu, MF_STRING, i + 1, replyList[i]);
- db_free(&dbv);
+ mir_free(value);
+ }
}
{
int index = TrackPopupMenu(hMenu, TPM_RETURNCMD, cbcd->pt.x, cbcd->pt.y, 0, cbcd->hwndFrom, NULL);
if (index > 0)
{
- if (_tcscmp(replyList.at(index - 1).c_str(), _T("")))
+ if (lstrcmp(replyList[index - 1], _T("")))
{
HWND hEdit = GetDlgItem(cbcd->hwndFrom, IDC_MESSAGE);
if (!hEdit) hEdit = GetDlgItem(cbcd->hwndFrom, IDC_CHATMESSAGE);
- SendMessage(hEdit, EM_REPLACESEL, TRUE, (LPARAM)replyList.at(index - 1).c_str());
+ SendMessage(hEdit, EM_REPLACESEL, TRUE, (LPARAM)replyList[index - 1]);
- mir_snprintf(key, 64, "ImmediatelySend_%x", iNumber);
- if ((BYTE)db_get_b(NULL, MODULE_NAME, key, 1) || cbcd->flags & BBCF_CONTROLPRESSED)
+ mir_snprintf(key, SIZEOF(key), "ImmediatelySend_%x", iNumber);
+ if ((BYTE)db_get_b(NULL, MODULE, key, 1) || cbcd->flags & BBCF_CONTROLPRESSED)
SendMessage(cbcd->hwndFrom, WM_COMMAND, IDOK, 0);
}
}
}
- for (std::vector<tString>::reverse_iterator item = replyList.rbegin(); item != replyList.rend(); ++item)
- ((tString)*item).clear();
- replyList.clear();
+ for (int i = 0; i < replyList.getCount(); i++)
+ mir_free(replyList[i]);
+ replyList.destroy();
return 1;
}
@@ -158,7 +156,7 @@ int OnPreShutdown(WPARAM wParam, LPARAM lParam) if (ServiceExists(MS_BB_REMOVEBUTTON))
{
char buttonName[32];
- mir_snprintf(buttonName, SIZEOF(buttonName), MODULE_NAME" %x", iNumber + 1);
+ mir_snprintf(buttonName, SIZEOF(buttonName), MODULE" %x", iNumber + 1);
BBButton bbd = {0};
bbd.cbSize = sizeof(BBButton);
|