summaryrefslogtreecommitdiffstats
blob: 99154f627c544223d6082c7435824622d2afc54f (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
/*
 * Copyright (c) 2010 Remko Tronçon
 * Licensed under the GNU General Public License v3.
 * See Documentation/Licenses/GPLv3.txt for more information.
 */

#include "Swiften/StreamStack/TLSLayer.h"
#include "Swiften/TLS/TLSContextFactory.h"
#include "Swiften/TLS/TLSContext.h"

namespace Swift {

TLSLayer::TLSLayer(TLSContextFactory* factory) {
	context = factory->createTLSContext();
	context->onDataForNetwork.connect(onWriteData);
	context->onDataForApplication.connect(onDataRead);
	context->onConnected.connect(onConnected);
	context->onError.connect(onError);
}

TLSLayer::~TLSLayer() {
	delete context;
}

void TLSLayer::connect() {
	context->connect();
}

void TLSLayer::writeData(const ByteArray& data) {
	context->handleDataFromApplication(data);
}

void TLSLayer::handleDataRead(const ByteArray& data) {
	context->handleDataFromNetwork(data);
}

bool TLSLayer::setClientCertificate(const PKCS12Certificate& certificate) {
	return context->setClientCertificate(certificate);
}

}