Changeset 3 for trunk/UContact.pas
- Timestamp:
- Jan 29, 2018, 10:54:40 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 5 5 *.lps 6 6 *.res 7 vCardStudio.exe
-
- Property svn:ignore
-
trunk/UContact.pas
r1 r3 57 57 function GetNext(var Text: string; Separator: string): string; 58 58 public 59 Records: TContacts;59 Contacts: TContacts; 60 60 function GetFileName: string; override; 61 61 function GetFileExt: string; override; … … 73 73 resourcestring 74 74 SVCardFile = 'vCard file'; 75 SUnknownCommand = 'Unknown command: %s'; 75 76 76 77 { TContactsFile } … … 110 111 try 111 112 Output := TStringList.Create; 112 for I := 0 to Records.Count - 1 do113 with TContact( Records[I]), Output do begin113 for I := 0 to Contacts.Count - 1 do 114 with TContact(Contacts[I]), Output do begin 114 115 Add('BEGIN:VCARD'); 115 116 if Version <> '' then Add('VERSION:' + Version); … … 160 161 Charset: string; 161 162 Encoding: string; 162 begin 163 inherited; 164 Records.Clear; 163 CommandItems: TStringList; 164 begin 165 inherited; 166 Contacts.Clear; 165 167 Lines := TStringList.Create; 166 168 Lines.LoadFromFile(FileName); 167 169 try 170 CommandItems := TStringList.Create; 171 CommandItems.Delimiter := ';'; 168 172 I := 0; 169 173 while I < Lines.Count do begin … … 173 177 end else 174 178 if Line = 'END:VCARD' then begin 175 Records.Add(NewRecord);179 Contacts.Add(NewRecord); 176 180 NewRecord := nil; 177 181 end else 178 182 if Pos(':', Line) > 0 then begin 179 183 CommandPart := GetNext(Line, ':'); 180 Command := GetNext(CommandPart, ';'); 181 while CommandPart <> '' do begin 182 CommandParam := GetNext(CommandPart, ';'); 183 if CommandParam = 'CHARSET' then begin 184 GetNext(CommandParam, '='); 185 Charset := CommandParam; 186 end else 187 if CommandParam = 'ENCODING' then begin 188 GetNext(CommandParam, '='); 189 Encoding := CommandParam; 190 end else if Assigned(FOnError) then FOnError('Unknown command param: ' + CommandParam); 184 CommandItems.DelimitedText := CommandPart; 185 if CommandItems.IndexOfName('CHARSET') >= 0 then begin 186 Charset := CommandItems.Values['CHARSET']; 187 CommandItems.Delete(CommandItems.IndexOfName('CHARSET')); 188 end 189 else if CommandItems.IndexOfName('ENCODING') >= 0 then begin 190 Encoding := CommandItems.Values['ENCODING']; 191 CommandItems.Delete(CommandItems.IndexOfName('ENCODING')); 191 192 end; 193 Command := CommandItems.DelimitedText; 194 192 195 if Command = 'FN' then NewRecord.FullName := Line 193 196 else if Command = 'N' then begin … … 212 215 else if Command = 'X-NICKNAME' then NewRecord.NickName := Line 213 216 else if Command = 'EMAIL;HOME' then NewRecord.EmailHome := Line 214 else if Command = 'EMAIL ;INTERNET' then NewRecord.EmailInternet := Line217 else if Command = 'EMAIL:INTERNET' then NewRecord.EmailInternet := Line 215 218 else if Command = 'NOTE' then NewRecord.Note := Line 216 219 else if Command = 'ORG' then NewRecord.Organization := Line … … 231 234 Inc(I); 232 235 end; 236 CommandItems.Free; 233 237 finally 234 238 Lines.Free; … … 239 243 begin 240 244 inherited; 241 Records := TContacts.Create;245 Contacts := TContacts.Create; 242 246 end; 243 247 244 248 destructor TContactsFile.Destroy; 245 249 begin 246 Records.Free;250 Contacts.Free; 247 251 inherited; 248 252 end;
Note:
See TracChangeset
for help on using the changeset viewer.