bluetoothengine/btui/btuidelegate/btdelegatevisibility.cpp
changeset 40 997690c3397a
parent 33 837dcc42fd6a
child 57 5ebadcda06cb
equal deleted inserted replaced
37:91746b151f97 40:997690c3397a
    32         QObject *parent )
    32         QObject *parent )
    33     : BtAbstractDelegate( NULL, NULL, parent )
    33     : BtAbstractDelegate( NULL, NULL, parent )
    34 {
    34 {
    35     TRAP_IGNORE( mBtengSettings = CBTEngSettings::NewL(this) );
    35     TRAP_IGNORE( mBtengSettings = CBTEngSettings::NewL(this) );
    36     Q_CHECK_PTR( mBtengSettings );
    36     Q_CHECK_PTR( mBtengSettings );
    37     mOperationOngoing = false;
    37     mActiveHandling = false;
    38 }
    38 }
    39 
    39 
    40 /*!
    40 /*!
    41     Destructor.
    41     Destructor.
    42  */
    42  */
    52  */
    52  */
    53 void BtDelegateVisibility::exec( const QVariant &params )
    53 void BtDelegateVisibility::exec( const QVariant &params )
    54 {
    54 {
    55     int minutes, err = 0;
    55     int minutes, err = 0;
    56 
    56 
    57     if (mOperationOngoing) {
    57     if (mActiveHandling) {
    58         // complete command with error
    58         // complete command with error
    59         emit commandCompleted(KErrInUse);
    59         emit commandCompleted(KErrInUse);
    60         return;
    60         return;
    61     } 
    61     } 
    62     mOperationOngoing = true;
    62     mActiveHandling = true;
    63     
    63     
    64     // read 1st parameter
    64     // read 1st parameter
    65     BTUI_ASSERT_X(params.toList().at(0).isValid(), "BtDelegateVisibility::exec", "invalid parameter");
    65     BTUI_ASSERT_X(params.toList().at(0).isValid(), "BtDelegateVisibility::exec", "invalid parameter");
    66     VisibilityMode btQtMode = (VisibilityMode)params.toList().at(0).toInt();
    66     VisibilityMode btQtMode = (VisibilityMode)params.toList().at(0).toInt();
    67     mOperation = BtEngVisibilityMode(btQtMode);
    67     mOperation = BtEngVisibilityMode(btQtMode);
    68     
    68     
    69     // verify that we are setting visibility to a new value, otherwise we won't get a callback
    69     // verify that we are setting visibility to a new value, otherwise we won't get a callback
    70     TBTVisibilityMode visibilityMode( EBTVisibilityModeNoScans );
    70     TBTVisibilityMode visibilityMode( EBTVisibilityModeNoScans );
    71     err = mBtengSettings->GetVisibilityMode( visibilityMode );
    71     err = mBtengSettings->GetVisibilityMode( visibilityMode );
    72     if (err) {
    72     if (err) {
    73         mOperationOngoing = false;
    73         mActiveHandling = false;
    74         emit commandCompleted(err);
    74         emit commandCompleted(err);
    75         return;
    75         return;
    76     }
    76     }
    77     if (visibilityMode == mOperation) {
    77     if (visibilityMode == mOperation) {
    78         mOperationOngoing = false;
    78         mActiveHandling = false;
    79         emit commandCompleted(KErrNone);
    79         emit commandCompleted(KErrNone);
    80         return;
    80         return;
    81     }
    81     }
    82     
    82     
    83     switch (mOperation) {
    83     switch (mOperation) {
    98         // error
    98         // error
    99         BTUI_ASSERT_X(false, "BtDelegateVisibility::exec", "invalid parameter");
    99         BTUI_ASSERT_X(false, "BtDelegateVisibility::exec", "invalid parameter");
   100     }
   100     }
   101     if (err) {
   101     if (err) {
   102         // complete command with error
   102         // complete command with error
   103         mOperationOngoing = false;
   103         mActiveHandling = false;
   104         emit commandCompleted(err);
   104         emit commandCompleted(err);
   105     }
   105     }
   106 }
   106 }
   107 
   107 
   108 void BtDelegateVisibility::PowerStateChanged( TBTPowerStateValue aState )
   108 void BtDelegateVisibility::PowerStateChanged( TBTPowerStateValue aState )
   116  *    1) KErrUnknown if something went wrong, or
   116  *    1) KErrUnknown if something went wrong, or
   117  *    2) KErrNone if everything ok 
   117  *    2) KErrNone if everything ok 
   118  */
   118  */
   119 void BtDelegateVisibility::VisibilityModeChanged( TBTVisibilityMode aState )
   119 void BtDelegateVisibility::VisibilityModeChanged( TBTVisibilityMode aState )
   120 {
   120 {
   121     if (mOperationOngoing) {
   121     if (mActiveHandling) {
   122         //Error handling has to be done, if value is not set properly.
   122         //Error handling has to be done, if value is not set properly.
   123         mOperationOngoing = false;
   123         mActiveHandling = false;
   124         if (mOperation == aState) {
   124         if (mOperation == aState) {
   125             emit commandCompleted(KErrNone);
   125             emit commandCompleted(KErrNone);
   126         }
   126         }
   127         else {
   127         else {
   128             emit commandCompleted(KErrUnknown);
   128             emit commandCompleted(KErrUnknown);