summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp14
-rw-r--r--protocols/WhatsApp/src/contacts.cpp14
-rw-r--r--protocols/WhatsApp/src/dialogs.cpp30
-rw-r--r--protocols/WhatsApp/src/messages.cpp32
-rw-r--r--protocols/WhatsApp/src/version.h2
5 files changed, 44 insertions, 48 deletions
diff --git a/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp b/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp
index 9aa4450937..fcb659e97b 100644
--- a/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp
+++ b/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp
@@ -195,12 +195,8 @@ bool WAConnection::read() throw(WAException)
if (node == NULL)
return false;
- #ifdef _DEBUG
- {
- string tmp = node->toString();
- rawConn->log(tmp.c_str());
- }
- #endif
+ string tmp = node->toString();
+ rawConn->log(tmp.c_str());
if (ProtocolTreeNode::tagEquals(node, "iq"))
parseIq(node);
@@ -307,6 +303,7 @@ void WAConnection::parseMessage(ProtocolTreeNode *messageNode) throw (WAExceptio
const string &id = messageNode->getAttributeValue("id");
const string &attribute_t = messageNode->getAttributeValue("t");
const string &from = messageNode->getAttributeValue("from");
+ const string &notify = messageNode->getAttributeValue("notify");
const string &author = messageNode->getAttributeValue("author");
const string &typeAttribute = messageNode->getAttributeValue("type");
@@ -343,7 +340,7 @@ void WAConnection::parseMessage(ProtocolTreeNode *messageNode) throw (WAExceptio
if (receiptRequested)
sendSubjectReceived(from, id);
}
- else if (typeAttribute == "chat" || typeAttribute == "text") {
+ else if (typeAttribute == "text") {
FMessage fmessage;
fmessage.wants_receipt = false;
fmessage.timestamp = atoi(attribute_t.c_str());
@@ -354,7 +351,7 @@ void WAConnection::parseMessage(ProtocolTreeNode *messageNode) throw (WAExceptio
ProtocolTreeNode *childNode = messageChildren[i];
if (ProtocolTreeNode::tagEquals(childNode, "body")) {
fmessage.key = Key(from, false, id);
- fmessage.remote_resource = author;
+ fmessage.notifyname = notify;
fmessage.data = childNode->getDataAsString();
fmessage.status = FMessage::STATUS_UNSENT;
}
@@ -395,6 +392,7 @@ void WAConnection::parseMessage(ProtocolTreeNode *messageNode) throw (WAExceptio
}
fmessage.key = Key(from, false, id);
+ fmessage.notifyname = notify;
fmessage.remote_resource = author;
}
}
diff --git a/protocols/WhatsApp/src/contacts.cpp b/protocols/WhatsApp/src/contacts.cpp
index 0250420ed2..487afc6321 100644
--- a/protocols/WhatsApp/src/contacts.cpp
+++ b/protocols/WhatsApp/src/contacts.cpp
@@ -28,9 +28,10 @@ MCONTACT WhatsAppProto::AddToContactList(const std::string& jid, BYTE , bool don
oldName = dbv.pszVal;
db_free(&dbv);
}
- db_set_utf(hContact, m_szModuleName, WHATSAPP_KEY_NICK, new_name);
if (oldName.compare(string(new_name)) != 0) {
+ db_set_utf(hContact, m_szModuleName, WHATSAPP_KEY_NICK, new_name);
+
CMString tmp(FORMAT, TranslateT("is now known as '%s'"), ptrT(mir_utf8decodeT(new_name)));
this->NotifyEvent(_A2T(oldName.c_str()), tmp, hContact, WHATSAPP_EVENT_OTHER);
}
@@ -496,13 +497,10 @@ INT_PTR __cdecl WhatsAppProto::OnChangeGroupSubject(WPARAM hContact, LPARAM lPar
{
input_box* ib = new input_box;
- DBVARIANT dbv;
- if (getTString(hContact, WHATSAPP_KEY_NICK, &dbv))
- ib->defaultValue = _T("");
- else {
- ib->defaultValue = dbv.ptszVal;
- db_free(&dbv);
- }
+ ptrT szNick(getTStringA(hContact, WHATSAPP_KEY_NICK));
+ if (szNick != NULL)
+ ib->defaultValue = szNick;
+
ib->limit = WHATSAPP_GROUP_NAME_LIMIT;
ib->text = _T("Enter new group subject");
ib->title = _T("WhatsApp - Change Group Subject");
diff --git a/protocols/WhatsApp/src/dialogs.cpp b/protocols/WhatsApp/src/dialogs.cpp
index e00b69196e..0550dc4102 100644
--- a/protocols/WhatsApp/src/dialogs.cpp
+++ b/protocols/WhatsApp/src/dialogs.cpp
@@ -16,21 +16,16 @@ INT_PTR CALLBACK WhatsAppAccountProc(HWND hwndDlg, UINT message, WPARAM wparam,
SendDlgItemMessage(hwndDlg, IDC_PW, EM_LIMITTEXT, 3, 0);
SendDlgItemMessage(hwndDlg, IDC_PW2, EM_LIMITTEXT, 3, 0);
CheckDlgButton(hwndDlg, IDC_SSL, db_get_b(NULL, proto->m_szModuleName, WHATSAPP_KEY_SSL, 0) ? BST_CHECKED : BST_UNCHECKED);
- DBVARIANT dbv;
+ {
+ ptrA szStr(proto->getStringA(WHATSAPP_KEY_CC));
+ if (szStr != NULL)
+ SetDlgItemTextA(hwndDlg, IDC_CC, szStr);
- if (!db_get_s(0, proto->m_szModuleName, WHATSAPP_KEY_CC, &dbv, DBVT_ASCIIZ)) {
- SetDlgItemTextA(hwndDlg, IDC_CC, dbv.pszVal);
- db_free(&dbv);
- }
-
- if (!db_get_s(0, proto->m_szModuleName, WHATSAPP_KEY_LOGIN, &dbv, DBVT_ASCIIZ)) {
- SetDlgItemTextA(hwndDlg, IDC_LOGIN, dbv.pszVal);
- db_free(&dbv);
- }
+ if ((szStr = proto->getStringA(WHATSAPP_KEY_LOGIN)) != NULL)
+ SetDlgItemTextA(hwndDlg, IDC_LOGIN, szStr);
- if (!db_get_s(0, proto->m_szModuleName, WHATSAPP_KEY_NICK, &dbv, DBVT_ASCIIZ)) {
- SetDlgItemTextA(hwndDlg, IDC_NICK, dbv.pszVal);
- db_free(&dbv);
+ if ((szStr = proto->getStringA(WHATSAPP_KEY_NICK)) != NULL)
+ SetDlgItemTextA(hwndDlg, IDC_NICK, szStr);
}
EnableWindow(GetDlgItem(hwndDlg, IDC_PW), FALSE);
@@ -44,7 +39,6 @@ INT_PTR CALLBACK WhatsAppAccountProc(HWND hwndDlg, UINT message, WPARAM wparam,
SendDlgItemMessage(hwndDlg, IDC_PW2, EM_SETREADONLY, 1, 0);
EnableWindow(GetDlgItem(hwndDlg, IDC_SSL), FALSE);
}
-
return TRUE;
case WM_COMMAND:
@@ -108,15 +102,15 @@ INT_PTR CALLBACK WhatsAppAccountProc(HWND hwndDlg, UINT message, WPARAM wparam,
char str[128];
GetDlgItemTextA(hwndDlg, IDC_CC, str, SIZEOF(str));
- db_set_s(0, proto->m_szModuleName, WHATSAPP_KEY_CC, str);
+ proto->setString(WHATSAPP_KEY_CC, str);
GetDlgItemTextA(hwndDlg, IDC_LOGIN, str, SIZEOF(str));
- db_set_s(0, proto->m_szModuleName, WHATSAPP_KEY_LOGIN, str);
+ proto->setString(WHATSAPP_KEY_LOGIN, str);
GetDlgItemTextA(hwndDlg, IDC_NICK, str, SIZEOF(str));
- db_set_s(0, proto->m_szModuleName, WHATSAPP_KEY_NICK, str);
+ proto->setString(WHATSAPP_KEY_NICK, str);
- db_set_b(0, proto->m_szModuleName, WHATSAPP_KEY_SSL, IsDlgButtonChecked(hwndDlg, IDC_SSL));
+ proto->setByte(WHATSAPP_KEY_SSL, IsDlgButtonChecked(hwndDlg, IDC_SSL));
return TRUE;
}
break;
diff --git a/protocols/WhatsApp/src/messages.cpp b/protocols/WhatsApp/src/messages.cpp
index d2f170a020..37b2ebad65 100644
--- a/protocols/WhatsApp/src/messages.cpp
+++ b/protocols/WhatsApp/src/messages.cpp
@@ -121,18 +121,24 @@ void WhatsAppProto::onMessageStatusUpdate(FMessage* fmsg)
if (hContact == 0)
return;
- if (fmsg->status == FMessage::STATUS_RECEIVED_BY_SERVER) {
- size_t delim = fmsg->key.id.find('-');
- if (delim == string::npos)
- return;
-
- int msgId = atoi(fmsg->key.id.substr(delim+1).c_str());
- ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)msgId, 0);
-
- time_t timestamp = atol(fmsg->key.id.substr(0, delim).c_str());
-
- TCHAR ttime[64];
- _tcsftime(ttime, SIZEOF(ttime), _T("%X"), localtime(&timestamp));
- utils::setStatusMessage(hContact, CMString(FORMAT, TranslateT("Message received: %s by %s"), ttime, pcli->pfnGetContactDisplayName(hContact, 0)));
+ const TCHAR *ptszBy;
+ switch (fmsg->status) {
+ case FMessage::STATUS_RECEIVED_BY_SERVER: ptszBy = TranslateT("server"); break;
+ case FMessage::STATUS_RECEIVED_BY_TARGET: ptszBy = pcli->pfnGetContactDisplayName(hContact, 0); break;
+ default:
+ return;
}
+
+ size_t delim = fmsg->key.id.find('-');
+ if (delim == string::npos)
+ return;
+
+ int msgId = atoi(fmsg->key.id.substr(delim+1).c_str());
+ ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)msgId, 0);
+
+ time_t timestamp = atol(fmsg->key.id.substr(0, delim).c_str());
+
+ TCHAR ttime[64];
+ _tcsftime(ttime, SIZEOF(ttime), _T("%X"), localtime(&timestamp));
+ utils::setStatusMessage(hContact, CMString(FORMAT, TranslateT("Message received: %s by %s"), ttime, ptszBy));
}
diff --git a/protocols/WhatsApp/src/version.h b/protocols/WhatsApp/src/version.h
index 6d60ffbd86..f762aa15d7 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 4
+#define __BUILD_NUM 5
#include <stdver.h>