public PhoneDeviceListItem(IPhoneDeviceInfo deviceInfo) : this() { DeviceInfo = deviceInfo; Loaded += delegate { if (deviceInfo.DisplayName != null) { const int MaxNameLength = 17; string phoneNameLocal = deviceInfo.DisplayName; if (phoneNameLocal.Length > MaxNameLength) { phoneNameLocal = phoneNameLocal.Substring(0, MaxNameLength) + "..."; } phoneNameLabel.Content = phoneNameLocal; } else { phoneNameLabel.Content = "Unknown Phone Name"; } if (deviceInfo.LastSync != null) { syncDateTextBlock.Text = string.Format("{0:MMM d, yyyy}", deviceInfo.LastSync); } else { syncDateTextBlock.Text = "Unknown"; } }; }
public void TestInitialize() { _PhoneA = new PhoneDeviceInfo(_PathA, "1", new DateTime(2012, 5, 13, 10, 1, 15), new OsVersion("5.4.3"), null); _PhoneB = new PhoneDeviceInfo(_PathB, "2", new DateTime(2011, 2, 15, 20, 18, 45), new OsVersion("5.4.3"), null); _PhoneC = new PhoneDeviceInfo(_PathC, "3", new DateTime(2010, 8, 28, 19, 14, 52), new OsVersion("4.1.2"), null); _PhoneD = new PhoneDeviceInfo(_PathD, "4", new DateTime(2010, 4, 15, 14, 45, 59), new OsVersion("4.1.1"), null); }
private void VerifyNewestPhoneMatchesExpected(IEnumerable <IPhoneDeviceInfo> phones, IPhoneDeviceInfo newestExpected) { PhoneSelector_Accessor selector = GetSelector(phones); IPhoneDeviceInfo newestActual = selector.GetMostRecentlySyncedDeviceInfo(); Assert.AreEqual(newestExpected, newestActual); }
private void VerifyPhoneWithPathMatchesExpected(IEnumerable <IPhoneDeviceInfo> phones, string path, IPhoneDeviceInfo matchingExpected) { PhoneSelector_Accessor selector = GetSelector(phones); IPhoneDeviceInfo matchingActual = selector.FindDeviceInfoWithPath(path); Assert.AreEqual(matchingExpected, matchingActual); }
private void VerifyXmlMatchesDeviceInfo(string xmlData, IPhoneDeviceInfo deviceInfoExpected) { IPhoneDeviceInfo deviceInfoActual; deviceInfoActual = PhoneDeviceInfoReader_Accessor.PhoneDeviceInfoFromFileContents(DummyXmlFileLocation, xmlData); Assert.AreEqual(deviceInfoExpected, deviceInfoActual); }
public AsyncLoadingProgressParams(ILoadingProgressCallback progressCallback, bool mergeConversations, IPhoneDeviceInfo deviceInfo) { LoadingProgressCallback = progressCallback; MergeConversations = mergeConversations; DeviceInfo = deviceInfo; }
private void VerifyAutoSelectMatchesExpected(IEnumerable <IPhoneDeviceInfo> phones, bool alwaysPrompt, string autoSelectPath, IPhoneDeviceInfo autoSelectedExpected) { PhoneSelector_Accessor phoneSelector = GetSelector(phones, alwaysPrompt, autoSelectPath); IPhoneDeviceInfo autoSelectedActual = phoneSelector.AutoSelectPhoneDevice(); Assert.AreEqual(autoSelectedExpected, autoSelectedActual); }
private void okButton_Click(object sender, RoutedEventArgs e) { this.DialogResult = true; if (phoneListBox.SelectedValue != null) { SelectedDevice = (IPhoneDeviceInfo)phoneListBox.SelectedValue; } CommitChanges(); }
public MainWindowModelBase(IDisplayOptions displayOptions, IPhoneSelectOptions phoneSelectOptions) { DisplayOptions = displayOptions; PhoneSelectOptions = phoneSelectOptions; DeviceInfo = null; ConversationManager = null; _sortedConversationList = null; }
private IPhoneDeviceInfo GetMostRecentlySyncedDeviceInfo() { IPhoneDeviceInfo mostRecent = null; foreach (IPhoneDeviceInfo deviceInfo in _devices) { if ((mostRecent == null) || (deviceInfo.LastSync >= mostRecent.LastSync)) { mostRecent = deviceInfo; } } return(mostRecent); }
private int ComparePhones(IPhoneDeviceInfo phone1, IPhoneDeviceInfo phone2) { if (!phone1.LastSync.HasValue) { return(1); } if (!phone2.LastSync.HasValue) { return(-1); } else { return(-1 * phone1.LastSync.Value.CompareTo(phone2.LastSync.Value)); } }
private int ComparePhones(IPhoneDeviceInfo phone1, IPhoneDeviceInfo phone2) { if (!phone1.LastSync.HasValue) { return 1; } if (!phone2.LastSync.HasValue) { return -1; } else { return -1 * phone1.LastSync.Value.CompareTo(phone2.LastSync.Value); } }
private IPhoneDeviceInfo GetSelectedPhoneInfo() { List <IPhoneDeviceInfo> devicesInfo = devicesInfo = new List <IPhoneDeviceInfo>(PhoneDeviceInfoReader.GetDevicesInfo()); PhoneSelector phoneSelector = new PhoneSelector(devicesInfo, _phoneSelectOptions); IPhoneDeviceInfo selectedPhone; selectedPhone = phoneSelector.AutoSelectPhoneDevice(); if (phoneSelector.ShouldWarnAboutLaterSyncedPhone()) { bool letUserChoosePhone; bool ignoreNewerSyncs; PromptToChooseLaterSync(out letUserChoosePhone, out ignoreNewerSyncs); if (letUserChoosePhone) { selectedPhone = null; } else if (ignoreNewerSyncs) { _phoneSelectOptions.WarnAboutMoreRecentSync = false; _phoneSelectOptions.Save(); } } if (selectedPhone != null) { _deviceInfo = selectedPhone; return(selectedPhone); } bool alwaysPrompt; if (PromptForPhoneSelectionOptions(devicesInfo, out selectedPhone, out alwaysPrompt) == false) { Environment.Exit(0); } _deviceInfo = selectedPhone; _phoneSelectOptions.PromptForPhoneChoice = alwaysPrompt; _phoneSelectOptions.PhoneDataPath = selectedPhone.BackupPath; _phoneSelectOptions.Save(); return(selectedPhone); }
public bool ShouldWarnAboutLaterSyncedPhone() { if (!_phoneSelectOptions.WarnAboutMoreRecentSync) { return(false); } IPhoneDeviceInfo autoSelectedPhone = AutoSelectPhoneDevice(); IPhoneDeviceInfo lastSyncedPhone = GetMostRecentlySyncedDeviceInfo(); if ((autoSelectedPhone != null) && (autoSelectedPhone != lastSyncedPhone)) { return(true); } else { return(false); } }
private void ShowSettingsDialog_Executed(object sender, ExecutedRoutedEventArgs e) { IDisplayOptions displayOptions = _mainWindowModel.DisplayOptions; IPhoneSelectOptions phoneSelectOptions = _mainWindowModel.PhoneSelectOptions; OptionsDialogView optionsDialog = new OptionsDialogView(displayOptions, phoneSelectOptions); optionsDialog.Owner = this; optionsDialog.SelectedDevice = _deviceInfo; optionsDialog.ShowDialog(); if (optionsDialog.DialogResult == true) { if (optionsDialog.SelectedDevice != _deviceInfo) { _deviceInfo = optionsDialog.SelectedDevice; PerformRefresh(); } } }
public bool Equals(IPhoneDeviceInfo other) { if (this.BackupPath != other.BackupPath) { return false; } if (this.DisplayName != other.DisplayName) { return false; } if (this.LastSync != other.LastSync) { return false; } if (this.OsVersion == null) { if (other.OsVersion != null) { return false; } } else if (!this.OsVersion.Equals(other.OsVersion)) { return false; } if (this.DeviceGuid == null) { if (other.DeviceGuid != null) { return false; } } else if (!this.DeviceGuid.Equals(other.DeviceGuid)) { return false; } return true; }
public bool Equals(IPhoneDeviceInfo other) { if (this.BackupPath != other.BackupPath) { return(false); } if (this.DisplayName != other.DisplayName) { return(false); } if (this.LastSync != other.LastSync) { return(false); } if (this.OsVersion == null) { if (other.OsVersion != null) { return(false); } } else if (!this.OsVersion.Equals(other.OsVersion)) { return(false); } if (this.DeviceGuid == null) { if (other.DeviceGuid != null) { return(false); } } else if (!this.DeviceGuid.Equals(other.DeviceGuid)) { return(false); } return(true); }
private static void OnDoWork(object sender, DoWorkEventArgs e) { AsyncLoadingProgressParams workParams = (AsyncLoadingProgressParams)e.Argument; ILoadingProgressCallback progressCallback = workParams.LoadingProgressCallback; bool mergeConversations = workParams.MergeConversations; IPhoneDeviceInfo deviceInfo = workParams.DeviceInfo; try { IConversationManager conversationManager = MainWindowModelBase.LoadConversationManager(progressCallback, deviceInfo, mergeConversations); progressCallback.End(); e.Result = conversationManager; } catch (OperationCanceledException) { e.Cancel = true; } }
public MainWindow() { InitializeComponent(); _currentView = DefaultApplicationView; _conversationManager = null; DisplayOptions options = new DisplayOptions(); _displayOptions = options as IDisplayOptions; _displayOptions.TimeDisplayFormatPropertyChanged += OnTimeDisplayFormatPropertyChanged; _displayOptions.HideEmptyConversationsPropertyChanged += OnHideEmptyConversationsPropertyChanged; _displayOptions.MergeContactsPropertyChanged += OnMergeContactsPropertyChanged; _displayOptions.LoadMmsAttachmentsPropertyChanged += OnLoadMmsAttachmentsPropertyChanged; _displayOptions.ConversationSortingPropertyChanged += OnConversationSortingPropertyChanged; _phoneSelectOptions = options as IPhoneSelectOptions; _deviceInfo = null; conversationRenderControl.DisplayOptions = _displayOptions; conversationRenderControl.findBar.FindModel = new FindDialogModel(this); Loaded += OnLoaded; }
private void VerifyNewestPhoneMatchesExpected(IEnumerable<IPhoneDeviceInfo> phones, IPhoneDeviceInfo newestExpected) { PhoneSelector_Accessor selector = GetSelector(phones); IPhoneDeviceInfo newestActual = selector.GetMostRecentlySyncedDeviceInfo(); Assert.AreEqual(newestExpected, newestActual); }
private bool PromptForPhoneSelectionOptions(IEnumerable<IPhoneDeviceInfo> devicesInfo, out IPhoneDeviceInfo selectedPhone, out bool alwaysPromptForChoice) { PhoneSelectionView phoneSelection = new PhoneSelectionView(devicesInfo, _phoneSelectOptions); phoneSelection.Owner = this; phoneSelection.ShowDialog(); if (phoneSelection.DialogResult == false) { selectedPhone = null; alwaysPromptForChoice = false; return false; } alwaysPromptForChoice = phoneSelection.AlwaysPrompt; selectedPhone = phoneSelection.SelectedPhoneInfo; return true; }
private IPhoneDeviceInfo GetSelectedPhoneInfo() { List<IPhoneDeviceInfo> devicesInfo = devicesInfo = new List<IPhoneDeviceInfo>(PhoneDeviceInfoReader.GetDevicesInfo()); PhoneSelector phoneSelector = new PhoneSelector(devicesInfo, _phoneSelectOptions); IPhoneDeviceInfo selectedPhone; selectedPhone = phoneSelector.AutoSelectPhoneDevice(); if (phoneSelector.ShouldWarnAboutLaterSyncedPhone()) { bool letUserChoosePhone; bool ignoreNewerSyncs; PromptToChooseLaterSync(out letUserChoosePhone, out ignoreNewerSyncs); if (letUserChoosePhone) { selectedPhone = null; } else if (ignoreNewerSyncs) { _phoneSelectOptions.WarnAboutMoreRecentSync = false; _phoneSelectOptions.Save(); } } if (selectedPhone != null) { _deviceInfo = selectedPhone; return selectedPhone; } bool alwaysPrompt; if (PromptForPhoneSelectionOptions(devicesInfo, out selectedPhone, out alwaysPrompt) == false) { Environment.Exit(0); } _deviceInfo = selectedPhone; _phoneSelectOptions.PromptForPhoneChoice = alwaysPrompt; _phoneSelectOptions.PhoneDataPath = selectedPhone.BackupPath; _phoneSelectOptions.Save(); return selectedPhone; }
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 bool PromptForPhoneSelectionOptions(IEnumerable <IPhoneDeviceInfo> devicesInfo, out IPhoneDeviceInfo selectedPhone, out bool alwaysPromptForChoice) { PhoneSelectionView phoneSelection = new PhoneSelectionView(devicesInfo, _phoneSelectOptions); phoneSelection.Owner = this; phoneSelection.ShowDialog(); if (phoneSelection.DialogResult == false) { selectedPhone = null; alwaysPromptForChoice = false; return(false); } alwaysPromptForChoice = phoneSelection.AlwaysPrompt; selectedPhone = phoneSelection.SelectedPhoneInfo; return(true); }
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 void VerifyAutoSelectMatchesExpected(IEnumerable<IPhoneDeviceInfo> phones, bool alwaysPrompt, string autoSelectPath, IPhoneDeviceInfo autoSelectedExpected) { PhoneSelector_Accessor phoneSelector = GetSelector(phones, alwaysPrompt, autoSelectPath); IPhoneDeviceInfo autoSelectedActual = phoneSelector.AutoSelectPhoneDevice(); Assert.AreEqual(autoSelectedExpected, autoSelectedActual); }
private void VerifyPhoneWithPathMatchesExpected(IEnumerable<IPhoneDeviceInfo> phones, string path, IPhoneDeviceInfo matchingExpected) { PhoneSelector_Accessor selector = GetSelector(phones); IPhoneDeviceInfo matchingActual = selector.FindDeviceInfoWithPath(path); Assert.AreEqual(matchingExpected, matchingActual); }