/// <summary> /// Sets the user's directory information -- SNAC(02,09) /// </summary> /// <param name="sess">A <see cref="Session"/> object</param> /// <param name="allow"><c>true</c> if other users may search this information, <c>false</c> if not</param> /// <param name="firstname">A first name</param> /// <param name="middlename">A middle name</param> /// <param name="lastname">A last name</param> /// <param name="maidenname">A maiden name</param> /// <param name="nickname">A nickname</param> /// <param name="city">A city</param> /// <param name="state">A state</param> /// <param name="country">A country (two-letter code)</param> /// <param name="zip">A ZIP code</param> /// <param name="address">An address</param> public static void SetDirectoryInformation( Session sess, bool allow, string firstname, string middlename, string lastname, string maidenname, string nickname, string city, string state, string country, string zip, string address) { SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = (ushort)SNACFamily.LocationService; sh.FamilySubtypeID = (ushort)LocationServices.UpdateDirectoryInfoRequest; ByteStream stream = new ByteStream(); using (TlvBlock tlvs = new TlvBlock()) { tlvs.WriteUshort(0x001A, (ushort)((allow) ? 0x0001 : 0x0000)); tlvs.WriteString(DIRECTORY_FIRSTNAME, firstname, Encoding.ASCII); tlvs.WriteString(DIRECTORY_MIDDLENAME, middlename, Encoding.ASCII); tlvs.WriteString(DIRECTORY_LASTNAME, lastname, Encoding.ASCII); tlvs.WriteString(DIRECTORY_MAIDENNAME, maidenname, Encoding.ASCII); tlvs.WriteString(DIRECTORY_COUNTRY, country, Encoding.ASCII); tlvs.WriteString(DIRECTORY_STATE, state, Encoding.ASCII); tlvs.WriteString(DIRECTORY_CITY, city, Encoding.ASCII); tlvs.WriteString(DIRECTORY_NICKNAME, nickname, Encoding.ASCII); tlvs.WriteString(DIRECTORY_ZIPCODE, zip, Encoding.ASCII); tlvs.WriteString(DIRECTORY_ADDRESS, address, Encoding.ASCII); stream.WriteByteArray(tlvs.GetBytes()); } SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream)); }
/// <summary> /// Sends an AIM invitation to a receipient -- SNAC(06,02) /// </summary> /// <param name="sess">A <see cref="ISession"/> object</param> /// <param name="email">The email address of the person to invite</param> /// <param name="text">The text of the invitation</param> public static void SendInvitiationRequest(ISession sess, string email, string text) { SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = (ushort) SNACFamily.PrivacyManagementService; sh.FamilySubtypeID = (ushort) PrivacyManagementService.ServiceParametersRequest; sh.Flags = 0x0000; sh.RequestID = Session.GetNextRequestID(); ByteStream stream = new ByteStream(); using (TlvBlock tlvs = new TlvBlock()) { tlvs.WriteString(0x0011, email, Encoding.ASCII); tlvs.WriteString(0x0015, text, Encoding.ASCII); stream.WriteTlvBlock(tlvs); } SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream)); }
/// <summary> /// Performs a directory search by interest -- SNAC(0F,02) /// </summary> /// <param name="sess">A <see cref="Session"/> object</param> /// <param name="interest">The interest to search for</param> public static void SearchByInterest(Session sess, string interest) { SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = (ushort)SNACFamily.DirectoryUserSearch; sh.FamilySubtypeID = (ushort)DirectorySearch.SearchUserRequest; ByteStream stream = new ByteStream(); using (TlvBlock tlvs = new TlvBlock()) { tlvs.WriteString(0x001C, "us-ascii", Encoding.ASCII); tlvs.WriteUshort(0x000A, 0x0001); tlvs.WriteString(0x0001, interest, Encoding.ASCII); stream.WriteTlvBlock(tlvs); } SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream)); }
/// <summary> /// Sends an AIM invitation to a receipient -- SNAC(06,02) /// </summary> /// <param name="sess">A <see cref="ISession"/> object</param> /// <param name="email">The email address of the person to invite</param> /// <param name="text">The text of the invitation</param> public static void SendInvitiationRequest(ISession sess, string email, string text) { SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = (ushort)SNACFamily.PrivacyManagementService; sh.FamilySubtypeID = (ushort)PrivacyManagementService.ServiceParametersRequest; sh.Flags = 0x0000; sh.RequestID = Session.GetNextRequestID(); ByteStream stream = new ByteStream(); using (TlvBlock tlvs = new TlvBlock()) { tlvs.WriteString(0x0011, email, Encoding.ASCII); tlvs.WriteString(0x0015, text, Encoding.ASCII); stream.WriteTlvBlock(tlvs); } SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream)); }
/// <summary> /// Sends authorization request -- SNAC(17,02) /// </summary> /// <param name="dp">A <see cref="DataPacket"/> object containing SNAC(17,07)</param> public static void SendAuthorizationRequest(DataPacket dp) { // Pull apart SNAC(17,07) byte[] key = dp.Data.ReadByteArray(dp.Data.ReadUshort()); // Construct SNAC(17,02) SNACHeader header = new SNACHeader(); header.FamilyServiceID = (ushort)SNACFamily.AuthorizationRegistrationService; header.FamilySubtypeID = (ushort)AuthorizationRegistrationService.LoginRequest; header.Flags = 0; header.RequestID = Session.GetNextRequestID(); OSCARIdentification id = dp.ParentSession.ClientIdentification; ByteStream stream = new ByteStream(); using (TlvBlock tlvs = new TlvBlock()) { tlvs.WriteString(0x0001, dp.ParentSession.ScreenName, Encoding.ASCII); tlvs.WriteString(0x0003, id.ClientName, Encoding.ASCII); tlvs.WriteString(0x000F, "en", Encoding.ASCII); tlvs.WriteString(0x000E, "us", Encoding.ASCII); tlvs.WriteUint(0x0014, id.ClientDistribution); tlvs.WriteUshort(0x0016, id.ClientId); tlvs.WriteUshort(0x0017, id.ClientMajor); tlvs.WriteUshort(0x0018, id.ClientMinor); tlvs.WriteUshort(0x0019, id.ClientLesser); tlvs.WriteUshort(0x001A, id.ClientBuild); tlvs.WriteByteArray(0x0025, dp.ParentSession.HashPassword(key)); tlvs.WriteByte(0x004A, 0x01); tlvs.WriteEmpty(0x004C); stream.WriteTlvBlock(tlvs); } DataPacket newPacket = Marshal.BuildDataPacket(dp.ParentSession, header, stream); newPacket.ParentConnection = dp.ParentConnection; SNACFunctions.BuildFLAP(newPacket); }
/// <summary> /// Sends authorization request -- SNAC(17,02) /// </summary> /// <param name="dp">A <see cref="DataPacket"/> object containing SNAC(17,07)</param> public static void SendAuthorizationRequest(DataPacket dp) { // Pull apart SNAC(17,07) byte[] key = dp.Data.ReadByteArray(dp.Data.ReadUshort()); // Construct SNAC(17,02) SNACHeader header = new SNACHeader(); header.FamilyServiceID = (ushort) SNACFamily.AuthorizationRegistrationService; header.FamilySubtypeID = (ushort) AuthorizationRegistrationService.LoginRequest; header.Flags = 0; header.RequestID = Session.GetNextRequestID(); OSCARIdentification id = dp.ParentSession.ClientIdentification; ByteStream stream = new ByteStream(); using (TlvBlock tlvs = new TlvBlock()) { tlvs.WriteString(0x0001, dp.ParentSession.ScreenName, Encoding.ASCII); tlvs.WriteString(0x0003, id.ClientName, Encoding.ASCII); tlvs.WriteString(0x000F, "en", Encoding.ASCII); tlvs.WriteString(0x000E, "us", Encoding.ASCII); tlvs.WriteUint(0x0014, id.ClientDistribution); tlvs.WriteUshort(0x0016, id.ClientId); tlvs.WriteUshort(0x0017, id.ClientMajor); tlvs.WriteUshort(0x0018, id.ClientMinor); tlvs.WriteUshort(0x0019, id.ClientLesser); tlvs.WriteUshort(0x001A, id.ClientBuild); tlvs.WriteByteArray(0x0025, dp.ParentSession.HashPassword(key)); tlvs.WriteByte(0x004A, 0x01); tlvs.WriteEmpty(0x004C); stream.WriteTlvBlock(tlvs); } DataPacket newPacket = Marshal.BuildDataPacket(dp.ParentSession, header, stream); newPacket.ParentConnection = dp.ParentConnection; SNACFunctions.BuildFLAP(newPacket); }
/// <summary> /// Send MD5 key request -- SNAC(17,06) /// </summary> /// <param name="sess">A <see cref="ISession"/> object</param> public static void SendMD5Request(ISession sess) { /*** Send SNAC(17,06) to get the auth key ***/ SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = (ushort)SNACFamily.AuthorizationRegistrationService; sh.FamilySubtypeID = (ushort)AuthorizationRegistrationService.MD5AuthkeyRequest; sh.Flags = 0x0000; sh.RequestID = Session.GetNextRequestID(); ByteStream stream = new ByteStream(); using (TlvBlock tlvs = new TlvBlock()) { tlvs.WriteString(0x0001, sess.ScreenName, Encoding.ASCII); tlvs.WriteEmpty(0x004B); tlvs.WriteEmpty(0x005A); stream.WriteTlvBlock(tlvs); } SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream)); }
/// <summary> /// Sets the user's interests list -- SNAC(02,0F) /// </summary> /// <param name="sess">A <see cref="Session"/> object</param> /// <param name="allow"><c>true</c> if other users may search this information, <c>false</c> if not</param> /// <param name="interests">An array of interest names</param> /// <remarks> /// OSCAR allows a user to set up to five interests. If <paramref name="interests"/> contains /// more than five items, only the first five are used. /// </remarks> public static void SetInterestsInformation(Session sess, bool allow, string[] interests) { SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = (ushort)SNACFamily.LocationService; sh.FamilySubtypeID = (ushort)LocationServices.UpdateInterestsRequest; ByteStream stream = new ByteStream(); using (TlvBlock tlvs = new TlvBlock()) { tlvs.WriteUshort(INTERESTS_ALLOWSEARCH, (ushort)((allow) ? 0x0001 : 0x0000)); for (int i = 0; i < interests.Length && i < 5; i++) { tlvs.WriteString(INTERESTS_INTEREST, interests[i], Encoding.ASCII); } stream.WriteByteArray(tlvs.GetBytes()); } SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream)); }
/// <summary> /// Sends authorization request -- SNAC(17,02) /// </summary> /// <param name="dp">A <see cref="DataPacket"/> object containing SNAC(17,07)</param> void SendAuthorizationRequest(DataPacket dp) { // Pull apart SNAC(17,07) byte[] key = dp.Data.ReadByteArray(dp.Data.ReadUshort()); // Construct SNAC(17,02) SNACHeader header = new SNACHeader(); header.FamilyServiceID = SNAC_AUTH_FAMILY; header.FamilySubtypeID = AUTH_LOGIN_REQUEST; OSCARIdentification id = parent.ClientIdentification; ByteStream stream = new ByteStream(); using (TlvBlock tlvs = new TlvBlock()) { tlvs.WriteString(0x0001, parent.ScreenName, Encoding.ASCII); tlvs.WriteString(0x0003, id.ClientName, Encoding.ASCII); tlvs.WriteString(0x000F, "en", Encoding.ASCII); tlvs.WriteString(0x000E, "us", Encoding.ASCII); tlvs.WriteUint(0x0014, id.ClientDistribution); tlvs.WriteUshort(0x0016, id.ClientId); tlvs.WriteUshort(0x0017, id.ClientMajor); tlvs.WriteUshort(0x0018, id.ClientMinor); tlvs.WriteUshort(0x0019, id.ClientLesser); tlvs.WriteUshort(0x001A, id.ClientBuild); tlvs.WriteByteArray(0x0025, parent.HashPassword(key)); tlvs.WriteByte(0x004A, 0x01); tlvs.WriteEmpty(0x004C); stream.WriteTlvBlock(tlvs); } DataPacket newPacket = Marshal.BuildDataPacket(parent, header, stream); newPacket.ParentConnection = dp.ParentConnection; SNACFunctions.BuildFLAP(newPacket); }
/// <summary> /// Kicks off the authorization hash request when the initial connection is complete /// </summary> void loginConnection_ServerConnectionCompleted(Connection conn) { conn.ReadyForData = true; /*** Send SNAC(17,06) to get the auth key ***/ SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = SNAC_AUTH_FAMILY; sh.FamilySubtypeID = AUTH_KEY_REQUEST; ByteStream stream = new ByteStream(); using (TlvBlock tlvs = new TlvBlock()) { tlvs.WriteString(0x0001, parent.ScreenName, Encoding.ASCII); tlvs.WriteEmpty(0x004B); tlvs.WriteEmpty(0x005A); stream.WriteTlvBlock(tlvs); } SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(parent, sh, stream)); conn.ReadHeader(); }
/// <summary> /// Send MD5 key request -- SNAC(17,06) /// </summary> /// <param name="sess">A <see cref="ISession"/> object</param> public static void SendMD5Request(ISession sess) { /*** Send SNAC(17,06) to get the auth key ***/ SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = (ushort) SNACFamily.AuthorizationRegistrationService; sh.FamilySubtypeID = (ushort) AuthorizationRegistrationService.MD5AuthkeyRequest; sh.Flags = 0x0000; sh.RequestID = Session.GetNextRequestID(); ByteStream stream = new ByteStream(); using (TlvBlock tlvs = new TlvBlock()) { tlvs.WriteString(0x0001, sess.ScreenName, Encoding.ASCII); tlvs.WriteEmpty(0x004B); tlvs.WriteEmpty(0x005A); stream.WriteTlvBlock(tlvs); } SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream)); }
/// <summary> /// Sets the away message and/or profile of the client /// </summary> /// <param name="awayMessage">The away message to set</param> /// <param name="profile">The profile to set</param> private void SetAwayMessageProfileInternal(string awayMessage, string profile) { // Build the SNAC header SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = SNAC_LOCATION_FAMILY; sh.FamilySubtypeID = LOCATION_PARAMETER_USERINFO; ByteStream stream = new ByteStream(); using (TlvBlock tlvs = new TlvBlock()) { if (profile != null) { Encoding profileEncoding = UtilityMethods.FindBestOscarEncoding(profile); tlvs.WriteString(LOCATION_PROFILE_ENCODING, Marshal.EncodingToAolMime(profileEncoding), Encoding.ASCII); tlvs.WriteString(LOCATION_PROFILE, profile, profileEncoding); } if (awayMessage != null) { Encoding awayMessageEncoding = UtilityMethods.FindBestOscarEncoding(awayMessage); tlvs.WriteString(LOCATION_AWAYMESSAGE_ENCODING, Marshal.EncodingToAolMime(awayMessageEncoding), Encoding.ASCII); tlvs.WriteString(LOCATION_AWAYMESSAGE, awayMessage, awayMessageEncoding); } stream.WriteByteArray(tlvs.GetBytes()); } SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(parent, sh, stream)); }
/// <summary> /// Performs a directory search by interest -- SNAC(0F,02) /// </summary> /// <param name="sess">A <see cref="Session"/> object</param> /// <param name="interest">The interest to search for</param> public static void SearchByInterest(Session sess, string interest) { SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = (ushort) SNACFamily.DirectoryUserSearch; sh.FamilySubtypeID = (ushort) DirectorySearch.SearchUserRequest; ByteStream stream = new ByteStream(); using (TlvBlock tlvs = new TlvBlock()) { tlvs.WriteString(0x001C, "us-ascii", Encoding.ASCII); tlvs.WriteUshort(0x000A, 0x0001); tlvs.WriteString(0x0001, interest, Encoding.ASCII); stream.WriteTlvBlock(tlvs); } SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream)); }
/// <summary> /// Cancel a direct connection attempt /// </summary> public void SendDirectConnectionCancellation(DirectConnection conn, string reason) { 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.Cancel)); tlv05.WriteByteArray(conn.Cookie.ToByteArray()); tlv05.WriteByteArray(CapabilityProcessor.GetCapabilityArray(conn.Capability)); using (TlvBlock tlvs = new TlvBlock()) { tlvs.WriteUshort(0x000B, 0x0001); tlvs.WriteString(0x000C, reason, Encoding.ASCII); tlvs.WriteEmpty(0x0003); //KSD-SYSTEMS - commented at 02.12.2009 -> Canceling = Send Message only with Cookie //tlv05.WriteByteArray(tlvs.GetBytes()); } stream.WriteUshort(0x0005); stream.WriteUshort((ushort)tlv05.GetByteCount()); stream.WriteByteArray(tlv05.GetBytes()); } SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(parent, sh, stream)); }
/// <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> /// 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> /// Performs a directory search by personal information -- SNAC(0F,02) /// </summary> /// <param name="sess">A <see cref="Session"/> object</param> /// <param name="items">The number of non-null search terms</param> /// <param name="firstname">A first name</param> /// <param name="middlename">A middle name</param> /// <param name="lastname">A last name</param> /// <param name="maidenname">A maiden name</param> /// <param name="nickname">A nickname</param> /// <param name="city">A city</param> /// <param name="state">A state</param> /// <param name="country">A country (two letter code)</param> /// <param name="zip">A ZIP code</param> /// <param name="address">An address</param> /// <remarks> /// <para>If a search term is to be ignored, it must be set to <c>null</c>.</para> /// <para>There must be at least one non-null search term.</para></remarks> public static void SearchByInfo( Session sess, int items, string firstname, string middlename, string lastname, string maidenname, string nickname, string city, string state, string country, string zip, string address) { SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = (ushort)SNACFamily.DirectoryUserSearch; sh.FamilySubtypeID = (ushort)DirectorySearch.SearchUserRequest; ByteStream stream = new ByteStream(); using (TlvBlock tlvs = new TlvBlock()) { tlvs.WriteString(0x001C, "us-ascii", Encoding.ASCII); tlvs.WriteUshort(0x000A, 0x0000); if (firstname != null) { tlvs.WriteString(0x0001, firstname, Encoding.ASCII); } if (middlename != null) { tlvs.WriteString(0x0002, middlename, Encoding.ASCII); } if (lastname != null) { tlvs.WriteString(0x0003, lastname, Encoding.ASCII); } if (maidenname != null) { tlvs.WriteString(0x0004, maidenname, Encoding.ASCII); } if (country != null) { tlvs.WriteString(0x0006, country, Encoding.ASCII); } if (state != null) { tlvs.WriteString(0x0007, state, Encoding.ASCII); } if (city != null) { tlvs.WriteString(0x0008, city, Encoding.ASCII); } if (nickname != null) { tlvs.WriteString(0x000C, nickname, Encoding.ASCII); } if (zip != null) { tlvs.WriteString(0x000D, zip, Encoding.ASCII); } if (address != null) { tlvs.WriteString(0x0021, address, Encoding.ASCII); } stream.WriteTlvBlock(tlvs); } SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream)); }
/// <summary> /// Performs a directory search by personal information -- SNAC(0F,02) /// </summary> /// <param name="sess">A <see cref="Session"/> object</param> /// <param name="items">The number of non-null search terms</param> /// <param name="firstname">A first name</param> /// <param name="middlename">A middle name</param> /// <param name="lastname">A last name</param> /// <param name="maidenname">A maiden name</param> /// <param name="nickname">A nickname</param> /// <param name="city">A city</param> /// <param name="state">A state</param> /// <param name="country">A country (two letter code)</param> /// <param name="zip">A ZIP code</param> /// <param name="address">An address</param> /// <remarks> /// <para>If a search term is to be ignored, it must be set to <c>null</c>.</para> /// <para>There must be at least one non-null search term.</para></remarks> public static void SearchByInfo( Session sess, int items, string firstname, string middlename, string lastname, string maidenname, string nickname, string city, string state, string country, string zip, string address) { SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = (ushort) SNACFamily.DirectoryUserSearch; sh.FamilySubtypeID = (ushort) DirectorySearch.SearchUserRequest; ByteStream stream = new ByteStream(); using (TlvBlock tlvs = new TlvBlock()) { tlvs.WriteString(0x001C, "us-ascii", Encoding.ASCII); tlvs.WriteUshort(0x000A, 0x0000); if (firstname != null) tlvs.WriteString(0x0001, firstname, Encoding.ASCII); if (middlename != null) tlvs.WriteString(0x0002, middlename, Encoding.ASCII); if (lastname != null) tlvs.WriteString(0x0003, lastname, Encoding.ASCII); if (maidenname != null) tlvs.WriteString(0x0004, maidenname, Encoding.ASCII); if (country != null) tlvs.WriteString(0x0006, country, Encoding.ASCII); if (state != null) tlvs.WriteString(0x0007, state, Encoding.ASCII); if (city != null) tlvs.WriteString(0x0008, city, Encoding.ASCII); if (nickname != null) tlvs.WriteString(0x000C, nickname, Encoding.ASCII); if (zip != null) tlvs.WriteString(0x000D, zip, Encoding.ASCII); if (address != null) tlvs.WriteString(0x0021, address, Encoding.ASCII); stream.WriteTlvBlock(tlvs); } SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream)); }