martinkostolny created this revision.
martinkostolny added a project: KTextEditor.
Restricted Application added subscribers: Frameworks, kwrite-devel.
Restricted Application added a project: Frameworks.

REVISION SUMMARY
  Before this patch: if one opens a write protected document, makes changes and 
then wants to save, error message occurs about insufficient privileges or disk 
space.
  
  With this patch kate-part will try to save the document contents with 
elevated privileges in case the regular save failed. So that KAuth graphical 
prompt is presented to user. I believe this was suggested by many KDE users as 
a wanted feature. Please let me know if this isn't the right approach.
  
  I'm in fact quite new to KTextEditor as well as KAuth so feel free to 
criticize the code. I'll try to fix everything you point at :).
  
  What I basically did:
  
  - created TextBufferSecure class (for dedicated KAuth helper binary)
  - moved most contents of TextBuffer:save() method to this new class' 
saveInternal() method
  - TextBuffer:save() method now first tries to save with 
TextBufferSecure::saveInternal() helper method
  - if that fails it will call it again through KAuth action

TEST PLAN
  - editing & saving document in home page
  - editing & saving /etc/hosts
  - tried with Krusader's "internal viewer" which uses ReadWritePart + tried 
with Kate
  
  But I'm sure there are a lot of other use-cases I didn't think of. Maybe you 
think of somehting. On my mind is now saving documents with different encoding, 
eol type, saving huge documents. I'll do that and if problems occur, I'll fix 
the diff.

REPOSITORY
  R39 KTextEditor

REVISION DETAIL
  https://phabricator.kde.org/D4847

AFFECTED FILES
  src/CMakeLists.txt
  src/buffer/katetextbuffer.cpp
  src/buffer/katetextbuffer_secure.cpp
  src/buffer/katetextbuffer_secure.h
  src/buffer/org.kde.ktexteditor.katetextbuffer.actions

EMAIL PREFERENCES
  https://phabricator.kde.org/settings/panel/emailpreferences/

To: martinkostolny, #ktexteditor
Cc: kwrite-devel, #frameworks, head7, cullmann, kfunk, sars, dhaumann

Reply via email to