|
1 /* |
|
2 * Copyright (c) 2002 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 the License "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: Implementation of CPushViewServiceOp. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 |
|
22 #include "PushViewServiceOp.h" |
|
23 #include "PushMtmUiPanic.h" |
|
24 #include "PushMtmLog.h" |
|
25 #include <PushEntry.h> |
|
26 #include <CUnknownPushMsgEntry.h> |
|
27 #include <eikenv.h> |
|
28 #include <apmstd.h> |
|
29 #include <DocumentHandler.h> |
|
30 |
|
31 // ================= MEMBER FUNCTIONS ======================= |
|
32 |
|
33 // --------------------------------------------------------- |
|
34 // CPushViewServiceOp::CPushViewServiceOp |
|
35 // --------------------------------------------------------- |
|
36 // |
|
37 CPushViewServiceOp::CPushViewServiceOp( CMsvSession& aSession, |
|
38 TMsvId aEntryId, |
|
39 TRequestStatus& aObserverStatus ) |
|
40 : CPushMtmUiOperation( aSession, aEntryId, aObserverStatus ) |
|
41 { |
|
42 PUSHLOG_WRITE("CPushViewServiceOp constructing") |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------- |
|
46 // CPushViewServiceOp::~CPushViewServiceOp |
|
47 // --------------------------------------------------------- |
|
48 // |
|
49 CPushViewServiceOp::~CPushViewServiceOp() |
|
50 { |
|
51 Cancel(); |
|
52 delete iDocHandler; |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------- |
|
56 // CPushViewServiceOp::StartL |
|
57 // --------------------------------------------------------- |
|
58 // |
|
59 void CPushViewServiceOp::StartL() |
|
60 { |
|
61 PUSHLOG_ENTERFN("CPushViewServiceOp::~CPushViewServiceOp") |
|
62 |
|
63 Cancel(); |
|
64 CPushMtmOperation::StartL(); |
|
65 |
|
66 PUSHLOG_LEAVEFN("CPushViewServiceOp::~CPushViewServiceOp") |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------- |
|
70 // CPushViewServiceOp::RunL |
|
71 // --------------------------------------------------------- |
|
72 // |
|
73 void CPushViewServiceOp::RunL() |
|
74 { |
|
75 PUSHLOG_ENTERFN("CPushViewServiceOp::RunL") |
|
76 |
|
77 TMsvEntry tEntry; |
|
78 TMsvId service; |
|
79 User::LeaveIfError( iMsvSession.GetEntry( iEntryId, service, tEntry ) ); |
|
80 |
|
81 __ASSERT_ALWAYS( tEntry.iMtm == KUidMtmWapPush, |
|
82 UiPanic( EPushMtmUiPanBadMtm ) ); |
|
83 |
|
84 CUnknownPushMsgEntry* context = NULL; |
|
85 const TInt32 bioType( tEntry.iBioType ); |
|
86 |
|
87 if ( bioType == KUidWapPushMsgUnknown.iUid ) |
|
88 { |
|
89 context = CUnknownPushMsgEntry::NewL(); |
|
90 } |
|
91 else |
|
92 { |
|
93 __ASSERT_DEBUG( EFalse, UiPanic( EPushMtmUiPanBadBioType ) ); |
|
94 User::Leave( KErrNotSupported ); |
|
95 } |
|
96 |
|
97 CleanupStack::PushL( context ); |
|
98 context->RetrieveL( iMsvSession, iEntryId ); |
|
99 |
|
100 const TPtrC contentType = context->ContentType(); |
|
101 const TPtrC8 content = context->MessageData(); |
|
102 |
|
103 __ASSERT_DEBUG( !iDocHandler, UiPanic( EPushMtmUiPanAlreadyInitialized ) ); |
|
104 iDocHandler = CDocumentHandler::NewL( CEikonEnv::Static()->Process() ); |
|
105 |
|
106 iDocHandler->SetExitObserver( this ); |
|
107 HBufC8* contentType8 = HBufC8::NewMaxLC( contentType.Length() ); |
|
108 contentType8->Des().Copy( contentType ); |
|
109 TDataType dataType( *contentType8 ); |
|
110 |
|
111 CAiwGenericParamList& paramList = iDocHandler->InParamListL(); |
|
112 RFile tempFile; |
|
113 iDocHandler->SaveTempFileL |
|
114 ( content, dataType, KNullDesC, tempFile ); |
|
115 PUSHLOG_WRITE(" SaveTempFileL OK"); |
|
116 CleanupClosePushL( tempFile ); |
|
117 iDocHandler->OpenFileEmbeddedL( tempFile, dataType, paramList ); |
|
118 PUSHLOG_WRITE(" OpenFileEmbeddedL OK"); |
|
119 CleanupStack::PopAndDestroy( &tempFile ); // tempFile |
|
120 PUSHLOG_WRITE(" PopAndDestroy( &tempFile ) OK"); |
|
121 |
|
122 CleanupStack::PopAndDestroy( 2, context ); // contentType8, context |
|
123 |
|
124 // Signal the observer when the viewer is terminated. |
|
125 |
|
126 PUSHLOG_LEAVEFN("CPushViewServiceOp::RunL") |
|
127 } |
|
128 |
|
129 // --------------------------------------------------------- |
|
130 // CPushViewServiceOp::DoCancel |
|
131 // --------------------------------------------------------- |
|
132 // |
|
133 void CPushViewServiceOp::DoCancel() |
|
134 { |
|
135 PUSHLOG_WRITE("CPushViewServiceOp::DoCancel") |
|
136 SignalObserver( KErrCancel ); |
|
137 } |
|
138 |
|
139 // --------------------------------------------------------- |
|
140 // CPushViewServiceOp::RunError |
|
141 // --------------------------------------------------------- |
|
142 // |
|
143 TInt CPushViewServiceOp::RunError( TInt aError ) |
|
144 { |
|
145 PUSHLOG_WRITE_FORMAT("CPushViewServiceOp::RunError <%d>",aError) |
|
146 TRAP_IGNORE( ShowGlobalErrorNoteL( aError ) ); |
|
147 return CPushMtmOperation::RunError( aError ); |
|
148 } |
|
149 |
|
150 // ----------------------------------------------------------------------------- |
|
151 // CPushViewServiceOp::HandleServerAppExit |
|
152 // ----------------------------------------------------------------------------- |
|
153 // |
|
154 void CPushViewServiceOp::HandleServerAppExit( TInt aReason ) |
|
155 { |
|
156 PUSHLOG_WRITE_FORMAT("CPushViewServiceOp::HandleServerAppExit <%d>",aReason) |
|
157 aReason = 0; // Just to avoid warnings. |
|
158 // Ready. |
|
159 SignalObserver( KErrNone ); |
|
160 } |
|
161 |
|
162 // End of file. |
|
163 |