sessionworker.hh 2.66 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#ifndef RSM_RSMCORE_SESSIONWORKER_HH_
#define RSM_RSMCORE_SESSIONWORKER_HH_

#include <QObject>

#include "rsmcore/declspec.hh"

namespace rsm
{
class SessionWorkerImpl;
class RSM_PUBLIC SessionWorker : public QObject
{
  Q_OBJECT
 private:
  // Private implementation
  SessionWorkerImpl* p;

 public:
  enum class Verbosity
  {
    None,
    Warning,
    Protocal,
    Packet,
    Functions
  };

28
29
30
  /**
   * Basic Constructor
   */
31
  SessionWorker(QObject* parent = nullptr);
32
33
34
  /**
   * Contructs with host name
   */
35
36
37
38
  SessionWorker(QString host, QObject* parent = nullptr);
  ~SessionWorker();

 public slots:
39
40
41
42

  /**
   * Set the remote host to connect to
   */
43
  void setHost(QString host);
44
45
46
  /**
   * Set the Log verbosity
   */
47
  void setLogVerbosity(Verbosity level);
48
49
50
  /**
   * Set the ssh port number
   */
51
  void setPort(int port);
52
53
54
55
  /**
   * Set the user
   * Defaults to system user
   */
56
  void setUser(QString name);
57
58
59
  /**
   * Perform hand-shake to connect to host.
   */
60
  void connect();
61
62
63
  /**
   * Disconnect ssh session
   */
64
  void disconnect();
65
66
67
68
69
70
71
72
  /**
   * Perform known host verification.
   * Checks known_host file to validate remote host SHA
   * Can emit hostUnknown(QString host_hash).
   * Can emit hostPublicKeyChanged(QString host_hash).
   * Can emit hostPublicKeyUnavailable().
   * Can emit knownHostError().
   */
73
  void verifyKnownHost();
74
75
76
77
  /**
   * Performs a request to accept/save the host's public key,
   * updating the known_hosts
   */
78
  void acceptHostPublicKeyUpdate();
79
80
81
82
83
84
  /**
   * Attempts to authenticate using public key or password.
   * Can emit authenticationError(QString message).
   * Can emit authenticationSucceeded() upon acceptance of public key.
   * Can emit passworedRequested().
   */
85
  void authenticate();
86
87
88
89
90
91
  /**
   * Attempts to authenticate with username and password.
   * Can emit authenticationError(QString message).
   * Can emit authenticationSuccessed() upon acceptance of password.
   * Can emit loginBannerIssued(QString message) give availability.
   */
92
93
  void authenticateWithPassword(QString pswd);

94
95
96
97
98
99
  /**
   * Requests remote execution of command
   * @param command - QString command to execute
   */
  void requestExec(QString command);

100
101
102
103
104
105
106
107
108
109
110
 signals:
  void getServerPublicKeyFailed();
  void hostUnknown(QString host_hash);
  void hostPublicKeyChanged(QString host_hash);
  void hostPublicKeyUnavailable();
  void knownHostError(QString message);
  void updateKnownHostsFailed();
  void authenticationError(QString message);
  void authenticationSucceeded();
  void passwordRequested();
  void loginBannerIssued(QString message);
111
  void execOutputReady();
112
113
114
115

};  // class SessionWorker
}  // namespace rsm
#endif /* RSM_RSMCORE_SESSIONWORKER_HH_*/