From d5d023f683b23fe26ddea93738cb721d532804f0 Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Thu, 14 Jun 2012 16:22:13 +0000 Subject: another portion of "#ifsef Unicode" removal git-svn-id: http://svn.miranda-ng.org/main/trunk@411 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/IRCG/commandmonitor.cpp | 33 ++++++++------------------------- protocols/IRCG/irc.h | 14 ++++---------- protocols/IRCG/irclib.cpp | 11 +---------- protocols/IRCG/ircproto.cpp | 7 +------ protocols/IRCG/options.cpp | 17 +++-------------- protocols/IRCG/tools.cpp | 4 ---- protocols/IRCG/ui_utils.cpp | 22 +++++++--------------- protocols/IRCG/ui_utils.h | 9 ++------- protocols/IRCG/windows.cpp | 21 ++++++--------------- 9 files changed, 32 insertions(+), 106 deletions(-) (limited to 'protocols/IRCG') diff --git a/protocols/IRCG/commandmonitor.cpp b/protocols/IRCG/commandmonitor.cpp index 0f39828891..352d162c48 100644 --- a/protocols/IRCG/commandmonitor.cpp +++ b/protocols/IRCG/commandmonitor.cpp @@ -228,18 +228,11 @@ int CIrcProto::AddOutgoingMessageToDB(HANDLE hContact, TCHAR* msg) dbei.szModule = m_szModuleName; dbei.eventType = EVENTTYPE_MESSAGE; dbei.timestamp = (DWORD)time(NULL); - #if defined( _UNICODE ) - dbei.flags = DBEF_SENT + DBEF_UTF; - dbei.pBlob = ( PBYTE )mir_utf8encodeW( S.c_str()); - #else - dbei.flags = DBEF_SENT; - dbei.pBlob = ( PBYTE )S.c_str(); - #endif + dbei.flags = DBEF_SENT + DBEF_UTF; + dbei.pBlob = ( PBYTE )mir_utf8encodeW( S.c_str()); dbei.cbBlob = (DWORD)strlen(( char* )dbei.pBlob) + 1; CallService( MS_DB_EVENT_ADD, (WPARAM) hContact, (LPARAM) & dbei); - #if defined( _UNICODE ) - mir_free( dbei.pBlob ); - #endif + mir_free( dbei.pBlob ); return 1; } @@ -733,18 +726,12 @@ bool CIrcProto::OnIrc_PRIVMSG( const CIrcMessage* pmsg ) ccs.hContact = CList_AddContact( &user, false, true ); ccs.lParam = (LPARAM)⪯ pre.timestamp = (DWORD)time(NULL); - #if defined( _UNICODE ) - pre.flags = PREF_UTF; - pre.szMessage = mir_utf8encodeW( mess.c_str()); - #else - pre.szMessage = ( char* )mess.c_str(); - #endif + pre.flags = PREF_UTF; + pre.szMessage = mir_utf8encodeW( mess.c_str()); setTString(ccs.hContact, "User", pmsg->prefix.sUser.c_str()); setTString(ccs.hContact, "Host", pmsg->prefix.sHost.c_str()); CallService( MS_PROTO_CHAINRECV, 0, (LPARAM) & ccs); - #if defined( _UNICODE ) - mir_free( pre.szMessage ); - #endif + mir_free( pre.szMessage ); return true; } @@ -841,12 +828,8 @@ bool CIrcProto::IsCTCP( const CIrcMessage* pmsg ) else if (pmsg->m_bIncoming && command == _T("version")) { PostIrcMessage( _T("/NOTICE %s \001VERSION Miranda IM %s (IRC v.%s%s), (c) 2003-09 J.Persson, G.Hazan\001"), pmsg->prefix.sNick.c_str(), _T("%mirver"), _T("%version"), - #if defined( _UNICODE ) - _T(" Unicode")); - #else - "" ); - #endif - + _T(" Unicode")); + TCHAR temp[300]; mir_sntprintf( temp, SIZEOF(temp), TranslateT("CTCP VERSION requested by %s"), pmsg->prefix.sNick.c_str()); DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, NULL, temp, NULL, NULL, NULL, true, false); diff --git a/protocols/IRCG/irc.h b/protocols/IRCG/irc.h index 13ec720381..823efec68e 100644 --- a/protocols/IRCG/irc.h +++ b/protocols/IRCG/irc.h @@ -515,9 +515,7 @@ struct CIrcProto : public PROTO_INTERFACE, public CCallocBase 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); - #if defined( _UNICODE ) - bool IsChannel(const char* sName); - #endif + bool IsChannel(const char* sName); bool IsChannel(const TCHAR* sName); void KillChatTimer(UINT_PTR &nIDEvent); CMString MakeWndID(const TCHAR* sWindow); @@ -578,9 +576,7 @@ struct CIrcProto : public PROTO_INTERFACE, public CCallocBase void Disconnect(void); void KillIdent(void); - #if defined( _UNICODE ) - int NLSend(const TCHAR* fmt, ...); - #endif + 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); @@ -733,10 +729,8 @@ TCHAR* __stdcall my_strstri(const TCHAR *s1, const TCHAR *s2) ; TCHAR* __stdcall DoColorCodes (const TCHAR* text, bool bStrip, bool bReplacePercent); char* __stdcall rtrim( char *string ); -#if defined( _UNICODE ) - String& __stdcall ReplaceString (String& text, const char* replaceme, const char* newword); - String __stdcall GetWord(const char* text, int index); -#endif +String& __stdcall ReplaceString (String& text, const char* replaceme, const char* newword); +String __stdcall GetWord(const char* text, int index); #define NEWSTR_ALLOCA(A) (A==NULL)?NULL:strcpy((char*)alloca(strlen(A)+1),A) #define NEWTSTR_ALLOCA(A) (A==NULL)?NULL:_tcscpy((TCHAR*)alloca(sizeof(TCHAR)*(_tcslen(A)+1)),A) diff --git a/protocols/IRCG/irclib.cpp b/protocols/IRCG/irclib.cpp index a5d3ad1537..78d33f11dc 100644 --- a/protocols/IRCG/irclib.cpp +++ b/protocols/IRCG/irclib.cpp @@ -308,7 +308,6 @@ int CIrcProto::NLSend( const TCHAR* fmt, ...) return result; } -#if defined( _UNICODE ) int CIrcProto::NLSend( const char* fmt, ...) { va_list marker; @@ -320,7 +319,6 @@ int CIrcProto::NLSend( const char* fmt, ...) return NLSend((unsigned char*)szBuf, cbLen ); } -#endif int CIrcProto::NLSendNoScript( const unsigned char* buf, int cbBuf) { @@ -355,15 +353,8 @@ void CIrcProto::createMessageFromPchar( const char* p ) { TCHAR* ptszMsg; if ( codepage != CP_UTF8 && m_utfAutodetect ) { - #if defined( _UNICODE ) - if ( mir_utf8decodecp( NEWSTR_ALLOCA(p), codepage, &ptszMsg ) == NULL ) + if ( mir_utf8decodecp( NEWSTR_ALLOCA(p), codepage, &ptszMsg ) == NULL ) ptszMsg = mir_a2t_cp( p, codepage ); - #else - if ( mir_utf8decodecp( NEWSTR_ALLOCA(p), codepage, NULL ) == NULL ) - ptszMsg = mir_a2t_cp( p, codepage ); - else - ptszMsg = mir_strdup( p ); - #endif } else ptszMsg = mir_a2t_cp( p, codepage ); CIrcMessage msg( this, ptszMsg, codepage, true ); diff --git a/protocols/IRCG/ircproto.cpp b/protocols/IRCG/ircproto.cpp index 1d72f2ac88..f167eddad6 100644 --- a/protocols/IRCG/ircproto.cpp +++ b/protocols/IRCG/ircproto.cpp @@ -859,12 +859,7 @@ int __cdecl CIrcProto::SendMsg( HANDLE hContact, int flags, const char* pszSrc ) else result = mir_a2t_cp( pszSrc, codepage ); } else if ( flags & PREF_UTF ) { - #if defined( _UNICODE ) - mir_utf8decode( NEWSTR_ALLOCA(pszSrc), &result ); - #else - result = mir_strdup( pszSrc ); - mir_utf8decodecp( result, codepage, NULL ); - #endif + mir_utf8decode( NEWSTR_ALLOCA(pszSrc), &result ); } else result = mir_a2t_cp( pszSrc, codepage ); diff --git a/protocols/IRCG/options.cpp b/protocols/IRCG/options.cpp index 76f6a97afe..25cf9d38b1 100644 --- a/protocols/IRCG/options.cpp +++ b/protocols/IRCG/options.cpp @@ -66,7 +66,6 @@ void CIrcProto::ReadSettings( TDbSetting* sets, int count ) *( char** )ptr = NULL; } break; - #if defined( _UNICODE ) case DBVT_TCHAR: if ( !getTString( p->name, &dbv )) { if ( p->size != -1 ) { @@ -87,7 +86,6 @@ void CIrcProto::ReadSettings( TDbSetting* sets, int count ) else *( TCHAR** )ptr = mir_tstrdup( p->defStr ); } break; - #endif } } } void CIrcProto::WriteSettings( TDbSetting* sets, int count ) @@ -109,14 +107,12 @@ void CIrcProto::WriteSettings( TDbSetting* sets, int count ) setString( p->name, (char*)ptr ); break; - #if defined( _UNICODE ) case DBVT_TCHAR: if ( p->size == -1 ) setTString( p->name, *(TCHAR**)ptr ); else setTString( p->name, (TCHAR*)ptr ); break; - #endif } } } ///////////////////////////////////////////////////////////////////////////////////////// @@ -1098,12 +1094,8 @@ void COtherPrefsDlg::OnInitDialog() m_add.Enable( m_proto->m_perform ); m_delete.Enable( m_proto->m_perform ); - #if defined( _UNICODE ) - fnGetCPInfoEx = ( pfnGetCPInfoEx )GetProcAddress( GetModuleHandleA( "kernel32.dll" ), "GetCPInfoExW" ); - #else - fnGetCPInfoEx = ( pfnGetCPInfoEx )GetProcAddress( GetModuleHandleA( "kernel32.dll" ), "GetCPInfoExA" ); - #endif - + fnGetCPInfoEx = ( pfnGetCPInfoEx )GetProcAddress( GetModuleHandleA( "kernel32.dll" ), "GetCPInfoExW" ); + m_codepage.AddString( TranslateT("Default ANSI codepage"), CP_ACP ); if ( fnGetCPInfoEx == NULL ) m_codepage.AddString( TranslateT("UTF-8"), CP_UTF8 ); @@ -1118,10 +1110,7 @@ void COtherPrefsDlg::OnInitDialog() break; } } - #if !defined( _UNICODE ) - m_codepage.Enable( FALSE ); - #endif - + if ( m_proto->m_codepage == CP_UTF8 ) m_autodetect.Disable(); diff --git a/protocols/IRCG/tools.cpp b/protocols/IRCG/tools.cpp index f2424c5689..5044c12715 100644 --- a/protocols/IRCG/tools.cpp +++ b/protocols/IRCG/tools.cpp @@ -231,7 +231,6 @@ void __stdcall RemoveLinebreaks( CMString& Message ) Message.Delete(Message.GetLength()-2, 2); } -#if defined( _UNICODE ) String& __stdcall ReplaceString ( String& text, const char* replaceme, const char* newword ) { if ( !text.IsEmpty() && replaceme != NULL) { @@ -244,7 +243,6 @@ String& __stdcall ReplaceString ( String& text, const char* replaceme, const cha return text; } -#endif CMString& __stdcall ReplaceString ( CMString& text, const TCHAR* replaceme, const TCHAR* newword) { @@ -321,7 +319,6 @@ bool CIrcProto::IsChannel(const TCHAR* sName) return ( sChannelPrefixes.Find( sName[0] ) != -1 ); } -#if defined( _UNICODE ) String __stdcall GetWord(const char* text, int index) { if ( text && text[0] ) { @@ -358,7 +355,6 @@ bool CIrcProto::IsChannel(const char* sName) { return ( sChannelPrefixes.Find( sName[0] ) != -1 ); } -#endif TCHAR* __stdcall my_strstri(const TCHAR* s1, const TCHAR* s2) { diff --git a/protocols/IRCG/ui_utils.cpp b/protocols/IRCG/ui_utils.cpp index a7c6477e29..5e3a41fb87 100644 --- a/protocols/IRCG/ui_utils.cpp +++ b/protocols/IRCG/ui_utils.cpp @@ -1685,14 +1685,10 @@ TCHAR* CCtrlBase::GetText() char* CCtrlBase::GetTextA() { - #ifdef UNICODE - int length = GetWindowTextLength(m_hwnd) + 1; - char *result = (char *)mir_alloc(length * sizeof(char)); - GetWindowTextA(m_hwnd, result, length); - return result; - #else - return GetText(); - #endif + int length = GetWindowTextLength(m_hwnd) + 1; + char *result = (char *)mir_alloc(length * sizeof(char)); + GetWindowTextA(m_hwnd, result, length); + return result; } TCHAR* CCtrlBase::GetText(TCHAR *buf, int size) @@ -1704,13 +1700,9 @@ TCHAR* CCtrlBase::GetText(TCHAR *buf, int size) char* CCtrlBase::GetTextA(char *buf, int size) { - #ifdef UNICODE - GetWindowTextA(m_hwnd, buf, size); - buf[size-1] = 0; - return buf; - #else - return GetText(buf, size); - #endif + GetWindowTextA(m_hwnd, buf, size); + buf[size-1] = 0; + return buf; } int CCtrlBase::GetInt() diff --git a/protocols/IRCG/ui_utils.h b/protocols/IRCG/ui_utils.h index b8d6cc0eca..60566ce913 100644 --- a/protocols/IRCG/ui_utils.h +++ b/protocols/IRCG/ui_utils.h @@ -105,13 +105,8 @@ typedef struct tagLVSETINFOTIP int iItem; int iSubItem; } LVSETINFOTIP, *PLVSETINFOTIP; -#ifndef _UNICODE - #define LPLVCOLUMN LPLVCOLUMNA - #define LPLVITEM LPLVITEMA -#else - #define LPLVCOLUMN LPLVCOLUMNW - #define LPLVITEM LPLVITEMW -#endif +#define LPLVCOLUMN LPLVCOLUMNA +#define LPLVITEM LPLVITEMA #define LVN_BEGINSCROLL (LVN_FIRST-80) #define LVN_ENDSCROLL (LVN_FIRST-81) #define LVN_HOTTRACK (LVN_FIRST-21) diff --git a/protocols/IRCG/windows.cpp b/protocols/IRCG/windows.cpp index 79a1b8011f..6eef163d34 100644 --- a/protocols/IRCG/windows.cpp +++ b/protocols/IRCG/windows.cpp @@ -928,13 +928,9 @@ void CManagerDlg::OnClose() if ( !S.IsEmpty() && m_proto->IsConnected() ) { mir_sntprintf( temp, SIZEOF(temp), _T("Topic%s%s"), window, m_proto->m_info.sNetwork.c_str()); - #if defined( _UNICODE ) - char* p = mir_t2a(temp); - m_proto->setTString(p, S.c_str()); - mir_free(p); - #else - m_proto->setString(temp, S.c_str()); - #endif + char* p = mir_t2a(temp); + m_proto->setTString(p, S.c_str()); + mir_free(p); } DestroyWindow( m_hwnd); } @@ -1280,11 +1276,8 @@ void CManagerDlg::InitManager( int mode, const TCHAR* window ) TCHAR temp[1000]; mir_sntprintf(temp, SIZEOF(temp), _T("Topic%s%s"), window, m_proto->m_info.sNetwork.c_str()); - #if defined( _UNICODE ) - char* p = mir_t2a(temp); - #else - char* p = temp; - #endif + char* p = mir_t2a(temp); + DBVARIANT dbv; if ( !m_proto->getTString( p, &dbv )) { for ( int i = 0; i<5; i++ ) { @@ -1298,9 +1291,7 @@ void CManagerDlg::InitManager( int mode, const TCHAR* window ) } } DBFreeVariant(&dbv); } - #if defined( _UNICODE ) - mir_free(p); - #endif + mir_free(p); } if ( wi->pszTopic ) -- cgit v1.2.3