47 { (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactAddress::FieldStreet).operator QString(), (TInt) CCreatorEngine::EAddress}, |
48 { (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactAddress::FieldStreet).operator QString(), (TInt) CCreatorEngine::EAddress}, |
48 { (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactAddress::FieldLocality).operator QString(), (TInt) CCreatorEngine::ECity}, |
49 { (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactAddress::FieldLocality).operator QString(), (TInt) CCreatorEngine::ECity}, |
49 { (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactAddress::FieldRegion).operator QString(), (TInt) CCreatorEngine::EState}, |
50 { (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactAddress::FieldRegion).operator QString(), (TInt) CCreatorEngine::EState}, |
50 { (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactAddress::FieldPostcode).operator QString(), (TInt) CCreatorEngine::EPostcode}, |
51 { (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactAddress::FieldPostcode).operator QString(), (TInt) CCreatorEngine::EPostcode}, |
51 { (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactAddress::FieldCountry).operator QString(), (TInt) CCreatorEngine::ECountry}, |
52 { (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactAddress::FieldCountry).operator QString(), (TInt) CCreatorEngine::ECountry}, |
|
53 { (QContactAddress::DefinitionName).operator QString(), "", (QContactAddress::FieldStreet).operator QString(), (TInt) CCreatorEngine::EAddress}, |
|
54 { (QContactAddress::DefinitionName).operator QString(), "", (QContactAddress::FieldLocality).operator QString(), (TInt) CCreatorEngine::ECity}, |
|
55 { (QContactAddress::DefinitionName).operator QString(), "", (QContactAddress::FieldRegion).operator QString(), (TInt) CCreatorEngine::EState}, |
|
56 { (QContactAddress::DefinitionName).operator QString(), "", (QContactAddress::FieldPostcode).operator QString(), (TInt) CCreatorEngine::EPostcode}, |
|
57 { (QContactAddress::DefinitionName).operator QString(), "", (QContactAddress::FieldCountry).operator QString(), (TInt) CCreatorEngine::ECountry}, |
52 { (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactAddress::FieldStreet).operator QString(), (TInt) CCreatorEngine::EAddress}, |
58 { (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactAddress::FieldStreet).operator QString(), (TInt) CCreatorEngine::EAddress}, |
53 { (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactAddress::FieldLocality).operator QString(), (TInt) CCreatorEngine::ECity}, |
59 { (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactAddress::FieldLocality).operator QString(), (TInt) CCreatorEngine::ECity}, |
54 { (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactAddress::FieldRegion).operator QString(), (TInt) CCreatorEngine::EState}, |
60 { (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactAddress::FieldRegion).operator QString(), (TInt) CCreatorEngine::EState}, |
55 { (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactAddress::FieldPostcode).operator QString(), (TInt) CCreatorEngine::EPostcode}, |
61 { (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactAddress::FieldPostcode).operator QString(), (TInt) CCreatorEngine::EPostcode}, |
56 { (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactAddress::FieldCountry).operator QString(), (TInt) CCreatorEngine::ECountry}, |
62 { (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactAddress::FieldCountry).operator QString(), (TInt) CCreatorEngine::ECountry}, |
62 { (QContactFamily::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactFamily::FieldSpouse).operator QString(), (TInt) CCreatorEngine::EFirstName}, |
68 { (QContactFamily::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactFamily::FieldSpouse).operator QString(), (TInt) CCreatorEngine::EFirstName}, |
63 { (QContactFamily::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactFamily::FieldChildren).operator QString(), (TInt) CCreatorEngine::EFirstName}, |
69 { (QContactFamily::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactFamily::FieldChildren).operator QString(), (TInt) CCreatorEngine::EFirstName}, |
64 { (QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactName::FieldCustomLabel).operator QString(), (TInt) CCreatorEngine::EFirstName} |
70 { (QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactName::FieldCustomLabel).operator QString(), (TInt) CCreatorEngine::EFirstName} |
65 }; |
71 }; |
66 |
72 |
67 /*TInt CreatorVPbkBinaryFields[] = { |
73 |
68 R_VPBK_FIELD_TYPE_CALLEROBJIMG//, |
|
69 //R_VPBK_FIELD_TYPE_THUMBNAILPATH |
|
70 };*/ |
|
71 |
|
72 /*QString CreatorPbkDateTimeFields[] = { |
|
73 QContactAnniversary::DefinitionName//R_VPBK_FIELD_TYPE_ANNIVERSARY |
|
74 };*/ |
|
75 |
|
76 //---------------------------------------------------------------------------- |
|
77 |
|
78 /* |
|
79 typedef struct{ |
74 typedef struct{ |
80 QString iFieldContext; |
75 QString iFieldContext; |
81 QString iFieldString; |
76 QString iFieldString; |
82 }PhoneNumInfo; |
77 }PhoneNumInfo; |
83 PhoneNumInfo CreatorPhoneNumberFields[] = |
78 PhoneNumInfo CreatorPhoneNumberFields[] = |
84 { |
79 { |
85 { QContactPhoneNumber::ContextHome, QContactPhoneNumber::SubTypeLandline}, |
80 { "", "Landline"}, |
86 { QContactPhoneNumber::ContextWork, QContactPhoneNumber::SubTypeLandline}, |
|
87 { QContactPhoneNumber::ContextHome, QContactPhoneNumber::SubTypeMobile}, |
|
88 { QContactPhoneNumber::ContextWork, QContactPhoneNumber::SubTypeMobile}, |
|
89 { QContactPhoneNumber::ContextHome, QContactPhoneNumber::SubTypeFacsimile}, |
|
90 { QContactPhoneNumber::ContextWork, QContactPhoneNumber::SubTypeFacsimile}, |
|
91 { QContactPhoneNumber::ContextWork, QContactPhoneNumber::SubTypePager }, |
|
92 { QContactPhoneNumber::ContextHome, QContactPhoneNumber::SubTypeVideo }, |
|
93 { QContactPhoneNumber::ContextWork, QContactPhoneNumber::SubTypeVideo }, |
|
94 { QContactPhoneNumber::ContextHome, QContactPhoneNumber::SubTypeVoice }, |
|
95 { QContactPhoneNumber::ContextWork, QContactPhoneNumber::SubTypeVoice }, |
|
96 { QContactPhoneNumber::ContextWork, QContactPhoneNumber::SubTypeAssistant }, |
|
97 { QContactPhoneNumber::ContextHome, QContactPhoneNumber::SubTypeCar } |
|
98 }; |
|
99 |
|
100 */ |
|
101 typedef struct{ |
|
102 QString iFieldContext; |
|
103 QString iFieldString; |
|
104 }PhoneNumInfo; |
|
105 PhoneNumInfo CreatorPhoneNumberFields[] = |
|
106 { |
|
107 { "Home", "Landline"}, |
81 { "Home", "Landline"}, |
108 { "Work", "Landline"}, |
82 { "Work", "Landline"}, |
|
83 { "","Mobile"}, |
109 { "Home","Mobile"}, |
84 { "Home","Mobile"}, |
110 { "Work", "Mobile"}, |
85 { "Work", "Mobile"}, |
111 { "Home", "Facsimile"}, |
86 { "Home", "Facsimile"}, |
112 { "Work", "Facsimile"}, |
87 { "Work", "Facsimile"}, |
113 { "Work", "Pager"}, |
88 { "Work", "Pager"}, |
238 } |
194 } |
239 } |
195 } |
240 |
196 |
241 //---------------------------------------------------------------------------- |
197 //---------------------------------------------------------------------------- |
242 |
198 |
243 TBool CCreatorPhonebook::AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries) |
|
244 { |
|
245 LOGSTRING("Creator: CCreatorPhonebook::AskDataFromUserL"); |
|
246 |
|
247 TBool ret = CCreatorPhonebookBase::AskDataFromUserL(aCommand, aNumberOfEntries); |
|
248 |
|
249 if(ret && aCommand == ECmdCreatePhoneBookEntryContacts && !iDefaultFieldsSelected) |
|
250 { |
|
251 iAddAllFields = iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Add all the other fields to contacts?")); |
|
252 } |
|
253 return ret; |
|
254 } |
|
255 |
|
256 |
|
257 //---------------------------------------------------------------------------- |
|
258 |
|
259 TInt CCreatorPhonebook::CreateContactEntryL(CCreatorModuleBaseParameters *aParameters) |
199 TInt CCreatorPhonebook::CreateContactEntryL(CCreatorModuleBaseParameters *aParameters) |
260 { |
200 { |
261 TInt err=0; |
201 TInt err = KErrNone; |
262 |
202 delete iParameters; |
263 InitializeContactParamsL(); |
203 iParameters = 0; |
|
204 CPhonebookParameters* parameters = 0; |
|
205 //InitializeContactParamsL(); |
|
206 |
|
207 if( aParameters == 0 ) |
|
208 { |
|
209 InitializeContactParamsL(); |
|
210 parameters = iParameters; |
|
211 } |
|
212 else |
|
213 { |
|
214 parameters = (CPhonebookParameters*) aParameters; |
|
215 } |
|
216 |
264 bool success = false; |
217 bool success = false; |
265 // create a new contact item |
218 // create a new contact item |
266 //iStore = new QContact(); |
|
267 |
|
268 QContact iStore; |
219 QContact iStore; |
269 |
220 |
270 int numberOfFields = iParameters->iContactFields.count(); |
221 int numberOfFields = parameters->iContactFields.count(); |
271 QString phone; |
222 QString phone; |
272 for(int i=0; i< numberOfFields; i++ ) |
223 for(int i=0; i< numberOfFields; i++ ) |
273 { |
224 { |
274 QContactDetail* cntdet = new QContactDetail(iParameters->iContactFields.at(i)); |
225 QContactDetail* cntdet = new QContactDetail(parameters->iContactFields.at(i)); |
275 success = iStore.saveDetail( cntdet ); |
226 success = iStore.saveDetail( cntdet ); |
276 delete cntdet; |
227 delete cntdet; |
277 } |
228 } |
278 |
229 |
279 iContactMngr->saveContact( &iStore ); |
230 iContactMngr->saveContact( &iStore ); |
280 |
231 |
281 iContactsToDelete.Append( (TUint32)iStore.localId() ); |
232 iContactsToDelete.Append( (TUint32)iStore.localId() ); |
282 //delete iStore; |
233 |
|
234 // If this contact has a link id in script (i.e. belongs to a contact-set), we must cache the contact id: |
|
235 if( parameters->ScriptLinkId() > 0 ) |
|
236 { |
|
237 RPointerArray<CCreatorContactSet>& contactsets = ContactLinkCache::Instance()->ContactSets(); |
|
238 TBool setFound(EFalse); |
|
239 for(TInt i = 0; i < contactsets.Count(); ++i ) |
|
240 { |
|
241 if( contactsets[i]->LinkId() == parameters->ScriptLinkId() ) |
|
242 { |
|
243 if( iStore.localId() ) |
|
244 { |
|
245 contactsets[i]->AppendL( iStore.localId() ); |
|
246 iContactLinkArray.AppendL( (TUint32)iStore.localId() ); |
|
247 } |
|
248 setFound = ETrue; |
|
249 break; |
|
250 } |
|
251 } |
|
252 if( !setFound ) |
|
253 { |
|
254 LOGSTRING2("Error: Contact set id %d not found.", parameters->ScriptLinkId()); |
|
255 } |
|
256 } |
|
257 |
283 return err; |
258 return err; |
284 } |
259 } |
285 |
260 |
286 |
261 |
287 //---------------------------------------------------------------------------- |
262 //---------------------------------------------------------------------------- |
709 } |
678 } |
710 |
679 |
711 //---------------------------------------------------------------------------- |
680 //---------------------------------------------------------------------------- |
712 |
681 |
713 //---------------------------------------------------------------------------- |
682 //---------------------------------------------------------------------------- |
714 /*TInt CCreatorPhonebook::iPhoneNumberFields[] = |
|
715 { |
|
716 R_VPBK_FIELD_TYPE_LANDPHONEGEN, |
|
717 R_VPBK_FIELD_TYPE_LANDPHONEHOME, |
|
718 R_VPBK_FIELD_TYPE_LANDPHONEWORK, |
|
719 R_VPBK_FIELD_TYPE_MOBILEPHONEGEN, |
|
720 R_VPBK_FIELD_TYPE_MOBILEPHONEHOME, |
|
721 R_VPBK_FIELD_TYPE_MOBILEPHONEWORK, |
|
722 R_VPBK_FIELD_TYPE_FAXNUMBERGEN, |
|
723 R_VPBK_FIELD_TYPE_FAXNUMBERHOME, |
|
724 R_VPBK_FIELD_TYPE_FAXNUMBERWORK, |
|
725 R_VPBK_FIELD_TYPE_PAGERNUMBER, |
|
726 R_VPBK_FIELD_TYPE_VIDEONUMBERGEN, |
|
727 R_VPBK_FIELD_TYPE_VIDEONUMBERHOME, |
|
728 R_VPBK_FIELD_TYPE_VIDEONUMBERWORK, |
|
729 R_VPBK_FIELD_TYPE_VOIPGEN, |
|
730 R_VPBK_FIELD_TYPE_VOIPHOME, |
|
731 R_VPBK_FIELD_TYPE_VOIPWORK, |
|
732 R_VPBK_FIELD_TYPE_ASSTPHONE, |
|
733 R_VPBK_FIELD_TYPE_CARPHONE |
|
734 };*/ |
|
735 |
|
736 /*TInt CCreatorPhonebook::iUrlFields[] = |
|
737 { |
|
738 R_VPBK_FIELD_TYPE_URLGEN, |
|
739 R_VPBK_FIELD_TYPE_URLHOME, |
|
740 R_VPBK_FIELD_TYPE_URLWORK |
|
741 };*/ |
|
742 |
|
743 /*TInt CCreatorPhonebook::iEmailFields[] = |
|
744 { |
|
745 R_VPBK_FIELD_TYPE_EMAILGEN, |
|
746 R_VPBK_FIELD_TYPE_EMAILHOME, |
|
747 R_VPBK_FIELD_TYPE_EMAILWORK |
|
748 };*/ |
|
749 |
683 |
750 void CCreatorPhonebook::InitializeContactParamsL(/*CCreatorModuleBaseParameters* aParameters*/) |
684 void CCreatorPhonebook::InitializeContactParamsL(/*CCreatorModuleBaseParameters* aParameters*/) |
751 { |
685 { |
752 LOGSTRING("Creator: CCreatorPhonebook::InitializeContactParamsL"); |
686 LOGSTRING("Creator: CCreatorPhonebook::InitializeContactParamsL"); |
753 |
687 |
771 if( iAddAllFields ) |
705 if( iAddAllFields ) |
772 { |
706 { |
773 TInt textFieldCount = sizeof(CreatorPbkMiscTextFields) / sizeof(DetailFieldInfo); |
707 TInt textFieldCount = sizeof(CreatorPbkMiscTextFields) / sizeof(DetailFieldInfo); |
774 for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex ) |
708 for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex ) |
775 { |
709 { |
776 QContactDetail field = CreateContactDetail( CreatorPbkMiscTextFields[tfIndex].iDetail, CreatorPbkMiscTextFields[tfIndex].iFieldContext, CreatorPbkMiscTextFields[tfIndex].iFieldString, CreatorPbkMiscTextFields[tfIndex].iRandomType ); |
710 // QContactDetail field = CreateContactDetail( CreatorPbkMiscTextFields[tfIndex].iDetail, CreatorPbkMiscTextFields[tfIndex].iFieldContext, CreatorPbkMiscTextFields[tfIndex].iFieldString, CreatorPbkMiscTextFields[tfIndex].iRandomType ); |
777 bool replace = false; |
711 |
778 for(int i = 0 ; i< iParameters->iContactFields.count() ; i++) |
712 CCreatorContactField* field = CCreatorContactField::NewL(); |
779 { |
713 CleanupStack::PushL( field ); |
780 if( !field.isEmpty() && field.definitionName() == iParameters->iContactFields.at(i).definitionName() ) |
714 QContactDetail cntDetail = field->CreateContactDetail(iEngine,iParameters,CreatorPbkMiscTextFields[tfIndex].iDetail, CreatorPbkMiscTextFields[tfIndex].iFieldContext, CreatorPbkMiscTextFields[tfIndex].iFieldString, CreatorPbkMiscTextFields[tfIndex].iRandomType ); |
781 { |
715 if(!cntDetail.isEmpty()) |
782 QString context = field.value(QContactDetail::FieldContext); |
716 { |
783 bool isContextEmpty = context.isEmpty(); |
717 field->AddFieldToParam( iParameters, cntDetail ); //it will do "param->iContactFields.AppendL(field);" |
784 if( isContextEmpty || ( field.value(QContactDetail::FieldContext) == iParameters->iContactFields.at(i).value(QContactDetail::FieldContext)) ) |
718 } |
785 { |
719 CleanupStack::Pop( field ); |
786 //replace |
|
787 iParameters->iContactFields.replace(i,field); |
|
788 replace = true; |
|
789 } |
|
790 } |
|
791 } |
|
792 if(!replace) |
|
793 { |
|
794 if(!field.isEmpty()) |
|
795 { |
|
796 iParameters->iContactFields.append(field); |
|
797 } |
|
798 } |
|
799 } |
720 } |
800 // Add binary fields: |
721 // Add binary fields: |
801 QContactDetail field = CreateContactDetail(QContactAvatar::DefinitionName,"","",0); |
722 TPtrC emptyData; |
802 iParameters->iContactFields.append(field); |
723 CCreatorContactField* fieldPicture = CCreatorContactField::NewL(); |
|
724 CleanupStack::PushL( fieldPicture ); |
|
725 QContactDetail cntDetail = fieldPicture->CreateContactDetail(iEngine,iParameters,QContactAvatar::DefinitionName,"","",emptyData ); |
|
726 if(!cntDetail.isEmpty()) |
|
727 { |
|
728 fieldPicture->AddFieldToParam( iParameters, cntDetail ); //it will do "param->iContactFields.AppendL(field);" |
|
729 } |
|
730 CleanupStack::Pop( fieldPicture ); |
803 |
731 |
804 // Add date-time fields: |
732 // Add date-time fields: |
805 QContactDetail fieldAnniv = CreateContactDetail(QContactAnniversary::DefinitionName,"","",0); |
733 CCreatorContactField* fieldAnniv = CCreatorContactField::NewL(); |
806 iParameters->iContactFields.append(fieldAnniv); |
734 CleanupStack::PushL( fieldAnniv ); |
|
735 QContactDetail cntDetAnniv = fieldAnniv->CreateContactDetail(iEngine,iParameters,QContactAnniversary::DefinitionName,"","",emptyData ); |
|
736 if(!cntDetAnniv .isEmpty()) |
|
737 { |
|
738 fieldAnniv->AddFieldToParam( iParameters, cntDetAnniv ); //it will do "param->iContactFields.AppendL(field);" |
|
739 } |
|
740 CleanupStack::Pop( fieldAnniv ); |
|
741 |
807 //*************************************************************************** |
742 //*************************************************************************** |
808 // Add text fields: |
743 |
809 /* TInt textFieldCount = sizeof(CreatorVPbkMiscTextFields) / sizeof(FieldInfo); |
|
810 for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex ) |
|
811 { |
|
812 //QContactDetail field; |
|
813 CCreatorContactField* field = CCreatorContactField::NewL(CreatorVPbkMiscTextFields[tfIndex].iFieldCode, KNullDesC); |
|
814 CleanupStack::PushL(field); |
|
815 field->SetRandomParametersL(CCreatorContactField::ERandomLengthDefault); |
|
816 iParameters->iContactFields.AppendL(field); |
|
817 CleanupStack::Pop(field); |
|
818 } |
|
819 |
|
820 // Add binary fields: |
|
821 TInt binFieldCount = sizeof(CreatorVPbkBinaryFields) / sizeof(TInt); |
|
822 for( TInt bfIndex = 0; bfIndex < binFieldCount; ++bfIndex ) |
|
823 { |
|
824 CCreatorContactField* field = CCreatorContactField::NewL(CreatorVPbkBinaryFields[bfIndex], KNullDesC8); |
|
825 CleanupStack::PushL(field); |
|
826 field->SetRandomParametersL(CCreatorContactField::ERandomLengthDefault); |
|
827 iParameters->iContactFields.AppendL(field); |
|
828 CleanupStack::Pop(field); |
|
829 } |
|
830 |
|
831 // Add date-time fields: |
|
832 TInt dtFieldCount = sizeof(CreatorVPbkDateTimeFields) / sizeof(TInt); |
|
833 for( TInt dtIndex = 0; dtIndex < dtFieldCount; ++dtIndex ) |
|
834 { |
|
835 AddFieldToParamsL(CreatorVPbkDateTimeFields[dtIndex], iEngine->RandomDate(CCreatorEngine::EDateFuture)); |
|
836 } |
|
837 |
|
838 AddFieldToParamsL(R_VPBK_FIELD_TYPE_CALLEROBJIMG, KNullDesC8); |
|
839 AddFieldToParamsL(R_VPBK_FIELD_TYPE_THUMBNAILPIC, KNullDesC8); |
|
840 AddFieldToParamsL(R_VPBK_FIELD_TYPE_CALLEROBJTEXT, firstname);*/ |
|
841 //*************************************************************************** |
|
842 |
|
843 //iParameters->iContactFields.append( name ); |
|
844 } |
744 } |
845 else |
745 else |
846 { |
746 { |
847 iParameters->iContactFields.append( name ); |
747 iParameters->iContactFields.append( name ); |
848 } |
748 } |
875 |
777 |
876 |
778 |
877 |
779 |
878 // URLs: |
780 // URLs: |
879 for( int i=0; i<iNumberOfURLFields; i++ ) |
781 for( int i=0; i<iNumberOfURLFields; i++ ) |
880 { |
782 { |
881 QContactUrl contactUrl; |
783 CCreatorContactField* fieldUrl = CCreatorContactField::NewL(); |
882 HBufC16* url = iEngine->CreateHTTPUrlLC(); |
784 CleanupStack::PushL( fieldUrl ); |
883 QString urlAddress = QString::fromUtf16(url->Ptr(), url->Length() ); |
785 QContactDetail cntDetUrl = fieldUrl->CreateContactDetail(iEngine,iParameters,QContactUrl::DefinitionName,"","",KErrNotFound ); |
884 contactUrl.setUrl( urlAddress ); |
786 if(!cntDetUrl.isEmpty()) |
885 iParameters->iContactFields.append( contactUrl ); |
787 { |
886 CleanupStack::PopAndDestroy(url); |
788 fieldUrl->AddFieldToParam( iParameters, cntDetUrl ); //it will do "param->iContactFields.AppendL(field);" |
887 } |
789 } |
|
790 CleanupStack::Pop( fieldUrl ); |
|
791 |
|
792 } |
888 |
793 |
889 // EMail addresses: |
794 // EMail addresses: |
890 for( int i=0; i<iNumberOfEmailAddressFields; i++ ) |
795 for( int i=0; i<iNumberOfEmailAddressFields; i++ ) |
891 { |
796 { |
892 QContactEmailAddress emailAddr; |
797 CCreatorContactField* fieldEmail = CCreatorContactField::NewL(); |
893 HBufC16* addr= iEngine->CreateEmailAddressLC();; |
798 CleanupStack::PushL( fieldEmail ); |
894 /*TPtrC comp = iEngine->RandomString(CCreatorEngine::ECompany); |
799 QContactDetail cntDetEmail = fieldEmail->CreateContactDetail(iEngine,iParameters,QContactEmailAddress::DefinitionName,"","",KErrNotFound ); |
895 QString company = QString::fromUtf16( comp.Ptr(), comp.Length() ); |
800 if(!cntDetEmail.isEmpty()) |
896 QString address = firstname+"@"+company+".com";*/ |
801 { |
897 //CreatorPbkEmailFields |
802 fieldEmail->AddFieldToParam( iParameters, cntDetEmail ); //it will do "param->iContactFields.AppendL(field);" |
898 QString address = QString::fromUtf16(addr->Ptr(), addr->Length() ); |
803 } |
899 emailAddr.setEmailAddress( address ); |
804 CleanupStack::Pop( fieldEmail ); |
900 emailAddr.setContexts(CreatorPbkEmailFields[i%2]); |
|
901 iParameters->iContactFields.append( emailAddr ); |
|
902 CleanupStack::PopAndDestroy(addr); |
|
903 } |
805 } |
904 |
806 |
905 } |
807 } |
906 |
808 |
907 |
809 |
908 |
810 |
909 // Checks if the link is a group or not |
811 // Checks if the link is a group or not |
910 TBool CCreatorPhonebook::IsContactGroupL() |
812 TBool CCreatorPhonebook::IsContactGroupL( QContactLocalId& aLink ) |
911 { |
813 { |
|
814 QContact group = iContactMngr->contact( aLink ); |
|
815 if( group.type() == QContactType::TypeGroup ) |
|
816 { |
|
817 return ETrue; |
|
818 } |
912 return EFalse; |
819 return EFalse; |
913 } |
820 } |
914 |
821 |
915 TInt CCreatorPhonebook::CreateGroupEntryL(CCreatorModuleBaseParameters *aParameters) |
822 TInt CCreatorPhonebook::CreateGroupEntryL(CCreatorModuleBaseParameters *aParameters) |
916 { |
823 { |
1047 return KErrNotSupported; |
959 return KErrNotSupported; |
1048 } |
960 } |
1049 |
961 |
1050 //---------------------------------------------------------------------------- |
962 //---------------------------------------------------------------------------- |
1051 |
963 |
1052 //---------------------------------------------------------------------------- |
964 CCreatorContactField::CCreatorContactField() |
1053 |
965 { |
1054 //---------------------------------------------------------------------------- |
966 } |
1055 |
967 CCreatorContactField::~CCreatorContactField() |
|
968 { |
|
969 } |
|
970 |
|
971 CCreatorContactField* CCreatorContactField::NewL() |
|
972 { |
|
973 CCreatorContactField* self = new (ELeave) CCreatorContactField(); |
|
974 CleanupStack::PushL(self); |
|
975 self->ConstructL(); |
|
976 CleanupStack::Pop(); |
|
977 return self; |
|
978 } |
|
979 void CCreatorContactField::ConstructL() |
|
980 { |
|
981 //pImpl = CCreatorContactTextField::NewL(aFieldType, aData); |
|
982 } |
|
983 QContactDetail CCreatorContactField::CreateContactDetail(CCreatorEngine* aEngine,CPhonebookParameters* aParameters,QString aDetail, QString aFieldContext, QString aFieldString, TInt aRand ) |
|
984 { |
|
985 QContactDetail emptyDet; |
|
986 TPtrC contentData; |
|
987 HBufC16* tempData = 0; |
|
988 if(aRand == KErrNotFound) |
|
989 { |
|
990 TInt textFieldCount = sizeof(CreatorPbkMiscTextFields) / sizeof(DetailFieldInfo); |
|
991 for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex ) |
|
992 { |
|
993 if( CreatorPbkMiscTextFields[tfIndex].iDetail == aDetail && CreatorPbkMiscTextFields[tfIndex].iFieldContext == aFieldContext && CreatorPbkMiscTextFields[tfIndex].iFieldString == aFieldString) |
|
994 { |
|
995 aRand = CreatorPbkMiscTextFields[tfIndex].iRandomType; |
|
996 } |
|
997 } |
|
998 } |
|
999 |
|
1000 if( aRand != KErrNotFound ) |
|
1001 { |
|
1002 contentData.Set(aEngine->RandomString((CCreatorEngine::TRandomStringType) aRand)); |
|
1003 } |
|
1004 else |
|
1005 { |
|
1006 if( aDetail == QContactPhoneNumber::DefinitionName ) |
|
1007 { |
|
1008 contentData.Set(aEngine->RandomString(CCreatorEngine::EPhoneNumber)); |
|
1009 } |
|
1010 else if( aDetail == QContactEmailAddress::DefinitionName ) |
|
1011 { |
|
1012 tempData = aEngine->CreateEmailAddressLC(); |
|
1013 contentData.Set( tempData->Des() ); |
|
1014 } |
|
1015 else if( aDetail == QContactUrl::DefinitionName ) |
|
1016 { |
|
1017 tempData = aEngine->CreateHTTPUrlLC(); |
|
1018 contentData.Set( tempData->Des() ); |
|
1019 } |
|
1020 else |
|
1021 { |
|
1022 return emptyDet; |
|
1023 } |
|
1024 } |
|
1025 emptyDet = CreateContactDetail( aEngine, aParameters, aDetail, aFieldContext, aFieldString, contentData ); |
|
1026 if( tempData ) |
|
1027 { |
|
1028 CleanupStack::PopAndDestroy( tempData ); |
|
1029 } |
|
1030 return emptyDet; |
|
1031 } |
|
1032 |
|
1033 QContactDetail CCreatorContactField::CreateContactDetail(CCreatorEngine* aEngine,CPhonebookParameters* aParameters,QString aDetail, QString aFieldContext, QString aFieldString, TPtrC aData ) |
|
1034 { |
|
1035 QContactDetail contactDetail; |
|
1036 |
|
1037 if( aDetail == QContactPhoneNumber::DefinitionName) |
|
1038 { |
|
1039 QContactPhoneNumber phoneNumber;// = contactDetail; |
|
1040 if(!aFieldContext.isEmpty()) |
|
1041 { |
|
1042 phoneNumber.setContexts(aFieldContext); |
|
1043 } |
|
1044 phoneNumber.setSubTypes(aFieldString); |
|
1045 QString number = QString::fromUtf16(aData.Ptr(),aData.Length()); |
|
1046 phoneNumber.setNumber(number); |
|
1047 return phoneNumber; |
|
1048 } |
|
1049 else if( aDetail == QContactName::DefinitionName ) //--Contact NAME----------------------------- |
|
1050 { |
|
1051 QContactName contactName; |
|
1052 for(int i = 0 ; i < aParameters->iContactFields.count() ; i++ ) //go through all contact details to check if there is already Contact Name to set other details |
|
1053 { |
|
1054 if(aParameters->iContactFields.at(i).definitionName() == QContactName::DefinitionName ) |
|
1055 { |
|
1056 contactName = aParameters->iContactFields.at(i); |
|
1057 } |
|
1058 } |
|
1059 QString name = QString::fromUtf16(aData.Ptr(),aData.Length()); |
|
1060 if(aFieldString == QContactName::FieldFirstName) |
|
1061 { |
|
1062 if(contactName.firstName().isEmpty()) |
|
1063 { |
|
1064 contactName.setFirstName( name ); |
|
1065 } |
|
1066 } |
|
1067 else if(aFieldString == QContactName::FieldLastName) |
|
1068 { |
|
1069 if(contactName.lastName().isEmpty()) |
|
1070 { |
|
1071 contactName.setLastName( name ); |
|
1072 } |
|
1073 } |
|
1074 else if(aFieldString == QContactName::FieldMiddleName) |
|
1075 { |
|
1076 if(contactName.middleName().isEmpty()) |
|
1077 { |
|
1078 contactName.setMiddleName( name ); |
|
1079 } |
|
1080 } |
|
1081 else if(aFieldString == QContactName::FieldPrefix) |
|
1082 { |
|
1083 if(contactName.prefix().isEmpty()) |
|
1084 { |
|
1085 contactName.setPrefix( name ); |
|
1086 } |
|
1087 } |
|
1088 else if(aFieldString == QContactName::FieldSuffix) |
|
1089 { |
|
1090 if(contactName.suffix().isEmpty()) |
|
1091 { |
|
1092 contactName.setSuffix( name ); |
|
1093 } |
|
1094 } |
|
1095 else //QContactName::FieldCustomLabel: |
|
1096 { |
|
1097 if(contactName.customLabel().isEmpty()) |
|
1098 { |
|
1099 contactName.setCustomLabel( name ); |
|
1100 } |
|
1101 } |
|
1102 return contactName; |
|
1103 } |
|
1104 else if( aDetail == QContactOrganization::DefinitionName ) //--Contact Company----------------------------- |
|
1105 { |
|
1106 QContactOrganization contactCompany; |
|
1107 |
|
1108 for(int i = 0 ; i < aParameters->iContactFields.count() ; i++ ) //go through all contact details to check if there is already Contact Name to set other details |
|
1109 { |
|
1110 if(aParameters->iContactFields.at(i).definitionName() == QContactOrganization::DefinitionName ) |
|
1111 { |
|
1112 contactCompany = aParameters->iContactFields.at(i); |
|
1113 } |
|
1114 } |
|
1115 |
|
1116 QString company = QString::fromUtf16(aData.Ptr(),aData.Length()); |
|
1117 if(aFieldString == QContactOrganization::FieldName) |
|
1118 { |
|
1119 if(contactCompany.name().isEmpty()) |
|
1120 { |
|
1121 contactCompany.setName( company ); |
|
1122 } |
|
1123 } |
|
1124 if(aFieldString == QContactOrganization::FieldTitle) |
|
1125 { |
|
1126 if(contactCompany.title().isEmpty()) |
|
1127 { |
|
1128 contactCompany.setTitle( company ); |
|
1129 } |
|
1130 } |
|
1131 if(aFieldString == QContactOrganization::FieldDepartment) |
|
1132 { |
|
1133 QStringList depList = contactCompany.department(); |
|
1134 depList.append(company); |
|
1135 contactCompany.setDepartment(depList); |
|
1136 } |
|
1137 if(aFieldString == QContactOrganization::FieldAssistantName) |
|
1138 { |
|
1139 if(contactCompany.assistantName().isEmpty()) |
|
1140 { |
|
1141 contactCompany.setAssistantName( company ); |
|
1142 } |
|
1143 } |
|
1144 return contactCompany; |
|
1145 } |
|
1146 else if( aDetail == QContactAddress::DefinitionName ) //--Contact Address----------------------------- |
|
1147 { |
|
1148 QContactAddress contactAddress; |
|
1149 |
|
1150 for(int i = 0 ; i < aParameters->iContactFields.count() ; i++ ) //go through all contact details to check if there is already Contact Name to set other details |
|
1151 { |
|
1152 if(aParameters->iContactFields.at(i).definitionName() == QContactAddress::DefinitionName && aParameters->iContactFields.at(i).value(QContactDetail::FieldContext) == aFieldContext ) |
|
1153 { |
|
1154 contactAddress = aParameters->iContactFields.at(i); |
|
1155 } |
|
1156 } |
|
1157 if( !aFieldContext.isEmpty() ) |
|
1158 { |
|
1159 contactAddress.setContexts( aFieldContext ); |
|
1160 } |
|
1161 QString address = QString::fromUtf16(aData.Ptr(),aData.Length()); |
|
1162 if(aFieldString == QContactAddress::FieldStreet ) |
|
1163 { |
|
1164 if( contactAddress.street().isEmpty() ) |
|
1165 { |
|
1166 contactAddress.setStreet( address ); |
|
1167 } |
|
1168 } |
|
1169 else if(aFieldString == QContactAddress::FieldLocality ) |
|
1170 { |
|
1171 if( contactAddress.locality().isEmpty() ) |
|
1172 { |
|
1173 contactAddress.setLocality( address ); |
|
1174 } |
|
1175 } |
|
1176 else if(aFieldString == QContactAddress::FieldRegion ) |
|
1177 { |
|
1178 if( contactAddress.region().isEmpty() ) |
|
1179 { |
|
1180 contactAddress.setRegion( address ); |
|
1181 } |
|
1182 } |
|
1183 else if(aFieldString == QContactAddress::FieldPostcode ) |
|
1184 { |
|
1185 if( contactAddress.postcode().isEmpty() ) |
|
1186 { |
|
1187 contactAddress.setPostcode( address ); |
|
1188 } |
|
1189 } |
|
1190 else if(aFieldString == QContactAddress::FieldCountry ) |
|
1191 { |
|
1192 if( contactAddress.country().isEmpty() ) |
|
1193 { |
|
1194 contactAddress.setCountry( address ); |
|
1195 } |
|
1196 } |
|
1197 else |
|
1198 { |
|
1199 return contactDetail; |
|
1200 } |
|
1201 return contactAddress; |
|
1202 } |
|
1203 else if( aDetail == QContactNote::DefinitionName ) //--Contact Note----------------------------- |
|
1204 { |
|
1205 QContactNote contactNote; |
|
1206 QString note = QString::fromUtf16(aData.Ptr(),aData.Length()); |
|
1207 contactNote.setNote(note); |
|
1208 return contactNote; |
|
1209 } |
|
1210 else if( aDetail == QContactFamily::DefinitionName ) //--Contact Family----------------------------- |
|
1211 { |
|
1212 QContactFamily contactFamily; |
|
1213 |
|
1214 for(int i = 0 ; i < aParameters->iContactFields.count() ; i++ ) //go through all contact details to check if there is already Contact Name to set other details |
|
1215 { |
|
1216 if(aParameters->iContactFields.at(i).definitionName() == QContactFamily::DefinitionName && aParameters->iContactFields.at(i).value(QContactDetail::FieldContext) == aFieldContext ) |
|
1217 { |
|
1218 contactFamily = aParameters->iContactFields.at(i); |
|
1219 } |
|
1220 } |
|
1221 |
|
1222 QString familyData = QString::fromUtf16(aData.Ptr(),aData.Length()); |
|
1223 if(aFieldString == QContactFamily::FieldSpouse ) |
|
1224 { |
|
1225 if( contactFamily.spouse().isEmpty() ) |
|
1226 { |
|
1227 contactFamily.setSpouse( familyData ); |
|
1228 } |
|
1229 } |
|
1230 if(aFieldString == QContactFamily::FieldChildren ) |
|
1231 { |
|
1232 QStringList children = contactFamily.children(); |
|
1233 children.append( familyData ); |
|
1234 contactFamily.setChildren( children ); |
|
1235 } |
|
1236 |
|
1237 return contactFamily; |
|
1238 } |
|
1239 |
|
1240 if( aDetail == QContactAvatar::DefinitionName) //--Contact Picture----------------------------- |
|
1241 { |
|
1242 RFs& fs = CCoeEnv::Static()->FsSession(); |
|
1243 QContactAvatar contactAvatar; |
|
1244 TBuf<KMaxFileName> srcPath; |
|
1245 aEngine->RandomPictureFileL(srcPath); |
|
1246 TBuf<KMaxFileName> destPath(KTempPath); |
|
1247 |
|
1248 if(!BaflUtils::FolderExists( fs, destPath )) |
|
1249 { |
|
1250 BaflUtils::EnsurePathExistsL( fs, destPath ); |
|
1251 } |
|
1252 |
|
1253 TInt err=BaflUtils::CopyFile( fs, srcPath, destPath ); |
|
1254 |
|
1255 TParse temp; |
|
1256 temp.Set( srcPath,NULL,NULL ); |
|
1257 destPath.Append(temp.NameAndExt()); |
|
1258 |
|
1259 QString avatarFile = QString::fromUtf16( destPath.Ptr(),destPath.Length() ); |
|
1260 |
|
1261 QPixmap avatarPix(avatarFile); |
|
1262 |
|
1263 contactAvatar.setAvatar(avatarFile); |
|
1264 contactAvatar.setPixmap(avatarPix); |
|
1265 |
|
1266 return contactAvatar; |
|
1267 } |
|
1268 if( aDetail == QContactAnniversary::DefinitionName) //--Anniversary------------------------------ |
|
1269 { |
|
1270 QContactAnniversary contactAnniversary; |
|
1271 QDate date; |
|
1272 TTime datetime = aEngine->RandomDate( CCreatorEngine::EDateFuture ); |
|
1273 date.setDate( datetime.DateTime().Year(),(int) (datetime.DateTime().Month()+1), datetime.DateTime().Day() ); |
|
1274 contactAnniversary.setOriginalDate( date ); |
|
1275 return contactAnniversary; |
|
1276 } |
|
1277 if( aDetail == QContactEmailAddress::DefinitionName) //--Email------------------------------------ |
|
1278 { |
|
1279 QContactEmailAddress email; |
|
1280 QString emailAddr = QString::fromUtf16(aData.Ptr(),aData.Length()); |
|
1281 if( !aFieldContext.isEmpty() ) |
|
1282 { |
|
1283 email.setContexts( aFieldContext ); |
|
1284 } |
|
1285 email.setEmailAddress( emailAddr ); |
|
1286 return email; |
|
1287 } |
|
1288 if( aDetail == QContactUrl::DefinitionName ) //--Url------------------------------------------- |
|
1289 { |
|
1290 QContactUrl url; |
|
1291 QString urlStr = QString::fromUtf16(aData.Ptr(),aData.Length()); |
|
1292 if( !aFieldContext.isEmpty() ) |
|
1293 { |
|
1294 url.setContexts( aFieldContext ); |
|
1295 } |
|
1296 url.setUrl(urlStr); |
|
1297 return url; |
|
1298 } |
|
1299 if( aDetail == QContactBirthday::DefinitionName ) //--Birthday----------------------------------- |
|
1300 { |
|
1301 QContactBirthday birthday; |
|
1302 QDate date; |
|
1303 TTime datetime = aEngine->RandomDate( CCreatorEngine::EDatePast ); |
|
1304 date.setDate( datetime.DateTime().Year(),(int) (datetime.DateTime().Month()+1), datetime.DateTime().Day() ); |
|
1305 birthday.setDate( date ); |
|
1306 return birthday; |
|
1307 } |
|
1308 |
|
1309 return contactDetail; |
|
1310 } |
|
1311 |
|
1312 void CCreatorContactField::AddFieldToParam( CPhonebookParameters* aParam, QContactDetail aDetail) |
|
1313 { |
|
1314 bool replace = false; |
|
1315 for(int i = 0 ; i< aParam->iContactFields.count() ; i++) //go through |
|
1316 { |
|
1317 if( !aDetail.isEmpty() && aDetail.definitionName() == aParam->iContactFields.at(i).definitionName() |
|
1318 && aDetail.definitionName() != QContactPhoneNumber::DefinitionName |
|
1319 && aDetail.definitionName() != QContactEmailAddress::DefinitionName |
|
1320 && aDetail.definitionName() != QContactUrl::DefinitionName ) |
|
1321 { |
|
1322 QString context = aDetail.value(QContactDetail::FieldContext); |
|
1323 bool isContextEmpty = context.isEmpty(); |
|
1324 if( isContextEmpty || ( aDetail.value(QContactDetail::FieldContext) == aParam->iContactFields.at(i).value(QContactDetail::FieldContext)) ) |
|
1325 { |
|
1326 //replace |
|
1327 aParam->iContactFields.replace(i,aDetail); |
|
1328 replace = true; |
|
1329 } |
|
1330 } |
|
1331 } |
|
1332 if(!replace) |
|
1333 { |
|
1334 if(!aDetail.isEmpty()) |
|
1335 { |
|
1336 aParam->iContactFields.append(aDetail); |
|
1337 } |
|
1338 } |
|
1339 |
|
1340 } |
|
1341 //---------------------------------------------------------------------------- |
|
1342 |
|
1343 //---------------------------------------------------------------------------- |
|
1344 |