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);
        }
Beispiel #2
0
 public pnVaultSystemNode(pnVaultNode node)
     : base(node)
 {
 }
Beispiel #3
0
 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();
        }
Beispiel #5
0
        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);
            }
        }
Beispiel #6
0
        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);
            }
        }
Beispiel #7
0
 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);
     }
 }
Beispiel #8
0
 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);
     }
 }
Beispiel #9
0
 public pnVaultImageNode(pnVaultNode node)
     : base(node)
 {
 }
Beispiel #10
0
 public pnVaultAgeInfoNode(pnVaultNode node)
     : base(node)
 {
 }
Beispiel #11
0
 public pnVaultFolderNode(pnVaultNode node)
     : base(node)
 {
 }
Beispiel #12
0
 public pnVaultChronicleNode(pnVaultNode node)
     : base(node)
 {
 }
Beispiel #13
0
 public pnVaultAgeLinkNode(pnVaultNode node)
     : base(node)
 {
 }
Beispiel #14
0
        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;
        }
Beispiel #15
0
 public pnVaultTextNode(pnVaultNode node)
     : base(node)
 {
 }
Beispiel #16
0
        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);
            }
        }
Beispiel #17
0
 public pnVaultMarkerNode(pnVaultNode node)
     : base(node)
 {
 }
Beispiel #18
0
 public override void Read(hsStream s)
 {
     fTransID = s.ReadUInt();
     if (s.ReadInt() != 0) {
         fPattern = new pnVaultNode();
         fPattern.Read(s);
     }
 }
Beispiel #19
0
 public pnVaultNodeAccess(pnVaultNode n)
 {
     fBase = n;
 }
Beispiel #20
0
        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);
        }
Beispiel #21
0
 public pnVaultNodeAccess(ENodeType type)
 {
     fBase = new pnVaultNode(type);
 }
Beispiel #22
0
        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);
            }
        }
Beispiel #23
0
 public pnVaultPlayerInfoListNode(pnVaultNode node)
     : base(node)
 {
 }
Beispiel #24
0
        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);
            }
        }
Beispiel #25
0
 public pnVaultPlayerNode(pnVaultNode node)
     : base(node)
 {
 }