summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2015-07-29 18:50:37 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2015-07-29 18:50:37 +0000
commit2afddc4305325447f91d879af7d5c4c280257867 (patch)
tree768293d3378dc33da532e22d9b99e19ca0323680
parent09f41999e99c45c0948d08f474682a85504a48df (diff)
SkypeWeb: code optimization
git-svn-id: http://svn.miranda-ng.org/main/trunk@14754 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--protocols/SkypeWeb/src/requests/capabilities.h36
-rw-r--r--protocols/SkypeWeb/src/requests/chatrooms.h47
-rw-r--r--protocols/SkypeWeb/src/requests/login.h5
-rw-r--r--protocols/SkypeWeb/src/requests/messages.h39
-rw-r--r--protocols/SkypeWeb/src/requests/status.h2
-rw-r--r--protocols/SkypeWeb/src/requests/subscriptions.h35
-rw-r--r--protocols/SkypeWeb/src/requests/trouter.h53
-rw-r--r--protocols/SkypeWeb/src/skype_chatrooms.cpp1
-rw-r--r--protocols/SkypeWeb/src/skype_db.cpp32
9 files changed, 127 insertions, 123 deletions
diff --git a/protocols/SkypeWeb/src/requests/capabilities.h b/protocols/SkypeWeb/src/requests/capabilities.h
index bc965e5a9b..bfdc6a5a60 100644
--- a/protocols/SkypeWeb/src/requests/capabilities.h
+++ b/protocols/SkypeWeb/src/requests/capabilities.h
@@ -29,24 +29,24 @@ public:
<< CHAR_VALUE("Content-Type", "application/json; charset=UTF-8")
<< FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken);
- JSONNode privateInfo(JSON_NODE);
- privateInfo.set_name("privateInfo");
- privateInfo.push_back(JSONNode("epname", hostname));
-
- JSONNode publicInfo(JSON_NODE);
- publicInfo.set_name("publicInfo");
- publicInfo.push_back(JSONNode("capabilities", "Audio|Video"));
- publicInfo.push_back(JSONNode("typ", 125));
- publicInfo.push_back(JSONNode("skypeNameVersion", "Miranda NG Skype"));
- publicInfo.push_back(JSONNode("nodeInfo", "xx"));
- publicInfo.push_back(JSONNode("version", g_szMirVer));
-
- JSONNode node(JSON_NODE);
- node.push_back(JSONNode("id", "messagingService"));
- node.push_back(JSONNode("type", "EndpointPresenceDoc"));
- node.push_back(JSONNode("selfLink", "uri"));
- node.push_back(privateInfo);
- node.push_back(publicInfo);
+ JSONNode privateInfo; privateInfo.set_name("privateInfo");
+ privateInfo << JSONNode("epname", hostname);
+
+ JSONNode publicInfo; publicInfo.set_name("publicInfo");
+ publicInfo
+ << JSONNode("capabilities", "Audio|Video")
+ << JSONNode("typ", 125)
+ << JSONNode("skypeNameVersion", "Miranda NG Skype")
+ << JSONNode("nodeInfo", "xx")
+ << JSONNode("version", g_szMirVer);
+
+ JSONNode node;
+ node
+ << JSONNode("id", "messagingService")
+ << JSONNode("type", "EndpointPresenceDoc")
+ << JSONNode("selfLink", "uri")
+ << privateInfo
+ << publicInfo;
Body << VALUE(node.write().c_str());
}
diff --git a/protocols/SkypeWeb/src/requests/chatrooms.h b/protocols/SkypeWeb/src/requests/chatrooms.h
index 1062b9f4b7..3a5b28c111 100644
--- a/protocols/SkypeWeb/src/requests/chatrooms.h
+++ b/protocols/SkypeWeb/src/requests/chatrooms.h
@@ -48,11 +48,12 @@ public:
<< FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken)
<< CHAR_VALUE("Content-Type", "application/json; charset=UTF-8");
- JSONNode node(JSON_NODE);
- node.push_back(JSONNode("clientmessageid", (long)timestamp));
- node.push_back(JSONNode("messagetype", "RichText"));
- node.push_back(JSONNode("contenttype", "text"));
- node.push_back(JSONNode("content", message));
+ JSONNode node;
+ node
+ << JSONNode("clientmessageid", (long)timestamp)
+ << JSONNode("messagetype", "RichText")
+ << JSONNode("contenttype", "text")
+ << JSONNode("content", message);
Body << VALUE(node.write().c_str());
}
@@ -70,11 +71,12 @@ public:
<< CHAR_VALUE("Content-Type", "application/json; charset=UTF-8");
JSONNode node(JSON_NODE);
- node.push_back(JSONNode("clientmessageid", (long)timestamp));
- node.push_back(JSONNode("messagetype", "RichText"));
- node.push_back(JSONNode("contenttype", "text"));
- node.push_back(JSONNode("content", message));
- node.push_back(JSONNode("skypeemoteoffset", 4));
+ node
+ << JSONNode("clientmessageid", (long)timestamp)
+ << JSONNode("messagetype", "RichText")
+ << JSONNode("contenttype", "text")
+ << JSONNode("content", message)
+ << JSONNode("skypeemoteoffset", 4);
Body << VALUE(node.write().c_str());
}
@@ -93,19 +95,18 @@ public:
<< CHAR_VALUE("Content-Type", "application/json; charset=UTF-8")
<< FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken);
- JSONNode node(JSON_NODE);
- JSONNode members(JSON_ARRAY);
-
- members.set_name("members");
+ JSONNode node;
+ JSONNode members(JSON_ARRAY); members.set_name("members");
for (int i = 0; i < skypenames.getCount(); i++)
{
- JSONNode member(JSON_NODE);
- member.push_back(JSONNode("id", CMStringA(::FORMAT, "8:%s", skypenames[i]).GetBuffer()));
- member.push_back(JSONNode("role", !mir_strcmpi(skypenames[i], selfname) ? "Admin" : "User"));
- members.push_back(member);
+ JSONNode member;
+ member
+ << JSONNode("id", CMStringA(::FORMAT, "8:%s", skypenames[i]).GetBuffer())
+ << JSONNode("role", !mir_strcmpi(skypenames[i], selfname) ? "Admin" : "User");
+ members << member;
}
- node.push_back(members);
+ node << members;
Body << VALUE(node.write().c_str());
}
@@ -137,9 +138,9 @@ public:
<< CHAR_VALUE("Content-Type", "application/json; charset=UTF-8")
<< FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken);
- JSONNode node(JSON_NODE);
+ JSONNode node;
- node.push_back(JSONNode("role", role));
+ node << JSONNode("role", role);
Body << VALUE(node.write().c_str());
}
@@ -169,8 +170,8 @@ public:
<< CHAR_VALUE("Content-Type", "application/json; charset=UTF-8")
<< FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken);
- JSONNode node(JSON_NODE);
- node.push_back(JSONNode(propname, value));
+ JSONNode node;
+ node << JSONNode(propname, value);
Body << VALUE(node.write().c_str());
}
diff --git a/protocols/SkypeWeb/src/requests/login.h b/protocols/SkypeWeb/src/requests/login.h
index 1ffb2b3ba9..013292b3b1 100644
--- a/protocols/SkypeWeb/src/requests/login.h
+++ b/protocols/SkypeWeb/src/requests/login.h
@@ -24,8 +24,7 @@ public:
LoginOAuthRequest(const char *username, const char *password) :
HttpRequest(REQUEST_POST, "api.skype.com/login/skypetoken")
{
- CMStringA user(username);
- user.MakeLower();
+ CMStringA user(username); user.MakeLower();
CMStringA str(::FORMAT, "%s\nskyper\n%s", user, password);
@@ -38,7 +37,7 @@ public:
Body
<< CHAR_VALUE("scopes", "client")
<< CHAR_VALUE("clientVersion", ptrA(mir_urlEncode("0/7.4.85.102/259/")))
- << CHAR_VALUE("username", ptrA(mir_urlEncode(user.GetBuffer())))
+ << CHAR_VALUE("username", ptrA(mir_urlEncode(user)))
<< CHAR_VALUE("passwordHash", ptrA(mir_urlEncode(hash)));
}
};
diff --git a/protocols/SkypeWeb/src/requests/messages.h b/protocols/SkypeWeb/src/requests/messages.h
index 1f4d4bc87d..451f89cb23 100644
--- a/protocols/SkypeWeb/src/requests/messages.h
+++ b/protocols/SkypeWeb/src/requests/messages.h
@@ -29,11 +29,12 @@ public:
<< FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken)
<< CHAR_VALUE("Content-Type", "application/json; charset=UTF-8");
- JSONNode node(JSON_NODE);
- node.push_back(JSONNode("clientmessageid", (long)timestamp));
- node.push_back(JSONNode("messagetype", "RichText"));
- node.push_back(JSONNode("contenttype", "text"));
- node.push_back(JSONNode("content", message));
+ JSONNode node;
+ node
+ << JSONNode("clientmessageid", (long)timestamp)
+ << JSONNode("messagetype", "RichText")
+ << JSONNode("contenttype", "text")
+ << JSONNode("content", message);
Body << VALUE(node.write().c_str());
}
@@ -53,12 +54,13 @@ public:
CMStringA content;
content.AppendFormat("%s %s", selfusername, message);
- JSONNode node(JSON_NODE);
- node.push_back(JSONNode("clientmessageid", (long)timestamp));
- node.push_back(JSONNode("messagetype", "RichText"));
- node.push_back(JSONNode("contenttype", "text"));
- node.push_back(JSONNode("content", content));
- node.push_back(JSONNode("skypeemoteoffset", (int)(mir_strlen(selfusername) + 1)));
+ JSONNode node;
+ node
+ << JSONNode("clientmessageid", (long)timestamp)
+ << JSONNode("messagetype", "RichText")
+ << JSONNode("contenttype", "text")
+ << JSONNode("content", content)
+ << JSONNode("skypeemoteoffset", (int)(mir_strlen(selfusername) + 1));
Body << VALUE(node.write().c_str());
}
@@ -75,13 +77,14 @@ public:
<< FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken)
<< CHAR_VALUE("Content-Type", "application/json; charset=UTF-8");
- char *state = (iState == PROTOTYPE_SELFTYPING_ON) ? "Control/Typing" : "Control/ClearTyping";
+ const char *state = (iState == PROTOTYPE_SELFTYPING_ON) ? "Control/Typing" : "Control/ClearTyping";
- JSONNode node(JSON_NODE);
- node.push_back(JSONNode("clientmessageid", (long)time(NULL)));
- node.push_back(JSONNode("messagetype", state));
- node.push_back(JSONNode("contenttype", "text"));
- node.push_back(JSONNode("content", ""));
+ JSONNode node;
+ node
+ << JSONNode("clientmessageid", (long)time(NULL))
+ << JSONNode("messagetype", state)
+ << JSONNode("contenttype", "text")
+ << JSONNode("content", "");
Body << VALUE(node.write().c_str());
}
@@ -101,7 +104,7 @@ public:
//"lastReadMessageTimestamp;modificationTime;lastReadMessageId"
JSONNode node(JSON_NODE);
- node.push_back(JSONNode("consumptionhorizon", CMStringA(::FORMAT, "%lld000;%lld000;%lld000", msgTimestamp, time(NULL), msgTimestamp).GetBuffer()));
+ node << JSONNode("consumptionhorizon", CMStringA(::FORMAT, "%lld000;%lld000;%lld000", msgTimestamp, time(NULL), msgTimestamp));
Body << VALUE(node.write().c_str());
}
diff --git a/protocols/SkypeWeb/src/requests/status.h b/protocols/SkypeWeb/src/requests/status.h
index aac7742ef0..b34f4fbce9 100644
--- a/protocols/SkypeWeb/src/requests/status.h
+++ b/protocols/SkypeWeb/src/requests/status.h
@@ -30,7 +30,7 @@ public:
<< CHAR_VALUE("Content-Type", "application/json; charset=UTF-8");
JSONNode node(JSON_NODE);
- node.push_back(JSONNode("status", status));
+ node << JSONNode("status", status);
Body << VALUE(node.write().c_str());
}
diff --git a/protocols/SkypeWeb/src/requests/subscriptions.h b/protocols/SkypeWeb/src/requests/subscriptions.h
index b29eddc639..403f7368e9 100644
--- a/protocols/SkypeWeb/src/requests/subscriptions.h
+++ b/protocols/SkypeWeb/src/requests/subscriptions.h
@@ -29,17 +29,18 @@ public:
<< FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken)
<< CHAR_VALUE("Content-Type", "application/json; charset=UTF-8");
- JSONNode interestedResources(JSON_ARRAY);
- interestedResources.set_name("interestedResources");
- interestedResources.push_back(JSONNode("", "/v1/users/ME/conversations/ALL/properties"));
- interestedResources.push_back(JSONNode("", "/v1/users/ME/conversations/ALL/messages"));
- interestedResources.push_back(JSONNode("", "/v1/users/ME/contacts/ALL"));
- interestedResources.push_back(JSONNode("", "/v1/threads/ALL"));
+ JSONNode interestedResources(JSON_ARRAY); interestedResources.set_name("interestedResources");
+ interestedResources
+ << JSONNode("", "/v1/users/ME/conversations/ALL/properties")
+ << JSONNode("", "/v1/users/ME/conversations/ALL/messages")
+ << JSONNode("", "/v1/users/ME/contacts/ALL")
+ << JSONNode("", "/v1/threads/ALL");
- JSONNode node(JSON_NODE);
- node.push_back(JSONNode("channelType", "httpLongPoll"));
- node.push_back(JSONNode("template", "raw"));
- node.push_back(interestedResources);
+ JSONNode node;
+ node
+ << JSONNode("channelType", "httpLongPoll")
+ << JSONNode("template", "raw")
+ << interestedResources;
Body << VALUE(node.write().c_str());
}
@@ -57,18 +58,16 @@ public:
<< FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken);
- JSONNode node(JSON_NODE);
- JSONNode contacts(JSON_ARRAY);
-
- contacts.set_name("contacts");
+ JSONNode node;
+ JSONNode contacts(JSON_ARRAY); contacts.set_name("contacts");
for (int i = 0; i < skypenames.getCount(); i++)
{
- JSONNode contact(JSON_NODE);
- contact.push_back(JSONNode("id", CMStringA(::FORMAT, "8:%s", skypenames[i]).GetBuffer()));
- contacts.push_back(contact);
+ JSONNode contact;
+ contact << JSONNode("id", CMStringA(::FORMAT, "8:%s", skypenames[i]));
+ contacts << contact;
}
- node.push_back(contacts);
+ node << contacts;
Body << VALUE(node.write().c_str());
}
diff --git a/protocols/SkypeWeb/src/requests/trouter.h b/protocols/SkypeWeb/src/requests/trouter.h
index 6035324cf9..37cacc8c92 100644
--- a/protocols/SkypeWeb/src/requests/trouter.h
+++ b/protocols/SkypeWeb/src/requests/trouter.h
@@ -38,12 +38,11 @@ public:
<< CHAR_VALUE("Content-Type", "application/json; charset=UTF-8")
<< CHAR_VALUE("X-Skypetoken", token);
- JSONNode node(JSON_NODE);
- node.push_back(JSONNode("sr", sr));
+ JSONNode node;
+ node << JSONNode("sr", sr);
Body << VALUE(node.write().c_str());
}
- //{"sr":"AUKRNgA8_eKV0Ibsx037Gbd8GVrsDg8zLQRt1pH8sCyIAile3gtoWmlq2x1yZ_VNZ3tf","issuer":"edf","sp":"connect","st":"1430236511619","se":"1430318082619","sig":"nYczCdlBENCxoAFLy7lPkGELVV1w5TcUnpSUE2G7GLA"}
};
class RegisterTrouterRequest : public HttpRequest
@@ -56,29 +55,31 @@ public:
<< CHAR_VALUE("Accept", "application/json, text/javascript, text/html,application/xhtml+xml, application/xml")
<< CHAR_VALUE("X-Skypetoken", token);
- JSONNode clientDescription(JSON_NODE);
- clientDescription.set_name("clientDescription");
- clientDescription.push_back(JSONNode("aesKey", ""));
- clientDescription.push_back(JSONNode("languageId", "en-US"));
- clientDescription.push_back(JSONNode("platform", "SWX"));
- clientDescription.push_back(JSONNode("templateKey", "SkypeWeb_1.0"));
-
- JSONNode TRouter(JSON_NODE);
- TRouter.push_back(JSONNode("context", ""));
- TRouter.push_back(JSONNode("path", trouterUrl));
- TRouter.push_back(JSONNode("ttl", 3600));
-
- JSONNode TROUTER (JSON_ARRAY); TROUTER.set_name("TROUTER");
- TROUTER.push_back(TRouter);
-
- JSONNode transports(JSON_NODE); transports.set_name("transports");
- transports.push_back(TROUTER);
-
- JSONNode node(JSON_NODE);
- node.push_back(JSONNode("registrationId", id));
- node.push_back(JSONNode("nodeId", ""));
- node.push_back(clientDescription);
- node.push_back(transports);
+ JSONNode clientDescription; clientDescription.set_name("clientDescription");
+ clientDescription
+ << JSONNode("aesKey", "")
+ << JSONNode("languageId", "en-US")
+ << JSONNode("platform", "SWX")
+ << JSONNode("templateKey", "SkypeWeb_1.0");
+
+ JSONNode TRouter;
+ TRouter
+ << JSONNode("context", "")
+ << JSONNode("path", trouterUrl)
+ << JSONNode("ttl", 3600);
+
+ JSONNode TRouters(JSON_ARRAY); TRouters.set_name("TROUTER");
+ TRouters << TRouter;
+
+ JSONNode transports; transports.set_name("transports");
+ transports << TRouters;
+
+ JSONNode node;
+ node
+ << JSONNode("registrationId", id)
+ << JSONNode("nodeId", "")
+ << clientDescription
+ << transports;
Body << VALUE(node.write().c_str());
}
diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp
index 5dc7dc21a3..7317a38cac 100644
--- a/protocols/SkypeWeb/src/skype_chatrooms.cpp
+++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp
@@ -228,7 +228,6 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam)
}
break;
-
}
}
return 0;
diff --git a/protocols/SkypeWeb/src/skype_db.cpp b/protocols/SkypeWeb/src/skype_db.cpp
index 478de25527..1d730d4296 100644
--- a/protocols/SkypeWeb/src/skype_db.cpp
+++ b/protocols/SkypeWeb/src/skype_db.cpp
@@ -84,34 +84,36 @@ MEVENT CSkypeProto::AppendDBEvent(MCONTACT hContact, MEVENT hEvent, const char *
return hEvent;
}
JSONNode jEdit;
- jEdit.push_back(JSONNode("time", (long)edit_time));
- jEdit.push_back(JSONNode("text", szContent));
+ jEdit
+ << JSONNode("time", (long)edit_time)
+ << JSONNode("text", szContent);
- jEdits.push_back(jEdit);
+ jEdits << jEdit;
}
}
else
{
jMsg = JSONNode();
- JSONNode jOriginalMsg;
- JSONNode jEdits(JSON_ARRAY);
+ JSONNode jOriginalMsg; jOriginalMsg.set_name("original_message");
+ JSONNode jEdits(JSON_ARRAY); jEdits.set_name("edits");
JSONNode jEdit;
- jOriginalMsg.set_name("original_message");
- jOriginalMsg.push_back(JSONNode("time", (long)dbei.timestamp));
- jOriginalMsg.push_back(JSONNode("text", (char*)dbei.pBlob));
- jMsg.push_back(jOriginalMsg);
+ jOriginalMsg
+ << JSONNode("time", (long)dbei.timestamp)
+ << JSONNode("text", (char*)dbei.pBlob);
- jEdit.push_back(JSONNode("time", (long)edit_time));
- jEdit.push_back(JSONNode("text", szContent));
+ jMsg << jOriginalMsg;
- jEdits.push_back(jEdit);
- jEdits.set_name("edits");
- jMsg.push_back(jEdits);
+ jEdit
+ << JSONNode("time", (long)edit_time)
+ << JSONNode("text", szContent);
+
+ jEdits << jEdit;
+ jMsg << jEdits;
}
- int r = db_event_delete(hContact, hEvent);
+ db_event_delete(hContact, hEvent);
return AddDbEvent(SKYPE_DB_EVENT_TYPE_EDITED_MESSAGE, hContact, dbei.timestamp, DBEF_UTF, jMsg.write().c_str(), szUid);
}