コード例 #1
0
        /**
         * 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);
            }
        }
コード例 #2
0
        void DropEmailUriList(Gtk.DragDataReceivedArgs args)
        {
            string uri_string = Encoding.UTF8.GetString(args.SelectionData.Data);

            subject_list = new List <string>();

            UriList uri_list = new UriList(uri_string);

            foreach (Uri uri in uri_list)
            {
                Logger.Debug("Evolution: Dropped URI: {0}", uri.LocalPath);

                int mail_fd = Syscall.open(uri.LocalPath, OpenFlags.O_RDONLY);
                if (mail_fd == -1)
                {
                    continue;
                }

                GMime.Stream stream = new GMime.StreamFs(mail_fd);
                GMime.Parser parser = new GMime.Parser(stream);
                parser.ScanFrom = true;

                // Use GMime to read the RFC822 message bodies (in temp
                // files pointed to by a uri-list) in MBOX format, so we
                // can get subject/sender/date info.
                while (!parser.Eos())
                {
                    GMime.Message message = parser.ConstructMessage();
                    if (message == null)
                    {
                        break;
                    }

                    Logger.Debug("Evolution: Message Subject: {0}", message.Subject);
                    subject_list.Add(message.Subject);
                    message.Dispose();
                }
                ;

                parser.Dispose();
                stream.Close();
                stream.Dispose();
            }
        }
コード例 #3
0
        void HandleDrop(int xx, int yy, bool first, Uri uri, string cm_path_folderitem, string msgid)
        {
            // get subject
            string subject = "<unknown>";
            int    mail_fd = Syscall.open(uri.LocalPath, OpenFlags.O_RDONLY);

            if (mail_fd != -1)
            {
                GMime.Stream stream = new GMime.StreamFs(mail_fd);
                GMime.Parser parser = new GMime.Parser(stream);

                parser.ScanFrom = false;
                while (!parser.Eos())
                {
                    GMime.Message message = parser.ConstructMessage();
                    if (message == null)
                    {
                        break;
                    }
                    subject = message.Subject;
                    message.Dispose();
                }
                parser.Dispose();
                stream.Close();
                stream.Dispose();
            }

            // Place the cursor in the position where the uri was
            // dropped, adjusting x,y by the TextView's VisibleRect.
            Gdk.Rectangle rect = Window.Editor.VisibleRect;
            xx += rect.X;
            yy += rect.Y;
            Gtk.TextIter cursor = Window.Editor.GetIterAtLocation(xx, yy);
            Buffer.PlaceCursor(cursor);

            int start_offset;

            if (!first)
            {
                cursor = Buffer.GetIterAtMark(Buffer.InsertMark);

                if (cursor.LineOffset == 0)
                {
                    Buffer.Insert(ref cursor, "\n");
                }
                else
                {
                    Buffer.Insert(ref cursor, ", ");
                }
            }

            EmailLink link_tag;

            link_tag          = (EmailLink)Note.TagTable.CreateDynamicTag("link:cm-mail");
            link_tag.EmailUri = cm_path_folderitem + "/<" + msgid + ">";

            cursor       = Buffer.GetIterAtMark(Buffer.InsertMark);
            start_offset = cursor.Offset;
            Buffer.Insert(ref cursor, subject);
            Gtk.TextIter start = Buffer.GetIterAtOffset(start_offset);
            Gtk.TextIter end   = Buffer.GetIterAtMark(Buffer.InsertMark);
            Buffer.ApplyTag(link_tag, start, end);
        }
コード例 #4
0
        void HandleDrop(int xx, int yy, bool first, Uri uri, string cm_path_folderitem, string msgid)
        {
            // get subject
            string subject = "<unknown>";
            int mail_fd = Syscall.open(uri.LocalPath, OpenFlags.O_RDONLY);
            if(mail_fd != -1) {
                GMime.Stream stream = new GMime.StreamFs(mail_fd);
                GMime.Parser parser = new GMime.Parser(stream);

                parser.ScanFrom = false;
                while(!parser.Eos()) {
                    GMime.Message message = parser.ConstructMessage();
                    if(message == null)
                        break;
                    subject = message.Subject;
                    message.Dispose();
                }
                parser.Dispose();
                stream.Close();
                stream.Dispose();
            }

            // Place the cursor in the position where the uri was
            // dropped, adjusting x,y by the TextView's VisibleRect.
            Gdk.Rectangle rect = Window.Editor.VisibleRect;
            xx += rect.X;
            yy += rect.Y;
            Gtk.TextIter cursor = Window.Editor.GetIterAtLocation(xx, yy);
            Buffer.PlaceCursor(cursor);

            int start_offset;

            if(!first) {
                cursor = Buffer.GetIterAtMark(Buffer.InsertMark);

                if(cursor.LineOffset == 0)
                    Buffer.Insert(ref cursor, "\n");
                else
                    Buffer.Insert(ref cursor, ", ");
            }

            EmailLink link_tag;
            link_tag = (EmailLink) Note.TagTable.CreateDynamicTag("link:cm-mail");
            link_tag.EmailUri = cm_path_folderitem + "/<" + msgid + ">";

            cursor = Buffer.GetIterAtMark(Buffer.InsertMark);
            start_offset = cursor.Offset;
            Buffer.Insert(ref cursor, subject);
            Gtk.TextIter start = Buffer.GetIterAtOffset(start_offset);
            Gtk.TextIter end = Buffer.GetIterAtMark(Buffer.InsertMark);
            Buffer.ApplyTag(link_tag, start, end);
        }
コード例 #5
0
		void DropEmailUriList (Gtk.DragDataReceivedArgs args)
		{
			string uri_string = Encoding.UTF8.GetString (args.SelectionData.Data);

			subject_list = new List<string>();

			UriList uri_list = new UriList (uri_string);
			foreach (Uri uri in uri_list) {
				Logger.Debug ("Evolution: Dropped URI: {0}", uri.LocalPath);

				int mail_fd = Syscall.open (uri.LocalPath, OpenFlags.O_RDONLY);
				if (mail_fd == -1)
					continue;

				GMime.Stream stream = new GMime.StreamFs (mail_fd);
				GMime.Parser parser = new GMime.Parser (stream);
				parser.ScanFrom = true;

				// Use GMime to read the RFC822 message bodies (in temp
				// files pointed to by a uri-list) in MBOX format, so we
				// can get subject/sender/date info.
				while (!parser.Eos()) {
					GMime.Message message = parser.ConstructMessage ();
					if (message == null)
						break;
					
					Logger.Debug ("Evolution: Message Subject: {0}", message.Subject);
					subject_list.Add (message.Subject);
					message.Dispose ();
				};

				parser.Dispose ();
				stream.Close ();
				stream.Dispose ();
			}
		}