private void ICreateNode(pnVaultNode node) { pnSqlInsertStatement insert = new pnSqlInsertStatement(); pnVaultNodeFields allFields = node.Fields; for (ulong bit = 1; bit != 0 && bit <= (ulong)allFields; bit <<= 1) { pnVaultNodeFields thisField = allFields & (pnVaultNodeFields)bit; if ((int)thisField == 0) continue; // Some basic sanity checks... switch (thisField) { case pnVaultNodeFields.CreateTime: // I don't care what we were told, it was created NOW insert.AddValue("CreateTime", DateTime.UtcNow); continue; case pnVaultNodeFields.ModifyTime: // I don't care what we were told, it was last modified NOW insert.AddValue("ModifyTime", DateTime.UtcNow); continue; case pnVaultNodeFields.NodeIdx: // Impossible. continue; } string colName = thisField.ToString(); insert.AddValue(colName, node[thisField]); } // We absolutely must have a correct Create/Modify time if (node[pnVaultNodeFields.CreateTime] == null) insert.AddValue("CreateTime", DateTime.UtcNow); if (node[pnVaultNodeFields.ModifyTime] == null) insert.AddValue("ModifyTime", DateTime.UtcNow); insert.Table = "Nodes"; insert.Execute(fDb); node.NodeID = pnDatabase.LastInsert(fDb); }
public pnVaultSystemNode(pnVaultNode node) : base(node) { }
public pnVaultSDLNode(pnVaultNode node) : base(node) { }
private uint[] IFindNode(pnVaultNode node) { pnSqlSelectStatement select = new pnSqlSelectStatement(); select.AddColumn("NodeIdx"); pnVaultNodeFields allFields = node.Fields; for (ulong bit = 1; bit != 0 && bit <= (ulong)allFields; bit <<= 1) { pnVaultNodeFields thisField = allFields & (pnVaultNodeFields)bit; if ((int)thisField == 0) continue; string colName = thisField.ToString(); select.AddWhere(colName, node[thisField]); } select.Limit = 500; // Match Cyan's functionality select.Table = "Nodes"; IDataReader r = select.Execute(fDb); List<uint> nodes = new List<uint>(); while (r.Read()) nodes.Add((uint)r["NodeIdx"]); r.Close(); return nodes.ToArray(); }
public void SaveVaultNode(pnVaultNode node, pnCallback cb = null) { pnCli2Auth_VaultNodeSave req = new pnCli2Auth_VaultNodeSave(); req.fNode = node; req.fNodeID = node.NodeID; req.fRevision = Guid.NewGuid(); req.fTransID = GetTransID(); lock (fStream) { if (cb != null) fCallbacks.Add(req.fTransID, cb); req.Send(fStream); } }
private void ITreeFetchRequest(ENetError result, pnVaultNode node, object param) { ENetError decision = ENetError.kNetErrVaultNodeAccessViolation; if (result != ENetError.kNetSuccess) // If something bad happens vault side, we cannot proceed :( decision = result; else if (node == null) // Successful node fetch but node is null? O.o result = ENetError.kNetErrInternalError; else if (node.NodeType == ENodeType.kNodeAge || node.NodeType == ENodeType.kNodeAgeInfo) // We will fetch the tree of ages when we link to them decision = ENetError.kNetSuccess; else if (node.NodeType == ENodeType.kNodePlayer) // We can only fetch our player if (fPlayerID == node.NodeID) decision = ENetError.kNetSuccess; if (decision == ENetError.kNetSuccess) fVaultCli.FetchNodeRefs(node.NodeID, new pnCallback(new pnVaultNodeRefsFetched(IOnNodeRefsFetched), param)); else { pnAuth2Cli_VaultNodeRefsFetched reply = new pnAuth2Cli_VaultNodeRefsFetched(); reply.fResult = decision; reply.fTransID = (uint)param; lock (fStream) reply.Send(fStream); } }
public override void Read(hsStream s) { fTransID = s.ReadUInt(); fResult = (ENetError)s.ReadInt(); if (s.ReadInt() != 0) { // Vault Node buffer size fNode = new pnVaultNode(); fNode.Read(s); } }
public override void Read(hsStream s) { fTransID = s.ReadUInt(); fNodeID = s.ReadUInt(); fRevision = pnHelpers.ReadUuid(s); if (s.ReadInt() != 0) { fNode = new pnVaultNode(); fNode.Read(s); } }
public pnVaultImageNode(pnVaultNode node) : base(node) { }
public pnVaultAgeInfoNode(pnVaultNode node) : base(node) { }
public pnVaultFolderNode(pnVaultNode node) : base(node) { }
public pnVaultChronicleNode(pnVaultNode node) : base(node) { }
public pnVaultAgeLinkNode(pnVaultNode node) : base(node) { }
private pnVaultNode IMakeNode(IDataReader r) { pnVaultNodeFields[] fields = (pnVaultNodeFields[])Enum.GetValues(typeof(pnVaultNodeFields)); pnVaultNode node = new pnVaultNode(); foreach (pnVaultNodeFields f in fields) { string name = f.ToString(); try { if (r[name] != null && r[name].ToString() != String.Empty) node[f] = r[name]; } catch { continue; } } return node; }
public pnVaultTextNode(pnVaultNode node) : base(node) { }
public void FindNode(pnVaultNode pattern, pnCallback cb = null) { pnCli2Vault_NodeFind req = new pnCli2Vault_NodeFind(); req.fPattern = pattern; req.fTransID = GetTransID(); lock (fStream) { if (cb != null) fCallbacks.Add(req.fTransID, cb); req.Send(fStream); } }
public pnVaultMarkerNode(pnVaultNode node) : base(node) { }
public override void Read(hsStream s) { fTransID = s.ReadUInt(); if (s.ReadInt() != 0) { fPattern = new pnVaultNode(); fPattern.Read(s); } }
public pnVaultNodeAccess(pnVaultNode n) { fBase = n; }
private void IOnNodeFetched(ENetError result, pnVaultNode node, object param) { pnAuth2Cli_VaultNodeFetched reply = new pnAuth2Cli_VaultNodeFetched(); reply.fTransID = (uint)param; if (result == ENetError.kNetSuccess && node != null && fPermissions < pnAcctPerms.CCR) { switch (node.NodeType) { case ENodeType.kNodeAdmin: case ENodeType.kNodeCCR: case ENodeType.kNodeGameServer: case ENodeType.kNodeInvalid: case ENodeType.kNodeUNUSED: case ENodeType.kNodeVaultServer: case ENodeType.kNodeVNodeMgrHigh: case ENodeType.kNodeVNodeMgrLow: reply.fResult = ENetError.kNetErrVaultNodeAccessViolation; break; case ENodeType.kNodeAgeInfoList: pnVaultAgeInfoListNode ages = new pnVaultAgeInfoListNode(node); if (ages.FolderType == EStandardNode.kPublicAgesFolder) reply.fResult = ENetError.kNetErrVaultNodeAccessViolation; break; case ENodeType.kNodeFolder: // Yay, moar switching pnVaultFolderNode folder = new pnVaultFolderNode(node); switch (folder.FolderType) { case EStandardNode.kAllAgeGlobalSDLNodesFolder: case EStandardNode.kGameScoresFolder: // Currently unused case EStandardNode.kVaultMgrGlobalDataFolder: reply.fResult = ENetError.kNetErrVaultNodeAccessViolation; break; } break; case ENodeType.kNodePlayer: if (fPlayerID != node.CreatorID) reply.fResult = ENetError.kNetErrVaultNodeAccessViolation; break; case ENodeType.kNodePlayerInfoList: pnVaultPlayerInfoListNode players = new pnVaultPlayerInfoListNode(node); switch (players.FolderType) { case EStandardNode.kAllPlayersFolder: case EStandardNode.kCCRPlayersFolder: // Currently unused reply.fResult = ENetError.kNetErrVaultNodeAccessViolation; break; } break; case ENodeType.kNodeSDL: pnVaultSDLNode sdl = new pnVaultSDLNode(node); if (sdl.StateIdent != EStandardNode.kAgeInstanceSDLNode) reply.fResult = ENetError.kNetErrVaultNodeAccessViolation; break; default: reply.fResult = result; break; } } else reply.fResult = result; if (result == ENetError.kNetSuccess) reply.fNode = node; reply.Send(fStream); }
public pnVaultNodeAccess(ENodeType type) { fBase = new pnVaultNode(type); }
public override void Read(hsStream s) { fTransID = s.ReadUInt(); fResult = (ENetError)s.ReadInt(); // I'm not eap, so just embed the vault node into the stream // Forget crazy buffer hacks. if (s.ReadBool()) { fNode = new pnVaultNode(); fNode.Read(s); } }
public pnVaultPlayerInfoListNode(pnVaultNode node) : base(node) { }
public void CreateVaultNode(pnVaultNode node, pnCallback cb = null) { pnCli2Auth_VaultNodeCreate req = new pnCli2Auth_VaultNodeCreate(); req.fNode = node; req.fTransID = GetTransID(); lock (fStream) { if (cb != null) fCallbacks.Add(req.fTransID, cb); req.Send(fStream); } }
public pnVaultPlayerNode(pnVaultNode node) : base(node) { }