--- a/bluetoothengine/btui/btuidelegate/btdelegateconnect.cpp Wed Jun 23 18:23:52 2010 +0300
+++ b/bluetoothengine/btui/btuidelegate/btdelegateconnect.cpp Tue Jul 06 14:27:09 2010 +0300
@@ -44,6 +44,10 @@
delete mBtengConnMan;
}
+/*!
+ * execute connect operation
+ * first check if power is on
+ */
void BtDelegateConnect::exec( const QVariant ¶ms )
{
if ( mActiveHandling ) {
@@ -61,9 +65,7 @@
mMajorProperty = (mIndex.data(BtDeviceModel::MajorPropertyRole)).toInt();
// first turn on power if needed
- QModelIndex powerIndex = getSettingModel()->index(BtSettingModel::PowerStateRow, 0);
- PowerStateQtValue powerState = (PowerStateQtValue)getSettingModel()->data(powerIndex, Qt::EditRole).toInt();
- if (powerState == BtPowerOff) {
+ if (!isBtPowerOn()) {
if (!mAbstractDelegate) //if there is no other delegate running
{
mAbstractDelegate = BtDelegateFactory::newDelegate(BtDelegate::ManagePower,
@@ -78,9 +80,11 @@
}
}
+/*!
+ * power delegate has completed, continue processing
+ */
void BtDelegateConnect::powerDelegateCompleted(int status)
{
- //ToDo: Error handling here
if (mAbstractDelegate)
{
disconnect(mAbstractDelegate);
@@ -97,6 +101,9 @@
}
}
+/*!
+ * execute connect operation
+ */
void BtDelegateConnect::exec_connect()
{
int error = KErrNone;
@@ -115,6 +122,9 @@
}
}
+/*!
+ * connect callback from CBTengConnMan
+ */
void BtDelegateConnect::ConnectComplete( TBTDevAddr& aAddr, TInt aErr,
RBTDevAddrArray* aConflicts )
{
@@ -125,14 +135,6 @@
return;
}
- // bteng calls ConnectComplete even if cancelConnect is called,
- // we won't signal the interested party in this case.
- // ToDo: is this needed?
- if ( aErr == KErrCancel ) {
- mActiveHandling = false;
- return;
- }
-
// conflict could occur as well if another audio device is already connected
// since currently we don't support multiple audio device connections.
if ( aErr && aConflicts && aConflicts->Count() ) {
@@ -170,6 +172,9 @@
}
}
+/*!
+ * handle user response to query about disconnecting conflict device
+ */
void BtDelegateConnect::handleUserAnswer( HbAction* answer )
{
HbMessageBox* dlg = static_cast<HbMessageBox*>( sender() );
@@ -191,15 +196,17 @@
}
}
else {
- // Cancel
+ // Cancel connect operation
emitCommandComplete(KErrCancel);
}
}
+
/*!
- * returns true if call is ongoing
+ * returns true if phone call is ongoing
*/
bool BtDelegateConnect::callOngoing()
{
+ // ToDo: check if there exists Qt PS key for ongoing call
int callState;
int err = RProperty::Get(KPSUidCtsyCallInformation, KCTsyCallState, callState);
if (!err && (callState == EPSCTsyCallStateNone || callState == EPSCTsyCallStateUninitialized)) {
@@ -209,8 +216,18 @@
return true;
}
}
+
+/*!
+ * disconnecting conflict device has completed, continue connecting
+ */
void BtDelegateConnect::disconnectDelegateCompleted(int status)
{
+ if (mAbstractDelegate)
+ {
+ disconnect(mAbstractDelegate);
+ delete mAbstractDelegate;
+ mAbstractDelegate = 0;
+ }
// finished disconnecting conflict device, now reconnect to original device
if ( status == KErrNone ) {
exec_connect();
@@ -221,13 +238,19 @@
}
}
+/*!
+ * not used here
+ */
void BtDelegateConnect::DisconnectComplete( TBTDevAddr& aAddr, TInt aErr )
{
Q_UNUSED(aAddr);
Q_UNUSED(aErr);
}
-
+/*!
+ * cancel connect operation
+ * ConnectComplete() callback will be called upon completion of cancel with KErrCancel
+ */
void BtDelegateConnect::cancel()
{
if ( mBtengConnMan ) {
@@ -235,18 +258,22 @@
}
}
+/*!
+ * shows user notes with connection success/failure information
+ * cancel operation is handled without a user note
+ */
void BtDelegateConnect::emitCommandComplete(int error)
{
if ( error == KErrNone ) {
// success, show indicator with connection status
- HbIcon icon = getBadgedDeviceTypeIcon( mCod, mMajorProperty, 0); // no badging required, only icon
+ HbIcon icon = getBadgedDeviceTypeIcon( mCod, mMajorProperty, BtuiNoCorners);
QString str(hbTrId("txt_bt_dpopinfo_connected_to_1"));
HbNotificationDialog::launchDialog( icon, hbTrId("txt_bt_dpophead_connected"),
str.arg(mDeviceName) );
}
else if ( error == KErrCancel ) {
- // no user note, return success
+ // no user note, return success since cancel operation completed successfully
error = KErrNone;
}
else {