|
@@ -4,9 +4,11 @@
|
|
#include "Global.h"
|
|
#include "Global.h"
|
|
#include "DataImpl.h"
|
|
#include "DataImpl.h"
|
|
#include <sys/stat.h>
|
|
#include <sys/stat.h>
|
|
|
|
+#include "CharEncoding.h"
|
|
|
|
|
|
ThreadSection g_csTask;
|
|
ThreadSection g_csTask;
|
|
std::list<STMid> CSDK::m_vtMidTask;
|
|
std::list<STMid> CSDK::m_vtMidTask;
|
|
|
|
+std::string CSDK::_host;
|
|
|
|
|
|
CSDK::CSDK(void):
|
|
CSDK::CSDK(void):
|
|
m_hDownloadEvent(NULL),
|
|
m_hDownloadEvent(NULL),
|
|
@@ -406,6 +408,91 @@ int CSDK::GetMidInfo(std::string order, STMid &mid)
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+BOOL CSDK::HttpPost(std::string host, std::string context, std::string &result, DATATYPE dt)
|
|
|
|
+{
|
|
|
|
+ CCurlClient curl;
|
|
|
|
+ curl.Initialize();
|
|
|
|
+ CharEncoding::ASCII2UTF8(context.c_str(), context);
|
|
|
|
+ curl.SetHeaders("Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/x-silverlight, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*");
|
|
|
|
+ curl.SetHeaders("Accept-Language: zh-cn");
|
|
|
|
+ if (dt == DATA_JSON)
|
|
|
|
+ curl.SetHeaders("Content-Type: application/json;charset=utf-8");
|
|
|
|
+
|
|
|
|
+ int nRecCode = CURLE_OK;
|
|
|
|
+ if (_tcsstr(host.c_str(), "https://"))
|
|
|
|
+ nRecCode = curl.Posts(host, context, result);
|
|
|
|
+ else
|
|
|
|
+ nRecCode = curl.Posts(host, context, result);
|
|
|
|
+
|
|
|
|
+ result = CharEncoding::DeCode_URLUTF8(result.c_str());
|
|
|
|
+
|
|
|
|
+ return CURLE_OK == nRecCode;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+BOOL CSDK::GetBidInfo(std::string order, std::string macs)
|
|
|
|
+{
|
|
|
|
+ // Json数据;
|
|
|
|
+ cJSON *pJson = cJSON_CreateObject();
|
|
|
|
+ cJSON_AddStringToObject(pJson, "clientType", "");
|
|
|
|
+ cJSON_AddStringToObject(pJson, "version", "");
|
|
|
|
+ cJSON_AddStringToObject(pJson, "mac", macs.c_str());
|
|
|
|
+ cJSON_AddStringToObject(pJson, "bid", order.c_str());
|
|
|
|
+ char *pJsonText = cJSON_Print(pJson);
|
|
|
|
+
|
|
|
|
+ // post请求;
|
|
|
|
+ std::string name, type;
|
|
|
|
+ std::string host, result, context;
|
|
|
|
+ context = pJsonText;
|
|
|
|
+
|
|
|
|
+ if (pJsonText)
|
|
|
|
+ delete pJsonText;
|
|
|
|
+ pJsonText = NULL;
|
|
|
|
+ cJSON_Delete(pJson);
|
|
|
|
+ pJson = NULL;
|
|
|
|
+
|
|
|
|
+ std::string code, message;
|
|
|
|
+ host = Global::g_bTestHost ? _T("http://test.admin.uc.qhmoka.com/scbc-server/clientType/getMessage.do") : _T("https://cn.uc.qhmoka.com/scbc-server/clientType/getMessage.do");
|
|
|
|
+ BOOL bRet = HttpPost(host, context, result, DATA_JSON);
|
|
|
|
+ if (!bRet)
|
|
|
|
+ {
|
|
|
|
+ goto end;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 解析返回值;
|
|
|
|
+ pJson = cJSON_Parse(result.c_str());
|
|
|
|
+ if (pJson == NULL)
|
|
|
|
+ {
|
|
|
|
+ bRet = FALSE;
|
|
|
|
+ goto end;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ message = cJSON_GetObjectItem(pJson, "message") ? cJSON_GetObjectItem(pJson, "message")->valuestring : "";
|
|
|
|
+ code = cJSON_GetObjectItem(pJson, "code") ? cJSON_GetObjectItem(pJson, "code")->valuestring : "";
|
|
|
|
+ _host = cJSON_GetObjectItem(pJson, "host") ? (cJSON_GetObjectItem(pJson, "host")->valuestring != NULL ? cJSON_GetObjectItem(pJson, "host")->valuestring : "") : "";
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (_tcsicmp(code.c_str(), "1000") != 0)
|
|
|
|
+ {
|
|
|
|
+ bRet = FALSE;
|
|
|
|
+ goto end;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (_host.size() == 0)
|
|
|
|
+ {
|
|
|
|
+ bRet = FALSE;
|
|
|
|
+ goto end;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+end:
|
|
|
|
+ // 释放Json;
|
|
|
|
+ if (pJsonText)
|
|
|
|
+ delete pJsonText;
|
|
|
|
+ pJsonText = NULL;
|
|
|
|
+ cJSON_Delete(pJson);
|
|
|
|
+
|
|
|
|
+ return bRet;
|
|
|
|
+}
|
|
|
|
+
|
|
int CSDK::ReportDownloadStatus(std::string order)
|
|
int CSDK::ReportDownloadStatus(std::string order)
|
|
{
|
|
{
|
|
// http获取mid;
|
|
// http获取mid;
|