Example #1
0
CServerProxy::EResult
CServerProxy::parseMessage(const UInt8* code)
{
	if (memcmp(code, kMsgDMouseMove, 4) == 0) {
		mouseMove();
	}

	else if (memcmp(code, kMsgDMouseRelMove, 4) == 0) {
		mouseRelativeMove();
	}

	else if (memcmp(code, kMsgDMouseWheel, 4) == 0) {
		mouseWheel();
	}

	else if (memcmp(code, kMsgDKeyDown, 4) == 0) {
		keyDown();
	}

	else if (memcmp(code, kMsgDKeyUp, 4) == 0) {
		keyUp();
	}

	else if (memcmp(code, kMsgDMouseDown, 4) == 0) {
		mouseDown();
	}

	else if (memcmp(code, kMsgDMouseUp, 4) == 0) {
		mouseUp();
	}

	else if (memcmp(code, kMsgDKeyRepeat, 4) == 0) {
		keyRepeat();
	}

	else if (memcmp(code, kMsgCKeepAlive, 4) == 0) {
		// echo keep alives and reset alarm
		CProtocolUtil::writef(m_stream, kMsgCKeepAlive);
		resetKeepAliveAlarm();
	}

	else if (memcmp(code, kMsgCNoop, 4) == 0) {
		// accept and discard no-op
	}

	else if (memcmp(code, kMsgCEnter, 4) == 0) {
		enter();
	}

	else if (memcmp(code, kMsgCLeave, 4) == 0) {
		leave();
	}

	else if (memcmp(code, kMsgCClipboard, 4) == 0) {
		grabClipboard();
	}

	else if (memcmp(code, kMsgCScreenSaver, 4) == 0) {
		screensaver();
	}

	else if (memcmp(code, kMsgQInfo, 4) == 0) {
		queryInfo();
	}

	else if (memcmp(code, kMsgCInfoAck, 4) == 0) {
		infoAcknowledgment();
	}

	else if (memcmp(code, kMsgDClipboard, 4) == 0) {
		setClipboard();
	}

	else if (memcmp(code, kMsgCResetOptions, 4) == 0) {
		resetOptions();
	}

	else if (memcmp(code, kMsgDSetOptions, 4) == 0) {
		setOptions();
	}

	else if (memcmp(code, kMsgDCryptoIv, 4) == 0) {
		cryptoIv();
	}

	else if (memcmp(code, kMsgDFileTransfer, 4) == 0) {
		fileChunkReceived();
	}
	else if (memcmp(code, kMsgDDragInfo, 4) == 0) {
		dragInfoReceived();
	}

	else if (memcmp(code, kMsgCClose, 4) == 0) {
		// server wants us to hangup
		LOG((CLOG_DEBUG1 "recv close"));
		m_client->disconnect(NULL);
		return kDisconnect;
	}
	else if (memcmp(code, kMsgEBad, 4) == 0) {
		LOG((CLOG_ERR "server disconnected due to a protocol error"));
		m_client->disconnect("server reported a protocol error");
		return kDisconnect;
	}
	else {
		return kUnknown;
	}

	// send a reply.  this is intended to work around a delay when
	// running a linux server and an OS X (any BSD?) client.  the
	// client waits to send an ACK (if the system control flag
	// net.inet.tcp.delayed_ack is 1) in hopes of piggybacking it
	// on a data packet.  we provide that packet here.  i don't
	// know why a delayed ACK should cause the server to wait since
	// TCP_NODELAY is enabled.
	CProtocolUtil::writef(m_stream, kMsgCNoop);

	return kOkay;
}
Example #2
0
CServerProxy::EResult
CServerProxy::parseHandshakeMessage(const UInt8* code)
{
	if (memcmp(code, kMsgQInfo, 4) == 0) {
		queryInfo();
	}

	else if (memcmp(code, kMsgCInfoAck, 4) == 0) {
		infoAcknowledgment();
	}

	else if (memcmp(code, kMsgDSetOptions, 4) == 0) {
		setOptions();

		// handshake is complete
		m_parser = &CServerProxy::parseMessage;
		m_client->handshakeComplete();
	}

	else if (memcmp(code, kMsgCResetOptions, 4) == 0) {
		resetOptions();
	}

	else if (memcmp(code, kMsgCKeepAlive, 4) == 0) {
		// echo keep alives and reset alarm
		CProtocolUtil::writef(m_stream, kMsgCKeepAlive);
		resetKeepAliveAlarm();
	}

	else if (memcmp(code, kMsgCNoop, 4) == 0) {
		// accept and discard no-op
	}

	else if (memcmp(code, kMsgCClose, 4) == 0) {
		// server wants us to hangup
		LOG((CLOG_DEBUG1 "recv close"));
		m_client->disconnect(NULL);
		return kDisconnect;
	}

	else if (memcmp(code, kMsgEIncompatible, 4) == 0) {
		SInt32 major, minor;
		CProtocolUtil::readf(m_stream,
						kMsgEIncompatible + 4, &major, &minor);
		LOG((CLOG_ERR "server has incompatible version %d.%d", major, minor));
		m_client->disconnect("server has incompatible version");
		return kDisconnect;
	}

	else if (memcmp(code, kMsgEBusy, 4) == 0) {
		LOG((CLOG_ERR "server already has a connected client with name \"%s\"", m_client->getName().c_str()));
		m_client->disconnect("server already has a connected client with our name");
		return kDisconnect;
	}

	else if (memcmp(code, kMsgEUnknown, 4) == 0) {
		LOG((CLOG_ERR "server refused client with name \"%s\"", m_client->getName().c_str()));
		m_client->disconnect("server refused client with our name");
		return kDisconnect;
	}

	else if (memcmp(code, kMsgEBad, 4) == 0) {
		LOG((CLOG_ERR "server disconnected due to a protocol error"));
		m_client->disconnect("server reported a protocol error");
		return kDisconnect;
	}
	else {
		return kUnknown;
	}

	return kOkay;
}
void DownloadListWidgetCompactDelegate::issueQueryInfo()
{
  emit queryInfo(m_ContextIndex.row());
}
Example #4
0
bool FileSystem::queryInfo(Path const& filename, FileInfo& info) const
{
    wchar_t buffer[1024];
    filename.convertTo(buffer, 1024);
    return queryInfo(buffer, info);
}
Example #5
0
BOOL IPM_BuildItemPath (CdIpmDoc* pDoc, CTypedPtrList<CObList, CuIpmTreeFastItem*>& listItemPath)
{
	ASSERT(!pDoc->GetSelectKey().IsEmpty());
	if (pDoc->GetSelectKey().IsEmpty())
		return FALSE;

	BOOL bOK = FALSE;
	int  nLevel = 0;
	int  nParent0type = 0;
	int  nObjectType  = 0;
	CString strParent0 = _T("");
	CString strStaticParent = _T("");
	CStringArray& arrayItemPath = pDoc->GetItemPath();
	void* pStructParent = NULL;
	int narrayItemPathSize = arrayItemPath.GetSize();
	ASSERT(narrayItemPathSize >= 1);
	if (narrayItemPathSize < 1)
		return FALSE;
	CString strObject = arrayItemPath.GetAt(0);
	//
	// Default (from old class CuIpmObjDesc in vdba):
	BOOL bObjectNeedsNameCheck = FALSE;
	BOOL bObjectHasStaticBranch= TRUE;
	BOOL bStaticParentNeedsNameCheck= FALSE;

	if (pDoc->GetSelectKey().CompareNoCase (_T("SERVER")) == 0)
	{
		//
		// Old class CuIpmObjDesc_SERVER in vdba (no overwrite the 3 default booleans above.
		nObjectType  = OT_MON_SERVER;
	}
	else
	if (pDoc->GetSelectKey().CompareNoCase (_T("SESSION")) == 0)
	{
		//
		// Old class CuIpmObjDesc_SESSION in vdba (no overwrite the 3 default booleans above.
		nLevel = 1; // Parent is the SERVER. EX: ii\ingres\158
		nParent0type = OT_MON_SERVER;
		nObjectType  = OT_MON_SESSION;
		ASSERT(narrayItemPathSize >= 2);
		if (narrayItemPathSize < 2)
			return FALSE;
		strParent0   = arrayItemPath.GetAt(0);
		strObject    = arrayItemPath.GetAt(1);
	}
	else
	if (pDoc->GetSelectKey().CompareNoCase (_T("REPLICSERVER")) == 0)
	{
		//
		// Old class CuIpmObjDesc_REPLICSERVER in vdba (overwrite the 2 default booleans above.
		bStaticParentNeedsNameCheck = TRUE;
		bObjectHasStaticBranch = FALSE;
		nLevel = 1; // Parent is the database name
		nParent0type = OT_DATABASE;
		nObjectType  = OT_MON_REPLIC_SERVER;
		ASSERT(narrayItemPathSize >= 1);
		if (narrayItemPathSize < 1)
			return FALSE;
		strStaticParent = _T("Replication");
		strParent0   = arrayItemPath.GetAt(0);
		if (narrayItemPathSize > 1)
			strObject    = arrayItemPath.GetAt(1);
	}
	else
	if (pDoc->GetSelectKey().CompareNoCase (_T("LOGINFO")) == 0)
	{
		//
		// Old class CuIpmObjDesc_LOGINFO in vdba (overwrite the 1 default boolean above.
		bObjectNeedsNameCheck = TRUE;
		strObject.LoadString(IDS_TM_LOGINFO); // "Log information"
	}

	if (nLevel > 0)
	{
		ASSERT (nParent0type);
		ASSERT (!strParent0.IsEmpty());
		// Static parent
		if (bStaticParentNeedsNameCheck) 
		{
			//
			// Only for replication:
			listItemPath.AddTail(new CaTreeItemPath(TRUE, nParent0type, NULL, TRUE, strStaticParent));
		}
		else
		{
			listItemPath.AddTail(new CaTreeItemPath(TRUE, nParent0type));
		}

		int reqSize = IPM_StructSize(nParent0type);
		CPtrList listInfoStruct;
		IPMUPDATEPARAMS ups;
		memset (&ups, 0, sizeof(ups));
		CaIpmQueryInfo queryInfo(pDoc, nParent0type, &ups, (LPVOID)NULL, reqSize);
		queryInfo.SetReportError(FALSE);

		bOK = IPM_QueryInfo (&queryInfo, listInfoStruct);
		if (bOK)
		{
			POSITION p = NULL, pos = listInfoStruct.GetHeadPosition();

			while (pos != NULL)
			{
				p = pos;
				LPVOID pObject = listInfoStruct.GetNext(pos);
				if (MatchedStruct (nParent0type, strParent0, pObject))
				{
					pStructParent = pObject;
					listInfoStruct.RemoveAt (p);
					listItemPath.AddTail(new CaTreeItemPath(FALSE, nParent0type, pObject)); // non-static
					break;
				}
			}
			while (!listInfoStruct.IsEmpty())
				delete listInfoStruct.RemoveHead();
		}

		if (!pStructParent)
			return FALSE;
	}

	//
	// Object itself:
	if (strObject.IsEmpty())
		return bOK;

	if (bObjectNeedsNameCheck)
	{
		listItemPath.AddTail(new CaTreeItemPath(TRUE,  nObjectType, NULL, TRUE, strObject));  // Root item
		bOK = TRUE;
	}
	else
	{
		if (bObjectHasStaticBranch)
			listItemPath.AddTail(new CaTreeItemPath(TRUE, nObjectType));  // static

		int reqSize = IPM_StructSize(nObjectType);
		CPtrList listInfoStruct;
		IPMUPDATEPARAMS ups;
		memset (&ups, 0, sizeof(ups));
		ups.nType   = nParent0type;
		ups.pStruct = pStructParent;
		ups.pSFilter= NULL;

		CaIpmQueryInfo queryInfo(pDoc, nObjectType, &ups, (LPVOID)NULL, reqSize);
		queryInfo.SetReportError(FALSE);

		BOOL bHasObjects = IPM_QueryInfo (&queryInfo, listInfoStruct);
		if (bHasObjects)
		{
#if !defined (_IGNORE_NOT_MATCHED_ITEM)
			bOK = FALSE;
#endif
			POSITION p = NULL, pos = listInfoStruct.GetHeadPosition();
			while (pos != NULL)
			{
				p = pos;
				LPVOID pObject = listInfoStruct.GetNext(pos);
				if (MatchedStruct (nObjectType, strObject, pObject))
				{
					bOK = TRUE;
					listInfoStruct.RemoveAt (p);
					listItemPath.AddTail(new CaTreeItemPath(FALSE, nObjectType, pObject)); // non-static
					break;
				}
			}
			while (!listInfoStruct.IsEmpty())
				delete listInfoStruct.RemoveHead();
		}
	}

	return bOK;
}