public EvolutionMailIndexableGeneratorImap (EvolutionMailQueryable queryable, FileInfo summary_info) : base (queryable)
		{
			this.summary_info = summary_info;
		}
		protected EvolutionMailIndexableGenerator (EvolutionMailQueryable queryable)
		{
			this.queryable = queryable;
		}
Exemple #3
0
 private Uri CamelMessageUri(B_U_Camel.MessageInfo message_info)
 {
     return(EvolutionMailQueryable.EmailUri(this.account_name, this.folder_name, message_info.uid));
 }
		public EvolutionMailIndexableGeneratorMbox (EvolutionMailQueryable queryable, FileInfo mbox_info) : base (queryable)
		{
			this.mbox_info = mbox_info;
		}
Exemple #5
0
        public override Indexable GetNextIndexable()
        {
            Indexable indexable = null;

            // No more new messages to index, so start on the removals.
            if (this.delete_mode)
            {
                string uid = (string)this.deleted_list [0];
                Uri    uri = EvolutionMailQueryable.EmailUri(this.account_name, this.folder_name, uid);

                indexable = new Indexable(IndexableType.Remove, uri);

                this.deleted_list.RemoveAt(0);
                this.tracker.Remove(uid);

                this.delete_count++;

                return(indexable);
            }

            B_U_Camel.MessageInfo mi = (B_U_Camel.MessageInfo) this.summary_enumerator.Current;

            ++this.count;

            if (Debug)
            {
                Logger.Log.Debug("Constructed message {0} with uid {1}, flags {2}.",
                                 this.count, mi.uid, mi.flags);
            }

            uint flags;
            bool found = this.tracker.Get(mi.uid, out flags);

            if (!found)
            {
                // New, previously unseen message
                string msg_file;

                if (this.backend_type == ImapBackendType.Imap)
                {
                    msg_file = Path.Combine(summary_info.DirectoryName, mi.uid + ".");
                }
                else
                {
                    // This is taken from e-d-s's camel-data-cache.c.  No doubt
                    // NotZed would scream bloody murder if he saw this here.
                    int    hash       = (g_str_hash(mi.uid) >> 5) & CAMEL_DATA_CACHE_MASK;
                    string cache_path = String.Format("cache/{0:x}/{1}", hash, mi.uid);
                    msg_file = Path.Combine(summary_info.DirectoryName, cache_path);
                }

                indexable = this.CamelMessageToIndexable(mi, msg_file);

                if (Debug)
                {
                    Logger.Log.Debug("Unseen message, indexable {0} null", indexable == null ? "" : "not");
                }

                if (indexable != null)
                {
                    ++this.indexed_count;
                }
            }
            else if (found && flags != mi.flags)
            {
                // Previously seen message, but flags have changed.
                Uri uri = CamelMessageUri(mi);
                indexable      = new Indexable(uri);
                indexable.Type = IndexableType.PropertyChange;

                Property flag_prop = Property.NewUnsearched("fixme:flags", mi.flags);
                flag_prop.IsMutable = true;
                indexable.AddProperty(flag_prop);

                if (Debug)
                {
                    Logger.Log.Debug("Previously seen message, flags changed: {0} -> {1}", flags, mi.flags);
                }

                ++this.indexed_count;
            }
            else
            {
                if (Debug)
                {
                    Logger.Log.Debug("Previously seen message, unchanged.");
                }
            }

            this.tracker.Update(mi.uid, mi.flags);

            return(indexable);
        }
Exemple #6
0
 protected EvolutionMailIndexableGenerator(EvolutionMailQueryable queryable)
 {
     this.queryable = queryable;
 }
Exemple #7
0
 public EvolutionMailIndexableGeneratorImap(EvolutionMailQueryable queryable, FileInfo summary_info) : base(queryable)
 {
     this.summary_info = summary_info;
 }
Exemple #8
0
        private Indexable GMimeMessageToIndexable(string uid, GMime.Message message, uint flags)
        {
            // Don't index messages flagged as junk
            if (CheckFlags(flags, B_U_Camel.CamelFlags.Junk))
            {
                return(null);
            }

            System.Uri uri       = EvolutionMailQueryable.EmailUri(this.account_name, this.folder_name, uid);
            Indexable  indexable = new Indexable(uri);

            indexable.Timestamp    = message.Date.ToUniversalTime();
            indexable.HitType      = "MailMessage";
            indexable.MimeType     = "message/rfc822";
            indexable.CacheContent = true;

            indexable.AddProperty(Property.NewUnsearched("fixme:client", "evolution"));
            indexable.AddProperty(Property.NewUnsearched("fixme:account", "Local"));
            indexable.AddProperty(Property.NewUnsearched("fixme:folder", this.folder_name));

            GMime.InternetAddressList addrs;

            if (this.folder_name == "Sent")
            {
                addrs = message.GetRecipients(GMime.RecipientType.To);
                foreach (GMime.InternetAddress ia in addrs)
                {
                    if (ia is GMime.InternetAddressMailbox)
                    {
                        GMime.InternetAddressMailbox mailbox = ia as GMime.InternetAddressMailbox;

                        indexable.AddProperty(Property.NewUnsearched("fixme:sentTo", mailbox.Address));
                    }
                }

                addrs.Dispose();
            }

            if (this.folder_name == "Sent")
            {
                addrs = message.GetRecipients(GMime.RecipientType.Cc);
                foreach (GMime.InternetAddress ia in addrs)
                {
                    if (ia is GMime.InternetAddressMailbox)
                    {
                        GMime.InternetAddressMailbox mailbox = ia as GMime.InternetAddressMailbox;

                        indexable.AddProperty(Property.NewUnsearched("fixme:sentTo", mailbox.Address));
                    }
                }

                addrs.Dispose();
            }

            if (this.folder_name != "Sent")
            {
                addrs = GMime.InternetAddressList.Parse(message.Sender);
                foreach (GMime.InternetAddress ia in addrs)
                {
                    if (ia is GMime.InternetAddressMailbox)
                    {
                        GMime.InternetAddressMailbox mailbox = ia as GMime.InternetAddressMailbox;

                        indexable.AddProperty(Property.NewUnsearched("fixme:gotFrom", mailbox.Address));
                    }
                }

                addrs.Dispose();
            }

            if (this.folder_name == "Sent")
            {
                indexable.AddProperty(Property.NewFlag("fixme:isSent"));
            }

            Property flag_prop = Property.NewUnsearched("fixme:flags", flags);

            flag_prop.IsMutable = true;
            indexable.AddProperty(flag_prop);

            if (CheckFlags(flags, B_U_Camel.CamelFlags.Answered))
            {
                indexable.AddProperty(Property.NewFlag("fixme:isAnswered"));
            }

            if (CheckFlags(flags, B_U_Camel.CamelFlags.Deleted))
            {
                indexable.AddProperty(Property.NewFlag("fixme:isDeleted"));
            }

            if (CheckFlags(flags, B_U_Camel.CamelFlags.Draft))
            {
                indexable.AddProperty(Property.NewFlag("fixme:isDraft"));
            }

            if (CheckFlags(flags, B_U_Camel.CamelFlags.Flagged))
            {
                indexable.AddProperty(Property.NewFlag("fixme:isFlagged"));
            }

            if (CheckFlags(flags, B_U_Camel.CamelFlags.Seen))
            {
                indexable.AddProperty(Property.NewFlag("fixme:isSeen"));
            }

            if (CheckFlags(flags, B_U_Camel.CamelFlags.AnsweredAll))
            {
                indexable.AddProperty(Property.NewFlag("fixme:isAnsweredAll"));
            }

            indexable.SetBinaryStream(message.Stream);

            return(indexable);
        }
Exemple #9
0
 public EvolutionMailIndexableGeneratorMbox(EvolutionMailQueryable queryable, FileInfo mbox_info) : base(queryable)
 {
     this.mbox_info = mbox_info;
 }