summaryrefslogtreecommitdiff
path: root/include/connectionManager.h
blob: 9680891e27f4a3afa6842a6ec7bbd0bf5449ff79 (plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 * connectionManager.h
 *
 *  Created on: 27.08.2012
 *      Author: savop
 */

#ifndef CONNECTIONMANAGER_H_
#define CONNECTIONMANAGER_H_

#include "../include/service.h"
#include "../include/connection.h"
#include "../include/tools.h"
#include <string>
#include <list>
#include <map>

namespace upnp {

/**
 * The connection manager service
 *
 * This is the connection manager service which handles all incoming connection,
 * creates and destroys connections to clients.
 */
class cConnectionManager : public cUPnPService {
public:

  typedef std::map<int32_t, cVirtualConnection*> ConnectionList;
  /**
   * Constructor of a Connection manager
   *
   * This creates an instance of a <em>Connection Manager Service</em> and provides
   * interfaces for executing actions and subscribing on events.
   */
  cConnectionManager();
  virtual ~cConnectionManager();
  /*! @copydoc cUpnpService::subscribe(Upnp_Subscription_Request* Request) */
  virtual int Subscribe(Upnp_Subscription_Request* request);
  /*! @copydoc cUpnpService::execute(Upnp_Action_Request* Request) */
  virtual int Execute(Upnp_Action_Request* request);
  /*! @copydoc cUpnpService::setError(Upnp_Action_Request* Request, int Error) */
  virtual void SetError(Upnp_Action_Request* request, int error);
private:

  int GetProtocolInfo(Upnp_Action_Request* request);
  int GetCurrentConnectionIDs(Upnp_Action_Request* request);
  int GetCurrentConnectionInfo(Upnp_Action_Request* request);
  int PrepareForConnection(Upnp_Action_Request* request);
  int ConnectionComplete(Upnp_Action_Request* request);
  const std::string GetConnectionIDsCVS();

  void DeleteConnections();
  bool DeleteConnection(int32_t connectionID);
  bool CreateConnection(
      const std::string & remoteProtocolInfo,
      const std::string & peerConnectionManager,
      int32_t peerConnectionID,
      const std::string & direction
      );

  bool OnConnectionChange();

  ConnectionList mVirtualConnections;
  StringList mSupportedProtocols;
} ConnectionManager;

}  // namespace upnp

#endif /* CONNECTIONMANAGER_H_ */