~c-franke/do/XesamSearch

« back to all changes in this revision

Viewing changes to BeagleEmailAttachItem.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
// BeagleEmailAttachItem.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
        class BeagleEmailAttachItem: XesamItem, IOpenableItem {
 
12
                protected string atitle;
 
13
                protected string parentTitle;
 
14
                //protected string emblem;
 
15
                
 
16
                
 
17
                public BeagleEmailAttachItem (Dictionary<string,string> fields):base(fields)
 
18
                {       
 
19
                        
 
20
                        this.atitle= fields["beagle:attachment_title"];
 
21
                        this.parentTitle=fields["beagle:parent:title"];
 
22
                        //this.emblem=fields["emblem"];
 
23
                        
 
24
                }
 
25
                
 
26
                public override string Name {
 
27
                        get {
 
28
                                string name="";
 
29
                                if(base.exactfilename==""){
 
30
                                        name=this.atitle;
 
31
                                }else{
 
32
                                        name=base.exactfilename;
 
33
                                }
 
34
                                
 
35
                                if(name=="")
 
36
                                        name = base.title;
 
37
                                        
 
38
                                if(name=="")
 
39
                                        name = "unknown (? *.doc)";
 
40
                                return name;
 
41
                        }
 
42
                }
 
43
                
 
44
                public override string Description {
 
45
                        get {
 
46
                                
 
47
                                        return "Attachment on: "+parentTitle;
 
48
                                
 
49
                        }
 
50
                }
 
51
                
 
52
                public override string Icon {
 
53
                        get {
 
54
                                string icon; //TODO: get icon from beagle-search code isRead isAnswered
 
55
                                
 
56
                                icon = base.mimetype;
 
57
                                try {
 
58
                                        if (icon == "x-directory/normal") {
 
59
                                                icon = "folder";
 
60
                                        } else if (icon.StartsWith ("image")) {
 
61
                                                icon = "gnome-mime-image";
 
62
                                        } else {
 
63
                                                icon = icon.Replace ('/', '-');
 
64
                                                icon = string.Format ("gnome-mime-{0}", icon);
 
65
                                        }
 
66
                                } catch (NullReferenceException) {
 
67
                                        icon = "file";
 
68
                                }
 
69
                                return icon; 
 
70
                        }
 
71
                }
 
72
                
 
73
                
 
74
                
 
75
                
 
76
                public virtual string Path {
 
77
                        get {
 
78
                                return base.url;
 
79
                        }
 
80
                }
 
81
                
 
82
                public  string URI {
 
83
                        get {
 
84
                                return base.url;
 
85
                        }
 
86
                }
 
87
                
 
88
                public string MimeType {
 
89
                        get {
 
90
                                return base.mimetype;
 
91
                        }
 
92
                }
 
93
                
 
94
                /** open email via evolution **/
 
95
                public virtual void Open ()
 
96
                {
 
97
                        //Prozess.Start("evolution \""+URI+"\"");
 
98
                        System.Diagnostics.Process locate;
 
99
                        locate = new System.Diagnostics.Process ();
 
100
                        locate.StartInfo.FileName = "evolution";
 
101
                        locate.StartInfo.Arguments = base.url ;
 
102
                        locate.StartInfo.RedirectStandardOutput = false;
 
103
                        locate.StartInfo.UseShellExecute = false;
 
104
                        locate.Start();
 
105
                }
 
106
        }
 
107
        
 
108
}