diff options
author | George Hazan <ghazan@miranda.im> | 2018-12-08 18:35:02 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-12-08 18:35:02 +0300 |
commit | 0b084cff5bb71a140d5181caa452a95b74ac8103 (patch) | |
tree | b0394812fbed52040485f90a1815892ad4f565fa /src/mir_app | |
parent | 7f1f391faf93d216bfe651131a95d70961f8ffa2 (diff) |
chats:
- Chat_GetGroup & Chat_SetGroup functions added to stop the zoo with chat default group name;
- fixes #1655 (custom chat group name doesn't work in Discord)
Diffstat (limited to 'src/mir_app')
-rw-r--r-- | src/mir_app/src/chat_clist.cpp | 26 | ||||
-rw-r--r-- | src/mir_app/src/chat_tools.cpp | 16 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 2 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 2 |
4 files changed, 30 insertions, 16 deletions
diff --git a/src/mir_app/src/chat_clist.cpp b/src/mir_app/src/chat_clist.cpp index 2c6b74cf1f..43944f535b 100644 --- a/src/mir_app/src/chat_clist.cpp +++ b/src/mir_app/src/chat_clist.cpp @@ -24,28 +24,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. MCONTACT AddRoom(const char *pszModule, const wchar_t *pszRoom, const wchar_t *pszDisplayName, int iType)
{
- wchar_t pszGroup[50]; *pszGroup = '\0';
- ptrW groupName(db_get_wsa(0, CHAT_MODULE, "AddToGroup"));
- if (groupName)
- wcsncpy_s(pszGroup, groupName, _TRUNCATE);
- else
- mir_wstrcpy(pszGroup, L"Chat rooms");
-
- if (pszGroup[0]) {
- MGROUP hGroup = Clist_GroupExists(pszGroup);
+ ptrW wszGroup(Chat_GetGroup());
+ if (mir_wstrlen(wszGroup)) {
+ MGROUP hGroup = Clist_GroupExists(wszGroup);
if (hGroup == 0) {
- hGroup = Clist_GroupCreate(0, pszGroup);
+ hGroup = Clist_GroupCreate(0, wszGroup);
if (hGroup)
Clist_GroupSetExpanded(hGroup, 1);
}
}
MCONTACT hContact = g_chatApi.FindRoom(pszModule, pszRoom);
- if (hContact) { //contact exist, make sure it is in the right group
- if (pszGroup[0]) {
+ if (hContact) { // contact exist, make sure it is in the right group
+ if (mir_wstrlen(wszGroup)) {
ptrW grpName(db_get_wsa(hContact, "CList", "Group"));
- if (!mir_wstrcmp(pszGroup, grpName))
- db_set_ws(hContact, "CList", "Group", pszGroup);
+ if (!mir_wstrcmp(wszGroup, grpName))
+ db_set_ws(hContact, "CList", "Group", wszGroup);
}
db_set_w(hContact, pszModule, "Status", ID_STATUS_OFFLINE);
@@ -58,8 +52,8 @@ MCONTACT AddRoom(const char *pszModule, const wchar_t *pszRoom, const wchar_t *p return 0;
Proto_AddToContact(hContact, pszModule);
- if (pszGroup[0])
- db_set_ws(hContact, "CList", "Group", pszGroup);
+ if (mir_wstrlen(wszGroup))
+ db_set_ws(hContact, "CList", "Group", wszGroup);
else
db_unset(hContact, "CList", "Group");
db_set_ws(hContact, pszModule, "Nick", pszDisplayName);
diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp index 8bc297ec50..deba485f86 100644 --- a/src/mir_app/src/chat_tools.cpp +++ b/src/mir_app/src/chat_tools.cpp @@ -685,6 +685,22 @@ wchar_t* GetChatLogsFilename(SESSION_INFO *si, time_t tTime) /////////////////////////////////////////////////////////////////////////////////////////
+MIR_APP_DLL(wchar_t*) Chat_GetGroup()
+{
+ ptrW pszGroup(db_get_wsa(0, CHAT_MODULE, "AddToGroup"));
+ return (pszGroup) ? pszGroup.detach() : mir_wstrdup(TranslateT("Chat rooms"));
+}
+
+MIR_APP_DLL(void) Chat_SetGroup(const wchar_t *pwszGroupName)
+{
+ if (mir_wstrlen(pwszGroupName))
+ db_set_ws(0, CHAT_MODULE, "AddToGroup", pwszGroupName);
+ else
+ db_unset(0, CHAT_MODULE, "AddToGroup");
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
MIR_APP_DLL(wchar_t*) Chat_UnescapeTags(wchar_t *str_in)
{
wchar_t *s = str_in, *d = str_in;
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index f758a80cce..e3be5f3916 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -669,3 +669,5 @@ g_hevSettingChanged @696 NONAME ?getMe@GCSessionInfoBase@@QBEPAUUSERINFO@@XZ @702 NONAME
?MetaRemoveSubHistory@MDatabaseCommon@@UAGHPAUDBCachedContact@@@Z @703 NONAME
?MetaRemoveSubHistory@MDatabaseReadonly@@UAGHPAUDBCachedContact@@@Z @704 NONAME
+Chat_GetGroup @705
+Chat_SetGroup @706
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 55a947a380..bb0746bc4e 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -669,3 +669,5 @@ g_hevSettingChanged @696 NONAME ?getMe@GCSessionInfoBase@@QEBAPEAUUSERINFO@@XZ @702 NONAME
?MetaRemoveSubHistory@MDatabaseCommon@@UEAAHPEAUDBCachedContact@@@Z @703 NONAME
?MetaRemoveSubHistory@MDatabaseReadonly@@UEAAHPEAUDBCachedContact@@@Z @704 NONAME
+Chat_GetGroup @705
+Chat_SetGroup @706
|