OpenSIP();
{ if (popupConditions == PR_FALSE) OpenSIP(); }
nsSoftKeyBoard::HandleEvent(nsIDOMEvent* aEvent){  if (!aEvent)    return NS_OK;  nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aEvent));  nsCOMPtr<nsIDOMEventTarget> target;  nsevent->GetOriginalTarget(getter_AddRefs(target));  nsCOMPtr<nsIContent> targetContent = do_QueryInterface(target);  if (!targetContent || !targetContent->IsContentOfType(nsIContent::eHTML_FORM_CONTROL))    return NS_OK;  nsCOMPtr<nsIFormControl> formControl(do_QueryInterface(targetContent));  if (!formControl)    return NS_OK;  PRInt32 controlType = formControl->GetType();        if (controlType != NS_FORM_TEXTAREA       &&  controlType != NS_FORM_INPUT_TEXT &&      controlType != NS_FORM_INPUT_PASSWORD &&  controlType != NS_FORM_INPUT_FILE)   {    return NS_OK;  }  nsAutoString eventType;  aEvent->GetType(eventType);    if (eventType.EqualsLiteral("keypress"))  {    PRUint32 keyCode;    nsCOMPtr<nsIDOMKeyEvent> keyEvent(do_QueryInterface(aEvent));        if (!keyEvent)      return NS_OK;        if (NS_FAILED(keyEvent->GetKeyCode(&keyCode)))      return NS_OK;        if (keyCode == nsIDOMKeyEvent::DOM_VK_RETURN && controlType != NS_FORM_TEXTAREA)    {      CloseSIP();    }#ifdef WINCE    if (IsSmartphone())    {      PRUint32 charCode;      keyEvent->GetCharCode(&charCode);#if 0      char buffer[2];      sprintf(buffer, "%d = %d", keyCode, charCode);      MessageBox(0, buffer, buffer, 0);#endif           /* value determined by inspection */      if (keyCode == 120)      {        // We're using this key, no one else should        aEvent->StopPropagation();        aEvent->PreventDefault();        if (mTimer)          mTimer->Cancel();         keybd_event(VK_SPACE, 0, 0, 0);        keybd_event(VK_SPACE, 0, KEYEVENTF_KEYUP, 0);        return NS_OK;      }      /* value determined by inspection */      if (keyCode == 119)      {        // We're using this key, no one else should        aEvent->StopPropagation();        aEvent->PreventDefault();        if (mTimer)          mTimer->Cancel();                 mUsage++;        if (mUsage>eUpperCase)           mUsage=eNumbers;        return NS_OK;      }      if (mUsage == eNumbers)        return NS_OK;      if ( charCode > nsIDOMKeyEvent::DOM_VK_0 && charCode <= nsIDOMKeyEvent::DOM_VK_9) // [0-9)      {        // We're using this key, no one else should        aEvent->StopPropagation();        aEvent->PreventDefault();        if (mTimer)          mTimer->Cancel();                if (mCurrentDigit != charCode)        {          mCurrentDigit = charCode;          mCurrentDigitCount = 1;        }        else        {          mCurrentDigitCount++;        }        mTimer = do_CreateInstance("@mozilla.org/timer;1");        if (!mTimer)          return NS_OK;        BYTE key = GetKeyPress(mCurrentDigit, mCurrentDigitCount);        if (mUsage == eUpperCase)          key = _toupper(key);        PRUint32 closure = key;                mTimer->InitWithFuncCallback(SoftKeyboardTimerCB,                                     (void*)closure,                                     700,                                      nsITimer::TYPE_ONE_SHOT);        return NS_OK;      }      else      {        mCurrentDigit = 0;        mCurrentDigitCount = 0;      }          }#endif    return NS_OK;  }  if (eventType.EqualsLiteral("focus"))    OpenSIP();  else    CloseSIP();    return NS_OK;}