diff options
author | George Hazan <george.hazan@gmail.com> | 2013-09-07 13:44:11 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-09-07 13:44:11 +0000 |
commit | a39e5feeb667a633cf6a24a4785233a73bb60e00 (patch) | |
tree | 7bfdcd0f6a33df62f396d3946cc9c26ebfd95487 /protocols | |
parent | 8543e1e7f855b195154a2d3739e834b58fa739cd (diff) |
- full group support
- code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@5998 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/MRA/src/Mra.h | 2 | ||||
-rw-r--r-- | protocols/MRA/src/MraChat.cpp | 4 | ||||
-rw-r--r-- | protocols/MRA/src/MraProto.cpp | 17 | ||||
-rw-r--r-- | protocols/MRA/src/MraProto.h | 11 | ||||
-rw-r--r-- | protocols/MRA/src/MraSendCommand.cpp | 24 | ||||
-rw-r--r-- | protocols/MRA/src/Mra_functions.cpp | 33 | ||||
-rw-r--r-- | protocols/MRA/src/Mra_proto.cpp | 27 | ||||
-rw-r--r-- | protocols/MRA/src/Mra_svcs.cpp | 55 |
8 files changed, 112 insertions, 61 deletions
diff --git a/protocols/MRA/src/Mra.h b/protocols/MRA/src/Mra.h index a6b234c6d0..18ca7ef94e 100644 --- a/protocols/MRA/src/Mra.h +++ b/protocols/MRA/src/Mra.h @@ -293,7 +293,7 @@ DWORD FindFile(LPWSTR lpszFolder, DWORD dwFolderLen, LPWSTR lpszFileName, DW DWORD MemFillRandom(LPVOID lpBuff, size_t dwBuffSize);
DWORD GetMraStatusFromMiradaStatus(DWORD dwMirandaStatus, DWORD dwXStatusMir, DWORD *pdwXStatusMra);
-DWORD GetMiradaStatusFromMraStatus(DWORD dwMraStatus, DWORD dwXStatusMra, DWORD *pdwXStatusMir);
+DWORD GetMirandaStatusFromMraStatus(DWORD dwMraStatus, DWORD dwXStatusMra, DWORD *pdwXStatusMir);
DWORD GetMraXStatusIDFromMraUriStatus(const char *lpszStatusUri);
INT_PTR CALLBACK DlgProcAccount(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
diff --git a/protocols/MRA/src/MraChat.cpp b/protocols/MRA/src/MraChat.cpp index b607571436..c7e8e2c209 100644 --- a/protocols/MRA/src/MraChat.cpp +++ b/protocols/MRA/src/MraChat.cpp @@ -72,7 +72,7 @@ INT_PTR CMraProto::MraChatSessionNew(HANDLE hContact) DWORD opcode = MULTICHAT_GET_MEMBERS;
CMStringA szEmail;
mraGetStringA(hContact, "e-mail", szEmail);
- MraMessageW(FALSE, NULL, 0, MESSAGE_FLAG_MULTICHAT, szEmail, L"", (LPBYTE)&opcode, sizeof(opcode));
+ MraMessage(FALSE, NULL, 0, MESSAGE_FLAG_MULTICHAT, szEmail, L"", (LPBYTE)&opcode, sizeof(opcode));
return 0;
}
}
@@ -229,7 +229,7 @@ int CMraProto::MraChatGcEventHook(WPARAM, LPARAM lParam) if (getByte("RTFSendEnable", MRA_DEFAULT_RTF_SEND_ENABLE) && (MraContactCapabilitiesGet(hContact)&FEATURE_FLAG_RTF_MESSAGE))
dwFlags |= MESSAGE_FLAG_RTF;
- INT_PTR iSendRet = MraMessageW(bSlowSend, hContact, ACKTYPE_MESSAGE, dwFlags, szEmail, gch->ptszText, NULL, 0);
+ INT_PTR iSendRet = MraMessage(bSlowSend, hContact, ACKTYPE_MESSAGE, dwFlags, szEmail, gch->ptszText, NULL, 0);
if (bSlowSend == FALSE)
ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)iSendRet, 0);
diff --git a/protocols/MRA/src/MraProto.cpp b/protocols/MRA/src/MraProto.cpp index a42d404bfa..67a8eba6d7 100644 --- a/protocols/MRA/src/MraProto.cpp +++ b/protocols/MRA/src/MraProto.cpp @@ -248,7 +248,7 @@ int CMraProto::AuthDeny(HANDLE hDBEvent, const TCHAR* szReason) LPSTR lpszLastName = lpszFirstName + lstrlenA(lpszFirstName) + 1;
LPSTR szEmail = lpszLastName + lstrlenA(lpszLastName) + 1;
- MraMessageW(FALSE, NULL, 0, 0, szEmail, szReason, NULL, 0);
+ MraMessage(FALSE, NULL, 0, 0, szEmail, szReason, NULL, 0);
return 0;
}
@@ -403,7 +403,7 @@ int CMraProto::SendContacts(HANDLE hContact, int flags, int nContacts, HANDLE* h }
bSlowSend = getByte("SlowSend", MRA_DEFAULT_SLOW_SEND);
- iRet = MraMessageW(bSlowSend, hContact, ACKTYPE_CONTACTS, MESSAGE_FLAG_CONTACT, szEmail, wszData, NULL, 0);
+ iRet = MraMessage(bSlowSend, hContact, ACKTYPE_CONTACTS, MESSAGE_FLAG_CONTACT, szEmail, wszData, NULL, 0);
if (bSlowSend == FALSE)
ProtoBroadcastAck(hContact, ACKTYPE_CONTACTS, ACKRESULT_SUCCESS, (HANDLE)iRet, 0);
}
@@ -454,7 +454,7 @@ int CMraProto::SendMsg(HANDLE hContact, int flags, const char *lpszMessage) if ( getByte("RTFSendEnable", MRA_DEFAULT_RTF_SEND_ENABLE) && (MraContactCapabilitiesGet(hContact) & FEATURE_FLAG_RTF_MESSAGE))
dwFlags |= MESSAGE_FLAG_RTF;
- iRet = MraMessageW(bSlowSend, hContact, ACKTYPE_MESSAGE, dwFlags, szEmail, lpwszMessage, NULL, 0);
+ iRet = MraMessage(bSlowSend, hContact, ACKTYPE_MESSAGE, dwFlags, szEmail, lpwszMessage, NULL, 0);
if (bSlowSend == FALSE)
ProtoBroadcastAckAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)iRet, 0);
}
@@ -476,13 +476,8 @@ int CMraProto::SetApparentMode(HANDLE hContact, int mode) // Dont send redundant updates
if (mode != dwOldMode) {
- CMStringA szEmail, szPhones;
- CMStringW wszNick;
- DWORD dwID, dwGroupID, dwContactFlag = 0;
+ DWORD dwContactFlag = 0;
- GetContactBasicInfoW(hContact, &dwID, &dwGroupID, &dwContactFlag, NULL, NULL, &szEmail, &wszNick, &szPhones);
-
- dwContactFlag &= ~(CONTACT_FLAG_INVISIBLE | CONTACT_FLAG_VISIBLE);
switch (mode) {
case ID_STATUS_OFFLINE:
dwContactFlag |= CONTACT_FLAG_INVISIBLE;
@@ -492,7 +487,7 @@ int CMraProto::SetApparentMode(HANDLE hContact, int mode) break;
}
- if (MraModifyContactW(hContact, dwID, dwContactFlag, dwGroupID, szEmail, wszNick, szPhones)) {
+ if ( MraModifyContact(hContact, 0, &dwContactFlag)) {
SetContactBasicInfoW(hContact, 0, SCBIF_FLAG, 0, 0, dwContactFlag, 0, 0, 0, 0, 0);
return 0; // Success
}
@@ -617,7 +612,7 @@ int CMraProto::UserIsTyping(HANDLE hContact, int type) CMStringA szEmail;
if ( MraGetContactStatus(hContact) != ID_STATUS_OFFLINE && m_iStatus != ID_STATUS_INVISIBLE)
if ( mraGetStringA(hContact, "e-mail", szEmail))
- if ( MraMessageW(FALSE, hContact, 0, MESSAGE_FLAG_NOTIFY, szEmail, L" ", NULL, 0))
+ if ( MraMessage(FALSE, hContact, 0, MESSAGE_FLAG_NOTIFY, szEmail, L" ", NULL, 0))
return 0;
return 1;
diff --git a/protocols/MRA/src/MraProto.h b/protocols/MRA/src/MraProto.h index cbd3d8d064..0506eea007 100644 --- a/protocols/MRA/src/MraProto.h +++ b/protocols/MRA/src/MraProto.h @@ -202,14 +202,15 @@ struct CMraProto : public PROTO<CMraProto> HANDLE AddToListByEmail(LPCTSTR plpsEMail, LPCTSTR plpsNick, LPCTSTR plpsFirstName, LPCTSTR plpsLastName, DWORD dwFlags);
- DWORD MraMessageW(BOOL bAddToQueue, HANDLE hContact, DWORD dwAckType, DWORD dwFlags, const CMStringA &szEmail, const CMStringW &wszMessage, LPBYTE lpbMultiChatData, size_t dwMultiChatDataSize);
- DWORD MraMessageAskW(DWORD dwMsgID, DWORD dwFlags, const CMStringA &szEmail, const CMStringW &wszMessage, const CMStringW &wszMessageRTF);
+ DWORD MraMessage(BOOL bAddToQueue, HANDLE hContact, DWORD dwAckType, DWORD dwFlags, const CMStringA &szEmail, const CMStringW &wszMessage, LPBYTE lpbMultiChatData, size_t dwMultiChatDataSize);
+ DWORD MraMessageAsk(DWORD dwMsgID, DWORD dwFlags, const CMStringA &szEmail, const CMStringW &wszMessage, const CMStringW &wszMessageRTF);
DWORD MraMessageRecv(const CMStringA &szFrom, DWORD dwMsgID);
- DWORD MraAddContactW(HANDLE hContact, DWORD dwContactFlag, DWORD dwGroupID, const CMStringA &szEmail, const CMStringW &wszCustomName, const CMStringA &szPhones, const CMStringW &wszAuthMessage, DWORD dwActions);
- DWORD MraModifyContactW(HANDLE hContact, DWORD dwID, DWORD dwContactFlag, DWORD dwGroupID, const CMStringA &szEmail, const CMStringW &wszCustomName, const CMStringA &szPhones);
+ DWORD MraAddContact(HANDLE hContact, DWORD dwContactFlag, DWORD dwGroupID, const CMStringA &szEmail, const CMStringW &wszCustomName, const CMStringA &szPhones, const CMStringW &wszAuthMessage, DWORD dwActions);
+ DWORD MraModifyContact(HANDLE hContact, DWORD *pdwID = 0, DWORD *pdwContactFlag = 0, DWORD *pdwGroupID = 0, const CMStringA *pszEmail = 0, const CMStringW *pwszCustomName = 0, const CMStringA *pszPhones = 0);
DWORD MraOfflineMessageDel(DWORDLONG dwMsgUIDL);
+ DWORD MraMoveContactToGroup(HANDLE hContact, DWORD dwGroupID, LPCTSTR ptszGroup);
DWORD MraAuthorize(const CMStringA &szEmail);
- DWORD MraChangeStatusW(DWORD dwStatus, const CMStringA &szStatusUri, const CMStringW &wszStatusTitle, const CMStringW &wszStatusDesc, DWORD dwFutureFlags);
+ DWORD MraChangeStatus(DWORD dwStatus, const CMStringA &szStatusUri, const CMStringW &wszStatusTitle, const CMStringW &wszStatusDesc, DWORD dwFutureFlags);
DWORD MraFileTransfer(const CMStringA &szEmail, DWORD dwIdRequest, DWORD dwFilesTotalSize, const CMStringW &lpwszFiles, const CMStringA &szAddresses);
DWORD MraFileTransferAck(DWORD dwStatus, const CMStringA &szEmail, DWORD dwIdRequest, LPBYTE lpbDescription, size_t dwDescriptionSize);
HANDLE MraWPRequestW(HANDLE hContact, DWORD dwAckType, DWORD dwRequestFlags, const CMStringA &szUser, const CMStringA &szDomain, const CMStringW &wszNickName, const CMStringW &wszFirstName, const CMStringW &wszLastName, DWORD dwSex, DWORD dwDate1, DWORD dwDate2, DWORD dwCityID, DWORD dwZodiak, DWORD dwBirthdayMonth, DWORD dwBirthdayDay, DWORD dwCountryID, DWORD dwOnline);
diff --git a/protocols/MRA/src/MraSendCommand.cpp b/protocols/MRA/src/MraSendCommand.cpp index 33796b5c36..ab7df94a28 100644 --- a/protocols/MRA/src/MraSendCommand.cpp +++ b/protocols/MRA/src/MraSendCommand.cpp @@ -71,7 +71,7 @@ public: /////////////////////////////////////////////////////////////////////////////////////////
-DWORD CMraProto::MraMessageW(BOOL bAddToQueue, HANDLE hContact, DWORD dwAckType, DWORD dwFlags, const CMStringA &szEmail, const CMStringW &lpwszMessage, LPBYTE lpbMultiChatData, size_t dwMultiChatDataSize)
+DWORD CMraProto::MraMessage(BOOL bAddToQueue, HANDLE hContact, DWORD dwAckType, DWORD dwFlags, const CMStringA &szEmail, const CMStringW &lpwszMessage, LPBYTE lpbMultiChatData, size_t dwMultiChatDataSize)
{
Netlib_Logf(m_hNetlibUser, "Sending message: flags %08x, to '%S', message '%S'\n", dwFlags, szEmail, lpwszMessage);
@@ -156,7 +156,7 @@ DWORD CMraProto::MraMessageW(BOOL bAddToQueue, HANDLE hContact, DWORD dwAckType, }
// Send confirmation
-DWORD CMraProto::MraMessageAskW(DWORD dwMsgID, DWORD dwFlags, const CMStringA &szEmail, const CMStringW &lpwszMessage, const CMStringW &lpwszMessageRTF)
+DWORD CMraProto::MraMessageAsk(DWORD dwMsgID, DWORD dwFlags, const CMStringA &szEmail, const CMStringW &lpwszMessage, const CMStringW &lpwszMessageRTF)
{
if (szEmail.GetLength() <= 4 || lpwszMessage.IsEmpty())
return 0;
@@ -184,7 +184,7 @@ DWORD CMraProto::MraMessageRecv(const CMStringA &szFrom, DWORD dwMsgID) }
// Adds new contact
-DWORD CMraProto::MraAddContactW(HANDLE hContact, DWORD dwContactFlag, DWORD dwGroupID, const CMStringA &szEmail, const CMStringW &wszCustomName, const CMStringA &szPhones, const CMStringW &wszAuthMessage, DWORD dwActions)
+DWORD CMraProto::MraAddContact(HANDLE hContact, DWORD dwContactFlag, DWORD dwGroupID, const CMStringA &szEmail, const CMStringW &wszCustomName, const CMStringA &szPhones, const CMStringW &wszAuthMessage, DWORD dwActions)
{
if (szEmail.GetLength() <= 4)
return 0;
@@ -211,11 +211,23 @@ DWORD CMraProto::MraAddContactW(HANDLE hContact, DWORD dwContactFlag, DWORD dwGr }
// change contact
-DWORD CMraProto::MraModifyContactW(HANDLE hContact, DWORD dwID, DWORD dwContactFlag, DWORD dwGroupID, const CMStringA &szEmail, const CMStringW &wszCustomName, const CMStringA &szPhones)
+DWORD CMraProto::MraModifyContact(HANDLE hContact, DWORD *pdwID, DWORD *pdwContactFlag, DWORD *pdwGroupID, const CMStringA *pszEmail, const CMStringW *pwszCustomName, const CMStringA *pszPhones)
{
- if (dwID == -1)
+ if (pdwID && *pdwID == -1)
return 0;
+ CMStringA szEmail, szPhones;
+ CMStringW wszNick, wszCustomName;
+ DWORD dwID, dwGroupID, dwContactFlag;
+ GetContactBasicInfoW(hContact, &dwID, &dwGroupID, &dwContactFlag, NULL, NULL, &szEmail, &wszNick, &szPhones);
+
+ if (pdwID) dwID = *pdwID;
+ if (pszEmail) szEmail = *pszEmail;
+ if (pszPhones) szPhones = *pszPhones;
+ if (pdwGroupID) dwGroupID = *pdwGroupID;
+ if (pdwContactFlag) dwContactFlag = *pdwContactFlag;
+ if (pwszCustomName) wszCustomName = *pwszCustomName;
+
dwContactFlag |= CONTACT_FLAG_UNICODE_NAME;
OutBuffer buf;
@@ -247,7 +259,7 @@ DWORD CMraProto::MraAuthorize(const CMStringA& szEmail) }
// change status
-DWORD CMraProto::MraChangeStatusW(DWORD dwStatus, const CMStringA &szStatusUri, const CMStringW &wszStatusTitle, const CMStringW &wszStatusDesc, DWORD dwFutureFlags)
+DWORD CMraProto::MraChangeStatus(DWORD dwStatus, const CMStringA &szStatusUri, const CMStringW &wszStatusTitle, const CMStringW &wszStatusDesc, DWORD dwFutureFlags)
{
OutBuffer buf;
buf.SetUL(dwStatus);
diff --git a/protocols/MRA/src/Mra_functions.cpp b/protocols/MRA/src/Mra_functions.cpp index 66d71e5966..e3548ebad4 100644 --- a/protocols/MRA/src/Mra_functions.cpp +++ b/protocols/MRA/src/Mra_functions.cpp @@ -297,12 +297,41 @@ BOOL DB_GetContactSettingBlob(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszVal return(bRet);
}
+DWORD CMraProto::MraMoveContactToGroup(HANDLE hContact, DWORD dwGroupID, LPCTSTR ptszName)
+{
+ MraGroupItem *p = NULL;
+
+ for (int i=0; i < m_groups.getCount(); i++)
+ if (m_groups[i].m_name == ptszName) {
+ p = &m_groups[i];
+ break;
+ }
+
+ if (p == NULL) {
+ if (m_groups.getCount() == 20)
+ return 0;
+
+ DWORD id;
+ for (id=0; id < 20; id++)
+ if (m_groups.find((MraGroupItem*)&id) == NULL)
+ break;
+
+ p = new MraGroupItem(id, CONTACT_FLAG_GROUP, ptszName);
+ m_groups.insert(p);
+ }
+
+ if (dwGroupID != p->m_id) {
+ setDword("GroupID", p->m_id);
+ MraModifyContact(hContact, 0, 0, &p->m_id);
+ }
+ return p->m_id;
+}
+
DWORD CMraProto::GetContactFlags(HANDLE hContact)
{
DWORD dwRet = 0;
- if (IsContactMra(hContact))
- {
+ if (IsContactMra(hContact)) {
dwRet = getDword(hContact, "ContactFlags", 0);
dwRet &= ~(CONTACT_FLAG_REMOVED|CONTACT_FLAG_GROUP|CONTACT_FLAG_INVISIBLE|CONTACT_FLAG_VISIBLE|CONTACT_FLAG_IGNORE|CONTACT_FLAG_SHADOW|CONTACT_FLAG_MULTICHAT);
dwRet |= CONTACT_FLAG_UNICODE_NAME;
diff --git a/protocols/MRA/src/Mra_proto.cpp b/protocols/MRA/src/Mra_proto.cpp index bba5f38854..a55092f7ba 100644 --- a/protocols/MRA/src/Mra_proto.cpp +++ b/protocols/MRA/src/Mra_proto.cpp @@ -713,7 +713,7 @@ bool CMraProto::CmdUserStatus(BinBuffer &buf) if (bAdded)
MraUpdateContactInfo(hContact);
- DWORD dwTemp = GetMiradaStatusFromMraStatus(dwStatus, GetMraXStatusIDFromMraUriStatus(szSpecStatusUri), &dwXStatus);
+ DWORD dwTemp = GetMirandaStatusFromMraStatus(dwStatus, GetMraXStatusIDFromMraUriStatus(szSpecStatusUri), &dwXStatus);
MraContactCapabilitiesSet(hContact, dwFutureFlags);
setByte(hContact, DBSETTING_XSTATUSID, (BYTE)dwXStatus);
@@ -934,7 +934,7 @@ bool CMraProto::CmdAnketaInfo(int seq, BinBuffer &buf) GetContactBasicInfoW(hContact, &dwID, NULL, NULL, &dwContactSeverFlags, NULL, NULL, NULL, NULL);
// для авторизованного нам и так присылают правильный статус
if (dwID == -1 || (dwContactSeverFlags & CONTACT_INTFLAG_NOT_AUTHORIZED)) {
- MraSetContactStatus(hContact, GetMiradaStatusFromMraStatus(atoi(val), MRA_MIR_XSTATUS_NONE, NULL));
+ MraSetContactStatus(hContact, GetMirandaStatusFromMraStatus(atoi(val), MRA_MIR_XSTATUS_NONE, NULL));
setByte(hContact, DBSETTING_XSTATUSID, (BYTE)MRA_MIR_XSTATUS_NONE);
}
}
@@ -945,7 +945,7 @@ bool CMraProto::CmdAnketaInfo(int seq, BinBuffer &buf) DWORD dwID, dwContactSeverFlags, dwXStatus;
GetContactBasicInfoW(hContact, &dwID, NULL, NULL, &dwContactSeverFlags, NULL, NULL, NULL, NULL);
if (dwID == -1 || (dwContactSeverFlags & CONTACT_INTFLAG_NOT_AUTHORIZED)) {
- MraSetContactStatus(hContact, GetMiradaStatusFromMraStatus(atoi(val), GetMraXStatusIDFromMraUriStatus(val), &dwXStatus));
+ MraSetContactStatus(hContact, GetMirandaStatusFromMraStatus(atoi(val), GetMraXStatusIDFromMraUriStatus(val), &dwXStatus));
setByte(hContact, DBSETTING_XSTATUSID, (BYTE)dwXStatus);
}
}
@@ -1101,6 +1101,8 @@ bool CMraProto::CmdClist2(BinBuffer &buf) CMStringW wszNick, wszString, wszGroupName, wszStatusTitle, wszStatusDesc, wszBlogStatus, wszBlogStatusMusic;
buf >> dwGroupsCount >> szGroupMask >> szContactMask;
+ int iGroupMode = getByte("GroupMode", 100);
+
DebugPrintCRLFW(L"Groups:");
DebugPrintCRLFA(szGroupMask);
DWORD dwID = 0;
@@ -1303,7 +1305,7 @@ bool CMraProto::CmdClist2(BinBuffer &buf) DebugBreak();
}
else {
- dwTemp = GetMiradaStatusFromMraStatus(dwStatus, GetMraXStatusIDFromMraUriStatus(szSpecStatusUri), &dwXStatus);
+ dwTemp = GetMirandaStatusFromMraStatus(dwStatus, GetMraXStatusIDFromMraUriStatus(szSpecStatusUri), &dwXStatus);
if (bAdded) { // update user info
SetContactBasicInfoW(hContact, SCBIFSI_LOCK_CHANGES_EVENTS, (SCBIF_ID|SCBIF_GROUP_ID|SCBIF_FLAG|SCBIF_SERVER_FLAG|SCBIF_STATUS|SCBIF_NICK|SCBIF_PHONES),
@@ -1312,11 +1314,17 @@ bool CMraProto::CmdClist2(BinBuffer &buf) MraUpdateContactInfo(hContact);
}
else { //****deb - check group ID param
+ if (iGroupMode == 100) { // first start
+ ptrT tszGroup( db_get_tsa(hContact, "CList", "Group"));
+ if (tszGroup)
+ dwGroupID = MraMoveContactToGroup(hContact, dwGroupID, tszGroup);
+ }
+
SetContactBasicInfoW(hContact, SCBIFSI_LOCK_CHANGES_EVENTS, (SCBIF_ID|SCBIF_GROUP_ID|SCBIF_SERVER_FLAG|SCBIF_STATUS),
dwID, dwGroupID, dwContactFlag, dwContactSeverFlags, dwTemp, NULL, &wszNick, &szCustomPhones);
if (wszNick.IsEmpty()) { // set the server-side nick
wszNick = GetContactNameW(hContact);
- MraModifyContactW(hContact, dwID, dwContactFlag, dwGroupID, szEmail, wszNick, szCustomPhones);
+ MraModifyContact(hContact, &dwID, &dwContactFlag, &dwGroupID, &szEmail, &wszNick, &szCustomPhones);
}
}
@@ -1367,7 +1375,7 @@ bool CMraProto::CmdClist2(BinBuffer &buf) MraSetContactStatus(hContact, ID_STATUS_ONLINE);
CMStringW wszCustomName = GetContactNameW(hContact);
- MraAddContactW(hContact, (CONTACT_FLAG_VISIBLE|CONTACT_FLAG_MULTICHAT|CONTACT_FLAG_UNICODE_NAME),
+ MraAddContact(hContact, (CONTACT_FLAG_VISIBLE|CONTACT_FLAG_MULTICHAT|CONTACT_FLAG_UNICODE_NAME),
-1, szEmail, wszCustomName, "", L"", 0);
}
else {
@@ -1375,7 +1383,7 @@ bool CMraProto::CmdClist2(BinBuffer &buf) SetExtraIcons(hContact);
if (getByte("AutoAddContactsToServer", MRA_DEFAULT_AUTO_ADD_CONTACTS_TO_SERVER)) { //add all contacts to server
GetContactBasicInfoW(hContact, NULL, &dwGroupID, NULL, NULL, NULL, NULL, &wszNick, &szPhones);
- MraAddContactW(hContact, (CONTACT_FLAG_VISIBLE|CONTACT_FLAG_UNICODE_NAME), dwGroupID, szEmail, wszNick, szPhones, wszAuthMessage, 0);
+ MraAddContact(hContact, (CONTACT_FLAG_VISIBLE|CONTACT_FLAG_UNICODE_NAME), dwGroupID, szEmail, wszNick, szPhones, wszAuthMessage, 0);
}
}
}
@@ -1383,6 +1391,7 @@ bool CMraProto::CmdClist2(BinBuffer &buf) }
}
}
+ setByte("GroupMode", 1);
}
else { // контакт лист почемуто не получили
// всех в offline и id в нестандарт
@@ -1778,7 +1787,7 @@ DWORD CMraProto::MraRecvCommand_Message(DWORD dwTime, DWORD dwFlags, CMStringA & break;
case MULTICHAT_INVITE:
MraChatSessionInvite(hContact, lpsEMailInMultiChat, dwTime);// LPS sender
- MraAddContactW(hContact, (CONTACT_FLAG_VISIBLE|CONTACT_FLAG_MULTICHAT|CONTACT_FLAG_UNICODE_NAME), -1, plpsFrom, lpsMultichatName, "", L"", 0);
+ MraAddContact(hContact, (CONTACT_FLAG_VISIBLE|CONTACT_FLAG_MULTICHAT|CONTACT_FLAG_UNICODE_NAME), -1, plpsFrom, lpsMultichatName, "", L"", 0);
break;
default:
DebugBreak();
@@ -1928,7 +1937,7 @@ DWORD GetMraStatusFromMiradaStatus(DWORD dwMirandaStatus, DWORD dwXStatusMir, DW return STATUS_OFFLINE;
}
-DWORD GetMiradaStatusFromMraStatus(DWORD dwMraStatus, DWORD dwXStatusMra, DWORD *pdwXStatusMir)
+DWORD GetMirandaStatusFromMraStatus(DWORD dwMraStatus, DWORD dwXStatusMra, DWORD *pdwXStatusMir)
{
if (pdwXStatusMir) *pdwXStatusMir = 0;
diff --git a/protocols/MRA/src/Mra_svcs.cpp b/protocols/MRA/src/Mra_svcs.cpp index 73eabd9c5b..bcb5a4a65b 100644 --- a/protocols/MRA/src/Mra_svcs.cpp +++ b/protocols/MRA/src/Mra_svcs.cpp @@ -263,7 +263,7 @@ INT_PTR CMraProto::MraRequestAuthorization(WPARAM wParam, LPARAM lParam) 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);
+ int iRet = MraMessage(bSlowSend, hContact, ACKTYPE_AUTHREQ, MESSAGE_FLAG_AUTHORIZE, szEmail, wszAuthMessage, NULL, 0);
if (bSlowSend == FALSE)
ProtoBroadcastAck(hContact, ACKTYPE_AUTHREQ, ACKRESULT_SUCCESS, (HANDLE)iRet, 0);
@@ -414,13 +414,14 @@ int CMraProto::MraContactDeleted(WPARAM wParam, LPARAM lParam) return 0;
if ( IsContactMra(hContact)) {
- CMStringA szEmail;
DWORD dwID, dwGroupID;
- GetContactBasicInfoW(hContact, &dwID, &dwGroupID, NULL, NULL, NULL, &szEmail, NULL, NULL);
+ GetContactBasicInfoW(hContact, &dwID, &dwGroupID, NULL, NULL, NULL, NULL, 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, L"", "");
+ if ( !db_get_b(hContact, "CList", "NotOnList", 0) || dwID != -1) {
+ DWORD dwFlags = CONTACT_FLAG_REMOVED;
+ MraModifyContact(hContact, &dwID, &dwFlags);
+ }
MraAvatarsDeleteContactAvatarFile(hAvatarsQueueHandle, hContact);
}
return 0;
@@ -439,14 +440,13 @@ int CMraProto::MraDbSettingChanged(WPARAM wParam, LPARAM lParam) // это наш контакт, он не временный (есть в списке на сервере) и его обновление разрешено
if ( IsContactMra(hContact) && !db_get_b(hContact, "CList", "NotOnList", 0) && getDword(hContact, "HooksLocked", FALSE) == FALSE) {
- CMStringA szEmail, szPhones;
- CMStringW wszNick;
- DWORD dwID, dwGroupID, dwContactFlag;
+ DWORD dwContactFlag;
if ( !strcmp(cws->szModule, "CList")) {
// MyHandle setting
if ( !strcmp(cws->szSetting, "MyHandle")) {
// always store custom nick
+ CMStringW wszNick;
if (cws->value.type == DBVT_DELETED) {
wszNick = GetContactNameW(hContact);
db_set_ws(hContact, "CList", "MyHandle", wszNick);
@@ -462,23 +462,28 @@ int CMraProto::MraDbSettingChanged(WPARAM wParam, LPARAM lParam) case DBVT_ASCIIZ:
wszNick = ptrW( mir_a2u_cp(cws->value.pszVal, MRA_CODE_PAGE));
break;
- default:
- break;
}
if (wszNick.GetLength())
- if (GetContactBasicInfoW(hContact, &dwID, &dwGroupID, &dwContactFlag, NULL, NULL, &szEmail, NULL, &szPhones) == NO_ERROR)
- MraModifyContactW(hContact, dwID, dwContactFlag, dwGroupID, szEmail, wszNick, szPhones);
+ MraModifyContact(hContact, 0, 0, 0, 0, &wszNick);
}
}
// Group setting
else if ( !strcmp(cws->szSetting, "Group")) {
+ CMStringW wszGroup;
// manage group on server
switch (cws->value.type) {
- case DBVT_ASCIIZ:
+ case DBVT_WCHAR:
+ wszGroup = cws->value.pwszVal;
break;
- case DBVT_DELETED:
+ case DBVT_UTF8:
+ wszGroup = ptrW( mir_utf8decodeW(cws->value.pszVal));
+ break;
+ case DBVT_ASCIIZ:
+ wszGroup = ptrW( mir_a2u_cp(cws->value.pszVal, MRA_CODE_PAGE));
break;
}
+ if (wszGroup.GetLength())
+ MraMoveContactToGroup(hContact, getDword("GroupID", -1), wszGroup);
}
// NotOnList setting. Has a temporary contact just been added permanently?
else if ( !strcmp(cws->szSetting, "NotOnList")) {
@@ -488,39 +493,39 @@ int CMraProto::MraDbSettingChanged(WPARAM wParam, LPARAM lParam) wszAuthMessage = TranslateW(MRA_DEFAULT_AUTH_MESSAGE);
db_unset(hContact, "CList", "Hidden");
+
+ CMStringA szEmail, szPhones;
+ CMStringW wszNick;
+ DWORD dwGroupID, dwContactFlag;
GetContactBasicInfoW(hContact, NULL, &dwGroupID, &dwContactFlag, NULL, NULL, &szEmail, &wszNick, &szPhones);
- MraAddContactW(hContact, dwContactFlag, dwGroupID, szEmail, wszNick, szPhones, wszAuthMessage, 0);
+ MraAddContact(hContact, dwContactFlag, dwGroupID, szEmail, wszNick, szPhones, wszAuthMessage, 0);
}
}
// Hidden setting
else if ( !strcmp(cws->szSetting, "Hidden")) {
- 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);
+ MraModifyContact(hContact, 0, &dwContactFlag);
}
}
// Ignore section
else if ( !strcmp(cws->szModule, "Ignore")) {
if ( !strcmp(cws->szSetting, "Mask1")) {
- 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);
+ MraModifyContact(hContact, 0, &dwContactFlag);
}
}
// User info section
else if ( !strcmp(cws->szModule, "UserInfo")) {
- if ( !strcmp(cws->szSetting, "MyPhone0") || !strcmp(cws->szSetting, "MyPhone1") || !strcmp(cws->szSetting, "MyPhone2")) {
- GetContactBasicInfoW(hContact, &dwID, &dwGroupID, &dwContactFlag, NULL, NULL, &szEmail, &wszNick, &szPhones);
- MraModifyContactW(hContact, dwID, dwContactFlag, dwGroupID, szEmail, wszNick, szPhones);
- }
+ if ( !strcmp(cws->szSetting, "MyPhone0") || !strcmp(cws->szSetting, "MyPhone1") || !strcmp(cws->szSetting, "MyPhone2"))
+ MraModifyContact(hContact);
}
}
return 0;
@@ -874,7 +879,7 @@ DWORD CMraProto::MraSendNewStatus(DWORD dwStatusMir, DWORD dwXStatusMir, const C else if (pwszStatusTitle.IsEmpty())
wszStatusTitle = GetStatusModeDescriptionW(dwStatusMir);
- MraChangeStatusW(dwStatus, lpcszStatusUri[dwXStatus], wszStatusTitle, wszStatusDesc, ((getByte("RTFReceiveEnable", MRA_DEFAULT_RTF_RECEIVE_ENABLE)? FEATURE_FLAG_RTF_MESSAGE:0)|MRA_FEATURE_FLAGS));
+ MraChangeStatus(dwStatus, lpcszStatusUri[dwXStatus], wszStatusTitle, wszStatusDesc, ((getByte("RTFReceiveEnable", MRA_DEFAULT_RTF_RECEIVE_ENABLE)? FEATURE_FLAG_RTF_MESSAGE:0)|MRA_FEATURE_FLAGS));
return 0;
}
@@ -886,7 +891,7 @@ INT_PTR CMraProto::MraSendNudge(WPARAM wParam, LPARAM lParam) CMStringA szEmail;
if (mraGetStringA(hContact, "e-mail", szEmail))
- if (MraMessageW(FALSE, hContact, 0, (MESSAGE_FLAG_RTF|MESSAGE_FLAG_ALARM), szEmail, lpwszAlarmMessage, NULL, 0))
+ if (MraMessage(FALSE, hContact, 0, (MESSAGE_FLAG_RTF|MESSAGE_FLAG_ALARM), szEmail, lpwszAlarmMessage, NULL, 0))
return 0;
}
return 1;
|