Recent

Author Topic: Indy 10.6.1.5238 for Lazarus 1.2.6 with Debian 7.5  (Read 18168 times)

balazsszekely

  • Guest
Re: Indy 10.6.1.5238 for Lazarus 1.2.6 with Debian 7.5
« Reply #15 on: January 27, 2015, 08:28:01 pm »
Quote
My other problem is that when I want to use any Indy object, even IdHTTP... and while writing my program, when putting a
'.' after and object, Lazarus used to display to properties, events, methods of that object... So if I am starting to use an object
that I havent used it before, that way I can find out the capabilities of that object. But since for Indy objects Lazarus does not display its own little capability window... I have no idea what and how can I use :( But I am afraid that is some kind incompatibility between FPC / Lazarus and Indy... And mostly FPC / Lazarus, because Indy 10.2.0.3 was working for me previously...

I recently installed Indy 10.6.1.0 to Lazarus 1.2.6(Windows 7(32/64), Linux Ubuntu 14.0 LTS, OSX Mavericks). I have absolutely no problem with the code inside. Indy is working just fine, except TIdIPWatch.LocalIP which it fails on linux(when I will have more free time, I will try to figure it out why it fails)

Quote
Ur test program works!! That means that Indy is somehow working... BUT... Ur program displays my IP WAN address and
not LAN IP address... That I got calling IdIPWatch.LocalIP

As a quick workaround use this function:
Code: [Select]
program Project1;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes,
  Process,
  SysUtils
  { you can add units after this };


function GetLocalIP: String;
var
  Buffer: array[0..32000] of char;
  ReadCount: Integer;
  ReadSize: Integer;
  Process: TProcess;
begin
  Result := '';
  Process := TProcess.Create(nil);
  try
    Process.Executable := 'hostname';
    Process.Parameters.Add('--ip-address');
    Process.Options := [poUsePipes, poStderrToOutPut];
    Process.Execute;
    while Process.Running do
      Sleep(1);
    ReadSize := Process.Output.NumBytesAvailable;
    ReadSize := SizeOf(Buffer);
    if ReadSize > 0 then
    begin
      ReadCount := Process.Output.Read(Buffer, ReadSize);
      if ReadCount > 0 then
        Result := Copy(Buffer,0, ReadCount);
    end
  finally
    Process.Free;
  end;
end;

begin
  writeln(GetLocalIP);
  readln();
end.

If you need more info:
Code: [Select]
    Process.Executable := 'ifconfig';
    Process.Parameters.Add('-a');
Then scoop the data you need.



ozoltan

  • New Member
  • *
  • Posts: 37
Re: Indy 10.6.1.5238 for Lazarus 1.2.6 with Debian 7.5
« Reply #16 on: January 27, 2015, 09:32:43 pm »
On Windows 7 / 32 it works fine for me Indy 10.6.1.0.5203. I have tried installing version 5238, but I started the problems that I have mentioned above.

As I get back to my workplace I will test it with my email program...

But Ur program shows me a lot of things :) Thx for that :)

And of course THANK YOU for everyone who tried to help me on this forum :)

Anyone who has some idea that h can this Indy put to work normally - as on Windows and as it worked before - I will be
very grateful and happy if shared with me and the forum :)

Sincerelly
Zoltán

ozoltan

  • New Member
  • *
  • Posts: 37
Re: Indy 10.6.1.5238 for Lazarus 1.2.6 with Debian 7.5
« Reply #17 on: January 29, 2015, 10:49:11 am »
Back to workplace and I could try my email send test program. It works :) That means that Indy works under Lazarus / Debian... Except of minor problems... Eg. my initial problem.

That problem still exists that Lazarus does not display the properties, events, methods little window when writing program. So first I have to write the program under windows,
then I can port it to Linux... Hoping that it work well under Linux too... Lets hope this will change in the future :)

Here is my test program :

---------------------------------------------------------------------------------------------------------------------------------------

unit emtest2;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
  StdCtrls, IdSMTP, IdMessage,IdAttachmentFile, IdMessageCoderMIME;

type

  { TEmTestF }

  TEmTestF = class(TForm)
    BAddAttach: TButton;
    Bevel1: TBevel;
    BSend: TButton;
    IdMsg: TIdMessage;
    IdSMTP: TIdSMTP;
    Label1: TLabel;
    Label2: TLabel;
    LBAttach: TListBox;
    LEAddresses: TLabeledEdit;
    LEBCopies: TLabeledEdit;
    LECopies: TLabeledEdit;
    LEFrom: TLabeledEdit;
    LESMTP: TLabeledEdit;
    LESubject: TLabeledEdit;
    LEUsername: TLabeledEdit;
    Memo1: TMemo;
    OpenDlg: TOpenDialog;
    procedure FormOnClose(Sender: TObject; var CloseAction: TCloseAction);
    procedure FormOnActivate(Sender: TObject);

    procedure BAddAttachClick(Sender: TObject);
    procedure BSendClick(Sender: TObject);

    procedure FormOnCreate(Sender: TObject);
  private
    { private declarations }
    function UTF8ToDos(StrIn:shortstring):shortstring;
  public
    { public declarations }
  end;

var
  EmTestF: TEmTestF;

implementation

{$R *.lfm}

  var Activated:boolean;

{********************************************************************}

procedure TEmTestF.FormOnCreate(Sender: TObject);

begin
 Activated:=False;
end; { procedure TEmTestF.FormOnCreate }

{********************************************************************}

procedure TEmTestF.FormOnActivate(Sender: TObject);

begin
 if Not Activated then
   begin
    Activated:=True;

    EmTestF.LBAttach.Items.Clear;

//      árvíztűrő tükörfúrógép - test string with hungarian chars

//      ÁRVÍZTŰRŐ TÜKÖRFÚRÓGÉP


   end; { if Not Activated then }
end; { procedure TEmTestF.FormOnActivate }

{********************************************************************}

procedure TEmTestF.BAddAttachClick(Sender: TObject);

begin
 if EmTestF.OpenDlg.Execute then
   begin
    TIdAttachmentFile.Create(EmTestF.IdMsg.MessageParts,EmTestF.OpenDlg.FileName);
    EmTestF.LBAttach.Items.Add(EmTestF.OpenDlg.FileName);
   end; { if EmTestF.OpenDlg.Execute then }
end; { procedure TEmTestF.BAddAttachClick }

{********************************************************************}

function TEmTestF.UTF8ToDos(StrIn:shortstring):shortstring;
 { Needs this conversion subroutine that the hungarian characters }
 { should be displayed correctly by the receiver }

  var s0,s1:shortstring;
      i:word;

begin
 s0:=StrIn;
 s1:='';

 if Length(s0)>0 then
   for i:=1 to Length(s0) do
    if Not(s0 in [#$C3,#$C5]) then
      case s0 of
       #$AD:s1:=s1+#$ED; { í }
       #$A9:s1:=s1+#$E9; { é }
       #$A1:s1:=s1+#$E1; { á }
       #$B1:s1:=s1+#$FB; { ű }
       #$91:s1:=s1+#$F5; { ő }
       #$BA:s1:=s1+#$FA; { ú }
       #$B6:s1:=s1+#$F6; { ö }
       #$BC:s1:=s1+#$FC; { ü }
       #$B3:s1:=s1+#$F3; { ó }

       #$8D:s1:=s1+#$CD; { Í }
       #$89:s1:=s1+#$C9; { É }
       #$81:s1:=s1+#$C1; { Á }
       #$B0:s1:=s1+#$DB; { Ű }
       #$90:s1:=s1+#$D5; { Ő }
       #$9A:s1:=s1+#$DA; { Ú }
       #$96:s1:=s1+#$D6; { Ö }
       #$9C:s1:=s1+#$DC; { Ü }
       #$93:s1:=s1+#$D3; { Ó }
       else
        if Byte(s0)<=128 then
          s1:=s1+s0
                            else
          s1:=s1+'_';
      end; { case }

 UTF8ToDos:=s1;
end; { function TEmTestF.ConvertUTF8ToDos }

{*******************************************************************}

procedure TEmTestF.BSendClick(Sender: TObject);
  var i:word;
      s0:shortstring;

begin
 EmTestF.IdSMTP.Host:=EmTestF.LESMTP.Text;
 EmTestF.IdSMTP.Port:=25;

 EmTestF.IdSMTP.AuthType:=satNone;

 EmTestF.IdSMTP.Username:=EmTestF.LEUsername.Text;

// EmTestF.IdMsg.AttachmentEncoding:='MIME';
// EmTestF.IdMsg.Encoding:=meMIME;
 EmTestF.IdMsg.NoDecode:=False;
 EmtestF.IdMsg.NoEncode:=False;

 EmTestF.IdMsg.Recipients.EMailAddresses:=EmTestF.LEAddresses.Text;
 EmTestF.IdMsg.From.Text:=EmTestF.LEFrom.Text;
 EmTestF.IdMsg.Subject:=EmTestF.UTF8ToDos(EmTestF.LESubject.Text);

 EmTestF.IdMsg.CCList.EMailAddresses:=EmTestF.LECopies.Text;
 EmTestF.IdMsg.BccList.EMailAddresses:=EmTestF.LEBCopies.Text;

 EmTestF.IdMsg.Body.Clear;
 for i:=0 to EmTestF.Memo1.Lines.Count-1 do
  begin
   s0:=EmTestF.Memo1.Lines;
   s0:=EmTestF.UTF8ToDos(s0);
   EmTestF.IdMsg.Body.Add(s0); { use this because TMemo has a bug with UTF8 }
  end; { for }
 EmTestF.Memo1.Lines.SaveToFile('memo1.txt');

 try
  EmTestF.IdSMTP.Connect;

  try
   EmTestF.IdSMTP.Send(EmTestF.IdMsg);
  except
   ShowMessage('Cannot send the email !');
  end; { try }

  EmTestF.IdSMTP.Disconnect;
 except
  ShowMessage('Cannot connect to SMTP server !');
 end; { try }

 if EmTestF.IdMsg.MessageParts.Count>0 then
   EmTestF.IdMsg.MessageParts.Clear;
end; { procedure TEmTestF.BSendClick }

{********************************************************************}

procedure TEmTestF.FormOnClose(Sender: TObject; var CloseAction: TCloseAction);

begin
 Activated:=False;

 CloseAction:=caFree;
end; { procedure TEmTestF.FormOnClose }

{********************************************************************}

end.

---------------------------------------------------------------------------------------------------------------------------------------

Thank You very much for everybody who tried to help me and helped a lot :)

Sincerelly
Zoltán

balazsszekely

  • Guest
Re: Indy 10.6.1.5238 for Lazarus 1.2.6 with Debian 7.5
« Reply #18 on: January 29, 2015, 01:55:57 pm »
Hi Zoltán,

Quote
That problem still exists that Lazarus does not display the properties, events, methods little window when writing program.

Try this:
1. Lazarus Menu-->Project-->Project Options-->Complier Options-->Other unit files-->Locate the indy directory(see attachment, just change Indy 10.5.8.0 to whatever your current version is). Rebuild your application...now test if the properties, events are displayed(source code autocompletion is working properly)

2. If you still have problems with code insight:
After typing "IdSMTP." press [CTRL] + [SPACE]

regards,
GetMem
« Last Edit: January 29, 2015, 02:09:07 pm by GetMem »

ozoltan

  • New Member
  • *
  • Posts: 37
Re: Indy 10.6.1.5238 for Lazarus 1.2.6 with Debian 7.5
« Reply #19 on: January 30, 2015, 09:02:06 am »
Hi GetMem...

I have tried these 2 solution that U have suggested me and here are the results:

- for adding the Indy directory, nothing changes...

- the [CTRL+SPACE] throwed me into unti IdGlobal.pas, line 1681:

-------------------------------------------------------------------------------------------------------------------------------------------------

procedure IdDisposeAndNil(var Obj); {$IFDEF USE_INLINE}inline;{$ENDIF}

var
  {$IFDEF UNIX}

  // For linux the user needs to set this variable to be accurate where used (mail, etc)
  GOffsetFromUTC: TDateTime = 0 {$IFDEF HAS_DEPRECATED}deprecated{$ENDIF};         // <<-- line 1681

    {$IFDEF DARWIN}
  GMachTimeBaseInfo: TTimebaseInfoData;
    {$ENDIF}
  {$ENDIF}

  IndyPos: TPosProc = nil;

{$IFDEF UNIX}
const
  {$IFDEF HAS_SharedPrefix}
  LIBEXT = '.' + SharedSuffix; {do not localize}
  {$ELSE}
    {$UNDEF LIBEXT_IS_DYLIB}
    {$IFDEF DARWIN}
      {$DEFINE LIBEXT_IS_DYLIB}
    {$ELSE}
      {$IFDEF IOS}
        {$IFNDEF CPUARM}
          // iOS Simulator
          {$DEFINE LIBEXT_IS_DYLIB}
        {$ENDIF}
      {$ENDIF}
    {$ENDIF}
    {$IFDEF LIBEXT_IS_DYLIB}
  LIBEXT = '.dylib'; {do not localize}
    {$ELSE}
  LIBEXT = '.so'; {do not localize}
    {$ENDIF}
  {$ENDIF}
{$ENDIF}

-------------------------------------------------------------------------------------------------------------------------------------------------

While Lazarus gave the following error message:

"/usr/share/lazarus/1.2.6/components/indylaz_v105203/IdGlobal.pas(1681,56) Error: expected ;, but deprecated found"

If I am not mistaken then this seems to me that Lazarus does not understands the "deprecated" directive...

Regards
Zoltán

balazsszekely

  • Guest
Re: Indy 10.6.1.5238 for Lazarus 1.2.6 with Debian 7.5
« Reply #20 on: January 30, 2015, 09:36:35 pm »
Quote
I have tried these 2 solution that U have suggested me and here are the results:
- for adding the Indy directory, nothing changes...
- the [CTRL+SPACE] throwed me into unti IdGlobal.pas, line 1681:

I did not believed you :D, so I decided to install Debian 7.8 to a virtual machine. It turns out you were right, code completion it's not working properly.
The good news is that I found the solution and it's quite trivial:
1. First I had to set permission for the IdGLobal.pas(it was read only)
2. Secondly I removed the following code
Code: [Select]
{$IFDEF HAS_DEPRECATED}deprecated{$ENDIF}; So line 1681 should look like this:
Code: [Select]
GOffsetFromUTC: TDateTime = 0;I double checked on other Linux distros...

https://www.youtube.com/watch?v=_ZmbbGu_GM0&feature=youtu.be (watch in full screen, 720p)
 

ozoltan

  • New Member
  • *
  • Posts: 37
Re: Indy 10.6.1.5238 for Lazarus 1.2.6 with Debian 7.5
« Reply #21 on: January 31, 2015, 09:59:47 am »
Hi GetMem!

THANK YOU very much that U did not believed me and U have tried :) So now I have proof that I am not talking nonsense
things :)

Unfortunately Lazarus installs itself into /usr/share directory, which is read-only by default, so it is very adviceable that U should set to read-write the whole Lazarus directory, especially if U want to install other components like Zeos database modul, PowerPdf, fpsreadsheet, etc... -->> "chmod -R a+w lazarus"  Maybe its not a too good idea because of security reasons, then it should be installed somewhere else... Anyway, Lazarus needs read-write rights to its own directory... If I am not mistaken...

The deprecated clause... It seems that it is a Delphi directive that Lazarus does not understand. I was afraid to remove, because I had no idea what may cause...

So thank You again GetMem! U helped me a lot :)

Have a nice day! Now I will have :):):)

Sincerely
Zoltán

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Indy 10.6.1.5238 for Lazarus 1.2.6 with Debian 7.5
« Reply #22 on: January 31, 2015, 02:29:03 pm »
Unfortunately Lazarus installs itself into /usr/share directory, which is read-only by default, so it is very adviceable that U should set to read-write the whole Lazarus directory, especially if U want to install other components like Zeos database modul, PowerPdf, fpsreadsheet, etc... -->> "chmod -R a+w lazarus"  Maybe its not a too good idea because of security reasons, then it should be installed somewhere else... Anyway, Lazarus needs read-write rights to its own directory... If I am not mistaken...
No need, if Lazarus finds out that its directory is read-only, it will output compiled units and packages to $HOME/.lazarus. There's no obligation for packages to live under components folder, they can be anywhere accessible, Lazarus will remember their location.
UThe deprecated clause... It seems that it is a Delphi directive that Lazarus does not understand. I was afraid to remove, because I had no idea what may cause...
Lazarus should understand, since FPC does: http://wiki.freepascal.org/Hint_Directives

ozoltan

  • New Member
  • *
  • Posts: 37
Re: Indy 10.6.1.5238 for Lazarus 1.2.6 with Debian 7.5
« Reply #23 on: January 31, 2015, 04:09:09 pm »
Ok Leledumbo...

I will try to put the additional packages somewhere else, to see that really Lazarus observes that its home directory its read-only or not. My experience it that some of the packages it compiles under its home directory, and some of them under the $HOME/.lazarus directory. It depends on the package. But I have put the components under Lazarus home directory...

If Lazarus understands the "deprecated" clause, then why it fails using it under Indy ? Because I have tried what GetMem told, me and commenting out that directive in IdGlobal.pas, line 1681, Indy components immediately start to be shown correctly in the code completition... Try pls out the same what GetMem did... U will see :)

balazsszekely

  • Guest
Re: Indy 10.6.1.5238 for Lazarus 1.2.6 with Debian 7.5
« Reply #24 on: January 31, 2015, 04:53:11 pm »
Lazarus does understand deprecated keyword, that line fails because the syntax is incorrect. On other Linux distros it's not even there(so you can safely remove it).

Deprecated example:
Code: [Select]
  TTest = class
  private
    function TestTest: string; deprecated 'do not use this function'; //<-- custom message for the user
  public
    constructor create;
    destructor destroy; override;
  end;     

function TTest.TestTest: string;
begin
  //...
  Result := 'fadfas';
end;

constructor TTest.create;
begin
  //...
end;

destructor TTest.destroy;
begin
  //...
  inherited destroy;
end;         
//....

We create an instance of the TTest class:
Code: [Select]
var
  Test: TTest;
begin
   Test := TTest.create;
   try
     Test.TestTest; //<--compiler warning here
   finally
     Test.Free;
   end;
end;     

When you compile this code, you will get a warning:
Quote
unit1.pas(49,17) Warning: Symbol "TestTest" is deprecated: "do not use this function"
So basically the deprecated keyword is just a way to warn the user about the status of a function, method, etc...

« Last Edit: January 31, 2015, 04:56:52 pm by GetMem »

ozoltan

  • New Member
  • *
  • Posts: 37
Re: Indy 10.6.1.5238 for Lazarus 1.2.6 with Debian 7.5
« Reply #25 on: February 05, 2015, 03:06:18 pm »
So it seems that my problem is mainly solved... Ok, still cannot get simply the localip of the client computer, but I will overcome of that problem somehow :)
I found a way how to install indy 10.6.1.5238, it works and I can get the code completition little window while writing program :)

Thank You for everyone who tried and could help me :) I appreciate very much :)

For me this topic can be closed...

Thx for everyone :)
Zoltán

 

TinyPortal © 2005-2018