562 TInt nodeCount = nodes.Count(); |
562 TInt nodeCount = nodes.Count(); |
563 for ( TInt i = 0; i < nodeCount; i++ ) |
563 for ( TInt i = 0; i < nodeCount; i++ ) |
564 { |
564 { |
565 CXdmDocumentNode* currNode = nodes[i]; |
565 CXdmDocumentNode* currNode = nodes[i]; |
566 attr = ( currNode )->Attribute( KPresenceId ); |
566 attr = ( currNode )->Attribute( KPresenceId ); |
567 |
567 if ( attr && !attr->AttributeValue().CompareF( aUri )) |
568 TBool uriMatch = CompareUriWithoutPrefixL( |
|
569 aUri, attr->AttributeValue() ); |
|
570 |
|
571 if ( attr && uriMatch ) |
|
572 { |
568 { |
573 DP_SDA("RemoveOneFromRule Remove"); |
569 DP_SDA("RemoveOneFromRule Remove"); |
574 //First remove currNode form model |
570 //First remove currNode form model |
575 iPresRulesDoc->RemoveFromModelL( currNode ); |
571 iPresRulesDoc->RemoveFromModelL( currNode ); |
576 |
572 |
649 // Find identityNode inside rulenode |
645 // Find identityNode inside rulenode |
650 User::LeaveIfError( |
646 User::LeaveIfError( |
651 ruleNode->Find( KPresenceIdentity, identityNode ) ); |
647 ruleNode->Find( KPresenceIdentity, identityNode ) ); |
652 if ( identityNode[0] ) |
648 if ( identityNode[0] ) |
653 { |
649 { |
654 if ( identityNode[0]->IsEmptyNode() ) |
650 if ( identityNode[0]->IsEmptyNode() ) |
655 { |
651 { |
656 DP_SDA("DoOneAddUserL rule node empty"); |
652 DP_SDA("DoOneAddUserL rule node empty"); |
657 identityNode[0]->SetEmptyNode( EFalse ); |
653 identityNode[0]->SetEmptyNode( ETrue ); |
658 } |
654 } |
659 |
655 // create new one node inside identity |
660 // create new one node inside identity |
656 CXdmDocumentNode* newNode = |
661 CXdmDocumentNode* newNode = |
|
662 identityNode[0]->CreateChileNodeL( KPresenceOne ); |
657 identityNode[0]->CreateChileNodeL( KPresenceOne ); |
663 CXdmNodeAttribute* attributeOneId = |
658 newNode->SetEmptyNode( ETrue ); |
|
659 CXdmNodeAttribute* attributeOneId = |
664 newNode->CreateAttributeL( KPresenceId ); |
660 newNode->CreateAttributeL( KPresenceId ); |
665 |
661 |
666 attributeOneId->SetAttributeValueL( aUri ); |
662 attributeOneId->SetAttributeValueL( aUri ); |
667 iPresRulesDoc->AppendL(); |
663 iPresRulesDoc->AppendL(); |
668 DP_SDA("DoOneAddUserL added"); |
664 DP_SDA("DoOneAddUserL added"); |
669 } |
665 } |
670 } |
666 } |
671 } |
667 } |
672 else |
668 else |
673 { |
669 { |
872 TInt nodeCount = nodes.Count(); |
868 TInt nodeCount = nodes.Count(); |
873 for ( TInt i = 0; i < nodeCount; i++ ) |
869 for ( TInt i = 0; i < nodeCount; i++ ) |
874 { |
870 { |
875 CXdmDocumentNode* currNode = nodes[i]; |
871 CXdmDocumentNode* currNode = nodes[i]; |
876 attr = ( currNode )->Attribute( KPresenceId ); |
872 attr = ( currNode )->Attribute( KPresenceId ); |
877 |
873 if ( attr && !attr->AttributeValue().CompareF( aUri )) |
878 TBool uriMatch( EFalse ); |
|
879 uriMatch = CompareUriWithoutPrefixL( |
|
880 aUri, attr->AttributeValue() ); |
|
881 |
|
882 if ( attr && uriMatch ) |
|
883 { |
874 { |
884 DP_SDA("CheckIfOneExistL entity exists"); |
875 DP_SDA("CheckIfOneExistL entity exists"); |
885 //Enity is exist |
876 //Enity is exist |
886 state = ETrue; |
877 state = ETrue; |
887 break; |
878 break; |
1100 currNode = NULL; |
1091 currNode = NULL; |
1101 } |
1092 } |
1102 |
1093 |
1103 CleanupStack::PopAndDestroy(); // clItem |
1094 CleanupStack::PopAndDestroy(); // clItem |
1104 CleanupStack::PopAndDestroy(); // clItem2 |
1095 CleanupStack::PopAndDestroy(); // clItem2 |
1105 DP_SDA("CPresencePluginXdmPresRules::SearchListUnderParentL return"); |
1096 DP_SDA("CPresencePluginXdmUtils::SearchListUnderParentL return"); |
1106 return currNode; |
1097 return currNode; |
1107 } |
1098 } |
1108 |
1099 |
1109 |
|
1110 // --------------------------------------------------------------------------- |
|
1111 // CPresencePluginXdmPresRules::SearchListUnderParentL |
|
1112 // --------------------------------------------------------------------------- |
|
1113 // |
|
1114 TBool CPresencePluginXdmPresRules::CompareUriWithoutPrefixL( |
|
1115 const TDesC& aUri, const TDesC& aAttribute ) |
|
1116 { |
|
1117 DP_SDA("CPresencePluginXdmPresRules::CompareUriWithoutPrefixL"); |
|
1118 |
|
1119 TBool match( EFalse ); |
|
1120 |
|
1121 RBuf uriWithoutPrefix; |
|
1122 CleanupClosePushL( uriWithoutPrefix ); |
|
1123 uriWithoutPrefix.CreateL( aUri ); |
|
1124 TInt prefixLocation = uriWithoutPrefix.Locate( ':' ); |
|
1125 |
|
1126 if ( KErrNotFound != prefixLocation ) |
|
1127 { |
|
1128 uriWithoutPrefix.Delete( 0, ( prefixLocation + 1 ) ); |
|
1129 } |
|
1130 |
|
1131 RBuf attributeWithoutprefix; |
|
1132 CleanupClosePushL( attributeWithoutprefix ); |
|
1133 attributeWithoutprefix.CreateL( aAttribute ); |
|
1134 prefixLocation = attributeWithoutprefix.Locate( ':' ); |
|
1135 |
|
1136 if ( KErrNotFound != prefixLocation ) |
|
1137 { |
|
1138 attributeWithoutprefix.Delete( 0, ( prefixLocation + 1 ) ); |
|
1139 } |
|
1140 |
|
1141 DP_SDA2(" --> uri without prefix=%S", &uriWithoutPrefix ); |
|
1142 DP_SDA2(" --> attribute without prefix=%S", &attributeWithoutprefix ); |
|
1143 |
|
1144 if ( uriWithoutPrefix.Compare( attributeWithoutprefix ) == 0 ) |
|
1145 { |
|
1146 match = ETrue; |
|
1147 } |
|
1148 |
|
1149 CleanupStack::PopAndDestroy( &attributeWithoutprefix ); |
|
1150 CleanupStack::PopAndDestroy( &uriWithoutPrefix ); |
|
1151 |
|
1152 return match; |
|
1153 } |
|
1154 |
|
1155 // End of file |
1100 // End of file |