Jump to content
NamoRamana

Delphi 10.3.2 - IdObjs not found

Recommended Posts

Trying to recompile old code in Delphi 10.3.2 and getting error: 'IdObjs not found'. Also code insight shows red line under TIdThreadList. Does Delphi Rio (10.3.2) missing any indy libraries? Any indy libraries merged/renamed in later delphi versions?

 

interface

uses IdContext, Classes, SysUtils, IdCustomTCPServer, StreamUtils,
  IdTCPConnection, IdYarn, IdObjs, IdComponent;

type
  TRequestType = (rtNone, rtGetFileList, rtGetFile, rtGetMasterHash, rtDisconnect);
  TResponseType = (rstNone, rstFile, rstString, rstStringList);

  TGetMasterHash = procedure (var AHash : string) of object;
  TGetFileList = procedure (var AFileList : TStrings) of object;
  TGetFile = procedure (const AFilename : string; var AStream : TStream) of object;
  TBytesSent = procedure (AByteCount : integer) of object;

  TSyncContext = class(TIdContext)
  private
    FOnGetMasterHash: TGetMasterHash;
    FOnGetFileList: TGetFileList;
    FOnGetFile: TGetFile;
    FOnBytesSent: TBytesSent;
    FBytesSentTotal : integer;
  protected
    procedure WriteResponseHeader(AResponseType : TResponseType; ASize : Int64);
    function ReadRequestHeader : TRequestType;

    procedure DoGetMasterHash; virtual;
    procedure DoGetFileList; virtual;
    procedure DoGetFile(const AFilename : string); virtual;
    procedure DoBytesSent(AByteCount : integer); virtual;

    procedure DoWork(ASender: TObject; AWorkMode: TWorkMode; AWorkCount: Integer);
    procedure DoWorkBegin(ASender: TObject; AWorkMode: TWorkMode; AWorkCountMax: Integer);
  public
    constructor Create(AConnection: TIdTCPConnection; AYarn: TIdYarn;
      AList: TIdThreadList = nil); override;

 

Share this post


Link to post

How old is this code? From browsing the history of the git repository I can see that references to IdObjs.pas have been removed (in the master branch) as early as July 2007, though I did not see a trace of the file itself.

I could not find IdObjs.pas in Delphi 2010 and 10.1 either, and a grep for TIdThreadList returned no matches.

Share this post


Link to post

Original code was written in Delphi 2006.. But I think, I found the solution (untested). Somewhere Remy B. wrote that IdObjs and IdSys(??!!) has been obsolete. So the changes I made to above code were like:

- Removed IdObjs from "interface uses"

- Derived TSyncContext from TIdSeverContext (instead of TIdContext)

- And changed the constructor signature to use TIdContextThreadList

 

interface

uses IdContext, Classes, SysUtils, IdCustomTCPServer, StreamUtils,
  IdTCPConnection, IdYarn, IdComponent; //IdObjs,

type
  TRequestType = (rtNone, rtGetFileList, rtGetFile, rtGetMasterHash, rtDisconnect);
  TResponseType = (rstNone, rstFile, rstString, rstStringList);

  TGetMasterHash = procedure (var AHash : string) of object;
  TGetFileList = procedure (var AFileList : TStrings) of object;
  TGetFile = procedure (const AFilename : string; var AStream : TStream) of object;
  TBytesSent = procedure (AByteCount : integer) of object;

  TSyncContext = class(TIdServerContext)
  private
    FOnGetMasterHash: TGetMasterHash;
    FOnGetFileList: TGetFileList;
    FOnGetFile: TGetFile;
    FOnBytesSent: TBytesSent;
    FBytesSentTotal : integer;
  protected
    procedure WriteResponseHeader(AResponseType : TResponseType; ASize : Int64);
    function ReadRequestHeader : TRequestType;

    procedure DoGetMasterHash; virtual;
    procedure DoGetFileList; virtual;
    procedure DoGetFile(const AFilename : string); virtual;
    procedure DoBytesSent(AByteCount : integer); virtual;

    procedure DoWork(ASender: TObject; AWorkMode: TWorkMode; AWorkCount: Int64);
    procedure DoWorkBegin(ASender: TObject; AWorkMode: TWorkMode; AWorkCountMax: Int64);
  public
    //constructor Create(AConnection: TIdTCPConnection; AYarn: TIdYarn;
      //AList: TIdThreadList = nil); override;
    constructor Create(AConnection: TIdTCPConnection; AYarn: TIdYarn;
      AList: TIdContextThreadList = nil); override;

 

Share this post


Link to post
10 hours ago, jottkaerr said:

How old is this code?

Ancient.

10 hours ago, jottkaerr said:

From browsing the history of the git repository I can see that references to IdObjs.pas have been removed (in the master branch) as early as July 2007, though I did not see a trace of the file itself.

Yes, the IdObjs and IdSys units were removed from Indy well over a decade ago.  Any code that references them is severely outdated and needs to be updated to a modern version.

 

The GitHub repository is just a mirror, the real repository is still on SVN instead.  So the Git history may not have everything.

10 hours ago, jottkaerr said:

I could not find IdObjs.pas in Delphi 2010 and 10.1 either, and a grep for TIdThreadList returned no matches.

When the IdObjs/IdSy units were removed, TIdThreadList was replaced with the RTL's standard TThreadList (and various other compatibility classes were likewise replaced with standard equivalents - TIdStrings -> TStrings, etc).

  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×