~cszikszoy/do-plugins/pastebin

« back to all changes in this revision

Viewing changes to DiskMounter/MountedDriveItem.cs

  • Committer: Alex Launi
  • Date: 2008-05-24 22:51:36 UTC
  • mfrom: (39.7.7 plugins-devel)
  • mto: This revision was merged to the branch mainline in revision 98.
  • Revision ID: alex@eriktorvaldsonn-20080524225136-ni1424yaozte846m
merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// MountedDriveItem.cs
 
2
//
 
3
// This program is free software; you can redistribute it and/or modify
 
4
// it under the terms of the GNU General Public License as published by
 
5
// the Free Software Foundation; either version 3 of the License, or
 
6
// (at your option) any later version.
 
7
//
 
8
// This program is distributed in the hope that it will be useful,
 
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
11
// GNU General Public License for more details.
 
12
// 
 
13
// You should have received a copy of the GNU General Public License
 
14
// along with this program; if not, see <http://www.gnu.org/licenses/> or 
 
15
// write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
 
16
// Boston, MA 02111-1307 USA
 
17
//
 
18
 
 
19
using System;
 
20
using Do.Universe;
 
21
 
 
22
using Gnome.Vfs;
 
23
 
 
24
namespace Mount
 
25
{
 
26
        public class MountedDriveItem : IItem
 
27
        {
 
28
 
 
29
                private Drive drive;
 
30
                
 
31
                public MountedDriveItem (Drive drive){
 
32
                        if (drive.IsMounted)
 
33
                                this.drive = drive;
 
34
                }
 
35
                
 
36
                public string Path {
 
37
                       get { return drive.ActivationUri.ToString(); }
 
38
                }
 
39
                
 
40
                public void Unmount ()
 
41
                {
 
42
                        try {
 
43
                                drive.Unmount (VolumeOpCallback);
 
44
                        } catch
 
45
                        {    // error message will be handled by VolumeOpCallback                                                     
 
46
                        }
 
47
                }
 
48
                                        
 
49
                public void VolumeOpCallback (bool succeeded, string error, string detailed_error)
 
50
                {
 
51
                        if ( succeeded )
 
52
                                Console.WriteLine("Unmount operation succeeded");
 
53
                        else
 
54
                                Console.Error.WriteLine("Unmount operation failed {0}, detail : {1}" , error, detailed_error );
 
55
                }
 
56
                                
 
57
                public string Name {
 
58
                        get { return drive.DisplayName; }               
 
59
                }
 
60
                
 
61
                public string Description {
 
62
                        get { return String.Format("{0}",drive.DeviceType); }
 
63
                }
 
64
                
 
65
                public string Icon {
 
66
                        get { return drive.Icon; }
 
67
                }
 
68
        }
 
69
}