purple: Add a way to specify the account has a password

This commit is contained in:
2021-04-10 18:23:04 +01:00
parent 6cca0cf014
commit 0b577205b3
2 changed files with 11 additions and 3 deletions

View File

@@ -41,6 +41,15 @@ impl Account {
}
}
pub fn get_password(&self) -> Option<Cow<str>> {
let password_ptr = unsafe { purple_sys::purple_account_get_password(self.0) };
if password_ptr.is_null() {
None
} else {
Some(unsafe { CStr::from_ptr(password_ptr) }.to_string_lossy())
}
}
pub fn is_disconnected(&self) -> bool {
let is_disconnected = unsafe { purple_sys::purple_account_is_disconnected(self.0) };
is_disconnected != 0

View File

@@ -44,9 +44,8 @@ impl<P> RegisterContext<P> {
// purple_sys defaults extra_info.options to contain:
// OPT_PROTO_NO_PASSWORD | OPT_PROTO_IM_IMAGE | OPT_PROTO_CHAT_TOPIC
// All we have to do is remove the no_password one.
self.extra_info.options =
purple_sys::PurpleProtocolOptions::OPT_PROTO_IM_IMAGE |
purple_sys::PurpleProtocolOptions::OPT_PROTO_CHAT_TOPIC;
self.extra_info.options = purple_sys::PurpleProtocolOptions::OPT_PROTO_IM_IMAGE
| purple_sys::PurpleProtocolOptions::OPT_PROTO_CHAT_TOPIC;
self
}