/// <summary> /// Sets the client's extended status -- SNAC(01,1E) /// </summary> /// <param name="sess">A <see cref="Session"/> object</param> /// <param name="availablemessage">The available message to set</param> /// <param name="flags">The ICQ flags to set</param> /// <param name="status">The ICQ status to set</param> /// <remarks>Either the available message or the flags/status can be set in one call to SetExtendedStatus</remarks> private static void SetExtendedStatus(Session sess, string availablemessage, ICQFlags flags, ICQStatus status) { SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = (ushort)SNACFamily.BasicOscarService; sh.FamilySubtypeID = (ushort)GenericServiceControls.SetExtendedStatus; sh.Flags = 0x0000; sh.RequestID = Session.GetNextRequestID(); ByteStream stream = new ByteStream(); if (availablemessage != null) { stream.WriteUshort(0x001D); stream.WriteUshort((ushort)(availablemessage.Length + 8)); stream.WriteUshort(0x0002); stream.WriteByte(0x04); stream.WriteByte((byte)(Encoding.ASCII.GetByteCount(availablemessage) + 4)); stream.WriteUshort((ushort)Encoding.ASCII.GetByteCount(availablemessage)); stream.WriteString(availablemessage, Encoding.ASCII); stream.WriteUshort(0x0000); } else { uint stat = (uint)((ushort)flags << 16); stat |= (ushort)status; stream.WriteUint(0x00060004); stream.WriteUint(stat); } DataPacket dp = Marshal.BuildDataPacket(sess, sh, stream); dp.ParentConnection = sess.Connections.BOSConnection; SNACFunctions.BuildFLAP(dp); }
byte[] ISegment.GetBytes() { using (ByteStream buffer = new ByteStream()) { buffer.WriteUshort((ushort)item.Type); buffer.WriteByte((byte)item.Flags); buffer.WriteByte((byte)item.Data.Length); buffer.WriteByteArray(item.Data); return(buffer.GetBytes()); } }
/// <summary> /// Sends a response for a authorization request /// </summary> /// <param name="sess">the session object</param> /// <param name="screenname">the destination screenname</param> /// <param name="grantAuthorization">Determines if the authorization is granted</param> /// <param name="reason">The reason for this decision</param> public static void SendAuthorizationResponse(Session sess, string screenname, bool grantAuthorization, string reason) { SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = (ushort)SNACFamily.SSIService; sh.FamilySubtypeID = (ushort)SSIService.SendAuthorizationResponse; ByteStream stream = new ByteStream(); stream.WriteByte((byte)Encoding.ASCII.GetByteCount(screenname)); stream.WriteString(screenname, Encoding.ASCII); stream.WriteByte(Convert.ToByte(grantAuthorization)); stream.WriteUshort((ushort)sess.Encoding.GetByteCount(reason)); stream.WriteString(reason, sess.Encoding); SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream)); }
public void TestByteStreamNumberWriting() { ByteStream stream = new ByteStream(); stream.WriteByte(0x08); stream.WriteUshort(0x4164); stream.WriteUint(0x7269656e); stream.WriteByteArray(new byte[] {0x6e, 0x65}); Assert.AreEqual(testData.Length, stream.GetByteCount()); ByteStream testStream = new ByteStream(stream.GetBytes()); Assert.AreEqual("Adrienne", testStream.ReadString(testStream.ReadByte(), Encoding.ASCII)); }
public void TestByteStreamStringWriting() { ByteStream stream = new ByteStream(); stream.WriteByte((byte) Encoding.ASCII.GetByteCount("Adrienne")); stream.WriteString("Adrienne", Encoding.ASCII); Assert.AreEqual(testData.Length, stream.GetByteCount()); byte[] data = stream.GetBytes(); for (int i = 0; i < testData.Length; i++) { Assert.AreEqual(testData[i], data[i]); } }
/// <summary> /// Delete yourself from another client server-side contact list. /// </summary> /// <param name="sess"></param> /// <param name="screenname">The contacts icq-number.</param> public static void RemoveMySSIItem(Session sess, string screenname) { SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = (ushort)SNACFamily.SSIService; sh.FamilySubtypeID = (ushort)SSIService.RemoveSelfFromContact; ByteStream stream = new ByteStream(); stream.WriteByte((byte)screenname.Length); stream.WriteString(screenname, Encoding.ASCII); SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream)); }
/// <summary> /// Sends an out-of-the-country text message /// </summary> /// <param name="sess">A <see cref="ISession"/> object</param> /// <param name="number">The number to which to send the message</param> /// <param name="message">The message to send</param> /// <param name="alias">The sender's alias</param> /// <remarks><paramref name="message"/> must be in codepage 1252. A delivery receipt /// is automatically requested by this method.</remarks> public static void SendSMSMessage(ISession sess, string number, string message, string alias) { string xmlformat = "<icq_sms_message>\n" + "\t<destination>{0}</destination>\n" + "\t<text>{1}</text>\n" + "\t<codepage>1252</codepage>\n" + "\t<senders_UIN>{2}</senders_UIN>\n" + "\t<senders_name>{3}</senders_name>\n" + "\t<delivery_receipt>Yes</delivery_receipt>\n" + "\t<time>{4}</time>\n" + "</icq_sms_message>\n"; string xml = String.Format(xmlformat, number, message, sess.ScreenName, alias, DateTime.Now.ToString("r")); SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = (ushort)SNACFamily.ICQExtensionsService; sh.FamilySubtypeID = (ushort)ICQExtensionsService.MetaInformationRequest; sh.Flags = 0x0000; sh.RequestID = Session.GetNextRequestID(); ByteStream stream = new ByteStream(); stream.WriteUshort(0x0001); stream.WriteUshort(0x000A); stream.WriteUshort(0x0008); stream.WriteUint(uint.Parse(sess.ScreenName)); stream.WriteUshortLE(0x07D0); stream.WriteUshortLE((ushort)sh.RequestID); stream.WriteUshort(0x8214); stream.WriteUshort(0x0001); stream.WriteUshort(0x0016); stream.WriteUint(0x00000000); stream.WriteUint(0x00000000); stream.WriteUint(0x00000000); stream.WriteUint(0x00000000); stream.WriteUshort(0x0000); stream.WriteUshort((ushort)Encoding.ASCII.GetByteCount(xml)); stream.WriteString(xml, Encoding.ASCII); stream.WriteByte(0x00); SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream)); }
/// <summary> /// Registers the user's screenname with the Location service -- SNAC(02,0B) /// </summary> /// <param name="sess">A <see cref="Session"/> object</param> /// <remarks> /// The function of this SNAC is unknown, but the official AIM client (5.9.3861) sends it sometime /// after SNAC(01,02) is sent. /// </remarks> public static void SetSelfLocation(Session sess) { SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = (ushort)SNACFamily.LocationService; sh.FamilySubtypeID = (ushort)0x000B; ByteStream stream = new ByteStream(); stream.WriteByte((byte)Encoding.ASCII.GetByteCount(sess.ScreenName)); stream.WriteString(sess.ScreenName, Encoding.ASCII); // This SNAC expects a response in SNAC(02,0C) sess.StoreRequestID(sh.RequestID, null); SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream)); }
/// <summary> /// Changes the password on an ICQ account /// </summary> /// <param name="sess">A <see cref="ISession"/> object</param> /// <param name="newpassword">The new password</param> /// <remarks>If the new password is longer than 8 characters, it is automatically /// truncated to 8 characters by the server.</remarks> public static void ChangeICQPassword(ISession sess, string newpassword) { SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = (ushort) SNACFamily.ICQExtensionsService; sh.FamilySubtypeID = (ushort) ICQExtensionsService.MetaInformationRequest; sh.Flags = 0x0000; sh.RequestID = Session.GetNextRequestID(); ByteStream stream = new ByteStream(); stream.WriteUshort(0x0001); stream.WriteUshort(0x000A); stream.WriteUshort(0x0008); stream.WriteUint(uint.Parse(sess.ScreenName)); stream.WriteUshortLE(0x07D0); stream.WriteUshortLE((ushort) sh.RequestID); stream.WriteUshort(0x042E); stream.WriteUshort((ushort) (newpassword.Length + 1)); stream.WriteString(newpassword, Encoding.ASCII); stream.WriteByte(0x00); SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream)); }
/// <summary> /// Sends an XML string /// </summary> /// <param name="sess">A <see cref="ISession"/> object</param> /// <param name="xml">The contents of an XML document</param> /// <remarks>I have no idea how to use this.</remarks> public static void SendXmlRequest(ISession sess, string xml) { SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = (ushort)SNACFamily.ICQExtensionsService; sh.FamilySubtypeID = (ushort)ICQExtensionsService.MetaInformationRequest; sh.Flags = 0x0000; sh.RequestID = Session.GetNextRequestID(); ByteStream stream = new ByteStream(); stream.WriteUshort(0x0001); stream.WriteUshort(0x000A); stream.WriteUshort(0x0008); stream.WriteUint(uint.Parse(sess.ScreenName)); stream.WriteUshortLE(0x07D0); stream.WriteUshortLE((ushort)sh.RequestID); stream.WriteUshort(0x0998); stream.WriteUshort((ushort)Encoding.ASCII.GetByteCount(xml)); stream.WriteString(xml, Encoding.ASCII); stream.WriteByte(0x00); SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream)); }
/// <summary> /// Changes the password on an ICQ account /// </summary> /// <param name="sess">A <see cref="ISession"/> object</param> /// <param name="newpassword">The new password</param> /// <remarks>If the new password is longer than 8 characters, it is automatically /// truncated to 8 characters by the server.</remarks> public static void ChangeICQPassword(ISession sess, string newpassword) { SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = (ushort)SNACFamily.ICQExtensionsService; sh.FamilySubtypeID = (ushort)ICQExtensionsService.MetaInformationRequest; sh.Flags = 0x0000; sh.RequestID = Session.GetNextRequestID(); ByteStream stream = new ByteStream(); stream.WriteUshort(0x0001); stream.WriteUshort(0x000A); stream.WriteUshort(0x0008); stream.WriteUint(uint.Parse(sess.ScreenName)); stream.WriteUshortLE(0x07D0); stream.WriteUshortLE((ushort)sh.RequestID); stream.WriteUshort(0x042E); stream.WriteUshort((ushort)(newpassword.Length + 1)); stream.WriteString(newpassword, Encoding.ASCII); stream.WriteByte(0x00); SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream)); }
/// <summary> /// Sets the client's available message -- SNAC(01,1E) /// </summary> /// <param name="availablemessage">The available message to set</param> internal void SetAvailableMessage(string availablemessage) { SNACHeader sh = new SNACHeader(SNAC_BOS_FAMILY, BOS_SET_EXTENDED_STATUS); ByteStream stream = new ByteStream(); if (String.IsNullOrEmpty(availablemessage)) { availablemessage = String.Empty; } stream.WriteUshort(0x001D); stream.WriteUshort((ushort)(availablemessage.Length + 8)); stream.WriteUshort(0x0002); stream.WriteByte(0x04); stream.WriteByte((byte)(Encoding.ASCII.GetByteCount(availablemessage) + 4)); stream.WriteUshort((ushort)Encoding.ASCII.GetByteCount(availablemessage)); stream.WriteString(availablemessage, Encoding.ASCII); stream.WriteUshort(0x0000); DataPacket dp = Marshal.BuildDataPacket(parent, sh, stream); dp.ParentConnection = parent.Connections.BOSConnection; SNACFunctions.BuildFLAP(dp); }
byte[] ISegment.GetBytes() { using (ByteStream buffer = new ByteStream()) { buffer.WriteUshort((ushort)item.Type); buffer.WriteByte((byte)item.Flags); buffer.WriteByte((byte)item.Data.Length); buffer.WriteByteArray(item.Data); return buffer.GetBytes(); } }
/// <summary> /// Sends a direct connection request /// </summary> /// <param name="conn">A <see cref="DirectConnection"/> object that will handle the request</param> public void RequestDirectConnectionInvite(DirectConnection conn) { SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = SNAC_ICBM_FAMILY; sh.FamilySubtypeID = ICBM_OUTGOING_MESSAGE; ByteStream stream = new ByteStream(); InsertIcbmHeader(stream, conn.Cookie, 0x0002, conn.Other.ScreenName); using (ByteStream tlv05 = new ByteStream()) { tlv05.WriteUshort(RendezvousData.UshortFromType(RendezvousType.Invite)); tlv05.WriteByteArray(conn.Cookie.ToByteArray()); tlv05.WriteByteArray(CapabilityProcessor.GetCapabilityArray(conn.Capability)); using (TlvBlock tlvs = new TlvBlock()) { tlvs.WriteUshort(DC_SEQUENCE_NUMBER, RendezvousData.UshortFromSequence(conn.Sequence)); if (conn.Sequence == RendezvousSequence.DirectOrStage1) { tlvs.WriteEmpty(0x000F); } if (!String.IsNullOrEmpty(conn.Message)) { tlvs.WriteString(DC_MESSAGE, conn.Message, Encoding.ASCII); } uint ipaddress = 0; if (conn.Method == DirectConnectionMethod.Proxied) { ipaddress = ConvertIPAddress(conn.AOLProxyIP); } else { ipaddress = ConvertIPAddress(conn.ClientIP); } tlvs.WriteUint(DC_PROXY_IP_ADDRESS, ipaddress); tlvs.WriteUint(DC_PROXY_IP_ADDRESS_COMPLIMENT, ~ipaddress); if (conn.Sequence == RendezvousSequence.DirectOrStage1) { tlvs.WriteUint(DC_CLIENT_IP_ADDRESS, ConvertIPAddress(conn.ClientIP)); } if (conn.Sequence != RendezvousSequence.Stage3) { tlvs.WriteUshort(DC_PORT, (ushort)conn.Port); tlvs.WriteUshort(DC_PORT_COMPLIMENT, (ushort)(~conn.Port)); } if (conn.Method == DirectConnectionMethod.Proxied) { tlvs.WriteEmpty(DC_USE_PROXY_FLAG); } if (conn is FileTransferConnection && conn.Sequence == RendezvousSequence.DirectOrStage1) { FileTransferConnection ftc = conn as FileTransferConnection; using (ByteStream tlv2711 = new ByteStream()) { tlv2711.WriteUshort((ushort)((ftc.TotalFiles > 1) ? 0x0002 : 0x0001)); tlv2711.WriteUshort((ushort)ftc.TotalFiles); tlv2711.WriteUint(ftc.TotalFileSize); tlv2711.WriteString(ftc.FileHeader.Name, Encoding.ASCII); tlv2711.WriteByte(0x00); tlvs.WriteByteArray(0x2711, tlv2711.GetBytes()); } tlvs.WriteString(0x2712, ftc.LocalFileNameEncoding.WebName, Encoding.ASCII); } tlv05.WriteByteArray(tlvs.GetBytes()); } stream.WriteUshort(0x0005); stream.WriteUshort((ushort)tlv05.GetByteCount()); stream.WriteByteArray(tlv05.GetBytes()); } // Acknowledgement request stream.WriteUint(0x00030000); SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(parent, sh, stream)); }
/// <summary> /// Sends a typing notification /// </summary> /// <param name="screenName">The screenname to receive the typing notification</param> /// <param name="tn">A <see cref="TypingNotification"/> enumeration specifying what /// notification to send</param> /// <exception cref="NotLoggedInException">Thrown when the <see cref="Session"/> is not logged in</exception> public void SendTypingNotification(string screenName, TypingNotification tn) { if (!parent.LoggedIn) { throw new NotLoggedInException(); } DirectIMConnection conn = parent.Connections.GetDirectIMByScreenname(screenName); if (conn != null) { if (conn.Connected) { // TODO: send DIM typing notifications } } // Construct SNAC(04,14) SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = SNAC_ICBM_FAMILY; sh.FamilySubtypeID = ICBM_TYPING_NOTIFICATION; ByteStream stream = new ByteStream(); stream.WriteByteArray(new byte[] {0, 0, 0, 0, 0, 0, 0, 0}); stream.WriteUshort(0x0001); stream.WriteByte((byte) Encoding.ASCII.GetByteCount(screenName)); stream.WriteString(screenName, Encoding.ASCII); stream.WriteUshort((ushort) tn); SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(parent, sh, stream)); }
/// <summary> /// Sends a warning to a remote client -- SNAC(04,08) /// </summary> /// <param name="screenname">The screenname of the client to warn</param> /// <param name="anonymous">Send the warning as anonymous or as yourself</param> public void SendWarning(string screenname, bool anonymous) { SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = SNAC_ICBM_FAMILY; sh.FamilySubtypeID = ICBM_SEND_WARNING; ByteStream stream = new ByteStream(); stream.WriteUshort((ushort)((anonymous) ? 1 : 0)); stream.WriteByte((byte)Encoding.ASCII.GetByteCount(screenname)); stream.WriteString(screenname, Encoding.ASCII); // Save the screenname so the handler for the reply SNAC can retrieve it parent.StoreRequestID(sh.RequestID, screenname); SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(parent, sh, stream)); }
/// <summary> /// Allows the authorization to another client in the future /// </summary> /// <param name="sess">the session object</param> /// <param name="screenname">the destination screenname</param> /// <param name="reason">the reason for the future authorization</param> public static void SendFutureAuthorizationGrant(Session sess, string screenname, string reason) { SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = (ushort) SNACFamily.SSIService; sh.FamilySubtypeID = (ushort) SSIService.SendFutureAuthorizationGrant; ByteStream stream = new ByteStream(); stream.WriteByte((byte) Encoding.ASCII.GetByteCount(screenname)); stream.WriteString(screenname, Encoding.ASCII); stream.WriteUshort((ushort) sess.Encoding.GetByteCount(reason)); stream.WriteString(reason, sess.Encoding); stream.WriteUshort(0x0000); SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream)); }
/// <summary> /// Inserts an ICBM header /// </summary> private static void InsertIcbmHeader(ByteStream stream, Cookie cookie, ushort channel, string screenName) { stream.WriteByteArray(cookie.ToByteArray()); stream.WriteUshort(channel); stream.WriteByte((byte)Encoding.ASCII.GetByteCount(screenName)); stream.WriteString(screenName, Encoding.ASCII); }
/// <summary> /// Delete yourself from another client server-side contact list. /// </summary> /// <param name="sess"></param> /// <param name="screenname">The contacts icq-number.</param> public static void RemoveMySSIItem(Session sess, string screenname) { SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = (ushort)SNACFamily.SSIService; sh.FamilySubtypeID = (ushort)SSIService.RemoveSelfFromContact; ByteStream stream = new ByteStream(); stream.WriteByte((byte)screenname.Length); stream.WriteString(screenname, Encoding.ASCII); SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream)); }
/// <summary> /// Invites an AIM user to an AOL chatroom /// </summary> /// <param name="chatroom">The <see cref="ChatRoom"/> describing the chatroom</param> /// <param name="screenName">The screenname of the user to invite</param> /// <param name="message">A message to send along with the invitation</param> public Cookie InviteToChatRoom(ChatRoom chatroom, string screenName, string message) { if (!parent.LoggedIn) { throw new NotLoggedInException(); } SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = SNAC_ICBM_FAMILY; sh.FamilySubtypeID = ICBM_OUTGOING_MESSAGE; Cookie cookie = Cookie.CreateCookieForSending(); Encoding enc = Encoding.ASCII; byte destlength = (byte) enc.GetByteCount(screenName); ushort messagelength = (ushort) enc.GetByteCount(message); byte roomnamelength = (byte) enc.GetByteCount(chatroom.FullName); ByteStream stream = new ByteStream(); InsertIcbmHeader(stream, cookie, 0x0002, screenName); ByteStream header = new ByteStream(); header.WriteUshort(0x0000); header.WriteByteArray(cookie.ToByteArray()); header.WriteUint(0x748F2420); header.WriteUint(0x628711D1); header.WriteUint(0x82224445); header.WriteUint(0x53540000); using (TlvBlock tlv05 = new TlvBlock()) { tlv05.WriteUshort(0x000A, 0x0001); tlv05.WriteEmpty(0x000F); tlv05.WriteString(0x000C, message, enc); ByteStream tlv2711 = new ByteStream(); tlv2711.WriteUshort(chatroom.Exchange); tlv2711.WriteByte(roomnamelength); tlv2711.WriteString(chatroom.FullName, enc); tlv2711.WriteUshort(chatroom.Instance); tlv05.WriteByteArray(0x2711, tlv2711.GetBytes()); header.WriteByteArray(tlv05.GetBytes()); } stream.WriteUshort(0x0005); stream.WriteUshort((ushort) header.GetByteCount()); stream.WriteByteArray(header.GetBytes()); SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(parent, sh, stream)); return cookie; }
/// <summary> /// Sends an out-of-the-country text message /// </summary> /// <param name="sess">A <see cref="ISession"/> object</param> /// <param name="number">The number to which to send the message</param> /// <param name="message">The message to send</param> /// <param name="alias">The sender's alias</param> /// <remarks><paramref name="message"/> must be in codepage 1252. A delivery receipt /// is automatically requested by this method.</remarks> public static void SendSMSMessage(ISession sess, string number, string message, string alias) { string xmlformat = "<icq_sms_message>\n" + "\t<destination>{0}</destination>\n" + "\t<text>{1}</text>\n" + "\t<codepage>1252</codepage>\n" + "\t<senders_UIN>{2}</senders_UIN>\n" + "\t<senders_name>{3}</senders_name>\n" + "\t<delivery_receipt>Yes</delivery_receipt>\n" + "\t<time>{4}</time>\n" + "</icq_sms_message>\n"; string xml = String.Format(xmlformat, number, message, sess.ScreenName, alias, DateTime.Now.ToString("r")); SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = (ushort) SNACFamily.ICQExtensionsService; sh.FamilySubtypeID = (ushort) ICQExtensionsService.MetaInformationRequest; sh.Flags = 0x0000; sh.RequestID = Session.GetNextRequestID(); ByteStream stream = new ByteStream(); stream.WriteUshort(0x0001); stream.WriteUshort(0x000A); stream.WriteUshort(0x0008); stream.WriteUint(uint.Parse(sess.ScreenName)); stream.WriteUshortLE(0x07D0); stream.WriteUshortLE((ushort) sh.RequestID); stream.WriteUshort(0x8214); stream.WriteUshort(0x0001); stream.WriteUshort(0x0016); stream.WriteUint(0x00000000); stream.WriteUint(0x00000000); stream.WriteUint(0x00000000); stream.WriteUint(0x00000000); stream.WriteUshort(0x0000); stream.WriteUshort((ushort) Encoding.ASCII.GetByteCount(xml)); stream.WriteString(xml, Encoding.ASCII); stream.WriteByte(0x00); SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream)); }
/// <summary> /// Requests all user information from the server /// </summary> /// <param name="screenname">The screenname to get information about</param> /// <remarks>Results are returned by the <see cref="UserInfoReceived"/> event</remarks> public void RequestAllUserInfo(string screenname) { //KSD-SYSTEMS - commented at 24.02.2010 -> I want AllUserInfo, no Redirect // If the requested information is an ICQ name, redirect this //if (ScreennameVerifier.IsValidICQ(screenname)) //{ // RequestBasicUserInfo(screenname, BasicUserInfoRequest.AwayMessage); // return; //} // Build SNAC(02,15) SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = SNAC_LOCATION_FAMILY; sh.FamilySubtypeID = LOCATION_REQUEST_ALL_INFO; ByteStream stream = new ByteStream(); stream.WriteUint((uint)(UserInfoRequest.AwayMessage | UserInfoRequest.Capabilities | UserInfoRequest.UserProfile)); stream.WriteByte((byte)Encoding.ASCII.GetByteCount(screenname)); stream.WriteString(screenname, Encoding.ASCII); SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(parent, sh, stream)); }
/// <summary> /// Sets the client's extended status -- SNAC(01,1E) /// </summary> /// <param name="sess">A <see cref="Session"/> object</param> /// <param name="availablemessage">The available message to set</param> /// <param name="flags">The ICQ flags to set</param> /// <param name="status">The ICQ status to set</param> /// <remarks>Either the available message or the flags/status can be set in one call to SetExtendedStatus</remarks> private static void SetExtendedStatus(Session sess, string availablemessage, ICQFlags flags, ICQStatus status) { SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = (ushort)SNACFamily.BasicOscarService; sh.FamilySubtypeID = (ushort)GenericServiceControls.SetExtendedStatus; sh.Flags = 0x0000; sh.RequestID = Session.GetNextRequestID(); ByteStream stream = new ByteStream(); if (availablemessage != null) { stream.WriteUshort(0x001D); stream.WriteUshort((ushort)(availablemessage.Length + 8)); stream.WriteUshort(0x0002); stream.WriteByte(0x04); stream.WriteByte((byte)(Encoding.ASCII.GetByteCount(availablemessage) + 4)); stream.WriteUshort((ushort)Encoding.ASCII.GetByteCount(availablemessage)); stream.WriteString(availablemessage, Encoding.ASCII); stream.WriteUshort(0x0000); } else { uint stat = (uint)((ushort)flags << 16); stat |= (ushort)status; stream.WriteUint(0x00060004); stream.WriteUint(stat); } DataPacket dp = Marshal.BuildDataPacket(sess, sh, stream); dp.ParentConnection = sess.Connections.BOSConnection; SNACFunctions.BuildFLAP(dp); }
/// <summary> /// Sets the client's DC info -- SNAC(01,1E) /// </summary> /// <remarks>see <see cref="UserDCInfo"/> for contact info</remarks> internal void SetDCInfo() { SNACHeader sh = new SNACHeader(SNAC_BOS_FAMILY, BOS_SET_EXTENDED_STATUS); ByteStream stream = new ByteStream(); // Header stream.WriteUshort(0x000c); stream.WriteUshort(0x0025); // Values from Icq 6.5 & 7 dumping // Miranda use other Values (see CIcqProto::handleServUINSettings) stream.WriteUint(0); // IP stream.WriteUint(0); // Port stream.WriteByte((byte)DCType.Disabled); // DC type stream.WriteUshort((ushort)DCProtocol.IcqLite); // DC protocol version stream.WriteInt(AuthCookie); // DC auth cookie stream.WriteUint(0); // Web front port stream.WriteUint(0); // Client futures stream.WriteUint(0); // last info update time stream.WriteUint(0); // last ext info update time (i.e. icqphone status) stream.WriteUint(0); // last ext status update time (i.e. phonebook) stream.WriteUshort(0); // unknown DataPacket dp = Marshal.BuildDataPacket(parent, sh, stream); dp.ParentConnection = parent.Connections.BOSConnection; SNACFunctions.BuildFLAP(dp); }
/// <summary> /// Requests a single type of user information from the server /// </summary> /// <param name="screenname">The screenname to get information about</param> /// <param name="requesttype">The type of information to retrieve</param> /// <remarks>Results are returned by the <see cref="UserInfoReceived"/> event</remarks> public void RequestBasicUserInfo(string screenname, BasicUserInfoRequest requesttype) { // Build SNAC(02,05) SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = SNAC_LOCATION_FAMILY; sh.FamilySubtypeID = LOCATION_REQUEST_BASIC_INFO; ByteStream stream = new ByteStream(); stream.WriteUshort((ushort)requesttype); stream.WriteByte((byte)Encoding.ASCII.GetByteCount(screenname)); stream.WriteString(screenname, Encoding.ASCII); SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(parent, sh, stream)); }
/// <summary> /// Sends a status report to the OSCAR server -- SNAC(0B,03) /// </summary> /// <param name="sess">A <see cref="ISession"/> object</param> /// <remarks>libfaim does not send this report</remarks> public static void SendStatusReport(ISession sess) { SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = (ushort)SNACFamily.UsageStatsService; sh.FamilySubtypeID = (ushort)UsageStatsService.UsageReport; sh.Flags = 0; sh.RequestID = Session.GetNextRequestID(); // Get the necessary strings together string sn = sess.ScreenName; // Here we start lying until I can figure out how to get *all* the values in .NET string osversion = Environment.OSVersion.ToString(); string osname = "Windows 98"; //osversion.Substring(0, osversion.LastIndexOf(" ") - 1); string osver = "4.10.67766446"; //osversion.Substring(osversion.LastIndexOf(" ") + 1); string procname = "Intel Pentium"; string winsockname = "Microsoft Corporation BSD Socket API for Windows"; string winsockver = "4.1.1998"; Encoding enc = Encoding.ASCII; byte snlength = (byte)enc.GetByteCount(sn); ushort osversionlength = (ushort)enc.GetByteCount(osversion); ushort osnamelength = (ushort)enc.GetByteCount(osname); ushort osverlength = (ushort)enc.GetByteCount(osver); ushort procnamelength = (ushort)enc.GetByteCount(procname); ushort winsocknamelength = (ushort)enc.GetByteCount(winsockname); ushort winsockverlength = (ushort)enc.GetByteCount(winsockver); ByteStream mainStream = new ByteStream(); using (ByteStream stream = new ByteStream()) { TimeSpan t = (DateTime.Now - new DateTime(1970, 1, 1)); stream.WriteUint((uint)t.Seconds); t = (DateTime.UtcNow - new DateTime(1970, 1, 1).ToUniversalTime()); stream.WriteUint((uint)t.Seconds); stream.WriteUint(0x00000000); stream.WriteUint(0x00000000); stream.WriteUint(0x00000000); stream.WriteUint(0x00000000); stream.WriteByte(snlength); stream.WriteString(sn, Encoding.ASCII); stream.WriteUshort(osnamelength); stream.WriteString(osname, Encoding.ASCII); stream.WriteUshort(osverlength); stream.WriteString(osver, Encoding.ASCII); stream.WriteUshort(procnamelength); stream.WriteString(procname, Encoding.ASCII); stream.WriteUshort(winsocknamelength); stream.WriteString(winsockname, Encoding.ASCII); stream.WriteUshort(winsockverlength); stream.WriteString(winsockver, Encoding.ASCII); stream.WriteUint(0x00000002); stream.WriteUint(0x00010001); stream.WriteUint(0x00020002); using (TlvBlock tlv = new TlvBlock()) { tlv.WriteByteArray(0x0009, stream.GetBytes()); mainStream.WriteTlvBlock(tlv); } } SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, mainStream)); }
/// <summary> /// Sends an XML string /// </summary> /// <param name="sess">A <see cref="ISession"/> object</param> /// <param name="xml">The contents of an XML document</param> /// <remarks>I have no idea how to use this.</remarks> public static void SendXmlRequest(ISession sess, string xml) { SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = (ushort) SNACFamily.ICQExtensionsService; sh.FamilySubtypeID = (ushort) ICQExtensionsService.MetaInformationRequest; sh.Flags = 0x0000; sh.RequestID = Session.GetNextRequestID(); ByteStream stream = new ByteStream(); stream.WriteUshort(0x0001); stream.WriteUshort(0x000A); stream.WriteUshort(0x0008); stream.WriteUint(uint.Parse(sess.ScreenName)); stream.WriteUshortLE(0x07D0); stream.WriteUshortLE((ushort) sh.RequestID); stream.WriteUshort(0x0998); stream.WriteUshort((ushort) Encoding.ASCII.GetByteCount(xml)); stream.WriteString(xml, Encoding.ASCII); stream.WriteByte(0x00); SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream)); }
/// <summary> /// Downloads a buddy icon from the AIM servers /// </summary> /// <param name="screenName">The screenname to which the icon belongs</param> /// <param name="iconId">The ID of the icon stored on the server</param> public void DownloadBuddyIcon(string screenName, BartID iconId) { // Check to make sure the icon ID is valid and actually a buddy icon if (iconId == null || iconId.Data == null || !(iconId.Type == BartTypeId.BuddyIcon || iconId.Type == BartTypeId.BigBuddyIcon)) { return; } // Check to see if the icon's cached, if the cache location is set if (!String.IsNullOrEmpty(AutoSaveLocation)) { string saveLocation = Path.Combine(AutoSaveLocation, iconId.ToString()); if (File.Exists(saveLocation)) { OnBuddyIconDownloaded(screenName, iconId, saveLocation); return; } } // Check to see if there's already a request in progress for this icon ID if (currentlyDownloading.Contains(iconId)) { return; } currentlyDownloading.Add(iconId); SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = SNAC_BART_FAMILY; sh.FamilySubtypeID = BART_DOWNLOAD; sh.Flags = 0; ByteStream stream = new ByteStream(); stream.WriteByte((byte)Encoding.ASCII.GetByteCount(screenName)); stream.WriteString(screenName, Encoding.ASCII); stream.WriteByte(0x01); stream.WriteBartID(iconId); SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(parent, sh, stream)); }