|
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 "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: Implements storage class for mail preferences |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <msvapi.h> // MsvSession, MsvEntry |
|
21 #include <miutset.h> // KUidMsgTypeSMTP |
|
22 #include <smtpset.h> // CImSmtpSettings |
|
23 #include <featmgr.h> |
|
24 #include <bldvariant.hrh> |
|
25 #include <charconv.h> |
|
26 #include <cemailaccounts.h> // CEmailAccounts |
|
27 #include <SendUiConsts.h> |
|
28 #include "MsgMailPreferences.h" // TMsgMailPreferences |
|
29 |
|
30 |
|
31 // LOCAL CONSTANTS |
|
32 const TInt KFirstBit = 1; |
|
33 const TInt KSecondBit = 2; |
|
34 const TInt KFourthBit = 4; |
|
35 |
|
36 |
|
37 // ================= MEMBER FUNCTIONS ======================= |
|
38 |
|
39 // Constructor |
|
40 // Sets default values. |
|
41 // |
|
42 EXPORT_C CMsgMailPreferences::CMsgMailPreferences(): |
|
43 iScheduling(CMsgMailPreferences::EMsgMailSchedulingNextConn), |
|
44 iServiceId(KMsvUnknownServiceIndexEntryId) |
|
45 { |
|
46 iHeaderResults = 5; // CSI: 47 # See a comment above. |
|
47 // if these defaults above are changed, DefaultAccountSettings() should be |
|
48 // changed accordingly |
|
49 } |
|
50 |
|
51 // ---------------------------------------------------------------------------- |
|
52 // CMsgMailPreferences::DefaultAccountSettingsL gets all default values |
|
53 // for all preferences from specified remote mailbox service |
|
54 // Returns: none (updates fields) |
|
55 // ---------------------------------------------------------------------------- |
|
56 // |
|
57 EXPORT_C void CMsgMailPreferences::DefaultAccountSettingsL( |
|
58 const TMsvId aServiceId, // service whose settings are to be used |
|
59 CMsvSession& aSession) // used to get the settings |
|
60 { |
|
61 SetServiceId( aServiceId ); |
|
62 |
|
63 if ( aServiceId != KMsvUnknownServiceIndexEntryId ) |
|
64 { |
|
65 // Resolve account id |
|
66 TMsvEntry smtpEntry; |
|
67 TMsvId serviceId; |
|
68 User::LeaveIfError( |
|
69 aSession.GetEntry( aServiceId, serviceId, smtpEntry ) ); |
|
70 |
|
71 // Set "Send on next connection" and Utf 8 as defaults |
|
72 TImSMTPSendMessageOption sendingOption = ESendMessageOnNextConnection; |
|
73 iSendingCharacterSet = TUid::Uid(KCharacterSetIdentifierUtf8); |
|
74 |
|
75 |
|
76 CEmailAccounts* smtpAccount = CEmailAccounts::NewLC(); |
|
77 CImSmtpSettings* smtpSet = new ( ELeave ) CImSmtpSettings(); |
|
78 CleanupStack::PushL( smtpSet ); |
|
79 |
|
80 TSmtpAccount accountParams; |
|
81 accountParams.iSmtpService = aServiceId; |
|
82 accountParams.iSmtpAccountId = smtpEntry.iMtmData2; |
|
83 |
|
84 smtpAccount->LoadSmtpSettingsL( accountParams, *smtpSet ); |
|
85 sendingOption = smtpSet->SendMessageOption(); |
|
86 iSendingCharacterSet = SolveCharacterSet( *smtpSet ); |
|
87 |
|
88 CleanupStack::PopAndDestroy( 2, smtpAccount ); // CSI: 47 # smtpSet, smtpAccount |
|
89 |
|
90 |
|
91 SetMessageScheduling( |
|
92 ( sendingOption == ESendMessageImmediately ) ? |
|
93 EMsgMailSchedulingNow : EMsgMailSchedulingNextConn ); |
|
94 } |
|
95 else |
|
96 { |
|
97 // no default account, restore defaults (see constructor) |
|
98 SetMessageScheduling( |
|
99 CMsgMailPreferences::EMsgMailSchedulingNextConn); |
|
100 } |
|
101 } |
|
102 |
|
103 // ---------------------------------------------------------------------------- |
|
104 // CMsgMailPreferences::ExportSendOptionsL exports preferences from TMsvEntry |
|
105 // Returns: none (updates fields from TMsvEntry) |
|
106 // ---------------------------------------------------------------------------- |
|
107 // |
|
108 EXPORT_C void CMsgMailPreferences::ExportSendOptionsL( |
|
109 const TMsvEmailEntry& aEntry) // TMsvEntry from where the values are got |
|
110 { |
|
111 // Send options: "Mail account" |
|
112 SetServiceId(aEntry.iServiceId); |
|
113 |
|
114 // Send options: "Sending" |
|
115 SetMessageScheduling(aEntry.SendingState() == KMsvSendStateWaiting ? |
|
116 EMsgMailSchedulingNow : EMsgMailSchedulingNextConn); |
|
117 } |
|
118 |
|
119 // ---------------------------------------------------------------------------- |
|
120 // CMsgMailPreferences::ImportSendOptionsL imports preferences into TMsvEntry |
|
121 // ---------------------------------------------------------------------------- |
|
122 // |
|
123 EXPORT_C void CMsgMailPreferences::ImportSendOptionsL(TMsvEmailEntry& aEntry) |
|
124 { |
|
125 aEntry.iServiceId = ServiceId(); |
|
126 |
|
127 // set Send options: "Sending" in entry |
|
128 // for entry, there is no difference between now and next connection |
|
129 if ( MessageScheduling() == |
|
130 CMsgMailPreferences::EMsgMailSchedulingNow ) |
|
131 { |
|
132 aEntry.SetSendingState(KMsvSendStateWaiting); |
|
133 } |
|
134 else |
|
135 { |
|
136 aEntry.SetSendingState(KMsvSendStateScheduled); |
|
137 } |
|
138 } |
|
139 |
|
140 // |
|
141 // --------------------------------------------------------- |
|
142 // CMsgMailPreferences::GetAdditionalHeaderVisibility gets header visibility |
|
143 // Returns: header visibility status |
|
144 // --------------------------------------------------------- |
|
145 // |
|
146 EXPORT_C EHeaderStatus CMsgMailPreferences::GetAdditionalHeaderVisibility( TMsgControlId aHeader) |
|
147 { |
|
148 TInt results(0); |
|
149 |
|
150 if(aHeader == EMsgComponentIdCc) |
|
151 { |
|
152 results = iHeaderResults ^ KFirstBit; |
|
153 } |
|
154 else if(aHeader == EMsgComponentIdBcc) |
|
155 { |
|
156 results = iHeaderResults ^ KSecondBit; // CSI: 47 # <insert a comment here> |
|
157 } |
|
158 else if(aHeader == EMsgComponentIdSubject) |
|
159 { |
|
160 results = iHeaderResults ^ KFourthBit; // CSI: 47 # <insert a comment here> |
|
161 } |
|
162 |
|
163 EHeaderStatus returnVal; |
|
164 |
|
165 if (results < iHeaderResults) |
|
166 returnVal = EHeaderVisible; |
|
167 else |
|
168 returnVal = EHeaderHidden; |
|
169 |
|
170 return returnVal; |
|
171 } |
|
172 |
|
173 // --------------------------------------------------------- |
|
174 // CMsgMailPreferences::SetAdditionalHeaders sets user configurable headers |
|
175 // Returns: none |
|
176 // ---------------------------------------------------- |
|
177 // |
|
178 EXPORT_C void CMsgMailPreferences::SetAdditionalHeaders( |
|
179 TInt aValue) // new additional headers settings |
|
180 { |
|
181 iHeaderResults = aValue; |
|
182 } |
|
183 |
|
184 // ---------------------------------------------------------------------------- |
|
185 // CMsgMailPreferences::SolveCharacterSet() |
|
186 // ---------------------------------------------------------------------------- |
|
187 // |
|
188 TUid CMsgMailPreferences::SolveCharacterSet( |
|
189 const CImSmtpSettings& aSmtpSettings ) const |
|
190 { |
|
191 TUid characterSet = TUid::Uid(KCharacterSetIdentifierUtf8); |
|
192 // encoding supported, so read charset id from smtp settings. |
|
193 if ( iEncodingSupported ) |
|
194 { |
|
195 characterSet = aSmtpSettings.DefaultMsgCharSet(); |
|
196 } |
|
197 else |
|
198 { |
|
199 if ( FeatureManager::FeatureSupported( KFeatureIdJapanese ) ) |
|
200 { |
|
201 characterSet = TUid::Uid( |
|
202 KCharacterSetIdentifierIso2022Jp ); |
|
203 } |
|
204 } |
|
205 |
|
206 return characterSet; |
|
207 } |
|
208 |
|
209 // End of File |
|
210 |