Files
palemoon27/dom/bluetooth/common/BluetoothUtils.h
T
roytam1 fe0509a62e import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 904479 - Added createPromiseWithId() that returns id of resolver r=kanru,nsm (2ac672d882)
- Bug 1166580 - Disable mozHasPendingMessage tests on non-browser platform. r=me (03c689964b)
- Bug 1162281 - Invalid system message handler in an App Manifest can break the entire system. r=fabrice (e192a95f9c)
- Bug 1198988 - Turn off some useless dump() calls r=ferjm (34fc83b236)
- Bug 1164498: Remove |DispatchBluetoothReply|, r=btian (6143335efa)
- Bug 1001757 - Add ability to store core apps outside of profile on desktop b2g; r=fabrice (f6b605e7aa)
- Bug 1155245 - Set the app status correctly for hosted certified apps in developer mode. r=fabrice (131178b80e)
- Bug 1179052 - Add some raptor markers to b2g gecko startup r=gwagner (222256fad8)
- Bug 1163904 - handle -url command line argument. r=fabrice (ee61af1ff9)
- Bug 1167275 - JS error in shell.js handleCmdLine() r=me (32e75c604f)
- Bug 1167197 - Fix GMPProvider on Android r=cpearce Bug 1181209 - Make changes to Gecko needed for b2gdroid to boot. r=fabrice (b35d3a372f)
- Bug 1158544 - Remove FTPChannelChild::mWasOpened and make the base class mWasOpened protected; r=mcmanus (9111e1bc00)
- Bug 1171716 - Part 2: Use NS_ReleaseOnMainThread in nsBaseChannel. r=froydnj (f138124f14)
- partial of Bug 1177175 - Add a UITour target inside the TP panel. (603cc719b3)
- Bug 1175545 - Dont process alt-svc on 421 r=hurley (ad0f2f6e91)
- Bug 1191291 - convert nsHttpChannel::RetargetDeliveryTo warning to log r=michal.novotny (b9c6003df8)
- Bug 1182487 - Don't try to write to HTTP cache entry in nsHttpChannel when entry is open for reading only. r=michal (b36d7014a0)
- Bug 1173069 - Don't accumulate the cache hit telemetry for intercepted channels; r=mayhemer,jdm (aaed79183d)
- Bug 1208755 HttpBaseChannel::ShouldIntercept() should not assume every channel has a LoadInfo. r=ckerschb (d55be94901)
- Bug 1201229 - Return an empty string for a header when an error occurs; r=dragana (256d0462c8)
- Bug 1048048 - add preload content policy types - web platform test updates (r=dveditz) (baa1004dd6)
- Bug 1048048 - add preload content policy types - csp changes (r=dveditz) (17914dadba)
- Bug 1048048 - add preload content policy types for stylesheets (r=cam) (29af13263a)
- Bug 1048048 - add preload content policy types (r=ehsan) (f58a32d51b)
- Bug 1201747 - Don't inspect the subject principal in StorageAllowedForPrincipal. r=mystor (4f2c100882)
- Bug 1176829 - Remove custom elements base element queue. r=smaug (03a520c13d)
- Bug 1176829 follow-up, finish removing unused member to fix bustage. CLOSED TREE (29c6150af8)
- Bug 1179909: Build fix. r=me CLOSED TREE (40e3bdb971)
- Bug 1188932 - Allow the User-Agent header to be explicitly set by requests, r=bkelly, r=jgraham (37aacbd37d)
2022-04-01 23:06:55 +08:00

191 lines
5.6 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_bluetooth_BluetoothUtils_h
#define mozilla_dom_bluetooth_BluetoothUtils_h
#include "BluetoothCommon.h"
#include "js/TypeDecls.h"
BEGIN_BLUETOOTH_NAMESPACE
class BluetoothNamedValue;
class BluetoothReplyRunnable;
class BluetoothValue;
//
// BluetoothUuid <-> uuid string conversion
//
/**
* Convert BluetoothUuid object to xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx uuid string.
*
* Note: This utility function is used by gecko internal only to convert
* BluetoothUuid created by bluetooth stack to uuid string representation.
*/
void
UuidToString(const BluetoothUuid& aUuid, nsAString& aString);
/**
* Convert xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx uuid string to BluetoothUuid object.
*
* Note: This utility function is used by gecko internal only to convert uuid
* string created by gecko back to BluetoothUuid representation.
*/
void
StringToUuid(const char* aString, BluetoothUuid& aUuid);
/**
* Convert xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx uuid string to BluetoothUuid object.
*
* This utility function is used by gecko internal only to convert uuid string
* created by gecko back to BluetoothUuid representation.
*/
void
StringToUuid(const nsAString& aString, BluetoothUuid& aUuid);
/**
* Generate a random uuid.
*
* @param aUuidString [out] String to store the generated uuid.
*/
void
GenerateUuid(nsAString &aUuidString);
//
// Generate bluetooth signal path from GattId
//
/**
* Generate bluetooth signal path from a GattId.
*
* @param aId [in] GattId value to convert.
* @param aPath [out] Bluetooth signal path generated from aId.
*/
void
GeneratePathFromGattId(const BluetoothGattId& aId,
nsAString& aPath);
//
// Register/Unregister bluetooth signal handlers
//
/**
* Register the bluetooth signal handler.
*
* @param aPath Path of the signal to be registered.
* @param aHandler The message handler object to be added into the observer
* list. Note that this function doesn't take references to it.
*/
void
RegisterBluetoothSignalHandler(const nsAString& aPath,
BluetoothSignalObserver* aHandler);
/**
* Unregister the bluetooth signal handler.
*
* @param aPath Path of the signal to be unregistered.
* @param aHandler The message handler object to be removed from the observer
* list. Note that this function doesn't take references to it.
*/
void
UnregisterBluetoothSignalHandler(const nsAString& aPath,
BluetoothSignalObserver* aHandler);
//
// Broadcast system message
//
bool
BroadcastSystemMessage(const nsAString& aType,
const BluetoothValue& aData);
bool
BroadcastSystemMessage(const nsAString& aType,
const InfallibleTArray<BluetoothNamedValue>& aData);
//
// Dispatch bluetooth reply to main thread
//
/**
* Dispatch successful bluetooth reply with NO value to reply request.
*
* @param aRunnable the runnable to reply bluetooth request.
*/
void
DispatchReplySuccess(BluetoothReplyRunnable* aRunnable);
/**
* Dispatch successful bluetooth reply with value to reply request.
*
* @param aRunnable the runnable to reply bluetooth request.
* @param aValue the BluetoothValue to reply successful request.
*/
void
DispatchReplySuccess(BluetoothReplyRunnable* aRunnable,
const BluetoothValue& aValue);
/**
* Dispatch failed bluetooth reply with error string.
*
* This function is for methods returning DOMRequest. If |aErrorStr| is not
* empty, the DOMRequest property 'error.name' would be updated to |aErrorStr|
* before callback function 'onerror' is fired.
*
* NOTE: For methods returning Promise, |aErrorStr| would be ignored and only
* STATUS_FAIL is returned in BluetoothReplyRunnable.
*
* @param aRunnable the runnable to reply bluetooth request.
* @param aErrorStr the error string to reply failed request.
*/
void
DispatchReplyError(BluetoothReplyRunnable* aRunnable,
const nsAString& aErrorStr);
/**
* Dispatch failed bluetooth reply with error status.
*
* This function is for methods returning Promise. The Promise would reject
* with an Exception object that carries nsError associated with |aStatus|.
* The name and messege of Exception (defined in dom/base/domerr.msg) are
* filled automatically during promise rejection.
*
* @param aRunnable the runnable to reply bluetooth request.
* @param aStatus the error status to reply failed request.
*/
void
DispatchReplyError(BluetoothReplyRunnable* aRunnable,
const enum BluetoothStatus aStatus);
void
DispatchStatusChangedEvent(const nsAString& aType,
const nsAString& aDeviceAddress,
bool aStatus);
//
// BluetoothNamedValue manipulation
//
/**
* Wrap literal name and value into a BluetoothNamedValue and
* append it to the array.
*/
void AppendNamedValue(InfallibleTArray<BluetoothNamedValue>& aArray,
const char* aName, const BluetoothValue& aValue);
/**
* Wrap literal name and value into a BluetoothNamedValue and
* insert it to the array.
*/
void InsertNamedValue(InfallibleTArray<BluetoothNamedValue>& aArray,
uint8_t aIndex, const char* aName,
const BluetoothValue& aValue);
END_BLUETOOTH_NAMESPACE
#endif // mozilla_dom_bluetooth_BluetoothUtils_h