diff options
author | Sergey Bolhovskoy <elzorfox@ya.ru> | 2016-04-17 16:33:32 +0000 |
---|---|---|
committer | Sergey Bolhovskoy <elzorfox@ya.ru> | 2016-04-17 16:33:32 +0000 |
commit | cebf5d329dcf0a441350a505882382a7094c0f3e (patch) | |
tree | 05a6bfae4e728e66ee3abb03e630544e1b3a975b /protocols | |
parent | 55b1f7fafef7085638c4c8604b248bbe9fe08124 (diff) |
VKontakte:
add change nick in muc support
version bump
git-svn-id: http://svn.miranda-ng.org/main/trunk@16698 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/VKontakte/src/misc.cpp | 12 | ||||
-rw-r--r-- | protocols/VKontakte/src/version.h | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_chats.cpp | 41 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 1 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_struct.h | 1 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_thread.cpp | 2 |
6 files changed, 51 insertions, 8 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index bc1bcbe504..3012278540 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -420,6 +420,18 @@ CMString CVkProto::RunConfirmationCode() return (!EnterString(&pForm)) ? CMString() : CMString(ptrT(pForm.ptszResult));
}
+CMString CVkProto::RunRenameNick(LPCTSTR ptszOldName)
+{
+ ENTER_STRING pForm = { sizeof(pForm) };
+ pForm.type = ESF_COMBO;
+ pForm.recentCount = 0;
+ pForm.caption = TranslateT("Enter new nickname");
+ pForm.ptszInitVal = ptszOldName;
+ pForm.szModuleName = m_szModuleName;
+ pForm.szDataPrefix = "renamenick_";
+ return (!EnterString(&pForm)) ? CMString() : CMString(ptrT(pForm.ptszResult));
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
void CVkProto::GrabCookies(NETLIBHTTPREQUEST *nhr)
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index 90d20a508a..283bf323fb 100644 --- a/protocols/VKontakte/src/version.h +++ b/protocols/VKontakte/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 1
#define __RELEASE_NUM 1
-#define __BUILD_NUM 27
+#define __BUILD_NUM 28
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp index 2957f8272c..b668ab2913 100644 --- a/protocols/VKontakte/src/vk_chats.cpp +++ b/protocols/VKontakte/src/vk_chats.cpp @@ -21,7 +21,7 @@ enum {
IDM_NONE,
IDM_TOPIC, IDM_INVITE, IDM_DESTROY,
- IDM_KICK, IDM_INFO, IDM_VISIT_PROFILE
+ IDM_KICK, IDM_INFO, IDM_CHANGENICK, IDM_VISIT_PROFILE
};
static LPCTSTR sttStatuses[] = { LPGENT("Participants"), LPGENT("Owners") };
@@ -183,9 +183,12 @@ void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe bNew = cu->m_bUnknown;
cu->m_bDel = false;
- CMString fName(jnUser["first_name"].as_mstring());
- CMString lName(jnUser["last_name"].as_mstring());
- CMString tszNick = fName.Trim() + _T(" ") + lName.Trim();
+ CMString tszNick(ptrT(db_get_tsa(cc->m_hContact, m_szModuleName, CMStringA(FORMAT, "nick%d", cu->m_uid))));
+ if (tszNick.IsEmpty()) {
+ CMString fName(jnUser["first_name"].as_mstring());
+ CMString lName(jnUser["last_name"].as_mstring());
+ tszNick = fName.Trim() + _T(" ") + lName.Trim();
+ }
cu->m_tszNick = mir_tstrdup(tszNick);
cu->m_bUnknown = false;
@@ -416,7 +419,8 @@ void CVkProto::AppendChatMessage(CVkChatInfo *cc, int uid, int msgTime, LPCTSTR CVkChatUser *cu = cc->m_users.find((CVkChatUser*)&uid);
if (cu == NULL) {
cc->m_users.insert(cu = new CVkChatUser(uid));
- cu->m_tszNick = mir_tstrdup(hContact ? ptrT(db_get_tsa(hContact, m_szModuleName, "Nick")) : TranslateT("Unknown"));
+ CMString tszNick(ptrT(db_get_tsa(cc->m_hContact, m_szModuleName, CMStringA(FORMAT, "nick%d", cu->m_uid))));
+ cu->m_tszNick = mir_tstrdup(tszNick.IsEmpty() ? (hContact ? ptrT(db_get_tsa(hContact, m_szModuleName, "Nick")) : TranslateT("Unknown")) : tszNick);
cu->m_bUnknown = true;
}
@@ -783,6 +787,31 @@ void CVkProto::NickMenuHook(CVkChatInfo *cc, GCHOOK *gch) SvcVisitProfile(hContact, 0);
break;
+ case IDM_CHANGENICK:
+ {
+ CMString tszNewNick = RunRenameNick(cu->m_tszNick);
+ if (tszNewNick.IsEmpty() || tszNewNick == cu->m_tszNick)
+ break;
+
+ GCDEST gcd = { m_szModuleName, cc->m_tszId, GC_EVENT_NICK };
+ GCEVENT gce = { sizeof(GCEVENT), &gcd };
+
+ TCHAR tszId[20];
+ _itot(cu->m_uid, tszId, 10);
+
+ gce.ptszNick = mir_tstrdup(cu->m_tszNick);
+ gce.bIsMe = (cu->m_uid == m_myUserId);
+ gce.ptszUID = tszId;
+ gce.ptszText = mir_tstrdup(tszNewNick);
+ gce.dwFlags = GCEF_ADDTOLOG;
+ gce.time = time(NULL);
+ CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
+
+ cu->m_tszNick = mir_tstrdup(tszNewNick);
+ setTString(cc->m_hContact, CMStringA(FORMAT, "nick%d", cu->m_uid), tszNewNick);
+ }
+ break;
+
case IDM_KICK:
if (!IsOnline())
return;
@@ -791,6 +820,7 @@ void CVkProto::NickMenuHook(CVkChatInfo *cc, GCHOOK *gch) << INT_PARAM("chat_id", cc->m_chatid)
<< INT_PARAM("user_id", cu->m_uid));
cu->m_bUnknown = true;
+
break;
}
}
@@ -809,6 +839,7 @@ static gc_item sttListItems[] = {
{ LPGENT("&User details"), IDM_INFO, MENU_ITEM },
{ LPGENT("Visit profile"), IDM_VISIT_PROFILE, MENU_ITEM },
+ { LPGENT("Change nick"), IDM_CHANGENICK, MENU_ITEM },
{ LPGENT("&Kick"), IDM_KICK, MENU_ITEM }
};
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index dea5af4195..ecd9dd6869 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -324,6 +324,7 @@ private: void OnReceiveSmth(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
bool AutoFillForm(char*, CMStringA&, CMStringA&);
CMString RunConfirmationCode();
+ CMString RunRenameNick(LPCTSTR ptszOldName);
void GrabCookies(NETLIBHTTPREQUEST *nhr);
void ApplyCookies(AsyncHttpRequest*);
void __cdecl DBAddAuthRequestThread(void *p);
diff --git a/protocols/VKontakte/src/vk_struct.h b/protocols/VKontakte/src/vk_struct.h index c373e40524..2f2116da87 100644 --- a/protocols/VKontakte/src/vk_struct.h +++ b/protocols/VKontakte/src/vk_struct.h @@ -341,7 +341,6 @@ struct CVKOptions { CMOption<TCHAR*> ptszReturnChatMessage;
CMOption<TCHAR*> ptszVKLang;
-
CVKOptions(PROTO_INTERFACE *proto);
__forceinline BBCSupport BBCForNews() { return (BBCSupport)(BYTE)iBBCForNews; };
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index 4915f4a283..3e51da9baa 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -221,7 +221,7 @@ void CVkProto::OnOAuthAuthorize(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq void CVkProto::RetrieveMyInfo()
{
debugLogA("CVkProto::RetrieveMyInfo");
- Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/users.get.json", true, &CVkProto::OnReceiveMyInfo,AsyncHttpRequest::rpHigh));
+ Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/users.get.json", true, &CVkProto::OnReceiveMyInfo, AsyncHttpRequest::rpHigh));
}
void CVkProto::OnReceiveMyInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
|