diff options
-rw-r--r-- | include/m_contacts.h | 5 | ||||
-rw-r--r-- | libs/win32/mir_app.lib | bin | 302284 -> 302564 bytes | |||
-rw-r--r-- | libs/win64/mir_app.lib | bin | 302356 -> 302636 bytes | |||
-rw-r--r-- | protocols/JabberG/src/jabber_iqid.cpp | 12 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_contacts.cpp | 7 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_profile.cpp | 5 | ||||
-rw-r--r-- | protocols/Telegram/src/proto.cpp | 12 | ||||
-rw-r--r-- | protocols/Telegram/src/proto.h | 1 | ||||
-rw-r--r-- | protocols/Telegram/src/server.cpp | 7 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_thread.cpp | 8 | ||||
-rw-r--r-- | src/mir_app/src/clistcontacts.cpp | 20 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 1 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 1 |
13 files changed, 49 insertions, 30 deletions
diff --git a/include/m_contacts.h b/include/m_contacts.h index ff5c4873e9..f2fc4fa665 100644 --- a/include/m_contacts.h +++ b/include/m_contacts.h @@ -102,6 +102,11 @@ namespace Contact MIR_APP_DLL(void) Readonly(MCONTACT hContact, bool bReadOnly = true);
/////////////////////////////////////////////////////////////////////////////////////////
+ // sets a birthday
+
+ MIR_APP_DLL(void) SetBirthday(MCONTACT hContact, int dd, int mm, int yy);
+
+ /////////////////////////////////////////////////////////////////////////////////////////
// checks / adds / removes a contact from list of contacts
// removed contacts would be physically deleted after restart
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib Binary files differindex cd7f77bc00..f64c48e8a2 100644 --- a/libs/win32/mir_app.lib +++ b/libs/win32/mir_app.lib diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib Binary files differindex c220916ef0..9af7b02a6f 100644 --- a/libs/win64/mir_app.lib +++ b/libs/win64/mir_app.lib diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp index 5e0a2b47ed..431f9d26a0 100644 --- a/protocols/JabberG/src/jabber_iqid.cpp +++ b/protocols/JabberG/src/jabber_iqid.cpp @@ -760,17 +760,7 @@ void CJabberProto::OnIqResultGetVcard(const TiXmlElement *iqNode, CJabberIqInfo* if (hContact != 0) {
if (sscanf(n->GetText(), "%d-%d-%d", &nYear, &nMonth, &nDay) == 3) {
hasBday = true;
- setWord(hContact, "BirthYear", (uint16_t)nYear);
- setByte(hContact, "BirthMonth", (uint8_t)nMonth);
- setByte(hContact, "BirthDay", (uint8_t)nDay);
-
- SYSTEMTIME sToday = { 0 };
- GetLocalTime(&sToday);
- int nAge = sToday.wYear - nYear;
- if (sToday.wMonth < nMonth || (sToday.wMonth == nMonth && sToday.wDay < nDay))
- nAge--;
- if (nAge)
- setWord(hContact, "Age", (uint16_t)nAge);
+ Contact::SetBirthday(hContact, nDay, nMonth, nYear);
}
}
else {
diff --git a/protocols/SkypeWeb/src/skype_contacts.cpp b/protocols/SkypeWeb/src/skype_contacts.cpp index a96a25262d..daed188bb2 100644 --- a/protocols/SkypeWeb/src/skype_contacts.cpp +++ b/protocols/SkypeWeb/src/skype_contacts.cpp @@ -189,11 +189,8 @@ void CSkypeProto::LoadContactList(MHttpResponse *response, AsyncHttpRequest*) auto wstr = profile["birthday"].as_mstring();
if (!wstr.IsEmpty() ) {
int nYear, nMonth, nDay;
- if (swscanf(wstr, L"%d-%d-%d", &nYear, &nMonth, &nDay) == 3) {
- setWord(hContact, "BirthYear", nYear);
- setByte(hContact, "BirthMonth", nMonth);
- setByte(hContact, "BirthDay", nDay);
- }
+ if (swscanf(wstr, L"%d-%d-%d", &nYear, &nMonth, &nDay) == 3)
+ Contact::SetBirthday(hContact, nDay, nMonth, nYear);
}
wstr = profile["gender"].as_mstring();
diff --git a/protocols/SkypeWeb/src/skype_profile.cpp b/protocols/SkypeWeb/src/skype_profile.cpp index f6ca94ef30..5bfcd49513 100644 --- a/protocols/SkypeWeb/src/skype_profile.cpp +++ b/protocols/SkypeWeb/src/skype_profile.cpp @@ -50,9 +50,8 @@ void CSkypeProto::UpdateProfileBirthday(const JSONNode &root, MCONTACT hContact) if (!birthday.IsEmpty() && birthday != "null") {
int d, m, y;
if (3 == swscanf(birthday.GetBuffer(), L"%d-%d-%d", &y, &m, &d)) {
- setWord(hContact, "BirthYear", y);
- setByte(hContact, "BirthDay", d);
- setByte(hContact, "BirthMonth", m);
+ Contact::SetBirthday(hContact, d, m, y);
+ return;
}
}
diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp index 3732e1a5e5..327cc9a090 100644 --- a/protocols/Telegram/src/proto.cpp +++ b/protocols/Telegram/src/proto.cpp @@ -635,6 +635,11 @@ HANDLE CTelegramProto::SendFile(MCONTACT hContact, const wchar_t *szDescription, ///////////////////////////////////////////////////////////////////////////////////////// +void CTelegramProto::OnChatCreated(td::ClientManager::Response &response, void *pUserInfo) +{ + SetEvent(pUserInfo); +} + int CTelegramProto::SendMsg(MCONTACT hContact, MEVENT hReplyEvent, const char *pszMessage) { ptrA szId(getStringA(hContact, DBKEY_ID)); @@ -653,6 +658,13 @@ int CTelegramProto::SendMsg(MCONTACT hContact, MEVENT hReplyEvent, const char *p iReplyId = dbei2id(dbei); } + if (pUser->chatId == -1) { + HANDLE hEvent = ::CreateEvent(0, TRUE, FALSE, 0); + SendQuery(new TD::createNewPrivateChat(pUser->id, false), &CTelegramProto::OnChatCreated, hEvent); + WaitForSingleObject(hEvent, INFINITE); + CloseHandle(hEvent); + } + int msgid = SendTextMessage(pUser->chatId, 0, iReplyId, pszMessage); if (msgid != -1) m_arOwnMsg.insert(new TG_OWN_MESSAGE(hContact, (HANDLE)msgid, "")); diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h index 29cc8b3654..c8a607eccc 100644 --- a/protocols/Telegram/src/proto.h +++ b/protocols/Telegram/src/proto.h @@ -233,6 +233,7 @@ class CTelegramProto : public PROTO<CTelegramProto> } void OnAvatarSet(td::ClientManager::Response &response, void *pUserInfo); + void OnChatCreated(td::ClientManager::Response &response, void *pUserInfo); void OnEndSession(td::ClientManager::Response &response); void OnGetFileInfo(td::ClientManager::Response &response, void *pUserInfo); void OnGetFileLink(td::ClientManager::Response &response); diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp index 20d55e04a9..fdec9f3046 100644 --- a/protocols/Telegram/src/server.cpp +++ b/protocols/Telegram/src/server.cpp @@ -1328,11 +1328,8 @@ void CTelegramProto::ProcessUser(TD::updateUser *pObj) void CTelegramProto::ProcessUserInfo(TD::int53 userId, TD::userFullInfo *pObj)
{
if (auto *pUser = FindUser(userId)) {
- if (auto *pBirthday = pObj->birthdate_.get()) {
- setWord(pUser->hContact, "BirthDay", pBirthday->day_);
- setWord(pUser->hContact, "BirthMonth", pBirthday->month_);
- setWord(pUser->hContact, "BirthYear", pBirthday->year_);
- }
+ if (auto *pBirthday = pObj->birthdate_.get())
+ Contact::SetBirthday(pUser->hContact, pBirthday->day_, pBirthday->month_, pBirthday->year_);
if (pObj->bio_) {
CMStringA szNotes(GetFormattedText(pObj->bio_));
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index ba92c7ff06..890701e068 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -368,12 +368,8 @@ MCONTACT CVkProto::SetContactInfo(const JSONNode &jnItem, bool bFlag, VKContactT if (!wszValue.IsEmpty()) {
int d, m, y, iReadCount;
iReadCount = swscanf(wszValue, L"%d.%d.%d", &d, &m, &y);
- if (iReadCount > 1) {
- if (iReadCount == 3)
- setWord(hContact, "BirthYear", y);
- setByte(hContact, "BirthDay", d);
- setByte(hContact, "BirthMonth", m);
- }
+ if (iReadCount > 1)
+ Contact::SetBirthday(hContact, d, m, (iReadCount == 3) ? y : 0);
}
wszValue = jnItem["photo_100"].as_mstring();
diff --git a/src/mir_app/src/clistcontacts.cpp b/src/mir_app/src/clistcontacts.cpp index 759bce6f52..77fefe36af 100644 --- a/src/mir_app/src/clistcontacts.cpp +++ b/src/mir_app/src/clistcontacts.cpp @@ -296,6 +296,26 @@ MIR_APP_DLL(bool) Contact::IsGroupChat(MCONTACT hContact, const char *szProto) return db_get_b(hContact, szProto, "ChatRoom") != 0; } +MIR_APP_DLL(void) Contact::SetBirthday(MCONTACT hContact, int dd, int mm, int yy) +{ + if (auto *szProto = Proto_GetBaseAccountName(hContact)) { + db_set_w(hContact, szProto, "BirthMonth", mm); + db_set_w(hContact, szProto, "BirthDay", dd); + + if (yy) { + db_set_w(hContact, szProto, "BirthYear", yy); + + SYSTEMTIME sToday = {}; + GetLocalTime(&sToday); + int nAge = sToday.wYear - yy; + if (sToday.wMonth < mm || (sToday.wMonth == mm && sToday.wDay < dd)) + nAge--; + if (nAge) + db_set_w(hContact, szProto, "Age", nAge); + } + } +} + /////////////////////////////////////////////////////////////////////////////// MIR_APP_DLL(bool) Contact::IsHidden(MCONTACT hContact) diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index f38c665f8b..1dd24ecab3 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -997,3 +997,4 @@ Proto_CanDeleteHistory @1118 NONAME ?iHistoryMode@Srmm@@3V?$CMOption@E@@A @1128 NONAME
?getConn@MWebSocket@@QBEPAXXZ @1129 NONAME
?Chat_GetStatus@@YGPAUSTATUSINFO@@PAUSESSION_INFO@@PBUUSERINFO@@@Z @1130 NONAME
+?SetBirthday@Contact@@YGXIHHH@Z @1131 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 54d6d48c19..5e7b681246 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -997,3 +997,4 @@ Proto_CanDeleteHistory @1118 NONAME ?iHistoryMode@Srmm@@3V?$CMOption@E@@A @1128 NONAME
?getConn@MWebSocket@@QEBAPEAXXZ @1129 NONAME
?Chat_GetStatus@@YAPEAUSTATUSINFO@@PEAUSESSION_INFO@@PEBUUSERINFO@@@Z @1130 NONAME
+?SetBirthday@Contact@@YAXIHHH@Z @1131 NONAME
|