[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gambas-user] desktop portal file IDs


Am looking into that darn portal file definition problem.
I think cracking this may help with a couple of things that require portals
file id values like Inhibit() and SendMail attachments

I'm thinking this may be a way to get the integer used in the portal for
"fiie ids"..
The use of Documents.Add() that "adds to the document store" seems files
are used in "a controlled way" in the portal and they must be added to the
"store" and can be used then from there.

DBus["org.freedesktop.portal.Documents"]["/org/freedesktop/portal/documents","org.freedesktop.portal.Documents"].Add(iFileHandle)

this following code (a mod of DesktopPortal.SendMail() ) damn near works....

Public Sub SendMail(aTo As String[], aCc As String[], aBcc As String[],
sSubject As String, sBody As String, aAttach As String[])

  Dim aFile As String[]
  Dim sAttach As String
  Dim sID As String
  Dim hFile As File
  Dim cOption As New Collection

  StartPortal

'' begin mod

  If aAttach And If aAttach.Count Then
    aFile = New String[]
    For Each sAttach In aAttach
      Try hFile = Open sAttach For Read
      If Error Then Continue
      sID =
DBus["org.freedesktop.portal.Documents"]["/org/freedesktop/portal/documents",
"org.freedesktop.portal.Documents"].Add(hFile.Handle, True, True)
      aFile.Add(sID)
    Next
  Endif

'' End mod

  cOption = New Collection

  If Not aTo Then aTo = New String[]
  cOption["addresses"] = aTo
  If Not aCc Then aCc = New String[]
  cOption["cc"] = aCc
  If Not aBcc Then aBcc = New String[]
  cOption["bcc"] = aBcc
  cOption["subject"] = sSubject
  cOption["body"] = sBody
  If aFile Then cOption["attachment_fds"] = aFile

  GetPortal("Email").ComposeEmail("", cOption)

End

I've tried it but it is still not working.
think i am on the right track though
it gets the ID from the File.Handle property just fine it seems.

using
DBus["org.freedesktop.portal.Documents"]["/org/freedesktop/portal/documents","org.freedesktop.portal.Documents"].List()
shows the file is added.

but still no attachments added :(

Respects
BruceS

Follow-Ups:
Re: [Gambas-user] desktop portal file IDsBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>