From b0f3e30460fc26ef4fe59bc161b0fddd8eeb9a08 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 11 Oct 2016 21:05:12 +0300 Subject: Yahoo & YahooGroups plugins moved to _deprecated --- tools/_deprecated/YahooGroups/src/YahooGroups.cpp | 78 ++++++ tools/_deprecated/YahooGroups/src/dlg_handlers.cpp | 84 ++++++ tools/_deprecated/YahooGroups/src/dlg_handlers.h | 29 ++ .../_deprecated/YahooGroups/src/hooked_events.cpp | 65 +++++ tools/_deprecated/YahooGroups/src/hooked_events.h | 36 +++ tools/_deprecated/YahooGroups/src/list.cpp | 106 ++++++++ tools/_deprecated/YahooGroups/src/list.h | 53 ++++ tools/_deprecated/YahooGroups/src/resource.h | 19 ++ tools/_deprecated/YahooGroups/src/services.cpp | 193 +++++++++++++ tools/_deprecated/YahooGroups/src/services.h | 38 +++ tools/_deprecated/YahooGroups/src/stdafx.cxx | 18 ++ tools/_deprecated/YahooGroups/src/stdafx.h | 51 ++++ tools/_deprecated/YahooGroups/src/utils.cpp | 298 +++++++++++++++++++++ tools/_deprecated/YahooGroups/src/utils.h | 56 ++++ tools/_deprecated/YahooGroups/src/version.h | 39 +++ 15 files changed, 1163 insertions(+) create mode 100644 tools/_deprecated/YahooGroups/src/YahooGroups.cpp create mode 100644 tools/_deprecated/YahooGroups/src/dlg_handlers.cpp create mode 100644 tools/_deprecated/YahooGroups/src/dlg_handlers.h create mode 100644 tools/_deprecated/YahooGroups/src/hooked_events.cpp create mode 100644 tools/_deprecated/YahooGroups/src/hooked_events.h create mode 100644 tools/_deprecated/YahooGroups/src/list.cpp create mode 100644 tools/_deprecated/YahooGroups/src/list.h create mode 100644 tools/_deprecated/YahooGroups/src/resource.h create mode 100644 tools/_deprecated/YahooGroups/src/services.cpp create mode 100644 tools/_deprecated/YahooGroups/src/services.h create mode 100644 tools/_deprecated/YahooGroups/src/stdafx.cxx create mode 100644 tools/_deprecated/YahooGroups/src/stdafx.h create mode 100644 tools/_deprecated/YahooGroups/src/utils.cpp create mode 100644 tools/_deprecated/YahooGroups/src/utils.h create mode 100644 tools/_deprecated/YahooGroups/src/version.h (limited to 'tools/_deprecated/YahooGroups/src') diff --git a/tools/_deprecated/YahooGroups/src/YahooGroups.cpp b/tools/_deprecated/YahooGroups/src/YahooGroups.cpp new file mode 100644 index 0000000000..da71a8f752 --- /dev/null +++ b/tools/_deprecated/YahooGroups/src/YahooGroups.cpp @@ -0,0 +1,78 @@ +/* +YahooGroups plugin for Miranda IM + +Copyright © 2007 Cristian Libotean + +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 "stdafx.h" + +CLIST_INTERFACE *pcli; +char ModuleName[] = "YahooGroups"; +HINSTANCE hInstance; + +UINT currentCodePage = 0; +int hLangpack = 0; + +PLUGININFOEX pluginInfo = { + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), + __DESCRIPTION, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + // {2F3FE8B9-7327-4008-A60D-93F0F4F7F0F1} + {0x2f3fe8b9, 0x7327, 0x4008, {0xa6, 0x0d, 0x93, 0xf0, 0xf4, 0xf7, 0xf0, 0xf1}} +}; + +extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD) +{ + return &pluginInfo; +} + +extern "C" int __declspec(dllexport) Load() +{ + mir_getLP(&pluginInfo); + pcli = Clist_GetInterface(); + + currentCodePage = Langpack_GetDefaultCodePage(); + + InitServices(); + + HookEvents(); + + return 0; +} + +extern "C" int __declspec(dllexport) Unload() +{ + DestroyServices(); + + UnhookEvents(); + return 0; +} + +bool WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID) +{ + hInstance = hinstDLL; + if (fdwReason == DLL_PROCESS_ATTACH) + DisableThreadLibraryCalls(hinstDLL); + + return TRUE; +} diff --git a/tools/_deprecated/YahooGroups/src/dlg_handlers.cpp b/tools/_deprecated/YahooGroups/src/dlg_handlers.cpp new file mode 100644 index 0000000000..1bb4ae8b58 --- /dev/null +++ b/tools/_deprecated/YahooGroups/src/dlg_handlers.cpp @@ -0,0 +1,84 @@ +/* +YahooGroups plugin for Miranda IM + +Copyright © 2007 Cristian Libotean + +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 "stdafx.h" + +INT_PTR CALLBACK DlgProcOptions(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) + { + case WM_INITDIALOG: + { + TranslateDialogDefault(hWnd); + + int autoMove = db_get_b(NULL, ModuleName, "MoveAutomatically", 0); + CheckDlgButton(hWnd, IDC_MOVEAUTOMATICALLY, autoMove ? BST_CHECKED : BST_UNCHECKED); + + return 0; + break; + } + + case WM_COMMAND: + { + switch (LOWORD(wParam)) + { + case IDC_YAHOOGROUPS: + { + YahooGroupsMoveService(0,0); + break; + } + + case IDC_MOVEAUTOMATICALLY: + { + SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); + break; + } + } + + break; + } + + case WM_NOTIFY: + { + switch(((LPNMHDR)lParam)->idFrom) + { + case 0: + { + switch (((LPNMHDR)lParam)->code) + { + case PSN_APPLY: + { + int autoMove = IsDlgButtonChecked(hWnd, IDC_MOVEAUTOMATICALLY); + db_set_b(NULL, ModuleName, "MoveAutomatically", autoMove); + break; + } + } + + break; + } + } + + break; + } + + } + + return 0; +} \ No newline at end of file diff --git a/tools/_deprecated/YahooGroups/src/dlg_handlers.h b/tools/_deprecated/YahooGroups/src/dlg_handlers.h new file mode 100644 index 0000000000..e1fe1b8115 --- /dev/null +++ b/tools/_deprecated/YahooGroups/src/dlg_handlers.h @@ -0,0 +1,29 @@ +/* +YahooGroups plugin for Miranda IM + +Copyright © 2007 Cristian Libotean + +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. +*/ + +#ifndef M_YAHOOGROUPS_DLGHANDLERS_H +#define M_YAHOOGROUPS_DLGHANDLERS_H + +#include "stdafx.h" + +INT_PTR CALLBACK DlgProcOptions(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); + + +#endif //M_YAHOOGROUPS_DLG_HANDLERS_H \ No newline at end of file diff --git a/tools/_deprecated/YahooGroups/src/hooked_events.cpp b/tools/_deprecated/YahooGroups/src/hooked_events.cpp new file mode 100644 index 0000000000..722075e1f6 --- /dev/null +++ b/tools/_deprecated/YahooGroups/src/hooked_events.cpp @@ -0,0 +1,65 @@ +/* +YahooGroups plugin for Miranda IM + +Copyright © 2007 Cristian Libotean + +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 "stdafx.h" + +HANDLE hModulesLoaded; +HANDLE hOptionsInitialize; + + +int HookEvents() +{ + hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); + hOptionsInitialize = HookEvent(ME_OPT_INITIALISE, OnOptionsInitialise); + + return 0; +} + +int UnhookEvents() +{ + UnhookEvent(hModulesLoaded); + UnhookEvent(hOptionsInitialize); + + return 0; +} + +int OnModulesLoaded(WPARAM, LPARAM) +{ + int autoMove = db_get_b(NULL, ModuleName, "MoveAutomatically", 0); + if (autoMove) + YahooGroupsMoveService(0,0); + + return 0; +} + +int OnOptionsInitialise(WPARAM wParam, LPARAM) +{ + OPTIONSDIALOGPAGE odp = { 0 }; + odp.position = 100000000; + odp.hInstance = hInstance; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS); + odp.pwszTitle = LPGENW("Yahoo Groups"); + odp.pwszGroup = LPGENW("Plugins"); + odp.groupPosition = 810000000; + odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE; + odp.pfnDlgProc = DlgProcOptions; + Options_AddPage(wParam, &odp); + return 0; +} diff --git a/tools/_deprecated/YahooGroups/src/hooked_events.h b/tools/_deprecated/YahooGroups/src/hooked_events.h new file mode 100644 index 0000000000..555fe570e9 --- /dev/null +++ b/tools/_deprecated/YahooGroups/src/hooked_events.h @@ -0,0 +1,36 @@ +/* +YahooGroups plugin for Miranda IM + +Copyright © 2007 Cristian Libotean + +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. +*/ + + +#ifndef M_YAHOOGROUPS_HOOKED_EVENTS_H +#define M_YAHOOGROUPS_HOOKED_EVENTS_H + +#include "stdafx.h" + +extern HANDLE hModulesLoaded; +extern HANDLE hOptionsInitialise; + +int HookEvents(); +int UnhookEvents(); + +int OnModulesLoaded(WPARAM wParam, LPARAM lParam); +int OnOptionsInitialise(WPARAM wParam, LPARAM lParam); + +#endif \ No newline at end of file diff --git a/tools/_deprecated/YahooGroups/src/list.cpp b/tools/_deprecated/YahooGroups/src/list.cpp new file mode 100644 index 0000000000..491867af2d --- /dev/null +++ b/tools/_deprecated/YahooGroups/src/list.cpp @@ -0,0 +1,106 @@ +/* +YahooGroups plugin for Miranda IM + +Copyright © 2007 Cristian Libotean + +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 "stdafx.h" + +CGroupsList availableGroups; + +void CGroupsList::Enlarge(int amount) +{ + size += amount; + groups = (char **) realloc(groups, size * sizeof(char *)); +} + +void CGroupsList::EnsureCapacity() +{ + if (count >= size - 1) + { + Enlarge(size / 2); + } +} + +CGroupsList::CGroupsList() +{ + groups = NULL; + size = 0; + count = 0; + Enlarge(10); +} + +CGroupsList::~CGroupsList() +{ + Clear(); + + free(groups); + groups = NULL; +} + +void CGroupsList::Clear() +{ + if (groups) + { + for (int i = 0; i < count; i++) + { + delete groups[i]; + } + + count = 0; + } +} + +void CGroupsList::Add(char *group) +{ + EnsureCapacity(); + groups[count++] = group; +} + +char *CGroupsList::operator [](int index) +{ + if ((index < 0) || (index >= count)) + { + return NULL; + } + + return groups[index]; +} + +int CGroupsList::Count() +{ + return count; +} + +int CGroupsList::Contains(const char *group) +{ + return (Index(group) >= 0); +} + +int CGroupsList::Index(const char *group) +{ + int i; + for (i = 0; i < count; i++) + { + if (_stricmp(groups[i], group) == 0) + { + return i; + } + } + + return -1; +} \ No newline at end of file diff --git a/tools/_deprecated/YahooGroups/src/list.h b/tools/_deprecated/YahooGroups/src/list.h new file mode 100644 index 0000000000..87ff6b93a6 --- /dev/null +++ b/tools/_deprecated/YahooGroups/src/list.h @@ -0,0 +1,53 @@ +/* +YahooGroups plugin for Miranda IM + +Copyright © 2007 Cristian Libotean + +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. +*/ + +#ifndef M_YAHOOGROUPS_LIST_H +#define M_YAHOOGROUPS_LIST_H + +#include "stdafx.h" + +class CGroupsList +{ + protected: + char **groups; + int size; + int count; + + void Enlarge(int amount); + void EnsureCapacity(); + + public: + CGroupsList(); + ~CGroupsList(); + + void Add(char *group); + void Clear(); + + int Count(); + + int Contains(const char *group); + int Index(const char *group); + + char *operator [](int index); +}; + +extern CGroupsList availableGroups; + +#endif //M_VIUPLOADER_LIST_H \ No newline at end of file diff --git a/tools/_deprecated/YahooGroups/src/resource.h b/tools/_deprecated/YahooGroups/src/resource.h new file mode 100644 index 0000000000..1f15e3a8a1 --- /dev/null +++ b/tools/_deprecated/YahooGroups/src/resource.h @@ -0,0 +1,19 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by YahooGroups.rc +// +#define IDD_OPTIONS 101 +#define IDC_YAHOOGROUPS 1001 +#define IDC_CHECK1 1003 +#define IDC_MOVEAUTOMATICALLY 1003 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1004 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/tools/_deprecated/YahooGroups/src/services.cpp b/tools/_deprecated/YahooGroups/src/services.cpp new file mode 100644 index 0000000000..16e58a2add --- /dev/null +++ b/tools/_deprecated/YahooGroups/src/services.cpp @@ -0,0 +1,193 @@ +/* +YahooGroups plugin for Miranda IM + +Copyright © 2007 Cristian Libotean + +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 "stdafx.h" + +#define CLIST_GROUPS "CListGroups" + +HANDLE hsYGMove = NULL; +HANDLE hsYGReset = NULL; + +int InitServices() +{ + hsYGMove = CreateServiceFunction(MS_YAHOOGROUPS_MOVE, YahooGroupsMoveService); + hsYGReset = CreateServiceFunction(MS_YAHOOGROUPS_RESET, YahooGroupsResetService); + + ReadAvailableGroups(); + + return 0; +} + +int DestroyServices() +{ + DestroyServiceFunction(hsYGMove); + DestroyServiceFunction(hsYGReset); + + return 0; +} + +void ReadAvailableGroups() +{ + int ok = 1; + int index = 0; + + char group[1024] = {0}; + char tmp[128] = {0}; + + while (ok) + { + mir_snprintf(tmp, "%d", index); + GetStringFromDatabase(NULL, CLIST_GROUPS, tmp, NULL, group, sizeof(group)); + if (mir_strlen(group) > 0) + { + availableGroups.Add(_strdup(group + 1)); + index += 1; + } + else{ + ok = 0; + } + } +} + +int GetNextGroupIndex() +{ + int index = 0; + int found = 0; + + char buffer[1024] = {0}; + char tmp[128] = {0}; + + while (!found) + { + mir_snprintf(tmp, "%d", index++); + + if (GetStringFromDatabase(NULL, CLIST_GROUPS, tmp, NULL, buffer, sizeof(buffer))) + { + found = 1; + } + } + + return index - 1; +} + +void AddNewGroup(const char *newGroup) +{ + int index = GetNextGroupIndex(); + + char tmp[128]; + char group[1024]; + + *group = 1; + strncpy_s((group + 1), (_countof(group) - 1), newGroup, _TRUNCATE); + + mir_snprintf(tmp, "%d", index); + const int MAX_SIZE = 1024; + wchar_t wide[MAX_SIZE] = {0}; + *wide = 1; + MultiByteToWideChar(currentCodePage, 0, group + 1, -1, wide + 1, MAX_SIZE - 1); + db_set_ws(NULL, CLIST_GROUPS, tmp, wide); + + availableGroups.Add(_strdup(group + 1)); +} + +void AddContactToGroup(MCONTACT hContact, char *group) +{ + const int MAX_SIZE = 1024; + wchar_t wide[MAX_SIZE] = {0}; + MultiByteToWideChar(currentCodePage, 0, group, -1, wide, MAX_SIZE); + db_set_ws(hContact, "CList", "Group", wide); +} + +void CreateGroup(char *group) +{ + char *p = group; + char *sub = group; + + CMStringA buf; + while ((p = strchr(sub, '\\'))) + { + *p = 0; + if (!buf.IsEmpty()) + buf.AppendChar('\\'); + buf.Append(sub); + + if (!availableGroups.Contains(buf)) + AddNewGroup(buf); + + *p++ = '\\'; + sub = p; + } + + if (sub) { + if (!buf.IsEmpty()) + buf.AppendChar('\\'); + buf.Append(sub); + + if (!availableGroups.Contains(buf)) + AddNewGroup(buf); + } +} + +void ProcessContacts(void (*callback)(MCONTACT, char *), char *protocol) +{ + for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) + callback(hContact, protocol); +} + +void YahooMoveCallback(MCONTACT hContact, char*) +{ + char protocol[128] = {0}; + GetContactProtocol(hContact, protocol, sizeof(protocol)); + + if (mir_strlen(protocol) > 0) + { + char ygroup[128] = {0}; + + if (!GetStringFromDatabase(hContact, protocol, "YGroup", NULL, ygroup, sizeof(ygroup))) + { + CreateGroup(ygroup); + AddContactToGroup(hContact, ygroup); + } + } +} + +void ResetGroupCallback(MCONTACT hContact, char *protocol) +{ + char p[128] = {0}; + + GetContactProtocol(hContact, p, sizeof(protocol)); + + if ((!protocol) || (_stricmp(protocol, p) == 0)) + { + db_unset(hContact, "CList", "Group"); + } +} + +INT_PTR YahooGroupsMoveService(WPARAM, LPARAM) +{ + ProcessContacts(YahooMoveCallback, NULL); + return 0; +} + +INT_PTR YahooGroupsResetService(WPARAM, LPARAM) +{ + ProcessContacts(ResetGroupCallback, NULL); + return 0; +} diff --git a/tools/_deprecated/YahooGroups/src/services.h b/tools/_deprecated/YahooGroups/src/services.h new file mode 100644 index 0000000000..b6a2237815 --- /dev/null +++ b/tools/_deprecated/YahooGroups/src/services.h @@ -0,0 +1,38 @@ +/* +YahooGroups plugin for Miranda IM + +Copyright © 2007 Cristian Libotean + +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. +*/ + + +#ifndef M_YAHOOGROUPS_SERVICES_H +#define M_YAHOOGROUPS_SERVICES_H + +#include "stdafx.h" + +#define MS_YAHOOGROUPS_MOVE "YahooGroups/Groups/MoveToOfficialGroups" +#define MS_YAHOOGROUPS_RESET "YahooGroups/Groups/Reset" + +int InitServices(); +int DestroyServices(); + +INT_PTR YahooGroupsMoveService(WPARAM wParam, LPARAM lParam); +INT_PTR YahooGroupsResetService(WPARAM wParam, LPARAM lParam); + +void ReadAvailableGroups(); + +#endif //M_CMDLINE_SERVICES_H diff --git a/tools/_deprecated/YahooGroups/src/stdafx.cxx b/tools/_deprecated/YahooGroups/src/stdafx.cxx new file mode 100644 index 0000000000..0765fbaa6f --- /dev/null +++ b/tools/_deprecated/YahooGroups/src/stdafx.cxx @@ -0,0 +1,18 @@ +/* +Copyright (C) 2012-16 Miranda NG project (http://miranda-ng.org) + +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 version 2 +of the License. + +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, see . +*/ + +#include "stdafx.h" \ No newline at end of file diff --git a/tools/_deprecated/YahooGroups/src/stdafx.h b/tools/_deprecated/YahooGroups/src/stdafx.h new file mode 100644 index 0000000000..a42495ae84 --- /dev/null +++ b/tools/_deprecated/YahooGroups/src/stdafx.h @@ -0,0 +1,51 @@ +/* +YahooGroups plugin for Miranda IM + +Copyright © 2007 Cristian Libotean + +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. +*/ + + +#ifndef M_YAHOOGROUPS_COMMONHEADERS_H +#define M_YAHOOGROUPS_COMMONHEADERS_H + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "version.h" +#include "dlg_handlers.h" +#include "hooked_events.h" +#include "services.h" +#include "list.h" +#include "services.h" +#include "utils.h" +#include "resource.h" + +extern char ModuleName[]; +extern HINSTANCE hInstance; +extern UINT currentCodePage; + +#endif //M_YAHOOGROUPS_COMMONHEADERS_H \ No newline at end of file diff --git a/tools/_deprecated/YahooGroups/src/utils.cpp b/tools/_deprecated/YahooGroups/src/utils.cpp new file mode 100644 index 0000000000..7b9ff8ec90 --- /dev/null +++ b/tools/_deprecated/YahooGroups/src/utils.cpp @@ -0,0 +1,298 @@ +/* +YahooGroups plugin for Miranda IM + +Copyright © 2007 Cristian Libotean + +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 "stdafx.h" + +int Info(char *title, char *format, ...) +{ + char str[4096]; + va_list vararg; + int tBytes; + va_start(vararg, format); + tBytes = mir_vsnprintf(str, sizeof(str), format, vararg); + if (tBytes > 0) + str[tBytes] = 0; + + va_end(vararg); + return MessageBoxA(0, str, title, MB_OK | MB_ICONINFORMATION); +} + +int MyPUShowMessage(wchar_t *lpzText, BYTE kind) +{ + if (ServiceExists(MS_POPUP_SHOWMESSAGE)) + { + return PUShowMessageT(lpzText, kind); + } + else{ + wchar_t *title = (kind == SM_NOTIFY) ? TranslateT("Notify") : TranslateT("Warning"); + + return MessageBox(NULL, lpzText, title, MB_OK | (kind == SM_NOTIFY) ? MB_ICONINFORMATION : MB_ICONEXCLAMATION); + } +} + +#define HEX_SIZE 8 + +char *BinToHex(int size, PBYTE data) +{ + char *szresult = NULL; + char buffer[32] = {0}; //should be more than enough + int maxSize = size * 2 + HEX_SIZE + 1; + szresult = (char *) new char[ maxSize ]; + memset(szresult, 0, maxSize); + mir_snprintf(buffer, "%0*X", HEX_SIZE, size); + mir_strcpy(szresult, buffer); + int i; + for (i = 0; i < size; i++) + { + mir_snprintf(buffer, "%02X", data[i]); + mir_strcpy(szresult + (HEX_SIZE + i * 2), buffer); + } + return szresult; +} + +void HexToBin(char *inData, ULONG &size, LPBYTE &outData) +{ + char buffer[32] = {0}; + mir_strcpy(buffer, "0x"); + strncpy(buffer + 2, inData, HEX_SIZE); + sscanf(buffer, "%x", &size); + outData = (unsigned char*)new char[size*2]; + UINT i; + //size = i; + char *tmp = inData + HEX_SIZE; + buffer[4] = '\0'; //mark the end of the string + for (i = 0; i < size; i++) + { + strncpy(buffer + 2, &tmp[i * 2], 2); + sscanf(buffer, "%hhx", &outData[i]); + } + i = size; +} + +int GetStringFromDatabase(MCONTACT hContact, char *szModule, char *szSettingName, char *szError, char *szResult, int size) +{ + DBVARIANT dbv = {0}; + int res = 1; + int len; + dbv.type = DBVT_ASCIIZ; + if (db_get_s(hContact, szModule, szSettingName, &dbv) == 0) + { + res = 0; + int tmp = (int)mir_strlen(dbv.pszVal); + len = (tmp < size - 1) ? tmp : size - 1; + strncpy(szResult, dbv.pszVal, len); + szResult[len] = '\0'; + mir_free(dbv.pszVal); + } + else{ + res = 1; + if (szError) + { + int tmp = (int)mir_strlen(szError); + len = (tmp < size - 1) ? tmp : size - 1; + strncpy(szResult, szError, len); + szResult[len] = '\0'; + } + else{ + szResult[0] = '\0'; + } + } + return res; +} + +int GetStringFromDatabase(MCONTACT hContact, char *szModule, char *szSettingName, WCHAR *szError, WCHAR *szResult, int count) +{ + DBVARIANT dbv = {0}; + int res = 1; + int len; + dbv.type = DBVT_WCHAR; + if ( db_get_s(hContact, szModule, szSettingName, &dbv, 0) == 0) { + res = 0; + if (dbv.type != DBVT_WCHAR) + MultiByteToWideChar(CP_ACP, 0, dbv.pszVal, -1, szResult, count); + else { + int tmp = (int)mir_wstrlen(dbv.pwszVal); + len = (tmp < count - 1) ? tmp : count - 1; + wcsncpy(szResult, dbv.pwszVal, len); + szResult[len] = L'\0'; + } + mir_free(dbv.pwszVal); + } + else { + res = 1; + if (szError) { + int tmp = (int)mir_wstrlen(szError); + len = (tmp < count - 1) ? tmp : count - 1; + wcsncpy(szResult, szError, len); + szResult[len] = L'\0'; + } + else szResult[0] = L'\0'; + } + return res; +} + +int GetStringFromDatabase(char *szSettingName, char *szError, char *szResult, int size) +{ + return GetStringFromDatabase(NULL, ModuleName, szSettingName, szError, szResult, size); +} + +int GetStringFromDatabase(char *szSettingName, WCHAR *szError, WCHAR *szResult, int count) +{ + return GetStringFromDatabase(NULL, ModuleName, szSettingName, szError, szResult, count); +} + +wchar_t* GetContactName(MCONTACT hContact, char *szProto) +{ + ptrW id(Contact_GetInfo(CNF_DISPLAYUID, hContact, szProto)); + return (id != NULL) ? wcsdup(id) : NULL; +} + +void GetContactProtocol(MCONTACT hContact, char *szProto, int size) +{ + GetStringFromDatabase(hContact, "Protocol", "p", NULL, szProto, size); +} + +wchar_t *GetContactID(MCONTACT hContact) +{ + char protocol[256]; + GetContactProtocol(hContact, protocol, sizeof(protocol)); + + return GetContactID(hContact, protocol); +} + +wchar_t* GetContactID(MCONTACT hContact, char *szProto) +{ + ptrW id(Contact_GetInfo(CNF_DISPLAY, hContact, szProto)); + return (id != NULL) ? wcsdup(id) : NULL; +} + +MCONTACT GetContactFromID(wchar_t *szID, char *szProto) +{ + wchar_t *szHandle; + wchar_t dispName[1024]; + char cProtocol[256]; + wchar_t *tmp; + + int found = 0; + for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { + GetContactProtocol(hContact, cProtocol, sizeof(cProtocol)); + szHandle = GetContactID(hContact, cProtocol); + + tmp = pcli->pfnGetContactDisplayName(hContact, 0); + wcsncpy(dispName, tmp, _countof(dispName)); + + if ((szHandle) && ((mir_wstrcmpi(szHandle, szID) == 0) || (mir_wstrcmpi(dispName, szID) == 0)) && ((szProto == NULL) || (_stricmp(szProto, cProtocol) == 0))) + found = 1; + + if (szHandle) { free(szHandle); } + + if (found) + return hContact; + } + + return NULL; +} +#pragma warning (default: 4312) + +#pragma warning (disable: 4312) +MCONTACT GetContactFromID(wchar_t *szID, wchar_t *szProto) +{ + char protocol[1024]; + WideCharToMultiByte(CP_ACP, 0, szProto, -1, protocol, sizeof(protocol), NULL, NULL); + return GetContactFromID(szID, protocol); +} +#pragma warning (default: 4312) + +void ScreenToClient(HWND hWnd, LPRECT rect) +{ + POINT pt; + int cx = rect->right - rect->left; + int cy = rect->bottom - rect->top; + pt.x = rect->left; + pt.y = rect->top; + ScreenToClient(hWnd, &pt); + rect->left = pt.x; + rect->top = pt.y; + rect->right = pt.x + cx; + rect->bottom = pt.y + cy; +} + +void AnchorMoveWindow(HWND window, const WINDOWPOS *parentPos, int anchors) +{ + RECT rParent; + RECT rChild; + + if (parentPos->flags & SWP_NOSIZE) + { + return; + } + GetWindowRect(parentPos->hwnd, &rParent); + rChild = AnchorCalcPos(window, &rParent, parentPos, anchors); + MoveWindow(window, rChild.left, rChild.top, rChild.right - rChild.left, rChild.bottom - rChild.top, FALSE); +} + +RECT AnchorCalcPos(HWND window, const RECT *rParent, const WINDOWPOS *parentPos, int anchors) +{ + RECT rChild; + RECT rTmp; + + GetWindowRect(window, &rChild); + ScreenToClient(parentPos->hwnd, &rChild); + + int cx = rParent->right - rParent->left; + int cy = rParent->bottom - rParent->top; + if ((cx == parentPos->cx) && (cy == parentPos->cy)) + { + return rChild; + } + if (parentPos->flags & SWP_NOSIZE) + { + return rChild; + } + + rTmp.left = parentPos->x - rParent->left; + rTmp.right = (parentPos->x + parentPos->cx) - rParent->right; + rTmp.bottom = (parentPos->y + parentPos->cy) - rParent->bottom; + rTmp.top = parentPos->y - rParent->top; + + cx = (rTmp.left) ? -rTmp.left : rTmp.right; + cy = (rTmp.top) ? -rTmp.top : rTmp.bottom; + + rChild.right += cx; + rChild.bottom += cy; + //expanded the window accordingly, now we need to enforce the anchors + if ((anchors & ANCHOR_LEFT) && (!(anchors & ANCHOR_RIGHT))) + { + rChild.right -= cx; + } + if ((anchors & ANCHOR_TOP) && (!(anchors & ANCHOR_BOTTOM))) + { + rChild.bottom -= cy; + } + if ((anchors & ANCHOR_RIGHT) && (!(anchors & ANCHOR_LEFT))) + { + rChild.left += cx; + } + if ((anchors & ANCHOR_BOTTOM) && (!(anchors & ANCHOR_TOP))) + { + rChild.top += cy; + } + return rChild; +} \ No newline at end of file diff --git a/tools/_deprecated/YahooGroups/src/utils.h b/tools/_deprecated/YahooGroups/src/utils.h new file mode 100644 index 0000000000..fc94116254 --- /dev/null +++ b/tools/_deprecated/YahooGroups/src/utils.h @@ -0,0 +1,56 @@ +/* +YahooGroups plugin for Miranda IM + +Copyright © 2007 Cristian Libotean + +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. +*/ + + +#ifndef M_YAHOOGROUPS_UTILS_H +#define M_YAHOOGROUPS_UTILS_H + +#include "stdafx.h" + +#define ANCHOR_LEFT 0x000001 +#define ANCHOR_RIGHT 0x000002 +#define ANCHOR_TOP 0x000004 +#define ANCHOR_BOTTOM 0x000008 +#define ANCHOR_ALL ANCHOR_LEFT | ANCHOR_RIGHT | ANCHOR_TOP | ANCHOR_BOTTOM + +int Info(char *title, char *format, ...); + +char *BinToHex(int size, PBYTE data); +void HexToBin(char *inData, ULONG &size, PBYTE &outData); + +void ScreenToClient(HWND hWnd, LPRECT rect); +void AnchorMoveWindow(HWND window, const WINDOWPOS *parentPos, int anchors); +RECT AnchorCalcPos(HWND window, const RECT *rParent, const WINDOWPOS *parentPos, int anchors); + +int GetStringFromDatabase(MCONTACT hContact, char *szModule, char *szSettingName, char *szError, char *szResult, int size); +int GetStringFromDatabase(MCONTACT hContact, char *szModule, char *szSettingName, WCHAR *szError, WCHAR *szResult, int count); +int GetStringFromDatabase(char *szSettingName, char *szError, char *szResult, int size); +int GetStringFromDatabase(char *szSettingName, WCHAR *szError, WCHAR *szResult, int count); + +wchar_t *GetContactName(MCONTACT hContact, char *szProto); +wchar_t *GetContactID(MCONTACT hContact); +wchar_t *GetContactID(MCONTACT hContact, char *szProto); +MCONTACT GetContactFromID(wchar_t *szID, char *szProto); +MCONTACT GetContactFromID(wchar_t *szID, wchar_t *szProto); +void GetContactProtocol(MCONTACT hContact, char *szProto, int size); + +int MyPUShowMessage(char *lpzText, BYTE kind); + +#endif \ No newline at end of file diff --git a/tools/_deprecated/YahooGroups/src/version.h b/tools/_deprecated/YahooGroups/src/version.h new file mode 100644 index 0000000000..653b67ebc8 --- /dev/null +++ b/tools/_deprecated/YahooGroups/src/version.h @@ -0,0 +1,39 @@ +/* +YahooGroups plugin for Miranda IM + +Copyright © 2007 Cristian Libotean + +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. +*/ + +#ifndef M_CMDLINE_VERSION_H +#define M_CMDLINE_VERSION_H + +#define __MAJOR_VERSION 0 +#define __MINOR_VERSION 0 +#define __RELEASE_NUM 1 +#define __BUILD_NUM 1 + +#include + +#define __PLUGIN_NAME "Yahoo groups" +#define __FILENAME "YahooGroups.dll" +#define __DESCRIPTION "This plugin imports and creates the Yahoo groups defined in Yahoo Messenger." +#define __AUTHOR "Cristian Libotean" +#define __AUTHOREMAIL "eblis102@yahoo.com" +#define __AUTHORWEB "http://miranda-ng.org/p/YahooGroups/" +#define __COPYRIGHT "© 2007 Cristian Libotean" + +#endif //M_CMDLINE_VERSION_H -- cgit v1.2.3