|
1 /* |
|
2 * Copyright (c) 2008 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: Reads message information from message store. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <msvids.h> |
|
19 #include <mmsconst.h> |
|
20 #include <SendUiConsts.h> |
|
21 |
|
22 #include "msgstorehandler.h" |
|
23 #include "msgbiouids.h" |
|
24 #include "convergedmessage.h" |
|
25 |
|
26 //---------------------------------------------------------------------------- |
|
27 // MsgStoreHandler::MsgStoreHandler |
|
28 // @see header |
|
29 //---------------------------------------------------------------------------- |
|
30 MsgStoreHandler::MsgStoreHandler(): |
|
31 iMsvSession(NULL) |
|
32 { |
|
33 InitL(); |
|
34 } |
|
35 |
|
36 //---------------------------------------------------------------------------- |
|
37 // MsgStoreHandler::~MsgStoreHandler |
|
38 // @see header |
|
39 //---------------------------------------------------------------------------- |
|
40 MsgStoreHandler::~MsgStoreHandler() |
|
41 { |
|
42 if(iMsvSession) |
|
43 { |
|
44 delete iMsvSession; |
|
45 iMsvSession = NULL; |
|
46 } |
|
47 } |
|
48 |
|
49 //---------------------------------------------------------------------------- |
|
50 // MsgStoreHandler::InitL |
|
51 // @see header |
|
52 //---------------------------------------------------------------------------- |
|
53 void MsgStoreHandler::InitL( ) |
|
54 { |
|
55 iMsvSession = CMsvSession::OpenSyncL(*this); |
|
56 } |
|
57 |
|
58 //---------------------------------------------------------------------------- |
|
59 // MsgStoreHandler::markAsReadAndGetType |
|
60 // @see header |
|
61 //---------------------------------------------------------------------------- |
|
62 void MsgStoreHandler::markAsReadAndGetType(int msgId, |
|
63 int& msgType, |
|
64 int& msgSubType) |
|
65 { |
|
66 msgType = ConvergedMessage::None; |
|
67 |
|
68 CMsvEntry* cEntry = NULL; |
|
69 TRAPD(err, cEntry = iMsvSession->GetEntryL(msgId)); |
|
70 if ( err == KErrNone) |
|
71 { |
|
72 TMsvEntry entry = cEntry->Entry(); |
|
73 if ( entry.Unread() ) |
|
74 { |
|
75 // Mark the entry as read |
|
76 entry.SetUnread( EFalse ); |
|
77 cEntry->ChangeL( entry ); |
|
78 } |
|
79 // extract message type |
|
80 extractMsgType(entry,msgType,msgSubType); |
|
81 } |
|
82 |
|
83 delete cEntry; |
|
84 } |
|
85 |
|
86 //---------------------------------------------------------------------------- |
|
87 // MsgStoreHandler::HandleSessionEventL |
|
88 // @see header |
|
89 //---------------------------------------------------------------------------- |
|
90 void MsgStoreHandler::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, |
|
91 TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) |
|
92 { |
|
93 // Nothing to do |
|
94 } |
|
95 |
|
96 //---------------------------------------------------------------------------- |
|
97 // MsgStoreHandler::extractMsgType |
|
98 // @see header |
|
99 //---------------------------------------------------------------------------- |
|
100 void MsgStoreHandler::extractMsgType(const TMsvEntry& entry, |
|
101 int& msgType, |
|
102 int& msgSubType) |
|
103 { |
|
104 msgType = ConvergedMessage::None; |
|
105 msgSubType = ConvergedMessage::None; |
|
106 |
|
107 switch(entry.iMtm.iUid) |
|
108 { |
|
109 case KSenduiMtmSmsUidValue: |
|
110 msgType = ConvergedMessage::Sms; |
|
111 break; |
|
112 case KSenduiMtmBtUidValue: |
|
113 msgType = ConvergedMessage::BT; |
|
114 break; |
|
115 case KSenduiMtmMmsUidValue: |
|
116 msgType = ConvergedMessage::Mms; |
|
117 break; |
|
118 case KSenduiMMSNotificationUidValue: |
|
119 msgType = ConvergedMessage::MmsNotification; |
|
120 break; |
|
121 case KSenduiMtmBioUidValue: |
|
122 { |
|
123 if (entry.iMtmData1 == KSenduiMtmBtUidValue) |
|
124 { |
|
125 msgType = ConvergedMessage::BT; |
|
126 |
|
127 if (entry.iBioType == KMsgBioUidVCard.iUid) |
|
128 { |
|
129 msgSubType = ConvergedMessage::VCard; |
|
130 } |
|
131 else if (entry.iBioType == KMsgBioUidVCalendar.iUid) |
|
132 { |
|
133 msgSubType = ConvergedMessage::VCal; |
|
134 } |
|
135 |
|
136 break; |
|
137 } |
|
138 msgType = ConvergedMessage::BioMsg; |
|
139 |
|
140 // based on the biotype uid set message type |
|
141 if(entry.iBioType == KMsgBioUidRingingTone.iUid) |
|
142 { |
|
143 msgSubType = ConvergedMessage::RingingTone; |
|
144 } |
|
145 else if(entry.iBioType == KMsgBioProvisioningMessage.iUid) |
|
146 { |
|
147 msgSubType = ConvergedMessage::Provisioning; |
|
148 } |
|
149 else if (entry.iBioType == KMsgBioUidVCard.iUid) |
|
150 { |
|
151 msgSubType = ConvergedMessage::VCard; |
|
152 } |
|
153 else if (entry.iBioType == KMsgBioUidVCalendar.iUid) |
|
154 { |
|
155 msgSubType = ConvergedMessage::VCal; |
|
156 } |
|
157 } |
|
158 break; |
|
159 default: |
|
160 msgType = ConvergedMessage::None; |
|
161 break; |
|
162 } |
|
163 } |
|
164 |
|
165 //---------------------------------------------------------------------------- |
|
166 // MsgStoreHandler::deleteMessage |
|
167 // @see header |
|
168 //---------------------------------------------------------------------------- |
|
169 void MsgStoreHandler::deleteMessage(int msgId) |
|
170 { |
|
171 iMsvSession->RemoveEntry(msgId); |
|
172 } |
|
173 |
|
174 //---------------------------------------------------------------------------- |
|
175 // MsgStoreHandler::isDraftMessage |
|
176 // @see header |
|
177 //---------------------------------------------------------------------------- |
|
178 bool MsgStoreHandler::isDraftMessage(int msgId) |
|
179 { |
|
180 bool draftmsg = false; |
|
181 CMsvEntry* cEntry = NULL; |
|
182 TRAPD(err, cEntry = iMsvSession->GetEntryL(msgId)); |
|
183 if ( err == KErrNone) |
|
184 { |
|
185 TMsvEntry msvEntry = cEntry->Entry(); |
|
186 TMsvId parent = msvEntry.Parent(); |
|
187 if(parent == KMsvDraftEntryIdValue) |
|
188 { |
|
189 draftmsg = true; |
|
190 } |
|
191 } |
|
192 |
|
193 delete cEntry; |
|
194 return draftmsg; |
|
195 } |
|
196 // End of file |