diff options
Diffstat (limited to 'protocols/MRA/src/Mra_svcs.cpp')
-rw-r--r-- | protocols/MRA/src/Mra_svcs.cpp | 504 |
1 files changed, 206 insertions, 298 deletions
diff --git a/protocols/MRA/src/Mra_svcs.cpp b/protocols/MRA/src/Mra_svcs.cpp index 992032963d..11b7f37b35 100644 --- a/protocols/MRA/src/Mra_svcs.cpp +++ b/protocols/MRA/src/Mra_svcs.cpp @@ -124,7 +124,7 @@ const LPWSTR lpcszXStatusNameDef[] = void CMraProto::SetExtraIcons(HANDLE hContact)
{
DWORD dwID, dwGroupID, dwContactSeverFlags;
- if ( GetContactBasicInfoW(hContact, &dwID, &dwGroupID, NULL, &dwContactSeverFlags, NULL, NULL, 0, NULL, NULL, 0, NULL, NULL, 0, NULL))
+ if ( GetContactBasicInfoW(hContact, &dwID, &dwGroupID, NULL, &dwContactSeverFlags, NULL, NULL, NULL, NULL))
return;
DWORD dwIconID = -1;
@@ -148,10 +148,10 @@ void CMraProto::SetExtraIcons(HANDLE hContact) }
if (dwIconID == -1) {
- size_t dwBlogStatusMsgSize = 0;
-
- mraGetStaticStringW(hContact, DBSETTING_BLOGSTATUS, NULL, 0, &dwBlogStatusMsgSize);
- if (dwBlogStatusMsgSize) dwIconID = ADV_ICON_BLOGSTATUS;
+ CMStringW statusMsg;
+ mraGetStringW(hContact, DBSETTING_BLOGSTATUS, statusMsg);
+ if (statusMsg.GetLength())
+ dwIconID = ADV_ICON_BLOGSTATUS;
}
ExtraIcon_SetIcon(hExtraXstatusIcon, hContact,
@@ -168,13 +168,13 @@ INT_PTR CMraProto::MraXStatusMenu(WPARAM wParam, LPARAM lParam, LPARAM param) INT_PTR CMraProto::MraGotoInbox(WPARAM wParam, LPARAM lParam)
{
- MraMPopSessionQueueAddUrl(hMPopSessionQueue, MRA_WIN_INBOX_URL, sizeof(MRA_WIN_INBOX_URL));
+ MraMPopSessionQueueAddUrl(hMPopSessionQueue, MRA_WIN_INBOX_URL);
return 0;
}
INT_PTR CMraProto::MraShowInboxStatus(WPARAM wParam, LPARAM lParam)
{
- MraUpdateEmailStatus(NULL, 0, NULL, 0, 0, 0);
+ MraUpdateEmailStatus("", "", 0, 0);
return 0;
}
@@ -184,27 +184,24 @@ INT_PTR CMraProto::MraSendSMS(WPARAM wParam, LPARAM lParam) return 0;
ptrW lpwszMessageXMLEncoded( mir_utf8decodeW((LPSTR)lParam));
- size_t dwBuffLen = lstrlenA((LPSTR)lParam) + MAX_PATH;
- LPWSTR lpwszMessageXMLDecoded = (LPWSTR)mir_calloc((dwBuffLen*sizeof(WCHAR)));
- if (lpwszMessageXMLEncoded && lpwszMessageXMLDecoded) {
- size_t dwMessageXMLDecodedSize;
- DecodeXML(lpwszMessageXMLEncoded, lstrlen(lpwszMessageXMLEncoded), lpwszMessageXMLDecoded, dwBuffLen, &dwMessageXMLDecodedSize);
- if (dwMessageXMLDecodedSize)
- MraSMSW(NULL, (LPSTR)wParam , lstrlenA((LPSTR)wParam), lpwszMessageXMLDecoded, dwMessageXMLDecodedSize);
+ if (lpwszMessageXMLEncoded) {
+ CMStringW decoded = DecodeXML( CMStringW(lpwszMessageXMLEncoded));
+ if (decoded.GetLength())
+ MraSMSW(NULL, CMStringA((LPSTR)wParam), decoded);
}
- mir_free(lpwszMessageXMLDecoded);
+
return 0;
}
INT_PTR CMraProto::MraEditProfile(WPARAM wParam, LPARAM lParam)
{
- MraMPopSessionQueueAddUrl(hMPopSessionQueue, MRA_EDIT_PROFILE_URL, sizeof(MRA_EDIT_PROFILE_URL));
+ MraMPopSessionQueueAddUrl(hMPopSessionQueue, MRA_EDIT_PROFILE_URL);
return 0;
}
INT_PTR CMraProto::MraZhuki(WPARAM wParam, LPARAM lParam)
{
- MraMPopSessionQueueAddUrl(hMPopSessionQueue, MRA_ZHUKI_URL, sizeof(MRA_ZHUKI_URL));
+ MraMPopSessionQueueAddUrl(hMPopSessionQueue, MRA_ZHUKI_URL);
return 0;
}
@@ -218,10 +215,9 @@ INT_PTR CMraProto::MraUpdateAllUsersInfo(WPARAM wParam, LPARAM lParam) {
if ( MessageBox(NULL, TranslateT("Are you sure?"), TranslateW(MRA_UPD_ALL_USERS_INFO_STR), MB_YESNO | MB_ICONQUESTION) == IDYES ) {
for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
- size_t dwEMailSize;
- CHAR szEMail[MAX_EMAIL_LEN];
- if ( mraGetStaticStringA(hContact, "e-mail", szEMail, SIZEOF(szEMail), &dwEMailSize))
- MraWPRequestByEMail(hContact, ACKTYPE_GETINFO, szEMail, dwEMailSize);
+ CMStringA szEmail;
+ if ( mraGetStringA(hContact, "e-mail", szEmail))
+ MraWPRequestByEMail(hContact, ACKTYPE_GETINFO, szEmail);
}
}
return 0;
@@ -231,12 +227,10 @@ INT_PTR CMraProto::MraCheckUpdatesUsersAvt(WPARAM wParam, LPARAM lParam) {
if ( MessageBox(NULL, TranslateT("Are you sure?"), TranslateW(MRA_CHK_USERS_AVATARS_STR), MB_YESNO | MB_ICONQUESTION) == IDYES) {
for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
- size_t dwEMailSize;
- CHAR szEMail[MAX_EMAIL_LEN];
-
- if (mraGetStaticStringA(hContact, "e-mail", szEMail, SIZEOF(szEMail), &dwEMailSize))
- if (IsEMailChatAgent(szEMail, dwEMailSize) == FALSE)// только для оптимизации, MraAvatarsQueueGetAvatarSimple сама умеет фильтровать чатконтакты
- MraAvatarsQueueGetAvatarSimple(hAvatarsQueueHandle, 0/*GAIF_FORCE*/, hContact, 0);
+ CMStringA szEmail;
+ if (mraGetStringA(hContact, "e-mail", szEmail))
+ if ( !IsEMailChatAgent(szEmail))
+ MraAvatarsQueueGetAvatarSimple(hAvatarsQueueHandle, 0, hContact, 0);
}
}
return 0;
@@ -247,7 +241,7 @@ INT_PTR CMraProto::MraRequestAuthForAll(WPARAM wParam, LPARAM lParam) if ( MessageBox(NULL, TranslateT("Are you sure?"), TranslateW(MRA_REQ_AUTH_FOR_ALL_STR), MB_YESNO | MB_ICONQUESTION) == IDYES) {
for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
DWORD dwContactSeverFlags;
- if (GetContactBasicInfoW(hContact, NULL, NULL, NULL, &dwContactSeverFlags, NULL, NULL, 0, NULL, NULL, 0, NULL, NULL, 0, NULL) == NO_ERROR)
+ if (GetContactBasicInfoW(hContact, NULL, NULL, NULL, &dwContactSeverFlags, NULL, NULL, NULL, NULL) == NO_ERROR)
if (dwContactSeverFlags & CONTACT_INTFLAG_NOT_AUTHORIZED && dwContactSeverFlags != -1)
MraRequestAuthorization((WPARAM)hContact, 0);
}
@@ -257,31 +251,27 @@ INT_PTR CMraProto::MraRequestAuthForAll(WPARAM wParam, LPARAM lParam) INT_PTR CMraProto::MraRequestAuthorization(WPARAM wParam, LPARAM lParam)
{
- if (wParam) {
- WCHAR wszAuthMessage[MAX_PATH];
-
- if (mraGetStaticStringW(NULL, "AuthMessage", wszAuthMessage, SIZEOF(wszAuthMessage), NULL) == FALSE)
- lstrcpynW(wszAuthMessage, TranslateW(MRA_DEFAULT_AUTH_MESSAGE), SIZEOF(wszAuthMessage));
+ HANDLE hContact = (HANDLE)wParam;
+ if (!hContact)
+ return 0;
- CHAR szEMail[MAX_EMAIL_LEN];
- size_t dwEMailSize, dwMessageSize;
+ CMStringW wszAuthMessage;
+ if ( !mraGetStringW(NULL, "AuthMessage", wszAuthMessage))
+ wszAuthMessage = TranslateW(MRA_DEFAULT_AUTH_MESSAGE);
- dwMessageSize = lstrlen(wszAuthMessage);
- if (dwMessageSize) {
- HANDLE hContact = (HANDLE)wParam;
- if ( mraGetStaticStringA(hContact, "e-mail", szEMail, SIZEOF(szEMail), &dwEMailSize)) {
- BOOL bSlowSend = getByte("SlowSend", MRA_DEFAULT_SLOW_SEND);
- int iRet = MraMessageW(bSlowSend, hContact, ACKTYPE_AUTHREQ, MESSAGE_FLAG_AUTHORIZE, szEMail, dwEMailSize, wszAuthMessage, dwMessageSize, NULL, 0);
- if (bSlowSend == FALSE)
- ProtoBroadcastAck(hContact, ACKTYPE_AUTHREQ, ACKRESULT_SUCCESS, (HANDLE)iRet, 0);
+ if ( !wszAuthMessage.IsEmpty()) {
+ CMStringA szEmail;
+ if ( mraGetStringA(hContact, "e-mail", szEmail)) {
+ BOOL bSlowSend = getByte("SlowSend", MRA_DEFAULT_SLOW_SEND);
+ int iRet = MraMessageW(bSlowSend, hContact, ACKTYPE_AUTHREQ, MESSAGE_FLAG_AUTHORIZE, szEmail, wszAuthMessage, NULL, 0);
+ if (bSlowSend == FALSE)
+ ProtoBroadcastAck(hContact, ACKTYPE_AUTHREQ, ACKRESULT_SUCCESS, (HANDLE)iRet, 0);
- return 0;
- }
+ return 0;
}
-
- return 1;
}
- return 0;
+
+ return 1;
}
INT_PTR CMraProto::MraGrantAuthorization(WPARAM wParam, LPARAM lParam)
@@ -289,12 +279,10 @@ INT_PTR CMraProto::MraGrantAuthorization(WPARAM wParam, LPARAM lParam) if (!m_bLoggedIn || !wParam)
return 0;
- CHAR szEMail[MAX_EMAIL_LEN];
- size_t dwEMailSize;
-
// send without reason, do we need any ?
- if (mraGetStaticStringA((HANDLE)wParam, "e-mail", szEMail, SIZEOF(szEMail), &dwEMailSize))
- MraAuthorize(szEMail, dwEMailSize);
+ CMStringA szEmail;
+ if (mraGetStringA((HANDLE)wParam, "e-mail", szEmail))
+ MraAuthorize(szEmail);
return 0;
}
@@ -307,13 +295,11 @@ INT_PTR CMraProto::MraSendPostcard(WPARAM wParam, LPARAM lParam) DWORD dwContactEMailCount = GetContactEMailCount((HANDLE)wParam, FALSE);
if (dwContactEMailCount) {
if (dwContactEMailCount == 1) {
- size_t dwUrlSize, dwEMailSize;
- CHAR szUrl[BUFF_SIZE_URL], szEMail[MAX_EMAIL_LEN];
-
- if ( GetContactFirstEMail((HANDLE)wParam, FALSE, szEMail, SIZEOF(szEMail), &dwEMailSize)) {
- BuffToLowerCase(szEMail, szEMail, dwEMailSize);
- dwUrlSize = mir_snprintf(szUrl, SIZEOF(szUrl), "http://cards.mail.ru/event.html?rcptname=%s&rcptemail=%s", GetContactNameA((HANDLE)wParam), szEMail);
- MraMPopSessionQueueAddUrl(hMPopSessionQueue, szUrl, dwUrlSize);
+ CMStringA szUrl, szEmail;
+ if ( GetContactFirstEMail((HANDLE)wParam, FALSE, szEmail)) {
+ szEmail.MakeLower();
+ szUrl.Format("http://cards.mail.ru/event.html?rcptname=%s&rcptemail=%s", GetContactNameA((HANDLE)wParam), szEmail);
+ MraMPopSessionQueueAddUrl(hMPopSessionQueue, szUrl);
}
}
else MraSelectEMailDlgShow((HANDLE)wParam, MRA_SELECT_EMAIL_TYPE_SEND_POSTCARD);
@@ -329,10 +315,9 @@ INT_PTR CMraProto::MraViewAlbum(WPARAM wParam, LPARAM lParam) DWORD dwContactEMailMRCount = GetContactEMailCount((HANDLE)wParam, TRUE);
if (dwContactEMailMRCount) {
if (dwContactEMailMRCount == 1) {
- size_t dwEMailSize;
- CHAR szEMail[MAX_EMAIL_LEN];
- if (GetContactFirstEMail((HANDLE)wParam, TRUE, szEMail, SIZEOF(szEMail), &dwEMailSize))
- MraMPopSessionQueueAddUrlAndEMail(hMPopSessionQueue, MRA_FOTO_URL, sizeof(MRA_FOTO_URL), szEMail, dwEMailSize);
+ CMStringA szEmail;
+ if ( GetContactFirstEMail((HANDLE)wParam, TRUE, szEmail))
+ MraMPopSessionQueueAddUrlAndEMail(hMPopSessionQueue, MRA_FOTO_URL, szEmail);
}
else MraSelectEMailDlgShow((HANDLE)wParam, MRA_SELECT_EMAIL_TYPE_VIEW_ALBUM);
}
@@ -347,10 +332,9 @@ INT_PTR CMraProto::MraReadBlog(WPARAM wParam, LPARAM lParam) DWORD dwContactEMailMRCount = GetContactEMailCount((HANDLE)wParam, TRUE);
if (dwContactEMailMRCount)
if (dwContactEMailMRCount == 1) {
- CHAR szEMail[MAX_EMAIL_LEN];
- size_t dwEMailSize;
- if (GetContactFirstEMail((HANDLE)wParam, TRUE, szEMail, SIZEOF(szEMail), &dwEMailSize))
- MraMPopSessionQueueAddUrlAndEMail(hMPopSessionQueue, MRA_BLOGS_URL, sizeof(MRA_BLOGS_URL), szEMail, dwEMailSize);
+ CMStringA szEmail;
+ if (GetContactFirstEMail((HANDLE)wParam, TRUE, szEmail))
+ MraMPopSessionQueueAddUrlAndEMail(hMPopSessionQueue, MRA_BLOGS_URL, szEmail);
}
else MraSelectEMailDlgShow((HANDLE)wParam, MRA_SELECT_EMAIL_TYPE_READ_BLOG);
@@ -362,9 +346,9 @@ INT_PTR CMraProto::MraReplyBlogStatus(WPARAM wParam, LPARAM lParam) if (!m_bLoggedIn)
return 0;
- size_t dwBlogStatusMsgSize = 0;
- mraGetStaticStringW((HANDLE)wParam, DBSETTING_BLOGSTATUS, NULL, 0, &dwBlogStatusMsgSize);
- if (dwBlogStatusMsgSize || wParam == 0)
+ CMStringW blogStatusMsg;
+ mraGetStringW((HANDLE)wParam, DBSETTING_BLOGSTATUS, blogStatusMsg);
+ if (!blogStatusMsg.IsEmpty()|| wParam == 0)
MraSendReplyBlogStatus((HANDLE)wParam);
return 0;
@@ -378,10 +362,9 @@ INT_PTR CMraProto::MraViewVideo(WPARAM wParam, LPARAM lParam) DWORD dwContactEMailMRCount = GetContactEMailCount((HANDLE)wParam, TRUE);
if (dwContactEMailMRCount) {
if (dwContactEMailMRCount == 1) {
- CHAR szEMail[MAX_EMAIL_LEN];
- size_t dwEMailSize;
- if (GetContactFirstEMail((HANDLE)wParam, TRUE, szEMail, SIZEOF(szEMail), &dwEMailSize))
- MraMPopSessionQueueAddUrlAndEMail(hMPopSessionQueue, MRA_VIDEO_URL, sizeof(MRA_VIDEO_URL), szEMail, dwEMailSize);
+ CMStringA szEmail;
+ if (GetContactFirstEMail((HANDLE)wParam, TRUE, szEmail))
+ MraMPopSessionQueueAddUrlAndEMail(hMPopSessionQueue, MRA_VIDEO_URL, szEmail);
}
else MraSelectEMailDlgShow((HANDLE)wParam, MRA_SELECT_EMAIL_TYPE_VIEW_VIDEO);
}
@@ -396,10 +379,9 @@ INT_PTR CMraProto::MraAnswers(WPARAM wParam, LPARAM lParam) DWORD dwContactEMailMRCount = GetContactEMailCount((HANDLE)wParam, TRUE);
if (dwContactEMailMRCount) {
if (dwContactEMailMRCount == 1) {
- CHAR szEMail[MAX_EMAIL_LEN];
- size_t dwEMailSize;
- if (GetContactFirstEMail((HANDLE)wParam, TRUE, szEMail, SIZEOF(szEMail), &dwEMailSize))
- MraMPopSessionQueueAddUrlAndEMail(hMPopSessionQueue, MRA_ANSWERS_URL, sizeof(MRA_ANSWERS_URL), szEMail, dwEMailSize);
+ CMStringA szEmail;
+ if (GetContactFirstEMail((HANDLE)wParam, TRUE, szEmail))
+ MraMPopSessionQueueAddUrlAndEMail(hMPopSessionQueue, MRA_ANSWERS_URL, szEmail);
}
else MraSelectEMailDlgShow((HANDLE)wParam, MRA_SELECT_EMAIL_TYPE_ANSWERS);
}
@@ -414,10 +396,9 @@ INT_PTR CMraProto::MraWorld(WPARAM wParam, LPARAM lParam) DWORD dwContactEMailMRCount = GetContactEMailCount((HANDLE)wParam, TRUE);
if (dwContactEMailMRCount) {
if (dwContactEMailMRCount == 1) {
- CHAR szEMail[MAX_EMAIL_LEN];
- size_t dwEMailSize;
- if (GetContactFirstEMail((HANDLE)wParam, TRUE, szEMail, SIZEOF(szEMail), &dwEMailSize))
- MraMPopSessionQueueAddUrlAndEMail(hMPopSessionQueue, MRA_WORLD_URL, sizeof(MRA_WORLD_URL), szEMail, dwEMailSize);
+ CMStringA szEmail;
+ if (GetContactFirstEMail((HANDLE)wParam, TRUE, szEmail))
+ MraMPopSessionQueueAddUrlAndEMail(hMPopSessionQueue, MRA_WORLD_URL, szEmail);
}
else MraSelectEMailDlgShow((HANDLE)wParam, MRA_SELECT_EMAIL_TYPE_WORLD);
}
@@ -433,14 +414,13 @@ int CMraProto::MraContactDeleted(WPARAM wParam, LPARAM lParam) return 0;
if ( IsContactMra(hContact)) {
- CHAR szEMail[MAX_EMAIL_LEN];
+ CMStringA szEmail;
DWORD dwID, dwGroupID;
- size_t dwEMailSize;
- GetContactBasicInfoW(hContact, &dwID, &dwGroupID, NULL, NULL, NULL, szEMail, SIZEOF(szEMail), &dwEMailSize, NULL, 0, NULL, NULL, 0, NULL);
+ GetContactBasicInfoW(hContact, &dwID, &dwGroupID, NULL, NULL, NULL, &szEmail, NULL, NULL);
MraSetContactStatus(hContact, ID_STATUS_OFFLINE);
if ( !db_get_b(hContact, "CList", "NotOnList", 0) || dwID != -1)
- MraModifyContactW(hContact, dwID, CONTACT_FLAG_REMOVED, dwGroupID, szEMail, dwEMailSize, NULL, 0, NULL, 0);
+ MraModifyContactW(hContact, dwID, CONTACT_FLAG_REMOVED, dwGroupID, szEmail, L"", "");
MraAvatarsDeleteContactAvatarFile(hAvatarsQueueHandle, hContact);
}
return 0;
@@ -452,124 +432,99 @@ int CMraProto::MraDbSettingChanged(WPARAM wParam, LPARAM lParam) return 0;
HANDLE hContact = (HANDLE)wParam;
+ if (hContact == NULL)
+ return 0;
+
DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam;
- if (hContact) {
- // это наш контакт, он не временный (есть в списке на сервере) и его обновление разрешено
- if ( IsContactMra(hContact) && !db_get_b(hContact, "CList", "NotOnList", 0) && getDword(hContact, "HooksLocked", FALSE) == FALSE) {
- CHAR szEMail[MAX_EMAIL_LEN], szPhones[MAX_EMAIL_LEN];
- WCHAR wszNick[MAX_EMAIL_LEN];
- DWORD dwID, dwGroupID, dwContactFlag;
- size_t dwEMailSize, dwNickSize, dwPhonesSize;
-
- if ( CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, cws->szModule, -1, "CList", 5) == CSTR_EQUAL) {
- // MyHandle setting
- if (CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, cws->szSetting, -1, "MyHandle", 8) == CSTR_EQUAL) {
- LPWSTR lpwszNewNick;
-
- // allways store custom nick
- if (cws->value.type == DBVT_DELETED) {
- lstrcpynW(wszNick, GetContactNameW(hContact), SIZEOF(wszNick));
- lpwszNewNick = wszNick;
- dwNickSize = lstrlenW(lpwszNewNick);
- DB_SetStringExW(hContact, "CList", "MyHandle", lpwszNewNick, dwNickSize);
- }
- else if (cws->value.pszVal) {
- switch (cws->value.type) {
- case DBVT_WCHAR:
- lpwszNewNick = cws->value.pwszVal;
- dwNickSize = lstrlenW(lpwszNewNick);
- break;
- case DBVT_UTF8:
- lpwszNewNick = wszNick;
- dwNickSize = MultiByteToWideChar(CP_UTF8, 0, cws->value.pszVal, -1, wszNick, SIZEOF(wszNick));
- break;
- case DBVT_ASCIIZ:
- lpwszNewNick = wszNick;
- dwNickSize = MultiByteToWideChar(MRA_CODE_PAGE, 0, cws->value.pszVal, -1, wszNick, SIZEOF(wszNick));
- break;
- default:
- lpwszNewNick = NULL;
- dwNickSize = 0;
- break;
- }
- if (lpwszNewNick)
- if (GetContactBasicInfoW(hContact, &dwID, &dwGroupID, &dwContactFlag, NULL, NULL, szEMail, SIZEOF(szEMail), &dwEMailSize, NULL, 0, NULL, szPhones, SIZEOF(szPhones), &dwPhonesSize) == NO_ERROR)
- MraModifyContactW(hContact, dwID, dwContactFlag, dwGroupID, szEMail, dwEMailSize, lpwszNewNick, dwNickSize, szPhones, dwPhonesSize);
- }
+ // это наш контакт, он не временный (есть в списке на сервере) и его обновление разрешено
+ if ( IsContactMra(hContact) && !db_get_b(hContact, "CList", "NotOnList", 0) && getDword(hContact, "HooksLocked", FALSE) == FALSE) {
+ CMStringA szEmail, szPhones;
+ CMStringW wszNick;
+ DWORD dwID, dwGroupID, dwContactFlag;
+
+ if ( CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, cws->szModule, -1, "CList", 5) == CSTR_EQUAL) {
+ // MyHandle setting
+ if (CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, cws->szSetting, -1, "MyHandle", 8) == CSTR_EQUAL) {
+ // always store custom nick
+ if (cws->value.type == DBVT_DELETED) {
+ wszNick = GetContactNameW(hContact);
+ db_set_ws(hContact, "CList", "MyHandle", wszNick);
}
- // Group setting
- else if ( CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, cws->szSetting, -1, "Group", 5) == CSTR_EQUAL ) {
- // manage group on server
+ else if (cws->value.pszVal) {
switch (cws->value.type) {
+ case DBVT_WCHAR:
+ wszNick = cws->value.pwszVal;
+ break;
+ case DBVT_UTF8:
+ wszNick = ptrW( mir_utf8decodeW(cws->value.pszVal));
+ break;
case DBVT_ASCIIZ:
+ wszNick = ptrW( mir_a2u_cp(cws->value.pszVal, MRA_CODE_PAGE));
break;
- case DBVT_DELETED:
+ default:
break;
}
- }
- // NotOnList setting. Has a temporary contact just been added permanently?
- else if ( CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, cws->szSetting, -1, "NotOnList", 9) == CSTR_EQUAL) {
- if (cws->value.type == DBVT_DELETED || (cws->value.type == DBVT_BYTE && cws->value.bVal == 0)) {
- WCHAR wszAuthMessage[MAX_PATH];
- size_t dwAuthMessageSize;
- if ( mraGetStaticStringW(NULL, "AuthMessage", wszAuthMessage, SIZEOF(wszAuthMessage), &dwAuthMessageSize) == FALSE) {
- lstrcpynW(wszAuthMessage, TranslateW(MRA_DEFAULT_AUTH_MESSAGE), SIZEOF(wszAuthMessage));
- dwAuthMessageSize = lstrlenW(wszAuthMessage);
- }
-
- db_unset(hContact, "CList", "Hidden");
- GetContactBasicInfoW(hContact, NULL, &dwGroupID, &dwContactFlag, NULL, NULL, szEMail, SIZEOF(szEMail), &dwEMailSize, wszNick, SIZEOF(wszNick), &dwNickSize, szPhones, SIZEOF(szPhones), &dwPhonesSize);
- MraAddContactW(hContact, dwContactFlag, dwGroupID, szEMail, dwEMailSize, wszNick, dwNickSize, szPhones, dwPhonesSize, wszAuthMessage, dwAuthMessageSize, 0);
- }
- }
- // Hidden setting
- else if ( CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, cws->szSetting, -1, "Hidden" , 6) == CSTR_EQUAL) {
- GetContactBasicInfoW(hContact, &dwID, &dwGroupID, &dwContactFlag, NULL, NULL, szEMail, SIZEOF(szEMail), &dwEMailSize, wszNick, SIZEOF(wszNick), &dwNickSize, szPhones, SIZEOF(szPhones), &dwPhonesSize);
- if (cws->value.type == DBVT_DELETED || (cws->value.type == DBVT_BYTE && cws->value.bVal == 0))
- dwContactFlag &= ~CONTACT_FLAG_SHADOW;
- else
- dwContactFlag |= CONTACT_FLAG_SHADOW;
-
- MraModifyContactW(hContact, dwID, dwContactFlag, dwGroupID, szEMail, dwEMailSize, wszNick, dwNickSize, szPhones, dwPhonesSize);
+ if (wszNick.GetLength())
+ if (GetContactBasicInfoW(hContact, &dwID, &dwGroupID, &dwContactFlag, NULL, NULL, &szEmail, NULL, &szPhones) == NO_ERROR)
+ MraModifyContactW(hContact, dwID, dwContactFlag, dwGroupID, szEmail, wszNick, szPhones);
}
}
- // Ignore section
- else if ( CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, cws->szModule, -1, "Ignore", 6) == CSTR_EQUAL) {
- if ( CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, cws->szSetting, -1, "Mask1", 5) == CSTR_EQUAL) {
- GetContactBasicInfoW(hContact, &dwID, &dwGroupID, &dwContactFlag, NULL, NULL, szEMail, SIZEOF(szEMail), &dwEMailSize, wszNick, SIZEOF(wszNick), &dwNickSize, szPhones, SIZEOF(szPhones), &dwPhonesSize);
- if (cws->value.type == DBVT_DELETED || (cws->value.type == DBVT_DWORD && cws->value.dVal&IGNOREEVENT_MESSAGE) == 0)
- dwContactFlag &= ~CONTACT_FLAG_IGNORE;
- else
- dwContactFlag |= CONTACT_FLAG_IGNORE;
-
- MraModifyContactW(hContact, dwID, dwContactFlag, dwGroupID, szEMail, dwEMailSize, wszNick, dwNickSize, szPhones, dwPhonesSize);
+ // Group setting
+ else if ( CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, cws->szSetting, -1, "Group", 5) == CSTR_EQUAL ) {
+ // manage group on server
+ switch (cws->value.type) {
+ case DBVT_ASCIIZ:
+ break;
+ case DBVT_DELETED:
+ break;
}
}
- // User info section
- else if (CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, cws->szModule, -1, "UserInfo", 8) == CSTR_EQUAL) {
- if ( CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, cws->szSetting, -1, "MyPhone0", 8) == CSTR_EQUAL ||
- CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, cws->szSetting, -1, "MyPhone1", 8) == CSTR_EQUAL ||
- CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, cws->szSetting, -1, "MyPhone2", 8) == CSTR_EQUAL) {
- GetContactBasicInfoW(hContact, &dwID, &dwGroupID, &dwContactFlag, NULL, NULL, szEMail, SIZEOF(szEMail), &dwEMailSize, wszNick, SIZEOF(wszNick), &dwNickSize, szPhones, SIZEOF(szPhones), &dwPhonesSize);
- MraModifyContactW(hContact, dwID, dwContactFlag, dwGroupID, szEMail, dwEMailSize, wszNick, dwNickSize, szPhones, dwPhonesSize);
+ // NotOnList setting. Has a temporary contact just been added permanently?
+ else if ( CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, cws->szSetting, -1, "NotOnList", 9) == CSTR_EQUAL) {
+ if (cws->value.type == DBVT_DELETED || (cws->value.type == DBVT_BYTE && cws->value.bVal == 0)) {
+ CMStringW wszAuthMessage;
+ if ( !mraGetStringW(NULL, "AuthMessage", wszAuthMessage))
+ wszAuthMessage = TranslateW(MRA_DEFAULT_AUTH_MESSAGE);
+
+ db_unset(hContact, "CList", "Hidden");
+ GetContactBasicInfoW(hContact, NULL, &dwGroupID, &dwContactFlag, NULL, NULL, &szEmail, &wszNick, &szPhones);
+ MraAddContactW(hContact, dwContactFlag, dwGroupID, szEmail, wszNick, szPhones, wszAuthMessage, 0);
}
}
+ // Hidden setting
+ else if ( CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, cws->szSetting, -1, "Hidden" , 6) == CSTR_EQUAL) {
+ GetContactBasicInfoW(hContact, &dwID, &dwGroupID, &dwContactFlag, NULL, NULL, &szEmail, &wszNick, &szPhones);
+ if (cws->value.type == DBVT_DELETED || (cws->value.type == DBVT_BYTE && cws->value.bVal == 0))
+ dwContactFlag &= ~CONTACT_FLAG_SHADOW;
+ else
+ dwContactFlag |= CONTACT_FLAG_SHADOW;
+
+ MraModifyContactW(hContact, dwID, dwContactFlag, dwGroupID, szEmail, wszNick, szPhones);
+ }
}
- }
- // not contact
- else {
- if ( CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, cws->szModule, -1, "CListGroups", 11) == CSTR_EQUAL) {
- // manage group on server
- switch (cws->value.type) {
- case DBVT_ASCIIZ:
- break;
- case DBVT_DELETED:
- break;
+ // Ignore section
+ else if ( CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, cws->szModule, -1, "Ignore", 6) == CSTR_EQUAL) {
+ if ( CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, cws->szSetting, -1, "Mask1", 5) == CSTR_EQUAL) {
+ GetContactBasicInfoW(hContact, &dwID, &dwGroupID, &dwContactFlag, NULL, NULL, &szEmail, &wszNick, &szPhones);
+ if (cws->value.type == DBVT_DELETED || (cws->value.type == DBVT_DWORD && cws->value.dVal&IGNOREEVENT_MESSAGE) == 0)
+ dwContactFlag &= ~CONTACT_FLAG_IGNORE;
+ else
+ dwContactFlag |= CONTACT_FLAG_IGNORE;
+
+ MraModifyContactW(hContact, dwID, dwContactFlag, dwGroupID, szEmail, wszNick, szPhones);
+ }
+ }
+ // User info section
+ else if (CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, cws->szModule, -1, "UserInfo", 8) == CSTR_EQUAL) {
+ if ( CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, cws->szSetting, -1, "MyPhone0", 8) == CSTR_EQUAL ||
+ CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, cws->szSetting, -1, "MyPhone1", 8) == CSTR_EQUAL ||
+ CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, cws->szSetting, -1, "MyPhone2", 8) == CSTR_EQUAL) {
+ GetContactBasicInfoW(hContact, &dwID, &dwGroupID, &dwContactFlag, NULL, NULL, &szEmail, &wszNick, &szPhones);
+ MraModifyContactW(hContact, dwID, dwContactFlag, dwGroupID, szEmail, wszNick, szPhones);
}
}
}
-
return 0;
}
@@ -577,7 +532,7 @@ int CMraProto::MraRebuildContactMenu(WPARAM wParam, LPARAM lParam) {
BOOL bIsContactMRA, bHasEMail, bHasEMailMR, bChatAgent;
DWORD dwContactSeverFlags = 0;
- size_t dwBlogStatusMsgSize = 0;
+ CMStringW blogStatusMsgSize;
HANDLE hContact = (HANDLE)wParam;
// proto own contact
@@ -586,8 +541,8 @@ int CMraProto::MraRebuildContactMenu(WPARAM wParam, LPARAM lParam) bHasEMail = TRUE;
bHasEMailMR = TRUE;
bChatAgent = IsContactChatAgent(hContact);
- GetContactBasicInfoW(hContact, NULL, NULL, NULL, &dwContactSeverFlags, NULL, NULL, 0, NULL, NULL, 0, NULL, NULL, 0, NULL);
- mraGetStaticStringW(hContact, DBSETTING_BLOGSTATUS, NULL, 0, &dwBlogStatusMsgSize);
+ GetContactBasicInfoW(hContact, NULL, NULL, NULL, &dwContactSeverFlags, NULL, NULL, NULL, NULL);
+ mraGetStringW(hContact, DBSETTING_BLOGSTATUS, blogStatusMsgSize);
}
// non proto contact
else bHasEMail = bHasEMailMR = bChatAgent = FALSE;
@@ -608,7 +563,7 @@ int CMraProto::MraRebuildContactMenu(WPARAM wParam, LPARAM lParam) Menu_ShowItem(hContactMenuItems[4], (m_bLoggedIn && bHasEMailMR && bChatAgent == FALSE));
//"Reply Blog Status"
- Menu_ShowItem(hContactMenuItems[5], (m_bLoggedIn && dwBlogStatusMsgSize && bChatAgent == FALSE));
+ Menu_ShowItem(hContactMenuItems[5], (m_bLoggedIn && blogStatusMsgSize.GetLength() && bChatAgent == FALSE));
//"View Video"
Menu_ShowItem(hContactMenuItems[6], (m_bLoggedIn && bHasEMailMR && bChatAgent == FALSE));
@@ -620,7 +575,7 @@ int CMraProto::MraRebuildContactMenu(WPARAM wParam, LPARAM lParam) Menu_ShowItem(hContactMenuItems[8], (m_bLoggedIn && bHasEMailMR && bChatAgent == FALSE));
//"Send &Nudge"
- Menu_ShowItem(hContactMenuItems[9], (!heNudgeReceived) ? (m_bLoggedIn && bIsContactMRA) : 0);
+ Menu_ShowItem(hContactMenuItems[9], (!m_heNudgeReceived) ? (m_bLoggedIn && bIsContactMRA) : 0);
return 0;
}
@@ -641,7 +596,7 @@ int CMraProto::MraRebuildStatusMenu(WPARAM wParam, LPARAM lParam) strncpy(szServiceFunction, m_szModuleName, sizeof(szServiceFunction));
pszServiceFunctionName = szServiceFunction + strlen(m_szModuleName);
- WCHAR szItem[MAX_PATH+64], szStatusTitle[STATUS_TITLE_MAX+4];
+ WCHAR szItem[MAX_PATH+64];
mir_sntprintf(szItem, SIZEOF(szItem), L"%s Custom Status", m_tszUserName);
CLISTMENUITEM mi = { sizeof(mi) };
@@ -652,16 +607,16 @@ int CMraProto::MraRebuildStatusMenu(WPARAM wParam, LPARAM lParam) mi.pszService = szServiceFunction;
mi.pszContactOwner = m_szModuleName;
+ CMStringW szStatusTitle;
for (size_t i = 0; i < MRA_XSTATUS_COUNT; i++) {
mir_snprintf(pszServiceFunctionName, 100, "/menuXStatus%ld", i);
mi.position++;
if (i) {
mir_snprintf(szValueName, SIZEOF(szValueName), "XStatus%ldName", i);
- if (mraGetStaticStringW(NULL, szValueName, szStatusTitle, (STATUS_TITLE_MAX+1), NULL)) {
- szStatusTitle[STATUS_TITLE_MAX] = 0;
- mi.ptszName = szStatusTitle;
- }
- else mi.ptszName = lpcszXStatusNameDef[i];
+ if ( mraGetStringW(NULL, szValueName, szStatusTitle))
+ mi.ptszName = (TCHAR*)szStatusTitle.c_str();
+ else
+ mi.ptszName = lpcszXStatusNameDef[i];
mi.icolibItem = hXStatusAdvancedStatusIcons[i];
}
@@ -680,28 +635,19 @@ INT_PTR CMraProto::MraSetListeningTo(WPARAM wParam, LPARAM lParam) if (pliInfo == NULL || pliInfo->cbSize != sizeof(LISTENINGTOINFO))
{
- MraChangeUserBlogStatus(MRIM_BLOG_STATUS_MUSIC, NULL, 0, 0);
+ MraChangeUserBlogStatus(MRIM_BLOG_STATUS_MUSIC, L"", 0);
delSetting(DBSETTING_BLOGSTATUSMUSIC);
}
else if (pliInfo->dwFlags & LTI_UNICODE) {
- LPWSTR pwszListeningTo;
- WCHAR wszListeningTo[MICBLOG_STATUS_MAX+4];
- size_t dwListeningToSize;
-
- if ( ServiceExists(MS_LISTENINGTO_GETPARSEDTEXT)) {
- pwszListeningTo = (LPWSTR)CallService(MS_LISTENINGTO_GETPARSEDTEXT, (WPARAM)L"%track%. %title% - %artist% - %player%", (LPARAM)pliInfo);
- dwListeningToSize = lstrlenW(pwszListeningTo);
- }
- else {
- pwszListeningTo = wszListeningTo;
- dwListeningToSize = mir_sntprintf(pwszListeningTo, SIZEOF(wszListeningTo), L"%s. %s - %s - %s", pliInfo->ptszTrack?pliInfo->ptszTrack:L"", pliInfo->ptszTitle?pliInfo->ptszTitle:L"", pliInfo->ptszArtist?pliInfo->ptszArtist:L"", pliInfo->ptszPlayer?pliInfo->ptszPlayer:L"");
- }
+ CMStringW wszListeningTo;
- mraSetStringExW(NULL, DBSETTING_BLOGSTATUSMUSIC, pwszListeningTo, dwListeningToSize);
- MraChangeUserBlogStatus(MRIM_BLOG_STATUS_MUSIC, pwszListeningTo, dwListeningToSize, 0);
+ if ( ServiceExists(MS_LISTENINGTO_GETPARSEDTEXT))
+ wszListeningTo = ptrT((LPWSTR)CallService(MS_LISTENINGTO_GETPARSEDTEXT, (WPARAM)L"%track%. %title% - %artist% - %player%", (LPARAM)pliInfo));
+ else
+ wszListeningTo.Format(L"%s. %s - %s - %s", pliInfo->ptszTrack?pliInfo->ptszTrack:L"", pliInfo->ptszTitle?pliInfo->ptszTitle:L"", pliInfo->ptszArtist?pliInfo->ptszArtist:L"", pliInfo->ptszPlayer?pliInfo->ptszPlayer:L"");
- if (pwszListeningTo != wszListeningTo)
- mir_free(pwszListeningTo);
+ mraSetStringExW(NULL, DBSETTING_BLOGSTATUSMUSIC, wszListeningTo);
+ MraChangeUserBlogStatus(MRIM_BLOG_STATUS_MUSIC, wszListeningTo, 0);
}
return 0;
@@ -714,7 +660,7 @@ int CMraProto::MraMusicChanged(WPARAM wParam, LPARAM lParam) // stopped
if (1 == lParam) {
delSetting(DBSETTING_BLOGSTATUSMUSIC);
- MraChangeUserBlogStatus(MRIM_BLOG_STATUS_MUSIC, NULL, 0, 0);
+ MraChangeUserBlogStatus(MRIM_BLOG_STATUS_MUSIC, L"", 0);
}
break;
@@ -722,12 +668,10 @@ int CMraProto::MraMusicChanged(WPARAM wParam, LPARAM lParam) {
SONGINFO *psiSongInfo;
if (WAT_RES_OK == CallService(MS_WAT_GETMUSICINFO, WAT_INF_UNICODE, (LPARAM)&psiSongInfo)) {
- WCHAR wszMusic[MICBLOG_STATUS_MAX+4];
- size_t dwMusicSize;
-
- dwMusicSize = mir_sntprintf(wszMusic, SIZEOF(wszMusic), L"%ld. %s - %s - %s", psiSongInfo->track, psiSongInfo->artist, psiSongInfo->title, psiSongInfo->player);
- mraSetStringExW(NULL, DBSETTING_BLOGSTATUSMUSIC, wszMusic, dwMusicSize);
- MraChangeUserBlogStatus(MRIM_BLOG_STATUS_MUSIC, wszMusic, dwMusicSize, 0);
+ CMStringW wszMusic;
+ wszMusic.Format(L"%ld. %s - %s - %s", psiSongInfo->track, psiSongInfo->artist, psiSongInfo->title, psiSongInfo->player);
+ mraSetStringExW(NULL, DBSETTING_BLOGSTATUSMUSIC, wszMusic);
+ MraChangeUserBlogStatus(MRIM_BLOG_STATUS_MUSIC, wszMusic, 0);
}
}
break;
@@ -738,29 +682,22 @@ int CMraProto::MraMusicChanged(WPARAM wParam, LPARAM lParam) DWORD CMraProto::MraSetXStatusInternal(DWORD dwXStatus)
{
- DWORD dwOldStatusMode;
-
if ( IsXStatusValid(dwXStatus)) {
- CHAR szValueName[MAX_PATH];
- WCHAR szBuff[4096];
- size_t dwBuffSize;
+ CMStringW szBuff;
// obsolete (TODO: remove in next version)
+ char szValueName[MAX_PATH];
mir_snprintf(szValueName, SIZEOF(szValueName), "XStatus%ldName", dwXStatus);
- if (mraGetStaticStringW(NULL, szValueName, szBuff, SIZEOF(szBuff), &dwBuffSize) == FALSE) {
- lstrcpynW(szBuff, lpcszXStatusNameDef[dwXStatus], SIZEOF(szBuff));
- dwBuffSize = lstrlenW(szBuff);
- }
- if (dwBuffSize>STATUS_TITLE_MAX) dwBuffSize = STATUS_TITLE_MAX;
- mraSetStringExW(NULL, DBSETTING_XSTATUSNAME, szBuff, dwBuffSize);
+ if ( !mraGetStringW(NULL, szValueName, szBuff))
+ szBuff = lpcszXStatusNameDef[dwXStatus];
+ mraSetStringExW(NULL, DBSETTING_XSTATUSNAME, szBuff);
// obsolete (TODO: remove in next version)
mir_snprintf(szValueName, SIZEOF(szValueName), "XStatus%ldMsg", dwXStatus);
- if (mraGetStaticStringW(NULL, szValueName, szBuff, SIZEOF(szBuff), &dwBuffSize)) {
- if (dwBuffSize>STATUS_DESC_MAX) dwBuffSize = STATUS_DESC_MAX;
- mraSetStringExW(NULL, DBSETTING_XSTATUSMSG, szBuff, dwBuffSize);
- }
- else delSetting(DBSETTING_XSTATUSMSG);
+ if (mraGetStringW(NULL, szValueName, szBuff))
+ mraSetStringExW(NULL, DBSETTING_XSTATUSMSG, szBuff);
+ else
+ delSetting(DBSETTING_XSTATUSMSG);
}
else {
delSetting(DBSETTING_XSTATUSNAME);
@@ -768,10 +705,10 @@ DWORD CMraProto::MraSetXStatusInternal(DWORD dwXStatus) dwXStatus = MRA_MIR_XSTATUS_NONE;
}
- dwOldStatusMode = InterlockedExchange((volatile LONG*)&m_iXStatus, dwXStatus);
+ DWORD dwOldStatusMode = InterlockedExchange((volatile LONG*)&m_iXStatus, dwXStatus);
setByte(DBSETTING_XSTATUSID, (BYTE)dwXStatus);
- MraSendNewStatus(m_iStatus, dwXStatus, NULL, 0, NULL, 0);
+ MraSendNewStatus(m_iStatus, dwXStatus, L"", L"");
return dwOldStatusMode;
}
@@ -795,25 +732,17 @@ INT_PTR CMraProto::MraSetXStatusEx(WPARAM wParam, LPARAM lParam) if (pData->flags & (CSSF_MASK_NAME|CSSF_MASK_MESSAGE) && iRet == 0) {
if ( IsXStatusValid(dwXStatus) || dwXStatus == MRA_MIR_XSTATUS_NONE) {
CHAR szValueName[MAX_PATH];
- size_t dwBuffSize;
// set custom status name
if (pData->flags & CSSF_MASK_NAME) {
mir_snprintf(szValueName, SIZEOF(szValueName), "XStatus%ldName", dwXStatus);
if (pData->flags & CSSF_UNICODE) {
- dwBuffSize = lstrlenW(pData->pwszName);
- if (dwBuffSize>STATUS_TITLE_MAX) dwBuffSize = STATUS_TITLE_MAX;
-
- mraSetStringExW(NULL, szValueName, pData->pwszName, dwBuffSize);
- mraSetStringExW(NULL, DBSETTING_XSTATUSNAME, pData->pwszName, dwBuffSize);
+ mraSetStringExW(NULL, szValueName, pData->pwszName);
+ mraSetStringExW(NULL, DBSETTING_XSTATUSNAME, pData->pwszName);
}
else {
- dwBuffSize = lstrlenA(pData->pszName);
- if (dwBuffSize > STATUS_TITLE_MAX)
- dwBuffSize = STATUS_TITLE_MAX;
-
- mraSetStringExA(NULL, szValueName, pData->pszName, dwBuffSize);
- mraSetStringExA(NULL, DBSETTING_XSTATUSNAME, pData->pszName, dwBuffSize);
+ mraSetStringExA(NULL, szValueName, pData->pszName);
+ mraSetStringExA(NULL, DBSETTING_XSTATUSNAME, pData->pszName);
}
}
@@ -821,18 +750,12 @@ INT_PTR CMraProto::MraSetXStatusEx(WPARAM wParam, LPARAM lParam) if (pData->flags & CSSF_MASK_MESSAGE) {
mir_snprintf(szValueName, SIZEOF(szValueName), "XStatus%ldMsg", dwXStatus);
if (pData->flags & CSSF_UNICODE) {
- dwBuffSize = lstrlenW(pData->pwszMessage);
- if (dwBuffSize>STATUS_TITLE_MAX) dwBuffSize = STATUS_DESC_MAX;
-
- mraSetStringExW(NULL, szValueName, pData->pwszMessage, dwBuffSize);
- mraSetStringExW(NULL, DBSETTING_XSTATUSMSG, pData->pwszMessage, dwBuffSize);
+ mraSetStringExW(NULL, szValueName, pData->pwszMessage);
+ mraSetStringExW(NULL, DBSETTING_XSTATUSMSG, pData->pwszMessage);
}
else {
- dwBuffSize = lstrlenA(pData->pszMessage);
- if (dwBuffSize>STATUS_TITLE_MAX) dwBuffSize = STATUS_DESC_MAX;
-
- mraSetStringExA(NULL, szValueName, pData->pszMessage, dwBuffSize);
- mraSetStringExA(NULL, DBSETTING_XSTATUSMSG, pData->pszMessage, dwBuffSize);
+ mraSetStringExA(NULL, szValueName, pData->pszMessage);
+ mraSetStringExA(NULL, DBSETTING_XSTATUSMSG, pData->pszMessage);
}
}
}
@@ -926,62 +849,46 @@ INT_PTR CMraProto::MraGetXStatusIcon(WPARAM wParam, LPARAM lParam) return (INT_PTR)IconLibGetIconEx(hXStatusAdvancedStatusIcons[wParam], lParam);
}
-DWORD CMraProto::MraSendNewStatus(DWORD dwStatusMir, DWORD dwXStatusMir, LPCWSTR lpwszStatusTitle, size_t dwStatusTitleSize, LPCWSTR lpwszStatusDesc, size_t dwStatusDescSize)
+DWORD CMraProto::MraSendNewStatus(DWORD dwStatusMir, DWORD dwXStatusMir, const CMStringW &pwszStatusTitle, const CMStringW &pwszStatusDesc)
{
if (!m_bLoggedIn)
return 0;
- CHAR szValueName[MAX_PATH];
- WCHAR wszStatusTitle[STATUS_TITLE_MAX+4], wszStatusDesc[STATUS_DESC_MAX+4];
- DWORD dwStatus, dwXStatus;
-
- dwStatus = GetMraStatusFromMiradaStatus(dwStatusMir, dwXStatusMir, &dwXStatus);
+ CMStringW wszStatusTitle, wszStatusDesc;
+ DWORD dwXStatus, dwStatus = GetMraStatusFromMiradaStatus(dwStatusMir, dwXStatusMir, &dwXStatus);
if ( IsXStatusValid(dwXStatusMir)) {
- if (lpwszStatusTitle == NULL || dwStatusTitleSize == 0) {
+ char szValueName[MAX_PATH];
+ if (pwszStatusTitle.IsEmpty()) {
mir_snprintf(szValueName, SIZEOF(szValueName), "XStatus%ldName", dwXStatusMir);
// custom xstatus name
- if (mraGetStaticStringW(NULL, szValueName, wszStatusTitle, (STATUS_TITLE_MAX+1), &dwStatusTitleSize))
- lpwszStatusTitle = wszStatusTitle;
- // default xstatus name
- else {
- lpwszStatusTitle = TranslateW(lpcszXStatusNameDef[dwXStatusMir]);
- dwStatusTitleSize = lstrlenW(lpwszStatusTitle);
- }
+ if ( !mraGetStringW(NULL, szValueName, wszStatusTitle))
+ wszStatusTitle = TranslateW(lpcszXStatusNameDef[dwXStatusMir]);
}
+ else wszStatusTitle = pwszStatusTitle;
- if (lpwszStatusDesc == NULL || dwStatusDescSize == 0) {
+ if (pwszStatusDesc.IsEmpty()) {
mir_snprintf(szValueName, SIZEOF(szValueName), "XStatus%ldMsg", dwXStatusMir);
// custom xstatus description
- if (mraGetStaticStringW(NULL, szValueName, wszStatusDesc, (STATUS_DESC_MAX+1), &dwStatusDescSize))
- lpwszStatusDesc = wszStatusDesc;
- // default xstatus description
- else {
- lpwszStatusDesc = NULL;
- dwStatusDescSize = 0;
- }
- }
- }
- else {
- if (lpwszStatusTitle == NULL || dwStatusTitleSize == 0) {
- lpwszStatusTitle = GetStatusModeDescriptionW(dwStatusMir);
- dwStatusTitleSize = lstrlenW(lpwszStatusTitle);
+ mraGetStringW(NULL, szValueName, wszStatusDesc);
}
+ else wszStatusDesc = pwszStatusDesc;
}
+ else if (pwszStatusTitle.IsEmpty())
+ wszStatusTitle = GetStatusModeDescriptionW(dwStatusMir);
- MraChangeStatusW(dwStatus, lpcszStatusUri[dwXStatus], lstrlenA(lpcszStatusUri[dwXStatus]), lpwszStatusTitle, dwStatusTitleSize, lpwszStatusDesc, dwStatusDescSize, ((getByte("RTFReceiveEnable", MRA_DEFAULT_RTF_RECEIVE_ENABLE)? FEATURE_FLAG_RTF_MESSAGE:0)|MRA_FEATURE_FLAGS));
+ MraChangeStatusW(dwStatus, lpcszStatusUri[dwXStatus], wszStatusTitle, wszStatusDesc, ((getByte("RTFReceiveEnable", MRA_DEFAULT_RTF_RECEIVE_ENABLE)? FEATURE_FLAG_RTF_MESSAGE:0)|MRA_FEATURE_FLAGS));
return 0;
}
INT_PTR CMraProto::MraSendNudge(WPARAM wParam, LPARAM lParam)
{
if (m_bLoggedIn && wParam) {
- CHAR szEMail[MAX_EMAIL_LEN];
LPWSTR lpwszAlarmMessage = TranslateW(MRA_ALARM_MESSAGE);
- size_t dwEMailSize;
HANDLE hContact = (HANDLE)wParam;
- if (mraGetStaticStringA(hContact, "e-mail", szEMail, SIZEOF(szEMail), &dwEMailSize))
- if (MraMessageW(FALSE, hContact, 0, (MESSAGE_FLAG_RTF|MESSAGE_FLAG_ALARM), szEMail, dwEMailSize, lpwszAlarmMessage, lstrlenW(lpwszAlarmMessage), NULL, 0))
+ CMStringA szEmail;
+ if (mraGetStringA(hContact, "e-mail", szEmail))
+ if (MraMessageW(FALSE, hContact, 0, (MESSAGE_FLAG_RTF|MESSAGE_FLAG_ALARM), szEmail, lpwszAlarmMessage, NULL, 0))
return 0;
}
return 1;
@@ -1003,7 +910,7 @@ INT_PTR CMraProto::MraGetAvatarCaps(WPARAM wParam, LPARAM lParam) return 0; // no formats to set
case AF_ENABLED:
- return 1; // allways on
+ return 1; // always on
case AF_DONTNEEDDELAYS:
return 0; // need delay
@@ -1031,8 +938,9 @@ INT_PTR CMraProto::MraGetAvatarInfo(WPARAM wParam, LPARAM lParam) INT_PTR CMraProto::MraGetMyAvatar(WPARAM wParam, LPARAM lParam)
{
- if ( MraAvatarsGetFileName(hAvatarsQueueHandle, NULL, GetContactAvatarFormat(NULL, PA_FORMAT_DEFAULT), (LPTSTR)wParam, (size_t)lParam, NULL) == NO_ERROR) {
- LPSTR lpsz = (LPSTR)wParam;
+ CMStringW wszFileName;
+ if ( MraAvatarsGetFileName(hAvatarsQueueHandle, NULL, GetContactAvatarFormat(NULL, PA_FORMAT_DEFAULT), wszFileName) == NO_ERROR) {
+ lstrcpyn((LPTSTR)wParam, wszFileName, (size_t)lParam);
return 0;
}
return 1;
|