diff options
author | Yana Stamcheva <yana@jitsi.org> | 2010-05-03 15:35:35 +0000 |
---|---|---|
committer | Yana Stamcheva <yana@jitsi.org> | 2010-05-03 15:35:35 +0000 |
commit | 7393be5cfb0dc60997bf654af16acc36486b6129 (patch) | |
tree | 2bb884705ebef32bdeb2f4f50aebbafd07de91cd /src/net/java | |
parent | a1f74ad638d9d4eda31cff0296b525d8ded15ee9 (diff) | |
download | jitsi-7393be5cfb0dc60997bf654af16acc36486b6129.zip jitsi-7393be5cfb0dc60997bf654af16acc36486b6129.tar.gz jitsi-7393be5cfb0dc60997bf654af16acc36486b6129.tar.bz2 |
Fix unit tests.
Diffstat (limited to 'src/net/java')
3 files changed, 60 insertions, 11 deletions
diff --git a/src/net/java/sip/communicator/impl/callhistory/CallHistoryServiceImpl.java b/src/net/java/sip/communicator/impl/callhistory/CallHistoryServiceImpl.java index 93d83f4..55ecf7e 100644 --- a/src/net/java/sip/communicator/impl/callhistory/CallHistoryServiceImpl.java +++ b/src/net/java/sip/communicator/impl/callhistory/CallHistoryServiceImpl.java @@ -345,7 +345,10 @@ public class CallHistoryServiceImpl if (this.historyService.isHistoryExisting(historyId)) { retVal = this.historyService.getHistory(historyId); - } else { + retVal.setHistoryRecordsStructure(recordStructure); + } + else + { retVal = this.historyService.createHistory(historyId, recordStructure); } @@ -891,12 +894,15 @@ public class CallHistoryServiceImpl * @param callPeer CallPeer * @param srcCall Call */ - private void handlePeerRemoved(CallPeer callPeer, - Call srcCall) + private void handlePeerRemoved( CallPeer callPeer, + Call srcCall) { CallRecord callRecord = findCallRecord(srcCall); String pAddress = callPeer.getAddress(); + if (callRecord == null) + return; + CallPeerRecordImpl cpRecord = (CallPeerRecordImpl)callRecord.findPeerRecord(pAddress); @@ -1105,17 +1111,17 @@ public class CallHistoryServiceImpl if (callRecord == null) return; - if (evt.getNewValue().equals(CallState.CALL_ENDED) - && evt.getOldValue().equals(CallState.CALL_INITIALIZATION)) + if (evt.getNewValue().equals(CallState.CALL_ENDED)) { - callRecord.setEndTime(callRecord.getStartTime()); - } - else - callRecord.setEndTime(new Date()); + if(evt.getOldValue().equals(CallState.CALL_INITIALIZATION)) + callRecord.setEndTime(callRecord.getStartTime()); + else + callRecord.setEndTime(new Date()); - writeCall(callRecord, null, null); + writeCall(callRecord, null, null); - currentCallRecords.remove(callRecord); + currentCallRecords.remove(callRecord); + } } } diff --git a/src/net/java/sip/communicator/impl/history/HistoryImpl.java b/src/net/java/sip/communicator/impl/history/HistoryImpl.java index 0be13d2..04e4b12 100644 --- a/src/net/java/sip/communicator/impl/history/HistoryImpl.java +++ b/src/net/java/sip/communicator/impl/history/HistoryImpl.java @@ -41,6 +41,15 @@ public class HistoryImpl implements History { private SortedMap<String, Object> historyDocuments = new TreeMap<String, Object>(); + /** + * Creates an instance of <tt>HistoryImpl</tt> by specifying the history + * identifier, the directory, the <tt>HistoryRecordStructure</tt> to use + * and the parent <tt>HistoryServiceImpl</tt>. + * @param id the identifier + * @param directory the directory + * @param historyRecordStructure the structure + * @param historyServiceImpl the parent history service + */ protected HistoryImpl(HistoryID id, File directory, HistoryRecordStructure historyRecordStructure, HistoryServiceImpl historyServiceImpl) @@ -68,16 +77,44 @@ public class HistoryImpl implements History { } } + /** + * Returns the identifier of this history. + * @return the identifier of this history + */ public HistoryID getID() { return this.id; } + /** + * Returns the current <tt>HistoryRecordStructure</tt>. + * @return the current <tt>HistoryRecordStructure</tt> + */ public HistoryRecordStructure getHistoryRecordsStructure() { return this.historyRecordStructure; } + /** + * Sets the given <tt>structure</tt> to be the new history records + * structure used in this history implementation. + * @param structure the new <tt>HistoryRecordStructure</tt> to use + */ + public void setHistoryRecordsStructure(HistoryRecordStructure structure) + { + this.historyRecordStructure = structure; + + try + { + File dbDatFile = new File(directory, HistoryServiceImpl.DATA_FILE); + DBStructSerializer dbss = new DBStructSerializer(historyServiceImpl); + dbss.writeHistory(dbDatFile, this); + } + catch (IOException e) + { + log.debug("Could not create new history structure"); + } + } public HistoryReader getReader() { if (this.reader == null) diff --git a/src/net/java/sip/communicator/service/history/History.java b/src/net/java/sip/communicator/service/history/History.java index b34d32d..864bed2 100644 --- a/src/net/java/sip/communicator/service/history/History.java +++ b/src/net/java/sip/communicator/service/history/History.java @@ -35,4 +35,10 @@ public interface History { */ HistoryRecordStructure getHistoryRecordsStructure(); + /** + * Sets the given <tt>structure</tt> to be the new history records + * structure used in this history implementation. + * @param structure the new <tt>HistoryRecordStructure</tt> to use + */ + void setHistoryRecordsStructure(HistoryRecordStructure struct); } |