diff options
Diffstat (limited to 'protocols/MRA/src')
-rw-r--r-- | protocols/MRA/src/MraProto.cpp | 6 | ||||
-rw-r--r-- | protocols/MRA/src/MraProto.h | 2 | ||||
-rw-r--r-- | protocols/MRA/src/Mra_functions.cpp | 47 | ||||
-rw-r--r-- | protocols/MRA/src/Mra_proto.cpp | 17 |
4 files changed, 30 insertions, 42 deletions
diff --git a/protocols/MRA/src/MraProto.cpp b/protocols/MRA/src/MraProto.cpp index cbe12c5f6a..a6e05e5c3e 100644 --- a/protocols/MRA/src/MraProto.cpp +++ b/protocols/MRA/src/MraProto.cpp @@ -100,7 +100,7 @@ int CMraProto::OnModulesLoaded(WPARAM, LPARAM) // всех в offline // тк unsaved values сохраняются их нужно инициализировать
for (HANDLE hContact = db_find_first(); hContact != NULL; hContact = db_find_next(hContact))
- SetContactBasicInfoW(hContact, SCBIFSI_LOCK_CHANGES_EVENTS, (SCBIF_ID|SCBIF_GROUP_ID|SCBIF_SERVER_FLAG|SCBIF_STATUS), -1, -1, 0, 0, ID_STATUS_OFFLINE, "", L"", "");
+ SetContactBasicInfoW(hContact, SCBIFSI_LOCK_CHANGES_EVENTS, (SCBIF_ID|SCBIF_GROUP_ID|SCBIF_SERVER_FLAG|SCBIF_STATUS), -1, -1, 0, 0, ID_STATUS_OFFLINE, 0, 0, 0);
// unsaved values
db_set_resident(m_szModuleName, "Status");// NOTE: XStatus cannot be temporary
@@ -492,7 +492,7 @@ int CMraProto::SetApparentMode(HANDLE hContact, int mode) }
if (MraModifyContactW(hContact, dwID, dwContactFlag, dwGroupID, szEmail, wszNick, szPhones)) {
- SetContactBasicInfoW(hContact, 0, SCBIF_FLAG, 0, 0, dwContactFlag, 0, 0, "", L"", "");
+ SetContactBasicInfoW(hContact, 0, SCBIF_FLAG, 0, 0, dwContactFlag, 0, 0, 0, 0, 0);
return 0; // Success
}
}
@@ -530,7 +530,7 @@ int CMraProto::SetStatus(int iNewStatus) if (dwOldStatusMode > ID_STATUS_OFFLINE) {
// функция сама проверяет принадлежность контакта к MRA
for (HANDLE hContact = db_find_first();hContact != NULL;hContact = db_find_next(hContact))
- SetContactBasicInfoW(hContact, SCBIFSI_LOCK_CHANGES_EVENTS, (SCBIF_ID|SCBIF_GROUP_ID|SCBIF_SERVER_FLAG|SCBIF_STATUS), -1, -1, 0, 0, ID_STATUS_OFFLINE, "", L"", "");
+ SetContactBasicInfoW(hContact, SCBIFSI_LOCK_CHANGES_EVENTS, (SCBIF_ID|SCBIF_GROUP_ID|SCBIF_SERVER_FLAG|SCBIF_STATUS), -1, -1, 0, 0, ID_STATUS_OFFLINE, 0, 0, 0);
}
Netlib_CloseHandle(m_hConnection);
}
diff --git a/protocols/MRA/src/MraProto.h b/protocols/MRA/src/MraProto.h index e0f7e06254..a9788ef432 100644 --- a/protocols/MRA/src/MraProto.h +++ b/protocols/MRA/src/MraProto.h @@ -228,7 +228,7 @@ struct CMraProto : public PROTO<CMraProto> DWORD GetContactFlags(HANDLE hContact);
DWORD SetContactFlags(HANDLE hContact, DWORD dwContactFlag);
DWORD GetContactBasicInfoW(HANDLE hContact, DWORD *pdwID, DWORD *pdwGroupID, DWORD *pdwContactFlag, DWORD *pdwContactSeverFlags, DWORD *pdwStatus, CMStringA *szEmail, CMStringW *wszNick, CMStringA *szPhones);
- DWORD SetContactBasicInfoW(HANDLE hContact, DWORD dwSetInfoFlags, DWORD dwFlags, DWORD dwID, DWORD dwGroupID, DWORD dwContactFlag, DWORD dwContactSeverFlags, DWORD dwStatus, const CMStringA &szEmail, const CMStringW &wszNick, const CMStringA &szPhones);
+ DWORD SetContactBasicInfoW(HANDLE hContact, DWORD dwSetInfoFlags, DWORD dwFlags, DWORD dwID, DWORD dwGroupID, DWORD dwContactFlag, DWORD dwContactSeverFlags, DWORD dwStatus, const CMStringA *szEmail, const CMStringW *wszNick, const CMStringA *szPhones);
DWORD GetContactEMailCount(HANDLE hContact, BOOL bMRAOnly);
bool GetContactFirstEMail(HANDLE hContact, BOOL bMRAOnly, CMStringA &szRetBuff);
diff --git a/protocols/MRA/src/Mra_functions.cpp b/protocols/MRA/src/Mra_functions.cpp index f9daa4b4b0..2e08684f42 100644 --- a/protocols/MRA/src/Mra_functions.cpp +++ b/protocols/MRA/src/Mra_functions.cpp @@ -397,7 +397,7 @@ DWORD CMraProto::GetContactBasicInfoW(HANDLE hContact, DWORD *pdwID, DWORD *pdwG return 0;
}
-DWORD CMraProto::SetContactBasicInfoW(HANDLE hContact, DWORD dwSetInfoFlags, DWORD dwFlags, DWORD dwID, DWORD dwGroupID, DWORD dwContactFlag, DWORD dwContactSeverFlags, DWORD dwStatus, const CMStringA &szEmail, const CMStringW &wszNick, const CMStringA &szPhones)
+DWORD CMraProto::SetContactBasicInfoW(HANDLE hContact, DWORD dwSetInfoFlags, DWORD dwFlags, DWORD dwID, DWORD dwGroupID, DWORD dwContactFlag, DWORD dwContactSeverFlags, DWORD dwStatus, const CMStringA *szEmail, const CMStringW *wszNick, const CMStringA *szPhones)
{
if ( !IsContactMra(hContact))
return ERROR_INVALID_HANDLE;
@@ -410,43 +410,30 @@ DWORD CMraProto::SetContactBasicInfoW(HANDLE hContact, DWORD dwSetInfoFlags, DWO if (dwFlags & SCBIF_ID)
setDword(hContact, "ContactID", dwID);
- if ((dwFlags & SCBIF_EMAIL) && !szEmail.IsEmpty())
- mraSetStringExA(hContact, "e-mail", szEmail);
+ if ((dwFlags & SCBIF_EMAIL) && szEmail != NULL && !szEmail->IsEmpty())
+ mraSetStringExA(hContact, "e-mail", *szEmail);
// поля изменения которых отслеживаются
if (dwFlags & SCBIF_GROUP_ID)
setDword(hContact, "GroupID", dwGroupID);
- if ((dwFlags & SCBIF_NICK) && !wszNick.IsEmpty()) {
+ if ((dwFlags & SCBIF_NICK) && wszNick != NULL && !wszNick->IsEmpty()) {
if ((dwFlags & SCBIF_FLAG) && ((dwContactFlag & CONTACT_FLAG_UNICODE_NAME) == 0))
- DB_SetStringExA(hContact, "CList", "MyHandle", CMStringA(wszNick));
+ DB_SetStringExA(hContact, "CList", "MyHandle", CMStringA(*wszNick));
else
- DB_SetStringExW(hContact, "CList", "MyHandle", wszNick);
+ DB_SetStringExW(hContact, "CList", "MyHandle", *wszNick);
}
- if ((dwFlags & SCBIF_PHONES) && !szPhones.IsEmpty()) {
- char szPhone[MAX_PATH], szValue[MAX_PATH];
- LPCSTR lpszCurPhone, lpszPhoneNext;
- size_t i, dwCurPhoneSize;
-
- i = 0;
- lpszPhoneNext = lpszCurPhone = szPhones.c_str();
- while (lpszPhoneNext) {
- lpszPhoneNext = (LPSTR)MemoryFindByte((lpszCurPhone-szPhones), szPhones, szPhones.GetLength(), ',');
- if (lpszPhoneNext)
- dwCurPhoneSize = lpszPhoneNext - lpszCurPhone;
- else
- dwCurPhoneSize = (szPhones.c_str() + szPhones.GetLength()) - lpszCurPhone;
-
- szPhone[0] = '+';
- memmove(szPhone+1, lpszCurPhone, min(dwCurPhoneSize, (SIZEOF(szPhone)-1)));
- szPhone[dwCurPhoneSize+1] = 0;
-
- mir_snprintf(szValue, SIZEOF(szValue), "MyPhone%lu", i);
- DB_SetStringExA(hContact, "UserInfo", szValue, szPhone);
+ if ((dwFlags & SCBIF_PHONES) && szPhones != NULL && !szPhones->IsEmpty()) {
+ int iStart = 0, i = 0;
+ while (true) {
+ CMStringA szPhone = szPhones->Tokenize(",", iStart);
+ if (iStart == -1)
+ break;
- i++;
- lpszCurPhone = (lpszPhoneNext+1);
+ char szValue[MAX_PATH];
+ mir_snprintf(szValue, SIZEOF(szValue), "MyPhone%d", i++);
+ DB_SetStringExA(hContact, "UserInfo", szValue, "+" + szPhone);
}
}
@@ -519,12 +506,12 @@ HANDLE CMraProto::MraHContactFromEmail(const CMStringA& szEmail, BOOL bAddIfNeed if (hContact) {
if ( IsEMailChatAgent(szEmail))
- SetContactBasicInfoW(hContact, SCBIFSI_LOCK_CHANGES_EVENTS, (SCBIF_ID|SCBIF_GROUP_ID|SCBIF_SERVER_FLAG|SCBIF_STATUS|SCBIF_EMAIL), -1, -1, 0, CONTACT_INTFLAG_NOT_AUTHORIZED, ID_STATUS_ONLINE, szEmail, L"", "");
+ SetContactBasicInfoW(hContact, SCBIFSI_LOCK_CHANGES_EVENTS, (SCBIF_ID|SCBIF_GROUP_ID|SCBIF_SERVER_FLAG|SCBIF_STATUS|SCBIF_EMAIL), -1, -1, 0, CONTACT_INTFLAG_NOT_AUTHORIZED, ID_STATUS_ONLINE, &szEmail, 0, 0);
else {
if (bTemporary)
db_set_b(hContact, "CList", "NotOnList", 1);
mraSetStringExA(hContact, "MirVer", MIRVER_UNKNOWN);
- SetContactBasicInfoW(hContact, SCBIFSI_LOCK_CHANGES_EVENTS, (SCBIF_ID|SCBIF_GROUP_ID|SCBIF_SERVER_FLAG|SCBIF_STATUS|SCBIF_EMAIL), -1, -1, 0, CONTACT_INTFLAG_NOT_AUTHORIZED, ID_STATUS_OFFLINE, szEmail, L"", "");
+ SetContactBasicInfoW(hContact, SCBIFSI_LOCK_CHANGES_EVENTS, (SCBIF_ID|SCBIF_GROUP_ID|SCBIF_SERVER_FLAG|SCBIF_STATUS|SCBIF_EMAIL), -1, -1, 0, CONTACT_INTFLAG_NOT_AUTHORIZED, ID_STATUS_OFFLINE, &szEmail, 0, 0);
}
}
}
diff --git a/protocols/MRA/src/Mra_proto.cpp b/protocols/MRA/src/Mra_proto.cpp index 26f1aceb66..7a3cadef80 100644 --- a/protocols/MRA/src/Mra_proto.cpp +++ b/protocols/MRA/src/Mra_proto.cpp @@ -622,7 +622,7 @@ bool CMraProto::CmdAuthAck(BinBuffer &buf) DWORD dwTemp;
GetContactBasicInfoW(hContact, NULL, NULL, NULL, &dwTemp, NULL, NULL, NULL, NULL);
dwTemp &= ~CONTACT_INTFLAG_NOT_AUTHORIZED;
- SetContactBasicInfoW(hContact, SCBIFSI_LOCK_CHANGES_EVENTS, SCBIF_SERVER_FLAG, 0, 0, 0, dwTemp, 0, "", L"", "");
+ SetContactBasicInfoW(hContact, SCBIFSI_LOCK_CHANGES_EVENTS, SCBIF_SERVER_FLAG, 0, 0, 0, dwTemp, 0, 0, 0, 0);
setDword(hContact, "HooksLocked", TRUE);
db_unset(hContact, "CList", "NotOnList");
setDword(hContact, "HooksLocked", FALSE);
@@ -763,7 +763,7 @@ bool CMraProto::CmdContactAck(int cmd, int seq, BinBuffer &buf) case CONTACT_OPER_SUCCESS:// ## добавление произведено успешно
buf >> dwTemp;
if (cmd == MRIM_CS_ADD_CONTACT_ACK)
- SetContactBasicInfoW(hContact, 0, (SCBIF_ID|SCBIF_SERVER_FLAG), dwTemp, 0, 0, CONTACT_INTFLAG_NOT_AUTHORIZED, 0, "", L"", "");
+ SetContactBasicInfoW(hContact, 0, (SCBIF_ID|SCBIF_SERVER_FLAG), dwTemp, 0, 0, CONTACT_INTFLAG_NOT_AUTHORIZED, 0, 0, 0, 0);
break;
case CONTACT_OPER_ERROR:// ## переданные данные были некорректны
ShowFormattedErrorMessage(L"Data been sent are invalid", NO_ERROR);
@@ -772,7 +772,7 @@ bool CMraProto::CmdContactAck(int cmd, int seq, BinBuffer &buf) ShowFormattedErrorMessage(L"Internal server error", NO_ERROR);
break;
case CONTACT_OPER_NO_SUCH_USER:// ## добавляемого пользователя не существует в системе
- SetContactBasicInfoW(hContact, 0, SCBIF_SERVER_FLAG, 0, 0, 0, -1, 0, "", L"", "");
+ SetContactBasicInfoW(hContact, 0, SCBIF_SERVER_FLAG, 0, 0, 0, -1, 0, 0, 0, 0);
ShowFormattedErrorMessage(L"User does not registred", NO_ERROR);
break;
case CONTACT_OPER_INVALID_INFO:// ## некорректное имя пользователя
@@ -807,7 +807,7 @@ bool CMraProto::CmdAnketaInfo(int seq, BinBuffer &buf) DWORD dwTemp; buf >> dwTemp;
switch(dwTemp) {
case MRIM_ANKETA_INFO_STATUS_NOUSER:// не найдено ни одной подходящей записи
- SetContactBasicInfoW(hContact, 0, SCBIF_SERVER_FLAG, 0, 0, 0, -1, 0, "", L"", "");
+ SetContactBasicInfoW(hContact, 0, SCBIF_SERVER_FLAG, 0, 0, 0, -1, 0, 0, 0, 0);
case MRIM_ANKETA_INFO_STATUS_DBERR:// ошибка базы данных
case MRIM_ANKETA_INFO_STATUS_RATELIMERR:// слишком много запросов, поиск временно запрещен
switch (dwAckType) {
@@ -1261,8 +1261,9 @@ bool CMraProto::CmdClist2(BinBuffer &buf) else {
if (szContactMask[j] == 's') {
buf >> szString;
- if (szString.GetLength())
+ if (szString.GetLength()) {
DebugPrintCRLFA(szString);
+ }
}
else if (szContactMask[j] == 'u') {
mir_snprintf(szBuff, SIZEOF(szBuff), "%lu, ", dwTemp);//;
@@ -1315,13 +1316,13 @@ bool CMraProto::CmdClist2(BinBuffer &buf) 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),
- dwID, dwGroupID, dwContactFlag, dwContactSeverFlags, dwTemp, "", wszNick, szCustomPhones);
+ dwID, dwGroupID, dwContactFlag, dwContactSeverFlags, dwTemp, NULL, &wszNick, &szCustomPhones);
// request user info from server
MraUpdateContactInfo(hContact);
}
else { //****deb - check group ID param
SetContactBasicInfoW(hContact, SCBIFSI_LOCK_CHANGES_EVENTS, (SCBIF_ID|SCBIF_GROUP_ID|SCBIF_SERVER_FLAG|SCBIF_STATUS),
- dwID, dwGroupID, dwContactFlag, dwContactSeverFlags, dwTemp, "", wszNick, szCustomPhones);
+ 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);
@@ -1396,7 +1397,7 @@ bool CMraProto::CmdClist2(BinBuffer &buf) // всех в offline и id в нестандарт
for (HANDLE hContact = db_find_first();hContact != NULL;hContact = db_find_next(hContact)) {
SetContactBasicInfoW(hContact, SCBIFSI_LOCK_CHANGES_EVENTS, (SCBIF_ID|SCBIF_GROUP_ID|SCBIF_SERVER_FLAG|SCBIF_STATUS),
- -1, -2, 0, 0, ID_STATUS_OFFLINE, "", L"", "");
+ -1, -2, 0, 0, ID_STATUS_OFFLINE, 0, 0, 0);
// request user info from server
MraUpdateContactInfo(hContact);
}
|