/// <summary> /// Set the status of the contact list owner (the client). /// </summary> /// <remarks>You can only set the status _after_ SignedIn event. Otherwise you won't receive online notifications from other clients or the connection is closed by the server.</remarks> internal void SetPresenceStatus( PresenceStatus newStatus, ClientCapabilities newLocalIMCaps, ClientCapabilitiesEx newLocalIMCapsex, ClientCapabilities newLocalPECaps, ClientCapabilitiesEx newLocalPECapsex, string newEPName, PersonalMessage newPSM, bool forcePEservice) { if (IsSignedIn == false) throw new MSNPSharpException("Can't set status. You must wait for the SignedIn event before you can set an initial status."); if (newStatus == PresenceStatus.Offline) { SignoutFrom(MachineGuid); return; } bool setAll = (Owner.Status == PresenceStatus.Offline); if (setAll || forcePEservice || newStatus != Owner.Status || newLocalIMCaps != Owner.LocalEndPointIMCapabilities || newLocalIMCapsex != Owner.LocalEndPointIMCapabilitiesEx || newLocalPECaps != Owner.LocalEndPointPECapabilities || newLocalPECapsex != Owner.LocalEndPointPECapabilitiesEx || newEPName != Owner.EpName) { XmlDocument xmlDoc = new XmlDocument(); XmlElement userElement = xmlDoc.CreateElement("user"); // s.IM (Status, CurrentMedia) if (setAll || forcePEservice || newStatus != Owner.Status) { XmlElement service = xmlDoc.CreateElement("s"); service.SetAttribute("n", ServiceShortNames.IM.ToString()); service.InnerXml = "<Status>" + ParseStatus(newStatus) + "</Status>" + "<CurrentMedia>" + MSNHttpUtility.XmlEncode(newPSM.CurrentMedia) + "</CurrentMedia>"; userElement.AppendChild(service); // Don't call Owner.Status = newStatus. } // s.PE (UserTileLocation, FriendlyName, PSM, Scene, ColorScheme) if (setAll || forcePEservice) { XmlElement service = xmlDoc.CreateElement("s"); service.SetAttribute("n", ServiceShortNames.PE.ToString()); service.InnerXml = newPSM.Payload; userElement.AppendChild(service); // Don't set owner.PersonalMessage here. It is replaced (with a new reference) when NFY PUT received. } // sep.IM (Capabilities) if (setAll || newLocalIMCaps != Owner.LocalEndPointIMCapabilities || newLocalIMCapsex != Owner.LocalEndPointIMCapabilitiesEx) { ClientCapabilities localIMCaps = setAll ? ClientCapabilities.DefaultIM : newLocalIMCaps; ClientCapabilitiesEx localIMCapsEx = setAll ? ClientCapabilitiesEx.DefaultIM : newLocalIMCapsex; XmlElement sep = xmlDoc.CreateElement("sep"); sep.SetAttribute("n", ServiceShortNames.IM.ToString()); XmlElement capabilities = xmlDoc.CreateElement("Capabilities"); capabilities.InnerText = ((long)localIMCaps).ToString() + ":" + ((long)localIMCapsEx).ToString(); sep.AppendChild(capabilities); userElement.AppendChild(sep); // Don't call Owner.LocalEndPointIMCapabilities. It is recursive call to this method. } // sep.PE (Capabilities) if (setAll || newLocalPECaps != Owner.LocalEndPointPECapabilities || newLocalPECapsex != Owner.LocalEndPointPECapabilitiesEx) { ClientCapabilities localPECaps = setAll ? ClientCapabilities.DefaultPE : newLocalPECaps; ClientCapabilitiesEx localPECapsEx = setAll ? ClientCapabilitiesEx.DefaultPE : newLocalPECapsex; XmlElement sep = xmlDoc.CreateElement("sep"); sep.SetAttribute("n", ServiceShortNames.PE.ToString()); XmlElement VER = xmlDoc.CreateElement("VER"); VER.InnerText = Credentials.ClientInfo.MessengerClientName + ":" + Credentials.ClientInfo.MessengerClientBuildVer; sep.AppendChild(VER); XmlElement TYP = xmlDoc.CreateElement("TYP"); TYP.InnerText = "1"; sep.AppendChild(TYP); XmlElement capabilities = xmlDoc.CreateElement("Capabilities"); capabilities.InnerText = ((long)localPECaps).ToString() + ":" + ((long)localPECapsEx).ToString(); sep.AppendChild(capabilities); userElement.AppendChild(sep); // Don't call Owner.LocalEndPointPECapabilities. It is recursive call to this method. } // sep.PD (EpName, State) if (setAll || newEPName != Owner.EpName || newStatus != Owner.Status) { XmlElement sep = xmlDoc.CreateElement("sep"); sep.SetAttribute("n", ServiceShortNames.PD.ToString()); XmlElement clientType = xmlDoc.CreateElement("ClientType"); clientType.InnerText = "1"; sep.AppendChild(clientType); XmlElement epName = xmlDoc.CreateElement("EpName"); epName.InnerText = MSNHttpUtility.XmlEncode(newEPName); sep.AppendChild(epName); XmlElement idle = xmlDoc.CreateElement("Idle"); idle.InnerText = ((newStatus == PresenceStatus.Idle) ? "true" : "false"); sep.AppendChild(idle); XmlElement state = xmlDoc.CreateElement("State"); state.InnerText = ParseStatus(newStatus); sep.AppendChild(state); userElement.AppendChild(sep); // Don't set Owner.EpName. It is recursive call to this method. } if (userElement.HasChildNodes) { string xml = userElement.OuterXml; string me = ((int)Owner.ClientType).ToString() + ":" + Owner.Account; MultiMimeMessage mmMessage = new MultiMimeMessage(me, me); mmMessage.RoutingHeaders[MIMERoutingHeaders.From][MIMERoutingHeaders.EPID] = NSMessageHandler.MachineGuid.ToString("B").ToLowerInvariant(); mmMessage.Stream = 1; mmMessage.ReliabilityHeaders[MIMEReliabilityHeaders.Flags] = "ACK"; mmMessage.ContentKey = MIMEContentHeaders.Publication; mmMessage.ContentHeaders[MIMEContentHeaders.URI] = "/user"; mmMessage.ContentHeaders[MIMEContentHeaders.ContentType] = "application/user+xml"; mmMessage.InnerBody = System.Text.Encoding.UTF8.GetBytes(xml); NSMessage nsMessage = new NSMessage("PUT"); nsMessage.InnerMessage = mmMessage; MessageProcessor.SendMessage(nsMessage); } } }
/// <summary> /// Sets personal message. /// </summary> internal void SetPersonalMessage(PersonalMessage newPSM) { if (Owner == null) throw new MSNPSharpException("Not a valid owner"); if (Owner.Status != PresenceStatus.Offline) { SetPresenceStatus( Owner.Status, Owner.LocalEndPointIMCapabilities, Owner.LocalEndPointIMCapabilitiesEx, Owner.LocalEndPointPECapabilities, Owner.LocalEndPointPECapabilitiesEx, Owner.EpName, newPSM, true); } }
private void OnNFYPUTReceived(MultiMimeMessage multiMimeMessage, RoutingInfo routingInfo) { switch (multiMimeMessage.ContentHeaders[MIMEContentHeaders.ContentType].Value) { #region user xml case "application/user+xml": { if (multiMimeMessage.ContentHeaders[MIMEHeaderStrings.NotifType].Value == "Sync") { if (routingInfo.SenderGateway != null && routingInfo.SenderGateway.ClientType == IMAddressInfoType.Circle) { JoinMultiparty(routingInfo.SenderGateway); } //Sync the contact in contact list with the contact in gateway. // TODO: Set the NSMessagehandler.ContactList contact to the gateway // TODO: triger the ContactOnline event for the gateway contact. //Just wait for my fix. } if (multiMimeMessage.InnerBody == null || multiMimeMessage.InnerBody.Length == 0) return; //No xml content. if (multiMimeMessage.ContentHeaders[MIMEHeaderStrings.NotifType].Value == "Full") { //This is an initial NFY } XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(Encoding.UTF8.GetString(multiMimeMessage.InnerBody)); XmlNodeList services = xmlDoc.SelectNodes("//user/s"); XmlNodeList serviceEndPoints = xmlDoc.SelectNodes("//user/sep"); if (services.Count > 0) { foreach (XmlNode service in services) { ServiceShortNames serviceEnum = (ServiceShortNames)Enum.Parse(typeof(ServiceShortNames), service.Attributes["n"].Value); switch (serviceEnum) { case ServiceShortNames.IM: { foreach (XmlNode node in service.ChildNodes) { switch (node.Name) { case "Status": if (routingInfo.FromOwner && IsSignedIn == false) { // We have already signed in another place, but not here... // Don't set status... This place will set the status later. return; } PresenceStatus oldStatus = routingInfo.Sender.Status; PresenceStatus newStatus = ParseStatus(node.InnerText); routingInfo.Sender.SetStatus(newStatus); OnContactStatusChanged(new ContactStatusChangedEventArgs(routingInfo.Sender, routingInfo.SenderGateway, oldStatus, newStatus)); OnContactOnline(new ContactStatusChangedEventArgs(routingInfo.Sender, routingInfo.SenderGateway, oldStatus, newStatus)); break; case "CurrentMedia": //MSNP21TODO: UBX implementation break; } } break; } case ServiceShortNames.PE: { // Create a new reference to fire PersonalMessageChanged event. PersonalMessage personalMessage = new PersonalMessage(service.ChildNodes); if (!String.IsNullOrEmpty(personalMessage.Payload) && routingInfo.Sender.PersonalMessage != personalMessage) { // FriendlyName if (!String.IsNullOrEmpty(personalMessage.FriendlyName)) { //Only Windows Live Messenger Contact has friendly name. routingInfo.Sender.SetName(personalMessage.FriendlyName); } // UserTileLocation if (!String.IsNullOrEmpty(personalMessage.UserTileLocation) && routingInfo.Sender.UserTileLocation != personalMessage.UserTileLocation) { routingInfo.Sender.UserTileLocation = personalMessage.UserTileLocation; routingInfo.Sender.FireDisplayImageContextChangedEvent(personalMessage.UserTileLocation); } // Scene if (!String.IsNullOrEmpty(personalMessage.Scene)) { if (routingInfo.Sender.SceneContext != personalMessage.Scene) { routingInfo.Sender.SceneContext = personalMessage.Scene; routingInfo.Sender.FireSceneImageContextChangedEvent(personalMessage.Scene); } } // ColorScheme if (personalMessage.ColorScheme != Color.Empty) { if (routingInfo.Sender.ColorScheme != personalMessage.ColorScheme) { routingInfo.Sender.ColorScheme = personalMessage.ColorScheme; routingInfo.Sender.OnColorSchemeChanged(); } } // This must be final... routingInfo.Sender.PersonalMessage = personalMessage; } break; } case ServiceShortNames.PF: { // Profile Annotation, it is AB.Me.annotations/Live.Profile.Expression.LastChanged // <user><s n="PF" ts="2011-04-16T06:00:58Z"></s></user> if (routingInfo.FromOwner) { DateTime ts = WebServiceDateTimeConverter.ConvertToDateTime(service.Attributes["ts"].Value); } break; } } } } if (serviceEndPoints.Count > 0) { foreach (XmlNode serviceEndPoint in serviceEndPoints) { ServiceShortNames serviceEnum = (ServiceShortNames)Enum.Parse(typeof(ServiceShortNames), serviceEndPoint.Attributes["n"].Value); Guid epid = serviceEndPoint.Attributes["epid"] == null ? Guid.Empty : new Guid(serviceEndPoint.Attributes["epid"].Value); if (!routingInfo.Sender.EndPointData.ContainsKey(epid)) { lock (routingInfo.Sender.SyncObject) routingInfo.Sender.EndPointData.Add(epid, routingInfo.FromOwner ? new PrivateEndPointData(routingInfo.Sender.Account, epid) : new EndPointData(routingInfo.Sender.Account, epid)); } switch (serviceEnum) { case ServiceShortNames.IM: { foreach (XmlNode node in serviceEndPoint.ChildNodes) { switch (node.Name) { case "Capabilities": ClientCapabilities cap = ClientCapabilities.None; ClientCapabilitiesEx capEx = ClientCapabilitiesEx.None; string[] caps = node.InnerText.Split(':'); if (caps.Length > 1) { capEx = (ClientCapabilitiesEx)long.Parse(caps[1]); } cap = (ClientCapabilities)long.Parse(caps[0]); routingInfo.Sender.EndPointData[epid].IMCapabilities = cap; routingInfo.Sender.EndPointData[epid].IMCapabilitiesEx = capEx; break; } } break; } case ServiceShortNames.PE: { foreach (XmlNode node in serviceEndPoint.ChildNodes) { switch (node.Name) { case "Capabilities": ClientCapabilities cap = ClientCapabilities.None; ClientCapabilitiesEx capEx = ClientCapabilitiesEx.None; string[] caps = node.InnerText.Split(':'); if (caps.Length > 1) { capEx = (ClientCapabilitiesEx)long.Parse(caps[1]); } cap = (ClientCapabilities)long.Parse(caps[0]); routingInfo.Sender.EndPointData[epid].PECapabilities = cap; routingInfo.Sender.EndPointData[epid].PECapabilitiesEx = capEx; break; } } routingInfo.Sender.SetChangedPlace(new PlaceChangedEventArgs(routingInfo.Sender.EndPointData[epid], PlaceChangedReason.SignedIn)); break; } case ServiceShortNames.PD: { PrivateEndPointData privateEndPoint = routingInfo.Sender.EndPointData[epid] as PrivateEndPointData; foreach (XmlNode node in serviceEndPoint.ChildNodes) { switch (node.Name) { case "ClientType": privateEndPoint.ClientType = node.InnerText; break; case "EpName": privateEndPoint.Name = node.InnerText; break; case "Idle": privateEndPoint.Idle = bool.Parse(node.InnerText); break; case "State": privateEndPoint.State = ParseStatus(node.InnerText); break; } } Owner.SetChangedPlace(new PlaceChangedEventArgs(privateEndPoint, PlaceChangedReason.SignedIn)); break; } } } } } break; #endregion #region circles xml case "application/circles+xml": { if (routingInfo.SenderType == IMAddressInfoType.Circle) { Contact circle = ContactList.GetCircle(routingInfo.SenderAccount); if (circle == null) { Trace.WriteLineIf(Settings.TraceSwitch.TraceError, "[OnNFYReceived] Cannot complete the operation since circle not found: " + multiMimeMessage.From.ToString()); return; } if (multiMimeMessage.InnerBody == null || multiMimeMessage.InnerBody.Length == 0 || "<circle></circle>" == Encoding.UTF8.GetString(multiMimeMessage.InnerBody)) { // No xml content and full notify... Circle goes online... if (multiMimeMessage.ContentHeaders[MIMEHeaderStrings.NotifType].Value == "Full") { PresenceStatus oldStatus = circle.Status; PresenceStatus newStatus = PresenceStatus.Online; circle.SetStatus(newStatus); // The contact changed status OnContactStatusChanged(new ContactStatusChangedEventArgs(circle, oldStatus, newStatus)); // The contact goes online OnContactOnline(new ContactStatusChangedEventArgs(circle, oldStatus, newStatus)); } return; } XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(Encoding.UTF8.GetString(multiMimeMessage.InnerBody)); XmlNodeList ids = xmlDoc.SelectNodes("//circle/roster/user/id"); if (ids.Count == 0) { return; //I hate indent. } foreach (XmlNode node in ids) { IMAddressInfoType accountAddressType; string account; IMAddressInfoType viaAccountAddressType; string viaAccount; string fullAccount = node.InnerText; if (false == Contact.ParseFullAccount(fullAccount, out accountAddressType, out account, out viaAccountAddressType, out viaAccount)) { continue; } if (account == Owner.Account) continue; if (circle.ContactList.HasContact(account, accountAddressType)) { Contact contact = circle.ContactList.GetContact(account, accountAddressType); OnJoinedGroupChat(new GroupChatParticipationEventArgs(contact, circle)); } } } else if (routingInfo.SenderType == IMAddressInfoType.TemporaryGroup) { MultipartyObject mpo = GetMultipartyObject(routingInfo.SenderAccount); Contact group = null; if (mpo == null) { // Created remotely. NSMessageProcessor nsmp = (NSMessageProcessor)MessageProcessor; int transId = nsmp.IncreaseTransactionID(); group = new Contact(routingInfo.SenderAccount, IMAddressInfoType.TemporaryGroup, this); group.ContactList = new ContactList(new Guid(routingInfo.SenderAccount.Split('@')[0]), null, group, this); mpo = new MultipartyObject(transId, new List<string>(), group, null); lock (multiParties) multiParties[transId] = mpo; OnMultipartyCreatedRemotely(new MultipartyCreatedEventArgs(group)); group.SetStatus(PresenceStatus.Online); } else { group = mpo.MultiParty; } if (multiMimeMessage.InnerBody == null || multiMimeMessage.InnerBody.Length == 0) { // No xml content and full notify... Circle goes online... if (multiMimeMessage.ContentHeaders[MIMEHeaderStrings.NotifType].Value == "Full") { PresenceStatus oldStatus = group.Status; PresenceStatus newStatus = PresenceStatus.Online; group.SetStatus(newStatus); // The contact changed status OnContactStatusChanged(new ContactStatusChangedEventArgs(group, oldStatus, newStatus)); // The contact goes online OnContactOnline(new ContactStatusChangedEventArgs(group, oldStatus, newStatus)); } return; } // Join multiparty if state is Pending XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(Encoding.UTF8.GetString(multiMimeMessage.InnerBody)); XmlNodeList rosters = xmlDoc.SelectNodes("//circle/roster/user"); foreach (XmlNode roster in rosters) { string state = (roster["state"] == null) ? string.Empty : roster["state"].InnerText; string[] fullAccount = roster["id"].InnerText.Split(':'); IMAddressInfoType addressType = (IMAddressInfoType)int.Parse(fullAccount[0]); string memberAccount = fullAccount[1].ToLowerInvariant(); // Me contact if ("pending" == state.ToLowerInvariant() && addressType == Owner.ClientType && memberAccount == Owner.Account) { JoinMultiparty(group); } else { Contact part = group.ContactList.GetContactWithCreate(memberAccount, addressType); Contact real = ContactList.GetContactWithCreate(memberAccount, addressType); part.SetStatus(real.Status); OnJoinedGroupChat(new GroupChatParticipationEventArgs(part, group)); if (mpo.InviteQueueHash.Contains(part.SiblingString)) mpo.InviteQueueHash.Remove(part.SiblingString); } } } } break; #endregion #region network xml case "application/network+xml": { if (routingInfo.Sender.ClientType == IMAddressInfoType.RemoteNetwork && routingInfo.Sender.Account == RemoteNetworkGateways.FaceBookGatewayAccount) { string status = Encoding.UTF8.GetString(multiMimeMessage.InnerBody); PresenceStatus oldStatus = routingInfo.Sender.Status; PresenceStatus newStatus = PresenceStatus.Unknown; if (status.Contains("SignedIn")) newStatus = PresenceStatus.Online; else if (status.Contains("SignedOut")) newStatus = PresenceStatus.Offline; if (newStatus != PresenceStatus.Unknown) { routingInfo.Sender.SetStatus(newStatus); // The contact changed status OnContactStatusChanged(new ContactStatusChangedEventArgs(routingInfo.Sender, routingInfo.SenderGateway, oldStatus, newStatus)); if (newStatus == PresenceStatus.Online) OnContactOnline(new ContactStatusChangedEventArgs(routingInfo.Sender, routingInfo.SenderGateway, oldStatus, newStatus)); else OnContactOffline(new ContactStatusChangedEventArgs(routingInfo.Sender, routingInfo.SenderGateway, oldStatus, newStatus)); } } } break; #endregion } }
protected virtual void OnPersonalMessageChanged(PersonalMessage newmessage) { if (PersonalMessageChanged != null) { PersonalMessageChanged(this, EventArgs.Empty); } }
protected internal Contact(Guid abId, string acc, IMAddressInfoType cliType, long cid, NSMessageHandler handler) { GenerateNewDCKeys(); NSMessageHandler = handler; addressBookId = abId; account = acc.ToLowerInvariant(); clientType = cliType; cId = cid; SetName(account); siblingString = ClientType.ToString() + ":" + account; hash = MakeHash(Account, ClientType); if (NSMessageHandler != null) { NSMessageHandler.ContactManager.Add(this); } displayImage = DisplayImage.CreateDefaultImage(Account); sceneImage = SceneImage.CreateDefaultImage(Account); personalMessage = new PersonalMessage(); if (Account == RemoteNetworkGateways.FaceBookGatewayAccount || Account == RemoteNetworkGateways.LinkedInGateway) { IsHiddenContact = true; } }
internal void SyncProfileToDeltas() { if (CoreProfile.ContainsKey(CoreProfileAttributeName.PublicProfile_ResourceId)) { if (NSMessageHandler.ContactService.Deltas.Profile == null) { NSMessageHandler.ContactService.Deltas.Profile = new OwnerProfile(); } NSMessageHandler.ContactService.Deltas.Profile.ResourceID = CoreProfile[CoreProfileAttributeName.PublicProfile_ResourceId].ToString(); if (CoreProfile.ContainsKey(CoreProfileAttributeName.LastModified)) { NSMessageHandler.ContactService.Deltas.Profile.DateModified = CoreProfile[CoreProfileAttributeName.LastModified].ToString(); } } if (CoreProfile.ContainsKey(CoreProfileAttributeName.PictureProfile_UserTileStatic_ResourceId)) { NSMessageHandler.ContactService.Deltas.Profile.Photo.ResourceID = CoreProfile[CoreProfileAttributeName.PictureProfile_UserTileStatic_ResourceId].ToString(); } if (CoreProfile.ContainsKey(CoreProfileAttributeName.UserTileStaticUrl)) { NSMessageHandler.ContactService.Deltas.Profile.Photo.PreAthURL = CoreProfile[CoreProfileAttributeName.UserTileStaticUrl].ToString(); } if (CoreProfile.ContainsKey(CoreProfileAttributeName.ExpressionProfile_ResourceId)) { NSMessageHandler.ContactService.Deltas.Profile.HasExpressionProfile = true; if (NSMessageHandler.ContactService.Deltas.Profile.ExpressionProfile == null) { NSMessageHandler.ContactService.Deltas.Profile.ExpressionProfile = new ProfileResource(); } NSMessageHandler.ContactService.Deltas.Profile.ExpressionProfile.ResourceID = CoreProfile[CoreProfileAttributeName.ExpressionProfile_ResourceId].ToString(); if (CoreProfile.ContainsKey(CoreProfileAttributeName.PictureProfile_UserTileStatic_ResourceId)) { NSMessageHandler.ContactService.Deltas.Profile.Photo.ResourceID = CoreProfile[CoreProfileAttributeName.PictureProfile_UserTileStatic_ResourceId].ToString(); } if (CoreProfile.ContainsKey(CoreProfileAttributeName.ExpressionProfile_DisplayName_LastModified)) { NSMessageHandler.ContactService.Deltas.Profile.ExpressionProfile.DateModified = CoreProfile[CoreProfileAttributeName.ExpressionProfile_DisplayName_LastModified].ToString(); } if (CoreProfile.ContainsKey(CoreProfileAttributeName.ExpressionProfile_PersonalStatus)) { NSMessageHandler.ContactService.Deltas.Profile.PersonalMessage = CoreProfile[CoreProfileAttributeName.ExpressionProfile_PersonalStatus].ToString(); PersonalMessage newPersonalMessage = PersonalMessage == null ? new PersonalMessage(NSMessageHandler.ContactService.Deltas.Profile.PersonalMessage) : PersonalMessage; newPersonalMessage.Message = NSMessageHandler.ContactService.Deltas.Profile.PersonalMessage; PersonalMessage = newPersonalMessage; } } NSMessageHandler.ContactService.Deltas.Profile.DisplayName = Name; NSMessageHandler.ContactService.Deltas.Save(true); if (CoreProfile.ContainsKey(CoreProfileAttributeName.UserTileStaticUrl)) { NSMessageHandler.StorageService.SyncUserTile(CoreProfile[CoreProfileAttributeName.UserTileStaticUrl].ToString(), true, delegate(object param) { SerializableMemoryStream ms = param as SerializableMemoryStream; if (ms != null) { NSMessageHandler.ContactService.Deltas.Profile.Photo.DisplayImage = ms; NSMessageHandler.ContactService.Deltas.Save(true); } Trace.WriteLineIf(Settings.TraceSwitch.TraceInfo, "Get owner's display image from: " + CoreProfile[CoreProfileAttributeName.UserTileStaticUrl] + " succeeded."); }, delegate(object param) { Exception ex = param as Exception; if (ex != null) { Trace.WriteLineIf(Settings.TraceSwitch.TraceError, "An error occurred while getting owner's display image from:" + CoreProfile[CoreProfileAttributeName.UserTileStaticUrl] + "\r\n" + ex.Message); } } ); } if (Name != PreferredName) { try { NSMessageHandler.SetScreenName(PreferredName); SetName(PreferredName); } catch (Exception ex) { Trace.WriteLineIf(Settings.TraceSwitch.TraceError, ex.Message); } } }