/**
         * Advance to the next mail in the mbox file.
         */
        public bool HasNextIndexable()
        {
            if (mbox_fd < 0)
            {
                Logger.Log.Debug("Opening mbox {0}", mbox_file);

                try {
                    KMailQueryable.InitializeGMime();
                } catch (Exception e) {
                    Logger.Log.Warn(e, "Caught exception trying to initalize gmime:");
                    return(false);
                }


                try {
                    mbox_fd = Mono.Unix.Native.Syscall.open(mbox_file, Mono.Unix.Native.OpenFlags.O_RDONLY);
                } catch (System.IO.FileNotFoundException e) {
                    Logger.Log.Warn("mbox " + mbox_file + " deleted while indexing.");
                    return(false);
                }
                mbox_stream = new GMime.StreamFs(mbox_fd);
                if (initial_scan && !IsUpToDate(mbox_file))
                {
                    // this is the initial scan and
                    // file has changed since last scan =>
                    // set mboxlastoffset to 0 and seek to 0
                    mbox_stream.Seek((int)(MboxLastOffset = 0));
                }
                else
                {
                    mbox_stream.Seek((int)MboxLastOffset);
                }
                mbox_parser          = new GMime.Parser(mbox_stream);
                mbox_parser.ScanFrom = true;
            }

            if (mbox_parser.Eos())
            {
                // save the state ASAP
                Checkpoint();

                mbox_stream.Close();
                mbox_fd = -1;
                mbox_stream.Dispose();
                mbox_stream = null;
                mbox_parser.Dispose();
                mbox_parser = null;

                Logger.Log.Debug("{0}: Finished indexing {1} messages", folder_name, indexed_count);
                return(false);
            }
            else
            {
                return(true);
            }
        }
		private string lastGoodDirPath = ""; // cache last successful directory

		public KMailIndexer (KMailQueryable queryable, string account, string root)
		{
			this.queryable = queryable;
			account_name = account;
			mail_root = root;
			mail_directories = new ArrayList ();
			folder_directories = new ArrayList ();
			mbox_files = new ArrayList ();

			excludes = new ArrayList ();
			List<string[]> values = Conf.Daemon.GetListOptionValues (Conf.Names.ExcludeMailfolder);
			if (values == null)
				return;

			foreach (string[] item in values)
				excludes.Add (item [0].ToLower ());
		}
        private string lastGoodDirPath = "";         // cache last successful directory

        public KMailIndexer(KMailQueryable queryable, string account, string root)
        {
            this.queryable     = queryable;
            account_name       = account;
            mail_root          = root;
            mail_directories   = new ArrayList();
            folder_directories = new ArrayList();
            mbox_files         = new ArrayList();

            excludes = new ArrayList();
            List <string[]> values = Conf.Daemon.GetListOptionValues(Conf.Names.ExcludeMailfolder);

            if (values == null)
            {
                return;
            }

            foreach (string[] item in values)
            {
                excludes.Add(item [0].ToLower());
            }
        }