author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Thu, 27 Aug 2009 07:43:07 +0300 | |
changeset 22 | fc9cf246af83 |
parent 19 | 989d2f495d90 |
permissions | -rw-r--r-- |
19 | 1 |
/* |
2 |
* Copyright (c) 2007-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: This Class is observer for the Launching Application |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
#include <e32const.h> |
|
21 |
#include "tcallback.h" |
|
22 |
||
23 |
||
24 |
||
25 |
//#include <TPbkContactItemField.h> |
|
26 |
//#include <CPbkFieldInfo.h> |
|
27 |
||
28 |
||
29 |
// ----------------------------------------------------------------------------- |
|
30 |
// CCContactCallBack::NewL |
|
31 |
// Returns the instance of CLauncherObserver. |
|
32 |
// ----------------------------------------------------------------------------- |
|
33 |
EXPORT_C CContactCallBack* CContactCallBack::NewL(RFile* afile ) |
|
34 |
{ |
|
35 |
CContactCallBack* self = new( ELeave ) CContactCallBack(afile); |
|
36 |
||
37 |
return self; |
|
38 |
} |
|
39 |
||
40 |
||
41 |
// --------------------------------------------------------------------------- |
|
42 |
// consturctor |
|
43 |
// --------------------------------------------------------------------------- |
|
44 |
// |
|
45 |
CContactCallBack::CContactCallBack(RFile* afile ):iId(NULL),iCont(NULL) |
|
46 |
{ |
|
47 |
ifile = afile; |
|
48 |
} |
|
49 |
||
50 |
||
51 |
CContactCallBack::~CContactCallBack() |
|
52 |
{ |
|
53 |
delete iCont; |
|
54 |
delete iId; |
|
55 |
||
56 |
||
57 |
} |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
58 |
void CContactCallBack::HandleReturnArray(const TInt& aError, RPointerArray<HBufC8>& aArray, TInt aTransId ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
59 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
60 |
CActiveScheduler::Stop(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
61 |
} |
19 | 62 |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
63 |
void CContactCallBack::HandleReturnId( const TInt& aError, HBufC8* acntId, TInt aTransId ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
64 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
65 |
CActiveScheduler::Stop(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
66 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
67 |
|
19 | 68 |
|
69 |
void CContactCallBack::HandleReturnValue(TOperationEvent aEventId, const TInt& aError, TInt aTransId ) |
|
70 |
{ |
|
71 |
CActiveScheduler::Stop(); |
|
72 |
iErrCode=aError; |
|
73 |
TBuf8<25> filebuf; |
|
74 |
filebuf.Num(aError); |
|
75 |
||
76 |
//filebuf.Append(_L("\n NextL called")); |
|
77 |
ifile->Write(filebuf); |
|
78 |
filebuf.Zero(); |
|
79 |
ifile->Flush(); |
|
80 |
||
81 |
||
82 |
} |
|
83 |
||
84 |
void CContactCallBack::HandleReturnIter( const TInt& aError, CContactIter* aIter, TInt aTransId ) |
|
85 |
{ |
|
86 |
CActiveScheduler::Stop(); |
|
87 |
CSingleContact* singleContact = NULL; |
|
88 |
HBufC8* buf = NULL; |
|
89 |
TInt count = 0; |
|
90 |
iErrCode = aError; |
|
91 |
||
92 |
||
93 |
TBuf8<100> filebuf; |
|
94 |
||
95 |
while(ETrue) |
|
96 |
{ |
|
97 |
aIter->NextL(singleContact,buf); |
|
98 |
||
99 |
filebuf.Append(_L("\n NextL called")); |
|
100 |
ifile->Write(filebuf); |
|
101 |
filebuf.Zero(); |
|
102 |
ifile->Flush(); |
|
103 |
||
104 |
if(singleContact) |
|
105 |
{ |
|
106 |
||
107 |
iId = buf; |
|
108 |
||
109 |
filebuf.Append(_L("\n Id copied")); |
|
110 |
ifile->Write(filebuf); |
|
111 |
filebuf.Zero(); |
|
112 |
ifile->Flush(); |
|
113 |
||
114 |
iCont = singleContact; |
|
115 |
||
116 |
filebuf.Append(_L("\n single contact copied")); |
|
117 |
ifile->Write(filebuf); |
|
118 |
filebuf.Zero(); |
|
119 |
ifile->Flush(); |
|
120 |
||
121 |
TInt count(singleContact->FieldCount()); |
|
122 |
||
123 |
filebuf.Append(_L("\n count calculated")); |
|
124 |
ifile->Write(filebuf); |
|
125 |
filebuf.Zero(); |
|
126 |
ifile->Flush(); |
|
127 |
while(count) |
|
128 |
{ |
|
129 |
||
130 |
CSingleContactField* field = singleContact->FieldAt(--count); |
|
131 |
||
132 |
filebuf.Append(_L("\n single filed ")); |
|
133 |
ifile->Write(filebuf); |
|
134 |
filebuf.Zero(); |
|
135 |
ifile->Flush(); |
|
136 |
||
137 |
TPtrC8 fieldKey; |
|
138 |
TPtrC label; |
|
139 |
TPtrC value; |
|
140 |
field->GetFieldDataL(fieldKey,label,value); |
|
141 |
||
142 |
filebuf.Append(_L("\n gets field value ")); |
|
143 |
ifile->Write(filebuf); |
|
144 |
filebuf.Zero(); |
|
145 |
ifile->Flush(); |
|
146 |
||
147 |
filebuf.Append(fieldKey); |
|
148 |
ifile->Write(filebuf); |
|
149 |
filebuf.Zero(); |
|
150 |
ifile->Flush(); |
|
151 |
||
152 |
||
153 |
if (fieldKey == KLastName && value == KName) |
|
154 |
{ |
|
155 |
iErrCode = KErrNone; |
|
156 |
||
157 |
filebuf.Append(_L("\n got contact item ")); |
|
158 |
ifile->Write(filebuf); |
|
159 |
filebuf.Zero(); |
|
160 |
ifile->Flush(); |
|
161 |
} |
|
162 |
else if (fieldKey == KFirstName) |
|
163 |
{ |
|
164 |
break; |
|
165 |
} |
|
166 |
||
167 |
} |
|
168 |
||
169 |
||
170 |
} |
|
171 |
||
172 |
if(!singleContact) |
|
173 |
{ |
|
174 |
break; |
|
175 |
} |
|
176 |
||
177 |
// delete singleContact; |
|
178 |
} |
|
179 |
||
180 |
if(iErrCode != KErrNone ) |
|
181 |
{ |
|
182 |
iErrCode = KErrNotFound; |
|
183 |
} |
|
184 |
||
185 |
delete aIter; |
|
186 |
filebuf.Append(_L("\n iteratro deleted ")); |
|
187 |
ifile->Write(filebuf); |
|
188 |
filebuf.Zero(); |
|
189 |
ifile->Flush(); |
|
190 |
} |
|
191 |