From 721aea0764451e985d575236205808bbef298244 Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Thu, 14 Jun 2012 11:13:37 +0000 Subject: one more "#ifsef Unicode" removal git-svn-id: http://svn.miranda-ng.org/main/trunk@409 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Scriver/chat/chat.h | 6 +-- plugins/Scriver/chat/log.c | 21 +-------- plugins/Scriver/chat/manager.c | 15 ++---- plugins/Scriver/chat/message.c | 45 ++---------------- plugins/Scriver/chat/services.c | 76 ++++++++++++------------------ plugins/Scriver/chat/tools.c | 101 ++++++++++++++++------------------------ plugins/Scriver/chat/window.c | 15 ++---- 7 files changed, 85 insertions(+), 194 deletions(-) (limited to 'plugins/Scriver/chat') diff --git a/plugins/Scriver/chat/chat.h b/plugins/Scriver/chat/chat.h index 283adcdecd..1c11ad223a 100644 --- a/plugins/Scriver/chat/chat.h +++ b/plugins/Scriver/chat/chat.h @@ -191,10 +191,8 @@ typedef struct SESSION_INFO_TYPE TCHAR* ptszStatusbarText; TCHAR* ptszTopic; - #if defined( _UNICODE ) - char* pszID; // ugly fix for returning static ANSI strings in GC_INFO - char* pszName; // just to fix a bug quickly, should die after porting IRC to Unicode - #endif + char* pszID; // ugly fix for returning static ANSI strings in GC_INFO + char* pszName; // just to fix a bug quickly, should die after porting IRC to Unicode int iType; int iFG; diff --git a/plugins/Scriver/chat/log.c b/plugins/Scriver/chat/log.c index 5887708957..7fcae3f870 100644 --- a/plugins/Scriver/chat/log.c +++ b/plugins/Scriver/chat/log.c @@ -208,11 +208,7 @@ static int Log_AppendRTF(LOGSTREAMDATA* streamData, BOOL simpleMode, char **buff else if (*line > 0 && *line < 128) { *d++ = (char) *line; } else { - #if defined( _UNICODE ) d += sprintf(d, "\\u%u ?", (WORD)*line); - #else - d += sprintf(d, "\\'%02x", (BYTE)*line); - #endif } } @@ -323,13 +319,12 @@ static void AddEventToBuffer(char **buffer, int *bufferEnd, int *bufferAlloced, if ( streamData->lin->ptszText ) { TCHAR *ptszTemp = NULL; TCHAR *ptszText = streamData->lin->ptszText; - #if defined( _UNICODE ) if (streamData->si->windowData.codePage != CP_ACP) { char *aText = t2acp(streamData->lin->ptszText, CP_ACP); ptszText = ptszTemp = a2tcp(aText, streamData->si->windowData.codePage); mir_free(aText); } - #endif + Log_AppendRTF( streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T("%s"), ptszText ); mir_free(ptszTemp); } @@ -416,13 +411,12 @@ static void AddEventToBufferIEView(TCHAR **buffer, int *bufferEnd, int *bufferAl if ( streamData->lin->ptszText ) { TCHAR *ptszTemp = NULL; TCHAR *ptszText = streamData->lin->ptszText; - #if defined( _UNICODE ) if (streamData->si->windowData.codePage != CP_ACP) { char *aText = t2acp(streamData->lin->ptszText, CP_ACP); ptszText = ptszTemp = a2tcp(aText, streamData->si->windowData.codePage); mir_free(aText); } - #endif + Log_AppendIEView( streamData, FALSE, buffer, bufferEnd, bufferAlloced, _T("%s"), ptszText ); mir_free(ptszTemp); } @@ -567,9 +561,7 @@ static void LogEventIEView(LOGSTREAMDATA *streamData, TCHAR *ptszNick) } ied.dwData |= g_Settings.ShowTime ? IEEDD_GC_SHOW_TIME : 0; ied.dwData |= IEEDD_GC_SHOW_ICON; -#if defined( _UNICODE ) ied.dwFlags = IEEDF_UNICODE_TEXT | IEEDF_UNICODE_NICK | IEEDF_UNICODE_TEXT2; -#endif ied.next = NULL; /* ied.color = event->color; @@ -881,15 +873,6 @@ char * Log_CreateRtfHeader(MODULEINFO * mi, SESSION_INFO* si) int charset = 0; BOOL forceCharset = FALSE; -#if !defined ( _UNICODE ) - if (si->windowData.codePage != CP_ACP) { - CHARSETINFO csi; - if(TranslateCharsetInfo((DWORD*)si->windowData.codePage, &csi, TCI_SRCCODEPAGE)) { - forceCharset = TRUE; - charset = csi.ciCharset; - } - } -#endif // guesstimate amount of memory for the RTF header bufferEnd = 0; bufferAlloced = 4096; diff --git a/plugins/Scriver/chat/manager.c b/plugins/Scriver/chat/manager.c index 62542fd14a..74595f3bc0 100644 --- a/plugins/Scriver/chat/manager.c +++ b/plugins/Scriver/chat/manager.c @@ -136,11 +136,9 @@ int SM_RemoveSession( const TCHAR* pszID, const char* pszModule) mir_free( pTemp->ptszStatusbarText ); mir_free( pTemp->ptszTopic ); mir_free( pTemp->pszHeader ); - #if defined( _UNICODE ) - mir_free( pTemp->pszID ); - mir_free( pTemp->pszName ); - #endif - + mir_free( pTemp->pszID ); + mir_free( pTemp->pszName ); + // delete commands tcmdlist_free(pTemp->windowData.cmdList); mir_free(pTemp); @@ -771,11 +769,8 @@ char* SM_GetUsers(SESSION_INFO* si) if ( pLen + nameLen + 2 > alloced ) p = mir_realloc( p, alloced += 4096 ); - #if !defined( _UNICODE ) - lstrcpy( p + pLen, utemp->pszUID ); - #else - WideCharToMultiByte( CP_ACP, 0, utemp->pszUID, -1, p + pLen, nameLen+1, 0, 0 ); - #endif + WideCharToMultiByte( CP_ACP, 0, utemp->pszUID, -1, p + pLen, nameLen+1, 0, 0 ); + lstrcpyA( p + pLen + nameLen, " " ); utemp = utemp->next; } diff --git a/plugins/Scriver/chat/message.c b/plugins/Scriver/chat/message.c index 2951cc3856..a6866941d2 100644 --- a/plugins/Scriver/chat/message.c +++ b/plugins/Scriver/chat/message.c @@ -86,9 +86,7 @@ TCHAR* DoRtfToTags( char* pszText, SESSION_INFO* si) char InsertThis[50]; BOOL bJustRemovedRTF = TRUE; BOOL bTextHasStarted = FALSE; - #if defined(_UNICODE) - TCHAR *ptszResult; - #endif + TCHAR *ptszResult; int iUcMode = 0; if ( !pszText ) @@ -157,11 +155,7 @@ TCHAR* DoRtfToTags( char* pszText, SESSION_INFO* si) bTextHasStarted = TRUE; bJustRemovedRTF = TRUE; iRemoveChars = 7; -#if defined(_UNICODE) strcpy(InsertThis, "\xE2\x80\xA2"); -#else - strcpy(InsertThis, "\x95"); -#endif } else if ( !memcmp(p1, "\\b", 2 )) { //bold bTextHasStarted = bJustRemovedRTF = TRUE; @@ -202,61 +196,37 @@ TCHAR* DoRtfToTags( char* pszText, SESSION_INFO* si) bTextHasStarted = TRUE; bJustRemovedRTF = TRUE; iRemoveChars = 7; -#if defined(_UNICODE) strcpy(InsertThis, "\xE2\x80\x93"); -#else - strcpy(InsertThis, "\x96"); -#endif } else if (!memcmp(p1, "\\emdash", 7)) { bTextHasStarted = TRUE; bJustRemovedRTF = TRUE; iRemoveChars = 7; -#if defined(_UNICODE) strcpy(InsertThis, "\xE2\x80\x94"); -#else - strcpy(InsertThis, "\x97"); -#endif } else if (!memcmp(p1, "\\lquote",7)) { bTextHasStarted = TRUE; bJustRemovedRTF = TRUE; iRemoveChars = 7; -#if defined(_UNICODE) strcpy(InsertThis, "\xE2\x80\x98"); -#else - strcpy(InsertThis, "\x91"); -#endif } else if (!memcmp(p1, "\\rquote",7)) { bTextHasStarted = TRUE; bJustRemovedRTF = TRUE; iRemoveChars = 7; -#if defined(_UNICODE) strcpy(InsertThis, "\xE2\x80\x99"); -#else - strcpy(InsertThis, "\x92"); -#endif } else if (!memcmp(p1, "\\ldblquote",10)) { bTextHasStarted = TRUE; bJustRemovedRTF = TRUE; iRemoveChars = 10; -#if defined(_UNICODE) strcpy(InsertThis, "\xe2\x80\x9c"); -#else - strcpy(InsertThis, "\""); -#endif } else if (!memcmp(p1, "\\rdblquote",10)) { bTextHasStarted = TRUE; bJustRemovedRTF = TRUE; iRemoveChars = 10; -#if defined(_UNICODE) strcpy(InsertThis, "\xe2\x80\x9d"); -#else - strcpy(InsertThis, "\""); -#endif } else if ( p1[1] == '\\' || p1[1] == '{' || p1[1] == '}' ) { // escaped characters bTextHasStarted = TRUE; @@ -268,11 +238,7 @@ TCHAR* DoRtfToTags( char* pszText, SESSION_INFO* si) bTextHasStarted = TRUE; bJustRemovedRTF = FALSE; iRemoveChars = 2; -#if defined(_UNICODE) strcpy(InsertThis, "\xC2\xA0"); -#else - strcpy(InsertThis, "\xA0"); -#endif } else if ( p1[1] == '\'' ) { // special character char tmp[4], *p3 = tmp; @@ -340,12 +306,7 @@ TCHAR* DoRtfToTags( char* pszText, SESSION_INFO* si) } mir_free(pIndex); - - #if !defined( _UNICODE ) - return pszText; - #else - mir_utf8decode(pszText, &ptszResult); - return ptszResult; - #endif + mir_utf8decode(pszText, &ptszResult); + return ptszResult; } diff --git a/plugins/Scriver/chat/services.c b/plugins/Scriver/chat/services.c index 1104aa262b..22afdfd389 100644 --- a/plugins/Scriver/chat/services.c +++ b/plugins/Scriver/chat/services.c @@ -117,20 +117,11 @@ static INT_PTR Service_GetInfo(WPARAM wParam,LPARAM lParam) if ( gci->Flags & TYPE ) gci->iType = si->iType; if ( gci->Flags & COUNT ) gci->iCount = si->nUsersInNicklist; if ( gci->Flags & USERS ) gci->pszUsers = SM_GetUsers(si); - - #if defined( _UNICODE ) - if ( si->dwFlags & GC_UNICODE ) { - if ( gci->Flags & ID ) gci->pszID = si->ptszID; - if ( gci->Flags & NAME ) gci->pszName = si->ptszName; - } - else { - if ( gci->Flags & ID ) gci->pszID = ( TCHAR* )si->pszID; - if ( gci->Flags & NAME ) gci->pszName = ( TCHAR* )si->pszName; - } - #else + if ( si->dwFlags & GC_UNICODE ) { if ( gci->Flags & ID ) gci->pszID = si->ptszID; if ( gci->Flags & NAME ) gci->pszName = si->ptszName; - #endif + } + LeaveCriticalSection(&cs); return 0; @@ -171,11 +162,6 @@ static INT_PTR Service_Register(WPARAM wParam, LPARAM lParam) if (gcr->cbSize != SIZEOF_STRUCT_GCREGISTER_V1) return GC_REGISTER_WRONGVER; - #ifndef _UNICODE - if (gcr->dwFlags & GC_UNICODE) - return GC_REGISTER_NOUNICODE; - #endif - EnterCriticalSection(&cs); mi = MM_AddModule( gcr->pszModule ); @@ -243,12 +229,12 @@ static INT_PTR Service_NewChat(WPARAM wParam, LPARAM lParam) si->iLogFilterFlags = (int)DBGetContactSettingDword(NULL, "Chat", "FilterFlags", 0x03E0); si->bFilterEnabled = DBGetContactSettingByte(NULL, "Chat", "FilterEnabled", 0); si->bNicklistEnabled = DBGetContactSettingByte(NULL, "Chat", "ShowNicklist", 1); - #if defined( _UNICODE ) - if ( !( gcw->dwFlags & GC_UNICODE )) { - si->pszID = mir_strdup( gcw->pszID ); - si->pszName = mir_strdup( gcw->pszName ); - } - #endif + + if ( !( gcw->dwFlags & GC_UNICODE )) { + si->pszID = mir_strdup( gcw->pszID ); + si->pszName = mir_strdup( gcw->pszName ); + } + if ( mi->bColor ) { si->iFG = 4; @@ -480,18 +466,16 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) EnterCriticalSection(&cs); - #if defined( _UNICODE ) - if ( !( gce->dwFlags & GC_UNICODE )) { - save_gce = *gce; - save_gcd = *gce->pDest; - gce->pDest->ptszID = a2tf( gce->pDest->ptszID, gce->dwFlags ); - gce->ptszUID = a2tf( gce->ptszUID, gce->dwFlags ); - gce->ptszNick = a2tf( gce->ptszNick, gce->dwFlags ); - gce->ptszStatus = a2tf( gce->ptszStatus, gce->dwFlags ); - gce->ptszText = a2tf( gce->ptszText, gce->dwFlags ); - gce->ptszUserInfo = a2tf( gce->ptszUserInfo, gce->dwFlags ); - } - #endif + if ( !( gce->dwFlags & GC_UNICODE )) { + save_gce = *gce; + save_gcd = *gce->pDest; + gce->pDest->ptszID = a2tf( gce->pDest->ptszID, gce->dwFlags ); + gce->ptszUID = a2tf( gce->ptszUID, gce->dwFlags ); + gce->ptszNick = a2tf( gce->ptszNick, gce->dwFlags ); + gce->ptszStatus = a2tf( gce->ptszStatus, gce->dwFlags ); + gce->ptszText = a2tf( gce->ptszText, gce->dwFlags ); + gce->ptszUserInfo = a2tf( gce->ptszUserInfo, gce->dwFlags ); + } // Do different things according to type of event switch(gcd->iType) { @@ -627,18 +611,16 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) LBL_Exit: LeaveCriticalSection(&cs); - #if defined( _UNICODE ) - if ( !( gce->dwFlags & GC_UNICODE )) { - mir_free((void*)gce->ptszText ); - mir_free((void*)gce->ptszNick ); - mir_free((void*)gce->ptszUID ); - mir_free((void*)gce->ptszStatus ); - mir_free((void*)gce->ptszUserInfo ); - mir_free((void*)gce->pDest->ptszID ); - *gce = save_gce; - *gce->pDest = save_gcd; - } - #endif + if ( !( gce->dwFlags & GC_UNICODE )) { + mir_free((void*)gce->ptszText ); + mir_free((void*)gce->ptszNick ); + mir_free((void*)gce->ptszUID ); + mir_free((void*)gce->ptszStatus ); + mir_free((void*)gce->ptszUserInfo ); + mir_free((void*)gce->pDest->ptszID ); + *gce = save_gce; + *gce->pDest = save_gcd; + } return iRetVal; } diff --git a/plugins/Scriver/chat/tools.c b/plugins/Scriver/chat/tools.c index 882d2b2c0a..d18115dfae 100644 --- a/plugins/Scriver/chat/tools.c +++ b/plugins/Scriver/chat/tools.c @@ -531,10 +531,8 @@ BOOL LogToFile(SESSION_INFO* si, GCEVENT * gce) if (hFile) { TCHAR szTemp[512], szTemp2[512]; TCHAR* pszNick = NULL; -#ifdef _UNICODE if (bFileJustCreated) fputws((const wchar_t*)"\377\376", hFile); //UTF-16 LE BOM == FF FE -#endif if ( gce->ptszNick ) { if ( g_Settings.LogLimitNames && lstrlen(gce->ptszNick) > 20 ) { lstrcpyn(szTemp2, gce->ptszNick, 20); @@ -652,9 +650,7 @@ BOOL LogToFile(SESSION_INFO* si, GCEVENT * gce) if (read > 0) { hFile = _tfopen(tszFile, _T("wb")); if (hFile) { -#ifdef _UNICODE fputws((const wchar_t*)"\377\376", hFile); //UTF-16 LE BOM == FF FE -#endif fwrite(pBufferTemp, 1, read, hFile); fclose(hFile); hFile = NULL; @@ -766,9 +762,7 @@ void DestroyGCMenu(HMENU *hMenu, int iIndex) BOOL DoEventHookAsync(HWND hwnd, const TCHAR* pszID, const char* pszModule, int iType, TCHAR* pszUID, TCHAR* pszText, DWORD dwItem) { - #if defined( _UNICODE ) - SESSION_INFO* si; - #endif + SESSION_INFO* si; GCHOOK* gch = (GCHOOK*)mir_alloc( sizeof( GCHOOK )); GCDEST* gcd = (GCDEST*)mir_alloc( sizeof( GCDEST )); @@ -776,23 +770,20 @@ BOOL DoEventHookAsync(HWND hwnd, const TCHAR* pszID, const char* pszModule, int memset( gcd, 0, sizeof( GCDEST )); replaceStrA( &gcd->pszModule, pszModule); - #if defined( _UNICODE ) - if (( si = SM_FindSession(pszID, pszModule)) == NULL ) - return FALSE; - - if ( !( si->dwFlags & GC_UNICODE )) { - gcd->pszID = t2a( pszID ); - gch->pszUID = t2a( pszUID ); - gch->pszText = t2a( pszText ); - } - else { - #endif - replaceStr( &gcd->ptszID, pszID ); - replaceStr( &gch->ptszUID, pszUID); - replaceStr( &gch->ptszText, pszText); - #if defined( _UNICODE ) - } - #endif + if (( si = SM_FindSession(pszID, pszModule)) == NULL ) + return FALSE; + + if ( !( si->dwFlags & GC_UNICODE )) { + gcd->pszID = t2a( pszID ); + gch->pszUID = t2a( pszUID ); + gch->pszText = t2a( pszText ); + } + else { + replaceStr( &gcd->ptszID, pszID ); + replaceStr( &gch->ptszUID, pszUID); + replaceStr( &gch->ptszText, pszText); + } + gcd->iType = iType; gch->dwData = dwItem; gch->pDest = gcd; @@ -802,30 +793,24 @@ BOOL DoEventHookAsync(HWND hwnd, const TCHAR* pszID, const char* pszModule, int BOOL DoEventHook(const TCHAR* pszID, const char* pszModule, int iType, const TCHAR* pszUID, const TCHAR* pszText, DWORD dwItem) { - #if defined( _UNICODE ) - SESSION_INFO* si; - #endif + SESSION_INFO* si; GCHOOK gch = {0}; GCDEST gcd = {0}; gcd.pszModule = (char*)pszModule; - #if defined( _UNICODE ) - if (( si = SM_FindSession(pszID, pszModule)) == NULL ) - return FALSE; - - if ( !( si->dwFlags & GC_UNICODE )) { - gcd.pszID = t2a( pszID ); - gch.pszUID = t2a( pszUID ); - gch.pszText = t2a( pszText ); - } - else { - #endif - gcd.ptszID = mir_tstrdup( pszID ); - gch.ptszUID = mir_tstrdup( pszUID ); - gch.ptszText = mir_tstrdup( pszText ); - #if defined( _UNICODE ) - } - #endif + if (( si = SM_FindSession(pszID, pszModule)) == NULL ) + return FALSE; + + if ( !( si->dwFlags & GC_UNICODE )) { + gcd.pszID = t2a( pszID ); + gch.pszUID = t2a( pszUID ); + gch.pszText = t2a( pszText ); + } + else { + gcd.ptszID = mir_tstrdup( pszID ); + gch.ptszUID = mir_tstrdup( pszUID ); + gch.ptszText = mir_tstrdup( pszText ); + } gcd.iType = iType; gch.dwData = dwItem; @@ -878,24 +863,20 @@ TCHAR* a2tf( const TCHAR* str, int flags ) if ( str == NULL ) return NULL; - #if defined( _UNICODE ) - if ( flags & GC_UNICODE ) - return mir_tstrdup( str ); - else { - int codepage = CallService( MS_LANGPACK_GETCODEPAGE, 0, 0 ); + if ( flags & GC_UNICODE ) + return mir_tstrdup( str ); + else { + int codepage = CallService( MS_LANGPACK_GETCODEPAGE, 0, 0 ); - int cbLen = MultiByteToWideChar( codepage, 0, (char*)str, -1, 0, 0 ); - TCHAR* result = ( TCHAR* )mir_alloc( sizeof(TCHAR)*( cbLen+1 )); - if ( result == NULL ) - return NULL; + int cbLen = MultiByteToWideChar( codepage, 0, (char*)str, -1, 0, 0 ); + TCHAR* result = ( TCHAR* )mir_alloc( sizeof(TCHAR)*( cbLen+1 )); + if ( result == NULL ) + return NULL; - MultiByteToWideChar( codepage, 0, (char*)str, -1, result, cbLen ); - result[ cbLen ] = 0; - return result; - } - #else - return mir_strdup( str ); - #endif + MultiByteToWideChar( codepage, 0, (char*)str, -1, result, cbLen ); + result[ cbLen ] = 0; + return result; + } } TCHAR* replaceStr( TCHAR** dest, const TCHAR* src ) diff --git a/plugins/Scriver/chat/window.c b/plugins/Scriver/chat/window.c index 1a11b234f3..cc49d7172c 100644 --- a/plugins/Scriver/chat/window.c +++ b/plugins/Scriver/chat/window.c @@ -339,11 +339,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, end = HIWORD(lResult); SendMessage(hwnd, EM_SETSEL, end, end); - #if defined( _UNICODE ) - gt.codepage = 1200; - #else - gt.codepage = CP_ACP; - #endif + gt.codepage = 1200; iLen = GetRichTextLength(hwnd, gt.codepage, TRUE); if (iLen >0) { TCHAR *pszName = NULL; @@ -1318,11 +1314,8 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) sid.cbSize = sizeof(sid); sid.szModule = SRMMMOD; sid.dwId = 0; - #if defined( _UNICODE ) sid.flags = 0; - #else - sid.flags = MBF_DISABLED; - #endif + ModifyStatusIcon((WPARAM)si->windowData.hContact, (LPARAM) &sid); // SendMessage(hwndDlg, GC_FIXTABICONS, 0, (LPARAM)si); } @@ -1900,9 +1893,7 @@ LABEL_SHOWWINDOW: DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_MESSAGE, NULL, ptszText, (LPARAM)NULL); mir_free(pszRtf); - #if defined( _UNICODE ) - mir_free(ptszText); - #endif + mir_free(ptszText); SetFocus(GetDlgItem(hwndDlg, IDC_CHAT_MESSAGE)); } break; -- cgit v1.2.3