/// <summary> /// Invoked when a message stanza has been received. /// </summary> /// <param name="stanza">The stanza which has been received.</param> /// <returns>true to intercept the stanza or false to pass the stanza /// on to the next handler.</returns> public bool Input(Sharp.Xmpp.Im.Message message) { if (message.Type == MessageType.Webrtc) { //TO DO log.LogWarning("[Input] Input in Webrtc context received - To manage ..."); return(true); } else if ((message.Type == MessageType.Chat) && (message.Data["deleted_call_log"] != null) && (message.Data["deleted_call_log"].NamespaceURI == "jabber:iq:notification:telephony:call_log")) { String peerId = message.Data["deleted_call_log"].GetAttribute("peer"); String callId = message.Data["deleted_call_log"].GetAttribute("call_id"); log.LogDebug("CallLogItemsDeleted raised - peer:[{0}] - callId:[{1}]", peerId, callId); CallLogItemsDeleted.Raise(this, new CallLogItemDeletedEventArgs(peerId, callId)); return(true); } else if ((message.Data["read"] != null) && (message.Data["read"].NamespaceURI == "urn:xmpp:telephony:call_log:receipts")) { String id = message.Data["read"].GetAttribute("call_id"); log.LogDebug("CallLogRead raised - id:[{0}]", id); CallLogRead.Raise(this, new CallLogReadEventArgs(id)); return(true); } else if ((message.Data["result"] != null) && (message.Data["result"].NamespaceURI == "jabber:iq:telephony:call_log")) { CallLogItemEventArgs evt = GetCallLogItemEventArgs(message.Data["result"]); if (evt != null) { CallLogItemRetrieved.Raise(this, evt); } else { log.LogWarning("Cannot create CallLogItemEventArgs object ... [using jabber:iq:telephony:call_log namespace]"); } return(true); } else if ((message.Data["updated_call_log"] != null) && (message.Data["updated_call_log"].NamespaceURI == "jabber:iq:notification:telephony:call_log")) { CallLogItemEventArgs evt = GetCallLogItemEventArgs(message.Data["updated_call_log"]); if (evt != null) { CallLogItemAdded.Raise(this, evt); } else { log.LogWarning("Cannot create CallLogItemEventArgs object ... [using jabber:iq:notification:telephony:call_log]"); } return(true); } // Pass the message to the next handler. return(false); }
private CallLogItemEventArgs GetCallLogItemEventArgs(XmlElement e) { CallLogItemEventArgs result = null; if ((e["forwarded"] != null) && (e["forwarded"]["call_log"] != null)) { XmlElement callLog = e["forwarded"]["call_log"]; String id = ""; String callId = ""; String callee = ""; String caller = ""; String duration = ""; String state = ""; String media = ""; String timeStamp = ""; String type = ""; String service = ""; bool read = false; id = e.GetAttribute("id"); type = callLog.GetAttribute("type"); service = callLog.GetAttribute("service"); if (service == "conference") { type = service; } if (callLog["call_id"] != null) { callId = callLog["call_id"].InnerText; } if (callLog["callee"] != null) { callee = callLog["callee"].InnerText; } if (callLog["caller"] != null) { caller = callLog["caller"].InnerText; } if (callLog["duration"] != null) { duration = callLog["duration"].InnerText; } if (callLog["state"] != null) { state = callLog["state"].InnerText; } if (callLog["media"] != null) { media = callLog["media"].InnerText; } if (callLog["ack"] != null) { read = (callLog["ack"].GetAttribute("read") == "true"); } if (e["forwarded"]["delay"] != null) { timeStamp = e["forwarded"]["delay"].GetAttribute("stamp"); } result = new CallLogItemEventArgs(id, callId, state, callee, caller, media, timeStamp, duration, read, type); } return(result); }