Author: jmagne
Update of /cvs/dirsec/esc/src/app/xpcom/tray
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv12696/tray
Modified Files:
Makefile Makefile.in Makefile.moz rhITray.idl
rhITrayWindNotify.idl rhLinuxTray.cpp rhMacTray.cpp rhTray.cpp
rhTray.h
Log Message:
Update to latest
Index: Makefile
===================================================================
RCS file: /cvs/dirsec/esc/src/app/xpcom/tray/Makefile,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- Makefile 12 Jun 2006 23:39:50 -0000 1.1.1.1
+++ Makefile 13 Sep 2006 17:50:07 -0000 1.2
@@ -29,14 +29,18 @@
#MOZ_OBJDIR=$(MOZ_SRCDIR)
endif
+ifeq ($(OS_ARCH),Linux)
+endif
+
all export install clean deploy args::
echo "***** Dropping into the Mozilla build environment ***** $(MOZ_OBJDIR)
$@"
+ echo $(DIST)
$(MAKE) -f Makefile.moz $@ \
OBJDIR=$(OBJDIR) \
CORE_DIST=$(DIST) \
CORE_INC=$(CORE_INC) \
MOZ_SRCDIR=$(MOZ_SRCDIR) \
- MOZ_OBJDIR=$(MOZ_OBJDIR)
+ MOZ_OBJDIR=$(MOZ_OBJDIR) \
libs::
@@ -45,13 +49,13 @@
CORE_DIST=$(DIST) \
CORE_INC=$(CORE_INC) \
MOZ_SRCDIR=$(MOZ_SRCDIR) \
- MOZ_OBJDIR=$(MOZ_OBJDIR)
+ MOZ_OBJ_DIR=$(MOZ_OBJDIR) \
$(MAKE) -f Makefile.moz deploy \
OBJDIR=$(OBJDIR) \
CORE_DIST=$(DIST) \
CORE_INC=$(CORE_INC) \
MOZ_SRCDIR=$(MOZ_SRCDIR) \
- MOZ_OBJDIR=$(MOZ_OBJDIR)
+ MOZ_OBJ_DIR=$(MOZ_OBJDIR)
Index: Makefile.in
===================================================================
RCS file: /cvs/dirsec/esc/src/app/xpcom/tray/Makefile.in,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- Makefile.in 12 Jun 2006 23:39:50 -0000 1.1.1.1
+++ Makefile.in 13 Sep 2006 17:50:07 -0000 1.2
@@ -23,18 +23,39 @@
CORE_INC=$(SOURCE_XP_DIR)/public
MOZ_SRCDIR=$(SOURCE_XP_DIR)/src/mozilla
-MOZ_OBJDIR=$(DIST)/xulrunner_build/mozilla
+MOZ_OBJDIR=$(DIST)/xulrunner_build
ifeq ($(OS_ARCH), Darwin)
#MOZ_OBJDIR=$(MOZ_SRCDIR)
endif
-all export libs install clean args::
- echo "***** Dropping into the Mozilla build environment ***** $(MOZ_OBJDIR)"
+ifeq ($(OS_ARCH),Linux)
+endif
+
+all export install clean deploy args::
+ echo "***** Dropping into the Mozilla build environment ***** $(MOZ_OBJDIR)
$@"
+ echo $(DIST)
$(MAKE) -f Makefile.moz $@ \
OBJDIR=$(OBJDIR) \
CORE_DIST=$(DIST) \
CORE_INC=$(CORE_INC) \
- MOZ_SRCDIR=$(MOZ_OBJDIR) \
- MOZ_OBJDIR=$(MOZ_OBJDIR)
+ MOZ_SRCDIR=$(MOZ_SRCDIR) \
+ MOZ_OBJDIR=$(MOZ_OBJDIR) \
+
+libs::
+
+ $(MAKE) -f Makefile.moz libs \
+ OBJDIR=$(OBJDIR) \
+ CORE_DIST=$(DIST) \
+ CORE_INC=$(CORE_INC) \
+ MOZ_SRCDIR=$(MOZ_SRCDIR) \
+ MOZ_OBJ_DIR=$(MOZ_OBJDIR) \
+
+ $(MAKE) -f Makefile.moz deploy \
+ OBJDIR=$(OBJDIR) \
+ CORE_DIST=$(DIST) \
+ CORE_INC=$(CORE_INC) \
+ MOZ_SRCDIR=$(MOZ_SRCDIR) \
+ MOZ_OBJ_DIR=$(MOZ_OBJDIR)
+
Index: Makefile.moz
===================================================================
RCS file: /cvs/dirsec/esc/src/app/xpcom/tray/Makefile.moz,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- Makefile.moz 12 Jun 2006 23:39:50 -0000 1.1.1.1
+++ Makefile.moz 13 Sep 2006 17:50:07 -0000 1.2
@@ -28,12 +28,20 @@
MDDEPDIR := $(OBJDIR)/.deps
DESTDIR = $(MOZ_OBJDIR)/install
+NOTIFY_DEPTH = $(CORE_DEPTH)/src/lib/notifytray
+NOTIFY_CXX_FLAGS = -I$(NOTIFY_DEPTH) $(shell pkg-config --cflags glib-2.0)
+NOTIFY_LDFLAGS = $(shell pkg-config --libs libnotify)
+
+NO_DIST_INSTALL = 1
+ifeq ($(OS_ARCH),Linux)
+
+endif
-include $(MOZ_OBJDIR)/config/autoconf.mk
OS_CXXFLAGS += $(HOST_CXXFLAGS)
-MODULE = rhTray
+#MODULE = rhTray
XPIDL_MODULE = rhTray
LIBRARY_NAME = rhTray
@@ -44,13 +52,19 @@
RESFILE=cool.res
endif
+ifeq ($(OS_ARCH),Linux)
+
+COOLKEY_LIBS+= -L $(CORE_DIST)/lib -ltraynotify -L/usr/lib $(NOTIFY_LDFLAGS)
+
+endif
+
IS_COMPONENT = 1
MODULE_NAME = rhTray
# Ensure that the xpcom classes that we build
# do not export themselves
-DEFINES += -DXPCOM_GLUE $(GECKO_INCLUDES)
+DEFINES += -DXPCOM_GLUE $(GECKO_INCLUDES) -I./_xpidlgen
REQUIRES = string \
@@ -71,9 +85,8 @@
ifeq ($(OS_ARCH),Linux)
CPPSRCS = \
- rhLinuxTray.cpp \
- $(NULL)
-
+ rhLinuxTray.cpp \
+ $(NULL)
endif
ifeq ($(OS_ARCH),Darwin)
@@ -93,7 +106,7 @@
INSTALL_STUFF =
ifeq ($(OS_ARCH),Linux)
-INSTALL_STUFF += CoolKeyLogo.gif
+INSTALL_STUFF += icon.png
endif
ifeq ($(OS_ARCH),WINNT)
@@ -104,16 +117,14 @@
ifeq ($(OS_ARCH),Linux)
-
-CXXFLAGS += $(MOZ_GTK_CFLAGS) $(MOZ_GTK2_CFLAGS)
-
+CXXFLAGS += $(MOZ_GTK_CFLAGS) $(MOZ_GTK2_CFLAGS) $(NOTIFY_CXX_FLAGS)
endif
all:: export libs deploy
libs:: $(INSTALL_STUFF) rhTray.h
- $(NSINSTALL) rhTray.h $(DIST)/include/rhTray
+ $(NSINSTALL) rhTray.h $(CORE_INC)/rhTray
clean::
@@ -122,8 +133,8 @@
deploy::
echo "Deploying"
echo $(IMPORT_LIBRARY)
- $(NSINSTALL) ./$(LIB_PREFIX)rhTray$(DLL_SUFFIX)
$(CORE_DEPTH)/esc/app/xul/esc/components
- $(NSINSTALL) ./_xpidlgen/*.xpt $(INSTALL_STUFF)
$(CORE_DEPTH)/esc/app/xul/esc/components
+ $(NSINSTALL) ./$(LIB_PREFIX)rhTray$(DLL_SUFFIX)
$(CORE_DEPTH)/src/app/xul/esc/components
+ $(NSINSTALL) ./_xpidlgen/*.xpt $(INSTALL_STUFF)
$(CORE_DEPTH)/src/app/xul/esc/components
# separate libraries linked in.
Index: rhITray.idl
===================================================================
RCS file: /cvs/dirsec/esc/src/app/xpcom/tray/rhITray.idl,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- rhITray.idl 12 Jun 2006 23:39:50 -0000 1.1.1.1
+++ rhITray.idl 13 Sep 2006 17:50:07 -0000 1.2
@@ -1,22 +1,5 @@
-/** BEGIN COPYRIGHT BLOCK
- * This Program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation; version 2 of the License.
- *
- * This Program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * Copyright (C) 2005 Red Hat, Inc.
- * All rights reserved.
- * END COPYRIGHT BLOCK **/
-
#include "nsISupports.idl"
-
+#include "rhITrayWindNotify.idl"
interface nsIBaseWindow;
[scriptable,uuid(18100a23-0e0f-4201-8378-c9625d09be39)]
@@ -31,7 +14,16 @@
void hideall();
void showall();
boolean isInitializedAlready();
- void sendnotification(in string aMessage);
+ void sendnotification(in string aTitle, in string aMessage,in unsigned long
aSeverity,in unsigned long aTimeout,in string aIcon);
+
+ void settooltipmsg(in string aMessage);
+ void seticonimage(in string aIcon);
+
+ void hideicon();
+ void showicon();
+
+ void setwindnotifycallback(in rhITrayWindNotify jsNotify);
+ void unsetwindnotifycallback(in rhITrayWindNotify jsNotify);
};
Index: rhITrayWindNotify.idl
===================================================================
RCS file: /cvs/dirsec/esc/src/app/xpcom/tray/rhITrayWindNotify.idl,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- rhITrayWindNotify.idl 12 Jun 2006 23:39:50 -0000 1.1.1.1
+++ rhITrayWindNotify.idl 13 Sep 2006 17:50:07 -0000 1.2
@@ -1,20 +1,3 @@
-/** BEGIN COPYRIGHT BLOCK
- * This Program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation; version 2 of the License.
- *
- * This Program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * Copyright (C) 2005 Red Hat, Inc.
- * All rights reserved.
- * END COPYRIGHT BLOCK **/
-
#include "nsISupports.idl"
Index: rhLinuxTray.cpp
===================================================================
RCS file: /cvs/dirsec/esc/src/app/xpcom/tray/rhLinuxTray.cpp,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- rhLinuxTray.cpp 12 Jun 2006 23:39:50 -0000 1.1.1.1
+++ rhLinuxTray.cpp 13 Sep 2006 17:50:07 -0000 1.2
@@ -15,18 +15,23 @@
* All rights reserved.
* END COPYRIGHT BLOCK **/
+#define FORCE_PR_LOG 1
+
#include "rhTray.h"
#include "nsIGenericFactory.h"
#include <prlog.h>
+#include "notifytray.h"
+#include "intl/nsIStringBundle.h"
NS_IMPL_ISUPPORTS1(rhTray, rhITray)
-
GtkWidget* rhTray::mWnd = NULL;
GtkWidget* rhTray::mIconMenu = NULL;
int rhTray::mInitialized = 0;
+std::list< nsCOMPtr<rhITrayWindNotify> > rhTray::gTrayWindNotifyListeners;
+
map< nsIBaseWindow *, rhTrayWindowListener *> rhTray::mWindowMap;
@@ -35,18 +40,45 @@
rhTray::rhTray()
{
/* member initializers and constructor code */
+
}
rhTray::~rhTray()
{
- PR_LOG( trayLog, 5, ("rhTray::~rhTray\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::~rhTray\n"));
Cleanup();
/* destructor code */
}
+NS_IMETHODIMP rhTray::Setwindnotifycallback(rhITrayWindNotify *jsNotify)
+{
+
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Setwindnotifycallback\n"));
+
+ if(jsNotify)
+ AddTrayWindNotifyListener(jsNotify);
+
+
+ return NS_OK;
+
+}
+ /* void unsetwindnotifycallback (in rhITrayWindNotify jsNotify); */
+
+NS_IMETHODIMP rhTray::Unsetwindnotifycallback(rhITrayWindNotify *jsNotify)
+{
+
+
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Unsetwindnotifycallback\n"));
+
+ if(jsNotify)
+ RemoveTrayWindNotifyListener(jsNotify);
+
+ return NS_OK;
+}
+
/* void add (); */
NS_IMETHODIMP rhTray::Add(nsIBaseWindow *aWindow)
{
@@ -54,7 +86,7 @@
NS_ENSURE_ARG(aWindow);
- PR_LOG( trayLog, 5, ("rhTray::Add %p \n",aWindow));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Add %p \n",aWindow));
HRESULT res = Initialize();
if(res != S_OK)
{
@@ -72,7 +104,7 @@
/* void remove (); */
NS_IMETHODIMP rhTray::Remove(nsIBaseWindow *aWindow)
{
- PR_LOG( trayLog, 5, ("rhTray::Remove window %p \n",aWindow));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Remove window %p \n",aWindow));
if(!aWindow)
return NS_OK;
@@ -133,9 +165,11 @@
}
-NS_IMETHODIMP rhTray::Sendnotification(const char *aMessage)
+NS_IMETHODIMP rhTray::Sendnotification(const char *aTitle,const char *aMessage,PRUint32
aSeverity,PRUint32 aTimeout, const char *aIcon)
{
+ if(aMessage)
+ notify_icon_send_tooltip_msg(aTitle,aMessage,aSeverity,aTimeout,aIcon);
return NS_OK;
@@ -156,7 +190,42 @@
return NS_OK;
}
+/* void settooltipmsg (in string aMessage); */
+NS_IMETHODIMP rhTray::Settooltipmsg(const char *aMessage)
+{
+
+ if(aMessage)
+ notify_icon_set_static_tooltip(aMessage);
+
+ return NS_OK;
+}
+
+/* void seticonimage (in string aIcon); */
+NS_IMETHODIMP rhTray::Seticonimage(const char *aIcon)
+{
+
+
+ return NS_OK;
+}
+
+/* void hideicon (); */
+NS_IMETHODIMP rhTray::Hideicon(void)
+{
+
+ notify_icon_hide();
+
+ return NS_OK;
+}
+
+/* void showicon (); */
+NS_IMETHODIMP rhTray::Showicon(void)
+{
+
+ notify_icon_show();
+
+ return NS_OK;
+}
HRESULT rhTray::Initialize()
{
@@ -166,21 +235,32 @@
return S_OK;
}
- PR_LOG( trayLog, 5, ("rhTray::Initialize \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Initialize \n"));
g_set_print_handler(rhTray::TrayPrintHandler);
-
- HRESULT res = E_FAIL;
+
+ notify_icon_create_with_image_file(COOLKEY_ICON);
+
+ HRESULT res = notify_icon_created_ok();
if(res != S_OK)
{
return E_FAIL;
}
+
+ GtkWidget *icon_widget = notify_icon_get_box_widget();
+
+ if(icon_widget)
+ {
+ g_signal_connect(G_OBJECT(icon_widget), "button-press-event",
G_CALLBACK(rhTray::IconCBProc), NULL);
+
+ }
+
res = CreateEventWindow();
- PR_LOG( trayLog, 5, ("rhTray::Initialize result of CreateIconMenu %d
\n",res));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Initialize result of CreateIconMenu %d
\n",res));
if(res != S_OK)
{
@@ -189,6 +269,8 @@
mInitialized = 1;
+ notify_icon_hide();
+
return S_OK;
}
@@ -199,7 +281,7 @@
HRESULT rhTray::Cleanup()
{
- PR_LOG( trayLog, 5, ("rhTray::Cleanup.\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Cleanup.\n"));
RemoveAllListeners();
DestroyEventWindow();
@@ -211,7 +293,7 @@
void rhTray::ShowAllListeners()
{
- PR_LOG( trayLog, 5, ("rhTray::ShowAllListeners.\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ShowAllListeners.\n"));
map< nsIBaseWindow *, rhTrayWindowListener *>::iterator i;
rhTrayWindowListener *cur = NULL;
@@ -235,7 +317,7 @@
void rhTray::HideAllListeners()
{
- PR_LOG( trayLog, 5, ("rhTray::HideAllListeners.\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::HideAllListeners.\n"));
map< nsIBaseWindow *, rhTrayWindowListener *>::iterator i;
@@ -258,7 +340,7 @@
HRESULT rhTray::DestroyEventWindow()
{
- PR_LOG( trayLog, 5, ("rhTray::DestroyEventWindow \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::DestroyEventWindow \n"));
rhTray::mWnd = 0;
@@ -268,7 +350,7 @@
void rhTray::IconMenuCBProc(GtkWidget *widget, gpointer data)
{
- PR_LOG( trayLog, 5, ("rhTray::IconMenuCBProc data %s \n",data));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::IconMenuCBProc data %s
\n",data));
if(!strcmp((char *)data,"icon.min"))
@@ -278,6 +360,7 @@
if(!strcmp((char *)data,"icon.max"))
{
+ NotifyTrayWindListeners(MENU_EVT,MENU_SHOW);
rhTray::ShowAllListeners();
}
@@ -290,7 +373,7 @@
HRESULT rhTray::CreateIconMenu()
{
- PR_LOG( trayLog, 5, ("rhTray::CreateIconMenu \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::CreateIconMenu \n"));
if(mIconMenu)
return E_FAIL;
@@ -298,11 +381,11 @@
mIconMenu = gtk_menu_new ();
GtkWidget *min_item = gtk_menu_item_new_with_label ("Hide");
- GtkWidget *max_item = gtk_menu_item_new_with_label ("Show");
+ GtkWidget *max_item = gtk_menu_item_new_with_label ("Manage Keys");
GtkWidget *exit_item = gtk_menu_item_new_with_label ("Exit");
gtk_menu_shell_append (GTK_MENU_SHELL (mIconMenu), max_item);
- gtk_menu_shell_append (GTK_MENU_SHELL (mIconMenu), min_item);
+ //gtk_menu_shell_append (GTK_MENU_SHELL (mIconMenu), min_item);
gtk_menu_shell_append (GTK_MENU_SHELL (mIconMenu), exit_item);
g_signal_connect(G_OBJECT (min_item), "activate",
@@ -326,7 +409,7 @@
void rhTray::IconCBProc(GtkWidget *button, GdkEventButton *event, void *data)
{
- PR_LOG( trayLog, 5, ("rhTray::IconCBProc \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::IconCBProc \n"));
if(event->type != GDK_BUTTON_PRESS)
@@ -364,7 +447,7 @@
HRESULT rhTray::CreateEventWindow()
{
- PR_LOG( trayLog, 5, ("rhTray::CreateEventWindow \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::CreateEventWindow \n"));
HRESULT res = CreateIconMenu();
return res;
@@ -376,7 +459,7 @@
nsresult rv;
- PR_LOG( trayLog, 5, ("rhTray::AddListener %p \n",aWindow));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddListener %p \n",aWindow));
NS_ENSURE_ARG(aWindow);
nativeWindow aNativeWindow;
@@ -394,7 +477,7 @@
gdk_window_get_user_data (gWnd,(void **)&hWnd);
- PR_LOG(trayLog,5, ("rhTray::AddListener is widget %p .\n",hWnd));
+ PR_LOG(trayLog,PR_LOG_DEBUG, ("rhTray::AddListener is widget %p
.\n",hWnd));
if(!hWnd)
{
return E_FAIL;
@@ -407,20 +490,20 @@
if(already)
{
- PR_LOG( trayLog, 5, ("rhTray::AddWindowListener Window already registered
%p \n",aWindow));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddWindowListener Window already
registered %p \n",aWindow));
return S_OK;
}
- PR_LOG( trayLog, 5, ("rhTray::AddWindowListener current level widget %p
\n",hWnd));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddWindowListener current level widget
%p \n",hWnd));
hWnd = gtk_widget_get_toplevel( hWnd);
- PR_LOG( trayLog, 5, ("rhTray::AddWindowListener top level widget %p
\n",hWnd));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddWindowListener top level widget %p
\n",hWnd));
if (GTK_WIDGET_TOPLEVEL (hWnd))
{
- PR_LOG( trayLog, 5, ("rhTray::AddWindowListener is really a top level widget
%p \n",hWnd));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddWindowListener is really a top
level widget %p \n",hWnd));
}
rhTrayWindowListener *create = new rhTrayWindowListener(hWnd);
@@ -450,7 +533,7 @@
HRESULT rhTray::RemoveListener(nsIBaseWindow *aBaseWindow)
{
- PR_LOG( trayLog, 5, ("rhTray::RemoveWindowListener %p \n",aBaseWindow));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::RemoveWindowListener %p
\n",aBaseWindow));
if(!aBaseWindow)
return S_OK;
@@ -478,7 +561,7 @@
HRESULT rhTray::RemoveAllListeners()
{
- PR_LOG( trayLog, 5, ("rhTray::RemoveAllListenesr\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::RemoveAllListenesr\n"));
map< nsIBaseWindow *, rhTrayWindowListener *>::iterator i;
rhTrayWindowListener *cur = NULL;
@@ -503,11 +586,109 @@
}
+//rhTrayWindNotify methods
+
+rhITrayWindNotify* rhTray::GetTrayWindNotifyListener(rhITrayWindNotify *listener)
+{
+
+ std::list<nsCOMPtr<rhITrayWindNotify> >::const_iterator it;
+
+ for(it=gTrayWindNotifyListeners.begin(); it!=gTrayWindNotifyListeners.end(); ++it) {
+
+ if((*it) == listener)
+ {
+ return (*it);
+ }
+}
+
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhCoolKey::GetNotifyKeyListener: looking for
%p returning NULL. \n",listener));
+
+ return nsnull;
+
+
+
+}
+
+int rhTray::GetTrayWindNotifyListSize()
+{
+ return gTrayWindNotifyListeners.size();
+
+}
+
+
+void rhTray::AddTrayWindNotifyListener(rhITrayWindNotify *listener)
+{
+
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddTrayWindNotifyListener: %p
\n",
+listener));
+
+ if(GetTrayWindNotifyListener(listener ))
+ {
+
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddTrayWindNotifyListener: %p
listener already in list. \n",listener));
+
+ return ;
+
+ }
+
+ gTrayWindNotifyListeners.push_back(listener);
+
+
+}
+
+void rhTray::RemoveTrayWindNotifyListener(rhITrayWindNotify *listener)
+{
+
+ if(!GetTrayWindNotifyListener(listener))
+ {
+ return;
+ }
+
+ gTrayWindNotifyListeners.remove(listener);
+
+
+ listener = NULL;
+}
+
+
+void rhTray::ClearTrayWindNotifyList()
+{
+
+ while (gTrayWindNotifyListeners.size() > 0) {
+ rhITrayWindNotify * node = (gTrayWindNotifyListeners.front()).get();
+
+ node = NULL;
+
+ gTrayWindNotifyListeners.pop_front();
+ }
+
+}
+
+void rhTray::NotifyTrayWindListeners(PRUint32 aEvent, PRUint32 aEventData,PRUint32
aKeyData,PRUint32 aData1, PRUint32 aData2)
+{
+
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::NotifyTrayWindListeners \n"));
+
+ //Now notify all the listeners of the event
+
+ std::list< nsCOMPtr <rhITrayWindNotify> >::const_iterator it;
+ for(it=gTrayWindNotifyListeners.begin(); it!=gTrayWindNotifyListeners.end(); ++it) {
+
+ PRBool claimed = 0;
+
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("NotifyTrayWindListeners about to notify
\n"));
+ ((rhITrayWindNotify *) (*it))->RhTrayWindEventNotify(aEvent,aEventData,
aKeyData, aData1, aData2, &claimed);
+
+
+ }
+
+}
+
void rhTray::TrayPrintHandler(const gchar *string)
{
- PR_LOG( trayLog, 5, ("rhTray:TrayPrintHandler. : %s \n",(char *) string));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray:TrayPrintHandler. : %s \n",(char *)
string));
}
//rhTrayWindowListener Methods
@@ -519,12 +700,12 @@
rhTrayWindowListener::~rhTrayWindowListener()
{
- PR_LOG( trayLog, 5, ("rhTrayWindowListener::rhTrayWindowListener.\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG,
("rhTrayWindowListener::rhTrayWindowListener.\n"));
}
HRESULT rhTrayWindowListener::Initialize()
{
- PR_LOG( trayLog, 5, ("rhTrayWindowListener::Initialize \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener::Initialize \n"));
if(mWnd)
{
@@ -548,7 +729,7 @@
gtk_window_deiconify(GTK_WINDOW(mWnd));
- PR_LOG( trayLog, 5, ("rhTrayWindowListener:: ShowWindow \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: ShowWindow
\n"));
}
}
@@ -558,7 +739,7 @@
if(mWnd)
{
gtk_widget_hide(mWnd);
- PR_LOG( trayLog, 5, ("rhTrayWindowListener:: Hide Window
%p\n",mWnd));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: Hide Window
%p\n",mWnd));
}
}
@@ -568,7 +749,7 @@
g_print("WndDestroyCBProc \n");
- PR_LOG( trayLog, 5, ("rhTrayWindowListener::WndDestroyCBProc \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener::WndDestroyCBProc
\n"));
}
@@ -578,7 +759,7 @@
{
g_print("WndDeleteCBProc\n");
- PR_LOG( trayLog, 5, ("rhTrayWindowListener::WndDeleteCBProc \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener::WndDeleteCBProc
\n"));
rhTrayWindowListener *me = (rhTrayWindowListener *) data;
Index: rhMacTray.cpp
===================================================================
RCS file: /cvs/dirsec/esc/src/app/xpcom/tray/rhMacTray.cpp,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- rhMacTray.cpp 12 Jun 2006 23:39:50 -0000 1.1.1.1
+++ rhMacTray.cpp 13 Sep 2006 17:50:07 -0000 1.2
@@ -15,6 +15,8 @@
* All rights reserved.
* END COPYRIGHT BLOCK **/
+#define FORCE_PR_LOG 1
+
#include "rhTray.h"
#include "nsIGenericFactory.h"
#include <prlog.h>
@@ -30,6 +32,8 @@
map< nsIBaseWindow *, rhTrayWindowListener *> rhTray::mWindowMap;
+std::list< nsCOMPtr<rhITrayWindNotify> > rhTray::gTrayWindNotifyListeners;
+
static PRLogModuleInfo *trayLog = PR_NewLogModule("tray");
rhTray::rhTray()
@@ -40,13 +44,39 @@
rhTray::~rhTray()
{
- PR_LOG( trayLog, 5, ("rhTray::~rhTray\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::~rhTray\n"));
Cleanup();
/* destructor code */
}
+NS_IMETHODIMP rhTray::Setwindnotifycallback(rhITrayWindNotify *jsNotify)
+{
+
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Setwindnotifycallback\n"));
+
+ if(jsNotify)
+ AddTrayWindNotifyListener(jsNotify);
+
+
+ return NS_OK;
+
+}
+ /* void unsetwindnotifycallback (in rhITrayWindNotify jsNotify); */
+
+NS_IMETHODIMP rhTray::Unsetwindnotifycallback(rhITrayWindNotify *jsNotify)
+{
+
+
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Unsetwindnotifycallback\n"));
+
+ if(jsNotify)
+ RemoveTrayWindNotifyListener(jsNotify);
+
+ return NS_OK;
+}
+
/* void add (); */
NS_IMETHODIMP rhTray::Add(nsIBaseWindow *aWindow)
{
@@ -54,7 +84,7 @@
NS_ENSURE_ARG(aWindow);
- PR_LOG( trayLog, 5, ("rhTray::Add %p \n",aWindow));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Add %p \n",aWindow));
HRESULT res = Initialize();
if(res != S_OK)
@@ -73,7 +103,7 @@
/* void remove (); */
NS_IMETHODIMP rhTray::Remove(nsIBaseWindow *aWindow)
{
- PR_LOG( trayLog, 5, ("rhTray::Remove window %p \n",aWindow));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Remove window %p \n",aWindow));
if(!aWindow)
return NS_OK;
@@ -150,17 +180,46 @@
}
-NS_IMETHODIMP rhTray::Sendnotification(const char *aMessage)
+NS_IMETHODIMP rhTray::Sendnotification(const char *aTitle,const char *aMessage,PRUint32
aSeverity,PRUint32 aTimeout, const char *aIcon)
+{
+ return NS_OK;
+
+}
+
+/* void settooltipmsg (in string aMessage); */
+NS_IMETHODIMP rhTray::Settooltipmsg(const char *aMessage)
+{
+ return NS_OK;
+}
+
+/* void seticonimage (in string aIcon); */
+NS_IMETHODIMP rhTray::Seticonimage(const char *aIcon)
+{
+
+
+ return NS_OK;
+}
+
+/* void hideicon (); */
+NS_IMETHODIMP rhTray::Hideicon(void)
{
+
return NS_OK;
+}
+
+/* void showicon (); */
+NS_IMETHODIMP rhTray::Showicon(void)
+{
+
+ return NS_OK;
}
void rhTray::ShowApp()
{
- PR_LOG( trayLog, 5, ("rhTray::Show app! \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Show app! \n"));
::ShowHideProcess(&rhTray::mPSN,TRUE);
::SetFrontProcess(&rhTray::mPSN);
@@ -181,19 +240,19 @@
if(mInitialized)
return S_OK;
- PR_LOG( trayLog, 5, ("rhTray::Initialize dock: \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Initialize dock: \n"));
OSErr pRes = GetCurrentProcess (
&mPSN
);
- PR_LOG( trayLog, 5, ("rhTray::Initialize App PID result %d \n",pRes));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Initialize App PID result %d
\n",pRes));
HRESULT res = CreateApplicationListener();
- PR_LOG( trayLog, 5, ("rhTray::Initialize result of CreateApplicationListener %d
\n",res));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Initialize result of
CreateApplicationListener %d \n",res));
if(res != S_OK)
{
@@ -207,7 +266,7 @@
HRESULT rhTray::RemoveIcon()
{
- PR_LOG( trayLog, 5, ("rhTray::RemoveIcon. \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::RemoveIcon. \n"));
@@ -216,7 +275,7 @@
HRESULT rhTray::Cleanup()
{
- PR_LOG( trayLog, 5, ("rhTray::Cleanup.\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Cleanup.\n"));
RemoveAllListeners();
DestroyEventWindow();
@@ -244,7 +303,7 @@
if(!target)
return E_FAIL;
- PR_LOG( trayLog, 5, ("rhTray::CreateApplicationListener . app target
%p\n",target));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::CreateApplicationListener . app target
%p\n",target));
int numTypes = 4;
@@ -265,7 +324,7 @@
{
ShowApp();
- PR_LOG( trayLog, 5, ("rhTray::ShowAllListeners.\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ShowAllListeners.\n"));
map< nsIBaseWindow *, rhTrayWindowListener *>::iterator i;
rhTrayWindowListener *cur = NULL;
@@ -289,7 +348,7 @@
void rhTray::HideAllListeners()
{
- PR_LOG( trayLog, 5, ("rhTray::HideAllListeners.\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::HideAllListeners.\n"));
map< nsIBaseWindow *, rhTrayWindowListener *>::iterator i;
@@ -313,7 +372,7 @@
HRESULT rhTray::DestroyEventWindow()
{
- PR_LOG( trayLog, 5, ("rhTray::DestroyEventWindow \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::DestroyEventWindow \n"));
return S_OK;
@@ -326,7 +385,7 @@
nsresult rv;
- PR_LOG( trayLog, 5, ("rhTray::AddListener %p \n",aWindow));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddListener %p \n",aWindow));
NS_ENSURE_ARG(aWindow);
nativeWindow aNativeWindow;
@@ -357,13 +416,13 @@
if(already)
{
- PR_LOG( trayLog, 5, ("rhTray::AddWindowListener Window already registered
%p \n",aWindow));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddWindowListener Window already
registered %p \n",aWindow));
return S_OK;
}
- PR_LOG( trayLog, 5, ("rhTray::AddWindowListener top level widget %p
\n",hWnd));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddWindowListener top level widget %p
\n",hWnd));
rhTrayWindowListener *create = new rhTrayWindowListener(hWnd);
@@ -391,7 +450,7 @@
HRESULT rhTray::RemoveListener(nsIBaseWindow *aBaseWindow)
{
- PR_LOG( trayLog, 5, ("rhTray::RemoveWindowListener %p \n",aBaseWindow));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::RemoveWindowListener %p
\n",aBaseWindow));
if(!aBaseWindow)
return S_OK;
@@ -419,7 +478,7 @@
HRESULT rhTray::RemoveAllListeners()
{
- PR_LOG( trayLog, 5, ("rhTray::RemoveAllListenesr\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::RemoveAllListenesr\n"));
map< nsIBaseWindow *, rhTrayWindowListener *>::iterator i;
rhTrayWindowListener *cur = NULL;
@@ -444,18 +503,111 @@
}
+//rhTrayWindNotify methods
+
+rhITrayWindNotify* rhTray::GetTrayWindNotifyListener(rhITrayWindNotify *listener)
+{
+
+ std::list<nsCOMPtr<rhITrayWindNotify> >::const_iterator it;
+
+ for(it=gTrayWindNotifyListeners.begin(); it!=gTrayWindNotifyListeners.end(); ++it) {
+
+ if((*it) == listener)
+ {
+ return (*it);
+ }
+}
+
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhCoolKey::GetNotifyKeyListener: looking for
%p returning NULL. \n",listener));
+
+ return nsnull;
+
+
+
+}
+
+int rhTray::GetTrayWindNotifyListSize()
+{
+ return gTrayWindNotifyListeners.size();
+
+}
+
+void rhTray::AddTrayWindNotifyListener(rhITrayWindNotify *listener)
+{
+
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddTrayWindNotifyListener: %p
\n",
+listener));
+
+ if(GetTrayWindNotifyListener(listener ))
+ {
+
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddTrayWindNotifyListener: %p
listener already in list. \n",listener));
+
+ return ;
+
+ }
+
+ gTrayWindNotifyListeners.push_back(listener);
+
+
+}
+
+void rhTray::RemoveTrayWindNotifyListener(rhITrayWindNotify *listener)
+{
+
+ if(!GetTrayWindNotifyListener(listener))
+ {
+ return;
+ }
+
+ gTrayWindNotifyListeners.remove(listener);
+
+
+ listener = NULL;
+}
+
+void rhTray::ClearTrayWindNotifyList()
+{
+
+ while (gTrayWindNotifyListeners.size() > 0) {
+ rhITrayWindNotify * node = (gTrayWindNotifyListeners.front()).get();
+
+ node = NULL;
+
+ gTrayWindNotifyListeners.pop_front();
+ }
+
+}
+
+void rhTray::NotifyTrayWindListeners(PRUint32 aEvent, PRUint32 aEventData,PRUint32
aKeyData,PRUint32 aData1, PRUint32 aData2)
+{
+
+ //Now notify all the listeners of the event
+
+ std::list< nsCOMPtr <rhITrayWindNotify> >::const_iterator it;
+ for(it=gTrayWindNotifyListeners.begin(); it!=gTrayWindNotifyListeners.end(); ++it) {
+
+ PRBool claimed = 0;
+
+ ((rhITrayWindNotify *) (*it))->RhTrayWindEventNotify(aEvent,aEventData,
aKeyData, aData1, aData2, &claimed);
+
+
+ }
+
+}
+
pascal OSStatus rhTray::ApplicationProc(EventHandlerCallRef nextHandler, EventRef aEvent,
void *userData)
{
OSStatus result = eventNotHandledErr;
- PR_LOG( trayLog, 5, ("rhTray::ApplicationProc .\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ApplicationProc .\n"));
int theEvent = GetEventKind(aEvent);
int theClass = GetEventClass(aEvent);
- PR_LOG( trayLog, 5, ("rhTray::ApplicationProc class %d event: %d
\n",theClass,theEvent));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ApplicationProc class %d event: %d
\n",theClass,theEvent));
switch(theClass)
{
@@ -466,12 +618,12 @@
{
case kEventAppActivated:
- PR_LOG( trayLog, 5, ("rhTray::ApplicationProc App activated!
\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ApplicationProc App
activated! \n"));
break;
case kEventAppDeactivated:
- PR_LOG( trayLog, 5, ("rhTray::ApplicationProc App deactivated!
\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ApplicationProc App
deactivated! \n"));
result = noErr;
break;
@@ -482,7 +634,7 @@
case kEventClassCommand:
- PR_LOG( trayLog, 5, ("rhTray::ApplicationProc App kEventClassCommand!
\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ApplicationProc App
kEventClassCommand! \n"));
HICommand commandStruct;
@@ -494,19 +646,19 @@
switch(commandStruct.commandID)
{
case kHICommandHide:
- PR_LOG( trayLog, 5, ("rhTray::ApplicationProc App
kHICommandHide! \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ApplicationProc App
kHICommandHide! \n"));
break;
case kHICommandSelectWindow:
- PR_LOG( trayLog, 5, ("rhTray::ApplicationProc App
kHICommandSelectWindow! \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ApplicationProc App
kHICommandSelectWindow! \n"));
break;
case kHICommandClose:
- PR_LOG( trayLog, 5, ("rhTray::ApplicationProc App
kHICommandClose! \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ApplicationProc App
kHICommandClose! \n"));
break;
case kHICommandQuit:
- PR_LOG( trayLog, 5, ("rhTray::ApplicationProc App
kHICommandQuit! \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ApplicationProc App
kHICommandQuit! \n"));
break;
};
@@ -532,14 +684,14 @@
rhTrayWindowListener::~rhTrayWindowListener()
{
- PR_LOG( trayLog, 5, ("rhTrayWindowListener::~rhTrayWindowListener.\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG,
("rhTrayWindowListener::~rhTrayWindowListener.\n"));
Cleanup();
}
HRESULT rhTrayWindowListener::Initialize()
{
- PR_LOG( trayLog, 5, ("rhTrayWindowListener::Initialize \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener::Initialize \n"));
mEventHandlerUPP = NewEventHandlerUPP(rhTrayWindowListener::WindowProc);
@@ -564,24 +716,24 @@
if(mWnd)
{
- PR_LOG( trayLog, 5, ("rhTrayWindowListener:: ShowWindow \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: ShowWindow
\n"));
if(IsWindowCollapsed(mWnd))
{
- PR_LOG( trayLog, 5, ("rhTrayWindowListener:: ShowWindow : uncollapsing
collapsed window. \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: ShowWindow :
uncollapsing collapsed window. \n"));
::CollapseWindow(mWnd,FALSE);
}
if(!IsWindowVisible(mWnd))
{
- PR_LOG( trayLog, 5, ("rhTrayWindowListener:: ShowWindow : Window not
visible showing... \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: ShowWindow :
Window not visible showing... \n"));
::ShowWindow(mWnd);
}
//::BringToFront(mWnd);
- PR_LOG( trayLog, 5, ("rhTrayWindowListener:: ShowWindow : \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: ShowWindow :
\n"));
rhTray::ShowApp();
@@ -593,7 +745,7 @@
if(mWnd)
{
- PR_LOG( trayLog, 5, ("rhTrayWindowListener:: HideWindow \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: HideWindow
\n"));
//OSStatus res = ::CollapseWindow(mWnd,TRUE);
@@ -601,7 +753,7 @@
rhTray::HideApp();
- PR_LOG( trayLog, 5, ("rhTrayWindowListener:: HideWindow \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: HideWindow
\n"));
}
@@ -616,13 +768,13 @@
int theEvent = GetEventKind(aEvent);
- PR_LOG( trayLog, 5, ("rhTrayWindowListener::WindowProc event: %d
\n",theEvent));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener::WindowProc event: %d
\n",theEvent));
switch(theEvent)
{
case kEventWindowClose:
- PR_LOG( trayLog, 5, ("rhTrayWindowListener::WindowProc attempting Window
close! \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener::WindowProc
attempting Window close! \n"));
if(self)
self->HideWindow();
@@ -631,17 +783,17 @@
case kEventWindowHidden:
- PR_LOG( trayLog, 5, ("rhTrayWindowListener::WindowProc attempting
Window hide! \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener::WindowProc
attempting Window hide! \n"));
break;
case kEventWindowClosed:
- PR_LOG( trayLog, 5, ("rhTrayWindowListener::WindowProc Window closed!
\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener::WindowProc Window
closed! \n"));
break;
case kEventMouseDown:
- PR_LOG( trayLog, 5, ("rhTrayWindowListener::WindowProc mouse down!
\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener::WindowProc mouse
down! \n"));
break;
}
@@ -652,7 +804,7 @@
HRESULT rhTrayWindowListener::Cleanup()
{
- PR_LOG( trayLog, 5, ("rhTrayWindowListener::Cleanup. \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener::Cleanup. \n"));
if(mEventHandlerRef)
{
Index: rhTray.cpp
===================================================================
RCS file: /cvs/dirsec/esc/src/app/xpcom/tray/rhTray.cpp,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- rhTray.cpp 12 Jun 2006 23:39:50 -0000 1.1.1.1
+++ rhTray.cpp 13 Sep 2006 17:50:07 -0000 1.2
@@ -15,6 +15,8 @@
* All rights reserved.
* END COPYRIGHT BLOCK **/
+#define FORCE_PR_LOG 1
+
#include "rhTray.h"
#include "nsIGenericFactory.h"
#include <prlog.h>
@@ -28,6 +30,8 @@
ATOM rhTray::mWndClass = 0;
+std::list< nsCOMPtr<rhITrayWindNotify> > rhTray::gTrayWindNotifyListeners;
+
map< nsIBaseWindow *, rhTrayWindowListener *> rhTray::mWindowMap;
NOTIFYICONDATA rhTray::mIconData;
@@ -50,13 +54,36 @@
rhTray::~rhTray()
{
- PR_LOG( trayLog, 5, ("rhTray::~rhTray\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::~rhTray\n"));
Cleanup();
/* destructor code */
}
+NS_IMETHODIMP rhTray::Setwindnotifycallback(rhITrayWindNotify *jsNotify)
+{
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Setwindnotifycallback\n"));
+
+ if(jsNotify)
+ AddTrayWindNotifyListener(jsNotify);
+
+ return NS_OK;
+
+}
+ /* void unsetwindnotifycallback (in rhITrayWindNotify jsNotify); */
+
+NS_IMETHODIMP rhTray::Unsetwindnotifycallback(rhITrayWindNotify *jsNotify)
+{
+
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Unsetwindnotifycallback\n"));
+
+ if(jsNotify)
+ RemoveTrayWindNotifyListener(jsNotify);
+
+ return NS_OK;
+}
+
/* void add (); */
NS_IMETHODIMP rhTray::Add(nsIBaseWindow *aWindow)
{
@@ -64,7 +91,7 @@
NS_ENSURE_ARG(aWindow);
- PR_LOG( trayLog, 5, ("rhTray::Add %p \n",aWindow));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Add %p \n",aWindow));
HRESULT res = Initialize();
if(res != S_OK)
{
@@ -82,8 +109,7 @@
/* void remove (); */
NS_IMETHODIMP rhTray::Remove(nsIBaseWindow *aWindow)
{
- PR_LOG( trayLog, 5, ("rhTray::Remove window %p \n",aWindow));
-
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Remove window %p \n",aWindow));
return NS_OK;
}
@@ -150,7 +176,7 @@
return NS_OK;
}
-NS_IMETHODIMP rhTray::Sendnotification(const char *aMessage)
+NS_IMETHODIMP rhTray::Sendnotification(const char *aTitle,const char *aMessage,PRUint32
aSeverity,PRUint32 aTimeout, const char *aIcon)
{
if(aMessage)
@@ -163,6 +189,38 @@
}
+/* void settooltipmsg (in string aMessage); */
+NS_IMETHODIMP rhTray::Settooltipmsg(const char *aMessage)
+{
+ return NS_OK;
+}
+
+/* void seticonimage (in string aIcon); */
+NS_IMETHODIMP rhTray::Seticonimage(const char *aIcon)
+{
+
+
+ return NS_OK;
+}
+
+/* void hideicon (); */
+NS_IMETHODIMP rhTray::Hideicon(void)
+{
+
+
+ return NS_OK;
+}
+
+/* void showicon (); */
+NS_IMETHODIMP rhTray::Showicon(void)
+{
+
+
+ return NS_OK;
+}
+
+
+
HRESULT rhTray::SendBalloonTooltipMessage(char *aMessage)
{
@@ -189,9 +247,8 @@
return S_OK;
}
- PR_LOG( trayLog, 5, ("rhTray::Initialize \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Initialize \n"));
- //MessageBox(NULL,"Inside rhTray::Initialize!",NULL,NULL);
HRESULT res = CreateEventWindow();
@@ -227,7 +284,7 @@
rhTray::mIconData.uTimeout = 1000;
- PR_LOG(trayLog,5,("rhTray::Initialize tray icon handle %d \n",icon));
+ PR_LOG(trayLog,PR_LOG_DEBUG,("rhTray::Initialize tray icon handle %d
\n",icon));
::Shell_NotifyIcon( NIM_ADD, &rhTray::mIconData);
@@ -238,7 +295,7 @@
HRESULT rhTray::RemoveIcon()
{
- PR_LOG( trayLog, 5, ("rhTray::RemoveIcon. \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::RemoveIcon. \n"));
::Shell_NotifyIcon(NIM_DELETE,&rhTray::mIconData);
@@ -248,7 +305,7 @@
HRESULT rhTray::Cleanup()
{
- PR_LOG( trayLog, 5, ("rhTray::Cleanup.\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Cleanup.\n"));
RemoveAllListeners();
DestroyEventWindow();
@@ -260,7 +317,7 @@
void rhTray::ShowAllListeners()
{
- PR_LOG( trayLog, 5, ("rhTray::ShowAllListeners.\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ShowAllListeners.\n"));
map< nsIBaseWindow *, rhTrayWindowListener *>::iterator i;
rhTrayWindowListener *cur = NULL;
@@ -284,7 +341,7 @@
void rhTray::HideAllListeners()
{
- PR_LOG( trayLog, 5, ("rhTray::HideAllListeners.\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::HideAllListeners.\n"));
map< nsIBaseWindow *, rhTrayWindowListener *>::iterator i;
@@ -307,7 +364,7 @@
HRESULT rhTray::DestroyEventWindow()
{
- PR_LOG( trayLog, 5, ("rhTray::DestroyEventWindow \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::DestroyEventWindow \n"));
::DestroyWindow(rhTray::mWnd);
rhTray::mWnd = 0;
@@ -318,7 +375,7 @@
HRESULT rhTray::CreateEventWindow()
{
- PR_LOG( trayLog, 5, ("rhTray::CreateEventWindow \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::CreateEventWindow \n"));
::SetLastError(0);
HINSTANCE hInst = ::GetModuleHandle(NULL);
@@ -388,13 +445,13 @@
{
case WM_LBUTTONDBLCLK:
- PR_LOG( trayLog, 5, ("rhTray::WindowProc: WM_LBUTTONDBLCLK
\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::WindowProc: WM_LBUTTONDBLCLK
\n"));
ShowAllListeners();
break;
case WM_RBUTTONDOWN:
- PR_LOG( trayLog, 5, ("rhTray::WindowProc: WM_RBUTTONDOWN
\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::WindowProc: WM_RBUTTONDOWN
\n"));
HRESULT res = rhTray::ShowPopupMenu (IDR_MENU1);
@@ -424,7 +481,7 @@
break;
case WM_CREATE:
- PR_LOG( trayLog, 5, ("rhTray::WindowProc: WM_CREATE \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::WindowProc: WM_CREATE
\n"));
break;
default:
break;
@@ -444,7 +501,7 @@
nsresult rv;
- PR_LOG( trayLog, 5, ("rhTray::AddListener %p \n",aWindow));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddListener %p \n",aWindow));
NS_ENSURE_ARG(aWindow);
nativeWindow aNativeWindow;
@@ -470,7 +527,7 @@
if(already)
{
- PR_LOG( trayLog, 5, ("rhTray::AddWindowListener Window already registered
%p \n",aWindow));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddWindowListener Window already
registered %p \n",aWindow));
return S_OK;
}
@@ -502,7 +559,7 @@
hMenu = ::LoadMenu (::GetModuleHandle("rhTray.dll"),
MAKEINTRESOURCE (PopupMenuResource));
- PR_LOG( trayLog, 5, ("rhTray::ShowPopupMenu hMenu %d error
%d\n",hMenu,GetLastError()));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ShowPopupMenu hMenu %d error
%d\n",hMenu,GetLastError()));
if (hMenu != 0) {
POINT pt;
@@ -526,7 +583,7 @@
HRESULT rhTray::RemoveListener(nsIBaseWindow *aBaseWindow)
{
- PR_LOG( trayLog, 5, ("rhTray::RemoveWindowListener %p \n",aBaseWindow));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::RemoveWindowListener %p
\n",aBaseWindow));
if(!aBaseWindow)
return S_OK;
@@ -556,7 +613,7 @@
HRESULT rhTray::RemoveAllListeners()
{
- PR_LOG( trayLog, 5, ("rhTray::RemoveAllListenesr\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::RemoveAllListenesr\n"));
map< nsIBaseWindow *, rhTrayWindowListener *>::iterator i;
rhTrayWindowListener *cur = NULL;
@@ -570,7 +627,7 @@
{
- PR_LOG( trayLog, 5, ("rhTray::RemoveAllListeners deleting
%p\n",cur));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::RemoveAllListeners deleting
%p\n",cur));
delete cur;
@@ -584,6 +641,96 @@
}
+//rhTrayWindNotify methods
+
+rhITrayWindNotify* rhTray::GetTrayWindNotifyListener(rhITrayWindNotify *listener)
+{
+
+ std::list<nsCOMPtr<rhITrayWindNotify> >::const_iterator it;
+
+ for(it=gTrayWindNotifyListeners.begin(); it!=gTrayWindNotifyListeners.end(); ++it) {
+
+ if((*it) == listener)
+ {
+ return (*it);
+ }
+}
+
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhCoolKey::GetNotifyKeyListener: looking for
%p returning NULL. \n",listener));
+
+ return nsnull;
+
+}
+
+int rhTray::GetTrayWindNotifyListSize()
+{
+ return gTrayWindNotifyListeners.size();
+
+}
+void rhTray::AddTrayWindNotifyListener(rhITrayWindNotify *listener)
+{
+
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddTrayWindNotifyListener: %p
\n",
+listener));
+
+ if(GetTrayWindNotifyListener(listener ))
+ {
+
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddTrayWindNotifyListener: %p
listener already in list. \n",listener));
+
+ return ;
+
+ }
+
+ gTrayWindNotifyListeners.push_back(listener);
+
+
+}
+
+void rhTray::RemoveTrayWindNotifyListener(rhITrayWindNotify *listener)
+{
+
+ if(!GetTrayWindNotifyListener(listener))
+ {
+ return;
+ }
+
+ gTrayWindNotifyListeners.remove(listener);
+
+
+ listener = NULL;
+}
+
+void rhTray::ClearTrayWindNotifyList()
+{
+
+ while (gTrayWindNotifyListeners.size() > 0) {
+ rhITrayWindNotify * node = (gTrayWindNotifyListeners.front()).get();
+
+ node = NULL;
+
+ gTrayWindNotifyListeners.pop_front();
+ }
+
+}
+
+void rhTray::NotifyTrayWindListeners(PRUint32 aEvent, PRUint32 aEventData,PRUint32
aKeyData,PRUint32 aData1, PRUint32 aData2)
+{
+
+ //Now notify all the listeners of the event
+
+ std::list< nsCOMPtr <rhITrayWindNotify> >::const_iterator it;
+ for(it=gTrayWindNotifyListeners.begin(); it!=gTrayWindNotifyListeners.end(); ++it) {
+
+ PRBool claimed = 0;
+
+ ((rhITrayWindNotify *) (*it))->RhTrayWindEventNotify(aEvent,aEventData,
aKeyData, aData1, aData2, &claimed);
+
+
+ }
+
+}
+
//rhTrayWindowListener Methods
@@ -597,7 +744,7 @@
rhTrayWindowListener::~rhTrayWindowListener()
{
- PR_LOG( trayLog, 5, ("rhTrayWindowListener::~rhTrayWindowListener.\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG,
("rhTrayWindowListener::~rhTrayWindowListener.\n"));
Cleanup();
@@ -636,27 +783,25 @@
case WM_NCLBUTTONDOWN:
switch(wParam)
{
-
case HTMINBUTTON:
if(me)
{
me->HideWindow();
-
}
- PR_LOG( trayLog, 5, ("rhTrayWindowListener Minimize\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener
Minimize\n"));
eventClaimed = 1;
break;
case HTMAXBUTTON:
- PR_LOG( trayLog, 5, ("rhTrayWindowListener:: Maximize
\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: Maximize
\n"));
eventClaimed = 1;
break;
case HTCLOSE:
- PR_LOG( trayLog, 5, ("rhTrayWindowListener Close! \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener Close!
\n"));
if(me)
{
@@ -677,7 +822,7 @@
case WA_ACTIVE:
case WA_CLICKACTIVE:
- PR_LOG( trayLog, 5, ("rhTrayWindowListener ACTIVATE!
\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener ACTIVATE!
\n"));
break;
@@ -701,7 +846,7 @@
}
- PR_LOG( trayLog, 5, ("rhTrayWindowListener WM_SHOWWINDOW wParam %d lParam
%d! \n",wParam, lParam));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener WM_SHOWWINDOW wParam
%d lParam %d! \n",wParam, lParam));
show = (int) wParam;
@@ -709,7 +854,7 @@
if(lParam == 0)
{
- PR_LOG( trayLog, 5, ("rhTrayWindowListener WM_SHOW called from
ShowWindow or HideWindow \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener WM_SHOW
called from ShowWindow or HideWindow \n"));
}
@@ -721,7 +866,7 @@
{
case SC_CLOSE:
- PR_LOG( trayLog, 5, ("rhTrayWindowListener:: WM_SYSCOMMAND
SC_CLOSE \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener::
WM_SYSCOMMAND SC_CLOSE \n"));
break;
default:
@@ -735,7 +880,7 @@
{
case SIZE_MINIMIZED:
- PR_LOG( trayLog, 5, ("rhTrayWindowListener:: WM_SIZE
SIZE_MINIMIZE \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: WM_SIZE
SIZE_MINIMIZE \n"));
break;
default:
@@ -751,7 +896,7 @@
if(eventClaimed)
{
- PR_LOG( trayLog, 5, ("rhTrayWindowListener:: Event claimed \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: Event claimed
\n"));
return FALSE;
}
@@ -766,7 +911,7 @@
HRESULT rhTrayWindowListener::Cleanup()
{
- PR_LOG( trayLog, 5, ("rhTrayWindowListener::Cleanup. \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener::Cleanup. \n"));
return S_OK;
@@ -790,7 +935,7 @@
{
if(mWnd)
{
- PR_LOG( trayLog, 5, ("rhTrayWindowListener:: ShowWindow \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: ShowWindow
\n"));
::ShowWindow(mWnd,SW_SHOW);
::ShowWindow(mWnd,SW_RESTORE);
@@ -804,7 +949,7 @@
if(mWnd)
{
- PR_LOG( trayLog, 5, ("rhTrayWindowListener:: Hide Window \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: Hide Window
\n"));
::ShowWindow(mWnd,SW_MINIMIZE);
::ShowWindow(mWnd,SW_HIDE);
Index: rhTray.h
===================================================================
RCS file: /cvs/dirsec/esc/src/app/xpcom/tray/rhTray.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- rhTray.h 12 Jun 2006 23:39:50 -0000 1.1.1.1
+++ rhTray.h 13 Sep 2006 17:50:07 -0000 1.2
@@ -26,6 +26,20 @@
#include "widget/nsIBaseWindow.h"
#include "widget/nsIWidget.h"
+
+// Event Defines
+#define MENU_EVT 1
+#define APP_EVT 2
+#define WINDOW_EVT 3
+
+#define SHOW_ALL_WINDOWS 4
+#define HIDE_ALL_WINDOWS 5
+
+#define MENU_SHOW 6
+#define APP_SHOW 7
+
+
+
#ifdef XP_WIN32
#define _WIN32_IE 0x0500
@@ -46,8 +60,11 @@
#include <gtk/gtk.h>
+extern "C" {
+#include "notifytray.h"
+}
-#define COOLKEY_ICON "components/CoolKeyLogo.gif"
+#define COOLKEY_ICON "components/icon.png"
#endif
#include <map>
@@ -151,6 +168,20 @@
HRESULT DestroyEventWindow();
HRESULT RemoveIcon();
+
+ // rhTrayWindNotify content
+
+ static std::list< nsCOMPtr<rhITrayWindNotify> > gTrayWindNotifyListeners;
+
+
+ rhITrayWindNotify* GetTrayWindNotifyListener(rhITrayWindNotify *listener);
+
+ int GetTrayWindNotifyListSize();
+ void AddTrayWindNotifyListener(rhITrayWindNotify *listener);
+ void RemoveTrayWindNotifyListener(rhITrayWindNotify *listener);
+ void ClearTrayWindNotifyList();
+
+ static void NotifyTrayWindListeners(PRUint32 aEvent, PRUint32 aEventData =0,PRUint32
aKeyData=0, PRUint32 aData1=0, PRUint32 aData2=0);
};
#endif
@@ -240,6 +271,21 @@
//Gtk print handler
static void TrayPrintHandler(const gchar *string);
+
+
+ // rhTrayWindNotify content
+
+ static std::list< nsCOMPtr<rhITrayWindNotify> > gTrayWindNotifyListeners;
+
+
+ rhITrayWindNotify* GetTrayWindNotifyListener(rhITrayWindNotify *listener);
+
+ int GetTrayWindNotifyListSize();
+ void AddTrayWindNotifyListener(rhITrayWindNotify *listener);
+ void RemoveTrayWindNotifyListener(rhITrayWindNotify *listener);
+ void ClearTrayWindNotifyList();
+
+ static void NotifyTrayWindListeners(PRUint32 aEvent, PRUint32 aEventData =0,PRUint32
aKeyData=0, PRUint32 aData1=0, PRUint32 aData2=0);
};
#endif
@@ -331,6 +377,21 @@
HRESULT RemoveIcon();
+
+ // rhTrayWindNotify content
+
+ static std::list< nsCOMPtr<rhITrayWindNotify> > gTrayWindNotifyListeners;
+
+
+ rhITrayWindNotify* GetTrayWindNotifyListener(rhITrayWindNotify *listener);
+
+ int GetTrayWindNotifyListSize();
+ void AddTrayWindNotifyListener(rhITrayWindNotify *listener);
+ void RemoveTrayWindNotifyListener(rhITrayWindNotify *listener);
+ void ClearTrayWindNotifyList();
+
+ static void NotifyTrayWindListeners(PRUint32 aEvent, PRUint32 aEventData =0,PRUint32
aKeyData=0, PRUint32 aData1=0, PRUint32 aData2=0);
+
};
#endif