Compare commits
5 Commits
320201271b
...
37f652f106
Author | SHA1 | Date | |
---|---|---|---|
37f652f106 | |||
c41e7c6259 | |||
45406b30b1 | |||
f718015318 | |||
0b577205b3 |
17
src/lib.rs
17
src/lib.rs
@@ -141,6 +141,23 @@ impl purple::PrplPlugin for PurpleDelta {
|
||||
context
|
||||
.with_info(info)
|
||||
.with_password()
|
||||
.with_string_option("Display Name".into(), "displayname".into(), "".into())
|
||||
.with_string_option(
|
||||
"IMAP server hostname".into(),
|
||||
"mail_server".into(),
|
||||
"".into(),
|
||||
)
|
||||
.with_string_option("IMAP server port".into(), "mail_port".into(), "".into())
|
||||
// Username and password are mail_user and mail_pw
|
||||
.with_string_option(
|
||||
"SMTP server hostname".into(),
|
||||
"send_server".into(),
|
||||
"".into(),
|
||||
)
|
||||
.with_string_option("SMTP server port".into(), "send_port".into(), "".into())
|
||||
.with_string_option("SMTP server username".into(), "send_user".into(), "".into())
|
||||
.with_password_option("SMTP server password".into(), "send_pw".into(), "".into())
|
||||
.with_bool_option("Copy messages to self".into(), "bcc_self".into(), false)
|
||||
.enable_login()
|
||||
.enable_load()
|
||||
.enable_close()
|
||||
|
@@ -23,6 +23,13 @@ impl<P> RegisterContext<P> {
|
||||
pub fn into_raw(mut self) -> *mut purple_sys::PurplePluginInfo {
|
||||
self.extra_info.roomlist_get_list = Some(entrypoints::roomlist_get_list_handler);
|
||||
|
||||
// If any protocol options have been set, they are back to front, so
|
||||
// reverse the list now
|
||||
unsafe {
|
||||
self.extra_info.protocol_options =
|
||||
glib_sys::g_list_reverse(self.extra_info.protocol_options);
|
||||
}
|
||||
|
||||
self.info.extra_info = Box::into_raw(self.extra_info) as *mut c_void;
|
||||
|
||||
Box::into_raw(self.info)
|
||||
@@ -44,12 +51,64 @@ 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
|
||||
}
|
||||
|
||||
fn with_option(mut self, option: PrplOption) -> Self {
|
||||
let mut list: *mut glib_sys::GList = self.extra_info.protocol_options;
|
||||
unsafe {
|
||||
let ptr: *mut purple_sys::PurpleAccountOption = match option.def {
|
||||
PrplOptionValue::String(def) => purple_sys::purple_account_option_string_new(
|
||||
CString::new(option.text).unwrap().into_raw(),
|
||||
CString::new(option.key).unwrap().into_raw(),
|
||||
CString::new(def).unwrap().into_raw(),
|
||||
),
|
||||
PrplOptionValue::Bool(def) => purple_sys::purple_account_option_bool_new(
|
||||
CString::new(option.text).unwrap().into_raw(),
|
||||
CString::new(option.key).unwrap().into_raw(),
|
||||
def.into(),
|
||||
),
|
||||
};
|
||||
|
||||
purple_sys::purple_account_option_set_masked(ptr, option.masked.into());
|
||||
|
||||
list = glib_sys::g_list_prepend(list, glib::translate::Ptr::to(ptr));
|
||||
}
|
||||
|
||||
self.extra_info.protocol_options = list;
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_string_option(mut self, name: String, key: String, def: String) -> Self {
|
||||
self.with_option(PrplOption {
|
||||
text: name,
|
||||
key: key,
|
||||
def: PrplOptionValue::String(def),
|
||||
masked: false,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn with_password_option(mut self, name: String, key: String, def: String) -> Self {
|
||||
self.with_option(PrplOption {
|
||||
text: name,
|
||||
key: key,
|
||||
def: PrplOptionValue::String(def),
|
||||
masked: true,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn with_bool_option(mut self, name: String, key: String, def: bool) -> Self {
|
||||
self.with_option(PrplOption {
|
||||
text: name,
|
||||
key: key,
|
||||
def: PrplOptionValue::Bool(def),
|
||||
masked: false,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub struct PrplPluginLoader<P: PrplPlugin>(*mut purple_sys::PurplePlugin, PhantomData<P>);
|
||||
@@ -86,6 +145,18 @@ pub struct PrplInfo {
|
||||
pub homepage: String,
|
||||
}
|
||||
|
||||
enum PrplOptionValue {
|
||||
Bool(bool),
|
||||
String(String),
|
||||
}
|
||||
|
||||
struct PrplOption {
|
||||
text: String,
|
||||
key: String,
|
||||
def: PrplOptionValue,
|
||||
masked: bool,
|
||||
}
|
||||
|
||||
impl Default for PrplInfo {
|
||||
fn default() -> Self {
|
||||
PrplInfo {
|
||||
|
Reference in New Issue
Block a user