Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/dom/presentation/Session.cpp b/dom/presentation/Session.cpp
- --- a/dom/presentation/Session.cpp
- +++ b/dom/presentation/Session.cpp
- @@ -15,16 +15,20 @@
- #include "nsISupportsPrimitives.h"
- #include "nsIDNSService.h"
- #include "nsISocketTransport.h"
- #include "nsISocketTransportService.h"
- #include "nsISimpleEnumerator.h"
- #include "PresentationSessionTransport.h"
- #include "PresentationService.h"
- +#ifdef MOZ_WIDGET_GONK
- +#include "nsINetworkManager.h"
- +#endif
- +
- namespace mozilla {
- namespace dom {
- namespace presentation {
- namespace {
- class PresentationChannelDescription MOZ_FINAL : public nsIPresentationChannelDescription
- {
- @@ -163,20 +167,47 @@ Requester::NotifyReceiverReady()
- mServerSocket = do_CreateInstance(NS_SERVERSOCKET_CONTRACTID);
- mServerSocket->Init(-1, true, -1);
- mServerSocket->AsyncListen(this);
- // prepare offer and send to remote endpoint
- int32_t serverPort;
- mServerSocket->GetPort(&serverPort);
- + nsCString host;
- +#ifdef MOZ_WIDGET_GONK
- + nsCOMPtr<nsINetworkManager> networkManager =
- + do_GetService("@mozilla.org/network/manager;1");
- + nsCOMPtr<nsINetworkInterface> active;
- + networkManager->GetActive(getter_AddRefs(active));
- + if (NS_WARN_IF(!active)) {
- + mControlChannel->Close(NS_ERROR_FAILURE);
- + return NS_OK;
- + }
- + char16_t **ips = nullptr;
- + uint32_t *prefixs = nullptr;
- + uint32_t count = 0;
- + active->GetAddresses(&ips, &prefixs, &count);
- + if (NS_WARN_IF(!count)) {
- + nsMemory::Free(prefixs);
- + NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, ips);
- + mControlChannel->Close(NS_ERROR_FAILURE);
- + return NS_OK;
- + }
- + nsAutoString ip;
- + ip.Assign(ips[0]);
- + host = NS_ConvertUTF16toUTF8(ip);
- +
- + nsMemory::Free(prefixs);
- + NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, ips);
- +#else
- //XXX Does it really work?
- nsCOMPtr<nsIDNSService> dns = do_GetService(NS_DNSSERVICE_CONTRACTID);
- - nsCString host;
- dns->GetMyHostName(host);
- +#endif
- nsRefPtr<PresentationChannelDescription> offer =
- new PresentationChannelDescription(host, static_cast<uint16_t>(serverPort));
- mControlChannel->SendOffer(offer);
- return NS_OK;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement