nsSystemTrayServiceWin.h
Go to the documentation of this file.
1 /* ***** BEGIN LICENSE BLOCK *****
2  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3  *
4  * The contents of this file are subject to the Mozilla Public License Version
5  * 1.1 (the "License"); you may not use this file except in compliance with
6  * the License. You may obtain a copy of the License at
7  * http://www.mozilla.org/MPL/
8  *
9  * Software distributed under the License is distributed on an "AS IS" basis,
10  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11  * for the specific language governing rights and limitations under the
12  * License.
13  *
14  * The Original Code is MinimizeToTray.
15  *
16  * The Initial Developer of the Original Code are
17  * Mark Yen and Brad Peterson.
18  * Portions created by the Initial Developer are Copyright (C) 2004
19  * the Initial Developer. All Rights Reserved.
20  *
21  * Contributor(s):
22  * Mark Yen <mook.moz+cvs.mozilla.org@gmail.com>, Original author
23  * Brad Peterson <b_peterson@yahoo.com>, Original author
24  * Daniel Glazman <daniel.glazman@disruptive-innovations.com>
25  * Matthew Gertner <matthew@allpeers.com>
26  *
27  * Alternatively, the contents of this file may be used under the terms of
28  * either the GNU General Public License Version 2 or later (the "GPL"), or
29  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30  * in which case the provisions of the GPL or the LGPL are applicable instead
31  * of those above. If you wish to allow use of your version of this file only
32  * under the terms of either the GPL or the LGPL, and not to allow others to
33  * use your version of this file under the terms of the MPL, indicate your
34  * decision by deleting the provisions above and replace them with the notice
35  * and other provisions required by the GPL or the LGPL. If you do not delete
36  * the provisions above, a recipient may use your version of this file under
37  * the terms of any one of the MPL, the GPL or the LGPL.
38  *
39  * ***** END LICENSE BLOCK ***** */
40 
41 #ifndef ULONG_PTR
42 #define ULONG_PTR DWORD
43 #endif
44 
45 #ifndef nsSystemTrayService_h__
46 #define nsSystemTrayService_h__
47 
48 // needed for QueueUserAPC
49 #ifdef _WIN32_WINNT
50 #undef _WIN32_WINNT
51 #endif
52 #define _WIN32_WINNT 0x0400
53 
54 #include <windows.h>
55 #include <shellapi.h>
56 
57 #include "nsISystemTrayService.h"
58 #include "imgIDecoderObserver.h"
59 #include "imgILoad.h"
60 #include "nsIDOMEventListener.h"
61 #include "nsCOMPtr.h"
62 #include "nsDataHashtable.h"
63 
64 class nsIDOMWindow;
65 class nsIURI;
66 class nsIXULWindow;
67 
68 // {F53FCEFA-2F53-40cf-BBAF-2F5896A56E82}
69 #define NS_SYSTEMTRAYSERVICE_CID \
70  { 0xf53fcefa, 0x2f53, 0x40cf, \
71  { 0xbb, 0xaf, 0x2f, 0x58, 0x96, 0xa5, 0x6e, 0x82 } }
72 
73 #define NS_SYSTEMTRAYSERVICE_CONTRACTID \
74  "@mozilla.org/system-tray-service;1"
75 
76 #define NS_SYSTEMTRAYSERVICE_CLASSNAME "System Tray Service"
77 
78 class nsIDOMAbstractView;
79 class nsIDOMDocumentEvent;
80 class nsIDOMElement;
81 class nsIDOMEvent;
82 class nsIDOMEventTarget;
83 class nsIURI;
84 
86  public imgILoad, public imgIDecoderObserver
87 {
88 public:
90  NS_DECL_NSISYSTEMTRAYSERVICE
91  NS_DECL_IMGICONTAINEROBSERVER
92  NS_DECL_IMGIDECODEROBSERVER
93  NS_DECL_IMGILOAD
94 
96 
97  nsresult Init();
98 
99 private:
101 
102 protected:
103  nsresult AddTrayIcon(HWND hwnd, nsIURI* iconURI, const nsAString& iconId,
104  nsIDOMElement* targetElement);
105  nsresult GetIconForWnd(HWND hwnd, HICON& result);
106  nsresult GetIconForURI(nsIURI* iconURI, HICON& result);
107  nsresult CreateListenerWindow(HWND* listenerWindow,
108  nsIDOMElement* targetElement);
109  nsresult GetDOMWindow(nsIXULWindow* xulWindow, nsIDOMWindow** _retval);
110 
111  static nsresult CreateEvent(nsIDOMDocumentEvent* documentEvent,
112  const nsAString& typeArg, nsIDOMEvent** _retval);
113  static nsresult CreateMouseEvent(nsIDOMDocumentEvent* documentEvent,
114  const nsAString& typeArg, nsIDOMAbstractView* viewArg, PRInt32 detailArg,
115  PRInt32 screenXArg, PRInt32 screenYArg, PRInt32 clientXArg,
116  PRInt32 clientYArg, PRBool ctrlKeyArg, PRBool altKeyArg,
117  PRBool shiftKeyArg, PRBool metkeyArg, PRUint16 buttonArg,
118  nsIDOMEvent** _retval);
119 
120  static LRESULT CALLBACK WindowProc(
121  HWND hwnd,
122  UINT uMsg,
123  WPARAM wParam,
124  LPARAM lParam
125  );
126 
127  /* additional members */
128  static ATOM s_wndClass;
129  nsDataHashtable<nsStringHashKey, NOTIFYICONDATAW> mIconDataMap;
130  nsCOMPtr<imgIContainer> mImage;
131 
132  /* window property constants */
133  static const TCHAR* S_PROPINST;
134  static const TCHAR* S_PROPPROC;
135 };
136 
137 #endif // nsSystemTrayService_h__
nsCOMPtr< imgIContainer > mImage
NS_DECL_ISUPPORTS NS_DECL_NSISYSTEMTRAYSERVICE nsSystemTrayService()
static const TCHAR * S_PROPPROC
nsresult GetIconForWnd(HWND hwnd, HICON &result)
nsresult CreateListenerWindow(HWND *listenerWindow, nsIDOMElement *targetElement)
struct HICON__ * HICON
static nsresult CreateMouseEvent(nsIDOMDocumentEvent *documentEvent, const nsAString &typeArg, nsIDOMAbstractView *viewArg, PRInt32 detailArg, PRInt32 screenXArg, PRInt32 screenYArg, PRInt32 clientXArg, PRInt32 clientYArg, PRBool ctrlKeyArg, PRBool altKeyArg, PRBool shiftKeyArg, PRBool metkeyArg, PRUint16 buttonArg, nsIDOMEvent **_retval)
const nsIDOMWindow
nsresult AddTrayIcon(HWND hwnd, nsIURI *iconURI, const nsAString &iconId, nsIDOMElement *targetElement)
static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
nsDataHashtable< nsStringHashKey, NOTIFYICONDATAW > mIconDataMap
nsresult GetDOMWindow(nsIXULWindow *xulWindow, nsIDOMWindow **_retval)
nsresult GetIconForURI(nsIURI *iconURI, HICON &result)
static const TCHAR * S_PROPINST
static nsresult CreateEvent(nsIDOMDocumentEvent *documentEvent, const nsAString &typeArg, nsIDOMEvent **_retval)