diff -r aecbbf00d063 -r d48ab3b357f1 commonuis/CommonUi/src/FindItemMenu.cpp --- a/commonuis/CommonUi/src/FindItemMenu.cpp Tue Aug 31 15:28:30 2010 +0300 +++ b/commonuis/CommonUi/src/FindItemMenu.cpp Wed Sep 01 12:16:19 2010 +0100 @@ -11,7 +11,7 @@ * * Contributors: * -* Description: +* Description: * */ @@ -28,7 +28,16 @@ #include +#include // for CSendAppUi +#include // for CMessageData + #include // Phonenumber parser +#include // Mtm uids + +#include // KFavouritesMaxUrl +#include // for CBookmarkItem + +#include #include // RApaLsSession for WMLBrowser launch #include @@ -44,15 +53,19 @@ #endif // !RD_VIRTUAL_PHONEBOOK #include "finditem.hrh" -#include +#include #include +// add to gallery related +#include + #include #include #include #include +#include // Callback query #include @@ -205,7 +218,7 @@ } delete iRPbkResourceFile; #endif // !RD_VIRTUAL_PHONEBOOK - + delete iSendUi; delete iSenderDescriptor; delete iServiceHandler; @@ -215,6 +228,7 @@ delete iCallbackNumber; + delete iSchemeHandler; delete iDialData; @@ -609,19 +623,17 @@ tempBuf); index = EFindItemCmdGoToUrl; - if ( !iIsContextMenu ) - { - // Add bookmark - iCoeEnv->ReadResourceL( - tempBuf, R_FINDITEMMENU_ADD_BOOKMARK ); - AddMenuItemL( - *iMenuPane, - EFindItemCmdAddToBookmark, - index, - 0, - tempBuf ); - index = EFindItemCmdAddToBookmark; - } + // Add bookmark + iCoeEnv->ReadResourceL( + tempBuf, R_FINDITEMMENU_ADD_BOOKMARK ); + AddMenuItemL( + *iMenuPane, + EFindItemCmdAddToBookmark, + index, + 0, + tempBuf ); + index = EFindItemCmdAddToBookmark; + } else { @@ -633,18 +645,16 @@ tempBuf ); index = EFindItemCmdGoToRstp; - if ( !iIsContextMenu ) - { - iCoeEnv->ReadResourceL( - tempBuf, R_FINDITEMMENU_ADD_TO_GALLERY ); - AddMenuItemL( - *iMenuPane, - EFindItemCmdAddToGallery, - index, - 0, - tempBuf ); - index = EFindItemCmdAddToGallery; - } + iCoeEnv->ReadResourceL( + tempBuf, R_FINDITEMMENU_ADD_TO_GALLERY ); + AddMenuItemL( + *iMenuPane, + EFindItemCmdAddToGallery, + index, + 0, + tempBuf ); + index = EFindItemCmdAddToGallery; + } break; } @@ -828,8 +838,6 @@ // Add to contacts if ( ( itemType != CItemFinder::EUriScheme ) && - !( itemType == CItemFinder::EUrlAddress && - iIsContextMenu ) && ( ( ( ( !iIsSenderKnown && iSenderDescriptor->Length() ) || iCallbackNumber ) && @@ -879,7 +887,8 @@ if ( ( !iHideCallMenu || ( iFindItemVoIPExtension->IsVoIPSupported() && iFindItemVoIPExtension->VoIPProfilesExistL() ) ) && - iMenuPane->MenuItemExists( EFindItemCmdCall, dummy ) ) + iMenuPane->MenuItemExists( EFindItemCmdCall, dummy ) && + !iHideCallSubMenu ) { iMenuPane->SetItemDimmed( EFindItemCmdCall, ETrue ); iMenuPane->AddMenuItemsL( @@ -888,6 +897,18 @@ } } + +// ----------------------------------------------------------------------------- +// CFindItemMenu::SetCallSubMenuVisibility +// Sets AIW submenu visibility +// ----------------------------------------------------------------------------- +// +EXPORT_C void CFindItemMenu::SetCallSubMenuVisibility( TBool aVisible ) + { + iHideCallSubMenu = !aVisible; + } + + EXPORT_C void CFindItemMenu::HandleItemFinderCommandL( TInt aCommand ) { switch ( aCommand ) @@ -899,17 +920,60 @@ } case EFindItemSubMenuSend: { + TSendingCapabilities sendingCapabilities; + sendingCapabilities.iFlags = TSendingCapabilities::ESupportsEditor; + CArrayFixFlat* mtmFilter = new(ELeave) CArrayFixFlat( 1 ); + CleanupStack::PushL(mtmFilter); + CItemFinder::TItemType itemType = iAutomaticFind ? iAutomaticFind->CurrentItemExt().iItemType : CItemFinder::ENoneSelected; + + mtmFilter->AppendL(KSenduiMtmPostcardUid);// dim postcard + // Hide SMS if not supported + + #ifndef RD_UNIFIED_EDITOR + if ( !iEmailOverSmsFeatureSupported ) + { + mtmFilter->AppendL(KSenduiMtmSmsUid); + } + // Hide MMS if not supported + if (!iMMSFeatureSupported) + { + mtmFilter->AppendL(KSenduiMtmMmsUid); + } + #endif + + // Hide E-Mail if nosupported or phonenumber + if ( !iEmailUiFeatureSupported || itemType == CItemFinder::EPhoneNumber ) + { + mtmFilter->AppendL(KSenduiMtmSmtpUid); + mtmFilter->AppendL(KSenduiMtmImap4Uid); + mtmFilter->AppendL(KSenduiMtmPop3Uid); + mtmFilter->AppendL(KSenduiMtmSyncMLEmailUid); + } + // Hide Audio if not supported or E-mail address + if( !iAudioMessagingFeatureSupported || itemType == CItemFinder::EEmailAddress) + { + mtmFilter->AppendL(KSenduiMtmAudioMessageUid); + } + TUid uid = iSendUi->ShowTypedQueryL( CSendUi::EWriteMenu, NULL, sendingCapabilities, mtmFilter ); + + CleanupStack::PopAndDestroy(); + if ( uid == KNullUid ) + { + break; + } + SendMessageL(uid); + break; } case EFindItemCmdGoToUrl: { - + LaunchGenericUriL(); break; } case EFindItemCmdGoToRstp: { - + LaunchGenericUriL(); break; } @@ -961,6 +1025,7 @@ case EFindItemCmdUse: { + LaunchGenericUriL(); break; } @@ -1087,7 +1152,29 @@ void CFindItemMenu::SendMessageL( const TUid aMtmUid ) { - + HBufC* parsedAddress = 0; + TBool isNumber = EFalse; + if ( iAutomaticFind && iAutomaticFind->CurrentItemExt().iItemType == CItemFinder::EEmailAddress ) + { + parsedAddress = iAutomaticFind->CurrentItemExt().iItemDescriptor; + } + else + { + // if sender descriptor is something else than phone number it will + // still go through this brach.. + TBool numberSelected = ( iAutomaticFind && iAutomaticFind->CurrentItemExt().iItemType == CItemFinder::EPhoneNumber ); + parsedAddress = ( numberSelected ? iAutomaticFind->CurrentItemExt().iItemDescriptor : iSenderDescriptor)->AllocLC(); + TPtr numberPtr = parsedAddress->Des(); + CommonPhoneParser::ParsePhoneNumber( numberPtr, CommonPhoneParser::EPlainPhoneNumber ); + AknTextUtils::ConvertDigitsTo( numberPtr, EDigitTypeWestern ); + isNumber = ETrue; + } + + CMessageData* messageData = CMessageData::NewL(); + CleanupStack::PushL( messageData ); + messageData->AppendToAddressL( parsedAddress->Des() ); + iSendUi->CreateAndSendMessageL( aMtmUid,messageData ); + CleanupStack::PopAndDestroy( isNumber ? 2 : 1 ); // messageData, number } void CFindItemMenu::GoToUrlL( TUid /*aHandlerAppUid*/ ) @@ -1097,6 +1184,10 @@ void CFindItemMenu::AddToBookmarkL() { + // Create an item + CFavouritesItem* item = CFavouritesItem::NewLC(); + item->SetParentFolder( KFavouritesRootUid ); + item->SetType( CFavouritesItem::EItem ); // Read default name from resources RConeResourceLoader ldr( *iCoeEnv ); @@ -1118,15 +1209,31 @@ if ( !dlg->ExecuteLD( R_FINDITEM_BOOKMARK_QUERY_DIALOG ) ) { // User press cancel - do not add bookmark - CleanupStack::PopAndDestroy( 2 ); // defaultName, resourceLoader + CleanupStack::PopAndDestroy( 3 ); // item, defaultName, resourceLoader return; } + item->SetNameL( retName ); + item->SetUrlL( iAutomaticFind->CurrentItemExt().iItemDescriptor->Des() ); + + RFavouritesSession sess; + RFavouritesDb db; + + User::LeaveIfError( sess.Connect() ); + CleanupClosePushL( sess ); + User::LeaveIfError( db.Open( sess, KBrowserBookmarks ) ); + CleanupClosePushL( db ); + + // add item + db.Add( *item, ETrue ); + // Close the database. + db.Close(); + HBufC* msgBuffer = iCoeEnv->AllocReadResourceLC( R_FINDITEM_BOOKMARK_SAVED ); CAknConfirmationNote* note = new (ELeave)CAknConfirmationNote( ETrue ); note->ExecuteLD( *msgBuffer ); - CleanupStack::PopAndDestroy( 3 ); // resourceLoader, + CleanupStack::PopAndDestroy( 6 ); // item, db, sess, resourceLoader, // defaultName, msgBuffer } @@ -1265,7 +1372,35 @@ void CFindItemMenu::AddToGalleryL() { - //no need to do anything ,due to the remove of AknCommonDialogs + _LIT( KRamFileExtension,".ram" ); + TFileName fileName; + iCoeEnv->ReadResourceL( fileName, R_FINDITEMMENU_DEFAULT_GALL_NAME ); + fileName.Append( KRamFileExtension ); + if ( AknCommonDialogs::RunSaveDlgLD( + fileName, R_MEMORY_SELECTION_LOCATIONS ) ) + { + CDesCArrayFlat* array = new (ELeave)CDesCArrayFlat( 1 ); + CleanupStack::PushL( array ); + array->AppendL( iAutomaticFind->CurrentItemExt().iItemDescriptor->Des() ); + TInt err = KErrNone; + if( !iMPEngineDllLoaded ) + { + LoadMPEngineApiL(); + } + err = iMPEngineApi->CreateNewLinkFileL( fileName, array, ETrue ); + CleanupStack::PopAndDestroy( 1 ); + + if ( err == KErrNone ) + { + // Show note + HBufC* msgBuffer = + iCoeEnv->AllocReadResourceLC( R_FINDITEMMENU_LINK_SAVED ); + CAknConfirmationNote* note = + new (ELeave) CAknConfirmationNote( ETrue ); + note->ExecuteLD( *msgBuffer ); + CleanupStack::PopAndDestroy(); // msgBuffer + } + } } EXPORT_C void CFindItemMenu::SetSenderDescriptorType( @@ -1286,6 +1421,7 @@ iPbkEngine = CPbkContactEngine::NewL(); iPbkDataSave = CPbkDataSaveAppUi::NewL( *iPbkEngine ); #endif // !RD_VIRTUAL_PHONEBOOK + iSendUi = CSendUi::NewL(); TRAPD( ret, iCommonUiRepository = CRepository::NewL( KCRUidCommonUi ) ); if ( ret == KErrNone ) @@ -1435,7 +1571,20 @@ void CFindItemMenu::LaunchGenericUriL() { - + if ( iSchemeHandler ) + { + delete iSchemeHandler; + iSchemeHandler = 0; + } + iSchemeHandler = CSchemeHandler::NewL( iAutomaticFind->CurrentItemExt().iItemDescriptor->Des() ); + if ( iAutomaticFind->CurrentItemExt().iItemDescriptor->FindF( KRtspUrlAddress ) != KErrNotFound ) + { + iSchemeHandler->HandleUrlEmbeddedL(); + } + else + { + iSchemeHandler->HandleUrlStandaloneL(); + } } EXPORT_C void CFindItemMenu::SetCallbackNumber( const TDesC& aPhoneNumber ) @@ -1693,7 +1842,7 @@ User::Leave(err); } } - return KErrNone; + return ETrue; } // End of File