tvout/tvoutwrapper/src/glxtvoutwrapper_p.cpp
branchRCL_3
changeset 59 8e5f6eea9c9f
equal deleted inserted replaced
57:ea65f74e6de4 59:8e5f6eea9c9f
       
     1 /*
       
     2 * Copyright (c) 2008-2009 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:    Implementation of private wrapper class
       
    15 *
       
    16 */
       
    17 
       
    18 #include "glxtvoutwrapper.h"
       
    19 #include "glxtvoutwrapper_p.h"
       
    20 #include "glxtvconnectionobserver.h"
       
    21 #include "glxhdmicontroller.h"
       
    22 #include "glxmodelparm.h"
       
    23 #include "glxviewids.h"
       
    24 
       
    25 #include "glxtracer.h"
       
    26 #include "glxlog.h"
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // Static method to create the private wrapper instance 
       
    30 // -----------------------------------------------------------------------------
       
    31 GlxTvOutWrapperPrivate* GlxTvOutWrapperPrivate::Instance(GlxTvOutWrapper* aTvOutWrapper,
       
    32         QAbstractItemModel* aModel,QSize aScreenSize,bool aEfectsOn)
       
    33     {
       
    34     TRACER("GlxTvOutWrapperPrivate::Instance()");
       
    35     GlxTvOutWrapperPrivate* self = new GlxTvOutWrapperPrivate(aTvOutWrapper,aModel);
       
    36     if (self){
       
    37         TRAPD(err,self->ConstructL(aScreenSize,aEfectsOn));
       
    38         if(err != KErrNone){
       
    39             delete self;
       
    40             self = NULL;
       
    41             }
       
    42         }
       
    43     return self;
       
    44     }
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // ConstructL
       
    48 // This creates the Connection observer and the Hdmi Controller
       
    49 // -----------------------------------------------------------------------------
       
    50 void GlxTvOutWrapperPrivate::ConstructL(QSize aScreenSize,bool aEfectsOn)
       
    51     {
       
    52     TRACER("GlxTvOutWrapperPrivate::ConstructL()");
       
    53     iConnectionObserver = CGlxConnectionObserver::NewL(this);
       
    54     if (!iHdmiController) {
       
    55         TRect rect(0,0,aScreenSize.width(),aScreenSize.height());
       
    56         iHdmiController = CGlxHdmiController::NewL(rect,
       
    57                 aEfectsOn);
       
    58         iHdmiConnected = iConnectionObserver->IsHdmiConnected();
       
    59         }
       
    60     }
       
    61     
       
    62 // -----------------------------------------------------------------------------
       
    63 // Constructor
       
    64 // -----------------------------------------------------------------------------
       
    65 GlxTvOutWrapperPrivate::GlxTvOutWrapperPrivate(GlxTvOutWrapper* aTvOutWrapper,
       
    66         QAbstractItemModel* aModel):iTvOutWrapper(aTvOutWrapper),
       
    67                 iModel(aModel),
       
    68                 iConnectionObserver(NULL),
       
    69                 iHdmiController(NULL),
       
    70                 iHdmiConnected(false),
       
    71                 isImageSetToHdmi(false),
       
    72                 iIsPhotosInForeground(false)
       
    73     {
       
    74     TRACER("GlxTvOutWrapperPrivate::GlxTvOutWrapperPrivate()");
       
    75     // Do Nothing
       
    76     }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // Destructor
       
    80 // -----------------------------------------------------------------------------
       
    81 GlxTvOutWrapperPrivate::~GlxTvOutWrapperPrivate()
       
    82     {
       
    83     TRACER("GlxTvOutWrapperPrivate::~GlxTvOutWrapperPrivate()");
       
    84     if (iConnectionObserver){
       
    85     delete iConnectionObserver;
       
    86     iConnectionObserver = NULL;
       
    87     }
       
    88     if (iHdmiController){
       
    89     delete iHdmiController;
       
    90     iHdmiController = NULL;
       
    91     }
       
    92     }
       
    93 
       
    94 // -----------------------------------------------------------------------------
       
    95 // HandleConnectionChange
       
    96 // observes the connection change to modify the connection flag
       
    97 // -----------------------------------------------------------------------------
       
    98 void GlxTvOutWrapperPrivate::HandleConnectionChange(bool aConnected)
       
    99     {
       
   100     TRACER("GlxTvOutWrapperPrivate::HandleConnectionChange()");
       
   101     iHdmiConnected = aConnected;
       
   102     // if Connection state positive and uri/bmp are not passed to HDMI already
       
   103     // then it is a new image - Set it.
       
   104     GLX_LOG_INFO2("GlxTvOutWrapperPrivate::HandleConnectionChange() - isImageSetToHdmi-%d, iHdmiConnected-%d",
       
   105             isImageSetToHdmi,iHdmiConnected);
       
   106     if (!isImageSetToHdmi && iHdmiConnected && getSubState() !=IMAGEVIEWER_S && iIsPhotosInForeground)
       
   107         {
       
   108         SetNewImage();
       
   109         }
       
   110     }
       
   111 
       
   112 // -----------------------------------------------------------------------------
       
   113 // SetImagetoHDMI
       
   114 // if the Hdmi is connected, Set the new image else do nothing
       
   115 // -----------------------------------------------------------------------------
       
   116 void GlxTvOutWrapperPrivate::SetImagetoHDMI()
       
   117     {
       
   118     TRACER("GlxTvOutWrapperPrivate::SetImagetoHDMI()");
       
   119     iIsPhotosInForeground = true;
       
   120     if (iHdmiConnected)
       
   121         {
       
   122         // Set the Image
       
   123         SetNewImage();
       
   124         // Set the flag after HDMI is set for the image
       
   125         isImageSetToHdmi = true;    
       
   126         }
       
   127     else
       
   128         {
       
   129         // UnSet the flag as HDMI not set
       
   130         // this would be in future use if HDMI not set for a image in FS/SS and
       
   131         // cable connected
       
   132         isImageSetToHdmi = false;
       
   133         }
       
   134     }
       
   135 
       
   136 // -----------------------------------------------------------------------------
       
   137 // SetNewImage
       
   138 // Private implementation of setting the image to HDMI
       
   139 // -----------------------------------------------------------------------------
       
   140 void GlxTvOutWrapperPrivate::SetNewImage()
       
   141     {
       
   142     TRACER("GlxTvOutWrapperPrivate::SetNewImage()");
       
   143     QVariant focusVariant =(iModel->data(iModel->index(0,0),GlxFocusIndexRole)); 
       
   144     int focusIndex;
       
   145     if (focusVariant.isValid() && focusVariant.canConvert<int>()) {
       
   146         focusIndex = (focusVariant.value<int>());
       
   147         GLX_LOG_INFO1("GlxTvOutWrapperPrivate::SetNewImage() focusindex = %d",focusIndex);
       
   148 	}
       
   149 	else{
       
   150 		return ;
       
   151 	}
       
   152     
       
   153     // Get the image uri
       
   154     QString imagePath = (iModel->data(iModel->index(focusIndex,0),GlxUriRole)).value<QString>();
       
   155     if(imagePath.isNull()) {
       
   156     // Null path no need to proceed
       
   157         return ;
       
   158     }
       
   159    
       
   160     TPtrC aPtr = reinterpret_cast<const TUint16*>(imagePath.utf16());
       
   161     QVariant var = (iModel->data(iModel->index(focusIndex,0),GlxHdmiBitmap));
       
   162     CFbsBitmap* bmp = var.value<CFbsBitmap*>();
       
   163     iHdmiController->SetImageL(aPtr,bmp);
       
   164     iIsPhotosInForeground = true;
       
   165     }
       
   166 
       
   167 // -----------------------------------------------------------------------------
       
   168 // setToCloningMode 
       
   169 // -----------------------------------------------------------------------------
       
   170 void GlxTvOutWrapperPrivate::SetToCloningMode()
       
   171     {
       
   172     TRACER("GlxTvOutWrapperPrivate::SetToCloningMode()");
       
   173     iIsPhotosInForeground = false;
       
   174     if(iHdmiController && iHdmiConnected){
       
   175     iHdmiController->ShiftToCloningMode();
       
   176     }
       
   177     }
       
   178 
       
   179 // -----------------------------------------------------------------------------
       
   180 // setToNativeMode 
       
   181 // -----------------------------------------------------------------------------
       
   182 void GlxTvOutWrapperPrivate::SetToNativeMode()
       
   183     {
       
   184     TRACER("GlxTvOutWrapperPrivate::SetToNativeMode()");
       
   185     iIsPhotosInForeground = true;
       
   186     
       
   187     if(iHdmiController && iHdmiConnected) {
       
   188     if (!isImageSetToHdmi){
       
   189     }
       
   190     SetNewImage(); // this case can occur when FS image is opened and set to background
       
   191                    // HDMI cable connected and then FS is brought to foreground
       
   192     }
       
   193     else{
       
   194     iHdmiController->ShiftToPostingMode();
       
   195     }
       
   196     }
       
   197 
       
   198 // -----------------------------------------------------------------------------
       
   199 // itemNotSupported 
       
   200 // -----------------------------------------------------------------------------
       
   201 void GlxTvOutWrapperPrivate::ItemNotSupported()
       
   202     {
       
   203     TRACER("GlxTvOutWrapperPrivate::ItemNotSupported()");
       
   204     if(iHdmiController && iHdmiConnected){
       
   205     iHdmiController->ItemNotSupported();
       
   206     }
       
   207     }
       
   208 
       
   209 // -----------------------------------------------------------------------------
       
   210 // activateZoom 
       
   211 // -----------------------------------------------------------------------------
       
   212 void GlxTvOutWrapperPrivate::ActivateZoom(bool autoZoomOut)
       
   213     {
       
   214     if(iHdmiController && iHdmiConnected){
       
   215     iHdmiController->ActivateZoom(autoZoomOut);
       
   216     }
       
   217     }
       
   218 
       
   219 // -----------------------------------------------------------------------------
       
   220 // deactivateZoom 
       
   221 // -----------------------------------------------------------------------------
       
   222 void GlxTvOutWrapperPrivate::DeactivateZoom()
       
   223     {
       
   224     if(iHdmiController && iHdmiConnected){
       
   225     iHdmiController->DeactivateZoom();
       
   226     }
       
   227     }
       
   228 
       
   229 // -----------------------------------------------------------------------------
       
   230 // FadeSurface 
       
   231 // -----------------------------------------------------------------------------
       
   232 void GlxTvOutWrapperPrivate::FadeSurface(bool aFadeInOut)
       
   233     {
       
   234     if(iHdmiController && iHdmiConnected){
       
   235     iHdmiController->FadeSurface(aFadeInOut);
       
   236     }
       
   237     }
       
   238 
       
   239 // -----------------------------------------------------------------------------
       
   240 // getSubState 
       
   241 // -----------------------------------------------------------------------------
       
   242 int GlxTvOutWrapperPrivate::getSubState()
       
   243 {
       
   244     int substate = NO_FULLSCREEN_S;
       
   245     QVariant variant = iModel->data( iModel->index(0,0), GlxSubStateRole );    
       
   246     if ( variant.isValid() &&  variant.canConvert<int> ()  ) {
       
   247         substate = variant.value<int>();
       
   248     }
       
   249     return substate;
       
   250 }
       
   251 
       
   252 // End of file