summaryrefslogtreecommitdiff
path: root/protocols/WhatsApp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-02-10 08:04:30 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-02-10 08:04:30 +0000
commitddba4ede6b451d0cfcd0d32b5180fbd0689966bf (patch)
tree5d74f37a7013d13b92c182628d6b68a58e148ae4 /protocols/WhatsApp
parentc39340bf493a1745a41317bbf937fc7eb6cbb26a (diff)
- HANDLE hContact => HCONTACT
- GCF_* prefix was added to chat constants to avoid name conflicts git-svn-id: http://svn.miranda-ng.org/main/trunk@8078 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/WhatsApp')
-rw-r--r--protocols/WhatsApp/src/chat.cpp2
-rw-r--r--protocols/WhatsApp/src/contacts.cpp93
-rw-r--r--protocols/WhatsApp/src/entities.h8
-rw-r--r--protocols/WhatsApp/src/messages.cpp12
-rw-r--r--protocols/WhatsApp/src/proto.cpp10
-rw-r--r--protocols/WhatsApp/src/proto.h61
-rw-r--r--protocols/WhatsApp/src/theme.cpp18
7 files changed, 97 insertions, 107 deletions
diff --git a/protocols/WhatsApp/src/chat.cpp b/protocols/WhatsApp/src/chat.cpp
index 63551a953f..81fd154153 100644
--- a/protocols/WhatsApp/src/chat.cpp
+++ b/protocols/WhatsApp/src/chat.cpp
@@ -35,7 +35,7 @@ int WhatsAppProto::OnChatOutgoing(WPARAM wParam, LPARAM lParam)
mir_free(id);
if (isOnline()) {
- HANDLE hContact = this->ContactIDToHContact(chat_id);
+ HCONTACT hContact = this->ContactIDToHContact(chat_id);
if (hContact)
{
debugLogA("**Chat - Outgoing message: %s", text);
diff --git a/protocols/WhatsApp/src/contacts.cpp b/protocols/WhatsApp/src/contacts.cpp
index ead537fc1d..fb3a7bea5f 100644
--- a/protocols/WhatsApp/src/contacts.cpp
+++ b/protocols/WhatsApp/src/contacts.cpp
@@ -1,6 +1,6 @@
#include "common.h"
-bool WhatsAppProto::IsMyContact(HANDLE hContact, bool include_chat)
+bool WhatsAppProto::IsMyContact(HCONTACT hContact, bool include_chat)
{
const char *proto = GetContactProto(hContact);
if( proto && strcmp(m_szModuleName,proto) == 0 )
@@ -14,10 +14,10 @@ bool WhatsAppProto::IsMyContact(HANDLE hContact, bool include_chat)
return false;
}
-HANDLE WhatsAppProto::AddToContactList(const std::string& jid, BYTE type, bool dont_check, const char *new_name,
+HCONTACT WhatsAppProto::AddToContactList(const std::string& jid, BYTE type, bool dont_check, const char *new_name,
bool isChatRoom, bool isHidden)
{
- HANDLE hContact;
+ HCONTACT hContact;
if (!dont_check) {
// First, check if this contact exists
@@ -55,7 +55,7 @@ HANDLE WhatsAppProto::AddToContactList(const std::string& jid, BYTE type, bool d
}
// If not, make a new contact!
- hContact = (HANDLE)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ hContact = (HCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
if (hContact)
{
if (CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)m_szModuleName) == 0)
@@ -111,33 +111,28 @@ HANDLE WhatsAppProto::AddToContactList(const std::string& jid, BYTE type, bool d
else CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
}
- return INVALID_HANDLE_VALUE;
+ return (HCONTACT)INVALID_HANDLE_VALUE;
}
-HANDLE WhatsAppProto::ContactIDToHContact(const std::string& phoneNumber)
+HCONTACT WhatsAppProto::ContactIDToHContact(const std::string& phoneNumber)
{
// Cache
- std::map<string, HANDLE>::iterator it = this->hContactByJid.find(phoneNumber);
+ std::map<string, HCONTACT>::iterator it = this->hContactByJid.find(phoneNumber);
if (it != this->hContactByJid.end())
return it->second;
const char* idForContact = "ID";
const char* idForChat = "ChatRoomID";
- for(HANDLE hContact = db_find_first();
- hContact;
- hContact = db_find_next(hContact))
- {
- if(!IsMyContact(hContact, true))
+ for (HCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if (!IsMyContact(hContact, true))
continue;
const char* id = isChatRoom(hContact) ? idForChat : idForContact;
DBVARIANT dbv;
- if( !getString(hContact, id, &dbv))
- {
- if( strcmp(phoneNumber.c_str(),dbv.pszVal) == 0 )
- {
+ if (!getString(hContact, id, &dbv)) {
+ if (strcmp(phoneNumber.c_str(), dbv.pszVal) == 0) {
db_free(&dbv);
this->hContactByJid[phoneNumber] = hContact;
return hContact;
@@ -152,13 +147,10 @@ HANDLE WhatsAppProto::ContactIDToHContact(const std::string& phoneNumber)
void WhatsAppProto::SetAllContactStatuses(int status, bool reset_client)
{
- for (HANDLE hContact = db_find_first();
- hContact;
- hContact = db_find_next(hContact))
- {
+ for (HCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (!IsMyContact(hContact))
continue;
-
+
if (reset_client) {
DBVARIANT dbv;
if (!getTString(hContact, "MirVer", &dbv)) {
@@ -170,7 +162,7 @@ void WhatsAppProto::SetAllContactStatuses(int status, bool reset_client)
db_set_ws(hContact, "CList", "StatusMsg", _T(""));
}
- if (getWord(hContact, "Status",ID_STATUS_OFFLINE) != status)
+ if (getWord(hContact, "Status", ID_STATUS_OFFLINE) != status)
setWord(hContact, "Status", status);
}
}
@@ -179,7 +171,7 @@ void WhatsAppProto::ProcessBuddyList(void*)
{
std::vector<std::string> jids;
DBVARIANT dbv;
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ for (HCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (!IsMyContact(hContact))
continue;
@@ -227,7 +219,7 @@ void WhatsAppProto::SearchAckThread(void *targ)
void WhatsAppProto::onAvailable(const std::string& paramString, bool paramBoolean)
{
- HANDLE hContact = this->AddToContactList(paramString, 0, false);
+ HCONTACT hContact = this->AddToContactList(paramString, 0, false);
if (hContact != NULL)
{
if (paramBoolean)
@@ -254,7 +246,7 @@ void WhatsAppProto::onAvailable(const std::string& paramString, bool paramBoolea
void WhatsAppProto::onLastSeen(const std::string& paramString1, int paramInt, std::string* paramString2)
{
/*
- HANDLE hContact = this->ContactIDToHContact(paramString1);
+ HCONTACT hContact = this->ContactIDToHContact(paramString1);
if (hContact == NULL)
{
// This contact was searched
@@ -270,13 +262,13 @@ void WhatsAppProto::onLastSeen(const std::string& paramString1, int paramInt, st
// #TODO
}
*/
- HANDLE hContact = this->AddToContactList(paramString1, 0, false);
+ HCONTACT hContact = this->AddToContactList(paramString1, 0, false);
setDword(hContact, WHATSAPP_KEY_LAST_SEEN, paramInt);
this->UpdateStatusMsg(hContact);
}
-void WhatsAppProto::UpdateStatusMsg(HANDLE hContact)
+void WhatsAppProto::UpdateStatusMsg(HCONTACT hContact)
{
std::wstringstream ss;
@@ -312,7 +304,7 @@ void WhatsAppProto::onPictureChanged(const std::string& from, const std::string&
void WhatsAppProto::onSendGetPicture(const std::string& jid, const std::vector<unsigned char>& data, const std::string& oldId, const std::string& newId)
{
- HANDLE hContact = this->ContactIDToHContact(jid);
+ HCONTACT hContact = this->ContactIDToHContact(jid);
if (hContact)
{
debugLogA("Updating avatar for jid %s", jid.c_str());
@@ -350,7 +342,7 @@ void WhatsAppProto::onSendGetPictureIds(std::map<string,string>* ids)
{
for (std::map<string,string>::iterator it = ids->begin(); it != ids->end(); ++it)
{
- HANDLE hContact = this->AddToContactList(it->first);
+ HCONTACT hContact = this->AddToContactList(it->first);
if (hContact != NULL)
{
DBVARIANT dbv;
@@ -373,14 +365,14 @@ void WhatsAppProto::onSendGetPictureIds(std::map<string,string>* ids)
}
}
-string WhatsAppProto::GetContactDisplayName(HANDLE hContact)
+string WhatsAppProto::GetContactDisplayName(HCONTACT hContact)
{
return string((CHAR*) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, 0));
}
string WhatsAppProto::GetContactDisplayName(const string& jid)
{
- HANDLE hContact = this->ContactIDToHContact(jid);
+ HCONTACT hContact = this->ContactIDToHContact(jid);
return hContact ? this->GetContactDisplayName(hContact) : (string("+")+ Utilities::removeWaDomainFromJid(jid));
}
@@ -397,7 +389,7 @@ void WhatsAppProto::SendGetGroupInfoWorker(void* data)
void WhatsAppProto::onGroupInfo(const std::string& gjid, const std::string& ownerJid, const std::string& subject, const std::string& createrJid, int paramInt1, int paramInt2)
{
debugLogA("'%s', '%s', '%s', '%s'", gjid.c_str(), ownerJid.c_str(), subject.c_str(), createrJid.c_str());
- HANDLE hContact = ContactIDToHContact(gjid);
+ HCONTACT hContact = ContactIDToHContact(gjid);
if (!hContact)
{
debugLogA("Group info requested for non existing contact '%s'", gjid.c_str());
@@ -417,13 +409,13 @@ void WhatsAppProto::onGroupInfoFromList(const std::string& paramString1, const s
void WhatsAppProto::onGroupNewSubject(const std::string& from, const std::string& author, const std::string& newSubject, int paramInt)
{
debugLogA("'%s', '%s', '%s'", from.c_str(), author.c_str(), newSubject.c_str());
- HANDLE hContact = this->AddToContactList(from, 0, false, newSubject.c_str(), true);
+ HCONTACT hContact = this->AddToContactList(from, 0, false, newSubject.c_str(), true);
}
void WhatsAppProto::onGroupAddUser(const std::string& paramString1, const std::string& paramString2)
{
debugLogA("%s - user: %s", paramString1.c_str(), paramString2.c_str());
- HANDLE hContact = this->AddToContactList(paramString1);
+ HCONTACT hContact = this->AddToContactList(paramString1);
std::string groupName(this->GetContactDisplayName(hContact));
if (paramString2.compare(this->jid) == 0)
@@ -446,7 +438,7 @@ void WhatsAppProto::onGroupAddUser(const std::string& paramString1, const std::s
void WhatsAppProto::onGroupRemoveUser(const std::string& paramString1, const std::string& paramString2)
{
debugLogA("%s - user: %s", paramString1.c_str(), paramString2.c_str());
- HANDLE hContact = this->ContactIDToHContact(paramString1);
+ HCONTACT hContact = this->ContactIDToHContact(paramString1);
if (!hContact)
return;
@@ -473,7 +465,7 @@ void WhatsAppProto::onLeaveGroup(const std::string& paramString)
{
// Won't be called for unknown reasons!
debugLogA("%s", this->GetContactDisplayName(paramString).c_str());
- HANDLE hContact = this->ContactIDToHContact(paramString);
+ HCONTACT hContact = this->ContactIDToHContact(paramString);
if (hContact)
setByte(hContact, "IsGroupMember", 0);
}
@@ -482,8 +474,7 @@ void WhatsAppProto::onGetParticipants(const std::string& gjid, const std::vector
{
debugLogA("%s", this->GetContactDisplayName(gjid).c_str());
- HANDLE hUserContact;
- HANDLE hContact = this->ContactIDToHContact(gjid);
+ HCONTACT hUserContact, hContact = this->ContactIDToHContact(gjid);
if (!hContact)
return;
@@ -534,8 +525,8 @@ void WhatsAppProto::onGetParticipants(const std::string& gjid, const std::vector
// Menu handler
INT_PTR __cdecl WhatsAppProto::OnAddContactToGroup(WPARAM wParam, LPARAM, LPARAM lParam)
{
- string a = GetContactDisplayName((HANDLE) wParam);
- string b = GetContactDisplayName((HANDLE) lParam);
+ string a = GetContactDisplayName((HCONTACT)wParam);
+ string b = GetContactDisplayName((HCONTACT)lParam);
debugLogA("Request add user %s to group %s", a.c_str(), b.c_str());
if (!this->isOnline())
@@ -543,14 +534,14 @@ INT_PTR __cdecl WhatsAppProto::OnAddContactToGroup(WPARAM wParam, LPARAM, LPARAM
DBVARIANT dbv;
- if (getString((HANDLE)wParam, "ID", &dbv))
+ if (getString((HCONTACT)wParam, "ID", &dbv))
return NULL;
std::vector<string> participants;
participants.push_back(string(dbv.pszVal));
db_free(&dbv);
- if (getString((HANDLE)lParam, "ID", &dbv))
+ if (getString((HCONTACT)lParam, "ID", &dbv))
return NULL;
this->connection->sendAddParticipants(string(dbv.pszVal), participants);
@@ -562,8 +553,8 @@ INT_PTR __cdecl WhatsAppProto::OnAddContactToGroup(WPARAM wParam, LPARAM, LPARAM
// Menu handler
INT_PTR __cdecl WhatsAppProto::OnRemoveContactFromGroup(WPARAM wParam, LPARAM, LPARAM lParam)
{
- string a = GetContactDisplayName((HANDLE) wParam);
- string b = GetContactDisplayName((HANDLE) lParam);
+ string a = GetContactDisplayName((HCONTACT)wParam);
+ string b = GetContactDisplayName((HCONTACT)lParam);
debugLogA("Request remove user %s from group %s", a.c_str(), b.c_str());
if (!this->isOnline())
@@ -571,14 +562,14 @@ INT_PTR __cdecl WhatsAppProto::OnRemoveContactFromGroup(WPARAM wParam, LPARAM, L
DBVARIANT dbv;
- if (getString((HANDLE)lParam, "ID", &dbv))
+ if (getString((HCONTACT)lParam, "ID", &dbv))
return NULL;
std::vector<string> participants;
participants.push_back(string(dbv.pszVal));
db_free(&dbv);
- if (getString((HANDLE)wParam, "ID", &dbv))
+ if (getString((HCONTACT)wParam, "ID", &dbv))
return NULL;
this->connection->sendRemoveParticipants(string(dbv.pszVal), participants);
@@ -601,7 +592,7 @@ void WhatsAppProto::onParticipatingGroups(const std::vector<string>& paramVector
void WhatsAppProto::HandleReceiveGroups(const std::vector<string>& groups, bool isOwned)
{
- HANDLE hContact;
+ HCONTACT hContact;
map<HANDLE, bool> isMember; // at the moment, only members of owning groups are stored
// This could take long time if there are many new groups which aren't
@@ -641,7 +632,7 @@ void WhatsAppProto::onGroupCreated(const std::string& paramString1, const std::s
// Must be received after onOwningGroups() :/
debugLogA("%s / %s", paramString1.c_str(), paramString2.c_str());
string jid = paramString2 +string("@")+ paramString1;
- HANDLE hContact = this->AddToContactList(jid, 0, false, NULL, true);
+ HCONTACT hContact = this->AddToContactList(jid, 0, false, NULL, true);
setByte(hContact, "SimpleChatRoom", 2);
}
@@ -668,7 +659,7 @@ void __cdecl WhatsAppProto::SendSetGroupNameWorker(void* data)
string groupName(ibr->value);
mir_free(ibr->value);
DBVARIANT dbv;
- if (!getString(*((HANDLE*) ibr->userData), WHATSAPP_KEY_ID, &dbv) && this->isOnline())
+ if (!getString(*((HCONTACT*)ibr->userData), WHATSAPP_KEY_ID, &dbv) && this->isOnline())
{
this->connection->sendSetNewSubject(dbv.pszVal, groupName);
db_free(&dbv);
@@ -691,7 +682,7 @@ void __cdecl WhatsAppProto::SendCreateGroupWorker(void* data)
INT_PTR __cdecl WhatsAppProto::OnChangeGroupSubject(WPARAM wParam, LPARAM lParam)
{
DBVARIANT dbv;
- HANDLE hContact = reinterpret_cast<HANDLE>(wParam);
+ HCONTACT hContact = reinterpret_cast<HCONTACT>(wParam);
input_box* ib = new input_box;
if (getTString(hContact, WHATSAPP_KEY_PUSH_NAME, &dbv))
@@ -719,7 +710,7 @@ INT_PTR __cdecl WhatsAppProto::OnChangeGroupSubject(WPARAM wParam, LPARAM lParam
INT_PTR __cdecl WhatsAppProto::OnLeaveGroup(WPARAM wParam, LPARAM)
{
DBVARIANT dbv;
- HANDLE hContact = reinterpret_cast<HANDLE>(wParam);
+ HCONTACT hContact = reinterpret_cast<HCONTACT>(wParam);
if (this->isOnline() && !getString(hContact, WHATSAPP_KEY_ID, &dbv))
{
setByte(hContact, "IsGroupMember", 0);
diff --git a/protocols/WhatsApp/src/entities.h b/protocols/WhatsApp/src/entities.h
index d48fbfb573..a2543cf20d 100644
--- a/protocols/WhatsApp/src/entities.h
+++ b/protocols/WhatsApp/src/entities.h
@@ -3,18 +3,18 @@
struct send_direct
{
- send_direct(HANDLE hContact,const std::string &msg, HANDLE msgid, bool isChat = false)
+ send_direct(HCONTACT hContact,const std::string &msg, HANDLE msgid, bool isChat = false)
: hContact(hContact), msg(msg), msgid(msgid)
{}
- HANDLE hContact;
+ HCONTACT hContact;
std::string msg;
HANDLE msgid;
};
struct send_typing
{
- send_typing(HANDLE hContact,const int status) : hContact(hContact), status(status) {}
- HANDLE hContact;
+ send_typing(HCONTACT hContact,const int status) : hContact(hContact), status(status) {}
+ HCONTACT hContact;
int status;
};
diff --git a/protocols/WhatsApp/src/messages.cpp b/protocols/WhatsApp/src/messages.cpp
index 00ddab1e12..c5c911ade8 100644
--- a/protocols/WhatsApp/src/messages.cpp
+++ b/protocols/WhatsApp/src/messages.cpp
@@ -1,6 +1,6 @@
#include "common.h"
-int WhatsAppProto::RecvMsg(HANDLE hContact, PROTORECVEVENT *pre)
+int WhatsAppProto::RecvMsg(HCONTACT hContact, PROTORECVEVENT *pre)
{
CallService(MS_PROTO_CONTACTISTYPING, (WPARAM)hContact, (LPARAM)PROTOTYPE_CONTACTTYPING_OFF);
@@ -28,7 +28,7 @@ void WhatsAppProto::onMessageForMe(FMessage* paramFMessage, bool paramBoolean)
msg->insert(0, std::string("[").append(paramFMessage->notifyname).append("]: "));
}
- HANDLE hContact = this->AddToContactList(paramFMessage->key->remote_jid, 0, false,
+ HCONTACT hContact = this->AddToContactList(paramFMessage->key->remote_jid, 0, false,
isChatRoom ? NULL : paramFMessage->notifyname.c_str(), isChatRoom);
PROTORECVEVENT recv = {0};
@@ -40,7 +40,7 @@ void WhatsAppProto::onMessageForMe(FMessage* paramFMessage, bool paramBoolean)
this->connection->sendMessageReceived(paramFMessage);
}
-int WhatsAppProto::SendMsg(HANDLE hContact, int flags, const char *msg)
+int WhatsAppProto::SendMsg(HCONTACT hContact, int flags, const char *msg)
{
debugLogA("");
int msgId = ++(this->msgId);
@@ -120,7 +120,7 @@ void WhatsAppProto::RecvMsgWorker(void *p)
void WhatsAppProto::onIsTyping(const std::string& paramString, bool paramBoolean)
{
- HANDLE hContact = this->AddToContactList(paramString, 0, false);
+ HCONTACT hContact = this->AddToContactList(paramString, 0, false);
if (hContact != NULL)
{
CallService(MS_PROTO_CONTACTISTYPING, (WPARAM) hContact, (LPARAM)
@@ -129,7 +129,7 @@ void WhatsAppProto::onIsTyping(const std::string& paramString, bool paramBoolean
}
-int WhatsAppProto::UserIsTyping(HANDLE hContact,int type)
+int WhatsAppProto::UserIsTyping(HCONTACT hContact,int type)
{
if (hContact && isOnline())
ForkThread(&WhatsAppProto::SendTypingWorker, new send_typing(hContact, type));
@@ -165,7 +165,7 @@ void WhatsAppProto::onMessageStatusUpdate(FMessage* fmsg)
{
debugLogA("");
- HANDLE hContact = this->ContactIDToHContact(fmsg->key->remote_jid);
+ HCONTACT hContact = this->ContactIDToHContact(fmsg->key->remote_jid);
if (hContact == 0)
return;
diff --git a/protocols/WhatsApp/src/proto.cpp b/protocols/WhatsApp/src/proto.cpp
index 6b61cca21c..c7239ee4e2 100644
--- a/protocols/WhatsApp/src/proto.cpp
+++ b/protocols/WhatsApp/src/proto.cpp
@@ -61,7 +61,7 @@ int WhatsAppProto::OnModulesLoaded(WPARAM wParam, LPARAM lParam)
return 0;
}
-DWORD_PTR WhatsAppProto::GetCaps( int type, HANDLE hContact )
+DWORD_PTR WhatsAppProto::GetCaps( int type, HCONTACT hContact )
{
switch(type)
{
@@ -139,7 +139,7 @@ HANDLE WhatsAppProto::AddToList( int flags, PROTOSEARCHRESULT* psr )
return NULL;
}
-int WhatsAppProto::AuthRequest(HANDLE hContact,const PROTOCHAR *message)
+int WhatsAppProto::AuthRequest(HCONTACT hContact,const PROTOCHAR *message)
{
return this->RequestFriendship((WPARAM)hContact, NULL);
}
@@ -314,7 +314,7 @@ int WhatsAppProto::RequestFriendship(WPARAM wParam, LPARAM lParam)
if (wParam == NULL || isOffline())
return 0;
- HANDLE hContact = reinterpret_cast<HANDLE>(wParam);
+ HCONTACT hContact = reinterpret_cast<HCONTACT>(wParam);
DBVARIANT dbv;
if ( !getString(hContact, WHATSAPP_KEY_ID, &dbv))
@@ -363,7 +363,7 @@ LRESULT CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
return DefWindowProc(hwnd, message, wParam, lParam);
};
-void WhatsAppProto::NotifyEvent(const string& title, const string& info, HANDLE contact, DWORD flags, TCHAR* url)
+void WhatsAppProto::NotifyEvent(const string& title, const string& info, HCONTACT contact, DWORD flags, TCHAR* url)
{
TCHAR* rawTitle = mir_a2t_cp(title.c_str(), CP_UTF8);
TCHAR* rawInfo = mir_a2t_cp(info.c_str(), CP_UTF8);
@@ -372,7 +372,7 @@ void WhatsAppProto::NotifyEvent(const string& title, const string& info, HANDLE
mir_free(rawInfo);
}
-void WhatsAppProto::NotifyEvent(TCHAR* title, TCHAR* info, HANDLE contact, DWORD flags, TCHAR* szUrl)
+void WhatsAppProto::NotifyEvent(TCHAR* title, TCHAR* info, HCONTACT contact, DWORD flags, TCHAR* szUrl)
{
int ret; int timeout; COLORREF colorBack = 0; COLORREF colorText = 0;
diff --git a/protocols/WhatsApp/src/proto.h b/protocols/WhatsApp/src/proto.h
index d8bdab70a6..80e954d71a 100644
--- a/protocols/WhatsApp/src/proto.h
+++ b/protocols/WhatsApp/src/proto.h
@@ -37,18 +37,18 @@ public:
virtual int __cdecl Authorize( HANDLE hDbEvent );
virtual int __cdecl AuthDeny( HANDLE hDbEvent, const PROTOCHAR* szReason ) { return 1; }
- virtual int __cdecl AuthRecv( HANDLE hContact, PROTORECVEVENT* ) { return 1; }
- virtual int __cdecl AuthRequest( HANDLE hContact, const PROTOCHAR* szMessage );
+ virtual int __cdecl AuthRecv(HCONTACT hContact, PROTORECVEVENT* ) { return 1; }
+ virtual int __cdecl AuthRequest(HCONTACT hContact, const PROTOCHAR* szMessage );
virtual HANDLE __cdecl ChangeInfo( int iInfoType, void* pInfoData ) { return NULL; }
- virtual HANDLE __cdecl FileAllow( HANDLE hContact, HANDLE hTransfer, const PROTOCHAR* szPath ) { return NULL; }
- virtual int __cdecl FileCancel( HANDLE hContact, HANDLE hTransfer ) { return 1; }
- virtual int __cdecl FileDeny( HANDLE hContact, HANDLE hTransfer, const PROTOCHAR* szReason ) { return 1; }
+ virtual HANDLE __cdecl FileAllow(HCONTACT hContact, HANDLE hTransfer, const PROTOCHAR* szPath ) { return NULL; }
+ virtual int __cdecl FileCancel(HCONTACT hContact, HANDLE hTransfer ) { return 1; }
+ virtual int __cdecl FileDeny(HCONTACT hContact, HANDLE hTransfer, const PROTOCHAR* szReason ) { return 1; }
virtual int __cdecl FileResume( HANDLE hTransfer, int* action, const PROTOCHAR** szFilename ) { return 1; }
- virtual DWORD_PTR __cdecl GetCaps( int type, HANDLE hContact = NULL );
- virtual int __cdecl GetInfo( HANDLE hContact, int infoType ) { return 1; }
+ virtual DWORD_PTR __cdecl GetCaps( int type, HCONTACT hContact = NULL );
+ virtual int __cdecl GetInfo(HCONTACT hContact, int infoType ) { return 1; }
virtual HANDLE __cdecl SearchBasic( const PROTOCHAR* id );
virtual HANDLE __cdecl SearchByEmail( const PROTOCHAR* email ) { return NULL; }
@@ -56,25 +56,25 @@ public:
virtual HWND __cdecl SearchAdvanced( HWND owner ) { return NULL; }
virtual HWND __cdecl CreateExtendedSearchUI( HWND owner ) { return NULL; }
- virtual int __cdecl RecvContacts( HANDLE hContact, PROTORECVEVENT* ) { return 1; }
- virtual int __cdecl RecvFile( HANDLE hContact, PROTOFILEEVENT* ) { return 1; }
- virtual int __cdecl RecvMsg( HANDLE hContact, PROTORECVEVENT* );
- virtual int __cdecl RecvUrl( HANDLE hContact, PROTORECVEVENT* ) { return 1; }
+ virtual int __cdecl RecvContacts(HCONTACT hContact, PROTORECVEVENT* ) { return 1; }
+ virtual int __cdecl RecvFile(HCONTACT hContact, PROTOFILEEVENT* ) { return 1; }
+ virtual int __cdecl RecvMsg(HCONTACT hContact, PROTORECVEVENT* );
+ virtual int __cdecl RecvUrl(HCONTACT hContact, PROTORECVEVENT* ) { return 1; }
- virtual int __cdecl SendContacts( HANDLE hContact, int flags, int nContacts, HANDLE* hContactsList ) { return 1; }
- virtual HANDLE __cdecl SendFile( HANDLE hContact, const PROTOCHAR* szDescription, PROTOCHAR** ppszFiles ) { return NULL; }
- virtual int __cdecl SendMsg( HANDLE hContact, int flags, const char* msg );
- virtual int __cdecl SendUrl( HANDLE hContact, int flags, const char* url ) { return 1; }
+ virtual int __cdecl SendContacts(HCONTACT hContact, int flags, int nContacts, HCONTACT *hContactsList) { return 1; }
+ virtual HANDLE __cdecl SendFile(HCONTACT hContact, const PROTOCHAR* szDescription, PROTOCHAR** ppszFiles ) { return NULL; }
+ virtual int __cdecl SendMsg(HCONTACT hContact, int flags, const char* msg );
+ virtual int __cdecl SendUrl(HCONTACT hContact, int flags, const char* url ) { return 1; }
- virtual int __cdecl SetApparentMode( HANDLE hContact, int mode ) { return 1; }
+ virtual int __cdecl SetApparentMode(HCONTACT hContact, int mode ) { return 1; }
virtual int __cdecl SetStatus( int iNewStatus );
- virtual HANDLE __cdecl GetAwayMsg( HANDLE hContact ) { return NULL; }
- virtual int __cdecl RecvAwayMsg( HANDLE hContact, int mode, PROTORECVEVENT* evt ) { return 1; }
- virtual int __cdecl SendAwayMsg( HANDLE hContact, HANDLE hProcess, const char* msg ) { return 1; }
+ virtual HANDLE __cdecl GetAwayMsg(HCONTACT hContact ) { return NULL; }
+ virtual int __cdecl RecvAwayMsg(HCONTACT hContact, int mode, PROTORECVEVENT* evt ) { return 1; }
+ virtual int __cdecl SendAwayMsg(HCONTACT hContact, HANDLE hProcess, const char* msg ) { return 1; }
virtual int __cdecl SetAwayMsg( int iStatus, const PROTOCHAR* msg ) { return 1; }
- virtual int __cdecl UserIsTyping( HANDLE hContact, int type );
+ virtual int __cdecl UserIsTyping(HCONTACT hContact, int type );
virtual int __cdecl OnEvent( PROTOEVENTTYPE iEventType, WPARAM wParam, LPARAM lParam ) { return 1; }
@@ -120,18 +120,18 @@ public:
void __cdecl SendCreateGroupWorker(void*);
// Contacts handling
- HANDLE AddToContactList(const std::string& jid, BYTE type = 0, bool dont_check = false,
+ HCONTACT AddToContactList(const std::string& jid, BYTE type = 0, bool dont_check = false,
const char *new_name = NULL, bool isChatRoom = false, bool isHidden = false);
- bool IsMyContact(HANDLE, bool include_chat = false);
- HANDLE ContactIDToHContact(const std::string&);
+ bool IsMyContact(HCONTACT hContact, bool include_chat = false);
+ HCONTACT ContactIDToHContact(const std::string&);
void SetAllContactStatuses(int status, bool reset_client = false);
- void UpdateStatusMsg(HANDLE hContact);
- string GetContactDisplayName(HANDLE hContact);
+ void UpdateStatusMsg(HCONTACT hContact);
+ string GetContactDisplayName(HCONTACT hContact);
string GetContactDisplayName(const string& jid);
void InitContactMenus();
void HandleReceiveGroups(const std::vector<string>& groups, bool isOwned);
- bool IsGroupChat(HANDLE hC, bool checkIsAdmin = false)
+ bool IsGroupChat(HCONTACT hC, bool checkIsAdmin = false)
{
return getByte(hC, "SimpleChatRoom", 0) > (checkIsAdmin ? 1 : 0);
}
@@ -165,9 +165,8 @@ public:
string phoneNumber;
string jid;
string nick;
- std::map<string, HANDLE> hContactByJid;
- //std::map<HANDLE, std::vector<HANDLE>> membersByGroupContact;
- map<HANDLE, map<HANDLE, bool>> isMemberByGroupContact;
+ std::map<string, HCONTACT> hContactByJid;
+ map<HCONTACT, map<HCONTACT, bool>> isMemberByGroupContact;
// WhatsApp Events
virtual void onMessageForMe(FMessage* paramFMessage, bool paramBoolean);
@@ -206,8 +205,8 @@ public:
virtual void onLeaveGroup(const std::string& paramString);
// Information providing
- void NotifyEvent(TCHAR* title, TCHAR* info, HANDLE contact, DWORD flags, TCHAR* url=NULL);
- void NotifyEvent(const string& title, const string& info, HANDLE contact, DWORD flags, TCHAR* url=NULL);
+ void NotifyEvent(TCHAR* title, TCHAR* info, HCONTACT contact, DWORD flags, TCHAR* url = NULL);
+ void NotifyEvent(const string& title, const string& info, HCONTACT contact, DWORD flags, TCHAR* url = NULL);
};
diff --git a/protocols/WhatsApp/src/theme.cpp b/protocols/WhatsApp/src/theme.cpp
index e5285ddf0a..3e64694ade 100644
--- a/protocols/WhatsApp/src/theme.cpp
+++ b/protocols/WhatsApp/src/theme.cpp
@@ -40,7 +40,7 @@ char *GetIconDescription(const char* name)
HGENMENU g_hContactMenuItems[CMITEMS_COUNT];
// Helper functions
-static WhatsAppProto* GetInstanceByHContact(HANDLE hContact)
+static WhatsAppProto* GetInstanceByHContact(HCONTACT hContact)
{
char *proto = GetContactProto(hContact);
if( !proto )
@@ -56,14 +56,14 @@ static WhatsAppProto* GetInstanceByHContact(HANDLE hContact)
template<INT_PTR (__cdecl WhatsAppProto::*Fcn)(WPARAM,LPARAM)>
INT_PTR GlobalService(WPARAM wParam,LPARAM lParam)
{
- WhatsAppProto *proto = GetInstanceByHContact(reinterpret_cast<HANDLE>(wParam));
+ WhatsAppProto *proto = GetInstanceByHContact(reinterpret_cast<HCONTACT>(wParam));
return proto ? (proto->*Fcn)(wParam,lParam) : 0;
}
template<INT_PTR (__cdecl WhatsAppProto::*Fcn)(WPARAM,LPARAM,LPARAM)>
INT_PTR GlobalServiceParam(WPARAM wParam,LPARAM lParam, LPARAM lParam2)
{
- WhatsAppProto *proto = GetInstanceByHContact(reinterpret_cast<HANDLE>(wParam));
+ WhatsAppProto *proto = GetInstanceByHContact(reinterpret_cast<HCONTACT>(wParam));
return proto ? (proto->*Fcn)(wParam,lParam,lParam2) : 0;
}
@@ -72,7 +72,7 @@ static int PrebuildContactMenu(WPARAM wParam,LPARAM lParam)
for (size_t i=0; i<SIZEOF(g_hContactMenuItems); i++)
Menu_ShowItem(g_hContactMenuItems[i], false);
- WhatsAppProto *proto = GetInstanceByHContact(reinterpret_cast<HANDLE>(wParam));
+ WhatsAppProto *proto = GetInstanceByHContact(reinterpret_cast<HCONTACT>(wParam));
return proto ? proto->OnPrebuildContactMenu(wParam,lParam) : 0;
}
@@ -104,7 +104,7 @@ void WhatsAppProto::InitContactMenus()
int WhatsAppProto::OnPrebuildContactMenu(WPARAM wParam,LPARAM lParam)
{
- HANDLE hContact = reinterpret_cast<HANDLE>(wParam);
+ HCONTACT hContact = reinterpret_cast<HCONTACT>(wParam);
if (hContact)
debugLogA(this->GetContactDisplayName(hContact).c_str());
else
@@ -144,10 +144,10 @@ int WhatsAppProto::OnPrebuildContactMenu(WPARAM wParam,LPARAM lParam)
svcName += "/AddContactToGroup_";
DBVARIANT dbv;
- for (map<HANDLE, map<HANDLE, bool>>::iterator it = this->isMemberByGroupContact.begin();
+ for (map<HCONTACT, map<HCONTACT, bool>>::iterator it = this->isMemberByGroupContact.begin();
it != this->isMemberByGroupContact.end(); ++it)
{
- map<HANDLE, bool>::iterator memberIt = it->second.find(hContact);
+ map<HCONTACT, bool>::iterator memberIt = it->second.find(hContact);
// Only, if current contact is not already member of this group
if ((memberIt == it->second.end() || memberIt->second == false) && !getString(it->first, "ID", &dbv))
{
@@ -184,7 +184,7 @@ int WhatsAppProto::OnPrebuildContactMenu(WPARAM wParam,LPARAM lParam)
bool bShow = false;
if (isOnline() && getByte(hContact, "IsGroupMember", 0) == 1)
{
- map<HANDLE, map<HANDLE, bool>>::iterator groupsIt = this->isMemberByGroupContact.find(hContact);
+ map<HCONTACT, map<HCONTACT, bool>>::iterator groupsIt = this->isMemberByGroupContact.find(hContact);
if (groupsIt == this->isMemberByGroupContact.end())
{
debugLogA("Group exists only on contact list");
@@ -199,7 +199,7 @@ int WhatsAppProto::OnPrebuildContactMenu(WPARAM wParam,LPARAM lParam)
svcName += "/RemoveContactFromGroup_";
DBVARIANT dbv;
- for (map<HANDLE, bool>::iterator it = groupsIt->second.begin(); it != groupsIt->second.end(); ++it)
+ for (map<HCONTACT, bool>::iterator it = groupsIt->second.begin(); it != groupsIt->second.end(); ++it)
{
if (!getString(it->first, "ID", &dbv))
{