iaupdate/IAD/ui/src/iaupdateserviceprovider.cpp
changeset 29 26b6f0522fd8
child 33 8110bf1194d1
equal deleted inserted replaced
25:98b66e4fb0be 29:26b6f0522fd8
       
     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 
       
    27 
       
    28 IAUpdateServiceProvider::IAUpdateServiceProvider(IAUpdateEngine& engine)
       
    29 : XQServiceProvider( QString("com.nokia.services.swupdate.swupdate_interface")),
       
    30   mEngine(&engine),
       
    31   mCurrentRequest(NoOperation)
       
    32     
       
    33 {
       
    34     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::IAUpdateServiceProvider() begin");
       
    35     publishAll();
       
    36     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::IAUpdateServiceProvider() end");
       
    37 }
       
    38 
       
    39 IAUpdateServiceProvider::~IAUpdateServiceProvider()
       
    40 {
       
    41     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::~IAUpdateServiceProvider()");
       
    42 }
       
    43 
       
    44 void IAUpdateServiceProvider::startedByLauncher(bool refreshFromNetworkDenied)
       
    45 {
       
    46     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::startedByLauncher() begin");
       
    47     mAsyncReqId = setCurrentRequestAsync();
       
    48     mEngine->StartedByLauncherL(refreshFromNetworkDenied);
       
    49     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::startedByLauncher() end");
       
    50 }
       
    51 
       
    52 void IAUpdateServiceProvider::checkUpdates(QString stringWgId, 
       
    53                                            QString stringUid,  
       
    54                                            QString searchCriteria, 
       
    55                                            QString commandLineExecutable,
       
    56                                            QString commandLineArguments,
       
    57                                            QString stringShowProgress,
       
    58                                            QString stringImportance,
       
    59                                            QString stringType,
       
    60                                            QString stringRefresh)
       
    61 {
       
    62     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::checkUpdates() begin");
       
    63     mAsyncReqId = setCurrentRequestAsync();
       
    64     mCurrentRequest = CheckUpdates;
       
    65     CIAUpdateParameters* params = NULL;
       
    66     TRAP_IGNORE(params = CIAUpdateParameters::NewL());
       
    67     if (params)
       
    68     {
       
    69         SetParams(*params, 
       
    70                   stringUid,
       
    71                   searchCriteria,
       
    72                   commandLineExecutable,
       
    73                   commandLineArguments,
       
    74                   stringShowProgress,
       
    75                   stringImportance,
       
    76                   stringType,
       
    77                   stringRefresh);
       
    78   
       
    79         if ( requestInfo().clientSecureId() != KSIDBackgroundChecker )      
       
    80         {
       
    81             // other processes than backroundchecker are not allowed to cause refresh from network 
       
    82             params->SetRefresh( EFalse );
       
    83         }
       
    84     mEngine->CheckUpdatesRequestL(stringWgId.toInt(),params);
       
    85     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::checkUpdates() end");
       
    86     }
       
    87     
       
    88 }
       
    89 
       
    90 void IAUpdateServiceProvider::showUpdates(QString stringWgId, 
       
    91                                           QString stringUid,  
       
    92                                           QString searchCriteria, 
       
    93                                           QString commandLineExecutable,
       
    94                                           QString commandLineArguments,
       
    95                                           QString stringShowProgress,
       
    96                                           QString stringImportance,
       
    97                                           QString stringType,
       
    98                                           QString stringRefresh)
       
    99 {
       
   100     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::showUpdates() begin");
       
   101     mAsyncReqId = setCurrentRequestAsync();
       
   102     mCurrentRequest = ShowUpdates;
       
   103     CIAUpdateParameters* params = NULL;
       
   104     TRAP_IGNORE(params = CIAUpdateParameters::NewL());
       
   105     if (params)
       
   106     {
       
   107         SetParams(*params, 
       
   108                   stringUid,
       
   109                   searchCriteria,
       
   110                   commandLineExecutable,
       
   111                   commandLineArguments,
       
   112                   stringShowProgress,
       
   113                   stringImportance,
       
   114                   stringType,
       
   115                   stringRefresh);
       
   116     } 
       
   117     mEngine->ShowUpdatesRequestL(stringWgId.toInt(),params);
       
   118     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::showUpdates() end");
       
   119 }
       
   120 
       
   121 
       
   122 
       
   123 void IAUpdateServiceProvider::updateQuery(QString stringWgId)
       
   124 {
       
   125     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::updateQuery() begin");
       
   126     mAsyncReqId = setCurrentRequestAsync();
       
   127     mCurrentRequest = UpdateQuery;
       
   128     mEngine->ShowUpdateQueryRequestL( stringWgId.toInt(), requestInfo().clientSecureId() );        
       
   129     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::updateQuery() end");
       
   130 }
       
   131 
       
   132 
       
   133 
       
   134 void IAUpdateServiceProvider::completeLauncherLaunch(int error)
       
   135 {
       
   136     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::completeLauncherLaunch() begin");
       
   137     completeRequest(mAsyncReqId, QVariant(error));    
       
   138     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::completeLauncherLaunch() end");
       
   139 }
       
   140 
       
   141 void IAUpdateServiceProvider::completeCheckUpdates(int countOfAvailableUpdates, int error)
       
   142 {
       
   143     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::completeCheckUpdates() begin");
       
   144     QList<QVariant> resultList;
       
   145     resultList.append(QVariant(error));
       
   146     resultList.append(QVariant(countOfAvailableUpdates));
       
   147     completeRequest(mAsyncReqId, QVariant(resultList));
       
   148     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::completeCheckUpdates() end");
       
   149 }
       
   150 
       
   151 void IAUpdateServiceProvider::completeShowUpdates(const CIAUpdateResult* updateResult, int error)
       
   152 {
       
   153     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::completeShowUpdates() begin");
       
   154     QList<QVariant> resultList;
       
   155     resultList.append(QVariant(error));
       
   156     if (updateResult)
       
   157     {    
       
   158         resultList.append(QVariant(updateResult->SuccessCount()));
       
   159         resultList.append(QVariant(updateResult->FailCount()));
       
   160         resultList.append(QVariant(updateResult->CancelCount()));
       
   161         delete updateResult;
       
   162     }    
       
   163     else
       
   164     {
       
   165         resultList.append(QVariant(0));
       
   166         resultList.append(QVariant(0));
       
   167         resultList.append(QVariant(0));
       
   168     }
       
   169     completeRequest(mAsyncReqId, QVariant(resultList));
       
   170     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::completeShowUpdates() end");
       
   171 }
       
   172 
       
   173 void IAUpdateServiceProvider::completeUpdateQuery(bool updateNow, int error)
       
   174 {
       
   175     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::completeUpdateQuery() begin");
       
   176     QList<QVariant> resultList;
       
   177     resultList.append(QVariant(error));
       
   178     resultList.append(QVariant(updateNow));
       
   179     completeRequest(mAsyncReqId, QVariant(resultList));
       
   180     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::completeUpdateQuery() end");
       
   181 }
       
   182 
       
   183 
       
   184 void IAUpdateServiceProvider::SetParams(CIAUpdateParameters& params,
       
   185                                         QString& stringUid,  
       
   186                                         QString& searchCriteria, 
       
   187                                         QString& commandLineExecutable,
       
   188                                         QString& commandLineArguments,
       
   189                                         QString& stringShowProgress,
       
   190                                         QString& stringImportance,
       
   191                                         QString& stringType,
       
   192                                         QString& stringRefresh) const
       
   193 {
       
   194     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::SetParams() begin");
       
   195     params.SetUid(TUid::Uid(stringUid.toInt()));
       
   196     TPtrC ptr(reinterpret_cast<const TText*>(searchCriteria.constData()));
       
   197     params.SetSearchCriteriaL(ptr);
       
   198     ptr.Set(reinterpret_cast<const TText*>(commandLineExecutable.constData()));
       
   199     params.SetCommandLineExecutableL(ptr);
       
   200     ptr.Set(reinterpret_cast<const TText*>(commandLineArguments.constData()));
       
   201     HBufC8* arguments8 = HBufC8::NewL(ptr.Length());
       
   202     TPtr8 ptr8(arguments8->Des());
       
   203     ptr8.Copy(ptr);
       
   204     params.SetCommandLineArgumentsL(ptr8);
       
   205     params.SetShowProgress(stringShowProgress.toInt());
       
   206     params.SetImportance(stringImportance.toUInt());
       
   207     params.SetType(stringType.toUInt());
       
   208     params.SetRefresh(stringRefresh.toInt());
       
   209     IAUPDATE_TRACE("[IAUPDATE] IAUpdateServiceProvider::SetParams() end");
       
   210 }
       
   211 
       
   212