|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: cbsbrandobserver.cpp |
|
15 * |
|
16 */ |
|
17 // INCLUDE FILES |
|
18 |
|
19 #include "cbsbrandobserver.h" |
|
20 #include <mbsbrandchangeobserver.h> |
|
21 #include <mbsbackuprestorestateobserver.h> |
|
22 #include "mbsbrandobserverregistrar.h" |
|
23 |
|
24 CBSBrandObserver* CBSBrandObserver::NewL( MBSBrandChangeObserver* aObserver, |
|
25 MBSBackupRestoreStateObserver* aBackupObserver, |
|
26 MBSBrandObserverRegistrar* aRegistrar ) |
|
27 { |
|
28 CBSBrandObserver* self = new ( ELeave ) CBSBrandObserver( aObserver, aBackupObserver, aRegistrar ) ; |
|
29 CleanupStack::PushL( self ); |
|
30 self->ConstructL(); |
|
31 CleanupStack::Pop( self ); //self |
|
32 return self; |
|
33 } |
|
34 |
|
35 |
|
36 void CBSBrandObserver::ConstructL() |
|
37 { |
|
38 iContinueBackupStateObserving = ETrue ; |
|
39 iContinueDataUpdateObserving = ETrue ; |
|
40 |
|
41 CActiveScheduler::Add( this ); |
|
42 iRegistrar->RegisterObserverToServerL( iStatus ); |
|
43 SetActive(); |
|
44 } |
|
45 |
|
46 |
|
47 CBSBrandObserver::~CBSBrandObserver() |
|
48 { |
|
49 Cancel(); |
|
50 } |
|
51 |
|
52 |
|
53 CBSBrandObserver::CBSBrandObserver( MBSBrandChangeObserver* aObserver, |
|
54 MBSBackupRestoreStateObserver* aBackupObserver, |
|
55 MBSBrandObserverRegistrar* aRegistrar ) |
|
56 : CActive( CActive::EPriorityIdle ), iObserver( aObserver ), iBackupObserver( aBackupObserver ), |
|
57 iRegistrar( aRegistrar ) |
|
58 { |
|
59 } |
|
60 |
|
61 void CBSBrandObserver::RunL() |
|
62 { |
|
63 |
|
64 // Pankaj - chk for what has changed.. |
|
65 TInt isBackupRestore = iRegistrar->GetBackupRestoreL() ; |
|
66 if(isBackupRestore) |
|
67 { |
|
68 // if client donot want to listen backup state event any more donot call its observer.. |
|
69 if(iBackupObserver && iContinueBackupStateObserving) |
|
70 { |
|
71 TInt activeState = iRegistrar->GetBackupStateL() ; |
|
72 iContinueBackupStateObserving = iBackupObserver->BackupRestoreActivated(activeState) ; |
|
73 } |
|
74 } |
|
75 else |
|
76 { |
|
77 // if client donot want to listen update data event any more donot call its observer.. |
|
78 if(iObserver && iContinueDataUpdateObserving) |
|
79 { |
|
80 TInt newVersion = iRegistrar->GetNewVersionL(); |
|
81 iContinueDataUpdateObserving = iObserver->BrandUpdateAvailable( newVersion ) ; |
|
82 } |
|
83 } |
|
84 |
|
85 if(iContinueBackupStateObserving || iContinueDataUpdateObserving) |
|
86 { |
|
87 iRegistrar->RegisterObserverToServerL( iStatus ); |
|
88 SetActive(); |
|
89 } |
|
90 } |
|
91 |
|
92 void CBSBrandObserver::DoCancel() |
|
93 { |
|
94 |
|
95 } |
|
96 |
|
97 |
|
98 // END OF FILE |