Changes the updateCallRecordPeerSecondaryAddress method parameters in call history service and fixes NPE in call history service.

ice4sip 5092
hristoterezov 12 years ago
parent 744d44d3f2
commit 70daf44fbb

@ -487,7 +487,7 @@ else if(propName.equals(STRUCTURE_NAMES[10]))
callPeerEndValue);
String callPeerSecondaryID = null;
if(!callPeerSecondaryIDs.isEmpty())
if(callPeerSecondaryIDs != null && !callPeerSecondaryIDs.isEmpty())
callPeerSecondaryID = callPeerSecondaryIDs.get(i);
if(callPeerSecondaryID != null && !callPeerSecondaryID.equals(""))
@ -1100,26 +1100,32 @@ private void handlePeerRemoved( CallPeer callPeer,
/**
* Updates the secondary address field of call record.
* @param date the start date of the record which will be updated.
* @param peer the peer of the record which will be updated.
* @param peerAddress the address of the peer of the record which will be
* updated.
* @param address the value of the secondary address .
*/
public void updateCallRecordPeerSecondaryAddress(final Date date,
final CallPeer peer,
final String peerAddress,
final String address)
{
CallRecord record = findCallRecord(peer.getCall());
if(record != null)
boolean callRecordFound = false;
synchronized (currentCallRecords)
{
for(CallPeerRecord peerRecord : record.getPeerRecords())
{
if(peerRecord.getPeerAddress().equals(peer.getAddress()))
for(CallRecord record : currentCallRecords)
for(CallPeerRecord peerRecord : record.getPeerRecords())
{
peerRecord.setPeerSecondaryAddress(address);
if(peerRecord.getPeerAddress().equals(peerAddress)
&& peerRecord.getStartTime().equals(date))
{
callRecordFound = true;
peerRecord.setPeerSecondaryAddress(address);
}
}
}
return;
}
if(callRecordFound)
return;
History history;
try
{
@ -1173,7 +1179,7 @@ public boolean isMatching()
List<String> peerIDs
= getCSVs(propertyVlaues[peerIDIndex]);
int i = peerIDs.indexOf(peer.getAddress());
int i = peerIDs.indexOf(peerAddress);
if(i == -1)
return false;
@ -1209,13 +1215,13 @@ public Map<String, String> getUpdateChanges()
List<String> peerIDs
= getCSVs(propertyVlaues[peerIDIndex]);
int i = peerIDs.indexOf(peer.getAddress());
int i = peerIDs.indexOf(peerAddress);
if(i == -1)
return null;
List<String> secondaryID
= getCSVs(record.getPropertyValues()[peerSecondaryIDIndex]);
secondaryID.set(i, peer.getAddress());
secondaryID.set(i, peerAddress);
String res = "";
int j = 0;
for(String id : secondaryID)
@ -1248,12 +1254,16 @@ public Map<String, String> getUpdateChanges()
*/
private CallRecordImpl findCallRecord(Call call)
{
for (CallRecordImpl item : currentCallRecords)
synchronized (currentCallRecords)
{
if (item.getSourceCall().equals(call))
return item;
for (CallRecordImpl item : currentCallRecords)
{
if (item.getSourceCall().equals(call))
return item;
}
}
return null;
}
@ -1281,13 +1291,18 @@ private CallPeerRecordImpl findPeerRecord(
*/
private void handleNewCall(Call sourceCall, String direction)
{
// if call exist. its not new
for (CallRecordImpl currentCallRecord : currentCallRecords)
synchronized (currentCallRecords)
{
if (currentCallRecord.getSourceCall().equals(sourceCall))
return;
for (CallRecordImpl currentCallRecord : currentCallRecords)
{
if (currentCallRecord.getSourceCall().equals(sourceCall))
return;
}
}
CallRecordImpl newRecord = new CallRecordImpl(
direction,
new Date(),
@ -1296,7 +1311,10 @@ private void handleNewCall(Call sourceCall, String direction)
sourceCall.addCallChangeListener(historyCallChangeListener);
currentCallRecords.add(newRecord);
synchronized (currentCallRecords)
{
currentCallRecords.add(newRecord);
}
// if has already perticipants Dispatch them
@ -1452,8 +1470,10 @@ public void callStateChanged(CallChangeEvent evt)
callRecord.setEndTime(new Date());
writeCall(callRecord, null, null);
currentCallRecords.remove(callRecord);
synchronized (currentCallRecords)
{
currentCallRecords.remove(callRecord);
}
}
}
}

@ -10,7 +10,6 @@
import net.java.sip.communicator.service.callhistory.event.*;
import net.java.sip.communicator.service.contactlist.*;
import net.java.sip.communicator.service.protocol.*;
/**
* The Call History Service stores info about calls made from various protocols
@ -153,7 +152,7 @@ public void removeSearchProgressListener(
* @param address the value of the secondary address .
*/
public void updateCallRecordPeerSecondaryAddress(final Date date,
final CallPeer peer,
final String peerAddress,
final String address);
/**

Loading…
Cancel
Save