~ubuntu-branches/ubuntu/trusty/eiciel/trusty-proposed

« back to all changes in this revision

Viewing changes to src/eiciel_xattr_controller.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2010-06-04 02:38:02 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100604023802-jp2v6c9uviiioc5z
* New upstream release.
* debian/patches/02-gio.patch
  - Removed, merged upstream.
* debian/patches/03-no-libgnomeui.patch
  - Removed, merged upstream.
* debian/patches/01-fix-gettext-translations.patch
  - Fix gettext translations by using dgettext and specifying the correct
    domainname.
* debian/patches/02-de-po.patch
  - Update and complete German translation.
* debian/rules
  - Remove de.gmo on clean and rebuild it on build.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Eiciel - GNOME editor of ACL file permissions.
 
3
    Copyright (C) 2004-2010 Roger Ferrer Ibáñez
 
4
 
 
5
    This program is free software; you can redistribute it and/or modify
 
6
    it under the terms of the GNU General Public License as published by
 
7
    the Free Software Foundation; either version 2 of the License, or
 
8
    (at your option) any later version.
 
9
 
 
10
    This program is distributed in the hope that it will be useful,
 
11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
    GNU General Public License for more details.
 
14
 
 
15
    You should have received a copy of the GNU General Public License
 
16
    along with this program; if not, write to the Free Software
 
17
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,  USA
 
18
*/
 
19
 
 
20
#include "eiciel_xattr_controller.hpp"
 
21
 
 
22
EicielXAttrController::EicielXAttrController()
 
23
        : _xattr_manager(NULL), _window(NULL), _opened_file(false)
 
24
{
 
25
}
 
26
 
 
27
void EicielXAttrController::open_file(const Glib::ustring& filename) throw (XAttrManagerException)
 
28
{
 
29
        if (_xattr_manager != NULL)
 
30
        {
 
31
                delete _xattr_manager;
 
32
        }
 
33
 
 
34
        try
 
35
        {
 
36
                _xattr_manager = new XAttrManager(filename);
 
37
                _opened_file = true;
 
38
 
 
39
                _window->set_active(true);
 
40
 
 
41
                check_editable();
 
42
 
 
43
                _window->fill_attributes(_xattr_manager->get_attributes_list());
 
44
        }
 
45
        catch (XAttrManagerException e)
 
46
        {
 
47
                delete _xattr_manager;
 
48
                _xattr_manager = NULL;
 
49
                _opened_file = false;
 
50
                _window->set_active(false);
 
51
        }
 
52
}
 
53
 
 
54
void EicielXAttrController::remove_attribute(const Glib::ustring& nomAtrib)  throw (XAttrManagerException)
 
55
{
 
56
        _xattr_manager->remove_attribute(nomAtrib);
 
57
}
 
58
 
 
59
void EicielXAttrController::add_attribute(const Glib::ustring& nomAtrib, const Glib::ustring& valorAtrib) throw (XAttrManagerException)
 
60
{
 
61
        _xattr_manager->add_attribute(nomAtrib, valorAtrib);
 
62
}
 
63
 
 
64
void EicielXAttrController::update_attribute_value(const Glib::ustring& nomAtrib, const Glib::ustring& valorNouAtrib) throw (XAttrManagerException) 
 
65
{
 
66
        _xattr_manager->add_attribute(nomAtrib, valorNouAtrib);
 
67
}
 
68
 
 
69
void EicielXAttrController::update_attribute_name(const Glib::ustring& nomAnticAtribut, const Glib::ustring& nomNouAtribut) throw (XAttrManagerException)
 
70
{
 
71
        _xattr_manager->change_attribute_name(nomAnticAtribut, nomNouAtribut);
 
72
}
 
73
 
 
74
void EicielXAttrController::check_editable()
 
75
{
 
76
        /*
 
77
         * Comprovem que es el propietari o root
 
78
         */
 
79
        uid_t real_user = getuid();
 
80
        if ((real_user != 0) && (real_user != _xattr_manager->get_owner_uid()))
 
81
        {
 
82
                _window->set_readonly(true);
 
83
        }
 
84
        else
 
85
        {
 
86
                _window->set_readonly(false);
 
87
        }
 
88
        
 
89
}