~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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// BeagleEmailAttachItem.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
{
	class BeagleEmailAttachItem: XesamItem, IOpenableItem {
		protected string atitle;
		protected string parentTitle;
		//protected string emblem;
		
		
		public BeagleEmailAttachItem (Dictionary<string,string> fields):base(fields)
		{	
			
			this.atitle= fields["beagle:attachment_title"];
			this.parentTitle=fields["beagle:parent:title"];
			//this.emblem=fields["emblem"];
			
		}
		
		public override string Name {
			get {
				string name="";
				if(base.exactfilename==""){
					name=this.atitle;
				}else{
					name=base.exactfilename;
				}
				
				if(name=="")
					name = base.title;
					
				if(name=="")
					name = "unknown (? *.doc)";
				return name;
			}
		}
		
		public override string Description {
			get {
				
					return "Attachment on: "+parentTitle;
				
			}
		}
		
		public override string Icon {
			get {
				string icon; //TODO: get icon from beagle-search code isRead isAnswered
				
				icon = base.mimetype;
				try {
					if (icon == "x-directory/normal") {
						icon = "folder";
					} else if (icon.StartsWith ("image")) {
						icon = "gnome-mime-image";
					} else {
						icon = icon.Replace ('/', '-');
						icon = string.Format ("gnome-mime-{0}", icon);
					}
				} catch (NullReferenceException) {
					icon = "file";
				}
				return icon; 
			}
		}
		
		
		
		
		public virtual string Path {
			get {
				return base.url;
			}
		}
		
		public  string URI {
			get {
				return base.url;
			}
		}
		
		public string MimeType {
			get {
				return base.mimetype;
			}
		}
		
		/** open email via evolution **/
		public virtual void Open ()
		{
			//Prozess.Start("evolution \""+URI+"\"");
			System.Diagnostics.Process locate;
			locate = new System.Diagnostics.Process ();
			locate.StartInfo.FileName = "evolution";
			locate.StartInfo.Arguments = base.url ;
			locate.StartInfo.RedirectStandardOutput = false;
			locate.StartInfo.UseShellExecute = false;
			locate.Start();
		}
	}
	
}