Compare commits
7 Commits
8150d341f2
...
320201271b
Author | SHA1 | Date | |
---|---|---|---|
320201271b | |||
3807dd5ab1 | |||
8c6afe8a0a | |||
5402398c3f | |||
b33fe7b2e9 | |||
6cca0cf014 | |||
80985f25f0 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
|
/purple
|
||||||
/target
|
/target
|
||||||
|
7
Makefile
Normal file
7
Makefile
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
run:
|
||||||
|
cargo build
|
||||||
|
rm -rf purple/plugins
|
||||||
|
mkdir -p purple/plugins
|
||||||
|
ln -s ../../target/debug/libpurple_delta.so purple/plugins/libpurple_delta.so
|
||||||
|
ldd purple/plugins/libpurple_delta.so
|
||||||
|
pidgin -d -c purple
|
45
src/lib.rs
45
src/lib.rs
@@ -80,7 +80,19 @@ pub struct MsgInfo {
|
|||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct AccountData {
|
pub struct AccountData {
|
||||||
phone_number: String,
|
display_name: String,
|
||||||
|
imap_host: String,
|
||||||
|
imap_port: i32,
|
||||||
|
imap_user: String,
|
||||||
|
imap_pass: String,
|
||||||
|
smtp_host: String,
|
||||||
|
smtp_port: i32,
|
||||||
|
smtp_user: String,
|
||||||
|
smtp_pass: String,
|
||||||
|
bcc_self: bool,
|
||||||
|
|
||||||
|
// Not exposed: server_flags, selfstatus, e2ee_enabled
|
||||||
|
|
||||||
session_closed: AtomicBool,
|
session_closed: AtomicBool,
|
||||||
// session: RwLock<Option<icq::protocol::SessionInfo>>,
|
// session: RwLock<Option<icq::protocol::SessionInfo>>,
|
||||||
}
|
}
|
||||||
@@ -128,6 +140,7 @@ impl purple::PrplPlugin for PurpleDelta {
|
|||||||
|
|
||||||
context
|
context
|
||||||
.with_info(info)
|
.with_info(info)
|
||||||
|
.with_password()
|
||||||
.enable_login()
|
.enable_login()
|
||||||
.enable_load()
|
.enable_load()
|
||||||
.enable_close()
|
.enable_close()
|
||||||
@@ -148,9 +161,35 @@ impl purple::PrplPlugin for PurpleDelta {
|
|||||||
|
|
||||||
impl purple::LoginHandler for PurpleDelta {
|
impl purple::LoginHandler for PurpleDelta {
|
||||||
fn login(&mut self, account: &mut Account) {
|
fn login(&mut self, account: &mut Account) {
|
||||||
let phone_number = account.get_username().unwrap().into();
|
let display_name = account.get_string("displayname", "");
|
||||||
|
|
||||||
|
let imap_host = account.get_string("mail_server", "");
|
||||||
|
let imap_port = account.get_int("mail_port", 0);
|
||||||
|
let imap_user = account.get_username().unwrap().into();
|
||||||
|
let imap_pass = account.get_password().unwrap().into();
|
||||||
|
|
||||||
|
let smtp_host = account.get_string("send_server", "");
|
||||||
|
let smtp_port = account.get_int("send_port", 0);
|
||||||
|
let smtp_user = account.get_string("send_user", "");
|
||||||
|
let smtp_pass = account.get_string("send_pw", "");
|
||||||
|
|
||||||
|
let bcc_self = account.get_bool("bcc_self", false);
|
||||||
|
|
||||||
let protocol_data: AccountDataBox = Arc::new(AccountData {
|
let protocol_data: AccountDataBox = Arc::new(AccountData {
|
||||||
phone_number,
|
display_name,
|
||||||
|
|
||||||
|
imap_host,
|
||||||
|
imap_port,
|
||||||
|
imap_user,
|
||||||
|
imap_pass,
|
||||||
|
|
||||||
|
smtp_host,
|
||||||
|
smtp_port,
|
||||||
|
smtp_user,
|
||||||
|
smtp_pass,
|
||||||
|
|
||||||
|
bcc_self,
|
||||||
|
|
||||||
session_closed: AtomicBool::new(false),
|
session_closed: AtomicBool::new(false),
|
||||||
// session: RwLock::new(None),
|
// session: RwLock::new(None),
|
||||||
});
|
});
|
||||||
|
@@ -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 {
|
pub fn is_disconnected(&self) -> bool {
|
||||||
let is_disconnected = unsafe { purple_sys::purple_account_is_disconnected(self.0) };
|
let is_disconnected = unsafe { purple_sys::purple_account_is_disconnected(self.0) };
|
||||||
is_disconnected != 0
|
is_disconnected != 0
|
||||||
|
@@ -39,6 +39,17 @@ impl<P> RegisterContext<P> {
|
|||||||
self.info.actions = Some(entrypoints::actions);
|
self.info.actions = Some(entrypoints::actions);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn with_password(mut self) -> Self {
|
||||||
|
// 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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct PrplPluginLoader<P: PrplPlugin>(*mut purple_sys::PurplePlugin, PhantomData<P>);
|
pub struct PrplPluginLoader<P: PrplPlugin>(*mut purple_sys::PurplePlugin, PhantomData<P>);
|
||||||
|
Reference in New Issue
Block a user