|
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: Singleton that posts errors to the framework |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "glxerrorposter.h" |
|
21 |
|
22 #include <glxsingletonstore.h> |
|
23 |
|
24 #include <glxlog.h> |
|
25 |
|
26 // --------------------------------------------------------------------------- |
|
27 // Provides instance of error poster and increments ref count |
|
28 // --------------------------------------------------------------------------- |
|
29 // |
|
30 EXPORT_C CGlxErrorPoster* CGlxErrorPoster::InstanceL() |
|
31 { |
|
32 GLX_LOG_INFO( "CGlxErrorPoster::InstanceL" ); |
|
33 |
|
34 return CGlxSingletonStore::InstanceL( &NewL ); |
|
35 } |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // Removes instance of error poster and decrements ref count |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 EXPORT_C void CGlxErrorPoster::Close() |
|
42 { |
|
43 GLX_LOG_INFO( "CGlxErrorPoster::Close" ); |
|
44 |
|
45 CGlxSingletonStore::Close( this ); |
|
46 } |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // Two phase constructor. |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 CGlxErrorPoster* CGlxErrorPoster::NewL() |
|
53 { |
|
54 GLX_LOG_INFO( "CGlxErrorPoster::NewL" ); |
|
55 |
|
56 CGlxErrorPoster* self = new ( ELeave ) CGlxErrorPoster(); |
|
57 CleanupStack::PushL( self ); |
|
58 self->ConstructL(); |
|
59 CleanupStack::Pop( self ); |
|
60 return self; |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // Constructor. |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 CGlxErrorPoster::CGlxErrorPoster() : |
|
68 CActive(EPriorityStandard) |
|
69 { |
|
70 GLX_LOG_INFO( "CGlxErrorPoster::CGlxErrorPoster" ); |
|
71 |
|
72 CActiveScheduler::Add( this ); |
|
73 } |
|
74 |
|
75 // --------------------------------------------------------------------------- |
|
76 // Destructor |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 CGlxErrorPoster::~CGlxErrorPoster() |
|
80 { |
|
81 GLX_LOG_INFO( "CGlxErrorPoster::~CGlxErrorPoster" ); |
|
82 |
|
83 Cancel(); |
|
84 } |
|
85 |
|
86 // --------------------------------------------------------------------------- |
|
87 // 2nd phase constructor. |
|
88 // --------------------------------------------------------------------------- |
|
89 // |
|
90 void CGlxErrorPoster::ConstructL() |
|
91 { |
|
92 GLX_LOG_INFO( "CGlxErrorPoster::ConstructL" ); |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // Post an error |
|
97 // --------------------------------------------------------------------------- |
|
98 // |
|
99 EXPORT_C void CGlxErrorPoster::PostError(TInt aError) |
|
100 { |
|
101 GLX_LOG_INFO1( "CGlxErrorPoster::PostError %d" , aError); |
|
102 |
|
103 iLatestError = aError; |
|
104 if ( !IsActive() ) |
|
105 { |
|
106 TRequestStatus* requestStatus = &iStatus; |
|
107 User::RequestComplete( requestStatus, KErrNone ); |
|
108 SetActive(); |
|
109 } |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------------------------- |
|
113 // CActive::RunL |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 void CGlxErrorPoster::RunL() |
|
117 { |
|
118 GLX_LOG_INFO( "CGlxErrorPoster::RunL" ); |
|
119 |
|
120 TInt error = iLatestError; |
|
121 iLatestError = KErrNone; |
|
122 User::Leave( error ); |
|
123 } |
|
124 |
|
125 // --------------------------------------------------------------------------- |
|
126 // CActive::DoCancel |
|
127 // --------------------------------------------------------------------------- |
|
128 // |
|
129 void CGlxErrorPoster::DoCancel() |
|
130 { |
|
131 GLX_LOG_INFO( "CGlxErrorPoster::DoCancel" ); |
|
132 // No need to do anything |
|
133 // CActive::Cancel() will wait for the request to complete |
|
134 } |