Index: components/os_crypt/kwallet_dbus.cc |
diff --git a/components/os_crypt/kwallet_dbus.cc b/components/os_crypt/kwallet_dbus.cc |
index f6ec2a1fcec6940aa99522634d12233cd94e5844..a65d6006d1bcf312f7c1ae34bfd613818bd779f9 100644 |
--- a/components/os_crypt/kwallet_dbus.cc |
+++ b/components/os_crypt/kwallet_dbus.cc |
@@ -342,3 +342,86 @@ KWalletDBus::Error KWalletDBus::CreateFolder(const int handle, |
} |
return SUCCESS; |
} |
+ |
+KWalletDBus::Error KWalletDBus::WritePassword(const int handle, |
+ const std::string& folder_name, |
+ const std::string& key, |
+ const std::string& password, |
+ const std::string& app_name, |
+ bool* const write_success_ptr) { |
+ dbus::MethodCall method_call(kKWalletInterface, "writePassword"); |
+ dbus::MessageWriter builder(&method_call); |
+ builder.AppendInt32(handle); |
+ builder.AppendString(folder_name); |
+ builder.AppendString(key); |
+ builder.AppendString(password); |
+ builder.AppendString(app_name); |
+ std::unique_ptr<dbus::Response> response(kwallet_proxy_->CallMethodAndBlock( |
+ &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT)); |
+ if (!response.get()) { |
Lei Zhang
2016/07/20 01:08:26
No need for .get() here, ditto on line 390, and 41
cfroussios
2016/07/20 15:22:47
Done.
|
+ LOG(ERROR) << "Error contacting << " << kwalletd_name_ |
Lei Zhang
2016/07/20 01:08:26
did you want the extra "<< " in the string? Ditto
cfroussios
2016/07/20 15:22:47
Done.
|
+ << " (writePassword)"; |
+ return CANNOT_CONTACT; |
+ } |
+ dbus::MessageReader reader(response.get()); |
+ int return_code; |
+ if (!reader.PopInt32(&return_code)) { |
+ LOG(ERROR) << "Error reading response from " << kwalletd_name_ |
+ << " (writePassword): " << response->ToString(); |
+ return CANNOT_READ; |
+ } |
+ *write_success_ptr = return_code == 0; |
+ return SUCCESS; |
+} |
+ |
+KWalletDBus::Error KWalletDBus::ReadPassword(const int handle, |
+ const std::string& folder_name, |
+ const std::string& key, |
+ const std::string& app_name, |
+ std::string* const password_ptr) { |
+ dbus::MethodCall method_call(kKWalletInterface, "readPassword"); |
+ dbus::MessageWriter builder(&method_call); |
+ builder.AppendInt32(handle); |
+ builder.AppendString(folder_name); |
+ builder.AppendString(key); |
+ builder.AppendString(app_name); |
+ std::unique_ptr<dbus::Response> response(kwallet_proxy_->CallMethodAndBlock( |
+ &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT)); |
+ if (!response.get()) { |
+ LOG(ERROR) << "Error contacting << " << kwalletd_name_ << " (readPassword)"; |
+ return CANNOT_CONTACT; |
+ } |
+ dbus::MessageReader reader(response.get()); |
+ if (!reader.PopString(password_ptr)) { |
+ LOG(ERROR) << "Error reading response from " << kwalletd_name_ |
+ << " (readPassword): " << response->ToString(); |
+ return CANNOT_READ; |
+ } |
+ return SUCCESS; |
+} |
+ |
+KWalletDBus::Error KWalletDBus::Close(const int handle, |
+ const bool force, |
+ const std::string& app_name, |
+ bool* success_ptr) { |
+ dbus::MethodCall method_call(kKWalletInterface, "close"); |
+ dbus::MessageWriter builder(&method_call); |
+ builder.AppendInt32(handle); |
+ builder.AppendBool(force); |
+ builder.AppendString(app_name); |
+ std::unique_ptr<dbus::Response> response(kwallet_proxy_->CallMethodAndBlock( |
+ &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT)); |
+ if (!response.get()) { |
+ LOG(ERROR) << "Error contacting << " << kwalletd_name_ << " (close)"; |
+ return CANNOT_CONTACT; |
+ } |
+ dbus::MessageReader reader(response.get()); |
+ int return_code = 1; |
+ if (!reader.PopInt32(&return_code)) { |
+ LOG(ERROR) << "Error reading response from " << kwalletd_name_ |
+ << " (close): " << response->ToString(); |
+ return CANNOT_READ; |
+ } |
+ *success_ptr = return_code == 0; |
+ return SUCCESS; |
+} |