~c-franke/do/XesamSearch

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// DoXesamSearchAction.cs 
// User: kraut (c.franke@muenchen-mail.de) at 22:23 21.02.2008


using System;
using System.Collections.Generic;
using Do.Universe;

namespace Do.Addins.DoXesam
{
	public class DoXesamSearchAction: AbstractAction
	{
		public DoXesamSearchAction()
		{
		}
		
		public  override string Name
		{
			get { return "XSearch"; }
		}
		
		public  override string Description
		{
			get { return "Searching with Beagle / Tracker / Strigi / Pinot "; }
		} 
		
		public  override string Icon
		{
			get { return "system-search"; }
		}
		
		public override Type[] SupportedItemTypes
		{
			get {
				return new Type[] {
					typeof (ITextItem)
				};
			}
		}
		
		public override IItem[] Perform (IItem[] items, IItem[] modifierItems)
		{
			IItem item = items[0];
				//To Group by ResultType
				List<IItem> files = new List<IItem>();
				List<IItem> attachment = new List<IItem>();
				List<IItem> email = new List<IItem>();
				List<IItem> imMsg = new List<IItem>();
			
				string searchstr = (item as ITextItem).Text;
				List<Dictionary<string,string>> result=DoXesamDriver.GetSearchResults(searchstr,1000);
				
				
				foreach(Dictionary<string,string> ss in result)
				{	
					if((ss["xesam:url"]).StartsWith("file://")& ss["beagle:protocol"]=="")
					{	
						files.Add(new FileItem(""+ss["xesam:url"]));
					
					}
					if(DoXesamDriver.BInterface)
						{
							if((ss["xesam:url"]).StartsWith("email://")&ss["beagle:hasAttachments"]=="true")
							{
								attachment.Add(new BeagleEmailAttachItem(ss));
					
							}
				  		 	if((ss["xesam:url"]).StartsWith("email://")&(ss["beagle:hasAttachments"]!="true"))
				  		 	{	//Emails without Name and Description would be excluded!
						        BeagleEmailItem mail=new BeagleEmailItem(ss);
						        if((mail.Name.Trim() !="" | mail.Description.Trim()!=""))
									email.Add(mail);				
  							}else if((ss["beagle:protocol"])!=""){
								imMsg.Add(new BeaglePidginItem(ss));
							}
					}else{
						if(ss["xesam:url"].StartsWith("email://")){
							email.Add(new XesamEmailItem(ss));
						}
					}			
				}	
				//Add result groups
				files.AddRange(attachment);
				files.AddRange(email);
				files.AddRange(imMsg);
				return files.ToArray();		
		}
	}
}