// ----------------------------------------------------------------------------- // CMPXClientList::AddSubscriptionL // ----------------------------------------------------------------------------- // EXPORT_C void CMPXClientList::AddSubscriptionL( TInt aIndex, CMPXSubscription* aSubscription) { MPX_FUNC("CMPXClientList::AddSubscriptionL"); CClientId* id( iClients[aIndex] ); TInt subCount( id->iSubscriptions.Count() ); const CMPXMediaArray* items = id->iSubscriptions[0]->ItemsL(); // check if it has an empty subscription if ( 1 == subCount && items->Count() ) { // remove it if so id->RemoveAllSubscriptionsL(); } // add the new subscription id->AddSubscriptionL(aSubscription); }
void Model::cleanupAfterParsing(Record const &prev) { if(gets("state") == "-") { def().set("state", prev.gets("state")); } if(gets("sprite") == "-") { def().set("sprite", prev.gets("sprite")); } for(int i = 0; i < subCount(); ++i) { Record &subDef = sub(i); if(subDef.gets("filename") == "-") subDef.set("filename", ""); if(subDef.gets("skinFilename") == "-") subDef.set("skinFilename", ""); if(subDef.gets("shinySkin") == "-") subDef.set("shinySkin", ""); if(subDef.gets("frame") == "-") subDef.set("frame", ""); } }
// ----------------------------------------------------------------------------- // CMPXClientList::IsMsgSubscribedL // ----------------------------------------------------------------------------- // TBool CMPXClientList::IsMsgSubscribedL(TInt aIndex, const CMPXMessage* aMsg) { // check the subscriptions TBool IsSubScribed(EFalse); TInt subCount(iClients[aIndex]->iSubscriptions.Count()); if (subCount) { const CMPXMediaArray* subscriptionItems = iClients[aIndex]->iSubscriptions[0]->ItemsL(); if (1==subCount && (0== subscriptionItems->Count())) {// one empty subscription - send everything IsSubScribed = ETrue; } else {// have to check the message against the subscriptions. MPX_ASSERT(aMsg); const TArray<TMPXAttribute> msgAttrs = aMsg->Attributes(); TInt msgAttrCount(msgAttrs.Count()); // iterate subscriptions for (TInt subIndex = 0; subIndex<subCount && !IsSubScribed; ++subIndex) { // iterate items for the current subscription subscriptionItems = iClients[aIndex]->iSubscriptions[subIndex]->ItemsL(); TInt itemCount(subscriptionItems->Count()); for (TInt itemIndex = 0; itemIndex < itemCount; ++itemIndex) { // check the message attributes for the current subscription item TBool subMatch(ETrue); TInt attrMatchCount(0); CMPXSubscriptionItem* subItem(subscriptionItems->AtL(itemIndex)); for (TInt msgAttrIndex = 0; msgAttrIndex < msgAttrCount; ++msgAttrIndex) { TBool attrExists(EFalse); TBool attrMatch(EFalse); const TMPXAttribute& msgAttr( msgAttrs[msgAttrIndex] ); if ( subItem->IsSupported(msgAttr)) { attrExists = ETrue; if ( subItem->Match( *aMsg, msgAttr )) { attrMatch = ETrue; attrMatchCount++; } } if (attrExists && !attrMatch) { subMatch = EFalse; break; } } // send the message if all attributes that exist in both the message and the subscription // have the same values and all subscription attributes match if ( subMatch && ( attrMatchCount == subItem->Count()) ) { IsSubScribed = ETrue; break; } } } } } // else subCount = 0, IsSubScribed = EFalse (default) return IsSubScribed; }
bool Model::hasSub(int index) const { return index >= 0 && index < subCount(); }