~c-franke/do/XesamSearch

« back to all changes in this revision

Viewing changes to DoXesamSearchAction.cs

  • Committer: Christof Franke
  • Date: 2008-02-26 10:55:05 UTC
  • Revision ID: kraut@workstation-20080226105505-8am13vug28ok1wsf
version 0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// DoXesamSearchAction.cs 
 
2
// User: kraut (c.franke@muenchen-mail.de) at 22:23¬†21.02.2008
 
3
 
 
4
 
 
5
using System;
 
6
using System.Collections.Generic;
 
7
using Do.Universe;
 
8
 
 
9
namespace Do.Addins.DoXesam
 
10
{
 
11
        public class DoXesamSearchAction: AbstractAction
 
12
        {
 
13
                public DoXesamSearchAction()
 
14
                {
 
15
                }
 
16
                
 
17
                public  override string Name
 
18
                {
 
19
                        get { return "XSearch"; }
 
20
                }
 
21
                
 
22
                public  override string Description
 
23
                {
 
24
                        get { return "Searching with Beagle / Tracker / Strigi / Pinot "; }
 
25
                } 
 
26
                
 
27
                public  override string Icon
 
28
                {
 
29
                        get { return "system-search"; }
 
30
                }
 
31
                
 
32
                public override Type[] SupportedItemTypes
 
33
                {
 
34
                        get {
 
35
                                return new Type[] {
 
36
                                        typeof (ITextItem)
 
37
                                };
 
38
                        }
 
39
                }
 
40
                
 
41
                public override IItem[] Perform (IItem[] items, IItem[] modifierItems)
 
42
                {
 
43
                        IItem item = items[0];
 
44
                                //To Group by ResultType
 
45
                                List<IItem> files = new List<IItem>();
 
46
                                List<IItem> attachment = new List<IItem>();
 
47
                                List<IItem> email = new List<IItem>();
 
48
                                List<IItem> imMsg = new List<IItem>();
 
49
                        
 
50
                                string searchstr = (item as ITextItem).Text;
 
51
                                List<Dictionary<string,string>> result=DoXesamDriver.GetSearchResults(searchstr,1000);
 
52
                                
 
53
                                
 
54
                                foreach(Dictionary<string,string> ss in result)
 
55
                                {       
 
56
                                        if((ss["xesam:url"]).StartsWith("file://")& ss["beagle:protocol"]=="")
 
57
                                        {       
 
58
                                                files.Add(new FileItem(""+ss["xesam:url"]));
 
59
                                        
 
60
                                        }
 
61
                                        if(DoXesamDriver.BInterface)
 
62
                                                {
 
63
                                                        if((ss["xesam:url"]).StartsWith("email://")&ss["beagle:hasAttachments"]=="true")
 
64
                                                        {
 
65
                                                                attachment.Add(new BeagleEmailAttachItem(ss));
 
66
                                        
 
67
                                                        }
 
68
                                                        if((ss["xesam:url"]).StartsWith("email://")&(ss["beagle:hasAttachments"]!="true"))
 
69
                                                        {       //Emails without Name and Description would be excluded!
 
70
                                                        BeagleEmailItem mail=new BeagleEmailItem(ss);
 
71
                                                        if((mail.Name.Trim() !="" | mail.Description.Trim()!=""))
 
72
                                                                        email.Add(mail);                                
 
73
                                                        }else if((ss["beagle:protocol"])!=""){
 
74
                                                                imMsg.Add(new BeaglePidginItem(ss));
 
75
                                                        }
 
76
                                        }else{
 
77
                                                if(ss["xesam:url"].StartsWith("email://")){
 
78
                                                        email.Add(new XesamEmailItem(ss));
 
79
                                                }
 
80
                                        }                       
 
81
                                }       
 
82
                                //Add result groups
 
83
                                files.AddRange(attachment);
 
84
                                files.AddRange(email);
 
85
                                files.AddRange(imMsg);
 
86
                                return files.ToArray();         
 
87
                }
 
88
        }
 
89
}
 
 
b'\\ No newline at end of file'