summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-09-07 19:27:31 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-09-07 19:27:31 +0000
commit1a8fbb98e30b55aee908e3ad2382622a0688c635 (patch)
tree870a5861345c4f0115304655861c1d0137d8b3ef /plugins
parentd2a2a30b0dfd94fa50bf269a17c6486a33114877 (diff)
direct access to CListGroups restricted
git-svn-id: http://svn.miranda-ng.org/main/trunk@6009 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/AddContactPlus/src/addcontact.cpp385
-rw-r--r--plugins/AddContactPlus/src/addcontactplus.h1
-rw-r--r--plugins/AddContactPlus/src/main.cpp2
-rw-r--r--plugins/Clist_modern/src/modern_viewmodebar.cpp16
-rw-r--r--plugins/Clist_nicer/src/viewmodes.cpp28
-rw-r--r--plugins/ContactsPlus/src/contacts.h1
-rw-r--r--plugins/ContactsPlus/src/main.cpp3
-rw-r--r--plugins/ContactsPlus/src/receive.cpp900
-rw-r--r--plugins/FavContacts/src/headers.h1
-rw-r--r--plugins/FavContacts/src/main.cpp190
-rwxr-xr-xplugins/MetaContacts/src/meta_services.cpp5
-rw-r--r--plugins/Non-IM Contact/src/commonheaders.h1
-rw-r--r--plugins/Non-IM Contact/src/contactinfo.cpp48
-rw-r--r--plugins/Non-IM Contact/src/main.cpp2
-rwxr-xr-xplugins/StopSpamMod/src/options.cpp802
-rwxr-xr-xplugins/StopSpamMod/src/utilities.cpp873
16 files changed, 1527 insertions, 1731 deletions
diff --git a/plugins/AddContactPlus/src/addcontact.cpp b/plugins/AddContactPlus/src/addcontact.cpp
index 15de673f7d..e895bffb09 100644
--- a/plugins/AddContactPlus/src/addcontact.cpp
+++ b/plugins/AddContactPlus/src/addcontact.cpp
@@ -183,256 +183,231 @@ bool AddContactDlgAccounts(HWND hdlg, ADDCONTACTSTRUCT* acs)
INT_PTR CALLBACK AddContactDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
ADDCONTACTSTRUCT* acs;
- switch (msg)
- {
- case WM_INITDIALOG:
- acs = (ADDCONTACTSTRUCT*)mir_calloc(sizeof(ADDCONTACTSTRUCT));
- acs->handleType = HANDLE_SEARCHRESULT;
- SetWindowLongPtr(hdlg, GWLP_USERDATA, (LONG_PTR)acs);
-
- Utils_RestoreWindowPositionNoSize(hdlg, NULL, "AddContact", "");
- TranslateDialogDefault(hdlg);
- SendMessage(hdlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_GetIcon(ICON_ADD,1));
- SendMessage(hdlg, WM_SETICON, ICON_SMALL, (LPARAM)Skin_GetIcon(ICON_ADD));
- HookEventMessage(ME_SKIN2_ICONSCHANGED, hdlg, DM_ADDCONTACT_CHANGEICONS);
- HookEventMessage(ME_PROTO_ACCLISTCHANGED, hdlg, DM_ADDCONTACT_CHANGEACCLIST);
+ switch (msg) {
+ case WM_INITDIALOG:
+ acs = (ADDCONTACTSTRUCT*)mir_calloc(sizeof(ADDCONTACTSTRUCT));
+ acs->handleType = HANDLE_SEARCHRESULT;
+ SetWindowLongPtr(hdlg, GWLP_USERDATA, (LONG_PTR)acs);
+
+ Utils_RestoreWindowPositionNoSize(hdlg, NULL, "AddContact", "");
+ TranslateDialogDefault(hdlg);
+ SendMessage(hdlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_GetIcon(ICON_ADD,1));
+ SendMessage(hdlg, WM_SETICON, ICON_SMALL, (LPARAM)Skin_GetIcon(ICON_ADD));
+ HookEventMessage(ME_SKIN2_ICONSCHANGED, hdlg, DM_ADDCONTACT_CHANGEICONS);
+ HookEventMessage(ME_PROTO_ACCLISTCHANGED, hdlg, DM_ADDCONTACT_CHANGEACCLIST);
- {
- for (int groupId = 0; groupId < 999; groupId++)
- {
- DBVARIANT dbv;
- char idstr[4];
- _itoa(groupId, idstr, 10);
- if (db_get_ts(NULL, "CListGroups", idstr, &dbv)) break;
- int id = SendDlgItemMessage(hdlg, IDC_GROUP, CB_ADDSTRING, 0, (LPARAM)(dbv.ptszVal + 1));
- SendDlgItemMessage(hdlg, IDC_GROUP, CB_SETITEMDATA, (WPARAM)id, (LPARAM)groupId + 1);
- db_free(&dbv);
- }
+ {
+ TCHAR *szGroup;
+ for (int i=1; (szGroup = pcli->pfnGetGroupName(i, NULL)) != NULL; i++) {
+ int id = SendDlgItemMessage(hdlg, IDC_GROUP, CB_ADDSTRING, 0, (LPARAM)szGroup);
+ SendDlgItemMessage(hdlg, IDC_GROUP, CB_SETITEMDATA, (WPARAM)id, (LPARAM)i+1);
}
- SendDlgItemMessage(hdlg, IDC_GROUP, CB_INSERTSTRING, 0, (LPARAM)TranslateT("None"));
- SendDlgItemMessage(hdlg, IDC_GROUP, CB_SETCURSEL, 0, 0);
+ }
+ SendDlgItemMessage(hdlg, IDC_GROUP, CB_INSERTSTRING, 0, (LPARAM)TranslateT("None"));
+ SendDlgItemMessage(hdlg, IDC_GROUP, CB_SETCURSEL, 0, 0);
- {
- DBVARIANT dbv = {0};
- if(!db_get_s(NULL,"AddContact","LastProto",&dbv))
- {
- acs->szProto = dbv.pszVal;
- db_free(&dbv);
+ {
+ DBVARIANT dbv = {0};
+ if(!db_get_s(NULL,"AddContact","LastProto",&dbv)) {
+ acs->szProto = dbv.pszVal;
+ db_free(&dbv);
+ }
+ }
+ if(AddContactDlgAccounts(hdlg, acs)) {
+ // By default check these checkboxes
+ CheckDlgButton(hdlg, IDC_ADDED, BST_CHECKED);
+ CheckDlgButton(hdlg, IDC_AUTH, BST_CHECKED);
+ AddContactDlgOpts(hdlg, acs->szProto);
+ EnableWindow(GetDlgItem(hdlg, IDOK), FALSE);
+ }
+ break;
+
+ case WM_COMMAND:
+ acs = (ADDCONTACTSTRUCT*)GetWindowLongPtr(hdlg, GWLP_USERDATA);
+ switch (LOWORD(wparam)) {
+ case IDC_USERID:
+ if (HIWORD(wparam) == EN_CHANGE) {
+ TCHAR szUserId[256];
+ if (GetDlgItemText(hdlg, IDC_USERID, szUserId, SIZEOF(szUserId))) {
+ if (!IsWindowEnabled(GetDlgItem(hdlg, IDOK)))
+ EnableWindow(GetDlgItem(hdlg, IDOK), TRUE);
}
+ else if (IsWindowEnabled(GetDlgItem(hdlg, IDOK)))
+ EnableWindow(GetDlgItem(hdlg, IDOK), FALSE);
}
- if(AddContactDlgAccounts(hdlg, acs))
- {
- // By default check these checkboxes
- CheckDlgButton(hdlg, IDC_ADDED, BST_CHECKED);
- CheckDlgButton(hdlg, IDC_AUTH, BST_CHECKED);
+ break;
+
+ case IDC_PROTO:
+ if (HIWORD(wparam) == CBN_SELCHANGE || HIWORD(wparam) == CBN_SELENDOK) {
+ acs->szProto = (char*)SendDlgItemMessage(hdlg, IDC_PROTO, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hdlg, IDC_PROTO, CB_GETCURSEL, 0, 0), 0);
+ // TODO remember last setting for each proto?
AddContactDlgOpts(hdlg, acs->szProto);
- EnableWindow(GetDlgItem(hdlg, IDOK), FALSE);
}
break;
- case WM_COMMAND:
- acs = (ADDCONTACTSTRUCT*)GetWindowLongPtr(hdlg, GWLP_USERDATA);
- switch (LOWORD(wparam))
+ case IDC_ADDTEMP:
+ AddContactDlgOpts(hdlg, acs->szProto, TRUE);
+ break;
+
+ case IDC_AUTH:
{
- case IDC_USERID:
- if (HIWORD(wparam) == EN_CHANGE)
- {
- TCHAR szUserId[256];
- if (GetDlgItemText(hdlg, IDC_USERID, szUserId, SIZEOF(szUserId)))
- {
- if (!IsWindowEnabled(GetDlgItem(hdlg, IDOK)))
- EnableWindow(GetDlgItem(hdlg, IDOK), TRUE);
- }
- else if (IsWindowEnabled(GetDlgItem(hdlg, IDOK)))
- EnableWindow(GetDlgItem(hdlg, IDOK), FALSE);
- }
- break;
+ DWORD flags = CallProtoService(acs->szProto, PS_GETCAPS, PFLAGNUM_4,0);
+ if (flags & PF4_NOCUSTOMAUTH) {
+ EnableWindow(GetDlgItem(hdlg, IDC_AUTHREQ), FALSE);
+ EnableWindow(GetDlgItem(hdlg, IDC_AUTHGB), FALSE);
+ }
+ else {
+ EnableWindow(GetDlgItem(hdlg, IDC_AUTHREQ), IsDlgButtonChecked(hdlg, IDC_AUTH));
+ EnableWindow(GetDlgItem(hdlg, IDC_AUTHGB), IsDlgButtonChecked(hdlg, IDC_AUTH));
+ }
+ }
+ break;
- case IDC_PROTO:
- if (HIWORD(wparam) == CBN_SELCHANGE || HIWORD(wparam) == CBN_SELENDOK)
- {
- acs->szProto = (char*)SendDlgItemMessage(hdlg, IDC_PROTO, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hdlg, IDC_PROTO, CB_GETCURSEL, 0, 0), 0);
- // TODO remember last setting for each proto?
- AddContactDlgOpts(hdlg, acs->szProto);
- }
- break;
+ case IDOK:
+ {
+ HANDLE hContact = INVALID_HANDLE_VALUE;
+ PROTOSEARCHRESULT* psr;
- case IDC_ADDTEMP:
- AddContactDlgOpts(hdlg, acs->szProto, TRUE);
- break;
+ TCHAR szUserId[256];
+ GetDlgItemText(hdlg, IDC_USERID, szUserId, SIZEOF(szUserId));
- case IDC_AUTH:
+ if (*rtrim(szUserId) == 0 ||
+ (strstr(acs->szProto, "GG") && _tcstoul(szUserId, NULL, 10) > INT_MAX) || // Gadu-Gadu protocol
+ ((CallProtoService(acs->szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_NUMERICUSERID) && !_tcstoul(szUserId, NULL, 10)))
{
- DWORD flags = CallProtoService(acs->szProto, PS_GETCAPS, PFLAGNUM_4,0);
- if (flags & PF4_NOCUSTOMAUTH)
- {
- EnableWindow(GetDlgItem(hdlg, IDC_AUTHREQ), FALSE);
- EnableWindow(GetDlgItem(hdlg, IDC_AUTHGB), FALSE);
- }
- else
- {
- EnableWindow(GetDlgItem(hdlg, IDC_AUTHREQ), IsDlgButtonChecked(hdlg, IDC_AUTH));
- EnableWindow(GetDlgItem(hdlg, IDC_AUTHGB), IsDlgButtonChecked(hdlg, IDC_AUTH));
- }
+ MessageBox(NULL,
+ TranslateT("The contact cannot be added to your contact list. Please make sure the contact ID is entered correctly."),
+ TranslateT("Add contact"), MB_OK | MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST);
break;
}
- case IDOK:
- {
- HANDLE hContact = INVALID_HANDLE_VALUE;
- PROTOSEARCHRESULT* psr;
-
- TCHAR szUserId[256];
- GetDlgItemText(hdlg, IDC_USERID, szUserId, SIZEOF(szUserId));
-
- if (*rtrim(szUserId) == 0 ||
- (strstr(acs->szProto, "GG") && _tcstoul(szUserId, NULL, 10) > INT_MAX) || // Gadu-Gadu protocol
- ((CallProtoService(acs->szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_NUMERICUSERID) && !_tcstoul(szUserId, NULL, 10)))
- {
+ if (strstr(acs->szProto, "MNETSEND")) { // mNetSend protocol
+ psr = (PROTOSEARCHRESULT*)mir_calloc(sizeof(NETSENDSEARCHRESULT));
+ psr->cbSize = sizeof(NETSENDSEARCHRESULT);
+ }
+ else if (strstr(acs->szProto, "MYSPACE")) { // Myspace protocol
+ if (_tcstoul(szUserId, NULL, 10) > INT_MAX) {
MessageBox(NULL,
TranslateT("The contact cannot be added to your contact list. Please make sure the contact ID is entered correctly."),
TranslateT("Add contact"), MB_OK | MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST);
break;
}
-
- if (strstr(acs->szProto, "MNETSEND")) // mNetSend protocol
- {
- psr = (PROTOSEARCHRESULT*)mir_calloc(sizeof(NETSENDSEARCHRESULT));
- psr->cbSize = sizeof(NETSENDSEARCHRESULT);
- }
- else if (strstr(acs->szProto, "MYSPACE")) // Myspace protocol
- {
- if (_tcstoul(szUserId, NULL, 10) > INT_MAX)
- {
- MessageBox(NULL,
- TranslateT("The contact cannot be added to your contact list. Please make sure the contact ID is entered correctly."),
- TranslateT("Add contact"), MB_OK | MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST);
- break;
- }
- psr = (PROTOSEARCHRESULT*)mir_calloc(sizeof(MYPROTOSEARCHRESULT));
- psr->cbSize = sizeof(MYPROTOSEARCHRESULT);
- ((MYPROTOSEARCHRESULT*)psr)->uid = _tcstoul(szUserId, NULL, 10);
- }
- else if (strstr(acs->szProto, "TLEN")) // Tlen protocol
- {
- if (_tcschr(szUserId, '@') == NULL)
- {
- MessageBox(NULL,
- TranslateT("The contact cannot be added to your contact list. Please make sure the contact ID is entered correctly."),
- TranslateT("Add contact"), MB_OK | MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST);
- break;
- }
- psr = (PROTOSEARCHRESULT*)mir_calloc(sizeof(TLEN_SEARCH_RESULT));
- psr->cbSize = sizeof(TLEN_SEARCH_RESULT);
- mir_snprintf(((TLEN_SEARCH_RESULT*)psr)->jid, SIZEOF(((TLEN_SEARCH_RESULT*)psr)->jid), "%S", szUserId);
- }
- else
- {
- psr = (PROTOSEARCHRESULT*)mir_calloc(sizeof(PROTOSEARCHRESULT));
- psr->cbSize = sizeof(PROTOSEARCHRESULT);
- }
-
- psr->flags = PSR_TCHAR;
- psr->id = mir_tstrdup(szUserId);
- acs->psr = psr;
-
- hContact = (HANDLE)CallProtoService(acs->szProto, PS_ADDTOLIST, IsDlgButtonChecked(hdlg, IDC_ADDTEMP) ? PALF_TEMPORARY : 0, (LPARAM)acs->psr);
-
- if (hContact == NULL)
- {
+ psr = (PROTOSEARCHRESULT*)mir_calloc(sizeof(MYPROTOSEARCHRESULT));
+ psr->cbSize = sizeof(MYPROTOSEARCHRESULT);
+ ((MYPROTOSEARCHRESULT*)psr)->uid = _tcstoul(szUserId, NULL, 10);
+ }
+ else if (strstr(acs->szProto, "TLEN")) { // Tlen protocol
+ if (_tcschr(szUserId, '@') == NULL) {
MessageBox(NULL,
- TranslateT("The contact cannot be added to your contact list. If you are not logged into the selected account, please try to do so. Also, make sure the contact ID is entered correctly."),
+ TranslateT("The contact cannot be added to your contact list. Please make sure the contact ID is entered correctly."),
TranslateT("Add contact"), MB_OK | MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST);
break;
}
+ psr = (PROTOSEARCHRESULT*)mir_calloc(sizeof(TLEN_SEARCH_RESULT));
+ psr->cbSize = sizeof(TLEN_SEARCH_RESULT);
+ mir_snprintf(((TLEN_SEARCH_RESULT*)psr)->jid, SIZEOF(((TLEN_SEARCH_RESULT*)psr)->jid), "%S", szUserId);
+ }
+ else {
+ psr = (PROTOSEARCHRESULT*)mir_calloc(sizeof(PROTOSEARCHRESULT));
+ psr->cbSize = sizeof(PROTOSEARCHRESULT);
+ }
- TCHAR szHandle[256];
- if (GetDlgItemText(hdlg, IDC_MYHANDLE, szHandle, SIZEOF(szHandle)))
- db_set_ts(hContact, "CList", "MyHandle", szHandle);
+ psr->flags = PSR_TCHAR;
+ psr->id = mir_tstrdup(szUserId);
+ acs->psr = psr;
- int item = SendDlgItemMessage(hdlg, IDC_GROUP, CB_GETCURSEL, 0, 0);
- if (item > 0)
- {
- item = SendDlgItemMessage(hdlg, IDC_GROUP, CB_GETITEMDATA, item, 0);
- CallService(MS_CLIST_CONTACTCHANGEGROUP, (WPARAM)hContact, item);
- }
+ hContact = (HANDLE)CallProtoService(acs->szProto, PS_ADDTOLIST, IsDlgButtonChecked(hdlg, IDC_ADDTEMP) ? PALF_TEMPORARY : 0, (LPARAM)acs->psr);
- if (!IsDlgButtonChecked(hdlg, IDC_ADDTEMP))
- {
- db_unset(hContact, "CList", "NotOnList");
+ if (hContact == NULL) {
+ MessageBox(NULL,
+ TranslateT("The contact cannot be added to your contact list. If you are not logged into the selected account, please try to do so. Also, make sure the contact ID is entered correctly."),
+ TranslateT("Add contact"), MB_OK | MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST);
+ break;
+ }
- if (IsDlgButtonChecked(hdlg, IDC_ADDED))
- CallContactService(hContact, PSS_ADDED, 0, 0);
+ TCHAR szHandle[256];
+ if (GetDlgItemText(hdlg, IDC_MYHANDLE, szHandle, SIZEOF(szHandle)))
+ db_set_ts(hContact, "CList", "MyHandle", szHandle);
- if (IsDlgButtonChecked(hdlg, IDC_AUTH))
+ int item = SendDlgItemMessage(hdlg, IDC_GROUP, CB_GETCURSEL, 0, 0);
+ if (item > 0) {
+ item = SendDlgItemMessage(hdlg, IDC_GROUP, CB_GETITEMDATA, item, 0);
+ CallService(MS_CLIST_CONTACTCHANGEGROUP, (WPARAM)hContact, item);
+ }
+
+ if (!IsDlgButtonChecked(hdlg, IDC_ADDTEMP)) {
+ db_unset(hContact, "CList", "NotOnList");
+
+ if (IsDlgButtonChecked(hdlg, IDC_ADDED))
+ CallContactService(hContact, PSS_ADDED, 0, 0);
+
+ if (IsDlgButtonChecked(hdlg, IDC_AUTH))
+ {
+ DWORD flags = CallProtoService(acs->szProto, PS_GETCAPS, PFLAGNUM_4, 0);
+ if (flags & PF4_NOCUSTOMAUTH)
+ CallContactService(hContact, PSS_AUTHREQUESTT, 0, 0);
+ else
{
- DWORD flags = CallProtoService(acs->szProto, PS_GETCAPS, PFLAGNUM_4, 0);
- if (flags & PF4_NOCUSTOMAUTH)
- CallContactService(hContact, PSS_AUTHREQUESTT, 0, 0);
- else
- {
- TCHAR szReason[512];
- GetDlgItemText(hdlg, IDC_AUTHREQ, szReason, SIZEOF(szReason));
- CallContactService(hContact, PSS_AUTHREQUESTT, 0, (LPARAM)szReason);
- }
+ TCHAR szReason[512];
+ GetDlgItemText(hdlg, IDC_AUTHREQ, szReason, SIZEOF(szReason));
+ CallContactService(hContact, PSS_AUTHREQUESTT, 0, (LPARAM)szReason);
}
}
-
- if (GetAsyncKeyState(VK_CONTROL))
- CallService(MS_MSG_SENDMESSAGE, (WPARAM)hContact, (LPARAM)(const char*)NULL);
}
- // fall through
- case IDCANCEL:
- if (GetParent(hdlg) == NULL)
- DestroyWindow(hdlg);
- else
- EndDialog(hdlg, 0);
- break;
- }
- break;
- case WM_CLOSE:
- /* if there is no parent for the dialog, its a modeless dialog and can't be killed using EndDialog() */
+ if (GetAsyncKeyState(VK_CONTROL))
+ CallService(MS_MSG_SENDMESSAGE, (WPARAM)hContact, (LPARAM)(const char*)NULL);
+ }
+ // fall through
+ case IDCANCEL:
if (GetParent(hdlg) == NULL)
DestroyWindow(hdlg);
else
EndDialog(hdlg, 0);
break;
-
- case DM_ADDCONTACT_CHANGEICONS:
- Skin_ReleaseIcon((HICON)SendMessage(hdlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_GetIcon(ICON_ADD, 1)));
- Skin_ReleaseIcon((HICON)SendMessage(hdlg, WM_SETICON, ICON_SMALL, (LPARAM)Skin_GetIcon(ICON_ADD)));
- break;
-
- case DM_ADDCONTACT_CHANGEACCLIST:
- {
- acs = (ADDCONTACTSTRUCT*)GetWindowLongPtr(hdlg, GWLP_USERDATA);
- AddContactDlgAccounts(hdlg, acs);
- break;
}
+ break;
- case WM_DESTROY:
- hAddDlg = NULL;
- Skin_ReleaseIcon((HICON)SendMessage(hdlg, WM_SETICON, ICON_BIG, 0));
- Skin_ReleaseIcon((HICON)SendMessage(hdlg, WM_SETICON, ICON_SMALL, 0));
- ImageList_Destroy((HIMAGELIST)SendDlgItemMessage(hdlg, IDC_PROTO, CBEM_GETIMAGELIST, 0, 0));
- acs = (ADDCONTACTSTRUCT*)GetWindowLongPtr(hdlg, GWLP_USERDATA);
- if (acs)
+ case WM_CLOSE:
+ /* if there is no parent for the dialog, its a modeless dialog and can't be killed using EndDialog() */
+ if (GetParent(hdlg) == NULL)
+ DestroyWindow(hdlg);
+ else
+ EndDialog(hdlg, 0);
+ break;
+
+ case DM_ADDCONTACT_CHANGEICONS:
+ Skin_ReleaseIcon((HICON)SendMessage(hdlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_GetIcon(ICON_ADD, 1)));
+ Skin_ReleaseIcon((HICON)SendMessage(hdlg, WM_SETICON, ICON_SMALL, (LPARAM)Skin_GetIcon(ICON_ADD)));
+ break;
+
+ case DM_ADDCONTACT_CHANGEACCLIST:
+ acs = (ADDCONTACTSTRUCT*)GetWindowLongPtr(hdlg, GWLP_USERDATA);
+ AddContactDlgAccounts(hdlg, acs);
+ break;
+
+ case WM_DESTROY:
+ hAddDlg = NULL;
+ Skin_ReleaseIcon((HICON)SendMessage(hdlg, WM_SETICON, ICON_BIG, 0));
+ Skin_ReleaseIcon((HICON)SendMessage(hdlg, WM_SETICON, ICON_SMALL, 0));
+ ImageList_Destroy((HIMAGELIST)SendDlgItemMessage(hdlg, IDC_PROTO, CBEM_GETIMAGELIST, 0, 0));
+ acs = (ADDCONTACTSTRUCT*)GetWindowLongPtr(hdlg, GWLP_USERDATA);
+ if (acs)
+ {
+ if(acs->szProto)
+ db_set_s(NULL,"AddContact","LastProto",acs->szProto);
+ if (acs->psr)
{
- if(acs->szProto)
- db_set_s(NULL,"AddContact","LastProto",acs->szProto);
- if (acs->psr)
- {
- mir_free(acs->psr->nick);
- mir_free(acs->psr->firstName);
- mir_free(acs->psr->lastName);
- mir_free(acs->psr->email);
- mir_free(acs->psr);
- }
- mir_free(acs);
+ mir_free(acs->psr->nick);
+ mir_free(acs->psr->firstName);
+ mir_free(acs->psr->lastName);
+ mir_free(acs->psr->email);
+ mir_free(acs->psr);
}
- Utils_SaveWindowPosition(hdlg, NULL, "AddContact", "");
- break;
+ mir_free(acs);
+ }
+ Utils_SaveWindowPosition(hdlg, NULL, "AddContact", "");
+ break;
}
return FALSE;
diff --git a/plugins/AddContactPlus/src/addcontactplus.h b/plugins/AddContactPlus/src/addcontactplus.h
index ad24744b2d..b404c4cbe2 100644
--- a/plugins/AddContactPlus/src/addcontactplus.h
+++ b/plugins/AddContactPlus/src/addcontactplus.h
@@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <win2k.h>
#include <newpluginapi.h>
#include <m_database.h>
+#include <m_clistint.h>
#include <m_genmenu.h>
#include <m_hotkeys.h>
#include <m_icolib.h>
diff --git a/plugins/AddContactPlus/src/main.cpp b/plugins/AddContactPlus/src/main.cpp
index f8c4f270a2..785840056f 100644
--- a/plugins/AddContactPlus/src/main.cpp
+++ b/plugins/AddContactPlus/src/main.cpp
@@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/
#include "addcontactplus.h"
+CLIST_INTERFACE *pcli;
HINSTANCE hInst;
int hLangpack;
static HANDLE hMainMenuItem = 0, hToolBarItem = 0;
@@ -140,6 +141,7 @@ static int OnModulesLoaded(WPARAM, LPARAM)
extern "C" int __declspec(dllexport) Load(void)
{
mir_getLP(&pluginInfo);
+ mir_getCLI();
INITCOMMONCONTROLSEX icex = { sizeof(icex), ICC_USEREX_CLASSES };
InitCommonControlsEx(&icex);
diff --git a/plugins/Clist_modern/src/modern_viewmodebar.cpp b/plugins/Clist_modern/src/modern_viewmodebar.cpp
index 4cf5074ef6..ad4717d393 100644
--- a/plugins/Clist_modern/src/modern_viewmodebar.cpp
+++ b/plugins/Clist_modern/src/modern_viewmodebar.cpp
@@ -237,10 +237,6 @@ static int FillDialog(HWND hwnd)
// fill groups
{
- LVITEM item = {0};
- char buf[20];
- DBVARIANT dbv = {0};
-
hwndList = GetDlgItem(hwnd, IDC_GROUPS);
ListView_SetExtendedListViewStyle(hwndList, LVS_EX_CHECKBOXES);
@@ -248,21 +244,17 @@ static int FillDialog(HWND hwnd)
lvc.fmt = LVCFMT_IMAGE | LVCFMT_LEFT;
ListView_InsertColumn(hwndList, 0, &lvc);
+ LVITEM item = {0};
item.mask = LVIF_TEXT;
item.iItem = 1000;
item.pszText = TranslateT("Ungrouped contacts");
newItem = SendMessage(hwndList, LVM_INSERTITEM, 0, (LPARAM)&item);
- for (i=0;;i++)
- {
- mir_snprintf(buf, 20, "%d", i);
- if (db_get_ts(NULL, "CListGroups", buf, &dbv))
- break;
-
- item.pszText = &dbv.ptszVal[1];
+ TCHAR *szGroup;
+ for (int i=1; (szGroup = pcli->pfnGetGroupName(i, NULL)) != NULL; i++) {
+ item.pszText = szGroup;
newItem = SendMessage(hwndList, LVM_INSERTITEM, 0, (LPARAM)&item);
- db_free(&dbv);
}
ListView_SetColumnWidth(hwndList, 0, LVSCW_AUTOSIZE);
ListView_Arrange(hwndList, LVA_ALIGNLEFT | LVA_ALIGNTOP);
diff --git a/plugins/Clist_nicer/src/viewmodes.cpp b/plugins/Clist_nicer/src/viewmodes.cpp
index acf7e07cda..1e167b3825 100644
--- a/plugins/Clist_nicer/src/viewmodes.cpp
+++ b/plugins/Clist_nicer/src/viewmodes.cpp
@@ -173,7 +173,7 @@ static int FillDialog(HWND hwnd)
LVCOLUMN lvc = {0};
HWND hwndList = GetDlgItem(hwnd, IDC_PROTOCOLS);
LVITEMA item = {0};
- int protoCount = 0, i, newItem;
+ int protoCount = 0, i;
PROTOACCOUNT **accs = 0;
CLVM_EnumModes(FillModes);
@@ -189,7 +189,7 @@ static int FillDialog(HWND hwnd)
item.iItem = 1000;
for (i = 0; i < protoCount; i++) {
item.pszText = accs[i]->szModuleName;
- newItem = SendMessageA(hwndList, LVM_INSERTITEMA, 0, (LPARAM)&item);
+ SendMessageA(hwndList, LVM_INSERTITEMA, 0, (LPARAM)&item);
}
ListView_SetColumnWidth(hwndList, 0, LVSCW_AUTOSIZE);
@@ -197,10 +197,6 @@ static int FillDialog(HWND hwnd)
// fill groups
{
- LVITEM item = {0};
- char buf[20];
- DBVARIANT dbv = {0};
-
hwndList = GetDlgItem(hwnd, IDC_GROUPS);
ListView_SetExtendedListViewStyle(hwndList, LVS_EX_CHECKBOXES);
@@ -208,33 +204,33 @@ static int FillDialog(HWND hwnd)
lvc.fmt = LVCFMT_IMAGE | LVCFMT_LEFT;
ListView_InsertColumn(hwndList, 0, &lvc);
+ LVITEM item = {0};
item.mask = LVIF_TEXT;
item.iItem = 1000;
item.pszText = TranslateT("Ungrouped contacts");
- newItem = SendMessage(hwndList, LVM_INSERTITEM, 0, (LPARAM)&item);
-
- for (i = 0;;i++) {
- mir_snprintf(buf, 20, "%d", i);
- if (cfg::getTString(NULL, "CListGroups", buf, &dbv))
- break;
+ SendMessage(hwndList, LVM_INSERTITEM, 0, (LPARAM)&item);
- item.pszText = &dbv.ptszVal[1];
- newItem = SendMessage(hwndList, LVM_INSERTITEM, 0, (LPARAM)&item);
- db_free(&dbv);
+ TCHAR *grpName;
+ for (i = 1; (grpName = pcli->pfnGetGroupName(i, NULL)) != NULL; i++) {
+ item.pszText = grpName;
+ SendMessage(hwndList, LVM_INSERTITEM, 0, (LPARAM)&item);
}
ListView_SetColumnWidth(hwndList, 0, LVSCW_AUTOSIZE);
ListView_Arrange(hwndList, LVA_ALIGNLEFT | LVA_ALIGNTOP);
}
+
hwndList = GetDlgItem(hwnd, IDC_STATUSMODES);
ListView_SetExtendedListViewStyle(hwndList, LVS_EX_CHECKBOXES);
+
lvc.mask = LVCF_FMT;
lvc.fmt = LVCFMT_IMAGE | LVCFMT_LEFT;
ListView_InsertColumn(hwndList, 0, &lvc);
+
for (i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) {
item.pszText = Translate((char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)i, 0));
item.iItem = i - ID_STATUS_OFFLINE;
- newItem = SendMessageA(hwndList, LVM_INSERTITEMA, 0, (LPARAM)&item);
+ SendMessageA(hwndList, LVM_INSERTITEMA, 0, (LPARAM)&item);
}
ListView_SetColumnWidth(hwndList, 0, LVSCW_AUTOSIZE);
ListView_Arrange(hwndList, LVA_ALIGNLEFT | LVA_ALIGNTOP);
diff --git a/plugins/ContactsPlus/src/contacts.h b/plugins/ContactsPlus/src/contacts.h
index 4693a74d4a..3183c942b8 100644
--- a/plugins/ContactsPlus/src/contacts.h
+++ b/plugins/ContactsPlus/src/contacts.h
@@ -35,6 +35,7 @@
#include "m_langpack.h"
#include "m_skin.h"
#include "m_clist.h"
+#include "m_clistint.h"
#include "m_clc.h"
#include "m_clui.h"
#include "m_addcontact.h"
diff --git a/plugins/ContactsPlus/src/main.cpp b/plugins/ContactsPlus/src/main.cpp
index 3cfdef9d1a..615b126000 100644
--- a/plugins/ContactsPlus/src/main.cpp
+++ b/plugins/ContactsPlus/src/main.cpp
@@ -23,6 +23,7 @@
#include "contacts.h"
+CLIST_INTERFACE *pcli;
HINSTANCE hInst;
@@ -223,6 +224,8 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda
extern "C" __declspec(dllexport) int Load(void)
{
mir_getLP(&pluginInfo);
+ mir_getCLI();
+
InitCommonControls();
InitI18N();
diff --git a/plugins/ContactsPlus/src/receive.cpp b/plugins/ContactsPlus/src/receive.cpp
index dbb19d3330..a56283a296 100644
--- a/plugins/ContactsPlus/src/receive.cpp
+++ b/plugins/ContactsPlus/src/receive.cpp
@@ -23,500 +23,476 @@
#include "contacts.h"
-
/* TRecvContactsData */
TReceivedItem* TRecvContactsData::AddReceivedItem() {
- int iItem = cbReceived;
+ int iItem = cbReceived;
- cbReceived++;
- maReceived = (TReceivedItem**)realloc(maReceived, cbReceived*sizeof(TReceivedItem*));
- maReceived[iItem] = new TReceivedItem();
+ cbReceived++;
+ maReceived = (TReceivedItem**)realloc(maReceived, cbReceived*sizeof(TReceivedItem*));
+ maReceived[iItem] = new TReceivedItem();
- return maReceived[iItem];
+ return maReceived[iItem];
}
static int RecvDlg_Resize(HWND hwndDlg,LPARAM lParam,UTILRESIZECONTROL *urc)
{
- switch (urc->wId)
- {
- case IDC_CONTACTS:
- return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
- break;
- case IDOK:
- case IDDETAILS:
- case IDC_ENABLEGROUPS:
- case IDC_GROUPS:
- return RD_ANCHORX_LEFT | RD_ANCHORY_BOTTOM;
- break;
- case IDC_ADD:
- case IDC_HISTORY:
- case IDC_USERMENU:
- case IDC_DETAILS:
- return RD_ANCHORX_RIGHT | RD_ANCHORY_TOP;
- break;
- case IDCANCEL:
- return RD_ANCHORY_BOTTOM | RD_ANCHORX_RIGHT;
- break;
- }
- return RD_ANCHORX_LEFT | RD_ANCHORY_TOP; // default
+ switch (urc->wId)
+ {
+ case IDC_CONTACTS:
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
+ break;
+ case IDOK:
+ case IDDETAILS:
+ case IDC_ENABLEGROUPS:
+ case IDC_GROUPS:
+ return RD_ANCHORX_LEFT | RD_ANCHORY_BOTTOM;
+ break;
+ case IDC_ADD:
+ case IDC_HISTORY:
+ case IDC_USERMENU:
+ case IDC_DETAILS:
+ return RD_ANCHORX_RIGHT | RD_ANCHORY_TOP;
+ break;
+ case IDCANCEL:
+ return RD_ANCHORY_BOTTOM | RD_ANCHORX_RIGHT;
+ break;
+ }
+ return RD_ANCHORX_LEFT | RD_ANCHORY_TOP; // default
}
static char* ListView_GetItemTextEx(HWND hLV, int iItem, int iSubItem)
{
- LVITEM lvi = {0};
-
- lvi.mask = LVIF_TEXT;
- lvi.iSubItem = iSubItem;
- lvi.cchTextMax = 64;
- lvi.pszText = (char*)malloc(lvi.cchTextMax);
- while (SendMessageT(hLV, LVM_GETITEMTEXT, iItem, (LPARAM)&lvi) == lvi.cchTextMax - 1)
- { // loop until the returned size is smaller than buffer size
- SAFE_FREE((void**)&lvi.pszText);
- lvi.cchTextMax += 64;
- lvi.pszText = (char*)malloc(lvi.cchTextMax);
- }
- return lvi.pszText;
+ LVITEM lvi = {0};
+
+ lvi.mask = LVIF_TEXT;
+ lvi.iSubItem = iSubItem;
+ lvi.cchTextMax = 64;
+ lvi.pszText = (char*)malloc(lvi.cchTextMax);
+ while (SendMessageT(hLV, LVM_GETITEMTEXT, iItem, (LPARAM)&lvi) == lvi.cchTextMax - 1)
+ { // loop until the returned size is smaller than buffer size
+ SAFE_FREE((void**)&lvi.pszText);
+ lvi.cchTextMax += 64;
+ lvi.pszText = (char*)malloc(lvi.cchTextMax);
+ }
+ return lvi.pszText;
}
static void EnableGroupCombo(HWND hwndDlg)
{
- EnableDlgItem(hwndDlg, IDC_GROUPS, SendMessageT(GetDlgItem(hwndDlg, IDC_ENABLEGROUPS), BM_GETCHECK, 0, 0));
+ EnableDlgItem(hwndDlg, IDC_GROUPS, SendMessageT(GetDlgItem(hwndDlg, IDC_ENABLEGROUPS), BM_GETCHECK, 0, 0));
}
-
static void RebuildGroupCombo(HWND hwndDlg)
{
- DBVARIANT dbv = {0};
- char caGroupId[33];
- int bHasGroups = !DBGetContactSettingT(NULL, "CListGroups", "0", &dbv);
- HWND hGroupsCombo = GetDlgItem(hwndDlg, IDC_GROUPS);
-
- db_free(&dbv);
- if (bHasGroups)
- {
- int curs = SendMessageT(hGroupsCombo, CB_GETCURSEL, 0, 0);
- TCHAR* curst;
-
- EnableDlgItem(hwndDlg, IDC_ENABLEGROUPS, TRUE);
- EnableGroupCombo(hwndDlg);
-
- if (curs != CB_ERR)
- {
- curst = (char*)_alloca((SendMessageT(hGroupsCombo, CB_GETLBTEXTLEN, curs, 0) + 1) * sizeof(WCHAR));
- SendMessageT(hGroupsCombo, CB_GETLBTEXT, curs, (LPARAM)curst);
- }
- SendMessageT(hGroupsCombo, CB_RESETCONTENT, 0, 0);
-
- for (int groupId=0; ; groupId++)
- {
- itoa(groupId, caGroupId, 10);
- TCHAR* szGroup = DBGetContactSettingStringT(NULL, "CListGroups", caGroupId, NULL);
- int nPrefix = sizeof(WCHAR);
- if (!szGroup) break;
- int nIndex = SendMessageT(hGroupsCombo, CB_ADDSTRING, 0, (LPARAM)szGroup + nPrefix);
- SendMessageT(hGroupsCombo, CB_SETITEMDATA, nIndex, groupId+1);
- SAFE_FREE((void**)&szGroup);
- }
- if (curs != CB_ERR)
- SendMessageT(hGroupsCombo, CB_SELECTSTRING, -1, (LPARAM)curst);
- else
- SendMessageT(hGroupsCombo, CB_SETCURSEL, 0, 0);
- }
- else
- { // no groups available
- EnableDlgItem(hwndDlg, IDC_ENABLEGROUPS, FALSE);
- EnableDlgItem(hwndDlg, IDC_GROUPS, FALSE);
- }
+ int bHasGroups = pcli->pfnGetGroupName(0, NULL) != 0;
+ HWND hGroupsCombo = GetDlgItem(hwndDlg, IDC_GROUPS);
+
+ if (bHasGroups) {
+ int curs = SendMessageT(hGroupsCombo, CB_GETCURSEL, 0, 0);
+ TCHAR* curst;
+
+ EnableDlgItem(hwndDlg, IDC_ENABLEGROUPS, TRUE);
+ EnableGroupCombo(hwndDlg);
+
+ if (curs != CB_ERR) {
+ curst = (char*)_alloca((SendMessageT(hGroupsCombo, CB_GETLBTEXTLEN, curs, 0) + 1) * sizeof(WCHAR));
+ SendMessageT(hGroupsCombo, CB_GETLBTEXT, curs, (LPARAM)curst);
+ }
+ SendMessageT(hGroupsCombo, CB_RESETCONTENT, 0, 0);
+
+ TCHAR *szGroup;
+ for (int i=1; (szGroup = pcli->pfnGetGroupName(i, NULL)) != NULL; i++) {
+ int nIndex = SendMessageT(hGroupsCombo, CB_ADDSTRING, 0, (LPARAM)szGroup);
+ SendMessageT(hGroupsCombo, CB_SETITEMDATA, nIndex, i);
+ }
+ if (curs != CB_ERR)
+ SendMessageT(hGroupsCombo, CB_SELECTSTRING, -1, (LPARAM)curst);
+ else
+ SendMessageT(hGroupsCombo, CB_SETCURSEL, 0, 0);
+ }
+ else
+ { // no groups available
+ EnableDlgItem(hwndDlg, IDC_ENABLEGROUPS, FALSE);
+ EnableDlgItem(hwndDlg, IDC_GROUPS, FALSE);
+ }
}
-
static HANDLE CreateTemporaryContactForItem(HWND hwndDlg, TRecvContactsData* wndData, int iItem)
{
- char* caUIN = ListView_GetItemTextEx(GetDlgItem(hwndDlg, IDC_CONTACTS), iItem, 0);
- char* szProto =GetContactProto(wndData->mhContact);
- wndData->rhSearch = (HANDLE)CallProtoService(szProto, PS_BASICSEARCH, 0, (LPARAM)caUIN); // find it
- SAFE_FREE((void**)&wndData->haUin);
- wndData->haUin = caUIN;
- for (int j = 0; j < wndData->cbReceived; j++)
- if (!strcmpnull(wndData->maReceived[j]->mcaUIN, caUIN))
- return (HANDLE)CallProtoService(szProto, PS_ADDTOLISTBYEVENT, MAKEWPARAM(PALF_TEMPORARY, j), (LPARAM)wndData->mhDbEvent);
- return NULL;
+ char* caUIN = ListView_GetItemTextEx(GetDlgItem(hwndDlg, IDC_CONTACTS), iItem, 0);
+ char* szProto =GetContactProto(wndData->mhContact);
+ wndData->rhSearch = (HANDLE)CallProtoService(szProto, PS_BASICSEARCH, 0, (LPARAM)caUIN); // find it
+ SAFE_FREE((void**)&wndData->haUin);
+ wndData->haUin = caUIN;
+ for (int j = 0; j < wndData->cbReceived; j++)
+ if (!strcmpnull(wndData->maReceived[j]->mcaUIN, caUIN))
+ return (HANDLE)CallProtoService(szProto, PS_ADDTOLISTBYEVENT, MAKEWPARAM(PALF_TEMPORARY, j), (LPARAM)wndData->mhDbEvent);
+ return NULL;
}
-
-void RecvListView_AddColumn(HWND hList, int nWidth, const char* szTitle, int nTranslate, int nItem) {
- LVCOLUMN col;
- WCHAR tmp[MAX_PATH];
-
-
- col.mask = LVCF_FMT|LVCF_WIDTH|LVCF_TEXT|LVCF_SUBITEM;
- col.fmt = LVCFMT_LEFT;
- col.cx = nWidth;
- if (nTranslate) {
- col.pszText = SRCTranslateT(szTitle, tmp);
- }
- else {
- if (!szTitle) szTitle = "UID";
- col.pszText = ansi_to_tchar(szTitle, CallService(MS_LANGPACK_GETCODEPAGE, 0, 0));
- }
- col.iSubItem = nItem;
- ListView_InsertColumnT(hList, nItem, &col);
- if (!nTranslate)
- SAFE_FREE((void**)&col.pszText);
+void RecvListView_AddColumn(HWND hList, int nWidth, const char* szTitle, int nTranslate, int nItem)
+{
+ LVCOLUMN col;
+ WCHAR tmp[MAX_PATH];
+
+ col.mask = LVCF_FMT|LVCF_WIDTH|LVCF_TEXT|LVCF_SUBITEM;
+ col.fmt = LVCFMT_LEFT;
+ col.cx = nWidth;
+ if (nTranslate) {
+ col.pszText = SRCTranslateT(szTitle, tmp);
+ }
+ else {
+ if (!szTitle) szTitle = "UID";
+ col.pszText = ansi_to_tchar(szTitle, CallService(MS_LANGPACK_GETCODEPAGE, 0, 0));
+ }
+ col.iSubItem = nItem;
+ ListView_InsertColumnT(hList, nItem, &col);
+ if (!nTranslate)
+ SAFE_FREE((void**)&col.pszText);
}
-
INT_PTR CALLBACK RecvDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- TRecvContactsData* wndData = (TRecvContactsData*)GetWindowLongPtr(hwndDlg, DWLP_USER);
-
- switch (msg)
- {
- case WM_INITDIALOG:
- {
- CLISTEVENT* pcle = (CLISTEVENT*)lParam; /// got it
-
- TranslateDialogDefault(hwndDlg);
- WindowList_Add(ghRecvWindowList, hwndDlg, pcle->hContact);
- SendMessageT(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(hInst, MAKEINTRESOURCE(IDI_CONTACTS)));
- EnableDlgItem(hwndDlg, IDOK, FALSE);
- EnableDlgItem(hwndDlg, IDDETAILS, FALSE);
- wndData = new TRecvContactsData(pcle->hContact);
- SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG)wndData);
- wndData->mhDbEvent = pcle->hDbEvent; /// initialized, pcle not needed anymore
- wndData->mhListIcon = ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),ILC_COLORDDB|ILC_MASK, 0, 1);
- wndData->mhPopup = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTACTMENU));
- TranslateMenu(wndData->mhPopup);
- wndData->hHook = HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_EVENTSENT);
-
- char *szProto =GetContactProto(wndData->mhContact);
-
- HWND hLV = GetDlgItem(hwndDlg, IDC_CONTACTS);
- ListView_SetExtendedListViewStyle(hLV, LVS_EX_CHECKBOXES|LVS_EX_FULLROWSELECT);
- // add columns
- RecvListView_AddColumn(hLV, 120, (char*)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDTEXT, 0), FALSE, 0);
- RecvListView_AddColumn(hLV, 100, "Nick", TRUE, 1);
- RecvListView_AddColumn(hLV, 100, "First Name", TRUE, 2);
- RecvListView_AddColumn(hLV, 100, "Last Name", TRUE, 3);
-
- // fill in groups
- SendMessageT(GetDlgItem(hwndDlg, IDC_ENABLEGROUPS), BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
- RebuildGroupCombo(hwndDlg);
-
- { // fill listview with received contacts
- DBEVENTINFO dbe = {0};
-
- dbe.cbSize = sizeof(DBEVENTINFO);
- dbe.cbBlob = db_event_getBlobSize(wndData->mhDbEvent);
- if (dbe.cbBlob != -1) // this marks an invalid hDbEvent - all smashed anyway...
- dbe.pBlob = (PBYTE)_alloca(dbe.cbBlob);
- db_event_get(wndData->mhDbEvent, &dbe);
- char* pcBlob = (char*)dbe.pBlob;
- char* pcEnd = (char*)dbe.pBlob + dbe.cbBlob;
-
- HICON hiProto = LoadContactProtoIcon(wndData->mhContact);
- ImageList_AddIcon(wndData->mhListIcon, hiProto);
- DestroyIcon(hiProto); // imagelist copied the resource
- ListView_SetImageList(hLV, wndData->mhListIcon, LVSIL_SMALL);
- LVITEM lvi = {0};
- lvi.iImage = 0;
- lvi.mask = LVIF_TEXT | LVIF_IMAGE;
-
- for (int nItem = 0; ; nItem++)
- { // Nick
- int strsize = (int)strlennull(pcBlob);
- TReceivedItem* pItem = wndData->AddReceivedItem();
-
- if (dbe.flags & DBEF_UTF)
- pItem->mcaNick = utf8_to_tchar((unsigned char*)pcBlob);
- else
- pItem->mcaNick = ansi_to_tchar(pcBlob);
- pcBlob += strsize + 1;
- // UIN
- strsize = (int)strlennull(pcBlob);
- pItem->mcaUIN = null_strdup(pcBlob);
- pcBlob += strsize + 1;
- // add to listview
- lvi.iItem = nItem;
- lvi.pszText = pItem->mcaUIN;
- ListView_InsertItem(hLV, &lvi); // with image
- ListView_SetItemTextT(hLV, nItem, 1, pItem->mcaNick);
- // check for end of contacts
- if (pcBlob >= pcEnd)
- break;
- }
- }
- // new dlg init
- wndData->hIcons[0] = InitMButton(hwndDlg, IDC_ADD, MAKEINTRESOURCEA(IDI_ADDCONTACT), Translate("Add Contact Permanently to List"));
- wndData->hIcons[1] = InitMButton(hwndDlg, IDC_DETAILS, MAKEINTRESOURCEA(IDI_USERDETAILS), Translate("View User's Details"));
- wndData->hIcons[2] = InitMButton(hwndDlg, IDC_HISTORY, MAKEINTRESOURCEA(IDI_HISTORY), Translate("View User's History"));
- wndData->hIcons[3] = InitMButton(hwndDlg, IDC_USERMENU, MAKEINTRESOURCEA(IDI_DOWNARROW), Translate("User Menu"));
-
- SendMessageT(hwndDlg,DM_UPDATETITLE,0,0);
- // new dialog init done
- Utils_RestoreWindowPosition(hwndDlg, NULL, MODULENAME, "");
- return TRUE;
- }
- case WM_NOTIFY:
- if (((LPNMHDR)lParam)->idFrom == IDC_CONTACTS)
- {
- switch (((LPNMHDR)lParam)->code)
- {
- case NM_DBLCLK:
- {
- HWND hLV = GetDlgItem(hwndDlg, IDC_CONTACTS);
- if (ListView_GetSelectedCount(hLV) != 1) break; // if not clicking on item, bye
- wndData->iPopupItem = ListView_GetNextItem(hLV, -1, LVNI_ALL|LVNI_SELECTED);
- if (wndData->iPopupItem == -1) break; // if no item selected no user details available
- return SendMessageT(hwndDlg, WM_COMMAND, ID_POPUP_USERDETAILS, 0); // show user details
- }
- case LVN_ITEMCHANGED:
- {
- LPNMLISTVIEW pNMLV = (LPNMLISTVIEW)lParam;
- HWND hLV = GetDlgItem(hwndDlg, IDC_CONTACTS); // optimisation, for FOR-Cycle
- bool bExistsCheckedItem = false; // there must be no checked items to disable "Add" button
-
- if (ListView_GetCheckState(hLV, pNMLV->iItem))
- { // the user has checked this item
- bExistsCheckedItem = true; // enable "Add" button
- }
- else
- { // loop thru items and check if at least one is checked
- for (int i = 0; i < ListView_GetItemCount(hLV); i++)
- if (ListView_GetCheckState(hLV, i))
- { // we found checked item, enable add, exit loop
- bExistsCheckedItem = true;
- break;
- }
- }
- EnableDlgItem(hwndDlg, IDOK, bExistsCheckedItem);
- EnableDlgItem(hwndDlg, IDDETAILS, ListView_GetSelectedCount(hLV) > 0);
- break;
- }
- }
- }
- break;
-
- case WM_COMMAND:
- {
- if (!lParam && CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)wndData->mhContact))
- break;
-
- switch(LOWORD(wParam))
- {
- case IDOK: // "Add Selected" button click
- { // for each selected item, find its index in the hDbEvent
- // and after that add this item to the DB permanently
- char* caUIN;
- HWND hLV = GetDlgItem(hwndDlg, IDC_CONTACTS);
- HWND hGroupsCombo = GetDlgItem(hwndDlg, IDC_GROUPS);
- HWND hGroupsCheck = GetDlgItem(hwndDlg, IDC_ENABLEGROUPS);
- int curs = SendMessageT(hGroupsCombo, CB_GETCURSEL, 0, 0);
- TCHAR* caGroup = NULL;
- int nGroupId = -1;
- if (curs != CB_ERR && IsWindowEnabled(hGroupsCheck) && SendMessageT(hGroupsCheck, BM_GETCHECK, 0, 0))
- { //got groups, get the one selected in combo
- TCHAR* caGroup = (TCHAR*)_alloca((SendMessageT(hGroupsCombo, CB_GETLBTEXTLEN, curs, 0) + 1) * sizeof(WCHAR));
- SendMessageT(hGroupsCombo, CB_GETLBTEXT, curs, (LPARAM)caGroup);
- nGroupId = SendMessageT(hGroupsCombo, CB_GETITEMDATA, curs, 0);
- }
-
- for (int i = 0; i < ListView_GetItemCount(hLV); i++)
- if (ListView_GetCheckState(hLV, i))
- { // found checked contact item, add it
- caUIN = ListView_GetItemTextEx(hLV, i, 0);
- for (int j = 0; j < wndData->cbReceived; j++) // determine item index in packet
- if (!strcmpnull(wndData->maReceived[j]->mcaUIN, caUIN))
- {
- char* szProto =GetContactProto(wndData->mhContact);
- HANDLE hContact = (HANDLE)CallProtoService(szProto, PS_ADDTOLISTBYEVENT, MAKEWPARAM(0, j), (LPARAM)wndData->mhDbEvent);
- if (hContact && caGroup)
- { // use newest group API if available
- if (ServiceExists(MS_CLIST_CONTACTCHANGEGROUP))
- CallService(MS_CLIST_CONTACTCHANGEGROUP, (WPARAM)hContact, (LPARAM)nGroupId);
- else
- DBWriteContactSettingStringT(hContact, "CList", "Group", caGroup);
- }
- break;
- }
- SAFE_FREE((void**)&caUIN);
- } // move to next item
- break;
- }
- case IDDETAILS:
- { // for each selected item, find its index in the hDbEvent
- // and after that add this item to the DB
- // finally, request Details window for this hContact
- HWND hLV = GetDlgItem(hwndDlg, IDC_CONTACTS);
- for (int i = 0; i < ListView_GetItemCount(hLV); i++)
- if (ListView_GetItemState(hLV, i, LVIS_SELECTED))
- {
- HANDLE hContact = CreateTemporaryContactForItem(hwndDlg, wndData, i);
- if (hContact)
- CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)hContact, 0);
- }
- break;
- }
- case IDCANCEL:
- {
- SendMessageT(hwndDlg, WM_CLOSE, 0, 0);
- break;
- }
- case IDC_ENABLEGROUPS:
- {
- EnableGroupCombo(hwndDlg);
- break;
- }
- case IDC_GROUPS:
- { // rebuild group list on popup
- if (HIWORD(wParam) == CBN_DROPDOWN)
- RebuildGroupCombo(hwndDlg);
- break;
- }
- case ID_POPUP_ADDUSER:
- {
- HANDLE hContact = CreateTemporaryContactForItem(hwndDlg, wndData, wndData->iPopupItem);
-
- if (hContact)
- DialogAddContactExecute(hwndDlg, hContact);
- break;
- }
- case ID_POPUP_USERDETAILS:
- {
- HANDLE hContact = CreateTemporaryContactForItem(hwndDlg, wndData, wndData->iPopupItem);
-
- if (hContact)
- CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)hContact, 0 );
- break;
- }
- case ID_POPUP_SENDMESSAGE:
- {
- HANDLE hContact = CreateTemporaryContactForItem(hwndDlg, wndData, wndData->iPopupItem);
-
- if (hContact)
- CallService(MS_MSG_SENDMESSAGE, (WPARAM)hContact, 0);
- break;
- }
- case IDC_USERMENU:
- {
- RECT rc;
- HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)wndData->mhContact, 0);
- GetWindowRect(GetDlgItem(hwndDlg,IDC_USERMENU), &rc);
- TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL);
- DestroyMenu(hMenu);
- break;
- }
- case IDC_HISTORY:
- CallService(MS_HISTORY_SHOWCONTACTHISTORY,(WPARAM)wndData->mhContact,0);
- break;
- case IDC_DETAILS:
- CallService(MS_USERINFO_SHOWDIALOG,(WPARAM)wndData->mhContact,0);
- break;
- case IDC_ADD:
- DialogAddContactExecute(hwndDlg, wndData->mhContact);
- break;
- }
- break;
- }
- case WM_CONTEXTMENU:
- {
- HWND hLV = GetDlgItem(hwndDlg, IDC_CONTACTS);
- LVHITTESTINFO lvh;
- RECT rt;
-
- wndData->iPopupItem = -1;
- if ((HWND)wParam != hLV) break; // if not our ListView go away
- lvh.pt.x = LOWORD(lParam);
- lvh.pt.y = HIWORD(lParam);
- if (GetWindowRect(hLV, &rt)==0) return FALSE; // ?? why this, some check ??
- ScreenToClient(hLV, &lvh.pt); // convert to ListView local coordinates
- int ci = ListView_HitTest(hLV, &lvh);
- if (ci==-1) break; // mouse is not over any item
- wndData->iPopupItem = ci;
- TrackPopupMenu(GetSubMenu(wndData->mhPopup, 0), TPM_LEFTALIGN|TPM_TOPALIGN, LOWORD(lParam), HIWORD(lParam), 0, hwndDlg, NULL);
- break;
- }
- case HM_EVENTSENT:
- {
- ACKDATA *ack=(ACKDATA*)lParam;
- if (ack->type!=ACKTYPE_SEARCH) break; // not search ack, go away
- if (ack->hProcess!=wndData->rhSearch) break; //not our search, go away
- if (ack->result==ACKRESULT_DATA)
- {
- HWND hLV = GetDlgItem(hwndDlg, IDC_CONTACTS);
- PROTOSEARCHRESULT* psr = (PROTOSEARCHRESULT*)ack->lParam;
- LVFINDINFO fi;
- fi.flags = LVFI_STRING;
- fi.psz = wndData->haUin;
- int iLPos = ListView_FindItem(hLV, -1, &fi);
- if (iLPos==-1) iLPos=0;
-// ListView_SetItemText(hLV, iLPos, 0, psr->email); // not sent by ICQ, and currently unsupported either
- if (strcmpnull(psr->nick, "") && psr->nick) ListView_SetItemText(hLV, iLPos, 1, psr->nick);
- ListView_SetItemText(hLV, iLPos, 2, psr->firstName);
- ListView_SetItemText(hLV, iLPos, 3, psr->lastName);
- break;
- }
- SAFE_FREE((void**)&wndData->haUin);
- break;
- }
- case WM_CLOSE: // user closed window, so destroy it
- {
- WindowList_Remove(ghRecvWindowList, hwndDlg);
- DestroyWindow(hwndDlg);
- break;
- }
- case WM_DESTROY: // last message received by this dialog, cleanup
- {
- db_event_markRead(wndData->mhContact, wndData->mhDbEvent);
- Utils_SaveWindowPosition(hwndDlg, NULL, MODULENAME, "");
- ImageList_Destroy(wndData->mhListIcon);
- UnhookEvent(wndData->hHook);
- DestroyMenu(wndData->mhPopup);
- for (int i=0; i < SIZEOF(wndData->hIcons); i++)
- DestroyIcon(wndData->hIcons[i]);
- delete wndData; // automatically calls destructor
- break;
- }
- case WM_MEASUREITEM:
- return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam);
-
- case WM_DRAWITEM:
- {
- DrawProtocolIcon(hwndDlg, lParam, wndData->mhContact);
- return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam);
- }
- case WM_SIZE:
- { // make the dlg resizeable
- UTILRESIZEDIALOG urd = {0};
-
- if (IsIconic(hwndDlg)) break;
- urd.cbSize = sizeof(urd);
- urd.hInstance = hInst;
- urd.hwndDlg = hwndDlg;
- urd.lParam = 0; // user-defined
- urd.lpTemplate = MAKEINTRESOURCEA(IDD_RECEIVE);
- urd.pfnResizer = RecvDlg_Resize;
- CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM) & urd);
- break;
- }
- case WM_GETMINMAXINFO:
- {
- MINMAXINFO* mmi=(MINMAXINFO*)lParam;
- mmi->ptMinTrackSize.x = 480+2*GetSystemMetrics(SM_CXSIZEFRAME);
- mmi->ptMinTrackSize.y = 130+2*GetSystemMetrics(SM_CYSIZEFRAME);
- break;
- }
- case DM_UPDATETITLE:
- {
- UpdateDialogTitle(hwndDlg, wndData?wndData->mhContact:NULL, "Contacts from");
- if (wndData)
- UpdateDialogAddButton(hwndDlg, wndData->mhContact);
- break;
- }
- }
- return FALSE;
+ TRecvContactsData* wndData = (TRecvContactsData*)GetWindowLongPtr(hwndDlg, DWLP_USER);
+
+ switch (msg) {
+ case WM_INITDIALOG:
+ {
+ CLISTEVENT* pcle = (CLISTEVENT*)lParam; /// got it
+
+ TranslateDialogDefault(hwndDlg);
+ WindowList_Add(ghRecvWindowList, hwndDlg, pcle->hContact);
+ SendMessageT(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(hInst, MAKEINTRESOURCE(IDI_CONTACTS)));
+ EnableDlgItem(hwndDlg, IDOK, FALSE);
+ EnableDlgItem(hwndDlg, IDDETAILS, FALSE);
+ wndData = new TRecvContactsData(pcle->hContact);
+ SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG)wndData);
+ wndData->mhDbEvent = pcle->hDbEvent; /// initialized, pcle not needed anymore
+ wndData->mhListIcon = ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),ILC_COLORDDB|ILC_MASK, 0, 1);
+ wndData->mhPopup = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTACTMENU));
+ TranslateMenu(wndData->mhPopup);
+ wndData->hHook = HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_EVENTSENT);
+
+ char *szProto =GetContactProto(wndData->mhContact);
+
+ HWND hLV = GetDlgItem(hwndDlg, IDC_CONTACTS);
+ ListView_SetExtendedListViewStyle(hLV, LVS_EX_CHECKBOXES|LVS_EX_FULLROWSELECT);
+ // add columns
+ RecvListView_AddColumn(hLV, 120, (char*)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDTEXT, 0), FALSE, 0);
+ RecvListView_AddColumn(hLV, 100, "Nick", TRUE, 1);
+ RecvListView_AddColumn(hLV, 100, "First Name", TRUE, 2);
+ RecvListView_AddColumn(hLV, 100, "Last Name", TRUE, 3);
+
+ // fill in groups
+ SendMessageT(GetDlgItem(hwndDlg, IDC_ENABLEGROUPS), BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
+ RebuildGroupCombo(hwndDlg);
+
+ { // fill listview with received contacts
+ DBEVENTINFO dbe = {0};
+
+ dbe.cbSize = sizeof(DBEVENTINFO);
+ dbe.cbBlob = db_event_getBlobSize(wndData->mhDbEvent);
+ if (dbe.cbBlob != -1) // this marks an invalid hDbEvent - all smashed anyway...
+ dbe.pBlob = (PBYTE)_alloca(dbe.cbBlob);
+ db_event_get(wndData->mhDbEvent, &dbe);
+ char* pcBlob = (char*)dbe.pBlob;
+ char* pcEnd = (char*)dbe.pBlob + dbe.cbBlob;
+
+ HICON hiProto = LoadContactProtoIcon(wndData->mhContact);
+ ImageList_AddIcon(wndData->mhListIcon, hiProto);
+ DestroyIcon(hiProto); // imagelist copied the resource
+ ListView_SetImageList(hLV, wndData->mhListIcon, LVSIL_SMALL);
+ LVITEM lvi = {0};
+ lvi.iImage = 0;
+ lvi.mask = LVIF_TEXT | LVIF_IMAGE;
+
+ for (int nItem = 0; ; nItem++)
+ { // Nick
+ int strsize = (int)strlennull(pcBlob);
+ TReceivedItem* pItem = wndData->AddReceivedItem();
+
+ if (dbe.flags & DBEF_UTF)
+ pItem->mcaNick = utf8_to_tchar((unsigned char*)pcBlob);
+ else
+ pItem->mcaNick = ansi_to_tchar(pcBlob);
+ pcBlob += strsize + 1;
+ // UIN
+ strsize = (int)strlennull(pcBlob);
+ pItem->mcaUIN = null_strdup(pcBlob);
+ pcBlob += strsize + 1;
+ // add to listview
+ lvi.iItem = nItem;
+ lvi.pszText = pItem->mcaUIN;
+ ListView_InsertItem(hLV, &lvi); // with image
+ ListView_SetItemTextT(hLV, nItem, 1, pItem->mcaNick);
+ // check for end of contacts
+ if (pcBlob >= pcEnd)
+ break;
+ }
+ }
+ // new dlg init
+ wndData->hIcons[0] = InitMButton(hwndDlg, IDC_ADD, MAKEINTRESOURCEA(IDI_ADDCONTACT), Translate("Add Contact Permanently to List"));
+ wndData->hIcons[1] = InitMButton(hwndDlg, IDC_DETAILS, MAKEINTRESOURCEA(IDI_USERDETAILS), Translate("View User's Details"));
+ wndData->hIcons[2] = InitMButton(hwndDlg, IDC_HISTORY, MAKEINTRESOURCEA(IDI_HISTORY), Translate("View User's History"));
+ wndData->hIcons[3] = InitMButton(hwndDlg, IDC_USERMENU, MAKEINTRESOURCEA(IDI_DOWNARROW), Translate("User Menu"));
+
+ SendMessageT(hwndDlg,DM_UPDATETITLE,0,0);
+ // new dialog init done
+ Utils_RestoreWindowPosition(hwndDlg, NULL, MODULENAME, "");
+ return TRUE;
+ }
+ case WM_NOTIFY:
+ if (((LPNMHDR)lParam)->idFrom == IDC_CONTACTS) {
+ switch (((LPNMHDR)lParam)->code) {
+ case NM_DBLCLK:
+ {
+ HWND hLV = GetDlgItem(hwndDlg, IDC_CONTACTS);
+ if (ListView_GetSelectedCount(hLV) != 1) break; // if not clicking on item, bye
+ wndData->iPopupItem = ListView_GetNextItem(hLV, -1, LVNI_ALL|LVNI_SELECTED);
+ if (wndData->iPopupItem == -1) break; // if no item selected no user details available
+ return SendMessageT(hwndDlg, WM_COMMAND, ID_POPUP_USERDETAILS, 0); // show user details
+ }
+ case LVN_ITEMCHANGED:
+ {
+ LPNMLISTVIEW pNMLV = (LPNMLISTVIEW)lParam;
+ HWND hLV = GetDlgItem(hwndDlg, IDC_CONTACTS); // optimisation, for FOR-Cycle
+ bool bExistsCheckedItem = false; // there must be no checked items to disable "Add" button
+
+ if (ListView_GetCheckState(hLV, pNMLV->iItem))
+ { // the user has checked this item
+ bExistsCheckedItem = true; // enable "Add" button
+ }
+ else
+ { // loop thru items and check if at least one is checked
+ for (int i = 0; i < ListView_GetItemCount(hLV); i++)
+ if (ListView_GetCheckState(hLV, i))
+ { // we found checked item, enable add, exit loop
+ bExistsCheckedItem = true;
+ break;
+ }
+ }
+ EnableDlgItem(hwndDlg, IDOK, bExistsCheckedItem);
+ EnableDlgItem(hwndDlg, IDDETAILS, ListView_GetSelectedCount(hLV) > 0);
+ break;
+ }
+ }
+ }
+ break;
+
+ case WM_COMMAND:
+ {
+ if (!lParam && CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)wndData->mhContact))
+ break;
+
+ switch(LOWORD(wParam))
+ {
+ case IDOK: // "Add Selected" button click
+ { // for each selected item, find its index in the hDbEvent
+ // and after that add this item to the DB permanently
+ char* caUIN;
+ HWND hLV = GetDlgItem(hwndDlg, IDC_CONTACTS);
+ HWND hGroupsCombo = GetDlgItem(hwndDlg, IDC_GROUPS);
+ HWND hGroupsCheck = GetDlgItem(hwndDlg, IDC_ENABLEGROUPS);
+ int curs = SendMessageT(hGroupsCombo, CB_GETCURSEL, 0, 0);
+ TCHAR* caGroup = NULL;
+ int nGroupId = -1;
+ if (curs != CB_ERR && IsWindowEnabled(hGroupsCheck) && SendMessageT(hGroupsCheck, BM_GETCHECK, 0, 0))
+ { //got groups, get the one selected in combo
+ TCHAR* caGroup = (TCHAR*)_alloca((SendMessageT(hGroupsCombo, CB_GETLBTEXTLEN, curs, 0) + 1) * sizeof(WCHAR));
+ SendMessageT(hGroupsCombo, CB_GETLBTEXT, curs, (LPARAM)caGroup);
+ nGroupId = SendMessageT(hGroupsCombo, CB_GETITEMDATA, curs, 0);
+ }
+
+ for (int i = 0; i < ListView_GetItemCount(hLV); i++)
+ if (ListView_GetCheckState(hLV, i))
+ { // found checked contact item, add it
+ caUIN = ListView_GetItemTextEx(hLV, i, 0);
+ for (int j = 0; j < wndData->cbReceived; j++) // determine item index in packet
+ if (!strcmpnull(wndData->maReceived[j]->mcaUIN, caUIN))
+ {
+ char* szProto =GetContactProto(wndData->mhContact);
+ HANDLE hContact = (HANDLE)CallProtoService(szProto, PS_ADDTOLISTBYEVENT, MAKEWPARAM(0, j), (LPARAM)wndData->mhDbEvent);
+ if (hContact && caGroup)
+ { // use newest group API if available
+ if (ServiceExists(MS_CLIST_CONTACTCHANGEGROUP))
+ CallService(MS_CLIST_CONTACTCHANGEGROUP, (WPARAM)hContact, (LPARAM)nGroupId);
+ else
+ DBWriteContactSettingStringT(hContact, "CList", "Group", caGroup);
+ }
+ break;
+ }
+ SAFE_FREE((void**)&caUIN);
+ } // move to next item
+ break;
+ }
+ case IDDETAILS:
+ { // for each selected item, find its index in the hDbEvent
+ // and after that add this item to the DB
+ // finally, request Details window for this hContact
+ HWND hLV = GetDlgItem(hwndDlg, IDC_CONTACTS);
+ for (int i = 0; i < ListView_GetItemCount(hLV); i++)
+ if (ListView_GetItemState(hLV, i, LVIS_SELECTED)) {
+ HANDLE hContact = CreateTemporaryContactForItem(hwndDlg, wndData, i);
+ if (hContact)
+ CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)hContact, 0);
+ }
+ break;
+ }
+ case IDCANCEL:
+ {
+ SendMessageT(hwndDlg, WM_CLOSE, 0, 0);
+ break;
+ }
+ case IDC_ENABLEGROUPS:
+ {
+ EnableGroupCombo(hwndDlg);
+ break;
+ }
+ case IDC_GROUPS:
+ // rebuild group list on popup
+ if (HIWORD(wParam) == CBN_DROPDOWN)
+ RebuildGroupCombo(hwndDlg);
+ break;
+
+ case ID_POPUP_ADDUSER:
+ {
+ HANDLE hContact = CreateTemporaryContactForItem(hwndDlg, wndData, wndData->iPopupItem);
+ if (hContact)
+ DialogAddContactExecute(hwndDlg, hContact);
+ break;
+ }
+ case ID_POPUP_USERDETAILS:
+ {
+ HANDLE hContact = CreateTemporaryContactForItem(hwndDlg, wndData, wndData->iPopupItem);
+ if (hContact)
+ CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)hContact, 0 );
+ break;
+ }
+ case ID_POPUP_SENDMESSAGE:
+ {
+ HANDLE hContact = CreateTemporaryContactForItem(hwndDlg, wndData, wndData->iPopupItem);
+ if (hContact)
+ CallService(MS_MSG_SENDMESSAGE, (WPARAM)hContact, 0);
+ break;
+ }
+ case IDC_USERMENU:
+ {
+ RECT rc;
+ HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)wndData->mhContact, 0);
+ GetWindowRect(GetDlgItem(hwndDlg,IDC_USERMENU), &rc);
+ TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL);
+ DestroyMenu(hMenu);
+ break;
+ }
+ case IDC_HISTORY:
+ CallService(MS_HISTORY_SHOWCONTACTHISTORY,(WPARAM)wndData->mhContact,0);
+ break;
+
+ case IDC_DETAILS:
+ CallService(MS_USERINFO_SHOWDIALOG,(WPARAM)wndData->mhContact,0);
+ break;
+
+ case IDC_ADD:
+ DialogAddContactExecute(hwndDlg, wndData->mhContact);
+ break;
+ }
+ break;
+ }
+ case WM_CONTEXTMENU:
+ {
+ HWND hLV = GetDlgItem(hwndDlg, IDC_CONTACTS);
+ LVHITTESTINFO lvh;
+ RECT rt;
+
+ wndData->iPopupItem = -1;
+ if ((HWND)wParam != hLV) break; // if not our ListView go away
+ lvh.pt.x = LOWORD(lParam);
+ lvh.pt.y = HIWORD(lParam);
+ if (GetWindowRect(hLV, &rt)==0) return FALSE; // ?? why this, some check ??
+ ScreenToClient(hLV, &lvh.pt); // convert to ListView local coordinates
+ int ci = ListView_HitTest(hLV, &lvh);
+ if (ci==-1) break; // mouse is not over any item
+ wndData->iPopupItem = ci;
+ TrackPopupMenu(GetSubMenu(wndData->mhPopup, 0), TPM_LEFTALIGN|TPM_TOPALIGN, LOWORD(lParam), HIWORD(lParam), 0, hwndDlg, NULL);
+ break;
+ }
+ case HM_EVENTSENT:
+ {
+ ACKDATA *ack=(ACKDATA*)lParam;
+ if (ack->type!=ACKTYPE_SEARCH) break; // not search ack, go away
+ if (ack->hProcess!=wndData->rhSearch) break; //not our search, go away
+ if (ack->result==ACKRESULT_DATA)
+ {
+ HWND hLV = GetDlgItem(hwndDlg, IDC_CONTACTS);
+ PROTOSEARCHRESULT* psr = (PROTOSEARCHRESULT*)ack->lParam;
+ LVFINDINFO fi;
+ fi.flags = LVFI_STRING;
+ fi.psz = wndData->haUin;
+ int iLPos = ListView_FindItem(hLV, -1, &fi);
+ if (iLPos==-1) iLPos=0;
+ // ListView_SetItemText(hLV, iLPos, 0, psr->email); // not sent by ICQ, and currently unsupported either
+ if (strcmpnull(psr->nick, "") && psr->nick) ListView_SetItemText(hLV, iLPos, 1, psr->nick);
+ ListView_SetItemText(hLV, iLPos, 2, psr->firstName);
+ ListView_SetItemText(hLV, iLPos, 3, psr->lastName);
+ break;
+ }
+ SAFE_FREE((void**)&wndData->haUin);
+ break;
+ }
+ case WM_CLOSE: // user closed window, so destroy it
+ WindowList_Remove(ghRecvWindowList, hwndDlg);
+ DestroyWindow(hwndDlg);
+ break;
+
+ case WM_DESTROY: // last message received by this dialog, cleanup
+ {
+ db_event_markRead(wndData->mhContact, wndData->mhDbEvent);
+ Utils_SaveWindowPosition(hwndDlg, NULL, MODULENAME, "");
+ ImageList_Destroy(wndData->mhListIcon);
+ UnhookEvent(wndData->hHook);
+ DestroyMenu(wndData->mhPopup);
+ for (int i=0; i < SIZEOF(wndData->hIcons); i++)
+ DestroyIcon(wndData->hIcons[i]);
+ delete wndData; // automatically calls destructor
+ break;
+ }
+ case WM_MEASUREITEM:
+ return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam);
+
+ case WM_DRAWITEM:
+ DrawProtocolIcon(hwndDlg, lParam, wndData->mhContact);
+ return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam);
+
+ case WM_SIZE:
+ { // make the dlg resizeable
+ UTILRESIZEDIALOG urd = {0};
+
+ if (IsIconic(hwndDlg)) break;
+ urd.cbSize = sizeof(urd);
+ urd.hInstance = hInst;
+ urd.hwndDlg = hwndDlg;
+ urd.lParam = 0; // user-defined
+ urd.lpTemplate = MAKEINTRESOURCEA(IDD_RECEIVE);
+ urd.pfnResizer = RecvDlg_Resize;
+ CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM) & urd);
+ break;
+ }
+ case WM_GETMINMAXINFO:
+ {
+ MINMAXINFO* mmi=(MINMAXINFO*)lParam;
+ mmi->ptMinTrackSize.x = 480+2*GetSystemMetrics(SM_CXSIZEFRAME);
+ mmi->ptMinTrackSize.y = 130+2*GetSystemMetrics(SM_CYSIZEFRAME);
+ break;
+ }
+ case DM_UPDATETITLE:
+ UpdateDialogTitle(hwndDlg, wndData?wndData->mhContact:NULL, "Contacts from");
+ if (wndData)
+ UpdateDialogAddButton(hwndDlg, wndData->mhContact);
+ break;
+ }
+ return FALSE;
}
diff --git a/plugins/FavContacts/src/headers.h b/plugins/FavContacts/src/headers.h
index e5e6f21412..4b12d2ba63 100644
--- a/plugins/FavContacts/src/headers.h
+++ b/plugins/FavContacts/src/headers.h
@@ -34,6 +34,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <m_database.h>
#include <m_langpack.h>
#include <m_clist.h>
+#include <m_clistint.h>
#include <m_clc.h>
#include <m_protosvc.h>
#include <m_skin.h>
diff --git a/plugins/FavContacts/src/main.cpp b/plugins/FavContacts/src/main.cpp
index 0081078862..d39b41a63b 100644
--- a/plugins/FavContacts/src/main.cpp
+++ b/plugins/FavContacts/src/main.cpp
@@ -20,6 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "headers.h"
+CLIST_INTERFACE *pcli;
+
HINSTANCE g_hInst;
int hLangpack;
@@ -349,79 +351,19 @@ static void sttSaveOptions()
db_set_w(NULL, "FavContacts", "MaxRecent", g_Options.wMaxRecent);
}
-static bool sttIsGroup(int id)
-{
- if (id == 1) return true;
-
- DBVARIANT dbv = {0};
- char buf[32];
- mir_snprintf(buf, SIZEOF(buf), "%d", (int)(id - 2));
- if (!db_get_ts(NULL, "CListGroups", buf, &dbv))
- {
- db_free(&dbv);
- return true;
- }
- return false;
-}
-
-static TCHAR *sttGetGroupName(int id)
-{
- if (id == 1)
- {
- if (g_Options.bUseGroups)
- return mir_tstrdup(TranslateT("<No group>"));
- return mir_tstrdup(TranslateT("Favourite Contacts"));
- }
-
- DBVARIANT dbv = {0};
- char buf[32];
- mir_snprintf(buf, SIZEOF(buf), "%d", (int)(id - 2));
- if (!db_get_ts(NULL, "CListGroups", buf, &dbv))
- {
- TCHAR *res = mir_tstrdup(dbv.ptszVal+1);
- db_free(&dbv);
- return res;
- }
- return NULL;
-}
-
-static int sttGetGroupId(TCHAR *name)
-{
- for (int i = 0; ; ++i)
- {
- DBVARIANT dbv = {0};
- char buf[32];
- mir_snprintf(buf, SIZEOF(buf), "%d", (int)i);
- if (!db_get_ts(NULL, "CListGroups", buf, &dbv))
- {
- if (!lstrcmp(dbv.ptszVal+1, name))
- {
- db_free(&dbv);
- return i+2;
- }
-
- db_free(&dbv);
- } else
- {
- // default is root
- return 1;
- }
- }
-}
-
static BOOL sttMeasureItem_Group(LPMEASUREITEMSTRUCT lpmis, Options *options)
{
if (true)
{
HDC hdc = GetDC(g_hwndMenuHost);
HFONT hfntSave = (HFONT)SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));
- TCHAR *name = sttGetGroupName(lpmis->itemData);
+ TCHAR *name = pcli->pfnGetGroupName(lpmis->itemData-1, NULL);
SIZE sz;
- if (!options->bSysColors) SelectObject(hdc, g_Options.hfntName);
+ if (!options->bSysColors)
+ SelectObject(hdc, g_Options.hfntName);
GetTextExtentPoint32(hdc, name, lstrlen(name), &sz);
lpmis->itemHeight = sz.cy + 8;
lpmis->itemWidth = sz.cx + 10;
- mir_free(name);
SelectObject(hdc, hfntSave);
ReleaseDC(g_hwndMenuHost, hdc);
}
@@ -511,7 +453,7 @@ static BOOL sttMeasureItem(LPMEASUREITEMSTRUCT lpmis, Options *options=NULL)
return FALSE;
BOOL res = FALSE;
- if (sttIsGroup(lpmis->itemData))
+ if ( pcli->pfnGetGroupName(lpmis->itemData-1, 0))
res = sttMeasureItem_Group(lpmis, options);
else if (CallService(MS_DB_CONTACT_IS, lpmis->itemData, 0))
res = sttMeasureItem_Contact(lpmis, options);
@@ -529,8 +471,7 @@ static BOOL sttDrawItem_Group(LPDRAWITEMSTRUCT lpdis, Options *options = NULL)
HFONT hfntSave = (HFONT)SelectObject(lpdis->hDC, GetStockObject(DEFAULT_GUI_FONT));
SetBkMode(lpdis->hDC, TRANSPARENT);
- if (options->bSysColors)
- {
+ if (options->bSysColors) {
FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_HIGHLIGHT));
SetTextColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
}
@@ -538,18 +479,14 @@ static BOOL sttDrawItem_Group(LPDRAWITEMSTRUCT lpdis, Options *options = NULL)
HBRUSH hbr = CreateSolidBrush(g_Options.clBackSel);
FillRect(lpdis->hDC, &lpdis->rcItem, hbr);
DeleteObject(hbr);
- //hbr = CreateSolidBrush(g_Options.clBackSel);
- //FrameRect(lpdis->hDC, &lpdis->rcItem, hbr);
- //DeleteObject(hbr);
SetTextColor(lpdis->hDC, g_Options.clLine1Sel);
}
- if (true)
- {
- TCHAR *name = sttGetGroupName(lpdis->itemData);
- if (!options->bSysColors) SelectObject(lpdis->hDC, g_Options.hfntName);
+ if (true) {
+ TCHAR *name = pcli->pfnGetGroupName(lpdis->itemData-1, NULL);
+ if (!options->bSysColors)
+ SelectObject(lpdis->hDC, g_Options.hfntName);
DrawText(lpdis->hDC, name, lstrlen(name), &lpdis->rcItem, DT_NOPREFIX|DT_SINGLELINE|DT_VCENTER|DT_CENTER);
- mir_free(name);
}
SelectObject(lpdis->hDC, hfntSave);
@@ -561,10 +498,9 @@ void ImageList_DrawDimmed(HIMAGELIST himl, int i, HDC hdc, int left, int top, UI
{
typedef BOOL (WINAPI *TFnAlphaBlend)(HDC, int, int, int, int, HDC, int, int, int, int, BLENDFUNCTION);
static TFnAlphaBlend pfnAlphaBlend = NULL;
- bool load_funcs = true;
- if (load_funcs)
- {
+ bool load_funcs = true;
+ if (load_funcs) {
pfnAlphaBlend = (TFnAlphaBlend)GetProcAddress(GetModuleHandleA("msimg32"), "AlphaBlend");
load_funcs = false;
}
@@ -577,13 +513,12 @@ void ImageList_DrawDimmed(HIMAGELIST himl, int i, HDC hdc, int left, int top, UI
HBITMAP hbmOld = (HBITMAP)SelectObject(dcMem, hbm);
BitBlt(dcMem, 0, 0, dx, dx, hdc, left, top, SRCCOPY);
ImageList_Draw(himl, i, dcMem, 0, 0, fStyle);
- if (pfnAlphaBlend)
- {
+ if (pfnAlphaBlend) {
BLENDFUNCTION bf = {0};
bf.SourceConstantAlpha = 180;
pfnAlphaBlend(hdc, left, top, dx, dy, dcMem, 0, 0, dx, dy, bf);
- } else
- {
+ }
+ else {
SetStretchBltMode(hdc, HALFTONE);
StretchBlt(hdc, left, top, dx, dy, dcMem, 0, 0, dx, dy, SRCCOPY);
}
@@ -606,42 +541,37 @@ static BOOL sttDrawItem_Contact(LPDRAWITEMSTRUCT lpdis, Options *options = NULL)
HFONT hfntSave = (HFONT)SelectObject(hdcTemp, GetStockObject(DEFAULT_GUI_FONT));
SetBkMode(hdcTemp, TRANSPARENT);
COLORREF clBack, clLine1, clLine2;
- if (lpdis->itemState & ODS_SELECTED)
- {
- if (options->bSysColors)
- {
+ if (lpdis->itemState & ODS_SELECTED) {
+ if (options->bSysColors) {
FillRect(hdcTemp, &lpdis->rcItem, GetSysColorBrush(COLOR_HIGHLIGHT));
clBack = GetSysColor(COLOR_HIGHLIGHT);
clLine1 = GetSysColor(COLOR_HIGHLIGHTTEXT);
- } else
- {
+ }
+ else {
clBack = g_Options.clBackSel;
clLine1 = g_Options.clLine1Sel;
clLine2 = g_Options.clLine2Sel;
}
- } else
- {
- if (options->bSysColors)
- {
+ }
+ else {
+ if (options->bSysColors) {
FillRect(hdcTemp, &lpdis->rcItem, GetSysColorBrush(COLOR_MENU));
clBack = GetSysColor(COLOR_MENU);
clLine1 = GetSysColor(COLOR_MENUTEXT);
- } else
- {
+ }
+ else {
clBack = g_Options.clBack;
clLine1 = g_Options.clLine1;
clLine2 = g_Options.clLine2;
}
}
- if (options->bSysColors)
- {
+ if (options->bSysColors) {
clLine2 = RGB(
(GetRValue(clLine1) * 66UL + GetRValue(clBack) * 34UL) / 100,
(GetGValue(clLine1) * 66UL + GetGValue(clBack) * 34UL) / 100,
- (GetBValue(clLine1) * 66UL + GetBValue(clBack) * 34UL) / 100
- );
- } else
- {
+ (GetBValue(clLine1) * 66UL + GetBValue(clBack) * 34UL) / 100);
+ }
+ else {
HBRUSH hbr = CreateSolidBrush(clBack);
FillRect(hdcTemp, &lpdis->rcItem, hbr);
DeleteObject(hbr);
@@ -655,38 +585,31 @@ static BOOL sttDrawItem_Contact(LPDRAWITEMSTRUCT lpdis, Options *options = NULL)
char *proto = GetContactProto(hContact);
- if (true)
- {
- HIMAGELIST hIml = (HIMAGELIST)CallService(MS_CLIST_GETICONSIMAGELIST, 0, 0);
- int iIcon = CallService(MS_CLIST_GETCONTACTICON, (WPARAM)hContact, 0);
+ HIMAGELIST hIml = (HIMAGELIST)CallService(MS_CLIST_GETICONSIMAGELIST, 0, 0);
+ int iIcon = CallService(MS_CLIST_GETCONTACTICON, (WPARAM)hContact, 0);
- if (db_get_dw(hContact, proto, "IdleTS", 0))
- {
- ImageList_DrawDimmed(hIml, iIcon, hdcTemp,
- lpdis->rcItem.left, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2,
- ILD_TRANSPARENT);
- } else
- {
- ImageList_Draw(hIml, iIcon, hdcTemp,
- lpdis->rcItem.left, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2,
- ILD_TRANSPARENT);
- }
-
- lpdis->rcItem.left += 20;
+ if (db_get_dw(hContact, proto, "IdleTS", 0)) {
+ ImageList_DrawDimmed(hIml, iIcon, hdcTemp,
+ lpdis->rcItem.left, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2,
+ ILD_TRANSPARENT);
+ }
+ else {
+ ImageList_Draw(hIml, iIcon, hdcTemp,
+ lpdis->rcItem.left, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2,
+ ILD_TRANSPARENT);
}
- if (options->wMaxRecent && db_get_b(hContact, "FavContacts", "IsFavourite", 0))
- {
+ lpdis->rcItem.left += 20;
+
+ if (options->wMaxRecent && db_get_b(hContact, "FavContacts", "IsFavourite", 0)) {
DrawIconEx(hdcTemp, lpdis->rcItem.right - 18, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2,
Skin_GetIconByHandle(iconList[0].hIcolib), 16, 16, 0, NULL, DI_NORMAL);
lpdis->rcItem.right -= 20;
}
- if (options->bAvatars)
- {
+ if (options->bAvatars) {
AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)hContact, 0);
- if (ace && (ace != (AVATARCACHEENTRY *)CALLSERVICE_NOTFOUND))
- {
+ if (ace && (ace != (AVATARCACHEENTRY *)CALLSERVICE_NOTFOUND)) {
int avatarWidth = lpdis->rcItem.bottom - lpdis->rcItem.top;
if (ace->bmWidth < ace->bmHeight)
avatarWidth = (lpdis->rcItem.bottom - lpdis->rcItem.top) * ace->bmWidth / ace->bmHeight;
@@ -701,14 +624,12 @@ static BOOL sttDrawItem_Contact(LPDRAWITEMSTRUCT lpdis, Options *options = NULL)
else
avdr.rcDraw.right = avdr.rcDraw.left + avatarWidth;
avdr.dwFlags = AVDRQ_FALLBACKPROTO;
- if (options->bAvatarBorder)
- {
+ if (options->bAvatarBorder) {
avdr.dwFlags |= AVDRQ_DRAWBORDER;
avdr.clrBorder = clLine1;
if (options->bNoTransparentBorder)
avdr.dwFlags |= AVDRQ_HIDEBORDERONTRANSPARENCY;
- if (options->wAvatarRadius)
- {
+ if (options->wAvatarRadius) {
avdr.dwFlags |= AVDRQ_ROUNDEDCORNER;
avdr.radius = (unsigned char)options->wAvatarRadius;
}
@@ -723,8 +644,7 @@ static BOOL sttDrawItem_Contact(LPDRAWITEMSTRUCT lpdis, Options *options = NULL)
}
}
- if (true)
- {
+ if (true) {
TCHAR *name = (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR);
if (!options->bSysColors) SelectObject(hdcTemp, g_Options.hfntName);
@@ -735,17 +655,15 @@ static BOOL sttDrawItem_Contact(LPDRAWITEMSTRUCT lpdis, Options *options = NULL)
lpdis->rcItem.top += sz.cy + 3;
}
- if (options->bSecondLine)
- {
+ if (options->bSecondLine) {
DBVARIANT dbv;
TCHAR *title;
bool bFree = false;
- if (db_get_ts(hContact, "CList", "StatusMsg", &dbv) || !*dbv.ptszVal)
- {
+ if (db_get_ts(hContact, "CList", "StatusMsg", &dbv) || !*dbv.ptszVal) {
int status = db_get_w(hContact, proto, "Status", ID_STATUS_OFFLINE);
title = (TCHAR *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, status, GSMDF_TCHAR);
- } else
- {
+ }
+ else {
title = dbv.ptszVal;
bFree = true;
}
@@ -778,7 +696,7 @@ static BOOL sttDrawItem(LPDRAWITEMSTRUCT lpdis, Options *options=NULL)
if (!lpdis->itemData)
return FALSE;
- if (sttIsGroup(lpdis->itemData))
+ if ( pcli->pfnGetGroupName(lpdis->itemData-1, NULL))
return sttDrawItem_Group(lpdis, options);
if (CallService(MS_DB_CONTACT_IS, lpdis->itemData, 0))
@@ -903,7 +821,7 @@ int sttShowMenu(bool centered)
szColumn.cx = szColumn.cy = 0;
}
- DWORD groupID = sttGetGroupId(favList[i]->getGroup());
+ DWORD groupID = (DWORD)Clist_GroupExists(favList[i]->getGroup())+1;
AppendMenu(hMenu,
MF_OWNERDRAW|MF_SEPARATOR| ((prevGroup && g_Options.bUseColumns) ? MF_MENUBREAK : 0),
diff --git a/plugins/MetaContacts/src/meta_services.cpp b/plugins/MetaContacts/src/meta_services.cpp
index 8e27411d78..79eb2d3f1c 100755
--- a/plugins/MetaContacts/src/meta_services.cpp
+++ b/plugins/MetaContacts/src/meta_services.cpp
@@ -599,11 +599,6 @@ int Meta_SettingChanged(WPARAM wParam, LPARAM lParam)
Meta_SuppressStatus(options.suppress_status);
}
- if (wParam == 0 && strcmp(dcws->szModule, "CListGroups") == 0 && dcws->value.type != DBVT_DELETED && strcmp(dcws->value.pszVal, META_HIDDEN_GROUP) == 0)
- {
- // someone is creating our hidden group!!
- }
-
// from here on, we're just interested in contact settings
if (wParam == 0) return 0;
diff --git a/plugins/Non-IM Contact/src/commonheaders.h b/plugins/Non-IM Contact/src/commonheaders.h
index 8dad5c498a..ca593df8ab 100644
--- a/plugins/Non-IM Contact/src/commonheaders.h
+++ b/plugins/Non-IM Contact/src/commonheaders.h
@@ -33,6 +33,7 @@ struct DLGTEMPLATEEX
#include <newpluginapi.h>
#include <m_clist.h>
+#include <m_clistint.h>
#include <m_clui.h>
#include <m_skin.h>
#include <m_langpack.h>
diff --git a/plugins/Non-IM Contact/src/contactinfo.cpp b/plugins/Non-IM Contact/src/contactinfo.cpp
index daf3f96ce4..c55ea4f159 100644
--- a/plugins/Non-IM Contact/src/contactinfo.cpp
+++ b/plugins/Non-IM Contact/src/contactinfo.cpp
@@ -78,32 +78,6 @@ LRESULT CALLBACK ButtWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
return res;
}
-void checkGroups(TCHAR* group)
-{
- if (lstrlen(group) < 1)
- return;
-
- char str[50];
- int i;
- for (i=0;; i++) {
- _itoa(i, str, 10);
- DBVARIANT dbv;
- if (db_get_ts(NULL, "CListGroups", str, &dbv))
- break;
-
- bool bFound = lstrcmpi(dbv.ptszVal+1, group) == 0;
- db_free(&dbv);
- if (bFound)
- return;
- }
-
- TCHAR name[256];
- name[0] = 1 | GROUPF_EXPANDED;
- _tcsncpy(name+1, group, SIZEOF(name)-1);
- db_set_ts(NULL, "CListGroups", str, name);
- CallService(MS_CLUI_GROUPADDED, i+1, 0);
-}
-
int BrowseForFolder(HWND hwnd,char *szPath)
{
int result=0;
@@ -138,8 +112,7 @@ INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
switch(msg) {
case WM_INITDIALOG:
{
- int i = 0;
- DBVARIANT dbv;
+ int i;
char string[512];
HANDLE hContact = (HANDLE)((PROPSHEETPAGE*)lParam)->lParam;
TranslateDialogDefault(hwnd);
@@ -155,16 +128,11 @@ INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
SetDlgItemTextA(hwnd, IDC_PARAMS, string);
/* group*/
- while (i != -1) {
- char str[3];
- mir_snprintf(str, SIZEOF(str), "%d", i);
- if (!db_get_ts(NULL, "CListGroups", str, &dbv)) {
- SendMessage(GetDlgItem(hwnd, IDC_GROUP), CB_INSERTSTRING,0, LPARAM(dbv.ptszVal+1));
- db_free(&dbv);
- i++;
- }
- else i = -1;
- }
+ TCHAR *szGroup;
+ for (i=1; (szGroup = pcli->pfnGetGroupName(i, NULL)) != NULL; i++)
+ SendMessage(GetDlgItem(hwnd, IDC_GROUP), CB_INSERTSTRING,0, LPARAM(szGroup));
+
+ DBVARIANT dbv;
if (!db_get(hContact, "CList", "Group", &dbv))
SetDlgItemTextA(hwnd, IDC_GROUP, dbv.pszVal);
@@ -268,7 +236,7 @@ INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
if (GetWindowTextLength(GetDlgItem(hwnd,IDC_GROUP))) {
TCHAR text[512];
GetDlgItemText(hwnd, IDC_GROUP, text, SIZEOF(text));
- checkGroups(text);
+ Clist_CreateGroup(NULL, text);
db_set_ts(hContact, "CList", "Group", text);
}
else db_unset(hContact, "CList", "Group");
@@ -595,7 +563,7 @@ INT_PTR ImportContacts(WPARAM wParam, LPARAM lParam)
}
else if (contactDone && !strcmp(line,"[/Non-IM Contact]\r\n")) {
if (!name) continue;
- int size = strlen(name) + strlen("Do you want to import this Non-IM Contact?\r\n\r\nName: \r\n") + 1;
+ size_t size = strlen(name) + strlen("Do you want to import this Non-IM Contact?\r\n\r\nName: \r\n") + 1;
char *msg = (char*)malloc(size);
mir_snprintf(msg, size, "Do you want to import this Non-IM Contact?\r\n\r\nName: %s\r\n", name);
if (program) {
diff --git a/plugins/Non-IM Contact/src/main.cpp b/plugins/Non-IM Contact/src/main.cpp
index 02df17e56d..a2a9537b88 100644
--- a/plugins/Non-IM Contact/src/main.cpp
+++ b/plugins/Non-IM Contact/src/main.cpp
@@ -6,6 +6,7 @@
#include "Version.h"
+CLIST_INTERFACE *pcli;
HINSTANCE hInst;
int hLangpack;
@@ -122,6 +123,7 @@ IconItem icoList[] =
extern "C" __declspec(dllexport) int Load()
{
mir_getLP(&pluginInfoEx);
+ mir_getCLI();
Icon_Register(hInst, LPGEN("Non-IM Contact"), icoList, SIZEOF(icoList));
diff --git a/plugins/StopSpamMod/src/options.cpp b/plugins/StopSpamMod/src/options.cpp
index c38dd8f771..4205a6a19b 100755
--- a/plugins/StopSpamMod/src/options.cpp
+++ b/plugins/StopSpamMod/src/options.cpp
@@ -1,414 +1,388 @@
-/* Copyright (C) Miklashevsky Roman, sss, elzor
-*
-* 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; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "headers.h"
-
-char * pluginDescription = LPGEN("No more spam! Robots can't go! Only human beings invited!\r\n\r\nThis plugin works pretty simple:\r\nWhile messages from users on your contact list go as there is no any anti-spam software, messages from unknown users are not delivered to you. But also they are not ignored, this plugin replies with a simple question, and if user gives the right answer plugin adds him to your contact list so that he can contact you.");
-TCHAR const * defQuestion = TranslateT("Spammers made me to install small anti-spam system you are now speaking with.\r\nPlease reply \"nospam\" without quotes and spaces if you want to contact me.");
-
-INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- switch(msg)
- {
- case WM_INITDIALOG:
- {
- SetDlgItemTextA(hwnd, ID_DESCRIPTION, pluginDescription);
- TranslateDialogDefault(hwnd);
- SetDlgItemInt(hwnd, ID_MAXQUESTCOUNT, gbMaxQuestCount, FALSE);
- SendDlgItemMessage(hwnd, ID_INFTALKPROT, BM_SETCHECK, gbInfTalkProtection ? BST_CHECKED : BST_UNCHECKED, 0);
- SendDlgItemMessage(hwnd, ID_ADDPERMANENT, BM_SETCHECK, gbAddPermanent ? BST_CHECKED : BST_UNCHECKED, 0);
- SendDlgItemMessage(hwnd, ID_HANDLEAUTHREQ, BM_SETCHECK, gbHandleAuthReq ? BST_CHECKED : BST_UNCHECKED, 0);
- SendDlgItemMessage(hwnd, ID_HIDECONTACTS, BM_SETCHECK, gbHideContacts ? BST_CHECKED : BST_UNCHECKED, 0);
- SendDlgItemMessage(hwnd, ID_IGNORESPAMMERS, BM_SETCHECK, gbIgnoreContacts ? BST_CHECKED : BST_UNCHECKED, 0);
- SendDlgItemMessage(hwnd, ID_LOGSPAMTOFILE, BM_SETCHECK, gbLogToFile ? BST_CHECKED : BST_UNCHECKED, 0);
- }
- return TRUE;
- case WM_COMMAND:{
- switch (LOWORD(wParam))
- {
- case ID_MAXQUESTCOUNT:
- {
- if (EN_CHANGE != HIWORD(wParam) || (HWND)lParam != GetFocus())
- return FALSE;
- break;
- }
- }
- SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- }
- break;
- case WM_NOTIFY:
- {
- NMHDR* nmhdr = (NMHDR*)lParam;
- switch (nmhdr->code)
- {
- case PSN_APPLY:
- {
- db_set_dw(NULL, pluginName, "maxQuestCount", gbMaxQuestCount = GetDlgItemInt(hwnd, ID_MAXQUESTCOUNT, NULL, FALSE));
- db_set_b(NULL, pluginName, "infTalkProtection", gbInfTalkProtection = BST_CHECKED == SendDlgItemMessage(hwnd, ID_INFTALKPROT, BM_GETCHECK, 0, 0));
- db_set_b(NULL, pluginName, "addPermanent", gbAddPermanent = BST_CHECKED == SendDlgItemMessage(hwnd, ID_ADDPERMANENT, BM_GETCHECK, 0, 0));
- db_set_b(NULL, pluginName, "handleAuthReq", gbHandleAuthReq = BST_CHECKED == SendDlgItemMessage(hwnd, ID_HANDLEAUTHREQ, BM_GETCHECK, 0, 0));
- db_set_b(NULL, pluginName, "HideContacts", gbHideContacts = BST_CHECKED == SendDlgItemMessage(hwnd, ID_HIDECONTACTS, BM_GETCHECK, 0, 0));
- db_set_b(NULL, pluginName, "IgnoreContacts", gbIgnoreContacts = BST_CHECKED == SendDlgItemMessage(hwnd, ID_IGNORESPAMMERS, BM_GETCHECK, 0, 0));
- db_set_b(NULL, pluginName, "LogSpamToFile", gbLogToFile = BST_CHECKED == SendDlgItemMessage(hwnd, ID_LOGSPAMTOFILE, BM_GETCHECK, 0, 0));
- }
- return TRUE;
- }
- }
- break;
- }
- return FALSE;
-}
-
-INT_PTR CALLBACK MessagesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
-
- switch(msg)
- {
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwnd);
- SetDlgItemText(hwnd, ID_QUESTION, gbQuestion.c_str());
- SetDlgItemText(hwnd, ID_ANSWER, gbAnswer.c_str());
- SetDlgItemText(hwnd, ID_CONGRATULATION, gbCongratulation.c_str());
- SetDlgItemText(hwnd, ID_AUTHREPL, gbAuthRepl.c_str());
- EnableWindow(GetDlgItem(hwnd, ID_ANSWER), !gbMathExpression);
- variables_skin_helpbutton(hwnd, IDC_VARS);
- gbVarsServiceExist?EnableWindow(GetDlgItem(hwnd, IDC_VARS),1):EnableWindow(GetDlgItem(hwnd, IDC_VARS),0);
- }
- return TRUE;
- case WM_COMMAND:
- {
- switch(LOWORD(wParam))
- {
- case ID_QUESTION:
- case ID_ANSWER:
- case ID_AUTHREPL:
- case ID_CONGRATULATION:
- {
- if (EN_CHANGE != HIWORD(wParam) || (HWND)lParam != GetFocus())
- return FALSE;
- break;
- }
- case ID_RESTOREDEFAULTS:
- SetDlgItemText(hwnd, ID_QUESTION, defQuestion);
- SetDlgItemText(hwnd, ID_ANSWER, TranslateT("nospam"));
- SetDlgItemText(hwnd, ID_AUTHREPL, TranslateT("StopSpam: send a message and reply to a anti-spam bot question."));
- SetDlgItemText(hwnd, ID_CONGRATULATION, TranslateT("Congratulations! You just passed human/robot test. Now you can write me a message."));
- SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- return TRUE;
- case IDC_VARS:
- variables_showhelp(hwnd, msg, VHF_FULLDLG|VHF_SETLASTSUBJECT, NULL, NULL);
- return TRUE;
- }
- SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- }
- break;
- case WM_NOTIFY:
- {
- NMHDR* nmhdr = (NMHDR*)lParam;
- switch (nmhdr->code)
- {
- case PSN_APPLY:
- {
- db_set_ws(NULL, pluginName, "question", GetDlgItemString(hwnd, ID_QUESTION).c_str());
- gbQuestion = DBGetContactSettingStringPAN(NULL, pluginName, "question", defQuestion);
- db_set_ws(NULL, pluginName, "answer", GetDlgItemString(hwnd, ID_ANSWER).c_str());
- gbAnswer = DBGetContactSettingStringPAN(NULL, pluginName, "answer", TranslateT("nospam"));
- db_set_ws(NULL, pluginName, "authrepl", GetDlgItemString(hwnd, ID_AUTHREPL).c_str());
- gbAuthRepl = DBGetContactSettingStringPAN(NULL, pluginName, "authrepl", TranslateT("StopSpam: send a message and reply to a anti-spam bot question."));
- db_set_ws(NULL, pluginName, "congratulation", GetDlgItemString(hwnd, ID_CONGRATULATION).c_str());
- gbCongratulation = DBGetContactSettingStringPAN(NULL, pluginName, "congratulation", TranslateT("Congratulations! You just passed human/robot test. Now you can write me a message."));
- }
- return TRUE;
- }
- }
- break;
- }
- return FALSE;
-}
-
-INT_PTR CALLBACK ProtoDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- switch(msg)
- {
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwnd);
- int n;
- PROTOACCOUNT **pppd;
- if(!ProtoEnumAccounts(&n, &pppd))
- for (int i = 0; i < n; ++i) {
- SendDlgItemMessageA(hwnd, (ProtoInList(pppd[i]->szModuleName) ? ID_USEDPROTO : ID_ALLPROTO), LB_ADDSTRING, 0, (LPARAM)pppd[i]->szModuleName);
- }
- }
- return TRUE;
- case WM_COMMAND:
- switch(LOWORD(wParam))
- {
- case ID_ADD:
- {
- WPARAM n = (WPARAM)SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_GETCURSEL, 0, 0);
- if(LB_ERR != n) {
- size_t len = SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_GETTEXTLEN, n, 0);
- if(LB_ERR != len) {
- TCHAR * buf = new TCHAR[len + 1];
- SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_GETTEXT, n, (LPARAM)buf);
- SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_ADDSTRING, 0, (LPARAM)buf);
- delete []buf;
- SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_DELETESTRING, n, 0);
- }
- }
- }
- break;
- case ID_REMOVE:
- {
- WPARAM n = (WPARAM)SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_GETCURSEL, 0, 0);
- if(LB_ERR != n) {
- size_t len = SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_GETTEXTLEN, n, 0);
- if(LB_ERR != len) {
- TCHAR * buf = new TCHAR[len + 1];
- SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_GETTEXT, n, (LPARAM)buf);
- SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_ADDSTRING, 0, (LPARAM)buf);
- delete []buf;
- SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_DELETESTRING, n, 0);
- }
- }
- }
- break;
- case ID_ADDALL:
- for(;;)
- {
- LRESULT count = SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_GETCOUNT, 0, 0);
- if(!count || LB_ERR == count)
- break;
- SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_SETCURSEL, 0, 0);
- SendMessage(hwnd, WM_COMMAND, ID_ADD, 0);
- }
- break;
- case ID_REMOVEALL:
- for(;;)
- {
- LRESULT count = SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_GETCOUNT, 0, 0);
- if(!count || LB_ERR == count)
- break;
- SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_SETCURSEL, 0, 0);
- SendMessage(hwnd, WM_COMMAND, ID_REMOVE, 0);
- }
- break;
- default:
- return FALSE;
- }
- SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- return TRUE;
- case WM_NOTIFY:
- {
- NMHDR* nmhdr = (NMHDR*)lParam;
- switch (nmhdr->code)
- {
- case PSN_APPLY:
- {
- LRESULT count = SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_GETCOUNT, 0, 0);
- std::ostringstream out;
- for(int i = 0; i < count; ++i) {
- size_t len = SendDlgItemMessageA(hwnd, ID_USEDPROTO, LB_GETTEXTLEN, i, 0);
- if(LB_ERR != len) {
- char * buf = new char[len + 1];
- SendDlgItemMessageA(hwnd, ID_USEDPROTO, LB_GETTEXT, i, (LPARAM)buf);
- out << buf << "\r\n";
- delete []buf;
- }
- }
- db_set_s(NULL, pluginName, "protoList", out.str().c_str());
- }
- return TRUE;
- }
- }
- break;
- }
- return FALSE;
-}
-
-INT_PTR CALLBACK AdvancedDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- switch(msg)
- {
- case WM_INITDIALOG: {
- TranslateDialogDefault(hwnd);
- SendDlgItemMessage(hwnd, IDC_INVIS_DISABLE, BM_SETCHECK, gbInvisDisable ? BST_CHECKED : BST_UNCHECKED, 0);
- SendDlgItemMessage(hwnd, IDC_CASE_INSENSITIVE, BM_SETCHECK, gbCaseInsensitive ? BST_CHECKED : BST_UNCHECKED, 0);
- gbDosServiceExist?EnableWindow(GetDlgItem(hwnd, ID_DOS_INTEGRATION),1):EnableWindow(GetDlgItem(hwnd, ID_DOS_INTEGRATION),0);
- SendDlgItemMessage(hwnd, ID_DOS_INTEGRATION, BM_SETCHECK, gbDosServiceIntegration ? BST_CHECKED : BST_UNCHECKED, 0);
- SetDlgItemText(hwnd, ID_SPECIALGROUPNAME, gbSpammersGroup.c_str());
- SendDlgItemMessage(hwnd, ID_SPECIALGROUP, BM_SETCHECK, gbSpecialGroup ? BST_CHECKED : BST_UNCHECKED, 0);
- SendDlgItemMessage(hwnd, ID_EXCLUDE, BM_SETCHECK, gbExclude ? BST_CHECKED : BST_UNCHECKED, 0);
- SendDlgItemMessage(hwnd, ID_REMOVE_TMP, BM_SETCHECK, gbDelExcluded ? BST_CHECKED : BST_UNCHECKED, 0);
- SendDlgItemMessage(hwnd, ID_REMOVE_TMP_ALL, BM_SETCHECK, gbDelAllTempory ? BST_CHECKED : BST_UNCHECKED, 0);
- SendDlgItemMessage(hwnd, ID_IGNOREURL, BM_SETCHECK, gbIgnoreURL ? BST_CHECKED : BST_UNCHECKED, 0);
- SendDlgItemMessage(hwnd, IDC_AUTOAUTH, BM_SETCHECK, gbAutoAuth ? BST_CHECKED : BST_UNCHECKED, 0);
- SendDlgItemMessage(hwnd, IDC_ADDTOSRVLST, BM_SETCHECK, gbAutoAddToServerList ? BST_CHECKED : BST_UNCHECKED, 0);
- SendDlgItemMessage(hwnd, IDC_REQAUTH, BM_SETCHECK, gbAutoReqAuth ? BST_CHECKED : BST_UNCHECKED, 0);
- SendDlgItemMessage(hwnd, IDC_REGEX, BM_SETCHECK, gbRegexMatch ? BST_CHECKED : BST_UNCHECKED, 0);
- SendDlgItemMessage(hwnd, IDC_HISTORY_LOG, BM_SETCHECK, gbHistoryLog ? BST_CHECKED : BST_UNCHECKED, 0);
- SendDlgItemMessage(hwnd, IDC_MATH_QUESTION, BM_SETCHECK, gbMathExpression ? BST_CHECKED : BST_UNCHECKED, 0 );
-
- SetDlgItemText(hwnd, IDC_AUTOADDGROUP, gbAutoAuthGroup.c_str());
- }
- return TRUE;
- case WM_COMMAND: {
- switch (LOWORD(wParam))
- {
- case IDC_MATH_DETAILS: {
- MessageBox(hwnd, TranslateT("If math expression is turned on you can use following expression in message text:\nXX+XX-X/X*X\neach X will be replaced by one random number and answer will be expression result\nMessage must contain only one expression without spaces"), TranslateT("Info"), MB_OK);
- }
- break;
- case IDC_INVIS_DISABLE:
- case IDC_CASE_INSENSITIVE:
- case ID_DOS_INTEGRATION:
- case ID_SPECIALGROUPNAME:
- case ID_SPECIALGROUP:
- case ID_EXCLUDE:
- case ID_REMOVE_TMP:
- case ID_REMOVE_TMP_ALL:
- case ID_IGNOREURL:
- case IDC_AUTOAUTH:
- case IDC_ADDTOSRVLST:
- case IDC_REQAUTH:
- case IDC_AUTOADDGROUP:
- case IDC_REGEX:
- case IDC_HISTORY_LOG:
- SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- break;
- }
- }
- break;
- case WM_NOTIFY: {
- NMHDR* nmhdr = (NMHDR*)lParam;
- switch (nmhdr->code)
- {
- case PSN_APPLY: {
- db_set_b(NULL, pluginName, "CaseInsensitive", gbCaseInsensitive = BST_CHECKED == SendDlgItemMessage(hwnd, IDC_CASE_INSENSITIVE, BM_GETCHECK, 0, 0));
- db_set_b(NULL, pluginName, "DisableInInvis", gbInvisDisable = BST_CHECKED == SendDlgItemMessage(hwnd, IDC_INVIS_DISABLE, BM_GETCHECK, 0, 0));
- db_set_b(NULL, pluginName, "DOSIntegration", gbDosServiceIntegration = BST_CHECKED == SendDlgItemMessage(hwnd, ID_DOS_INTEGRATION, BM_GETCHECK, 0, 0));
- {
- static tstring NewGroupName, CurrentGroupName;
- NewGroupName = GetDlgItemString(hwnd, ID_SPECIALGROUPNAME);
- CurrentGroupName = gbSpammersGroup = DBGetContactSettingStringPAN(NULL, pluginName, "SpammersGroup", _T("0"));
- if (wcscmp(CurrentGroupName.c_str(), NewGroupName.c_str()) != 0) {
- int GroupNumber = 0;
- BYTE GroupExist = 0;
- TCHAR szValue[96] = {0};
- char szNumber[32] = {0};
- extern int CreateCListGroup(TCHAR* szGroupName);
- strcpy(szNumber, "0");
- while (strcmp(DBGetContactSettingStringPAN_A(NULL, "CListGroups", szNumber, "0").c_str(), "0") != 0) {
- _itoa(GroupNumber, szNumber, 10);
- wcscpy(szValue, DBGetContactSettingStringPAN(NULL, "CListGroups", szNumber, _T("0")).c_str());
- if (wcscmp(NewGroupName.c_str(), szValue + 1) == 0) {
- GroupExist = 1;
- break;
- }
- GroupNumber++;
- }
- db_set_ws(NULL,pluginName, "SpammersGroup", NewGroupName.c_str());
- gbSpammersGroup = DBGetContactSettingStringPAN(NULL,pluginName,"SpammersGroup", _T("Spammers"));
- if(!GroupExist && gbSpecialGroup)
- CreateCListGroup((TCHAR*)gbSpammersGroup.c_str());
- }
- }
- db_set_b(NULL, pluginName, "SpecialGroup", gbSpecialGroup = BST_CHECKED == SendDlgItemMessage(hwnd, ID_SPECIALGROUP, BM_GETCHECK, 0, 0));
- db_set_b(NULL, pluginName, "ExcludeContacts", gbExclude = BST_CHECKED == SendDlgItemMessage(hwnd, ID_EXCLUDE, BM_GETCHECK, 0, 0));
- db_set_b(NULL, pluginName, "DelExcluded", gbDelExcluded = BST_CHECKED == SendDlgItemMessage(hwnd, ID_REMOVE_TMP, BM_GETCHECK, 0, 0));
- db_set_b(NULL, pluginName, "DelAllTempory", gbDelAllTempory = BST_CHECKED == SendDlgItemMessage(hwnd, ID_REMOVE_TMP_ALL, BM_GETCHECK, 0, 0));
- db_set_b(NULL, pluginName, "IgnoreURL", gbIgnoreURL = BST_CHECKED == SendDlgItemMessage(hwnd, ID_IGNOREURL, BM_GETCHECK, 0, 0));
-
- db_set_b(NULL, pluginName, "AutoAuth", gbAutoAuth = BST_CHECKED == SendDlgItemMessage(hwnd, IDC_AUTOAUTH, BM_GETCHECK, 0, 0));
- db_set_b(NULL, pluginName, "AutoAddToServerList", gbAutoAddToServerList = BST_CHECKED == SendDlgItemMessage(hwnd, IDC_ADDTOSRVLST, BM_GETCHECK, 0, 0));
- db_set_b(NULL, pluginName, "AutoReqAuth", gbAutoReqAuth = BST_CHECKED == SendDlgItemMessage(hwnd, IDC_REQAUTH, BM_GETCHECK, 0, 0));
- db_set_b(NULL, pluginName, "RegexMatch", gbRegexMatch = BST_CHECKED == SendDlgItemMessage(hwnd, IDC_REGEX, BM_GETCHECK, 0, 0));
- db_set_b(NULL, pluginName, "HistoryLog", gbHistoryLog = BST_CHECKED == SendDlgItemMessage(hwnd, IDC_HISTORY_LOG, BM_GETCHECK, 0, 0));
- db_set_b(NULL, pluginName, "MathExpression", gbMathExpression = BST_CHECKED == SendDlgItemMessage(hwnd, IDC_MATH_QUESTION, BM_GETCHECK, 0, 0));
-
- {
- static tstring NewAGroupName, CurrentAGroupName;
- NewAGroupName = GetDlgItemString(hwnd, IDC_AUTOADDGROUP);
- CurrentAGroupName = gbAutoAuthGroup = DBGetContactSettingStringPAN(NULL, pluginName, "AutoAuthGroup", _T("0"));
- if (wcscmp(CurrentAGroupName.c_str(), NewAGroupName.c_str()) != 0) {
- int GroupNumber = 0;
- BYTE GroupExist = 0;
- TCHAR szValue[96] = {0};
- char szNumber[32] = {0};
- extern int CreateCListGroup(TCHAR* szGroupName);
- strcpy(szNumber, "0");
- while (strcmp(DBGetContactSettingStringPAN_A(NULL, "CListGroups", szNumber, "0").c_str(), "0") != 0) {
- _itoa(GroupNumber, szNumber, 10);
- wcscpy(szValue, DBGetContactSettingStringPAN(NULL, "CListGroups", szNumber, _T("0")).c_str());
- if (wcscmp(NewAGroupName.c_str(), szValue + 1) == 0) {
- GroupExist = 1;
- break;
- }
- GroupNumber++;
- }
- db_set_ws(NULL,pluginName, "AutoAuthGroup", NewAGroupName.c_str());
- gbAutoAuthGroup = DBGetContactSettingStringPAN(NULL,pluginName,"AutoAuthGroup", _T("Not Spammers"));
- if(!GroupExist && gbAutoAddToServerList)
- CreateCListGroup((TCHAR*)gbAutoAuthGroup.c_str());
- }
- }
- }
- return TRUE;
- }
- }
- break;
- }
- return FALSE;
-}
-
-
-HINSTANCE hInst;
-MIRANDA_HOOK_EVENT(ME_OPT_INITIALISE, w, l)
-{
- OPTIONSDIALOGPAGE odp = {0};
- odp.cbSize = sizeof(odp);
- odp.ptszGroup = LPGENT("Message Sessions");
- odp.ptszTitle = LPGENT("StopSpam");
- odp.position = -1;
- odp.hInstance = hInst;
- odp.flags = ODPF_TCHAR;
-
- odp.ptszTab = LPGENT("General");
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_MAIN);
- odp.pfnDlgProc = MainDlgProc;
- Options_AddPage(w, &odp);
-
-
- odp.ptszTab = LPGENT("Messages");
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_MESSAGES);
- odp.pfnDlgProc = MessagesDlgProc;
- Options_AddPage(w, &odp);
-
- odp.ptszTab = LPGENT("Accounts");
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_PROTO);
- odp.pfnDlgProc = ProtoDlgProc;
- Options_AddPage(w, &odp);
-
- odp.ptszTab = LPGENT("Advanced");
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_ADVANCED);
- odp.pfnDlgProc = AdvancedDlgProc;
- Options_AddPage(w, &odp);
-
- return 0;
-}
+/* Copyright (C) Miklashevsky Roman, sss, elzor
+*
+* 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; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "headers.h"
+
+int CreateCListGroup(TCHAR* szGroupName);
+
+char * pluginDescription = LPGEN("No more spam! Robots can't go! Only human beings invited!\r\n\r\nThis plugin works pretty simple:\r\nWhile messages from users on your contact list go as there is no any anti-spam software, messages from unknown users are not delivered to you. But also they are not ignored, this plugin replies with a simple question, and if user gives the right answer plugin adds him to your contact list so that he can contact you.");
+TCHAR const * defQuestion = TranslateT("Spammers made me to install small anti-spam system you are now speaking with.\r\nPlease reply \"nospam\" without quotes and spaces if you want to contact me.");
+
+INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg)
+ {
+ case WM_INITDIALOG:
+ {
+ SetDlgItemTextA(hwnd, ID_DESCRIPTION, pluginDescription);
+ TranslateDialogDefault(hwnd);
+ SetDlgItemInt(hwnd, ID_MAXQUESTCOUNT, gbMaxQuestCount, FALSE);
+ SendDlgItemMessage(hwnd, ID_INFTALKPROT, BM_SETCHECK, gbInfTalkProtection ? BST_CHECKED : BST_UNCHECKED, 0);
+ SendDlgItemMessage(hwnd, ID_ADDPERMANENT, BM_SETCHECK, gbAddPermanent ? BST_CHECKED : BST_UNCHECKED, 0);
+ SendDlgItemMessage(hwnd, ID_HANDLEAUTHREQ, BM_SETCHECK, gbHandleAuthReq ? BST_CHECKED : BST_UNCHECKED, 0);
+ SendDlgItemMessage(hwnd, ID_HIDECONTACTS, BM_SETCHECK, gbHideContacts ? BST_CHECKED : BST_UNCHECKED, 0);
+ SendDlgItemMessage(hwnd, ID_IGNORESPAMMERS, BM_SETCHECK, gbIgnoreContacts ? BST_CHECKED : BST_UNCHECKED, 0);
+ SendDlgItemMessage(hwnd, ID_LOGSPAMTOFILE, BM_SETCHECK, gbLogToFile ? BST_CHECKED : BST_UNCHECKED, 0);
+ }
+ return TRUE;
+ case WM_COMMAND:{
+ switch (LOWORD(wParam))
+ {
+ case ID_MAXQUESTCOUNT:
+ {
+ if (EN_CHANGE != HIWORD(wParam) || (HWND)lParam != GetFocus())
+ return FALSE;
+ break;
+ }
+ }
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ }
+ break;
+ case WM_NOTIFY:
+ {
+ NMHDR* nmhdr = (NMHDR*)lParam;
+ switch (nmhdr->code)
+ {
+ case PSN_APPLY:
+ {
+ db_set_dw(NULL, pluginName, "maxQuestCount", gbMaxQuestCount = GetDlgItemInt(hwnd, ID_MAXQUESTCOUNT, NULL, FALSE));
+ db_set_b(NULL, pluginName, "infTalkProtection", gbInfTalkProtection = BST_CHECKED == SendDlgItemMessage(hwnd, ID_INFTALKPROT, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "addPermanent", gbAddPermanent = BST_CHECKED == SendDlgItemMessage(hwnd, ID_ADDPERMANENT, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "handleAuthReq", gbHandleAuthReq = BST_CHECKED == SendDlgItemMessage(hwnd, ID_HANDLEAUTHREQ, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "HideContacts", gbHideContacts = BST_CHECKED == SendDlgItemMessage(hwnd, ID_HIDECONTACTS, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "IgnoreContacts", gbIgnoreContacts = BST_CHECKED == SendDlgItemMessage(hwnd, ID_IGNORESPAMMERS, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "LogSpamToFile", gbLogToFile = BST_CHECKED == SendDlgItemMessage(hwnd, ID_LOGSPAMTOFILE, BM_GETCHECK, 0, 0));
+ }
+ return TRUE;
+ }
+ }
+ break;
+ }
+ return FALSE;
+}
+
+INT_PTR CALLBACK MessagesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+
+ switch(msg)
+ {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwnd);
+ SetDlgItemText(hwnd, ID_QUESTION, gbQuestion.c_str());
+ SetDlgItemText(hwnd, ID_ANSWER, gbAnswer.c_str());
+ SetDlgItemText(hwnd, ID_CONGRATULATION, gbCongratulation.c_str());
+ SetDlgItemText(hwnd, ID_AUTHREPL, gbAuthRepl.c_str());
+ EnableWindow(GetDlgItem(hwnd, ID_ANSWER), !gbMathExpression);
+ variables_skin_helpbutton(hwnd, IDC_VARS);
+ gbVarsServiceExist?EnableWindow(GetDlgItem(hwnd, IDC_VARS),1):EnableWindow(GetDlgItem(hwnd, IDC_VARS),0);
+ }
+ return TRUE;
+ case WM_COMMAND:
+ {
+ switch(LOWORD(wParam))
+ {
+ case ID_QUESTION:
+ case ID_ANSWER:
+ case ID_AUTHREPL:
+ case ID_CONGRATULATION:
+ {
+ if (EN_CHANGE != HIWORD(wParam) || (HWND)lParam != GetFocus())
+ return FALSE;
+ break;
+ }
+ case ID_RESTOREDEFAULTS:
+ SetDlgItemText(hwnd, ID_QUESTION, defQuestion);
+ SetDlgItemText(hwnd, ID_ANSWER, TranslateT("nospam"));
+ SetDlgItemText(hwnd, ID_AUTHREPL, TranslateT("StopSpam: send a message and reply to a anti-spam bot question."));
+ SetDlgItemText(hwnd, ID_CONGRATULATION, TranslateT("Congratulations! You just passed human/robot test. Now you can write me a message."));
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ return TRUE;
+ case IDC_VARS:
+ variables_showhelp(hwnd, msg, VHF_FULLDLG|VHF_SETLASTSUBJECT, NULL, NULL);
+ return TRUE;
+ }
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ }
+ break;
+ case WM_NOTIFY:
+ {
+ NMHDR* nmhdr = (NMHDR*)lParam;
+ switch (nmhdr->code)
+ {
+ case PSN_APPLY:
+ {
+ db_set_ws(NULL, pluginName, "question", GetDlgItemString(hwnd, ID_QUESTION).c_str());
+ gbQuestion = DBGetContactSettingStringPAN(NULL, pluginName, "question", defQuestion);
+ db_set_ws(NULL, pluginName, "answer", GetDlgItemString(hwnd, ID_ANSWER).c_str());
+ gbAnswer = DBGetContactSettingStringPAN(NULL, pluginName, "answer", TranslateT("nospam"));
+ db_set_ws(NULL, pluginName, "authrepl", GetDlgItemString(hwnd, ID_AUTHREPL).c_str());
+ gbAuthRepl = DBGetContactSettingStringPAN(NULL, pluginName, "authrepl", TranslateT("StopSpam: send a message and reply to a anti-spam bot question."));
+ db_set_ws(NULL, pluginName, "congratulation", GetDlgItemString(hwnd, ID_CONGRATULATION).c_str());
+ gbCongratulation = DBGetContactSettingStringPAN(NULL, pluginName, "congratulation", TranslateT("Congratulations! You just passed human/robot test. Now you can write me a message."));
+ }
+ return TRUE;
+ }
+ }
+ break;
+ }
+ return FALSE;
+}
+
+INT_PTR CALLBACK ProtoDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg)
+ {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwnd);
+ int n;
+ PROTOACCOUNT **pppd;
+ if(!ProtoEnumAccounts(&n, &pppd))
+ for (int i = 0; i < n; ++i) {
+ SendDlgItemMessageA(hwnd, (ProtoInList(pppd[i]->szModuleName) ? ID_USEDPROTO : ID_ALLPROTO), LB_ADDSTRING, 0, (LPARAM)pppd[i]->szModuleName);
+ }
+ }
+ return TRUE;
+ case WM_COMMAND:
+ switch(LOWORD(wParam))
+ {
+ case ID_ADD:
+ {
+ WPARAM n = (WPARAM)SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_GETCURSEL, 0, 0);
+ if(LB_ERR != n) {
+ size_t len = SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_GETTEXTLEN, n, 0);
+ if(LB_ERR != len) {
+ TCHAR * buf = new TCHAR[len + 1];
+ SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_GETTEXT, n, (LPARAM)buf);
+ SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_ADDSTRING, 0, (LPARAM)buf);
+ delete []buf;
+ SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_DELETESTRING, n, 0);
+ }
+ }
+ }
+ break;
+ case ID_REMOVE:
+ {
+ WPARAM n = (WPARAM)SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_GETCURSEL, 0, 0);
+ if(LB_ERR != n) {
+ size_t len = SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_GETTEXTLEN, n, 0);
+ if(LB_ERR != len) {
+ TCHAR * buf = new TCHAR[len + 1];
+ SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_GETTEXT, n, (LPARAM)buf);
+ SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_ADDSTRING, 0, (LPARAM)buf);
+ delete []buf;
+ SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_DELETESTRING, n, 0);
+ }
+ }
+ }
+ break;
+ case ID_ADDALL:
+ for(;;)
+ {
+ LRESULT count = SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_GETCOUNT, 0, 0);
+ if(!count || LB_ERR == count)
+ break;
+ SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_SETCURSEL, 0, 0);
+ SendMessage(hwnd, WM_COMMAND, ID_ADD, 0);
+ }
+ break;
+ case ID_REMOVEALL:
+ for(;;)
+ {
+ LRESULT count = SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_GETCOUNT, 0, 0);
+ if(!count || LB_ERR == count)
+ break;
+ SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_SETCURSEL, 0, 0);
+ SendMessage(hwnd, WM_COMMAND, ID_REMOVE, 0);
+ }
+ break;
+ default:
+ return FALSE;
+ }
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ return TRUE;
+ case WM_NOTIFY:
+ {
+ NMHDR* nmhdr = (NMHDR*)lParam;
+ switch (nmhdr->code)
+ {
+ case PSN_APPLY:
+ {
+ LRESULT count = SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_GETCOUNT, 0, 0);
+ std::ostringstream out;
+ for(int i = 0; i < count; ++i) {
+ size_t len = SendDlgItemMessageA(hwnd, ID_USEDPROTO, LB_GETTEXTLEN, i, 0);
+ if(LB_ERR != len) {
+ char * buf = new char[len + 1];
+ SendDlgItemMessageA(hwnd, ID_USEDPROTO, LB_GETTEXT, i, (LPARAM)buf);
+ out << buf << "\r\n";
+ delete []buf;
+ }
+ }
+ db_set_s(NULL, pluginName, "protoList", out.str().c_str());
+ }
+ return TRUE;
+ }
+ }
+ break;
+ }
+ return FALSE;
+}
+
+INT_PTR CALLBACK AdvancedDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg)
+ {
+ case WM_INITDIALOG: {
+ TranslateDialogDefault(hwnd);
+ SendDlgItemMessage(hwnd, IDC_INVIS_DISABLE, BM_SETCHECK, gbInvisDisable ? BST_CHECKED : BST_UNCHECKED, 0);
+ SendDlgItemMessage(hwnd, IDC_CASE_INSENSITIVE, BM_SETCHECK, gbCaseInsensitive ? BST_CHECKED : BST_UNCHECKED, 0);
+ gbDosServiceExist?EnableWindow(GetDlgItem(hwnd, ID_DOS_INTEGRATION),1):EnableWindow(GetDlgItem(hwnd, ID_DOS_INTEGRATION),0);
+ SendDlgItemMessage(hwnd, ID_DOS_INTEGRATION, BM_SETCHECK, gbDosServiceIntegration ? BST_CHECKED : BST_UNCHECKED, 0);
+ SetDlgItemText(hwnd, ID_SPECIALGROUPNAME, gbSpammersGroup.c_str());
+ SendDlgItemMessage(hwnd, ID_SPECIALGROUP, BM_SETCHECK, gbSpecialGroup ? BST_CHECKED : BST_UNCHECKED, 0);
+ SendDlgItemMessage(hwnd, ID_EXCLUDE, BM_SETCHECK, gbExclude ? BST_CHECKED : BST_UNCHECKED, 0);
+ SendDlgItemMessage(hwnd, ID_REMOVE_TMP, BM_SETCHECK, gbDelExcluded ? BST_CHECKED : BST_UNCHECKED, 0);
+ SendDlgItemMessage(hwnd, ID_REMOVE_TMP_ALL, BM_SETCHECK, gbDelAllTempory ? BST_CHECKED : BST_UNCHECKED, 0);
+ SendDlgItemMessage(hwnd, ID_IGNOREURL, BM_SETCHECK, gbIgnoreURL ? BST_CHECKED : BST_UNCHECKED, 0);
+ SendDlgItemMessage(hwnd, IDC_AUTOAUTH, BM_SETCHECK, gbAutoAuth ? BST_CHECKED : BST_UNCHECKED, 0);
+ SendDlgItemMessage(hwnd, IDC_ADDTOSRVLST, BM_SETCHECK, gbAutoAddToServerList ? BST_CHECKED : BST_UNCHECKED, 0);
+ SendDlgItemMessage(hwnd, IDC_REQAUTH, BM_SETCHECK, gbAutoReqAuth ? BST_CHECKED : BST_UNCHECKED, 0);
+ SendDlgItemMessage(hwnd, IDC_REGEX, BM_SETCHECK, gbRegexMatch ? BST_CHECKED : BST_UNCHECKED, 0);
+ SendDlgItemMessage(hwnd, IDC_HISTORY_LOG, BM_SETCHECK, gbHistoryLog ? BST_CHECKED : BST_UNCHECKED, 0);
+ SendDlgItemMessage(hwnd, IDC_MATH_QUESTION, BM_SETCHECK, gbMathExpression ? BST_CHECKED : BST_UNCHECKED, 0 );
+
+ SetDlgItemText(hwnd, IDC_AUTOADDGROUP, gbAutoAuthGroup.c_str());
+ }
+ return TRUE;
+ case WM_COMMAND: {
+ switch (LOWORD(wParam))
+ {
+ case IDC_MATH_DETAILS: {
+ MessageBox(hwnd, TranslateT("If math expression is turned on you can use following expression in message text:\nXX+XX-X/X*X\neach X will be replaced by one random number and answer will be expression result\nMessage must contain only one expression without spaces"), TranslateT("Info"), MB_OK);
+ }
+ break;
+ case IDC_INVIS_DISABLE:
+ case IDC_CASE_INSENSITIVE:
+ case ID_DOS_INTEGRATION:
+ case ID_SPECIALGROUPNAME:
+ case ID_SPECIALGROUP:
+ case ID_EXCLUDE:
+ case ID_REMOVE_TMP:
+ case ID_REMOVE_TMP_ALL:
+ case ID_IGNOREURL:
+ case IDC_AUTOAUTH:
+ case IDC_ADDTOSRVLST:
+ case IDC_REQAUTH:
+ case IDC_AUTOADDGROUP:
+ case IDC_REGEX:
+ case IDC_HISTORY_LOG:
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ break;
+ }
+ }
+ break;
+ case WM_NOTIFY: {
+ NMHDR* nmhdr = (NMHDR*)lParam;
+ switch (nmhdr->code)
+ {
+ case PSN_APPLY: {
+ db_set_b(NULL, pluginName, "CaseInsensitive", gbCaseInsensitive = BST_CHECKED == SendDlgItemMessage(hwnd, IDC_CASE_INSENSITIVE, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "DisableInInvis", gbInvisDisable = BST_CHECKED == SendDlgItemMessage(hwnd, IDC_INVIS_DISABLE, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "DOSIntegration", gbDosServiceIntegration = BST_CHECKED == SendDlgItemMessage(hwnd, ID_DOS_INTEGRATION, BM_GETCHECK, 0, 0));
+ {
+ static tstring NewGroupName, CurrentGroupName;
+ NewGroupName = GetDlgItemString(hwnd, ID_SPECIALGROUPNAME);
+ CurrentGroupName = gbSpammersGroup = DBGetContactSettingStringPAN(NULL, pluginName, "SpammersGroup", _T("0"));
+ if (wcscmp(CurrentGroupName.c_str(), NewGroupName.c_str()) != 0) {
+ bool GroupExist = Clist_GroupExists(NewGroupName.c_str()) != NULL;
+ db_set_ws(NULL,pluginName, "SpammersGroup", NewGroupName.c_str());
+ gbSpammersGroup = DBGetContactSettingStringPAN(NULL,pluginName,"SpammersGroup", _T("Spammers"));
+ if(!GroupExist && gbSpecialGroup)
+ CreateCListGroup((TCHAR*)gbSpammersGroup.c_str());
+ }
+ }
+ db_set_b(NULL, pluginName, "SpecialGroup", gbSpecialGroup = BST_CHECKED == SendDlgItemMessage(hwnd, ID_SPECIALGROUP, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "ExcludeContacts", gbExclude = BST_CHECKED == SendDlgItemMessage(hwnd, ID_EXCLUDE, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "DelExcluded", gbDelExcluded = BST_CHECKED == SendDlgItemMessage(hwnd, ID_REMOVE_TMP, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "DelAllTempory", gbDelAllTempory = BST_CHECKED == SendDlgItemMessage(hwnd, ID_REMOVE_TMP_ALL, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "IgnoreURL", gbIgnoreURL = BST_CHECKED == SendDlgItemMessage(hwnd, ID_IGNOREURL, BM_GETCHECK, 0, 0));
+
+ db_set_b(NULL, pluginName, "AutoAuth", gbAutoAuth = BST_CHECKED == SendDlgItemMessage(hwnd, IDC_AUTOAUTH, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "AutoAddToServerList", gbAutoAddToServerList = BST_CHECKED == SendDlgItemMessage(hwnd, IDC_ADDTOSRVLST, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "AutoReqAuth", gbAutoReqAuth = BST_CHECKED == SendDlgItemMessage(hwnd, IDC_REQAUTH, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "RegexMatch", gbRegexMatch = BST_CHECKED == SendDlgItemMessage(hwnd, IDC_REGEX, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "HistoryLog", gbHistoryLog = BST_CHECKED == SendDlgItemMessage(hwnd, IDC_HISTORY_LOG, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "MathExpression", gbMathExpression = BST_CHECKED == SendDlgItemMessage(hwnd, IDC_MATH_QUESTION, BM_GETCHECK, 0, 0));
+
+ {
+ static tstring NewAGroupName, CurrentAGroupName;
+ NewAGroupName = GetDlgItemString(hwnd, IDC_AUTOADDGROUP);
+ CurrentAGroupName = gbAutoAuthGroup = DBGetContactSettingStringPAN(NULL, pluginName, "AutoAuthGroup", _T("0"));
+ if (wcscmp(CurrentAGroupName.c_str(), NewAGroupName.c_str()) != 0) {
+ bool GroupExist = Clist_GroupExists(NewAGroupName.c_str());
+ db_set_ws(NULL,pluginName, "AutoAuthGroup", NewAGroupName.c_str());
+ gbAutoAuthGroup = DBGetContactSettingStringPAN(NULL,pluginName,"AutoAuthGroup", _T("Not Spammers"));
+ if(!GroupExist && gbAutoAddToServerList)
+ CreateCListGroup((TCHAR*)gbAutoAuthGroup.c_str());
+ }
+ }
+ }
+ return TRUE;
+ }
+ }
+ break;
+ }
+ return FALSE;
+}
+
+
+HINSTANCE hInst;
+MIRANDA_HOOK_EVENT(ME_OPT_INITIALISE, w, l)
+{
+ OPTIONSDIALOGPAGE odp = {0};
+ odp.cbSize = sizeof(odp);
+ odp.ptszGroup = LPGENT("Message Sessions");
+ odp.ptszTitle = LPGENT("StopSpam");
+ odp.position = -1;
+ odp.hInstance = hInst;
+ odp.flags = ODPF_TCHAR;
+
+ odp.ptszTab = LPGENT("General");
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_MAIN);
+ odp.pfnDlgProc = MainDlgProc;
+ Options_AddPage(w, &odp);
+
+
+ odp.ptszTab = LPGENT("Messages");
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_MESSAGES);
+ odp.pfnDlgProc = MessagesDlgProc;
+ Options_AddPage(w, &odp);
+
+ odp.ptszTab = LPGENT("Accounts");
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_PROTO);
+ odp.pfnDlgProc = ProtoDlgProc;
+ Options_AddPage(w, &odp);
+
+ odp.ptszTab = LPGENT("Advanced");
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_ADVANCED);
+ odp.pfnDlgProc = AdvancedDlgProc;
+ Options_AddPage(w, &odp);
+
+ return 0;
+}
diff --git a/plugins/StopSpamMod/src/utilities.cpp b/plugins/StopSpamMod/src/utilities.cpp
index 647293687a..46707c67fa 100755
--- a/plugins/StopSpamMod/src/utilities.cpp
+++ b/plugins/StopSpamMod/src/utilities.cpp
@@ -1,445 +1,436 @@
-/* Copyright (C) Miklashevsky Roman, sss, elzor
-*
-* 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; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-
-#include "headers.h"
-
-tstring DBGetContactSettingStringPAN(HANDLE hContact, char const * szModule, char const * szSetting, tstring errorValue)
-{
- DBVARIANT dbv;
- //if(db_get(hContact, szModule, szSetting, &dbv))
- if(db_get_ts(hContact, szModule, szSetting, &dbv))
- return errorValue;
-// if(DBVT_TCHAR == dbv.type )
- errorValue = dbv.ptszVal;
- db_free(&dbv);
- return errorValue;
-}
-
-std::string DBGetContactSettingStringPAN_A(HANDLE hContact, char const * szModule, char const * szSetting, std::string errorValue)
-{
- DBVARIANT dbv;
- //if(db_get(hContact, szModule, szSetting, &dbv))
- if(db_get_s(hContact, szModule, szSetting, &dbv))
- return errorValue;
-// if(DBVT_ASCIIZ == dbv.type )
- errorValue = dbv.pszVal;
- db_free(&dbv);
- return errorValue;
-}
-
-tstring &GetDlgItemString(HWND hwnd, int id)
-{
- HWND h = GetDlgItem(hwnd, id);
- int len = GetWindowTextLength(h);
- TCHAR * buf = new TCHAR[len + 1];
- GetWindowText(h, buf, len + 1);
- static tstring s;
- s = buf;
- delete []buf;
- return s;
-}
-
-std::string &GetProtoList()
-{
- static std::string s;
- return s = DBGetContactSettingStringPAN_A(NULL, pluginName, "protoList", "ICQ\r\n");
-}
-
-bool ProtoInList(std::string proto)
-{
- return std::string::npos != GetProtoList().find(proto + "\r\n");
-}
-
-int CreateCListGroup(TCHAR* szGroupName)
-{
- int hGroup = CallService(MS_CLIST_GROUPCREATE, 0, 0);
-
- TCHAR* usTmp = szGroupName;
- pcli->pfnRenameGroup(hGroup, usTmp);
-
- return hGroup;
-}
-
-void DeleteCListGroupsByName(TCHAR* szGroupName)
-{
- int GroupNumber = 0;
- TCHAR szValue[96] = {0};
- char szNumber[32] = {0};
- strcpy(szNumber, "0");
- BYTE ConfirmDelete=db_get_b(NULL, "CList", "ConfirmDelete", SETTING_CONFIRMDELETE_DEFAULT);
- if(ConfirmDelete)
- db_set_b(NULL, "CList", "ConfirmDelete", 0);
- while(strcmp(DBGetContactSettingStringPAN_A(NULL, "CListGroups", szNumber, "0").c_str(), "0") != 0)
- {
- wcscpy(szValue, DBGetContactSettingStringPAN(NULL, "CListGroups", szNumber, _T("0")).c_str());
- if(wcscmp(szGroupName, szValue + 1) == 0)
- CallService(MS_CLIST_GROUPDELETE, (WPARAM)(HANDLE)GroupNumber+1, 0); // bug or ??? @_@
- GroupNumber++;
-#if defined(_MSC_VER) && _MSC_VER >= 1300
- _itoa_s(GroupNumber, szNumber, sizeof(szNumber), 10);
-#else
- _itoa(GroupNumber, szNumber, 10);
-#endif
- };
- if(ConfirmDelete)
- db_set_b(NULL, "CList", "ConfirmDelete", ConfirmDelete);
-}
-
-int RemoveTmp(WPARAM,LPARAM)
-{
- void CleanThread();
- CleanThread();
- return 0;
-}
-tstring variables_parse(tstring const &tstrFormat, HANDLE hContact){
- if (gbVarsServiceExist) {
- FORMATINFO fi;
- TCHAR *tszParsed;
- tstring tstrResult;
-
- ZeroMemory(&fi, sizeof(fi));
- fi.cbSize = sizeof(fi);
- fi.tszFormat = _tcsdup(tstrFormat.c_str());
- fi.hContact = hContact;
- fi.flags |= FIF_TCHAR;
- tszParsed = (TCHAR *)CallService(MS_VARS_FORMATSTRING, (WPARAM)&fi, 0);
- free(fi.tszFormat);
- if (tszParsed) {
- tstrResult = tszParsed;
- mir_free(tszParsed);
- return tstrResult;
- }
- }
- return tstrFormat;
-}
-
-// case-insensitive _tcscmp
-//by nullbie as i remember...
-#define NEWTSTR_MALLOC(A) (A==NULL) ? NULL : _tcscpy((TCHAR*)mir_alloc(sizeof(TCHAR)*(_tcslen(A)+1)),A)
-const int Stricmp(const TCHAR *str, const TCHAR *substr)
-{
- int i = 0;
-
- TCHAR *str_up = NEWTSTR_MALLOC(str);
- TCHAR *substr_up = NEWTSTR_MALLOC(substr);
-
- CharUpperBuff(str_up, lstrlen(str_up));
- CharUpperBuff(substr_up, lstrlen(substr_up));
-
- i = _tcscmp(str_up, substr_up);
-
- mir_free(str_up);
- mir_free(substr_up);
-
- return i;
-}
-
-TCHAR* ReqGetText(DBEVENTINFO* dbei)
-{
- if ( !dbei->pBlob )
- return 0;
-
- char * ptr=(char *)&dbei->pBlob[sizeof(DWORD)*2];
- int len=dbei->cbBlob-sizeof(DWORD)*2;
- int i=0;
-
- while(len && (i<4))
- {
- if(!ptr[0]) i++;
- ptr++;
- len--;
- };
-
- if(len)
- {
- char * tstr=(char *)mir_alloc(len+1);
- memcpy(tstr, ptr, len);
- tstr[len]=0;
- WCHAR* msg = NULL;
- msg=(dbei->flags&DBEF_UTF)?mir_utf8decodeW(tstr):mir_a2u(tstr);
- mir_free(tstr);
- return (TCHAR *)msg;
- };
- return 0;
-}
-
-BOOL IsUrlContains(TCHAR * Str)
-{
- const int CountUrl=11;
- const TCHAR URL[CountUrl][5]=
- {
- L"http",
- L"www",
- L".ru",
- L".com",
- L".de",
- L".cz",
- L".org",
- L".net",
- L".su",
- L".ua",
- L".tv"
- };
-
- if(Str && _tcslen(Str)>0) {
- TCHAR *StrLower = NEWTSTR_MALLOC(Str);
- CharLowerBuff(StrLower, lstrlen(StrLower));
- for (int i=0; i<CountUrl; i++)
- if(_tcsstr (StrLower, URL[i]))
- {
- mir_free(StrLower);
- return 1;
- }
- mir_free(StrLower);
- }
- return 0;
-}
-
-tstring GetContactUid(HANDLE hContact, tstring Protocol)
-{
- tstring Uid;
- TCHAR dUid[32]={0};
- char aUid[32]={0};
- char *szProto = mir_utf8encodeW(Protocol.c_str());
- CONTACTINFO ci;
- ZeroMemory((void *)&ci, sizeof(ci));
-
- ci.hContact = hContact;
- ci.szProto = szProto;
- ci.cbSize = sizeof(ci);
-
- ci.dwFlag = CNF_DISPLAYUID | CNF_TCHAR;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) & ci)) {
- switch (ci.type) {
- case CNFT_ASCIIZ:
- Uid=ci.pszVal;
- mir_free((void *)ci.pszVal);
- break;
- case CNFT_DWORD:
-#if defined(_MSC_VER) && _MSC_VER >= 1300
-
- _itoa_s(ci.dVal,aUid,32,10);
-#else
- _itoa(ci.dVal,aUid,10);
-
-#endif
- OemToChar(aUid, dUid);
- Uid=dUid;
- break;
- default:
- Uid=_T("");
- break;
- };
- }
- mir_free(szProto);
- return Uid;
-}
-
-void LogSpamToFile(HANDLE hContact, tstring message)
-{
- if (!gbLogToFile) return;
-
- tstring LogStrW, LogTime, LogProtocol, LogContactId, LogContactName;
- tstring filename;
- std::fstream file;
- TCHAR pszName[MAX_PATH];
-
+/* Copyright (C) Miklashevsky Roman, sss, elzor
+*
+* 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; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+
+#include "headers.h"
+
+tstring DBGetContactSettingStringPAN(HANDLE hContact, char const * szModule, char const * szSetting, tstring errorValue)
+{
+ DBVARIANT dbv;
+ //if(db_get(hContact, szModule, szSetting, &dbv))
+ if(db_get_ts(hContact, szModule, szSetting, &dbv))
+ return errorValue;
+// if(DBVT_TCHAR == dbv.type )
+ errorValue = dbv.ptszVal;
+ db_free(&dbv);
+ return errorValue;
+}
+
+std::string DBGetContactSettingStringPAN_A(HANDLE hContact, char const * szModule, char const * szSetting, std::string errorValue)
+{
+ DBVARIANT dbv;
+ //if(db_get(hContact, szModule, szSetting, &dbv))
+ if(db_get_s(hContact, szModule, szSetting, &dbv))
+ return errorValue;
+// if(DBVT_ASCIIZ == dbv.type )
+ errorValue = dbv.pszVal;
+ db_free(&dbv);
+ return errorValue;
+}
+
+tstring &GetDlgItemString(HWND hwnd, int id)
+{
+ HWND h = GetDlgItem(hwnd, id);
+ int len = GetWindowTextLength(h);
+ TCHAR * buf = new TCHAR[len + 1];
+ GetWindowText(h, buf, len + 1);
+ static tstring s;
+ s = buf;
+ delete []buf;
+ return s;
+}
+
+std::string &GetProtoList()
+{
+ static std::string s;
+ return s = DBGetContactSettingStringPAN_A(NULL, pluginName, "protoList", "ICQ\r\n");
+}
+
+bool ProtoInList(std::string proto)
+{
+ return std::string::npos != GetProtoList().find(proto + "\r\n");
+}
+
+int CreateCListGroup(TCHAR* szGroupName)
+{
+ int hGroup = CallService(MS_CLIST_GROUPCREATE, 0, 0);
+
+ TCHAR* usTmp = szGroupName;
+ pcli->pfnRenameGroup(hGroup, usTmp);
+
+ return hGroup;
+}
+
+void DeleteCListGroupsByName(TCHAR* szGroupName)
+{
+ BYTE ConfirmDelete = db_get_b(NULL, "CList", "ConfirmDelete", SETTING_CONFIRMDELETE_DEFAULT);
+ if(ConfirmDelete)
+ db_set_b(NULL, "CList", "ConfirmDelete", 0);
+
+ TCHAR *szGroup;
+ for (int i=1; (szGroup = pcli->pfnGetGroupName(i, NULL)) != NULL; i++)
+ if( !wcscmp(szGroupName, szGroup))
+ CallService(MS_CLIST_GROUPDELETE, i, 0);
+
+ if(ConfirmDelete)
+ db_set_b(NULL, "CList", "ConfirmDelete", ConfirmDelete);
+}
+
+int RemoveTmp(WPARAM,LPARAM)
+{
+ void CleanThread();
+ CleanThread();
+ return 0;
+}
+
+tstring variables_parse(tstring const &tstrFormat, HANDLE hContact){
+ if (gbVarsServiceExist) {
+ FORMATINFO fi;
+ TCHAR *tszParsed;
+ tstring tstrResult;
+
+ ZeroMemory(&fi, sizeof(fi));
+ fi.cbSize = sizeof(fi);
+ fi.tszFormat = _tcsdup(tstrFormat.c_str());
+ fi.hContact = hContact;
+ fi.flags |= FIF_TCHAR;
+ tszParsed = (TCHAR *)CallService(MS_VARS_FORMATSTRING, (WPARAM)&fi, 0);
+ free(fi.tszFormat);
+ if (tszParsed) {
+ tstrResult = tszParsed;
+ mir_free(tszParsed);
+ return tstrResult;
+ }
+ }
+ return tstrFormat;
+}
+
+// case-insensitive _tcscmp
+//by nullbie as i remember...
+#define NEWTSTR_MALLOC(A) (A==NULL) ? NULL : _tcscpy((TCHAR*)mir_alloc(sizeof(TCHAR)*(_tcslen(A)+1)),A)
+const int Stricmp(const TCHAR *str, const TCHAR *substr)
+{
+ int i = 0;
+
+ TCHAR *str_up = NEWTSTR_MALLOC(str);
+ TCHAR *substr_up = NEWTSTR_MALLOC(substr);
+
+ CharUpperBuff(str_up, lstrlen(str_up));
+ CharUpperBuff(substr_up, lstrlen(substr_up));
+
+ i = _tcscmp(str_up, substr_up);
+
+ mir_free(str_up);
+ mir_free(substr_up);
+
+ return i;
+}
+
+TCHAR* ReqGetText(DBEVENTINFO* dbei)
+{
+ if ( !dbei->pBlob )
+ return 0;
+
+ char * ptr=(char *)&dbei->pBlob[sizeof(DWORD)*2];
+ int len=dbei->cbBlob-sizeof(DWORD)*2;
+ int i=0;
+
+ while(len && (i<4))
+ {
+ if(!ptr[0]) i++;
+ ptr++;
+ len--;
+ };
+
+ if(len)
+ {
+ char * tstr=(char *)mir_alloc(len+1);
+ memcpy(tstr, ptr, len);
+ tstr[len]=0;
+ WCHAR* msg = NULL;
+ msg=(dbei->flags&DBEF_UTF)?mir_utf8decodeW(tstr):mir_a2u(tstr);
+ mir_free(tstr);
+ return (TCHAR *)msg;
+ };
+ return 0;
+}
+
+BOOL IsUrlContains(TCHAR * Str)
+{
+ const int CountUrl=11;
+ const TCHAR URL[CountUrl][5]=
+ {
+ L"http",
+ L"www",
+ L".ru",
+ L".com",
+ L".de",
+ L".cz",
+ L".org",
+ L".net",
+ L".su",
+ L".ua",
+ L".tv"
+ };
+
+ if(Str && _tcslen(Str)>0) {
+ TCHAR *StrLower = NEWTSTR_MALLOC(Str);
+ CharLowerBuff(StrLower, lstrlen(StrLower));
+ for (int i=0; i<CountUrl; i++)
+ if(_tcsstr (StrLower, URL[i]))
+ {
+ mir_free(StrLower);
+ return 1;
+ }
+ mir_free(StrLower);
+ }
+ return 0;
+}
+
+tstring GetContactUid(HANDLE hContact, tstring Protocol)
+{
+ tstring Uid;
+ TCHAR dUid[32]={0};
+ char aUid[32]={0};
+ char *szProto = mir_utf8encodeW(Protocol.c_str());
+ CONTACTINFO ci;
+ ZeroMemory((void *)&ci, sizeof(ci));
+
+ ci.hContact = hContact;
+ ci.szProto = szProto;
+ ci.cbSize = sizeof(ci);
+
+ ci.dwFlag = CNF_DISPLAYUID | CNF_TCHAR;
+ if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) & ci)) {
+ switch (ci.type) {
+ case CNFT_ASCIIZ:
+ Uid=ci.pszVal;
+ mir_free((void *)ci.pszVal);
+ break;
+ case CNFT_DWORD:
+#if defined(_MSC_VER) && _MSC_VER >= 1300
+
+ _itoa_s(ci.dVal,aUid,32,10);
+#else
+ _itoa(ci.dVal,aUid,10);
+
+#endif
+ OemToChar(aUid, dUid);
+ Uid=dUid;
+ break;
+ default:
+ Uid=_T("");
+ break;
+ };
+ }
+ mir_free(szProto);
+ return Uid;
+}
+
+void LogSpamToFile(HANDLE hContact, tstring message)
+{
+ if (!gbLogToFile) return;
+
+ tstring LogStrW, LogTime, LogProtocol, LogContactId, LogContactName;
+ tstring filename;
+ std::fstream file;
+ TCHAR pszName[MAX_PATH];
+
if (hStopSpamLogDirH)
FoldersGetCustomPathT(hStopSpamLogDirH, pszName, MAX_PATH, _T(""));
else
lstrcpyn(pszName, VARST( _T("%miranda_logpath%")), SIZEOF(pszName));
-
- filename = pszName;
- filename = filename + _T("\\stopspam_mod.log");
-
- file.open(filename.c_str(),std::ios::out |std::ios::app);
-
- // Time Log line
- time_t time_now;
- tm *TimeNow;
- time(&time_now);
- TimeNow = localtime(&time_now);
- LogTime=_wasctime( TimeNow );
- // Time Log line
-
- // Name, UID and Protocol Log line
- LogProtocol=DBGetContactSettingStringPAN(hContact,"Protocol","p",_T(""));
- LogContactName=(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, GCDNF_TCHAR);
- LogContactId=(LogProtocol==_T(""))?_T(""):GetContactUid(hContact,LogProtocol);
- // Name, UID and Protocol Log line
-
- LogStrW=_T("[")+LogTime.substr(0,LogTime.length()-1)+_T("] ")+
- LogContactId+_T(" - ")+
- LogContactName+_T(" (")+
- LogProtocol+_T("): ")+
- message+_T("\n");
-
- char * buf=mir_u2a(LogStrW.c_str());
- file.write(buf,LogStrW.length());
- mir_free(buf);
-
- file.close();
-}
-
-boost::mutex clean_mutex;
-
-void CleanProtocolTmpThread(std::string proto)
-{
- while(true)
- {
- UINT status = CallProtoService(proto.c_str(), PS_GETSTATUS, 0, 0);
- if(status > ID_STATUS_OFFLINE)
- break;
- boost::this_thread::sleep(boost::posix_time::seconds(2));
- }
-
- std::list<HANDLE> contacts;
- for(HANDLE hContact = db_find_first(proto.c_str()); hContact; hContact = db_find_next(hContact, proto.c_str()))
- if(db_get_b(hContact, "CList", "NotOnList", 0)|| (_T("Not In List")== DBGetContactSettingStringPAN(hContact,"CList","Group",_T(""))))
- contacts.push_back(hContact);
-
- boost::this_thread::sleep(boost::posix_time::seconds(5));
- clean_mutex.lock();
- std::list<HANDLE>::iterator end = contacts.end();
- for(std::list<HANDLE>::iterator i = contacts.begin(); i != end; ++i)
- {
- LogSpamToFile(*i, _T("Deleted"));
- HistoryLogFunc(*i, "Deleted");
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)*i, 0);
- }
- clean_mutex.unlock();
-}
-
-void CleanProtocolExclThread(std::string proto)
-{
- while(true)
- {
- UINT status = CallProtoService(proto.c_str(), PS_GETSTATUS, 0, 0);
- if(status > ID_STATUS_OFFLINE)
- break;
- boost::this_thread::sleep(boost::posix_time::seconds(2));
- }
-
- std::list<HANDLE> contacts;
- for(HANDLE hContact = db_find_first(proto.c_str()); hContact; hContact = db_find_next(hContact, proto.c_str()))
- if(db_get_b(hContact, "CList", "NotOnList", 0) && db_get_b(hContact, pluginName, "Excluded", 0))
- contacts.push_back(hContact);
-
- boost::this_thread::sleep(boost::posix_time::seconds(5));
- clean_mutex.lock();
- std::list<HANDLE>::iterator end = contacts.end();
- for(std::list<HANDLE>::iterator i = contacts.begin(); i != end; ++i)
- {
- LogSpamToFile(*i, _T("Deleted"));
- HistoryLogFunc(*i, "Deleted");
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)*i, 0);
- }
- clean_mutex.unlock();
-}
-
-void CleanThread()
-{
- std::list<std::string> protocols;
- int count = 0;
- PROTOACCOUNT **accounts;
- ProtoEnumAccounts(&count, &accounts);
- for(int i = 0; i < count; i++)
- {
- if(!strstr(accounts[i]->szModuleName, "MetaContacts") && !strstr(accounts[i]->szModuleName, "Weather")) //not real protocols
- protocols.push_back(accounts[i]->szModuleName);
- }
- std::list<std::string>::iterator end = protocols.end();
- for(std::list<std::string>::iterator i = protocols.begin(); i != end; ++i)
- {
- if(gbDelAllTempory)
- boost::thread *thr = new boost::thread(boost::bind(&CleanProtocolTmpThread, *i));
- if(gbDelExcluded)
- boost::thread *thr = new boost::thread(boost::bind(&CleanProtocolExclThread, *i));
- }
-}
-
-void HistoryLog(HANDLE hContact, char *data, int event_type, int flags)
-{
- DBEVENTINFO Event = { sizeof(Event) };
- Event.szModule = pluginName;
- Event.eventType = event_type;
- Event.flags = flags | DBEF_UTF;
- Event.timestamp = (DWORD)time(NULL);
- Event.cbBlob = strlen(data)+1;
- Event.pBlob = (PBYTE)_strdup(data);
- db_event_add(hContact, &Event);
-}
-
-void HistoryLogFunc(HANDLE hContact, std::string message)
-{
- if(gbHistoryLog)
- {
- if(hContact == INVALID_HANDLE_VALUE)
- return;
- std::string msg = message;
- msg.append("\n");
- msg.append("Protocol: ").append(GetContactProto(hContact)).append(" Contact: ");
- msg.append(toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, GCDNF_TCHAR))).append(" ID: ");
- msg.append(toUTF8(GetContactUid(hContact,toUTF16(GetContactProto(hContact)))));
- HistoryLog(NULL, (char*)msg.c_str(), EVENTTYPE_MESSAGE, DBEF_READ);
- }
-}
-
-std::string toUTF8(std::wstring str)
-{
- std::string ustr;
- try{
- utf8::utf16to8(str.begin(), str.end(), back_inserter(ustr));
- }
- catch(const std::exception&)
- {
- //TODO: handle utf8cpp exceptions
- }
- return ustr;
-}
-
-std::string toUTF8(std::string str)
-{
- return toUTF8(toUTF16(str));
-}
-
-std::wstring toUTF16(std::string str) //convert as much as possible
-{
- std::wstring ustr;
- std::string tmpstr;
- try{
- utf8::replace_invalid(str.begin(), str.end(), back_inserter(tmpstr));
- utf8::utf8to16(tmpstr.begin(), tmpstr.end(), back_inserter(ustr));
- }
- catch(const std::exception &)
- {
- //TODO: handle utf8cpp exceptions
- }
- return ustr;
-}
-
-std::string get_random_num(int length)
-{
- std::string chars("123456789");
- std::string data;
- boost::random_device rng;
- boost::variate_generator<boost::random_device&, boost::uniform_int<>> gen(rng, boost::uniform_int<>(0, chars.length()-1));
- for(int i = 0; i < length; ++i)
- data += chars[gen()];
- return data;
-}
+
+ filename = pszName;
+ filename = filename + _T("\\stopspam_mod.log");
+
+ file.open(filename.c_str(),std::ios::out |std::ios::app);
+
+ // Time Log line
+ time_t time_now;
+ tm *TimeNow;
+ time(&time_now);
+ TimeNow = localtime(&time_now);
+ LogTime=_wasctime( TimeNow );
+ // Time Log line
+
+ // Name, UID and Protocol Log line
+ LogProtocol=DBGetContactSettingStringPAN(hContact,"Protocol","p",_T(""));
+ LogContactName=(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, GCDNF_TCHAR);
+ LogContactId=(LogProtocol==_T(""))?_T(""):GetContactUid(hContact,LogProtocol);
+ // Name, UID and Protocol Log line
+
+ LogStrW=_T("[")+LogTime.substr(0,LogTime.length()-1)+_T("] ")+
+ LogContactId+_T(" - ")+
+ LogContactName+_T(" (")+
+ LogProtocol+_T("): ")+
+ message+_T("\n");
+
+ char * buf=mir_u2a(LogStrW.c_str());
+ file.write(buf,LogStrW.length());
+ mir_free(buf);
+
+ file.close();
+}
+
+boost::mutex clean_mutex;
+
+void CleanProtocolTmpThread(std::string proto)
+{
+ while(true)
+ {
+ UINT status = CallProtoService(proto.c_str(), PS_GETSTATUS, 0, 0);
+ if(status > ID_STATUS_OFFLINE)
+ break;
+ boost::this_thread::sleep(boost::posix_time::seconds(2));
+ }
+
+ std::list<HANDLE> contacts;
+ for(HANDLE hContact = db_find_first(proto.c_str()); hContact; hContact = db_find_next(hContact, proto.c_str()))
+ if(db_get_b(hContact, "CList", "NotOnList", 0)|| (_T("Not In List")== DBGetContactSettingStringPAN(hContact,"CList","Group",_T(""))))
+ contacts.push_back(hContact);
+
+ boost::this_thread::sleep(boost::posix_time::seconds(5));
+ clean_mutex.lock();
+ std::list<HANDLE>::iterator end = contacts.end();
+ for(std::list<HANDLE>::iterator i = contacts.begin(); i != end; ++i)
+ {
+ LogSpamToFile(*i, _T("Deleted"));
+ HistoryLogFunc(*i, "Deleted");
+ CallService(MS_DB_CONTACT_DELETE, (WPARAM)*i, 0);
+ }
+ clean_mutex.unlock();
+}
+
+void CleanProtocolExclThread(std::string proto)
+{
+ while(true)
+ {
+ UINT status = CallProtoService(proto.c_str(), PS_GETSTATUS, 0, 0);
+ if(status > ID_STATUS_OFFLINE)
+ break;
+ boost::this_thread::sleep(boost::posix_time::seconds(2));
+ }
+
+ std::list<HANDLE> contacts;
+ for(HANDLE hContact = db_find_first(proto.c_str()); hContact; hContact = db_find_next(hContact, proto.c_str()))
+ if(db_get_b(hContact, "CList", "NotOnList", 0) && db_get_b(hContact, pluginName, "Excluded", 0))
+ contacts.push_back(hContact);
+
+ boost::this_thread::sleep(boost::posix_time::seconds(5));
+ clean_mutex.lock();
+ std::list<HANDLE>::iterator end = contacts.end();
+ for(std::list<HANDLE>::iterator i = contacts.begin(); i != end; ++i)
+ {
+ LogSpamToFile(*i, _T("Deleted"));
+ HistoryLogFunc(*i, "Deleted");
+ CallService(MS_DB_CONTACT_DELETE, (WPARAM)*i, 0);
+ }
+ clean_mutex.unlock();
+}
+
+void CleanThread()
+{
+ std::list<std::string> protocols;
+ int count = 0;
+ PROTOACCOUNT **accounts;
+ ProtoEnumAccounts(&count, &accounts);
+ for(int i = 0; i < count; i++)
+ {
+ if(!strstr(accounts[i]->szModuleName, "MetaContacts") && !strstr(accounts[i]->szModuleName, "Weather")) //not real protocols
+ protocols.push_back(accounts[i]->szModuleName);
+ }
+ std::list<std::string>::iterator end = protocols.end();
+ for(std::list<std::string>::iterator i = protocols.begin(); i != end; ++i)
+ {
+ if(gbDelAllTempory)
+ boost::thread *thr = new boost::thread(boost::bind(&CleanProtocolTmpThread, *i));
+ if(gbDelExcluded)
+ boost::thread *thr = new boost::thread(boost::bind(&CleanProtocolExclThread, *i));
+ }
+}
+
+void HistoryLog(HANDLE hContact, char *data, int event_type, int flags)
+{
+ DBEVENTINFO Event = { sizeof(Event) };
+ Event.szModule = pluginName;
+ Event.eventType = event_type;
+ Event.flags = flags | DBEF_UTF;
+ Event.timestamp = (DWORD)time(NULL);
+ Event.cbBlob = (DWORD)strlen(data)+1;
+ Event.pBlob = (PBYTE)_strdup(data);
+ db_event_add(hContact, &Event);
+}
+
+void HistoryLogFunc(HANDLE hContact, std::string message)
+{
+ if(gbHistoryLog)
+ {
+ if(hContact == INVALID_HANDLE_VALUE)
+ return;
+ std::string msg = message;
+ msg.append("\n");
+ msg.append("Protocol: ").append(GetContactProto(hContact)).append(" Contact: ");
+ msg.append(toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, GCDNF_TCHAR))).append(" ID: ");
+ msg.append(toUTF8(GetContactUid(hContact,toUTF16(GetContactProto(hContact)))));
+ HistoryLog(NULL, (char*)msg.c_str(), EVENTTYPE_MESSAGE, DBEF_READ);
+ }
+}
+
+std::string toUTF8(std::wstring str)
+{
+ std::string ustr;
+ try{
+ utf8::utf16to8(str.begin(), str.end(), back_inserter(ustr));
+ }
+ catch(const std::exception&)
+ {
+ //TODO: handle utf8cpp exceptions
+ }
+ return ustr;
+}
+
+std::string toUTF8(std::string str)
+{
+ return toUTF8(toUTF16(str));
+}
+
+std::wstring toUTF16(std::string str) //convert as much as possible
+{
+ std::wstring ustr;
+ std::string tmpstr;
+ try{
+ utf8::replace_invalid(str.begin(), str.end(), back_inserter(tmpstr));
+ utf8::utf8to16(tmpstr.begin(), tmpstr.end(), back_inserter(ustr));
+ }
+ catch(const std::exception &)
+ {
+ //TODO: handle utf8cpp exceptions
+ }
+ return ustr;
+}
+
+std::string get_random_num(int length)
+{
+ std::string chars("123456789");
+ std::string data;
+ boost::random_device rng;
+ boost::variate_generator<boost::random_device&, boost::uniform_int<>> gen(rng, boost::uniform_int<>(0, (int)chars.length()-1));
+ for(int i = 0; i < length; ++i)
+ data += chars[gen()];
+ return data;
+}