Skip to content

Commit

Permalink
- added "Snapper Support" checkbox for shares (fate#313349)
Browse files Browse the repository at this point in the history
- 3.0.1
  • Loading branch information
jsuchome committed Sep 12, 2013
1 parent 7da0e88 commit da9b312
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 38 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.0
3.0.1
6 changes: 6 additions & 0 deletions package/yast2-samba-server.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Thu Sep 12 17:11:20 CEST 2013 - jsuchome@suse.cz

- added "Snapper Support" checkbox for shares (fate#313349)
- 3.0.1

-------------------------------------------------------------------
Wed Jul 31 08:38:58 UTC 2013 - yast-devel@opensuse.org

Expand Down
107 changes: 70 additions & 37 deletions src/include/samba-server/dialogs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,33 @@ def initialize_samba_server_dialogs(include_target)
@guest_access = false

@autoyast_warning_done = false

@snapper_available = nil
end

# routines

# check if snapper support is available (initial check)
def snapper_available?
if @snapper_available.nil?
@snapper_available = Package.Installed("snapper")
end
@snapper_available
end

# check if given path points to btrfs subvolume
def subvolume?(path)
return false unless path
stat = SCR.Read(path(".target.stat"), path)

return true if
# 1. is btrfs subvolume
stat["inode"] == 256 &&
# 2. has snapper config
SCR.Execute(path(".target.bash"), "grep 'SUBVOLUME=\"#{path}\"' /etc/snapper/configs/*")
false
end


def sharesItems(filt)
shares = SambaConfig.GetShares
Expand Down Expand Up @@ -653,7 +676,7 @@ def SharesWidgetHandle(key, event_descr)
)
return nil if share == nil

if ret == :edit
if ret == :edit || ret == :table
@shareToEdit = share
return :edit
end
Expand Down Expand Up @@ -825,9 +848,7 @@ def EditShareDialog
"caption" => caption,
"back_button" => Label.BackButton,
"next_button" => Label.OKButton,
"fallback_functions" => {
:abort => fun_ref(method(:confirmAbort), "boolean ()")
}
"abort_button" => nil
}
)
end
Expand Down Expand Up @@ -865,6 +886,8 @@ def GlobalSettingsDialog
end

def AddShareDialog
default_path = "/home"

contents = HVSquash(HBox(
HSpacing(1),
VBox(Opt(:hstretch),
Expand All @@ -889,7 +912,7 @@ def AddShareDialog
)),
HBox(
# translators: text entry label
InputField(Id(:path), _("Share &Path"), "/home"),
InputField(Id(:path), Opt(:notify), _("Share &Path"), default_path),
VBox(
Label(""),
PushButton(Id(:browse), Label.BrowseButton)
Expand All @@ -898,64 +921,75 @@ def AddShareDialog
# translators: checkbox label, setting for share
Left(CheckBox(Id(:read_only), _("&Read-Only"), false)),
# checkbox label
Left(CheckBox(Id(:inherit_acls), _("&Inherit ACLs"), true))
Left(CheckBox(Id(:inherit_acls), _("&Inherit ACLs"), true)),
# checkbox label
Left(CheckBox(Id(:snapper_support), _("Snapper Support"), false))
),
HSpacing(1)
))
)
))

# translators: dialog caption
caption = _("New Share")

Wizard.SetContentsButtons(
caption,
# translators: dialog caption
_("New Share"),
contents,
Ops.get_string(@HELPS, "add_share", ""),
@HELPS["add_share"] || "",
Label.BackButton,
Label.OKButton
)
Wizard.HideAbortButton

UI.SetFocus(Id(:name))
UI.ChangeWidget(Id(:snapper_support), :Enabled, snapper_available? && subvolume?(default_path))

ret = nil
begin
# enable/disable path
on = Convert.to_boolean(UI.QueryWidget(Id(:directory), :Value))
on = UI.QueryWidget(Id(:directory), :Value)
UI.ChangeWidget(Id(:path), :Enabled, on)
UI.ChangeWidget(Id(:browse), :Enabled, on)
UI.ChangeWidget(Id(:read_only), :Enabled, on)
UI.ChangeWidget(Id(:inherit_acls), :Enabled, on)

ret = Convert.to_symbol(UI.UserInput)
ret = UI.UserInput

if ret == :cancel
break if confirmAbort
ret = nil
next
end

if ret == :printer || ret == :directory
ret = nil
next
end

if ret == :browse
pathvalue = UI.QueryWidget(Id(:path), :Value)

if ret == :path
if snapper_available?
UI.ChangeWidget(Id(:snapper_support), :Enabled, subvolume?(pathvalue))
end
ret = nil
elsif ret == :browse
# translators: file selection dialog title
dir = UI.AskForExistingDirectory(
Convert.to_string(UI.QueryWidget(Id(:path), :Value)),
_("Path for a Share")
)
UI.ChangeWidget(Id(:path), :Value, dir) if dir != nil
dir = UI.AskForExistingDirectory(pathvalue, _("Path for a Share"))
UI.ChangeWidget(Id(:path), :Value, dir) unless dir
ret = nil
elsif ret == :next
# OK was pressed

name = Convert.to_string(UI.QueryWidget(Id(:name), :Value))
pathvalue = Convert.to_string(UI.QueryWidget(Id(:path), :Value))
comment = Convert.to_string(UI.QueryWidget(Id(:comment), :Value))
printable = Convert.to_boolean(UI.QueryWidget(Id(:printer), :Value))
name = UI.QueryWidget(Id(:name), :Value)
comment = UI.QueryWidget(Id(:comment), :Value)
printable = UI.QueryWidget(Id(:printer), :Value)

if Builtins.size(name) == 0
if name.empty?
# translators: error message
Popup.Error(_("Share name cannot be empty."))
ret = nil
next
elsif Builtins.size(pathvalue) == 0 && !printable
elsif pathvalue.empty? && !printable
# translators: error message
Popup.Error(_("Share path cannot be empty."))
ret = nil
Expand All @@ -972,18 +1006,17 @@ def AddShareDialog
res = { "comment" => comment }

if printable
Ops.set(res, "printable", "Yes")
Ops.set(res, "path", "/var/tmp")
res["printable"] = "Yes"
res["path"] = "/var/tmp"
else
read_only = Convert.to_boolean(
UI.QueryWidget(Id(:read_only), :Value)
)
inherit_acls = Convert.to_boolean(
UI.QueryWidget(Id(:inherit_acls), :Value)
)
Ops.set(res, "read only", read_only ? "Yes" : "No")
Ops.set(res, "inherit acls", inherit_acls ? "Yes" : "No")
Ops.set(res, "path", pathvalue)
read_only = UI.QueryWidget(Id(:read_only), :Value)
inherit_acls = UI.QueryWidget(Id(:inherit_acls), :Value)

res["read only"] = read_only ? "Yes" : "No"
res["inherit acls"] = inherit_acls ? "Yes" : "No"
res["path"] = pathvalue
res["vfs objects"] = "snapper" if
snapper_available? && UI.QueryWidget(Id(:snapper_support), :Value)
end

if SambaConfig.ShareExists(name)
Expand Down Expand Up @@ -1024,7 +1057,7 @@ def Installation_Conf_Tab
# translators: table header texts
Table(
Id(:table),
Opt(:hvstretch),
Opt(:hvstretch,:notify),
Header(
_("Status"),
_("Read-Only"),
Expand Down

0 comments on commit da9b312

Please sign in to comment.