dom/icc/src/StkCommandEvent.h
author Matt Brubeck <mbrubeck@mozilla.com>
Thu, 18 Apr 2013 22:29:25 -0700
changeset 140245 583bf36efce8741279509aa7bee18fbb36d05850
parent 140242 f53ad2a10ff8bcdd821c51e5e3082eb56dc2fbb4
child 140331 dcee2cd3394a2c3e0fbba7304da1abe1a5f7a5b5
permissions -rw-r--r--
Back out cd218e07ede2, e57ac5581703, f53ad2a10ff8, ec91252c57d2, 2eca17711eff, 1997e63a1124 for build errors

/* 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_icc_stkcommandevent_h
#define mozilla_dom_icc_stkcommandevent_h

#include "nsDOMEvent.h"
#include "SimToolKit.h"

namespace mozilla {
namespace dom {
namespace icc {

class StkCommandEvent : public nsDOMEvent,
                        public nsIDOMMozStkCommandEvent
{
  nsString mCommand;

public:
  NS_DECL_ISUPPORTS_INHERITED
  NS_FORWARD_TO_NSDOMEVENT
  NS_DECL_NSIDOMMOZSTKCOMMANDEVENT
  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(StkCommandEvent, nsDOMEvent)

  static already_AddRefed<StkCommandEvent>
  Create(mozilla::dom::EventTarget* aOwner, const nsAString& aMessage);

  nsresult
  Dispatch(nsIDOMEventTarget* aTarget, const nsAString& aEventType)
  {
    NS_ASSERTION(aTarget, "Null pointer!");
    NS_ASSERTION(!aEventType.IsEmpty(), "Empty event type!");

    nsresult rv = InitEvent(aEventType, false, false);
    NS_ENSURE_SUCCESS(rv, rv);

    SetTrusted(true);

    nsDOMEvent* thisEvent = this;

    bool dummy;
    rv = aTarget->DispatchEvent(thisEvent, &dummy);
    NS_ENSURE_SUCCESS(rv, rv);

    return NS_OK;
  }

private:
  StkCommandEvent(mozilla::dom::EventTarget* aOwner)
  : nsDOMEvent(aOwner, nullptr, nullptr)
  { }

  ~StkCommandEvent()
  { }
};

}
}
}

#endif // mozilla_dom_icc_stkcommandevent_h