diff options
| -rw-r--r-- | include/m_netlib.h | 1 | ||||
| -rw-r--r-- | protocols/Facebook/src/db.h | 10 | ||||
| -rw-r--r-- | protocols/Facebook/src/groupchats.cpp | 4 | ||||
| -rw-r--r-- | protocols/Facebook/src/server.cpp | 14 | ||||
| -rw-r--r-- | protocols/SkypeWeb/src/skype_avatars.cpp | 2 | ||||
| -rw-r--r-- | protocols/SkypeWeb/src/skype_chatrooms.cpp | 4 | ||||
| -rw-r--r-- | protocols/SkypeWeb/src/skype_contacts.cpp | 4 | ||||
| -rw-r--r-- | protocols/SkypeWeb/src/skype_files.cpp | 2 | ||||
| -rw-r--r-- | protocols/SkypeWeb/src/skype_history_sync.cpp | 4 | ||||
| -rw-r--r-- | protocols/SkypeWeb/src/skype_profile.cpp | 2 | ||||
| -rw-r--r-- | protocols/SkypeWeb/src/skype_search.cpp | 2 | ||||
| -rw-r--r-- | protocols/SkypeWeb/src/skype_utils.h | 10 | ||||
| -rw-r--r-- | protocols/Weather/src/stdafx.h | 9 | ||||
| -rw-r--r-- | protocols/Weather/src/weather_addstn.cpp | 2 | ||||
| -rw-r--r-- | protocols/Weather/src/weather_update.cpp | 2 | ||||
| -rw-r--r-- | src/mir_app/src/MHttpResponse.cpp | 2 |
16 files changed, 51 insertions, 23 deletions
diff --git a/include/m_netlib.h b/include/m_netlib.h index 71e2696c4f..f02d1e890f 100644 --- a/include/m_netlib.h +++ b/include/m_netlib.h @@ -505,6 +505,7 @@ public: class MIR_APP_EXPORT JsonReply : public MNonCopyable
{
+protected:
class JSONNode *m_root = nullptr;
int m_errorCode = 0;
diff --git a/protocols/Facebook/src/db.h b/protocols/Facebook/src/db.h index 1842fc390a..3d75fae2fb 100644 --- a/protocols/Facebook/src/db.h +++ b/protocols/Facebook/src/db.h @@ -42,3 +42,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. // Hidden account DB keys (can't be changed through GUI)
#define DBKEY_LOCALE "Locale" // [HIDDEN] - (string) en_US, cs_CZ, etc. (requires restart to apply)
+
+struct FbReply : public JsonReply
+{
+ FbReply(MHttpResponse *response) :
+ JsonReply(response)
+ {
+ if (m_root)
+ m_errorCode = (*m_root)["error_code"].as_int();
+ }
+};
diff --git a/protocols/Facebook/src/groupchats.cpp b/protocols/Facebook/src/groupchats.cpp index 047bee95e1..cc20fceb4e 100644 --- a/protocols/Facebook/src/groupchats.cpp +++ b/protocols/Facebook/src/groupchats.cpp @@ -87,7 +87,7 @@ public: pReq << CHAR_PARAM("to", list.write().c_str()) << WCHAR_PARAM("id", CMStringW(FORMAT, L"t_%s", m_si->ptszID));
pReq->CalcSig();
- JsonReply reply(m_proto->ExecuteRequest(pReq));
+ FbReply reply(m_proto->ExecuteRequest(pReq));
return true;
}
};
@@ -233,7 +233,7 @@ int FacebookProto::Chat_KickUser(SESSION_INFO *si, const wchar_t *pwszUid) }
pReq->CalcSig();
- JsonReply reply(ExecuteRequest(pReq));
+ FbReply reply(ExecuteRequest(pReq));
return reply.error();
}
diff --git a/protocols/Facebook/src/server.cpp b/protocols/Facebook/src/server.cpp index f660fee8bd..6eebad7ec8 100644 --- a/protocols/Facebook/src/server.cpp +++ b/protocols/Facebook/src/server.cpp @@ -157,7 +157,7 @@ int FacebookProto::RefreshContacts() pReq->flags |= NLHRF_NODUMPSEND;
pReq->CalcSig();
- JsonReply reply(ExecuteRequest(pReq));
+ FbReply reply(ExecuteRequest(pReq));
if (int iErrorCode = reply.error())
return iErrorCode; // unknown error
@@ -238,7 +238,7 @@ bool FacebookProto::RefreshSid() pReq << CHAR_PARAM("query_params", root.write().c_str());
pReq->CalcSig();
- JsonReply reply(ExecuteRequest(pReq));
+ FbReply reply(ExecuteRequest(pReq));
if (reply.error())
return false;
@@ -320,7 +320,7 @@ FacebookUser* FacebookProto::RefreshThread(CMStringW &wszId) pReq << WCHAR_PARAM("query_params", CMStringW(FORMAT, L"{\"0\":[\"%s\"], \"12\":0, \"13\":\"false\"}", wszId.c_str()));
pReq->CalcSig();
- JsonReply reply(ExecuteRequest(pReq));
+ FbReply reply(ExecuteRequest(pReq));
if (!reply.error()) {
auto &root = reply.data();
for (auto &n : root)
@@ -339,7 +339,7 @@ void FacebookProto::RefreshThreads() pReq << CHAR_PARAM("query_params", json.write().c_str());
pReq->CalcSig();
- JsonReply reply(ExecuteRequest(pReq));
+ FbReply reply(ExecuteRequest(pReq));
if (!reply.error()) {
auto &root = reply.data()["viewer"]["message_threads"];
@@ -361,7 +361,7 @@ int FacebookProto::RefreshToken() pReq << CHAR_PARAM("password", getMStringA(DBKEY_PASS));
pReq->CalcSig();
- JsonReply reply(ExecuteRequest(pReq));
+ FbReply reply(ExecuteRequest(pReq));
if (reply.error())
return reply.error();
@@ -659,7 +659,7 @@ void FacebookProto::FetchAttach(const CMStringA &mid, __int64 fbid, CMStringA &s pReq << CHAR_PARAM("mid", mid) << INT64_PARAM("aid", fbid);
pReq->CalcSig();
- JsonReply reply(ExecuteRequest(pReq));
+ FbReply reply(ExecuteRequest(pReq));
switch (reply.error()) {
case 0:
{
@@ -751,7 +751,7 @@ void FacebookProto::OnPublishPrivateMessage(const JSONNode &root) pReq << CHAR_PARAM("query_params", CMStringA(FORMAT, "{\"0\":[\"%s\"]}", stickerId.c_str()));
pReq->CalcSig();
- JsonReply reply(ExecuteRequest(pReq));
+ FbReply reply(ExecuteRequest(pReq));
if (!reply.error()) {
for (auto &sticker : reply.data()) {
std::string szUrl = sticker["thread_image"]["uri"].as_string();
diff --git a/protocols/SkypeWeb/src/skype_avatars.cpp b/protocols/SkypeWeb/src/skype_avatars.cpp index 2b5ce586fa..67fa2f4d3a 100644 --- a/protocols/SkypeWeb/src/skype_avatars.cpp +++ b/protocols/SkypeWeb/src/skype_avatars.cpp @@ -191,7 +191,7 @@ struct SetAvatarRequest : public AsyncHttpRequest void CSkypeProto::OnSentAvatar(MHttpResponse *response, AsyncHttpRequest*)
{
- JsonReply root(response);
+ SkypeReply root(response);
if (root.error())
return;
}
diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp index dc8cf49007..498ed4458d 100644 --- a/protocols/SkypeWeb/src/skype_chatrooms.cpp +++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp @@ -353,7 +353,7 @@ void CSkypeProto::SendChatMessage(SESSION_INFO *si, const wchar_t *tszMessage) void CSkypeProto::OnGetChatMembers(MHttpResponse *response, AsyncHttpRequest *pRequest)
{
- JsonReply reply(response);
+ SkypeReply reply(response);
if (reply.error())
return;
@@ -375,7 +375,7 @@ void CSkypeProto::OnGetChatMembers(MHttpResponse *response, AsyncHttpRequest *pR void CSkypeProto::OnGetChatInfo(MHttpResponse *response, AsyncHttpRequest*)
{
- JsonReply reply(response);
+ SkypeReply reply(response);
if (reply.error())
return;
diff --git a/protocols/SkypeWeb/src/skype_contacts.cpp b/protocols/SkypeWeb/src/skype_contacts.cpp index daed188bb2..c70a432005 100644 --- a/protocols/SkypeWeb/src/skype_contacts.cpp +++ b/protocols/SkypeWeb/src/skype_contacts.cpp @@ -102,7 +102,7 @@ MCONTACT CSkypeProto::AddContact(const char *skypeId, const char *nick, bool isT void CSkypeProto::LoadContactsAuth(MHttpResponse *response, AsyncHttpRequest*)
{
- JsonReply reply(response);
+ SkypeReply reply(response);
if (reply.error())
return;
@@ -140,7 +140,7 @@ void CSkypeProto::LoadContactsAuth(MHttpResponse *response, AsyncHttpRequest*) void CSkypeProto::LoadContactList(MHttpResponse *response, AsyncHttpRequest*)
{
- JsonReply reply(response);
+ SkypeReply reply(response);
if (reply.error())
return;
diff --git a/protocols/SkypeWeb/src/skype_files.cpp b/protocols/SkypeWeb/src/skype_files.cpp index 41608e3c8b..e1c59cac7d 100644 --- a/protocols/SkypeWeb/src/skype_files.cpp +++ b/protocols/SkypeWeb/src/skype_files.cpp @@ -48,7 +48,7 @@ void CSkypeProto::ReceiveFileThread(void *param) nlhr.AddHeader("Cookie", szCookie);
NLHR_PTR response(Netlib_HttpTransaction(m_hNetlibUser, &nlhr));
if (response) {
- JsonReply reply(response);
+ SkypeReply reply(response);
if (!reply.error()) {
auto &root = reply.data();
if (root["content_state"].as_string() == "ready")
diff --git a/protocols/SkypeWeb/src/skype_history_sync.cpp b/protocols/SkypeWeb/src/skype_history_sync.cpp index ffa7b7292e..33d48aff12 100644 --- a/protocols/SkypeWeb/src/skype_history_sync.cpp +++ b/protocols/SkypeWeb/src/skype_history_sync.cpp @@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. void CSkypeProto::OnGetServerHistory(MHttpResponse *response, AsyncHttpRequest *pRequest)
{
- JsonReply reply(response);
+ SkypeReply reply(response);
if (reply.error())
return;
@@ -96,7 +96,7 @@ INT_PTR CSkypeProto::SvcLoadHistory(WPARAM hContact, LPARAM) void CSkypeProto::OnSyncConversations(MHttpResponse *response, AsyncHttpRequest*)
{
- JsonReply reply(response);
+ SkypeReply reply(response);
if (reply.error())
return;
diff --git a/protocols/SkypeWeb/src/skype_profile.cpp b/protocols/SkypeWeb/src/skype_profile.cpp index 5bfcd49513..f06b22102c 100644 --- a/protocols/SkypeWeb/src/skype_profile.cpp +++ b/protocols/SkypeWeb/src/skype_profile.cpp @@ -105,7 +105,7 @@ void CSkypeProto::LoadProfile(MHttpResponse *response, AsyncHttpRequest *pReques {
MCONTACT hContact = (DWORD_PTR)pRequest->pUserInfo;
- JsonReply reply(response);
+ SkypeReply reply(response);
if (reply.error()) {
ProtoBroadcastAck(hContact, ACKTYPE_GETINFO, ACKRESULT_FAILED, 0);
return;
diff --git a/protocols/SkypeWeb/src/skype_search.cpp b/protocols/SkypeWeb/src/skype_search.cpp index 67c5ffbcfa..80029f4754 100644 --- a/protocols/SkypeWeb/src/skype_search.cpp +++ b/protocols/SkypeWeb/src/skype_search.cpp @@ -34,7 +34,7 @@ void CSkypeProto::OnSearch(MHttpResponse *response, AsyncHttpRequest*) {
debugLogA(__FUNCTION__);
- JsonReply reply(response);
+ SkypeReply reply(response);
if (reply.error()) {
ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)1, 0);
return;
diff --git a/protocols/SkypeWeb/src/skype_utils.h b/protocols/SkypeWeb/src/skype_utils.h index aecb8f66fe..7ea1e290dd 100644 --- a/protocols/SkypeWeb/src/skype_utils.h +++ b/protocols/SkypeWeb/src/skype_utils.h @@ -60,4 +60,14 @@ struct CFileUploadParam : public MZeroedObject }
};
+struct SkypeReply : public JsonReply
+{
+ SkypeReply(MHttpResponse *response) :
+ JsonReply(response)
+ {
+ if (m_root)
+ m_errorCode = (*m_root)["status"]["code"].as_int();
+ }
+};
+
#endif //_UTILS_H_
diff --git a/protocols/Weather/src/stdafx.h b/protocols/Weather/src/stdafx.h index 96e5410c71..eec03bd13e 100644 --- a/protocols/Weather/src/stdafx.h +++ b/protocols/Weather/src/stdafx.h @@ -113,6 +113,15 @@ enum EWeatherCondition #define SM_WEATHERALERT 16
#define WM_UPDATEDATA (WM_USER + 2687)
+struct WeatherReply : public JsonReply
+{
+ WeatherReply(MHttpResponse *response) :
+ JsonReply(response)
+ {
+ delete response;
+ }
+};
+
/////////////////////////////////////////////////////////////////////////////////////////
// GLOBAL VARIABLES
diff --git a/protocols/Weather/src/weather_addstn.cpp b/protocols/Weather/src/weather_addstn.cpp index 90c60ab68b..1bdfb9b49d 100644 --- a/protocols/Weather/src/weather_addstn.cpp +++ b/protocols/Weather/src/weather_addstn.cpp @@ -204,7 +204,7 @@ HANDLE CWeatherProto::SearchAdvanced(MWindow hwndOwner) int CWeatherProto::IDSearch(wchar_t *sID, int searchId) { - JsonReply reply(RunQuery(sID, 0)); + WeatherReply reply(RunQuery(sID, 0)); if (reply) { auto &data = reply.data(); CMStringW id(FORMAT, L"%lf, %lf", data["latitude"].as_float(), data["longitude"].as_float()); diff --git a/protocols/Weather/src/weather_update.cpp b/protocols/Weather/src/weather_update.cpp index d3a3fdfb90..15713e110e 100644 --- a/protocols/Weather/src/weather_update.cpp +++ b/protocols/Weather/src/weather_update.cpp @@ -411,7 +411,7 @@ int CWeatherProto::GetWeatherData(MCONTACT hContact) uint16_t cond = NA; // download the html file from the internet - JsonReply reply(RunQuery(id, 7)); + WeatherReply reply(RunQuery(id, 7)); if (!reply) return reply.error(); diff --git a/src/mir_app/src/MHttpResponse.cpp b/src/mir_app/src/MHttpResponse.cpp index 4a27d794df..249c25173b 100644 --- a/src/mir_app/src/MHttpResponse.cpp +++ b/src/mir_app/src/MHttpResponse.cpp @@ -51,8 +51,6 @@ JsonReply::JsonReply(MHttpResponse *pReply) m_errorCode = 500; return; } - - m_errorCode = (*m_root)["status"]["code"].as_int(); } JsonReply::~JsonReply() |
