1 /* |
|
2 * Copyright (c) 2006 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: Gets the voice tags from VAS |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "rubydebug.h" |
|
20 #include "taggetter.h" |
|
21 |
|
22 #include <nssvascoreconstant.h> |
|
23 |
|
24 // For CleanupResetAndDestroy |
|
25 #include <mmfcontrollerpluginresolver.h> |
|
26 |
|
27 // For getting tags basing on the convertion details |
|
28 // KCommandIdRrdIntIndex has to be known |
|
29 #include "tagcommandconverter.h" |
|
30 |
|
31 CTagGetter* CTagGetter::NewLC() |
|
32 { |
|
33 CTagGetter* self = new (ELeave) CTagGetter; |
|
34 CleanupStack::PushL( self ); |
|
35 return self; |
|
36 } |
|
37 |
|
38 CTagGetter* CTagGetter::NewL() |
|
39 { |
|
40 CTagGetter* self = CTagGetter::NewLC(); |
|
41 CleanupStack::Pop( self ); |
|
42 return self; |
|
43 } |
|
44 |
|
45 /** |
|
46 * Retrieves the list of tags for a given context. Synchronous. |
|
47 * Leaves two objects on the cleanup stack! |
|
48 * First PopAndDestroy will ResetAndDestroy content |
|
49 * Second one will destroy the MNsstagListArray itself |
|
50 */ |
|
51 MNssTagListArray* CTagGetter::GetTagListLC2( MNssTagMgr& aTagManager, const MNssContext& aContext ) |
|
52 { |
|
53 RUBY_DEBUG0( "CTagGetter::GetTagListLC2 start" ); |
|
54 __ASSERT_ALWAYS( !iTagList, User::Leave( KErrNotReady ) ); |
|
55 TInt nssErr = |
|
56 aTagManager.GetTagList( this, const_cast<MNssContext*>( &aContext) ); |
|
57 MNssTagListArray* result = WaitAndFormTagListLC2( nssErr ); |
|
58 RUBY_DEBUG0( "CTagGetter::GetTagListLC2 end" ); |
|
59 return result; |
|
60 } |
|
61 |
|
62 /** |
|
63 * Retrieves the list of tags for a given context and vcommand id. Synchronous. |
|
64 * Leaves two objects on the cleanup stack! |
|
65 * First PopAndDestroy will ResetAndDestroy content |
|
66 * Second one will destroy the MNsstagListArray itself |
|
67 */ |
|
68 MNssTagListArray* CTagGetter::GetTagListLC2( MNssTagMgr& aTagManager, const MNssContext& aContext, |
|
69 TInt aCommandId ) |
|
70 { |
|
71 RUBY_DEBUG0( "CTagGetter::GetTagListLC2 start" ); |
|
72 __ASSERT_ALWAYS( !iTagList, User::Leave( KErrNotReady ) ); |
|
73 TInt nssErr = |
|
74 aTagManager.GetTagList( this, const_cast<MNssContext*>( &aContext), |
|
75 aCommandId, KCommandIdRrdIntIndex ); |
|
76 MNssTagListArray* result = WaitAndFormTagListLC2( nssErr ); |
|
77 |
|
78 RUBY_DEBUG0( "CTagGetter::GetTagListLC2 end" ); |
|
79 return result; |
|
80 } |
|
81 |
|
82 /** |
|
83 * After one of the GetTagListLC2 functions requested a list of |
|
84 * tags from VAS, they call this function to wait for the query |
|
85 * result and process it |
|
86 * Leaves two objects on the cleanup stack! |
|
87 * First PopAndDestroy will ResetAndDestroy content |
|
88 * Second one will destroy the MNssTagListArray itself |
|
89 * @param aNssErr Error code from the GetTagList request |
|
90 */ |
|
91 MNssTagListArray* CTagGetter::WaitAndFormTagListLC2( TInt aNssErr ) |
|
92 { |
|
93 RUBY_DEBUG0( "CTagGetter::WaitAndFormTagListLC2 start" ); |
|
94 MNssTagListArray* result = NULL; |
|
95 if( aNssErr != KErrNone ) |
|
96 { |
|
97 RUBY_ERROR1( "CTagGetter::GetTagListLC2 GetTagList failed with nss code [%d]", |
|
98 aNssErr ); |
|
99 // Unfortunately VAS does not report if it was a real failure or just no tags |
|
100 // Return empty list in both cases |
|
101 // 1 stands for the random granularity, not for a number of elements |
|
102 result = new (ELeave) MNssTagListArray( 1 ); |
|
103 } |
|
104 else |
|
105 { |
|
106 // Tag list requested |
|
107 WaitForAsyncCallbackL(); |
|
108 result = iTagList; |
|
109 iTagList = NULL; |
|
110 } |
|
111 CleanupDeletePushL( result ); |
|
112 CleanupResetAndDestroyPushL( *result ); |
|
113 |
|
114 RUBY_DEBUG0( "CTagGetter::WaitAndFormTagListLC2 end" ); |
|
115 return result; |
|
116 } |
|
117 |
|
118 // From MNssGetTagClient |
|
119 |
|
120 /** |
|
121 * Callback to indicate GetTag successed. |
|
122 * client has to delete the tag list |
|
123 * @param aTagList |
|
124 * @param aErrorCode KErrNone if getting of tag list was successfull |
|
125 * @return None |
|
126 */ |
|
127 void CTagGetter::GetTagListCompleted( MNssTagListArray* aTagList, |
|
128 TInt aErrorCode ) |
|
129 { |
|
130 RUBY_DEBUG0( "CTagGetter::GetTagListCompleted start" ); |
|
131 |
|
132 if( aErrorCode == KErrNone ) |
|
133 { |
|
134 TInt err = KErrNone; |
|
135 if( !aTagList ) |
|
136 { |
|
137 RUBY_ERROR0( "CTagGetter::GetTagListCompleted NULL received" ); |
|
138 err = KErrArgument; |
|
139 } |
|
140 else if( iTagList ) |
|
141 { |
|
142 // Whenever error is returned, post-WaitForAsynchCallbackL code has no chance |
|
143 // to clean the iVasContext; |
|
144 delete iTagList; |
|
145 iTagList = NULL; |
|
146 RUBY_ERROR0( "CTagGetter::GetTagListCompleted iTagList is not empty" ); |
|
147 err = KErrAlreadyExists; |
|
148 } |
|
149 else |
|
150 { |
|
151 iTagList = aTagList; |
|
152 } |
|
153 StopAsyncWaitingOrPanic( err ); |
|
154 } |
|
155 |
|
156 else // aErrorCode is not KErrNone |
|
157 { |
|
158 RUBY_ERROR1( "CTagGetter::GetTagCompleted error. Error code[%d] ", aErrorCode ); |
|
159 StopAsyncWaitingOrPanic( aErrorCode ); |
|
160 } |
|
161 |
|
162 RUBY_DEBUG0( "CTagGetter::GetTagListCompleted end" ); |
|
163 } |
|
164 |
|
165 //End of file |
|