|
1 /* |
|
2 * Copyright (c) 2007 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 the License "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: Implementaion of change status Delete message |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <msvapi.h> |
|
20 #include <miuthdr.h> |
|
21 |
|
22 #include "messageheader.h" |
|
23 #include "ChangeStatus.h" |
|
24 |
|
25 // --------------------------------------------------------------------------- |
|
26 // two-phased constructor |
|
27 // --------------------------------------------------------------------------- |
|
28 CMessageChangeStatus* CMessageChangeStatus::NewL( CMsvSession& aSession ) |
|
29 { |
|
30 CMessageChangeStatus* self=NewLC( aSession ); |
|
31 CleanupStack::Pop( self ); |
|
32 return self; |
|
33 } |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 // two-phased constructor |
|
37 // --------------------------------------------------------------------------- |
|
38 CMessageChangeStatus* CMessageChangeStatus::NewLC( CMsvSession& aSession ) |
|
39 { |
|
40 CMessageChangeStatus* self=new(ELeave) CMessageChangeStatus( aSession ); |
|
41 CleanupStack::PushL( self ); |
|
42 return self; |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // default constructor |
|
47 // --------------------------------------------------------------------------- |
|
48 CMessageChangeStatus::CMessageChangeStatus( CMsvSession& aSession ): |
|
49 iServerSession( aSession ) |
|
50 { |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // destructor |
|
55 // --------------------------------------------------------------------------- |
|
56 CMessageChangeStatus::~CMessageChangeStatus() |
|
57 { |
|
58 delete iEntry; |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // CMessageChangeStatus::DeleteMessageL |
|
63 // This function is used to delete a message |
|
64 // returns KErrNone after success |
|
65 // --------------------------------------------------------------------------- |
|
66 void CMessageChangeStatus::DeleteMessageL( const TMsvId& aMsgId ) |
|
67 { |
|
68 iMessageId = aMsgId; |
|
69 |
|
70 InitializeL(); |
|
71 DeleteMessageL(); |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // CMessageChangeStatus::ChangeStatus |
|
76 // This function is used to change the message status based on the status falg passed |
|
77 // returns KErrNone on success. |
|
78 // --------------------------------------------------------------------------- |
|
79 void CMessageChangeStatus::ChangeStatusL( const TMsvId& aMsgId, |
|
80 const TMessageStatusFlag aStatusFlag, |
|
81 const TBool aValue ) |
|
82 { |
|
83 iMessageId= aMsgId; |
|
84 iStatusFlag = aStatusFlag; |
|
85 iFlagValue = aValue; |
|
86 |
|
87 InitializeL(); |
|
88 ChangeStatusL(); |
|
89 } |
|
90 |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // CMessageChangeStatus::InitializeL |
|
94 // This function is used to get the various message entry to be chnaged/deleted |
|
95 // and an index pointing to that entry. |
|
96 // --------------------------------------------------------------------------- |
|
97 void CMessageChangeStatus::InitializeL() |
|
98 { |
|
99 if ( iEntry ) |
|
100 { |
|
101 delete iEntry; |
|
102 iEntry = NULL; |
|
103 } |
|
104 |
|
105 iEntry = iServerSession.GetEntryL( iMessageId ); |
|
106 iIndexEntry = iEntry->Entry(); |
|
107 } |
|
108 |
|
109 // --------------------------------------------------------------------------- |
|
110 // CMessageChangeStatus::ChangeStatusL |
|
111 // This function is used to change the message status based on the status flag passed |
|
112 // returns KErrNone on success. |
|
113 // --------------------------------------------------------------------------- |
|
114 void CMessageChangeStatus::ChangeStatusL() |
|
115 { |
|
116 switch ( iStatusFlag ) |
|
117 { |
|
118 case EUnread: |
|
119 { |
|
120 iIndexEntry.SetUnread( iFlagValue ); |
|
121 iEntry->ChangeL( iIndexEntry ); |
|
122 } |
|
123 break; |
|
124 |
|
125 default: |
|
126 User::Leave( KErrGeneral ); |
|
127 } |
|
128 } |
|
129 |
|
130 // --------------------------------------------------------------------------- |
|
131 // CMessageChangeStatus::DeleteMessageL |
|
132 // delete a message based on its message ID |
|
133 // --------------------------------------------------------------------------- |
|
134 void CMessageChangeStatus::DeleteMessageL() |
|
135 { |
|
136 TMsvId parentID = iIndexEntry.Parent(); |
|
137 CMsvEntry* parentEntry = iServerSession.GetEntryL( parentID ); |
|
138 CleanupStack::PushL( parentEntry ); |
|
139 |
|
140 if ( iEntry ) |
|
141 { |
|
142 delete iEntry; |
|
143 iEntry = NULL; |
|
144 } |
|
145 |
|
146 parentEntry->DeleteL( iMessageId ); |
|
147 |
|
148 CleanupStack::PopAndDestroy( parentEntry ); |
|
149 } |
|
150 |