From b43b7abf33f5b2ab480a85584df0e3ce8c76a8ca Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 10 Nov 2014 17:19:12 +0000 Subject: much less crazy imlementaion of xml reader git-svn-id: http://svn.miranda-ng.org/main/trunk@10945 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp') diff --git a/protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp b/protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp index f8bf6dc993..311edc70a5 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp @@ -222,18 +222,17 @@ std::vector* WALogin::readFeaturesUntilChallengeOrSuccess() { } void WALogin::parseSuccessNode(ProtocolTreeNode* node) { - std::string* expiration = node->getAttributeValue("expiration"); - if (expiration != NULL) { - this->expire_date = atol(expiration->c_str()); + const string &expiration = node->getAttributeValue("expiration"); + if (!expiration.empty()) { + this->expire_date = atol(expiration.c_str()); if (this->expire_date == 0) - throw WAException("invalid expire date: " + *expiration); + throw WAException("invalid expire date: " + expiration); } - - std::string* kind = node->getAttributeValue("kind"); - if (kind != NULL && kind->compare("paid") == 0) + const string &kind = node->getAttributeValue("kind"); + if (kind == "paid") this->account_kind = 1; - else if (kind != NULL && kind->compare("free") == 0) + else if (kind == "free") this->account_kind = 0; else this->account_kind = -1; @@ -254,18 +253,18 @@ std::vector WALogin::readSuccess() { ProtocolTreeNode::require(node, "success"); this->parseSuccessNode(node); - std::string* status = node->getAttributeValue("status"); - if (status != NULL && status->compare("expired") == 0) { + const string &status = node->getAttributeValue("status"); + if (status == "expired") { delete node; throw WAException("Account expired on" + std::string(ctime(&this->expire_date)), WAException::LOGIN_FAILURE_EX, WAException::LOGIN_FAILURE_EX_TYPE_EXPIRED, this->expire_date); } - if (status != NULL && status->compare("active") == 0) { - if (node->getAttributeValue("expiration") == NULL) { + if (status == "active") { + if (node->getAttributeValue("expiration").empty()) { delete node; throw WAException("active account with no expiration"); } - } else - this->account_kind = -1; + } + else this->account_kind = -1; std::vector data = *node->data; delete node; -- cgit v1.2.3