mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-05 13:36:17 +02:00
* Fixes so the examples can be compiled with FPC 2.6.4, and one fix for new anonymous type naming change in google code generator
git-svn-id: trunk@48978 -
This commit is contained in:
parent
732196cb07
commit
347c5403b9
@ -60,7 +60,7 @@
|
|||||||
</RunParams>
|
</RunParams>
|
||||||
<RequiredPackages Count="3">
|
<RequiredPackages Count="3">
|
||||||
<Item1>
|
<Item1>
|
||||||
<PackageName Value="googleapiclient"/>
|
<PackageName Value="lazgoogleapis"/>
|
||||||
</Item1>
|
</Item1>
|
||||||
<Item2>
|
<Item2>
|
||||||
<PackageName Value="laz_synapse"/>
|
<PackageName Value="laz_synapse"/>
|
||||||
@ -69,7 +69,7 @@
|
|||||||
<PackageName Value="LCL"/>
|
<PackageName Value="LCL"/>
|
||||||
</Item3>
|
</Item3>
|
||||||
</RequiredPackages>
|
</RequiredPackages>
|
||||||
<Units Count="2">
|
<Units Count="3">
|
||||||
<Unit0>
|
<Unit0>
|
||||||
<Filename Value="calendardemo.lpr"/>
|
<Filename Value="calendardemo.lpr"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
@ -80,8 +80,11 @@
|
|||||||
<ComponentName Value="MainForm"/>
|
<ComponentName Value="MainForm"/>
|
||||||
<HasResources Value="True"/>
|
<HasResources Value="True"/>
|
||||||
<ResourceBaseClass Value="Form"/>
|
<ResourceBaseClass Value="Form"/>
|
||||||
<UnitName Value="frmmain"/>
|
|
||||||
</Unit1>
|
</Unit1>
|
||||||
|
<Unit2>
|
||||||
|
<Filename Value="fphttpclient.pp"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
</Unit2>
|
||||||
</Units>
|
</Units>
|
||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
<CompilerOptions>
|
<CompilerOptions>
|
||||||
|
@ -2,6 +2,14 @@ unit frmmain;
|
|||||||
|
|
||||||
{$mode objfpc}{$H+}
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
|
// Define USESYNAPSE if you want to force use of synapse
|
||||||
|
{ $DEFINE USESYNAPSE}
|
||||||
|
|
||||||
|
// For version 2.6.4, synapse is the only option.
|
||||||
|
{$IFDEF VER2_6}
|
||||||
|
{$DEFINE USESYNAPSE}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
@ -58,11 +66,11 @@ uses
|
|||||||
jsonparser, // needed
|
jsonparser, // needed
|
||||||
fpoauth2,
|
fpoauth2,
|
||||||
lclintf,
|
lclintf,
|
||||||
{$IFDEF NATIVEWEBCLIENT}
|
{$IFDEF USESYNAPSE}
|
||||||
fphttpwebclient
|
|
||||||
{$ELSE}
|
|
||||||
ssl_openssl,
|
ssl_openssl,
|
||||||
synapsewebclient
|
synapsewebclient
|
||||||
|
{$ELSE}
|
||||||
|
fphttpwebclient
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -76,7 +84,12 @@ begin
|
|||||||
TCalendarAPI.RegisterAPIResources;
|
TCalendarAPI.RegisterAPIResources;
|
||||||
// Set up google client.
|
// Set up google client.
|
||||||
FClient:=TGoogleClient.Create(Self);
|
FClient:=TGoogleClient.Create(Self);
|
||||||
|
{$IFDEF USESYNAPSE}
|
||||||
FClient.WebClient:=TSynapseWebClient.Create(Self);
|
FClient.WebClient:=TSynapseWebClient.Create(Self);
|
||||||
|
{$ELSE}
|
||||||
|
FClient.WebClient:=TFPHTTPWebClient.Create(Self);
|
||||||
|
{$ENDIF}
|
||||||
|
FClient.WebClient.LogFile:='requests.log';
|
||||||
FClient.WebClient.RequestSigner:=FClient.AuthHandler;
|
FClient.WebClient.RequestSigner:=FClient.AuthHandler;
|
||||||
FClient.AuthHandler.WebClient:=FClient.WebClient;
|
FClient.AuthHandler.WebClient:=FClient.WebClient;
|
||||||
FClient.AuthHandler.Config.AccessType:=atOffLine;
|
FClient.AuthHandler.Config.AccessType:=atOffLine;
|
||||||
|
@ -52,21 +52,18 @@
|
|||||||
<ComponentName Value="MainForm"/>
|
<ComponentName Value="MainForm"/>
|
||||||
<HasResources Value="True"/>
|
<HasResources Value="True"/>
|
||||||
<ResourceBaseClass Value="Form"/>
|
<ResourceBaseClass Value="Form"/>
|
||||||
<UnitName Value="frmmain"/>
|
|
||||||
</Unit1>
|
</Unit1>
|
||||||
<Unit2>
|
<Unit2>
|
||||||
<Filename Value="frmgenoptions.pp"/>
|
<Filename Value="frmgenoptions.pp"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<ComponentName Value="GenCodeFormOptions"/>
|
<ComponentName Value="GenCodeFormOptions"/>
|
||||||
<ResourceBaseClass Value="Form"/>
|
<ResourceBaseClass Value="Form"/>
|
||||||
<UnitName Value="frmgenoptions"/>
|
|
||||||
</Unit2>
|
</Unit2>
|
||||||
<Unit3>
|
<Unit3>
|
||||||
<Filename Value="frmview.pp"/>
|
<Filename Value="frmview.pp"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<ComponentName Value="ViewForm"/>
|
<ComponentName Value="ViewForm"/>
|
||||||
<ResourceBaseClass Value="Form"/>
|
<ResourceBaseClass Value="Form"/>
|
||||||
<UnitName Value="frmview"/>
|
|
||||||
</Unit3>
|
</Unit3>
|
||||||
</Units>
|
</Units>
|
||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
|
@ -2,6 +2,15 @@ unit frmmain;
|
|||||||
|
|
||||||
{$mode objfpc}{$H+}
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
|
// Define this if you want to use synapse.
|
||||||
|
{ $DEFINE USESYNAPSE}
|
||||||
|
|
||||||
|
// For 2.6.4, synapse is currently the only option.
|
||||||
|
// You will need to add lazsynapsewebclient to the requires list.
|
||||||
|
{$IFDEF VER2_6}
|
||||||
|
{$DEFINE USESYNAPSE}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
@ -64,10 +73,11 @@ type
|
|||||||
FClient : TGoogleClient;
|
FClient : TGoogleClient;
|
||||||
FDiscoveryAPI : TDiscoveryAPI;
|
FDiscoveryAPI : TDiscoveryAPI;
|
||||||
FDirectory : TDirectoryList;
|
FDirectory : TDirectoryList;
|
||||||
Function CurrentAPI : TDirectoryListitems;
|
Function CurrentAPI : TDirectoryListTypeitemsItem;
|
||||||
procedure DoFetch;
|
procedure DoFetch;
|
||||||
procedure DownLoadRestAPI(Const AName,AURL: String);
|
procedure DownLoadRestAPI(Const AName,AURL: String);
|
||||||
procedure GenerateCode(const AName, AURL: String);
|
procedure GenerateCode(const AName, AURL: String);
|
||||||
|
function HttpGetBinary(AURL: String; S: TStream): Boolean;
|
||||||
procedure ShowDiscovery(PreferredOnly: Boolean; FilterOn: String);
|
procedure ShowDiscovery(PreferredOnly: Boolean; FilterOn: String);
|
||||||
procedure UpdateCaption;
|
procedure UpdateCaption;
|
||||||
procedure ViewFile(AFileName: String);
|
procedure ViewFile(AFileName: String);
|
||||||
@ -87,9 +97,14 @@ uses
|
|||||||
ssl_openssl,
|
ssl_openssl,
|
||||||
jsonparser, // needed
|
jsonparser, // needed
|
||||||
fpoauth2, lclintf,
|
fpoauth2, lclintf,
|
||||||
|
{$IFDEF USESYNAPSE}
|
||||||
synapsewebclient,
|
synapsewebclient,
|
||||||
googlediscoverytopas,
|
httpsend,
|
||||||
httpsend;
|
{$ELSE}
|
||||||
|
fphttpclient,
|
||||||
|
fphttpwebclient,
|
||||||
|
{$ENDIF}
|
||||||
|
googlediscoverytopas;
|
||||||
|
|
||||||
{ TMainForm }
|
{ TMainForm }
|
||||||
|
|
||||||
@ -97,7 +112,11 @@ procedure TMainForm.FormCreate(Sender: TObject);
|
|||||||
begin
|
begin
|
||||||
// set up communication.
|
// set up communication.
|
||||||
FClient:=TGoogleClient.Create(Self);
|
FClient:=TGoogleClient.Create(Self);
|
||||||
|
{$IFDEF USESYNAPSE}
|
||||||
FClient.WebClient:=TSynapseWebClient.Create(Self);
|
FClient.WebClient:=TSynapseWebClient.Create(Self);
|
||||||
|
{$ELSE}
|
||||||
|
FClient.WebClient:=TFPHTTPWebClient.Create(Self);
|
||||||
|
{$ENDIF}
|
||||||
// Register all classes so they can be streamed.
|
// Register all classes so they can be streamed.
|
||||||
TDiscoveryAPI.RegisterAPIResources;
|
TDiscoveryAPI.RegisterAPIResources;
|
||||||
// create the API and hook it up to the google client.
|
// create the API and hook it up to the google client.
|
||||||
@ -137,7 +156,7 @@ end;
|
|||||||
procedure TMainForm.AGenCodeExecute(Sender: TObject);
|
procedure TMainForm.AGenCodeExecute(Sender: TObject);
|
||||||
|
|
||||||
Var
|
Var
|
||||||
DLI : TDirectoryListitems;
|
DLI : TDirectoryListTypeitemsItem;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
DLI:=CurrentAPI;
|
DLI:=CurrentAPI;
|
||||||
@ -174,6 +193,22 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Function TMainForm.HttpGetBinary(AURL : String; S : TStream) : Boolean;
|
||||||
|
|
||||||
|
begin
|
||||||
|
{$IFDEF USESYNAPSE}
|
||||||
|
Result:=httpsend.HttpGetBinary(AURL,S);
|
||||||
|
{$ELSE}
|
||||||
|
try
|
||||||
|
TFPHTTPClient.SimpleGet(AURL,S);
|
||||||
|
S.Position:=0;
|
||||||
|
Result:=True;
|
||||||
|
except
|
||||||
|
Result:=False;
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TMainForm.GenerateCode(const AName, AURL: String);
|
procedure TMainForm.GenerateCode(const AName, AURL: String);
|
||||||
|
|
||||||
Var
|
Var
|
||||||
@ -255,7 +290,7 @@ end;
|
|||||||
procedure TMainForm.ASaveRESTExecute(Sender: TObject);
|
procedure TMainForm.ASaveRESTExecute(Sender: TObject);
|
||||||
|
|
||||||
Var
|
Var
|
||||||
DLI : TDirectoryListitems;
|
DLI : TDirectoryListTypeitemsItem;
|
||||||
begin
|
begin
|
||||||
DLI:=CurrentAPI;
|
DLI:=CurrentAPI;
|
||||||
DownLoadRestAPI(DLI.Name,DLI.DiscoveryRestUrl);
|
DownLoadRestAPI(DLI.Name,DLI.DiscoveryRestUrl);
|
||||||
@ -269,7 +304,7 @@ end;
|
|||||||
procedure TMainForm.APreViewRestExecute(Sender: TObject);
|
procedure TMainForm.APreViewRestExecute(Sender: TObject);
|
||||||
|
|
||||||
Var
|
Var
|
||||||
DLI : TDirectoryListitems;
|
DLI : TDirectoryListTypeitemsItem;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
DLI:=CurrentAPI;
|
DLI:=CurrentAPI;
|
||||||
@ -302,10 +337,10 @@ begin
|
|||||||
SBDiscovery.Panels[0].Text:=Format('%d items',[C]);
|
SBDiscovery.Panels[0].Text:=Format('%d items',[C]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TMainForm.CurrentAPI: TDirectoryListitems;
|
function TMainForm.CurrentAPI: TDirectoryListTypeitemsItem;
|
||||||
begin
|
begin
|
||||||
If Assigned(LVServices.Selected) and Assigned(LVServices.Selected.Data) then
|
If Assigned(LVServices.Selected) and Assigned(LVServices.Selected.Data) then
|
||||||
Result:=TDirectoryListitems(LVServices.Selected.Data)
|
Result:=TDirectoryListTypeitemsItem(LVServices.Selected.Data)
|
||||||
else
|
else
|
||||||
Result:=Nil;
|
Result:=Nil;
|
||||||
end;
|
end;
|
||||||
@ -330,7 +365,7 @@ procedure TMainForm.ShowDiscovery(PreferredOnly : Boolean; FilterOn : String);
|
|||||||
Result:=Pos(FilterOn,LowerCase(S))<>0;
|
Result:=Pos(FilterOn,LowerCase(S))<>0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function ShowItem (DLI : TDirectoryListitems) : Boolean;
|
Function ShowItem (DLI : TDirectoryListTypeitemsItem) : Boolean;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=DLI.Preferred or (Not PreferredOnly);
|
Result:=DLI.Preferred or (Not PreferredOnly);
|
||||||
@ -344,7 +379,7 @@ procedure TMainForm.ShowDiscovery(PreferredOnly : Boolean; FilterOn : String);
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
Var
|
Var
|
||||||
DLI : TDirectoryListitems;
|
DLI : TDirectoryListTypeitemsItem;
|
||||||
LI : TListItem;
|
LI : TListItem;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
@ -46,14 +46,12 @@
|
|||||||
<ComponentName Value="MainForm"/>
|
<ComponentName Value="MainForm"/>
|
||||||
<HasResources Value="True"/>
|
<HasResources Value="True"/>
|
||||||
<ResourceBaseClass Value="Form"/>
|
<ResourceBaseClass Value="Form"/>
|
||||||
<UnitName Value="frmmain"/>
|
|
||||||
</Unit1>
|
</Unit1>
|
||||||
<Unit2>
|
<Unit2>
|
||||||
<Filename Value="frmselectdownload.pp"/>
|
<Filename Value="frmselectdownload.pp"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<ComponentName Value="SelectDownloadForm"/>
|
<ComponentName Value="SelectDownloadForm"/>
|
||||||
<ResourceBaseClass Value="Form"/>
|
<ResourceBaseClass Value="Form"/>
|
||||||
<UnitName Value="frmselectdownload"/>
|
|
||||||
</Unit2>
|
</Unit2>
|
||||||
</Units>
|
</Units>
|
||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
unit frmmain;
|
unit frmmain;
|
||||||
|
|
||||||
{$mode objfpc}{$H+}
|
{$mode objfpc}{$H+}
|
||||||
|
// Define USESYNAPSE if you want to force use of synapse
|
||||||
|
{ $DEFINE USESYNAPSE}
|
||||||
|
|
||||||
|
// For version 2.6.4, synapse is the only option.
|
||||||
|
{$IFDEF VER2_6}
|
||||||
|
{$DEFINE USESYNAPSE}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
@ -69,7 +76,13 @@ uses {$ifdef windows}windows,{$endif}
|
|||||||
lclintf,
|
lclintf,
|
||||||
fpwebclient,
|
fpwebclient,
|
||||||
frmselectdownload,
|
frmselectdownload,
|
||||||
synapsewebclient;
|
{$IFDEF USESYNAPSE}
|
||||||
|
ssl_openssl,
|
||||||
|
synapsewebclient
|
||||||
|
{$ELSE}
|
||||||
|
fphttpwebclient
|
||||||
|
{$ENDIF}
|
||||||
|
;
|
||||||
|
|
||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
|
|
||||||
@ -81,7 +94,11 @@ begin
|
|||||||
TDriveAPI.RegisterAPIResources;
|
TDriveAPI.RegisterAPIResources;
|
||||||
// Set up google client.
|
// Set up google client.
|
||||||
FClient:=TGoogleClient.Create(Self);
|
FClient:=TGoogleClient.Create(Self);
|
||||||
FClient.WebClient:=TSynapseWebClient.Create(Self);
|
{$IFDEF USESYNAPSE}
|
||||||
|
FClient.WebClient:=TSynapseWebClient.Create(Self);
|
||||||
|
{$ELSE}
|
||||||
|
FClient.WebClient:=TFPHTTPWebClient.Create(Self);
|
||||||
|
{$ENDIF}
|
||||||
FClient.WebClient.RequestSigner:=FClient.AuthHandler;
|
FClient.WebClient.RequestSigner:=FClient.AuthHandler;
|
||||||
FClient.WebClient.LogFile:='requests.log';
|
FClient.WebClient.LogFile:='requests.log';
|
||||||
FClient.AuthHandler.WebClient:=FClient.WebClient;
|
FClient.AuthHandler.WebClient:=FClient.WebClient;
|
||||||
|
@ -8,7 +8,7 @@ object MainForm: TMainForm
|
|||||||
ClientWidth = 702
|
ClientWidth = 702
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
OnDestroy = FormDestroy
|
OnDestroy = FormDestroy
|
||||||
LCLVersion = '1.3'
|
LCLVersion = '1.5'
|
||||||
object BFetchTaskLists: TButton
|
object BFetchTaskLists: TButton
|
||||||
Left = 8
|
Left = 8
|
||||||
Height = 25
|
Height = 25
|
||||||
@ -108,4 +108,4 @@ object MainForm: TMainForm
|
|||||||
Caption = 'Tasks for list : <select a tasklist>'
|
Caption = 'Tasks for list : <select a tasklist>'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
unit frmmain;
|
unit frmmain;
|
||||||
|
|
||||||
{$mode objfpc}{$H+}
|
{$mode objfpc}{$H+}
|
||||||
|
// Define USESYNAPSE if you want to force use of synapse
|
||||||
|
{ $DEFINE USESYNAPSE}
|
||||||
|
|
||||||
|
// For version 2.6.4, synapse is the only option.
|
||||||
|
{$IFDEF VER2_6}
|
||||||
|
{$DEFINE USESYNAPSE}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
@ -53,11 +60,15 @@ implementation
|
|||||||
|
|
||||||
|
|
||||||
uses {$ifdef windows}windows,{$endif}
|
uses {$ifdef windows}windows,{$endif}
|
||||||
ssl_openssl,
|
|
||||||
jsonparser, // needed
|
jsonparser, // needed
|
||||||
fpoauth2,
|
fpoauth2,
|
||||||
lclintf,
|
{$IFDEF USESYNAPSE}
|
||||||
synapsewebclient;
|
ssl_openssl,
|
||||||
|
synapse,webclient
|
||||||
|
{$ELSE}
|
||||||
|
fphttpwebclient,
|
||||||
|
{$ENDIF}
|
||||||
|
lclintf;
|
||||||
|
|
||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
|
|
||||||
@ -69,7 +80,11 @@ begin
|
|||||||
TTasksAPI.RegisterAPIResources;
|
TTasksAPI.RegisterAPIResources;
|
||||||
// Set up google client.
|
// Set up google client.
|
||||||
FClient:=TGoogleClient.Create(Self);
|
FClient:=TGoogleClient.Create(Self);
|
||||||
FClient.WebClient:=TSynapseWebClient.Create(Self);
|
{$IFDEF USESYNAPSE}
|
||||||
|
FClient.WebClient:=TSynapseWebClient.Create(Self);
|
||||||
|
{$ELSE}
|
||||||
|
FClient.WebClient:=TFPHTTPWebClient.Create(Self);
|
||||||
|
{$ENDIF}
|
||||||
FClient.WebClient.RequestSigner:=FClient.AuthHandler;
|
FClient.WebClient.RequestSigner:=FClient.AuthHandler;
|
||||||
FClient.WebClient.LogFile:='requests.log';
|
FClient.WebClient.LogFile:='requests.log';
|
||||||
FClient.AuthHandler.WebClient:=FClient.WebClient;
|
FClient.AuthHandler.WebClient:=FClient.WebClient;
|
||||||
|
@ -46,7 +46,6 @@
|
|||||||
<ComponentName Value="MainForm"/>
|
<ComponentName Value="MainForm"/>
|
||||||
<HasResources Value="True"/>
|
<HasResources Value="True"/>
|
||||||
<ResourceBaseClass Value="Form"/>
|
<ResourceBaseClass Value="Form"/>
|
||||||
<UnitName Value="frmmain"/>
|
|
||||||
</Unit1>
|
</Unit1>
|
||||||
</Units>
|
</Units>
|
||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
|
Loading…
Reference in New Issue
Block a user