23 #include <CVPbkContactStoreUriArray.h> |
23 #include <CVPbkContactStoreUriArray.h> |
24 #include <CVPbkContactManager.h> |
24 #include <CVPbkContactManager.h> |
25 #include <MVPbkContactStoreList.h> |
25 #include <MVPbkContactStoreList.h> |
26 #include <TVPbkContactStoreUriPtr.h> |
26 #include <TVPbkContactStoreUriPtr.h> |
27 #include <MVPbkContactLink.h> |
27 #include <MVPbkContactLink.h> |
|
28 |
|
29 #include <f32file.h> |
|
30 #include <e32des16.h> |
|
31 #include <e32base.h> |
|
32 #include <e32svr.h> |
28 |
33 |
29 // User Includes |
34 // User Includes |
30 #include "contactservice.h" |
35 #include "contactservice.h" |
31 #include "contactinterface.h" |
36 #include "contactinterface.h" |
32 #include "contactinterfacecallback.h" |
37 #include "contactinterfacecallback.h" |
389 |
396 |
390 void CContactInterface::ProcessAddDataL(const CLiwMap* aMap, |
397 void CContactInterface::ProcessAddDataL(const CLiwMap* aMap, |
391 CSingleContact* aContact, |
398 CSingleContact* aContact, |
392 CLiwGenericParamList& aOutParamList) |
399 CLiwGenericParamList& aOutParamList) |
393 { |
400 { |
|
401 TBool xspid = EFalse; |
|
402 TBool xspidIsDes = EFalse; |
394 TBool atleastOneField = EFalse; |
403 TBool atleastOneField = EFalse; |
395 iDburi = HBufC::NewL(VPbkContactStoreUris::DefaultCntDbUri().Length()); |
404 iDburi = HBufC::NewL(VPbkContactStoreUris::DefaultCntDbUri().Length()); |
396 //set the DBUri to the default value. |
405 //set the DBUri to the default value. |
397 iDburi->Des().Copy(VPbkContactStoreUris::DefaultCntDbUri()); |
406 iDburi->Des().Copy(VPbkContactStoreUris::DefaultCntDbUri()); |
398 //get the number of entries in the map |
407 //get the number of entries in the map |
447 } |
456 } |
448 else |
457 else |
449 { |
458 { |
450 //if the key is not uri and is not a contact id |
459 //if the key is not uri and is not a contact id |
451 //search for the field |
460 //search for the field |
452 if(CSearchFields::GetIdFromFieldKey(fieldKey) == -1) |
461 if(CSearchFields::GetIdFromFieldKey(fieldKey) != -1) |
453 { |
462 /* { |
454 TBuf<25> buff; |
463 TBuf<25> buff; |
455 buff.Copy(fieldKey); |
464 buff.Copy(fieldKey); |
456 TBuf<KMaxName> errmsg(KAddInvalidFieldKey); |
465 TBuf<KMaxName> errmsg(KAddInvalidFieldKey); |
457 errmsg.Append(buff); |
466 errmsg.Append(buff); |
458 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
467 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
459 TLiwVariant(errmsg))); |
468 TLiwVariant(errmsg))); |
460 User::Leave(KErrArgument); |
469 User::Leave(KErrArgument); |
461 } |
470 } |
|
471 else*/ |
|
472 { |
462 aMap->FindL(fieldKey,fieldVal); |
473 aMap->FindL(fieldKey,fieldVal); |
463 if(EVariantTypeMap == fieldVal.TypeId()) |
474 if(EVariantTypeMap == fieldVal.TypeId()) |
464 { |
475 { |
465 const CLiwMap* pMap = fieldVal.AsMap(); |
476 const CLiwMap* pMap = fieldVal.AsMap(); |
466 if(pMap) |
477 if(pMap) |
501 } |
512 } |
502 TBool date = EFalse; |
513 TBool date = EFalse; |
503 //Set contact item field value |
514 //Set contact item field value |
504 if(pMap->FindL(KFieldValue, valueVar)) |
515 if(pMap->FindL(KFieldValue, valueVar)) |
505 { |
516 { |
506 if((fieldKey.Compare(KDate) == 0 || (fieldKey.Compare(KAnniversary) == 0))) |
517 if(fieldKey.Compare(KXspid) == 0) |
|
518 { |
|
519 xspid = ETrue; |
|
520 if(EVariantTypeList != valueVar.TypeId()) |
|
521 { |
|
522 if(EVariantTypeDesC == valueVar.TypeId()) |
|
523 { |
|
524 //xspidIsDes = ETrue; |
|
525 CLiwList* xspidList = NULL; |
|
526 xspidList = CLiwDefaultList::NewL(); |
|
527 /* TPtrC val = valueVar.AsDes(); |
|
528 |
|
529 TBuf<1000> bufVal; |
|
530 bufVal.Copy(val); |
|
531 HBufC* xspidVal = bufVal.AllocLC();*/ |
|
532 |
|
533 xspidList->AppendL(valueVar); |
|
534 valueVar.Reset(); |
|
535 valueVar.Set(xspidList); |
|
536 } |
|
537 else |
|
538 { |
|
539 TPtr16 err(iErrorMess->Des()); |
|
540 TBuf<KMaxName> buf; |
|
541 buf.Copy(valueVar.AsData()); |
|
542 err.Append(KAddCnt); |
|
543 err.Append(buf); |
|
544 err.Append(KAddInvalidTime); |
|
545 |
|
546 aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(*iErrorMess) ) ); |
|
547 CleanupStack::Pop(&nextVar); |
|
548 nextVar.Reset(); |
|
549 CleanupStack::Pop(&valueVar); |
|
550 valueVar.Reset(); |
|
551 CleanupStack::Pop(&labelVar); |
|
552 labelVar.Reset(); |
|
553 CleanupStack::Pop(&fieldVal); |
|
554 fieldVal.Reset(); |
|
555 err.Delete(0,iErrorMess->Length()); |
|
556 User::Leave(KErrArgument); |
|
557 } |
|
558 } |
|
559 } |
|
560 if((fieldKey.Compare(KDate) == 0 || (fieldKey.Compare(KAnniversary) == 0))) // || (fieldKey.Compare(KBirthDay) == 0)) |
507 { |
561 { |
508 if(EVariantTypeTTime != valueVar.TypeId()) |
562 if(EVariantTypeTTime != valueVar.TypeId()) |
509 { |
563 { |
510 TPtr16 err(iErrorMess->Des()); |
564 TPtr16 err(iErrorMess->Des()); |
511 TBuf<KMaxName> buf; |
565 TBuf<KMaxName> buf; |
558 { |
611 { |
559 field->SetFieldParamsL(fieldKey, |
612 field->SetFieldParamsL(fieldKey, |
560 labelVar.AsDes(), |
613 labelVar.AsDes(), |
561 KNullDesC); |
614 KNullDesC); |
562 field->SetDateTime(valueVar.AsTTime()); |
615 field->SetDateTime(valueVar.AsTTime()); |
|
616 } |
|
617 else if(xspid && !xspidIsDes) |
|
618 { |
|
619 RPointerArray<HBufC> xspidArray; |
|
620 const CLiwList* xspidList = valueVar.AsList(); |
|
621 TInt count = xspidList->Count(); |
|
622 for(int i =0; i< count; i++) |
|
623 { |
|
624 TLiwVariant xspidVal; |
|
625 if(xspidList->AtL(i,xspidVal)) |
|
626 { |
|
627 TPtrC ptrVal = xspidVal.AsDes(); |
|
628 HBufC *pHeap1 = ptrVal.AllocLC(); |
|
629 xspidArray.Append(pHeap1); |
|
630 TInt len = pHeap1->Find(_L(":")); |
|
631 if(len == -1) |
|
632 { |
|
633 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
634 TLiwVariant(KAddXspidInvalidFormat))); |
|
635 User::Leave(KErrArgument); |
|
636 } |
|
637 CleanupStack::Pop(pHeap1); |
|
638 } |
|
639 } |
|
640 field->SetXspidDataL(fieldKey, |
|
641 labelVar.AsDes(), |
|
642 xspidArray); |
|
643 xspid = EFalse; |
563 } |
644 } |
564 else |
645 else |
565 { |
646 { |
566 field->SetFieldParamsL(fieldKey, |
647 field->SetFieldParamsL(fieldKey, |
567 labelVar.AsDes(), |
648 labelVar.AsDes(), |
635 for( TInt i=0;i<fieldCount;i++ ) |
717 for( TInt i=0;i<fieldCount;i++ ) |
636 { |
718 { |
637 contactfield = aContact->FieldAt(i); |
719 contactfield = aContact->FieldAt(i); |
638 if(contactfield) |
720 if(contactfield) |
639 { |
721 { |
640 contactfield->GetFieldDataL(fieldKey, fieldLabel, fieldValue); |
722 contactfield->GetFieldDataL(fieldKey, fieldLabel, fieldValue); |
641 if(!(fieldKey.Compare(KDate) == 0 || fieldKey.Compare(KAnniversary) == 0)) |
723 if(fieldKey.Compare(KXspid) == 0) |
|
724 { |
|
725 RPointerArray<HBufC> xspidArr; |
|
726 contactfield->GetXspidDataL(xspidArr); |
|
727 for(TInt j=0;j<xspidArr.Count(); j++) |
|
728 { |
|
729 HBufC* xspidVal = xspidArr[j]; |
|
730 //HBufC* xspidBufVal = xspidVal.AllocL(); |
|
731 if(xspidVal->Length() > GetFieldMaxLength(CSearchFields::GetIdFromFieldKey(fieldKey), *iDburi)) |
|
732 { |
|
733 TPtr16 err(iErrorMess->Des()); |
|
734 TBuf<KMaxName> fld; |
|
735 fld.Copy(fieldKey); |
|
736 err.Append(_L("Contacts : Add : Field Value too long for key : ")); |
|
737 err.Append(fld); |
|
738 |
|
739 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
740 TLiwVariant(*iErrorMess))); |
|
741 |
|
742 err.Delete(0,iErrorMess->Length()); |
|
743 User::Leave(KErrArgument); |
|
744 } |
|
745 } |
|
746 } |
|
747 else if(!(fieldKey.Compare(KDate) == 0 || fieldKey.Compare(KAnniversary) == 0)) |
642 { |
748 { |
643 if(fieldValue.Length() > GetFieldMaxLength(CSearchFields::GetIdFromFieldKey(fieldKey), *iDburi)) |
749 if(fieldValue.Length() > GetFieldMaxLength(CSearchFields::GetIdFromFieldKey(fieldKey), *iDburi)) |
644 { |
750 { |
645 TPtr16 err(iErrorMess->Des()); |
751 TPtr16 err(iErrorMess->Des()); |
646 TBuf<KMaxName> fld; |
752 TBuf<KMaxName> fld; |
792 { |
898 { |
793 GetListCommandL(aInParamList, |
899 GetListCommandL(aInParamList, |
794 aOutParamList, |
900 aOutParamList, |
795 aCallback, |
901 aCallback, |
796 aCmdOptions, |
902 aCmdOptions, |
797 transId); |
903 transId, |
|
904 EGetList); |
798 } |
905 } |
|
906 //Passing arguments for GetIds command |
|
907 else if( aCmdName.CompareF( KCmdGetIds ) == 0 ) |
|
908 { |
|
909 GetListCommandL(aInParamList, |
|
910 aOutParamList, |
|
911 aCallback, |
|
912 aCmdOptions, |
|
913 transId, |
|
914 EGetIds); |
|
915 } |
799 else |
916 else |
800 { |
917 { |
801 //Leave with the error code |
918 //Leave with the error code |
802 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
919 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
803 TLiwVariant(KCommandNotSupported))); |
920 TLiwVariant(KCommandNotSupported))); |
821 void CContactInterface:: |
938 void CContactInterface:: |
822 GetListCommandL(const CLiwGenericParamList& aInParamList, |
939 GetListCommandL(const CLiwGenericParamList& aInParamList, |
823 CLiwGenericParamList& aOutParamList, |
940 CLiwGenericParamList& aOutParamList, |
824 MLiwNotifyCallback* aCallback, |
941 MLiwNotifyCallback* aCallback, |
825 TUint aCmdOptions, |
942 TUint aCmdOptions, |
826 TInt aTransId) |
943 TInt aTransId, TCmdType aVal) |
827 { |
944 { |
828 const TLiwGenericParam* paramContentType = NULL; |
945 const TLiwGenericParam* paramContentType = NULL; |
829 const TLiwGenericParam* paramGetListData = NULL; |
946 const TLiwGenericParam* paramGetListData = NULL; |
830 const TLiwGenericParam* paramGetListSortOrder = NULL; |
947 const TLiwGenericParam* paramGetListSortOrder = NULL; |
831 |
948 |
938 TPtrC dbUri(VPbkContactStoreUris::DefaultCntDbUri()); |
1055 TPtrC dbUri(VPbkContactStoreUris::DefaultCntDbUri()); |
939 //Switch based on the Ttype var value |
1056 //Switch based on the Ttype var value |
940 switch(listType) |
1057 switch(listType) |
941 { |
1058 { |
942 case EDatabase: |
1059 case EDatabase: |
|
1060 if(aVal == EGetIds) |
|
1061 { |
|
1062 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
1063 TLiwVariant(KGetIdsInvalidContentType))); |
|
1064 User::Leave(KErrArgument); |
|
1065 } |
943 //In case it is GetList of dabases, the call is synchronous |
1066 //In case it is GetList of dabases, the call is synchronous |
944 iter = CContactIter::NewL(); |
1067 iter = CContactIter::NewL(); |
945 CleanupStack::PushL(iter); |
1068 CleanupStack::PushL(iter); |
946 iContactService->GetListL(*iter); |
1069 iContactService->GetListL(*iter); |
947 CleanupStack::Pop(iter); |
1070 CleanupStack::Pop(iter); |
996 listType, |
1119 listType, |
997 *cntid, |
1120 *cntid, |
998 KNullDesC, |
1121 KNullDesC, |
999 NULL, |
1122 NULL, |
1000 EAsc, |
1123 EAsc, |
1001 dbUri); |
1124 dbUri,aVal); |
1002 |
1125 |
1003 CleanupStack :: Pop(contactCallback); |
1126 CleanupStack :: Pop(contactCallback); |
1004 CleanupStack::PopAndDestroy(cntid); |
1127 CleanupStack::PopAndDestroy(cntid); |
1005 } |
1128 } |
1006 else |
1129 else |
1007 { |
1130 { |
1008 //it is assumed that the call is synchronous |
1131 if(aVal == EGetList) |
|
1132 { |
|
1133 //it is assumed that the call is synchronous |
1009 CContactIter* iter = |
1134 CContactIter* iter = |
1010 iContactService->GetListL(listType, |
1135 iContactService->GetListL(listType, |
1011 *cntid, |
1136 *cntid, |
1012 KNullDesC, |
1137 KNullDesC, |
1013 NULL, |
1138 NULL, |
1014 EAsc, |
1139 EAsc, |
1015 dbUri); |
1140 dbUri, |
|
1141 aVal); |
1016 aOutParamList.AppendL(TLiwGenericParam( KErrorCode, |
1142 aOutParamList.AppendL(TLiwGenericParam( KErrorCode, |
1017 TLiwVariant((TInt32)SErrNone))); |
1143 TLiwVariant((TInt32)SErrNone))); |
1018 //Setting the output param |
1144 //Setting the output param |
1019 CContactIterator* iterator=CContactIterator::NewL(iter); |
1145 CContactIterator* iterator=CContactIterator::NewL(iter); |
1020 CleanupStack::PushL(iterator); |
1146 CleanupStack::PushL(iterator); |
1021 aOutParamList.AppendL(TLiwGenericParam(KReturnValue, |
1147 aOutParamList.AppendL(TLiwGenericParam(KReturnValue, |
1022 TLiwVariant(iterator))); |
1148 TLiwVariant(iterator))); |
1023 CleanupStack::Pop(iterator); |
1149 CleanupStack::Pop(iterator); |
1024 iterator->DecRef(); |
1150 iterator->DecRef(); |
|
1151 } |
|
1152 else |
|
1153 { |
|
1154 aOutParamList.AppendL(TLiwGenericParam( KErrorCode, |
|
1155 TLiwVariant((TInt32)SErrBadArgumentType))); |
|
1156 aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage,TLiwVariant(KGetIdsBadArgGrpId) ) ); |
|
1157 } |
1025 CleanupStack::PopAndDestroy(cntid); |
1158 CleanupStack::PopAndDestroy(cntid); |
1026 CleanupStack::Pop(&groupId); |
1159 CleanupStack::Pop(&groupId); |
1027 groupId.Reset(); |
1160 groupId.Reset(); |
1028 CleanupStack::Pop(&uriofDb); |
1161 CleanupStack::Pop(&uriofDb); |
1029 uriofDb.Reset(); |
1162 uriofDb.Reset(); |
1045 listType, |
1178 listType, |
1046 ptrToCntId, |
1179 ptrToCntId, |
1047 KNullDesC, |
1180 KNullDesC, |
1048 NULL, |
1181 NULL, |
1049 EAsc, |
1182 EAsc, |
1050 dbUri); |
1183 dbUri, |
|
1184 aVal); |
1051 |
1185 |
1052 CleanupStack :: Pop(contactCallback); |
1186 CleanupStack :: Pop(contactCallback); |
1053 } |
1187 } |
1054 else |
1188 else |
1055 { |
1189 { |
1056 //it is assumed that the call is synchronous |
1190 if(aVal == EGetList) |
|
1191 { |
|
1192 //it is assumed that the call is synchronous |
1057 CContactIter* iter = |
1193 CContactIter* iter = |
1058 iContactService->GetListL(listType, |
1194 iContactService->GetListL(listType, |
1059 ptrToCntId, |
1195 ptrToCntId, |
1060 KNullDesC, |
1196 KNullDesC, |
1061 NULL, |
1197 NULL, |
1062 EAsc, |
1198 EAsc, |
1063 dbUri); |
1199 dbUri, |
|
1200 aVal); |
1064 //Setting the output param |
1201 //Setting the output param |
1065 CContactIterator* iterator=CContactIterator::NewL(iter); |
1202 CContactIterator* iterator=CContactIterator::NewL(iter); |
1066 CleanupStack::PushL(iterator); |
1203 CleanupStack::PushL(iterator); |
1067 aOutParamList.AppendL(TLiwGenericParam( KReturnValue, |
1204 aOutParamList.AppendL(TLiwGenericParam( KReturnValue, |
1068 TLiwVariant(iterator) )); |
1205 TLiwVariant(iterator) )); |
1069 CleanupStack::Pop(iterator); |
1206 CleanupStack::Pop(iterator); |
1070 iterator->DecRef(); |
1207 iterator->DecRef(); |
|
1208 } |
|
1209 else |
|
1210 { |
|
1211 //call the GetIds() service api |
|
1212 RPointerArray<HBufC8>& arrayid = |
|
1213 iContactService->GetIdsL(listType, |
|
1214 KNullDesC, |
|
1215 NULL, |
|
1216 EAsc, |
|
1217 dbUri, |
|
1218 aVal); |
|
1219 |
|
1220 |
|
1221 |
|
1222 |
|
1223 aOutParamList.AppendL(TLiwGenericParam( KErrorCode, |
|
1224 TLiwVariant((TInt32)SErrNone))); |
|
1225 //Setting the output param |
|
1226 if(arrayid.Count() > 0) |
|
1227 { |
|
1228 CLiwList* iList = NULL; |
|
1229 iList = CLiwDefaultList::NewL(); |
|
1230 TLiwVariant outputVal; |
|
1231 TInt count = arrayid.Count(); |
|
1232 TInt i; |
|
1233 for(i=0; i<count; i++) |
|
1234 { |
|
1235 TDesC8* idVal = arrayid[i]; |
|
1236 HBufC* cntIdUnicode = HBufC::NewL(idVal->Length()); |
|
1237 CleanupStack :: PushL(cntIdUnicode); |
|
1238 cntIdUnicode->Des().Copy(*idVal); |
|
1239 CContactInterfaceCallback::ContactIDToUTF(cntIdUnicode); |
|
1240 outputVal.Set(*cntIdUnicode); |
|
1241 iList->AppendL(outputVal); |
|
1242 CleanupStack :: Pop(cntIdUnicode); |
|
1243 } |
|
1244 CLiwMap* pFieldLinkedMap = CLiwDefaultMap::NewL(); |
|
1245 CleanupClosePushL(*pFieldLinkedMap); |
|
1246 pFieldLinkedMap->InsertL(KIdsLabel,TLiwVariant(iList)); |
|
1247 |
|
1248 aOutParamList.AppendL(TLiwGenericParam(KReturnValue, |
|
1249 TLiwVariant(pFieldLinkedMap))); |
|
1250 CleanupStack::PopAndDestroy(pFieldLinkedMap); |
|
1251 arrayid.ResetAndDestroy(); |
|
1252 } |
|
1253 } |
1071 CleanupStack::Pop(&groupId); |
1254 CleanupStack::Pop(&groupId); |
1072 groupId.Reset(); |
1255 groupId.Reset(); |
1073 CleanupStack::Pop(&uriofDb); |
1256 CleanupStack::Pop(&uriofDb); |
1074 uriofDb.Reset(); |
1257 uriofDb.Reset(); |
1075 return; |
1258 return; |
1104 contactCallback->SetParams(aCallback, |
1287 contactCallback->SetParams(aCallback, |
1105 aTransId, |
1288 aTransId, |
1106 &aInParamList); |
1289 &aInParamList); |
1107 //Call GetList in case of retrieval of a |
1290 //Call GetList in case of retrieval of a |
1108 //single contact whose id is known |
1291 //single contact whose id is known |
1109 iContactService->GetListL(contactCallback, |
1292 iContactService->GetListL(contactCallback, |
1110 aTransId, |
1293 aTransId, |
1111 listType, |
1294 listType, |
1112 *cntid, |
1295 *cntid, |
1113 KNullDesC, |
1296 KNullDesC, |
1114 NULL, |
1297 NULL, |
1115 EAsc, |
1298 EAsc, |
1116 dbUri); |
1299 dbUri, |
1117 |
1300 aVal); |
1118 CleanupStack :: Pop(contactCallback); |
1301 CleanupStack :: Pop(contactCallback); |
1119 CleanupStack::PopAndDestroy(cntid); |
1302 CleanupStack::PopAndDestroy(cntid); |
1120 } |
1303 } |
1121 else |
1304 else |
1122 { |
1305 { |
1123 //it is assumed that the call is synchronous |
1306 //it is assumed that the call is synchronous |
1124 CContactIter* iter = |
1307 if(aVal == EGetList) |
|
1308 { |
|
1309 CContactIter* iter = |
1125 iContactService->GetListL(listType, |
1310 iContactService->GetListL(listType, |
1126 *cntid, |
1311 *cntid, |
1127 KNullDesC, |
1312 KNullDesC, |
1128 NULL, |
1313 NULL, |
1129 EAsc, |
1314 EAsc, |
1130 dbUri); |
1315 dbUri, |
|
1316 aVal); |
1131 aOutParamList.AppendL(TLiwGenericParam( KErrorCode, |
1317 aOutParamList.AppendL(TLiwGenericParam( KErrorCode, |
1132 TLiwVariant((TInt32)SErrNone))); |
1318 TLiwVariant((TInt32)SErrNone))); |
1133 //Setting the output param |
1319 //Setting the output param |
1134 CContactIterator* iterator=CContactIterator::NewL(iter); |
1320 CContactIterator* iterator=CContactIterator::NewL(iter); |
1135 CleanupStack::PushL(iterator); |
1321 CleanupStack::PushL(iterator); |
1136 aOutParamList.AppendL(TLiwGenericParam(KReturnValue, |
1322 aOutParamList.AppendL(TLiwGenericParam(KReturnValue, |
1137 TLiwVariant(iterator))); |
1323 TLiwVariant(iterator))); |
1138 CleanupStack::Pop(iterator); |
1324 CleanupStack::Pop(iterator); |
1139 iterator->DecRef(); |
1325 iterator->DecRef(); |
|
1326 } |
|
1327 else |
|
1328 { |
|
1329 aOutParamList.AppendL(TLiwGenericParam( KErrorCode, |
|
1330 TLiwVariant((TInt32)SErrBadArgumentType))); |
|
1331 aOutParamList.AppendL( TLiwGenericParam ( KErrorMessage, |
|
1332 TLiwVariant(KGetIdsBadArgCntId) ) ); |
|
1333 } |
1140 CleanupStack::PopAndDestroy(cntid); |
1334 CleanupStack::PopAndDestroy(cntid); |
1141 CleanupStack::Pop(&contactId); |
1335 CleanupStack::Pop(&contactId); |
1142 contactId.Reset(); |
1336 contactId.Reset(); |
1143 CleanupStack::Pop(&groupId); |
1337 CleanupStack::Pop(&groupId); |
1144 groupId.Reset(); |
1338 groupId.Reset(); |
1239 listType, |
1433 listType, |
1240 ptrToCntId, |
1434 ptrToCntId, |
1241 srchVal, |
1435 srchVal, |
1242 searchFields, |
1436 searchFields, |
1243 srtOrder, |
1437 srtOrder, |
1244 dbUri); |
1438 dbUri, |
|
1439 aVal); |
1245 |
1440 |
1246 CleanupStack :: Pop(contactCallback); |
1441 CleanupStack :: Pop(contactCallback); |
1247 } |
1442 } |
1248 else |
1443 else |
1249 { |
1444 { |
1250 //it is assumed that the call is synchronous |
1445 //it is assumed that the call is synchronous |
|
1446 if(aVal == EGetList) |
|
1447 { |
1251 CContactIter* iter = |
1448 CContactIter* iter = |
1252 iContactService->GetListL(listType, |
1449 iContactService->GetListL(listType, |
1253 ptrToCntId, |
1450 ptrToCntId, |
1254 srchVal, |
1451 srchVal, |
1255 searchFields, |
1452 searchFields, |
1256 srtOrder, |
1453 srtOrder, |
1257 dbUri); |
1454 dbUri, |
|
1455 aVal); |
1258 |
1456 |
1259 aOutParamList.AppendL(TLiwGenericParam(KErrorCode, |
1457 aOutParamList.AppendL(TLiwGenericParam(KErrorCode, |
1260 TLiwVariant((TInt32)SErrNone))); |
1458 TLiwVariant((TInt32)SErrNone))); |
1261 |
1459 |
1262 //Setting the output param |
1460 //Setting the output param |
1263 CContactIterator* iterator=CContactIterator::NewL(iter); |
1461 CContactIterator* iterator=CContactIterator::NewL(iter); |
1264 CleanupStack::PushL(iterator); |
1462 CleanupStack::PushL(iterator); |
1265 aOutParamList.AppendL(TLiwGenericParam(KReturnValue, |
1463 aOutParamList.AppendL(TLiwGenericParam(KReturnValue, |
1266 TLiwVariant(iterator))); |
1464 TLiwVariant(iterator))); |
1267 CleanupStack::Pop(iterator); |
1465 CleanupStack::Pop(iterator); |
1268 iterator->DecRef(); |
1466 iterator->DecRef(); |
|
1467 } |
|
1468 else |
|
1469 { |
|
1470 RPointerArray<HBufC8>& arrayid = |
|
1471 iContactService->GetIdsL(listType, |
|
1472 srchVal, |
|
1473 searchFields, |
|
1474 srtOrder, |
|
1475 dbUri, |
|
1476 aVal); |
|
1477 aOutParamList.AppendL(TLiwGenericParam( KErrorCode, |
|
1478 TLiwVariant((TInt32)SErrNone))); |
|
1479 //Setting the output param |
|
1480 if(arrayid.Count() > 0) |
|
1481 { |
|
1482 CLiwList* iList = NULL; |
|
1483 iList = CLiwDefaultList::NewL(); |
|
1484 TLiwVariant outputVal; |
|
1485 TInt count = arrayid.Count(); |
|
1486 TInt i; |
|
1487 for(i=0; i<count; i++) |
|
1488 { |
|
1489 TDesC8* idVal = arrayid[i]; |
|
1490 HBufC* cntIdUnicode = HBufC::NewL(idVal->Length()); |
|
1491 CleanupStack :: PushL(cntIdUnicode); |
|
1492 cntIdUnicode->Des().Copy(*idVal); |
|
1493 CContactInterfaceCallback::ContactIDToUTF(cntIdUnicode); |
|
1494 outputVal.Set(*cntIdUnicode); |
|
1495 iList->AppendL(outputVal); |
|
1496 CleanupStack :: Pop(cntIdUnicode); |
|
1497 } |
|
1498 CLiwMap* pFieldLinkedMap = CLiwDefaultMap::NewL(); |
|
1499 CleanupClosePushL(*pFieldLinkedMap); |
|
1500 pFieldLinkedMap->InsertL(KIdsLabel,TLiwVariant(iList)); |
|
1501 |
|
1502 aOutParamList.AppendL(TLiwGenericParam(KReturnValue, |
|
1503 TLiwVariant(pFieldLinkedMap))); |
|
1504 CleanupStack::PopAndDestroy(pFieldLinkedMap); |
|
1505 arrayid.ResetAndDestroy(); |
|
1506 } |
|
1507 |
|
1508 } |
1269 CleanupStack::Pop(&order); |
1509 CleanupStack::Pop(&order); |
1270 order.Reset(); |
1510 order.Reset(); |
1271 CleanupStack::Pop(&searchFieldKeys); |
1511 CleanupStack::Pop(&searchFieldKeys); |
1272 searchFieldKeys.Reset(); |
1512 searchFieldKeys.Reset(); |
1273 CleanupStack::Pop(&searchVal); |
1513 CleanupStack::Pop(&searchVal); |
1467 CleanupStack :: Pop(contactCallback); |
1707 CleanupStack :: Pop(contactCallback); |
1468 } |
1708 } |
1469 else |
1709 else |
1470 { |
1710 { |
1471 //it is assumed that the call is synchronous |
1711 //it is assumed that the call is synchronous |
1472 TRAPD(err,iContactService->AddL(contact, |
1712 |
1473 KNullDesC8, //group id |
1713 HBufC8* cntIdVal = NULL; |
1474 KNullDesC, //group label |
1714 TRAPD(err, cntIdVal = iContactService->AddL(contact, |
1475 *iDburi)); |
1715 KNullDesC8, //group id |
|
1716 KNullDesC, //group label |
|
1717 *iDburi)); |
|
1718 |
|
1719 |
1476 if(err == KErrNotSupported) |
1720 if(err == KErrNotSupported) |
1477 { |
1721 { |
1478 TInt errkey = iContactService->GetErrKey(); |
1722 TInt errkey = iContactService->GetErrKey(); |
1479 TPtrC8 ptr = CSearchFields::GetFieldKeyFromId(errkey); |
1723 TPtrC8 ptr = CSearchFields::GetFieldKeyFromId(errkey); |
1480 TBuf<25> buff; |
1724 TBuf<25> buff; |
1482 TBuf<KMaxName> errmsg(KAddFieldKeyNotSupported); |
1726 TBuf<KMaxName> errmsg(KAddFieldKeyNotSupported); |
1483 errmsg.Append(buff); |
1727 errmsg.Append(buff); |
1484 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
1728 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
1485 TLiwVariant(errmsg))); |
1729 TLiwVariant(errmsg))); |
1486 User::Leave(err); |
1730 User::Leave(err); |
|
1731 } |
|
1732 |
|
1733 if(err == KErrNone) |
|
1734 { |
|
1735 HBufC* cntIdUnicode = HBufC::NewL(cntIdVal->Length()); |
|
1736 CleanupStack :: PushL(cntIdUnicode); |
|
1737 cntIdUnicode->Des().Copy(*cntIdVal); |
|
1738 delete cntIdVal; |
|
1739 cntIdVal = NULL; |
|
1740 CContactInterfaceCallback::ContactIDToUTF(cntIdUnicode); |
|
1741 aOutParamList.AppendL(TLiwGenericParam(KReturnValue,TLiwVariant(*cntIdUnicode))); |
|
1742 CleanupStack :: Pop(cntIdUnicode); |
1487 } |
1743 } |
1488 } |
1744 else |
|
1745 { |
|
1746 User::Leave(err); |
|
1747 } |
|
1748 } |
|
1749 |
1489 CleanupStack::Pop(contact); |
1750 CleanupStack::Pop(contact); |
1490 } //end of if pMap |
1751 } //end of if pMap |
1491 else |
1752 else |
1492 { |
1753 { |
1493 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
1754 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
1547 //get the values for dburi, group id and group label |
1809 //get the values for dburi, group id and group label |
1548 if(EFalse != pMap->FindL(KGroupLabel,valueGrplabel)) |
1810 if(EFalse != pMap->FindL(KGroupLabel,valueGrplabel)) |
1549 { |
1811 { |
1550 if(EVariantTypeDesC != valueGrplabel.TypeId()) |
1812 if(EVariantTypeDesC != valueGrplabel.TypeId()) |
1551 { |
1813 { |
|
1814 CleanupStack::Pop(&valueUri); |
|
1815 valueUri.Reset(); |
1552 CleanupStack::Pop(&valueGrplabel); |
1816 CleanupStack::Pop(&valueGrplabel); |
1553 valueGrplabel.Reset(); |
1817 valueGrplabel.Reset(); |
1554 CleanupStack::Pop(&valueGrpid); |
1818 CleanupStack::Pop(&valueGrpid); |
1555 valueGrpid.Reset(); |
1819 valueGrpid.Reset(); |
1556 |
1820 |
1614 TBuf<KMaxName> errmsg(KAddFieldKeyNotSupported); |
1879 TBuf<KMaxName> errmsg(KAddFieldKeyNotSupported); |
1615 errmsg.Append(buff); |
1880 errmsg.Append(buff); |
1616 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
1881 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
1617 TLiwVariant(errmsg))); |
1882 TLiwVariant(errmsg))); |
1618 User::Leave(err); |
1883 User::Leave(err); |
1619 } |
1884 } |
|
1885 if(err == KErrNone) |
|
1886 { |
|
1887 if(grpId) |
|
1888 { |
|
1889 HBufC* grpIdUnicode = HBufC::NewL(grpId->Length()); |
|
1890 CleanupStack :: PushL(grpIdUnicode); |
|
1891 grpIdUnicode->Des().Copy(*grpId); |
|
1892 delete grpId; |
|
1893 grpId = NULL; |
|
1894 CContactInterfaceCallback::ContactIDToUTF(grpIdUnicode); |
|
1895 |
|
1896 aOutParamList.AppendL(TLiwGenericParam(KReturnValue,TLiwVariant(*grpIdUnicode))); |
|
1897 CleanupStack :: Pop(grpIdUnicode); |
|
1898 } |
|
1899 } |
|
1900 else |
|
1901 { |
|
1902 User::Leave(err); |
|
1903 } |
|
1904 |
1620 |
1905 |
1621 } |
1906 } |
1622 CleanupStack :: PopAndDestroy(groupId); |
1907 CleanupStack :: PopAndDestroy(groupId); |
1623 CleanupStack::Pop(&valueUri); |
1908 CleanupStack::Pop(&valueUri); |
1624 valueUri.Reset(); |
1909 valueUri.Reset(); |