Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1168266 - Add few member functions of ObexHeaderSet for PBAP. r=s…
Browse files Browse the repository at this point in the history
…huang
  • Loading branch information
JaminLiu committed May 27, 2015
1 parent b1ef5e0 commit ca2e592
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
62 changes: 62 additions & 0 deletions dom/bluetooth/ObexBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,68 @@ class ObexHeaderSet
}
}

uint32_t GetConnectionId() const
{
int length = mHeaders.Length();

for (int i = 0; i < length; ++i) {
if (mHeaders[i]->mId == ObexHeaderId::ConnectionId) {
uint32_t* id = (uint32_t *) mHeaders[i]->mData.get();
return *id;
}
}

// According to OBEX spec., the value 0xFFFFFFFF is reserved and it's
// considered invalid for Connection ID.
return 0xFFFFFFFF;
}

/**
* Get a specified parameter from the 'Application Parameters' header.
*
* @param aTagId [in] The tag ID of parameter which is defined by
* applications or upper protocol layer.
* @param aRetBuf [out] The buffer which is used to return the parameter.
* @param aBufferSize [in] The size of the given buffer.
*
* @return a boolean value to indicate whether the given paramter exists.
*/
bool GetAppParameter(uint8_t aTagId, uint8_t* aRetBuf, int aBufferSize) const
{
int length = mHeaders.Length();

for (int i = 0; i < length; ++i) {
// Parse the 'Application Parameters' header.
if (mHeaders[i]->mId == ObexHeaderId::AppParameters) {
uint8_t* ptr = mHeaders[i]->mData.get();
int dataLen = mHeaders[i]->mDataLength;

// An application parameters header may contain more than one
// [tag]-[length]-[value] triplet. The [tag] and [length] fields are
// each one byte in length.
uint8_t tagId;
uint8_t offset = 0;
do {
tagId = *(ptr + offset++);

// The length of value field, it should not exceed 255.
uint8_t paramLen = *(ptr + offset++);

if (tagId == aTagId) {
memcpy(aRetBuf, ptr + offset, paramLen < aBufferSize ? paramLen
: aBufferSize);
return true;
}

offset += paramLen;
} while (offset < dataLen);
}
}

// The specified parameter don't exist in 'Application Parameters' header.
return false;
}

bool Has(ObexHeaderId aId) const
{
int length = mHeaders.Length();
Expand Down
22 changes: 22 additions & 0 deletions dom/bluetooth/bluedroid/BluetoothPbapManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,28 @@

BEGIN_BLUETOOTH_NAMESPACE

/*
* Defined in section 6.2.1 "Application Parameters Header", PBAP ver 1.2
*/
enum AppParameterTag {
Order = 0x01,
SearchValue = 0x02,
SearchProperty = 0x03,
MaxListCount = 0x04,
ListStartOffset = 0x05,
PropertySelector = 0x06,
Format = 0x07,
PhonebookSize = 0x08,
NewMissedCalls = 0x09,
PrimaryVersionCounter = 0x0A,
SecondaryVersionCounter = 0x0B,
vCardSelector = 0x0C,
DatabaseIdentifier = 0x0D,
vCardSelectorOperator = 0x0E,
ResetNewMissedCalls = 0x0F,
PbapSupportedFeatures = 0x10
};

class BluetoothSocket;
class ObexHeaderSet;

Expand Down

0 comments on commit ca2e592

Please sign in to comment.