sbDeviceEvent.h
Go to the documentation of this file.
1 /* vim: set sw=2 :miv */
2 /*
3 //
4 // BEGIN SONGBIRD GPL
5 //
6 // This file is part of the Songbird web player.
7 //
8 // Copyright(c) 2005-2008 POTI, Inc.
9 // http://songbirdnest.com
10 //
11 // This file may be licensed under the terms of of the
12 // GNU General Public License Version 2 (the "GPL").
13 //
14 // Software distributed under the License is distributed
15 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
16 // express or implied. See the GPL for the specific language
17 // governing rights and limitations.
18 //
19 // You should have received a copy of the GPL along with this
20 // program. If not, go to http://www.gnu.org/licenses/gpl.html
21 // or write to the Free Software Foundation, Inc.,
22 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 //
24 // END SONGBIRD GPL
25 //
26 */
27 
28 #include <nsIVariant.h>
29 #include "sbIDeviceEvent.h"
30 
31 #include <nsCOMPtr.h>
32 #include "sbIDeviceEventTarget.h"
33 
34 class nsIVariant;
35 
36 #define SBDEVICEEVENT_IID \
37  {0xad7c89b5, 0x52f8, 0x487f, \
38  { 0x90, 0xf7, 0x2f, 0x79, 0xab, 0x8a, 0x84, 0x6b } }
39 
41 {
42 public:
44  NS_DECL_SBIDEVICEEVENT
45 
46  nsresult InitEvent(PRUint32 aType,
47  nsIVariant *aData,
48  nsISupports *aOrigin,
49  PRUint32 aDeviceState,
50  PRUint32 aDeviceSubState);
51  static sbDeviceEvent* CreateEvent();
52 
53 protected:
54  sbDeviceEvent();
56 
57 public:
58  NS_DECLARE_STATIC_IID_ACCESSOR(SBDEVICEEVENT_IID)
59  virtual void Dispatch() { mWasDispatched = PR_TRUE; }
60  virtual PRBool WasDispatched() { return mWasDispatched; }
61  virtual nsresult SetTarget(sbIDeviceEventTarget* aTarget);
62 
63  // XXXAus: This static CreateEvent method is necessary
64  // to accommodate our static linking of the CRT. Otherwise
65  // the event would get deallocated with the wrong allocator.
66  static nsresult CreateEvent(PRUint32 aType,
67  nsIVariant *aData,
68  nsISupports *aOrigin,
69  PRUint32 aDeviceState,
70  PRUint32 aDeviceSubState,
71  sbIDeviceEvent **_retval);
72 
73 protected:
74  PRUint32 mType;
75  nsCOMPtr<nsIVariant> mData;
76  nsCOMPtr<sbIDeviceEventTarget> mTarget;
77  nsCOMPtr<nsISupports> mOrigin;
79  PRUint32 mDeviceState;
80  PRUint32 mDeviceSubState;
81 };
82 
83 /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
84 #define NS_FORWARD_SAFE_SBDEVICEEVENT(_to) \
85  void Dispatch() { NS_ASSERTION(_to, "_to is null"); if (_to) _to->Dispatch(); } \
86  PRBool WasDispatched() { NS_ASSERTION(_to, "_to is null"); return !_to ? PR_FALSE : _to->WasDispatched(); } \
87  nsresult SetTarget(sbIDeviceEventTarget* aTarget) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetTarget(aTarget); }
88 
89 NS_DEFINE_STATIC_IID_ACCESSOR(sbDeviceEvent, SBDEVICEEVENT_IID)
nsCOMPtr< sbIDeviceEventTarget > mTarget
Definition: sbDeviceEvent.h:76
static sbDeviceEvent * CreateEvent()
#define SBDEVICEEVENT_IID
Definition: sbDeviceEvent.h:36
virtual PRBool WasDispatched()
Definition: sbDeviceEvent.h:60
PRUint32 mType
Definition: sbDeviceEvent.h:74
NS_DECL_ISUPPORTS NS_DECL_SBIDEVICEEVENT nsresult InitEvent(PRUint32 aType, nsIVariant *aData, nsISupports *aOrigin, PRUint32 aDeviceState, PRUint32 aDeviceSubState)
virtual nsresult SetTarget(sbIDeviceEventTarget *aTarget)
virtual void Dispatch()
Definition: sbDeviceEvent.h:59
PRUint32 mDeviceSubState
Definition: sbDeviceEvent.h:80
nsCOMPtr< nsISupports > mOrigin
Definition: sbDeviceEvent.h:77
PRUint32 mDeviceState
Definition: sbDeviceEvent.h:79
nsCOMPtr< nsIVariant > mData
Definition: sbDeviceEvent.h:75
PRBool mWasDispatched
Definition: sbDeviceEvent.h:78
_updateTextAndScrollDataForFrame aData