From 08dc125be616458112368e7154b29d5d23f1126e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 19 Jul 2012 08:02:41 +0000 Subject: Unicode in status message plugins git-svn-id: http://svn.miranda-ng.org/main/trunk@1033 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/ExternalAPI/m_skin_eng.h | 16 +- plugins/ExternalAPI/m_statusplugins.h | 4 +- plugins/MyDetails/commons.h | 23 +- plugins/MyDetails/data.cpp | 327 ++++++--------------- plugins/MyDetails/data.h | 12 +- plugins/MyDetails/frame.cpp | 246 +++++++--------- plugins/MyDetails/mydetails.cpp | 287 +++++------------- plugins/MyDetails/mydetails.h | 25 -- plugins/MyDetails/mydetails.vcxproj | 29 +- plugins/MyDetails/mydetails.vcxproj.filters | 3 - plugins/MyDetails/options.cpp | 10 +- .../AdvancedAutoAway/advancedautoaway.cpp | 6 +- plugins/StatusPlugins/KeepStatus/keepstatus.cpp | 32 +- plugins/StatusPlugins/StartupStatus/options.cpp | 12 +- plugins/StatusPlugins/StartupStatus/profiles.cpp | 12 +- .../StatusPlugins/StartupStatus/startupstatus.cpp | 6 +- .../StatusPlugins/StartupStatus/startupstatus.h | 4 +- plugins/StatusPlugins/commonstatus.cpp | 119 +------- plugins/StatusPlugins/confirmdialog.cpp | 10 +- plugins/Utils/mir_memory.h | 2 +- plugins/Utils/mir_options.cpp | 42 +-- plugins/Utils/mir_smileys.cpp | 55 ++-- plugins/Utils/mir_smileys.h | 4 +- 23 files changed, 374 insertions(+), 912 deletions(-) delete mode 100644 plugins/MyDetails/mydetails.h diff --git a/plugins/ExternalAPI/m_skin_eng.h b/plugins/ExternalAPI/m_skin_eng.h index c099a28be7..c6e3e181d7 100644 --- a/plugins/ExternalAPI/m_skin_eng.h +++ b/plugins/ExternalAPI/m_skin_eng.h @@ -181,7 +181,7 @@ int __inline SkinDrawWindowBack(HWND hwndIn, HDC hdc, RECT * rcClip, char * obje rq.hDC=hdc; rq.rcDestRect=rc; rq.rcClipRect=*rcClip; - strncpy(rq.szObjectID,objectID,sizeof(rq.szObjectID)); + lstrcpynA(rq.szObjectID,objectID,sizeof(rq.szObjectID)); ///ske_Service_DrawGlyph((WPARAM)&rq,0); //$$$ return CallService(MS_SKIN_DRAWGLYPH,(WPARAM)&rq,0); } @@ -253,13 +253,13 @@ static BOOL __inline ScreenToClientRect(HWND hWnd, LPRECT lpRect) //} static int __inline SkinDrawGlyph(HDC hdc, RECT * rcSize, RECT * rcClip, char * objectID) { - SKINDRAWREQUEST rq; - if (!objectID) return 0; - rq.hDC=hdc; - rq.rcDestRect=*rcSize; - rq.rcClipRect=*rcClip; - strncpy(rq.szObjectID,objectID,sizeof(rq.szObjectID)); - return CallService(MS_SKIN_DRAWGLYPH,(WPARAM)&rq,0); + SKINDRAWREQUEST rq; + if (!objectID) return 0; + rq.hDC=hdc; + rq.rcDestRect=*rcSize; + rq.rcClipRect=*rcClip; + lstrcpynA(rq.szObjectID,objectID,sizeof(rq.szObjectID)); + return CallService(MS_SKIN_DRAWGLYPH,(WPARAM)&rq,0); } //#include "../hdr/modern_skin_selector.h" diff --git a/plugins/ExternalAPI/m_statusplugins.h b/plugins/ExternalAPI/m_statusplugins.h index 5139673c6a..34a3f1da90 100644 --- a/plugins/ExternalAPI/m_statusplugins.h +++ b/plugins/ExternalAPI/m_statusplugins.h @@ -25,7 +25,7 @@ typedef struct { int cbSize; char *szName; // pointer to protocol modulename - char *szMsg; // pointer to the status message (may be NULL) + TCHAR *szMsg; // pointer to the status message (may be NULL) WORD status; // the status WORD lastStatus;// last status TCHAR *tszAccName; @@ -133,7 +133,7 @@ typedef struct { // returns 0 #define MS_KS_ANNOUNCESTATUSCHANGE "KeepStatus/AnnounceStatusChange" -__inline static int announce_status_change(char *szProto, int newstatus, char *szMsg) { +__inline static int announce_status_change(char *szProto, int newstatus, TCHAR *szMsg) { PROTOCOLSETTINGEX ps; diff --git a/plugins/MyDetails/commons.h b/plugins/MyDetails/commons.h index cc176e193a..eeff18a681 100644 --- a/plugins/MyDetails/commons.h +++ b/plugins/MyDetails/commons.h @@ -28,10 +28,12 @@ Boston, MA 02111-1307, USA. #include #include #include + #include #include #include #include +#include #include #include #include @@ -45,7 +47,6 @@ Boston, MA 02111-1307, USA. #include #include -#include #include #include #include @@ -91,9 +92,6 @@ extern long status_msg_dialog_open; #define PS_GETMYNICKNAMEMAXLENGTH "/GetMyNicknameMaxLength" -#define MAX_REGS(_A_) ( sizeof(_A_) / sizeof(_A_[0]) ) - - // See if a protocol service exists __inline static int ProtoServiceExists(const char *szModule,const char *szService) { @@ -105,21 +103,14 @@ __inline static int ProtoServiceExists(const char *szModule,const char *szServic // Helper -static __inline int DRAW_TEXT(HDC hDC, LPCSTR lpString, int nCount, LPRECT lpRect, UINT uFormat, const char *protocol, +static __inline int DRAW_TEXT(HDC hDC, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT uFormat, const char *protocol, SmileysParseInfo parseInfo) { - if (opts.replace_smileys) - { - return Smileys_DrawText(hDC, lpString, nCount, lpRect, uFormat | (opts.resize_smileys ? DT_RESIZE_SMILEYS : 0), - opts.use_contact_list_smileys ? "clist" : protocol, parseInfo); - } - else - { + if (!opts.replace_smileys) return DrawText(hDC, lpString, nCount, lpRect, uFormat); - } + + return Smileys_DrawText(hDC, lpString, nCount, lpRect, uFormat | (opts.resize_smileys ? DT_RESIZE_SMILEYS : 0), + opts.use_contact_list_smileys ? "clist" : protocol, parseInfo); } - - - #endif // __COMMONS_H__ diff --git a/plugins/MyDetails/data.cpp b/plugins/MyDetails/data.cpp index 728e601a06..8a01c94c72 100644 --- a/plugins/MyDetails/data.cpp +++ b/plugins/MyDetails/data.cpp @@ -72,7 +72,7 @@ void DeInitProtocolData() Protocol::Protocol(const char *aName) { - lstrcpyn(name, aName, MAX_REGS(name)); + lstrcpynA(name, aName, SIZEOF(name)); description[0] = _T('\0'); nickname[0] = _T('\0'); @@ -91,7 +91,7 @@ Protocol::Protocol(const char *aName) caps = CallProtoService(name, PS_GETCAPS, PFLAGNUM_1, 0); valid = (caps & PF1_IM) == PF1_IM && strcmp(aName, "MetaContacts"); - if (!valid) + if ( !valid) return; can_have_listening_to = (ProtoServiceExists(name, PS_SET_LISTENINGTO) != 0); @@ -104,11 +104,11 @@ Protocol::Protocol(const char *aName) avatar_max_width = 0; avatar_max_height = 0; if (ProtoServiceExists(name, PS_GETMYAVATARMAXSIZE)) - { CallProtoService(name, PS_GETMYAVATARMAXSIZE, (WPARAM) &avatar_max_width, (LPARAM) &avatar_max_height); - } - CallProtoService(name, PS_GETNAME, sizeof(description),(LPARAM) description); + char tmp[100]; + CallProtoService(name, PS_GETNAME, SIZEOF(tmp), (LPARAM)tmp); + lstrcpyn(description, _A2T(tmp), SIZEOF(description)); can_set_nick = ProtoServiceExists(name, PS_SETMYNICKNAME) != FALSE; @@ -158,49 +158,49 @@ int Protocol::GetStatus() if (custom_status == 0) { - TCHAR *tmp = (char *) CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, status, GSMDF_TCHAR); - lcopystr(status_name, tmp, MAX_REGS(status_name)); + TCHAR *tmp = (TCHAR*) CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, status, GSMDF_TCHAR); + lcopystr(status_name, tmp, SIZEOF(status_name)); } else { DBVARIANT dbv; - TCHAR tmp[256] = "\0"; + TCHAR tmp[256]; tmp[0] = 0; if (custom_status_name != NULL && custom_status_name[0] != '\0' - && !DBGetContactSettingTString(0, name, custom_status_name, &dbv)) + && !DBGetContactSettingTString(0, name, _T2A(custom_status_name), &dbv)) { if (dbv.ptszVal != NULL && dbv.ptszVal[0] != _T('\0')) - lstrcpyn(tmp, dbv.ptszVal, MAX_REGS(tmp)); + lstrcpyn(tmp, dbv.ptszVal, SIZEOF(tmp)); else - lstrcpyn(tmp, TranslateTS(""), MAX_REGS(tmp)); + lstrcpyn(tmp, TranslateT(""), SIZEOF(tmp)); DBFreeVariant(&dbv); } else { - lstrcpyn(tmp, TranslateTS(""), MAX_REGS(tmp)); + lstrcpyn(tmp, TranslateT(""), SIZEOF(tmp)); } if (custom_status_message != NULL && custom_status_message[0] != '\0' - && !DBGetContactSettingTString(0, name, custom_status_message, &dbv)) + && !DBGetContactSettingTString(0, name, _T2A(custom_status_message), &dbv)) { if (dbv.ptszVal != NULL && dbv.ptszVal[0] != '\0') { int len = lstrlen(tmp); - if (len < MAX_REGS(tmp)) - lstrcpyn(&tmp[len], _T(": "), MAX_REGS(tmp) - len); + if (len < SIZEOF(tmp)) + lstrcpyn(&tmp[len], _T(": "), SIZEOF(tmp) - len); len += 2; - if (len < MAX_REGS(tmp)) - lstrcpyn(&tmp[len], dbv.ptszVal, MAX_REGS(tmp) - len); + if (len < SIZEOF(tmp)) + lstrcpyn(&tmp[len], dbv.ptszVal, SIZEOF(tmp) - len); } DBFreeVariant(&dbv); } - lcopystr(status_name, tmp, MAX_REGS(status_name)); + lcopystr(status_name, tmp, SIZEOF(status_name)); } return status; @@ -208,7 +208,7 @@ int Protocol::GetStatus() void Protocol::SetStatus(int aStatus) { - char status_msg[256]; + TCHAR status_msg[256]; if (ServiceExists(MS_CS_SETSTATUSEX)) { @@ -220,7 +220,7 @@ void Protocol::SetStatus(int aStatus) pCount = 0; CallService(MS_PROTO_ENUMPROTOCOLS,(WPARAM)&count,(LPARAM)&protos); - for(i=0;itype!=PROTOTYPE_PROTOCOL || CallProtoService(protos[i]->szName,PS_GETCAPS,PFLAGNUM_2,0)==0) continue; pCount += 1; } @@ -229,7 +229,7 @@ void Protocol::SetStatus(int aStatus) PROTOCOLSETTINGEX **pse = (PROTOCOLSETTINGEX **) mir_alloc0(pCount * sizeof(PROTOCOLSETTINGEX *)); - for(i = 0; i < pCount; i++) + for (i = 0; i < pCount; i++) { pse[i] = (PROTOCOLSETTINGEX *) mir_alloc0(sizeof(PROTOCOLSETTINGEX)); pse[i]->szName = ""; @@ -239,12 +239,12 @@ void Protocol::SetStatus(int aStatus) pse[0]->status = aStatus; pse[0]->szName = name; - GetStatusMsg(aStatus, status_msg, sizeof(status_msg)); + GetStatusMsg(aStatus, status_msg, SIZEOF(status_msg)); pse[0]->szMsg = status_msg; CallService(MS_CS_SETSTATUSEX, (WPARAM) &pse, 0); - for(i = 0; i < pCount; i++) + for (i = 0; i < pCount; i++) mir_free(pse[i]); mir_free(pse); } @@ -252,10 +252,9 @@ void Protocol::SetStatus(int aStatus) { CallProtoService(name, PS_SETSTATUS, aStatus, 0); - if (CanSetStatusMsg(aStatus)) - { - char status_msg[MS_MYDETAILS_GETMYSTATUSMESSAGE_BUFFER_SIZE]; - GetStatusMsg(aStatus, status_msg, sizeof(status_msg)); + if (CanSetStatusMsg(aStatus)) { + TCHAR status_msg[MS_MYDETAILS_GETMYSTATUSMESSAGE_BUFFER_SIZE]; + GetStatusMsg(aStatus, status_msg, SIZEOF(status_msg)); SetStatusMsg(aStatus, status_msg); } } @@ -276,9 +275,7 @@ bool Protocol::CanGetStatusMsg(int aStatus) bool Protocol::CanSetStatusMsg() { - return CanSetStatusMsg(GetStatus()) // <- Simple away handled by this one - || ServiceExists(MS_NAS_INVOKESTATUSWINDOW); - + return CanSetStatusMsg(GetStatus()); // <- Simple away handled by this one } bool Protocol::CanSetStatusMsg(int aStatus) @@ -286,152 +283,49 @@ bool Protocol::CanSetStatusMsg(int aStatus) return CanGetStatusMsg(aStatus); } -void Protocol::GetStatusMsg(int aStatus, char *msg, size_t msg_size) +void Protocol::GetStatusMsg(int aStatus, TCHAR *msg, size_t msg_size) { - if (!CanGetStatusMsg()) + if ( !CanGetStatusMsg()) { - lcopystr(msg, "", msg_size); + lcopystr(msg, _T(""), msg_size); return; } if (aStatus == status && ProtoServiceExists(name, PS_GETMYAWAYMSG) ) { - char *tmp = (char *) CallProtoService(name, PS_GETMYAWAYMSG, 0, 0); - lcopystr(msg, tmp == NULL ? "" : tmp, msg_size); + TCHAR *tmp = (TCHAR*) CallProtoService(name, PS_GETMYAWAYMSG, 0, SGMA_TCHAR); + lcopystr(msg, tmp == NULL ? _T("") : tmp, msg_size); } - else if (ServiceExists(MS_NAS_GETSTATE)) - { - NAS_PROTOINFO pi; - - ZeroMemory(&pi, sizeof(pi)); - pi.cbSize = sizeof(NAS_PROTOINFO); - pi.szProto = name; - pi.status = aStatus == status ? 0 : aStatus; - pi.szMsg = NULL; - - if (CallService(MS_NAS_GETSTATE, (WPARAM) &pi, 1) == 0) - { - if (pi.szMsg == NULL) - { - pi.szProto = NULL; - - if (CallService(MS_NAS_GETSTATE, (WPARAM) &pi, 1) == 0) - { - if (pi.szMsg != NULL) - { - lcopystr(msg, pi.szMsg, msg_size); - mir_free(pi.szMsg); - } - else lcopystr(msg, "", msg_size); - } - else lcopystr(msg, "", msg_size); - } - else // if (pi.szMsg != NULL) - { - lcopystr(msg, pi.szMsg, msg_size); - mir_free(pi.szMsg); - } - } - else lcopystr(msg, "", msg_size); - - if (ServiceExists(MS_VARS_FORMATSTRING)) - { - char *tmp = variables_parse(msg, NULL, NULL); - lcopystr(msg, tmp, msg_size); - variables_free(tmp); - } - } - // TODO: Remove when removing old NAS services support - else if (ServiceExists("NewAwaySystem/GetState")) - { - NAS_PROTOINFO pi, *pii; - - ZeroMemory(&pi, sizeof(pi)); - pi.cbSize = sizeof(NAS_PROTOINFO); - pi.szProto = name; - pi.status = aStatus == status ? 0 : aStatus; - pi.szMsg = NULL; - pii = π - - if (CallService("NewAwaySystem/GetState", (WPARAM) &pii, 1) == 0) - { - if (pi.szMsg == NULL) - { - pi.szProto = NULL; - - if (CallService("NewAwaySystem/GetState", (WPARAM) &pii, 1) == 0) - { - if (pi.szMsg != NULL) - { - lcopystr(msg, pi.szMsg, msg_size); - mir_free(pi.szMsg); - } - else lcopystr(msg, "", msg_size); - } - else lcopystr(msg, "", msg_size); - } - else // if (pi.szMsg != NULL) - { - lcopystr(msg, pi.szMsg, msg_size); - mir_free(pi.szMsg); - } - } - else lcopystr(msg, "", msg_size); - - if (ServiceExists(MS_VARS_FORMATSTRING)) - { - char *tmp = variables_parse(msg, NULL, NULL); - lcopystr(msg, tmp, msg_size); - variables_free(tmp); - } - } else if (ServiceExists(MS_AWAYMSG_GETSTATUSMSG)) { - char *tmp = (char *) CallService(MS_AWAYMSG_GETSTATUSMSG, (WPARAM)aStatus, 0); - + TCHAR *tmp = (TCHAR*) CallService(MS_AWAYMSG_GETSTATUSMSGT, (WPARAM)aStatus, 0); if (tmp != NULL) { lcopystr(msg, tmp, msg_size); mir_free(tmp); } - else lcopystr(msg, "", msg_size); + else lcopystr(msg, _T(""), msg_size); } } -char * Protocol::GetStatusMsg() +TCHAR* Protocol::GetStatusMsg() { - GetStatusMsg(status, status_message, sizeof(status_message)); + GetStatusMsg(status, status_message, SIZEOF(status_message)); return status_message; } -void Protocol::SetStatusMsg(const char *message) +void Protocol::SetStatusMsg(const TCHAR *message) { SetStatusMsg(GetStatus(), message); } -void Protocol::SetStatusMsg(int aStatus, const char *message) +void Protocol::SetStatusMsg(int aStatus, const TCHAR *message) { - if (!CanSetStatusMsg(aStatus)) + if ( !CanSetStatusMsg(aStatus)) return; - if (ServiceExists(MS_NAS_SETSTATE)) - { - NAS_PROTOINFO pi = {0}, *pii; - - pi.cbSize = sizeof(pi); - pi.szProto = name; - pi.szMsg = mir_strdup(message); - pi.status = aStatus; - - pii = π - - CallService(MS_NAS_SETSTATE, (WPARAM) &pii, 1); - } - else - { - CallProtoService(name, PS_SETAWAYMSG, (WPARAM)aStatus, (LPARAM)message); - } + CallProtoService(name, PS_SETAWAYMSG, (WPARAM)aStatus, (LPARAM)message); } bool Protocol::HasAvatar() @@ -443,10 +337,10 @@ bool Protocol::HasAvatar() bool Protocol::CanGetAvatar() { - if (!can_have_avatar) + if ( !can_have_avatar) return false; - if (!ServiceExists(MS_AV_GETMYAVATAR)) + if ( !ServiceExists(MS_AV_GETMYAVATAR)) return false; return true; @@ -455,7 +349,7 @@ bool Protocol::CanGetAvatar() void Protocol::GetAvatar() { // See if can get one - if (!CanGetAvatar()) + if ( !CanGetAvatar()) return; avatar_file[0] = '\0'; @@ -489,32 +383,30 @@ int Protocol::GetNickMaxLength() return MS_MYDETAILS_GETMYNICKNAME_BUFFER_SIZE; } -char * Protocol::GetNick() +TCHAR* Protocol::GetNick() { // See if can get one - if (!CanGetNick()) + if ( !CanGetNick()) return NULL; // Get it - CONTACTINFO ci; - ZeroMemory(&ci, sizeof(ci)); - ci.cbSize = sizeof(ci); - ci.hContact = NULL; - ci.szProto = name; - ci.dwFlag = CNF_DISPLAY; + CONTACTINFO ci = { 0 }; + ci.cbSize = sizeof(ci); + ci.hContact = NULL; + ci.szProto = name; + ci.dwFlag = CNF_DISPLAY; #ifdef UNICODE ci.dwFlag |= CNF_UNICODE; #endif - if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) & ci)) + if ( !CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) & ci)) { - // CNF_DISPLAY always returns a string type - lcopystr(nickname, ci.pszVal, MAX_REGS(nickname)); + // CNF_DISPLAY always returns a string type + lcopystr(nickname, ci.pszVal, SIZEOF(nickname)); mir_free(ci.pszVal); - } - else - lcopystr(nickname, "", MAX_REGS(nickname)); + } + else lcopystr(nickname, _T(""), SIZEOF(nickname)); return nickname; } @@ -526,10 +418,10 @@ bool Protocol::CanSetNick() } -void Protocol::SetNick(const char *nick) +void Protocol::SetNick(const TCHAR *nick) { // See if can get one - if (!CanSetNick()) + if ( !CanSetNick()) return; if (nick == NULL) @@ -546,12 +438,12 @@ bool Protocol::CanSetAvatar() CallService(MS_AV_CANSETMYAVATAR, (WPARAM) name, 0); } -void Protocol::SetAvatar(const char *file_name) +void Protocol::SetAvatar(const TCHAR *file_name) { - if (!CanSetAvatar()) + if ( !CanSetAvatar()) return; - CallService(MS_AV_SETMYAVATAR, (WPARAM) name, (LPARAM) file_name); + CallService(MS_AV_SETMYAVATART, (WPARAM) name, (LPARAM) file_name); } bool Protocol::CanGetListeningTo() @@ -571,31 +463,26 @@ bool Protocol::ListeningToEnabled() TCHAR * Protocol::GetListeningTo() { - if (!CanGetListeningTo()) + if ( !CanGetListeningTo()) { - lcopystr(listening_to, "", MAX_REGS(listening_to)); + lcopystr(listening_to, _T(""), SIZEOF(listening_to)); return listening_to; } DBVARIANT dbv = {0}; if (DBGetContactSettingTString(NULL, name, "ListeningTo", &dbv)) { - lcopystr(listening_to, "", MAX_REGS(listening_to)); + lcopystr(listening_to, _T(""), SIZEOF(listening_to)); return listening_to; } - lcopystr(listening_to, dbv.pszVal, MAX_REGS(listening_to)); - + lcopystr(listening_to, dbv.ptszVal, SIZEOF(listening_to)); DBFreeVariant(&dbv); - return listening_to; } - - // ProtocolDataArray Class ///////////////////////////////////////////////////////////////////////////// - ProtocolArray::ProtocolArray(int max_size) { buffer = (Protocol **) malloc(max_size * sizeof(Protocol*)); @@ -659,7 +546,7 @@ Protocol * ProtocolArray::Get(const char *name) bool ProtocolArray::CanSetStatusMsgPerProtocol() { - return ServiceExists(MS_NAS_INVOKESTATUSWINDOW) || ServiceExists(MS_SA_CHANGESTATUSMSG); + return ServiceExists(MS_SA_CHANGESTATUSMSG) != 0; } @@ -674,57 +561,48 @@ void ProtocolArray::GetAvatars() void ProtocolArray::GetStatusMsgs() { for ( int i = 0 ; i < buffer_len ; i++ ) - { buffer[i]->GetStatusMsg(); - } } void ProtocolArray::GetStatuses() { for ( int i = 0 ; i < buffer_len ; i++ ) - { buffer[i]->GetStatus(); - } } int ProtocolArray::GetGlobalStatus() { int status = CallService(MS_CLIST_GETSTATUSMODE, 0, 0); if (status == ID_STATUS_CONNECTING) - { status = ID_STATUS_OFFLINE; - } return status; } bool ProtocolArray::CanSetAvatars() { - return ServiceExists(MS_AV_SETMYAVATAR) != FALSE; + return ServiceExists(MS_AV_SETMYAVATART) != FALSE; } -void ProtocolArray::SetAvatars(const char *file_name) +void ProtocolArray::SetAvatars(const TCHAR *file_name) { - if (!CanSetAvatars()) + if ( !CanSetAvatars()) return; - CallService(MS_AV_SETMYAVATAR, NULL, (WPARAM) file_name); + CallService(MS_AV_SETMYAVATART, NULL, (WPARAM) file_name); } - -void ProtocolArray::SetNicks(const char *nick) +void ProtocolArray::SetNicks(const TCHAR *nick) { if (nick == NULL || nick[0] == '\0') return; - lstrcpyn(default_nick, nick, sizeof(default_nick)); + lstrcpyn(default_nick, nick, SIZEOF(default_nick)); - DBWriteContactSettingString(0, MODULE_NAME, SETTING_DEFAULT_NICK, nick); + DBWriteContactSettingTString(0, MODULE_NAME, SETTING_DEFAULT_NICK, nick); for ( int i = 0 ; i < buffer_len ; i++ ) - { buffer[i]->SetNick(default_nick); - } } @@ -733,82 +611,61 @@ void ProtocolArray::SetStatus(int aStatus) CallService(MS_CLIST_SETSTATUSMODE, aStatus, 0); } -void ProtocolArray::SetStatusMsgs(const char *message) +void ProtocolArray::SetStatusMsgs(const TCHAR *message) { for (int i = ID_STATUS_OFFLINE ; i <= ID_STATUS_IDLE; i++) - { SetStatusMsgs(i, message); - } } -void ProtocolArray::SetStatusMsgs(int status, const char *message) +void ProtocolArray::SetStatusMsgs(int status, const TCHAR *message) { - DBWriteContactSettingString(NULL,"SRAway",StatusModeToDbSetting(status,"Msg"),message); - if (!DBGetContactSettingByte(NULL,"SRAway",StatusModeToDbSetting(status,"UsePrev"),0)) - { - // Save default also - DBWriteContactSettingString(NULL,"SRAway",StatusModeToDbSetting(status,"Default"),message); - } + DBWriteContactSettingTString(NULL,"SRAway",StatusModeToDbSetting(status,"Msg"),message); + + // Save default also + if ( !DBGetContactSettingByte(NULL,"SRAway",StatusModeToDbSetting(status,"UsePrev"),0)) + DBWriteContactSettingTString(NULL,"SRAway",StatusModeToDbSetting(status,"Default"),message); for ( int i = 0 ; i < buffer_len ; i++ ) - { if (buffer[i]->status == status) buffer[i]->SetStatusMsg(status, message); - } } - void ProtocolArray::GetDefaultNick() { DBVARIANT dbv; - - if (!DBGetContactSettingTString(0, MODULE_NAME, SETTING_DEFAULT_NICK, &dbv)) - { - lstrcpyn(default_nick, dbv.pszVal, sizeof(default_nick)); + if ( !DBGetContactSettingTString(0, MODULE_NAME, SETTING_DEFAULT_NICK, &dbv)) { + lstrcpyn(default_nick, dbv.ptszVal, SIZEOF(default_nick)); DBFreeVariant(&dbv); } - else - { - default_nick[0] = '\0'; - } + else default_nick[0] = '\0'; } void ProtocolArray::GetDefaultAvatar() { DBVARIANT dbv; - - if (!DBGetContactSettingTString(0, "ContactPhoto", "File", &dbv)) - { - lstrcpyn(default_avatar_file, dbv.pszVal, sizeof(default_avatar_file)); + if ( !DBGetContactSettingTString(0, "ContactPhoto", "File", &dbv)) { + lstrcpyn(default_avatar_file, dbv.ptszVal, SIZEOF(default_avatar_file)); DBFreeVariant(&dbv); } - else - { - default_avatar_file[0] = '\0'; - } + else default_avatar_file[0] = '\0'; } -char * ProtocolArray::GetDefaultStatusMsg() +TCHAR* ProtocolArray::GetDefaultStatusMsg() { return GetDefaultStatusMsg(CallService(MS_CLIST_GETSTATUSMODE, 0, 0)); } -char * ProtocolArray::GetDefaultStatusMsg(int status) +TCHAR* ProtocolArray::GetDefaultStatusMsg(int status) { default_status_message[0] = '\0'; - if (ServiceExists(MS_AWAYMSG_GETSTATUSMSG)) - { + if (ServiceExists(MS_AWAYMSG_GETSTATUSMSG)) { if (status == ID_STATUS_CONNECTING) - { status = ID_STATUS_OFFLINE; - } - - char *tmp = (char *) CallService(MS_AWAYMSG_GETSTATUSMSG, (WPARAM)status, 0); - if (tmp != NULL) - { - lstrcpyn(default_status_message, tmp, sizeof(default_status_message)); + TCHAR *tmp = (TCHAR*) CallService(MS_AWAYMSG_GETSTATUSMSGT, (WPARAM)status, 0); + if (tmp != NULL) { + lstrcpyn(default_status_message, tmp, SIZEOF(default_status_message)); mir_free(tmp); } } @@ -832,7 +689,7 @@ bool ProtocolArray::ListeningToEnabled() static char *StatusModeToDbSetting(int status,const char *suffix) { - char *prefix; + char *prefix; static char str[64]; switch(status) { diff --git a/plugins/MyDetails/data.h b/plugins/MyDetails/data.h index 4ae35dbce7..3ae7b024e5 100644 --- a/plugins/MyDetails/data.h +++ b/plugins/MyDetails/data.h @@ -39,7 +39,7 @@ protected: public: // Name of protocol char name[256]; - char description[256]; + TCHAR description[256]; TCHAR nickname[256]; TCHAR status_name[256]; TCHAR *custom_status_name; @@ -119,8 +119,8 @@ public: int GetSize(); void Add(Protocol *p); - Protocol * Get(int i); - Protocol * Get(const char *name); + Protocol* Get(int i); + Protocol* Get(const char *name); void GetAvatars(); bool CanSetAvatars(); @@ -135,14 +135,14 @@ public: void GetStatusMsgs(); void GetStatuses(); - int GetGlobalStatus(); + int GetGlobalStatus(); bool CanSetStatusMsgPerProtocol(); void GetDefaultNick(); // Copy to cache void GetDefaultAvatar(); // Copy to cache - TCHAR * GetDefaultStatusMsg(); // Copy to cache - TCHAR * GetDefaultStatusMsg(int status); + TCHAR* GetDefaultStatusMsg(); // Copy to cache + TCHAR* GetDefaultStatusMsg(int status); bool CanSetListeningTo(); bool ListeningToEnabled(); diff --git a/plugins/MyDetails/frame.cpp b/plugins/MyDetails/frame.cpp index 7610da8f32..2afae69561 100644 --- a/plugins/MyDetails/frame.cpp +++ b/plugins/MyDetails/frame.cpp @@ -28,8 +28,8 @@ Boston, MA 02111-1307, USA. #define WINDOW_NAME_PREFIX "mydetails_window" -#define WINDOW_CLASS_NAME "MyDetailsFrame" -#define CONTAINER_CLASS_NAME "MyDetailsFrameContainer" +#define WINDOW_CLASS_NAME _T("MyDetailsFrame") +#define CONTAINER_CLASS_NAME _T("MyDetailsFrameContainer") #define ID_FRAME_TIMER 1011 #define ID_RECALC_TIMER 1012 @@ -39,9 +39,9 @@ Boston, MA 02111-1307, USA. #define IDC_HAND MAKEINTRESOURCE(32649) -#define DEFAULT_NICKNAME "" -#define DEFAULT_STATUS_MESSAGE "" -#define DEFAULT_LISTENING_TO "" +#define DEFAULT_NICKNAME _T("") +#define DEFAULT_STATUS_MESSAGE _T("") +#define DEFAULT_LISTENING_TO _T("") // Messages @@ -229,19 +229,19 @@ int CreateFrame() ZeroMemory(&font_id[i], sizeof(font_id[i])); font_id[i].cbSize = sizeof(FontID); - strncpy(font_id[i].group, Translate("My Details"), sizeof(font_id[i].group)); - strncpy(font_id[i].name, Translate(font_names[i]), sizeof(font_id[i].name)); - strncpy(font_id[i].dbSettingsGroup, MODULE_NAME, sizeof(font_id[i].dbSettingsGroup)); + strncpy(font_id[i].group, Translate("My Details"), SIZEOF(font_id[i].group)); + strncpy(font_id[i].name, Translate(font_names[i]), SIZEOF(font_id[i].name)); + strncpy(font_id[i].dbSettingsGroup, MODULE_NAME, SIZEOF(font_id[i].dbSettingsGroup)); char tmp[128]; mir_snprintf(tmp, sizeof(tmp), "%sFont", font_names[i]); - strncpy(font_id[i].prefix, tmp, sizeof(font_id[i].prefix)); + strncpy(font_id[i].prefix, tmp, SIZEOF(font_id[i].prefix)); font_id[i].deffontsettings.colour = font_colors[i]; font_id[i].deffontsettings.size = -MulDiv(font_sizes[i], GetDeviceCaps(hdc, LOGPIXELSY), 72); font_id[i].deffontsettings.style = font_styles[i]; font_id[i].deffontsettings.charset = DEFAULT_CHARSET; - strncpy(font_id[i].deffontsettings.szFace, "Tahoma", sizeof(font_id[i].deffontsettings.szFace)); + strncpy(font_id[i].deffontsettings.szFace, "Tahoma", SIZEOF(font_id[i].deffontsettings.szFace)); font_id[i].order = i; font_id[i].flags = FIDF_DEFAULTVALID; FontRegister(&font_id[i]); @@ -267,7 +267,7 @@ int CreateFrame() if (ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) { - hwnd_frame = CreateWindow(WINDOW_CLASS_NAME, Translate("My Details"), + hwnd_frame = CreateWindow(WINDOW_CLASS_NAME, TranslateT("My Details"), WS_CHILD | WS_VISIBLE, 0,0,10,10, (HWND)CallService(MS_CLUI_GETHWND, 0, 0), NULL, hInst, NULL); @@ -316,11 +316,11 @@ int CreateFrame() wndclass.lpszClassName = CONTAINER_CLASS_NAME; RegisterClass(&wndclass); - hwnd_container = CreateWindowEx(WS_EX_TOOLWINDOW, CONTAINER_CLASS_NAME, Translate("My Details"), + hwnd_container = CreateWindowEx(WS_EX_TOOLWINDOW, CONTAINER_CLASS_NAME, TranslateT("My Details"), (WS_THICKFRAME | WS_CAPTION | WS_SYSMENU) & ~WS_VISIBLE, 0,0,200,130, (HWND)CallService(MS_CLUI_GETHWND, 0, 0), NULL, hInst, NULL); - hwnd_frame = CreateWindow(WINDOW_CLASS_NAME, Translate("My Details"), + hwnd_frame = CreateWindow(WINDOW_CLASS_NAME, TranslateT("My Details"), WS_CHILD | WS_VISIBLE, 0,0,10,10, hwnd_container, NULL, hInst, NULL); @@ -424,7 +424,7 @@ BOOL ScreenToClient(HWND hWnd, LPRECT lpRect) ret = ScreenToClient(hWnd, &pt); - if (!ret) return ret; + if ( !ret) return ret; lpRect->left = pt.x; lpRect->top = pt.y; @@ -472,7 +472,7 @@ RECT GetRect(HDC hdc, RECT rc, SIZE s, UINT uFormat, int next_top, int text_left uFormat &= ~DT_END_ELLIPSIS; RECT rc_tmp = rc; - DrawText(hdc, " ...", 4, &rc_tmp, DT_CALCRECT | uFormat); + DrawText(hdc, _T(" ..."), 4, &rc_tmp, DT_CALCRECT | uFormat); s.cx += rc_tmp.right - rc_tmp.left; } @@ -509,13 +509,13 @@ RECT GetRect(HDC hdc, RECT rc, SIZE s, UINT uFormat, int next_top, int text_left return r; } -RECT GetRect(HDC hdc, RECT rc, const char *text, const char *def_text, Protocol *proto, UINT uFormat, +RECT GetRect(HDC hdc, RECT rc, const TCHAR *text, const TCHAR *def_text, Protocol *proto, UINT uFormat, int next_top, int text_left, bool smileys = true, bool frame = true, bool end_elipsis_on_frame = true) { - const char *tmp; + const TCHAR *tmp; if (text[0] == '\0') - tmp = Translate(def_text); + tmp = TranslateTS(def_text); else tmp = text; @@ -525,16 +525,16 @@ RECT GetRect(HDC hdc, RECT rc, const char *text, const char *def_text, Protocol RECT r_tmp = rc; // Only first line - char *tmp2 = _strdup(tmp); - char *pos = strchr(tmp2, '\r'); + TCHAR *tmp2 = _tcsdup(tmp); + TCHAR *pos = _tcschr(tmp2, '\r'); if (pos != NULL) pos[0] = '\0'; - pos = strchr(tmp2, '\n'); + pos = _tcschr(tmp2, '\n'); if (pos != NULL) pos[0] = '\0'; if (smileys) - DRAW_TEXT(hdc, tmp2, strlen(tmp2), &r_tmp, uFormat | DT_CALCRECT, proto->name, NULL); + DRAW_TEXT(hdc, tmp2, _tcslen(tmp2), &r_tmp, uFormat | DT_CALCRECT, proto->name, NULL); else - DrawText(hdc, tmp2, strlen(tmp2), &r_tmp, uFormat | DT_CALCRECT); + DrawText(hdc, tmp2, _tcslen(tmp2), &r_tmp, uFormat | DT_CALCRECT); free(tmp2); @@ -771,7 +771,7 @@ void CalcRectangles(HWND hwnd) } // Fit to image proportions - if (!opts.draw_avatar_allow_to_grow) + if ( !opts.draw_avatar_allow_to_grow) { if (width > bmp.bmWidth) width = bmp.bmWidth; @@ -780,7 +780,7 @@ void CalcRectangles(HWND hwnd) height = bmp.bmHeight; } - if (!opts.resize_frame && height * bmp.bmWidth / bmp.bmHeight <= width) + if ( !opts.resize_frame && height * bmp.bmWidth / bmp.bmHeight <= width) { width = height * bmp.bmWidth / bmp.bmHeight; } @@ -838,7 +838,7 @@ void CalcRectangles(HWND hwnd) tmp_r.right -= 2 * ICON_SIZE; } - data->proto_rect = GetRect(hdc, tmp_r, proto->description, "", proto, uFormat, + data->proto_rect = GetRect(hdc, tmp_r, proto->description, _T(""), proto, uFormat, next_top, tmp_text_left, false, true, false); @@ -906,7 +906,7 @@ void CalcRectangles(HWND hwnd) // Text size RECT r_tmp = r; - DrawText(hdc, proto->status_name, strlen(proto->status_name), &r_tmp, + DrawText(hdc, proto->status_name, _tcslen(proto->status_name), &r_tmp, DT_CALCRECT | (uFormat & ~DT_END_ELLIPSIS)); SIZE s; @@ -1009,7 +1009,7 @@ void CalcRectangles(HWND hwnd) // Text size RECT r_tmp = r; - DrawText(hdc, proto->listening_to, strlen(proto->listening_to), &r_tmp, + DrawText(hdc, proto->listening_to, _tcslen(proto->listening_to), &r_tmp, DT_CALCRECT | (uFormat & ~DT_END_ELLIPSIS)); SIZE s; @@ -1108,23 +1108,23 @@ finish: HBITMAP CreateBitmap32(int cx, int cy) { - BITMAPINFO RGB32BitsBITMAPINFO; - UINT * ptPixels; - HBITMAP DirectBitmap; - - ZeroMemory(&RGB32BitsBITMAPINFO,sizeof(BITMAPINFO)); - RGB32BitsBITMAPINFO.bmiHeader.biSize=sizeof(BITMAPINFOHEADER); - RGB32BitsBITMAPINFO.bmiHeader.biWidth=cx;//bm.bmWidth; - RGB32BitsBITMAPINFO.bmiHeader.biHeight=cy;//bm.bmHeight; - RGB32BitsBITMAPINFO.bmiHeader.biPlanes=1; - RGB32BitsBITMAPINFO.bmiHeader.biBitCount=32; - - DirectBitmap = CreateDIBSection(NULL, - (BITMAPINFO *)&RGB32BitsBITMAPINFO, - DIB_RGB_COLORS, - (void **)&ptPixels, - NULL, 0); - return DirectBitmap; + BITMAPINFO RGB32BitsBITMAPINFO; + UINT * ptPixels; + HBITMAP DirectBitmap; + + ZeroMemory(&RGB32BitsBITMAPINFO,sizeof(BITMAPINFO)); + RGB32BitsBITMAPINFO.bmiHeader.biSize=sizeof(BITMAPINFOHEADER); + RGB32BitsBITMAPINFO.bmiHeader.biWidth=cx;//bm.bmWidth; + RGB32BitsBITMAPINFO.bmiHeader.biHeight=cy;//bm.bmHeight; + RGB32BitsBITMAPINFO.bmiHeader.biPlanes=1; + RGB32BitsBITMAPINFO.bmiHeader.biBitCount=32; + + DirectBitmap = CreateDIBSection(NULL, + (BITMAPINFO *)&RGB32BitsBITMAPINFO, + DIB_RGB_COLORS, + (void **)&ptPixels, + NULL, 0); + return DirectBitmap; } void EraseBackground(HWND hwnd, HDC hdc) @@ -1137,21 +1137,20 @@ HBITMAP CreateBitmap32(int cx, int cy) DeleteObject(hB); } -void DrawTextWithRect(HDC hdc, const char *text, const char *def_text, RECT rc, UINT uFormat, +void DrawTextWithRect(HDC hdc, const TCHAR *text, const TCHAR *def_text, RECT rc, UINT uFormat, bool mouse_over, Protocol *proto, bool replace_smileys = true) { - const char *tmp; - + const TCHAR *tmp; if (text[0] == '\0') - tmp = Translate(def_text); + tmp = TranslateTS(def_text); else tmp = text; // Only first line - char *tmp2 = _strdup(tmp); - char *pos = strchr(tmp2, '\r'); + TCHAR *tmp2 = _tcsdup(tmp); + TCHAR *pos = _tcsrchr(tmp2, '\r'); if (pos != NULL) pos[0] = '\0'; - pos = strchr(tmp2, '\n'); + pos = _tcschr(tmp2, '\n'); if (pos != NULL) pos[0] = '\0'; @@ -1172,7 +1171,7 @@ void DrawTextWithRect(HDC hdc, const char *text, const char *def_text, RECT rc, uFormat &= ~DT_END_ELLIPSIS; rc_tmp = r; - text_height = DrawText(hdc, " ...", 4, &rc_tmp, DT_CALCRECT | uFormat); + text_height = DrawText(hdc, _T(" ..."), 4, &rc_tmp, DT_CALCRECT | uFormat); rc_tmp.top += (r.bottom - r.top - text_height) >> 1; rc_tmp.bottom = rc_tmp.top + text_height; @@ -1193,13 +1192,13 @@ void DrawTextWithRect(HDC hdc, const char *text, const char *def_text, RECT rc, } if (replace_smileys) - DRAW_TEXT(hdc, tmp2, strlen(tmp2), &r, uFormat, proto->name, NULL); + DRAW_TEXT(hdc, tmp2, _tcslen(tmp2), &r, uFormat, proto->name, NULL); else - DrawText(hdc, tmp2, strlen(tmp2), &r, uFormat); + DrawText(hdc, tmp2, _tcslen(tmp2), &r, uFormat); if (mouse_over) { - DrawText(hdc, " ...", 4, &rc_tmp, uFormat); + DrawText(hdc, _T(" ..."), 4, &rc_tmp, uFormat); } SelectClipRgn(hdc, NULL); @@ -1277,7 +1276,6 @@ void Draw(HWND hwnd, HDC hdc_orig) AVATARDRAWREQUEST adr = {0}; - adr.cbSize = sizeof(AVATARDRAWREQUEST); adr.hTargetDC = hdc; adr.rcDraw = data->img_rect; @@ -1361,7 +1359,7 @@ void Draw(HWND hwnd, HDC hdc_orig) SelectObject(hdc, hFont[FONT_PROTO]); SetTextColor(hdc, font_colour[FONT_PROTO]); - DrawText(hdc, proto->description, strlen(proto->description), &rr, uFormat); + DrawText(hdc, proto->description, _tcslen(proto->description), &rr, uFormat); // Clipping rgn SelectClipRgn(hdc, NULL); @@ -1411,7 +1409,7 @@ void Draw(HWND hwnd, HDC hdc_orig) SelectObject(hdc, hFont[FONT_STATUS]); SetTextColor(hdc, font_colour[FONT_STATUS]); - DrawText(hdc, proto->status_name, strlen(proto->status_name), &rc, uFormat); + DrawText(hdc, proto->status_name, _tcslen(proto->status_name), &rc, uFormat); SelectClipRgn(hdc, NULL); DeleteObject(rgn); @@ -1486,7 +1484,7 @@ void Draw(HWND hwnd, HDC hdc_orig) SelectObject(hdc, hFont[FONT_LISTENING_TO]); SetTextColor(hdc, font_colour[FONT_LISTENING_TO]); - DrawText(hdc, proto->listening_to, strlen(proto->listening_to), &rc, uFormat); + DrawText(hdc, proto->listening_to, _tcslen(proto->listening_to), &rc, uFormat); SelectClipRgn(hdc, NULL); DeleteObject(rgn); @@ -1515,7 +1513,7 @@ void MakeHover(HWND hwnd, bool draw, bool *hover, POINT *p, RECT *r) { if (draw && p != NULL && r != NULL && InsideRect(p, r)) { - if (!*hover) + if ( !*hover) { *hover = true; @@ -1574,26 +1572,19 @@ void ShowProtocolStatusMenu(HWND hwnd, MyDetailsFrameData *data, Protocol *proto mii.cbSize = sizeof(mii); if(!IsWinVer98Plus()) - { mii.fMask = MIIM_TYPE; - } else - { mii.fMask = MIIM_STRING; - } GetMenuItemInfo(menu, i, TRUE, &mii); - if (mii.cch != 0) - { + if (mii.cch != 0) { mii.cch++; - mii.dwTypeData = (char *)malloc(sizeof(char) * mii.cch); + mii.dwTypeData = (TCHAR*)malloc(sizeof(TCHAR) * mii.cch); GetMenuItemInfo(menu, i, TRUE, &mii); - if (strcmp(mii.dwTypeData, proto->description) == 0) - { + if ( _tcscmp(mii.dwTypeData, proto->description) == 0) submenu = GetSubMenu(menu, i); - } free(mii.dwTypeData); } @@ -1607,29 +1598,6 @@ void ShowProtocolStatusMenu(HWND hwnd, MyDetailsFrameData *data, Protocol *proto if (submenu != NULL) { - /* - // Remove the first itens (protocol name and separator) - int to_remove = 0; - for(; to_remove < 5; to_remove++) - { - MENUITEMINFO mii = {0}; - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_TYPE; - GetMenuItemInfo(submenu, to_remove, TRUE, &mii); - - if (mii.fType == MFT_SEPARATOR) - break; - } - - if (to_remove < 5) - { - submenu = CopyMenu(submenu); - - for(int i = 0; i <= to_remove; i++) - RemoveMenu(submenu, i, MF_BYPOSITION); - } - */ - if (opts.draw_text_align_right) p.x = data->status_rect.right; else @@ -1662,7 +1630,7 @@ void ShowProtocolStatusMenu(HWND hwnd, MyDetailsFrameData *data, Protocol *proto DWORD flags = CallProtoService(proto->name, PS_GETCAPS, PFLAGNUM_2,0); for ( int i = GetMenuItemCount(submenu) -1 ; i >= 0 ; i-- ) { - if (!(flags & statusModePf2List[i])) + if ( !(flags & statusModePf2List[i])) { // Hide menu RemoveMenu(submenu, i, MF_BYPOSITION); @@ -1693,8 +1661,8 @@ void ShowListeningToMenu(HWND hwnd, MyDetailsFrameData *data, Protocol *proto, P CallService(MS_LANGPACK_TRANSLATEMENU,(WPARAM)submenu,0); // Add this proto to menu - char tmp[128]; - mir_snprintf(tmp, sizeof(tmp), Translate("Enable Listening To for %s"), proto->description); + TCHAR tmp[128]; + mir_sntprintf(tmp, SIZEOF(tmp), TranslateT("Enable Listening To for %s"), proto->description); MENUITEMINFO mii = {0}; mii.cbSize = sizeof(mii); @@ -1702,10 +1670,10 @@ void ShowListeningToMenu(HWND hwnd, MyDetailsFrameData *data, Protocol *proto, P mii.fType = MFT_STRING; mii.fState = proto->ListeningToEnabled() ? MFS_CHECKED : 0; mii.dwTypeData = tmp; - mii.cch = strlen(tmp); + mii.cch = _tcslen(tmp); mii.wID = 1; - if (!proto->CanSetListeningTo()) + if ( !proto->CanSetListeningTo()) { mii.fState |= MFS_DISABLED; } @@ -1717,7 +1685,7 @@ void ShowListeningToMenu(HWND hwnd, MyDetailsFrameData *data, Protocol *proto, P mii.fMask = MIIM_STATE; mii.fState = protocols->ListeningToEnabled() ? MFS_CHECKED : 0; - if (!protocols->CanSetListeningTo()) + if ( !protocols->CanSetListeningTo()) { mii.fState |= MFS_DISABLED; } @@ -1831,7 +1799,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar if (wParam == ID_FRAME_TIMER) { - if (!data->showing_menu) + if ( !data->showing_menu) CallService(MS_MYDETAILS_SHOWNEXTPROTOCOL, 0, 0); } else if (wParam == ID_RECALC_TIMER) @@ -1936,7 +1904,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar mii.fMask = MIIM_ID | MIIM_TYPE; mii.fType = MFT_STRING; mii.dwTypeData = protocols->Get(i)->description; - mii.cch = strlen(protocols->Get(i)->description); + mii.cch = _tcslen(protocols->Get(i)->description); mii.wID = i + 1; if (i == data->protocol_number) @@ -2001,18 +1969,18 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar CallService(MS_LANGPACK_TRANSLATEMENU,(WPARAM)submenu,0); // Add this proto to menu - char tmp[128]; - mir_snprintf(tmp, sizeof(tmp), Translate("Set My Avatar for %s..."), proto->description); + TCHAR tmp[128]; + mir_sntprintf(tmp, SIZEOF(tmp), TranslateT("Set My Avatar for %s..."), proto->description); MENUITEMINFO mii = {0}; mii.cbSize = sizeof(mii); mii.fMask = MIIM_ID | MIIM_TYPE; mii.fType = MFT_STRING; mii.dwTypeData = tmp; - mii.cch = strlen(tmp); + mii.cch = _tcslen(tmp); mii.wID = 1; - if (!proto->CanSetAvatar()) + if ( !proto->CanSetAvatar()) { mii.fMask |= MIIM_STATE; mii.fState = MFS_DISABLED; @@ -2047,18 +2015,18 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar CallService(MS_LANGPACK_TRANSLATEMENU,(WPARAM)submenu,0); // Add this proto to menu - char tmp[128]; - mir_snprintf(tmp, sizeof(tmp), Translate("Set My Nickname for %s..."), proto->description); + TCHAR tmp[128]; + mir_sntprintf(tmp, SIZEOF(tmp), TranslateT("Set My Nickname for %s..."), proto->description); MENUITEMINFO mii = {0}; mii.cbSize = sizeof(mii); mii.fMask = MIIM_ID | MIIM_TYPE; mii.fType = MFT_STRING; mii.dwTypeData = tmp; - mii.cch = strlen(tmp); + mii.cch = _tcslen(tmp); mii.wID = 1; - if (!proto->CanSetNick()) + if ( !proto->CanSetNick()) { mii.fMask |= MIIM_STATE; mii.fState = MFS_DISABLED; @@ -2097,7 +2065,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar // In status message? else if (data->draw_away_msg && InsideRect(&p, &data->away_msg_rect)) { - char tmp[128]; + TCHAR tmp[128]; HMENU menu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU1)); HMENU submenu = GetSubMenu(menu, 3); @@ -2106,18 +2074,17 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar if (protocols->CanSetStatusMsgPerProtocol()) { // Add this proto to menu - mir_snprintf(tmp, sizeof(tmp), Translate("Set My Status Message for %s..."), - proto->description); + mir_sntprintf(tmp, SIZEOF(tmp), TranslateT("Set My Status Message for %s..."), proto->description); MENUITEMINFO mii = {0}; mii.cbSize = sizeof(mii); mii.fMask = MIIM_ID | MIIM_TYPE; mii.fType = MFT_STRING; mii.dwTypeData = tmp; - mii.cch = strlen(tmp); + mii.cch = _tcslen(tmp); mii.wID = 1; - if (!proto->CanSetStatusMsg()) + if ( !proto->CanSetStatusMsg()) { mii.fMask |= MIIM_STATE; mii.fState = MFS_DISABLED; @@ -2128,7 +2095,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar { // Add this to menu - mir_snprintf(tmp, sizeof(tmp), Translate("Set My Status Message for %s..."), + mir_sntprintf(tmp, SIZEOF(tmp), TranslateT("Set My Status Message for %s..."), CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, proto->status, 0)); MENUITEMINFO mii = {0}; @@ -2136,7 +2103,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar mii.fMask = MIIM_ID | MIIM_TYPE; mii.fType = MFT_STRING; mii.dwTypeData = tmp; - mii.cch = strlen(tmp); + mii.cch = _tcslen(tmp); mii.wID = 2; if (proto->status == ID_STATUS_OFFLINE) @@ -2202,10 +2169,10 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar RemoveMenu(submenu, ID_DONT_CYCLE_THROUGH_PROTOS, MF_BYCOMMAND); // Add this proto to menu - char tmp[128]; + TCHAR tmp[128]; MENUITEMINFO mii = {0}; - mir_snprintf(tmp, sizeof(tmp), Translate("Enable Listening To for %s"), proto->description); + mir_sntprintf(tmp, SIZEOF(tmp), TranslateT("Enable Listening To for %s"), proto->description); ZeroMemory(&mii, sizeof(mii)); mii.cbSize = sizeof(mii); @@ -2213,10 +2180,10 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar mii.fType = MFT_STRING; mii.fState = proto->ListeningToEnabled() ? MFS_CHECKED : 0; mii.dwTypeData = tmp; - mii.cch = strlen(tmp); + mii.cch = _tcslen(tmp); mii.wID = 5; - if (!proto->CanSetListeningTo()) + if ( !proto->CanSetListeningTo()) { mii.fState |= MFS_DISABLED; } @@ -2224,7 +2191,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar InsertMenuItem(submenu, 0, TRUE, &mii); // Add this to menu - mir_snprintf(tmp, sizeof(tmp), Translate("Set My Status Message for %s..."), + mir_sntprintf(tmp, SIZEOF(tmp), TranslateT("Set My Status Message for %s..."), CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, proto->status, 0)); ZeroMemory(&mii, sizeof(mii)); @@ -2232,11 +2199,10 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar mii.fMask = MIIM_ID | MIIM_TYPE; mii.fType = MFT_STRING; mii.dwTypeData = tmp; - mii.cch = strlen(tmp); + mii.cch = _tcslen(tmp); mii.wID = 4; - if (proto->status == ID_STATUS_OFFLINE) - { + if (proto->status == ID_STATUS_OFFLINE) { mii.fMask |= MIIM_STATE; mii.fState = MFS_DISABLED; } @@ -2246,17 +2212,17 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar if (protocols->CanSetStatusMsgPerProtocol()) { // Add this proto to menu - mir_snprintf(tmp, sizeof(tmp), Translate("Set My Status Message for %s..."), proto->description); + mir_sntprintf(tmp, SIZEOF(tmp), TranslateT("Set My Status Message for %s..."), proto->description); ZeroMemory(&mii, sizeof(mii)); mii.cbSize = sizeof(mii); mii.fMask = MIIM_ID | MIIM_TYPE; mii.fType = MFT_STRING; mii.dwTypeData = tmp; - mii.cch = strlen(tmp); + mii.cch = _tcslen(tmp); mii.wID = 3; - if (!proto->CanSetStatusMsg()) + if ( !proto->CanSetStatusMsg()) { mii.fMask |= MIIM_STATE; mii.fState = MFS_DISABLED; @@ -2265,17 +2231,17 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar InsertMenuItem(submenu, 0, TRUE, &mii); } - mir_snprintf(tmp, sizeof(tmp), Translate("Set My Nickname for %s..."), proto->description); + mir_sntprintf(tmp, SIZEOF(tmp), TranslateT("Set My Nickname for %s..."), proto->description); ZeroMemory(&mii, sizeof(mii)); mii.cbSize = sizeof(mii); mii.fMask = MIIM_ID | MIIM_TYPE; mii.fType = MFT_STRING; mii.dwTypeData = tmp; - mii.cch = strlen(tmp); + mii.cch = _tcslen(tmp); mii.wID = 2; - if (!proto->CanSetNick()) + if ( !proto->CanSetNick()) { mii.fMask |= MIIM_STATE; mii.fState = MFS_DISABLED; @@ -2283,17 +2249,17 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar InsertMenuItem(submenu, 0, TRUE, &mii); - mir_snprintf(tmp, sizeof(tmp), Translate("Set My Avatar for %s..."), proto->description); + mir_sntprintf(tmp, SIZEOF(tmp), TranslateT("Set My Avatar for %s..."), proto->description); ZeroMemory(&mii, sizeof(mii)); mii.cbSize = sizeof(mii); mii.fMask = MIIM_ID | MIIM_TYPE; mii.fType = MFT_STRING; mii.dwTypeData = tmp; - mii.cch = strlen(tmp); + mii.cch = _tcslen(tmp); mii.wID = 1; - if (!proto->CanSetAvatar()) + if ( !proto->CanSetAvatar()) { mii.fMask |= MIIM_STATE; mii.fState = MFS_DISABLED; @@ -2306,7 +2272,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar mii.fMask = MIIM_STATE; mii.fState = protocols->ListeningToEnabled() ? MFS_CHECKED : 0; - if (!protocols->CanSetListeningTo()) + if ( !protocols->CanSetListeningTo()) { mii.fState |= MFS_DISABLED; } @@ -2608,7 +2574,7 @@ int ShowFrameFunc(WPARAM wParam, LPARAM lParam) } else { - if (!MyDetailsFrameVisible()) + if ( !MyDetailsFrameVisible()) { ShowWindow(hwnd_container, SW_SHOW); DBWriteContactSettingByte(0, MODULE_NAME, SETTING_FRAME_VISIBLE, 1); @@ -2794,7 +2760,7 @@ int PluginCommand_ShowProtocol(WPARAM wParam,LPARAM lParam) if (proto == NULL) return -1; - for(int i = 0 ; i < protocols->GetSize() ; i++) + for (int i = 0 ; i < protocols->GetSize() ; i++) { if (_stricmp(protocols->Get(i)->name, proto) == 0) { @@ -2834,13 +2800,13 @@ int SettingsChangedHook(WPARAM wParam, LPARAM lParam) { Protocol *proto = protocols->Get((const char *) cws->szModule); - if (!strcmp(cws->szSetting,"Status") + if ( !strcmp(cws->szSetting,"Status") || ( proto != NULL && proto->custom_status != 0 && proto->custom_status_name != NULL - && !strcmp(cws->szSetting, proto->custom_status_name) ) + && !strcmp(cws->szSetting, _T2A(proto->custom_status_name))) || ( proto != NULL && proto->custom_status != 0 && proto->custom_status_message != NULL - && !strcmp(cws->szSetting, proto->custom_status_message) )) + && !strcmp(cws->szSetting, _T2A(proto->custom_status_message)))) { // Status changed if (proto != NULL) diff --git a/plugins/MyDetails/mydetails.cpp b/plugins/MyDetails/mydetails.cpp index f990f6e129..83007d10dc 100644 --- a/plugins/MyDetails/mydetails.cpp +++ b/plugins/MyDetails/mydetails.cpp @@ -19,7 +19,6 @@ Boston, MA 02111-1307, USA. #include "commons.h" -#include "mydetails.h" // Prototypes ///////////////////////////////////////////////////////////////////////////////////// @@ -39,9 +38,6 @@ PLUGININFOEX pluginInfo={ { 0xa82baeb3, 0xa33c, 0x4036, { 0xb8, 0x37, 0x78, 0x3, 0xa5, 0xb6, 0xc2, 0xab } } // {A82BAEB3-A33C-4036-B837-7803A5B6C2AB} }; - -HANDLE hTTB = NULL; - // Hooks HANDLE hModulesLoadedHook = NULL; HANDLE hPreShutdownHook = NULL; @@ -52,12 +48,10 @@ HWND hwndSetNickname; long status_msg_dialog_open; HWND hwndSetStatusMsg; - // Hook called after init static int MainInit(WPARAM wparam,LPARAM lparam); static int MainUninit(WPARAM wParam, LPARAM lParam); - // Services static int PluginCommand_SetMyNicknameUI(WPARAM wParam,LPARAM lParam); static int PluginCommand_SetMyNickname(WPARAM wParam,LPARAM lParam); @@ -69,8 +63,6 @@ static int PluginCommand_SetMyStatusMessageUI(WPARAM wParam,LPARAM lParam); static int PluginCommand_CicleThroughtProtocols(WPARAM wParam,LPARAM lParam); - - // Functions ////////////////////////////////////////////////////////////////////////////////////// @@ -165,9 +157,9 @@ static int MainInit(WPARAM wparam,LPARAM lparam) mi.cbSize = sizeof(mi); mi.flags = 0; mi.popupPosition = 500050000; - mi.pszPopupName = Translate("My Details"); + mi.pszPopupName = LPGEN("My Details"); mi.position = 100001; - mi.pszName = Translate("Set My Avatar..."); + mi.pszName = LPGEN("Set My Avatar..."); CreateServiceFunction("MENU_" MS_MYDETAILS_SETMYAVATARUI, Menu_SetMyAvatarUI); mi.pszService = "MENU_" MS_MYDETAILS_SETMYAVATARUI; Menu_AddMainMenuItem(&mi); @@ -177,9 +169,9 @@ static int MainInit(WPARAM wparam,LPARAM lparam) mi.cbSize = sizeof(mi); mi.flags = 0; mi.popupPosition = 500050000; - mi.pszPopupName = Translate("My Details"); + mi.pszPopupName = LPGEN("My Details"); mi.position = 100002; - mi.pszName = Translate("Set My Nickname..."); + mi.pszName = LPGEN("Set My Nickname..."); CreateServiceFunction("MENU_" MS_MYDETAILS_SETMYNICKNAMEUI, Menu_SetMyNicknameUI); mi.pszService = "MENU_" MS_MYDETAILS_SETMYNICKNAMEUI; Menu_AddMainMenuItem(&mi); @@ -188,9 +180,9 @@ static int MainInit(WPARAM wparam,LPARAM lparam) mi.cbSize = sizeof(mi); mi.flags = 0; mi.popupPosition = 500050000; - mi.pszPopupName = Translate("My Details"); + mi.pszPopupName = LPGEN("My Details"); mi.position = 100003; - mi.pszName = Translate("Set My Status Message..."); + mi.pszName = LPGEN("Set My Status Message..."); CreateServiceFunction("MENU_" MS_MYDETAILS_SETMYSTATUSMESSAGEUI, Menu_SetMyStatusMessageUI); mi.pszService = "MENU_" MS_MYDETAILS_SETMYSTATUSMESSAGEUI; Menu_AddMainMenuItem(&mi); @@ -200,9 +192,9 @@ static int MainInit(WPARAM wparam,LPARAM lparam) mi.cbSize = sizeof(mi); mi.flags = 0; mi.popupPosition = 500050000; - mi.pszPopupName = Translate("My Details"); + mi.pszPopupName = LPGEN("My Details"); mi.position = 200001; - mi.pszName = Translate("Show next protocol"); + mi.pszName = LPGEN("Show next protocol"); mi.pszService = MS_MYDETAILS_SHOWNEXTPROTOCOL; Menu_AddMainMenuItem(&mi); @@ -268,30 +260,24 @@ static BOOL CALLBACK DlgProcSetNickname(HWND hwndDlg, UINT msg, WPARAM wParam, L SetWindowLong(hwndDlg, GWL_USERDATA, proto_num); - if (proto_num == -1) - { + if (proto_num == -1) { SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadSkinnedIcon(SKINICON_OTHER_MIRANDA)); // All protos have the same nick? - if (protocols->GetSize() > 0) - { - char *nick = protocols->Get(0)->nickname; + if (protocols->GetSize() > 0) { + TCHAR *nick = protocols->Get(0)->nickname; bool foundDefNick = true; - for(int i = 1 ; foundDefNick && i < protocols->GetSize() ; i++) - { - if (_stricmp(protocols->Get(i)->nickname, nick) != 0) - { + for (int i=1 ; foundDefNick && i < protocols->GetSize() ; i++) { + if (_tcsicmp(protocols->Get(i)->nickname, nick) != 0) { foundDefNick = false; break; } } if (foundDefNick) - { - if (_stricmp(protocols->default_nick, nick) != 0) + if ( _tcsicmp(protocols->default_nick, nick) != 0) lstrcpy(protocols->default_nick, nick); - } } SetDlgItemText(hwndDlg, IDC_NICKNAME, protocols->default_nick); @@ -322,31 +308,24 @@ static BOOL CALLBACK DlgProcSetNickname(HWND hwndDlg, UINT msg, WPARAM wParam, L } case WM_COMMAND: - switch(wParam) + switch(wParam) { + case IDOK: { - case IDOK: - { - char tmp[MS_MYDETAILS_GETMYNICKNAME_BUFFER_SIZE]; - GetDlgItemText(hwndDlg, IDC_NICKNAME, tmp, sizeof(tmp)); + TCHAR tmp[MS_MYDETAILS_GETMYNICKNAME_BUFFER_SIZE]; + GetDlgItemText(hwndDlg, IDC_NICKNAME, tmp, SIZEOF(tmp)); - int proto_num = (int)GetWindowLong(hwndDlg, GWL_USERDATA); - if (proto_num == -1) - { - protocols->SetNicks(tmp); - } - else - { - protocols->Get(proto_num)->SetNick(tmp); - } + int proto_num = (int)GetWindowLong(hwndDlg, GWL_USERDATA); + if (proto_num == -1) + protocols->SetNicks(tmp); + else + protocols->Get(proto_num)->SetNick(tmp); - DestroyWindow(hwndDlg); - break; - } - case IDCANCEL: - { - DestroyWindow(hwndDlg); - break; - } + DestroyWindow(hwndDlg); + break; + } + case IDCANCEL: + DestroyWindow(hwndDlg); + break; } break; @@ -370,7 +349,7 @@ static int PluginCommand_SetMyNicknameUI(WPARAM wParam,LPARAM lParam) if (proto != NULL) { int i; - for(i = 0 ; i < protocols->GetSize() ; i++) + for (i = 0 ; i < protocols->GetSize() ; i++) { if (_stricmp(protocols->Get(i)->name, proto) == 0) { @@ -382,12 +361,12 @@ static int PluginCommand_SetMyNicknameUI(WPARAM wParam,LPARAM lParam) if (proto_num == -1) return -1; - if (!protocols->Get(i)->CanSetNick()) + if ( !protocols->Get(i)->CanSetNick()) return -2; } - if (!nickname_dialog_open) + if ( !nickname_dialog_open) { InterlockedExchange(&nickname_dialog_open, 1); @@ -403,50 +382,36 @@ static int PluginCommand_SetMyNicknameUI(WPARAM wParam,LPARAM lParam) return 0; } - static int PluginCommand_SetMyNickname(WPARAM wParam,LPARAM lParam) { char * proto = (char *)wParam; - - if (proto != NULL) - { - for(int i = 0 ; i < protocols->GetSize() ; i++) - { - if (_stricmp(protocols->Get(i)->name, proto) == 0) - { - if (!protocols->Get(i)->CanSetNick()) - { + if (proto != NULL) { + for (int i = 0 ; i < protocols->GetSize() ; i++) { + if (_stricmp(protocols->Get(i)->name, proto) == 0) { + if ( !protocols->Get(i)->CanSetNick()) return -2; - } - else - { - protocols->Get(i)->SetNick((char *)lParam); - return 0; - } + + protocols->Get(i)->SetNick((TCHAR*)lParam); + return 0; } } return -1; } - else - { - protocols->SetNicks((char *)lParam); - return 0; - } + protocols->SetNicks((TCHAR*)lParam); + return 0; } - static int PluginCommand_GetMyNickname(WPARAM wParam,LPARAM lParam) { - char * ret = (char *)lParam; + TCHAR* ret = (TCHAR*)lParam; char * proto = (char *)wParam; if (ret == NULL) return -1; - if (proto == NULL) - { + if (proto == NULL) { if (protocols->default_nick != NULL) lstrcpyn(ret, protocols->default_nick, MS_MYDETAILS_GETMYNICKNAME_BUFFER_SIZE); else @@ -479,7 +444,7 @@ static int PluginCommand_SetMyAvatarUI(WPARAM wParam,LPARAM lParam) if (proto != NULL) { int i; - for(i = 0 ; i < protocols->GetSize() ; i++) + for (i = 0 ; i < protocols->GetSize() ; i++) { if (_stricmp(protocols->Get(i)->name, proto) == 0) { @@ -491,7 +456,7 @@ static int PluginCommand_SetMyAvatarUI(WPARAM wParam,LPARAM lParam) if (proto_num == -1) return -1; - if (!protocols->Get(i)->CanSetAvatar()) + if ( !protocols->Get(i)->CanSetAvatar()) { return -2; } @@ -509,42 +474,27 @@ static int PluginCommand_SetMyAvatarUI(WPARAM wParam,LPARAM lParam) return 0; } - static int PluginCommand_SetMyAvatar(WPARAM wParam,LPARAM lParam) { char * proto = (char *)wParam; - - if (proto != NULL) - { - for(int i = 0 ; i < protocols->GetSize() ; i++) - { - if (_stricmp(protocols->Get(i)->name, proto) == 0) - { - if (!protocols->Get(i)->CanSetAvatar()) - { + if (proto != NULL) { + for (int i = 0 ; i < protocols->GetSize() ; i++) { + if (_stricmp(protocols->Get(i)->name, proto) == 0) { + if ( !protocols->Get(i)->CanSetAvatar()) return -2; - } - else - { - protocols->Get(i)->SetAvatar((char *)lParam); - return 0; - } + + protocols->Get(i)->SetAvatar((TCHAR*)lParam); + return 0; } } return -1; } - else - { - protocols->SetAvatars((char *)lParam); - - return 0; - } + protocols->SetAvatars((TCHAR*)lParam); return 0; } - int Status2SkinIcon(int status) { switch(status) { @@ -567,14 +517,13 @@ int Status2SkinIcon(int status) static int PluginCommand_GetMyAvatar(WPARAM wParam,LPARAM lParam) { - char * ret = (char *)lParam; + TCHAR* ret = (TCHAR*)lParam; char * proto = (char *)wParam; if (ret == NULL) return -1; - if (proto == NULL) - { + if (proto == NULL) { if (protocols->default_avatar_file != NULL) lstrcpyn(ret, protocols->default_avatar_file, MS_MYDETAILS_GETMYAVATAR_BUFFER_SIZE); else @@ -582,28 +531,20 @@ static int PluginCommand_GetMyAvatar(WPARAM wParam,LPARAM lParam) return 0; } - else - { - for(int i = 0 ; i < protocols->GetSize() ; i++) - { - if (_stricmp(protocols->Get(i)->name, proto) == 0) - { - if (!protocols->Get(i)->CanGetAvatar()) - { - return -2; - } - else - { - protocols->Get(i)->GetAvatar(); + + for (int i = 0 ; i < protocols->GetSize() ; i++) { + if (_stricmp(protocols->Get(i)->name, proto) == 0) { + if ( !protocols->Get(i)->CanGetAvatar()) + return -2; - if (protocols->Get(i)->avatar_file != NULL) - lstrcpyn(ret, protocols->Get(i)->avatar_file, MS_MYDETAILS_GETMYAVATAR_BUFFER_SIZE); - else - ret[0] = '\0'; + protocols->Get(i)->GetAvatar(); - return 0; - } - } + if (protocols->Get(i)->avatar_file != NULL) + lstrcpyn(ret, protocols->Get(i)->avatar_file, MS_MYDETAILS_GETMYAVATAR_BUFFER_SIZE); + else + ret[0] = '\0'; + + return 0; } } @@ -701,7 +642,7 @@ static BOOL CALLBACK DlgProcSetStatusMessage(HWND hwndDlg, UINT msg, WPARAM wPar { case IDOK: { - char tmp[MS_MYDETAILS_GETMYSTATUSMESSAGE_BUFFER_SIZE]; + TCHAR tmp[MS_MYDETAILS_GETMYSTATUSMESSAGE_BUFFER_SIZE]; GetDlgItemText(hwndDlg, IDC_STATUSMESSAGE, tmp, sizeof(tmp)); SetStatusMessageData *data = (SetStatusMessageData *) GetWindowLong(hwndDlg, GWL_USERDATA); @@ -745,14 +686,13 @@ static int PluginCommand_SetMyStatusMessageUI(WPARAM wParam,LPARAM lParam) char * proto_name = (char *)lParam; int proto_num = -1; Protocol *proto = NULL; - TCHAR status_message[256]; if (status != 0 && (status < ID_STATUS_OFFLINE || status > ID_STATUS_OUTTOLUNCH)) return -10; if (proto_name != NULL) { - for(int i = 0 ; i < protocols->GetSize() ; i++) + for (int i = 0 ; i < protocols->GetSize() ; i++) { proto = protocols->Get(i); @@ -771,93 +711,6 @@ static int PluginCommand_SetMyStatusMessageUI(WPARAM wParam,LPARAM lParam) return -2; } } - - if (ServiceExists(MS_NAS_INVOKESTATUSWINDOW)) - { - NAS_ISWINFO iswi; - - ZeroMemory(&iswi, sizeof(iswi)); - - iswi.cbSize = sizeof(NAS_ISWINFO); - - if (proto != NULL) - { - // Has to get the unparsed message - NAS_PROTOINFO pi; - - ZeroMemory(&pi, sizeof(pi)); - pi.cbSize = sizeof(NAS_PROTOINFO); - pi.szProto = proto->name; - pi.status = status; - pi.szMsg = NULL; - - if (ServiceExists(MS_NAS_GETSTATE)) - { - if (CallService(MS_NAS_GETSTATE, (WPARAM) &pi, 1) == 0) - { - if (pi.szMsg == NULL) - { - pi.szProto = NULL; - - if (CallService(MS_NAS_GETSTATE, (WPARAM) &pi, 1) == 0) - { - if (pi.szMsg != NULL) - { - lstrcpyn(status_message, pi.szMsg, MAX_REGS(status_message)); - mir_free(pi.szMsg); - } - } - } - else // if (pi.szMsg != NULL) - { - lstrcpyn(status_message, pi.szMsg, MAX_REGS(status_message)); - mir_free(pi.szMsg); - } - } - } - // TODO: Remove when removing old NAS services support - else - { - NAS_PROTOINFO *pii = π - - // Old services - if (CallService("NewAwaySystem/GetState", (WPARAM) &pii, 1) == 0) - { - if (pi.szMsg == NULL) - { - pi.szProto = NULL; - - if (CallService("NewAwaySystem/GetState", (WPARAM) &pii, 1) == 0) - { - if (pi.szMsg != NULL) - { - lstrcpyn(status_message, pi.szMsg, MAX_REGS(status_message)); - mir_free(pi.szMsg); - } - } - } - else // if (pi.szMsg != NULL) - { - lstrcpyn(status_message, pi.szMsg, MAX_REGS(status_message)); - mir_free(pi.szMsg); - } - } - } - - iswi.szProto = proto->name; - iswi.szMsg = status_message; - } - else - { - iswi.szMsg = protocols->GetDefaultStatusMsg(); - } - - iswi.Flags = ISWF_NOCOUNTDOWN; - - CallService(MS_NAS_INVOKESTATUSWINDOW, (WPARAM) &iswi, 0); - - return 0; - } else if (ServiceExists(MS_SA_CHANGESTATUSMSG)) { if (proto == NULL && status == 0) @@ -877,7 +730,7 @@ static int PluginCommand_SetMyStatusMessageUI(WPARAM wParam,LPARAM lParam) } else if (proto == NULL || proto->status != ID_STATUS_OFFLINE) { - if (!status_msg_dialog_open) + if ( !status_msg_dialog_open) { InterlockedExchange(&status_msg_dialog_open, 1); diff --git a/plugins/MyDetails/mydetails.h b/plugins/MyDetails/mydetails.h deleted file mode 100644 index dd2d8050d3..0000000000 --- a/plugins/MyDetails/mydetails.h +++ /dev/null @@ -1,25 +0,0 @@ -/* -Copyright (C) 2005 Ricardo Pescuma Domenecci - -This is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This 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 -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this file; see the file license.txt. If -not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. -*/ - - -#ifndef __MYDETAILS_H__ -#define __MYDETAILS_H__ - - -#endif // __MYDETAILS_H__ \ No newline at end of file diff --git a/plugins/MyDetails/mydetails.vcxproj b/plugins/MyDetails/mydetails.vcxproj index 2377f6d5d8..0a2a0696a2 100644 --- a/plugins/MyDetails/mydetails.vcxproj +++ b/plugins/MyDetails/mydetails.vcxproj @@ -134,7 +134,7 @@ OnlyExplicitInline Size ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;MYDETAILS_EXPORTS;%(PreprocessorDefinitions) + WIN64;NDEBUG;_WINDOWS;_USRDLL;MYDETAILS_EXPORTS;%(PreprocessorDefinitions) true MultiThreadedDLL true @@ -211,7 +211,7 @@ Disabled ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;MYDETAILS_EXPORTS;%(PreprocessorDefinitions) + WIN64;_DEBUG;_WINDOWS;_USRDLL;MYDETAILS_EXPORTS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL true @@ -258,8 +258,6 @@ Disabled %(AdditionalIncludeDirectories) %(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;MYDETAILS_EXPORTS - WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;MYDETAILS_EXPORTS EnableFastChecks EnableFastChecks true @@ -268,16 +266,12 @@ MaxSpeed %(AdditionalIncludeDirectories) %(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;MYDETAILS_EXPORTS - WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;MYDETAILS_EXPORTS Disabled Disabled %(AdditionalIncludeDirectories) %(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;MYDETAILS_EXPORTS - WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;MYDETAILS_EXPORTS EnableFastChecks EnableFastChecks true @@ -286,16 +280,12 @@ MaxSpeed %(AdditionalIncludeDirectories) %(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;MYDETAILS_EXPORTS - WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;MYDETAILS_EXPORTS Disabled Disabled %(AdditionalIncludeDirectories) %(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;MYDETAILS_EXPORTS - WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;MYDETAILS_EXPORTS EnableFastChecks EnableFastChecks NotUsing @@ -306,8 +296,6 @@ MaxSpeed %(AdditionalIncludeDirectories) %(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;MYDETAILS_EXPORTS - WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;MYDETAILS_EXPORTS NotUsing NotUsing @@ -316,8 +304,6 @@ Disabled %(AdditionalIncludeDirectories) %(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;MYDETAILS_EXPORTS - WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;MYDETAILS_EXPORTS EnableFastChecks EnableFastChecks NotUsing @@ -328,8 +314,6 @@ MaxSpeed %(AdditionalIncludeDirectories) %(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;MYDETAILS_EXPORTS - WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;MYDETAILS_EXPORTS NotUsing NotUsing @@ -338,8 +322,6 @@ Disabled %(AdditionalIncludeDirectories) %(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;MYDETAILS_EXPORTS - WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;MYDETAILS_EXPORTS EnableFastChecks EnableFastChecks Create @@ -350,8 +332,6 @@ MaxSpeed %(AdditionalIncludeDirectories) %(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;MYDETAILS_EXPORTS - WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;MYDETAILS_EXPORTS Create Create @@ -360,8 +340,6 @@ Disabled %(AdditionalIncludeDirectories) %(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;MYDETAILS_EXPORTS - WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;MYDETAILS_EXPORTS EnableFastChecks EnableFastChecks true @@ -370,8 +348,6 @@ MaxSpeed %(AdditionalIncludeDirectories) %(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;MYDETAILS_EXPORTS - WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;MYDETAILS_EXPORTS @@ -385,7 +361,6 @@ - diff --git a/plugins/MyDetails/mydetails.vcxproj.filters b/plugins/MyDetails/mydetails.vcxproj.filters index 70834e293a..1b4ed68251 100644 --- a/plugins/MyDetails/mydetails.vcxproj.filters +++ b/plugins/MyDetails/mydetails.vcxproj.filters @@ -64,9 +64,6 @@ Header Files - - Header Files - Header Files diff --git a/plugins/MyDetails/options.cpp b/plugins/MyDetails/options.cpp index 05d38aa6cc..e879e078b7 100644 --- a/plugins/MyDetails/options.cpp +++ b/plugins/MyDetails/options.cpp @@ -70,7 +70,7 @@ static OptPageControl pageControls[] = { // Initializations needed by options void LoadOptions() { - LoadOpts(pageControls, MAX_REGS(pageControls), MODULE_NAME); + LoadOpts(pageControls, SIZEOF(pageControls), MODULE_NAME); // This is created here to assert that this key always exists opts.refresh_status_message_timer = DBGetContactSettingWord(NULL,"MyDetails","RefreshStatusMessageTimer",12); @@ -88,7 +88,7 @@ int InitOptionsCallback(WPARAM wParam,LPARAM lParam) odp.position = -200000000; odp.hInstance = hInst; odp.pfnDlgProc = DlgProcOpts; - odp.pszTemplate = MAKEINTRESOURCE(IDD_OPTS); + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTS); odp.pszGroup = LPGEN("Customize"); odp.pszTitle = LPGEN("My Details"); odp.flags = ODPF_BOLDGROUPS; @@ -112,7 +112,7 @@ void DeInitOptions() static BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - BOOL ret = SaveOptsDlgProc(pageControls, MAX_REGS(pageControls), MODULE_NAME, hwndDlg, msg, wParam, lParam); + BOOL ret = SaveOptsDlgProc(pageControls, SIZEOF(pageControls), MODULE_NAME, hwndDlg, msg, wParam, lParam); switch (msg) { @@ -133,13 +133,13 @@ static BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l { EnableWindow(GetDlgItem(hwndDlg,IDC_SHOW_CYCLE_PROTO_BUTTON),FALSE); } - if (!ServiceExists(MS_SMILEYADD_BATCHPARSE)) + if ( !ServiceExists(MS_SMILEYADD_BATCHPARSE)) { EnableWindow(GetDlgItem(hwndDlg,IDC_REPLACE_SMILEYS),FALSE); EnableWindow(GetDlgItem(hwndDlg,IDC_USE_CONTACT_LIST_SMILEYS),FALSE); EnableWindow(GetDlgItem(hwndDlg,IDC_RESIZE_SMILEYS),FALSE); } - if (!ServiceExists(MS_CLIST_FRAMES_SETFRAMEOPTIONS)) + if ( !ServiceExists(MS_CLIST_FRAMES_SETFRAMEOPTIONS)) { EnableWindow(GetDlgItem(hwndDlg,IDC_RESIZE_FRAME),FALSE); } diff --git a/plugins/StatusPlugins/AdvancedAutoAway/advancedautoaway.cpp b/plugins/StatusPlugins/AdvancedAutoAway/advancedautoaway.cpp index c969b5c98a..d4527e8091 100644 --- a/plugins/StatusPlugins/AdvancedAutoAway/advancedautoaway.cpp +++ b/plugins/StatusPlugins/AdvancedAutoAway/advancedautoaway.cpp @@ -275,8 +275,8 @@ static int changeState(TAAAProtoSetting& setting, STATES newState) if (DBGetContactSettingByte(NULL, MODULENAME, StatusModeToDbSetting(setting.status, SETTING_MSGCUSTOM), FALSE)) { DBVARIANT dbv; - if (!DBGetContactSetting(NULL, MODULENAME, StatusModeToDbSetting(setting.status, SETTING_STATUSMSG), &dbv)) { - setting.szMsg = _strdup(dbv.pszVal); + if (!DBGetContactSettingTString(NULL, MODULENAME, StatusModeToDbSetting(setting.status, SETTING_STATUSMSG), &dbv)) { + setting.szMsg = _tcsdup(dbv.ptszVal); DBFreeVariant(&dbv); } } } @@ -409,7 +409,7 @@ static VOID CALLBACK AutoAwayTimer(HWND hwnd,UINT message,UINT_PTR idEvent,DWORD int i; for ( i=0; i < ps.getCount(); i++ ) { if ( ps[i].szMsg ) - ps[i].szMsg = _strdup( ps[i].szMsg ); + ps[i].szMsg = _tcsdup( ps[i].szMsg ); if (ps[i].status == ID_STATUS_DISABLED) ps[i].szName = ""; diff --git a/plugins/StatusPlugins/KeepStatus/keepstatus.cpp b/plugins/StatusPlugins/KeepStatus/keepstatus.cpp index 929a9aa1df..b451325c19 100644 --- a/plugins/StatusPlugins/KeepStatus/keepstatus.cpp +++ b/plugins/StatusPlugins/KeepStatus/keepstatus.cpp @@ -71,7 +71,7 @@ static int StartTimer(int timer, int timeout, BOOL restart); static int StopTimer(int timer); int LoadMainOptions(); static void GetCurrentConnectionSettings(); -static int AssignStatus(TConnectionSettings* connSetting, int status, int lastStatus, char *szMsg); +static int AssignStatus(TConnectionSettings* connSetting, int status, int lastStatus, TCHAR *szMsg); static int ProcessProtoAck(WPARAM wParam,LPARAM lParam); static VOID CALLBACK CheckConnectingTimer(HWND hwnd,UINT message,UINT_PTR idEvent,DWORD dwTime); static VOID CALLBACK CheckAckStatusTimer(HWND hwnd,UINT message,UINT_PTR idEvent,DWORD dwTime); @@ -215,30 +215,6 @@ static PROTOCOLSETTINGEX** GetCurrentProtoSettingsCopy() ps[i]->szMsg = NULL; ps[i]->szName = cs.szName; ps[i]->tszAccName = cs.tszAccName; - if ( (ServiceExists(MS_NAS_GETSTATE)) && (CallProtoService(ps[i]->szName, PS_GETSTATUS, 0, 0) == ID_STATUS_OFFLINE) && (ps[i]->status != ID_STATUS_OFFLINE)) { - NAS_PROTOINFO npi; - - ZeroMemory(&npi, sizeof(NAS_PROTOINFO)); - npi.cbSize = sizeof(NAS_PROTOINFO); - npi.status = 0; - npi.szProto = ps[i]->szName; - if (!CallService(MS_NAS_GETSTATEA, (WPARAM)&npi, (LPARAM)1)) { - if (npi.szMsg != NULL) { - ps[i]->szMsg = _strdup(npi.szMsg); - log_infoA("KeepStatus: Status message for %s retrieved from NAS", ps[i]->szName); - } - else { - npi.status = 0; - npi.szProto = NULL; - if (!CallService(MS_NAS_GETSTATEA, (WPARAM)&npi, (LPARAM)1)) { - if (npi.szMsg != NULL) { - ps[i]->szMsg = _strdup(npi.szMsg); - log_infoA("KeepStatus: Status message for %s retrieved from NAS (global)", ps[i]->szName); - } - } - } - } - } } LeaveCriticalSection(&GenStatusCS); @@ -255,7 +231,7 @@ static void FreeProtoSettings(PROTOCOLSETTINGEX** ps) free(ps); } -static int AssignStatus(TConnectionSettings* cs, int status, int lastStatus, char *szMsg) +static int AssignStatus(TConnectionSettings* cs, int status, int lastStatus, TCHAR *szMsg) { if ( status < MIN_STATUS || status > MAX_STATUS ) return -1; @@ -274,11 +250,11 @@ static int AssignStatus(TConnectionSettings* cs, int status, int lastStatus, cha log_infoA("KeepStatus: assigning status %d to %s", cs->status, cs->szName); - if ( szMsg != NULL && szMsg != cs->szMsg ) { + if ( szMsg != NULL && _tcscmp(szMsg, cs->szMsg)) { if ( cs->szMsg != NULL ) free(cs->szMsg); - cs->szMsg = _strdup(szMsg); + cs->szMsg = _tcsdup(szMsg); } else if (szMsg != cs->szMsg) { if (cs->szMsg != NULL) diff --git a/plugins/StatusPlugins/StartupStatus/options.cpp b/plugins/StatusPlugins/StartupStatus/options.cpp index 107cf06e99..410412072c 100644 --- a/plugins/StatusPlugins/StartupStatus/options.cpp +++ b/plugins/StatusPlugins/StartupStatus/options.cpp @@ -442,7 +442,7 @@ static INT_PTR CALLBACK StartupStatusOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wPa GetProfile( defProfile, *ps ); for ( int i=0; i < ps->getCount(); i++ ) if ( (*ps)[i].szMsg != NULL ) - (*ps)[i].szMsg = _strdup( (*ps)[i].szMsg ); + (*ps)[i].szMsg = _tcsdup( (*ps)[i].szMsg ); CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CMDLOPTIONS), hwndDlg, CmdlOptionsDlgProc, (LPARAM)ps); } @@ -551,7 +551,7 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wP else { for (int j=0; j < ar.getCount(); j++) if ( ar[j].szMsg != NULL) - ar[j].szMsg = _strdup( ar[j].szMsg ); + ar[j].szMsg = _tcsdup( ar[j].szMsg ); ppo->szName = db_get_sa(NULL, MODULENAME, OptName(i, SETTING_PROFILENAME)); if (ppo->szName == NULL) { @@ -662,7 +662,7 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wP CheckRadioButton(hwndDlg, IDC_MIRANDAMSG, IDC_CUSTOMMSG, ps->szMsg!=NULL?IDC_CUSTOMMSG:IDC_MIRANDAMSG); if (ps->szMsg != NULL) - SetDlgItemTextA(hwndDlg, IDC_STATUSMSG, ps->szMsg); + SetDlgItemText(hwndDlg, IDC_STATUSMSG, ps->szMsg); bStatusMsg = ( (((CallProtoService(ps->szName, PS_GETCAPS, (WPARAM)PFLAGNUM_1, 0)&PF1_MODEMSGSEND&~PF1_INDIVMODEMSG)) && (CallProtoService(ps->szName, PS_GETCAPS, (WPARAM)PFLAGNUM_3, 0)&Proto_Status2Flag(ps->status))) || (ps->status == ID_STATUS_CURRENT) || (ps->status == ID_STATUS_LAST)); @@ -754,7 +754,7 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wP ps->szMsg = NULL; if (IsDlgButtonChecked(hwndDlg, IDC_CUSTOMMSG)) { len = SendDlgItemMessage(hwndDlg, IDC_STATUSMSG, WM_GETTEXTLENGTH, 0, 0); - ps->szMsg = (char *)malloc(len+1); + ps->szMsg = (TCHAR*)calloc(sizeof(TCHAR), len+1); memset(ps->szMsg, '\0', len+1); SendDlgItemMessage(hwndDlg, IDC_STATUSMSG, WM_GETTEXT, (WPARAM)len+1, (LPARAM)ps->szMsg); } @@ -774,7 +774,7 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wP ps->szMsg = NULL; } int len = SendDlgItemMessageA(hwndDlg, IDC_STATUSMSG, WM_GETTEXTLENGTH, 0, 0); - ps->szMsg = (char *)malloc(len+1); + ps->szMsg = (TCHAR*)calloc(sizeof(TCHAR), len+1); memset(ps->szMsg, '\0', len+1); SendDlgItemMessageA(hwndDlg, IDC_STATUSMSG, WM_GETTEXT, (WPARAM)len+1, (LPARAM)ps->szMsg); } @@ -851,7 +851,7 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wP for ( j=0; j < ar.getCount(); j++ ) { if ( ar[j].szMsg != NULL ) { mir_snprintf(setting, sizeof(setting), "%s_%s", ar[j].szName, SETTING_PROFILE_STSMSG); - db_set_s(NULL, MODULENAME, OptName(i, setting), ar[j].szMsg); + db_set_ts(NULL, MODULENAME, OptName(i, setting), ar[j].szMsg); } db_set_w(NULL, MODULENAME, OptName(i, ar[j].szName), ar[j].status); } diff --git a/plugins/StatusPlugins/StartupStatus/profiles.cpp b/plugins/StatusPlugins/StartupStatus/profiles.cpp index dbf7ebec82..3cb20918f8 100644 --- a/plugins/StatusPlugins/StartupStatus/profiles.cpp +++ b/plugins/StatusPlugins/StartupStatus/profiles.cpp @@ -183,7 +183,7 @@ INT_PTR GetProfileCount(WPARAM wParam, LPARAM lParam) return count; } -char *GetStatusMessage(int profile, char *szProto) +TCHAR *GetStatusMessage(int profile, char *szProto) { char dbSetting[80]; DBVARIANT dbv; @@ -191,10 +191,10 @@ char *GetStatusMessage(int profile, char *szProto) for ( int i=0; i < pceCount; i++ ) { if ( (pce[i].profile == profile) && (!strcmp(pce[i].szProto, szProto))) { _snprintf(dbSetting, sizeof(dbSetting), "%d_%s_%s", profile, szProto, SETTING_PROFILE_STSMSG); - if (!DBGetContactSetting(NULL, MODULENAME, dbSetting, &dbv)) { // reload from db - pce[i].msg = ( char* )realloc(pce[i].msg, strlen(dbv.pszVal)+1); + if (!DBGetContactSettingTString(NULL, MODULENAME, dbSetting, &dbv)) { // reload from db + pce[i].msg = ( TCHAR* )realloc(pce[i].msg, sizeof(TCHAR)*(_tcslen(dbv.ptszVal)+1)); if (pce[i].msg != NULL) { - strcpy(pce[i].msg, dbv.pszVal); + _tcscpy(pce[i].msg, dbv.ptszVal); } DBFreeVariant(&dbv); } @@ -215,8 +215,8 @@ char *GetStatusMessage(int profile, char *szProto) pce[pceCount].szProto = _strdup(szProto); pce[pceCount].msg = NULL; _snprintf(dbSetting, sizeof(dbSetting), "%d_%s_%s", profile, szProto, SETTING_PROFILE_STSMSG); - if (!DBGetContactSetting(NULL, MODULENAME, dbSetting, &dbv)) { - pce[pceCount].msg = _strdup(dbv.pszVal); + if (!DBGetContactSettingTString(NULL, MODULENAME, dbSetting, &dbv)) { + pce[pceCount].msg = _tcsdup(dbv.ptszVal); DBFreeVariant(&dbv); } pceCount += 1; diff --git a/plugins/StatusPlugins/StartupStatus/startupstatus.cpp b/plugins/StatusPlugins/StartupStatus/startupstatus.cpp index 7028868272..e1445a7704 100644 --- a/plugins/StatusPlugins/StartupStatus/startupstatus.cpp +++ b/plugins/StatusPlugins/StartupStatus/startupstatus.cpp @@ -64,7 +64,7 @@ TSSSetting::TSSSetting( int profile, PROTOACCOUNT* pa ) szMsg = GetStatusMessage(profile, szName); if ( szMsg ) - szMsg = _strdup( szMsg ); + szMsg = _tcsdup( szMsg ); } TSSSetting::~TSSSetting() @@ -178,8 +178,8 @@ static void SetLastStatusMessages(TSettingsList& ps) _snprintf(dbSetting, sizeof(dbSetting), "%s%s", PREFIX_LASTMSG, ps[i].szName); DBVARIANT dbv; - if ( ps[i].szMsg == NULL && !DBGetContactSetting(NULL, MODULENAME, dbSetting, &dbv)) { - ps[i].szMsg = _strdup(dbv.pszVal); // remember this won't be freed + if ( ps[i].szMsg == NULL && !DBGetContactSettingTString(NULL, MODULENAME, dbSetting, &dbv)) { + ps[i].szMsg = _tcsdup(dbv.ptszVal); // remember this won't be freed DBFreeVariant(&dbv); } } } diff --git a/plugins/StatusPlugins/StartupStatus/startupstatus.h b/plugins/StatusPlugins/StartupStatus/startupstatus.h index d6248ba4b2..640638f788 100644 --- a/plugins/StatusPlugins/StartupStatus/startupstatus.h +++ b/plugins/StatusPlugins/StartupStatus/startupstatus.h @@ -45,7 +45,7 @@ struct PROFILECE { int profile; char *szProto; - char *msg; + TCHAR *msg; }; struct PROFILEOPTIONS @@ -152,7 +152,7 @@ TSettingsList* GetCurrentProtoSettings(); // profile int GetProfile(int profileID, TSettingsList& arSettings ); -char *GetStatusMessage(int profile, char *szProto); +TCHAR *GetStatusMessage(int profile, char *szProto); INT_PTR LoadAndSetProfile(WPARAM wParam, LPARAM lParam); INT_PTR GetProfileCount(WPARAM wParam, LPARAM lParam); diff --git a/plugins/StatusPlugins/commonstatus.cpp b/plugins/StatusPlugins/commonstatus.cpp index c2cc820e9b..cb5f9ea9c5 100644 --- a/plugins/StatusPlugins/commonstatus.cpp +++ b/plugins/StatusPlugins/commonstatus.cpp @@ -122,7 +122,7 @@ TCHAR *GetDefaultStatusMessage(PROTOCOLSETTINGEX *ps, int newstatus) { if (ps->szMsg != NULL) {// custom message set log_infoA("CommonStatus: Status message set by calling plugin"); - return mir_a2t( ps->szMsg ); + return mir_tstrdup( ps->szMsg ); } if ( ServiceExists( MS_AWAYMSG_GETSTATUSMSGT )) { @@ -196,119 +196,6 @@ static int equalsGlobalStatus(PROTOCOLSETTINGEX **ps) { return gstatus; } -static int nasSetStatus(PROTOCOLSETTINGEX **protoSettings, int newstatus) -{ - NAS_PROTOINFO npi; - char **nasProtoMessages, *nasGlobalMsg; - int i, j, msgCount, maxMsgCount; - - if (!ServiceExists(MS_NAS_SETSTATE)) - return -1; - - nasGlobalMsg = NULL; - msgCount = maxMsgCount = 0; - if (newstatus == 0) { - /* - The global status will not be changed. Still, we'd like to set the global status message for NAS. - This should only be done if all protocols will change in this call. Otherwise, the chance exists - that an already set status message will be overwritten. The global status message will be set for - the status message which is to be set for most of the protocols. Protocols are only considered - which have szMsg==NULL. After the global status message is set, the protocols for which another - message and/or status have to be set will be overwritten. - */ - ZeroMemory(&npi, sizeof(NAS_PROTOINFO)); - npi.cbSize = sizeof(NAS_PROTOINFO); - npi.status = 0; - npi.szProto = NULL; - CallService(MS_NAS_GETSTATEA, (WPARAM)&npi, (LPARAM)1); - nasProtoMessages = ( char** )calloc(protoList->getCount(),sizeof(char *)); - if (nasProtoMessages == NULL) { - return -1; - } - // fill the array of proto message for NAS, this will be used anyway - for (i=0;igetCount();i++) { - if ( (!CallService(MS_PROTO_ISPROTOCOLLOADED, 0, (LPARAM)protoSettings[i]->szName)) || (protoSettings[i]->szMsg != NULL)) { - continue; - } - ZeroMemory(&npi, sizeof(NAS_PROTOINFO)); - npi.cbSize = sizeof(NAS_PROTOINFO); - npi.status = GetActualStatus(protoSettings[i]); - npi.szProto = protoSettings[i]->szName; - if (CallService(MS_NAS_GETSTATEA, (WPARAM)&npi, (LPARAM)1) == 0) { - nasProtoMessages[i] = npi.szMsg; - } - } - // if not all proto's are to be set here, we don't set the global status message - for (i=0;igetCount();i++) { - if (!CallService(MS_PROTO_ISPROTOCOLLOADED, 0, (LPARAM)protoSettings[i]->szName)) { - break; - } - } - if (i == protoList->getCount()) { - for (i=0;igetCount();i++) { - msgCount = 0; - for (j=i;jgetCount();j++) { - if ( (nasProtoMessages[i] != NULL) && (nasProtoMessages[j] != NULL) && (!strcmp(nasProtoMessages[i], nasProtoMessages[j]))) { - msgCount += 1; - //log_infoA("Adding %s (%u) to %s (%u)", protoSettings[j]->szName, protoSettings[j]->status, protoSettings[i]->szName, protoSettings[i]->status); - } - } - if ( (msgCount > maxMsgCount) && ((protoList->getCount() == 1) || (msgCount > 1))) { - maxMsgCount = msgCount; - nasGlobalMsg = _strdup(nasProtoMessages[i]); - } - } - } - if (nasGlobalMsg != NULL) { - // set global message - ZeroMemory(&npi, sizeof(NAS_PROTOINFO)); - npi.cbSize = sizeof(NAS_PROTOINFO); - npi.status = 0; // status is not important for global message - npi.szMsg = mir_strdup(nasGlobalMsg); - npi.Flags |= PIF_NO_CLIST_SETSTATUSMODE; - log_infoA("CommonStatus sets global status message for NAS which is to be changed for %d protocols", maxMsgCount); - CallService(MS_NAS_SETSTATEA, (WPARAM)&npi, (LPARAM)1); - } - for (i=0;igetCount();i++) { - if (!CallService(MS_PROTO_ISPROTOCOLLOADED, 0, (LPARAM)protoSettings[i]->szName)) - continue; - - ZeroMemory(&npi, sizeof(NAS_PROTOINFO)); - npi.cbSize = sizeof(NAS_PROTOINFO); - npi.status = GetActualStatus(protoSettings[i]); - npi.szProto = protoSettings[i]->szName; - if (protoSettings[i]->szMsg != NULL) { - npi.szMsg = mir_strdup(protoSettings[i]->szMsg); - log_infoA("CommonStatus will set status %u for %s and message specified by plugin using NAS (%x)", npi.status, npi.szProto, npi.szMsg); - } - else if ( (nasProtoMessages[i] != NULL) && (nasGlobalMsg != NULL) && (!strcmp(nasProtoMessages[i], nasGlobalMsg))) { - npi.szMsg = NULL; - log_infoA("CommonStatus will set status %u for %s and global message using NAS", npi.status, npi.szProto); - } - else { - npi.szMsg = nasProtoMessages[i]; - log_infoA("CommonStatus will set status %u for %s and message from NAS using NAS", npi.status, npi.szProto); - } - CallService(MS_NAS_SETSTATEA, (WPARAM)&npi, (LPARAM)1); - } - if (nasGlobalMsg != NULL) { - free(nasGlobalMsg); - } - free(nasProtoMessages); - } - else { - ZeroMemory(&npi, sizeof(NAS_PROTOINFO)); - npi.cbSize = sizeof(NAS_PROTOINFO); - npi.szProto = NULL; // global - npi.szMsg = NULL; // global - npi.status = newstatus; - log_debugA("CommonStatus sets global status %u using NAS", newstatus); - CallService(MS_NAS_SETSTATEA, (WPARAM)&npi, (LPARAM)1); - } - - return 0; -} - static void SetStatusMsg(PROTOCOLSETTINGEX *ps, int newstatus) { TCHAR* tszMsg = GetDefaultStatusMessage( ps, newstatus ); @@ -412,10 +299,6 @@ INT_PTR SetStatusEx(WPARAM wParam, LPARAM lParam) CallProtoService(szProto, PS_SETSTATUS, (WPARAM)newstatus, 0); } } - // and finally set a status - if ( !nasSetStatus( protoSettings, globStatus )) - return 0; - if ( globStatus != 0 ) { if ( !ServiceExists( MS_CLIST_SETSTATUSMODE )) { log_debugA("CommonStatus: MS_CLIST_SETSTATUSMODE not available!"); diff --git a/plugins/StatusPlugins/confirmdialog.cpp b/plugins/StatusPlugins/confirmdialog.cpp index 2d93e181fc..da3f428062 100644 --- a/plugins/StatusPlugins/confirmdialog.cpp +++ b/plugins/StatusPlugins/confirmdialog.cpp @@ -33,7 +33,7 @@ struct TConfirmSetting : public PROTOCOLSETTINGEX { memcpy( this, &x, sizeof(PROTOCOLSETTINGEX)); if ( szMsg ) - szMsg = _strdup( szMsg ); + szMsg = _tcsdup( szMsg ); } ~TConfirmSetting() @@ -64,7 +64,7 @@ static INT_PTR CALLBACK StatusMessageDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam mir_free(smsg); } } - else SetDlgItemTextA(hwndDlg, IDC_STSMSG, protoSetting->szMsg); + else SetDlgItemText(hwndDlg, IDC_STSMSG, protoSetting->szMsg); { TCHAR desc[ 512 ]; @@ -82,9 +82,9 @@ static INT_PTR CALLBACK StatusMessageDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam { int len = SendMessage(GetDlgItem(hwndDlg, IDC_STSMSG), WM_GETTEXTLENGTH, 0, 0); if (len > 0) { - protoSetting->szMsg = ( char* )realloc(protoSetting->szMsg, len+1); + protoSetting->szMsg = ( TCHAR* )realloc(protoSetting->szMsg, sizeof(TCHAR)*(len+1)); if (protoSetting->szMsg != NULL) - GetDlgItemTextA(hwndDlg, IDC_STSMSG, protoSetting->szMsg, len+1); + GetDlgItemText(hwndDlg, IDC_STSMSG, protoSetting->szMsg, len+1); } SendMessage(GetParent(hwndDlg), UM_STSMSGDLGCLOSED, (WPARAM)TRUE, 0); EndDialog(hwndDlg, IDC_OK); @@ -247,7 +247,7 @@ static BOOL CALLBACK ConfirmDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM l CallService(MS_SS_GETPROFILE, (WPARAM)profile, (LPARAM)&confirmSettings); for ( i=0; i < confirmSettings.getCount(); i++ ) if (confirmSettings[i].szMsg != NULL) // we free this later, copy to our memory space - confirmSettings[i].szMsg = _strdup(confirmSettings[i].szMsg); + confirmSettings[i].szMsg = _tcsdup(confirmSettings[i].szMsg); SetStatusList(hwndDlg); } diff --git a/plugins/Utils/mir_memory.h b/plugins/Utils/mir_memory.h index 51b16866ab..678972805c 100644 --- a/plugins/Utils/mir_memory.h +++ b/plugins/Utils/mir_memory.h @@ -75,7 +75,7 @@ static int strcmpnullW(WCHAR *str1, WCHAR *str2) #define CHECK_VERSION(_NAME_) \ - if (!mir_is_unicode()) \ + if ( !mir_is_unicode()) \ { \ MessageBox(NULL, _T("Your Miranda is ansi. You have to install ansi ") _T(_NAME_), \ _T(_NAME_), MB_OK | MB_ICONERROR); \ diff --git a/plugins/Utils/mir_options.cpp b/plugins/Utils/mir_options.cpp index c52995471e..493f01f527 100644 --- a/plugins/Utils/mir_options.cpp +++ b/plugins/Utils/mir_options.cpp @@ -37,7 +37,7 @@ Boston, MA 02111-1307, USA. #include "mir_memory.h" -#define MAX_REGS(_A_) ( sizeof(_A_) / sizeof(_A_[0])) +#define SIZEOF(_A_) ( sizeof(_A_) / sizeof(_A_[0])) static TCHAR* MyDBGetContactSettingTString(HANDLE hContact, char* module, char* setting, TCHAR* out, size_t len, TCHAR *def) @@ -46,7 +46,7 @@ static TCHAR* MyDBGetContactSettingTString(HANDLE hContact, char* module, char* out[0] = _T('\0'); - if (!DBGetContactSettingTString(hContact, module, setting, &dbv)) + if ( !DBGetContactSettingTString(hContact, module, setting, &dbv)) { lstrcpyn(out, dbv.ptszVal, (int)len); DBFreeVariant(&dbv); @@ -66,7 +66,7 @@ static TCHAR dbPath[MAX_PATH] = {0}; // database profile path (read at startup static int PathIsAbsolute(const TCHAR *path) { - if (!path || !(lstrlen(path) > 2)) + if ( !path || !(lstrlen(path) > 2)) return 0; if ((path[1]==_T(':') && path[2]==_T('\\')) || (path[0]==_T('\\')&&path[1]==_T('\\'))) return 1; @@ -75,7 +75,7 @@ static int PathIsAbsolute(const TCHAR *path) static void PathToRelative(TCHAR *pOut, size_t outSize, const TCHAR *pSrc) { - if (!PathIsAbsolute(pSrc)) + if ( !PathIsAbsolute(pSrc)) { lstrcpyn(pOut, pSrc, (int)outSize); } @@ -84,8 +84,8 @@ static void PathToRelative(TCHAR *pOut, size_t outSize, const TCHAR *pSrc) if (dbPath[0] == _T('\0')) { char tmp[1024]; - CallService(MS_DB_GETPROFILEPATH, MAX_REGS(tmp), (LPARAM) tmp); - mir_sntprintf(dbPath, MAX_REGS(dbPath), _T(TCHAR_STR_PARAM) _T("\\"), tmp); + CallService(MS_DB_GETPROFILEPATH, SIZEOF(tmp), (LPARAM) tmp); + mir_sntprintf(dbPath, SIZEOF(dbPath), _T(TCHAR_STR_PARAM) _T("\\"), tmp); } size_t len = lstrlen(dbPath); @@ -111,8 +111,8 @@ static void PathToAbsolute(TCHAR *pOut, size_t outSize, const TCHAR *pSrc) if (dbPath[0] == _T('\0')) { char tmp[1024]; - CallService(MS_DB_GETPROFILEPATH, MAX_REGS(tmp), (LPARAM) tmp); - mir_sntprintf(dbPath, MAX_REGS(dbPath), _T(TCHAR_STR_PARAM) _T("\\"), tmp); + CallService(MS_DB_GETPROFILEPATH, SIZEOF(tmp), (LPARAM) tmp); + mir_sntprintf(dbPath, SIZEOF(dbPath), _T(TCHAR_STR_PARAM) _T("\\"), tmp); } mir_sntprintf(pOut, outSize, _T("%s%s"), dbPath, pSrc); @@ -167,16 +167,16 @@ static void LoadOpt(OptPageControl *ctrl, char *module) tmp[0]=0; DBVARIANT dbv = {0}; - if (!DBGetContactSettingString(NULL, module, ctrl->setting, &dbv)) + if ( !DBGetContactSettingString(NULL, module, ctrl->setting, &dbv)) { - lstrcpynA(tmp, dbv.pszVal, MAX_REGS(tmp)); + lstrcpynA(tmp, dbv.pszVal, SIZEOF(tmp)); DBFreeVariant(&dbv); } if (tmp[0] != 0) - CallService(MS_DB_CRYPT_DECODESTRING, MAX_REGS(tmp), (LPARAM) tmp); + CallService(MS_DB_CRYPT_DECODESTRING, SIZEOF(tmp), (LPARAM) tmp); else if (ctrl->szDefValue != NULL) - lstrcpynA(tmp, ctrl->szDefValue, MAX_REGS(tmp)); + lstrcpynA(tmp, ctrl->szDefValue, SIZEOF(tmp)); char *var = (char *) ctrl->var; int size = min(ctrl->max <= 0 ? 1024 : ctrl->max, 1024); @@ -340,16 +340,16 @@ INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, cha tmp[0]=0; DBVARIANT dbv = {0}; - if (!DBGetContactSettingString(NULL, module, ctrl->setting, &dbv)) + if ( !DBGetContactSettingString(NULL, module, ctrl->setting, &dbv)) { - lstrcpynA(tmp, dbv.pszVal, MAX_REGS(tmp)); + lstrcpynA(tmp, dbv.pszVal, SIZEOF(tmp)); DBFreeVariant(&dbv); } if (tmp[0] != 0) - CallService(MS_DB_CRYPT_DECODESTRING, MAX_REGS(tmp), (LPARAM) tmp); + CallService(MS_DB_CRYPT_DECODESTRING, SIZEOF(tmp), (LPARAM) tmp); else if (ctrl->szDefValue != NULL) - lstrcpynA(tmp, ctrl->szDefValue, MAX_REGS(tmp)); + lstrcpynA(tmp, ctrl->szDefValue, SIZEOF(tmp)); SetDlgItemTextA(hwndDlg, ctrl->nID, tmp); SendDlgItemMessage(hwndDlg, ctrl->nID, EM_LIMITTEXT, min(ctrl->max <= 0 ? 1024 : ctrl->max, 1024), 0); @@ -386,7 +386,7 @@ INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, cha MyDBGetContactSettingTString(NULL, module, ctrl->setting, tmp, 1024, ctrl->tszDefValue == NULL ? NULL : TranslateTS(ctrl->tszDefValue)); int count = SendDlgItemMessage(hwndDlg, ctrl->nID, CB_GETCOUNT, 0, 0); int i; - for(i = 0; i < count; i++) + for (i = 0; i < count; i++) { TCHAR *id = (TCHAR *) SendDlgItemMessage(hwndDlg, ctrl->nID, CB_GETITEMDATA, (WPARAM) i, 0); if (lstrcmp(id, tmp) == 0) @@ -500,14 +500,14 @@ INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, cha case CONTROL_TEXT: { TCHAR tmp[1024]; - GetDlgItemText(hwndDlg, ctrl->nID, tmp, MAX_REGS(tmp)); + GetDlgItemText(hwndDlg, ctrl->nID, tmp, SIZEOF(tmp)); DBWriteContactSettingTString(NULL, module, ctrl->setting, tmp); break; } case CONTROL_PASSWORD: { char tmp[1024]; - GetDlgItemTextA(hwndDlg, ctrl->nID, tmp, MAX_REGS(tmp)); + GetDlgItemTextA(hwndDlg, ctrl->nID, tmp, SIZEOF(tmp)); if (ctrl->var != NULL) { @@ -522,7 +522,7 @@ INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, cha continue; } - CallService(MS_DB_CRYPT_ENCODESTRING, MAX_REGS(tmp), (LPARAM) tmp); + CallService(MS_DB_CRYPT_ENCODESTRING, SIZEOF(tmp), (LPARAM) tmp); DBWriteContactSettingString(NULL, module, ctrl->setting, tmp); // Don't load from DB @@ -532,7 +532,7 @@ INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, cha { BOOL trans; int val = GetDlgItemInt(hwndDlg, ctrl->nID, &trans, ctrl->min <= 0); - if (!trans) + if ( !trans) val = ctrl->dwDefValue; if (ctrl->max != 0) val = min(val, ctrl->max); diff --git a/plugins/Utils/mir_smileys.cpp b/plugins/Utils/mir_smileys.cpp index 59587f4c9c..7313f093d8 100644 --- a/plugins/Utils/mir_smileys.cpp +++ b/plugins/Utils/mir_smileys.cpp @@ -60,10 +60,10 @@ typedef struct -SortedList * ReplaceSmileys(const char *text, int text_size, const char *protocol, int *max_smiley_height); -void DrawTextSmiley(HDC hdcMem, RECT free_rc, const char *szText, int len, SortedList *plText, UINT uTextFormat, int max_smiley_height); +SortedList * ReplaceSmileys(const TCHAR *text, int text_size, const char *protocol, int *max_smiley_height); +void DrawTextSmiley(HDC hdcMem, RECT free_rc, const TCHAR *szText, int len, SortedList *plText, UINT uTextFormat, int max_smiley_height); void DestroySmileyList( SortedList* p_list ); -SIZE GetTextSize(HDC hdcMem, const char *szText, SortedList *plText, UINT uTextFormat, int max_smiley_height); +SIZE GetTextSize(HDC hdcMem, const TCHAR *szText, SortedList *plText, UINT uTextFormat, int max_smiley_height); @@ -86,7 +86,7 @@ int InitContactListSmileys() return 0; } -SmileysParseInfo Smileys_PreParse(LPCSTR lpString, int nCount, const char *protocol) +SmileysParseInfo Smileys_PreParse(const TCHAR* lpString, int nCount, const char *protocol) { SmileysParseInfo info = (SmileysParseInfo) mir_alloc0(sizeof(_SmileysParseInfo)); @@ -106,26 +106,17 @@ void Smileys_FreeParse(SmileysParseInfo parseInfo) } } -int skin_DrawText(HDC hDC, LPCSTR lpString, int nCount, LPRECT lpRect, UINT uFormat) +int skin_DrawText(HDC hDC, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT uFormat) { if ((uFormat & DT_CALCRECT) == 0 && ServiceExists(MS_SKINENG_ALPHATEXTOUT)) { COLORREF color = SetTextColor(hDC, 0); SetTextColor(hDC, color); - if (mir_is_unicode()) - { - return AlphaText(hDC, (char *) (const WCHAR *) CharToWchar(lpString), nCount, lpRect, uFormat, color); - } - else - { - return AlphaText(hDC, lpString, nCount, lpRect, uFormat, color); - } - } - else - { - return DrawText(hDC, lpString, nCount, lpRect, uFormat); + return AlphaText(hDC, lpString, nCount, lpRect, uFormat, color); } + + return DrawText(hDC, lpString, nCount, lpRect, uFormat); } int skin_DrawIconEx(HDC hdc, int xLeft, int yTop, HICON hIcon, int cxWidth, int cyWidth, @@ -142,13 +133,13 @@ int skin_DrawIconEx(HDC hdc, int xLeft, int yTop, HICON hIcon, int cxWidth, int // Similar to DrawText win32 api function // Pass uFormat | DT_CALCRECT to calc rectangle to be returned by lpRect // parseInfo is optional (pass NULL and it will be calculated and deleted inside function -int Smileys_DrawText(HDC hDC, LPCSTR lpString, int nCount, LPRECT lpRect, UINT uFormat, const char *protocol, SmileysParseInfo parseInfo) +int Smileys_DrawText(HDC hDC, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT uFormat, const char *protocol, SmileysParseInfo parseInfo) { SmileysParseInfo info; int ret; if (nCount < 0) - nCount = strlen(lpString); + nCount = _tcslen(lpString); // Get parse info if (parseInfo == NULL) @@ -225,7 +216,7 @@ int Smileys_DrawText(HDC hDC, LPCSTR lpString, int nCount, LPRECT lpRect, UINT u -SIZE GetTextSize(HDC hdcMem, const char *szText, SortedList *plText, UINT uTextFormat, int max_smiley_height) +SIZE GetTextSize(HDC hdcMem, const TCHAR *szText, SortedList *plText, UINT uTextFormat, int max_smiley_height) { SIZE text_size; @@ -248,7 +239,7 @@ SIZE GetTextSize(HDC hdcMem, const char *szText, SortedList *plText, UINT uTextF } else { - if (!(uTextFormat & DT_RESIZE_SMILEYS)) + if ( !(uTextFormat & DT_RESIZE_SMILEYS)) text_size.cy = max(text_size.cy, max_smiley_height); text_size.cx = 0; @@ -287,12 +278,10 @@ SIZE GetTextSize(HDC hdcMem, const char *szText, SortedList *plText, UINT uTextF return text_size; } -void DrawTextSmiley(HDC hdcMem, RECT free_rc, const char *szText, int len, SortedList *plText, UINT uTextFormat, int max_smiley_height) +void DrawTextSmiley(HDC hdcMem, RECT free_rc, const TCHAR *szText, int len, SortedList *plText, UINT uTextFormat, int max_smiley_height) { if (szText == NULL) - { return; - } uTextFormat &= ~DT_RIGHT; @@ -308,7 +297,7 @@ void DrawTextSmiley(HDC hdcMem, RECT free_rc, const char *szText, int len, Sorte i = 0; // Get real height of the line - text_height = skin_DrawText(hdcMem, "A", 1, &tmp_rc, DT_CALCRECT | uTextFormat); + text_height = skin_DrawText(hdcMem, _T("A"), 1, &tmp_rc, DT_CALCRECT | uTextFormat); if (uTextFormat & DT_RESIZE_SMILEYS) row_height = text_height; else @@ -317,7 +306,7 @@ void DrawTextSmiley(HDC hdcMem, RECT free_rc, const char *szText, int len, Sorte // Just draw ellipsis if (free_rc.right <= free_rc.left) { - skin_DrawText(hdcMem, "...", 3, &free_rc, uTextFormat & ~DT_END_ELLIPSIS); + skin_DrawText(hdcMem, _T("..."), 3, &free_rc, uTextFormat & ~DT_END_ELLIPSIS); } else { @@ -381,7 +370,7 @@ void DrawTextSmiley(HDC hdcMem, RECT free_rc, const char *szText, int len, Sorte else { text_rc.top += (row_height - text_height) >> 1; - skin_DrawText(hdcMem, "...", 3, &text_rc, uTextFormat); + skin_DrawText(hdcMem, _T("..."), 3, &text_rc, uTextFormat); } pos_x += (LONG)(piece->smiley_width * factor); @@ -420,7 +409,7 @@ void DestroySmileyList( SortedList* p_list ) // Generete the list of smileys / text to be drawn -SortedList * ReplaceSmileys(const char *text, int text_size, const char *protocol, int *max_smiley_height) +SortedList * ReplaceSmileys(const TCHAR *text, int text_size, const char *protocol, int *max_smiley_height) { SMADD_BATCHPARSE2 sp = {0}; SMADD_BATCHPARSERES *spres; @@ -435,7 +424,7 @@ SortedList * ReplaceSmileys(const char *text, int text_size, const char *protoco // Parse it! sp.cbSize = sizeof(sp); sp.Protocolname = protocol; - sp.str = (char *)text; + sp.str = (TCHAR*)text; sp.oflag = SAFL_TCHAR; spres = (SMADD_BATCHPARSERES *) CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&sp); @@ -448,13 +437,13 @@ SortedList * ReplaceSmileys(const char *text, int text_size, const char *protoco // Lets add smileys SortedList *plText = List_Create(0, 10); - const char *next_text_pos = text; - const char *last_text_pos = _tcsninc(text, text_size); + const TCHAR *next_text_pos = text; + const TCHAR *last_text_pos = _tcsninc(text, text_size); for (unsigned int i = 0; i < sp.numSmileys; i++) { - char * start = _tcsninc(text, spres[i].startChar); - char * end = _tcsninc(start, spres[i].size); + TCHAR* start = _tcsninc(text, spres[i].startChar); + TCHAR* end = _tcsninc(start, spres[i].size); if (spres[i].hIcon != NULL) // For deffective smileypacks { diff --git a/plugins/Utils/mir_smileys.h b/plugins/Utils/mir_smileys.h index cfbebb853a..8b3b2a504b 100644 --- a/plugins/Utils/mir_smileys.h +++ b/plugins/Utils/mir_smileys.h @@ -55,13 +55,13 @@ void Smileys_FreeParse(SmileysParseInfo parseInfo); // Similar to DrawText win32 api function // Pass uFormat | DT_CALCRECT to calc rectangle to be returned by lpRect // parseInfo is optional (pass NULL and it will be calculated and deleted inside function) -int Smileys_DrawText(HDC hDC, LPCSTR lpString, int nCount, LPRECT lpRect, UINT uFormat, const char *protocol, SmileysParseInfo parseInfo); +int Smileys_DrawText(HDC hDC, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT uFormat, const char *protocol, SmileysParseInfo parseInfo); // TODO: // int Smileys_DrawTextW(HDC hDC, LPCWSTR lpString, int nCount, LPRECT lpRect, UINT uFormat, const char *protocol, SmileysParseInfo parseInfo); -int skin_DrawText(HDC hDC, LPCSTR lpString, int nCount, LPRECT lpRect, UINT uFormat); +int skin_DrawText(HDC hDC, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT uFormat); int skin_DrawIconEx(HDC hdc, int xLeft, int yTop, HICON hIcon, int cxWidth, int cyWidth, UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, UINT diFlags); -- cgit v1.2.3