[Fedora-directory-commits] esc/src/app/xpcom/tray Makefile.moz, 1.2, 1.3 cool.rc, 1.1.1.1, 1.2 rhMacTray.cpp, 1.3, 1.4 rhTray.cpp, 1.3, 1.4 rhTray.h, 1.2, 1.3
Jack Magne (jmagne)
fedora-directory-commits at redhat.com
Wed Oct 25 03:59:05 UTC 2006
- Previous message (by thread): [Fedora-directory-commits] esc/src/app/xpcom CoolKeyCSP.cpp, 1.2, 1.3 CoolKeyCSP.h, 1.1.1.1, 1.2 Makefile.moz, 1.3, 1.4 openkey.h, 1.1.1.1, 1.2 rhCoolKey.cpp, 1.3, 1.4
- Next message (by thread): [Fedora-directory-commits] esc/src/app/xul/esc application.ini, 1.2, 1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: jmagne
Update of /cvs/dirsec/esc/src/app/xpcom/tray
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv9535
Modified Files:
Makefile.moz cool.rc rhMacTray.cpp rhTray.cpp rhTray.h
Log Message:
Latest mac/win fixes.
Index: Makefile.moz
===================================================================
RCS file: /cvs/dirsec/esc/src/app/xpcom/tray/Makefile.moz,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Makefile.moz 13 Sep 2006 17:50:07 -0000 1.2
+++ Makefile.moz 25 Oct 2006 03:59:03 -0000 1.3
@@ -39,6 +39,12 @@
-include $(MOZ_OBJDIR)/config/autoconf.mk
+DEPLOY_OFFSET=/esc
+ifeq ($(OS_ARCH),Linux)
+DEPLOY_OFFSET=/src
+endif
+
+
OS_CXXFLAGS += $(HOST_CXXFLAGS)
#MODULE = rhTray
@@ -133,8 +139,8 @@
deploy::
echo "Deploying"
echo $(IMPORT_LIBRARY)
- $(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
+ $(NSINSTALL) ./$(LIB_PREFIX)rhTray$(DLL_SUFFIX) $(CORE_DEPTH)$(DEPLOY_OFFSET)/app/xul/esc/components
+ $(NSINSTALL) ./_xpidlgen/*.xpt $(INSTALL_STUFF) $(CORE_DEPTH)$(DEPLOY_OFFSET)/app/xul/esc/components
# separate libraries linked in.
Index: cool.rc
===================================================================
RCS file: /cvs/dirsec/esc/src/app/xpcom/tray/cool.rc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- cool.rc 12 Jun 2006 23:39:50 -0000 1.1.1.1
+++ cool.rc 25 Oct 2006 03:59:03 -0000 1.2
@@ -58,8 +58,8 @@
BEGIN
POPUP "System Tray Menu"
BEGIN
- MENUITEM "Show...", ID_SHOW
- //MENUITEM "Hide...", ID_HIDE
+ MENUITEM "Show Manage Smart Cards", ID_SHOW
+ //MENUITEM "Hide", ID_HIDE
MENUITEM "Exit", IDM_EXIT
END
END
Index: rhMacTray.cpp
===================================================================
RCS file: /cvs/dirsec/esc/src/app/xpcom/tray/rhMacTray.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- rhMacTray.cpp 27 Sep 2006 17:21:58 -0000 1.3
+++ rhMacTray.cpp 25 Oct 2006 03:59:03 -0000 1.4
@@ -25,12 +25,16 @@
int rhTray::mInitialized = 0;
WindowRef rhTray::mWnd = NULL;
+MenuRef rhTray::mDockMenu = NULL;
+MenuRef rhTray::mRootMenu = NULL;
ProcessSerialNumber rhTray::mPSN;
EventHandlerRef rhTray::mEventHandlerRef=NULL;
EventHandlerUPP rhTray::mEventHandlerUPP=NULL;
map< nsIBaseWindow *, rhTrayWindowListener *> rhTray::mWindowMap;
+#define MENU_ITEM_ID_BASE 5
+#define GO_MENU_ID 6
std::list< nsCOMPtr<rhITrayWindNotify> > rhTray::gTrayWindNotifyListeners;
@@ -137,7 +141,6 @@
rhTrayWindowListener *listener = rhTray::mWindowMap[aWindow];
- ShowApp();
if(listener)
{
listener->ShowWindow();
@@ -220,7 +223,7 @@
{
PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Show app! \n"));
-
+
::ShowHideProcess(&rhTray::mPSN,TRUE);
::SetFrontProcess(&rhTray::mPSN);
@@ -259,6 +262,64 @@
return E_FAIL;
}
+ //Take care of the menu stuff
+
+ MenuRef tMenu;
+ CreateNewMenu(1, 0, &tMenu);
+
+ MenuItemIndex item;
+ AppendMenuItemTextWithCFString( tMenu, CFSTR("Show Manage Smart Cards"), 0,MENU_ITEM_ID_BASE , &item );
+
+ if(tMenu)
+ {
+ OSStatus result = SetApplicationDockTileMenu (tMenu);
+
+ if(result == noErr)
+ {
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Initialize result of SetApplicationDockTileMenu %d \n",result));
+ mDockMenu = GetApplicationDockTileMenu();
+
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Initialize result of GetApplicationDockTileMenu: %d . \n",mDockMenu));
+ }
+ }
+
+ MenuRef tGoMenu;
+ ::CreateNewMenu(1,0,&tGoMenu);
+
+ if(tGoMenu)
+ {
+ SetMenuID (tGoMenu,GO_MENU_ID);
+ }
+ else
+ {
+ return S_OK;
+ }
+
+ MenuRef tRootMenu;
+ ::CreateNewMenu(0, 0, &tRootMenu);
+
+ if(!tRootMenu)
+ {
+ return S_OK;
+ }
+
+ MenuItemIndex goItem;
+
+ ::AppendMenuItemTextWithCFString( tGoMenu, CFSTR("Show Manage Smart Cards"), 0,MENU_ITEM_ID_BASE , &goItem );
+
+ ::SetMenuTitleWithCFString( tGoMenu, CFSTR("Go") );
+
+ OSStatus rootResult = ::SetRootMenu(tRootMenu);
+
+ if(rootResult == noErr)
+ {
+ mRootMenu = AcquireRootMenu();
+
+ MenuItemIndex myMenuIndex;
+ AppendMenuItemTextWithCFString( tRootMenu, NULL, 0, 0, &myMenuIndex );
+ SetMenuItemHierarchicalMenu(tRootMenu, myMenuIndex, tGoMenu);
+ }
+
mInitialized = 1;
return S_OK;
@@ -292,6 +353,24 @@
::DisposeEventHandlerUPP(mEventHandlerUPP);
}
+
+ if(mDockMenu)
+ {
+ ::ReleaseMenu(mDockMenu);
+ }
+
+
+ MenuRef goMenu = GetMenuHandle (GO_MENU_ID);
+
+ if(goMenu)
+ {
+ ::ReleaseMenu(goMenu);
+ }
+
+ if(mRootMenu)
+ {
+ ::ReleaseMenu(mRootMenu);
+ }
return S_OK;
}
@@ -323,7 +402,6 @@
void rhTray::ShowAllListeners()
{
- ShowApp();
PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ShowAllListeners.\n"));
map< nsIBaseWindow *, rhTrayWindowListener *>::iterator i;
@@ -421,7 +499,6 @@
}
-
PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddWindowListener top level widget %p \n",hWnd));
rhTrayWindowListener *create = new rhTrayWindowListener(hWnd);
@@ -437,7 +514,7 @@
if(res != S_OK)
return E_FAIL;
-
+
return S_OK;
}
@@ -506,6 +583,95 @@
/* void setmenuitemtext (in unsigned long aIndex, in string aText); */
NS_IMETHODIMP rhTray::Setmenuitemtext(PRUint32 aIndex, const char *aText)
{
+
+ // On the Mac , we support only one menu item
+
+ if(aIndex == 0 && aText)
+ {
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhCoolKey::Setmenuitemtext aIndex: %d text %s. \n",aIndex,aText));
+
+ MenuRef outMenu;
+ MenuItemIndex theIndex;
+
+ OSStatus result = GetIndMenuItemWithCommandID (
+ mDockMenu,
+ MENU_ITEM_ID_BASE + aIndex,
+ 1,
+ &outMenu,
+ &theIndex
+ );
+
+
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhCoolKey::Setmenuitemtext Result of menu item: %d. \n",result));
+
+ if(result == noErr)
+ {
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhCoolKey::Setmenuitemtext changing item index: %d . \n",theIndex));
+ CFStringRef cfStr= CFStringCreateWithCString (
+ NULL,
+ aText,
+ kCFStringEncodingASCII
+ );
+
+ OSStatus result = SetMenuItemTextWithCFString (
+ mDockMenu,
+ theIndex ,
+ cfStr
+ );
+
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhCoolKey::Setmenuitemtext Result of setting item text: %d. \n",result));
+
+ }
+
+
+ // Now take care of the root menu, provide exact same item here
+
+ MenuRef tGoMenu = GetMenuHandle (GO_MENU_ID);
+
+
+ if(!tGoMenu)
+ {
+ return S_OK;
+ }
+
+ MenuRef goOutMenu;
+ MenuItemIndex theGoIndex;
+
+ OSStatus resultRoot = GetIndMenuItemWithCommandID (
+ tGoMenu,
+ MENU_ITEM_ID_BASE + aIndex,
+ 1,
+ &goOutMenu,
+ &theGoIndex
+ );
+
+
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhCoolKey::Setmenuitemtext Result of menu item for go menu: %d. \n",result));
+
+ if(resultRoot == noErr)
+ {
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhCoolKey::Setmenuitemtext changing item index: %d . For go menu. \n",theIndex));
+ CFStringRef cfStr= CFStringCreateWithCString (
+ NULL,
+ aText,
+ kCFStringEncodingASCII
+ );
+
+ OSStatus result = SetMenuItemTextWithCFString (
+ tGoMenu,
+ theGoIndex ,
+ cfStr
+ );
+
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhCoolKey::Setmenuitemtext Result of setting item text for root menu: %d. \n",result));
+
+ }
+
+
+
+
+ }
+
return S_OK;
}
@@ -596,6 +762,7 @@
PRBool claimed = 0;
+ PR_LOG(trayLog, PR_LOG_DEBUG, ("rhTray::NotifyTrayWindListener: . \n"));
((rhITrayWindNotify *) (*it))->RhTrayWindEventNotify(aEvent,aEventData, aKeyData, aData1, aData2, &claimed);
@@ -626,6 +793,7 @@
case kEventAppActivated:
PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ApplicationProc App activated! \n"));
+ result = noErr;
break;
case kEventAppDeactivated:
@@ -668,6 +836,12 @@
PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ApplicationProc App kHICommandQuit! \n"));
break;
+
+ case MENU_ITEM_ID_BASE:
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ApplicationProc App Manage Smart Cards! \n"));
+ NotifyTrayWindListeners(MENU_EVT,MENU_SHOW);
+
+ break;
};
@@ -714,6 +888,8 @@
//::InstallStandardEventHandler(target);
::InstallEventHandler(target,mEventHandlerUPP,numTypes,eventTypes, (void *) this,&mEventHandlerRef);
+ ShowWindow();
+
return S_OK;
}
@@ -728,18 +904,18 @@
if(IsWindowCollapsed(mWnd))
{
PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: ShowWindow : uncollapsing collapsed window. \n"));
- ::CollapseWindow(mWnd,FALSE);
+ //::CollapseWindow(mWnd,FALSE);
}
if(!IsWindowVisible(mWnd))
{
PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: ShowWindow : Window not visible showing... \n"));
- ::ShowWindow(mWnd);
+ //::ShowWindow(mWnd);
}
- //::BringToFront(mWnd);
+ ::BringToFront(mWnd);
PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: ShowWindow : \n"));
rhTray::ShowApp();
@@ -753,15 +929,6 @@
{
PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: HideWindow \n"));
-
- //OSStatus res = ::CollapseWindow(mWnd,TRUE);
-
- //::HideWindow(mWnd);
-
- rhTray::HideApp();
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: HideWindow \n"));
-
}
}
@@ -783,9 +950,6 @@
PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener::WindowProc attempting Window close! \n"));
- if(self)
- self->HideWindow();
- //result = noErr;
break;
case kEventWindowHidden:
Index: rhTray.cpp
===================================================================
RCS file: /cvs/dirsec/esc/src/app/xpcom/tray/rhTray.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- rhTray.cpp 27 Sep 2006 17:21:58 -0000 1.3
+++ rhTray.cpp 25 Oct 2006 03:59:03 -0000 1.4
@@ -23,7 +23,7 @@
NS_IMPL_ISUPPORTS1(rhTray, rhITray)
-#include "Winuser.h"
+#include "WinUser.h"
HWND rhTray::mWnd = 0;
int rhTray::mInitialized = 0;
@@ -34,8 +34,11 @@
map< nsIBaseWindow *, rhTrayWindowListener *> rhTray::mWindowMap;
+map<unsigned int,string> rhTray::mMenuItemStringMap;
+
NOTIFYICONDATA rhTray::mIconData;
+
const TCHAR* LISTENER_INSTANCE =
TEXT("_RH_TRAY_WIND_LISTENER_INST");
@@ -192,6 +195,21 @@
/* void settooltipmsg (in string aMessage); */
NS_IMETHODIMP rhTray::Settooltipmsg(const char *aMessage)
{
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Settooltipmsg %s \n",aMessage));
+strcpy(rhTray::mIconData.szTip, aMessage);
+
+ if(!aMessage)
+ return E_FAIL;
+
+ if(strlen(aMessage) >= 64)
+ return E_FAIL;
+
+ strcpy(rhTray::mIconData.szTip, aMessage);
+
+
+ ::Shell_NotifyIcon(NIM_MODIFY,&rhTray::mIconData);
+
+
return NS_OK;
}
@@ -250,6 +268,8 @@
PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Initialize \n"));
+ CreateMutex(NULL, FALSE, "ESCMutex");
+
HRESULT res = CreateEventWindow();
@@ -311,6 +331,8 @@
DestroyEventWindow();
RemoveIcon();
+ rhTray::mMenuItemStringMap.clear();
+
return S_OK;
}
@@ -444,8 +466,10 @@
switch(lParam)
{
case WM_LBUTTONDBLCLK:
+ case WM_LBUTTONDOWN:
PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::WindowProc: WM_LBUTTONDBLCLK \n"));
+ NotifyTrayWindListeners(MENU_EVT,MENU_SHOW);
ShowAllListeners();
break;
@@ -461,14 +485,11 @@
case ID_SHOW:
+ NotifyTrayWindListeners(MENU_EVT,MENU_SHOW);
+
ShowAllListeners();
break;
- case ID_HIDE:
-
- HideAllListeners();
- break;
-
case IDM_EXIT:
PostQuitMessage(0);
@@ -556,6 +577,8 @@
{
HMENU hMenu, hPopup = 0;
+ const int numMenuItems = 2;
+
hMenu = ::LoadMenu (::GetModuleHandle("rhTray.dll"),
MAKEINTRESOURCE (PopupMenuResource));
@@ -567,6 +590,68 @@
hPopup = ::GetSubMenu (hMenu, 0);
+ int numItems = rhTray::mMenuItemStringMap.size();
+
+
+
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ShowPopupMenu num menu item strings : %d\n",numItems));
+ // Change the menu items text if possible
+
+ MENUITEMINFO mii = {0};
+
+ unsigned int menuItemID = 0;
+
+ int i = 0;
+
+ if(numItems == numMenuItems)
+ {
+ for (i = 0 ;i < numMenuItems; i++)
+ {
+ mii.cbSize = sizeof(MENUITEMINFO);
+ mii.fMask = MIIM_TYPE ;
+
+
+
+ char * itemText = (char *) (rhTray::mMenuItemStringMap[i]).c_str();
+
+
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ShowPopupMenu menutext: %d text %s \n",i,itemText));
+ if(itemText)
+ {
+
+ if(i == 0)
+ {
+ menuItemID= ID_SHOW;
+ }
+ else
+ {
+ menuItemID= IDM_EXIT;
+
+ }
+
+ if( GetMenuItemInfo(hPopup,menuItemID,FALSE,&mii))
+ {
+ char *tmpBuff = NULL;
+
+ tmpBuff = strdup(itemText);
+
+ mii.cch=strlen(itemText);
+ mii.dwTypeData=tmpBuff;
+ SetMenuItemInfo(hPopup,menuItemID,FALSE,&mii);
+
+ free(tmpBuff);
+ }
+ else
+ {
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ShowPopupMenu Can't GetMenuItemInfo \n"));
+
+ }
+ }
+
+ }
+
+ }
+
::SetForegroundWindow (rhTray::mWnd);
WORD cmd = ::TrackPopupMenu (hPopup, TPM_RIGHTBUTTON | TPM_RETURNCMD,
@@ -644,6 +729,18 @@
/* void setmenuitemtext (in unsigned long aIndex, in string aText); */
NS_IMETHODIMP rhTray::Setmenuitemtext(PRUint32 aIndex, const char *aText)
{
+
+
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Setmenuitemtext index: %d text: %s\n",aIndex, aText));
+
+ if(aIndex >= 0 && aIndex <= 10 && aText)
+ {
+ rhTray::mMenuItemStringMap[aIndex] = aText;
+
+ }
+
+
+
return S_OK;
}
@@ -794,16 +891,16 @@
if(me)
{
- me->HideWindow();
+ //me->HideWindow();
}
PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener Minimize\n"));
- eventClaimed = 1;
+ //eventClaimed = 1;
break;
case HTMAXBUTTON:
PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: Maximize \n"));
- eventClaimed = 1;
+ //eventClaimed = 1;
break;
case HTCLOSE:
@@ -812,10 +909,10 @@
if(me)
{
- me->HideWindow();
+ //me->HideWindow();
}
- eventClaimed = 1;
+ //eventClaimed = 1;
break;
@@ -943,9 +1040,9 @@
if(mWnd)
{
PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: ShowWindow \n"));
- ::ShowWindow(mWnd,SW_SHOW);
+ //::ShowWindow(mWnd,SW_SHOW);
- ::ShowWindow(mWnd,SW_RESTORE);
+ //::ShowWindow(mWnd,SW_RESTORE);
}
@@ -958,7 +1055,13 @@
PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: Hide Window \n"));
- ::ShowWindow(mWnd,SW_MINIMIZE);
+ ::ShowWindow(mWnd,SW_HIDE);
+
+ //Change style to nix the taskbar button
+
+ ::SetWindowLongPtr(mWnd,GWL_EXSTYLE,GetWindowLongPtr(mWnd,GWL_STYLE) | WS_EX_TOOLWINDOW);
+
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: Hide Window , try to hide owner window too. \n"));
::ShowWindow(mWnd,SW_HIDE);
}
Index: rhTray.h
===================================================================
RCS file: /cvs/dirsec/esc/src/app/xpcom/tray/rhTray.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- rhTray.h 13 Sep 2006 17:50:07 -0000 1.2
+++ rhTray.h 25 Oct 2006 03:59:03 -0000 1.3
@@ -68,6 +68,7 @@
#endif
#include <map>
+#include <string>
using namespace std;
// generate unique ID here with uuidgen
@@ -142,6 +143,8 @@
static map< nsIBaseWindow *, rhTrayWindowListener *> mWindowMap;
+ static map<unsigned int,string> mMenuItemStringMap;
+
static HRESULT ShowPopupMenu (WORD PopupMenuResource);
HRESULT AddListener(nsIBaseWindow *aBaseWindow);
@@ -343,6 +346,8 @@
static EventHandlerRef mEventHandlerRef;
static EventHandlerUPP mEventHandlerUPP;
+ static MenuRef mDockMenu;
+ static MenuRef mRootMenu;
// Icon menu related
- Previous message (by thread): [Fedora-directory-commits] esc/src/app/xpcom CoolKeyCSP.cpp, 1.2, 1.3 CoolKeyCSP.h, 1.1.1.1, 1.2 Makefile.moz, 1.3, 1.4 openkey.h, 1.1.1.1, 1.2 rhCoolKey.cpp, 1.3, 1.4
- Next message (by thread): [Fedora-directory-commits] esc/src/app/xul/esc application.ini, 1.2, 1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Fedora-directory-commits
mailing list