code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  WAP
  QBtConstants

  WAP_CLIENT
  QBtConstants

  Wearable
  QBtDevice

  WSP
  QBtConstants

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  QBluetoothZero.h

  QBtAddress.h

  QBtAuxFunctions.h

  QBtConstants.h

  QBtDevice.h

  QBtDeviceDiscoverer.h

  QBtGlobal.h

  QBtLocalDevice.h

  QBtObjectExchangeClient.h

  QBtObjectExchangeServer.h

  QBtRemoteFileInfo.h

  QBtSerialPortClient.h

  QBtSerialPortServer.h

  QBtService.h

  QBtServiceAdvertiser.h

  QBtServiceDiscoverer.h

  QBtServiceDiscovererForAll.h

  QBtSingleDeviceSelectorUI.h

  QBtTypes.h

  QBtUuid.h

Searching...

No Matches

repo_name: snapshot/qbluetooth

license: unknown


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  _Assert_Msg
  QBtAuxFunctions.h

  _Assert_Msg2
  QBtAuxFunctions.h

  _Break_Here

    _Break_Here(const QString &file, int line): QBtAuxFunctions.h
    _Break_Here(const QString &file, const QString &line): QBtAuxFunctions.h

  _Debug_Msg
  QBtAuxFunctions.h

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  abort
  QBtObjectExchangeClient

  addNewDevice
  QBtLocalDevice

  addNewService
  QBtDevice

  addProtocol
  QBtService

  advertisingStarted
  QBtServiceAdvertiser

  advertisingStopped
  QBtServiceAdvertiser

  askUserTurnOnBtPower
  QBtLocalDevice

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  batchFileRetrieval
  QBtObjectExchangeClient

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  clear
  QBtUuid

  clientAbortedTransmittion
  QBtObjectExchangeServer

  clientConnected
  QBtSerialPortServer

  clientDisconnected
  QBtSerialPortServer

  connect
  QBtSerialPortClient

  connectedToServer

    QBtObjectExchangeClient::connectedToServer()
    QBtSerialPortClient::connectedToServer()

  connectionResetByPeer
  QBtSerialPortClient

  connectToServer
  QBtObjectExchangeClient

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  dataReceived

    QBtObjectExchangeClient::dataReceived()
    QBtSerialPortClient::dataReceived()
    QBtSerialPortClient::dataReceived()
    QBtSerialPortServer::dataReceived()

  dataSent

    QBtSerialPortClient::dataSent()
    QBtSerialPortServer::dataSent()

  deleteDevice

    QBtLocalDevice::deleteDevice(const QBtDevice &device)
    QBtLocalDevice::deleteDevice(const QBtAddress &address)

  deviceDiscoveryError
  QBtServiceDiscovererForAll

  disconnect

    QBtObjectExchangeClient::disconnect()
    QBtSerialPortClient::disconnect()

  disconnectedFromServer

    QBtObjectExchangeClient::disconnectedFromServer()
    QBtSerialPortClient::disconnectedFromServer()

  discoveryCompleted
  QBtSingleDeviceSelectorUI

  discoveryEnded
  QBtServiceDiscovererForAll

  discoveryStarted

    QBtDeviceDiscoverer::discoveryStarted()
    QBtServiceDiscoverer::discoveryStarted()
    QBtServiceDiscovererForAll::discoveryStarted()
    QBtSingleDeviceSelectorUI::discoveryStarted()

  discoveryStopped

    QBtDeviceDiscoverer::discoveryStopped()
    QBtServiceDiscoverer::discoveryStopped()

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  emitDummySignalTest
  QBtDeviceDiscoverer

  error

    QBtDeviceDiscoverer::error()
    QBtObjectExchangeClient::error()
    QBtObjectExchangeServer::error()
    QBtSerialPortClient::error()
    QBtSerialPortServer::error()
    QBtServiceAdvertiser::error()
    QBtServiceDiscoverer::error()

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  fileReceived
  QBtObjectExchangeClient

  folderBrowsingResultElement
  QBtObjectExchangeClient

  foundDevices
  QBtServiceDiscovererForAll

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  get

    QBtUuid::get() const
    QBtUuid::get(uint &highWord1, uint &highWord2, uint &lowWord1, uint &lowWord2) const

  getAddress
  QBtDevice

  getAddressFromReversedArray
  QBtAddress

  getBluetoothPowerState
  QBtLocalDevice

  getByteBuffer
  QBtObjectExchangeClient

  getClass
  QBtService

  getDescription
  QBtService

  getDeviceClass
  QBtLocalDevice

  getDeviceList
  QBtServiceDiscovererForAll

  getFile
  QBtObjectExchangeClient

  getHandle
  QBtService

  getInquiredDevices
  QBtDeviceDiscoverer

  getInquiredServices
  QBtServiceDiscoverer

  getLocalDeviceAddress
  QBtLocalDevice

  getLocalDeviceName
  QBtLocalDevice

  getName

    QBtDevice::getName()
    QBtService::getName()

  getNumberOfFoundDevices
  QBtServiceDiscovererForAll

  getPort
  QBtService

  getProtocols
  QBtService

  getServerDevice
  QBtObjectExchangeClient

  getSupportedServices
  QBtDevice

  getTargetDevice
  QBtServiceDiscoverer

  getTransmittingService
  QBtObjectExchangeClient

  getTransmittingServiceInfo

    QBtObjectExchangeServer::getTransmittingServiceInfo()
    QBtSerialPortServer::getTransmittingServiceInfo()

  getType
  QBtDevice

  getTypeAsString
  QBtDevice

  getWorkingPath
  QBtObjectExchangeClient

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  initiateFolderBrowsing
  QBtObjectExchangeClient

  isBluetoothSupported
  QBtLocalDevice

  isBusy

    QBtDeviceDiscoverer::isBusy()
    QBtObjectExchangeClient::isBusy()
    QBtServiceDiscoverer::isBusy()
    QBtServiceDiscovererForAll::isBusy()

  isConnected

    QBtObjectExchangeClient::isConnected()
    QBtObjectExchangeServer::isConnected()
    QBtSerialPortClient::isConnected()
    QBtSerialPortServer::isConnected()

  isFull
  QBtUuid

  isNull
  QBtUuid

  isValid
  QBtAddress

  isVisible
  QBtLocalDevice

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  locateFiles
  QBtObjectExchangeClient

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  name
  QBtDevice

  nameChanged
  QBtDevice

  newDeviceFound

    QBtDeviceDiscoverer::newDeviceFound()
    QBtServiceDiscovererForAll::newDeviceFound()

  newServiceFound
  QBtServiceDiscoverer

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  objectSent
  QBtObjectExchangeClient

  operator!=

    QBtAddress::operator!=()
    QBtUuid::operator!=()

  operator<
  QBtAddress

  operator=

    QBtAddress::operator=()
    QBtDevice::operator=()
    QBtRemoteFileInfo::operator=()
    QBtService::operator=()
    QBtUuid::operator=()

  operator==

    QBtAddress::operator==()
    QBtUuid::operator==()

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  putByteBuffer
  QBtObjectExchangeClient

  putFile
  QBtObjectExchangeClient

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  QBtAddress

    QBtAddress::QBtAddress()
    QBtAddress::QBtAddress(const QBtAddress &other)
    QBtAddress::QBtAddress(const QByteArray &byteArray)
    QBtAddress::QBtAddress(const QString &addr)

  QBtDevice

    QBtDevice::QBtDevice(QObject *parent=0)
    QBtDevice::QBtDevice(const QBtDevice &dev, QObject *parent=0)
    QBtDevice::QBtDevice(const QString &devName, const QBtAddress &devAddress, DeviceMajor devType, QObject *parent=0)

  QBtDeviceDiscoverer
  QBtDeviceDiscoverer

  QBtObjectExchangeClient
  QBtObjectExchangeClient

  QBtObjectExchangeServer
  QBtObjectExchangeServer

  QBtRemoteFileInfo

    QBtRemoteFileInfo::QBtRemoteFileInfo(QObject *parent=0)
    QBtRemoteFileInfo::QBtRemoteFileInfo(const QBtRemoteFileInfo &fileInfo)

  QBtSerialPortClient
  QBtSerialPortClient

  QBtSerialPortServer
  QBtSerialPortServer

  QBtService

    QBtService::QBtService(QObject *parent=0)
    QBtService::QBtService(const QBtService &service, QObject *parent=0)

  QBtServiceAdvertiser
  QBtServiceAdvertiser

  QBtServiceDiscoverer
  QBtServiceDiscoverer

  QBtServiceDiscovererForAll
  QBtServiceDiscovererForAll

  QBtSingleDeviceSelectorUI
  QBtSingleDeviceSelectorUI

  QBtUuid

    QBtUuid::QBtUuid(QObject *parent=NULL)
    QBtUuid::QBtUuid(const QString &uuid)
    QBtUuid::QBtUuid(uint uuid)
    QBtUuid::QBtUuid(const QBtUuid &uuid)

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  receivingObjectInfo
  QBtObjectExchangeServer

  receivingStarted
  QBtObjectExchangeServer

  receivingStopped
  QBtObjectExchangeServer

  remotePathSet
  QBtObjectExchangeClient

  removeProtocol
  QBtService

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  SafeDelete
  QBtAuxFunctions.h

  sendData

    QBtSerialPortClient::sendData(const QString &data)
    QBtSerialPortClient::sendData(const QByteArray &data)
    QBtSerialPortServer::sendData()

  serverStarted

    QBtObjectExchangeServer::serverStarted()
    QBtSerialPortServer::serverStarted()

  serverStopped

    QBtObjectExchangeServer::serverStopped()
    QBtSerialPortServer::serverStopped()

  serviceDiscoveyError
  QBtServiceDiscovererForAll

  serviceListUpdated
  QBtDevice

  set

    QBtUuid::set(uint uuid)
    QBtUuid::set(const QString &uuid)

  setAddress
  QBtDevice

  setBluetoothPowerState
  QBtLocalDevice

  setClass
  QBtService

  setConnectionStatus
  QBtSerialPortServer

  setDescription
  QBtService

  setDeviceClass
  QBtLocalDevice

  setHandle
  QBtService

  setLocalDeviceName
  QBtLocalDevice

  setName

    QBtDevice::setName()
    QBtService::setName()

  setPath
  QBtObjectExchangeClient

  setPort
  QBtService

  setProtocols
  QBtService

  setSupportedServices
  QBtDevice

  setTransmittingService

    QBtObjectExchangeServer::setTransmittingService()
    QBtSerialPortServer::setTransmittingService()

  setType
  QBtDevice

  setVisible
  QBtLocalDevice

  show
  QBtSingleDeviceSelectorUI

  startAdvertising
  QBtServiceAdvertiser

  startAdvertisingService

    QBtObjectExchangeServer::startAdvertisingService()
    QBtSerialPortServer::startAdvertisingService()

  startDiscovery

    QBtDeviceDiscoverer::startDiscovery()
    QBtServiceDiscoverer::startDiscovery(const QBtDevice &targetDevice)
    QBtServiceDiscoverer::startDiscovery(const QBtDevice &targetDevice, const QBtUuid &uuid)
    QBtServiceDiscoverer::startDiscovery(const QBtDevice &targetDevice, const QList< QBtUuid > &uuids)
    QBtServiceDiscovererForAll::startDiscovery()
    QBtServiceDiscovererForAll::startDiscovery(const QBtUuid &uuid)
    QBtServiceDiscovererForAll::startDiscovery(const QList< QBtUuid > &uuids)

  startObexDiscovery

    QBtServiceDiscoverer::startObexDiscovery()
    QBtServiceDiscovererForAll::startObexDiscovery()

  startRfcommDiscovery

    QBtServiceDiscoverer::startRfcommDiscovery()
    QBtServiceDiscovererForAll::startRfcommDiscovery()

  startServer

    QBtObjectExchangeServer::startServer()
    QBtSerialPortServer::startServer()

  stopAdvertising
  QBtServiceAdvertiser

  stopAdvertisingService

    QBtObjectExchangeServer::stopAdvertisingService()
    QBtSerialPortServer::stopAdvertisingService()

  stopDiscovery

    QBtDeviceDiscoverer::stopDiscovery()
    QBtServiceDiscoverer::stopDiscovery()
    QBtServiceDiscovererForAll::stopDiscovery()

  stopServer

    QBtObjectExchangeServer::stopServer()
    QBtSerialPortServer::stopServer()

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  toByteArray
  QBtAddress

  toReversedByteArray
  QBtAddress

  toString

    QBtAddress::toString()
    QBtRemoteFileInfo::toString()
    QBtUuid::toString()

  transmittingObjectInfo
  QBtObjectExchangeServer

  transmittingRejected
  QBtObjectExchangeServer

  transmittingStarted
  QBtObjectExchangeServer

  transmittingStopped
  QBtObjectExchangeServer

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  unpairDevice

    QBtLocalDevice::unpairDevice(const QBtDevice &device)
    QBtLocalDevice::unpairDevice(const QBtAddress &address)

  updateAvailability
  QBtServiceAdvertiser

  userCanceled
  QBtSingleDeviceSelectorUI

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  ~QBtAddress
  QBtAddress

  ~QBtDevice
  QBtDevice

  ~QBtDeviceDiscoverer
  QBtDeviceDiscoverer

  ~QBtObjectExchangeClient
  QBtObjectExchangeClient

  ~QBtObjectExchangeServer
  QBtObjectExchangeServer

  ~QBtSerialPortClient
  QBtSerialPortClient

  ~QBtSerialPortServer
  QBtSerialPortServer

  ~QBtServiceAdvertiser
  QBtServiceAdvertiser

  ~QBtServiceDiscoverer
  QBtServiceDiscoverer

  ~QBtServiceDiscovererForAll
  QBtServiceDiscovererForAll

  ~QBtSingleDeviceSelectorUI
  QBtSingleDeviceSelectorUI

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  QBluetooth

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  _address
  QBtAddress

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  address
  QBtDevice

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  name
  QBtDevice

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  type
  QBtDevice

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  QBtDeviceDiscovererPrivate
  QBtDeviceDiscoverer

  QBtObjectExchangeClientPrivate
  QBtObjectExchangeClient

  QBtObjectExchangeServerPrivate
  QBtObjectExchangeServer

  QBtSerialPortClientPrivate
  QBtSerialPortClient

  QBtSerialPortServerPrivate
  QBtSerialPortServer

  QBtServiceAdvertiserPrivate
  QBtServiceAdvertiser

  QBtServiceDiscovererPrivate
  QBtServiceDiscoverer

  QBtSingleDeviceSelectorUIPrivate
  QBtSingleDeviceSelectorUI

Searching...

No Matches


code:
/*---------------- Search Box */

#FSearchBox {
    float: left;
}

#MSearchBox {
    white-space : nowrap;
    position: absolute;
    float: none;
    display: inline;
    margin-top: 8px;
    right: 0px;
    width: 170px;
    z-index: 102;
}

#MSearchBox .left
{
    display:block;
    position:absolute;
    left:10px;
    width:20px;
    height:19px;
    background:url('search_l.png') no-repeat;
    background-position:right;
}

#MSearchSelect {
    display:block;
    position:absolute;
    width:20px;
    height:19px;
}

.left #MSearchSelect {
    left:4px;
}

.right #MSearchSelect {
    right:5px;
}

#MSearchField {
    display:block;
    position:absolute;
    height:19px;
    background:url('search_m.png') repeat-x;
    border:none;
    width:116px;
    margin-left:20px;
    padding-left:4px;
    color: #909090;
    outline: none;
    font: 9pt Arial, Verdana, sans-serif;
}

#FSearchBox #MSearchField {
    margin-left:15px;
}

#MSearchBox .right {
    display:block;
    position:absolute;
    right:10px;
    top:0px;
    width:20px;
    height:19px;
    background:url('search_r.png') no-repeat;
    background-position:left;
}

#MSearchClose {
    display: none;
    position: absolute;
    top: 4px;
    background : none;
    border: none;
    margin: 0px 4px 0px 0px;
    padding: 0px 0px;
    outline: none;
}

.left #MSearchClose {
    left: 6px;
}

.right #MSearchClose {
    right: 2px;
}

.MSearchBoxActive #MSearchField {
    color: #000000;
}

/*---------------- Search filter selection */

#MSearchSelectWindow {
    display: none;
    position: absolute;
    left: 0; top: 0;
    border: 1px solid #90A5CE;
    background-color: #F9FAFC;
    z-index: 1;
    padding-top: 4px;
    padding-bottom: 4px;
    -moz-border-radius: 4px;
    -webkit-border-top-left-radius: 4px;
    -webkit-border-top-right-radius: 4px;
    -webkit-border-bottom-left-radius: 4px;
    -webkit-border-bottom-right-radius: 4px;
    -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15);
}

.SelectItem {
    font: 8pt Arial, Verdana, sans-serif;
    padding-left:  2px;
    padding-right: 12px;
    border: 0px;
}

span.SelectionMark {
    margin-right: 4px;
    font-family: monospace;
    outline-style: none;
    text-decoration: none;
}

a.SelectItem {
    display: block;
    outline-style: none;
    color: #000000;
    text-decoration: none;
    padding-left:   6px;
    padding-right: 12px;
}

a.SelectItem:focus,
a.SelectItem:active {
    color: #000000;
    outline-style: none;
    text-decoration: none;
}

a.SelectItem:hover {
    color: #FFFFFF;
    background-color: #3D578C;
    outline-style: none;
    text-decoration: none;
    cursor: pointer;
    display: block;
}

/*---------------- Search results window */

iframe#MSearchResults {
    width: 60ex;
    height: 15em;
}

#MSearchResultsWindow {
    display: none;
    position: absolute;
    left: 0; top: 0;
    border: 1px solid #000;
    background-color: #EEF1F7;
}

/* ----------------------------------- */

#SRIndex {
    clear:both;
    padding-bottom: 15px;
}

.SREntry {
    font-size: 10pt;
    padding-left: 1ex;
}

.SRPage .SREntry {
    font-size: 8pt;
    padding: 1px 5px;
}

body.SRPage {
    margin: 5px 2px;
}

.SRChildren {
    padding-left: 3ex; padding-bottom: .5em
}

.SRPage .SRChildren {
    display: none;
}

.SRSymbol {
    font-weight: bold;
    color: #425E97;
    font-family: Arial, Verdana, sans-serif;
    text-decoration: none;
    outline: none;
}

a.SRScope {
    display: block;
    color: #425E97;
    font-family: Arial, Verdana, sans-serif;
    text-decoration: none;
    outline: none;
}

a.SRSymbol:focus, a.SRSymbol:active,
a.SRScope:focus, a.SRScope:active {
    text-decoration: underline;
}

.SRPage .SRStatus {
    padding: 2px 5px;
    font-size: 8pt;
    font-style: italic;
}

.SRResult {
    display: none;
}

DIV.searchresults {
    margin-left: 10px;
    margin-right: 10px;
}


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  List

    QBtDevice::List()
    QBtService::List()

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  ProtocolList
  QBtService

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  absolutePath
  QBtRemoteFileInfo

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  creationTime
  QBtRemoteFileInfo

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  fileName
  QBtRemoteFileInfo

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  isDir
  QBtRemoteFileInfo

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  lastAccessTime
  QBtRemoteFileInfo

  lastWriteTime
  QBtRemoteFileInfo

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  path
  QBtRemoteFileInfo

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  size
  QBtRemoteFileInfo

Searching...

No Matches


code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

  type
  QBtRemoteFileInfo

Searching...

No Matches


code:
.tabs, .tabs2, .tabs3 {
    background-image: url('tab_b.png');
    width: 100%;
    z-index: 101;
    font-size: 13px;
}

.tabs2 {
    font-size: 10px;
}
.tabs3 {
    font-size: 9px;
}

.tablist {
    margin: 0;
    padding: 0;
    display: table;
}

.tablist li {
    float: left;
    display: table-cell;
    background-image: url('tab_b.png');
    line-height: 36px;
    list-style: none;
}

.tablist a {
    display: block;
    padding: 0 20px;
    font-weight: bold;
    background-image:url('tab_s.png');
    background-repeat:no-repeat;
    background-position:right;
    color: #283A5D;
    text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9);
    text-decoration: none;
    outline: none;
}

.tabs3 .tablist a {
    padding: 0 10px;
}

.tablist a:hover {
    background-image: url('tab_h.png');
    background-repeat:repeat-x;
    color: #fff;
    text-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0);
    text-decoration: none;
}

.tablist li.current a {
    background-image: url('tab_a.png');
    background-repeat:repeat-x;
    color: #fff;
    text-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0);
}


code:
/*
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "../QBtAddress.h"
#include <QRegExp>

QBT_NAMESPACE_BEGIN

#define BT_INVALID_ADDRESS "00:00:00:00:00:00"

QBtAddress::QBtAddress()
: QObject(),
  _address(BT_INVALID_ADDRESS),
  _valid(false)
{
}

QBtAddress::QBtAddress (const QBtAddress& other)
{
	_valid = other.isValid();
	_address = other.toString();
}

QBtAddress::QBtAddress (const QString& addr)
 : QObject(),
   _address(BT_INVALID_ADDRESS),
   _valid(false)
{
	QRegExp rx("^[0-9a-fA-F]{2,2}:[0-9a-fA-F]{2,2}:[0-9a-fA-F]{2,2}:[0-9a-fA-F]{2,2}:[0-9a-fA-F]{2,2}:[0-9a-fA-F]{2,2}$");
	_valid = addr.contains( rx );
	if (_valid)
		_address = addr.toLower();
}

QBtAddress::QBtAddress (const QByteArray& byteArray)
: QObject(),
  _address(BT_INVALID_ADDRESS),
  _valid(false)
{
	if (byteArray.size() != 6)
		return;

	QString btAddr = "";
	char tmpChar[32];

	for (int i = 0; i < 5; i++){
		sprintf(tmpChar,"%02X:", ((unsigned char)byteArray[i]));
		btAddr += tmpChar;
	}
	sprintf(tmpChar,"%02X", ((unsigned char)byteArray[5]));
	btAddr += tmpChar;

	QRegExp rx("^[0-9a-fA-F]{2,2}:[0-9a-fA-F]{2,2}:[0-9a-fA-F]{2,2}:[0-9a-fA-F]{2,2}:[0-9a-fA-F]{2,2}:[0-9a-fA-F]{2,2}$");
	_valid = btAddr.contains( rx );
	if (_valid)
		_address = btAddr.toLower();
}

#ifdef Q_OS_SYMBIAN
QBtAddress::QBtAddress (const TBTDevAddr& addr)
{
	QBtAddress tmpAddr (QByteArray((const char*)addr.Des().Ptr(), 6));
	*this = tmpAddr;
}
#endif

QBtAddress& QBtAddress::getAddressFromReversedArray (const QByteArray & reversedArray)
{
	unsigned char tmpByte;
	int size = reversedArray.size();

	QByteArray bArray (reversedArray);

	for(int i=0; i<size/2; i++)
	{
		tmpByte = bArray [i];
		bArray [i] = bArray [size-i-1];
		bArray [size-i-1] = tmpByte;
	}

	return *(new QBtAddress(bArray));
}

QBtAddress::~QBtAddress ()
{
}

bool QBtAddress::isValid () const
{
	return _valid;
}

QString QBtAddress::toString() const
{
	return _address;
}

// Converts the _address string into a byte array of size 6.
// Every 2 characters from the string represent an 8bit number,
// the characters (excluding ':') are 12, so 6 8bit numbers are
// created and returned through QByteArray
//
QByteArray QBtAddress::toByteArray() const
{
	if(!_valid)
		return QByteArray();

	QString btAddressCopy = _address;
	btAddressCopy.remove(QChar(':'));

	QByteArray resultArray;
	resultArray.append(btAddressCopy.toAscii());
	resultArray = QByteArray::fromHex(resultArray);

	return resultArray;
}

// Converts the _address string into a byte array as toByteArray
// function but reversed. This function is supported for
// convenience on windows support (and specialy Bluesoleil SDK
// where _address byte array is expected in this reversed way)
//
QByteArray QBtAddress::toReversedByteArray() const
{
	if(!_valid)
			return NULL;

	QByteArray revArray = this->toByteArray();

	int arraySize = revArray.size();
	char tmpChar;
	for(int i=0; i<arraySize/2; i++)
	{
		tmpChar = revArray[i];
		revArray[i] = revArray[arraySize-i-1];
		revArray[arraySize-i-1] = tmpChar;
	}

	return revArray;
}

bool QBtAddress::operator!= (const QBtAddress & other )
{
  int result = _address.compare(other.toString(),Qt::CaseInsensitive);

  return ((result == 0) ? false : true);
}

QBtAddress& QBtAddress::operator= ( const QBtAddress & other )
{
	if(this != &other)
	{
		_valid = other.isValid();
		_address = other.toString();
	}
	return *this;
}

bool QBtAddress::operator== (const QBtAddress & other )
{
	return !(*this!=other);
}

bool QBtAddress::operator< (const QBtAddress & other )
{
	return (this->toString() < other.toString());
}

#ifdef Q_OS_SYMBIAN
TBTDevAddr QBtAddress::convertToSymbianBtDevAddr() const
{
	const TUint8* memPtr = (const TUint8*)toByteArray().constData();

	TPtrC8 devAddrPtr8;
	devAddrPtr8.Set(memPtr, 6);

	const TBTDevAddr devAddress = TBTDevAddr(devAddrPtr8);

	return devAddress;
}
#endif

QBT_NAMESPACE_END


code:
/*
 * QBtDevice.cpp
 *
 *
 *      Author: Ftylitakis Nikolaos
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "../QBtDevice.h"

QBT_NAMESPACE_BEGIN

QBtDevice::QBtDevice(QObject* parent) : QObject(parent),
	_name("Undefined"), _address(), _type(Uncategorized), _serviceListUpdated (false)
{
	_supportedServices.clear();
}

QBtDevice::QBtDevice(const QBtDevice& dev, QObject* parent) : QObject(parent),
	 _name(dev.getName()), _address(dev.getAddress()), _type(dev.getType()), _serviceListUpdated (dev._serviceListUpdated)
{
	QBtService::List* servList = new QBtService::List();
	*servList = dev.getSupportedServices();

	_supportedServices.clear();
	_supportedServices = *servList;
}

QBtDevice::QBtDevice (const QString & devName, const QBtAddress & devAddress, DeviceMajor devType, QObject* parent)
: QObject(parent), _name(devName), _address(devAddress), _type(devType)
{
	_supportedServices.clear();
}

QBtDevice::~QBtDevice()
{

}

void QBtDevice::addNewService (const QBtService& newService)
{
	_supportedServices.append(newService);
}

void QBtDevice::setName (const QString & newName)
{
	_name = newName;
	emit nameChanged(_name);
}

void QBtDevice::setAddress (const QBtAddress& newAddress)
{
	_address = newAddress;
}

void QBtDevice::setType(DeviceMajor newType)
{
	_type = newType;
}

void QBtDevice::setSupportedServices (const QBtService::List& newSupportedServices)
{
	_serviceListUpdated = true;

	_supportedServices.clear();
	_supportedServices = newSupportedServices;
}

bool QBtDevice::serviceListUpdated() const
{
	return _serviceListUpdated;
}

QString QBtDevice::getName() const
{
	return _name;
}

const QBtAddress& QBtDevice::getAddress() const
{
	return _address;
}

QBtDevice::DeviceMajor QBtDevice::getType() const
{
	return _type;
}

QString QBtDevice::getTypeAsString() const
{
	switch(_type)
	{
		case (QBtDevice::Miscellaneous):
			return "Miscellaneous";
		case (QBtDevice::Computer):
			return "Computer";
		case (QBtDevice::Phone):
			return "Phone";
		case (QBtDevice::LANAccess):
			return "LANAccess";
		case (QBtDevice::AudioVideo):
			return "AudioVideo";
		case (QBtDevice::Peripheral):
			return "Peripheral";
		case (QBtDevice::Imaging):
			return "Imaging";
		default:
			return "Uncategorized";
	}
}

const QBtService::List & QBtDevice::getSupportedServices() const
{
	return _supportedServices;
}

QBtDevice& QBtDevice::operator= (const QBtDevice& dev)
{
	if ( this == &dev )
		return *this;

	QBtAddress* addr = new QBtAddress(dev.getAddress());
	QBtService::List* servList = new QBtService::List();
	*servList = dev.getSupportedServices();

	setName(dev.getName());
	setAddress(*addr);
	setType(dev.getType());
	setSupportedServices(*servList);

	return *this;
}

//////////////////////////////////////////////////////////////////////////

QString QBtDevice::name() const
{
	return _name;
}

QBT_NAMESPACE_END


code:
#include <QBtRemoteFileInfo.h>

QBT_NAMESPACE_BEGIN

QBtRemoteFileInfo::QBtRemoteFileInfo(QObject* parent) : QObject(parent){}

QBtRemoteFileInfo::QBtRemoteFileInfo(const QBtRemoteFileInfo& fileInfo) : QObject(fileInfo.parent())
{
	operator=(fileInfo);
}

QString QBtRemoteFileInfo::toString()
{
	return absolutePath;
}

QBtRemoteFileInfo& QBtRemoteFileInfo::operator=(const QBtRemoteFileInfo& fileInfo)
{
	fileName = fileInfo.fileName;
	path = fileInfo.path;
	isDir = fileInfo.isDir;
	type = fileInfo.type;
	size = fileInfo.size;
	creationTime = fileInfo.creationTime;
	lastAccessTime = fileInfo.lastAccessTime;
	lastWriteTime = fileInfo.lastWriteTime;

#if defined(Q_OS_WIN32)
	absolutePath = path + "\\" + fileName;
#else
	absolutePath = path + "/" + fileName;
#endif

	return *this;
}

QBT_NAMESPACE_END


code:
/*
 * QBtService.cpp
 *
 *
 *      Author: Ftylitakis Nikolaos
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "../QBtService.h"

QBT_NAMESPACE_BEGIN

//____________________________________________________________________________

QBtService::QBtService(QObject* parent)
   : QObject(parent),
	 _name ("Undefined"),
     _description ("Undefined"),
     _handle(0),
     _port(0)
{
    _protocolList.clear();
}

QBtService::QBtService(const QBtService& service, QObject* parent) : QObject(parent)
{
	_serviceUuid = service.getClass();
	_protocolList = service.getProtocols();
	_name = service.getName();
	_description = service.getDescription();
	_handle = service.getHandle();
    _port = service.getPort();
}

//____________________________________________________________________________

QBtService::ProtocolList QBtService::getProtocols() const
{
    return _protocolList;
}

//____________________________________________________________________________

QBtUuid QBtService::getClass() const
{
    return _serviceUuid;
}

//____________________________________________________________________________

QString QBtService::getName() const
{
    return _name;
}

//____________________________________________________________________________

QString QBtService::getDescription() const
{
    return _description;
}

//____________________________________________________________________________

uint QBtService::getPort() const
{
    return _port;
}

//____________________________________________________________________________

uint QBtService::getHandle() const
{
    return _handle;
}

//____________________________________________________________________________

void QBtService::setClass (const QBtUuid & newClass)
{
    _serviceUuid = newClass;
}

//____________________________________________________________________________

void QBtService::setName(const QString& newName)
{
    _name = newName;
}

//____________________________________________________________________________

void QBtService::setDescription(const QString& newDescription)
{
    _description = newDescription;
}

//____________________________________________________________________________

void QBtService::setPort (uint newPort)
{
    _port = newPort;
}

//____________________________________________________________________________

void QBtService::setHandle(uint newHandle)
{
    _handle = newHandle;
}

//____________________________________________________________________________

void QBtService::setProtocols(const QBtService::ProtocolList & newUuids)
{
    _protocolList = newUuids;
}

//____________________________________________________________________________

void QBtService::addProtocol(const QBtUuid & uuid)
{
    if (_protocolList.indexOf (uuid) == -1) // if not on list
        _protocolList.append (uuid);
}

//____________________________________________________________________________
//
// Returns false if uuid not found in the protocol list

bool QBtService::removeProtocol (const QBtUuid & uuid)
{
    return _protocolList.removeOne(uuid);
}

QBtService& QBtService::operator=(const QBtService& service)
{
	if(this != &service)
	{
		_serviceUuid = service.getClass();
		_protocolList = service.getProtocols();
		_name = service.getName();
		_description = service.getDescription();
		_handle = service.getHandle();
        _port = service.getPort();
	}
	return *this;
}

QBT_NAMESPACE_END


code:
/*
 * QBtService.cpp
 *
 *
 *      Author: Ftylitakis Nikolaos
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "../QBtUuid.h"
#include "../../QBtAuxFunctions.h"

#include <QStringList>

QBT_NAMESPACE_BEGIN

//____________________________________________________________________________
//
// Valid formats:
// XXXX
// XXXXXXXX
// XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
//
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX (TODO)

inline bool IsValidUuid (const QString & uuid)
{
   bool ok;

   switch (uuid.length() )
   {
      case 4:
      case 8:
      {
         uuid.toUInt (&ok, 16);
         return ok;
      }
      case 36:
      {

         // split
         QStringList list = uuid.split("-");

         if (list.length() != 5)
            return false;

         // check size
         if (list [0].length() != 8 ||
             list [1].length() != 4 ||
             list [2].length() != 4 ||
             list [3].length() != 4 ||
             list [4].length() != 12)
             return false;

         // check each part
         for (int i = 0; i < 5; ++i)
         {
            list[i].toUInt (&ok, 16);

            if (ok != true)
               return false;
         }

         // ok now
         return true;

      }

      case 32:
      {
         // split in four and check
         QStringList s;
         s.append(uuid.mid(0, 8));
         s.append(uuid.mid(8, 4));
         s.append(uuid.mid(16, 4));
         s.append(uuid.mid(24, 4));

         // check each part
         bool ok;
         for (int i = 0; i < s.length(); ++i)
         {
            s[i].toUInt (&ok, 16);

            if (ok != true)
               return false;
         }

         return true;

      } break;

      default:
         return false;
   }

}

//____________________________________________________________________________

inline QString UintToString (uint uuid)
{
   if (uuid <= 0xFFFF)
      return QString ("%1").arg (uuid, 4, 16, QLatin1Char('0') );
    else
      return QString ("%1").arg (uuid, 8, 16, QLatin1Char('0') );
}

//____________________________________________________________________________

QBtUuid::QBtUuid(QObject* parent) : QObject(parent)
{
   _uuid.clear();
}

//____________________________________________________________________________
//
// uuid assumed as hexadecimal
//

QBtUuid::QBtUuid (uint uuid) : QObject()
{
   set (uuid);
}

//____________________________________________________________________________
//
// uuid assumed to be in the following formats:
// XXXX
// XXXXXXXX
// XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
//

QBtUuid::QBtUuid (const QString & uuid) : QObject()
{
   set (uuid);
}

QBtUuid::QBtUuid(const QBtUuid& uuid) : QObject()
{
	set(uuid.get());
}

//____________________________________________________________________________
//
// uuid assumed to be in hexadecimal, 16 or 32 bit.
//

void QBtUuid::set (uint uuid)
{
   set (UintToString(uuid) );
}

//____________________________________________________________________________
//
// Assumed to be short or full uuid.
//

void QBtUuid::set (const QString & value)
{
  // upper
  QString up = value.toUpper();

  // split
  QStringList list = up.split("-");

  // join all
  _uuid = list.join("");

  // checks
  BT_ASSERT_MSG2(IsValidUuid(_uuid), "invalid uuid", _uuid);
}

//____________________________________________________________________________
//
// If short uuid, returns the equivalent uint. If full uuid, returns 0.
//

uint QBtUuid::get() const
{
   if (isFull() )
      return 0;

   bool ok;
   return _uuid.toUInt (&ok, 16);
}

//____________________________________________________________________________
//
// If this is a full uuid, splits it four 32-bit values. If this is a short
// uuid, all values are set to zero.
//

void QBtUuid::get (uint & highWord1, uint & highWord2, uint & lowWord1, uint & lowWord2) const
{
  // split
   QStringList list = _uuid.split("-");

   // join all
   QString s = list.join("");

   // separate parts
   QString s1 = s.mid (0, 8);
   QString s2 = s.mid (8, 8);
   QString s3 = s.mid (16, 8);
   QString s4 = s.mid (24, 8);

   // convert
   bool ok;

   highWord1 = s1.toUInt(&ok, 16);
   highWord2 = s2.toUInt(&ok, 16);
   lowWord1  = s3.toUInt(&ok, 16);
   lowWord2  = s4.toUInt(&ok, 16);

}

//____________________________________________________________________________
//
// Returns the string representation
//

QString QBtUuid::toString () const
{
  return _uuid;
}

//____________________________________________________________________________
//
// Checks if this is the full uuid
//

bool QBtUuid::isFull() const
{
   return _uuid.length() == 32;
}

//____________________________________________________________________________
//
//

bool QBtUuid::isNull () const
{
   return _uuid.length() == 0;
}

//____________________________________________________________________________

void QBtUuid::clear()
{
   _uuid.clear();
}

//____________________________________________________________________________

bool QBtUuid::operator == (const QBtUuid & obj) const
{
   return _uuid == obj._uuid;

}

//____________________________________________________________________________

bool QBtUuid::operator != (const QBtUuid & obj) const
{
   return _uuid != obj._uuid;
}

QBtUuid& QBtUuid::operator=(class QBtUuid const &uuid)
{
	if(this != &uuid)
	{
		_uuid = uuid.toString();
	}
	return *this;
}

QBT_NAMESPACE_END


code:
/*
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef QBTADDRESS_H
#define QBTADDRESS_H

#include <QtCore/QString.h>
#include <QtCore/QByteArray.h>
#include <QBtGlobal.h>

#ifdef Q_OS_SYMBIAN
#include <bttypes.h>
#endif

QBT_NAMESPACE_BEGIN

/**
 * Class that represents the device's bluetooth _address.
 * It is one of the main fields of QBtDevice.
 */
class DLL_EXPORT QBtAddress : public QObject
{
	Q_OBJECT
	Q_PROPERTY(QString _address READ toString)// WRITE setName)

public:

    /**
     * QBtAddress()
     * Default constructor.
     */
    QBtAddress();

    /**
     * QBtAddress()
     * Copy constructor
     */
    QBtAddress (const QBtAddress& other);

    QBtAddress (const QByteArray& byteArray);
    QBtAddress (const QString& addr);

#ifdef Q_OS_SYMBIAN
    QBtAddress (const TBTDevAddr& addr);
#endif
    /**
     * Mainly created because on windows bluesoleil sdk, bluetooth _address
     * byte array is reversed so it is usefull to provide this functionality
     * here
     *
     * @param reversedArray
     */
    static QBtAddress& getAddressFromReversedArray (const QByteArray & reversedArray);

    ~QBtAddress ();

    /**
     * @return true if the _address contained in this instance is
     * a valid bluetooth _address
     */
    bool isValid () const;

    /**
     * Returns a string representation of this bluetooth _address
     */
    QString toString() const;

    /**
     * Returns a 6-byte array representation of the bluetooth _address
     */
    QByteArray toByteArray() const; // Symbian representation

    /**
     * Returns a 6-byte array representation of the bluetooth _address
     * in reversed order. Mainly created for convenience when using
     * windows bluesoleil SDK.
     */
    QByteArray toReversedByteArray() const; // windows representation

    QBtAddress& operator= (const QBtAddress & other );
    bool operator!= (const QBtAddress & other );
    bool operator== (const QBtAddress & other );
    bool operator< (const QBtAddress & other );

#ifdef Q_OS_SYMBIAN
    TBTDevAddr convertToSymbianBtDevAddr() const;
#endif

private:
    QString _address;
    bool _valid;
};

QBT_NAMESPACE_END

Q_DECLARE_METATYPE(QBT_PREPEND_NAMESPACE(QBtAddress))

#endif // QBTADDRESS_H


code:
/*
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef QBTCONSTANTS_H
#define QBTCONSTANTS_H

#include <QBtGlobal.h>

QBT_NAMESPACE_BEGIN

/**
 * Basic enumerations of bluetooth UUIDs
 */
class DLL_EXPORT QBtConstants : public QObject
{
	Q_OBJECT
	Q_ENUMS(ServiceClass)
	Q_ENUMS(ServiceProtocol)
public:

    /**
     * Short UUIDs for standard services, as unsigned integers.
     */
    enum ServiceClass
    {
            UndefinedClass = 0x0000,
            SerialPort = 0x1101,
            LANAccessUsingPPP,
            DialupNetworking,
            IrMCSync,
            OBEXObjectPush,
            OBEXFileTransfer,
            IrMCSyncCommand,
            Headset,
            CordlessTelephony,
            AudioSource,
            AudioSink,
            RemoteControlTarget,
            AdvancedAudioDistribution,
            AV_RemoteControl,
            VideoConferencing,
            Intercom,
            Fax,
            HeadsetAudioGateway,
            WAP,
            WAP_CLIENT,
            PANU,
            NAP,
            GN,
            DirectPrinting,
            ReferencePrinting,
            Imaging,
            ImagingResponder,
            ImagingAutomaticArchive,
            ImagingReferencedObjects,
            Handsfree,
            HandsfreeAudioGateway,
            DirectPrintingReferenceObjectsService,
            ReflectedUI,
            BasicPrinting,
            PrintingStatus,
            HumanInterfaceDeviceService,
            HardcopyCableReplacement,
            HCR_Print,
            HCR_Scan,
            Common_ISDN_Access,
            VideoConferencingGW,
            UDI_MT,
            UDI_TA,
            Audio_Video,
            SIM_Access,
            PnPInformation,
            GenericNetworking,
            GenericFileTransfer,
            GenericAudio,
            GenericTelephony,
            UPNP_Service,
            UPNP_IP_Service,
            ESDP_UPNP_IP_PAN,
            ESDP_UPNP_IP_LAP,
            ESDP_UPNP_L2CAP,

            MY_CUSTOM = 0x10ff
        };

    /**
     * Short UUIDs for standard protocols.
     */
    enum ServiceProtocol
    {
            UndefinedProtocol 	= 0x0000,
            SDP,
            UDP,
            RFCOMM,
            TCP,
            TCS_BIN,
            TCS_AT,
            OBEX 		= 0x0008,
            IP,
            FTP,
            HTTP		= 0x000C,
            WSP			= 0x000E,
            BNEP,
            UPNP,
            HIDP,
            HardcopyControlChannel,
            HardcopyDataChannel = 0x0014,
            HardcopyNotification = 0x0016,
            AVCTP,
            AVDTP = 0x0019,
            CMPT = 0x001B,
            UDI_C_Plane = 0x001D,
            L2CAP = 0x0100
        };
};

QBT_NAMESPACE_END

Q_DECLARE_METATYPE(QBT_PREPEND_NAMESPACE(QBtConstants::ServiceClass))
Q_DECLARE_METATYPE(QBT_PREPEND_NAMESPACE(QBtConstants::ServiceProtocol))

#endif // QBTCONSTANTS_H


code:
/*
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef QBTDEVICE_H
#define QBTDEVICE_H

#include <QtCore/QList>
#include <QtCore/QString>
#include <QBtGlobal.h>
#include <QBtService.h>
#include <QBtAddress.h>

//#include <QtDeclarative/QtDeclarative.h>

QBT_NAMESPACE_BEGIN

/**
 * The class that contains all the information needed about any bluetooth device.
 * Its main fields are 4.
 *
 * a) QBtAddress address: It is the device's bluetooth address.
 *                  Any communication between remote devices is made using this field
 *                  so it is an essential information. No communication can be done
 *                  without this.
 *
 * b) QString name: The name of the device. By default this field is equal to QBtAddress.toString().
 *                  The actual name is retrieved from the device discovery
 *                  and is set by the remote device as an identification string ID.
 *
 * c) DeviceMajor type: an enumeration field characterizing the device type.
 *
 * d) QBtService::List supportedServices: this field is updated after calling
 *                  QBtServiceDiscoverer::startDiscovery(QBtDevice*)
 *                  (if any services are found through SDP)
 */
class DLL_EXPORT QBtDevice : public QObject
{
	Q_OBJECT
	Q_ENUMS(DeviceMajor)
	Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
	Q_PROPERTY(QBtAddress address READ getAddress WRITE setAddress)
	Q_PROPERTY(DeviceMajor type READ getType WRITE setType)

public:
    typedef QList<QBtDevice> List;

    enum DeviceMajor
    {
        Uncategorized, 	//Uncategorized device
        Computer,		//Computer device
        Phone,			//Phone device
        LANAccess,		//Some form of a local area network router
        AudioVideo,		//Audio / Video device
        Peripheral,		//Mouse, Joystick, Keyboard
        Imaging,		//Camera or Scanner device
        Wearable,		//Wearable Device
        Toy,			//Toy device
        Miscellaneous	//Miscellaneous device
    };

public:
    QBtDevice(QObject* parent=0);

	/**
	 *  Copy constructor is needed by the QMetaType to register this custom class
	 */
    QBtDevice(const QBtDevice& dev, QObject* parent=0);
    QBtDevice (const QString & devName, const QBtAddress & devAddress, DeviceMajor devType, QObject* parent=0);
    ~QBtDevice();

    void addNewService (const QBtService& newService);
    //void setName (const QString & newName);
	void setName (const QString & newName);
    void setAddress (const QBtAddress& newAddress);
    void setType(DeviceMajor newType);
    void setSupportedServices (const QBtService::List& newSupportedServices);

    bool serviceListUpdated() const;

	Q_INVOKABLE QString name() const;
    Q_INVOKABLE QString getName() const;
    const QBtAddress& getAddress() const;
    DeviceMajor getType() const;
    QString getTypeAsString() const;
    const QBtService::List & getSupportedServices() const;

    // really needed? does not require special processing to copy the members
	//	->	It is required as it turns out when inheriting from QObject. If not implemented
	//		then i get linker error (at least when compiling for Windows)
    QBtDevice& operator= (const QBtDevice& dev);

signals:
	void nameChanged(QString newName);

private:
    QString _name;
    QBtAddress _address;
    DeviceMajor _type;
    QBtService::List _supportedServices;

    bool _serviceListUpdated;
};

#if QT_VERSION >= 0x040700
//QML_DECLARE_TYPE (QBtDevice)
#endif

//Q_DECLARE_METATYPE(QBtDevice)
//Q_DECLARE_METATYPE(QBtDevice::DeviceMajor)
QBT_NAMESPACE_END

//Q_DECLARE_METATYPE(QBT_PREPEND_NAMESPACE(QBtDevice))

#endif // QBTDEVICE_H

//QML_DECLARE_TYPE(type)


code:
#ifndef QBTREMOTEFILEINFO_H
#define QBTREMOTEFILEINFO_H

#include <QString>
#include <QObject>
#include <QBtGlobal.h>
#include <QDate>

QBT_NAMESPACE_BEGIN

class DLL_EXPORT QBtRemoteFileInfo : public QObject{
	Q_OBJECT
public:
	QBtRemoteFileInfo(QObject* parent=0);
	QBtRemoteFileInfo(const QBtRemoteFileInfo& fileInfo);
	QString toString();
	QBtRemoteFileInfo& operator=(const QBtRemoteFileInfo& fileInfo);

public:
	QString absolutePath;
	QString fileName;
	QString path;
	bool isDir;
	int type;
	int size;

	QDate creationTime;
	QDate lastAccessTime;
	QDate lastWriteTime;
};

QBT_NAMESPACE_END

Q_DECLARE_METATYPE(QBT_PREPEND_NAMESPACE(QBtRemoteFileInfo))

#endif // QBTREMOTEFILEINFO_H


code:
/*
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef QBTSERVICE_H
#define QBTSERVICE_H

#include <QtCore/QString>
#include <QtCore/QList>
#include <QBtGlobal.h>
#include <QBtConstants.h>
#include <QBtUuid.h>

QBT_NAMESPACE_BEGIN

/**
 * Class containing all the necessary information about a bluetooth service
 * of a remote device.
 */
class DLL_EXPORT QBtService : public QObject
{
	Q_OBJECT

   public:
      typedef QList<QBtService> List;

      /**
       * This list will be populates either by the Service Discovery or
       * by the user.
       *
       * The index of every protocol contained corresponds to the level of
       * hierarchy that it belongs.
       *
       * example: to create a service using RFCOMM then the list will be:
       * [0]: L2CAP
       * [1]: RFCOMM
       *
       * So ProtocolList::last() returns the highest protocol.
       */
      typedef QList<QBtUuid> ProtocolList;

      /**
       * Constructs an empty instance.
       */
      QBtService(QObject* parent = 0);

	  /**
	   *  Copy constructor
	   */
	  QBtService(const QBtService& service, QObject* parent = 0);

      /**
       * Gets the protocol list used by this service.
       */
      ProtocolList getProtocols() const;

      /**
       * Gets the service id of this service.
       */
      QBtUuid getClass () const;

      /**
       * Gets the service name.
       */
      QString getName() const;

      /**
       * Gets the service description.
       */
      QString getDescription() const;

      /**
       * Gets the service port.
       */
      uint getPort() const;

      /**
       * Gets the native (?) service handle.
       */
      uint getHandle() const;

      /**
       * Adds a protocol to the service protocol list.
       */
      void addProtocol(const QBtUuid & uuid);

      bool removeProtocol (const QBtUuid & uuid);

      void setProtocols(const ProtocolList & newUUIDs);

      void setClass(const QBtUuid & newClass);

      void setName(const QString& newName);

      void setDescription(const QString& newDescription);

      void setPort(uint newPort);

      void setHandle (uint newHandle);

	  QBtService& operator=(const QBtService& service);

   private:

      // protocol list is mainly used on symbian
      // on windows the connections are done using classUUID
      QBtUuid       _serviceUuid;
      ProtocolList  _protocolList;
      QString       _name;
      QString       _description;
      uint          _handle;

      // used on RFCOMM service as channel number to be used for connection
      // to remote device
      uint          _port;

};

QBT_NAMESPACE_END

Q_DECLARE_METATYPE(QBT_PREPEND_NAMESPACE(QBtService))

#endif // QBTSERVICE_H


code:
#ifndef QBTUUID_H
#define QBTUUID_H

#include <QBtGlobal.h>
#include <QtCore/QString>

QBT_NAMESPACE_BEGIN

/**
 * This class represents a UUID for Bluetooth, either in short format (16 or 32-bits) or full (128-bit).
 *
 */
class DLL_EXPORT QBtUuid : public QObject
{
	Q_OBJECT

   public:

      /**
       * Constructs an empty instance.
       */
      QBtUuid (QObject* parent=NULL);

      /**
       * Constructs an instance from a string representation.
       *
       * Valid formats:
       * XXXX
       * XXXXXXXX
       * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
       */
      QBtUuid (const QString & uuid);

      /**
       * Constructs an instance from a short uuid representation, a 16-bit or 32-bit value.
       */
      explicit QBtUuid (uint uuid);

	  /**
	   * Copy constructor
	   */
	  QBtUuid(const QBtUuid& uuid);
   public:

      /**
       * Sets as short UUID based on the supplied value. Assumed to be a 16-bit or 32-bit hexadecimal number.
       */
      void set (uint uuid);

      /**
       * Sets the uuid from a string representation.
       *
       * Valid formats:
       * XXXX
       * XXXXXXXX
       * XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
       * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
       */
      void set (const QString & uuid);

      /**
       * If short uuid, returns the equivalent uint. If full uuid, returns 0.
       *
       */
      uint get() const;

      /**
       * If this is a full uuid, splits it four 32-bit values. If this is a short
       * uuid, all values are set to zero.
       *
       */
      void get (uint & highWord1, uint & highWord2, uint & lowWord1, uint & lowWord2) const;

      /**
       * If short format, returns the equivalent uint. If full uuid, returns 0.
       *
       */
      bool isFull () const;

      /**
       * Returns true if this is an empty instance.
       *
       */
      bool isNull () const;
      /**
       * Returns a string representation.
       *
       */
      QString toString() const;

      /**
       * Resets to a null UUID.
       */
      void clear();

      /**
       *
       */
      bool operator == (const QBtUuid & obj) const;

	  /**
       *
       */
      bool operator != (const QBtUuid & obj) const;

	  /**
	   *
	   */
	  QBtUuid& operator=(class QBtUuid const &uuid);

   private:

      QString _uuid;

};

#ifdef Q_OS_SYMBIAN
#include <bttypes.h>

/**
 * A simple utility function to convert to the symbian native type.
 *
 */
inline TUUID QBtUuidToSymbianUuid (const QBtUuid & value)
{
   if (value.isFull() == false)
   {
      return TUUID (value.get() );
    }
    else
    {
      uint highWord1, highWord2, lowWord1, lowWord2;
      value.get (highWord1, highWord2, lowWord1, lowWord2);

      return TUUID (highWord1, highWord2, lowWord1, lowWord2);
    }
}

#endif

QBT_NAMESPACE_END

Q_DECLARE_METATYPE(QBT_PREPEND_NAMESPACE(QBtUuid))

#endif // QBTUUID_H


code:
/*
 * QBtTypes.h
 *
 *
 *      Author: Ftylitakis Nikolaos
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef QBTTYPES_H_
#define QBTTYPES_H_

#include <QBtAddress.h>
#include <QBtService.h>
#include <QBtDevice.h>
#include <QBtConstants.h>
#include <QBtUuid.h>
#include <QBtRemoteFileInfo.h>

#endif /* QBTTYPES_H_ */


code:
/*
 * QBtObjectExchangeClient.cpp
 *
 *
 *      Author: Ftylitakis Nikolaos
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "../QBtObjectExchangeClient.h"
#include <QBtAuxFunctions.h>

#if defined(Q_OS_SYMBIAN)
#include "../QBtObjectExchangeClient_symbian.h"
#elif defined(Q_OS_WIN32)
#include "../QBtObjectExchangeClient_win32.h"
#elif !defined(Q_OS_WIN32) && !defined(Q_OS_SYMBIAN)
#include "../QBtObjectExchangeClient_stub.h"
#endif

QBT_NAMESPACE_BEGIN

//////////////////////////////////////////////////
// QBtObjectExchangeClient::QBtObjectExchangeClient()	//
// Defaul constructor							//
//////////////////////////////////////////////////
QBtObjectExchangeClient::QBtObjectExchangeClient(QObject *parent) :
    QObject(parent)
{
#ifdef Q_OS_SYMBIAN
    QT_TRAP_THROWING(_implPtr = QBtObjectExchangeClientPrivate::NewL(this));
#else
    _implPtr = new QBtObjectExchangeClientPrivate(this);
#endif
}

QBtObjectExchangeClient::~QBtObjectExchangeClient()
{
    SafeDelete(_implPtr);
}

void QBtObjectExchangeClient::connectToServer(
        const QBtDevice& remoteDevice,
        const QBtService& remoteService)
{
    _implPtr->ConnectToServer(remoteDevice, remoteService);
}

void QBtObjectExchangeClient::disconnect()
{
    _implPtr->Disconnect();
}

void QBtObjectExchangeClient::getFile(const QString& remoteFileAbsolutePath, const QString& destinationFolder)
{
    _implPtr->GetFile(destinationFolder, remoteFileAbsolutePath);
}

void QBtObjectExchangeClient::getByteBuffer(const QString& dataName)
{
    _implPtr->GetByteBuffer(dataName);
}

void QBtObjectExchangeClient::putFile(const QString& fileName)
{
    _implPtr->SendFile(fileName);
}

void QBtObjectExchangeClient::putByteBuffer(const QByteArray& data, const QString& bufferName)
{
    _implPtr->SendData(data, bufferName);
}

void QBtObjectExchangeClient::abort()
{
    _implPtr->Abort();
}

void QBtObjectExchangeClient::setPath(const QString & path)
{
    _implPtr->SetPath(path);
}

QList<QBtRemoteFileInfo*> QBtObjectExchangeClient::initiateFolderBrowsing(const QString& folderPath)
{
#ifdef Q_OS_WIN32
	return _implPtr->InitiateFolderBrowsing(folderPath);
#else
	emit error(QBtObjectExchangeClient::OBEXFeatureNotSupported);
        return  QList<QBtRemoteFileInfo*>();
#endif
}

// accessor commands
QString QBtObjectExchangeClient::getWorkingPath()
{
#ifdef Q_OS_WIN32
	return _implPtr->GetRemoteWorkingDirectory();
#else
	emit error(QBtObjectExchangeClient::OBEXFeatureNotSupported);
#endif
}

QBtService& GetTransmittingService()
{
    return *(new QBtService());
}

QBtDevice& GetServerDevice()
{
    return *(new QBtDevice());
}

bool QBtObjectExchangeClient::isBusy() const
{
	return _implPtr->IsBusy();
}

bool QBtObjectExchangeClient::isConnected() const
{
	return _implPtr->IsConnected();
}

QList<QBtRemoteFileInfo*> QBtObjectExchangeClient::locateFiles(QRegExp* regex, QString folder)
{
#ifdef Q_OS_WIN32
	return _implPtr->locateFiles(regex, folder);
#else
	emit error(QBtObjectExchangeClient::OBEXFeatureNotSupported);
#endif
}

void QBtObjectExchangeClient::batchFileRetrieval(const QList<QBtRemoteFileInfo*>& files,
		const QString destinationFolder,
		bool retrieveOnlyNewFiles)
{
#ifdef Q_OS_WIN32
	return _implPtr->batchFileRetrieval(files, destinationFolder, retrieveOnlyNewFiles);
#else
	emit error(QBtObjectExchangeClient::OBEXFeatureNotSupported);
#endif
}

QBT_NAMESPACE_END


code:
/*
 * QBtObjectExchangeClient_stub.cpp
 *
 *
 *      Author: Ftylitakis Nikolaos
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "../QBtObjectExchangeClient_stub.h"

QBtObjectExchangeClientPrivate::QBtObjectExchangeClientPrivate(
		QBtObjectExchangeClient* publicClass) : p_ptr(publicClass)
{
}

QBtObjectExchangeClientPrivate::~QBtObjectExchangeClientPrivate()
{

}

void QBtObjectExchangeClientPrivate::ConnectToServer(const QBtDevice& remoteDevice, const QBtService& remoteService)
{

}

void QBtObjectExchangeClientPrivate::Disconnect()
{

}

void QBtObjectExchangeClientPrivate::SendFile(const QString& fileName)
{

}

void QBtObjectExchangeClientPrivate::SendData (const QByteArray& data, const QString& bufferName)
{

}

void QBtObjectExchangeClientPrivate::Abort()
{

}

bool QBtObjectExchangeClientPrivate::IsConnected()
{
	return false;
}

bool QBtObjectExchangeClientPrivate::IsBusy()
{
	return false;
}

bool QBtObjectExchangeClientPrivate::SetPath (const QString & path)
{
	return false;
}

void QBtObjectExchangeClientPrivate::GetFile(
		const QString& localPath, const QString& remoteFileNameFull)
{

}

void QBtObjectExchangeClientPrivate::GetByteBuffer(const QString& dataName)
{

}


code:
/*
 * QBtObjectExchangeClient_symbian.cpp
 *
 *      Author: Ftylitakis Nikolaos
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <QFile>
#include <QTextStream>
#include "../QBtObjectExchangeClient_symbian.h"
#include <QBtAuxFunctions.h>

// ----------------------------------------------------------------------------
// QBtObjectExchangeClientPrivate::NewL()
// Symbian two-phased constructor.
// ----------------------------------------------------------------------------
//
QBtObjectExchangeClientPrivate* QBtObjectExchangeClientPrivate::NewL(
                                            QBtObjectExchangeClient* publicClass )
{
    QBtObjectExchangeClientPrivate* self = NewLC( publicClass );
    CleanupStack::Pop( self );
    return self;
}

// ----------------------------------------------------------------------------
// QBtObjectExchangeClientPrivate::NewLC()
// Symbian two-phased constructor.
// ----------------------------------------------------------------------------
//
QBtObjectExchangeClientPrivate* QBtObjectExchangeClientPrivate::NewLC(
                                            QBtObjectExchangeClient* publicClass )
{
    QBtObjectExchangeClientPrivate* self = new ( ELeave ) QBtObjectExchangeClientPrivate(publicClass );
    CleanupStack::PushL( self );
    self->ConstructL();
    return self;
}

// ----------------------------------------------------------------------------
// QBtObjectExchangeClientPrivate::QBtObjectExchangeClientPrivate()
// Constructor.
// ----------------------------------------------------------------------------
//
QBtObjectExchangeClientPrivate::QBtObjectExchangeClientPrivate( QBtObjectExchangeClient* publicClass )
            : CActive( CActive::EPriorityStandard ),
            iNewFile(NULL),
            iState( ENone ),
            iClient(NULL),
            iCurrObject(NULL),
            buffer(NULL),
            p_ptr( publicClass )
            //server(NULL),
            //service(NULL),

{
    CActiveScheduler::Add( this );
}

// ----------------------------------------------------------------------------
// QBtObjectExchangeClientPrivate::~QBtObjectExchangeClientPrivate()
// Destructor.
// ----------------------------------------------------------------------------
//
QBtObjectExchangeClientPrivate::~QBtObjectExchangeClientPrivate()
{
    Disconnect();

    SafeDelete(iCurrObject);
    SafeDelete(iClient);
    //SafeDelete(server);
    //SafeDelete(service);
    SafeDelete(buffer);
}

// ----------------------------------------------------------------------------
// QBtObjectExchangeClientPrivate::ConstructL()
// Perform second phase construction of this object.
// ----------------------------------------------------------------------------
//
void QBtObjectExchangeClientPrivate::ConstructL()
{
}

// ----------------------------------------------------------------------------
// QBtObjectExchangeClientPrivate::DoCancel()
// Cancel any outstanding requests.
// ----------------------------------------------------------------------------
//
void QBtObjectExchangeClientPrivate::DoCancel()
{

}

// ----------------------------------------------------------------------------
// QBtObjectExchangeClientPrivate::RunL()
// Respond to an event.
// ----------------------------------------------------------------------------
//
void QBtObjectExchangeClientPrivate::RunL()
{
    //ERespForbidden
    if ( iStatus == KErrDisconnected)
    {
    	QT_TRYCATCH_LEAVING (emit p_ptr->disconnectedFromServer() );
        if(IsActive())
            Cancel();
    }
    else if ( iStatus != KErrNone )
    {
        switch ( iState )
        {
            case EGettingConnection:
            case EDisconnecting:
            	QT_TRYCATCH_LEAVING (emit p_ptr->error(QBtObjectExchangeClient::OBEXClientConnectionError) );
                break;
            case EWaitingToSend:
            	QT_TRYCATCH_LEAVING (emit p_ptr->error(QBtObjectExchangeClient::OBEXClientSendError) );
                break;
            case EWaitingToReceiveData:
            case EWaitingToReceiveFile:
            	QT_TRYCATCH_LEAVING (emit p_ptr->error(QBtObjectExchangeClient::OBEXClientReceiveError) );
                break;
            default:
                break;
        }
        //TInt statusId = iStatus.Int();
        return;
    }
    else
    {
        switch ( iState )
        {
            case EGettingConnection:
                HandleServerConnection();
                break;

            case EWaitingToSend:
                HandleObjectSent();
                break;

            case EWaitingToReceiveData:
            case EWaitingToReceiveFile:
                HandleObjectReceived();
                break;

            case EDisconnecting:
                HandleDisconnection();
                break;

            case EBrowsing:
                HandleBrowsingFinsished();
                break;

            case ESettingPath:
                HandleSettingPathCompletion();
                break;

            default:
                break;
        };
    }
}

//////////////
// Handles	//
//////////////

void QBtObjectExchangeClientPrivate::HandleServerConnection()
{
    iState = EWaitingToSend;
    QT_TRYCATCH_LEAVING (emit p_ptr->connectedToServer() );
}

void QBtObjectExchangeClientPrivate::HandleObjectSent()
{
    iState = EWaitingToSend;
    SafeDelete(iCurrObject); // delete temporaly object
    QT_TRYCATCH_LEAVING (emit p_ptr->objectSent() );
}

void QBtObjectExchangeClientPrivate::HandleObjectReceived()
{
    if(EWaitingToReceiveFile)
    {
        iState = EWaitingToSend;

        QString fileName = QString::fromUtf16(iCurrObject->Name().Ptr(),iCurrObject->Name().Size());
        QT_TRYCATCH_LEAVING (emit p_ptr->fileReceived(fileName) );

    /*	QString fileNameFullWithLocalPath = tmpLocalPath + fileName;
        QFile file(fileNameFullWithLocalPath);
        file.open(QIODevice::WriteOnly | QIODevice::Text);
        QTextStream out(&file);
        QString fileData = QString::fromUtf16(((CObexFileObject*)iCurrObject)->DataFile().Ptr());
        out << fileData;
        file.close();*/
    }
    else
    {
        iState = EWaitingToSend;
        if(!buffer)
            return;

        TUint8* tmpArray = new TUint8(buffer->Size());
        CleanupStack::PushL(tmpArray);
        TPtr8 data(tmpArray, buffer->Size());
        buffer->Read(0, data);

        QByteArray retArray((const char*)data.Ptr(), data.Size());
        delete tmpArray;

        QT_TRYCATCH_LEAVING (emit p_ptr->dataReceived(retArray) );
    }
}

void QBtObjectExchangeClientPrivate::HandleDisconnection()
{
    iState = ENone;
    QT_TRYCATCH_LEAVING (emit p_ptr->disconnectedFromServer() );
}

void QBtObjectExchangeClientPrivate::HandleBrowsingFinsished()
{
    iState = EWaitingToSend;
    return;
}

void QBtObjectExchangeClientPrivate::HandleSettingPathCompletion()
{
    iState = EWaitingToSend;
    return;
}

// ----------------------------------------------------------------------------
// QBtObjectExchangeClientPrivate::ConnectToServer()
// Connect to the server.
// ----------------------------------------------------------------------------
//
void QBtObjectExchangeClientPrivate::ConnectToServer(const QBtDevice& remoteDevice, const QBtService& remoteService)
{
    TObexBluetoothProtocolInfo protocolInfo;

    protocolInfo.iTransport.Copy( _L("RFCOMM") );
    protocolInfo.iAddr.SetBTAddr (remoteDevice.getAddress().convertToSymbianBtDevAddr());
    protocolInfo.iAddr.SetPort (remoteService.getPort());

    SafeDelete(iClient);

    iClient = CObexClient::NewL( protocolInfo );

    iState = EGettingConnection;
    iClient->Connect( iStatus );
    SetActive();
}

// ----------------------------------------------------------------------------
// QBtObjectExchangeClientPrivate::SendFile()
// Send a message to a service on a remote machine.
// ----------------------------------------------------------------------------
//
void QBtObjectExchangeClientPrivate::SendFile(const QString& fileName)
{
    if(!CheckServiceAvailability())
        return;

    iState = EWaitingToSend;

    //in case QFileDialog is used (or an address is given in the following format),
    // all '/' are changed to  '\'.
    QString fileNameEdited = fileName;
    fileNameEdited.replace("/", "\\");

    TPtrC16 aName = TPtrC16(fileNameEdited.utf16());

    SafeDelete(iCurrObject);
    iCurrObject = CObexFileObject::NewL(aName);

    TParse parse;
    parse.Set(aName, NULL, NULL);
    TPtrC ptr = parse.NameAndExt();

    iCurrObject->SetNameL( ptr );

    iClient->Put( *iCurrObject, iStatus );
    SetActive();
}

// ----------------------------------------------------------------------------
// QBtObjectExchangeClientPrivate::Abort()
// Aborts command.
// ----------------------------------------------------------------------------
//
void QBtObjectExchangeClientPrivate::Abort()
{
    if ( iClient && iClient->IsConnected() )
    {
        iClient->Abort();
        iState = EWaitingToSend;
    }
}

// ----------------------------------------------------------------------------
// QBtObjectExchangeClientPrivate::Disconnect()
// Disconnects from the remote machine.
// ----------------------------------------------------------------------------
//
void QBtObjectExchangeClientPrivate::Disconnect()
{
    if ( iState == ENone  || !iClient || iState == EGettingConnection)
        return;

    Abort();
    iState = EDisconnecting;
    iClient->Disconnect( iStatus );
    SetActive();
}

// ----------------------------------------------------------------------------
// QBtObjectExchangeClientPrivate::IsBusy()
// True, if the client is performing some operation..
// ----------------------------------------------------------------------------
//
TBool QBtObjectExchangeClientPrivate::IsBusy()
{
    return IsActive();
}

// ----------------------------------------------------------------------------
// QBtObjectExchangeClientPrivate::IsConnected()
// True, if the client is performing some operation..
// ----------------------------------------------------------------------------
//
TBool QBtObjectExchangeClientPrivate::IsConnected()
{
    return (iState != ENone && iState != EGettingConnection);
}

//if KErrArgument -> invalid path!!!
void QBtObjectExchangeClientPrivate::SetPath (const QString & path)
{
    if(!CheckServiceAvailability())
        return;

    iState = ESettingPath;

    // If you do not which to send a name
    if(path == "")
    {
        pathInfo.iNamePresent = EFalse;
    }
    else
    {
        TPtrC16 path16;
        path16.Set(path.utf16());
        pathInfo.iName = path16;
    }

    iClient->SetPath(pathInfo, iStatus);
    SetActive();
}

TBool QBtObjectExchangeClientPrivate::CheckServiceAvailability()
{
    if ( iState == ENone ||  iState == EGettingConnection)
    {
    	QT_TRYCATCH_LEAVING (emit p_ptr->error(QBtObjectExchangeClient::OBEXClientDisconnected) );
        return EFalse;
    }
    else if ( IsBusy() )
    {
    	QT_TRYCATCH_LEAVING (emit p_ptr->error(QBtObjectExchangeClient::OBEXClientInUse) );
        return EFalse;
    }
    else
        return ETrue;
}

// ----------------------------------------------------------------------------
// QBtObjectExchangeClientPrivate::SendData
// Send a byte array to a service on a remote machine
// ----------------------------------------------------------------------------
void QBtObjectExchangeClientPrivate::SendData(const QByteArray& data, const QString& bufferName)
{
    if(!CheckServiceAvailability())
            return;

    iState = EWaitingToSend;

    SafeDelete(buffer);
    SafeDelete(iCurrObject);

    TPtrC16 aName = TPtrC16(bufferName.utf16());

    TPtrC8 data8;
    data8.Set((TUint8*)data.constData(), data.size());
    buffer = CBufFlat::NewL(data.size());
    buffer->Write(0, data8, data8.Size());

    iCurrObject = CObexBufObject::NewL(buffer);
    iCurrObject->SetNameL(aName);
    iClient->Put(*iCurrObject, iStatus);
    SetActive();
}

void QBtObjectExchangeClientPrivate::GetFile(const QString& localPath, const QString& remoteFileNameFull)
{
    if(!CheckServiceAvailability())
            return;

    iState = EWaitingToReceiveFile;

    tmpLocalPath = localPath;
    if(tmpLocalPath.size() == 0)
    {
        tmpLocalPath = "c:\\data\\";
    }
    else if(tmpLocalPath.lastIndexOf("\\") != tmpLocalPath.size() - 1)
    {
        tmpLocalPath.append("\\");
    }

    TPtrC16 fullName = TPtrC16(remoteFileNameFull.utf16());

    SafeDelete(iCurrObject);
    iCurrObject = CObexFileObject::NewL();
    iCurrObject->SetNameL( fullName );

    iClient->Get( *iCurrObject, iStatus );
    SetActive();
}

void QBtObjectExchangeClientPrivate::GetByteBuffer(const QString& dataName)
{
    if(!CheckServiceAvailability())
        return;

    iState = EWaitingToReceiveData;

    SafeDelete(buffer);
    SafeDelete(iCurrObject);

    TPtrC16 aName = TPtrC16(dataName.utf16());

    buffer = CBufFlat::NewL(256);
    iCurrObject = CObexBufObject::NewL(buffer);
    iCurrObject->SetNameL(aName);
    iClient->Get(*iCurrObject, iStatus);
    SetActive();

}


code:
/*
 * QBtObjectExchangeClient_win32.cpp
 *
 *
 *      Author: Ftylitakis Nikolaos
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "../QBtObjectExchangeClient_win32.h"
#include <iostream>
#include <string>
#include <cstdlib>
#include <QByteArray>
#include <QFile>

QBT_NAMESPACE_BEGIN

#define MAX_FTP_FOLDER_LIST 128
#define MAX_FILENAME    256

bool QBtObjectExchangeClientPrivate::isBusy = false;
QBtObjectExchangeClientPrivate* QBtObjectExchangeClientPrivate::thisPtr = NULL;
QList<QBtRemoteFileInfo*>* QBtObjectExchangeClientPrivate::files = NULL;

QString QBtObjectExchangeClientPrivate::currentWorkingDirectory;

QBtObjectExchangeClientPrivate::QBtObjectExchangeClientPrivate(QBtObjectExchangeClient* publicClass,QObject* parent) :
	QObject(parent), p_ptr(publicClass), connectionHandle(BTSDK_INVALID_HANDLE), server(NULL), connectingService(NULL),
	maxFileNameSize(256)
{
	QBtAuxFunctions::InitBthSdk();
	thisPtr = this;
}

QBtObjectExchangeClientPrivate::~QBtObjectExchangeClientPrivate()
{
	Disconnect();
	QBtAuxFunctions::DeinitBthSdk();

	SafeDelete(server);
	SafeDelete(connectingService);
}

/**
* ConnectToServer
* Connect to the server
* @param remoteDevice the remote server to connect to
* @param remoteServive the remote service of the server
*/
void QBtObjectExchangeClientPrivate::ConnectToServer(const QBtDevice& remoteDevice, const QBtService& remoteService)
{
	//check
	if( !remoteDevice.getAddress().isValid())
	{
		emit p_ptr->error(QBtObjectExchangeClient::OBEXClientNoSelectedDevice);
		return;
	}
	if( remoteService.getClass()  == QBtUuid (QBtConstants::UndefinedClass) &&
		remoteService.getHandle() == 0)
	{
		emit p_ptr->error(QBtObjectExchangeClient::OBEXClientNoSelectedService);
		return;
	}

	server = new QBtDevice(remoteDevice);
	connectingService = new QBtService(remoteService);

	BTDEVHDL devHandle = QBtAuxFunctions::GetDeviceHandle(server->getAddress());

	BTINT32 result = BTSDK_FALSE;

	if(connectionHandle != BTSDK_INVALID_HANDLE)
		result = Btsdk_Connect(connectingService->getHandle(), 0, &connectionHandle);
	else
		result = Btsdk_ConnectEx(devHandle, connectingService->getClass().get(), 0, &connectionHandle);

	if(result != BTSDK_OK)
		emit p_ptr->error(QBtObjectExchangeClient::OBEXClientConnectionError);
	else
		emit p_ptr->connectedToServer();
}

/**
* Disconnect
* Disconnect from the remote machine, by sending an
* OBEX disconnect, and closing the transport on (and
* regardless of) response from the server.
*/
void QBtObjectExchangeClientPrivate::Disconnect()
{
	if (connectionHandle != BTSDK_INVALID_HANDLE)
	{
		BTINT32 result = BTSDK_FALSE;
		result = Btsdk_Disconnect(connectionHandle);
		if(result != BTSDK_OK)
			emit p_ptr->error(QBtObjectExchangeClient::OBEXClientConnectionError);
		else
		{
			connectionHandle = BTSDK_INVALID_HANDLE;
			emit p_ptr->disconnectedFromServer();
		}
	}
}

/**
* SendFile
* Send a file to a service on a remote machine
*/
void QBtObjectExchangeClientPrivate::SendFile(const QString& fileName)
{
	if (connectionHandle == BTSDK_INVALID_HANDLE)
	{
		emit p_ptr->error(QBtObjectExchangeClient::OBEXClientDisconnected);
		return;
	}

	WIN32_FIND_DATA pFindData;
	HANDLE hFile;
	BTUINT32 iErrorCode;

	//in case QFileDialog is used (or an address is given in the following format),
	// all '/' are changed to  '\'.
	QString fileNameEdited = fileName;
	fileNameEdited.replace("/", "\\");

	QString  fileNamePath = fileNameEdited.left( fileNameEdited.lastIndexOf("\\") );

//	SetPath("");
//	SetPath(fileNamePath);

//	ZeroMemory(ucCurrentLocalPath, BTSDK_PATH_MAXLENGTH);
//	strcpy((char*)ucCurrentLocalPath, (char*)localFilePath);

	Btsdk_FTPRegisterStatusCallback4ThirdParty(connectionHandle,
											&QBtObjectExchangeClientPrivate::FTPStatusCallback);

	hFile = FindFirstFile(fileNameEdited.utf16(),&pFindData);

	QString fileNameWStr = QString::fromUtf16(pFindData.cFileName);

	iErrorCode = Btsdk_FTPPutFile(connectionHandle,
									(BTUINT8*)fileNameEdited.toUtf8().constData(),
									(BTUINT8*)fileNameWStr.toUtf8().constData());

	Btsdk_FTPRegisterStatusCallback4ThirdParty(connectionHandle, NULL);

	if(iErrorCode == BTSDK_OK)
		emit p_ptr->objectSent();
	else
		emit p_ptr->error(QBtObjectExchangeClient::OBEXClientSendError);
}

/**
* SendData
* Send a byte array to a service on a remote machine
*/
void QBtObjectExchangeClientPrivate::SendData(const QByteArray& /*data*/, const QString& /*bufferName*/)
{
	return;
}

/**
* GetFile
*
* Request from the server to GET the file defined in the argument
*/
void QBtObjectExchangeClientPrivate::GetFile(const QString& localPath, const QString& remoteFileNameFull)
{
	if (connectionHandle == BTSDK_INVALID_HANDLE)
		return;

	//save current working directory to restore it after operation
	QString cwd = GetRemoteWorkingDirectory();

	int slashPosition = remoteFileNameFull.lastIndexOf("\\");

	QString localPathStr = localPath;
	QString remoteFilePath = remoteFileNameFull.left(slashPosition+1);
	QString remoteFileName = remoteFileNameFull.right(remoteFileNameFull.size() - slashPosition - 1);

	BTUINT32 iErrorCode;

	Btsdk_FTPRegisterStatusCallback4ThirdParty(connectionHandle, &QBtObjectExchangeClientPrivate::FTPStatusCallback);

	// go to directory that contains the file
	if(remoteFilePath != currentWorkingDirectory)
	{
		SetPath("");
		SetPath(remoteFilePath);
	}

	//////////////////////////////////////////////////////////////////////////
	if(localPathStr.lastIndexOf("\\") != localPathStr.size() -1)
		localPathStr.append("\\");

	localPathStr += remoteFileName;
	//////////////////////////////////////////////////////////////////////////

	BTUINT8 remoteFile[MAX_FILENAME] = {0};
	BTUINT8 local[MAX_FILENAME] = {0};

	memcpy((char*)remoteFile, remoteFileName.toUtf8().data(), remoteFileName.size());
	memcpy((char*)local, localPathStr.toUtf8().data(), localPathStr.size());

	iErrorCode = Btsdk_FTPGetFile(connectionHandle,
								remoteFile,
								local);

	Btsdk_FTPRegisterStatusCallback4ThirdParty(connectionHandle, NULL);

	if(iErrorCode == BTSDK_OK)
		emit p_ptr->fileReceived(QString(localPathStr));
	else
		emit p_ptr->error(QBtObjectExchangeClient::OBEXClientReceiveError);

	//restore current working directory to the one before the operation starts
	SetPath(cwd);

	return;
}

/**
* GetByteBuffer()
*
* Request from the server to GET the data buffer defined in the argument
*/
void QBtObjectExchangeClientPrivate::GetByteBuffer(const QString& /*dataName*/)
{
	return;
}

/**
* Abort
* Send the OBEX aborts command to the remote machine
*/
void QBtObjectExchangeClientPrivate::Abort()
{
	if(isBusy)
		Btsdk_FTPCancelTransfer(connectionHandle);
}

/**
* SetPath()
* Set the current path of the remote device OBEX session.
*/
bool QBtObjectExchangeClientPrivate::SetPath (const QString & path)
{
	if (connectionHandle == BTSDK_INVALID_HANDLE)
	{
		emit p_ptr->error(QBtObjectExchangeClient::OBEXClientDisconnected);
		return false;
	}

	BTINT32 iErrorCode;

	if(path == "..")
	{
		iErrorCode = Btsdk_FTPBackDir(connectionHandle);
		return (iErrorCode == BTSDK_OK);
	}

	QString pathEdited = path;
	if(pathEdited[0] != QChar('\\'))
		pathEdited.prepend("\\");

	// first try if file is in relative path form
	iErrorCode = Btsdk_FTPSetRmtDir(connectionHandle, (BTUINT8*)pathEdited.toUtf8().constData());

	if(iErrorCode != BTSDK_OK)
	{
		// then try as absolute path, going first to root path and then setting
		// the path given as argument
		Btsdk_FTPSetRmtDir(connectionHandle, NULL);
		iErrorCode = Btsdk_FTPSetRmtDir(connectionHandle, (BTUINT8*)pathEdited.toUtf8().constData());
	}

	if(iErrorCode == BTSDK_OK)
	{
		QString remotePath(GetRemoteWorkingDirectory());
		emit p_ptr->remotePathSet(remotePath);
		return true;
	}
	else
	{
		emit p_ptr->error(QBtObjectExchangeClient::OBEXClientUnableToSetPath);
		return false;
	}
}

/**
* IsConnected
* @return true if the client is connected
*/
bool QBtObjectExchangeClientPrivate::IsConnected()
{
	return (connectionHandle != BTSDK_INVALID_HANDLE);
}

/**
* IsBusy
* @return true if the client is performing some operation.
*/
bool QBtObjectExchangeClientPrivate::IsBusy()
{
	return isBusy;
}

QString QBtObjectExchangeClientPrivate::GetRemoteWorkingDirectory()
{
	if (connectionHandle == BTSDK_INVALID_HANDLE)
	{
		emit p_ptr->error(QBtObjectExchangeClient::OBEXClientConnectionError);
		return QString("");
	}

	BTUINT8 remoteCurrentDir[MAX_FILENAME];
	BTINT32 result = BTSDK_FALSE;

	ZeroMemory(remoteCurrentDir, MAX_FILENAME);

	result = Btsdk_FTPGetRmtDir(connectionHandle, remoteCurrentDir);

	if(result == BTSDK_OK)
		return QString((char*)remoteCurrentDir);
	else
		return "";
}

QList<QBtRemoteFileInfo*> QBtObjectExchangeClientPrivate::InitiateFolderBrowsing(const QString folderPath)
{
	BTINT32 result = BTSDK_FALSE;
	QString folderPathStr = folderPath;
	QString currentdir(GetRemoteWorkingDirectory());

	currentWorkingDirectory = currentdir;

	if (connectionHandle == BTSDK_INVALID_HANDLE)
	{
		emit p_ptr->error(QBtObjectExchangeClient::OBEXClientConnectionError);
		return QList<QBtRemoteFileInfo*>();
	}

	if(folderPath == "")
		folderPathStr = currentdir;

	SafeDelete(files);
	files = new QList<QBtRemoteFileInfo*>();

	if(folderPathStr == currentdir)
	{
		int slashPos = folderPathStr.lastIndexOf("\\");
		if(slashPos == folderPathStr.size()-1)
		{
			folderPathStr.resize(folderPathStr.size()-1);
			slashPos = folderPathStr.lastIndexOf("\\");
		}

		QString folderName = folderPathStr.right(folderPathStr.size() - slashPos - 1);
		currentWorkingDirectory = folderPathStr;

		result = Btsdk_FTPBrowseFolder(connectionHandle, (BTUINT8*)folderName.toAscii().data(), &QBtObjectExchangeClientPrivate::FTPBrowsingCallback, FTP_OP_REFRESH);
	}
	else
	{
		//in case we have absolute paths for folder in a tree bench other than the one we are at.
		if(folderPathStr[0] == QChar('\\'))
		{
			SetPath("");
			folderPathStr = folderPathStr.right(folderPathStr.size()-1);
			currentWorkingDirectory = "\\";
		}
		//else the path is relative to the current working directory

		if(currentWorkingDirectory.size() != 1)
			currentWorkingDirectory += "\\";
		currentWorkingDirectory += folderPathStr;

		result = Btsdk_FTPBrowseFolder(connectionHandle, (BTUINT8*)folderPathStr.toAscii().data(), &QBtObjectExchangeClientPrivate::FTPBrowsingCallback, FTP_OP_NEXT);
	}

	//if not empty then it means that there was some error
	if (!(result == 0X6a4))
		emit p_ptr->error(QBtObjectExchangeClient::OBEXClientBrowseError);

	return QList<QBtRemoteFileInfo*>(*files);
}

QList<QBtRemoteFileInfo*> QBtObjectExchangeClientPrivate::locateFiles(QRegExp* regex, QString folder)
{
	static int refCounter=0;
	QString cwd;
	if(!refCounter++)
	{
		//save current working directory to restore it after operation
		cwd = GetRemoteWorkingDirectory();
		selectedFiles.clear();
	}

	QList<QBtRemoteFileInfo*>& results = InitiateFolderBrowsing(folder);

	if(regex == NULL)
	{
		regex = new QRegExp("*");
		regex->setPatternSyntax(QRegExp::Wildcard);
		regex->setCaseSensitivity(Qt::CaseInsensitive);
	}

	for(int i=0; i<results.size(); i++)
	{
		if(results[i]->isDir)
		{
			locateFiles(regex, results[i]->fileName);
			SetPath("..");
		}
		else{
			if(regex == NULL)
				return QList<QBtRemoteFileInfo*>();

			if (results[i]->fileName.contains(*regex))
			{
				//currently adds all the non directory files in
				selectedFiles.append(results[i]);
			}
		}
	}

	if(!--refCounter)
	{
		//restore current working directory to the one before the operation starts
		SetPath(cwd);
		return selectedFiles;
	}
	else
		return QList<QBtRemoteFileInfo*>();
}

void QBtObjectExchangeClientPrivate::batchFileRetrieval(const QList<QBtRemoteFileInfo*>& files,
																 const QString destinationFolder,
																 bool retrieveOnlyNewFiles)
{
	QList<QBtRemoteFileInfo*> filesEdited;
	QString destFolderEdited = destinationFolder;

	if(retrieveOnlyNewFiles)
	{
		for(int i=0; i<files.size(); i++)
		{
			if(destFolderEdited.lastIndexOf("\\") != destFolderEdited.size() -1)
				destFolderEdited.append("\\");

			QString fileLocalAbsolute = destFolderEdited + files[i]->fileName;
			//check local file system if file is already there
			if(!QFile(fileLocalAbsolute).exists())
			{
				filesEdited.append(files[i]);
				cout << "File: " << files[i]->fileName.toAscii().data() << " queued for download." << endl;
			}
		}
	}

	if(retrieveOnlyNewFiles)
		for(int i=0; i<filesEdited.size(); i++)
			GetFile(destinationFolder, filesEdited[i]->absolutePath);
	else
		for(int i=0; i<files.size(); i++)
			GetFile(destinationFolder, files[i]->absolutePath);
}

/************************************************************************/
/*                     Transfer info callback                           */
/************************************************************************/
void QBtObjectExchangeClientPrivate::FTPStatusCallback(UCHAR ucFirst,
					UCHAR ucLast, UCHAR* ucFileName, DWORD dwFilesize, DWORD dwCursize)
{
	static BTUINT32 s_TotalFileSize;
	static BTUINT32 s_CurrentFileSize;

	if (1 == ucFirst)
	{
		s_TotalFileSize = dwFilesize;
		s_CurrentFileSize = 0;

		isBusy = true;
	}

	printf("*******It is transfering file %s, and current size = %d****\n",
							ucFileName,s_CurrentFileSize += dwCursize);

	if (1 == ucLast)
	{
		printf("*******It has finished transfering file %s,and total size = %d ****\n",
			   ucFileName,s_TotalFileSize);

		isBusy = false;
	}
}

void QBtObjectExchangeClientPrivate::FTPBrowsingCallback(BTUINT8 *pFileInfo)
{
	QBtRemoteFileInfo file;

	WIN32_FIND_DATA *pFindData = NULL;

	if (NULL == pFileInfo) return;

	pFindData = (WIN32_FIND_DATA *)pFileInfo;

	file.fileName = QString::fromUtf8((char*)pFindData->cFileName);
	file.size = pFindData->nFileSizeLow;
	file.type = pFindData->dwFileAttributes;
	file.isDir = (pFindData->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
	file.path = currentWorkingDirectory;

	file.creationTime = convertToQDate(pFindData->ftCreationTime);
	file.lastAccessTime = convertToQDate(pFindData->ftLastAccessTime);
	file.lastWriteTime = convertToQDate(pFindData->ftLastWriteTime);

	if(files)
		files->append(new QBtRemoteFileInfo(file));

	Btsdk_FreeMemory(pFileInfo);
}

QDate QBtObjectExchangeClientPrivate::convertToQDate(FILETIME& time)
{
	SYSTEMTIME sysTime;
	FileTimeToSystemTime( &time, &sysTime);

	QDate qdate(sysTime.wYear, sysTime.wMonth, sysTime.wDay);
	return qdate;
}

QBT_NAMESPACE_END