Ejemplo n.º 1
0
        /////////////////////////////////////////////////

        protected override bool HitFilter(Hit hit)
        {
            string speakingto = hit ["fixme:speakingto"];

            // We have no idea who we're speaking to.  Bad, but we
            // still want to present it.
            if (String.IsNullOrEmpty(speakingto))
            {
                return(true);
            }

            ImBuddy buddy = list.Search(speakingto);

            // We might still want to see a chat even if someone's
            // not on our buddy list.
            if (buddy == null)
            {
                return(true);
            }

            if (!String.IsNullOrEmpty(buddy.Alias))
            {
                hit.AddProperty(Property.NewKeyword("fixme:speakingto_alias", buddy.Alias));
            }

            if (!String.IsNullOrEmpty(buddy.BuddyIconLocation))
            {
                hit.AddProperty(Property.NewUnsearched("fixme:speakingto_icon", buddy.BuddyIconLocation));
            }

            return(true);
        }
Ejemplo n.º 2
0
        private bool HitIsValidRemovable(Hit hit)
        {
            if (mount_dir == null || hit.Uri.Scheme != "removable")
            {
                return(true);
            }

            hit.AddProperty(Beagrep.Property.NewKeyword("beagrep:RemovableUri",
                                                        hit.EscapedUri));

            string path = hit.Uri.LocalPath;

            path    = path.Substring(1);           // Remove initial '/'
            path    = Path.Combine(mount_dir, path);
            hit.Uri = UriFu.PathToFileUri(path);

            hit.AddProperty(Beagrep.Property.NewKeyword("fixme:mount_dir", mount_dir));

            return(true);
        }
Ejemplo n.º 3
0
        //////////////////////////////////////////////////
        // Convert matches to Hits

        private Hit PathToHit(string path)
        {
            // Check if hidden
            if (path.IndexOf("/.") != -1)
            {
                return(null);
            }

            Hit hit = new Hit();

            hit.Uri       = UriFu.PathToFileUri(path);
            hit.Timestamp = File.GetLastWriteTimeUtc(path);
            hit.AddProperty(Property.NewUnsearched("beagle:HitType", "File"));
            // Prevent any mimetype matching
            hit.AddProperty(Property.NewUnsearched("beagle:MimeType", "beagle/x-locate-result"));
            hit.AddProperty(Property.NewUnsearched("beagle:Source", "Locate"));
            // Use a generic enough filetype to hint there is _no_ special properties
            // for this hit
            hit.AddProperty(Property.NewUnsearched("beagle:FileType", "document"));
            hit.Score = 1.0;

            foreach (Property std_prop in Property.StandardFileProperties(Path.GetFileName(path), true))
            {
                hit.AddProperty(std_prop);
            }

            hit.AddProperty(Property.NewUnsearched(
                                Property.ParentDirUriPropKey,
                                UriFu.PathToFileUri(Path.GetDirectoryName(path))));

            return(hit);
        }
Ejemplo n.º 4
0
		//////////////////////////////////////////////////
		// Convert matches to Hits

		private Hit PathToHit (string path)
		{
			// Check if hidden
			if (path.IndexOf ("/.") != -1)
				return null;

			Hit hit = new Hit ();
			hit.Uri = UriFu.PathToFileUri (path);
			hit.Timestamp = File.GetLastWriteTimeUtc (path);
                        hit.AddProperty (Property.NewUnsearched ("beagle:HitType", "File"));
			// Prevent any mimetype matching
                        hit.AddProperty (Property.NewUnsearched ("beagle:MimeType", "beagle/x-locate-result"));
                        hit.AddProperty (Property.NewUnsearched ("beagle:Source", "Locate"));
			// Use a generic enough filetype to hint there is _no_ special properties
			// for this hit
                        hit.AddProperty (Property.NewUnsearched ("beagle:FileType", "document"));
			hit.Score = 1.0;

			foreach (Property std_prop in Property.StandardFileProperties (Path.GetFileName (path), true))
				hit.AddProperty (std_prop);

			hit.AddProperty (Property.NewUnsearched (
					 Property.ParentDirUriPropKey,
					 UriFu.PathToFileUri (Path.GetDirectoryName (path))));

			return hit;
		}
Ejemplo n.º 5
0
		private bool HitIsValidRemovable (Hit hit)
		{
			if (mount_dir == null || hit.Uri.Scheme != "removable")
				return true;

			hit.AddProperty (Beagle.Property.NewKeyword ("beagle:RemovableUri",
								     hit.EscapedUri));

			string path = hit.Uri.LocalPath;
			path = path.Substring (1); // Remove initial '/'
			path = Path.Combine (mount_dir, path);
			hit.Uri = UriFu.PathToFileUri (path);

			hit.AddProperty (Beagle.Property.NewKeyword ("fixme:mount_dir", mount_dir));

			return true;
		}
Ejemplo n.º 6
0
		/////////////////////////////////////////////////

		protected override bool HitFilter (Hit hit) 
		{
			string speakingto = hit ["fixme:speakingto"];

			// We have no idea who we're speaking to.  Bad, but we
			// still want to present it.
			if (String.IsNullOrEmpty (speakingto))
				return true;

			ImBuddy buddy = list.Search (speakingto);
			
			// We might still want to see a chat even if someone's
			// not on our buddy list.
			if (buddy == null) 
				return true;
			
			if (! String.IsNullOrEmpty (buddy.Alias))
 				hit.AddProperty (Property.NewKeyword ("fixme:speakingto_alias", buddy.Alias));
			
 			if (! String.IsNullOrEmpty (buddy.BuddyIconLocation))
 				hit.AddProperty (Property.NewUnsearched ("fixme:speakingto_icon", buddy.BuddyIconLocation));
			
			return true;
		}
Ejemplo n.º 7
0
		// Copied from FilterMail.cs:DoPullProperties
		private Hit MessageToHit (GMime.Message message)
		{
			string msgid = message.GetHeader ("Message-Id");
			if (msgid == null)
				return null;

			msgid = GMime.Utils.DecodeMessageId (msgid);
			Hit hit = new Hit ();
			hit.Uri = new Uri (String.Format (GMAIL_HIT_URL, domain, msgid));
                        hit.AddProperty (Property.NewUnsearched ("beagle:HitType", "MailMessage"));
                        hit.AddProperty (Property.NewUnsearched ("beagle:MimeType", "text/html"));
                        hit.AddProperty (Property.NewUnsearched ("beagle:Source", "GMailSearch"));
			hit.Score = 1.0;

			hit.AddProperty (Property.NewUnsearched ("fixme:msgid", msgid));

			string subject = GMime.Utils.HeaderDecodePhrase (message.Subject);
			hit.AddProperty (Property.New ("dc:title", subject));
			hit.Timestamp = message.Date.ToUniversalTime ();
			hit.AddProperty (Property.NewDate ("fixme:date", message.Date.ToUniversalTime ()));

			GMime.InternetAddressList addrs;
			addrs = message.GetRecipients (GMime.RecipientType.To);
			foreach (GMime.InternetAddress ia in addrs) {
				hit.AddProperty (Property.NewUnsearched ("fixme:to", ia.ToString (false)));
				if (ia is GMime.InternetAddressMailbox) {
					GMime.InternetAddressMailbox mailbox = ia as GMime.InternetAddressMailbox;
					
					hit.AddProperty (Property.New ("fixme:to_address", mailbox.Address));
				}
				
				hit.AddProperty (Property.New ("fixme:to_name", ia.Name));
			}
			addrs.Dispose ();

			addrs = message.GetRecipients (GMime.RecipientType.Cc);
			foreach (GMime.InternetAddress ia in addrs) {
				hit.AddProperty (Property.NewUnsearched ("fixme:cc", ia.ToString (false)));
				if (ia is GMime.InternetAddressMailbox) {
					GMime.InternetAddressMailbox mailbox = ia as GMime.InternetAddressMailbox;
					
					hit.AddProperty (Property.New ("fixme:cc_address", mailbox.Address));
				}
				
				hit.AddProperty (Property.New ("fixme:cc_name", ia.Name));
			}
			addrs.Dispose ();

			addrs = GMime.InternetAddressList.Parse (message.Sender);
			foreach (GMime.InternetAddress ia in addrs) {
				hit.AddProperty (Property.NewUnsearched ("fixme:from", ia.ToString (false)));
				if (ia is GMime.InternetAddressMailbox) {
					GMime.InternetAddressMailbox mailbox = ia as GMime.InternetAddressMailbox;
					
					hit.AddProperty (Property.New ("fixme:from_address", mailbox.Address));
				}
				
				hit.AddProperty (Property.New ("fixme:from_name", ia.Name));
			}
			addrs.Dispose ();

			foreach (GMime.References refs in message.References)
				hit.AddProperty (Property.NewUnsearched ("fixme:reference", refs.MessageId));

			string list_id = message.GetHeader ("List-Id");
			if (list_id != null)
				hit.AddProperty (Property.New ("fixme:mlist", GMime.Utils.HeaderDecodePhrase (list_id)));

			return hit;
		}
Ejemplo n.º 8
0
		private bool RemapUri (Hit hit)
		{
			// Store the hit's internal uri in a property
			Property prop;
			prop = Property.NewUnsearched ("beagle:InternalUri",
						       UriFu.UriToEscapedString (hit.Uri));
			hit.AddProperty (prop);

			// Now assemble the path by looking at the parent and name
			string name = null, path, is_child;
			is_child = hit [Property.IsChildPropKey];

			if (is_child == "true")
				name = hit ["parent:" + Property.ExactFilenamePropKey];
			else
				name = hit [Property.ExactFilenamePropKey];

			if (name == null) {
				// If we don't have the filename property, we have to do a lookup
				// based on the guid.  This happens with synthetic hits produced by
				// index listeners.
				Guid hit_id;
				hit_id = GuidFu.FromUri (hit.Uri);
				path = UniqueIdToFullPath (hit_id);
			} else if (hit [Property.IsDirectoryPropKey] == "true") {
				// For directories, it is better to get the path directly from directory model
				Guid hit_id;
				hit_id = GuidFu.FromUri (hit.Uri);
				path = UniqueIdToDirectoryName (hit_id);
			} else {
				string parent_id_uri;
				parent_id_uri = hit [Property.ParentDirUriPropKey];
				if (parent_id_uri == null)
					parent_id_uri = hit ["parent:" + Property.ParentDirUriPropKey];

				Guid parent_id = Guid.Empty;
				if (parent_id_uri != null)
					parent_id = GuidFu.FromUriString (parent_id_uri);
			
				path = ToFullPath (name, parent_id);
				if (path == null)
					Logger.Log.Debug ("Couldn't find path of file with name '{0}' and parent '{1}'",
							  name, GuidFu.ToShortString (parent_id));
			}

			if (Debug)
				Log.Debug ("Resolved {0} to {1}", hit.Uri, path);

			if (path != null) {
				hit.Uri = UriFu.PathToFileUri (path);
				return true;
			}

			return false;
		}
Ejemplo n.º 9
0
        // Copied from FilterMail.cs:DoPullProperties
        private Hit MessageToHit(GMime.Message message)
        {
            string msgid = message.GetHeader("Message-Id");

            if (msgid == null)
            {
                return(null);
            }

            msgid = GMime.Utils.DecodeMessageId(msgid);
            Hit hit = new Hit();

            hit.Uri = new Uri(String.Format(GMAIL_HIT_URL, domain, msgid));
            hit.AddProperty(Property.NewUnsearched("beagle:HitType", "MailMessage"));
            hit.AddProperty(Property.NewUnsearched("beagle:MimeType", "text/html"));
            hit.AddProperty(Property.NewUnsearched("beagle:Source", "GMailSearch"));
            hit.Score = 1.0;

            hit.AddProperty(Property.NewUnsearched("fixme:msgid", msgid));

            string subject = GMime.Utils.HeaderDecodePhrase(message.Subject);

            hit.AddProperty(Property.New("dc:title", subject));
            hit.Timestamp = message.Date.ToUniversalTime();
            hit.AddProperty(Property.NewDate("fixme:date", message.Date.ToUniversalTime()));

            GMime.InternetAddressList addrs;
            addrs = message.GetRecipients(GMime.RecipientType.To);
            foreach (GMime.InternetAddress ia in addrs)
            {
                hit.AddProperty(Property.NewUnsearched("fixme:to", ia.ToString(false)));
                if (ia is GMime.InternetAddressMailbox)
                {
                    GMime.InternetAddressMailbox mailbox = ia as GMime.InternetAddressMailbox;

                    hit.AddProperty(Property.New("fixme:to_address", mailbox.Address));
                }

                hit.AddProperty(Property.New("fixme:to_name", ia.Name));
            }
            addrs.Dispose();

            addrs = message.GetRecipients(GMime.RecipientType.Cc);
            foreach (GMime.InternetAddress ia in addrs)
            {
                hit.AddProperty(Property.NewUnsearched("fixme:cc", ia.ToString(false)));
                if (ia is GMime.InternetAddressMailbox)
                {
                    GMime.InternetAddressMailbox mailbox = ia as GMime.InternetAddressMailbox;

                    hit.AddProperty(Property.New("fixme:cc_address", mailbox.Address));
                }

                hit.AddProperty(Property.New("fixme:cc_name", ia.Name));
            }
            addrs.Dispose();

            addrs = GMime.InternetAddressList.Parse(message.Sender);
            foreach (GMime.InternetAddress ia in addrs)
            {
                hit.AddProperty(Property.NewUnsearched("fixme:from", ia.ToString(false)));
                if (ia is GMime.InternetAddressMailbox)
                {
                    GMime.InternetAddressMailbox mailbox = ia as GMime.InternetAddressMailbox;

                    hit.AddProperty(Property.New("fixme:from_address", mailbox.Address));
                }

                hit.AddProperty(Property.New("fixme:from_name", ia.Name));
            }
            addrs.Dispose();

            foreach (GMime.References refs in message.References)
            {
                hit.AddProperty(Property.NewUnsearched("fixme:reference", refs.MessageId));
            }

            string list_id = message.GetHeader("List-Id");

            if (list_id != null)
            {
                hit.AddProperty(Property.New("fixme:mlist", GMime.Utils.HeaderDecodePhrase(list_id)));
            }

            return(hit);
        }