зеркало из https://github.com/mozilla/gecko-dev.git
Merge b2ginbound to central, a=merge
--HG-- extra : commitid : BSBFtYPaA87
This commit is contained in:
Коммит
234f7ca3e5
|
@ -15,7 +15,7 @@
|
|||
<project name="platform_build" path="build" remote="b2g" revision="8d83715f08b7849f16a0dfc88f78d5c3a89c0a54">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="e8c15ae4e5324a210000ee0a869a962aa542009f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="54167ef91545c948e44098deb9f721210890eaf0"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="fake-qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="939b377d55a2f081d94029a30a75d05e5a20daf3"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="9a58f2e395da17c252f61f28900b5b09aeb813bd"/>
|
||||
|
@ -24,7 +24,7 @@
|
|||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
|
||||
<project name="valgrind" path="external/valgrind" remote="b2g" revision="5f931350fbc87c3df9db8b0ceb37734b8b471593"/>
|
||||
<project name="vex" path="external/VEX" remote="b2g" revision="48d8c7c950745f1b166b42125e6f0d3293d71636"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="f009c98ba697582c857c5788e5cdf0640e287ae6"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="94bbf7890326d37f03fd2a6822b6618b08bec8e2"/>
|
||||
<project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
|
||||
<!-- Stock Android things -->
|
||||
<project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="95bb5b66b3ec5769c3de8d3f25d681787418e7d2"/>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<project name="platform_build" path="build" remote="b2g" revision="8d83715f08b7849f16a0dfc88f78d5c3a89c0a54">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="e8c15ae4e5324a210000ee0a869a962aa542009f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="54167ef91545c948e44098deb9f721210890eaf0"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="fake-qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="939b377d55a2f081d94029a30a75d05e5a20daf3"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="9a58f2e395da17c252f61f28900b5b09aeb813bd"/>
|
||||
|
@ -24,7 +24,7 @@
|
|||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
|
||||
<project name="valgrind" path="external/valgrind" remote="b2g" revision="5f931350fbc87c3df9db8b0ceb37734b8b471593"/>
|
||||
<project name="vex" path="external/VEX" remote="b2g" revision="48d8c7c950745f1b166b42125e6f0d3293d71636"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="f009c98ba697582c857c5788e5cdf0640e287ae6"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="94bbf7890326d37f03fd2a6822b6618b08bec8e2"/>
|
||||
<project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
|
||||
<!-- Stock Android things -->
|
||||
<project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="95bb5b66b3ec5769c3de8d3f25d681787418e7d2"/>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="e8c15ae4e5324a210000ee0a869a962aa542009f"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="54167ef91545c948e44098deb9f721210890eaf0"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="9a58f2e395da17c252f61f28900b5b09aeb813bd"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
|
||||
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="cb4604d5a578efd027277059ce3e0f6e3af59bd1"/>
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
</project>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="e8c15ae4e5324a210000ee0a869a962aa542009f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="54167ef91545c948e44098deb9f721210890eaf0"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="9a58f2e395da17c252f61f28900b5b09aeb813bd"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="ac7e9ae8a24ab4a3f3da801ca53f95f39a32b89f"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="f009c98ba697582c857c5788e5cdf0640e287ae6"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="94bbf7890326d37f03fd2a6822b6618b08bec8e2"/>
|
||||
<project name="valgrind" path="external/valgrind" remote="b2g" revision="5f931350fbc87c3df9db8b0ceb37734b8b471593"/>
|
||||
<project name="vex" path="external/VEX" remote="b2g" revision="48d8c7c950745f1b166b42125e6f0d3293d71636"/>
|
||||
<project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<project name="platform_build" path="build" remote="b2g" revision="8d83715f08b7849f16a0dfc88f78d5c3a89c0a54">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="e8c15ae4e5324a210000ee0a869a962aa542009f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="54167ef91545c948e44098deb9f721210890eaf0"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="9a58f2e395da17c252f61f28900b5b09aeb813bd"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
|
||||
|
@ -23,7 +23,7 @@
|
|||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
|
||||
<project name="valgrind" path="external/valgrind" remote="b2g" revision="5f931350fbc87c3df9db8b0ceb37734b8b471593"/>
|
||||
<project name="vex" path="external/VEX" remote="b2g" revision="48d8c7c950745f1b166b42125e6f0d3293d71636"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="f009c98ba697582c857c5788e5cdf0640e287ae6"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="94bbf7890326d37f03fd2a6822b6618b08bec8e2"/>
|
||||
<project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
|
||||
<!-- Stock Android things -->
|
||||
<project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="f92a936f2aa97526d4593386754bdbf02db07a12"/>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<project name="platform_build" path="build" remote="b2g" revision="c9d4fe680662ee44a4bdea42ae00366f5df399cf">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="e8c15ae4e5324a210000ee0a869a962aa542009f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="54167ef91545c948e44098deb9f721210890eaf0"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="9a58f2e395da17c252f61f28900b5b09aeb813bd"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
|
||||
|
@ -23,7 +23,7 @@
|
|||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
|
||||
<project name="valgrind" path="external/valgrind" remote="b2g" revision="5f931350fbc87c3df9db8b0ceb37734b8b471593"/>
|
||||
<project name="vex" path="external/VEX" remote="b2g" revision="48d8c7c950745f1b166b42125e6f0d3293d71636"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="f009c98ba697582c857c5788e5cdf0640e287ae6"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="94bbf7890326d37f03fd2a6822b6618b08bec8e2"/>
|
||||
<project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
|
||||
<!-- Stock Android things -->
|
||||
<project groups="pdk,linux" name="platform/prebuilts/clang/linux-x86/host/3.5" path="prebuilts/clang/linux-x86/host/3.5" revision="ffc05a232799fe8fcb3e47b7440b52b1fb4244c0"/>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="e8c15ae4e5324a210000ee0a869a962aa542009f"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="54167ef91545c948e44098deb9f721210890eaf0"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="9a58f2e395da17c252f61f28900b5b09aeb813bd"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
|
||||
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="cb4604d5a578efd027277059ce3e0f6e3af59bd1"/>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<project name="platform_build" path="build" remote="b2g" revision="8d83715f08b7849f16a0dfc88f78d5c3a89c0a54">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="e8c15ae4e5324a210000ee0a869a962aa542009f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="54167ef91545c948e44098deb9f721210890eaf0"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="fake-qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="939b377d55a2f081d94029a30a75d05e5a20daf3"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="9a58f2e395da17c252f61f28900b5b09aeb813bd"/>
|
||||
|
@ -24,7 +24,7 @@
|
|||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
|
||||
<project name="valgrind" path="external/valgrind" remote="b2g" revision="5f931350fbc87c3df9db8b0ceb37734b8b471593"/>
|
||||
<project name="vex" path="external/VEX" remote="b2g" revision="48d8c7c950745f1b166b42125e6f0d3293d71636"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="f009c98ba697582c857c5788e5cdf0640e287ae6"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="94bbf7890326d37f03fd2a6822b6618b08bec8e2"/>
|
||||
<project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
|
||||
<!-- Stock Android things -->
|
||||
<project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="95bb5b66b3ec5769c3de8d3f25d681787418e7d2"/>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"git": {
|
||||
"git_revision": "e8c15ae4e5324a210000ee0a869a962aa542009f",
|
||||
"git_revision": "54167ef91545c948e44098deb9f721210890eaf0",
|
||||
"remote": "https://git.mozilla.org/releases/gaia.git",
|
||||
"branch": ""
|
||||
},
|
||||
"revision": "6394e546d2ec13a35c18d2c2bfb66e238c040fdc",
|
||||
"revision": "503587ee1e9b599ee7f2f8a0be7256141c4c48c6",
|
||||
"repo_path": "integration/gaia-central"
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<project name="platform_build" path="build" remote="b2g" revision="8d83715f08b7849f16a0dfc88f78d5c3a89c0a54">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="e8c15ae4e5324a210000ee0a869a962aa542009f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="54167ef91545c948e44098deb9f721210890eaf0"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="fake-qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="939b377d55a2f081d94029a30a75d05e5a20daf3"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="9a58f2e395da17c252f61f28900b5b09aeb813bd"/>
|
||||
|
@ -24,7 +24,7 @@
|
|||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
|
||||
<project name="valgrind" path="external/valgrind" remote="b2g" revision="5f931350fbc87c3df9db8b0ceb37734b8b471593"/>
|
||||
<project name="vex" path="external/VEX" remote="b2g" revision="48d8c7c950745f1b166b42125e6f0d3293d71636"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="f009c98ba697582c857c5788e5cdf0640e287ae6"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="94bbf7890326d37f03fd2a6822b6618b08bec8e2"/>
|
||||
<project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
|
||||
<!-- Stock Android things -->
|
||||
<project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="f92a936f2aa97526d4593386754bdbf02db07a12"/>
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="fake-qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="939b377d55a2f081d94029a30a75d05e5a20daf3"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="e8c15ae4e5324a210000ee0a869a962aa542009f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="54167ef91545c948e44098deb9f721210890eaf0"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="9a58f2e395da17c252f61f28900b5b09aeb813bd"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="ac7e9ae8a24ab4a3f3da801ca53f95f39a32b89f"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="f009c98ba697582c857c5788e5cdf0640e287ae6"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="94bbf7890326d37f03fd2a6822b6618b08bec8e2"/>
|
||||
<project name="valgrind" path="external/valgrind" remote="b2g" revision="5f931350fbc87c3df9db8b0ceb37734b8b471593"/>
|
||||
<project name="vex" path="external/VEX" remote="b2g" revision="48d8c7c950745f1b166b42125e6f0d3293d71636"/>
|
||||
<project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<project name="platform_build" path="build" remote="b2g" revision="c9d4fe680662ee44a4bdea42ae00366f5df399cf">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="e8c15ae4e5324a210000ee0a869a962aa542009f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="54167ef91545c948e44098deb9f721210890eaf0"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="fake-qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="939b377d55a2f081d94029a30a75d05e5a20daf3"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="9a58f2e395da17c252f61f28900b5b09aeb813bd"/>
|
||||
|
@ -24,7 +24,7 @@
|
|||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
|
||||
<project name="valgrind" path="external/valgrind" remote="b2g" revision="5f931350fbc87c3df9db8b0ceb37734b8b471593"/>
|
||||
<project name="vex" path="external/VEX" remote="b2g" revision="48d8c7c950745f1b166b42125e6f0d3293d71636"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="f009c98ba697582c857c5788e5cdf0640e287ae6"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="94bbf7890326d37f03fd2a6822b6618b08bec8e2"/>
|
||||
<project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
|
||||
<!-- Stock Android things -->
|
||||
<project groups="pdk,linux" name="platform/prebuilts/clang/linux-x86/host/3.5" path="prebuilts/clang/linux-x86/host/3.5" revision="ffc05a232799fe8fcb3e47b7440b52b1fb4244c0"/>
|
||||
|
|
|
@ -130,6 +130,11 @@ AudioChannelAgent::InitInternal(nsIDOMWindow* aWindow, int32_t aChannelType,
|
|||
mCallback = aCallback;
|
||||
}
|
||||
|
||||
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
||||
("AudioChannelAgent, InitInternal, this = %p, type = %d, "
|
||||
"owner = %p, hasCallback = %d\n", this, mAudioChannelType,
|
||||
mWindow.get(), (!!mCallback || !!mWeakCallback)));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -158,6 +163,10 @@ NS_IMETHODIMP AudioChannelAgent::NotifyStartedPlaying(uint32_t aNotifyPlayback,
|
|||
|
||||
service->GetState(mWindow, mAudioChannelType, aVolume, aMuted);
|
||||
|
||||
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
||||
("AudioChannelAgent, NotifyStartedPlaying, this = %p, mute = %d, "
|
||||
"volume = %f\n", this, *aMuted, *aVolume));
|
||||
|
||||
mNotifyPlayback = aNotifyPlayback;
|
||||
mIsRegToService = true;
|
||||
return NS_OK;
|
||||
|
@ -170,6 +179,9 @@ NS_IMETHODIMP AudioChannelAgent::NotifyStoppedPlaying()
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
||||
("AudioChannelAgent, NotifyStoppedPlaying, this = %p\n", this));
|
||||
|
||||
RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
|
||||
service->UnregisterAudioChannelAgent(this, mNotifyPlayback);
|
||||
mIsRegToService = false;
|
||||
|
@ -200,6 +212,10 @@ AudioChannelAgent::WindowVolumeChanged()
|
|||
RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
|
||||
service->GetState(mWindow, mAudioChannelType, &volume, &muted);
|
||||
|
||||
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
||||
("AudioChannelAgent, WindowVolumeChanged, this = %p, mute = %d, "
|
||||
"volume = %f\n", this, muted, volume));
|
||||
|
||||
callback->WindowVolumeChanged(volume, muted);
|
||||
}
|
||||
|
||||
|
|
|
@ -78,6 +78,11 @@ public:
|
|||
mActive
|
||||
? MOZ_UTF16("active")
|
||||
: MOZ_UTF16("inactive"));
|
||||
|
||||
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
||||
("NotifyChannelActiveRunnable, type = %d, active = %d\n",
|
||||
mAudioChannel, mActive));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -178,6 +183,16 @@ AudioChannelService::GetOrCreate()
|
|||
return service.forget();
|
||||
}
|
||||
|
||||
/* static */ PRLogModuleInfo*
|
||||
AudioChannelService::GetAudioChannelLog()
|
||||
{
|
||||
static PRLogModuleInfo *gAudioChannelLog;
|
||||
if (!gAudioChannelLog) {
|
||||
gAudioChannelLog = PR_NewLogModule("AudioChannel");
|
||||
}
|
||||
return gAudioChannelLog;
|
||||
}
|
||||
|
||||
void
|
||||
AudioChannelService::Shutdown()
|
||||
{
|
||||
|
@ -719,6 +734,10 @@ AudioChannelService::SetAudioChannelVolume(nsPIDOMWindow* aWindow,
|
|||
MOZ_ASSERT(aWindow);
|
||||
MOZ_ASSERT(aWindow->IsOuterWindow());
|
||||
|
||||
MOZ_LOG(GetAudioChannelLog(), LogLevel::Debug,
|
||||
("AudioChannelService, SetAudioChannelVolume, window = %p, type = %d, "
|
||||
"volume = %d\n", aWindow, aAudioChannel, aVolume));
|
||||
|
||||
AudioChannelWindow* winData = GetOrCreateWindowData(aWindow);
|
||||
winData->mChannels[(uint32_t)aAudioChannel].mVolume = aVolume;
|
||||
RefreshAgentsVolume(aWindow);
|
||||
|
@ -773,6 +792,10 @@ AudioChannelService::SetAudioChannelMuted(nsPIDOMWindow* aWindow,
|
|||
MOZ_ASSERT(aWindow);
|
||||
MOZ_ASSERT(aWindow->IsOuterWindow());
|
||||
|
||||
MOZ_LOG(GetAudioChannelLog(), LogLevel::Debug,
|
||||
("AudioChannelService, SetAudioChannelMuted, window = %p, type = %d, "
|
||||
"mute = %d\n", aWindow, aAudioChannel, aMuted));
|
||||
|
||||
if (aAudioChannel == AudioChannel::System) {
|
||||
// Workaround for bug1183033, system channel type can always playback.
|
||||
return;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
class nsIRunnable;
|
||||
class nsPIDOMWindow;
|
||||
struct PRLogModuleInfo;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -45,6 +46,8 @@ public:
|
|||
|
||||
static bool IsAudioChannelMutedByDefault();
|
||||
|
||||
static PRLogModuleInfo* GetAudioChannelLog();
|
||||
|
||||
/**
|
||||
* Any audio channel agent that starts playing should register itself to
|
||||
* this service, sharing the AudioChannel.
|
||||
|
|
|
@ -100,10 +100,6 @@
|
|||
#include "nsWrapperCacheInlines.h"
|
||||
#include "mozilla/dom/HTMLCollectionBinding.h"
|
||||
|
||||
#include "nsIDOMMozSmsMessage.h"
|
||||
#include "nsIDOMMozMmsMessage.h"
|
||||
#include "nsIDOMMozMobileMessageThread.h"
|
||||
|
||||
#ifdef MOZ_B2G_FM
|
||||
#include "FMRadio.h"
|
||||
#endif
|
||||
|
@ -243,15 +239,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
|||
NS_DEFINE_CLASSINFO_DATA(CSSSupportsRule, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(MozSmsMessage, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(MozMmsMessage, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(MozMobileMessageThread, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(CSSFontFaceRule, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
|
@ -651,18 +638,6 @@ nsDOMClassInfo::Init()
|
|||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSSupportsRule)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(MozSmsMessage, nsIDOMMozSmsMessage)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsMessage)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(MozMmsMessage, nsIDOMMozMmsMessage)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozMmsMessage)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(MozMobileMessageThread, nsIDOMMozMobileMessageThread)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozMobileMessageThread)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(CSSFontFaceRule, nsIDOMCSSFontFaceRule)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSFontFaceRule)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
|
|
@ -32,10 +32,6 @@ DOMCI_CLASS(XULTreeBuilder)
|
|||
DOMCI_CLASS(CSSMozDocumentRule)
|
||||
DOMCI_CLASS(CSSSupportsRule)
|
||||
|
||||
DOMCI_CLASS(MozSmsMessage)
|
||||
DOMCI_CLASS(MozMmsMessage)
|
||||
DOMCI_CLASS(MozMobileMessageThread)
|
||||
|
||||
// @font-face in CSS
|
||||
DOMCI_CLASS(CSSFontFaceRule)
|
||||
|
||||
|
|
|
@ -1977,12 +1977,10 @@ addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True)
|
|||
addExternalIface('MenuBuilder', nativeType='nsIMenuBuilder', notflattened=True)
|
||||
addExternalIface('MozControllers', nativeType='nsIControllers')
|
||||
addExternalIface('MozFrameLoader', nativeType='nsIFrameLoader', notflattened=True)
|
||||
addExternalIface('MozMmsMessage')
|
||||
addExternalIface('MozObserver', nativeType='nsIObserver', notflattened=True)
|
||||
addExternalIface('MozRDFCompositeDataSource', nativeType='nsIRDFCompositeDataSource',
|
||||
notflattened=True)
|
||||
addExternalIface('MozRDFResource', nativeType='nsIRDFResource', notflattened=True)
|
||||
addExternalIface('MozSmsMessage')
|
||||
addExternalIface('MozTreeView', nativeType='nsITreeView',
|
||||
headerFile='nsITreeView.h', notflattened=True)
|
||||
addExternalIface('MozWakeLockListener', headerFile='nsIDOMWakeLockListener.h')
|
||||
|
|
|
@ -70,32 +70,6 @@ USING_BLUETOOTH_NAMESPACE
|
|||
static BluetoothInterface* sBtInterface;
|
||||
static nsTArray<RefPtr<BluetoothProfileController> > sControllerArray;
|
||||
|
||||
/*
|
||||
* Static methods
|
||||
*/
|
||||
|
||||
ControlPlayStatus
|
||||
BluetoothServiceBluedroid::PlayStatusStringToControlPlayStatus(
|
||||
const nsAString& aPlayStatus)
|
||||
{
|
||||
ControlPlayStatus playStatus = ControlPlayStatus::PLAYSTATUS_UNKNOWN;
|
||||
if (aPlayStatus.EqualsLiteral("STOPPED")) {
|
||||
playStatus = ControlPlayStatus::PLAYSTATUS_STOPPED;
|
||||
} else if (aPlayStatus.EqualsLiteral("PLAYING")) {
|
||||
playStatus = ControlPlayStatus::PLAYSTATUS_PLAYING;
|
||||
} else if (aPlayStatus.EqualsLiteral("PAUSED")) {
|
||||
playStatus = ControlPlayStatus::PLAYSTATUS_PAUSED;
|
||||
} else if (aPlayStatus.EqualsLiteral("FWD_SEEK")) {
|
||||
playStatus = ControlPlayStatus::PLAYSTATUS_FWD_SEEK;
|
||||
} else if (aPlayStatus.EqualsLiteral("REV_SEEK")) {
|
||||
playStatus = ControlPlayStatus::PLAYSTATUS_REV_SEEK;
|
||||
} else if (aPlayStatus.EqualsLiteral("ERROR")) {
|
||||
playStatus = ControlPlayStatus::PLAYSTATUS_ERROR;
|
||||
}
|
||||
|
||||
return playStatus;
|
||||
}
|
||||
|
||||
class BluetoothServiceBluedroid::EnableResultHandler final
|
||||
: public BluetoothResultHandler
|
||||
{
|
||||
|
@ -352,7 +326,7 @@ BluetoothServiceBluedroid::StopInternal(BluetoothReplyRunnable* aRunnable)
|
|||
|
||||
void
|
||||
BluetoothServiceBluedroid::StartLeScanInternal(
|
||||
const nsTArray<nsString>& aServiceUuids,
|
||||
const nsTArray<BluetoothUuid>& aServiceUuids,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
@ -361,18 +335,12 @@ BluetoothServiceBluedroid::StartLeScanInternal(
|
|||
BluetoothGattManager* gatt = BluetoothGattManager::Get();
|
||||
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
|
||||
|
||||
nsTArray<BluetoothUuid> serviceUuids(aServiceUuids.Length());
|
||||
|
||||
for (auto i = 0ul; i < aServiceUuids.Length(); ++i) {
|
||||
StringToUuid(aServiceUuids[i], serviceUuids[i]);
|
||||
}
|
||||
|
||||
gatt->StartLeScan(serviceUuids, aRunnable);
|
||||
gatt->StartLeScan(aServiceUuids, aRunnable);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::StopLeScanInternal(
|
||||
const nsAString& aScanUuid,
|
||||
const BluetoothUuid& aScanUuid,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
@ -381,15 +349,12 @@ BluetoothServiceBluedroid::StopLeScanInternal(
|
|||
BluetoothGattManager* gatt = BluetoothGattManager::Get();
|
||||
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
|
||||
|
||||
BluetoothUuid scanUuid;
|
||||
StringToUuid(aScanUuid, scanUuid);
|
||||
|
||||
gatt->StopLeScan(scanUuid, aRunnable);
|
||||
gatt->StopLeScan(aScanUuid, aRunnable);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::ConnectGattClientInternal(
|
||||
const nsAString& aAppUuid, const nsAString& aDeviceAddress,
|
||||
const BluetoothUuid& aAppUuid, const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
@ -399,21 +364,12 @@ BluetoothServiceBluedroid::ConnectGattClientInternal(
|
|||
BluetoothGattManager* gatt = BluetoothGattManager::Get();
|
||||
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
StringToUuid(aAppUuid, appUuid);
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
if (NS_FAILED(StringToAddress(aDeviceAddress, deviceAddress))) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
gatt->Connect(appUuid, deviceAddress, aRunnable);
|
||||
gatt->Connect(aAppUuid, aDeviceAddress, aRunnable);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::DisconnectGattClientInternal(
|
||||
const nsAString& aAppUuid, const nsAString& aDeviceAddress,
|
||||
const BluetoothUuid& aAppUuid, const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
@ -423,21 +379,12 @@ BluetoothServiceBluedroid::DisconnectGattClientInternal(
|
|||
BluetoothGattManager* gatt = BluetoothGattManager::Get();
|
||||
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
StringToUuid(aAppUuid, appUuid);
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
if (NS_FAILED(StringToAddress(aDeviceAddress, deviceAddress))) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
gatt->Disconnect(appUuid, deviceAddress, aRunnable);
|
||||
gatt->Disconnect(aAppUuid, aDeviceAddress, aRunnable);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::DiscoverGattServicesInternal(
|
||||
const nsAString& aAppUuid, BluetoothReplyRunnable* aRunnable)
|
||||
const BluetoothUuid& aAppUuid, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
|
@ -446,15 +393,12 @@ BluetoothServiceBluedroid::DiscoverGattServicesInternal(
|
|||
BluetoothGattManager* gatt = BluetoothGattManager::Get();
|
||||
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
StringToUuid(aAppUuid, appUuid);
|
||||
|
||||
gatt->Discover(appUuid, aRunnable);
|
||||
gatt->Discover(aAppUuid, aRunnable);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::GattClientStartNotificationsInternal(
|
||||
const nsAString& aAppUuid, const BluetoothGattServiceId& aServId,
|
||||
const BluetoothUuid& aAppUuid, const BluetoothGattServiceId& aServId,
|
||||
const BluetoothGattId& aCharId, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
@ -464,15 +408,12 @@ BluetoothServiceBluedroid::GattClientStartNotificationsInternal(
|
|||
BluetoothGattManager* gatt = BluetoothGattManager::Get();
|
||||
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
StringToUuid(aAppUuid, appUuid);
|
||||
|
||||
gatt->RegisterNotifications(appUuid, aServId, aCharId, aRunnable);
|
||||
gatt->RegisterNotifications(aAppUuid, aServId, aCharId, aRunnable);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::GattClientStopNotificationsInternal(
|
||||
const nsAString& aAppUuid, const BluetoothGattServiceId& aServId,
|
||||
const BluetoothUuid& aAppUuid, const BluetoothGattServiceId& aServId,
|
||||
const BluetoothGattId& aCharId, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
@ -482,10 +423,7 @@ BluetoothServiceBluedroid::GattClientStopNotificationsInternal(
|
|||
BluetoothGattManager* gatt = BluetoothGattManager::Get();
|
||||
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
StringToUuid(aAppUuid, appUuid);
|
||||
|
||||
gatt->DeregisterNotifications(appUuid, aServId, aCharId, aRunnable);
|
||||
gatt->DeregisterNotifications(aAppUuid, aServId, aCharId, aRunnable);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -504,7 +442,7 @@ BluetoothServiceBluedroid::UnregisterGattClientInternal(
|
|||
|
||||
void
|
||||
BluetoothServiceBluedroid::GattClientReadRemoteRssiInternal(
|
||||
int aClientIf, const nsAString& aDeviceAddress,
|
||||
int aClientIf, const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
@ -514,18 +452,12 @@ BluetoothServiceBluedroid::GattClientReadRemoteRssiInternal(
|
|||
BluetoothGattManager* gatt = BluetoothGattManager::Get();
|
||||
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
if (NS_FAILED(StringToAddress(aDeviceAddress, deviceAddress))) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
gatt->ReadRemoteRssi(aClientIf, deviceAddress, aRunnable);
|
||||
gatt->ReadRemoteRssi(aClientIf, aDeviceAddress, aRunnable);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::GattClientReadCharacteristicValueInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
const BluetoothGattId& aCharacteristicId,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
|
@ -537,16 +469,13 @@ BluetoothServiceBluedroid::GattClientReadCharacteristicValueInternal(
|
|||
BluetoothGattManager* gatt = BluetoothGattManager::Get();
|
||||
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
StringToUuid(aAppUuid, appUuid);
|
||||
|
||||
gatt->ReadCharacteristicValue(appUuid, aServiceId, aCharacteristicId,
|
||||
gatt->ReadCharacteristicValue(aAppUuid, aServiceId, aCharacteristicId,
|
||||
aRunnable);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::GattClientWriteCharacteristicValueInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
const BluetoothGattId& aCharacteristicId,
|
||||
const BluetoothGattWriteType& aWriteType,
|
||||
|
@ -560,16 +489,13 @@ BluetoothServiceBluedroid::GattClientWriteCharacteristicValueInternal(
|
|||
BluetoothGattManager* gatt = BluetoothGattManager::Get();
|
||||
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
StringToUuid(aAppUuid, appUuid);
|
||||
|
||||
gatt->WriteCharacteristicValue(appUuid, aServiceId, aCharacteristicId,
|
||||
gatt->WriteCharacteristicValue(aAppUuid, aServiceId, aCharacteristicId,
|
||||
aWriteType, aValue, aRunnable);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::GattClientReadDescriptorValueInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
const BluetoothGattId& aCharacteristicId,
|
||||
const BluetoothGattId& aDescriptorId,
|
||||
|
@ -582,16 +508,13 @@ BluetoothServiceBluedroid::GattClientReadDescriptorValueInternal(
|
|||
BluetoothGattManager* gatt = BluetoothGattManager::Get();
|
||||
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
StringToUuid(aAppUuid, appUuid);
|
||||
|
||||
gatt->ReadDescriptorValue(appUuid, aServiceId, aCharacteristicId,
|
||||
gatt->ReadDescriptorValue(aAppUuid, aServiceId, aCharacteristicId,
|
||||
aDescriptorId, aRunnable);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::GattClientWriteDescriptorValueInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
const BluetoothGattId& aCharacteristicId,
|
||||
const BluetoothGattId& aDescriptorId,
|
||||
|
@ -605,17 +528,14 @@ BluetoothServiceBluedroid::GattClientWriteDescriptorValueInternal(
|
|||
BluetoothGattManager* gatt = BluetoothGattManager::Get();
|
||||
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
StringToUuid(aAppUuid, appUuid);
|
||||
|
||||
gatt->WriteDescriptorValue(appUuid, aServiceId, aCharacteristicId,
|
||||
gatt->WriteDescriptorValue(aAppUuid, aServiceId, aCharacteristicId,
|
||||
aDescriptorId, aValue, aRunnable);
|
||||
}
|
||||
|
||||
// GATT Server
|
||||
void
|
||||
BluetoothServiceBluedroid::GattServerConnectPeripheralInternal(
|
||||
const nsAString& aAppUuid, const nsAString& aAddress,
|
||||
const BluetoothUuid& aAppUuid, const BluetoothAddress& aAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
@ -625,21 +545,12 @@ BluetoothServiceBluedroid::GattServerConnectPeripheralInternal(
|
|||
BluetoothGattManager* gatt = BluetoothGattManager::Get();
|
||||
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
StringToUuid(aAppUuid, appUuid);
|
||||
|
||||
BluetoothAddress address;
|
||||
if (NS_FAILED(StringToAddress(aAddress, address))) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
gatt->ConnectPeripheral(appUuid, address, aRunnable);
|
||||
gatt->ConnectPeripheral(aAppUuid, aAddress, aRunnable);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::GattServerDisconnectPeripheralInternal(
|
||||
const nsAString& aAppUuid, const nsAString& aAddress,
|
||||
const BluetoothUuid& aAppUuid, const BluetoothAddress& aAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
@ -649,16 +560,7 @@ BluetoothServiceBluedroid::GattServerDisconnectPeripheralInternal(
|
|||
BluetoothGattManager* gatt = BluetoothGattManager::Get();
|
||||
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
StringToUuid(aAppUuid, appUuid);
|
||||
|
||||
BluetoothAddress address;
|
||||
if (NS_FAILED(StringToAddress(aAddress, address))) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
gatt->DisconnectPeripheral(appUuid, address, aRunnable);
|
||||
gatt->DisconnectPeripheral(aAppUuid, aAddress, aRunnable);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -677,7 +579,7 @@ BluetoothServiceBluedroid::UnregisterGattServerInternal(
|
|||
|
||||
void
|
||||
BluetoothServiceBluedroid::GattServerAddServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
uint16_t aHandleCount,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
|
@ -689,15 +591,12 @@ BluetoothServiceBluedroid::GattServerAddServiceInternal(
|
|||
BluetoothGattManager* gatt = BluetoothGattManager::Get();
|
||||
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
StringToUuid(aAppUuid, appUuid);
|
||||
|
||||
gatt->ServerAddService(appUuid, aServiceId, aHandleCount, aRunnable);
|
||||
gatt->ServerAddService(aAppUuid, aServiceId, aHandleCount, aRunnable);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::GattServerAddIncludedServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
const BluetoothAttributeHandle& aIncludedServiceHandle,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
|
@ -709,10 +608,7 @@ BluetoothServiceBluedroid::GattServerAddIncludedServiceInternal(
|
|||
BluetoothGattManager* gatt = BluetoothGattManager::Get();
|
||||
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
StringToUuid(aAppUuid, appUuid);
|
||||
|
||||
gatt->ServerAddIncludedService(appUuid,
|
||||
gatt->ServerAddIncludedService(aAppUuid,
|
||||
aServiceHandle,
|
||||
aIncludedServiceHandle,
|
||||
aRunnable);
|
||||
|
@ -720,7 +616,7 @@ BluetoothServiceBluedroid::GattServerAddIncludedServiceInternal(
|
|||
|
||||
void
|
||||
BluetoothServiceBluedroid::GattServerAddCharacteristicInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
const BluetoothUuid& aCharacteristicUuid,
|
||||
BluetoothGattAttrPerm aPermissions,
|
||||
|
@ -734,10 +630,7 @@ BluetoothServiceBluedroid::GattServerAddCharacteristicInternal(
|
|||
BluetoothGattManager* gatt = BluetoothGattManager::Get();
|
||||
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
StringToUuid(aAppUuid, appUuid);
|
||||
|
||||
gatt->ServerAddCharacteristic(appUuid,
|
||||
gatt->ServerAddCharacteristic(aAppUuid,
|
||||
aServiceHandle,
|
||||
aCharacteristicUuid,
|
||||
aPermissions,
|
||||
|
@ -747,7 +640,7 @@ BluetoothServiceBluedroid::GattServerAddCharacteristicInternal(
|
|||
|
||||
void
|
||||
BluetoothServiceBluedroid::GattServerAddDescriptorInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
const BluetoothAttributeHandle& aCharacteristicHandle,
|
||||
const BluetoothUuid& aDescriptorUuid,
|
||||
|
@ -761,10 +654,7 @@ BluetoothServiceBluedroid::GattServerAddDescriptorInternal(
|
|||
BluetoothGattManager* gatt = BluetoothGattManager::Get();
|
||||
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
StringToUuid(aAppUuid, appUuid);
|
||||
|
||||
gatt->ServerAddDescriptor(appUuid,
|
||||
gatt->ServerAddDescriptor(aAppUuid,
|
||||
aServiceHandle,
|
||||
aCharacteristicHandle,
|
||||
aDescriptorUuid,
|
||||
|
@ -774,7 +664,7 @@ BluetoothServiceBluedroid::GattServerAddDescriptorInternal(
|
|||
|
||||
void
|
||||
BluetoothServiceBluedroid::GattServerRemoveServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
|
@ -785,15 +675,12 @@ BluetoothServiceBluedroid::GattServerRemoveServiceInternal(
|
|||
BluetoothGattManager* gatt = BluetoothGattManager::Get();
|
||||
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
StringToUuid(aAppUuid, appUuid);
|
||||
|
||||
gatt->ServerRemoveService(appUuid, aServiceHandle, aRunnable);
|
||||
gatt->ServerRemoveService(aAppUuid, aServiceHandle, aRunnable);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::GattServerStartServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
|
@ -804,15 +691,12 @@ BluetoothServiceBluedroid::GattServerStartServiceInternal(
|
|||
BluetoothGattManager* gatt = BluetoothGattManager::Get();
|
||||
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
StringToUuid(aAppUuid, appUuid);
|
||||
|
||||
gatt->ServerStartService(appUuid, aServiceHandle, aRunnable);
|
||||
gatt->ServerStartService(aAppUuid, aServiceHandle, aRunnable);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::GattServerStopServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
|
@ -823,16 +707,13 @@ BluetoothServiceBluedroid::GattServerStopServiceInternal(
|
|||
BluetoothGattManager* gatt = BluetoothGattManager::Get();
|
||||
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
StringToUuid(aAppUuid, appUuid);
|
||||
|
||||
gatt->ServerStopService(appUuid, aServiceHandle, aRunnable);
|
||||
gatt->ServerStopService(aAppUuid, aServiceHandle, aRunnable);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::GattServerSendResponseInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aAddress,
|
||||
uint16_t aStatus,
|
||||
int32_t aRequestId,
|
||||
const BluetoothGattResponse& aRsp,
|
||||
|
@ -845,23 +726,14 @@ BluetoothServiceBluedroid::GattServerSendResponseInternal(
|
|||
BluetoothGattManager* gatt = BluetoothGattManager::Get();
|
||||
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
StringToUuid(aAppUuid, appUuid);
|
||||
|
||||
BluetoothAddress address;
|
||||
if (NS_FAILED(StringToAddress(aAddress, address))) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
gatt->ServerSendResponse(
|
||||
appUuid, address, aStatus, aRequestId, aRsp, aRunnable);
|
||||
aAppUuid, aAddress, aStatus, aRequestId, aRsp, aRunnable);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::GattServerSendIndicationInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aAddress,
|
||||
const BluetoothAttributeHandle& aCharacteristicHandle,
|
||||
bool aConfirm,
|
||||
const nsTArray<uint8_t>& aValue,
|
||||
|
@ -874,17 +746,8 @@ BluetoothServiceBluedroid::GattServerSendIndicationInternal(
|
|||
BluetoothGattManager* gatt = BluetoothGattManager::Get();
|
||||
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
StringToUuid(aAppUuid, appUuid);
|
||||
|
||||
BluetoothAddress address;
|
||||
if (NS_FAILED(StringToAddress(aAddress, address))) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
gatt->ServerSendIndication(appUuid,
|
||||
address,
|
||||
gatt->ServerSendIndication(aAppUuid,
|
||||
aAddress,
|
||||
aCharacteristicHandle,
|
||||
aConfirm,
|
||||
aValue,
|
||||
|
@ -1028,7 +891,8 @@ BluetoothServiceBluedroid::GetConnectedDevicePropertiesInternal(
|
|||
|
||||
nsresult
|
||||
BluetoothServiceBluedroid::GetPairedDevicePropertiesInternal(
|
||||
const nsTArray<nsString>& aDeviceAddress, BluetoothReplyRunnable* aRunnable)
|
||||
const nsTArray<BluetoothAddress>& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
|
@ -1044,17 +908,10 @@ BluetoothServiceBluedroid::GetPairedDevicePropertiesInternal(
|
|||
mGetDeviceRequests.AppendElement(request);
|
||||
|
||||
for (uint8_t i = 0; i < aDeviceAddress.Length(); i++) {
|
||||
|
||||
BluetoothAddress address;
|
||||
nsresult rv = StringToAddress(aDeviceAddress[i], address);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Retrieve all properties of devices
|
||||
sBtInterface->GetRemoteDeviceProperties(address,
|
||||
new GetRemoteDevicePropertiesResultHandler(mGetDeviceRequests, address));
|
||||
sBtInterface->GetRemoteDeviceProperties(aDeviceAddress[i],
|
||||
new GetRemoteDevicePropertiesResultHandler(mGetDeviceRequests,
|
||||
aDeviceAddress[i]));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1100,7 +957,7 @@ BluetoothServiceBluedroid::StartDiscoveryInternal(
|
|||
|
||||
nsresult
|
||||
BluetoothServiceBluedroid::FetchUuidsInternal(
|
||||
const nsAString& aDeviceAddress, BluetoothReplyRunnable* aRunnable)
|
||||
const BluetoothAddress& aDeviceAddress, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
|
@ -1114,15 +971,8 @@ BluetoothServiceBluedroid::FetchUuidsInternal(
|
|||
StopDiscoveryInternal(aRunnable);
|
||||
}
|
||||
|
||||
BluetoothAddress address;
|
||||
nsresult rv = StringToAddress(aDeviceAddress, address);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return rv;
|
||||
}
|
||||
|
||||
mFetchUuidsRunnables.AppendElement(aRunnable);
|
||||
sBtInterface->GetRemoteServices(address,
|
||||
sBtInterface->GetRemoteServices(aDeviceAddress,
|
||||
new DispatchReplyErrorResultHandler(mFetchUuidsRunnables, aRunnable));
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1358,22 +1208,15 @@ BluetoothServiceBluedroid::UpdateSdpRecords(
|
|||
|
||||
nsresult
|
||||
BluetoothServiceBluedroid::CreatePairedDeviceInternal(
|
||||
const nsAString& aDeviceAddress, int aTimeout,
|
||||
const BluetoothAddress& aDeviceAddress, int aTimeout,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
ENSURE_BLUETOOTH_IS_READY(aRunnable, NS_OK);
|
||||
|
||||
BluetoothAddress address;
|
||||
nsresult rv = StringToAddress(aDeviceAddress, address);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return rv;
|
||||
}
|
||||
|
||||
mCreateBondRunnables.AppendElement(aRunnable);
|
||||
sBtInterface->CreateBond(address, TRANSPORT_AUTO,
|
||||
sBtInterface->CreateBond(aDeviceAddress, TRANSPORT_AUTO,
|
||||
new DispatchReplyErrorResultHandler(mCreateBondRunnables, aRunnable));
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1381,21 +1224,14 @@ BluetoothServiceBluedroid::CreatePairedDeviceInternal(
|
|||
|
||||
nsresult
|
||||
BluetoothServiceBluedroid::RemoveDeviceInternal(
|
||||
const nsAString& aDeviceAddress, BluetoothReplyRunnable* aRunnable)
|
||||
const BluetoothAddress& aDeviceAddress, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
ENSURE_BLUETOOTH_IS_READY(aRunnable, NS_OK);
|
||||
|
||||
BluetoothAddress address;
|
||||
nsresult rv = StringToAddress(aDeviceAddress, address);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return rv;
|
||||
}
|
||||
|
||||
mRemoveBondRunnables.AppendElement(aRunnable);
|
||||
sBtInterface->RemoveBond(address,
|
||||
sBtInterface->RemoveBond(aDeviceAddress,
|
||||
new DispatchReplyErrorResultHandler(mRemoveBondRunnables, aRunnable));
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1425,34 +1261,20 @@ private:
|
|||
|
||||
void
|
||||
BluetoothServiceBluedroid::PinReplyInternal(
|
||||
const nsAString& aDeviceAddress, bool aAccept,
|
||||
const nsAString& aPinCode, BluetoothReplyRunnable* aRunnable)
|
||||
const BluetoothAddress& aDeviceAddress, bool aAccept,
|
||||
const BluetoothPinCode& aPinCode, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
ENSURE_BLUETOOTH_IS_READY_VOID(aRunnable);
|
||||
|
||||
BluetoothAddress address;
|
||||
nsresult rv = StringToAddress(aDeviceAddress, address);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
BluetoothPinCode pinCode;
|
||||
rv = StringToPinCode(aPinCode, pinCode);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
sBtInterface->PinReply(address, aAccept, pinCode,
|
||||
sBtInterface->PinReply(aDeviceAddress, aAccept, aPinCode,
|
||||
new PinReplyResultHandler(aRunnable));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::SetPinCodeInternal(
|
||||
const nsAString& aDeviceAddress, const nsAString& aPinCode,
|
||||
const BluetoothAddress& aDeviceAddress, const BluetoothPinCode& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
// Legacy method used by BlueZ only.
|
||||
|
@ -1460,7 +1282,7 @@ BluetoothServiceBluedroid::SetPinCodeInternal(
|
|||
|
||||
void
|
||||
BluetoothServiceBluedroid::SetPasskeyInternal(
|
||||
const nsAString& aDeviceAddress, uint32_t aPasskey,
|
||||
const BluetoothAddress& aDeviceAddress, uint32_t aPasskey,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
// Legacy method used by BlueZ only.
|
||||
|
@ -1490,27 +1312,20 @@ private:
|
|||
|
||||
void
|
||||
BluetoothServiceBluedroid::SspReplyInternal(
|
||||
const nsAString& aDeviceAddress, BluetoothSspVariant aVariant,
|
||||
const BluetoothAddress& aDeviceAddress, BluetoothSspVariant aVariant,
|
||||
bool aAccept, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
ENSURE_BLUETOOTH_IS_READY_VOID(aRunnable);
|
||||
|
||||
BluetoothAddress address;
|
||||
nsresult rv = StringToAddress(aDeviceAddress, address);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
sBtInterface->SspReply(address, aVariant, aAccept, 0 /* passkey */,
|
||||
sBtInterface->SspReply(aDeviceAddress, aVariant, aAccept, 0 /* passkey */,
|
||||
new SspReplyResultHandler(aRunnable));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::SetPairingConfirmationInternal(
|
||||
const nsAString& aDeviceAddress, bool aConfirm,
|
||||
const BluetoothAddress& aDeviceAddress, bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
// Legacy method used by BlueZ only.
|
||||
|
@ -1533,22 +1348,15 @@ BluetoothServiceBluedroid::NextBluetoothProfileController()
|
|||
|
||||
void
|
||||
BluetoothServiceBluedroid::ConnectDisconnect(
|
||||
bool aConnect, const nsAString& aDeviceAddress,
|
||||
bool aConnect, const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable,
|
||||
uint16_t aServiceUuid, uint32_t aCod)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aRunnable);
|
||||
|
||||
BluetoothAddress address;
|
||||
nsresult rv = StringToAddress(aDeviceAddress, address);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
BluetoothProfileController* controller =
|
||||
new BluetoothProfileController(aConnect, address, aRunnable,
|
||||
new BluetoothProfileController(aConnect, aDeviceAddress, aRunnable,
|
||||
NextBluetoothProfileController,
|
||||
aServiceUuid, aCod);
|
||||
sControllerArray.AppendElement(controller);
|
||||
|
@ -1564,7 +1372,7 @@ BluetoothServiceBluedroid::ConnectDisconnect(
|
|||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::Connect(const nsAString& aDeviceAddress,
|
||||
BluetoothServiceBluedroid::Connect(const BluetoothAddress& aDeviceAddress,
|
||||
uint32_t aCod,
|
||||
uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
|
@ -1574,34 +1382,27 @@ BluetoothServiceBluedroid::Connect(const nsAString& aDeviceAddress,
|
|||
|
||||
void
|
||||
BluetoothServiceBluedroid::Disconnect(
|
||||
const nsAString& aDeviceAddress, uint16_t aServiceUuid,
|
||||
const BluetoothAddress& aDeviceAddress, uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
ConnectDisconnect(false, aDeviceAddress, aRunnable, aServiceUuid);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::SendFile(const nsAString& aDeviceAddress,
|
||||
BluetoothServiceBluedroid::SendFile(const BluetoothAddress& aDeviceAddress,
|
||||
BlobParent* aBlobParent,
|
||||
BlobChild* aBlobChild,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
nsresult rv = StringToAddress(aDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
// Currently we only support one device sending one file at a time,
|
||||
// so we don't need aDeviceAddress here because the target device
|
||||
// has been determined when calling 'Connect()'. Nevertheless, keep
|
||||
// it for future use.
|
||||
|
||||
BluetoothOppManager* opp = BluetoothOppManager::Get();
|
||||
if (!opp || !opp->SendFile(deviceAddress, aBlobParent)) {
|
||||
if (!opp || !opp->SendFile(aDeviceAddress, aBlobParent)) {
|
||||
DispatchReplyError(aRunnable, NS_LITERAL_STRING("SendFile failed"));
|
||||
return;
|
||||
}
|
||||
|
@ -1610,26 +1411,19 @@ BluetoothServiceBluedroid::SendFile(const nsAString& aDeviceAddress,
|
|||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::SendFile(const nsAString& aDeviceAddress,
|
||||
BluetoothServiceBluedroid::SendFile(const BluetoothAddress& aDeviceAddress,
|
||||
Blob* aBlob,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
nsresult rv = StringToAddress(aDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
// Currently we only support one device sending one file at a time,
|
||||
// so we don't need aDeviceAddress here because the target device
|
||||
// has been determined when calling 'Connect()'. Nevertheless, keep
|
||||
// it for future use.
|
||||
|
||||
BluetoothOppManager* opp = BluetoothOppManager::Get();
|
||||
if (!opp || !opp->SendFile(deviceAddress, aBlob)) {
|
||||
if (!opp || !opp->SendFile(aDeviceAddress, aBlob)) {
|
||||
DispatchReplyError(aRunnable, NS_LITERAL_STRING("SendFile failed"));
|
||||
return;
|
||||
}
|
||||
|
@ -1638,8 +1432,8 @@ BluetoothServiceBluedroid::SendFile(const nsAString& aDeviceAddress,
|
|||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::StopSendingFile(const nsAString& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
BluetoothServiceBluedroid::StopSendingFile(
|
||||
const BluetoothAddress& aDeviceAddress, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
|
@ -1660,7 +1454,7 @@ BluetoothServiceBluedroid::StopSendingFile(const nsAString& aDeviceAddress,
|
|||
|
||||
void
|
||||
BluetoothServiceBluedroid::ConfirmReceivingFile(
|
||||
const nsAString& aDeviceAddress, bool aConfirm,
|
||||
const BluetoothAddress& aDeviceAddress, bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
@ -2021,15 +1815,12 @@ BluetoothServiceBluedroid::SendMetaData(const nsAString& aTitle,
|
|||
|
||||
void
|
||||
BluetoothServiceBluedroid::SendPlayStatus(
|
||||
int64_t aDuration, int64_t aPosition,
|
||||
const nsAString& aPlayStatus,
|
||||
int64_t aDuration, int64_t aPosition, ControlPlayStatus aPlayStatus,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
BluetoothAvrcpManager* avrcp = BluetoothAvrcpManager::Get();
|
||||
if (avrcp) {
|
||||
ControlPlayStatus playStatus =
|
||||
PlayStatusStringToControlPlayStatus(aPlayStatus);
|
||||
avrcp->UpdatePlayStatus(aDuration, aPosition, playStatus);
|
||||
avrcp->UpdatePlayStatus(aDuration, aPosition, aPlayStatus);
|
||||
}
|
||||
DispatchReplySuccess(aRunnable);
|
||||
}
|
||||
|
|
|
@ -50,11 +50,12 @@ public:
|
|||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual nsresult
|
||||
GetPairedDevicePropertiesInternal(const nsTArray<nsString>& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
GetPairedDevicePropertiesInternal(
|
||||
const nsTArray<BluetoothAddress>& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual nsresult
|
||||
FetchUuidsInternal(const nsAString& aDeviceAddress,
|
||||
FetchUuidsInternal(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void StartDiscoveryInternal(BluetoothReplyRunnable* aRunnable);
|
||||
|
@ -75,67 +76,67 @@ public:
|
|||
BluetoothProfileManagerBase* aManager);
|
||||
|
||||
virtual nsresult
|
||||
CreatePairedDeviceInternal(const nsAString& aDeviceAddress,
|
||||
CreatePairedDeviceInternal(const BluetoothAddress& aDeviceAddress,
|
||||
int aTimeout,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual nsresult
|
||||
RemoveDeviceInternal(const nsAString& aDeviceObjectPath,
|
||||
RemoveDeviceInternal(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
PinReplyInternal(const nsAString& aDeviceAddress,
|
||||
PinReplyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
bool aAccept,
|
||||
const nsAString& aPinCode,
|
||||
const BluetoothPinCode& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
SspReplyInternal(const nsAString& aDeviceAddress,
|
||||
SspReplyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothSspVariant aVariant,
|
||||
bool aAccept,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
virtual void
|
||||
SetPinCodeInternal(const nsAString& aDeviceAddress,
|
||||
const nsAString& aPinCode,
|
||||
SetPinCodeInternal(const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothPinCode& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
SetPasskeyInternal(const nsAString& aDeviceAddress,
|
||||
SetPasskeyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
uint32_t aPasskey,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
SetPairingConfirmationInternal(const nsAString& aDeviceAddress,
|
||||
SetPairingConfirmationInternal(const BluetoothAddress& aDeviceAddress,
|
||||
bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
Connect(const nsAString& aDeviceAddress,
|
||||
Connect(const BluetoothAddress& aDeviceAddress,
|
||||
uint32_t aCod,
|
||||
uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
Disconnect(const nsAString& aDeviceAddress, uint16_t aServiceUuid,
|
||||
Disconnect(const BluetoothAddress& aDeviceAddress, uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
SendFile(const nsAString& aDeviceAddress,
|
||||
SendFile(const BluetoothAddress& aDeviceAddress,
|
||||
BlobParent* aBlobParent,
|
||||
BlobChild* aBlobChild,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
SendFile(const nsAString& aDeviceAddress,
|
||||
SendFile(const BluetoothAddress& aDeviceAddress,
|
||||
Blob* aBlob,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
StopSendingFile(const nsAString& aDeviceAddress,
|
||||
StopSendingFile(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
ConfirmReceivingFile(const nsAString& aDeviceAddress, bool aConfirm,
|
||||
ConfirmReceivingFile(const BluetoothAddress& aDeviceAddress, bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
|
@ -254,7 +255,7 @@ public:
|
|||
virtual void
|
||||
SendPlayStatus(int64_t aDuration,
|
||||
int64_t aPosition,
|
||||
const nsAString& aPlayStatus,
|
||||
ControlPlayStatus aPlayStatus,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
|
@ -274,36 +275,36 @@ public:
|
|||
// GATT Client
|
||||
//
|
||||
|
||||
virtual void StartLeScanInternal(const nsTArray<nsString>& aServiceUuids,
|
||||
virtual void StartLeScanInternal(const nsTArray<BluetoothUuid>& aServiceUuids,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void StopLeScanInternal(const nsAString& aScanUuid,
|
||||
virtual void StopLeScanInternal(const BluetoothUuid& aScanUuid,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
ConnectGattClientInternal(const nsAString& aAppUuid,
|
||||
const nsAString& aDeviceAddress,
|
||||
ConnectGattClientInternal(const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
DisconnectGattClientInternal(const nsAString& aAppUuid,
|
||||
const nsAString& aDeviceAddress,
|
||||
DisconnectGattClientInternal(const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
DiscoverGattServicesInternal(const nsAString& aAppUuid,
|
||||
DiscoverGattServicesInternal(const BluetoothUuid& aAppUuid,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattClientStartNotificationsInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServId,
|
||||
const BluetoothGattId& aCharId,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattClientStopNotificationsInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServId,
|
||||
const BluetoothGattId& aCharId,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
@ -314,19 +315,19 @@ public:
|
|||
|
||||
virtual void
|
||||
GattClientReadRemoteRssiInternal(
|
||||
int aClientIf, const nsAString& aDeviceAddress,
|
||||
int aClientIf, const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattClientReadCharacteristicValueInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
const BluetoothGattId& aCharacteristicId,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattClientWriteCharacteristicValueInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
const BluetoothGattId& aCharacteristicId,
|
||||
const BluetoothGattWriteType& aWriteType,
|
||||
|
@ -335,7 +336,7 @@ public:
|
|||
|
||||
virtual void
|
||||
GattClientReadDescriptorValueInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
const BluetoothGattId& aCharacteristicId,
|
||||
const BluetoothGattId& aDescriptorId,
|
||||
|
@ -343,7 +344,7 @@ public:
|
|||
|
||||
virtual void
|
||||
GattClientWriteDescriptorValueInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
const BluetoothGattId& aCharacteristicId,
|
||||
const BluetoothGattId& aDescriptorId,
|
||||
|
@ -352,14 +353,14 @@ public:
|
|||
|
||||
virtual void
|
||||
GattServerConnectPeripheralInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattServerDisconnectPeripheralInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
|
@ -368,21 +369,21 @@ public:
|
|||
|
||||
virtual void
|
||||
GattServerAddServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
uint16_t aHandleCount,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattServerAddIncludedServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
const BluetoothAttributeHandle& aIncludedServiceHandle,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattServerAddCharacteristicInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
const BluetoothUuid& aCharacteristicUuid,
|
||||
BluetoothGattAttrPerm aPermissions,
|
||||
|
@ -391,7 +392,7 @@ public:
|
|||
|
||||
virtual void
|
||||
GattServerAddDescriptorInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
const BluetoothAttributeHandle& aCharacteristicHandle,
|
||||
const BluetoothUuid& aDescriptorUuid,
|
||||
|
@ -400,26 +401,26 @@ public:
|
|||
|
||||
virtual void
|
||||
GattServerRemoveServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattServerStartServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattServerStopServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattServerSendResponseInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aAddress,
|
||||
uint16_t aStatus,
|
||||
int32_t aRequestId,
|
||||
const BluetoothGattResponse& aRsp,
|
||||
|
@ -427,8 +428,8 @@ public:
|
|||
|
||||
virtual void
|
||||
GattServerSendIndicationInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aAddress,
|
||||
const BluetoothAttributeHandle& aCharacteristicHandle,
|
||||
bool aConfirm,
|
||||
const nsTArray<uint8_t>& aValue,
|
||||
|
@ -485,11 +486,8 @@ protected:
|
|||
static nsresult StartGonkBluetooth();
|
||||
static nsresult StopGonkBluetooth();
|
||||
|
||||
static ControlPlayStatus PlayStatusStringToControlPlayStatus(
|
||||
const nsAString& aPlayStatus);
|
||||
|
||||
static void ConnectDisconnect(bool aConnect,
|
||||
const nsAString& aDeviceAddress,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable,
|
||||
uint16_t aServiceUuid, uint32_t aCod = 0);
|
||||
static void NextBluetoothProfileController();
|
||||
|
|
|
@ -2703,7 +2703,7 @@ class BluetoothArrayOfDevicePropertiesReplyHandler : public DBusReplyHandler
|
|||
{
|
||||
public:
|
||||
BluetoothArrayOfDevicePropertiesReplyHandler(
|
||||
const nsTArray<nsString>& aDeviceAddresses,
|
||||
const nsTArray<BluetoothAddress>& aDeviceAddresses,
|
||||
const FilterFunc aFilterFunc, BluetoothReplyRunnable* aRunnable)
|
||||
: mDeviceAddresses(aDeviceAddresses)
|
||||
, mProcessedDeviceAddresses(0)
|
||||
|
@ -2772,8 +2772,11 @@ public:
|
|||
}
|
||||
|
||||
if (mFilterFunc(deviceProperties)) {
|
||||
nsString deviceAddressStr;
|
||||
AddressToString(mDeviceAddresses[i], deviceAddressStr);
|
||||
|
||||
mValues.get_ArrayOfBluetoothNamedValue().AppendElement(
|
||||
BluetoothNamedValue(mDeviceAddresses[i], deviceProperties));
|
||||
BluetoothNamedValue(deviceAddressStr, deviceProperties));
|
||||
}
|
||||
|
||||
ProcessRemainingDeviceAddresses();
|
||||
|
@ -2822,7 +2825,7 @@ protected:
|
|||
|
||||
private:
|
||||
nsString mObjectPath;
|
||||
const nsTArray<nsString> mDeviceAddresses;
|
||||
const nsTArray<BluetoothAddress> mDeviceAddresses;
|
||||
nsTArray<nsString>::size_type mProcessedDeviceAddresses;
|
||||
const FilterFunc mFilterFunc;
|
||||
RefPtr<BluetoothReplyRunnable> mRunnable;
|
||||
|
@ -2868,7 +2871,8 @@ BluetoothDBusService::GetConnectedDevicePropertiesInternal(
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsTArray<nsString> deviceAddresses;
|
||||
nsTArray<BluetoothAddress> deviceAddresses;
|
||||
|
||||
BluetoothProfileManagerBase* profile =
|
||||
BluetoothUuidHelper::GetBluetoothProfileManager(aServiceUuid);
|
||||
if (!profile) {
|
||||
|
@ -2880,11 +2884,7 @@ BluetoothDBusService::GetConnectedDevicePropertiesInternal(
|
|||
if (profile->IsConnected()) {
|
||||
BluetoothAddress address;
|
||||
profile->GetAddress(address);
|
||||
|
||||
nsAutoString addressStr;
|
||||
AddressToString(address, addressStr);
|
||||
|
||||
deviceAddresses.AppendElement(addressStr);
|
||||
deviceAddresses.AppendElement(address);
|
||||
}
|
||||
|
||||
BluetoothArrayOfDevicePropertiesReplyHandler* handler =
|
||||
|
@ -2899,8 +2899,8 @@ BluetoothDBusService::GetConnectedDevicePropertiesInternal(
|
|||
|
||||
nsresult
|
||||
BluetoothDBusService::GetPairedDevicePropertiesInternal(
|
||||
const nsTArray<nsString>& aDeviceAddresses,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
const nsTArray<BluetoothAddress>& aDeviceAddresses,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
|
@ -2921,7 +2921,7 @@ BluetoothDBusService::GetPairedDevicePropertiesInternal(
|
|||
}
|
||||
|
||||
nsresult
|
||||
BluetoothDBusService::FetchUuidsInternal(const nsAString& aDeviceAddress,
|
||||
BluetoothDBusService::FetchUuidsInternal(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
return NS_OK;
|
||||
|
@ -3092,14 +3092,14 @@ BluetoothDBusService::SetProperty(BluetoothObjectType aType,
|
|||
class CreatePairedDeviceInternalTask : public Task
|
||||
{
|
||||
public:
|
||||
CreatePairedDeviceInternalTask(const nsACString& aDeviceAddress,
|
||||
CreatePairedDeviceInternalTask(const BluetoothAddress& aDeviceAddress,
|
||||
int aTimeout,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
: mDeviceAddress(aDeviceAddress)
|
||||
, mTimeout(aTimeout)
|
||||
, mRunnable(aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(!mDeviceAddress.IsEmpty());
|
||||
MOZ_ASSERT(!mDeviceAddress.IsCleared());
|
||||
MOZ_ASSERT(mRunnable);
|
||||
}
|
||||
|
||||
|
@ -3109,7 +3109,11 @@ public:
|
|||
MOZ_ASSERT(sDBusConnection);
|
||||
MOZ_ASSERT(!sAdapterPath.IsEmpty());
|
||||
|
||||
const char *deviceAddress = mDeviceAddress.get();
|
||||
nsString deviceAddressStr;
|
||||
AddressToString(mDeviceAddress, deviceAddressStr);
|
||||
auto utf8DeviceAddressStr = NS_ConvertUTF16toUTF8(deviceAddressStr);
|
||||
|
||||
const char *deviceAddress = utf8DeviceAddressStr.get();
|
||||
const char *deviceAgentPath = KEY_REMOTE_AGENT;
|
||||
const char *capabilities = B2G_AGENT_CAPABILITIES;
|
||||
|
||||
|
@ -3145,20 +3149,20 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
const nsCString mDeviceAddress;
|
||||
BluetoothAddress mDeviceAddress;
|
||||
int mTimeout;
|
||||
RefPtr<BluetoothReplyRunnable> mRunnable;
|
||||
};
|
||||
|
||||
nsresult
|
||||
BluetoothDBusService::CreatePairedDeviceInternal(
|
||||
const nsAString& aDeviceAddress,
|
||||
int aTimeout,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
int aTimeout,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
Task* task = new CreatePairedDeviceInternalTask(
|
||||
NS_ConvertUTF16toUTF8(aDeviceAddress),
|
||||
aTimeout, aRunnable);
|
||||
Task* task = new CreatePairedDeviceInternalTask(aDeviceAddress,
|
||||
aTimeout,
|
||||
aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -3221,8 +3225,9 @@ private:
|
|||
};
|
||||
|
||||
nsresult
|
||||
BluetoothDBusService::RemoveDeviceInternal(const nsAString& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
BluetoothDBusService::RemoveDeviceInternal(
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
|
@ -3232,14 +3237,7 @@ BluetoothDBusService::RemoveDeviceInternal(const nsAString& aDeviceAddress,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
auto rv = StringToAddress(aDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return rv;
|
||||
}
|
||||
|
||||
Task* task = new RemoveDeviceTask(deviceAddress, aRunnable);
|
||||
Task* task = new RemoveDeviceTask(aDeviceAddress, aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -3249,7 +3247,7 @@ class SetPinCodeTask : public Task
|
|||
{
|
||||
public:
|
||||
SetPinCodeTask(const BluetoothAddress& aDeviceAddress,
|
||||
const nsACString& aPinCode,
|
||||
const BluetoothPinCode& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
: mDeviceAddress(aDeviceAddress)
|
||||
, mPinCode(aPinCode)
|
||||
|
@ -3283,7 +3281,19 @@ public:
|
|||
return;
|
||||
}
|
||||
|
||||
const char* pinCode = mPinCode.get();
|
||||
nsAutoString pinCodeStr;
|
||||
if (NS_FAILED(PinCodeToString(mPinCode, pinCodeStr))) {
|
||||
BT_WARNING("%s: Cannot convert pin code to string.", __FUNCTION__);
|
||||
dbus_message_unref(msg);
|
||||
dbus_message_unref(reply);
|
||||
errorStr.AssignLiteral("Cannot convert pin code to string.");
|
||||
DispatchBluetoothReply(mRunnable, v, errorStr);
|
||||
return;
|
||||
}
|
||||
|
||||
auto utf8PinCodeStr = NS_ConvertUTF16toUTF8(pinCodeStr);
|
||||
|
||||
const char* pinCode = utf8PinCodeStr.get();
|
||||
|
||||
if (!dbus_message_append_args(reply,
|
||||
DBUS_TYPE_STRING, &pinCode,
|
||||
|
@ -3304,41 +3314,32 @@ public:
|
|||
|
||||
private:
|
||||
const BluetoothAddress mDeviceAddress;
|
||||
const nsCString mPinCode;
|
||||
const BluetoothPinCode mPinCode;
|
||||
RefPtr<BluetoothReplyRunnable> mRunnable;
|
||||
};
|
||||
|
||||
void
|
||||
BluetoothDBusService::PinReplyInternal(
|
||||
const nsAString& aDeviceAddress, bool aAccept,
|
||||
const nsAString& aPinCode, BluetoothReplyRunnable* aRunnable)
|
||||
const BluetoothAddress& aDeviceAddress, bool aAccept,
|
||||
const BluetoothPinCode& aPinCode, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
// Legacy interface used by Bluedroid only.
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDBusService::SspReplyInternal(
|
||||
const nsAString& aDeviceAddress, BluetoothSspVariant aVariant,
|
||||
const BluetoothAddress& aDeviceAddress, BluetoothSspVariant aVariant,
|
||||
bool aAccept, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
// Legacy interface used by Bluedroid only.
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDBusService::SetPinCodeInternal(const nsAString& aDeviceAddress,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothDBusService::SetPinCodeInternal(const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothPinCode& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
BluetoothAddress deviceAddress;
|
||||
auto rv = StringToAddress(aDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
Task* task = new SetPinCodeTask(deviceAddress,
|
||||
NS_ConvertUTF16toUTF8(aPinCode),
|
||||
aRunnable);
|
||||
Task* task = new SetPinCodeTask(aDeviceAddress, aPinCode, aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
}
|
||||
|
||||
|
@ -3406,17 +3407,12 @@ private:
|
|||
};
|
||||
|
||||
void
|
||||
BluetoothDBusService::SetPasskeyInternal(const nsAString& aDeviceAddress,
|
||||
uint32_t aPasskey,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
BluetoothDBusService::SetPasskeyInternal(
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
uint32_t aPasskey,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
BluetoothAddress deviceAddress;
|
||||
if (NS_FAILED(StringToAddress(aDeviceAddress, deviceAddress))) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
Task* task = new SetPasskeyTask(deviceAddress,
|
||||
Task* task = new SetPasskeyTask(aDeviceAddress,
|
||||
aPasskey,
|
||||
aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
|
@ -3424,19 +3420,13 @@ BluetoothDBusService::SetPasskeyInternal(const nsAString& aDeviceAddress,
|
|||
|
||||
void
|
||||
BluetoothDBusService::SetPairingConfirmationInternal(
|
||||
const nsAString& aDeviceAddress,
|
||||
bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
if (NS_FAILED(StringToAddress(aDeviceAddress, deviceAddress))) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
Task* task = new SetPairingConfirmationTask(deviceAddress,
|
||||
Task* task = new SetPairingConfirmationTask(aDeviceAddress,
|
||||
aConfirm,
|
||||
aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
|
@ -3457,22 +3447,15 @@ NextBluetoothProfileController()
|
|||
}
|
||||
|
||||
static void
|
||||
ConnectDisconnect(bool aConnect, const nsAString& aDeviceAddress,
|
||||
ConnectDisconnect(bool aConnect, const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable,
|
||||
uint16_t aServiceUuid, uint32_t aCod = 0)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aRunnable);
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
nsresult rv = StringToAddress(aDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
BluetoothProfileController* controller =
|
||||
new BluetoothProfileController(aConnect, deviceAddress, aRunnable,
|
||||
new BluetoothProfileController(aConnect, aDeviceAddress, aRunnable,
|
||||
NextBluetoothProfileController,
|
||||
aServiceUuid, aCod);
|
||||
sControllerArray.AppendElement(controller);
|
||||
|
@ -3488,7 +3471,7 @@ ConnectDisconnect(bool aConnect, const nsAString& aDeviceAddress,
|
|||
}
|
||||
|
||||
void
|
||||
BluetoothDBusService::Connect(const nsAString& aDeviceAddress,
|
||||
BluetoothDBusService::Connect(const BluetoothAddress& aDeviceAddress,
|
||||
uint32_t aCod,
|
||||
uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
|
@ -3497,7 +3480,7 @@ BluetoothDBusService::Connect(const nsAString& aDeviceAddress,
|
|||
}
|
||||
|
||||
void
|
||||
BluetoothDBusService::Disconnect(const nsAString& aDeviceAddress,
|
||||
BluetoothDBusService::Disconnect(const BluetoothAddress& aDeviceAddress,
|
||||
uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
|
@ -3542,16 +3525,13 @@ BluetoothDBusService::ToggleCalls(BluetoothReplyRunnable* aRunnable)
|
|||
class OnUpdateSdpRecordsRunnable : public nsRunnable
|
||||
{
|
||||
public:
|
||||
OnUpdateSdpRecordsRunnable(const nsAString& aObjectPath,
|
||||
OnUpdateSdpRecordsRunnable(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothProfileManagerBase* aManager)
|
||||
: mManager(aManager)
|
||||
: mDeviceAddress(aDeviceAddress)
|
||||
, mManager(aManager)
|
||||
{
|
||||
MOZ_ASSERT(!aObjectPath.IsEmpty());
|
||||
MOZ_ASSERT(aManager);
|
||||
|
||||
const nsString deviceAddressStr = GetAddressFromObjectPath(aObjectPath);
|
||||
|
||||
StringToAddress(deviceAddressStr, mDeviceAddress);
|
||||
MOZ_ASSERT(!mDeviceAddress.IsCleared());
|
||||
MOZ_ASSERT(mManager);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -3758,7 +3738,7 @@ public:
|
|||
// I choose to use raw pointer here because this is going to be passed as an
|
||||
// argument into SendWithReply() at once.
|
||||
OnUpdateSdpRecordsRunnable* callbackRunnable =
|
||||
new OnUpdateSdpRecordsRunnable(objectPath, mBluetoothProfileManager);
|
||||
new OnUpdateSdpRecordsRunnable(mDeviceAddress, mBluetoothProfileManager);
|
||||
|
||||
sDBusConnection->SendWithReply(DiscoverServicesCallback,
|
||||
(void*)callbackRunnable, -1,
|
||||
|
@ -3798,26 +3778,20 @@ BluetoothDBusService::UpdateSdpRecords(const BluetoothAddress& aDeviceAddress,
|
|||
}
|
||||
|
||||
void
|
||||
BluetoothDBusService::SendFile(const nsAString& aDeviceAddress,
|
||||
BluetoothDBusService::SendFile(const BluetoothAddress& aDeviceAddress,
|
||||
BlobParent* aBlobParent,
|
||||
BlobChild* aBlobChild,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
if (NS_FAILED(StringToAddress(aDeviceAddress, deviceAddress))) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
// Currently we only support one device sending one file at a time,
|
||||
// so we don't need aDeviceAddress here because the target device
|
||||
// has been determined when calling 'Connect()'. Nevertheless, keep
|
||||
// it for future use.
|
||||
BluetoothOppManager* opp = BluetoothOppManager::Get();
|
||||
nsAutoString errorStr;
|
||||
if (!opp || !opp->SendFile(deviceAddress, aBlobParent)) {
|
||||
if (!opp || !opp->SendFile(aDeviceAddress, aBlobParent)) {
|
||||
errorStr.AssignLiteral("Calling SendFile() failed");
|
||||
}
|
||||
|
||||
|
@ -3825,25 +3799,19 @@ BluetoothDBusService::SendFile(const nsAString& aDeviceAddress,
|
|||
}
|
||||
|
||||
void
|
||||
BluetoothDBusService::SendFile(const nsAString& aDeviceAddress,
|
||||
BluetoothDBusService::SendFile(const BluetoothAddress& aDeviceAddress,
|
||||
Blob* aBlob,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
if (NS_FAILED(StringToAddress(aDeviceAddress, deviceAddress))) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
// Currently we only support one device sending one file at a time,
|
||||
// so we don't need aDeviceAddress here because the target device
|
||||
// has been determined when calling 'Connect()'. Nevertheless, keep
|
||||
// it for future use.
|
||||
BluetoothOppManager* opp = BluetoothOppManager::Get();
|
||||
nsAutoString errorStr;
|
||||
if (!opp || !opp->SendFile(deviceAddress, aBlob)) {
|
||||
if (!opp || !opp->SendFile(aDeviceAddress, aBlob)) {
|
||||
errorStr.AssignLiteral("Calling SendFile() failed");
|
||||
}
|
||||
|
||||
|
@ -3851,7 +3819,7 @@ BluetoothDBusService::SendFile(const nsAString& aDeviceAddress,
|
|||
}
|
||||
|
||||
void
|
||||
BluetoothDBusService::StopSendingFile(const nsAString& aDeviceAddress,
|
||||
BluetoothDBusService::StopSendingFile(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
@ -3870,9 +3838,10 @@ BluetoothDBusService::StopSendingFile(const nsAString& aDeviceAddress,
|
|||
}
|
||||
|
||||
void
|
||||
BluetoothDBusService::ConfirmReceivingFile(const nsAString& aDeviceAddress,
|
||||
bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
BluetoothDBusService::ConfirmReceivingFile(
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread(), "Must be called from main thread!");
|
||||
|
||||
|
@ -4075,27 +4044,6 @@ BluetoothDBusService::SendMetaData(const nsAString& aTitle,
|
|||
aMediaNumber, aTotalMediaCount, aDuration);
|
||||
}
|
||||
|
||||
static ControlPlayStatus
|
||||
PlayStatusStringToControlPlayStatus(const nsAString& aPlayStatus)
|
||||
{
|
||||
ControlPlayStatus playStatus = ControlPlayStatus::PLAYSTATUS_UNKNOWN;
|
||||
if (aPlayStatus.EqualsLiteral("STOPPED")) {
|
||||
playStatus = ControlPlayStatus::PLAYSTATUS_STOPPED;
|
||||
} else if (aPlayStatus.EqualsLiteral("PLAYING")) {
|
||||
playStatus = ControlPlayStatus::PLAYSTATUS_PLAYING;
|
||||
} else if (aPlayStatus.EqualsLiteral("PAUSED")) {
|
||||
playStatus = ControlPlayStatus::PLAYSTATUS_PAUSED;
|
||||
} else if (aPlayStatus.EqualsLiteral("FWD_SEEK")) {
|
||||
playStatus = ControlPlayStatus::PLAYSTATUS_FWD_SEEK;
|
||||
} else if (aPlayStatus.EqualsLiteral("REV_SEEK")) {
|
||||
playStatus = ControlPlayStatus::PLAYSTATUS_REV_SEEK;
|
||||
} else if (aPlayStatus.EqualsLiteral("ERROR")) {
|
||||
playStatus = ControlPlayStatus::PLAYSTATUS_ERROR;
|
||||
}
|
||||
|
||||
return playStatus;
|
||||
}
|
||||
|
||||
class SendPlayStatusTask : public Task
|
||||
{
|
||||
public:
|
||||
|
@ -4150,7 +4098,7 @@ private:
|
|||
void
|
||||
BluetoothDBusService::SendPlayStatus(int64_t aDuration,
|
||||
int64_t aPosition,
|
||||
const nsAString& aPlayStatus,
|
||||
ControlPlayStatus aPlayStatus,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
@ -4161,9 +4109,7 @@ BluetoothDBusService::SendPlayStatus(int64_t aDuration,
|
|||
return;
|
||||
}
|
||||
|
||||
ControlPlayStatus playStatus =
|
||||
PlayStatusStringToControlPlayStatus(aPlayStatus);
|
||||
if (playStatus == ControlPlayStatus::PLAYSTATUS_UNKNOWN) {
|
||||
if (aPlayStatus == ControlPlayStatus::PLAYSTATUS_UNKNOWN) {
|
||||
DispatchBluetoothReply(aRunnable, BluetoothValue(),
|
||||
NS_LITERAL_STRING("Invalid play status"));
|
||||
return;
|
||||
|
@ -4186,9 +4132,9 @@ BluetoothDBusService::SendPlayStatus(int64_t aDuration,
|
|||
return;
|
||||
}
|
||||
|
||||
if (playStatus != avrcp->GetPlayStatus()) {
|
||||
if (aPlayStatus != avrcp->GetPlayStatus()) {
|
||||
UpdateNotification(ControlEventId::EVENT_PLAYBACK_STATUS_CHANGED,
|
||||
playStatus);
|
||||
aPlayStatus);
|
||||
} else if (aPosition != avrcp->GetPosition()) {
|
||||
UpdateNotification(ControlEventId::EVENT_PLAYBACK_POS_CHANGED, aPosition);
|
||||
}
|
||||
|
@ -4199,11 +4145,11 @@ BluetoothDBusService::SendPlayStatus(int64_t aDuration,
|
|||
Task* task = new SendPlayStatusTask(deviceAddress,
|
||||
aDuration,
|
||||
aPosition,
|
||||
playStatus,
|
||||
aPlayStatus,
|
||||
aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
|
||||
avrcp->UpdatePlayStatus(aDuration, aPosition, playStatus);
|
||||
avrcp->UpdatePlayStatus(aDuration, aPosition, aPlayStatus);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -4349,48 +4295,48 @@ BluetoothDBusService::UpdateNotification(ControlEventId aEventId,
|
|||
|
||||
void
|
||||
BluetoothDBusService::StartLeScanInternal(
|
||||
const nsTArray<nsString>& aServiceUuids,
|
||||
const nsTArray<BluetoothUuid>& aServiceUuids,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDBusService::StopLeScanInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDBusService::ConnectGattClientInternal(
|
||||
const nsAString& aAppUuid, const nsAString& aDeviceAddress,
|
||||
const BluetoothUuid& aAppUuid, const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDBusService::DisconnectGattClientInternal(
|
||||
const nsAString& aAppUuid, const nsAString& aDeviceAddress,
|
||||
const BluetoothUuid& aAppUuid, const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDBusService::DiscoverGattServicesInternal(
|
||||
const nsAString& aAppUuid, BluetoothReplyRunnable* aRunnable)
|
||||
const BluetoothUuid& aAppUuid, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDBusService::GattClientStartNotificationsInternal(
|
||||
const nsAString& aAppUuid, const BluetoothGattServiceId& aServId,
|
||||
const BluetoothUuid& aAppUuid, const BluetoothGattServiceId& aServId,
|
||||
const BluetoothGattId& aCharId, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDBusService::GattClientStopNotificationsInternal(
|
||||
const nsAString& aAppUuid, const BluetoothGattServiceId& aServId,
|
||||
const BluetoothUuid& aAppUuid, const BluetoothGattServiceId& aServId,
|
||||
const BluetoothGattId& aCharId, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
}
|
||||
|
@ -4403,14 +4349,14 @@ BluetoothDBusService::UnregisterGattClientInternal(
|
|||
|
||||
void
|
||||
BluetoothDBusService::GattClientReadRemoteRssiInternal(
|
||||
int aClientIf, const nsAString& aDeviceAddress,
|
||||
int aClientIf, const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDBusService::GattClientReadCharacteristicValueInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
const BluetoothGattId& aCharacteristicId,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
|
@ -4419,7 +4365,7 @@ BluetoothDBusService::GattClientReadCharacteristicValueInternal(
|
|||
|
||||
void
|
||||
BluetoothDBusService::GattClientWriteCharacteristicValueInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
const BluetoothGattId& aCharacteristicId,
|
||||
const BluetoothGattWriteType& aWriteType,
|
||||
|
@ -4430,7 +4376,7 @@ BluetoothDBusService::GattClientWriteCharacteristicValueInternal(
|
|||
|
||||
void
|
||||
BluetoothDBusService::GattClientReadDescriptorValueInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
const BluetoothGattId& aCharacteristicId,
|
||||
const BluetoothGattId& aDescriptorId,
|
||||
|
@ -4440,7 +4386,7 @@ BluetoothDBusService::GattClientReadDescriptorValueInternal(
|
|||
|
||||
void
|
||||
BluetoothDBusService::GattClientWriteDescriptorValueInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
const BluetoothGattId& aCharacteristicId,
|
||||
const BluetoothGattId& aDescriptorId,
|
||||
|
@ -4575,14 +4521,14 @@ BluetoothDBusService::ReplyToMapMessageUpdate(long aMasId, bool aStatus,
|
|||
|
||||
void
|
||||
BluetoothDBusService::GattServerConnectPeripheralInternal(
|
||||
const nsAString& aAppUuid, const nsAString& aAddress,
|
||||
const BluetoothUuid& aAppUuid, const BluetoothAddress& aAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDBusService::GattServerDisconnectPeripheralInternal(
|
||||
const nsAString& aAppUuid, const nsAString& aAddress,
|
||||
const BluetoothUuid& aAppUuid, const BluetoothAddress& aAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
}
|
||||
|
@ -4595,7 +4541,7 @@ BluetoothDBusService::UnregisterGattServerInternal(
|
|||
|
||||
void
|
||||
BluetoothDBusService::GattServerAddServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
uint16_t aHandleCount,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
|
@ -4604,7 +4550,7 @@ BluetoothDBusService::GattServerAddServiceInternal(
|
|||
|
||||
void
|
||||
BluetoothDBusService::GattServerAddIncludedServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
const BluetoothAttributeHandle& aIncludedServiceHandle,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
|
@ -4613,7 +4559,7 @@ BluetoothDBusService::GattServerAddIncludedServiceInternal(
|
|||
|
||||
void
|
||||
BluetoothDBusService::GattServerAddCharacteristicInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
const BluetoothUuid& aCharacteristicUuid,
|
||||
BluetoothGattAttrPerm aPermissions,
|
||||
|
@ -4624,7 +4570,7 @@ BluetoothDBusService::GattServerAddCharacteristicInternal(
|
|||
|
||||
void
|
||||
BluetoothDBusService::GattServerAddDescriptorInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
const BluetoothAttributeHandle& aCharacteristicHandle,
|
||||
const BluetoothUuid& aDescriptorUuid,
|
||||
|
@ -4635,7 +4581,7 @@ BluetoothDBusService::GattServerAddDescriptorInternal(
|
|||
|
||||
void
|
||||
BluetoothDBusService::GattServerRemoveServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
|
@ -4643,7 +4589,7 @@ BluetoothDBusService::GattServerRemoveServiceInternal(
|
|||
|
||||
void
|
||||
BluetoothDBusService::GattServerStartServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
|
@ -4651,7 +4597,7 @@ BluetoothDBusService::GattServerStartServiceInternal(
|
|||
|
||||
void
|
||||
BluetoothDBusService::GattServerStopServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
|
@ -4659,8 +4605,8 @@ BluetoothDBusService::GattServerStopServiceInternal(
|
|||
|
||||
void
|
||||
BluetoothDBusService::GattServerSendIndicationInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aAddress,
|
||||
const BluetoothAttributeHandle& aCharacteristicHandle,
|
||||
bool aConfirm,
|
||||
const nsTArray<uint8_t>& aValue,
|
||||
|
@ -4670,8 +4616,8 @@ BluetoothDBusService::GattServerSendIndicationInternal(
|
|||
|
||||
void
|
||||
BluetoothDBusService::GattServerSendResponseInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aAddress,
|
||||
uint16_t aStatus,
|
||||
int32_t aRequestId,
|
||||
const BluetoothGattResponse& aRsp,
|
||||
|
|
|
@ -59,11 +59,12 @@ public:
|
|||
uint16_t aServiceUuid, BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual nsresult
|
||||
GetPairedDevicePropertiesInternal(const nsTArray<nsString>& aDeviceAddresses,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
GetPairedDevicePropertiesInternal(
|
||||
const nsTArray<BluetoothAddress>& aDeviceAddresses,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual nsresult
|
||||
FetchUuidsInternal(const nsAString& aDeviceAddress,
|
||||
FetchUuidsInternal(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
|
@ -87,65 +88,67 @@ public:
|
|||
BluetoothProfileManagerBase* aManager) override;
|
||||
|
||||
virtual nsresult
|
||||
CreatePairedDeviceInternal(const nsAString& aDeviceAddress,
|
||||
CreatePairedDeviceInternal(const BluetoothAddress& aDeviceAddress,
|
||||
int aTimeout,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual nsresult
|
||||
RemoveDeviceInternal(const nsAString& aDeviceObjectPath,
|
||||
RemoveDeviceInternal(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
PinReplyInternal(const nsAString& aDeviceAddress,
|
||||
PinReplyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
bool aAccept,
|
||||
const nsAString& aPinCode,
|
||||
const BluetoothPinCode& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
SspReplyInternal(const nsAString& aDeviceAddress,
|
||||
SspReplyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothSspVariant aVariant,
|
||||
bool aAccept,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
SetPinCodeInternal(const nsAString& aDeviceAddress, const nsAString& aPinCode,
|
||||
SetPinCodeInternal(const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothPinCode& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
SetPasskeyInternal(const nsAString& aDeviceAddress, uint32_t aPasskey,
|
||||
SetPasskeyInternal(const BluetoothAddress& aDeviceAddress, uint32_t aPasskey,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
SetPairingConfirmationInternal(const nsAString& aDeviceAddress, bool aConfirm,
|
||||
SetPairingConfirmationInternal(const BluetoothAddress& aDeviceAddress,
|
||||
bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
Connect(const nsAString& aDeviceAddress,
|
||||
Connect(const BluetoothAddress& aDeviceAddress,
|
||||
uint32_t aCod,
|
||||
uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
Disconnect(const nsAString& aDeviceAddress, uint16_t aServiceUuid,
|
||||
Disconnect(const BluetoothAddress& aDeviceAddress, uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
SendFile(const nsAString& aDeviceAddress,
|
||||
SendFile(const BluetoothAddress& aDeviceAddress,
|
||||
BlobParent* aBlobParent,
|
||||
BlobChild* aBlobChild,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
SendFile(const nsAString& aDeviceAddress,
|
||||
SendFile(const BluetoothAddress& aDeviceAddress,
|
||||
Blob* aBlob,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
StopSendingFile(const nsAString& aDeviceAddress,
|
||||
StopSendingFile(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
ConfirmReceivingFile(const nsAString& aDeviceAddress, bool aConfirm,
|
||||
ConfirmReceivingFile(const BluetoothAddress& aDeviceAddress, bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
|
@ -265,7 +268,7 @@ public:
|
|||
virtual void
|
||||
SendPlayStatus(int64_t aDuration,
|
||||
int64_t aPosition,
|
||||
const nsAString& aPlayStatus,
|
||||
ControlPlayStatus aPlayStatus,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
|
@ -282,37 +285,37 @@ public:
|
|||
const nsAString& aMessage) override;
|
||||
|
||||
virtual void
|
||||
StartLeScanInternal(const nsTArray<nsString>& aServiceUuids,
|
||||
StartLeScanInternal(const nsTArray<BluetoothUuid>& aServiceUuids,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
StopLeScanInternal(const nsAString& aAppUuid,
|
||||
StopLeScanInternal(const BluetoothUuid& aAppUuid,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
ConnectGattClientInternal(const nsAString& aAppUuid,
|
||||
const nsAString& aDeviceAddress,
|
||||
ConnectGattClientInternal(const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
DisconnectGattClientInternal(const nsAString& aAppUuid,
|
||||
const nsAString& aDeviceAddress,
|
||||
DisconnectGattClientInternal(const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
DiscoverGattServicesInternal(const nsAString& aAppUuid,
|
||||
DiscoverGattServicesInternal(const BluetoothUuid& aAppUuid,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattClientStartNotificationsInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServId,
|
||||
const BluetoothGattId& aCharId,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattClientStopNotificationsInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServId,
|
||||
const BluetoothGattId& aCharId,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
@ -323,19 +326,19 @@ public:
|
|||
|
||||
virtual void
|
||||
GattClientReadRemoteRssiInternal(
|
||||
int aClientIf, const nsAString& aDeviceAddress,
|
||||
int aClientIf, const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattClientReadCharacteristicValueInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
const BluetoothGattId& aCharacteristicId,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattClientWriteCharacteristicValueInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
const BluetoothGattId& aCharacteristicId,
|
||||
const BluetoothGattWriteType& aWriteType,
|
||||
|
@ -344,7 +347,7 @@ public:
|
|||
|
||||
virtual void
|
||||
GattClientReadDescriptorValueInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
const BluetoothGattId& aCharacteristicId,
|
||||
const BluetoothGattId& aDescriptorId,
|
||||
|
@ -352,7 +355,7 @@ public:
|
|||
|
||||
virtual void
|
||||
GattClientWriteDescriptorValueInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
const BluetoothGattId& aCharacteristicId,
|
||||
const BluetoothGattId& aDescriptorId,
|
||||
|
@ -361,14 +364,14 @@ public:
|
|||
|
||||
virtual void
|
||||
GattServerConnectPeripheralInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattServerDisconnectPeripheralInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
|
@ -377,21 +380,21 @@ public:
|
|||
|
||||
virtual void
|
||||
GattServerAddServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
uint16_t aHandleCount,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattServerAddIncludedServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
const BluetoothAttributeHandle& aIncludedServiceHandle,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattServerAddCharacteristicInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
const BluetoothUuid& aCharacteristicUuid,
|
||||
BluetoothGattAttrPerm aPermissions,
|
||||
|
@ -400,7 +403,7 @@ public:
|
|||
|
||||
virtual void
|
||||
GattServerAddDescriptorInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
const BluetoothAttributeHandle& aCharacteristicHandle,
|
||||
const BluetoothUuid& aDescriptorUuid,
|
||||
|
@ -409,26 +412,26 @@ public:
|
|||
|
||||
virtual void
|
||||
GattServerRemoveServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattServerStartServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattServerStopServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattServerSendResponseInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aAddress,
|
||||
uint16_t aStatus,
|
||||
int32_t aRequestId,
|
||||
const BluetoothGattResponse& aRsp,
|
||||
|
@ -436,8 +439,8 @@ public:
|
|||
|
||||
virtual void
|
||||
GattServerSendIndicationInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aAddress,
|
||||
const BluetoothAttributeHandle& aCharacteristicHandle,
|
||||
bool aConfirm,
|
||||
const nsTArray<uint8_t>& aValue,
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
|
||||
#include "BluetoothCommon.h"
|
||||
|
||||
// FIXME: Bug 1224171: This variable needs to be cleaned up and
|
||||
// remove from global namespace.
|
||||
bool gBluetoothDebugFlag = false;
|
||||
|
||||
BEGIN_BLUETOOTH_NAMESPACE
|
||||
|
||||
//
|
||||
|
|
|
@ -674,6 +674,24 @@ struct BluetoothUuid {
|
|||
struct BluetoothPinCode {
|
||||
uint8_t mPinCode[16]; /* not \0-terminated */
|
||||
uint8_t mLength;
|
||||
|
||||
BluetoothPinCode()
|
||||
: mLength(0)
|
||||
{
|
||||
std::fill(mPinCode, mPinCode + MOZ_ARRAY_LENGTH(mPinCode), 0);
|
||||
}
|
||||
|
||||
bool operator==(const BluetoothPinCode& aRhs) const
|
||||
{
|
||||
MOZ_ASSERT(mLength <= MOZ_ARRAY_LENGTH(mPinCode));
|
||||
return (mLength == aRhs.mLength) &&
|
||||
std::equal(aRhs.mPinCode, aRhs.mPinCode + aRhs.mLength, mPinCode);
|
||||
}
|
||||
|
||||
bool operator!=(const BluetoothPinCode& aRhs) const
|
||||
{
|
||||
return !operator==(aRhs);
|
||||
}
|
||||
};
|
||||
|
||||
struct BluetoothServiceName {
|
||||
|
|
|
@ -165,6 +165,12 @@ MobileConnectionListener::NotifyNetworkSelectionModeChanged()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionListener::NotifyDeviceIdentitiesChanged()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
MobileConnectionListener::Listen(bool aStart)
|
||||
{
|
||||
|
|
|
@ -69,8 +69,6 @@
|
|||
|
||||
#define DEFAULT_SHUTDOWN_TIMER_MS 5000
|
||||
|
||||
bool gBluetoothDebugFlag = false;
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
USING_BLUETOOTH_NAMESPACE
|
||||
|
|
|
@ -149,8 +149,9 @@ public:
|
|||
* @return NS_OK on success, NS_ERROR_FAILURE otherwise
|
||||
*/
|
||||
virtual nsresult
|
||||
GetPairedDevicePropertiesInternal(const nsTArray<nsString>& aDeviceAddresses,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
GetPairedDevicePropertiesInternal(
|
||||
const nsTArray<BluetoothAddress>& aDeviceAddresses,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
/**
|
||||
* Returns the properties of connected devices regarding to specific profile,
|
||||
|
@ -169,7 +170,7 @@ public:
|
|||
* @return NS_OK on success, NS_ERROR_FAILURE otherwise
|
||||
*/
|
||||
virtual nsresult
|
||||
FetchUuidsInternal(const nsAString& aDeviceAddress,
|
||||
FetchUuidsInternal(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
/**
|
||||
|
@ -188,14 +189,14 @@ public:
|
|||
* Stops an ongoing Bluetooth LE device scan.
|
||||
*/
|
||||
virtual void
|
||||
StopLeScanInternal(const nsAString& aScanUuid,
|
||||
StopLeScanInternal(const BluetoothUuid& aScanUuid,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
/**
|
||||
* Starts a Bluetooth LE device scan.
|
||||
*/
|
||||
virtual void
|
||||
StartLeScanInternal(const nsTArray<nsString>& aServiceUuids,
|
||||
StartLeScanInternal(const nsTArray<BluetoothUuid>& aServiceUuids,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
/**
|
||||
|
@ -213,12 +214,12 @@ public:
|
|||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual nsresult
|
||||
CreatePairedDeviceInternal(const nsAString& aAddress,
|
||||
CreatePairedDeviceInternal(const BluetoothAddress& aDeviceAddress,
|
||||
int aTimeout,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual nsresult
|
||||
RemoveDeviceInternal(const nsAString& aObjectPath,
|
||||
RemoveDeviceInternal(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
/**
|
||||
|
@ -241,13 +242,13 @@ public:
|
|||
BluetoothProfileManagerBase* aManager) = 0;
|
||||
|
||||
virtual void
|
||||
PinReplyInternal(const nsAString& aDeviceAddress,
|
||||
PinReplyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
bool aAccept,
|
||||
const nsAString& aPinCode,
|
||||
const BluetoothPinCode& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual void
|
||||
SspReplyInternal(const nsAString& aDeviceAddress,
|
||||
SspReplyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothSspVariant aVariant,
|
||||
bool aAccept,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
@ -256,49 +257,51 @@ public:
|
|||
* Legacy method used by bluez only to reply pincode request.
|
||||
*/
|
||||
virtual void
|
||||
SetPinCodeInternal(const nsAString& aDeviceAddress,
|
||||
const nsAString& aPinCode,
|
||||
SetPinCodeInternal(const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothPinCode& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
/**
|
||||
* Legacy method used by bluez only to reply passkey entry request.
|
||||
*/
|
||||
virtual void
|
||||
SetPasskeyInternal(const nsAString& aDeviceAddress, uint32_t aPasskey,
|
||||
SetPasskeyInternal(const BluetoothAddress& aDeviceAddress, uint32_t aPasskey,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
/**
|
||||
* Legacy method used by bluez only to reply pairing confirmation request.
|
||||
*/
|
||||
virtual void
|
||||
SetPairingConfirmationInternal(const nsAString& aDeviceAddress, bool aConfirm,
|
||||
SetPairingConfirmationInternal(const BluetoothAddress& aDeviceAddress,
|
||||
bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual void
|
||||
Connect(const nsAString& aDeviceAddress, uint32_t aCod, uint16_t aServiceUuid,
|
||||
Connect(const BluetoothAddress& aDeviceAddress,
|
||||
uint32_t aCod, uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual void
|
||||
Disconnect(const nsAString& aDeviceAddress, uint16_t aServiceUuid,
|
||||
Disconnect(const BluetoothAddress& aDeviceAddress, uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual void
|
||||
SendFile(const nsAString& aDeviceAddress,
|
||||
SendFile(const BluetoothAddress& aDeviceAddress,
|
||||
BlobParent* aBlobParent,
|
||||
BlobChild* aBlobChild,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual void
|
||||
SendFile(const nsAString& aDeviceAddress,
|
||||
SendFile(const BluetoothAddress& aDeviceAddress,
|
||||
Blob* aBlob,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual void
|
||||
StopSendingFile(const nsAString& aDeviceAddress,
|
||||
StopSendingFile(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual void
|
||||
ConfirmReceivingFile(const nsAString& aDeviceAddress, bool aConfirm,
|
||||
ConfirmReceivingFile(const BluetoothAddress& aDeviceAddress, bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual void
|
||||
|
@ -418,7 +421,7 @@ public:
|
|||
virtual void
|
||||
SendPlayStatus(int64_t aDuration,
|
||||
int64_t aPosition,
|
||||
const nsAString& aPlayStatus,
|
||||
ControlPlayStatus aPlayStatus,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual void
|
||||
|
@ -438,8 +441,8 @@ public:
|
|||
* Connect to a remote GATT server. (platform specific implementation)
|
||||
*/
|
||||
virtual void
|
||||
ConnectGattClientInternal(const nsAString& aAppUuid,
|
||||
const nsAString& aDeviceAddress,
|
||||
ConnectGattClientInternal(const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
/**
|
||||
|
@ -447,8 +450,8 @@ public:
|
|||
* (platform specific implementation)
|
||||
*/
|
||||
virtual void
|
||||
DisconnectGattClientInternal(const nsAString& aAppUuid,
|
||||
const nsAString& aDeviceAddress,
|
||||
DisconnectGattClientInternal(const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
/**
|
||||
|
@ -456,7 +459,7 @@ public:
|
|||
* server. (platform specific implementation)
|
||||
*/
|
||||
virtual void
|
||||
DiscoverGattServicesInternal(const nsAString& aAppUuid,
|
||||
DiscoverGattServicesInternal(const BluetoothUuid& aAppUuid,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
/**
|
||||
|
@ -464,7 +467,7 @@ public:
|
|||
* (platform specific implementation)
|
||||
*/
|
||||
virtual void
|
||||
GattClientStartNotificationsInternal(const nsAString& aAppUuid,
|
||||
GattClientStartNotificationsInternal(const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServId,
|
||||
const BluetoothGattId& aCharId,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
@ -474,7 +477,7 @@ public:
|
|||
* (platform specific implementation)
|
||||
*/
|
||||
virtual void
|
||||
GattClientStopNotificationsInternal(const nsAString& aAppUuid,
|
||||
GattClientStopNotificationsInternal(const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServId,
|
||||
const BluetoothGattId& aCharId,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
@ -491,7 +494,7 @@ public:
|
|||
*/
|
||||
virtual void
|
||||
GattClientReadRemoteRssiInternal(int aClientIf,
|
||||
const nsAString& aDeviceAddress,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
/**
|
||||
|
@ -500,7 +503,7 @@ public:
|
|||
*/
|
||||
virtual void
|
||||
GattClientReadCharacteristicValueInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
const BluetoothGattId& aCharacteristicId,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
@ -511,7 +514,7 @@ public:
|
|||
*/
|
||||
virtual void
|
||||
GattClientWriteCharacteristicValueInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
const BluetoothGattId& aCharacteristicId,
|
||||
const BluetoothGattWriteType& aWriteType,
|
||||
|
@ -524,7 +527,7 @@ public:
|
|||
*/
|
||||
virtual void
|
||||
GattClientReadDescriptorValueInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
const BluetoothGattId& aCharacteristicId,
|
||||
const BluetoothGattId& aDescriptorId,
|
||||
|
@ -536,7 +539,7 @@ public:
|
|||
*/
|
||||
virtual void
|
||||
GattClientWriteDescriptorValueInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
const BluetoothGattId& aCharacteristicId,
|
||||
const BluetoothGattId& aDescriptorId,
|
||||
|
@ -545,14 +548,14 @@ public:
|
|||
|
||||
virtual void
|
||||
GattServerConnectPeripheralInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aAddress,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual void
|
||||
GattServerDisconnectPeripheralInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aAddress,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
/**
|
||||
|
@ -564,21 +567,21 @@ public:
|
|||
|
||||
virtual void
|
||||
GattServerAddServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
uint16_t aHandleCount,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual void
|
||||
GattServerAddIncludedServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
const BluetoothAttributeHandle& aIncludedServiceHandle,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual void
|
||||
GattServerAddCharacteristicInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
const BluetoothUuid& aCharacteristicUuid,
|
||||
BluetoothGattAttrPerm aPermissions,
|
||||
|
@ -587,7 +590,7 @@ public:
|
|||
|
||||
virtual void
|
||||
GattServerAddDescriptorInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
const BluetoothAttributeHandle& aCharacteristicHandle,
|
||||
const BluetoothUuid& aDescriptorUuid,
|
||||
|
@ -596,26 +599,26 @@ public:
|
|||
|
||||
virtual void
|
||||
GattServerRemoveServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual void
|
||||
GattServerStartServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual void
|
||||
GattServerStopServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual void
|
||||
GattServerSendResponseInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aAddress,
|
||||
uint16_t aStatus,
|
||||
int32_t aRequestId,
|
||||
const BluetoothGattResponse& aRsp,
|
||||
|
@ -623,8 +626,8 @@ public:
|
|||
|
||||
virtual void
|
||||
GattServerSendIndicationInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aAddress,
|
||||
const BluetoothAttributeHandle& aCharacteristicHandle,
|
||||
bool aConfirm,
|
||||
const nsTArray<uint8_t>& aValue,
|
||||
|
|
|
@ -61,6 +61,21 @@ StringToAddress(const nsAString& aString, BluetoothAddress& aAddress)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
PinCodeToString(const BluetoothPinCode& aPinCode, nsAString& aString)
|
||||
{
|
||||
if (aPinCode.mLength > sizeof(aPinCode.mPinCode)) {
|
||||
BT_LOGR("Pin-code string too long");
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
aString = NS_ConvertUTF8toUTF16(
|
||||
nsCString(reinterpret_cast<const char*>(aPinCode.mPinCode),
|
||||
aPinCode.mLength));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
StringToPinCode(const nsAString& aString, BluetoothPinCode& aPinCode)
|
||||
{
|
||||
|
@ -69,7 +84,7 @@ StringToPinCode(const nsAString& aString, BluetoothPinCode& aPinCode)
|
|||
auto len = stringUTF8.Length();
|
||||
|
||||
if (len > sizeof(aPinCode.mPinCode)) {
|
||||
BT_LOGR("Service-name string too long");
|
||||
BT_LOGR("Pin-code string too long");
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
|
@ -82,6 +97,31 @@ StringToPinCode(const nsAString& aString, BluetoothPinCode& aPinCode)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
StringToControlPlayStatus(const nsAString& aString,
|
||||
ControlPlayStatus& aPlayStatus)
|
||||
{
|
||||
if (aString.EqualsLiteral("STOPPED")) {
|
||||
aPlayStatus = ControlPlayStatus::PLAYSTATUS_STOPPED;
|
||||
} else if (aString.EqualsLiteral("PLAYING")) {
|
||||
aPlayStatus = ControlPlayStatus::PLAYSTATUS_PLAYING;
|
||||
} else if (aString.EqualsLiteral("PAUSED")) {
|
||||
aPlayStatus = ControlPlayStatus::PLAYSTATUS_PAUSED;
|
||||
} else if (aString.EqualsLiteral("FWD_SEEK")) {
|
||||
aPlayStatus = ControlPlayStatus::PLAYSTATUS_FWD_SEEK;
|
||||
} else if (aString.EqualsLiteral("REV_SEEK")) {
|
||||
aPlayStatus = ControlPlayStatus::PLAYSTATUS_REV_SEEK;
|
||||
} else if (aString.EqualsLiteral("ERROR")) {
|
||||
aPlayStatus = ControlPlayStatus::PLAYSTATUS_ERROR;
|
||||
} else {
|
||||
BT_LOGR("Invalid play status: %s", NS_ConvertUTF16toUTF8(aString).get());
|
||||
aPlayStatus = ControlPlayStatus::PLAYSTATUS_UNKNOWN;
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
StringToPropertyType(const nsAString& aString, BluetoothPropertyType& aType)
|
||||
{
|
||||
|
@ -205,15 +245,18 @@ UuidToString(const BluetoothUuid& aUuid, nsAString& aString)
|
|||
aString.AssignLiteral(uuidStr);
|
||||
}
|
||||
|
||||
void
|
||||
nsresult
|
||||
StringToUuid(const nsAString& aString, BluetoothUuid& aUuid)
|
||||
{
|
||||
uint32_t uuid0, uuid4;
|
||||
uint16_t uuid1, uuid2, uuid3, uuid5;
|
||||
|
||||
sscanf(NS_ConvertUTF16toUTF8(aString).get(),
|
||||
"%08x-%04hx-%04hx-%04hx-%08x%04hx",
|
||||
&uuid0, &uuid1, &uuid2, &uuid3, &uuid4, &uuid5);
|
||||
auto res = sscanf(NS_ConvertUTF16toUTF8(aString).get(),
|
||||
"%08x-%04hx-%04hx-%04hx-%08x%04hx",
|
||||
&uuid0, &uuid1, &uuid2, &uuid3, &uuid4, &uuid5);
|
||||
if (res == EOF || res < 6) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
uuid0 = htonl(uuid0);
|
||||
uuid1 = htons(uuid1);
|
||||
|
@ -228,6 +271,8 @@ StringToUuid(const nsAString& aString, BluetoothUuid& aUuid)
|
|||
memcpy(&aUuid.mUuid[8], &uuid3, sizeof(uint16_t));
|
||||
memcpy(&aUuid.mUuid[10], &uuid4, sizeof(uint32_t));
|
||||
memcpy(&aUuid.mUuid[14], &uuid5, sizeof(uint16_t));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -37,9 +37,20 @@ StringToAddress(const nsAString& aString, BluetoothAddress& aAddress);
|
|||
// Pin code/string conversion
|
||||
//
|
||||
|
||||
nsresult
|
||||
PinCodeToString(const BluetoothPinCode& aPinCode, nsAString& aString);
|
||||
|
||||
nsresult
|
||||
StringToPinCode(const nsAString& aString, BluetoothPinCode& aPinCode);
|
||||
|
||||
//
|
||||
// Play status/string conversion
|
||||
//
|
||||
|
||||
nsresult
|
||||
StringToControlPlayStatus(const nsAString& aString,
|
||||
ControlPlayStatus& aPlayStatus);
|
||||
|
||||
//
|
||||
// Property type/string conversion
|
||||
//
|
||||
|
@ -89,7 +100,7 @@ UuidToString(const BluetoothUuid& aUuid, nsAString& aString);
|
|||
* Note: This utility function is used by gecko internal only to convert uuid
|
||||
* string created by gecko back to BluetoothUuid representation.
|
||||
*/
|
||||
void
|
||||
nsresult
|
||||
StringToUuid(const nsAString& aString, BluetoothUuid& aUuid);
|
||||
|
||||
/**
|
||||
|
|
|
@ -366,12 +366,16 @@ BluetoothAdapter::Cleanup()
|
|||
BluetoothService* bs = BluetoothService::Get();
|
||||
NS_ENSURE_TRUE_VOID(bs);
|
||||
|
||||
nsString uuid;
|
||||
nsString uuidStr;
|
||||
for (uint32_t i = 0; i < mLeScanHandleArray.Length(); ++i) {
|
||||
mLeScanHandleArray[i]->GetLeScanUuid(uuid);
|
||||
mLeScanHandleArray[i]->GetLeScanUuid(uuidStr);
|
||||
RefPtr<BluetoothVoidReplyRunnable> results =
|
||||
new BluetoothVoidReplyRunnable(nullptr);
|
||||
bs->StopLeScanInternal(uuid, results);
|
||||
|
||||
BluetoothUuid uuid;
|
||||
if (NS_SUCCEEDED(StringToUuid(uuidStr, uuid))) {
|
||||
bs->StopLeScanInternal(uuid, results);
|
||||
}
|
||||
}
|
||||
mLeScanHandleArray.Clear();
|
||||
}
|
||||
|
@ -405,13 +409,24 @@ BluetoothAdapter::GetPairedDeviceProperties(
|
|||
BluetoothService* bs = BluetoothService::Get();
|
||||
NS_ENSURE_TRUE_VOID(bs);
|
||||
|
||||
nsTArray<BluetoothAddress> deviceAddresses;
|
||||
deviceAddresses.SetLength(aDeviceAddresses.Length());
|
||||
|
||||
for (size_t i = 0; i < deviceAddresses.Length(); ++i) {
|
||||
auto rv = StringToAddress(aDeviceAddresses[i], deviceAddresses[i]);
|
||||
if (NS_FAILED(rv)) {
|
||||
BT_WARNING("GetPairedDeviceProperties failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<BluetoothVoidReplyRunnable> results =
|
||||
new BluetoothVoidReplyRunnable(nullptr);
|
||||
|
||||
nsresult rv =
|
||||
bs->GetPairedDevicePropertiesInternal(aDeviceAddresses, results);
|
||||
auto rv = bs->GetPairedDevicePropertiesInternal(deviceAddresses, results);
|
||||
if (NS_FAILED(rv)) {
|
||||
BT_WARNING("GetPairedDeviceProperties failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -671,6 +686,16 @@ BluetoothAdapter::StartLeScan(const nsTArray<nsString>& aServiceUuids,
|
|||
RefPtr<Promise> promise = Promise::Create(global, aRv);
|
||||
NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
|
||||
|
||||
nsTArray<BluetoothUuid> serviceUuids;
|
||||
serviceUuids.SetLength(aServiceUuids.Length());
|
||||
|
||||
for (size_t i = 0; i < serviceUuids.Length(); ++i) {
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(StringToUuid(aServiceUuids[i],
|
||||
serviceUuids[i])),
|
||||
promise,
|
||||
NS_ERROR_DOM_OPERATION_ERR);
|
||||
}
|
||||
|
||||
BT_ENSURE_TRUE_REJECT(mState == BluetoothAdapterState::Enabled,
|
||||
promise,
|
||||
NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
|
@ -680,7 +705,7 @@ BluetoothAdapter::StartLeScan(const nsTArray<nsString>& aServiceUuids,
|
|||
|
||||
RefPtr<BluetoothReplyRunnable> result =
|
||||
new StartLeScanTask(this, promise, aServiceUuids);
|
||||
bs->StartLeScanInternal(aServiceUuids, result);
|
||||
bs->StartLeScanInternal(serviceUuids, result);
|
||||
|
||||
return promise.forget();
|
||||
}
|
||||
|
@ -710,10 +735,16 @@ BluetoothAdapter::StopLeScan(BluetoothDiscoveryHandle& aDiscoveryHandle,
|
|||
promise,
|
||||
NS_ERROR_DOM_BLUETOOTH_DONE);
|
||||
|
||||
nsString scanUuid;
|
||||
aDiscoveryHandle.GetLeScanUuid(scanUuid);
|
||||
nsString scanUuidStr;
|
||||
aDiscoveryHandle.GetLeScanUuid(scanUuidStr);
|
||||
|
||||
BluetoothUuid scanUuid;
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(StringToUuid(scanUuidStr, scanUuid)),
|
||||
promise,
|
||||
NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
||||
RefPtr<BluetoothReplyRunnable> result =
|
||||
new StopLeScanTask(this, promise, scanUuid);
|
||||
new StopLeScanTask(this, promise, scanUuidStr);
|
||||
bs->StopLeScanInternal(scanUuid, result);
|
||||
|
||||
return promise.forget();
|
||||
|
@ -851,11 +882,13 @@ BluetoothAdapter::PairUnpair(bool aPair, const nsAString& aDeviceAddress,
|
|||
|
||||
/**
|
||||
* Ensure
|
||||
* - device address is not empty,
|
||||
* - device address is valid,
|
||||
* - adapter is already enabled, and
|
||||
* - BluetoothService is available.
|
||||
*/
|
||||
BT_ENSURE_TRUE_REJECT(!aDeviceAddress.IsEmpty(),
|
||||
BluetoothAddress deviceAddress;
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(StringToAddress(aDeviceAddress,
|
||||
deviceAddress)),
|
||||
promise,
|
||||
NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
BT_ENSURE_TRUE_REJECT(mState == BluetoothAdapterState::Enabled,
|
||||
|
@ -867,10 +900,10 @@ BluetoothAdapter::PairUnpair(bool aPair, const nsAString& aDeviceAddress,
|
|||
nsresult rv;
|
||||
if (aPair) {
|
||||
rv = bs->CreatePairedDeviceInternal(
|
||||
aDeviceAddress, kCreatePairedDeviceTimeout,
|
||||
deviceAddress, kCreatePairedDeviceTimeout,
|
||||
new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
} else {
|
||||
rv = bs->RemoveDeviceInternal(aDeviceAddress,
|
||||
rv = bs->RemoveDeviceInternal(deviceAddress,
|
||||
new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
}
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(rv), promise, NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
@ -1660,6 +1693,12 @@ BluetoothAdapter::Connect(BluetoothDevice& aDevice,
|
|||
|
||||
nsAutoString address;
|
||||
aDevice.GetAddress(address);
|
||||
BluetoothAddress deviceAddress;
|
||||
if (NS_FAILED(StringToAddress(address, deviceAddress))) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t deviceClass = aDevice.Cod()->ToUint32();
|
||||
uint16_t serviceUuid = 0;
|
||||
if (aServiceUuid.WasPassed()) {
|
||||
|
@ -1671,7 +1710,7 @@ BluetoothAdapter::Connect(BluetoothDevice& aDevice,
|
|||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
bs->Connect(address, deviceClass, serviceUuid, results);
|
||||
bs->Connect(deviceAddress, deviceClass, serviceUuid, results);
|
||||
|
||||
return request.forget();
|
||||
}
|
||||
|
@ -1693,6 +1732,12 @@ BluetoothAdapter::Disconnect(BluetoothDevice& aDevice,
|
|||
|
||||
nsAutoString address;
|
||||
aDevice.GetAddress(address);
|
||||
BluetoothAddress deviceAddress;
|
||||
if (NS_FAILED(StringToAddress(address, deviceAddress))) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint16_t serviceUuid = 0;
|
||||
if (aServiceUuid.WasPassed()) {
|
||||
serviceUuid = aServiceUuid.Value();
|
||||
|
@ -1703,7 +1748,7 @@ BluetoothAdapter::Disconnect(BluetoothDevice& aDevice,
|
|||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
bs->Disconnect(address, serviceUuid, results);
|
||||
bs->Disconnect(deviceAddress, serviceUuid, results);
|
||||
|
||||
return request.forget();
|
||||
}
|
||||
|
@ -1722,6 +1767,13 @@ BluetoothAdapter::SendFile(const nsAString& aDeviceAddress,
|
|||
RefPtr<BluetoothVoidReplyRunnable> results =
|
||||
new BluetoothVoidReplyRunnable(request);
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
auto rv = StringToAddress(aDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
if (!bs) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
|
@ -1730,7 +1782,7 @@ BluetoothAdapter::SendFile(const nsAString& aDeviceAddress,
|
|||
|
||||
if (XRE_IsParentProcess()) {
|
||||
// In-process transfer
|
||||
bs->SendFile(aDeviceAddress, &aBlob, results);
|
||||
bs->SendFile(deviceAddress, &aBlob, results);
|
||||
} else {
|
||||
ContentChild *cc = ContentChild::GetSingleton();
|
||||
if (!cc) {
|
||||
|
@ -1744,7 +1796,7 @@ BluetoothAdapter::SendFile(const nsAString& aDeviceAddress,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bs->SendFile(aDeviceAddress, nullptr, actor, results);
|
||||
bs->SendFile(deviceAddress, nullptr, actor, results);
|
||||
}
|
||||
|
||||
return request.forget();
|
||||
|
@ -1764,12 +1816,19 @@ BluetoothAdapter::StopSendingFile(
|
|||
RefPtr<BluetoothVoidReplyRunnable> results =
|
||||
new BluetoothVoidReplyRunnable(request);
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
auto rv = StringToAddress(aDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
if (!bs) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
bs->StopSendingFile(aDeviceAddress, results);
|
||||
bs->StopSendingFile(deviceAddress, results);
|
||||
|
||||
return request.forget();
|
||||
}
|
||||
|
@ -1788,12 +1847,19 @@ BluetoothAdapter::ConfirmReceivingFile(const nsAString& aDeviceAddress,
|
|||
RefPtr<BluetoothVoidReplyRunnable> results =
|
||||
new BluetoothVoidReplyRunnable(request);
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
auto rv = StringToAddress(aDeviceAddress, deviceAddress);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
if (!bs) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
bs->ConfirmReceivingFile(aDeviceAddress, aConfirmation, results);
|
||||
bs->ConfirmReceivingFile(deviceAddress, aConfirmation, results);
|
||||
|
||||
return request.forget();
|
||||
}
|
||||
|
@ -1991,6 +2057,13 @@ BluetoothAdapter::SendMediaPlayStatus(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
ControlPlayStatus playStatus;
|
||||
auto rv = StringToControlPlayStatus(aMediaPlayStatus.mPlayStatus, playStatus);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<DOMRequest> request = new DOMRequest(win);
|
||||
RefPtr<BluetoothReplyRunnable> results =
|
||||
new BluetoothVoidReplyRunnable(request);
|
||||
|
@ -2002,7 +2075,7 @@ BluetoothAdapter::SendMediaPlayStatus(
|
|||
}
|
||||
bs->SendPlayStatus(aMediaPlayStatus.mDuration,
|
||||
aMediaPlayStatus.mPosition,
|
||||
aMediaPlayStatus.mPlayStatus,
|
||||
playStatus,
|
||||
results);
|
||||
|
||||
return request.forget();
|
||||
|
|
|
@ -187,10 +187,13 @@ BluetoothDevice::FetchUuids(ErrorResult& aRv)
|
|||
// Ensure BluetoothService is available
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
BluetoothAddress address;
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(StringToAddress(mAddress, address)),
|
||||
promise,
|
||||
NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
BT_ENSURE_TRUE_REJECT(
|
||||
NS_SUCCEEDED(
|
||||
bs->FetchUuidsInternal(mAddress, new FetchUuidsTask(promise, this))),
|
||||
bs->FetchUuidsInternal(address, new FetchUuidsTask(promise, this))),
|
||||
promise, NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
||||
return promise.forget();
|
||||
|
|
|
@ -112,6 +112,17 @@ BluetoothGatt::Connect(ErrorResult& aRv)
|
|||
BluetoothService* bs = BluetoothService::Get();
|
||||
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(StringToUuid(mAppUuid, appUuid)),
|
||||
promise,
|
||||
NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
||||
BluetoothAddress deviceAddr;
|
||||
BT_ENSURE_TRUE_REJECT(
|
||||
NS_SUCCEEDED(StringToAddress(mDeviceAddr, deviceAddr)),
|
||||
promise,
|
||||
NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
||||
if (mAppUuid.IsEmpty()) {
|
||||
nsresult rv = GenerateUuid(mAppUuid);
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(rv) && !mAppUuid.IsEmpty(),
|
||||
|
@ -122,7 +133,7 @@ BluetoothGatt::Connect(ErrorResult& aRv)
|
|||
|
||||
UpdateConnectionState(BluetoothConnectionState::Connecting);
|
||||
bs->ConnectGattClientInternal(
|
||||
mAppUuid, mDeviceAddr, new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
appUuid, deviceAddr, new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
|
||||
return promise.forget();
|
||||
}
|
||||
|
@ -147,9 +158,20 @@ BluetoothGatt::Disconnect(ErrorResult& aRv)
|
|||
BluetoothService* bs = BluetoothService::Get();
|
||||
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(StringToUuid(mAppUuid, appUuid)),
|
||||
promise,
|
||||
NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
||||
BluetoothAddress deviceAddr;
|
||||
BT_ENSURE_TRUE_REJECT(
|
||||
NS_SUCCEEDED(StringToAddress(mDeviceAddr, deviceAddr)),
|
||||
promise,
|
||||
NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
||||
UpdateConnectionState(BluetoothConnectionState::Disconnecting);
|
||||
bs->DisconnectGattClientInternal(
|
||||
mAppUuid, mDeviceAddr, new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
appUuid, deviceAddr, new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
|
||||
return promise.forget();
|
||||
}
|
||||
|
@ -196,8 +218,14 @@ BluetoothGatt::ReadRemoteRssi(ErrorResult& aRv)
|
|||
BluetoothService* bs = BluetoothService::Get();
|
||||
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
BluetoothAddress deviceAddr;
|
||||
BT_ENSURE_TRUE_REJECT(
|
||||
NS_SUCCEEDED(StringToAddress(mDeviceAddr, deviceAddr)),
|
||||
promise,
|
||||
NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
||||
bs->GattClientReadRemoteRssiInternal(
|
||||
mClientIf, mDeviceAddr, new ReadRemoteRssiTask(promise));
|
||||
mClientIf, deviceAddr, new ReadRemoteRssiTask(promise));
|
||||
|
||||
return promise.forget();
|
||||
}
|
||||
|
@ -214,6 +242,11 @@ BluetoothGatt::DiscoverServices(ErrorResult& aRv)
|
|||
RefPtr<Promise> promise = Promise::Create(global, aRv);
|
||||
NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(StringToUuid(mAppUuid, appUuid)),
|
||||
promise,
|
||||
NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
||||
BT_ENSURE_TRUE_REJECT(
|
||||
mConnectionState == BluetoothConnectionState::Connected &&
|
||||
!mDiscoveringServices,
|
||||
|
@ -228,7 +261,7 @@ BluetoothGatt::DiscoverServices(ErrorResult& aRv)
|
|||
BluetoothGattBinding::ClearCachedServicesValue(this);
|
||||
|
||||
bs->DiscoverGattServicesInternal(
|
||||
mAppUuid, new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
appUuid, new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
|
||||
return promise.forget();
|
||||
}
|
||||
|
|
|
@ -154,8 +154,14 @@ BluetoothGattCharacteristic::StartNotifications(ErrorResult& aRv)
|
|||
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
BT_ENSURE_TRUE_REJECT(mService, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(StringToUuid(mService->GetAppUuid(),
|
||||
appUuid)),
|
||||
promise,
|
||||
NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
||||
bs->GattClientStartNotificationsInternal(
|
||||
mService->GetAppUuid(), mService->GetServiceId(), mCharId,
|
||||
appUuid, mService->GetServiceId(), mCharId,
|
||||
new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
|
||||
return promise.forget();
|
||||
|
@ -181,8 +187,14 @@ BluetoothGattCharacteristic::StopNotifications(ErrorResult& aRv)
|
|||
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
BT_ENSURE_TRUE_REJECT(mService, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(StringToUuid(mService->GetAppUuid(),
|
||||
appUuid)),
|
||||
promise,
|
||||
NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
||||
bs->GattClientStopNotificationsInternal(
|
||||
mService->GetAppUuid(), mService->GetServiceId(), mCharId,
|
||||
appUuid, mService->GetServiceId(), mCharId,
|
||||
new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
|
||||
return promise.forget();
|
||||
|
@ -362,8 +374,14 @@ BluetoothGattCharacteristic::ReadValue(ErrorResult& aRv)
|
|||
BluetoothService* bs = BluetoothService::Get();
|
||||
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(StringToUuid(mService->GetAppUuid(),
|
||||
appUuid)),
|
||||
promise,
|
||||
NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
||||
bs->GattClientReadCharacteristicValueInternal(
|
||||
mService->GetAppUuid(), mService->GetServiceId(), mCharId,
|
||||
appUuid, mService->GetServiceId(), mCharId,
|
||||
new ReadValueTask(this, promise));
|
||||
|
||||
return promise.forget();
|
||||
|
@ -405,9 +423,14 @@ BluetoothGattCharacteristic::WriteValue(const ArrayBuffer& aValue,
|
|||
BluetoothService* bs = BluetoothService::Get();
|
||||
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(StringToUuid(mService->GetAppUuid(),
|
||||
appUuid)),
|
||||
promise,
|
||||
NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
||||
bs->GattClientWriteCharacteristicValueInternal(
|
||||
mService->GetAppUuid(), mService->GetServiceId(),
|
||||
mCharId, mWriteType, value,
|
||||
appUuid, mService->GetServiceId(), mCharId, mWriteType, value,
|
||||
new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
|
||||
return promise.forget();
|
||||
|
|
|
@ -232,6 +232,12 @@ BluetoothGattDescriptor::ReadValue(ErrorResult& aRv)
|
|||
RefPtr<Promise> promise = Promise::Create(global, aRv);
|
||||
NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(StringToUuid(
|
||||
mCharacteristic->Service()->GetAppUuid(), appUuid)),
|
||||
promise,
|
||||
NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
||||
if (mAttRole == ATT_SERVER_ROLE) {
|
||||
promise->MaybeResolve(mValue);
|
||||
return promise.forget();
|
||||
|
@ -241,7 +247,7 @@ BluetoothGattDescriptor::ReadValue(ErrorResult& aRv)
|
|||
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
bs->GattClientReadDescriptorValueInternal(
|
||||
mCharacteristic->Service()->GetAppUuid(),
|
||||
appUuid,
|
||||
mCharacteristic->Service()->GetServiceId(),
|
||||
mCharacteristic->GetCharacteristicId(),
|
||||
mDescriptorId,
|
||||
|
@ -263,6 +269,12 @@ BluetoothGattDescriptor::WriteValue(
|
|||
RefPtr<Promise> promise = Promise::Create(global, aRv);
|
||||
NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(StringToUuid(
|
||||
mCharacteristic->Service()->GetAppUuid(), appUuid)),
|
||||
promise,
|
||||
NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
||||
aValue.ComputeLengthAndData();
|
||||
|
||||
if (mAttRole == ATT_SERVER_ROLE) {
|
||||
|
@ -280,7 +292,7 @@ BluetoothGattDescriptor::WriteValue(
|
|||
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
bs->GattClientWriteDescriptorValueInternal(
|
||||
mCharacteristic->Service()->GetAppUuid(),
|
||||
appUuid,
|
||||
mCharacteristic->Service()->GetServiceId(),
|
||||
mCharacteristic->GetCharacteristicId(),
|
||||
mDescriptorId,
|
||||
|
|
|
@ -319,12 +319,23 @@ BluetoothGattServer::Connect(const nsAString& aAddress, ErrorResult& aRv)
|
|||
RefPtr<Promise> promise = Promise::Create(global, aRv);
|
||||
NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(StringToUuid(mAppUuid, appUuid)),
|
||||
promise,
|
||||
NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
||||
BluetoothAddress address;
|
||||
BT_ENSURE_TRUE_REJECT(
|
||||
NS_SUCCEEDED(StringToAddress(aAddress, address)),
|
||||
promise,
|
||||
NS_ERROR_INVALID_ARG);
|
||||
|
||||
BT_ENSURE_TRUE_REJECT(mValid, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
bs->GattServerConnectPeripheralInternal(
|
||||
mAppUuid, aAddress, new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
appUuid, address, new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
|
||||
return promise.forget();
|
||||
}
|
||||
|
@ -341,12 +352,23 @@ BluetoothGattServer::Disconnect(const nsAString& aAddress, ErrorResult& aRv)
|
|||
RefPtr<Promise> promise = Promise::Create(global, aRv);
|
||||
NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(StringToUuid(mAppUuid, appUuid)),
|
||||
promise,
|
||||
NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
||||
BluetoothAddress address;
|
||||
BT_ENSURE_TRUE_REJECT(
|
||||
NS_SUCCEEDED(StringToAddress(aAddress, address)),
|
||||
promise,
|
||||
NS_ERROR_INVALID_ARG);
|
||||
|
||||
BT_ENSURE_TRUE_REJECT(mValid, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
bs->GattServerDisconnectPeripheralInternal(
|
||||
mAppUuid, aAddress, new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
appUuid, address, new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
|
||||
return promise.forget();
|
||||
}
|
||||
|
@ -372,8 +394,13 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
if (NS_FAILED(StringToUuid(mServer->mAppUuid, appUuid))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bs->GattServerAddIncludedServiceInternal(
|
||||
mServer->mAppUuid,
|
||||
appUuid,
|
||||
mService->GetServiceHandle(),
|
||||
mIncludedService->GetServiceHandle(),
|
||||
GetReply());
|
||||
|
@ -408,10 +435,15 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
if (NS_FAILED(StringToUuid(mServer->mAppUuid, appUuid))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BluetoothUuid uuid;
|
||||
mCharacteristic->GetUuid(uuid);
|
||||
bs->GattServerAddCharacteristicInternal(
|
||||
mServer->mAppUuid,
|
||||
appUuid,
|
||||
mService->GetServiceHandle(),
|
||||
uuid,
|
||||
mCharacteristic->GetPermissions(),
|
||||
|
@ -450,10 +482,15 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
if (NS_FAILED(StringToUuid(mServer->mAppUuid, appUuid))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BluetoothUuid uuid;
|
||||
mDescriptor->GetUuid(uuid);
|
||||
bs->GattServerAddDescriptorInternal(
|
||||
mServer->mAppUuid,
|
||||
appUuid,
|
||||
mService->GetServiceHandle(),
|
||||
mCharacteristic->GetCharacteristicHandle(),
|
||||
uuid,
|
||||
|
@ -489,8 +526,13 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
if (NS_FAILED(StringToUuid(mServer->mAppUuid, appUuid))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bs->GattServerStartServiceInternal(
|
||||
mServer->mAppUuid,
|
||||
appUuid,
|
||||
mService->GetServiceHandle(),
|
||||
GetReply());
|
||||
|
||||
|
@ -616,8 +658,14 @@ private:
|
|||
BluetoothService* bs = BluetoothService::Get();
|
||||
BT_ENSURE_TRUE_REJECT_VOID(bs, mPromise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
BT_ENSURE_TRUE_REJECT_VOID(NS_SUCCEEDED(StringToUuid(mServer->mAppUuid,
|
||||
appUuid)),
|
||||
mPromise,
|
||||
NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
||||
bs->GattServerRemoveServiceInternal(
|
||||
mServer->mAppUuid,
|
||||
appUuid,
|
||||
mService->GetServiceHandle(),
|
||||
new CancelAddServiceTask(mServer, mService, mPromise));
|
||||
}
|
||||
|
@ -704,7 +752,12 @@ BluetoothGattServer::AddService(BluetoothGattService& aService,
|
|||
|
||||
mPendingService = &aService;
|
||||
|
||||
bs->GattServerAddServiceInternal(mAppUuid,
|
||||
BluetoothUuid appUuid;
|
||||
if (NS_FAILED(StringToUuid(mAppUuid, appUuid))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bs->GattServerAddServiceInternal(appUuid,
|
||||
mPendingService->GetServiceId(),
|
||||
mPendingService->GetHandleCount(),
|
||||
new AddServiceTask(this,
|
||||
|
@ -772,8 +825,13 @@ BluetoothGattServer::RemoveService(BluetoothGattService& aService,
|
|||
BluetoothService* bs = BluetoothService::Get();
|
||||
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(StringToUuid(mAppUuid, appUuid)),
|
||||
promise,
|
||||
NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
||||
bs->GattServerRemoveServiceInternal(
|
||||
mAppUuid, aService.GetServiceHandle(), new RemoveServiceTask(this,
|
||||
appUuid, aService.GetServiceHandle(), new RemoveServiceTask(this,
|
||||
&aService,
|
||||
promise));
|
||||
|
||||
|
@ -798,6 +856,17 @@ BluetoothGattServer::NotifyCharacteristicChanged(
|
|||
|
||||
BT_ENSURE_TRUE_REJECT(mValid, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(StringToUuid(mAppUuid, appUuid)),
|
||||
promise,
|
||||
NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
||||
BluetoothAddress address;
|
||||
BT_ENSURE_TRUE_REJECT(
|
||||
NS_SUCCEEDED(StringToAddress(aAddress, address)),
|
||||
promise,
|
||||
NS_ERROR_INVALID_ARG);
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
|
@ -808,7 +877,7 @@ BluetoothGattServer::NotifyCharacteristicChanged(
|
|||
NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
bs->GattServerSendIndicationInternal(
|
||||
mAppUuid, aAddress, aCharacteristic.GetCharacteristicHandle(), aConfirm,
|
||||
appUuid, address, aCharacteristic.GetCharacteristicHandle(), aConfirm,
|
||||
aCharacteristic.GetValue(),
|
||||
new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
|
||||
|
@ -830,6 +899,17 @@ BluetoothGattServer::SendResponse(const nsAString& aAddress,
|
|||
RefPtr<Promise> promise = Promise::Create(global, aRv);
|
||||
NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
|
||||
|
||||
BluetoothUuid appUuid;
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(StringToUuid(mAppUuid, appUuid)),
|
||||
promise,
|
||||
NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
||||
BluetoothAddress address;
|
||||
BT_ENSURE_TRUE_REJECT(
|
||||
NS_SUCCEEDED(StringToAddress(aAddress, address)),
|
||||
promise,
|
||||
NS_ERROR_INVALID_ARG);
|
||||
|
||||
BT_ENSURE_TRUE_REJECT(mValid, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
RequestData* requestData;
|
||||
|
@ -861,8 +941,8 @@ BluetoothGattServer::SendResponse(const nsAString& aAddress,
|
|||
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
bs->GattServerSendResponseInternal(
|
||||
mAppUuid,
|
||||
aAddress,
|
||||
appUuid,
|
||||
address,
|
||||
aStatus,
|
||||
aRequestId,
|
||||
response,
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "BluetoothPairingHandle.h"
|
||||
#include "BluetoothReplyRunnable.h"
|
||||
#include "BluetoothService.h"
|
||||
#include "BluetoothUtils.h"
|
||||
|
||||
#include "mozilla/dom/BluetoothPairingHandleBinding.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
|
@ -79,10 +80,21 @@ BluetoothPairingHandle::SetPinCode(const nsAString& aPinCode, ErrorResult& aRv)
|
|||
promise,
|
||||
NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(StringToAddress(mDeviceAddress,
|
||||
deviceAddress)),
|
||||
promise,
|
||||
NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
|
||||
BluetoothPinCode pinCode;
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(StringToPinCode(aPinCode, pinCode)),
|
||||
promise,
|
||||
NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
bs->PinReplyInternal(mDeviceAddress, true /* accept */, aPinCode,
|
||||
bs->PinReplyInternal(deviceAddress, true /* accept */, pinCode,
|
||||
new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
|
||||
return promise.forget();
|
||||
|
@ -108,12 +120,18 @@ BluetoothPairingHandle::Accept(ErrorResult& aRv)
|
|||
BluetoothService* bs = BluetoothService::Get();
|
||||
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(StringToAddress(mDeviceAddress,
|
||||
deviceAddress)),
|
||||
promise,
|
||||
NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
|
||||
BluetoothSspVariant variant;
|
||||
BT_ENSURE_TRUE_REJECT(GetSspVariant(variant),
|
||||
promise,
|
||||
NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
||||
bs->SspReplyInternal(mDeviceAddress, variant, true /* aAccept */,
|
||||
bs->SspReplyInternal(deviceAddress, variant, true /* aAccept */,
|
||||
new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
|
||||
return promise.forget();
|
||||
|
@ -131,11 +149,18 @@ BluetoothPairingHandle::Reject(ErrorResult& aRv)
|
|||
RefPtr<Promise> promise = Promise::Create(global, aRv);
|
||||
NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(StringToAddress(mDeviceAddress,
|
||||
deviceAddress)),
|
||||
promise,
|
||||
NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
if (mType.EqualsLiteral(PAIRING_REQ_TYPE_ENTERPINCODE)) { // Pin request
|
||||
bs->PinReplyInternal(mDeviceAddress, false /* aAccept */, EmptyString(),
|
||||
bs->PinReplyInternal(deviceAddress, false /* aAccept */,
|
||||
BluetoothPinCode(),
|
||||
new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
} else { // Ssp request
|
||||
BluetoothSspVariant variant;
|
||||
|
@ -143,7 +168,7 @@ BluetoothPairingHandle::Reject(ErrorResult& aRv)
|
|||
promise,
|
||||
NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
||||
bs->SspReplyInternal(mDeviceAddress, variant, false /* aAccept */,
|
||||
bs->SspReplyInternal(deviceAddress, variant, false /* aAccept */,
|
||||
new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,29 @@
|
|||
|
||||
namespace IPC {
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::bluetooth::BluetoothAddress>
|
||||
{
|
||||
typedef mozilla::dom::bluetooth::BluetoothAddress paramType;
|
||||
|
||||
static void Write(Message* aMsg, const paramType& aParam)
|
||||
{
|
||||
for (size_t i = 0; i < MOZ_ARRAY_LENGTH(aParam.mAddr); ++i) {
|
||||
WriteParam(aMsg, aParam.mAddr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
|
||||
{
|
||||
for (size_t i = 0; i < MOZ_ARRAY_LENGTH(aResult->mAddr); ++i) {
|
||||
if (!ReadParam(aMsg, aIter, aResult->mAddr + i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::bluetooth::BluetoothObjectType>
|
||||
: public ContiguousEnumSerializer<
|
||||
|
@ -20,6 +43,42 @@ struct ParamTraits<mozilla::dom::bluetooth::BluetoothObjectType>
|
|||
mozilla::dom::bluetooth::NUM_TYPE>
|
||||
{ };
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::bluetooth::BluetoothPinCode>
|
||||
{
|
||||
typedef mozilla::dom::bluetooth::BluetoothPinCode paramType;
|
||||
|
||||
static void Write(Message* aMsg, const paramType& aParam)
|
||||
{
|
||||
WriteParam(aMsg, aParam.mLength);
|
||||
for (uint8_t i = 0; i < aParam.mLength; ++i) {
|
||||
WriteParam(aMsg, aParam.mPinCode[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
|
||||
{
|
||||
if (!ReadParam(aMsg, aIter, &aResult->mLength)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto maxLength = MOZ_ARRAY_LENGTH(aResult->mPinCode);
|
||||
|
||||
if (aResult->mLength > maxLength) {
|
||||
return false;
|
||||
}
|
||||
for (uint8_t i = 0; i < aResult->mLength; ++i) {
|
||||
if (!ReadParam(aMsg, aIter, aResult->mPinCode + i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (uint8_t i = aResult->mLength; i < maxLength; ++i) {
|
||||
aResult->mPinCode[i] = 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::bluetooth::BluetoothSspVariant>
|
||||
: public ContiguousEnumSerializer<
|
||||
|
@ -198,6 +257,42 @@ struct ParamTraits<mozilla::dom::bluetooth::BluetoothGattResponse>
|
|||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::bluetooth::ControlPlayStatus>
|
||||
{
|
||||
typedef mozilla::dom::bluetooth::ControlPlayStatus paramType;
|
||||
|
||||
static void Write(Message* aMsg, const paramType& aParam)
|
||||
{
|
||||
WriteParam(aMsg, static_cast<uint8_t>(aParam));
|
||||
}
|
||||
|
||||
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
|
||||
{
|
||||
uint8_t value;
|
||||
if (!ReadParam(aMsg, aIter, &value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mozilla::dom::bluetooth::ControlPlayStatus result =
|
||||
static_cast<mozilla::dom::bluetooth::ControlPlayStatus>(value);
|
||||
|
||||
switch (result) {
|
||||
case mozilla::dom::bluetooth::ControlPlayStatus::PLAYSTATUS_STOPPED:
|
||||
case mozilla::dom::bluetooth::ControlPlayStatus::PLAYSTATUS_PLAYING:
|
||||
case mozilla::dom::bluetooth::ControlPlayStatus::PLAYSTATUS_PAUSED:
|
||||
case mozilla::dom::bluetooth::ControlPlayStatus::PLAYSTATUS_FWD_SEEK:
|
||||
case mozilla::dom::bluetooth::ControlPlayStatus::PLAYSTATUS_REV_SEEK:
|
||||
case mozilla::dom::bluetooth::ControlPlayStatus::PLAYSTATUS_ERROR:
|
||||
*aResult = result;
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace IPC
|
||||
|
||||
#endif // mozilla_dom_bluetooth_ipc_BluetoothMessageUtils_h
|
||||
|
|
|
@ -599,7 +599,7 @@ BluetoothRequestParent::DoRequest(const SetPinCodeRequest& aRequest)
|
|||
MOZ_ASSERT(mService);
|
||||
MOZ_ASSERT(mRequestType == Request::TSetPinCodeRequest);
|
||||
|
||||
mService->SetPinCodeInternal(aRequest.path(),
|
||||
mService->SetPinCodeInternal(aRequest.address(),
|
||||
aRequest.pincode(),
|
||||
mReplyRunnable.get());
|
||||
|
||||
|
@ -612,7 +612,7 @@ BluetoothRequestParent::DoRequest(const SetPasskeyRequest& aRequest)
|
|||
MOZ_ASSERT(mService);
|
||||
MOZ_ASSERT(mRequestType == Request::TSetPasskeyRequest);
|
||||
|
||||
mService->SetPasskeyInternal(aRequest.path(),
|
||||
mService->SetPasskeyInternal(aRequest.address(),
|
||||
aRequest.passkey(),
|
||||
mReplyRunnable.get());
|
||||
|
||||
|
@ -626,7 +626,7 @@ BluetoothRequestParent::DoRequest(const ConfirmPairingConfirmationRequest&
|
|||
MOZ_ASSERT(mService);
|
||||
MOZ_ASSERT(mRequestType == Request::TConfirmPairingConfirmationRequest);
|
||||
|
||||
mService->SetPairingConfirmationInternal(aRequest.path(),
|
||||
mService->SetPairingConfirmationInternal(aRequest.address(),
|
||||
true,
|
||||
mReplyRunnable.get());
|
||||
|
||||
|
@ -640,7 +640,7 @@ BluetoothRequestParent::DoRequest(const DenyPairingConfirmationRequest&
|
|||
MOZ_ASSERT(mService);
|
||||
MOZ_ASSERT(mRequestType == Request::TDenyPairingConfirmationRequest);
|
||||
|
||||
mService->SetPairingConfirmationInternal(aRequest.path(),
|
||||
mService->SetPairingConfirmationInternal(aRequest.address(),
|
||||
false,
|
||||
mReplyRunnable.get());
|
||||
|
||||
|
@ -680,7 +680,7 @@ BluetoothRequestParent::DoRequest(const SendFileRequest& aRequest)
|
|||
MOZ_ASSERT(mService);
|
||||
MOZ_ASSERT(mRequestType == Request::TSendFileRequest);
|
||||
|
||||
mService->SendFile(aRequest.devicePath(),
|
||||
mService->SendFile(aRequest.address(),
|
||||
(BlobParent*)aRequest.blobParent(),
|
||||
(BlobChild*)aRequest.blobChild(),
|
||||
mReplyRunnable.get());
|
||||
|
@ -694,7 +694,7 @@ BluetoothRequestParent::DoRequest(const StopSendingFileRequest& aRequest)
|
|||
MOZ_ASSERT(mService);
|
||||
MOZ_ASSERT(mRequestType == Request::TStopSendingFileRequest);
|
||||
|
||||
mService->StopSendingFile(aRequest.devicePath(),
|
||||
mService->StopSendingFile(aRequest.address(),
|
||||
mReplyRunnable.get());
|
||||
|
||||
return true;
|
||||
|
@ -706,7 +706,7 @@ BluetoothRequestParent::DoRequest(const ConfirmReceivingFileRequest& aRequest)
|
|||
MOZ_ASSERT(mService);
|
||||
MOZ_ASSERT(mRequestType == Request::TConfirmReceivingFileRequest);
|
||||
|
||||
mService->ConfirmReceivingFile(aRequest.devicePath(),
|
||||
mService->ConfirmReceivingFile(aRequest.address(),
|
||||
true,
|
||||
mReplyRunnable.get());
|
||||
return true;
|
||||
|
@ -718,7 +718,7 @@ BluetoothRequestParent::DoRequest(const DenyReceivingFileRequest& aRequest)
|
|||
MOZ_ASSERT(mService);
|
||||
MOZ_ASSERT(mRequestType == Request::TDenyReceivingFileRequest);
|
||||
|
||||
mService->ConfirmReceivingFile(aRequest.devicePath(),
|
||||
mService->ConfirmReceivingFile(aRequest.address(),
|
||||
false,
|
||||
mReplyRunnable.get());
|
||||
return true;
|
||||
|
|
|
@ -129,8 +129,8 @@ BluetoothServiceChildProcess::GetConnectedDevicePropertiesInternal(
|
|||
|
||||
nsresult
|
||||
BluetoothServiceChildProcess::GetPairedDevicePropertiesInternal(
|
||||
const nsTArray<nsString>& aDeviceAddresses,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
const nsTArray<BluetoothAddress>& aDeviceAddresses,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
PairedDevicePropertiesRequest request;
|
||||
request.addresses().AppendElements(aDeviceAddresses);
|
||||
|
@ -141,9 +141,9 @@ BluetoothServiceChildProcess::GetPairedDevicePropertiesInternal(
|
|||
|
||||
nsresult
|
||||
BluetoothServiceChildProcess::FetchUuidsInternal(
|
||||
const nsAString& aDeviceAddress, BluetoothReplyRunnable* aRunnable)
|
||||
const BluetoothAddress& aDeviceAddress, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable, FetchUuidsRequest(nsString(aDeviceAddress)));
|
||||
SendRequest(aRunnable, FetchUuidsRequest(aDeviceAddress));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -163,15 +163,15 @@ BluetoothServiceChildProcess::StartDiscoveryInternal(
|
|||
|
||||
void
|
||||
BluetoothServiceChildProcess::StopLeScanInternal(
|
||||
const nsAString& aScanUuid,
|
||||
const BluetoothUuid& aScanUuid,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable, StopLeScanRequest(nsString(aScanUuid)));
|
||||
SendRequest(aRunnable, StopLeScanRequest(aScanUuid));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::StartLeScanInternal(
|
||||
const nsTArray<nsString>& aServiceUuids,
|
||||
const nsTArray<BluetoothUuid>& aServiceUuids,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable, StartLeScanRequest(aServiceUuids));
|
||||
|
@ -188,22 +188,18 @@ BluetoothServiceChildProcess::SetProperty(BluetoothObjectType aType,
|
|||
|
||||
nsresult
|
||||
BluetoothServiceChildProcess::CreatePairedDeviceInternal(
|
||||
const nsAString& aAddress,
|
||||
int aTimeout,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
const BluetoothAddress& aDeviceAddress, int aTimeout,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
PairRequest(nsString(aAddress), aTimeout));
|
||||
SendRequest(aRunnable, PairRequest(aDeviceAddress, aTimeout));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
BluetoothServiceChildProcess::RemoveDeviceInternal(
|
||||
const nsAString& aObjectPath,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
const BluetoothAddress& aDeviceAddress, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
UnpairRequest(nsString(aObjectPath)));
|
||||
SendRequest(aRunnable, UnpairRequest(aDeviceAddress));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -224,98 +220,83 @@ BluetoothServiceChildProcess::UpdateSdpRecords(const BluetoothAddress& aDeviceAd
|
|||
|
||||
void
|
||||
BluetoothServiceChildProcess::PinReplyInternal(
|
||||
const nsAString& aDeviceAddress, bool aAccept,
|
||||
const nsAString& aPinCode, BluetoothReplyRunnable* aRunnable)
|
||||
const BluetoothAddress& aDeviceAddress, bool aAccept,
|
||||
const BluetoothPinCode& aPinCode, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
PinReplyRequest(nsString(aDeviceAddress),
|
||||
aAccept,
|
||||
nsString(aPinCode)));
|
||||
SendRequest(aRunnable, PinReplyRequest(aDeviceAddress, aAccept, aPinCode));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::SspReplyInternal(
|
||||
const nsAString& aDeviceAddress, BluetoothSspVariant aVariant,
|
||||
bool aAccept, BluetoothReplyRunnable* aRunnable)
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothSspVariant aVariant, bool aAccept,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
SspReplyRequest(nsString(aDeviceAddress),
|
||||
aVariant,
|
||||
aAccept));
|
||||
SendRequest(aRunnable, SspReplyRequest(aDeviceAddress, aVariant, aAccept));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::SetPinCodeInternal(
|
||||
const nsAString& aDeviceAddress,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothPinCode& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
SetPinCodeRequest(nsString(aDeviceAddress), nsString(aPinCode)));
|
||||
SendRequest(aRunnable, SetPinCodeRequest(aDeviceAddress, aPinCode));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::SetPasskeyInternal(
|
||||
const nsAString& aDeviceAddress,
|
||||
uint32_t aPasskey,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
uint32_t aPasskey,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
SetPasskeyRequest(nsString(aDeviceAddress), aPasskey));
|
||||
SendRequest(aRunnable, SetPasskeyRequest(aDeviceAddress, aPasskey));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::SetPairingConfirmationInternal(
|
||||
const nsAString& aDeviceAddress,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
if(aConfirm) {
|
||||
SendRequest(aRunnable,
|
||||
ConfirmPairingConfirmationRequest(nsString(aDeviceAddress)));
|
||||
if (aConfirm) {
|
||||
SendRequest(aRunnable, ConfirmPairingConfirmationRequest(aDeviceAddress));
|
||||
} else {
|
||||
SendRequest(aRunnable,
|
||||
DenyPairingConfirmationRequest(nsString(aDeviceAddress)));
|
||||
SendRequest(aRunnable, DenyPairingConfirmationRequest(aDeviceAddress));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::Connect(
|
||||
const nsAString& aDeviceAddress,
|
||||
uint32_t aCod,
|
||||
uint16_t aServiceUuid,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
uint32_t aCod, uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
ConnectRequest(nsString(aDeviceAddress),
|
||||
aCod,
|
||||
aServiceUuid));
|
||||
SendRequest(aRunnable, ConnectRequest(aDeviceAddress, aCod, aServiceUuid));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::Disconnect(
|
||||
const nsAString& aDeviceAddress,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
DisconnectRequest(nsString(aDeviceAddress), aServiceUuid));
|
||||
SendRequest(aRunnable, DisconnectRequest(aDeviceAddress, aServiceUuid));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::SendFile(
|
||||
const nsAString& aDeviceAddress,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BlobParent* aBlobParent,
|
||||
BlobChild* aBlobChild,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
SendFileRequest(nsString(aDeviceAddress), nullptr, aBlobChild));
|
||||
SendRequest(aRunnable, SendFileRequest(aDeviceAddress, nullptr, aBlobChild));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::SendFile(
|
||||
const nsAString& aDeviceAddress,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
Blob* aBlobChild,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
|
@ -325,27 +306,23 @@ BluetoothServiceChildProcess::SendFile(
|
|||
|
||||
void
|
||||
BluetoothServiceChildProcess::StopSendingFile(
|
||||
const nsAString& aDeviceAddress,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
StopSendingFileRequest(nsString(aDeviceAddress)));
|
||||
SendRequest(aRunnable, StopSendingFileRequest(aDeviceAddress));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::ConfirmReceivingFile(
|
||||
const nsAString& aDeviceAddress,
|
||||
bool aConfirm,
|
||||
const BluetoothAddress& aDeviceAddress, bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
if(aConfirm) {
|
||||
SendRequest(aRunnable,
|
||||
ConfirmReceivingFileRequest(nsString(aDeviceAddress)));
|
||||
SendRequest(aRunnable, ConfirmReceivingFileRequest(aDeviceAddress));
|
||||
return;
|
||||
}
|
||||
|
||||
SendRequest(aRunnable,
|
||||
DenyReceivingFileRequest(nsString(aDeviceAddress)));
|
||||
SendRequest(aRunnable, DenyReceivingFileRequest(aDeviceAddress));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -564,56 +541,53 @@ BluetoothServiceChildProcess::SendMetaData(const nsAString& aTitle,
|
|||
void
|
||||
BluetoothServiceChildProcess::SendPlayStatus(int64_t aDuration,
|
||||
int64_t aPosition,
|
||||
const nsAString& aPlayStatus,
|
||||
ControlPlayStatus aPlayStatus,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
SendPlayStatusRequest(aDuration, aPosition,
|
||||
nsString(aPlayStatus)));
|
||||
SendPlayStatusRequest(aDuration, aPosition, aPlayStatus));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::ConnectGattClientInternal(
|
||||
const nsAString& aAppUuid, const nsAString& aDeviceAddress,
|
||||
const BluetoothUuid& aAppUuid, const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable, ConnectGattClientRequest(nsString(aAppUuid),
|
||||
nsString(aDeviceAddress)));
|
||||
SendRequest(aRunnable, ConnectGattClientRequest(aAppUuid, aDeviceAddress));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::DisconnectGattClientInternal(
|
||||
const nsAString& aAppUuid, const nsAString& aDeviceAddress,
|
||||
const BluetoothUuid& aAppUuid, const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
DisconnectGattClientRequest(nsString(aAppUuid), nsString(aDeviceAddress)));
|
||||
DisconnectGattClientRequest(aAppUuid, aDeviceAddress));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::DiscoverGattServicesInternal(
|
||||
const nsAString& aAppUuid, BluetoothReplyRunnable* aRunnable)
|
||||
const BluetoothUuid& aAppUuid, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
DiscoverGattServicesRequest(nsString(aAppUuid)));
|
||||
SendRequest(aRunnable, DiscoverGattServicesRequest(aAppUuid));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::GattClientStartNotificationsInternal(
|
||||
const nsAString& aAppUuid, const BluetoothGattServiceId& aServId,
|
||||
const BluetoothUuid& aAppUuid, const BluetoothGattServiceId& aServId,
|
||||
const BluetoothGattId& aCharId, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
GattClientStartNotificationsRequest(nsString(aAppUuid), aServId, aCharId));
|
||||
GattClientStartNotificationsRequest(aAppUuid, aServId, aCharId));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::GattClientStopNotificationsInternal(
|
||||
const nsAString& aAppUuid, const BluetoothGattServiceId& aServId,
|
||||
const BluetoothUuid& aAppUuid, const BluetoothGattServiceId& aServId,
|
||||
const BluetoothGattId& aCharId, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
GattClientStopNotificationsRequest(nsString(aAppUuid), aServId, aCharId));
|
||||
GattClientStopNotificationsRequest(aAppUuid, aServId, aCharId));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -625,30 +599,29 @@ BluetoothServiceChildProcess::UnregisterGattClientInternal(
|
|||
|
||||
void
|
||||
BluetoothServiceChildProcess::GattClientReadRemoteRssiInternal(
|
||||
int aClientIf, const nsAString& aDeviceAddress,
|
||||
int aClientIf, const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
GattClientReadRemoteRssiRequest(aClientIf,
|
||||
nsString(aDeviceAddress)));
|
||||
GattClientReadRemoteRssiRequest(aClientIf, aDeviceAddress));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::GattClientReadCharacteristicValueInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
const BluetoothGattId& aCharacteristicId,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
GattClientReadCharacteristicValueRequest(nsString(aAppUuid),
|
||||
GattClientReadCharacteristicValueRequest(aAppUuid,
|
||||
aServiceId,
|
||||
aCharacteristicId));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::GattClientWriteCharacteristicValueInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
const BluetoothGattId& aCharacteristicId,
|
||||
const BluetoothGattWriteType& aWriteType,
|
||||
|
@ -656,7 +629,7 @@ BluetoothServiceChildProcess::GattClientWriteCharacteristicValueInternal(
|
|||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
GattClientWriteCharacteristicValueRequest(nsString(aAppUuid),
|
||||
GattClientWriteCharacteristicValueRequest(aAppUuid,
|
||||
aServiceId,
|
||||
aCharacteristicId,
|
||||
aWriteType,
|
||||
|
@ -665,14 +638,14 @@ BluetoothServiceChildProcess::GattClientWriteCharacteristicValueInternal(
|
|||
|
||||
void
|
||||
BluetoothServiceChildProcess::GattClientReadDescriptorValueInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
const BluetoothGattId& aCharacteristicId,
|
||||
const BluetoothGattId& aDescriptorId,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
GattClientReadDescriptorValueRequest(nsString(aAppUuid),
|
||||
GattClientReadDescriptorValueRequest(aAppUuid,
|
||||
aServiceId,
|
||||
aCharacteristicId,
|
||||
aDescriptorId));
|
||||
|
@ -680,7 +653,7 @@ BluetoothServiceChildProcess::GattClientReadDescriptorValueInternal(
|
|||
|
||||
void
|
||||
BluetoothServiceChildProcess::GattClientWriteDescriptorValueInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
const BluetoothGattId& aCharacteristicId,
|
||||
const BluetoothGattId& aDescriptorId,
|
||||
|
@ -688,7 +661,7 @@ BluetoothServiceChildProcess::GattClientWriteDescriptorValueInternal(
|
|||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
GattClientWriteDescriptorValueRequest(nsString(aAppUuid),
|
||||
GattClientWriteDescriptorValueRequest(aAppUuid,
|
||||
aServiceId,
|
||||
aCharacteristicId,
|
||||
aDescriptorId,
|
||||
|
@ -697,24 +670,22 @@ BluetoothServiceChildProcess::GattClientWriteDescriptorValueInternal(
|
|||
|
||||
void
|
||||
BluetoothServiceChildProcess::GattServerConnectPeripheralInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
GattServerConnectPeripheralRequest(nsString(aAppUuid),
|
||||
nsString(aAddress)));
|
||||
GattServerConnectPeripheralRequest(aAppUuid, aAddress));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::GattServerDisconnectPeripheralInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
GattServerDisconnectPeripheralRequest(nsString(aAppUuid),
|
||||
nsString(aAddress)));
|
||||
GattServerDisconnectPeripheralRequest(aAppUuid, aAddress));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -726,31 +697,31 @@ BluetoothServiceChildProcess::UnregisterGattServerInternal(
|
|||
|
||||
void
|
||||
BluetoothServiceChildProcess::GattServerAddServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
uint16_t aHandleCount,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
GattServerAddServiceRequest(nsString(aAppUuid), aServiceId, aHandleCount));
|
||||
GattServerAddServiceRequest(aAppUuid, aServiceId, aHandleCount));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::GattServerAddIncludedServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
const BluetoothAttributeHandle& aIncludedServiceHandle,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
GattServerAddIncludedServiceRequest(nsString(aAppUuid),
|
||||
GattServerAddIncludedServiceRequest(aAppUuid,
|
||||
aServiceHandle,
|
||||
aIncludedServiceHandle));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::GattServerAddCharacteristicInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
const BluetoothUuid& aCharacteristicUuid,
|
||||
BluetoothGattAttrPerm aPermissions,
|
||||
|
@ -758,7 +729,7 @@ BluetoothServiceChildProcess::GattServerAddCharacteristicInternal(
|
|||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
GattServerAddCharacteristicRequest(nsString(aAppUuid),
|
||||
GattServerAddCharacteristicRequest(aAppUuid,
|
||||
aServiceHandle,
|
||||
aCharacteristicUuid,
|
||||
aPermissions,
|
||||
|
@ -767,7 +738,7 @@ BluetoothServiceChildProcess::GattServerAddCharacteristicInternal(
|
|||
|
||||
void
|
||||
BluetoothServiceChildProcess::GattServerAddDescriptorInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
const BluetoothAttributeHandle& aCharacteristicHandle,
|
||||
const BluetoothUuid& aDescriptorUuid,
|
||||
|
@ -775,7 +746,7 @@ BluetoothServiceChildProcess::GattServerAddDescriptorInternal(
|
|||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
GattServerAddDescriptorRequest(nsString(aAppUuid),
|
||||
GattServerAddDescriptorRequest(aAppUuid,
|
||||
aServiceHandle,
|
||||
aCharacteristicHandle,
|
||||
aDescriptorUuid,
|
||||
|
@ -784,60 +755,63 @@ BluetoothServiceChildProcess::GattServerAddDescriptorInternal(
|
|||
|
||||
void
|
||||
BluetoothServiceChildProcess::GattServerRemoveServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
GattServerRemoveServiceRequest(nsString(aAppUuid), aServiceHandle));
|
||||
GattServerRemoveServiceRequest(aAppUuid, aServiceHandle));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::GattServerStartServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
GattServerStartServiceRequest(nsString(aAppUuid), aServiceHandle));
|
||||
GattServerStartServiceRequest(aAppUuid, aServiceHandle));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::GattServerStopServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
GattServerStopServiceRequest(nsString(aAppUuid), aServiceHandle));
|
||||
GattServerStopServiceRequest(aAppUuid, aServiceHandle));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::GattServerSendResponseInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aAddress,
|
||||
uint16_t aStatus,
|
||||
int32_t aRequestId,
|
||||
const BluetoothGattResponse& aRsp,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
GattServerSendResponseRequest(
|
||||
nsString(aAppUuid), nsString(aAddress), aStatus, aRequestId, aRsp));
|
||||
GattServerSendResponseRequest(aAppUuid,
|
||||
aAddress,
|
||||
aStatus,
|
||||
aRequestId,
|
||||
aRsp));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::GattServerSendIndicationInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aAddress,
|
||||
const BluetoothAttributeHandle& aCharacteristicHandle,
|
||||
bool aConfirm,
|
||||
const nsTArray<uint8_t>& aValue,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
GattServerSendIndicationRequest(nsString(aAppUuid),
|
||||
nsString(aAddress),
|
||||
GattServerSendIndicationRequest(aAppUuid,
|
||||
aAddress,
|
||||
aCharacteristicHandle,
|
||||
aConfirm,
|
||||
aValue));
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
StopInternal(BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual nsresult
|
||||
GetPairedDevicePropertiesInternal(const nsTArray<nsString>& aDeviceAddresses,
|
||||
GetPairedDevicePropertiesInternal(const nsTArray<BluetoothAddress>& aDeviceAddresses,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
override;
|
||||
|
||||
|
@ -50,7 +50,7 @@ public:
|
|||
BluetoothReplyRunnable* aRunnable)
|
||||
override;
|
||||
virtual nsresult
|
||||
FetchUuidsInternal(const nsAString& aDeviceAddress,
|
||||
FetchUuidsInternal(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
|
@ -60,11 +60,11 @@ public:
|
|||
StartDiscoveryInternal(BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
StopLeScanInternal(const nsAString& aScanUuid,
|
||||
StopLeScanInternal(const BluetoothUuid& aScanUuid,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
StartLeScanInternal(const nsTArray<nsString>& aServiceUuids,
|
||||
StartLeScanInternal(const nsTArray<BluetoothUuid>& aServiceUuids,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual nsresult
|
||||
|
@ -73,12 +73,12 @@ public:
|
|||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual nsresult
|
||||
CreatePairedDeviceInternal(const nsAString& aAddress,
|
||||
CreatePairedDeviceInternal(const BluetoothAddress& aDeviceAddress,
|
||||
int aTimeout,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual nsresult
|
||||
RemoveDeviceInternal(const nsAString& aObjectPath,
|
||||
RemoveDeviceInternal(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual nsresult
|
||||
|
@ -91,61 +91,61 @@ public:
|
|||
BluetoothProfileManagerBase* aManager) override;
|
||||
|
||||
virtual void
|
||||
SetPinCodeInternal(const nsAString& aDeviceAddress,
|
||||
const nsAString& aPinCode,
|
||||
SetPinCodeInternal(const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothPinCode& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
SetPasskeyInternal(const nsAString& aDeviceAddress,
|
||||
SetPasskeyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
uint32_t aPasskey,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
SetPairingConfirmationInternal(const nsAString& aDeviceAddress,
|
||||
SetPairingConfirmationInternal(const BluetoothAddress& aDeviceAddress,
|
||||
bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
override;
|
||||
|
||||
virtual void
|
||||
PinReplyInternal(const nsAString& aDeviceAddress,
|
||||
PinReplyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
bool aAccept,
|
||||
const nsAString& aPinCode,
|
||||
const BluetoothPinCode& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
SspReplyInternal(const nsAString& aDeviceAddress,
|
||||
SspReplyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothSspVariant aVariant,
|
||||
bool aAccept,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
Connect(const nsAString& aDeviceAddress,
|
||||
Connect(const BluetoothAddress& aDeviceAddress,
|
||||
uint32_t aCod,
|
||||
uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
Disconnect(const nsAString& aDeviceAddress,
|
||||
Disconnect(const BluetoothAddress& aDeviceAddress,
|
||||
uint16_t aServiceUuid,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
SendFile(const nsAString& aDeviceAddress,
|
||||
SendFile(const BluetoothAddress& aDeviceAddress,
|
||||
BlobParent* aBlobParent,
|
||||
BlobChild* aBlobChild,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
SendFile(const nsAString& aDeviceAddress,
|
||||
SendFile(const BluetoothAddress& aDeviceAddress,
|
||||
Blob* aBlob,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
StopSendingFile(const nsAString& aDeviceAddress,
|
||||
StopSendingFile(const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
ConfirmReceivingFile(const nsAString& aDeviceAddress,
|
||||
ConfirmReceivingFile(const BluetoothAddress& aDeviceAddress,
|
||||
bool aConfirm,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
|
@ -267,7 +267,7 @@ public:
|
|||
virtual void
|
||||
SendPlayStatus(int64_t aDuration,
|
||||
int64_t aPosition,
|
||||
const nsAString& aPlayStatus,
|
||||
ControlPlayStatus aPlayStatus,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
|
@ -284,29 +284,29 @@ public:
|
|||
const nsAString& aMessage) override;
|
||||
|
||||
virtual void
|
||||
ConnectGattClientInternal(const nsAString& aAppUuid,
|
||||
const nsAString& aDeviceAddress,
|
||||
ConnectGattClientInternal(const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
DisconnectGattClientInternal(const nsAString& aAppUuid,
|
||||
const nsAString& aDeviceAddress,
|
||||
DisconnectGattClientInternal(const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
DiscoverGattServicesInternal(const nsAString& aAppUuid,
|
||||
DiscoverGattServicesInternal(const BluetoothUuid& aAppUuid,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattClientStartNotificationsInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServId,
|
||||
const BluetoothGattId& aCharId,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattClientStopNotificationsInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServId,
|
||||
const BluetoothGattId& aCharId,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
@ -317,19 +317,19 @@ public:
|
|||
|
||||
virtual void
|
||||
GattClientReadRemoteRssiInternal(int aClientIf,
|
||||
const nsAString& aDeviceAddress,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattClientReadCharacteristicValueInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
const BluetoothGattId& aCharacteristicId,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattClientWriteCharacteristicValueInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
const BluetoothGattId& aCharacteristicId,
|
||||
const BluetoothGattWriteType& aWriteType,
|
||||
|
@ -338,7 +338,7 @@ public:
|
|||
|
||||
virtual void
|
||||
GattClientReadDescriptorValueInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
const BluetoothGattId& aCharacteristicId,
|
||||
const BluetoothGattId& aDescriptorId,
|
||||
|
@ -346,7 +346,7 @@ public:
|
|||
|
||||
virtual void
|
||||
GattClientWriteDescriptorValueInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
const BluetoothGattId& aCharacteristicId,
|
||||
const BluetoothGattId& aDescriptorId,
|
||||
|
@ -355,14 +355,14 @@ public:
|
|||
|
||||
virtual void
|
||||
GattServerConnectPeripheralInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattServerDisconnectPeripheralInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
|
@ -371,21 +371,21 @@ public:
|
|||
|
||||
virtual void
|
||||
GattServerAddServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
uint16_t aHandleCount,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattServerAddIncludedServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
const BluetoothAttributeHandle& aIncludedServiceHandle,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattServerAddCharacteristicInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
const BluetoothUuid& aCharacteristicUuid,
|
||||
BluetoothGattAttrPerm aPermissions,
|
||||
|
@ -394,7 +394,7 @@ public:
|
|||
|
||||
virtual void
|
||||
GattServerAddDescriptorInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
const BluetoothAttributeHandle& aCharacteristicHandle,
|
||||
const BluetoothUuid& aDescriptorUuid,
|
||||
|
@ -403,26 +403,26 @@ public:
|
|||
|
||||
virtual void
|
||||
GattServerRemoveServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattServerStartServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattServerStopServiceInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAttributeHandle& aServiceHandle,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattServerSendResponseInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aAddress,
|
||||
uint16_t aStatus,
|
||||
int32_t aRequestId,
|
||||
const BluetoothGattResponse& aRsp,
|
||||
|
@ -430,8 +430,8 @@ public:
|
|||
|
||||
virtual void
|
||||
GattServerSendIndicationInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothUuid& aAppUuid,
|
||||
const BluetoothAddress& aAddress,
|
||||
const BluetoothAttributeHandle& aCharacteristicHandle,
|
||||
bool aConfirm,
|
||||
const nsTArray<uint8_t>& aValue,
|
||||
|
|
|
@ -12,7 +12,14 @@ include BluetoothTypes;
|
|||
|
||||
include "mozilla/dom/bluetooth/ipc/BluetoothMessageUtils.h";
|
||||
|
||||
using mozilla::dom::bluetooth::BluetoothObjectType from "mozilla/dom/bluetooth/BluetoothCommon.h";
|
||||
using mozilla::dom::bluetooth::BluetoothAddress
|
||||
from "mozilla/dom/bluetooth/BluetoothCommon.h";
|
||||
using mozilla::dom::bluetooth::BluetoothObjectType
|
||||
from "mozilla/dom/bluetooth/BluetoothCommon.h";
|
||||
using mozilla::dom::bluetooth::BluetoothPinCode
|
||||
from "mozilla/dom/bluetooth/BluetoothCommon.h";
|
||||
using mozilla::dom::bluetooth::ControlPlayStatus
|
||||
from "mozilla/dom/bluetooth/BluetoothCommon.h";
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -42,7 +49,7 @@ struct SetPropertyRequest
|
|||
struct GetPropertyRequest
|
||||
{
|
||||
BluetoothObjectType type;
|
||||
nsString path;
|
||||
BluetoothAddress address;
|
||||
};
|
||||
|
||||
struct StartDiscoveryRequest
|
||||
|
@ -55,64 +62,64 @@ struct StopDiscoveryRequest
|
|||
|
||||
struct StartLeScanRequest
|
||||
{
|
||||
nsString[] serviceUuids;
|
||||
BluetoothUuid[] serviceUuids;
|
||||
};
|
||||
|
||||
struct StopLeScanRequest
|
||||
{
|
||||
nsString scanUuid;
|
||||
BluetoothUuid scanUuid;
|
||||
};
|
||||
|
||||
struct PairRequest
|
||||
{
|
||||
nsString address;
|
||||
BluetoothAddress address;
|
||||
uint32_t timeoutMS;
|
||||
};
|
||||
|
||||
struct UnpairRequest
|
||||
{
|
||||
nsString address;
|
||||
BluetoothAddress address;
|
||||
};
|
||||
|
||||
struct PinReplyRequest
|
||||
{
|
||||
nsString address;
|
||||
BluetoothAddress address;
|
||||
bool accept;
|
||||
nsString pinCode;
|
||||
BluetoothPinCode pinCode;
|
||||
};
|
||||
|
||||
struct SspReplyRequest
|
||||
{
|
||||
nsString address;
|
||||
BluetoothAddress address;
|
||||
BluetoothSspVariant variant;
|
||||
bool accept;
|
||||
};
|
||||
|
||||
struct SetPinCodeRequest
|
||||
{
|
||||
nsString path;
|
||||
nsString pincode;
|
||||
BluetoothAddress address;
|
||||
BluetoothPinCode pincode;
|
||||
};
|
||||
|
||||
struct SetPasskeyRequest
|
||||
{
|
||||
nsString path;
|
||||
BluetoothAddress address;
|
||||
uint32_t passkey;
|
||||
};
|
||||
|
||||
struct ConfirmPairingConfirmationRequest
|
||||
{
|
||||
nsString path;
|
||||
BluetoothAddress address;
|
||||
};
|
||||
|
||||
struct DenyPairingConfirmationRequest
|
||||
{
|
||||
nsString path;
|
||||
BluetoothAddress address;
|
||||
};
|
||||
|
||||
struct PairedDevicePropertiesRequest
|
||||
{
|
||||
nsString[] addresses;
|
||||
BluetoothAddress[] addresses;
|
||||
};
|
||||
|
||||
struct ConnectedDevicePropertiesRequest
|
||||
|
@ -122,41 +129,41 @@ struct ConnectedDevicePropertiesRequest
|
|||
|
||||
struct FetchUuidsRequest
|
||||
{
|
||||
nsString address;
|
||||
BluetoothAddress address;
|
||||
};
|
||||
|
||||
struct ConnectRequest
|
||||
{
|
||||
nsString address;
|
||||
BluetoothAddress address;
|
||||
uint32_t cod;
|
||||
uint16_t serviceUuid;
|
||||
};
|
||||
|
||||
struct DisconnectRequest
|
||||
{
|
||||
nsString address;
|
||||
BluetoothAddress address;
|
||||
uint16_t serviceUuid;
|
||||
};
|
||||
|
||||
struct SendFileRequest
|
||||
{
|
||||
nsString devicePath;
|
||||
BluetoothAddress address;
|
||||
PBlob blob;
|
||||
};
|
||||
|
||||
struct StopSendingFileRequest
|
||||
{
|
||||
nsString devicePath;
|
||||
BluetoothAddress address;
|
||||
};
|
||||
|
||||
struct ConfirmReceivingFileRequest
|
||||
{
|
||||
nsString devicePath;
|
||||
BluetoothAddress address;
|
||||
};
|
||||
|
||||
struct DenyReceivingFileRequest
|
||||
{
|
||||
nsString devicePath;
|
||||
BluetoothAddress address;
|
||||
};
|
||||
|
||||
struct ConnectScoRequest
|
||||
|
@ -263,36 +270,36 @@ struct SendPlayStatusRequest
|
|||
{
|
||||
int64_t duration;
|
||||
int64_t position;
|
||||
nsString playStatus;
|
||||
ControlPlayStatus playStatus;
|
||||
};
|
||||
|
||||
struct ConnectGattClientRequest
|
||||
{
|
||||
nsString appUuid;
|
||||
nsString deviceAddress;
|
||||
BluetoothUuid appUuid;
|
||||
BluetoothAddress deviceAddress;
|
||||
};
|
||||
|
||||
struct DisconnectGattClientRequest
|
||||
{
|
||||
nsString appUuid;
|
||||
nsString deviceAddress;
|
||||
BluetoothUuid appUuid;
|
||||
BluetoothAddress deviceAddress;
|
||||
};
|
||||
|
||||
struct DiscoverGattServicesRequest
|
||||
{
|
||||
nsString appUuid;
|
||||
BluetoothUuid appUuid;
|
||||
};
|
||||
|
||||
struct GattClientStartNotificationsRequest
|
||||
{
|
||||
nsString appUuid;
|
||||
BluetoothUuid appUuid;
|
||||
BluetoothGattServiceId servId;
|
||||
BluetoothGattId charId;
|
||||
};
|
||||
|
||||
struct GattClientStopNotificationsRequest
|
||||
{
|
||||
nsString appUuid;
|
||||
BluetoothUuid appUuid;
|
||||
BluetoothGattServiceId servId;
|
||||
BluetoothGattId charId;
|
||||
};
|
||||
|
@ -305,19 +312,19 @@ struct UnregisterGattClientRequest
|
|||
struct GattClientReadRemoteRssiRequest
|
||||
{
|
||||
int clientIf;
|
||||
nsString deviceAddress;
|
||||
BluetoothAddress deviceAddress;
|
||||
};
|
||||
|
||||
struct GattClientReadCharacteristicValueRequest
|
||||
{
|
||||
nsString appUuid;
|
||||
BluetoothUuid appUuid;
|
||||
BluetoothGattServiceId serviceId;
|
||||
BluetoothGattId charId;
|
||||
};
|
||||
|
||||
struct GattClientWriteCharacteristicValueRequest
|
||||
{
|
||||
nsString appUuid;
|
||||
BluetoothUuid appUuid;
|
||||
BluetoothGattServiceId serviceId;
|
||||
BluetoothGattId charId;
|
||||
BluetoothGattWriteType writeType;
|
||||
|
@ -326,7 +333,7 @@ struct GattClientWriteCharacteristicValueRequest
|
|||
|
||||
struct GattClientReadDescriptorValueRequest
|
||||
{
|
||||
nsString appUuid;
|
||||
BluetoothUuid appUuid;
|
||||
BluetoothGattServiceId serviceId;
|
||||
BluetoothGattId charId;
|
||||
BluetoothGattId descId;
|
||||
|
@ -334,7 +341,7 @@ struct GattClientReadDescriptorValueRequest
|
|||
|
||||
struct GattClientWriteDescriptorValueRequest
|
||||
{
|
||||
nsString appUuid;
|
||||
BluetoothUuid appUuid;
|
||||
BluetoothGattServiceId serviceId;
|
||||
BluetoothGattId charId;
|
||||
BluetoothGattId descId;
|
||||
|
@ -343,14 +350,14 @@ struct GattClientWriteDescriptorValueRequest
|
|||
|
||||
struct GattServerConnectPeripheralRequest
|
||||
{
|
||||
nsString appUuid;
|
||||
nsString address;
|
||||
BluetoothUuid appUuid;
|
||||
BluetoothAddress address;
|
||||
};
|
||||
|
||||
struct GattServerDisconnectPeripheralRequest
|
||||
{
|
||||
nsString appUuid;
|
||||
nsString address;
|
||||
BluetoothUuid appUuid;
|
||||
BluetoothAddress address;
|
||||
};
|
||||
|
||||
struct UnregisterGattServerRequest
|
||||
|
@ -360,21 +367,21 @@ struct UnregisterGattServerRequest
|
|||
|
||||
struct GattServerAddServiceRequest
|
||||
{
|
||||
nsString appUuid;
|
||||
BluetoothUuid appUuid;
|
||||
BluetoothGattServiceId serviceId;
|
||||
uint16_t handleCount;
|
||||
};
|
||||
|
||||
struct GattServerAddIncludedServiceRequest
|
||||
{
|
||||
nsString appUuid;
|
||||
BluetoothUuid appUuid;
|
||||
BluetoothAttributeHandle serviceHandle;
|
||||
BluetoothAttributeHandle includedServiceHandle;
|
||||
};
|
||||
|
||||
struct GattServerAddCharacteristicRequest
|
||||
{
|
||||
nsString appUuid;
|
||||
BluetoothUuid appUuid;
|
||||
BluetoothAttributeHandle serviceHandle;
|
||||
BluetoothUuid characteristicUuid;
|
||||
BluetoothGattAttrPerm permissions;
|
||||
|
@ -383,7 +390,7 @@ struct GattServerAddCharacteristicRequest
|
|||
|
||||
struct GattServerAddDescriptorRequest
|
||||
{
|
||||
nsString appUuid;
|
||||
BluetoothUuid appUuid;
|
||||
BluetoothAttributeHandle serviceHandle;
|
||||
BluetoothAttributeHandle characteristicHandle;
|
||||
BluetoothUuid descriptorUuid;
|
||||
|
@ -392,26 +399,26 @@ struct GattServerAddDescriptorRequest
|
|||
|
||||
struct GattServerRemoveServiceRequest
|
||||
{
|
||||
nsString appUuid;
|
||||
BluetoothUuid appUuid;
|
||||
BluetoothAttributeHandle serviceHandle;
|
||||
};
|
||||
|
||||
struct GattServerStartServiceRequest
|
||||
{
|
||||
nsString appUuid;
|
||||
BluetoothUuid appUuid;
|
||||
BluetoothAttributeHandle serviceHandle;
|
||||
};
|
||||
|
||||
struct GattServerStopServiceRequest
|
||||
{
|
||||
nsString appUuid;
|
||||
BluetoothUuid appUuid;
|
||||
BluetoothAttributeHandle serviceHandle;
|
||||
};
|
||||
|
||||
struct GattServerSendResponseRequest
|
||||
{
|
||||
nsString appUuid;
|
||||
nsString address;
|
||||
BluetoothUuid appUuid;
|
||||
BluetoothAddress address;
|
||||
uint16_t status;
|
||||
int32_t requestId;
|
||||
BluetoothGattResponse response;
|
||||
|
@ -419,8 +426,8 @@ struct GattServerSendResponseRequest
|
|||
|
||||
struct GattServerSendIndicationRequest
|
||||
{
|
||||
nsString appUuid;
|
||||
nsString address;
|
||||
BluetoothUuid appUuid;
|
||||
BluetoothAddress address;
|
||||
BluetoothAttributeHandle characteristicHandle;
|
||||
bool confirm;
|
||||
uint8_t[] value;
|
||||
|
|
|
@ -16,7 +16,6 @@ if CONFIG['MOZ_B2G_BT']:
|
|||
]
|
||||
|
||||
SOURCES += [
|
||||
'common/BluetoothCommon.cpp',
|
||||
'common/BluetoothHidManager.cpp',
|
||||
'common/BluetoothInterface.cpp',
|
||||
'common/BluetoothProfileController.cpp',
|
||||
|
@ -130,8 +129,6 @@ if CONFIG['MOZ_B2G_BT']:
|
|||
DEFINES['MOZ_BLUETOOTH_DBUS'] = True
|
||||
DEFINES['HAVE_PTHREADS'] = True
|
||||
|
||||
FINAL_LIBRARY = 'xul'
|
||||
|
||||
#
|
||||
# Exported interfaces
|
||||
#
|
||||
|
@ -160,6 +157,11 @@ EXPORTS.mozilla.dom.bluetooth += [
|
|||
'common/webapi/BluetoothPairingListener.h',
|
||||
'common/webapi/BluetoothPbapRequestHandle.h'
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'common/BluetoothCommon.cpp',
|
||||
]
|
||||
|
||||
IPDL_SOURCES += [
|
||||
'ipc/BluetoothTypes.ipdlh',
|
||||
'ipc/PBluetooth.ipdl',
|
||||
|
@ -173,3 +175,5 @@ LOCAL_INCLUDES += [
|
|||
]
|
||||
|
||||
include('/ipc/chromium/chromium-config.mozbuild')
|
||||
|
||||
FINAL_LIBRARY = 'xul'
|
||||
|
|
|
@ -68,6 +68,10 @@ BrowserElementAudioChannel::Create(nsPIDOMWindow* aWindow,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
||||
("BrowserElementAudioChannel, Create, channel = %p, type = %d\n",
|
||||
ac.get(), aAudioChannel));
|
||||
|
||||
return ac.forget();
|
||||
}
|
||||
|
||||
|
@ -608,6 +612,10 @@ BrowserElementAudioChannel::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
void
|
||||
BrowserElementAudioChannel::ProcessStateChanged(const char16_t* aData)
|
||||
{
|
||||
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
||||
("BrowserElementAudioChannel, ProcessStateChanged, this = %p, "
|
||||
"type = %d\n", this, mAudioChannel));
|
||||
|
||||
nsAutoString value(aData);
|
||||
mState = value.EqualsASCII("active") ? eStateActive : eStateInactive;
|
||||
DispatchTrustedEvent(NS_LITERAL_STRING("activestatechanged"));
|
||||
|
|
|
@ -563,6 +563,9 @@ nsBrowserElement::GetAllowedAudioChannels(
|
|||
return;
|
||||
}
|
||||
|
||||
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
||||
("nsBrowserElement, GetAllowedAudioChannels, this = %p\n", this));
|
||||
|
||||
GenerateAllowedAudioChannels(window, frameLoader, mBrowserElementAPI,
|
||||
manifestURL, mBrowserElementAudioChannels,
|
||||
aRv);
|
||||
|
|
|
@ -693,6 +693,9 @@ TabChild::Observe(nsISupports *aSubject,
|
|||
// In theory a tabChild should contain just 1 top window, but let's double
|
||||
// check it comparing the windowID.
|
||||
if (window->WindowID() != windowID) {
|
||||
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
||||
("TabChild, Observe, different windowID, owner ID = %lld, "
|
||||
"ID from wrapper = %lld", window->WindowID(), windowID));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -1127,6 +1127,13 @@ MobileConnection::NotifyNetworkSelectionModeChanged()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnection::NotifyDeviceIdentitiesChanged()
|
||||
{
|
||||
// To be supported when bug 1222870 is required in m-c.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIIccListener
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -462,6 +462,22 @@ CdmaCellInfo.prototype = {
|
|||
evdoSnr: UNKNOWN_VALUE
|
||||
};
|
||||
|
||||
function MobileDeviceIdentities(aImei, aImeisv, aEsn, aMeid) {
|
||||
this.imei = aImei;
|
||||
this.imeisv = aImeisv;
|
||||
this.esn = aEsn;
|
||||
this.meid = aMeid;
|
||||
}
|
||||
MobileDeviceIdentities.prototype = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileDeviceIdentities]),
|
||||
|
||||
// nsIMobileDeviceIdentities
|
||||
imei: null,
|
||||
imeisv: null,
|
||||
esn: null,
|
||||
meid: null
|
||||
};
|
||||
|
||||
function MobileConnectionProvider(aClientId, aRadioInterface) {
|
||||
this._clientId = aClientId;
|
||||
this._radioInterface = aRadioInterface;
|
||||
|
@ -501,6 +517,7 @@ MobileConnectionProvider.prototype = {
|
|||
lastKnownNetwork: null,
|
||||
lastKnownHomeNetwork: null,
|
||||
supportedNetworkTypes: null,
|
||||
deviceIdentities: null,
|
||||
|
||||
/**
|
||||
* A utility function to dump debug message.
|
||||
|
@ -961,6 +978,17 @@ MobileConnectionProvider.prototype = {
|
|||
aServiceClass]);
|
||||
},
|
||||
|
||||
notifyDeviceIdentitiesChanged: function(aImei, aImeisv, aEsn, aMeid) {
|
||||
if (this.deviceIdentities) {
|
||||
if (DEBUG) this._debug("deviceIdentities shall not be changed once being updated.");
|
||||
return;
|
||||
}
|
||||
|
||||
this.deviceIdentities =
|
||||
new MobileDeviceIdentities(aImei, aImeisv, aEsn, aMeid);
|
||||
this.deliverListenerEvent("notifyDeviceIdentitiesChanged");
|
||||
},
|
||||
|
||||
getSupportedNetworkTypes: function(aTypes) {
|
||||
aTypes.value = this.supportedNetworkTypes.slice();
|
||||
return aTypes.value.length;
|
||||
|
@ -1693,6 +1721,12 @@ MobileConnectionService.prototype = {
|
|||
.notifyCdmaInfoRecAudioControl(aClientId, aUpLink, aDownLink);
|
||||
},
|
||||
|
||||
notifyDeviceIdentitiesChanged: function(aClientId, aImei, aImeisv,
|
||||
aEsn, aMeid) {
|
||||
this.getItemByServiceId(aClientId)
|
||||
.notifyDeviceIdentitiesChanged(aImei, aImeisv, aEsn, aMeid);
|
||||
},
|
||||
|
||||
/**
|
||||
* nsIObserver interface.
|
||||
*/
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
"@mozilla.org/mobileconnection/gonkmobileconnectionservice;1"
|
||||
%}
|
||||
|
||||
[scriptable, uuid(3a7b8d47-d1c6-44c3-a312-df73fda1161e)]
|
||||
[scriptable, uuid(3c306f88-86bf-11e5-91af-3b2233acec65)]
|
||||
interface nsIGonkMobileConnectionService : nsIMobileConnectionService
|
||||
{
|
||||
void notifyNetworkInfoChanged(in unsigned long clientId, in jsval networkInfo);
|
||||
|
@ -248,4 +248,27 @@ interface nsIGonkMobileConnectionService : nsIMobileConnectionService
|
|||
void notifyCdmaInfoRecAudioControl(in unsigned long clientId,
|
||||
in short upLink,
|
||||
in short downLink);
|
||||
|
||||
/**
|
||||
* Notify Device Identities.
|
||||
*
|
||||
* @param aClientId
|
||||
* The ID of radioInterface where this info is notified from.
|
||||
* @param aImei
|
||||
* Device IMEI, valid if GSM subscription is available.
|
||||
* @param aImeisv
|
||||
* Device IMEISV, valid if GSM subscription is available.
|
||||
* @param aEsn
|
||||
* Device ESN, valid if CDMA subscription is available.
|
||||
* @param aMeid
|
||||
* Device MEID, valid if CDMA subscription is available.
|
||||
*
|
||||
* Note: The value might be dummy like "000..." from modem
|
||||
* if the corresponding subscription is not available.
|
||||
*/
|
||||
void notifyDeviceIdentitiesChanged(in unsigned long aClientId,
|
||||
in DOMString aImei,
|
||||
in DOMString aImeisv,
|
||||
in DOMString aEsn,
|
||||
in DOMString aMeid);
|
||||
};
|
||||
|
|
|
@ -8,11 +8,12 @@ interface nsICellInfoListCallback;
|
|||
interface nsIMobileCallForwardingOptions;
|
||||
interface nsIMobileConnection;
|
||||
interface nsIMobileConnectionInfo;
|
||||
interface nsIMobileDeviceIdentities;
|
||||
interface nsIMobileNetworkInfo;
|
||||
interface nsINeighboringCellIdsCallback;
|
||||
interface nsIVariant;
|
||||
|
||||
[scriptable, uuid(d6827b51-61a7-4b7c-8454-42d0cffc1829)]
|
||||
[scriptable, uuid(8884b326-891c-11e5-a434-67def07c4a41)]
|
||||
interface nsIMobileConnectionListener : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -102,6 +103,11 @@ interface nsIMobileConnectionListener : nsISupports
|
|||
* Notify when network selection mode is changed.
|
||||
*/
|
||||
void notifyNetworkSelectionModeChanged();
|
||||
|
||||
/**
|
||||
* Notify when device identities are changed.
|
||||
*/
|
||||
void notifyDeviceIdentitiesChanged();
|
||||
};
|
||||
|
||||
%{C++
|
||||
|
@ -165,7 +171,7 @@ already_AddRefed<nsIMobileConnectionService>
|
|||
NS_CreateMobileConnectionService();
|
||||
%}
|
||||
|
||||
[scriptable, uuid(d7173ff3-a8da-41c1-a976-440e5402b856)]
|
||||
[scriptable, uuid(7a557116-8753-11e5-9f9b-6794b577c0a1)]
|
||||
interface nsIMobileConnection : nsISupports
|
||||
{
|
||||
/*
|
||||
|
@ -320,6 +326,11 @@ interface nsIMobileConnection : nsISupports
|
|||
*/
|
||||
readonly attribute long radioState;
|
||||
|
||||
/**
|
||||
* Device Identities, including IMEI, IMEISV, ESN and MEID.
|
||||
*/
|
||||
readonly attribute nsIMobileDeviceIdentities deviceIdentities;
|
||||
|
||||
/**
|
||||
* The network types supported by this radio.
|
||||
*
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
/* 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/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(3fc79ece-8399-11e5-beff-6b8209cb93f6)]
|
||||
interface nsIMobileDeviceIdentities : nsISupports
|
||||
{
|
||||
/**
|
||||
* Device IMEI, including check digit.
|
||||
*
|
||||
* Valid if GSM subscription is available.
|
||||
*
|
||||
* Note: The value might be dummy like "000..." from modem if invalid.
|
||||
*/
|
||||
readonly attribute DOMString imei;
|
||||
|
||||
/**
|
||||
* Device IMEISV.
|
||||
*
|
||||
* Valid if GSM subscription is available.
|
||||
*
|
||||
* Note: IMEISV is presented in 2-decimal digits.
|
||||
* The value might be dummy like "00" from modem if invalid.
|
||||
*/
|
||||
readonly attribute DOMString imeisv;
|
||||
|
||||
/**
|
||||
* Device ESN.
|
||||
*
|
||||
* Valid if CDMA subscription is available.
|
||||
*
|
||||
* Note: The value might be dummy like "000..." from modem if invalid.
|
||||
*/
|
||||
readonly attribute DOMString esn;
|
||||
|
||||
/**
|
||||
* Device MEID.
|
||||
*
|
||||
* Valid if CDMA subscription is available.
|
||||
*
|
||||
* Note: The value might be dummy like "000..." from modem if invalid.
|
||||
*/
|
||||
readonly attribute DOMString meid;
|
||||
};
|
|
@ -107,6 +107,12 @@ MobileConnectionChild::GetRadioState(int32_t* aRadioState)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::GetDeviceIdentities(nsIMobileDeviceIdentities** aIdentities)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::GetSupportedNetworkTypes(int32_t** aTypes,
|
||||
uint32_t* aLength)
|
||||
|
|
|
@ -288,6 +288,13 @@ MobileConnectionParent::NotifyNetworkSelectionModeChanged()
|
|||
return SendNotifyNetworkSelectionModeChanged(mode) ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionParent::NotifyDeviceIdentitiesChanged()
|
||||
{
|
||||
// To be supported when bug 1222870 is required in m-c.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* PMobileConnectionRequestParent
|
||||
******************************************************************************/
|
||||
|
|
|
@ -27,6 +27,7 @@ XPIDL_SOURCES += [
|
|||
'interfaces/nsIMobileCellInfo.idl',
|
||||
'interfaces/nsIMobileConnectionInfo.idl',
|
||||
'interfaces/nsIMobileConnectionService.idl',
|
||||
'interfaces/nsIMobileDeviceIdentities.idl',
|
||||
'interfaces/nsIMobileNetworkInfo.idl',
|
||||
'interfaces/nsINeighboringCellInfo.idl',
|
||||
]
|
||||
|
|
|
@ -6,10 +6,11 @@
|
|||
|
||||
#include "DOMMobileMessageError.h"
|
||||
#include "mozilla/dom/DOMMobileMessageErrorBinding.h"
|
||||
#include "nsIDOMMozMmsMessage.h"
|
||||
#include "nsIDOMMozSmsMessage.h"
|
||||
#include "MmsMessage.h"
|
||||
#include "SmsMessage.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(DOMMobileMessageError)
|
||||
|
||||
|
@ -31,7 +32,7 @@ NS_IMPL_RELEASE_INHERITED(DOMMobileMessageError, DOMError)
|
|||
|
||||
DOMMobileMessageError::DOMMobileMessageError(nsPIDOMWindow* aWindow,
|
||||
const nsAString& aName,
|
||||
nsIDOMMozSmsMessage* aSms)
|
||||
SmsMessage* aSms)
|
||||
: DOMError(aWindow, aName)
|
||||
, mSms(aSms)
|
||||
, mMms(nullptr)
|
||||
|
@ -40,7 +41,7 @@ DOMMobileMessageError::DOMMobileMessageError(nsPIDOMWindow* aWindow,
|
|||
|
||||
DOMMobileMessageError::DOMMobileMessageError(nsPIDOMWindow* aWindow,
|
||||
const nsAString& aName,
|
||||
nsIDOMMozMmsMessage* aMms)
|
||||
MmsMessage* aMms)
|
||||
: DOMError(aWindow, aName)
|
||||
, mSms(nullptr)
|
||||
, mMms(aMms)
|
||||
|
@ -48,15 +49,15 @@ DOMMobileMessageError::DOMMobileMessageError(nsPIDOMWindow* aWindow,
|
|||
}
|
||||
|
||||
void
|
||||
DOMMobileMessageError::GetData(OwningMozSmsMessageOrMozMmsMessage& aRetVal) const
|
||||
DOMMobileMessageError::GetData(OwningSmsMessageOrMmsMessage& aRetVal) const
|
||||
{
|
||||
if (mSms) {
|
||||
aRetVal.SetAsMozSmsMessage() = mSms;
|
||||
aRetVal.SetAsSmsMessage() = mSms;
|
||||
return;
|
||||
}
|
||||
|
||||
if (mMms) {
|
||||
aRetVal.SetAsMozMmsMessage() = mMms;
|
||||
aRetVal.SetAsMmsMessage() = mMms;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -68,3 +69,6 @@ DOMMobileMessageError::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenPr
|
|||
{
|
||||
return DOMMobileMessageErrorBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -9,13 +9,12 @@
|
|||
|
||||
#include "mozilla/dom/DOMError.h"
|
||||
|
||||
class nsIDOMMozMmsMessage;
|
||||
class nsIDOMMozSmsMessage;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class OwningMozSmsMessageOrMozMmsMessage;
|
||||
class MmsMessage;
|
||||
class OwningSmsMessageOrMmsMessage;
|
||||
class SmsMessage;
|
||||
|
||||
class DOMMobileMessageError final : public DOMError
|
||||
{
|
||||
|
@ -24,21 +23,21 @@ public:
|
|||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DOMMobileMessageError, DOMError)
|
||||
|
||||
DOMMobileMessageError(nsPIDOMWindow* aWindow, const nsAString& aName,
|
||||
nsIDOMMozSmsMessage* aSms);
|
||||
SmsMessage* aSms);
|
||||
|
||||
DOMMobileMessageError(nsPIDOMWindow* aWindow, const nsAString& aName,
|
||||
nsIDOMMozMmsMessage* aMms);
|
||||
MmsMessage* aMms);
|
||||
|
||||
virtual JSObject*
|
||||
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
void GetData(OwningMozSmsMessageOrMozMmsMessage& aRetVal) const;
|
||||
void GetData(OwningSmsMessageOrMmsMessage& aRetVal) const;
|
||||
|
||||
private:
|
||||
~DOMMobileMessageError() {}
|
||||
|
||||
nsCOMPtr<nsIDOMMozSmsMessage> mSms;
|
||||
nsCOMPtr<nsIDOMMozMmsMessage> mMms;
|
||||
RefPtr<SmsMessage> mSms;
|
||||
RefPtr<MmsMessage> mMms;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -1,628 +1,162 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* 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/. */
|
||||
* 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/. */
|
||||
|
||||
#include "MmsMessage.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
#include "jsapi.h" // For JS_IsArrayObject, JS_GetElement, etc.
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsTArrayHelpers.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/dom/File.h"
|
||||
#include "mozilla/dom/mobilemessage/Constants.h" // For MessageType
|
||||
#include "mozilla/dom/mobilemessage/SmsTypes.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "mozilla/dom/ToJSValue.h"
|
||||
#include "mozilla/dom/ipc/BlobChild.h"
|
||||
#include "mozilla/dom/ipc/BlobParent.h"
|
||||
|
||||
#include "MmsMessageInternal.h"
|
||||
#include "mozilla/dom/MmsMessageBinding.h"
|
||||
|
||||
using namespace mozilla::dom::mobilemessage;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(MmsMessage)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMMozMmsMessage)
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(MmsMessage, mWindow, mMessage)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(MmsMessage)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(MmsMessage)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MmsMessage)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozMmsMessage)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_ADDREF(MmsMessage)
|
||||
NS_IMPL_RELEASE(MmsMessage)
|
||||
|
||||
MmsMessage::MmsMessage(int32_t aId,
|
||||
uint64_t aThreadId,
|
||||
const nsAString& aIccId,
|
||||
DeliveryState aDelivery,
|
||||
const nsTArray<MmsDeliveryInfo>& aDeliveryInfo,
|
||||
const nsAString& aSender,
|
||||
const nsTArray<nsString>& aReceivers,
|
||||
uint64_t aTimestamp,
|
||||
uint64_t aSentTimestamp,
|
||||
bool aRead,
|
||||
const nsAString& aSubject,
|
||||
const nsAString& aSmil,
|
||||
const nsTArray<Attachment>& aAttachments,
|
||||
uint64_t aExpiryDate,
|
||||
bool aReadReportRequested)
|
||||
: mId(aId),
|
||||
mThreadId(aThreadId),
|
||||
mIccId(aIccId),
|
||||
mDelivery(aDelivery),
|
||||
mDeliveryInfo(aDeliveryInfo),
|
||||
mSender(aSender),
|
||||
mReceivers(aReceivers),
|
||||
mTimestamp(aTimestamp),
|
||||
mSentTimestamp(aSentTimestamp),
|
||||
mRead(aRead),
|
||||
mSubject(aSubject),
|
||||
mSmil(aSmil),
|
||||
mAttachments(aAttachments),
|
||||
mExpiryDate(aExpiryDate),
|
||||
mReadReportRequested(aReadReportRequested)
|
||||
MmsMessage::MmsMessage(nsPIDOMWindow* aWindow, MmsMessageInternal* aMessage)
|
||||
: mWindow(aWindow)
|
||||
, mMessage(aMessage)
|
||||
{
|
||||
}
|
||||
|
||||
MmsMessage::MmsMessage(const mobilemessage::MmsMessageData& aData)
|
||||
: mId(aData.id())
|
||||
, mThreadId(aData.threadId())
|
||||
, mIccId(aData.iccId())
|
||||
, mDelivery(aData.delivery())
|
||||
, mSender(aData.sender())
|
||||
, mReceivers(aData.receivers())
|
||||
, mTimestamp(aData.timestamp())
|
||||
, mSentTimestamp(aData.sentTimestamp())
|
||||
, mRead(aData.read())
|
||||
, mSubject(aData.subject())
|
||||
, mSmil(aData.smil())
|
||||
, mExpiryDate(aData.expiryDate())
|
||||
, mReadReportRequested(aData.readReportRequested())
|
||||
MmsMessage::~MmsMessage()
|
||||
{
|
||||
uint32_t len = aData.attachments().Length();
|
||||
mAttachments.SetCapacity(len);
|
||||
for (uint32_t i = 0; i < len; i++) {
|
||||
MmsAttachment att;
|
||||
const MmsAttachmentData &element = aData.attachments()[i];
|
||||
att.mId = element.id();
|
||||
att.mLocation = element.location();
|
||||
|
||||
// mContent is not going to be exposed to JS directly so we can use
|
||||
// nullptr as parent.
|
||||
if (element.contentParent()) {
|
||||
RefPtr<BlobImpl> impl = static_cast<BlobParent*>(element.contentParent())->GetBlobImpl();
|
||||
att.mContent = Blob::Create(nullptr, impl);
|
||||
} else if (element.contentChild()) {
|
||||
RefPtr<BlobImpl> impl = static_cast<BlobChild*>(element.contentChild())->GetBlobImpl();
|
||||
att.mContent = Blob::Create(nullptr, impl);
|
||||
} else {
|
||||
NS_WARNING("MmsMessage: Unable to get attachment content.");
|
||||
}
|
||||
mAttachments.AppendElement(att);
|
||||
}
|
||||
|
||||
len = aData.deliveryInfo().Length();
|
||||
mDeliveryInfo.SetCapacity(len);
|
||||
for (uint32_t i = 0; i < len; i++) {
|
||||
MmsDeliveryInfo info;
|
||||
const MmsDeliveryInfoData &infoData = aData.deliveryInfo()[i];
|
||||
|
||||
// Prepare |info.mReceiver|.
|
||||
info.mReceiver = infoData.receiver();
|
||||
|
||||
// Prepare |info.mDeliveryStatus|.
|
||||
nsString statusStr;
|
||||
switch (infoData.deliveryStatus()) {
|
||||
case eDeliveryStatus_NotApplicable:
|
||||
statusStr = DELIVERY_STATUS_NOT_APPLICABLE;
|
||||
break;
|
||||
case eDeliveryStatus_Success:
|
||||
statusStr = DELIVERY_STATUS_SUCCESS;
|
||||
break;
|
||||
case eDeliveryStatus_Pending:
|
||||
statusStr = DELIVERY_STATUS_PENDING;
|
||||
break;
|
||||
case eDeliveryStatus_Error:
|
||||
statusStr = DELIVERY_STATUS_ERROR;
|
||||
break;
|
||||
case eDeliveryStatus_Reject:
|
||||
statusStr = DELIVERY_STATUS_REJECTED;
|
||||
break;
|
||||
case eDeliveryStatus_Manual:
|
||||
statusStr = DELIVERY_STATUS_MANUAL;
|
||||
break;
|
||||
case eDeliveryStatus_EndGuard:
|
||||
default:
|
||||
MOZ_CRASH("We shouldn't get any other delivery status!");
|
||||
}
|
||||
info.mDeliveryStatus = statusStr;
|
||||
|
||||
// Prepare |info.mDeliveryTimestamp|.
|
||||
info.mDeliveryTimestamp = infoData.deliveryTimestamp();
|
||||
|
||||
// Prepare |info.mReadStatus|.
|
||||
nsString statusReadString;
|
||||
switch(infoData.readStatus()) {
|
||||
case eReadStatus_NotApplicable:
|
||||
statusReadString = READ_STATUS_NOT_APPLICABLE;
|
||||
break;
|
||||
case eReadStatus_Success:
|
||||
statusReadString = READ_STATUS_SUCCESS;
|
||||
break;
|
||||
case eReadStatus_Pending:
|
||||
statusReadString = READ_STATUS_PENDING;
|
||||
break;
|
||||
case eReadStatus_Error:
|
||||
statusReadString = READ_STATUS_ERROR;
|
||||
break;
|
||||
case eReadStatus_EndGuard:
|
||||
default:
|
||||
MOZ_CRASH("We shouldn't get any other read status!");
|
||||
}
|
||||
info.mReadStatus = statusReadString;
|
||||
|
||||
// Prepare |info.mReadTimestamp|.
|
||||
info.mReadTimestamp = infoData.readTimestamp();
|
||||
|
||||
mDeliveryInfo.AppendElement(info);
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ nsresult
|
||||
MmsMessage::Create(int32_t aId,
|
||||
uint64_t aThreadId,
|
||||
const nsAString& aIccId,
|
||||
const nsAString& aDelivery,
|
||||
const JS::Value& aDeliveryInfo,
|
||||
const nsAString& aSender,
|
||||
const JS::Value& aReceivers,
|
||||
uint64_t aTimestamp,
|
||||
uint64_t aSentTimestamp,
|
||||
bool aRead,
|
||||
const nsAString& aSubject,
|
||||
const nsAString& aSmil,
|
||||
const JS::Value& aAttachments,
|
||||
uint64_t aExpiryDate,
|
||||
bool aIsReadReportRequested,
|
||||
JSContext* aCx,
|
||||
nsIDOMMozMmsMessage** aMessage)
|
||||
JSObject*
|
||||
MmsMessage::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
*aMessage = nullptr;
|
||||
return MmsMessageBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
// Set |delivery|.
|
||||
DeliveryState delivery;
|
||||
if (aDelivery.Equals(DELIVERY_SENT)) {
|
||||
delivery = eDeliveryState_Sent;
|
||||
} else if (aDelivery.Equals(DELIVERY_RECEIVED)) {
|
||||
delivery = eDeliveryState_Received;
|
||||
} else if (aDelivery.Equals(DELIVERY_SENDING)) {
|
||||
delivery = eDeliveryState_Sending;
|
||||
} else if (aDelivery.Equals(DELIVERY_NOT_DOWNLOADED)) {
|
||||
delivery = eDeliveryState_NotDownloaded;
|
||||
} else if (aDelivery.Equals(DELIVERY_ERROR)) {
|
||||
delivery = eDeliveryState_Error;
|
||||
} else {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
void
|
||||
MmsMessage::GetType(nsString& aRetVal) const
|
||||
{
|
||||
mMessage->GetType(aRetVal);
|
||||
}
|
||||
|
||||
// Set |deliveryInfo|.
|
||||
if (!aDeliveryInfo.isObject()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
JS::Rooted<JSObject*> deliveryInfoObj(aCx, &aDeliveryInfo.toObject());
|
||||
bool isArray;
|
||||
if (!JS_IsArrayObject(aCx, deliveryInfoObj, &isArray)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!isArray) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
int32_t
|
||||
MmsMessage::Id() const
|
||||
{
|
||||
int32_t id;
|
||||
mMessage->GetId(&id);
|
||||
return id;
|
||||
}
|
||||
|
||||
uint32_t length;
|
||||
MOZ_ALWAYS_TRUE(JS_GetArrayLength(aCx, deliveryInfoObj, &length));
|
||||
uint64_t
|
||||
MmsMessage::ThreadId() const
|
||||
{
|
||||
uint64_t id;
|
||||
mMessage->GetThreadId(&id);
|
||||
return id;
|
||||
}
|
||||
|
||||
nsTArray<MmsDeliveryInfo> deliveryInfo;
|
||||
JS::Rooted<JS::Value> infoJsVal(aCx);
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
if (!JS_GetElement(aCx, deliveryInfoObj, i, &infoJsVal) ||
|
||||
!infoJsVal.isObject()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
void
|
||||
MmsMessage::GetIccId(nsString& aRetVal) const
|
||||
{
|
||||
mMessage->GetIccId(aRetVal);
|
||||
}
|
||||
|
||||
MmsDeliveryInfo info;
|
||||
if (!info.Init(aCx, infoJsVal)) {
|
||||
return NS_ERROR_TYPE_ERR;
|
||||
}
|
||||
void
|
||||
MmsMessage::GetDelivery(nsString& aRetVal) const
|
||||
{
|
||||
mMessage->GetDelivery(aRetVal);
|
||||
}
|
||||
|
||||
deliveryInfo.AppendElement(info);
|
||||
}
|
||||
void
|
||||
MmsMessage::GetDeliveryInfo(nsTArray<MmsDeliveryInfo>& aRetVal) const
|
||||
{
|
||||
aRetVal = mMessage->mDeliveryInfo;
|
||||
}
|
||||
|
||||
// Set |receivers|.
|
||||
if (!aReceivers.isObject()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
JS::Rooted<JSObject*> receiversObj(aCx, &aReceivers.toObject());
|
||||
if (!JS_IsArrayObject(aCx, receiversObj, &isArray)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!isArray) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
void
|
||||
MmsMessage::GetSender(nsString& aRetVal) const
|
||||
{
|
||||
mMessage->GetSender(aRetVal);
|
||||
}
|
||||
|
||||
MOZ_ALWAYS_TRUE(JS_GetArrayLength(aCx, receiversObj, &length));
|
||||
void
|
||||
MmsMessage::GetReceivers(nsTArray<nsString>& aRetVal) const
|
||||
{
|
||||
aRetVal = mMessage->mReceivers;
|
||||
}
|
||||
|
||||
nsTArray<nsString> receivers;
|
||||
JS::Rooted<JS::Value> receiverJsVal(aCx);
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
if (!JS_GetElement(aCx, receiversObj, i, &receiverJsVal) ||
|
||||
!receiverJsVal.isString()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
uint64_t
|
||||
MmsMessage::Timestamp() const
|
||||
{
|
||||
uint64_t timestamp;
|
||||
mMessage->GetTimestamp(×tamp);
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
nsAutoJSString receiverStr;
|
||||
if (!receiverStr.init(aCx, receiverJsVal.toString())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
receivers.AppendElement(receiverStr);
|
||||
}
|
||||
|
||||
// Set |attachments|.
|
||||
if (!aAttachments.isObject()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
JS::Rooted<JSObject*> attachmentsObj(aCx, &aAttachments.toObject());
|
||||
if (!JS_IsArrayObject(aCx, attachmentsObj, &isArray)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!isArray) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
nsTArray<Attachment> attachments;
|
||||
MOZ_ALWAYS_TRUE(JS_GetArrayLength(aCx, attachmentsObj, &length));
|
||||
|
||||
JS::Rooted<JS::Value> attachmentJsVal(aCx);
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
if (!JS_GetElement(aCx, attachmentsObj, i, &attachmentJsVal)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
MmsAttachment attachment;
|
||||
if (!attachment.Init(aCx, attachmentJsVal)) {
|
||||
return NS_ERROR_TYPE_ERR;
|
||||
}
|
||||
|
||||
attachments.AppendElement(attachment);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMMozMmsMessage> message = new MmsMessage(aId,
|
||||
aThreadId,
|
||||
aIccId,
|
||||
delivery,
|
||||
deliveryInfo,
|
||||
aSender,
|
||||
receivers,
|
||||
aTimestamp,
|
||||
aSentTimestamp,
|
||||
aRead,
|
||||
aSubject,
|
||||
aSmil,
|
||||
attachments,
|
||||
aExpiryDate,
|
||||
aIsReadReportRequested);
|
||||
message.forget(aMessage);
|
||||
return NS_OK;
|
||||
uint64_t
|
||||
MmsMessage::SentTimestamp() const
|
||||
{
|
||||
uint64_t timestamp;
|
||||
mMessage->GetSentTimestamp(×tamp);
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
bool
|
||||
MmsMessage::GetData(ContentParent* aParent,
|
||||
mobilemessage::MmsMessageData& aData)
|
||||
MmsMessage::Read() const
|
||||
{
|
||||
NS_ASSERTION(aParent, "aParent is null");
|
||||
bool read;
|
||||
mMessage->GetRead(&read);
|
||||
return read;
|
||||
}
|
||||
|
||||
aData.id() = mId;
|
||||
aData.threadId() = mThreadId;
|
||||
aData.iccId() = mIccId;
|
||||
aData.delivery() = mDelivery;
|
||||
aData.sender().Assign(mSender);
|
||||
aData.receivers() = mReceivers;
|
||||
aData.timestamp() = mTimestamp;
|
||||
aData.sentTimestamp() = mSentTimestamp;
|
||||
aData.read() = mRead;
|
||||
aData.subject() = mSubject;
|
||||
aData.smil() = mSmil;
|
||||
aData.expiryDate() = mExpiryDate;
|
||||
aData.readReportRequested() = mReadReportRequested;
|
||||
void
|
||||
MmsMessage::GetSubject(nsString& aRetVal) const
|
||||
{
|
||||
mMessage->GetSubject(aRetVal);
|
||||
}
|
||||
|
||||
aData.deliveryInfo().SetCapacity(mDeliveryInfo.Length());
|
||||
for (uint32_t i = 0; i < mDeliveryInfo.Length(); i++) {
|
||||
MmsDeliveryInfoData infoData;
|
||||
const MmsDeliveryInfo &info = mDeliveryInfo[i];
|
||||
void
|
||||
MmsMessage::GetSmil(nsString& aRetVal) const
|
||||
{
|
||||
mMessage->GetSmil(aRetVal);
|
||||
}
|
||||
|
||||
// Prepare |infoData.mReceiver|.
|
||||
infoData.receiver().Assign(info.mReceiver);
|
||||
void
|
||||
MmsMessage::GetAttachments(nsTArray<MmsAttachment>& aRetVal) const
|
||||
{
|
||||
uint32_t length = mMessage->mAttachments.Length();
|
||||
|
||||
// Prepare |infoData.mDeliveryStatus|.
|
||||
DeliveryStatus status;
|
||||
if (info.mDeliveryStatus.Equals(DELIVERY_STATUS_NOT_APPLICABLE)) {
|
||||
status = eDeliveryStatus_NotApplicable;
|
||||
} else if (info.mDeliveryStatus.Equals(DELIVERY_STATUS_SUCCESS)) {
|
||||
status = eDeliveryStatus_Success;
|
||||
} else if (info.mDeliveryStatus.Equals(DELIVERY_STATUS_PENDING)) {
|
||||
status = eDeliveryStatus_Pending;
|
||||
} else if (info.mDeliveryStatus.Equals(DELIVERY_STATUS_ERROR)) {
|
||||
status = eDeliveryStatus_Error;
|
||||
} else if (info.mDeliveryStatus.Equals(DELIVERY_STATUS_REJECTED)) {
|
||||
status = eDeliveryStatus_Reject;
|
||||
} else if (info.mDeliveryStatus.Equals(DELIVERY_STATUS_MANUAL)) {
|
||||
status = eDeliveryStatus_Manual;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
infoData.deliveryStatus() = status;
|
||||
|
||||
// Prepare |infoData.mDeliveryTimestamp|.
|
||||
infoData.deliveryTimestamp() = info.mDeliveryTimestamp;
|
||||
|
||||
// Prepare |infoData.mReadStatus|.
|
||||
ReadStatus readStatus;
|
||||
if (info.mReadStatus.Equals(READ_STATUS_NOT_APPLICABLE)) {
|
||||
readStatus = eReadStatus_NotApplicable;
|
||||
} else if (info.mReadStatus.Equals(READ_STATUS_SUCCESS)) {
|
||||
readStatus = eReadStatus_Success;
|
||||
} else if (info.mReadStatus.Equals(READ_STATUS_PENDING)) {
|
||||
readStatus = eReadStatus_Pending;
|
||||
} else if (info.mReadStatus.Equals(READ_STATUS_ERROR)) {
|
||||
readStatus = eReadStatus_Error;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
infoData.readStatus() = readStatus;
|
||||
|
||||
// Prepare |infoData.mReadTimestamp|.
|
||||
infoData.readTimestamp() = info.mReadTimestamp;
|
||||
|
||||
aData.deliveryInfo().AppendElement(infoData);
|
||||
// Duplicating the Blob with the correct parent object.
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
MmsAttachment attachment;
|
||||
const MmsAttachment &element = mMessage->mAttachments[i];
|
||||
attachment.mId = element.mId;
|
||||
attachment.mLocation = element.mLocation;
|
||||
attachment.mContent = Blob::Create(mWindow, element.mContent->Impl());
|
||||
aRetVal.AppendElement(attachment);
|
||||
}
|
||||
|
||||
aData.attachments().SetCapacity(mAttachments.Length());
|
||||
for (uint32_t i = 0; i < mAttachments.Length(); i++) {
|
||||
MmsAttachmentData mma;
|
||||
const Attachment &element = mAttachments[i];
|
||||
mma.id().Assign(element.id);
|
||||
mma.location().Assign(element.location);
|
||||
|
||||
// This is a workaround. Sometimes the blob we get from the database
|
||||
// doesn't have a valid last modified date, making the ContentParent
|
||||
// send a "Mystery Blob" to the ContentChild. Attempting to get the
|
||||
// last modified date of blob can force that value to be initialized.
|
||||
RefPtr<BlobImpl> impl = element.content->Impl();
|
||||
if (impl && impl->IsDateUnknown()) {
|
||||
ErrorResult rv;
|
||||
impl->GetLastModified(rv);
|
||||
if (rv.Failed()) {
|
||||
NS_WARNING("Failed to get last modified date!");
|
||||
rv.SuppressException();
|
||||
}
|
||||
}
|
||||
|
||||
mma.contentParent() = aParent->GetOrCreateActorForBlob(element.content);
|
||||
if (!mma.contentParent()) {
|
||||
return false;
|
||||
}
|
||||
aData.attachments().AppendElement(mma);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetType(nsAString& aType)
|
||||
uint64_t
|
||||
MmsMessage::ExpiryDate() const
|
||||
{
|
||||
aType = NS_LITERAL_STRING("mms");
|
||||
return NS_OK;
|
||||
uint64_t date;
|
||||
mMessage->GetExpiryDate(&date);
|
||||
return date;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetId(int32_t* aId)
|
||||
bool
|
||||
MmsMessage::ReadReportRequested() const
|
||||
{
|
||||
*aId = mId;
|
||||
return NS_OK;
|
||||
bool reportRequested;
|
||||
mMessage->GetReadReportRequested(&reportRequested);
|
||||
return reportRequested;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetThreadId(uint64_t* aThreadId)
|
||||
{
|
||||
*aThreadId = mThreadId;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetIccId(nsAString& aIccId)
|
||||
{
|
||||
aIccId = mIccId;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetDelivery(nsAString& aDelivery)
|
||||
{
|
||||
switch (mDelivery) {
|
||||
case eDeliveryState_Received:
|
||||
aDelivery = DELIVERY_RECEIVED;
|
||||
break;
|
||||
case eDeliveryState_Sending:
|
||||
aDelivery = DELIVERY_SENDING;
|
||||
break;
|
||||
case eDeliveryState_Sent:
|
||||
aDelivery = DELIVERY_SENT;
|
||||
break;
|
||||
case eDeliveryState_Error:
|
||||
aDelivery = DELIVERY_ERROR;
|
||||
break;
|
||||
case eDeliveryState_NotDownloaded:
|
||||
aDelivery = DELIVERY_NOT_DOWNLOADED;
|
||||
break;
|
||||
case eDeliveryState_Unknown:
|
||||
case eDeliveryState_EndGuard:
|
||||
default:
|
||||
MOZ_CRASH("We shouldn't get any other delivery state!");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetDeliveryInfo(JSContext* aCx, JS::MutableHandle<JS::Value> aDeliveryInfo)
|
||||
{
|
||||
// TODO Bug 850525 It'd be better to depend on the delivery of MmsMessage
|
||||
// to return a more correct value. Ex, if .delivery = 'received', we should
|
||||
// also make .deliveryInfo = null, since the .deliveryInfo is useless.
|
||||
uint32_t length = mDeliveryInfo.Length();
|
||||
if (length == 0) {
|
||||
aDeliveryInfo.setNull();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!ToJSValue(aCx, mDeliveryInfo, aDeliveryInfo)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetSender(nsAString& aSender)
|
||||
{
|
||||
aSender = mSender;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetReceivers(JSContext* aCx, JS::MutableHandle<JS::Value> aReceivers)
|
||||
{
|
||||
JS::Rooted<JSObject*> receiversObj(aCx);
|
||||
nsresult rv = nsTArrayToJSArray(aCx, mReceivers, &receiversObj);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
aReceivers.setObject(*receiversObj);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetTimestamp(DOMTimeStamp* aTimestamp)
|
||||
{
|
||||
*aTimestamp = mTimestamp;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetSentTimestamp(DOMTimeStamp* aSentTimestamp)
|
||||
{
|
||||
*aSentTimestamp = mSentTimestamp;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetRead(bool* aRead)
|
||||
{
|
||||
*aRead = mRead;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetSubject(nsAString& aSubject)
|
||||
{
|
||||
aSubject = mSubject;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetSmil(nsAString& aSmil)
|
||||
{
|
||||
aSmil = mSmil;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetAttachments(JSContext* aCx, JS::MutableHandle<JS::Value> aAttachments)
|
||||
{
|
||||
uint32_t length = mAttachments.Length();
|
||||
|
||||
JS::Rooted<JSObject*> attachments(
|
||||
aCx, JS_NewArrayObject(aCx, length));
|
||||
NS_ENSURE_TRUE(attachments, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
const Attachment &attachment = mAttachments[i];
|
||||
|
||||
JS::Rooted<JSObject*> attachmentObj(aCx, JS_NewPlainObject(aCx));
|
||||
NS_ENSURE_TRUE(attachmentObj, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
JS::Rooted<JSString*> tmpJsStr(aCx);
|
||||
|
||||
// Get |attachment.mId|.
|
||||
tmpJsStr = JS_NewUCStringCopyN(aCx,
|
||||
attachment.id.get(),
|
||||
attachment.id.Length());
|
||||
NS_ENSURE_TRUE(tmpJsStr, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
if (!JS_DefineProperty(aCx, attachmentObj, "id", tmpJsStr, JSPROP_ENUMERATE)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Get |attachment.mLocation|.
|
||||
tmpJsStr = JS_NewUCStringCopyN(aCx,
|
||||
attachment.location.get(),
|
||||
attachment.location.Length());
|
||||
NS_ENSURE_TRUE(tmpJsStr, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
if (!JS_DefineProperty(aCx, attachmentObj, "location", tmpJsStr, JSPROP_ENUMERATE)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Get |attachment.mContent|.
|
||||
|
||||
// Duplicating the File with the correct parent object.
|
||||
nsIGlobalObject *global = xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx));
|
||||
MOZ_ASSERT(global);
|
||||
RefPtr<Blob> newBlob = Blob::Create(global, attachment.content->Impl());
|
||||
|
||||
JS::Rooted<JS::Value> val(aCx);
|
||||
if (!ToJSValue(aCx, newBlob, &val)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (!JS_DefineProperty(aCx, attachmentObj, "content", val, JSPROP_ENUMERATE)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (!JS_DefineElement(aCx, attachments, i, attachmentObj, JSPROP_ENUMERATE)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
aAttachments.setObject(*attachments);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetExpiryDate(DOMTimeStamp* aExpiryDate)
|
||||
{
|
||||
*aExpiryDate = mExpiryDate;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessage::GetReadReportRequested(bool* aReadReportRequested)
|
||||
{
|
||||
*aReadReportRequested = mReadReportRequested;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -1,111 +1,106 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* 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/. */
|
||||
* 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_mobilemessage_MmsMessage_h
|
||||
#define mozilla_dom_mobilemessage_MmsMessage_h
|
||||
#ifndef mozilla_dom_MmsMessage_h
|
||||
#define mozilla_dom_MmsMessage_h
|
||||
|
||||
#include "nsIDOMMozMmsMessage.h"
|
||||
#include "nsString.h"
|
||||
#include "mozilla/dom/mobilemessage/Types.h"
|
||||
#include "mozilla/dom/MozMmsMessageBinding.h"
|
||||
#include "mozilla/dom/MozMobileMessageManagerBinding.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
class nsPIDOMWindow;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class Blob;
|
||||
|
||||
namespace mobilemessage {
|
||||
class MmsMessageData;
|
||||
class MmsMessageInternal;
|
||||
} // namespace mobilemessage
|
||||
|
||||
class ContentParent;
|
||||
struct MmsAttachment;
|
||||
struct MmsDeliveryInfo;
|
||||
|
||||
class MmsMessage final : public nsIDOMMozMmsMessage
|
||||
class MmsMessage final : public nsISupports,
|
||||
public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOMMOZMMSMESSAGE
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MmsMessage)
|
||||
|
||||
// If this is changed, change the WebIDL dictionary as well.
|
||||
struct Attachment final
|
||||
MmsMessage(nsPIDOMWindow* aWindow,
|
||||
mobilemessage::MmsMessageInternal* aMessage);
|
||||
|
||||
nsPIDOMWindow*
|
||||
GetParentObject() const
|
||||
{
|
||||
RefPtr<Blob> content;
|
||||
nsString id;
|
||||
nsString location;
|
||||
return mWindow;
|
||||
}
|
||||
|
||||
explicit Attachment(const MmsAttachment& aAttachment) :
|
||||
content(aAttachment.mContent),
|
||||
id(aAttachment.mId),
|
||||
location(aAttachment.mLocation)
|
||||
{}
|
||||
};
|
||||
virtual JSObject*
|
||||
WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
MmsMessage(int32_t aId,
|
||||
uint64_t aThreadId,
|
||||
const nsAString& aIccId,
|
||||
mobilemessage::DeliveryState aDelivery,
|
||||
const nsTArray<MmsDeliveryInfo>& aDeliveryInfo,
|
||||
const nsAString& aSender,
|
||||
const nsTArray<nsString>& aReceivers,
|
||||
uint64_t aTimestamp,
|
||||
uint64_t aSentTimestamp,
|
||||
bool aRead,
|
||||
const nsAString& aSubject,
|
||||
const nsAString& aSmil,
|
||||
const nsTArray<Attachment>& aAttachments,
|
||||
uint64_t aExpiryDate,
|
||||
bool aReadReportRequested);
|
||||
void
|
||||
GetType(nsString& aRetVal) const;
|
||||
|
||||
explicit MmsMessage(const mobilemessage::MmsMessageData& aData);
|
||||
int32_t
|
||||
Id() const;
|
||||
|
||||
static nsresult Create(int32_t aId,
|
||||
uint64_t aThreadId,
|
||||
const nsAString& aIccId,
|
||||
const nsAString& aDelivery,
|
||||
const JS::Value& aDeliveryInfo,
|
||||
const nsAString& aSender,
|
||||
const JS::Value& aReceivers,
|
||||
uint64_t aTimestamp,
|
||||
uint64_t aSentTimestamp,
|
||||
bool aRead,
|
||||
const nsAString& aSubject,
|
||||
const nsAString& aSmil,
|
||||
const JS::Value& aAttachments,
|
||||
uint64_t aExpiryDate,
|
||||
bool aReadReportRequested,
|
||||
JSContext* aCx,
|
||||
nsIDOMMozMmsMessage** aMessage);
|
||||
uint64_t
|
||||
ThreadId() const;
|
||||
|
||||
bool GetData(ContentParent* aParent,
|
||||
mobilemessage::MmsMessageData& aData);
|
||||
void
|
||||
GetIccId(nsString& aRetVal) const;
|
||||
|
||||
void
|
||||
GetDelivery(nsString& aRetVal) const;
|
||||
|
||||
void
|
||||
GetDeliveryInfo(nsTArray<MmsDeliveryInfo>& aRetVal) const;
|
||||
|
||||
void
|
||||
GetSender(nsString& aRetVal) const;
|
||||
|
||||
void
|
||||
GetReceivers(nsTArray<nsString>& aRetVal) const;
|
||||
|
||||
uint64_t
|
||||
Timestamp() const;
|
||||
|
||||
uint64_t
|
||||
SentTimestamp() const;
|
||||
|
||||
bool
|
||||
Read() const;
|
||||
|
||||
void
|
||||
GetSubject(nsString& aRetVal) const;
|
||||
|
||||
void
|
||||
GetSmil(nsString& aRetVal) const;
|
||||
|
||||
void
|
||||
GetAttachments(nsTArray<MmsAttachment>& aRetVal) const;
|
||||
|
||||
uint64_t
|
||||
ExpiryDate() const;
|
||||
|
||||
bool
|
||||
ReadReportRequested() const;
|
||||
|
||||
private:
|
||||
// Don't try to use the default constructor.
|
||||
MmsMessage() = delete;
|
||||
|
||||
~MmsMessage() {}
|
||||
~MmsMessage();
|
||||
|
||||
int32_t mId;
|
||||
uint64_t mThreadId;
|
||||
nsString mIccId;
|
||||
mobilemessage::DeliveryState mDelivery;
|
||||
nsTArray<MmsDeliveryInfo> mDeliveryInfo;
|
||||
nsString mSender;
|
||||
nsTArray<nsString> mReceivers;
|
||||
uint64_t mTimestamp;
|
||||
uint64_t mSentTimestamp;
|
||||
bool mRead;
|
||||
nsString mSubject;
|
||||
nsString mSmil;
|
||||
nsTArray<Attachment> mAttachments;
|
||||
uint64_t mExpiryDate;
|
||||
bool mReadReportRequested;
|
||||
nsCOMPtr<nsPIDOMWindow> mWindow;
|
||||
RefPtr<mobilemessage::MmsMessageInternal> mMessage;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_mobilemessage_MmsMessage_h
|
||||
#endif // mozilla_dom_MmsMessage_h
|
||||
|
|
|
@ -0,0 +1,614 @@
|
|||
/* -*- 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/. */
|
||||
|
||||
#include "MmsMessageInternal.h"
|
||||
|
||||
#include "nsIDOMClassInfo.h"
|
||||
#include "jsapi.h" // For JS_IsArrayObject, JS_GetElement, etc.
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsTArrayHelpers.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/dom/File.h"
|
||||
#include "mozilla/dom/mobilemessage/Constants.h" // For MessageType
|
||||
#include "mozilla/dom/mobilemessage/SmsTypes.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "mozilla/dom/ToJSValue.h"
|
||||
#include "mozilla/dom/ipc/BlobChild.h"
|
||||
#include "mozilla/dom/ipc/BlobParent.h"
|
||||
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mobilemessage {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(MmsMessageInternal)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(MmsMessageInternal)
|
||||
for (uint32_t i = 0; i < tmp->mAttachments.Length(); i++) {
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAttachments[i].mContent)
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(MmsMessageInternal)
|
||||
for (uint32_t i = 0; i < tmp->mAttachments.Length(); i++) {
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mAttachments[i].mContent)
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MmsMessageInternal)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIMmsMessage)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(MmsMessageInternal)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(MmsMessageInternal)
|
||||
|
||||
MmsMessageInternal::MmsMessageInternal(int32_t aId,
|
||||
uint64_t aThreadId,
|
||||
const nsAString& aIccId,
|
||||
DeliveryState aDelivery,
|
||||
const nsTArray<MmsDeliveryInfo>& aDeliveryInfo,
|
||||
const nsAString& aSender,
|
||||
const nsTArray<nsString>& aReceivers,
|
||||
uint64_t aTimestamp,
|
||||
uint64_t aSentTimestamp,
|
||||
bool aRead,
|
||||
const nsAString& aSubject,
|
||||
const nsAString& aSmil,
|
||||
const nsTArray<MmsAttachment>& aAttachments,
|
||||
uint64_t aExpiryDate,
|
||||
bool aReadReportRequested)
|
||||
: mId(aId),
|
||||
mThreadId(aThreadId),
|
||||
mIccId(aIccId),
|
||||
mDelivery(aDelivery),
|
||||
mDeliveryInfo(aDeliveryInfo),
|
||||
mSender(aSender),
|
||||
mReceivers(aReceivers),
|
||||
mTimestamp(aTimestamp),
|
||||
mSentTimestamp(aSentTimestamp),
|
||||
mRead(aRead),
|
||||
mSubject(aSubject),
|
||||
mSmil(aSmil),
|
||||
mAttachments(aAttachments),
|
||||
mExpiryDate(aExpiryDate),
|
||||
mReadReportRequested(aReadReportRequested)
|
||||
{
|
||||
}
|
||||
|
||||
MmsMessageInternal::MmsMessageInternal(const MmsMessageData& aData)
|
||||
: mId(aData.id())
|
||||
, mThreadId(aData.threadId())
|
||||
, mIccId(aData.iccId())
|
||||
, mDelivery(aData.delivery())
|
||||
, mSender(aData.sender())
|
||||
, mReceivers(aData.receivers())
|
||||
, mTimestamp(aData.timestamp())
|
||||
, mSentTimestamp(aData.sentTimestamp())
|
||||
, mRead(aData.read())
|
||||
, mSubject(aData.subject())
|
||||
, mSmil(aData.smil())
|
||||
, mExpiryDate(aData.expiryDate())
|
||||
, mReadReportRequested(aData.readReportRequested())
|
||||
{
|
||||
uint32_t len = aData.attachments().Length();
|
||||
mAttachments.SetCapacity(len);
|
||||
for (uint32_t i = 0; i < len; i++) {
|
||||
MmsAttachment att;
|
||||
const MmsAttachmentData &element = aData.attachments()[i];
|
||||
att.mId = element.id();
|
||||
att.mLocation = element.location();
|
||||
|
||||
// mContent is not going to be exposed to JS directly so we can use
|
||||
// nullptr as parent.
|
||||
if (element.contentParent()) {
|
||||
RefPtr<BlobImpl> impl = static_cast<BlobParent*>(element.contentParent())->GetBlobImpl();
|
||||
att.mContent = Blob::Create(nullptr, impl);
|
||||
} else if (element.contentChild()) {
|
||||
RefPtr<BlobImpl> impl = static_cast<BlobChild*>(element.contentChild())->GetBlobImpl();
|
||||
att.mContent = Blob::Create(nullptr, impl);
|
||||
} else {
|
||||
NS_WARNING("MmsMessage: Unable to get attachment content.");
|
||||
}
|
||||
mAttachments.AppendElement(att);
|
||||
}
|
||||
|
||||
len = aData.deliveryInfo().Length();
|
||||
mDeliveryInfo.SetCapacity(len);
|
||||
for (uint32_t i = 0; i < len; i++) {
|
||||
MmsDeliveryInfo info;
|
||||
const MmsDeliveryInfoData &infoData = aData.deliveryInfo()[i];
|
||||
|
||||
// Prepare |info.mReceiver|.
|
||||
info.mReceiver = infoData.receiver();
|
||||
|
||||
// Prepare |info.mDeliveryStatus|.
|
||||
nsString statusStr;
|
||||
switch (infoData.deliveryStatus()) {
|
||||
case eDeliveryStatus_NotApplicable:
|
||||
statusStr = DELIVERY_STATUS_NOT_APPLICABLE;
|
||||
break;
|
||||
case eDeliveryStatus_Success:
|
||||
statusStr = DELIVERY_STATUS_SUCCESS;
|
||||
break;
|
||||
case eDeliveryStatus_Pending:
|
||||
statusStr = DELIVERY_STATUS_PENDING;
|
||||
break;
|
||||
case eDeliveryStatus_Error:
|
||||
statusStr = DELIVERY_STATUS_ERROR;
|
||||
break;
|
||||
case eDeliveryStatus_Reject:
|
||||
statusStr = DELIVERY_STATUS_REJECTED;
|
||||
break;
|
||||
case eDeliveryStatus_Manual:
|
||||
statusStr = DELIVERY_STATUS_MANUAL;
|
||||
break;
|
||||
case eDeliveryStatus_EndGuard:
|
||||
default:
|
||||
MOZ_CRASH("We shouldn't get any other delivery status!");
|
||||
}
|
||||
info.mDeliveryStatus = statusStr;
|
||||
|
||||
// Prepare |info.mDeliveryTimestamp|.
|
||||
info.mDeliveryTimestamp = infoData.deliveryTimestamp();
|
||||
|
||||
// Prepare |info.mReadStatus|.
|
||||
nsString statusReadString;
|
||||
switch(infoData.readStatus()) {
|
||||
case eReadStatus_NotApplicable:
|
||||
statusReadString = READ_STATUS_NOT_APPLICABLE;
|
||||
break;
|
||||
case eReadStatus_Success:
|
||||
statusReadString = READ_STATUS_SUCCESS;
|
||||
break;
|
||||
case eReadStatus_Pending:
|
||||
statusReadString = READ_STATUS_PENDING;
|
||||
break;
|
||||
case eReadStatus_Error:
|
||||
statusReadString = READ_STATUS_ERROR;
|
||||
break;
|
||||
case eReadStatus_EndGuard:
|
||||
default:
|
||||
MOZ_CRASH("We shouldn't get any other read status!");
|
||||
}
|
||||
info.mReadStatus = statusReadString;
|
||||
|
||||
// Prepare |info.mReadTimestamp|.
|
||||
info.mReadTimestamp = infoData.readTimestamp();
|
||||
|
||||
mDeliveryInfo.AppendElement(info);
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ nsresult
|
||||
MmsMessageInternal::Create(int32_t aId,
|
||||
uint64_t aThreadId,
|
||||
const nsAString& aIccId,
|
||||
const nsAString& aDelivery,
|
||||
const JS::Value& aDeliveryInfo,
|
||||
const nsAString& aSender,
|
||||
const JS::Value& aReceivers,
|
||||
uint64_t aTimestamp,
|
||||
uint64_t aSentTimestamp,
|
||||
bool aRead,
|
||||
const nsAString& aSubject,
|
||||
const nsAString& aSmil,
|
||||
const JS::Value& aAttachments,
|
||||
uint64_t aExpiryDate,
|
||||
bool aIsReadReportRequested,
|
||||
JSContext* aCx,
|
||||
nsIMmsMessage** aMessage)
|
||||
{
|
||||
*aMessage = nullptr;
|
||||
|
||||
// Set |delivery|.
|
||||
DeliveryState delivery;
|
||||
if (aDelivery.Equals(DELIVERY_SENT)) {
|
||||
delivery = eDeliveryState_Sent;
|
||||
} else if (aDelivery.Equals(DELIVERY_RECEIVED)) {
|
||||
delivery = eDeliveryState_Received;
|
||||
} else if (aDelivery.Equals(DELIVERY_SENDING)) {
|
||||
delivery = eDeliveryState_Sending;
|
||||
} else if (aDelivery.Equals(DELIVERY_NOT_DOWNLOADED)) {
|
||||
delivery = eDeliveryState_NotDownloaded;
|
||||
} else if (aDelivery.Equals(DELIVERY_ERROR)) {
|
||||
delivery = eDeliveryState_Error;
|
||||
} else {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
// Set |deliveryInfo|.
|
||||
if (!aDeliveryInfo.isObject()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
JS::Rooted<JSObject*> deliveryInfoObj(aCx, &aDeliveryInfo.toObject());
|
||||
bool isArray;
|
||||
if (!JS_IsArrayObject(aCx, deliveryInfoObj, &isArray)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!isArray) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
uint32_t length;
|
||||
MOZ_ALWAYS_TRUE(JS_GetArrayLength(aCx, deliveryInfoObj, &length));
|
||||
|
||||
nsTArray<MmsDeliveryInfo> deliveryInfo;
|
||||
JS::Rooted<JS::Value> infoJsVal(aCx);
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
if (!JS_GetElement(aCx, deliveryInfoObj, i, &infoJsVal) ||
|
||||
!infoJsVal.isObject()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
MmsDeliveryInfo info;
|
||||
if (!info.Init(aCx, infoJsVal)) {
|
||||
return NS_ERROR_TYPE_ERR;
|
||||
}
|
||||
|
||||
deliveryInfo.AppendElement(info);
|
||||
}
|
||||
|
||||
// Set |receivers|.
|
||||
if (!aReceivers.isObject()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
JS::Rooted<JSObject*> receiversObj(aCx, &aReceivers.toObject());
|
||||
if (!JS_IsArrayObject(aCx, receiversObj, &isArray)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!isArray) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
MOZ_ALWAYS_TRUE(JS_GetArrayLength(aCx, receiversObj, &length));
|
||||
|
||||
nsTArray<nsString> receivers;
|
||||
JS::Rooted<JS::Value> receiverJsVal(aCx);
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
if (!JS_GetElement(aCx, receiversObj, i, &receiverJsVal) ||
|
||||
!receiverJsVal.isString()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
nsAutoJSString receiverStr;
|
||||
if (!receiverStr.init(aCx, receiverJsVal.toString())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
receivers.AppendElement(receiverStr);
|
||||
}
|
||||
|
||||
// Set |attachments|.
|
||||
if (!aAttachments.isObject()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
JS::Rooted<JSObject*> attachmentsObj(aCx, &aAttachments.toObject());
|
||||
if (!JS_IsArrayObject(aCx, attachmentsObj, &isArray)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!isArray) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
nsTArray<MmsAttachment> attachments;
|
||||
MOZ_ALWAYS_TRUE(JS_GetArrayLength(aCx, attachmentsObj, &length));
|
||||
|
||||
JS::Rooted<JS::Value> attachmentJsVal(aCx);
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
if (!JS_GetElement(aCx, attachmentsObj, i, &attachmentJsVal)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
MmsAttachment attachment;
|
||||
if (!attachment.Init(aCx, attachmentJsVal)) {
|
||||
return NS_ERROR_TYPE_ERR;
|
||||
}
|
||||
|
||||
NS_ENSURE_TRUE(attachment.mContent, NS_ERROR_TYPE_ERR);
|
||||
|
||||
attachments.AppendElement(attachment);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIMmsMessage> message =
|
||||
new MmsMessageInternal(aId,
|
||||
aThreadId,
|
||||
aIccId,
|
||||
delivery,
|
||||
deliveryInfo,
|
||||
aSender,
|
||||
receivers,
|
||||
aTimestamp,
|
||||
aSentTimestamp,
|
||||
aRead,
|
||||
aSubject,
|
||||
aSmil,
|
||||
attachments,
|
||||
aExpiryDate,
|
||||
aIsReadReportRequested);
|
||||
message.forget(aMessage);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
MmsMessageInternal::GetData(ContentParent* aParent,
|
||||
MmsMessageData& aData)
|
||||
{
|
||||
NS_ASSERTION(aParent, "aParent is null");
|
||||
|
||||
aData.id() = mId;
|
||||
aData.threadId() = mThreadId;
|
||||
aData.iccId() = mIccId;
|
||||
aData.delivery() = mDelivery;
|
||||
aData.sender().Assign(mSender);
|
||||
aData.receivers() = mReceivers;
|
||||
aData.timestamp() = mTimestamp;
|
||||
aData.sentTimestamp() = mSentTimestamp;
|
||||
aData.read() = mRead;
|
||||
aData.subject() = mSubject;
|
||||
aData.smil() = mSmil;
|
||||
aData.expiryDate() = mExpiryDate;
|
||||
aData.readReportRequested() = mReadReportRequested;
|
||||
|
||||
aData.deliveryInfo().SetCapacity(mDeliveryInfo.Length());
|
||||
for (uint32_t i = 0; i < mDeliveryInfo.Length(); i++) {
|
||||
MmsDeliveryInfoData infoData;
|
||||
const MmsDeliveryInfo &info = mDeliveryInfo[i];
|
||||
|
||||
// Prepare |infoData.mReceiver|.
|
||||
infoData.receiver().Assign(info.mReceiver);
|
||||
|
||||
// Prepare |infoData.mDeliveryStatus|.
|
||||
DeliveryStatus status;
|
||||
if (info.mDeliveryStatus.Equals(DELIVERY_STATUS_NOT_APPLICABLE)) {
|
||||
status = eDeliveryStatus_NotApplicable;
|
||||
} else if (info.mDeliveryStatus.Equals(DELIVERY_STATUS_SUCCESS)) {
|
||||
status = eDeliveryStatus_Success;
|
||||
} else if (info.mDeliveryStatus.Equals(DELIVERY_STATUS_PENDING)) {
|
||||
status = eDeliveryStatus_Pending;
|
||||
} else if (info.mDeliveryStatus.Equals(DELIVERY_STATUS_ERROR)) {
|
||||
status = eDeliveryStatus_Error;
|
||||
} else if (info.mDeliveryStatus.Equals(DELIVERY_STATUS_REJECTED)) {
|
||||
status = eDeliveryStatus_Reject;
|
||||
} else if (info.mDeliveryStatus.Equals(DELIVERY_STATUS_MANUAL)) {
|
||||
status = eDeliveryStatus_Manual;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
infoData.deliveryStatus() = status;
|
||||
|
||||
// Prepare |infoData.mDeliveryTimestamp|.
|
||||
infoData.deliveryTimestamp() = info.mDeliveryTimestamp;
|
||||
|
||||
// Prepare |infoData.mReadStatus|.
|
||||
ReadStatus readStatus;
|
||||
if (info.mReadStatus.Equals(READ_STATUS_NOT_APPLICABLE)) {
|
||||
readStatus = eReadStatus_NotApplicable;
|
||||
} else if (info.mReadStatus.Equals(READ_STATUS_SUCCESS)) {
|
||||
readStatus = eReadStatus_Success;
|
||||
} else if (info.mReadStatus.Equals(READ_STATUS_PENDING)) {
|
||||
readStatus = eReadStatus_Pending;
|
||||
} else if (info.mReadStatus.Equals(READ_STATUS_ERROR)) {
|
||||
readStatus = eReadStatus_Error;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
infoData.readStatus() = readStatus;
|
||||
|
||||
// Prepare |infoData.mReadTimestamp|.
|
||||
infoData.readTimestamp() = info.mReadTimestamp;
|
||||
|
||||
aData.deliveryInfo().AppendElement(infoData);
|
||||
}
|
||||
|
||||
aData.attachments().SetCapacity(mAttachments.Length());
|
||||
for (uint32_t i = 0; i < mAttachments.Length(); i++) {
|
||||
MmsAttachmentData mma;
|
||||
const MmsAttachment &element = mAttachments[i];
|
||||
mma.id().Assign(element.mId);
|
||||
mma.location().Assign(element.mLocation);
|
||||
|
||||
// This is a workaround. Sometimes the blob we get from the database
|
||||
// doesn't have a valid last modified date, making the ContentParent
|
||||
// send a "Mystery Blob" to the ContentChild. Attempting to get the
|
||||
// last modified date of blob can force that value to be initialized.
|
||||
RefPtr<BlobImpl> impl = element.mContent->Impl();
|
||||
if (impl && impl->IsDateUnknown()) {
|
||||
ErrorResult rv;
|
||||
impl->GetLastModified(rv);
|
||||
if (rv.Failed()) {
|
||||
NS_WARNING("Failed to get last modified date!");
|
||||
rv.SuppressException();
|
||||
}
|
||||
}
|
||||
|
||||
mma.contentParent() = aParent->GetOrCreateActorForBlob(element.mContent);
|
||||
if (!mma.contentParent()) {
|
||||
return false;
|
||||
}
|
||||
aData.attachments().AppendElement(mma);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessageInternal::GetType(nsAString& aType)
|
||||
{
|
||||
aType = NS_LITERAL_STRING("mms");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessageInternal::GetId(int32_t* aId)
|
||||
{
|
||||
*aId = mId;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessageInternal::GetThreadId(uint64_t* aThreadId)
|
||||
{
|
||||
*aThreadId = mThreadId;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessageInternal::GetIccId(nsAString& aIccId)
|
||||
{
|
||||
aIccId = mIccId;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessageInternal::GetDelivery(nsAString& aDelivery)
|
||||
{
|
||||
switch (mDelivery) {
|
||||
case eDeliveryState_Received:
|
||||
aDelivery = DELIVERY_RECEIVED;
|
||||
break;
|
||||
case eDeliveryState_Sending:
|
||||
aDelivery = DELIVERY_SENDING;
|
||||
break;
|
||||
case eDeliveryState_Sent:
|
||||
aDelivery = DELIVERY_SENT;
|
||||
break;
|
||||
case eDeliveryState_Error:
|
||||
aDelivery = DELIVERY_ERROR;
|
||||
break;
|
||||
case eDeliveryState_NotDownloaded:
|
||||
aDelivery = DELIVERY_NOT_DOWNLOADED;
|
||||
break;
|
||||
case eDeliveryState_Unknown:
|
||||
case eDeliveryState_EndGuard:
|
||||
default:
|
||||
MOZ_CRASH("We shouldn't get any other delivery state!");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessageInternal::GetDeliveryInfo(JSContext* aCx, JS::MutableHandle<JS::Value> aDeliveryInfo)
|
||||
{
|
||||
// TODO Bug 850525 It'd be better to depend on the delivery of MmsMessage
|
||||
// to return a more correct value. Ex, if .delivery = 'received', we should
|
||||
// also make .deliveryInfo = null, since the .deliveryInfo is useless.
|
||||
uint32_t length = mDeliveryInfo.Length();
|
||||
if (length == 0) {
|
||||
aDeliveryInfo.setNull();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!ToJSValue(aCx, mDeliveryInfo, aDeliveryInfo)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessageInternal::GetSender(nsAString& aSender)
|
||||
{
|
||||
aSender = mSender;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessageInternal::GetReceivers(JSContext* aCx, JS::MutableHandle<JS::Value> aReceivers)
|
||||
{
|
||||
JS::Rooted<JSObject*> receiversObj(aCx);
|
||||
nsresult rv = nsTArrayToJSArray(aCx, mReceivers, &receiversObj);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
aReceivers.setObject(*receiversObj);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessageInternal::GetTimestamp(DOMTimeStamp* aTimestamp)
|
||||
{
|
||||
*aTimestamp = mTimestamp;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessageInternal::GetSentTimestamp(DOMTimeStamp* aSentTimestamp)
|
||||
{
|
||||
*aSentTimestamp = mSentTimestamp;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessageInternal::GetRead(bool* aRead)
|
||||
{
|
||||
*aRead = mRead;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessageInternal::GetSubject(nsAString& aSubject)
|
||||
{
|
||||
aSubject = mSubject;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessageInternal::GetSmil(nsAString& aSmil)
|
||||
{
|
||||
aSmil = mSmil;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessageInternal::GetAttachments(JSContext* aCx, JS::MutableHandle<JS::Value> aAttachments)
|
||||
{
|
||||
uint32_t length = mAttachments.Length();
|
||||
|
||||
if (length == 0) {
|
||||
aAttachments.setNull();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Duplicating the Blob with the correct parent object.
|
||||
nsIGlobalObject* global = xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx));
|
||||
MOZ_ASSERT(global);
|
||||
nsTArray<MmsAttachment> result;
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
MmsAttachment attachment;
|
||||
const MmsAttachment &element = mAttachments[i];
|
||||
attachment.mId = element.mId;
|
||||
attachment.mLocation = element.mLocation;
|
||||
attachment.mContent = Blob::Create(global, element.mContent->Impl());
|
||||
result.AppendElement(attachment);
|
||||
}
|
||||
|
||||
if (!ToJSValue(aCx, result, aAttachments)) {
|
||||
JS_ClearPendingException(aCx);
|
||||
return NS_ERROR_TYPE_ERR;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessageInternal::GetExpiryDate(DOMTimeStamp* aExpiryDate)
|
||||
{
|
||||
*aExpiryDate = mExpiryDate;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MmsMessageInternal::GetReadReportRequested(bool* aReadReportRequested)
|
||||
{
|
||||
*aReadReportRequested = mReadReportRequested;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace mobilemessage
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,104 @@
|
|||
/* -*- 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_mobilemessage_MmsMessageInternal_h
|
||||
#define mozilla_dom_mobilemessage_MmsMessageInternal_h
|
||||
|
||||
#include "nsIMmsMessage.h"
|
||||
#include "nsString.h"
|
||||
#include "mozilla/dom/mobilemessage/Types.h"
|
||||
#include "mozilla/dom/MmsMessageBinding.h"
|
||||
#include "mozilla/dom/MozMobileMessageManagerBinding.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class ContentParent;
|
||||
class Blob;
|
||||
struct MmsAttachment;
|
||||
class MmsMessage;
|
||||
|
||||
namespace mobilemessage {
|
||||
|
||||
class MmsMessageData;
|
||||
|
||||
class MmsMessageInternal final : public nsIMmsMessage
|
||||
{
|
||||
// This allows the MmsMessage class to access jsval data members
|
||||
// like |deliveryInfo|, |receivers|, and |attachments| without JS API.
|
||||
friend class mozilla::dom::MmsMessage;
|
||||
|
||||
public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS(MmsMessageInternal)
|
||||
NS_DECL_NSIMMSMESSAGE
|
||||
|
||||
MmsMessageInternal(int32_t aId,
|
||||
uint64_t aThreadId,
|
||||
const nsAString& aIccId,
|
||||
mobilemessage::DeliveryState aDelivery,
|
||||
const nsTArray<MmsDeliveryInfo>& aDeliveryInfo,
|
||||
const nsAString& aSender,
|
||||
const nsTArray<nsString>& aReceivers,
|
||||
uint64_t aTimestamp,
|
||||
uint64_t aSentTimestamp,
|
||||
bool aRead,
|
||||
const nsAString& aSubject,
|
||||
const nsAString& aSmil,
|
||||
const nsTArray<MmsAttachment>& aAttachments,
|
||||
uint64_t aExpiryDate,
|
||||
bool aReadReportRequested);
|
||||
|
||||
explicit MmsMessageInternal(const MmsMessageData& aData);
|
||||
|
||||
static nsresult Create(int32_t aId,
|
||||
uint64_t aThreadId,
|
||||
const nsAString& aIccId,
|
||||
const nsAString& aDelivery,
|
||||
const JS::Value& aDeliveryInfo,
|
||||
const nsAString& aSender,
|
||||
const JS::Value& aReceivers,
|
||||
uint64_t aTimestamp,
|
||||
uint64_t aSentTimestamp,
|
||||
bool aRead,
|
||||
const nsAString& aSubject,
|
||||
const nsAString& aSmil,
|
||||
const JS::Value& aAttachments,
|
||||
uint64_t aExpiryDate,
|
||||
bool aReadReportRequested,
|
||||
JSContext* aCx,
|
||||
nsIMmsMessage** aMessage);
|
||||
|
||||
bool GetData(ContentParent* aParent,
|
||||
MmsMessageData& aData);
|
||||
|
||||
private:
|
||||
|
||||
~MmsMessageInternal() {}
|
||||
|
||||
int32_t mId;
|
||||
uint64_t mThreadId;
|
||||
nsString mIccId;
|
||||
mobilemessage::DeliveryState mDelivery;
|
||||
nsTArray<MmsDeliveryInfo> mDeliveryInfo;
|
||||
nsString mSender;
|
||||
nsTArray<nsString> mReceivers;
|
||||
uint64_t mTimestamp;
|
||||
uint64_t mSentTimestamp;
|
||||
bool mRead;
|
||||
nsString mSubject;
|
||||
nsString mSmil;
|
||||
nsTArray<MmsAttachment> mAttachments;
|
||||
uint64_t mExpiryDate;
|
||||
bool mReadReportRequested;
|
||||
};
|
||||
|
||||
} // namespace mobilemessage
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_mobilemessage_MmsMessageInternal_h
|
|
@ -7,11 +7,12 @@
|
|||
#include "MobileMessageCallback.h"
|
||||
#include "mozilla/dom/ToJSValue.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIDOMMozSmsMessage.h"
|
||||
#include "nsIDOMMozMmsMessage.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "MmsMessage.h"
|
||||
#include "MmsMessageInternal.h"
|
||||
#include "SmsMessage.h"
|
||||
#include "SmsMessageInternal.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "jsapi.h"
|
||||
#include "xpcpublic.h"
|
||||
|
@ -132,14 +133,36 @@ MobileMessageCallback::NotifySuccess(JS::Handle<JS::Value> aResult, bool aAsync)
|
|||
nsresult
|
||||
MobileMessageCallback::NotifySuccess(nsISupports *aMessage, bool aAsync)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> window = mDOMRequest->GetOwner();
|
||||
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsISupports> result;
|
||||
|
||||
nsCOMPtr<nsISmsMessage> internalSms =
|
||||
do_QueryInterface(aMessage);
|
||||
if (internalSms) {
|
||||
SmsMessageInternal* smsMsg = static_cast<SmsMessageInternal*>(internalSms.get());
|
||||
result = new SmsMessage(window, smsMsg);
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
nsCOMPtr<nsIMmsMessage> internalMms =
|
||||
do_QueryInterface(aMessage);
|
||||
if (internalMms) {
|
||||
MmsMessageInternal* mmsMsg = static_cast<MmsMessageInternal*>(internalMms.get());
|
||||
result = new MmsMessage(window, mmsMsg);
|
||||
}
|
||||
}
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
if (NS_WARN_IF(!jsapi.Init(mDOMRequest->GetOwner()))) {
|
||||
if (NS_WARN_IF(!jsapi.Init(window))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
JSContext* cx = jsapi.cx();
|
||||
|
||||
JS::Rooted<JS::Value> wrappedMessage(cx);
|
||||
nsresult rv = nsContentUtils::WrapNative(cx, aMessage, &wrappedMessage);
|
||||
nsresult rv =
|
||||
nsContentUtils::WrapNative(cx, result, &wrappedMessage);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NotifySuccess(wrappedMessage, aAsync);
|
||||
|
@ -190,15 +213,19 @@ MobileMessageCallback::NotifySendMessageFailed(int32_t aError, nsISupports *aMes
|
|||
RefPtr<DOMMobileMessageError> domMobileMessageError;
|
||||
if (aMessage) {
|
||||
nsAutoString errorStr = ConvertErrorCodeToErrorString(aError);
|
||||
nsCOMPtr<nsIDOMMozSmsMessage> smsMsg = do_QueryInterface(aMessage);
|
||||
if (smsMsg) {
|
||||
nsCOMPtr<nsISmsMessage> internalSms = do_QueryInterface(aMessage);
|
||||
if (internalSms) {
|
||||
domMobileMessageError =
|
||||
new DOMMobileMessageError(window, errorStr, smsMsg);
|
||||
new DOMMobileMessageError(window, errorStr,
|
||||
new SmsMessage(window,
|
||||
static_cast<SmsMessageInternal*>(internalSms.get())));
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIDOMMozMmsMessage> mmsMsg = do_QueryInterface(aMessage);
|
||||
nsCOMPtr<nsIMmsMessage> internalMms = do_QueryInterface(aMessage);
|
||||
domMobileMessageError =
|
||||
new DOMMobileMessageError(window, errorStr, mmsMsg);
|
||||
new DOMMobileMessageError(window, errorStr,
|
||||
new MmsMessage(window,
|
||||
static_cast<MmsMessageInternal*>(internalMms.get())));
|
||||
}
|
||||
NS_ASSERTION(domMobileMessageError, "Invalid DOMMobileMessageError!");
|
||||
}
|
||||
|
|
|
@ -5,9 +5,14 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "MobileMessageCursorCallback.h"
|
||||
#include "MmsMessage.h"
|
||||
#include "MmsMessageInternal.h"
|
||||
#include "MobileMessageThread.h"
|
||||
#include "MobileMessageThreadInternal.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "nsIDOMDOMRequest.h"
|
||||
#include "nsIDOMMozSmsMessage.h"
|
||||
#include "SmsMessage.h"
|
||||
#include "SmsMessageInternal.h"
|
||||
#include "nsIMobileMessageCallback.h"
|
||||
#include "nsServiceManagerUtils.h" // for do_GetService
|
||||
|
||||
|
@ -80,6 +85,36 @@ MobileMessageCursor::FireSuccessWithNextPendingResult()
|
|||
// be empty.
|
||||
MOZ_ASSERT(mPendingResults.Length());
|
||||
|
||||
nsCOMPtr<nsISupports> result;
|
||||
|
||||
nsCOMPtr<nsIMobileMessageThread> internalThread =
|
||||
do_QueryInterface(mPendingResults.LastElement());
|
||||
if (internalThread) {
|
||||
MobileMessageThreadInternal* thread =
|
||||
static_cast<MobileMessageThreadInternal*>(internalThread.get());
|
||||
result = new MobileMessageThread(GetOwner(), thread);
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
nsCOMPtr<nsISmsMessage> internalSms =
|
||||
do_QueryInterface(mPendingResults.LastElement());
|
||||
if (internalSms) {
|
||||
SmsMessageInternal* sms = static_cast<SmsMessageInternal*>(internalSms.get());
|
||||
result = new SmsMessage(GetOwner(), sms);
|
||||
}
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
nsCOMPtr<nsIMmsMessage> internalMms =
|
||||
do_QueryInterface(mPendingResults.LastElement());
|
||||
if (internalMms) {
|
||||
MmsMessageInternal* mms = static_cast<MmsMessageInternal*>(internalMms.get());
|
||||
result = new MmsMessage(GetOwner(), mms);
|
||||
}
|
||||
}
|
||||
|
||||
MOZ_ASSERT(result);
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
if (NS_WARN_IF(!jsapi.Init(GetOwner()))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -88,7 +123,7 @@ MobileMessageCursor::FireSuccessWithNextPendingResult()
|
|||
JSContext* cx = jsapi.cx();
|
||||
JS::Rooted<JS::Value> val(cx);
|
||||
nsresult rv =
|
||||
nsContentUtils::WrapNative(cx, mPendingResults.LastElement(), &val);
|
||||
nsContentUtils::WrapNative(cx, result, &val);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mPendingResults.RemoveElementAt(mPendingResults.Length() - 1);
|
||||
|
|
|
@ -9,8 +9,12 @@
|
|||
#include "DeletedMessageInfo.h"
|
||||
#include "DOMCursor.h"
|
||||
#include "DOMRequest.h"
|
||||
#include "MmsMessage.h"
|
||||
#include "MmsMessageInternal.h"
|
||||
#include "MobileMessageCallback.h"
|
||||
#include "MobileMessageCursorCallback.h"
|
||||
#include "SmsMessage.h"
|
||||
#include "SmsMessageInternal.h"
|
||||
#include "mozilla/dom/mobilemessage/Constants.h" // For kSms*ObserverTopic
|
||||
#include "mozilla/dom/MozMessageDeletedEvent.h"
|
||||
#include "mozilla/dom/MozMmsEvent.h"
|
||||
|
@ -20,8 +24,6 @@
|
|||
#include "mozilla/dom/ToJSValue.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "nsIDOMMozMmsMessage.h"
|
||||
#include "nsIDOMMozSmsMessage.h"
|
||||
#include "nsIMmsService.h"
|
||||
#include "nsIMobileMessageCallback.h"
|
||||
#include "nsIMobileMessageDatabaseService.h"
|
||||
|
@ -357,31 +359,21 @@ MobileMessageManager::Delete(int32_t aId,
|
|||
}
|
||||
|
||||
already_AddRefed<DOMRequest>
|
||||
MobileMessageManager::Delete(nsIDOMMozSmsMessage* aMessage,
|
||||
MobileMessageManager::Delete(SmsMessage& aMessage,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
int32_t id;
|
||||
|
||||
DebugOnly<nsresult> rv = aMessage->GetId(&id);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
return Delete(id, aRv);
|
||||
return Delete(aMessage.Id(), aRv);
|
||||
}
|
||||
|
||||
already_AddRefed<DOMRequest>
|
||||
MobileMessageManager::Delete(nsIDOMMozMmsMessage* aMessage,
|
||||
MobileMessageManager::Delete(MmsMessage& aMessage,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
int32_t id;
|
||||
|
||||
DebugOnly<nsresult> rv = aMessage->GetId(&id);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
return Delete(id, aRv);
|
||||
return Delete(aMessage.Id(), aRv);
|
||||
}
|
||||
|
||||
already_AddRefed<DOMRequest>
|
||||
MobileMessageManager::Delete(const Sequence<OwningLongOrMozSmsMessageOrMozMmsMessage>& aParams,
|
||||
MobileMessageManager::Delete(const Sequence<OwningLongOrSmsMessageOrMmsMessage>& aParams,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
const uint32_t size = aParams.Length();
|
||||
|
@ -393,17 +385,15 @@ MobileMessageManager::Delete(const Sequence<OwningLongOrMozSmsMessageOrMozMmsMes
|
|||
|
||||
DebugOnly<nsresult> rv;
|
||||
for (uint32_t i = 0; i < size; i++) {
|
||||
const OwningLongOrMozSmsMessageOrMozMmsMessage& element = aParams[i];
|
||||
const OwningLongOrSmsMessageOrMmsMessage& element = aParams[i];
|
||||
int32_t &id = idArray[i];
|
||||
|
||||
if (element.IsLong()) {
|
||||
id = element.GetAsLong();
|
||||
} else if (element.IsMozMmsMessage()) {
|
||||
rv = element.GetAsMozMmsMessage()->GetId(&id);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
} else /*if (element.IsMozSmsMessage())*/ {
|
||||
rv = element.GetAsMozSmsMessage()->GetId(&id);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
} else if (element.IsMmsMessage()) {
|
||||
id = element.GetAsMmsMessage()->Id();
|
||||
} else /*if (element.IsSmsMessage())*/ {
|
||||
id = element.GetAsSmsMessage()->Id();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -592,15 +582,10 @@ MobileMessageManager::RetrieveMMS(int32_t aId,
|
|||
}
|
||||
|
||||
already_AddRefed<DOMRequest>
|
||||
MobileMessageManager::RetrieveMMS(nsIDOMMozMmsMessage* aMessage,
|
||||
MobileMessageManager::RetrieveMMS(MmsMessage& aMessage,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
int32_t id;
|
||||
|
||||
DebugOnly<nsresult> rv = aMessage->GetId(&id);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
return RetrieveMMS(id, aRv);
|
||||
return RetrieveMMS(aMessage.Id(), aRv);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -608,24 +593,29 @@ MobileMessageManager::DispatchTrustedSmsEventToSelf(const char* aTopic,
|
|||
const nsAString& aEventName,
|
||||
nsISupports* aMsg)
|
||||
{
|
||||
nsCOMPtr<nsIDOMMozSmsMessage> sms = do_QueryInterface(aMsg);
|
||||
nsCOMPtr<nsPIDOMWindow> window = GetOwner();
|
||||
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsISmsMessage> sms = do_QueryInterface(aMsg);
|
||||
if (sms) {
|
||||
MozSmsEventInit init;
|
||||
init.mBubbles = false;
|
||||
init.mCancelable = false;
|
||||
init.mMessage = sms;
|
||||
init.mMessage =
|
||||
new SmsMessage(window, static_cast<SmsMessageInternal*>(sms.get()));
|
||||
|
||||
RefPtr<MozSmsEvent> event =
|
||||
MozSmsEvent::Constructor(this, aEventName, init);
|
||||
return DispatchTrustedEvent(event);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMMozMmsMessage> mms = do_QueryInterface(aMsg);
|
||||
nsCOMPtr<nsIMmsMessage> mms = do_QueryInterface(aMsg);
|
||||
if (mms) {
|
||||
MozMmsEventInit init;
|
||||
init.mBubbles = false;
|
||||
init.mCancelable = false;
|
||||
init.mMessage = mms;
|
||||
init.mMessage =
|
||||
new MmsMessage(window, static_cast<MmsMessageInternal*>(mms.get()));
|
||||
|
||||
RefPtr<MozMmsEvent> event =
|
||||
MozMmsEvent::Constructor(this, aEventName, init);
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
#include "nsIObserver.h"
|
||||
|
||||
class nsISmsService;
|
||||
class nsIDOMMozSmsMessage;
|
||||
class nsIDOMMozMmsMessage;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -21,10 +19,12 @@ namespace dom {
|
|||
class Promise;
|
||||
class DOMRequest;
|
||||
class DOMCursor;
|
||||
class MmsMessage;
|
||||
struct MmsParameters;
|
||||
struct MmsSendParameters;
|
||||
struct MobileMessageFilter;
|
||||
class OwningLongOrMozSmsMessageOrMozMmsMessage;
|
||||
class OwningLongOrSmsMessageOrMmsMessage;
|
||||
class SmsMessage;
|
||||
struct SmsSendParameters;
|
||||
struct SmscAddress;
|
||||
|
||||
|
@ -81,15 +81,15 @@ public:
|
|||
ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<DOMRequest>
|
||||
Delete(nsIDOMMozSmsMessage* aMessage,
|
||||
Delete(SmsMessage& aMessage,
|
||||
ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<DOMRequest>
|
||||
Delete(nsIDOMMozMmsMessage* aMessage,
|
||||
Delete(MmsMessage& aMessage,
|
||||
ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<DOMRequest>
|
||||
Delete(const Sequence<OwningLongOrMozSmsMessageOrMozMmsMessage>& aParams,
|
||||
Delete(const Sequence<OwningLongOrSmsMessageOrMmsMessage>& aParams,
|
||||
ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<DOMCursor>
|
||||
|
@ -111,7 +111,7 @@ public:
|
|||
ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<DOMRequest>
|
||||
RetrieveMMS(nsIDOMMozMmsMessage* aMessage,
|
||||
RetrieveMMS(MmsMessage& aMessage,
|
||||
ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<Promise>
|
||||
|
@ -159,14 +159,6 @@ private:
|
|||
|
||||
nsresult
|
||||
DispatchTrustedDeletedEventToSelf(nsISupports* aDeletedInfo);
|
||||
|
||||
/**
|
||||
* Helper to get message ID from SMS/MMS Message object
|
||||
*/
|
||||
nsresult
|
||||
GetMessageId(JSContext* aCx,
|
||||
const JS::Value& aMessage,
|
||||
int32_t* aId);
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* 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/. */
|
||||
|
||||
#include "SmsMessage.h"
|
||||
#include "MmsMessage.h"
|
||||
#include "MobileMessageThread.h"
|
||||
#include "SmsMessageInternal.h"
|
||||
#include "MmsMessageInternal.h"
|
||||
#include "MobileMessageThreadInternal.h"
|
||||
#include "MobileMessageService.h"
|
||||
#include "DeletedMessageInfo.h"
|
||||
|
||||
|
@ -31,23 +31,23 @@ MobileMessageService::CreateSmsMessage(int32_t aId,
|
|||
uint64_t aDeliveryTimestamp,
|
||||
bool aRead,
|
||||
JSContext* aCx,
|
||||
nsIDOMMozSmsMessage** aMessage)
|
||||
nsISmsMessage** aMessage)
|
||||
{
|
||||
return SmsMessage::Create(aId,
|
||||
aThreadId,
|
||||
aIccId,
|
||||
aDelivery,
|
||||
aDeliveryStatus,
|
||||
aSender,
|
||||
aReceiver,
|
||||
aBody,
|
||||
aMessageClass,
|
||||
aTimestamp,
|
||||
aSentTimestamp,
|
||||
aDeliveryTimestamp,
|
||||
aRead,
|
||||
aCx,
|
||||
aMessage);
|
||||
return SmsMessageInternal::Create(aId,
|
||||
aThreadId,
|
||||
aIccId,
|
||||
aDelivery,
|
||||
aDeliveryStatus,
|
||||
aSender,
|
||||
aReceiver,
|
||||
aBody,
|
||||
aMessageClass,
|
||||
aTimestamp,
|
||||
aSentTimestamp,
|
||||
aDeliveryTimestamp,
|
||||
aRead,
|
||||
aCx,
|
||||
aMessage);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -67,25 +67,25 @@ MobileMessageService::CreateMmsMessage(int32_t aId,
|
|||
uint64_t aExpiryDate,
|
||||
bool aReadReportRequested,
|
||||
JSContext* aCx,
|
||||
nsIDOMMozMmsMessage** aMessage)
|
||||
nsIMmsMessage** aMessage)
|
||||
{
|
||||
return MmsMessage::Create(aId,
|
||||
aThreadId,
|
||||
aIccId,
|
||||
aDelivery,
|
||||
aDeliveryInfo,
|
||||
aSender,
|
||||
aReceivers,
|
||||
aTimestamp,
|
||||
aSentTimestamp,
|
||||
aRead,
|
||||
aSubject,
|
||||
aSmil,
|
||||
aAttachments,
|
||||
aExpiryDate,
|
||||
aReadReportRequested,
|
||||
aCx,
|
||||
aMessage);
|
||||
return MmsMessageInternal::Create(aId,
|
||||
aThreadId,
|
||||
aIccId,
|
||||
aDelivery,
|
||||
aDeliveryInfo,
|
||||
aSender,
|
||||
aReceivers,
|
||||
aTimestamp,
|
||||
aSentTimestamp,
|
||||
aRead,
|
||||
aSubject,
|
||||
aSmil,
|
||||
aAttachments,
|
||||
aExpiryDate,
|
||||
aReadReportRequested,
|
||||
aCx,
|
||||
aMessage);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -97,17 +97,17 @@ MobileMessageService::CreateThread(uint64_t aId,
|
|||
uint64_t aUnreadCount,
|
||||
const nsAString& aLastMessageType,
|
||||
JSContext* aCx,
|
||||
nsIDOMMozMobileMessageThread** aThread)
|
||||
nsIMobileMessageThread** aThread)
|
||||
{
|
||||
return MobileMessageThread::Create(aId,
|
||||
aParticipants,
|
||||
aTimestamp,
|
||||
aLastMessageSubject,
|
||||
aBody,
|
||||
aUnreadCount,
|
||||
aLastMessageType,
|
||||
aCx,
|
||||
aThread);
|
||||
return MobileMessageThreadInternal::Create(aId,
|
||||
aParticipants,
|
||||
aTimestamp,
|
||||
aLastMessageSubject,
|
||||
aBody,
|
||||
aUnreadCount,
|
||||
aLastMessageType,
|
||||
aCx,
|
||||
aThread);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -1,190 +1,91 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* 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/. */
|
||||
* 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/. */
|
||||
|
||||
#include "MobileMessageThread.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
#include "jsapi.h" // For OBJECT_TO_JSVAL and JS_NewDateObjectMsec
|
||||
#include "nsJSUtils.h" // For nsAutoJSString
|
||||
#include "nsTArrayHelpers.h" // For nsTArrayToJSArray
|
||||
#include "mozilla/dom/mobilemessage/Constants.h" // For MessageType
|
||||
|
||||
#include "MobileMessageThreadInternal.h"
|
||||
#include "mozilla/dom/MobileMessageThreadBinding.h"
|
||||
|
||||
using namespace mozilla::dom::mobilemessage;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(MobileMessageThread)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMMozMobileMessageThread)
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(MobileMessageThread, mWindow, mThread)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(MobileMessageThread)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(MobileMessageThread)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MobileMessageThread)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozMobileMessageThread)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_ADDREF(MobileMessageThread)
|
||||
NS_IMPL_RELEASE(MobileMessageThread)
|
||||
|
||||
/* static */ nsresult
|
||||
MobileMessageThread::Create(uint64_t aId,
|
||||
const JS::Value& aParticipants,
|
||||
uint64_t aTimestamp,
|
||||
const nsAString& aLastMessageSubject,
|
||||
const nsAString& aBody,
|
||||
uint64_t aUnreadCount,
|
||||
const nsAString& aLastMessageType,
|
||||
JSContext* aCx,
|
||||
nsIDOMMozMobileMessageThread** aThread)
|
||||
MobileMessageThread::MobileMessageThread(nsPIDOMWindow* aWindow,
|
||||
MobileMessageThreadInternal* aThread)
|
||||
: mWindow(aWindow)
|
||||
, mThread(aThread)
|
||||
{
|
||||
*aThread = nullptr;
|
||||
|
||||
// ThreadData exposes these as references, so we can simply assign
|
||||
// to them.
|
||||
ThreadData data;
|
||||
data.id() = aId;
|
||||
data.lastMessageSubject().Assign(aLastMessageSubject);
|
||||
data.body().Assign(aBody);
|
||||
data.unreadCount() = aUnreadCount;
|
||||
|
||||
// Participants.
|
||||
{
|
||||
if (!aParticipants.isObject()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> obj(aCx, &aParticipants.toObject());
|
||||
bool isArray;
|
||||
if (!JS_IsArrayObject(aCx, obj, &isArray)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!isArray) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
uint32_t length;
|
||||
MOZ_ALWAYS_TRUE(JS_GetArrayLength(aCx, obj, &length));
|
||||
NS_ENSURE_TRUE(length, NS_ERROR_INVALID_ARG);
|
||||
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
JS::Rooted<JS::Value> val(aCx);
|
||||
|
||||
if (!JS_GetElement(aCx, obj, i, &val) || !val.isString()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
nsAutoJSString str;
|
||||
if (!str.init(aCx, val.toString())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
data.participants().AppendElement(str);
|
||||
}
|
||||
}
|
||||
|
||||
// Set |timestamp|;
|
||||
data.timestamp() = aTimestamp;
|
||||
|
||||
// Set |lastMessageType|.
|
||||
{
|
||||
MessageType lastMessageType;
|
||||
if (aLastMessageType.Equals(MESSAGE_TYPE_SMS)) {
|
||||
lastMessageType = eMessageType_SMS;
|
||||
} else if (aLastMessageType.Equals(MESSAGE_TYPE_MMS)) {
|
||||
lastMessageType = eMessageType_MMS;
|
||||
} else {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
data.lastMessageType() = lastMessageType;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMMozMobileMessageThread> thread = new MobileMessageThread(data);
|
||||
thread.forget(aThread);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
MobileMessageThread::MobileMessageThread(uint64_t aId,
|
||||
const nsTArray<nsString>& aParticipants,
|
||||
uint64_t aTimestamp,
|
||||
const nsString& aLastMessageSubject,
|
||||
const nsString& aBody,
|
||||
uint64_t aUnreadCount,
|
||||
MessageType aLastMessageType)
|
||||
: mData(aId, aParticipants, aTimestamp, aLastMessageSubject, aBody,
|
||||
aUnreadCount, aLastMessageType)
|
||||
MobileMessageThread::~MobileMessageThread()
|
||||
{
|
||||
MOZ_ASSERT(aParticipants.Length());
|
||||
}
|
||||
|
||||
MobileMessageThread::MobileMessageThread(const ThreadData& aData)
|
||||
: mData(aData)
|
||||
JSObject*
|
||||
MobileMessageThread::WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
MOZ_ASSERT(aData.participants().Length());
|
||||
return MobileMessageThreadBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileMessageThread::GetId(uint64_t* aId)
|
||||
uint64_t
|
||||
MobileMessageThread::Id() const
|
||||
{
|
||||
*aId = mData.id();
|
||||
return NS_OK;
|
||||
uint64_t id;
|
||||
mThread->GetId(&id);
|
||||
return id;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileMessageThread::GetLastMessageSubject(nsAString& aLastMessageSubject)
|
||||
void
|
||||
MobileMessageThread::GetLastMessageSubject(nsString& aRetVal) const
|
||||
{
|
||||
aLastMessageSubject = mData.lastMessageSubject();
|
||||
return NS_OK;
|
||||
mThread->GetLastMessageSubject(aRetVal);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileMessageThread::GetBody(nsAString& aBody)
|
||||
void
|
||||
MobileMessageThread::GetBody(nsString& aRetVal) const
|
||||
{
|
||||
aBody = mData.body();
|
||||
return NS_OK;
|
||||
mThread->GetBody(aRetVal);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileMessageThread::GetUnreadCount(uint64_t* aUnreadCount)
|
||||
uint64_t
|
||||
MobileMessageThread::UnreadCount() const
|
||||
{
|
||||
*aUnreadCount = mData.unreadCount();
|
||||
return NS_OK;
|
||||
uint64_t count;
|
||||
mThread->GetUnreadCount(&count);
|
||||
return count;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileMessageThread::GetParticipants(JSContext* aCx,
|
||||
JS::MutableHandle<JS::Value> aParticipants)
|
||||
void
|
||||
MobileMessageThread::GetParticipants(nsTArray<nsString>& aRetVal) const
|
||||
{
|
||||
JS::Rooted<JSObject*> obj(aCx);
|
||||
|
||||
nsresult rv = nsTArrayToJSArray(aCx, mData.participants(), &obj);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
aParticipants.setObject(*obj);
|
||||
return NS_OK;
|
||||
aRetVal = mThread->mData.participants();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileMessageThread::GetTimestamp(DOMTimeStamp* aDate)
|
||||
DOMTimeStamp
|
||||
MobileMessageThread::Timestamp() const
|
||||
{
|
||||
*aDate = mData.timestamp();
|
||||
return NS_OK;
|
||||
DOMTimeStamp timestamp;
|
||||
mThread->GetTimestamp(×tamp);
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileMessageThread::GetLastMessageType(nsAString& aLastMessageType)
|
||||
void
|
||||
MobileMessageThread::GetLastMessageType(nsString& aRetVal) const
|
||||
{
|
||||
switch (mData.lastMessageType()) {
|
||||
case eMessageType_SMS:
|
||||
aLastMessageType = MESSAGE_TYPE_SMS;
|
||||
break;
|
||||
case eMessageType_MMS:
|
||||
aLastMessageType = MESSAGE_TYPE_MMS;
|
||||
break;
|
||||
case eMessageType_EndGuard:
|
||||
default:
|
||||
MOZ_CRASH("We shouldn't get any other message type!");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
mThread->GetLastMessageType(aRetVal);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -1,61 +1,80 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* 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/. */
|
||||
* 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_mobilemessage_MobileMessageThread_h
|
||||
#define mozilla_dom_mobilemessage_MobileMessageThread_h
|
||||
#ifndef mozilla_dom_MobileMessageThread_h
|
||||
#define mozilla_dom_MobileMessageThread_h
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/mobilemessage/SmsTypes.h"
|
||||
#include "nsIDOMMozMobileMessageThread.h"
|
||||
#include "nsString.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
class nsPIDOMWindow;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class MobileMessageThread final : public nsIDOMMozMobileMessageThread
|
||||
namespace mobilemessage {
|
||||
class MobileMessageThreadInternal;
|
||||
} // namespace mobilemessage
|
||||
|
||||
/**
|
||||
* Each instance of this class provides the DOM-level representation of
|
||||
* a MobileMessageThread object to bind it to a window being exposed to.
|
||||
*/
|
||||
class MobileMessageThread final : public nsISupports,
|
||||
public nsWrapperCache
|
||||
{
|
||||
private:
|
||||
typedef mobilemessage::ThreadData ThreadData;
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOMMOZMOBILEMESSAGETHREAD
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MobileMessageThread)
|
||||
|
||||
MobileMessageThread(uint64_t aId,
|
||||
const nsTArray<nsString>& aParticipants,
|
||||
uint64_t aTimestamp,
|
||||
const nsString& aLastMessageSubject,
|
||||
const nsString& aBody,
|
||||
uint64_t aUnreadCount,
|
||||
mobilemessage::MessageType aLastMessageType);
|
||||
MobileMessageThread(nsPIDOMWindow* aWindow,
|
||||
mobilemessage::MobileMessageThreadInternal* aThread);
|
||||
|
||||
explicit MobileMessageThread(const ThreadData& aData);
|
||||
nsPIDOMWindow*
|
||||
GetParentObject() const
|
||||
{
|
||||
return mWindow;
|
||||
}
|
||||
|
||||
static nsresult Create(uint64_t aId,
|
||||
const JS::Value& aParticipants,
|
||||
uint64_t aTimestamp,
|
||||
const nsAString& aLastMessageSubject,
|
||||
const nsAString& aBody,
|
||||
uint64_t aUnreadCount,
|
||||
const nsAString& aLastMessageType,
|
||||
JSContext* aCx,
|
||||
nsIDOMMozMobileMessageThread** aThread);
|
||||
virtual JSObject*
|
||||
WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
const ThreadData& GetData() const { return mData; }
|
||||
uint64_t
|
||||
Id() const;
|
||||
|
||||
void
|
||||
GetLastMessageSubject(nsString& aRetVal) const;
|
||||
|
||||
void
|
||||
GetBody(nsString& aRetVal) const;
|
||||
|
||||
uint64_t
|
||||
UnreadCount() const;
|
||||
|
||||
void
|
||||
GetParticipants(nsTArray<nsString>& aRetVal) const;
|
||||
|
||||
DOMTimeStamp
|
||||
Timestamp() const;
|
||||
|
||||
void
|
||||
GetLastMessageType(nsString& aRetVal) const;
|
||||
|
||||
private:
|
||||
~MobileMessageThread() {}
|
||||
|
||||
// Don't try to use the default constructor.
|
||||
MobileMessageThread() = delete;
|
||||
|
||||
ThreadData mData;
|
||||
~MobileMessageThread();
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> mWindow;
|
||||
RefPtr<mobilemessage::MobileMessageThreadInternal> mThread;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_mobilemessage_MobileMessageThread_h
|
||||
#endif // mozilla_dom_MobileMessageThread_h
|
||||
|
|
|
@ -0,0 +1,185 @@
|
|||
/* -*- 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/. */
|
||||
|
||||
#include "MobileMessageThreadInternal.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
#include "jsapi.h" // For OBJECT_TO_JSVAL and JS_NewDateObjectMsec
|
||||
#include "nsJSUtils.h" // For nsAutoJSString
|
||||
#include "nsTArrayHelpers.h" // For nsTArrayToJSArray
|
||||
#include "mozilla/dom/mobilemessage/Constants.h" // For MessageType
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mobilemessage {
|
||||
|
||||
NS_IMPL_ISUPPORTS(MobileMessageThreadInternal, nsIMobileMessageThread)
|
||||
|
||||
/* static */ nsresult
|
||||
MobileMessageThreadInternal::Create(uint64_t aId,
|
||||
const JS::Value& aParticipants,
|
||||
uint64_t aTimestamp,
|
||||
const nsAString& aLastMessageSubject,
|
||||
const nsAString& aBody,
|
||||
uint64_t aUnreadCount,
|
||||
const nsAString& aLastMessageType,
|
||||
JSContext* aCx,
|
||||
nsIMobileMessageThread** aThread)
|
||||
{
|
||||
*aThread = nullptr;
|
||||
|
||||
// ThreadData exposes these as references, so we can simply assign
|
||||
// to them.
|
||||
ThreadData data;
|
||||
data.id() = aId;
|
||||
data.lastMessageSubject().Assign(aLastMessageSubject);
|
||||
data.body().Assign(aBody);
|
||||
data.unreadCount() = aUnreadCount;
|
||||
|
||||
// Participants.
|
||||
{
|
||||
if (!aParticipants.isObject()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> obj(aCx, &aParticipants.toObject());
|
||||
bool isArray;
|
||||
if (!JS_IsArrayObject(aCx, obj, &isArray)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!isArray) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
uint32_t length;
|
||||
MOZ_ALWAYS_TRUE(JS_GetArrayLength(aCx, obj, &length));
|
||||
NS_ENSURE_TRUE(length, NS_ERROR_INVALID_ARG);
|
||||
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
JS::Rooted<JS::Value> val(aCx);
|
||||
|
||||
if (!JS_GetElement(aCx, obj, i, &val) || !val.isString()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
nsAutoJSString str;
|
||||
if (!str.init(aCx, val.toString())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
data.participants().AppendElement(str);
|
||||
}
|
||||
}
|
||||
|
||||
// Set |timestamp|;
|
||||
data.timestamp() = aTimestamp;
|
||||
|
||||
// Set |lastMessageType|.
|
||||
{
|
||||
MessageType lastMessageType;
|
||||
if (aLastMessageType.Equals(MESSAGE_TYPE_SMS)) {
|
||||
lastMessageType = eMessageType_SMS;
|
||||
} else if (aLastMessageType.Equals(MESSAGE_TYPE_MMS)) {
|
||||
lastMessageType = eMessageType_MMS;
|
||||
} else {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
data.lastMessageType() = lastMessageType;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIMobileMessageThread> thread =
|
||||
new MobileMessageThreadInternal(data);
|
||||
thread.forget(aThread);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
MobileMessageThreadInternal::MobileMessageThreadInternal(uint64_t aId,
|
||||
const nsTArray<nsString>& aParticipants,
|
||||
uint64_t aTimestamp,
|
||||
const nsString& aLastMessageSubject,
|
||||
const nsString& aBody,
|
||||
uint64_t aUnreadCount,
|
||||
MessageType aLastMessageType)
|
||||
: mData(aId, aParticipants, aTimestamp, aLastMessageSubject, aBody,
|
||||
aUnreadCount, aLastMessageType)
|
||||
{
|
||||
MOZ_ASSERT(aParticipants.Length());
|
||||
}
|
||||
|
||||
MobileMessageThreadInternal::MobileMessageThreadInternal(const ThreadData& aData)
|
||||
: mData(aData)
|
||||
{
|
||||
MOZ_ASSERT(aData.participants().Length());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileMessageThreadInternal::GetId(uint64_t* aId)
|
||||
{
|
||||
*aId = mData.id();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileMessageThreadInternal::GetLastMessageSubject(nsAString& aLastMessageSubject)
|
||||
{
|
||||
aLastMessageSubject = mData.lastMessageSubject();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileMessageThreadInternal::GetBody(nsAString& aBody)
|
||||
{
|
||||
aBody = mData.body();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileMessageThreadInternal::GetUnreadCount(uint64_t* aUnreadCount)
|
||||
{
|
||||
*aUnreadCount = mData.unreadCount();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileMessageThreadInternal::GetParticipants(JSContext* aCx,
|
||||
JS::MutableHandle<JS::Value> aParticipants)
|
||||
{
|
||||
JS::Rooted<JSObject*> obj(aCx);
|
||||
|
||||
nsresult rv = nsTArrayToJSArray(aCx, mData.participants(), &obj);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
aParticipants.setObject(*obj);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileMessageThreadInternal::GetTimestamp(DOMTimeStamp* aDate)
|
||||
{
|
||||
*aDate = mData.timestamp();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileMessageThreadInternal::GetLastMessageType(nsAString& aLastMessageType)
|
||||
{
|
||||
switch (mData.lastMessageType()) {
|
||||
case eMessageType_SMS:
|
||||
aLastMessageType = MESSAGE_TYPE_SMS;
|
||||
break;
|
||||
case eMessageType_MMS:
|
||||
aLastMessageType = MESSAGE_TYPE_MMS;
|
||||
break;
|
||||
case eMessageType_EndGuard:
|
||||
default:
|
||||
MOZ_CRASH("We shouldn't get any other message type!");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace mobilemessage
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,69 @@
|
|||
/* -*- 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_mobilemessage_MobileMessageThreadInternal_h
|
||||
#define mozilla_dom_mobilemessage_MobileMessageThreadInternal_h
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/mobilemessage/SmsTypes.h"
|
||||
#include "nsIMobileMessageThread.h"
|
||||
#include "nsString.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class MobileMessageThread;
|
||||
|
||||
namespace mobilemessage {
|
||||
|
||||
class ThreadData;
|
||||
|
||||
class MobileMessageThreadInternal final : public nsIMobileMessageThread
|
||||
{
|
||||
// This allows the MobileMessageThread class to access data members, i.e. participants
|
||||
// without JS API.
|
||||
friend class mozilla::dom::MobileMessageThread;
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMOBILEMESSAGETHREAD
|
||||
|
||||
MobileMessageThreadInternal(uint64_t aId,
|
||||
const nsTArray<nsString>& aParticipants,
|
||||
uint64_t aTimestamp,
|
||||
const nsString& aLastMessageSubject,
|
||||
const nsString& aBody,
|
||||
uint64_t aUnreadCount,
|
||||
mobilemessage::MessageType aLastMessageType);
|
||||
|
||||
explicit MobileMessageThreadInternal(const ThreadData& aData);
|
||||
|
||||
static nsresult Create(uint64_t aId,
|
||||
const JS::Value& aParticipants,
|
||||
uint64_t aTimestamp,
|
||||
const nsAString& aLastMessageSubject,
|
||||
const nsAString& aBody,
|
||||
uint64_t aUnreadCount,
|
||||
const nsAString& aLastMessageType,
|
||||
JSContext* aCx,
|
||||
nsIMobileMessageThread** aThread);
|
||||
|
||||
const ThreadData& GetData() const { return mData; }
|
||||
|
||||
private:
|
||||
~MobileMessageThreadInternal() {}
|
||||
|
||||
// Don't try to use the default constructor.
|
||||
MobileMessageThreadInternal() = delete;
|
||||
|
||||
ThreadData mData;
|
||||
};
|
||||
|
||||
} // namespace mobilemessage
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_mobilemessage_MobileMessageThreadInternal_h
|
|
@ -1,289 +1,135 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* 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/. */
|
||||
* 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/. */
|
||||
|
||||
#include "SmsMessage.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
#include "mozilla/dom/mobilemessage/Constants.h" // For MessageType
|
||||
|
||||
using namespace mozilla::dom::mobilemessage;
|
||||
#include "SmsMessageInternal.h"
|
||||
#include "mozilla/dom/SmsMessageBinding.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(SmsMessage)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMMozSmsMessage)
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(SmsMessage, mWindow, mMessage)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(SmsMessage)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(SmsMessage)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SmsMessage)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozSmsMessage)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_ADDREF(SmsMessage)
|
||||
NS_IMPL_RELEASE(SmsMessage)
|
||||
|
||||
SmsMessage::SmsMessage(int32_t aId,
|
||||
uint64_t aThreadId,
|
||||
const nsString& aIccId,
|
||||
DeliveryState aDelivery,
|
||||
DeliveryStatus aDeliveryStatus,
|
||||
const nsString& aSender,
|
||||
const nsString& aReceiver,
|
||||
const nsString& aBody,
|
||||
MessageClass aMessageClass,
|
||||
uint64_t aTimestamp,
|
||||
uint64_t aSentTimestamp,
|
||||
uint64_t aDeliveryTimestamp,
|
||||
bool aRead)
|
||||
: mData(aId, aThreadId, aIccId, aDelivery, aDeliveryStatus,
|
||||
aSender, aReceiver, aBody, aMessageClass, aTimestamp, aSentTimestamp,
|
||||
aDeliveryTimestamp, aRead)
|
||||
SmsMessage::SmsMessage(nsPIDOMWindow* aWindow, SmsMessageInternal* aMessage)
|
||||
: mWindow(aWindow)
|
||||
, mMessage(aMessage)
|
||||
{
|
||||
}
|
||||
|
||||
SmsMessage::SmsMessage(const SmsMessageData& aData)
|
||||
: mData(aData)
|
||||
SmsMessage::~SmsMessage()
|
||||
{
|
||||
}
|
||||
|
||||
/* static */ nsresult
|
||||
SmsMessage::Create(int32_t aId,
|
||||
uint64_t aThreadId,
|
||||
const nsAString& aIccId,
|
||||
const nsAString& aDelivery,
|
||||
const nsAString& aDeliveryStatus,
|
||||
const nsAString& aSender,
|
||||
const nsAString& aReceiver,
|
||||
const nsAString& aBody,
|
||||
const nsAString& aMessageClass,
|
||||
uint64_t aTimestamp,
|
||||
uint64_t aSentTimestamp,
|
||||
uint64_t aDeliveryTimestamp,
|
||||
bool aRead,
|
||||
JSContext* aCx,
|
||||
nsIDOMMozSmsMessage** aMessage)
|
||||
JSObject*
|
||||
SmsMessage::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
*aMessage = nullptr;
|
||||
|
||||
// SmsMessageData exposes these as references, so we can simply assign
|
||||
// to them.
|
||||
SmsMessageData data;
|
||||
data.id() = aId;
|
||||
data.threadId() = aThreadId;
|
||||
data.iccId() = nsString(aIccId);
|
||||
data.sender() = nsString(aSender);
|
||||
data.receiver() = nsString(aReceiver);
|
||||
data.body() = nsString(aBody);
|
||||
data.read() = aRead;
|
||||
|
||||
if (aDelivery.Equals(DELIVERY_RECEIVED)) {
|
||||
data.delivery() = eDeliveryState_Received;
|
||||
} else if (aDelivery.Equals(DELIVERY_SENDING)) {
|
||||
data.delivery() = eDeliveryState_Sending;
|
||||
} else if (aDelivery.Equals(DELIVERY_SENT)) {
|
||||
data.delivery() = eDeliveryState_Sent;
|
||||
} else if (aDelivery.Equals(DELIVERY_ERROR)) {
|
||||
data.delivery() = eDeliveryState_Error;
|
||||
} else {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (aDeliveryStatus.Equals(DELIVERY_STATUS_NOT_APPLICABLE)) {
|
||||
data.deliveryStatus() = eDeliveryStatus_NotApplicable;
|
||||
} else if (aDeliveryStatus.Equals(DELIVERY_STATUS_SUCCESS)) {
|
||||
data.deliveryStatus() = eDeliveryStatus_Success;
|
||||
} else if (aDeliveryStatus.Equals(DELIVERY_STATUS_PENDING)) {
|
||||
data.deliveryStatus() = eDeliveryStatus_Pending;
|
||||
} else if (aDeliveryStatus.Equals(DELIVERY_STATUS_ERROR)) {
|
||||
data.deliveryStatus() = eDeliveryStatus_Error;
|
||||
} else {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (aMessageClass.Equals(MESSAGE_CLASS_NORMAL)) {
|
||||
data.messageClass() = eMessageClass_Normal;
|
||||
} else if (aMessageClass.Equals(MESSAGE_CLASS_CLASS_0)) {
|
||||
data.messageClass() = eMessageClass_Class0;
|
||||
} else if (aMessageClass.Equals(MESSAGE_CLASS_CLASS_1)) {
|
||||
data.messageClass() = eMessageClass_Class1;
|
||||
} else if (aMessageClass.Equals(MESSAGE_CLASS_CLASS_2)) {
|
||||
data.messageClass() = eMessageClass_Class2;
|
||||
} else if (aMessageClass.Equals(MESSAGE_CLASS_CLASS_3)) {
|
||||
data.messageClass() = eMessageClass_Class3;
|
||||
} else {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
// Set |timestamp|.
|
||||
data.timestamp() = aTimestamp;
|
||||
|
||||
// Set |sentTimestamp|.
|
||||
data.sentTimestamp() = aSentTimestamp;
|
||||
|
||||
// Set |deliveryTimestamp|.
|
||||
data.deliveryTimestamp() = aDeliveryTimestamp;
|
||||
|
||||
nsCOMPtr<nsIDOMMozSmsMessage> message = new SmsMessage(data);
|
||||
message.swap(*aMessage);
|
||||
return NS_OK;
|
||||
return SmsMessageBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
const SmsMessageData&
|
||||
SmsMessage::GetData() const
|
||||
void
|
||||
SmsMessage::GetType(nsString& aRetVal) const
|
||||
{
|
||||
return mData;
|
||||
mMessage->GetType(aRetVal);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessage::GetType(nsAString& aType)
|
||||
int32_t
|
||||
SmsMessage::Id() const
|
||||
{
|
||||
aType = NS_LITERAL_STRING("sms");
|
||||
return NS_OK;
|
||||
int32_t id;
|
||||
mMessage->GetId(&id);
|
||||
return id;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessage::GetId(int32_t* aId)
|
||||
uint64_t
|
||||
SmsMessage::ThreadId() const
|
||||
{
|
||||
*aId = mData.id();
|
||||
return NS_OK;
|
||||
uint64_t id;
|
||||
mMessage->GetThreadId(&id);
|
||||
return id;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessage::GetThreadId(uint64_t* aThreadId)
|
||||
void
|
||||
SmsMessage::GetIccId(nsString& aRetVal) const
|
||||
{
|
||||
*aThreadId = mData.threadId();
|
||||
return NS_OK;
|
||||
mMessage->GetIccId(aRetVal);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessage::GetIccId(nsAString& aIccId)
|
||||
void
|
||||
SmsMessage::GetDelivery(nsString& aRetVal) const
|
||||
{
|
||||
aIccId = mData.iccId();
|
||||
return NS_OK;
|
||||
mMessage->GetDelivery(aRetVal);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessage::GetDelivery(nsAString& aDelivery)
|
||||
void
|
||||
SmsMessage::GetDeliveryStatus(nsString& aRetVal) const
|
||||
{
|
||||
switch (mData.delivery()) {
|
||||
case eDeliveryState_Received:
|
||||
aDelivery = DELIVERY_RECEIVED;
|
||||
break;
|
||||
case eDeliveryState_Sending:
|
||||
aDelivery = DELIVERY_SENDING;
|
||||
break;
|
||||
case eDeliveryState_Sent:
|
||||
aDelivery = DELIVERY_SENT;
|
||||
break;
|
||||
case eDeliveryState_Error:
|
||||
aDelivery = DELIVERY_ERROR;
|
||||
break;
|
||||
case eDeliveryState_Unknown:
|
||||
case eDeliveryState_EndGuard:
|
||||
default:
|
||||
MOZ_CRASH("We shouldn't get any other delivery state!");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
mMessage->GetDeliveryStatus(aRetVal);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessage::GetDeliveryStatus(nsAString& aDeliveryStatus)
|
||||
void
|
||||
SmsMessage::GetSender(nsString& aRetVal) const
|
||||
{
|
||||
switch (mData.deliveryStatus()) {
|
||||
case eDeliveryStatus_NotApplicable:
|
||||
aDeliveryStatus = DELIVERY_STATUS_NOT_APPLICABLE;
|
||||
break;
|
||||
case eDeliveryStatus_Success:
|
||||
aDeliveryStatus = DELIVERY_STATUS_SUCCESS;
|
||||
break;
|
||||
case eDeliveryStatus_Pending:
|
||||
aDeliveryStatus = DELIVERY_STATUS_PENDING;
|
||||
break;
|
||||
case eDeliveryStatus_Error:
|
||||
aDeliveryStatus = DELIVERY_STATUS_ERROR;
|
||||
break;
|
||||
case eDeliveryStatus_EndGuard:
|
||||
default:
|
||||
MOZ_CRASH("We shouldn't get any other delivery status!");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
mMessage->GetSender(aRetVal);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessage::GetSender(nsAString& aSender)
|
||||
void
|
||||
SmsMessage::GetReceiver(nsString& aRetVal) const
|
||||
{
|
||||
aSender = mData.sender();
|
||||
return NS_OK;
|
||||
mMessage->GetReceiver(aRetVal);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessage::GetReceiver(nsAString& aReceiver)
|
||||
void
|
||||
SmsMessage::GetBody(nsString& aRetVal) const
|
||||
{
|
||||
aReceiver = mData.receiver();
|
||||
return NS_OK;
|
||||
mMessage->GetBody(aRetVal);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessage::GetBody(nsAString& aBody)
|
||||
void
|
||||
SmsMessage::GetMessageClass(nsString& aRetVal) const
|
||||
{
|
||||
aBody = mData.body();
|
||||
return NS_OK;
|
||||
mMessage->GetMessageClass(aRetVal);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessage::GetMessageClass(nsAString& aMessageClass)
|
||||
uint64_t
|
||||
SmsMessage::Timestamp() const
|
||||
{
|
||||
switch (mData.messageClass()) {
|
||||
case eMessageClass_Normal:
|
||||
aMessageClass = MESSAGE_CLASS_NORMAL;
|
||||
break;
|
||||
case eMessageClass_Class0:
|
||||
aMessageClass = MESSAGE_CLASS_CLASS_0;
|
||||
break;
|
||||
case eMessageClass_Class1:
|
||||
aMessageClass = MESSAGE_CLASS_CLASS_1;
|
||||
break;
|
||||
case eMessageClass_Class2:
|
||||
aMessageClass = MESSAGE_CLASS_CLASS_2;
|
||||
break;
|
||||
case eMessageClass_Class3:
|
||||
aMessageClass = MESSAGE_CLASS_CLASS_3;
|
||||
break;
|
||||
default:
|
||||
MOZ_CRASH("We shouldn't get any other message class!");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
uint64_t timestamp;
|
||||
mMessage->GetTimestamp(×tamp);
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessage::GetTimestamp(DOMTimeStamp* aTimestamp)
|
||||
uint64_t
|
||||
SmsMessage::SentTimestamp() const
|
||||
{
|
||||
*aTimestamp = mData.timestamp();
|
||||
return NS_OK;
|
||||
uint64_t timestamp;
|
||||
mMessage->GetSentTimestamp(×tamp);
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessage::GetSentTimestamp(DOMTimeStamp* aSentTimestamp)
|
||||
uint64_t
|
||||
SmsMessage::DeliveryTimestamp() const
|
||||
{
|
||||
*aSentTimestamp = mData.sentTimestamp();
|
||||
return NS_OK;
|
||||
uint64_t timestamp;
|
||||
mMessage->GetDeliveryTimestamp(×tamp);
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessage::GetDeliveryTimestamp(DOMTimeStamp* aDate)
|
||||
bool
|
||||
SmsMessage::Read() const
|
||||
{
|
||||
*aDate = mData.deliveryTimestamp();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessage::GetRead(bool* aRead)
|
||||
{
|
||||
*aRead = mData.read();
|
||||
return NS_OK;
|
||||
bool read;
|
||||
mMessage->GetRead(&read);
|
||||
return read;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -1,70 +1,102 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* 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/. */
|
||||
* 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_mobilemessage_SmsMessage_h
|
||||
#define mozilla_dom_mobilemessage_SmsMessage_h
|
||||
#ifndef mozilla_dom_SmsMessage_h
|
||||
#define mozilla_dom_SmsMessage_h
|
||||
|
||||
#include "mozilla/dom/mobilemessage/SmsTypes.h"
|
||||
#include "nsIDOMMozSmsMessage.h"
|
||||
#include "nsString.h"
|
||||
#include "mozilla/dom/mobilemessage/Types.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
class nsPIDOMWindow;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class SmsMessage final : public nsIDOMMozSmsMessage
|
||||
namespace mobilemessage {
|
||||
class SmsMessageInternal;
|
||||
} // namespace mobilemessage
|
||||
|
||||
/**
|
||||
* Each instance of this class provides the DOM-level representation of
|
||||
* a SmsMessage object to bind it to a window being exposed to.
|
||||
*/
|
||||
class SmsMessage final : public nsISupports,
|
||||
public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOMMOZSMSMESSAGE
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(SmsMessage)
|
||||
|
||||
SmsMessage(int32_t aId,
|
||||
uint64_t aThreadId,
|
||||
const nsString& aIccId,
|
||||
mobilemessage::DeliveryState aDelivery,
|
||||
mobilemessage::DeliveryStatus aDeliveryStatus,
|
||||
const nsString& aSender,
|
||||
const nsString& aReceiver,
|
||||
const nsString& aBody,
|
||||
mobilemessage::MessageClass aMessageClass,
|
||||
uint64_t aTimestamp,
|
||||
uint64_t aSentTimestamp,
|
||||
uint64_t aDeliveryTimestamp,
|
||||
bool aRead);
|
||||
SmsMessage(nsPIDOMWindow* aWindow,
|
||||
mobilemessage::SmsMessageInternal* aMessage);
|
||||
|
||||
explicit SmsMessage(const mobilemessage::SmsMessageData& aData);
|
||||
public:
|
||||
nsPIDOMWindow*
|
||||
GetParentObject() const
|
||||
{
|
||||
return mWindow;
|
||||
}
|
||||
|
||||
static nsresult Create(int32_t aId,
|
||||
uint64_t aThreadId,
|
||||
const nsAString& aIccId,
|
||||
const nsAString& aDelivery,
|
||||
const nsAString& aDeliveryStatus,
|
||||
const nsAString& aSender,
|
||||
const nsAString& aReceiver,
|
||||
const nsAString& aBody,
|
||||
const nsAString& aMessageClass,
|
||||
uint64_t aTimestamp,
|
||||
uint64_t aSentTimestamp,
|
||||
uint64_t aDeliveryTimestamp,
|
||||
bool aRead,
|
||||
JSContext* aCx,
|
||||
nsIDOMMozSmsMessage** aMessage);
|
||||
const mobilemessage::SmsMessageData& GetData() const;
|
||||
virtual JSObject*
|
||||
WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
void
|
||||
GetType(nsString& aRetVal) const;
|
||||
|
||||
int32_t
|
||||
Id() const;
|
||||
|
||||
uint64_t
|
||||
ThreadId() const;
|
||||
|
||||
void
|
||||
GetIccId(nsString& aRetVal) const;
|
||||
|
||||
void
|
||||
GetDelivery(nsString& aRetVal) const;
|
||||
|
||||
void
|
||||
GetDeliveryStatus(nsString& aRetVal) const;
|
||||
|
||||
void
|
||||
GetSender(nsString& aRetVal) const;
|
||||
|
||||
void
|
||||
GetReceiver(nsString& aRetVal) const;
|
||||
|
||||
void
|
||||
GetBody(nsString& aRetVal) const;
|
||||
|
||||
void
|
||||
GetMessageClass(nsString& aRetVal) const;
|
||||
|
||||
uint64_t
|
||||
Timestamp() const;
|
||||
|
||||
uint64_t
|
||||
SentTimestamp() const;
|
||||
|
||||
uint64_t
|
||||
DeliveryTimestamp() const;
|
||||
|
||||
bool
|
||||
Read() const;
|
||||
|
||||
private:
|
||||
~SmsMessage() {}
|
||||
|
||||
// Don't try to use the default constructor.
|
||||
SmsMessage();
|
||||
SmsMessage() = delete;
|
||||
|
||||
mobilemessage::SmsMessageData mData;
|
||||
~SmsMessage();
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> mWindow;
|
||||
RefPtr<mobilemessage::SmsMessageInternal> mMessage;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_mobilemessage_SmsMessage_h
|
||||
#endif // mozilla_dom_SmsMessage_h
|
||||
|
|
|
@ -0,0 +1,283 @@
|
|||
/* -*- 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/. */
|
||||
|
||||
#include "SmsMessageInternal.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
#include "mozilla/dom/mobilemessage/Constants.h" // For MessageType
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mobilemessage {
|
||||
|
||||
NS_IMPL_ISUPPORTS(SmsMessageInternal, nsISmsMessage)
|
||||
|
||||
SmsMessageInternal::SmsMessageInternal(int32_t aId,
|
||||
uint64_t aThreadId,
|
||||
const nsString& aIccId,
|
||||
DeliveryState aDelivery,
|
||||
DeliveryStatus aDeliveryStatus,
|
||||
const nsString& aSender,
|
||||
const nsString& aReceiver,
|
||||
const nsString& aBody,
|
||||
MessageClass aMessageClass,
|
||||
uint64_t aTimestamp,
|
||||
uint64_t aSentTimestamp,
|
||||
uint64_t aDeliveryTimestamp,
|
||||
bool aRead)
|
||||
: mData(aId, aThreadId, aIccId, aDelivery, aDeliveryStatus,
|
||||
aSender, aReceiver, aBody, aMessageClass, aTimestamp, aSentTimestamp,
|
||||
aDeliveryTimestamp, aRead)
|
||||
{
|
||||
}
|
||||
|
||||
SmsMessageInternal::SmsMessageInternal(const SmsMessageData& aData)
|
||||
: mData(aData)
|
||||
{
|
||||
}
|
||||
|
||||
/* static */ nsresult
|
||||
SmsMessageInternal::Create(int32_t aId,
|
||||
uint64_t aThreadId,
|
||||
const nsAString& aIccId,
|
||||
const nsAString& aDelivery,
|
||||
const nsAString& aDeliveryStatus,
|
||||
const nsAString& aSender,
|
||||
const nsAString& aReceiver,
|
||||
const nsAString& aBody,
|
||||
const nsAString& aMessageClass,
|
||||
uint64_t aTimestamp,
|
||||
uint64_t aSentTimestamp,
|
||||
uint64_t aDeliveryTimestamp,
|
||||
bool aRead,
|
||||
JSContext* aCx,
|
||||
nsISmsMessage** aMessage)
|
||||
{
|
||||
*aMessage = nullptr;
|
||||
|
||||
// SmsMessageData exposes these as references, so we can simply assign
|
||||
// to them.
|
||||
SmsMessageData data;
|
||||
data.id() = aId;
|
||||
data.threadId() = aThreadId;
|
||||
data.iccId() = nsString(aIccId);
|
||||
data.sender() = nsString(aSender);
|
||||
data.receiver() = nsString(aReceiver);
|
||||
data.body() = nsString(aBody);
|
||||
data.read() = aRead;
|
||||
|
||||
if (aDelivery.Equals(DELIVERY_RECEIVED)) {
|
||||
data.delivery() = eDeliveryState_Received;
|
||||
} else if (aDelivery.Equals(DELIVERY_SENDING)) {
|
||||
data.delivery() = eDeliveryState_Sending;
|
||||
} else if (aDelivery.Equals(DELIVERY_SENT)) {
|
||||
data.delivery() = eDeliveryState_Sent;
|
||||
} else if (aDelivery.Equals(DELIVERY_ERROR)) {
|
||||
data.delivery() = eDeliveryState_Error;
|
||||
} else {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (aDeliveryStatus.Equals(DELIVERY_STATUS_NOT_APPLICABLE)) {
|
||||
data.deliveryStatus() = eDeliveryStatus_NotApplicable;
|
||||
} else if (aDeliveryStatus.Equals(DELIVERY_STATUS_SUCCESS)) {
|
||||
data.deliveryStatus() = eDeliveryStatus_Success;
|
||||
} else if (aDeliveryStatus.Equals(DELIVERY_STATUS_PENDING)) {
|
||||
data.deliveryStatus() = eDeliveryStatus_Pending;
|
||||
} else if (aDeliveryStatus.Equals(DELIVERY_STATUS_ERROR)) {
|
||||
data.deliveryStatus() = eDeliveryStatus_Error;
|
||||
} else {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (aMessageClass.Equals(MESSAGE_CLASS_NORMAL)) {
|
||||
data.messageClass() = eMessageClass_Normal;
|
||||
} else if (aMessageClass.Equals(MESSAGE_CLASS_CLASS_0)) {
|
||||
data.messageClass() = eMessageClass_Class0;
|
||||
} else if (aMessageClass.Equals(MESSAGE_CLASS_CLASS_1)) {
|
||||
data.messageClass() = eMessageClass_Class1;
|
||||
} else if (aMessageClass.Equals(MESSAGE_CLASS_CLASS_2)) {
|
||||
data.messageClass() = eMessageClass_Class2;
|
||||
} else if (aMessageClass.Equals(MESSAGE_CLASS_CLASS_3)) {
|
||||
data.messageClass() = eMessageClass_Class3;
|
||||
} else {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
// Set |timestamp|.
|
||||
data.timestamp() = aTimestamp;
|
||||
|
||||
// Set |sentTimestamp|.
|
||||
data.sentTimestamp() = aSentTimestamp;
|
||||
|
||||
// Set |deliveryTimestamp|.
|
||||
data.deliveryTimestamp() = aDeliveryTimestamp;
|
||||
|
||||
nsCOMPtr<nsISmsMessage> message = new SmsMessageInternal(data);
|
||||
message.swap(*aMessage);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
const SmsMessageData&
|
||||
SmsMessageInternal::GetData() const
|
||||
{
|
||||
return mData;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessageInternal::GetType(nsAString& aType)
|
||||
{
|
||||
aType = NS_LITERAL_STRING("sms");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessageInternal::GetId(int32_t* aId)
|
||||
{
|
||||
*aId = mData.id();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessageInternal::GetThreadId(uint64_t* aThreadId)
|
||||
{
|
||||
*aThreadId = mData.threadId();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessageInternal::GetIccId(nsAString& aIccId)
|
||||
{
|
||||
aIccId = mData.iccId();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessageInternal::GetDelivery(nsAString& aDelivery)
|
||||
{
|
||||
switch (mData.delivery()) {
|
||||
case eDeliveryState_Received:
|
||||
aDelivery = DELIVERY_RECEIVED;
|
||||
break;
|
||||
case eDeliveryState_Sending:
|
||||
aDelivery = DELIVERY_SENDING;
|
||||
break;
|
||||
case eDeliveryState_Sent:
|
||||
aDelivery = DELIVERY_SENT;
|
||||
break;
|
||||
case eDeliveryState_Error:
|
||||
aDelivery = DELIVERY_ERROR;
|
||||
break;
|
||||
case eDeliveryState_Unknown:
|
||||
case eDeliveryState_EndGuard:
|
||||
default:
|
||||
MOZ_CRASH("We shouldn't get any other delivery state!");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessageInternal::GetDeliveryStatus(nsAString& aDeliveryStatus)
|
||||
{
|
||||
switch (mData.deliveryStatus()) {
|
||||
case eDeliveryStatus_NotApplicable:
|
||||
aDeliveryStatus = DELIVERY_STATUS_NOT_APPLICABLE;
|
||||
break;
|
||||
case eDeliveryStatus_Success:
|
||||
aDeliveryStatus = DELIVERY_STATUS_SUCCESS;
|
||||
break;
|
||||
case eDeliveryStatus_Pending:
|
||||
aDeliveryStatus = DELIVERY_STATUS_PENDING;
|
||||
break;
|
||||
case eDeliveryStatus_Error:
|
||||
aDeliveryStatus = DELIVERY_STATUS_ERROR;
|
||||
break;
|
||||
case eDeliveryStatus_EndGuard:
|
||||
default:
|
||||
MOZ_CRASH("We shouldn't get any other delivery status!");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessageInternal::GetSender(nsAString& aSender)
|
||||
{
|
||||
aSender = mData.sender();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessageInternal::GetReceiver(nsAString& aReceiver)
|
||||
{
|
||||
aReceiver = mData.receiver();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessageInternal::GetBody(nsAString& aBody)
|
||||
{
|
||||
aBody = mData.body();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessageInternal::GetMessageClass(nsAString& aMessageClass)
|
||||
{
|
||||
switch (mData.messageClass()) {
|
||||
case eMessageClass_Normal:
|
||||
aMessageClass = MESSAGE_CLASS_NORMAL;
|
||||
break;
|
||||
case eMessageClass_Class0:
|
||||
aMessageClass = MESSAGE_CLASS_CLASS_0;
|
||||
break;
|
||||
case eMessageClass_Class1:
|
||||
aMessageClass = MESSAGE_CLASS_CLASS_1;
|
||||
break;
|
||||
case eMessageClass_Class2:
|
||||
aMessageClass = MESSAGE_CLASS_CLASS_2;
|
||||
break;
|
||||
case eMessageClass_Class3:
|
||||
aMessageClass = MESSAGE_CLASS_CLASS_3;
|
||||
break;
|
||||
default:
|
||||
MOZ_CRASH("We shouldn't get any other message class!");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessageInternal::GetTimestamp(DOMTimeStamp* aTimestamp)
|
||||
{
|
||||
*aTimestamp = mData.timestamp();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessageInternal::GetSentTimestamp(DOMTimeStamp* aSentTimestamp)
|
||||
{
|
||||
*aSentTimestamp = mData.sentTimestamp();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessageInternal::GetDeliveryTimestamp(DOMTimeStamp* aDate)
|
||||
{
|
||||
*aDate = mData.deliveryTimestamp();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsMessageInternal::GetRead(bool* aRead)
|
||||
{
|
||||
*aRead = mData.read();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace mobilemessage
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,74 @@
|
|||
/* -*- 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_mobilemessage_SmsMessageInternal_h
|
||||
#define mozilla_dom_mobilemessage_SmsMessageInternal_h
|
||||
|
||||
#include "mozilla/dom/mobilemessage/SmsTypes.h"
|
||||
#include "nsISmsMessage.h"
|
||||
#include "nsString.h"
|
||||
#include "mozilla/dom/mobilemessage/Types.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mobilemessage {
|
||||
|
||||
class SmsMessageData;
|
||||
|
||||
class SmsMessageInternal final : public nsISmsMessage
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISMSMESSAGE
|
||||
|
||||
SmsMessageInternal(int32_t aId,
|
||||
uint64_t aThreadId,
|
||||
const nsString& aIccId,
|
||||
mobilemessage::DeliveryState aDelivery,
|
||||
mobilemessage::DeliveryStatus aDeliveryStatus,
|
||||
const nsString& aSender,
|
||||
const nsString& aReceiver,
|
||||
const nsString& aBody,
|
||||
mobilemessage::MessageClass aMessageClass,
|
||||
uint64_t aTimestamp,
|
||||
uint64_t aSentTimestamp,
|
||||
uint64_t aDeliveryTimestamp,
|
||||
bool aRead);
|
||||
|
||||
explicit SmsMessageInternal(const SmsMessageData& aData);
|
||||
|
||||
static nsresult Create(int32_t aId,
|
||||
uint64_t aThreadId,
|
||||
const nsAString& aIccId,
|
||||
const nsAString& aDelivery,
|
||||
const nsAString& aDeliveryStatus,
|
||||
const nsAString& aSender,
|
||||
const nsAString& aReceiver,
|
||||
const nsAString& aBody,
|
||||
const nsAString& aMessageClass,
|
||||
uint64_t aTimestamp,
|
||||
uint64_t aSentTimestamp,
|
||||
uint64_t aDeliveryTimestamp,
|
||||
bool aRead,
|
||||
JSContext* aCx,
|
||||
nsISmsMessage** aMessage);
|
||||
const SmsMessageData& GetData() const;
|
||||
|
||||
private:
|
||||
~SmsMessageInternal() {}
|
||||
|
||||
// Don't try to use the default constructor.
|
||||
SmsMessageInternal();
|
||||
|
||||
SmsMessageData mData;
|
||||
};
|
||||
|
||||
} // namespace mobilemessage
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_mobilemessage_SmsMessageInternal_h
|
|
@ -10,8 +10,8 @@
|
|||
#include "mozilla/dom/mobilemessage/SmsParent.h"
|
||||
#include "mozilla/dom/mobilemessage/SmsTypes.h"
|
||||
#include "mozilla/dom/mobilemessage/Types.h"
|
||||
#include "mozilla/dom/MobileMessageThread.h"
|
||||
#include "mozilla/dom/SmsMessage.h"
|
||||
#include "MobileMessageThreadInternal.h"
|
||||
#include "SmsMessageInternal.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "nsIMobileMessageDatabaseService.h"
|
||||
#include "nsIObserverService.h"
|
||||
|
@ -51,7 +51,7 @@ SmsManager::NotifySmsReceived(jni::String::Param aSender,
|
|||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMMozSmsMessage> domMessage = new SmsMessage(message);
|
||||
nsCOMPtr<nsISmsMessage> domMessage = new SmsMessageInternal(message);
|
||||
obs->NotifyObservers(domMessage, kSmsReceivedObserverTopic, nullptr);
|
||||
});
|
||||
NS_DispatchToMainThread(runnable);
|
||||
|
@ -92,7 +92,7 @@ SmsManager::NotifySmsSent(int32_t aId,
|
|||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMMozSmsMessage> domMessage = new SmsMessage(message);
|
||||
nsCOMPtr<nsISmsMessage> domMessage = new SmsMessageInternal(message);
|
||||
obs->NotifyObservers(domMessage, kSmsSentObserverTopic, nullptr);
|
||||
|
||||
nsCOMPtr<nsIMobileMessageCallback> request =
|
||||
|
@ -137,7 +137,7 @@ SmsManager::NotifySmsDelivery(int32_t aId,
|
|||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMMozSmsMessage> domMessage = new SmsMessage(message);
|
||||
nsCOMPtr<nsISmsMessage> domMessage = new SmsMessageInternal(message);
|
||||
const char* topic = (message.deliveryStatus() == eDeliveryStatus_Success)
|
||||
? kSmsDeliverySuccessObserverTopic
|
||||
: kSmsDeliveryErrorObserverTopic;
|
||||
|
@ -201,7 +201,7 @@ SmsManager::NotifyGetSms(int32_t aId,
|
|||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMMozSmsMessage> domMessage = new SmsMessage(message);
|
||||
nsCOMPtr<nsISmsMessage> domMessage = new SmsMessageInternal(message);
|
||||
request->NotifyMessageGot(domMessage);
|
||||
});
|
||||
NS_DispatchToMainThread(runnable);
|
||||
|
@ -313,10 +313,10 @@ SmsManager::NotifyThreadCursorResult(int64_t aId,
|
|||
return;
|
||||
}
|
||||
|
||||
nsCOMArray<nsIDOMMozMobileMessageThread> arr;
|
||||
arr.AppendElement(new MobileMessageThread(thread));
|
||||
nsCOMArray<nsIMobileMessageThread> arr;
|
||||
arr.AppendElement(new MobileMessageThreadInternal(thread));
|
||||
|
||||
nsIDOMMozMobileMessageThread** elements;
|
||||
nsIMobileMessageThread** elements;
|
||||
int32_t size;
|
||||
size = arr.Forget(&elements);
|
||||
|
||||
|
@ -365,10 +365,10 @@ SmsManager::NotifyMessageCursorResult(int32_t aMessageId,
|
|||
return;
|
||||
}
|
||||
|
||||
nsCOMArray<nsIDOMMozSmsMessage> arr;
|
||||
arr.AppendElement(new SmsMessage(message));
|
||||
nsCOMArray<nsISmsMessage> arr;
|
||||
arr.AppendElement(new SmsMessageInternal(message));
|
||||
|
||||
nsIDOMMozSmsMessage** elements;
|
||||
nsISmsMessage** elements;
|
||||
int32_t size;
|
||||
size = arr.Forget(&elements);
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
* 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/. */
|
||||
|
||||
#include "SmsMessage.h"
|
||||
#include "SmsService.h"
|
||||
#include "AndroidBridge.h"
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
||||
|
||||
Cu.importGlobalProperties(['Blob']);
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/PhoneNumberUtils.jsm");
|
||||
|
@ -1294,7 +1295,7 @@ SendTransaction.prototype = Object.create(CancellableTransaction.prototype, {
|
|||
|
||||
let numPartsToLoad = parts.length;
|
||||
parts.forEach((aPart) => {
|
||||
if (!(aPart.content instanceof Ci.nsIDOMBlob)) {
|
||||
if (!(aPart.content instanceof Blob)) {
|
||||
numPartsToLoad--;
|
||||
if (!numPartsToLoad) {
|
||||
callbackIfValid();
|
||||
|
@ -1683,7 +1684,7 @@ MmsService.prototype = {
|
|||
* A callback function that takes two arguments: one for X-Mms-Status,
|
||||
* the other parsed MMS message.
|
||||
* @param aDomMessage
|
||||
* The nsIDOMMozMmsMessage object.
|
||||
* The nsIMmsMessage object.
|
||||
*/
|
||||
retrieveMessage: function(aMmsConnection, aContentLocation, aCallback,
|
||||
aDomMessage) {
|
||||
|
@ -1703,7 +1704,7 @@ MmsService.prototype = {
|
|||
* @param aName
|
||||
* The system message name.
|
||||
* @param aDomMessage
|
||||
* The nsIDOMMozMmsMessage object.
|
||||
* The nsIMmsMessage object.
|
||||
*/
|
||||
broadcastMmsSystemMessage: function(aName, aDomMessage) {
|
||||
if (DEBUG) debug("Broadcasting the MMS system message: " + aName);
|
||||
|
@ -1742,7 +1743,7 @@ MmsService.prototype = {
|
|||
* an MMS is sent.
|
||||
*
|
||||
* @params aDomMessage
|
||||
* The nsIDOMMozMmsMessage object.
|
||||
* The nsIMmsMessage object.
|
||||
*/
|
||||
broadcastSentMessageEvent: function(aDomMessage) {
|
||||
// Broadcasting a 'sms-sent' system message to open apps.
|
||||
|
@ -1757,7 +1758,7 @@ MmsService.prototype = {
|
|||
* an MMS is failed to send.
|
||||
*
|
||||
* @params aDomMessage
|
||||
* The nsIDOMMozMmsMessage object.
|
||||
* The nsIMmsMessage object.
|
||||
*/
|
||||
broadcastSentFailureMessageEvent: function(aDomMessage) {
|
||||
// Broadcasting a 'sms-sent' system message to open apps.
|
||||
|
@ -1772,7 +1773,7 @@ MmsService.prototype = {
|
|||
* an MMS is received.
|
||||
*
|
||||
* @params aDomMessage
|
||||
* The nsIDOMMozMmsMessage object.
|
||||
* The nsIMmsMessage object.
|
||||
*/
|
||||
broadcastReceivedMessageEvent: function(aDomMessage) {
|
||||
// Broadcasting a 'sms-received' system message to open apps.
|
||||
|
@ -1822,8 +1823,13 @@ MmsService.prototype = {
|
|||
null,
|
||||
DELIVERY_STATUS_ERROR,
|
||||
null,
|
||||
(rv, domMessage) =>
|
||||
this.broadcastReceivedMessageEvent(domMessage));
|
||||
(aRv, aDomMessage) => {
|
||||
let mmsMessage = null;
|
||||
try {
|
||||
mmsMessage = aDomMessage.QueryInterface(Ci.nsIMmsMessage);
|
||||
} catch (e) {}
|
||||
this.broadcastReceivedMessageEvent(mmsMessage);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1831,8 +1837,13 @@ MmsService.prototype = {
|
|||
retrievedMessage,
|
||||
savableMessage);
|
||||
gMobileMessageDatabaseService.saveReceivedMessage(savableMessage,
|
||||
(rv, domMessage) => {
|
||||
let success = Components.isSuccessCode(rv);
|
||||
(aRv, aDomMessage) => {
|
||||
let mmsMessage = null;
|
||||
try {
|
||||
mmsMessage = aDomMessage.QueryInterface(Ci.nsIMmsMessage);
|
||||
} catch (e) {}
|
||||
|
||||
let success = Components.isSuccessCode(aRv);
|
||||
|
||||
// Cite 6.2.1 "Transaction Flow" in OMA-TS-MMS_ENC-V1_3-20110913-A:
|
||||
// The M-NotifyResp.ind response PDU SHALL provide a message retrieval
|
||||
|
@ -1851,11 +1862,11 @@ MmsService.prototype = {
|
|||
// At this point we could send a message to content to notify the user
|
||||
// that storing an incoming MMS failed, most likely due to a full disk.
|
||||
// The end user has to retrieve the MMS again.
|
||||
if (DEBUG) debug("Could not store MMS , error code " + rv);
|
||||
if (DEBUG) debug("Could not store MMS , error code " + aRv);
|
||||
return;
|
||||
}
|
||||
|
||||
this.broadcastReceivedMessageEvent(domMessage);
|
||||
this.broadcastReceivedMessageEvent(mmsMessage);
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -1968,12 +1979,17 @@ MmsService.prototype = {
|
|||
|
||||
gMobileMessageDatabaseService
|
||||
.saveReceivedMessage(savableMessage,
|
||||
(aRv, aDomMessage) =>
|
||||
this.saveReceivedMessageCallback(mmsConnection,
|
||||
retrievalMode,
|
||||
savableMessage,
|
||||
aRv,
|
||||
aDomMessage));
|
||||
(aRv, aDomMessage) => {
|
||||
let mmsMessage = null;
|
||||
try {
|
||||
mmsMessage = aDomMessage.QueryInterface(Ci.nsIMmsMessage);
|
||||
} catch (e) {}
|
||||
this.saveReceivedMessageCallback(mmsConnection,
|
||||
retrievalMode,
|
||||
savableMessage,
|
||||
aRv,
|
||||
mmsMessage);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -2024,24 +2040,30 @@ MmsService.prototype = {
|
|||
.setMessageDeliveryStatusByEnvelopeId(envelopeId, address, deliveryStatus,
|
||||
(aRv, aDomMessage) => {
|
||||
if (DEBUG) debug("Marking the delivery status is done.");
|
||||
|
||||
let mmsMessage = null;
|
||||
try {
|
||||
mmsMessage = aDomMessage.QueryInterface(Ci.nsIMmsMessage);
|
||||
} catch (e) {}
|
||||
|
||||
// TODO bug 832140 handle !Components.isSuccessCode(aRv)
|
||||
|
||||
let topic;
|
||||
if (mmsStatus === MMS.MMS_PDU_STATUS_RETRIEVED) {
|
||||
topic = kSmsDeliverySuccessObserverTopic;
|
||||
// Broadcasting a 'sms-delivery-success' system message to open apps.
|
||||
this.broadcastMmsSystemMessage(topic, aDomMessage);
|
||||
this.broadcastMmsSystemMessage(topic, mmsMessage);
|
||||
} else if (mmsStatus === MMS.MMS_PDU_STATUS_REJECTED) {
|
||||
topic = kSmsDeliveryErrorObserverTopic;
|
||||
// Broadcasting a 'sms-delivery-error' system message to open apps.
|
||||
this.broadcastMmsSystemMessage(topic, aDomMessage);
|
||||
this.broadcastMmsSystemMessage(topic, mmsMessage);
|
||||
} else {
|
||||
if (DEBUG) debug("Needn't fire event for this MMS status. Returning.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Notifying observers the delivery status is updated.
|
||||
Services.obs.notifyObservers(aDomMessage, topic, null);
|
||||
Services.obs.notifyObservers(mmsMessage, topic, null);
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -2073,6 +2095,11 @@ MmsService.prototype = {
|
|||
gMobileMessageDatabaseService
|
||||
.setMessageReadStatusByEnvelopeId(envelopeId, address, readStatus,
|
||||
(aRv, aDomMessage) => {
|
||||
let mmsMessage = null;
|
||||
try {
|
||||
mmsMessage = aDomMessage.QueryInterface(Ci.nsIMmsMessage);
|
||||
} catch (e) {}
|
||||
|
||||
if (!Components.isSuccessCode(aRv)) {
|
||||
if (DEBUG) debug("Failed to update read status: " + aRv);
|
||||
return;
|
||||
|
@ -2084,13 +2111,13 @@ MmsService.prototype = {
|
|||
topic = kSmsReadSuccessObserverTopic;
|
||||
|
||||
// Broadcasting a 'sms-read-success' system message to open apps.
|
||||
this.broadcastMmsSystemMessage(topic, aDomMessage);
|
||||
this.broadcastMmsSystemMessage(topic, mmsMessage);
|
||||
} else {
|
||||
topic = kSmsReadErrorObserverTopic;
|
||||
}
|
||||
|
||||
// Notifying observers the read status is updated.
|
||||
Services.obs.notifyObservers(aDomMessage, topic, null);
|
||||
Services.obs.notifyObservers(mmsMessage, topic, null);
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -2305,21 +2332,27 @@ MmsService.prototype = {
|
|||
aEnvelopeId,
|
||||
(aRv, aDomMessage) => {
|
||||
if (DEBUG) debug("Marking the delivery state/staus is done. Notify sent or failed.");
|
||||
|
||||
let mmsMessage = null;
|
||||
try {
|
||||
mmsMessage = aDomMessage.QueryInterface(Ci.nsIMmsMessage);
|
||||
} catch (e) {}
|
||||
|
||||
// TODO bug 832140 handle !Components.isSuccessCode(aRv)
|
||||
if (!isSentSuccess) {
|
||||
if (DEBUG) debug("Sending MMS failed.");
|
||||
aRequest.notifySendMessageFailed(aErrorCode, aDomMessage);
|
||||
this.broadcastSentFailureMessageEvent(aDomMessage);
|
||||
aRequest.notifySendMessageFailed(aErrorCode, mmsMessage);
|
||||
this.broadcastSentFailureMessageEvent(mmsMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
if (DEBUG) debug("Sending MMS succeeded.");
|
||||
|
||||
// Notifying observers the MMS message is sent.
|
||||
this.broadcastSentMessageEvent(aDomMessage);
|
||||
this.broadcastSentMessageEvent(mmsMessage);
|
||||
|
||||
// Return the request after sending the MMS message successfully.
|
||||
aRequest.notifyMessageSent(aDomMessage);
|
||||
aRequest.notifyMessageSent(mmsMessage);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -2331,29 +2364,34 @@ MmsService.prototype = {
|
|||
gMobileMessageDatabaseService
|
||||
.saveSendingMessage(savableMessage,
|
||||
(aRv, aDomMessage) => {
|
||||
let mmsMessage = null;
|
||||
try {
|
||||
mmsMessage = aDomMessage.QueryInterface(Ci.nsIMmsMessage);
|
||||
} catch (e) {}
|
||||
|
||||
if (!Components.isSuccessCode(aRv)) {
|
||||
if (DEBUG) debug("Error! Fail to save sending message! rv = " + aRv);
|
||||
aRequest.notifySendMessageFailed(
|
||||
gMobileMessageDatabaseService.translateCrErrorToMessageCallbackError(aRv),
|
||||
aDomMessage);
|
||||
this.broadcastSentFailureMessageEvent(aDomMessage);
|
||||
mmsMessage);
|
||||
this.broadcastSentFailureMessageEvent(mmsMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
if (DEBUG) debug("Saving sending message is done. Start to send.");
|
||||
|
||||
Services.obs.notifyObservers(aDomMessage, kSmsSendingObserverTopic, null);
|
||||
Services.obs.notifyObservers(mmsMessage, kSmsSendingObserverTopic, null);
|
||||
|
||||
if (errorCode !== Ci.nsIMobileMessageCallback.SUCCESS_NO_ERROR) {
|
||||
if (DEBUG) debug("Error! The params for sending MMS are invalid.");
|
||||
sendTransactionCb(aDomMessage, errorCode, null);
|
||||
sendTransactionCb(mmsMessage, errorCode, null);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check radio state in prior to default service Id.
|
||||
if (getRadioDisabledState()) {
|
||||
if (DEBUG) debug("Error! Radio is disabled when sending MMS.");
|
||||
sendTransactionCb(aDomMessage,
|
||||
sendTransactionCb(mmsMessage,
|
||||
Ci.nsIMobileMessageCallback.RADIO_DISABLED_ERROR,
|
||||
null);
|
||||
return;
|
||||
|
@ -2364,7 +2402,7 @@ MmsService.prototype = {
|
|||
// SIM. Users have to manually swith the default SIM before sending.
|
||||
if (mmsConnection.serviceId != this.mmsDefaultServiceId) {
|
||||
if (DEBUG) debug("RIL service is not active to send MMS.");
|
||||
sendTransactionCb(aDomMessage,
|
||||
sendTransactionCb(mmsMessage,
|
||||
Ci.nsIMobileMessageCallback.NON_ACTIVE_SIM_CARD_ERROR,
|
||||
null);
|
||||
return;
|
||||
|
@ -2374,11 +2412,11 @@ MmsService.prototype = {
|
|||
let sendTransaction;
|
||||
try {
|
||||
sendTransaction =
|
||||
new SendTransaction(mmsConnection, aDomMessage.id, savableMessage,
|
||||
new SendTransaction(mmsConnection, mmsMessage.id, savableMessage,
|
||||
savableMessage["deliveryStatusRequested"]);
|
||||
} catch (e) {
|
||||
if (DEBUG) debug("Exception: fail to create a SendTransaction instance.");
|
||||
sendTransactionCb(aDomMessage,
|
||||
sendTransactionCb(mmsMessage,
|
||||
Ci.nsIMobileMessageCallback.INTERNAL_ERROR, null);
|
||||
return;
|
||||
}
|
||||
|
@ -2400,7 +2438,7 @@ MmsService.prototype = {
|
|||
}
|
||||
let envelopeId =
|
||||
aMsg && aMsg.headers && aMsg.headers["message-id"] || null;
|
||||
sendTransactionCb(aDomMessage, errorCode, envelopeId);
|
||||
sendTransactionCb(mmsMessage, errorCode, envelopeId);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
@ -2409,6 +2447,11 @@ MmsService.prototype = {
|
|||
if (DEBUG) debug("Retrieving message with ID " + aMessageId);
|
||||
gMobileMessageDatabaseService
|
||||
.getMessageRecordById(aMessageId, (aRv, aMessageRecord, aDomMessage) => {
|
||||
let mmsMessage = null;
|
||||
try {
|
||||
mmsMessage = aDomMessage.QueryInterface(Ci.nsIMmsMessage);
|
||||
} catch (e) {}
|
||||
|
||||
if (!Components.isSuccessCode(aRv)) {
|
||||
if (DEBUG) debug("Function getMessageRecordById() return error: " + aRv);
|
||||
aRequest.notifyGetMessageFailed(
|
||||
|
@ -2546,23 +2589,28 @@ MmsService.prototype = {
|
|||
aMessageRecord);
|
||||
|
||||
gMobileMessageDatabaseService.saveReceivedMessage(aMessageRecord,
|
||||
(rv, domMessage) => {
|
||||
let success = Components.isSuccessCode(rv);
|
||||
(aRv, aDomMessage) => {
|
||||
let mmsMessage = null;
|
||||
try {
|
||||
mmsMessage = aDomMessage.QueryInterface(Ci.nsIMmsMessage);
|
||||
} catch (e) {}
|
||||
|
||||
let success = Components.isSuccessCode(aRv);
|
||||
if (!success) {
|
||||
// At this point we could send a message to content to
|
||||
// notify the user that storing an incoming MMS failed, most
|
||||
// likely due to a full disk.
|
||||
if (DEBUG) debug("Could not store MMS, error code " + rv);
|
||||
if (DEBUG) debug("Could not store MMS, error code " + aRv);
|
||||
aRequest.notifyGetMessageFailed(
|
||||
gMobileMessageDatabaseService.translateCrErrorToMessageCallbackError(rv));
|
||||
gMobileMessageDatabaseService.translateCrErrorToMessageCallbackError(aRv));
|
||||
return;
|
||||
}
|
||||
|
||||
// Notifying observers a new MMS message is retrieved.
|
||||
this.broadcastReceivedMessageEvent(domMessage);
|
||||
this.broadcastReceivedMessageEvent(mmsMessage);
|
||||
|
||||
// Return the request after retrieving the MMS message successfully.
|
||||
aRequest.notifyMessageGot(domMessage);
|
||||
aRequest.notifyMessageGot(mmsMessage);
|
||||
|
||||
// Cite 6.3.1 "Transaction Flow" in OMA-TS-MMS_ENC-V1_3-20110913-A:
|
||||
// If an acknowledgement is requested, the MMS Client SHALL respond
|
||||
|
@ -2596,7 +2644,7 @@ MmsService.prototype = {
|
|||
url,
|
||||
(aMmsStatus, aRetrievedMsg) =>
|
||||
responseNotify(aMmsStatus, aRetrievedMsg),
|
||||
aDomMessage);
|
||||
mmsMessage);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
|
|
@ -2065,13 +2065,13 @@ MobileMessageDB.prototype = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Generate a <code>nsIDOMMozSmsMessage</code> or
|
||||
* <code>nsIDOMMozMmsMessage</code> instance from a stored message record.
|
||||
* Generate a <code>nsISmsMessage</code> or
|
||||
* <code>nsIMmsMessage</code> instance from a stored message record.
|
||||
*
|
||||
* @function MobileMessageDB.createDomMessageFromRecord
|
||||
* @param {MobileMessageDB.MessageRecord} aMessageRecord
|
||||
* The stored message record.
|
||||
* @return {nsIDOMMozSmsMessage|nsIDOMMozMmsMessage}
|
||||
* @return {nsISmsMessage|nsIMmsMessage}
|
||||
*/
|
||||
createDomMessageFromRecord: function(aMessageRecord) {
|
||||
if (DEBUG) {
|
||||
|
@ -2580,7 +2580,7 @@ MobileMessageDB.prototype = {
|
|||
* @callback MobileMessageDB.TransactionResultCallback
|
||||
* @param {number} aErrorCode
|
||||
* The error code on failure, or <code>NS_OK</code> on success.
|
||||
* @param {nsIDOMMozSmsMessage|nsIDOMMozMmsMessage} aDomMessage
|
||||
* @param {nsISmsMessage|nsIMmsMessage} aDomMessage
|
||||
* The DOM message instance of the transaction result.
|
||||
*/
|
||||
|
||||
|
@ -3592,7 +3592,7 @@ MobileMessageDB.prototype = {
|
|||
* The error code on failure, or <code>NS_OK</code> on success.
|
||||
* @param {MobileMessageDB.MessageRecord} aMessageRecord
|
||||
* The stored message record.
|
||||
* @param {nsIDOMMozSmsMessage|nsIDOMMozMmsMessage} aDomMessage
|
||||
* @param {nsISmsMessage|nsIMmsMessage} aDomMessage
|
||||
* The DOM message instance of the message record.
|
||||
*/
|
||||
|
||||
|
|
|
@ -291,7 +291,7 @@ SmsService.prototype = {
|
|||
|
||||
_notifySendingError: function(aErrorCode, aSendingMessage, aSilent, aRequest) {
|
||||
if (aSilent || aErrorCode === Ci.nsIMobileMessageCallback.NOT_FOUND_ERROR) {
|
||||
// There is no way to modify nsIDOMMozSmsMessage attributes as they
|
||||
// There is no way to modify nsISmsMessage attributes as they
|
||||
// are read only so we just create a new sms instance to send along
|
||||
// with the notification.
|
||||
aRequest.notifySendMessageFailed(aErrorCode,
|
||||
|
@ -322,11 +322,15 @@ SmsService.prototype = {
|
|||
RIL.GECKO_SMS_DELIVERY_STATUS_ERROR,
|
||||
null,
|
||||
(aRv, aDomMessage) => {
|
||||
let smsMessage = null;
|
||||
try {
|
||||
smsMessage = aDomMessage.QueryInterface(Ci.nsISmsMessage);
|
||||
} catch (e) {}
|
||||
// TODO bug 832140 handle !Components.isSuccessCode(aRv)
|
||||
this._broadcastSmsSystemMessage(
|
||||
Ci.nsISmsMessenger.NOTIFICATION_TYPE_SENT_FAILED, aDomMessage);
|
||||
aRequest.notifySendMessageFailed(aErrorCode, aDomMessage);
|
||||
Services.obs.notifyObservers(aDomMessage, kSmsFailedObserverTopic, null);
|
||||
Ci.nsISmsMessenger.NOTIFICATION_TYPE_SENT_FAILED, smsMessage);
|
||||
aRequest.notifySendMessageFailed(aErrorCode, smsMessage);
|
||||
Services.obs.notifyObservers(smsMessage, kSmsFailedObserverTopic, null);
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -396,7 +400,7 @@ SmsService.prototype = {
|
|||
// Message was sent to SMSC.
|
||||
if (!aResponse.deliveryStatus) {
|
||||
if (aSilent) {
|
||||
// There is no way to modify nsIDOMMozSmsMessage attributes as they
|
||||
// There is no way to modify nsISmsMessage attributes as they
|
||||
// are read only so we just create a new sms instance to send along
|
||||
// with the notification.
|
||||
aRequest.notifyMessageSent(
|
||||
|
@ -424,17 +428,21 @@ SmsService.prototype = {
|
|||
sentMessage.deliveryStatus,
|
||||
null,
|
||||
(aRv, aDomMessage) => {
|
||||
let smsMessage = null;
|
||||
try {
|
||||
smsMessage = aDomMessage.QueryInterface(Ci.nsISmsMessage);
|
||||
} catch (e) {}
|
||||
// TODO bug 832140 handle !Components.isSuccessCode(aRv)
|
||||
|
||||
if (requestStatusReport) {
|
||||
// Update the sentMessage and wait for the status report.
|
||||
sentMessage = aDomMessage;
|
||||
sentMessage = smsMessage;
|
||||
}
|
||||
|
||||
this._broadcastSmsSystemMessage(
|
||||
Ci.nsISmsMessenger.NOTIFICATION_TYPE_SENT, aDomMessage);
|
||||
aRequest.notifyMessageSent(aDomMessage);
|
||||
Services.obs.notifyObservers(aDomMessage, kSmsSentObserverTopic, null);
|
||||
Ci.nsISmsMessenger.NOTIFICATION_TYPE_SENT, smsMessage);
|
||||
aRequest.notifyMessageSent(smsMessage);
|
||||
Services.obs.notifyObservers(smsMessage, kSmsSentObserverTopic, null);
|
||||
});
|
||||
|
||||
// Keep this callback if we have status report waiting.
|
||||
|
@ -450,6 +458,10 @@ SmsService.prototype = {
|
|||
aResponse.deliveryStatus,
|
||||
null,
|
||||
(aRv, aDomMessage) => {
|
||||
let smsMessage = null;
|
||||
try {
|
||||
smsMessage = aDomMessage.QueryInterface(Ci.nsISmsMessage);
|
||||
} catch (e) {}
|
||||
// TODO bug 832140 handle !Components.isSuccessCode(aRv)
|
||||
|
||||
let [topic, notificationType] =
|
||||
|
@ -461,10 +473,10 @@ SmsService.prototype = {
|
|||
|
||||
// Broadcasting a "sms-delivery-success/sms-delivery-error" system
|
||||
// message to open apps.
|
||||
this._broadcastSmsSystemMessage(notificationType, aDomMessage);
|
||||
this._broadcastSmsSystemMessage(notificationType, smsMessage);
|
||||
|
||||
// Notifying observers the delivery status is updated.
|
||||
Services.obs.notifyObservers(aDomMessage, topic, null);
|
||||
Services.obs.notifyObservers(smsMessage, topic, null);
|
||||
});
|
||||
|
||||
// Send transaction has ended completely.
|
||||
|
@ -479,7 +491,7 @@ SmsService.prototype = {
|
|||
* @param aNotificationType
|
||||
* Ci.nsISmsMessenger.NOTIFICATION_TYPE_*.
|
||||
* @param aDomMessage
|
||||
* The nsIDOMMozSmsMessage object.
|
||||
* The nsISmsMessage object.
|
||||
*/
|
||||
_broadcastSmsSystemMessage: function(aNotificationType, aDomMessage) {
|
||||
if (DEBUG) debug("Broadcasting the SMS system message: " + aNotificationType);
|
||||
|
@ -799,6 +811,10 @@ SmsService.prototype = {
|
|||
}
|
||||
|
||||
let notifyReceived = (aRv, aDomMessage) => {
|
||||
let smsMessage = null;
|
||||
try {
|
||||
smsMessage = aDomMessage.QueryInterface(Ci.nsISmsMessage);
|
||||
} catch (e) {}
|
||||
let success = Components.isSuccessCode(aRv);
|
||||
|
||||
this._sendAckSms(aRv, aMessage, aServiceId);
|
||||
|
@ -813,8 +829,8 @@ SmsService.prototype = {
|
|||
}
|
||||
|
||||
this._broadcastSmsSystemMessage(
|
||||
Ci.nsISmsMessenger.NOTIFICATION_TYPE_RECEIVED, aDomMessage);
|
||||
Services.obs.notifyObservers(aDomMessage, kSmsReceivedObserverTopic, null);
|
||||
Ci.nsISmsMessenger.NOTIFICATION_TYPE_RECEIVED, smsMessage);
|
||||
Services.obs.notifyObservers(smsMessage, kSmsReceivedObserverTopic, null);
|
||||
};
|
||||
|
||||
if (aMessage.messageClass != RIL.GECKO_SMS_MESSAGE_CLASSES[RIL.PDU_DCS_MSG_CLASS_0]) {
|
||||
|
@ -960,20 +976,25 @@ SmsService.prototype = {
|
|||
iccId: this._getIccId(aServiceId)
|
||||
};
|
||||
|
||||
let saveSendingMessageCallback = (aRv, aSendingMessage) => {
|
||||
let saveSendingMessageCallback = (aRv, aDomMessage) => {
|
||||
let smsMessage = null;
|
||||
try {
|
||||
smsMessage = aDomMessage.QueryInterface(Ci.nsISmsMessage);
|
||||
} catch (e) {}
|
||||
|
||||
if (!Components.isSuccessCode(aRv)) {
|
||||
if (DEBUG) debug("Error! Fail to save sending message! aRv = " + aRv);
|
||||
this._broadcastSmsSystemMessage(
|
||||
Ci.nsISmsMessenger.NOTIFICATION_TYPE_SENT_FAILED, aSendingMessage);
|
||||
Ci.nsISmsMessenger.NOTIFICATION_TYPE_SENT_FAILED, smsMessage);
|
||||
aRequest.notifySendMessageFailed(
|
||||
gMobileMessageDatabaseService.translateCrErrorToMessageCallbackError(aRv),
|
||||
aSendingMessage);
|
||||
Services.obs.notifyObservers(aSendingMessage, kSmsFailedObserverTopic, null);
|
||||
smsMessage);
|
||||
Services.obs.notifyObservers(smsMessage, kSmsFailedObserverTopic, null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!aSilent) {
|
||||
Services.obs.notifyObservers(aSendingMessage, kSmsSendingObserverTopic, null);
|
||||
Services.obs.notifyObservers(smsMessage, kSmsSendingObserverTopic, null);
|
||||
}
|
||||
|
||||
let connection =
|
||||
|
@ -994,11 +1015,11 @@ SmsService.prototype = {
|
|||
errorCode = Ci.nsIMobileMessageCallback.NO_SIM_CARD_ERROR;
|
||||
}
|
||||
if (errorCode) {
|
||||
this._notifySendingError(errorCode, aSendingMessage, aSilent, aRequest);
|
||||
this._notifySendingError(errorCode, smsMessage, aSilent, aRequest);
|
||||
return;
|
||||
}
|
||||
|
||||
this._scheduleSending(aServiceId, aSendingMessage, aSilent, options,
|
||||
this._scheduleSending(aServiceId, smsMessage, aSilent, options,
|
||||
aRequest);
|
||||
}; // End of |saveSendingMessageCallback|.
|
||||
|
||||
|
@ -1389,7 +1410,9 @@ SmsSendingScheduler.prototype = {
|
|||
notifyClirModeChanged: function(mode) {},
|
||||
notifyLastKnownNetworkChanged: function() {},
|
||||
notifyLastKnownHomeNetworkChanged: function() {},
|
||||
notifyNetworkSelectionModeChanged: function() {}
|
||||
notifyNetworkSelectionModeChanged: function() {},
|
||||
notifyDeviceIdentitiesChanged: function() {}
|
||||
|
||||
};
|
||||
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([SmsService]);
|
||||
|
|
|
@ -6,14 +6,14 @@
|
|||
|
||||
XPIDL_SOURCES += [
|
||||
'nsIDeletedMessageInfo.idl',
|
||||
'nsIDOMMozMmsMessage.idl',
|
||||
'nsIDOMMozMobileMessageThread.idl',
|
||||
'nsIDOMMozSmsMessage.idl',
|
||||
'nsIMmsMessage.idl',
|
||||
'nsIMmsService.idl',
|
||||
'nsIMobileMessageCallback.idl',
|
||||
'nsIMobileMessageCursorCallback.idl',
|
||||
'nsIMobileMessageDatabaseService.idl',
|
||||
'nsIMobileMessageService.idl',
|
||||
'nsIMobileMessageThread.idl',
|
||||
'nsISmsMessage.idl',
|
||||
'nsISmsService.idl',
|
||||
'nsIWapPushApplication.idl',
|
||||
]
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
interface nsIGonkMobileMessageDatabaseCallback : nsISupports
|
||||
{
|
||||
/**
|
||||
* |aDomMessage|: the nsIDOMMoz{Mms,Sms}Message
|
||||
* |aDomMessage|: the nsI{Mms,Sms}Message
|
||||
*/
|
||||
void notify(in nsresult aRv, in nsISupports aDomMessage);
|
||||
};
|
||||
|
@ -20,7 +20,7 @@ interface nsIGonkMobileMessageDatabaseRecordCallback : nsISupports
|
|||
{
|
||||
/**
|
||||
* |aMessageRecord| Object: the mobile-message database record
|
||||
* |aDomMessage|: the nsIDOMMoz{Mms,Sms}Message. Noted, this value might be null.
|
||||
* |aDomMessage|: the nsI{Mms,Sms}Message. Noted, this value might be null.
|
||||
*/
|
||||
void notify(in nsresult aRv, in jsval aMessageRecord, in nsISupports aDomMessage);
|
||||
};
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
interface nsIDOMBlob;
|
||||
|
||||
[scriptable, builtinclass, uuid(f41d7400-0026-11e3-829d-eb7459c03810)]
|
||||
interface nsIDOMMozMmsMessage : nsISupports
|
||||
[scriptable, builtinclass, uuid(cd2ff09a-8853-11e5-ac49-0f655992cef6)]
|
||||
interface nsIMmsMessage : nsISupports
|
||||
{
|
||||
/**
|
||||
* |type| is always "mms".
|
||||
|
@ -41,7 +41,7 @@ interface nsIDOMMozMmsMessage : nsISupports
|
|||
|
||||
readonly attribute DOMTimeStamp timestamp;
|
||||
|
||||
readonly attribute DOMTimeStamp sentTimestamp;
|
||||
readonly attribute DOMTimeStamp sentTimestamp;
|
||||
// 0 if not available (e.g., |delivery| =
|
||||
// "sending").
|
||||
|
|
@ -32,13 +32,13 @@ interface nsIMobileMessageCallback : nsISupports
|
|||
const unsigned short RETRY_REQUIRED_ERROR = 17;
|
||||
|
||||
/**
|
||||
* |message| can be nsIDOMMoz{Mms,Sms}Message.
|
||||
* |message| can be nsI{Mms,Sms}Message.
|
||||
*/
|
||||
void notifyMessageSent(in nsISupports message);
|
||||
void notifySendMessageFailed(in long error, in nsISupports message);
|
||||
|
||||
/**
|
||||
* |message| can be nsIDOMMoz{Mms,Sms}Message.
|
||||
* |message| can be nsI{Mms,Sms}Message.
|
||||
*/
|
||||
void notifyMessageGot(in nsISupports message);
|
||||
void notifyGetMessageFailed(in long error);
|
||||
|
|
|
@ -5,58 +5,58 @@
|
|||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDeletedMessageInfo;
|
||||
interface nsIDOMMozSmsMessage;
|
||||
interface nsIDOMMozMmsMessage;
|
||||
interface nsIDOMMozMobileMessageThread;
|
||||
interface nsISmsMessage;
|
||||
interface nsIMmsMessage;
|
||||
interface nsIMobileMessageThread;
|
||||
|
||||
%{C++
|
||||
#define MOBILE_MESSAGE_SERVICE_CID { 0x829c1dd6, 0x0466, 0x4591, { 0x83, 0x6f, 0xb8, 0xf6, 0xfd, 0x1f, 0x7b, 0xa5 } }
|
||||
#define MOBILE_MESSAGE_SERVICE_CONTRACTID "@mozilla.org/mobilemessage/mobilemessageservice;1"
|
||||
%}
|
||||
|
||||
[scriptable, builtinclass, uuid(bc28e604-53ee-4be9-af20-268ce9efc61a)]
|
||||
[scriptable, builtinclass, uuid(15267554-8854-11e5-8947-8f2150f4eabc)]
|
||||
interface nsIMobileMessageService : nsISupports
|
||||
{
|
||||
[implicit_jscontext]
|
||||
nsIDOMMozSmsMessage createSmsMessage(in long id,
|
||||
in unsigned long long threadId,
|
||||
in DOMString iccId,
|
||||
in DOMString delivery,
|
||||
in DOMString deliveryStatus,
|
||||
in DOMString sender,
|
||||
in DOMString receiver,
|
||||
in DOMString body,
|
||||
in DOMString messageClass,
|
||||
in unsigned long long timestamp,
|
||||
in unsigned long long sentTimestamp,
|
||||
in unsigned long long deliveryTimestamp,
|
||||
in bool read);
|
||||
nsISmsMessage createSmsMessage(in long id,
|
||||
in unsigned long long threadId,
|
||||
in DOMString iccId,
|
||||
in DOMString delivery,
|
||||
in DOMString deliveryStatus,
|
||||
in DOMString sender,
|
||||
in DOMString receiver,
|
||||
in DOMString body,
|
||||
in DOMString messageClass,
|
||||
in unsigned long long timestamp,
|
||||
in unsigned long long sentTimestamp,
|
||||
in unsigned long long deliveryTimestamp,
|
||||
in bool read);
|
||||
|
||||
[implicit_jscontext]
|
||||
nsIDOMMozMmsMessage createMmsMessage(in long id,
|
||||
in unsigned long long threadId,
|
||||
in DOMString iccId,
|
||||
in DOMString delivery,
|
||||
in jsval deliveryInfo,
|
||||
in DOMString sender,
|
||||
in jsval receivers,
|
||||
in unsigned long long timestamp,
|
||||
in unsigned long long sentTimestamp,
|
||||
in boolean read,
|
||||
in DOMString subject,
|
||||
in DOMString smil,
|
||||
in jsval attachments,
|
||||
in unsigned long long expiryDate,
|
||||
in boolean readReportRequested);
|
||||
nsIMmsMessage createMmsMessage(in long id,
|
||||
in unsigned long long threadId,
|
||||
in DOMString iccId,
|
||||
in DOMString delivery,
|
||||
in jsval deliveryInfo,
|
||||
in DOMString sender,
|
||||
in jsval receivers,
|
||||
in unsigned long long timestamp,
|
||||
in unsigned long long sentTimestamp,
|
||||
in boolean read,
|
||||
in DOMString subject,
|
||||
in DOMString smil,
|
||||
in jsval attachments,
|
||||
in unsigned long long expiryDate,
|
||||
in boolean readReportRequested);
|
||||
|
||||
[implicit_jscontext]
|
||||
nsIDOMMozMobileMessageThread createThread(in unsigned long long id,
|
||||
in jsval participants,
|
||||
in unsigned long long timestamp,
|
||||
in DOMString lastMessageSubject,
|
||||
in DOMString body,
|
||||
in unsigned long long unreadCount,
|
||||
in DOMString aLastMessageType);
|
||||
nsIMobileMessageThread createThread(in unsigned long long id,
|
||||
in jsval participants,
|
||||
in unsigned long long timestamp,
|
||||
in DOMString lastMessageSubject,
|
||||
in DOMString body,
|
||||
in unsigned long long unreadCount,
|
||||
in DOMString aLastMessageType);
|
||||
|
||||
nsIDeletedMessageInfo createDeletedMessageInfo(
|
||||
[array, size_is(msgCount)] in long messageIds,
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
#include "domstubs.idl"
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, builtinclass, uuid(525ad3a6-59a9-11e3-bdc3-836486cb58be)]
|
||||
interface nsIDOMMozMobileMessageThread : nsISupports
|
||||
[scriptable, builtinclass, uuid(dd6794cc-8853-11e5-89b4-278852073d45)]
|
||||
interface nsIMobileMessageThread : nsISupports
|
||||
{
|
||||
// Unique identity of the thread.
|
||||
readonly attribute unsigned long long id;
|
|
@ -5,8 +5,8 @@
|
|||
#include "domstubs.idl"
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, builtinclass, uuid(fc8153d2-0026-11e3-bf31-8b0c1d5e7638)]
|
||||
interface nsIDOMMozSmsMessage : nsISupports
|
||||
[scriptable, builtinclass, uuid(d7670dfa-8853-11e5-8e3e-43cd171289cc)]
|
||||
interface nsISmsMessage : nsISupports
|
||||
{
|
||||
/**
|
||||
* |type| is always "sms".
|
||||
|
@ -52,7 +52,7 @@ interface nsIDOMMozSmsMessage : nsISupports
|
|||
|
||||
readonly attribute DOMTimeStamp timestamp;
|
||||
|
||||
readonly attribute DOMTimeStamp sentTimestamp;
|
||||
readonly attribute DOMTimeStamp sentTimestamp;
|
||||
// 0 if not available (e.g., |delivery| =
|
||||
// "sending").
|
||||
|
|
@ -24,7 +24,7 @@ interface nsISmsMessenger : nsISupports
|
|||
* 'sms-sent', 'sms-failed' and 'sms-delivery-error'.
|
||||
*
|
||||
* Note: Except aNotificationType, all parameters are the attributes of the
|
||||
* nsIDOMMozSmsMessage generated by nsIMobileMessageService.createSmsMessage().
|
||||
* nsISmsMessage generated by nsIMobileMessageService.createSmsMessage().
|
||||
*
|
||||
* @param aNotificationType
|
||||
* A predefined constant of nsISmsMessenger.NOTIFICATION_TYPE_*.
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMMozSmsMessage;
|
||||
interface nsIMobileMessageCallback;
|
||||
|
||||
%{C++
|
||||
|
|
|
@ -5,14 +5,15 @@
|
|||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "SmsChild.h"
|
||||
#include "SmsMessage.h"
|
||||
#include "MmsMessage.h"
|
||||
|
||||
#include "SmsMessageInternal.h"
|
||||
#include "MmsMessageInternal.h"
|
||||
#include "DeletedMessageInfo.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/mobilemessage/Constants.h" // For MessageType
|
||||
#include "MobileMessageThread.h"
|
||||
#include "MobileMessageThreadInternal.h"
|
||||
#include "MainThreadUtils.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
@ -28,10 +29,10 @@ CreateMessageFromMessageData(const MobileMessageData& aData)
|
|||
|
||||
switch(aData.type()) {
|
||||
case MobileMessageData::TMmsMessageData:
|
||||
message = new MmsMessage(aData.get_MmsMessageData());
|
||||
message = new MmsMessageInternal(aData.get_MmsMessageData());
|
||||
break;
|
||||
case MobileMessageData::TSmsMessageData:
|
||||
message = new SmsMessage(aData.get_SmsMessageData());
|
||||
message = new SmsMessageInternal(aData.get_SmsMessageData());
|
||||
break;
|
||||
default:
|
||||
MOZ_CRASH("Unexpected type of MobileMessageData");
|
||||
|
@ -376,7 +377,8 @@ MobileMessageCursorChild::DoNotifyResult(const nsTArray<ThreadData>& aDataArray)
|
|||
NS_ENSURE_TRUE_VOID(threads.SetCapacity(length, fallible));
|
||||
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
nsCOMPtr<nsISupports> thread = new MobileMessageThread(aDataArray[i]);
|
||||
nsCOMPtr<nsISupports> thread =
|
||||
new MobileMessageThreadInternal(aDataArray[i]);
|
||||
NS_ENSURE_TRUE_VOID(threads.AppendElement(thread, fallible));
|
||||
NS_ENSURE_TRUE_VOID(autoArray.AppendElement(thread.get(), fallible));
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include "SmsIPCService.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "mozilla/dom/mobilemessage/SmsChild.h"
|
||||
#include "SmsMessage.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "mozilla/dom/MozMobileMessageManagerBinding.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
|
|
|
@ -5,17 +5,18 @@
|
|||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "SmsParent.h"
|
||||
|
||||
#include "nsISmsService.h"
|
||||
#include "nsIMmsService.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "nsIDOMMozSmsMessage.h"
|
||||
#include "nsIDOMMozMmsMessage.h"
|
||||
#include "nsISmsMessage.h"
|
||||
#include "nsIMmsMessage.h"
|
||||
#include "mozilla/unused.h"
|
||||
#include "SmsMessage.h"
|
||||
#include "MmsMessage.h"
|
||||
#include "SmsMessageInternal.h"
|
||||
#include "MmsMessageInternal.h"
|
||||
#include "nsIMobileMessageDatabaseService.h"
|
||||
#include "MobileMessageThread.h"
|
||||
#include "MobileMessageThreadInternal.h"
|
||||
#include "mozilla/dom/ipc/BlobParent.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/dom/File.h"
|
||||
|
@ -144,23 +145,23 @@ GetMobileMessageDataFromMessage(ContentParent* aParent,
|
|||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMMozMmsMessage> mmsMsg = do_QueryInterface(aMsg);
|
||||
nsCOMPtr<nsIMmsMessage> mmsMsg = do_QueryInterface(aMsg);
|
||||
if (mmsMsg) {
|
||||
if (!aParent) {
|
||||
NS_ERROR("Invalid ContentParent to convert MMS Message!");
|
||||
return false;
|
||||
}
|
||||
MmsMessageData data;
|
||||
if (!static_cast<MmsMessage*>(mmsMsg.get())->GetData(aParent, data)) {
|
||||
if (!static_cast<MmsMessageInternal*>(mmsMsg.get())->GetData(aParent, data)) {
|
||||
return false;
|
||||
}
|
||||
aData = data;
|
||||
return true;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMMozSmsMessage> smsMsg = do_QueryInterface(aMsg);
|
||||
nsCOMPtr<nsISmsMessage> smsMsg = do_QueryInterface(aMsg);
|
||||
if (smsMsg) {
|
||||
aData = static_cast<SmsMessage*>(smsMsg.get())->GetData();
|
||||
aData = static_cast<SmsMessageInternal*>(smsMsg.get())->GetData();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -296,7 +297,7 @@ SmsParent::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
}
|
||||
|
||||
if (!strcmp(aTopic, kSilentSmsReceivedObserverTopic)) {
|
||||
nsCOMPtr<nsIDOMMozSmsMessage> smsMsg = do_QueryInterface(aSubject);
|
||||
nsCOMPtr<nsISmsMessage> smsMsg = do_QueryInterface(aSubject);
|
||||
if (!smsMsg) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -308,7 +309,7 @@ SmsParent::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
}
|
||||
|
||||
MobileMessageData msgData =
|
||||
static_cast<SmsMessage*>(smsMsg.get())->GetData();
|
||||
static_cast<SmsMessageInternal*>(smsMsg.get())->GetData();
|
||||
Unused << SendNotifyReceivedSilentMessage(msgData);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -906,18 +907,18 @@ MobileMessageCursorParent::NotifyCursorResult(nsISupports** aResults,
|
|||
// error here to avoid sending a message to the dead process.
|
||||
NS_ENSURE_TRUE(mContinueCallback, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDOMMozMobileMessageThread> iThread =
|
||||
nsCOMPtr<nsIMobileMessageThread> iThread =
|
||||
do_QueryInterface(aResults[0]);
|
||||
if (iThread) {
|
||||
nsTArray<ThreadData> threads;
|
||||
|
||||
for (uint32_t i = 0; i < aSize; i++) {
|
||||
nsCOMPtr<nsIDOMMozMobileMessageThread> iThread =
|
||||
nsCOMPtr<nsIMobileMessageThread> iThread =
|
||||
do_QueryInterface(aResults[i]);
|
||||
NS_ENSURE_TRUE(iThread, NS_ERROR_FAILURE);
|
||||
|
||||
MobileMessageThread* thread =
|
||||
static_cast<MobileMessageThread*>(iThread.get());
|
||||
MobileMessageThreadInternal* thread =
|
||||
static_cast<MobileMessageThreadInternal*>(iThread.get());
|
||||
threads.AppendElement(thread->GetData());
|
||||
}
|
||||
|
||||
|
@ -928,18 +929,20 @@ MobileMessageCursorParent::NotifyCursorResult(nsISupports** aResults,
|
|||
ContentParent* parent = static_cast<ContentParent*>(Manager()->Manager());
|
||||
nsTArray<MobileMessageData> messages;
|
||||
for (uint32_t i = 0; i < aSize; i++) {
|
||||
nsCOMPtr<nsIDOMMozSmsMessage> iSms = do_QueryInterface(aResults[i]);
|
||||
if (iSms) {
|
||||
SmsMessage* sms = static_cast<SmsMessage*>(iSms.get());
|
||||
messages.AppendElement(sms->GetData());
|
||||
nsCOMPtr<nsISmsMessage> sms = do_QueryInterface(aResults[i]);
|
||||
if (sms) {
|
||||
messages.AppendElement(
|
||||
static_cast<SmsMessageInternal*>(sms.get())->GetData());
|
||||
continue;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMMozMmsMessage> iMms = do_QueryInterface(aResults[i]);
|
||||
if (iMms) {
|
||||
MmsMessage* mms = static_cast<MmsMessage*>(iMms.get());
|
||||
nsCOMPtr<nsIMmsMessage> mms = do_QueryInterface(aResults[i]);
|
||||
if (mms) {
|
||||
MmsMessageData mmsData;
|
||||
NS_ENSURE_TRUE(mms->GetData(parent, mmsData), NS_ERROR_FAILURE);
|
||||
NS_ENSURE_TRUE(
|
||||
static_cast<MmsMessageInternal*>(mms.get())->GetData(parent, mmsData),
|
||||
NS_ERROR_FAILURE
|
||||
);
|
||||
messages.AppendElement(mmsData);
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -60,12 +60,15 @@ UNIFIED_SOURCES += [
|
|||
'ipc/SmsIPCService.cpp',
|
||||
'ipc/SmsParent.cpp',
|
||||
'MmsMessage.cpp',
|
||||
'MmsMessageInternal.cpp',
|
||||
'MobileMessageCallback.cpp',
|
||||
'MobileMessageCursorCallback.cpp',
|
||||
'MobileMessageManager.cpp',
|
||||
'MobileMessageService.cpp',
|
||||
'MobileMessageThread.cpp',
|
||||
'MobileMessageThreadInternal.cpp',
|
||||
'SmsMessage.cpp',
|
||||
'SmsMessageInternal.cpp',
|
||||
]
|
||||
|
||||
IPDL_SOURCES += [
|
||||
|
|
|
@ -236,7 +236,7 @@ function sendMmsWithFailure(aMmsParameters, aSendParameters) {
|
|||
/**
|
||||
* Retrieve message by message id.
|
||||
*
|
||||
* Fulfill params: MozSmsMessage
|
||||
* Fulfill params: SmsMessage
|
||||
* Reject params:
|
||||
* event -- a DOMEvent
|
||||
*
|
||||
|
@ -481,7 +481,7 @@ function sendTextSmsToEmulator(aFrom, aText) {
|
|||
/**
|
||||
* Send simple text SMS to emulator and wait for a received event.
|
||||
*
|
||||
* Fulfill params: MozSmsMessage
|
||||
* Fulfill params: SmsMessage
|
||||
* Reject params: (none)
|
||||
*
|
||||
* @param aFrom
|
||||
|
|
|
@ -53,7 +53,7 @@ function saveMmsNotification() {
|
|||
.saveReceivedMessage(notification, function(aRv, aDomMessage) {
|
||||
log("saveReceivedMessage(): " + aRv);
|
||||
if (Components.isSuccessCode(aRv)) {
|
||||
deferred.resolve(aDomMessage);
|
||||
deferred.resolve(aDomMessage.QueryInterface(Ci.nsIMmsMessage));
|
||||
} else {
|
||||
deferred.reject();
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ const LONG_BODY = new Array(17).join(SHORT_BODY);
|
|||
ok(LONG_BODY.length > 160, "LONG_BODY.length");
|
||||
|
||||
function checkMessage(aMessage, aBody) {
|
||||
ok(aMessage instanceof MozSmsMessage, "Message is instanceof MozSmsMessage");
|
||||
ok(aMessage instanceof SmsMessage, "Message is instanceof SmsMessage");
|
||||
|
||||
is(aMessage.type, "sms", "message.type");
|
||||
ok(aMessage.id, "message.id");
|
||||
|
|
|
@ -34,7 +34,7 @@ function sendSmsPduToEmulator(pdu) {
|
|||
}
|
||||
|
||||
function checkMessage(message, id, threadId, messageClass) {
|
||||
ok(message instanceof MozSmsMessage,
|
||||
ok(message instanceof SmsMessage,
|
||||
"message is instanceof " + message.constructor);
|
||||
if (id == null) {
|
||||
ok(message.id > 0, "message.id");
|
||||
|
|
|
@ -24,7 +24,7 @@ const LONG_BODY = "Let me not to the marriage of true minds\n"
|
|||
|
||||
function checkMessage(message, delivery, body) {
|
||||
ok(message, "message is valid");
|
||||
ok(message instanceof MozSmsMessage,
|
||||
ok(message instanceof SmsMessage,
|
||||
"message is instanceof " + message.constructor);
|
||||
|
||||
is(message.type, "sms", "message.type");
|
||||
|
|
|
@ -15,13 +15,14 @@
|
|||
|
||||
/** Test for WebSMS **/
|
||||
|
||||
// idl interfaces exposed to every page.
|
||||
// TODO Bug 859764
|
||||
const IDL_IFACE_WITH_PREFIX = ["SmsMessage", "MmsMessage", "MobileMessageThread"];
|
||||
|
||||
// webidl interfaces guarded by [AvailableIn=CertifiedApps].
|
||||
const WEBIDL_IFACE_WITH_PREFIX = ["SmsEvent", "MmsEvent", "MessageDeletedEvent"];
|
||||
const WEBIDL_IFACE = ["DOMMobileMessageError"];
|
||||
const WEBIDL_IFACE = [
|
||||
"DOMMobileMessageError",
|
||||
"MmsMessage",
|
||||
"MobileMessageThread",
|
||||
"SmsMessage",
|
||||
];
|
||||
|
||||
function checkSmsDisabled() {
|
||||
ok(!('mozMobileMessage' in frames[0].navigator), "navigator.mozMobileMessage should not exist");
|
||||
|
@ -42,14 +43,6 @@ function checkSmsEnabled() {
|
|||
"navigator.mozMobileMessage is an MobileMessageManager object");
|
||||
}
|
||||
|
||||
function checkIdlInterfaceInWindow() {
|
||||
for (let i = 0; i < IDL_IFACE_WITH_PREFIX.length; i++) {
|
||||
let iface = IDL_IFACE_WITH_PREFIX[i];
|
||||
ok(!(iface in window), iface + " should be prefixed");
|
||||
ok(("Moz" + iface) in window, iface + " should be prefixed");
|
||||
}
|
||||
}
|
||||
|
||||
function checkWebidlInterfaceInWindow() {
|
||||
for (let i = 0; i < WEBIDL_IFACE_WITH_PREFIX.length; i++) {
|
||||
let iface = WEBIDL_IFACE_WITH_PREFIX[i];
|
||||
|
@ -77,7 +70,6 @@ function checkWebidlInterfaceNotInWindow() {
|
|||
}
|
||||
|
||||
function test() {
|
||||
checkIdlInterfaceInWindow();
|
||||
checkWebidlInterfaceNotInWindow();
|
||||
|
||||
// If sms is disabled and permission is removed, sms is disabled.
|
||||
|
|
|
@ -34,7 +34,7 @@ function run_test() {
|
|||
add_test(function test_interface() {
|
||||
let sms = newMessage(null, null, ICC_ID, "sent", "success", null, null, null,
|
||||
"normal", Date.now(), Date.now(), Date.now(), true);
|
||||
do_check_true(sms instanceof Ci.nsIDOMMozSmsMessage);
|
||||
do_check_true(sms instanceof Ci.nsISmsMessage);
|
||||
do_check_eq(sms.id, 0);
|
||||
do_check_eq(sms.threadId, 0);
|
||||
do_check_eq(sms.iccId, ICC_ID);
|
||||
|
@ -54,7 +54,7 @@ add_test(function test_interface() {
|
|||
add_test(function test_icc_id_not_available() {
|
||||
let sms = newMessage(null, null, null, "sent", "success", null, null, null,
|
||||
"normal", Date.now(), Date.now(), Date.now(), true);
|
||||
do_check_true(sms instanceof Ci.nsIDOMMozSmsMessage);
|
||||
do_check_true(sms instanceof Ci.nsISmsMessage);
|
||||
do_check_eq(sms.id, 0);
|
||||
do_check_eq(sms.threadId, 0);
|
||||
do_check_eq(sms.iccId, null);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
interface nsIDOMDOMRequest;
|
||||
|
||||
[scriptable, uuid(ceb874cd-cc1a-4e65-b404-cc2d3e42425f)]
|
||||
[scriptable, uuid(72c4e583-389d-4d1b-9424-702feabb6055)]
|
||||
interface nsIDOMMozNetworkStatsManager : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -40,7 +40,7 @@ interface nsIDOMMozNetworkStatsManager : nsISupports
|
|||
* If success, the |result| field of the DOMRequest keeps the alarm Id.
|
||||
*/
|
||||
nsIDOMDOMRequest addAlarm(in nsISupports network,
|
||||
in long threshold,
|
||||
in long long threshold,
|
||||
[optional] in jsval options /* NetworkStatsAlarmOptions */);
|
||||
|
||||
/**
|
||||
|
|
|
@ -147,6 +147,51 @@ var steps = [
|
|||
ok(false, "getAllAlarms() shouldn't fail.");
|
||||
}
|
||||
},
|
||||
// Bug 1209654 - Test threshold value will overflow or not for 2^32.
|
||||
function () {
|
||||
ok(true, "Calling addAlarm() with threshold greater than 4GiB");
|
||||
|
||||
req = navigator.mozNetworkStats
|
||||
.addAlarm(new window.MozNetworkStatsInterface(wifi), 5000000000);
|
||||
|
||||
req.onsuccess = function () {
|
||||
ok(true, "Succeeded to add alarm. AlarmId: " + req.result);
|
||||
next();
|
||||
};
|
||||
req.onerror = function () {
|
||||
ok(false, "addAlarm() shouldn't fail.");
|
||||
};
|
||||
},
|
||||
function () {
|
||||
ok(true, "Calling getAllAlarms() and check threshold.");
|
||||
|
||||
req = navigator.mozNetworkStats.getAllAlarms();
|
||||
|
||||
req.onsuccess = function () {
|
||||
ok(Array.isArray(req.result) && req.result[0].threshold == 5000000000,
|
||||
"Succeeded to check threshold.");
|
||||
next();
|
||||
};
|
||||
|
||||
req.onerror = function () {
|
||||
ok(false, "getAllAlarms() shouldn't fail.");
|
||||
}
|
||||
},
|
||||
// Bug 1209654 - Test threshold value will overflow or not for signed long.
|
||||
function () {
|
||||
ok(true, "Calling addAlarm() with threshold 3 Gib");
|
||||
|
||||
req = navigator.mozNetworkStats
|
||||
.addAlarm(new window.MozNetworkStatsInterface(wifi), 3000000000);
|
||||
|
||||
req.onsuccess = function () {
|
||||
ok(true, "Succeeded to add alarm. AlarmId: " + req.result);
|
||||
next();
|
||||
};
|
||||
req.onerror = function () {
|
||||
ok(false, "addAlarm() shouldn't fail.");
|
||||
};
|
||||
},
|
||||
function () {
|
||||
ok(true, "all done!\n");
|
||||
SimpleTest.finish();
|
||||
|
|
|
@ -5,8 +5,11 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "MozIsoDepTech.h"
|
||||
#include "TagUtils.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
|
||||
using namespace mozilla::dom::nfc;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
|
@ -35,7 +38,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MozIsoDepTech)
|
|||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
const NFCTechType MozIsoDepTech::mTechnology = NFCTechType::ISO_DEP;
|
||||
const NFCTechType MozIsoDepTech::sTechnology = NFCTechType::ISO_DEP;
|
||||
|
||||
/* static */
|
||||
already_AddRefed<MozIsoDepTech>
|
||||
|
@ -50,14 +53,7 @@ MozIsoDepTech::Constructor(const GlobalObject& aGlobal,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Nullable<nsTArray<NFCTechType>> techList;
|
||||
aNFCTag.GetTechList(techList, rv);
|
||||
if (rv.Failed()) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (techList.IsNull() || !(techList.Value().Contains(mTechnology))) {
|
||||
if (!TagUtils::IsTechSupported(aNFCTag, sTechnology)) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -80,16 +76,7 @@ MozIsoDepTech::~MozIsoDepTech()
|
|||
already_AddRefed<Promise>
|
||||
MozIsoDepTech::Transceive(const Uint8Array& aCommand, ErrorResult& aRv)
|
||||
{
|
||||
ErrorResult rv;
|
||||
|
||||
aCommand.ComputeLengthAndData();
|
||||
RefPtr<Promise> promise = mTag->Transceive(mTechnology, aCommand, rv);
|
||||
if (rv.Failed()) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return promise.forget();
|
||||
return TagUtils::Transceive(mTag, sTechnology, aCommand, aRv);
|
||||
}
|
||||
|
||||
JSObject*
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче