MCPcopy Create free account
hub / github.com/ashkulz/NppFTP / LoadProfile

Method LoadProfile

src/FTPProfile.cpp:606–733  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

604}
605
606FTPProfile* FTPProfile::LoadProfile(const TiXmlElement * profileElem) {
607 if (!profileElem)
608 return NULL;
609
610 FTPProfile * profile = new FTPProfile();
611 bool success = false;
612 const char * attrstr = NULL;
613
614 do {
615 attrstr = profileElem->Attribute("name");
616 if (!attrstr)
617 break;
618 profile->m_name = SU::Utf8ToTChar(attrstr);
619
620 attrstr = profileElem->Attribute("parent");
621 if (!attrstr)
622 profile->m_parent = SU::Utf8ToTChar("");
623 else
624 profile->m_parent = SU::Utf8ToTChar(attrstr);
625
626
627 attrstr = profileElem->Attribute("hostname");
628 if (!attrstr)
629 profile->m_hostname = SU::strdup("");
630 else
631 profile->m_hostname = SU::strdup(attrstr);
632
633 profileElem->Attribute("port", &profile->m_port);
634
635 attrstr = profileElem->Attribute("username");
636 if (!attrstr)
637 profile->m_username = SU::strdup("");
638 else
639 profile->m_username = SU::strdup(attrstr);
640
641 attrstr = profileElem->Attribute("password");
642 if (!attrstr) {
643 profile->m_password = SU::strdup("");
644 } else {
645 char * decryptpass = Encryption::Decrypt(NULL, -1, attrstr, true);
646 if (decryptpass)
647 profile->m_password = SU::strdup(decryptpass);
648 else
649 profile->m_password = SU::strdup("");
650 Encryption::FreeData(decryptpass);
651 }
652
653 profileElem->QueryBoolAttribute("askPassword", &profile->m_askPassword);
654
655 profileElem->Attribute("timeout", &profile->m_timeout);
656
657 //TODO: this is rather risky casting, check if the compiler accepts it
658 profileElem->Attribute("securityMode", (int*)(&profile->m_securityMode));
659 profileElem->Attribute("transferMode", (int*)(&profile->m_transferMode));
660 profileElem->Attribute("connectionMode", (int*)(&profile->m_connectionMode));
661
662 profileElem->Attribute("dataPortMin", (int*)(&profile->m_dataPortMin));
663 profileElem->Attribute("dataPortMax", (int*)(&profile->m_dataPortMax));

Callers

nothing calls this directly

Calls 5

AttributeMethod · 0.80
QueryBoolAttributeMethod · 0.80
ExpandTypeVectorMethod · 0.80
SanitizeMethod · 0.80
FirstChildElementMethod · 0.45

Tested by

no test coverage detected