当前位置: 首页>>代码示例>>C++>>正文


C++ BluetoothSignal类代码示例

本文整理汇总了C++中BluetoothSignal的典型用法代码示例。如果您正苦于以下问题:C++ BluetoothSignal类的具体用法?C++ BluetoothSignal怎么用?C++ BluetoothSignal使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BluetoothSignal类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: MOZ_ASSERT

void
BluetoothService::DistributeSignal(const BluetoothSignal& aSignal)
{
  MOZ_ASSERT(NS_IsMainThread());

  if (aSignal.path().EqualsLiteral(KEY_LOCAL_AGENT)) {
    Notify(aSignal);
    return;
  } else if (aSignal.path().EqualsLiteral(KEY_REMOTE_AGENT)) {
    Notify(aSignal);
    return;
  }

  BluetoothSignalObserverList* ol;
  if (!mBluetoothSignalObserverTable.Get(aSignal.path(), &ol)) {
#if DEBUG
    nsAutoCString msg("No observer registered for path ");
    msg.Append(NS_ConvertUTF16toUTF8(aSignal.path()));
    NS_WARNING(msg.get());
#endif
    return;
  }
  MOZ_ASSERT(ol->Length());
  ol->Broadcast(aSignal);
}
开发者ID:TelefonicaPushServer,项目名称:mozilla-central,代码行数:25,代码来源:BluetoothService.cpp

示例2: SetPropertyByValue

void
BluetoothDevice::Notify(const BluetoothSignal& aData)
{
  if (aData.name().EqualsLiteral("PropertyChanged")) {
    NS_ASSERTION(aData.value().type() == BluetoothValue::TArrayOfBluetoothNamedValue,
                 "PropertyChanged: Invalid value type");
    InfallibleTArray<BluetoothNamedValue> arr = aData.value().get_ArrayOfBluetoothNamedValue();

    NS_ASSERTION(arr.Length() == 1, "Got more than one property in a change message!");
    BluetoothNamedValue v = arr[0];
    nsString name = v.name();

    SetPropertyByValue(v);
    if (name.EqualsLiteral("Connected")) {
      DispatchTrustedEvent(mConnected ? NS_LITERAL_STRING("connected")
                           : NS_LITERAL_STRING("disconnected"));
    } else {
      nsRefPtr<BluetoothPropertyEvent> e = BluetoothPropertyEvent::Create(name);
      e->Dispatch(ToIDOMEventTarget(), NS_LITERAL_STRING("propertychanged"));
    }
  } else {
#ifdef DEBUG
    nsCString warningMsg;
    warningMsg.AssignLiteral("Not handling device signal: ");
    warningMsg.Append(NS_ConvertUTF16toUTF8(aData.name()));
    NS_WARNING(warningMsg.get());
#endif
  }
}
开发者ID:LyeSS,项目名称:mozilla-central,代码行数:29,代码来源:BluetoothDevice.cpp

示例3: NotifyStatusChanged

void
BluetoothHidManager::HandleInputPropertyChanged(const BluetoothSignal& aSignal)
{
  MOZ_ASSERT(NS_IsMainThread());
  MOZ_ASSERT(aSignal.value().type() == BluetoothValue::TArrayOfBluetoothNamedValue);

  const InfallibleTArray<BluetoothNamedValue>& arr =
    aSignal.value().get_ArrayOfBluetoothNamedValue();
  MOZ_ASSERT(arr.Length() == 1);

  const nsString& name = arr[0].name();
  const BluetoothValue& value = arr[0].value();

  if (name.EqualsLiteral("Connected")) {
    MOZ_ASSERT(value.type() == BluetoothValue::Tbool);
    MOZ_ASSERT(mConnected != value.get_bool());

    mConnected = value.get_bool();
    NotifyStatusChanged();
    if (mConnected) {
      OnConnect(EmptyString());
    } else {
      OnDisconnect(EmptyString());
    }
  }
}
开发者ID:Incognito,项目名称:mozilla-central,代码行数:26,代码来源:BluetoothHidManager.cpp

示例4: DispatchPairingEvent

void
BluetoothPairingListener::Notify(const BluetoothSignal& aData)
{
  InfallibleTArray<BluetoothNamedValue> arr;

  BluetoothValue value = aData.value();
  if (aData.name().EqualsLiteral("PairingRequest")) {

    MOZ_ASSERT(value.type() == BluetoothValue::TArrayOfBluetoothNamedValue);

    const InfallibleTArray<BluetoothNamedValue>& arr =
      value.get_ArrayOfBluetoothNamedValue();

    MOZ_ASSERT(arr.Length() == 4 &&
               arr[0].value().type() == BluetoothValue::TnsString && // address
               arr[1].value().type() == BluetoothValue::TnsString && // name
               arr[2].value().type() == BluetoothValue::TnsString && // passkey
               arr[3].value().type() == BluetoothValue::TnsString);  // type

    nsString address = arr[0].value().get_nsString();
    nsString name = arr[1].value().get_nsString();
    nsString passkey = arr[2].value().get_nsString();
    nsString type = arr[3].value().get_nsString();

    // Notify pairing listener of pairing requests
    DispatchPairingEvent(name, address, passkey, type);
  } else {
    BT_WARNING("Not handling pairing listener signal: %s",
               NS_ConvertUTF16toUTF8(aData.name()).get());
  }
}
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:31,代码来源:BluetoothPairingListener.cpp

示例5: MOZ_ASSERT

void
BluetoothService::DistributeSignal(const BluetoothSignal& aSignal)
{
  MOZ_ASSERT(NS_IsMainThread());

  BluetoothSignalObserverList* ol;
  if (!mBluetoothSignalObserverTable.Get(aSignal.path(), &ol)) {
    // If there is no BluetoohPairingListener in observer table, put the signal
    // into a pending queue of pairing requests and send a system message to
    // launch bluetooth certified app.
    if (aSignal.path().EqualsLiteral(KEY_PAIRING_LISTENER)) {
      mPendingPairReqSignals.AppendElement(aSignal);

      BT_ENSURE_TRUE_VOID_BROADCAST_SYSMSG(
        NS_LITERAL_STRING(SYS_MSG_BT_PAIRING_REQ),
        BluetoothValue(EmptyString()));
    } else {
      BT_WARNING("No observer registered for path %s",
                 NS_ConvertUTF16toUTF8(aSignal.path()).get());
    }
    return;
  }

  MOZ_ASSERT(ol->Length());
  ol->Broadcast(aSignal);
}
开发者ID:atilag,项目名称:Gecko,代码行数:26,代码来源:BluetoothService.cpp

示例6: DispatchTrustedEvent

void
BluetoothAdapter::Notify(const BluetoothSignal& aData)
{
  InfallibleTArray<BluetoothNamedValue> arr;

  BT_LOG("[A] %s: %s", __FUNCTION__, NS_ConvertUTF16toUTF8(aData.name()).get());

  BluetoothValue v = aData.value();
  if (aData.name().EqualsLiteral("DeviceFound")) {
    nsRefPtr<BluetoothDevice> device = BluetoothDevice::Create(GetOwner(), mPath, aData.value());
    nsCOMPtr<nsIDOMEvent> event;
    NS_NewDOMBluetoothDeviceEvent(getter_AddRefs(event), this, nullptr, nullptr);

    nsCOMPtr<nsIDOMBluetoothDeviceEvent> e = do_QueryInterface(event);
    e->InitBluetoothDeviceEvent(NS_LITERAL_STRING("devicefound"),
                                false, false, device);
    DispatchTrustedEvent(event);
  } else if (aData.name().EqualsLiteral("PropertyChanged")) {
    MOZ_ASSERT(v.type() == BluetoothValue::TArrayOfBluetoothNamedValue);
    const InfallibleTArray<BluetoothNamedValue>& arr =
      v.get_ArrayOfBluetoothNamedValue();

    MOZ_ASSERT(arr.Length() == 1);
    SetPropertyByValue(arr[0]);
  } else if (aData.name().EqualsLiteral(PAIRED_STATUS_CHANGED_ID) ||
             aData.name().EqualsLiteral(HFP_STATUS_CHANGED_ID) ||
             aData.name().EqualsLiteral(SCO_STATUS_CHANGED_ID) ||
             aData.name().EqualsLiteral(A2DP_STATUS_CHANGED_ID)) {
    MOZ_ASSERT(v.type() == BluetoothValue::TArrayOfBluetoothNamedValue);
    const InfallibleTArray<BluetoothNamedValue>& arr =
      v.get_ArrayOfBluetoothNamedValue();

    MOZ_ASSERT(arr.Length() == 2 &&
               arr[0].value().type() == BluetoothValue::TnsString &&
               arr[1].value().type() == BluetoothValue::Tbool);
    nsString address = arr[0].value().get_nsString();
    bool status = arr[1].value().get_bool();

    nsCOMPtr<nsIDOMEvent> event;
    NS_NewDOMBluetoothStatusChangedEvent(
      getter_AddRefs(event), this, nullptr, nullptr);

    nsCOMPtr<nsIDOMBluetoothStatusChangedEvent> e = do_QueryInterface(event);
    e->InitBluetoothStatusChangedEvent(aData.name(), false, false,
                                       address, status);
    DispatchTrustedEvent(event);
  } else {
#ifdef DEBUG
    nsCString warningMsg;
    warningMsg.AssignLiteral("Not handling adapter signal: ");
    warningMsg.Append(NS_ConvertUTF16toUTF8(aData.name()));
    NS_WARNING(warningMsg.get());
#endif
  }
}
开发者ID:Jaxo,项目名称:releases-mozilla-central,代码行数:55,代码来源:BluetoothAdapter.cpp

示例7: DispatchDeviceEvent

void
BluetoothDiscoveryHandle::Notify(const BluetoothSignal& aData)
{
  BT_LOGD("[DH] %s", NS_ConvertUTF16toUTF8(aData.name()).get());

  if (aData.name().EqualsLiteral("DeviceFound")) {
    DispatchDeviceEvent(aData.value());
  } else {
    BT_WARNING("Not handling discovery handle signal: %s",
               NS_ConvertUTF16toUTF8(aData.name()).get());
  }
}
开发者ID:CodeSpeaker,项目名称:gecko-dev,代码行数:12,代码来源:BluetoothDiscoveryHandle.cpp

示例8: if

void
BluetoothGatt::Notify(const BluetoothSignal& aData)
{
  BT_LOGD("[D] %s", NS_ConvertUTF16toUTF8(aData.name()).get());

  BluetoothValue v = aData.value();
  if (aData.name().EqualsLiteral("ClientRegistered")) {
    MOZ_ASSERT(v.type() == BluetoothValue::Tuint32_t);
    mClientIf = v.get_uint32_t();
  } else if (aData.name().EqualsLiteral("ClientUnregistered")) {
    mClientIf = 0;
  } else if (aData.name().EqualsLiteral(GATT_CONNECTION_STATE_CHANGED_ID)) {
    MOZ_ASSERT(v.type() == BluetoothValue::Tbool);

    BluetoothConnectionState state =
      v.get_bool() ? BluetoothConnectionState::Connected
                   : BluetoothConnectionState::Disconnected;
    UpdateConnectionState(state);
  } else if (aData.name().EqualsLiteral("ServicesDiscovered")) {
    HandleServicesDiscovered(v);
  } else if (aData.name().EqualsLiteral("DiscoverCompleted")) {
    MOZ_ASSERT(v.type() == BluetoothValue::Tbool);

    bool isDiscoverSuccess = v.get_bool();
    if (!isDiscoverSuccess) { // Clean all discovered attributes if failed
      mServices.Clear();
      BluetoothGattBinding::ClearCachedServicesValue(this);
    }

    mDiscoveringServices = false;
  } else {
    BT_WARNING("Not handling GATT signal: %s",
               NS_ConvertUTF16toUTF8(aData.name()).get());
  }
}
开发者ID:Mardak,项目名称:tiles-dev,代码行数:35,代码来源:BluetoothGatt.cpp

示例9: HandleCharacteristicValueUpdated

void
BluetoothGattCharacteristic::Notify(const BluetoothSignal& aData)
{
  BT_LOGD("[D] %s", NS_ConvertUTF16toUTF8(aData.name()).get());
  NS_ENSURE_TRUE_VOID(mSignalRegistered);

  BluetoothValue v = aData.value();
  if (aData.name().EqualsLiteral("CharacteristicValueUpdated")) {
    HandleCharacteristicValueUpdated(v);
  } else {
    BT_WARNING("Not handling GATT Characteristic signal: %s",
               NS_ConvertUTF16toUTF8(aData.name()).get());
  }
}
开发者ID:70599,项目名称:Waterfox,代码行数:14,代码来源:BluetoothGattCharacteristic.cpp

示例10: DispatchTrustedEvent

void
BluetoothManager::Notify(const BluetoothSignal& aData)
{
  if (aData.name().EqualsLiteral("AdapterAdded")) {
    DispatchTrustedEvent(NS_LITERAL_STRING("adapteradded"));
  } else {
#ifdef DEBUG
    nsCString warningMsg;
    warningMsg.AssignLiteral("Not handling manager signal: ");
    warningMsg.Append(NS_ConvertUTF16toUTF8(aData.name()));
    NS_WARNING(warningMsg.get());
#endif
  }
}
开发者ID:hideakihata,项目名称:mozilla-central.fgv,代码行数:14,代码来源:BluetoothManager.cpp

示例11: jsar

void
BluetoothService::Notify(const BluetoothSignal& aData)
{
  InfallibleTArray<BluetoothNamedValue> arr = aData.value().get_ArrayOfBluetoothNamedValue();
  nsString type;

  JSContext* cx = nsContentUtils::GetSafeJSContext();
  NS_ASSERTION(!::JS_IsExceptionPending(cx),
               "Shouldn't get here when an exception is pending!");
  
  JSAutoRequest jsar(cx);  
  JSObject* obj = JS_NewObject(cx, NULL, NULL, NULL);
  if (!obj) {
    NS_WARNING("Failed to new JSObject for system message!");
    return;
  }

  bool ok = SetJsObject(cx, obj, arr);
  if (!ok) {
    NS_WARNING("Failed to set properties of system message!");
    return;
  }

  if (aData.name().EqualsLiteral("RequestConfirmation")) {
    NS_ASSERTION(arr.Length() == 3, "RequestConfirmation: Wrong length of parameters");
    type.AssignLiteral("bluetooth-requestconfirmation");
  } else if (aData.name().EqualsLiteral("RequestPinCode")) {
    NS_ASSERTION(arr.Length() == 2, "RequestPinCode: Wrong length of parameters");
    type.AssignLiteral("bluetooth-requestpincode");
  } else if (aData.name().EqualsLiteral("RequestPasskey")) {
    NS_ASSERTION(arr.Length() == 2, "RequestPinCode: Wrong length of parameters");
    type.AssignLiteral("bluetooth-requestpasskey");
  } else if (aData.name().EqualsLiteral("Authorize")) {
    NS_ASSERTION(arr.Length() == 2, "Authorize: Wrong length of parameters");
    type.AssignLiteral("bluetooth-authorize");
  } else if (aData.name().EqualsLiteral("Cancel")) {
    NS_ASSERTION(arr.Length() == 0, "Cancel: Wrong length of parameters");
    type.AssignLiteral("bluetooth-cancel");
  } else if (aData.name().EqualsLiteral("PairedStatusChanged")) {
    NS_ASSERTION(arr.Length() == 1, "PairedStatusChagned: Wrong length of parameters");
    type.AssignLiteral("bluetooth-pairingstatuschanged");
  } else {
#ifdef DEBUG
    nsCString warningMsg;
    warningMsg.AssignLiteral("Not handling service signal: ");
    warningMsg.Append(NS_ConvertUTF16toUTF8(aData.name()));
    NS_WARNING(warningMsg.get());
#endif
  }

  nsCOMPtr<nsISystemMessagesInternal> systemMessenger =
    do_GetService("@mozilla.org/system-message-internal;1");

  if (!systemMessenger) {
    NS_WARNING("Failed to get SystemMessenger service!");
    return;
  }
  systemMessenger->BroadcastMessage(type, OBJECT_TO_JSVAL(obj));
}
开发者ID:mokerjoke,项目名称:mozilla-central,代码行数:59,代码来源:BluetoothService.cpp

示例12: HandleIncludedServicesDiscovered

void
BluetoothGattService::Notify(const BluetoothSignal& aData)
{
  BT_LOGD("[D] %s", NS_ConvertUTF16toUTF8(aData.name()).get());

  BluetoothValue v = aData.value();
  if (aData.name().EqualsLiteral("IncludedServicesDiscovered")) {
    HandleIncludedServicesDiscovered(v);
  } else if (aData.name().EqualsLiteral("CharacteristicsDiscovered")) {
    HandleCharacteristicsDiscovered(v);
  } else {
    BT_WARNING("Not handling GATT Service signal: %s",
               NS_ConvertUTF16toUTF8(aData.name()).get());
  }
}
开发者ID:Mardak,项目名称:tiles-dev,代码行数:15,代码来源:BluetoothGattService.cpp

示例13: MOZ_ASSERT

void
BluetoothService::DistributeSignal(const BluetoothSignal& aSignal)
{
  MOZ_ASSERT(NS_IsMainThread());
  // Notify observers that a message has been sent
  BluetoothSignalObserverList* ol;
  if (!mBluetoothSignalObserverTable.Get(aSignal.path(), &ol)) {
#if DEBUG
    nsAutoCString msg("No observer registered for path ");
    msg.Append(NS_ConvertUTF16toUTF8(aSignal.path()));
    NS_WARNING(msg.get());
#endif
    return;
  }
  MOZ_ASSERT(ol->Length());
  ol->Broadcast(aSignal);
}
开发者ID:mokerjoke,项目名称:mozilla-central,代码行数:17,代码来源:BluetoothService.cpp

示例14:

void
BluetoothManager::Notify(const BluetoothSignal& aData)
{
#ifdef DEBUG
  nsCString warningMsg;
  warningMsg.AssignLiteral("Not handling manager signal: ");
  warningMsg.Append(NS_ConvertUTF16toUTF8(aData.name()));
  NS_WARNING(warningMsg.get());
#endif
}
开发者ID:Ajunboys,项目名称:mozilla-os2,代码行数:10,代码来源:BluetoothManager.cpp

示例15: DispatchTrustedEvent

void
BluetoothManager::Notify(const BluetoothSignal& aData)
{
  BT_LOGD("[M] %s: %s", __FUNCTION__, NS_ConvertUTF16toUTF8(aData.name()).get());

  if (aData.name().EqualsLiteral("AdapterAdded")) {
    DispatchTrustedEvent(NS_LITERAL_STRING("adapteradded"));
  } else if (aData.name().EqualsLiteral("Enabled")) {
    DispatchTrustedEvent(NS_LITERAL_STRING("enabled"));
  } else if (aData.name().EqualsLiteral("Disabled")) {
    DispatchTrustedEvent(NS_LITERAL_STRING("disabled"));
  } else {
#ifdef DEBUG
    nsCString warningMsg;
    warningMsg.AssignLiteral("Not handling manager signal: ");
    warningMsg.Append(NS_ConvertUTF16toUTF8(aData.name()));
    BT_WARNING(warningMsg.get());
#endif
  }
}
开发者ID:jedp,项目名称:gecko-dev,代码行数:20,代码来源:BluetoothManager.cpp


注:本文中的BluetoothSignal类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。