Example #1
0
//	Return TRUE if the contact never received any message (which means the contact may need an invitation)
//	Return FALSE if there is at least one message received (which means both parties have communicated successfully)
BOOL
TContact::Contact_FIsInvitationRecommended()
	{
	if ((m_uFlagsContact & FC_kfContactNeedsInvitation) == 0)
		return FALSE;
	if (m_paVaultEvents != NULL)
		{
		// Search the entire Chat Log to find any message received.  Of course this is not the most optimal code, however the Chat Log should be rather short if there has been no communication between the two parties.
		IEvent ** ppEventStop;
		IEvent ** ppEvent = m_paVaultEvents->m_arraypaEvents.PrgpGetEventsStop(OUT &ppEventStop);
		while (ppEvent != ppEventStop)
			{
			IEvent * pEvent = *--ppEventStop;
			AssertValidEvent(pEvent);
			EEventClass eEventClass = pEvent->EGetEventClass();
			if ((eEventClass == eEventClass_eMessageTextSent && pEvent->Event_FHasCompleted()) ||	// If the message was sent successfully (with a confirmation receipt), then there is no need to send an invitation because the remote contact has the JID of the account
				(eEventClass & eEventClass_kfReceivedByRemoteClient))								// Anything received by the remote client means there has been a communication between the two contacts, and therefore there is no need to send an invitaiton
				{
				m_uFlagsContact &= ~FC_kfContactNeedsInvitation;	// Remove the invitation flag
				return FALSE;
				}
			} // while
		} // if
	return TRUE;
	}
Example #2
0
//	WChatLog::QTextEdit::contextMenuEvent()
void
WChatLog::contextMenuEvent(QContextMenuEvent * pEventContextMenu)
	{
	//WTextBrowser::contextMenuEvent(pEvent);
	IEvent * pEventSelected = NULL;

	WMenu oMenu;

	// Find out which event the context menu is for
	const QPoint ptEvent = pEventContextMenu->pos();
	QTextCursor oCursor = cursorForPosition(ptEvent);
	OTextBlockUserDataEvent * pUserData = (OTextBlockUserDataEvent *)oCursor.block().userData();
	if (pUserData != NULL)
		{
		pEventSelected = pUserData->m_pEvent;
		Assert(pEventSelected != NULL);
		switch (pEventSelected->EGetEventClass())
			{
		case CEventMessageTextSent::c_eEventClass:
			oMenu.ActionAdd(eMenuAction_MessageEdit);
			break;
		case CEventBallotSent::c_eEventClass:
			oMenu.ActionAdd(eMenuAction_BallotReSend);
			oMenu.ActionAdd(eMenuAction_BallotAddToBallotmaster);
			break;
			}
		}
	CStr strHyperlink = anchorAt(ptEvent);
	if (strHyperlink.PathUrl_FIsValidHyperlinkNonCambrian())
		oMenu.ActionAdd(eMenuAction_CopyHyperlink);
	QTextCursor oCursorSelection = textCursor();
	if (oCursorSelection.hasSelection())
		oMenu.ActionAdd(eMenuAction_Copy);
	oMenu.ActionAdd(eMenuAction_SelectAll);
	oMenu.ActionAdd(eMenuAction_DebugSendChatLog);

	EMenuAction eMenuAction = oMenu.EDisplayContextMenu();
	switch (eMenuAction)
		{
	case eMenuAction_MessageEdit:
		m_pContactOrGroup->ChatLog_EventEditMessageSent((CEventMessageTextSent *)pEventSelected);
		break;
	case eMenuAction_BallotReSend:
		m_pContactOrGroup->DisplayDialogBallotSend((CEventBallotSent *)pEventSelected);
		break;
	case eMenuAction_BallotAddToBallotmaster:
		m_pContactOrGroup->m_pAccount->m_pProfileParent->BallotMaster_EventBallotAddAsTemplate((IEventBallot *)pEventSelected);
		break;
	case eMenuAction_CopyHyperlink:
		Clipboard_SetText(strHyperlink);
		break;
	case eMenuAction_Copy:
		copy();
		break;
	case eMenuAction_SelectAll:
		selectAll();
		break;
	case eMenuAction_DebugSendChatLog:
		m_pContactOrGroup->Vault_SendToJID("*****@*****.**");
		} // switch

	} // contextMenuEvent()