examples/ForumNokia/BluetoothPMPExample/src/BluetoothPMPExampleEngine.cpp

00001 /*
00002  * Copyright © 2009 Nokia Corporation.
00003  */
00004 
00005 // INCLUDE FILES
00006 #include <aknquerydialog.h> // for input dialogs
00007 #include <utf.h>
00008 #include "Common.h"
00009 #include "BluetoothPMPExampleEngine.h"
00010 #include "DeviceDiscoverer.h"
00011 #include "ServiceAdvertiser.h"
00012 #include "ServiceDiscoverer.h"
00013 #include "Listener.h"
00014 #include "Connector.h"
00015 #include <BtPmpEx.rsg>
00016 
00017 CBluetoothPMPExampleEngine* CBluetoothPMPExampleEngine::NewL(
00018     CBluetoothPMPExampleAppUi& aAppUi)
00019     {
00020     CBluetoothPMPExampleEngine* self =
00021         CBluetoothPMPExampleEngine::NewLC(aAppUi);
00022     CleanupStack::Pop(self);
00023     return self;
00024     }
00025 
00026 
00027 CBluetoothPMPExampleEngine* CBluetoothPMPExampleEngine::NewLC(
00028     CBluetoothPMPExampleAppUi& aAppUi)
00029     {
00030     CBluetoothPMPExampleEngine* self =
00031         new (ELeave) CBluetoothPMPExampleEngine(aAppUi);
00032     CleanupStack::PushL(self);
00033     self->ConstructL();
00034     return self;
00035     }
00036 
00037 
00038 // Standard EPOC 2nd phase constructor
00039 void CBluetoothPMPExampleEngine::ConstructL()
00040     {
00041     // get socket server session
00042     User::LeaveIfError(iSocketServ.Connect());
00043 
00044     // init listener
00045     iListener = CListener::NewL(*this, iSocketServ);
00046     // init device discoverer
00047     iDeviceDiscoverer = CDeviceDiscoverer::NewL(iSocketServ, *this);
00048 
00049 #ifdef ENABLE_LIAC
00050     // Set default LIAC to OFF
00051     iLIAC = ETrue;
00052     // set current LIAC state
00053     iDeviceDiscoverer->SetLIAC( iLIAC );
00054 #endif
00055     // init service advertiser
00056     iServiceAdvertiser = CServiceAdvertiser::NewL();
00057     // init service discoverer
00058     iServiceDiscoverer = CServiceDiscoverer::NewL(*this);
00059 
00060     // clean connections table to begin with
00061     for ( TInt idx=0; idx<KMaxConnectedDevices; idx++ )
00062         {
00063         iConnectedDevices[idx] = NULL;
00064         }
00065     
00066     #ifdef ENABLE_LIAC
00067     // The key to control whether the local device is in Limited Discoverable 
00068     // mode The P&S value will contain a boolean: ETrue if in limited discoverable mode,
00069     // otherwise EFalse
00070     TInt attErr = iProperty.Define(KPropertyUidBluetoothControlCategory, 
00071             KPropertyKeyBluetoothSetLimitedDiscoverableStatus,RProperty::EInt);
00072     if (attErr != KErrNone && attErr != KErrAlreadyExists)
00073         {
00074         User::Leave(attErr);
00075         }
00076     
00077     
00078     // Set LIAC value
00079     SetLIAC(iLIAC);
00080     #endif
00081     }
00082 
00083 
00084 // ----------------------------------------------------------------------------
00085 // CBluetoothPMPExampleEngine::CBluetoothPMPExampleEngine(
00086 //     CBluetoothPMPExampleAppUi* aAppUi)
00087 //
00088 // constructor
00089 // ----------------------------------------------------------------------------
00090 CBluetoothPMPExampleEngine::CBluetoothPMPExampleEngine(
00091     CBluetoothPMPExampleAppUi& aAppUi):
00092     iIsSlave(EFalse),
00093     iAppUi(aAppUi)
00094     {
00095     //Nothing to do
00096     }
00097 
00098 // ----------------------------------------------------------------------------
00099 // CBluetoothPMPExampleEngine::~CBluetoothPMPExampleEngine()
00100 //
00101 // destructor
00102 // ----------------------------------------------------------------------------
00103 CBluetoothPMPExampleEngine::~CBluetoothPMPExampleEngine()
00104     {
00105     #ifdef ENABLE_LIAC
00106     SetLIAC(EFalse);
00107     iProperty.Close();
00108     #endif
00109 
00110     // disconnect all devices and clean up connections table
00111     DisconnectDevices();
00112     // stop and kill helpers
00113 
00114     delete iServiceAdvertiser;
00115     iServiceAdvertiser=NULL;
00116 
00117     delete iListener;
00118     iListener=NULL;
00119     
00120     iDeviceDiscoverer->Cancel();
00121     delete iDeviceDiscoverer;
00122     iDeviceDiscoverer = NULL;
00123 
00124     delete iServiceDiscoverer;
00125     iServiceDiscoverer=NULL;
00126 
00127     iSocketServ.Close();
00128 
00129     // wipe device data list
00130     iDevDataList.ResetAndDestroy();
00131     }
00132 
00133 
00134 
00135 // ----------------------------------------------------------------------------
00136 // ShowMessageL(
00137 //     const TDesC& aMsg, TBool aDrawLine=EFalse)
00138 //
00139 // displays text referenced by aMsg in the label, will append the aMsg in the
00140 // existing text
00141 // ----------------------------------------------------------------------------
00142 void CBluetoothPMPExampleEngine::ShowMessageL(const TDesC& aMsg,
00143                                               TBool aDrawLine=EFalse)
00144     {
00145     if (iAppUi.Container())
00146         {
00147         if( aDrawLine )
00148             iAppUi.Container()->DrawLineL();
00149         
00150         iAppUi.Container()->ShowMessageL(aMsg);
00151         }
00152     }
00153 
00154 
00155 
00156 // ----------------------------------------------------------------------------
00157 // CBluetoothPMPExampleEngine::DiscoverDevicesL()
00158 //
00159 // discover bluetooth devices within range.
00160 // ----------------------------------------------------------------------------
00161 void CBluetoothPMPExampleEngine::DiscoverDevicesL()
00162     {
00163     //timing:
00164     iStartTime.HomeTime();
00165     ShowMessageL(KDiscDevicesTxt, ETrue);
00166     TRAPD(err,iDeviceDiscoverer->DiscoverDevicesL(&iDevDataList));
00167     if (err)
00168         {
00169         HandleDeviceDiscoveryComplete(err);
00170         }
00171     }
00172 
00173 
00174 // ----------------------------------------------------------------------------
00175 // CBluetoothPMPExampleEngine::DiscoverServicesL()
00176 //
00177 // discover services provided by the discovered devices.
00178 // ----------------------------------------------------------------------------
00179 void CBluetoothPMPExampleEngine::DiscoverServicesL()
00180     {
00181     iStartTime.HomeTime();
00182     ShowMessageL(KDiscServicesTxt, ETrue);
00183     iServiceDiscoverer->DiscoverServicesL(&iDevDataList);
00184     }
00185 
00186 
00187 // ----------------------------------------------------------------------------
00188 // CBluetoothPMPExampleEngine::StartSlaveL()
00189 //
00190 // set application in slave mode.  the device will be set to listen to
00191 // a bluetooth channel, and advertise its service on the channel.
00192 // ----------------------------------------------------------------------------
00193 void CBluetoothPMPExampleEngine::StartSlaveL()
00194     {
00195     if ( iIsSlave )
00196         return;
00197 
00198     ShowMessageL(KSlaveInitTxt, ETrue);
00199 
00200     TInt channel;
00201     iListener->StartListenerL(channel);
00202     TBuf<KThirty> msg;
00203     msg.AppendFormat(KListeningTxt, channel);
00204     ShowMessageL(msg, EFalse);
00205 
00206     iServiceAdvertiser->StartAdvertiserL(channel);
00207     ShowMessageL(KSlaveInitCompTxt, EFalse);
00208     iIsSlave=ETrue;
00209     }
00210 
00211 // ----------------------------------------------------------------------------
00212 // CBluetoothPMPExampleEngine::StopSlaveL()
00213 //
00214 // Stop slave mode
00215 // 
00216 // ----------------------------------------------------------------------------
00217 void CBluetoothPMPExampleEngine::StopSlaveL()
00218     {
00219     if ( !iIsSlave )
00220         return;
00221 
00222     ShowMessageL(KNullDesC, ETrue);
00223 
00224     iListener->StopListener();
00225     iServiceAdvertiser->StopAdvertiserL();
00226     iIsSlave=EFalse;
00227     }
00228 
00229 
00230 // ----------------------------------------------------------------------------
00231 // CBluetoothPMPExampleEngine::DisconnectDevices()
00232 //
00233 // disconnect connected devices and clean up connections table
00234 // ----------------------------------------------------------------------------
00235 void CBluetoothPMPExampleEngine::DisconnectDevices()
00236     {
00237     for ( TInt idx=0; idx<KMaxConnectedDevices; idx++ )
00238         {
00239         if ( iConnectedDevices[idx] )
00240             {
00241             delete iConnectedDevices[idx];
00242             iConnectedDevices[idx]=NULL;
00243             }
00244         }
00245     ShowMessageL(KDisconnDevicesTxt, ETrue);
00246     iIsMaster = EFalse;
00247     }
00248 
00249 
00250 // ----------------------------------------------------------------------------
00251 // CBluetoothPMPExampleEngine::ConnectDevicesL()
00252 //
00253 // attempt to connect on all discovered devices (up to 7)
00254 // ----------------------------------------------------------------------------
00255 void CBluetoothPMPExampleEngine::ConnectDevicesL()
00256      {
00257      // close and delete all existing connections
00258      DisconnectDevices();
00259 
00260      iIsMaster = ETrue;
00261      ShowMessageL(KConnectingTxt, ETrue);
00262      // now attempt to connect
00263      for ( TInt idx=0; idx<(iDevDataList.Count()); idx++ )
00264          {
00265          if ( iConnectedDeviceCount>=KMaxConnectedDevices )
00266              return;
00267 
00268          TDeviceData *dev = iDevDataList[idx];
00269 
00270          // if matching service on remote device was found, the service port
00271          // is set and will be > 0.  if so, we can attempt to connect.
00272          if ( dev->iDeviceServicePort>0 )
00273              {
00274              CConnector* connector = CConnector::NewLC(*this, iSocketServ);
00275              if ( (connector->ConnectL(dev->iDeviceName,
00276                                        dev->iDeviceAddr,
00277                                        dev->iDeviceServicePort))==KErrNone )
00278                  {
00279                  iConnectedDevices[iConnectedDeviceCount] = connector;
00280                  iConnectedDeviceCount++;
00281                  CleanupStack::Pop(connector);
00282                  }
00283              else
00284                  {
00285                  // connection to device failed!!
00286                  CleanupStack::PopAndDestroy();
00287                  }
00288              }
00289          }
00290 
00291      ShowConnectedDevicesL();
00292      }
00293 
00294 // ----------------------------------------------------------------------------
00295 // CBluetoothPMPExampleEngine::ShowConnectedDevicesL()
00296 //
00297 // display the devices we are connected to
00298 // ----------------------------------------------------------------------------
00299 void CBluetoothPMPExampleEngine::ShowConnectedDevicesL()
00300     {
00301     TInt count=0;
00302     ShowMessageL(KConnDevicesTxt, ETrue);
00303     for (TInt idx=0; idx<KMaxConnectedDevices; idx++)
00304         {
00305         if ( iConnectedDevices[idx] )
00306             {
00307             THostName name;
00308             name = iConnectedDevices[idx]->iName;
00309             name.Append(KNewLine);
00310             ShowMessageL(name, EFalse);
00311             count++;
00312             }
00313         }
00314     if ( count==0 )
00315         {
00316         // no connections!
00317         // this may be because of no devices has been discovered,
00318         // or no devices are offering the requested service.
00319         ShowMessageL(KNoConns, EFalse);
00320         }
00321     }
00322 
00323 
00324 // ----------------------------------------------------------------------------
00325 // CBluetoothPMPExampleEngine::SendMessageL()
00326 //
00327 // send a message to all connected devices.  user will be prompted to enter
00328 // the message text.
00329 // ----------------------------------------------------------------------------
00330 void CBluetoothPMPExampleEngine::SendMessageL()
00331     {
00332     iMsgtext.Zero();
00333     CAknTextQueryDialog* dlg = CAknTextQueryDialog::NewL(iMsgtext);
00334     if(!dlg->ExecuteLD(R_BLUETOOTHEXAMPLE_MESSAGEINPUT))
00335         {
00336         // Cancel
00337         return;
00338         }
00339     
00340     // explicitly convert from 16bit to 8bit character set
00341     CnvUtfConverter::ConvertFromUnicodeToUtf8(iMsgtext8, iMsgtext);
00342 
00343     TBuf<KEighty> msg;
00344     if ( iIsSlave )
00345         {
00346         // slave sending data
00347         iListener->SendData(iMsgtext8);
00348         msg.Format(KFormatStr3, &iMsgtext);
00349         ShowMessageL(msg, EFalse);
00350         }
00351     else
00352         {
00353         // master sending data
00354         for (TInt idx=0; idx<KMaxConnectedDevices; idx++)
00355             {
00356             if ( iConnectedDevices[idx])
00357                 {
00358                 iConnectedDevices[idx]->SendData(iMsgtext8);
00359                 THostName name;
00360                 name=iConnectedDevices[idx]->iName;
00361                 msg.Format(KFormatStr2, &name, &iMsgtext);
00362                 ShowMessageL(msg, EFalse);
00363                 }
00364             }
00365         }
00366     }
00367 
00368 
00369 // ----------------------------------------------------------------------------
00370 // CBluetoothPMPExampleEngine::HandleListenerDataReceivedL(TDesC& aData)
00371 //
00372 // display data the slave listener receives from the master.  this is a
00373 // callback that CListener class will invoke when it receives new data.
00374 // ----------------------------------------------------------------------------
00375 void CBluetoothPMPExampleEngine::HandleListenerDataReceivedL(const TDesC& aData)
00376     {
00377     // display received message
00378     TBuf<KEighty> msg;
00379     msg.Format(KFormatStr1, &aData);
00380     ShowMessageL(msg, EFalse);
00381     }
00382 
00383 
00384 // ----------------------------------------------------------------------------
00385 // CBluetoothPMPExampleEngine::HandleListenerConnectedL()
00386 //
00387 // a callback received from CListener to indicate that it has been connected to
00388 // ----------------------------------------------------------------------------
00389 void CBluetoothPMPExampleEngine::HandleListenerConnectedL()
00390     {
00391     ShowMessageL(KConnMsg, ETrue);
00392     }
00393 
00394 
00395 // ----------------------------------------------------------------------------
00396 // CBluetoothPMPExampleEngine::HandleListenerDisconnectedL()
00397 //
00398 // a callback received from CListener to indicate that it has been disconnected
00399 // ----------------------------------------------------------------------------
00400 void CBluetoothPMPExampleEngine::HandleListenerDisconnectedL()
00401     {
00402     if ( !iIsSlave )
00403         return;
00404 
00405     // Stop listener and advertiser
00406     // Set app to init mode
00407     StopSlaveL();
00408     ShowMessageL(KDisconMsg, ETrue);
00409     }
00410 
00411 
00412 // ----------------------------------------------------------------------------
00413 // CBluetoothPMPExampleEngine::HandleConnectorDataReceivedL(THostName aName,
00414 //                                                          TDesC& aData)
00415 //
00416 // display data the master receives from a connected slave.  this is a
00417 // callback that CConnector class will invoke when it receives data from slave.
00418 // Also echo the message to other slaves.
00419 // ----------------------------------------------------------------------------
00420 void CBluetoothPMPExampleEngine::HandleConnectorDataReceivedL(THostName aName,
00421                                                               const TDesC& aData)
00422     {
00423     // display received message
00424     TBuf<KEighty> msg;
00425     msg.Format(KFormatStr, &aName, &aData);
00426     ShowMessageL(msg, EFalse);
00427 
00428     // echo the message to other slaves
00429     _LIT8(KSeparator, ":");
00430 
00431     TBuf8<KEighty> buf; //should use HBufC so the size will be big enough
00432     TPtr8 msgtext8((TUint8*)buf.Ptr(), aData.Size()+KSeparator().Length() + aName.Size());
00433     CnvUtfConverter::ConvertFromUnicodeToUtf8(msgtext8, aData);
00434 
00435     //convert name to UTF8 so other slaves see
00436     //the sender name
00437     TBuf8<KEighty> bufName;
00438     TPtr8 name8((TUint8*)bufName.Ptr(), aName.Size());
00439     CnvUtfConverter::ConvertFromUnicodeToUtf8(name8, aName);
00440 
00441     //add the separator and name in the beginning;
00442     msgtext8.Insert(0, KSeparator );
00443     msgtext8.Insert(0, name8);
00444 
00445     for (TInt idx=0; idx<KMaxConnectedDevices; idx++)
00446         {
00447         if ( iConnectedDevices[idx])
00448             {
00449             THostName name;
00450             name=iConnectedDevices[idx]->iName;
00451 
00452             //echo to other slaves than the sender
00453             if( name.Compare(aName) != 0)
00454                 iConnectedDevices[idx]->SendData(msgtext8);
00455             }
00456         }
00457     }
00458 
00459 // ----------------------------------------------------------------------------
00460 // CBluetoothPMPExampleEngine::HandleConnectorErrorL(THostName aName,TInt aError)
00461 //
00462 // ----------------------------------------------------------------------------
00463 void CBluetoothPMPExampleEngine::HandleConnectorErrorL(THostName aName, TInt aError)
00464     {
00465     if (aError)
00466         {
00467         // display received message
00468         TBuf<KEighty> msg;
00469         msg.Format(KDeviceDisconMsg, &aName);
00470         ShowMessageL(msg, EFalse);
00471 
00472         for (TInt idx=0; idx<KMaxConnectedDevices; idx++)
00473             {
00474             if ( iConnectedDevices[idx])
00475                 {
00476                 THostName name;
00477                 name=iConnectedDevices[idx]->iName;
00478 
00479                 //echo to other slaves than the sender
00480                 if( name.Compare(aName) == 0)
00481                     {
00482                     delete iConnectedDevices[idx];
00483                     iConnectedDevices[idx] = NULL;
00484                     }
00485                 }
00486             }
00487 
00488         // Is there more connection running?
00489         iIsMaster = EFalse;
00490         for (TInt idx=0; idx<KMaxConnectedDevices; idx++)
00491             {
00492             if ( iConnectedDevices[idx])
00493                 {
00494                 iIsMaster = ETrue;
00495                 break;
00496                 }
00497             }
00498         }
00499     }
00500 
00501 // ----------------------------------------------------------------------------
00502 // CBluetoothPMPExampleEngine::HandleDeviceDiscoveryComplete()
00503 //
00504 // a callback received from device discoverer to indicate that the device
00505 // discovery has completed.
00506 // ----------------------------------------------------------------------------
00507 void CBluetoothPMPExampleEngine::HandleDeviceDiscoveryComplete(TInt aError)
00508     {
00509     if (aError)
00510         {
00511         iIsMaster = EFalse;
00512         }
00513     else
00514         {
00515         iIsMaster = ETrue;
00516         }
00517     
00518     iEndTime.HomeTime();
00519 
00520     TTimeIntervalSeconds seconds;
00521     iEndTime.SecondsFrom(iStartTime, seconds);
00522 
00523     TInt time = seconds.Int();
00524     TBuf<KTwelve> temp = KTimeTxt();
00525     temp.AppendNum(time);
00526     temp.Append(KSecTxt);
00527     TRAPD(err,ShowMessageL(temp,EFalse));
00528 
00529     // iterate and display found devices, if any
00530     if ( iDevDataList.Count()> 0 )
00531         {
00532         TBuf<KTwenty> count = KFoundTxt();
00533         count.AppendNum( iDevDataList.Count() );
00534         count.Append( KDevices );
00535         TRAP(err,ShowMessageL(count));
00536         }
00537     else
00538         {
00539         // no devices found
00540         TRAP(err,ShowMessageL(KNoDevFound, EFalse));
00541         }
00542     }
00543 
00544 // ----------------------------------------------------------------------------
00545 // CBluetoothPMPExampleEngine::HandleServiceDiscoveryCompleteL()
00546 //
00547 // a callback received from service discoverer to indicate that the service
00548 // discovery has completed.
00549 // ----------------------------------------------------------------------------
00550 void CBluetoothPMPExampleEngine::HandleServiceDiscoveryCompleteL()
00551     {
00552     iEndTime.HomeTime();
00553 
00554     TTimeIntervalSeconds seconds;
00555     iEndTime.SecondsFrom(iStartTime, seconds);
00556 
00557     TInt time = seconds.Int();
00558     TBuf<KTwelve> temp = KTimeTxt();
00559     temp.AppendNum(time);
00560     temp.Append(KSecTxt);
00561     ShowMessageL(temp,ETrue);
00562 
00563     TInt count=0;
00564     // display devices with service we can use
00565     for ( TInt idx=0; idx<(iDevDataList.Count()); idx++ )
00566         {
00567         TDeviceData *dev = iDevDataList[idx];
00568         if ( dev->iDeviceServicePort>0 )
00569             {
00570             THostName name = dev->iDeviceName;
00571             name.Append(KNewLine);
00572             ShowMessageL(name, EFalse);
00573             count++;
00574             }
00575         }
00576     if ( count==0 )
00577         {
00578         ShowMessageL(KNoServiceFound, EFalse);
00579         }
00580     else
00581         {
00582         ShowMessageL(KServiceFound, EFalse);
00583         }
00584     }
00585 
00586 
00587 // ----------------------------------------------------------------------------
00588 // CBluetoothPMPExampleEngine::HasConnections()
00589 //
00590 // returns true if master has any connections to slave(s)
00591 // ----------------------------------------------------------------------------
00592 TBool CBluetoothPMPExampleEngine::HasConnections()
00593     {
00594     TBool exists = EFalse;
00595     for (TInt idx=0; idx<KMaxConnectedDevices; idx++)
00596         {
00597         if ( iConnectedDevices[idx])
00598             {
00599             exists = ETrue;
00600             break;
00601             }
00602         }
00603     return exists;
00604     }
00605 
00606 
00607 // ----------------------------------------------------------------------------
00608 // CBluetoothPMPExampleEngine::DeviceDiscovered
00609 // ----------------------------------------------------------------------------
00610 //a callback to indicate that a device has been found
00611 //main reason for this is that the UI can react so user
00612 //knows that something is going on and the app is not "frozen"
00613 void CBluetoothPMPExampleEngine::DeviceDiscovered(const TDeviceData &aDevice)
00614     {
00615     TBuf<KForty> name = aDevice.iDeviceName;
00616     name.Trim();
00617 
00618     if( name.Length() == 0 )
00619         name.Append(KDeviceWithNoName);
00620 
00621     TRAPD(err,ShowMessageL(name, EFalse));
00622     }
00623 
00624 // ----------------------------------------------------------------------------
00625 // CBluetoothPMPExampleEngine::ReportServiceDiscoveryErrorL
00626 // ----------------------------------------------------------------------------
00627 void CBluetoothPMPExampleEngine::ReportServiceDiscoveryErrorL(TInt aError)
00628     {
00629     TBuf<KThirty> discError = KServiceDiscoveryError();
00630     discError.AppendNum(aError);
00631     iAppUi.Container()->ShowMessageL(discError);
00632     }
00633 
00634 // ----------------------------------------------------------------------------
00635 // CBluetoothPMPExampleEngine::TurnBtOnL
00636 // ----------------------------------------------------------------------------
00637 //Uses the Notifier API to ask the user to turn on Bluetooth
00638 //if it's not on already.
00639 void CBluetoothPMPExampleEngine::TurnBtOnL()
00640     {
00641     //the constant is from btnotifierapi.h which is not in all SDKs
00642     //so it's hard coded here
00643     const TUid KPowerModeSettingNotifierUid = {0x100059E2};
00644     //const TUid KBTPowerStateNotifierUid = {0x101F808E}; //S80 and 7710
00645     
00646     RNotifier notifier;
00647     User::LeaveIfError( notifier.Connect() );
00648     TPckgBuf<TBool> dummy(ETrue);
00649     TPckgBuf<TBool> reply(EFalse);
00650     TRequestStatus stat;
00651     notifier.StartNotifierAndGetResponse(stat, KPowerModeSettingNotifierUid, dummy, reply);
00652     User::WaitForRequest(stat);
00653     notifier.CancelNotifier(KPowerModeSettingNotifierUid);
00654     notifier.Close();
00655     }
00656 
00657 #ifdef ENABLE_LIAC
00658 // ----------------------------------------------------------------------------
00659 // CBluetoothPMPExampleEngine::SetLIAC
00660 // ----------------------------------------------------------------------------
00661 void CBluetoothPMPExampleEngine::SetLIAC( TBool aState )
00662     {
00663     TInt err = KErrNone;
00664 
00665     // Set LIAC for the system    
00666     err = iProperty.Set(KPropertyUidBluetoothControlCategory,
00667             KPropertyKeyBluetoothSetLimitedDiscoverableStatus, 
00668             aState);
00669     
00670     TBuf<KEighty> myMessage;
00671 
00672     myMessage.Zero();
00673 
00674     if ( KErrNone == err )
00675         {
00676         if ( aState )
00677             {
00678             myMessage.Append( KLIACOn );
00679             }
00680         else
00681             {
00682             myMessage.Append( KLIACOff );
00683             }        
00684         iLIAC = aState;
00685 
00686         iDeviceDiscoverer->SetLIAC( iLIAC );
00687 
00688         }
00689     else
00690         {
00691         myMessage.AppendFormat( KLIACError, err );
00692         }
00693 
00694     TRAP( err, ShowMessageL( myMessage, ETrue ));
00695     }
00696 
00697 // ----------------------------------------------------------------------------
00698 // CBluetoothPMPExampleEngine::LIAC
00699 // ----------------------------------------------------------------------------
00700 TBool CBluetoothPMPExampleEngine::LIAC()
00701     {
00702     return iLIAC;
00703     }
00704 #endif
00705 
00706 // ----------------------------------------------------------------------------
00707 // CBluetoothPMPExampleEngine::IsDiscoveryActive
00708 // ----------------------------------------------------------------------------
00709 TBool CBluetoothPMPExampleEngine::IsDiscoveryActive()
00710     {
00711     return iDeviceDiscoverer->IsActive();
00712     }
00713 
00714 // ----------------------------------------------------------------------------
00715 // CBluetoothPMPExampleEngine::StopDiscovery
00716 // ----------------------------------------------------------------------------
00717 void CBluetoothPMPExampleEngine::StopDiscovery()
00718     {
00719     if ( IsDiscoveryActive() )
00720         {
00721         iDeviceDiscoverer->StopDiscovery();
00722         } 
00723     iIsMaster = EFalse;
00724     }

Generated by  doxygen 1.6.2