|
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 TRAP_IGNORE(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 msgType = ConvergedMessage::BioMsg; |
|
124 |
|
125 // based on the biotype uid set message type |
|
126 if(entry.iBioType == KMsgBioUidRingingTone.iUid) |
|
127 { |
|
128 msgSubType = ConvergedMessage::RingingTone; |
|
129 } |
|
130 else if(entry.iBioType == KMsgBioProvisioningMessage.iUid) |
|
131 { |
|
132 msgSubType = ConvergedMessage::Provisioning; |
|
133 } |
|
134 else if (entry.iBioType == KMsgBioUidVCard.iUid) |
|
135 { |
|
136 msgSubType = ConvergedMessage::VCard; |
|
137 } |
|
138 else if (entry.iBioType == KMsgBioUidVCalendar.iUid) |
|
139 { |
|
140 msgSubType = ConvergedMessage::VCal; |
|
141 } |
|
142 } |
|
143 break; |
|
144 default: |
|
145 msgType = ConvergedMessage::None; |
|
146 break; |
|
147 } |
|
148 } |
|
149 |
|
150 //---------------------------------------------------------------------------- |
|
151 // MsgStoreHandler::deleteMessage |
|
152 // @see header |
|
153 //---------------------------------------------------------------------------- |
|
154 void MsgStoreHandler::deleteMessage(int msgId) |
|
155 { |
|
156 iMsvSession->RemoveEntry(msgId); |
|
157 } |
|
158 // End of file |