Esempio n. 1
0
// sendDataInfo
bool sendDataInfo(cgcResponse::pointer response, CDataInfo::pointer dataInfo)
{
	BOOST_ASSERT (response.get() != 0);
	BOOST_ASSERT (dataInfo.get() != 0);
	BOOST_ASSERT (dataInfo->parentgroup() != 0);

	if (response->isInvalidate()) return false;

	response->lockResponse();
	response->setParameter(cgcParameter::create(_T("GrouId"), dataInfo->parentgroup()->groupid()));
	response->setParameter(cgcParameter::create(_T("DataId"), dataInfo->dataid()));
	response->setParameter(cgcParameter::create(_T("Name"), dataInfo->name()));
	response->setParameter(cgcParameter::create(_T("Desc"), dataInfo->desc()));
	// ???
	//response->setParameter(cgcParameter::create(_T("AttachName"), dataId));
	response->sendResponse(0, 152);
	return true;
}
Esempio n. 2
0
bool sendMsg(cgcResponse::pointer response, CUserInfo::pointer fromUser, CFromInfo::pointer fromInfo, long mid, cgcAttachment::pointer attachment)
{
	BOOST_ASSERT (response.get() != 0);
	BOOST_ASSERT (fromUser.get() != 0);
	BOOST_ASSERT (fromInfo.get() != 0);
	BOOST_ASSERT (attachment.get() != 0);

	if (response->isInvalidate()) return false;

	response->lockResponse();
	if (fromInfo->fromType() == CFromInfo::FromDialogInfo)
	{
		response->setParameter(cgcParameter::create(_T("DID"), fromInfo->fromDialog()->dialogId()));
	}
	response->setParameter(cgcParameter::create(_T("FromAccount"), fromUser->getAccount()));
	response->setParameter(cgcParameter::create(_T("MID"), mid));
	response->setAttachInfo(attachment->getTotal(), attachment->getIndex());
	response->setAttachData(attachment->getAttachData(), attachment->getAttachSize());
	response->sendResponse(0, 501);
	return true;
}
Esempio n. 3
0
bool sendCoGroupUserInfo(cgcResponse::pointer response, unsigned int coId, unsigned cogroupId, CUserInfoPointer userInfo)
{
	BOOST_ASSERT (response.get() != 0);
	BOOST_ASSERT (userInfo.get() != 0);

	if (response->isInvalidate()) return false;

	response->lockResponse();
	response->setParameter(cgcParameter::create(_T("CoId"), (long)coId));
	//response->setParameter(cgcParameter::create(_T("Id"), cogroupId));

	int index = 0;
	CLockMap<unsigned int, CCoGroupInfo::pointer>::const_iterator iterCoGroup;
	boost::mutex::scoped_lock lockCoGroupInfo(const_cast<boost::mutex&>(userInfo->m_cogroups.mutex()));
	for (iterCoGroup=userInfo->m_cogroups.begin(); iterCoGroup!=userInfo->m_cogroups.end(); iterCoGroup++)
	{
		CCoGroupInfo::pointer cogroupInfo = iterCoGroup->second;

		char buffer[10];
		sprintf(buffer, "Id%d", index++);
		response->setParameter(cgcParameter::create(buffer, (long)cogroupInfo->groupid()));
	}

	response->setParameter(cgcParameter::create(_T("Account"), userInfo->getAccount()));
	response->setParameter(cgcParameter::create(_T("Name"), userInfo->getUserName()));
	response->setParameter(cgcParameter::create(_T("Nick"), userInfo->getNick()));
	response->setParameter(cgcParameter::create(_T("Gender"), (long)userInfo->getGender()));
	response->setParameter(cgcParameter::create(_T("Ext"), userInfo->getExtension()));
	response->setParameter(cgcParameter::create(_T("Phone"), userInfo->getPhone()));
	response->setParameter(cgcParameter::create(_T("Mobile"), userInfo->getMobile()));
	response->setParameter(cgcParameter::create(_T("Email"), userInfo->getEmail()));
	//response->setParameter(cgcParameter::create(_T("Desc"), userInfo->getDescription()));
	response->setParameter(cgcParameter::create(_T("LineState"), (long)userInfo->getLineState()));
	response->sendResponse(0, 112);
	return true;
}
Esempio n. 4
0
extern "C" int CGC_API MsgRequest(const cgcRequest::pointer & request, cgcResponse::pointer response, cgcSession::pointer session)
{
	/////////////////////////////////
	// Request
	const tstring & sAccountId = request->getParameterValue(_T("AccountId"), _T(""));
	if (sAccountId.empty()) return -1;
	long mid = request->getParameterValue(_T("MID"), 0);
	const tstring & sFriendAccount = request->getParameterValue(_T("SendTo"), _T(""));
	if (sFriendAccount.empty()) return -1;
	long type = request->getParameterValue(_T("Type"), 0);

	/////////////////////////////////
	// Process
	CAccountInfo::pointer accountInfo = CGC_POINTER_CAST<CAccountInfo>(gApplication->getAttribute(BMT_ACCOUNTIDS, sAccountId));
	if (accountInfo.get() == NULL)
//	if (!gAVSProxy->m_accountids.find(sAccountId, accountInfo))
	{
		// Un register.
		return 14;
	}else if (session->getId().compare(accountInfo->getSessionId()) != 0)
	{
		// SessionId Error
		return -3;
	}

	CAccountInfo::pointer friendAccountInfo = CGC_POINTER_CAST<CAccountInfo>(gApplication->getAttribute(BMT_ACCOUNTS, sFriendAccount));
	if (friendAccountInfo.get() == NULL)
	//if (!gAVSProxy->m_accounts.find(sFriendAccount, friendAccountInfo))
	{
		// SentTo Account offline state;
		return 17;
	}

	long newmid = ++gCurrentMessageId;

	if (type == 11)
	{
		const tstring & filename = request->getParameterValue(_T("Name"), _T(""));
		if (filename.empty()) return -1;
		long filesize = request->getParameterValue(_T("Size"), 0);
		if (filesize <= 0) return -1;

		response->lockResponse();
		response->setParameter(cgcParameter::create(_T("MID"), mid));
		response->setParameter(cgcParameter::create(_T("NMID"), newmid));
		response->sendResponse();

		sendFileRequest(friendAccountInfo, accountInfo->getUserinfo(), newmid, filename, filesize);
	}else// if ()
	{
		response->lockResponse();
		response->setParameter(cgcParameter::create(_T("MID"), mid));
		response->setParameter(cgcParameter::create(_T("NMID"), newmid));
		response->sendResponse();

		sendMsgRequest(friendAccountInfo, accountInfo->getUserinfo(), newmid, type);
	}

	// Response
	return 0;
}