From cb4a46e7fbe62d788e66ed6121c717a2d22a4d7c Mon Sep 17 00:00:00 2001 From: watcherhd Date: Thu, 21 Apr 2011 14:14:52 +0000 Subject: svn.miranda.im is moving to a new home! git-svn-id: http://miranda-plugins.googlecode.com/svn/trunk@7 e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb --- icqj_mod/log.c | 158 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 icqj_mod/log.c (limited to 'icqj_mod/log.c') diff --git a/icqj_mod/log.c b/icqj_mod/log.c new file mode 100644 index 0000000..c552cc2 --- /dev/null +++ b/icqj_mod/log.c @@ -0,0 +1,158 @@ +// ---------------------------------------------------------------------------80 +// ICQ plugin for Miranda Instant Messenger +// ________________________________________ +// +// Copyright © 2000,2001 Richard Hughes, Roland Rabien, Tristan Van de Vreede +// Copyright © 2001,2002 Jon Keating, Richard Hughes +// Copyright © 2002,2003,2004 Martin Öberg, Sam Kothari, Robert Rainwater +// Copyright © 2004,2005,2006 Joe Kucera +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// ----------------------------------------------------------------------------- +// +// File name : $Source: /cvsroot/miranda/miranda/protocols/IcqOscarJ/log.c,v $ +// Revision : $Revision: 3316 $ +// Last change on : $Date: 2006-07-12 20:26:25 +0400 (Ср, 12 июл 2006) $ +// Last change by : $Author: jokusoftware $ +// +// DESCRIPTION: +// +// Describe me here please... +// +// ----------------------------------------------------------------------------- + +#include "icqoscar.h" + + +static const char *szLevelDescr[] = {"ICQ Note", "ICQ Warning", "ICQ Error", "ICQ Fatal"}; + +typedef struct { + char *szMsg; + char *szTitle; +} LogMessageInfo; + +static BOOL bErrorVisible = FALSE; + +static void __cdecl icq_LogMessageThread(void* arg) +{ + LogMessageInfo *err = (LogMessageInfo*)arg; + + if (!err) return; + bErrorVisible = TRUE; + if (err->szMsg&&err->szTitle) + MessageBoxUtf(NULL, err->szMsg, err->szTitle, MB_OK); + SAFE_FREE(&err->szMsg); + SAFE_FREE(&err->szTitle); + SAFE_FREE(&err); + bErrorVisible = FALSE; +} + + + +void icq_LogMessage(int level, const char *szMsg) +{ + int displayLevel; + + NetLog_Server("%s", szMsg); + + displayLevel = ICQGetContactSettingByte(NULL, "ShowLogLevel", LOG_WARNING); + if (level >= displayLevel) + { + LogMessageInfo *lmi; + + if (ICQGetContactSettingByte(NULL, "PopupsLogEnabled", DEFAULT_LOG_POPUPS_ENABLED)) + { + if (!ShowPopUpMsg(NULL, szLevelDescr[level], szMsg, (BYTE)level)) + return; // Popup showed successfuly + } + if (!bErrorVisible || !ICQGetContactSettingByte(NULL, "IgnoreMultiErrorBox", 0)) + { // error not shown or allowed multi - show messagebox + lmi = (LogMessageInfo*)SAFE_MALLOC(sizeof(LogMessageInfo)); + lmi->szMsg = ICQTranslateUtf(szMsg); + lmi->szTitle = ICQTranslateUtf(szLevelDescr[level]); + forkthread(icq_LogMessageThread, 0, lmi); + } + } +} + + + +void icq_LogUsingErrorCode(int level, DWORD dwError, const char *szMsg) +{ + char szBuf[1024]; + char str[1024]; + char str2[64]; + char szErrorMsg[256]; + char* pszErrorMsg; + char* pszErrorMsgUtf = NULL; + + + switch(dwError) + { + case ERROR_TIMEOUT: + case WSAETIMEDOUT: + pszErrorMsg = "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 = "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 = "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 = "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 = "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 = "The server to which you are trying to connect does not exist. Check your spelling in M->Options->Network->ICQ."; + break; + + default: + if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwError, 0, szErrorMsg, sizeof(szErrorMsg), NULL)) + pszErrorMsg = szErrorMsg; + else + pszErrorMsg = ""; + break; + } + utf8_encode(pszErrorMsg, &pszErrorMsgUtf); + + null_snprintf(szBuf, sizeof(szBuf), "%s%s%s (%s %d)", szMsg?ICQTranslateUtfStatic(szMsg, str):"", szMsg?"\r\n\r\n":"", pszErrorMsgUtf, ICQTranslateUtfStatic("error", str2), dwError); + icq_LogMessage(level, szBuf); + + SAFE_FREE(&pszErrorMsgUtf); +} + + + +void icq_LogFatalParam(const char* szMsg, WORD wError) +{ + char str[MAX_PATH]; + char buf[MAX_PATH]; + + null_snprintf(buf, MAX_PATH, ICQTranslateUtfStatic(szMsg, str), wError); + icq_LogMessage(LOG_FATAL, buf); +} -- cgit v1.2.3