1 /* |
|
2 * Copyright (c) 2002-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: One MMS setting item. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32base.h> |
|
22 #include <msvapi.h> |
|
23 #include <mmsclient.h> |
|
24 #include <mtclreg.h> |
|
25 #include <cmmanagerext.h> |
|
26 #include <cmconnectionmethodext.h> |
|
27 #include <cmpluginpacketdatadef.h> |
|
28 #include <CWPCharacteristic.h> |
|
29 #include <CWPParameter.h> |
|
30 #include <CWPAdapter.h> |
|
31 #include <favouritesdb.h> |
|
32 #include "CWPWAPMMSItem.h" |
|
33 #include "WPWAPItemFactory.h" |
|
34 #include "WPWAPUtil.h" |
|
35 |
|
36 #ifdef __MESSAGING_API_V2__ |
|
37 #include <mmssettings.h> |
|
38 #endif |
|
39 |
|
40 // CONSTANTS |
|
41 const TInt KUrlMaxLength = 255; |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CWPWAPMMSItem::CWPWAPMMSItem |
|
45 // C++ default constructor can NOT contain any code, that |
|
46 // might leave. |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 CWPWAPMMSItem::CWPWAPMMSItem( const TDesC& aTitle, |
|
50 const TDesC& aDefaultName, |
|
51 CWPCharacteristic& aCharacteristic, |
|
52 CCommsDatabase*& aDb, |
|
53 RCmManagerExt*& aCmManager ) |
|
54 : CWPWAPItemBase( aTitle, aDefaultName, aCharacteristic, aDb, aCmManager ) |
|
55 { |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CWPWAPMMSItem::ConstructL |
|
60 // Symbian 2nd phase constructor can leave. |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 void CWPWAPMMSItem::ConstructL() |
|
64 { |
|
65 BaseConstructL(); |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CWPWAPMMSItem::NewL |
|
70 // Two-phased constructor. |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 CWPWAPMMSItem* CWPWAPMMSItem::NewL( const TDesC& aTitle, |
|
74 const TDesC& aDefaultName, |
|
75 CWPCharacteristic& aCharacteristic, |
|
76 CCommsDatabase*& aDb, |
|
77 RCmManagerExt*& aCmManager ) |
|
78 { |
|
79 CWPWAPMMSItem* self = new(ELeave) CWPWAPMMSItem( aTitle, aDefaultName, |
|
80 aCharacteristic, aDb, aCmManager ); |
|
81 CleanupStack::PushL(self); |
|
82 self->ConstructL(); |
|
83 CleanupStack::Pop(self); |
|
84 return self; |
|
85 } |
|
86 |
|
87 // Destructor |
|
88 CWPWAPMMSItem::~CWPWAPMMSItem() |
|
89 { |
|
90 iLinks.Close(); |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CWPWAPMMSItem::SaveL |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 void CWPWAPMMSItem::SaveL() |
|
98 { |
|
99 CreateDbL(); |
|
100 TBool check = EFalse; |
|
101 RCmConnectionMethodExt cm; |
|
102 TUint32 bearer = 0; |
|
103 for( TInt i( 0 ); i < iLinks.Count() && check == EFalse ; i++ ) |
|
104 { |
|
105 CWPCharacteristic* curr = iLinks[i]; |
|
106 TPckgBuf<TUint32> uidPckg; |
|
107 const TInt pkgLength( uidPckg.MaxLength() ); |
|
108 for( TInt dataNum( 0 ); check == EFalse && curr->Data( dataNum ).Length() == pkgLength;dataNum++ ) |
|
109 { |
|
110 uidPckg.Copy( curr->Data( dataNum ) ); |
|
111 // Read the access point pointed to by TO-NAPID or TO-PROXY |
|
112 cm = iCmManager->ConnectionMethodL( uidPckg() ); |
|
113 CleanupClosePushL( cm ); |
|
114 bearer = cm.GetIntAttributeL( CMManager::ECmBearerType ); |
|
115 if( bearer == KUidPacketDataBearerType ) |
|
116 { |
|
117 // Item left on cleanup stack |
|
118 check = ETrue; |
|
119 } |
|
120 else |
|
121 { |
|
122 CleanupStack::PopAndDestroy(); // cm |
|
123 } |
|
124 } |
|
125 } |
|
126 |
|
127 WriteHomePageL( cm ); |
|
128 CleanupStack::PopAndDestroy(); // cm |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // CWPWAPMMSItem::CanSetAsDefault |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 TBool CWPWAPMMSItem::CanSetAsDefault() const |
|
136 { |
|
137 return ETrue; |
|
138 } |
|
139 |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 // CWPWAPMMSItem::SetAsDefaultL |
|
143 // ----------------------------------------------------------------------------- |
|
144 // |
|
145 void CWPWAPMMSItem::SetAsDefaultL() |
|
146 { |
|
147 // Open Messaging Server session |
|
148 CMsvSession* session = CMsvSession::OpenSyncL( *this ); |
|
149 CleanupStack::PushL( session ); |
|
150 |
|
151 // Read the MMS client information via registry |
|
152 CClientMtmRegistry* registry = CClientMtmRegistry::NewL( *session ); |
|
153 CleanupStack::PushL( registry ); |
|
154 |
|
155 CMmsClientMtm* mmsClient = |
|
156 static_cast<CMmsClientMtm*>( registry->NewMtmL( KUidMsgTypeMultimedia ) ); |
|
157 CleanupStack::PushL( mmsClient ); |
|
158 |
|
159 #ifdef __MESSAGING_API_V2__ |
|
160 |
|
161 CMmsSettings* mmsSettings = CMmsSettings::NewL(); |
|
162 CleanupStack::PushL( mmsSettings ); |
|
163 |
|
164 mmsClient->RestoreSettingsL(); |
|
165 |
|
166 mmsSettings->CopyL( mmsClient->MmsSettings() ); |
|
167 TInt apCount = mmsSettings->AccessPointCount(); |
|
168 TInt index; |
|
169 for ( index = 0; index < apCount; index++) |
|
170 { |
|
171 mmsSettings->DeleteAccessPointL( 0 ); |
|
172 } |
|
173 mmsSettings->AddAccessPointL( iUID, 0 ); |
|
174 |
|
175 mmsClient->SetSettingsL( *mmsSettings ); |
|
176 mmsClient->StoreSettingsL(); |
|
177 |
|
178 CleanupStack::PopAndDestroy(); // mmsSettings |
|
179 |
|
180 #else |
|
181 |
|
182 mmsClient->LoadMessageL(); |
|
183 // Set the correct access point and save |
|
184 mmsClient->SetFirstAccessPoint( iUID ); |
|
185 mmsClient->SaveMessageL(); |
|
186 |
|
187 #endif |
|
188 |
|
189 CleanupStack::PopAndDestroy(3); // mmsClient, registry, session |
|
190 } |
|
191 |
|
192 // ----------------------------------------------------------------------------- |
|
193 // CWPWAPMMSItem::ValidateL |
|
194 // ----------------------------------------------------------------------------- |
|
195 // |
|
196 TBool CWPWAPMMSItem::ValidateL() |
|
197 { |
|
198 return iLinks.Count() > 0 |
|
199 && iAddr |
|
200 && iAddr->Length() <=KUrlMaxLength |
|
201 && WPWAPUtil::CheckURI( *iAddr ); |
|
202 } |
|
203 |
|
204 // ----------------------------------------------------------------------------- |
|
205 // CWPWAPMMSItem::ResourceL |
|
206 // ----------------------------------------------------------------------------- |
|
207 // |
|
208 void CWPWAPMMSItem::ResourceL( CWPCharacteristic& aResource ) |
|
209 { |
|
210 RFavouritesDb favouritesDb; |
|
211 MWPWAPItemBase* item = WPWAPItemFactory::CreateBookmarkLC( KNullDesC, |
|
212 KNullDesC, aResource, iLink, favouritesDb ); // iDb is NULL but it's not used. |
|
213 |
|
214 // Not supporting resources without startpage. |
|
215 if ( item->CanSetAsDefault() && !iAddr ) |
|
216 { |
|
217 iAddr = item->Address().AllocL(); |
|
218 } |
|
219 CleanupStack::PopAndDestroy(); |
|
220 } |
|
221 |
|
222 // ----------------------------------------------------------------------------- |
|
223 // CWPWAPMMSItem::AddL |
|
224 // ----------------------------------------------------------------------------- |
|
225 // |
|
226 void CWPWAPMMSItem::AddL( RPointerArray<MWPWAPItemBase>& aShownItems, |
|
227 RPointerArray<MWPWAPItemBase>& /*aHiddenItems*/ ) |
|
228 { |
|
229 User::LeaveIfError( aShownItems.Append( this ) ); |
|
230 } |
|
231 |
|
232 // ----------------------------------------------------------------------------- |
|
233 // CWPWAPMMSItem::VisitLinkL |
|
234 // ----------------------------------------------------------------------------- |
|
235 // |
|
236 void CWPWAPMMSItem::VisitLinkL( CWPCharacteristic& aLink ) |
|
237 { |
|
238 CWPWAPItemBase::VisitLinkL( aLink ); |
|
239 User::LeaveIfError( iLinks.Append( &aLink ) ); |
|
240 } |
|
241 |
|
242 // ----------------------------------------------------------------------------- |
|
243 // CWPWAPMMSItem::HandleSessionEventL |
|
244 // ----------------------------------------------------------------------------- |
|
245 // |
|
246 void CWPWAPMMSItem::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, |
|
247 TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) |
|
248 { |
|
249 } |
|
250 |
|
251 |
|
252 |
|
253 // End of File |
|