public static byte[] WritePublicDirectoryRequest(byte requestType, uint uin, string firstName, string lastName, string nickname, int startBirthyear, int stopBirthyear, string city, Gender gender, bool activeOnly, string familyName, string familyCity, uint start) { using (PacketWriter writer = new PacketWriter()) { writer.Write(requestType); //request type writer.Write((uint)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds); //sequence number if (uin > 0) //uin { writer.Write(Encoding.ASCII.GetBytes("FmNumber")); writer.Write('\0'); writer.Write(Encoding.UTF8.GetBytes(uin.ToString())); writer.Write('\0'); } if (firstName != null && firstName != string.Empty) //first name { writer.Write(Encoding.ASCII.GetBytes("firstname")); writer.Write('\0'); writer.Write(Encoding.UTF8.GetBytes(firstName)); writer.Write('\0'); } if (lastName != null && lastName != string.Empty) //last name { writer.Write(Encoding.ASCII.GetBytes("lastname")); writer.Write('\0'); writer.Write(Encoding.UTF8.GetBytes(lastName)); writer.Write('\0'); } if (nickname != null && nickname != string.Empty) //nickname { writer.Write(Encoding.ASCII.GetBytes("nickname")); writer.Write('\0'); writer.Write(Encoding.UTF8.GetBytes(nickname)); writer.Write('\0'); } if (startBirthyear > 0) //birthyear { writer.Write(Encoding.ASCII.GetBytes("birthyear")); writer.Write('\0'); writer.Write(Encoding.ASCII.GetBytes(startBirthyear.ToString())); if (stopBirthyear > 0 && startBirthyear != stopBirthyear) { writer.Write(' '); writer.Write(Encoding.ASCII.GetBytes(stopBirthyear.ToString())); } writer.Write('\0'); } if (city != null || city != string.Empty) //city { writer.Write(Encoding.ASCII.GetBytes("city")); writer.Write('\0'); writer.Write(Encoding.UTF8.GetBytes(city)); writer.Write('\0'); } if (gender != Gender.None) //gender { writer.Write(Encoding.ASCII.GetBytes("gender")); writer.Write('\0'); writer.Write(Encoding.ASCII.GetBytes(Utils.ToInternalGender(gender, (requestType != Container.GG_PUBDIR50_SEARCH)).ToString())); writer.Write('\0'); } if (activeOnly) //active { writer.Write(Encoding.ASCII.GetBytes("ActiveOnly")); writer.Write('\0'); writer.Write(Encoding.UTF8.GetBytes(Container.GG_PUBDIR50_ACTIVE_TRUE.ToString())); //writer.Write(Encoding.UTF8.GetBytes((activeOnly ? Container.GG_PUBDIR50_ACTIVE_TRUE.ToString() : Container.GG_PUBDIR50_ACTIVE_FALSE.ToString()))); writer.Write('\0'); } if (familyName != null && familyName != string.Empty) //family name { writer.Write(Encoding.ASCII.GetBytes("familyname")); writer.Write('\0'); writer.Write(Encoding.UTF8.GetBytes(familyName)); writer.Write('\0'); } if (familyCity != null && familyCity != string.Empty) //family city { writer.Write(Encoding.ASCII.GetBytes("familycity")); writer.Write('\0'); writer.Write(Encoding.UTF8.GetBytes(familyCity)); writer.Write('\0'); } if (start > 0) //start uin { writer.Write(Encoding.ASCII.GetBytes("fmstart")); writer.Write('\0'); writer.Write(Encoding.UTF8.GetBytes(start.ToString())); writer.Write('\0'); } return(BuildHeader(Container.GG_PUBDIR50_REQUEST, writer.Data)); } }
public static byte[] WriteLogin(uint uin, string password, uint passwordSeed, Status status, string description) { using (PacketWriter writer = new PacketWriter()) { byte[] ver = Encoding.ASCII.GetBytes("Gadu-Gadu Client build 10.0.0.10450"); byte[] desc = Encoding.UTF8.GetBytes(description); writer.Write(uin); //gg num writer.Write('p'); writer.Write('l'); //language writer.Write(Container.GG_LOGIN_HASH_SHA1); //hash type writer.Write(Utils.ComputeSHA1(password, passwordSeed)); //pass hash writer.Write(Utils.ToInternalStatus(status, (description != string.Empty))); //status writer.Write((uint)0); //flags writer.Write(Container.GG_LOGIN_FLAG_MSGTYPE_80 | Container.GG_LOGIN_FLAG_STATUSTYPE_80 | Container.GG_LOGIN_FLAG_LOGINFAILEDTYPE | Container.GG_LOGIN_FLAG_UNKNOWN | Container.GG_LOGIN_FLAG_SENDMSGACK | Container.GG_LOGIN_FLAG_DNDFFC | Container.GG_LOGIN_FLAG_MULTILOGIN | Container.GG_LOGIN_FLAG_TYPINGNOTIF); //features //writer.Write((uint)0x00000367); writer.Write((uint)0); //local ip (not used) writer.Write((ushort)0); //local port (not used) writer.Write((uint)0); //external ip (not used) writer.Write((ushort)0); //external port (not used) writer.Write((byte)255); //image size writer.Write((byte)0x64); //unknown writer.Write((uint)ver.Length); //version structHeader string writer.Write(ver); //version writer.Write((uint)desc.Length); //description structHeader if (description != string.Empty) { writer.Write(desc); //description } return(BuildHeader(Container.GG_LOGIN80, writer.Data)); } }