Show invite menu in wlm chat window immediately
[kdenetwork.git] / kopete / protocols / groupwise / libgroupwise / qcatlshandler.cpp
blob0c9265b68bd2677d07ab19eca8e020d69ede73d9
1 /*
2 qcatlshandler.cpp - Kopete Groupwise Protocol
4 Copyright (c) 2006 Novell, Inc http://www.opensuse.org
5 Copyright (c) 2004 SUSE Linux AG http://www.suse.com
7 Based on Iris, Copyright (C) 2003 Justin Karneges <justin@affinix.com>
9 Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
11 *************************************************************************
12 * *
13 * This library is free software; you can redistribute it and/or *
14 * modify it under the terms of the GNU Lesser General Public *
15 * License as published by the Free Software Foundation; either *
16 * version 2 of the License, or (at your option) any later version. *
17 * *
18 *************************************************************************
21 #include <qtimer.h>
23 #include <QtCrypto>
25 #include "qcatlshandler.h"
27 class QCATLSHandler::Private
29 public:
30 QCA::TLS *tls;
31 int state, err;
34 QCATLSHandler::QCATLSHandler(QCA::TLS *parent)
35 :TLSHandler(parent), d(new Private())
37 d->tls = parent;
38 connect(d->tls, SIGNAL(handshaken()), SLOT(tls_handshaken()));
39 connect(d->tls, SIGNAL(readyRead()), SLOT(tls_readyRead()));
40 connect(d->tls, SIGNAL(readyReadOutgoing()), SLOT(tls_readyReadOutgoing()));
41 connect(d->tls, SIGNAL(closed()), SLOT(tls_closed()));
42 connect(d->tls, SIGNAL(error()), SLOT(tls_error()));
43 d->state = 0;
44 d->err = -1;
47 QCATLSHandler::~QCATLSHandler()
49 delete d;
52 QCA::TLS *QCATLSHandler::tls() const
54 return d->tls;
57 int QCATLSHandler::tlsError() const
59 return d->err;
62 void QCATLSHandler::reset()
64 d->tls->reset();
65 d->state = 0;
68 void QCATLSHandler::startClient(const QString &host)
70 d->state = 0;
71 d->err = -1;
72 d->tls->startClient(host);
75 void QCATLSHandler::write(const QByteArray &a)
77 d->tls->write(a);
80 void QCATLSHandler::writeIncoming(const QByteArray &a)
82 d->tls->writeIncoming(a);
85 void QCATLSHandler::continueAfterHandshake()
87 if(d->state == 2) {
88 d->tls->continueAfterStep();
89 success();
90 d->state = 3;
94 void QCATLSHandler::tls_handshaken()
96 d->state = 2;
97 tlsHandshaken();
100 void QCATLSHandler::tls_readyRead()
102 readyRead(d->tls->read());
105 void QCATLSHandler::tls_readyReadOutgoing()
107 int plainBytes;
108 QByteArray buf = d->tls->readOutgoing(&plainBytes);
109 readyReadOutgoing(buf, plainBytes);
112 void QCATLSHandler::tls_closed()
114 closed();
117 void QCATLSHandler::tls_error()
119 d->err = d->tls->errorCode();
120 d->state = 0;
121 fail();
124 #include "qcatlshandler.moc"