diff options
author | Gluzskiy Alexandr <sss123next@list.ru> | 2010-09-28 18:15:02 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss123next@list.ru> | 2010-09-28 18:15:02 +0300 |
commit | 353c79463614e291eb37e629e8b0d1cb9c58d8e8 (patch) | |
tree | c4a3a921bf8f0411933485d8c7fde446b1b8d305 | |
parent | 4f8f8d3b1691decd02ba93ca7799c46cff1c4f9b (diff) |
code cleanup
-rw-r--r-- | commonheaders.h | 16 | ||||
-rw-r--r-- | globals.h | 2 | ||||
-rw-r--r-- | init.cpp | 16 | ||||
-rw-r--r-- | messages.cpp | 59 | ||||
-rw-r--r-- | utilities.cpp | 52 | ||||
-rw-r--r-- | utilities.h | 12 |
6 files changed, 1 insertions, 156 deletions
diff --git a/commonheaders.h b/commonheaders.h index b164be0..b2a647c 100644 --- a/commonheaders.h +++ b/commonheaders.h @@ -26,18 +26,9 @@ #include <shlwapi.h> #include <iostream> -#include <map> -using std::map; -#include <list> -using std::list; -#include <vector> -using std::vector; #include <string> using std::string; using std::wstring; -#include <fstream> -using std::wfstream; -using std::fstream; #include <algorithm> @@ -45,17 +36,10 @@ using std::fstream; #include <m_database.h> #include <m_options.h> #include <m_langpack.h> -#include <m_clist.h> -#include <m_clui.h> -#include <m_icolib.h> -#include <m_skin.h> #include <m_protomod.h> #include <m_protosvc.h> #include <m_netlib.h> -#include <m_jabber.h> #include <m_message.h> -#include <m_cluiframes.h> -#include <m_icolib.h> #include "m_metacontacts.h" #include "resource.h" @@ -16,6 +16,4 @@ #ifndef GLOBALS_H #define GLOBALS_H -extern bool bAppendTags; -extern TCHAR *inopentag, *inclosetag, *outopentag, *outclosetag; #endif @@ -17,8 +17,7 @@ #include "commonheaders.h" //global variables -bool bAppendTags = false, bDebugLog = false, bJabberAPI = false, bIsMiranda09 = false, bMetaContacts = false, bFileTransfers = false; -TCHAR *inopentag = NULL, *inclosetag = NULL, *outopentag = NULL, *outclosetag = NULL, *password = NULL; +bool bMetaContacts = false; HINSTANCE hInst; PLUGINLINK *pluginLink; @@ -93,15 +92,12 @@ int AddContact(WPARAM w, LPARAM l) 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 ReplacerOptInit(WPARAM wParam,LPARAM lParam); bMetaContacts = ServiceExists(MS_MC_GETMETACONTACT); HookEvent(ME_OPT_INITIALISE, ReplacerOptInit); - HookEvent(ME_DB_EVENT_FILTER_ADD, HookSendMsg); PROTOCOLDESCRIPTOR pd = {0}; pd.cbSize=sizeof(PROTOCOLDESCRIPTOR); @@ -109,9 +105,7 @@ static int OnModulesLoaded(WPARAM wParam,LPARAM lParam) pd.type=PROTOTYPE_ENCRYPTION; CallService(MS_PROTO_REGISTERMODULE,0,(LPARAM)&pd); - CreateProtoServiceFunction(szReplacerModuleName,PSR_MESSAGE,RecvMsgSvc); CreateProtoServiceFunction(szReplacerModuleName,PSS_MESSAGE,SendMsgSvc); - CreateProtoServiceFunction(szReplacerModuleName,PSR_MESSAGE"W",RecvMsgSvc); CreateProtoServiceFunction(szReplacerModuleName,PSS_MESSAGE"W",SendMsgSvc); for (HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); hContact; hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0)) @@ -128,13 +122,5 @@ static int OnModulesLoaded(WPARAM wParam,LPARAM lParam) extern "C" int __declspec(dllexport) Unload(void) { - for (HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); hContact; hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0)) - DBDeleteContactSetting(hContact, szReplacerModuleName, "KeyID_Prescense"); - mir_free(inopentag); - mir_free(inclosetag); - mir_free(outopentag); - mir_free(outclosetag); - if(password) - delete [] password; return 0; } diff --git a/messages.cpp b/messages.cpp index 369354c..283f4be 100644 --- a/messages.cpp +++ b/messages.cpp @@ -17,32 +17,6 @@ #include "commonheaders.h" -wstring new_key; -HANDLE new_key_hcnt = NULL; -HANDLE new_key_hcnt_mutex = NULL; -bool _terminate = false; - -BOOL isProtoMetaContacts(HANDLE hContact); - -int RecvMsgSvc(WPARAM w, LPARAM l) -{ - CCSDATA *ccs = (CCSDATA*)l; - if (!ccs) - return CallService(MS_PROTO_CHAINRECV, w, l); - PROTORECVEVENT *pre = (PROTORECVEVENT*)(ccs->lParam); - if (!pre) - return CallService(MS_PROTO_CHAINRECV, w, l); - char *msg = pre->szMessage; - if (!msg) - return CallService(MS_PROTO_CHAINRECV, w, l); - HANDLE hContact = ccs->hContact; - if(isProtoMetaContacts(hContact)) - hContact = metaGetMostOnline(hContact); - - - return CallService(MS_PROTO_CHAINRECV, w, l); -} - char *send_msg = NULL; int SendMsgSvc(WPARAM w, LPARAM l) @@ -132,39 +106,6 @@ int SendMsgSvc(WPARAM w, LPARAM l) return CallService(MS_PROTO_CHAINSEND, w, l); } -int HookSendMsg(WPARAM w, LPARAM l) -{ - HANDLE hContact = (HANDLE)w; - if(isProtoMetaContacts(hContact)) - hContact = metaGetMostOnline(hContact); - if(!DBGetContactSettingByte(hContact, szReplacerModuleName, "GPGEncryption", 0)) - return 0; - - if(bAppendTags) - { - if(!l) - return 0; - BYTE Msgs = DBGetContactSettingByte(hContact, szReplacerModuleName, "MsgsForTagging", 0); - if(!Msgs) - return 0; - DBEVENTINFO * dbei = (DBEVENTINFO*)l; - if((dbei->eventType == EVENTTYPE_MESSAGE) && (dbei->flags & DBEF_SENT)) - { - char *msg = (char*)dbei->pBlob; - TCHAR *tmp = mir_utf8decodeW(msg); - wstring str = tmp; - mir_free(tmp); - str.insert(0, outopentag); - str.append(outclosetag); - char *msg2 = mir_utf8encodeW(str.c_str()); - mir_free(dbei->pBlob); - dbei->pBlob = (PBYTE)msg2; - dbei->cbBlob = strlen(msg2)+1; - DBWriteContactSettingByte(hContact, szReplacerModuleName, "MsgsForTagging", Msgs - 1); - } - } - return 0; -} diff --git a/utilities.cpp b/utilities.cpp index 3ab2e28..ebe8751 100644 --- a/utilities.cpp +++ b/utilities.cpp @@ -90,55 +90,3 @@ char *date() d[9]=tmp[5]; return d; } - - -void HistoryLog(HANDLE hContact, char *data, int event_type, int flags) -{ - DBEVENTINFO Event = {0}; - Event.cbSize = sizeof(Event); - Event.szModule = szReplacerModuleName; - Event.eventType = event_type; - Event.flags = flags, DBEF_UTF; - Event.timestamp = (DWORD)time(NULL); - Event.cbBlob = strlen(data)+1; - Event.pBlob = (PBYTE)_strdup(data); - CallService(MS_DB_EVENT_ADD, (WPARAM)(HANDLE)hContact,(LPARAM)&Event); -} - -static int ControlAddStringUtf(HWND ctrl, DWORD msg, const TCHAR *szString) -{ - int item = -1; - item = SendMessage(ctrl, msg, 0, (LPARAM)szString); - return item; -} - -int ComboBoxAddStringUtf(HWND hCombo, const TCHAR *szString, DWORD data) -{ - int item = ControlAddStringUtf(hCombo, CB_ADDSTRING, szString); - SendMessage(hCombo, CB_SETITEMDATA, item, data); - - return item; -} - - - - -#define NEWTSTR_MALLOC(A) (A==NULL)?NULL:strcpy((char*)mir_alloc(sizeof(char)*(strlen(A)+1)),A)
-
-const bool StriStr(const char *str, const char *substr)
-{
- bool i = false;
- char *str_up = NEWTSTR_MALLOC(str);
- char *substr_up = NEWTSTR_MALLOC(substr);
-
- CharUpperBuffA(str_up, strlen(str_up));
- CharUpperBuffA(substr_up, strlen(substr_up));
-
- if(strstr (str_up, substr_up))
- i = true;
-
- mir_free(str_up);
- mir_free(substr_up);
-
- return i;
-}
diff --git a/utilities.h b/utilities.h index b7f0a7d..a480d14 100644 --- a/utilities.h +++ b/utilities.h @@ -18,17 +18,5 @@ #define UTILITIES_H TCHAR* __stdcall UniGetContactSettingUtf(HANDLE hContact, const char *szModule,const char* szSetting, TCHAR* szDef); char* __stdcall UniGetContactSettingUtf(HANDLE hContact, const char *szModule,const char* szSetting, char* szDef); -void HistoryLog(HANDLE hContact, char *data, int event_type, int flags); -int ComboBoxAddStringUtf(HWND hCombo, const TCHAR *szString, DWORD data); -const bool StriStr(const char *str, const char *substr); - -class iwchar_traits : public std::char_traits<wchar_t> {
-public:
- static bool eq(wchar_t, wchar_t);
- static bool lt(wchar_t, wchar_t);
- static int compare(const wchar_t *, const wchar_t *, size_t n);
- static const char * find(const wchar_t *, size_t n, wchar_t);
-};
- #endif |