Compare commits
5 Commits
37f652f106
...
320201271b
Author | SHA1 | Date | |
---|---|---|---|
320201271b | |||
3807dd5ab1 | |||
8c6afe8a0a | |||
5402398c3f | |||
b33fe7b2e9 |
17
src/lib.rs
17
src/lib.rs
@@ -141,23 +141,6 @@ impl purple::PrplPlugin for PurpleDelta {
|
|||||||
context
|
context
|
||||||
.with_info(info)
|
.with_info(info)
|
||||||
.with_password()
|
.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_login()
|
||||||
.enable_load()
|
.enable_load()
|
||||||
.enable_close()
|
.enable_close()
|
||||||
|
@@ -23,13 +23,6 @@ impl<P> RegisterContext<P> {
|
|||||||
pub fn into_raw(mut self) -> *mut purple_sys::PurplePluginInfo {
|
pub fn into_raw(mut self) -> *mut purple_sys::PurplePluginInfo {
|
||||||
self.extra_info.roomlist_get_list = Some(entrypoints::roomlist_get_list_handler);
|
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;
|
self.info.extra_info = Box::into_raw(self.extra_info) as *mut c_void;
|
||||||
|
|
||||||
Box::into_raw(self.info)
|
Box::into_raw(self.info)
|
||||||
@@ -51,64 +44,12 @@ impl<P> RegisterContext<P> {
|
|||||||
// purple_sys defaults extra_info.options to contain:
|
// purple_sys defaults extra_info.options to contain:
|
||||||
// OPT_PROTO_NO_PASSWORD | OPT_PROTO_IM_IMAGE | OPT_PROTO_CHAT_TOPIC
|
// OPT_PROTO_NO_PASSWORD | OPT_PROTO_IM_IMAGE | OPT_PROTO_CHAT_TOPIC
|
||||||
// All we have to do is remove the no_password one.
|
// All we have to do is remove the no_password one.
|
||||||
self.extra_info.options = purple_sys::PurpleProtocolOptions::OPT_PROTO_IM_IMAGE
|
self.extra_info.options =
|
||||||
| purple_sys::PurpleProtocolOptions::OPT_PROTO_CHAT_TOPIC;
|
purple_sys::PurpleProtocolOptions::OPT_PROTO_IM_IMAGE |
|
||||||
|
purple_sys::PurpleProtocolOptions::OPT_PROTO_CHAT_TOPIC;
|
||||||
|
|
||||||
self
|
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>);
|
pub struct PrplPluginLoader<P: PrplPlugin>(*mut purple_sys::PurplePlugin, PhantomData<P>);
|
||||||
@@ -145,18 +86,6 @@ pub struct PrplInfo {
|
|||||||
pub homepage: String,
|
pub homepage: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum PrplOptionValue {
|
|
||||||
Bool(bool),
|
|
||||||
String(String),
|
|
||||||
}
|
|
||||||
|
|
||||||
struct PrplOption {
|
|
||||||
text: String,
|
|
||||||
key: String,
|
|
||||||
def: PrplOptionValue,
|
|
||||||
masked: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for PrplInfo {
|
impl Default for PrplInfo {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
PrplInfo {
|
PrplInfo {
|
||||||
|
Reference in New Issue
Block a user