📄 contactgroup.cs
字号:
AsyncBizOperation op = (AsyncBizOperation) sipMsg.Request.Context;
ParamForBiz contextForBiz = (ParamForBiz) op.ContextForBiz;
int? nullable = contextForBiz.Int1;
Imps.Client.Core.User user = contextForBiz.User;
if (!sipMsg.IsOK)
{
LogHelper.LogReceivedSipMessage(sipMsg);
switch (sipMsg.Message.StatusCode)
{
case 400:
user.FireImpsErrorInUiThread(new ImpsErrorEventArgs(StringTable.MsgBadRequest), op);
return;
case 0x194:
user.FireImpsErrorInUiThread(new ImpsErrorEventArgs(StringTable.MsgContactOrGroupNotExist), op);
return;
case 500:
user.FireImpsErrorInUiThread(new ImpsErrorEventArgs(StringTable.MsgSipRespInternalServerError), op);
return;
}
user.FireImpsErrorInUiThread(new ImpsErrorEventArgs(sipMsg.Message.ToString()), op);
}
else
{
XmlDocument document = new XmlDocument();
document.LoadXml(sipMsg.Message.Body);
XmlNode node = document.DocumentElement.SelectSingleNode("contacts");
if (node != null)
{
string text = XmlHelper.ReadXmlAttributeString(node, "version");
string xpath = "buddies" + "/" + "buddy";
XmlNode node2 = node.SelectSingleNode(xpath);
if (node2 == null)
{
xpath = "mobile-buddies" + "/" + "mobile-buddy";
node2 = node.SelectSingleNode(xpath);
if (node2 == null)
{
return;
}
}
string text3 = XmlHelper.ReadXmlAttributeString(node2, "uri");
Imps.Client.Core.Contact item = user.ContactList.Contacts[text3];
if (item != null)
{
string text4 = XmlHelper.ReadXmlAttributeString(node2, "buddy-lists");
try
{
for (int i = item.BelongToGroups.get_Count() - 1; i >= 0; i--)
{
int num2 = item.BelongToGroups.get_Item(i);
Imps.Client.Core.ContactGroup group = user.ContactList.Groups[new int?(num2)] as Imps.Client.Core.ContactGroup;
if (group != null)
{
group.Contacts.Remove(item);
}
}
foreach (string text5 in text4.Split(new char[] { ';' }))
{
if (text5.Trim().Length != 0)
{
int num3 = Convert.ToInt32(text5.Trim());
Imps.Client.Core.ContactGroup group2 = user.ContactList.Groups[new int?(num3)] as Imps.Client.Core.ContactGroup;
if (group2 != null)
{
group2.Contacts.Add(item);
}
}
}
user.ContactList.Version = text;
ContactChangedEventArgs args = new ContactChangedEventArgs(item, ContactEventType.BelongGroupChanged);
args.TargetGroupId = nullable;
user.ContactList.InnerOnContactChanged(args);
}
catch
{
user.ContactList.AsyncReGetContactList(new AsyncBizOperation(), true);
}
user.ContactList.SaveContactListXml();
}
}
}
}
private void finalResponse_AsyncUpdate(object sender, SipResponseReceivedEventArgs e)
{
SipResponse sipMsg = e.Response;
if (!sipMsg.IsOK)
{
LogHelper.LogReceivedSipMessage(sipMsg);
}
else
{
XmlDocument document = new XmlDocument();
document.LoadXml(sipMsg.Message.Body);
string text = XmlHelper.ReadXmlAttributeString(document.DocumentElement.SelectSingleNode("contacts"), "version");
if (text.Length == 0)
{
LogHelper.LogFatalError("修改用户组,返回版本号错误");
LogHelper.LogReceivedSipMessage(sipMsg);
base.Owner.FireImpsErrorInUiThread(new ImpsErrorEventArgs(StringTable.ContactGroup.MsgUpdateFailed), e.Response.Request.Context as AsyncBizOperation);
}
else
{
string xpath = "contacts" + "/" + "buddy-lists" + "/" + "buddy-list";
XmlNode node = document.DocumentElement.SelectSingleNode(xpath);
if (node != null)
{
if (XmlHelper.ReadXmlAttributeInt32(node, "id", 0) != this.Id)
{
LogHelper.LogFatalError("修改用户组,返回Id错误");
LogHelper.LogReceivedSipMessage(sipMsg);
base.Owner.FireImpsErrorInUiThread(new ImpsErrorEventArgs(StringTable.ContactGroup.MsgUpdateFailed), e.Response.Request.Context as AsyncBizOperation);
}
else
{
string text3 = XmlHelper.ReadXmlAttributeString(node, "name");
this.Name = text3;
base.Owner.ContactList.Version = text;
base.Owner.ContactList.Groups.ForceSort();
base.InnerOnInfoChanged();
base.Owner.ContactList.SaveContactListXml();
}
}
}
}
}
public string[] GetEnableFileShareContacts()
{
ArrayList list = new ArrayList();
using (IEnumerator<Imps.Client.Core.Contact> enumerator = base.Contacts.GetEnumerator())
{
while (enumerator.MoveNext())
{
Imps.Client.Core.Contact contact = enumerator.get_Current();
if (contact.EnableMultiSendFile)
{
list.Add(contact.Uri.Raw);
}
}
}
return (string[]) list.ToArray(typeof(string));
}
public string[] GetEnableImContacts()
{
ArrayList list = new ArrayList();
using (IEnumerator<Imps.Client.Core.Contact> enumerator = base.Contacts.GetEnumerator())
{
while (enumerator.MoveNext())
{
Imps.Client.Core.Contact contact = enumerator.get_Current();
if (contact.EnableMultiIM)
{
list.Add(contact.Uri.Raw);
}
}
}
return (string[]) list.ToArray(typeof(string));
}
public string[] GetEnableIvrContacts()
{
ArrayList list = new ArrayList();
using (IEnumerator<Imps.Client.Core.Contact> enumerator = base.Contacts.GetEnumerator())
{
while (enumerator.MoveNext())
{
Imps.Client.Core.Contact contact = enumerator.get_Current();
if (contact.EnableIvr)
{
list.Add(contact.Uri.Raw);
}
}
}
return (string[]) list.ToArray(typeof(string));
}
public string[] GetEnableSmsContacts()
{
ArrayList list = new ArrayList();
using (IEnumerator<Imps.Client.Core.Contact> enumerator = base.Contacts.GetEnumerator())
{
while (enumerator.MoveNext())
{
Imps.Client.Core.Contact contact = enumerator.get_Current();
if (contact.EnableSMS)
{
list.Add(contact.Uri.Raw);
}
}
}
return (string[]) list.ToArray(typeof(string));
}
internal void WriteRecordXml(XmlTextWriter writer)
{
writer.WriteStartElement("buddy-list");
writer.WriteAttributeString("id", this.Id.ToString());
writer.WriteAttributeString("name", this.Name.ToString());
writer.WriteEndElement();
}
public string DisplayContactCount
{
get
{
if (base.Contacts.Count == 0)
{
return string.Empty;
}
int num = 0;
if (this.Id == -1)
{
return string.Format(StringTable.ContactTree.ContactCount, base.Contacts.Count);
}
using (IEnumerator<Imps.Client.Core.Contact> enumerator = base.Contacts.GetEnumerator())
{
while (enumerator.MoveNext())
{
Imps.Client.Core.Contact contact = enumerator.get_Current();
if (contact.Presence.IsDisplayOnline(contact.Presence.MainPresence))
{
num++;
}
}
}
return string.Format(StringTable.ContactTree.ContactCountIncludeAll, num, base.Contacts.Count);
}
}
public override string DisplayName
{
get
{
return this.Name;
}
}
public override int Id
{
get
{
return this._id;
}
}
public bool IsChatFriendGroup
{
get
{
return (this.Id == -1);
}
}
public override string Name
{
get
{
return this._name;
}
internal set
{
this._name = value;
base.InnerOnInfoChanged();
}
}
internal enum SetBuddyListsType
{
Copy,
Move,
Delete
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -