[Fedora-directory-commits] esc/src/lib/coolkey CoolKey.cpp,1.4,1.5
by Doctor Conrad
Author: jmagne
Update of /cvs/dirsec/esc/src/lib/coolkey
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv1991
Modified Files:
CoolKey.cpp
Log Message:
Add time stamps to log messages and handle cancelled operation better.
Index: CoolKey.cpp
===================================================================
RCS file: /cvs/dirsec/esc/src/lib/coolkey/CoolKey.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- CoolKey.cpp 9 Feb 2007 22:00:37 -0000 1.4
+++ CoolKey.cpp 24 Feb 2007 02:14:07 -0000 1.5
@@ -32,6 +32,7 @@
#include <list>
#include <algorithm>
#include <prlog.h>
+#include <time.h>
#include "CoolKey.h"
static NSSManager* g_NSSManager = NULL;
@@ -42,57 +43,56 @@
struct ActiveKeyNode;
HRESULT AddNodeToActiveKeyList(ActiveKeyNode *aNode);
-//extern HRESULT RemoveKeyFromActiveKeyList(const CoolKey *aKey);
HRESULT ClearActiveKeyList(void);
ActiveKeyNode *GetNodeInActiveKeyList(const CoolKey *aKey);
-
-
COOLKEY_API HRESULT CoolKeyInit(const char *aAppDir)
{
+ char tBuff[56];
- PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyInit: appDir %s \n",aAppDir));
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("%s CoolKeyInit: appDir %s \n",GetTStamp(tBuff,56),aAppDir));
- if (g_NSSManager)
- {
- PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyInit:g_NSSManager already exists. \n"));
- return E_FAIL;
- }
+ if (g_NSSManager)
+ {
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG, ( "%s CoolKeyInit:g_NSSManager already exists. \n",GetTStamp(tBuff,56)));
+ return E_FAIL;
+ }
- InitCoolKeyList();
+ InitCoolKeyList();
- g_NSSManager = new NSSManager();
+ g_NSSManager = new NSSManager();
- if (!g_NSSManager)
- {
- PR_LOG( coolKeyLog, PR_LOG_ERROR, ("CoolKeyInit:Failed to create NSSManager.\n"));
- return E_FAIL;
- }
+ if (!g_NSSManager)
+ {
+ PR_LOG( coolKeyLog, PR_LOG_ERROR, ("%s CoolKeyInit:Failed to create NSSManager.\n",GetTStamp(tBuff,56)));
+ return E_FAIL;
+ }
- HRESULT rv = g_NSSManager->InitNSS(aAppDir);
- if (rv == E_FAIL)
- {
- PR_LOG( coolKeyLog, PR_LOG_ERROR, ("Failed to initialize Crypto library! \n"));
- return rv;
- }
+ HRESULT rv = g_NSSManager->InitNSS(aAppDir);
+ if (rv == E_FAIL)
+ {
+ PR_LOG( coolKeyLog, PR_LOG_ERROR, ("%s Failed to initialize Crypto library! \n",GetTStamp(tBuff,56)));
+ return rv;
+ }
- return S_OK;
+ return S_OK;
}
COOLKEY_API HRESULT CoolKeyShutdown()
{
+ char tBuff[56];
- PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyShutdown:\n"));
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("%s CoolKeyShutdown:\n",GetTStamp(tBuff,56)));
- DestroyCoolKeyList();
+ DestroyCoolKeyList();
- if (g_NSSManager) {
- g_NSSManager->Shutdown();
- delete g_NSSManager;
- g_NSSManager = 0;
- }
+ if (g_NSSManager) {
+ g_NSSManager->Shutdown();
+ delete g_NSSManager;
+ g_NSSManager = 0;
+ }
- return S_OK;
+ return S_OK;
}
static CoolKeyDispatch g_Dispatch = NULL;
@@ -107,23 +107,20 @@
CoolKeyReference reference, CoolKeyRelease release,
CoolKeyGetConfigValue getconfigvalue,CoolKeySetConfigValue setconfigvalue)
{
- g_Dispatch = dispatch;
- g_Reference = reference;
- g_Release = release;
- g_GetConfigValue = getconfigvalue;
- g_SetConfigValue = setconfigvalue;
-
-
+ g_Dispatch = dispatch;
+ g_Reference = reference;
+ g_Release = release;
+ g_GetConfigValue = getconfigvalue;
+ g_SetConfigValue = setconfigvalue;
- char * suppressPINPrompt =(char*) CoolKeyGetConfig("esc.disable.password.prompt");
+ char * suppressPINPrompt =(char*) CoolKeyGetConfig("esc.disable.password.prompt");
-
- if(suppressPINPrompt && !strcmp(suppressPINPrompt,"yes"))
- {
- PK11_SetPasswordFunc( CoolKeyVerifyPassword);
- }
- // Set the verify password callback here, no params needed we know what it is
- return 0;
+ if(suppressPINPrompt && !strcmp(suppressPINPrompt,"yes"))
+ {
+ PK11_SetPasswordFunc( CoolKeyVerifyPassword);
+ }
+ // Set the verify password callback here, no params needed we know what it is
+ return 0;
}
#define REFERENCE_LISTENER(list) \
@@ -138,246 +135,247 @@
char *CoolKeyVerifyPassword(PK11SlotInfo *slot,PRBool retry,void *arg)
{
- PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyVerifyPassword: \n"));
+ char tBuff[56];
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("%s CoolKeyVerifyPassword: \n",GetTStamp(tBuff,56)));
return NULL;
}
COOLKEY_API HRESULT CoolKeyRegisterListener(CoolKeyListener* aListener)
{
- PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyRegisterListener: aListener %p\n",aListener));
+ char tBuff[56];
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("%s CoolKeyRegisterListener: aListener %p\n",GetTStamp(tBuff,56),aListener));
+ if (!aListener)
+ return -1;
- if (!aListener)
- return -1;
-
- REFERENCE_LISTENER(aListener);
- g_Listeners.push_back(aListener);
+ REFERENCE_LISTENER(aListener);
+ g_Listeners.push_back(aListener);
- return 0;
+ return 0;
}
COOLKEY_API HRESULT CoolKeyUnregisterListener(CoolKeyListener* aListener)
{
-
- PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyUnregisterListener:\n"));
- if (!aListener)
- return -1;
+ char tBuff[56];
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("%s CoolKeyUnregisterListener:\n",GetTStamp(tBuff,56)));
+ if (!aListener)
+ return -1;
- std::list<CoolKeyListener*>::iterator it =
+ std::list<CoolKeyListener*>::iterator it =
find(g_Listeners.begin(), g_Listeners.end(), aListener);
- if (it != g_Listeners.end()) {
-
- PR_LOG( coolKeyLog, PR_LOG_DEBUG,
- ("CoolKeyUnregisterListener: erasing listener %p \n",*it));
- g_Listeners.erase(it);
- RELEASE_LISTENER(aListener);
- }
- return 0;
-}
-
+ if (it != g_Listeners.end()) {
-HRESULT CoolKeyNotify(const CoolKey *aKey, CoolKeyState aKeyState,
- int aData,const char *strData)
-{
- PR_LOG( coolKeyLog, PR_LOG_DEBUG,
- ("CoolKeyNotify: key %s state %d data %d strData %s",
- aKey->mKeyID,aKeyState,aData,strData));
-
- std::list<CoolKeyListener*>::iterator it;
- for(it=g_Listeners.begin(); it!=g_Listeners.end(); ++it)
- {
- PR_LOG( coolKeyLog, PR_LOG_DEBUG,
- ("CoolKeyNotify: About to notify listener %p",*it));
-
- if (g_Dispatch) {
- (*g_Dispatch)(*it, aKey->mKeyType, aKey->mKeyID,
- aKeyState, aData, strData);
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG,
+ ("%s CoolKeyUnregisterListener: erasing listener %p \n",GetTStamp(tBuff,56),*it));
+ g_Listeners.erase(it);
+ RELEASE_LISTENER(aListener);
}
- }
-
- return S_OK;
+ return 0;
}
struct BlinkTimerParams
{
- BlinkTimerParams(const CoolKey *aKey) : mKey(*aKey), mSlot(0), mRate(0),
+ BlinkTimerParams(const CoolKey *aKey) : mKey(*aKey), mSlot(0), mRate(0),
mEnd(0), mThread(0), mActive(false)
- {
- }
+ {
+ }
- ~BlinkTimerParams()
- {
- mActive = false;
+ ~BlinkTimerParams()
+ {
+ mActive = false;
- if (mThread && mThread != PR_GetCurrentThread())
- PR_JoinThread(mThread);
- }
+ if (mThread && mThread != PR_GetCurrentThread())
+ PR_JoinThread(mThread);
+ }
- AutoCoolKey mKey;
- PK11SlotInfo *mSlot;
- unsigned long mRate;
- PRIntervalTime mEnd;
- PRThread *mThread;
- bool mActive;
+ AutoCoolKey mKey;
+ PK11SlotInfo *mSlot;
+ unsigned long mRate;
+ PRIntervalTime mEnd;
+ PRThread *mThread;
+ bool mActive;
};
struct ActiveKeyNode
{
- ActiveKeyNode(const CoolKey *aKey) : mKey(*aKey)
- {
- }
+ ActiveKeyNode(const CoolKey *aKey) : mKey(*aKey)
+ {
+ }
- virtual ~ActiveKeyNode()
- {
- }
+ virtual ~ActiveKeyNode()
+ {
+ }
- virtual HRESULT OnRemoval() = 0;
+ virtual HRESULT OnRemoval() = 0;
- AutoCoolKey mKey;
+ AutoCoolKey mKey;
};
struct ActiveKeyHandler : public ActiveKeyNode
{
- ActiveKeyHandler(const CoolKey *aKey, CoolKeyHandler *aHandler)
- : ActiveKeyNode(aKey)
- {
- PR_LOG( coolKeyLog, PR_LOG_DEBUG,
- ("ActiveKeyHandler::ActiveKeyHandler \n"));
+ ActiveKeyHandler(const CoolKey *aKey, CoolKeyHandler *aHandler)
+ : ActiveKeyNode(aKey)
+ {
+ char tBuff[56];
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG,
+ ("%s ActiveKeyHandler::ActiveKeyHandler \n",GetTStamp(tBuff,56)));
- assert(aHandler);
- mHandler = aHandler;
- mHandler->AddRef();
- }
+ assert(aHandler);
+ mHandler = aHandler;
+ mHandler->AddRef();
+ }
- ~ActiveKeyHandler()
- {
- if (mHandler)
+ ~ActiveKeyHandler()
{
- PR_LOG( coolKeyLog, PR_LOG_DEBUG,
- ("ActiveKeyHandler::~ActiveKeyHandler \n"));
+ char tBuff[56];
+ if (mHandler)
+ {
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG,
+ ("%s ActiveKeyHandler::~ActiveKeyHandler \n",GetTStamp(tBuff,56)));
- mHandler->Release();
+ mHandler->Release();
+ }
}
- }
- HRESULT OnRemoval() { return S_OK; }
+ HRESULT OnRemoval() { return S_OK; }
- CoolKeyHandler *mHandler;
+ CoolKeyHandler *mHandler;
};
struct ActiveBlinker : public ActiveKeyNode
{
- ActiveBlinker(const CoolKey *aKey, BlinkTimerParams *aParams)
- : ActiveKeyNode(aKey)
- {
- assert(aParams);
- mParams = aParams;
- }
+ ActiveBlinker(const CoolKey *aKey, BlinkTimerParams *aParams)
+ : ActiveKeyNode(aKey)
+ {
+ assert(aParams);
+ mParams = aParams;
+ }
- ~ActiveBlinker()
- {
- if (mParams)
- delete mParams;
- }
+ ~ActiveBlinker()
+ {
+ if (mParams)
+ delete mParams;
+ }
+
+ HRESULT OnRemoval()
+ {
+ if (mParams) {
+ mParams->mActive = false;
- HRESULT OnRemoval()
- {
- if (mParams) {
- mParams->mActive = false;
-
- if (mParams->mThread && mParams->mThread != PR_GetCurrentThread()) {
- PR_JoinThread(mParams->mThread);
- mParams->mThread = 0;
- }
+ if (mParams->mThread && mParams->mThread != PR_GetCurrentThread()) {
+ PR_JoinThread(mParams->mThread);
+ mParams->mThread = 0;
+ }
- delete mParams;
- mParams = 0;
+ delete mParams;
+ mParams = 0;
+ }
+
+ return S_OK;
}
+ BlinkTimerParams *mParams;
+};
+
+HRESULT CoolKeyNotify(const CoolKey *aKey, CoolKeyState aKeyState,
+ int aData,const char *strData)
+{
+ char tBuff[56];
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG,
+ ("%s CoolKeyNotify: key %s state %d data %d strData %s",GetTStamp(tBuff,56),
+ aKey->mKeyID,aKeyState,aData,strData));
+ if(aKeyState == eCKState_KeyRemoved)
+ {
+ ActiveKeyHandler *node = (ActiveKeyHandler *) GetNodeInActiveKeyList(aKey);
+ if(node)
+ {
+ if(node->mHandler)
+ {
+ node->mHandler->CancelAuthParameters();
+ }
+ }
+ }
+ std::list<CoolKeyListener*>::iterator it;
+ for(it=g_Listeners.begin(); it!=g_Listeners.end(); ++it)
+ {
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG,
+ ("%s CoolKeyNotify: About to notify listener %p",GetTStamp(tBuff,56),*it));
+ if (g_Dispatch) {
+ (*g_Dispatch)(*it, aKey->mKeyType, aKey->mKeyID,
+ aKeyState, aData, strData);
+ }
+ }
return S_OK;
- }
+}
+
- BlinkTimerParams *mParams;
-};
static std::list<ActiveKeyNode *> g_ActiveKeyList;
static void PR_CALLBACK BlinkTimer(void *arg)
{
- BlinkTimerParams *params = (BlinkTimerParams*)arg;
+ BlinkTimerParams *params = (BlinkTimerParams*)arg;
- while(params->mActive && PR_IntervalNow() < params->mEnd) {
- CKYBuffer ATR;
- CKYBuffer_InitEmpty(&ATR);
- CKYCardConnection *conn = NULL;
- CKYISOStatus apduRC = 0;
- CKYStatus status;
- const char *readerName = NULL;
-
- CKYCardContext *cardCtxt = CKYCardContext_Create(SCARD_SCOPE_USER);
- assert(cardCtxt);
- if (!cardCtxt) {
- goto done;
- }
+ while(params->mActive && PR_IntervalNow() < params->mEnd) {
+ CKYBuffer ATR;
+ CKYBuffer_InitEmpty(&ATR);
+ CKYCardConnection *conn = NULL;
+ CKYISOStatus apduRC = 0;
+ CKYStatus status;
+ const char *readerName = NULL;
+
+ CKYCardContext *cardCtxt = CKYCardContext_Create(SCARD_SCOPE_USER);
+ assert(cardCtxt);
+ if (!cardCtxt) {
+ goto done;
+ }
- conn = CKYCardConnection_Create(cardCtxt);
- assert(conn);
- if (!conn) {
- goto done;
- }
+ conn = CKYCardConnection_Create(cardCtxt);
+ assert(conn);
+ if (!conn) {
+ goto done;
+ }
- readerName = GetReaderNameForKeyID(¶ms->mKey);
- assert(readerName);
- if (!readerName) {
- goto done;
- }
+ readerName = GetReaderNameForKeyID(¶ms->mKey);
+ assert(readerName);
+ if (!readerName) {
+ goto done;
+ }
- status = CKYCardConnection_Connect(conn, readerName);
- if (status != CKYSUCCESS) {
- goto done;
- }
- unsigned long state;
+ status = CKYCardConnection_Connect(conn, readerName);
+ if (status != CKYSUCCESS) {
+ goto done;
+ }
+ unsigned long state;
- status = CKYCardConnection_GetStatus(conn, &state, &ATR);
- if (status != CKYSUCCESS) {
- goto done;
- }
+ status = CKYCardConnection_GetStatus(conn, &state, &ATR);
+ if (status != CKYSUCCESS) {
+ goto done;
+ }
- apduRC = 0;
- status = CKYApplet_SelectCardManager(conn, &apduRC);
- if (status != CKYSUCCESS) {
- goto done;
- }
+ apduRC = 0;
+ status = CKYApplet_SelectCardManager(conn, &apduRC);
+ if (status != CKYSUCCESS) {
+ goto done;
+ }
- done:
+ done:
- if (conn) {
- CKYCardConnection_Disconnect(conn);
- CKYCardConnection_Destroy(conn);
- }
- if (cardCtxt) {
- CKYCardContext_Destroy(cardCtxt);
- }
+ if (conn) {
+ CKYCardConnection_Disconnect(conn);
+ CKYCardConnection_Destroy(conn);
+ }
+ if (cardCtxt) {
+ CKYCardContext_Destroy(cardCtxt);
+ }
- CKYBuffer_FreeData(&ATR);
+ CKYBuffer_FreeData(&ATR);
- PR_Sleep(PR_MillisecondsToInterval(params->mRate));
- }
+ PR_Sleep(PR_MillisecondsToInterval(params->mRate));
+ }
-// while(params->mActive && PR_IntervalNow() < params->mEnd) {
- /* call some function that requires communication with the card */
- // CK_TOKEN_INFO dummy;
- //PK11_GetTokenInfo(params->mSlot, &dummy);
-
-/* CoolKeyInfo *
- CKHGetCoolKeyInfo("dummy"); */
-// tokenName = PK11_GetTokenName(params->mSlot);
-
- // PR_Sleep(PR_MillisecondsToInterval(params->mRate));
- // }
-
PK11_FreeSlot(params->mSlot);
// The assumption we're making here is that if we get here
@@ -390,7 +388,6 @@
if (params->mActive) {
CoolKeyNotify(¶ms->mKey, eCKState_BlinkComplete, 0);
-// ProxyEventToUIThread(new RemoveKeyFromActiveKeyListEvent(¶ms->mKey));
RemoveKeyFromActiveKeyList(¶ms->mKey);
}
}
@@ -399,47 +396,48 @@
CoolKeyBlinkToken(const CoolKey *aKey, unsigned long aRate, unsigned long aDuration)
{
- PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyBlinkToken:\n"));
- BlinkTimerParams* params = new BlinkTimerParams(aKey);
+ char tBuff[56];
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("%s CoolKeyBlinkToken:\n",GetTStamp(tBuff,56)));
+ BlinkTimerParams* params = new BlinkTimerParams(aKey);
- if (!params)
- {
- PR_LOG( coolKeyLog, PR_LOG_DEBUG,
- ("CoolKeyBlinkToken: Can't create BlinkTimerParams.\n"));
- return E_FAIL;
- }
+ if (!params)
+ {
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG,
+ ("%s CoolKeyBlinkToken: Can't create BlinkTimerParams.\n",GetTStamp(tBuff,56)));
+ return E_FAIL;
+ }
- params->mSlot = GetSlotForKeyID(aKey);
+ params->mSlot = GetSlotForKeyID(aKey);
- if (!params->mSlot) {
+ if (!params->mSlot) {
- PR_LOG( coolKeyLog, PR_LOG_DEBUG,
- ("CoolKeyBlinkToken:Can't get Slot for key.\n"));
- delete params;
- return E_FAIL;
- }
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG,
+ ("%s CoolKeyBlinkToken:Can't get Slot for key.\n",GetTStamp(tBuff,56)));
+ delete params;
+ return E_FAIL;
+ }
- params->mRate = aRate;
- params->mEnd = PR_IntervalNow()
+ params->mRate = aRate;
+ params->mEnd = PR_IntervalNow()
+ PR_MillisecondsToInterval(aDuration + /*fudge*/ 200);
- params->mActive = true;
+ params->mActive = true;
- ActiveBlinker *node = new ActiveBlinker(aKey, params);
+ ActiveBlinker *node = new ActiveBlinker(aKey, params);
- if (!node) {
- delete params;
- return E_FAIL;
- }
+ if (!node) {
+ delete params;
+ return E_FAIL;
+ }
- HRESULT hres = AddNodeToActiveKeyList(node);
+ HRESULT hres = AddNodeToActiveKeyList(node);
- if (hres == E_FAIL) {
- delete params;
- return E_FAIL;
- }
+ if (hres == E_FAIL) {
+ delete params;
+ return E_FAIL;
+ }
- params->mThread = PR_CreateThread(PR_SYSTEM_THREAD,
+ params->mThread = PR_CreateThread(PR_SYSTEM_THREAD,
BlinkTimer,
(void*)params,
PR_PRIORITY_NORMAL,
@@ -447,88 +445,86 @@
PR_JOINABLE_THREAD,
0);
- CoolKeyNotify(aKey, eCKState_BlinkStart, 0);
+ CoolKeyNotify(aKey, eCKState_BlinkStart, 0);
- return S_OK;
+ return S_OK;
}
HRESULT
AddNodeToActiveKeyList(ActiveKeyNode *aNode)
{
+ char tBuff[56];
- PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("AddNodeToActiveKeyList:\n"));
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("%s AddNodeToActiveKeyList:\n",GetTStamp(tBuff,56)));
- g_ActiveKeyList.push_back(aNode);
- return S_OK;
+ g_ActiveKeyList.push_back(aNode);
+ return S_OK;
}
HRESULT
RemoveKeyFromActiveKeyList(const CoolKey *aKey)
{
- PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("RemoveKeyFromActiveKeyList:\n"));
- std::list<ActiveKeyNode *>::iterator it;
-
- for (it = g_ActiveKeyList.begin(); it != g_ActiveKeyList.end(); ++it) {
- if ((*it)->mKey == *aKey) {
- ActiveKeyNode *node = *it;
- g_ActiveKeyList.erase(it);
- node->OnRemoval();
- delete node;
- return S_OK;
+ char tBuff[56];
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("%s RemoveKeyFromActiveKeyList:\n",GetTStamp(tBuff,56)));
+ std::list<ActiveKeyNode *>::iterator it;
+
+ for (it = g_ActiveKeyList.begin(); it != g_ActiveKeyList.end(); ++it) {
+ if ((*it)->mKey == *aKey) {
+ ActiveKeyNode *node = *it;
+ g_ActiveKeyList.erase(it);
+ node->OnRemoval();
+ delete node;
+ return S_OK;
+ }
}
- }
// XXX: Do we want to return E_FAIL instead?
- return S_OK;
+ return S_OK;
}
HRESULT
ClearActiveKeyList()
{
- std::list<ActiveKeyNode *>::iterator it;
+ std::list<ActiveKeyNode *>::iterator it;
- for (it = g_ActiveKeyList.begin(); it != g_ActiveKeyList.end(); ++it) {
- if (*it) {
- ActiveKeyNode *node = *it;
- delete node;
+ for (it = g_ActiveKeyList.begin(); it != g_ActiveKeyList.end(); ++it) {
+ if (*it) {
+ ActiveKeyNode *node = *it;
+ delete node;
+ }
}
- }
- g_ActiveKeyList.clear();
+ g_ActiveKeyList.clear();
- return S_OK;
+ return S_OK;
}
-
-
HRESULT
-
IsNodeInActiveKeyList(const CoolKey *aKey)
{
+ ActiveKeyNode *test = NULL;
- ActiveKeyNode *test = NULL;
-
- test = GetNodeInActiveKeyList(aKey);
+ test = GetNodeInActiveKeyList(aKey);
- if(test)
- return 1;
+ if(test)
+ return 1;
- return 0;
+ return 0;
}
ActiveKeyNode *
GetNodeInActiveKeyList(const CoolKey *aKey)
{
- std::list<ActiveKeyNode *>::iterator it;
+ std::list<ActiveKeyNode *>::iterator it;
- for (it = g_ActiveKeyList.begin(); it != g_ActiveKeyList.end(); ++it) {
- if ((*it)->mKey == *aKey)
- return *it;
- }
+ for (it = g_ActiveKeyList.begin(); it != g_ActiveKeyList.end(); ++it) {
+ if ((*it)->mKey == *aKey)
+ return *it;
+ }
- return NULL;
+ return NULL;
}
HRESULT CoolKeyEnrollToken(const CoolKey *aKey, const char *aTokenType,
@@ -536,157 +532,161 @@
const char *aScreenNamePWord,const char *aTokenCode)
{
- PR_LOG( coolKeyLog, PR_LOG_DEBUG,
- ("CoolKeyEnrollToken: aTokenCode %s\n",aTokenCode));
- if (!aKey || !aKey->mKeyID)
- return E_FAIL;
+ char tBuff[56];
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG,
+ ("%s CoolKeyEnrollToken: aTokenCode %s\n",GetTStamp(tBuff,56),aTokenCode));
+ if (!aKey || !aKey->mKeyID)
+ return E_FAIL;
- CoolKeyHandler *handler = new CoolKeyHandler();
+ CoolKeyHandler *handler = new CoolKeyHandler();
- if (!handler)
- return E_FAIL;
+ if (!handler)
+ return E_FAIL;
- ActiveKeyHandler *node = new ActiveKeyHandler(aKey, handler);
+ ActiveKeyHandler *node = new ActiveKeyHandler(aKey, handler);
- if (!node) {
- delete handler;
- return E_FAIL;
- }
+ if (!node) {
+ delete handler;
+ return E_FAIL;
+ }
// node now has the only reference to the
// key handler we just created. It will automatically
// destroy the key handler when it is removed from
// the active key list.
- HRESULT hres = AddNodeToActiveKeyList(node);
+ HRESULT hres = AddNodeToActiveKeyList(node);
- if (hres == E_FAIL) {
- delete handler;
- return hres;
- }
+ if (hres == E_FAIL) {
+ delete handler;
+ return hres;
+ }
- hres = handler->Init(aKey, aScreenName, aPIN,aScreenNamePWord,aTokenCode,ENROLL);
+ hres = handler->Init(aKey, aScreenName, aPIN,aScreenNamePWord,aTokenCode,ENROLL);
- if (hres == E_FAIL) {
- RemoveKeyFromActiveKeyList(aKey);
- return hres;
- }
+ if (hres == E_FAIL) {
+ RemoveKeyFromActiveKeyList(aKey);
+ return hres;
+ }
- hres = handler->Enroll(aTokenType);
+ hres = handler->Enroll(aTokenType);
- if (hres == E_FAIL) {
- RemoveKeyFromActiveKeyList(aKey);
- return hres;
- }
+ if (hres == E_FAIL) {
+ RemoveKeyFromActiveKeyList(aKey);
+ return hres;
+ }
- CoolKeyNotify(aKey, eCKState_EnrollmentStart, aScreenName ? 1 : 0);
+ CoolKeyNotify(aKey, eCKState_EnrollmentStart, aScreenName ? 1 : 0);
- return S_OK;
+ return S_OK;
}
HRESULT CoolKeyResetTokenPIN(const CoolKey *aKey, const char *aScreenName, const char *aPIN,const char *aScreenNamePwd)
{
- PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyResetTokenPIN:\n"));
- if (!aKey || !aKey->mKeyID)
- return E_FAIL;
+ char tBuff[56];
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("%s CoolKeyResetTokenPIN:\n",GetTStamp(tBuff,56)));
+ if (!aKey || !aKey->mKeyID)
+ return E_FAIL;
- CoolKeyHandler *handler = new CoolKeyHandler();
+ CoolKeyHandler *handler = new CoolKeyHandler();
- if (!handler)
- return E_FAIL;
+ if (!handler)
+ return E_FAIL;
- ActiveKeyHandler *node = new ActiveKeyHandler(aKey, handler);
+ ActiveKeyHandler *node = new ActiveKeyHandler(aKey, handler);
- if (!node) {
- delete handler;
- return E_FAIL;
- }
+ if (!node) {
+ delete handler;
+ return E_FAIL;
+ }
// node now has the only reference to the
// key handler we just created. It will automatically
// destroy the key handler when it is removed from
// the active key list.
- HRESULT hres = AddNodeToActiveKeyList(node);
+ HRESULT hres = AddNodeToActiveKeyList(node);
- if (hres == E_FAIL) {
- delete handler;
- return E_FAIL;
- }
+ if (hres == E_FAIL) {
+ delete handler;
+ return E_FAIL;
+ }
- hres = handler->Init(aKey, aScreenName, aPIN,aScreenNamePwd,NULL,RESET_PIN);
+ hres = handler->Init(aKey, aScreenName, aPIN,aScreenNamePwd,NULL,RESET_PIN);
- if (hres == E_FAIL) {
- RemoveKeyFromActiveKeyList(aKey);
- return hres;
- }
+ if (hres == E_FAIL) {
+ RemoveKeyFromActiveKeyList(aKey);
+ return hres;
+ }
- hres = handler->ResetPIN();
+ hres = handler->ResetPIN();
- if (hres == E_FAIL) {
- RemoveKeyFromActiveKeyList(aKey);
- return hres;
- }
+ if (hres == E_FAIL) {
+ RemoveKeyFromActiveKeyList(aKey);
+ return hres;
+ }
- CoolKeyNotify(aKey, eCKState_PINResetStart, aScreenName ? 1 : 0);
+ CoolKeyNotify(aKey, eCKState_PINResetStart, aScreenName ? 1 : 0);
- return S_OK;
+ return S_OK;
}
HRESULT CoolKeyFormatToken(const CoolKey *aKey, const char *aTokenType, const char *aScreenName, const char *aPIN,const char *aScreenNamePWord,
const char *aTokenCode)
{
- PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyFormatToken:\n"));
- if (!aKey || !aKey->mKeyID)
- return E_FAIL;
+ char tBuff[56];
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("%s CoolKeyFormatToken:\n",GetTStamp(tBuff,56)));
+ if (!aKey || !aKey->mKeyID)
+ return E_FAIL;
- CoolKeyHandler *handler = new CoolKeyHandler();
+ CoolKeyHandler *handler = new CoolKeyHandler();
- if (!handler)
- return E_FAIL;
+ if (!handler)
+ return E_FAIL;
- ActiveKeyHandler *node = new ActiveKeyHandler(aKey, handler);
+ ActiveKeyHandler *node = new ActiveKeyHandler(aKey, handler);
- if (!node) {
- delete handler;
- return E_FAIL;
- }
+ if (!node) {
+ delete handler;
+ return E_FAIL;
+ }
// node now has the only reference to the
// key handler we just created. It will automatically
// destroy the key handler when it is removed from
// the active key list.
- HRESULT hres = AddNodeToActiveKeyList(node);
+ HRESULT hres = AddNodeToActiveKeyList(node);
- if (hres == E_FAIL) {
- delete handler;
- return E_FAIL;
- }
+ if (hres == E_FAIL) {
+ delete handler;
+ return E_FAIL;
+ }
- hres = handler->Init(aKey, aScreenName, aPIN,aScreenNamePWord,aTokenCode,FORMAT);
+ hres = handler->Init(aKey, aScreenName, aPIN,aScreenNamePWord,aTokenCode,FORMAT);
- if (hres == E_FAIL) {
- RemoveKeyFromActiveKeyList(aKey);
- return hres;
- }
+ if (hres == E_FAIL) {
+ RemoveKeyFromActiveKeyList(aKey);
+ return hres;
+ }
- hres = handler->Format(aTokenType);
+ hres = handler->Format(aTokenType);
- if (hres == E_FAIL) {
- RemoveKeyFromActiveKeyList(aKey);
- return hres;
- }
+ if (hres == E_FAIL) {
+ RemoveKeyFromActiveKeyList(aKey);
+ return hres;
+ }
- CoolKeyNotify(aKey, eCKState_FormatStart, 0);
+ CoolKeyNotify(aKey, eCKState_FormatStart, 0);
- return S_OK;
+ return S_OK;
}
COOLKEY_API HRESULT CoolKeySetDataValue(const CoolKey *aKey,const char *name, const char *value)
{
- PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeySetDataValue: name %s value %s\n",name,value));
+ char tBuff[56];
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("%s CoolKeySetDataValue: name %s value %s\n",GetTStamp(tBuff,56),name,value));
if (!aKey || !aKey->mKeyID)
return E_FAIL;
@@ -705,140 +705,135 @@
HRESULT CoolKeyCancelTokenOperation(const CoolKey *aKey)
{
+ char tBuff[56];
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("%s CoolKeyCancelTokenOperation:\n",GetTStamp(tBuff,56)));
+ if (!aKey || !aKey->mKeyID)
+ return E_FAIL;
- PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyCancelTokenOperation:\n"));
- if (!aKey || !aKey->mKeyID)
- return E_FAIL;
-
-
- ActiveKeyHandler *node = (ActiveKeyHandler *) GetNodeInActiveKeyList(aKey);
+ ActiveKeyHandler *node = (ActiveKeyHandler *) GetNodeInActiveKeyList(aKey);
-
- if (node) {
+ if (node) {
if(node->mHandler)
{
- node->mHandler->setCancelled();
- node->mHandler->CloseConnection();
+ node->mHandler->setCancelled();
+ node->mHandler->CloseConnection();
}
RemoveKeyFromActiveKeyList(aKey);
RefreshInfoFlagsForKeyID(aKey);
- CoolKeyNotify(aKey, eCKState_OperationCancelled, 0);
+ CoolKeyNotify(aKey, eCKState_OperationCancelled, 0);
- }
+ }
- return S_OK;
- }
+ return S_OK;
+}
bool
CoolKeyHasApplet(const CoolKey *aKey)
{
+ char tBuff[56];
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("%s CoolKeyHasApplet:\n",GetTStamp(tBuff,56)));
+ bool hasApplet = false;
+
+ if (aKey && aKey->mKeyID) {
+ CoolKeyInfo *info = GetCoolKeyInfoByKeyID(aKey);
+ if (info)
+ {
+ hasApplet = (HAS_APPLET(info->mInfoFlags) != 0);
- PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyHasApplet:\n"));
- bool hasApplet = false;
-
- if (aKey && aKey->mKeyID) {
- CoolKeyInfo *info = GetCoolKeyInfoByKeyID(aKey);
- if (info)
- {
- hasApplet = (HAS_APPLET(info->mInfoFlags) != 0);
-
- PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyHasApplet: hasApplet: %d info flags %x\n",hasApplet,info->mInfoFlags));
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("%s CoolKeyHasApplet: hasApplet: %d info flags %x\n",GetTStamp(tBuff,56),hasApplet,info->mInfoFlags));
+ }
}
- }
- return hasApplet;
+ return hasApplet;
}
bool
CoolKeyIsEnrolled(const CoolKey *aKey)
{
- PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyIsEnrolled:\n"));
- bool isEnrolled = false;
-
- if (aKey && aKey->mKeyID) {
- CoolKeyInfo *info = GetCoolKeyInfoByKeyID(aKey);
- if (info)
- {
- isEnrolled = (IS_PERSONALIZED(info->mInfoFlags) != 0);
+ char tBuff[56];
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("%s CoolKeyIsEnrolled:\n",GetTStamp(tBuff,56)));
+ bool isEnrolled = false;
+
+ if (aKey && aKey->mKeyID) {
+ CoolKeyInfo *info = GetCoolKeyInfoByKeyID(aKey);
+ if (info)
+ {
+ isEnrolled = (IS_PERSONALIZED(info->mInfoFlags) != 0);
- PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyIsEnrolled: enrolled: %d info flags %x\n",isEnrolled,info->mInfoFlags));
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("%s CoolKeyIsEnrolled: enrolled: %d info flags %x\n",GetTStamp(tBuff,56),isEnrolled,info->mInfoFlags));
+ }
}
- }
- return isEnrolled;
+ return isEnrolled;
}
bool
CoolKeyAuthenticate(const CoolKey *aKey, const char *aPIN)
{
- PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyAuthenticate:\n"));
- if (!aKey || !aKey->mKeyID)
- return false;
+ char tBuff[56];
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("%s CoolKeyAuthenticate:\n",GetTStamp(tBuff,56)));
+ if (!aKey || !aKey->mKeyID)
+ return false;
- return NSSManager::AuthenticateCoolKey(aKey, aPIN);
+ return NSSManager::AuthenticateCoolKey(aKey, aPIN);
}
HRESULT
CoolKeyGenerateRandomData(unsigned char *aBuf, int aBufLen)
{
- if (!aBuf || aBufLen < 1)
- return E_FAIL;
+ if (!aBuf || aBufLen < 1)
+ return E_FAIL;
- SECStatus status = PK11_GenerateRandom(aBuf, aBufLen);
- return status;
+ SECStatus status = PK11_GenerateRandom(aBuf, aBufLen);
+ return status;
}
HRESULT CoolKeyGetSignatureLength(const CoolKey *aKey, int *aLength)
{
- return NSSManager::GetSignatureLength(aKey, aLength);
+ return NSSManager::GetSignatureLength(aKey, aLength);
}
HRESULT
CoolKeySignData(const CoolKey *aKey, const unsigned char *aData, int aDataLen, unsigned char *aSignedData, int *aSignedDataLen)
{
- if (!aKey || !aKey->mKeyID || !aData || aDataLen < 1 ||
- !aSignedData || !aSignedDataLen)
- return E_FAIL;
+ if (!aKey || !aKey->mKeyID || !aData || aDataLen < 1 ||
+ !aSignedData || !aSignedDataLen)
+ return E_FAIL;
- return NSSManager::SignDataWithKey(aKey, aData, aDataLen, aSignedData, aSignedDataLen);
+ return NSSManager::SignDataWithKey(aKey, aData, aDataLen, aSignedData, aSignedDataLen);
}
HRESULT
CoolKeyGetCertNicknames( const CoolKey *aKey , std::vector<std::string> & aNames)
{
-
if(!aKey )
return E_FAIL;
- HRESULT res = NSSManager::GetKeyCertNicknames(aKey,aNames);
-
- return res;
+ HRESULT res = NSSManager::GetKeyCertNicknames(aKey,aNames);
+ return res;
}
HRESULT
CoolKeyGetCertInfo(const CoolKey *aKey, char *aCertNickname, std::string & aCertInfo)
{
-
if(!aKey || !aCertNickname)
{
return E_FAIL;
-
}
return NSSManager::GetKeyCertInfo(aKey,aCertNickname,aCertInfo);
-
}
HRESULT
CoolKeyGetPolicy(const CoolKey *aKey, char *aBuf, int aBufLen)
{
- if (!aKey || !aKey->mKeyID || !aBuf || aBufLen < 1)
- return E_FAIL;
+ if (!aKey || !aKey->mKeyID || !aBuf || aBufLen < 1)
+ return E_FAIL;
- return NSSManager::GetKeyPolicy(aKey, aBuf, aBufLen);
+ return NSSManager::GetKeyPolicy(aKey, aBuf, aBufLen);
}
HRESULT
CoolKeyGetIssuedTo(const CoolKey *aKey, char *aBuf, int aBufLength)
@@ -847,16 +842,15 @@
return E_FAIL;
return NSSManager::GetKeyIssuedTo(aKey,aBuf,aBufLength);
-
}
HRESULT CoolKeyGetATR(const CoolKey *aKey, char *aBuf, int aBufLen)
{
-
+ char tBuff[56];
if (!aKey || !aKey->mKeyID || !aBuf || aBufLen < 1)
return E_FAIL;
aBuf[0] = 0;
- PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyGetATR::\n"));
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("%s CoolKeyGetATR::\n",GetTStamp(tBuff,56)));
HRESULT result = S_OK;
@@ -867,23 +861,22 @@
if((int) strlen(atr) < aBufLen)
{
-
sprintf(aBuf,"%s",(char *) atr);
}
return result;
-
}
HRESULT CoolKeyGetIssuerInfo(const CoolKey *aKey, char *aBuf, int aBufLen)
{
-
- if (!aKey || !aKey->mKeyID || !aBuf || aBufLen < 1)
+ char tBuff[56];
+
+ if (!aKey || !aKey->mKeyID || !aBuf || aBufLen < 1)
return E_FAIL;
aBuf[0] = 0;
- PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyGetIssuerInfo::\n"));
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("%s CoolKeyGetIssuerInfo::\n",GetTStamp(tBuff,56)));
CKYBuffer ISSUER_INFO;
CKYBuffer_InitEmpty(&ISSUER_INFO);
@@ -896,38 +889,37 @@
HRESULT result = S_OK;
-
CKYCardContext *cardCtxt = CKYCardContext_Create(SCARD_SCOPE_USER);
- assert(cardCtxt);
+ assert(cardCtxt);
if (!cardCtxt) {
- PR_LOG( coolKeyLog, PR_LOG_ERROR, ("Attempting to get key issuer info. Can't create Card Context !.\n"));
- result = E_FAIL;
- goto done;
+ PR_LOG( coolKeyLog, PR_LOG_ERROR, ("%s Attempting to get key issuer info. Can't create Card Context !.\n",GetTStamp(tBuff,56)));
+ result = E_FAIL;
+ goto done;
}
conn = CKYCardConnection_Create(cardCtxt);
assert(conn);
if (!conn) {
- PR_LOG( coolKeyLog, PR_LOG_ERROR, ("Attempting to get key issuer info. Can't create Card Connection!\n"));
- result = E_FAIL;
- goto done;
+ PR_LOG( coolKeyLog, PR_LOG_ERROR, ("%s Attempting to get key issuer info. Can't create Card Connection!\n",GetTStamp(tBuff,56)));
+ result = E_FAIL;
+ goto done;
}
readerName = GetReaderNameForKeyID(aKey);
assert(readerName);
if (!readerName) {
- PR_LOG( coolKeyLog, PR_LOG_ERROR, ("Attempting to get key issuer info. Can't get reader name!\n"));
- result = E_FAIL;
- goto done;
+ PR_LOG( coolKeyLog, PR_LOG_ERROR, ("%s Attempting to get key issuer info. Can't get reader name!\n",GetTStamp(tBuff,56)));
+ result = E_FAIL;
+ goto done;
}
status = CKYCardConnection_Connect(conn, readerName);
if (status != CKYSUCCESS) {
- PR_LOG( coolKeyLog, PR_LOG_ERROR, ("Attempting to get key issuer info. Can't connect to Card!\n"));
+ PR_LOG( coolKeyLog, PR_LOG_ERROR, ("%s Attempting to get key issuer info. Can't connect to Card!\n",GetTStamp(tBuff,56)));
- result = E_FAIL;
- goto done;
+ result = E_FAIL;
+ goto done;
}
#ifndef DARWIN
@@ -936,17 +928,15 @@
apduRC = 0;
status = CKYApplet_SelectCoolKeyManager(conn, &apduRC);
if (status != CKYSUCCESS) {
-
- PR_LOG( coolKeyLog, PR_LOG_ERROR, ("Attempting to get key issuer info. Can't select CoolKey manager!\n"));
- goto done;
+ PR_LOG( coolKeyLog, PR_LOG_ERROR, ("%s Attempting to get key issuer info. Can't select CoolKey manager!\n",GetTStamp(tBuff,56)));
+ goto done;
}
status = CKYApplet_GetIssuerInfo(conn, &ISSUER_INFO,
&apduRC);
-
if(status != CKYSUCCESS)
{
- PR_LOG( coolKeyLog, PR_LOG_ERROR, ("Attempting to get key issuer info. Error actually getting IssuerInfo!\n"));
+ PR_LOG( coolKeyLog, PR_LOG_ERROR, ("%s Attempting to get key issuer info. Error actually getting IssuerInfo!\n",GetTStamp(tBuff,56)));
result = E_FAIL;
goto done;
}
@@ -955,14 +945,14 @@
if(infoSize == 0)
{
- PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyGetIssuerInfo:: IssuerInfo buffer size is zero!\n"));
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("%s CoolKeyGetIssuerInfo:: IssuerInfo buffer size is zero!\n",GetTStamp(tBuff,56)));
result = E_FAIL;
goto done;
}
if(infoSize >= (CKYSize ) aBufLen)
{
- PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyGetIssuerInfo:: Insufficient space to put Issuer Info!\n"));
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("%s CoolKeyGetIssuerInfo:: Insufficient space to put Issuer Info!\n",GetTStamp(tBuff,56)));
result = E_FAIL;
goto done;
@@ -970,7 +960,7 @@
infoData = CKYBuffer_Data(&ISSUER_INFO);
- PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyGetIssuerInfo:: IssuerInfo actual data %s!\n",(char *) infoData));
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("%s CoolKeyGetIssuerInfo:: IssuerInfo actual data %s!\n",GetTStamp(tBuff,56),(char *) infoData));
if(infoData)
{
strcpy((char *) aBuf, (char *) infoData);
@@ -980,13 +970,13 @@
if (conn) {
#ifndef DARWIN
- CKYCardConnection_EndTransaction(conn);
+ CKYCardConnection_EndTransaction(conn);
#endif
- CKYCardConnection_Disconnect(conn);
- CKYCardConnection_Destroy(conn);
+ CKYCardConnection_Disconnect(conn);
+ CKYCardConnection_Destroy(conn);
}
if (cardCtxt) {
- CKYCardContext_Destroy(cardCtxt);
+ CKYCardContext_Destroy(cardCtxt);
}
CKYBuffer_FreeData(&ISSUER_INFO);
@@ -996,96 +986,87 @@
bool CoolKeyIsReallyCoolKey(const CoolKey *aKey)
{
- bool res = false;
+ bool res = false;
- if(!aKey)
- return res;
+ if(!aKey)
+ return res;
+ CoolKeyInfo *info =
+ GetCoolKeyInfoByKeyID(aKey);
- CoolKeyInfo *info =
- GetCoolKeyInfoByKeyID(aKey);
+ if(!info)
+ return res;
- if(!info)
- return res;
+ if( IS_REALLY_A_COOLKEY(info->mInfoFlags))
+ res = true;
- if( IS_REALLY_A_COOLKEY(info->mInfoFlags))
- res = true;
-
- return res;
+ return res;
}
int CoolKeyGetAppletVer(const CoolKey *aKey, const bool isMajor)
{
+ int result = -1;
+ if(!aKey)
+ return result;
- int result = -1;
- if(!aKey)
- return result;
-
- CoolKeyInfo *info =
- GetCoolKeyInfoByKeyID(aKey);
-
- if(!info)
- return result;
+ CoolKeyInfo *info =
+ GetCoolKeyInfoByKeyID(aKey);
- PK11SlotInfo *slot = GetSlotForKeyID(aKey);
+ if(!info)
+ return result;
- if(!slot)
- return result;
+ PK11SlotInfo *slot = GetSlotForKeyID(aKey);
- CK_TOKEN_INFO tokenInfo;
- PK11_GetTokenInfo(slot, &tokenInfo);
+ if(!slot)
+ return result;
- if(isMajor)
- result = (int) tokenInfo.firmwareVersion.major;
- else
- result = (int) tokenInfo.firmwareVersion.minor;
+ CK_TOKEN_INFO tokenInfo;
+ PK11_GetTokenInfo(slot, &tokenInfo);
- return result;
+ if(isMajor)
+ result = (int) tokenInfo.firmwareVersion.major;
+ else
+ result = (int) tokenInfo.firmwareVersion.minor;
+ return result;
}
-
bool
CoolKeyHasReader(const CoolKey *aKey)
{
+ bool res = false;
- bool res = false;
-
+ if(!aKey)
+ return res;
- if(!aKey)
- return res;
-
-
- const char *readerName = GetReaderNameForKeyID(aKey);
-
-
- if(readerName)
- res = true;
-
- return res;
+ const char *readerName = GetReaderNameForKeyID(aKey);
+ if(readerName)
+ res = true;
+ return res;
}
bool
CoolKeyRequiresAuthentication(const CoolKey *aKey)
{
- PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyRequiresAuthentication:\n"));
- if (!aKey || !aKey->mKeyID)
- return false;
-
- return NSSManager::RequiresAuthentication(aKey);
+ char tBuff[56];
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("%s CoolKeyRequiresAuthentication:\n",GetTStamp(tBuff,56)));
+ if (!aKey || !aKey->mKeyID)
+ return false;
+ return NSSManager::RequiresAuthentication(aKey);
}
bool
CoolKeyIsAuthenticated(const CoolKey *aKey)
{
- PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("CoolKeyIsAuthenticated:\n"));
- if (!aKey || !aKey->mKeyID)
- return false;
+ char tBuff[56];
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("%s CoolKeyIsAuthenticated:\n",GetTStamp(tBuff,56)));
+ if (!aKey || !aKey->mKeyID)
+ return false;
- return NSSManager::IsAuthenticated(aKey);
+ return NSSManager::IsAuthenticated(aKey);
}
#define NIBBLE_TO_HEX(nibble, caps) ((nibble) < 10) ? ((nibble) + '0') : ((nibble) - 10 + ((caps) ? 'A' : 'a'));
@@ -1099,42 +1080,42 @@
{
// Check if there's enough room to accomodate our output.
- if (aOutputLength < ((aInputLength*2) + 1))
- return E_FAIL;
+ if (aOutputLength < ((aInputLength*2) + 1))
+ return E_FAIL;
- unsigned long outIdx = 0;
- unsigned long i;
+ unsigned long outIdx = 0;
+ unsigned long i;
- for (i = 0; i < aInputLength; i++) {
- unsigned char hbits = aInput[i] >> 4;
- unsigned char lbits = aInput[i] & 0x0F;
+ for (i = 0; i < aInputLength; i++) {
+ unsigned char hbits = aInput[i] >> 4;
+ unsigned char lbits = aInput[i] & 0x0F;
- aOutput[outIdx++] = NIBBLE_TO_HEX(hbits, aCaps);
- aOutput[outIdx++] = NIBBLE_TO_HEX(lbits, aCaps);
- }
+ aOutput[outIdx++] = NIBBLE_TO_HEX(hbits, aCaps);
+ aOutput[outIdx++] = NIBBLE_TO_HEX(lbits, aCaps);
+ }
- aOutput[outIdx] = '\0';
+ aOutput[outIdx] = '\0';
- return S_OK;
+ return S_OK;
}
const char *
CoolKeyGetTokenName(const CoolKey *aKey)
{
- PK11SlotInfo *slot = GetSlotForKeyID(aKey);
- const char *tokenName = PK11_GetTokenName(slot);
- PK11_FreeSlot(slot); // depending
- return tokenName;
+ PK11SlotInfo *slot = GetSlotForKeyID(aKey);
+ const char *tokenName = PK11_GetTokenName(slot);
+ PK11_FreeSlot(slot); // depending
+ return tokenName;
}
const char *
CoolKeyGetKeyID(const char *tokenName, int *aKeyType)
{
- CoolKeyInfo *keyInfo = GetCoolKeyInfoByTokenName(tokenName);
- const char *aCUID = keyInfo->mCUID;
+ CoolKeyInfo *keyInfo = GetCoolKeyInfoByTokenName(tokenName);
+ const char *aCUID = keyInfo->mCUID;
- *aKeyType = eCKType_CoolKey;
- return aCUID;
+ *aKeyType = eCKType_CoolKey;
+ return aCUID;
}
const char *CoolKeyGetConfig(const char *aValue)
@@ -1161,3 +1142,20 @@
return res;
}
+
+//Utility function to get Time Stamp
+char *GetTStamp(char *aTime,int aSize)
+{
+ if(!aTime)
+ return NULL;
+ int maxSize = 55;
+ if(aSize < maxSize)
+ return NULL;
+
+ char *tFormat = "[%c]";
+ time_t tm = time(NULL);
+ struct tm *ptr = localtime(&tm);
+ strftime(aTime ,maxSize ,tFormat,ptr);
+ return aTime;
+}
+
17 years, 1 month
[Fedora-directory-commits] esc/src/lib/NssHttpClient response.cpp, 1.2, 1.3
by Doctor Conrad
Author: jmagne
Update of /cvs/dirsec/esc/src/lib/NssHttpClient
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv1962
Modified Files:
response.cpp
Log Message:
Add time stamps to log messages.
Index: response.cpp
===================================================================
RCS file: /cvs/dirsec/esc/src/lib/NssHttpClient/response.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- response.cpp 27 Sep 2006 17:49:21 -0000 1.2
+++ response.cpp 24 Feb 2007 02:12:56 -0000 1.3
@@ -25,6 +25,7 @@
#include <ctype.h>
#include <string.h>
#include <math.h>
+#include <time.h>
#include "nspr.h"
@@ -39,7 +40,6 @@
PRLogModuleInfo *httpRespLog = PR_NewLogModule("coolKeyHttpRes");
-
/**
* Constructor. This class is used by the HttpResponse class for reading and
* processing data from the socket
@@ -92,7 +92,8 @@
int num =1;
int i =0;
-
+
+ char tBuff[56];
PRBool endChunk= PR_FALSE;
// actual reading from the socket happens here
@@ -106,12 +107,12 @@
_timeout );
PR_LOG( httpRespLog, PR_LOG_DEBUG,
- ("RecvBuf::_getBytes:: read %d bytes\n",num));
+ ("%s RecvBuf::_getBytes:: read %d bytes\n",GetTStamp(tBuff,56),num));
if(num < 0)
{
PR_LOG( httpRespLog, PR_LOG_DEBUG,
- ("RecvBuf::_getBytes:: Conn Closed "));
+ ("%s RecvBuf::_getBytes:: Conn Closed ",GetTStamp(tBuff,56)));
return PR_FALSE;
}
@@ -247,6 +248,7 @@
* @returns - the next char from the data
*/
char RecvBuf::getChar() {
+ char tBuff[56];
if (!_chunkedMode)
return _getChar();
@@ -270,7 +272,7 @@
if (ch != '\r' || ch2 != '\n')
{
PR_LOG(httpRespLog, PR_LOG_DEBUG,
- ("did not find chunk trailer at end of chunk . \n"));
+ ("%s did not find chunk trailer at end of chunk . \n",GetTStamp(tBuff,56)));
}
}
@@ -305,7 +307,7 @@
if (ch1 != '\r' || ch2 != '\n')
{
PR_LOG(httpRespLog, PR_LOG_DEBUG,
- ("did not find chunk trailer at the end of chunk . ch1 %c ch2 %c \n",ch1,ch2));
+ ("%s did not find chunk trailer at the end of chunk . ch1 %c ch2 %c \n",GetTStamp(tBuff,56),ch1,ch2));
};
_currentChunkSize = _currentChunkBytesRead = 0;
@@ -667,7 +669,7 @@
PRBool PSHttpResponse::_handleChunkedConversation(RecvBuf &buf)
{
char ch = 0;
-
+ char tBuff[56];
char chunk[4096];
int i = 0;
@@ -681,15 +683,15 @@
}
PR_LOG(httpRespLog, PR_LOG_DEBUG,
- ("PSHttpResponse::_handleChunkedConversation \n"));
+ ("%s PSHttpResponse::_handleChunkedConversation \n",GetTStamp(tBuff,56)));
while(1)
{
if(_client && _client->isConnectionClosed())
{
PR_LOG(httpRespLog, PR_LOG_DEBUG,
- ("PSHttpResponse::_handleChunkedConversation client"
- " claims conn closed!\n"));
+ ("%s PSHttpResponse::_handleChunkedConversation client"
+ " claims conn closed!\n",GetTStamp(tBuff,56)));
chunk[0] = 0;
i = 0;
@@ -704,14 +706,14 @@
if(ch == -1)
{
PR_LOG(httpRespLog, PR_LOG_DEBUG,
- ("PSHttpResponse::_handleChunkedConversation getChar"
- " returned -1 ! \n"));
+ ("%s PSHttpResponse::_handleChunkedConversation getChar"
+ " returned -1 ! \n",GetTStamp(tBuff,56)));
chunk[i] = 0;
if(i >= 0)
{
PR_LOG(httpRespLog, PR_LOG_DEBUG,
- ("PSHttpResponse::_handleChunkedConversation"
- " chunk complete EOF condition. chunk: %s\n",(char *) chunk));
+ ("%s PSHttpResponse::_handleChunkedConversation"
+ " chunk complete EOF condition. chunk: %s\n",GetTStamp(tBuff,56),(char *) chunk));
(*cb)((unsigned char *) chunk,i,uw,HTTP_CHUNKED_EOF);
chunk[0] = 0;
@@ -728,8 +730,8 @@
if(i > 0)
{
PR_LOG(httpRespLog, PR_LOG_DEBUG,
- ("PSHttpResponse::_handleChunkedConversation"
- " chunk complete normal condition. chunk: %s\n",(char *) chunk));
+ ("%s PSHttpResponse::_handleChunkedConversation"
+ " chunk complete normal condition. chunk: %s\n",GetTStamp(tBuff,56),(char *) chunk));
(*cb)((unsigned char *) chunk,i,uw,HTTP_CHUNK_COMPLETE);
}
17 years, 1 month
[Fedora-directory-commits] esc/src/lib/NssHttpClient request.cpp, 1.2, 1.3
by Doctor Conrad
Author: jmagne
Update of /cvs/dirsec/esc/src/lib/NssHttpClient
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv1926
Modified Files:
request.cpp
Log Message:
Add time stamps to log messages.
Index: request.cpp
===================================================================
RCS file: /cvs/dirsec/esc/src/lib/NssHttpClient/request.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- request.cpp 27 Sep 2006 17:49:21 -0000 1.2
+++ request.cpp 24 Feb 2007 02:12:15 -0000 1.3
@@ -24,7 +24,7 @@
#include "request.h"
#include "engine.h"
#include <prlog.h>
-
+#include <time.h>
PRLogModuleInfo *httpLog = PR_NewLogModule("coolKeyHttpReq");
/**
@@ -249,6 +249,7 @@
PRBool PSHttpRequest::send( PRFileDesc *sock ) {
const char *hostname;
+ char tBuff[56];
PRBool rv = PR_FALSE;
if (!sock) {
@@ -319,7 +320,7 @@
data = PR_sprintf_append(data,"\r\n");
PR_LOG( httpLog, PR_LOG_DEBUG,
- ("PSHttpRequest::PSHttpRequest: data %s\n",data));
+ ("%s PSHttpRequest::PSHttpRequest: data %s\n",GetTStamp(tBuff,56),data));
int len = PL_strlen(data);
//send the data ..
17 years, 1 month
[Fedora-directory-commits] esc/src/lib/NssHttpClient http.h, 1.2, 1.3
by Doctor Conrad
Author: jmagne
Update of /cvs/dirsec/esc/src/lib/NssHttpClient
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv1892
Modified Files:
http.h
Log Message:
Add prototype for utility function needed to get time stamps for log messages.
Index: http.h
===================================================================
RCS file: /cvs/dirsec/esc/src/lib/NssHttpClient/http.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- http.h 27 Sep 2006 17:49:21 -0000 1.2
+++ http.h 24 Feb 2007 02:11:31 -0000 1.3
@@ -40,6 +40,13 @@
#define __EXPORT
#endif
+extern "C" {
+
+char *GetTStamp(char *aTime,int aSize);
+
+}
+
+
typedef bool ( *PSChunkedResponseCallback)(unsigned char *entity_data,unsigned entity_data_len,void *uw, int status);
class PSHttpResponse;
17 years, 1 month
[Fedora-directory-commits] esc/src/lib/NssHttpClient engine.cpp, 1.3, 1.4
by Doctor Conrad
Author: jmagne
Update of /cvs/dirsec/esc/src/lib/NssHttpClient
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv1861
Modified Files:
engine.cpp
Log Message:
Fix code responsible for closing the connection socket either by client request or when a connection is dropped.
Index: engine.cpp
===================================================================
RCS file: /cvs/dirsec/esc/src/lib/NssHttpClient/engine.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- engine.cpp 9 Feb 2007 21:56:36 -0000 1.3
+++ engine.cpp 24 Feb 2007 02:10:45 -0000 1.4
@@ -420,6 +420,12 @@
void Engine::CloseConnection()
{
connectionClosed = true;
+
+ if(_sock)
+ {
+ PR_Close(_sock);
+ _sock = NULL;
+ }
}
/**
* Returns a file descriptor for I/O if the HTTP connection is successful
@@ -567,13 +573,12 @@
char *nickName = request.getCertNickName();
char *serverName = (char *)server.getAddr();
- sock = _doConnect( &addr, request.isSSL(), 0, 0,nickName, 0, serverName );
+ _sock = _doConnect( &addr, request.isSSL(), 0, 0,nickName, 0, serverName );
- if ( sock != NULL) {
- _sock = sock;
- PRBool status = request.send( sock );
+ if ( _sock != NULL) {
+ PRBool status = request.send( _sock );
if ( status ) {
- resp = new PSHttpResponse( sock, &request, timeout, expectChunked ,this);
+ resp = new PSHttpResponse( _sock, &request, timeout, expectChunked ,this);
response_code = resp->processResponse(processStreamed);
if(!response_code)
@@ -583,18 +588,17 @@
delete resp;
resp = NULL;
}
- if( sock != NULL ) {
- PR_Close( sock );
- sock = NULL;
+ if( _sock != NULL ) {
+ PR_Close( _sock );
+ _sock = NULL;
}
return NULL;
}
}
- if( sock != NULL ) {
- PR_Close( sock );
- sock = NULL;
+ if( _sock != NULL ) {
+ PR_Close( _sock );
_sock = NULL;
}
}
17 years, 1 month
[Fedora-directory-commits] esc/src/app/xul/esc/chrome/content/esc ESC.js, 1.6, 1.7
by Doctor Conrad
Author: jmagne
Update of /cvs/dirsec/esc/src/app/xul/esc/chrome/content/esc
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv1741
Modified Files:
ESC.js
Log Message:
Issue some log messages to be written to the NSPR log file.
Index: ESC.js
===================================================================
RCS file: /cvs/dirsec/esc/src/app/xul/esc/chrome/content/esc/ESC.js,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ESC.js 9 Feb 2007 21:48:07 -0000 1.6
+++ ESC.js 24 Feb 2007 02:07:49 -0000 1.7
@@ -70,6 +70,20 @@
const HIDDEN_WINDOW = "hiddenWindow.xul";
const SECURITY_WINDOW = "security.xul";
+
+//Log level constants
+
+const PR_LOG_NONE = 0;
+const PR_LOG_ALWAYS = 1;
+const PR_LOG_ERROR = 2;
+const PR_LOG_WARNING = 3;
+const PR_LOG_DEBUG = 4;
+
+const PR_LOG_NOTICE = 4;
+const PR_LOG_WARN = 3;
+const PR_LOG_MIN = 4;
+const PR_LOG_MAX = 4;
+
function getUIForKey(aKeyID)
{
return keyUITable[aKeyID];
@@ -206,6 +220,7 @@
function DoPhoneHome(keyType,keyID)
{
+ CoolKeyLogMsg(PR_LOG_ALWAYS,"Attempting to phone home for Key " + keyID);
var callback = function (aResult) {
recordMessage("In DoPhoneHome callback");
@@ -217,6 +232,7 @@
if(!issuer)
issuer = getBundleString("unknownIssuer");
TraySendNotificationMessage(getBundleString("keyInserted"),"\"" + issuer +"\"" + " " + getBundleString("keyInsertedComputer"),3,4000,GetESCNotifyIconPath(keyType,keyID));
+ LogKeyInfo(keyType,keyID,"Key Inserted ...");
UpdateRowWithPhoneHomeData(keyType,keyID);
recordMessage("cached issuer " + issuer);
var browserURL = GetCachedEnrolledTokenBrowserURL(keyID);
@@ -233,6 +249,7 @@
{
issuer = getBundleString("unknownIssuer");
TraySendNotificationMessage(getBundleString("keyInserted"),"\"" + issuer +"\"" + " " + getBundleString("keyInsertedComputer"),3,4000,GetESCNotifyIconPath(keyType,keyID));
+ LogKeyInfo(keyType,keyID,"Key Inserted ...");
}
}
@@ -249,6 +266,7 @@
recordMessage("Phone home info cached...");
issuer = GetCachedIssuer(keyID);
TraySendNotificationMessage(getBundleString("keyInserted"),"\"" + issuer +"\"" + " " + getBundleString("keyInsertedComputer"),3,4000,GetESCNotifyIconPath(keyType,keyID));
+ LogKeyInfo(keyType,keyID,"Key Inserted ...");
var launchBrowserURL = GetCachedEnrolledTokenBrowserURL(keyID);
@@ -487,7 +505,7 @@
} catch(e) {
- MyAlert(getBundleString("errorSetDataValue") + e);
+ //MyAlert(getBundleString("errorSetDataValue") + e);
}
}
@@ -852,6 +870,18 @@
}
}
+function CoolKeyLogMsg(aLogLevel,aMessage)
+{
+ if(!aMessage)
+ return;
+
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey.CoolKeyLogMsg(aLogLevel,aMessage);
+ } catch(e) {
+ }
+}
+
function ChallengeCoolKey(keyType, keyID, data)
{
try {
@@ -973,10 +1003,14 @@
{
var image_src = "";
- if(observeBusy && (keyStatus == "BUSY" || keyStatus == "UNAVAILABLE"))
+ if(observeBusy && (keyStatus == "BUSY" ))
{
return "throbber-anim5.gif";
}
+ if(keyStatus == "UNAVAILABLE")
+ {
+ return "";
+ }
if(keyStatus == "ENROLLED")
{
image_src = "enrolled-key";
@@ -1982,6 +2016,8 @@
keyStatus = GetStatusForKeyID(keyType, keyID);
+ recordMessage("No Key: " + noKey + " status " + keyStatus);
+
var passwordArea = document.getElementById("password-area-id");
if(passwordArea)
@@ -2029,6 +2065,7 @@
var image_src = SelectImageForKeyStatus(keyStatus,1,1);
+ recordMessage("image_src " + image_src);
if(!image_src)
HideItem(detailsImage);
else
@@ -2057,7 +2094,8 @@
DisableItem(resetpinbtn);
DisableItem(formatbtn);
detailsKeyLabel.setAttribute("value",getBundleString("noKeysPresent"));
- return;
+ HideItem(detailsImage);
+ return;
}
if(keyStatus == "ENROLLED")
@@ -2613,12 +2651,19 @@
var row = GetRowForKey(keyType, keyID);
+
if(gHiddenPage)
{
+ if(curChildWindow)
+ {
+ curChildWindow.close();
+ curChildWindow = null;
+ }
var issuer = GetCachedIssuer(keyID);
if(!issuer)
issuer = getBundleString("unknownIssuer");
TraySendNotificationMessage(getBundleString("keyRemoved"),"\"" + issuer + "\"" + " " + getBundleString("keyRemovedComputer"),1,4000,GetESCNotifyIconPath(keyType,keyID));
+ LogKeyInfo(keyType,keyID, "Key Removed ...");
}
@@ -3531,19 +3576,30 @@
phoneHomeUrl = GetCachedPhoneHomeURL(aKeyID);
if(!phoneHomeUrl)
+ {
+ CoolKeyLogMsg(PR_LOG_ALWAYS,"IsPhoneHomeCached keyID: " + aKeyID + " IsCached: false " );
return false;
+ }
phoneHomeIssuer = GetCachedIssuer(aKeyID);
if(!phoneHomeIssuer)
+ {
+ CoolKeyLogMsg(PR_LOG_ALWAYS,"IsPhoneHomeCached keyID: " + aKeyID + " IsCached: false " );
return false;
+ }
tpsURL = GetCachedTPSURL(aKeyID);
if(!tpsURL)
+ {
+ CoolKeyLogMsg(PR_LOG_ALWAYS,"IsPhoneHomeCached keyID: " + aKeyID + " IsCached: false " );
return false;
+ }
+
tpsUI = GetCachedTPSUI(aKeyID);
+ CoolKeyLogMsg(PR_LOG_ALWAYS,"IsPhoneHomeCached keyID: " + aKeyID + " IsCached: true " );
return true;
}
@@ -3645,6 +3701,36 @@
return url;
}
+//Log information about the key
+
+function LogKeyInfo(aKeyType,aKeyID,aMessage)
+{
+ var issuer = GetCachedIssuer(aKeyID);
+ var status = GetStatusForKeyID(aKeyType, aKeyID);
+ var atr = DoCoolKeyGetATR(aKeyType,aKeyID);
+ var tpsURI = GetCachedTPSURL(aKeyID);
+ var tpsUI = GetCachedTPSUI(aKeyID);
+ var phoneHomeURI = GetCachedPhoneHomeURL(aKeyID);
+
+ if(aMessage)
+ CoolKeyLogMsg(PR_LOG_ALWAYS,aMessage);
+
+ CoolKeyLogMsg(PR_LOG_ALWAYS,"CoolKey ID: " + aKeyID);
+
+ if(issuer)
+ CoolKeyLogMsg(PR_LOG_ALWAYS,"CoolKey Issuer: " + issuer);
+
+ if(status)
+ CoolKeyLogMsg(PR_LOG_ALWAYS,"CoolKey Status: " + status);
+
+ if(atr)
+ CoolKeyLogMsg(PR_LOG_ALWAYS,"CoolKey Atr: " + atr);
+
+ if(phoneHomeURI)
+ CoolKeyLogMsg(PR_LOG_ALWAYS,"CoolKey Phone Home URI: " + phoneHomeURI);
+}
+
+
//Update display when phone home data comes in
function UpdateRowWithPhoneHomeData(keyType,keyID)
{
@@ -3664,6 +3750,7 @@
function phoneHome(theUrl,aKeyID,resultCB)
{
+ CoolKeyLogMsg(PR_LOG_ALWAYS,"Actually phoning Home for Key: " + aKeyID + " URI: " + theUrl);
var url = null ;
if(!theUrl || !aKeyID)
@@ -3756,6 +3843,8 @@
{
recordMessage("Writing out config : " +cValue + " value: " + value);
DoCoolKeySetConfigValue(cValue,value);
+ CoolKeyLogMsg(PR_LOG_ALWAYS,"Phone Home config value for Key: " + aKeyID + " ConfigKey: " + cValue + " ConfigValue: " + value);
+
}
}
@@ -3779,6 +3868,7 @@
var issuer_config_value = ConfigValueWithKeyID(aKeyID,KEY_ISSUER_URL);
var result = DoCoolKeySetConfigValue(issuer_config_value,url);
+ CoolKeyLogMsg(PR_LOG_ALWAYS,"Phone Home config value for Key: " + aKeyID + " ConfigKey: " + issuer_config_value + " ConfigValue: " + url);
resultCB(true);
}
return true;
17 years, 1 month
[Fedora-directory-commits] esc/src/app/xpcom/tray rhTray.h,1.3,1.4
by Doctor Conrad
Author: jmagne
Update of /cvs/dirsec/esc/src/app/xpcom/tray
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv1712
Modified Files:
rhTray.h
Log Message:
Add utility func to add a time stamp to a log message.
Index: rhTray.h
===================================================================
RCS file: /cvs/dirsec/esc/src/app/xpcom/tray/rhTray.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- rhTray.h 25 Oct 2006 03:59:03 -0000 1.3
+++ rhTray.h 24 Feb 2007 02:06:23 -0000 1.4
@@ -25,7 +25,24 @@
#include "nsCOMPtr.h"
#include "widget/nsIBaseWindow.h"
#include "widget/nsIWidget.h"
+#include <time.h>
+extern "C" {
+//Utility function to get Time Stamp
+ char *GetTStamp(char *aTime,int aSize)
+ {
+ if(!aTime)
+ return NULL;
+ int maxSize = 55;
+ if(aSize < maxSize)
+ return NULL;
+ char *tFormat = "[%c]";
+ time_t tm = time(NULL);
+ struct tm *ptr = localtime(&tm);
+ strftime(aTime ,maxSize ,tFormat,ptr);
+ return aTime;
+ }
+}
// Event Defines
#define MENU_EVT 1
17 years, 1 month
[Fedora-directory-commits] esc/src/app/xpcom/tray rhTray.cpp, 1.5, 1.6
by Doctor Conrad
Author: jmagne
Update of /cvs/dirsec/esc/src/app/xpcom/tray
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv1677
Modified Files:
rhTray.cpp
Log Message:
Add time stamp to log file.
Index: rhTray.cpp
===================================================================
RCS file: /cvs/dirsec/esc/src/app/xpcom/tray/rhTray.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- rhTray.cpp 30 Nov 2006 18:29:09 -0000 1.5
+++ rhTray.cpp 24 Feb 2007 02:05:13 -0000 1.6
@@ -20,6 +20,7 @@
#include "rhTray.h"
#include "nsIGenericFactory.h"
#include <prlog.h>
+#include <time.h>
NS_IMPL_ISUPPORTS1(rhTray, rhITray)
@@ -29,10 +30,8 @@
int rhTray::mInitialized = 0;
ATOM rhTray::mWndClass = 0;
-
std::list< nsCOMPtr<rhITrayWindNotify> > rhTray::gTrayWindNotifyListeners;
-
map< nsIBaseWindow *, rhTrayWindowListener *> rhTray::mWindowMap;
map<unsigned int,string> rhTray::mMenuItemStringMap;
@@ -56,8 +55,8 @@
rhTray::~rhTray()
{
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::~rhTray\n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::~rhTray\n",GetTStamp(tBuff,56)));
Cleanup();
@@ -66,7 +65,8 @@
NS_IMETHODIMP rhTray::Setwindnotifycallback(rhITrayWindNotify *jsNotify)
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Setwindnotifycallback\n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Setwindnotifycallback\n",GetTStamp(tBuff,56)));
if(jsNotify)
AddTrayWindNotifyListener(jsNotify);
@@ -78,8 +78,8 @@
NS_IMETHODIMP rhTray::Unsetwindnotifycallback(rhITrayWindNotify *jsNotify)
{
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Unsetwindnotifycallback\n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Unsetwindnotifycallback\n",GetTStamp(tBuff,56)));
if(jsNotify)
RemoveTrayWindNotifyListener(jsNotify);
@@ -90,11 +90,10 @@
/* void add (); */
NS_IMETHODIMP rhTray::Add(nsIBaseWindow *aWindow)
{
-
-
+ char tBuff[56];
NS_ENSURE_ARG(aWindow);
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Add %p \n",aWindow));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Add %p \n",GetTStamp(tBuff,56),aWindow));
HRESULT res = Initialize();
if(res != S_OK)
{
@@ -112,7 +111,8 @@
/* void remove (); */
NS_IMETHODIMP rhTray::Remove(nsIBaseWindow *aWindow)
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Remove window %p \n",aWindow));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Remove window %p \n",GetTStamp(tBuff,56),aWindow));
return NS_OK;
}
@@ -160,14 +160,11 @@
return NS_OK;
-
-
}
/* void hideall (); */
NS_IMETHODIMP rhTray::Hideall()
{
-
HideAllListeners();
return NS_OK;
}
@@ -195,15 +192,16 @@
/* void settooltipmsg (in string aMessage); */
NS_IMETHODIMP rhTray::Settooltipmsg(const char *aMessage)
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Settooltipmsg %s \n",aMessage));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Settooltipmsg %s \n",GetTStamp(tBuff,56),aMessage));
- if(!aMessage)
- return E_FAIL;
+ if(!aMessage)
+ return E_FAIL;
- if(strlen(aMessage) >= 64)
+ if(strlen(aMessage) >= 64)
return E_FAIL;
- strcpy(rhTray::mIconData.szTip, aMessage);
+ strcpy(rhTray::mIconData.szTip, aMessage);
return NS_OK;
}
@@ -211,24 +209,18 @@
/* 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;
}
@@ -254,14 +246,13 @@
HRESULT rhTray::Initialize()
{
-
+ char tBuff[56];
if(mInitialized)
{
return S_OK;
}
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Initialize \n"));
-
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Initialize \n",GetTStamp(tBuff,56)));
CreateMutex(NULL, FALSE, "ESCMutex");
@@ -299,7 +290,7 @@
rhTray::mIconData.uTimeout = 1000;
- PR_LOG(trayLog,PR_LOG_DEBUG,("rhTray::Initialize tray icon handle %d \n",icon));
+ PR_LOG(trayLog,PR_LOG_DEBUG,("%s rhTray::Initialize tray icon handle %d \n",GetTStamp(tBuff,56),icon));
::Shell_NotifyIcon( NIM_ADD, &rhTray::mIconData);
@@ -310,17 +301,18 @@
HRESULT rhTray::RemoveIcon()
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::RemoveIcon. \n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::RemoveIcon. \n",GetTStamp(tBuff,56)));
::Shell_NotifyIcon(NIM_DELETE,&rhTray::mIconData);
-
return S_OK;
}
HRESULT rhTray::Cleanup()
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Cleanup.\n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Cleanup.\n",GetTStamp(tBuff,56)));
RemoveAllListeners();
DestroyEventWindow();
@@ -334,7 +326,8 @@
void rhTray::ShowAllListeners()
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ShowAllListeners.\n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::ShowAllListeners.\n",GetTStamp(tBuff,56)));
map< nsIBaseWindow *, rhTrayWindowListener *>::iterator i;
rhTrayWindowListener *cur = NULL;
@@ -355,10 +348,10 @@
}
-
void rhTray::HideAllListeners()
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::HideAllListeners.\n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::HideAllListeners.\n",GetTStamp(tBuff,56)));
map< nsIBaseWindow *, rhTrayWindowListener *>::iterator i;
@@ -371,7 +364,6 @@
if(cur)
{
cur->HideWindow();
-
}
}
@@ -381,7 +373,8 @@
HRESULT rhTray::DestroyEventWindow()
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::DestroyEventWindow \n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::DestroyEventWindow \n",GetTStamp(tBuff,56)));
::DestroyWindow(rhTray::mWnd);
rhTray::mWnd = 0;
@@ -392,7 +385,8 @@
HRESULT rhTray::CreateEventWindow()
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::CreateEventWindow \n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::CreateEventWindow \n",GetTStamp(tBuff,56)));
::SetLastError(0);
HINSTANCE hInst = ::GetModuleHandle(NULL);
@@ -454,8 +448,9 @@
)
{
+ char tBuff[56];
- switch(aMsg) {
+ switch(aMsg) {
case WM_USER:
switch(lParam)
@@ -463,14 +458,14 @@
case WM_LBUTTONDBLCLK:
case WM_LBUTTONDOWN:
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::WindowProc: WM_LBUTTONDBLCLK \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::WindowProc: WM_LBUTTONDBLCLK \n",GetTStamp(tBuff,56)));
NotifyTrayWindListeners(MENU_EVT,MENU_SHOW);
ShowAllListeners();
break;
case WM_RBUTTONDOWN:
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::WindowProc: WM_RBUTTONDOWN \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::WindowProc: WM_RBUTTONDOWN \n",GetTStamp(tBuff,56)));
HRESULT res = rhTray::ShowPopupMenu (IDR_MENU1);
@@ -497,7 +492,7 @@
break;
case WM_CREATE:
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::WindowProc: WM_CREATE \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::WindowProc: WM_CREATE \n",GetTStamp(tBuff,56)));
break;
default:
break;
@@ -514,10 +509,11 @@
HRESULT rhTray::AddListener(nsIBaseWindow *aWindow)
{
+ char tBuff[56];
nsresult rv;
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddListener %p \n",aWindow));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::AddListener %p \n",GetTStamp(tBuff,56),aWindow));
NS_ENSURE_ARG(aWindow);
nativeWindow aNativeWindow;
@@ -543,7 +539,7 @@
if(already)
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddWindowListener Window already registered %p \n",aWindow));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::AddWindowListener Window already registered %p \n",GetTStamp(tBuff,56),aWindow));
return S_OK;
}
@@ -570,100 +566,95 @@
HRESULT rhTray::ShowPopupMenu (WORD PopupMenuResource)
{
- HMENU hMenu, hPopup = 0;
+ char tBuff[56];
+ HMENU hMenu, hPopup = 0;
- const int numMenuItems = 2;
+ const int numMenuItems = 2;
- hMenu = ::LoadMenu (::GetModuleHandle("rhTray.dll"),
+ hMenu = ::LoadMenu (::GetModuleHandle("rhTray.dll"),
MAKEINTRESOURCE (PopupMenuResource));
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ShowPopupMenu hMenu %d error %d\n",hMenu,GetLastError()));
-
- if (hMenu != 0) {
- POINT pt;
- ::GetCursorPos (&pt);
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::ShowPopupMenu hMenu %d error %d\n",GetTStamp(tBuff,56),hMenu,GetLastError()));
- hPopup = ::GetSubMenu (hMenu, 0);
-
- int numItems = rhTray::mMenuItemStringMap.size();
+ if (hMenu != 0) {
+ POINT pt;
+ ::GetCursorPos (&pt);
+ hPopup = ::GetSubMenu (hMenu, 0);
+ int numItems = rhTray::mMenuItemStringMap.size();
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ShowPopupMenu num menu item strings : %d\n",numItems));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::ShowPopupMenu num menu item strings : %d\n",GetTStamp(tBuff,56),numItems));
// Change the menu items text if possible
- MENUITEMINFO mii = {0};
+ MENUITEMINFO mii = {0};
- unsigned int menuItemID = 0;
+ unsigned int menuItemID = 0;
- int i = 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();
+ 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"));
-
- }
- }
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::ShowPopupMenu menutext: %d text %s \n",GetTStamp(tBuff,56),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, ("%s rhTray::ShowPopupMenu Can't GetMenuItemInfo \n",GetTStamp(tBuff,56)));
+ }
+ }
- }
+ }
- }
+ }
- ::SetForegroundWindow (rhTray::mWnd);
+ ::SetForegroundWindow (rhTray::mWnd);
- WORD cmd = ::TrackPopupMenu (hPopup, TPM_RIGHTBUTTON | TPM_RETURNCMD,
+ WORD cmd = ::TrackPopupMenu (hPopup, TPM_RIGHTBUTTON | TPM_RETURNCMD,
pt.x, pt.y, 0, mWnd, NULL);
- ::PostMessage (mWnd, WM_NULL, 0, 0);
+ ::PostMessage (mWnd, WM_NULL, 0, 0);
- ::DestroyMenu (hMenu);
- return cmd;
- }
- return 0;
+ ::DestroyMenu (hMenu);
+ return cmd;
+ }
+ return 0;
}
HRESULT rhTray::RemoveListener(nsIBaseWindow *aBaseWindow)
{
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::RemoveWindowListener %p \n",aBaseWindow));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::RemoveWindowListener %p \n",GetTStamp(tBuff,56),aBaseWindow));
if(!aBaseWindow)
return S_OK;
@@ -682,32 +673,27 @@
}
rhTray::mWindowMap.erase(i);
-
}
return S_OK;
-
}
HRESULT rhTray::RemoveAllListeners()
{
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::RemoveAllListenesr\n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::RemoveAllListenesr\n",GetTStamp(tBuff,56)));
map< nsIBaseWindow *, rhTrayWindowListener *>::iterator i;
rhTrayWindowListener *cur = NULL;
for(i = rhTray::mWindowMap.begin(); i!= rhTray::mWindowMap.end(); i++)
{
-
cur = (*i).second;
if(cur)
{
-
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::RemoveAllListeners deleting %p\n",cur));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::RemoveAllListeners deleting %p\n",GetTStamp(tBuff,56),cur));
delete cur;
@@ -718,23 +704,19 @@
rhTray::mWindowMap.clear();
return S_OK;
-
}
/* void setmenuitemtext (in unsigned long aIndex, in string aText); */
NS_IMETHODIMP rhTray::Setmenuitemtext(PRUint32 aIndex, const char *aText)
{
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%sa rhTray::Setmenuitemtext index: %d text: %s\n",GetTStamp(tBuff,56),aIndex, 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;
-
- }
-
+ if(aIndex >= 0 && aIndex <= 10 && aText)
+ {
+ rhTray::mMenuItemStringMap[aIndex] = aText;
+ }
return S_OK;
}
@@ -744,7 +726,7 @@
rhITrayWindNotify* rhTray::GetTrayWindNotifyListener(rhITrayWindNotify *listener)
{
-
+ char tBuff[56];
std::list<nsCOMPtr<rhITrayWindNotify> >::const_iterator it;
for(it=gTrayWindNotifyListeners.begin(); it!=gTrayWindNotifyListeners.end(); ++it) {
@@ -755,40 +737,34 @@
}
}
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhCoolKey::GetNotifyKeyListener: looking for %p returning NULL. \n",listener));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhCoolKey::GetNotifyKeyListener: looking for %p returning NULL. \n",GetTStamp(tBuff,56),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));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::AddTrayWindNotifyListener: %p \n", GetTStamp(tBuff,56),listener));
if(GetTrayWindNotifyListener(listener ))
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddTrayWindNotifyListener: %p listener already in list. \n",listener));
-
- return ;
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::AddTrayWindNotifyListener: %p listener already in list. \n",GetTStamp(tBuff,56),listener));
+ return ;
}
gTrayWindNotifyListeners.push_back(listener);
-
}
void rhTray::RemoveTrayWindNotifyListener(rhITrayWindNotify *listener)
{
-
if(!GetTrayWindNotifyListener(listener))
{
return;
@@ -825,7 +801,6 @@
((rhITrayWindNotify *) (*it))->RhTrayWindEventNotify(aEvent,aEventData, aKeyData, aData1, aData2, &claimed);
-
}
}
@@ -842,8 +817,8 @@
rhTrayWindowListener::~rhTrayWindowListener()
{
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener::~rhTrayWindowListener.\n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener::~rhTrayWindowListener.\n",GetTStamp(tBuff,56)));
Cleanup();
@@ -857,7 +832,7 @@
LPARAM lParam
)
{
-
+ char tBuff[56];
WNDPROC wndProc = (WNDPROC) NULL;
int eventClaimed = 0;
@@ -875,7 +850,6 @@
else
{
wndProc = me->origWindowProc;
-
}
switch(aMsg) {
@@ -884,23 +858,23 @@
{
case HTMINBUTTON:
- if(me)
- {
- //me->HideWindow();
- }
+ if(me)
+ {
+ //me->HideWindow();
+ }
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener Minimize\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener Minimize\n",GetTStamp(tBuff,56)));
//eventClaimed = 1;
break;
case HTMAXBUTTON:
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: Maximize \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener:: Maximize \n",GetTStamp(tBuff,56)));
//eventClaimed = 1;
break;
case HTCLOSE:
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener Close! \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener Close! \n",GetTStamp(tBuff,56)));
if(me)
{
@@ -921,7 +895,7 @@
case WA_ACTIVE:
case WA_CLICKACTIVE:
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener ACTIVATE! \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener ACTIVATE! \n",GetTStamp(tBuff,56)));
break;
@@ -945,17 +919,13 @@
}
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener WM_SHOWWINDOW wParam %d lParam %d! \n",wParam, lParam));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener WM_SHOWWINDOW wParam %d lParam %d! \n",GetTStamp(tBuff,56),wParam, lParam));
show = (int) wParam;
-
if(lParam == 0)
{
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener WM_SHOW called from ShowWindow or HideWindow \n"));
-
-
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener WM_SHOW called from ShowWindow or HideWindow \n",GetTStamp(tBuff,56)));
}
break;
@@ -964,8 +934,7 @@
switch(wParam)
{
case SC_CLOSE:
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: WM_SYSCOMMAND SC_CLOSE \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener:: WM_SYSCOMMAND SC_CLOSE \n",GetTStamp(tBuff,56)));
break;
default:
@@ -979,7 +948,7 @@
{
case SIZE_MINIMIZED:
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: WM_SIZE SIZE_MINIMIZE \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener:: WM_SIZE SIZE_MINIMIZE \n",GetTStamp(tBuff,56)));
break;
default:
@@ -993,24 +962,25 @@
};
- if(eventClaimed)
- {
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: Event claimed \n"));
- return FALSE;
- }
+ if(eventClaimed)
+ {
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener:: Event claimed \n",GetTStamp(tBuff,56)));
+ return FALSE;
+ }
- return ::CallWindowProc(
- wndProc,
- hwnd,
- aMsg,
- wParam,
- lParam);
+ return ::CallWindowProc(
+ wndProc,
+ hwnd,
+ aMsg,
+ wParam,
+ lParam);
}
HRESULT rhTrayWindowListener::Cleanup()
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener::Cleanup. \n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener::Cleanup. \n",GetTStamp(tBuff,56)));
return S_OK;
@@ -1032,9 +1002,10 @@
void rhTrayWindowListener::ShowWindow()
{
+ char tBuff[56];
if(mWnd)
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: ShowWindow \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener:: ShowWindow \n",GetTStamp(tBuff,56)));
//::ShowWindow(mWnd,SW_SHOW);
//::ShowWindow(mWnd,SW_RESTORE);
@@ -1045,10 +1016,11 @@
void rhTrayWindowListener::HideWindow()
{
+ char tBuff[56];
if(mWnd)
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: Hide Window \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener:: Hide Window \n",GetTStamp(tBuff,56)));
::ShowWindow(mWnd,SW_HIDE);
@@ -1056,7 +1028,7 @@
::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"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener:: Hide Window , try to hide owner window too. \n",GetTStamp(tBuff,56)));
::ShowWindow(mWnd,SW_HIDE);
}
17 years, 1 month
[Fedora-directory-commits] esc/src/app/xpcom/tray rhMacTray.cpp, 1.4, 1.5
by Doctor Conrad
Author: jmagne
Update of /cvs/dirsec/esc/src/app/xpcom/tray
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv1642
Modified Files:
rhMacTray.cpp
Log Message:
Add time stamp to log messages.
Index: rhMacTray.cpp
===================================================================
RCS file: /cvs/dirsec/esc/src/app/xpcom/tray/rhMacTray.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- rhMacTray.cpp 25 Oct 2006 03:59:03 -0000 1.4
+++ rhMacTray.cpp 24 Feb 2007 02:04:32 -0000 1.5
@@ -47,8 +47,8 @@
rhTray::~rhTray()
{
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::~rhTray\n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::~rhTray\n",GetTStamp(tBuff,56)));
Cleanup();
@@ -57,8 +57,8 @@
NS_IMETHODIMP rhTray::Setwindnotifycallback(rhITrayWindNotify *jsNotify)
{
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Setwindnotifycallback\n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Setwindnotifycallback\n",GetTStamp(tBuff,56)));
if(jsNotify)
AddTrayWindNotifyListener(jsNotify);
@@ -71,9 +71,8 @@
NS_IMETHODIMP rhTray::Unsetwindnotifycallback(rhITrayWindNotify *jsNotify)
{
-
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Unsetwindnotifycallback\n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Unsetwindnotifycallback\n",GetTStamp(tBuff,56)));
if(jsNotify)
RemoveTrayWindNotifyListener(jsNotify);
@@ -84,11 +83,11 @@
/* void add (); */
NS_IMETHODIMP rhTray::Add(nsIBaseWindow *aWindow)
{
-
+ char tBuff[56];
NS_ENSURE_ARG(aWindow);
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Add %p \n",aWindow));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Add %p \n",GetTStamp(tBuff,56),aWindow));
HRESULT res = Initialize();
if(res != S_OK)
@@ -107,7 +106,8 @@
/* void remove (); */
NS_IMETHODIMP rhTray::Remove(nsIBaseWindow *aWindow)
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Remove window %p \n",aWindow));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Remove window %p \n",GetTStamp(tBuff,56),aWindow));
if(!aWindow)
return NS_OK;
@@ -123,7 +123,6 @@
NS_IMETHODIMP rhTray::Hide(nsIBaseWindow *aWindow)
{
-
rhTrayWindowListener *listener = rhTray::mWindowMap[aWindow];
if(listener)
@@ -133,28 +132,23 @@
}
return NS_OK;
-
}
NS_IMETHODIMP rhTray::Show(nsIBaseWindow *aWindow)
{
-
rhTrayWindowListener *listener = rhTray::mWindowMap[aWindow];
if(listener)
{
listener->ShowWindow();
-
}
return NS_OK;
-
}
/* void hideall (); */
NS_IMETHODIMP rhTray::Hideall()
{
-
HideAllListeners();
return NS_OK;
}
@@ -168,7 +162,6 @@
NS_IMETHODIMP rhTray::IsInitializedAlready(PRBool *_retval)
{
-
*_retval = 0;
if(rhTray::mInitialized > 1)
@@ -176,17 +169,12 @@
rhTray::mInitialized ++;
-
return NS_OK;
-
-
-
}
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); */
@@ -198,64 +186,53 @@
/* 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, PR_LOG_DEBUG, ("rhTray::Show app! \n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Show app! \n",GetTStamp(tBuff,56)));
::ShowHideProcess(&rhTray::mPSN,TRUE);
::SetFrontProcess(&rhTray::mPSN);
-
}
void rhTray::HideApp()
{
-
::ShowHideProcess(&rhTray::mPSN,FALSE);
-
}
HRESULT rhTray::Initialize()
{
-
+ char tBuff[56];
if(mInitialized)
return S_OK;
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Initialize dock: \n"));
-
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Initialize dock: \n",GetTStamp(tBuff,56)));
OSErr pRes = GetCurrentProcess (
&mPSN
);
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Initialize App PID result %d \n",pRes));
-
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Initialize App PID result %d \n",GetTStamp(tBuff,56),pRes));
HRESULT res = CreateApplicationListener();
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Initialize result of CreateApplicationListener %d \n",res));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Initialize result of CreateApplicationListener %d \n",GetTStamp(tBuff,56),res));
if(res != S_OK)
{
@@ -276,10 +253,10 @@
if(result == noErr)
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Initialize result of SetApplicationDockTileMenu %d \n",result));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Initialize result of SetApplicationDockTileMenu %d \n",GetTStamp(tBuff,56),result));
mDockMenu = GetApplicationDockTileMenu();
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Initialize result of GetApplicationDockTileMenu: %d . \n",mDockMenu));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Initialize result of GetApplicationDockTileMenu: %d . \n",GetTStamp(tBuff,56),mDockMenu));
}
}
@@ -321,22 +298,20 @@
}
mInitialized = 1;
-
return S_OK;
}
HRESULT rhTray::RemoveIcon()
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::RemoveIcon. \n"));
-
-
-
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::RemoveIcon. \n",GetTStamp(tBuff,56)));
return S_OK;
}
HRESULT rhTray::Cleanup()
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Cleanup.\n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Cleanup.\n",GetTStamp(tBuff,56)));
RemoveAllListeners();
DestroyEventWindow();
@@ -345,13 +320,11 @@
if(mEventHandlerRef)
{
::RemoveEventHandler(mEventHandlerRef);
-
}
if(mEventHandlerUPP)
{
::DisposeEventHandlerUPP(mEventHandlerUPP);
-
}
if(mDockMenu)
@@ -359,7 +332,6 @@
::ReleaseMenu(mDockMenu);
}
-
MenuRef goMenu = GetMenuHandle (GO_MENU_ID);
if(goMenu)
@@ -377,21 +349,19 @@
HRESULT rhTray::CreateApplicationListener()
{
+ char tBuff[56];
EventTargetRef target = GetApplicationEventTarget();
if(!target)
return E_FAIL;
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::CreateApplicationListener . app target %p\n",target));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::CreateApplicationListener . app target %p\n",GetTStamp(tBuff,56),target));
int numTypes = 4;
-
rhTray::mEventHandlerUPP = NewEventHandlerUPP(rhTray::ApplicationProc);
if(!rhTray::mEventHandlerUPP)
return E_FAIL;
-
-
EventTypeSpec eventTypes[]= { {kEventClassApplication, kEventAppActivated } , {kEventClassApplication , kEventAppDeactivated }, {kEventClassCommand, kEventCommandProcess}};
@@ -401,32 +371,28 @@
void rhTray::ShowAllListeners()
{
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ShowAllListeners.\n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::ShowAllListeners.\n",GetTStamp(tBuff,56)));
map< nsIBaseWindow *, rhTrayWindowListener *>::iterator i;
rhTrayWindowListener *cur = NULL;
for(i = rhTray::mWindowMap.begin(); i!= rhTray::mWindowMap.end(); i++)
{
-
- cur = (*i).second;
+ cur = (*i).second;
if(cur)
{
cur->ShowWindow();
-
}
}
-
-
}
-
void rhTray::HideAllListeners()
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::HideAllListeners.\n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::HideAllListeners.\n",GetTStamp(tBuff,56)));
map< nsIBaseWindow *, rhTrayWindowListener *>::iterator i;
@@ -438,20 +404,15 @@
if(cur)
{
-
cur->HideWindow();
-
}
-
}
-
}
HRESULT rhTray::DestroyEventWindow()
{
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::DestroyEventWindow \n"));
-
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::DestroyEventWindow \n",GetTStamp(tBuff,56)));
return S_OK;
}
@@ -459,17 +420,15 @@
HRESULT rhTray::AddListener(nsIBaseWindow *aWindow)
{
-
+ char tBuff[56];
nsresult rv;
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddListener %p \n",aWindow));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::AddListener %p \n",GetTStamp(tBuff,56),aWindow));
NS_ENSURE_ARG(aWindow);
nativeWindow aNativeWindow;
rv = aWindow->GetParentNativeWindow( &aNativeWindow );
-
if(NS_FAILED(rv))
{
return E_FAIL;
@@ -477,29 +436,25 @@
nsIWidget *widget= nsnull;
-
WindowRef hWnd = (WindowRef) aNativeWindow;
//Now see if it's alreay in the map
-
rv = aWindow->GetParentWidget(&widget);
if(widget)
{
hWnd =(WindowRef) widget->GetNativeData(NS_NATIVE_DISPLAY);
-
}
rhTrayWindowListener *already = rhTray::mWindowMap[aWindow];
if(already)
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddWindowListener Window already registered %p \n",aWindow));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::AddWindowListener Window already registered %p \n",GetTStamp(tBuff,56),aWindow));
return S_OK;
-
}
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddWindowListener top level widget %p \n",hWnd));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::AddWindowListener top level widget %p \n",GetTStamp(tBuff,56),hWnd));
rhTrayWindowListener *create = new rhTrayWindowListener(hWnd);
@@ -526,8 +481,8 @@
HRESULT rhTray::RemoveListener(nsIBaseWindow *aBaseWindow)
{
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::RemoveWindowListener %p \n",aBaseWindow));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::RemoveWindowListener %p \n",GetTStamp(tBuff,56),aBaseWindow));
if(!aBaseWindow)
return S_OK;
@@ -554,41 +509,36 @@
HRESULT rhTray::RemoveAllListeners()
{
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::RemoveAllListenesr\n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::RemoveAllListenesr\n",GetTStamp(tBuff,56)));
map< nsIBaseWindow *, rhTrayWindowListener *>::iterator i;
rhTrayWindowListener *cur = NULL;
for(i = rhTray::mWindowMap.begin(); i!= rhTray::mWindowMap.end(); i++)
{
-
cur = (*i).second;
if(cur)
{
-
delete cur;
-
}
-
}
rhTray::mWindowMap.clear();
return S_OK;
-
}
/* void setmenuitemtext (in unsigned long aIndex, in string aText); */
NS_IMETHODIMP rhTray::Setmenuitemtext(PRUint32 aIndex, const char *aText)
{
-
+ char tBuff[56];
// 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));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhCoolKey::Setmenuitemtext aIndex: %d text %s. \n",GetTStamp(tBuff,56),aIndex,aText));
MenuRef outMenu;
MenuItemIndex theIndex;
@@ -601,12 +551,11 @@
&theIndex
);
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhCoolKey::Setmenuitemtext Result of menu item: %d. \n",result));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhCoolKey::Setmenuitemtext Result of menu item: %d. \n",GetTStamp(tBuff,56),result));
if(result == noErr)
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhCoolKey::Setmenuitemtext changing item index: %d . \n",theIndex));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhCoolKey::Setmenuitemtext changing item index: %d . \n",GetTStamp(tBuff,56),theIndex));
CFStringRef cfStr= CFStringCreateWithCString (
NULL,
aText,
@@ -619,16 +568,14 @@
cfStr
);
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhCoolKey::Setmenuitemtext Result of setting item text: %d. \n",result));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhCoolKey::Setmenuitemtext Result of setting item text: %d. \n",GetTStamp(tBuff,56),result));
}
-
// Now take care of the root menu, provide exact same item here
MenuRef tGoMenu = GetMenuHandle (GO_MENU_ID);
-
if(!tGoMenu)
{
return S_OK;
@@ -645,12 +592,11 @@
&theGoIndex
);
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhCoolKey::Setmenuitemtext Result of menu item for go menu: %d. \n",result));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhCoolKey::Setmenuitemtext Result of menu item for go menu: %d. \n",GetTStamp(tBuff,56),result));
if(resultRoot == noErr)
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhCoolKey::Setmenuitemtext changing item index: %d . For go menu. \n",theIndex));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhCoolKey::Setmenuitemtext changing item index: %d . For go menu. \n",GetTStamp(tBuff,56),theIndex));
CFStringRef cfStr= CFStringCreateWithCString (
NULL,
aText,
@@ -663,13 +609,9 @@
cfStr
);
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhCoolKey::Setmenuitemtext Result of setting item text for root menu: %d. \n",result));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhCoolKey::Setmenuitemtext Result of setting item text for root menu: %d. \n",GetTStamp(tBuff,56),result));
}
-
-
-
-
}
return S_OK;
@@ -680,7 +622,7 @@
rhITrayWindNotify* rhTray::GetTrayWindNotifyListener(rhITrayWindNotify *listener)
{
-
+ char tBuff[56];
std::list<nsCOMPtr<rhITrayWindNotify> >::const_iterator it;
for(it=gTrayWindNotifyListeners.begin(); it!=gTrayWindNotifyListeners.end(); ++it) {
@@ -691,43 +633,33 @@
}
}
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhCoolKey::GetNotifyKeyListener: looking for %p returning NULL. \n",listener));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhCoolKey::GetNotifyKeyListener: looking for %p returning NULL. \n",GetTStamp(tBuff,56),listener));
return nsnull;
-
-
-
}
int rhTray::GetTrayWindNotifyListSize()
{
return gTrayWindNotifyListeners.size();
-
}
void rhTray::AddTrayWindNotifyListener(rhITrayWindNotify *listener)
{
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddTrayWindNotifyListener: %p \n",
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddTrayWindNotifyListener: %p \n",GetTStamp(tBuff,56),
listener));
if(GetTrayWindNotifyListener(listener ))
{
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddTrayWindNotifyListener: %p listener already in list. \n",listener));
-
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::AddTrayWindNotifyListener: %p listener already in list. \n",GetTStamp(tBuff,56),listener));
return ;
-
}
gTrayWindNotifyListeners.push_back(listener);
-
-
}
void rhTray::RemoveTrayWindNotifyListener(rhITrayWindNotify *listener)
{
-
if(!GetTrayWindNotifyListener(listener))
{
return;
@@ -735,13 +667,11 @@
gTrayWindNotifyListeners.remove(listener);
-
listener = NULL;
}
void rhTray::ClearTrayWindNotifyList()
{
-
while (gTrayWindNotifyListeners.size() > 0) {
rhITrayWindNotify * node = (gTrayWindNotifyListeners.front()).get();
@@ -749,12 +679,11 @@
gTrayWindNotifyListeners.pop_front();
}
-
}
void rhTray::NotifyTrayWindListeners(PRUint32 aEvent, PRUint32 aEventData,PRUint32 aKeyData,PRUint32 aData1, PRUint32 aData2)
{
-
+ char tBuff[56];
//Now notify all the listeners of the event
std::list< nsCOMPtr <rhITrayWindNotify> >::const_iterator it;
@@ -762,46 +691,40 @@
PRBool claimed = 0;
- PR_LOG(trayLog, PR_LOG_DEBUG, ("rhTray::NotifyTrayWindListener: . \n"));
+ PR_LOG(trayLog, PR_LOG_DEBUG, ("%s rhTray::NotifyTrayWindListener: . \n",GetTStamp(tBuff,56)));
((rhITrayWindNotify *) (*it))->RhTrayWindEventNotify(aEvent,aEventData, aKeyData, aData1, aData2, &claimed);
-
}
}
pascal OSStatus rhTray::ApplicationProc(EventHandlerCallRef nextHandler, EventRef aEvent, void *userData)
{
-
+ char tBuff[56];
OSStatus result = eventNotHandledErr;
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ApplicationProc .\n"));
-
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::ApplicationProc .\n",GetTStamp(tBuff,56)));
int theEvent = GetEventKind(aEvent);
int theClass = GetEventClass(aEvent);
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ApplicationProc class %d event: %d \n",theClass,theEvent));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::ApplicationProc class %d event: %d \n",GetTStamp(tBuff,56),theClass,theEvent));
switch(theClass)
{
-
case kEventClassApplication:
switch(theEvent)
{
-
case kEventAppActivated:
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ApplicationProc App activated! \n"));
- result = noErr;
- break;
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::ApplicationProc App activated! \n",GetTStamp(tBuff,56)));
+ result = noErr;
+ break;
case kEventAppDeactivated:
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ApplicationProc App deactivated! \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::ApplicationProc App deactivated! \n",GetTStamp(tBuff,56)));
result = noErr;
break;
-
};
@@ -809,9 +732,7 @@
case kEventClassCommand:
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ApplicationProc App kEventClassCommand! \n"));
-
-
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::ApplicationProc App kEventClassCommand! \n",GetTStamp(tBuff,56)));
HICommand commandStruct;
GetEventParameter (aEvent, kEventParamDirectObject,
@@ -821,24 +742,24 @@
switch(commandStruct.commandID)
{
case kHICommandHide:
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ApplicationProc App kHICommandHide! \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::ApplicationProc App kHICommandHide! \n",GetTStamp(tBuff,56)));
break;
case kHICommandSelectWindow:
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ApplicationProc App kHICommandSelectWindow! \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::ApplicationProc App kHICommandSelectWindow! \n",GetTStamp(tBuff,56)));
break;
case kHICommandClose:
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ApplicationProc App kHICommandClose! \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::ApplicationProc App kHICommandClose! \n",GetTStamp(tBuff,56)));
break;
case kHICommandQuit:
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ApplicationProc App kHICommandQuit! \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::ApplicationProc App kHICommandQuit! \n",GetTStamp(tBuff,56)));
break;
case MENU_ITEM_ID_BASE:
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ApplicationProc App Manage Smart Cards! \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::ApplicationProc App Manage Smart Cards! \n",GetTStamp(tBuff,56)));
NotifyTrayWindListeners(MENU_EVT,MENU_SHOW);
break;
@@ -852,7 +773,6 @@
break;
}
-
return result;
}
@@ -865,14 +785,16 @@
rhTrayWindowListener::~rhTrayWindowListener()
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener::~rhTrayWindowListener.\n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener::~rhTrayWindowListener.\n",GetTStamp(tBuff,56)));
Cleanup();
}
HRESULT rhTrayWindowListener::Initialize()
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener::Initialize \n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener::Initialize \n",GetTStamp(tBuff,56)));
mEventHandlerUPP = NewEventHandlerUPP(rhTrayWindowListener::WindowProc);
@@ -895,28 +817,26 @@
void rhTrayWindowListener::ShowWindow()
{
-
+ char tBuff[56];
if(mWnd)
{
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: ShowWindow \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener:: ShowWindow \n",GetTStamp(tBuff,56)));
if(IsWindowCollapsed(mWnd))
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: ShowWindow : uncollapsing collapsed window. \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener:: ShowWindow : uncollapsing collapsed window. \n",GetTStamp(tBuff,56)));
//::CollapseWindow(mWnd,FALSE);
}
-
if(!IsWindowVisible(mWnd))
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: ShowWindow : Window not visible showing... \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener:: ShowWindow : Window not visible showing... \n",GetTStamp(tBuff,56)));
//::ShowWindow(mWnd);
}
::BringToFront(mWnd);
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: ShowWindow : \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener:: ShowWindow : \n",GetTStamp(tBuff,56)));
rhTray::ShowApp();
@@ -925,46 +845,45 @@
void rhTrayWindowListener::HideWindow()
{
+ char tBuff[56];
if(mWnd)
{
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: HideWindow \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener:: HideWindow \n",GetTStamp(tBuff,56)));
}
}
pascal OSStatus rhTrayWindowListener::WindowProc(EventHandlerCallRef nextHandler, EventRef aEvent, void *userData)
{
-
+ char tBuff[56];
OSStatus result = eventNotHandledErr;
rhTrayWindowListener * self = (rhTrayWindowListener *) userData;
int theEvent = GetEventKind(aEvent);
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener::WindowProc event: %d \n",theEvent));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener::WindowProc event: %d \n",GetTStamp(tBuff,56),theEvent));
switch(theEvent)
{
case kEventWindowClose:
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener::WindowProc attempting Window close! \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener::WindowProc attempting Window close! \n",GetTStamp(tBuff,56)));
break;
case kEventWindowHidden:
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener::WindowProc attempting Window hide! \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener::WindowProc attempting Window hide! \n",GetTStamp(tBuff,56)));
break;
case kEventWindowClosed:
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener::WindowProc Window closed! \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener::WindowProc Window closed! \n",GetTStamp(tBuff,56)));
break;
case kEventMouseDown:
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener::WindowProc mouse down! \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener::WindowProc mouse down! \n",GetTStamp(tBuff,56)));
break;
}
@@ -974,13 +893,12 @@
HRESULT rhTrayWindowListener::Cleanup()
{
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener::Cleanup. \n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener::Cleanup. \n",GetTStamp(tBuff,56)));
if(mEventHandlerRef)
{
::RemoveEventHandler(mEventHandlerRef);
-
}
if(mEventHandlerUPP)
@@ -989,7 +907,6 @@
}
return S_OK;
-
}
17 years, 1 month
[Fedora-directory-commits] esc/src/app/xpcom/tray rhLinuxTray.cpp, 1.3, 1.4
by Doctor Conrad
Author: jmagne
Update of /cvs/dirsec/esc/src/app/xpcom/tray
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv1548
Modified Files:
rhLinuxTray.cpp
Log Message:
Add time stamp to log messages.
Index: rhLinuxTray.cpp
===================================================================
RCS file: /cvs/dirsec/esc/src/app/xpcom/tray/rhLinuxTray.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- rhLinuxTray.cpp 27 Sep 2006 17:21:58 -0000 1.3
+++ rhLinuxTray.cpp 24 Feb 2007 02:02:37 -0000 1.4
@@ -37,6 +37,7 @@
static PRLogModuleInfo *trayLog = PR_NewLogModule("tray");
+
rhTray::rhTray()
{
/* member initializers and constructor code */
@@ -46,7 +47,8 @@
rhTray::~rhTray()
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::~rhTray\n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::~rhTray\n",GetTStamp(tBuff,56)));
Cleanup();
@@ -56,12 +58,12 @@
NS_IMETHODIMP rhTray::Setwindnotifycallback(rhITrayWindNotify *jsNotify)
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Setwindnotifycallback\n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Setwindnotifycallback\n",GetTStamp(tBuff,56)));
if(jsNotify)
AddTrayWindNotifyListener(jsNotify);
-
return NS_OK;
}
@@ -69,9 +71,9 @@
NS_IMETHODIMP rhTray::Unsetwindnotifycallback(rhITrayWindNotify *jsNotify)
{
+ char tBuff[56];
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Unsetwindnotifycallback\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Unsetwindnotifycallback\n",GetTStamp(tBuff,56)));
if(jsNotify)
RemoveTrayWindNotifyListener(jsNotify);
@@ -82,12 +84,14 @@
/* void add (); */
NS_IMETHODIMP rhTray::Add(nsIBaseWindow *aWindow)
{
-
-
+ char tBuff[56];
NS_ENSURE_ARG(aWindow);
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Add %p \n",aWindow));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Add %p \n",GetTStamp(tBuff,56),aWindow));
HRESULT res = Initialize();
+
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Add Initialize res %d \n",GetTStamp(tBuff,56),res));
+
if(res != S_OK)
{
return NS_ERROR_FAILURE;
@@ -104,23 +108,23 @@
/* void remove (); */
NS_IMETHODIMP rhTray::Remove(nsIBaseWindow *aWindow)
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Remove window %p \n",aWindow));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Remove window %p \n",GetTStamp(tBuff,56),aWindow));
- if(!aWindow)
+ if(!aWindow)
return NS_OK;
- HRESULT res = RemoveListener(aWindow);
+ HRESULT res = RemoveListener(aWindow);
- if(res != S_OK)
- {
- return NS_ERROR_FAILURE;
- }
- return NS_OK;
+ if(res != S_OK)
+ {
+ return NS_ERROR_FAILURE;
+ }
+ return NS_OK;
}
NS_IMETHODIMP rhTray::Hide(nsIBaseWindow *aWindow)
{
-
rhTrayWindowListener *listener = rhTray::mWindowMap[aWindow];
if(listener)
@@ -130,27 +134,22 @@
}
return NS_OK;
-
}
NS_IMETHODIMP rhTray::Show(nsIBaseWindow *aWindow)
{
-
rhTrayWindowListener *listener = rhTray::mWindowMap[aWindow];
if(listener)
{
listener->ShowWindow();
-
}
return NS_OK;
-
}
NS_IMETHODIMP rhTray::IsInitializedAlready(PRBool *_retval)
{
-
*_retval = 0;
if(rhTray::mInitialized > 1)
@@ -158,27 +157,20 @@
rhTray::mInitialized ++;
-
return NS_OK;
-
-
-
}
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;
-
}
/* void hideall (); */
NS_IMETHODIMP rhTray::Hideall()
{
-
HideAllListeners();
return NS_OK;
}
@@ -193,7 +185,6 @@
/* void settooltipmsg (in string aMessage); */
NS_IMETHODIMP rhTray::Settooltipmsg(const char *aMessage)
{
-
if(aMessage)
notify_icon_set_static_tooltip(aMessage);
@@ -203,43 +194,35 @@
/* 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()
{
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Initialize entering... mInitialized: %d \n",GetTStamp(tBuff,56),mInitialized));
if(mInitialized)
{
return S_OK;
}
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Initialize \n"));
-
-
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Initialize \n",GetTStamp(tBuff,56)));
g_set_print_handler(rhTray::TrayPrintHandler);
-
notify_icon_create_with_image_file(COOLKEY_ICON);
HRESULT res = notify_icon_created_ok();
@@ -248,19 +231,17 @@
{
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, PR_LOG_DEBUG, ("rhTray::Initialize result of CreateIconMenu %d \n",res));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Initialize result of CreateIconMenu %d \n",GetTStamp(tBuff,56),res));
if(res != S_OK)
{
@@ -269,7 +250,6 @@
mInitialized = 1;
-
return S_OK;
}
@@ -280,7 +260,8 @@
HRESULT rhTray::Cleanup()
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Cleanup.\n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Cleanup.\n",GetTStamp(tBuff,56)));
RemoveAllListeners();
DestroyEventWindow();
@@ -291,32 +272,27 @@
void rhTray::ShowAllListeners()
{
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::ShowAllListeners.\n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::ShowAllListeners.\n",GetTStamp(tBuff,56)));
map< nsIBaseWindow *, rhTrayWindowListener *>::iterator i;
rhTrayWindowListener *cur = NULL;
for(i = rhTray::mWindowMap.begin(); i!= rhTray::mWindowMap.end(); i++)
{
-
- cur = (*i).second;
+ cur = (*i).second;
if(cur)
{
cur->ShowWindow();
-
}
-
}
-
-
}
-
void rhTray::HideAllListeners()
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::HideAllListeners.\n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::HideAllListeners.\n",GetTStamp(tBuff,56)));
map< nsIBaseWindow *, rhTrayWindowListener *>::iterator i;
@@ -329,28 +305,23 @@
if(cur)
{
cur->HideWindow();
-
}
-
}
-
}
HRESULT rhTray::DestroyEventWindow()
{
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::DestroyEventWindow \n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::DestroyEventWindow \n",GetTStamp(tBuff,56)));
rhTray::mWnd = 0;
-
return S_OK;
}
void rhTray::IconMenuCBProc(GtkWidget *widget, gpointer data)
{
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::IconMenuCBProc data %s \n",data));
-
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::IconMenuCBProc data %s \n",GetTStamp(tBuff,56),data));
if(!strcmp((char *)data,"icon.min"))
{
@@ -371,8 +342,8 @@
HRESULT rhTray::CreateIconMenu()
{
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::CreateIconMenu \n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::CreateIconMenu \n",GetTStamp(tBuff,56)));
if(mIconMenu)
return E_FAIL;
@@ -407,20 +378,17 @@
void rhTray::IconCBProc(GtkWidget *button, GdkEventButton *event, void *data)
{
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::IconCBProc \n"));
-
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::IconCBProc \n",GetTStamp(tBuff,56)));
if(event->type != GDK_BUTTON_PRESS)
{
return;
-
}
if(event->button == 1)
{
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::IconCBProc Clicked!\n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::IconCBProc Clicked!\n",GetTStamp(tBuff,56)));
NotifyTrayWindListeners(MENU_EVT,MENU_SHOW);
rhTray::ShowAllListeners();
@@ -430,7 +398,6 @@
if(event->button == 2 || event->button == 3)
{
-
if(mIconMenu)
{
g_print("trying to create popup menu. \n");
@@ -449,8 +416,8 @@
HRESULT rhTray::CreateEventWindow()
{
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::CreateEventWindow \n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::CreateEventWindow \n",GetTStamp(tBuff,56)));
HRESULT res = CreateIconMenu();
return res;
@@ -458,17 +425,15 @@
HRESULT rhTray::AddListener(nsIBaseWindow *aWindow)
{
-
+ char tBuff[56];
nsresult rv;
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddListener %p \n",aWindow));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::AddListener %p \n",GetTStamp(tBuff,56),aWindow));
NS_ENSURE_ARG(aWindow);
- nativeWindow aNativeWindow;
+ nativeWindow aNativeWindow;
rv = aWindow->GetParentNativeWindow( &aNativeWindow );
-
if(NS_FAILED(rv))
{
return E_FAIL;
@@ -479,8 +444,7 @@
gdk_window_get_user_data (gWnd,(void **)&hWnd);
-
- PR_LOG(trayLog,PR_LOG_DEBUG, ("rhTray::AddListener is widget %p .\n",hWnd));
+ PR_LOG(trayLog,PR_LOG_DEBUG, ("%s rhTray::AddListener is widget %p .\n",GetTStamp(tBuff,56),hWnd));
if(!hWnd)
{
return E_FAIL;
@@ -493,22 +457,21 @@
if(already)
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddWindowListener Window already registered %p \n",aWindow));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::AddWindowListener Window already registered %p \n",GetTStamp(tBuff,56),aWindow));
return S_OK;
}
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddWindowListener current level widget %p \n",hWnd));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::AddWindowListener current level widget %p \n",GetTStamp(tBuff,56),hWnd));
hWnd = gtk_widget_get_toplevel( hWnd);
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddWindowListener top level widget %p \n",hWnd));
-
- if (GTK_WIDGET_TOPLEVEL (hWnd))
- {
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddWindowListener is really a top level widget %p \n",hWnd));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::AddWindowListener top level widget %p \n",GetTStamp(tBuff,56),hWnd));
- }
+ if (GTK_WIDGET_TOPLEVEL (hWnd))
+ {
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::AddWindowListener is really a top level widget %p \n",GetTStamp(tBuff,56),hWnd));
+ }
rhTrayWindowListener *create = new rhTrayWindowListener(hWnd);
if(!create)
@@ -535,8 +498,8 @@
HRESULT rhTray::RemoveListener(nsIBaseWindow *aBaseWindow)
{
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::RemoveWindowListener %p \n",aBaseWindow));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::RemoveWindowListener %p \n",GetTStamp(tBuff,56),aBaseWindow));
if(!aBaseWindow)
return S_OK;
@@ -563,22 +526,19 @@
HRESULT rhTray::RemoveAllListeners()
{
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::RemoveAllListenesr\n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::RemoveAllListenesr\n",GetTStamp(tBuff,56)));
map< nsIBaseWindow *, rhTrayWindowListener *>::iterator i;
rhTrayWindowListener *cur = NULL;
for(i = rhTray::mWindowMap.begin(); i!= rhTray::mWindowMap.end(); i++)
{
-
cur = (*i).second;
if(cur)
{
-
delete cur;
-
}
}
@@ -586,14 +546,13 @@
rhTray::mWindowMap.clear();
return S_OK;
-
}
/* 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));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Setmenuitemtext: index: %d text %s. \n",GetTStamp(tBuff,56),aIndex,aText));
if(!aText)
return S_OK;
@@ -611,17 +570,16 @@
unsigned int i = 0;
for (iterate = children; iterate; iterate=iterate->next)
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Setmenuitemtext: index: %d \n",i));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Setmenuitemtext: index: %d \n",GetTStamp(tBuff,56),i));
if(aIndex == i)
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::Setmenuitemtext: About to reset text of item %p. \n",(void *) iterate->data));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Setmenuitemtext: About to reset text of item %p. \n",GetTStamp(tBuff,56),(void *) iterate->data));
if(iterate->data)
{
GtkWidget *label = gtk_bin_get_child(GTK_BIN(iterate->data));
if(label)
{
-
gtk_label_set_text(GTK_LABEL(label),aText);
}
}
@@ -639,55 +597,45 @@
rhITrayWindNotify* rhTray::GetTrayWindNotifyListener(rhITrayWindNotify *listener)
{
-
+ char tBuff[56];
std::list<nsCOMPtr<rhITrayWindNotify> >::const_iterator it;
for(it=gTrayWindNotifyListeners.begin(); it!=gTrayWindNotifyListeners.end(); ++it) {
- if((*it) == listener)
- {
- return (*it);
+ if((*it) == listener)
+ {
+ return (*it);
+ }
}
-}
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhCoolKey::GetNotifyKeyListener: looking for %p returning NULL. \n",listener));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhCoolKey::GetNotifyKeyListener: looking for %p returning NULL. \n",GetTStamp(tBuff,56),listener));
return nsnull;
-
-
-
}
int rhTray::GetTrayWindNotifyListSize()
{
return gTrayWindNotifyListeners.size();
-
}
-
void rhTray::AddTrayWindNotifyListener(rhITrayWindNotify *listener)
{
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddTrayWindNotifyListener: %p \n",
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::AddTrayWindNotifyListener: %p \n", GetTStamp(tBuff,56),
listener));
if(GetTrayWindNotifyListener(listener ))
{
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::AddTrayWindNotifyListener: %p listener already in list. \n",listener));
-
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::AddTrayWindNotifyListener: %p listener already in list. \n",GetTStamp(tBuff,56),listener));
return ;
}
gTrayWindNotifyListeners.push_back(listener);
-
-
}
void rhTray::RemoveTrayWindNotifyListener(rhITrayWindNotify *listener)
{
-
if(!GetTrayWindNotifyListener(listener))
{
return;
@@ -695,14 +643,11 @@
gTrayWindNotifyListeners.remove(listener);
-
listener = NULL;
}
-
void rhTray::ClearTrayWindNotifyList()
{
-
while (gTrayWindNotifyListeners.size() > 0) {
rhITrayWindNotify * node = (gTrayWindNotifyListeners.front()).get();
@@ -716,7 +661,8 @@
void rhTray::NotifyTrayWindListeners(PRUint32 aEvent, PRUint32 aEventData,PRUint32 aKeyData,PRUint32 aData1, PRUint32 aData2)
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray::NotifyTrayWindListeners \n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::NotifyTrayWindListeners \n",GetTStamp(tBuff,56)));
//Now notify all the listeners of the event
@@ -725,10 +671,9 @@
PRBool claimed = 0;
- PR_LOG( trayLog, PR_LOG_DEBUG, ("NotifyTrayWindListeners about to notify \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s NotifyTrayWindListeners about to notify \n",GetTStamp(tBuff,56)));
((rhITrayWindNotify *) (*it))->RhTrayWindEventNotify(aEvent,aEventData, aKeyData, aData1, aData2, &claimed);
-
}
}
@@ -736,9 +681,8 @@
void rhTray::TrayPrintHandler(const gchar *string)
{
-
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTray:TrayPrintHandler. : %s \n",(char *) string));
-
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray:TrayPrintHandler. : %s \n",GetTStamp(tBuff,56),(char *) string));
}
//rhTrayWindowListener Methods
@@ -749,12 +693,14 @@
rhTrayWindowListener::~rhTrayWindowListener()
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener::rhTrayWindowListener.\n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener::rhTrayWindowListener.\n",GetTStamp(tBuff,56)));
}
HRESULT rhTrayWindowListener::Initialize()
{
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener::Initialize \n"));
+ char tBuff[56];
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener::Initialize \n",GetTStamp(tBuff,56)));
if(mWnd)
{
@@ -770,6 +716,7 @@
void rhTrayWindowListener::ShowWindow()
{
+ char tBuff[56];
if(mWnd)
{
GtkWidget *widget = NULL;
@@ -790,27 +737,27 @@
}
}
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: ShowWindow \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener:: ShowWindow \n",GetTStamp(tBuff,56)));
}
-
}
void rhTrayWindowListener::HideWindow()
{
+ char tBuff[56];
if(mWnd)
{
gtk_widget_hide(mWnd);
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener:: Hide Window %p\n",mWnd));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener:: Hide Window %p\n",GetTStamp(tBuff,56),mWnd));
}
}
void rhTrayWindowListener::WndDestroyCBProc( GtkWidget *widget,
gpointer data )
{
-
+ char tBuff[56];
g_print("WndDestroyCBProc \n");
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener::WndDestroyCBProc \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener::WndDestroyCBProc \n",GetTStamp(tBuff,56)));
}
@@ -818,9 +765,10 @@
GdkEvent *event,
gpointer data )
{
+ char tBuff[56];
g_print("WndDeleteCBProc\n");
- PR_LOG( trayLog, PR_LOG_DEBUG, ("rhTrayWindowListener::WndDeleteCBProc \n"));
+ PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTrayWindowListener::WndDeleteCBProc \n",GetTStamp(tBuff,56)));
rhTrayWindowListener *me = (rhTrayWindowListener *) data;
17 years, 1 month