commonuis/CommonUi/src/FindItemDialog.cpp
changeset 30 56e9a0aaad89
parent 0 2f259fa3e83a
child 47 2f0c06423c72
equal deleted inserted replaced
26:62ef28f7b435 30:56e9a0aaad89
    33 #include <akncontext.h> // for AknContextPane
    33 #include <akncontext.h> // for AknContextPane
    34 #include <bautils.h> // BaflUtils
    34 #include <bautils.h> // BaflUtils
    35 #include <eikbtgpc.h> // for ButtonGroupContainer
    35 #include <eikbtgpc.h> // for ButtonGroupContainer
    36 #include <uikon.hrh> // for EKeyOk
    36 #include <uikon.hrh> // for EKeyOk
    37 
    37 
    38 #include <FavouritesLimits.h> // KFavouritesMaxUrl
       
    39 #include <FavouritesItem.h> // for CBookmarkItem
       
    40 
       
    41 #include <FavouritesDb.h>
       
    42 
       
    43 #include <apgcli.h> // RApaLsSession for WMLBrowser launch
    38 #include <apgcli.h> // RApaLsSession for WMLBrowser launch
    44 
    39 
    45 #ifndef RD_VIRTUAL_PHONEBOOK
    40 #ifndef RD_VIRTUAL_PHONEBOOK
    46 #include <CPbkContactEngine.h> // Phonebook Engine
    41 #include <CPbkContactEngine.h> // Phonebook Engine
    47 #include <RPbkViewResourceFile.h> // Phonebook view dll resource loader
    42 #include <RPbkViewResourceFile.h> // Phonebook view dll resource loader
    57 #include <SendUiConsts.h> // Mtm uids
    52 #include <SendUiConsts.h> // Mtm uids
    58 
    53 
    59 #include <commonphoneparser.h> // Phonenumber parser
    54 #include <commonphoneparser.h> // Phonenumber parser
    60 
    55 
    61 #include <baclipb.h> // For CClipboard
    56 #include <baclipb.h> // For CClipboard
    62 
       
    63 #include <SchemeHandler.h> // For CSchemeHandler
       
    64 
    57 
    65 #include <aknnotewrappers.h>
    58 #include <aknnotewrappers.h>
    66 
    59 
    67 #include <finditemui.rsg>
    60 #include <finditemui.rsg>
    68 
    61 
   317     delete iIdle;
   310     delete iIdle;
   318 
   311 
   319     delete iServiceHandler;
   312     delete iServiceHandler;
   320     delete iFindItemVoIPExtension;
   313     delete iFindItemVoIPExtension;
   321 
   314 
   322     delete iSchemeHandler;
       
   323 
       
   324     delete iBgContext;
   315     delete iBgContext;
   325 
   316 
   326     delete iTitleText;
   317     delete iTitleText;
   327 
   318 
   328     delete iDialData;
   319     delete iDialData;
   705         CleanupStack::PopAndDestroy(); // itemtext
   696         CleanupStack::PopAndDestroy(); // itemtext
   706         return ETrue;
   697         return ETrue;
   707         }
   698         }
   708     // If current app is other than Browser, use schemehandler for launching
   699     // If current app is other than Browser, use schemehandler for launching
   709     // file
   700     // file
   710     else
       
   711         {
       
   712         if ( iSchemeHandler )
       
   713             {
       
   714             delete iSchemeHandler;
       
   715             iSchemeHandler = 0;
       
   716             }
       
   717         iSchemeHandler = CSchemeHandler::NewL( itemtextPtr );
       
   718         if ( itemtext->FindF( KRtspUrlAddress ) != KErrNotFound )
       
   719             {
       
   720             iSchemeHandler->HandleUrlEmbeddedL();
       
   721             }
       
   722         else
       
   723             {
       
   724             iSchemeHandler->HandleUrlStandaloneL();
       
   725             }
       
   726         }
       
   727 
   701 
   728     CleanupStack::PopAndDestroy(); // itemtext
   702     CleanupStack::PopAndDestroy(); // itemtext
   729     return EFalse;
   703     return EFalse;
   730     }
   704     }
   731 
   705 
   742 
   716 
   743     HBufC *parameters = HBufC::NewLC( paramLength );
   717     HBufC *parameters = HBufC::NewLC( paramLength );
   744     TPtr paramPtr = parameters->Des();
   718     TPtr paramPtr = parameters->Des();
   745     paramPtr.Copy( KWmlBrowserParameter );
   719     paramPtr.Copy( KWmlBrowserParameter );
   746     paramPtr.Append( KSpace );
   720     paramPtr.Append( KSpace );
   747     paramPtr.Append(
   721     paramPtr.Append( aItemtextPtr.Mid( 0, aItemtextPtr.Length() ) );
   748         aItemtextPtr.Mid(
       
   749             0, Min( aItemtextPtr.Length(), KFavouritesMaxUrl ) ) );
       
   750 
   722 
   751     TApaTaskList taskList( iEikonEnv->WsSession() );
   723     TApaTaskList taskList( iEikonEnv->WsSession() );
   752     TApaTask task = taskList.FindApp( KWapUid );
   724     TApaTask task = taskList.FindApp( KWapUid );
   753     if ( task.Exists() )
   725     if ( task.Exists() )
   754         {
   726         {
   776 //
   748 //
   777 void CFindItemDialog::AddToBookmarkL()
   749 void CFindItemDialog::AddToBookmarkL()
   778     {
   750     {
   779     __ASSERT_DEBUG( iEdwin->SelectionLength() > 0, Panic( ENoItemSelected ) );
   751     __ASSERT_DEBUG( iEdwin->SelectionLength() > 0, Panic( ENoItemSelected ) );
   780 
   752 
   781     // Create an item and fill with meaningful data.
       
   782     CFavouritesItem* item = CFavouritesItem::NewLC();
       
   783     item->SetParentFolder( KFavouritesRootUid );
       
   784     item->SetType( CFavouritesItem::EItem );
       
   785     // Read default name from resources
   753     // Read default name from resources
   786     HBufC* defaultName =
   754     HBufC* defaultName =
   787         iEikonEnv->AllocReadResourceLC( R_FINDITEM_DEFAULT_BOOKMARK_NAME );
   755         iEikonEnv->AllocReadResourceLC( R_FINDITEM_DEFAULT_BOOKMARK_NAME );
   788 
   756 
   789     TBuf<KMaxBookmarkNameLength> retName;
   757     TBuf<KMaxBookmarkNameLength> retName;
   794     CAknTextQueryDialog* dlg = CAknTextQueryDialog::NewL( retName );
   762     CAknTextQueryDialog* dlg = CAknTextQueryDialog::NewL( retName );
   795     dlg->SetMaxLength( KMaxBookmarkNameLength );
   763     dlg->SetMaxLength( KMaxBookmarkNameLength );
   796     if ( !dlg->ExecuteLD( R_FINDITEM_BOOKMARK_QUERY_DIALOG ) )
   764     if ( !dlg->ExecuteLD( R_FINDITEM_BOOKMARK_QUERY_DIALOG ) )
   797         {
   765         {
   798         // User press cancel - do not add bookmark
   766         // User press cancel - do not add bookmark
   799         CleanupStack::PopAndDestroy( ); // item
       
   800         return;
   767         return;
   801         }
   768         }
   802 
   769     
   803     item->SetNameL( retName );
       
   804     TCursorSelection selection = iEdwin->Selection();
   770     TCursorSelection selection = iEdwin->Selection();
   805     item->SetUrlL( iPlainText.Mid( selection.LowerPos(), selection.Length() ) );
   771     
   806 
       
   807     RFavouritesSession sess;
       
   808     RFavouritesDb db;
       
   809 
       
   810     User::LeaveIfError( sess.Connect() );
       
   811     CleanupClosePushL<RFavouritesSession>( sess );
       
   812     User::LeaveIfError( db.Open( sess, KBrowserBookmarks ) );
       
   813     CleanupClosePushL<RFavouritesDb>( db );
       
   814 
       
   815     // Add item.
       
   816     db.Add( *item, ETrue );
       
   817     // Close the database.
       
   818     db.Close();
       
   819 
       
   820     HBufC* msgBuffer =
   772     HBufC* msgBuffer =
   821         iCoeEnv->AllocReadResourceLC( R_FINDITEM_BOOKMARK_SAVED );
   773         iCoeEnv->AllocReadResourceLC( R_FINDITEM_BOOKMARK_SAVED );
   822     CAknConfirmationNote* note = new (ELeave)CAknConfirmationNote( ETrue );
   774     CAknConfirmationNote* note = new (ELeave)CAknConfirmationNote( ETrue );
   823     note->ExecuteLD( *msgBuffer );
   775     note->ExecuteLD( *msgBuffer );
   824 
   776 
   825     CleanupStack::PopAndDestroy( 4 );   // magBuffer, db, sess, item
   777     CleanupStack::PopAndDestroy();   // magBuffer
   826     }
   778     }
   827 
   779 
   828 // -----------------------------------------------------------------------------
   780 // -----------------------------------------------------------------------------
   829 // CFindItemDialog::ProcessCommandL
   781 // CFindItemDialog::ProcessCommandL
   830 //  Prosesses menu commands
   782 //  Prosesses menu commands