void OTTrade::UpdateContents() { // I release this because I'm about to repopulate it. m_xmlUnsigned.Release(); const String NOTARY_ID(GetNotaryID()), NYM_ID(GetSenderNymID()), INSTRUMENT_DEFINITION_ID(GetInstrumentDefinitionID()), ASSET_ACCT_ID(GetSenderAcctID()), CURRENCY_TYPE_ID(GetCurrencyID()), CURRENCY_ACCT_ID(GetCurrencyAcctID()); Tag tag("trade"); tag.add_attribute("version", m_strVersion.Get()); tag.add_attribute("hasActivated", formatBool(hasTradeActivated_)); tag.add_attribute("notaryID", NOTARY_ID.Get()); tag.add_attribute("instrumentDefinitionID", INSTRUMENT_DEFINITION_ID.Get()); tag.add_attribute("assetAcctID", ASSET_ACCT_ID.Get()); tag.add_attribute("currencyTypeID", CURRENCY_TYPE_ID.Get()); tag.add_attribute("currencyAcctID", CURRENCY_ACCT_ID.Get()); tag.add_attribute("nymID", NYM_ID.Get()); tag.add_attribute("completedNoTrades", formatInt(tradesAlreadyDone_)); tag.add_attribute("transactionNum", formatLong(m_lTransactionNum)); tag.add_attribute("creationDate", formatTimestamp(GetCreationDate())); tag.add_attribute("validFrom", formatTimestamp(GetValidFrom())); tag.add_attribute("validTo", formatTimestamp(GetValidTo())); // There are "closing" transaction numbers, used to CLOSE a transaction. // Often where Cron items are involved such as this payment plan, or in // baskets, // where many asset accounts are involved and require receipts to be closed // out. for (int32_t i = 0; i < GetCountClosingNumbers(); i++) { int64_t closingNumber = GetClosingTransactionNoAt(i); OT_ASSERT(closingNumber > 0); TagPtr tagClosing(new Tag("closingTransactionNumber")); tagClosing->add_attribute("value", formatLong(closingNumber)); tag.add_tag(tagClosing); } if (('<' == stopSign_) || ('>' == stopSign_)) { TagPtr tagStopOrder(new Tag("stopOrder")); tagStopOrder->add_attribute("hasActivated", formatBool(stopActivated_)); tagStopOrder->add_attribute("sign", formatChar(stopSign_)); tagStopOrder->add_attribute("price", formatLong(stopPrice_)); tag.add_tag(tagStopOrder); } if (marketOffer_.Exists()) { OTASCIIArmor ascOffer(marketOffer_); tag.add_tag("offer", ascOffer.Get()); } std::string str_result; tag.output(str_result); m_xmlUnsigned.Concatenate("%s", str_result.c_str()); }
void OTStash::Serialize(Tag& parent) const { uint32_t sizeMapStashItems = m_mapStashItems.size(); TagPtr pTag(new Tag("stash")); pTag->add_attribute("name", m_str_stash_name); pTag->add_attribute("count", formatUint(sizeMapStashItems)); for (auto& it : m_mapStashItems) { const std::string str_instrument_definition_id = it.first; OTStashItem* pStashItem = it.second; OT_ASSERT((str_instrument_definition_id.size() > 0) && (nullptr != pStashItem)); TagPtr pTagItem(new Tag("stashItem")); pTagItem->add_attribute("instrumentDefinitionID", pStashItem->GetInstrumentDefinitionID().Get()); pTagItem->add_attribute("balance", formatLong(pStashItem->GetAmount())); pTag->add_tag(pTagItem); } parent.add_tag(pTag); }
void Cheque::UpdateContents() { String INSTRUMENT_DEFINITION_ID(GetInstrumentDefinitionID()), NOTARY_ID(GetNotaryID()), SENDER_ACCT_ID(GetSenderAcctID()), SENDER_NYM_ID(GetSenderNymID()), RECIPIENT_NYM_ID(GetRecipientNymID()), REMITTER_NYM_ID(GetRemitterNymID()), REMITTER_ACCT_ID(GetRemitterAcctID()); std::string from = formatTimestamp(GetValidFrom()); std::string to = formatTimestamp(GetValidTo()); // I release this because I'm about to repopulate it. m_xmlUnsigned.Release(); Tag tag("cheque"); tag.add_attribute("version", m_strVersion.Get()); tag.add_attribute("amount", formatLong(m_lAmount)); tag.add_attribute("instrumentDefinitionID", INSTRUMENT_DEFINITION_ID.Get()); tag.add_attribute("transactionNum", formatLong(GetTransactionNum())); tag.add_attribute("notaryID", NOTARY_ID.Get()); tag.add_attribute("senderAcctID", SENDER_ACCT_ID.Get()); tag.add_attribute("senderNymID", SENDER_NYM_ID.Get()); tag.add_attribute("hasRecipient", formatBool(m_bHasRecipient)); tag.add_attribute("recipientNymID", m_bHasRecipient ? RECIPIENT_NYM_ID.Get() : ""); tag.add_attribute("hasRemitter", formatBool(m_bHasRemitter)); tag.add_attribute("remitterNymID", m_bHasRemitter ? REMITTER_NYM_ID.Get() : ""); tag.add_attribute("remitterAcctID", m_bHasRemitter ? REMITTER_ACCT_ID.Get() : ""); tag.add_attribute("validFrom", from); tag.add_attribute("validTo", to); if (m_strMemo.Exists() && m_strMemo.GetLength() > 2) { OTASCIIArmor ascMemo(m_strMemo); tag.add_tag("memo", ascMemo.Get()); } std::string str_result; tag.output(str_result); m_xmlUnsigned.Concatenate("%s", str_result.c_str()); }
void OTOffer::UpdateContents() { const String NOTARY_ID(GetNotaryID()), INSTRUMENT_DEFINITION_ID(GetInstrumentDefinitionID()), CURRENCY_TYPE_ID(GetCurrencyID()); // I release this because I'm about to repopulate it. m_xmlUnsigned.Release(); Tag tag("marketOffer"); tag.add_attribute("version", m_strVersion.Get()); tag.add_attribute("isSelling", formatBool(!IsBid())); tag.add_attribute("notaryID", NOTARY_ID.Get()); tag.add_attribute("instrumentDefinitionID", INSTRUMENT_DEFINITION_ID.Get()); tag.add_attribute("currencyTypeID", CURRENCY_TYPE_ID.Get()); tag.add_attribute("priceLimit", formatLong(GetPriceLimit())); tag.add_attribute("totalAssetsOnOffer", formatLong(GetTotalAssetsOnOffer())); tag.add_attribute("finishedSoFar", formatLong(GetFinishedSoFar())); tag.add_attribute("marketScale", formatLong(GetScale())); tag.add_attribute("minimumIncrement", formatLong(GetMinimumIncrement())); tag.add_attribute("transactionNum", formatLong(GetTransactionNum())); tag.add_attribute("validFrom", formatTimestamp(GetValidFrom())); tag.add_attribute("validTo", formatTimestamp(GetValidTo())); std::string str_result; tag.output(str_result); m_xmlUnsigned.Concatenate("%s", str_result.c_str()); }
void AddMailNotifyItem(LPFdirEntry lpFdirEntry, int type) { char lpszText[10240]; char szContributor[LEN_CIXNAME]; char szFileName[LEN_CIXFILENAME]; char szFileDate[64]; char szFileSize[64]; MAILOBJECT mailObject; LPFlistEntry lpFlistEntry;// = (LPFlistEntry)lpFdirEntry->fdirFlistEntry[0]; // Context context = (Context)lpGlobals->context; if (lpFdirEntry->fdirFlistEntry[0] != NULL ) { lpFlistEntry = (LPFlistEntry)lpFdirEntry->fdirFlistEntry[0]; } lstrcpy( szContributor, "$CIX$" ); GetRegistry((LPSTR)&szContributor); if(lstrcmp(lpGlobals->context.lpcConfName, "filepool") == 0) return; formatLong(szFileSize, "", lpFdirEntry->fdirSize, " bytes"); strftime(szFileDate, 63, "%A %d %B %Y", localtime(&lpFdirEntry->fdirTimestamp)); setCase(szFileName, lpFdirEntry->fdirName, setup.wNotifyCase); if (lpFdirEntry->fdirFlistEntry[0] != NULL ) { wsprintf(lpszText, "\r\n" " %s\r\n" "\r\n" " Filename: %s\r\n" " Hotlink: cixfile:\r\n" " File size: %s\r\n" "Contributor: %s\r\n" " Date: %s\r\n" "%s" "\r\n" "Description: \r\n\r\n" "%s\r\n", type?"The following local file has been exported to the filepool:":"The following file has been exported to the filepool:", (LPSTR)szFileName, (LPSTR)szFileSize, (LPSTR)szContributor, (LPSTR)szFileDate, setup.os_and_status?" Status: \r\n O/S: \r\n":"", (LPSTR)lpFlistEntry->flistDescription); } else { wsprintf(lpszText, "\r\n" " %s\r\n" "\r\n" " Filename: %s\r\n" " Hotlink: cixfile:\r\n" " File size: %s\r\n" "Contributor: %s\r\n" " Date: %s\r\n" "%s" "\r\n" "Description: <Unknown>\r\n\r\n" "\r\n", type?"The following local file has been exported to the filepool:":"The following file has been exported to the filepool:", (LPSTR)szFileName, (LPSTR)szFileSize, (LPSTR)szContributor, (LPSTR)szFileDate, setup.os_and_status?" Status: \r\n O/S: \r\n":""); } InitObject(&mailObject, OT_MAIL, MAILOBJECT); lstrcpy(mailObject.szTo, "*****@*****.**"); lstrcpy(mailObject.szSubject, "Export To Filepool - "); lstrcat(mailObject.szSubject, szFileName); mailObject.szCC[0] = '\x0'; mailObject.szReply[0] = '\x0'; PutObject(NULL, &mailObject, lpszText); }
bool MainFile::SaveMainFileToString(String& strMainFile) { Tag tag("notaryServer"); // We're on version 2.0 since adding the master key. tag.add_attribute("version", OTCachedKey::It()->IsGenerated() ? "2.0" : version_); tag.add_attribute("notaryID", server_->m_strNotaryID.Get()); tag.add_attribute("serverNymID", server_->m_strServerNymID.Get()); tag.add_attribute("transactionNum", formatLong(server_->transactor_.transactionNumber())); if (OTCachedKey::It()->IsGenerated()) // If it exists, then serialize it. { OTASCIIArmor ascMasterContents; if (OTCachedKey::It()->SerializeTo(ascMasterContents)) { tag.add_tag("cachedKey", ascMasterContents.Get()); } else Log::vError( "%s: Failed trying to write master key to notary file.\n", __FUNCTION__); } for (auto& it : server_->transactor_.contractsMap_) { Contract* pContract = it.second; OT_ASSERT_MSG(nullptr != pContract, "nullptr contract pointer in MainFile::SaveMainFile.\n"); // This is like the Server's wallet. pContract->SaveContractWallet(tag); } // Save the basket account information for (auto& it : server_->transactor_.idToBasketMap_) { String strBasketID = it.first.c_str(); String strBasketAcctID = it.second.c_str(); const Identifier BASKET_ACCOUNT_ID(strBasketAcctID); Identifier BASKET_CONTRACT_ID; bool bContractID = server_->transactor_.lookupBasketContractIDByAccountID( BASKET_ACCOUNT_ID, BASKET_CONTRACT_ID); if (!bContractID) { Log::vError("%s: Error: Missing Contract ID for basket ID %s\n", __FUNCTION__, strBasketID.Get()); break; } String strBasketContractID(BASKET_CONTRACT_ID); TagPtr pTag(new Tag("basketInfo")); pTag->add_attribute("basketID", strBasketID.Get()); pTag->add_attribute("basketAcctID", strBasketAcctID.Get()); pTag->add_attribute("basketContractID", strBasketContractID.Get()); tag.add_tag(pTag); } server_->transactor_.voucherAccounts_.Serialize(tag); std::string str_result; tag.output(str_result); strMainFile.Concatenate("%s", str_result.c_str()); return true; }
QString KLocale::formatLong(long num) const { return d->formatLong(num); }