private MergingConversationManager CreateMergingConversationManager(DummyContactId[] contactIds, DummyPhoneNumberId[] messageSetIds, ILoadingProgressCallback progressCallback) { if (progressCallback != null) { int workEstimate = ConversationManager.GetWorkEstimate(contactIds.Length, messageSetIds.Length, 0, 0) + MergingConversationManager.GetWorkEstimateByContacts(contactIds.Length); progressCallback.Begin(workEstimate); } ConversationManager conversationManager = DummyConversationDataGenerator.GetConversationManager(contactIds, messageSetIds, progressCallback); if (progressCallback != null) { progressCallback.UpdateRemaining(MergingConversationManager.GetWorkEstimate(conversationManager.ConversationCount)); } MergingConversationManager mergingConversationManager = new MergingConversationManager(conversationManager, progressCallback); if (progressCallback != null) { progressCallback.End(); } return(mergingConversationManager); }
public void MultipleUnknownContactTestTest() { DummyContactId[] dummyContactIds = { }; DummyPhoneNumberId[] DummyPhoneNumberIds = { DummyPhoneNumberId.UnknownEagle, DummyPhoneNumberId.UnknownGrahamBell }; MergingConversationManager conversationManagerMerged = CreateMergingConversationManager(dummyContactIds, DummyPhoneNumberIds, null); Assert.AreEqual(2, conversationManagerMerged.ConversationCount); }
public void MergingNullCallbackTest() { DummyContactId[] dummyContactIds = { DummyContactId.Davola, DummyContactId.Obama }; DummyPhoneNumberId[] DummyPhoneNumberIds = { DummyPhoneNumberId.DavolaCell, DummyPhoneNumberId.DavolaiPhone, DummyPhoneNumberId.ObamaCell }; MergingConversationManager conversationManagerMerged = CreateMergingConversationManager(dummyContactIds, DummyPhoneNumberIds, null); Assert.AreEqual(2, conversationManagerMerged.ConversationCount); }
public void MergedConversationWithExactDuplicatesTest() { MockLoadingProgressCallback progressCallback = new MockLoadingProgressCallback(); DummyContactId[] dummyContactIds = { DummyContactId.Davola, DummyContactId.Davola }; DummyPhoneNumberId[] DummyPhoneNumberIds = { DummyPhoneNumberId.DavolaCell, DummyPhoneNumberId.DavolaiPhone }; MergingConversationManager mergingConversationManager = CreateMergingConversationManager(dummyContactIds, DummyPhoneNumberIds, progressCallback); Assert.AreEqual(1, mergingConversationManager.ConversationCount); ConversationManagerTest.VerifySuccessfulCompletion(progressCallback); }
public static IConversation GetMergedConversation(DummyContactId contactId) { List <Contact> contacts = GetContacts(contactId); IEnumerable <TextMessage> messages = GetMessageSet(contactId); List <ChatRoomInformation> chatInfoItems = new List <ChatRoomInformation>(); List <MessageAttachment> attachments = new List <MessageAttachment>(); ConversationManager conversationManager = new ConversationManager(contacts, messages, chatInfoItems, attachments, null); MergingConversationManager megingConversationManager = new MergingConversationManager(conversationManager, null); return(megingConversationManager.GetConversation(0)); }
public void EmptyMergedConversationTest() { MockLoadingProgressCallback progressCallback = new MockLoadingProgressCallback(); DummyContactId[] dummyContactIds = { DummyContactId.NeverTexter }; DummyPhoneNumberId[] DummyPhoneNumberIds = { }; MergingConversationManager mergingConversationManager = CreateMergingConversationManager(dummyContactIds, DummyPhoneNumberIds, progressCallback); Assert.AreEqual(1, mergingConversationManager.ConversationCount); int expectedProgressMax = (DummyConversationDataGenerator.GetPhoneNumberCount(dummyContactIds) * 2) + DummyConversationDataGenerator.GetMessageCount(DummyPhoneNumberIds); Assert.AreEqual(expectedProgressMax, progressCallback.Maximum); ConversationManagerTest.VerifySuccessfulCompletion(progressCallback); }
public void ConversationWithNumberDuplicatesTest() { MockLoadingProgressCallback progressCallback = new MockLoadingProgressCallback(); DummyContactId[] dummyContactIds = { DummyContactId.Davola, DummyContactId.DavolaNumberDuplicate }; DummyPhoneNumberId[] DummyPhoneNumberIds = { DummyPhoneNumberId.DavolaCell, DummyPhoneNumberId.DavolaiPhone }; MergingConversationManager conversationManagerMerged = CreateMergingConversationManager(dummyContactIds, DummyPhoneNumberIds, progressCallback); Assert.AreEqual(1, conversationManagerMerged.ConversationCount); IConversation conversation = conversationManagerMerged.GetConversation(0); Assert.AreEqual(1, conversation.AssociatedContacts.Count); Assert.AreEqual((long)DummyContactId.Davola, conversation.AssociatedContacts[0].ContactId); ConversationManagerTest.VerifySuccessfulCompletion(progressCallback); }
private IConversationManager GetConversationManager(IDisplayOptions diplayOptions) { IConversationManager conversationManager; DummyContactId[] contactIds = { DummyContactId.Davola, DummyContactId.Obama, DummyContactId.NeverTexter, DummyContactId.ReliableLarry }; DummyPhoneNumberId[] messageSetIds = {DummyPhoneNumberId.DavolaCell, DummyPhoneNumberId.DavolaiPhone, DummyPhoneNumberId.ObamaCell, DummyPhoneNumberId.ReliableLarryOffice, DummyPhoneNumberId.UnknownLawnmower, DummyPhoneNumberId.UnknownEagle}; List<Contact> contacts = DummyConversationDataGenerator.GetContacts(contactIds); List<ChatRoomInformation> chatInfoItems = new List<ChatRoomInformation>(); List<TextMessage> messages = DummyConversationDataGenerator.GetMessages(messageSetIds); List<MessageAttachment> attachments = new List<MessageAttachment>(); conversationManager = new ConversationManager(contacts, messages, chatInfoItems, attachments, null); if (diplayOptions.MergeContacts) { conversationManager = new MergingConversationManager(conversationManager, null); } return conversationManager; }
private IConversationManager GetConversationManager(IDisplayOptions diplayOptions) { IConversationManager conversationManager; DummyContactId[] contactIds = { DummyContactId.Davola, DummyContactId.Obama, DummyContactId.NeverTexter, DummyContactId.ReliableLarry }; DummyPhoneNumberId[] messageSetIds = { DummyPhoneNumberId.DavolaCell, DummyPhoneNumberId.DavolaiPhone, DummyPhoneNumberId.ObamaCell, DummyPhoneNumberId.ReliableLarryOffice, DummyPhoneNumberId.UnknownLawnmower, DummyPhoneNumberId.UnknownEagle }; List <Contact> contacts = DummyConversationDataGenerator.GetContacts(contactIds); List <ChatRoomInformation> chatInfoItems = new List <ChatRoomInformation>(); List <TextMessage> messages = DummyConversationDataGenerator.GetMessages(messageSetIds); List <MessageAttachment> attachments = new List <MessageAttachment>(); conversationManager = new ConversationManager(contacts, messages, chatInfoItems, attachments, null); if (diplayOptions.MergeContacts) { conversationManager = new MergingConversationManager(conversationManager, null); } return(conversationManager); }
public static IConversation GetMergedConversation(DummyContactId contactId) { List<Contact> contacts = GetContacts(contactId); IEnumerable<TextMessage> messages = GetMessageSet(contactId); List<ChatRoomInformation> chatInfoItems = new List<ChatRoomInformation>(); List<MessageAttachment> attachments = new List<MessageAttachment>(); ConversationManager conversationManager = new ConversationManager(contacts, messages, chatInfoItems, attachments, null); MergingConversationManager megingConversationManager = new MergingConversationManager(conversationManager, null); return megingConversationManager.GetConversation(0); }
public static IConversationManager LoadConversationManager(ILoadingProgressCallback progressCallback, IPhoneDeviceInfo deviceInfo, bool mergeConversations) { IConversationManager conversationManager = null; using (DatabaseReader contactDatabaseReader = new DatabaseReader(DatabaseFinder.FindContactDatabasePath(deviceInfo.BackupPath))) { ContactReader contactReader = new ContactReader(); contactReader.ParseDatabase(contactDatabaseReader); using (DatabaseReader textDatabaseReader = new DatabaseReader(DatabaseFinder.FindTextMessageDatabasePath(deviceInfo.BackupPath))) { TextMessageReaderBase textMessageReader; IEnumerable<ChatRoomInformation> chatReader; IEnumerable<MessageAttachment> attachments; int chatWorkEstimate; if ((deviceInfo.OsVersion == null) || (deviceInfo.OsVersion.MajorVersion >= 6)) { try { textMessageReader = new TextMessageReaderiOS6(deviceInfo.BackupPath); textMessageReader.ParseDatabase(textDatabaseReader); ChatRoomInformationReaderiOS6 chatRoomInfoReader = new ChatRoomInformationReaderiOS6(); chatRoomInfoReader.ParseDatabase(textDatabaseReader); chatReader = chatRoomInfoReader; attachments = new List<MessageAttachment>(); chatWorkEstimate = chatRoomInfoReader.ItemCountEstimate; } catch (DatabaseQueryException) { textMessageReader = new TextMessageReader(deviceInfo.BackupPath); textMessageReader.ParseDatabase(textDatabaseReader); chatReader = new List<ChatRoomInformation>(); attachments = new List<MessageAttachment>(); chatWorkEstimate = 0; } } else if (deviceInfo.OsVersion.MajorVersion == 5) { textMessageReader = new TextMessageReader2(deviceInfo.BackupPath); textMessageReader.ParseDatabase(textDatabaseReader); ChatRoomInformationReader chatRoomInfoReader = new ChatRoomInformationReader(); chatRoomInfoReader.ParseDatabase(textDatabaseReader); chatReader = chatRoomInfoReader; attachments = new List<MessageAttachment>(); chatWorkEstimate = chatRoomInfoReader.ItemCountEstimate; } else { textMessageReader = new TextMessageReader(deviceInfo.BackupPath); textMessageReader.ParseDatabase(textDatabaseReader); chatReader = new List<ChatRoomInformation>(); attachments = new List<MessageAttachment>(); chatWorkEstimate = 0; } int workEstimate = AllYourTextsLib.Conversation.ConversationManager.GetWorkEstimate(contactReader.ItemCountEstimate, textMessageReader.ItemCountEstimate, chatWorkEstimate, 0); if (mergeConversations) { workEstimate += MergingConversationManager.GetWorkEstimateByContacts(contactReader.ItemCountEstimate); } progressCallback.Begin(workEstimate); conversationManager = new ConversationManager(contactReader, textMessageReader, chatReader, attachments, progressCallback); if (mergeConversations) { conversationManager = new MergingConversationManager(conversationManager, progressCallback); } } } return conversationManager; }
public static IConversationManager LoadConversationManager(ILoadingProgressCallback progressCallback, IPhoneDeviceInfo deviceInfo, bool mergeConversations) { IConversationManager conversationManager = null; using (DatabaseReader contactDatabaseReader = new DatabaseReader(DatabaseFinder.FindContactDatabasePath(deviceInfo.BackupPath))) { ContactReader contactReader = new ContactReader(); contactReader.ParseDatabase(contactDatabaseReader); using (DatabaseReader textDatabaseReader = new DatabaseReader(DatabaseFinder.FindTextMessageDatabasePath(deviceInfo.BackupPath))) { TextMessageReaderBase textMessageReader; IEnumerable <ChatRoomInformation> chatReader; IEnumerable <MessageAttachment> attachments; int chatWorkEstimate; if ((deviceInfo.OsVersion == null) || (deviceInfo.OsVersion.MajorVersion >= 6)) { try { textMessageReader = new TextMessageReaderiOS6(deviceInfo.BackupPath); textMessageReader.ParseDatabase(textDatabaseReader); ChatRoomInformationReaderiOS6 chatRoomInfoReader = new ChatRoomInformationReaderiOS6(); chatRoomInfoReader.ParseDatabase(textDatabaseReader); chatReader = chatRoomInfoReader; attachments = new List <MessageAttachment>(); chatWorkEstimate = chatRoomInfoReader.ItemCountEstimate; } catch (DatabaseQueryException) { textMessageReader = new TextMessageReader(deviceInfo.BackupPath); textMessageReader.ParseDatabase(textDatabaseReader); chatReader = new List <ChatRoomInformation>(); attachments = new List <MessageAttachment>(); chatWorkEstimate = 0; } } else if (deviceInfo.OsVersion.MajorVersion == 5) { textMessageReader = new TextMessageReader2(deviceInfo.BackupPath); textMessageReader.ParseDatabase(textDatabaseReader); ChatRoomInformationReader chatRoomInfoReader = new ChatRoomInformationReader(); chatRoomInfoReader.ParseDatabase(textDatabaseReader); chatReader = chatRoomInfoReader; attachments = new List <MessageAttachment>(); chatWorkEstimate = chatRoomInfoReader.ItemCountEstimate; } else { textMessageReader = new TextMessageReader(deviceInfo.BackupPath); textMessageReader.ParseDatabase(textDatabaseReader); chatReader = new List <ChatRoomInformation>(); attachments = new List <MessageAttachment>(); chatWorkEstimate = 0; } int workEstimate = AllYourTextsLib.Conversation.ConversationManager.GetWorkEstimate(contactReader.ItemCountEstimate, textMessageReader.ItemCountEstimate, chatWorkEstimate, 0); if (mergeConversations) { workEstimate += MergingConversationManager.GetWorkEstimateByContacts(contactReader.ItemCountEstimate); } progressCallback.Begin(workEstimate); conversationManager = new ConversationManager(contactReader, textMessageReader, chatReader, attachments, progressCallback); if (mergeConversations) { conversationManager = new MergingConversationManager(conversationManager, progressCallback); } } } return(conversationManager); }
private MergingConversationManager CreateMergingConversationManager(DummyContactId[] contactIds, DummyPhoneNumberId[] messageSetIds, ILoadingProgressCallback progressCallback) { if (progressCallback != null) { int workEstimate = ConversationManager.GetWorkEstimate(contactIds.Length, messageSetIds.Length, 0, 0) + MergingConversationManager.GetWorkEstimateByContacts(contactIds.Length); progressCallback.Begin(workEstimate); } ConversationManager conversationManager = DummyConversationDataGenerator.GetConversationManager(contactIds, messageSetIds, progressCallback); if (progressCallback != null) { progressCallback.UpdateRemaining(MergingConversationManager.GetWorkEstimate(conversationManager.ConversationCount)); } MergingConversationManager mergingConversationManager = new MergingConversationManager(conversationManager, progressCallback); if (progressCallback != null) { progressCallback.End(); } return mergingConversationManager; }