private void DoImporting() { _dbLocations.Clear(); _icqContacts.Clear(); _icqMessages.Clear(); _idResources.Clear(); Importer theImporter = Importer.GetInstance(); theImporter.Reset(); Core.UIManager.GetStatusWriter(this, StatusPane.UI).ShowStatus("Importing ICQ database"); if (Core.ProgressWindow != null) { Core.ProgressWindow.UpdateProgress(0, "Importing ICQ database", null); } AsyncProcessor resourceAP = (AsyncProcessor)Core.ResourceAP; bool needIdle = ObjectStore.ReadBool("ICQ", "NeedIdle", true); foreach (IICQDatabase D in theImporter) { if (needIdle && !_startedInIdleMode && _indexStartDate > DateTime.MinValue) { D.SkipUpdate(); } bool hasData = false; bool indexed = false; int lastUIN = 0; foreach (object ICQObject in D) { if (lastUIN != D.CurrentUIN) { lastUIN = D.CurrentUIN; indexed = IndexedUIN(lastUIN); } if (indexed) { if (ICQObject is ICQContact) { _icqContacts.Add(ICQObject); } else if (ICQObject is ICQMessage) { ICQMessage msg = (ICQMessage)ICQObject; DateTime msgDateTime = msg.Time; if ((_startedInIdleMode || _indexStartDate <= msgDateTime) && (_minUpdateDate > msgDateTime || _maxUpdateDate < msgDateTime)) { _icqMessages.Add(msg); } } hasData = true; } if (Core.State == CoreState.ShuttingDown) { D.SkipUpdate(); Interrupted = true; return; } if (resourceAP.OutstandingJobs > 0) { resourceAP.DoJobs(); } } if (hasData) { _dbLocations.Add(D.CurrentLocation); } } // sort messages by date _icqMessages.Sort(new ICQMessageComparer()); // remove duplicates for (int i = 0; i < _icqMessages.Count - 1;) { ICQMessage m1 = _icqMessages[i] as ICQMessage; ICQMessage m2 = _icqMessages[i + 1] as ICQMessage; if (m1 != null && m2 != null && m1.From == m2.From && m1.To == m2.To && m1.Time == m2.Time && m1.Body == m2.Body) { _icqMessages.RemoveAt(i + 1); } else { ++i; } if (resourceAP.OutstandingJobs > 0) { resourceAP.DoJobs(); } } Trace.WriteLine(_icqMessages.Count + " new messages appeared", "ICQ.Plugin"); _lastPercentage = -1; _percentage = _contactIndex = _messageIndex = 0; }