diff options
-rw-r--r-- | protocols/SkypeWeb/src/skype_chatrooms.cpp | 49 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/version.h | 2 |
2 files changed, 35 insertions, 16 deletions
diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp index 2e67171846..a254720323 100644 --- a/protocols/SkypeWeb/src/skype_chatrooms.cpp +++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp @@ -210,29 +210,48 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam) SendRequest(new InviteUserToChatRequest(chat_id, user_id, "User", li));
break;
case 50:
+ ptrW tnick_old(GetChatContactNick(chat_id, _T2A(gch->ptszUID), _T2A(gch->ptszText)));
ENTER_STRING pForm = { sizeof(pForm) };
pForm.type = ESF_COMBO;
pForm.recentCount = 0;
pForm.caption = TranslateT("Enter new nickname");
- pForm.ptszInitVal = gch->ptszUID;
+ pForm.ptszInitVal = tnick_old;
pForm.szModuleName = m_szModuleName;
pForm.szDataPrefix = "renamenick_";
- GCDEST gcd = { m_szModuleName, gch->ptszUID, GC_EVENT_NICK };
- GCEVENT gce = { sizeof(GCEVENT), &gcd };
-
- EnterString(&pForm);
-
- gce.ptszNick = gch->ptszUID;
- gce.bIsMe = IsMe(user_id);
- gce.ptszUID = gch->ptszUID;
- gce.ptszText = pForm.ptszResult;
- gce.dwFlags = GCEF_ADDTOLOG;
- gce.time = time(NULL);
- CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
-
- db_set_ws(FindChatRoom(chat_id), "UsersNicks", _T2A(gch->ptszUID), pForm.ptszResult);
+ if (EnterString(&pForm))
+ {
+ MCONTACT hChatContact = FindChatRoom(chat_id);
+ if (hChatContact == NULL)
+ break; // This probably shouldn't happen, but if chat is NULL for some reason, do nothing
+
+ ptrW tnick_new(pForm.ptszResult);
+ bool reset = (tnick_new == NULL || tnick_new[0] == '\0');
+ if (reset)
+ {
+ // User fill blank name, which means we reset the custom nick
+ db_unset(hChatContact, "UsersNicks", _T2A(gch->ptszUID));
+ tnick_new = GetChatContactNick(chat_id, _T2A(gch->ptszUID), _T2A(gch->ptszText));
+ }
+
+ if (!mir_wstrcmp(tnick_old, tnick_new))
+ break; // New nick is same, do nothing
+
+ GCDEST gcd = { m_szModuleName, gch->pDest->ptszID, GC_EVENT_NICK };
+ GCEVENT gce = { sizeof(GCEVENT), &gcd };
+
+ gce.ptszNick = tnick_old;
+ gce.bIsMe = IsMe(user_id);
+ gce.ptszUID = gch->ptszUID;
+ gce.ptszText = tnick_new;
+ gce.dwFlags = GCEF_ADDTOLOG;
+ gce.time = time(NULL);
+ CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
+
+ if (!reset)
+ db_set_ws(hChatContact, "UsersNicks", _T2A(gch->ptszUID), tnick_new);
+ }
break;
diff --git a/protocols/SkypeWeb/src/version.h b/protocols/SkypeWeb/src/version.h index 1ffd7b7600..f66e9decdd 100644 --- a/protocols/SkypeWeb/src/version.h +++ b/protocols/SkypeWeb/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 12
#define __RELEASE_NUM 2
-#define __BUILD_NUM 2
+#define __BUILD_NUM 3
#include <stdver.h>
|