f35d1b
diff -up ./esc/src/app/xpcom/rhCoolKey.cpp.fix15 ./esc/src/app/xpcom/rhCoolKey.cpp
f35d1b
--- ./esc/src/app/xpcom/rhCoolKey.cpp.fix15	2012-11-26 14:34:39.963604936 -0800
f35d1b
+++ ./esc/src/app/xpcom/rhCoolKey.cpp	2012-11-26 14:34:57.012934189 -0800
f35d1b
@@ -16,6 +16,7 @@
f35d1b
  * END COPYRIGHT BLOCK **/
f35d1b
 
f35d1b
 #define FORCE_PR_LOG 1
f35d1b
+#define nsnull NULL
f35d1b
 #include <stdio.h>
f35d1b
 #include "rhCoolKey.h"
f35d1b
 #include "CoolKey.h"
f35d1b
diff -up ./esc/src/app/xpcom/rhICoolKey.idl.fix15 ./esc/src/app/xpcom/rhICoolKey.idl
f35d1b
--- ./esc/src/app/xpcom/rhICoolKey.idl.fix15	2012-11-26 14:33:41.730480795 -0800
f35d1b
+++ ./esc/src/app/xpcom/rhICoolKey.idl	2012-11-26 14:34:08.479996487 -0800
f35d1b
@@ -48,11 +48,11 @@ interface rhICoolKey:nsISupports
f35d1b
 
f35d1b
     void CancelCoolKeyOperation(in unsigned long aKeyType, in string aKeyID);
f35d1b
 
f35d1b
-    void GetAvailableCoolKeys(out PRUint32 count,
f35d1b
+    void GetAvailableCoolKeys(out uint32_t count,
f35d1b
                      [retval, array, size_is(count)] out string str);
f35d1b
 
f35d1b
      void GetCoolKeyCertNicknames(in unsigned long aKeyType, in string aKeyID,
f35d1b
-      out PRUint32 count, [retval, array, size_is(count)] out string str);
f35d1b
+      out uint32_t count, [retval, array, size_is(count)] out string str);
f35d1b
 
f35d1b
     
f35d1b
     unsigned long GetCoolKeyStatus(in unsigned long  aKeyType,in string aKeyID);
f35d1b
diff -up ./esc/src/app/xpcom/tray/Makefile.sdk.fix15 ./esc/src/app/xpcom/tray/Makefile.sdk
f35d1b
--- ./esc/src/app/xpcom/tray/Makefile.sdk.fix15	2012-11-21 11:55:24.396959829 -0800
f35d1b
+++ ./esc/src/app/xpcom/tray/Makefile.sdk	2012-11-21 11:55:35.227171392 -0800
f35d1b
@@ -248,7 +248,7 @@ ifeq ($(OS_ARCH),Linux)
f35d1b
 
f35d1b
 	$(CXX)   $(CPPFLAGS) -shared -o $(TARGET) $(OBJECT)  $(GECKO_DEFINES) $(GECKO_INCLUDES)  $(GECKO_LDFLAGS) $(COOLKEY_LIBS) 
f35d1b
 	chmod +x $(TARGET)
f35d1b
-	strip $(TARGET)
f35d1b
+	#strip $(TARGET)
f35d1b
 endif
f35d1b
 
f35d1b
 ifeq ($(OS_ARCH),WINNT)
f35d1b
diff -up ./esc/src/app/xpcom/tray/rhLinuxTray.cpp.fix15 ./esc/src/app/xpcom/tray/rhLinuxTray.cpp
f35d1b
--- ./esc/src/app/xpcom/tray/rhLinuxTray.cpp.fix15	2012-11-21 11:56:16.677981170 -0800
f35d1b
+++ ./esc/src/app/xpcom/tray/rhLinuxTray.cpp	2012-11-26 14:26:03.793664849 -0800
f35d1b
@@ -290,7 +290,7 @@ HRESULT rhTray::Initialize()
f35d1b
 
f35d1b
     PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhTray::Initialize  \n",GetTStamp(tBuff,56)));
f35d1b
     g_set_print_handler(rhTray::TrayPrintHandler);
f35d1b
-    notify_icon_create_with_image_file(COOLKEY_ICON);
f35d1b
+    notify_icon_create_with_image_file((char *)COOLKEY_ICON);
f35d1b
  
f35d1b
     HRESULT res = notify_icon_created_ok(); 
f35d1b
 
f35d1b
@@ -690,7 +690,7 @@ rhITrayWindNotify* rhTray::GetTrayWindNo
f35d1b
 
f35d1b
     PR_LOG( trayLog, PR_LOG_DEBUG, ("%s rhCoolKey::GetNotifyKeyListener:  looking for %p returning NULL. \n",GetTStamp(tBuff,56),listener));
f35d1b
 
f35d1b
-    return nsnull;
f35d1b
+    return NULL;
f35d1b
 }
f35d1b
 
f35d1b
 int rhTray::GetTrayWindNotifyListSize()
f35d1b
diff -up ./esc/src/app/xpcom/tray/rhTray.h.fix15 ./esc/src/app/xpcom/tray/rhTray.h
f35d1b
--- ./esc/src/app/xpcom/tray/rhTray.h.fix15	2012-11-21 11:57:47.827762126 -0800
f35d1b
+++ ./esc/src/app/xpcom/tray/rhTray.h	2012-11-21 11:57:58.304966858 -0800
f35d1b
@@ -37,7 +37,7 @@ extern "C" {
f35d1b
         int maxSize = 55;
f35d1b
         if(aSize < maxSize)
f35d1b
             return NULL;
f35d1b
-        char *tFormat = "[%c]";
f35d1b
+        char *tFormat = (char *) "[%c]";
f35d1b
         time_t tm = time(NULL);
f35d1b
         struct tm *ptr = localtime(&tm;;
f35d1b
         strftime(aTime ,maxSize ,tFormat,ptr);
f35d1b
diff -up ./esc/src/app/xul/esc/chrome/content/esc/advancedinfo.xul.fix15 ./esc/src/app/xul/esc/chrome/content/esc/advancedinfo.xul
f35d1b
--- ./esc/src/app/xul/esc/chrome/content/esc/advancedinfo.xul.fix15	2012-11-21 14:23:47.146114600 -0800
f35d1b
+++ ./esc/src/app/xul/esc/chrome/content/esc/advancedinfo.xul	2012-11-21 14:24:57.057408644 -0800
f35d1b
@@ -22,6 +22,9 @@
f35d1b
 
f35d1b
     class="escwindow"
f35d1b
     id="esc-window"
f35d1b
+    height="500"
f35d1b
+    width="600"
f35d1b
+    persist="width height"
f35d1b
     onload="ShowAdvancedInfo();"
f35d1b
     onunload="cleanup();"
f35d1b
     title="&escTitle;"
f35d1b
diff -up ./esc/src/app/xul/esc/chrome/content/esc/config.xul.fix15 ./esc/src/app/xul/esc/chrome/content/esc/config.xul
f35d1b
--- ./esc/src/app/xul/esc/chrome/content/esc/config.xul.fix15	2012-11-21 14:25:17.956795502 -0800
f35d1b
+++ ./esc/src/app/xul/esc/chrome/content/esc/config.xul	2012-11-21 14:25:53.737457832 -0800
f35d1b
@@ -26,6 +26,7 @@
f35d1b
     onload="InitializePhoneHomeConfigUI();"
f35d1b
     width ="650"
f35d1b
     height= "400"
f35d1b
+    persist="width height"
f35d1b
     onunload="cleanup();"
f35d1b
     xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
f35d1b
 <stringbundle id="esc_strings" src="chrome://esc/locale/esc.properties"/>
f35d1b
diff -up ./esc/src/app/xul/esc/chrome/content/esc/esc.css.fix15 ./esc/src/app/xul/esc/chrome/content/esc/esc.css
f35d1b
--- ./esc/src/app/xul/esc/chrome/content/esc/esc.css.fix15	2012-11-21 14:26:08.849737580 -0800
f35d1b
+++ ./esc/src/app/xul/esc/chrome/content/esc/esc.css	2012-11-21 14:27:06.947813071 -0800
f35d1b
@@ -334,6 +334,10 @@ tr [COOLKeyPresent="yes"]{
f35d1b
    border: black solid 4px;
f35d1b
 }
f35d1b
 
f35d1b
+.BorderedBrowser {
f35d1b
+    border: black solid 4px;
f35d1b
+}
f35d1b
+
f35d1b
 .SelectedRow {
f35d1b
 
f35d1b
     color: white;
f35d1b
diff -up ./esc/src/app/xul/esc/chrome/content/esc/ESC.js.fix15 ./esc/src/app/xul/esc/chrome/content/esc/ESC.js
f35d1b
--- ./esc/src/app/xul/esc/chrome/content/esc/ESC.js.fix15	2012-11-20 16:10:36.281805678 -0800
f35d1b
+++ ./esc/src/app/xul/esc/chrome/content/esc/ESC.js	2012-11-21 14:55:47.392037184 -0800
f35d1b
@@ -29,6 +29,7 @@ var gAdminPage = 0;
f35d1b
 var gFactoryMode = 0;
f35d1b
 var gHiddenPage = 0;
f35d1b
 var gExternalUI = 0;
f35d1b
+var gErrorAlready = 0;
f35d1b
 
f35d1b
 loadStringBundle();
f35d1b
 
f35d1b
@@ -116,9 +117,10 @@ jsNotify.prototype = {
f35d1b
   {
f35d1b
      //  alert("iid: " + iid); 
f35d1b
      if(!iid.equals(Components.interfaces.rhIKeyNotify) &&
f35d1b
-         !iid.equals(Components.interfaces.nsISupports))
f35d1b
+         !iid.equals(Components.interfaces.nsISupports) &&
f35d1b
+         !iid.equals(Components.interfaces.nsIClassInfo))
f35d1b
       {
f35d1b
-          //MyAlert(getBundleString("errorJsNotifyInterface"));
f35d1b
+          MyAlert(getBundleString("errorJsNotifyInterface"));
f35d1b
           throw Components.results.NS_ERROR_NO_INTERFACE;
f35d1b
       }
f35d1b
       return this;
f35d1b
@@ -885,7 +887,7 @@ function DoShowAdvancedInfo()
f35d1b
          textDump += getBundleString("noLogFileOrData");
f35d1b
     }
f35d1b
 
f35d1b
-    var wnd = window.openDialog("chrome://esc/content/advancedinfo.xul","Info","chrome,centerscreen,width=600,height=500,modal=yes",textDump);
f35d1b
+    var wnd = window.openDialog("chrome://esc/content/advancedinfo.xul","Info","chrome,centerscreen,modal=yes",textDump);
f35d1b
 
f35d1b
 }
f35d1b
 
f35d1b
@@ -1279,7 +1281,8 @@ function DoShowFullEnrollmentUI()
f35d1b
    }
f35d1b
    else
f35d1b
    {
f35d1b
-       UpdateEnrollmentArea(keyType,keyID,keyInserted,showFullUI);
f35d1b
+     MyAlert(getBundleString("errorPhoneHomeInfo"));
f35d1b
+     window.close();
f35d1b
    }
f35d1b
 }
f35d1b
 
f35d1b
@@ -1424,7 +1427,7 @@ function UpdateEnrollmentArea(keyType,ke
f35d1b
                  HideItem(yes_key_area);
f35d1b
                  HideItem(enroll_key_message);
f35d1b
                  HideItem(enrollBtn);
f35d1b
-                 UpdateESCSize(ESC_ENROLL_WIDTH,ESC_ENROLL_HEIGHT);
f35d1b
+                 UpdateESCSize();
f35d1b
              }
f35d1b
          }
f35d1b
          else
f35d1b
@@ -1453,7 +1456,7 @@ function UpdateEnrollmentArea(keyType,ke
f35d1b
 
f35d1b
     if(!alreadyEnrolled  && inserted && showExternalUI)
f35d1b
      {
f35d1b
-         UpdateESCSize(ESC_ENROLL_WIDTH,ESC_ENROLL_HEIGHT);
f35d1b
+         UpdateESCSize();
f35d1b
          return;
f35d1b
      }
f35d1b
 
f35d1b
@@ -1792,9 +1795,73 @@ function InitializeEnrollment()
f35d1b
   UpdateCoolKeyAvailabilityForEnrollment();
f35d1b
 }
f35d1b
 
f35d1b
+function AdminKeyPressHandler(evt)
f35d1b
+{
f35d1b
+  var newitem = null;
f35d1b
+  var olditem = null;
f35d1b
+  var offset  = 0;
f35d1b
+  var selectedIndex = 0;
f35d1b
+
f35d1b
+  var list = document.getElementById("AdminBindingList");
f35d1b
+  if(!list)
f35d1b
+    return;
f35d1b
+
f35d1b
+  var numRows = list.getRowCount();
f35d1b
+  if(numRows == 0)
f35d1b
+  {
f35d1b
+      return;
f35d1b
+  }
f35d1b
+  list.selectItem(gCurrentSelectedRow);
f35d1b
+  selectedIndex = list.selectedIndex;
f35d1b
+
f35d1b
+  if(selectedIndex == -1)
f35d1b
+  {
f35d1b
+    olditem = list.getItemAtIndex(0);
f35d1b
+    if(olditem) {
f35d1b
+      list.selectItem(olditem);
f35d1b
+      olditem.click();
f35d1b
+    }
f35d1b
+  }
f35d1b
+  selectedIndex = list.selectedIndex;
f35d1b
+  olditem = list.getItemAtIndex(selectedIndex);
f35d1b
+
f35d1b
+  if(evt.keyCode == KeyEvent.DOM_VK_UP) {
f35d1b
+   offset = -1;
f35d1b
+  }
f35d1b
+  if(evt.keyCode == KeyEvent.DOM_VK_DOWN) {
f35d1b
+    offset = 1;
f35d1b
+  }
f35d1b
+
f35d1b
+  if(offset == 0)
f35d1b
+    return;
f35d1b
+
f35d1b
+  if(olditem)  {
f35d1b
+      list.moveByOffset( offset , 1, 0);
f35d1b
+      newitem = list.getItemAtIndex(list.selectedIndex);
f35d1b
+      olditem.blur();
f35d1b
+      if(newitem)
f35d1b
+        newitem.click();
f35d1b
+  }
f35d1b
+
f35d1b
+  var item = null;
f35d1b
+  for( i = 0; i < list.getRowCount(); i ++) {
f35d1b
+      item = list.getItemAtIndex(i);
f35d1b
+
f35d1b
+      if(item && item != gCurrentSelectedRow) {
f35d1b
+          item.setAttribute("class","UnSelectedRow");
f35d1b
+      }
f35d1b
+  }
f35d1b
+}
f35d1b
+
f35d1b
 function InitializeAdminBindingList()
f35d1b
 {
f35d1b
 
f35d1b
+ var list = document.getElementById("AdminBindingList");
f35d1b
+
f35d1b
+ if(list) {
f35d1b
+   list.addEventListener("keypress", AdminKeyPressHandler, false);
f35d1b
+ }
f35d1b
+
f35d1b
  gAdminPage = 1;
f35d1b
 
f35d1b
  UpdateAdminBindingListAvailability();
f35d1b
@@ -1802,8 +1869,7 @@ function InitializeAdminBindingList()
f35d1b
  DoSetEnrolledBrowserLaunchState(); 
f35d1b
  DoHandleEnrolledBrowserLaunch();
f35d1b
 
f35d1b
- window.setTimeout('ShowWindow()',250);
f35d1b
-
f35d1b
+ list.focus();
f35d1b
 }
f35d1b
 
f35d1b
 //Window related functions
f35d1b
@@ -1974,12 +2040,18 @@ function SelectESCPage(keyType,keyID,pho
f35d1b
    var enrollWnd = IsPageWindowPresent(ENROLL_WINDOW);
f35d1b
    var adminWnd  = IsPageWindowPresent(ADMIN_WINDOW);
f35d1b
 
f35d1b
-   if(keyUninitialized == UNINITIALIZED && !phoneHomeFailed )  //formatted uninitialized card
f35d1b
+   var arr = GetAvailableCoolKeys();
f35d1b
+   var no_launch_external_ui = 0;
f35d1b
+
f35d1b
+    if (arr && arr.length > 1)
f35d1b
+        no_launch_external_ui = 1;
f35d1b
+
f35d1b
+
f35d1b
+   if(keyUninitialized == UNINITIALIZED && !phoneHomeFailed && !no_launch_external_ui )  //formatted uninitialized card
f35d1b
    {
f35d1b
        if(enrollWnd)   //Enrollment window is  already up
f35d1b
        {
f35d1b
           enrollWnd.focus();
f35d1b
-          enrollWnd.ShowWindow();
f35d1b
        }
f35d1b
        else
f35d1b
        {
f35d1b
@@ -2332,12 +2404,14 @@ function UpdateAdminKeyDetailsArea(keyTy
f35d1b
        }
f35d1b
        else
f35d1b
        {
f35d1b
+           DisableItem(enrollbtn);
f35d1b
            DisableItem(resetpinbtn);
f35d1b
            DisableItem(formatbtn);
f35d1b
            if(adminkeymenu)
f35d1b
            {
f35d1b
                DisableItem(menu_format);
f35d1b
                DisableItem(menu_resetpassword);
f35d1b
+               DisableItem(menu_enroll);
f35d1b
            }
f35d1b
        }
f35d1b
 
f35d1b
@@ -2762,6 +2836,7 @@ function DoEnrollCoolKey()
f35d1b
   var tokencode = null;
f35d1b
   
f35d1b
   var failed = 0;
f35d1b
+  gErrorAlready = 0;
f35d1b
 
f35d1b
   if (type == "userKey")
f35d1b
   {
f35d1b
@@ -2792,12 +2867,13 @@ function DoEnrollCoolKey()
f35d1b
   {
f35d1b
      UpdateAdminListRow(keyType,keyID);
f35d1b
      UpdateAdminKeyDetailsArea(keyType,keyID);
f35d1b
-     if(!failed)
f35d1b
+     if(!failed && !gErrorAlready)
f35d1b
      {
f35d1b
           AdminToggleStatusProgress(1,keyType,keyID);
f35d1b
           UpdateAdminKeyAreaDetailsLabel(getBundleString("enrollingToken"));
f35d1b
      }
f35d1b
   }
f35d1b
+  gErrorAlready = 0;
f35d1b
 }
f35d1b
 
f35d1b
 function DoCollectPassword(operation)
f35d1b
@@ -2822,6 +2898,7 @@ function DoResetSelectedCoolKeyPIN()
f35d1b
   var screennamepwd = null;
f35d1b
 
f35d1b
   var failed = 0;
f35d1b
+  gErrorAlready = 0;
f35d1b
 
f35d1b
   if (GetCoolKeyIsEnrolled(keyType, keyID))
f35d1b
   {
f35d1b
@@ -2843,12 +2920,13 @@ function DoResetSelectedCoolKeyPIN()
f35d1b
      UpdateAdminListRow(keyType,keyID);
f35d1b
      UpdateAdminKeyDetailsArea(keyType,keyID);
f35d1b
 
f35d1b
-      if(!failed)
f35d1b
+      if(!failed && !gErrorAlready)
f35d1b
       {
f35d1b
           AdminToggleStatusProgress(1,keyType,keyID);
f35d1b
           UpdateAdminKeyAreaDetailsLabel(getBundleString("resettingTokenPIN"));
f35d1b
       }
f35d1b
   }
f35d1b
+  gErrorAlready = 0;
f35d1b
 }
f35d1b
 
f35d1b
 function DoFormatCoolKey(type)
f35d1b
@@ -2865,6 +2943,7 @@ function DoFormatCoolKey(type)
f35d1b
   var failed = 0;
f35d1b
   var globalType = GetCachedTokenType(keyID);
f35d1b
 
f35d1b
+  gErrorAlready = 0;
f35d1b
   if(!type)
f35d1b
       lType = gKeyEnrollmentType;
f35d1b
   else
f35d1b
@@ -2890,12 +2969,13 @@ function DoFormatCoolKey(type)
f35d1b
   {
f35d1b
       UpdateAdminListRow(keyType,keyID);
f35d1b
       UpdateAdminKeyDetailsArea(keyType,keyID);
f35d1b
-      if(!failed)
f35d1b
+      if(!failed && !gErrorAlready)
f35d1b
       {
f35d1b
           AdminToggleStatusProgress(1,keyType,keyID);
f35d1b
           UpdateAdminKeyAreaDetailsLabel(getBundleString("formatingToken"));
f35d1b
       }
f35d1b
   }
f35d1b
+  gErrorAlready = 0;
f35d1b
 }
f35d1b
 function DoCancelOperation()
f35d1b
 {
f35d1b
@@ -3156,6 +3236,7 @@ function OnCoolKeyStateError(keyType, ke
f35d1b
      AdminToggleStatusProgress(0,keyType,keyID);
f35d1b
    }
f35d1b
 
f35d1b
+  gErrorAlready = 1;
f35d1b
   if(!CheckForSecurityMode())
f35d1b
       MyAlert(typeStr);
f35d1b
   ClearProgressBar(KeyToProgressBarID(keyType, keyID));
f35d1b
@@ -3261,9 +3342,73 @@ function refresh()
f35d1b
   window.resizeBy(0,-1);
f35d1b
 }
f35d1b
 
f35d1b
+//nsIWebProgressListener to oversee the loading of the external UI
f35d1b
+var uiListener = null;
f35d1b
+var esc_enroll_uri = null;
f35d1b
+
f35d1b
+const STATE_START = Components.interfaces.nsIWebProgressListener.STATE_START;
f35d1b
+const STATE_STOP = Components.interfaces.nsIWebProgressListener.STATE_STOP;
f35d1b
+const STATE_IS_DOCUMENT = Components.interfaces.nsIWebProgressListener.STATE_IS_DOCUMENT;
f35d1b
+uiListener =
f35d1b
+{
f35d1b
+    QueryInterface: function(aIID)
f35d1b
+    {
f35d1b
+        if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
f35d1b
+         aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
f35d1b
+         aIID.equals(Components.interfaces.nsISupports))
f35d1b
+         return this;
f35d1b
+         throw Components.results.NS_NOINTERFACE;
f35d1b
+    },
f35d1b
+
f35d1b
+    onStateChange: function(aWebProgress, aRequest, aFlag, aStatus)
f35d1b
+    {
f35d1b
+        if(aFlag & STATE_START && aFlag & STATE_IS_DOCUMENT)
f35d1b
+        {
f35d1b
+        }
f35d1b
+        if(aFlag & STATE_STOP && aFlag & STATE_IS_DOCUMENT)
f35d1b
+        {
f35d1b
+
f35d1b
+            var url = aWebProgress.DOMWindow.document.URL;
f35d1b
+
f35d1b
+            if(url != esc_enroll_uri)
f35d1b
+            {
f35d1b
+                MyAlert(getBundleString("errorEnrollmentUI"));
f35d1b
+
f35d1b
+                if(uiListener)
f35d1b
+                    aWebProgress.removeProgressListener(uiListener);
f35d1b
+
f35d1b
+                var enrollWnd = IsPageWindowPresent(ENROLL_WINDOW);
f35d1b
+
f35d1b
+                if(enrollWnd)
f35d1b
+                {
f35d1b
+                    enrollWnd.close();
f35d1b
+                }
f35d1b
+            }
f35d1b
+            else
f35d1b
+            {
f35d1b
+                if(uiListener)
f35d1b
+                    aWebProgress.removeProgressListener(uiListener);
f35d1b
+            }
f35d1b
+        }
f35d1b
+    },
f35d1b
+
f35d1b
+    onLocationChange: function(aProgress, aRequest, aURI)
f35d1b
+    {
f35d1b
+    },
f35d1b
+    onProgressChange: function(aWebProgress, aRequest, curSelf, maxSelf, curTot, maxTot)
f35d1b
+    {
f35d1b
+    },
f35d1b
+    onStatusChange: function(aWebProgress, aRequest, aStatus, aMessage)
f35d1b
+    {
f35d1b
+    },
f35d1b
+    onSecurityChange: function(aWebProgress, aRequest, aState)
f35d1b
+    {
f35d1b
+    }
f35d1b
+}
f35d1b
+
f35d1b
 function loadExternalESCUI()
f35d1b
 {
f35d1b
-   var esc_enroll_uri = null;
f35d1b
+    esc_enroll_uri = null;
f35d1b
 
f35d1b
     var keyType= null;
f35d1b
     var keyID = null;
f35d1b
@@ -3324,6 +3469,7 @@ function loadExternalESCUI()
f35d1b
         if(ui_id)
f35d1b
         {
f35d1b
             ui_id.setAttribute("src",esc_enroll_uri);
f35d1b
+            ///ui_id.addProgressListener(uiListener,Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
f35d1b
             UpdateEnrollmentArea(keyType,keyID,inserted,showFullUI,showExternalUI)
f35d1b
         }
f35d1b
 
f35d1b
diff -up ./esc/src/app/xul/esc/chrome/content/esc/esc.xul.fix15 ./esc/src/app/xul/esc/chrome/content/esc/esc.xul
f35d1b
--- ./esc/src/app/xul/esc/chrome/content/esc/esc.xul.fix15	2012-11-21 11:14:42.545118881 -0800
f35d1b
+++ ./esc/src/app/xul/esc/chrome/content/esc/esc.xul	2012-11-21 11:16:21.542042804 -0800
f35d1b
@@ -147,7 +147,8 @@
f35d1b
       </hbox>
f35d1b
   </vbox>
f35d1b
 
f35d1b
-  <iframe id="esc-ui"  flex="1" class="BorderedIFrame" hidden="true"/>
f35d1b
+  <browser id="esc-ui" class="BorderedBrowser" height="725" flex="1" hidden="true" src="" />
f35d1b
+
f35d1b
   </groupbox>
f35d1b
   <hbox id = "enrollment_button_box">
f35d1b
         <spacer flex = "4"/>
f35d1b
diff -up ./esc/src/app/xul/esc/chrome/content/esc/password.js.fix15 ./esc/src/app/xul/esc/chrome/content/esc/password.js
f35d1b
--- ./esc/src/app/xul/esc/chrome/content/esc/password.js.fix15	2012-11-21 11:16:28.740186184 -0800
f35d1b
+++ ./esc/src/app/xul/esc/chrome/content/esc/password.js	2012-11-21 11:18:32.722686536 -0800
f35d1b
@@ -42,6 +42,21 @@ function doOperation()
f35d1b
    window.close(); 
f35d1b
 }
f35d1b
 
f35d1b
+//
f35d1b
+// unregister out notify event
f35d1b
+//
f35d1b
+function cleanup()
f35d1b
+{
f35d1b
+    TrayRemoveWindow(null);
f35d1b
+    try {
f35d1b
+      netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
f35d1b
+      netkey.rhCoolKeyUnSetNotifyCallback(gNotify);
f35d1b
+    } catch(e) {
f35d1b
+     MyAlert(getBundleString("errorUniversalXPConnect")  + e);
f35d1b
+    }
f35d1b
+
f35d1b
+}
f35d1b
+
f35d1b
 
f35d1b
 function GetLocalPINValue()
f35d1b
 {
f35d1b
diff -up ./esc/src/app/xul/esc/chrome/content/esc/password.xul.fix15 ./esc/src/app/xul/esc/chrome/content/esc/password.xul
f35d1b
diff -up ./esc/src/app/xul/esc/chrome/content/esc/security.xul.fix15 ./esc/src/app/xul/esc/chrome/content/esc/security.xul
f35d1b
--- ./esc/src/app/xul/esc/chrome/content/esc/security.xul.fix15	2012-11-21 14:52:14.192045524 -0800
f35d1b
+++ ./esc/src/app/xul/esc/chrome/content/esc/security.xul	2012-11-21 14:52:57.839863826 -0800
f35d1b
@@ -26,6 +26,7 @@
f35d1b
     onload="InitializeSecurityEnrollment()"
f35d1b
     width ="600"
f35d1b
     height= "575"
f35d1b
+    persist="width height"
f35d1b
     onunload="cleanup();OnSecurityPageHidden();"
f35d1b
     xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
f35d1b
 
f35d1b
diff -up ./esc/src/app/xul/esc/chrome/content/esc/settings.xul.fix15 ./esc/src/app/xul/esc/chrome/content/esc/settings.xul
f35d1b
--- ./esc/src/app/xul/esc/chrome/content/esc/settings.xul.fix15	2012-11-21 14:53:16.829219643 -0800
f35d1b
+++ ./esc/src/app/xul/esc/chrome/content/esc/settings.xul	2012-11-21 14:53:42.456699662 -0800
f35d1b
@@ -28,6 +28,7 @@
f35d1b
     width ="720"
f35d1b
     height= "415"
f35d1b
     name="admin"
f35d1b
+    persist="width height"
f35d1b
     xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
f35d1b
 
f35d1b
      <stringbundle id="esc_strings" src="chrome://esc/locale/esc.properties"/>
f35d1b
diff -up ./esc/src/app/xul/esc/chrome/content/esc/TRAY.js.fix15 ./esc/src/app/xul/esc/chrome/content/esc/TRAY.js
f35d1b
--- ./esc/src/app/xul/esc/chrome/content/esc/TRAY.js.fix15	2012-11-21 14:54:00.574038897 -0800
f35d1b
+++ ./esc/src/app/xul/esc/chrome/content/esc/TRAY.js	2012-11-21 14:58:29.722107000 -0800
f35d1b
@@ -47,9 +47,10 @@ jsWindNotify.prototype = {
f35d1b
   {
f35d1b
      //alert("iid: " + iid);
f35d1b
      if(!iid.equals(Components.interfaces.rhITrayWindNotify) &&
f35d1b
-         !iid.equals(Components.interfaces.nsISupports))
f35d1b
+         !iid.equals(Components.interfaces.nsISupports) &&
f35d1b
+         !iid.equals(Components.interfaces.nsIClassInfo)
f35d1b
       {
f35d1b
-          //MyAlert(getBundleString("errorJsNotifyInterface"));
f35d1b
+          MyAlert(getBundleString("errorJsNotifyInterface"));
f35d1b
           throw Components.results.NS_ERROR_NO_INTERFACE;
f35d1b
       }
f35d1b
       return this;
f35d1b
@@ -423,6 +424,13 @@ alert("exception " + e);
f35d1b
    }
f35d1b
 }
f35d1b
 
f35d1b
+//Cleanup this window if ESC.js doesn't do it
f35d1b
+function traycleanup()
f35d1b
+{
f35d1b
+    TrayRemoveWindow(null);
f35d1b
+}
f35d1b
+
f35d1b
+
f35d1b
 //String bundling related functions
f35d1b
 
f35d1b
 function loadStringBundle()
f35d1b
diff -up ./esc/src/app/xul/esc/chrome/locale/en-US/esc.properties.fix15 ./esc/src/app/xul/esc/chrome/locale/en-US/esc.properties
f35d1b
--- ./esc/src/app/xul/esc/chrome/locale/en-US/esc.properties.fix15	2012-11-21 11:21:31.426280759 -0800
f35d1b
+++ ./esc/src/app/xul/esc/chrome/locale/en-US/esc.properties	2012-11-21 11:22:33.427512763 -0800
f35d1b
@@ -176,6 +176,8 @@ errorSelectKey=Please select a smart car
f35d1b
 errorEnrolledFirst=Smart card must be enrolled first! Enroll card and try again.
f35d1b
 enrollmentFor=Enrollment of your 
f35d1b
 errorNeedKeyForSecMode=Please insert enrolled smart card before attempting secure mode.
f35d1b
+errorEnrollmentUI=Problem loading Enrollment UI, check your network connection, re-insert the card, and try again!
f35d1b
+errorPhoneHomeInfo=Problem loading Phone Home Information, check your network connection, re-insert the card, and try again!
f35d1b
 wasSuccessful=was successful.
f35d1b
 pinResetSuccessful=Password Reset was successfull!
f35d1b
 formatOf=Format of
f35d1b
diff -up ./esc/src/lib/coolkey/CoolKey.cpp.fix15 ./esc/src/lib/coolkey/CoolKey.cpp
f35d1b
--- ./esc/src/lib/coolkey/CoolKey.cpp.fix15	2012-11-21 14:58:53.164558727 -0800
f35d1b
+++ ./esc/src/lib/coolkey/CoolKey.cpp	2012-11-21 15:02:47.425039628 -0800
f35d1b
@@ -1412,7 +1412,7 @@ char *GetTStamp(char *aTime,int aSize)
f35d1b
     if(aSize < maxSize)
f35d1b
         return NULL;
f35d1b
 
f35d1b
-    char *tFormat = "[%c]";
f35d1b
+    char *tFormat = (char *) "[%c]";
f35d1b
     time_t tm = time(NULL);
f35d1b
     struct tm *ptr = localtime(&tm;;
f35d1b
     strftime(aTime ,maxSize ,tFormat,ptr);
f35d1b
diff -up ./esc/src/lib/coolkey/CoolKeyHandler.cpp.fix15 ./esc/src/lib/coolkey/CoolKeyHandler.cpp
f35d1b
--- ./esc/src/lib/coolkey/CoolKeyHandler.cpp.fix15	2012-11-21 15:03:00.069280046 -0800
f35d1b
+++ ./esc/src/lib/coolkey/CoolKeyHandler.cpp	2012-11-21 15:04:00.118420187 -0800
f35d1b
@@ -1096,7 +1096,7 @@ HRESULT CoolKeyHandler::HttpBeginOpReque
f35d1b
 
f35d1b
     char ascii_port[50];
f35d1b
     char host_port[200];
f35d1b
-    char *method = "POST";
f35d1b
+    char *method = (char *) "POST";
f35d1b
 
f35d1b
     if(mCharScreenName && mCharScreenNamePwd)
f35d1b
     {
f35d1b
@@ -1131,7 +1131,7 @@ HRESULT CoolKeyHandler::HttpBeginOpReque
f35d1b
 
f35d1b
     string ext_buffer = "";
f35d1b
 
f35d1b
-    char *clientVer = "ESC 1.0.1";
f35d1b
+    char *clientVer = (char *) "ESC 1.0.1";
f35d1b
     sprintf(buffer,"clientVersion=%s",clientVer);
f35d1b
 
f35d1b
     ext_buffer = buffer;
f35d1b
diff -up ./esc/src/lib/coolkey/CoolKey_Message.cpp.fix15 ./esc/src/lib/coolkey/CoolKey_Message.cpp
f35d1b
--- ./esc/src/lib/coolkey/CoolKey_Message.cpp.fix15	2012-11-21 11:25:37.996165274 -0800
f35d1b
+++ ./esc/src/lib/coolkey/CoolKey_Message.cpp	2012-11-21 11:27:42.797605767 -0800
f35d1b
@@ -560,7 +560,12 @@ void eCKMessage_LOGIN_RESPONSE::encode(s
f35d1b
 
f35d1b
     string lPassword = getStringValue(pKey);
f35d1b
 
f35d1b
-    aOutputVal += sKey + delim1 + lScreenName + delim + pKey + delim1 + lPassword;
f35d1b
+    string ScreenName_encoded, Password_encoded;
f35d1b
+
f35d1b
+    URLEncode_str(lScreenName, ScreenName_encoded);
f35d1b
+    URLEncode_str(lPassword, Password_encoded);
f35d1b
+
f35d1b
+    aOutputVal += sKey + delim1 + ScreenName_encoded + delim + pKey + delim1 + Password_encoded;
f35d1b
 
f35d1b
     eCKMessage::encode(aOutputVal);
f35d1b
 }
f35d1b
diff -up ./esc/src/lib/coolkey/NSSManager.cpp.fix15 ./esc/src/lib/coolkey/NSSManager.cpp
f35d1b
--- ./esc/src/lib/coolkey/NSSManager.cpp.fix15	2012-11-21 15:04:06.329537968 -0800
f35d1b
+++ ./esc/src/lib/coolkey/NSSManager.cpp	2012-11-21 15:04:53.612433763 -0800
f35d1b
@@ -96,7 +96,7 @@ HRESULT NSSManager::InitNSS(const char *
f35d1b
         }
f35d1b
     }
f35d1b
 
f35d1b
-    char *libName = COOLKEY_PKCS11_LIBRARY ;
f35d1b
+    char *libName = (char *) COOLKEY_PKCS11_LIBRARY ;
f35d1b
 
f35d1b
     PR_LOG( coolKeyLogNSS, PR_LOG_DEBUG, ("%s InitNSS: About to try SECMOD_AddNewModule :%s \n",GetTStamp(tBuff,56),libName));
f35d1b
 
f35d1b
@@ -330,8 +330,8 @@ NSSManager::GetKeyCertNicknames( const C
f35d1b
 
f35d1b
     CERTCertNicknames *nicknames =
f35d1b
     CERT_NicknameStringsFromCertList(certs,
f35d1b
-                                     NICKNAME_EXPIRED_STRING,
f35d1b
-                                     NICKNAME_NOT_YET_VALID_STRING);
f35d1b
+                                    (char *) NICKNAME_EXPIRED_STRING,
f35d1b
+                                    (char *) NICKNAME_NOT_YET_VALID_STRING);
f35d1b
 
f35d1b
     char *curName = NULL;
f35d1b
 
f35d1b
diff -up ./esc/src/lib/coolkey/SmartCardMonitoringThread.cpp.fix15 ./esc/src/lib/coolkey/SmartCardMonitoringThread.cpp
f35d1b
--- ./esc/src/lib/coolkey/SmartCardMonitoringThread.cpp.fix15	2012-11-21 15:05:09.934742670 -0800
f35d1b
+++ ./esc/src/lib/coolkey/SmartCardMonitoringThread.cpp	2012-11-21 15:40:49.570037221 -0800
f35d1b
@@ -35,8 +35,10 @@
f35d1b
 
f35d1b
 static PRLogModuleInfo *coolKeyLogSC = PR_NewLogModule("coolKeySmart");
f35d1b
 
f35d1b
+static const PRUint32 COOLKEY_SHUTDOWN_WAIT_INTERVAL = 3;
f35d1b
+
f35d1b
 SmartCardMonitoringThread::SmartCardMonitoringThread(SECMODModule *aModule)
f35d1b
-  : mModule(aModule), mThread(NULL)
f35d1b
+  : mModule(aModule), mThread(NULL), mExitThread(NULL)
f35d1b
 {
f35d1b
     char tBuff[56];
f35d1b
     PR_LOG( coolKeyLogSC, PR_LOG_DEBUG, 
f35d1b
@@ -184,6 +186,9 @@ void SmartCardMonitoringThread::Execute(
f35d1b
 
f35d1b
     } while (1);
f35d1b
 
f35d1b
+   PR_LOG( coolKeyLogSC, PR_LOG_DEBUG,
f35d1b
+             ("%s SmartCardMonitoringThread::Execute Leaving thread : \n",GetTStamp(tBuff,56)));
f35d1b
+
f35d1b
 }
f35d1b
 
f35d1b
 void SmartCardMonitoringThread::Interrupt()
f35d1b
@@ -195,6 +200,14 @@ void SmartCardMonitoringThread::Interrup
f35d1b
     if(mThread)
f35d1b
     {
f35d1b
         SECStatus rv;
f35d1b
+
f35d1b
+        if (!mExitThread) {
f35d1b
+            mExitThread = PR_CreateThread(PR_SYSTEM_THREAD, ExitTimeout, this,
f35d1b
+                              PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,
f35d1b
+                              PR_JOINABLE_THREAD, 0);
f35d1b
+        }
f35d1b
+
f35d1b
+
f35d1b
         rv = SECMOD_CancelWait(mModule);
f35d1b
         if (rv !=SECSuccess) {
f35d1b
             PR_LOG( coolKeyLogSC, PR_LOG_DEBUG, 
f35d1b
@@ -255,3 +268,28 @@ void SmartCardMonitoringThread::LaunchEx
f35d1b
 {
f35d1b
     ((SmartCardMonitoringThread*)arg)->Execute();
f35d1b
 }
f35d1b
+
f35d1b
+void SmartCardMonitoringThread::ExitTimeout(void *arg)
f35d1b
+{
f35d1b
+  char tBuff[56];
f35d1b
+  PR_LOG( coolKeyLogSC, PR_LOG_DEBUG,
f35d1b
+            ("%s SmartCardMonitoringThread::ExitTimeout : \n",GetTStamp(tBuff,56)));
f35d1b
+
f35d1b
+
f35d1b
+  if (arg == NULL) {
f35d1b
+     return;
f35d1b
+  }
f35d1b
+
f35d1b
+  PR_Sleep(PR_SecondsToInterval(COOLKEY_SHUTDOWN_WAIT_INTERVAL));
f35d1b
+
f35d1b
+  PR_LOG( coolKeyLogSC, PR_LOG_DEBUG,
f35d1b
+            ("%s SmartCardMonitoringThread::ExitTimeout : wait is done. \n",GetTStamp(tBuff,56)));
f35d1b
+
f35d1b
+  if(((SmartCardMonitoringThread*)arg)->mThread != NULL)  {
f35d1b
+
f35d1b
+     PR_LOG( coolKeyLogSC, PR_LOG_DEBUG,
f35d1b
+            ("%s SmartCardMonitoringThread::ExitTimeout : Timeout expired while SECMOD_Cancel is hanging, good-bye..! \n",GetTStamp(tBuff,56)));
f35d1b
+
f35d1b
+    _exit(0);
f35d1b
+  }
f35d1b
+}
f35d1b
diff -up ./esc/src/lib/coolkey/SmartCardMonitoringThread.h.fix15 ./esc/src/lib/coolkey/SmartCardMonitoringThread.h
f35d1b
--- ./esc/src/lib/coolkey/SmartCardMonitoringThread.h.fix15	2012-11-21 15:14:55.270744772 -0800
f35d1b
+++ ./esc/src/lib/coolkey/SmartCardMonitoringThread.h	2012-11-21 15:16:42.068742060 -0800
f35d1b
@@ -45,9 +45,11 @@ class SmartCardMonitoringThread
f35d1b
   void Remove(CoolKeyInfo *info);
f35d1b
 
f35d1b
   static void LaunchExecute(void *arg);
f35d1b
+  static void ExitTimeout(void *arg);
f35d1b
   
f35d1b
   SECMODModule *mModule;
f35d1b
   PRThread* mThread;
f35d1b
+  PRThread* mExitThread;
f35d1b
   char* mCurrentActivation;
f35d1b
 };
f35d1b
 
f35d1b
diff -up ./esc/src/lib/notifytray/notifytray.c.fix15 ./esc/src/lib/notifytray/notifytray.c
f35d1b
--- ./esc/src/lib/notifytray/notifytray.c.fix15	2012-11-21 15:35:54.119380073 -0800
f35d1b
+++ ./esc/src/lib/notifytray/notifytray.c	2012-11-21 15:36:57.948605760 -0800
f35d1b
@@ -218,7 +218,7 @@ void notify_icon_send_tooltip_msg(const
f35d1b
     if(!message || !notify)
f35d1b
         return;
f35d1b
 
f35d1b
-    gchar *msg_title = NULL;
f35d1b
+    const gchar *msg_title = NULL;
f35d1b
 
f35d1b
 
f35d1b
     if(!title)