Example #1
0
 public G2PacketXML(G2UserProfile prof)
     : base()
 {
     this.type = G2PacketType.XML;
     this.profile = prof;
     this.Str = this.profile.generateXML();
     this.bytes = BinaryUtils.getNullTerminatedBytesFromString(this.Str);
 }
Example #2
0
 public static G2UserProfile SmartUserProfile()
 {
     G2UserProfile profile = new G2UserProfile();
     profile.Nickname = SmartNickName();
     profile.Guid = GUID.generateGuid();
     return profile;
 }
Example #3
0
        public override int ReadPayload(System.IO.MemoryStream stream, int length)
        {
            int bread =  base.ReadPayload(stream, length);
            this.profile = new G2UserProfile();
            try
            {

                XElement xml = XElement.Parse(base.Str);
                XElement child = null;
                XAttribute attr = null;

                child = xml.Element("gnutella"); // get GUID
                if (child != null)
                    profile.Guid = new GUID(child.Value);
                child = null;

                child = xml.Element("identity");
                if(child != null)
                attr = child.Element("handle").Attribute("primary"); // get nickname
                if (attr != null)
                    profile.Nickname = attr.Value;
                attr = null;

                child = xml.Element("identity");
                if(child != null)
                {
                    child = child.Element("name");
                    if (child != null)
                    {
                        attr = child.Attribute("first"); // get first name
                        if (attr != null)
                            profile.FirstName = attr.Value;
                        attr = null;
                        attr = child.Attribute("last"); // get last name
                        if (attr != null)
                            profile.LastName = attr.Value;
                        attr = null;
                        child = null;
                    }
                }
                child = xml.Element("location");
                if(child != null)
                {
                    child = child.Element("political");
                    if (child != null)
                    {
                        attr = child.Attribute("city"); // get city
                        if (attr != null)
                            profile.City = attr.Value;

                        attr = child.Attribute("country"); // getcountry
                        if (attr != null)
                            profile.Country = attr.Value;

                    }
                }

            } catch (Exception e) {
                G2Log.Write("UPROD parsing " + base.Str + " : " + e.ToString());
            }
            return bread;
        }
Example #4
0
 public G2PacketXML(Header h )
     : base(h)
 {
     this.type = G2PacketType.XML;
     this.profile = null;
 }