|
Nokia N97 SDK Example Applications Guide |
00001 /* Copyright (c) 2005-2006 Nokia Corporation. 00002 * This material, including documentation and any related 00003 * computer programs, is protected by copyright controlled by 00004 * Nokia Corporation. 00005 */ 00006 00007 // INCLUDE FILES 00008 #include <avkon.hrh> 00009 #include <aknnotewrappers.h> 00010 #include <stringloader.h> 00011 #include <AIWConsumerBasics.rsg> 00012 #include <f32file.h> 00013 #include <s32file.h> 00014 #include <AiwServiceHandler.h> 00015 #include <AiwCommon.hrh> 00016 00017 #include "AIWConsumerBasics.pan" 00018 #include "AIWConsumerBasicsAppUi.h" 00019 #include "AIWConsumerBasicsAppView.h" 00020 #include "AIWConsumerBasics.hrh" 00021 00022 _LIT8(KContentTypeAll, "*"); 00023 00024 // ============================ MEMBER FUNCTIONS =============================== 00025 00026 00027 // ----------------------------------------------------------------------------- 00028 // CAIWConsumerBasicsAppUi::ConstructL() 00029 // Symbian 2nd phase constructor can leave. 00030 // ----------------------------------------------------------------------------- 00031 // 00032 void CAIWConsumerBasicsAppUi::ConstructL() 00033 { 00034 // Initialise app UI with standard value. 00035 BaseConstructL(); 00036 00037 // Create view object 00038 iAppView = CAIWConsumerBasicsAppView::NewL( ClientRect(), *this ); 00039 AddToStackL( iAppView ); 00040 00041 // Create service handler instance. 00042 iServiceHandler = CAiwServiceHandler::NewL(); 00043 00044 // Attach call UI menu service interest to AIW framework. 00045 TRAPD(err, iServiceHandler->AttachMenuL(R_AIWCONSUMERBASICS_MENU, 00046 R_AIWCONSUMERBASICS_MENUINTEREST) ); 00047 if(!err) 00048 { 00049 iIsAttached = ETrue; 00050 } 00051 } 00052 // ----------------------------------------------------------------------------- 00053 // CAIWConsumerBasicsAppUi::CAIWConsumerBasicsAppUi() 00054 // C++ default constructor can NOT contain any code, that might leave. 00055 // ----------------------------------------------------------------------------- 00056 // 00057 CAIWConsumerBasicsAppUi::CAIWConsumerBasicsAppUi() 00058 : iIsAttached(EFalse) 00059 { 00060 // No implementation required 00061 } 00062 00063 // ----------------------------------------------------------------------------- 00064 // CAIWConsumerBasicsAppUi::~CAIWConsumerBasicsAppUi() 00065 // Destructor. 00066 // ----------------------------------------------------------------------------- 00067 // 00068 CAIWConsumerBasicsAppUi::~CAIWConsumerBasicsAppUi() 00069 { 00070 delete iServiceHandler; 00071 00072 if ( iAppView ) 00073 { 00074 RemoveFromStack( iAppView ); 00075 delete iAppView; 00076 iAppView = NULL; 00077 } 00078 } 00079 00080 // ----------------------------------------------------------------------------- 00081 // CAIWConsumerBasicsAppUi::DynInitMenuPaneL() 00082 // 00083 // ----------------------------------------------------------------------------- 00084 // 00085 void CAIWConsumerBasicsAppUi::DynInitMenuPaneL( TInt aResourceId, 00086 CEikMenuPane *aMenuPane ) 00087 { 00088 // First, offer menu pane to AIW framework. It might be the case, that the 00089 // user is opening an AIW submenu. In this case, the AIW handles the menu. 00090 if ( iServiceHandler->HandleSubmenuL( *aMenuPane ) ) 00091 { 00092 return; 00093 } 00094 00095 // TODO: Add your normal (non-AIW) menu initialisation code here... 00096 00097 // Check whether this menu contains AIW menu items. 00098 if ( iServiceHandler->IsAiwMenu(aResourceId) ) 00099 { 00100 // Let AIW provider add its menu items to the menu. 00101 iServiceHandler->InitializeMenuPaneL( 00102 *aMenuPane, 00103 aResourceId, 00104 EAIWConsumerBasicsCmdLast, 00105 iServiceHandler->InParamListL()); 00106 } 00107 } 00108 00109 // ----------------------------------------------------------------------------- 00110 // CAIWConsumerBasicsAppUi::HandleCommandL() 00111 // Takes care of command handling. 00112 // ----------------------------------------------------------------------------- 00113 // 00114 void CAIWConsumerBasicsAppUi::HandleCommandL( TInt aCommand ) 00115 { 00116 switch( aCommand ) 00117 { 00118 case EEikCmdExit: 00119 case EAknSoftkeyExit: 00120 Exit(); 00121 break; 00122 00123 case EAiwAttach: 00124 if(!iIsAttached) 00125 { 00126 // Attach call UI menu service interest to AIW framework. 00127 TRAPD(err, iServiceHandler->AttachMenuL(R_AIWCONSUMERBASICS_MENU, 00128 R_AIWCONSUMERBASICS_MENUINTEREST) ); 00129 if(!err) 00130 { 00131 iIsAttached = ETrue; 00132 } 00133 } 00134 break; 00135 00136 case EAiwDetach: 00137 if(iIsAttached) 00138 { 00139 // Detach all providers from the main menu. 00140 iServiceHandler->DetachMenu(R_AIWCONSUMERBASICS_MENU, NULL); 00141 iIsAttached = EFalse; 00142 } 00143 break; 00144 00145 default: 00146 { 00147 // Check first that we really want to execute KAiwCmdHelp. By this 00148 // way we can set up the generic param list only if necessary. 00149 TInt aiwCmd = iServiceHandler->ServiceCmdByMenuCmd( aCommand ); 00150 if ( aiwCmd == KAiwCmdHelp ) 00151 { 00152 // First set up help context parameters. 00153 CAiwGenericParamList& inParamList = SetupGenericParamListL(); 00154 00155 // Execute AIW service command. 00156 iServiceHandler->ExecuteMenuCmdL( 00157 aCommand, 00158 inParamList, 00159 iServiceHandler->OutParamListL()); 00160 } 00161 break; 00162 } 00163 } 00164 } 00165 // ----------------------------------------------------------------------------- 00166 // CAIWConsumerBasicsAppUi::HandleStatusPaneSizeChange() 00167 // Called by the framework when the application status pane 00168 // size is changed. Passes the new client rectangle to the AppView 00169 // ----------------------------------------------------------------------------- 00170 // 00171 void CAIWConsumerBasicsAppUi::HandleStatusPaneSizeChange() 00172 { 00173 iAppView->SetRect( ClientRect() ); 00174 } 00175 00176 // ----------------------------------------------------------------------------- 00177 // CAIWConsumerBasicsAppUi::SetupGenericParamListL() 00178 // 00179 // ----------------------------------------------------------------------------- 00180 // 00181 CAiwGenericParamList& CAIWConsumerBasicsAppUi::SetupGenericParamListL() const 00182 { 00183 CArrayFix<TCoeHelpContext>* buf = iCoeEnv->AppUi()->AppHelpContextL(); 00184 TCoeHelpContext& helpContext = buf->At(0); 00185 00186 // Set help context UID. 00187 TAiwVariant uidVariant; 00188 uidVariant.Set(helpContext.iMajor); 00189 TAiwGenericParam uidParam(EGenericParamHelpItem, uidVariant); 00190 00191 // Set help context name. 00192 TAiwVariant contextVariant; 00193 contextVariant.Set(helpContext.iContext); 00194 TAiwGenericParam contextParam(EGenericParamHelpItem, contextVariant); 00195 00196 // Append parameters to input parameter list. 00197 CAiwGenericParamList& inParamList = iServiceHandler->InParamListL(); 00198 inParamList.AppendL(uidParam); 00199 inParamList.AppendL(contextParam); 00200 00201 delete buf; 00202 buf = NULL; 00203 00204 return inParamList; 00205 } 00206 00207 // ----------------------------------------------------------------------------- 00208 // CAIWConsumerBasicsAppUi::IsAttached() 00209 // 00210 // ----------------------------------------------------------------------------- 00211 // 00212 TBool CAIWConsumerBasicsAppUi::IsAttached() const 00213 { 00214 return iIsAttached; 00215 } 00216 00217 // ----------------------------------------------------------------------------- 00218 // CAIWConsumerBasicsAppUi::NumberOfProviders() 00219 // 00220 // ----------------------------------------------------------------------------- 00221 // 00222 TInt CAIWConsumerBasicsAppUi::NumberOfProviders() const 00223 { 00224 TInt providerCount = 0; 00225 00226 // Construct a criteria item object. A criteria item contains following fields: 00227 // - Criteria Id <Value must be set> 00228 // - Service command <Value must be set> 00229 // - Content type <Value must be set> 00230 // - Service class <Value must be set> 00231 // - Default provider <Default value can be used> 00232 // - Max providers <Default value can be used> 00233 // - Options <Default value can be used> 00234 CAiwCriteriaItem* criteria = CAiwCriteriaItem::NewLC( 00235 EAIWConsumerBasicsHelpPlaceholder, 00236 KAiwCmdHelp, 00237 KContentTypeAll); 00238 00239 criteria->SetServiceClass(TUid::Uid(KAiwClassMenu)); 00240 00241 // Query the number of providers. All fields of criteria item much match to 00242 // the criteria item defined in the resource file and used in AttachMenuL(). 00243 providerCount = iServiceHandler->NbrOfProviders(criteria); 00244 00245 CleanupStack::PopAndDestroy(criteria); 00246 return providerCount; 00247 } 00248 00249 00250 // End of File
|
© Nokia 2009 |