|
|
@ -74,17 +74,6 @@ struct INotifyAfterDownload : THashKeyVal<unsigned> { |
|
|
|
{} |
|
|
|
{} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
struct DeviceInbox : CHashKeyStr { |
|
|
|
|
|
|
|
HASHLINK(DeviceInbox) link; |
|
|
|
|
|
|
|
wchar_t inboxName[kMaxVaultNodeStringLength]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DeviceInbox (const wchar_t device[], const wchar_t inbox[]) |
|
|
|
|
|
|
|
: CHashKeyStr(device) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
StrCopy(inboxName, inbox, arrsize(inboxName)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// A RelVaultNodeLink may be either stored in the global table,
|
|
|
|
// A RelVaultNodeLink may be either stored in the global table,
|
|
|
|
// or stored in an IRelVaultNode's parents or children table.
|
|
|
|
// or stored in an IRelVaultNode's parents or children table.
|
|
|
|
struct RelVaultNodeLink : THashKeyVal<unsigned> { |
|
|
|
struct RelVaultNodeLink : THashKeyVal<unsigned> { |
|
|
@ -293,11 +282,7 @@ static HASHTABLEDECL( |
|
|
|
link |
|
|
|
link |
|
|
|
) s_notifyAfterDownload; |
|
|
|
) s_notifyAfterDownload; |
|
|
|
|
|
|
|
|
|
|
|
static HASHTABLEDECL( |
|
|
|
static std::unordered_map<plString, plString, plString::hash> s_ageDeviceInboxes; |
|
|
|
DeviceInbox, |
|
|
|
|
|
|
|
CHashKeyStr, |
|
|
|
|
|
|
|
link |
|
|
|
|
|
|
|
) s_ageDeviceInboxes; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static bool s_processPlayerInbox = false; |
|
|
|
static bool s_processPlayerInbox = false; |
|
|
|
|
|
|
|
|
|
|
@ -553,13 +538,13 @@ static void VaultNodeFetched ( |
|
|
|
// Add to global node table
|
|
|
|
// Add to global node table
|
|
|
|
RelVaultNodeLink * link = s_nodes.Find(node->GetNodeId()); |
|
|
|
RelVaultNodeLink * link = s_nodes.Find(node->GetNodeId()); |
|
|
|
if (!link) { |
|
|
|
if (!link) { |
|
|
|
link = new RelVaultNodeLink(false, 0, node->GetNodeId(), new RelVaultNode); |
|
|
|
link = new RelVaultNodeLink(false, 0, node->GetNodeId(), new RelVaultNode()); |
|
|
|
link->node->SetNodeId_NoDirty(node->GetNodeId()); |
|
|
|
link->node->SetNodeId_NoDirty(node->GetNodeId()); |
|
|
|
s_nodes.Add(link); |
|
|
|
s_nodes.Add(link); |
|
|
|
} |
|
|
|
} |
|
|
|
link->node->CopyFrom(node, NetVaultNode::kCopyOverwrite); |
|
|
|
link->node->CopyFrom(node); |
|
|
|
InitFetchedNode(link->node); |
|
|
|
InitFetchedNode(link->node); |
|
|
|
|
|
|
|
|
|
|
|
link->node->Print(L"Fetched", LogDumpProc, 0); |
|
|
|
link->node->Print(L"Fetched", LogDumpProc, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -602,7 +587,7 @@ static void VaultNodeChanged ( |
|
|
|
|
|
|
|
|
|
|
|
// We are the party responsible for the change, so we already have the
|
|
|
|
// We are the party responsible for the change, so we already have the
|
|
|
|
// latest version of the node; no need to fetch it.
|
|
|
|
// latest version of the node; no need to fetch it.
|
|
|
|
if (link->node->revisionId == revisionId) |
|
|
|
if (link->node->GetRevision() == revisionId) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
// We have the node and we weren't the one that changed it, so fetch it.
|
|
|
|
// We have the node and we weren't the one that changed it, so fetch it.
|
|
|
@ -726,12 +711,7 @@ static void SaveDirtyNodes () { |
|
|
|
for (RelVaultNodeLink * link = s_nodes.Head(); link; link = s_nodes.Next(link)) { |
|
|
|
for (RelVaultNodeLink * link = s_nodes.Head(); link; link = s_nodes.Next(link)) { |
|
|
|
if (bytesWritten >= kMaxBytesPerSaveUpdate) |
|
|
|
if (bytesWritten >= kMaxBytesPerSaveUpdate) |
|
|
|
break; |
|
|
|
break; |
|
|
|
if (link->node->GetDirtyFlags()) { |
|
|
|
if (link->node->IsDirty()) { |
|
|
|
|
|
|
|
|
|
|
|
// Auth server needs the name of the sdl record
|
|
|
|
|
|
|
|
if (link->node->GetNodeType() == plVault::kNodeType_SDL) |
|
|
|
|
|
|
|
link->node->SetDirtyFlags(VaultSDLNode::kSDLName); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (unsigned bytes = NetCliAuthVaultNodeSave(link->node, nil, nil)) { |
|
|
|
if (unsigned bytes = NetCliAuthVaultNodeSave(link->node, nil, nil)) { |
|
|
|
bytesWritten += bytes; |
|
|
|
bytesWritten += bytes; |
|
|
|
link->node->Print(L"Saving", LogDumpProc, 0); |
|
|
|
link->node->Print(L"Saving", LogDumpProc, 0); |
|
|
@ -1428,12 +1408,12 @@ static bool IStrSqlEscape (const T src[], T * dst, unsigned dstChars) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void IGetStringFieldValue ( |
|
|
|
static void IGetStringFieldValue ( |
|
|
|
const wchar_t * value, |
|
|
|
const plString & value, |
|
|
|
wchar_t * dst, |
|
|
|
wchar_t * dst, |
|
|
|
size_t dstChars |
|
|
|
size_t dstChars |
|
|
|
) { |
|
|
|
) { |
|
|
|
wchar_t * tmp = (wchar_t*)malloc(sizeof(wchar_t) * dstChars); |
|
|
|
wchar_t * tmp = (wchar_t*)malloc(sizeof(wchar_t) * dstChars); |
|
|
|
IStrSqlEscape(value, tmp, dstChars); |
|
|
|
IStrSqlEscape(value.ToWchar().GetData(), tmp, dstChars); |
|
|
|
swprintf(dst, dstChars, L"'%s'", tmp); |
|
|
|
swprintf(dst, dstChars, L"'%s'", tmp); |
|
|
|
free(tmp); |
|
|
|
free(tmp); |
|
|
|
} |
|
|
|
} |
|
|
@ -1875,18 +1855,18 @@ void VaultDeleteNode ( |
|
|
|
//============================================================================
|
|
|
|
//============================================================================
|
|
|
|
void VaultPublishNode ( |
|
|
|
void VaultPublishNode ( |
|
|
|
unsigned nodeId, |
|
|
|
unsigned nodeId, |
|
|
|
const wchar_t deviceName[] |
|
|
|
const plString& deviceName |
|
|
|
) { |
|
|
|
) { |
|
|
|
hsRef<RelVaultNode> rvn; |
|
|
|
hsRef<RelVaultNode> rvn; |
|
|
|
|
|
|
|
|
|
|
|
rvn = VaultAgeGetDeviceInbox(deviceName); |
|
|
|
rvn = VaultAgeGetDeviceInbox(deviceName); |
|
|
|
if (!rvn) { |
|
|
|
if (!rvn) { |
|
|
|
LogMsg(kLogDebug, L"Failed to find inbox for device %s, adding it on-the-fly", deviceName); |
|
|
|
LogMsg(kLogDebug, L"Failed to find inbox for device %S, adding it on-the-fly", deviceName.c_str()); |
|
|
|
VaultAgeSetDeviceInboxAndWait(deviceName, DEFAULT_DEVICE_INBOX); |
|
|
|
VaultAgeSetDeviceInboxAndWait(deviceName, DEFAULT_DEVICE_INBOX); |
|
|
|
|
|
|
|
|
|
|
|
rvn = VaultAgeGetDeviceInbox(deviceName); |
|
|
|
rvn = VaultAgeGetDeviceInbox(deviceName); |
|
|
|
if (!rvn) { |
|
|
|
if (!rvn) { |
|
|
|
LogMsg(kLogDebug, L"Failed to add inbox to device %s on-the-fly", deviceName); |
|
|
|
LogMsg(kLogDebug, L"Failed to add inbox to device %S on-the-fly", deviceName.c_str()); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1914,10 +1894,8 @@ void VaultCreateNode ( |
|
|
|
|
|
|
|
|
|
|
|
if (hsRef<RelVaultNode> age = VaultGetAgeNode()) { |
|
|
|
if (hsRef<RelVaultNode> age = VaultGetAgeNode()) { |
|
|
|
VaultAgeNode access(age); |
|
|
|
VaultAgeNode access(age); |
|
|
|
if (!(templateNode->GetFieldFlags() & NetVaultNode::kCreateAgeName)) |
|
|
|
templateNode->SetCreateAgeName(access.GetAgeName()); |
|
|
|
templateNode->SetCreateAgeName(access.GetAgeName()); |
|
|
|
templateNode->SetCreateAgeUuid(access.GetAgeInstanceGuid()); |
|
|
|
if (!(templateNode->GetFieldFlags() & NetVaultNode::kCreateAgeUuid)) |
|
|
|
|
|
|
|
templateNode->SetCreateAgeUuid(access.GetAgeInstanceGuid()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
NetCliAuthVaultNodeCreate( |
|
|
|
NetCliAuthVaultNodeCreate( |
|
|
@ -2297,9 +2275,7 @@ bool VaultGetLinkToMyNeighborhood (plAgeLinkStruct * link) { |
|
|
|
|
|
|
|
|
|
|
|
templateNode->SetNodeType(plVault::kNodeType_AgeInfo); |
|
|
|
templateNode->SetNodeType(plVault::kNodeType_AgeInfo); |
|
|
|
VaultAgeInfoNode ageInfo(templateNode); |
|
|
|
VaultAgeInfoNode ageInfo(templateNode); |
|
|
|
wchar_t str[MAX_PATH]; |
|
|
|
ageInfo.SetAgeFilename(kNeighborhoodAgeFilename); |
|
|
|
StrToUnicode(str, kNeighborhoodAgeFilename, arrsize(str)); |
|
|
|
|
|
|
|
ageInfo.SetAgeFilename(str); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hsRef<RelVaultNode> node; |
|
|
|
hsRef<RelVaultNode> node; |
|
|
|
if (node = rvnFldr->GetChildNode(templateNode, 2)) { |
|
|
|
if (node = rvnFldr->GetChildNode(templateNode, 2)) { |
|
|
@ -2320,9 +2296,7 @@ bool VaultGetLinkToMyPersonalAge (plAgeLinkStruct * link) { |
|
|
|
|
|
|
|
|
|
|
|
templateNode->SetNodeType(plVault::kNodeType_AgeInfo); |
|
|
|
templateNode->SetNodeType(plVault::kNodeType_AgeInfo); |
|
|
|
VaultAgeInfoNode ageInfo(templateNode); |
|
|
|
VaultAgeInfoNode ageInfo(templateNode); |
|
|
|
wchar_t str[MAX_PATH]; |
|
|
|
ageInfo.SetAgeFilename(kPersonalAgeFilename); |
|
|
|
StrToUnicode(str, kPersonalAgeFilename, arrsize(str)); |
|
|
|
|
|
|
|
ageInfo.SetAgeFilename(str); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hsRef<RelVaultNode> node; |
|
|
|
hsRef<RelVaultNode> node; |
|
|
|
if (node = rvnFldr->GetChildNode(templateNode, 2)) { |
|
|
|
if (node = rvnFldr->GetChildNode(templateNode, 2)) { |
|
|
@ -2343,9 +2317,7 @@ bool VaultGetLinkToCity (plAgeLinkStruct * link) { |
|
|
|
templateNode->SetNodeType(plVault::kNodeType_AgeInfo); |
|
|
|
templateNode->SetNodeType(plVault::kNodeType_AgeInfo); |
|
|
|
|
|
|
|
|
|
|
|
VaultAgeInfoNode ageInfo(templateNode); |
|
|
|
VaultAgeInfoNode ageInfo(templateNode); |
|
|
|
wchar_t str[MAX_PATH]; |
|
|
|
ageInfo.SetAgeFilename(kCityAgeFilename); |
|
|
|
StrToUnicode(str, kCityAgeFilename, arrsize(str)); |
|
|
|
|
|
|
|
ageInfo.SetAgeFilename(str); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hsRef<RelVaultNode> node; |
|
|
|
hsRef<RelVaultNode> node; |
|
|
|
if (node = rvnFldr->GetChildNode(templateNode, 2)) { |
|
|
|
if (node = rvnFldr->GetChildNode(templateNode, 2)) { |
|
|
@ -2368,16 +2340,14 @@ hsRef<RelVaultNode> VaultGetOwnedAgeLink (const plAgeInfoStruct * info) { |
|
|
|
|
|
|
|
|
|
|
|
VaultAgeInfoNode ageInfo(templateNode); |
|
|
|
VaultAgeInfoNode ageInfo(templateNode); |
|
|
|
if (info->HasAgeFilename()) { |
|
|
|
if (info->HasAgeFilename()) { |
|
|
|
wchar_t str[MAX_PATH]; |
|
|
|
ageInfo.SetAgeFilename(info->GetAgeFilename()); |
|
|
|
StrToUnicode(str, info->GetAgeFilename(), arrsize(str)); |
|
|
|
|
|
|
|
ageInfo.SetAgeFilename(str); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (info->HasAgeInstanceGuid()) { |
|
|
|
if (info->HasAgeInstanceGuid()) { |
|
|
|
ageInfo.SetAgeInstanceGuid(*info->GetAgeInstanceGuid()); |
|
|
|
ageInfo.SetAgeInstanceGuid(*info->GetAgeInstanceGuid()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (hsRef<RelVaultNode> rvnInfo = rvnFldr->GetChildNode(templateNode, 2)) { |
|
|
|
if (hsRef<RelVaultNode> rvnInfo = rvnFldr->GetChildNode(templateNode, 2)) { |
|
|
|
templateNode->ClearFieldFlags(); |
|
|
|
templateNode->Clear(); |
|
|
|
templateNode->SetNodeType(plVault::kNodeType_AgeLink); |
|
|
|
templateNode->SetNodeType(plVault::kNodeType_AgeLink); |
|
|
|
rvnLink = rvnInfo->GetParentNode(templateNode, 1); |
|
|
|
rvnLink = rvnInfo->GetParentNode(templateNode, 1); |
|
|
|
} |
|
|
|
} |
|
|
@ -2390,7 +2360,6 @@ hsRef<RelVaultNode> VaultGetOwnedAgeLink (const plAgeInfoStruct * info) { |
|
|
|
hsRef<RelVaultNode> VaultGetOwnedAgeInfo (const plAgeInfoStruct * info) { |
|
|
|
hsRef<RelVaultNode> VaultGetOwnedAgeInfo (const plAgeInfoStruct * info) { |
|
|
|
|
|
|
|
|
|
|
|
hsRef<RelVaultNode> rvnInfo; |
|
|
|
hsRef<RelVaultNode> rvnInfo; |
|
|
|
|
|
|
|
|
|
|
|
if (hsRef<RelVaultNode> rvnFldr = VaultGetAgesIOwnFolder()) { |
|
|
|
if (hsRef<RelVaultNode> rvnFldr = VaultGetAgesIOwnFolder()) { |
|
|
|
|
|
|
|
|
|
|
|
hsRef<NetVaultNode> templateNode = new NetVaultNode; |
|
|
|
hsRef<NetVaultNode> templateNode = new NetVaultNode; |
|
|
@ -2398,9 +2367,7 @@ hsRef<RelVaultNode> VaultGetOwnedAgeInfo (const plAgeInfoStruct * info) { |
|
|
|
|
|
|
|
|
|
|
|
VaultAgeInfoNode ageInfo(templateNode); |
|
|
|
VaultAgeInfoNode ageInfo(templateNode); |
|
|
|
if (info->HasAgeFilename()) { |
|
|
|
if (info->HasAgeFilename()) { |
|
|
|
wchar_t str[MAX_PATH]; |
|
|
|
ageInfo.SetAgeFilename(info->GetAgeFilename()); |
|
|
|
StrToUnicode(str, info->GetAgeFilename(), arrsize(str)); |
|
|
|
|
|
|
|
ageInfo.SetAgeFilename(str); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (info->HasAgeInstanceGuid()) { |
|
|
|
if (info->HasAgeInstanceGuid()) { |
|
|
|
ageInfo.SetAgeInstanceGuid(*info->GetAgeInstanceGuid()); |
|
|
|
ageInfo.SetAgeInstanceGuid(*info->GetAgeInstanceGuid()); |
|
|
@ -2408,7 +2375,6 @@ hsRef<RelVaultNode> VaultGetOwnedAgeInfo (const plAgeInfoStruct * info) { |
|
|
|
|
|
|
|
|
|
|
|
rvnInfo = rvnFldr->GetChildNode(templateNode, 2); |
|
|
|
rvnInfo = rvnFldr->GetChildNode(templateNode, 2); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return rvnInfo; |
|
|
|
return rvnInfo; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2488,16 +2454,14 @@ bool VaultSetAgePublicAndWait (NetVaultNode * ageInfoNode, bool publicOrNot) { |
|
|
|
NetCliAuthSetAgePublic(ageInfoNode->GetNodeId(), publicOrNot); |
|
|
|
NetCliAuthSetAgePublic(ageInfoNode->GetNodeId(), publicOrNot); |
|
|
|
|
|
|
|
|
|
|
|
VaultAgeInfoNode access(ageInfoNode); |
|
|
|
VaultAgeInfoNode access(ageInfoNode); |
|
|
|
char ageName[MAX_PATH]; |
|
|
|
|
|
|
|
StrToAnsi(ageName, access.GetAgeFilename(), arrsize(ageName)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plVaultNotifyMsg * msg = new plVaultNotifyMsg; |
|
|
|
plVaultNotifyMsg * msg = new plVaultNotifyMsg; |
|
|
|
if (publicOrNot) |
|
|
|
if (publicOrNot) |
|
|
|
msg->SetType(plVaultNotifyMsg::kPublicAgeCreated); |
|
|
|
msg->SetType(plVaultNotifyMsg::kPublicAgeCreated); |
|
|
|
else |
|
|
|
else |
|
|
|
msg->SetType(plVaultNotifyMsg::kPublicAgeRemoved); |
|
|
|
msg->SetType(plVaultNotifyMsg::kPublicAgeRemoved); |
|
|
|
msg->SetResultCode(true); |
|
|
|
msg->SetResultCode(true); |
|
|
|
msg->GetArgs()->AddString(plNetCommon::VaultTaskArgs::kAgeFilename, ageName); |
|
|
|
msg->GetArgs()->AddString(plNetCommon::VaultTaskArgs::kAgeFilename, access.GetAgeFilename().c_str()); |
|
|
|
msg->Send(); |
|
|
|
msg->Send(); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
@ -2513,17 +2477,15 @@ hsRef<RelVaultNode> VaultGetVisitAgeLink (const plAgeInfoStruct * info) { |
|
|
|
|
|
|
|
|
|
|
|
VaultAgeInfoNode ageInfo(templateNode); |
|
|
|
VaultAgeInfoNode ageInfo(templateNode); |
|
|
|
if (info->HasAgeFilename()) { |
|
|
|
if (info->HasAgeFilename()) { |
|
|
|
wchar_t str[MAX_PATH]; |
|
|
|
ageInfo.SetAgeFilename(info->GetAgeFilename()); |
|
|
|
StrToUnicode(str, info->GetAgeFilename(), arrsize(str)); |
|
|
|
|
|
|
|
ageInfo.SetAgeFilename(str); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (info->HasAgeInstanceGuid()) { |
|
|
|
if (info->HasAgeInstanceGuid()) { |
|
|
|
ageInfo.SetAgeInstanceGuid(*info->GetAgeInstanceGuid()); |
|
|
|
ageInfo.SetAgeInstanceGuid(*info->GetAgeInstanceGuid()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (hsRef<RelVaultNode> rvnInfo = rvnFldr->GetChildNode(templateNode, 2)) { |
|
|
|
if (hsRef<RelVaultNode> rvnInfo = rvnFldr->GetChildNode(templateNode, 2)) { |
|
|
|
templateNode->ClearFieldFlags(); |
|
|
|
templateNode->Clear(); |
|
|
|
templateNode->SetNodeType(plVault::kNodeType_AgeLink);
|
|
|
|
templateNode->SetNodeType(plVault::kNodeType_AgeLink); |
|
|
|
rvnLink = rvnInfo->GetParentNode(templateNode, 1); |
|
|
|
rvnLink = rvnInfo->GetParentNode(templateNode, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -2539,7 +2501,6 @@ bool VaultGetVisitAgeLink (const plAgeInfoStruct * info, class plAgeLinkStruct * |
|
|
|
|
|
|
|
|
|
|
|
VaultAgeLinkNode ageLink(rvn); |
|
|
|
VaultAgeLinkNode ageLink(rvn); |
|
|
|
ageLink.CopyTo(link); |
|
|
|
ageLink.CopyTo(link); |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -3365,7 +3326,7 @@ bool VaultUnregisterVisitAgeAndWait (const plAgeInfoStruct * info) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//============================================================================
|
|
|
|
hsRef<RelVaultNode> VaultFindChronicleEntry (const wchar_t entryName[], int entryType) { |
|
|
|
hsRef<RelVaultNode> VaultFindChronicleEntry (const plString& entryName, int entryType) { |
|
|
|
|
|
|
|
|
|
|
|
hsRef<RelVaultNode> result; |
|
|
|
hsRef<RelVaultNode> result; |
|
|
|
if (hsRef<RelVaultNode> rvnFldr = GetChildFolderNode(GetPlayerNode(), plVault::kChronicleFolder, 1)) { |
|
|
|
if (hsRef<RelVaultNode> rvnFldr = GetChildFolderNode(GetPlayerNode(), plVault::kChronicleFolder, 1)) { |
|
|
@ -3382,7 +3343,7 @@ hsRef<RelVaultNode> VaultFindChronicleEntry (const wchar_t entryName[], int entr |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//============================================================================
|
|
|
|
bool VaultHasChronicleEntry (const wchar_t entryName[], int entryType) { |
|
|
|
bool VaultHasChronicleEntry (const plString& entryName, int entryType) { |
|
|
|
if (VaultFindChronicleEntry(entryName, entryType)) |
|
|
|
if (VaultFindChronicleEntry(entryName, entryType)) |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -3390,9 +3351,9 @@ bool VaultHasChronicleEntry (const wchar_t entryName[], int entryType) { |
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//============================================================================
|
|
|
|
void VaultAddChronicleEntryAndWait ( |
|
|
|
void VaultAddChronicleEntryAndWait ( |
|
|
|
const wchar_t entryName[], |
|
|
|
const plString& entryName, |
|
|
|
int entryType, |
|
|
|
int entryType, |
|
|
|
const wchar_t entryValue[] |
|
|
|
const plString& entryValue |
|
|
|
) { |
|
|
|
) { |
|
|
|
if (hsRef<RelVaultNode> rvnChrn = VaultFindChronicleEntry(entryName, entryType)) { |
|
|
|
if (hsRef<RelVaultNode> rvnChrn = VaultFindChronicleEntry(entryName, entryType)) { |
|
|
|
VaultChronicleNode chrnNode(rvnChrn); |
|
|
|
VaultChronicleNode chrnNode(rvnChrn); |
|
|
@ -3526,7 +3487,7 @@ bool VaultAmOwnerOfCurrentAge () { |
|
|
|
VaultAgeInfoNode curAgeInfo(currentAgeInfoNode); |
|
|
|
VaultAgeInfoNode curAgeInfo(currentAgeInfoNode); |
|
|
|
|
|
|
|
|
|
|
|
plAgeInfoStruct info; |
|
|
|
plAgeInfoStruct info; |
|
|
|
info.SetAgeFilename(plString::FromWchar(curAgeInfo.GetAgeFilename())); |
|
|
|
info.SetAgeFilename(curAgeInfo.GetAgeFilename()); |
|
|
|
|
|
|
|
|
|
|
|
if (hsRef<RelVaultNode> rvnLink = VaultGetOwnedAgeLink(&info)) { |
|
|
|
if (hsRef<RelVaultNode> rvnLink = VaultGetOwnedAgeLink(&info)) { |
|
|
|
|
|
|
|
|
|
|
@ -3778,13 +3739,11 @@ hsRef<RelVaultNode> VaultFindAgeSubAgeLink (const plAgeInfoStruct * info) { |
|
|
|
templateNode->SetNodeType(plVault::kNodeType_AgeInfo); |
|
|
|
templateNode->SetNodeType(plVault::kNodeType_AgeInfo); |
|
|
|
|
|
|
|
|
|
|
|
VaultAgeInfoNode ageInfo(templateNode); |
|
|
|
VaultAgeInfoNode ageInfo(templateNode); |
|
|
|
wchar_t str[MAX_PATH]; |
|
|
|
ageInfo.SetAgeFilename(info->GetAgeFilename()); |
|
|
|
StrToUnicode(str, info->GetAgeFilename(), arrsize(str)); |
|
|
|
|
|
|
|
ageInfo.SetAgeFilename(str); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (hsRef<RelVaultNode> rvnInfo = rvnFldr->GetChildNode(templateNode, 2)) { |
|
|
|
if (hsRef<RelVaultNode> rvnInfo = rvnFldr->GetChildNode(templateNode, 2)) { |
|
|
|
templateNode->ClearFieldFlags(); |
|
|
|
templateNode->Clear(); |
|
|
|
templateNode->SetNodeType(plVault::kNodeType_AgeLink);
|
|
|
|
templateNode->SetNodeType(plVault::kNodeType_AgeLink); |
|
|
|
rvnLink = rvnInfo->GetParentNode(templateNode, 1); |
|
|
|
rvnLink = rvnInfo->GetParentNode(templateNode, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -3808,7 +3767,7 @@ void VaultAddAgeChronicleEntry ( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//============================================================================
|
|
|
|
hsRef<RelVaultNode> VaultAgeAddDeviceAndWait (const wchar_t deviceName[]) { |
|
|
|
hsRef<RelVaultNode> VaultAgeAddDeviceAndWait (const plString& deviceName) { |
|
|
|
if (hsRef<RelVaultNode> existing = VaultAgeGetDevice(deviceName)) |
|
|
|
if (hsRef<RelVaultNode> existing = VaultAgeGetDevice(deviceName)) |
|
|
|
return existing; |
|
|
|
return existing; |
|
|
|
|
|
|
|
|
|
|
@ -3836,7 +3795,7 @@ hsRef<RelVaultNode> VaultAgeAddDeviceAndWait (const wchar_t deviceName[]) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//============================================================================
|
|
|
|
void VaultAgeRemoveDevice (const wchar_t deviceName[]) { |
|
|
|
void VaultAgeRemoveDevice (const plString& deviceName) { |
|
|
|
if (hsRef<RelVaultNode> folder = VaultGetAgeDevicesFolder()) { |
|
|
|
if (hsRef<RelVaultNode> folder = VaultGetAgeDevicesFolder()) { |
|
|
|
hsRef<NetVaultNode> templateNode = new NetVaultNode; |
|
|
|
hsRef<NetVaultNode> templateNode = new NetVaultNode; |
|
|
|
templateNode->SetNodeType(plVault::kNodeType_TextNote); |
|
|
|
templateNode->SetNodeType(plVault::kNodeType_TextNote); |
|
|
@ -3845,14 +3804,15 @@ void VaultAgeRemoveDevice (const wchar_t deviceName[]) { |
|
|
|
if (hsRef<RelVaultNode> device = folder->GetChildNode(templateNode, 1)) { |
|
|
|
if (hsRef<RelVaultNode> device = folder->GetChildNode(templateNode, 1)) { |
|
|
|
VaultRemoveChildNode(folder->GetNodeId(), device->GetNodeId(), nil, nil); |
|
|
|
VaultRemoveChildNode(folder->GetNodeId(), device->GetNodeId(), nil, nil); |
|
|
|
|
|
|
|
|
|
|
|
if (DeviceInbox * deviceInbox = s_ageDeviceInboxes.Find(CHashKeyStr(deviceName))) |
|
|
|
auto it = s_ageDeviceInboxes.find(deviceName); |
|
|
|
delete device; |
|
|
|
if (it != s_ageDeviceInboxes.end()) |
|
|
|
|
|
|
|
s_ageDeviceInboxes.erase(it); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//============================================================================
|
|
|
|
bool VaultAgeHasDevice (const wchar_t deviceName[]) { |
|
|
|
bool VaultAgeHasDevice (const plString& deviceName) { |
|
|
|
bool found = false; |
|
|
|
bool found = false; |
|
|
|
if (hsRef<RelVaultNode> folder = VaultGetAgeDevicesFolder()) { |
|
|
|
if (hsRef<RelVaultNode> folder = VaultGetAgeDevicesFolder()) { |
|
|
|
hsRef<NetVaultNode> templateNode = new NetVaultNode; |
|
|
|
hsRef<NetVaultNode> templateNode = new NetVaultNode; |
|
|
@ -3866,7 +3826,7 @@ bool VaultAgeHasDevice (const wchar_t deviceName[]) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//============================================================================
|
|
|
|
hsRef<RelVaultNode> VaultAgeGetDevice (const wchar_t deviceName[]) { |
|
|
|
hsRef<RelVaultNode> VaultAgeGetDevice (const plString& deviceName) { |
|
|
|
hsRef<RelVaultNode> result; |
|
|
|
hsRef<RelVaultNode> result; |
|
|
|
if (hsRef<RelVaultNode> folder = VaultGetAgeDevicesFolder()) { |
|
|
|
if (hsRef<RelVaultNode> folder = VaultGetAgeDevicesFolder()) { |
|
|
|
hsRef<NetVaultNode> templateNode = new NetVaultNode; |
|
|
|
hsRef<NetVaultNode> templateNode = new NetVaultNode; |
|
|
@ -3880,24 +3840,17 @@ hsRef<RelVaultNode> VaultAgeGetDevice (const wchar_t deviceName[]) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//============================================================================
|
|
|
|
hsRef<RelVaultNode> VaultAgeSetDeviceInboxAndWait (const wchar_t deviceName[], const wchar_t inboxName[]) { |
|
|
|
hsRef<RelVaultNode> VaultAgeSetDeviceInboxAndWait (const plString& deviceName, const plString& inboxName) { |
|
|
|
DeviceInbox * devInbox = s_ageDeviceInboxes.Find(CHashKeyStr(deviceName)); |
|
|
|
s_ageDeviceInboxes[deviceName] = inboxName; |
|
|
|
if (devInbox) { |
|
|
|
|
|
|
|
StrCopy(devInbox->inboxName, inboxName, arrsize(devInbox->inboxName)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
devInbox = new DeviceInbox(deviceName, inboxName); |
|
|
|
|
|
|
|
s_ageDeviceInboxes.Add(devInbox); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if we found the inbox or its a global inbox then return here, otherwise if its the default inbox and
|
|
|
|
// if we found the inbox or its a global inbox then return here, otherwise if its the default inbox and
|
|
|
|
// it wasn't found then continue on and create the inbox
|
|
|
|
// it wasn't found then continue on and create the inbox
|
|
|
|
hsRef<RelVaultNode> existing = VaultAgeGetDeviceInbox(deviceName); |
|
|
|
hsRef<RelVaultNode> existing = VaultAgeGetDeviceInbox(deviceName); |
|
|
|
if (existing || StrCmp(inboxName, DEFAULT_DEVICE_INBOX) != 0) |
|
|
|
if (existing || inboxName == DEFAULT_DEVICE_INBOX) |
|
|
|
return existing; |
|
|
|
return existing; |
|
|
|
|
|
|
|
|
|
|
|
hsRef<RelVaultNode> device, inbox; |
|
|
|
hsRef<RelVaultNode> device, inbox; |
|
|
|
|
|
|
|
|
|
|
|
for (;;) { |
|
|
|
for (;;) { |
|
|
|
device = VaultAgeGetDevice(deviceName); |
|
|
|
device = VaultAgeGetDevice(deviceName); |
|
|
|
if (!device) |
|
|
|
if (!device) |
|
|
@ -3911,7 +3864,7 @@ hsRef<RelVaultNode> VaultAgeSetDeviceInboxAndWait (const wchar_t deviceName[], c |
|
|
|
VaultFolderNode access(inbox); |
|
|
|
VaultFolderNode access(inbox); |
|
|
|
access.SetFolderName(inboxName); |
|
|
|
access.SetFolderName(inboxName); |
|
|
|
access.SetFolderType(plVault::kDeviceInboxFolder); |
|
|
|
access.SetFolderType(plVault::kDeviceInboxFolder); |
|
|
|
|
|
|
|
|
|
|
|
VaultAddChildNodeAndWait(device->GetNodeId(), inbox->GetNodeId(), 0); |
|
|
|
VaultAddChildNodeAndWait(device->GetNodeId(), inbox->GetNodeId(), 0); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -3920,28 +3873,26 @@ hsRef<RelVaultNode> VaultAgeSetDeviceInboxAndWait (const wchar_t deviceName[], c |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//============================================================================
|
|
|
|
hsRef<RelVaultNode> VaultAgeGetDeviceInbox (const wchar_t deviceName[]) { |
|
|
|
hsRef<RelVaultNode> VaultAgeGetDeviceInbox (const plString& deviceName) { |
|
|
|
hsRef<RelVaultNode> result; |
|
|
|
hsRef<RelVaultNode> result; |
|
|
|
DeviceInbox * devInbox = s_ageDeviceInboxes.Find(CHashKeyStr(deviceName)); |
|
|
|
auto it = s_ageDeviceInboxes.find(deviceName); |
|
|
|
|
|
|
|
|
|
|
|
if (devInbox) |
|
|
|
if (it != s_ageDeviceInboxes.end()) { |
|
|
|
{ |
|
|
|
|
|
|
|
hsRef<RelVaultNode> parentNode; |
|
|
|
hsRef<RelVaultNode> parentNode; |
|
|
|
const wchar_t * inboxName = nil; |
|
|
|
const wchar_t * inboxName = nil; |
|
|
|
|
|
|
|
|
|
|
|
if (StrCmp(devInbox->inboxName, DEFAULT_DEVICE_INBOX) == 0) { |
|
|
|
//if (StrCmp(devInbox->inboxName, DEFAULT_DEVICE_INBOX) == 0) {
|
|
|
|
|
|
|
|
if (it->second == DEFAULT_DEVICE_INBOX) |
|
|
|
parentNode = VaultAgeGetDevice(deviceName); |
|
|
|
parentNode = VaultAgeGetDevice(deviceName); |
|
|
|
} |
|
|
|
else |
|
|
|
else { |
|
|
|
|
|
|
|
parentNode = VaultGetGlobalInbox(); |
|
|
|
parentNode = VaultGetGlobalInbox(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (parentNode) { |
|
|
|
if (parentNode) { |
|
|
|
hsRef<NetVaultNode> templateNode = new NetVaultNode; |
|
|
|
hsRef<NetVaultNode> templateNode = new NetVaultNode; |
|
|
|
templateNode->SetNodeType(plVault::kNodeType_Folder); |
|
|
|
templateNode->SetNodeType(plVault::kNodeType_Folder); |
|
|
|
VaultFolderNode access(templateNode); |
|
|
|
VaultFolderNode access(templateNode); |
|
|
|
access.SetFolderType(plVault::kDeviceInboxFolder); |
|
|
|
access.SetFolderType(plVault::kDeviceInboxFolder); |
|
|
|
access.SetFolderName(devInbox->inboxName); |
|
|
|
access.SetFolderName(it->second); |
|
|
|
result = parentNode->GetChildNode(templateNode, 1); |
|
|
|
result = parentNode->GetChildNode(templateNode, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -3950,9 +3901,7 @@ hsRef<RelVaultNode> VaultAgeGetDeviceInbox (const wchar_t deviceName[]) { |
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//============================================================================
|
|
|
|
void VaultClearDeviceInboxMap () { |
|
|
|
void VaultClearDeviceInboxMap () { |
|
|
|
while (DeviceInbox * inbox = s_ageDeviceInboxes.Head()) { |
|
|
|
s_ageDeviceInboxes.clear(); |
|
|
|
delete inbox; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//============================================================================
|
|
|
@ -3998,13 +3947,11 @@ hsRef<RelVaultNode> VaultGetSubAgeLink (const plAgeInfoStruct * info) { |
|
|
|
templateNode->SetNodeType(plVault::kNodeType_AgeInfo); |
|
|
|
templateNode->SetNodeType(plVault::kNodeType_AgeInfo); |
|
|
|
|
|
|
|
|
|
|
|
VaultAgeInfoNode ageInfo(templateNode); |
|
|
|
VaultAgeInfoNode ageInfo(templateNode); |
|
|
|
wchar_t str[MAX_PATH]; |
|
|
|
ageInfo.SetAgeFilename(info->GetAgeFilename()); |
|
|
|
StrToUnicode(str, info->GetAgeFilename(), arrsize(str)); |
|
|
|
|
|
|
|
ageInfo.SetAgeFilename(str); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (hsRef<RelVaultNode> rvnInfo = rvnFldr->GetChildNode(templateNode, 2)) { |
|
|
|
if (hsRef<RelVaultNode> rvnInfo = rvnFldr->GetChildNode(templateNode, 2)) { |
|
|
|
templateNode->ClearFieldFlags(); |
|
|
|
templateNode->Clear(); |
|
|
|
templateNode->SetNodeType(plVault::kNodeType_AgeLink);
|
|
|
|
templateNode->SetNodeType(plVault::kNodeType_AgeLink); |
|
|
|
rvnLink = rvnInfo->GetParentNode(templateNode, 1); |
|
|
|
rvnLink = rvnInfo->GetParentNode(templateNode, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -4438,13 +4385,11 @@ bool VaultAgeFindOrCreateChildAgeLinkAndWait ( |
|
|
|
templateNode->SetNodeType(plVault::kNodeType_AgeInfo); |
|
|
|
templateNode->SetNodeType(plVault::kNodeType_AgeInfo); |
|
|
|
|
|
|
|
|
|
|
|
VaultAgeInfoNode ageInfo(templateNode); |
|
|
|
VaultAgeInfoNode ageInfo(templateNode); |
|
|
|
wchar_t str[MAX_PATH]; |
|
|
|
ageInfo.SetAgeFilename(info->GetAgeFilename()); |
|
|
|
StrToUnicode(str, info->GetAgeFilename(), arrsize(str)); |
|
|
|
|
|
|
|
ageInfo.SetAgeFilename(str); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (hsRef<RelVaultNode> rvnInfo = rvnChildAges->GetChildNode(templateNode, 2)) { |
|
|
|
if (hsRef<RelVaultNode> rvnInfo = rvnChildAges->GetChildNode(templateNode, 2)) { |
|
|
|
templateNode->ClearFieldFlags(); |
|
|
|
templateNode->Clear(); |
|
|
|
templateNode->SetNodeType(plVault::kNodeType_AgeLink);
|
|
|
|
templateNode->SetNodeType(plVault::kNodeType_AgeLink); |
|
|
|
rvnLink = rvnInfo->GetParentNode(templateNode, 1); |
|
|
|
rvnLink = rvnInfo->GetParentNode(templateNode, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -4684,14 +4629,11 @@ uint8_t VaultAgeFindOrCreateChildAgeLink( |
|
|
|
// Still here? Try to find the Child Ages folder
|
|
|
|
// Still here? Try to find the Child Ages folder
|
|
|
|
uint8_t retval = hsFail; |
|
|
|
uint8_t retval = hsFail; |
|
|
|
if (hsRef<RelVaultNode> rvnChildAges = rvnParentInfo->GetChildAgeInfoListNode(plVault::kChildAgesFolder, 1)) { |
|
|
|
if (hsRef<RelVaultNode> rvnChildAges = rvnParentInfo->GetChildAgeInfoListNode(plVault::kChildAgesFolder, 1)) { |
|
|
|
wchar_t hack[MAX_PATH]; |
|
|
|
|
|
|
|
StrToUnicode(hack, info->GetAgeFilename(), arrsize(hack)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Search for our age
|
|
|
|
// Search for our age
|
|
|
|
hsRef<NetVaultNode> temp = new NetVaultNode; |
|
|
|
hsRef<NetVaultNode> temp = new NetVaultNode; |
|
|
|
temp->SetNodeType(plVault::kNodeType_AgeInfo); |
|
|
|
temp->SetNodeType(plVault::kNodeType_AgeInfo); |
|
|
|
VaultAgeInfoNode theAge(temp); |
|
|
|
VaultAgeInfoNode theAge(temp); |
|
|
|
theAge.SetAgeFilename(hack); |
|
|
|
theAge.SetAgeFilename(info->GetAgeFilename()); |
|
|
|
|
|
|
|
|
|
|
|
if (hsRef<RelVaultNode> rvnAgeInfo = rvnChildAges->GetChildNode(temp, 2)) { |
|
|
|
if (hsRef<RelVaultNode> rvnAgeInfo = rvnChildAges->GetChildNode(temp, 2)) { |
|
|
|
hsRef<RelVaultNode> rvnAgeLink = rvnAgeInfo->GetParentAgeLink(); |
|
|
|
hsRef<RelVaultNode> rvnAgeLink = rvnAgeInfo->GetParentAgeLink(); |
|
|
|