예제 #1
0
void
CClientProxy1_0::disconnect()
{
	removeHandlers();
	getStream()->close();
	EVENTQUEUE->addEvent(CEvent(getDisconnectedEvent(), getEventTarget()));
}
예제 #2
0
CClientProxyUnknown::~CClientProxyUnknown()
{
	removeHandlers();
	removeTimer();
	delete m_stream;
	delete m_proxy;
}
예제 #3
0
void
CClientProxy1_0::disconnect()
{
	removeHandlers();
	getStream()->close();
	m_events->addEvent(CEvent(m_events->forCClientProxy().disconnected(), getEventTarget()));
}
예제 #4
0
void
CClientProxyUnknown::sendFailure()
{
	delete m_proxy;
	m_proxy = NULL;
	m_ready = false;
	removeHandlers();
	removeTimer();
	EVENTQUEUE->addEvent(CEvent(getFailureEvent(), this));
}
void
CClientProxyUnknown::sendFailure()
{
	delete m_proxy;
	m_proxy = NULL;
	m_ready = false;
	removeHandlers();
	removeTimer();
	m_events->addEvent(CEvent(m_events->forCClientProxyUnknown().failure(), this));
}
void FileTransferHandlerManager::protocolHandlerChanged()
{
	auto account = Account{sender()};
	if (!account)
		return;

	if (account.protocolHandler())
		createHandlers(account);
	else
		removeHandlers(account);
}
예제 #7
0
CClientProxy*
CClientProxyUnknown::orphanClientProxy()
{
	if (m_ready) {
		removeHandlers();
		CClientProxy* proxy = m_proxy;
		m_proxy = NULL;
		return proxy;
	}
	else {
		return NULL;
	}
}
void FileTransferHandlerManager::accountUnregistered(Account account)
{
	removeHandlers(account);
	disconnect(account, SIGNAL(protocolHandlerChanged()), this, SLOT(protocolHandlerChanged()));
}
예제 #9
0
CClientProxy1_0::~CClientProxy1_0()
{
	removeHandlers();
}
예제 #10
0
void
CClientProxyUnknown::handleData(const CEvent&, void*)
{
	LOG((CLOG_DEBUG1 "parsing hello reply"));

	CString name("<unknown>");
	try {
		// limit the maximum length of the hello
		UInt32 n = m_stream->getSize();
		if (n > kMaxHelloLength) {
			LOG((CLOG_DEBUG1 "hello reply too long"));
			throw XBadClient();
		}

		// parse the reply to hello
		SInt16 major, minor;
		if (!CProtocolUtil::readf(m_stream, kMsgHelloBack,
									&major, &minor, &name)) {
			throw XBadClient();
		}

		// disallow invalid version numbers
		if (major <= 0 || minor < 0) {
			throw XIncompatibleClient(major, minor);
		}

		// remove stream event handlers.  the proxy we're about to create
		// may install its own handlers and we don't want to accidentally
		// remove those later.
		removeHandlers();

		// create client proxy for highest version supported by the client
		if (major == 1) {
			switch (minor) {
			case 0:
				m_proxy = new CClientProxy1_0(name, m_stream);
				break;

			case 1:
				m_proxy = new CClientProxy1_1(name, m_stream);
				break;

			case 2:
				m_proxy = new CClientProxy1_2(name, m_stream);
				break;

			case 3:
				m_proxy = new CClientProxy1_3(name, m_stream);
				break;
			}
		}

		// hangup (with error) if version isn't supported
		if (m_proxy == NULL) {
			throw XIncompatibleClient(major, minor);
		}

		// the proxy is created and now proxy now owns the stream
		LOG((CLOG_DEBUG1 "created proxy for client \"%s\" version %d.%d", name.c_str(), major, minor));
		m_stream = NULL;

		// wait until the proxy signals that it's ready or has disconnected
		addProxyHandlers();
		return;
	}
	catch (XIncompatibleClient& e) {
		// client is incompatible
		LOG((CLOG_WARN "client \"%s\" has incompatible version %d.%d)", name.c_str(), e.getMajor(), e.getMinor()));
		CProtocolUtil::writef(m_stream,
							kMsgEIncompatible,
							kProtocolMajorVersion, kProtocolMinorVersion);
	}
	catch (XBadClient&) {
		// client not behaving
		LOG((CLOG_WARN "protocol error from client \"%s\"", name.c_str()));
		CProtocolUtil::writef(m_stream, kMsgEBad);
	}
	catch (XBase& e) {
		// misc error
		LOG((CLOG_WARN "error communicating with client \"%s\": %s", name.c_str(), e.what()));
	}
	sendFailure();
}