private void RemoveCallEvent(VATRPCallEvent callEvent) { lock (this.Calls) { foreach (var call in Calls) { if (call.CallEvent == callEvent) { Calls.Remove(call); if (callEvent.Status == VATRPHistoryEvent.StatusType.Missed) { _unseenMissedCallsCount--; if (_unseenMissedCallsCount < 0) { _unseenMissedCallsCount = 0; } if (MissedCallsCountChanged != null) { MissedCallsCountChanged(null, EventArgs.Empty); } } CallsListView.Refresh(); break; } } } }
public HistoryCallEventViewModel(VATRPCallEvent callEvent, VATRPContact contact) : this() { this._callEvent = callEvent; this._backColor = callEvent.Status == VATRPHistoryEvent.StatusType.Missed ? new SolidColorBrush(Color.FromArgb(255, 0xFE, 0xCD, 0xCD)) : new SolidColorBrush(Color.FromArgb(255, 0xE9, 0xEF, 0xE9)); UpdateContact(contact); LoadCallStateIndicator(); DateTime callTime = VATRP.Core.Model.Utils.Time.ConvertUtcTimeToLocalTime( VATRP.Core.Model.Utils.Time.ConvertDateTimeToLong(callEvent.StartTime) / 1000); string dateFormat = "d/MM h:mm tt"; var diffTime = DateTime.Now - callTime; if (diffTime.Days == 0) { dateFormat = "h:mm tt"; } else if (diffTime.Days < 8) { dateFormat = "ddd h:mm tt"; } else if (diffTime.Days > 365) { dateFormat = "dd/MM/yy h:mm tt"; //Added YY in date format by MK on dated 02-NOV-2016 TO DISPLAY YEAR IN CALL DATE } CallDate = callTime.ToString(dateFormat); }
private void AddNewCallEvent(VATRPCallEvent callEvent) { try { var dn = callEvent.RemoteParty; var callItem = new RecentsCallItem() { CallerName = dn, CallTime = callEvent.StartTime, Duration = callEvent.Status == VATRPHistoryEvent.StatusType.Missed ? -1 : callEvent.Duration, TargetNumber = callEvent.RemoteParty, CallStatus = callEvent.Status, ContactId = callEvent.Contact != null ? callEvent.Contact.DisplayName : String.Empty }; if (callEvent.Status == VATRPHistoryEvent.StatusType.Missed) { MissedCallsList.Add(callItem); } CallsList.Add(callItem); } catch (Exception ex) { ServiceManager.LogError("AddNewCallEvent", ex); } }
private object FindCallEvent(VATRPCallEvent callEvent) { lock (this.Calls) { foreach (var call in Calls) { if (call.CallEvent == callEvent) { return(callEvent); } } } return(null); }
private void AddNewCallEvent(VATRPCallEvent callEvent, bool refreshNow = false) { if (FindCallEvent(callEvent) != null) { return; } long time_uts; var lastSeenDate = ServiceManager.Instance.ConfigurationService.Get(Configuration.ConfSection.GENERAL, Configuration.ConfEntry.LAST_MISSED_CALL_DATE, string.Empty); if (!long.TryParse(lastSeenDate, out time_uts)) { time_uts = 0; } var contact = _contactService.FindContact(new ContactID(callEvent.RemoteParty.TrimSipPrefix(), IntPtr.Zero)); lock (this.Calls) { Calls.Add(new HistoryCallEventViewModel(callEvent, contact)); if (callEvent.Status == VATRPHistoryEvent.StatusType.Missed) { if (callEvent.EndTime.Ticks > time_uts) { _unseenMissedCallsCount++; if (MissedCallsCountChanged != null) { MissedCallsCountChanged(callEvent, EventArgs.Empty); } } } } ServiceManager.Instance.ConfigurationService.Set(Configuration.ConfSection.GENERAL, Configuration.ConfEntry.LAST_MISSED_CALL_DATE, DateTime.UtcNow.Ticks.ToString()); if (refreshNow) { CallsListView.Refresh(); } }
private VATRPCallEvent ParseLinphoneCallLog(IntPtr callLogPtr) { LinphoneCallDir direction = LinphoneAPI.linphone_call_log_get_dir(callLogPtr); IntPtr tmpPtr = LinphoneAPI.linphone_call_log_get_remote_address(callLogPtr); if (tmpPtr == IntPtr.Zero) return null; tmpPtr = LinphoneAPI.linphone_address_as_string(tmpPtr); if (tmpPtr == IntPtr.Zero) return null; var remoteParty = Marshal.PtrToStringAnsi(tmpPtr); LinphoneAPI.ortp_free(tmpPtr); string dn = "", un = "", host = ""; int port = 0; VATRPCall.ParseSipAddressEx(remoteParty, out dn, out un, out host, out port); if (string.IsNullOrEmpty(un)) return null; remoteParty = port==0 ? string.Format("sip:{0}@{1}", un, host) : string.Format("sip:{0}@{1}:{2}", un, host, port); var callevent = new VATRPCallEvent("", remoteParty) { DisplayName = dn, Username = un }; tmpPtr = LinphoneAPI.linphone_call_log_get_call_id(callLogPtr); if (tmpPtr != IntPtr.Zero) callevent.CallGuid = Marshal.PtrToStringAnsi(tmpPtr); callevent.StartTime = new DateTime(1970, 1, 1).AddSeconds(LinphoneAPI.linphone_call_log_get_start_date(callLogPtr)); callevent.EndTime = callevent.StartTime.AddSeconds( Convert.ToInt32(LinphoneAPI.linphone_call_log_get_duration(callLogPtr))); switch (LinphoneAPI.linphone_call_log_get_status(callLogPtr)) { case LinphoneCallStatus.LinphoneCallSuccess: { callevent.Status = direction == LinphoneCallDir.LinphoneCallIncoming ? VATRPHistoryEvent.StatusType.Incoming : VATRPHistoryEvent.StatusType.Outgoing; } break; case LinphoneCallStatus.LinphoneCallAborted: callevent.Status = VATRPHistoryEvent.StatusType.Failed; break; case LinphoneCallStatus.LinphoneCallDeclined: callevent.Status = VATRPHistoryEvent.StatusType.Rejected; break; case LinphoneCallStatus.LinphoneCallMissed: callevent.Status = VATRPHistoryEvent.StatusType.Missed; break; } return callevent; }
private VATRPCallEvent ParseLinphoneCallLog(IntPtr callLogPtr) { LinphoneCallDir direction = LinphoneAPI.linphone_call_log_get_dir(callLogPtr); IntPtr tmpPtr = LinphoneAPI.linphone_call_log_get_remote_address(callLogPtr); if (tmpPtr == IntPtr.Zero) { return(null); } // 4/11 MITRE-fjr Throws Exception, Added Catch try { tmpPtr = LinphoneAPI.linphone_address_as_string(tmpPtr); // 4/11 try ?? LinphoneAddress _linphoneAddress = LinphoneAPI.linphone_address_as_string(tmpPtr); if (tmpPtr == IntPtr.Zero) { return(null); } } catch (Exception ex) { Console.Write(ex.InnerException); return(null); } var remoteParty = Marshal.PtrToStringAnsi(tmpPtr); LinphoneAPI.ortp_free(tmpPtr); string dn = "", un = "", host = ""; int port = 0; VATRPCall.ParseSipAddressEx(remoteParty, out dn, out un, out host, out port); if (string.IsNullOrEmpty(un)) { return(null); } remoteParty = port == 0 ? string.Format("sip:{0}@{1}", un, host) : string.Format("sip:{0}@{1}:{2}", un, host, port); var callevent = new VATRPCallEvent("", remoteParty) { DisplayName = dn, Username = un }; tmpPtr = LinphoneAPI.linphone_call_log_get_call_id(callLogPtr); if (tmpPtr != IntPtr.Zero) { callevent.CallGuid = Marshal.PtrToStringAnsi(tmpPtr); } callevent.StartTime = new DateTime(1970, 1, 1).AddSeconds(LinphoneAPI.linphone_call_log_get_start_date(callLogPtr)); callevent.EndTime = callevent.StartTime.AddSeconds( Convert.ToInt32(LinphoneAPI.linphone_call_log_get_duration(callLogPtr))); switch (LinphoneAPI.linphone_call_log_get_status(callLogPtr)) { case LinphoneCallStatus.LinphoneCallSuccess: { callevent.Status = direction == LinphoneCallDir.LinphoneCallIncoming ? VATRPHistoryEvent.StatusType.Incoming : VATRPHistoryEvent.StatusType.Outgoing; } break; case LinphoneCallStatus.LinphoneCallAborted: callevent.Status = VATRPHistoryEvent.StatusType.Failed; break; case LinphoneCallStatus.LinphoneCallDeclined: callevent.Status = VATRPHistoryEvent.StatusType.Rejected; break; case LinphoneCallStatus.LinphoneCallMissed: callevent.Status = VATRPHistoryEvent.StatusType.Missed; break; } return(callevent); }
private void DeleteCallEvent(VATRPCallEvent callEvent) { }
private void AddNewCallEvent(VATRPCallEvent callEvent) { try { var dn = callEvent.RemoteParty; var callItem = new RecentsCallItem() { CallerName = dn, CallTime = callEvent.StartTime, Duration = callEvent.Status == VATRPHistoryEvent.StatusType.Missed ? -1 : callEvent.Duration, TargetNumber = callEvent.RemoteParty, CallStatus = callEvent.Status, ContactId = callEvent.Contact != null ? callEvent.Contact.DisplayName : String.Empty }; if ( callEvent.Status == VATRPHistoryEvent.StatusType.Missed) MissedCallsList.Add(callItem); CallsList.Add(callItem); } catch (Exception ex) { ServiceManager.LogError("AddNewCallEvent", ex); } }
private void RemoveCallEvent(VATRPCallEvent callEvent) { lock (this.Calls) { foreach (var call in Calls) { if (call.CallEvent == callEvent) { Calls.Remove(call); if (callEvent.Status == VATRPHistoryEvent.StatusType.Missed) { _unseenMissedCallsCount--; if (_unseenMissedCallsCount < 0) _unseenMissedCallsCount = 0; if (MissedCallsCountChanged != null) MissedCallsCountChanged(null, EventArgs.Empty); } CallsListView.Refresh(); break; } } } }
private object FindCallEvent(VATRPCallEvent callEvent) { lock (this.Calls) { foreach (var call in Calls) { if (call.CallEvent == callEvent) { return callEvent; } } } return null; }
private void AddNewCallEvent(VATRPCallEvent callEvent, bool refreshNow = false) { if (FindCallEvent(callEvent) != null) return; long time_uts; var lastSeenDate = ServiceManager.Instance.ConfigurationService.Get(Configuration.ConfSection.GENERAL, Configuration.ConfEntry.LAST_MISSED_CALL_DATE, string.Empty); if (!long.TryParse(lastSeenDate, out time_uts)) { time_uts = 0; } var contact = _contactService.FindContact(new ContactID(callEvent.RemoteParty.TrimSipPrefix(), IntPtr.Zero)); lock (this.Calls) { Calls.Add(new HistoryCallEventViewModel(callEvent, contact)); if (callEvent.Status == VATRPHistoryEvent.StatusType.Missed) { if (callEvent.EndTime.Ticks > time_uts) { _unseenMissedCallsCount++; if (MissedCallsCountChanged != null) MissedCallsCountChanged(callEvent, EventArgs.Empty); } } } ServiceManager.Instance.ConfigurationService.Set(Configuration.ConfSection.GENERAL, Configuration.ConfEntry.LAST_MISSED_CALL_DATE, DateTime.UtcNow.Ticks.ToString()); if (refreshNow) CallsListView.Refresh(); }