diff options
Diffstat (limited to 'protocols/WhatsAppWeb')
23 files changed, 969 insertions, 0 deletions
diff --git a/protocols/WhatsAppWeb/WhatsAppWeb.vcxproj b/protocols/WhatsAppWeb/WhatsAppWeb.vcxproj new file mode 100644 index 0000000000..ac48c7237b --- /dev/null +++ b/protocols/WhatsAppWeb/WhatsAppWeb.vcxproj @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{13E796AD-BEA4-4213-A1B8-E18E2397E544}</ProjectGuid> + <ProjectName>WhatsAppWeb</ProjectName> + </PropertyGroup> + <ImportGroup Label="PropertySheets"> + <Import Project="$(ProjectDir)..\..\build\vc.common\plugin.props" /> + </ImportGroup> + <ItemDefinitionGroup> + <ClCompile> + <ExceptionHandling>Sync</ExceptionHandling> + </ClCompile> + </ItemDefinitionGroup> +</Project>
\ No newline at end of file diff --git a/protocols/WhatsAppWeb/WhatsAppWeb.vcxproj.filters b/protocols/WhatsAppWeb/WhatsAppWeb.vcxproj.filters new file mode 100644 index 0000000000..fcae13a9d8 --- /dev/null +++ b/protocols/WhatsAppWeb/WhatsAppWeb.vcxproj.filters @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(ProjectDir)..\..\build\vc.common\common.filters" /> +</Project>
\ No newline at end of file diff --git a/protocols/WhatsAppWeb/proto_whatsapp/CMakeLists.txt b/protocols/WhatsAppWeb/proto_whatsapp/CMakeLists.txt new file mode 100644 index 0000000000..5193619806 --- /dev/null +++ b/protocols/WhatsAppWeb/proto_whatsapp/CMakeLists.txt @@ -0,0 +1,2 @@ +set(TARGET Proto_WhatsApp) +include(${CMAKE_SOURCE_DIR}/cmake/icons.cmake)
\ No newline at end of file diff --git a/protocols/WhatsAppWeb/proto_whatsapp/Proto_WhatsApp.vcxproj b/protocols/WhatsAppWeb/proto_whatsapp/Proto_WhatsApp.vcxproj new file mode 100644 index 0000000000..1088bb1891 --- /dev/null +++ b/protocols/WhatsAppWeb/proto_whatsapp/Proto_WhatsApp.vcxproj @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectName>Proto_WhatsApp</ProjectName> + <ProjectGuid>{64A2B403-90AF-4CF8-BC69-4E8D33872D64}</ProjectGuid> + </PropertyGroup> + <ImportGroup Label="PropertySheets"> + <Import Project="$(ProjectDir)..\..\..\build\vc.common\icons.props" /> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/protocols/WhatsAppWeb/proto_whatsapp/Proto_WhatsApp.vcxproj.filters b/protocols/WhatsAppWeb/proto_whatsapp/Proto_WhatsApp.vcxproj.filters new file mode 100644 index 0000000000..28f81e7f1b --- /dev/null +++ b/protocols/WhatsAppWeb/proto_whatsapp/Proto_WhatsApp.vcxproj.filters @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(ProjectDir)..\..\..\build\vc.common\common.filters" /> +</Project>
\ No newline at end of file diff --git a/protocols/WhatsAppWeb/proto_whatsapp/res/Away.ico b/protocols/WhatsAppWeb/proto_whatsapp/res/Away.ico Binary files differnew file mode 100644 index 0000000000..9c07e3fa13 --- /dev/null +++ b/protocols/WhatsAppWeb/proto_whatsapp/res/Away.ico diff --git a/protocols/WhatsAppWeb/proto_whatsapp/res/Invisible.ico b/protocols/WhatsAppWeb/proto_whatsapp/res/Invisible.ico Binary files differnew file mode 100644 index 0000000000..cb743a4bfe --- /dev/null +++ b/protocols/WhatsAppWeb/proto_whatsapp/res/Invisible.ico diff --git a/protocols/WhatsAppWeb/proto_whatsapp/res/Offline.ico b/protocols/WhatsAppWeb/proto_whatsapp/res/Offline.ico Binary files differnew file mode 100644 index 0000000000..4019c68283 --- /dev/null +++ b/protocols/WhatsAppWeb/proto_whatsapp/res/Offline.ico diff --git a/protocols/WhatsAppWeb/proto_whatsapp/res/Online.ico b/protocols/WhatsAppWeb/proto_whatsapp/res/Online.ico Binary files differnew file mode 100644 index 0000000000..2143ea1438 --- /dev/null +++ b/protocols/WhatsAppWeb/proto_whatsapp/res/Online.ico diff --git a/protocols/WhatsAppWeb/proto_whatsapp/res/Proto_WhatsApp.rc b/protocols/WhatsAppWeb/proto_whatsapp/res/Proto_WhatsApp.rc new file mode 100644 index 0000000000..469a8d4484 --- /dev/null +++ b/protocols/WhatsAppWeb/proto_whatsapp/res/Proto_WhatsApp.rc @@ -0,0 +1,72 @@ +// Microsoft Visual C++ generated resource script. +// +#include "..\src\resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Russian (Russia) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) +LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "..\\src\\resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +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_ICON1 ICON "Offline.ico" +IDI_ICON2 ICON "Online.ico" +IDI_ICON3 ICON "Away.ico" +IDI_ICON4 ICON "Invisible.ico" +#endif // Russian (Russia) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/protocols/WhatsAppWeb/proto_whatsapp/src/resource.h b/protocols/WhatsAppWeb/proto_whatsapp/src/resource.h new file mode 100644 index 0000000000..e9d1373ca0 --- /dev/null +++ b/protocols/WhatsAppWeb/proto_whatsapp/src/resource.h @@ -0,0 +1,20 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Proto_WhatsApp.rc +// +#define IDI_ICON1 105 +#define IDI_ICON2 104 +#define IDI_ICON3 128 +#define IDI_ICON4 130 +//#define IDI_ICON5 1002 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 106 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/protocols/WhatsAppWeb/res/version.rc b/protocols/WhatsAppWeb/res/version.rc new file mode 100644 index 0000000000..37934706a0 --- /dev/null +++ b/protocols/WhatsAppWeb/res/version.rc @@ -0,0 +1,55 @@ +// Microsoft Visual C++ generated resource script. +// +#ifdef APSTUDIO_INVOKED +#error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + +#include "..\src\version.h" + +#define APSTUDIO_READONLY_SYMBOLS +#include "afxres.h" +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// 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 + +VS_VERSION_INFO VERSIONINFO + FILEVERSION __FILEVERSION_STRING + PRODUCTVERSION __FILEVERSION_STRING + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "Author", __AUTHOR + VALUE "FileDescription", __DESCRIPTION + VALUE "FileVersion", __VERSION_STRING + 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 + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// diff --git a/protocols/WhatsAppWeb/res/whatsapp.ico b/protocols/WhatsAppWeb/res/whatsapp.ico Binary files differnew file mode 100644 index 0000000000..7a0dc4c68d --- /dev/null +++ b/protocols/WhatsAppWeb/res/whatsapp.ico diff --git a/protocols/WhatsAppWeb/res/whatsapp.rc b/protocols/WhatsAppWeb/res/whatsapp.rc new file mode 100644 index 0000000000..e3d3cba800 --- /dev/null +++ b/protocols/WhatsAppWeb/res/whatsapp.rc @@ -0,0 +1,159 @@ +// Microsoft Visual C++ generated resource script. +// +#include "..\src\resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// German (Germany) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) +LANGUAGE LANG_GERMAN, SUBLANG_GERMAN +#pragma code_page(1252) + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "..\\src\\resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_WHATSAPOPTIONS, DIALOG + BEGIN + VERTGUIDE, 60 + VERTGUIDE, 178 + BOTTOMMARGIN, 126 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ACCMGRUI DIALOGEX 0, 0, 188, 144 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 400, 0, 0x0 +BEGIN + LTEXT "Phone number",IDC_STATIC,4,7,55,10 + EDITTEXT IDC_CC,60,6,24,12,ES_AUTOHSCROLL + EDITTEXT IDC_LOGIN,84,6,100,12,ES_AUTOHSCROLL + LTEXT "Nickname",IDC_STATIC,4,23,55,10 + EDITTEXT IDC_NICK,60,22,124,12,ES_AUTOHSCROLL + LTEXT "Default group:",IDC_STATIC,4,37,55,10 + EDITTEXT IDC_DEFGROUP,60,36,124,12,ES_AUTOHSCROLL + CONTROL "Use SSL connection (port 443)",IDC_SSL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,52,180,10 + CONTROL "Use remote message timestamps", IDC_REMOTE_TIME, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 4, 64, 180, 10 + CONTROL "Automatically open group chats",IDC_AUTORUN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,76,180,10 + GROUPBOX "Registration",IDC_STATIC,4,92,184,48 + LTEXT "Enter code",IDC_STATIC,8,123,47,10 + EDITTEXT IDC_PW,45,121,20,12,ES_AUTOHSCROLL | ES_NUMBER + CTEXT "-",IDC_STATIC,64,123,8,10 + EDITTEXT IDC_PW2,72,121,20,12,ES_AUTOHSCROLL | ES_NUMBER + PUSHBUTTON "Request SMS code",IDC_BUTTON_REQUEST_SMS_CODE,12,104,80,14 + PUSHBUTTON "Request Voice code",IDC_BUTTON_REQUEST_VOICE_CODE,99,104,80,14 + PUSHBUTTON "Register code",IDC_BUTTON_REGISTER,100,120,80,14 +END + +IDD_OPTIONS DIALOGEX 0, 0, 188, 164 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + LTEXT "Phone number",IDC_STATIC,4,7,55,10 + EDITTEXT IDC_CC,60,6,24,12,ES_AUTOHSCROLL + EDITTEXT IDC_LOGIN,84,6,100,12,ES_AUTOHSCROLL + LTEXT "Including country code, without '+' or '00'",IDC_STATIC,60,22,118,18 + LTEXT "Nickname",IDC_STATIC,4,43,55,10 + EDITTEXT IDC_NICK,60,42,124,12,ES_AUTOHSCROLL + LTEXT "Default group:",IDC_STATIC,4,57,55,10 + EDITTEXT IDC_DEFGROUP,60,56,124,12,ES_AUTOHSCROLL + CONTROL "Use SSL connection (port 443)",IDC_SSL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,72,180,10 + CONTROL "Use remote message timestamps", IDC_REMOTE_TIME, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 4, 84, 180, 10 + CONTROL "Automatically open group chats",IDC_AUTORUN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,96,180,10 + GROUPBOX "Registration",IDC_STATIC,4,112,184,48 + LTEXT "Enter code",IDC_STATIC,8,143,47,10 + EDITTEXT IDC_PW,45,141,20,12,ES_AUTOHSCROLL | ES_NUMBER + CTEXT "-",IDC_STATIC,64,143,8,10 + EDITTEXT IDC_PW2,72,141,20,12,ES_AUTOHSCROLL | ES_NUMBER + PUSHBUTTON "Request SMS code",IDC_BUTTON_REQUEST_SMS_CODE,12,124,80,14 + PUSHBUTTON "Request Voice code",IDC_BUTTON_REQUEST_VOICE_CODE,100,124,80,14 + PUSHBUTTON "Register code",IDC_BUTTON_REGISTER,100,140,80,14 +END + +IDD_GROUPCHAT_INVITE DIALOGEX 0, 0, 215, 170 +STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Invite users" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + GROUPBOX "Choose a user",IDC_STATIC,4,2,208,130 + CONTROL "",IDC_CLIST,"CListControl",WS_TABSTOP | 0x1,12,12,192,112,WS_EX_CLIENTEDGE + LTEXT "Other user:",IDC_STATIC,4,138,55,8 + EDITTEXT IDC_NEWJID,60,136,152,12,ES_AUTOHSCROLL + DEFPUSHBUTTON "&Invite",IDOK,108,152,50,14 + PUSHBUTTON "Cancel",IDCANCEL,162,152,50,14 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_WHATSAPP ICON "whatsapp.ico" + +#endif // German (Germany) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/protocols/WhatsAppWeb/src/avatars.cpp b/protocols/WhatsAppWeb/src/avatars.cpp new file mode 100644 index 0000000000..cacd251639 --- /dev/null +++ b/protocols/WhatsAppWeb/src/avatars.cpp @@ -0,0 +1,74 @@ +#include "stdafx.h" + +INT_PTR WhatsAppProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam) +{ + PROTO_AVATAR_INFORMATION *pai = (PROTO_AVATAR_INFORMATION*)lParam; + + ptrA id(getStringA(pai->hContact, isChatRoom(pai->hContact) ? "ChatRoomID" : WHATSAPP_KEY_ID)); + if (id == NULL) + return GAIR_NOAVATAR; + + CMStringW tszFileName(GetAvatarFileName(pai->hContact)); + wcsncpy_s(pai->filename, tszFileName.c_str(), _TRUNCATE); + pai->format = PA_FORMAT_JPEG; + + ptrA szAvatarId(getStringA(pai->hContact, WHATSAPP_KEY_AVATAR_ID)); + if (szAvatarId == NULL || (wParam & GAIF_FORCE) != 0) + if (pai->hContact != NULL && isOnline()) { + // m_pConnection->sendGetPicture(id, "image"); + return GAIR_WAITFOR; + } + + debugLogA("No avatar"); + return GAIR_NOAVATAR; +} + +INT_PTR WhatsAppProto::GetAvatarCaps(WPARAM wParam, LPARAM lParam) +{ + switch (wParam) { + case AF_PROPORTION: + return PIP_SQUARE; + + case AF_FORMATSUPPORTED: // Jabber supports avatars of virtually all formats + return PA_FORMAT_JPEG; + + case AF_ENABLED: + return TRUE; + + case AF_MAXSIZE: + POINT *size = (POINT*)lParam; + if (size) + size->x = size->y = 640; + return 0; + } + return -1; +} + +CMStringW WhatsAppProto::GetAvatarFileName(MCONTACT hContact) +{ + CMStringW result = m_tszAvatarFolder + L"\\"; + + CMStringA jid; + if (hContact != NULL) { + ptrA szId(getStringA(hContact, isChatRoom(hContact) ? "ChatRoomID" : WHATSAPP_KEY_ID)); + if (szId == NULL) + return L""; + + jid = szId; + } + else jid = m_szJid; + + return result + _A2T(jid.c_str()) + L".jpg"; +} + +INT_PTR WhatsAppProto::GetMyAvatar(WPARAM wParam, LPARAM lParam) +{ + std::wstring tszOwnAvatar(m_tszAvatarFolder + L"\\myavatar.jpg"); + wcsncpy_s((wchar_t*)wParam, lParam, tszOwnAvatar.c_str(), _TRUNCATE); + return 0; +} + +INT_PTR WhatsAppProto::SetMyAvatar(WPARAM, LPARAM lParam) +{ + return 0; +} diff --git a/protocols/WhatsAppWeb/src/db.h b/protocols/WhatsAppWeb/src/db.h new file mode 100644 index 0000000000..3c73fb18e7 --- /dev/null +++ b/protocols/WhatsAppWeb/src/db.h @@ -0,0 +1,35 @@ +#define MODULENAME "WhatsApp" + +// DB keys +#define WHATSAPP_KEY_ID "ID" +#define WHATSAPP_KEY_LOGIN "Login" +#define WHATSAPP_KEY_CC "CountryCode" +#define WHATSAPP_KEY_NICK "Nick" +#define WHATSAPP_KEY_PASS "Password" +#define WHATSAPP_KEY_IDX "DeviceID" +#define WHATSAPP_KEY_MAP_STATUSES "MapStatuses" +#define WHATSAPP_KEY_LOGGING_ENABLE "LoggingEnable" +#define WHATSAPP_KEY_NAME "RealName" +#define WHATSAPP_KEY_LAST_SEEN "LastSeen" +#define WHATSAPP_KEY_LAST_SEEN_DENIED "LastSeenDenied" +#define WHATSAPP_KEY_AVATAR_ID "AvatarId" +#define WHATSAPP_KEY_SYSTRAY_NOTIFY "UseSystrayNotify" +#define WHATSAPP_KEY_DEF_GROUP "DefaultGroup" +#define WHATSAPP_KEY_REG_CODE "RegistrationCode" +#define WHATSAPP_KEY_SSL "UseSSL" +#define WHATSAPP_KEY_AUTORUNCHATS "AutoRunChats" +#define WHATSAPP_KEY_USE_REMOTE_TIME "UseRemoteTime" + +#define WHATSAPP_KEY_EVENT_CLIENT_ENABLE "EventClientEnable" +#define WHATSAPP_KEY_EVENT_OTHER_ENABLE "EventOtherEnable" + +#define WHATSAPP_KEY_EVENT_CLIENT_COLBACK "PopupClientColorBack" +#define WHATSAPP_KEY_EVENT_CLIENT_COLTEXT "PopupClientColorText" +#define WHATSAPP_KEY_EVENT_CLIENT_TIMEOUT "PopupClientTimeout" +#define WHATSAPP_KEY_EVENT_CLIENT_DEFAULT "PopupClientColorDefault" + +#define WHATSAPP_KEY_EVENT_OTHER_COLBACK "PopupOtherColorBack" +#define WHATSAPP_KEY_EVENT_OTHER_COLTEXT "PopupOtherColorText" +#define WHATSAPP_KEY_EVENT_OTHER_TIMEOUT "PopupOtherTimeout" +#define WHATSAPP_KEY_EVENT_OTHER_DEFAULT "PopupOtherColorDefault" + diff --git a/protocols/WhatsAppWeb/src/main.cpp b/protocols/WhatsAppWeb/src/main.cpp new file mode 100644 index 0000000000..f414c61c19 --- /dev/null +++ b/protocols/WhatsAppWeb/src/main.cpp @@ -0,0 +1,50 @@ +#include "stdafx.h" +#include "version.h" + +CMPlugin g_plugin; + +PLUGININFOEX pluginInfo = { + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), + __DESCRIPTION, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + UNICODE_AWARE, //not transient + // {4f1ff7fa-4d75-44b9-93b0-2ced2e4f9e3e} + { 0x4f1ff7fa, 0x4d75, 0x44b9, { 0x93, 0xb0, 0x2c, 0xed, 0x2e, 0x4f, 0x9e, 0x3e } } + +}; + +///////////////////////////////////////////////////////////////////////////////////////// +// Interface information + +extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST }; + +///////////////////////////////////////////////////////////////////////////// + +CMPlugin::CMPlugin() : + ACCPROTOPLUGIN<WhatsAppProto>(MODULENAME, pluginInfo) +{ + SetUniqueId(WHATSAPP_KEY_ID); +} + +///////////////////////////////////////////////////////////////////////////////////////// +// Load + +int CMPlugin::Load() +{ + // InitIcons(); + // InitContactMenus(); + + return 0; +} + +///////////////////////////////////////////////////////////////////////////////////////// +// Unload + +int CMPlugin::Unload() +{ + return 0; +} diff --git a/protocols/WhatsAppWeb/src/proto.cpp b/protocols/WhatsAppWeb/src/proto.cpp new file mode 100644 index 0000000000..ac7a5b2bff --- /dev/null +++ b/protocols/WhatsAppWeb/src/proto.cpp @@ -0,0 +1,228 @@ +#include "stdafx.h" + +struct SearchParam +{ + SearchParam(const wchar_t *_jid, LONG _id) : + jid(_jid), id(_id) + {} + + std::wstring jid; + LONG id; +}; + +WhatsAppProto::WhatsAppProto(const char *proto_name, const wchar_t *username) + : PROTO<WhatsAppProto>(proto_name, username), + m_tszDefaultGroup(getWStringA(WHATSAPP_KEY_DEF_GROUP)) +{ + db_set_resident(m_szModuleName, "StatusMsg"); + + // CreateProtoService(PS_CREATEACCMGRUI, &WhatsAppProto::SvcCreateAccMgrUI); + + CreateProtoService(PS_GETAVATARINFO, &WhatsAppProto::GetAvatarInfo); + CreateProtoService(PS_GETAVATARCAPS, &WhatsAppProto::GetAvatarCaps); + CreateProtoService(PS_GETMYAVATAR, &WhatsAppProto::GetMyAvatar); + CreateProtoService(PS_SETMYAVATAR, &WhatsAppProto::SetMyAvatar); + + // HookProtoEvent(ME_OPT_INITIALISE, &WhatsAppProto::OnOptionsInit); + // HookProtoEvent(ME_CLIST_PREBUILDSTATUSMENU, &WhatsAppProto::OnBuildStatusMenu); + + // Create standard network connection + wchar_t descr[512]; + mir_snwprintf(descr, TranslateT("%s server connection"), m_tszUserName); + + NETLIBUSER nlu = {}; + nlu.flags = NUF_INCOMING | NUF_OUTGOING | NUF_HTTPCONNS | NUF_UNICODE; + nlu.szSettingsModule = m_szModuleName; + nlu.szDescriptiveName.w = descr; + m_hNetlibUser = Netlib_RegisterUser(&nlu); + if (m_hNetlibUser == nullptr) { + wchar_t error[200]; + mir_snwprintf(error, TranslateT("Unable to initialize Netlib for %s."), m_tszUserName); + MessageBox(nullptr, error, L"Miranda NG", MB_OK | MB_ICONERROR); + } + + m_tszAvatarFolder = CMStringW(VARSW(L"%miranda_avatarcache%")) + L"\\" + m_tszUserName; + DWORD dwAttributes = GetFileAttributes(m_tszAvatarFolder.c_str()); + if (dwAttributes == 0xffffffff || (dwAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) + CreateDirectoryTreeW(m_tszAvatarFolder.c_str()); + + if (m_tszDefaultGroup == NULL) + m_tszDefaultGroup = mir_wstrdup(L"WhatsApp"); + Clist_GroupCreate(0, m_tszDefaultGroup); +} + +WhatsAppProto::~WhatsAppProto() +{ +} + +INT_PTR WhatsAppProto::GetCaps(int type, MCONTACT) +{ + switch (type) { + case PFLAGNUM_1: + return PF1_IM | PF1_FILESEND | PF1_CHAT | PF1_BASICSEARCH | PF1_ADDSEARCHRES | PF1_MODEMSGRECV; + case PFLAGNUM_2: + return PF2_ONLINE | PF2_INVISIBLE; + case PFLAGNUM_3: + return 0; + case PFLAGNUM_4: + return PF4_NOCUSTOMAUTH | PF4_NOAUTHDENYREASON | PF4_IMSENDOFFLINE | PF4_OFFLINEFILES | PF4_SUPPORTTYPING | PF4_AVATARS; + case PFLAGNUM_5: + return 0; + case PFLAG_UNIQUEIDTEXT: + return (DWORD_PTR)"WhatsApp ID"; + } + return 0; +} + +int WhatsAppProto::SetStatus(int new_status) +{ + if (m_iDesiredStatus == new_status) + return 0; + + int oldStatus = m_iStatus; + debugLogA("===== Beginning SetStatus process"); + + // Routing statuses not supported by WhatsApp + switch (new_status) { + case ID_STATUS_INVISIBLE: + case ID_STATUS_OFFLINE: + m_iDesiredStatus = new_status; + break; + + case ID_STATUS_ONLINE: + case ID_STATUS_FREECHAT: + m_iDesiredStatus = ID_STATUS_ONLINE; + break; + + default: + m_iDesiredStatus = ID_STATUS_INVISIBLE; + break; + } + + if (m_iDesiredStatus == ID_STATUS_OFFLINE) { + m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE; + ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus); + } + else if (!IsStatusConnecting(m_iStatus)) { + m_iStatus = ID_STATUS_CONNECTING; + ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus); + } + else ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus); + + return 0; +} + +MCONTACT WhatsAppProto::AddToList(int flags, PROTOSEARCHRESULT *psr) +{ + if (psr->id.w == nullptr) + return NULL; + + std::string phone(T2Utf(psr->id.w)); + std::string jid(phone + "@s.whatsapp.net"); + +/* MCONTACT hContact = AddToContactList(jid, phone.c_str()); + if (!(flags & PALF_TEMPORARY)) + db_unset(hContact, "CList", "NotOnList"); + + return hContact;*/ +} + +int WhatsAppProto::SendMsg(MCONTACT hContact, int, const char *msg) +{ + ptrA jid(getStringA(hContact, "ID")); + if (jid == NULL) + return 0; + + if (!isOnline()) { + debugLogA("No connection"); + return 0; + } + + return 0; +} + +int WhatsAppProto::UserIsTyping(MCONTACT hContact, int type) +{ + if (hContact && isOnline()) { + ptrA jid(getStringA(hContact, WHATSAPP_KEY_ID)); + if (jid && isOnline()) { + } + } + + return 0; +} + +///////////////////////////////////////////////////////////////////////////////////////// + +void WhatsAppProto::SearchAckThread(void *targ) +{ + Sleep(100); + + SearchParam *param = (SearchParam*)targ; + PROTOSEARCHRESULT psr = { 0 }; + psr.cbSize = sizeof(psr); + psr.flags = PSR_UNICODE; + psr.nick.w = psr.firstName.w = psr.lastName.w = L""; + psr.id.w = (wchar_t*)param->jid.c_str(); + + ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)param->id, (LPARAM)&psr); + ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)param->id, 0); + + delete param; +} + +HANDLE WhatsAppProto::SearchBasic(const wchar_t* id) +{ + if (isOffline()) + return nullptr; + + // fake - we always accept search + SearchParam *param = new SearchParam(id, -1); + ForkThread(&WhatsAppProto::SearchAckThread, param); + return (HANDLE)param->id; +} + +////////////////////////////////////////////////////////////////////////////// +// EVENTS + +int WhatsAppProto::OnUserInfo(WPARAM, LPARAM hContact) +{ +/* ptrA jid(getStringA(hContact, WHATSAPP_KEY_ID)); + if (jid && isOnline()) { + m_pConnection->sendGetPicture((char*)jid, "image"); + m_pConnection->sendPresenceSubscriptionRequest((char*)jid); + } +*/ + return 0; +} + +void WhatsAppProto::RequestFriendship(MCONTACT hContact) +{ + if (hContact == NULL || isOffline()) + return; + +/* ptrA jid(getStringA(hContact, WHATSAPP_KEY_ID)); + if (jid) + m_pConnection->sendPresenceSubscriptionRequest((char*)jid); */ +} + +LRESULT CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) { + case WM_COMMAND: + // After a click, destroy popup + PUDeletePopup(hwnd); + break; + + case WM_CONTEXTMENU: + PUDeletePopup(hwnd); + break; + + case UM_FREEPLUGINDATA: + // After close, free + mir_free(PUGetPluginData(hwnd)); + return FALSE; + } + + return DefWindowProc(hwnd, message, wParam, lParam); +}; diff --git a/protocols/WhatsAppWeb/src/proto.h b/protocols/WhatsAppWeb/src/proto.h new file mode 100644 index 0000000000..564a31eb2e --- /dev/null +++ b/protocols/WhatsAppWeb/src/proto.h @@ -0,0 +1,93 @@ +#if !defined(PROTO_H) +#define PROTO_H + +struct WAChatInfo +{ + WAChatInfo(wchar_t *_jid, wchar_t *_nick) : + tszJid(_jid), tszNick(_nick) + { + bActive = false; + } + + ptrW tszJid, tszNick, tszOwner; + bool bActive; + + MCONTACT hContact; +}; + +class WhatsAppProto : public PROTO<WhatsAppProto> +{ + ptrW m_tszDefaultGroup; + + CMStringA m_szJid; + CMStringW m_tszAvatarFolder; + + /// Avatars ////////////////////////////////////////////////////////////////////////// + CMStringW GetAvatarFileName(MCONTACT hContact); + + INT_PTR __cdecl GetAvatarInfo(WPARAM, LPARAM); + INT_PTR __cdecl GetAvatarCaps(WPARAM, LPARAM); + INT_PTR __cdecl GetMyAvatar(WPARAM, LPARAM); + INT_PTR __cdecl SetMyAvatar(WPARAM, LPARAM); + +public: + WhatsAppProto(const char *proto_name, const wchar_t *username); + ~WhatsAppProto(); + + inline bool isOnline() const + { return false; + } + + inline bool isOffline() const + { return (m_iStatus == ID_STATUS_OFFLINE); + } + + inline bool isInvisible() const + { return (m_iStatus == ID_STATUS_INVISIBLE); + } + + // PROTO_INTERFACE /////////////////////////////////////////////////////////////////// + + MCONTACT __cdecl AddToList(int flags, PROTOSEARCHRESULT *psr) override; + INT_PTR __cdecl GetCaps(int type, MCONTACT hContact = NULL) override; + HANDLE __cdecl SearchBasic(const wchar_t* id) override; + int __cdecl SendMsg(MCONTACT hContact, int flags, const char* msg) override; + int __cdecl SetStatus(int iNewStatus) override; + int __cdecl UserIsTyping(MCONTACT hContact, int type) override; + + // Services ////////////////////////////////////////////////////////////////////////// + + INT_PTR __cdecl SvcCreateAccMgrUI(WPARAM, LPARAM); + + // Events //////////////////////////////////////////////////////////////////////////// + + int __cdecl OnOptionsInit(WPARAM, LPARAM); + int __cdecl OnUserInfo(WPARAM, LPARAM); + int __cdecl OnBuildStatusMenu(WPARAM, LPARAM); + + // Worker Threads //////////////////////////////////////////////////////////////////// + + void __cdecl stayConnectedLoop(void*); + void __cdecl sentinelLoop(void*); + + // Processing Threads //////////////////////////////////////////////////////////////// + + void __cdecl ProcessBuddyList(void*); + void __cdecl SearchAckThread(void*); + + // Contacts handling ///////////////////////////////////////////////////////////////// + + void SetAllContactStatuses(int status, bool reset_client = false); + void UpdateStatusMsg(MCONTACT hContact); + void RequestFriendship(MCONTACT hContact); +}; + +struct CMPlugin : public ACCPROTOPLUGIN<WhatsAppProto> +{ + CMPlugin(); + + int Load() override; + int Unload() override; +}; + +#endif diff --git a/protocols/WhatsAppWeb/src/resource.h b/protocols/WhatsAppWeb/src/resource.h new file mode 100644 index 0000000000..67e976f3ca --- /dev/null +++ b/protocols/WhatsAppWeb/src/resource.h @@ -0,0 +1,43 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by ..\res\whatsapp.rc +// +#define IDD_INPUTBOX 102 +#define IDR_REGISTERUTILITY 103 +#define IDD_ACCMGRUI 104 +#define IDD_GROUPCHAT_INVITE 105 +#define IDD_OPTIONS 106 +#define IDI_WHATSAPP 203 +#define IDI_ADD_GROUP 206 +#define IDI_RENAME_GROUP 208 +#define IDC_CLIST 1001 +#define IDC_NEWJID 1002 +#define IDC_LOGIN 1003 +#define IDC_PW 1004 +#define IDC_SSL 1005 +#define IDC_NICK 1006 +#define IDC_BUTTON_REQUEST_SMS_CODE 1007 +#define IDC_BUTTON_REGISTER 1008 +#define IDC_CC 1009 +#define IDC_VALUE 1010 +#define IDC_SSL2 1010 +#define IDC_CANCEL 1011 +#define IDC_OK 1012 +#define IDC_PW2 1013 +#define IDC_TEXT 1014 +#define IDC_INVITE 1015 +#define IDC_AUTORUN 1016 +#define IDC_DEFGROUP 1017 +#define IDC_REMOTE_TIME 1018 +#define IDC_BUTTON_REQUEST_VOICE_CODE 1019 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 107 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1020 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/protocols/WhatsAppWeb/src/stdafx.cxx b/protocols/WhatsAppWeb/src/stdafx.cxx new file mode 100644 index 0000000000..115d277c7a --- /dev/null +++ b/protocols/WhatsAppWeb/src/stdafx.cxx @@ -0,0 +1,8 @@ +// stdafx.cpp : Quelldatei, die nur die Standard-Includes einbindet. +// WhatsAPI++.pch ist der vorkompilierte Header. +// stdafx.obj enthдlt die vorkompilierten Typinformationen. + +#include "stdafx.h" + +// TODO: Auf zusдtzliche Header verweisen, die in STDAFX.H +// und nicht in dieser Datei erforderlich sind. diff --git a/protocols/WhatsAppWeb/src/stdafx.h b/protocols/WhatsAppWeb/src/stdafx.h new file mode 100644 index 0000000000..1f3834b9bc --- /dev/null +++ b/protocols/WhatsAppWeb/src/stdafx.h @@ -0,0 +1,47 @@ +/* + +WhatsApp plugin for Miranda NG +Copyright © 2013-14 Uli Hecht + +*/ + +#pragma once + +//#pragma warning(push) +//#pragma warning(disable:4312) +#pragma warning(disable:4996) +#pragma warning(disable:4290) + +#include <time.h> +#include <windows.h> + +#include <newpluginapi.h> +#include <m_avatars.h> +#include <m_chat.h> +#include <m_clist.h> +#include <m_database.h> +#include <m_history.h> +#include <m_imgsrvc.h> +#include <m_ignore.h> +#include <m_langpack.h> +#include <m_message.h> +#include <m_netlib.h> +#include <m_options.h> +#include <m_popup.h> +#include <m_protocols.h> +#include <m_protosvc.h> +#include <m_protoint.h> +#include <m_skin.h> +#include <m_string.h> +#include <statusmodes.h> +#include <m_userinfo.h> +#include <m_icolib.h> +#include <m_utils.h> +#include <m_xml.h> +#include <m_hotkeys.h> +#include <m_folders.h> +#include <m_json.h> +#include <m_gui.h> + +#include "db.h" +#include "proto.h" diff --git a/protocols/WhatsAppWeb/src/version.h b/protocols/WhatsAppWeb/src/version.h new file mode 100644 index 0000000000..2aa4528fd5 --- /dev/null +++ b/protocols/WhatsAppWeb/src/version.h @@ -0,0 +1,14 @@ +#define __MAJOR_VERSION 0 +#define __MINOR_VERSION 0 +#define __RELEASE_NUM 1 +#define __BUILD_NUM 1 + +#include <stdver.h> + +#define __PLUGIN_NAME "WhatsAppWeb protocol" +#define __FILENAME "WhatsApp.dll" +#define __DESCRIPTION "WhatsApp Web protocol support for Miranda NG." +#define __AUTHOR "George Hazan" +#define __AUTHOREMAIL "" +#define __AUTHORWEB "https://miranda-ng.org/p/WhatsApp/" +#define __COPYRIGHT "© 2019 Miranda NG Team" |