📄 contactinfo.cs
字号:
namespace Imps.Client.Core
{
using Imps.Base.Sipc;
using Imps.Client;
using Imps.Client.Base;
using Imps.Client.Resource;
using Imps.Common;
using Imps.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.CompilerServices;
using System.Xml;
public class ContactInfo : PersonalInfoBase
{
private string _mobileNoUserSet = string.Empty;
private string _namePYAb = string.Empty;
private string _namePYFull = string.Empty;
private string _nameUserSetPYAb = string.Empty;
private string _nameUserSetPYFull = string.Empty;
private string _nicknamePYAb = string.Empty;
private string _nicknamePYFull = string.Empty;
private Imps.Client.Core.Contact _owner;
private string _userSetVersion = string.Empty;
internal event EventHandler<PropertiesChangedEventArgs> InnerPropertiesChanged;
public ContactInfo(Imps.Client.Core.Contact owner)
{
this._owner = owner;
this.UpdateDisplayName();
}
internal override void CommitProposedProperties(AsyncBizOperation op)
{
XmlHelper.WriteXmlContentDelegate writeContentCallback = null;
XmlHelper.WriteXmlContentDelegate delegate3 = null;
lock (this)
{
if (this.HasProposedProperty() || this._owner.OnlineNotify.HasProposedValue)
{
SipRequest req = this._owner.Owner.CreateSipRequest("S");
if ((this._owner.Type == ContactType.Buddy) || (this._owner.Type == ContactType.Vodafone))
{
req.Message.AddHeader(new SipcEventHeader("SetBuddyInfo"));
StringWriter tw = new StringWriter();
if (writeContentCallback == null)
{
writeContentCallback = delegate (XmlWriter writer, object context) {
writer.WriteStartElement("contacts");
writer.WriteStartElement("buddies");
writer.WriteStartElement("buddy");
writer.WriteAttributeString("uri", this._owner.Uri.Raw);
if (this.BirthDate.HasProposedValue)
{
writer.WriteAttributeString("birth-date", this.BirthDate.UserSetData.ProposedValue.ToString());
}
if (this.BloodType.HasProposedValue)
{
writer.WriteAttributeString("blood-type", ((int) this.BloodType.UserSetData.ProposedValue).ToString());
}
if (this.Company.HasProposedValue)
{
writer.WriteAttributeString("company", this.Company.UserSetData.ProposedValue);
}
if (this.CompanyWebsite.HasProposedValue)
{
writer.WriteAttributeString("company-website", this.CompanyWebsite.UserSetData.ProposedValue);
}
if (this.HomePhone.HasProposedValue)
{
writer.WriteAttributeString("home-phone", this.HomePhone.UserSetData.ProposedValue);
}
if (this.IsBirthdayValid.HasProposedValue)
{
writer.WriteAttributeString("birthday-valid", this.IsBirthdayValid.UserSetData.ProposedValue ? "1" : "0");
}
if (this.JobTitle.HasProposedValue)
{
writer.WriteAttributeString("job-title", this.JobTitle.UserSetData.ProposedValue);
}
if (this.Name.HasProposedValue)
{
writer.WriteAttributeString("local-name", this.Name.UserSetData.ProposedValue);
}
if (this.Notes.HasProposedValue)
{
writer.WriteAttributeString("profile", this.Notes.UserSetData.ProposedValue);
}
if (this.OtherEmail.HasProposedValue)
{
writer.WriteAttributeString("other-email", this.OtherEmail.UserSetData.ProposedValue);
}
if (this.OtherPhone.HasProposedValue)
{
writer.WriteAttributeString("other-phone", this.OtherPhone.UserSetData.ProposedValue);
}
if (this.PersonalEmail.HasProposedValue)
{
writer.WriteAttributeString("personal-email", this.PersonalEmail.UserSetData.ProposedValue);
}
if (this.PrimaryEmail.HasProposedValue)
{
writer.WriteAttributeString("primary-email", this.PrimaryEmail.UserSetData.ProposedValue.ToString());
}
if (this.WorkEmail.HasProposedValue)
{
writer.WriteAttributeString("work-email", this.WorkEmail.UserSetData.ProposedValue);
}
if (this.WorkPhone.HasProposedValue)
{
writer.WriteAttributeString("work-phone", this.WorkPhone.UserSetData.ProposedValue);
}
if (this._owner.OnlineNotify.HasProposedValue)
{
writer.WriteAttributeString("online-notify", this._owner.OnlineNotify.ProposedValue ? "1" : "0");
}
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteEndElement();
};
}
XmlHelper.CreateXmlWriterForSipRequest(tw, null, writeContentCallback);
req.Message.Body = tw.ToString();
tw.Dispose();
}
else if (this._owner.Type == ContactType.MobileBuddy)
{
req.Message.AddHeader(new SipcEventHeader("SetMobileBuddyInfo"));
StringWriter writer2 = new StringWriter();
if (delegate3 == null)
{
delegate3 = delegate (XmlWriter writer, object context) {
writer.WriteStartElement("contacts");
writer.WriteStartElement("mobile-buddies");
writer.WriteStartElement("mobile-buddy");
writer.WriteAttributeString("uri", this._owner.Uri.Raw);
if (this.BirthDate.HasProposedValue)
{
writer.WriteAttributeString("birth-date", this.BirthDate.UserSetData.ProposedValue.ToString());
}
if (this.BloodType.HasProposedValue)
{
writer.WriteAttributeString("blood-type", ((int) this.BloodType.UserSetData.ProposedValue).ToString());
}
if (this.City.HasProposedValue)
{
writer.WriteAttributeString("city", this.City.UserSetData.ProposedValue.ToString());
}
if (this.Company.HasProposedValue)
{
writer.WriteAttributeString("company", this.Company.UserSetData.ProposedValue);
}
if (this.CompanyWebsite.HasProposedValue)
{
writer.WriteAttributeString("company-website", this.CompanyWebsite.UserSetData.ProposedValue);
}
if (this.HomePhone.HasProposedValue)
{
writer.WriteAttributeString("home-phone", this.HomePhone.UserSetData.ProposedValue);
}
if (this.IsBirthdayValid.HasProposedValue)
{
writer.WriteAttributeString("birthday-valid", this.IsBirthdayValid.UserSetData.ProposedValue ? "1" : "0");
}
if (this.JobTitle.HasProposedValue)
{
writer.WriteAttributeString("job-title", this.JobTitle.UserSetData.ProposedValue);
}
if (this.Name.HasProposedValue)
{
writer.WriteAttributeString("local-name", this.Name.UserSetData.ProposedValue);
}
if (this.Notes.HasProposedValue)
{
writer.WriteAttributeString("profile", this.Notes.UserSetData.ProposedValue);
}
if (this.OtherPhone.HasProposedValue)
{
writer.WriteAttributeString("other-phone", this.OtherPhone.UserSetData.ProposedValue);
}
if (this.OtherEmail.HasProposedValue)
{
writer.WriteAttributeString("other-email", this.OtherEmail.UserSetData.ProposedValue);
}
if (this.PersonalEmail.HasProposedValue)
{
writer.WriteAttributeString("personal-email", this.PersonalEmail.UserSetData.ProposedValue);
}
if (this.PrimaryEmail.HasProposedValue)
{
writer.WriteAttributeString("primary-email", this.PrimaryEmail.UserSetData.ProposedValue.ToString());
}
if (this.WorkEmail.HasProposedValue)
{
writer.WriteAttributeString("work-email", this.WorkEmail.UserSetData.ProposedValue);
}
if (this.WorkPhone.HasProposedValue)
{
writer.WriteAttributeString("work-phone", this.WorkPhone.UserSetData.ProposedValue);
}
if (this._owner.OnlineNotify.HasProposedValue)
{
writer.WriteAttributeString("online-notify", this._owner.OnlineNotify.ProposedValue ? "1" : "0");
}
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteEndElement();
};
}
XmlHelper.CreateXmlWriterForSipRequest(writer2, null, delegate3);
req.Message.Body = writer2.ToString();
writer2.Dispose();
}
req.FinalResponseReceived += new EventHandler<SipResponseReceivedEventArgs>(this, (IntPtr) this.reqCommitChanges_FinalResponseReceived);
ErrorHelper.HandleSendRequestErrorAndTimeout(req);
this._owner.Owner.SendSipMessage(req);
base.InnerResetProposedProperties();
}
}
}
public void CopyTo(Imps.Client.Core.ContactInfo target)
{
lock (base.SyncRoot)
{
lock (target.SyncRoot)
{
Suspender suspender = new Suspender(target);
try
{
bool flag = false;
using (IEnumerator<KeyValuePair<string, object>> enumerator = base.InnerData.GetEnumerator())
{
while (enumerator.MoveNext())
{
KeyValuePair<string, object> pair = enumerator.get_Current();
if (!target.InnerData.ContainsKey(pair.get_Key()))
{
target.InnerData.Add(pair);
flag = true;
}
}
}
target.SetPortrait(base.Portrait, base.LocalPortraitCrc);
if (string.IsNullOrEmpty(target.MobileNoUserSet) && !string.IsNullOrEmpty(this.MobileNoUserSet))
{
target.MobileNoUserSet = this.MobileNoUserSet;
flag = true;
}
if (flag)
{
target.Version = base.Version;
target.UserSetVersion = this.UserSetVersion;
}
}
finally
{
suspender.Dispose();
}
}
}
}
internal void finalResponseReceived_GetLocalContactInfo(object sender, SipResponseReceivedEventArgs e)
{
SipResponse sipMsg = e.Response;
AsyncBizOperation op = (AsyncBizOperation) sipMsg.Request.Context;
if (sipMsg != null)
{
if (!sipMsg.IsOK)
{
LogHelper.LogReceivedSipMessage(sipMsg);
switch (sipMsg.Message.StatusCode)
{
case 400:
this._owner.Owner.FireImpsErrorInUiThread(new ImpsErrorEventArgs(StringTable.ContactProfile.GetUserSetContactInfoFailed), op);
return;
case 0x194:
this._owner.Owner.FireImpsErrorInUiThread(new ImpsErrorEventArgs(StringTable.ContactProfile.GetUserSetContactInfoFailed), op);
return;
case 500:
this._owner.Owner.FireImpsErrorInUiThread(new ImpsErrorEventArgs(StringTable.ContactProfile.GetUserSetContactInfoFailed), op);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -