Ejemplo n.º 1
0
void CIcqProto::icq_LogUsingErrorCode(int level, DWORD dwError, const char *szMsg)
{
	char szBuf[1024];
	char str[1024];
	char str2[64];
	char szErrorMsg[512];
	char *pszErrorMsg = NULL;
	int bNeedFree = FALSE;

	switch(dwError) {
	case ERROR_TIMEOUT:
	case WSAETIMEDOUT:
		pszErrorMsg = LPGEN("The server did not respond to the connection attempt within a reasonable time, it may be temporarily down. Try again later.");
		break;

	case ERROR_GEN_FAILURE:
		pszErrorMsg = LPGEN("The connection with the server was abortively closed during the connection attempt. You may have lost your local network connection.");
		break;

	case WSAEHOSTUNREACH:
	case WSAENETUNREACH:
		pszErrorMsg = LPGEN("Miranda was unable to resolve the name of a server to its numeric address. This is most likely caused by a catastrophic loss of your network connection (for example, your modem has disconnected), but if you are behind a proxy, you may need to use the 'Resolve hostnames through proxy' option in M->Options->Network.");
		break;

	case WSAEHOSTDOWN:
	case WSAENETDOWN:
	case WSAECONNREFUSED:
		pszErrorMsg = LPGEN("Miranda was unable to make a connection with a server. It is likely that the server is down, in which case you should wait for a while and try again later.");
		break;

	case ERROR_ACCESS_DENIED:
		pszErrorMsg = LPGEN("Your proxy rejected the user name and password that you provided. Please check them in M->Options->Network.");
		break;

	case WSAHOST_NOT_FOUND:
	case WSANO_DATA:
		pszErrorMsg = LPGEN("The server to which you are trying to connect does not exist. Check your spelling in M->Options->Network->ICQ.");
		break;

	default:
		{
			TCHAR err[512];

			if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwError, 0, err, SIZEOF(err), NULL))
			{
#if defined( _UNICODE )
        pszErrorMsg = make_utf8_string(err);
#else
				utf8_encode(err, &pszErrorMsg);
#endif
				bNeedFree = TRUE;
			}
			break;
		}
	}

	null_snprintf(szBuf, sizeof(szBuf), "%s%s%s (%s %d)", 
		szMsg ? ICQTranslateUtfStatic(szMsg, str, 1024) : "", 
		szMsg ? "\r\n\r\n" : "",
		ICQTranslateUtfStatic(pszErrorMsg, szErrorMsg, 512), 
		ICQTranslateUtfStatic(LPGEN("error"), str2, 64),
		dwError);

	if (bNeedFree)
		SAFE_FREE(&pszErrorMsg);

	icq_LogMessage(level, szBuf);
}
Ejemplo n.º 2
0
void ChangeInfoData::BeginListEdit(int iItem, RECT *rc, int iSetting, WORD wVKey)
{
  int j,n;
  POINT pt;
  int itemHeight;
  char str[MAX_PATH];

  if (dataListEdit)
    dataListEdit->EndListEdit(0);

  pt.x=pt.y=0;
  ClientToScreen(hwndList,&pt);
  OffsetRect(rc,pt.x,pt.y);
  InflateRect(rc,-2,-2);
  rc->left-=2;
  iEditItem = iItem;
  ListView_RedrawItems(hwndList, iEditItem, iEditItem);
  UpdateWindow(hwndList);

  dataListEdit = this;
  hwndListEdit = CreateWindowEx(WS_EX_TOOLWINDOW|WS_EX_TOPMOST, _T("LISTBOX"), _T(""), WS_POPUP|WS_BORDER|WS_VSCROLL, rc->left, rc->bottom, rc->right - rc->left, 150, NULL, NULL, hInst, NULL);
  SendMessage(hwndListEdit, WM_SETFONT, (WPARAM)hListFont, 0);
  itemHeight = SendMessage(hwndListEdit, LB_GETITEMHEIGHT, 0, 0);

  FieldNamesItem *list = (FieldNamesItem*)setting[iSetting].pList;

  if (list == countryField)
  { // some country codes were changed leaving old details uknown, convert it for the user
    if (settingData[iSetting].value == 420) settingData[iSetting].value = 42; // conversion of obsolete codes (OMG!)
    else if (settingData[iSetting].value == 421) settingData[iSetting].value = 4201;
    else if (settingData[iSetting].value == 102) settingData[iSetting].value = 1201;
  }

  n = ListBoxAddStringUtf(hwndListEdit, "Unspecified");
  for (j=0; ; j++)
    if (!list[j].text)
    {
      SendMessage(hwndListEdit, LB_SETITEMDATA, n, j);
      if ((settingData[iSetting].value == 0 && list[j].code == 0)
       || (setting[iSetting].dbType != DBVT_ASCIIZ && settingData[iSetting].value == list[j].code))
        SendMessage(hwndListEdit, LB_SETCURSEL, n, 0);
      break;
    }

  for (j=0; list[j].text; j++) 
  {
    n = ListBoxAddStringUtf(hwndListEdit, list[j].text);
    SendMessage(hwndListEdit, LB_SETITEMDATA, n, j);
    if ((setting[iSetting].dbType == DBVT_ASCIIZ && (!strcmpnull((char*)settingData[iSetting].value, list[j].text))
     || (setting[iSetting].dbType == DBVT_ASCIIZ && (!strcmpnull((char*)settingData[iSetting].value, ICQTranslateUtfStatic(list[j].text, str, MAX_PATH))))
     || ((char*)settingData[iSetting].value == NULL && list[j].code == 0))
     || (setting[iSetting].dbType != DBVT_ASCIIZ && settingData[iSetting].value == list[j].code))
      SendMessage(hwndListEdit, LB_SETCURSEL, n, 0);
  }
  SendMessage(hwndListEdit, LB_SETTOPINDEX, SendMessage(hwndListEdit, LB_GETCURSEL, 0, 0) - 3, 0);
  int listCount = SendMessage(hwndListEdit, LB_GETCOUNT, 0, 0);
  if (itemHeight * listCount < 150)
    SetWindowPos(hwndListEdit, 0, 0, 0, rc->right - rc->left, itemHeight * listCount + GetSystemMetrics(SM_CYBORDER) * 2, SWP_NOZORDER|SWP_NOMOVE);
  OldListEditProc = (WNDPROC)SetWindowLongPtr(hwndListEdit, GWLP_WNDPROC, (LONG_PTR)ListEditSubclassProc);
  if (MyAnimateWindow = (BOOL (WINAPI*)(HWND,DWORD,DWORD))GetProcAddress(GetModuleHandleA("user32"), "AnimateWindow")) 
  {
    BOOL enabled;

    SystemParametersInfo(SPI_GETCOMBOBOXANIMATION, 0, &enabled, FALSE);
    if (enabled) MyAnimateWindow(hwndListEdit, 200, AW_SLIDE|AW_ACTIVATE|AW_VER_POSITIVE);
  }
  ShowWindow(hwndListEdit, SW_SHOW);
  SetFocus(hwndListEdit);
  if (wVKey)
    PostMessage(hwndListEdit, WM_KEYDOWN, wVKey, 0);
}