From 2617e958bd0059dc3c0971b01de9c0059c1e1692 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 29 Apr 2015 21:07:07 +0000 Subject: unified project for IRC protocol git-svn-id: http://svn.miranda-ng.org/main/trunk@13257 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/IRCG/src/clist.cpp | 2 +- protocols/IRCG/src/commandmonitor.cpp | 8 +- protocols/IRCG/src/input.cpp | 4 +- protocols/IRCG/src/irc.h | 640 ---------------------------------- protocols/IRCG/src/irclib.cpp | 2 +- protocols/IRCG/src/ircproto.cpp | 2 +- protocols/IRCG/src/main.cpp | 2 +- protocols/IRCG/src/options.cpp | 2 +- protocols/IRCG/src/output.cpp | 6 +- protocols/IRCG/src/scripting.cpp | 2 +- protocols/IRCG/src/services.cpp | 20 +- protocols/IRCG/src/stdafx.cpp | 18 - protocols/IRCG/src/stdafx.cxx | 18 + protocols/IRCG/src/stdafx.h | 638 +++++++++++++++++++++++++++++++++ protocols/IRCG/src/tools.cpp | 2 +- protocols/IRCG/src/userinfo.cpp | 2 +- protocols/IRCG/src/windows.cpp | 4 +- 17 files changed, 685 insertions(+), 687 deletions(-) delete mode 100644 protocols/IRCG/src/irc.h delete mode 100644 protocols/IRCG/src/stdafx.cpp create mode 100644 protocols/IRCG/src/stdafx.cxx create mode 100644 protocols/IRCG/src/stdafx.h (limited to 'protocols/IRCG/src') diff --git a/protocols/IRCG/src/clist.cpp b/protocols/IRCG/src/clist.cpp index e52c1c50d7..92fa0553df 100644 --- a/protocols/IRCG/src/clist.cpp +++ b/protocols/IRCG/src/clist.cpp @@ -20,7 +20,7 @@ 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" +#include "stdafx.h" BOOL CIrcProto::CList_AddDCCChat(const CMString& name, const CMString& hostmask, unsigned long adr, int port) { diff --git a/protocols/IRCG/src/commandmonitor.cpp b/protocols/IRCG/src/commandmonitor.cpp index eab057eac1..c6dbac79e0 100644 --- a/protocols/IRCG/src/commandmonitor.cpp +++ b/protocols/IRCG/src/commandmonitor.cpp @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // This file holds functions that are called upon receiving // certain commands from the server. -#include "irc.h" +#include "stdafx.h" using namespace irc; @@ -1591,7 +1591,7 @@ bool CIrcProto::OnIrc_BANLIST(const CIrcMessage* pmsg) S += pmsg->parameters[3]; if (pmsg->parameters.getCount() > 4) { S += _T(" - ( "); - time_t time = StrToInt(pmsg->parameters[4].c_str()); + time_t time = _ttoi(pmsg->parameters[4].c_str()); S += _tctime(&time); S.Replace(_T("\n"), _T(" ")); S += _T(")"); @@ -1703,7 +1703,7 @@ bool CIrcProto::OnIrc_WHOIS_END(const CIrcMessage* pmsg) bool CIrcProto::OnIrc_WHOIS_IDLE(const CIrcMessage* pmsg) { if (pmsg->m_bIncoming && m_whoisDlg && pmsg->parameters.getCount() > 2 && m_manualWhoisCount > 0) { - int S = StrToInt(pmsg->parameters[2].c_str()); + int S = _ttoi(pmsg->parameters[2].c_str()); int D = S / (60 * 60 * 24); S -= (D * 60 * 60 * 24); int H = S / (60 * 60); @@ -1880,7 +1880,7 @@ bool CIrcProto::OnIrc_ENDMOTD(const CIrcMessage* pmsg) bool CIrcProto::OnIrc_NOOFCHANNELS(const CIrcMessage* pmsg) { if (pmsg->m_bIncoming && pmsg->parameters.getCount() > 1) - m_noOfChannels = StrToInt(pmsg->parameters[1].c_str()); + m_noOfChannels = _ttoi(pmsg->parameters[1].c_str()); if (pmsg->m_bIncoming && !bPerformDone) DoOnConnect(pmsg); diff --git a/protocols/IRCG/src/input.cpp b/protocols/IRCG/src/input.cpp index 58718df3cc..2d8a84dd97 100644 --- a/protocols/IRCG/src/input.cpp +++ b/protocols/IRCG/src/input.cpp @@ -19,7 +19,7 @@ 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" +#include "stdafx.h" #include "version.h" #define NICKSUBSTITUTE _T("!_nick_!") @@ -417,7 +417,7 @@ BOOL CIrcProto::DoHardcodedCommand(CMString text, TCHAR* window, MCONTACT hConta CallFunctionAsync(sttSetTimerOff, this); } if (!mir_tstrcmpi(one.c_str(), _T("time")) && !two.IsEmpty()) { - m_iTempCheckTime = StrToInt(two.c_str()); + m_iTempCheckTime = _ttoi(two.c_str()); if (m_iTempCheckTime < 10 && m_iTempCheckTime != 0) m_iTempCheckTime = 10; diff --git a/protocols/IRCG/src/irc.h b/protocols/IRCG/src/irc.h deleted file mode 100644 index 25518d16ec..0000000000 --- a/protocols/IRCG/src/irc.h +++ /dev/null @@ -1,640 +0,0 @@ -/* -IRC plugin for Miranda IM - -Copyright (C) 2003-05 Jurgen Persson -Copyright (C) 2007-09 George Hazan - -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 _IRCWIN_H_ -#define _IRCWIN_H_ - -#define _CRT_SECURE_NO_WARNINGS - -#define WIN32_LEAN_AND_MEAN -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "newpluginapi.h" -#include "m_system.h" -#include "m_system_cpp.h" -#include "m_protocols.h" -#include "m_protomod.h" -#include "m_protosvc.h" -#include "m_protoint.h" -#include "m_clist.h" -#include "m_options.h" -#include "m_database.h" -#include "m_utils.h" -#include "m_skin.h" -#include "m_netlib.h" -#include "m_clui.h" -#include "m_langpack.h" -#include "m_message.h" -#include "m_userinfo.h" -#include "m_addcontact.h" -#include "m_button.h" -#include "m_genmenu.h" -#include "m_file.h" -#include "m_ignore.h" -#include "m_chat.h" -#include "m_icolib.h" -#include "m_string.h" -#include "win2k.h" -#include "m_gui.h" - -#include "resource.h" - -#define IRC_QUICKCONNECT "/QuickConnectMenu" -#define IRC_JOINCHANNEL "/JoinChannelMenu" -#define IRC_CHANGENICK "/ChangeNickMenu" -#define IRC_SHOWLIST "/ShowListMenu" -#define IRC_SHOWSERVER "/ShowServerMenu" -#define IRC_UM_CHANSETTINGS "/UMenuChanSettings" -#define IRC_UM_WHOIS "/UMenuWhois" -#define IRC_UM_DISCONNECT "/UMenuDisconnect" -#define IRC_UM_IGNORE "/UMenuIgnore" - -#define STR_QUITMESSAGE _T("\002Miranda NG!\002 Smaller, Faster, Easier. http://miranda-ng.org/") -#define STR_USERINFO _T("I'm a happy Miranda NG user! Get it here: http://miranda-ng.org/") -#define STR_AWAYMESSAGE _T("I'm away from the computer.") // Default away -#define DCCSTRING _T(" (DCC)") -#define SERVERSMODULE "IRC Servers" -#define SERVERWINDOW _T("Network log") - -#define DCC_CHAT 1 -#define DCC_SEND 2 - -#define FILERESUME_CANCEL 11 - -struct CIrcProto; - -// special service for tweaking performance, implemented in chat.dll -#define MS_GC_GETEVENTPTR "GChat/GetNewEventPtr" -typedef int (*GETEVENTFUNC)(WPARAM wParam, LPARAM lParam); -typedef struct { - GETEVENTFUNC pfnAddEvent; -} - GCPTRS; - -#define IP_AUTO 1 -#define IP_MANUAL 2 - -struct IPRESOLVE // Contains info about the channels -{ - IPRESOLVE( const char* _addr, int _type ) : - sAddr( _addr ), - iType( _type ) - {} - - ~IPRESOLVE() - {} - - CMStringA sAddr; - int iType; -}; - -struct CHANNELINFO // Contains info about the channels -{ - TCHAR* pszTopic; - TCHAR* pszMode; - TCHAR* pszPassword; - TCHAR* pszLimit; - BYTE OwnMode; /* own mode on the channel. Bitmask: - 0: voice - 1: halfop - 2: op - 3: admin - 4: owner */ - int codepage; -}; - -struct SERVER_INFO // Contains info about different servers -{ - ~SERVER_INFO(); - - char *m_name, *m_address, *m_group; - int m_portStart, m_portEnd, m_iSSL; -}; - -struct PERFORM_INFO // Contains 'm_perform buffer' for different networks -{ - PERFORM_INFO( const char* szSetting, const TCHAR* value ) : - mSetting( szSetting ), - mText( value ) - {} - - ~PERFORM_INFO() - {} - - CMStringA mSetting; - CMString mText; -}; - -struct CONTACT // Contains info about users -{ - TCHAR* name; - TCHAR* user; - TCHAR* host; - bool ExactOnly; - bool ExactWCOnly; - bool ExactNick; -}; - -struct TDbSetting -{ - int offset; - char* name; - int type; - size_t size; - union - { - int defValue; - TCHAR* defStr; - }; -}; - -#include "irclib.h" -using namespace irc; - -#include "irc_dlg.h" - -///////////////////////////////////////////////////////////////////////////////////////// - -typedef bool (CIrcProto::*PfnIrcMessageHandler)(const CIrcMessage* pmsg); - -struct CIrcHandler -{ - CIrcHandler( const TCHAR* _name, PfnIrcMessageHandler _handler ) : - m_name( _name ), - m_handler( _handler ) - {} - - const TCHAR* m_name; - PfnIrcMessageHandler m_handler; -}; - -struct CIrcProto : public PROTO -{ - CIrcProto(const char*, const TCHAR*); - ~CIrcProto(); - - // Protocol interface - - virtual MCONTACT __cdecl AddToList( int flags, PROTOSEARCHRESULT* psr ); - - virtual int __cdecl Authorize(MEVENT hDbEvent); - virtual int __cdecl AuthDeny(MEVENT hDbEvent, const TCHAR* szReason); - - virtual HANDLE __cdecl FileAllow(MCONTACT hContact, HANDLE hTransfer, const TCHAR *szPath); - virtual int __cdecl FileCancel(MCONTACT hContact, HANDLE hTransfer ); - virtual int __cdecl FileDeny(MCONTACT hContact, HANDLE hTransfer, const TCHAR *szReason); - virtual int __cdecl FileResume( HANDLE hTransfer, int *action, const TCHAR **szFilename); - - virtual DWORD_PTR __cdecl GetCaps( int type, MCONTACT hContact = NULL); - - virtual HANDLE __cdecl SearchBasic(const PROTOCHAR* id); - - virtual HANDLE __cdecl SendFile(MCONTACT hContact, const TCHAR *szDescription, TCHAR **ppszFiles); - virtual int __cdecl SendMsg(MCONTACT hContact, int flags, const char* msg); - - virtual int __cdecl SetStatus(int iNewStatus); - - virtual HANDLE __cdecl GetAwayMsg(MCONTACT hContact); - virtual int __cdecl SetAwayMsg(int m_iStatus, const TCHAR *msg); - - virtual int __cdecl OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam); - - // Services - INT_PTR __cdecl SvcCreateAccMgrUI(WPARAM, LPARAM); - INT_PTR __cdecl GetMyAwayMsg(WPARAM, LPARAM); - - INT_PTR __cdecl OnChangeNickMenuCommand(WPARAM, LPARAM); - INT_PTR __cdecl OnDoubleclicked(WPARAM, LPARAM); - INT_PTR __cdecl OnJoinChat(WPARAM, LPARAM); - INT_PTR __cdecl OnJoinMenuCommand(WPARAM, LPARAM); - INT_PTR __cdecl OnLeaveChat(WPARAM, LPARAM); - INT_PTR __cdecl OnMenuChanSettings(WPARAM, LPARAM); - INT_PTR __cdecl OnMenuDisconnect( WPARAM , LPARAM ); - INT_PTR __cdecl OnMenuIgnore(WPARAM, LPARAM); - INT_PTR __cdecl OnMenuWhois(WPARAM, LPARAM); - INT_PTR __cdecl OnQuickConnectMenuCommand(WPARAM, LPARAM ); - INT_PTR __cdecl OnShowListMenuCommand(WPARAM, LPARAM); - INT_PTR __cdecl OnShowServerMenuCommand(WPARAM, LPARAM); - - // Events - int __cdecl OnContactDeleted(WPARAM, LPARAM); - int __cdecl OnInitOptionsPages(WPARAM, LPARAM); - int __cdecl OnInitUserInfo(WPARAM, LPARAM); - int __cdecl OnModulesLoaded(WPARAM, LPARAM); - int __cdecl OnMenuPreBuild(WPARAM, LPARAM); - int __cdecl OnPreShutdown(WPARAM, LPARAM); - int __cdecl OnDbSettingChanged(WPARAM, LPARAM); - - int __cdecl GCEventHook(WPARAM, LPARAM); - int __cdecl GCMenuHook(WPARAM, LPARAM); - - // Data - - char m_serverName[100]; - char m_password [500]; - TCHAR m_identSystem[10]; - char m_network[30]; - char m_portStart[10]; - char m_portEnd[10]; - int m_iSSL; - TCHAR m_identPort[10]; - TCHAR m_nick[30], m_pNick[30]; - TCHAR m_alternativeNick[30]; - TCHAR m_name[200]; - TCHAR m_userID[200]; - TCHAR m_quitMessage[400]; - TCHAR m_userInfo[500]; - char m_myHost[50]; - char m_mySpecifiedHost[500]; - char m_mySpecifiedHostIP[50]; - char m_myLocalHost[50]; - WORD m_myLocalPort; - TCHAR* m_alias; - int m_serverComboSelection; - int m_quickComboSelection; - int m_onlineNotificationTime; - int m_onlineNotificationLimit; - BYTE m_scriptingEnabled; - BYTE m_IPFromServer; - BYTE m_showAddresses; - BYTE m_disconnectDCCChats; - BYTE m_disableErrorPopups; - BYTE m_rejoinChannels; - BYTE m_rejoinIfKicked; - BYTE m_hideServerWindow; - BYTE m_ident; - BYTE m_identTimer; - BYTE m_disableDefaultServer; - BYTE m_autoOnlineNotification; - BYTE m_sendKeepAlive; - BYTE m_joinOnInvite; - BYTE m_perform; - BYTE m_forceVisible; - BYTE m_ignore; - BYTE m_ignoreChannelDefault; - BYTE m_useServer; - BYTE m_DCCFileEnabled; - BYTE m_DCCChatEnabled; - BYTE m_DCCChatAccept; - BYTE m_DCCChatIgnore; - BYTE m_DCCPassive; - BYTE m_DCCMode; - WORD m_DCCPacketSize; - BYTE m_manualHost; - BYTE m_oldStyleModes; - BYTE m_channelAwayNotification; - BYTE m_sendNotice; - BYTE m_utfAutodetect; - int m_codepage; - COLORREF colors[16]; - HICON hIcon[13]; - - OBJLIST vUserhostReasons; - OBJLIST vWhoInProgress; - - mir_cs cs; - mir_cs m_gchook; - mir_cs m_resolve; - HANDLE m_evWndCreate; - - CMString m_statusMessage; - int m_iTempCheckTime; - - CIrcSessionInfo si; - - int m_portCount; - DWORD m_bConnectRequested; - DWORD m_bConnectThreadRunning; - - HGENMENU hMenuRoot, hMenuQuick, hMenuServer, hMenuJoin, hMenuNick, hMenuList; - HANDLE hNetlibDCC; - - bool bTempDisableCheck, bTempForceCheck, bEcho; - bool nickflag; - - bool bPerformDone; - - CJoinDlg* m_joinDlg; - CListDlg* m_listDlg; - CManagerDlg* m_managerDlg; - CNickDlg* m_nickDlg; - CWhoisDlg* m_whoisDlg; - CQuickDlg* m_quickDlg; - CIgnorePrefsDlg* m_ignoreDlg; - - int m_noOfChannels, m_manualWhoisCount; - CMStringA sChannelModes, sUserModes; - CMString sChannelPrefixes, sUserModePrefixes, WhoisAwayReply; - - //clist.cpp - MCONTACT CList_AddContact(CONTACT *user, bool InList, bool SetOnline); - bool CList_SetAllOffline(BYTE ChatsToo); - MCONTACT CList_SetOffline(CONTACT *user); - - bool CList_AddEvent(CONTACT *user, HICON Icon, HANDLE event, const char *tooltip, int type ) ; - MCONTACT CList_FindContact(CONTACT *user); - BOOL CList_AddDCCChat(const CMString &name, const CMString &hostmask, unsigned long adr, int port) ; - - //commandmonitor.cpp - UINT_PTR IdentTimer, InitTimer, KeepAliveTimer, OnlineNotifTimer, OnlineNotifTimer3; - - int AddOutgoingMessageToDB(MCONTACT hContact, TCHAR *msg); - bool DoOnConnect(const CIrcMessage *pmsg); - int DoPerform(const char *event); - void __cdecl ResolveIPThread(void *di); - - bool AddIgnore(const TCHAR *mask, const TCHAR *mode, const TCHAR *network) ; - int IsIgnored(const CMString &nick, const CMString &address, const CMString &host, char type) ; - int IsIgnored(CMString user, char type); - bool RemoveIgnore(const TCHAR *mask) ; - - //input.cpp - CMString DoAlias( const TCHAR *text, TCHAR *window); - BOOL DoHardcodedCommand(CMString text, TCHAR *window, MCONTACT hContact); - CMString DoIdentifiers(CMString text, const TCHAR *window); - void FormatMsg(CMString &text); - bool PostIrcMessageWnd(TCHAR *pszWindow, MCONTACT hContact, const TCHAR *szBuf); - bool PostIrcMessage(const TCHAR *fmt, ...); - - // irclib.cpp - UINT_PTR DCCTimer; - void SendIrcMessage(const TCHAR*, bool bNotify = true, int codepage = -1); - - // ircproto.cpp - void __cdecl AckBasicSearch(void* param); - void __cdecl AckMessageFail(void* info); - void __cdecl AckMessageFailDcc(void* info); - void __cdecl AckMessageSuccess(void* info); - - int SetStatusInternal(int iNewStatus, bool bIsInternal); - - //options.cpp - HWND m_hwndConnect; - - OBJLIST m_ignoreItems; - - int m_channelNumber; - CMString m_whoReply; - CMString sNamesList; - CMString sTopic; - CMString sTopicName; - CMString sTopicTime; - CMString m_namesToWho; - CMString m_channelsToWho; - CMString m_namesToUserhost; - - void InitPrefs(void); - void InitIgnore(void); - - void ReadSettings( TDbSetting* sets, int count ); - void RewriteIgnoreSettings( void ); - void WriteSettings( TDbSetting* sets, int count ); - - //output - BOOL ShowMessage (const CIrcMessage* pmsg); - - //scripting.cpp - INT_PTR __cdecl Scripting_InsertRawIn(WPARAM wParam,LPARAM lParam); - INT_PTR __cdecl Scripting_InsertRawOut(WPARAM wParam,LPARAM lParam); - INT_PTR __cdecl Scripting_InsertGuiIn(WPARAM wParam,LPARAM lParam); - INT_PTR __cdecl Scripting_InsertGuiOut(WPARAM wParam,LPARAM lParam); - INT_PTR __cdecl Scripting_GetIrcData(WPARAM wparam, LPARAM lparam); - - // services.cpp - void ConnectToServer(void); - void DisconnectFromServer(void); - void InitMainMenus(void); - - void __cdecl ConnectServerThread( void* ); - void __cdecl DisconnectServerThread( void* ); - - //tools.cpp - void AddToJTemp(TCHAR op, CMString& sCommand); - bool AddWindowItemData(CMString window, const TCHAR* pszLimit, const TCHAR* pszMode, const TCHAR* pszPassword, const TCHAR* pszTopic); - INT_PTR CallChatEvent(WPARAM wParam, LPARAM lParam); - INT_PTR DoEvent(int iEvent, const TCHAR* pszWindow, const TCHAR* pszNick, const TCHAR* pszText, const TCHAR* pszStatus, const TCHAR* pszUserInfo, DWORD_PTR dwItemData, bool bAddToLog, bool bIsMe,time_t timestamp = 1); - void FindLocalIP(HANDLE con); - bool FreeWindowItemData(CMString window, CHANNELINFO* wis); - bool IsChannel(const char* sName); - bool IsChannel(const TCHAR* sName); - void KillChatTimer(UINT_PTR &nIDEvent); - CMString MakeWndID(const TCHAR* sWindow); - CMString ModeToStatus(int sMode); - CMString PrefixToStatus(int cPrefix); - int SetChannelSBText(CMString sWindow, CHANNELINFO * wi); - void SetChatTimer(UINT_PTR &nIDEvent,UINT uElapse, TIMERPROC lpTimerFunc); - - void ClearUserhostReasons(int type); - void DoUserhostWithReason(int type, CMString reason, bool bSendCommand, CMString userhostparams, ...); - CMString GetNextUserhostReason(int type); - CMString PeekAtReasons(int type); - - // userinfo.cpp - void __cdecl AckUserInfoSearch( void* hContact ); - - //////////////////////////////////////////////////////////////////////////////////////// - // former CIrcSession class - - void AddDCCSession(MCONTACT hContact, CDccSession* dcc); - void AddDCCSession(DCCINFO* pdci, CDccSession* dcc); - void RemoveDCCSession(MCONTACT hContact); - void RemoveDCCSession(DCCINFO* pdci); - - CDccSession* FindDCCSession(MCONTACT hContact); - CDccSession* FindDCCSession(DCCINFO* pdci); - CDccSession* FindDCCSendByPort(int iPort); - CDccSession* FindDCCRecvByPortAndName(int iPort, const TCHAR* szName); - CDccSession* FindPassiveDCCSend(int iToken); - CDccSession* FindPassiveDCCRecv(CMString sName, CMString sToken); - - void DisconnectAllDCCSessions(bool Shutdown); - void CheckDCCTimeout(void); - - bool Connect(const CIrcSessionInfo& info); - void Disconnect(void); - void KillIdent(void); - - int NLSend(const TCHAR* fmt, ...); - int NLSend(const char* fmt, ...); - int NLSend(const unsigned char* buf, int cbBuf); - int NLSendNoScript( const unsigned char* buf, int cbBuf); - int NLReceive(unsigned char* buf, int cbBuf); - void InsertIncomingEvent(TCHAR* pszRaw); - - __inline bool IsConnected() const { return con != NULL; } - - // send-to-stream operators - int getCodepage() const; - __inline void setCodepage( int aPage ) { codepage = aPage; } - - CIrcSessionInfo m_info; - -protected : - int codepage; - HANDLE con; - HANDLE hBindPort; - void DoReceive(); - LIST m_dcc_chats; - LIST m_dcc_xfers; - -private : - mir_cs m_dcc; // protect the dcc objects - - void createMessageFromPchar( const char* p ); - void Notify(const CIrcMessage* pmsg); - void __cdecl ThreadProc( void *pparam ); - - //////////////////////////////////////////////////////////////////////////////////////// - // former CIrcMonitor class - - bool OnIrc_PING(const CIrcMessage* pmsg); - bool OnIrc_WELCOME(const CIrcMessage* pmsg); - bool OnIrc_YOURHOST(const CIrcMessage* pmsg); - bool OnIrc_NICK(const CIrcMessage* pmsg); - bool OnIrc_PRIVMSG(const CIrcMessage* pmsg); - bool OnIrc_JOIN(const CIrcMessage* pmsg); - bool OnIrc_QUIT(const CIrcMessage* pmsg); - bool OnIrc_PART(const CIrcMessage* pmsg); - bool OnIrc_KICK(const CIrcMessage* pmsg); - bool OnIrc_MODE(const CIrcMessage* pmsg); - bool OnIrc_USERHOST_REPLY(const CIrcMessage* pmsg); - bool OnIrc_MODEQUERY(const CIrcMessage* pmsg); - bool OnIrc_NAMES(const CIrcMessage* pmsg); - bool OnIrc_ENDNAMES(const CIrcMessage* pmsg); - bool OnIrc_INITIALTOPIC(const CIrcMessage* pmsg); - bool OnIrc_INITIALTOPICNAME(const CIrcMessage* pmsg); - bool OnIrc_TOPIC(const CIrcMessage* pmsg); - bool OnIrc_TRYAGAIN(const CIrcMessage* pmsg); - bool OnIrc_NOTICE(const CIrcMessage* pmsg); - bool OnIrc_WHOIS_NAME(const CIrcMessage* pmsg); - bool OnIrc_WHOIS_CHANNELS(const CIrcMessage* pmsg); - bool OnIrc_WHOIS_SERVER(const CIrcMessage* pmsg); - bool OnIrc_WHOIS_AWAY(const CIrcMessage* pmsg); - bool OnIrc_WHOIS_IDLE(const CIrcMessage* pmsg); - bool OnIrc_WHOIS_END(const CIrcMessage* pmsg); - bool OnIrc_WHOIS_OTHER(const CIrcMessage* pmsg); - bool OnIrc_WHOIS_AUTH(const CIrcMessage* pmsg); - bool OnIrc_WHOIS_NO_USER(const CIrcMessage* pmsg); - bool OnIrc_NICK_ERR(const CIrcMessage* pmsg); - bool OnIrc_ENDMOTD(const CIrcMessage* pmsg); - bool OnIrc_LISTSTART(const CIrcMessage* pmsg); - bool OnIrc_LIST(const CIrcMessage* pmsg); - bool OnIrc_LISTEND(const CIrcMessage* pmsg); - bool OnIrc_BANLIST(const CIrcMessage* pmsg); - bool OnIrc_BANLISTEND(const CIrcMessage* pmsg); - bool OnIrc_SUPPORT(const CIrcMessage* pmsg); - bool OnIrc_BACKFROMAWAY(const CIrcMessage* pmsg); - bool OnIrc_SETAWAY(const CIrcMessage* pmsg); - bool OnIrc_JOINERROR(const CIrcMessage* pmsg); - bool OnIrc_UNKNOWN(const CIrcMessage* pmsg); - bool OnIrc_ERROR(const CIrcMessage* pmsg); - bool OnIrc_NOOFCHANNELS(const CIrcMessage* pmsg); - bool OnIrc_PINGPONG(const CIrcMessage* pmsg); - bool OnIrc_INVITE(const CIrcMessage* pmsg); - bool OnIrc_WHO_END(const CIrcMessage* pmsg); - bool OnIrc_WHO_REPLY(const CIrcMessage* pmsg); - bool OnIrc_WHOTOOLONG(const CIrcMessage* pmsg); - - bool IsCTCP(const CIrcMessage* pmsg); - - void OnIrcDefault(const CIrcMessage* pmsg); - void OnIrcDisconnected(); - - static OBJLIST m_handlers; - - PfnIrcMessageHandler FindMethod(const TCHAR* lpszName); - - void OnIrcMessage(const CIrcMessage* pmsg); - CMString sNick4Perform; -}; - -// map actual member functions to their associated IRC command. -// put any number of this macro in the class's constructor. -#define IRC_MAP_ENTRY(name, member) \ - m_handlers.insert( new CIrcHandler( _T(name), &CIrcProto::OnIrc_##member )); - -///////////////////////////////////////////////////////////////////////////////////////// -// Functions - -//main.cpp -extern HINSTANCE hInst; - -extern LIST g_Instances; - -extern OBJLIST g_servers; - -void UpgradeCheck(void); - -CIrcProto* GetTimerOwner( UINT_PTR eventId ); - -VOID CALLBACK IdentTimerProc( HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime ); -VOID CALLBACK TimerProc( HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime ); -VOID CALLBACK KeepAliveTimerProc( HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime ); -VOID CALLBACK OnlineNotifTimerProc( HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime ); -VOID CALLBACK OnlineNotifTimerProc3( HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime ); -VOID CALLBACK DCCTimerProc( HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime ); - -// options.cpp - -void InitServers(void); -void RereadServers(void); - -void InitContactMenus(void); -void UninitContactMenus(void); - -void WindowSetIcon(HWND hWnd, int iconId); -void WindowFreeIcon(HWND hWnd); - -void InitIcons(void); -HICON LoadIconEx(int iIndex, bool big = false); -HANDLE GetIconHandle(int iconId); -void ReleaseIconEx(HICON hIcon); - -//tools.cpp -int __stdcall WCCmp(const TCHAR* wild, const TCHAR* string); -char* __stdcall IrcLoadFile(TCHAR * szPath); -CMString __stdcall GetWord(const TCHAR* text, int index); -const TCHAR* __stdcall GetWordAddress(const TCHAR* text, int index); -void __stdcall RemoveLinebreaks( CMString& Message ); -TCHAR* __stdcall my_strstri(const TCHAR *s1, const TCHAR *s2) ; -TCHAR* __stdcall DoColorCodes (const TCHAR* text, bool bStrip, bool bReplacePercent); - -CMStringA __stdcall GetWord(const char* text, int index); - -#pragma comment(lib,"comctl32.lib") - -#endif diff --git a/protocols/IRCG/src/irclib.cpp b/protocols/IRCG/src/irclib.cpp index 97396f1b32..eaee830928 100644 --- a/protocols/IRCG/src/irclib.cpp +++ b/protocols/IRCG/src/irclib.cpp @@ -18,7 +18,7 @@ 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" +#include "stdafx.h" #define DCCCHATTIMEOUT 300 #define DCCSENDTIMEOUT 120 diff --git a/protocols/IRCG/src/ircproto.cpp b/protocols/IRCG/src/ircproto.cpp index 7dd787fe5d..c70e78ab11 100644 --- a/protocols/IRCG/src/ircproto.cpp +++ b/protocols/IRCG/src/ircproto.cpp @@ -19,7 +19,7 @@ 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" +#include "stdafx.h" #include "version.h" #include diff --git a/protocols/IRCG/src/main.cpp b/protocols/IRCG/src/main.cpp index 12760a4a8a..0da567113c 100644 --- a/protocols/IRCG/src/main.cpp +++ b/protocols/IRCG/src/main.cpp @@ -19,7 +19,7 @@ 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" +#include "stdafx.h" #include "version.h" HINSTANCE hInst = NULL; diff --git a/protocols/IRCG/src/options.cpp b/protocols/IRCG/src/options.cpp index 3900273b4e..abc5ef02dd 100644 --- a/protocols/IRCG/src/options.cpp +++ b/protocols/IRCG/src/options.cpp @@ -19,7 +19,7 @@ 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" +#include "stdafx.h" #include static const CIrcProto* pZero = NULL; diff --git a/protocols/IRCG/src/output.cpp b/protocols/IRCG/src/output.cpp index 016918f612..94eae7e12d 100644 --- a/protocols/IRCG/src/output.cpp +++ b/protocols/IRCG/src/output.cpp @@ -19,7 +19,7 @@ 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" +#include "stdafx.h" static CMString FormatOutput(const CIrcMessage* pmsg) { @@ -50,7 +50,7 @@ static CMString FormatOutput(const CIrcMessage* pmsg) goto THE_END; } - int index = StrToInt(pmsg->sCommand.c_str()); + int index = _ttoi(pmsg->sCommand.c_str()); if (index == 301 && pmsg->parameters.getCount() > 0) { TCHAR temp[500]; *temp = '\0'; mir_sntprintf(temp, SIZEOF(temp), TranslateT("%s is away"), pmsg->parameters[1].c_str()); @@ -136,7 +136,7 @@ BOOL CIrcProto::ShowMessage(const CIrcMessage* pmsg) if (!pmsg->m_bIncoming) mess.Replace(_T("%%"), _T("%")); - int iTemp = StrToInt(pmsg->sCommand.c_str()); + int iTemp = _ttoi(pmsg->sCommand.c_str()); //To active window if ((iTemp > 400 || iTemp < 500) && pmsg->sCommand[0] == '4' //all error messages diff --git a/protocols/IRCG/src/scripting.cpp b/protocols/IRCG/src/scripting.cpp index 2da94329df..a88dbdbf4d 100644 --- a/protocols/IRCG/src/scripting.cpp +++ b/protocols/IRCG/src/scripting.cpp @@ -19,7 +19,7 @@ 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" +#include "stdafx.h" INT_PTR __cdecl CIrcProto::Scripting_InsertRawIn(WPARAM, LPARAM lParam) { diff --git a/protocols/IRCG/src/services.cpp b/protocols/IRCG/src/services.cpp index 9d0bed7754..0376a9d6a2 100644 --- a/protocols/IRCG/src/services.cpp +++ b/protocols/IRCG/src/services.cpp @@ -19,7 +19,7 @@ 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" +#include "stdafx.h" void CIrcProto::InitMainMenus(void) { @@ -446,11 +446,11 @@ static void DoChatFormatting(TCHAR* pszText) break; case 'C': if (p1[2] == '%' && p1[3] == 'F') { - mir_tstrcpy(InsertThis, _T("\00399,99")); + mir_tstrcpy(InsertThis, _T("\x0399,99")); iRemoveChars = 4; } else { - mir_tstrcpy(InsertThis, _T("\00399")); + mir_tstrcpy(InsertThis, _T("\x0399")); iRemoveChars = 2; } iFG = -1; @@ -459,18 +459,18 @@ static void DoChatFormatting(TCHAR* pszText) if (p1 - 3 >= pszText && p1[-3] == '\003') mir_tstrcpy(InsertThis, _T(",")); else if (iFG >= 0) - mir_sntprintf(InsertThis, SIZEOF(InsertThis), _T("\003%u,"), iFG); + mir_sntprintf(InsertThis, SIZEOF(InsertThis), _T("\x03%u,"), iFG); else - mir_tstrcpy(InsertThis, _T("\00399,")); + mir_tstrcpy(InsertThis, _T("\x0399,")); iRemoveChars = 2; break; case 'F': if (iFG >= 0) - mir_sntprintf(InsertThis, SIZEOF(InsertThis), _T("\003%u,99"), iFG); + mir_sntprintf(InsertThis, SIZEOF(InsertThis), _T("\x03%u,99"), iFG); else - mir_tstrcpy(InsertThis, _T("\00399,99")); + mir_tstrcpy(InsertThis, _T("\x0399,99")); iRemoveChars = 2; break; @@ -1041,7 +1041,7 @@ void __cdecl CIrcProto::DisconnectServerThread(void*) void CIrcProto::ConnectToServer(void) { - m_portCount = StrToIntA(m_portStart); + m_portCount = atoi(m_portStart); si.sServer = GetWord(m_serverName, 0); si.iPort = m_portCount; si.sNick = m_nick; @@ -1049,7 +1049,7 @@ void CIrcProto::ConnectToServer(void) si.sFullName = m_name; si.sPassword = m_password; si.bIdentServer = ((m_ident) ? (true) : (false)); - si.iIdentServerPort = StrToInt(m_identPort); + si.iIdentServerPort = _ttoi(m_identPort); si.sIdentServerType = m_identSystem; si.m_iSSL = m_iSSL; si.sNetwork = m_network; @@ -1069,7 +1069,7 @@ void CIrcProto::ConnectToServer(void) InterlockedIncrement((long *)&m_bConnectRequested); TCHAR szTemp[300]; - mir_sntprintf(szTemp, SIZEOF(szTemp), _T("\0033%s \002%s\002 (%S: %u)"), + mir_sntprintf(szTemp, SIZEOF(szTemp), _T("\033%s \002%s\002 (%S: %u)"), TranslateT("Connecting to"), si.sNetwork.c_str(), si.sServer.c_str(), si.iPort); DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, NULL, szTemp, NULL, NULL, NULL, true, false); } diff --git a/protocols/IRCG/src/stdafx.cpp b/protocols/IRCG/src/stdafx.cpp deleted file mode 100644 index 432abe2979..0000000000 --- a/protocols/IRCG/src/stdafx.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* -Copyright (C) 2012-15 Miranda NG project (http://miranda-ng.org) - -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 version 2 -of the License. - -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, see . -*/ - -#include "irc.h" \ No newline at end of file diff --git a/protocols/IRCG/src/stdafx.cxx b/protocols/IRCG/src/stdafx.cxx new file mode 100644 index 0000000000..0c766ea07f --- /dev/null +++ b/protocols/IRCG/src/stdafx.cxx @@ -0,0 +1,18 @@ +/* +Copyright (C) 2012-15 Miranda NG project (http://miranda-ng.org) + +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 version 2 +of the License. + +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, see . +*/ + +#include "stdafx.h" diff --git a/protocols/IRCG/src/stdafx.h b/protocols/IRCG/src/stdafx.h new file mode 100644 index 0000000000..1e6c4b683b --- /dev/null +++ b/protocols/IRCG/src/stdafx.h @@ -0,0 +1,638 @@ +/* +IRC plugin for Miranda IM + +Copyright (C) 2003-05 Jurgen Persson +Copyright (C) 2007-09 George Hazan + +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 _IRCWIN_H_ +#define _IRCWIN_H_ + +#define WIN32_LEAN_AND_MEAN +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "newpluginapi.h" +#include "m_system.h" +#include "m_system_cpp.h" +#include "m_protocols.h" +#include "m_protomod.h" +#include "m_protosvc.h" +#include "m_protoint.h" +#include "m_clist.h" +#include "m_options.h" +#include "m_database.h" +#include "m_utils.h" +#include "m_skin.h" +#include "m_netlib.h" +#include "m_clui.h" +#include "m_langpack.h" +#include "m_message.h" +#include "m_userinfo.h" +#include "m_addcontact.h" +#include "m_button.h" +#include "m_genmenu.h" +#include "m_file.h" +#include "m_ignore.h" +#include "m_chat.h" +#include "m_icolib.h" +#include "m_string.h" +#include "win2k.h" +#include "m_gui.h" + +#include "resource.h" + +#define IRC_QUICKCONNECT "/QuickConnectMenu" +#define IRC_JOINCHANNEL "/JoinChannelMenu" +#define IRC_CHANGENICK "/ChangeNickMenu" +#define IRC_SHOWLIST "/ShowListMenu" +#define IRC_SHOWSERVER "/ShowServerMenu" +#define IRC_UM_CHANSETTINGS "/UMenuChanSettings" +#define IRC_UM_WHOIS "/UMenuWhois" +#define IRC_UM_DISCONNECT "/UMenuDisconnect" +#define IRC_UM_IGNORE "/UMenuIgnore" + +#define STR_QUITMESSAGE _T("\002Miranda NG!\002 Smaller, Faster, Easier. http://miranda-ng.org/") +#define STR_USERINFO _T("I'm a happy Miranda NG user! Get it here: http://miranda-ng.org/") +#define STR_AWAYMESSAGE _T("I'm away from the computer.") // Default away +#define DCCSTRING _T(" (DCC)") +#define SERVERSMODULE "IRC Servers" +#define SERVERWINDOW _T("Network log") + +#define DCC_CHAT 1 +#define DCC_SEND 2 + +#define FILERESUME_CANCEL 11 + +struct CIrcProto; + +// special service for tweaking performance, implemented in chat.dll +#define MS_GC_GETEVENTPTR "GChat/GetNewEventPtr" +typedef int (*GETEVENTFUNC)(WPARAM wParam, LPARAM lParam); +typedef struct { + GETEVENTFUNC pfnAddEvent; +} + GCPTRS; + +#define IP_AUTO 1 +#define IP_MANUAL 2 + +struct IPRESOLVE // Contains info about the channels +{ + IPRESOLVE( const char* _addr, int _type ) : + sAddr( _addr ), + iType( _type ) + {} + + ~IPRESOLVE() + {} + + CMStringA sAddr; + int iType; +}; + +struct CHANNELINFO // Contains info about the channels +{ + TCHAR* pszTopic; + TCHAR* pszMode; + TCHAR* pszPassword; + TCHAR* pszLimit; + BYTE OwnMode; /* own mode on the channel. Bitmask: + 0: voice + 1: halfop + 2: op + 3: admin + 4: owner */ + int codepage; +}; + +struct SERVER_INFO // Contains info about different servers +{ + ~SERVER_INFO(); + + char *m_name, *m_address, *m_group; + int m_portStart, m_portEnd, m_iSSL; +}; + +struct PERFORM_INFO // Contains 'm_perform buffer' for different networks +{ + PERFORM_INFO( const char* szSetting, const TCHAR* value ) : + mSetting( szSetting ), + mText( value ) + {} + + ~PERFORM_INFO() + {} + + CMStringA mSetting; + CMString mText; +}; + +struct CONTACT // Contains info about users +{ + TCHAR* name; + TCHAR* user; + TCHAR* host; + bool ExactOnly; + bool ExactWCOnly; + bool ExactNick; +}; + +struct TDbSetting +{ + int offset; + char* name; + int type; + size_t size; + union + { + int defValue; + TCHAR* defStr; + }; +}; + +#include "irclib.h" +using namespace irc; + +#include "irc_dlg.h" + +///////////////////////////////////////////////////////////////////////////////////////// + +typedef bool (CIrcProto::*PfnIrcMessageHandler)(const CIrcMessage* pmsg); + +struct CIrcHandler +{ + CIrcHandler( const TCHAR* _name, PfnIrcMessageHandler _handler ) : + m_name( _name ), + m_handler( _handler ) + {} + + const TCHAR* m_name; + PfnIrcMessageHandler m_handler; +}; + +struct CIrcProto : public PROTO +{ + CIrcProto(const char*, const TCHAR*); + ~CIrcProto(); + + // Protocol interface + + virtual MCONTACT __cdecl AddToList( int flags, PROTOSEARCHRESULT* psr ); + + virtual int __cdecl Authorize(MEVENT hDbEvent); + virtual int __cdecl AuthDeny(MEVENT hDbEvent, const TCHAR* szReason); + + virtual HANDLE __cdecl FileAllow(MCONTACT hContact, HANDLE hTransfer, const TCHAR *szPath); + virtual int __cdecl FileCancel(MCONTACT hContact, HANDLE hTransfer ); + virtual int __cdecl FileDeny(MCONTACT hContact, HANDLE hTransfer, const TCHAR *szReason); + virtual int __cdecl FileResume( HANDLE hTransfer, int *action, const TCHAR **szFilename); + + virtual DWORD_PTR __cdecl GetCaps( int type, MCONTACT hContact = NULL); + + virtual HANDLE __cdecl SearchBasic(const PROTOCHAR* id); + + virtual HANDLE __cdecl SendFile(MCONTACT hContact, const TCHAR *szDescription, TCHAR **ppszFiles); + virtual int __cdecl SendMsg(MCONTACT hContact, int flags, const char* msg); + + virtual int __cdecl SetStatus(int iNewStatus); + + virtual HANDLE __cdecl GetAwayMsg(MCONTACT hContact); + virtual int __cdecl SetAwayMsg(int m_iStatus, const TCHAR *msg); + + virtual int __cdecl OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam); + + // Services + INT_PTR __cdecl SvcCreateAccMgrUI(WPARAM, LPARAM); + INT_PTR __cdecl GetMyAwayMsg(WPARAM, LPARAM); + + INT_PTR __cdecl OnChangeNickMenuCommand(WPARAM, LPARAM); + INT_PTR __cdecl OnDoubleclicked(WPARAM, LPARAM); + INT_PTR __cdecl OnJoinChat(WPARAM, LPARAM); + INT_PTR __cdecl OnJoinMenuCommand(WPARAM, LPARAM); + INT_PTR __cdecl OnLeaveChat(WPARAM, LPARAM); + INT_PTR __cdecl OnMenuChanSettings(WPARAM, LPARAM); + INT_PTR __cdecl OnMenuDisconnect( WPARAM , LPARAM ); + INT_PTR __cdecl OnMenuIgnore(WPARAM, LPARAM); + INT_PTR __cdecl OnMenuWhois(WPARAM, LPARAM); + INT_PTR __cdecl OnQuickConnectMenuCommand(WPARAM, LPARAM ); + INT_PTR __cdecl OnShowListMenuCommand(WPARAM, LPARAM); + INT_PTR __cdecl OnShowServerMenuCommand(WPARAM, LPARAM); + + // Events + int __cdecl OnContactDeleted(WPARAM, LPARAM); + int __cdecl OnInitOptionsPages(WPARAM, LPARAM); + int __cdecl OnInitUserInfo(WPARAM, LPARAM); + int __cdecl OnModulesLoaded(WPARAM, LPARAM); + int __cdecl OnMenuPreBuild(WPARAM, LPARAM); + int __cdecl OnPreShutdown(WPARAM, LPARAM); + int __cdecl OnDbSettingChanged(WPARAM, LPARAM); + + int __cdecl GCEventHook(WPARAM, LPARAM); + int __cdecl GCMenuHook(WPARAM, LPARAM); + + // Data + + char m_serverName[100]; + char m_password [500]; + TCHAR m_identSystem[10]; + char m_network[30]; + char m_portStart[10]; + char m_portEnd[10]; + int m_iSSL; + TCHAR m_identPort[10]; + TCHAR m_nick[30], m_pNick[30]; + TCHAR m_alternativeNick[30]; + TCHAR m_name[200]; + TCHAR m_userID[200]; + TCHAR m_quitMessage[400]; + TCHAR m_userInfo[500]; + char m_myHost[50]; + char m_mySpecifiedHost[500]; + char m_mySpecifiedHostIP[50]; + char m_myLocalHost[50]; + WORD m_myLocalPort; + TCHAR* m_alias; + int m_serverComboSelection; + int m_quickComboSelection; + int m_onlineNotificationTime; + int m_onlineNotificationLimit; + BYTE m_scriptingEnabled; + BYTE m_IPFromServer; + BYTE m_showAddresses; + BYTE m_disconnectDCCChats; + BYTE m_disableErrorPopups; + BYTE m_rejoinChannels; + BYTE m_rejoinIfKicked; + BYTE m_hideServerWindow; + BYTE m_ident; + BYTE m_identTimer; + BYTE m_disableDefaultServer; + BYTE m_autoOnlineNotification; + BYTE m_sendKeepAlive; + BYTE m_joinOnInvite; + BYTE m_perform; + BYTE m_forceVisible; + BYTE m_ignore; + BYTE m_ignoreChannelDefault; + BYTE m_useServer; + BYTE m_DCCFileEnabled; + BYTE m_DCCChatEnabled; + BYTE m_DCCChatAccept; + BYTE m_DCCChatIgnore; + BYTE m_DCCPassive; + BYTE m_DCCMode; + WORD m_DCCPacketSize; + BYTE m_manualHost; + BYTE m_oldStyleModes; + BYTE m_channelAwayNotification; + BYTE m_sendNotice; + BYTE m_utfAutodetect; + int m_codepage; + COLORREF colors[16]; + HICON hIcon[13]; + + OBJLIST vUserhostReasons; + OBJLIST vWhoInProgress; + + mir_cs cs; + mir_cs m_gchook; + mir_cs m_resolve; + HANDLE m_evWndCreate; + + CMString m_statusMessage; + int m_iTempCheckTime; + + CIrcSessionInfo si; + + int m_portCount; + DWORD m_bConnectRequested; + DWORD m_bConnectThreadRunning; + + HGENMENU hMenuRoot, hMenuQuick, hMenuServer, hMenuJoin, hMenuNick, hMenuList; + HANDLE hNetlibDCC; + + bool bTempDisableCheck, bTempForceCheck, bEcho; + bool nickflag; + + bool bPerformDone; + + CJoinDlg* m_joinDlg; + CListDlg* m_listDlg; + CManagerDlg* m_managerDlg; + CNickDlg* m_nickDlg; + CWhoisDlg* m_whoisDlg; + CQuickDlg* m_quickDlg; + CIgnorePrefsDlg* m_ignoreDlg; + + int m_noOfChannels, m_manualWhoisCount; + CMStringA sChannelModes, sUserModes; + CMString sChannelPrefixes, sUserModePrefixes, WhoisAwayReply; + + //clist.cpp + MCONTACT CList_AddContact(CONTACT *user, bool InList, bool SetOnline); + bool CList_SetAllOffline(BYTE ChatsToo); + MCONTACT CList_SetOffline(CONTACT *user); + + bool CList_AddEvent(CONTACT *user, HICON Icon, HANDLE event, const char *tooltip, int type ) ; + MCONTACT CList_FindContact(CONTACT *user); + BOOL CList_AddDCCChat(const CMString &name, const CMString &hostmask, unsigned long adr, int port) ; + + //commandmonitor.cpp + UINT_PTR IdentTimer, InitTimer, KeepAliveTimer, OnlineNotifTimer, OnlineNotifTimer3; + + int AddOutgoingMessageToDB(MCONTACT hContact, TCHAR *msg); + bool DoOnConnect(const CIrcMessage *pmsg); + int DoPerform(const char *event); + void __cdecl ResolveIPThread(void *di); + + bool AddIgnore(const TCHAR *mask, const TCHAR *mode, const TCHAR *network) ; + int IsIgnored(const CMString &nick, const CMString &address, const CMString &host, char type) ; + int IsIgnored(CMString user, char type); + bool RemoveIgnore(const TCHAR *mask) ; + + //input.cpp + CMString DoAlias( const TCHAR *text, TCHAR *window); + BOOL DoHardcodedCommand(CMString text, TCHAR *window, MCONTACT hContact); + CMString DoIdentifiers(CMString text, const TCHAR *window); + void FormatMsg(CMString &text); + bool PostIrcMessageWnd(TCHAR *pszWindow, MCONTACT hContact, const TCHAR *szBuf); + bool PostIrcMessage(const TCHAR *fmt, ...); + + // irclib.cpp + UINT_PTR DCCTimer; + void SendIrcMessage(const TCHAR*, bool bNotify = true, int codepage = -1); + + // ircproto.cpp + void __cdecl AckBasicSearch(void* param); + void __cdecl AckMessageFail(void* info); + void __cdecl AckMessageFailDcc(void* info); + void __cdecl AckMessageSuccess(void* info); + + int SetStatusInternal(int iNewStatus, bool bIsInternal); + + //options.cpp + HWND m_hwndConnect; + + OBJLIST m_ignoreItems; + + int m_channelNumber; + CMString m_whoReply; + CMString sNamesList; + CMString sTopic; + CMString sTopicName; + CMString sTopicTime; + CMString m_namesToWho; + CMString m_channelsToWho; + CMString m_namesToUserhost; + + void InitPrefs(void); + void InitIgnore(void); + + void ReadSettings( TDbSetting* sets, int count ); + void RewriteIgnoreSettings( void ); + void WriteSettings( TDbSetting* sets, int count ); + + //output + BOOL ShowMessage (const CIrcMessage* pmsg); + + //scripting.cpp + INT_PTR __cdecl Scripting_InsertRawIn(WPARAM wParam,LPARAM lParam); + INT_PTR __cdecl Scripting_InsertRawOut(WPARAM wParam,LPARAM lParam); + INT_PTR __cdecl Scripting_InsertGuiIn(WPARAM wParam,LPARAM lParam); + INT_PTR __cdecl Scripting_InsertGuiOut(WPARAM wParam,LPARAM lParam); + INT_PTR __cdecl Scripting_GetIrcData(WPARAM wparam, LPARAM lparam); + + // services.cpp + void ConnectToServer(void); + void DisconnectFromServer(void); + void InitMainMenus(void); + + void __cdecl ConnectServerThread( void* ); + void __cdecl DisconnectServerThread( void* ); + + //tools.cpp + void AddToJTemp(TCHAR op, CMString& sCommand); + bool AddWindowItemData(CMString window, const TCHAR* pszLimit, const TCHAR* pszMode, const TCHAR* pszPassword, const TCHAR* pszTopic); + INT_PTR CallChatEvent(WPARAM wParam, LPARAM lParam); + INT_PTR DoEvent(int iEvent, const TCHAR* pszWindow, const TCHAR* pszNick, const TCHAR* pszText, const TCHAR* pszStatus, const TCHAR* pszUserInfo, DWORD_PTR dwItemData, bool bAddToLog, bool bIsMe,time_t timestamp = 1); + void FindLocalIP(HANDLE con); + bool FreeWindowItemData(CMString window, CHANNELINFO* wis); + bool IsChannel(const char* sName); + bool IsChannel(const TCHAR* sName); + void KillChatTimer(UINT_PTR &nIDEvent); + CMString MakeWndID(const TCHAR* sWindow); + CMString ModeToStatus(int sMode); + CMString PrefixToStatus(int cPrefix); + int SetChannelSBText(CMString sWindow, CHANNELINFO * wi); + void SetChatTimer(UINT_PTR &nIDEvent,UINT uElapse, TIMERPROC lpTimerFunc); + + void ClearUserhostReasons(int type); + void DoUserhostWithReason(int type, CMString reason, bool bSendCommand, CMString userhostparams, ...); + CMString GetNextUserhostReason(int type); + CMString PeekAtReasons(int type); + + // userinfo.cpp + void __cdecl AckUserInfoSearch( void* hContact ); + + //////////////////////////////////////////////////////////////////////////////////////// + // former CIrcSession class + + void AddDCCSession(MCONTACT hContact, CDccSession* dcc); + void AddDCCSession(DCCINFO* pdci, CDccSession* dcc); + void RemoveDCCSession(MCONTACT hContact); + void RemoveDCCSession(DCCINFO* pdci); + + CDccSession* FindDCCSession(MCONTACT hContact); + CDccSession* FindDCCSession(DCCINFO* pdci); + CDccSession* FindDCCSendByPort(int iPort); + CDccSession* FindDCCRecvByPortAndName(int iPort, const TCHAR* szName); + CDccSession* FindPassiveDCCSend(int iToken); + CDccSession* FindPassiveDCCRecv(CMString sName, CMString sToken); + + void DisconnectAllDCCSessions(bool Shutdown); + void CheckDCCTimeout(void); + + bool Connect(const CIrcSessionInfo& info); + void Disconnect(void); + void KillIdent(void); + + int NLSend(const TCHAR* fmt, ...); + int NLSend(const char* fmt, ...); + int NLSend(const unsigned char* buf, int cbBuf); + int NLSendNoScript( const unsigned char* buf, int cbBuf); + int NLReceive(unsigned char* buf, int cbBuf); + void InsertIncomingEvent(TCHAR* pszRaw); + + __inline bool IsConnected() const { return con != NULL; } + + // send-to-stream operators + int getCodepage() const; + __inline void setCodepage( int aPage ) { codepage = aPage; } + + CIrcSessionInfo m_info; + +protected : + int codepage; + HANDLE con; + HANDLE hBindPort; + void DoReceive(); + LIST m_dcc_chats; + LIST m_dcc_xfers; + +private : + mir_cs m_dcc; // protect the dcc objects + + void createMessageFromPchar( const char* p ); + void Notify(const CIrcMessage* pmsg); + void __cdecl ThreadProc( void *pparam ); + + //////////////////////////////////////////////////////////////////////////////////////// + // former CIrcMonitor class + + bool OnIrc_PING(const CIrcMessage* pmsg); + bool OnIrc_WELCOME(const CIrcMessage* pmsg); + bool OnIrc_YOURHOST(const CIrcMessage* pmsg); + bool OnIrc_NICK(const CIrcMessage* pmsg); + bool OnIrc_PRIVMSG(const CIrcMessage* pmsg); + bool OnIrc_JOIN(const CIrcMessage* pmsg); + bool OnIrc_QUIT(const CIrcMessage* pmsg); + bool OnIrc_PART(const CIrcMessage* pmsg); + bool OnIrc_KICK(const CIrcMessage* pmsg); + bool OnIrc_MODE(const CIrcMessage* pmsg); + bool OnIrc_USERHOST_REPLY(const CIrcMessage* pmsg); + bool OnIrc_MODEQUERY(const CIrcMessage* pmsg); + bool OnIrc_NAMES(const CIrcMessage* pmsg); + bool OnIrc_ENDNAMES(const CIrcMessage* pmsg); + bool OnIrc_INITIALTOPIC(const CIrcMessage* pmsg); + bool OnIrc_INITIALTOPICNAME(const CIrcMessage* pmsg); + bool OnIrc_TOPIC(const CIrcMessage* pmsg); + bool OnIrc_TRYAGAIN(const CIrcMessage* pmsg); + bool OnIrc_NOTICE(const CIrcMessage* pmsg); + bool OnIrc_WHOIS_NAME(const CIrcMessage* pmsg); + bool OnIrc_WHOIS_CHANNELS(const CIrcMessage* pmsg); + bool OnIrc_WHOIS_SERVER(const CIrcMessage* pmsg); + bool OnIrc_WHOIS_AWAY(const CIrcMessage* pmsg); + bool OnIrc_WHOIS_IDLE(const CIrcMessage* pmsg); + bool OnIrc_WHOIS_END(const CIrcMessage* pmsg); + bool OnIrc_WHOIS_OTHER(const CIrcMessage* pmsg); + bool OnIrc_WHOIS_AUTH(const CIrcMessage* pmsg); + bool OnIrc_WHOIS_NO_USER(const CIrcMessage* pmsg); + bool OnIrc_NICK_ERR(const CIrcMessage* pmsg); + bool OnIrc_ENDMOTD(const CIrcMessage* pmsg); + bool OnIrc_LISTSTART(const CIrcMessage* pmsg); + bool OnIrc_LIST(const CIrcMessage* pmsg); + bool OnIrc_LISTEND(const CIrcMessage* pmsg); + bool OnIrc_BANLIST(const CIrcMessage* pmsg); + bool OnIrc_BANLISTEND(const CIrcMessage* pmsg); + bool OnIrc_SUPPORT(const CIrcMessage* pmsg); + bool OnIrc_BACKFROMAWAY(const CIrcMessage* pmsg); + bool OnIrc_SETAWAY(const CIrcMessage* pmsg); + bool OnIrc_JOINERROR(const CIrcMessage* pmsg); + bool OnIrc_UNKNOWN(const CIrcMessage* pmsg); + bool OnIrc_ERROR(const CIrcMessage* pmsg); + bool OnIrc_NOOFCHANNELS(const CIrcMessage* pmsg); + bool OnIrc_PINGPONG(const CIrcMessage* pmsg); + bool OnIrc_INVITE(const CIrcMessage* pmsg); + bool OnIrc_WHO_END(const CIrcMessage* pmsg); + bool OnIrc_WHO_REPLY(const CIrcMessage* pmsg); + bool OnIrc_WHOTOOLONG(const CIrcMessage* pmsg); + + bool IsCTCP(const CIrcMessage* pmsg); + + void OnIrcDefault(const CIrcMessage* pmsg); + void OnIrcDisconnected(); + + static OBJLIST m_handlers; + + PfnIrcMessageHandler FindMethod(const TCHAR* lpszName); + + void OnIrcMessage(const CIrcMessage* pmsg); + CMString sNick4Perform; +}; + +// map actual member functions to their associated IRC command. +// put any number of this macro in the class's constructor. +#define IRC_MAP_ENTRY(name, member) \ + m_handlers.insert( new CIrcHandler( _T(name), &CIrcProto::OnIrc_##member )); + +///////////////////////////////////////////////////////////////////////////////////////// +// Functions + +//main.cpp +extern HINSTANCE hInst; + +extern LIST g_Instances; + +extern OBJLIST g_servers; + +void UpgradeCheck(void); + +CIrcProto* GetTimerOwner( UINT_PTR eventId ); + +VOID CALLBACK IdentTimerProc( HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime ); +VOID CALLBACK TimerProc( HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime ); +VOID CALLBACK KeepAliveTimerProc( HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime ); +VOID CALLBACK OnlineNotifTimerProc( HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime ); +VOID CALLBACK OnlineNotifTimerProc3( HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime ); +VOID CALLBACK DCCTimerProc( HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime ); + +// options.cpp + +void InitServers(void); +void RereadServers(void); + +void InitContactMenus(void); +void UninitContactMenus(void); + +void WindowSetIcon(HWND hWnd, int iconId); +void WindowFreeIcon(HWND hWnd); + +void InitIcons(void); +HICON LoadIconEx(int iIndex, bool big = false); +HANDLE GetIconHandle(int iconId); +void ReleaseIconEx(HICON hIcon); + +//tools.cpp +int __stdcall WCCmp(const TCHAR* wild, const TCHAR* string); +char* __stdcall IrcLoadFile(TCHAR * szPath); +CMString __stdcall GetWord(const TCHAR* text, int index); +const TCHAR* __stdcall GetWordAddress(const TCHAR* text, int index); +void __stdcall RemoveLinebreaks( CMString& Message ); +TCHAR* __stdcall my_strstri(const TCHAR *s1, const TCHAR *s2) ; +TCHAR* __stdcall DoColorCodes (const TCHAR* text, bool bStrip, bool bReplacePercent); + +CMStringA __stdcall GetWord(const char* text, int index); + +#pragma comment(lib,"comctl32.lib") + +#endif diff --git a/protocols/IRCG/src/tools.cpp b/protocols/IRCG/src/tools.cpp index 45c7ded352..954665a01f 100644 --- a/protocols/IRCG/src/tools.cpp +++ b/protocols/IRCG/src/tools.cpp @@ -19,7 +19,7 @@ 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" +#include "stdafx.h" ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/protocols/IRCG/src/userinfo.cpp b/protocols/IRCG/src/userinfo.cpp index 6ea082678e..cbc85fe2c9 100644 --- a/protocols/IRCG/src/userinfo.cpp +++ b/protocols/IRCG/src/userinfo.cpp @@ -19,7 +19,7 @@ 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" +#include "stdafx.h" ///////////////////////////////////////////////////////////////////////////////////////// // 'User details' dialog diff --git a/protocols/IRCG/src/windows.cpp b/protocols/IRCG/src/windows.cpp index dc6e686b3e..ddac73b1c4 100644 --- a/protocols/IRCG/src/windows.cpp +++ b/protocols/IRCG/src/windows.cpp @@ -19,7 +19,7 @@ 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" +#include "stdafx.h" ///////////////////////////////////////////////////////////////////////////////////////// // Message Box @@ -435,7 +435,7 @@ static int CALLBACK ListViewSort(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSo return (*temp1 == 0) ? 1 : -1; } - return (StrToInt(temp1) < StrToInt(temp2)) ? 1 : -1; + return (_ttoi(temp1) < _ttoi(temp2)) ? 1 : -1; } int CListDlg::Resizer(UTILRESIZECONTROL *urc) -- cgit v1.2.3