1 /* |
1 /* |
2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2007-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". |
20 |
20 |
21 // INCLUDES |
21 // INCLUDES |
22 #include <eikenv.h> |
22 #include <eikenv.h> |
23 #include <iaupdateobserver.h> |
23 #include <iaupdateobserver.h> |
24 #include <iaupdateresult.h> |
24 #include <iaupdateresult.h> |
|
25 #include <iaupdateparameters.h> |
25 |
26 |
26 #include "iaupdatemanager.h" |
27 #include "iaupdatemanager.h" |
27 #include "iaupdateclient.h" |
28 #include "iaupdateclient.h" |
28 #include "iaupdatedebug.h" |
29 #include "iaupdatedebug.h" |
29 |
30 |
93 // ----------------------------------------------------------------------------- |
94 // ----------------------------------------------------------------------------- |
94 // |
95 // |
95 CIAUpdateManager::~CIAUpdateManager() |
96 CIAUpdateManager::~CIAUpdateManager() |
96 { |
97 { |
97 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::~CIAUpdateManager() begin"); |
98 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::~CIAUpdateManager() begin"); |
|
99 delete iUpdateParameters; |
|
100 iUpdateParameters = NULL; |
98 // If an operation is still active, |
101 // If an operation is still active, |
99 // then DoCancel will cancel ongoing request |
102 // then DoCancel will cancel ongoing request |
100 Cancel(); |
103 Cancel(); |
101 UpdateClient().Close(); |
104 UpdateClient().Close(); |
102 if ( iEikEnv ) |
105 if ( iEikEnv ) |
128 } |
131 } |
129 |
132 |
130 // Reset result values because we are starting a new operation. |
133 // Reset result values because we are starting a new operation. |
131 ResetResults(); |
134 ResetResults(); |
132 |
135 |
133 // Set the update type. |
136 // |
134 // So, we know later in RunL what operation was requested. |
137 delete iUpdateParameters; |
135 SetUpdateType( EIAUpdateCheck ); |
138 iUpdateParameters = NULL; |
136 |
139 TInt error = KErrNone; |
137 TInt error( UpdateClient().Open( ETrue) ); |
140 TRAP(error,CopyUpdateParamsL( aUpdateParameters ) ); |
138 if ( error == KErrNone ) |
141 if ( error == KErrNone ) |
139 { |
142 { |
140 error = |
143 // Set the update type. |
141 UpdateClient().CheckUpdates( aUpdateParameters, |
144 // So, we know later in RunL what operation was requested. |
142 iSuccessCount, |
145 SetUpdateType( EIAUpdateStartServer ); |
143 iStatus ); |
146 error = UpdateClient().OpenToBackroundAsync( iStatus); |
144 } |
147 } |
145 |
148 |
146 if ( error == KErrNone ) |
149 if ( error == KErrNone ) |
147 { |
150 { |
148 // Set this object active. |
151 // Set this object active. |
149 // Because everything went ok, |
152 // Because everything went ok, |
150 // the operation will be handled asynchronously |
153 // the operation will be handled asynchronously |
197 |
200 |
198 // Set the update type. |
201 // Set the update type. |
199 // So, we know later in RunL what operation was requested. |
202 // So, we know later in RunL what operation was requested. |
200 SetUpdateType( EIAUpdateUpdate ); |
203 SetUpdateType( EIAUpdateUpdate ); |
201 |
204 |
202 TInt error( UpdateClient().Open( EFalse ) ); |
205 TInt error( UpdateClient().Open() ); |
203 if ( error == KErrNone ) |
206 if ( error == KErrNone ) |
204 { |
207 { |
205 error = |
208 error = |
206 UpdateClient().ShowUpdates( aUpdateParameters, |
209 UpdateClient().ShowUpdates( aUpdateParameters, |
207 iSuccessCount, |
210 iSuccessCount, |
278 |
281 |
279 // Set the update type. |
282 // Set the update type. |
280 // So, we know later in RunL what operation was requested. |
283 // So, we know later in RunL what operation was requested. |
281 SetUpdateType( EIAUpdateQuery ); |
284 SetUpdateType( EIAUpdateQuery ); |
282 |
285 |
283 TInt error( UpdateClient().Open( EFalse ) ); |
286 TInt error( UpdateClient().Open() ); |
284 if ( error == KErrNone ) |
287 if ( error == KErrNone ) |
285 { |
288 { |
286 error = |
289 error = |
287 UpdateClient().UpdateQuery( iUpdateNow, iStatus ); |
290 UpdateClient().UpdateQuery( iUpdateNow, iStatus ); |
288 } |
291 } |
381 |
384 |
382 // Use the update type of the ongoing operation to check what callback |
385 // Use the update type of the ongoing operation to check what callback |
383 // function to call. |
386 // function to call. |
384 switch ( updateType ) |
387 switch ( updateType ) |
385 { |
388 { |
|
389 case EIAUpdateStartServer: |
|
390 if ( errorCode == KErrNone ) |
|
391 { |
|
392 CheckUpdatesContinue(); |
|
393 } |
|
394 else |
|
395 { |
|
396 UpdateClient().Close(); |
|
397 Observer().CheckUpdatesComplete( errorCode, 0); |
|
398 } |
|
399 break; |
|
400 |
386 case EIAUpdateCheck: |
401 case EIAUpdateCheck: |
387 if ( iSuccessCount == 0 ) |
402 if ( iSuccessCount == 0 ) |
388 { |
403 { |
389 // Let's assume that connection is not needed anymore |
404 // Let's assume that connection is not needed anymore |
390 UpdateClient().Close(); |
405 UpdateClient().Close(); |
520 // |
535 // |
521 void CIAUpdateManager::HandleLosingForeground() |
536 void CIAUpdateManager::HandleLosingForeground() |
522 { |
537 { |
523 } |
538 } |
524 |
539 |
525 |
540 // ----------------------------------------------------------------------------- |
526 |
541 // CIAUpdateManager::CheckUpdatesContinue |
527 |
542 // |
528 |
543 // ----------------------------------------------------------------------------- |
529 |
544 // |
|
545 void CIAUpdateManager::CheckUpdatesContinue() |
|
546 { |
|
547 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::CheckUpdatesContinue() begin"); |
|
548 TInt error = KErrNone; |
|
549 SetUpdateType( EIAUpdateCheck ); |
|
550 error = UpdateClient().ConnectToApp(); |
|
551 if ( error == KErrNone ) |
|
552 { |
|
553 error = UpdateClient().CheckUpdates( *iUpdateParameters, |
|
554 iSuccessCount, |
|
555 iStatus ); |
|
556 } |
|
557 |
|
558 if ( error == KErrNone ) |
|
559 { |
|
560 // Set this object active. |
|
561 // Because everything went ok, |
|
562 // the operation will be handled asynchronously |
|
563 // and the service provider will inform us when the operation |
|
564 // is finished. |
|
565 SetActive(); |
|
566 } |
|
567 else |
|
568 { |
|
569 // Because we are going to activate this active object, |
|
570 // set the status pending. |
|
571 iStatus = KRequestPending; |
|
572 |
|
573 // An error occurred above. |
|
574 // Therefore, the operation did not proceed any further. |
|
575 // Set this object active for asynchronous error handling. |
|
576 SetActive(); |
|
577 |
|
578 // Now, that everything is ready, just inform the active scheduler |
|
579 // that operation is finished. Pass the error code for the observer. |
|
580 TRequestStatus* status( &iStatus ); |
|
581 User::RequestComplete( status, error ); |
|
582 } |
|
583 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::CheckUpdatesContinue() end"); |
|
584 } |
|
585 |
|
586 // ----------------------------------------------------------------------------- |
|
587 // CIAUpdateManager::CopyUpdateParamsL |
|
588 // |
|
589 // ----------------------------------------------------------------------------- |
|
590 // |
|
591 void CIAUpdateManager::CopyUpdateParamsL( const CIAUpdateParameters& aUpdateParameters ) |
|
592 { |
|
593 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::CopyUpdateParamsL() begin"); |
|
594 iUpdateParameters = CIAUpdateParameters::NewL(); |
|
595 iUpdateParameters->SetCommandLineArgumentsL( aUpdateParameters.CommandLineArguments() ); |
|
596 iUpdateParameters->SetCommandLineExecutableL( aUpdateParameters.CommandLineExecutable() ); |
|
597 iUpdateParameters->SetImportance( aUpdateParameters.Importance() ); |
|
598 iUpdateParameters->SetRefresh( aUpdateParameters.Refresh() ); |
|
599 iUpdateParameters->SetSearchCriteriaL( aUpdateParameters.SearchCriteria() ); |
|
600 iUpdateParameters->SetShowProgress( aUpdateParameters.ShowProgress() ); |
|
601 iUpdateParameters->SetType( aUpdateParameters.Type() ); |
|
602 iUpdateParameters->SetUid( aUpdateParameters.Uid() ); |
|
603 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::CopyUpdateParamsL() end"); |
|
604 } |
|
605 |
|
606 |
|
607 |