8 IdBaseComponent
, IdGlobal
, KOLClasses
;
11 TIdVCardEmbeddedObject
= object(TObj
)
15 FBase64Encoded
: Boolean;
16 FEmbeddedData
: PStrList
;
17 procedure SetEmbeddedData(const Value
: PStrList
);
21 virtual; { published }
22 property ObjectType
: string read FObjectType write FObjectType
;
23 property ObjectURL
: string read FObjectURL write FObjectURL
;
24 property Base64Encoded
: Boolean read FBase64Encoded write FBase64Encoded
;
25 property EmbeddedData
: PStrList read FEmbeddedData write SetEmbeddedData
;
27 PIdVCardEmbeddedObject
=^TIdVCardEmbeddedObject
;
28 function NewIdVCardEmbeddedObject
:PIdVCardEmbeddedObject
;
31 TIdVCardBusinessInfo
= object(TObj
)
35 FOrganization
: string;
37 procedure SetDivisions(Value
: PStrList
);
41 virtual; { published }
42 property Organization
: string read FOrganization write FOrganization
;
43 property Divisions
: PStrList read FDivisions write SetDivisions
;
44 property Title
: string read FTitle write FTitle
;
45 property Role
: string read FRole write FRole
;
47 PIdVCardBusinessInfo
=^TIdVCardBusinessInfo
;
48 function NewIdVCardBusinessInfo
:PIdVCardBusinessInfo
;
51 TIdVCardGeog
= object(TObj
)
57 property Latitude
: Real read FLatitude write FLatitude
;
58 property Longitude
: Real read FLongitude write FLongitude
;
59 property TimeZoneStr
: string read FTimeZoneStr write FTimeZoneStr
;
61 PIdVCardGeog
=^TIdVCardGeog
;
62 function NewIdVCardGeog
:PIdVCardGeog
;
65 TIdPhoneAttributes
= set of
66 (tpaHome
, tpaVoiceMessaging
, tpaWork
, tpaPreferred
, tpaVoice
, tpaFax
,
67 paCellular
, tpaVideo
, tpaBBS
, tpaModem
, tpaCar
, tpaISDN
, tpaPCS
, tpaPager
);
69 TIdCardPhoneNumber
= object(TCollectionItem
)
71 FPhoneAttributes
: TIdPhoneAttributes
;
74 procedure Assign(Source
: PObj
);// override;
76 property PhoneAttributes
: TIdPhoneAttributes
77 read FPhoneAttributes write FPhoneAttributes
;
78 property Number
: string read FNumber write FNumber
;
80 PIdCardPhoneNumber
=^TIdCardPhoneNumber
;
81 function NewIdCardPhoneNumber
:PIdCardPhoneNumber
;
84 TIdVCardTelephones
= object(TOwnedCollection
)
86 function GetItem(Index
: Integer): TIdCardPhoneNumber
;
87 procedure SetItem(Index
: Integer; const Value
: TIdCardPhoneNumber
);
89 { constructor Create(AOwner: TPersistent); }// reintroduce;
90 function Add
: TIdCardPhoneNumber
;
91 property Items
[Index
: Integer]: TIdCardPhoneNumber read GetItem write
94 PIdVCardTelephones
=^TIdVCardTelephones
;
95 function NewIdVCardTelephones(AOwner
: PObj
):PIdVCardTelephones
;
98 TIdCardAddressAttributes
= set of (tatHome
, tatDomestic
, tatInternational
,
100 tatParcel
, tatWork
, tatPreferred
);
101 TIdCardAddressItem
= object(TCollectionItem
)
103 FAddressAttributes
: TIdCardAddressAttributes
;
105 FExtendedAddress
: string;
106 FStreetAddress
: string;
112 procedure Assign(Source
: PObj
); //override;
114 property AddressAttributes
: TIdCardAddressAttributes read
115 FAddressAttributes write FAddressAttributes
;
116 property POBox
: string read FPOBox write FPOBox
;
117 property ExtendedAddress
: string read FExtendedAddress write
119 property StreetAddress
: string read FStreetAddress write FStreetAddress
;
120 property Locality
: string read FLocality write FLocality
;
121 property Region
: string read FRegion write FRegion
;
122 property PostalCode
: string read FPostalCode write FPostalCode
;
123 property Nation
: string read FNation write FNation
;
125 PIdCardAddressItem
=^TIdCardAddressItem
;
126 function NewIdCardAddressItem
:PIdCardAddressItem
;
129 TIdVCardAddresses
= object(TOwnedCollection
)
131 function GetItem(Index
: Integer): TIdCardAddressItem
;
132 procedure SetItem(Index
: Integer; const Value
: TIdCardAddressItem
);
134 { constructor Create(AOwner: TPersistent); }// reintroduce;
135 function Add
: TIdCardAddressItem
;
136 property Items
[Index
: Integer]: TIdCardAddressItem read GetItem write
139 PIdVCardAddresses
=^TIdVCardAddresses
;
140 function NewIdVCardAddresses(AOwner
: PObj
):PIdVCardAddresses
;
143 TIdVCardMailingLabelItem
= object(TCollectionItem
)
145 FAddressAttributes
: TIdCardAddressAttributes
;
146 FMailingLabel
: PStrList
;
147 procedure SetMailingLabel(Value
: PStrList
);
149 { constructor Create(Collection: TCollection); override;
150 } destructor Destroy
;
151 virtual; procedure Assign(Source
: PObj
);// override;
153 property AddressAttributes
: TIdCardAddressAttributes read
154 FAddressAttributes write FAddressAttributes
;
155 property MailingLabel
: PStrList read FMailingLabel write SetMailingLabel
;
157 PIdVCardMailingLabelItem
=^TIdVCardMailingLabelItem
;
158 function NewIdVCardMailingLabelItem(Collection
: PCollection
):PIdVCardMailingLabelItem
;
161 TIdVCardMailingLabels
= object(TOwnedCollection
)
163 function GetItem(Index
: Integer): TIdVCardMailingLabelItem
;
164 procedure SetItem(Index
: Integer; const Value
: TIdVCardMailingLabelItem
);
166 { constructor Create(AOwner: TPersistent); } //reintroduce;
167 function Add
: TIdVCardMailingLabelItem
;
168 property Items
[Index
: Integer]: TIdVCardMailingLabelItem read GetItem write
171 PIdVCardMailingLabels
=^TIdVCardMailingLabels
;
172 function NewIdVCardMailingLabels(AOwner
: PObj
):PIdVCardMailingLabels
;
174 TIdVCardEMailType
= (ematAOL
,
187 TIdVCardEMailItem
= object(TCollectionItem
)
189 FEMailType
: TIdVCardEMailType
;
193 { constructor Create(Collection: TCollection); override;
194 } procedure Assign(Source
: PObj
);// override;
196 property EMailType
: TIdVCardEMailType read FEMailType write FEMailType
;
197 property Preferred
: Boolean read FPreferred write FPreferred
;
198 property Address
: string read FAddress write FAddress
;
200 PIdVCardEMailItem
=^TIdVCardEMailItem
;
201 function NewIdVCardEMailItem(Collection
: PCollection
):PIdVCardEMailItem
;
204 TIdVCardEMailAddresses
= object(TOwnedCollection
)
206 function GetItem(Index
: Integer): TIdVCardEMailItem
;
207 procedure SetItem(Index
: Integer; const Value
: TIdVCardEMailItem
);
209 { constructor Create(AOwner: TPersistent); }// reintroduce;
210 function Add
: TIdVCardEMailItem
;
211 property Items
[Index
: Integer]: TIdVCardEMailItem read GetItem write
214 PIdVCardEMailAddresses
=^TIdVCardEMailAddresses
;
215 function NewIdVCardEMailAddresses(AOwner
: PObj
):PIdVCardEMailAddresses
; type
217 TIdVCardName
= object(TObj
)
221 FOtherNames
: PStrList
;
224 FFormattedName
: string;
226 FNickNames
: PStrList
;
227 procedure SetOtherNames(Value
: PStrList
);
228 procedure SetNickNames(Value
: PStrList
);
230 { constructor Create;
231 } destructor Destroy
;
232 virtual; { published }
233 property FirstName
: string read FFirstName write FFirstName
;
234 property SurName
: string read FSurName write FSurName
;
235 property OtherNames
: PStrList read FOtherNames write SetOtherNames
;
236 property FormattedName
: string read FFormattedName write FFormattedName
;
237 property Prefix
: string read FPrefix write FPrefix
;
238 property Suffix
: string read FSuffix write FSuffix
;
239 property SortName
: string read FSortName write FSortName
;
240 property NickNames
: PStrList read FNickNames write SetNickNames
;
242 PIdVCardName
=^TIdVCardName
;
243 function NewIdVCardName
:PIdVCardName
;
246 TIdVCard
= object(TIdBaseComponent
)
250 FCatagories
: PStrList
;
251 FBusinessInfo
: TIdVCardBusinessInfo
;
252 FGeography
: TIdVCardGeog
;
253 FFullName
: TIdVCardName
;
256 FEMailProgram
: string;
257 FEMailAddresses
: TIdVCardEMailAddresses
;
258 FAddresses
: TIdVCardAddresses
;
259 FMailingLabels
: TIdVCardMailingLabels
;
260 FTelephones
: TIdVCardTelephones
;
264 FClassification
: string;
265 FLastRevised
: TDateTime
;
266 FBirthDay
: TDateTime
;
267 FPhoto
: TIdVCardEmbeddedObject
;
268 FLogo
: TIdVCardEmbeddedObject
;
269 FSound
: TIdVCardEmbeddedObject
;
270 FKey
: TIdVCardEmbeddedObject
;
271 procedure SetComments(Value
: PStrList
);
272 procedure SetCatagories(Value
: PStrList
);
273 procedure SetURLs(Value
: PStrList
);
274 procedure SetVariablesAfterRead
;
276 { constructor Create(AOwner: TComponent); override;
277 } destructor Destroy
;
278 virtual; procedure ReadFromPStrList(s
: PStrList
);
279 property RawForm
: PStrList read FRawForm
;
281 property VCardVersion
: Real read FVCardVersion
;
282 property URLs
: PStrList read FURLs write SetURLs
;
283 property ProductID
: string read FProductID write FProductID
;
284 property UniqueID
: string read FUniqueID write FUniqueID
;
285 property Classification
: string read FClassification write FClassification
;
286 property BirthDay
: TDateTime read FBirthDay write FBirthDay
;
287 property FullName
: TIdVCardName read FFullName write FFullName
;
288 property EMailProgram
: string read FEMailProgram write FEMailProgram
;
289 property EMailAddresses
: TIdVCardEMailAddresses read FEMailAddresses
;
290 property Telephones
: TIdVCardTelephones read FTelephones
;
291 property BusinessInfo
: TIdVCardBusinessInfo read FBusinessInfo
;
292 property Catagories
: PStrList read FCatagories write SetCatagories
;
293 property Addresses
: TIdVCardAddresses read FAddresses
;
294 property MailingLabels
: TIdVCardMailingLabels read FMailingLabels
;
295 property Comments
: PStrList read FComments write SetComments
;
296 property Photo
: TIdVCardEmbeddedObject read FPhoto
;
297 property Logo
: TIdVCardEmbeddedObject read FLogo
;
298 property Sound
: TIdVCardEmbeddedObject read FSound
;
299 property Key
: TIdVCardEmbeddedObject read FKey
;
302 function NewIdVCard(AOwner
: PControl
):PIdVCard
;
311 VCardProperties
: array[1..28] of string = (
312 'FN', 'N', 'NICKNAME', 'PHOTO',
313 'BDAY', 'ADR', 'LABEL', 'TEL',
314 'EMAIL', 'MAILER', 'TZ', 'GEO',
315 'TITLE', 'ROLE', 'LOGO', 'AGENT',
316 'ORG', 'CATEGORIES', 'NOTE', 'PRODID',
317 'REV', 'SORT-STRING', 'SOUND', 'URL',
318 'UID', 'VERSION', 'CLASS', 'KEY');
319 { These constants are for testing the VCard for E-Mail types.
322 EMailTypePropertyParameter
: array[1..12] of string =
336 procedure AddValueToStrings(strs
: PStrList
; Value
: string);
338 if (Length(Value
) <> 0) then
344 procedure ParseDelinatorToPStrList(strs
: PStrList
; str
: string;
345 deliniator
: Char = ',');
349 AddValueToStrings(strs
, Fetch(str
, deliniator
));
353 function ParseDateTimeStamp(DateString
: string): TDateTime
;
355 Year
, Day
, Month
: Integer;
356 Hour
, Minute
, Second
: Integer;
358 Year
:= StrToInt(Copy(DateString
, 1, 4));
359 Month
:= StrToInt(Copy(DateString
, 5, 2));
360 Day
:= StrToInt(Copy(DateString
, 7, 2));
361 if (Length(DateString
) > 14) then
363 Hour
:= StrToInt(Copy(DateString
, 10, 2));
364 Minute
:= StrToInt(Copy(DateString
, 12, 2));
365 Second
:= StrToInt(Copy(DateString
, 14, 2));
373 Result
:= EncodeDate(Year
, Month
, Day
) + EncodeTime(Hour
, Minute
, Second
, 0);
376 function GetAttributesAndValue(data
: string; var value
: string): PStrList
;
380 // Result := PStrList.Create;
381 // Result.Sorted := False;
382 if Pos(':', Data
) <> 0 then
384 Buff
:= idGlobal
.Fetch(Data
, ':');
385 StringReplace(Buff
, ',', ';', [rfReplaceAll
]);
386 while (Buff
<> '') do
388 Buff2
:= IdGlobal
.Fetch(Buff
, ';');
389 if (Length(Buff2
) > 0) then
391 Result
.Add(UpperCase(Buff2
));
398 procedure ParseOrg(OrgObj
: TIdVCardBusinessInfo
; OrgStr
: string);
400 OrgObj
.Organization
:= Fetch(OrgStr
);
401 ParseDelinatorToPStrList(OrgObj
.Divisions
, OrgStr
, ';');
404 procedure ParseGeography(Geog
: TIdVCardGeog
; GeogStr
: string);
406 Geog
.Latitude
:= StrToFloat(Fetch(GeogStr
, ';'));
407 Geog
.Longitude
:= StrToFloat(Fetch(GeogStr
, ';'));
410 procedure ParseTelephone(PhoneObj
: TIdCardPhoneNumber
; PhoneStr
: string);
417 TelephoneTypePropertyParameter
: array[0..13] of string =
418 ('HOME', 'MSG', 'WORK', 'PREF', 'VOICE', 'FAX',
419 'CELL', 'VIDEO', 'BBS', 'MODEM', 'CAR', 'ISDN',
422 attribs
:= GetAttributesAndValue(PhoneStr
, Value
);
425 while idx
< Attribs
.Count
do
427 { case idGlobal.PosInStrArray(attribs[idx], TelephoneTypePropertyParameter)
429 0: PhoneObj.PhoneAttributes := PhoneObj.PhoneAttributes + [tpaHome];
430 1: PhoneObj.PhoneAttributes := PhoneObj.PhoneAttributes +
432 2: PhoneObj.PhoneAttributes := PhoneObj.PhoneAttributes + [tpaWork];
433 3: PhoneObj.PhoneAttributes := PhoneObj.PhoneAttributes +
435 4: PhoneObj.PhoneAttributes := PhoneObj.PhoneAttributes + [tpaVoice];
436 5: PhoneObj.PhoneAttributes := PhoneObj.PhoneAttributes + [tpaFax];
437 6: PhoneObj.PhoneAttributes := PhoneObj.PhoneAttributes + [paCellular];
438 7: PhoneObj.PhoneAttributes := PhoneObj.PhoneAttributes + [tpaVideo];
439 8: PhoneObj.PhoneAttributes := PhoneObj.PhoneAttributes + [tpaBBS];
440 9: PhoneObj.PhoneAttributes := PhoneObj.PhoneAttributes + [tpaModem];
441 10: PhoneObj.PhoneAttributes := PhoneObj.PhoneAttributes + [tpaCar];
442 11: PhoneObj.PhoneAttributes := PhoneObj.PhoneAttributes + [tpaISDN];
443 12: PhoneObj.PhoneAttributes := PhoneObj.PhoneAttributes + [tpaPCS];
444 13: PhoneObj.PhoneAttributes := PhoneObj.PhoneAttributes + [tpaPager];
448 if (Attribs
.Count
= 0) then
450 PhoneObj
.PhoneAttributes
:= [tpaVoice
];
452 PhoneObj
.Number
:= Value
;
458 procedure ParseAddress(AddressObj
: TIdCardAddressItem
; AddressStr
: string);
464 AttribsArray
: array[0..6] of string =
465 ('HOME', 'DOM', 'INTL', 'POSTAL', 'PARCEL', 'WORK', 'PREF');
467 Attribs
:= GetAttributesAndValue(AddressStr
, Value
);
470 while idx
< Attribs
.Count
do
472 { case idGlobal.PosInStrArray(attribs[idx], AttribsArray) of
474 AddressObj.AddressAttributes :=
475 AddressObj.AddressAttributes + [tatHome];
477 AddressObj.AddressAttributes :=
478 AddressObj.AddressAttributes + [tatDomestic];
480 AddressObj.AddressAttributes :=
481 AddressObj.AddressAttributes + [tatInternational];
483 AddressObj.AddressAttributes :=
484 AddressObj.AddressAttributes + [tatPostal];
486 AddressObj.AddressAttributes :=
487 AddressObj.AddressAttributes + [tatParcel];
489 AddressObj.AddressAttributes :=
490 AddressObj.AddressAttributes + [tatWork];
492 AddressObj.AddressAttributes :=
493 AddressObj.AddressAttributes + [tatPreferred];
497 if (Attribs
.Count
= 0) then
499 AddressObj
.AddressAttributes
:= [tatInternational
, tatPostal
, tatParcel
,
502 AddressObj
.POBox
:= idGlobal
.Fetch(Value
, ';');
503 AddressObj
.ExtendedAddress
:= idGlobal
.Fetch(Value
, ';');
504 AddressObj
.StreetAddress
:= idGlobal
.Fetch(Value
, ';');
505 AddressObj
.Locality
:= idGlobal
.Fetch(Value
, ';');
506 AddressObj
.Region
:= idGlobal
.Fetch(Value
, ';');
507 AddressObj
.PostalCode
:= idGlobal
.Fetch(Value
, ';');
508 AddressObj
.Nation
:= idGlobal
.Fetch(Value
, ';');
514 procedure ParseMailingLabel(LabelObj
: TIdVCardMailingLabelItem
; LabelStr
:
521 AttribsArray
: array[0..6] of string =
522 ('HOME', 'DOM', 'INTL', 'POSTAL', 'PARCEL', 'WORK', 'PREF');
524 Attribs
:= GetAttributesAndValue(LabelStr
, Value
);
527 while idx
< Attribs
.Count
do
529 { case idGlobal.PosInStrArray(attribs[idx], AttribsArray) of
531 LabelObj.AddressAttributes :=
532 LabelObj.AddressAttributes + [tatHome];
534 LabelObj.AddressAttributes :=
535 LabelObj.AddressAttributes + [tatDomestic];
537 LabelObj.AddressAttributes :=
538 LabelObj.AddressAttributes + [tatInternational];
540 LabelObj.AddressAttributes :=
541 LabelObj.AddressAttributes + [tatPostal];
543 LabelObj.AddressAttributes :=
544 LabelObj.AddressAttributes + [tatParcel];
546 LabelObj.AddressAttributes :=
547 LabelObj.AddressAttributes + [tatWork];
549 LabelObj.AddressAttributes :=
550 LabelObj.AddressAttributes + [tatPreferred];
554 if Attribs
.Count
= 0 then
556 LabelObj
.AddressAttributes
:= [tatInternational
, tatPostal
, tatParcel
,
559 LabelObj
.MailingLabel
.Add(Value
);
565 procedure ParseName(NameObj
: TIdVCardName
; NameStr
: string);
570 NameObj
.SurName
:= Fetch(NameStr
, ';');
571 NameObj
.FirstName
:= Fetch(NameStr
, ';');
572 OtherNames
:= Fetch(NameStr
, ';');
573 NameObj
.Prefix
:= Fetch(NameStr
, ';');
574 NameObj
.Suffix
:= Fetch(NameStr
, ';');
575 OtherNames
:= StringReplace(OtherNames
, ' ', ',', [rfReplaceAll
]);
576 ParseDelinatorToPStrList(NameObj
.OtherNames
, OtherNames
);
579 procedure ParseEMailAddress(EMailObj
: TIdVCardEMailItem
; EMailStr
: string);
586 Attribs
:= GetAttributesAndValue(EMailStr
, Value
);
588 EMailObj
.Address
:= Value
;
589 EMailObj
.Preferred
:= (attribs
.IndexOf('PREF') <> -1);
592 while (idx
< Attribs
.Count
) and (ps
= -1) do
594 { ps := PosInStrArray(Attribs[idx], EMailTypePropertyParameter);
596 0: EMailObj.EMailType := ematAOL;
597 1: EMailObj.EMailType := ematAppleLink;
598 2: EMailObj.EMailType := ematATT;
599 3: EMailObj.EMailType := ematCIS;
600 4: EMailObj.EMailType := emateWorld;
601 5: EMailObj.EMailType := ematInternet;
602 6: EMailObj.EMailType := ematIBMMail;
603 7: EMailObj.EMailType := ematMCIMail;
604 8: EMailObj.EMailType := ematPowerShare;
605 9: EMailObj.EMailType := ematProdigy;
606 10: EMailObj.EMailType := ematTelex;
607 11: EMailObj.EMailType := ematX400;
616 function NewIdVCard(AOwner
: PControl
):PIdVCard
;
617 //constructor TIdVCard.Create(AOwner: TComponent);
619 New( Result
, Create
);
623 FPhoto := TIdVCardEmbeddedObject.Create;
624 FLogo := TIdVCardEmbeddedObject.Create;
625 FSound := TIdVCardEmbeddedObject.Create;
626 FKey := TIdVCardEmbeddedObject.Create;
627 FComments := PStrList.Create;
628 FCatagories := PStrList.Create;
629 FBusinessInfo := TIdVCardBusinessInfo.Create;
630 FGeography := TIdVCardGeog.Create;
631 FFullName := TIdVCardName.Create;
632 FRawForm := PStrList.Create;
633 FEMailAddresses := TIdVCardEMailAddresses.Create(Self);
634 FAddresses := TIdVCardAddresses.Create(Self);
635 FTelephones := TIdVCardTelephones.Create(Self);
636 FURLs := PStrList.Create;
637 FMailingLabels := TIdVCardMailingLabels.Create(Self);}
641 destructor TIdVCard
.Destroy
;
647 FreeAndNil(FComments
);
648 FreeAndNil(FMailingLabels
);
649 FreeAndNil(FCatagories
);
650 FreeAndNil(FBusinessInfo
);
651 FreeAndNil(FGeography
);
653 FreeAndNil(FTelephones
);
654 FreeAndNil(FAddresses
);
655 FreeAndNil(FEMailAddresses
);
656 FreeAndNil(FFullName
);
657 FreeAndNil(FRawForm
);
661 procedure TIdVCard
.ReadFromPStrList(s
: PStrList
);
663 idx
, embedded
: Integer;
668 while (idx
< s
.Count
) and
669 (Trim(UpperCase(s
.Items
[idx
])) <> 'BEGIN:VCARD') do
673 while (idx
< s
.Count
) do
675 if Length(s
.Items
[idx
]) > 0 then
677 if UpperCase(Trim(s
.Items
[idx
])) <> 'END:VCARD' then
679 if embedded
<> 0 then
685 if UpperCase(Trim(s
.Items
[idx
])) <> 'BEGIN:VCARD' then
689 FRawForm
.Add(s
.Items
[idx
]);
693 if (idx
< s
.Count
) and (Length(s
.Items
[idx
]) > 0) then
694 FRawForm
.Add(s
.Items
[idx
]);
695 SetVariablesAfterRead
;
698 procedure TIdVCard
.SetCatagories(Value
: PStrList
);
700 FCatagories
.Assign(Value
);
703 procedure TIdVCard
.SetComments(Value
: PStrList
);
705 FComments
.Assign(Value
);
708 procedure TIdVCard
.SetURLs(Value
: PStrList
);
713 procedure TIdVCard
.SetVariablesAfterRead
;
724 QPCoder
: TIdQuotedPrintableDecoder
;
726 function UnfoldLines
: string;
730 while (idx
< FRawForm
.Count
) and ((Length(FRawForm
.Items
[idx
]) > 0) and
731 (FRawForm
.Items
[idx
][1] = ' ') or (FRawForm
.Items
[idx
][1] = #9)) do
733 Result
:= Result
+ Trim(FRawForm
.Items
[idx
]);
739 procedure ProcessAgent
;
743 procedure ParseEmbeddedObject(EmObj
: TIdVCardEmbeddedObject
; StLn
: string);
749 { attribs := GetAttributesAndValue(StLn, Value);
752 while (idx2 < attribs.Count) do
754 if ((Attribs[idx2] = 'ENCODING=BASE64') or
755 (Attribs[idx2] = 'BASE64')) then
757 emObj.Base64Encoded := True;
761 if not ((Attribs[idx2] = 'VALUE=URI') or
762 (Attribs[idx2] = 'VALUE=URL') or
763 (Attribs[idx2] = 'URI') or
764 (Attribs[idx2] = 'URL')) then
766 emObj.ObjectType := Attribs[idx2];
771 if (Attribs.IndexOf('VALUE=URI') > -1) or
772 (Attribs.IndexOf('VALUE=URL') > -1) or
773 (Attribs.IndexOf('URI') > -1) or
774 (Attribs.IndexOf('URL') > -1) then
776 emObj.ObjectURL := Value + UnfoldLines;
780 AddValueToStrings(EmObj.EmbeddedData, Value);
782 while (idx < FRawForm.Count) and ((Length(FRawForm[idx]) > 0) and
783 (FRawForm[idx][1] = ' ') or (FRawForm[idx][1] = #9)) do
785 AddValueToStrings(EmObj.EmbeddedData, Trim(FRawForm[idx2]));
797 // QPCoder := TIdQuotedPrintableDecoder.Create(Self);
800 QPCoder
.AddCRLF
:= False;
801 QPCoder
.UseEvent
:= False;
802 QPCoder
.IgnoreNotification
:= True;
805 while idx
< FRawForm
.Count
do
807 // Line := FRawForm[idx];
808 Colon
:= Pos(':', Line
);
809 Attribs
:= Copy(Line
, 1, Colon
- 1);
810 if Pos('QUOTED-PRINTABLE', UpperCase(Attribs
)) > 0 then
813 Data
:= Copy(Line
, Colon
+ 1, Length(Line
));
815 // ColonFind := Pos(':', FRawForm[idx]);
816 while ColonFind
= 0 do
818 // Data := Data + CR + LF + TrimLeft(FRawForm[idx]);
820 if idx
<> FRawForm
.Count
then
822 // ColonFind := Pos(':', FRawForm[idx]);
829 Test
:= QPCoder
.CodeString(Data
);
835 Test
:= QPCoder
.GetCodedData
;
837 Test
:= QPCoder
.CompletedInput
;
843 Test
:= QPCoder
.GetCodedData
;
847 ColonFind
:= Pos(';', Attribs
);
849 while ColonFind
<> 0 do
851 Test
:= Copy(Attribs
, 1, ColonFind
);
852 if Pos('QUOTED-PRINTABLE', Test
) = 0 then
856 Attribs
:= Copy(Attribs
, ColonFind
+ 1, Length(Attribs
));
858 ColonFind
:= Pos(';', Attribs
);
861 if Length(Attribs
) <> 0 then
863 if Pos('QUOTED-PRINTABLE', Attribs
) = 0 then
865 Line
:= Line
+ Attribs
;
868 ColonFind
:= Length(Line
);
869 if ColonFind
> 0 then
871 if Line
[ColonFind
] = ';' then
873 Line
:= Copy(Line
, 1, ColonFind
- 1);
876 Line
:= Line
+ ':' + Data
;
878 Colon
:= Pos(':', Line
);
879 SColon
:= Pos(';', Line
);
880 if (Colon
< SColon
) or (SColon
= 0) then
882 Line
:= StringReplace(Line
, ':', ';', []);
885 Test
:= UpperCase(Fetch(Line
, ';'));
887 case PosInStrArray(Test
, VCardProperties
) of
888 0: FFullName
.FormattedName
:= Line
+ UnfoldLines
;
889 1: ParseName(FFullName
, Line
+ UnfoldLines
);
890 2: ParseDelinatorToPStrList(FFullName
.NickNames
, Line
+ UnfoldLines
);
891 3: ParseEmbeddedObject(FPhoto
, Line
);
892 4: FBirthDay
:= ParseDateTimeStamp(Line
+ UnfoldLines
);
893 5: ParseAddress(FAddresses
.Add
, Line
+ UnfoldLines
);
894 6: ParseMailingLabel(FMailingLabels
.Add
, Line
+ UnfoldLines
);
895 7: ParseTelephone(FTelephones
.Add
, Line
+ UnfoldLines
);
896 8: ParseEMailAddress(FEMailAddresses
.Add
, Line
+ UnfoldLines
);
897 9: FEMailProgram
:= Line
+ UnfoldLines
;
898 10: FGeography
.TimeZoneStr
:= Line
+ UnfoldLines
;
899 11: ParseGeography(FGeography
, Line
+ UnfoldLines
);
900 12: FBusinessInfo
.Title
:= Line
+ UnfoldLines
;
901 13: FBusinessInfo
.Role
:= Line
+ UnfoldLines
;
902 14: ParseEmbeddedObject(FLogo
, Line
);
904 16: ParseOrg(FBusinessInfo
, Line
+ UnfoldLines
);
905 17: ParseDelinatorToPStrList(FCatagories
, Line
+ UnfoldLines
);
906 18: FComments
.Add(Line
+ UnfoldLines
);
907 19: FProductID
:= Line
+ UnfoldLines
;
908 20: FLastRevised
:= ParseDateTimeStamp(Line
+ UnfoldLines
);
909 21: FFullName
.SortName
:= Line
+ UnfoldLines
;
910 22: ParseEmbeddedObject(FSound
, Line
);
911 23: AddValueToStrings(FURLs
, Line
+ UnfoldLines
);
912 24: FUniqueID
:= Line
+ UnfoldLines
;
913 25: FVCardVersion
:= StrToFloat(Line
+ UnfoldLines
);
914 26: FClassification
:= Line
+ UnfoldLines
;
915 27: ParseEmbeddedObject(FKey
, Line
);
925 function TIdVCardEMailAddresses
.Add
: TIdVCardEMailItem
;
927 // Result := TIdVCardEMailItem(inherited Add);
930 //constructor TIdVCardEMailAddresses.Create(AOwner: TPersistent);
931 function NewIdVCardEMailAddresses(AOwner
: PObj
):PIdVCardEMailAddresses
;
933 New( Result
, Create
);
934 // inherited Create(AOwner, TIdVCardEMailItem);
937 function TIdVCardEMailAddresses
.GetItem(Index
: Integer): TIdVCardEMailItem
;
939 // Result := TIdVCardEMailItem(inherited Items[Index]);
942 procedure TIdVCardEMailAddresses
.SetItem(Index
: Integer;
943 const Value
: TIdVCardEMailItem
);
945 // inherited SetItem(Index, Value);
948 procedure TIdVCardEMailItem
.Assign(Source
: PObj
);
950 EMail
: TIdVCardEMailItem
;
952 { if ClassType <> Source.ClassType then
958 EMail := TIdVCardEMailItem(Source);
959 EMailType := EMail.EMailType;
960 Preferred := EMail.Preferred;
961 Address := EMail.Address;
965 //constructor TIdVCardEMailItem.Create(Collection: TCollection);
966 function NewIdVCardEMailItem(Collection
: PCollection
):PIdVCardEMailItem
;
968 New( Result
, Create
);
971 FEMailType
:= ematInternet
;
974 function TIdVCardAddresses
.Add
: TIdCardAddressItem
;
976 // Result := TIdCardAddressItem(inherited Add);
979 //constructor TIdVCardAddresses.Create(AOwner: TPersistent);
980 function NewIdVCardAddresses(AOwner
: PObj
):PIdVCardAddresses
;
982 New( Result
, Create
);
983 // inherited Create(AOwner, TIdCardAddressItem);
986 function TIdVCardAddresses
.GetItem(Index
: Integer): TIdCardAddressItem
;
988 // Result := TIdCardAddressItem(inherited Items[Index]);
991 procedure TIdVCardAddresses
.SetItem(Index
: Integer;
992 const Value
: TIdCardAddressItem
);
994 // inherited SetItem(Index, Value);
997 function TIdVCardTelephones
.Add
: TIdCardPhoneNumber
;
999 // Result := TIdCardPhoneNumber(inherited Add);
1002 //constructor TIdVCardTelephones.Create(AOwner: TPersistent);
1003 function NewIdVCardTelephones(AOwner
: PObj
):PIdVCardTelephones
;
1005 New( Result
, Create
);
1006 // inherited Create(AOwner, TIdCardPhoneNumber);
1009 function TIdVCardTelephones
.GetItem(Index
: Integer): TIdCardPhoneNumber
;
1011 // Result := TIdCardPhoneNumber(inherited Items[Index]);
1014 procedure TIdVCardTelephones
.SetItem(Index
: Integer;
1015 const Value
: TIdCardPhoneNumber
);
1017 // inherited SetItem(Index, Value);
1020 //constructor TIdVCardName.Create;
1021 function NewIdVCardName
:PIdVCardName
;
1024 New( Result
, Create
);
1027 // FOtherNames := PStrList.Create;
1028 // FNickNames := PStrList.Create;
1032 destructor TIdVCardName
.Destroy
;
1034 FreeAndNil(FNickNames
);
1035 FreeAndNil(FOtherNames
);
1039 procedure TIdVCardName
.SetNickNames(Value
: PStrList
);
1041 FNickNames
.Assign(Value
);
1044 procedure TIdVCardName
.SetOtherNames(Value
: PStrList
);
1046 FOtherNames
.Assign(Value
);
1049 //constructor TIdVCardBusinessInfo.Create;
1050 function NewIdVCardBusinessInfo
:PIdVCardBusinessInfo
;
1052 New( Result
, Create
);
1056 // FDivisions := PStrList.Create;
1060 destructor TIdVCardBusinessInfo
.Destroy
;
1062 FreeAndNil(FDivisions
);
1066 procedure TIdVCardBusinessInfo
.SetDivisions(Value
: PStrList
);
1068 FDivisions
.Assign(Value
);
1071 procedure TIdVCardMailingLabelItem
.Assign(Source
: PObj
);
1073 lbl
: TIdVCardMailingLabelItem
;
1075 { if ClassType <> Source.ClassType then
1081 lbl := TIdVCardMailingLabelItem(Source);
1082 AddressAttributes := lbl.AddressAttributes;
1083 MailingLabel.Assign(lbl.MailingLabel);
1087 //constructor TIdVCardMailingLabelItem.Create(Collection: TCollection);
1088 function NewIdVCardMailingLabelItem(Collection
: PCollection
):PIdVCardMailingLabelItem
;
1090 New( Result
, Create
);
1094 // FMailingLabel := PStrList.Create;
1098 destructor TIdVCardMailingLabelItem
.Destroy
;
1100 FreeAndNil(FMailingLabel
);
1104 procedure TIdVCardMailingLabelItem
.SetMailingLabel(Value
: PStrList
);
1106 FMailingLabel
.Assign(Value
);
1109 function TIdVCardMailingLabels
.Add
: TIdVCardMailingLabelItem
;
1111 // Result := TIdVCardMailingLabelItem(inherited Add);
1114 //constructor TIdVCardMailingLabels.Create(AOwner: TPersistent);
1115 function NewIdVCardMailingLabels(AOwner
: PObj
):PIdVCardMailingLabels
;
1117 New( Result
, Create
);
1118 // inherited Create(AOwner, TIdVCardMailingLabelItem);
1121 function TIdVCardMailingLabels
.GetItem(
1122 Index
: Integer): TIdVCardMailingLabelItem
;
1124 // Result := TIdVCardMailingLabelItem(inherited GetItem(Index));
1127 procedure TIdVCardMailingLabels
.SetItem(Index
: Integer;
1128 const Value
: TIdVCardMailingLabelItem
);
1130 // inherited SetItem(Index, Value);
1133 //constructor TIdVCardEmbeddedObject.Create;
1134 function NewIdVCardEmbeddedObject
:PIdVCardEmbeddedObject
;
1136 New( Result
, Create
);
1140 // FEmbeddedData := PStrList.Create;
1144 destructor TIdVCardEmbeddedObject
.Destroy
;
1146 FreeAndNil(FEmbeddedData
);
1150 procedure TIdVCardEmbeddedObject
.SetEmbeddedData(const Value
: PStrList
);
1152 FEmbeddedData
.Assign(Value
);
1155 procedure TIdCardPhoneNumber
.Assign(Source
: PObj
);
1157 Phone
: TIdCardPhoneNumber
;
1159 { if ClassType <> Source.ClassType then
1165 Phone := TIdCardPhoneNumber(Source);
1166 PhoneAttributes := Phone.PhoneAttributes;
1167 Number := Phone.Number;
1171 procedure TIdCardAddressItem
.Assign(Source
: PObj
);
1173 Addr
: TIdCardAddressItem
;
1175 { if ClassType <> Source.ClassType then
1181 Addr := TIdCardAddressItem(Source);
1182 AddressAttributes := Addr.AddressAttributes;
1183 POBox := Addr.POBox;
1184 ExtendedAddress := Addr.ExtendedAddress;
1185 StreetAddress := Addr.StreetAddress;
1186 Locality := Addr.Locality;
1187 Region := Addr.Region;
1188 PostalCode := Addr.PostalCode;
1189 Nation := Addr.Nation;
1193 function NewIdVCardGeog
:PIdVCardGeog
;
1195 New( Result
, Create
);
1198 function NewIdCardPhoneNumber
:PIdCardPhoneNumber
;
1200 New( Result
, Create
);
1203 function NewIdCardAddressItem
:PIdCardAddressItem
;
1205 New( Result
, Create
);