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 |