|
1 /* |
|
2 * Copyright (c) 2008-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: Upload cenrep watcher |
|
15 * |
|
16 */ |
|
17 |
|
18 // CLASS HEADER |
|
19 #include <centralrepository.h> // for checking the ShareOnline version |
|
20 #include "glxcommandhandlerupload.h" |
|
21 #include "glxuploadcenrepwatcher.h" |
|
22 |
|
23 #include <glxtracer.h> // for TRACER logs |
|
24 |
|
25 |
|
26 // ----------------------------------------------------------------------------- |
|
27 // Two-phased constructor. |
|
28 // ----------------------------------------------------------------------------- |
|
29 CGlxUploadCenRepWatcher* CGlxUploadCenRepWatcher::NewL |
|
30 (MGlxUploadIconObserver& aUploadIconObserver, |
|
31 const TUid& aRepositoryUid, |
|
32 TUint32 aId ) |
|
33 { |
|
34 TRACER("CGlxUploadCenRepWatcher::NewL"); |
|
35 |
|
36 CGlxUploadCenRepWatcher* self = |
|
37 new(ELeave) CGlxUploadCenRepWatcher(aUploadIconObserver, aRepositoryUid, aId ); |
|
38 CleanupStack::PushL( self ); |
|
39 self->ConstructL(); |
|
40 CleanupStack::Pop( self ); |
|
41 return self; |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // constructor. |
|
46 // ----------------------------------------------------------------------------- |
|
47 inline CGlxUploadCenRepWatcher::CGlxUploadCenRepWatcher( |
|
48 MGlxUploadIconObserver& aUploadIconObserver, |
|
49 const TUid& aRepositoryUid, TUint32 aId ) |
|
50 : CActive(EPriorityStandard), |
|
51 iUploadIconObserver(aUploadIconObserver), |
|
52 iRepositoryUid(aRepositoryUid), |
|
53 iId(aId) |
|
54 { |
|
55 } |
|
56 |
|
57 // ---------------------------------------------------------------------------- |
|
58 // Symbian 2nd phase constructor |
|
59 // ---------------------------------------------------------------------------- |
|
60 void CGlxUploadCenRepWatcher::ConstructL() |
|
61 { |
|
62 TRACER("CGlxUploadCenRepWatcher::ConstructL"); |
|
63 CActiveScheduler::Add( this ); |
|
64 iRepository = CRepository::NewL(iRepositoryUid); |
|
65 |
|
66 //Request notification when the user changes cenrep values |
|
67 TInt err = iRepository->NotifyRequest( iId, iStatus ); |
|
68 if (!(KErrNone ==err ||KErrAlreadyExists ==err)) |
|
69 { |
|
70 User::Leave(err); |
|
71 } |
|
72 |
|
73 SetActive(); |
|
74 } |
|
75 |
|
76 // ---------------------------------------------------------------------------- |
|
77 // Destructor |
|
78 // ---------------------------------------------------------------------------- |
|
79 CGlxUploadCenRepWatcher::~CGlxUploadCenRepWatcher() |
|
80 { |
|
81 TRACER("CGlxUploadCenRepWatcher::~CGlxUploadCenRepWatcher"); |
|
82 |
|
83 Cancel(); |
|
84 delete iRepository; |
|
85 } |
|
86 |
|
87 |
|
88 // ---------------------------------------------------------------------------- |
|
89 // CGlxUploadCenRepWatcher::KeyValueL |
|
90 // ---------------------------------------------------------------------------- |
|
91 void CGlxUploadCenRepWatcher::KeyValueL(TDes& aKeyValue) const |
|
92 { |
|
93 TRACER("CGlxUploadCenRepWatcher::KeyValueL"); |
|
94 if(iRepository) |
|
95 { |
|
96 User::LeaveIfError( iRepository->Get(iId, aKeyValue) ); |
|
97 } |
|
98 } |
|
99 |
|
100 |
|
101 // ---------------------------------------------------------------------------- |
|
102 // CGlxUploadCenRepWatcher::RunL |
|
103 // ---------------------------------------------------------------------------- |
|
104 void CGlxUploadCenRepWatcher::RunL() |
|
105 { |
|
106 TRACER("CGlxUploadCenRepWatcher::RunL"); |
|
107 // Check for errors |
|
108 User::LeaveIfError( iStatus.Int() ); |
|
109 User::LeaveIfError( iRepository->NotifyRequest( iId, iStatus ) ); |
|
110 if (!IsActive()) |
|
111 { |
|
112 SetActive(); |
|
113 iUploadIconObserver.HandleUploadIconChangedL( ); |
|
114 } |
|
115 } |
|
116 |
|
117 // ---------------------------------------------------------------------------- |
|
118 // CGlxUploadCenRepWatcher::DoCancel |
|
119 // ---------------------------------------------------------------------------- |
|
120 void CGlxUploadCenRepWatcher::DoCancel() |
|
121 { |
|
122 TRACER("CGlxUploadCenRepWatcher::DoCancel"); |
|
123 iRepository->NotifyCancel( iId ); |
|
124 } |
|
125 |
|
126 //----------------------------------------------------------------------------- |
|
127 // CGlxUploadCenRepWatcher::RunError |
|
128 // From class CActive. |
|
129 //----------------------------------------------------------------------------- |
|
130 // |
|
131 TInt CGlxUploadCenRepWatcher::RunError( TInt /*aError*/ ) |
|
132 { |
|
133 TRACER("CGlxUploadCenRepWatcher::RunError()"); |
|
134 return KErrNone; |
|
135 } |
|
136 |
|
137 // End of file |
|
138 |