From a9e4905df31370fb65bf05b4f9068c1648f4e87e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 20 Sep 2012 19:40:57 +0000 Subject: code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@1612 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/MRA/MraAvatars.cpp | 161 +++++++++++++++--------------------- protocols/MRA/MraIcons.cpp | 28 +++---- protocols/MRA/MraProto.h | 3 - protocols/MRA/Mra_functions.cpp | 179 +++++++++++++++++++--------------------- protocols/MRA/Mra_svcs.cpp | 15 ---- 5 files changed, 167 insertions(+), 219 deletions(-) (limited to 'protocols') diff --git a/protocols/MRA/MraAvatars.cpp b/protocols/MRA/MraAvatars.cpp index 67c89f0328..b8c1d1584e 100644 --- a/protocols/MRA/MraAvatars.cpp +++ b/protocols/MRA/MraAvatars.cpp @@ -416,12 +416,7 @@ HANDLE MraAvatarsHttpConnect(HANDLE hNetlibUser, LPSTR lpszHost, DWORD dwPort) nloc.cbSize = sizeof(nloc); nloc.flags = (NLOCF_HTTP|NLOCF_V2); nloc.szHost = lpszHost; - if (IsHTTPSProxyUsed(hNetlibUser)) - {// через https прокси только 443 порт - nloc.wPort = MRA_SERVER_PORT_HTTPS; - }else { - nloc.wPort = (WORD)dwPort; - } + nloc.wPort = ( IsHTTPSProxyUsed(hNetlibUser)) ? MRA_SERVER_PORT_HTTPS : dwPort; nloc.timeout = DBGetContactSettingDword(NULL, MRA_AVT_SECT_NAME, "TimeOutConnect", MRA_AVT_DEFAULT_TIMEOUT_CONN); if (nloc.timeoutMRA_TIMEOUT_CONN_МАХ) nloc.timeout = MRA_TIMEOUT_CONN_МАХ; @@ -439,101 +434,79 @@ HANDLE MraAvatarsHttpConnect(HANDLE hNetlibUser, LPSTR lpszHost, DWORD dwPort) DWORD MraAvatarsHttpTransaction(HANDLE hConnection, DWORD dwRequestType, LPSTR lpszUser, LPSTR lpszDomain, LPSTR lpszHost, DWORD dwReqObj, BOOL bUseKeepAliveConn, DWORD *pdwResultCode, BOOL *pbKeepAlive, DWORD *pdwFormat, size_t *pdwAvatarSize, INTERNET_TIME *pitLastModifiedTime) { - DWORD dwRetErrorCode; + if (pdwResultCode) *pdwResultCode = 0; + if (pbKeepAlive) *pbKeepAlive = FALSE; + if (pdwFormat) *pdwFormat = PA_FORMAT_UNKNOWN; + if (pdwAvatarSize) *pdwAvatarSize = 0; + if (pitLastModifiedTime) bzero(pitLastModifiedTime, sizeof(INTERNET_TIME)); + + if (!hConnection) + return ERROR_INVALID_HANDLE; - if (pdwResultCode) (*pdwResultCode) = 0; - if (pbKeepAlive) (*pbKeepAlive) = FALSE; - if (pdwFormat) (*pdwFormat) = PA_FORMAT_UNKNOWN; - if (pdwAvatarSize) (*pdwAvatarSize) = 0; - if (pitLastModifiedTime)bzero(pitLastModifiedTime, sizeof(INTERNET_TIME)); + LPSTR lpszReqObj; - if (hConnection) - { - char szBuff[4096], szSelfVersionString[MAX_PATH]; - DWORD dwSended, dwBuffSize; - LPSTR lpszReqObj; - NETLIBHTTPHEADER nlbhHeaders[8] = {0}; - NETLIBHTTPREQUEST *pnlhr, nlhr = {0}; - - switch (dwReqObj) { - case MAHTRO_AVT: lpszReqObj = "_avatar"; break; - case MAHTRO_AVTMRIM: lpszReqObj = "_mrimavatar"; break; - case MAHTRO_AVTSMALL: lpszReqObj = "_avatarsmall"; break; - case MAHTRO_AVTSMALLMRIM: lpszReqObj = "_mrimavatarsmall"; break; - default: lpszReqObj = ""; break; - } - dwBuffSize = mir_snprintf(szBuff, SIZEOF(szBuff), "http://%s/%s/%s/%s", lpszHost, lpszDomain, lpszUser, lpszReqObj); - - MraGetSelfVersionString(szSelfVersionString, SIZEOF(szSelfVersionString), NULL); - - nlbhHeaders[0].szName = "User-Agent"; nlbhHeaders[0].szValue = szSelfVersionString; - nlbhHeaders[1].szName = "Accept-Encoding";nlbhHeaders[1].szValue = "deflate"; - nlbhHeaders[2].szName = "Pragma"; nlbhHeaders[2].szValue = "no-cache"; - nlbhHeaders[3].szName = "Connection"; nlbhHeaders[3].szValue = (bUseKeepAliveConn)? "keep-alive":"close"; - //nlbhHeaders[4].szName = "If-Modified-Since";nlbhHeaders[4].szValue = "Thu, 03 Aug 2006 19:54:33 GMT"; - - nlhr.cbSize = sizeof(nlhr); - nlhr.requestType = dwRequestType; - nlhr.flags = (NLHRF_GENERATEHOST|NLHRF_SMARTREMOVEHOST|NLHRF_SMARTAUTHHEADER); - nlhr.szUrl = szBuff; - nlhr.headers = (NETLIBHTTPHEADER*)&nlbhHeaders; - nlhr.headersCount = 4; - //nlhr.pData = NULL; - //nlhr.dataLength = 0; - //nlhr.resultCode = 0; - //nlhr.szResultDescr = NULL; - //nlhr.nlc = NULL; + switch (dwReqObj) { + case MAHTRO_AVT: lpszReqObj = "_avatar"; break; + case MAHTRO_AVTMRIM: lpszReqObj = "_mrimavatar"; break; + case MAHTRO_AVTSMALL: lpszReqObj = "_avatarsmall"; break; + case MAHTRO_AVTSMALLMRIM: lpszReqObj = "_mrimavatarsmall"; break; + default: lpszReqObj = ""; break; + } + + char szBuff[4096], szSelfVersionString[MAX_PATH]; + DWORD dwBuffSize = mir_snprintf(szBuff, SIZEOF(szBuff), "http://%s/%s/%s/%s", lpszHost, lpszDomain, lpszUser, lpszReqObj); + MraGetSelfVersionString(szSelfVersionString, SIZEOF(szSelfVersionString), NULL); + + NETLIBHTTPHEADER nlbhHeaders[8] = {0}; + nlbhHeaders[0].szName = "User-Agent"; nlbhHeaders[0].szValue = szSelfVersionString; + nlbhHeaders[1].szName = "Accept-Encoding"; nlbhHeaders[1].szValue = "deflate"; + nlbhHeaders[2].szName = "Pragma"; nlbhHeaders[2].szValue = "no-cache"; + nlbhHeaders[3].szName = "Connection"; nlbhHeaders[3].szValue = (bUseKeepAliveConn)? "keep-alive":"close"; + + NETLIBHTTPREQUEST *pnlhr, nlhr = {0}; + nlhr.cbSize = sizeof(nlhr); + nlhr.requestType = dwRequestType; + nlhr.flags = (NLHRF_GENERATEHOST|NLHRF_SMARTREMOVEHOST|NLHRF_SMARTAUTHHEADER); + nlhr.szUrl = szBuff; + nlhr.headers = (NETLIBHTTPHEADER*)&nlbhHeaders; + nlhr.headersCount = 4; - dwSended = CallService(MS_NETLIB_SENDHTTPREQUEST, (WPARAM)hConnection, (LPARAM)&nlhr); - if (dwSended != SOCKET_ERROR && dwSended) - { - pnlhr = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_RECVHTTPHEADERS, (WPARAM)hConnection, (LPARAM)0); - if (pnlhr) - { - for (size_t i = 0;i<(size_t)pnlhr->headersCount;i++) - { - if (CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, pnlhr->headers[i].szName, -1, "Connection", 10) == CSTR_EQUAL) - { - if (pbKeepAlive) (*pbKeepAlive) = (CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, pnlhr->headers[i].szValue, -1, "keep-alive", 10) == CSTR_EQUAL); - }else - if (CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, pnlhr->headers[i].szName, -1, "Content-Type", 12) == CSTR_EQUAL) - { - if (pdwFormat) - { - for (size_t j = 0;jheaders[i].szValue, -1, lpcszContentType[j], -1) == CSTR_EQUAL) - { - (*pdwFormat) = j; - break; - } - } - } - }else - if (CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, pnlhr->headers[i].szName, -1, "Content-Length", 14) == CSTR_EQUAL) - { - if (pdwAvatarSize) (*pdwAvatarSize) = StrToUNum(pnlhr->headers[i].szValue, lstrlenA(pnlhr->headers[i].szValue)); - }else - if (CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, pnlhr->headers[i].szName, -1, "Last-Modified", 13) == CSTR_EQUAL) - { - if (pitLastModifiedTime) InternetTimeGetTime(pnlhr->headers[i].szValue, lstrlenA(pnlhr->headers[i].szValue), pitLastModifiedTime); - } - }// end for + DWORD dwSent = CallService(MS_NETLIB_SENDHTTPREQUEST, (WPARAM)hConnection, (LPARAM)&nlhr); + if (dwSent == SOCKET_ERROR || !dwSent) + return GetLastError(); - if (pdwResultCode) (*pdwResultCode) = pnlhr->resultCode; - CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, (WPARAM)0, (LPARAM)pnlhr); - dwRetErrorCode = NO_ERROR; - }else {// err on receive - dwRetErrorCode = GetLastError(); + pnlhr = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_RECVHTTPHEADERS, (WPARAM)hConnection, (LPARAM)0); + if (!pnlhr) + return GetLastError(); + + for (int i = 0; i < pnlhr->headersCount; i++) { + if ( !_strnicmp(pnlhr->headers[i].szName, "Connection", 10)) { + if (pbKeepAlive) + *pbKeepAlive = !_strnicmp(pnlhr->headers[i].szValue, "keep-alive", 10); + } + else if ( !_strnicmp(pnlhr->headers[i].szName, "Content-Type", 12)) { + if (pdwFormat) { + for (DWORD j = 0; j < PA_FORMAT_MAX; j++) { + if ( !_stricmp(pnlhr->headers[i].szValue, lpcszContentType[j])) { + *pdwFormat = j; + break; + } + } } - }else {// err on send http request - dwRetErrorCode = GetLastError(); } - }else { - dwRetErrorCode = ERROR_INVALID_HANDLE; + else if ( !_strnicmp(pnlhr->headers[i].szName, "Content-Length", 14)) { + if (pdwAvatarSize) + *pdwAvatarSize = StrToUNum(pnlhr->headers[i].szValue, lstrlenA(pnlhr->headers[i].szValue)); + } + else if ( !_strnicmp(pnlhr->headers[i].szName, "Last-Modified", 13)) { + if (pitLastModifiedTime) + InternetTimeGetTime(pnlhr->headers[i].szValue, lstrlenA(pnlhr->headers[i].szValue), pitLastModifiedTime); + } } -return(dwRetErrorCode); + if (pdwResultCode) (*pdwResultCode) = pnlhr->resultCode; + CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, (WPARAM)0, (LPARAM)pnlhr); + return 0; } BOOL CMraProto::MraAvatarsGetContactTime(HANDLE hContact, LPSTR lpszValueName, SYSTEMTIME *pstTime) @@ -620,7 +593,7 @@ DWORD CMraProto::MraAvatarsGetFileName(HANDLE hAvatarsQueueHandle, HANDLE hConta mir_free(lpszPathToAvatarsCache); } else { - FoldersGetCustomPathT( pmraaqAvatarsQueue->hAvatarsPath, lpszCurPath, dwPathSize, _T("")); + FoldersGetCustomPathT( pmraaqAvatarsQueue->hAvatarsPath, lpszCurPath, int(dwPathSize), _T("")); dwEMailSize = lstrlen( lpszCurPath ); } diff --git a/protocols/MRA/MraIcons.cpp b/protocols/MRA/MraIcons.cpp index 9477215bff..2d8e3118c1 100644 --- a/protocols/MRA/MraIcons.cpp +++ b/protocols/MRA/MraIcons.cpp @@ -6,9 +6,9 @@ GUI_DISPLAY_ITEM gdiMenuItems[] = { MRA_GOTO_INBOX, MRA_GOTO_INBOX_STR, IDI_INBOX, &CMraProto::MraGotoInbox }, { MRA_SHOW_INBOX_STATUS, MRA_SHOW_INBOX_STATUS_STR, IDI_MAIL_NOTIFY, &CMraProto::MraShowInboxStatus }, { MRA_EDIT_PROFILE, MRA_EDIT_PROFILE_STR, IDI_PROFILE, &CMraProto::MraEditProfile }, - { MRA_MY_ALBUM, MRA_MY_ALBUM_STR, IDI_MRA_PHOTO, &CMraProto::MyAlbum }, - { MRA_MY_BLOG, MRA_MY_BLOG_STR, IDI_MRA_BLOGS, &CMraProto::MyBlog }, - { MRA_MY_BLOGSTATUS, MRA_MY_BLOGSTATUS_STR, IDI_BLOGSTATUS, &CMraProto::MyBlogStatus }, + { MRA_MY_ALBUM, MRA_MY_ALBUM_STR, IDI_MRA_PHOTO, &CMraProto::MraViewAlbum }, + { MRA_MY_BLOG, MRA_MY_BLOG_STR, IDI_MRA_BLOGS, &CMraProto::MraReadBlog }, + { MRA_MY_BLOGSTATUS, MRA_MY_BLOGSTATUS_STR, IDI_BLOGSTATUS, &CMraProto::MraReplyBlogStatus }, { MRA_MY_VIDEO, MRA_MY_VIDEO_STR, IDI_MRA_VIDEO, &CMraProto::MyVideo }, { MRA_MY_ANSWERS, MRA_MY_ANSWERS_STR, IDI_MRA_ANSWERS, &CMraProto::MyAnswers }, { MRA_MY_WORLD, MRA_MY_WORLD_STR, IDI_MRA_WORLD, &CMraProto::MyWorld }, @@ -101,9 +101,12 @@ void IconsLoad() void CMraProto::InitXStatusIcons() { - int iCurIndex; - char szBuff[MAX_PATH]; WCHAR wszSection[MAX_PATH], wszPath[MAX_FILEPATH]; + mir_sntprintf(wszSection, SIZEOF(wszSection), L"Status Icons/%s/Custom Status", m_tszUserName); + if (masMraSettings.hDLLXStatusIcons) + GetModuleFileName(masMraSettings.hDLLXStatusIcons, wszPath, SIZEOF(wszPath)); + else + bzero(wszPath, sizeof(wszPath)); SKINICONDESC sid = {0}; sid.cbSize = sizeof(sid); @@ -112,18 +115,13 @@ void CMraProto::InitXStatusIcons() sid.cx = sid.cy = 16; sid.flags = SIDF_ALL_UNICODE; - if (masMraSettings.hDLLXStatusIcons) - GetModuleFileName(masMraSettings.hDLLXStatusIcons, wszPath, SIZEOF(wszPath)); - else - bzero(wszPath, sizeof(wszPath)); - - mir_sntprintf(wszSection, SIZEOF(wszSection), L"Status Icons/%s/Custom Status", m_tszUserName); - hXStatusAdvancedStatusIcons[0] = NULL; - for (size_t i = 1; i < MRA_XSTATUS_COUNT+1; i++) { + for (int i = 1; i < MRA_XSTATUS_COUNT+1; i++) { + char szBuff[MAX_PATH]; mir_snprintf(szBuff, SIZEOF(szBuff), "%s_xstatus%ld", m_szModuleName, i); - iCurIndex = (IDI_XSTATUS1-1+i); sid.pszName = szBuff; + + int iCurIndex = i+IDI_XSTATUS1-1; sid.pwszDescription = lpcszXStatusNameDef[i]; sid.iDefaultIndex = -iCurIndex; if (masMraSettings.hDLLXStatusIcons) @@ -171,6 +169,7 @@ void CMraProto::CListCreateMenu(LONG lPosition, LONG lPopupPosition, HICON hMain CLISTMENUITEM mi = {0}; mi.cbSize = sizeof(mi); + mi.position = -1999901008; HGENMENU (*fnAddFunc)(CLISTMENUITEM*); if (bIsMain) { @@ -179,7 +178,6 @@ void CMraProto::CListCreateMenu(LONG lPosition, LONG lPopupPosition, HICON hMain HGENMENU hRootMenu = MO_GetProtoRootMenu(m_szModuleName); if (hRootMenu == NULL) { mi.ptszName = m_tszUserName; - mi.position = -1999901008; mi.hParentMenu = HGENMENU_ROOT; mi.flags = CMIF_ROOTPOPUP | CMIF_TCHAR | CMIF_KEEPUNTRANSLATED; mi.hIcon = hMainIcon; diff --git a/protocols/MRA/MraProto.h b/protocols/MRA/MraProto.h index 3203135a29..7c9dafe4a2 100644 --- a/protocols/MRA/MraProto.h +++ b/protocols/MRA/MraProto.h @@ -166,9 +166,6 @@ struct CMraProto : public PROTO_INTERFACE, public MZeroedObject INT_PTR __cdecl MraGotoInbox(WPARAM, LPARAM); INT_PTR __cdecl MraShowInboxStatus(WPARAM, LPARAM); INT_PTR __cdecl MraEditProfile(WPARAM, LPARAM); - INT_PTR __cdecl MyAlbum(WPARAM, LPARAM); - INT_PTR __cdecl MyBlog(WPARAM, LPARAM); - INT_PTR __cdecl MyBlogStatus(WPARAM, LPARAM); INT_PTR __cdecl MyVideo(WPARAM, LPARAM); INT_PTR __cdecl MyAnswers(WPARAM, LPARAM); INT_PTR __cdecl MyWorld(WPARAM, LPARAM); diff --git a/protocols/MRA/Mra_functions.cpp b/protocols/MRA/Mra_functions.cpp index d812e5eb1d..8cca94b907 100644 --- a/protocols/MRA/Mra_functions.cpp +++ b/protocols/MRA/Mra_functions.cpp @@ -459,121 +459,116 @@ DWORD CMraProto::SetContactFlags(HANDLE hContact, DWORD dwContactFlag) DWORD CMraProto::GetContactBasicInfoW(HANDLE hContact, DWORD *pdwID, DWORD *pdwGroupID, DWORD *pdwContactFlag, DWORD *pdwContactSeverFlags, DWORD *pdwStatus, LPSTR lpszEMail, size_t dwEMailSize, size_t *pdwEMailSize, LPWSTR lpwszNick, size_t dwNickSize, size_t *pdwNickSize, LPSTR lpszPhones, size_t dwPhonesSize, size_t *pdwPhonesSize) { - DWORD dwRetErrorCode = NO_ERROR; - - if (IsContactMra(hContact)) - { - if (pdwID) (*pdwID) = mraGetDword(hContact, "ContactID", -1); - if (pdwGroupID) (*pdwGroupID) = mraGetDword(hContact, "GroupID", -1); - if (pdwContactSeverFlags) (*pdwContactSeverFlags) = mraGetDword(hContact, "ContactSeverFlags", 0); - if (pdwStatus) (*pdwStatus) = MraGetContactStatus(hContact); - if (pdwContactFlag) (*pdwContactFlag) = GetContactFlags(hContact); - - if (lpszEMail && pdwEMailSize) mraGetStaticStringA(hContact, "e-mail", lpszEMail, dwEMailSize, pdwEMailSize); - if (lpwszNick && pdwNickSize) - { - DB_GetStaticStringW(hContact, "CList", "MyHandle", lpwszNick, dwNickSize, pdwNickSize); - //if ((*pdwNickSize) == 0) DebugBreak(); - } - if (lpszPhones && pdwPhonesSize) - { - char szPhone[MAX_PATH], szValue[MAX_PATH]; - size_t dwPhoneSize, dwCopyed = 0; + if ( !IsContactMra(hContact)) + return ERROR_INVALID_HANDLE; - for (size_t i = 0;i<3;i++) - { - mir_snprintf(szValue, SIZEOF(szValue), "MyPhone%lu", i); - if (DB_GetStaticStringA(hContact, "UserInfo", szValue, szPhone, SIZEOF(szPhone), &dwPhoneSize)) - { - if (dwCopyed) (*((LPBYTE)(lpszPhones+dwCopyed++))) = ','; - dwCopyed += CopyNumber((lpszPhones+dwCopyed), szPhone, dwPhoneSize); - } + if (pdwID) + *pdwID = mraGetDword(hContact, "ContactID", -1); + if (pdwGroupID) + *pdwGroupID = mraGetDword(hContact, "GroupID", -1); + if (pdwContactSeverFlags) + *pdwContactSeverFlags = mraGetDword(hContact, "ContactSeverFlags", 0); + if (pdwStatus) + *pdwStatus = MraGetContactStatus(hContact); + if (pdwContactFlag) + *pdwContactFlag = GetContactFlags(hContact); + if (lpszEMail && pdwEMailSize) + mraGetStaticStringA(hContact, "e-mail", lpszEMail, dwEMailSize, pdwEMailSize); + if (lpwszNick && pdwNickSize) + DB_GetStaticStringW(hContact, "CList", "MyHandle", lpwszNick, dwNickSize, pdwNickSize); + + if (lpszPhones && pdwPhonesSize) { + char szPhone[MAX_PATH], szValue[MAX_PATH]; + size_t dwPhoneSize, dwCopied = 0; + + for (size_t i = 0; i < 3; i++) { + mir_snprintf(szValue, SIZEOF(szValue), "MyPhone%lu", i); + if ( DB_GetStaticStringA(hContact, "UserInfo", szValue, szPhone, SIZEOF(szPhone), &dwPhoneSize)) { + if (dwCopied) + *((LPBYTE)(lpszPhones+dwCopied++)) = ','; + dwCopied += CopyNumber((lpszPhones+dwCopied), szPhone, dwPhoneSize); } - (*pdwPhonesSize) = dwCopyed; } - }else { - dwRetErrorCode = ERROR_INVALID_HANDLE; + *pdwPhonesSize = dwCopied; } -return(dwRetErrorCode); + return 0; } - DWORD CMraProto::SetContactBasicInfoW(HANDLE hContact, DWORD dwSetInfoFlags, DWORD dwFlags, DWORD dwID, DWORD dwGroupID, DWORD dwContactFlag, DWORD dwContactSeverFlags, DWORD dwStatus, LPSTR lpszEMail, size_t dwEMailSize, LPWSTR lpwszNick, size_t dwNickSize, LPSTR lpszPhones, size_t dwPhonesSize) { - DWORD dwRetErrorCode = NO_ERROR; + if ( !IsContactMra(hContact)) + return ERROR_INVALID_HANDLE; - if (IsContactMra(hContact)) - { - // LOCK - if (dwSetInfoFlags&SCBIFSI_LOCK_CHANGES_EVENTS) mraSetDword(hContact, "HooksLocked", TRUE); + // LOCK + if (dwSetInfoFlags & SCBIFSI_LOCK_CHANGES_EVENTS) + mraSetDword(hContact, "HooksLocked", TRUE); - // поля которые нужны, и изменения которых не отслеживаются - if (dwFlags&SCBIF_ID) mraSetDword(hContact, "ContactID", dwID); + // поля которые нужны, и изменения которых не отслеживаются + if (dwFlags & SCBIF_ID) + mraSetDword(hContact, "ContactID", dwID); - if (dwFlags&SCBIF_EMAIL) - { - if (lpszEMail && dwEMailSize) mraSetStringExA(hContact, "e-mail", lpszEMail, dwEMailSize); - } + if (dwFlags & SCBIF_EMAIL) + if (lpszEMail && dwEMailSize) + mraSetStringExA(hContact, "e-mail", lpszEMail, dwEMailSize); - // поля изменения которых отслеживаются - if (dwFlags&SCBIF_GROUP_ID) mraSetDword(hContact, "GroupID", dwGroupID); + // поля изменения которых отслеживаются + if (dwFlags & SCBIF_GROUP_ID) + mraSetDword(hContact, "GroupID", dwGroupID); - if (dwFlags&SCBIF_NICK) + if (dwFlags & SCBIF_NICK) { + if ((dwFlags & SCBIF_FLAG) && ((dwContactFlag&CONTACT_FLAG_UNICODE_NAME) == 0)) { - if ((dwFlags&SCBIF_FLAG) && ((dwContactFlag&CONTACT_FLAG_UNICODE_NAME) == 0)) - { - if (lpwszNick && dwNickSize) DB_SetStringExA(hContact, "CList", "MyHandle", (LPSTR)lpwszNick, dwNickSize); - }else { - if (lpwszNick && dwNickSize) DB_SetStringExW(hContact, "CList", "MyHandle", lpwszNick, dwNickSize); - //if (dwNickSize == 0) DebugBreak(); - } + if (lpwszNick && dwNickSize) + DB_SetStringExA(hContact, "CList", "MyHandle", (LPSTR)lpwszNick, dwNickSize); } + else { + if (lpwszNick && dwNickSize) + DB_SetStringExW(hContact, "CList", "MyHandle", lpwszNick, dwNickSize); + } + } - if (dwFlags&SCBIF_PHONES) - { - if (lpszPhones && dwPhonesSize) - { - char szPhone[MAX_PATH], szValue[MAX_PATH]; - LPSTR lpszCurPhone, lpszPhoneNext; - size_t i, dwCurPhoneSize; - - i = 0; - lpszCurPhone = lpszPhones; - lpszPhoneNext = lpszPhones; - while(lpszPhoneNext) - { - lpszPhoneNext = (LPSTR)MemoryFindByte((lpszCurPhone-lpszPhones), lpszPhones, dwPhonesSize, ','); - if (lpszPhoneNext) - { - dwCurPhoneSize = (lpszPhoneNext-lpszCurPhone); - }else { - dwCurPhoneSize = ((lpszPhones+dwPhonesSize)-lpszCurPhone); - } - - szPhone[0] = '+'; - memmove((szPhone+1), lpszCurPhone, min(dwCurPhoneSize, (SIZEOF(szPhone)-1))); - mir_snprintf(szValue, SIZEOF(szValue), "MyPhone%lu", i); - DB_SetStringExA(hContact, "UserInfo", szValue, szPhone, (1+dwCurPhoneSize)); + if (dwFlags & SCBIF_PHONES) { + if (lpszPhones && dwPhonesSize) { + char szPhone[MAX_PATH], szValue[MAX_PATH]; + LPSTR lpszCurPhone, lpszPhoneNext; + size_t i, dwCurPhoneSize; + + i = 0; + lpszCurPhone = lpszPhones; + lpszPhoneNext = lpszPhones; + while(lpszPhoneNext) { + lpszPhoneNext = (LPSTR)MemoryFindByte((lpszCurPhone-lpszPhones), lpszPhones, dwPhonesSize, ','); + if (lpszPhoneNext) + dwCurPhoneSize = lpszPhoneNext - lpszCurPhone; + else + dwCurPhoneSize = (lpszPhones + dwPhonesSize) - lpszCurPhone; + + szPhone[0] = '+'; + memmove((szPhone+1), lpszCurPhone, min(dwCurPhoneSize, (SIZEOF(szPhone)-1))); + mir_snprintf(szValue, SIZEOF(szValue), "MyPhone%lu", i); + DB_SetStringExA(hContact, "UserInfo", szValue, szPhone, (1+dwCurPhoneSize)); - i++; - lpszCurPhone = (lpszPhoneNext+1); - } + i++; + lpszCurPhone = (lpszPhoneNext+1); } } + } - if (dwFlags&SCBIF_FLAG) SetContactFlags(hContact, dwContactFlag); + if (dwFlags & SCBIF_FLAG) + SetContactFlags(hContact, dwContactFlag); - if (dwFlags&SCBIF_SERVER_FLAG) mraSetDword(hContact, "ContactSeverFlags", dwContactSeverFlags); + if (dwFlags & SCBIF_SERVER_FLAG) + mraSetDword(hContact, "ContactSeverFlags", dwContactSeverFlags); - if (dwFlags&SCBIF_STATUS) MraSetContactStatus(hContact, dwStatus); + if (dwFlags & SCBIF_STATUS) + MraSetContactStatus(hContact, dwStatus); - SetExtraIcons(hContact); - // UNLOCK - if (dwSetInfoFlags&SCBIFSI_LOCK_CHANGES_EVENTS) mraSetDword(hContact, "HooksLocked", FALSE); - }else { - dwRetErrorCode = ERROR_INVALID_HANDLE; - } -return(dwRetErrorCode); + SetExtraIcons(hContact); + // UNLOCK + if (dwSetInfoFlags & SCBIFSI_LOCK_CHANGES_EVENTS) + mraSetDword(hContact, "HooksLocked", FALSE); + + return 0; } HANDLE CMraProto::MraHContactFromEmail(LPSTR lpszEMail, size_t dwEMailSize, BOOL bAddIfNeeded, BOOL bTemporary, BOOL *pbAdded) diff --git a/protocols/MRA/Mra_svcs.cpp b/protocols/MRA/Mra_svcs.cpp index a69220a1d8..ea600236cd 100644 --- a/protocols/MRA/Mra_svcs.cpp +++ b/protocols/MRA/Mra_svcs.cpp @@ -204,21 +204,6 @@ INT_PTR CMraProto::MraEditProfile(WPARAM wParam, LPARAM lParam) return 0; } -INT_PTR CMraProto::MyAlbum(WPARAM wParam, LPARAM lParam) -{ - return MraViewAlbum(0, 0); -} - -INT_PTR CMraProto::MyBlog(WPARAM wParam, LPARAM lParam) -{ - return MraReadBlog(0, 0); -} - -INT_PTR CMraProto::MyBlogStatus(WPARAM wParam, LPARAM lParam) -{ - return MraReplyBlogStatus(0, 0); -} - INT_PTR CMraProto::MyVideo(WPARAM wParam, LPARAM lParam) { return MraViewVideo(0, 0); -- cgit v1.2.3