12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
|
18 // System includes |
18 #include <cvoicemailbox.h> |
19 #include <cvoicemailbox.h> |
19 #include <cvoicemailboxentry.h> |
20 #include <cvoicemailboxentry.h> |
20 #include <QtGlobal> |
21 #include <voicemailboxdefs.h> |
21 #include <QVariant> |
22 |
|
23 // User includes |
22 #include "vmbxuiengine.h" |
24 #include "vmbxuiengine.h" |
23 #include "loggerutil.h" |
25 #include "loggerutil.h" |
24 |
26 |
25 |
27 /*! |
26 // ----------------------------------------------------------------------------- |
28 Constructor |
27 // Comment me! |
29 */ |
28 // ----------------------------------------------------------------------------- |
|
29 // |
|
30 VmbxUiEngine::VmbxUiEngine() : |
30 VmbxUiEngine::VmbxUiEngine() : |
31 mVmbxEngine( 0 ) |
31 mVmbxEngine(NULL) |
32 { |
32 { |
33 _DBGLOG("VmbxUiEngine::VmbxUiEngine>") |
33 _DBGLOG("VmbxUiEngine::VmbxUiEngine >") |
34 |
34 QT_TRAP_THROWING(mVmbxEngine = CVoiceMailbox::NewL()); |
35 // TODO: test that leave vs thrown exception really works |
|
36 //mVmbxEngine = QT_TRAP_THROWING( CVoiceMailbox::NewL() ); this available in qt 4.6 |
|
37 // TODO: replace all this trapping&throwing using QT_TRAP_THROWING when qt 4.6 |
|
38 TRAPD( error, mVmbxEngine = CVoiceMailbox::NewL(); ); |
|
39 if ( error || !mVmbxEngine ) { |
|
40 QT_THROW( 0 ); |
|
41 } |
|
42 _DBGLOG("VmbxUiEngine::VmbxUiEngine <") |
35 _DBGLOG("VmbxUiEngine::VmbxUiEngine <") |
43 } |
36 } |
44 |
37 |
45 // ----------------------------------------------------------------------------- |
38 /*! |
46 // |
39 Destructor |
47 // ----------------------------------------------------------------------------- |
40 */ |
48 // |
|
49 VmbxUiEngine::~VmbxUiEngine() |
41 VmbxUiEngine::~VmbxUiEngine() |
50 { |
42 { |
51 _DBGLOG( "VmbxUiEngine::~VmbxUiEngine >") |
43 _DBGLOG( "VmbxUiEngine::~VmbxUiEngine >") |
52 delete mVmbxEngine; |
44 delete mVmbxEngine; |
53 // TODO: check cleanup, this is a first draft! |
45 mVmbxEngine = NULL; |
54 _DBGLOG( "VmbxUiEngine::~VmbxUiEngine <") |
46 _DBGLOG( "VmbxUiEngine::~VmbxUiEngine <") |
55 } |
47 } |
56 |
48 |
57 // ----------------------------------------------------------------------------- |
49 /*! |
58 // |
50 Getter method for primary voice number of Voice Mailbox. |
59 // ----------------------------------------------------------------------------- |
51 */ |
60 // |
52 void VmbxUiEngine::getCsVoice1Number(QString &aValue) |
61 void VmbxUiEngine::GetCsVoice1Number( QString& aValue ) |
|
62 { |
53 { |
63 _DBGLOG("VmbxUiEngine::GetCsVoice1Number >") |
54 _DBGLOG("VmbxUiEngine::getCsVoice1Number >") |
64 |
55 |
65 CVoiceMailboxEntry* vmbxEntry = NULL; |
|
66 TVoiceMailboxParams vmbxParams; |
56 TVoiceMailboxParams vmbxParams; |
67 vmbxParams.iType = EVmbxVoice; |
57 vmbxParams.iType = EVmbxVoice; |
68 vmbxParams.iLineType = EVmbxAlsLine1; |
58 vmbxParams.iLineType = EVmbxAlsLine1; |
69 vmbxParams.iServiceId = KVmbxServiceVoice; |
59 vmbxParams.iServiceId = KVmbxServiceVoice; |
70 TInt result = mVmbxEngine->GetStoredEntry( vmbxParams, vmbxEntry ); |
60 getNumber(vmbxParams, aValue); |
71 _DBGLOG2("VmbxUiEngine::GetCsVoice1Number, GetStoredEntry result=", result); |
61 _DBGLOG2("VmbxUiEngine::getCsVoice1Number < , string=", aValue) |
72 if ( KErrNone == result && vmbxEntry ) |
|
73 { |
|
74 TPtrC entryNumber( KNullDesC ); |
|
75 result = vmbxEntry->GetVmbxNumber( entryNumber ); |
|
76 _DBGLOG3("VmbxUiEngine::GetCsVoice1Number, GetVmbxNumber result=", |
|
77 result, |
|
78 " but ignore code and allow returing of an empty string to UI"); |
|
79 aValue = QString( (QChar*)entryNumber.Ptr(), entryNumber.Length() ); |
|
80 } |
|
81 |
|
82 _DBGLOG2("VmbxUiEngine::GetCsVoice1Number < , string=", aValue) |
|
83 } |
62 } |
84 |
63 |
85 // ----------------------------------------------------------------------------- |
64 /*! |
86 // |
65 Getter method for voice ALS number of Voice Mailbox. |
87 // ----------------------------------------------------------------------------- |
66 */ |
88 // |
67 void VmbxUiEngine::getCsVoice2Number(QString &aValue) |
89 void VmbxUiEngine::GetCsVoice2Number( QString& aValue ) |
|
90 { |
68 { |
91 _DBGLOG("VmbxUiEngine::GetCsVoice2Number >") |
69 _DBGLOG("VmbxUiEngine::getCsVoice2Number >") |
92 CVoiceMailboxEntry* vmbxEntry = NULL; |
|
93 TVoiceMailboxParams vmbxParams; |
70 TVoiceMailboxParams vmbxParams; |
94 vmbxParams.iType = EVmbxVoice; |
71 vmbxParams.iType = EVmbxVoice; |
95 vmbxParams.iLineType = EVmbxAlsLine2; |
72 vmbxParams.iLineType = EVmbxAlsLine2; |
96 vmbxParams.iServiceId = KVmbxServiceVoice; |
73 vmbxParams.iServiceId = KVmbxServiceVoice; |
97 TInt result = mVmbxEngine->GetStoredEntry( vmbxParams, vmbxEntry ); |
74 getNumber(vmbxParams, aValue); |
98 _DBGLOG2("VmbxUiEngine::GetCsVoice2Number, GetStoredEntry result=", result); |
75 _DBGLOG2("VmbxUiEngine::getCsVoice2Number < , string=", aValue) |
99 if ( KErrNone == result && vmbxEntry ) |
|
100 { |
|
101 TPtrC entryNumber( KNullDesC ); |
|
102 result = vmbxEntry->GetVmbxNumber( entryNumber ); |
|
103 _DBGLOG3("VmbxUiEngine::GetCsVoice2Number, GetVmbxNumber result=", |
|
104 result, |
|
105 " but ignore code and allow returing of an empty string to UI"); |
|
106 aValue = QString( (QChar*)entryNumber.Ptr(),entryNumber.Length() ); |
|
107 } |
|
108 _DBGLOG2("VmbxUiEngine::GetCsVoice2Number < , string=", aValue) |
|
109 } |
76 } |
110 |
77 |
111 // ----------------------------------------------------------------------------- |
78 /*! |
112 // |
79 Getter method for primary video number of Voice Mailbox. |
113 // ----------------------------------------------------------------------------- |
80 */ |
114 // |
81 void VmbxUiEngine::getCsVideo1Number(QString &aValue) |
115 void VmbxUiEngine::GetCsVideo1Number( QString& aValue ) |
|
116 { |
82 { |
117 _DBGLOG("VmbxUiEngine::GetCsVideo1Number >") |
83 _DBGLOG("VmbxUiEngine::getCsVideo1Number >") |
118 CVoiceMailboxEntry* vmbxEntry = NULL; |
|
119 TVoiceMailboxParams vmbxParams; |
84 TVoiceMailboxParams vmbxParams; |
120 vmbxParams.iType = EVmbxVideo; |
85 vmbxParams.iType = EVmbxVideo; |
121 vmbxParams.iLineType = EVmbxAlsLine1; |
86 vmbxParams.iLineType = EVmbxAlsLine1; |
122 vmbxParams.iServiceId = KVmbxServiceVideo; |
87 vmbxParams.iServiceId = KVmbxServiceVideo; |
123 TInt result = mVmbxEngine->GetStoredEntry( vmbxParams, vmbxEntry ); |
88 getNumber(vmbxParams, aValue); |
124 _DBGLOG2("VmbxUiEngine::GetCsVideo1Number, GetStoredEntry result=", result); |
89 _DBGLOG2("VmbxUiEngine::getCsVideo1Number < , string=", aValue) |
125 if ( KErrNone == result && vmbxEntry ) |
|
126 { |
|
127 TPtrC entryNumber( KNullDesC ); |
|
128 result = vmbxEntry->GetVmbxNumber( entryNumber ); |
|
129 _DBGLOG3("VmbxUiEngine::GetCsVideo1Number, GetVmbxNumber result=", |
|
130 result, |
|
131 " but ignore code and allow returing of an empty string to UI"); |
|
132 aValue = QString( (QChar*)entryNumber.Ptr(),entryNumber.Length() ); |
|
133 } |
|
134 _DBGLOG2("VmbxUiEngine::GetCsVideo1Number < , string=", aValue) |
|
135 } |
90 } |
136 |
91 |
137 // ----------------------------------------------------------------------------- |
92 /*! |
138 // |
93 Callback from voice mailbox engine when number has been updated |
139 // ----------------------------------------------------------------------------- |
94 This method notifies the UI to refresh its data. |
140 // |
95 */ |
141 VmbxUiEngine::TUiDefaultVoiceMailboxType VmbxUiEngine::DefaultMailboxType() |
96 void VmbxUiEngine::uiCsVoice1Changed(const QString& aValue) |
142 { |
97 { |
143 _DBGLOG( "VmbxUiEngine::DefaultMailboxType") |
98 _DBGLOG2("VmbxUiEngine::uiCsVoice1Changed >, value=",aValue) |
144 TUiDefaultVoiceMailboxType result = EUiDefaultVmbxNone; |
|
145 // TODO: get type from engine IF AND WHEN THIS FEATURE IS SUPPORTED |
|
146 _DBGLOG2("VmbxUiEngine::GetCsVideo1Number < , string=", result) |
|
147 return result; |
|
148 } |
|
149 |
|
150 // ----------------------------------------------------------------------------- |
|
151 // Callback from voice mailbox engine when number has been updated |
|
152 // This method notifies the UI to refresh its data. |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 void VmbxUiEngine::HandleNotifyL( const CVoiceMailboxEntry& /*aVmbxEntry*/ ) |
|
156 { |
|
157 _DBGLOG( "VmbxUiEngine::HandleNotifyL") |
|
158 /* TODO: consider is there need to pass the actual modified data |
|
159 and mailbox type enum to slot. |
|
160 |
|
161 TODO: issue the notification request to vmbxengine, that is missing |
|
162 at the moment ! |
|
163 */ |
|
164 emit voiceMailboxEngineEntriesUpdated(); |
|
165 } |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // Callback from voice mailbox engine when number has been updated |
|
169 // This method notifies the UI to refresh its data. |
|
170 // ----------------------------------------------------------------------------- |
|
171 // |
|
172 void VmbxUiEngine::uiCsVoice1Changed( const QString& aValue ) |
|
173 { |
|
174 _DBGLOG2("VmbxUiEngine::uiCsVoice1Changed, value=",aValue) |
|
175 CVoiceMailboxEntry* vmbxEntry = NULL; |
|
176 TVoiceMailboxParams vmbxParams; |
99 TVoiceMailboxParams vmbxParams; |
177 vmbxParams.iType = EVmbxVoice; |
100 vmbxParams.iType = EVmbxVoice; |
178 vmbxParams.iLineType = EVmbxAlsLine1; |
101 vmbxParams.iLineType = EVmbxAlsLine1; |
179 vmbxParams.iServiceId = KVmbxServiceVoice; |
102 vmbxParams.iServiceId = KVmbxServiceVoice; |
180 TInt result = mVmbxEngine->GetStoredEntry( vmbxParams, vmbxEntry ); |
103 setNumber(vmbxParams, aValue); |
181 _DBGLOG2("VmbxUiEngine::uiCsVoice1Changed, GetStoredEntry result=", result); |
104 _DBGLOG("VmbxUiEngine::uiCsVoice1Changed <"); |
182 if ( KErrNone != result ) |
105 } |
183 { |
106 |
184 // TODO: test that leave vs thrown exception really works |
107 /*! |
185 //vmbxEntry = QT_TRAP_THROWING( CVoiceMailboxEntry::NewL() ); this available in qt 4.6 |
108 Callback from voice mailbox engine when number has been updated |
186 // TODO: replace all this trapping using QT_TRAP_THROWING when qt 4.6 |
109 This method notifies the UI to refresh its data. |
187 TRAP_IGNORE( vmbxEntry = CVoiceMailboxEntry::NewL() ); |
110 */ |
188 vmbxEntry->SetServiceId( KVmbxServiceVoice ); |
111 void VmbxUiEngine::HandleNotifyL(const CVoiceMailboxEntry &aVmbxEntry) |
189 vmbxEntry->SetVoiceMailboxType( EVmbxVoice ); |
112 { |
190 vmbxEntry->SetVmbxAlsLineType( EVmbxAlsLine1 ); |
113 _DBGLOG( "VmbxUiEngine::HandleNotifyL") |
|
114 Q_UNUSED(aVmbxEntry); |
|
115 // Consider is there need to pass the actual modified data |
|
116 // and mailbox type enum to slot. |
|
117 // |
|
118 // Issue the notification request to vmbxengine, that is missing |
|
119 // at the moment ! |
|
120 emit voiceMailboxEngineEntriesUpdated(); |
|
121 } |
|
122 |
|
123 /*! |
|
124 Private getter method for voice mailbox number. |
|
125 */ |
|
126 void VmbxUiEngine::getNumber(const TVoiceMailboxParams &aParam, |
|
127 QString &aValue) |
|
128 { |
|
129 _DBGLOG("VmbxUiEngine::getNumber >") |
|
130 CVoiceMailboxEntry* vmbxEntry = NULL; |
|
131 TInt result = mVmbxEngine->GetStoredEntry( aParam, vmbxEntry ); |
|
132 _DBGLOG2("VmbxUiEngine::getNumber, GetStoredEntry result=", result); |
|
133 if ( KErrNone == result && vmbxEntry ){ |
|
134 TPtrC entryNumber( KNullDesC ); |
|
135 result = vmbxEntry->GetVmbxNumber( entryNumber ); |
|
136 _DBGLOG3("VmbxUiEngine::getNumber, GetVmbxNumber result=", |
|
137 result, |
|
138 " but ignore code and allow returing of an empty string to UI"); |
|
139 aValue = QString::fromUtf16 (entryNumber.Ptr(), entryNumber.Length()); |
|
140 } |
|
141 delete vmbxEntry; |
|
142 vmbxEntry = NULL; |
|
143 _DBGLOG2("VmbxUiEngine::getNumber < , string=", aValue) |
|
144 } |
|
145 |
|
146 /*! |
|
147 Setter method for voice mailbox number. |
|
148 */ |
|
149 void VmbxUiEngine::setNumber(const TVoiceMailboxParams &aParam, |
|
150 const QString &aValue) |
|
151 { |
|
152 _DBGLOG("VmbxUiEngine::setNumber >") |
|
153 |
|
154 CVoiceMailboxEntry* vmbxEntry = NULL; |
|
155 TInt result = mVmbxEngine->GetStoredEntry(aParam, vmbxEntry); |
|
156 _DBGLOG2("VmbxUiEngine::setNumber, GetStoredEntry result=", result); |
|
157 if ( KErrNone != result ){ |
|
158 QT_TRAP_THROWING(vmbxEntry = CVoiceMailboxEntry::NewL()); |
|
159 vmbxEntry->SetServiceId(aParam.iServiceId); |
|
160 vmbxEntry->SetVoiceMailboxType(aParam.iType); |
|
161 vmbxEntry->SetVmbxAlsLineType(aParam.iLineType); |
191 // Service name for cs is basically the one in service table, |
162 // Service name for cs is basically the one in service table, |
192 // but in this case it's not used for anything by vmbx. |
163 // but in this case it's not used for anything by vmbx. |
193 // So let's not set anything as name...fix if problems arise |
164 // So let's not set anything as name...fix if problems arise |
194 } |
165 } |
195 _DBGLOG( "VmbxUiEngine::uiCsVoice1Changed: cast to TPtrC") |
166 _DBGLOG( "VmbxUiEngine::setNumber: cast to TPtrC") |
196 TPtrC newNumber( |
167 TPtrC newNumber( |
197 reinterpret_cast<const TUint16*>( aValue.utf16() ), |
168 reinterpret_cast<const TUint16*>( aValue.utf16() ), |
198 aValue.length() ); |
169 aValue.length() ); |
199 result = vmbxEntry->SetVmbxNumber( newNumber ); |
170 result = vmbxEntry->SetVmbxNumber( newNumber ); |
200 _DBGLOG2("VmbxUiEngine::uiCsVoice1Changed, SetVmbxNumber result=", result); |
171 _DBGLOG2("VmbxUiEngine::setNumber, SetVmbxNumber result=", result); |
201 |
172 |
202 if ( KErrNone == result ) |
173 if ( KErrNone == result ){ |
203 { |
|
204 result = mVmbxEngine->SaveEntry( *vmbxEntry ); |
174 result = mVmbxEngine->SaveEntry( *vmbxEntry ); |
205 } |
175 _DBGLOG2("VmbxUiEngine::setNumber, SaveEntry result=", result); |
|
176 } |
206 delete vmbxEntry; |
177 delete vmbxEntry; |
207 // TODO: handle error here |
178 // TODO: handle error here |
208 _DBGLOG2("VmbxUiEngine::uiCsVoice1Changed <, SaveEntry result=", result); |
179 _DBGLOG("VmbxUiEngine::setNumber <"); |
209 } |
180 } |
|
181 |
|
182 //End of file |