Jump to content

Lars Fosdal

Administrators
  • Content Count

    3362
  • Joined

  • Last visited

  • Days Won

    112

Lars Fosdal last won the day on July 18

Lars Fosdal had the most liked content!

Community Reputation

1764 Excellent

Technical Information

  • Delphi-Version
    Delphi 12 Athens

Recent Profile Visitors

10477 profile views
  1. Lars Fosdal

    UK Remote Delphi Developer

    I think you need more detail to attract candidates.
  2. Lars Fosdal

    Watch me coding in Delphi on YouTube

    This is me
  3. Xiaomi maintain their own Android fork. Can that be a factor?
  4. Lars Fosdal

    REST api: too much data

    Do you get a monolithic collection of json elements for the entire day, or do they arrive one by one? If monolithic, you could split it up and add each element to a queue. Is there a sequence of processing requirement? If not, you could have multiple parallell consumers of that queue.
  5. Lars Fosdal

    MSGraph and OAuth

    Found a description of "Invalid audience"-here https://stackoverflow.com/questions/75228773/access-token-validation-failure-invalid-audience-office-365-graph-api Spelunked and found this, but haven't tried it myself https://github.com/jfbilodeau/AzureRESTExample There also is this thread, but I am uncertain if it came to conclusion? OAuth2 isn't really a standard, but a guideline, and there can be fickle differences between implementations. I successfully do OAuth2 authentication to our ERP systems, using System.Net.HTTPClient THTTPClient, and simulating a form post. I couldn't get the REST OAuth component to work. In the source below, TRes is a TObject containing the properties of the expected response body from the authentication - which should contain your tokens. function TIONAPI.BuildStringStream(const NameValues: TNetHeaders): TStringStream; var Encoded, Sep : string; begin Sep := ''; Encoded := ''; for var item in NameValues do begin Encoded := Encoded + Sep + Item.Name + '=' + Encoder.EncodeForm(Item.Value); Sep := '&'; end; Result := TStringStream.Create(UTF8String(Encoded)); end; function TIONAPI.PostForm<TRes>(const aURL: string; const aFormFields: TNetHeaders; aExpectsResult: Boolean): TRes; var HTTPRequest: IHttpRequest; HttpResponse: IHttpResponse; ReqBody: TStringStream; ResStatus: Integer; ResContent: string; ReqHeaders: TNetHeaders; T: TStopWatch; begin Result := nil; ResStatus := 0; ReqBody := nil; FLastStatus := 0; FLastErrorMsg := ''; try try DebugOut(Format('HTTP %s %s', ['POST', aURL])); // DO NOT TRANSLATE try HTTPRequest := HTTP.GetRequest('POST', aURL); HTTPRequest.RemoveHeader('User-Agent'); HTTPRequest.SetCredential(IONCredentials.ResourceOwnerClientId, IONCredentials.ResourceOwnerClientSecret); ReqBody := BuildStringStream(aFormFields); HttpRequest.SourceStream := ReqBody; ReqHeaders := [ TNetHeader.Create('content-type', mime.ApplicationXwwwForm), // DO NOT TRANSLATE TNetHeader.Create('Expect', '100-continue') // DO NOT TRANSLATE // TNetHeader.Create('User-Agent', UserAgent); // DO NOT TRANSLATE ]; HTTP.PreemptiveAuthentication := True; T := TStopWatch.StartNew; HttpResponse := HTTP.Execute(HTTPRequest, nil, ReqHeaders); T.Stop; DebugOut('Status: ' + ResStatus.ToString + ' in ' + T.ElapsedMilliseconds.ToString+ ' ms'); if Assigned(HttpResponse) then begin ResStatus := HttpResponse.StatusCode; ResContent := HttpResponse.ContentAsString(TEncoding.UTF8); if (ResStatus = 200) then begin try T := TStopWatch.StartNew; Result := TJson.JsonToObject<TRes>(ResContent); except on E: Exception do begin DebugOutException(E, Format('TIONAPI.PostForm.%s<%s, %s> returned StatusCode: %d - but failed during conversion of "%s"', // DO NOT TRANSLATE [aURL, '', Result.ClassName, ResStatus, ResContent])); ResStatus := HTTPStatus.ExpectationFailed417; Result := nil; FLastErrorMsg := E.Message; end; end; end else begin Result := nil; end; end else begin ResStatus := HTTPStatus.NoResponse; ResContent := ''; Result := nil; end; except // Json Exception on E:Exception do begin DebugOutException(E); ResStatus := HTTPStatus.ExpectationFailed417; end; end; finally // DebugOut('Status: ' + ResStatus.ToString); ReqBody.Free; end; except // HTTP Exception on E: Exception do begin FLastStatus := ResStatus; FLastErrorMsg := E.Message; DebugOutException(E, Self.ClassName + '.PostForm'); // DO NOT TRANSLATE end; end; end;
  6. Lars Fosdal

    TControlList — need help!

    Or VS Code.
  7. Lars Fosdal

    Delphi app using Access database very slow on network drive.

    Single user or multi user? Named share? Long path/file names? Antivirus changes? DNS changes? Security changes? Do you which calls that are slow? Have you tried System Monitor to look for errors?
  8. Lars Fosdal

    What happened to OmniThreadLibrary.com

    Last release was 7 months ago. https://github.com/gabr42/OmniThreadLibrary
  9. Lars Fosdal

    Essential Delphi Addins survey

    Done.
  10. @corneliusdavid The fewest new ones, or the fewest old ones? 😉
  11. None of them. Old bugs fixed. New bugs are added. Old bugs resurface. Repeat.
  12. Lars Fosdal

    My YouTube Channel - The Silver Coder

    @silvercoder79 Hi Tim! I think it is great that you share your experiences with our favorite language! There seems to be a small influx of new faces at the moment, so the better an education they can have, the better it is for the community!
  13. Lars Fosdal

    Is there a way to check is the "user Idle" (no interaction)

    @Tommi Prami - So, do you want to have your app do something, when the PC signals that there has been no keyboard or mouse events for a while? Do you want to track that yourself, or are you looking for a system event? https://stackoverflow.com/questions/2212823/how-to-detect-inactive-user https://stackoverflow.com/questions/2177513/receive-screensaver-notification
  14. @Leszek Ref. your report - unless the context/conditions are identical, it is always wise to start a new topic instead of adding your question to an existing topic. I split off this question for you, as it seems to be a different problem.
  15. So, you copy text from outside the Delphi app, and when you paste it into your TMemo, it is LF and not CRLF? What is your TMemo.Lines.LineBreak set to? An alternative would be to intercept the paste and use https://docwiki.embarcadero.com/Libraries/Alexandria/en/System.SysUtils.AdjustLineBreaks
×