summaryrefslogtreecommitdiff
path: root/protocols/Gadu-Gadu
diff options
context:
space:
mode:
authorSzymon Tokarz <wsx22@o2.pl>2013-11-06 20:09:45 +0000
committerSzymon Tokarz <wsx22@o2.pl>2013-11-06 20:09:45 +0000
commit4ab77d519ebde5e380a75fb3f139f965867f1ed8 (patch)
treee46f6baf9d6fe50aebc2a2b784cd9714e5efec5d /protocols/Gadu-Gadu
parent7e9129158fe087cb173792597751d1fcdc5572f1 (diff)
Gadu-Gadu protocol
Adaptation for todays another gadu-gadu.pl avatars api changes - url http://api.gadu-gadu.pl/avatars/%d/0.xml now returns data at XML format again - url to avatar is now at "users/user/avatars/avatar/bigavatar" node (instead "users/user/avatars/avatar/originBigAvatar" node) git-svn-id: http://svn.miranda-ng.org/main/trunk@6811 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Gadu-Gadu')
-rw-r--r--protocols/Gadu-Gadu/src/avatar.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/protocols/Gadu-Gadu/src/avatar.cpp b/protocols/Gadu-Gadu/src/avatar.cpp
index f0dd2ab105..7086aee901 100644
--- a/protocols/Gadu-Gadu/src/avatar.cpp
+++ b/protocols/Gadu-Gadu/src/avatar.cpp
@@ -80,20 +80,22 @@ bool GGPROTO::getAvatarFileInfo(uin_t uin, char **avatarurl, char **avatarts)
return false;
}
- if (strncmp(resp->pData, "<?xml", 5) == 0){
+ if ((strncmp(resp->pData, "<result>", 8) == 0) || (strncmp(resp->pData, "<?xml", 5) == 0)){
- //before 11.2013 this url returned xml data
+ //if this url returned xml data (before and after 11.2013 gg convention)
TCHAR *xmlAction = mir_a2t(resp->pData);
HXML hXml = xi.parseString(xmlAction, 0, _T("result"));
if (hXml != NULL) {
HXML node = xi.getChildByPath(hXml, _T("users/user/avatars/avatar"), 0);
const TCHAR *blank = (node != NULL) ? xi.getAttrValue(node, _T("blank")) : NULL;
if (blank != NULL && _tcscmp(blank, _T("1"))) {
- node = xi.getChildByPath(hXml, _T("users/user/avatars/avatar/originBigAvatar"), 0);
- *avatarurl = node != NULL ? mir_t2a(xi.getText(node)) : NULL;
-
node = xi.getChildByPath(hXml, _T("users/user/avatars/avatar/timestamp"), 0);
*avatarts = node != NULL ? mir_t2a(xi.getText(node)) : NULL;
+ node = xi.getChildByPath(hXml, _T("users/user/avatars/avatar/bigavatar"), 0); //new gg convention
+ if (node == NULL){
+ node = xi.getChildByPath(hXml, _T("users/user/avatars/avatar/originBigAvatar"), 0); //old gg convention
+ }
+ *avatarurl = node != NULL ? mir_t2a(xi.getText(node)) : NULL;
}
xi.destroyNode(hXml);
}
@@ -101,7 +103,7 @@ bool GGPROTO::getAvatarFileInfo(uin_t uin, char **avatarurl, char **avatarts)
} else if (strncmp(resp->pData, "{\"result\":", 10) == 0){
- //after 11.2013 this url returns json data
+ //if this url returns json data (11.2013 gg convention)
JSONNODE *respJSON = json_parse(resp->pData);
if (respJSON != NULL) {
JSONNODE* respJSONavatars = json_get(json_get(json_get(json_get(respJSON, "result"), "users"), "user"), "avatars");