Exemple #1
0
int CMraProto::SendMsg(MCONTACT hContact, int, const char *lpszMessage)
{
    if (!m_bLoggedIn) {
        ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, NULL, (LPARAM)"You cannot send when you are offline.");
        return 0;
    }

    DWORD dwFlags = 0;
    CMStringW wszMessage(ptrW(mir_utf8decodeT(lpszMessage)));
    if (wszMessage.IsEmpty()) {
        ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, NULL, (LPARAM)"Cant allocate buffer for convert to unicode.");
        return 0;
    }

    CMStringA szEmail;
    if (!mraGetStringA(hContact, "e-mail", szEmail))
        return 0;

    BOOL bSlowSend = getByte("SlowSend", MRA_DEFAULT_SLOW_SEND);
    if (getByte("RTFSendEnable", MRA_DEFAULT_RTF_SEND_ENABLE) && (MraContactCapabilitiesGet(hContact) & FEATURE_FLAG_RTF_MESSAGE))
        dwFlags |= MESSAGE_FLAG_RTF;

    int iRet = MraMessage(bSlowSend, hContact, ACKTYPE_MESSAGE, dwFlags, szEmail, wszMessage, NULL, 0);
    if (bSlowSend == FALSE)
        ProtoBroadcastAckAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)iRet, 0);
    return iRet;
}
Exemple #2
0
int CMraProto::SendMsg(HANDLE hContact, int flags, const char *lpszMessage)
{
	if (!m_bLoggedIn) {
		ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, NULL, (LPARAM)"You cannot send when you are offline.");
		return 0;
	}

	DWORD dwFlags = 0;
	LPWSTR lpwszMessage = NULL;
	int iRet = 0;

	if (flags & PREF_UNICODE)
		lpwszMessage = (LPWSTR)(lpszMessage + lstrlenA(lpszMessage)+1 );
	else if (flags & PREF_UTF)
		lpwszMessage = mir_utf8decodeT(lpszMessage);
	else
		lpwszMessage = mir_a2t(lpszMessage);

	if ( !lpwszMessage) {
		ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, NULL, (LPARAM)"Cant allocate buffer for convert to unicode.");
		return 0;
	}

	CMStringA szEmail;
	if ( mraGetStringA(hContact, "e-mail", szEmail)) {
		BOOL bSlowSend = getByte("SlowSend", MRA_DEFAULT_SLOW_SEND);
		if ( getByte("RTFSendEnable", MRA_DEFAULT_RTF_SEND_ENABLE) && (MraContactCapabilitiesGet(hContact) & FEATURE_FLAG_RTF_MESSAGE))
			dwFlags |= MESSAGE_FLAG_RTF;

		iRet = MraMessage(bSlowSend, hContact, ACKTYPE_MESSAGE, dwFlags, szEmail, lpwszMessage, NULL, 0);
		if (bSlowSend == FALSE)
			ProtoBroadcastAckAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)iRet, 0);
	}

	mir_free(lpwszMessage);
	return iRet;
}