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