From 35daa0c0ba771eb0bab7f870f12eaf265ec58a2d Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Mon, 23 Aug 2010 18:36:26 +0300 Subject: secureim code parts new file: clist.cpp modified: commonheaders.h new file: icons.cpp new file: icons/secured.ico new file: icons/unsecured.ico modified: init.cpp new file: m_extraicons.h new file: m_metacontacts.h new file: metacontacts.cpp modified: new_gpg.vcproj new file: srmm.cpp modified: utilities.cpp modified: utilities.h --- clist.cpp | 39 ++++++++++++ commonheaders.h | 4 ++ icons.cpp | 85 +++++++++++++++++++++++++++ icons/secured.ico | Bin 0 -> 2550 bytes icons/unsecured.ico | Bin 0 -> 2550 bytes init.cpp | 25 ++++++-- m_extraicons.h | 158 +++++++++++++++++++++++++++++++++++++++++++++++++ m_metacontacts.h | 166 ++++++++++++++++++++++++++++++++++++++++++++++++++++ metacontacts.cpp | 61 +++++++++++++++++++ new_gpg.vcproj | 24 ++++++++ srmm.cpp | 45 ++++++++++++++ utilities.cpp | 7 +++ utilities.h | 1 + 13 files changed, 609 insertions(+), 6 deletions(-) create mode 100644 clist.cpp create mode 100644 icons.cpp create mode 100644 icons/secured.ico create mode 100644 icons/unsecured.ico create mode 100644 m_extraicons.h create mode 100644 m_metacontacts.h create mode 100644 metacontacts.cpp create mode 100644 srmm.cpp diff --git a/clist.cpp b/clist.cpp new file mode 100644 index 0000000..4fa35bc --- /dev/null +++ b/clist.cpp @@ -0,0 +1,39 @@ +// Copyright © 2010 SecureIM developers (baloo and others), sss +// +// 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" + +extern HANDLE g_hCLIcon; +void RefreshContactListIcons(void); + +int onExtraImageListRebuilding(WPARAM, LPARAM) +{ + if(g_hCLIcon && ServiceExists(MS_CLIST_EXTRA_ADD_ICON) ) + RefreshContactListIcons(); + return 0; +} + + +int onExtraImageApplying(WPARAM wParam, LPARAM) +{ + if(g_hCLIcon && ServiceExists(MS_CLIST_EXTRA_SET_ICON)) + { + IconExtraColumn iec = {0}; //need to init this + if( g_hCLIcon ) + ExtraIcon_SetIcon(g_hCLIcon, (HANDLE)wParam, iec.hImage); + } + return 0; +} diff --git a/commonheaders.h b/commonheaders.h index 1effbfe..a1f1883 100644 --- a/commonheaders.h +++ b/commonheaders.h @@ -49,6 +49,10 @@ using std::fstream; #include #include #include +#include +#include +#include "m_extraicons.h" +#include "m_metacontacts.h" #include "resource.h" #include "constants.h" diff --git a/icons.cpp b/icons.cpp new file mode 100644 index 0000000..94603b8 --- /dev/null +++ b/icons.cpp @@ -0,0 +1,85 @@ +// Copyright © 2010 SecureIM developers (baloo and others), sss +// +// 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" + + +// обновляет иконки в clist и в messagew +void ShowStatusIcon(HANDLE hContact,bool enabled) { + + extern HANDLE g_hCLIcon; + extern IconExtraColumn g_IEC; + HANDLE getMetaContact(HANDLE hContact); + HANDLE hMC = getMetaContact(hContact); + HICON icon = NULL; //need to get icon here + if(g_hCLIcon) + { // обновить иконки в clist +// IconExtraColumn iec=g_IEC.hImage = (HANDLE) CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)icon, (LPARAM)0);; +// if(g_hCLIcon) + { +// ExtraIcon_SetIcon(g_hCLIcon, hContact, iec.hImage); +// if(hMC) +// ExtraIcon_SetIcon(g_hCLIcon, hMC, iec.hImage); + } + } + if(ServiceExists(MS_MSG_MODIFYICON)) + { // обновить иконки в srmm +// StatusIconData sid; +// memset(&sid,0,sizeof(sid)); +// sid.cbSize = sizeof(sid); +// sid.szModule = (char*)szGPGModuleName; +// sid.flags |= MBF_HIDDEN; // отключаем все ненужные иконки +// CallService(MS_MSG_MODIFYICON, (WPARAM)hContact, (LPARAM)&sid); +// if( hMC ) +// CallService(MS_MSG_MODIFYICON, (WPARAM)hMC, (LPARAM)&sid); + } +} + + +void ShowStatusIcon(HANDLE hContact) +{ + ShowStatusIcon(hContact,isContactSecured(hContact)); +} + +void ShowStatusIconNotify(HANDLE hContact) { + bool enabled = isContactSecured(hContact); +// NotifyEventHooks(g_hEvent[(mode&SECURED)!=0], (WPARAM)hContact, 0); + ShowStatusIcon(hContact,enabled); +} + + +void RefreshContactListIcons(void) +{ + HANDLE hContact; + extern HANDLE g_hCLIcon; +// CallService(MS_CLUI_LISTBEGINREBUILD,0,0); + if( !g_hCLIcon ) + { + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + while (hContact) + { // сначала все выключаем + ShowStatusIcon(hContact,0); + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); + } + } + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + while (hContact) + { // и снова зажигаем иконку + ShowStatusIcon(hContact); + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); + } +// CallService(MS_CLUI_LISTENDREBUILD,0,0); +} diff --git a/icons/secured.ico b/icons/secured.ico new file mode 100644 index 0000000..8b42e2c Binary files /dev/null and b/icons/secured.ico differ diff --git a/icons/unsecured.ico b/icons/unsecured.ico new file mode 100644 index 0000000..53209bc Binary files /dev/null and b/icons/unsecured.ico differ diff --git a/init.cpp b/init.cpp index 7523ef4..3fcd33c 100644 --- a/init.cpp +++ b/init.cpp @@ -17,15 +17,15 @@ #include "commonheaders.h" //global variables -bool bAppendTags = false, bDebugLog = false, bJabberAPI = false; +bool bAppendTags = false, bDebugLog = false, bJabberAPI = false, bIsMiranda09 = false, bMetaContacts = false; TCHAR *inopentag = NULL, *inclosetag = NULL, *outopentag = NULL, *outclosetag = NULL, *password = NULL; -bool bIsMiranda09 = false; list Accounts; HINSTANCE hInst; -HANDLE hLoadPubKey = NULL, hToggleEncryption = NULL, hOnPreBuildContactMenu = NULL, hSendKey = NULL; +HANDLE hLoadPubKey = NULL, hToggleEncryption = NULL, hOnPreBuildContactMenu = NULL, hSendKey = NULL, g_hCLIcon = NULL; PLUGINLINK *pluginLink; +IconExtraColumn g_IEC = {0}; static int OnModulesLoaded(WPARAM wParam,LPARAM lParam); extern char *date(); MM_INTERFACE mmi = {0}; @@ -149,8 +149,12 @@ static int OnModulesLoaded(WPARAM wParam,LPARAM lParam) int RecvMsgSvc(WPARAM w, LPARAM l); int SendMsgSvc(WPARAM w, LPARAM l); int HookSendMsg(WPARAM w, LPARAM l); - int TestHook(WPARAM w, LPARAM l); +// int TestHook(WPARAM w, LPARAM l); int GetJabberInterface(WPARAM w, LPARAM l); + int onWindowEvent(WPARAM wParam, LPARAM lParam); + int onIconPressed(WPARAM wParam, LPARAM lParam); + int onExtraImageListRebuilding(WPARAM, LPARAM); + int onExtraImageApplying(WPARAM wParam, LPARAM); void InitCheck(); @@ -159,6 +163,7 @@ static int OnModulesLoaded(WPARAM wParam,LPARAM lParam) InitCheck(); bIsMiranda09 = (DWORD)CallService(MS_SYSTEM_GETVERSION, 0, 0) >= 0x00090100?true:false; + bMetaContacts = ServiceExists(MS_MC_GETMETACONTACT); if(bJabberAPI && bIsMiranda09) GetJabberInterface(0,0); @@ -167,8 +172,16 @@ static int OnModulesLoaded(WPARAM wParam,LPARAM lParam) HookEvent(ME_DB_EVENT_FILTER_ADD, HookSendMsg); if(bJabberAPI && bIsMiranda09) HookEvent(ME_PROTO_ACCLISTCHANGED, GetJabberInterface); -// HookEvent(ME_NETLIB_FASTSEND, TestHook); - hOnPreBuildContactMenu = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, OnPreBuildContactMenu); + + HookEvent(ME_CLIST_PREBUILDCONTACTMENU, OnPreBuildContactMenu); + + HookEvent(ME_MSG_WINDOWEVENT, onWindowEvent); + HookEvent(ME_MSG_ICONPRESSED, onIconPressed); + + if(ServiceExists(MS_EXTRAICON_REGISTER)) + g_hCLIcon = ExtraIcon_Register(szGPGModuleName, Translate("SecureIM status"), "sim_cm_est", (MIRANDAHOOK)onExtraImageListRebuilding, (MIRANDAHOOK)onExtraImageApplying); + + PROTOCOLDESCRIPTOR pd = {0}; pd.cbSize=sizeof(PROTOCOLDESCRIPTOR); diff --git a/m_extraicons.h b/m_extraicons.h new file mode 100644 index 0000000..54270fe --- /dev/null +++ b/m_extraicons.h @@ -0,0 +1,158 @@ +/* + Copyright (C) 2009 Ricardo Pescuma Domenecci + + This is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this file; see the file license.txt. If + not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + */ + +#ifndef __M_EXTRAICONS_H__ +#define __M_EXTRAICONS_H__ + +#define MIID_EXTRAICONSSERVICE { 0x62d80749, 0xf169, 0x4592, { 0xb4, 0x4d, 0x3d, 0xd6, 0xde, 0x9d, 0x50, 0xc5 } } + + +#define EXTRAICON_TYPE_CALLBACK 0 // Similar to old clist callbacks, it fires 2 notifications +#define EXTRAICON_TYPE_ICOLIB 1 // This extra icon will use only icons registered with icolib. No callbacks + // needed. Just call MS_EXTRAICON_SET_ICON passing the name of the extraicon to set one. + + +typedef struct { + int cbSize; + int type; // One of EXTRAICON_TYPE_* + const char *name; // Internal name. More than one plugin can register extra icons with the same name + // if both have the same type. In this case, both will be handled as one. + // This is usefull for ex for extra status, where icq and jabber can share the same slot. + // If the types are different the second one will be denied. + const char *description; // [Translated by plugin] Description to be used in GUI + const char *descIcon; // [Optional] Name of an icon registered with icolib to be used in GUI. + + // If type == EXTRAICON_TYPE_CALLBACK this two must be set + + // Callback to add icons to clist, calling MS_CLIST_EXTRA_ADD_ICON + // wParam=lParam=0 + MIRANDAHOOK RebuildIcons; + + // Callback to set the icon to clist, calling MS_CLIST_EXTRA_SET_ICON or MS_EXTRAICON_SET_ICON + // wParam = HANDLE hContact + // lParam = int slot + MIRANDAHOOK ApplyIcon; + + // Other optional callbacks + + // [Optional] Callback called when extra icon was clicked + // wParam = HANDLE hContact + // lParam = int slot + // param = onClickParam + MIRANDAHOOKPARAM OnClick; + + LPARAM onClickParam; + +} EXTRAICON_INFO; + + +// Register an extra icon +// wParam = (EXTRAICON_INFO *) Extra icon info +// lParam = 0 +// Return: (HANDLE) id of extra icon on success, 0 on error +#define MS_EXTRAICON_REGISTER "ExtraIcon/Register" + + +typedef struct { + int cbSize; + HANDLE hExtraIcon; // Value returned by MS_EXTRAICON_REGISTER + HANDLE hContact; // Contact to set the extra icon + union { // The icon to be set. This depends on the type of the extra icon: + HANDLE hImage; // Value returned by MS_CLIST_EXTRA_ADD_ICON (if EXTRAICON_TYPE_CALLBACK) + const char *icoName; // Name of the icon registered with icolib (if EXTRAICON_TYPE_ICOLIB) + }; +} EXTRAICON; + +// Set an extra icon icon +// wParam = (EXTRAICON *) Extra icon +// Return: 0 on success +#define MS_EXTRAICON_SET_ICON "ExtraIcon/SetIcon" + + + +#ifndef _NO_WRAPPERS +#ifdef __cplusplus + +static HANDLE ExtraIcon_Register(const char *name, const char *description, const char *descIcon, + MIRANDAHOOK RebuildIcons, + MIRANDAHOOK ApplyIcon, + MIRANDAHOOKPARAM OnClick = NULL, LPARAM onClickParam = NULL) +{ + if (!ServiceExists(MS_EXTRAICON_REGISTER)) + return NULL; + + EXTRAICON_INFO ei = {0}; + ei.cbSize = sizeof(ei); + ei.type = EXTRAICON_TYPE_CALLBACK; + ei.name = name; + ei.description = description; + ei.descIcon = descIcon; + ei.RebuildIcons = RebuildIcons; + ei.ApplyIcon = ApplyIcon; + ei.OnClick = OnClick; + ei.onClickParam = onClickParam; + + return (HANDLE) CallService(MS_EXTRAICON_REGISTER, (WPARAM) &ei, 0); +} + +static HANDLE ExtraIcon_Register(const char *name, const char *description, const char *descIcon = NULL, + MIRANDAHOOKPARAM OnClick = NULL, LPARAM onClickParam = NULL) +{ + if (!ServiceExists(MS_EXTRAICON_REGISTER)) + return NULL; + + EXTRAICON_INFO ei = {0}; + ei.cbSize = sizeof(ei); + ei.type = EXTRAICON_TYPE_ICOLIB; + ei.name = name; + ei.description = description; + ei.descIcon = descIcon; + ei.OnClick = OnClick; + ei.onClickParam = onClickParam; + + return (HANDLE) CallService(MS_EXTRAICON_REGISTER, (WPARAM) &ei, 0); +} + +static int ExtraIcon_SetIcon(HANDLE hExtraIcon, HANDLE hContact, HANDLE hImage) +{ + EXTRAICON ei = {0}; + ei.cbSize = sizeof(ei); + ei.hExtraIcon = hExtraIcon; + ei.hContact = hContact; + ei.hImage = hImage; + + return CallService(MS_EXTRAICON_SET_ICON, (WPARAM) &ei, 0); +} + +static int ExtraIcon_SetIcon(HANDLE hExtraIcon, HANDLE hContact, const char *icoName) +{ + EXTRAICON ei = {0}; + ei.cbSize = sizeof(ei); + ei.hExtraIcon = hExtraIcon; + ei.hContact = hContact; + ei.icoName = icoName; + + return CallService(MS_EXTRAICON_SET_ICON, (WPARAM) &ei, 0); +} + +#endif +#endif + + +#endif // __M_EXTRAICONS_H__ diff --git a/m_metacontacts.h b/m_metacontacts.h new file mode 100644 index 0000000..9f348bd --- /dev/null +++ b/m_metacontacts.h @@ -0,0 +1,166 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright © 2004 Universite Louis PASTEUR, STRASBOURG. +Copyright © 2004 Scott Ellis (www.scottellis.com.au mail@scottellis.com.au) + +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_METACONTACTS_H__ +#define M_METACONTACTS_H__ 1 + +#ifndef MIID_METACONTACTS +#define MIID_METACONTACTS {0xc0325019, 0xc1a7, 0x40f5, { 0x83, 0x65, 0x4f, 0x46, 0xbe, 0x21, 0x86, 0x3e}} +#endif + +//get the handle for a contact's parent metacontact +//wParam=(HANDLE)hSubContact +//lParam=0 +//returns a handle to the parent metacontact, or null if this contact is not a subcontact +#define MS_MC_GETMETACONTACT "MetaContacts/GetMeta" + +//gets the handle for the default contact +//wParam=(HANDLE)hMetaContact +//lParam=0 +//returns a handle to the default contact, or null on failure +#define MS_MC_GETDEFAULTCONTACT "MetaContacts/GetDefault" + +//gets the contact number for the default contact +//wParam=(HANDLE)hMetaContact +//lParam=0 +//returns a DWORD contact number, or -1 on failure +#define MS_MC_GETDEFAULTCONTACTNUM "MetaContacts/GetDefaultNum" + +//gets the handle for the 'most online' contact +//wParam=(HANDLE)hMetaContact +//lParam=0 +//returns a handle to the 'most online' contact +#define MS_MC_GETMOSTONLINECONTACT "MetaContacts/GetMostOnline" + +//gets the number of subcontacts for a metacontact +//wParam=(HANDLE)hMetaContact +//lParam=0 +//returns a DWORD representing the number of subcontacts for the given metacontact +#define MS_MC_GETNUMCONTACTS "MetaContacts/GetNumContacts" + +//gets the handle of a subcontact, using the subcontact's number +//wParam=(HANDLE)hMetaContact +//lParam=(DWORD)contact number +//returns a handle to the specified subcontact +#define MS_MC_GETSUBCONTACT "MetaContacts/GetSubContact" + +//sets the default contact, using the subcontact's contact number +//wParam=(HANDLE)hMetaContact +//lParam=(DWORD)contact number +//returns 0 on success +#define MS_MC_SETDEFAULTCONTACTNUM "MetaContacts/SetDefault" + +//sets the default contact, using the subcontact's handle +//wParam=(HANDLE)hMetaContact +//lParam=(HANDLE)hSubcontact +//returns 0 on success +#define MS_MC_SETDEFAULTCONTACT "MetaContacts/SetDefaultByHandle" + +//forces the metacontact to send using a specific subcontact, using the subcontact's contact number +//wParam=(HANDLE)hMetaContact +//lParam=(DWORD)contact number +//returns 0 on success +#define MS_MC_FORCESENDCONTACTNUM "MetaContacts/ForceSendContact" + +//forces the metacontact to send using a specific subcontact, using the subcontact's handle +//wParam=(HANDLE)hMetaContact +//lParam=(HANDLE)hSubcontact +//returns 0 on success (will fail if 'force default' is in effect) +#define MS_MC_FORCESENDCONTACT "MetaContacts/ForceSendContactByHandle" + +//'unforces' the metacontact to send using a specific subcontact +//wParam=(HANDLE)hMetaContact +//lParam=0 +//returns 0 on success (will fail if 'force default' is in effect) +#define MS_MC_UNFORCESENDCONTACT "MetaContacts/UnforceSendContact" + +//'forces' or 'unforces' (i.e. toggles) the metacontact to send using it's default contact +// overrides (and clears) 'force send' above, and will even force use of offline contacts +// will send ME_MC_FORCESEND or ME_MC_UNFORCESEND event +//wParam=(HANDLE)hMetaContact +//lParam=0 +//returns 1(true) or 0(false) representing new state of 'force default' +#define MS_MC_FORCEDEFAULT "MetaContacts/ForceSendDefault" + +// method to get state of 'force' for a metacontact +// wParam=(HANDLE)hMetaContact +// lParam= (DWORD)&contact_number or NULL +// +// if lparam supplied, the contact_number of the contatct 'in force' will be copied to the address it points to, +// or if none is in force, the value (DWORD)-1 will be copied +// (v0.8.0.8+ returns 1 if 'force default' is true with *lParam == default contact number, else returns 0 with *lParam as above) +#define MS_MC_GETFORCESTATE "MetaContacts/GetForceState" + +// fired when a metacontact's default contact changes (fired upon creation of metacontact also, when default is initially set) +// wParam=(HANDLE)hMetaContact +// lParam=(HANDLE)hDefaultContact +#define ME_MC_DEFAULTTCHANGED "MetaContacts/DefaultChanged" + +// fired when a metacontact's subcontacts change (fired upon creation of metacontact, when contacts are added or removed, and when +// contacts are reordered) - a signal to re-read metacontact data +// wParam=(HANDLE)hMetaContact +// lParam=0 +#define ME_MC_SUBCONTACTSCHANGED "MetaContacts/SubcontactsChanged" + +// fired when a metacontact is forced to send using a specific subcontact +// wParam=(HANDLE)hMetaContact +// lParam=(HANDLE)hForceContact +#define ME_MC_FORCESEND "MetaContacts/ForceSend" + +// fired when a metacontact is 'unforced' to send using a specific subcontact +// wParam=(HANDLE)hMetaContact +// lParam=0 +#define ME_MC_UNFORCESEND "MetaContacts/UnforceSend" + +// method to get protocol name - used to be sure you're dealing with a "real" metacontacts plugin :) +// wParam=lParam=0 +#define MS_MC_GETPROTOCOLNAME "MetaContacts/GetProtoName" + + +// added 0.9.5.0 (22/3/05) +// wParam=(HANDLE)hContact +// lParam=0 +// convert a given contact into a metacontact +#define MS_MC_CONVERTTOMETA "MetaContacts/ConvertToMetacontact" + +// added 0.9.5.0 (22/3/05) +// wParam=(HANDLE)hContact +// lParam=(HANDLE)hMeta +// add an existing contact to a metacontact +#define MS_MC_ADDTOMETA "MetaContacts/AddToMetacontact" + +// added 0.9.5.0 (22/3/05) +// wParam=0 +// lParam=(HANDLE)hContact +// remove a contact from a metacontact +#define MS_MC_REMOVEFROMMETA "MetaContacts/RemoveFromMetacontact" + + +// added 0.9.13.2 (6/10/05) +// wParam=(BOOL)disable +// lParam=0 +// enable/disable the 'hidden group hack' - for clists that support subcontact hiding using 'IsSubcontact' setting +// should be called once in the clist 'onmodulesloaded' event handler (which, since it's loaded after the db, will be called +// before the metacontact onmodulesloaded handler where the subcontact hiding is usually done) +#define MS_MC_DISABLEHIDDENGROUP "MetaContacts/DisableHiddenGroup" + +#endif diff --git a/metacontacts.cpp b/metacontacts.cpp new file mode 100644 index 0000000..4540419 --- /dev/null +++ b/metacontacts.cpp @@ -0,0 +1,61 @@ +// Copyright © 2010 SecureIM developers (baloo and others), sss +// +// 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" + +extern bool bMetaContacts; + +BOOL isProtoMetaContacts(HANDLE hContact) { + if(bMetaContacts) { + LPSTR proto = (LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + if( proto && strcmp(proto,"MetaContacts")==0 ) { + return true; + } + } +// for(int j=0;jinspecting) +// return strstr(clist[j].proto->name,"MetaContacts")!=NULL; + return false; +} + + +BOOL isDefaultSubContact(HANDLE hContact) { + + if(bMetaContacts) { + return (HANDLE)CallService(MS_MC_GETDEFAULTCONTACT,(WPARAM)CallService(MS_MC_GETMETACONTACT,(WPARAM)hContact,0),0)==hContact; + } + return false; +} + + +HANDLE getMetaContact(HANDLE hContact) { + + if(bMetaContacts) { + return (HANDLE)CallService(MS_MC_GETMETACONTACT,(WPARAM)hContact,0); + } + return 0; +} + + +HANDLE getMostOnline(HANDLE hContact) { + + if(bMetaContacts) { + return (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT,(WPARAM)hContact,0); + } + return 0; +} + + diff --git a/new_gpg.vcproj b/new_gpg.vcproj index 7558805..f4c9fa1 100644 --- a/new_gpg.vcproj +++ b/new_gpg.vcproj @@ -615,10 +615,18 @@ Name="Source Files" Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" > + + + + @@ -652,10 +660,18 @@ RelativePath=".\messages.cpp" > + + + + @@ -706,6 +722,14 @@ RelativePath=".\new_gpg.rc" > + + + + diff --git a/srmm.cpp b/srmm.cpp new file mode 100644 index 0000000..ee603cc --- /dev/null +++ b/srmm.cpp @@ -0,0 +1,45 @@ +// Copyright © 2010 SecureIM developers (baloo and others), sss +// +// 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" + +void ShowStatusIcon(HANDLE hContact); +BOOL isProtoMetaContacts(HANDLE hContact); +HANDLE getMostOnline(HANDLE hContact); + +int __cdecl onWindowEvent(WPARAM wParam, LPARAM lParam) { + + MessageWindowEventData *mwd = (MessageWindowEventData *)lParam; + if(mwd->uType == MSG_WINDOW_EVT_OPEN || mwd->uType == MSG_WINDOW_EVT_OPENING) { + ShowStatusIcon(mwd->hContact); + } + return 0; +} + + +int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam) { + HANDLE hContact = (HANDLE)wParam; + if( isProtoMetaContacts(hContact) ) + hContact = getMostOnline(hContact); // возьмем тот, через который пойдет сообщение + + StatusIconClickData *sicd = (StatusIconClickData *)lParam; + if(strcmp(sicd->szModule, szGPGModuleName) != 0) + return 0; // not our event + + return 0; +} diff --git a/utilities.cpp b/utilities.cpp index d64e8ad..de7c3ff 100644 --- a/utilities.cpp +++ b/utilities.cpp @@ -483,3 +483,10 @@ void AddHandlers() } } } + +bool isContactSecured(HANDLE hContact) +{ + if(DBGetContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0)) + return true; + return false; +} diff --git a/utilities.h b/utilities.h index 7d70458..b89dc2f 100644 --- a/utilities.h +++ b/utilities.h @@ -28,5 +28,6 @@ void cp866_to_cp1251(string *str); void HistoryLog(HANDLE hContact, char *data, int event_type, int flags); int ComboBoxAddStringUtf(HWND hCombo, const TCHAR *szString, DWORD data); +bool isContactSecured(HANDLE hContact); #endif -- cgit v1.2.3