bluetoothengine/btui/btuidelegate/btdelegatepair.cpp
changeset 63 bcf742120177
parent 41 0b2439c3e397
equal deleted inserted replaced
52:4545c04e61e1 63:bcf742120177
    45 {
    45 {
    46     delete mBtengConnMan;
    46     delete mBtengConnMan;
    47     delete mLoader;
    47     delete mLoader;
    48 }
    48 }
    49 
    49 
       
    50 /*!
       
    51     Returns the supported editor types.
       
    52     \return the sum of supported editor types
       
    53  */
       
    54 int BtDelegatePair::supportedEditorTypes() const
       
    55 {
       
    56     return BtDelegate::PairDevice;
       
    57 }
       
    58 
    50 void BtDelegatePair::exec( const QVariant &params )
    59 void BtDelegatePair::exec( const QVariant &params )
    51 {
    60 {
    52     
    61     
    53     deviceIndex = params.value<QModelIndex>();
    62     deviceIndex = params.value<QModelIndex>();
    54     
    63     
    58     else {
    67     else {
    59         //If Bt Power is off, switch it on and then perform pairing.
    68         //If Bt Power is off, switch it on and then perform pairing.
    60         //todo: Do we ask for user confirmation here..?
    69         //todo: Do we ask for user confirmation here..?
    61         if (!mAbstractDelegate) { 
    70         if (!mAbstractDelegate) { 
    62             mAbstractDelegate = BtDelegateFactory::newDelegate(BtDelegate::ManagePower, 
    71             mAbstractDelegate = BtDelegateFactory::newDelegate(BtDelegate::ManagePower, 
    63                     getSettingModel(), getDeviceModel() ); 
    72                     settingModel(), deviceModel() ); 
    64             connect( mAbstractDelegate, SIGNAL(commandCompleted(int)), this, SLOT(powerDelegateCompleted(int)) );
    73             connect( mAbstractDelegate, SIGNAL(delegateCompleted(int,BtAbstractDelegate*)), this, SLOT(powerDelegateCompleted(int)) );
    65             mAbstractDelegate->exec(QVariant(BtPowerOn));
    74             mAbstractDelegate->exec(QVariant(BtPowerOn));
    66         }
    75         }
    67     }
    76     }
    68     
    77     
    69 }
    78 }
    70 
    79 
    71 void BtDelegatePair::powerDelegateCompleted(int error)
    80 void BtDelegatePair::powerDelegateCompleted(int error)
    72 {
    81 {
    73     if (mAbstractDelegate) {
    82     if (mAbstractDelegate) {
    74         disconnect(mAbstractDelegate);
       
    75         delete mAbstractDelegate;
    83         delete mAbstractDelegate;
    76         mAbstractDelegate = 0;
    84         mAbstractDelegate = 0;
    77     }
    85     }
    78     if ( error == KErrNone ) {
    86     if ( error == KErrNone ) {
    79         exec_pair();
    87         exec_pair();
    85 }
    93 }
    86 
    94 
    87 void BtDelegatePair::exec_pair()
    95 void BtDelegatePair::exec_pair()
    88 {
    96 {
    89     int error = KErrNone;
    97     int error = KErrNone;
    90     mdeviceName = getDeviceModel()->data(deviceIndex,BtDeviceModel::NameAliasRole).toString();
    98     mdeviceName = deviceModel()->data(deviceIndex,BtDeviceModel::NameAliasRole).toString();
    91     
    99     
    92     QString strBtAddr = getDeviceModel()->data(deviceIndex,BtDeviceModel::ReadableBdaddrRole).toString();
   100     QString strBtAddr = deviceModel()->data(deviceIndex,BtDeviceModel::ReadableBdaddrRole).toString();
    93     int cod = getDeviceModel()->data(deviceIndex,BtDeviceModel::CoDRole).toInt();
   101     int cod = deviceModel()->data(deviceIndex,BtDeviceModel::CoDRole).toInt();
    94     
   102     
    95     if ( ! mBtengConnMan ){
   103     if ( ! mBtengConnMan ){
    96         TRAP( error, mBtengConnMan = CBTEngConnMan::NewL(this) );
   104         TRAP( error, mBtengConnMan = CBTEngConnMan::NewL(this) );
    97     }
   105     }
    98     
   106     
   164 }
   172 }
   165 
   173 
   166 void BtDelegatePair::emitCommandComplete(int error)
   174 void BtDelegatePair::emitCommandComplete(int error)
   167 {
   175 {
   168 
   176 
   169     emit commandCompleted(error);
   177     emit delegateCompleted(error, this);
   170 }
   178 }
   171 
   179 
   172 void BtDelegatePair::cancel()
   180 void BtDelegatePair::cancel()
   173 {
   181 {
   174     if ( mBtengConnMan ) {
   182     if ( mBtengConnMan ) {