// ---------------------------------------------------------------------------
// TPresCondIdentityMany::AddIdentitiesInManyExceptL()
// ---------------------------------------------------------------------------
//
EXPORT_C TInt TPresCondIdentityMany::AddIdentitiesInManyExceptL(const TDesC& aRuleID,
        const CDesCArray& aIds, const TDesC& aDomain)
{
    OPENG_DP(D_OPENG_LIT( "TPresCondIdentityMany::AddIdentitiesInManyExceptL()" ) );
    OPENG_DP(D_OPENG_LIT( "     aRuleID:%S,aDomain:%S"),
             &aRuleID, &aDomain);

    TInt ret(KErrNotFound);

    RPointerArray<CXdmDocumentNode> nodes;
    CXdmDocumentNode* exceptNode(NULL);
    CXdmNodeAttribute* idattr(NULL);

    CXdmDocumentNode* manyNode = GetManyNodeL(aRuleID, EFalse, aDomain);
    TInt entitiesCount = aIds.MdcaCount();
    if(manyNode!=NULL)
    {
        for (TInt i = 0; i<entitiesCount; i++)
        {
            // if id doesnt exists in except
            if (!(IsIdentityExistsInManyExceptL(aRuleID, aIds.MdcaPoint(i), aDomain)))
            {
                exceptNode = manyNode->CreateChileNodeL(KXdmExcept);
                idattr = exceptNode->CreateAttributeL(KXdmId);
                idattr->SetAttributeValueL(aIds.MdcaPoint(i));
                ret = KErrNone;
            }
        }
        ret = KErrNone;
    }

    OPENG_DP(D_OPENG_LIT( "     return: %d"),ret);
    nodes.Close();
    return ret;
}
// --------------------------------------------------------------------------
// UPnPAppSettingPageHomeIAP::CreateAndExecuteSettingPageL ()
// --------------------------------------------------------------------------
//
void UPnPAppSettingItemHomeIAP::CreateAndExecuteSettingPageL()
    {
    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
    // if sharing is on, only information note is displayed
    UPnPAVControllerFactory::TAVControllerServerStatus status;
    UPnPAVControllerFactory::Status( status );
    if ( iSharingState || status == UPnPAVControllerFactory::EStatusActive )
        {
        CAknInformationNote* note = new (ELeave) CAknInformationNote;
        CleanupStack::PushL(note);
        HBufC* noteText = iCoeEnv->AllocReadResourceLC(
            R_QTN_IUPNP_IAP_TURN_SHARING_OFF);
        note->ExecuteLD(*noteText);
        CleanupStack::PopAndDestroy(noteText);
        CleanupStack::Pop(note);
        return;
        }

    // Resets the member array for iap ids.
    // Creates new array for iap names.
    iIAPIdArray.Reset();
    CDesCArray* array = new (ELeave) CDesCArrayFlat(5);
    CleanupStack::PushL(array);

    // adds static setting page items from resource
    // and stores the number of static items.
    AddStaticItemsL(array);
    TInt staticItemCount = array->Count();
    
    // adds wlan access points, array GETS the ownership
    CUPnPSettingsEngine::GetWLANAccessPointsL( array, iIAPIdArray );
    
    MAknQueryValue* qValue = QueryValue();
    User::LeaveIfNull(qValue);
    LoadL();
    StoreL();

    TInt idx = GetIAPIndex( staticItemCount );
    if ( idx >= array->MdcaCount() )
        {
        idx = array->MdcaCount() - 1;
        }
    // setting page is launched
    CAknSettingPage* dlg = new (ELeave) CAknRadioButtonSettingPage(
        SettingPageResourceId(),
        idx,
        array);

    if (dlg->ExecuteLD())
        {
        switch (idx)
            {
            case EUPnPSettingsEngineIAPItemNone:
                {
                DisplayInfoL(R_IBU_GALLERY_UPDATE_NOTE_TITLE_TEXT,
                             R_IBU_GALLERY_UPDATE_NOTAVAIL_NOTE_TEXT,
                             R_HOMECONNECT_INFO_QUERY);
                qValue->SetCurrentValueIndex(EUPnPSettingsEngineIAPItemNone);
                iIAPId = EUPnPSettingsEngineIAPIdNone;
                iIAPSetting = EUPnPSettingsEngineIAPItemNone;
                break;
                }
            case EUPnPSettingsEngineIAPItemAlwaysAsk:
                {
                qValue->SetCurrentValueIndex(EUPnPSettingsEngineIAPItemAlwaysAsk);
                iIAPId = EUPnPSettingsEngineIAPIdAlwaysAsk;
                iIAPSetting = EUPnPSettingsEngineIAPItemAlwaysAsk;
                DisplayInfoL(R_IBU_GALLERY_UPDATE_NOTE_TITLE_TEXT,
                             R_IBU_GALLERY_UPDATE_NOTE_TEXT,
                             R_HOMECONNECT_INFO_QUERY);
                break;
                }
            case EUPnPSettingsEngineIAPItemUserDefined: // Create new
                {
                // new iap wlan iap creation is started here
                
                TInt old_iap = iIAPId;
                
                CUPnPSettingsEngine::CreateAccessPointL();
                
                //We have to re-get all the wlan iaps again since
                //user may modify the iap list   
                RArray<TInt64> newArray;
                CleanupClosePushL( newArray );
                
                //We only are interested in the iap ids
                CUPnPSettingsEngine::GetWLANAccessPointsL(
                                                    NULL, 
                                                    newArray );
                
                if( newArray.Count() <= 0 ) //if no iap exisits
                    {
                    //if previous iap is not "None" or "Always ask"
                    if( old_iap > EUPnPSettingsEngineIAPIdAlwaysAsk )
                        {
                        DisplayInfoL(
                            R_IBU_GALLERY_UPDATE_NOTE_TITLE_TEXT,
                            R_IBU_GALLERY_UPDATE_NOTAVAIL_NOTE_TEXT,
                            R_HOMECONNECT_INFO_QUERY);
                        iIAPId = EUPnPSettingsEngineIAPIdNone;
                        
                        qValue->SetCurrentValueIndex(
                                            EUPnPSettingsEngineIAPItemNone );
                        iIAPSetting = EUPnPSettingsEngineIAPItemNone;
                        }
                    iIAPIdArray.Reset();
                    CleanupStack::PopAndDestroy( &newArray );
                    }
                else
                    {
                    TBool newiap = ETrue;
                    TInt lastItemIndex = newArray.Count() - 1;
                    //if the last item on the new iap list 
                    //is found in the old iap array
                    //then we think no new iap is created
                    for( TInt i = 0; i < iIAPIdArray.Count(); i++ )
                        {                        
                        if( newArray[lastItemIndex] == iIAPIdArray[i] )
                            {
                            newiap = EFalse; 
                            i = iIAPIdArray.Count();
                            }
                        }
                    
                    //get the new iap list
                    iIAPIdArray.Reset();
                    for( TInt i = 0; i < newArray.Count(); i++ )
                        {
                        iIAPIdArray.AppendL( newArray[i] );
                        }                        
                    CleanupStack::PopAndDestroy( &newArray );
                    
                    if( newiap )
                        {
                        iIAPId = iIAPIdArray[lastItemIndex];//get new iap
                        iIAPSetting = 
                                EUPnPSettingsEngineIAPItemUserDefined;
                        // show confirmation note if connection is 
                        // unsecured, the database store the value of
                        // the securitymode,such as EOpen,EWep,E802_1x,
                        // EWpa,if select other securitymode except 
                        // EOpen, the return value of the 
                        // CheckAPSecurityL fuction is not EWLanUnsecured
                        if ( CheckAPSecurityL(iIAPId) == EWLanUnsecured )
                            {
                            CAknQueryDialog* dlg = 
                                                CAknQueryDialog::NewL();
                            if (!(dlg->ExecuteLD(
                            R_UNSECURED_CONNECTIONS_CONFIRMATION_QUERY)))
                                {
                                //user cancels the dialog
                                UsePreviousIapL( old_iap ); 
                                }
                            }
                        else
                            {
                            // show 'Sharing Changed' note ( None -> sharing)
                            if(old_iap == EUPnPSettingsEngineIAPIdNone &&
                               iIAPId != old_iap )
                                {
                                DisplayInfoL(
                                     R_IBU_GALLERY_UPDATE_NOTE_TITLE_TEXT,
                                     R_IBU_GALLERY_UPDATE_NOTE_TEXT,
                                     R_HOMECONNECT_INFO_QUERY);
                                }  
                            }    
                        }
                    else 
                        {
                        UsePreviousIapL(old_iap);
                        } //if( newiap )
                    } //if( newArray.Count() <= 0 )
                break;
                }
            default: // Predefined iap is selected
                {
                TInt index;
                TInt old_iap = iIAPId;
                TBool iapchange = EFalse;
                // iap id is set
                if ( idx - staticItemCount >= 0 )
                    {
                    index = idx - staticItemCount;
                    if (CheckAPSecurityL(iIAPIdArray[index]) ==
                        EWLanUnsecured)
                        {
                        // show confirmation note if connection is unsecured
                        CAknQueryDialog* dlg = CAknQueryDialog::NewL();
                        if (dlg->ExecuteLD(
                            R_UNSECURED_CONNECTIONS_CONFIRMATION_QUERY))
                            {
                            //if "Continue"
                            iapchange = ETrue;
                            }
                        }
                    else
                        {
                        iapchange = ETrue;
                        }
                   
                    if( iapchange )
                        {
                        iIAPSetting = EUPnPSettingsEngineIAPItemUserDefined;
                        iIAPId = iIAPIdArray[index];
                        qValue->SetCurrentValueIndex(
                            EUPnPSettingsEngineIAPItemUserDefined);

                        // if previous iap was 'None' and current iap
                        // is not 'None'
                        if ( old_iap == EUPnPSettingsEngineIAPIdNone &&
                             iIAPId != old_iap )
                            {
                            DisplayInfoL(
                                R_IBU_GALLERY_UPDATE_NOTE_TITLE_TEXT,
                                R_IBU_GALLERY_UPDATE_NOTE_TEXT,
                                R_HOMECONNECT_INFO_QUERY);
                            }
                        }
                    }
                break;
                }
            }
        }
    LoadL();
    StoreL();

    CleanupStack::PopAndDestroy(array);
    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
    }
Пример #3
0
LOCAL_C TBool CompareLogsL()
	{
	TBool errorOccured = EFalse;

	CDesCArray* correctFile = new (ELeave) CDesCArrayFlat(1);
	CPtrCArray* resultFile = new (ELeave) CPtrCArray(1);

	TParse parsedFileName;
	TParse parsedResultFileName;
	TFileName name;
	name.Append(KOkFileNameEntryStructure);
	testUtils->ResolveFile(KComponent, name, parsedFileName);
	correctFile->AppendL(parsedFileName.FullName());
	name.Zero();
	name.Copy(KFileNameEntryStructure);
	testUtils->ResolveLogFile(name, parsedResultFileName);
	resultFile->AppendL(parsedResultFileName.FullName());

	RFileReadStream file1;
	RFileReadStream file2;
	HBufC8* line1Buffer = HBufC8::NewLC(1024);
	TPtr8 line1 = line1Buffer->Des();
	TBuf8<1> aChar1;

	HBufC8* line2Buffer = HBufC8::NewLC(1024);
	TPtr8 line2 = line2Buffer->Des();
	TBuf8<1> aChar2;

	for(TInt i=0; i<correctFile->MdcaCount(); i++)
		{
		TFileName file1Name = correctFile->MdcaPoint(i);

		TFileName file2Name = resultFile->MdcaPoint(i);

		TInt error1=KErrNone;
		TInt error2=KErrNone;
		
		test.Printf(_L("\n%s"), file2Name.PtrZ());

		error1=file1.Open(testUtils->FileSession(), file1Name, EFileShareAny);
		if(error1!=KErrNone)
			{
			errorOccured = ETrue;
			}
		else
			{
			error2=file2.Open(testUtils->FileSession(), file2Name, EFileShareAny);
			if(error2!=KErrNone)
				{
				errorOccured = ETrue;
				}
			}
		
		if((error1==KErrNone)&&(error2==KErrNone))
			{
			// read the file into the conversion object
			TBool finished = EFalse;
	
			do	{
				line1.FillZ();
				line1.SetLength(0);
				// compile the lines one char at a time
				do	{
					TRAPD( error, file1.ReadL(aChar1, 1) ); 
					if (error!=KErrEof)
						line1.Append(aChar1);
					else
						{
						finished = ETrue;
						break;
						}
					// stop at the end of line or no more data
					}
				while((aChar1[0]!=0x0A)&&(line1.Length()<1024));

				line2.FillZ();
				line2.SetLength(0);
				do	{
					TRAPD( error, file2.ReadL(aChar2, 1) ); 
					if (error!=KErrEof)
						line2.Append(aChar2);
					else
						{
						finished = ETrue;
						break;
						}
					// stop at the end of line or no more data
					}
				while((aChar2[0]!=0x0A)&&(line2.Length()<1024));
				
				// get rid of white space
				line1.TrimRight();
				line2.TrimRight();

   				if(line1.Compare(line2) != 0)
					{
					// error so no point in continuing to compare!!
					errorOccured = ETrue;
					file1.Close();
					file2.Close();
					delete correctFile;
					delete resultFile;
					CleanupStack::PopAndDestroy(2);  //line 1 , line 2
					return ETrue;
					}
				}
			while(!finished);
			}		

		file1.Close();
		file2.Close();
		}

	delete correctFile;
	delete resultFile;
	CleanupStack::PopAndDestroy(2);  //line 1 , line 2
	
	return errorOccured;
	}
TInt X509CertNameParser::GetNamePartsL( 
                             const CX500DistinguishedName& aDN, 
                             const CX509CertExtension* aExtension, 
                             CDesCArray& aNameArray, 
                             TX509CNPNameType aNameType)
    {
    const CX509AltNameExt* altNameExt = NULL;
    
    if (aExtension)
        {
        altNameExt = CX509AltNameExt::NewLC( aExtension->Data() ); 
        }

    TBool notFound = ETrue; 
    
    // In case of PrimaryAndSecondaryName loop goes through name elements
    // until two of them is found.
    // In case of FullNames loop goes through all supported name element and
    // adds founded names to array.
    for( TInt round = 1; notFound; round++ )
        {
        switch( round )
            {
            case EDNCommonName:
                {
                GetDNPartL( aDN, KX520CommonName, aNameArray );
                break;
                }
            case ECritAltRFC822Name:
                {
                if (aExtension && aExtension->Critical())
                    {
                    GetAltNamePartL( *altNameExt, EX509RFC822Name, aNameArray );
                    }
                break;
                }
            case EDNOrganizationName:
                {
                GetDNPartL( aDN, KX520OrganizationName, aNameArray);    
                break;  
                }
            case EDNOrganizationalUnitName:
                {
                if ( aNameType == EX509CNPPrimAndSecond )
                    {
                    GetDNPartL( aDN, KX520OrganizationalUnitName, aNameArray);    
                    }
                else
                    {
                    GetDNPartAllL( aDN, KX520OrganizationalUnitName, aNameArray);    
                    }
                break;
                }
            case ECritAltURI:
                {
                if (aExtension && aExtension->Critical())
                    {
                    GetAltNamePartL( *altNameExt, EX509URI, aNameArray );
                    }
                break;
                }
            case ECritAltDNSName:
                {
                if (aExtension && aExtension->Critical())
                    {
                    GetAltNamePartL( *altNameExt, EX509DNSName, aNameArray);
                    }
                break;
                }
            case ECritAltDirectoryName:
                {
                if (aExtension && aExtension->Critical())
                    {
                    GetAltNamePartL( *altNameExt, EX509DirectoryName, 
                                     aNameArray );                                   
                    }
                break;
                }
            case ECritAltIPAddress:
                {
                if (aExtension && aExtension->Critical())
                    {
                    GetAltNamePartL( *altNameExt, EX509IPAddress, 
                                     aNameArray );                                   
                    }
                break;
                } 
            case EAltRFC822Name:
                {
                if (aExtension)
                    {
                    GetAltNamePartL( *altNameExt, EX509RFC822Name, 
                                      aNameArray );
                    }
                break;
                }
            case EAltURI:
                {
                if ( aExtension )
                    {
                    GetAltNamePartL( *altNameExt, EX509URI, aNameArray );
                    }
                break;
                }
            case EAltDNSName:
                {
                if ( aExtension )
                    {
                    GetAltNamePartL( *altNameExt, EX509DNSName, aNameArray );
                    }  
                break;
                }
            case EDNCountryName:
                {
                GetDNPartL( aDN, KX520CountryName, aNameArray );
                break;
                }
            case EDNStateOrProvinceName:
                {
                GetDNPartL( aDN, KX520StateOrProvinceName, aNameArray );
                break;
                }
            case EDNLocalityName:
                {
                GetDNPartL( aDN, KX520LocalityName, aNameArray );
                break;
                }
            case EAltDirectoryName:
                {
                if ( aExtension )
                    {
                    GetAltNamePartL( *altNameExt, EX509DirectoryName, 
                                     aNameArray );
                    }
                break;
                }
            case EAltIPAddress:
                {
                if ( aExtension )
                    {
                    GetAltNamePartL( *altNameExt, EX509IPAddress, 
                                     aNameArray );                                   
                    }
                break;
                }    
            default:
                {
                // All the names are gone through.
                notFound = EFalse;
                break;
                }
            } // switch

        if ( notFound ) 
            {
            // If caller is PrimaryAndSecondaryNameL and PrimaryName and
            // SecondaryName have found then end loop.
            if ( aNameType == EX509CNPPrimAndSecond &&  
               ( aNameArray.MdcaCount() >= KX509CNPPrimAndSecondNameLengh ) )
                {
                notFound = EFalse;    
                } // if
            } // if 
        } // for
    
    if ( aExtension )
        {
        CleanupStack::PopAndDestroy(); // altNameExt
        }
    return KErrNone;
    }
void CPhotoListView::GetFolder()
{
	TInt PopValue;	
	//TBuf<150> msg;
	TInt count=0;	
	
	CDesCArray* items = iPhotosAppUi->GetFolderList();	
    CDesCArray* foldernames = iPhotosAppUi->ReturnText();

	if (items == NULL)
	{
		Count = 0;
		items = new (ELeave) CDesCArrayFlat(1);
		items->AppendL(foldernames->MdcaPoint(0));
	}
	else
	{
		Count = items->MdcaCount();	
		items->AppendL(foldernames->MdcaPoint(0));
	}
	foldernames->Reset();

	CEikTextListBox* list = new( ELeave ) CAknSinglePopupMenuStyleListBox;
    CleanupStack::PushL( list );

    CAknPopupList* popupList = CAknPopupList::NewL(
       list,
       R_AVKON_SOFTKEYS_SELECT_CANCEL,
       AknPopupLayouts::EMenuWindow);

    CleanupStack::PushL( popupList );
    
    popupList->SetMaximumHeight(2);

    list->ConstructL( popupList, CEikListBox::ELeftDownInViewRect );
    list->CreateScrollBarFrameL( ETrue );
    list->ScrollBarFrame()->SetScrollBarVisibilityL(
		   CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );

    CTextListBoxModel* model = list->Model();
    model->SetItemTextArray( items );
    model->SetOwnershipType( ELbmOwnsItemArray );
	
	count = GetPhotoCount();

//	TInt price;
//	TLex lex(iPhotosAppUi->iCharge);
//	lex.Val(price);
//	count = count * price;

//	TBuf<30> temp;
//	temp.AppendNum(count);	

//	msg.Copy(_L("Charge "));
//	msg.Append(temp);
//	msg.Append(_L(" pesos"));

	//msg.Copy(_L("Select Album:"));
	//msg.Copy(*(iEikonEnv->AllocReadResourceL(R_IMAGES_SELECT_ALBUM)));
	
	/*count = count / 3;
	temp.Copy(_L(""));
	temp.AppendNum(count);

	path = iPhotosAppUi->ImageFolderPath();
	if(path == 0 || path == 1)			
		msg.Append(_L(" Photos)"));
	else if(path == 2 || path == 3)
		msg.Append(_L(" Videos)"));*/

	popupList->SetTitleL(*(iEikonEnv->AllocReadResourceL(R_IMAGES_SELECT_ALBUM)));

	PopValue = popupList->ExecuteLD();		
	
	if(PopValue==0)
	{
		iFolderStatus=-1;
	}
	else if(PopValue==1)
	{
		PopValue=list->CurrentItemIndex();		
		iFolderStatus=PopValue;		
		TPtrC ptr1(items->MdcaPoint(PopValue));
		comment.Copy(ptr1);		
	}
	
	items->Reset();
	CleanupStack::Pop(); // popupList
    CleanupStack::PopAndDestroy(); // list	

}