~ubuntu-branches/ubuntu/dapper/eiciel/dapper

« back to all changes in this revision

Viewing changes to src/eiciel_xattr_controler.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2005-12-27 01:45:06 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051227014506-nhcty9r1kink5hlz
Tags: 0.9-1
* New upstream release.
* Updated description as eiciel now also allows to manipulate extended user
  attributes.

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-2005 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
*/
 
19
 
 
20
#include "eiciel_xattr_controler.hpp"
 
21
 
 
22
EicielXAttrControler::EicielXAttrControler()
 
23
        : gestorXAttr(NULL), finestra(NULL), _fitxerObert(false)
 
24
{
 
25
}
 
26
 
 
27
void EicielXAttrControler::obrirFitxer(const Glib::ustring& nomFitxer) throw (GestorXAttrException)
 
28
{
 
29
        if (gestorXAttr != NULL)
 
30
        {
 
31
                delete gestorXAttr;
 
32
        }
 
33
 
 
34
        try
 
35
        {
 
36
                gestorXAttr = new GestorXAttr(nomFitxer);
 
37
                _fitxerObert = true;
 
38
 
 
39
                finestra->activacio(true);
 
40
 
 
41
                comprovarEditable();
 
42
 
 
43
                finestra->ompleAtributs(gestorXAttr->donarLlistaAtributs());
 
44
        }
 
45
        catch (GestorXAttrException e)
 
46
        {
 
47
                delete gestorXAttr;
 
48
                gestorXAttr = NULL;
 
49
                _fitxerObert = false;
 
50
                finestra->activacio(false);
 
51
        }
 
52
}
 
53
 
 
54
void EicielXAttrControler::eliminarAtribut(const Glib::ustring& nomAtrib)  throw (GestorXAttrException)
 
55
{
 
56
        gestorXAttr->eliminarAtribut(nomAtrib);
 
57
}
 
58
 
 
59
void EicielXAttrControler::afegirAtribut(const Glib::ustring& nomAtrib, const Glib::ustring& valorAtrib) throw (GestorXAttrException)
 
60
{
 
61
        gestorXAttr->afegirAtribut(nomAtrib, valorAtrib);
 
62
}
 
63
 
 
64
void EicielXAttrControler::actualitzarValorAtribut(const Glib::ustring& nomAtrib, const Glib::ustring& valorNouAtrib) throw (GestorXAttrException) 
 
65
{
 
66
        gestorXAttr->afegirAtribut(nomAtrib, valorNouAtrib);
 
67
}
 
68
 
 
69
void EicielXAttrControler::modificarNomAtribut(const Glib::ustring& nomAnticAtribut, const Glib::ustring& nomNouAtribut) throw (GestorXAttrException)
 
70
{
 
71
        gestorXAttr->canviarNomAtribut(nomAnticAtribut, nomNouAtribut);
 
72
}
 
73
 
 
74
void EicielXAttrControler::comprovarEditable()
 
75
{
 
76
        /*
 
77
         * Comprovem que es el propietari o root
 
78
         */
 
79
        uid_t real_user = getuid();
 
80
        if ((real_user != 0) && (real_user != gestorXAttr->donarUidPropietari()))
 
81
        {
 
82
                finestra->establirNomesLectura(true);
 
83
        }
 
84
        else
 
85
        {
 
86
                finestra->establirNomesLectura(false);
 
87
        }
 
88
        
 
89
}