void
TAccountXmpp::PresenceUpdateFromContextMenu(EMenuAction eMenuAction_Presence)
	{
	Assert(eMenuAction_Presence <= eMenuAction_PresenceLast);
	const UINT uFlagsAccountStatus = (m_uFlagsAccountStatus & ~FAS_kmStatusPresenceMask) | eMenuAction_Presence;
	if (uFlagsAccountStatus == m_uFlagsAccountStatus)
		return;
	m_uFlagsAccountStatus = uFlagsAccountStatus;	// Update the presence
	if (m_paSocket != NULL && m_paSocket->Socket_FuIsReadyToSendMessages())
		{
		switch (eMenuAction_Presence)
			{
		case eMenuAction_PresenceAccountOnline:
		case eMenuAction_PresenceAway:
		case eMenuAction_PresenceAwayExtended:
		case eMenuAction_PresenceBusy:
			m_paSocket->Socket_WriteXmlPresence();
			break;
		default:
			m_paSocket->Socket_Disconnect();
			TContact ** ppContactStop;
			TContact ** ppContact = m_arraypaContacts.PrgpGetContactsStop(OUT &ppContactStop);
			while (ppContact != ppContactStop)
				{
				TContact * pContact = *ppContact++;
				Assert(pContact != NULL);
				Assert(pContact->EGetRuntimeClass() == RTI(TContact));
				Assert(pContact->m_pAccount == this);
				pContact->TreeItemContact_UpdateIconOffline();
				}
			} // switch
		} // if
	TreeItemAccount_UpdateIcon();	// Update the icon according to the new presence
	} // PresenceUpdateFromContextMenu()
//	Append the 'chat state' to the cursor
void
WChatLog::ChatLog_ChatStateTextAppend(INOUT OCursor & oTextCursor)
	{
	TContact ** ppContactStop;
	TContact ** ppContact = m_arraypContactsComposing.PrgpGetContactsStop(OUT &ppContactStop);
	if (ppContact == ppContactStop)
		{
		oTextCursor.removeSelectedText();
		}
	else
		{
		if (g_poImageComposing == NULL)
			g_poImageComposing = new QImage(":/ico/Pencil");
		while (TRUE)
			{
			oTextCursor.insertImage(*g_poImageComposing);
			TContact * pContact = *ppContact++;
			Assert(pContact != NULL);
			Assert(pContact->EGetRuntimeClass() == RTI(TContact));
			g_strScratchBufferStatusBar.Format(d_szu_nbsp " <b>^s</b> is typing...", pContact->ChatLog_PszGetNickname());
			oTextCursor.insertHtml(g_strScratchBufferStatusBar);
			if (ppContact == ppContactStop)
				break;
			} // while
		}
	if (m_pContactOrGroup->EGetRuntimeClass() == RTI(TContact))
		((TContact *)m_pContactOrGroup)->ChatLogContact_AppendExtraTextToChatState(INOUT oTextCursor);
	Widget_ScrollToEnd(INOUT this);
	} // ChatLog_ChatStateTextAppend()
Exemple #3
0
void
CArrayPtrContacts::ForEach_ChatLogResetNickNameAndRepopulateAllEvents()
	{
	TContact ** ppContactStop;
	TContact ** ppContact = PrgpGetContactsStop(OUT &ppContactStop);
	while (ppContact != ppContactStop)
		{
		TContact * pContact = *ppContact++;
		Assert(pContact->EGetRuntimeClass() == RTI(TContact));
		pContact->m_uFlagsTreeItem |= TContact::FTI_kfChatLogEvents_RepopulateAll;
		pContact->ChatLog_ResetNickname();
		}
	}
void
TAccountXmpp::TreeItemAccount_UpdateIconOfAllContacts()
	{
	TContact ** ppContactStop;
	TContact ** ppContact = m_arraypaContacts.PrgpGetContactsStop(OUT &ppContactStop);
	while (ppContact != ppContactStop)
		{
		TContact * pContact = *ppContact++;
		Assert(pContact != NULL);
		Assert(pContact->EGetRuntimeClass() == RTI(TContact));
		Assert(pContact->m_pAccount == this);
		pContact->TreeItemContact_UpdateIcon();
		}
	}
Exemple #5
0
PSZUC
CArrayPtrContacts::PszFormatDisplayNames(OUT CStr * pstrScratchBuffer) const
	{
	pstrScratchBuffer->Empty();
	TContact ** ppContactStop;
	TContact ** ppContact = PrgpGetContactsStop(OUT &ppContactStop);
	while (ppContact != ppContactStop)
		{
		TContact * pContact = *ppContact++;
		Assert(pContact->EGetRuntimeClass() == RTI(TContact));
		if (!pstrScratchBuffer->FIsEmptyBinary())
			pstrScratchBuffer->BinAppendText(", ");
		pstrScratchBuffer->BinAppendText((PSZAC)pContact->TreeItem_PszGetNameDisplay());
		}
	return pstrScratchBuffer->BinAppendNullTerminatorSz();
	}
//	Core routine to add a new event to the vault and send it to the contact(s).
//	Optionally this method may also send an 'Updater' event
void
CVaultEvents::EventAddAndDispatchToContacts(PA_CHILD IEvent * paEvent, PA_CHILD CEventUpdaterSent * paEventUpdater)
	{
	Assert(paEvent != NULL);
	Assert(paEvent->m_tsOther == d_ts_zNA);
	Assert(paEvent->m_pVaultParent_NZ == NULL);
	Assert(paEvent->Event_FIsEventTypeSent());
	//MessageLog_AppendTextFormatSev(eSeverityWarningToErrorLog, "EventAddAndDispatchToContacts() - tsEventID $t\n", paEvent->m_tsEventID);
	if (paEventUpdater != NULL)
		{
		// Always include the Updater before the updated event
		paEventUpdater->m_pVaultParent_NZ = this;
		m_arraypaEvents.Add(PA_CHILD paEventUpdater);
		}
	paEvent->m_pVaultParent_NZ = this;
	m_arraypaEvents.Add(PA_CHILD paEvent);
	SetModified();	// Make sure the events are saved to disk

	if (paEvent->EGetEventClass() & eEventClass_kfNeverSerializeToXCP)
		return;	// The event is never serialized to XOSP, therefore there is nothing else to do

	CBinXcpStanza binXcpStanza;			// All events are sent as XMPP 'messages' so they may be cached
	TGroup * pGroup = (TGroup *)m_pParent;
	TContact * pContact = (TContact *)m_pParent;
	if (pContact->EGetRuntimeClass() == RTI(TContact))
		{
		// Send the message to a contact
		MessageLog_AppendTextFormatCo(d_coGrayDark, "\t Sending message to $S\n\t\t m_tsEventIdLastSentCached $t, m_tsOtherLastSynchronized $t\n", &pContact->m_strJidBare, pContact->m_tsEventIdLastSentCached, pContact->m_tsOtherLastSynchronized);
		binXcpStanza.BinXmlAppendXcpApiCall_SendEventToContact(pContact, paEvent, paEventUpdater);
		}
	else
		{
		// Broadcast the message to every [active] group member
		Assert(pGroup->EGetRuntimeClass() == RTI(TGroup));
		TGroupMember ** ppMemberStop;
		TGroupMember ** ppMember = pGroup->m_arraypaMembers.PrgpGetMembersStop(OUT &ppMemberStop);
		while (ppMember != ppMemberStop)
			{
			TGroupMember * pMember = *ppMember++;
			Assert(pMember != NULL);
			Assert(pMember->EGetRuntimeClass() == RTI(TGroupMember));
			binXcpStanza.BinXmlAppendXcpApiCall_SendEventToContact(pMember->m_pContact, paEvent, paEventUpdater);
			} // while
		} // if...else
	m_pParent->m_tsEventIdLastSentCached = paEvent->m_tsEventID;
	} // EventAddAndDispatchToContacts()
Exemple #7
0
TContact *
CArrayPtrContacts::PFindContactByNameDisplay(PSZUC pszContactNameDisplay, const TContact * pContactExclude) const
	{
	TContact ** ppContactStop;
	TContact ** ppContact = PrgpGetContactsStop(OUT &ppContactStop);
	while (ppContact != ppContactStop)
		{
		TContact * pContact = *ppContact++;
		Assert(pContact->EGetRuntimeClass() == RTI(TContact));
		if (pContact != pContactExclude)
			{
			if (pContact->m_strNameDisplayTyped.FCompareStringsNoCase(pszContactNameDisplay))
				return pContact;
			}
		} // while
	return NULL;
	}
void
CArrayPtrContacts::RemoveAllContactsComposingWhoAreIdle()
	{
	if (m_paArrayHdr == NULL)
		return;
	TContact ** ppContactStop;
	TContact ** ppContactStart = PrgpGetContactsStop(OUT &ppContactStop);
	TContact ** ppContactDst = ppContactStart;
	TContact ** ppContactSrc = ppContactStart;
	while (ppContactSrc != ppContactStop)
		{
		TContact * pContact = *ppContactSrc++;
		Assert(pContact->EGetRuntimeClass() == RTI(TContact));
		MessageLog_AppendTextFormatSev(eSeverityNoise, "\t[$@] $S ($s) is still typing for $i minutes...\n", &pContact->m_strJidBare, pContact->ChatLog_PszGetNickname(), g_tsmMinutesSinceApplicationStarted - pContact->m_tsmLastStanzaReceived);
		if (g_tsmMinutesSinceApplicationStarted - pContact->m_tsmLastStanzaReceived >= 4)
			pContact->ChatLogContact_ChatStateIconUpdateComposingStopped();	// If the user has not typed anything during the past 4 minutes, then assume he stopped typing.
		else
			*ppContactDst++ = pContact;
		}
	m_paArrayHdr->cElements = ppContactDst - ppContactStart;
	} // RemoveAllContactsComposingWhoAreIdle()
void
TAccountXmpp::TreeItemAccount_DisplayWithinNavigationTree()
	{
	Endorse(g_pTreeItemInbox == NULL);	// Display the account at the root of the Navigation Tree
	TreeItemW_DisplayWithinNavigationTree(g_pTreeItemInbox);
	TContact ** ppContactStop;
	TContact ** ppContact = m_arraypaContacts.PrgpGetContactsStop(OUT &ppContactStop);
	while (ppContact != ppContactStop)
		{
		TContact * pContact = *ppContact++;
		Assert(pContact != NULL);
		Assert(pContact->EGetRuntimeClass() == RTI(TContact));
		Assert(pContact->m_pAccount == this);
		pContact->TreeItemContact_DisplayWithinNavigationTree();
		} // while
	#ifdef WANT_TREE_NODE_NEW_CONTACT
	m_pTreeItemContactNew = new TContactNew(this);
	#endif

	TGroup ** ppGroupStop;
	TGroup ** ppGroup = m_arraypaGroups.PrgpGetGroupsStop(OUT &ppGroupStop);
	while (ppGroup != ppGroupStop)
		{
		TGroup * pGroup = *ppGroup++;
		Assert(pGroup != NULL);
		Assert(pGroup->EGetRuntimeClass() == RTI(TGroup));
		Assert(pGroup->m_pAccount == this);
		if (pGroup->TreeItemGroup_FCanDisplayWithinNavigationTree())
			pGroup->TreeItemGroup_DisplayWithinNavigationTree();
		}
	TreeItemW_ExpandAccordingToSavedState();
	TreeItemAccount_UpdateIcon();

	#if FIX_THIS
	// Display the alias as well
	m_paAlias->TreeItem_DisplayWithinNavigationTree(m_pProfileParent, m_strJID, eMenuIconXmpp);
	#endif
	} // TreeItemAccount_DisplayWithinNavigationTree()