diff options
author | Damian Minkov <damencho@jitsi.org> | 2009-03-04 15:29:03 +0000 |
---|---|---|
committer | Damian Minkov <damencho@jitsi.org> | 2009-03-04 15:29:03 +0000 |
commit | 951deb323547203437f97c871362eebe5ade1584 (patch) | |
tree | 27beab163a9a25ece3fd66320cc5057dd75d11de /src/net/java/sip/communicator/impl/msghistory | |
parent | c1f7dcda55dc575e93e38859b827434537bc734a (diff) | |
download | jitsi-951deb323547203437f97c871362eebe5ade1584.zip jitsi-951deb323547203437f97c871362eebe5ade1584.tar.gz jitsi-951deb323547203437f97c871362eebe5ade1584.tar.bz2 |
Fix issue #520 storing message history per-account. Also if old data exists its migrated to new one on opening it.
Diffstat (limited to 'src/net/java/sip/communicator/impl/msghistory')
-rw-r--r-- | src/net/java/sip/communicator/impl/msghistory/MessageHistoryServiceImpl.java | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/src/net/java/sip/communicator/impl/msghistory/MessageHistoryServiceImpl.java b/src/net/java/sip/communicator/impl/msghistory/MessageHistoryServiceImpl.java index d27c811..82cf9c7 100644 --- a/src/net/java/sip/communicator/impl/msghistory/MessageHistoryServiceImpl.java +++ b/src/net/java/sip/communicator/impl/msghistory/MessageHistoryServiceImpl.java @@ -414,17 +414,49 @@ public class MessageHistoryServiceImpl String remoteId = remoteContact == null ? "default" : remoteContact .getAddress(); + String account = + remoteContact.getProtocolProvider().getAccountID().getAccountUniqueID(); + HistoryID historyId = HistoryID.createFromRawID( new String[] { "messages", localId, + account, + remoteId }); + + // if this history doesn't exists check to see if old one still exists + // old one is not storing history per account + // if old one exists its converted/moved to the new one + // the new one is in format messages/profile_name/account_uid/contact + // the old one was messages/profile_name/contact + if(!this.historyService.isHistoryCreated(historyId)) + { + HistoryID historyId_old = HistoryID.createFromRawID( + new String[] { "messages", + localId, remoteId }); + if(this.historyService.isHistoryCreated(historyId_old)) + { + try + { + this.historyService.moveHistory(historyId_old, historyId); + } + catch (IOException iOException) + { + // something is wrong just use the old one + historyId = historyId_old; + } + } + } + if (this.historyService.isHistoryExisting(historyId)) { retVal = this.historyService.getHistory(historyId); - } else { + } + else + { retVal = this.historyService.createHistory(historyId, - recordStructure); + recordStructure); } return retVal; |