modified PBE_U.dfm
modified PBE_U.pas * Rewrote parser to parse the whole backup into an array of Group, Name and Value * Updated PhoneBook-routines to use the new array + Debug panel for insight into the global data array
This commit is contained in:
parent
03bcfc89a3
commit
2a6017fd84
127
PBE_U.dfm
127
PBE_U.dfm
@ -1,6 +1,6 @@
|
|||||||
object Form1: TForm1
|
object Form1: TForm1
|
||||||
Left = 198
|
Left = 190
|
||||||
Top = 109
|
Top = 105
|
||||||
Width = 818
|
Width = 818
|
||||||
Height = 656
|
Height = 656
|
||||||
BorderIcons = [biSystemMenu, biMinimize]
|
BorderIcons = [biSystemMenu, biMinimize]
|
||||||
@ -33,7 +33,6 @@ object Form1: TForm1
|
|||||||
Width = 793
|
Width = 793
|
||||||
Height = 329
|
Height = 329
|
||||||
ActivePage = TabSheet1
|
ActivePage = TabSheet1
|
||||||
TabIndex = 0
|
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
object TabSheet1: TTabSheet
|
object TabSheet1: TTabSheet
|
||||||
Caption = 'Phonebook'
|
Caption = 'Phonebook'
|
||||||
@ -382,23 +381,13 @@ object Form1: TForm1
|
|||||||
ItemHeight = 13
|
ItemHeight = 13
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
end
|
end
|
||||||
object SM_Message: TEdit
|
|
||||||
Left = 136
|
|
||||||
Top = 56
|
|
||||||
Width = 233
|
|
||||||
Height = 113
|
|
||||||
AutoSize = False
|
|
||||||
Enabled = False
|
|
||||||
TabOrder = 1
|
|
||||||
Text = 'SM_Message'
|
|
||||||
end
|
|
||||||
object SM_SMSC: TEdit
|
object SM_SMSC: TEdit
|
||||||
Left = 184
|
Left = 184
|
||||||
Top = 8
|
Top = 8
|
||||||
Width = 185
|
Width = 185
|
||||||
Height = 21
|
Height = 21
|
||||||
Enabled = False
|
Enabled = False
|
||||||
TabOrder = 2
|
TabOrder = 1
|
||||||
Text = 'SM_SMSC'
|
Text = 'SM_SMSC'
|
||||||
end
|
end
|
||||||
object SM_Recipient: TEdit
|
object SM_Recipient: TEdit
|
||||||
@ -407,7 +396,7 @@ object Form1: TForm1
|
|||||||
Width = 185
|
Width = 185
|
||||||
Height = 21
|
Height = 21
|
||||||
Enabled = False
|
Enabled = False
|
||||||
TabOrder = 3
|
TabOrder = 2
|
||||||
Text = 'SM_Recipient'
|
Text = 'SM_Recipient'
|
||||||
end
|
end
|
||||||
object SM_PID: TEdit
|
object SM_PID: TEdit
|
||||||
@ -416,7 +405,7 @@ object Form1: TForm1
|
|||||||
Width = 49
|
Width = 49
|
||||||
Height = 21
|
Height = 21
|
||||||
Enabled = False
|
Enabled = False
|
||||||
TabOrder = 4
|
TabOrder = 3
|
||||||
Text = 'SM_PID'
|
Text = 'SM_PID'
|
||||||
end
|
end
|
||||||
object SM_DCS: TEdit
|
object SM_DCS: TEdit
|
||||||
@ -425,7 +414,7 @@ object Form1: TForm1
|
|||||||
Width = 49
|
Width = 49
|
||||||
Height = 21
|
Height = 21
|
||||||
Enabled = False
|
Enabled = False
|
||||||
TabOrder = 5
|
TabOrder = 4
|
||||||
Text = 'SM_DCS'
|
Text = 'SM_DCS'
|
||||||
end
|
end
|
||||||
object SM_TimeStamp: TEdit
|
object SM_TimeStamp: TEdit
|
||||||
@ -434,7 +423,7 @@ object Form1: TForm1
|
|||||||
Width = 153
|
Width = 153
|
||||||
Height = 21
|
Height = 21
|
||||||
Enabled = False
|
Enabled = False
|
||||||
TabOrder = 6
|
TabOrder = 5
|
||||||
Text = 'SM_TimeStamp'
|
Text = 'SM_TimeStamp'
|
||||||
end
|
end
|
||||||
object SM_NewButton: TButton
|
object SM_NewButton: TButton
|
||||||
@ -444,7 +433,7 @@ object Form1: TForm1
|
|||||||
Height = 25
|
Height = 25
|
||||||
Caption = 'New'
|
Caption = 'New'
|
||||||
Enabled = False
|
Enabled = False
|
||||||
TabOrder = 7
|
TabOrder = 6
|
||||||
end
|
end
|
||||||
object SM_DelButton: TButton
|
object SM_DelButton: TButton
|
||||||
Left = 272
|
Left = 272
|
||||||
@ -453,6 +442,16 @@ object Form1: TForm1
|
|||||||
Height = 25
|
Height = 25
|
||||||
Caption = 'Delete!'
|
Caption = 'Delete!'
|
||||||
Enabled = False
|
Enabled = False
|
||||||
|
TabOrder = 7
|
||||||
|
end
|
||||||
|
object SM_Message: TMemo
|
||||||
|
Left = 136
|
||||||
|
Top = 56
|
||||||
|
Width = 233
|
||||||
|
Height = 137
|
||||||
|
Enabled = False
|
||||||
|
Lines.Strings = (
|
||||||
|
'SM_Message')
|
||||||
TabOrder = 8
|
TabOrder = 8
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -464,8 +463,7 @@ object Form1: TForm1
|
|||||||
Top = 8
|
Top = 8
|
||||||
Width = 769
|
Width = 769
|
||||||
Height = 273
|
Height = 273
|
||||||
ActivePage = TabSheet5
|
ActivePage = TabSheet7
|
||||||
TabIndex = 0
|
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
object TabSheet5: TTabSheet
|
object TabSheet5: TTabSheet
|
||||||
Caption = 'WAP Profiles'
|
Caption = 'WAP Profiles'
|
||||||
@ -605,6 +603,91 @@ object Form1: TForm1
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
object TabSheet12: TTabSheet
|
||||||
|
Caption = 'Debug'
|
||||||
|
ImageIndex = 4
|
||||||
|
object Label18: TLabel
|
||||||
|
Left = 8
|
||||||
|
Top = 8
|
||||||
|
Width = 86
|
||||||
|
Height = 13
|
||||||
|
Caption = 'Number of entries:'
|
||||||
|
end
|
||||||
|
object Label19: TLabel
|
||||||
|
Left = 16
|
||||||
|
Top = 58
|
||||||
|
Width = 29
|
||||||
|
Height = 13
|
||||||
|
Caption = 'Group'
|
||||||
|
end
|
||||||
|
object Label20: TLabel
|
||||||
|
Left = 13
|
||||||
|
Top = 83
|
||||||
|
Width = 28
|
||||||
|
Height = 13
|
||||||
|
Caption = 'Name'
|
||||||
|
end
|
||||||
|
object DBG_Count: TEdit
|
||||||
|
Left = 96
|
||||||
|
Top = 4
|
||||||
|
Width = 65
|
||||||
|
Height = 21
|
||||||
|
TabOrder = 0
|
||||||
|
Text = 'DBG_Count'
|
||||||
|
end
|
||||||
|
object DBG_Entry: TMemo
|
||||||
|
Left = 8
|
||||||
|
Top = 104
|
||||||
|
Width = 289
|
||||||
|
Height = 145
|
||||||
|
Lines.Strings = (
|
||||||
|
'DBG_Entry')
|
||||||
|
TabOrder = 1
|
||||||
|
end
|
||||||
|
object DBG_ShowEntry: TButton
|
||||||
|
Left = 328
|
||||||
|
Top = 56
|
||||||
|
Width = 121
|
||||||
|
Height = 25
|
||||||
|
Caption = 'Show Entry'
|
||||||
|
TabOrder = 2
|
||||||
|
OnClick = DBG_ShowEntryClick
|
||||||
|
end
|
||||||
|
object DBG_EntryGroup: TEdit
|
||||||
|
Left = 48
|
||||||
|
Top = 56
|
||||||
|
Width = 249
|
||||||
|
Height = 21
|
||||||
|
TabOrder = 3
|
||||||
|
Text = 'DBG_EntryGroup'
|
||||||
|
end
|
||||||
|
object DBG_EntryName: TEdit
|
||||||
|
Left = 48
|
||||||
|
Top = 80
|
||||||
|
Width = 249
|
||||||
|
Height = 21
|
||||||
|
TabOrder = 4
|
||||||
|
Text = 'DBG_EntryName'
|
||||||
|
end
|
||||||
|
object DBG_SelEntry: TSpinEdit
|
||||||
|
Left = 328
|
||||||
|
Top = 32
|
||||||
|
Width = 121
|
||||||
|
Height = 22
|
||||||
|
MaxValue = 0
|
||||||
|
MinValue = 0
|
||||||
|
TabOrder = 5
|
||||||
|
Value = 0
|
||||||
|
end
|
||||||
|
object DBG_LastEntry: TCheckBox
|
||||||
|
Left = 8
|
||||||
|
Top = 248
|
||||||
|
Width = 209
|
||||||
|
Height = 17
|
||||||
|
Caption = 'Last entry of this group'
|
||||||
|
TabOrder = 6
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
object StatusBar: TStatusBar
|
object StatusBar: TStatusBar
|
||||||
Left = 0
|
Left = 0
|
||||||
@ -688,8 +771,6 @@ object Form1: TForm1
|
|||||||
Top = 264
|
Top = 264
|
||||||
Width = 465
|
Width = 465
|
||||||
Height = 22
|
Height = 22
|
||||||
Min = 0
|
|
||||||
Max = 100
|
|
||||||
TabOrder = 9
|
TabOrder = 9
|
||||||
Visible = False
|
Visible = False
|
||||||
end
|
end
|
||||||
|
148
PBE_U.pas
148
PBE_U.pas
@ -4,7 +4,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||||||
Dialogs, StdCtrls, ComCtrls, ExtCtrls, Jpeg, GIFImage, FileCtrl;
|
Dialogs, StdCtrls, ComCtrls, ExtCtrls, Jpeg, GIFImage, FileCtrl, Spin;
|
||||||
|
|
||||||
type
|
type
|
||||||
TForm1 = class(TForm)
|
TForm1 = class(TForm)
|
||||||
@ -58,7 +58,6 @@ type
|
|||||||
Button_Load: TButton;
|
Button_Load: TButton;
|
||||||
Button_Save: TButton;
|
Button_Save: TButton;
|
||||||
SM_List: TListBox;
|
SM_List: TListBox;
|
||||||
SM_Message: TEdit;
|
|
||||||
PB_NewButton: TButton;
|
PB_NewButton: TButton;
|
||||||
PB_DelButton: TButton;
|
PB_DelButton: TButton;
|
||||||
SM_SMSC: TEdit;
|
SM_SMSC: TEdit;
|
||||||
@ -92,6 +91,18 @@ type
|
|||||||
ProgressBar: TProgressBar;
|
ProgressBar: TProgressBar;
|
||||||
Button_SaveAs: TButton;
|
Button_SaveAs: TButton;
|
||||||
Button_Close: TButton;
|
Button_Close: TButton;
|
||||||
|
SM_Message: TMemo;
|
||||||
|
TabSheet12: TTabSheet;
|
||||||
|
DBG_Count: TEdit;
|
||||||
|
Label18: TLabel;
|
||||||
|
DBG_Entry: TMemo;
|
||||||
|
DBG_ShowEntry: TButton;
|
||||||
|
DBG_EntryGroup: TEdit;
|
||||||
|
DBG_EntryName: TEdit;
|
||||||
|
Label19: TLabel;
|
||||||
|
Label20: TLabel;
|
||||||
|
DBG_SelEntry: TSpinEdit;
|
||||||
|
DBG_LastEntry: TCheckBox;
|
||||||
procedure Button_LoadClick(Sender: TObject);
|
procedure Button_LoadClick(Sender: TObject);
|
||||||
procedure PB_ListClick(Sender: TObject);
|
procedure PB_ListClick(Sender: TObject);
|
||||||
procedure PB_OrderFLClick(Sender: TObject);
|
procedure PB_OrderFLClick(Sender: TObject);
|
||||||
@ -101,12 +112,13 @@ type
|
|||||||
procedure FileListBox1Change(Sender: TObject);
|
procedure FileListBox1Change(Sender: TObject);
|
||||||
procedure DirectoryListBox1Change(Sender: TObject);
|
procedure DirectoryListBox1Change(Sender: TObject);
|
||||||
procedure Button_CloseClick(Sender: TObject);
|
procedure Button_CloseClick(Sender: TObject);
|
||||||
|
procedure DBG_ShowEntryClick(Sender: TObject);
|
||||||
private
|
private
|
||||||
{ Private declarations }
|
{ Private declarations }
|
||||||
public
|
public
|
||||||
{ Public declarations }
|
{ Public declarations }
|
||||||
end;
|
end;
|
||||||
TPBEntry = record
|
TPhoneEntry = record
|
||||||
Version: String[5];
|
Version: String[5];
|
||||||
Name: String[30];
|
Name: String[30];
|
||||||
Home, Work, Mobile, Fax, Other: String[80];
|
Home, Work, Mobile, Fax, Other: String[80];
|
||||||
@ -115,18 +127,26 @@ type
|
|||||||
Company: String[30];
|
Company: String[30];
|
||||||
PhotoFile: String[255];
|
PhotoFile: String[255];
|
||||||
end;
|
end;
|
||||||
|
TPBData = record
|
||||||
|
Group: AnsiString;
|
||||||
|
Name: AnsiString;
|
||||||
|
Value: AnsiString;
|
||||||
|
LastOfGroup: Boolean;
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
Form1: TForm1;
|
Form1: TForm1;
|
||||||
BackupFileName: string;
|
BackupFileName: string;
|
||||||
PhoneBook: array[1..999] of TPBEntry;
|
PB: array of TPBData;
|
||||||
PhoneBookMax: integer;
|
PhoneBook: array of TPhoneEntry;
|
||||||
PhoneBookPhotoCount: integer = 0;
|
PhoneBookPhotoCount: integer = 0;
|
||||||
f: Textfile;
|
f: Textfile;
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
const CRLF: string = Chr(13)+Chr(10);
|
||||||
|
|
||||||
{$R *.dfm}
|
{$R *.dfm}
|
||||||
|
|
||||||
function DecodeQP(my: string): string;
|
function DecodeQP(my: string): string;
|
||||||
@ -134,38 +154,36 @@ const qpa: string[16] = '0123456789ABCDEF';
|
|||||||
var i: integer;
|
var i: integer;
|
||||||
qp: byte;
|
qp: byte;
|
||||||
begin
|
begin
|
||||||
i := Pos('=',my);
|
Result := my;
|
||||||
|
i := Pos('=',Result);
|
||||||
while (i>0) do begin
|
while (i>0) do begin
|
||||||
my[i] := '?';
|
Result[i] := '?';
|
||||||
qp := (Pos(my[i+1],qpa)-1)*16+Pos(my[i+2],qpa)-1;
|
qp := (Pos(Result[i+1],qpa)-1)*16+Pos(Result[i+2],qpa)-1;
|
||||||
my := Copy(my,1,i-1)+Chr(qp)+Copy(my,i+3,Length(my)-i-2);
|
Result := Copy(Result,1,i-1)+Chr(qp)+Copy(Result,i+3,Length(Result)-i-2);
|
||||||
i := Pos('=',my);
|
i := Pos('=',Result);
|
||||||
end;
|
end;
|
||||||
DecodeQP := my;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function B64toBin(my: string): string;
|
function B64toBin(my: string): string;
|
||||||
const b64a: string[64] = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
const b64a: string[64] = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
||||||
var x,i,j: integer;
|
var x,i,j: integer;
|
||||||
res: string;
|
|
||||||
begin
|
begin
|
||||||
res := '';
|
Result := '';
|
||||||
for i:=1 to 4 do begin
|
for i:=1 to 4 do begin
|
||||||
x := Pos(my[i],b64a)-1;
|
x := Pos(my[i],b64a)-1;
|
||||||
if (x>=0) then begin
|
if (x>=0) then begin
|
||||||
j := 32;
|
j := 32;
|
||||||
repeat
|
repeat
|
||||||
if (x DIV j)>0 then begin
|
if (x DIV j)>0 then begin
|
||||||
res := res + '1';
|
Result := Result + '1';
|
||||||
x := x - j;
|
x := x - j;
|
||||||
end else res := res + '0';
|
end else Result := Result + '0';
|
||||||
j := j DIV 2;
|
j := j DIV 2;
|
||||||
until (j=0);
|
until (j=0);
|
||||||
end else begin
|
end else begin
|
||||||
res := res + '000000';
|
Result := Result + '000000';
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
B64toBin := res;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function BintoASC(my: string): string;
|
function BintoASC(my: string): string;
|
||||||
@ -213,11 +231,11 @@ begin
|
|||||||
i := Pos('PHOTO;ENCODING=BASE64;TYPE=',data);
|
i := Pos('PHOTO;ENCODING=BASE64;TYPE=',data);
|
||||||
if (i>0) then begin
|
if (i>0) then begin
|
||||||
data := Copy(data,i+27,Length(data)-i-27);
|
data := Copy(data,i+27,Length(data)-i-27);
|
||||||
i := Pos('<br/><br/>',data); // Find end of record
|
i := Pos(CRLF+CRLF,data); // Find end of record
|
||||||
if (i>0) then begin
|
if (i>0) then begin
|
||||||
data := Copy(data,1,i-1);
|
data := Copy(data,1,i-1);
|
||||||
end;
|
end;
|
||||||
data := StringReplace(data,'<br/>','',[rfReplaceAll]); // Remove all <br/>
|
data := StringReplace(data,CRLF,'',[rfReplaceAll]); // Remove all <br/>
|
||||||
i := Pos(':',data); // Find Image-Type (first 3 or 4 chars followed by a colon)
|
i := Pos(':',data); // Find Image-Type (first 3 or 4 chars followed by a colon)
|
||||||
if (i>0) then begin
|
if (i>0) then begin
|
||||||
t := Copy(data,1,i-1); // Now contains the Image-Type ('JPEG' or 'GIF')
|
t := Copy(data,1,i-1); // Now contains the Image-Type ('JPEG' or 'GIF')
|
||||||
@ -248,23 +266,23 @@ var i,j: integer;
|
|||||||
tmp: string;
|
tmp: string;
|
||||||
begin
|
begin
|
||||||
qp := false;
|
qp := false;
|
||||||
s := '<br/>'+field+':';
|
s := CRLF+field+':';
|
||||||
i := Pos(s, data);
|
i := Pos(s, data);
|
||||||
if (i<=0) then begin
|
if (i<=0) then begin
|
||||||
s := '<br/>'+field+';ENCODING=QUOTED-PRINTABLE:';
|
s := CRLF+field+';ENCODING=QUOTED-PRINTABLE:';
|
||||||
i := Pos(s, data);
|
i := Pos(s, data);
|
||||||
if (i>0) then qp := true;
|
if (i>0) then qp := true;
|
||||||
end;
|
end;
|
||||||
if (i>0) then begin
|
if (i>0) then begin
|
||||||
j := Pos('<br/>',Copy(data,i+5,Length(data)-i-5))+i+5;
|
j := Pos(CRLF,Copy(data,i+5,Length(data)-i-5))+i+5;
|
||||||
tmp := Copy(data,i+Length(s),j-i-Length(s)-1);
|
tmp := Copy(data,i+Length(s),j-i-Length(s)-1);
|
||||||
end else tmp := '';
|
end else tmp := '';
|
||||||
if (qp) then tmp := DecodeQP(tmp);
|
if (qp) then tmp := DecodeQP(tmp);
|
||||||
FindDataInStream := tmp;
|
FindDataInStream := tmp;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ParsePBStream(data: AnsiString): TPBEntry;
|
function ParsePBStream(data: AnsiString): TPhoneEntry;
|
||||||
var tmp: TPBEntry;
|
var tmp: TPhoneEntry;
|
||||||
begin
|
begin
|
||||||
tmp.Version := FindDataInStream('VERSION',data);
|
tmp.Version := FindDataInStream('VERSION',data);
|
||||||
tmp.Name := FindDataInStream('N',data);
|
tmp.Name := FindDataInStream('N',data);
|
||||||
@ -302,7 +320,7 @@ var i: integer;
|
|||||||
begin
|
begin
|
||||||
Form1.PageControl1.ActivePageIndex := 0;
|
Form1.PageControl1.ActivePageIndex := 0;
|
||||||
Form1.PB_List.Clear;
|
Form1.PB_List.Clear;
|
||||||
for i:=1 to PhoneBookMax do begin
|
for i:=0 to Length(PhoneBook)-1 do begin
|
||||||
Form1.PB_List.Items.Add(FormatName(PhoneBook[i].Name));
|
Form1.PB_List.Items.Add(FormatName(PhoneBook[i].Name));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -314,8 +332,8 @@ var i: integer;
|
|||||||
begin
|
begin
|
||||||
e := false;
|
e := false;
|
||||||
d := '';
|
d := '';
|
||||||
if (PhoneBookMax>0) then begin
|
if (Length(PhoneBook)>0) then begin
|
||||||
for i:=1 to PhoneBookMax do begin
|
for i:=0 to Length(PhoneBook)-1 do begin
|
||||||
if (PhoneBook[i].PhotoFile<>'') then begin
|
if (PhoneBook[i].PhotoFile<>'') then begin
|
||||||
if (d='') then d := ExtractFileDir(PhoneBook[i].PhotoFile);
|
if (d='') then d := ExtractFileDir(PhoneBook[i].PhotoFile);
|
||||||
if (NOT DeleteFile(PhoneBook[i].PhotoFile)) then e := true;
|
if (NOT DeleteFile(PhoneBook[i].PhotoFile)) then e := true;
|
||||||
@ -327,27 +345,64 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure ReadPBintoMem(var InFile: TextFile);
|
procedure ReadPBintoMem(var InFile: TextFile);
|
||||||
var i: integer;
|
var i, j: integer;
|
||||||
cl: AnsiString;
|
cl, gp: AnsiString;
|
||||||
begin
|
begin
|
||||||
Form1.ProgressBar.Min := 0;
|
Form1.ProgressBar.Min := 0;
|
||||||
Form1.ProgressBar.Max := FileSize(InFile);
|
Form1.ProgressBar.Max := FileSize(InFile);
|
||||||
|
Form1.ProgressBar.Position := 0;
|
||||||
Form1.ProgressBar.Visible := true;
|
Form1.ProgressBar.Visible := true;
|
||||||
i:=1;
|
i:=0;
|
||||||
|
gp := '';
|
||||||
repeat
|
repeat
|
||||||
ReadLn(InFile, cl);
|
ReadLn(InFile, cl);
|
||||||
until Eof(InFile) OR (cl='<Contacts>');
|
|
||||||
ReadLn(InFile, cl);
|
|
||||||
repeat
|
|
||||||
Form1.ProgressBar.Position := FilePos(InFile);
|
Form1.ProgressBar.Position := FilePos(InFile);
|
||||||
cl := Trim(cl);
|
cl := Trim(cl);
|
||||||
PhoneBook[i] := ParsePBStream(cl);
|
cl := StringReplace(cl, '<br/>', CRLF, [rfReplaceAll]);
|
||||||
|
if (cl[1]='<') AND (cl[Length(cl)]='>') AND (cl[Length(cl)-1]<>'/') AND (Pos(' ',cl)=0) then begin
|
||||||
|
gp := gp + '>' + Copy(cl, 2, Length(cl)-2);
|
||||||
|
end else if (cl[1]='<') AND (cl[Length(cl)-1]+cl[Length(cl)]='/>') AND (Pos(' ',cl)=0) then begin
|
||||||
|
gp := Copy(gp,1,Length(gp)-Length(cl)+2);
|
||||||
|
// gp := StringReplace(gp, '>' + Copy(cl, 2, Length(cl)-3), '', [rfReplaceAll]);
|
||||||
|
if (i>0) then PB[i-1].LastOfGroup := true;
|
||||||
|
end else if (Pos('value=', LowerCase(cl))>0) AND (Pos('/>', cl)>0) then begin
|
||||||
|
Inc(i);
|
||||||
|
SetLength(PB, i);
|
||||||
|
PB[i-1].Group := gp;
|
||||||
|
PB[i-1].Name := Copy(cl, Pos('<', cl)+1, Pos(' ', cl)-Pos('<', cl)-1);
|
||||||
|
PB[i-1].Value := Copy(cl, Pos('value=', LowerCase(cl))+6, Pos('/>', cl)-Pos('value=', LowerCase(cl))-6);
|
||||||
|
PB[i-1].LastOfGroup := false;
|
||||||
|
end else if (Pos('value=', LowerCase(cl))>0) AND (Pos('/>', cl)=0) then begin
|
||||||
|
Inc(i);
|
||||||
|
SetLength(PB, i);
|
||||||
|
PB[i-1].Group := gp;
|
||||||
|
PB[i-1].Name := Copy(cl, Pos('<', cl)+1, Pos(' ', cl)-Pos('<', cl)-1);
|
||||||
|
PB[i-1].Value := Copy(cl, Pos('value=', LowerCase(cl))+6, Length(cl)-Pos('value=', LowerCase(cl))-6);
|
||||||
|
PB[i-1].LastOfGroup := false;
|
||||||
|
end else if (Pos('value=', LowerCase(cl))=0) AND (Pos('/>', cl)=0) then begin
|
||||||
|
PB[i-1].Value := PB[i-1].Value + cl;
|
||||||
|
end else if (Pos('value=', LowerCase(cl))=0) AND (Pos('/>', cl)>0) then begin
|
||||||
|
PB[i-1].Value := PB[i-1].Value + Copy(cl,1,Pos('/>', cl)-2);
|
||||||
|
end;
|
||||||
|
until Eof(InFile);
|
||||||
|
Form1.DBG_Count.Text := IntToStr(i);
|
||||||
|
Form1.DBG_SelEntry.MaxValue := i-1;
|
||||||
|
Form1.StatusBar.SimpleText := 'File openened. Now parsing for Contacts ...';
|
||||||
|
|
||||||
|
j := 1;
|
||||||
|
i := 0;
|
||||||
|
while (i<Length(PB)-1) do begin
|
||||||
|
if (Pos('Contacts', PB[i].Group)>0) then begin
|
||||||
|
SetLength(PhoneBook, j);
|
||||||
|
PhoneBook[j-1] := ParsePBStream(PB[i].Value);
|
||||||
|
Inc(j);
|
||||||
|
end;
|
||||||
Inc(i);
|
Inc(i);
|
||||||
ReadLn(InFile, cl);
|
if (Pos('Calendar', PB[i].Group)>0) then break;
|
||||||
until Eof(InFile) OR (cl='<Contacts/>');
|
end;
|
||||||
PhoneBookMax := i-1;
|
Form1.StatusBar.SimpleText := 'Loaded '+IntToStr(Length(PhoneBook))+' contacts into memory.';
|
||||||
Form1.StatusBar.SimpleText := 'Loaded '+IntToStr(PhoneBookMax)+' contacts into memory.';
|
|
||||||
BuildPBList;
|
BuildPBList;
|
||||||
|
|
||||||
Form1.ProgressBar.Visible := false;
|
Form1.ProgressBar.Visible := false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -405,7 +460,7 @@ var i: integer;
|
|||||||
x: TJPEGImage;
|
x: TJPEGImage;
|
||||||
y: TGIFImage;
|
y: TGIFImage;
|
||||||
begin
|
begin
|
||||||
i := Form1.PB_List.ItemIndex+1;
|
i := Form1.PB_List.ItemIndex;
|
||||||
x := TJpegImage.Create;
|
x := TJpegImage.Create;
|
||||||
y := TGIFImage.Create;
|
y := TGIFImage.Create;
|
||||||
Form1.PB_Name.Text := FormatName(PhoneBook[i].Name);
|
Form1.PB_Name.Text := FormatName(PhoneBook[i].Name);
|
||||||
@ -447,7 +502,8 @@ end;
|
|||||||
procedure TForm1.PB_PhotoDelButtonClick(Sender: TObject);
|
procedure TForm1.PB_PhotoDelButtonClick(Sender: TObject);
|
||||||
var i: integer;
|
var i: integer;
|
||||||
begin
|
begin
|
||||||
i := Form1.PB_List.ItemIndex+1;
|
i := Form1.PB_List.ItemIndex;
|
||||||
|
DeleteFile(PhoneBook[i].PhotoFile);
|
||||||
PhoneBook[i].PhotoFile := '';
|
PhoneBook[i].PhotoFile := '';
|
||||||
Form1.PB_ListClick(Sender);
|
Form1.PB_ListClick(Sender);
|
||||||
end;
|
end;
|
||||||
@ -488,7 +544,7 @@ begin
|
|||||||
PB_PhotoAtt.Checked := false;
|
PB_PhotoAtt.Checked := false;
|
||||||
PB_Photo.Visible := false;
|
PB_Photo.Visible := false;
|
||||||
DeleteTemp;
|
DeleteTemp;
|
||||||
PhoneBookMax := 0;
|
SetLength(PhoneBook, 0);
|
||||||
StatusBar.SimpleText := StatusBar.SimpleText + ' done.';
|
StatusBar.SimpleText := StatusBar.SimpleText + ' done.';
|
||||||
Button_Close.Enabled := false;
|
Button_Close.Enabled := false;
|
||||||
Button_SaveAs.Enabled := false;
|
Button_SaveAs.Enabled := false;
|
||||||
@ -500,4 +556,14 @@ begin
|
|||||||
Form1.FileListBox1.Enabled := true;
|
Form1.FileListBox1.Enabled := true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.DBG_ShowEntryClick(Sender: TObject);
|
||||||
|
var i: integer;
|
||||||
|
begin
|
||||||
|
i := Form1.DBG_SelEntry.Value;
|
||||||
|
Form1.DBG_EntryGroup.Text := PB[i].Group;
|
||||||
|
Form1.DBG_EntryName.Text := PB[i].Name;
|
||||||
|
Form1.DBG_Entry.Text := PB[i].Value;
|
||||||
|
Form1.DBG_LastEntry.Checked := PB[i].LastOfGroup;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Reference in New Issue
Block a user