Jump to content

wright

Members
  • Content Count

    38
  • Joined

  • Last visited

Everything posted by wright

  1. wright

    ICS for Linux?

    Hi, i think you are referring to me, except if i'm wrong! i will try to send it to you as soon as possible.
  2. Why would embarcadero use their competitor's servers? AWS => AMAZON Azure => Microsoft (MS Visual Studio)
  3. HI there i just made a try, i started there! To work on the Android platform using compile directives, i needed to make some modifications to the code in several files. Lets focus on 'svn.overbyte.be/svn/icsv9/Source/OverbyteIcsUtils.pas'.The classTIcsIntegerList is essentially a wrapper around the TList class, since this code was designed for use in a Windows platform target, on a different platform, i needed to make some adjustments. type TIcsIntegerList = class(TObject) private FList : TList<Integer>; // Use TList<Integer> instead of TList function GetCount: Integer; function GetFirst: Integer; function GetLast: Integer; function GetItem(Index: Integer): Integer; procedure SetItem(Index: Integer; const Value: Integer); public constructor Create; virtual; destructor Destroy; override; function IndexOf(Item: Integer): Integer; function Add(Item: Integer): Integer; virtual; procedure Assign(Source: TIcsIntegerList); virtual; procedure Clear; virtual; procedure Delete(Index: Integer); virtual; property Count: Integer read GetCount; property First: Integer read GetFirst; property Last : Integer read GetLast; property Items[Index: Integer] : Integer read GetItem write SetItem; default; end; // ... other codes { TIcsIntegerList } function TIcsIntegerList.Add(Item: Integer): Integer; begin Result := FList.Add(Item); // No need to typecast Item to Pointer end; procedure TIcsIntegerList.Clear; begin FList.Clear; end; constructor TIcsIntegerList.Create; begin FList := TList<Integer>.Create; // Use TList<Integer> instead of TList end; procedure TIcsIntegerList.Delete(Index: Integer); begin FList.Delete(Index); end; destructor TIcsIntegerList.Destroy; begin FList.Free; inherited; end; function TIcsIntegerList.GetCount: Integer; begin Result := FList.Count; end; function TIcsIntegerList.GetFirst: Integer; begin Result := FList.First; // No need to typecast FList.First to Integer end; function TIcsIntegerList.GetLast: Integer; begin Result := FList.Last; // No need to typecast FList.Last to Integer end; // ... other codes but i faced a lot of errors when i target android platform and compiled, it gives me errors like: [DCC Error] OverbyteIcsUtils.pas(5931): E2023 Function needs result type [DCC Error] OverbyteIcsUtils.pas(5933): E2003 Undeclared identifier: 'FList' [DCC Error] OverbyteIcsUtils.pas(5933): E2003 Undeclared identifier: 'Item' [DCC Error] OverbyteIcsUtils.pas(5938): E2004 Identifier redeclared: 'TIcsIntegerList' [DCC Error] OverbyteIcsUtils.pas(5940): E2003 Undeclared identifier: 'FList' [DCC Error] OverbyteIcsUtils.pas(5945): E2037 Declaration of 'TIcsIntegerList' differs from previous declaration ...: So how to fix it? Or can anyone point me to the right direction?
  4. ICS V9.1 Done! Some improvement needed. Now i'm targeting V10.
  5. How to fix => F2047 Circular unit reference to 'Ics.Fmx.OverbyteIcsWSocketS' ? when compiling the "D110InstallVclFmx" project it raised that error in "IcsLinuxD110". I thought that was due to the changes i did for porting it (ICS v9...) on Android platform, but that wasn't the case. it occured even for win32/64 bit platform too. I'm talking about the ICS V9.1
  6. Yep! right it works. For the moment i figured it out as you suggested. Also i think that block of code should be wrapped under {$IF DEFINED(MSWINDOWS)} statement for future builds... as it is planned to introduced Android platform in ICS V10.
  7. I fixed it. I have gone through all the implementations up to above the indexed function. All errors related to what i provided, were due to the compile directives that have encompassed "Compound statements" (begin...end) in function IcsGetLocalTimeZoneBias. I just added some android compile directives: //... {$IFDEF ANDROID} var TimeZone: TTimeZone; begin TimeZone := TTimeZone.Local; Result := -Round(TimeZone.GetUtcOffset(Now).TotalMinutes); end; {$ENDIF} Yes! i noticed that. I'll list all changes after succeeded tests.
  8. As per the recent updates, the iconv related functions and types have been removed and replaced with cross-platform RTL functions. That's how i managed to migrate the code... but needed to be tested. function IcsIsValidAnsiCodePage(const CP: LongWord): Boolean; {$IFDEF MSWINDOWS} begin Result := IsValidCodePage(CP); end; {$ENDIF} {$IFDEF POSIX} var Encoding: TEncoding; CodePageStr: AnsiString; I: Integer; begin Result := (CP <> 1200) and (CP <> 1201) and (CP <> 12000) and (CP <> 12001); if Result then begin // Find the corresponding character encoding for the code page for I := Low(IconvCodepageMapping) to High(IconvCodepageMapping) do begin if IconvCodepageMapping[I].C = CP then begin CodePageStr := IconvCodepageMapping[I].A; Break; end; end; // Try to get the encoding for the code page try Encoding := TEncoding.GetEncoding(AnsiString(CodePageStr)); Result := Assigned(Encoding); except on E: EEncodingError do Result := False; end; end; end; {$ENDIF} However, codes for posix should work with android platform, but we can use the TEncoding.GetEncoding method to attempt to get an encoding for the given code page. {$IFDEF ANDROID} var Encoding: TEncoding; begin Result := (CP <> 1200) and (CP <> 1201) and (CP <> 12000) and (CP <> 12001); if Result then begin try // Attempt to get the encoding for the code page Encoding := TEncoding.GetEncoding(CP); Result := Assigned(Encoding); except // Handle encoding error on E: EEncodingError do Result := False; end; end; end; {$ENDIF}
  9. For the moment: Android (32-64 bit) FList is declared, as i posted it in the first post.⬇️ The fact is that, i thought tha was simple, why the IDE kept showing error and compiler failed where everything was declared. i also tried to reorder the constructor and functions to see if it causes compile errors but nothing solved. I also checked Doc wiki for Constructor overriding, if there is something to do with mobile platform.
  10. - E2023 Function needs result type and E2003 Undeclared identifier: 'FList' function TIcsIntegerList.Add(Item: Integer): Integer; begin Result := FList.Add(Pointer(Item)); end; - E2004 Identifier redeclared: 'TIcsIntegerList', E2003 Undeclared identifier: 'FList' procedure TIcsIntegerList.Clear; begin FList.Clear; end; - E2037 Declaration of 'TIcsIntegerList' differs from previous declaration. constructor TIcsIntegerList.Create; begin FList := TList.Create; end; - E2004 Identifier redeclared: 'TIcsIntegerList', E2003 Undeclared identifier: 'FList', E2003 Undeclared identifier: 'Index' procedure TIcsIntegerList.Delete(Index: Integer); begin FList.Delete(Index); end; - E2003 Undeclared identifier: 'iconv_t', E2003 Undeclared identifier: 'iconv_open'E2003 Undeclared identifier: 'iconv_close' and E2029 Declaration expected but 'IF' found {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *} function IcsIsValidAnsiCodePage(const CP: LongWord): Boolean; {$IFDEF MSWINDOWS} begin Result := IsValidCodePage(CP); end; {$ENDIF} {$IFDEF POSIX} {$IFDEF MACOS} begin Result := CFLocaleGetIdentifier(CP); end; {$ENDIF} var Ctx: iconv_t; begin Result := (CP <> 1200) and (CP <> 1201) and (CP <> 12000) and (CP <> 12001); if Result then begin Ctx := iconv_open(PAnsiChar(IcsIconvNameFromCodePage(CP)), ICONV_UNICODE); if Ctx = iconv_t(-1) then Result := False else begin iconv_close(Ctx); Result := True; end; end; end; {$ENDIF} - E2003 Undeclared identifier: '_statvfs', E2003 Undeclared identifier: 'statvfs', W1023 Comparing signed and unsigned types - widened both operands, E2029 ')' expected but identifier 'f_bfree' found function IcsGetFreeDiskSpace(const APath: String): Int64; {$IFDEF MSWINDOWS} var TotalSpace, FreeSpace : Int64; begin if GetDiskFreeSpaceEx (PChar(APath), FreeSpace, TotalSpace, nil) then Result := FreeSpace else Result := -1; {$ENDIF} {$IFDEF POSIX} var FN : RawByteString; // Path or file name Buf : _statvfs; begin FN := UnicodeToAnsi(APath, CP_UTF8); if statvfs(PAnsiChar(FN), Buf) = 0 then Result := Int64(Buf.f_bfree) * Int64(Buf.f_frsize) { V8.65 } else Result := -1; {$ENDIF} end; - E2034 Too many actual parameters, with variable "LBOMSize" when compiling on Android platform. function IcsGetBufferCodepage(Buf: PAnsiChar; ByteCount: Integer): LongWord; { V8.07 } var LBOMSize: Integer; begin Result := IcsGetBufferCodepage(Buf, ByteCount, LBOMSize); end; - - The TIcsFileStreamW class is a Unicode version of the TFileStream class throws errors. It is a custom file stream class defined. On Android, file handling is done differently, i am still looking for a work around. E2003 Undeclared identifier: 'TIcsFileStreamW' E2029 '=' expected but ';' found E2029 '=' expected but ')' found E2075 This form of method call only allowed in methods of derived types E2003 Undeclared identifier: 'FFileName' E2037 Declaration of 'TIcsFileStreamW' differs from previous declaration { TIcsFileStreamW } {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *} constructor TIcsFileStreamW.Create(const FileName: UnicodeString; Mode: Word); begin {$IFDEF COMPILER12_UP} inherited Create(FileName, Mode); FFileName := FileName; {$ELSE} Create(Filename, Mode, 0); {$ENDIF} end; {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *} constructor TIcsFileStreamW.Create(const FileName: UnicodeString; Mode: Word; Rights: Cardinal); begin {$IFDEF COMPILER12_UP} inherited Create(FileName, Mode, Rights); FFileName := FileName; {$ELSE} if Mode = fmCreate then begin inherited Create(IcsFileCreateW(FileName)); if Cardinal(FHandle) = INVALID_HANDLE_VALUE then {$IFDEF COMPILER12_UP} raise Exception.CreateResFmt(@SFCreateErrorEx, [ExpandFileName(FileName), SysErrorMessage(GetLastError)]); {$ELSE} raise Exception.CreateResFmt(@SFCreateErrorEx, [IcsExpandFileNameW(FileName), SysErrorMessage(GetLastError)]); {$ENDIF} end else begin inherited Create(IcsFileOpenW(FileName, Mode)); if Cardinal(FHandle) = INVALID_HANDLE_VALUE then {$IFDEF COMPILER12_UP} raise Exception.CreateResFmt(@SFCreateErrorEx, [ExpandFileName(FileName), SysErrorMessage(GetLastError)]); {$ELSE} raise Exception.CreateResFmt(@SFCreateErrorEx, [IcsExpandFileNameW(FileName), SysErrorMessage(GetLastError)]); {$ENDIF} end; FFileName := FileName; {$ENDIF} end; {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *} constructor TIcsFileStreamW.Create(const Utf8FileName: UTF8String; Mode: Word); begin {$IFDEF COMPILER12_UP} FFileName := Utf8FileName; inherited Create(FFileName, Mode); {$ELSE} Create(AnsiToUnicode(Utf8FileName, CP_UTF8), Mode, 0); {$ENDIF} end;
  11. Really interesting! My main purpose is to have the WebSocket/Ssl modules working on my projects which target Android platform. I know that porting ICS V9.0 to Android is likely to be a more complex and time-consuming task. And by initially focusing on ICS V10, i can make quicker progress and gain valuable experience with the newer codebase but I would like to use / port "TSslWebSocketCli" with Ssl.
  12. TList exist on all platforms, yes! I followed instructions from Migrating_Delphi_Code_to_Mobile_from_Desktop and embarcadero Delphi recommends the use of TList<...>, in our case: TList<Integer> to make it Cros-platform. as in ref: Generics_Collections_TList, stackoverflow: explication of - Remy Lebeau. from the original file, these errors are on these lines (5912 to 5940) : [DCC Error] OverbyteIcsUtils.pas(5912): E2023 Function needs result type [DCC Error] OverbyteIcsUtils.pas(5914): E2003 Undeclared identifier: 'FList' [DCC Error] OverbyteIcsUtils.pas(5914): E2003 Undeclared identifier: 'Item' [DCC Error] OverbyteIcsUtils.pas(5919): E2004 Identifier redeclared: 'TIcsIntegerList' [DCC Error] OverbyteIcsUtils.pas(5921): E2003 Undeclared identifier: 'FList' [DCC Error] OverbyteIcsUtils.pas(5926): E2037 Declaration of 'TIcsIntegerList' differs from previous declaration [DCC Error] OverbyteIcsUtils.pas(5928): E2003 Undeclared identifier: 'FList' [DCC Error] OverbyteIcsUtils.pas(5933): E2004 Identifier redeclared: 'TIcsIntegerList' [DCC Error] OverbyteIcsUtils.pas(5935): E2003 Undeclared identifier: 'FList' [DCC Error] OverbyteIcsUtils.pas(5935): E2003 Undeclared identifier: 'Index' [DCC Error] OverbyteIcsUtils.pas(5940): E2037 Declaration of 'TIcsIntegerList' differs from previous declaration Yes, you've done the bulk of the work, thank you for that! but there are many Types / classes which don't compile on Android/mobile platform such as: "TIcsFileStreamW" in "OverbyteIcsUtils.pas", "iconv"..."iconv_open"..., "_statvfs" (the way we get free space on disk for linux doesn't work for android, i planned to add it), "IcsGetBufferCodepage" (the way to get buffer of codepage for mobile platform need to be implemented, i 'll post mine later). As i sais i'll focus on "TIcsIntegerList" first.
  13. wright

    ICS V8.67 announced

    Low-level experienced, I'm still learning.
  14. wright

    ICS V8.67 announced

    Sure, i'll try.
  15. wright

    ICS V8.67 announced

    Hi, it would be great to have at least Android suport!
  16. By Following the installation process, even when i have targeted the 32 bits, i got error: [dcc64 Error] OverbyteIcsSslHttpOAuth.pas(2818): E2003 Undeclared identifier: 'IcsDiffSecs64' [dcc64 Fatal Error] OverbyteIcsSslX509Certs.pas(2988): F2063 Could not compile used unit 'OverbyteIcsSslHttpOAuth.pas'
  17. Yes! that's what i have done. But i got the same error. My bad i forgot to put the Version i used: `ICS 8.71`.
  18. Hey there! following the documentation of TWSocket.Addr, i tried to connect to a WebSocket "wss://ws.twelvedata.com/v1/quotes/price?apikey=api_key" using the "C:\Users\Public\...\icsv870\Samples\Delphi\SslInternet\OverbyteIcsSimpleSslCli64.dproj". without success. i always got error like: 'Winsock Resolve Host: Cannot convert host address 'wss://ws.twelvedata.com/v1/quotes/price?apikey=api_key' - Host not found (#11001)'. Processus OverbyteIcsSimpleSslCli.exe (25544) can you point me to the right direction? thx
  19. hi! @Angus Robertson, I think there is a redundancy between WSPingSecs and Timer, or do they differ according to their use?
  20. i tried to install ICS 8.70 / 8.71 without getit on Delphi 11.2 it seems it's not yet supported. any workarround?
  21. Thank you @Angus Robertson,, i'm in Test mod, feedbacks will drop soon!
  22. Hi there, i tried to parse the selected elements (JSON items), and then display the results using the [TListView](http://docwiki.embarcadero.com/Libraries/en/Vcl.ComCtrls.TListView) component and using using the [TJSONIterator.Next](http://docwiki.embarcadero.com/Libraries/en/System.JSON.Builders.TJSONIterator.Next), [TJSONIterator.Recurse](http://docwiki.embarcadero.com/Libraries/en/System.JSON.Builders.TJSONIterator.Recurse), and [TJSONIterator.Return](http://docwiki.embarcadero.com/Libraries/en/System.JSON.Builders.TJSONIterator.Return) methods. Code data: {"address": {"building": "1007", "coord": [-73.856077, 40.848447], "street": "Morris Park Ave", "zipcode": "10462"}, "borough": "Bronx", "cuisine": "Bakery", "grades": [{"date": {"$date": 1393804800000}, "grade": "A", "score": 2}, {"date": {"$date": 1378857600000}, "grade": "A", "score": 6}, {"date": {"$date": 1358985600000}, "grade": "A", "score": 10}, {"date": {"$date": 1322006400000}, "grade": "A", "score": 9}, {"date": {"$date": 1299715200000}, "grade": "B", "score": 14}], "name": "Morris Park Bake Shop", "restaurant_id": "30075445"} {"address": {"building": "469", "coord": [-73.961704, 40.662942], "street": "Flatbush Avenue", "zipcode": "11225"}, "borough": "Brooklyn", "cuisine": "Hamburgers", "grades": [{"date": {"$date": 1419897600000}, "grade": "A", "score": 8}, {"date": {"$date": 1404172800000}, "grade": "B", "score": 23}, {"date": {"$date": 1367280000000}, "grade": "A", "score": 12}, {"date": {"$date": 1336435200000}, "grade": "A", "score": 12}], "name": "Wendy'S", "restaurant_id": "30112340"} {"address": {"building": "351", "coord": [-73.98513559999999, 40.7676919], "street": "West 57 Street", "zipcode": "10019"}, "borough": "Manhattan", "cuisine": "Irish", "grades": [{"date": {"$date": 1409961600000}, "grade": "A", "score": 2}, {"date": {"$date": 1374451200000}, "grade": "A", "score": 11}, {"date": {"$date": 1343692800000}, "grade": "A", "score": 12}, {"date": {"$date": 1325116800000}, "grade": "A", "score": 12}], "name": "Dj Reynolds Pub And Restaurant", "restaurant_id": "30191841"} {"address": {"building": "2780", "coord": [-73.98241999999999, 40.579505], "street": "Stillwell Avenue", "zipcode": "11224"}, "borough": "Brooklyn", "cuisine": "American ", "grades": [{"date": {"$date": 1402358400000}, "grade": "A", "score": 5}, {"date": {"$date": 1370390400000}, "grade": "A", "score": 7}, {"date": {"$date": 1334275200000}, "grade": "A", "score": 12}, {"date": {"$date": 1318377600000}, "grade": "A", "score": 12}], "name": "Riviera Caterer", "restaurant_id": "40356018"} {"address": {"building": "97-22", "coord": [-73.8601152, 40.7311739], "street": "63 Road", "zipcode": "11374"}, "borough": "Queens", "cuisine": "Jewish/Kosher", "grades": [{"date": {"$date": 1416787200000}, "grade": "Z", "score": 20}, {"date": {"$date": 1358380800000}, "grade": "A", "score": 13}, {"date": {"$date": 1343865600000}, "grade": "A", "score": 13}, {"date": {"$date": 1323907200000}, "grade": "B", "score": 25}], "name": "Tov Kosher Kitchen", "restaurant_id": "40356068"} procedure TForm2.AddColumn(const AName: String); var oCol: TListColumn; begin oCol := ListView1.Columns.Add; oCol.Width := -1; oCol.Caption := AName; end; procedure TForm2.Button3Click(Sender: TObject); begin ParseObject; end; procedure TForm2.ParseObject; var oIter: TJSONIterator; LJsonTextReader: TJsonTextReader; LStringReader: TStreamReader; oItem: TListItem; I: Integer; begin // oIter := TJSONIterator.Create(LJsonTextReader); // NObjJSON := oIter.AsInteger; ListView1.Items.Clear; ListView1.Columns.Clear; ListView1.ViewStyle := vsReport; AddColumn('Name'); AddColumn('Cuisine'); AddColumn('Street'); AddColumn('Building'); AddColumn('Borough'); ListView1.Items.BeginUpdate; try oItem := ListView1.Items.Add; for i := 1 to ListView1.Columns.Count - 1 do oItem.SubItems.Add(''); LStringReader := TStreamReader.Create('../../resto.json', TEncoding.UTF8, True); LJsonTextReader := TJsonTextReader.Create(LStringReader); oIter := TJSONIterator.Create(LJsonTextReader); try while True do begin while oIter.Next do if oIter.&Type in [TJsonToken.StartObject, TJsonToken.StartArray] then oIter.Recurse else if oIter.Path = 'name' then oItem.Caption := oIter.AsString else if oIter.Path = 'cuisine' then oItem.SubItems[0] := oIter.AsString else if oIter.Path = 'address.street' then oItem.SubItems[1] := oIter.AsString else if oIter.Path = 'address.building' then oItem.SubItems[2] := oIter.AsString else if oIter.Path = 'borough' then oItem.SubItems[3] := oIter.AsString; if oIter.InRecurse then oIter.Return else Break; end; finally oIter.Free; LJsonTextReader.Free; LStringReader.Free; end; finally ListView1.Items.EndUpdate; end; end; As Result: i only got one line filled. I would like to get the result like that: Expected behavior
  23. Got it Works but in a different way than the official sample. I'm not satisfied with my procedure, i think there is a better way to do iteration without MongoDB. what i changed: ... ListView1.Items.BeginUpdate; try LStreamReader := TStreamReader.Create('../../resto.json', TEncoding.UTF8, True); LJsonTextReader := TJsonTextReader.Create(LStreamReader); oIter := TJSONIterator.Create(LJsonTextReader); while oIter.Next() do begin oItem := ListView1.Items.Add; for i := 1 to ListView1.Columns.Count - 1 do oItem.SubItems.Add(''); if oIter.&Type in [TJsonToken.StartObject, TJsonToken.StartArray] then begin oIter.Recurse; if oIter.Next('address') then begin oIter.Recurse; oIter.Next('building'); oItem.SubItems[2] := oIter.AsString; oIter.Next('street'); oItem.SubItems[1] := oIter.AsString; oIter.Return end; oIter.Next('borough'); oItem.SubItems[3] := oIter.AsValue.ToString; oIter.Next('cuisine'); oItem.SubItems[0] := oIter.AsValue.ToString; oIter.Next('name'); oItem.Caption := oIter.AsValue.ToString; end; if oIter.InRecurse then oIter.Return else Break; end; finally ListView1.Items.EndUpdate; end; ... Result:
×