Skip to content

Commit

Permalink
OTSignedFile FilePayload and SignerNymID
Browse files Browse the repository at this point in the history
  • Loading branch information
yamamushi committed Sep 18, 2014
1 parent 86113ab commit 601524a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -22,3 +22,6 @@ Moneychanger.cc

# KDE Dolphin (file manager) noise
.directory

# CLion IDE noise
.idea
15 changes: 7 additions & 8 deletions include/opentxs/core/crypto/OTSignedFile.hpp
Expand Up @@ -160,6 +160,9 @@ class OTSignedFile : public OTContract
OTString m_strPurportedFilename; // This is the filename according to the
// file.

OTString m_strSignerNymID; // Optional. Here in case you ever
// want to use it.

// THOUGHT: What if someone switched the file for an older version of
// itself? Seems to me that he could
// make the server accept the file, in that case. Like maybe an account file
Expand Down Expand Up @@ -191,14 +194,10 @@ class OTSignedFile : public OTContract
// (You should still verify the signature on it as well, if you are doing
// this.)
void SetFilename(const OTString& LOCAL_SUBDIR, const OTString& FILE_NAME);
inline OTString& GetFilePayload()
{
return m_strSignedFilePayload;
}
inline void SetFilePayload(const OTString& strArg)
{
m_strSignedFilePayload = strArg;
}
EXPORT OTString& GetFilePayload();
EXPORT void SetFilePayload(const OTString& strArg);
EXPORT OTString& GetSignerNymID();
EXPORT void SetSignerNymID(const OTString& strArg);
EXPORT virtual ~OTSignedFile();
virtual void Release();
void Release_SignedFile();
Expand Down
31 changes: 29 additions & 2 deletions src/core/crypto/OTSignedFile.cpp
Expand Up @@ -143,19 +143,45 @@
namespace opentxs
{

OTString& OTSignedFile::GetFilePayload()
{
return m_strSignedFilePayload;
}

void OTSignedFile::SetFilePayload(const OTString& strArg)
{
m_strSignedFilePayload = strArg;
}

OTString& OTSignedFile::GetSignerNymID()
{
return m_strSignerNymID;
}

void OTSignedFile::SetSignerNymID(const OTString& strArg)
{
m_strSignerNymID = strArg;
}

void OTSignedFile::UpdateContents()
{

OTString strSignerNym("");
if (m_strSignerNymID.Exists()) {
strSignerNym.Format("\n signer=\"%s\"", m_strSignerNymID.Get());
}

// I release this because I'm about to repopulate it.
m_xmlUnsigned.Release();

m_xmlUnsigned.Concatenate("<?xml version=\"%s\"?>\n\n", "1.0");

m_xmlUnsigned.Concatenate("<signedFile\n version=\"%s\"\n"
" localDir=\"%s\"\n"
" filename=\"%s\""
" filename=\"%s\"%s"
" >\n\n",
m_strVersion.Get(), m_strLocalDir.Get(),
m_strSignedFilename.Get());
m_strSignedFilename.Get(), strSignerNym.Get());

if (m_strSignedFilePayload.Exists()) {
OTASCIIArmor ascPayload(m_strSignedFilePayload);
Expand Down Expand Up @@ -186,6 +212,7 @@ int32_t OTSignedFile::ProcessXMLNode(irr::io::IrrXMLReader*& xml)

m_strPurportedLocalDir = xml->getAttributeValue("localDir");
m_strPurportedFilename = xml->getAttributeValue("filename");
m_strSignerNymID = xml->getAttributeValue("signer");

nReturnVal = 1;
}
Expand Down

0 comments on commit 601524a

Please sign in to comment.