diff options
Diffstat (limited to 'plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp')
-rw-r--r-- | plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp b/plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp index 21730d165f..10be0bfc49 100644 --- a/plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp +++ b/plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp @@ -57,27 +57,27 @@ int CSendHost_Imgur::Send() void CSendHost_Imgur::SendThread(void* obj) { - CSendHost_Imgur* self = (CSendHost_Imgur*)obj; + CSendHost_Imgur *self = (CSendHost_Imgur*)obj; // send DATA and wait for m_nlreply - NETLIBHTTPREQUEST* reply = Netlib_HttpTransaction(g_hNetlibUser, &self->m_nlhr); + NETLIBHTTPREQUEST *reply = Netlib_HttpTransaction(g_hNetlibUser, &self->m_nlhr); self->HTTPFormDestroy(&self->m_nlhr); if (reply) { if (reply->dataLength) { - char buf[128]; - - if (GetJSONBool(reply->pData, reply->dataLength, "success")) { - GetJSONString(reply->pData, reply->dataLength, "data[link]", buf, sizeof(buf)); - - self->m_URL = buf; - int idx = self->m_URL.ReverseFind('.'); - if (idx != -1) { - self->m_URLthumb = self->m_URL; - self->m_URLthumb.Insert(idx, 'm'); + JSONROOT root(reply->pData); + if (root) { + if ((*root)["success"].as_bool()) { + self->m_URL = (*root)["data"]["link"].as_mstring(); + int idx = self->m_URL.ReverseFind('.'); + if (idx != -1) { + self->m_URLthumb = self->m_URL; + self->m_URLthumb.Insert(idx, 'm'); + } + Netlib_FreeHttpRequest(reply); + self->svcSendMsgExit(self->m_URL); return; } - Netlib_FreeHttpRequest(reply); - self->svcSendMsgExit(self->m_URL); return; + else self->Error(SS_ERR_RESPONSE, self->m_pszSendTyp, (*root)["status"].as_int(), 0); } - else self->Error(SS_ERR_RESPONSE, self->m_pszSendTyp, GetJSONInteger(reply->pData, reply->dataLength, "status", 0)); + else self->Error(SS_ERR_RESPONSE, self->m_pszSendTyp, reply->resultCode); } else self->Error(SS_ERR_RESPONSE, self->m_pszSendTyp, reply->resultCode); |