// ---------------------------------------------------------------------------- // Symbian 2nd phase constructor can leave. // ---------------------------------------------------------------------------- // void CWrtHarvester::ConstructL() { User::LeaveIfError( iApaSession.Connect() ); iWidgetUIListener = CWrtHarvesterPSNotifier::NewL( this, EWidgetUIState ); iWidgetRegListener = CWrtHarvesterPSNotifier::NewL( this, EWidgetRegAltered ); User::LeaveIfError( iFs.Connect() ); iWidgetUsbListener = CWrtUsbHandler::NewL( this, iFs ); iWidgetUsbListener->Start(); SetMSMode(0); TFileName resourceFileName; TParse parse; Dll::FileName (resourceFileName); parse.Set(KResourceFileName, &resourceFileName, NULL); resourceFileName = parse.FullName(); CCoeEnv* coeEnv = CCoeEnv::Static(); BaflUtils::NearestLanguageFile(coeEnv->FsSession(), resourceFileName); if ( !BaflUtils::FileExists( coeEnv->FsSession(), resourceFileName ) ) { // Use resource file on the Z drive instead parse.Set( KResourceDir, &KDC_RESOURCE_FILES_DIR, NULL ); resourceFileName = parse.FullName(); BaflUtils::NearestLanguageFile( coeEnv->FsSession(),resourceFileName ); } iResourceFileOffset = coeEnv->AddResourceFileL(resourceFileName); }
int main() { int res = 0; __UHEAP_MARK; // Create the control environment. CCoeEnv* environment = new (ELeave) CCoeEnv(); TRAPD( err, environment->ConstructL( ETrue, 0 ) ); if( err != KErrNone ) { printf( "Unable to create a CCoeEnv!\n" ); getchar(); } TRAP( err, res = mainWithTrap()); // Close the stdout & stdin, else printf / getchar causes a memory leak. fclose( stdout ); fclose( stdin ); // Cleanup CCoeEnv::Static()->DestroyEnvironment(); delete CCoeEnv::Static(); __UHEAP_MARKEND; return res; }
/** Inform with a message ,the timer seconds remaining till its up.\n Send event to windows group when timer time is up .\n */ void CTestTimer::RunL() { --iSecondsRemaining; if (iSecondsRemaining>0) { QueueAndInfoPrint(); } else { User::InfoPrint(_L("Time's up")); iCompleted = ETrue; CCoeEnv* env = CCoeEnv::Static(); TWsEvent theEvent; theEvent.SetType(EEventUser + 1); RWsSession ws; TInt theRes = ws.Connect(); if(theRes == KErrNone) { RWindowGroup& winGroup = env->RootWin(); theEvent.SetType(EEventUser + 1); theEvent.SetTimeNow(); TInt theId = winGroup.Identifier(); ws.SendEventToWindowGroup(theId, theEvent); } ws.Close(); } }
void CAknKeyLockNotifierSubject::ConstructL() { CCoeEnv* environment = CCoeEnv::Static(); TFileName resourceFile; resourceFile.Append(KRESOURCEFILE); BaflUtils::NearestLanguageFile(environment->FsSession(),resourceFile); iResourceFileOffset = environment->AddResourceFileL(resourceFile); iObserverList = new(ELeave)CArrayPtrFlat<MAknKeyLockObserver>(KAknObserverListGranularity); iKeyLockControl = new(ELeave)CAknKeyLockControl(this); iKeyLockControl->ConstructL(); // Make sure AppUi has a pointer to this STATIC_CAST(CEikServAppUi*,CEikonEnv::Static()->AppUi())->iKeyLockController = this; }
void CTstFepPlugIn::SynchronouslyExecuteSettingsDialogL(CCoeEnv& aConeEnvironment) { _LIT(KLitResourceFileName,"TFEP1PlugIn.rsc"); TFileName* resourceFileName=new(ELeave) TFileName; CleanupStack::PushL(resourceFileName); Dll::FileName(*resourceFileName); // Get the drive letter TParse* parse=new(ELeave) TParse; CleanupStack::PushL(parse); User::LeaveIfError(parse->SetNoWild(KLitResourceFileName, &KTestFepResFilePath, resourceFileName)); resourceFileName->Copy(parse->FullName()); CleanupStack::PopAndDestroy(parse); BaflUtils::NearestLanguageFile(aConeEnvironment.FsSession(), *resourceFileName); TTstResourceFileId resourceFileId(aConeEnvironment, aConeEnvironment.AddResourceFileL(*resourceFileName)); // object must not be an anonymous temporary passed into CleanupStack::PushL, as its lifetime would be too short CleanupStack::PopAndDestroy(resourceFileName); CleanupStack::PushL(resourceFileId); (new(ELeave) CTstSettingsDialog)->ExecuteLD(R_TFP_SETTINGS_DIALOG); CleanupStack::PopAndDestroy(&resourceFileId); }
void CMMADisplay::SetWindowResources(QWidget* qtWidget) { LOG(EJavaMMAPI,EInfo,"CMMADisplay::SetWindowResources +"); CCoeControl* control = 0; if (qtWidget && qtWidget ->winId()) { control = reinterpret_cast<CCoeControl*>(qtWidget->winId()); } CCoeEnv *coeEnv = control->ControlEnv(); RWsSession * iWs = &(coeEnv->WsSession()); CWsScreenDevice* iScreenDevice = coeEnv->ScreenDevice(); RWindowBase* window = static_cast<RWindowBase*>(control->DrawableWindow()); if (!iWindow) { return; } iWindow->ProcureWindowResourcesFromQWidget(iWs,iScreenDevice,window); iWindow->SetVisible(ETrue,ETrue); LOG(EJavaMMAPI,EInfo,"CMMADisplay::SetWindowResources -"); }
// ----------------------------------------------------------------------------- // CGameController::ConstructL // Second phase constructor. // Initializes EGL. // ----------------------------------------------------------------------------- // void CGameController::ConstructL() { CCoeEnv* env = CCoeEnv::Static(); if( !env ) { User::Leave( KErrCoeEnvNotInitialized ); } // Get the Windows Server Session, screen device and window group. iWsSession = env->WsSession(); iWsScreenDevice = env->ScreenDevice(); iWindowGroup = env->RootWin(); if( !iWsScreenDevice ) { User::Leave( KErrCoeEnvNotInitialized ); } // Intializes iWindow to a full screen window. CreateNativeWindowL(); // Choose the buffer size based on the Window's display mode. TDisplayMode displayMode = iWindow->DisplayMode(); TInt bufferSize = 0; switch( displayMode ) { case(EColor4K): bufferSize = 12; break; case(EColor64K): bufferSize = 16; break; case(EColor16M): bufferSize = 24; break; case(EColor16MU): case(EColor16MA): bufferSize = 32; break; default: break; } // Set the desired properties for the EGLSurface const EGLint attributeList[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_BUFFER_SIZE, bufferSize, EGL_NONE }; EGLConfig bestConfig; EGLint numConfigs = 0; // Choose the best EGLConfig that matches the desired properties. if( eglChooseConfig( iEglDisplay, attributeList, &bestConfig, 1, &numConfigs ) == EGL_FALSE ) { User::Leave( KErrConfigFailed ); } if( numConfigs == 0 ) { User::Leave( KErrConfigFailed ); } // Create a window surface where the graphics are blitted. // Pass the Native Window handle to egl. iEglSurface = eglCreateWindowSurface( iEglDisplay, bestConfig, (void*)iWindow, NULL ); if( iEglSurface == NULL ) { User::Leave( KErrCreateWindowSurfaceFailed ); } // Create a rendering context iEglContext = eglCreateContext( iEglDisplay, bestConfig, EGL_NO_CONTEXT, NULL ); if( iEglContext == NULL ) { User::Leave( KErrCreateContextFailed ); } // Make it the current context. if( eglMakeCurrent( iEglDisplay, iEglSurface, iEglSurface, iEglContext ) == EGL_FALSE ) { User::Leave( KErrSetContextFailed ); } // Creates the Active Object that waits for Windows Server events. iWsEventReceiver = CWsEventReceiver::NewL( *this ); }
/** * Set a new animation * * Redo layout and full redraw (partial layout and redraw left * for future extensions) */ void CAknNoteAttributes::SetAnimationL(TInt aResourceId) { if (aResourceId <= 0) return; delete iAnimation; iAnimation = NULL; iAnimation = CAknBitmapAnimation::NewL(); iAnimationID = aResourceId; if (iAnimationID == R_QGN_GRAF_WAIT_BAR_ANIM) { iAnimation->SetScaleModeForAnimationFrames(EAspectRatioNotPreserved); } CCoeEnv* coe = CCoeEnv::Static(); TAknsItemID iid; iid.Set( EAknsMajorAvkon, aResourceId ); TBool animation ( EFalse ); TRAPD( err, animation = iAnimation->ConstructFromSkinL ( iid ) ); if ( err != KErrNone || !animation ) { TResourceReader readerForAnimation; coe->CreateResourceReaderLC(readerForAnimation,aResourceId); iAnimation->ConstructFromResourceL(readerForAnimation); CleanupStack::PopAndDestroy(); // readerForAnimation } // FIXME: Experimental heuristics for finding out popup context from image/animation #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS switch ( aResourceId ) { case EAknsMinorQgnNoteOkAnim: CAknTransitionUtils::SetData( ( TInt )iNoteControl, ( TAny* )KGfxConfirmationNoteControlUid.iUid ); break; case EAknsMinorQgnNoteErrorAnim: CAknTransitionUtils::SetData( ( TInt )iNoteControl, ( TAny* )KGfxErrorNoteControlUid.iUid ); break; case EAknsMinorQgnNoteInfoAnim: CAknTransitionUtils::SetData( ( TInt )iNoteControl, ( TAny* )KGfxInformationNoteControlUid.iUid ); break; case EAknsMinorQgnNoteWarningAnim: CAknTransitionUtils::SetData( ( TInt )iNoteControl, ( TAny* )KGfxWarningNoteControlUid.iUid ); break; case EAknsMinorQgnGrafBarWaitAnim: CAknTransitionUtils::SetData( ( TInt )iNoteControl, ( TAny* )KGfxWaitNoteControlUid.iUid ); break; default: break; } #endif // If the image exists, but the dialog does not need it (is neither progress // nor wait dialog), delete the image if (iImage && iNoteControl->NoteLayout() != EProgressLayout && iNoteControl->NoteLayout() != EWaitLayout ) { delete iImage; iImage = NULL; } TransferToControlL(iAnimation); if (iNoteControl) { iNoteControl->ParseTextL(); } InvalidateLayout(); }