📄 contactlist.cs
字号:
{
writer.WriteAttributeString("local-name", localName);
}
}
else if (result == 0)
{
bool? nullable1 = isBlock;
if (nullable1.GetValueOrDefault() && nullable1.get_HasValue())
{
writer.WriteAttributeString("accept-instant-message", "0");
writer.WriteAttributeString("expose-basic-presence", "0");
}
}
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteEndElement();
});
req.Message.Body = tw.ToString();
tw.Dispose();
ErrorHelper.HandleSendRequestErrorAndTimeout(req);
req.FinalResponseReceived += new EventHandler<SipResponseReceivedEventArgs>(this, (IntPtr) this.finalResponseReceived_HandleAddBuddyRequest);
base.SendSipMessage(req);
return true;
}
public bool AsyncInviteMobileOpenIMPSService(string mobileNo, string description, AsyncBizOperation op)
{
if (!ImpsHelper.IsCmccMobileNo(mobileNo))
{
LogHelper.LogFatalError("手机号不正确");
base.Owner.FireImpsErrorInUiThread(new ImpsErrorEventArgs(StringTable.MsgInvalidMobileNo));
return false;
}
string uri = IicUri.CreateTelUri(mobileNo).Raw;
SipRequest req = base.Owner.CreateSipRequest("S");
req.Message.AddHeader(new SipcEventHeader("InviteMobileUser"));
req.Context = op;
StringWriter tw = new StringWriter();
XmlHelper.CreateXmlWriterForSipRequest(tw, null, delegate (XmlWriter writer, object context) {
writer.WriteStartElement("contacts");
writer.WriteStartElement("contact");
writer.WriteAttributeString("uri", uri);
writer.WriteAttributeString("desc", description);
writer.WriteEndElement();
writer.WriteEndElement();
});
req.Message.Body = tw.ToString();
ErrorHelper.HandleSendRequestErrorAndTimeout(req, base.Owner, op, string.Format(StringTable.Contact.InviteOpenIMPSServiceFailed, mobileNo));
req.FinalResponseReceived += new EventHandler<SipResponseReceivedEventArgs>(this, (IntPtr) this.finalResponse_AsyncInviteMobileOpenIMPSService);
base.Owner.SendSipMessage(req);
return true;
}
public void AsyncReGetContactList(AsyncBizOperation op, bool withVersion)
{
if (op == null)
{
op = new AsyncBizOperation();
}
op.IsImpsErrorHandled = true;
this.AsyncGetContactList(op, withVersion, false);
op.Successed += delegate {
this.AsyncGetContactsInfoBatchAll(new AsyncBizOperation());
};
this._canReGetContactList = true;
}
public void AsyncRemoveFromBlackList(string[] uriArray, AsyncBizOperation op)
{
if (uriArray.Length != 0)
{
SipRequest req = base.Owner.CreateSipRequest("S");
req.Message.AddHeader(new SipcEventHeader("RemoveFromBlacklist"));
req.Context = op;
StringWriter tw = new StringWriter();
XmlHelper.CreateXmlWriterForSipRequest(tw, null, delegate (XmlWriter writer, object context) {
writer.WriteStartElement("contacts");
writer.WriteStartElement("blacklist");
foreach (string text in uriArray)
{
writer.WriteStartElement("blocked");
writer.WriteAttributeString("uri", text);
writer.WriteEndElement();
}
writer.WriteEndElement();
writer.WriteEndElement();
});
req.Message.Body = tw.ToString();
tw.Dispose();
ErrorHelper.HandleSendRequestErrorAndTimeout(req);
req.FinalResponseReceived += new EventHandler<SipResponseReceivedEventArgs>(this, (IntPtr) this.finalResponseReceived_RemoveFromBlackList);
base.Owner.SendSipMessage(req);
}
}
public void AsyncRemoveFromBlackList(IicUri uri, AsyncBizOperation op)
{
this.AsyncRemoveFromBlackList(new string[] { uri.Raw }, op);
}
internal bool AsyncSubscribePresence(bool isSub, Imps.Client.Core.Contact contact, AsyncBizOperation op, params string[] subExtendedContent)
{
ContactCollection contacts = new ContactCollection();
contacts.Add(contact);
return this.AsyncSubscribePresence(isSub, contacts, false, op, subExtendedContent);
}
internal bool AsyncSubscribePresence(bool isSub, ContactCollection contacts, bool subUser, AsyncBizOperation op, params string[] subExtendedContent)
{
List<string> list = null;
SipRequest req;
if ((contacts != null) && (contacts.Count > 0))
{
using (IEnumerator<Imps.Client.Core.Contact> enumerator = contacts.GetEnumerator())
{
while (enumerator.MoveNext())
{
Imps.Client.Core.Contact contact = enumerator.get_Current();
if (contact.CanSubscribedPresence)
{
if (list == null)
{
list = new List<string>(contacts.Count);
}
list.Add(contact.Uri.Raw);
contact.BeenSubscribedPresence = isSub;
}
}
}
}
if ((list == null) && !subUser)
{
return false;
}
string text = string.Empty;
if ((subExtendedContent == null) || (subExtendedContent.Length == 0))
{
text = string.Join(";", new string[] { "sms", "location", "listening", "ring-back-tone" });
}
else
{
foreach (string text2 in subExtendedContent)
{
if (text.Length > 0)
{
text = text + ";";
}
text = text + text2;
}
}
StringWriter w = new StringWriter();
XmlTextWriter writer2 = new XmlTextWriter(w);
writer2.WriteStartElement("args");
if (list != null)
{
writer2.WriteStartElement("subscription");
writer2.WriteStartElement("contacts");
List<string>.Enumerator enumerator2 = list.GetEnumerator();
try
{
while (enumerator2.MoveNext())
{
string text3 = enumerator2.get_Current();
writer2.WriteStartElement("contact");
writer2.WriteAttributeString("uri", text3);
writer2.WriteEndElement();
}
}
finally
{
enumerator2.Dispose();
}
writer2.WriteEndElement();
if (isSub)
{
writer2.WriteStartElement("presence");
writer2.WriteStartElement("basic");
writer2.WriteAttributeString("attributes", "all");
writer2.WriteEndElement();
writer2.WriteStartElement("personal");
writer2.WriteAttributeString("attributes", "all");
writer2.WriteEndElement();
writer2.WriteStartElement("extended");
writer2.WriteAttributeString("types", text);
writer2.WriteEndElement();
writer2.WriteEndElement();
}
writer2.WriteEndElement();
}
if (subUser)
{
writer2.WriteStartElement("subscription");
writer2.WriteStartElement("contacts");
writer2.WriteStartElement("contact");
writer2.WriteAttributeString("uri", base.Owner.Uri.Raw);
writer2.WriteEndElement();
writer2.WriteEndElement();
if (isSub)
{
writer2.WriteStartElement("presence");
writer2.WriteStartElement("extended");
writer2.WriteAttributeString("types", text);
writer2.WriteEndElement();
writer2.WriteEndElement();
}
writer2.WriteEndElement();
base.Owner.BeenSubscribedPresence = isSub;
}
writer2.WriteEndElement();
writer2.Flush();
writer2.Close();
if (this._subCallId == -1)
{
req = base.CreateSipRequest("SUB");
}
else
{
req = base.CreateSipRequest("SUB", this._subCallId, ++this._subCSeq);
}
req.Message.AddHeader(new SipcEventHeader("presence"));
if (!isSub)
{
req.Message.AddHeader(new SipcExpiresHeader(0));
}
this._subCallId = req.Message.CallId.CallId;
this._subCSeq = req.Message.CSeq.Number;
req.Message.Body = w.ToString();
req.Context = op;
ErrorHelper.HandleSendRequestErrorAndTimeout(req, base.Owner, op, "获取好友状态失败");
req.FinalResponseReceived += new EventHandler<SipResponseReceivedEventArgs>(this, (IntPtr) this.finalResponseReceived_AsyncSubscribePresence);
base.SendSipMessage(req);
return true;
}
internal bool AsyncSubscribePresenceBatchAll(bool isSub, AsyncBizOperation op)
{
EventHandler<ImpsErrorEventArgs> handler = null;
EventHandler handler2 = null;
try
{
ContactCollection contacts = new ContactCollection();
lock (this.Contacts.SyncRoot)
{
using (IEnumerator<Imps.Client.Core.Contact> enumerator = this.Contacts.GetEnumerator())
{
while (enumerator.MoveNext())
{
Imps.Client.Core.Contact item = enumerator.get_Current();
if (item.CanSubscribedPresence && (item.BeenSubscribedPresence != isSub))
{
contacts.Add(item);
item.BeenSubscribedPresence = isSub;
if (isSub && (contacts.Count >= 100))
{
goto Label_00B4;
}
}
}
}
}
Label_00B4:
if ((contacts.Count == 0) && (base.Owner.BeenSubscribedPresence == isSub))
{
if (op != null)
{
op.FireSuccessedInUiThread(EventArgs.Empty);
}
return true;
}
AsyncBizOperation operation = new AsyncBizOperation();
this.AsyncSubscribePresence(isSub, contacts, base.Owner.BeenSubscribedPresence != isSub, operation, null);
if (handler == null)
{
<>c__DisplayClass38 class2;
handler = new EventHandler<ImpsErrorEventArgs>(class2, (IntPtr) this.<AsyncSubscribePresenceBatchAll>b__34);
}
operation.ImpsError += handler;
if (handler2 == null)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -