コード例 #1
0
ファイル: OpUser.cs プロジェクト: nandub/DeOps
        public static UserInfo Decode(G2Header root)
        {
            UserInfo user = new UserInfo();

            if (G2Protocol.ReadPayload(root))
            {
                user.Key = Utilities.ExtractBytes(root.Data, root.PayloadPos, root.PayloadSize);
                user.ID  = Utilities.KeytoID(user.Key);
            }

            G2Protocol.ResetPacket(root);

            G2Header child = new G2Header(root.Data);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (!G2Protocol.ReadPayload(child))
                {
                    continue;
                }

                switch (child.Name)
                {
                case Packet_Name:
                    user.Name = UTF8Encoding.UTF8.GetString(child.Data, child.PayloadPos, child.PayloadSize);
                    break;
                }
            }

            return(user);
        }
コード例 #2
0
ファイル: OpUser.cs プロジェクト: nandub/DeOps
        public static CachedIP Decode(G2Header root)
        {
            CachedIP saved = new CachedIP();

            G2Header child = new G2Header(root.Data);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (!G2Protocol.ReadPayload(child))
                {
                    continue;
                }

                switch (child.Name)
                {
                case Packet_Contact:
                    saved.Contact = DhtContact.ReadPacket(child);
                    break;

                case Packet_LastSeen:
                    saved.LastSeen = DateTime.FromBinary(BitConverter.ToInt64(child.Data, child.PayloadPos));
                    break;

                case Packet_Bootstrap:
                    saved.Bootstrap = BitConverter.ToBoolean(child.Data, child.PayloadPos);
                    break;
                }
            }

            saved.Contact.LastSeen = saved.LastSeen;

            return(saved);
        }
コード例 #3
0
        public static OneWayInvite Decode(G2Header root)
        {
            OneWayInvite invite = new OneWayInvite();

            G2Header child = new G2Header(root.Data);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (!G2Protocol.ReadPayload(child))
                {
                    continue;
                }

                switch (child.Name)
                {
                case Packet_UserName:
                    invite.UserName = UTF8Encoding.UTF8.GetString(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_OpName:
                    invite.OpName = UTF8Encoding.UTF8.GetString(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_OpAccess:
                    invite.OpAccess = (AccessType)child.Data[child.PayloadPos];
                    break;

                case Packet_OpID:
                    invite.OpID = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
                    break;
                }
            }

            return(invite);
        }
コード例 #4
0
ファイル: PacketsComm.cs プロジェクト: nandub/DeOps
        public static CommData Decode(G2Header root)
        {
            CommData data = new CommData();

            G2Header child = new G2Header(root.Data);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (!G2Protocol.ReadPayload(child))
                {
                    continue;
                }

                switch (child.Name)
                {
                case Packet_Service:
                    data.Service = CompactNum.ToUInt32(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_DataType:
                    data.DataType = CompactNum.ToUInt32(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_Data:
                    data.Data = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
                    break;
                }
            }

            return(data);
        }
コード例 #5
0
ファイル: BoardPackets.cs プロジェクト: nandub/DeOps
        public static PostInfo Decode(G2Header root)
        {
            PostInfo info  = new PostInfo();
            G2Header child = new G2Header(root.Data);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (!G2Protocol.ReadPayload(child))
                {
                    continue;
                }

                switch (child.Name)
                {
                case Packet_Subject:
                    info.Subject = UTF8Encoding.UTF8.GetString(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_Format:
                    info.Format = (TextFormat)CompactNum.ToInt32(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_Quip:
                    info.Quip = UTF8Encoding.UTF8.GetString(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_Unique:
                    info.Unique = BitConverter.ToInt32(child.Data, child.PayloadPos);
                    break;
                }
            }

            return(info);
        }
コード例 #6
0
ファイル: MailPackets.cs プロジェクト: nandub/DeOps
        public static MailDestination Decode(G2Header root)
        {
            MailDestination dest  = new MailDestination();
            G2Header        child = new G2Header(root.Data);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (!G2Protocol.ReadPayload(child))
                {
                    continue;
                }

                switch (child.Name)
                {
                case Packet_Key:
                    dest.Key   = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
                    dest.KeyID = Utilities.KeytoID(dest.Key);
                    break;

                case Packet_CC:
                    dest.CC = BitConverter.ToBoolean(child.Data, child.PayloadPos);
                    break;
                }
            }

            return(dest);
        }
コード例 #7
0
ファイル: IMPackets.cs プロジェクト: nandub/DeOps
        public static MessageData Decode(G2Header root)
        {
            MessageData msg = new MessageData();

            G2Header child = new G2Header(root.Data);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (!G2Protocol.ReadPayload(child))
                {
                    continue;
                }

                switch (child.Name)
                {
                case Packet_Text:
                    msg.Text = UTF8Encoding.UTF8.GetString(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_Format:
                    msg.Format = (TextFormat)CompactNum.ToInt32(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_TargetID:
                    msg.TargetID = BitConverter.ToUInt64(child.Data, child.PayloadPos);
                    break;
                }
            }

            return(msg);
        }
コード例 #8
0
        public static LinkData Decode(G2Header root)
        {
            LinkData link  = new LinkData();
            G2Header child = new G2Header(root.Data);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (!G2Protocol.ReadPayload(child))
                {
                    continue;
                }

                switch (child.Name)
                {
                case Packet_Project:
                    link.Project = BitConverter.ToUInt32(child.Data, child.PayloadPos);
                    break;

                case Packet_Target:
                    link.Target   = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
                    link.TargetID = Utilities.KeytoID(link.Target);
                    break;

                case Packet_Uplink:
                    link.Uplink = BitConverter.ToBoolean(child.Data, child.PayloadPos);
                    break;

                case Packet_Title:
                    link.Title = UTF8Encoding.UTF8.GetString(child.Data, child.PayloadPos, child.PayloadSize);
                    break;
                }
            }

            return(link);
        }
コード例 #9
0
        public static ProjectData Decode(G2Header root)
        {
            ProjectData project = new ProjectData();
            G2Header    child   = new G2Header(root.Data);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (!G2Protocol.ReadPayload(child))
                {
                    continue;
                }

                switch (child.Name)
                {
                case Packet_ID:
                    project.ID = BitConverter.ToUInt32(child.Data, child.PayloadPos);
                    break;

                case Packet_Name:
                    project.Name = UTF8Encoding.UTF8.GetString(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_UserName:
                    project.UserName = UTF8Encoding.UTF8.GetString(child.Data, child.PayloadPos, child.PayloadSize);
                    break;
                }
            }

            return(project);
        }
コード例 #10
0
        public static ProfileField Decode(G2Header root)
        {
            ProfileField field = new ProfileField();
            G2Header     child = new G2Header(root.Data);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (!G2Protocol.ReadPayload(child))
                {
                    continue;
                }

                switch (child.Name)
                {
                case Packet_Type:
                    field.FieldType = (ProfileFieldType)child.Data[child.PayloadPos];
                    break;

                case Packet_Name:
                    field.Name = UTF8Encoding.UTF8.GetString(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_Value:
                    field.Value = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
                    break;
                }
            }

            return(field);
        }
コード例 #11
0
ファイル: VoiceService.cs プロジェクト: nandub/DeOps
        public static AudioPacket Decode(G2Header root)
        {
            AudioPacket packet = new AudioPacket();

            if (G2Protocol.ReadPayload(root))
            {
                packet.Audio = Utilities.ExtractBytes(root.Data, root.PayloadPos, root.PayloadSize);
            }

            G2Protocol.ResetPacket(root);

            G2Header child = new G2Header(root.Data);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (!G2Protocol.ReadPayload(child))
                {
                    continue;
                }

                switch (child.Name)
                {
                case Packet_FrameSize:
                    packet.FrameSize = CompactNum.ToInt32(child.Data, child.PayloadPos, child.PayloadSize);
                    break;
                }
            }

            return(packet);
        }
コード例 #12
0
        public static WebCache Decode(G2Header root)
        {
            WebCache cache = new WebCache();

            G2Header child = new G2Header(root.Data);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (!G2Protocol.ReadPayload(child))
                {
                    continue;
                }

                switch (child.Name)
                {
                case Packet_Address:
                    cache.Address = UTF8Encoding.UTF8.GetString(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_AccessKey:
                    cache.AccessKey = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_LastSeen:
                    cache.LastSeen = DateTime.FromBinary(BitConverter.ToInt64(child.Data, child.PayloadPos));
                    break;

                case Packet_LastTried:
                    cache.LastTried = DateTime.FromBinary(BitConverter.ToInt64(child.Data, child.PayloadPos));
                    break;
                }
            }

            return(cache);
        }
コード例 #13
0
ファイル: BoardPackets.cs プロジェクト: nandub/DeOps
        public static PostFile Decode(G2Header root)
        {
            PostFile file  = new PostFile();
            G2Header child = new G2Header(root.Data);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (!G2Protocol.ReadPayload(child))
                {
                    continue;
                }

                switch (child.Name)
                {
                case Packet_Name:
                    file.Name = UTF8Encoding.UTF8.GetString(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_Size:
                    file.Size = CompactNum.ToInt64(child.Data, child.PayloadPos, child.PayloadSize);
                    break;
                }
            }

            return(file);
        }
コード例 #14
0
        public static SubHashPacket Decode(G2Header root)
        {
            SubHashPacket subhash = new SubHashPacket();

            G2Header child = new G2Header(root.Data);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (!G2Protocol.ReadPayload(child))
                {
                    continue;
                }

                switch (child.Name)
                {
                case Packet_ChunkSize:
                    subhash.ChunkSize = BitConverter.ToInt32(child.Data, child.PayloadPos);
                    break;

                case Packet_TotalCount:
                    subhash.TotalCount = BitConverter.ToInt32(child.Data, child.PayloadPos);
                    break;

                case Packet_SubHashes:
                    subhash.SubHashes = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
                    break;
                }
            }

            return(subhash);
        }
コード例 #15
0
ファイル: LocalSync.cs プロジェクト: nandub/DeOps
        public static ServiceData Decode(byte[] data)
        {
            G2Header root = new G2Header(data);

            G2Protocol.ReadPacket(root);

            if (root.Name != LocationPacket.Data)
            {
                return(null);
            }

            ServiceData packet = new ServiceData();
            G2Header    child  = new G2Header(root.Data);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (!G2Protocol.ReadPayload(child))
                {
                    continue;
                }

                switch (child.Name)
                {
                case Packet_Date:
                    packet.Date = DateTime.FromBinary(BitConverter.ToInt64(child.Data, child.PayloadPos));
                    break;

                case Packet_Tag:
                    packet.Tags.Add(PatchTag.FromBytes(child.Data, child.PayloadPos, child.PayloadSize));
                    break;
                }
            }

            return(packet);
        }
コード例 #16
0
ファイル: ShareService.cs プロジェクト: nandub/DeOps
        public static ShareCollection Decode(G2Header header, ulong user)
        {
            ShareCollection root  = new ShareCollection(user);
            G2Header        child = new G2Header(header.Data);

            while (G2Protocol.ReadNextChild(header, child) == G2ReadResult.PACKET_GOOD)
            {
                if (!G2Protocol.ReadPayload(child))
                {
                    continue;
                }

                switch (child.Name)
                {
                case Packet_Hash:
                    root.Hash = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_Size:
                    root.Size = CompactNum.ToInt64(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_Key:
                    root.Key = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
                    break;
                }
            }

            return(root);
        }
コード例 #17
0
ファイル: PacketsNet.cs プロジェクト: nandub/DeOps
        public static Ping Decode(G2ReceivedPacket packet)
        {
            Ping pi = new Ping();

            if (G2Protocol.ReadPayload(packet.Root))
            {
                pi.Ident = BitConverter.ToUInt16(packet.Root.Data, packet.Root.PayloadPos);
            }

            G2Protocol.ResetPacket(packet.Root);

            G2Header child = new G2Header(packet.Root.Data);

            while (G2Protocol.ReadNextChild(packet.Root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (!G2Protocol.ReadPayload(child))
                {
                    continue;
                }

                switch (child.Name)
                {
                case Packet_Source:
                    pi.Source = DhtSource.ReadPacket(child);
                    break;

                case Packet_RemoteIP:
                    pi.RemoteIP = new IPAddress(Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize));
                    break;
                }
            }

            return(pi);
        }
コード例 #18
0
ファイル: PacketsNet.cs プロジェクト: nandub/DeOps
        public static ProxyReq Decode(G2ReceivedPacket packet)
        {
            ProxyReq pr = new ProxyReq();

            G2Header child = new G2Header(packet.Root.Data);

            while (G2Protocol.ReadNextChild(packet.Root, child) == G2ReadResult.PACKET_GOOD)
            {
                switch (child.Name)
                {
                case Packet_Source:
                    if (G2Protocol.ReadPayload(child))
                    {
                        pr.SenderID = BitConverter.ToUInt64(child.Data, child.PayloadPos);
                    }
                    break;

                case Packet_Blocked:
                    pr.Type = ProxyType.ClientBlocked;
                    break;

                case Packet_NAT:
                    pr.Type = ProxyType.ClientNAT;
                    break;
                }
            }

            return(pr);
        }
コード例 #19
0
ファイル: PacketsNet.cs プロジェクト: nandub/DeOps
        public static ProxyAck Decode(G2ReceivedPacket packet)
        {
            ProxyAck pa = new ProxyAck();

            G2Header child = new G2Header(packet.Root.Data);

            while (G2Protocol.ReadNextChild(packet.Root, child) == G2ReadResult.PACKET_GOOD)
            {
                switch (child.Name)
                {
                case Packet_Source:
                    if (G2Protocol.ReadPayload(child))
                    {
                        pa.Source = DhtSource.ReadPacket(child);
                    }
                    break;

                case Packet_Accept:
                    pa.Accept = true;
                    break;

                case Packet_Contacts:
                    if (G2Protocol.ReadPayload(child))
                    {
                        pa.ContactList.Add(DhtContact.ReadPacket(child));
                    }
                    break;
                }
            }

            return(pa);
        }
コード例 #20
0
ファイル: PacketsNet.cs プロジェクト: nandub/DeOps
        public static DhtAddress ReadPacket(G2Header root)
        {
            // read payload
            DhtAddress address = new DhtAddress();

            address.UserID   = BitConverter.ToUInt64(root.Data, root.PayloadPos);
            address.ClientID = BitConverter.ToUInt16(root.Data, root.PayloadPos + 8);
            address.UdpPort  = BitConverter.ToUInt16(root.Data, root.PayloadPos + 10);

            // read packets
            G2Protocol.ResetPacket(root);

            G2Header child = new G2Header(root.Data);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (!G2Protocol.ReadPayload(child))
                {
                    continue;
                }

                switch (child.Name)
                {
                case Packet_IP:
                    address.IP = new IPAddress(Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize));
                    break;
                }
            }

            return(address);
        }
コード例 #21
0
ファイル: PacketsForm.cs プロジェクト: nandub/DeOps
        public void ReadChildren(G2Header rootPacket, TreeNode rootNode, Type packetType)
        {
            G2Header child = new G2Header(rootPacket.Data);

            while (G2Protocol.ReadNextChild(rootPacket, child) == G2ReadResult.PACKET_GOOD)
            {
                string name = child.Name.ToString();

                if (packetType != null)
                {
                    name += " : " + GetVariableName(packetType, child.Name);
                }

                TreeNode childNode = rootNode.Nodes.Add(name);

                if (G2Protocol.ReadPayload(child))
                {
                    //childNode.Nodes.Add( "Payload Ascii: " + Utilities.BytestoAscii(childPacket.Data, childPacket.PayloadPos, childPacket.PayloadSize));
                    childNode.Nodes.Add(new DataNode(child.Data, child.PayloadPos, child.PayloadSize));
                }

                G2Protocol.ResetPacket(child);

                ReadChildren(child, childNode, null);
            }
        }
コード例 #22
0
ファイル: TempCache.cs プロジェクト: nandub/DeOps
        public static TempData Decode(ulong target, byte[] data)
        {
            G2Header root = new G2Header(data);

            G2Protocol.ReadPacket(root);

            if (root.Name != TempPacket.Data)
            {
                return(null);
            }

            TempData temp  = new TempData(target);
            G2Header child = new G2Header(root.Data);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (!G2Protocol.ReadPayload(child))
                {
                    continue;
                }

                switch (child.Name)
                {
                case Packet_TTL:
                    temp.TTL = CompactNum.ToInt32(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_Data:
                    temp.Data = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
                    break;
                }
            }

            return(temp);
        }
コード例 #23
0
        public static LargeDataPacket Decode(G2Header root)
        {
            LargeDataPacket packet = new LargeDataPacket(root.Name, 0, null);

            // size packet
            G2Header child = new G2Header(root.Data);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (!G2Protocol.ReadPayload(child))
                {
                    continue;
                }

                if (child.Name == Packet_Size)
                {
                    packet.Size = BitConverter.ToInt32(child.Data, child.PayloadPos);
                }

                if (child.Name == Packet_Hash)
                {
                    packet.Hash = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
                }
            }

            return(packet);
        }
コード例 #24
0
        public static SignedData Decode(G2Header root)
        {
            SignedData signed = new SignedData();
            G2Header   child  = new G2Header(root.Data);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (!G2Protocol.ReadPayload(child))
                {
                    continue;
                }

                switch (child.Name)
                {
                case Packet_Signature:
                    signed.Signature = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_Data:
                    signed.Data = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
                    break;
                }
            }

            return(signed);
        }
コード例 #25
0
ファイル: PacketsComm.cs プロジェクト: nandub/DeOps
        public static KeyRequest Decode(G2ReceivedPacket packet)
        {
            KeyRequest kr = new KeyRequest();

            G2Header child = new G2Header(packet.Root.Data);

            while (G2Protocol.ReadNextChild(packet.Root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (!G2Protocol.ReadPayload(child))
                {
                    continue;
                }

                if (child.Name == Packet_Encryption)
                {
                    kr.Encryption = UTF8Encoding.UTF8.GetString(child.Data, child.PayloadPos, child.PayloadSize);
                }

                else if (child.Name == Packet_Key)
                {
                    kr.Key = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
                }

                else if (child.Name == Packet_IV)
                {
                    kr.IV = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
                }
            }

            return(kr);
        }
コード例 #26
0
ファイル: StoragePackets.cs プロジェクト: nandub/DeOps
        public static StorageFolder Decode(G2Header root)
        {
            StorageFolder folder = new StorageFolder();
            G2Header      child  = new G2Header(root.Data);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (!G2Protocol.ReadPayload(child))
                {
                    continue;
                }

                switch (child.Name)
                {
                case Packet_UID:
                    folder.UID = BitConverter.ToUInt64(child.Data, child.PayloadPos);
                    break;

                case Packet_ParentUID:
                    folder.ParentUID = BitConverter.ToUInt64(child.Data, child.PayloadPos);
                    break;

                case Packet_Name:
                    folder.Name = UTF8Encoding.UTF8.GetString(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_Date:
                    folder.Date = DateTime.FromBinary(BitConverter.ToInt64(child.Data, child.PayloadPos));
                    break;

                case Packet_Flags:
                    folder.Flags = (StorageFlags)BitConverter.ToUInt16(child.Data, child.PayloadPos);
                    break;

                case Packet_Note:
                    folder.Note = UTF8Encoding.UTF8.GetString(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_Revs:
                    folder.Revs = child.Data[child.PayloadPos];
                    break;

                case Packet_Integrated:
                    folder.IntegratedID = BitConverter.ToUInt64(child.Data, child.PayloadPos);
                    break;

                case Packet_Scope:
                    folder.Scope[BitConverter.ToUInt64(child.Data, child.PayloadPos)] = BitConverter.ToInt16(child.Data, child.PayloadPos + 8);
                    break;
                }
            }

            return(folder);
        }
コード例 #27
0
ファイル: PlanPackets.cs プロジェクト: nandub/DeOps
        public static PlanItem Decode(G2Header root)
        {
            PlanItem item  = new PlanItem();
            G2Header child = new G2Header(root.Data);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (!G2Protocol.ReadPayload(child))
                {
                    continue;
                }

                switch (child.Name)
                {
                case Packet_Ident:
                    item.Ident = BitConverter.ToInt32(child.Data, child.PayloadPos);
                    break;

                case Packet_BranchUp:
                    item.BranchUp = BitConverter.ToInt32(child.Data, child.PayloadPos);
                    break;

                case Packet_Project:
                    item.Project = BitConverter.ToUInt32(child.Data, child.PayloadPos);
                    break;

                case Packet_Title:
                    item.Title = UTF8Encoding.UTF8.GetString(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_Start:
                    item.Start = DateTime.FromBinary(BitConverter.ToInt64(child.Data, child.PayloadPos));
                    break;

                case Packet_End:
                    item.End = DateTime.FromBinary(BitConverter.ToInt64(child.Data, child.PayloadPos));
                    break;

                case Packet_Desc:
                    item.Description = UTF8Encoding.UTF8.GetString(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_HoursCompleted:
                    item.HoursCompleted = BitConverter.ToInt32(child.Data, child.PayloadPos);
                    break;

                case Packet_HoursTotal:
                    item.HoursTotal = BitConverter.ToInt32(child.Data, child.PayloadPos);
                    break;
                }
            }

            return(item);
        }
コード例 #28
0
ファイル: OpUser.cs プロジェクト: nandub/DeOps
        public static IconPacket Decode(G2Header root)
        {
            if (G2Protocol.ReadPayload(root))
            {
                byte[] array = Utilities.ExtractBytes(root.Data, root.PayloadPos, root.PayloadSize);

                return(new IconPacket(root.Name, (Bitmap)Bitmap.FromStream(new MemoryStream(array))));
            }

            return(new IconPacket(root.Name, null));
        }
コード例 #29
0
        public static bool Decode(G2Header root, byte[] destination, ref int pos)
        {
            // data packet
            if (G2Protocol.ReadPayload(root))
            {
                Buffer.BlockCopy(root.Data, root.PayloadPos, destination, pos, root.PayloadSize);
                pos += root.PayloadSize;
                return(true);
            }

            return(false);
        }
コード例 #30
0
ファイル: OpUser.cs プロジェクト: nandub/DeOps
        private static void DecodeKey(G2Header child, SettingsPacket settings)
        {
            G2Header key = new G2Header(child.Data);

            RSAParameters rsa = new RSAParameters();

            while (G2Protocol.ReadNextChild(child, key) == G2ReadResult.PACKET_GOOD)
            {
                if (!G2Protocol.ReadPayload(key))
                {
                    continue;
                }

                switch (key.Name)
                {
                case Key_D:
                    rsa.D = Utilities.ExtractBytes(key.Data, key.PayloadPos, key.PayloadSize);
                    break;

                case Key_DP:
                    rsa.DP = Utilities.ExtractBytes(key.Data, key.PayloadPos, key.PayloadSize);
                    break;

                case Key_DQ:
                    rsa.DQ = Utilities.ExtractBytes(key.Data, key.PayloadPos, key.PayloadSize);
                    break;

                case Key_Exponent:
                    rsa.Exponent = Utilities.ExtractBytes(key.Data, key.PayloadPos, key.PayloadSize);
                    break;

                case Key_InverseQ:
                    rsa.InverseQ = Utilities.ExtractBytes(key.Data, key.PayloadPos, key.PayloadSize);
                    break;

                case Key_Modulus:
                    rsa.Modulus = Utilities.ExtractBytes(key.Data, key.PayloadPos, key.PayloadSize);
                    break;

                case Key_P:
                    rsa.P = Utilities.ExtractBytes(key.Data, key.PayloadPos, key.PayloadSize);
                    break;

                case Key_Q:
                    rsa.Q = Utilities.ExtractBytes(key.Data, key.PayloadPos, key.PayloadSize);
                    break;
                }
            }

            settings.KeyPair.ImportParameters(rsa);
            settings.KeyPublic = rsa.Modulus;
        }