From 122baf7f7465e0b5b890729d65914f527db1ca26 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 17 Jun 2012 14:07:44 +0000 Subject: Unicode ACKTYPE_AWAYMSG broadcast git-svn-id: http://svn.miranda-ng.org/main/trunk@458 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Clist_modern/modern_clc.cpp | 24 +--- plugins/Clist_mw/clistmod.cpp | 8 +- plugins/NewAwaySysMod/ReadAwayMsg.cpp | 2 +- plugins/NewXstatusNotify/popup.cpp | 95 +++++++--------- plugins/SimpleStatusMsg/awaymsg.cpp | 61 ++-------- plugins/TipperYM/message_pump.cpp | 136 +++++++++++----------- protocols/AimOscar/proto.cpp | 88 +++++++-------- protocols/AimOscar/server.cpp | 5 +- protocols/Gadu-Gadu/services.c | 16 +-- protocols/IRCG/commandmonitor.cpp | 2 +- protocols/IcqOscarJ/fam_03buddy.cpp | 20 +--- protocols/IcqOscarJ/icq_proto.cpp | 26 ++--- protocols/JabberG/jabber_proto.cpp | 22 ++-- protocols/MSN/msn_commands.cpp | 207 +++++++++++++++++----------------- protocols/MSN/msn_proto.cpp | 115 ++++++++++--------- protocols/Twitter/contacts.cpp | 16 +-- protocols/Yahoo/proto.cpp | 153 +++++++++++++------------ src/modules/srawaymsg/awaymsg.cpp | 14 +-- 18 files changed, 448 insertions(+), 562 deletions(-) diff --git a/plugins/Clist_modern/modern_clc.cpp b/plugins/Clist_modern/modern_clc.cpp index bc7a5a4f66..aeb301a8d5 100644 --- a/plugins/Clist_modern/modern_clc.cpp +++ b/plugins/Clist_modern/modern_clc.cpp @@ -2055,28 +2055,8 @@ int ClcDoProtoAck(HANDLE wParam,ACKDATA * ack) if(ModernGetSettingByte(ack->hContact, ack->szModule, "ChatRoom", 0) != 0) return 0; } - { - DBVARIANT dbv={0}; - BOOL bUnicode = (!ModernGetSetting(ack->hContact, "CList", "StatusMsg", &dbv) && (dbv.type !=DBVT_ASCIIZ) ); - ModernDBFreeVariant(&dbv); - if (!bUnicode) - { - char * val= ModernGetStringA(ack->hContact,"CList","StatusMsg"); - if (val) - { - if (!mir_bool_strcmpi(val,(const char *)ack->lParam)) - ModernWriteSettingString(ack->hContact,"CList","StatusMsg",(const char *)ack->lParam); - else - gtaRenewText(ack->hContact); - mir_free_and_nill(val); - } - else - ModernWriteSettingString(ack->hContact,"CList","StatusMsg",(const char *)ack->lParam); - - //pcli->pfnClcBroadcast( INTM_STATUSMSGCHANGED,(WPARAM)ack->hContact,(LPARAM)ack->lParam); - } - gtaRenewText(ack->hContact); - } + ModernWriteSettingTString(ack->hContact,"CList","StatusMsg",(const TCHAR *)ack->lParam); + gtaRenewText(ack->hContact); } else { diff --git a/plugins/Clist_mw/clistmod.cpp b/plugins/Clist_mw/clistmod.cpp index 6551c8d03e..5f769427f8 100644 --- a/plugins/Clist_mw/clistmod.cpp +++ b/plugins/Clist_mw/clistmod.cpp @@ -66,7 +66,7 @@ int cli_IconFromStatusMode(const char *szProto,int nStatus, HANDLE hContact) if (ServiceExists(AdvancedService)) result = CallService(AdvancedService,(WPARAM)hActContact, (LPARAM)0); - if (result == -1 || !(LOWORD(result))) + if (result == -1 || !(LOWORD(result))) // result == -1 means no Advanced icon. LOWORD(result) == 0 happens when Advanced icon returned by ICQ (i.e. no transpot) result = saveIconFromStatusMode(szActProto,nActStatus,NULL); } @@ -101,15 +101,15 @@ static int ProtocolAck(WPARAM wParam,LPARAM lParam) ACKDATA *ack = (ACKDATA*)lParam; if (ack->type == ACKTYPE_AWAYMSG && ack->lParam) { DBVARIANT dbv; - if (!DBGetContactSettingString(ack->hContact, "CList", "StatusMsg", &dbv)) { - if (!strcmp(dbv.pszVal, (char *)ack->lParam)) { + if (!DBGetContactSettingTString(ack->hContact, "CList", "StatusMsg", &dbv)) { + if ( !_tcscmp(dbv.ptszVal, (TCHAR *)ack->lParam)) { DBFreeVariant(&dbv); return 0; } DBFreeVariant(&dbv); } if ( DBGetContactSettingByte(NULL,"CList","ShowStatusMsg",0) || DBGetContactSettingByte(ack->hContact,"CList","StatusMsgAuto",0)) - DBWriteContactSettingString(ack->hContact, "CList", "StatusMsg", (char *)ack->lParam); + DBWriteContactSettingTString(ack->hContact, "CList", "StatusMsg", (TCHAR *)ack->lParam); } return 0; diff --git a/plugins/NewAwaySysMod/ReadAwayMsg.cpp b/plugins/NewAwaySysMod/ReadAwayMsg.cpp index f0b6c46706..6d197b7614 100644 --- a/plugins/NewAwaySysMod/ReadAwayMsg.cpp +++ b/plugins/NewAwaySysMod/ReadAwayMsg.cpp @@ -93,7 +93,7 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam UnhookEvent(awayData->hAwayMsgEvent); awayData->hAwayMsgEvent = NULL; } - SetDlgItemTextA(hwndDlg, IDC_READAWAYMSG_MSG, (const char*)ack->lParam); + SetDlgItemText(hwndDlg, IDC_READAWAYMSG_MSG, (const TCHAR*)ack->lParam); ShowWindow(GetDlgItem(hwndDlg, IDC_READAWAYMSG_RETRIEVE), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_READAWAYMSG_MSG), SW_SHOW); SetDlgItemText(hwndDlg, IDOK, TranslateT("&Close")); diff --git a/plugins/NewXstatusNotify/popup.cpp b/plugins/NewXstatusNotify/popup.cpp index 761ec3578f..c62b061b94 100644 --- a/plugins/NewXstatusNotify/popup.cpp +++ b/plugins/NewXstatusNotify/popup.cpp @@ -26,14 +26,14 @@ extern OPTIONS opt; -void QueryAwayMessage(HWND hWnd, PLUGINDATA *pdp) +void QueryAwayMessage(HWND hWnd, PLUGINDATA *pdp) { HANDLE hContact = PUGetContact(hWnd); char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - if (szProto) + if (szProto) { if ((CallProtoService(szProto, PS_GETCAPS,PFLAGNUM_1, 0) & PF1_MODEMSGRECV) && - (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(pdp->newStatus))) + (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(pdp->newStatus))) { //The following HookEventMessage will hook the ME_PROTO_ACK event and send a WM_AWAYMSG to hWnd when the hooks get notified. pdp->hAwayMsgHook = HookEventMessage(ME_PROTO_ACK, hWnd, WM_AWAYMSG); @@ -43,46 +43,38 @@ void QueryAwayMessage(HWND hWnd, PLUGINDATA *pdp) } } -void ReceivedAwayMessage(HWND hWnd, LPARAM lParam, PLUGINDATA * pdp) +void ReceivedAwayMessage(HWND hWnd, LPARAM lParam, PLUGINDATA * pdp) { - HANDLE hContact = PUGetContact(hWnd); ACKDATA *ack = (ACKDATA *)lParam; - - if (ack->type != ACKTYPE_AWAYMSG) + if (ack->type != ACKTYPE_AWAYMSG || ack->hProcess != pdp->hAwayMsgProcess) return; - if (ack->hProcess == pdp->hAwayMsgProcess) //It's my hProcess, so it's ok to continue. - { - //The first thing we go is removing the hook from the chain to avoid useless calls. - UnhookEvent(pdp->hAwayMsgHook); - pdp->hAwayMsgHook = NULL; + //The first thing we go is removing the hook from the chain to avoid useless calls. + UnhookEvent(pdp->hAwayMsgHook); + pdp->hAwayMsgHook = NULL; - if (ack->result != ACKRESULT_SUCCESS) - return; + if (ack->result != ACKRESULT_SUCCESS) + return; - DBVARIANT dbv; - TCHAR stzText[MAX_SECONDLINE]; + DBVARIANT dbv; + HANDLE hContact = PUGetContact(hWnd); - if (!DBGetContactSettingTString(hContact, MODULE, "LastPopupText", &dbv)) - { - _tcscpy(stzText, dbv.ptszVal); - DBFreeVariant(&dbv); + if ( DBGetContactSettingTString(hContact, MODULE, "LastPopupText", &dbv)) + return; - if (!DBGetContactSettingTString(ack->hContact, "CList", "StatusMsg", &dbv)) - { - if (dbv.ptszVal && dbv.ptszVal[0]) - { - if (stzText[0]) _tcscat(stzText, _T("\n")); - _tcscat(stzText, dbv.ptszVal); - SendMessage(hWnd, WM_SETREDRAW, FALSE, 0); - PUChangeTextT(hWnd, stzText); - SendMessage(hWnd, WM_SETREDRAW, TRUE, 0); - } - DBFreeVariant(&dbv); - } + TCHAR stzText[MAX_SECONDLINE], *tszStatus = (TCHAR*)ack->lParam; + _tcscpy(stzText, dbv.ptszVal); + DBFreeVariant(&dbv); - } - } + if (tszStatus == NULL || *tszStatus == 0) + return; + + if (stzText[0]) + _tcscat(stzText, _T("\n")); + _tcscat(stzText, tszStatus); + SendMessage(hWnd, WM_SETREDRAW, FALSE, 0); + PUChangeTextT(hWnd, stzText); + SendMessage(hWnd, WM_SETREDRAW, TRUE, 0); } void PopupAction(HWND hWnd, BYTE action) @@ -98,7 +90,7 @@ void PopupAction(HWND hWnd, BYTE action) break; } case PCA_OPENMENU: - { + { POINT pt = {0}; HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)hContact, 0); GetCursorPos(&pt); @@ -107,7 +99,7 @@ void PopupAction(HWND hWnd, BYTE action) return; } case PCA_OPENDETAILS: - { + { CallServiceSync(MS_USERINFO_SHOWDIALOG, (WPARAM)hContact, 0); break; } @@ -116,7 +108,7 @@ void PopupAction(HWND hWnd, BYTE action) CallServiceSync(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)hContact, 0); break; } - case PCA_CLOSEPOPUP: + case PCA_CLOSEPOPUP: break; case PCA_DONOTHING: return; @@ -126,36 +118,36 @@ void PopupAction(HWND hWnd, BYTE action) } } -INT_PTR CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { PLUGINDATA *pdp = NULL; - switch(message) + switch(message) { case WM_MEASUREITEM: //Needed by the contact's context menu return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam); case WM_DRAWITEM: //Needed by the contact's context menu return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam); - case WM_COMMAND: + case WM_COMMAND: { //This one returns TRUE if it processed the menu command, and FALSE if it did not process it. - if (CallServiceSync(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)PUGetContact(hwnd))) + if (CallServiceSync(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)PUGetContact(hwnd))) break; PopupAction(hwnd, opt.LeftClickAction); - break; + break; } - case WM_CONTEXTMENU: + case WM_CONTEXTMENU: { PopupAction(hwnd, opt.RightClickAction); break; } - case UM_FREEPLUGINDATA: + case UM_FREEPLUGINDATA: { PLUGINDATA *pdp = (PLUGINDATA *)PUGetPluginData(hwnd); - if (pdp != NULL) + if (pdp != NULL) { - if (pdp->hAwayMsgHook != NULL) + if (pdp->hAwayMsgHook != NULL) { UnhookEvent(pdp->hAwayMsgHook); pdp->hAwayMsgHook = NULL; @@ -165,15 +157,15 @@ INT_PTR CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa } return FALSE; } - case UM_INITPOPUP: + case UM_INITPOPUP: { pdp = (PLUGINDATA *)PUGetPluginData(hwnd); if (pdp != NULL) { char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)PUGetContact(hwnd), 0); - if (szProto && opt.ReadAwayMsg && StatusHasAwayMessage(szProto, pdp->newStatus)) + if (szProto && opt.ReadAwayMsg && StatusHasAwayMessage(szProto, pdp->newStatus)) { - WORD myStatus = (WORD)CallProtoService(szProto, PS_GETSTATUS, 0, 0); + WORD myStatus = (WORD)CallProtoService(szProto, PS_GETSTATUS, 0, 0); if (myStatus != ID_STATUS_INVISIBLE) QueryAwayMessage(hwnd, pdp); } @@ -182,13 +174,12 @@ INT_PTR CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa return FALSE; } case WM_AWAYMSG: //We're here because ME_PROTO_ACK has been hooked to this window (too!). - { + { pdp = (PLUGINDATA *)PUGetPluginData(hwnd); if (pdp != NULL) ReceivedAwayMessage(hwnd, lParam, pdp); return FALSE; - } + } } return DefWindowProc(hwnd, message, wParam, lParam); } - diff --git a/plugins/SimpleStatusMsg/awaymsg.cpp b/plugins/SimpleStatusMsg/awaymsg.cpp index 5aebe1edb1..705b860cc5 100644 --- a/plugins/SimpleStatusMsg/awaymsg.cpp +++ b/plugins/SimpleStatusMsg/awaymsg.cpp @@ -137,28 +137,12 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP if (ack->result != ACKRESULT_SUCCESS) break; if (dat->hAwayMsgEvent && ack->hProcess == dat->hSeq) { UnhookEvent(dat->hAwayMsgEvent); dat->hAwayMsgEvent = NULL; } + TCHAR *tszMsg = StrNormNewline((TCHAR*)ack->lParam); + SetDlgItemText(hwndDlg, IDC_MSG, tszMsg); + mir_free(tszMsg); - DBVARIANT dbv; - bool unicode = !DBGetContactSetting(dat->hContact, "CList", "StatusMsg", &dbv) && - (dbv.type == DBVT_UTF8 || dbv.type == DBVT_WCHAR); - DBFreeVariant(&dbv); - if (unicode) - { - DBGetContactSettingWString(dat->hContact, "CList", "StatusMsg", &dbv); - TCHAR *tszMsg = StrNormNewline(dbv.pwszVal); - SetDlgItemText(hwndDlg, IDC_MSG, tszMsg); - mir_free(tszMsg); - DBFreeVariant(&dbv); - } - else - - { - char *szMsg = StrNormNewlineA((char *)ack->lParam); - SetDlgItemTextA(hwndDlg, IDC_MSG, szMsg); - mir_free(szMsg); - } - - if (ack->lParam && *((char*)ack->lParam) != '\0') EnableWindow(GetDlgItem(hwndDlg, IDC_COPY), TRUE); + if (ack->lParam && *((char*)ack->lParam) != '\0') + EnableWindow(GetDlgItem(hwndDlg, IDC_COPY), TRUE); ShowWindow(GetDlgItem(hwndDlg, IDC_RETRIEVING), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_MSG), SW_SHOW); SetDlgItemText(hwndDlg, IDOK, TranslateT("&Close")); @@ -257,7 +241,7 @@ static INT_PTR CALLBACK CopyAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP } case HM_AWAYMSG: - { + { ACKDATA *ack = (ACKDATA*)lParam; if (ack->hContact != dat->hContact || ack->type != ACKTYPE_AWAYMSG) { DestroyWindow(hwndDlg); break; } if (ack->result != ACKRESULT_SUCCESS) { DestroyWindow(hwndDlg); break; } @@ -267,35 +251,15 @@ static INT_PTR CALLBACK CopyAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP if (EmptyClipboard()) { TCHAR msg[1024]; - int len; - - DBVARIANT dbv; - bool unicode = !DBGetContactSetting(dat->hContact, "CList", "StatusMsg", &dbv) && - (dbv.type == DBVT_UTF8 || dbv.type == DBVT_WCHAR); - DBFreeVariant(&dbv); - if (unicode) - { - DBGetContactSettingWString(dat->hContact, "CList", "StatusMsg", &dbv); - TCHAR *tszMsg = StrNormNewline(dbv.pwszVal); - mir_sntprintf(msg, SIZEOF(msg), _T("%s"), tszMsg); - mir_free(tszMsg); - DBFreeVariant(&dbv); - } - else - - { - char *szMsg = StrNormNewlineA((char *)ack->lParam); - mir_sntprintf(msg, SIZEOF(msg), _T("%hs"), szMsg); - mir_free(szMsg); - } - len = lstrlen(msg); - + TCHAR *tszMsg = StrNormNewline((TCHAR*)ack->lParam); + mir_sntprintf(msg, SIZEOF(msg), _T("%s"), tszMsg); + mir_free(tszMsg); + size_t len = lstrlen(msg); if (len) { LPTSTR lptstrCopy; HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (len + 1) * sizeof(TCHAR)); - if (hglbCopy == NULL) - { + if (hglbCopy == NULL) { CloseClipboard(); DestroyWindow(hwndDlg); break; @@ -306,7 +270,6 @@ static INT_PTR CALLBACK CopyAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP GlobalUnlock(hglbCopy); SetClipboardData(CF_UNICODETEXT, hglbCopy); - } } CloseClipboard(); @@ -362,7 +325,7 @@ static char *StrFindURL(char *pszStr) if (pszURL == NULL) pszURL = strstr(pszStr, "ftp://"); } - + return pszURL; } diff --git a/plugins/TipperYM/message_pump.cpp b/plugins/TipperYM/message_pump.cpp index 4aab0f10b3..ed29d48234 100644 --- a/plugins/TipperYM/message_pump.cpp +++ b/plugins/TipperYM/message_pump.cpp @@ -15,7 +15,7 @@ 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. +Boston, MA 02111-1307, USA. */ #include "common.h" @@ -30,7 +30,7 @@ BOOL (WINAPI *MyUpdateLayeredWindow)(HWND hwnd, HDC hdcDST, POINT *pptDst, SIZE BOOL (WINAPI *MyAnimateWindow)(HWND hWnd,DWORD dwTime,DWORD dwFlags) = 0; HMONITOR (WINAPI *MyMonitorFromPoint)(POINT, DWORD); BOOL (WINAPI *MyGetMonitorInfo)(HMONITOR, LPMONITORINFO); -HRESULT (WINAPI *MyDwmEnableBlurBehindWindow)(HWND hWnd, DWM_BLURBEHIND *pBlurBehind) = 0; +HRESULT (WINAPI *MyDwmEnableBlurBehindWindow)(HWND hWnd, DWM_BLURBEHIND *pBlurBehind) = 0; unsigned int uintMessagePumpThreadId = 0; POINT pt = {-1}; @@ -43,11 +43,11 @@ __inline bool IsContactTooltip(CLCINFOTIPEX *clc) return (clc->szProto || clc->swzText) == false; } -void CALLBACK TimerProcWaitForContent(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) +void CALLBACK TimerProcWaitForContent(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) { KillTimer(0, WaitForContentTimerID); WaitForContentTimerID = 0; - bStatusMsgReady = true; + bStatusMsgReady = true; bAvatarReady = true; PostMPMessage(MUM_CREATEPOPUP, 0, 0); } @@ -61,13 +61,13 @@ bool NeedWaitForContent(CLCINFOTIPEX *clcitex) char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)clcitex->hItem, 0); if (!szProto) return false; - if (opt.bWaitForStatusMsg && !bStatusMsgReady) + if (opt.bWaitForStatusMsg && !bStatusMsgReady) { DBDeleteContactSetting(clcitex->hItem, MODULE, "TempStatusMsg"); if (CanRetrieveStatusMsg(clcitex->hItem, szProto) && - CallContactService(clcitex->hItem, PSS_GETAWAYMSG, 0, 0)) + CallContactService(clcitex->hItem, PSS_GETAWAYMSG, 0, 0)) { - if (WaitForContentTimerID) + if (WaitForContentTimerID) KillTimer(0, WaitForContentTimerID); WaitForContentTimerID = SetTimer(NULL, 0, WAIT_TIMER_INTERVAL, TimerProcWaitForContent); @@ -75,41 +75,41 @@ bool NeedWaitForContent(CLCINFOTIPEX *clcitex) } } - if (opt.bWaitForAvatar && !bAvatarReady && - CallProtoService(szProto, PS_GETAVATARCAPS, AF_ENABLED, 0)) + if (opt.bWaitForAvatar && !bAvatarReady && + CallProtoService(szProto, PS_GETAVATARCAPS, AF_ENABLED, 0)) { DBVARIANT dbv; if (!DBGetContactSettingString(clcitex->hItem, "ContactPhoto", "File", &dbv)) - { - if (!strstr(dbv.pszVal, ".xml")) + { + if (!strstr(dbv.pszVal, ".xml")) { AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)clcitex->hItem, 0); - if (!ace) + if (!ace) { - if (WaitForContentTimerID) + if (WaitForContentTimerID) KillTimer(0, WaitForContentTimerID); WaitForContentTimerID = SetTimer(NULL, 0, WAIT_TIMER_INTERVAL, TimerProcWaitForContent); bNeedWait = true; - } + } else bAvatarReady = true; - } + } else bAvatarReady = true; DBFreeVariant(&dbv); - } + } else bAvatarReady = true; } - - } + + } return bNeedWait; } -unsigned int CALLBACK MessagePumpThread(void *param) +unsigned int CALLBACK MessagePumpThread(void *param) { HWND hwndTip = 0; CLCINFOTIPEX *clcitex = 0; @@ -117,23 +117,23 @@ unsigned int CALLBACK MessagePumpThread(void *param) MSG hwndMsg = {0}; while (GetMessage(&hwndMsg, 0, 0, 0) > 0 && !Miranda_Terminated()) { - if (!IsDialogMessage(hwndMsg.hwnd, &hwndMsg)) + if (!IsDialogMessage(hwndMsg.hwnd, &hwndMsg)) { - switch (hwndMsg.message) + switch (hwndMsg.message) { case MUM_CREATEPOPUP: { - if (!clcitex) + if (!clcitex) { if (hwndMsg.lParam) clcitex = (CLCINFOTIPEX *)hwndMsg.lParam; else break; } - if (!NeedWaitForContent(clcitex)) + if (!NeedWaitForContent(clcitex)) { if (hwndTip) MyDestroyWindow(hwndTip); hwndTip = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, POP_WIN_CLASS, NULL, WS_POPUP, 0, 0, 0, 0, 0, 0, hInst, (LPVOID)clcitex); - + if (clcitex) { mir_free(clcitex); @@ -144,10 +144,10 @@ unsigned int CALLBACK MessagePumpThread(void *param) bAvatarReady = false; } break; - } + } case MUM_DELETEPOPUP: { - if (hwndTip) + if (hwndTip) { MyDestroyWindow(hwndTip); hwndTip = 0; @@ -168,12 +168,12 @@ unsigned int CALLBACK MessagePumpThread(void *param) HANDLE hContact = (HANDLE)hwndMsg.wParam; TCHAR *swzMsg = (TCHAR *)hwndMsg.lParam; - if (opt.bWaitForContent && - bStatusMsgReady == false && - clcitex && + if (opt.bWaitForContent && + bStatusMsgReady == false && + clcitex && clcitex->hItem == hContact) { - if (WaitForContentTimerID) + if (WaitForContentTimerID) { KillTimer(0, WaitForContentTimerID); WaitForContentTimerID = 0; @@ -181,23 +181,23 @@ unsigned int CALLBACK MessagePumpThread(void *param) if (swzMsg) { - DBWriteContactSettingTString(clcitex->hItem, MODULE, "TempStatusMsg", swzMsg); + DBWriteContactSettingTString(clcitex->hItem, MODULE, "TempStatusMsg", swzMsg); mir_free(swzMsg); } bStatusMsgReady = true; PostMPMessage(MUM_CREATEPOPUP, 0, 0); - } - else if (!opt.bWaitForContent && hwndTip) + } + else if (!opt.bWaitForContent && hwndTip) SendMessage(hwndTip, PUM_SETSTATUSTEXT, (WPARAM)hContact, (LPARAM)swzMsg); - else if (swzMsg) + else if (swzMsg) mir_free(swzMsg); break; - } + } case MUM_GOTXSTATUS: { - if (hwndTip && !opt.bWaitForContent) + if (hwndTip && !opt.bWaitForContent) SendMessage(hwndTip, PUM_SHOWXSTATUS, hwndMsg.wParam, 0); break; } @@ -205,10 +205,10 @@ unsigned int CALLBACK MessagePumpThread(void *param) { HANDLE hContact = (HANDLE)hwndMsg.wParam; - if (opt.bWaitForContent && - bAvatarReady == false && - clcitex && - clcitex->hItem == hContact) + if (opt.bWaitForContent && + bAvatarReady == false && + clcitex && + clcitex->hItem == hContact) { if (WaitForContentTimerID) { @@ -216,10 +216,10 @@ unsigned int CALLBACK MessagePumpThread(void *param) WaitForContentTimerID = 0; } - bAvatarReady = true; + bAvatarReady = true; PostMPMessage(MUM_CREATEPOPUP, 0, 0); - } - else if (!opt.bWaitForContent && hwndTip) + } + else if (!opt.bWaitForContent && hwndTip) SendMessage(hwndTip, PUM_SETAVATAR, hwndMsg.wParam, 0); break; @@ -237,12 +237,12 @@ unsigned int CALLBACK MessagePumpThread(void *param) return 0; } -void PostMPMessage(UINT msg, WPARAM wParam, LPARAM lParam) +void PostMPMessage(UINT msg, WPARAM wParam, LPARAM lParam) { PostThreadMessage(uintMessagePumpThreadId, msg, wParam, lParam); } -void InitMessagePump() +void InitMessagePump() { WNDCLASSEX wcl = {0}; wcl.cbSize = sizeof(wcl); @@ -254,7 +254,7 @@ void InitMessagePump() RegisterClassEx(&wcl); HMODULE hUserDll = LoadLibrary(_T("user32.dll")); - if (hUserDll) + if (hUserDll) { MySetLayeredWindowAttributes = (BOOL (WINAPI *)(HWND,COLORREF,BYTE,DWORD))GetProcAddress(hUserDll, "SetLayeredWindowAttributes"); MyUpdateLayeredWindow = (BOOL (WINAPI *)(HWND hwnd, HDC hdcDST, POINT *pptDst, SIZE *psize, HDC hdcSrc, POINT *pptSrc, COLORREF crKey, BLENDFUNCTION *pblend, DWORD dwFlags))GetProcAddress(hUserDll, "UpdateLayeredWindow"); @@ -271,13 +271,13 @@ void InitMessagePump() CloseHandle(mir_forkthreadex(MessagePumpThread, NULL, 0, &uintMessagePumpThreadId)); } -void DeinitMessagePump() +void DeinitMessagePump() { PostMPMessage(WM_QUIT, 0, 0); UnregisterClass(POP_WIN_CLASS, hInst); } -INT_PTR ShowTip(WPARAM wParam, LPARAM lParam) +INT_PTR ShowTip(WPARAM wParam, LPARAM lParam) { CLCINFOTIP *clcit = (CLCINFOTIP *)lParam; HWND clist = (HWND)CallService(MS_CLUI_GETHWNDTREE, 0, 0); @@ -294,7 +294,7 @@ INT_PTR ShowTip(WPARAM wParam, LPARAM lParam) clcit2->swzText = NULL; if (wParam) // wParam is char pointer containing text - e.g. status bar tooltip - { + { clcit2->swzText = a2t((char *)wParam); GetCursorPos(&clcit2->ptCursor); } @@ -303,13 +303,13 @@ INT_PTR ShowTip(WPARAM wParam, LPARAM lParam) return 1; } -int ShowTipHook(WPARAM wParam, LPARAM lParam) +int ShowTipHook(WPARAM wParam, LPARAM lParam) { ShowTip(wParam, lParam); return 0; } -INT_PTR ShowTipW(WPARAM wParam, LPARAM lParam) +INT_PTR ShowTipW(WPARAM wParam, LPARAM lParam) { CLCINFOTIP *clcit = (CLCINFOTIP *)lParam; HWND clist = (HWND)CallService(MS_CLUI_GETHWNDTREE, 0, 0); @@ -326,7 +326,7 @@ INT_PTR ShowTipW(WPARAM wParam, LPARAM lParam) clcit2->swzText = NULL; if (wParam) // wParam is char pointer containing text - e.g. status bar tooltip - { + { clcit2->swzText = mir_tstrdup((TCHAR *)wParam); GetCursorPos(&clcit2->ptCursor); } @@ -335,7 +335,7 @@ INT_PTR ShowTipW(WPARAM wParam, LPARAM lParam) return 1; } -INT_PTR HideTip(WPARAM wParam, LPARAM lParam) +INT_PTR HideTip(WPARAM wParam, LPARAM lParam) { //CLCINFOTIP *clcit = (CLCINFOTIP *)lParam; if (GetAsyncKeyState(VK_CONTROL) & 0x8000) @@ -346,29 +346,23 @@ INT_PTR HideTip(WPARAM wParam, LPARAM lParam) return 1; } -int HideTipHook(WPARAM wParam, LPARAM lParam) +int HideTipHook(WPARAM wParam, LPARAM lParam) { HideTip(wParam, lParam); return 0; } -int ProtoAck(WPARAM wParam, LPARAM lParam) +int ProtoAck(WPARAM wParam, LPARAM lParam) { - DBVARIANT dbv; ACKDATA *ack = (ACKDATA *)lParam; if (ack->result != ACKRESULT_SUCCESS) return 0; - if (ack->type == ACKTYPE_AWAYMSG) - { - if (!DBGetContactSettingTString(ack->hContact, "CList", "StatusMsg", &dbv)) - { - if (dbv.ptszVal[0]) - PostMPMessage(MUM_GOTSTATUS, (WPARAM)ack->hContact, (LPARAM)mir_tstrdup(dbv.ptszVal)); - - DBFreeVariant(&dbv); - } - } + if (ack->type == ACKTYPE_AWAYMSG) { + TCHAR* tszMsg = ( TCHAR* )ack->lParam; + if ( lstrlen(tszMsg)) + PostMPMessage(MUM_GOTSTATUS, (WPARAM)ack->hContact, (LPARAM)mir_tstrdup(tszMsg)); + } else if (ack->type == ICQACKTYPE_XSTATUS_RESPONSE) { PostMPMessage(MUM_GOTXSTATUS, (WPARAM)ack->hContact, 0); @@ -377,14 +371,14 @@ int ProtoAck(WPARAM wParam, LPARAM lParam) return 0; } -int AvatarChanged(WPARAM wParam, LPARAM lParam) +int AvatarChanged(WPARAM wParam, LPARAM lParam) { HANDLE hContact = (HANDLE)wParam; PostMPMessage(MUM_GOTAVATAR, (WPARAM)hContact, 0); return 0; } -int FramesShowSBTip(WPARAM wParam, LPARAM lParam) +int FramesShowSBTip(WPARAM wParam, LPARAM lParam) { if (opt.bStatusBarTips) { @@ -402,9 +396,9 @@ int FramesShowSBTip(WPARAM wParam, LPARAM lParam) return 0; } -int FramesHideSBTip(WPARAM wParam, LPARAM lParam) +int FramesHideSBTip(WPARAM wParam, LPARAM lParam) { - if (opt.bStatusBarTips) + if (opt.bStatusBarTips) { PostMPMessage(MUM_DELETEPOPUP, 0, 0); return 1; @@ -412,7 +406,7 @@ int FramesHideSBTip(WPARAM wParam, LPARAM lParam) return 0; } -BOOL MyDestroyWindow(HWND hwnd) +BOOL MyDestroyWindow(HWND hwnd) { SendMessage(hwnd, PUM_FADEOUTWINDOW, 0, 0); return DestroyWindow(hwnd); diff --git a/protocols/AimOscar/proto.cpp b/protocols/AimOscar/proto.cpp index e122ebe0ae..c8ea97f3d7 100644 --- a/protocols/AimOscar/proto.cpp +++ b/protocols/AimOscar/proto.cpp @@ -22,7 +22,7 @@ along with this program. If not, see . CAimProto::CAimProto(const char* aProtoName, const TCHAR* aUserName) : chat_rooms(5) { - m_iVersion = 2; + m_iVersion = 2; m_tszUserName = mir_tstrdup(aUserName); m_szModuleName = mir_strdup(aProtoName); m_szProtoName = mir_strdup(aProtoName); @@ -39,7 +39,7 @@ CAimProto::CAimProto(const char* aProtoName, const TCHAR* aUserName) InitializeCriticalSection(&connMutex); CreateProtoService(PS_CREATEACCMGRUI, &CAimProto::SvcCreateAccMgrUI); - + CreateProtoService(PS_GETMYAWAYMSG, &CAimProto::GetMyAwayMsg); CreateProtoService(PS_GETAVATARINFOT, &CAimProto::GetAvatarInfo); @@ -118,7 +118,7 @@ CAimProto::~CAimProto() mir_free(CHATNAV_COOKIE); mir_free(ADMIN_COOKIE); mir_free(username); - + mir_free(m_szModuleName); mir_free(m_tszUserName); mir_free(m_szProtoName); @@ -185,13 +185,13 @@ int __cdecl CAimProto::AuthRecv(HANDLE hContact, PROTORECVEVENT* evt) // PSS_AUTHREQUEST int __cdecl CAimProto::AuthRequest(HANDLE hContact, const TCHAR* szMessage) -{ +{ //Not a real authrequest- only used b/c we don't know the group until now. if (state != 1) return 1; DBVARIANT dbv; - if (!DBGetContactSettingStringUtf(hContact, MOD_KEY_CL, OTH_KEY_GP, &dbv) && dbv.pszVal[0]) + if (!DBGetContactSettingStringUtf(hContact, MOD_KEY_CL, OTH_KEY_GP, &dbv) && dbv.pszVal[0]) { add_contact_to_group(hContact, dbv.pszVal); DBFreeVariant(&dbv); @@ -202,7 +202,7 @@ int __cdecl CAimProto::AuthRequest(HANDLE hContact, const TCHAR* szMessage) } //////////////////////////////////////////////////////////////////////////////////////// -// ChangeInfo +// ChangeInfo HANDLE __cdecl CAimProto::ChangeInfo(int iInfoType, void* pInfoData) { @@ -215,7 +215,7 @@ HANDLE __cdecl CAimProto::ChangeInfo(int iInfoType, void* pInfoData) HANDLE __cdecl CAimProto::FileAllow(HANDLE hContact, HANDLE hTransfer, const PROTOCHAR* szPath) { file_transfer *ft = (file_transfer*)hTransfer; - if (ft && ft_list.find_by_ft(ft)) + if (ft && ft_list.find_by_ft(ft)) { char *path = mir_utf8encodeT(szPath); @@ -227,7 +227,7 @@ HANDLE __cdecl CAimProto::FileAllow(HANDLE hContact, HANDLE hTransfer, const PRO path = (char*)mir_realloc(path, path_len + len); mir_snprintf(&path[path_len], len, "%s\\", ft->file); } - + mir_free(ft->file); ft->file = path; @@ -249,12 +249,12 @@ int __cdecl CAimProto::FileCancel(HANDLE hContact, HANDLE hTransfer) aim_chat_deny(hServerConn, seqno, ft->sn, ft->icbm_cookie); - if (ft->hConn) + if (ft->hConn) { Netlib_Shutdown(ft->hConn); SetEvent(ft->hResumeEvent); } - else + else ft_list.remove_by_ft(ft); return 0; @@ -282,7 +282,7 @@ int __cdecl CAimProto::FileResume(HANDLE hTransfer, int* action, const PROTOCHAR file_transfer *ft = (file_transfer*)hTransfer; if (!ft_list.find_by_ft(ft)) return 0; - switch (*action) + switch (*action) { case FILERESUME_RESUME: { @@ -320,7 +320,7 @@ int __cdecl CAimProto::FileResume(HANDLE hTransfer, int* action, const PROTOCHAR DWORD_PTR __cdecl CAimProto::GetCaps(int type, HANDLE hContact) { - switch (type) + switch (type) { case PFLAGNUM_1: return PF1_IM | PF1_MODEMSG | PF1_BASICSEARCH | PF1_SEARCHBYEMAIL | PF1_FILE; @@ -367,7 +367,7 @@ HICON __cdecl CAimProto::GetIcon(int iconIndex) { if (iconIndex & PLIF_ICOLIBHANDLE) return (HICON)GetIconHandle("aim"); - + bool big = (iconIndex & PLIF_SMALL) == 0; HICON hIcon = LoadIconEx("aim", big); @@ -397,11 +397,11 @@ void __cdecl CAimProto::basic_search_ack_success(void* p) char *sn = normalize_name((char*)p); if (sn) // normalize it { - if (strlen(sn) > 32) + if (strlen(sn) > 32) { sendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE) 1, 0); } - else + else { PROTOSEARCHRESULT psr = {0}; psr.cbSize = sizeof(psr); @@ -483,7 +483,7 @@ int __cdecl CAimProto::RecvMsg(HANDLE hContact, PROTORECVEVENT* pre) char *omsg = pre->szMessage; char *bbuf = NULL; - if (getByte(AIM_KEY_FI, 1)) + if (getByte(AIM_KEY_FI, 1)) { LOG("Converting from html to bbcodes then stripping leftover html."); pre->szMessage = bbuf = html_to_bbcodes(pre->szMessage); @@ -521,16 +521,16 @@ HANDLE __cdecl CAimProto::SendFile(HANDLE hContact, const PROTOCHAR* szDescripti { if (state != 1) return 0; - if (hContact && szDescription && ppszFiles) + if (hContact && szDescription && ppszFiles) { DBVARIANT dbv; - if (!getString(hContact, AIM_KEY_SN, &dbv)) + if (!getString(hContact, AIM_KEY_SN, &dbv)) { file_transfer *ft = new file_transfer(hContact, dbv.pszVal, NULL); bool isDir = false; int count = 0; - while (ppszFiles[count] != NULL) + while (ppszFiles[count] != NULL) { struct _stati64 statbuf; if (_tstati64(ppszFiles[count++], &statbuf) == 0) @@ -564,12 +564,12 @@ HANDLE __cdecl CAimProto::SendFile(HANDLE hContact, const PROTOCHAR* szDescripti ft_list.insert(ft); - if (ft->me_force_proxy) + if (ft->me_force_proxy) { LOG("We are forcing a proxy file transfer."); ForkThread(&CAimProto::accept_file_thread, ft); } - else + else { aim_send_file(hServerConn, seqno, detected_ip, local_port, false, ft); } @@ -591,10 +591,10 @@ void __cdecl CAimProto::msg_ack_success(void* param) msg_ack_param *msg_ack = (msg_ack_param*)param; Sleep(150); - sendBroadcast(msg_ack->hContact, ACKTYPE_MESSAGE, - msg_ack->success ? ACKRESULT_SUCCESS : ACKRESULT_FAILED, + sendBroadcast(msg_ack->hContact, ACKTYPE_MESSAGE, + msg_ack->success ? ACKRESULT_SUCCESS : ACKRESULT_FAILED, (HANDLE)msg_ack->id, (LPARAM)msg_ack->msg); - + mir_free(msg_ack); } @@ -621,10 +621,10 @@ int __cdecl CAimProto::SendMsg(HANDLE hContact, int flags, const char* pszSrc) } char* msg; - if (flags & PREF_UNICODE) + if (flags & PREF_UNICODE) { const char* p = strchr(pszSrc, '\0'); - if (p != pszSrc) + if (p != pszSrc) { while (*(++p) == '\0'); } @@ -638,12 +638,12 @@ int __cdecl CAimProto::SendMsg(HANDLE hContact, int flags, const char* pszSrc) char* smsg = html_encode(msg); mir_free(msg); - if (getByte(AIM_KEY_FO, 1)) + if (getByte(AIM_KEY_FO, 1)) { msg = bbcodes_to_html(smsg); mir_free(smsg); } - else + else msg = smsg; bool blast = getBool(hContact, AIM_KEY_BLS, false); @@ -651,7 +651,7 @@ int __cdecl CAimProto::SendMsg(HANDLE hContact, int flags, const char* pszSrc) mir_free(msg); mir_free(sn); - + if (!res || blast || 0 == getByte(AIM_KEY_DC, 1)) { msg_ack_param *msg_ack = (msg_ack_param*)mir_alloc(sizeof(msg_ack_param)); @@ -723,7 +723,7 @@ int __cdecl CAimProto::SetStatus(int iNewStatus) } else if (m_iStatus > ID_STATUS_OFFLINE) { - switch(iNewStatus) + switch(iNewStatus) { case ID_STATUS_ONLINE: aim_set_status(hServerConn, seqno, AIM_STATUS_ONLINE); @@ -744,7 +744,7 @@ int __cdecl CAimProto::SetStatus(int iNewStatus) aim_set_status(hServerConn, seqno, AIM_STATUS_AWAY); broadcast_status(ID_STATUS_AWAY); break; - } + } } return 0; @@ -759,9 +759,8 @@ void __cdecl CAimProto::get_online_msg_thread(void* arg) const HANDLE hContact = arg; DBVARIANT dbv; - if (!DBGetContactSettingString(hContact, MOD_KEY_CL, OTH_KEY_SM, &dbv)) - { - sendBroadcast(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)dbv.pszVal); + if (!DBGetContactSettingTString(hContact, MOD_KEY_CL, OTH_KEY_SM, &dbv)) { + sendBroadcast(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)dbv.ptszVal); DBFreeVariant(&dbv); } else sendBroadcast(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)0); @@ -773,8 +772,7 @@ HANDLE __cdecl CAimProto::GetAwayMsg(HANDLE hContact) return 0; int status = getWord(hContact, AIM_KEY_ST, ID_STATUS_OFFLINE); - switch (status) - { + switch (status) { case ID_STATUS_AWAY: case ID_STATUS_ONLINE: ForkThread(&CAimProto::get_online_msg_thread, hContact); @@ -791,7 +789,7 @@ HANDLE __cdecl CAimProto::GetAwayMsg(HANDLE hContact) // PSR_AWAYMSG int __cdecl CAimProto::RecvAwayMsg(HANDLE hContact, int statusMode, PROTORECVEVENT* pre) -{ +{ sendBroadcast(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)pre->szMessage); return 0; } @@ -800,7 +798,7 @@ int __cdecl CAimProto::RecvAwayMsg(HANDLE hContact, int statusMode, PROTORECVEVE // PSS_AWAYMSG int __cdecl CAimProto::SendAwayMsg(HANDLE hContact, HANDLE hProcess, const char* msg) -{ +{ return 1; } @@ -843,7 +841,7 @@ int __cdecl CAimProto::SetAwayMsg(int status, const TCHAR* msg) mir_free(last_status_msg); last_status_msg = mir_strdup(nmsg); aim_set_statusmsg(hServerConn, seqno, nmsg); - aim_set_away(hServerConn, seqno, nmsg, + aim_set_away(hServerConn, seqno, nmsg, status == ID_STATUS_AWAY || status == ID_STATUS_OCCUPIED); } return 0; @@ -860,7 +858,7 @@ int __cdecl CAimProto::UserIsTyping(HANDLE hContact, int type) return 0; DBVARIANT dbv; - if (!getBool(hContact, AIM_KEY_BLS, false) && !getString(hContact, AIM_KEY_SN, &dbv)) + if (!getBool(hContact, AIM_KEY_BLS, false) && !getString(hContact, AIM_KEY_SN, &dbv)) { if (type == PROTOTYPE_SELFTYPING_ON) aim_typing_notification(hServerConn, seqno, dbv.pszVal, 0x0002); @@ -876,19 +874,19 @@ int __cdecl CAimProto::UserIsTyping(HANDLE hContact, int type) int __cdecl CAimProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam) { - switch (eventType) + switch (eventType) { - case EV_PROTO_ONLOAD: + case EV_PROTO_ONLOAD: return OnModulesLoaded(0, 0); -// case EV_PROTO_ONEXIT: +// case EV_PROTO_ONEXIT: // return OnPreShutdown(0, 0); case EV_PROTO_ONMENU: InitMainMenus(); break; - case EV_PROTO_ONOPTIONS: + case EV_PROTO_ONOPTIONS: return OnOptionsInit(wParam, lParam); case EV_PROTO_ONERASE: @@ -901,7 +899,7 @@ int __cdecl CAimProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM l case EV_PROTO_ONRENAME: if (hMenuRoot) - { + { CLISTMENUITEM clmi = { 0 }; clmi.cbSize = sizeof(CLISTMENUITEM); clmi.flags = CMIM_NAME | CMIF_TCHAR | CMIF_KEEPUNTRANSLATED; diff --git a/protocols/AimOscar/server.cpp b/protocols/AimOscar/server.cpp index 7cd4601dcd..800f90a882 100644 --- a/protocols/AimOscar/server.cpp +++ b/protocols/AimOscar/server.cpp @@ -547,7 +547,10 @@ void CAimProto::snac_user_online(SNAC &snac)//family 0x0003 char* msg = tlv.part(i + 6, len); char* msg_s = process_status_msg(msg, sn); DBWriteContactSettingStringUtf(hContact, MOD_KEY_CL, OTH_KEY_SM, msg_s); - sendBroadcast(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, NULL, (LPARAM)msg); + + TCHAR* tszMsg = mir_utf8decodeT(msg_s); + sendBroadcast(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, NULL, (LPARAM)tszMsg); + mir_free(tszMsg); mir_free(msg); mir_free(msg_s); } diff --git a/protocols/Gadu-Gadu/services.c b/protocols/Gadu-Gadu/services.c index 7591356f81..7ba24b2328 100644 --- a/protocols/Gadu-Gadu/services.c +++ b/protocols/Gadu-Gadu/services.c @@ -288,7 +288,7 @@ HANDLE gg_basicsearch(PROTO_INTERFACE *proto, const PROTOCHAR *id) return (HANDLE)1; } - ida = gg_t2a(id); + ida = gg_t2a(id); // Add uin and search it gg_pubdir50_add(req, GG_PUBDIR50_UIN, ida); @@ -332,7 +332,7 @@ static HANDLE gg_searchbydetails(PROTO_INTERFACE *proto, const PROTOCHAR *nick, // Add uin and search it if(nick) { - char *nickA = gg_t2a(nick); + char *nickA = gg_t2a(nick); gg_pubdir50_add(req, GG_PUBDIR50_NICKNAME, nickA); strncat(data, nickA, sizeof(data) - strlen(data)); mir_free(nickA); @@ -341,7 +341,7 @@ static HANDLE gg_searchbydetails(PROTO_INTERFACE *proto, const PROTOCHAR *nick, if(firstName) { - char *firstNameA = gg_t2a(firstName); + char *firstNameA = gg_t2a(firstName); gg_pubdir50_add(req, GG_PUBDIR50_FIRSTNAME, firstNameA); strncat(data, firstNameA, sizeof(data) - strlen(data)); mir_free(firstNameA); @@ -350,7 +350,7 @@ static HANDLE gg_searchbydetails(PROTO_INTERFACE *proto, const PROTOCHAR *nick, if(lastName) { - char *lastNameA = gg_t2a(lastName); + char *lastNameA = gg_t2a(lastName); gg_pubdir50_add(req, GG_PUBDIR50_LASTNAME, lastNameA); strncat(data, lastNameA, sizeof(data) - strlen(data)); mir_free(lastNameA); @@ -479,10 +479,10 @@ void __cdecl gg_getawaymsgthread(GGPROTO *gg, void *hContact) DBVARIANT dbv; SleepEx(100, FALSE); - if (!DBGetContactSettingString(hContact, "CList", GG_KEY_STATUSDESCR, &dbv)) + if (!DBGetContactSettingTString(hContact, "CList", GG_KEY_STATUSDESCR, &dbv)) { - ProtoBroadcastAck(GG_PROTO, hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE) 1, (LPARAM) dbv.pszVal); - gg_netlog(gg, "gg_getawaymsg(): Reading away msg \"%s\".", dbv.pszVal); + ProtoBroadcastAck(GG_PROTO, hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE) 1, (LPARAM) dbv.ptszVal); + gg_netlog(gg, "gg_getawaymsg(): Reading away msg <" TCHAR_STR_PARAM ">.", dbv.ptszVal); DBFreeVariant(&dbv); } else @@ -533,7 +533,7 @@ int gg_setawaymsg(PROTO_INTERFACE *proto, int iStatus, const PROTOCHAR *msgt) // Check if we change status here somehow if (*szMsg && msg && !strcmp(*szMsg, msg) - || !*szMsg && (!msg || !*msg)) + || !*szMsg && (!msg || !*msg)) { if (status == gg->proto.m_iDesiredStatus && gg->proto.m_iDesiredStatus == gg->proto.m_iStatus) { diff --git a/protocols/IRCG/commandmonitor.cpp b/protocols/IRCG/commandmonitor.cpp index 352d162c48..57e9aa3517 100644 --- a/protocols/IRCG/commandmonitor.cpp +++ b/protocols/IRCG/commandmonitor.cpp @@ -1709,7 +1709,7 @@ bool CIrcProto::OnIrc_WHOIS_END( const CIrcMessage* pmsg ) CONTACT user = { (TCHAR*)pmsg->parameters[1].c_str(), NULL, NULL, false, false, true}; HANDLE hContact = CList_FindContact( &user ); if ( hContact ) - ProtoBroadcastAck( m_szModuleName, hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE) 1, (LPARAM)( char* )_T2A( WhoisAwayReply.c_str(), getCodepage())); + ProtoBroadcastAck( m_szModuleName, hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE) 1, (LPARAM)WhoisAwayReply.c_str()); } m_manualWhoisCount--; diff --git a/protocols/IcqOscarJ/fam_03buddy.cpp b/protocols/IcqOscarJ/fam_03buddy.cpp index b551066248..3819972a8b 100644 --- a/protocols/IcqOscarJ/fam_03buddy.cpp +++ b/protocols/IcqOscarJ/fam_03buddy.cpp @@ -760,20 +760,12 @@ void CIcqProto::parseStatusNote(DWORD dwUin, char *szUid, HANDLE hContact, oscar deleteSetting(hContact, DBSETTING_STATUS_NOTE); setSettingDword(hContact, DBSETTING_STATUS_NOTE_TIME, dwStatusNoteTS); - { // Broadcast a notification - int nNoteLen = strlennull(szStatusNote); - char *szNoteAnsi = NULL; - - if (nNoteLen) - { // the broadcast does not support unicode - szNoteAnsi = (char*)_alloca(nNoteLen + 1); - utf8_decode_static(szStatusNote, szNoteAnsi, strlennull(szStatusNote) + 1); - } - if (getContactXStatus(hContact) != 0 || !CheckContactCapabilities(hContact, CAPF_STATUS_MESSAGES)) - { - setStatusMsgVar(hContact, szStatusNote, false); - BroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, NULL, (LPARAM)szNoteAnsi); - } + if (getContactXStatus(hContact) != 0 || !CheckContactCapabilities(hContact, CAPF_STATUS_MESSAGES)) { + setStatusMsgVar(hContact, szStatusNote, false); + + TCHAR* tszNote = mir_utf8decodeT(szStatusNote); + BroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, NULL, (LPARAM)tszNote); + mir_free(tszNote); } } SAFE_FREE(&szStatusNote); diff --git a/protocols/IcqOscarJ/icq_proto.cpp b/protocols/IcqOscarJ/icq_proto.cpp index 685c3142a5..342153e976 100644 --- a/protocols/IcqOscarJ/icq_proto.cpp +++ b/protocols/IcqOscarJ/icq_proto.cpp @@ -2130,26 +2130,21 @@ struct status_message_thread_data void __cdecl CIcqProto::GetAwayMsgThread( void *pStatusData ) { status_message_thread_data *pThreadData = (status_message_thread_data*)pStatusData; - - if (pThreadData) - { - char *szAnsiMsg = NULL; - + if (pThreadData) { // wait a little Sleep(100); setStatusMsgVar(pThreadData->hContact, pThreadData->szMessage, false); - if (utf8_decode(pThreadData->szMessage, &szAnsiMsg)) - BroadcastAck(pThreadData->hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, pThreadData->hProcess, (LPARAM)szAnsiMsg); + TCHAR *tszMsg = mir_utf8decodeT(pThreadData->szMessage); + BroadcastAck(pThreadData->hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, pThreadData->hProcess, (LPARAM)tszMsg); + mir_free(tszMsg); - SAFE_FREE(&szAnsiMsg); SAFE_FREE(&pThreadData->szMessage); SAFE_FREE((void**)&pThreadData); } } - //////////////////////////////////////////////////////////////////////////////////////// // PS_GetAwayMsg - returns a contact's away message @@ -2249,19 +2244,16 @@ HANDLE __cdecl CIcqProto::GetAwayMsg( HANDLE hContact ) int __cdecl CIcqProto::RecvAwayMsg( HANDLE hContact, int statusMode, PROTORECVEVENT* evt ) { - if (evt->flags & PREF_UTF) - { + if (evt->flags & PREF_UTF) { setStatusMsgVar(hContact, evt->szMessage, false); - char* pszMsg = NULL; - utf8_decode(evt->szMessage, &pszMsg); + TCHAR* pszMsg = mir_utf8decodeT(evt->szMessage); BroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)evt->lParam, (LPARAM)pszMsg); - SAFE_FREE(&pszMsg); + mir_free(pszMsg); } - else - { + else { setStatusMsgVar(hContact, evt->szMessage, true); - BroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)evt->lParam, (LPARAM)evt->szMessage); + BroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)evt->lParam, (LPARAM)(TCHAR*)_A2T(evt->szMessage)); } return 0; } diff --git a/protocols/JabberG/jabber_proto.cpp b/protocols/JabberG/jabber_proto.cpp index 350c9d28a8..46042c7640 100644 --- a/protocols/JabberG/jabber_proto.cpp +++ b/protocols/JabberG/jabber_proto.cpp @@ -1407,7 +1407,7 @@ void __cdecl CJabberProto::GetAwayMsgThread( void* hContact ) JABBER_LIST_ITEM *item; JABBER_RESOURCE_STATUS *r; int i, msgCount; - size_t len; + size_t len; if ( !JGetStringT( hContact, "jid", &dbv )) { if (( item = ListGetItemPtr( LIST_ROSTER, dbv.ptszVal )) != NULL ) { @@ -1416,15 +1416,15 @@ void __cdecl CJabberProto::GetAwayMsgThread( void* hContact ) Log( "resourceCount > 0" ); r = item->resource; len = msgCount = 0; - for ( i=0; iresourceCount; i++ ) { + for ( i=0; iresourceCount; i++ ) if ( r[i].statusMessage ) { msgCount++; len += ( _tcslen( r[i].resourceName ) + _tcslen( r[i].statusMessage ) + 8 ); - } } + } TCHAR* str = ( TCHAR* )alloca( sizeof( TCHAR )*( len+1 )); str[0] = str[len] = '\0'; - for ( i=0; i < item->resourceCount; i++ ) { + for ( i=0; i < item->resourceCount; i++ ) if ( r[i].statusMessage ) { if ( str[0] != '\0' ) _tcscat( str, _T("\r\n" )); if ( msgCount > 1 ) { @@ -1433,27 +1433,21 @@ void __cdecl CJabberProto::GetAwayMsgThread( void* hContact ) _tcscat( str, _T(" ): ")); } _tcscat( str, r[i].statusMessage ); - } } + } - char* msg = mir_t2a(str); - char* msg2 = JabberUnixToDos(msg); - JSendBroadcast( hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, ( HANDLE ) 1, ( LPARAM )msg2 ); - mir_free(msg); - mir_free(msg2); + JSendBroadcast( hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)str); return; } if ( item->itemResource.statusMessage != NULL ) { - char* msg = mir_t2a(item->itemResource.statusMessage); - JSendBroadcast( hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, ( HANDLE ) 1, ( LPARAM )msg ); - mir_free(msg); + JSendBroadcast( hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)item->itemResource.statusMessage); return; } } else JFreeVariant( &dbv ); } - JSendBroadcast( hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, ( HANDLE ) 1, ( LPARAM )"" ); + JSendBroadcast( hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, ( HANDLE ) 1, ( LPARAM )0 ); } HANDLE __cdecl CJabberProto::GetAwayMsg( HANDLE hContact ) diff --git a/protocols/MSN/msn_commands.cpp b/protocols/MSN/msn_commands.cpp index af6494f741..3e4ebaa8a8 100644 --- a/protocols/MSN/msn_commands.cpp +++ b/protocols/MSN/msn_commands.cpp @@ -27,14 +27,14 @@ along with this program. If not, see . void MSN_ConnectionProc(HANDLE hNewConnection, DWORD /* dwRemoteIP */, void* extra) { CMsnProto *proto = (CMsnProto*)extra; - + proto->MSN_DebugLog("File transfer connection accepted"); - NETLIBCONNINFO connInfo = { sizeof(connInfo) }; + NETLIBCONNINFO connInfo = { sizeof(connInfo) }; CallService(MS_NETLIB_GETCONNECTIONINFO, (WPARAM)hNewConnection, (LPARAM)&connInfo); ThreadData* T = proto->MSN_GetThreadByPort(connInfo.wPort); - if (T != NULL && T->s == NULL) + if (T != NULL && T->s == NULL) { T->s = hNewConnection; ReleaseSemaphore(T->hWaitEvent, 1, NULL); @@ -79,12 +79,12 @@ void CMsnProto::sttSetMirVer(HANDLE hContact, DWORD dwValue, bool always) setString(hContact, "MirVer", "Miranda IM 0.5.x (MSN v.0.5.x)"); else if (dwValue == 0x30000024) setString(hContact, "MirVer", "Miranda IM 0.4.x (MSN v.0.4.x)"); - else if (always || getByte(hContact, "StdMirVer", 0)) + else if (always || getByte(hContact, "StdMirVer", 0)) { unsigned wlmId = min(dwValue >> 28 & 0xff, SIZEOF(MirVerStr)-1); setString(hContact, "MirVer", MirVerStr[wlmId]); } - else + else return; setByte(hContact, "StdMirVer", 1); @@ -113,19 +113,19 @@ void CMsnProto::sttInviteMessage(ThreadData* info, char* msgBody, char* email, c const char* SessionID = tFileInfo["Session-ID"]; const char* SessionProtocol = tFileInfo["Session-Protocol"]; // const char* Connectivity = tFileInfo["Connectivity"]; - + if (AppGUID != NULL) { - if (!strcmp(AppGUID, "{02D3C01F-BF30-4825-A83A-DE7AF41648AA}")) + if (!strcmp(AppGUID, "{02D3C01F-BF30-4825-A83A-DE7AF41648AA}")) { MSN_ShowPopup(info->getContactHandle(), TranslateT("Contact tried to open an audio conference (currently not supported)"), MSN_ALLOW_MSGBOX); return; - } + } } - if (Invcommand && (strcmp(Invcommand, "CANCEL") == 0)) + if (Invcommand && (strcmp(Invcommand, "CANCEL") == 0)) { delete info->mMsnFtp; info->mMsnFtp = NULL; @@ -199,7 +199,7 @@ void CMsnProto::sttInviteMessage(ThreadData* info, char* msgBody, char* email, c if (Appname == NULL && SessionID != NULL && SessionProtocol != NULL) // netmeeting send 1 { - if (!_stricmp(Invcommand,"ACCEPT")) + if (!_stricmp(Invcommand,"ACCEPT")) { ShellExecuteA(NULL, "open", "conf.exe", NULL, NULL, SW_SHOW); Sleep(3000); @@ -228,7 +228,7 @@ void CMsnProto::sttInviteMessage(ThreadData* info, char* msgBody, char* email, c mir_sntprintf(text, SIZEOF(text), TranslateT("Accept NetMeeting request from %s?"), tszEmail); mir_free(tszEmail); - if (MessageBox(NULL, text, TranslateT("MSN Protocol"), MB_YESNO | MB_ICONQUESTION) == IDYES) + if (MessageBox(NULL, text, TranslateT("MSN Protocol"), MB_YESNO | MB_ICONQUESTION) == IDYES) { nBytes = mir_snprintf(command, sizeof(command), "MIME-Version: 1.0\r\n" @@ -242,7 +242,7 @@ void CMsnProto::sttInviteMessage(ThreadData* info, char* msgBody, char* email, c "IP-Address: %s\r\n\r\n", Invcookie, MyConnection.GetMyExtIPStr()); } - else + else { nBytes = mir_snprintf(command, sizeof(command), "MIME-Version: 1.0\r\n" @@ -340,7 +340,7 @@ void CMsnProto::sttCustomSmiley(const char* msgBody, char* email, char* nick, in void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* params) { - union + union { char* tWords[6]; struct { char *fromEmail, *fromNick, *strMsgBytes; } data; @@ -414,7 +414,7 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para if (tContentType == NULL) return; - if (!_strnicmp(tContentType, "text/x-clientcaps", 17)) + if (!_strnicmp(tContentType, "text/x-clientcaps", 17)) { MimeHeaders tFileInfo; tFileInfo.readFromBuffer(msgBody); @@ -428,7 +428,7 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para deleteSetting(hContact, "StdMirVer"); } } - else if (!ubmMsg && !info->firstMsgRecv) + else if (!ubmMsg && !info->firstMsgRecv) { info->firstMsgRecv = true; MsnContact *cont = Lists_Get(email); @@ -436,7 +436,7 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para sttSetMirVer(cont->hContact, cont->cap1, true); } - if (!_strnicmp(tContentType, "text/plain", 10)) + if (!_strnicmp(tContentType, "text/plain", 10)) { CCSDATA ccs = {0}; @@ -445,19 +445,19 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para const char* p = tHeader["X-MMS-IM-Format"]; bool isRtl = p != NULL && strstr(p, "RL=1") != NULL; - if (info->mJoinedContactsWLID.getCount() > 1) + if (info->mJoinedContactsWLID.getCount() > 1) { if (msnHaveChatDll) MSN_ChatStart(info); else { - for (int j=0; j < info->mJoinedContactsWLID.getCount(); j++) + for (int j=0; j < info->mJoinedContactsWLID.getCount(); j++) { - if (_stricmp(info->mJoinedContactsWLID[j], email) == 0 && j != 0) + if (_stricmp(info->mJoinedContactsWLID[j], email) == 0 && j != 0) { ccs.hContact = info->getContactHandle(); break; - } + } } } } @@ -467,12 +467,12 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para parseWLID(NEWSTR_ALLOCA(email), NULL, &szEmail, NULL); sentMsg = _stricmp(szEmail, MyOptions.szEmail) == 0; if (sentMsg) - ccs.hContact = ubmMsg ? MSN_HContactFromEmail(datau.toEmail, nick) : + ccs.hContact = ubmMsg ? MSN_HContactFromEmail(datau.toEmail, nick) : info->getContactHandle(); } const char* tP4Context = tHeader["P4-Context"]; - if (tP4Context) + if (tP4Context) { size_t newlen = strlen(msgBody) + strlen(tP4Context) + 4; char* newMsgBody = (char*)mir_alloc(newlen); @@ -481,7 +481,7 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para msgBody = newbody = newMsgBody; } - if (info->mChatID[0]) + if (info->mChatID[0]) { GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_MESSAGE }; gcd.ptszID = info->mChatID; @@ -508,7 +508,7 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para if (!sentMsg) { MSN_CallService(MS_PROTO_CONTACTISTYPING, WPARAM(ccs.hContact), 0); - + PROTORECVEVENT pre; pre.szMessage = (char*)msgBody; pre.flags = PREF_UTF + (isRtl ? PREF_RTL : 0); @@ -525,7 +525,7 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para DBEVENTINFO dbei = {0}; bool haveWnd = MSN_MsgWndExist(ccs.hContact); - + dbei.cbSize = sizeof(dbei); dbei.eventType = EVENTTYPE_MESSAGE; dbei.flags = DBEF_SENT | DBEF_UTF | (haveWnd ? 0 : DBEF_READ) | (isRtl ? DBEF_RTL : 0); @@ -537,14 +537,14 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para } } } - else if (!_strnicmp(tContentType, "text/x-msmsgsprofile", 20)) + else if (!_strnicmp(tContentType, "text/x-msmsgsprofile", 20)) { replaceStr(msnExternalIP, tHeader["ClientIP"]); abchMigrated = atol(tHeader["ABCHMigrated"]); langpref = atol(tHeader["lang_preference"]); emailEnabled = atol(tHeader["EmailEnabled"]); - if (!MSN_RefreshContactList()) + if (!MSN_RefreshContactList()) { SendBroadcast(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_NOSERVER); info->sendTerminate(); @@ -555,17 +555,17 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para MSN_EnableMenuItems(true); } } - else if (!_strnicmp(tContentType, "text/x-msmsgscontrol", 20)) + else if (!_strnicmp(tContentType, "text/x-msmsgscontrol", 20)) { const char* tTypingUser = tHeader["TypingUser"]; - if (tTypingUser != NULL && info->mChatID[0] == 0 && _stricmp(email, MyOptions.szEmail)) + if (tTypingUser != NULL && info->mChatID[0] == 0 && _stricmp(email, MyOptions.szEmail)) { HANDLE hContact = MSN_HContactFromEmail(tTypingUser, tTypingUser); MSN_CallService(MS_PROTO_CONTACTISTYPING, (WPARAM) hContact, 7); } } - else if (!_strnicmp(tContentType, "text/x-msnmsgr-datacast", 23)) + else if (!_strnicmp(tContentType, "text/x-msnmsgr-datacast", 23)) { if (info->mJoinedContactsWLID.getCount()) { @@ -652,13 +652,13 @@ void CMsnProto::sttProcessYFind(char* buf, size_t len) { if (buf == NULL) return; ezxml_t xmli = ezxml_parse_str(buf, len); - + ezxml_t dom = ezxml_child(xmli, "d"); const char* szDom = ezxml_attr(dom, "n"); ezxml_t cont = ezxml_child(dom, "c"); const char* szCont = ezxml_attr(cont, "n"); - + char szEmail[128]; mir_snprintf(szEmail, sizeof(szEmail), "%s@%s", szCont, szDom); @@ -679,7 +679,7 @@ void CMsnProto::sttProcessYFind(char* buf, size_t len) mir_free(szEmailT); } SendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, msnSearchId, 0); - + msnSearchId = NULL; } else @@ -700,7 +700,7 @@ void CMsnProto::sttProcessYFind(char* buf, size_t len) } ezxml_free(xmli); -} +} ///////////////////////////////////////////////////////////////////////////////////////// @@ -722,7 +722,7 @@ void CMsnProto::sttProcessAdd(char* buf, size_t len) const char* szNick = ezxml_attr(cont, "f"); int listId = atol(ezxml_attr(cont, "l")); int netId = atol(ezxml_attr(cont, "t")); - + char szEmail[128]; mir_snprintf(szEmail, sizeof(szEmail), "%s@%s", szCont, szDom); @@ -777,13 +777,13 @@ void CMsnProto::sttProcessRemove(char* buf, size_t len) { const char* szCont = ezxml_attr(cont, "n"); int listId = atol(ezxml_attr(cont, "l")); - + char szEmail[128]; mir_snprintf(szEmail, sizeof(szEmail), "%s@%s", szCont, szDom); Lists_Remove(listId, szEmail); MsnContact* msc = Lists_Get(szEmail); - if (msc == NULL || (msc->list & (LIST_RL | LIST_FL | LIST_LL)) == 0) + if (msc == NULL || (msc->list & (LIST_RL | LIST_FL | LIST_LL)) == 0) { if (msc->hContact && _stricmp(szEmail, MyOptions.szEmail)) { @@ -837,8 +837,7 @@ void CMsnProto::sttProcessStatusMessage(char* buf, unsigned len, const char* wli else DBDeleteContactSetting(hContact, "CList", "StatusMsg"); - mir_utf8decode((char*)szStatMsg, NULL); - SendBroadcast(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, NULL, (LPARAM)szStatMsg); + SendBroadcast(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, NULL, (LPARAM)(TCHAR*)_A2T(szStatMsg)); // Process current media info const char* szCrntMda = ezxml_txt(ezxml_child(xmli, "CurrentMedia")); @@ -866,7 +865,7 @@ void CMsnProto::sttProcessStatusMessage(char* buf, unsigned len, const char* wli } // Now let's mount the final string - if (pCount <= 4) + if (pCount <= 4) { deleteSetting(hContact, "ListeningTo"); ezxml_free(xmli); @@ -875,15 +874,15 @@ void CMsnProto::sttProcessStatusMessage(char* buf, unsigned len, const char* wli // Check if there is any info in the string bool foundUsefullInfo = false; - for (unsigned i = 4; i < pCount; i++) + for (unsigned i = 4; i < pCount; i++) { - if (parts[i][0] != '\0') + if (parts[i][0] != '\0') { foundUsefullInfo = true; break; } } - if (!foundUsefullInfo) + if (!foundUsefullInfo) { deleteSetting(hContact, "ListeningTo"); ezxml_free(xmli); @@ -900,16 +899,16 @@ void CMsnProto::sttProcessStatusMessage(char* buf, unsigned len, const char* wli if (ServiceExists(MS_LISTENINGTO_GETUNKNOWNTEXT)) unknown = mir_utf8encodeT((TCHAR *) CallService(MS_LISTENINGTO_GETUNKNOWNTEXT, 0, 0)); - for (unsigned i = 4; i < pCount; i++) + for (unsigned i = 4; i < pCount; i++) { char part[16]; size_t lenPart = mir_snprintf(part, sizeof(part), "{%d}", i - 4); if (parts[i][0] == '\0' && unknown != NULL) parts[i] = unknown; size_t lenPartsI = strlen(parts[i]); - for (p = strstr(format, part); p; p = strstr(p + lenPartsI, part)) + for (p = strstr(format, part); p; p = strstr(p + lenPartsI, part)) { - if (lenPart < lenPartsI) + if (lenPart < lenPartsI) { int loc = p - format; format = (char *)mir_realloc(format, strlen(format) + (lenPartsI - lenPart) + 1); @@ -917,7 +916,7 @@ void CMsnProto::sttProcessStatusMessage(char* buf, unsigned len, const char* wli } memmove(p + lenPartsI, p + lenPart, strlen(p + lenPart) + 1); memmove(p, parts[i], lenPartsI); - } + } } setStringUtf(hContact, "ListeningTo", format); @@ -1010,9 +1009,9 @@ void CMsnProto::sttProcessNotificationMessage(char* buf, unsigned len) size_t sz = 0; const char* acturl = ezxml_attr(xmlact, "url"); - if (acturl == NULL || strstr(acturl, "://") == NULL) + if (acturl == NULL || strstr(acturl, "://") == NULL) sz += mir_snprintf(fullurl+sz, sizeof(fullurl)-sz, "%s", ezxml_attr(xmlnot, "siteurl")); - + sz += mir_snprintf(fullurl+sz, sizeof(fullurl)-sz, "%s", acturl); if (sz != 0 && fullurl[sz-1] != '?') sz += mir_snprintf(fullurl+sz, sizeof(fullurl)-sz, "?"); @@ -1056,7 +1055,7 @@ void CMsnProto::MSN_InitSB(ThreadData* info, const char* szEmail) if (E.msgType == 'X') ; else if (E.msgType == 2571) typing = E.flags != 0; - else if (E.msgSize == 0) + else if (E.msgSize == 0) { info->sendMessage(E.msgType, NULL, 1, E.message, E.flags); SendBroadcast(cont->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)E.seq, 0); @@ -1090,7 +1089,7 @@ void CMsnProto::MSN_InitSB(ThreadData* info, const char* szEmail) if (getByte("EnableDeliveryPopup", 0)) { MSN_ShowPopup(cont->hContact, info->mCaller ? - TranslateT("Chat session established by my request") : + TranslateT("Chat session established by my request") : TranslateT("Chat session established by contact request"), 0); } @@ -1104,12 +1103,12 @@ int CMsnProto::MSN_HandleCommands(ThreadData* info, char* cmdString) char* params = ""; int trid = -1; - if (cmdString[3]) + if (cmdString[3]) { - if (isdigit((BYTE)cmdString[4])) + if (isdigit((BYTE)cmdString[4])) { trid = strtol(cmdString+4, ¶ms, 10); - switch (*params) + switch (*params) { case ' ': case '\0': case '\t': case '\n': while (*params == ' ' || *params == '\t') @@ -1117,7 +1116,7 @@ int CMsnProto::MSN_HandleCommands(ThreadData* info, char* cmdString) break; default: params = cmdString+4; - } + } } else params = cmdString+4; } @@ -1141,7 +1140,7 @@ int CMsnProto::MSN_HandleCommands(ThreadData* info, char* cmdString) else { size_t len = atol(tWords[0]); - sttProcessYFind((char*)HReadBuffer(info, 0).surelyRead(len), len); + sttProcessYFind((char*)HReadBuffer(info, 0).surelyRead(len), len); } break; @@ -1158,7 +1157,7 @@ LBL_InvalidCommand: if (strcmp(tWords[0], "OK") != 0) { size_t len = atol(tWords[0]); - sttProcessAdd((char*)HReadBuffer(info, 0).surelyRead(len), len); + sttProcessAdd((char*)HReadBuffer(info, 0).surelyRead(len), len); } break; } @@ -1177,7 +1176,7 @@ LBL_InvalidCommand: case ' EYB': //********* BYE: section 8.5 Session Participant Changes { - union + union { char* tWords[2]; // modified for chat, orginally param2 = junk @@ -1200,7 +1199,7 @@ LBL_InvalidCommand: MSN_ShowPopup(hContact, TranslateT("Contact left channel"), 0); // modified for chat - if (msnHaveChatDll) + if (msnHaveChatDll) { GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_QUIT }; gcd.ptszID = info->mChatID; @@ -1226,7 +1225,7 @@ LBL_InvalidCommand: // see if the session is quit due to idleness if (info->mChatID[0] && personleft == 1) { - if (!strcmp(data.isIdle, "1")) + if (!strcmp(data.isIdle, "1")) { GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_INFORMATION }; gcd.ptszID = info->mChatID; @@ -1244,13 +1243,13 @@ LBL_InvalidCommand: } else { - if (!Miranda_Terminated() && MessageBox(NULL, + if (!Miranda_Terminated() && MessageBox(NULL, TranslateT("There is only 1 person left in the chat, do you want to switch back to standard message window?"), TranslateT("MSN Chat"), MB_YESNO|MB_ICONQUESTION) == IDYES) { // kill chat dlg and open srmm dialog MSN_KillChatSession(info->mChatID); - + // open up srmm dialog when quit while 1 person left HANDLE hContact = info->getContactHandle(); if (hContact) CallServiceSync(MS_MSG_SENDMESSAGE, (WPARAM)hContact, 0); @@ -1281,7 +1280,7 @@ LBL_InvalidCommand: if (msc->netId == NETID_MOB) setWord(msc->hContact, "Status", ID_STATUS_ONTHEPHONE); - } + } } if (newStatus != ID_STATUS_IDLE) { @@ -1308,8 +1307,8 @@ LBL_InvalidCommand: break; case ' NLF': //********* FLN: section 7.9 Notification Messages - { - union + { + union { char* tWords[2]; struct { char *userEmail, *netId; } data; @@ -1322,7 +1321,7 @@ LBL_InvalidCommand: HANDLE hContact = MSN_HContactFromEmail(data.userEmail); if (hContact != NULL) { - setWord(hContact, "Status", MSN_GetThreadByContact(data.userEmail) ? + setWord(hContact, "Status", MSN_GetThreadByContact(data.userEmail) ? ID_STATUS_INVISIBLE : ID_STATUS_OFFLINE); setDword(hContact, "IdleTS", 0); ForkThread(&CMsnProto::MsgQueue_AllClearThread, mir_strdup(data.userEmail)); @@ -1332,7 +1331,7 @@ LBL_InvalidCommand: case ' NLI': case ' NLN': //********* ILN/NLN: section 7.9 Notification Messages { - union + union { char* tWords[5]; struct { char *userStatus, *wlid, *userNick, *objid, *cmdstring; } data; @@ -1385,7 +1384,7 @@ LBL_InvalidCommand: setDword(hContact, "IdleTS", newStatus != ID_STATUS_IDLE ? 0 : time(NULL)); } - if (tArgs > 3 && tArgs <= 5 && cont) + if (tArgs > 3 && tArgs <= 5 && cont) { UrlDecode(data.cmdstring); @@ -1393,7 +1392,7 @@ LBL_InvalidCommand: cont->cap1 = strtoul(data.objid, &end, 10); cont->cap2 = end && *end == ':' ? strtoul(end + 1, NULL, 10) : 0; - if (lastStatus == ID_STATUS_OFFLINE) + if (lastStatus == ID_STATUS_OFFLINE) { DBVARIANT dbv; bool always = getString(hContact, "MirVer", &dbv) != 0; @@ -1401,7 +1400,7 @@ LBL_InvalidCommand: sttSetMirVer(hContact, cont->cap1, always); } - if ((cont->cap1 & 0xf0000000) && data.cmdstring[0] && strcmp(data.cmdstring, "0")) + if ((cont->cap1 & 0xf0000000) && data.cmdstring[0] && strcmp(data.cmdstring, "0")) { char* szAvatarHash = MSN_GetAvatarHash(data.cmdstring); if (szAvatarHash == NULL) goto remove; @@ -1427,7 +1426,7 @@ LBL_InvalidCommand: mir_free(szAvatarHash); } } - else + else { remove: deleteSetting(hContact, "AvatarHash"); @@ -1440,9 +1439,9 @@ remove: // remove(tFileName); SendBroadcast(hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, NULL, 0); - } + } } - else + else { if (lastStatus == ID_STATUS_OFFLINE) deleteSetting(hContact, "MirVer"); @@ -1452,7 +1451,7 @@ remove: } case ' ORI': //********* IRO: section 8.4 Getting Invited to a Switchboard Session { - union + union { char* tWords[5]; struct { char *strThisContact, *totalContacts, *userEmail, *userNick, *flags; } data; @@ -1500,9 +1499,9 @@ remove: if (tNumTokens < 2) goto LBL_InvalidCommand; - UrlDecode(data.userEmail); - - if (strchr(data.userEmail, ';')) + UrlDecode(data.userEmail); + + if (strchr(data.userEmail, ';')) { info->contactJoined(data.userEmail); break; @@ -1512,11 +1511,11 @@ remove: { if (!info->mCaller) { - if (info->mJoinedContactsWLID.getCount() == 1) + if (info->mJoinedContactsWLID.getCount() == 1) { MSN_InitSB(info, info->mJoinedContactsWLID[0]); } - else + else { info->sendCaps(); if (info->mInitialContactWLID && MsgQueue_CheckContact(info->mInitialContactWLID)) @@ -1546,7 +1545,7 @@ remove: info->sendPacket("CAL", (*E.cont)[i]); MSN_ChatStart(info); - + delete E.cont; mir_free(E.wlid); break; @@ -1579,19 +1578,19 @@ remove: mir_utf8decode(data.userNick, NULL); MSN_DebugLog("New contact in channel %s %s", data.userEmail, data.userNick); - if (info->contactJoined(data.userEmail) <= 1) + if (info->contactJoined(data.userEmail) <= 1) { MSN_InitSB(info, data.userEmail); } - else + else { bool chatCreated = info->mChatID[0] != 0; info->sendCaps(); - if (msnHaveChatDll) + if (msnHaveChatDll) { - if (chatCreated) + if (chatCreated) { GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_JOIN }; gcd.ptszID = info->mChatID; @@ -1609,7 +1608,7 @@ remove: mir_free((void*)gce.ptszUID); } else MSN_ChatStart(info); - } + } } break; } @@ -1624,8 +1623,8 @@ remove: case ' KAN': //********* NAK: section 8.7 Instant Messages if (info->mJoinedContactsWLID.getCount() > 0 && MyOptions.SlowSend) - SendBroadcast(info->getContactHandle(), - ACKTYPE_MESSAGE, ACKRESULT_FAILED, + SendBroadcast(info->getContactHandle(), + ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)trid, (LPARAM)MSN_Translate("Message delivery failed")); MSN_DebugLog("Message send failed (trid=%d)", trid); break; @@ -1638,7 +1637,7 @@ remove: sttProcessPage((char*)HReadBuffer(info, 0).surelyRead(trid), trid); break; - case ' FCG': //********* GCF: + case ' FCG': //********* GCF: HReadBuffer(info, 0).surelyRead(atol(params)); break; @@ -1672,7 +1671,7 @@ remove: if (strcmp(tWords[0], "OK") != 0) { size_t len = atol(tWords[0]); - sttProcessRemove((char*)HReadBuffer(info, 0).surelyRead(len), len); + sttProcessRemove((char*)HReadBuffer(info, 0).surelyRead(len), len); } break; } @@ -1716,7 +1715,7 @@ remove: case ' XBU': // UBX : MSNP11+ User Status Message { - union + union { char* tWords[2]; struct { char *wlid, *datalen; } data; @@ -1735,7 +1734,7 @@ remove: case ' NBU': // UBN : MSNP13+ File sharing, P2P Bootstrap, TURN setup. { - union + union { char* tWords[3]; struct { char *email, *typeId, *datalen; } data; @@ -1811,7 +1810,7 @@ remove: } else //dispatch or notification server (section 7.3) { - union + union { char* tWords[4]; struct { char *security, *sequence, *authChallengeInfo, *nonce; } data; @@ -1820,7 +1819,7 @@ remove: if (sttDivideWords(params, 4, tWords) != 4) goto LBL_InvalidCommand; - if (!strcmp(data.security, "SSO")) + if (!strcmp(data.security, "SSO")) { if (MSN_GetPassportAuth()) { @@ -1835,24 +1834,24 @@ remove: ForkThread(&CMsnProto::msn_keepAliveThread, NULL); ForkThread(&CMsnProto::MSNConnDetectThread, NULL); } - else if (!strcmp(data.security, "OK")) + else if (!strcmp(data.security, "OK")) { } else { MSN_DebugLog("Unknown security package '%s'", data.security); - if (info->mType == SERVER_NOTIFICATION) + if (info->mType == SERVER_NOTIFICATION) { SendBroadcast(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_WRONGPROTOCOL); } return 1; - } + } } break; - case ' SFR': // RFS: Refresh Contact List - if (!MSN_RefreshContactList()) + case ' SFR': // RFS: Refresh Contact List + if (!MSN_RefreshContactList()) { MSN_ShowError("Cannot retrieve contact list"); return 1; @@ -1879,17 +1878,17 @@ remove: if (sttDivideWords(params, 1, &protocol1) != 1) goto LBL_InvalidCommand; - if (MyOptions.szEmail[0] == 0) + if (MyOptions.szEmail[0] == 0) { MSN_ShowError("You must specify your e-mail in Options/Network/MSN"); return 1; } /* - if (strcmp(protocol1, msnProtID)) + if (strcmp(protocol1, msnProtID)) { MSN_ShowError("Server has requested an unknown protocol set (%s)", params); - if (info->mType == SERVER_NOTIFICATION) + if (info->mType == SERVER_NOTIFICATION) { SendBroadcast(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_WRONGPROTOCOL); } @@ -1901,7 +1900,7 @@ remove: GetVersionEx((LPOSVERSIONINFO)&osvi); info->sendPacket("CVR","0x0409 %s %d.%d.%d i386 MSNMSGR %s msmsgs %s", - osvi.dwPlatformId >= 2 ? "winnt" : "win", osvi.dwMajorVersion, + osvi.dwPlatformId >= 2 ? "winnt" : "win", osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.wServicePackMajor, msnProductVer, MyOptions.szEmail); @@ -1910,7 +1909,7 @@ remove: } case ' RFX': //******** XFR: sections 7.4 Referral, 8.1 Referral to Switchboard { - union + union { char* tWords[7]; struct { char *type, *newServer, *security, *authChallengeInfo, @@ -1944,7 +1943,7 @@ remove: if (numWords < 4) goto LBL_InvalidCommand; - if (strcmp(data.security, "CKI")) + if (strcmp(data.security, "CKI")) { MSN_DebugLog("Unknown XFR SB security package '%s'", data.security); break; diff --git a/protocols/MSN/msn_proto.cpp b/protocols/MSN/msn_proto.cpp index 75af99f283..10d2ba701d 100644 --- a/protocols/MSN/msn_proto.cpp +++ b/protocols/MSN/msn_proto.cpp @@ -94,11 +94,11 @@ CMsnProto::CMsnProto(const char* aProtoName, const TCHAR* aUserName) : HookProtoEvent(ME_CLIST_GROUPCHANGE, &CMsnProto::OnGroupChange); HookProtoEvent(ME_OPT_INITIALISE, &CMsnProto::OnOptionsInit); HookProtoEvent(ME_CLIST_DOUBLECLICKED, &CMsnProto::OnContactDoubleClicked); - + LoadOptions(); HANDLE hContact = (HANDLE)MSN_CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - while (hContact != NULL) + while (hContact != NULL) { if (MSN_IsMyContact(hContact)) { @@ -120,9 +120,9 @@ CMsnProto::CMsnProto(const char* aProtoName, const TCHAR* aUserName) : if (MyOptions.SlowSend) { - if (DBGetContactSettingDword(NULL, "SRMsg", "MessageTimeout", 10000) < 60000) + if (DBGetContactSettingDword(NULL, "SRMsg", "MessageTimeout", 10000) < 60000) DBWriteContactSettingDword(NULL, "SRMsg", "MessageTimeout", 60000); - if (DBGetContactSettingDword(NULL, "SRMM", "MessageTimeout", 10000) < 60000) + if (DBGetContactSettingDword(NULL, "SRMM", "MessageTimeout", 10000) < 60000) DBWriteContactSettingDword(NULL, "SRMM", "MessageTimeout", 60000); } @@ -142,7 +142,7 @@ CMsnProto::CMsnProto(const char* aProtoName, const TCHAR* aUserName) : P2pSessions_Init(); InitCustomFolders(); - TCHAR szBuffer[MAX_PATH]; + TCHAR szBuffer[MAX_PATH]; char szDbsettings[64]; NETLIBUSER nlu1 = {0}; @@ -209,7 +209,7 @@ CMsnProto::~CMsnProto() int CMsnProto::OnModulesLoaded(WPARAM, LPARAM) { - if (msnHaveChatDll) + if (msnHaveChatDll) { GCREGISTER gcr = {0}; gcr.cbSize = sizeof(GCREGISTER); @@ -252,15 +252,15 @@ HANDLE CMsnProto::AddToListByEmail(const char *email, const char *nick, DWORD fl { HANDLE hContact = MSN_HContactFromEmail(email, nick, true, flags & PALF_TEMPORARY); - if (flags & PALF_TEMPORARY) + if (flags & PALF_TEMPORARY) { - if (DBGetContactSettingByte(hContact, "CList", "NotOnList", 0) == 1) + if (DBGetContactSettingByte(hContact, "CList", "NotOnList", 0) == 1) DBWriteContactSettingByte(hContact, "CList", "Hidden", 1); } - else + else { DBDeleteContactSetting(hContact, "CList", "Hidden"); - if (msnLoggedIn) + if (msnLoggedIn) { // int netId = Lists_GetNetId(email); // if (netId == NETID_UNKNOWN) @@ -285,8 +285,8 @@ HANDLE __cdecl CMsnProto::AddToList(int flags, PROTOSEARCHRESULT* psr) { TCHAR *id = psr->id ? psr->id : psr->email; return AddToListByEmail( - psr->flags & PSR_UNICODE ? UTF8((wchar_t*)id) : UTF8((char*)id), - psr->flags & PSR_UNICODE ? UTF8((wchar_t*)psr->nick) : UTF8((char*)psr->nick), + psr->flags & PSR_UNICODE ? UTF8((wchar_t*)id) : UTF8((char*)id), + psr->flags & PSR_UNICODE ? UTF8((wchar_t*)psr->nick) : UTF8((char*)psr->nick), flags); } @@ -333,11 +333,11 @@ int CMsnProto::AuthRecv(HANDLE hContact, PROTORECVEVENT* pre) // PSS_AUTHREQUEST int __cdecl CMsnProto::AuthRequest(HANDLE hContact, const TCHAR* szMessage) -{ - if (msnLoggedIn) +{ + if (msnLoggedIn) { char email[MSN_MAX_EMAIL_LEN]; - if (getStaticString(hContact, "e-mail", email, sizeof(email))) + if (getStaticString(hContact, "e-mail", email, sizeof(email))) return 1; char* szMsg = mir_utf8encodeT(szMessage); @@ -361,7 +361,7 @@ int __cdecl CMsnProto::AuthRequest(HANDLE hContact, const TCHAR* szMessage) } //////////////////////////////////////////////////////////////////////////////////////// -// ChangeInfo +// ChangeInfo HANDLE __cdecl CMsnProto::ChangeInfo(int iInfoType, void* pInfoData) { @@ -489,7 +489,7 @@ void __cdecl CMsnProto::MsnSearchAckThread(void* arg) SendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, arg, 0); } break; - + case 1: if (strstr(email, "@yahoo.com") == NULL) SendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, arg, 0); @@ -512,8 +512,8 @@ void __cdecl CMsnProto::MsnSearchAckThread(void* arg) HANDLE __cdecl CMsnProto::SearchBasic(const PROTOCHAR* id) { if (!msnLoggedIn) return 0; - - TCHAR* email = mir_tstrdup(id); + + TCHAR* email = mir_tstrdup(id); ForkThread(&CMsnProto::MsnSearchAckThread, email); return email; @@ -546,7 +546,7 @@ HWND __cdecl CMsnProto::CreateExtendedSearchUI(HWND parent) void __cdecl CMsnProto::MsnFileAckThread(void* arg) { filetransfer* ft = (filetransfer*)arg; - + TCHAR filefull[MAX_PATH]; mir_sntprintf(filefull, SIZEOF(filefull), _T("%s\\%s"), ft->std.tszWorkingDir, ft->std.tszCurrentFile); replaceStr(ft->std.tszCurrentFile, filefull); @@ -556,7 +556,7 @@ void __cdecl CMsnProto::MsnFileAckThread(void* arg) bool fcrt = ft->create() != -1; - if (ft->p2p_appID != 0) + if (ft->p2p_appID != 0) { if (fcrt) p2p_sendFeedStart(ft); @@ -575,13 +575,13 @@ HANDLE __cdecl CMsnProto::FileAllow(HANDLE hContact, HANDLE hTransfer, const PRO if (!msnLoggedIn || !p2p_sessionRegistered(ft)) return 0; - if ((ft->std.tszWorkingDir = mir_tstrdup(szPath)) == NULL) + if ((ft->std.tszWorkingDir = mir_tstrdup(szPath)) == NULL) { TCHAR szCurrDir[MAX_PATH]; GetCurrentDirectory(SIZEOF(szCurrDir), szCurrDir); ft->std.tszWorkingDir = mir_tstrdup(szCurrDir); } - else + else { size_t len = _tcslen(ft->std.tszWorkingDir) - 1; if (ft->std.tszWorkingDir[len] == '\\') @@ -603,14 +603,14 @@ int __cdecl CMsnProto::FileCancel(HANDLE hContact, HANDLE hTransfer) if (!msnLoggedIn || !p2p_sessionRegistered(ft)) return 0; - if (!(ft->std.flags & PFTS_SENDING) && ft->fileId == -1) + if (!(ft->std.flags & PFTS_SENDING) && ft->fileId == -1) { if (ft->p2p_appID != 0) p2p_sendStatus(ft, 603); else msnftp_sendAcceptReject (ft, false); } - else + else { ft->bCanceled = true; if (ft->p2p_appID != 0) @@ -636,14 +636,14 @@ int __cdecl CMsnProto::FileDeny(HANDLE hContact, HANDLE hTransfer, const PROTOCH if (!msnLoggedIn || !p2p_sessionRegistered(ft)) return 1; - if (!(ft->std.flags & PFTS_SENDING) && ft->fileId == -1) + if (!(ft->std.flags & PFTS_SENDING) && ft->fileId == -1) { if (ft->p2p_appID != 0) p2p_sendStatus(ft, 603); else msnftp_sendAcceptReject (ft, false); } - else + else { ft->bCanceled = true; if (ft->p2p_appID != 0) @@ -663,7 +663,7 @@ int __cdecl CMsnProto::FileResume(HANDLE hTransfer, int* action, const PROTOCHAR if (!msnLoggedIn || !p2p_sessionRegistered(ft)) return 1; - switch (*action) + switch (*action) { case FILERESUME_SKIP: if (ft->p2p_appID != 0) @@ -677,7 +677,7 @@ int __cdecl CMsnProto::FileResume(HANDLE hTransfer, int* action, const PROTOCHAR default: bool fcrt = ft->create() != -1; - if (ft->p2p_appID != 0) + if (ft->p2p_appID != 0) { if (fcrt) p2p_sendFeedStart(ft); @@ -709,9 +709,8 @@ void __cdecl CMsnProto::MsnGetAwayMsgThread(void* arg) AwayMsgInfo *inf = (AwayMsgInfo*)arg; DBVARIANT dbv; - if (!DBGetContactSettingString(inf->hContact, "CList", "StatusMsg", &dbv)) - { - SendBroadcast(inf->hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)inf->id, (LPARAM)dbv.pszVal); + if (!DBGetContactSettingTString(inf->hContact, "CList", "StatusMsg", &dbv)) { + SendBroadcast(inf->hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)inf->id, (LPARAM)dbv.ptszVal); MSN_FreeVariant(&dbv); } else SendBroadcast(inf->hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)inf->id, (LPARAM)0); @@ -734,7 +733,7 @@ HANDLE __cdecl CMsnProto::GetAwayMsg(HANDLE hContact) DWORD_PTR __cdecl CMsnProto::GetCaps(int type, HANDLE hContact) { - switch(type) + switch(type) { case PFLAGNUM_1: { int result = PF1_IM | PF1_SERVERCLIST | PF1_AUTHREQ | PF1_BASICSEARCH | @@ -749,7 +748,7 @@ DWORD_PTR __cdecl CMsnProto::GetCaps(int type, HANDLE hContact) return PF2_ONLINE | PF2_SHORTAWAY | PF2_LIGHTDND; case PFLAGNUM_4: - return PF4_FORCEAUTH | PF4_FORCEADDED | PF4_SUPPORTTYPING | PF4_AVATARS | PF4_SUPPORTIDLE | PF4_IMSENDUTF | + return PF4_FORCEAUTH | PF4_FORCEADDED | PF4_SUPPORTTYPING | PF4_AVATARS | PF4_SUPPORTIDLE | PF4_IMSENDUTF | PF4_IMSENDOFFLINE | PF4_NOAUTHDENYREASON; case PFLAGNUM_5: @@ -785,7 +784,7 @@ HICON __cdecl CMsnProto::GetIcon(int iconIndex) { if (iconIndex & PLIF_ICOLIBHANDLE) return (HICON)GetIconHandle(IDI_MSN); - + bool big = (iconIndex & PLIF_SMALL) == 0; HICON hIcon = LoadIconEx("main", big); @@ -872,7 +871,7 @@ HANDLE __cdecl CMsnProto::SendFile(HANDLE hContact, const PROTOCHAR* szDescripti sft->std.flags |= PFTS_SENDING; int count = 0; - while (ppszFiles[count] != NULL) + while (ppszFiles[count] != NULL) { struct _stati64 statbuf; if (_tstati64(ppszFiles[count++], &statbuf) == 0 && (statbuf.st_mode & _S_IFDIR) == 0) @@ -882,7 +881,7 @@ HANDLE __cdecl CMsnProto::SendFile(HANDLE hContact, const PROTOCHAR* szDescripti } } - if (sft->openNext() == -1) + if (sft->openNext() == -1) { delete sft; return 0; @@ -923,7 +922,7 @@ void CMsnProto::MsnFakeAck(void* arg) TFakeAckParams* tParam = (TFakeAckParams*)arg; Sleep(150); - tParam->proto->SendBroadcast(tParam->hContact, ACKTYPE_MESSAGE, + tParam->proto->SendBroadcast(tParam->hContact, ACKTYPE_MESSAGE, tParam->msg ? ACKRESULT_FAILED : ACKRESULT_SUCCESS, (HANDLE)tParam->id, LPARAM(tParam->msg)); @@ -942,7 +941,7 @@ int __cdecl CMsnProto::SendMsg(HANDLE hContact, int flags, const char* pszSrc) } char tEmail[MSN_MAX_EMAIL_LEN]; - if (MSN_IsMeByContact(hContact, tEmail)) + if (MSN_IsMeByContact(hContact, tEmail)) { errMsg = MSN_Translate("You cannot send message to yourself"); ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, 999999, errMsg, this)); @@ -988,7 +987,7 @@ int __cdecl CMsnProto::SendMsg(HANDLE hContact, int flags, const char* pszSrc) break; case NETID_YAHOO: - if (strlen(msg) > 1202) + if (strlen(msg) > 1202) { seq = 999996; errMsg = MSN_Translate("Message is too long: MSN messages are limited by 1202 UTF8 chars"); @@ -1002,7 +1001,7 @@ int __cdecl CMsnProto::SendMsg(HANDLE hContact, int flags, const char* pszSrc) break; default: - if (strlen(msg) > 1202) + if (strlen(msg) > 1202) { seq = 999996; errMsg = MSN_Translate("Message is too long: MSN messages are limited by 1202 UTF8 chars"); @@ -1015,7 +1014,7 @@ int __cdecl CMsnProto::SendMsg(HANDLE hContact, int flags, const char* pszSrc) ThreadData* thread = MSN_StartSB(tEmail, isOffline); if (thread == NULL) { - if (isOffline) + if (isOffline) { if (netId != NETID_LCS) { @@ -1083,7 +1082,7 @@ int __cdecl CMsnProto::SetAwayMsg(int status, const TCHAR* msg) // PSR_AWAYMSG int __cdecl CMsnProto::RecvAwayMsg(HANDLE hContact, int statusMode, PROTORECVEVENT* evt) -{ +{ return 1; } @@ -1091,7 +1090,7 @@ int __cdecl CMsnProto::RecvAwayMsg(HANDLE hContact, int statusMode, PROTORECVEVE // PSS_AWAYMSG int __cdecl CMsnProto::SendAwayMsg(HANDLE hContact, HANDLE hProcess, const char* msg) -{ +{ return 1; } @@ -1114,25 +1113,25 @@ int __cdecl CMsnProto::SetStatus(int iNewStatus) { char szPassword[100]; int ps = getStaticString(NULL, "Password", szPassword, sizeof(szPassword)); - if (ps != 0 || *szPassword == 0) + if (ps != 0 || *szPassword == 0) { SendBroadcast(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_WRONGPASSWORD); m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE; return 0; - } - - if (*MyOptions.szEmail == 0) + } + + if (*MyOptions.szEmail == 0) { SendBroadcast(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_BADUSERID); m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE; return 0; - } + } sessionList.destroy(); dcList.destroy(); usingGateway = false; - + int oldMode = m_iStatus; m_iStatus = ID_STATUS_CONNECTING; SendBroadcast(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldMode, m_iStatus); @@ -1144,7 +1143,7 @@ int __cdecl CMsnProto::SetStatus(int iNewStatus) newThread->startThread(&CMsnProto::MSNServerThread, this); } - else + else if (m_iStatus > ID_STATUS_OFFLINE) MSN_SetServerStatus(m_iDesiredStatus); return 0; @@ -1172,7 +1171,7 @@ int __cdecl CMsnProto::UserIsTyping(HANDLE hContact, int type) bool isOffline; ThreadData* thread = MSN_StartSB(tEmail, isOffline); - if (thread == NULL) + if (thread == NULL) { if (isOffline) return 0; MsgQueue_Add(tEmail, 2571, NULL, 0, NULL, typing); @@ -1218,15 +1217,15 @@ int __cdecl CMsnProto::SetApparentMode(HANDLE hContact, int mode) int __cdecl CMsnProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam) { - switch(eventType) + switch(eventType) { - case EV_PROTO_ONLOAD: + case EV_PROTO_ONLOAD: return OnModulesLoaded(0, 0); - case EV_PROTO_ONEXIT: + case EV_PROTO_ONEXIT: return OnPreShutdown(0, 0); - case EV_PROTO_ONOPTIONS: + case EV_PROTO_ONOPTIONS: return OnOptionsInit(wParam, lParam); case EV_PROTO_ONMENU: @@ -1242,8 +1241,8 @@ int __cdecl CMsnProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM l } case EV_PROTO_ONRENAME: - if (mainMenuRoot) - { + if (mainMenuRoot) + { CLISTMENUITEM clmi = {0}; clmi.cbSize = sizeof(CLISTMENUITEM); clmi.flags = CMIM_NAME | CMIF_TCHAR; diff --git a/protocols/Twitter/contacts.cpp b/protocols/Twitter/contacts.cpp index 32df94b12f..a2245c021a 100644 --- a/protocols/Twitter/contacts.cpp +++ b/protocols/Twitter/contacts.cpp @@ -23,7 +23,7 @@ void TwitterProto::AddToListWorker(void *p) // TODO: what happens if there is an error? if(p == 0) return; - + char *name = static_cast(p); try @@ -59,7 +59,7 @@ void TwitterProto::UpdateInfoWorker(void *hContact) { twitter_user user; std::string username; - + DBVARIANT dbv; if( !DBGetContactSettingString(hContact,m_szModuleName,TWITTER_KEY_UN,&dbv) ) { @@ -171,17 +171,11 @@ void TwitterProto::GetAwayMsgWorker(void *hContact) return; DBVARIANT dbv; - if( !DBGetContactSettingString(hContact,"CList","StatusMsg",&dbv) ) - { - ProtoBroadcastAck(m_szModuleName,hContact,ACKTYPE_AWAYMSG,ACKRESULT_SUCCESS, - (HANDLE)1,(LPARAM)dbv.pszVal); + if( !DBGetContactSettingTString(hContact,"CList","StatusMsg",&dbv)) { + ProtoBroadcastAck(m_szModuleName,hContact,ACKTYPE_AWAYMSG,ACKRESULT_SUCCESS, (HANDLE)1,(LPARAM)dbv.ptszVal); DBFreeVariant(&dbv); } - else - { - ProtoBroadcastAck(m_szModuleName,hContact,ACKTYPE_AWAYMSG,ACKRESULT_FAILED, - (HANDLE)1,(LPARAM)0); - } + else ProtoBroadcastAck(m_szModuleName,hContact,ACKTYPE_AWAYMSG,ACKRESULT_FAILED, (HANDLE)1,(LPARAM)0); } HANDLE TwitterProto::GetAwayMsg(HANDLE hContact) diff --git a/protocols/Yahoo/proto.cpp b/protocols/Yahoo/proto.cpp index 4dd453a489..268bdc7358 100644 --- a/protocols/Yahoo/proto.cpp +++ b/protocols/Yahoo/proto.cpp @@ -1,9 +1,9 @@ /* * $Id: proto.cpp 13497 2011-03-25 04:55:36Z borkra $ * - * myYahoo Miranda Plugin + * myYahoo Miranda Plugin * - * Authors: Gennady Feldman (aka Gena01) + * Authors: Gennady Feldman (aka Gena01) * Laurent Marechal (aka Peorth) * * This code is under GPL and is based on AIM, MSN and Miranda source code. @@ -29,7 +29,7 @@ #endif CYahooProto::CYahooProto( const char* aProtoName, const TCHAR* aUserName ) : - m_bLoggedIn( FALSE ), poll_loop( 0 ) + m_bLoggedIn( FALSE ), poll_loop( 0 ) { m_iVersion = 2; m_tszUserName = mir_tstrdup( aUserName ); @@ -38,11 +38,11 @@ CYahooProto::CYahooProto( const char* aProtoName, const TCHAR* aUserName ) : m_startStatus = ID_STATUS_ONLINE; m_connections = NULL; m_connection_tags = 0; - + logoff_buddies(); SkinAddNewSoundExT("mail", m_tszUserName, LPGENT("New E-mail available in Inbox")); - + LoadYahooServices(); IconsInit(); InitCustomFolders(); @@ -52,19 +52,19 @@ CYahooProto::~CYahooProto() { if (m_bLoggedIn) logout(); - + DebugLog("Logged out"); DestroyHookableEvent(hYahooNudge); MenuUninit(); - + mir_free( m_szModuleName ); mir_free( m_tszUserName ); FREE(m_startMsg); - FREE(m_pw_token); - + FREE(m_pw_token); + Netlib_CloseHandle( m_hNetlibUser ); } @@ -81,7 +81,7 @@ INT_PTR CYahooProto::OnModulesLoadedEx( WPARAM, LPARAM ) TCHAR tModuleDescr[ 100 ]; mir_sntprintf(tModuleDescr, SIZEOF(tModuleDescr), TranslateT( "%s plugin connections" ), m_tszUserName); - + NETLIBUSER nlu = {0}; nlu.cbSize = sizeof(nlu); #ifdef HTTP_GATEWAY @@ -91,20 +91,20 @@ INT_PTR CYahooProto::OnModulesLoadedEx( WPARAM, LPARAM ) #endif nlu.szSettingsModule = m_szModuleName; nlu.ptszDescriptiveName = tModuleDescr; - + #ifdef HTTP_GATEWAY - // Here comes the Gateway Code! + // Here comes the Gateway Code! nlu.szHttpGatewayHello = NULL; nlu.szHttpGatewayUserAgent = "User-Agent: Mozilla/4.01 [en] (Win95; I)"; nlu.pfnHttpGatewayInit = YAHOO_httpGatewayInit; nlu.pfnHttpGatewayBegin = NULL; nlu.pfnHttpGatewayWrapSend = YAHOO_httpGatewayWrapSend; nlu.pfnHttpGatewayUnwrapRecv = YAHOO_httpGatewayUnwrapRecv; -#endif - +#endif + m_hNetlibUser = ( HANDLE )YAHOO_CallService( MS_NETLIB_REGISTERUSER, 0, ( LPARAM )&nlu ); MenuContactInit(); - + return 0; } @@ -191,14 +191,14 @@ HANDLE __cdecl CYahooProto::AddToListByEvent( int flags, int /*iContact*/, HANDL //once, you should just do lots of calls. /* TYPE ADDED - blob is: uin(DWORD), hcontact(HANDLE), nick(ASCIIZ), first(ASCIIZ), - last(ASCIIZ), email(ASCIIZ) - + blob is: uin(DWORD), hcontact(HANDLE), nick(ASCIIZ), first(ASCIIZ), + last(ASCIIZ), email(ASCIIZ) + TYPE AUTH REQ - blob is: uin(DWORD), hcontact(HANDLE), nick(ASCIIZ), first(ASCIIZ), + blob is: uin(DWORD), hcontact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ) */ - memcpy(&hContact,( char* )( dbei.pBlob + sizeof( DWORD ) ), sizeof(HANDLE)); + memcpy(&hContact,( char* )( dbei.pBlob + sizeof( DWORD ) ), sizeof(HANDLE)); if (hContact != NULL) { DebugLog("Temp Buddy found at: %p ", hContact); @@ -236,7 +236,7 @@ int CYahooProto::Authorize( HANDLE hdbe ) return 1; HANDLE hContact; - memcpy(&hContact,( char* )( dbei.pBlob + sizeof( DWORD ) ), sizeof(HANDLE)); + memcpy(&hContact,( char* )( dbei.pBlob + sizeof( DWORD ) ), sizeof(HANDLE)); /* Need to remove the buddy from our Miranda Lists */ @@ -246,7 +246,7 @@ int CYahooProto::Authorize( HANDLE hdbe ) char *myid = DBGetString(hContact, m_szModuleName, "MyIdentity"); - DebugLog("Accepting buddy:%s", who); + DebugLog("Accepting buddy:%s", who); accept(myid, who, GetWord(hContact, "yprotoid", 0)); mir_free(myid); @@ -291,7 +291,7 @@ int CYahooProto::AuthDeny( HANDLE hdbe, const TCHAR* reason ) } HANDLE hContact; - memcpy(&hContact, dbei.pBlob + sizeof(DWORD), sizeof(HANDLE)); + memcpy(&hContact, dbei.pBlob + sizeof(DWORD), sizeof(HANDLE)); /* Need to remove the buddy from our Miranda Lists */ if (hContact != NULL) @@ -301,11 +301,11 @@ int CYahooProto::AuthDeny( HANDLE hdbe, const TCHAR* reason ) char *myid = DBGetString(hContact, m_szModuleName, "MyIdentity"); char *u_reason = mir_utf8encodeT(reason); - - DebugLog("Rejecting buddy:%s msg: %s", who, u_reason); + + DebugLog("Rejecting buddy:%s msg: %s", who, u_reason); reject(myid, who, GetWord(hContact, "yprotoid", 0), u_reason); YAHOO_CallService(MS_DB_CONTACT_DELETE, (WPARAM) hContact, 0); - + mir_free(u_reason); mir_free(myid); mir_free(who); @@ -342,19 +342,19 @@ int __cdecl CYahooProto::AuthRecv( HANDLE hContact, PROTORECVEVENT* pre ) // PSS_AUTHREQUEST int __cdecl CYahooProto::AuthRequest( HANDLE hContact, const TCHAR* msg ) -{ +{ DebugLog("[YahooSendAuthRequest]"); - + if (hContact && m_bLoggedIn) { AddBuddy(hContact, "miranda", msg); return 0; // Success } - + return 1; // Failure } //////////////////////////////////////////////////////////////////////////////////////// -// ChangeInfo +// ChangeInfo HANDLE __cdecl CYahooProto::ChangeInfo( int /*iInfoType*/, void* ) { @@ -367,19 +367,19 @@ HANDLE __cdecl CYahooProto::ChangeInfo( int /*iInfoType*/, void* ) DWORD_PTR __cdecl CYahooProto::GetCaps( int type, HANDLE /*hContact*/ ) { int ret = 0; - switch ( type ) { + switch ( type ) { case PFLAGNUM_1: ret = PF1_IM | PF1_ADDED | PF1_AUTHREQ | PF1_MODEMSGRECV | PF1_MODEMSGSEND | PF1_BASICSEARCH | PF1_EXTSEARCH | PF1_FILESEND | PF1_FILERECV| PF1_VISLIST | PF1_SERVERCLIST ; break; case PFLAGNUM_2: - ret = PF2_ONLINE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_ONTHEPHONE | + ret = PF2_ONLINE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_ONTHEPHONE | PF2_OUTTOLUNCH | PF2_INVISIBLE | PF2_LIGHTDND /*| PF2_HEAVYDND*/; break; case PFLAGNUM_3: - ret = PF2_ONLINE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_ONTHEPHONE | + ret = PF2_ONLINE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_ONTHEPHONE | PF2_OUTTOLUNCH | PF2_LIGHTDND ; break; @@ -409,7 +409,7 @@ HICON __cdecl CYahooProto::GetIcon( int iconIndex ) { if (iconIndex & PLIF_ICOLIBHANDLE) return (HICON)GetIconHandle(IDI_YAHOO); - + bool big = (iconIndex & PLIF_SMALL) == 0; HICON hIcon = LoadIconEx("yahoo", big); @@ -426,7 +426,7 @@ HICON __cdecl CYahooProto::GetIcon( int iconIndex ) //////////////////////////////////////////////////////////////////////////////////////// // GetInfo - retrieves a contact info -void __cdecl CYahooProto::get_info_thread(HANDLE hContact) +void __cdecl CYahooProto::get_info_thread(HANDLE hContact) { SleepEx(500, TRUE); ProtoBroadcastAck(m_szModuleName, hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE) 1, 0); @@ -517,11 +517,11 @@ int __cdecl CYahooProto::SetApparentMode( HANDLE hContact, int mode ) int __cdecl CYahooProto::SetStatus( int iNewStatus ) { LOG(("[SetStatus] New status %s", (char *) CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, iNewStatus, 0))); - + if (iNewStatus == ID_STATUS_OFFLINE) { - + logout(); - + } else if (!m_bLoggedIn) { DBVARIANT dbv; int err = 0; @@ -577,15 +577,15 @@ int __cdecl CYahooProto::SetStatus( int iNewStatus ) iNewStatus = ID_STATUS_ONLINE; FREE(m_pw_token); // No Token yet. - + if (!GetString(YAHOO_PWTOKEN, &dbv)) { if (lstrlenA(dbv.pszVal) > 0) { m_pw_token = strdup(dbv.pszVal); - } - + } + DBFreeVariant(&dbv); } - + //DBWriteContactSettingWord(NULL, m_szModuleName, "StartupStatus", status); m_startStatus = iNewStatus; @@ -673,7 +673,7 @@ void __cdecl CYahooProto::get_status_thread(HANDLE hContact) FREE(sm); - SendBroadcast( hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, ( HANDLE )1, ( LPARAM ) fm ); + SendBroadcast( hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, ( HANDLE )1, ( LPARAM )( TCHAR* )_A2T(fm)); } HANDLE __cdecl CYahooProto::GetAwayMsg( HANDLE hContact ) @@ -685,7 +685,7 @@ HANDLE __cdecl CYahooProto::GetAwayMsg( HANDLE hContact ) return 0; /* user offline, what Status message? */ YForkThread(&CYahooProto::get_status_thread, hContact); - return (HANDLE)1; //Success + return (HANDLE)1; //Success } return 0; // Failure @@ -695,7 +695,7 @@ HANDLE __cdecl CYahooProto::GetAwayMsg( HANDLE hContact ) // PSR_AWAYMSG int __cdecl CYahooProto::RecvAwayMsg( HANDLE /*hContact*/, int /*statusMode*/, PROTORECVEVENT* ) -{ +{ return 1; } @@ -703,7 +703,7 @@ int __cdecl CYahooProto::RecvAwayMsg( HANDLE /*hContact*/, int /*statusMode*/, P // PSS_AWAYMSG int __cdecl CYahooProto::SendAwayMsg( HANDLE /*hContact*/, HANDLE /*hProcess*/, const char* ) -{ +{ return 1; } @@ -713,12 +713,12 @@ int __cdecl CYahooProto::SendAwayMsg( HANDLE /*hContact*/, HANDLE /*hProcess*/, int __cdecl CYahooProto::SetAwayMsg( int status, const PROTOCHAR* msg ) { char *c = msg && msg[0] ? mir_utf8encodeT(msg) : NULL; - + DebugLog("[YahooSetAwayMessage] Status: %s, Msg: %s",(char *) CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, status, 0), (char*) c); - + if (!m_bLoggedIn) { if (m_iStatus == ID_STATUS_OFFLINE) { - DebugLog("[YahooSetAwayMessage] WARNING: WE ARE OFFLINE!"); + DebugLog("[YahooSetAwayMessage] WARNING: WE ARE OFFLINE!"); mir_free(c); return 1; } else { @@ -729,26 +729,26 @@ int __cdecl CYahooProto::SetAwayMsg( int status, const PROTOCHAR* msg ) mir_free(c); return 0; } - } - + } + /* need to tell ALL plugins that we are changing status */ BroadcastStatus(status); - + if (m_startMsg) free(m_startMsg); - + /* now decide what we tell the server */ if (c != 0) { m_startMsg = strdup(c); if(status == ID_STATUS_ONLINE) { set_status(YAHOO_CUSTOM_STATUS, c, 0); - } else if(status != ID_STATUS_INVISIBLE) { + } else if(status != ID_STATUS_INVISIBLE) { set_status(YAHOO_CUSTOM_STATUS, c, 1); } } else { set_status(status, NULL, 0); m_startMsg = NULL; } - + mir_free(c); return 0; } @@ -760,7 +760,7 @@ INT_PTR __cdecl CYahooProto::GetMyAwayMsg(WPARAM wParam, LPARAM lParam) { if (!m_bLoggedIn || ! m_startMsg) return 0; - + if (lParam & SGMA_UNICODE) { return (INT_PTR) mir_utf8decodeW(m_startMsg); } else { @@ -805,7 +805,7 @@ int __cdecl CYahooProto::OnEvent( PROTOEVENTTYPE eventType, WPARAM wParam, LPARA break; case EV_PROTO_ONRENAME: - if ( mainMenuRoot ) { + if ( mainMenuRoot ) { CLISTMENUITEM clmi = { 0 }; clmi.cbSize = sizeof(CLISTMENUITEM); clmi.flags = CMIM_NAME | CMIF_TCHAR | CMIF_KEEPUNTRANSLATED; @@ -819,13 +819,13 @@ int __cdecl CYahooProto::OnEvent( PROTOEVENTTYPE eventType, WPARAM wParam, LPARA case EV_PROTO_DBSETTINGSCHANGED: return OnSettingChanged(wParam, lParam); - } + } return 1; } INT_PTR CALLBACK first_run_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - switch (msg) + switch (msg) { case WM_INITDIALOG: { @@ -847,26 +847,26 @@ INT_PTR CALLBACK first_run_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM SetDlgItemTextA(hwndDlg, IDC_PASSWORD, dbv.pszVal); DBFreeVariant(&dbv); } - + SetButtonCheck( hwndDlg, IDC_YAHOO_JAPAN, ppro->GetByte( "YahooJapan", 0 ) ); return TRUE; } case WM_COMMAND: if ( LOWORD( wParam ) == IDC_NEWYAHOOACCOUNTLINK ) { - CallService( MS_UTILS_OPENURL, - 1, + CallService( MS_UTILS_OPENURL, + 1, (( BYTE )IsDlgButtonChecked( hwndDlg, IDC_YAHOO_JAPAN ) == 1) ? ( LPARAM ) "http://edit.yahoo.co.jp/config/eval_register" : - ( LPARAM ) "http://edit.yahoo.com/config/eval_register" + ( LPARAM ) "http://edit.yahoo.com/config/eval_register" ); return TRUE; } - if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) + if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) { switch( LOWORD( wParam )) { - case IDC_HANDLE: + case IDC_HANDLE: case IDC_PASSWORD: case IDC_YAHOO_JAPAN: SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); @@ -875,40 +875,40 @@ INT_PTR CALLBACK first_run_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM break; case WM_NOTIFY: - if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY ) + if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY ) { CYahooProto* ppro = (CYahooProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); char str[128]; DBVARIANT dbv; BOOL reconnectRequired = FALSE; - + GetDlgItemTextA(hwndDlg, IDC_HANDLE, str, sizeof(str)); - + dbv.pszVal = NULL; - + if ( ppro->GetString( YAHOO_LOGINID, &dbv ) || lstrcmpA( str, dbv.pszVal )) reconnectRequired = TRUE; - + if ( dbv.pszVal != NULL ) DBFreeVariant( &dbv ); - + ppro->SetString(YAHOO_LOGINID, str); GetDlgItemTextA(hwndDlg, IDC_PASSWORD, str, sizeof(str)); - + dbv.pszVal = NULL; if ( ppro->GetString( YAHOO_PASSWORD, &dbv ) || lstrcmpA( str, dbv.pszVal )) reconnectRequired = TRUE; if ( dbv.pszVal != NULL ) DBFreeVariant( &dbv ); - + if (reconnectRequired ) { DBDeleteContactSetting(NULL, ppro->m_szModuleName, YAHOO_PWTOKEN); } - + CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(str), (LPARAM) str); ppro->SetString(YAHOO_PASSWORD, str); ppro->SetByte("YahooJapan", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_YAHOO_JAPAN )); - + if ( reconnectRequired && ppro->m_bLoggedIn ) MessageBoxA( hwndDlg, Translate( "The changes you have made require you to reconnect to the Yahoo network before they take effect"), Translate("YAHOO Options"), MB_OK ); @@ -923,7 +923,6 @@ INT_PTR CALLBACK first_run_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM INT_PTR CYahooProto::SvcCreateAccMgrUI(WPARAM wParam, LPARAM lParam) { - return (INT_PTR)CreateDialogParam (hInstance, MAKEINTRESOURCE( IDD_YAHOOACCOUNT ), + return (INT_PTR)CreateDialogParam (hInstance, MAKEINTRESOURCE( IDD_YAHOOACCOUNT ), (HWND)lParam, first_run_dialog, (LPARAM)this ); } - diff --git a/src/modules/srawaymsg/awaymsg.cpp b/src/modules/srawaymsg/awaymsg.cpp index d4435f8e3c..46ce60bd14 100644 --- a/src/modules/srawaymsg/awaymsg.cpp +++ b/src/modules/srawaymsg/awaymsg.cpp @@ -85,19 +85,7 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP if (ack->result != ACKRESULT_SUCCESS) break; if (dat->hAwayMsgEvent && ack->hProcess == dat->hSeq) { UnhookEvent(dat->hAwayMsgEvent); dat->hAwayMsgEvent = NULL; } - - DBVARIANT dbv; - bool unicode = !DBGetContactSetting(dat->hContact, "CList", "StatusMsg", &dbv) && - (dbv.type == DBVT_UTF8 || dbv.type == DBVT_WCHAR); - DBFreeVariant(&dbv); - if (unicode) - { - DBGetContactSettingWString(dat->hContact, "CList", "StatusMsg", &dbv); - SetDlgItemText(hwndDlg, IDC_MSG, dbv.pwszVal); - } - else - - SetDlgItemTextA(hwndDlg, IDC_MSG, (const char*)ack->lParam); + SetDlgItemText(hwndDlg, IDC_MSG, (const TCHAR*)ack->lParam); ShowWindow(GetDlgItem(hwndDlg, IDC_RETRIEVING), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_MSG), SW_SHOW); -- cgit v1.2.3