diff options
Diffstat (limited to 'protocols/WhatsApp/src')
-rw-r--r-- | protocols/WhatsApp/src/connection.cpp | 10 | ||||
-rw-r--r-- | protocols/WhatsApp/src/contacts.cpp | 107 | ||||
-rw-r--r-- | protocols/WhatsApp/src/db.h | 15 | ||||
-rw-r--r-- | protocols/WhatsApp/src/dialogs.cpp | 2 | ||||
-rw-r--r-- | protocols/WhatsApp/src/messages.cpp | 26 | ||||
-rw-r--r-- | protocols/WhatsApp/src/proto.cpp | 8 | ||||
-rw-r--r-- | protocols/WhatsApp/src/proto.h | 2 | ||||
-rw-r--r-- | protocols/WhatsApp/src/theme.cpp | 11 |
8 files changed, 72 insertions, 109 deletions
diff --git a/protocols/WhatsApp/src/connection.cpp b/protocols/WhatsApp/src/connection.cpp index 6288d74ad9..edd04248df 100644 --- a/protocols/WhatsApp/src/connection.cpp +++ b/protocols/WhatsApp/src/connection.cpp @@ -44,7 +44,7 @@ void WhatsAppProto::stayConnectedLoop(void*) std::string cc, in, pass;
DBVARIANT dbv = {0};
- if ( !db_get_s(NULL,m_szModuleName,WHATSAPP_KEY_CC,&dbv,DBVT_ASCIIZ))
+ if ( !getString(WHATSAPP_KEY_CC, &dbv))
{
cc = dbv.pszVal;
db_free(&dbv);
@@ -57,7 +57,7 @@ void WhatsAppProto::stayConnectedLoop(void*) }
error = true;
- if ( !db_get_s(NULL,m_szModuleName,WHATSAPP_KEY_LOGIN,&dbv,DBVT_ASCIIZ))
+ if ( !getString(WHATSAPP_KEY_LOGIN, &dbv))
{
in = dbv.pszVal;
db_free(&dbv);
@@ -72,7 +72,7 @@ void WhatsAppProto::stayConnectedLoop(void*) this->jid = this->phoneNumber + "@s.whatsapp.net";
error = true;
- if ( !db_get_s(NULL, m_szModuleName, WHATSAPP_KEY_NICK, &dbv, DBVT_ASCIIZ))
+ if ( !getString(WHATSAPP_KEY_NICK, &dbv))
{
this->nick = dbv.pszVal;
db_free(&dbv);
@@ -85,7 +85,7 @@ void WhatsAppProto::stayConnectedLoop(void*) }
error = true;
- if ( !db_get_s(NULL,m_szModuleName,WHATSAPP_KEY_PASS,&dbv, DBVT_ASCIIZ))
+ if ( !getString(WHATSAPP_KEY_PASS, &dbv))
{
CallService(MS_DB_CRYPT_DECODESTRING,strlen(dbv.pszVal)+1,
reinterpret_cast<LPARAM>(dbv.pszVal));
@@ -145,7 +145,7 @@ void WhatsAppProto::stayConnectedLoop(void*) unsigned passLen;
ptrA passBin((char*)mir_base64_decode(pass.c_str(), &passLen));
std::string password(passBin, passLen);
- BYTE UseSSL = db_get_b(NULL, this->ModuleName(), WHATSAPP_KEY_SSL, 0);
+ BYTE UseSSL = getByte(WHATSAPP_KEY_SSL, 0);
if (UseSSL) {
this->conn = new WASocketConnection("c.whatsapp.net", 443);
diff --git a/protocols/WhatsApp/src/contacts.cpp b/protocols/WhatsApp/src/contacts.cpp index 6a0c3108c6..2cdc0effc9 100644 --- a/protocols/WhatsApp/src/contacts.cpp +++ b/protocols/WhatsApp/src/contacts.cpp @@ -7,11 +7,11 @@ bool WhatsAppProto::IsMyContact(HANDLE hContact, bool include_chat) {
if( include_chat )
return true;
- else
- return db_get_b(hContact,m_szModuleName,"ChatRoom",0) == 0;
- } else {
- return false;
+
+ return getByte(hContact, "ChatRoom", 0) == 0;
}
+
+ return false;
}
HANDLE WhatsAppProto::AddToContactList(const std::string& jid, BYTE type, bool dont_check, const char *new_name,
@@ -29,7 +29,7 @@ HANDLE WhatsAppProto::AddToContactList(const std::string& jid, BYTE type, bool d {
DBVARIANT dbv;
string oldName;
- if (db_get_s(hContact, m_szModuleName, WHATSAPP_KEY_PUSH_NAME, &dbv, DBVT_UTF8))
+ if (db_get_utf(hContact, m_szModuleName, WHATSAPP_KEY_PUSH_NAME, &dbv))
{
oldName = jid.c_str();
}
@@ -60,9 +60,9 @@ HANDLE WhatsAppProto::AddToContactList(const std::string& jid, BYTE type, bool d {
if (CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)m_szModuleName) == 0)
{
- db_set_s(hContact ,m_szModuleName, "ID", jid.c_str());
+ setString(hContact, "ID", jid.c_str());
LOG("Added contact %s", jid.c_str());
- db_set_s(hContact, m_szModuleName, "MirVer", "WhatsApp");
+ setString(hContact, "MirVer", "WhatsApp");
db_unset(hContact, "CList", "MyHandle");
db_set_b(hContact, "CList", "NotOnList", 1);
@@ -94,27 +94,21 @@ HANDLE WhatsAppProto::AddToContactList(const std::string& jid, BYTE type, bool d */
DBVARIANT dbv;
- if( !db_get_s(NULL, m_szModuleName, WHATSAPP_KEY_DEF_GROUP, &dbv, DBVT_WCHAR))
+ if( !getTString(WHATSAPP_KEY_DEF_GROUP, &dbv))
{
db_set_ws(hContact, "CList", "Group", dbv.ptszVal);
db_free(&dbv);
}
if (new_name != NULL)
- {
db_set_utf(hContact, m_szModuleName, WHATSAPP_KEY_PUSH_NAME, new_name);
- }
if (isChatRoom)
- {
- db_set_b(hContact, m_szModuleName, "SimpleChatRoom", 1);
- //ForkThread(&WhatsAppProto::SendGetGroupInfoWorker, this, (void*) &jid);
- }
+ setByte(hContact, "SimpleChatRoom", 1);
return hContact;
- } else {
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
}
+ else CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
}
return INVALID_HANDLE_VALUE;
@@ -137,10 +131,10 @@ HANDLE WhatsAppProto::ContactIDToHContact(const std::string& phoneNumber) if(!IsMyContact(hContact, true))
continue;
- const char* id = db_get_b(hContact, m_szModuleName, "ChatRoom", 0) > 0 ? idForChat : idForContact;
+ const char* id = getByte(hContact, "ChatRoom", 0) > 0 ? idForChat : idForContact;
DBVARIANT dbv;
- if( !db_get_s(hContact,m_szModuleName, id,&dbv, DBVT_ASCIIZ))
+ if( !getString(hContact, id, &dbv))
{
if( strcmp(phoneNumber.c_str(),dbv.pszVal) == 0 )
{
@@ -167,17 +161,17 @@ void WhatsAppProto::SetAllContactStatuses(int status, bool reset_client) if (reset_client) {
DBVARIANT dbv;
- if (!db_get_s(hContact,m_szModuleName,"MirVer",&dbv,DBVT_WCHAR)) {
+ if (!getTString(hContact, "MirVer", &dbv)) {
if (_tcscmp(dbv.ptszVal, _T("WhatsApp")))
- db_set_ws(hContact,m_szModuleName,"MirVer", _T("WhatsApp"));
+ setTString(hContact, "MirVer", _T("WhatsApp"));
db_free(&dbv);
}
db_set_ws(hContact, "CList", "StatusMsg", _T(""));
}
- if (db_get_w(hContact,m_szModuleName,"Status",ID_STATUS_OFFLINE) != status)
- db_set_w(hContact,m_szModuleName,"Status",status);
+ if (getWord(hContact, "Status",ID_STATUS_OFFLINE) != status)
+ setWord(hContact, "Status", status);
}
}
@@ -189,7 +183,7 @@ void WhatsAppProto::ProcessBuddyList(void*) if (!IsMyContact(hContact))
continue;
- if (!db_get_s(hContact, m_szModuleName, WHATSAPP_KEY_ID, &dbv, DBVT_ASCIIZ)) {
+ if (!getString(hContact, WHATSAPP_KEY_ID, &dbv)) {
std::string id(dbv.pszVal);
db_free(&dbv);
@@ -199,7 +193,7 @@ void WhatsAppProto::ProcessBuddyList(void*) // Do not request picture for inactive groups - this would make the group visible again
jids.push_back(id);
}
- if (db_get_b(hContact, m_szModuleName, "SimpleChatRoom", 0) == 0)
+ if (getByte(hContact, "SimpleChatRoom", 0) == 0)
{
this->connection->sendQueryLastOnline(id);
this->connection->sendPresenceSubscriptionRequest(id);
@@ -244,16 +238,16 @@ void WhatsAppProto::onAvailable(const std::string& paramString, bool paramBoolea ids.push_back(paramString);
this->connection->sendGetPictureIds(ids);
*/
- db_set_w(hContact, m_szModuleName, "Status", ID_STATUS_ONLINE);
+ setWord(hContact, "Status", ID_STATUS_ONLINE);
}
else
{
- db_set_w(hContact, m_szModuleName, "Status", ID_STATUS_OFFLINE);
+ setWord(hContact, "Status", ID_STATUS_OFFLINE);
this->UpdateStatusMsg(hContact);
}
}
- db_set_dw(hContact, this->m_szModuleName, WHATSAPP_KEY_LAST_SEEN, 0);
+ setDword(hContact, WHATSAPP_KEY_LAST_SEEN, 0);
this->UpdateStatusMsg(hContact);
}
@@ -277,7 +271,7 @@ void WhatsAppProto::onLastSeen(const std::string& paramString1, int paramInt, st }
*/
HANDLE hContact = this->AddToContactList(paramString1, 0, false);
- db_set_dw(hContact, this->m_szModuleName, WHATSAPP_KEY_LAST_SEEN, paramInt);
+ setDword(hContact, WHATSAPP_KEY_LAST_SEEN, paramInt);
this->UpdateStatusMsg(hContact);
}
@@ -286,7 +280,7 @@ void WhatsAppProto::UpdateStatusMsg(HANDLE hContact) {
std::wstringstream ss;
- int lastSeen = db_get_dw(hContact, m_szModuleName, WHATSAPP_KEY_LAST_SEEN, -1);
+ int lastSeen = getDword(hContact, WHATSAPP_KEY_LAST_SEEN, -1);
if (lastSeen != -1)
{
time_t timestamp = time(NULL) - lastSeen;
@@ -297,7 +291,7 @@ void WhatsAppProto::UpdateStatusMsg(HANDLE hContact) << std::setw(2) << t->tm_hour << _T(":") << std::setw(2) << t->tm_min;
}
- int state = db_get_dw(hContact, m_szModuleName, WHATSAPP_KEY_LAST_MSG_STATE, 2);
+ int state = getDword(hContact, WHATSAPP_KEY_LAST_MSG_STATE, 2);
if (state < 2 && lastSeen != -1)
ss << _T(" - ");
for (; state < 2; ++state)
@@ -341,7 +335,7 @@ void WhatsAppProto::onSendGetPicture(const std::string& jid, const std::vector<u int ackResult;
if (r > 0)
{
- db_set_s(hContact, m_szModuleName, WHATSAPP_KEY_AVATAR_ID, newId.c_str());
+ setString(hContact, WHATSAPP_KEY_AVATAR_ID, newId.c_str());
ackResult = ACKRESULT_SUCCESS;
}
else
@@ -361,10 +355,8 @@ void WhatsAppProto::onSendGetPictureIds(std::map<string,string>* ids) {
DBVARIANT dbv;
std::string oldId;
- if (db_get_s(hContact, m_szModuleName, WHATSAPP_KEY_AVATAR_ID, &dbv, DBVT_ASCIIZ))
- {
+ if (getString(hContact, WHATSAPP_KEY_AVATAR_ID, &dbv))
oldId = "";
- }
else
{
oldId = dbv.pszVal;
@@ -411,11 +403,9 @@ void WhatsAppProto::onGroupInfo(const std::string& gjid, const std::string& owne LOG("Group info requested for non existing contact '%s'", gjid.c_str());
return;
}
- db_set_b(hContact, m_szModuleName, "SimpleChatRoom", ownerJid.compare(this->jid) == 0 ? 2 : 1);
+ setByte(hContact, "SimpleChatRoom", ownerJid.compare(this->jid) == 0 ? 2 : 1);
if (this->isOnline())
- {
this->connection->sendGetParticipants(gjid);
- }
}
void WhatsAppProto::onGroupInfoFromList(const std::string& paramString1, const std::string& paramString2, const std::string& paramString3, const std::string& paramString4, int paramInt1, int paramInt2)
@@ -439,7 +429,7 @@ void WhatsAppProto::onGroupAddUser(const std::string& paramString1, const std::s if (paramString2.compare(this->jid) == 0)
{
this->NotifyEvent(groupName, this->TranslateStr("You have been added to the group"), hContact, WHATSAPP_EVENT_OTHER);
- db_set_b(hContact, m_szModuleName, "IsGroupMember", 1);
+ setByte(hContact, "IsGroupMember", 1);
}
else
{
@@ -465,7 +455,7 @@ void WhatsAppProto::onGroupRemoveUser(const std::string& paramString1, const std if (paramString2.compare(this->jid) == 0)
{
//db_set_b(hContact, "CList", "Hidden", 1);
- db_set_b(hContact, m_szModuleName, "IsGroupMember", 0);
+ setByte(hContact, "IsGroupMember", 0);
this->NotifyEvent(groupName, this->TranslateStr("You have been removed from the group"),
hContact, WHATSAPP_EVENT_OTHER);
@@ -485,10 +475,7 @@ void WhatsAppProto::onLeaveGroup(const std::string& paramString) LOG("%s", this->GetContactDisplayName(paramString).c_str());
HANDLE hContact = this->ContactIDToHContact(paramString);
if (hContact)
- {
- //db_set_b(hContact, "CList", "Hidden", 1);
- db_set_b(hContact, m_szModuleName, "IsGroupMember", 0);
- }
+ setByte(hContact, "IsGroupMember", 0);
}
void WhatsAppProto::onGetParticipants(const std::string& gjid, const std::vector<string>& participants)
@@ -504,12 +491,10 @@ void WhatsAppProto::onGetParticipants(const std::string& gjid, const std::vector return;
bool isHidden = true;
- bool isOwningGroup = db_get_b(hContact, m_szModuleName, "SimpleChatRoom", 0) == 2;
+ bool isOwningGroup = getByte(hContact, "SimpleChatRoom", 0) == 2;
if (isOwningGroup)
- {
this->isMemberByGroupContact[hContact].clear();
- }
for (std::vector<string>::const_iterator it = participants.begin(); it != participants.end(); ++it)
{
@@ -542,7 +527,7 @@ void WhatsAppProto::onGetParticipants(const std::string& gjid, const std::vector {
//db_set_b(hContact, "CList", "Hidden", 1);
// #TODO Check if it's possible to reach this point at all
- db_set_b(hContact, m_szModuleName, "IsGroupMember", 0);
+ setByte(hContact, "IsGroupMember", 0);
}
}
@@ -558,14 +543,14 @@ INT_PTR __cdecl WhatsAppProto::OnAddContactToGroup(WPARAM wParam, LPARAM, LPARAM DBVARIANT dbv;
- if (db_get_s((HANDLE) wParam, m_szModuleName, "ID", &dbv, DBVT_ASCIIZ))
+ if (getString((HANDLE)wParam, "ID", &dbv))
return NULL;
std::vector<string> participants;
participants.push_back(string(dbv.pszVal));
db_free(&dbv);
- if (db_get_s((HANDLE) lParam, m_szModuleName, "ID", &dbv, DBVT_ASCIIZ))
+ if (getString((HANDLE)lParam, "ID", &dbv))
return NULL;
this->connection->sendAddParticipants(string(dbv.pszVal), participants);
@@ -586,14 +571,14 @@ INT_PTR __cdecl WhatsAppProto::OnRemoveContactFromGroup(WPARAM wParam, LPARAM, L DBVARIANT dbv;
- if (db_get_s((HANDLE) lParam, m_szModuleName, "ID", &dbv, DBVT_ASCIIZ))
+ if (getString((HANDLE)lParam, "ID", &dbv))
return NULL;
std::vector<string> participants;
participants.push_back(string(dbv.pszVal));
db_free(&dbv);
- if (db_get_s((HANDLE) wParam, m_szModuleName, "ID", &dbv, DBVT_ASCIIZ))
+ if (getString((HANDLE)wParam, "ID", &dbv))
return NULL;
this->connection->sendRemoveParticipants(string(dbv.pszVal), participants);
@@ -624,11 +609,11 @@ void WhatsAppProto::HandleReceiveGroups(const std::vector<string>& groups, bool for (std::vector<string>::const_iterator it = groups.begin(); it != groups.end(); ++it)
{
hContact = this->AddToContactList(*it, 0, false, NULL, true);
- db_set_b(hContact, m_szModuleName, "IsGroupMember", 1);
+ setByte(hContact, "IsGroupMember", 1);
if (isOwned)
{
this->isMemberByGroupContact[hContact]; // []-operator creates entry, if it doesn't exist
- db_set_b(hContact, m_szModuleName, "SimpleChatRoom", 2);
+ setByte(hContact, "SimpleChatRoom", 2);
this->connection->sendGetParticipants(*it);
}
else
@@ -642,11 +627,10 @@ void WhatsAppProto::HandleReceiveGroups(const std::vector<string>& groups, bool {
for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
{
- if (IsMyContact(hContact) && db_get_b(hContact, m_szModuleName, "SimpleChatRoom", 0) > 0)
+ if (IsMyContact(hContact) && getByte(hContact, "SimpleChatRoom", 0) > 0)
{
//LOG("Set IsGroupMember to 0 for '%s'", this->GetContactDisplayName(hContact).c_str());
- db_set_b(hContact, m_szModuleName, "IsGroupMember",
- isMember.find(hContact) == isMember.end() ? 0 : 1);
+ setByte(hContact, "IsGroupMember", isMember.find(hContact) == isMember.end() ? 0 : 1);
}
}
}
@@ -658,7 +642,7 @@ void WhatsAppProto::onGroupCreated(const std::string& paramString1, const std::s LOG("%s / %s", paramString1.c_str(), paramString2.c_str());
string jid = paramString2 +string("@")+ paramString1;
HANDLE hContact = this->AddToContactList(jid, 0, false, NULL, true);
- db_set_b(hContact, m_szModuleName, "SimpleChatRoom", 2);
+ setByte(hContact, "SimpleChatRoom", 2);
}
// Menu-handler
@@ -684,8 +668,7 @@ void __cdecl WhatsAppProto::SendSetGroupNameWorker(void* data) string groupName(ibr->value);
mir_free(ibr->value);
DBVARIANT dbv;
- if (!db_get_s(*((HANDLE*) ibr->userData), m_szModuleName, WHATSAPP_KEY_ID, &dbv, DBVT_ASCIIZ)
- && this->isOnline())
+ if (!getString(*((HANDLE*) ibr->userData), WHATSAPP_KEY_ID, &dbv) && this->isOnline())
{
this->connection->sendSetNewSubject(dbv.pszVal, groupName);
db_free(&dbv);
@@ -711,7 +694,7 @@ INT_PTR __cdecl WhatsAppProto::OnChangeGroupSubject(WPARAM wParam, LPARAM lParam HANDLE hContact = reinterpret_cast<HANDLE>(wParam);
input_box* ib = new input_box;
- if (db_get_s(hContact, m_szModuleName, WHATSAPP_KEY_PUSH_NAME, &dbv, DBVT_WCHAR))
+ if (getTString(hContact, WHATSAPP_KEY_PUSH_NAME, &dbv))
ib->defaultValue = _T("");
else
{
@@ -737,9 +720,9 @@ INT_PTR __cdecl WhatsAppProto::OnLeaveGroup(WPARAM wParam, LPARAM) {
DBVARIANT dbv;
HANDLE hContact = reinterpret_cast<HANDLE>(wParam);
- if (this->isOnline() && !db_get_s(hContact, m_szModuleName, WHATSAPP_KEY_ID, &dbv, DBVT_ASCIIZ))
+ if (this->isOnline() && !getString(hContact, WHATSAPP_KEY_ID, &dbv))
{
- db_set_b(hContact, m_szModuleName, "IsGroupMember", 0);
+ setByte(hContact, "IsGroupMember", 0);
this->connection->sendLeaveGroup(dbv.pszVal);
db_free(&dbv);
}
diff --git a/protocols/WhatsApp/src/db.h b/protocols/WhatsApp/src/db.h index ef2610e523..615d0d8608 100644 --- a/protocols/WhatsApp/src/db.h +++ b/protocols/WhatsApp/src/db.h @@ -1,18 +1,3 @@ -// DB macros
-#define getByte( setting, error ) db_get_b( NULL, m_szModuleName, setting, error )
-#define setByte( setting, value ) db_set_b( NULL, m_szModuleName, setting, value )
-#define getWord( setting, error ) db_get_w( NULL, m_szModuleName, setting, error )
-#define setWord( setting, value ) db_set_w( NULL, m_szModuleName, setting, value )
-#define getDword( setting, error ) db_get_dw( NULL, m_szModuleName, setting, error )
-#define setDword( setting, value ) db_set_dw( NULL, m_szModuleName, setting, value )
-#define getString( setting, dest ) db_get_s( NULL, m_szModuleName, setting, dest, DBVT_ASCIIZ )
-#define setString( setting, value ) db_set_s( NULL, m_szModuleName, setting, value )
-#define getTString( setting, dest ) DBGetContactSettingTString( NULL, m_szModuleName, setting, dest )
-#define setTString( setting, value ) DBWriteContactSettingTString( NULL, m_szModuleName, setting, value )
-#define getU8String( setting, dest ) DBGetContactSettingUTF8String( NULL, m_szModuleName, setting, dest )
-#define setU8String( setting, value ) DBWriteContactSettingUTF8String( NULL, m_szModuleName, setting, value )
-#define deleteSetting( setting ) DBDeleteContactSetting( NULL, m_szModuleName, setting )
-
// DB keys
#define WHATSAPP_KEY_ID "ID"
#define WHATSAPP_KEY_LOGIN "Login"
diff --git a/protocols/WhatsApp/src/dialogs.cpp b/protocols/WhatsApp/src/dialogs.cpp index 605537cb6d..21d3513e62 100644 --- a/protocols/WhatsApp/src/dialogs.cpp +++ b/protocols/WhatsApp/src/dialogs.cpp @@ -80,7 +80,7 @@ INT_PTR CALLBACK WhatsAppAccountProc(HWND hwnd, UINT message, WPARAM wparam, LPA if (!pw.empty())
{
CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(pw.c_str()), (LPARAM)pw.c_str());
- db_set_s(NULL, proto->ModuleName(), WHATSAPP_KEY_PASS, pw.c_str());
+ proto->setString(WHATSAPP_KEY_PASS, pw.c_str());
MessageBox(NULL, TranslateT("Your password has been set automatically.\nIf you change your password manually you may lose it and need to request a new code!"), PRODUCT_NAME, MB_ICONWARNING);
}
}
diff --git a/protocols/WhatsApp/src/messages.cpp b/protocols/WhatsApp/src/messages.cpp index 4dd3b10997..ba0b4210f5 100644 --- a/protocols/WhatsApp/src/messages.cpp +++ b/protocols/WhatsApp/src/messages.cpp @@ -58,21 +58,19 @@ void WhatsAppProto::SendMsgWorker(void* p) DBVARIANT dbv;
send_direct *data = static_cast<send_direct*>(p);
- if (db_get_b(data->hContact, m_szModuleName, "SimpleChatRoom", 0) > 0 &&
- db_get_b(data->hContact, m_szModuleName, "IsGroupMember", 0) == 0)
+ if (getByte(data->hContact, "SimpleChatRoom", 0) > 0 && getByte(data->hContact, "IsGroupMember", 0) == 0)
{
LOG("not a group member");
ProtoBroadcastAck(data->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED,
(HANDLE) (this->msgIdHeader + this->msgId), (LPARAM) "You cannot send messages to groups if you are not a member.");
}
- else if (!db_get_s(data->hContact, m_szModuleName,"ID", &dbv, DBVT_ASCIIZ) &&
- this->connection != NULL)
+ else if (!getString(data->hContact, "ID", &dbv) && this->connection != NULL)
{
try
{
- db_set_dw(data->hContact, m_szModuleName, WHATSAPP_KEY_LAST_MSG_STATE, 2);
- db_set_dw(data->hContact, m_szModuleName, WHATSAPP_KEY_LAST_MSG_ID_HEADER, this->msgIdHeader);
- db_set_dw(data->hContact, m_szModuleName, WHATSAPP_KEY_LAST_MSG_ID, this->msgId);
+ setDword(data->hContact, WHATSAPP_KEY_LAST_MSG_STATE, 2);
+ setDword(data->hContact, WHATSAPP_KEY_LAST_MSG_ID_HEADER, this->msgIdHeader);
+ setDword(data->hContact, WHATSAPP_KEY_LAST_MSG_ID, this->msgId);
std::stringstream ss;
ss << this->msgIdHeader << "-" << this->msgId;
@@ -147,18 +145,17 @@ void WhatsAppProto::SendTypingWorker(void* p) send_typing *typing = static_cast<send_typing*>(p);
// Don't send typing notifications to contacts which are offline
- if ( db_get_w(typing->hContact,m_szModuleName,"Status", 0) == ID_STATUS_OFFLINE)
+ if ( getWord(typing->hContact, "Status", 0) == ID_STATUS_OFFLINE)
return;
DBVARIANT dbv;
- if ( !db_get_s(typing->hContact,m_szModuleName,WHATSAPP_KEY_ID,&dbv, DBVT_ASCIIZ) &&
+ if ( !getString(typing->hContact, WHATSAPP_KEY_ID,&dbv) &&
this->isOnline())
{
- if (typing->status == PROTOTYPE_SELFTYPING_ON) {
+ if (typing->status == PROTOTYPE_SELFTYPING_ON)
this->connection->sendComposing(dbv.pszVal);
- } else {
+ else
this->connection->sendPaused(dbv.pszVal);
- }
}
delete typing;
@@ -191,10 +188,9 @@ void WhatsAppProto::onMessageStatusUpdate(FMessage* fmsg) if (state == 1)
ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE) (header + id),0);
- if (db_get_dw(hContact, m_szModuleName, WHATSAPP_KEY_LAST_MSG_ID_HEADER, 0) == header &&
- db_get_dw(hContact, m_szModuleName, WHATSAPP_KEY_LAST_MSG_ID, -1) == id)
+ if (getDword(hContact, WHATSAPP_KEY_LAST_MSG_ID_HEADER, 0) == header && getDword(hContact, WHATSAPP_KEY_LAST_MSG_ID, -1) == id)
{
- db_set_dw(hContact, m_szModuleName, WHATSAPP_KEY_LAST_MSG_STATE, state);
+ setDword(hContact, WHATSAPP_KEY_LAST_MSG_STATE, state);
this->UpdateStatusMsg(hContact);
}
}
\ No newline at end of file diff --git a/protocols/WhatsApp/src/proto.cpp b/protocols/WhatsApp/src/proto.cpp index 5a6cab3f85..5c2ffad18f 100644 --- a/protocols/WhatsApp/src/proto.cpp +++ b/protocols/WhatsApp/src/proto.cpp @@ -112,7 +112,7 @@ int WhatsAppProto::SetStatus( int new_status ) case ID_STATUS_IDLE:
default:
m_iDesiredStatus = ID_STATUS_INVISIBLE;
- if (db_get_b(NULL, m_szModuleName, WHATSAPP_KEY_MAP_STATUSES, DEFAULT_MAP_STATUSES))
+ if (getByte(WHATSAPP_KEY_MAP_STATUSES, DEFAULT_MAP_STATUSES))
break;
case ID_STATUS_ONLINE:
case ID_STATUS_FREECHAT:
@@ -183,7 +183,7 @@ string WhatsAppProto::Register(int state, string cc, string number, string code) return ret;
}
- if ( !db_get_s(NULL,m_szModuleName,WHATSAPP_KEY_IDX,&dbv,DBVT_ASCIIZ))
+ if ( !getString(WHATSAPP_KEY_IDX, &dbv))
{
idx = dbv.pszVal;
db_free(&dbv);
@@ -196,7 +196,7 @@ string WhatsAppProto::Register(int state, string cc, string number, string code) BYTE idxBuf[16];
utils::md5string(tm.str(), idxBuf);
idx = std::string((const char*) idxBuf, 16);
- db_set_s(0, m_szModuleName, WHATSAPP_KEY_IDX, idx.c_str());
+ setString(WHATSAPP_KEY_IDX, idx.c_str());
}
string url;
@@ -303,7 +303,7 @@ int WhatsAppProto::RequestFriendship(WPARAM wParam, LPARAM lParam) HANDLE hContact = reinterpret_cast<HANDLE>(wParam);
DBVARIANT dbv;
- if ( !db_get_s(hContact,m_szModuleName,WHATSAPP_KEY_ID,&dbv, DBVT_ASCIIZ))
+ if ( !getString(hContact, WHATSAPP_KEY_ID, &dbv))
{
std::string id(dbv.pszVal);
this->connection->sendQueryLastOnline(id);
diff --git a/protocols/WhatsApp/src/proto.h b/protocols/WhatsApp/src/proto.h index a143922df5..778db45ccf 100644 --- a/protocols/WhatsApp/src/proto.h +++ b/protocols/WhatsApp/src/proto.h @@ -131,7 +131,7 @@ public: bool IsGroupChat(HANDLE hC, bool checkIsAdmin = false)
{
- return db_get_b(hC, m_szModuleName, "SimpleChatRoom", 0) > (checkIsAdmin ? 1 : 0);
+ return getByte(hC, "SimpleChatRoom", 0) > (checkIsAdmin ? 1 : 0);
}
// Registration
diff --git a/protocols/WhatsApp/src/theme.cpp b/protocols/WhatsApp/src/theme.cpp index b293efe719..d292cf80a8 100644 --- a/protocols/WhatsApp/src/theme.cpp +++ b/protocols/WhatsApp/src/theme.cpp @@ -116,7 +116,7 @@ int WhatsAppProto::OnPrebuildContactMenu(WPARAM wParam,LPARAM lParam) if (g_hContactMenuItems[CMI_REMOVE_CONTACT_FROM_GROUP] != NULL)
CallService("CList/RemoveContactMenuItem", (WPARAM) g_hContactMenuItems[CMI_REMOVE_CONTACT_FROM_GROUP], (LPARAM) 0);
- int chatType = db_get_b(hContact, m_szModuleName, "SimpleChatRoom", 0);
+ int chatType = getByte(hContact, "SimpleChatRoom", 0);
CLISTMENUITEM mi = {sizeof(mi)};
@@ -149,8 +149,7 @@ int WhatsAppProto::OnPrebuildContactMenu(WPARAM wParam,LPARAM lParam) {
map<HANDLE, 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) &&
- !db_get_s(it->first, m_szModuleName, "ID", &dbv, DBVT_ASCIIZ))
+ if ((memberIt == it->second.end() || memberIt->second == false) && !getString(it->first, "ID", &dbv))
{
fullSvcName = svcName + dbv.pszVal;
mi.pszService = (char*) fullSvcName.c_str();
@@ -168,7 +167,7 @@ int WhatsAppProto::OnPrebuildContactMenu(WPARAM wParam,LPARAM lParam) else if (chatType == 1)
{
mi.flags = CMIM_FLAGS;
- if (!isOnline() || db_get_b(hContact, m_szModuleName, "IsGroupMember", 0) == 0)
+ if (!isOnline() || getByte(hContact, "IsGroupMember", 0) == 0)
mi.flags |= CMIF_GRAYED;
CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) g_hContactMenuItems[CMI_LEAVE_GROUP], (LPARAM) &mi);
}
@@ -183,7 +182,7 @@ int WhatsAppProto::OnPrebuildContactMenu(WPARAM wParam,LPARAM lParam) g_hContactMenuItems[CMI_REMOVE_CONTACT_FROM_GROUP] = Menu_AddContactMenuItem(&mi);
bool bShow = false;
- if (isOnline() && db_get_b(hContact, m_szModuleName, "IsGroupMember", 0) == 1)
+ if (isOnline() && getByte(hContact, "IsGroupMember", 0) == 1)
{
map<HANDLE, map<HANDLE, bool>>::iterator groupsIt = this->isMemberByGroupContact.find(hContact);
if (groupsIt == this->isMemberByGroupContact.end())
@@ -202,7 +201,7 @@ int WhatsAppProto::OnPrebuildContactMenu(WPARAM wParam,LPARAM lParam) for (map<HANDLE, bool>::iterator it = groupsIt->second.begin(); it != groupsIt->second.end(); ++it)
{
- if (!db_get_s(it->first, m_szModuleName, "ID", &dbv, DBVT_ASCIIZ))
+ if (!getString(it->first, "ID", &dbv))
{
fullSvcName = svcName + dbv.pszVal;
mi.pszService = (char*) fullSvcName.c_str();
|