iaupdate/IAD/ui/src/iaupdateengine.cpp
changeset 53 ae54820ef82c
parent 52 92f864ef0288
child 72 a0dc14075813
equal deleted inserted replaced
52:92f864ef0288 53:ae54820ef82c
     1 /*
     1 /*
     2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3  * All rights reserved.
     4 * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5  * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     8  *
     9 * Initial Contributors:
     9  * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10  * Nokia Corporation - initial contribution.
    11 *
    11  *
    12 * Contributors:
    12  * Contributors:
    13 *
    13  *
    14 * Description:   This module contains the implementation of IAUpdateEngine
    14  * Description:   This module contains the implementation of IAUpdateEngine
    15 *                class member functions.
    15  *                class member functions.
    16 *
    16  *
    17 */
    17  */
    18 
    18 
    19 #include <qapplication.h>
    19 #include <qapplication.h>
    20 #include <hbmessagebox.h>
    20 #include <hbmessagebox.h>
    21 #include <hbaction.h>
    21 #include <hbaction.h>
    22 #include <eikenv.h>
    22 #include <eikenv.h>
    23 #include <centralrepository.h>
    23 #include <centralrepository.h>
    24 #include <cmmanagerext.h>
    24 #include <cmmanager.h>
    25 #include <cmdestinationext.h>
    25 #include <cmdestination.h>
    26 #include <rconnmon.h>
    26 #include <rconnmon.h>
    27 #include <apgwgnam.h>
    27 #include <apgwgnam.h>
    28 #include <starterclient.h>
    28 #include <starterclient.h>
    29 
    29 
    30 #include "iaupdateengine.h"
    30 #include "iaupdateengine.h"
    41 #include "iaupdateagreement.h"
    41 #include "iaupdateagreement.h"
    42 #include "iaupdateautomaticcheck.h"
    42 #include "iaupdateautomaticcheck.h"
    43 #include "iaupdateresultsdialog.h"
    43 #include "iaupdateresultsdialog.h"
    44 #include "iaupdatedebug.h"
    44 #include "iaupdatedebug.h"
    45 
    45 
    46 
    46 IAUpdateEngine::IAUpdateEngine(QObject *parent) :
    47 IAUpdateEngine::IAUpdateEngine(QObject *parent)
    47     QObject(parent)
    48      : QObject(parent)
    48     {
    49 {
       
    50     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::IAUpdateEngine() begin");
    49     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::IAUpdateEngine() begin");
    51     iController = NULL;
    50     iController = NULL;
    52     iFwUpdateHandler = NULL;
    51     iFwUpdateHandler = NULL;
    53     iGlobalLockHandler = NULL;
    52     iGlobalLockHandler = NULL;
    54     iAutomaticCheck = NULL;
    53     iAutomaticCheck = NULL;
    62     mWgId = 0;
    61     mWgId = 0;
    63     mUpdatequeryUid = 0;
    62     mUpdatequeryUid = 0;
    64     mDialogState = NoDialog;
    63     mDialogState = NoDialog;
    65     mResultsDialog = NULL;
    64     mResultsDialog = NULL;
    66     mServiceProvider = NULL;
    65     mServiceProvider = NULL;
    67     mServiceProvider = new IAUpdateServiceProvider( *this );
    66     mServiceProvider = new IAUpdateServiceProvider(*this);
    68     connect(mServiceProvider, SIGNAL(clientDisconnected()), this, SLOT(handleAllClientsClosed()));
    67     connect(mServiceProvider, SIGNAL(clientDisconnected()), this,
       
    68             SLOT(handleAllClientsClosed()));
    69     TRAP_IGNORE( iController = CIAUpdateUiController::NewL( *this ));
    69     TRAP_IGNORE( iController = CIAUpdateUiController::NewL( *this ));
    70     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::IAUpdateEngine() end");
    70     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::IAUpdateEngine() end");
    71 }
    71     }
    72 
       
    73 
    72 
    74 IAUpdateEngine::~IAUpdateEngine()
    73 IAUpdateEngine::~IAUpdateEngine()
    75 {
    74     {
    76     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::~IAUpdateEngine() begin");
    75     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::~IAUpdateEngine() begin");
    77     InformRequestObserver( KErrCancel );
    76     InformRequestObserver(KErrCancel);
    78     if (iIdle)
    77     if (iIdle)
    79         {
    78         {
    80         delete iIdle;
    79         delete iIdle;
    81         }
    80         }
    82     if (iIdleAutCheck)
    81     if (iIdleAutCheck)
    85         }
    84         }
    86     if (iGlobalLockHandler)
    85     if (iGlobalLockHandler)
    87         {
    86         {
    88         delete iGlobalLockHandler;
    87         delete iGlobalLockHandler;
    89         }
    88         }
    90     if ( iAutomaticCheck )
    89     if (iAutomaticCheck)
    91         {
    90         {
    92         delete iAutomaticCheck;
    91         delete iAutomaticCheck;
    93         }
    92         }
    94     if ( iController )
    93     if (iController)
    95         {
    94         {
    96         delete iController;
    95         delete iController;
    97         }
    96         }
    98     if ( iFwUpdateHandler )
    97     if (iFwUpdateHandler)
    99         {
    98         {
   100         delete iFwUpdateHandler;
    99         delete iFwUpdateHandler;
   101         }
   100         }
   102     if ( mServiceProvider )
   101     if (mServiceProvider)
   103         {
   102         {
   104         delete mServiceProvider;
   103         delete mServiceProvider;
   105         }
   104         }
   106     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::~IAUpdateEngine() end");
   105     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::~IAUpdateEngine() end");
   107 }
   106     }
   108 
   107 
   109 // -----------------------------------------------------------------------------
   108 // -----------------------------------------------------------------------------
   110 // IAUpdateEngine::StartedByLauncherL
   109 // IAUpdateEngine::StartedByLauncherL
   111 // 
   110 // 
   112 // -----------------------------------------------------------------------------
   111 // -----------------------------------------------------------------------------
   113 //
   112 //
   114 void IAUpdateEngine::StartedByLauncherL( bool aRefreshFromNetworkDenied )
   113 void IAUpdateEngine::StartedByLauncherL(bool aRefreshFromNetworkDenied)
   115     {
   114     {
   116     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::StartedByLauncherL() begin");
   115     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::StartedByLauncherL() begin");
   117     mRequestIssued = true;
   116     mRequestIssued = true;
   118     mRequestType = IAUpdateUiDefines::ENoRequest;
   117     mRequestType = IAUpdateUiDefines::ENoRequest;
   119     iController->SetRequestType( mRequestType );
   118     iController->SetRequestType(mRequestType);
   120     SetVisibleL( true );
   119     SetVisibleL(true);
   121     CIAUpdateParameters* params = iController->ParamsReadAndRemoveFileL();
   120     CIAUpdateParameters* params = iController->ParamsReadAndRemoveFileL();
   122     iController->CheckUpdatesDeferredL( params, aRefreshFromNetworkDenied );
   121     iController->CheckUpdatesDeferredL(params, aRefreshFromNetworkDenied);
   123     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::StartedByLauncherL() end");
       
   124     }
   122     }
   125 
   123 
   126 // -----------------------------------------------------------------------------
   124 // -----------------------------------------------------------------------------
   127 // IAUpdateEngine::CheckUpdatesRequestL
   125 // IAUpdateEngine::CheckUpdatesRequestL
   128 // 
   126 // 
   129 // -----------------------------------------------------------------------------
   127 // -----------------------------------------------------------------------------
   130 //
   128 //
   131 void IAUpdateEngine::CheckUpdatesRequestL( int wgid, 
   129 void IAUpdateEngine::CheckUpdatesRequestL(int wgid,
   132                                            CIAUpdateParameters* aFilterParams,
   130         CIAUpdateParameters* aFilterParams, bool aForcedRefresh)
   133                                            bool aForcedRefresh )
   131 
   134                                            
       
   135     {
   132     {
   136     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::CheckUpdatesRequestL() begin");
   133     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::CheckUpdatesRequestL() begin");
   137     SetClientWgId( wgid );
   134     SetClientWgId(wgid);
   138     mRequestIssued = true;
   135     mRequestIssued = true;
   139     mStartedFromApplication  = true;
   136     mStartedFromApplication = true;
   140     CleanupStack::PushL( aFilterParams );
   137     CleanupStack::PushL(aFilterParams);
   141     if ( wgid > 0 )
   138     if (wgid > 0)
   142         {
   139         {
   143         HideApplicationInFSWL( true );
   140         HideApplicationInFSWL(true);
   144         }
   141         }
   145     CleanupStack::Pop( aFilterParams );
   142     CleanupStack::Pop(aFilterParams);
   146     
   143 
   147     if ( !aFilterParams->ShowProgress() )
   144     if (!aFilterParams->ShowProgress())
   148         {
   145         {
   149         iEikEnv->RootWin().SetOrdinalPosition( -1, ECoeWinPriorityNeverAtFront ); 
   146         iEikEnv->RootWin().SetOrdinalPosition(-1, ECoeWinPriorityNeverAtFront);
   150         }
   147         }
   151            
   148 
   152     mRequestType = IAUpdateUiDefines::ECheckUpdates; 
   149     mRequestType = IAUpdateUiDefines::ECheckUpdates;
   153     iController->SetRequestType( mRequestType );
   150     iController->SetRequestType(mRequestType);
   154     iController->SetForcedRefresh( aForcedRefresh );
   151     iController->SetForcedRefresh(aForcedRefresh);
   155     
   152 
   156     iController->CheckUpdatesDeferredL( aFilterParams, false ); 
   153     iController->CheckUpdatesDeferredL(aFilterParams, false);
   157     
   154 
   158     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::CheckUpdatesRequestL() end");
   155     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::CheckUpdatesRequestL() end");
   159     }
   156     }
   160 
   157 
   161 // -----------------------------------------------------------------------------
   158 // -----------------------------------------------------------------------------
   162 // IAUpdateEngine::ShowUpdatesRequestL
   159 // IAUpdateEngine::ShowUpdatesRequestL
   163 // 
   160 // 
   164 // -----------------------------------------------------------------------------
   161 // -----------------------------------------------------------------------------
   165 // 
   162 // 
   166 void IAUpdateEngine::ShowUpdatesRequestL( int wgid, CIAUpdateParameters* aFilterParams )
   163 void IAUpdateEngine::ShowUpdatesRequestL(int wgid,
   167     {
   164         CIAUpdateParameters* aFilterParams)
   168     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::ShowUpdatesRequestL() begin"); 
   165     {
   169     SetClientWgId( wgid );
   166     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::ShowUpdatesRequestL() begin");
       
   167     SetClientWgId(wgid);
   170     mRequestIssued = true;
   168     mRequestIssued = true;
   171 //    delete iBackgroundTimer;
   169     //    delete iBackgroundTimer;
   172 //    iBackgroundTimer = NULL;
   170     //    iBackgroundTimer = NULL;
   173     mStartedFromApplication  = true;
   171     mStartedFromApplication = true;
   174     CleanupStack::PushL( aFilterParams );
   172     CleanupStack::PushL(aFilterParams);
   175     if ( wgid > 0 )
   173     if (wgid > 0)
   176         {
   174         {
   177         HideApplicationInFSWL( true );
   175         HideApplicationInFSWL(true);
   178         }
   176         }
   179    
   177 
   180     //StatusPane()->MakeVisible( true );
   178     //StatusPane()->MakeVisible( true );
   181     iEikEnv->RootWin().SetOrdinalPosition( 0, ECoeWinPriorityNormal );
   179     iEikEnv->RootWin().SetOrdinalPosition(0, ECoeWinPriorityNormal);
   182     
   180 
   183     //iRequestObserver = &aObserver;
   181     //iRequestObserver = &aObserver;
   184     mRequestType = IAUpdateUiDefines::EShowUpdates;
   182     mRequestType = IAUpdateUiDefines::EShowUpdates;
   185     iController->SetRequestType( mRequestType );
   183     iController->SetRequestType(mRequestType);
   186      
       
   187 
   184 
   188     //if ( !iMainView )
   185     //if ( !iMainView )
   189     //    {
   186     //    {
   190     //    iMainView  = CIAUpdateMainView::NewL( ClientRect() ); 
   187     //    iMainView  = CIAUpdateMainView::NewL( ClientRect() ); 
   191     //    AddViewL( iMainView );
   188     //    AddViewL( iMainView );
   192     //    }
   189     //    }
   193     
   190 
   194       
   191 
   195     // by pushing object to cleanup stack its destructor is called if leave happens
   192     // by pushing object to cleanup stack its destructor is called if leave happens
   196     // so global lock issued by this instance can be released in destructor of CIAUpdateGlobalLockHandler
   193     // so global lock issued by this instance can be released in destructor of CIAUpdateGlobalLockHandler
   197     CIAUpdateGlobalLockHandler* globalLockHandler = CIAUpdateGlobalLockHandler::NewLC();
   194     CIAUpdateGlobalLockHandler* globalLockHandler =
   198     if ( !globalLockHandler->InUseByAnotherInstanceL() )
   195             CIAUpdateGlobalLockHandler::NewLC();
   199         {
   196     if (!globalLockHandler->InUseByAnotherInstanceL())
   200         globalLockHandler->SetToInUseForAnotherInstancesL( true );
   197         {
   201         CleanupStack::Pop( globalLockHandler );
   198         globalLockHandler->SetToInUseForAnotherInstancesL(true);
   202         CleanupStack::Pop( aFilterParams );
   199         CleanupStack::Pop(globalLockHandler);
   203         CleanupStack::PushL( globalLockHandler );
   200         CleanupStack::Pop(aFilterParams);
   204         iController->CheckUpdatesDeferredL( aFilterParams, false );
   201         CleanupStack::PushL(globalLockHandler);
   205         CleanupStack::Pop( globalLockHandler ); 
   202         iController->CheckUpdatesDeferredL(aFilterParams, false);
       
   203         CleanupStack::Pop(globalLockHandler);
   206         delete iGlobalLockHandler;
   204         delete iGlobalLockHandler;
   207         iGlobalLockHandler = globalLockHandler;
   205         iGlobalLockHandler = globalLockHandler;
   208         //now possible deletion of iGlobalLockHandler in leave situation is handled
   206         //now possible deletion of iGlobalLockHandler in leave situation is handled
   209         //in HandleLeaveErrorL() and HandleLeaveErrorWithoutLeave methods. 
   207         //in HandleLeaveErrorL() and HandleLeaveErrorWithoutLeave methods. 
   210         }
   208         }
   211     else
   209     else
   212         {
   210         {
   213         CleanupStack::PopAndDestroy( globalLockHandler );
   211         CleanupStack::PopAndDestroy(globalLockHandler);
   214         CleanupStack::PopAndDestroy( aFilterParams );
   212         CleanupStack::PopAndDestroy(aFilterParams);
   215         // locked by another IAD instance, nothing else to do than just complete client's request.  
   213         // locked by another IAD instance, nothing else to do than just complete client's request.  
   216         InformRequestObserver( KErrNone );
   214         InformRequestObserver(KErrNone);
   217         }  
   215         }
   218 
   216 
   219     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::ShowUpdatesRequestL() end"); 
   217     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::ShowUpdatesRequestL() end");
   220     }
   218     }
   221     
       
   222 
   219 
   223 // -----------------------------------------------------------------------------
   220 // -----------------------------------------------------------------------------
   224 // IAUpdateEngine::ShowUpdateQueryRequestL
   221 // IAUpdateEngine::ShowUpdateQueryRequestL
   225 // 
   222 // 
   226 // -----------------------------------------------------------------------------
   223 // -----------------------------------------------------------------------------
   227 //     
   224 //     
   228 void IAUpdateEngine::ShowUpdateQueryRequestL( int wgid, uint aUid )
   225 void IAUpdateEngine::ShowUpdateQueryRequestL(int wgid, uint aUid)
   229     {
   226     {
   230     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::ShowUpdateQueryRequestL begin");
   227     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::ShowUpdateQueryRequestL begin");
   231     SetClientWgId( wgid );
   228     SetClientWgId(wgid);
   232     mRequestIssued = true;
   229     mRequestIssued = true;
   233     mStartedFromApplication  = true;
   230     mStartedFromApplication = true;
   234     mUpdatequeryUid = aUid;
   231     mUpdatequeryUid = aUid;
   235     mUpdateNow = false;
   232     mUpdateNow = false;
   236     if ( wgid > 0 )
   233     if (wgid > 0)
   237         {
   234         {
   238         HideApplicationInFSWL( true );
   235         HideApplicationInFSWL(true);
   239         }
   236         }
   240     mRequestType = IAUpdateUiDefines::EUpdateQuery;
   237     mRequestType = IAUpdateUiDefines::EUpdateQuery;
   241     
   238 
   242     
       
   243     delete iIdle;
   239     delete iIdle;
   244     iIdle = NULL;
   240     iIdle = NULL;
   245     iIdle = CIdle::NewL( CActive::EPriorityIdle ); 
   241     iIdle = CIdle::NewL(CActive::EPriorityIdle);
   246     iIdle->Start( TCallBack( UpdateQueryCallbackL, this ) ); 
   242     iIdle->Start(TCallBack(UpdateQueryCallbackL, this));
   247     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::ShowUpdateQueryRequestL end")
   243     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::ShowUpdateQueryRequestL end")
   248     }
   244     }
   249 
   245 
   250 // -----------------------------------------------------------------------------
   246 // -----------------------------------------------------------------------------
   251 // IAUpdateEngine::StartUpdate
   247 // IAUpdateEngine::StartUpdate
   252 // 
   248 // 
   253 // -----------------------------------------------------------------------------
   249 // -----------------------------------------------------------------------------
   254 //
   250 //
   255 void IAUpdateEngine::StartUpdate( bool aFirmwareUpdate )
   251 void IAUpdateEngine::StartUpdate(bool aFirmwareUpdate)
   256     {
   252     {
   257     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::StartUpdate() begin");
   253     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::StartUpdate() begin");
   258     if ( aFirmwareUpdate )
   254     if (aFirmwareUpdate)
   259         {
   255         {
   260         if ( !iFwUpdateHandler )
   256         if (!iFwUpdateHandler)
   261             {
   257             {
   262             TRAP_IGNORE( CIAUpdateFWUpdateHandler::NewL() );
   258             TRAP_IGNORE( CIAUpdateFWUpdateHandler::NewL() );
   263             }
   259             }
   264         if ( iFwUpdateHandler )
   260         if (iFwUpdateHandler)
   265             {
   261             {
   266             iFwUpdateHandler->FirmWareUpdatewithFOTA();
   262             iFwUpdateHandler->FirmWareUpdatewithFOTA();
   267             }
   263             }
   268         }
   264         }
   269     else
   265     else
   270         {
   266         {
   271         // by pushing object to cleanup stack it's destructor is called if leave happens
   267         // by pushing object to cleanup stack it's destructor is called if leave happens
   272         // so global lock issued by this instance can be released in destructor of CIAUpdateGlobalLockHandler
   268         // so global lock issued by this instance can be released in destructor of CIAUpdateGlobalLockHandler
   273         CIAUpdateGlobalLockHandler* globalLockHandler = CIAUpdateGlobalLockHandler::NewLC();
   269         CIAUpdateGlobalLockHandler* globalLockHandler =
   274         if ( !globalLockHandler->InUseByAnotherInstanceL() )
   270                 CIAUpdateGlobalLockHandler::NewLC();
   275             {
   271         if (!globalLockHandler->InUseByAnotherInstanceL())
   276             globalLockHandler->SetToInUseForAnotherInstancesL( true );
   272             {
       
   273             globalLockHandler->SetToInUseForAnotherInstancesL(true);
   277             // No need to be totally silent since the updating is started
   274             // No need to be totally silent since the updating is started
   278             // by user.
   275             // by user.
   279             SetDefaultConnectionMethodL( false );
   276             SetDefaultConnectionMethodL(false);
   280             iController->StartUpdateL();
   277             iController->StartUpdateL();
   281             CleanupStack::Pop( globalLockHandler ); 
   278             CleanupStack::Pop(globalLockHandler);
   282             delete iGlobalLockHandler;
   279             delete iGlobalLockHandler;
   283             iGlobalLockHandler = globalLockHandler;
   280             iGlobalLockHandler = globalLockHandler;
   284             //now possible deletion of iGlobalLockHandler in leave situation is handled
   281             //now possible deletion of iGlobalLockHandler in leave situation is handled
   285             //in HandleLeaveErrorL() and HandleLeaveErrorWithoutLeave methods. 
   282             //in HandleLeaveErrorL() and HandleLeaveErrorWithoutLeave methods. 
   286             }
   283             }
   287         else
   284         else
   288             {
   285             {
   289             CleanupStack::PopAndDestroy( globalLockHandler );   
   286             CleanupStack::PopAndDestroy(globalLockHandler);
   290             }
   287             }
   291         }
   288         }
   292     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::StartUpdate() end");
   289     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::StartUpdate() end");
   293     }
   290     }
   294 
   291 
   295 
       
   296 // -----------------------------------------------------------------------------
   292 // -----------------------------------------------------------------------------
   297 // IAUpdateEngine::SetVisibleL
   293 // IAUpdateEngine::SetVisibleL
   298 // 
   294 // 
   299 // -----------------------------------------------------------------------------
   295 // -----------------------------------------------------------------------------
   300 //  
   296 //  
   301 void IAUpdateEngine::SetVisibleL( bool aVisible )
   297 void IAUpdateEngine::SetVisibleL(bool /*aVisible*/)
   302     {
   298     {
   303     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::SetVisibleL() begin");
   299     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::SetVisibleL() begin");
   304     IAUPDATE_TRACE_1("[IAUPDATE] visible: %d", aVisible );
   300     //IAUPDATE_TRACE_1("[IAUPDATE] visible: %d", aVisible );
   305     /*if ( aVisible )
   301     /*if ( aVisible )
   306         {
   302      {
   307         if ( iEikonEnv->RootWin().OrdinalPosition() != 0 || iEikonEnv->RootWin().OrdinalPriority() != ECoeWinPriorityNormal )
   303      if ( iEikonEnv->RootWin().OrdinalPosition() != 0 || iEikonEnv->RootWin().OrdinalPriority() != ECoeWinPriorityNormal )
   308             {
   304      {
   309             iEikonEnv->RootWin().SetOrdinalPosition( 0, ECoeWinPriorityNormal );
   305      iEikonEnv->RootWin().SetOrdinalPosition( 0, ECoeWinPriorityNormal );
   310             }
   306      }
   311         
   307      
   312         StatusPane()->MakeVisible( ETrue );
   308      StatusPane()->MakeVisible( ETrue );
   313         iMainView  = CIAUpdateMainView::NewL( ClientRect() ); 
   309      iMainView  = CIAUpdateMainView::NewL( ClientRect() ); 
   314         AddViewL( iMainView );
   310      AddViewL( iMainView );
   315         ActivateLocalViewL( TUid::Uid( EIAUpdateMainViewId ) );
   311      ActivateLocalViewL( TUid::Uid( EIAUpdateMainViewId ) );
   316         }
   312      }
   317     else
   313      else
   318         {
   314      {
   319         iEikonEnv->RootWin().SetOrdinalPosition( -1, ECoeWinPriorityNeverAtFront );
   315      iEikonEnv->RootWin().SetOrdinalPosition( -1, ECoeWinPriorityNeverAtFront );
   320         StatusPane()->MakeVisible( EFalse );
   316      StatusPane()->MakeVisible( EFalse );
   321         }*/
   317      }*/
   322     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::SetVisibleL() end");
   318     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::SetVisibleL() end");
   323     }
   319     }
   324 
   320 
   325 // -----------------------------------------------------------------------------
   321 // -----------------------------------------------------------------------------
   326 // IAUpdateEngine::SetClientWgId
   322 // IAUpdateEngine::SetClientWgId
   327 // 
   323 // 
   328 // -----------------------------------------------------------------------------
   324 // -----------------------------------------------------------------------------
   329 // 
   325 // 
   330 void IAUpdateEngine::SetClientWgId( int aWgId )
   326 void IAUpdateEngine::SetClientWgId(int aWgId)
   331     {
   327     {
   332     IAUPDATE_TRACE_1("[IAUPDATE] IAUpdateEngine::SetClientWgId() wgId %d", aWgId );
   328     IAUPDATE_TRACE_1("[IAUPDATE] IAUpdateEngine::SetClientWgId() wgId %d", aWgId );
   333     mWgId = aWgId;
   329     mWgId = aWgId;
   334     }
   330     }
   335 
   331 
   340 // 
   336 // 
   341 bool IAUpdateEngine::ClientInBackgroundL() const
   337 bool IAUpdateEngine::ClientInBackgroundL() const
   342     {
   338     {
   343     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::ClientInBackgroundL() begin");
   339     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::ClientInBackgroundL() begin");
   344     bool inBackground = false;
   340     bool inBackground = false;
   345     if ( mWgId > 0 )
   341     if (mWgId > 0)
   346         {
   342         {
   347         CArrayFixFlat<int>*  wgArray = new( ELeave ) CArrayFixFlat<int>(10);  
   343         CArrayFixFlat<int>* wgArray = new (ELeave) CArrayFixFlat<int> (10);
   348         CleanupStack::PushL( wgArray );
   344         CleanupStack::PushL(wgArray);
   349         User::LeaveIfError( iEikEnv->WsSession().WindowGroupList( 0, wgArray ) );  
   345         User::LeaveIfError(iEikEnv->WsSession().WindowGroupList(0, wgArray));
   350         int ownWgId = iEikEnv->RootWin().Identifier();
   346         int ownWgId = iEikEnv->RootWin().Identifier();
   351         if ( ( wgArray->At( 0 ) != ownWgId ) && ( wgArray->At( 0 ) != mWgId  ) )
   347         if ((wgArray->At(0) != ownWgId) && (wgArray->At(0) != mWgId))
   352             {
   348             {
   353             inBackground = true;
   349             inBackground = true;
   354             }
   350             }
   355         CleanupStack::PopAndDestroy( wgArray );  
   351         CleanupStack::PopAndDestroy(wgArray);
   356         }
   352         }
   357     IAUPDATE_TRACE_1("[IAUPDATE] IAUpdateEngine::ClientInBackgroundL() inBackground: %d", inBackground );
   353     IAUPDATE_TRACE_1("[IAUPDATE] IAUpdateEngine::ClientInBackgroundL() inBackground: %d", inBackground );
   358     return inBackground;  
   354     return inBackground;
   359     }
   355     }
   360 
       
   361 
   356 
   362 // -----------------------------------------------------------------------------
   357 // -----------------------------------------------------------------------------
   363 // IAUpdateEngine::handleAllClientsClosed()
   358 // IAUpdateEngine::handleAllClientsClosed()
   364 // 
   359 // 
   365 // -----------------------------------------------------------------------------
   360 // -----------------------------------------------------------------------------
   366 //
   361 //
   367 void IAUpdateEngine::handleAllClientsClosed()
   362 void IAUpdateEngine::handleAllClientsClosed()
   368 {
   363     {
   369     qApp->quit(); 
   364     qApp->quit();
   370 }
   365     }
   371 
       
   372 
   366 
   373 // -----------------------------------------------------------------------------
   367 // -----------------------------------------------------------------------------
   374 // IAUpdateEngine::dialogFinished
   368 // IAUpdateEngine::dialogFinished
   375 // Called when dialog is finished.
   369 // Called when dialog is finished.
   376 // -----------------------------------------------------------------------------
   370 // -----------------------------------------------------------------------------
   377 //
   371 //
   378 void IAUpdateEngine::dialogFinished(HbAction *action)
   372 void IAUpdateEngine::dialogFinished(HbAction *action)
   379     {
   373     {
   380     DialogState dialogState = mDialogState;
   374     DialogState dialogState = mDialogState;
   381     mDialogState = NoDialog;
   375     mDialogState = NoDialog;
   382     
   376 
   383     switch ( dialogState )
   377     switch (dialogState)
   384         {
   378         {
   385         case Results:
   379         case Results:
   386             mUiRefreshAllowed = true;
   380             mUiRefreshAllowed = true;
   387             if ( iController->ResultsInfo().iRebootAfterInstall )
   381             if (iController->ResultsInfo().iRebootAfterInstall)
   388                 {
   382                 {
   389                 ShowRebootDialogL();
   383                 ShowRebootDialogL();
   390                 }
   384                 }
   391             else
   385             else
   392                 {
   386                 {
   395                     iController->RefreshNodeList();
   389                     iController->RefreshNodeList();
   396                     RefreshUI();
   390                     RefreshUI();
   397                     }
   391                     }
   398                 }
   392                 }
   399             break;
   393             break;
   400         case RebootQuery:    
   394         case RebootQuery:
   401             if (action == mPrimaryAction )
   395             if (action == mPrimaryAction)
   402                 {
   396                 {
   403                 RStarterSession startersession;
   397                 RStarterSession startersession;
   404                 if( startersession.Connect() == KErrNone )
   398                 if (startersession.Connect() == KErrNone)
   405                     {
   399                     {
   406                     startersession.Reset( RStarterSession::EUnknownReset );
   400                     startersession.Reset(RStarterSession::EUnknownReset);
   407                     startersession.Close();
   401                     startersession.Close();
   408                     }
   402                     }
   409                 }
   403                 }
   410             else
   404             else
   411                 {
   405                 {
   414                     iController->RefreshNodeList();
   408                     iController->RefreshNodeList();
   415                     RefreshUI();
   409                     RefreshUI();
   416                     }
   410                     }
   417                 }
   411                 }
   418             break;
   412             break;
   419         case ShowUpdateQuery:    
   413         case ShowUpdateQuery:
   420             if (action == mPrimaryAction)
   414             if (action == mPrimaryAction)
   421                 {
   415                 {
   422                 IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::dialogFinished() Now");
   416                 IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::dialogFinished() Now");
   423                 mUpdateNow = true;
   417                 mUpdateNow = true;
   424                 }
   418                 }
   425             else if (action == mSecondaryAction)
   419             else if (action == mSecondaryAction)
   426                 {
   420                 {
   427                 IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::dialogFinished() Later");
   421                 IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::dialogFinished() Later");
   428                 CIAUpdateQueryHistory* updateQueryHistory = CIAUpdateQueryHistory::NewL();
   422                 CIAUpdateQueryHistory* updateQueryHistory =
   429                 CleanupStack::PushL( updateQueryHistory );
   423                         CIAUpdateQueryHistory::NewL();
   430                 updateQueryHistory->SetTimeL( mUpdatequeryUid );
   424                 CleanupStack::PushL(updateQueryHistory);
   431                 CleanupStack::PopAndDestroy( updateQueryHistory );
   425                 updateQueryHistory->SetTimeL(mUpdatequeryUid);
   432                 }
   426                 CleanupStack::PopAndDestroy(updateQueryHistory);
   433             InformRequestObserver( KErrNone );
   427                 }
       
   428             InformRequestObserver(KErrNone);
   434             break;
   429             break;
   435         default: 
   430         default:
   436             break;
   431             break;
   437         }
   432         }
   438     }
   433     }
   439 
   434 
   440 
       
   441 
       
   442 // -----------------------------------------------------------------------------
   435 // -----------------------------------------------------------------------------
   443 // IAUpdateEngine::StartupComplete
   436 // IAUpdateEngine::StartupComplete
   444 // 
   437 // 
   445 // -----------------------------------------------------------------------------
   438 // -----------------------------------------------------------------------------
   446 //    
   439 //    
   447 void IAUpdateEngine::StartupComplete( TInt aError )
   440 void IAUpdateEngine::StartupComplete(TInt aError)
   448     {
   441     {
   449     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::StartupComplete() begin"); 
   442     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::StartupComplete() begin");
   450     IAUPDATE_TRACE_1("[IAUPDATE] error code: %d", aError);
   443     IAUPDATE_TRACE_1("[IAUPDATE] error code: %d", aError);
   451     
   444 
   452     if( aError != KErrNone ) 
   445     if (aError != KErrNone)
   453         {  
   446         {
   454         HandleLeaveErrorWithoutLeave( aError );
   447         HandleLeaveErrorWithoutLeave(aError);
   455         }
   448         }
   456     else
   449     else
   457         {
   450         {
   458         TRAPD( err, StartupCompleteL() );
   451         TRAPD( err, StartupCompleteL() );
   459         if( err != KErrNone ) 
   452         if (err != KErrNone)
   460            {  
   453             {
   461            HandleLeaveErrorWithoutLeave( err );
   454             HandleLeaveErrorWithoutLeave(err);
   462            }
   455             }
   463         }
   456         }
   464  
   457 
   465     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::StartupComplete() end");    
   458     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::StartupComplete() end");
   466     }
   459     }
   467     
   460 
   468 // -----------------------------------------------------------------------------
   461 // -----------------------------------------------------------------------------
   469 // IAUpdateEngine::StartupCompleteL
   462 // IAUpdateEngine::StartupCompleteL
   470 // 
   463 // 
   471 // -----------------------------------------------------------------------------
   464 // -----------------------------------------------------------------------------
   472 //    
   465 //    
   473 void IAUpdateEngine::StartupCompleteL()
   466 void IAUpdateEngine::StartupCompleteL()
   474     {
   467     {
   475     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::StartupCompleteL() begin"); 
   468     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::StartupCompleteL() begin");
   476     
   469 
   477     delete iGlobalLockHandler;
   470     delete iGlobalLockHandler;
   478     iGlobalLockHandler = NULL;
   471     iGlobalLockHandler = NULL;
   479     iGlobalLockHandler = CIAUpdateGlobalLockHandler::NewL();
   472     iGlobalLockHandler = CIAUpdateGlobalLockHandler::NewL();
   480     if ( !iGlobalLockHandler->InUseByAnotherInstanceL() )
   473     if (!iGlobalLockHandler->InUseByAnotherInstanceL())
   481         {
   474         {
   482         bool totalSilent(false);
   475         bool totalSilent(false);
   483         if ( mRequestType == IAUpdateUiDefines::ECheckUpdates )
   476         if (mRequestType == IAUpdateUiDefines::ECheckUpdates)
   484             {
   477             {
   485             if ( iController->Filter() )
   478             if (iController->Filter())
   486                 {
   479                 {
   487                 if ( iController->Filter()->FilterParams() )
   480                 if (iController->Filter()->FilterParams())
   488                     {
   481                     {
   489                     if ( iController->Filter()->FilterParams()->Refresh() )
   482                     if (iController->Filter()->FilterParams()->Refresh())
   490                         {
   483                         {
   491                         if ( !iController->ForcedRefresh() )
   484                         if (!iController->ForcedRefresh())
   492                             {
   485                             {
   493                             //from bgchecker, make it silent
   486                             //from bgchecker, make it silent
   494                             totalSilent = true;
   487                             totalSilent = true;
   495                             }
   488                             }
   496                         }
   489                         }
   497                     }
   490                     }
   498                 }
   491                 }
   499             }
   492             }
   500         SetDefaultConnectionMethodL( totalSilent );
   493         SetDefaultConnectionMethodL(totalSilent);
   501         iGlobalLockHandler->SetToInUseForAnotherInstancesL(true);
   494         iGlobalLockHandler->SetToInUseForAnotherInstancesL(true);
   502         iController->StartRefreshL();  
   495         iController->StartRefreshL();
   503         }
   496         }
   504     else
   497     else
   505         {
   498         {
   506         RefreshCompleteL( true, KErrServerBusy );
   499         RefreshCompleteL(true, KErrServerBusy);
   507         }    
   500         }
   508  
   501 
   509        
   502     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::StartupCompleteL() end");
   510     
   503     }
   511     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::StartupCompleteL() end");    
   504 
   512     }
       
   513 
       
   514  
       
   515 // -----------------------------------------------------------------------------
   505 // -----------------------------------------------------------------------------
   516 // IAUpdateEngine::HandleLeaveErrorL
   506 // IAUpdateEngine::HandleLeaveErrorL
   517 // 
   507 // 
   518 // -----------------------------------------------------------------------------
   508 // -----------------------------------------------------------------------------
   519 //        
   509 //        
   520 void IAUpdateEngine::HandleLeaveErrorL( TInt aError )
   510 void IAUpdateEngine::HandleLeaveErrorL(TInt aError)
   521     {
   511     {
   522     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::HandleLeaveErrorL() begin");
   512     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::HandleLeaveErrorL() begin");
   523     //removal of iGlobalLockHandler releases possible global operation lock to other IAD instances
   513     //removal of iGlobalLockHandler releases possible global operation lock to other IAD instances
   524     delete iGlobalLockHandler;
   514     delete iGlobalLockHandler;
   525     iGlobalLockHandler = NULL;
   515     iGlobalLockHandler = NULL;
   526     // client request is completed before leave in case of leave error
   516     // client request is completed before leave in case of leave error
   527     if ( aError != KErrNone ) 
   517     if (aError != KErrNone)
   528         {   
   518         {
   529         InformRequestObserver( aError );
   519         InformRequestObserver(aError);
   530         User::Leave( aError );
   520         User::Leave(aError);
   531         }
   521         }
   532     
   522 
   533     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::HandleLeaveErrorL() end");
   523     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::HandleLeaveErrorL() end");
   534     }
   524     }
   535 
   525 
   536 
       
   537 // -----------------------------------------------------------------------------
   526 // -----------------------------------------------------------------------------
   538 // IAUpdateEngine::HandleLeaveErrorWithoutLeave
   527 // IAUpdateEngine::HandleLeaveErrorWithoutLeave
   539 // 
   528 // 
   540 // -----------------------------------------------------------------------------
   529 // -----------------------------------------------------------------------------
   541 //  
   530 //  
   542 void IAUpdateEngine::HandleLeaveErrorWithoutLeave( TInt aError )
   531 void IAUpdateEngine::HandleLeaveErrorWithoutLeave(TInt aError)
   543     {
   532     {
   544     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::HandleLeaveErrorWithoutLeave() begin");
   533     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::HandleLeaveErrorWithoutLeave() begin");
   545     //removal of iGlobalLockHandler releases possible global operation lock to other IAD instances
   534     //removal of iGlobalLockHandler releases possible global operation lock to other IAD instances
   546     delete iGlobalLockHandler;
   535     delete iGlobalLockHandler;
   547     iGlobalLockHandler = NULL;
   536     iGlobalLockHandler = NULL;
   548     if ( aError != KErrNone ) 
   537     if (aError != KErrNone)
   549         {
   538         {
   550         InformRequestObserver( aError );
   539         InformRequestObserver(aError);
   551         }
   540         }
   552     if ( aError == KErrDiskFull )
   541     if (aError == KErrDiskFull)
   553         {
   542         {
   554         //TRAP_IGNORE( ShowGlobalErrorNoteL( aError ) );
   543         //TRAP_IGNORE( ShowGlobalErrorNoteL( aError ) );
   555         }
   544         }
   556     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::HandleLeaveErrorWithoutLeave end");
   545     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::HandleLeaveErrorWithoutLeave end");
   557     }
   546     }
   558 
   547 
   559 
       
   560 // -----------------------------------------------------------------------------
   548 // -----------------------------------------------------------------------------
   561 // IAUpdateEngine::RefreshUI
   549 // IAUpdateEngine::RefreshUI
   562 // 
   550 // 
   563 // -----------------------------------------------------------------------------
   551 // -----------------------------------------------------------------------------
   564 // 
   552 // 
   565 void IAUpdateEngine::RefreshUI()
   553 void IAUpdateEngine::RefreshUI()
   566     {
   554     {
   567     emit refresh( iController->Nodes(), iController->FwNodes(), KErrNone );
   555     emit refresh(iController->Nodes(), iController->FwNodes(), KErrNone);
   568     }
   556     }
   569 
       
   570 
   557 
   571 // -----------------------------------------------------------------------------
   558 // -----------------------------------------------------------------------------
   572 // IAUpdateEngine::RefreshCompleteL
   559 // IAUpdateEngine::RefreshCompleteL
   573 // 
   560 // 
   574 // -----------------------------------------------------------------------------
   561 // -----------------------------------------------------------------------------
   575 //      
   562 //      
   576 void IAUpdateEngine::RefreshCompleteL( TBool /*aWithViewActivation*/, TInt aError )
   563 void IAUpdateEngine::RefreshCompleteL(TBool /*aWithViewActivation*/,
       
   564         TInt aError)
   577     {
   565     {
   578     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::RefreshCompleteL() begin");
   566     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::RefreshCompleteL() begin");
   579     IAUPDATE_TRACE_1("[IAUPDATE] error code: %d", aError );
   567     IAUPDATE_TRACE_1("[IAUPDATE] error code: %d", aError );
   580     //removal of iGlobalLockHandler releases possible global operation lock to other IAD instances
   568     //removal of iGlobalLockHandler releases possible global operation lock to other IAD instances
   581     delete iGlobalLockHandler;
   569     delete iGlobalLockHandler;
   582     iGlobalLockHandler = NULL;   
   570     iGlobalLockHandler = NULL;
   583    
   571 
   584     if ( mRequestType == IAUpdateUiDefines::ECheckUpdates )
   572     if (mRequestType == IAUpdateUiDefines::ECheckUpdates)
   585         {
   573         {
   586         InformRequestObserver( aError );
   574         InformRequestObserver(aError);
   587         }
   575         }
   588     else 
   576     else
   589         {    
   577         {
   590         emit refresh( iController->Nodes(), iController->FwNodes(), aError );   
   578         emit refresh(iController->Nodes(), iController->FwNodes(), aError);
   591         //if ( aWithViewActivation)
   579         //if ( aWithViewActivation)
   592           //  {
   580         //  {
   593           //  ActivateLocalViewL( TUid::Uid( EIAUpdateMainViewId ) );
   581         //  ActivateLocalViewL( TUid::Uid( EIAUpdateMainViewId ) );
   594           //  }
   582         //  }
   595         CIAUpdateAgreement* agreement = CIAUpdateAgreement::NewLC();
   583         CIAUpdateAgreement* agreement = CIAUpdateAgreement::NewLC();
   596         bool agreementAccepted = agreement->AgreementAcceptedL();
   584         bool agreementAccepted = agreement->AgreementAcceptedL();
   597         if ( iController->ForcedRefresh() )    
   585         if (iController->ForcedRefresh())
   598             {
   586             {
   599             if ( !agreementAccepted )
   587             if (!agreementAccepted)
   600                 {
   588                 {
   601                 agreement->SetAgreementAcceptedL();
   589                 agreement->SetAgreementAcceptedL();
   602                 }
   590                 }
   603             }
   591             }
   604         CleanupStack::PopAndDestroy( agreement );
   592         CleanupStack::PopAndDestroy(agreement);
   605         // By calling CIdle possible waiting dialog can be closed before
   593         // By calling CIdle possible waiting dialog can be closed before
   606         // automatic check where a new dialog may be launched
   594         // automatic check where a new dialog may be launched
   607         delete iIdleAutCheck;
   595         delete iIdleAutCheck;
   608         iIdleAutCheck = NULL;
   596         iIdleAutCheck = NULL;
   609         iIdleAutCheck = CIdle::NewL( CActive::EPriorityIdle ); 
   597         iIdleAutCheck = CIdle::NewL(CActive::EPriorityIdle);
   610         iIdleAutCheck->Start( TCallBack( AutomaticCheckCallbackL, this ) );
   598         iIdleAutCheck->Start(TCallBack(AutomaticCheckCallbackL, this));
   611         } 
   599         }
   612  
   600 
   613   
   601     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::RefreshCompleteL() end");
   614     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::RefreshCompleteL() end");        
   602     }
   615     }
       
   616 
       
   617 
       
   618 
       
   619 
   603 
   620 // -----------------------------------------------------------------------------
   604 // -----------------------------------------------------------------------------
   621 // IAUpdateEngine::UpdateCompleteL
   605 // IAUpdateEngine::UpdateCompleteL
   622 // 
   606 // 
   623 // -----------------------------------------------------------------------------
   607 // -----------------------------------------------------------------------------
   624 //     
   608 //     
   625 void IAUpdateEngine::UpdateCompleteL( TInt aError )    
   609 void IAUpdateEngine::UpdateCompleteL(TInt aError)
   626     {
   610     {
   627     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::UpdateCompleteL begin");
   611     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::UpdateCompleteL begin");
   628     IAUPDATE_TRACE_1("[IAUPDATE] error code: %d", aError );
   612     IAUPDATE_TRACE_1("[IAUPDATE] error code: %d", aError );
   629     //removal of iGlobalLockHandler releases possible global operation lock to other IAD instances
   613     //removal of iGlobalLockHandler releases possible global operation lock to other IAD instances
   630     delete iGlobalLockHandler;
   614     delete iGlobalLockHandler;
   631     iGlobalLockHandler = NULL;  
   615     iGlobalLockHandler = NULL;
   632     if ( mRequestType != IAUpdateUiDefines::ENoRequest )
   616     if (mRequestType != IAUpdateUiDefines::ENoRequest)
   633         {
   617         {
   634         InformRequestObserver( aError );
   618         InformRequestObserver(aError);
   635         }
   619         }
   636              
   620 
   637     ShowResultsDialogL();
   621     ShowResultsDialogL();
   638                 
   622 
   639     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::UpdateCompleteL end");
   623     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::UpdateCompleteL end");
   640     }
   624     }
   641 
       
   642 
       
   643 
   625 
   644 // -----------------------------------------------------------------------------
   626 // -----------------------------------------------------------------------------
   645 // IAUpdateEngine::ShowResultsDialogL
   627 // IAUpdateEngine::ShowResultsDialogL
   646 // 
   628 // 
   647 // -----------------------------------------------------------------------------
   629 // -----------------------------------------------------------------------------
   648 //   
   630 //   
   649 void IAUpdateEngine::ShowResultsDialogL()
   631 void IAUpdateEngine::ShowResultsDialogL()
   650     {
   632     {
   651     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::ShowResultsDialogL() begin"); 
   633     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::ShowResultsDialogL() begin");
   652                 
   634 
   653     mUiRefreshAllowed = false;
   635     mUiRefreshAllowed = false;
   654     mResultsDialog = new IAUpdateResultsDialog(this);
   636     mResultsDialog = new IAUpdateResultsDialog(this);
   655     mResultsDialog->showResults(iController->ResultsInfo(),this,SLOT(dialogFinished(HbAction*)));
   637     mResultsDialog->showResults(iController->ResultsInfo(), this,
       
   638             SLOT(dialogFinished(HbAction*)));
   656     mDialogState = Results;
   639     mDialogState = Results;
   657     
   640 
   658     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::ShowResultsDialogL() end");
   641     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::ShowResultsDialogL() end");
   659     }
   642     }
   660     
   643 
   661 // -----------------------------------------------------------------------------
   644 // -----------------------------------------------------------------------------
   662 // IAUpdateEngine::ShowRebootDialogL
   645 // IAUpdateEngine::ShowRebootDialogL
   663 // 
   646 // 
   664 // -----------------------------------------------------------------------------
   647 // -----------------------------------------------------------------------------
   665 //
   648 //
   666 void IAUpdateEngine::ShowRebootDialogL()
   649 void IAUpdateEngine::ShowRebootDialogL()
   667     {
   650     {
   668     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::ShowRebootDialogL() begin");
   651     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::ShowRebootDialogL() begin");
   669     
   652 
   670     HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
   653     HbMessageBox *messageBox = new HbMessageBox(
       
   654             HbMessageBox::MessageTypeQuestion);
   671     messageBox->setText(QString("Phone restart needed. Restart now?"));
   655     messageBox->setText(QString("Phone restart needed. Restart now?"));
   672     int actionCount = messageBox->actions().count();
   656     int actionCount = messageBox->actions().count();
   673     for (int i=actionCount-1; i >= 0; i--)
   657     for (int i = actionCount - 1; i >= 0; i--)
   674     { 
   658         {
   675         messageBox->removeAction(messageBox->actions().at(i));
   659         messageBox->removeAction(messageBox->actions().at(i));
   676     }
   660         }
   677     mPrimaryAction = NULL;
   661     mPrimaryAction = NULL;
   678     mPrimaryAction = new HbAction("Ok");
   662     mPrimaryAction = new HbAction("Ok");
   679     HbAction *secondaryAction = NULL;
   663     HbAction *secondaryAction = NULL;
   680     secondaryAction = new HbAction("Cancel");
   664     secondaryAction = new HbAction("Cancel");
   681 
   665 
   683     messageBox->addAction(secondaryAction);
   667     messageBox->addAction(secondaryAction);
   684     messageBox->setTimeout(HbPopup::NoTimeout);
   668     messageBox->setTimeout(HbPopup::NoTimeout);
   685     messageBox->setAttribute(Qt::WA_DeleteOnClose);
   669     messageBox->setAttribute(Qt::WA_DeleteOnClose);
   686     messageBox->open(this, SLOT(dialogFinished(HbAction*)));
   670     messageBox->open(this, SLOT(dialogFinished(HbAction*)));
   687     mDialogState = RebootQuery;
   671     mDialogState = RebootQuery;
   688     
   672 
   689     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::ShowRebootDialogL() end");
   673     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::ShowRebootDialogL() end");
   690     }
   674     }
   691 
   675 
   692 
       
   693 
       
   694 
       
   695 
       
   696 
       
   697 // -----------------------------------------------------------------------------
   676 // -----------------------------------------------------------------------------
   698 // IAUpdateEngine::InformRequestObserver
   677 // IAUpdateEngine::InformRequestObserver
   699 // 
   678 // 
   700 // -----------------------------------------------------------------------------
   679 // -----------------------------------------------------------------------------
   701 //      
   680 //      
   702 void IAUpdateEngine::InformRequestObserver( int aError )
   681 void IAUpdateEngine::InformRequestObserver(int aError)
   703     {
   682     {
   704     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::InformRequestObserver() begin");
   683     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::InformRequestObserver() begin");
   705         
   684 
   706     //if ( iRequestObserver )
   685     //if ( iRequestObserver )
   707     if ( mRequestIssued )    
   686     if (mRequestIssued)
   708         {
   687         {
   709         if ( iController->ClosingAllowedByClient() )
   688         if (iController->ClosingAllowedByClient())
   710             {
   689             {
   711             if ( mRequestType != IAUpdateUiDefines::ENoRequest )
   690             if (mRequestType != IAUpdateUiDefines::ENoRequest)
   712                 {
   691                 {
   713 //                if ( iRequestType == IAUpdateUiDefines::EUpdateQuery && iUpdateNow )
   692                 //                if ( iRequestType == IAUpdateUiDefines::EUpdateQuery && iUpdateNow )
   714 //                    {
   693                 //                    {
   715 //                  if ( !iBackgroundTimer )
   694                 //                  if ( !iBackgroundTimer )
   716 //                        {
   695                 //                        {
   717 //                        iBackgroundTimer = CIAUpdateUITimer::NewL( *this, CIAUpdateUITimer::EBackgroundDelay );
   696                 //                        iBackgroundTimer = CIAUpdateUITimer::NewL( *this, CIAUpdateUITimer::EBackgroundDelay );
   718 //                        }
   697                 //                        }
   719 //                 if ( !iBackgroundTimer->IsActive() )
   698                 //                 if ( !iBackgroundTimer->IsActive() )
   720 //                        {
   699                 //                        {
   721 //                        iBackgroundTimer->After( 500000 );
   700                 //                        iBackgroundTimer->After( 500000 );
   722 //                        }
   701                 //                        }
   723 //                    }
   702                 //                    }
   724 //                 else
   703                 //                 else
   725 //                    {
   704                 //                    {
   726                       iEikEnv->RootWin().SetOrdinalPosition( -1, ECoeWinPriorityNeverAtFront );
   705                 iEikEnv->RootWin().SetOrdinalPosition(-1,
   727 //                    }
   706                         ECoeWinPriorityNeverAtFront);
   728                 }
   707                 //                    }
   729             }
   708                 }
   730         
   709             }
   731         switch ( mRequestType )
   710 
       
   711         switch (mRequestType)
   732             {
   712             {
   733             case IAUpdateUiDefines::ENoRequest:
   713             case IAUpdateUiDefines::ENoRequest:
   734                 {
   714                 {
   735                 mServiceProvider->completeLauncherLaunch( aError );
   715                 mServiceProvider->completeLauncherLaunch(aError);
   736                 break;
   716                 break;
   737                 }
   717                 }
   738             case IAUpdateUiDefines::ECheckUpdates:
   718             case IAUpdateUiDefines::ECheckUpdates:
   739                 {
   719                 {
   740                 mServiceProvider->completeCheckUpdates( iController->CountOfAvailableUpdates(), aError );
   720                 mServiceProvider->completeCheckUpdates(
       
   721                         iController->CountOfAvailableUpdates(), aError);
   741                 break;
   722                 break;
   742                 }
   723                 }
   743             case IAUpdateUiDefines::EShowUpdates:
   724             case IAUpdateUiDefines::EShowUpdates:
   744                 {
   725                 {
   745                 CIAUpdateResult* result( NULL );
   726                 CIAUpdateResult* result(NULL);
   746                 TRAPD( error, result = CIAUpdateResult::NewL() )
   727                 TRAPD( error, result = CIAUpdateResult::NewL() )
   747                 if ( result )
   728                 if (result)
   748                     {
   729                     {
   749                     TIAUpdateResultsInfo resultsInfo( iController->ResultsInfo() );
   730                     TIAUpdateResultsInfo resultsInfo(
   750                     IAUPDATE_TRACE_3("[IAUPDATE] IAUpdateEngine::InformRequestObserver succeed: %d failed: %d  cancelled: %d", 
   731                             iController->ResultsInfo());
   751                                                   resultsInfo.iCountSuccessfull, 
   732                     IAUPDATE_TRACE_3("[IAUPDATE] IAUpdateEngine::InformRequestObserver succeed: %d failed: %d  cancelled: %d",
   752                                                   resultsInfo.iCountFailed, 
   733                             resultsInfo.iCountSuccessfull,
   753                                                   resultsInfo.iCountCancelled );
   734                             resultsInfo.iCountFailed,
   754                     result->SetSuccessCount( resultsInfo.iCountSuccessfull );
   735                             resultsInfo.iCountCancelled );
   755                     result->SetFailCount( resultsInfo.iCountFailed );
   736                     result->SetSuccessCount(resultsInfo.iCountSuccessfull);
   756                     result->SetCancelCount( resultsInfo.iCountCancelled );    
   737                     result->SetFailCount(resultsInfo.iCountFailed);
   757                     mServiceProvider->completeShowUpdates( result, aError );
   738                     result->SetCancelCount(resultsInfo.iCountCancelled);
       
   739                     mServiceProvider->completeShowUpdates(result, aError);
   758                     // Ownership of result is transferred here.
   740                     // Ownership of result is transferred here.
   759                     }
   741                     }
   760                 else
   742                 else
   761                     {
   743                     {
   762                     mServiceProvider->completeShowUpdates( NULL, error );
   744                     mServiceProvider->completeShowUpdates(NULL, error);
   763                     }
   745                     }
   764                 break;
   746                 break;
   765                 }
   747                 }
   766             case IAUpdateUiDefines::EUpdateQuery:
   748             case IAUpdateUiDefines::EUpdateQuery:
   767                 {
   749                 {
   768                 mServiceProvider->completeUpdateQuery( mUpdateNow, aError );
   750                 mServiceProvider->completeUpdateQuery(mUpdateNow, aError);
   769                 break;
   751                 break;
   770                 }
   752                 }
   771             default:
   753             default:
   772                 {
   754                 {
   773                 break;
   755                 break;
   774                 }
   756                 }
   775             }
   757             }
   776 
   758 
   777         mRequestIssued = false;
   759         mRequestIssued = false;
   778         }
   760         }
   779         
   761 
   780     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::InformRequestObserver() end");
   762     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::InformRequestObserver() end");
   781     }
   763     }
   782 
       
   783 
   764 
   784 // ---------------------------------------------------------------------------
   765 // ---------------------------------------------------------------------------
   785 // IAUpdateEngine::SetDefaultConnectionMethodL
   766 // IAUpdateEngine::SetDefaultConnectionMethodL
   786 // Sets the connection method for the update network connection.
   767 // Sets the connection method for the update network connection.
   787 // ---------------------------------------------------------------------------
   768 // ---------------------------------------------------------------------------
   788 //
   769 //
   789 void IAUpdateEngine::SetDefaultConnectionMethodL( bool aTotalSilent )
   770 void IAUpdateEngine::SetDefaultConnectionMethodL(bool aTotalSilent)
   790     {
   771     {
   791     if ( aTotalSilent )
   772     if (aTotalSilent)
   792         {
   773         {
   793         // from back ground checker, choose the IAP to make the internet access silent
   774         // from back ground checker, choose the IAP to make the internet access silent
   794         IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::SetDefaultConnectionMethodL() begin");
   775         IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::SetDefaultConnectionMethodL() begin");
   795 
   776 
   796         uint connectionMethodId( 0 );
   777         uint connectionMethodId(0);
   797         int connMethodId( 0 );
   778         int connMethodId(0);
   798 
   779 
   799         // Let's first check whether cenrep contains SNAP id other than zero
   780         // Let's first check whether cenrep contains SNAP id other than zero
   800         CRepository* cenrep( CRepository::NewLC( KCRUidIAUpdateSettings ) );
   781         CRepository* cenrep(CRepository::NewLC(KCRUidIAUpdateSettings));
   801         User::LeaveIfError(  
   782         User::LeaveIfError(cenrep->Get(KIAUpdateAccessPoint, connMethodId));
   802                cenrep->Get( KIAUpdateAccessPoint, connMethodId ) );
   783         CleanupStack::PopAndDestroy(cenrep);
   803         CleanupStack::PopAndDestroy( cenrep ); 
       
   804         cenrep = NULL;
   784         cenrep = NULL;
   805 
   785 
   806         RCmManagerExt cmManagerExt;
   786         RCmManager cmManager;
   807         cmManagerExt.OpenL();
   787         cmManager.OpenL();
   808         CleanupClosePushL( cmManagerExt );
   788         CleanupClosePushL(cmManager);
   809            
   789 
   810         if ( connMethodId == -1 )
   790         if (connMethodId == -1)
   811             {
   791             {
   812             IAUPDATE_TRACE("[IAUPDATE] user chooses default connection, use IAP logic");
   792             IAUPDATE_TRACE("[IAUPDATE] user chooses default connection, use IAP logic");
   813                
   793 
   814             //check what is the default connection by users     
   794             //check what is the default connection by users     
   815                
   795 
   816             TCmDefConnValue DCSetting;
   796             TCmDefConnValue DCSetting;
   817             cmManagerExt.ReadDefConnL( DCSetting );
   797             cmManager.ReadDefConnL(DCSetting);
   818                
   798 
   819             switch ( DCSetting.iType )
   799             switch (DCSetting.iType)
   820                 {
   800                 {
   821                 case ECmDefConnAlwaysAsk:
   801                 case ECmDefConnAlwaysAsk:
   822                 case ECmDefConnAskOnce:
   802                 case ECmDefConnAskOnce:
   823                     {
   803                     {
   824                     //go with the best IAP under internet snap
   804                     //go with the best IAP under internet snap
   825                     connectionMethodId = GetBestIAPInAllSNAPsL( cmManagerExt );
   805                     connectionMethodId = GetBestIAPInAllSNAPsL(cmManager);
   826                     break;
   806                     break;
   827                     }
   807                     }
   828                 case ECmDefConnDestination:
   808                 case ECmDefConnDestination:
   829                     {
   809                     {
   830                     //go with the best IAP under this snap
   810                     //go with the best IAP under this snap
   831                     connectionMethodId = GetBestIAPInThisSNAPL( cmManagerExt, DCSetting.iId );
   811                     connectionMethodId = GetBestIAPInThisSNAPL(cmManager,
       
   812                             DCSetting.iId);
   832                     break;
   813                     break;
   833                     }
   814                     }
   834                 case ECmDefConnConnectionMethod:
   815                 case ECmDefConnConnectionMethod:
   835                     {
   816                     {
   836                     //go with the best IAP under this snap
   817                     //go with the best IAP under this snap
   837                     connectionMethodId = DCSetting.iId;
   818                     connectionMethodId = DCSetting.iId;
   838                     break;
   819                     break;
   839                     }
   820                     }
   840                 }
   821                 }
   841             }
   822             }
   842         else if ( connMethodId == 0 )
   823         else if (connMethodId == 0)
   843             {
   824             {
   844             //no choice from user, we go with the best IAP under Internent SNAP
   825             //no choice from user, we go with the best IAP under Internent SNAP
   845             connectionMethodId = GetBestIAPInAllSNAPsL( cmManagerExt );
   826             connectionMethodId = GetBestIAPInAllSNAPsL(cmManager);
   846             }
   827             }
   847         else
   828         else
   848             {
   829             {
   849             IAUPDATE_TRACE("[IAUPDATE] use chooses a snap");
   830             IAUPDATE_TRACE("[IAUPDATE] use chooses a snap");
   850             // It was some SNAP value
   831             // It was some SNAP value
   851             connectionMethodId = GetBestIAPInThisSNAPL( cmManagerExt, connMethodId );
   832             connectionMethodId = GetBestIAPInThisSNAPL(cmManager,
   852             }
   833                     connMethodId);
   853 
   834             }
   854         CleanupStack::PopAndDestroy( &cmManagerExt ); 
   835 
   855            
   836         CleanupStack::PopAndDestroy(&cmManager);
   856         if ( connectionMethodId != 0 )
   837 
   857             {
   838         if (connectionMethodId != 0)
   858             TIAUpdateConnectionMethod connectionMethod( 
   839             {
   859                    connectionMethodId, 
   840             TIAUpdateConnectionMethod
   860                    TIAUpdateConnectionMethod::EConnectionMethodTypeAccessPoint );
   841                     connectionMethod(
   861 
   842                             connectionMethodId,
   862             iController->SetDefaultConnectionMethodL( connectionMethod );
   843                             TIAUpdateConnectionMethod::EConnectionMethodTypeAccessPoint);
       
   844 
       
   845             iController->SetDefaultConnectionMethodL(connectionMethod);
   863             }
   846             }
   864         else
   847         else
   865             {
   848             {
   866             //In the totally silent case, if no usable IAP, we complete the check update with 0 updates.
   849             //In the totally silent case, if no usable IAP, we complete the check update with 0 updates.
   867             //the bgchecker will try again later after 1 month. 
   850             //the bgchecker will try again later after 1 month. 
   868             //The LEAVE will be catched up later and complete the request from background checker.
   851             //The LEAVE will be catched up later and complete the request from background checker.
   869             User::LeaveIfError( KErrNotFound );
   852             User::LeaveIfError(KErrNotFound);
   870             }
   853             }
   871         IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::SetDefaultConnectionMethodL() end");
   854         IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::SetDefaultConnectionMethodL() end");
   872         }
   855         }
   873     else
   856     else
   874         {
   857         {
   875         // from grid, use the old logic
   858         // from grid, use the old logic
   876         IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::SetDefaultConnectionMethodL() begin");
   859         IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::SetDefaultConnectionMethodL() begin");
   877         uint connectionMethodId( 0 );
   860         uint connectionMethodId(0);
   878         int connMethodId( 0 );
   861         int connMethodId(0);
   879 
   862 
   880         // Set initial value to always ask
   863         // Set initial value to always ask
   881         int connectionMethodType( TIAUpdateConnectionMethod::EConnectionMethodTypeAlwaysAsk );
   864         int connectionMethodType(
       
   865                 TIAUpdateConnectionMethod::EConnectionMethodTypeAlwaysAsk);
   882         bool needSaving(false);
   866         bool needSaving(false);
   883 
   867 
   884         // Let's first check whether cenrep contains SNAP id other than zero
   868         // Let's first check whether cenrep contains SNAP id other than zero
   885         CRepository* cenrep( CRepository::NewLC( KCRUidIAUpdateSettings ) );
   869         CRepository* cenrep(CRepository::NewLC(KCRUidIAUpdateSettings));
   886         User::LeaveIfError(  
   870         User::LeaveIfError(cenrep->Get(KIAUpdateAccessPoint, connMethodId));
   887                       cenrep->Get( KIAUpdateAccessPoint, connMethodId ) );
   871         CleanupStack::PopAndDestroy(cenrep);
   888         CleanupStack::PopAndDestroy( cenrep ); 
       
   889         cenrep = NULL;
   872         cenrep = NULL;
   890                     
   873 
   891         if ( connMethodId == -1 )
   874         if (connMethodId == -1)
   892             {
   875             {
   893             IAUPDATE_TRACE("[IAUPDATE] user chooses default connection, use IAP logic");
   876             IAUPDATE_TRACE("[IAUPDATE] user chooses default connection, use IAP logic");
   894                                             
   877 
   895             connectionMethodId = 0;
   878             connectionMethodId = 0;
   896             connectionMethodType = TIAUpdateConnectionMethod::EConnectionMethodTypeDefault;
   879             connectionMethodType
   897             }
   880                     = TIAUpdateConnectionMethod::EConnectionMethodTypeDefault;
   898         else if ( connMethodId == 0 )
   881             }
       
   882         else if (connMethodId == 0)
   899             {
   883             {
   900             IAUPDATE_TRACE("[IAUPDATE] use chooses nothing, use internal IAP logic");
   884             IAUPDATE_TRACE("[IAUPDATE] use chooses nothing, use internal IAP logic");
   901             //if nothing is set by user, use our new logic
   885             //if nothing is set by user, use our new logic
   902             //SetDefaultConnectionMethod2L();
   886             //SetDefaultConnectionMethod2L();
   903             //return;
   887             //return;
   904             // CenRep didn't contain any SNAP id. Let's try Internet SNAP then.
   888             // CenRep didn't contain any SNAP id. Let's try Internet SNAP then.
   905                           
   889 
   906             RCmManagerExt cmManagerExt;
   890             RCmManager cmManager;
   907             cmManagerExt.OpenL();
   891             cmManager.OpenL();
   908             CleanupClosePushL( cmManagerExt );
   892             CleanupClosePushL(cmManager);
   909             iDestIdArray.Reset();
   893             iDestIdArray.Reset();
   910             cmManagerExt.AllDestinationsL( iDestIdArray );
   894             cmManager.AllDestinationsL(iDestIdArray);
   911 
   895 
   912             for ( int i = 0; i< iDestIdArray.Count(); i++ )
   896             for (int i = 0; i < iDestIdArray.Count(); i++)
   913                 {
   897                 {
   914                 RCmDestinationExt dest = cmManagerExt.DestinationL( iDestIdArray[i] );
   898                 RCmDestination dest = cmManager.DestinationL(iDestIdArray[i]);
   915                 CleanupClosePushL( dest );
   899                 CleanupClosePushL(dest);
   916                            
   900 
   917                 if ( dest.MetadataL( CMManager::ESnapMetadataInternet ) )
   901                 if (dest.MetadataL(CMManager::ESnapMetadataInternet))
   918                     {
   902                     {
   919                     // Check whether Internet SNAP contains any IAP.
   903                     // Check whether Internet SNAP contains any IAP.
   920                     if ( dest.ConnectionMethodCount() > 0 )
   904                     if (dest.ConnectionMethodCount() > 0)
   921                         {
   905                         {
   922                         connectionMethodId = iDestIdArray[i];
   906                         connectionMethodId = iDestIdArray[i];
   923                         needSaving = true;
   907                         needSaving = true;
   924                         IAUPDATE_TRACE_1("[IAUPDATE] connectionMethodId: %d", connectionMethodId );
   908                         IAUPDATE_TRACE_1("[IAUPDATE] connectionMethodId: %d", connectionMethodId );
   925                         }
   909                         }
   926                     CleanupStack::PopAndDestroy( &dest ); 
   910                     CleanupStack::PopAndDestroy(&dest);
   927                     break;
   911                     break;
   928                     }
   912                     }
   929                              
   913 
   930                 CleanupStack::PopAndDestroy( &dest ); 
   914                 CleanupStack::PopAndDestroy(&dest);
   931                 }
   915                 }
   932             iDestIdArray.Reset();
   916             iDestIdArray.Reset();
   933             CleanupStack::PopAndDestroy( &cmManagerExt ); 
   917             CleanupStack::PopAndDestroy(&cmManager);
   934             }
   918             }
   935         else
   919         else
   936             {
   920             {
   937             IAUPDATE_TRACE("[IAUPDATE] use chooses a snap");
   921             IAUPDATE_TRACE("[IAUPDATE] use chooses a snap");
   938             // It was some SNAP value
   922             // It was some SNAP value
   939             connectionMethodId = connMethodId;
   923             connectionMethodId = connMethodId;
   940             }
   924             }
   941                   
   925 
   942         if ( connectionMethodId > 0)
   926         if (connectionMethodId > 0)
   943             {
   927             {
   944             // We have now some valid SNAP id, either from CenRep or Internet SNAP
   928             // We have now some valid SNAP id, either from CenRep or Internet SNAP
   945             connectionMethodType = TIAUpdateConnectionMethod::EConnectionMethodTypeDestination;
   929             connectionMethodType
       
   930                     = TIAUpdateConnectionMethod::EConnectionMethodTypeDestination;
   946             // Save to cenrep if needed
   931             // Save to cenrep if needed
   947             if ( needSaving )
   932             if (needSaving)
   948                 {
   933                 {
   949                 cenrep = CRepository::NewLC( KCRUidIAUpdateSettings );
   934                 cenrep = CRepository::NewLC(KCRUidIAUpdateSettings);
   950                 int err = cenrep->StartTransaction( CRepository::EReadWriteTransaction );
   935                 int err = cenrep->StartTransaction(
   951                 User::LeaveIfError( err );
   936                         CRepository::EReadWriteTransaction);
       
   937                 User::LeaveIfError(err);
   952                 cenrep->CleanupCancelTransactionPushL();
   938                 cenrep->CleanupCancelTransactionPushL();
   953                           
   939 
   954                  connMethodId = connectionMethodId;
   940                 connMethodId = connectionMethodId;
   955                  err = cenrep->Set( KIAUpdateAccessPoint, connMethodId );
   941                 err = cenrep->Set(KIAUpdateAccessPoint, connMethodId);
   956                  User::LeaveIfError( err );
   942                 User::LeaveIfError(err);
   957                  TUint32 ignore = KErrNone;
   943                 TUint32 ignore = KErrNone;
   958                  User::LeaveIfError( cenrep->CommitTransaction( ignore ) );
   944                 User::LeaveIfError(cenrep->CommitTransaction(ignore));
   959                  CleanupStack::PopAndDestroy(); // CleanupCancelTransactionPushL()
   945                 CleanupStack::PopAndDestroy(); // CleanupCancelTransactionPushL()
   960                  CleanupStack::PopAndDestroy( cenrep );            
   946                 CleanupStack::PopAndDestroy(cenrep);
   961                  }
   947                 }
   962             }
   948             }
   963 
   949 
   964         TIAUpdateConnectionMethod connectionMethod( 
   950         TIAUpdateConnectionMethod
   965                       connectionMethodId, 
   951                 connectionMethod(
   966                       static_cast< TIAUpdateConnectionMethod::TConnectionMethodType >( connectionMethodType ) );
   952                         connectionMethodId,
   967 
   953                         static_cast<TIAUpdateConnectionMethod::TConnectionMethodType> (connectionMethodType));
   968         iController->SetDefaultConnectionMethodL( connectionMethod );
   954 
       
   955         iController->SetDefaultConnectionMethodL(connectionMethod);
   969 
   956 
   970         IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::SetDefaultConnectionMethodL() end");
   957         IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::SetDefaultConnectionMethodL() end");
   971         }
   958         }
   972     }
   959     }
   973 
       
   974 
   960 
   975 // ---------------------------------------------------------------------------
   961 // ---------------------------------------------------------------------------
   976 // IAUpdateEngine::GetBestIAPInAllSNAPsL
   962 // IAUpdateEngine::GetBestIAPInAllSNAPsL
   977 // Sets the best IAP from all snaps
   963 // Sets the best IAP from all snaps
   978 // ---------------------------------------------------------------------------
   964 // ---------------------------------------------------------------------------
   979 //
   965 //
   980 uint IAUpdateEngine::GetBestIAPInAllSNAPsL( RCmManagerExt& aCmManagerExt  )
   966 uint IAUpdateEngine::GetBestIAPInAllSNAPsL(RCmManager& aCmManager)
   981     { 
   967     {
   982     //go with internet SNAP first.
   968     //go with internet SNAP first.
   983     uint IAPID = 0;
   969     uint IAPID = 0;
   984     IAPID = GetBestIAPInInternetSNAPL( aCmManagerExt );
   970     IAPID = GetBestIAPInInternetSNAPL(aCmManager);
   985     
   971 
   986     if ( IAPID )
   972     if (IAPID)
   987         {
   973         {
   988         return IAPID;
   974         return IAPID;
   989         }
   975         }
   990     
   976 
   991     //select IAP from rest of the SNAPs
   977     //select IAP from rest of the SNAPs
   992     iDestIdArray.Reset();
   978     iDestIdArray.Reset();
   993     aCmManagerExt.AllDestinationsL( iDestIdArray );
   979     aCmManager.AllDestinationsL(iDestIdArray);
   994     
   980 
   995     for ( int i = 0; i< iDestIdArray.Count(); i++ )
   981     for (int i = 0; i < iDestIdArray.Count(); i++)
   996         {
   982         {
   997         uint SNAPID = iDestIdArray[i];                   
   983         uint SNAPID = iDestIdArray[i];
   998         IAPID = GetBestIAPInThisSNAPL( aCmManagerExt, SNAPID );
   984         IAPID = GetBestIAPInThisSNAPL(aCmManager, SNAPID);
   999         if ( IAPID )
   985         if (IAPID)
  1000             {
   986             {
  1001             break;
   987             break;
  1002             }
   988             }
  1003          }
   989         }
  1004     iDestIdArray.Reset();
   990     iDestIdArray.Reset();
  1005     return IAPID;
   991     return IAPID;
  1006     }
   992     }
  1007 
   993 
  1008 
       
  1009 
       
  1010 // ---------------------------------------------------------------------------
   994 // ---------------------------------------------------------------------------
  1011 // IAUpdateEngine::GetBestIAPInInternetSNAPL
   995 // IAUpdateEngine::GetBestIAPInInternetSNAPL
  1012 // Sets the best IAP from internet snap
   996 // Sets the best IAP from internet snap
  1013 // ---------------------------------------------------------------------------
   997 // ---------------------------------------------------------------------------
  1014 //
   998 //
  1015 uint IAUpdateEngine::GetBestIAPInInternetSNAPL( RCmManagerExt& aCmManagerExt  )
   999 uint IAUpdateEngine::GetBestIAPInInternetSNAPL(RCmManager& aCmManager)
  1016     {
  1000     {
  1017     //select IAP from Internet SNAP
  1001     //select IAP from Internet SNAP
  1018     iDestIdArray.Reset();
  1002     iDestIdArray.Reset();
  1019     aCmManagerExt.AllDestinationsL( iDestIdArray );
  1003     aCmManager.AllDestinationsL(iDestIdArray);
  1020     uint InternetSNAPID = 0;
  1004     uint InternetSNAPID = 0;
  1021     for ( int i = 0; i< iDestIdArray.Count(); i++ )
  1005     for (int i = 0; i < iDestIdArray.Count(); i++)
  1022         {
  1006         {
  1023         RCmDestinationExt dest = aCmManagerExt.DestinationL( iDestIdArray[i] );
  1007         RCmDestination dest = aCmManager.DestinationL(iDestIdArray[i]);
  1024         CleanupClosePushL( dest );
  1008         CleanupClosePushL(dest);
  1025                                      
  1009 
  1026         if ( dest.MetadataL( CMManager::ESnapMetadataInternet ) )
  1010         if (dest.MetadataL(CMManager::ESnapMetadataInternet))
  1027             {
  1011             {
  1028             InternetSNAPID = iDestIdArray[i];
  1012             InternetSNAPID = iDestIdArray[i];
  1029             CleanupStack::PopAndDestroy( &dest ); 
  1013             CleanupStack::PopAndDestroy(&dest);
  1030             break;
  1014             break;
  1031             }                     
  1015             }
  1032          CleanupStack::PopAndDestroy( &dest ); 
  1016         CleanupStack::PopAndDestroy(&dest);
  1033          }
  1017         }
  1034     iDestIdArray.Reset();
  1018     iDestIdArray.Reset();
  1035     
  1019 
  1036     return GetBestIAPInThisSNAPL( aCmManagerExt, InternetSNAPID );
  1020     return GetBestIAPInThisSNAPL(aCmManager, InternetSNAPID);
  1037     }
  1021     }
  1038 
       
  1039 
       
  1040 
  1022 
  1041 // ---------------------------------------------------------------------------
  1023 // ---------------------------------------------------------------------------
  1042 // IAUpdateEngine::GetBestIAPInThisSNAPL
  1024 // IAUpdateEngine::GetBestIAPInThisSNAPL
  1043 // Sets the best IAP from the given snap
  1025 // Sets the best IAP from the given snap
  1044 // ---------------------------------------------------------------------------
  1026 // ---------------------------------------------------------------------------
  1045 //
  1027 //
  1046 uint IAUpdateEngine::GetBestIAPInThisSNAPL( RCmManagerExt& aCmManagerExt, uint aSNAPID  )
  1028 uint IAUpdateEngine::GetBestIAPInThisSNAPL(RCmManager& aCmManager,
       
  1029         uint aSNAPID)
  1047     {
  1030     {
  1048     //get all usable IAPs
  1031     //get all usable IAPs
  1049     TConnMonIapInfoBuf iapInfo;
  1032     TConnMonIapInfoBuf iapInfo;
  1050     TRequestStatus status;
  1033     TRequestStatus status;
  1051                        
  1034 
  1052     RConnectionMonitor connMon;
  1035     RConnectionMonitor connMon;
  1053     connMon.ConnectL();
  1036     connMon.ConnectL();
  1054     CleanupClosePushL( connMon );
  1037     CleanupClosePushL(connMon);
  1055     
  1038 
  1056     connMon.GetPckgAttribute( EBearerIdAll, 0, KIapAvailability,iapInfo, status );
  1039     connMon.GetPckgAttribute(EBearerIdAll, 0, KIapAvailability, iapInfo,
  1057     User::WaitForRequest( status );
  1040             status);
  1058     User::LeaveIfError( status.Int() );
  1041     User::WaitForRequest(status);
  1059     
  1042     User::LeaveIfError(status.Int());
  1060     CleanupStack::PopAndDestroy( &connMon ); 
  1043 
  1061     
  1044     CleanupStack::PopAndDestroy(&connMon);
  1062     RCmDestinationExt dest = aCmManagerExt.DestinationL( aSNAPID );
  1045 
  1063     CleanupClosePushL( dest );
  1046     RCmDestination dest = aCmManager.DestinationL(aSNAPID);
  1064     
  1047     CleanupClosePushL(dest);
       
  1048 
  1065     // Check whether the SNAP contains any IAP.
  1049     // Check whether the SNAP contains any IAP.
  1066     for  (int i = 0; i < dest.ConnectionMethodCount(); i++ )
  1050     for (int i = 0; i < dest.ConnectionMethodCount(); i++)
  1067         {
  1051         {
  1068         RCmConnectionMethodExt cm =  dest.ConnectionMethodL( i );
  1052         RCmConnectionMethod cm = dest.ConnectionMethodL(i);
  1069         CleanupClosePushL( cm );
  1053         CleanupClosePushL(cm);
  1070         
  1054 
  1071         uint iapid= cm.GetIntAttributeL( CMManager::ECmIapId );
  1055         uint iapid = cm.GetIntAttributeL(CMManager::ECmIapId);
  1072         
  1056 
  1073         for ( int i = 0; i < iapInfo().iCount; i++ )
  1057         for (int i = 0; i < iapInfo().iCount; i++)
  1074             {
  1058             {
  1075             if ( iapInfo().iIap[i].iIapId == iapid )
  1059             if (iapInfo().iIap[i].iIapId == iapid)
  1076                 {
  1060                 {
  1077                 CleanupStack::PopAndDestroy( 2 ); //cm & dest;
  1061                 CleanupStack::PopAndDestroy(2); //cm & dest;
  1078                 return iapid;
  1062                 return iapid;
  1079                 }
  1063                 }
  1080             }    
  1064             }
  1081                                                                                  
  1065 
  1082         CleanupStack::PopAndDestroy( &cm );
  1066         CleanupStack::PopAndDestroy(&cm);
  1083         }
  1067         }
  1084     
  1068 
  1085     CleanupStack::PopAndDestroy( &dest ); 
  1069     CleanupStack::PopAndDestroy(&dest);
  1086     return 0;
  1070     return 0;
  1087     }
  1071     }
  1088 
  1072 
  1089 // -----------------------------------------------------------------------------
  1073 // -----------------------------------------------------------------------------
  1090 // IAUpdateEngine::ShowUpdateQueryL
  1074 // IAUpdateEngine::ShowUpdateQueryL
  1095     {
  1079     {
  1096     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::ShowUpdateQueryL() begin");
  1080     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::ShowUpdateQueryL() begin");
  1097     CIAUpdateQueryHistory* updateQueryHistory = CIAUpdateQueryHistory::NewL();
  1081     CIAUpdateQueryHistory* updateQueryHistory = CIAUpdateQueryHistory::NewL();
  1098     // Get the delay information from the controller that has read it from
  1082     // Get the delay information from the controller that has read it from
  1099     // the config file.
  1083     // the config file.
  1100     updateQueryHistory->SetDelay( iController->ConfigData().QueryHistoryDelayHours() );
  1084     updateQueryHistory->SetDelay(
  1101     CleanupStack::PushL( updateQueryHistory );
  1085             iController->ConfigData().QueryHistoryDelayHours());
  1102     bool isDelayed( updateQueryHistory->IsDelayedL( mUpdatequeryUid ) );
  1086     CleanupStack::PushL(updateQueryHistory);
  1103     CleanupStack::PopAndDestroy( updateQueryHistory );
  1087     bool isDelayed(updateQueryHistory->IsDelayedL(mUpdatequeryUid));
  1104     if ( !isDelayed )
  1088     CleanupStack::PopAndDestroy(updateQueryHistory);
  1105         {
  1089     if (!isDelayed)
  1106         if ( ClientInBackgroundL() )
  1090         {
  1107             {
  1091         if (ClientInBackgroundL())
  1108             iEikEnv->RootWin().SetOrdinalPosition( -1, ECoeWinPriorityNormal );
  1092             {
       
  1093             iEikEnv->RootWin().SetOrdinalPosition(-1, ECoeWinPriorityNormal);
  1109             }
  1094             }
  1110         else
  1095         else
  1111             {
  1096             {
  1112             iEikEnv->RootWin().SetOrdinalPosition( 0, ECoeWinPriorityNormal );    
  1097             iEikEnv->RootWin().SetOrdinalPosition(0, ECoeWinPriorityNormal);
  1113             }
  1098             }
  1114  
  1099 
  1115         HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion); 
  1100         HbMessageBox *messageBox = new HbMessageBox(
  1116         messageBox->setText(QString("Application update is available from Nokia. Update?"));
  1101                 HbMessageBox::MessageTypeQuestion);
       
  1102         messageBox->setText(QString(
       
  1103                 "Application update is available from Nokia. Update?"));
  1117         int actionCount = messageBox->actions().count();
  1104         int actionCount = messageBox->actions().count();
  1118         for (int i=actionCount-1; i >= 0; i--)
  1105         for (int i = actionCount - 1; i >= 0; i--)
  1119         { 
  1106             {
  1120             messageBox->removeAction(messageBox->actions().at(i));
  1107             messageBox->removeAction(messageBox->actions().at(i));
  1121         }
  1108             }
  1122         mPrimaryAction = NULL;
  1109         mPrimaryAction = NULL;
  1123         mPrimaryAction = new HbAction("Now");
  1110         mPrimaryAction = new HbAction("Now");
  1124         mSecondaryAction = NULL;
  1111         mSecondaryAction = NULL;
  1125         mSecondaryAction = new HbAction("Later");
  1112         mSecondaryAction = new HbAction("Later");
  1126         messageBox->addAction(mPrimaryAction);
  1113         messageBox->addAction(mPrimaryAction);
  1130         messageBox->open(this, SLOT(dialogFinished(HbAction*)));
  1117         messageBox->open(this, SLOT(dialogFinished(HbAction*)));
  1131         mDialogState = ShowUpdateQuery;
  1118         mDialogState = ShowUpdateQuery;
  1132         }
  1119         }
  1133     else
  1120     else
  1134         {
  1121         {
  1135         InformRequestObserver( KErrNone );
  1122         InformRequestObserver(KErrNone);
  1136         }
  1123         }
  1137    
  1124 
  1138     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::ShowUpdateQueryL() end");
  1125     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::ShowUpdateQueryL() end");
  1139     }
  1126     }
  1140 
  1127 
  1141 
       
  1142 
       
  1143 // -----------------------------------------------------------------------------
  1128 // -----------------------------------------------------------------------------
  1144 // IAUpdateEngine::HideApplicationInFSWL
  1129 // IAUpdateEngine::HideApplicationInFSWL
  1145 // 
  1130 // 
  1146 // -----------------------------------------------------------------------------
  1131 // -----------------------------------------------------------------------------
  1147 //  
  1132 //  
  1148 void IAUpdateEngine::HideApplicationInFSWL( bool aHide ) const
  1133 void IAUpdateEngine::HideApplicationInFSWL(bool aHide) const
  1149     {
  1134     {
  1150     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::HideApplicationInFSW() begin");
  1135     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::HideApplicationInFSW() begin");
  1151     IAUPDATE_TRACE_1("[IAUPDATE] hide: %d", aHide );
  1136     IAUPDATE_TRACE_1("[IAUPDATE] hide: %d", aHide );
  1152     int id = iEikEnv->RootWin().Identifier();
  1137     int id = iEikEnv->RootWin().Identifier();
  1153 
  1138 
  1154     CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC( 
  1139     CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(
  1155             iEikEnv->WsSession(), id );
  1140             iEikEnv->WsSession(), id);
  1156     
  1141 
  1157     wgName->SetHidden( aHide );
  1142     wgName->SetHidden(aHide);
  1158     wgName->SetWindowGroupName( iEikEnv->RootWin() );    
  1143     wgName->SetWindowGroupName(iEikEnv->RootWin());
  1159     CleanupStack::PopAndDestroy( wgName ); 
  1144     CleanupStack::PopAndDestroy(wgName);
  1160     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::HideApplicationInFSW() end");
  1145     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::HideApplicationInFSW() end");
  1161     }
  1146     }
  1162 
  1147 
  1163 // ---------------------------------------------------------------------------
  1148 // ---------------------------------------------------------------------------
  1164 // IAUpdateEngine::UpdateQueryCallbackL
  1149 // IAUpdateEngine::UpdateQueryCallbackL
  1165 // ---------------------------------------------------------------------------
  1150 // ---------------------------------------------------------------------------
  1166 //
  1151 //
  1167 TInt IAUpdateEngine::UpdateQueryCallbackL( TAny* aPtr )
  1152 TInt IAUpdateEngine::UpdateQueryCallbackL(TAny* aPtr)
  1168     {
  1153     {
  1169     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::UpdateQueryCallbackL() begin");
  1154     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::UpdateQueryCallbackL() begin");
  1170     IAUpdateEngine* engine = static_cast<IAUpdateEngine*>( aPtr ); 
  1155     IAUpdateEngine* engine = static_cast<IAUpdateEngine*> (aPtr);
  1171     //TRAPD( err, engine->ShowUpdateQueryL() );
  1156     //TRAPD( err, engine->ShowUpdateQueryL() );
  1172     TRAP_IGNORE( engine->ShowUpdateQueryL() );
  1157     TRAP_IGNORE( engine->ShowUpdateQueryL() );
  1173     //if ( err != KErrNone )
  1158     //if ( err != KErrNone )
  1174     //    {
  1159     //    {
  1175     //    appUI->HandleLeaveErrorL( err );
  1160     //    appUI->HandleLeaveErrorL( err );
  1176     //    }
  1161     //    }
  1177     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::UpdateQueryCallbackL() end");
  1162     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::UpdateQueryCallbackL() end");
  1178     return KErrNone;
  1163     return KErrNone;
  1179     }    
  1164     }
  1180 
  1165 
  1181 // ---------------------------------------------------------------------------
  1166 // ---------------------------------------------------------------------------
  1182 // IAUpdateEngine::AutomaticCheckCallbackL
  1167 // IAUpdateEngine::AutomaticCheckCallbackL
  1183 // ---------------------------------------------------------------------------
  1168 // ---------------------------------------------------------------------------
  1184 //    
  1169 //    
  1185     
  1170 
  1186 TInt IAUpdateEngine::AutomaticCheckCallbackL( TAny* aPtr )    
  1171 TInt IAUpdateEngine::AutomaticCheckCallbackL(TAny* aPtr)
  1187     {
  1172     {
  1188     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::AutomaticCheckCallbackL() begin");
  1173     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::AutomaticCheckCallbackL() begin");
  1189     IAUpdateEngine* engine= static_cast<IAUpdateEngine*>( aPtr ); 
  1174     IAUpdateEngine* engine = static_cast<IAUpdateEngine*> (aPtr);
  1190     
  1175 
  1191     int err = KErrNone;
  1176     int err = KErrNone;
  1192     if ( !engine->iAutomaticCheck )
  1177     if (!engine->iAutomaticCheck)
  1193         {
  1178         {
  1194         TRAP( err, engine->iAutomaticCheck = CIAUpdateAutomaticCheck::NewL() ); 
  1179         TRAP( err, engine->iAutomaticCheck = CIAUpdateAutomaticCheck::NewL() );
  1195         }
  1180         }
  1196     if ( err != KErrNone )
  1181     if (err != KErrNone)
  1197         {
  1182         {
  1198         engine->HandleLeaveErrorL( err );
  1183         engine->HandleLeaveErrorL(err);
  1199         }
  1184         }
  1200     else
  1185     else
  1201         {
  1186         {
  1202         TRAP( err, engine->iAutomaticCheck->AcceptAutomaticCheckL() );
  1187         TRAP( err, engine->iAutomaticCheck->AcceptAutomaticCheckL() );
  1203         if ( err != KErrNone )
  1188         if (err != KErrNone)
  1204             {
  1189             {
  1205             engine->HandleLeaveErrorL( err );
  1190             engine->HandleLeaveErrorL(err);
  1206             }   
  1191             }
  1207         } 
  1192         }
  1208   
  1193 
  1209     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::AutomaticCheckCallbackL() end");
  1194     IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::AutomaticCheckCallbackL() end");
  1210     return KErrNone;
  1195     return KErrNone;
  1211     }
  1196     }
  1212 
  1197 
  1213 // ---------------------------------------------------------------------------
  1198 // ---------------------------------------------------------------------------
  1216 //  
  1201 //  
  1217 bool IAUpdateEngine::DoPossibleApplicationClose()
  1202 bool IAUpdateEngine::DoPossibleApplicationClose()
  1218     {
  1203     {
  1219     //exit from result view if there are no update left
  1204     //exit from result view if there are no update left
  1220     bool toBeClosed = false;
  1205     bool toBeClosed = false;
  1221     if ( iController->Nodes().Count() == 0 && iController->FwNodes().Count() == 0 )
  1206     if (iController->Nodes().Count() == 0 && iController->FwNodes().Count()
  1222         {
  1207             == 0)
  1223         toBeClosed = true; 
       
  1224         }
       
  1225     else if ( mStartedFromApplication && 
       
  1226         iController->ResultsInfo().iCountCancelled == 0 &&
       
  1227         iController->ResultsInfo().iCountFailed == 0 )
       
  1228         {
  1208         {
  1229         toBeClosed = true;
  1209         toBeClosed = true;
  1230         }
  1210         }
  1231     if ( toBeClosed )
  1211     else if (mStartedFromApplication
       
  1212             && iController->ResultsInfo().iCountCancelled == 0
       
  1213             && iController->ResultsInfo().iCountFailed == 0)
       
  1214         {
       
  1215         toBeClosed = true;
       
  1216         }
       
  1217     if (toBeClosed)
  1232         {
  1218         {
  1233         qApp->quit();
  1219         qApp->quit();
  1234         }
  1220         }
  1235     return toBeClosed;
  1221     return toBeClosed;
  1236     }
  1222     }
  1237             
  1223