module KWalletd5

Public Instance Methods

change_wallet_password(wallet_name, app_name, window_id: "0") click to toggle source

Direct Functions

# File lib/kwalletd5-wrapper.rb, line 122
def change_wallet_password(wallet_name, app_name, window_id: "0")
  # Kwalletd5 returns "-1" if the prompt opens properly. No way of telling if
  # the password was actually changed (at least not via qdbus).
  message_kwd5("changePassword", wallet_name, app_name, window_id) == "-1"
end
delete_wallet(wallet_name) click to toggle source
# File lib/kwalletd5-wrapper.rb, line 136
def delete_wallet(wallet_name)
  message_kwd5("deleteWallet", wallet_name)
end
does_wallet_exist(wallet_name) click to toggle source
# File lib/kwalletd5-wrapper.rb, line 144
def does_wallet_exist(wallet_name)
  message_kwd5("wallets").split("\n").include?(wallet_name)
end
is_wallet_open(wallet_name) click to toggle source
# File lib/kwalletd5-wrapper.rb, line 140
def is_wallet_open(wallet_name)
  message_kwd5("isOpen", wallet_name) == "true"
end
list_users(wallet_name) click to toggle source
# File lib/kwalletd5-wrapper.rb, line 132
def list_users(wallet_name)
  message_kwd5("users", wallet_name)
end
list_wallets() click to toggle source
# File lib/kwalletd5-wrapper.rb, line 128
def list_wallets
  message_kwd5("wallets")
end

Private Instance Methods

message_kwd5(method, *args, path: "/modules/kwalletd5") click to toggle source

Private helper functions

# File lib/kwalletd5-wrapper.rb, line 151
def message_kwd5(method, *args, path: "/modules/kwalletd5")
  # TODO: Test if capture3 handles escaping characters.
  # TODO: handle the case where a string contains "\;" already (escape both?)
  #         args.each{ |arg| arg.split(";").join("\;") }
  stdout, stderr, status = Open3.capture3("qdbus org.kde.kwalletd5 #{path} #{method} #{args.join(" ")}")
  unless stderr == ""
    raise stderr + " -- ran: qdbus org.kde.kwalletd5 #{path} #{method} #{args.join(" ")}"
  end
  unless status == 0
    raise "Method call returned error code: #{status}. stdout = '#{stdout}', stderr = '#{stderr}'" +
      " -- ran: qdbus org.kde.kwalletd5 #{path} #{method} #{args.join(" ")}"
  end
  stdout.strip()
end