phonebookui/Speeddial/src/SpdiaAppUi.cpp
changeset 0 e686773b3f54
child 68 9da50d567e3c
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    
       
    15 *     Declares UI class for application.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 // INCLUDE FILES
       
    25 #include <avkon.hrh>
       
    26 
       
    27 #include <bldvariant.hrh>
       
    28 #include <hlplch.h>
       
    29 #include <featmgr.h>
       
    30 #include <aknview.h>
       
    31 
       
    32 #include <SpeedDial.rsg>
       
    33 #include <AknGlobalNote.h>
       
    34 
       
    35 #include "speeddial.hrh"
       
    36 #include "SpdiaAppUi.h"
       
    37 #include "SpdiaView.h"
       
    38 #include "SpdiaContainer.h"
       
    39 #include "SpdiaCallingVmbxView_voip.h"
       
    40 #include "speeddialprivate.h"//for migration
       
    41 
       
    42 
       
    43 #include <e32property.h>
       
    44 #include <aknnotewrappers.h> 
       
    45 #include <StringLoader.h>
       
    46 
       
    47 
       
    48 
       
    49 #include <BTSapInternalPSKeys.h>
       
    50 #include <centralrepository.h>
       
    51 
       
    52 #include <AknNotify.h>
       
    53 #include <AknNotifyStd.h>
       
    54 
       
    55 #include <CVPbkContactStoreUriArray.h>
       
    56 #include <TVPbkContactStoreUriPtr.h>
       
    57 #include <CPbk2StoreConfiguration.h>
       
    58 #include <VPbkContactStoreUris.h>
       
    59 
       
    60 //  local constant
       
    61 const TUint32 KSettingAppID = 0x100058EC;
       
    62 
       
    63 // ================= MEMBER FUNCTIONS =======================
       
    64 //
       
    65 // ----------------------------------------------------------
       
    66 // CSpdiaAppUi::ConstructL()
       
    67 // ?implementation_description
       
    68 // ----------------------------------------------------------
       
    69 void CSpdiaAppUi::ConstructL()
       
    70     {
       
    71     BaseConstructL(EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible ); 
       
    72     CEikonEnv::Static()->AppUiFactory()->StatusPane()->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_EMPTY );
       
    73     iSettingType = iEikonEnv->StartedAsServerApp();
       
    74     FeatureManager::InitializeLibL();
       
    75 
       
    76 	
       
    77     CPbk2StoreConfiguration* configuration = CPbk2StoreConfiguration::NewL();
       
    78     CleanupStack::PushL(configuration);
       
    79     CVPbkContactStoreUriArray* uriArray = configuration->CurrentConfigurationL();
       
    80     if (EFalse == uriArray->IsIncluded(VPbkContactStoreUris::DefaultCntDbUri()))
       
    81     {
       
    82     	uriArray->AppendL(VPbkContactStoreUris::DefaultCntDbUri());	
       
    83     }
       
    84     CleanupStack::PushL(uriArray);
       
    85    	iContactManager = NULL;
       
    86     iContactManager = CVPbkContactManager::NewL(*uriArray);
       
    87     CleanupStack::PopAndDestroy(2); // uriArray, configuration
       
    88    
       
    89     iSpeedPrivate = NULL;
       
    90 	iSpeedPrivate = CSpeedDialPrivate::NewL(iContactManager);
       
    91 	TInt error = iSpeedPrivate->GetSpdCtrlLastError();
       
    92 	
       
    93 	
       
    94     CAknView* view1 = CSpdiaView::NewLC(iSpeedPrivate);
       
    95     AddViewL( view1 );       // transfer ownership to CAknViewAppUi
       
    96     CleanupStack::Pop();    // view1
       
    97 
       
    98     CSpdiaCallingVmbxView* view2 = CSpdiaCallingVmbxView::NewLC();
       
    99     AddViewL( view2 );
       
   100     CleanupStack::Pop();    // view2
       
   101 
       
   102 	
       
   103 	if (error != KErrNone)
       
   104       {
       
   105         LaunchInfoNoteL();
       
   106       }
       
   107     SetDefaultViewL( *view1 );
       
   108 #ifdef __BT_SAP
       
   109 	if ( FeatureManager::FeatureSupported( KFeatureIdBtSap ) ) 	
       
   110 	{
       
   111 
       
   112 	        TInt sapState(0); 
       
   113 	        if ( RProperty::Get( 
       
   114 	            KPSUidBluetoothSapConnectionState, 
       
   115 	            KBTSapConnectionState, 
       
   116 	            sapState ) == KErrNone ) 
       
   117 	            { 
       
   118 	           if ( sapState == EBTSapConnected ) 
       
   119 	                { 
       
   120 
       
   121 	HBufC* informationNoteTxt = StringLoader::LoadLC(R_OFFLINE_NOT_POSSIBLE_SAP);
       
   122 	TPtrC note = informationNoteTxt->Des();				    
       
   123 				    CAknGlobalNote* globalNote = CAknGlobalNote::NewLC();
       
   124 				    globalNote->SetGraphic(EMbmAvkonQgn_note_info,EMbmAvkonQgn_note_info_mask);
       
   125 	globalNote->ShowNoteL(EAknGlobalErrorNote,note); 
       
   126 				    CleanupStack::PopAndDestroy(globalNote);
       
   127 					Exit();
       
   128 				   				    		                         
       
   129 	                } 
       
   130 	           } 
       
   131 
       
   132 		
       
   133 	}
       
   134 #endif
       
   135     }
       
   136 
       
   137 // ----------------------------------------------------
       
   138 // CSpdiaAppUi::~CSpdiaAppUi()
       
   139 // Destructor
       
   140 // Frees reserved resources
       
   141 // ----------------------------------------------------
       
   142 CSpdiaAppUi::~CSpdiaAppUi()
       
   143     {
       
   144     FeatureManager::UnInitializeLib();
       
   145     
       
   146     // We had gone to some other application using active application..
       
   147 	// We are coming back..Restore the GridStatus..
       
   148 	if(iSpeedPrivate!=NULL)
       
   149 	{
       
   150 	if(iSpeedPrivate->State() == CSpeedDialPrivate::STATE_IDLE && 
       
   151 		iSpeedPrivate->GridStatus() == CSpeedDialPrivate::EGridNoUse )
       
   152 	{
       
   153 		iSpeedPrivate->SetGridStatus(CSpeedDialPrivate::EGridUse);
       
   154 	}
       
   155 	}
       
   156 
       
   157 	 CSpdiaView* view = dynamic_cast<CSpdiaView*>(View( KViewId ));
       
   158 	 if ( view )
       
   159 	     {
       
   160 	     view->SetSpeedPrivate( NULL );
       
   161 	     }
       
   162     delete iSpeedPrivate;
       
   163     delete iContactManager;
       
   164     }
       
   165 
       
   166 // ----------------------------------------------------
       
   167 // CSpdiaAppUi::HandleCommandL(TInt aCommand)
       
   168 // ?implementation_description
       
   169 // ----------------------------------------------------
       
   170 void CSpdiaAppUi::HandleCommandL(TInt aCommand)
       
   171     {
       
   172     switch ( aCommand )
       
   173         {
       
   174         case EEikCmdExit:
       
   175             {
       
   176             if ( iSettingType )
       
   177                 {
       
   178             RWsSession& ws = iCoeEnv->WsSession();
       
   179             TApaTaskList taskList(ws);
       
   180             TUid appUid = { KSettingAppID };
       
   181             TApaTask task = taskList.FindApp( appUid );
       
   182             if ( task.Exists() )
       
   183                 {
       
   184                 task.SendToBackground();
       
   185                 task.EndTask();
       
   186                     }
       
   187                 }
       
   188             Exit();
       
   189             break;
       
   190             }
       
   191         case EAknCmdHelp:
       
   192             {
       
   193             if (FeatureManager::FeatureSupported( KFeatureIdHelp ))
       
   194                 {
       
   195                 CArrayFix<TCoeHelpContext>* buf = AppHelpContextL();
       
   196                 HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(), buf);
       
   197                 }
       
   198             break;
       
   199             }
       
   200         default:
       
   201             break;      
       
   202         }
       
   203     }
       
   204 
       
   205 // ----------------------------------------------------
       
   206 // CSpdiaAppUi::HandleResourceChangeL(TInt aType)
       
   207 // Handle skin change event.
       
   208 // ----------------------------------------------------
       
   209 
       
   210 void CSpdiaAppUi::HandleResourceChangeL(TInt aType)
       
   211 	{
       
   212 	CAknViewAppUi::HandleResourceChangeL( aType );
       
   213 	if(aType == KAknsMessageSkinChange)
       
   214 		{
       
   215 		iSpeedPrivate->DeleteIconArray();//for miration
       
   216 		
       
   217 		iSpeedPrivate->ReloadIconArray();//for miration
       
   218 		iSkinChange=ETrue;
       
   219 		}
       
   220 	}
       
   221 
       
   222  // ----------------------------------------------------
       
   223 // CSpdiaAppUi::IsSkinChanged()
       
   224 // Returns the skin change status.
       
   225 // ----------------------------------------------------
       
   226  TBool CSpdiaAppUi::IsSkinChanged()
       
   227 	 {
       
   228 		 return iSkinChange;
       
   229 	 }
       
   230 	
       
   231 // ----------------------------------------------------
       
   232 // CSpdiaAppUi::LaunchInfoNoteL()
       
   233 // Launchs inforamtion note and exits from application
       
   234 // ----------------------------------------------------
       
   235 void CSpdiaAppUi::LaunchInfoNoteL()
       
   236    {
       
   237    	CAknNoteWrapper* note = new(ELeave) CAknNoteWrapper;
       
   238 	note->ExecuteLD(R_PBK_NOTE_DATABASE_CORRUPTED);
       
   239 	Exit();
       
   240    }
       
   241     
       
   242 // ----------------------------------------------------
       
   243 // CSpdiaAppUi::IsSettingType()
       
   244 // ----------------------------------------------------   
       
   245 TBool CSpdiaAppUi::IsSettingType()
       
   246     {
       
   247     return iSettingType;
       
   248     }
       
   249     
       
   250 // End of File