示例#1
0
//---------------------------------------------------------------------------
int CSendHTTPServer::Send()
{
	if (!m_hContact) return 1;
	if (CallService(MS_HTTP_ACCEPT_CONNECTIONS, TRUE, 0) != 0) {
		Error(LPGENT("Could not start the HTTP Server plugin."));
		Exit(ACKRESULT_FAILED);
		return !m_bAsync;
	}

	if (!m_pszFileName) {
		m_pszFileName = GetFileNameA(m_pszFile);
	}
	mir_freeAndNil(m_fsi_pszSrvPath);
	mir_stradd(m_fsi_pszSrvPath, "/");
	mir_stradd(m_fsi_pszSrvPath, m_pszFileName);

	replaceStr(m_fsi_pszRealPath, _T2A(m_pszFile));

	memset(&m_fsi, 0, sizeof(m_fsi));
	m_fsi.lStructSize = sizeof(STFileShareInfo);
	m_fsi.pszSrvPath = m_fsi_pszSrvPath;
	m_fsi.nMaxDownloads = -1;					// -1 = infinite
	m_fsi.pszRealPath = m_fsi_pszRealPath;

	//start Send thread
	mir_forkthread(&CSendHTTPServer::SendThreadWrapper, this);
	return 0;
}
//---------------------------------------------------------------------------
void CSendImageShack::MFDR_Reset() {
	char	Temp[64];
	DWORD	dwBoundaryRand1 = GetTickCount();
	DWORD	dwBoundaryRand2 = rand();

	mir_freeAndNil(m_MFDRboundary);
	mir_snprintf(Temp, SIZEOF(Temp), "B-O-U-N-D-A-R-Y%u%u", dwBoundaryRand1, dwBoundaryRand2);
	mir_stradd(m_MFDRboundary,Temp);
}
示例#3
0
void CSend::svcSendMsgExit(const char* szMessage)
{
	if (m_bSilent) {
		Exit(ACKRESULT_SUCCESS); return;
	}
	if (!m_hContact) {
		if (!m_pszFileDesc)
			m_pszFileDesc = mir_a2t(szMessage);
		Exit(CSEND_DIALOG); return;
	}
	if (m_ChatRoom) {
		TCHAR* tmp = mir_a2t(szMessage);
		if (m_pszFileDesc) {
			mir_tstradd(tmp, _T("\r\n"));
			mir_tstradd(tmp, m_pszFileDesc);
		}
		GC_INFO gci = { 0 };
		int res = GC_RESULT_NOSESSION;
		int cnt = (int)CallService(MS_GC_GETSESSIONCOUNT, 0, (LPARAM)m_pszProto);

		//loop on all gc session to get the right (save) ptszID for the chatroom from m_hContact
		gci.pszModule = m_pszProto;
		for (int i = 0; i < cnt; i++) {
			gci.iItem = i;
			gci.Flags = GCF_BYINDEX | GCF_HCONTACT | GCF_ID;
			CallService(MS_GC_GETINFO, 0, (LPARAM)&gci);
			if (gci.hContact == m_hContact) {
				GCDEST gcd = { m_pszProto, gci.pszID, GC_EVENT_SENDMESSAGE };
				GCEVENT gce = { sizeof(gce), &gcd };
				gce.bIsMe = TRUE;
				gce.dwFlags = GCEF_ADDTOLOG;
				gce.ptszText = tmp;
				gce.time = time(NULL);

				//* returns 0 on success or error code on failure
				res = 200 + (int)CallService(MS_GC_EVENT, 0, (LPARAM)&gce);
				break;
			}
		}
		Exit(res); return;
	}
	else {
		mir_freeAndNil(m_szEventMsg);
		m_cbEventMsg = (DWORD)mir_strlen(szMessage) + 1;
		m_szEventMsg = (char*)mir_realloc(m_szEventMsg, (sizeof(char) * m_cbEventMsg));
		memset(m_szEventMsg, 0, (sizeof(char) * m_cbEventMsg));
		mir_strcpy(m_szEventMsg, szMessage);
		if (m_pszFileDesc && m_pszFileDesc[0] != NULL) {
			char *temp = mir_t2a(m_pszFileDesc);
			mir_stradd(m_szEventMsg, "\r\n");
			mir_stradd(m_szEventMsg, temp);
			m_cbEventMsg = (DWORD)mir_strlen(m_szEventMsg) + 1;
			mir_free(temp);
		}
		//create a HookEventObj on ME_PROTO_ACK
		if (!m_hOnSend) {
			m_hOnSend = HookEventObj(ME_PROTO_ACK, OnSend, this);
		}
		//start PSS_MESSAGE service
		m_hSend = (HANDLE)CallContactService(m_hContact, PSS_MESSAGE, NULL, ptrA(mir_utf8encode(m_szEventMsg)));
		// check we actually got an ft handle back from the protocol
		if (!m_hSend) {
			Unhook();
			Error(SS_ERR_INIT, m_pszSendTyp);
			Exit(ACKRESULT_FAILED); return;
		}
	}
}