summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-06-24 15:52:53 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-06-24 15:52:53 +0000
commit539b80cc27668922592364c5f2c33cf802414573 (patch)
treebb17aeec9c67f0b79efa4fbfbe4941f01228c850
parentb40015c18a9acd7272d850df4389de98009a91f4 (diff)
minor optimization
git-svn-id: http://svn.miranda-ng.org/main/trunk@5123 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--protocols/WhatsApp/src/proto.cpp50
1 files changed, 12 insertions, 38 deletions
diff --git a/protocols/WhatsApp/src/proto.cpp b/protocols/WhatsApp/src/proto.cpp
index de7835cd86..1c8fab0515 100644
--- a/protocols/WhatsApp/src/proto.cpp
+++ b/protocols/WhatsApp/src/proto.cpp
@@ -166,6 +166,15 @@ HANDLE WhatsAppProto::SearchBasic( const PROTOCHAR* id )
return email;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static NETLIBHTTPHEADER s_registerHeaders[] =
+{
+ { "User-Agent", ACCOUNT_USER_AGENT_REGISTRATION },
+ { "Accept", "text/json" },
+ { "Content-Type", "application/x-www-form-urlencoded" }
+};
+
string WhatsAppProto::Register(int state, string cc, string number, string code)
{
string idx;
@@ -178,33 +187,12 @@ string WhatsAppProto::Register(int state, string cc, string number, string code)
return ret;
}
- /*
- if ( !db_get_s(NULL,m_szModuleName,WHATSAPP_KEY_CC,&dbv, DBVT_ASCIIZ))
- {
- cc = dbv.pszVal;
- db_free(&dbv);
- if (cc.empty())
- {
- NotifyEvent(m_tszUserName,TranslateT("Please enter a country-code."),NULL,WHATSAPP_EVENT_CLIENT);
- return;
- }
- }
- if ( !db_get_s(NULL,m_szModuleName,WHATSAPP_KEY_LOGIN,&dbv, DBVT_ASCIIZ))
- {
- number = dbv.pszVal;
- db_free(&dbv);
- if (number.empty())
- {
- NotifyEvent(m_tszUserName,TranslateT("Please enter a phone-number without country-code."),NULL,WHATSAPP_EVENT_CLIENT);
- return;
- }
- }
- */
if ( !db_get_s(NULL,m_szModuleName,WHATSAPP_KEY_IDX,&dbv,DBVT_ASCIIZ))
{
idx = dbv.pszVal;
db_free(&dbv);
}
+
if (idx.empty())
{
std::stringstream tm;
@@ -230,25 +218,11 @@ string WhatsAppProto::Register(int state, string cc, string number, string code)
}
url += "&cc="+ cc +"&in="+ number +"&id="+ idx;
- NETLIBHTTPHEADER agentHdr;
- agentHdr.szName = "User-Agent";
- agentHdr.szValue = ACCOUNT_USER_AGENT_REGISTRATION;
-
- NETLIBHTTPHEADER acceptHdr;
- acceptHdr.szName = "Accept";
- acceptHdr.szValue = "text/json";
-
- NETLIBHTTPHEADER ctypeHdr;
- ctypeHdr.szName = "Content-Type";
- ctypeHdr.szValue = "application/x-www-form-urlencoded";
-
- NETLIBHTTPHEADER headers[] = { agentHdr, acceptHdr, ctypeHdr };
-
NETLIBHTTPREQUEST nlhr = {sizeof(NETLIBHTTPREQUEST)};
nlhr.requestType = REQUEST_POST;
nlhr.szUrl = (char*) url.c_str();
- nlhr.headers = &headers[0];
- nlhr.headersCount = 3;
+ nlhr.headers = s_registerHeaders;
+ nlhr.headersCount = SIZEOF(s_registerHeaders);
nlhr.flags = NLHRF_HTTP11 | NLHRF_GENERATEHOST | NLHRF_REMOVEHOST | NLHRF_SSL;
NETLIBHTTPREQUEST* pnlhr = (NETLIBHTTPREQUEST*) CallService(MS_NETLIB_HTTPTRANSACTION,