String sid,
boolean pairing_enabled )
{
PairingManager pm = PairingManagerFactory.getSingleton();
PairedService service = pm.getService( sid );
if ( plugin_enabled && pairing_enabled && pm.isEnabled()){
setupAutoAuth();
if ( service == null ){
log( "Adding pairing service" );
service = pm.addService( sid );
PairingConnectionData cd = service.getConnectionData();
try{
updatePairing( cd );
}finally{
cd.sync();
}
}
}else{
pairing_access_code = null;
pairing_session_code = null;
if ( service != null ){
log( "Removing pairing service" );
service.remove();
}
}
}