// ----------------------------------------------------------------------------- // CLandmarksEditDialog::FetchFloatL // // (other items were commented in a header). // ----------------------------------------------------------------------------- // void CLandmarksEditDialog::FetchFloatL( TRealX& aFloat, TInt aEditorResourceId, TInt aErrorResourceId) { const TChar KDecimalPoint = '.'; TBuf<KPosLmMaxTextFieldLength> textFieldValue; TLex fieldLex; TInt result(KErrNone); CEikEdwin* editor = static_cast <CEikEdwin*> (Control(aEditorResourceId)); editor->GetText(textFieldValue); if (textFieldValue == KNullDesC) { // User has indicated that he/she wants this value to be undefined. aFloat.SetNaN(); } else { // Try to extract value fieldLex = textFieldValue; TReal floatValue(0); result = fieldLex.Val(floatValue, KDecimalPoint); if (result != KErrNone) { NotifyErrorToUserL(aErrorResourceId); } // Update output parameter User::LeaveIfError(aFloat.Set(floatValue)); } }
TBool CEmTubeVideoUploadDialog::SaveFormDataL() { TBuf<KUploadVideoMaxFieldLength> data; CEikEdwin* editor; editor = static_cast <CEikEdwin*> (Control(EUploadVideoFieldTitle)); editor->GetText( data ); iQueueEntry->SetTitleL( data ); editor = static_cast <CEikEdwin*> (Control(EUploadVideoFieldDescription)); editor->GetText( data ); iQueueEntry->SetDescriptionL( data ); editor = static_cast <CEikEdwin*> (Control(EUploadVideoFieldTags)); editor->GetText( data ); iQueueEntry->SetTagsL( data ); CAknPopupFieldText* popup = static_cast<CAknPopupFieldText*>(ControlOrNull(EUploadVideoFieldPublic)); switch ( popup->CurrentValueIndex() ) { case 0: iQueueEntry->SetPublic( ETrue ); break; case 1: iQueueEntry->SetPublic( EFalse ); break; } popup = static_cast<CAknPopupFieldText*>(ControlOrNull(EUploadVideoFieldCategory)); iQueueEntry->SetCategory( KCategories[ popup->CurrentValueIndex() ] ); return ETrue; }
// ----------------------------------------------------------------------------- // CLandmarksEditDialog::UpdateTitleBarL // // (other items were commented in a header). // ----------------------------------------------------------------------------- // void CLandmarksEditDialog::UpdateTitleBarL(TBool aFromField) { if (aFromField) { TBuf<KPosLmMaxTextFieldLength> name; CEikEdwin* nameEditor = static_cast<CEikEdwin*>(Control(ELandmarkNameField)); nameEditor->GetText(name); iTitlePane->SetTextL(name); } else { TPtrC ptr; iLandmark->GetLandmarkName(ptr); iTitlePane->SetTextL(ptr); } }
TBool CCreate2WayVideoSessionDialog::OkToExitL( TInt aKey ) { if ( aKey == EEikCmdCanceled ) { // Cancel pressed. Just exit. return ETrue; } CEikEdwin* edwinRecipientAddress = static_cast<CEikEdwin*>( Control( ESessionDialog2WayVideoRecipientAddress ) ); TBuf<KBufLength> buffer; edwinRecipientAddress->GetText(buffer); iParams->iRecipentAddress = buffer; CAknPopupFieldText* popupFieldText = static_cast <CAknPopupFieldText*> (Control(ESessionDialog2WayVideoVideoCodec)); TInt index = popupFieldText->CurrentValueIndex(); if(index == 0) { iParams->iVideoCodec = TSessionParams::EMceCodecSingle; } else if ( index == 1 ) { iParams->iVideoCodec = TSessionParams::EMceCodecAll; } else { iParams->iVideoCodec = TSessionParams::EMceCodecMultipleModes; } popupFieldText = static_cast <CAknPopupFieldText*> (Control(ESessionDialog2WayVideoAudioCodec)); index = popupFieldText->CurrentValueIndex(); if(index == 0) { iParams->iAudioCodec = TSessionParams::EMceCodecSingle; } else if (index == 1) { iParams->iAudioCodec = TSessionParams::EMceCodecAll; } else { iParams->iAudioCodec = TSessionParams::EMceCodecNone; } popupFieldText = static_cast <CAknPopupFieldText*> (Control(ESessionDialog2WayVideoViewFinder)); index = popupFieldText->CurrentValueIndex(); if(index == 0) { iParams->videoSinkDisplay = TSessionParams::EMceViewFinderDisabled; } else { iParams->videoSinkDisplay = TSessionParams::EMceViewFinderEnabled; } popupFieldText = static_cast <CAknPopupFieldText*> (Control(ESessionDialog2WayVideoCamera)); index = popupFieldText->CurrentValueIndex(); if(index == 0) { iParams->iCameraSetting = TSessionParams::EMceCameraPrimary; } else { iParams->iCameraSetting = TSessionParams::EMceCameraSecondary; } return ETrue; }
// ----------------------------------------------------------------------------- // CLandmarksEditDialog::SaveFormDataL // // (other items were commented in a header). // ----------------------------------------------------------------------------- // TBool CLandmarksEditDialog::SaveFormDataL() { CEikEdwin* editor = NULL; // Fetch name TBuf<KPosLmMaxTextFieldLength> name; editor = static_cast <CEikEdwin*> (Control(ELandmarkNameField)); editor->GetText(name); // Fetch description HBufC* descBuf = HBufC::NewLC(KPosLmMaxDescriptionLength); TPtr desc = descBuf->Des(); editor = static_cast <CEikEdwin*> (Control(ELandmarkDescField)); editor->GetText(desc); // Fetch existing location TLocality existingLocation; TBool locationExists = (iLandmark->GetPosition(existingLocation) == KErrNone); TRealX floatFieldValue; // Fetch Latitude TReal latitude = existingLocation.Latitude(); if (iIsRealValueEdited[ELatitudeEditor] || !locationExists) { FetchFloatL(floatFieldValue, ELandmarkLatitudeField, R_LMREFAPP_LATITUDE_ERROR); floatFieldValue.GetTReal(latitude); } // Fetch Longitude TReal longitude = existingLocation.Longitude(); if (iIsRealValueEdited[ELongitudeEditor] || !locationExists) { FetchFloatL(floatFieldValue, ELandmarkLongitudeField, R_LMREFAPP_LONGITUDE_ERROR); floatFieldValue.GetTReal(longitude); } // Fetch Altitude TReal32 altitude = existingLocation.Altitude(); if (iIsRealValueEdited[EAltitudeEditor] || !locationExists) { FetchFloatL(floatFieldValue, ELandmarkAltitudeField, R_LMREFAPP_ALTITUDE_ERROR); floatFieldValue.GetTReal(altitude); } // Fetch horizontal accuracy TReal32 horAcc = existingLocation.HorizontalAccuracy(); if (iIsRealValueEdited[EHorizontalAccEditor] || !locationExists) { FetchFloatL(floatFieldValue, ELandmarkHorAccField, R_LMREFAPP_HOR_ACC_ERROR); floatFieldValue.GetTReal(horAcc); } // Fetch vertical accuracy TReal32 verAcc = existingLocation.VerticalAccuracy(); if (iIsRealValueEdited[EVerticalAccEditor] || !locationExists) { FetchFloatL(floatFieldValue, ELandmarkVerAccField, R_LMREFAPP_VER_ACC_ERROR); floatFieldValue.GetTReal(verAcc); } // Fetch Coverage Radius TReal32 radius; TInt radiusExists = (iLandmark->GetCoverageRadius(radius) == KErrNone); if (iIsRealValueEdited[ERadiusEditor] || !radiusExists) { FetchFloatL(floatFieldValue, ELandmarkRadiusField, R_LMREFAPP_RADIUS_ERROR); floatFieldValue.GetTReal(radius); } // Fetch street TBuf<KPosLmMaxTextFieldLength> street; editor = static_cast <CEikEdwin*> (Control(ELandmarkStreetField)); editor->GetText(street); // Fetch postal code TBuf<KPosLmMaxTextFieldLength> postalCode; editor = static_cast <CEikEdwin*> (Control(ELandmarkPostalField)); editor->GetText(postalCode); // Fetch city TBuf<KPosLmMaxTextFieldLength> city; editor = static_cast <CEikEdwin*> (Control(ELandmarkCityField)); editor->GetText(city); // Fetch country TBuf<KPosLmMaxTextFieldLength> country; editor = static_cast <CEikEdwin*> (Control(ELandmarkCountryField)); editor->GetText(country); // Update category iLandmark->RemoveLandmarkAttributes(CPosLandmark::ECategoryInfo); for (TInt i = 0; i < iCategoryIds.Count(); i++) { iLandmark->AddCategoryL(iCategoryIds[i]); } // Check that at least some data is entered if (!name.Length() && !desc.Length() && !street.Length() && !city.Length() && !country.Length() && !postalCode.Length() && !iCategoryIds.Count() && Math::IsNaN(latitude) && Math::IsNaN(longitude) && Math::IsNaN(altitude) && Math::IsNaN(radius) && Math::IsNaN(horAcc) && Math::IsNaN(verAcc)) { NotifyErrorToUserL(R_LMREFAPP_EMPTY_LANDMARK); } // Update name iLandmark->SetLandmarkNameL(name); // Update description iLandmark->SetLandmarkDescriptionL(desc); CleanupStack::PopAndDestroy(descBuf); // Update coverage radius if (!Math::IsNaN(radius) && radius < 0) { NotifyErrorToUserL(R_LMREFAPP_RADIUS_ERROR); } iLandmark->SetCoverageRadius(radius); // Update street iLandmark->SetPositionFieldL(EPositionFieldStreet, street); // Update postal code iLandmark->SetPositionFieldL(EPositionFieldPostalCode, postalCode); // Update city iLandmark->SetPositionFieldL(EPositionFieldCity, city); // Update country iLandmark->SetPositionFieldL(EPositionFieldCountry, country); // Update location. There are some rules specified by TLocality and // TCoordinate how to update a location. These rules are taken into // account below when validating the location data. if (Math::IsNaN(latitude) && Math::IsNaN(longitude)) { // If lat long are undefined, then alt and hAcc // must be undefined if (!Math::IsNaN(horAcc)) { NotifyErrorToUserL(R_LMREFAPP_HACC_LAT_LONG_ERROR); } else if (!Math::IsNaN(altitude)) { NotifyErrorToUserL(R_LMREFAPP_ALT_LAT_LONG_ERROR); } else if (!Math::IsNaN(verAcc)) { NotifyErrorToUserL(R_LMREFAPP_VACC_ALT_ERROR); } else { // None position fields are set, Remove position info. iLandmark->RemoveLandmarkAttributes(CPosLandmark::EPosition); } } else if (!Math::IsNaN(latitude) && !Math::IsNaN(longitude)) { // If lat long are defined, hAcc must be positive if defined if (!Math::IsNaN(horAcc) && horAcc < 0) { NotifyErrorToUserL(R_LMREFAPP_HOR_ACC_ERROR); } // if altitude is undefined, then vertical accuracy // must be undefined if (Math::IsNaN(altitude) && !Math::IsNaN(verAcc)) { NotifyErrorToUserL(R_LMREFAPP_VACC_ALT_ERROR); } // vertical accuracy must be positive if defined if (!Math::IsNaN(verAcc) && verAcc < 0) { NotifyErrorToUserL(R_LMREFAPP_VER_ACC_ERROR); } // We are allowed to set the new locality TCoordinate coordinate(latitude, longitude, altitude); TLocality newLocation(coordinate, horAcc, verAcc); iLandmark->SetPositionL(newLocation); } else { // Inform user that no valid lat/long has been entered NotifyErrorToUserL(R_LMREFAPP_LAT_LONG_ERROR); } iEdited = ETrue; return ETrue; }