diff options
author | George Hazan <george.hazan@gmail.com> | 2015-02-08 13:30:36 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-02-08 13:30:36 +0000 |
commit | 149298bd03dcfce00815d798c9f670e8ea24e7e0 (patch) | |
tree | f9fa1a9215fca876599e465e278afaa21b22d73e /protocols | |
parent | 8be3a7a616f0739959fb0d4f5266973510bd4142 (diff) |
support for private messages in chats
git-svn-id: http://svn.miranda-ng.org/main/trunk@12055 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/WhatsApp/src/chat.cpp | 24 | ||||
-rw-r--r-- | protocols/WhatsApp/src/contacts.cpp | 5 | ||||
-rw-r--r-- | protocols/WhatsApp/src/proto.cpp | 6 | ||||
-rw-r--r-- | protocols/WhatsApp/src/proto.h | 1 | ||||
-rw-r--r-- | protocols/WhatsApp/src/version.h | 2 |
5 files changed, 25 insertions, 13 deletions
diff --git a/protocols/WhatsApp/src/chat.cpp b/protocols/WhatsApp/src/chat.cpp index 28f0629f9b..c34f9e8e1b 100644 --- a/protocols/WhatsApp/src/chat.cpp +++ b/protocols/WhatsApp/src/chat.cpp @@ -49,10 +49,6 @@ int WhatsAppProto::onGroupChatEvent(WPARAM wParam, LPARAM lParam) return 0;
switch (gch->pDest->iType) {
- case GC_USER_LEAVE:
- case GC_SESSION_TERMINATE:
- break;
-
case GC_USER_LOGMENU:
ChatLogMenuHook(pInfo, gch);
break;
@@ -80,6 +76,20 @@ int WhatsAppProto::onGroupChatEvent(WPARAM wParam, LPARAM lParam) CODE_BLOCK_CATCH_ALL
}
break;
+
+ case GC_USER_PRIVMESS:
+ string jid = string(_T2A(gch->ptszUID)) + "@s.whatsapp.net";
+ MCONTACT hContact = ContactIDToHContact(jid);
+ if (hContact == 0) {
+ hContact = AddToContactList(jid, (char*)_T2A(gch->ptszUID));
+ setWord(hContact, "Status", ID_STATUS_ONLINE);
+
+ db_set_b(hContact, "CList", "Hidden", 1);
+ setTString(hContact, "Nick", gch->ptszUID);
+ db_set_dw(hContact, "Ignore", "Mask1", 0);
+ }
+ CallService(MS_MSG_SENDMESSAGE, hContact, 0);
+ break;
}
return 0;
@@ -160,7 +170,7 @@ void WhatsAppProto::InviteChatUser(WAChatInfo *pInfo) /////////////////////////////////////////////////////////////////////////////////////////
// nicklist menu event handler
-static gc_item sttListItems[] =
+static gc_item sttNickListItems[] =
{
{ LPGENT("&Add to roster"), IDM_ADD_RJID, MENU_POPUPITEM },
{ NULL, 0, MENU_SEPARATOR },
@@ -239,8 +249,8 @@ int WhatsAppProto::OnChatMenu(WPARAM wParam, LPARAM lParam) gcmi->Item = sttLogListItems;
}
else if (gcmi->Type == MENU_ON_NICKLIST) {
- gcmi->nItems = SIZEOF(sttListItems);
- gcmi->Item = sttListItems;
+ gcmi->nItems = SIZEOF(sttNickListItems);
+ gcmi->Item = sttNickListItems;
}
return 0;
diff --git a/protocols/WhatsApp/src/contacts.cpp b/protocols/WhatsApp/src/contacts.cpp index e1a3a33bf1..d1146a5ca6 100644 --- a/protocols/WhatsApp/src/contacts.cpp +++ b/protocols/WhatsApp/src/contacts.cpp @@ -42,10 +42,7 @@ MCONTACT WhatsAppProto::AddToContactList(const std::string &jid, const char *new setString(hContact, "MirVer", "WhatsApp");
db_unset(hContact, "CList", "MyHandle");
db_set_b(hContact, "CList", "NotOnList", 1);
-
- ptrT tszGroup(getTStringA(WHATSAPP_KEY_DEF_GROUP));
- if (tszGroup)
- db_set_ts(hContact, "CList", "Group", tszGroup);
+ db_set_ts(hContact, "CList", "Group", m_defaultGroup);
if (new_name != NULL)
db_set_utf(hContact, m_szModuleName, WHATSAPP_KEY_NICK, new_name);
diff --git a/protocols/WhatsApp/src/proto.cpp b/protocols/WhatsApp/src/proto.cpp index ca412a77e8..c202503703 100644 --- a/protocols/WhatsApp/src/proto.cpp +++ b/protocols/WhatsApp/src/proto.cpp @@ -13,7 +13,8 @@ struct SearchParam };
WhatsAppProto::WhatsAppProto(const char* proto_name, const TCHAR* username) :
- PROTO<WhatsAppProto>(proto_name, username)
+ PROTO<WhatsAppProto>(proto_name, username),
+ m_defaultGroup(getTStringA(WHATSAPP_KEY_DEF_GROUP))
{
update_loop_lock_ = CreateEvent(NULL, false, false, NULL);
@@ -49,6 +50,9 @@ WhatsAppProto::WhatsAppProto(const char* proto_name, const TCHAR* username) : if (dwAttributes == 0xffffffff || (dwAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
CreateDirectoryTreeT(m_tszAvatarFolder.c_str());
+ if (m_defaultGroup == NULL)
+ m_defaultGroup = mir_tstrdup(_T("WhatsApp"));
+
SetAllContactStatuses(ID_STATUS_OFFLINE, true);
}
diff --git a/protocols/WhatsApp/src/proto.h b/protocols/WhatsApp/src/proto.h index b07d8aed87..8702f2c060 100644 --- a/protocols/WhatsApp/src/proto.h +++ b/protocols/WhatsApp/src/proto.h @@ -172,6 +172,7 @@ private: WAConnection *m_pConnection;
Mutex connMutex;
time_t m_tLastWriteTime;
+ ptrT m_defaultGroup;
std::vector<unsigned char> m_Challenge;
std::string m_szPhoneNumber;
diff --git a/protocols/WhatsApp/src/version.h b/protocols/WhatsApp/src/version.h index 6f591420cd..3475fe9955 100644 --- a/protocols/WhatsApp/src/version.h +++ b/protocols/WhatsApp/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 1
#define __RELEASE_NUM 2
-#define __BUILD_NUM 7
+#define __BUILD_NUM 8
#include <stdver.h>
|