Jump to content

emileverh

Members
  • Content Count

    103
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by emileverh

  1. Hi guys! Last days I get a lot of "Error F2084: Internal Error: L878" errors in Delphi 13. Anyone has seen that also and a solution? -Emile
  2. emileverh

    Detection of Internet Connection

    var connectionstatus : DWORD; Result := InternetGetConnectedState( @connectionstatus, 0); ( Google InternetGetConnectedState to get all the info. Result is a boolean in this case )
  3. Hi guys! I want to use in Delphi 13 the NameOf() function to get the current function name ( "UploadCardParseResult" in example below). Is that possible?! procedure TdtmPeppolInvoices.UploadCardParseResult(const AJsonString: string; const AHxr: THXR); begin ShowMessage( NameOf(????) );
  4. Hi! I have an error: F2051 Unit System.Types was compiled with a different version of System.TArray`1 at line 6 (6:17) see screenshot. I tried cleaning the project from the project window. Tried cleaning my .dcu's in the Explorer. Where does come from?!?! I never touched system.types and it is included once in this project and even not in this unit. PLEASE HELP!
  5. emileverh

    System.Types error in Delphi 13

    I used the USES cleaner from CNPACK and know its gone. I still believe it was a glitch somewhere in D13. But anyhow, until now it's good!
  6. Exactly that is what I hope/hoped for
  7. emileverh

    Gexperts for Delphi 13

    I had the same problem, search did not react on keys Alt+Shif+s. By a restart of my PC I saw in a flash a screen with LSP exception and disappeared ...... After PC restart it worked again. (Talking about 32-bit btw)
  8. Hi team! I have download the great github example from Geoffrey Smith https://github.com/geoffsmith82/GmailAuthSMTP/. So in short, I want to send (and send only) for clients who have a Google account And it worked fine. So I went to the verification approval process of Google and I passed 😉 I asked for the scope in Google Console: https://www.googleapis.com/auth/gmail.send because I want to send (and sending only) PDF's from my application (I have an invoicing app). But after the approval I get the error message "username and password not accepted". I looked at StackOverflow, Google, Deepseek, etc. to find an answer. I am spending already lots of time in this.... Anyone an idea?
  9. "...Indy recently got a few new OAuth components...." In Delphi 12.2?
  10. Yes scope is correct. Else I did not get the final approval. @Remy Lebeau You as a specialist. Do you know if we can get it working via other components such as TNetHTTPClient? So not for the full scope but for the send-only scope. If you have any good tips for Indy, that is of course also welcome! ( https://www.googleapis.com/auth/gmail.send )
  11. CASA Tier 2.... I don't have a clue what that is. And I think also off topic. Yes, as I wrote, I am verified owner. I did 1000 times go to screen consent screen again. QUESTION.... ANYBODY: Is there a other way by not using the Indy components. Because gathering the tokens I tried today with a different component from DevExpress ( TdxGoogleAPIOauth2AuthorizationAgent). But I am stuck with 'IdSTMP.Authenticate' as you can see in the first post. In other words is there a working example for TNetHTTPClient?!?!?
  12. procedure TdtmOAuth.DataModuleCreate(Sender: TObject); begin var inifilename: string := ChangeFileExt(ParamStr(0), '.ini'); FIniSettings := TIniFile.Create(inifilename); FOAuth2 := TEnhancedOAuth2Authenticator.Create(nil); IdHTTPServer.Active := True; end; procedure TdtmOAuth.DataModuleDestroy(Sender: TObject); begin FreeAndNil(FOAuth2); end; procedure TdtmOAuth.DoLog(const msg: String); begin CodeSite.Send(msg); end; function TdtmOAuth.HasRefreshToken: Boolean; begin Result := not FOAuth2.RefreshToken.IsEmpty; end; procedure TdtmOAuth.IdConnectionReceive(ASender: TIdConnectionIntercept; var ABuffer: TIdBytes); begin DoLog('R:' + TEncoding.ASCII.GetString(ABuffer)); end; procedure TdtmOAuth.IdConnectionSend(ASender: TIdConnectionIntercept; var ABuffer: TIdBytes); begin DoLog('S:' + TEncoding.ASCII.GetString(ABuffer)); end; procedure TdtmOAuth.IdHTTPServerCommandGet(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo); var code: string; begin if ARequestInfo.QueryParams = '' then Exit; var url: TURI := TURI.Create('https://localhost/?' + ARequestInfo.QueryParams); try code := url.ParameterByName['code']; except Exit; end; FOAuth2.AuthCode := code; FOAuth2.ChangeAuthCodeToAccesToken; // AResponseInfo.ContentText := '<html><body onload="setTimeout(window.close(), 5000);"><h1>PERIFACT: U kunt de browser nu sluiten en terugkeren naar het programma/ You can close the browser and return to the program</h1></body></html>'; AResponseInfo.ContentText := '<html><body><h1>PERIFACT: U kunt de browser nu sluiten en terugkeren naar het programma/ You can close the browser and return to the program</h1></body></html>'; var tokennamestr: string := Provider.AuthName + 'Token'; FIniSettings.WriteString('Authentication', tokennamestr, FOAuth2.RefreshToken); DoLog('Authenticated via OAUTH2'); DoLog(FOAuth2.RefreshToken); SetupAuthenticator; end; function TdtmOAuth.IsAuthenticated: Boolean; begin Result := FIsAuthenticated; end; procedure TdtmOAuth.AuthenticateInBrowser; begin var uri: TURI := TURI.Create(FOAuth2.AuthorizationRequestURI); ShellExecute(0, 'open', PChar(uri.ToString), nil, nil, 0); end; procedure TdtmOAuth.ClearAuthentication; begin // Delete persistent Refresh_token. Note // - This probably should have a logout function called on it // - The token should be stored in an encrypted way ... but this is just a demo. FIniSettings.DeleteKey('Authentication', Provider.TokenName); SetupAuthenticator; end; procedure TdtmOAuth.SendMessage; var IdMessage: TIdMessage; xoauthSASL: TIdSASLListEntry; begin // if we only have refresh_token or access token has expired // request new access_token to use with request FOAuth2.ClientID := Provider.ClientID; FOAuth2.ClientSecret := Provider.ClientSecret; FOAuth2.RefreshAccessTokenIfRequired; DoLog('refresh_token=' + FOAuth2.RefreshToken); DoLog('access_token=' + FOAuth2.AccessToken); if FOAuth2.AccessToken.Length = 0 then begin DoLog('Failed to authenticate properly'); Exit; end; IdSMTP.Host := Provider.SmtpHost; IdSMTP.UseTLS := Provider.TLS; IdSMTP.Port := Provider.SmtpPort; xoauthSASL := IdSMTP.SASLMechanisms.Add; xoauthSASL.SASL := Provider.AuthenticationType.Create(nil); TIdSASLOAuthBase(xoauthSASL.SASL).Token := FOAuth2.AccessToken; TIdSASLOAuthBase(xoauthSASL.SASL).User := Provider.ClientAccount; IdSSLIOHandlerSocketSMTP.SSLOptions.SSLVersions := [sslvTLSv1_2]; IdSMTP.Connect; IdSMTP.AuthType := satSASL; IdSMTP.Authenticate; // <<<<<<<<<<<< HERE IT FAILS!!! <<<<<<<<<<<<<<<<<<<<<<<<<<<<< IdMessage := TIdMessage.Create(Self); IdMessage.From.Address := Provider.ClientAccount; IdMessage.From.Name := CLIENTNAME; IdMessage.ReplyTo.EMailAddresses := IdMessage.From.Address; IdMessage.Recipients.Add.Text := CLIENTSENDTOADDRESS; IdMessage.Subject := 'Hello World'; IdMessage.Body.Text := 'Hello Body'; IdSMTP.Send(IdMessage); IdSMTP.Disconnect; ShowMessage('Message Sent'); end;
  13. I have a SQLite table. Which has a column 'Description' and is initially defined as varchar(256). But that limitation is too small for the customers and I want to go to varchar(1024). According to the SQLite website they don't care; "SQLite does not enforce the length of a VARCHAR. You can declare a VARCHAR(10) and SQLite will be happy to store a 500-million character string there. And it will keep all 500-million characters intact. Your content is never truncated. SQLite understands the column type of "VARCHAR(N)" to be the same as "TEXT", regardless of the value of N."" I changed in the TFDQuery the field .Size definition of that field from 256 to 1024 in the Fields-editor. But still Delphi cuts of my string to 256 chars. When I Google I see all kinds of scripts of creating a temp-table and redefine the thing. I don't want to do that. Question; is there a property (somewhere, no size checking?!?) which I can change so that Delphi does not cut of the string? Thanks! -Emile CREATE TABLE IF NOT EXISTS cardlines ( UniquePK INTEGER PRIMARY KEY AUTOINCREMENT, Description varchar(256) NOT NULL, ........
  14. emileverh

    SQLite insert size beyond declaration

    Nope! Still no result. After Googling I found a link on this forum. And I think the only option is to create a temp table ;-((. https://en.delphipraxis.net/topic/9099-sqlite-varchar-field-overflow/
  15. emileverh

    SQLite insert size beyond declaration

    Hmm this feels good. I think we are in the right direction. I am gonna try this and come back with the results!
  16. emileverh

    SQLite insert size beyond declaration

    Okay, and where is the setting which I am searching for? Thats why I am asking this here on this forum....
  17. emileverh

    SQLite insert size beyond declaration

    Or in a Delphi connection-setting (TFDConnection) which I don't know yet....
  18. emileverh

    SQLite insert size beyond declaration

    What an other tool does, says nothing about Delphi. And the search for '256' I already... so still no result ;-((
  19. emileverh

    Retrieve value of INSERT ... RETURNING ...?

    The what they called performance issue I never noticed. You have to see it in a relative way. But I am sure that I have unique values.
  20. emileverh

    Retrieve value of INSERT ... RETURNING ...?

    If I was you in SQLite I defined 'database_id' as AUTOINCREMENT. No duplicates anymore! CREATE TABLE databases ( database_id INTEGER PRIMARY KEY AUTOINCREMENT And if you want to know the last inserted id, call the following statement: select LAST_INSERT_ID() as seq
  21. Team! I have one large application which I compile twice, one is for MySQL and the other for SQLite. For regular queries like select * from everything goes fine. But it goes wrong with SUM() functions. The query defined in a TFDQuery below works fine in MySQL, but when I compile the application for SQLite I get an exception "Type mismatch for field 'SumVal', expecting: FMTBcd actual: Float'. " The definition of AmountValue in the database is: AmountValue DECIMAL(13,4) NOT NULL And here is the query: select SUM(AmountValue) AS SumVal from camtentries Is there a property for this one and only TFDQuery or for the field qrySumPositiveSumVal.AsCurrency where it compiles fine in both applications? I prefer not to set an overall property in the TFDConnection. Thanks!!! -Emile
  22. The final solution is different than proposed. I did not know but the SUM() function can return NULL values. So on larger datasets I did get 'WideString'!!! conversion error messages on SQLite. So I had to use IFNULL. May be not for all the most elegant solution. But this TFDQUERY works now for both MySQL and SQLite select IFNULL(SUM(AmountValue),0) AS SumVal from camtentries And in the code: var mycurr: currency := qryMyQuery.FieldByName('SumValue').Value; Normally I don't work with .FieldByName and .Value. I prefer this: var mycurr: currency := qryMyQuerySumValue.AsCurrency; But know the app is not complaining. I have hundreds of queries, but only 2 SUM()'s. So I can live with that. I don't use them in a loop, so performance is not an issue. And I develop the app with MySQL. Because I can easy test my data together with HeidiSQL. The field names become also strange select IFNULL(SUM(AmountValue),0) AS "SumVal::DOUBLE:" will be qryMyQuerySumValueDOUBLE.AsCurrency; Although the first answers where not the implemented one. I want to thank all the people in general on this forum. As solo entrepreneur I don't have a collegae to ask. So thank you all!
×