private void ProcessICQMessage(ICQMessage message) { ICQContact From = message.From; ICQContact To = message.To; if (!From.IsIgnored() && !To.IsIgnored()) { // searching for the "From" contact IResource fromAccount = Core.ResourceStore.FindUniqueResource(_icqAccountResName, _propUIN, From.UIN) ?? NewICQAccount(From); // searching for the "To" contact IResource toAccount = Core.ResourceStore.FindUniqueResource(_icqAccountResName, _propUIN, To.UIN) ?? NewICQAccount(To); // update or create conversation and request its indexing if updated IResource convs = _conversationManager.Update(message.Body, message.Time, fromAccount, toAccount); if (convs != null) { _idResources.Add(convs.Id); } if (_lastPercentage < _percentage) { if (Core.ProgressWindow != null) { Core.ProgressWindow.UpdateProgress(_percentage, "Building ICQ conversations", null); } Core.UIManager.GetStatusWriter(this, StatusPane.UI).ShowStatus( "Building ICQ conversations (" + _percentage + "%)"); _lastPercentage = _percentage; } } }
public int Compare(object x, object y) { ICQMessage mx = (ICQMessage)x; ICQMessage my = (ICQMessage)y; if (mx.Time < my.Time) { return(-1); } if (mx.Time > my.Time) { return(1); } return(0); }
public override bool Equals(object aMessage) { ICQMessage right = aMessage as ICQMessage; if (right == null) { return(false); } ICQContact From = this.From; ICQContact To = this.To; ICQContact rFrom = right.From; ICQContact rTo = right.To; if (From == null || To == null || rFrom == null || rTo == null) { return(false); } return(From.Equals(rFrom) && To.Equals(rTo) && Time == right.Time && Body == right.Body); }
public override AbstractJob GetNextJob() { if (_contactIndex < _icqContacts.Count) { ICQContact contact = (ICQContact)_icqContacts[_contactIndex++]; return(new DelegateJob( "Processing ICQ contact [" + contact.UIN + ']', new ProcessICQAccountDelegate(ProcessICQAccount), new object[] { contact })); } while (_messageIndex < _icqMessages.Count) { if (_startedInIdleMode && !Core.IsSystemIdle) { Interrupted = true; Core.ResourceAP.QueueIdleJob(this); break; } ICQMessage message = (ICQMessage)_icqMessages[_messageIndex++]; DateTime msgDateTime = message.Time; if (msgDateTime <= DateTime.Now) { _percentage = _messageIndex * 100 / _icqMessages.Count; if (_minUpdateDate > msgDateTime) { _minUpdateDate = msgDateTime; } else if (_maxUpdateDate < msgDateTime) { _maxUpdateDate = msgDateTime; } _percentage = _messageIndex * 100 / _icqMessages.Count; return(new DelegateJob("Processing ICQ message from " + message.From.UIN, new ProcessICQMessageDelegate(ProcessICQMessage), new object[] { message })); } } return(null); }
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; }