From ff7f3e307695442889801f3bd9afbe14075da6d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Fri, 9 Nov 2012 13:58:09 +0000 Subject: Added MobileState plugin. git-svn-id: http://svn.miranda-ng.org/main/trunk@2256 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MobileState/mobilestate_10.vcxproj | 199 +++++++++++++++++++++ plugins/MobileState/mobilestate_10.vcxproj.filters | 52 ++++++ plugins/MobileState/res/mobile.ico | Bin 0 -> 1150 bytes plugins/MobileState/res/mobilestate.rc | 80 +++++++++ plugins/MobileState/res/version.rc | 38 ++++ plugins/MobileState/src/commonheaders.h | 42 +++++ plugins/MobileState/src/main.cpp | 150 ++++++++++++++++ plugins/MobileState/src/resource.h | 16 ++ plugins/MobileState/src/version.h | 20 +++ 9 files changed, 597 insertions(+) create mode 100644 plugins/MobileState/mobilestate_10.vcxproj create mode 100644 plugins/MobileState/mobilestate_10.vcxproj.filters create mode 100644 plugins/MobileState/res/mobile.ico create mode 100644 plugins/MobileState/res/mobilestate.rc create mode 100644 plugins/MobileState/res/version.rc create mode 100644 plugins/MobileState/src/commonheaders.h create mode 100644 plugins/MobileState/src/main.cpp create mode 100644 plugins/MobileState/src/resource.h create mode 100644 plugins/MobileState/src/version.h (limited to 'plugins/MobileState') diff --git a/plugins/MobileState/mobilestate_10.vcxproj b/plugins/MobileState/mobilestate_10.vcxproj new file mode 100644 index 0000000000..ee74f49f4a --- /dev/null +++ b/plugins/MobileState/mobilestate_10.vcxproj @@ -0,0 +1,199 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + MobileState + {DB315D7D-00BB-43B2-93A6-0430CA2B9F28} + + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)\Plugins\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)\Plugins\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Plugins\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Plugins\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + true + + + + Disabled + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;MOBILESTATE_EXPORTS;%(PreprocessorDefinitions) + MultiThreadedDebugDLL + Use + Commonheaders.h + Level3 + EditAndContinue + 4996;%(DisableSpecificWarnings) + + + true + Windows + 0x22620000 + false + $(IntDir)$(TargetName).lib + $(ProfileDir)..\..\bin10\lib + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + + + Full + OnlyExplicitInline + Size + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;MOBILESTATE_EXPORTS;%(PreprocessorDefinitions) + Use + Commonheaders.h + Level3 + 4996;%(DisableSpecificWarnings) + + + true + Windows + true + true + 0x22620000 + false + $(IntDir)$(TargetName).lib + $(ProfileDir)..\..\bin10\lib + /PDBALTPATH:%_PDB% + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + + + Disabled + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN64;_DEBUG;_WINDOWS;_USRDLL;MOBILESTATE_EXPORTS;%(PreprocessorDefinitions) + MultiThreadedDebugDLL + Use + Commonheaders.h + Level3 + 4996;%(DisableSpecificWarnings) + + + true + Windows + 0x22620000 + false + $(IntDir)$(TargetName).lib + $(ProfileDir)..\..\bin10\lib + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + + + Full + OnlyExplicitInline + Size + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN64;NDEBUG;_WINDOWS;_USRDLL;MOBILESTATE_EXPORTS;%(PreprocessorDefinitions) + Use + Commonheaders.h + Level3 + 4996;%(DisableSpecificWarnings) + + + true + Windows + true + true + 0x22620000 + false + $(IntDir)$(TargetName).lib + $(ProfileDir)..\..\bin10\lib + /PDBALTPATH:%_PDB% + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + + + Create + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/MobileState/mobilestate_10.vcxproj.filters b/plugins/MobileState/mobilestate_10.vcxproj.filters new file mode 100644 index 0000000000..678f37832c --- /dev/null +++ b/plugins/MobileState/mobilestate_10.vcxproj.filters @@ -0,0 +1,52 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx + + + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + + + Resource Files + + + Resource Files + + + + + Resource Files + + + Resource Files + + + Resource Files + + + \ No newline at end of file diff --git a/plugins/MobileState/res/mobile.ico b/plugins/MobileState/res/mobile.ico new file mode 100644 index 0000000000..5ecaf1cd56 Binary files /dev/null and b/plugins/MobileState/res/mobile.ico differ diff --git a/plugins/MobileState/res/mobilestate.rc b/plugins/MobileState/res/mobilestate.rc new file mode 100644 index 0000000000..b7f5153d7d --- /dev/null +++ b/plugins/MobileState/res/mobilestate.rc @@ -0,0 +1,80 @@ +// 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 + +///////////////////////////////////////////////////////////////////////////// +// Czech (Czech Republic) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CSY) +LANGUAGE LANG_CZECH, SUBLANG_DEFAULT +#pragma code_page(1250) + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_MOBILE ICON "mobile.ico" +#endif // Czech (Czech Republic) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#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 + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/MobileState/res/version.rc b/plugins/MobileState/res/version.rc new file mode 100644 index 0000000000..5bfbab4754 --- /dev/null +++ b/plugins/MobileState/res/version.rc @@ -0,0 +1,38 @@ +// Microsoft Visual C++ generated resource script. +// +#ifdef APSTUDIO_INVOKED +#error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + +#include "afxres.h" +#include "..\src\version.h" + +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/MobileState/src/commonheaders.h b/plugins/MobileState/src/commonheaders.h new file mode 100644 index 0000000000..811c50f07f --- /dev/null +++ b/plugins/MobileState/src/commonheaders.h @@ -0,0 +1,42 @@ +/* + Mobile State plugin for Miranda NG (www.miranda-ng.org) + (c) 2012 by Robert Pösel + + 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 COMMHEADERS_H +#define COMMHEADERS_H + +#define MIRANDA_VER 0x0A00 + +#include + +// Miranda API headers +#include +#include +#include +#include +#include +#include + +#include "resource.h" +#include "Version.h" + +#define MODULENAME "MobileState" + +extern HINSTANCE g_hInst; + +#endif //COMMHEADERS_H diff --git a/plugins/MobileState/src/main.cpp b/plugins/MobileState/src/main.cpp new file mode 100644 index 0000000000..0ea50726ad --- /dev/null +++ b/plugins/MobileState/src/main.cpp @@ -0,0 +1,150 @@ +/* + Mobile State plugin for Miranda NG (www.miranda-ng.org) + (c) 2012 by Robert Pösel + + 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 "commonheaders.h" + +HINSTANCE g_hInst; +static HANDLE hHookModulesLoaded = NULL; +static HANDLE hHookExtraIconsApply = NULL, hContactSettingChanged = NULL; +HANDLE hExtraIcon = NULL; +int hLangpack; + +PLUGININFOEX pluginInfo = { + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), + __DESCRIPTION, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + // {F0BA32D0-CD07-4A9C-926B-5A1FF21C3C10} + {0xf0ba32d0, 0xcd07, 0x4a9c, { 0x92, 0x6b, 0x5a, 0x1f, 0xf2, 0x1c, 0x3c, 0x10 }} +}; + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + g_hInst = hinstDLL; + return TRUE; +} + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +bool hasMobileClient(HANDLE hContact, LPARAM lParam) +{ + char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + bool ret = false; + + DBVARIANT dbv; + if (!DBGetContactSettingTString(hContact, proto, "MirVer", &dbv)) + { + if (_tcsstr(dbv.ptszVal, _T("Android")) || _tcsstr(dbv.ptszVal, _T("android")) || _tcsstr(dbv.ptszVal, _T("Mobile")) || _tcsstr(dbv.ptszVal, _T("mobile"))) + ret = true; + + DBFreeVariant(&dbv); + } + + return ret; +} + +int ExtraIconsApply(WPARAM wParam, LPARAM lParam) +{ + if (wParam == NULL) + return 0; + + const char *icon = hasMobileClient((HANDLE) wParam, lParam) ? "mobile_icon" : NULL; + + ExtraIcon_SetIcon(hExtraIcon, (HANDLE)wParam, icon); + return 0; +} + +int onContactSettingChanged(WPARAM wParam,LPARAM lParam) +{ + DBCONTACTWRITESETTING *cws=(DBCONTACTWRITESETTING*)lParam; + char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + if (!proto) + return 0; + + if (!lstrcmpA(cws->szModule,proto)) + if (!lstrcmpA(cws->szSetting, "MirVer")) + ExtraIconsApply(wParam, 1); + + return 0; +} + +int onModulesLoaded(WPARAM wParam,LPARAM lParam) +{ + // IcoLib support + TCHAR szFile[MAX_PATH]; + GetModuleFileName(g_hInst, szFile, MAX_PATH); + + SKINICONDESC sid = {0}; + sid.cbSize = sizeof(sid); + sid.flags = SIDF_ALL_TCHAR; + + sid.ptszSection = _T("Mobile State"); + sid.ptszDefaultFile = szFile; + + sid.ptszDescription = _T("Mobile State"); + sid.pszName = "mobile_icon"; + sid.iDefaultIndex = -IDI_MOBILE; + Skin_AddIcon(&sid); + + // extra icons + hExtraIcon = ExtraIcon_Register("mobilestate", "Mobile State", "mobile_icon"); + + // Set initial value for all contacts + HANDLE hContact = db_find_first(); + while (hContact != NULL) { + ExtraIconsApply((WPARAM)hContact, 1); + hContact = db_find_next(hContact); + } + + return 0; +} + +int onSystemOKToExit(WPARAM wParam,LPARAM lParam) +{ + + return 0; +} + +extern "C" int __declspec(dllexport) Load(void) +{ + mir_getLP(&pluginInfo); + + hHookModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, onModulesLoaded); + hContactSettingChanged = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, onContactSettingChanged); + hHookExtraIconsApply = HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY, ExtraIconsApply); + + return 0; +} + +extern "C" int __declspec(dllexport) Unload(void) +{ + UnhookEvent(hHookModulesLoaded); + UnhookEvent(hHookExtraIconsApply); + UnhookEvent(hContactSettingChanged); + + return 0; +} diff --git a/plugins/MobileState/src/resource.h b/plugins/MobileState/src/resource.h new file mode 100644 index 0000000000..23a3832222 --- /dev/null +++ b/plugins/MobileState/src/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Z:\Myranda\trunk\plugins\MobileState\res\mobilestate.rc +// +#define IDI_MOBILE 105 + +// 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 1010 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/plugins/MobileState/src/version.h b/plugins/MobileState/src/version.h new file mode 100644 index 0000000000..06b775380e --- /dev/null +++ b/plugins/MobileState/src/version.h @@ -0,0 +1,20 @@ +#define __MAJOR_VERSION 0 +#define __MINOR_VERSION 0 +#define __RELEASE_NUM 1 +#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 "Mobile State" +#define __INTERNAL_NAME "MobileState" +#define __FILENAME "MobileState.dll" +#define __DESCRIPTION "Plugin shows mobile icon in contact list next to contacts which are using mobile client." +#define __AUTHOR "Robert Pösel" +#define __AUTHOREMAIL "robyer@seznam.cz" +#define __AUTHORWEB "http://miranda-ng.org/" +#define __COPYRIGHT "© 2012 Robert Pösel" -- cgit v1.2.3