~ubuntu-branches/ubuntu/precise/smb4k/precise

« back to all changes in this revision

Viewing changes to core/smb4ksudowriterinterface.h

  • Committer: Bazaar Package Importer
  • Author(s): Richard A. Johnson
  • Date: 2008-11-23 12:14:34 UTC
  • mfrom: (1.1.14 upstream)
  • Revision ID: james.westby@ubuntu.com-20081123121434-88cpidapbcqteud1
Tags: 0.10.1-0ubuntu1
* New upstream release for KDE 4
* Closes
  - (LP: #238011)
  - (LP: #248510)
  - (LP: #261803)
  - (LP: #262225)
  - (LP: #275539)
* Updated debian/
  - control: updated for new deps and removed old deps, bumped versions,
    modified Maintainer
  - rules: removed all but the kde4.mk for cdbs

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
    smb4ksudowriterinterface  -  This class provides an interface to the
 
3
    smb4k_sudowriter utility program that writes entries to the sudoers
 
4
    file.
 
5
                             -------------------
 
6
    begin                : Sa Aug 2 2008
 
7
    copyright            : (C) 2008 by Alexander Reinholdt
 
8
    email                : dustpuppy@users.berlios.de
 
9
 ***************************************************************************/
 
10
 
 
11
/***************************************************************************
 
12
 *   This program is free software; you can redistribute it and/or modify  *
 
13
 *   it under the terms of the GNU General Public License as published by  *
 
14
 *   the Free Software Foundation; either version 2 of the License, or     *
 
15
 *   (at your option) any later version.                                   *
 
16
 *                                                                         *
 
17
 *   This program is distributed in the hope that it will be useful, but   *
 
18
 *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
 
19
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
 
20
 *   General Public License for more details.                              *
 
21
 *                                                                         *
 
22
 *   You should have received a copy of the GNU General Public License     *
 
23
 *   along with this program; if not, write to the                         *
 
24
 *   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,   *
 
25
 *   MA  02111-1307 USA                                                    *
 
26
 ***************************************************************************/
 
27
 
 
28
#ifndef SMB4KSUDOWRITERINTERFACE_H
 
29
#define SMB4KSUDOWRITERINTERFACE_H
 
30
 
 
31
#ifdef HAVE_CONFIG_H
 
32
#include <config.h>
 
33
#endif
 
34
 
 
35
// Qt includes
 
36
#include <QObject>
 
37
 
 
38
// KDE includes
 
39
#include <kdemacros.h>
 
40
#include <kprocess.h>
 
41
 
 
42
 
 
43
/**
 
44
 * This class provides an interface to the smb4k_sudowriter utility program
 
45
 * that writes to the sudoers file.
 
46
 *
 
47
 * @author Alexander Reinholdt <dustpuppy@users.berlios.de>
 
48
 */
 
49
 
 
50
class KDE_EXPORT Smb4KSudoWriterInterface : public QObject
 
51
{
 
52
  Q_OBJECT
 
53
 
 
54
  friend class Smb4KSudoWriterInterfacePrivate;
 
55
 
 
56
  public:
 
57
    /**
 
58
     * Enumeration for the operation that is currently done.
 
59
     */
 
60
    enum Operation { AddUser,
 
61
                     RemoveUser,
 
62
                     Unknown };
 
63
 
 
64
    /**
 
65
     * This function returns a static pointer to this class.
 
66
     *
 
67
     * @returns a static pointer to the Smb4KSudoWriterInterface class.
 
68
     */
 
69
    static Smb4KSudoWriterInterface *self();
 
70
 
 
71
    /**
 
72
     * This function adds the name of the current user to the Smb4K section
 
73
     * in the sudoers file by invoking the smb4k_sudowriter utility program.
 
74
     * If no Smb4K section exists, the utility program will create one.
 
75
     */
 
76
    void addUser();
 
77
 
 
78
    /**
 
79
     * This function removes the name of the current user from the Smb4K
 
80
     * section in the sudoers file by invoking the smb4k_sudowriter utility
 
81
     * program. If the user is the only entry, the Smb4K section will be
 
82
     * removed from the sudoers file.
 
83
     */
 
84
    void removeUser();
 
85
 
 
86
  signals:
 
87
    /**
 
88
     * This signal is emitted when somthing went wrong with the writing to
 
89
     * the sudoers file.
 
90
     */
 
91
    void failed( Smb4KSudoWriterInterface::Operation operation );
 
92
 
 
93
    /**
 
94
     * This signal is emitted when the writing to the sudoers file has
 
95
     * finished. It is emitted in case the writing was successful as well
 
96
     * as in case it wasn't.
 
97
     */
 
98
    void finished( Smb4KSudoWriterInterface::Operation operation );
 
99
 
 
100
  protected slots:
 
101
    /**
 
102
     * This slot is called, when the process exited.
 
103
     *
 
104
     * @param exitCode           The exit code of the process
 
105
     *
 
106
     * @param exitStatus         The exit status of the process (@see QProcess::ExitStatus)
 
107
     */
 
108
    void slotProcessFinished( int exitCode, QProcess::ExitStatus exitStatus );
 
109
 
 
110
    /**
 
111
     * This slot is invoked when an error occurred with the process.
 
112
     *
 
113
     * @param errorCode          The error code returned by the process
 
114
     */
 
115
    void slotProcessError( QProcess::ProcessError errorCode );
 
116
 
 
117
  private:
 
118
    /**
 
119
     * The constructor.
 
120
     */
 
121
    Smb4KSudoWriterInterface();
 
122
 
 
123
    /**
 
124
     * The destructor.
 
125
     */
 
126
    ~Smb4KSudoWriterInterface();
 
127
 
 
128
    /**
 
129
     * Operation
 
130
     */
 
131
    Operation m_operation;
 
132
 
 
133
    /**
 
134
     * The KProcess object
 
135
     */
 
136
    KProcess *m_proc;
 
137
 
 
138
    /**
 
139
     * Process error
 
140
     */
 
141
    QProcess::ProcessError m_process_error;
 
142
};
 
143
 
 
144
#endif