pub fn handle_signals(manager: Arc<Mutex<Endpoint>>, stop: Arc<AtomicBool>, rori_text: Arc<Mutex<String>>, user_text: Arc<Mutex<String>>, user_logged: Arc<Mutex<bool>>) {
        // Use another dbus connection to listen signals.
        let dbus_listener = Connection::get_private(BusType::Session).unwrap();
        dbus_listener.add_match("interface=cx.ring.Ring.ConfigurationManager,member=incomingAccountMessage").unwrap();
        dbus_listener.add_match("interface=cx.ring.Ring.ConfigurationManager,member=incomingTrustRequest").unwrap();
        dbus_listener.add_match("interface=cx.ring.Ring.ConfigurationManager,member=accountsChanged").unwrap();
        dbus_listener.add_match("interface=cx.ring.Ring.ConfigurationManager,member=registrationStateChanged").unwrap();
        let rori_ring_id = manager.lock().unwrap().rori_ring_id.clone();
        // For each signals, call handlers.
        for i in dbus_listener.iter(100) {

            let mut m = manager.lock().unwrap();
            m.handle_accounts_signals(&i);
            m.handle_registration_changed(&i);
            if let Some((account_id, interaction)) = m.handle_interactions(&i) {
                info!("New interation for {}: {}", account_id, interaction);
                if account_id == m.account.id {
                    if interaction.author_ring_id == rori_ring_id && interaction.body != "" {
                        if interaction.datatype == "rori/message" {
                            match from_str(&interaction.body) {
                                Ok(j) => {
                                    // Only if rori order
                                    let j: Value = j;
                                    if j["registered"].to_string() == "true" {
                                        *user_logged.lock().unwrap() = true;
                                        m.send_interaction_to_rori("/set_types music command alarm", "rori/command");
                                        *rori_text.lock().unwrap() = String::new();
                                    }
                                },
                                _ => {
                                    warn!("Message received, but not recognized: {}", interaction.body);
                                }
                            };
                        } else if interaction.datatype == "text/plain" {
                            m.add_to_say_queue(&interaction.body);
                        } else if interaction.datatype == "music" {
                            Command::new("python3")
                                .arg("scripts/music.py")
                                .arg(&interaction.body)
                                .spawn()
                                .expect("music.py command failed to start");
                        } else if interaction.datatype == "alarm" {
                            Command::new("python3")
                                .arg("scripts/alarm.py")
                                .arg(&interaction.body)
                                .spawn()
                                .expect("alarm.py command failed to start");
                        } else if interaction.datatype == "command" {
                            Command::new("sh")
                                .arg("-c")
                                .arg(&interaction.body)
                                .spawn()
                                .expect("command failed to start");
                        }
                    }
                }
            };
            if let Some((account_id, from)) = m.handle_requests(&i) {
                if account_id == m.account.id {
                    info!("New request from {}", from);
                    // TODO
                }
            };
            let utext = user_text.lock().unwrap().clone();
            if utext != "" {
                *user_text.lock().unwrap() = String::new();

                let mut datatype = "text/plain";
                if m.is_a_command(&utext) {
                    datatype = "rori/command";
                }
                m.send_interaction_to_rori(&*utext, datatype);
            }
            if stop.load(Ordering::SeqCst) {
                break;
            }
        }
    }
/**
     * Listen from interresting signals from dbus and call handlers
     * @param self
     */
Listen from interresting signals from dbus and call handlers
@param self
Listen from interresting signals from dbus and call handlers @param self
pub fn handle_signals(manager: Arc<Mutex<Endpoint>>, stop: Arc<AtomicBool>, rori_text: Arc<Mutex<String>>, user_text: Arc<Mutex<String>>, user_logged: Arc<Mutex<bool>>) {
        // Use another dbus connection to listen signals.
        let dbus_listener = Connection::get_private(BusType::Session).unwrap();
        dbus_listener.add_match("interface=cx.ring.Ring.ConfigurationManager,member=incomingAccountMessage").unwrap();
        dbus_listener.add_match("interface=cx.ring.Ring.ConfigurationManager,member=incomingTrustRequest").unwrap();
        dbus_listener.add_match("interface=cx.ring.Ring.ConfigurationManager,member=accountsChanged").unwrap();
        dbus_listener.add_match("interface=cx.ring.Ring.ConfigurationManager,member=registrationStateChanged").unwrap();
        let rori_ring_id = manager.lock().unwrap().rori_ring_id.clone();
        // For each signals, call handlers.
        for i in dbus_listener.iter(100) {
            let mut m = manager.lock().unwrap();
            m.handle_accounts_signals(&i);
            m.handle_registration_changed(&i);
            if let Some((account_id, interaction)) = m.handle_interactions(&i) {
                info!("New interation for {}: {}", account_id, interaction);
                if account_id == m.account.id {
                    if interaction.author_ring_id == rori_ring_id && interaction.body != "" {
                        if interaction.datatype == "rori/message" {
                            match from_str(&interaction.body) {
                                Ok(j) => {
                                    // Only if rori order
                                    let j: Value = j;
                                    if j["registered"].to_string() == "true" {
                                        *user_logged.lock().unwrap() = true;
                                        m.send_interaction_to_rori("/set_types music command alarm", "rori/command");
                                        *rori_text.lock().unwrap() = String::new();
                                    }
                                },
                                _ => {
                                    warn!("Message received, but not recognized: {}", interaction.body);
                                }
                            };
                        } else if interaction.datatype == "text/plain" {
                            m.add_to_say_queue(&interaction.body);
                        } else if interaction.datatype == "music" {
                            Command::new("python3")
                                .arg("scripts/music.py")
                                .arg(&interaction.body)
                                .spawn()
                                .expect("music.py command failed to start");
                        } else if interaction.datatype == "alarm" {
                            Command::new("python3")
                                .arg("scripts/alarm.py")
                                .arg(&interaction.body)
                                .spawn()
                                .expect("alarm.py command failed to start");
                        } else if interaction.datatype == "command" {
                            Command::new("sh")
                                .arg("-c")
                                .arg(&interaction.body)
                                .spawn()
                                .expect("command failed to start");
                        }
                    }
                }
            };
            if let Some((account_id, from)) = m.handle_requests(&i) {
                if account_id == m.account.id {
                    info!("New request from {}", from);
                    // TODO
                }
            };
            let utext = user_text.lock().unwrap().clone();
            if utext != "" {
                *user_text.lock().unwrap() = String::new();
                let mut datatype = "text/plain";
                if m.is_a_command(&utext) {
                    datatype = "rori/command";
                }
                m.send_interaction_to_rori(&*utext, datatype);
            }
            if stop.load(Ordering::SeqCst) {
                break;
            }
        }
    }
pub fn handle_signals ( manager : Arc < Mutex < Endpoint > > , stop : Arc < AtomicBool > , rori_text : Arc < Mutex < String > > , user_text : Arc < Mutex < String > > , user_logged : Arc < Mutex < bool > > ) { // Use another dbus connection to listen signals. let dbus_listener = Connection :: get_private ( BusType :: Session ) . unwrap ( ) ; dbus_listener . add_match ( " " ) . unwrap ( ) ; dbus_listener . add_match ( " " ) . unwrap ( ) ; dbus_listener . add_match ( " " ) . unwrap ( ) ; dbus_listener . add_match ( " " ) . unwrap ( ) ; let rori_ring_id = manager . lock ( ) . unwrap ( ) . rori_ring_id . clone ( ) ; // For each signals, call handlers. for i in dbus_listener . iter ( 100 ) { let mut m = manager . lock ( ) . unwrap ( ) ; m . handle_accounts_signals ( & i ) ; m . handle_registration_changed ( & i ) ; if let Some ( ( account_id , interaction ) ) = m . handle_interactions ( & i ) { info ! ( " " account_id interaction ) ; if account_id == m . account . id { if interaction . author_ring_id == rori_ring_id && interaction . body != " " { if interaction . datatype == " " { match from_str ( & interaction . body ) { Ok ( j ) => { // Only if rori order let j : Value = j ; if j [ " " ] . to_string ( ) == " " { * user_logged . lock ( ) . unwrap ( ) = true ; m . send_interaction_to_rori ( " " , " " ) ; * rori_text . lock ( ) . unwrap ( ) = String :: new ( ) ; } } , _ => { warn ! ( " " interaction body ) ; } } ; } else if interaction . datatype == " " { m . add_to_say_queue ( & interaction . body ) ; } else if interaction . datatype == " " { Command :: new ( " " ) . arg ( " " ) . arg ( & interaction . body ) . spawn ( ) . expect ( " " ) ; } else if interaction . datatype == " " { Command :: new ( " " ) . arg ( " " ) . arg ( & interaction . body ) . spawn ( ) . expect ( " " ) ; } else if interaction . datatype == " " { Command :: new ( " " ) . arg ( " " ) . arg ( & interaction . body ) . spawn ( ) . expect ( " " ) ; } } } } ; if let Some ( ( account_id , from ) ) = m . handle_requests ( & i ) { if account_id == m . account . id { info ! ( " " from ) ; // TODO } } ; let utext = user_text . lock ( ) . unwrap ( ) . clone ( ) ; if utext != " " { * user_text . lock ( ) . unwrap ( ) = String :: new ( ) ; let mut datatype = " " ; if m . is_a_command ( & utext ) { datatype = " " ; } m . send_interaction_to_rori ( & * utext , datatype ) ; } if stop . load ( Ordering :: SeqCst ) { break ; } } }
Listen from interresting signals from dbus and call handlers
 @param self
Listen from interresting signals from dbus and call handlers @param self
manager
Arc<Mutex<Endpoint>>
stop
Arc<AtomicBool>
rori_text
Arc<Mutex<String>>
user_text
Arc<Mutex<String>>
user_logged
Arc<Mutex<bool>>
manager
Arc<Mutex<Endpoint>>
stop
Arc<AtomicBool>
rori_text
Arc<Mutex<String>>
user_text
Arc<Mutex<String>>
user_logged
Arc<Mutex<bool>>