示例#1
0
void  CMsnProto::MsgQueue_Clear(const char* wlid, bool msg)
{
	int i;

	EnterCriticalSection(&csMsgQueue);
	if (wlid == NULL)
	{

		for(i=0; i < msgQueueList.getCount(); i++)
		{
			const MsgQueueEntry& E = msgQueueList[i];
			if (E.msgSize == 0)
			{
				HANDLE hContact = MSN_HContactFromEmail(E.wlid);
				SendBroadcast(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, 
					(HANDLE)E.seq, (LPARAM)MSN_Translate("Message delivery failed"));
			}
			mir_free(E.message);
			mir_free(E.wlid);
			if (E.cont) delete E.cont;
		}
		msgQueueList.destroy();

		msgQueueSeq = 1;
	}
	else
	{
		for(i=0; i < msgQueueList.getCount(); i++)
		{
			time_t ts = time(NULL);
			const MsgQueueEntry& E = msgQueueList[i];
			if (_stricmp(msgQueueList[i].wlid, wlid) == 0 && (!msg || E.msgSize == 0))
			{
				bool msgfnd = E.msgSize == 0 && E.ts < ts;
				int seq = E.seq;
				
				mir_free(E.message);
				mir_free(E.wlid);
				if (E.cont) delete E.cont;
				msgQueueList.remove(i);

				if (msgfnd) 
				{
					LeaveCriticalSection(&csMsgQueue);
					HANDLE hContact = MSN_HContactFromEmail(wlid);
					SendBroadcast(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)seq, 
						(LPARAM)MSN_Translate("Message delivery failed"));
					i = 0;
					EnterCriticalSection(&csMsgQueue);
				}
			}
		}
	}
	LeaveCriticalSection(&csMsgQueue);
}
示例#2
0
DWORD_PTR __cdecl CMsnProto::GetCaps(int type, HANDLE hContact)
{
	switch(type) 
	{
	case PFLAGNUM_1:
	{	int result = PF1_IM | PF1_SERVERCLIST | PF1_AUTHREQ | PF1_BASICSEARCH |
				 PF1_ADDSEARCHRES | PF1_CHAT |
				 PF1_FILESEND | PF1_FILERECV | PF1_URLRECV | PF1_VISLIST | PF1_MODEMSG;
		return result;
	}
	case PFLAGNUM_2:
		return PF2_ONLINE | PF2_SHORTAWAY | PF2_LIGHTDND | PF2_INVISIBLE | PF2_ONTHEPHONE | PF2_IDLE;

	case PFLAGNUM_3:
		return PF2_ONLINE | PF2_SHORTAWAY | PF2_LIGHTDND;

	case PFLAGNUM_4:
		return PF4_FORCEAUTH | PF4_FORCEADDED | PF4_SUPPORTTYPING | PF4_AVATARS | PF4_SUPPORTIDLE | PF4_IMSENDUTF | 
			PF4_IMSENDOFFLINE | PF4_NOAUTHDENYREASON;

	case PFLAGNUM_5:
        return PF2_ONTHEPHONE;

	case PFLAG_UNIQUEIDTEXT:
		return (UINT_PTR)MSN_Translate("Live ID");

	case PFLAG_UNIQUEIDSETTING:
		return (UINT_PTR)"e-mail";

	case PFLAG_MAXLENOFMESSAGE:
		return 1202;
	}

	return 0;
}
示例#3
0
int __cdecl CMsnProto::SendMsg(HANDLE hContact, int flags, const char* pszSrc)
{
	const char *errMsg = NULL;

	if (!msnLoggedIn)
	{
		errMsg = MSN_Translate("Protocol is offline");
		ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, 999999, errMsg, this));
		return 999999;
	}

	char tEmail[MSN_MAX_EMAIL_LEN];
	if (MSN_IsMeByContact(hContact, tEmail)) 
	{
		errMsg = MSN_Translate("You cannot send message to yourself");
		ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, 999999, errMsg, this));
		return 999999;
	}

	char *msg = (char*)pszSrc;
	if (msg == NULL) return 0;

	if (flags & PREF_UNICODE)
	{
		char* p = strchr(msg, '\0');
		if (p != msg)
		{
			while (*(++p) == '\0') {}
			msg = mir_utf8encodeW((wchar_t*)p);
		}
		else
			msg = mir_strdup(msg);
	}
	else
		msg = (flags & PREF_UTF) ? mir_strdup(msg) : mir_utf8encode(msg);

	int rtlFlag = (flags & PREF_RTL) ? MSG_RTL : 0;

	int seq = 0;
	int netId  = Lists_GetNetId(tEmail);

	switch (netId)
	{
	case NETID_MOB:
		if (strlen(msg) > 133)
		{
			errMsg = MSN_Translate("Message is too long: SMS page limited to 133 UTF8 chars");
			seq = 999997;
		}
		else
		{
			errMsg = NULL;
			seq = msnNsThread->sendMessage('1', tEmail, netId, msg, rtlFlag);
		}
		ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, errMsg, this));
		break;

	case NETID_YAHOO:
		if (strlen(msg) > 1202) 
		{
			seq = 999996;
			errMsg = MSN_Translate("Message is too long: MSN messages are limited by 1202 UTF8 chars");
			ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, errMsg, this));
		}
		else
		{
			seq = msnNsThread->sendMessage('1', tEmail, netId, msg, rtlFlag);
			ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, NULL, this));
		}
		break;

	default:
		if (strlen(msg) > 1202) 
		{
			seq = 999996;
			errMsg = MSN_Translate("Message is too long: MSN messages are limited by 1202 UTF8 chars");
			ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, errMsg, this));
		}
		else
		{
			const char msgType = MyOptions.SlowSend ? 'A' : 'N';
			bool isOffline;
			ThreadData* thread = MSN_StartSB(tEmail, isOffline);
			if (thread == NULL)
			{
				if (isOffline) 
				{
					if (netId != NETID_LCS)
					{
						seq = msnNsThread->sendMessage('1', tEmail, netId, msg, rtlFlag | MSG_OFFLINE);
						ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, NULL, this));
					}
					else
					{
						seq = 999993;
						errMsg = MSN_Translate("Offline messaging is not allowed for LCS contacts");
						ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, errMsg, this));
					}
				}
				else
					seq = MsgQueue_Add(tEmail, msgType, msg, 0, 0, rtlFlag);
			}
			else
			{
				seq = thread->sendMessage(msgType, tEmail, netId, msg, rtlFlag);
				if (!MyOptions.SlowSend)
					ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, NULL, this));
			}
		}
		break;
	}

	mir_free(msg);
	return seq;
}