Re: [gedit-list] File loading hooks: anyone working on it?




You should have a look at gedit-code-assistance:
https://git.gnome.org/browse/gedit-code-assistance/

But it's maybe not flexible enough for what you want to do, I don't
know.

Cheers,
Sébastien


Hi Sébastien,
thank you for your answer.  I am looking at gedit-code-assistance, but
maybe it is not what I am searching for.

Maybe it is better if I explain fully what I would like to do.  I
would like to write an "encryption" plugin with a behavior similar to
OpenOffice.  More into detail,  I am thinking something like this

  1.   gedit loads a file and starts calling the registered "load file hook"-s

  2.   The hook of my plugin is called.  The called procedure checks
if the file begins with a special "magic number" (seed for key
stretching followed by its hash) that identifies the file as an
encrypted file.

  3.   If the magic number is present the user is asked for a passphrase

  4.   The passphrase is given to a "password stretching" procedure
together with the seed in order to get the encryption key

  5.   The file content is decrypted and a check that the decryption
is correct is done (e.g., by checking an hash appended to the
cleartext before encryption)

  6.   If the decryption is correct,
           6.1  replace the content read from disk with the decryption
           6.2 register a "save file hook" (that will re-encrypt the
content before saving it)
           6.3 return to the caller;
       if the decryption is not correct, go back to 3 to ask for a new
passphrase.

So, as you can see, I would like my hook to be called every time a
file is loaded and also I would like to be able to register a hook to
be called when the file is written back to disk.

   [[ Now that I write it, I see that maybe the addition of those two
"hooks" may result  too "invasive"... (depending on the current code)
]]

I understand that there are other approaches for working with
encrypted files: shell scripts that decrypt/encrypt the file
before/after calling gedit, calling an external command from inside
gedit, calling the plugin "by hand", and so on.  However, if possible,
I would prefer the behavior described above..

Thanks in advance for any help.

Cheers,
Riccardo


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