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