From 5544a559d7eea6b6da2a9e512e3480a10f31714d Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Wed, 4 Jul 2012 07:47:32 +0000 Subject: AddContactPlus: changed folder structure git-svn-id: http://svn.miranda-ng.org/main/trunk@749 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/AddContactPlus/Version.h | 20 - plugins/AddContactPlus/Version.rc | 38 -- plugins/AddContactPlus/addcontact.cpp | 433 --------------------- .../AddContactPlus/addcontactplus-translation.txt | 27 -- plugins/AddContactPlus/addcontactplus.h | 56 --- plugins/AddContactPlus/addcontactplus_10.vcxproj | 22 +- .../addcontactplus_10.vcxproj.filters | 14 +- plugins/AddContactPlus/contact_add.ico | Bin 6830 -> 0 bytes .../docs/addcontactplus-translation.txt | 27 ++ plugins/AddContactPlus/main.cpp | 202 ---------- plugins/AddContactPlus/res/Version.rc | 38 ++ plugins/AddContactPlus/res/contact_add.ico | Bin 0 -> 6830 bytes plugins/AddContactPlus/res/resource.rc | 134 +++++++ plugins/AddContactPlus/resource.h | 28 -- plugins/AddContactPlus/resource.rc | 134 ------- plugins/AddContactPlus/src/Version.h | 20 + plugins/AddContactPlus/src/addcontact.cpp | 433 +++++++++++++++++++++ plugins/AddContactPlus/src/addcontactplus.h | 56 +++ plugins/AddContactPlus/src/main.cpp | 202 ++++++++++ plugins/AddContactPlus/src/resource.h | 28 ++ 20 files changed, 956 insertions(+), 956 deletions(-) delete mode 100644 plugins/AddContactPlus/Version.h delete mode 100644 plugins/AddContactPlus/Version.rc delete mode 100644 plugins/AddContactPlus/addcontact.cpp delete mode 100644 plugins/AddContactPlus/addcontactplus-translation.txt delete mode 100644 plugins/AddContactPlus/addcontactplus.h delete mode 100644 plugins/AddContactPlus/contact_add.ico create mode 100644 plugins/AddContactPlus/docs/addcontactplus-translation.txt delete mode 100644 plugins/AddContactPlus/main.cpp create mode 100644 plugins/AddContactPlus/res/Version.rc create mode 100644 plugins/AddContactPlus/res/contact_add.ico create mode 100644 plugins/AddContactPlus/res/resource.rc delete mode 100644 plugins/AddContactPlus/resource.h delete mode 100644 plugins/AddContactPlus/resource.rc create mode 100644 plugins/AddContactPlus/src/Version.h create mode 100644 plugins/AddContactPlus/src/addcontact.cpp create mode 100644 plugins/AddContactPlus/src/addcontactplus.h create mode 100644 plugins/AddContactPlus/src/main.cpp create mode 100644 plugins/AddContactPlus/src/resource.h (limited to 'plugins') diff --git a/plugins/AddContactPlus/Version.h b/plugins/AddContactPlus/Version.h deleted file mode 100644 index fa45898d07..0000000000 --- a/plugins/AddContactPlus/Version.h +++ /dev/null @@ -1,20 +0,0 @@ -#define __MAJOR_VERSION 0 -#define __MINOR_VERSION 9 -#define __RELEASE_NUM 9 -#define __BUILD_NUM 0 - -#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM -#define __FILEVERSION_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM - -#define __STRINGIFY_IMPL(x) #x -#define __STRINGIFY(x) __STRINGIFY_IMPL(x) -#define __VERSION_STRING __STRINGIFY(__FILEVERSION_DOTS) - -#define __PLUGIN_NAME "AddContact+" -#define __INTERNAL_NAME "AddContact+" -#define __FILENAME "AddContactPlus.dll" -#define __DESCRIPTION "Provides the ability to quickly add new contacts." -#define __AUTHOR "Bartosz 'Dezeath' Białek" -#define __AUTHOREMAIL "dezred@gmail.com" -#define __AUTHORWEB "http://code.google.com/p/dezeath" -#define __COPYRIGHT "© 2007-2012 Bartosz 'Dezeath' Białek" diff --git a/plugins/AddContactPlus/Version.rc b/plugins/AddContactPlus/Version.rc deleted file mode 100644 index e637f0cb33..0000000000 --- a/plugins/AddContactPlus/Version.rc +++ /dev/null @@ -1,38 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "afxres.h" -#include "version.h" - -#ifdef _WIN32 -LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL -#endif //_WIN32 - -VS_VERSION_INFO VERSIONINFO - FILEVERSION __FILEVERSION_STRING - PRODUCTVERSION __FILEVERSION_STRING - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x0L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "FileDescription", __DESCRIPTION - VALUE "InternalName", __PLUGIN_NAME - VALUE "LegalCopyright", __COPYRIGHT - VALUE "OriginalFilename", __FILENAME - VALUE "ProductName", __PLUGIN_NAME - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0, 1200 - END -END diff --git a/plugins/AddContactPlus/addcontact.cpp b/plugins/AddContactPlus/addcontact.cpp deleted file mode 100644 index a2feb5c449..0000000000 --- a/plugins/AddContactPlus/addcontact.cpp +++ /dev/null @@ -1,433 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2011 Miranda ICQ/IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -Portions of this code modified for AddContact+ plugin -Copyright (C) 2007-2011 Bartosz 'Dezeath' Białek - -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., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ -#include "addcontactplus.h" -#include - -// Function from miranda\src\modules\utils\utils.cpp -TCHAR* __fastcall rtrim(TCHAR* str) -{ - if (str == NULL) return NULL; - TCHAR* p = _tcschr(str, 0); - while (--p >= str) - { - switch (*p) - { - case ' ': case '\t': case '\n': case '\r': - *p = 0; break; - default: - return str; - } - } - return str; -} - -typedef struct // mNetSend protocol -{ - PROTOSEARCHRESULT hdr; - DWORD dwIP; -} NETSENDSEARCHRESULT; - -typedef struct // Myspace protocol -{ - PROTOSEARCHRESULT psr; - int uid; -} MYPROTOSEARCHRESULT; - -typedef struct // Tlen protocol -{ - PROTOSEARCHRESULT hdr; - char jid[256]; -} TLEN_SEARCH_RESULT; - -void AddContactDlgOpts(HWND hdlg, const char* szProto, BOOL bAuthOptsOnly = FALSE) -{ - DWORD flags = (szProto) ? CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) : 0; - if (IsDlgButtonChecked(hdlg, IDC_ADDTEMP)) - { - EnableWindow(GetDlgItem(hdlg, IDC_ADDED), FALSE); - EnableWindow(GetDlgItem(hdlg, IDC_AUTH), FALSE); - EnableWindow(GetDlgItem(hdlg, IDC_AUTHREQ), FALSE); - EnableWindow(GetDlgItem(hdlg, IDC_AUTHGB), FALSE); - } - else - { - EnableWindow(GetDlgItem(hdlg, IDC_ADDED), !(flags & PF4_FORCEADDED)); - EnableWindow(GetDlgItem(hdlg, IDC_AUTH), !(flags & PF4_FORCEAUTH)); - EnableWindow(GetDlgItem(hdlg, IDC_AUTHREQ), (flags & PF4_NOCUSTOMAUTH) ? FALSE : IsDlgButtonChecked(hdlg, IDC_AUTH)); - EnableWindow(GetDlgItem(hdlg, IDC_AUTHGB), (flags & PF4_NOCUSTOMAUTH) ? FALSE : IsDlgButtonChecked(hdlg, IDC_AUTH)); - } - - if (bAuthOptsOnly) - return; - - SetDlgItemText(hdlg, IDC_AUTHREQ, (flags & PF4_NOCUSTOMAUTH) ? _T("") : TranslateT("Please authorize my request and add me to your contact list.")); - - char* szUniqueId = (char*)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDTEXT, 0); - if (szUniqueId) - { - size_t cbLen = strlen(szUniqueId) + 2; - TCHAR* pszUniqueId = (TCHAR*)mir_alloc(cbLen * sizeof(TCHAR)); - mir_sntprintf(pszUniqueId, cbLen, _T(TCHAR_STR_PARAM) _T(":"), szUniqueId); - SetDlgItemText(hdlg, IDC_IDLABEL, pszUniqueId); - mir_free(pszUniqueId); - } - else - SetDlgItemText(hdlg, IDC_IDLABEL, TranslateT("Contact ID:")); - - flags = (szProto) ? CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) : 0; - if (flags & PF1_NUMERICUSERID) - { - char buffer[65]; - SetWindowLongPtr(GetDlgItem(hdlg, IDC_USERID), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hdlg, IDC_USERID), GWL_STYLE) | ES_NUMBER); - if (strstr(szProto, "GG") || strstr(szProto, "MYSPACE")) - _ultoa(INT_MAX, buffer, 10); - else - _ultoa(ULONG_MAX, buffer, 10); - SendDlgItemMessage(hdlg, IDC_USERID, EM_LIMITTEXT, (WPARAM)strlen(buffer), 0); - } - else - { - SetWindowLongPtr(GetDlgItem(hdlg, IDC_USERID), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hdlg, IDC_USERID), GWL_STYLE) &~ES_NUMBER); - SendDlgItemMessage(hdlg, IDC_USERID, EM_LIMITTEXT, 255, 0); - } -} - -void AddContactDlgAccounts(HWND hdlg, ADDCONTACTSTRUCT* acs) -{ - PROTOACCOUNT** pAccounts; - int iRealAccCount, iAccCount = 0, i; - DWORD dwCaps; - - ProtoEnumAccounts(&iRealAccCount, &pAccounts); - for (i = 0; i < iRealAccCount; i++) - { - if (!IsAccountEnabled(pAccounts[i])) continue; - dwCaps = (DWORD)CallProtoService(pAccounts[i]->szModuleName, PS_GETCAPS,PFLAGNUM_1, 0); - if (dwCaps & PF1_BASICSEARCH || dwCaps & PF1_EXTSEARCH || dwCaps & PF1_SEARCHBYEMAIL || dwCaps & PF1_SEARCHBYNAME) - iAccCount++; - } - - if (iAccCount == 0) - { - if (GetParent(hdlg) == NULL) - DestroyWindow(hdlg); - else - EndDialog(hdlg, 0); - return; - } - - HICON hIcon; - SIZE textSize; - RECT rc; - int iIndex = 0, cbWidth = 0; - - HIMAGELIST hIml = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), (IsWinVerXPPlus() ? ILC_COLOR32 : ILC_COLOR16) | ILC_MASK, iAccCount, 0); - ImageList_Destroy((HIMAGELIST)SendDlgItemMessage(hdlg, IDC_PROTO, CBEM_SETIMAGELIST, 0, (LPARAM)hIml)); - SendDlgItemMessage(hdlg, IDC_PROTO, CB_RESETCONTENT, 0, 0); - - COMBOBOXEXITEM cbei = {0}; - cbei.mask = CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_TEXT | CBEIF_LPARAM; - HDC hdc = GetDC(hdlg); - SelectObject(hdc, (HFONT)SendDlgItemMessage(hdlg, IDC_PROTO, WM_GETFONT, 0, 0)); - for (i = 0; i < iRealAccCount; i++) - { - if (!IsAccountEnabled(pAccounts[i])) continue; - dwCaps = (DWORD)CallProtoService(pAccounts[i]->szModuleName, PS_GETCAPS,PFLAGNUM_1, 0); - if (!(dwCaps & PF1_BASICSEARCH) && !(dwCaps & PF1_EXTSEARCH) && !(dwCaps & PF1_SEARCHBYEMAIL) && !(dwCaps & PF1_SEARCHBYNAME)) - continue; - - cbei.pszText = pAccounts[i]->tszAccountName; - GetTextExtentPoint32(hdc, cbei.pszText, lstrlen(cbei.pszText), &textSize); - if (textSize.cx > cbWidth) cbWidth = textSize.cx; - hIcon = (HICON)CallProtoService(pAccounts[i]->szModuleName, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0); - cbei.iImage = cbei.iSelectedImage = ImageList_AddIcon(hIml, hIcon); - DestroyIcon(hIcon); - cbei.lParam = (LPARAM)pAccounts[i]->szModuleName; - SendDlgItemMessage(hdlg, IDC_PROTO, CBEM_INSERTITEM, 0, (LPARAM)&cbei); - if (acs->szProto && cbei.lParam && !strcmp(acs->szProto, pAccounts[i]->szModuleName)) - iIndex = cbei.iItem; - cbei.iItem++; - } - cbWidth += 32; - SendDlgItemMessage(hdlg, IDC_PROTO, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&rc); - if ((rc.right - rc.left) < cbWidth) - SendDlgItemMessage(hdlg, IDC_PROTO, CB_SETDROPPEDWIDTH, cbWidth, 0); - SendDlgItemMessage(hdlg, IDC_PROTO, CB_SETCURSEL, iIndex, 0); - SendMessage(hdlg, WM_COMMAND, MAKEWPARAM(IDC_PROTO, CBN_SELCHANGE), (LPARAM)GetDlgItem(hdlg, IDC_PROTO)); - if (iAccCount == 1) - SetFocus(GetDlgItem(hdlg, IDC_USERID)); -} - -#define DM_ADDCONTACT_CHANGEICONS WM_USER + 11 -#define DM_ADDCONTACT_CHANGEACCLIST WM_USER + 12 - -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)CallService(MS_SKIN2_GETICON, 1, (LPARAM)ICON_ADD)); - SendMessage(hdlg, WM_SETICON, ICON_SMALL, (LPARAM)CallService(MS_SKIN2_GETICON, 0, (LPARAM)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]; - int id; - _itoa(groupId, idstr, 10); - if (DBGetContactSettingTString(NULL, "CListGroups", idstr, &dbv)) break; - id = SendDlgItemMessage(hdlg, IDC_GROUP, CB_ADDSTRING, 0, (LPARAM)(dbv.ptszVal + 1)); - SendDlgItemMessage(hdlg, IDC_GROUP, CB_SETITEMDATA, (WPARAM)id, (LPARAM)groupId + 1); - DBFreeVariant(&dbv); - } - } - SendDlgItemMessage(hdlg, IDC_GROUP, CB_INSERTSTRING, 0, (LPARAM)TranslateT("None")); - SendDlgItemMessage(hdlg, IDC_GROUP, CB_SETCURSEL, 0, 0); - - 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); - } - 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); - } - if (HIWORD(wparam) == CBN_CLOSEUP) - SetFocus(GetDlgItem(hdlg, IDC_USERID)); - break; - - case IDC_ADDTEMP: - AddContactDlgOpts(hdlg, acs->szProto, TRUE); - break; - - case IDC_AUTH: - { - 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 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))) - { - 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), TCHAR_STR_PARAM, 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) - { - 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; - } - - TCHAR szHandle[256]; - if (GetDlgItemText(hdlg, IDC_MYHANDLE, szHandle, SIZEOF(szHandle))) - DBWriteContactSettingTString(hContact, "CList", "MyHandle", szHandle); - - 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)) - { - DBDeleteContactSetting(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 - { - 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 (GetParent(hdlg) == NULL) - DestroyWindow(hdlg); - else - EndDialog(hdlg, 0); - break; - - case DM_ADDCONTACT_CHANGEICONS: - CallService(MS_SKIN2_RELEASEICONBIG, (WPARAM)SendMessage(hdlg, WM_SETICON, ICON_BIG, (LPARAM)CallService(MS_SKIN2_GETICON, 1, (LPARAM)ICON_ADD)), 0); - CallService(MS_SKIN2_RELEASEICON, (WPARAM)SendMessage(hdlg, WM_SETICON, ICON_SMALL, (LPARAM)CallService(MS_SKIN2_GETICON, 0, (LPARAM)ICON_ADD)), 0); - break; - - case DM_ADDCONTACT_CHANGEACCLIST: - { - acs = (ADDCONTACTSTRUCT*)GetWindowLongPtr(hdlg, GWLP_USERDATA); - AddContactDlgAccounts(hdlg, acs); - break; - } - - case WM_DESTROY: - CallService(MS_SKIN2_RELEASEICONBIG, (WPARAM)SendMessage(hdlg, WM_SETICON, ICON_BIG, (LPARAM)NULL), 0); - CallService(MS_SKIN2_RELEASEICON, (WPARAM)SendMessage(hdlg, WM_SETICON, ICON_SMALL, (LPARAM)NULL), 0); - ImageList_Destroy((HIMAGELIST)SendDlgItemMessage(hdlg, IDC_PROTO, CBEM_GETIMAGELIST, 0, 0)); - acs = (ADDCONTACTSTRUCT*)GetWindowLongPtr(hdlg, GWLP_USERDATA); - if (acs) - { - 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); - } - Utils_SaveWindowPosition(hdlg, NULL, "AddContact", ""); - break; - } - - return FALSE; -} diff --git a/plugins/AddContactPlus/addcontactplus-translation.txt b/plugins/AddContactPlus/addcontactplus-translation.txt deleted file mode 100644 index 38432dbe43..0000000000 --- a/plugins/AddContactPlus/addcontactplus-translation.txt +++ /dev/null @@ -1,27 +0,0 @@ -; Common strings that belong to many files -;[Add Contact] -;[Contact ID:] - -; ../../plugins/AddContactPlus/addcontact.cpp -;[None] -;[Please authorize my request and add me to your contact list.] -;[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.] -;[The contact cannot be added to your contact list. Please make sure the contact ID is entered correctly.] - -; ../../plugins/AddContactPlus/main.cpp -;[&Add Contact...] -;[Main] -;[Open Add Contact Dialog] - -; ../../plugins/AddContactPlus/resource.rc -;[&Add] -;[&Cancel] -;[Account:] -;[Add Contact\nAdd a contact to your contact list] -;[Add temporarily] -;[Authorization Request] -;[Custom name:] -;[Group:] -;[Options] -;[Send \"You were added\"] -;[Send authorization request] diff --git a/plugins/AddContactPlus/addcontactplus.h b/plugins/AddContactPlus/addcontactplus.h deleted file mode 100644 index 6e9d90e9fd..0000000000 --- a/plugins/AddContactPlus/addcontactplus.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - -AddContact+ plugin for Miranda IM - -Copyright (C) 2007-2011 Bartosz 'Dezeath' Białek - -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., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -// to enable all 0.9 core functions -#define MIRANDA_VER 0x0A00 - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "m_toolbar.h" -#include "m_updater.h" -#include "m_addcontactplus.h" - -#include "resource.h" -#include "version.h" - -#define ICON_ADD "AddContactPlus_Icon" - -INT_PTR CALLBACK AddContactDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam); -extern HINSTANCE hInst; diff --git a/plugins/AddContactPlus/addcontactplus_10.vcxproj b/plugins/AddContactPlus/addcontactplus_10.vcxproj index cd1cbd5430..e443dc3069 100644 --- a/plugins/AddContactPlus/addcontactplus_10.vcxproj +++ b/plugins/AddContactPlus/addcontactplus_10.vcxproj @@ -75,7 +75,7 @@ OnlyExplicitInline Size ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;UNICODE;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) true false true @@ -103,7 +103,7 @@ Disabled ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;UNICODE;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) false true EnableFastChecks @@ -133,7 +133,7 @@ OnlyExplicitInline Size ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN64;NDEBUG;_WINDOWS;UNICODE;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + WIN64;NDEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) true false true @@ -161,7 +161,7 @@ Disabled ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN64;_DEBUG;_WINDOWS;UNICODE;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + WIN64;_DEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) false true EnableFastChecks @@ -185,19 +185,19 @@ - - + + - - + + - + - - + + diff --git a/plugins/AddContactPlus/addcontactplus_10.vcxproj.filters b/plugins/AddContactPlus/addcontactplus_10.vcxproj.filters index b87d889578..2dacf09fed 100644 --- a/plugins/AddContactPlus/addcontactplus_10.vcxproj.filters +++ b/plugins/AddContactPlus/addcontactplus_10.vcxproj.filters @@ -15,31 +15,31 @@ - + Source Files - + Source Files - + Header Files - + Header Files - + Resource Files - + Resource Files - + Resource Files diff --git a/plugins/AddContactPlus/contact_add.ico b/plugins/AddContactPlus/contact_add.ico deleted file mode 100644 index 53788e9990..0000000000 Binary files a/plugins/AddContactPlus/contact_add.ico and /dev/null differ diff --git a/plugins/AddContactPlus/docs/addcontactplus-translation.txt b/plugins/AddContactPlus/docs/addcontactplus-translation.txt new file mode 100644 index 0000000000..38432dbe43 --- /dev/null +++ b/plugins/AddContactPlus/docs/addcontactplus-translation.txt @@ -0,0 +1,27 @@ +; Common strings that belong to many files +;[Add Contact] +;[Contact ID:] + +; ../../plugins/AddContactPlus/addcontact.cpp +;[None] +;[Please authorize my request and add me to your contact list.] +;[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.] +;[The contact cannot be added to your contact list. Please make sure the contact ID is entered correctly.] + +; ../../plugins/AddContactPlus/main.cpp +;[&Add Contact...] +;[Main] +;[Open Add Contact Dialog] + +; ../../plugins/AddContactPlus/resource.rc +;[&Add] +;[&Cancel] +;[Account:] +;[Add Contact\nAdd a contact to your contact list] +;[Add temporarily] +;[Authorization Request] +;[Custom name:] +;[Group:] +;[Options] +;[Send \"You were added\"] +;[Send authorization request] diff --git a/plugins/AddContactPlus/main.cpp b/plugins/AddContactPlus/main.cpp deleted file mode 100644 index 56d8b0ad1b..0000000000 --- a/plugins/AddContactPlus/main.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/* - -AddContact+ plugin for Miranda IM - -Copyright (C) 2007-2011 Bartosz 'Dezeath' Białek - -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., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ -#include "addcontactplus.h" - -HINSTANCE hInst; -int hLangpack; -static HANDLE hModulesLoaded = 0, hChangedIcons = 0, hAccListChanged = 0, - hMainMenuItem = 0, hToolBarItem = 0, hService = 0; -HANDLE hIconLibItem; - -PLUGININFOEX pluginInfo = { - sizeof(PLUGININFOEX), - __PLUGIN_NAME, - PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), - __DESCRIPTION, - __AUTHOR, - __AUTHOREMAIL, - __COPYRIGHT, - __AUTHORWEB, - UNICODE_AWARE, - // {6471D451-2FE0-4ee2-850E-9F84F3C0D187} - { 0x6471d451, 0x2fe0, 0x4ee2, { 0x85, 0xe, 0x9f, 0x84, 0xf3, 0xc0, 0xd1, 0x87 } } -}; - -static const MUUID interfaces[] = {MIID_ADDCONTACTPLUS, MIID_LAST}; - -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) -{ - hInst = hinstDLL; - return TRUE; -} - -extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) -{ - return &pluginInfo; -} - -extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) -{ - return interfaces; -} - -INT_PTR AddContactPlusDialog(WPARAM, LPARAM) -{ - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADDCONTACT), (HWND)NULL, AddContactDlgProc, 0); - return 0; -} - -static int OnIconsChanged(WPARAM, LPARAM) -{ - CLISTMENUITEM mi = {0}; - - if (!hMainMenuItem) - return 0; - - mi.cbSize = sizeof(mi); - mi.flags = CMIM_ICON | CMIF_ICONFROMICOLIB | CMIF_TCHAR; - mi.icolibItem = hIconLibItem; - CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMainMenuItem, (LPARAM)&mi); - - return 0; -} - -static int OnAccListChanged(WPARAM, LPARAM) -{ - PROTOACCOUNT** pAccounts; - int iRealAccCount, iAccCount = 0; - DWORD dwCaps; - - ProtoEnumAccounts(&iRealAccCount, &pAccounts); - for (int i = 0; i < iRealAccCount; i++) - { - if (!IsAccountEnabled(pAccounts[i])) continue; - dwCaps = (DWORD)CallProtoService(pAccounts[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0); - if (dwCaps & PF1_BASICSEARCH || dwCaps & PF1_EXTSEARCH || dwCaps & PF1_SEARCHBYEMAIL || dwCaps & PF1_SEARCHBYNAME) - iAccCount++; - } - - if (iAccCount) - { - CLISTMENUITEM mi = {0}; - - if (hMainMenuItem) - return 0; - - mi.cbSize = sizeof(mi); - mi.position = 500020001; - mi.flags = CMIF_ICONFROMICOLIB | CMIF_TCHAR; - mi.icolibItem = hIconLibItem; - mi.ptszName = LPGENT("&Add Contact..."); - mi.pszService = MS_ADDCONTACTPLUS_SHOW; - hMainMenuItem = Menu_AddMainMenuItem(&mi); - - if (ServiceExists(MS_TB_ADDBUTTON)) - { - TBButton tbb = {0}; - - tbb.cbSize = sizeof(TBButton); - tbb.tbbFlags = TBBF_VISIBLE | TBBF_SHOWTOOLTIP; - tbb.pszButtonID = "acplus_btn"; - tbb.pszButtonName = Translate("Add Contact"); - tbb.pszServiceName = MS_ADDCONTACTPLUS_SHOW; - tbb.pszTooltipUp = Translate("Add Contact"); - tbb.hPrimaryIconHandle = hIconLibItem; - tbb.defPos = 10100; - hToolBarItem = (HANDLE)CallService(MS_TB_ADDBUTTON, 0, (LPARAM)&tbb); - } - } - else - { - if (!hMainMenuItem) - return 0; - - CallService(MS_CLIST_REMOVEMAINMENUITEM, (WPARAM)hMainMenuItem, 0); - CallService(MS_TB_REMOVEBUTTON, (WPARAM)hToolBarItem, 0); - - hMainMenuItem = 0; - } - - return 0; -} - -static int OnModulesLoaded(WPARAM, LPARAM) -{ - if (ServiceExists(MS_UPDATE_REGISTERFL)) -#if defined(_WIN64) - CallService(MS_UPDATE_REGISTERFL, 4414, (LPARAM)&pluginInfo); -#else - CallService(MS_UPDATE_REGISTERFL, 3842, (LPARAM)&pluginInfo); -#endif - - SKINICONDESC sid = {0}; - char szFile[MAX_PATH]; - GetModuleFileNameA(hInst, szFile, MAX_PATH); - sid.cbSize = sizeof(SKINICONDESC); - sid.flags = SIDF_TCHAR; - sid.pszDefaultFile = szFile; - sid.ptszSection = _T("AddContact+"); - sid.iDefaultIndex = -IDI_ADDCONTACT; - sid.ptszDescription = LPGENT("Add Contact"); - sid.pszName = ICON_ADD; - hIconLibItem = Skin_AddIcon(&sid); - hChangedIcons = HookEvent(ME_SKIN2_ICONSCHANGED, OnIconsChanged); - - HOTKEYDESC hkd = {0}; - hkd.cbSize = sizeof(hkd); - hkd.dwFlags = HKD_TCHAR; - hkd.pszName = "AddContactPlus_OpenDialog"; - hkd.ptszDescription = LPGENT("Open Add Contact Dialog"); - hkd.ptszSection = LPGENT("Main"); - hkd.pszService = MS_ADDCONTACTPLUS_SHOW; - hkd.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL | HOTKEYF_SHIFT, 'C') | HKF_MIRANDA_LOCAL; - Hotkey_Register(&hkd); - - OnAccListChanged(0, 0); - - return 0; -} - -extern "C" int __declspec(dllexport) Load(void) -{ - mir_getLP(&pluginInfo); - - INITCOMMONCONTROLSEX icex = {0}; - icex.dwSize = sizeof(INITCOMMONCONTROLSEX); - icex.dwICC = ICC_USEREX_CLASSES; - InitCommonControlsEx(&icex); - - hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); - hAccListChanged = HookEvent(ME_PROTO_ACCLISTCHANGED, OnAccListChanged); - hService = CreateServiceFunction(MS_ADDCONTACTPLUS_SHOW, AddContactPlusDialog); - - return 0; -} - -extern "C" int __declspec(dllexport) Unload(void) -{ - UnhookEvent(hModulesLoaded); - UnhookEvent(hChangedIcons); - UnhookEvent(hAccListChanged); - DestroyServiceFunction(hService); - - return 0; -} diff --git a/plugins/AddContactPlus/res/Version.rc b/plugins/AddContactPlus/res/Version.rc new file mode 100644 index 0000000000..700fecb1fc --- /dev/null +++ b/plugins/AddContactPlus/res/Version.rc @@ -0,0 +1,38 @@ +// Microsoft Visual C++ generated resource script. +// +#include "afxres.h" +#include "..\src\version.h" + +#ifdef _WIN32 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +#endif //_WIN32 + +VS_VERSION_INFO VERSIONINFO + FILEVERSION __FILEVERSION_STRING + PRODUCTVERSION __FILEVERSION_STRING + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x0L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "FileDescription", __DESCRIPTION + VALUE "InternalName", __PLUGIN_NAME + VALUE "LegalCopyright", __COPYRIGHT + VALUE "OriginalFilename", __FILENAME + VALUE "ProductName", __PLUGIN_NAME + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END diff --git a/plugins/AddContactPlus/res/contact_add.ico b/plugins/AddContactPlus/res/contact_add.ico new file mode 100644 index 0000000000..53788e9990 Binary files /dev/null and b/plugins/AddContactPlus/res/contact_add.ico differ diff --git a/plugins/AddContactPlus/res/resource.rc b/plugins/AddContactPlus/res/resource.rc new file mode 100644 index 0000000000..098ea223a5 --- /dev/null +++ b/plugins/AddContactPlus/res/resource.rc @@ -0,0 +1,134 @@ +//Microsoft Developer Studio generated resource script. +// +#include "..\src\resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Polish resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_PLK) +#ifdef _WIN32 +LANGUAGE LANG_POLISH, SUBLANG_DEFAULT +#pragma code_page(1250) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "..\src\resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_ADDCONTACT ICON DISCARDABLE "contact_add.ico" +#endif // Polish resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ADDCONTACT DIALOGEX 0, 0, 230, 219 +STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_CONTROLPARENT +CAPTION "Add Contact" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + CONTROL "Add Contact\nAdd a contact to your contact list",IDC_HEADERBAR,"MHeaderbarCtrl",0x0,0,0,230,25 + LTEXT "Account:",IDC_STATIC,6,29,89,10 + CONTROL "",IDC_PROTO,"ComboBoxEx32",CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP,6,41,90,80 + LTEXT "Contact ID:",IDC_IDLABEL,112,29,108,10 + EDITTEXT IDC_USERID,112,41,110,12,ES_AUTOHSCROLL + LTEXT "Custom name:",IDC_STATIC,6,58,89,10 + EDITTEXT IDC_MYHANDLE,6,70,90,12,ES_AUTOHSCROLL + LTEXT "Group:",IDC_STATIC,112,58,108,10 + COMBOBOX IDC_GROUP,112,70,110,60,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP + GROUPBOX "Options",IDC_STATIC,7,87,216,57 + CONTROL "Add temporarily",IDC_ADDTEMP,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,11,100,204,10 + CONTROL "Send ""You were added""",IDC_ADDED,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,11,114,204,10 + CONTROL "Send authorization request",IDC_AUTH,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,11,128,204,10 + GROUPBOX "Authorization Request",IDC_AUTHGB,7,147,216,45 + EDITTEXT IDC_AUTHREQ,13,157,204,29,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL + DEFPUSHBUTTON "&Add",IDOK,20,198,72,14 + PUSHBUTTON "&Cancel",IDCANCEL,139,198,71,14 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO DISCARDABLE +BEGIN + IDD_ADDCONTACT, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 223 + TOPMARGIN, 7 + BOTTOMMARGIN, 144 + END +END +#endif // APSTUDIO_INVOKED + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/AddContactPlus/resource.h b/plugins/AddContactPlus/resource.h deleted file mode 100644 index b796c401d0..0000000000 --- a/plugins/AddContactPlus/resource.h +++ /dev/null @@ -1,28 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by resource.rc -// -#define IDD_ADDCONTACT 101 -#define IDI_ADDCONTACT 102 -#define IDC_MYHANDLE 1000 -#define IDC_GROUP 1001 -#define IDC_ADDED 1002 -#define IDC_AUTH 1003 -#define IDC_AUTHGB 1004 -#define IDC_AUTHREQ 1005 -#define IDC_USERID 1006 -#define IDC_PROTO 1007 -#define IDC_IDLABEL 1008 -#define IDC_HEADERBAR 1009 -#define IDC_ADDTEMP 1010 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 103 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1011 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/plugins/AddContactPlus/resource.rc b/plugins/AddContactPlus/resource.rc deleted file mode 100644 index 932df05741..0000000000 --- a/plugins/AddContactPlus/resource.rc +++ /dev/null @@ -1,134 +0,0 @@ -//Microsoft Developer Studio generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Polish resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_PLK) -#ifdef _WIN32 -LANGUAGE LANG_POLISH, SUBLANG_DEFAULT -#pragma code_page(1250) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_ADDCONTACT ICON DISCARDABLE "contact_add.ico" -#endif // Polish resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ADDCONTACT DIALOGEX 0, 0, 230, 219 -STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_CONTROLPARENT -CAPTION "Add Contact" -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - CONTROL "Add Contact\nAdd a contact to your contact list",IDC_HEADERBAR,"MHeaderbarCtrl",0x0,0,0,230,25 - LTEXT "Account:",IDC_STATIC,6,29,89,10 - CONTROL "",IDC_PROTO,"ComboBoxEx32",CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP,6,41,90,80 - LTEXT "Contact ID:",IDC_IDLABEL,112,29,108,10 - EDITTEXT IDC_USERID,112,41,110,12,ES_AUTOHSCROLL - LTEXT "Custom name:",IDC_STATIC,6,58,89,10 - EDITTEXT IDC_MYHANDLE,6,70,90,12,ES_AUTOHSCROLL - LTEXT "Group:",IDC_STATIC,112,58,108,10 - COMBOBOX IDC_GROUP,112,70,110,60,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP - GROUPBOX "Options",IDC_STATIC,7,87,216,57 - CONTROL "Add temporarily",IDC_ADDTEMP,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,11,100,204,10 - CONTROL "Send ""You were added""",IDC_ADDED,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,11,114,204,10 - CONTROL "Send authorization request",IDC_AUTH,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,11,128,204,10 - GROUPBOX "Authorization Request",IDC_AUTHGB,7,147,216,45 - EDITTEXT IDC_AUTHREQ,13,157,204,29,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL - DEFPUSHBUTTON "&Add",IDOK,20,198,72,14 - PUSHBUTTON "&Cancel",IDCANCEL,139,198,71,14 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE -BEGIN - IDD_ADDCONTACT, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 223 - TOPMARGIN, 7 - BOTTOMMARGIN, 144 - END -END -#endif // APSTUDIO_INVOKED - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/plugins/AddContactPlus/src/Version.h b/plugins/AddContactPlus/src/Version.h new file mode 100644 index 0000000000..fa45898d07 --- /dev/null +++ b/plugins/AddContactPlus/src/Version.h @@ -0,0 +1,20 @@ +#define __MAJOR_VERSION 0 +#define __MINOR_VERSION 9 +#define __RELEASE_NUM 9 +#define __BUILD_NUM 0 + +#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM +#define __FILEVERSION_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM + +#define __STRINGIFY_IMPL(x) #x +#define __STRINGIFY(x) __STRINGIFY_IMPL(x) +#define __VERSION_STRING __STRINGIFY(__FILEVERSION_DOTS) + +#define __PLUGIN_NAME "AddContact+" +#define __INTERNAL_NAME "AddContact+" +#define __FILENAME "AddContactPlus.dll" +#define __DESCRIPTION "Provides the ability to quickly add new contacts." +#define __AUTHOR "Bartosz 'Dezeath' Białek" +#define __AUTHOREMAIL "dezred@gmail.com" +#define __AUTHORWEB "http://code.google.com/p/dezeath" +#define __COPYRIGHT "© 2007-2012 Bartosz 'Dezeath' Białek" diff --git a/plugins/AddContactPlus/src/addcontact.cpp b/plugins/AddContactPlus/src/addcontact.cpp new file mode 100644 index 0000000000..a2feb5c449 --- /dev/null +++ b/plugins/AddContactPlus/src/addcontact.cpp @@ -0,0 +1,433 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2011 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +Portions of this code modified for AddContact+ plugin +Copyright (C) 2007-2011 Bartosz 'Dezeath' Białek + +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., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +#include "addcontactplus.h" +#include + +// Function from miranda\src\modules\utils\utils.cpp +TCHAR* __fastcall rtrim(TCHAR* str) +{ + if (str == NULL) return NULL; + TCHAR* p = _tcschr(str, 0); + while (--p >= str) + { + switch (*p) + { + case ' ': case '\t': case '\n': case '\r': + *p = 0; break; + default: + return str; + } + } + return str; +} + +typedef struct // mNetSend protocol +{ + PROTOSEARCHRESULT hdr; + DWORD dwIP; +} NETSENDSEARCHRESULT; + +typedef struct // Myspace protocol +{ + PROTOSEARCHRESULT psr; + int uid; +} MYPROTOSEARCHRESULT; + +typedef struct // Tlen protocol +{ + PROTOSEARCHRESULT hdr; + char jid[256]; +} TLEN_SEARCH_RESULT; + +void AddContactDlgOpts(HWND hdlg, const char* szProto, BOOL bAuthOptsOnly = FALSE) +{ + DWORD flags = (szProto) ? CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) : 0; + if (IsDlgButtonChecked(hdlg, IDC_ADDTEMP)) + { + EnableWindow(GetDlgItem(hdlg, IDC_ADDED), FALSE); + EnableWindow(GetDlgItem(hdlg, IDC_AUTH), FALSE); + EnableWindow(GetDlgItem(hdlg, IDC_AUTHREQ), FALSE); + EnableWindow(GetDlgItem(hdlg, IDC_AUTHGB), FALSE); + } + else + { + EnableWindow(GetDlgItem(hdlg, IDC_ADDED), !(flags & PF4_FORCEADDED)); + EnableWindow(GetDlgItem(hdlg, IDC_AUTH), !(flags & PF4_FORCEAUTH)); + EnableWindow(GetDlgItem(hdlg, IDC_AUTHREQ), (flags & PF4_NOCUSTOMAUTH) ? FALSE : IsDlgButtonChecked(hdlg, IDC_AUTH)); + EnableWindow(GetDlgItem(hdlg, IDC_AUTHGB), (flags & PF4_NOCUSTOMAUTH) ? FALSE : IsDlgButtonChecked(hdlg, IDC_AUTH)); + } + + if (bAuthOptsOnly) + return; + + SetDlgItemText(hdlg, IDC_AUTHREQ, (flags & PF4_NOCUSTOMAUTH) ? _T("") : TranslateT("Please authorize my request and add me to your contact list.")); + + char* szUniqueId = (char*)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDTEXT, 0); + if (szUniqueId) + { + size_t cbLen = strlen(szUniqueId) + 2; + TCHAR* pszUniqueId = (TCHAR*)mir_alloc(cbLen * sizeof(TCHAR)); + mir_sntprintf(pszUniqueId, cbLen, _T(TCHAR_STR_PARAM) _T(":"), szUniqueId); + SetDlgItemText(hdlg, IDC_IDLABEL, pszUniqueId); + mir_free(pszUniqueId); + } + else + SetDlgItemText(hdlg, IDC_IDLABEL, TranslateT("Contact ID:")); + + flags = (szProto) ? CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) : 0; + if (flags & PF1_NUMERICUSERID) + { + char buffer[65]; + SetWindowLongPtr(GetDlgItem(hdlg, IDC_USERID), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hdlg, IDC_USERID), GWL_STYLE) | ES_NUMBER); + if (strstr(szProto, "GG") || strstr(szProto, "MYSPACE")) + _ultoa(INT_MAX, buffer, 10); + else + _ultoa(ULONG_MAX, buffer, 10); + SendDlgItemMessage(hdlg, IDC_USERID, EM_LIMITTEXT, (WPARAM)strlen(buffer), 0); + } + else + { + SetWindowLongPtr(GetDlgItem(hdlg, IDC_USERID), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hdlg, IDC_USERID), GWL_STYLE) &~ES_NUMBER); + SendDlgItemMessage(hdlg, IDC_USERID, EM_LIMITTEXT, 255, 0); + } +} + +void AddContactDlgAccounts(HWND hdlg, ADDCONTACTSTRUCT* acs) +{ + PROTOACCOUNT** pAccounts; + int iRealAccCount, iAccCount = 0, i; + DWORD dwCaps; + + ProtoEnumAccounts(&iRealAccCount, &pAccounts); + for (i = 0; i < iRealAccCount; i++) + { + if (!IsAccountEnabled(pAccounts[i])) continue; + dwCaps = (DWORD)CallProtoService(pAccounts[i]->szModuleName, PS_GETCAPS,PFLAGNUM_1, 0); + if (dwCaps & PF1_BASICSEARCH || dwCaps & PF1_EXTSEARCH || dwCaps & PF1_SEARCHBYEMAIL || dwCaps & PF1_SEARCHBYNAME) + iAccCount++; + } + + if (iAccCount == 0) + { + if (GetParent(hdlg) == NULL) + DestroyWindow(hdlg); + else + EndDialog(hdlg, 0); + return; + } + + HICON hIcon; + SIZE textSize; + RECT rc; + int iIndex = 0, cbWidth = 0; + + HIMAGELIST hIml = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), (IsWinVerXPPlus() ? ILC_COLOR32 : ILC_COLOR16) | ILC_MASK, iAccCount, 0); + ImageList_Destroy((HIMAGELIST)SendDlgItemMessage(hdlg, IDC_PROTO, CBEM_SETIMAGELIST, 0, (LPARAM)hIml)); + SendDlgItemMessage(hdlg, IDC_PROTO, CB_RESETCONTENT, 0, 0); + + COMBOBOXEXITEM cbei = {0}; + cbei.mask = CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_TEXT | CBEIF_LPARAM; + HDC hdc = GetDC(hdlg); + SelectObject(hdc, (HFONT)SendDlgItemMessage(hdlg, IDC_PROTO, WM_GETFONT, 0, 0)); + for (i = 0; i < iRealAccCount; i++) + { + if (!IsAccountEnabled(pAccounts[i])) continue; + dwCaps = (DWORD)CallProtoService(pAccounts[i]->szModuleName, PS_GETCAPS,PFLAGNUM_1, 0); + if (!(dwCaps & PF1_BASICSEARCH) && !(dwCaps & PF1_EXTSEARCH) && !(dwCaps & PF1_SEARCHBYEMAIL) && !(dwCaps & PF1_SEARCHBYNAME)) + continue; + + cbei.pszText = pAccounts[i]->tszAccountName; + GetTextExtentPoint32(hdc, cbei.pszText, lstrlen(cbei.pszText), &textSize); + if (textSize.cx > cbWidth) cbWidth = textSize.cx; + hIcon = (HICON)CallProtoService(pAccounts[i]->szModuleName, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0); + cbei.iImage = cbei.iSelectedImage = ImageList_AddIcon(hIml, hIcon); + DestroyIcon(hIcon); + cbei.lParam = (LPARAM)pAccounts[i]->szModuleName; + SendDlgItemMessage(hdlg, IDC_PROTO, CBEM_INSERTITEM, 0, (LPARAM)&cbei); + if (acs->szProto && cbei.lParam && !strcmp(acs->szProto, pAccounts[i]->szModuleName)) + iIndex = cbei.iItem; + cbei.iItem++; + } + cbWidth += 32; + SendDlgItemMessage(hdlg, IDC_PROTO, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&rc); + if ((rc.right - rc.left) < cbWidth) + SendDlgItemMessage(hdlg, IDC_PROTO, CB_SETDROPPEDWIDTH, cbWidth, 0); + SendDlgItemMessage(hdlg, IDC_PROTO, CB_SETCURSEL, iIndex, 0); + SendMessage(hdlg, WM_COMMAND, MAKEWPARAM(IDC_PROTO, CBN_SELCHANGE), (LPARAM)GetDlgItem(hdlg, IDC_PROTO)); + if (iAccCount == 1) + SetFocus(GetDlgItem(hdlg, IDC_USERID)); +} + +#define DM_ADDCONTACT_CHANGEICONS WM_USER + 11 +#define DM_ADDCONTACT_CHANGEACCLIST WM_USER + 12 + +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)CallService(MS_SKIN2_GETICON, 1, (LPARAM)ICON_ADD)); + SendMessage(hdlg, WM_SETICON, ICON_SMALL, (LPARAM)CallService(MS_SKIN2_GETICON, 0, (LPARAM)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]; + int id; + _itoa(groupId, idstr, 10); + if (DBGetContactSettingTString(NULL, "CListGroups", idstr, &dbv)) break; + id = SendDlgItemMessage(hdlg, IDC_GROUP, CB_ADDSTRING, 0, (LPARAM)(dbv.ptszVal + 1)); + SendDlgItemMessage(hdlg, IDC_GROUP, CB_SETITEMDATA, (WPARAM)id, (LPARAM)groupId + 1); + DBFreeVariant(&dbv); + } + } + SendDlgItemMessage(hdlg, IDC_GROUP, CB_INSERTSTRING, 0, (LPARAM)TranslateT("None")); + SendDlgItemMessage(hdlg, IDC_GROUP, CB_SETCURSEL, 0, 0); + + 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); + } + 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); + } + if (HIWORD(wparam) == CBN_CLOSEUP) + SetFocus(GetDlgItem(hdlg, IDC_USERID)); + break; + + case IDC_ADDTEMP: + AddContactDlgOpts(hdlg, acs->szProto, TRUE); + break; + + case IDC_AUTH: + { + 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 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))) + { + 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), TCHAR_STR_PARAM, 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) + { + 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; + } + + TCHAR szHandle[256]; + if (GetDlgItemText(hdlg, IDC_MYHANDLE, szHandle, SIZEOF(szHandle))) + DBWriteContactSettingTString(hContact, "CList", "MyHandle", szHandle); + + 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)) + { + DBDeleteContactSetting(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 + { + 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 (GetParent(hdlg) == NULL) + DestroyWindow(hdlg); + else + EndDialog(hdlg, 0); + break; + + case DM_ADDCONTACT_CHANGEICONS: + CallService(MS_SKIN2_RELEASEICONBIG, (WPARAM)SendMessage(hdlg, WM_SETICON, ICON_BIG, (LPARAM)CallService(MS_SKIN2_GETICON, 1, (LPARAM)ICON_ADD)), 0); + CallService(MS_SKIN2_RELEASEICON, (WPARAM)SendMessage(hdlg, WM_SETICON, ICON_SMALL, (LPARAM)CallService(MS_SKIN2_GETICON, 0, (LPARAM)ICON_ADD)), 0); + break; + + case DM_ADDCONTACT_CHANGEACCLIST: + { + acs = (ADDCONTACTSTRUCT*)GetWindowLongPtr(hdlg, GWLP_USERDATA); + AddContactDlgAccounts(hdlg, acs); + break; + } + + case WM_DESTROY: + CallService(MS_SKIN2_RELEASEICONBIG, (WPARAM)SendMessage(hdlg, WM_SETICON, ICON_BIG, (LPARAM)NULL), 0); + CallService(MS_SKIN2_RELEASEICON, (WPARAM)SendMessage(hdlg, WM_SETICON, ICON_SMALL, (LPARAM)NULL), 0); + ImageList_Destroy((HIMAGELIST)SendDlgItemMessage(hdlg, IDC_PROTO, CBEM_GETIMAGELIST, 0, 0)); + acs = (ADDCONTACTSTRUCT*)GetWindowLongPtr(hdlg, GWLP_USERDATA); + if (acs) + { + 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); + } + Utils_SaveWindowPosition(hdlg, NULL, "AddContact", ""); + break; + } + + return FALSE; +} diff --git a/plugins/AddContactPlus/src/addcontactplus.h b/plugins/AddContactPlus/src/addcontactplus.h new file mode 100644 index 0000000000..6e9d90e9fd --- /dev/null +++ b/plugins/AddContactPlus/src/addcontactplus.h @@ -0,0 +1,56 @@ +/* + +AddContact+ plugin for Miranda IM + +Copyright (C) 2007-2011 Bartosz 'Dezeath' Białek + +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., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +// to enable all 0.9 core functions +#define MIRANDA_VER 0x0A00 + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "m_toolbar.h" +#include "m_updater.h" +#include "m_addcontactplus.h" + +#include "resource.h" +#include "version.h" + +#define ICON_ADD "AddContactPlus_Icon" + +INT_PTR CALLBACK AddContactDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam); +extern HINSTANCE hInst; diff --git a/plugins/AddContactPlus/src/main.cpp b/plugins/AddContactPlus/src/main.cpp new file mode 100644 index 0000000000..56d8b0ad1b --- /dev/null +++ b/plugins/AddContactPlus/src/main.cpp @@ -0,0 +1,202 @@ +/* + +AddContact+ plugin for Miranda IM + +Copyright (C) 2007-2011 Bartosz 'Dezeath' Białek + +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., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +#include "addcontactplus.h" + +HINSTANCE hInst; +int hLangpack; +static HANDLE hModulesLoaded = 0, hChangedIcons = 0, hAccListChanged = 0, + hMainMenuItem = 0, hToolBarItem = 0, hService = 0; +HANDLE hIconLibItem; + +PLUGININFOEX pluginInfo = { + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), + __DESCRIPTION, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + // {6471D451-2FE0-4ee2-850E-9F84F3C0D187} + { 0x6471d451, 0x2fe0, 0x4ee2, { 0x85, 0xe, 0x9f, 0x84, 0xf3, 0xc0, 0xd1, 0x87 } } +}; + +static const MUUID interfaces[] = {MIID_ADDCONTACTPLUS, MIID_LAST}; + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + hInst = hinstDLL; + return TRUE; +} + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) +{ + return interfaces; +} + +INT_PTR AddContactPlusDialog(WPARAM, LPARAM) +{ + CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADDCONTACT), (HWND)NULL, AddContactDlgProc, 0); + return 0; +} + +static int OnIconsChanged(WPARAM, LPARAM) +{ + CLISTMENUITEM mi = {0}; + + if (!hMainMenuItem) + return 0; + + mi.cbSize = sizeof(mi); + mi.flags = CMIM_ICON | CMIF_ICONFROMICOLIB | CMIF_TCHAR; + mi.icolibItem = hIconLibItem; + CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMainMenuItem, (LPARAM)&mi); + + return 0; +} + +static int OnAccListChanged(WPARAM, LPARAM) +{ + PROTOACCOUNT** pAccounts; + int iRealAccCount, iAccCount = 0; + DWORD dwCaps; + + ProtoEnumAccounts(&iRealAccCount, &pAccounts); + for (int i = 0; i < iRealAccCount; i++) + { + if (!IsAccountEnabled(pAccounts[i])) continue; + dwCaps = (DWORD)CallProtoService(pAccounts[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0); + if (dwCaps & PF1_BASICSEARCH || dwCaps & PF1_EXTSEARCH || dwCaps & PF1_SEARCHBYEMAIL || dwCaps & PF1_SEARCHBYNAME) + iAccCount++; + } + + if (iAccCount) + { + CLISTMENUITEM mi = {0}; + + if (hMainMenuItem) + return 0; + + mi.cbSize = sizeof(mi); + mi.position = 500020001; + mi.flags = CMIF_ICONFROMICOLIB | CMIF_TCHAR; + mi.icolibItem = hIconLibItem; + mi.ptszName = LPGENT("&Add Contact..."); + mi.pszService = MS_ADDCONTACTPLUS_SHOW; + hMainMenuItem = Menu_AddMainMenuItem(&mi); + + if (ServiceExists(MS_TB_ADDBUTTON)) + { + TBButton tbb = {0}; + + tbb.cbSize = sizeof(TBButton); + tbb.tbbFlags = TBBF_VISIBLE | TBBF_SHOWTOOLTIP; + tbb.pszButtonID = "acplus_btn"; + tbb.pszButtonName = Translate("Add Contact"); + tbb.pszServiceName = MS_ADDCONTACTPLUS_SHOW; + tbb.pszTooltipUp = Translate("Add Contact"); + tbb.hPrimaryIconHandle = hIconLibItem; + tbb.defPos = 10100; + hToolBarItem = (HANDLE)CallService(MS_TB_ADDBUTTON, 0, (LPARAM)&tbb); + } + } + else + { + if (!hMainMenuItem) + return 0; + + CallService(MS_CLIST_REMOVEMAINMENUITEM, (WPARAM)hMainMenuItem, 0); + CallService(MS_TB_REMOVEBUTTON, (WPARAM)hToolBarItem, 0); + + hMainMenuItem = 0; + } + + return 0; +} + +static int OnModulesLoaded(WPARAM, LPARAM) +{ + if (ServiceExists(MS_UPDATE_REGISTERFL)) +#if defined(_WIN64) + CallService(MS_UPDATE_REGISTERFL, 4414, (LPARAM)&pluginInfo); +#else + CallService(MS_UPDATE_REGISTERFL, 3842, (LPARAM)&pluginInfo); +#endif + + SKINICONDESC sid = {0}; + char szFile[MAX_PATH]; + GetModuleFileNameA(hInst, szFile, MAX_PATH); + sid.cbSize = sizeof(SKINICONDESC); + sid.flags = SIDF_TCHAR; + sid.pszDefaultFile = szFile; + sid.ptszSection = _T("AddContact+"); + sid.iDefaultIndex = -IDI_ADDCONTACT; + sid.ptszDescription = LPGENT("Add Contact"); + sid.pszName = ICON_ADD; + hIconLibItem = Skin_AddIcon(&sid); + hChangedIcons = HookEvent(ME_SKIN2_ICONSCHANGED, OnIconsChanged); + + HOTKEYDESC hkd = {0}; + hkd.cbSize = sizeof(hkd); + hkd.dwFlags = HKD_TCHAR; + hkd.pszName = "AddContactPlus_OpenDialog"; + hkd.ptszDescription = LPGENT("Open Add Contact Dialog"); + hkd.ptszSection = LPGENT("Main"); + hkd.pszService = MS_ADDCONTACTPLUS_SHOW; + hkd.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL | HOTKEYF_SHIFT, 'C') | HKF_MIRANDA_LOCAL; + Hotkey_Register(&hkd); + + OnAccListChanged(0, 0); + + return 0; +} + +extern "C" int __declspec(dllexport) Load(void) +{ + mir_getLP(&pluginInfo); + + INITCOMMONCONTROLSEX icex = {0}; + icex.dwSize = sizeof(INITCOMMONCONTROLSEX); + icex.dwICC = ICC_USEREX_CLASSES; + InitCommonControlsEx(&icex); + + hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); + hAccListChanged = HookEvent(ME_PROTO_ACCLISTCHANGED, OnAccListChanged); + hService = CreateServiceFunction(MS_ADDCONTACTPLUS_SHOW, AddContactPlusDialog); + + return 0; +} + +extern "C" int __declspec(dllexport) Unload(void) +{ + UnhookEvent(hModulesLoaded); + UnhookEvent(hChangedIcons); + UnhookEvent(hAccListChanged); + DestroyServiceFunction(hService); + + return 0; +} diff --git a/plugins/AddContactPlus/src/resource.h b/plugins/AddContactPlus/src/resource.h new file mode 100644 index 0000000000..b796c401d0 --- /dev/null +++ b/plugins/AddContactPlus/src/resource.h @@ -0,0 +1,28 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by resource.rc +// +#define IDD_ADDCONTACT 101 +#define IDI_ADDCONTACT 102 +#define IDC_MYHANDLE 1000 +#define IDC_GROUP 1001 +#define IDC_ADDED 1002 +#define IDC_AUTH 1003 +#define IDC_AUTHGB 1004 +#define IDC_AUTHREQ 1005 +#define IDC_USERID 1006 +#define IDC_PROTO 1007 +#define IDC_IDLABEL 1008 +#define IDC_HEADERBAR 1009 +#define IDC_ADDTEMP 1010 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1011 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif -- cgit v1.2.3