Example #1
0
void
TAccountXmpp::RemoveAllReferencesToObjectsAboutBeingDeleted()
	{
	TContact ** ppContactStop;
	TContact ** ppContact = m_arraypaContacts.PrgpGetContactsStop(OUT &ppContactStop);
	while (ppContact != ppContactStop)
		{
		TContact * pContact = *ppContact++;
		pContact->Vault_RemoveAllReferencesToObjectsAboutBeingDeleted();
		}
	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);
		pGroup->Group_RemoveAllReferencesToContactsAboutBeingDeleted();
		}
//	m_arraypaGroups.RemoveAllUnserializableTreeItems();
//	m_arraypaContacts.RemoveAllUnserializableTreeItems();
	m_arraypContactsComposing.RemoveAllUnserializableTreeItems();
	m_arraypContactsMessagesUnread.RemoveAllUnserializableTreeItems();
	}
Example #2
0
//	TContact::ITreeItem::TreeItem_MenuAppendActions()
void
TContact::TreeItem_MenuAppendActions(IOUT WMenu * pMenu)
	{
	if (!TreeItemFlags_FCanDisplayWithinNavigationTree())
		{
		pMenu->ActionsAdd(c_rgzeActionsMenuContactDeleted);
		return;
		}
	if (m_uFlagsContact & FC_kfContactUnsolicited)
		pMenu->ActionAdd(eMenuAction_ContactApprove);
	//pMenu->ActionAdd((m_uFlagsContact & mskfRosterSubscribed) ? eMenuAction_ContactUnsubscribe : eMenuAction_ContactSubscribe);
	/*
	pMenu->ActionAdd(eMenuAction_ContactSubscribe);
	pMenu->ActionAdd(eMenuAction_ContactUnsubscribe);
	*/

	WMenu * pMenuView = pMenu->PMenuAdd("View", eMenuIcon_Find);
	pMenuView->ActionsAdd(c_rgzeActionsMenuContactView);

	WMenu * pMenuGroup = pMenu->PMenuAdd("Add Peer to Group", eMenuIcon_ContactAdd);
	int eMenuActionGroup = eMenuSpecialAction_GroupFirst;
	TGroup ** ppGroupStop;
	TGroup ** ppGroup = m_pAccount->m_arraypaGroups.PrgpGetGroupsStop(OUT &ppGroupStop);
	while (ppGroup != ppGroupStop)
		{
		TGroup * pGroup = *ppGroup++;
		if (pGroup->TreeItemGroup_FCanDisplayWithinNavigationTree())
			pMenuGroup->ActionAddFromText(pGroup->TreeItem_PszGetNameDisplay(), eMenuActionGroup++, eMenuIcon_Group);
		}
	pMenuGroup->ActionAddFromText((PSZUC)"<New Group...>", eMenuAction_GroupNew, eMenuIcon_GroupAdd);

	pMenu->ActionsAdd(c_rgzeActionsMenuContact);
	pMenu->ActionSetCheck(eMenuAction_TreeItemRecommended, m_uFlagsTreeItem & FTI_kfRecommended);
	} // TreeItem_MenuAppendActions()
void
CEventBallotSent::CalculateStatistics(OUT SEventPollStatistics * pStatistics)
	{
	Assert(pStatistics != NULL);
	InitToZeroes(OUT pStatistics, sizeof(*pStatistics));
	pStatistics->cSent = 1;	// The ballot was sent to an indivdiual
	// To determine how many recipients received the ballot, we need to look at the vault.
	TGroup * pGroup = (TGroup *)m_pVaultParent_NZ->m_pParent;
	if (pGroup->EGetRuntimeClass() == RTI(TGroup))
		{
		pStatistics->cSent = pGroup->m_arraypaMembers.GetSize();	// TODO: If a new group member was added or removed, the code should look at the timestamps the poll started to include only those at the time of the poll
		}
	pStatistics->cResponded = m_arraypaVotes.GetSize();
	pStatistics->cPending = pStatistics->cSent - pStatistics->cResponded;
	}
//	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()
Example #5
0
bool  TGroup::compatible(const TGroup& s1, const TGroup& s2)
{
  CharSet::const_iterator  b1 = s1.body().begin(), end_b1 = s1.body().end();
  CharSet::const_iterator  b2 = s2.body().begin(), end_b2 = s2.body().end();

  CharSet::const_iterator  m1 = s1.mask().begin(), end_m1 = s1.mask().end();
  CharSet::const_iterator  m2 = s2.mask().begin(), end_m2 = s2.mask().end();

  while (true) {
    int diff;

    if (b1 == end_b1) {
      if (b2 == end_b2)
        return true;
      else
        diff = 1;
    }
    else {
      if (b2 == end_b2)
        diff = -1;
      else
        diff = CharSet::Traits::compare(*b1, *b2);
    }

    if (diff < 0) {
      do {
        if (m2 == end_m2) {
          return false;
        }
        diff = CharSet::Traits::compare(*b1, *m2);
        ++m2;
      } while (diff < 0);
      if (diff > 0) {
        return false;
      }
      ++b1;
    }
    else if (diff > 0) {
      do {
        if (m1 == end_m1) {
          return false;
        }
        diff = CharSet::Traits::compare(*b2, *m1);
        ++m1;
      } while (diff < 0);
      if (diff > 0) {
        return false;
      }
      ++b2;
    }
    else {
      ++b1;
      ++b2;
    }
  }
}
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()
Example #7
0
void AsUser(TPortoAPI &api, TUser &user, TGroup &group) {
    AsRoot(api);

    Expect(setregid(0, group.GetId()) == 0);
    Expect(setreuid(0, user.GetId()) == 0);
}