Address a number of clippy complaints
This commit is contained in:
@@ -43,8 +43,8 @@ fn run() -> Result<()> {
|
||||
let mut c = LocalConnection::new_session()?;
|
||||
tree.start_receive(&c);
|
||||
|
||||
for name in vec![CM_BUS_NAME, PROTO_BUS_NAME, CM_CONN_BUS_NAME, CONN_BUS_NAME] {
|
||||
let result = c.request_name(name, false, false, true)?;
|
||||
for name in &[CM_BUS_NAME, PROTO_BUS_NAME, CM_CONN_BUS_NAME, CONN_BUS_NAME] {
|
||||
let result = c.request_name(*name, false, false, true)?;
|
||||
match result {
|
||||
RequestNameReply::Exists => {
|
||||
return Err(anyhow!("Another process is already registered on {}", name))
|
||||
|
@@ -1,6 +1,7 @@
|
||||
mod avatars;
|
||||
pub use self::avatars::*;
|
||||
|
||||
#[allow(clippy::module_inception)]
|
||||
mod connection;
|
||||
pub use self::connection::*;
|
||||
|
||||
@@ -69,7 +70,7 @@ impl Connection {
|
||||
};
|
||||
|
||||
let mut dbfile = directories::ProjectDirs::from("gs", "ur", "telepathy-padfoot")
|
||||
.ok_or(MethodErr::no_arg())
|
||||
.ok_or_else(MethodErr::no_arg)
|
||||
.and_then(|p| Ok(p.data_local_dir().to_path_buf()))?;
|
||||
|
||||
dbfile.push(&id);
|
||||
@@ -137,9 +138,9 @@ impl Connection {
|
||||
|
||||
Ok(Connection {
|
||||
id,
|
||||
msgq,
|
||||
ctx: Arc::new(RwLock::new(ctx)),
|
||||
state: Arc::new(RwLock::new(ConnState::Initial)),
|
||||
msgq: msgq.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -177,12 +178,11 @@ impl Connection {
|
||||
let requests_iface =
|
||||
telepathy::connection_interface_requests_server(&f, (), move |_| c_rc5.clone());
|
||||
|
||||
let c_rc6 = c_rc.clone();
|
||||
let simple_presence_iface =
|
||||
telepathy::connection_interface_simple_presence_server(&f, (), move |_| c_rc6.clone());
|
||||
telepathy::connection_interface_simple_presence_server(&f, (), move |_| c_rc.clone());
|
||||
|
||||
tree = tree.add(
|
||||
f.object_path(path.clone(), ())
|
||||
f.object_path(path, ())
|
||||
.introspectable()
|
||||
.add(conn_iface)
|
||||
.add(avatars_iface)
|
||||
@@ -223,18 +223,14 @@ impl Connection {
|
||||
println!("Error processing: {}", e);
|
||||
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
// Spend a bit of time sending any outgoing messages - signals, mostly
|
||||
loop {
|
||||
let msg = match msgq.lock().unwrap().pop_front() {
|
||||
Some(msg) => msg,
|
||||
None => break,
|
||||
};
|
||||
|
||||
while let Some(msg) = msgq.lock().unwrap().pop_front() {
|
||||
print!("Connection<{}>: Sending message...", id);
|
||||
|
||||
match c.send(msg) {
|
||||
Err(e) => println!("error! {:?}", e),
|
||||
Err(e) => println!("error! {:?}", e), // FIXME: handle error better?
|
||||
_ => println!("OK!"),
|
||||
}
|
||||
}
|
||||
|
@@ -11,9 +11,11 @@ impl AsRef<dyn telepathy::ConnectionInterfaceAvatars + 'static> for std::rc::Rc<
|
||||
}
|
||||
}
|
||||
|
||||
type AvatarRequirementSpec = (Vec<String>, u16, u16, u16, u16, u32);
|
||||
|
||||
// TODO: come back and do this properly, I'm just putting it in for consistency
|
||||
impl telepathy::ConnectionInterfaceAvatars for Connection {
|
||||
fn get_avatar_requirements(&self) -> Result<(Vec<String>, u16, u16, u16, u16, u32), MethodErr> {
|
||||
fn get_avatar_requirements(&self) -> Result<AvatarRequirementSpec, MethodErr> {
|
||||
println!("Connection<{}>::get_avatar_requirements()", self.id);
|
||||
Ok((vec![], 0, 0, 0, 0, 0))
|
||||
}
|
||||
|
@@ -15,6 +15,10 @@ impl AsRef<dyn telepathy::ConnectionInterfaceRequests + 'static> for std::rc::Rc
|
||||
}
|
||||
}
|
||||
|
||||
type ChannelSpec = (dbus::Path<'static>, HashMap<String, VarArg>);
|
||||
|
||||
type RequestableChannelSpec = (HashMap<String, VarArg>, Vec<String>);
|
||||
|
||||
impl telepathy::ConnectionInterfaceRequests for Connection {
|
||||
fn create_channel(
|
||||
&self,
|
||||
@@ -33,14 +37,12 @@ impl telepathy::ConnectionInterfaceRequests for Connection {
|
||||
Err(MethodErr::no_arg()) // FIXME: should be NotImplemented?
|
||||
}
|
||||
|
||||
fn channels(&self) -> Result<Vec<(dbus::Path<'static>, HashMap<String, VarArg>)>, MethodErr> {
|
||||
fn channels(&self) -> Result<Vec<ChannelSpec>, MethodErr> {
|
||||
println!("Connection<{}>::channels()", self.id);
|
||||
Ok(vec![])
|
||||
}
|
||||
|
||||
fn requestable_channel_classes(
|
||||
&self,
|
||||
) -> Result<Vec<(HashMap<String, VarArg>, Vec<String>)>, MethodErr> {
|
||||
fn requestable_channel_classes(&self) -> Result<Vec<RequestableChannelSpec>, MethodErr> {
|
||||
println!("Connection<{}>::requestable_channel_classes()", self.id);
|
||||
Ok(crate::padfoot::requestables())
|
||||
}
|
||||
|
Reference in New Issue
Block a user