fix tricky regression noticed by Vyacheslav Tokarev on Google Reader.
[kdelibs.git] / kdesu / ssh.h
blobbb702340c2fd08c94c5843e985b362d8580e421d
1 /* vi: ts=8 sts=4 sw=4
3 * This file is part of the KDE project, module kdesu.
4 * Copyright (C) 2000 Geert Jansen <jansen@kde.org>
6 * This is free software; you can use this library under the GNU Library
7 * General Public License, version 2. See the file "COPYING.LIB" for the
8 * exact licensing terms.
9 */
11 #ifndef __SSH_h_Included__
12 #define __SSH_h_Included__
14 #include "stub.h"
16 #include <kdesu/kdesu_export.h>
18 namespace KDESu {
20 /** \class SshProcess ssh.h kdesu/ssh.h
21 * Executes a remote command, using ssh.
24 class KDESU_EXPORT SshProcess: public StubProcess
26 public:
27 explicit SshProcess(const QByteArray &host = QByteArray(),
28 const QByteArray &user = QByteArray(),
29 const QByteArray &command = QByteArray());
30 ~SshProcess();
32 enum Errors { SshNotFound=1, SshNeedsPassword, SshIncorrectPassword };
34 /**
35 * Sets the target host.
37 void setHost(const QByteArray &host);
39 /**
40 * Sets the localtion of the remote stub.
42 void setStub(const QByteArray &stub);
44 /**
45 * Checks if the current user\@host needs a password.
46 * @return The prompt for the password if a password is required. A null
47 * string otherwise.
49 * @todo The return doc is so obviously wrong that the C code needs to be checked.
51 int checkNeedPassword();
53 /**
54 * Checks if the stub is installed and if the password is correct.
55 * @return Zero if everything is correct, nonzero otherwise.
57 int checkInstall(const char *password);
59 /**
60 * Executes the command.
62 int exec(const char *password, int check=0);
64 QByteArray prompt() const;
65 QByteArray error() const;
67 protected:
68 virtual QByteArray display();
69 virtual QByteArray displayAuth();
71 private:
72 int ConverseSsh(const char *password, int check);
74 protected:
75 virtual void virtual_hook( int id, void* data );
76 private:
77 class SshProcessPrivate;
78 SshProcessPrivate * const d;
83 #endif