purplexpcom/src/purpleDNS.h
author aleth <aleth@instantbird.org>
Wed, 09 Jul 2014 20:33:32 +0200
changeset 737 b0681d7c96db64cdbdd931e01ffe43d65a23e0e5
parent 687 a616b34ed68066c5005923bc54e8c7877eb2d0fd
child 768 b35d07fd309b19b942732cdabe20fde4a076db6d
permissions -rw-r--r--
Bug 1036367 - Fix dangerous public destructors in purple/. r=florian

/* 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 <nsCOMPtr.h>
#include <nsCOMArray.h>

#pragma GCC visibility push(default)
#include <glib.h>
#include <libpurple/dnsquery.h>
#pragma GCC visibility pop

#include <nsIDNSService.h>
#include <nsIDNSRecord.h>
#include <nsIDNSListener.h>

class purpleDNSRequest MOZ_FINAL : public nsIDNSListener
{
  NS_DECL_THREADSAFE_ISUPPORTS
  NS_DECL_NSIDNSLISTENER

  purpleDNSRequest();
  PRUint32 mAccountId;
  PurpleDnsQueryData *query_data;
  PurpleDnsQueryResolvedCallback resolved_cb;
  PurpleDnsQueryFailedCallback failed_cb;
  nsCOMPtr<nsICancelable> asyncResolv;

 private:
  ~purpleDNSRequest();
  inline void Failed(const char *aMsg);
};

class purpleDNS
{
 public:
  static void init();
  static void unInit();

  static gboolean Resolve(PurpleDnsQueryData *query_data,
                          PurpleDnsQueryResolvedCallback resolved_cb,
                          PurpleDnsQueryFailedCallback failed_cb);
  static void Cancel(PurpleDnsQueryData *query_data);

  static nsresult Remove(PurpleDnsQueryData *query_data);

 private:
  static nsCOMArray<purpleDNSRequest> *sRequests;
};