From 26f56c43370a09117821f818ac37bf9f550085ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Tue, 13 Nov 2012 20:17:01 +0000 Subject: MobileState: Rewrited detection and added more clients. git-svn-id: http://svn.miranda-ng.org/main/trunk@2307 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MobileState/src/clients.h | 38 +++++++++++++++++++++++++++++++++ plugins/MobileState/src/commonheaders.h | 6 ++---- plugins/MobileState/src/main.cpp | 18 +++++++++------- 3 files changed, 50 insertions(+), 12 deletions(-) create mode 100644 plugins/MobileState/src/clients.h (limited to 'plugins/MobileState/src') diff --git a/plugins/MobileState/src/clients.h b/plugins/MobileState/src/clients.h new file mode 100644 index 0000000000..5ff4ea71df --- /dev/null +++ b/plugins/MobileState/src/clients.h @@ -0,0 +1,38 @@ +/* + 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 +*/ + +#pragma once + +static const TCHAR *clients[] = { + _T("android"), + _T("mobile"), + _T("pda"), + _T("gtalk"), + _T("jtalk"), + _T("jasmine"), + _T("ebuddy"), + _T("emessenger"), + _T("jimm"), + _T("mobicq"), + _T("bombus"), + _T("colibry"), + _T("berry"), + _T("iphone"), + _T("ipad") +}; diff --git a/plugins/MobileState/src/commonheaders.h b/plugins/MobileState/src/commonheaders.h index 811c50f07f..2574df0c71 100644 --- a/plugins/MobileState/src/commonheaders.h +++ b/plugins/MobileState/src/commonheaders.h @@ -17,12 +17,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef COMMHEADERS_H -#define COMMHEADERS_H +#pragma once #define MIRANDA_VER 0x0A00 #include +#include // Miranda API headers #include @@ -38,5 +38,3 @@ #define MODULENAME "MobileState" extern HINSTANCE g_hInst; - -#endif //COMMHEADERS_H diff --git a/plugins/MobileState/src/main.cpp b/plugins/MobileState/src/main.cpp index 0ea50726ad..f0c3bc77e9 100644 --- a/plugins/MobileState/src/main.cpp +++ b/plugins/MobileState/src/main.cpp @@ -18,6 +18,7 @@ */ #include "commonheaders.h" +#include "clients.h" HINSTANCE g_hInst; static HANDLE hHookModulesLoaded = NULL; @@ -53,18 +54,19 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda 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; - + if (!DBGetContactSettingTString(hContact, proto, "MirVer", &dbv)) { + TCHAR *client = _tcslwr(NEWTSTR_ALLOCA(dbv.ptszVal)); DBFreeVariant(&dbv); + + for (size_t i=0; i<(sizeof(clients) / sizeof(TCHAR*)); i++) { + if (_tcsstr(client, clients[i])) { + return true; + } + } } - - return ret; + return false; } int ExtraIconsApply(WPARAM wParam, LPARAM lParam) -- cgit v1.2.3