iaupdate/IAD/ui/src/iaupdateserviceprovider.cpp
branchRCL_3
changeset 25 7333d7932ef7
equal deleted inserted replaced
24:5cc91383ab1e 25:7333d7932ef7
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   This module contains the implementation of IAUpdateServiceProvider class 
       
    15 *                member functions.
       
    16 *
       
    17 */
       
    18 
       
    19 #include <iaupdateparameters.h>
       
    20 #include <iaupdateresult.h>
       
    21 #include "iaupdateserviceprovider.h"
       
    22 #include "iaupdateengine.h"
       
    23 #include "iaupdatedebug.h"
       
    24 
       
    25 const TSecureId KSIDBackgroundChecker = 0x200211f4;
       
    26 const TSecureId KSIDCwrtWidget = 0x200267C0;
       
    27 
       
    28 
       
    29 IAUpdateServiceProvider::IAUpdateServiceProvider(IAUpdateEngine& engine)
       
    30 : XQServiceProvider( QString("com.nokia.services.swupdate.swupdate_interface")),
       
    31   mEngine(&engine),
       
    32   mCurrentRequest(NoOperation)
       
    33     
       
    34 {
       
    35     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::IAUpdateServiceProvider() begin");
       
    36     publishAll();
       
    37     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::IAUpdateServiceProvider() end");
       
    38 }
       
    39 
       
    40 IAUpdateServiceProvider::~IAUpdateServiceProvider()
       
    41 {
       
    42     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::~IAUpdateServiceProvider()");
       
    43 }
       
    44 
       
    45 void IAUpdateServiceProvider::startedByLauncher(QString refreshFromNetworkDenied)
       
    46 {
       
    47     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::startedByLauncher() begin");
       
    48     mAsyncReqId = setCurrentRequestAsync();
       
    49     mEngine->StartedByLauncherL(refreshFromNetworkDenied.toInt());
       
    50     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::startedByLauncher() end");
       
    51 }
       
    52 
       
    53 void IAUpdateServiceProvider::checkUpdates(QString stringWgId, 
       
    54                                            QString stringUid,  
       
    55                                            QString searchCriteria, 
       
    56                                            QString commandLineExecutable,
       
    57                                            QString commandLineArguments,
       
    58                                            QString stringShowProgress,
       
    59                                            QString stringImportance,
       
    60                                            QString stringType,
       
    61                                            QString stringRefresh)
       
    62 {
       
    63     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::checkUpdates() begin");
       
    64     mAsyncReqId = setCurrentRequestAsync();
       
    65     mCurrentRequest = CheckUpdates;
       
    66     CIAUpdateParameters* params = NULL;
       
    67     TRAP_IGNORE(params = CIAUpdateParameters::NewL());
       
    68     if (params)
       
    69     {
       
    70         SetParams(*params, 
       
    71                   stringUid,
       
    72                   searchCriteria,
       
    73                   commandLineExecutable,
       
    74                   commandLineArguments,
       
    75                   stringShowProgress,
       
    76                   stringImportance,
       
    77                   stringType,
       
    78                   stringRefresh);
       
    79   
       
    80         if ((requestInfo().clientSecureId() != KSIDBackgroundChecker) && (requestInfo().clientSecureId() != KSIDCwrtWidget))      
       
    81         {
       
    82             // other processes than backroundchecker are not allowed to cause refresh from network 
       
    83             params->SetRefresh( EFalse );
       
    84         }
       
    85     mEngine->CheckUpdatesRequestL(stringWgId.toInt(),params, params->Refresh() && requestInfo().clientSecureId() == KSIDCwrtWidget);
       
    86     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::checkUpdates() end");
       
    87     }
       
    88     
       
    89 }
       
    90 
       
    91 void IAUpdateServiceProvider::showUpdates(QString stringWgId, 
       
    92                                           QString stringUid,  
       
    93                                           QString searchCriteria, 
       
    94                                           QString commandLineExecutable,
       
    95                                           QString commandLineArguments,
       
    96                                           QString stringShowProgress,
       
    97                                           QString stringImportance,
       
    98                                           QString stringType,
       
    99                                           QString stringRefresh)
       
   100 {
       
   101     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::showUpdates() begin");
       
   102     mAsyncReqId = setCurrentRequestAsync();
       
   103     mCurrentRequest = ShowUpdates;
       
   104     CIAUpdateParameters* params = NULL;
       
   105     TRAP_IGNORE(params = CIAUpdateParameters::NewL());
       
   106     if (params)
       
   107     {
       
   108         SetParams(*params, 
       
   109                   stringUid,
       
   110                   searchCriteria,
       
   111                   commandLineExecutable,
       
   112                   commandLineArguments,
       
   113                   stringShowProgress,
       
   114                   stringImportance,
       
   115                   stringType,
       
   116                   stringRefresh);
       
   117     } 
       
   118     mEngine->ShowUpdatesRequestL(stringWgId.toInt(),params);
       
   119     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::showUpdates() end");
       
   120 }
       
   121 
       
   122 
       
   123 
       
   124 void IAUpdateServiceProvider::updateQuery(QString stringWgId)
       
   125 {
       
   126     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::updateQuery() begin");
       
   127     mAsyncReqId = setCurrentRequestAsync();
       
   128     mCurrentRequest = UpdateQuery;
       
   129     mEngine->ShowUpdateQueryRequestL( stringWgId.toInt(), requestInfo().clientSecureId() );        
       
   130     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::updateQuery() end");
       
   131 }
       
   132 
       
   133 
       
   134 
       
   135 void IAUpdateServiceProvider::completeLauncherLaunch(int error)
       
   136 {
       
   137     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::completeLauncherLaunch() begin");
       
   138     completeRequest(mAsyncReqId, QVariant(error));    
       
   139     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::completeLauncherLaunch() end");
       
   140 }
       
   141 
       
   142 void IAUpdateServiceProvider::completeCheckUpdates(int countOfAvailableUpdates, int error)
       
   143 {
       
   144     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::completeCheckUpdates() begin");
       
   145     QList<QVariant> resultList;
       
   146     resultList.append(QVariant(error));
       
   147     resultList.append(QVariant(countOfAvailableUpdates));
       
   148     completeRequest(mAsyncReqId, QVariant(resultList));
       
   149     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::completeCheckUpdates() end");
       
   150 }
       
   151 
       
   152 void IAUpdateServiceProvider::completeShowUpdates(const CIAUpdateResult* updateResult, int error)
       
   153 {
       
   154     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::completeShowUpdates() begin");
       
   155     QList<QVariant> resultList;
       
   156     resultList.append(QVariant(error));
       
   157     if (updateResult)
       
   158     {    
       
   159         resultList.append(QVariant(updateResult->SuccessCount()));
       
   160         resultList.append(QVariant(updateResult->FailCount()));
       
   161         resultList.append(QVariant(updateResult->CancelCount()));
       
   162         delete updateResult;
       
   163     }    
       
   164     else
       
   165     {
       
   166         resultList.append(QVariant(0));
       
   167         resultList.append(QVariant(0));
       
   168         resultList.append(QVariant(0));
       
   169     }
       
   170     completeRequest(mAsyncReqId, QVariant(resultList));
       
   171     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::completeShowUpdates() end");
       
   172 }
       
   173 
       
   174 void IAUpdateServiceProvider::completeUpdateQuery(bool updateNow, int error)
       
   175 {
       
   176     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::completeUpdateQuery() begin");
       
   177     QList<QVariant> resultList;
       
   178     resultList.append(QVariant(error));
       
   179     resultList.append(QVariant(updateNow));
       
   180     completeRequest(mAsyncReqId, QVariant(resultList));
       
   181     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::completeUpdateQuery() end");
       
   182 }
       
   183 
       
   184 
       
   185 void IAUpdateServiceProvider::SetParams(CIAUpdateParameters& params,
       
   186                                         QString& stringUid,  
       
   187                                         QString& searchCriteria, 
       
   188                                         QString& commandLineExecutable,
       
   189                                         QString& commandLineArguments,
       
   190                                         QString& stringShowProgress,
       
   191                                         QString& stringImportance,
       
   192                                         QString& stringType,
       
   193                                         QString& stringRefresh) const
       
   194 {
       
   195     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::SetParams() begin");
       
   196     params.SetUid(TUid::Uid(stringUid.toInt()));
       
   197     TPtrC ptr(reinterpret_cast<const TText*>(searchCriteria.constData()));
       
   198     params.SetSearchCriteriaL(ptr);
       
   199     ptr.Set(reinterpret_cast<const TText*>(commandLineExecutable.constData()));
       
   200     params.SetCommandLineExecutableL(ptr);
       
   201     ptr.Set(reinterpret_cast<const TText*>(commandLineArguments.constData()));
       
   202     HBufC8* arguments8 = HBufC8::NewL(ptr.Length());
       
   203     TPtr8 ptr8(arguments8->Des());
       
   204     ptr8.Copy(ptr);
       
   205     params.SetCommandLineArgumentsL(ptr8);
       
   206     params.SetShowProgress(stringShowProgress.toInt());
       
   207     params.SetImportance(stringImportance.toUInt());
       
   208     params.SetType(stringType.toUInt());
       
   209     params.SetRefresh(stringRefresh.toInt());
       
   210     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::SetParams() end");
       
   211 }
       
   212 
       
   213