|
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 "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: |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 #include "cmscontact.h" |
|
20 #include "cmssession.h" |
|
21 #include "cmscontactfieldinfo.h" |
|
22 #include "cmscommondefines.h" |
|
23 |
|
24 // ---------------------------------------------------- |
|
25 // CCmsContactFieldInfo::CCmsContactFieldInfo |
|
26 // |
|
27 // ---------------------------------------------------- |
|
28 // |
|
29 CCmsContactFieldInfo::CCmsContactFieldInfo( RCmsContact& aContact ) : |
|
30 CCmsContactBase( aContact ) |
|
31 { |
|
32 } |
|
33 |
|
34 // ---------------------------------------------------- |
|
35 // CCmsContactFieldInfo::CCmsContactFieldInfo |
|
36 // |
|
37 // ---------------------------------------------------- |
|
38 // |
|
39 CCmsContactFieldInfo::CCmsContactFieldInfo( RCmsContact& aContact, |
|
40 TRequestStatus& aClientStatus ) : |
|
41 CCmsContactBase( aContact, aClientStatus ) |
|
42 { |
|
43 } |
|
44 |
|
45 // ---------------------------------------------------- |
|
46 // CCmsContactFieldInfo::NewL |
|
47 // |
|
48 // ---------------------------------------------------- |
|
49 // |
|
50 CCmsContactFieldInfo* CCmsContactFieldInfo::NewL( RCmsContact& aContact ) |
|
51 { |
|
52 CCmsContactFieldInfo* self = new ( ELeave ) CCmsContactFieldInfo( aContact ); |
|
53 CleanupStack::PushL( self ); |
|
54 self->ConstructL(); |
|
55 CleanupStack::Pop(); |
|
56 return self; |
|
57 } |
|
58 |
|
59 // ---------------------------------------------------- |
|
60 // CCmsContactFieldInfo::NewL |
|
61 // |
|
62 // ---------------------------------------------------- |
|
63 // |
|
64 CCmsContactFieldInfo* CCmsContactFieldInfo::NewL( RCmsContact& aContact, TRequestStatus& aClientStatus ) |
|
65 { |
|
66 CCmsContactFieldInfo* self = new ( ELeave ) CCmsContactFieldInfo( aContact, aClientStatus ); |
|
67 CleanupStack::PushL( self ); |
|
68 self->BaseConstructL(); |
|
69 self->ConstructL(); |
|
70 CleanupStack::Pop(); |
|
71 return self; |
|
72 } |
|
73 |
|
74 // ---------------------------------------------------- |
|
75 // CCmsContactFieldInfo::Fields |
|
76 // |
|
77 // ---------------------------------------------------- |
|
78 // |
|
79 EXPORT_C const RArray<CCmsContactFieldItem::TCmsContactField>& CCmsContactFieldInfo::Fields() const |
|
80 { |
|
81 return iEnabledFields; |
|
82 } |
|
83 |
|
84 // ---------------------------------------------------- |
|
85 // CCmsContactFieldInfo::NewL |
|
86 // |
|
87 // ---------------------------------------------------- |
|
88 // |
|
89 void CCmsContactFieldInfo::ConstructL() |
|
90 { |
|
91 iBinary = EFalse; |
|
92 } |
|
93 |
|
94 // ---------------------------------------------------- |
|
95 // CCmsContactFieldInfo::NewL |
|
96 // |
|
97 // ---------------------------------------------------- |
|
98 // |
|
99 EXPORT_C CCmsContactFieldInfo::~CCmsContactFieldInfo() |
|
100 { |
|
101 iEnabledFields.Close(); |
|
102 } |
|
103 |
|
104 // ---------------------------------------------------- |
|
105 // CCmsContactFieldInfo::RunL |
|
106 // |
|
107 // ---------------------------------------------------- |
|
108 // |
|
109 void CCmsContactFieldInfo::RunL() |
|
110 { |
|
111 #ifdef _DEBUG |
|
112 RCmsSession::WriteToLog( _L8( "CCmsContactFieldInfo::RunL() - Error: %d" ), iStatus.Int() ); |
|
113 #endif |
|
114 if( KErrNone == iStatus.Int() ) |
|
115 { |
|
116 #ifdef _DEBUG |
|
117 RCmsSession::WriteToLog( _L8( " Enabled fields fetched OK." ) ); |
|
118 #endif |
|
119 const TChar delimiter = 32; |
|
120 for( TInt i = 0;iStreamDesc16.Length() > 0;i++ ) |
|
121 { |
|
122 TUint fieldId = 0; |
|
123 TPtrC idDesc( _L( "" ) ); |
|
124 TInt index = iStreamDesc16.Locate( delimiter ); |
|
125 index < 0 ? idDesc.Set( iStreamDesc16 ) : |
|
126 idDesc.Set( iStreamDesc16.Left( index ) ); |
|
127 TLex luthor( idDesc ); |
|
128 User::LeaveIfError( luthor.Val( fieldId ) ); |
|
129 CCmsContactFieldItem::TCmsContactField field = |
|
130 ( CCmsContactFieldItem::TCmsContactField )fieldId; |
|
131 User::LeaveIfError( iEnabledFields.Append( field ) ); |
|
132 index > 0 ? iStreamDesc16.Delete( 0, index + 1 ) : |
|
133 iStreamDesc16.Delete( 0, iStreamDesc16.Length() ); |
|
134 } |
|
135 User::RequestComplete( iClientStatus, KErrNone ); |
|
136 } |
|
137 else if( iStatus > 0 ) |
|
138 { |
|
139 #ifdef _DEBUG |
|
140 RCmsSession::WriteToLog( _L8( " Not enough memory allocated => Reallocate" ) ); |
|
141 #endif |
|
142 ReAllocBufferL( iStatus.Int() ); |
|
143 TIpcArgs args( StreamDesc16() ); |
|
144 TInt operation( ( TInt )ECmsFetchEnabledFields ); |
|
145 iContact.ResendReceive( operation, Activate(), args ); |
|
146 } |
|
147 else |
|
148 { |
|
149 //Handle errors in the base class |
|
150 HandleError(); |
|
151 } |
|
152 } |
|
153 |
|
154 // End of File |