Advertisement
Guest User

Untitled

a guest
Jan 29th, 2015
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. diff --git a/dom/presentation/Session.cpp b/dom/presentation/Session.cpp
  2. --- a/dom/presentation/Session.cpp
  3. +++ b/dom/presentation/Session.cpp
  4. @@ -15,16 +15,20 @@
  5. #include "nsISupportsPrimitives.h"
  6. #include "nsIDNSService.h"
  7. #include "nsISocketTransport.h"
  8. #include "nsISocketTransportService.h"
  9. #include "nsISimpleEnumerator.h"
  10. #include "PresentationSessionTransport.h"
  11. #include "PresentationService.h"
  12.  
  13. +#ifdef MOZ_WIDGET_GONK
  14. +#include "nsINetworkManager.h"
  15. +#endif
  16. +
  17. namespace mozilla {
  18. namespace dom {
  19. namespace presentation {
  20.  
  21. namespace {
  22.  
  23. class PresentationChannelDescription MOZ_FINAL : public nsIPresentationChannelDescription
  24. {
  25. @@ -163,20 +167,47 @@ Requester::NotifyReceiverReady()
  26. mServerSocket = do_CreateInstance(NS_SERVERSOCKET_CONTRACTID);
  27. mServerSocket->Init(-1, true, -1);
  28. mServerSocket->AsyncListen(this);
  29.  
  30. // prepare offer and send to remote endpoint
  31. int32_t serverPort;
  32. mServerSocket->GetPort(&serverPort);
  33.  
  34. + nsCString host;
  35. +#ifdef MOZ_WIDGET_GONK
  36. + nsCOMPtr<nsINetworkManager> networkManager =
  37. + do_GetService("@mozilla.org/network/manager;1");
  38. + nsCOMPtr<nsINetworkInterface> active;
  39. + networkManager->GetActive(getter_AddRefs(active));
  40. + if (NS_WARN_IF(!active)) {
  41. + mControlChannel->Close(NS_ERROR_FAILURE);
  42. + return NS_OK;
  43. + }
  44. + char16_t **ips = nullptr;
  45. + uint32_t *prefixs = nullptr;
  46. + uint32_t count = 0;
  47. + active->GetAddresses(&ips, &prefixs, &count);
  48. + if (NS_WARN_IF(!count)) {
  49. + nsMemory::Free(prefixs);
  50. + NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, ips);
  51. + mControlChannel->Close(NS_ERROR_FAILURE);
  52. + return NS_OK;
  53. + }
  54. + nsAutoString ip;
  55. + ip.Assign(ips[0]);
  56. + host = NS_ConvertUTF16toUTF8(ip);
  57. +
  58. + nsMemory::Free(prefixs);
  59. + NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, ips);
  60. +#else
  61. //XXX Does it really work?
  62. nsCOMPtr<nsIDNSService> dns = do_GetService(NS_DNSSERVICE_CONTRACTID);
  63. - nsCString host;
  64. dns->GetMyHostName(host);
  65. +#endif
  66.  
  67. nsRefPtr<PresentationChannelDescription> offer =
  68. new PresentationChannelDescription(host, static_cast<uint16_t>(serverPort));
  69. mControlChannel->SendOffer(offer);
  70.  
  71. return NS_OK;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement