void QBtSingleDeviceSelectorUIPrivate::BTDeviceSelectedL()
{
	//Do something when BT device is selected
	//e.g. get details of the device the user selected    
  
	TBTDeviceResponseParams response = _finder->ResponseParams();  
	TBTDevAddr deviceAddress = response.BDAddr();
	TBTDeviceName deviceName = response.DeviceName();
	TBTDeviceClass deviceClass = response.DeviceClass();
	
	
	// on to qt types
	QBtAddress address (deviceAddress);
	
	// name
	QString name = QString::fromUtf16 (deviceName.Ptr(), deviceName.Length());
	
	// major device class
	QBtDevice::DeviceMajor majorClass;
	
	switch (deviceClass.MajorDeviceClass() )
	{
		case 0x00: //computer
			majorClass = QBtDevice::Miscellaneous;
			break;	     
		case 0x01:
			majorClass = QBtDevice::Computer;
			break;	
		case 0x02:
			majorClass = QBtDevice::Phone;
			break;
		case 0x03:
			majorClass = QBtDevice::LANAccess;
			break;   	
		case 0x04:
			majorClass = QBtDevice::AudioVideo;
			break;         	
		case 0x05:
			majorClass = QBtDevice::Peripheral;
			break;     
		case 0x06:
			majorClass = QBtDevice::Imaging;
			break;   
		default:
			majorClass = QBtDevice::Uncategorized;
			break;
	}
	
	// create device
	QBtDevice remoteDevice (name, address, majorClass);
	
	// if this throws, generate a leave as this is symbian code
	QT_TRYCATCH_LEAVING (emit _publicClass->discoveryCompleted (remoteDevice) );
		
}
// ---------------------------------------------------------------------------
// Check if availability of some plug-in
// ---------------------------------------------------------------------------
//
TBool CBTUIPluginMan::IsPluginAvaiable(TBTDeviceClass aDeviceClassInfo)
	{
	for( TInt i=0; i<iPluginArray.Count(); i++ )
		{
		TBTDeviceClass devClass = iPluginArray[i]->GetCOD(); 
		if( devClass.MajorDeviceClass() == aDeviceClassInfo.MajorDeviceClass() && 
			devClass.MinorDeviceClass() == aDeviceClassInfo.MinorDeviceClass() )
			return ETrue;
		}
	return EFalse;
	}
Пример #3
0
// Wraps GetLocalDeviceClass() to provide a Python method interface.
// Takes no arguments.
//
// Returns the local device class (an integer).
static PyObject* LightBlue_GetLocalDeviceClass(PyObject* self, PyObject* args) 
{
    //TDeviceData aDeviceData;
    TBTDeviceClass aDeviceClass;
    
    if (!PyArg_ParseTuple(args, ""))
        return NULL;
    
    TInt err = GetLocalDeviceClass(aDeviceClass);
    if (err) 
        return SPyErr_SetFromSymbianOSErr(err);
        
    return Py_BuildValue("i", aDeviceClass.DeviceClass());
}
// ---------------------------------------------------------------------------
// Get the setting view from PluginArrary based on the COD 
// ---------------------------------------------------------------------------
//
CAknView* CBTUIPluginMan::GetSettingViewL(TBTDevice& aDevice)
	{
	for (TInt ii = 0; ii < iPluginArray.Count(); ii++ )
		{
		TBTDeviceClass tmpCOD = iPluginArray[ii]->GetCOD();
		//Currently one device - one view - one plugin, 
		//in future maybe other device properties will decide on getting the view. 
		if(aDevice.iDeviceClass.MajorDeviceClass() == tmpCOD.MajorDeviceClass() &&
				aDevice.iDeviceClass.MinorDeviceClass() == 	tmpCOD.MinorDeviceClass())
			{
			return (CAknView*)iPluginArray[ii];
			}
		}
	
	return NULL;	
	}
Пример #5
0
// Wraps SelectDeviceUI() to provide a Python method interface. 
// Takes no arguments.
//
// Returns None if user cancelled, otherwise returns a
// (name, address, (service,major,minor)) Python tuple.
static PyObject* LightBlue_SelectDevice(PyObject* self, PyObject* args) 
{
    if (!PyArg_ParseTuple(args, ""))
        return NULL;    
    
    TBTDeviceResponseParamsPckg response;
    TInt err = SelectDeviceUI(response);
     
    if (err) {
        if (err == KErrCancel) {
            // user cancelled
            Py_INCREF(Py_None);
            return Py_None;  
        } else {
            // some other error occured
            return SPyErr_SetFromSymbianOSErr(err);
        }
    }
    if (!(response().IsValidDeviceName())) {
        PyErr_SetString(PyExc_SymbianError, "discovery returned invalid data");
        return NULL;
    }
    
    // get device address
    TBuf8<6*2+5> addrString;
    TBTDevAddr addr = response().BDAddr();
    DevAddressToString(addr, addrString);
    
    // get device class details
    TBTDeviceClass deviceClass = response().DeviceClass();
    TUint16 service = deviceClass.MajorServiceClass();
    TUint8 major = deviceClass.MajorDeviceClass();
    TUint8 minor = deviceClass.MinorDeviceClass();
    
    return Py_BuildValue("s#u#(iii)",
        addrString.Ptr(), addrString.Length(),
        response().DeviceName().Ptr(), response().DeviceName().Length(),
        service,
        major,
        minor);
}