Ejemplo n.º 1
0
j_result_t CXlClient::OnHandleRead(J_AsioDataBase *pAsioData)
{
	if (m_ioCmdState == CXlProtocol::xl_init_state)
	{
		pAsioData->ioCall = J_AsioDataBase::j_read_e;
		CXlHelper::MakeNetData(pAsioData, m_readBuff, sizeof(CXlProtocol::CmdHeader));

		m_ioCmdState = CXlProtocol::xl_read_head_state;
	}
	else if (m_ioCmdState == CXlProtocol::xl_read_head_state)
	{
		CXlProtocol::CmdHeader cmdHeader = *((CXlProtocol::CmdHeader *)m_readBuff);
		//J_OS::LOGINFO("%d ", cmdHeader.cmd);
		//if (cmdHeader.length > 1000)
		//{
		//	J_OS::LOGINFO("");
		//}
		CXlHelper::MakeNetData(pAsioData, m_readBuff + sizeof(CXlProtocol::CmdHeader), cmdHeader.length + sizeof(CXlProtocol::CmdTail));
		pAsioData->ioCall = J_AsioDataBase::j_read_e;

		m_ioCmdState = CXlProtocol::xl_read_data_state;
	}
	else if (m_ioCmdState == CXlProtocol::xl_read_data_state)
	{
		CXlClientCmdData *pCmdData = (CXlClientCmdData *)m_readBuff;
		switch (pCmdData->cmdHeader.cmd)
		{
		case CXlProtocol::xlc_login:
			OnLogin(*pCmdData);
			break;
		case CXlProtocol::xlc_logout:
			OnLogout(*pCmdData);
			break;
		case CXlProtocol::xlc_heart_beat:
			OnHeartBeat(*pCmdData);
			break;
		case CXlProtocol::xlc_real_play:
			SaveRequest(*pCmdData, pCmdData->cmdHeader.flag == CXlProtocol::xl_ctrl_start);
			pCmdData->cmdRealPlay.pBuffer = &m_ringBuffer;
			JoDataBus->Request(pCmdData->cmdRealPlay.hostId, this, *pCmdData);
			break;
		case CXlProtocol::xlc_vod_play:
		case CXlProtocol::xlc_vod_download:
			SaveRequest(*pCmdData, pCmdData->cmdHeader.flag == CXlProtocol::xl_ctrl_start);
			pCmdData->cmdStartVod.pBuffer = &m_ringBuffer;
			JoDataBus->Request(pCmdData->cmdStartVod.hostId, this, *pCmdData);
			break;
		case CXlProtocol::xlc_real_alarm:
			EnableAlarm(*pCmdData, pCmdData->cmdHeader.flag == CXlProtocol::xl_ctrl_start);
			break;
		case CXlProtocol::xlc_trans_context:
			break;
		case CXlProtocol::xlc_upload_file:
			break;
		default:
			//assert(false);
			SendRequest(*pCmdData);
			break;
		}

		CXlHelper::MakeNetData(pAsioData, m_readBuff, sizeof(CXlProtocol::CmdHeader));
		pAsioData->ioCall = J_AsioDataBase::j_read_e;
		m_ioCmdState = CXlProtocol::xl_read_head_state;
	}

	return J_OK;
}
void
BluetoothServiceChildProcess::DisconnectSco(BluetoothReplyRunnable* aRunnable)
{
  SendRequest(aRunnable, DisconnectScoRequest());
}
void
BluetoothServiceChildProcess::IgnoreWaitingCall(
  BluetoothReplyRunnable* aRunnable)
{
  SendRequest(aRunnable, IgnoreWaitingCallRequest());
}
void
BluetoothServiceChildProcess::DiscoverGattServicesInternal(
  const BluetoothUuid& aAppUuid, BluetoothReplyRunnable* aRunnable)
{
  SendRequest(aRunnable, DiscoverGattServicesRequest(aAppUuid));
}
void
BluetoothServiceChildProcess::UnregisterGattServerInternal(
  int aServerIf, BluetoothReplyRunnable* aRunnable)
{
  SendRequest(aRunnable, UnregisterGattServerRequest(aServerIf));
}
Ejemplo n.º 6
0
void CSkypeProto::OnChatEvent(const JSONNode &node)
{
	//std::string clientMsgId = node["clientmessageid"].as_string();
	//std::string skypeEditedId = node["skypeeditedid"].as_string();

	std::string fromLink = node["from"].as_string();
	CMStringA from(ContactUrlToName(fromLink.c_str()));

	time_t timestamp = IsoToUnixTime(node["composetime"].as_string().c_str());

	std::string content = node["content"].as_string();
	int emoteOffset = node["skypeemoteoffset"].as_int();

	std::string conversationLink = node["conversationLink"].as_string();
	CMStringA chatname(ChatUrlToName(conversationLink.c_str()));

	CMString topic(node["threadtopic"].as_mstring());
	if (FindChatRoom(chatname) == NULL)
		SendRequest(new GetChatInfoRequest(m_szRegToken, chatname, m_szServer), &CSkypeProto::OnGetChatInfo, topic.Detach());

	std::string messageType = node["messagetype"].as_string();
	if (!mir_strcmpi(messageType.c_str(), "Text") || !mir_strcmpi(messageType.c_str(), "RichText"))
	{
		AddMessageToChat(_A2T(chatname), _A2T(from), content.c_str(), emoteOffset != NULL, emoteOffset, timestamp);
	}
	else if (!mir_strcmpi(messageType.c_str(), "ThreadActivity/AddMember"))
	{
		ptrA xinitiator, xtarget, initiator;
		//content = <addmember><eventtime>1429186229164</eventtime><initiator>8:initiator</initiator><target>8:user</target></addmember>

		HXML xml = xmlParseString(ptrT(mir_a2t(content.c_str())), 0, _T("addmember"));
		if (xml == NULL)
			return;

		for (int i = 0; i < xmlGetChildCount(xml); i++)
		{
			HXML xmlNode = xmlGetNthChild(xml, L"target", i);
			if (xmlNode == NULL)
				break;

			xtarget = mir_t2a(xmlGetText(xmlNode));

			CMStringA target = ParseUrl(xtarget, "8:");
			AddChatContact(_A2T(chatname), target, target, L"User");
		}
		xmlDestroyNode(xml);
	}
	else if (!mir_strcmpi(messageType.c_str(), "ThreadActivity/DeleteMember"))
	{
		ptrA xinitiator, xtarget;
		//content = <addmember><eventtime>1429186229164</eventtime><initiator>8:initiator</initiator><target>8:user</target></addmember>

		HXML xml = xmlParseString(ptrT(mir_a2t(content.c_str())), 0, _T("deletemember"));
		if (xml != NULL) {
			HXML xmlNode = xmlGetChildByPath(xml, _T("initiator"), 0);
			xinitiator = node != NULL ? mir_t2a(xmlGetText(xmlNode)) : NULL;

			xmlNode = xmlGetChildByPath(xml, _T("target"), 0);
			xtarget = xmlNode != NULL ? mir_t2a(xmlGetText(xmlNode)) : NULL;

			xmlDestroyNode(xml);
		}
		if (xtarget == NULL)
			return;

		CMStringA target = ParseUrl(xtarget, "8:");
		CMStringA initiator = ParseUrl(xinitiator, "8:");
		RemoveChatContact(_A2T(chatname), target, target, true, initiator);

	}
	else if (!mir_strcmpi(messageType.c_str(), "ThreadActivity/TopicUpdate"))
	{
		//content=<topicupdate><eventtime>1429532702130</eventtime><initiator>8:user</initiator><value>test topic</value></topicupdate>
		ptrA xinitiator, value;
		HXML xml = xmlParseString(ptrT(mir_a2t(content.c_str())), 0, _T("topicupdate"));
		if (xml != NULL) {
			HXML xmlNode = xmlGetChildByPath(xml, _T("initiator"), 0);
			xinitiator = xmlNode != NULL ? mir_t2a(xmlGetText(xmlNode)) : NULL;

			xmlNode = xmlGetChildByPath(xml, _T("value"), 0);
			value = xmlNode != NULL ? mir_t2a(xmlGetText(xmlNode)) : NULL;

			xmlDestroyNode(xml);
		}

		CMStringA initiator = ParseUrl(xinitiator, "8:");
		RenameChat(chatname, value);
		ChangeChatTopic(chatname, value, initiator);
	}
	else if (!mir_strcmpi(messageType.c_str(), "ThreadActivity/RoleUpdate"))
	{
		//content=<roleupdate><eventtime>1429551258363</eventtime><initiator>8:user</initiator><target><id>8:user1</id><role>admin</role></target></roleupdate>
		ptrA xinitiator, xId, xRole;
		HXML xml = xmlParseString(ptrT(mir_a2t(content.c_str())), 0, _T("roleupdate"));
		if (xml != NULL) {
			HXML xmlNode = xmlGetChildByPath(xml, _T("initiator"), 0);
			xinitiator = xmlNode != NULL ? mir_t2a(xmlGetText(xmlNode)) : NULL;

			xmlNode = xmlGetChildByPath(xml, _T("target"), 0);
			if (xmlNode != NULL)
			{
				HXML xmlId = xmlGetChildByPath(xmlNode, _T("id"), 0);
				HXML xmlRole = xmlGetChildByPath(xmlNode, _T("role"), 0);
				xId = xmlId != NULL ? mir_t2a(xmlGetText(xmlId)) : NULL;
				xRole = xmlRole != NULL ? mir_t2a(xmlGetText(xmlRole)) : NULL;
			}
			xmlDestroyNode(xml);
			
			CMStringA initiator = ParseUrl(xinitiator, "8:");
			CMStringA id = ParseUrl(xId, "8:");

			GCDEST gcd = { m_szModuleName, _A2T(chatname), !mir_strcmpi(xRole, "Admin") ? GC_EVENT_ADDSTATUS : GC_EVENT_REMOVESTATUS };
			GCEVENT gce = { sizeof(gce), &gcd };
			ptrT tszId(mir_a2t(id));
			ptrT tszRole(mir_a2t(xRole));
			ptrT tszInitiator(mir_a2t(initiator));
			gce.pDest = &gcd;
			gce.dwFlags = GCEF_ADDTOLOG;
			gce.ptszNick = tszId;
			gce.ptszUID = tszId;
			gce.ptszText = tszInitiator;
			gce.time = time(NULL);
			gce.bIsMe = IsMe(id);
			gce.ptszStatus = TranslateT("Admin");
			CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
		}
	}
}
void
BluetoothServiceChildProcess::StartDiscoveryInternal(
  BluetoothReplyRunnable* aRunnable)
{
  SendRequest(aRunnable, StartDiscoveryRequest());
}
Ejemplo n.º 8
0
//用设备档案表中的注册号更改端口及终端的注册号
bool COperator::ModifyDocRegister(TSSmartDocEx *pDocEx, TSSmartDoc *pDoc, TSCmdBuffer *pBuffer, int nPort, char *szOldReg)
{
	unsigned char newRegNo[4];
	char  szNewReg[32];
	bool bRet = false;

	strcpy(szNewReg, pDoc->DeviceInfo.sRegNo);
	strcpy(pDoc->DeviceInfo.sRegNo, szOldReg);

	unsigned char sID[256];

	memset(sID, 0, sizeof(sID));
	SVC_DSP_2_HEX((BYTE*)pDoc->m_szDeviceID, sID, 4);
	sID[4] = pDoc->DeviceInfo.nAddr;

	MakeBuf_SetAddr(&pDoc->DeviceInfo, pBuffer, sID);
	for(int k=0; k<3; k++)
	{
		if( SendRequest(pDoc, pBuffer) == RET_OK )
		{
			if( UnMakeDeviceBuffer(pBuffer) == RET_OK && !pBuffer->pBuffer[2] )
			{
				bRet = true;
				break;
			}
		}
		else
		{
			Sleep(200);
		}
	}

	if( !bRet )
	{
		strcpy(pDoc->DeviceInfo.sRegNo, szNewReg);
		return false;
	}

#if 0	
	MakeBuf_GetID(&pDoc->DeviceInfo, pBuffer);
	for(int k=0; k<3; k++)
	{
		if(SendRequest(pDoc, pBuffer) == RET_OK )
		{
			if( UnMakeDeviceBuffer(pBuffer) == RET_OK && !pBuffer->pBuffer[2] )
			{
				unsigned char szTemp[256];
				unsigned char *pHardBuffer = pBuffer->pBuffer+4;

				memset(szTemp, 0, sizeof(szTemp));
				SVC_HEX_2_DSP(pHardBuffer, szTemp, 4);

				if( strcmp(pDoc->m_szDeviceID, ( char*)szTemp) )
				{
					printf("设备ID不同, 不能更改注册号!\n");
					strcpy(pDoc->DeviceInfo.sRegNo, szNewReg);
					return false;
				}
				else
				{
					bRet = true;
					break;
				}
			}
		}
		else
		{
			Sleep(1000);
		}
	}
#endif 

/*	MakeBuf_SearchPort(&pDocEx->pChildDoc[0]->DeviceInfo, pBuffer, nPort);
	if( SendRequest(pDocEx->pChildDoc[0], pBuffer) == RET_OK )
	{
		UnMakeDeviceBuffer(pBuffer);
	}
*/
	bRet = false ;
	for( k =0; k < 3; k++ )
	{
		MakeBuf_GetPortPar(&pDocEx->pChildDoc[0]->DeviceInfo, pBuffer, nPort);
		if( SendRequest(pDocEx->pChildDoc[0], pBuffer) == RET_OK )
		{
			if( UnMakeDeviceBuffer(pBuffer) == RET_OK && !pBuffer->pBuffer[2] ) 
			{
				unsigned char sPortID[16];
				memset(sPortID, 0, sizeof(sPortID));

				SVC_HEX_2_DSP(&pBuffer->pBuffer[4], sPortID, 4);

			//	strcpy(pDoc->DeviceInfo.sRegNo, (char*)sPortID);
				bRet = true;
				break;
			}
		}
		else
		{
			Sleep(1000);
		}
	}

	if( !bRet )
	{
		strcpy(pDoc->DeviceInfo.sRegNo, szNewReg);
		return bRet;
	}

	int nOldAdd = pDoc->DeviceInfo.nAddr;
	pDoc->DeviceInfo.nAddr = pBuffer->pBuffer[8];

	bRet = false;
	SVC_DSP_2_HEX((unsigned char*)pDoc->m_szRegister, newRegNo, 4);
	MakeBuf_SetRegNo(&pDoc->DeviceInfo, pBuffer, newRegNo);

	for(k=0; k<3; k++)
	{
		if( SendRequest(pDoc, pBuffer) == RET_OK )
		{
			if( UnMakeDeviceBuffer(pBuffer) == RET_OK && !pBuffer->pBuffer[2] )
			{
				printf("修改注册号成功!\n");
				bRet = true;
				break;
			}
		}
		else
		{
			Sleep(1000);
		}
	}

	if( !bRet )
	{
		strcpy(pDoc->DeviceInfo.sRegNo, szNewReg);
		pDoc->DeviceInfo.nAddr = nOldAdd;
		return bRet;
	}

	bRet = false;
	for(int i=0;i<3;i++)
	{
		MakeBuf_SetPortRegNoAndMacNo(
			pDocEx->pDeviceInfo, pBuffer, nPort, newRegNo, nOldAdd);
		if(SendRequest(pDocEx->pChildDoc[0], pBuffer) == RET_OK )
		{
			if( UnMakeDeviceBuffer(pBuffer) == RET_OK && !pBuffer->pBuffer[2] )
			{
				bRet = true;
				break;
			}
		}
	}
	return bRet;
}
Ejemplo n.º 9
0
	bool Peer::SendPeers(const protocol::Peers &db_peers, std::error_code &ec) {
		return SendRequest(protocol::OVERLAY_MSGTYPE_PEERS, db_peers.SerializeAsString(), ec);
	}
Ejemplo n.º 10
0
//修改注册号
bool COperator::ModifyRegister(TSSmartDoc *pDoc, TSCmdBuffer *pBuffer)
{
	unsigned char newRegNo[4];
	bool bRet = false;

	unsigned char sID[256];

	memset(sID, 0, sizeof(sID));
	SVC_DSP_2_HEX((BYTE*)pDoc->m_szDeviceID, sID, 4);
	sID[4] = pDoc->DeviceInfo.nAddr;

	MakeBuf_SetAddr(&pDoc->DeviceInfo, pBuffer, sID);
	for(int k=0; k<3; k++)
	{
		if( SendRequest(pDoc, pBuffer) == RET_OK )
		{
			if( UnMakeDeviceBuffer(pBuffer) == RET_OK && !pBuffer->pBuffer[2] )
			{
				bRet = true;
				break;
			}
		}
	}

#if 0 
	MakeBuf_GetID(&pDoc->DeviceInfo, pBuffer);
	for(int k=0; k<3; k++)
	{
		if(SendRequest(pDoc, pBuffer) == RET_OK )
		{
			if( UnMakeDeviceBuffer(pBuffer) == RET_OK && !pBuffer->pBuffer[2] )
			{
				unsigned char szTemp[256];
				unsigned char *pHardBuffer = pBuffer->pBuffer+4;

				memset(szTemp, 0, sizeof(szTemp));
				SVC_HEX_2_DSP(pHardBuffer, szTemp, 4);

				if( strcmp(pDoc->m_szDeviceID, ( char*)szTemp) )
				{
					printf("设备ID不同, 不能更改注册号!\n");
					return false;
				}
				else
				{
					//strcpy(pDoc->m_szDeviceID, ( char*)szTemp);
					bRet = true;
					break;
				}
			}
		}
	}
#endif

	if( !bRet )
	{
		printf("设备ID不同, 不能更改注册号!\n");
		return false;
	}

	bRet = false;
	MakeBuf_Debug_GetMainPar(&pDoc->DeviceInfo, pBuffer);
	for(k=0; k<3; k++)
	{
		if( SendRequest(pDoc, pBuffer) == RET_OK )
		{
			if( UnMakeDeviceBuffer(pBuffer) == RET_OK && !pBuffer->pBuffer[2] )
			{
				char szReg[32];
				memset(szReg, 0, sizeof(szReg));

				if( !strcmp(pDoc->m_szMacCode, "5301") || pDoc->m_nParentID > 0 )
					SVC_HEX_2_DSP(pBuffer->pBuffer+8, (unsigned char*)szReg, 4);
				else
					SVC_HEX_2_DSP(pBuffer->pBuffer+4, (unsigned char*)szReg, 4);

				strcpy(pDoc->m_szRegister, ( char*)szReg);
				strcpy(pDoc->DeviceInfo.sRegNo, ( char*)szReg);

				printf("机器正在使用的注册号........%s...!\n", ( char*)szReg);

				bRet = true;
				break;
			}
		}
	}

	if( !bRet )
	{
		return false;
	}

	bRet = false;
	switch( GetMachineType(pDoc) )
	{
	case MACHINE_TYPE_5301:
		{
			for(int i=0;i<3;i++)
			{
				SVC_DSP_2_HEX((unsigned char *)pDoc->m_szRegister, newRegNo, 4);
				MakeBuf_SetLportNewRegNo(&pDoc->DeviceInfo, pBuffer, newRegNo);
				if(SendRequest(pDoc, pBuffer) == RET_OK )
				{
					if( UnMakeDeviceBuffer(pBuffer) == RET_OK && !pBuffer->pBuffer[2] )
					{
						bRet = true;
						break;
					}
				}
			}
		}
		break;
	case MACHINE_TYPE_0201://增值机
	case MACHINE_TYPE_0226://收费机
	case MACHINE_TYPE_0228://车载机
	case MACHINE_TYPE_0230://管理机
	case MACHINE_TYPE_0232://上机上网机
	case MACHINE_TYPE_0234://淋浴管理机
	case MACHINE_TYPE_0240://售票机
	case MACHINE_TYPE_0130://身份识别机
	case MACHINE_TYPE_0140://检票机
	case MACHINE_TYPE_0248://上海理工转帐机
		{
			//查询终端
			CString strSQL;
			strSQL.Format("SELECT * FROM Smart_Machine WHERE SMT_Authno = %d", pDoc->m_nAuthID);
			unsigned char sBuffer[256];
			char sValue[256];
	
		//	GetFieldStringValueEx(nRec, "Smt_RegNo", (char*)sValue);
		//	SVC_DSP_2_HEX(sValue, sBuffer, 4);

			for(int i=0;i<3;i++)
			{
				MakeBuf_SetRegNo(&pDoc->DeviceInfo, pBuffer, sBuffer);
				if(SendRequest(pDoc, pBuffer) == RET_OK )
				{
					if( UnMakeDeviceBuffer(pBuffer) == RET_OK && !pBuffer->pBuffer[2] )
					{
						strcpy(pDoc->m_szRegister, ( char*)sValue);
						strcpy(pDoc->DeviceInfo.sRegNo, ( char*)sValue);
						//bRet = true;
						printf("更改注册号为........%s...!\n", ( char*)sValue);
						break;
					}
				}
			}
		}
		break;
	default:
		break;
	}
	return bRet;
}
Ejemplo n.º 11
0
//修改注册号
bool COperator::ModifyRegisterEx(TSSmartDocEx *pDocEx, TSCmdBuffer *pBuffer, int nPort)
{
	bool bRet = false;
	unsigned char Buffer[256];

	switch(GetMachineType(pDocEx->pChildDoc[pDocEx->nPortNo]) )
	{
	case MACHINE_TYPE_5301:
		{
			TSDeviceInfo  Info;

			bool bFound = false;
			unsigned char  sPortID[16];
			memset(sPortID, 0, sizeof(sPortID));

			for( int p=0; p<3; p++)
			{
				MakeBuf_SearchPort(&pDocEx->pChildDoc[0]->DeviceInfo, pBuffer, nPort);
				if( SendRequest(pDocEx->pChildDoc[0], pBuffer) == RET_OK )
				{
					if( UnMakeDeviceBuffer(pBuffer) == RET_OK && !pBuffer->pBuffer[2] ) 
					{
						bFound = true;
						break;
					}
				}
			}

			if( !bFound )
			{
				printf("搜索端口%d失败! 不能修改端口注册号!\n", nPort);
				return false;
			}

			bFound = false ;

			for( p =0; p < 3; p++ )
			{
				MakeBuf_GetPortPar(&pDocEx->pChildDoc[pDocEx->nPortNo]->DeviceInfo, pBuffer, nPort);
				if( SendRequest(pDocEx->pChildDoc[0], pBuffer) == RET_OK )
				{
					if( UnMakeDeviceBuffer(pBuffer) == RET_OK && !pBuffer->pBuffer[2] ) 
					{
						bFound = true;
						SVC_HEX_2_DSP(&pBuffer->pBuffer[4], sPortID, 4);
						break;
					}
				}
			}

			if( !bFound )
			{
				printf("得到端口%d的设备失败! 不能修改端口注册号!\n", nPort);
				return false;
			}

			//匹配原来端口的硬件
			int nIndex = GetPos(pDocEx, nPort);
			if( nIndex <= 0 )
			{
				printf("端口%d有硬件变动! 设备档案表中没有此终端记录! 设备ID:%s\n", nPort, sPortID);
/*				MakeBuf_ClearPortData(&pDocEx->pChildDoc[pDocEx->nPortNo]->DeviceInfo, pBuffer, nPort);
				if( SendRequest(pDocEx->pChildDoc[0], pBuffer) == RET_OK )
				{
					if( UnMakeDeviceBuffer(pBuffer) == RET_OK && !pBuffer->pBuffer[2] ) 
					{
						return true;
					}
				}*/
				return false;
			}

			//比较设备ID
			if( strcmp((char*)sPortID, pDocEx->pChildDoc[nIndex]->m_szDeviceID) )
			{
				printf("端口%d的设备已更换, 查找端口%d上新的相关设备!\n", nPort, nPort);
				nIndex = GetPosEx(pDocEx, (char*)sPortID);
				if( nIndex <= 0 )
				{
					printf("端口%d(设备ID:%s) 与终端设备%s的设备ID不同, 不能修改端口注册号!\n", 
						nPort, sPortID, pDocEx->pChildDoc[nIndex]->m_szRegister);
					return false;
				}
			}

/*			if( pBuffer->pBuffer[8] != pDocEx->pChildDoc[nIndex]->DeviceInfo.nAddr )
			{
				printf("端口%d(机号:%d) 与终端设备%s(机号:%d)的机号不同, 不能修改端口注册号!\n", nPort, pBuffer->pBuffer[8] ,
					pDocEx->pChildDoc[nIndex]->m_szRegister, pDocEx->pChildDoc[nIndex]->DeviceInfo.nAddr);
				return false;
			}
*/
			printf("端口:%d, 端口设备ID号:%s ,与终端设备ID相同, 准备修改端口注册号为:%s!\n", nPort, sPortID, pDocEx->pChildDoc[nIndex]->m_szRegister);

			memcpy(&Info, &pDocEx->pChildDoc[nIndex]->DeviceInfo, sizeof(Info));

			//更改Lport服务器该端口注册号
			for( int n=0; n<3; n++)
			{
				SVC_DSP_2_HEX((unsigned char *)pDocEx->pChildDoc[nIndex]->m_szRegister, Buffer, 4);
				MakeBuf_SetPortRegNoAndMacNo(
					pDocEx->pDeviceInfo, pBuffer, nPort, Buffer, pDocEx->pChildDoc[nIndex]->DeviceInfo.nAddr);
				if ( SendRequest(pDocEx->pChildDoc[0], pBuffer) == RET_OK )
				{
					if( UnMakeDeviceBuffer(pBuffer) == RET_OK && !pBuffer->pBuffer[2] ) 
					{
						CString strText;

						strText.Format("端口%d注册号与实际注册号不符! 修改端口%d注册号成功!", nPort, nPort); 
						ReportLog(pDocEx, NULL, RET_OK, "实时收集", strText.GetBuffer(0)); 
						printf("%s\n", strText.GetBuffer(0));
						bRet = true;
						break;
					}
				}
			}
		}
		break;
	default:
		break;
	}

	return bRet;
}
Ejemplo n.º 12
0
void CChatControl::Timer()
{
	int ChatConnects = 0;

	
	if(m_TryUltraCache > 0)
		m_TryUltraCache--;

	if(m_ServerList.size() == 0)
		m_UltraCacheMode = false;


	// Manage connected chat servers
	std::vector<CChatServer*>::iterator itServer;
	for(itServer = m_ServerList.begin(); itServer != m_ServerList.end(); itServer++)
	{
		if((*itServer)->m_Status == SOCK_CONNECTED)
		{
			ChatConnects++;
		}
		else
		{
			if((*itServer)->m_SecsDead > 5)
			{
				RemoveServer(*itServer);
				itServer--;
			}
			else
				(*itServer)->m_SecsDead++;
		}
	}



	// Send a connect request if we're connected and in the cache channel
	if(ChatConnects)
		if(m_UltraCacheMode)
		{
			if(m_SecsRequest > 50)
				m_SecsRequest = SendRequest() ? 0 : 50;
			else
				m_SecsRequest++;
		}


	// Chat window open
	if(m_pDoc->m_pViewChat)
	{
		if(m_AutoConnect)
		{
			bool ChatConnect = false;

			for(int i = 0; i < m_ServerList.size(); i++)
				if(m_ServerList[i]->m_Host == "irc.freenode.net")
					ChatConnect = true;

			if(!ChatConnect)
				GetConnect();
		}
	}

	// Chat window not open
	else if(m_AutoConnect)
	{
		if(ChatConnects)
		{
			if(!m_UltraCacheMode && m_TryUltraCache == 0)
				if(m_autNetwork->ClientMode() == CLIENT_LEAF || m_autPrefs->GetMinConnects() != -1 && m_autNetwork->GetNormalConnectedCount() >= m_autPrefs->GetMinConnects())
					RemoveServer( m_ServerList[0] );
		}
		else
		{
			if(m_autNetwork->GetNormalConnectedCount() == 0)
				GetConnect();

			m_UltraCacheMode = false;
			m_TryUltraCache  = 0;
		}
	}

	// Clean Chat Sockets
	std::vector<CChatServer*>::iterator itChat;
	for(itChat = m_ServerList.begin(); itChat != m_ServerList.end(); itChat++)
		if((*itChat)->m_Status == SOCK_CLOSED)
		{
			delete *itChat;
			m_ServerList.erase(itChat);

			itChat--;
		}

	// Remove old ident connects
	std::vector<CChatIdentd*>::iterator itIdent;
	for(itIdent = m_IdentdList.begin(); itIdent != m_IdentdList.end(); itIdent++)
	{
		(*itIdent)->m_SecsAlive++;

		if((*itIdent)->m_SecsAlive >= 10)
		{
			delete *itIdent;
			m_IdentdList.erase(itIdent);

			itIdent--;
		}
	}

}
Ejemplo n.º 13
0
INT_PTR CSkypeProto::UnblockContact(WPARAM hContact, LPARAM)
{
	SendRequest(new UnblockContactRequest(li, ptrA(db_get_sa(hContact, m_szModuleName, SKYPE_SETTINGS_ID))), &CSkypeProto::OnUnblockContact, (void *)hContact);
	return 0;
}
Ejemplo n.º 14
0
NS_IMETHODIMP
SmsIPCService::GetThreadList(nsISmsRequest* aRequest)
{
  SendRequest(GetThreadListRequest(), aRequest);
  return NS_OK;
}
Ejemplo n.º 15
0
void DuplicateConnector::OnSessionOpen( Session * session )
{
    auto s = scast<DuplicateSession*>( session );
    DuplicateSessionPool::Instance()->Push( s );
    s->SendRequest();
}
Ejemplo n.º 16
0
/* Analyze the request from browser and decide whether retrieve from
 * cache or connect to the server*/
void* request (void* data){
    pthread_detach(pthread_self());
    Signal(SIGPIPE,SIG_IGN);
    signal(SIGPIPE,SIG_IGN);
    int serverfd=*(int*)data;
    int clientfd;
    char headerBuff[MAXHEADERSIZE],Buffer[MAXBUFFERSIZE];
    char hostname[300],uriname[MAXHEADERSIZE],urlname[MAXHEADERSIZE];
    char* cache_buff;
    int getbyte,error;
    int cachehit = 0;
    int cache_size = 0;
    free(data);
    rio_t serverrio_t;

    rio_readinitb(&serverrio_t,serverfd);

    rio_readlineb(&serverrio_t,headerBuff,sizeof(headerBuff));
    if (takeHostUriUrl(headerBuff,hostname,uriname,urlname) ==0){
        perror("Get Host Uri Url error\n");
        close(serverfd);
        pthread_exit(NULL);
    }
    /* Try to get cached data, must check no thread writing the cache,
     *      * and use FILO architecture to lock when there threads reading cache*/

    P(&mutex);
    readcnt++;
    if(readcnt == 1)
        P(&w);
    V(&mutex);
    if( Get_cachedata(urlname,serverfd) > 0){
        cachehit = 1;
    }

    P(&mutex);
    readcnt--;
    if(readcnt == 0)
        V(&w);
    V(&mutex);

    if(cachehit){
        printf("Cache Hit!!!!\n");
        close(serverfd);
        pthread_exit(NULL);
    }




    if( (clientfd=socket(AF_INET,SOCK_STREAM,0))<0){
        perror("socket");
        close(serverfd);
        pthread_exit(NULL);
    }
    /*get server's address info*/
    struct addrinfo *hostinfo;
    if( (error=getaddrinfo(hostname,"http",NULL,&hostinfo)) >0){
        perror("hostinfo");
        close(serverfd);
        close(clientfd);
        pthread_exit(NULL);
    }
    /* connect to the server*/
    if( (connect(clientfd,hostinfo->ai_addr,hostinfo->ai_addrlen))<0){
        perror("connect");
        close(serverfd);
        close(clientfd);
        return NULL;
    }

    cache_buff = (char*) malloc(MAX_OBJECT_SIZE*sizeof(char));
    cache_size = 0;

    /* Send the request to the server */

    SendRequest(clientfd,serverrio_t,hostname,uriname);
    /*read the information from web server and send it to browser*/
    while(1){
        getbyte = rio_readn(clientfd,Buffer,sizeof(Buffer));
        if(getbyte <= 0 )
            break;
        if(cache_size + getbyte < MAX_OBJECT_SIZE){
            memcpy(cache_buff + cache_size,Buffer,getbyte);
        }
        cache_size += getbyte;

        rio_writen(serverfd,Buffer,getbyte);
    }
    /* if size fit in cache, write into cache, else free the content*/
    if(cache_size < MAX_OBJECT_SIZE){
        char* new_cache_buff = realloc(cache_buff,cache_size);
        free(cache_buff);
        if(new_cache_buff == NULL){
            perror("Realloc fail\n");
            close(clientfd);
            close(serverfd);
            pthread_exit(NULL);
        }

        P(&w);
        char *saveurlname = (char*)malloc(strlen(urlname)*sizeof(char));
        memcpy(saveurlname,urlname,strlen(urlname));
        Create_cache(saveurlname,new_cache_buff,cache_size);
        V(&w);

    }
    else{
        free(cache_buff);
    }


    close(clientfd);
    close(serverfd);
    pthread_exit(NULL);

}
Ejemplo n.º 17
0
int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam)
{
	GCHOOK *gch = (GCHOOK*)lParam;
	if (!gch)
	{
		return 1;
	}
	else if (mir_strcmp(gch->pDest->pszModule, m_szModuleName) != 0)
	{
		return 0;
	}

	ptrA chat_id(mir_t2a(gch->pDest->ptszID));

	switch (gch->pDest->iType)
	{
	case GC_USER_MESSAGE:
	{
		OnSendChatMessage(gch->pDest->ptszID, gch->ptszText);
		break;
	}

	case GC_USER_PRIVMESS:
	{
		MCONTACT hContact = FindContact(_T2A(gch->ptszUID));
		if (hContact == NULL)
		{
			hContact = AddContact(_T2A(gch->ptszUID), true);
			setWord(hContact, "Status", ID_STATUS_ONLINE);
			db_set_b(hContact, "CList", "Hidden", 1);
			setTString(hContact, "Nick", gch->ptszUID);
			db_set_dw(hContact, "Ignore", "Mask1", 0);
		}
		CallService(MS_MSG_SENDMESSAGET, hContact, 0);
		break;
	}

	case GC_USER_LOGMENU:
	{
		switch (gch->dwData)
		{
		case 10: {
			CSkypeInviteDlg dlg(this);
			if(!dlg.DoModal())
			{
				break;
			}
			MCONTACT hContact = dlg.m_hContact;
			if (hContact != NULL)
			{
				ptrA username(db_get_sa(hContact, m_szModuleName, SKYPE_SETTINGS_ID));
				SendRequest(new InviteUserToChatRequest(m_szRegToken, chat_id, username, "User", m_szServer));
			}
			break;
		}
		case 20:
			OnLeaveChatRoom(FindChatRoom(chat_id), NULL);
			break;
		case 30:
			CMString newTopic = ChangeTopicForm();
			if (!newTopic.IsEmpty())
				SendRequest(new SetChatPropertiesRequest(m_szRegToken, chat_id, "topic", ptrA(mir_utf8encodeT(newTopic.GetBuffer())), m_szServer));
			break;
		}
		break;
	}

	case GC_USER_NICKLISTMENU:
	{
		ptrA user_id;
		if (gch->dwData == 10 || gch->dwData == 30 || gch->dwData == 40)
		{
			user_id = mir_t2a_cp(gch->ptszUID, CP_UTF8);
		}

		switch (gch->dwData)
		{
		case 10:
			SendRequest(new KickUserRequest(m_szRegToken, chat_id, user_id, m_szServer));
			break;
		case 30:
			SendRequest(new InviteUserToChatRequest(m_szRegToken, chat_id, user_id, "Admin", m_szServer));
			break;
		case 40:
			SendRequest(new InviteUserToChatRequest(m_szRegToken, chat_id, user_id, "User", m_szServer));
			break;
		}

		break;

	}
	}
	return 0;
}
Ejemplo n.º 18
0
XOSD
EXPENTRY
TLFunc(
    TLF   wCommand,
    HPID  hpid,
    DWORD64 wParam,
    DWORD64 lParam
    )
/*++

Routine Description:

    This function contains the dispatch loop for commands comming into
    the transport layer.  The address of this procedure is exported to
    users of the DLL.

Arguments:

    wCommand - Supplies the command to be executed.

    hpid - Supplies the hpid for which the command is to be executed.

    wParam - Supplies information about the command.

    lParam - Supplies information about the command.

Return Value:

    XOSD error code.  xosdNone means that no errors occured.  Other
    error codes are defined in osdebug\include\od.h.

--*/

{
    int        cb;
    LPSTR      p;
    MPACKET *  pMpckt;
    XOSD       xosd = xosdNone;
    LPDBB      lpdbb;
    AVS        dmavs = {0};


    switch ( wCommand ) {
        case tlfInit:
            DEBUG_OUT("TlFunc:  tlfInit\n");
            lpdbf = (LPDBF) wParam;
            TLCallBack = (TLCALLBACKTYPE) lParam;

            TlpLocalInit();
            break;

        case tlfLoadDM:

            assert(!FDMSide);
            //
            // If this is the debugger side, send the data across the wire
            // to the stub side.
            //
            // what happens if the stub already loaded a dm?
            //

            xosd = LoadRemoteDM(hpid, (LPLOADDMSTRUCT)lParam);


            break;


        case tlfDestroy:
            DEBUG_OUT("TlFunc:  tlfDestroy\n");
            if (LpDmInit != NULL) {
                LpDmInit(NULL, NULL);
            }
            if (HDm != NULL) {
                FreeLibrary(HDm);
                HDm = NULL;
                LpDmInit = NULL;
                LpDmFunc = NULL;
            }
            if (LpUiServer) {
                DEBUG_OUT(("NL: tlcbDisconnect\n"));
                LpUiServer(tlcbDisconnect, 0, 0, 0, 0);
            }

            TlDestroyTransport();

            TlpWaitForThreadsToExit();
            TlpLocalDestroy();
            FConnected = FALSE;

            DEBUG_OUT(("NL: tlfDestroy exit\n"));
            break;

        case tlfGetProc:
            DEBUG_OUT("TlFunc:  tlfGetProc\n");
            *((TLFUNCTYPE FAR *) lParam) = TLFunc;
            break;

        case tlfConnect:
            DEBUG_OUT("TlFunc:  tlfConnect\n");
            if (hpid) {
                hpidRoot = hpid;
            } else {
                if (lParam) {
                    if (TlCreateTransport(NULL) != xosdNone) {
                        xosd = xosdCannotConnect;
                    }
                    else if ((xosd = TlConnectTransport()) == xosdNone) {
                        FConnected = TRUE;
                        strncpy( (LPSTR)lParam, ClientId, (size_t)wParam );
                    }
                } else {
                    if (TlCreateClient(NULL) != xosdNone) {
                        xosd = xosdCannotConnect;
                    } else {
                        FConnected = TRUE;
                    }
                }
            }
            break;

        case tlfDisconnect:
            DEBUG_OUT("TlFunc:  tlfDisconnect\n");
            TlDestroyTransport();
            FConnected = FALSE;
            break;

        case tlfRemoteQuit:
            DEBUG_OUT("TlFunc:  tlfRemoteQuit\n");

            //
            // tell the dm that it is disconnected from the debugger
            //
            //
            // This can happen before the DM is initialized...
            //
            if (LpDmFunc) {
                lpdbb = (LPDBB)Rgb;
                lpdbb->dmf = dmfRemoteQuit;
                lpdbb->hpid = 0;
                lpdbb->htid = 0;
                LpDmFunc(sizeof(*lpdbb), (char *) lpdbb);
            }

            TlDisconnectTransport();
            break;

        case tlfSetBuffer:
            DEBUG_OUT("TlFunc:  tlfSetBuffer\n");
            lpbDM = (LPB) lParam;
            ibMaxDM = (DWORD)wParam;
            break;

        case tlfDebugPacket:
            DEBUG_OUT("TlFunc:  tlfDebugPacket\n");
            if (!FConnected) {
                xosd = xosdLineNotConnected;
            } else if (wParam > MAX_INTERNAL_PACKET) {
                pMpckt = (MPACKET * ) Pnlblk->rgchData;
                Pnlblk->mtypeBlk = mtypeAsyncMulti;
                Pnlblk->hpid = hpid;
                Pnlblk->cchMessage = MAX_INTERNAL_PACKET + sizeof(MPACKET);
                Pnlblk->seq = ++pkSeq;
                pMpckt->packetNum = 0;

                pMpckt->packetCount = (((short)wParam + MAX_INTERNAL_PACKET - 1) /
                                       MAX_INTERNAL_PACKET);
                while (wParam > MAX_INTERNAL_PACKET) {
                    memcpy(pMpckt->rgchData, (LPB) lParam, MAX_INTERNAL_PACKET);
                    xosd = SendData(Pnlblk, sizeof(NLBLK) + sizeof(MPACKET) +
                                    MAX_INTERNAL_PACKET);
                    if (xosd != xosdNone) {
                        return xosdUnknown;
                    }
                    wParam -= MAX_INTERNAL_PACKET;
                    lParam += MAX_INTERNAL_PACKET;

                    pMpckt->packetNum += 1;
                }

                memcpy(pMpckt->rgchData, (LPB) lParam, (size_t) wParam);

                Pnlblk->cchMessage = (short)(wParam + sizeof(MPACKET));

                xosd = SendData(Pnlblk, (LPARAM)(sizeof(NLBLK) + sizeof(MPACKET) + wParam));
            } else {
                Pnlblk->mtypeBlk = mtypeAsync;

                Pnlblk->hpid = hpid;
                Pnlblk->cchMessage = (short)wParam;
                Pnlblk->seq = ++pkSeq;

                memcpy(Pnlblk->rgchData, (LPB) lParam, (size_t) wParam);
                xosd = SendData(Pnlblk, (LPARAM)(sizeof(NLBLK) + wParam));
            }
            break;


        case tlfReply:
            DEBUG_OUT("TlFunc:  tlfReply\n");
#if DBG
            EnterCriticalSection(&csExpecting);
            assert(FExpectingReply);
            FExpectingReply = 0;
            LeaveCriticalSection(&csExpecting);
#endif
            if (!FConnected) {
                xosd = xosdLineNotConnected;
            } else if (wParam > MAX_INTERNAL_PACKET) {
                pMpckt = (MPACKET * ) PnlblkRp->rgchData;
                PnlblkRp->mtypeBlk = mtypeReplyMulti;
                PnlblkRp->hpid = hpid;
                PnlblkRp->cchMessage = MAX_INTERNAL_PACKET + sizeof(MPACKET);
                PnlblkRp->seq = ++pkSeq;
                pMpckt->packetNum = 0;

                pMpckt->packetCount = (((short)wParam + MAX_INTERNAL_PACKET - 1) /
                                       MAX_INTERNAL_PACKET);
                while (wParam > MAX_INTERNAL_PACKET) {
                    memcpy(pMpckt->rgchData, (LPB) lParam, MAX_INTERNAL_PACKET);
                    xosd = SendData(PnlblkRp, sizeof(NLBLK) + sizeof(MPACKET) +
                                    MAX_INTERNAL_PACKET);
                    if (xosd != xosdNone) {
                        return xosdUnknown;
                    }
                    wParam -= MAX_INTERNAL_PACKET;
                    lParam += MAX_INTERNAL_PACKET;

                    pMpckt->packetNum += 1;
                }

                memcpy(pMpckt->rgchData, (LPB) lParam, (size_t) wParam);

                PnlblkRp->cchMessage = (short)(wParam + sizeof(MPACKET));

                xosd = SendData(PnlblkRp, (LPARAM)(sizeof(NLBLK) + sizeof(MPACKET) + wParam));
            } else {
                PnlblkRp->mtypeBlk = mtypeReply;

                PnlblkRp->hpid = hpid;
                PnlblkRp->cchMessage = (short)wParam;
                PnlblkRp->seq = ++pkSeq;

                memcpy(PnlblkRp->rgchData, (LPB) lParam, (size_t) wParam);
                xosd = SendData(PnlblkRp, (LPARAM)(sizeof(NLBLK) + wParam));
            }
            break;

        case tlfRequest:
            DEBUG_OUT("TlFunc:  tlfRequest\n");
            if ( !FConnected ) {
                xosd = xosdLineNotConnected;
            } else {
                cb = ibMaxDM;
                if (wParam > MAX_INTERNAL_PACKET) {
                    pMpckt = (MPACKET * ) PnlblkRq->rgchData;
                    PnlblkRq->mtypeBlk = mtypeSyncMulti;
                    PnlblkRq->hpid = hpid;
                    PnlblkRq->cchMessage = MAX_INTERNAL_PACKET + sizeof(MPACKET);
                    PnlblkRq->seq = ++pkSeq;
                    pMpckt->packetNum = 0;

                    pMpckt->packetCount = (((short)wParam + MAX_INTERNAL_PACKET - 1) /
                                           MAX_INTERNAL_PACKET);
                    while (wParam > MAX_INTERNAL_PACKET) {
                        memcpy(pMpckt->rgchData, (LPB) lParam, MAX_INTERNAL_PACKET);
                        xosd = SendData(PnlblkRq, sizeof(NLBLK) + sizeof(MPACKET) +
                                        MAX_INTERNAL_PACKET);
                        if (xosd != xosdNone) {
                            return xosdUnknown;
                        }
                        wParam -= MAX_INTERNAL_PACKET;
                        lParam += MAX_INTERNAL_PACKET;

                        pMpckt->packetNum += 1;
                    }

                    PnlblkRq->cchMessage = (short)(wParam + sizeof(MPACKET));

                    memcpy(pMpckt->rgchData, (LPB) lParam, (size_t) wParam);
                    xosd = SendRequest(mtypeReply,
                                       PnlblkRq,
                                       sizeof(NLBLK) + sizeof(MPACKET) + (int) wParam,
                                       lpbDM,
                                       &cb,
                                       TLFuncSendReplyTimeout
                                       );
                } else {
                    PnlblkRq->mtypeBlk = mtypeSync;

                    PnlblkRq->cchMessage = (short)wParam;
                    PnlblkRq->hpid = hpid;
                    PnlblkRq->seq = ++pkSeq;

                    memcpy(PnlblkRq->rgchData, (char *) lParam, (size_t) wParam);
                    xosd = SendRequest(mtypeReply,
                                       PnlblkRq,
                                       (int) wParam + sizeof(NLBLK),
                                       lpbDM,
                                       &cb,
                                       TLFuncSendReplyTimeout
                                       );
                }
            }
            break;

        case tlfGetVersion:
            DEBUG_OUT("TlFunc:  tlfGetVersion\n");
            {
                int cb = (int) wParam;
                //
                // Get the version information from the remote side.  If it doesn't
                // return anything in 10 seconds, time out and return 0's.
                //
                // lParam = buffer to fill in
                // wParam = size of buffer
                //
                // sets globals lpchVersionReply = lParam
                // cchVersionReplyMax = wParam
                //
                //

                DEBUG_OUT("NL: tlfGetVersion\n");
                if (!FConnected) {
                    DEBUG_OUT(("NL: tlfGetVersion not on line\n"));
                    xosd = xosdLineNotConnected;
                    break;
                }

                //
                // must be connected
                // basically works like a tlfRequest with a timeout and a
                // target in the transport rather than the DM/EM.
                //

                //
                // Create the desired packet.  The packet consists of:
                // type = mtypeVersionRequest
                // length = 0
                // hpid = current pid
                //

                Pnlblk->mtypeBlk = mtypeVersionRequest;

                Pnlblk->cchMessage = 0;
                Pnlblk->hpid = hpid;
                Pnlblk->seq = ++pkSeq;

                //
                // send the version request packet
                //

                xosd = SendRequest(mtypeVersionReply, Pnlblk,
                                   sizeof(NLBLK), (void *) lParam, &cb, 5);
                if (xosd == xosdNone) {
                } else {
                    memset((LPCH) lParam, 0, (size_t) wParam);
                }
                DEBUG_OUT("NL: tlfVersionCheck exit\n");
            }
            break;

        case tlfSendVersion:
            DEBUG_OUT("TlFunc:  tlfSendVersion\n");
            if (!FConnected) {
                return xosdLineNotConnected;
            } else {
                // Send the version information to
                // the other side.  This is in response to a mtypeVersionRequest
                // (tlfGetVersion)

                // Create a packet with the appropriate data packet
                // type = mtypeVersionReply cb = sizeof(Avs);
                // hpid = hpid
                // data = Version structure

                if (HDm) {
                    DBGVERSIONPROC verproc =
                       (DBGVERSIONPROC)GetProcAddress(HDm, DBGVERSIONPROCNAME);
                    dmavs = *verproc();
                } else {
                    dmavs = Avs;
                }

                Pnlblk->mtypeBlk = mtypeVersionReply;
                Pnlblk->hpid = hpid;
                Pnlblk->cchMessage = sizeof(AVS);
                Pnlblk->seq = ++pkSeq;
                memcpy(&Pnlblk->rgchData,(LPCH)&dmavs, sizeof(AVS));
                SendData(Pnlblk, sizeof(NLBLK) + sizeof(AVS));

                DEBUG_OUT(("Send Reply to version request packet\n"));
            }
            break;

        case tlfGetInfo:
            DEBUG_OUT("TlFunc:  tlfGetInfo\n");
            memcpy((LPVOID)lParam, TlGetInfo(), sizeof(TLIS));
            break;

        case tlfSetup:
            DEBUG_OUT("TlFunc:  tlfSetup\n");
            {
                LPTLSS lptlss = (LPTLSS)lParam;

                if (lptlss->fRMAttached) {
                    TlSetRemoteStatus(lptlss->mpt);
                }

                TlDoTlSetup(lptlss);
            }
            break;

        case tlfSetErrorCB:
            DEBUG_OUT("TlFunc:  tlfSetErrorCB\n");
            LpUiServer = (LPUISERVERCB) lParam;
            break;

        default:
            DEBUG_OUT("TlFunc:  **** unknown tlf ****\n");
            assert ( FALSE );
            break;
    }

    return xosd;
}
Ejemplo n.º 19
0
void HttpPostSocket::DoMultipartPost()
{
	long length = 0; // calculate content_length of our post body
	std::string tmp;

	// fields
	{
		for (std::map<std::string,std::list<std::string> >::iterator it = m_fields.begin(); it != m_fields.end(); ++it)
		{
			std::string name = (*it).first;
			std::list<std::string>& ref = (*it).second;
			tmp = "--" + m_boundary + "\r\n"
				"content-disposition: form-data; name=\"" + name + "\"\r\n"
				"\r\n";
			for (std::list<std::string>::iterator it = ref.begin(); it != ref.end(); ++it)
			{
				std::string value = *it;
				tmp += value + "\r\n";
			}
			length += (long)tmp.size();
		}
	}

	// files
	{
		for (std::map<std::string,std::string>::iterator it = m_files.begin(); it != m_files.end(); ++it)
		{
			std::string name = (*it).first;
			std::string filename = (*it).second;
			long content_length = m_content_length[filename];
			std::string content_type = m_content_type[filename];
			tmp = "--" + m_boundary + "\r\n"
				"content-disposition: form-data; name=\"" + name + "\"; filename=\"" + filename + "\"\r\n"
				"content-type: " + content_type + "\r\n"
				"\r\n";
			length += (long)tmp.size();
			length += content_length;
			length += 2; // crlf after file
		}
	}

	// end
	tmp = "--" + m_boundary + "--\r\n";
	length += (long)tmp.size();

	// build header, send body
	SetMethod("POST");
	SetHttpVersion( "HTTP/1.1" );
	AddResponseHeader( "Host", GetUrlHost() ); // oops - this is actually a request header that we're adding..
	AddResponseHeader( "User-agent", MyUseragent());
	AddResponseHeader( "Accept", "text/html, text/plain, */*;q=0.01" );
	AddResponseHeader( "Connection", "close" );
	AddResponseHeader( "Content-type", "multipart/form-data; boundary=" + m_boundary );
	AddResponseHeader( "Content-length", Utility::l2string(length) );

	SendRequest();

	// send fields
	{
		for (std::map<std::string,std::list<std::string> >::iterator it = m_fields.begin(); it != m_fields.end(); ++it)
		{
			std::string name = (*it).first;
			std::list<std::string>& ref = (*it).second;
			tmp = "--" + m_boundary + "\r\n"
				"content-disposition: form-data; name=\"" + name + "\"\r\n"
				"\r\n";
			for (std::list<std::string>::iterator it = ref.begin(); it != ref.end(); ++it)
			{
				std::string value = *it;
				tmp += value + "\r\n";
			}
			Send( tmp );
		}
	}

	// send files
	{
		for (std::map<std::string,std::string>::iterator it = m_files.begin(); it != m_files.end(); ++it)
		{
			std::string name = (*it).first;
			std::string filename = (*it).second;
			std::string content_type = m_content_type[filename];
			tmp = "--" + m_boundary + "\r\n"
				"content-disposition: form-data; name=\"" + name + "\"; filename=\"" + filename + "\"\r\n"
				"content-type: " + content_type + "\r\n"
				"\r\n";
			Send( tmp );
			{
				std::auto_ptr<IFile> fil = std::auto_ptr<IFile>(new File);
				if (fil -> fopen(filename, "rb"))
				{
					char slask[2000]; // for fread
					size_t n;
					while ((n = fil -> fread(slask, 1, 2000)) > 0)
					{
						SendBuf(slask, n);
					}
					fil -> fclose();
				}
			}
			Send("\r\n");
		}
	}

	// end of send
	Send("--" + m_boundary + "--\r\n");
}
Ejemplo n.º 20
0
XOSD EXPENTRY
DMTLFunc(
    TLF   wCommand,
    HPID  hpid,
    DWORD64 wParam,
    DWORD64 lParam
    )
{
    XOSD xosd = xosdNone;
    int cb;
    MPACKET * pMpckt;

    switch ( wCommand ) {
        case tlfInit:
            DEBUG_OUT( "DMTlFunc:  tlfInit\n" );
            break;

        case tlfDestroy:
            DEBUG_OUT( "DMTlFunc:  tlfDestroy\n" );
            break;

        case tlfConnect:
            DEBUG_OUT( "DMTlFunc:  tlfConnect\n" );
            break;

        case tlfDisconnect:
            DEBUG_OUT( "DMTlFunc:  tlfDisconnect\n" );
            TlDestroyTransport();
            FConnected = FALSE;
            break;

        case tlfSetBuffer: lpbDM = (LPB) lParam;
            DEBUG_OUT( "DMTlFunc:  tlfSetBuffer\n" );
            ibMaxDM = (DWORD)wParam;
            break;

        case tlfDebugPacket:
            DEBUG_OUT( "DMTlFunc:  tlfDebugPacket\n" );
            if (!FConnected) {
                xosd = xosdLineNotConnected;
            } else if (wParam > MAX_INTERNAL_PACKET) {
                pMpckt = (MPACKET * ) PnlblkDm->rgchData;
                PnlblkDm->mtypeBlk = mtypeAsyncMulti;
                PnlblkDm->hpid = hpid;
                PnlblkDm->cchMessage = MAX_INTERNAL_PACKET + sizeof(MPACKET);
                PnlblkDm->seq = ++pkSeq;
                pMpckt->packetNum = 0;

                pMpckt->packetCount = (((short)wParam + MAX_INTERNAL_PACKET - 1) /
                                       MAX_INTERNAL_PACKET);
                while (wParam > MAX_INTERNAL_PACKET) {
                    memcpy(pMpckt->rgchData, (LPB) lParam, MAX_INTERNAL_PACKET);
                    xosd = SendData(PnlblkDm, sizeof(NLBLK) + sizeof(MPACKET) +
                                    MAX_INTERNAL_PACKET);
                    if (xosd != xosdNone) {
                        return xosdUnknown;
                    }
                    wParam -= MAX_INTERNAL_PACKET;
                    lParam += MAX_INTERNAL_PACKET;

                    pMpckt->packetNum += 1;
                }

                memcpy(pMpckt->rgchData, (LPB) lParam, (size_t) wParam);

                PnlblkDm->cchMessage = (short)(wParam + sizeof(MPACKET));

                xosd = SendData(PnlblkDm, (LPARAM)(sizeof(NLBLK) + sizeof(MPACKET) + wParam));
            } else {
                PnlblkDm->mtypeBlk = mtypeAsync;

                PnlblkDm->hpid = hpid;
                PnlblkDm->cchMessage = (short)wParam;
                PnlblkDm->seq = ++pkSeq;

                memcpy(PnlblkDm->rgchData, (LPB) lParam, (size_t) wParam);
                xosd = SendData(PnlblkDm, (LPARAM)(sizeof(NLBLK) + wParam));
            }
            break;


        case tlfReply:
            DEBUG_OUT( "DMTlFunc:  tlfReply\n" );
#if DBG
            EnterCriticalSection(&csExpecting);
            assert(FExpectingReply);
            FExpectingReply = 0;
            LeaveCriticalSection(&csExpecting);
#endif
            if (!FConnected) {
                xosd = xosdLineNotConnected;
            } else if (wParam > MAX_INTERNAL_PACKET) {
                pMpckt = (MPACKET * ) PnlblkRp->rgchData;
                PnlblkRp->mtypeBlk = mtypeReplyMulti;
                PnlblkRp->hpid = hpid;
                PnlblkRp->cchMessage = MAX_INTERNAL_PACKET + sizeof(MPACKET);
                PnlblkRp->seq = ++pkSeq;
                pMpckt->packetNum = 0;

                pMpckt->packetCount = (((short)wParam + MAX_INTERNAL_PACKET - 1) /
                                       MAX_INTERNAL_PACKET);
                while (wParam > MAX_INTERNAL_PACKET) {
                    memcpy(pMpckt->rgchData, (LPB) lParam, MAX_INTERNAL_PACKET);
                    xosd = SendData(PnlblkRp, sizeof(NLBLK) + sizeof(MPACKET) +
                                    MAX_INTERNAL_PACKET);
                    if (xosd != xosdNone) {
                        return xosdUnknown;
                    }
                    wParam -= MAX_INTERNAL_PACKET;
                    lParam += MAX_INTERNAL_PACKET;

                    pMpckt->packetNum += 1;
                }

                memcpy(pMpckt->rgchData, (LPB) lParam, (size_t) wParam);

                PnlblkRp->cchMessage = (short)(wParam + sizeof(MPACKET));

                xosd = SendData(PnlblkRp, (LPARAM)(sizeof(NLBLK) + sizeof(MPACKET) + wParam));
            } else {
                PnlblkRp->mtypeBlk = mtypeReply;

                PnlblkRp->hpid = hpid;
                PnlblkRp->cchMessage = (short)wParam;
                PnlblkRp->seq = ++pkSeq;

                memcpy(PnlblkRp->rgchData, (LPB) lParam, (size_t) wParam);
                xosd = SendData(PnlblkRp, (LPARAM)(sizeof(NLBLK) + wParam));
            }
            break;


        case tlfRequest:
            DEBUG_OUT( "DMTlFunc:  tlfRequest\n" );
            if ( !FConnected ) {
                xosd = xosdLineNotConnected;
            } else {
                cb = ibMaxDM;
                if (wParam > MAX_INTERNAL_PACKET) {
                    pMpckt = (MPACKET * ) PnlblkRq->rgchData;
                    PnlblkRq->mtypeBlk = mtypeSyncMulti;
                    PnlblkRq->hpid = hpid;
                    PnlblkRq->cchMessage = MAX_INTERNAL_PACKET + sizeof(MPACKET);
                    PnlblkRq->seq = ++pkSeq;
                    pMpckt->packetNum = 0;

                    pMpckt->packetCount = (((short)wParam + MAX_INTERNAL_PACKET - 1) /
                                           MAX_INTERNAL_PACKET);
                    while (wParam > MAX_INTERNAL_PACKET) {
                        memcpy(pMpckt->rgchData, (LPB) lParam, MAX_INTERNAL_PACKET);
                        xosd = SendData(PnlblkRq, sizeof(NLBLK) + sizeof(MPACKET) +
                                        MAX_INTERNAL_PACKET);
                        if (xosd != xosdNone) {
                            return xosdUnknown;
                        }
                        wParam -= MAX_INTERNAL_PACKET;
                        lParam += MAX_INTERNAL_PACKET;

                        pMpckt->packetNum += 1;
                    }

                    PnlblkRq->cchMessage = (short)(wParam + sizeof(MPACKET));

                    memcpy(pMpckt->rgchData, (LPB) lParam, (size_t) wParam);
                    xosd = SendRequest(mtypeReply,
                                       PnlblkRq,
                                       sizeof(NLBLK) + sizeof(MPACKET) + (int) wParam,
                                       lpbDM,
                                       &cb,
                                       DMTLFuncSendReplyTimeout
                                       );
                } else {
                    PnlblkRq->mtypeBlk = mtypeSync;
                    PnlblkRq->cchMessage = (short)wParam;
                    PnlblkRq->hpid = hpid;
                    PnlblkRq->seq = ++pkSeq;
                    memcpy(PnlblkRq->rgchData, (char *) lParam, (size_t) wParam);
                    xosd = SendRequest(mtypeReply,
                                       PnlblkRq,
                                       (int) wParam + sizeof(NLBLK),
                                       lpbDM,
                                       &cb,
                                       DMTLFuncSendReplyTimeout
                                       );
                }
            }
            break;

        default:
            DEBUG_OUT( "DMTlFunc:  **** unknown tlf ****\n" );
            assert ( FALSE );
            break;
    }
    return xosd;
}
void
BluetoothServiceChildProcess::RejectObexAuth(BluetoothReplyRunnable* aRunnable)
{
  SendRequest(aRunnable, RejectObexAuthRequest());
}
Ejemplo n.º 22
0
void
w1394_AsyncStream(
                  HWND         hWnd,
                  __in PSTR    szDeviceName)
{
    ASYNC_STREAM    asyncStream;
    PASYNC_STREAM pAsyncStream = NULL;
    DWORD           dwRet, bytesReturned;
    ULONG             ulBufferSize = sizeof (ASYNC_STREAM);
    ULONG             i; 

    UNREFERENCED_PARAMETER(szDeviceName);

    TRACE(TL_TRACE, (hWnd, "Enter w1394_AsyncStream\r\n"));

    asyncStream.nNumberOfBytesToStream = 8;
    asyncStream.fulFlags = 0;
    asyncStream.ulTag = 0;
    asyncStream.nChannel = 0;
    asyncStream.ulSynch = 0;
    asyncStream.nSpeed = SPEED_FLAGS_FASTEST;

    if (DialogBoxParam( (HINSTANCE) GetWindowLongPtr(hWnd, GWLP_HINSTANCE),
                        "AsyncStream",
                        hWnd,
                        AsyncStreamDlgProc,
                        (LPARAM)&asyncStream))
    {

        ulBufferSize += asyncStream.nNumberOfBytesToStream;
        pAsyncStream = (PASYNC_STREAM) LocalAlloc (LPTR, ulBufferSize);
        if (NULL == pAsyncStream)
        {
            TRACE (TL_WARNING, (hWnd, "Failed to allocate asyncStream\n"));
            return;
        }

        pAsyncStream = &asyncStream;
       

        for (i=0; i < (asyncStream.nNumberOfBytesToStream / sizeof(ULONG)); i++) 
        {
            TRACE(TL_TRACE, (hWnd, "Quadlet[0x%x] = 0x%x\r\n", i, (PULONG)&pAsyncStream->Data[i]));
        }

        dwRet = SendRequest (
                                IOCTL_ASYNC_STREAM,
                                pAsyncStream,
                                ulBufferSize,
                                pAsyncStream,
                                ulBufferSize,
                                &bytesReturned);
        if (ERROR_SUCCESS != dwRet)
        {
            TRACE (TL_WARNING, (hWnd, "Failed SendRequest %d\n", dwRet));
        }
    }

    LocalFree (pAsyncStream);
    TRACE(TL_TRACE, (hWnd, "Exit w1394_AsyncStream\r\n"));
    return;
} // w1394_AsyncStream
void
BluetoothServiceChildProcess::UnregisterGattClientInternal(
  int aClientIf, BluetoothReplyRunnable* aRunnable)
{
  SendRequest(aRunnable, UnregisterGattClientRequest(aClientIf));
}
Ejemplo n.º 24
0
void
w1394_AllocateAddressRange(
                           HWND         hWnd,
                           __in PSTR    szDeviceName)
{
    PALLOCATE_ADDRESS_RANGE  allocateAddressRange;
    DWORD                       dwRet, bytesReturned;
    ULONG ulBufferSize = sizeof (ALLOCATE_ADDRESS_RANGE) + 512;

    UNREFERENCED_PARAMETER(szDeviceName);

    TRACE(TL_TRACE, (hWnd, "Enter w1394_AllocateAddressRange\r\n"));

    allocateAddressRange = \
        (PALLOCATE_ADDRESS_RANGE) LocalAlloc (LPTR, ulBufferSize);
    if (NULL == allocateAddressRange)
    {
        TRACE (TL_WARNING, (hWnd, "Failed to allocate memory\n"));
        return;
    }

    allocateAddressRange->fulAllocateFlags = ASYNC_ALLOC_USE_MDL;
    allocateAddressRange->fulFlags = 0;
    allocateAddressRange->nLength = 512;
    allocateAddressRange->MaxSegmentSize = 0;
    allocateAddressRange->fulAccessType = ACCESS_FLAGS_TYPE_READ | 
        ACCESS_FLAGS_TYPE_WRITE | ACCESS_FLAGS_TYPE_LOCK | 
        ACCESS_FLAGS_TYPE_BROADCAST;
    allocateAddressRange->fulNotificationOptions = NOTIFY_FLAGS_NEVER;
    allocateAddressRange->Required1394Offset.Off_High = 0;
    allocateAddressRange->Required1394Offset.Off_Low = 0;


    if (DialogBoxParam ( 
        (HINSTANCE) GetWindowLongPtr(hWnd, GWLP_HINSTANCE),
        "AllocateAddressRange",
        hWnd,
        AllocateAddressRangeDlgProc,
        (LPARAM) allocateAddressRange)) 
    {

        dwRet = SendRequest (
            IOCTL_ALLOCATE_ADDRESS_RANGE,
            allocateAddressRange,
            ulBufferSize,
            allocateAddressRange,
            ulBufferSize,
            &bytesReturned);

        if (ERROR_SUCCESS != dwRet)
        {
            TRACE (TL_WARNING, (hWnd, "Failed SendRequest %d\n", dwRet));
        }
        else
        {
            TRACE (
                TL_TRACE, 
                (hWnd, "Copy the hAddressRange to free the resource later\n"));
            TRACE(
                TL_TRACE, 
                (hWnd, "hAddressRange = %p\r\n", 
                allocateAddressRange->hAddressRange));
            TRACE(
                TL_TRACE, 
                (hWnd, "Required1394Offset.Off_High = 0x%x\r\n", 
                allocateAddressRange->Required1394Offset.Off_High));
            TRACE(
                TL_TRACE, 
                (hWnd, "Required1394Offset.Off_low = 0x%x\r\n", 
                allocateAddressRange->Required1394Offset.Off_Low));
        }

        LocalFree (allocateAddressRange);
    }

    TRACE(TL_TRACE, (hWnd, "Exit w1394_AllocateAddressRange\r\n"));
    return;
} // w1394_AllocateAddressRange
nsresult
BluetoothServiceChildProcess::StopInternal(BluetoothReplyRunnable* aRunnable)
{
  SendRequest(aRunnable, StopBluetoothRequest());
  return NS_OK;
}
Ejemplo n.º 26
0
void
w1394_AsyncRead (
                 HWND         hWnd,
                 __in PSTR    szDeviceName)
{
    PASYNC_READ      asyncRead;
    DWORD           dwRet, bytesTransferred;
    ULONG ulBufferSize = sizeof (ASYNC_READ) + sizeof (ULONG);

    UNREFERENCED_PARAMETER(szDeviceName);

    TRACE(TL_TRACE, (hWnd, "Enter w1394_AsyncRead\r\n"));

    asyncRead =  (PASYNC_READ) LocalAlloc (LPTR, ulBufferSize);
    if (NULL == asyncRead)
    {
        TRACE (TL_WARNING, (hWnd, "Failed to allocate asyncRead\n"));
        return;
    }

    asyncRead->bGetGeneration = TRUE;
    asyncRead->DestinationAddress.IA_Destination_ID.NA_Bus_Number = 0x3FF;
    asyncRead->DestinationAddress.IA_Destination_ID.NA_Node_Number = 0;
    asyncRead->DestinationAddress.IA_Destination_Offset.Off_High = 0xFFFF;
    asyncRead->DestinationAddress.IA_Destination_Offset.Off_Low = 0xF0000400;
    asyncRead->nNumberOfBytesToRead = sizeof(ULONG);
    asyncRead->nBlockSize = 0;
    asyncRead->fulFlags = 0;
    asyncRead->ulGeneration = 0;


    if (DialogBoxParam( 
        (HINSTANCE) GetWindowLongPtr(hWnd, GWLP_HINSTANCE),
        "AsyncRead",
        hWnd,
        AsyncReadDlgProc,
        (LPARAM)asyncRead)) 
    {

        dwRet = SendRequest (
            IOCTL_ASYNC_READ,
            asyncRead,
            ulBufferSize,
            asyncRead,
            ulBufferSize,
            &bytesTransferred);
        if (ERROR_SUCCESS != dwRet)
        {
            TRACE (TL_WARNING, (hWnd, "Failed SendRequest %d\n", dwRet));
        }
        else
        {
            ULONG i;    
            for (i=0; i < (asyncRead->nNumberOfBytesToRead/sizeof(ULONG)); i++) 
            {

                PULONG ulTemp;

                ulTemp = (PULONG)asyncRead->Data[i*sizeof(ULONG)];
                if (NULL == ulTemp)
                {
                    TRACE (
                        TL_TRACE, 
                        (hWnd, 
                        "Null read attempted\r\n"));
                }
                else
                {
                TRACE(
                    TL_TRACE, 
                    (hWnd, 
                    "Quadlet[0x%x] = 0x%x\r\n", 
                    i, 
                    (ULONG)*ulTemp));
                }
            }
        }
    }

    LocalFree (asyncRead);
    TRACE(TL_TRACE, (hWnd, "Exit w1394_AsyncRead\r\n"));
    return;
} // w1394_AsyncRead
void
BluetoothServiceChildProcess::IsScoConnected(BluetoothReplyRunnable* aRunnable)
{
  SendRequest(aRunnable, IsScoConnectedRequest());
}
Ejemplo n.º 28
0
void UbuntuOneService::RequestVolumeList() {
  QUrl volumes_url(kVolumesEndpoint);
  QNetworkReply* reply = SendRequest(volumes_url);
  NewClosure(reply, SIGNAL(finished()),
             this, SLOT(VolumeListRequestFinished(QNetworkReply*)), reply);
}
void
BluetoothServiceChildProcess::ToggleCalls(
  BluetoothReplyRunnable* aRunnable)
{
  SendRequest(aRunnable, ToggleCallsRequest());
}
Ejemplo n.º 30
0
BOOL CHostBrowser::OnConnected()
{
	CTransfer::OnConnected();
	SendRequest();
	return TRUE;
}