From cb4a46e7fbe62d788e66ed6121c717a2d22a4d7c Mon Sep 17 00:00:00 2001 From: watcherhd Date: Thu, 21 Apr 2011 14:14:52 +0000 Subject: svn.miranda.im is moving to a new home! git-svn-id: http://miranda-plugins.googlecode.com/svn/trunk@7 e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb --- irc_mod/main.cpp | 248 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 248 insertions(+) create mode 100644 irc_mod/main.cpp (limited to 'irc_mod/main.cpp') diff --git a/irc_mod/main.cpp b/irc_mod/main.cpp new file mode 100644 index 0000000..1f57f01 --- /dev/null +++ b/irc_mod/main.cpp @@ -0,0 +1,248 @@ +/* +IRC plugin for Miranda IM + +Copyright (C) 2003 Jörgen Persson + +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 "irc.h" + +CIrcSession g_ircSession=NULL; // Representation of the IRC-connection +CMyMonitor *monitor; // Object that processes data from the IRC server +MM_INTERFACE mmi = {0}; // structure which keeps pointers to mirandas alloc, free and realloc +char * IRCPROTONAME = NULL; +char * ALTIRCPROTONAME = NULL; +char * pszServerFile = NULL; +char * pszPerformFile = NULL; +char * pszIgnoreFile = NULL; +char mirandapath[MAX_PATH]; +DWORD mirVersion = NULL; +CRITICAL_SECTION cs; +CRITICAL_SECTION m_gchook; +PLUGINLINK * pluginLink; +HINSTANCE g_hInstance = NULL; +PREFERENCES * prefs; + +//static HMODULE m_libeay32; +HMODULE m_ssleay32 = NULL; + +// NUDGE +HANDLE hIRCNudge = NULL; + +// Unicode +BYTE gbUnicodeAPI; +BYTE gbUnicodeCore; +BYTE gbUtfLangpack; + +PLUGININFO pluginInfo= +{ // Information about the plugin + sizeof( PLUGININFO ), + #ifdef _UNICODE + "IRC Protocol (Unicode)", + #else + "IRC Protocol", + #endif + PLUGIN_MAKE_VERSION( 0,7,0,11 ), + "IRC protocol for Miranda IM. (Nudge, Typing Notify, xStatus, Avatars)", + "MatriX, Angeli-Ka, prog, IRoN, etc", + "wortex@users.sourceforge.net", + "© 2003 - 2005 Jörgen Persson, © 2006 Miranda IM Community", + "http://dev.mirandaim.ru/iron/", + 0, + 0 +}; + +extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) +{ + g_hInstance=hinstDLL; + + return TRUE; +} + +extern "C" __declspec(dllexport) PLUGININFO* MirandaPluginInfo(DWORD mirandaVersion) +{ + mirVersion = mirandaVersion; + return &pluginInfo; +} + +static void GetModuleName( void ) // ripped from msn +{ + char * p = NULL; + char * p1 = NULL; + + GetModuleFileName(g_hInstance, mirandapath, MAX_PATH); + p = strrchr( mirandapath, '\\' ); + if(p) + { + char * p2; + *p = '\0'; + p++; + p1 = strrchr( p, '.' ); + *p1 = '\0'; + p2 = p; + while( *p2 ) + { + if(*p2 == ' ') + *p2 = '_'; + p2++; + } + IRCPROTONAME = strdup( p ); + ALTIRCPROTONAME = new char[lstrlen( IRCPROTONAME ) + 7 ]; + CharUpper(IRCPROTONAME); + + if (lstrcmpi(IRCPROTONAME, "IRC")) + mir_snprintf(ALTIRCPROTONAME, lstrlen( IRCPROTONAME ) + 7 , "IRC (%s)", IRCPROTONAME); + else + mir_snprintf(ALTIRCPROTONAME, lstrlen( IRCPROTONAME ) + 7 , "%s", IRCPROTONAME); + } +} + +static void RegisterProtocol( void ) +{ + PROTOCOLDESCRIPTOR pd; + ZeroMemory( &pd, sizeof( pd ) ); + pd.cbSize = sizeof( pd ); + pd.szName = IRCPROTONAME; + pd.type = PROTOTYPE_PROTOCOL; + CallService( MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd ); +} + +extern "C" int __declspec(dllexport) Load( PLUGINLINK *link ) +{ + #ifndef NDEBUG //mem leak detector :-) Thanks Tornado! + int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); // Get current flag + flag |= _CRTDBG_LEAK_CHECK_DF; // Turn on leak-checking bit + _CrtSetDbgFlag(flag); // Set flag to the new value + #endif + + pluginLink=link; + + // Are we running under Unicode Windows version ? + gbUnicodeAPI = (GetVersion() & 0x80000000) == 0; + #ifdef _DEBUG + DBGprintf("UnicodeAPI = %d\n", gbUnicodeAPI); + #endif + + // Do we have new LangPack module ready ? + gbUtfLangpack = ServiceExists(MS_LANGPACK_GETCODEPAGE); + { // Are we running under unicode Miranda core ? + char szVer[MAX_PATH]; + CallService(MS_SYSTEM_GETVERSIONTEXT, MAX_PATH, (LPARAM)szVer); + gbUnicodeCore = (strstr(szVer, "Unicode") != NULL); + } + #ifdef _DEBUG + DBGprintf("UnicodeCore = %d\n", gbUnicodeCore); + #endif + + // Initialize charset conversion routines + InitI18N(); + + // Initialize core modules + InitDB(); // DB interface + + if( !mirVersion || mirVersion dwVersion) + { + if(dwVersion < PLUGIN_MAKE_VERSION(0,6,1,0)) + { + DBDeleteContactSetting(NULL, IRCPROTONAME, "OnlineNotificationTime"); + DBDeleteContactSetting(NULL, IRCPROTONAME, "AutoOnlineNotifTempAlso"); + + } + if(dwVersion < PLUGIN_MAKE_VERSION(0,6,3,7)) + { + DBVARIANT dbv; + char pw[600] = {0}; + if(!DBGetContactSetting(NULL, IRCPROTONAME, "Password", &dbv) && dbv.type==DBVT_ASCIIZ) + { + lstrcpyn(pw, dbv.pszVal, 599); + DBFreeVariant(&dbv); + } + if(lstrlenA(pw) > 0) + { + CallService(MS_DB_CRYPT_ENCODESTRING, 499, (LPARAM)pw); + DBWriteContactSettingString(NULL, IRCPROTONAME, "Password", pw); + MessageBoxA(NULL, Translate("To increase security the saved password for your\n default network is now encrypted."), IRCPROTONAME, MB_OK|MB_ICONINFORMATION); + } + } + } + DBWriteContactSettingDword(NULL, IRCPROTONAME, "OldVersion", pluginInfo.version); + return; +} \ No newline at end of file -- cgit v1.2.3