#[derive(Debug)]
pub enum InitError {
Failure,
FailureNoMessage
}
#[allow(unused_variables, unknown_lints, too_many_arguments)]
pub trait Plugin: 'static + Send {
fn new(api: &mut ::TsApi) -> Result<Box<Self>, InitError> where Self: Sized;
fn connect_status_change(&mut self, api: &mut ::TsApi, server_id: ::ServerId, status:
::ConnectStatus, error: ::Error) {}
fn server_stop(&mut self, api: &mut ::TsApi, server_id: ::ServerId, message: String) {}
fn server_error(&mut self, api: &mut ::TsApi, server_id: ::ServerId,
error: ::Error, message: String, return_code: String,
extra_message: String) -> bool { false }
fn server_edited(&mut self, api: &mut ::TsApi, server_id: ::ServerId,
invoker: Option<::Invoker>) {}
fn server_connection_info(&mut self, api: &mut ::TsApi, server_id: ::ServerId) {}
fn connection_info(&mut self, api: &mut ::TsApi, server_id: ::ServerId,
connection_id: ::ConnectionId) {}
fn connection_updated(&mut self, api: &mut ::TsApi, server_id: ::ServerId,
connection_id: ::ConnectionId, old_connection: Option<::Connection>, invoker: ::Invoker) {}
fn connection_announced(&mut self, api: &mut ::TsApi, server_id: ::ServerId,
connection_id: ::ConnectionId, appeared: bool) {}
fn connection_changed(&mut self, api: &mut ::TsApi, server_id: ::ServerId,
connection_id: ::ConnectionId, connected: bool, message: String) {}
fn connection_move(&mut self, api: &mut ::TsApi, server_id: ::ServerId,
connection_id: ::ConnectionId, old_channel_id: ::ChannelId,
new_channel_id: ::ChannelId, visibility: ::Visibility) {}
fn connection_moved(&mut self, api: &mut ::TsApi, server_id: ::ServerId,
connection_id: ::ConnectionId, old_channel_id: ::ChannelId,
new_channel_id: ::ChannelId, visibility: ::Visibility, invoker: ::Invoker) {}
fn connection_timeout(&mut self, api: &mut ::TsApi, server_id: ::ServerId,
connection_id: ::ConnectionId) {}
fn channel_announced(&mut self, api: &mut ::TsApi, server_id: ::ServerId,
channel_id: ::ChannelId) {}
fn channel_description_updated(&mut self, api: &mut ::TsApi, server_id: ::ServerId,
channel_id: ::ChannelId) {}
fn channel_updated(&mut self, api: &mut ::TsApi, server_id: ::ServerId,
channel_id: ::ChannelId, old_channel: Option<::Channel>) {}
fn channel_created(&mut self, api: &mut ::TsApi, server_id: ::ServerId,
channel_id: ::ChannelId, invoker: Option<::Invoker>) {}
fn channel_deleted(&mut self, api: &mut ::TsApi, server_id: ::ServerId,
channel_id: ::ChannelId, invoker: Option<::Invoker>) {}
fn channel_edited(&mut self, api: &mut ::TsApi, server_id: ::ServerId,
channel_id: ::ChannelId, old_channel: Option<::Channel>, invoker: ::Invoker) {}
fn channel_password_updated(&mut self, api: &mut ::TsApi, server_id: ::ServerId,
channel_id: ::ChannelId) {}
fn channel_moved(&mut self, api: &mut ::TsApi, server_id: ::ServerId,
channel_id: ::ChannelId, new_parent_channel_id: ::ChannelId,
invoker: Option<::Invoker>) {}
fn message(&mut self, api: &mut ::TsApi, server_id: ::ServerId, invoker: ::Invoker,
target: ::MessageReceiver, message: String, ignored: bool) -> bool { false }
fn poke(&mut self, api: &mut ::TsApi, server_id: ::ServerId, invoker: ::Invoker,
message: String, ignored: bool) -> bool { false }
fn channel_kick(&mut self, api: &mut ::TsApi, server_id: ::ServerId,
connection_id: ::ConnectionId, old_channel_id: ::ChannelId, new_channel_id: ::ChannelId,
visibility: ::Visibility, invoker: ::Invoker, message: String) {}
fn server_kick(&mut self, api: &mut ::TsApi, server_id: ::ServerId,
connection_id: ::ConnectionId, invoker: ::Invoker, message: String) {}
fn server_ban(&mut self, api: &mut ::TsApi, server_id: ::ServerId,
connection_id: ::ConnectionId, invoker: ::Invoker, message: String, time: u64) {}
fn talking_changed(&mut self, api: &mut ::TsApi, server_id: ::ServerId,
connection_id: ::ConnectionId, talking: ::TalkStatus, whispering: bool) {}
fn avatar_changed(&mut self, api: &mut ::TsApi, server_id: ::ServerId,
connection_id: ::ConnectionId, path: Option<String>) {}
fn connection_channel_group_changed(&mut self, api: &mut ::TsApi,
server_id: ::ServerId, connection_id: ::ConnectionId, channel_group_id: ::ChannelGroupId,
channel_id: ::ChannelId, invoker: ::Invoker) {}
fn connection_server_group_added(&mut self, api: &mut ::TsApi, server_id: ::ServerId,
connection: ::Invoker, server_group_id: ::ServerGroupId, invoker: ::Invoker) {}
fn connection_server_group_removed(&mut self, api: &mut ::TsApi, server_id: ::ServerId,
connection: ::Invoker, server_group_id: ::ServerGroupId, invoker: ::Invoker) {}
fn playback_voice_data(&mut self, api: &mut ::TsApi, server_id: ::ServerId,
connection_id: ::ConnectionId, samples: &mut [i16], channels: i32) {}
fn post_process_voice_data(&mut self, api: &mut ::TsApi, server_id: ::ServerId,
connection_id: ::ConnectionId, samples: &mut [i16], channels: i32,
channel_speaker_array: &[::Speaker], channel_fill_mask: &mut u32) {}
fn mixed_playback_voice_data(&mut self, api: &mut ::TsApi, server_id: ::ServerId,
samples: &mut [i16], channels: i32, channel_speaker_array: &[::Speaker],
channel_fill_mask: &mut u32) {}
fn captured_voice_data(&mut self, api: &mut ::TsApi, server_id: ::ServerId,
samples: &mut [i16], channels: i32, send: &mut bool) -> bool { false }
fn permission_error(&mut self, api: &mut ::TsApi, server_id: ::ServerId,
permission_id: ::PermissionId, error: ::Error, message: String,
return_code: String) -> bool { false }
fn shutdown(&mut self, api: &mut ::TsApi) {}
}
#[macro_export]
macro_rules! create_plugin {
($name: expr, $version: expr, $author: expr, $description: expr,
$configurable: expr, $autoload: expr, $typename: ident) => {
lazy_static! {
static ref PLUGIN_NAME: std::ffi::CString = std::ffi::CString::new($name).unwrap();
static ref PLUGIN_VERSION: std::ffi::CString = std::ffi::CString::new($version).unwrap();
static ref PLUGIN_AUTHOR: std::ffi::CString = std::ffi::CString::new($author).unwrap();
static ref PLUGIN_DESCRIPTION: std::ffi::CString = std::ffi::CString::new($description).unwrap();
}
#[no_mangle]
#[doc(hidden)]
pub unsafe extern "C" fn ts3plugin_init() -> std::os::raw::c_int {
match $crate::ts3interface::private_init::<$typename>() {
Ok(_) => 0,
Err($crate::InitError::Failure) => 1,
Err($crate::InitError::FailureNoMessage) => -2,
}
}
#[no_mangle]
#[doc(hidden)]
pub extern "C" fn ts3plugin_name() -> *const std::os::raw::c_char {
(*PLUGIN_NAME).as_ptr()
}
#[no_mangle]
#[doc(hidden)]
pub extern "C" fn ts3plugin_version() -> *const std::os::raw::c_char {
(*PLUGIN_VERSION).as_ptr()
}
#[no_mangle]
#[doc(hidden)]
pub extern "C" fn ts3plugin_author() -> *const std::os::raw::c_char {
(*PLUGIN_AUTHOR).as_ptr()
}
#[no_mangle]
#[doc(hidden)]
pub extern "C" fn ts3plugin_description() -> *const std::os::raw::c_char {
(*PLUGIN_DESCRIPTION).as_ptr()
}
#[allow(non_snake_case)]
#[no_mangle]
#[doc(hidden)]
pub extern "C" fn ts3plugin_offersConfigure() -> std::os::raw::c_int {
$configurable as std::os::raw::c_int
}
#[allow(non_snake_case)]
#[no_mangle]
#[doc(hidden)]
pub extern "C" fn ts3plugin_requestAutoload() -> std::os::raw::c_int {
if $autoload {
1
} else {
0
}
}
};
}