-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I've made a patch to support translation of main source messages (at this moment only the daemon and main licq program changes are made)
This is made using GNU gettext to translate. []'s - -- Gustavo Pichorim Boiko ---------------------------------------- Debian GNU/Linux - sid - Kernel 2.4.20 Linux User: 231003 ICQ (Licq): 86128708 Computer Science - UFPR ---------------------------------------- [EMAIL PROTECTED] [EMAIL PROTECTED] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) iD8DBQE/Bg7uZQYlDr5VjykRAsiAAJ9uO2AoWxSz39LeHjedk7MLOwP1KQCgivrv 7umRrIz7TciPg0QiGkXYEPI= =QG7y -----END PGP SIGNATURE-----
Index: icqd-tcp.cpp =================================================================== RCS file: /cvsroot/licq/licq/src/icqd-tcp.cpp,v retrieving revision 1.58 diff -u -r1.58 icqd-tcp.cpp --- icqd-tcp.cpp 2 Jul 2003 04:41:01 -0000 1.58 +++ icqd-tcp.cpp 4 Jul 2003 11:59:31 -0000 @@ -16,6 +16,10 @@ #include <unistd.h> #include <errno.h> +//This is to gettext +#include <libintl.h> +#define tr(String) gettext(String) + #include "time-fix.h" #include "licq_icqd.h" @@ -73,7 +77,7 @@ e = new CEventMsg(m, ICQ_CMDxSND_THRUxSERVER, TIME_NOW, f); if (strlen(mDos) > MAX_MESSAGE_SIZE) { - gLog.Warn("%sTruncating message to %d characters to send through server.\n", + gLog.Warn(tr("%sTruncating message to %d characters to send through server.\n"), L_WARNxSTR, MAX_MESSAGE_SIZE); mDos[MAX_MESSAGE_SIZE] = '\0'; } @@ -89,7 +93,7 @@ e = new CEventMsg(m, ICQ_CMDxTCP_START, TIME_NOW, f); if (pColor != NULL) e->SetColor(pColor); CPT_Message *p = new CPT_Message(mDos, nLevel, bMultipleRecipients, pColor, u); - gLog.Info("%sSending %smessage to %s (#%ld).\n", L_TCPxSTR, + gLog.Info(tr("%sSending %smessage to %s (#%ld).\n"), L_TCPxSTR, nLevel == ICQ_TCPxMSG_URGENT ? "urgent " : "", u->GetAlias(), -p->Sequence()); result = SendExpectEvent_Client(u, p, e); @@ -138,7 +142,7 @@ e = new CEventMsg(m, ICQ_CMDxSND_THRUxSERVER, TIME_NOW, f); if (strlen(mDos) > MAX_MESSAGE_SIZE) { - gLog.Warn("%sTruncating message to %d characters to send through server.\n", + gLog.Warn(tr("%sTruncating message to %d characters to send through server.\n"), L_WARNxSTR, MAX_MESSAGE_SIZE); mDos[MAX_MESSAGE_SIZE] = '\0'; } @@ -154,8 +158,8 @@ e = new CEventMsg(m, ICQ_CMDxTCP_START, TIME_NOW, f); if (pColor != NULL) e->SetColor(pColor); CPT_Message *p = new CPT_Message(mDos, nLevel, bMultipleRecipients, pColor, u); - gLog.Info("%sSending %smessage to %s (#%ld).\n", L_TCPxSTR, - nLevel == ICQ_TCPxMSG_URGENT ? "urgent " : "", + gLog.Info(tr("%sSending %smessage to %s (#%ld).\n"), L_TCPxSTR, + nLevel == ICQ_TCPxMSG_URGENT ? tr("urgent ") : "", u->GetAlias(), -p->Sequence()); result = SendExpectEvent_Client(u, p, e); } @@ -190,14 +194,14 @@ // Generic read, gets changed in constructor CSrvPacketTcp *s = new CPU_AdvancedMessage(u, ICQ_CMDxTCP_READxAWAYxMSG, 0, false, 0, 0, 0); - gLog.Info("%sRequesting auto reponse from %s.\n", L_SRVxSTR, + gLog.Info(tr("%sRequesting auto reponse from %s.\n"), L_SRVxSTR, u->GetAlias()); result = SendExpectEvent_Server(nUin, s, NULL); } else { CPT_ReadAwayMessage *p = new CPT_ReadAwayMessage(u); - gLog.Info("%sRequesting auto response from %s (#%ld).\n", L_TCPxSTR, + gLog.Info(tr("%sRequesting auto response from %s (#%ld).\n"), L_TCPxSTR, u->GetAlias(), -p->Sequence()); result = SendExpectEvent_Client(u, p, NULL); } @@ -266,8 +270,8 @@ e = new CEventUrl(url, description, ICQ_CMDxTCP_START, TIME_NOW, f); if (pColor != NULL) e->SetColor(pColor); CPT_Url *p = new CPT_Url(m, nLevel, bMultipleRecipients, pColor, u); - gLog.Info("%sSending %sURL to %s (#%ld).\n", L_TCPxSTR, - nLevel == ICQ_TCPxMSG_URGENT ? "urgent " : "", + gLog.Info(tr("%sSending %sURL to %s (#%ld).\n"), L_TCPxSTR, + nLevel == ICQ_TCPxMSG_URGENT ? tr("urgent ") : "", u->GetAlias(), -p->Sequence()); result = SendExpectEvent_Client(u, p, e); } @@ -334,7 +338,7 @@ { e = new CEventFile(szFilename, p->GetDescription(), p->GetFileSize(), lFileList, p->Sequence(), TIME_NOW, f); - gLog.Info("%sSending file transfer to %s (#%ld).\n", L_SRVxSTR, + gLog.Info(tr("%sSending file transfer to %s (#%ld).\n"), L_SRVxSTR, u->GetAlias(), -p->Sequence()); result = SendExpectEvent_Server(u->Uin(), p, e); @@ -357,7 +361,7 @@ e = new CEventFile(szFilename, p->GetDescription(), p->GetFileSize(), lFileList, p->Sequence(), TIME_NOW, f); - gLog.Info("%sSending %sfile transfer to %s (#%ld).\n", L_TCPxSTR, + gLog.Info(tr("%sSending %sfile transfer to %s (#%ld).\n"), L_TCPxSTR, nLevel == ICQ_TCPxMSG_URGENT ? "urgent " : "", u->GetAlias(), -p->Sequence()); @@ -403,7 +407,7 @@ if (!online && p > MAX_MESSAGE_SIZE) { - gLog.Warn("%sContact list too large to send through server.\n", L_WARNxSTR); + gLog.Warn(tr("%sContact list too large to send through server.\n"), L_WARNxSTR); delete []m; return 0; } @@ -432,8 +436,8 @@ e = new CEventContactList(vc, false, ICQ_CMDxTCP_START, TIME_NOW, f); if (pColor != NULL) e->SetColor(pColor); CPT_ContactList *p = new CPT_ContactList(m, nLevel, bMultipleRecipients, pColor, u); - gLog.Info("%sSending %scontact list to %s (#%ld).\n", L_TCPxSTR, - nLevel == ICQ_TCPxMSG_URGENT ? "urgent " : "", + gLog.Info(tr("%sSending %scontact list to %s (#%ld).\n"), L_TCPxSTR, + nLevel == ICQ_TCPxMSG_URGENT ? tr("urgent ") : "", u->GetAlias(), -p->Sequence()); result = SendExpectEvent_Client(u, p, e); } @@ -489,7 +493,7 @@ if (!online && p > MAX_MESSAGE_SIZE) { - gLog.Warn("%sContact list too large to send through server.\n", L_WARNxSTR); + gLog.Warn(tr("%sContact list too large to send through server.\n"), L_WARNxSTR); delete []m; return 0; } @@ -516,8 +520,8 @@ e = new CEventContactList(vc, false, ICQ_CMDxTCP_START, TIME_NOW, f); if (pColor != NULL) e->SetColor(pColor); CPT_ContactList *p = new CPT_ContactList(m, nLevel, bMultipleRecipients, pColor, u); - gLog.Info("%sSending %scontact list to %s (#%ld).\n", L_TCPxSTR, - nLevel == ICQ_TCPxMSG_URGENT ? "urgent " : "", + gLog.Info(tr("%sSending %scontact list to %s (#%ld).\n"), L_TCPxSTR, + nLevel == ICQ_TCPxMSG_URGENT ? tr("urgent ") : "", u->GetAlias(), -p->Sequence()); result = SendExpectEvent_Client(u, p, e); } @@ -545,7 +549,7 @@ // add to history ?? ICQUser *u = gUserManager.FetchUser(nUin, LOCK_R); if (u == NULL) return; - gLog.Info("%sCancelling file transfer to %s (#%ld).\n", L_TCPxSTR, + gLog.Info(tr("%sCancelling file transfer to %s (#%ld).\n"), L_TCPxSTR, u->GetAlias(), -nSequence); CPT_CancelFile p(nSequence, u); AckTCP(p, u->SocketDesc()); @@ -560,7 +564,7 @@ // basically a fancy tcp ack packet which is sent late ICQUser *u = gUserManager.FetchUser(nUin, LOCK_R); if (u == NULL) return; - gLog.Info("%sAccepting file transfer from %s (#%ld).\n", + gLog.Info(tr("%sAccepting file transfer from %s (#%ld).\n"), bDirect ? L_TCPxSTR : L_SRVxSTR, u->GetAlias(), -nSequence); if (bDirect) { @@ -587,7 +591,7 @@ gTranslator.ClientToServer(szReasonDos); ICQUser *u = gUserManager.FetchUser(nUin, LOCK_R); if (u == NULL) return; - gLog.Info("%sRefusing file transfer from %s (#%ld).\n", + gLog.Info(tr("%sRefusing file transfer from %s (#%ld).\n"), bDirect ? L_TCPxSTR : L_SRVxSTR, u->GetAlias(), -nSequence); if (bDirect) @@ -650,7 +654,7 @@ CEventChat *e = new CEventChat(reason, szChatUsers, nPort, p->Sequence(), TIME_NOW, f); - gLog.Info("%sSending chat request to %s (#%ld).\n", L_SRVxSTR, + gLog.Info(tr("%sSending chat request to %s (#%ld).\n"), L_SRVxSTR, u->GetAlias(), -p->Sequence()); result = SendExpectEvent_Server(u->Uin(), p, e); @@ -664,12 +668,12 @@ if (u->Secure()) f |= E_ENCRYPTED; CEventChat *e = new CEventChat(reason, szChatUsers, nPort, p->Sequence(), TIME_NOW, f); - gLog.Info("%sSending %schat request to %s (#%ld).\n", L_TCPxSTR, - nLevel == ICQ_TCPxMSG_URGENT ? "urgent " : "", + gLog.Info(tr("%sSending %schat request to %s (#%ld).\n"), L_TCPxSTR, + nLevel == ICQ_TCPxMSG_URGENT ? tr("urgent ") : "", u->GetAlias(), -p->Sequence()); result = SendExpectEvent_Client(u, p, e); } - + u->SetSendServer(bServer); u->SetSendLevel(nLevel); gUserManager.DropUser(u); @@ -687,7 +691,7 @@ { ICQUser *u = gUserManager.FetchUser(nUin, LOCK_R); if (u == NULL) return; - gLog.Info("%sCancelling chat request with %s (#%ld).\n", L_TCPxSTR, + gLog.Info(tr("%sCancelling chat request with %s (#%ld).\n"), L_TCPxSTR, u->GetAlias(), -nSequence); CPT_CancelChat p(nSequence, u); AckTCP(p, u->SocketDesc()); @@ -702,7 +706,7 @@ // add to history ?? ICQUser *u = gUserManager.FetchUser(nUin, LOCK_R); if (u == NULL) return; - gLog.Info("%sRefusing chat request with %s (#%ld).\n", + gLog.Info(tr("%sRefusing chat request with %s (#%ld).\n"), bDirect ? L_TCPxSTR : L_SRVxSTR, u->GetAlias(), -nSequence); char *szReasonDos = gTranslator.NToRN(szReason); gTranslator.ClientToServer(szReasonDos); @@ -735,7 +739,7 @@ // add to history ?? ICQUser *u = gUserManager.FetchUser(nUin, LOCK_R); if (u == NULL) return; - gLog.Info("%sAccepting chat request with %s (#%ld).\n", + gLog.Info(tr("%sAccepting chat request with %s (#%ld).\n"), bDirect ? L_TCPxSTR : L_SRVxSTR, u->GetAlias(), -nSequence); if (bDirect) @@ -767,7 +771,7 @@ ICQUser *u = gUserManager.FetchUser(nUin, LOCK_W); if (u == NULL) { - gLog.Warn("%sCannot send secure channel request to user not on list (%ld).\n", + gLog.Warn(tr("%sCannot send secure channel request to user not on list (%ld).\n"), L_WARNxSTR, nUin); return 0; } @@ -775,14 +779,14 @@ // Check that the user doesn't already have a secure channel if (u->Secure()) { - gLog.Warn("%s%s (%ld) already has a secure channel.\n", L_WARNxSTR, + gLog.Warn(tr("%s%s (%ld) already has a secure channel.\n"), L_WARNxSTR, u->GetAlias(), nUin); gUserManager.DropUser(u); return 0; } CPT_OpenSecureChannel *pkt = new CPT_OpenSecureChannel(u); - gLog.Info("%sSending request for secure channel to %s (#%ld).\n", L_TCPxSTR, + gLog.Info(tr("%sSending request for secure channel to %s (#%ld).\n"), L_TCPxSTR, u->GetAlias(), -pkt->Sequence()); result = SendExpectEvent_Client(u, pkt, NULL); @@ -795,7 +799,7 @@ return 0; #else // No OpenSSL - gLog.Warn("%sicqOpenSecureChannel() to %ld called when we do not support OpenSSL.\n", + gLog.Warn(tr("%sicqOpenSecureChannel() to %ld called when we do not support OpenSSL.\n"), L_WARNxSTR, nUin); return 0; @@ -811,7 +815,7 @@ ICQUser *u = gUserManager.FetchUser(nUin, LOCK_W); if (u == NULL) { - gLog.Warn("%sCannot send secure channel request to user not on list (%ld).\n", + gLog.Warn(tr("%sCannot send secure channel request to user not on list (%ld).\n"), L_WARNxSTR, nUin); return 0; } @@ -819,14 +823,14 @@ // Check that the user doesn't already have a secure channel if (!u->Secure()) { - gLog.Warn("%s%s (%ld) does not have a secure channel.\n", L_WARNxSTR, + gLog.Warn(tr("%s%s (%ld) does not have a secure channel.\n"), L_WARNxSTR, u->GetAlias(), nUin); gUserManager.DropUser(u); return 0; } CPT_CloseSecureChannel *pkt = new CPT_CloseSecureChannel(u); - gLog.Info("%sClosing secure channel with %s (#%ld).\n", L_TCPxSTR, + gLog.Info(tr("%sClosing secure channel with %s (#%ld).\n"), L_TCPxSTR, u->GetAlias(), -pkt->Sequence()); result = SendExpectEvent_Client(u, pkt, NULL); @@ -839,7 +843,7 @@ return 0; #else // No OpenSSL - gLog.Warn("%sicqCloseSecureChannel() to %ld called when we do not support OpenSSL.\n", + gLog.Warn(tr("%sicqCloseSecureChannel() to %ld called when we do not support OpenSSL.\n"), L_WARNxSTR, nUin); return 0; @@ -852,7 +856,7 @@ { ICQUser *u = gUserManager.FetchUser(nUin, LOCK_W); if (u == NULL) return; - gLog.Info("%sCancelling secure channel request to %s (#%ld).\n", L_TCPxSTR, + gLog.Info(tr("%sCancelling secure channel request to %s (#%ld).\n"), L_TCPxSTR, u->GetAlias(), -nSequence); // XXX Tear down tcp connection ?? gUserManager.DropUser(u); @@ -904,7 +908,7 @@ s->ClearRecvBuffer(); if (nOk != 1) { - gLog.Warn("%sBad handshake ack: %ld.\n", L_WARNxSTR, nOk); + gLog.Warn(tr("%sBad handshake ack: %ld.\n"), L_WARNxSTR, nOk); return false; } @@ -917,7 +921,7 @@ s->ClearRecvBuffer(); if (p.SessionId() != p_in.SessionId()) { - gLog.Warn("%sBad handshake session id: received %ld, expecting %ld.\n", + gLog.Warn(tr("%sBad handshake session id: received %ld, expecting %ld.\n"), L_WARNxSTR, p_in.SessionId(), p.SessionId()); return false; } @@ -945,7 +949,7 @@ s->ClearRecvBuffer(); if (nOk != 1) { - gLog.Warn("%sBad handshake ack: %ld.\n", L_WARNxSTR, nOk); + gLog.Warn(tr("%sBad handshake ack: %ld.\n"), L_WARNxSTR, nOk); return false; } @@ -958,7 +962,7 @@ s->ClearRecvBuffer(); if (p.SessionId() != p_in.SessionId()) { - gLog.Warn("%sBad handshake cookie: received %ld, expecting %ld.\n", + gLog.Warn(tr("%sBad handshake cookie: received %ld, expecting %ld.\n"), L_WARNxSTR, p_in.SessionId(), p.SessionId()); return false; } @@ -990,16 +994,16 @@ default: // Should never happen - gLog.Error("%sUnknown ICQ TCP version (%d).\n", L_ERRORxSTR, nVersion); + gLog.Error(tr("%sUnknown ICQ TCP version (%d).\n"), L_ERRORxSTR, nVersion); return false; } sock_error: char buf[128]; if (s->Error() == 0) - gLog.Warn("%sHandshake error, remote side closed connection.\n", L_WARNxSTR); + gLog.Warn(tr("%sHandshake error, remote side closed connection.\n"), L_WARNxSTR); else - gLog.Warn("%sHandshake socket error:\n%s%s.\n", L_WARNxSTR, L_BLANKxSTR, s->ErrorStr(buf, 128)); + gLog.Warn(tr("%sHandshake socket error:\n%s%s.\n"), L_WARNxSTR, L_BLANKxSTR, s->ErrorStr(buf, 128)); return false; } @@ -1021,7 +1025,7 @@ if (sd != -1) { gUserManager.DropUser(u); - gLog.Warn("%sConnection attempted to already connected user (%ld).\n", + gLog.Warn(tr("%sConnection attempted to already connected user (%ld).\n"), L_WARNxSTR, nUin); return sd; } @@ -1056,7 +1060,7 @@ return -1; } - gLog.Info("%sShaking hands with %s (%ld) [v%d].\n", L_TCPxSTR, + gLog.Info(tr("%sShaking hands with %s (%ld) [v%d].\n"), L_TCPxSTR, szAlias, nUin, nVersion); nPort = s->LocalPort(); @@ -1122,28 +1126,28 @@ // Sending to internet ip if (!bSendIntIp) { - gLog.Info("%sConnecting to %s at %s:%d.\n", L_TCPxSTR, szAlias, + gLog.Info(tr("%sConnecting to %s at %s:%d.\n"), L_TCPxSTR, szAlias, ip_ntoa(nIp, buf), nPort); // If we fail to set the remote address, the ip must be 0 if (!sock->SetRemoteAddr(nIp, nPort)) return false; if (!sock->OpenConnection()) { - gLog.Warn("%sConnect to %s failed:\n%s%s.\n", L_WARNxSTR, szAlias, + gLog.Warn(tr("%sConnect to %s failed:\n%s%s.\n"), L_WARNxSTR, szAlias, L_BLANKxSTR, sock->ErrorStr(buf, 128)); // Now try the internal ip if it is different from this one and we are behind a firewall if (sock->Error() != EINTR && nIntIp != nIp && nIntIp != 0 && CPacket::Firewall()) { - gLog.Info("%sConnecting to %s at %s:%d.\n", L_TCPxSTR, szAlias, + gLog.Info(tr("%sConnecting to %s at %s:%d.\n"), L_TCPxSTR, szAlias, ip_ntoa(nIntIp, buf), nPort); sock->SetRemoteAddr(nIntIp, nPort); if (!sock->OpenConnection()) { char buf[128]; - gLog.Warn("%sConnect to %s real ip failed:\n%s%s.\n", L_WARNxSTR, szAlias, + gLog.Warn(tr("%sConnect to %s real ip failed:\n%s%s.\n"), L_WARNxSTR, szAlias, L_BLANKxSTR, sock->ErrorStr(buf, 128)); return false; } @@ -1158,13 +1162,13 @@ // Sending to Internal IP else { - gLog.Info("%sConnecting to %s at %s:%d.\n", L_TCPxSTR, szAlias, + gLog.Info(tr("%sConnecting to %s at %s:%d.\n"), L_TCPxSTR, szAlias, ip_ntoa(nIntIp, buf), nPort); if (!sock->SetRemoteAddr(nIntIp, nPort)) return false; if (!sock->OpenConnection()) { - gLog.Warn("%sConnect to %s real ip failed:\n%s%s.\n", L_WARNxSTR, szAlias, + gLog.Warn(tr("%sConnect to %s real ip failed:\n%s%s.\n"), L_WARNxSTR, szAlias, L_BLANKxSTR, sock->ErrorStr(buf, 128)); return false; } @@ -1188,7 +1192,7 @@ TCPSocket *s = new TCPSocket(nUin); char buf[32]; - gLog.Info("%sReverse connecting to %ld at %s:%d.\n", L_TCPxSTR, nUin, + gLog.Info(tr("%sReverse connecting to %ld at %s:%d.\n"), L_TCPxSTR, nUin, ip_ntoa(nIp, buf), nPort); // If we fail to set the remote address, the ip must be 0 @@ -1197,12 +1201,12 @@ if (!s->OpenConnection()) { char buf[128]; - gLog.Warn("%sReverse connect to %ld failed:\n%s%s.\n", L_WARNxSTR, + gLog.Warn(tr("%sReverse connect to %ld failed:\n%s%s.\n"), L_WARNxSTR, nUin, L_BLANKxSTR, s->ErrorStr(buf, 128)); return -1; } - gLog.Info("%sReverse shaking hands with %ld.\n", L_TCPxSTR, nUin); + gLog.Info(tr("%sReverse shaking hands with %ld.\n"), L_TCPxSTR, nUin); if (!Handshake_Send(s, nUin, 0, nVersion)) { delete s; @@ -1253,7 +1257,7 @@ // What the--? else { - gLog.Warn("%sReverse connection to unknown port (%d).\n", L_WARNxSTR, nFailedPort); + gLog.Warn(tr("%sReverse connection to unknown port (%d).\n"), L_WARNxSTR, nFailedPort); delete s; } @@ -1301,7 +1305,7 @@ if (!Decrypt_Client(&packet, 4)) { char *buf; - gLog.Unknown("%sInvalid TCPv4 encryption:\n%s\n", L_UNKNOWNxSTR, packet.print(buf)); + gLog.Unknown(tr("%sInvalid TCPv4 encryption:\n%s\n"), L_UNKNOWNxSTR, packet.print(buf)); delete [] buf; return false; } @@ -1322,7 +1326,7 @@ if (!Decrypt_Client(&packet, 6)) { char *buf; - gLog.Unknown("%sInvalid TCPv6 encryption:\n%s\n", L_UNKNOWNxSTR, packet.print(buf)); + gLog.Unknown(tr("%sInvalid TCPv6 encryption:\n%s\n"), L_UNKNOWNxSTR, packet.print(buf)); delete [] buf; return false; } @@ -1345,7 +1349,7 @@ if (!Decrypt_Client(&packet, nInVersion)) { char *buf; - gLog.Unknown("%sUnknown TCPv%d packet:\n%s\n", L_UNKNOWNxSTR, nInVersion, packet.print(buf)); + gLog.Unknown(tr("%sUnknown TCPv%d packet:\n%s\n"), L_UNKNOWNxSTR, nInVersion, packet.print(buf)); delete [] buf; break; } @@ -1379,7 +1383,7 @@ } default: { - gLog.Warn("%sUnknown TCP version %d from socket.\n", L_WARNxSTR, nInVersion); + gLog.Warn(tr("%sUnknown TCP version %d from socket.\n"), L_WARNxSTR, nInVersion); break; } } @@ -1388,7 +1392,7 @@ if (nUin == 0 || command == 0 || newCommand == 0) { char *buf; - gLog.Unknown("%sInvalid TCP packet (uin: %08lx, cmd: %04x, subcmd: %04x):\n%s\n", + gLog.Unknown(tr("%sInvalid TCP packet (uin: %08lx, cmd: %04x, subcmd: %04x):\n%s\n"), L_UNKNOWNxSTR, nUin, command, newCommand, packet.print(buf)); delete [] buf; return false; @@ -1398,9 +1402,9 @@ { char *buf; if(nUin == gUserManager.OwnerUin()) - gLog.Warn("%sTCP message from self (probable spoof):\n%s\n", L_WARNxSTR, packet.print(buf)); + gLog.Warn(tr("%sTCP message from self (probable spoof):\n%s\n"), L_WARNxSTR, packet.print(buf)); else - gLog.Warn("%sTCP message from invalid UIN (%ld, expect %ld):\n%s\n", + gLog.Warn(tr("%sTCP message from invalid UIN (%ld, expect %ld):\n%s\n"), L_WARNxSTR, nUin, pSock->Owner(), packet.print(buf)); delete [] buf; return false; @@ -1454,7 +1458,7 @@ // Check for spoofing if (u->SocketDesc() != sockfd) { - gLog.Warn("%sUser %s (%ld) socket (%d) does not match incoming message (%d).\n", + gLog.Warn(tr("%sUser %s (%ld) socket (%d) does not match incoming message (%d).\n"), L_TCPxSTR, u->GetAlias(), u->Uin(), u->SocketDesc(), sockfd); } @@ -1507,7 +1511,7 @@ case ICQ_TCPxMSG_FxDND: ns |= ICQ_STATUS_DND; break; default: ns = ICQ_STATUS_OFFLINE; - gLog.Warn("%sUnknown TCP status: %04X\n", L_WARNxSTR, msgFlags); + gLog.Warn(tr("%sUnknown TCP status: %04X\n"), L_WARNxSTR, msgFlags); break; } //fprintf(stderr, "%08lX\n", (u->StatusFull() & ICQ_STATUS_FxFLAGS) | ns); @@ -1519,7 +1523,7 @@ { bool r = u->OfflineOnDisconnect() || u->StatusOffline(); ChangeUserStatus(u, (u->StatusFull() & ICQ_STATUS_FxFLAGS) | ns); - gLog.Info("%s%s (%ld) is %s to us.\n", L_TCPxSTR, u->GetAlias(), + gLog.Info(tr("%s%s (%ld) is %s to us.\n"), L_TCPxSTR, u->GetAlias(), u->Uin(), u->StatusStr()); if (r) u->SetOfflineOnDisconnect(true); } @@ -1551,10 +1555,10 @@ packet >> licqChar >> licqVersion; nMask |= licqVersion; if (licqChar == 'L') - gLog.Info("%sMessage from %s (%ld) [Licq %s].\n", L_TCPxSTR, u->GetAlias(), + gLog.Info(tr("%sMessage from %s (%ld) [Licq %s].\n"), L_TCPxSTR, u->GetAlias(), nUin, CUserEvent::LicqVersionToString(licqVersion)); else - gLog.Info("%sMessage from %s (%ld).\n", L_TCPxSTR, u->GetAlias(), nUin); + gLog.Info(tr("%sMessage from %s (%ld).\n"), L_TCPxSTR, u->GetAlias(), nUin); CEventMsg *e = CEventMsg::Parse(message, ICQ_CMDxTCP_START, TIME_NOW, nMask); e->SetColor(fore, back); @@ -1610,10 +1614,10 @@ packet >> junkLong >> junkLong; packet >> licqChar >> licqVersion; if (licqChar == 'L') - gLog.Info("%s%s (%ld) requested auto response [Licq %s].\n", L_TCPxSTR, + gLog.Info(tr("%s%s (%ld) requested auto response [Licq %s].\n"), L_TCPxSTR, u->GetAlias(), nUin, CUserEvent::LicqVersionToString(licqVersion)); else - gLog.Info("%s%s (%ld) requested auto response.\n", L_TCPxSTR, u->GetAlias(), nUin); + gLog.Info(tr("%s%s (%ld) requested auto response.\n"), L_TCPxSTR, u->GetAlias(), nUin); CPT_AckGeneral p(newCommand, theSequence, true, false, u); AckTCP(p, pSock); @@ -1649,16 +1653,16 @@ packet >> licqChar >> licqVersion; nMask |= licqVersion; if (licqChar == 'L') - gLog.Info("%sURL from %s (%ld) [Licq %s].\n", L_TCPxSTR, u->GetAlias(), + gLog.Info(tr("%sURL from %s (%ld) [Licq %s].\n"), L_TCPxSTR, u->GetAlias(), nUin, CUserEvent::LicqVersionToString(licqVersion)); else - gLog.Info("%sURL from %s (%ld).\n", L_TCPxSTR, u->GetAlias(), nUin); + gLog.Info(tr("%sURL from %s (%ld).\n"), L_TCPxSTR, u->GetAlias(), nUin); CEventUrl *e = CEventUrl::Parse(message, ICQ_CMDxTCP_START, TIME_NOW, nMask); if (e == NULL) { char *buf; - gLog.Warn("%sInvalid URL message:\n%s\n", L_WARNxSTR, packet.print(buf)); + gLog.Warn(tr("%sInvalid URL message:\n%s\n"), L_WARNxSTR, packet.print(buf)); delete []buf; errorOccured = true; break; @@ -1718,17 +1722,17 @@ packet >> licqChar >> licqVersion; nMask |= licqVersion; if (licqChar == 'L') - gLog.Info("%sContact list from %s (%ld) [Licq %s].\n", L_TCPxSTR, + gLog.Info(tr("%sContact list from %s (%ld) [Licq %s].\n"), L_TCPxSTR, u->GetAlias(), nUin, CUserEvent::LicqVersionToString(licqVersion)); else - gLog.Info("%sContact list from %s (%ld).\n", L_TCPxSTR, u->GetAlias(), + gLog.Info(tr("%sContact list from %s (%ld).\n"), L_TCPxSTR, u->GetAlias(), nUin); CEventContactList *e = CEventContactList::Parse(message, ICQ_CMDxTCP_START, TIME_NOW, nMask); if (e == NULL) { char *buf; - gLog.Warn("%sInvalid contact list message:\n%s\n", L_WARNxSTR, packet.print(buf)); + gLog.Warn(tr("%sInvalid contact list message:\n%s\n"), L_WARNxSTR, packet.print(buf)); delete []buf; errorOccured = true; break; @@ -1785,10 +1789,10 @@ packet >> licqChar >> licqVersion; if (licqChar == 'L') - gLog.Info("%sChat request from %s (%ld) [Licq %s].\n", L_TCPxSTR, + gLog.Info(tr("%sChat request from %s (%ld) [Licq %s].\n"), L_TCPxSTR, u->GetAlias(), nUin, CUserEvent::LicqVersionToString(licqVersion)); else - gLog.Info("%sChat request from %s (%ld).\n", L_TCPxSTR, u->GetAlias(), + gLog.Info(tr("%sChat request from %s (%ld).\n"), L_TCPxSTR, u->GetAlias(), nUin); // translating string with translation table @@ -1839,10 +1843,10 @@ packet >> licqChar >> licqVersion; if (licqChar == 'L') - gLog.Info("%sFile transfer request from %s (%ld) [Licq %s].\n", + gLog.Info(tr("%sFile transfer request from %s (%ld) [Licq %s].\n"), L_TCPxSTR, u->GetAlias(), nUin, CUserEvent::LicqVersionToString(licqVersion)); else - gLog.Info("%sFile transfer request from %s (%ld).\n", L_TCPxSTR, + gLog.Info(tr("%sFile transfer request from %s (%ld).\n"), L_TCPxSTR, u->GetAlias(), nUin); ConstFileList filelist; @@ -1901,7 +1905,7 @@ nICBMCommand = ICQ_CMDxSUB_CONTACTxLIST; else { - gLog.Info("%sUnknown ICBM plugin type: %s\n", L_TCPxSTR, szPlugin); + gLog.Info(tr("%sUnknown ICBM plugin type: %s\n"), L_TCPxSTR, szPlugin); break; } @@ -1925,7 +1929,7 @@ packet >> nFileSize; packet.incDataPosRead(2); // reversed port (BE) - gLog.Info("%sFile transfer request from %s (%ld).\n", L_TCPxSTR, + gLog.Info(tr("%sFile transfer request from %s (%ld).\n"), L_TCPxSTR, u->GetAlias(), nUin); ConstFileList filelist; @@ -1960,9 +1964,9 @@ if (nPort == 0) nPort = nPortReversed; - gLog.Info("%sChat request from %s (%ld).\n", L_TCPxSTR, + gLog.Info(tr("%sChat request from %s (%ld).\n"), L_TCPxSTR, u->GetAlias(), nUin); - + // translating string with translation table gTranslator.ServerToClient(szMessage); CEventChat *e = new CEventChat(szMessage, szChatClients, nPort, @@ -1984,13 +1988,13 @@ } case ICQ_CMDxSUB_URL: { - gLog.Info("%sURL from %s (%ld).\n", L_TCPxSTR, u->GetAlias(), nUin); + gLog.Info(tr("%sURL from %s (%ld).\n"), L_TCPxSTR, u->GetAlias(), nUin); CEventUrl *e = CEventUrl::Parse(szMessage, ICQ_CMDxTCP_START, TIME_NOW, nMask); if (e == NULL) { char *buf; - gLog.Warn("%sInvalid URL message:\n%s\n", L_WARNxSTR, + gLog.Warn(tr("%sInvalid URL message:\n%s\n"), L_WARNxSTR, packet.print(buf)); delete [] buf; errorOccured = true; @@ -2014,7 +2018,7 @@ } case ICQ_CMDxSUB_CONTACTxLIST: { - gLog.Info("%sContact list from %s (%ld).\n", L_TCPxSTR, + gLog.Info(tr("%sContact list from %s (%ld).\n"), L_TCPxSTR, u->GetAlias(), nUin); CEventContactList *e = CEventContactList::Parse(szMessage, ICQ_CMDxTCP_START, @@ -2022,7 +2026,7 @@ if (e == NULL) { char *buf; - gLog.Warn("%sInvalid contact list message:\n%s\n", L_TCPxSTR, + gLog.Warn(tr("%sInvalid contact list message:\n%s\n"), L_TCPxSTR, packet.print(buf)); delete [] buf; errorOccured = true; @@ -2041,7 +2045,7 @@ } if (!AddUserEvent(u, e)) break; - m_xOnEventManager.Do(ON_EVENT_MSG, u); + m_xOnEventManager.Do(ON_EVENT_MSG, u); break; } } // switch nICBMCommand @@ -2052,7 +2056,7 @@ // Old-style encryption request: case ICQ_CMDxSUB_SECURExOLD: { - gLog.Info("%sReceived old-style key request from %s (%ld) but we do not support it.\n", + gLog.Info(tr("%sReceived old-style key request from %s (%ld) but we do not support it.\n"), L_TCPxSTR, u->GetAlias(), nUin); // Send the nack back CPT_AckOldSecureChannel p(theSequence, u); @@ -2077,10 +2081,10 @@ packet >> licqChar >> licqVersion; if (licqChar == 'L') - gLog.Info("%sSecure channel request from %s (%ld) [Licq %s].\n", + gLog.Info(tr("%sSecure channel request from %s (%ld) [Licq %s].\n"), L_TCPxSTR, u->GetAlias(), nUin, CUserEvent::LicqVersionToString(licqVersion)); else - gLog.Info("%sSecure channel request from %s (%ld).\n", L_TCPxSTR, + gLog.Info(tr("%sSecure channel request from %s (%ld).\n"), L_TCPxSTR, u->GetAlias(), nUin); CPT_AckOpenSecureChannel p(theSequence, true, u); @@ -2105,13 +2109,13 @@ u->SetSendServer(false); PushPluginSignal(new CICQSignal(SIGNAL_UPDATExUSER, USER_SECURITY, nUin, 1)); - gLog.Info("%sSecure channel established with %s (%ld).\n", + gLog.Info(tr("%sSecure channel established with %s (%ld).\n"), L_SSLxSTR, u->GetAlias(), nUin); break; #else // We do not support OpenSSL - gLog.Info("%sReceived secure channel request from %s (%ld) but we do not support OpenSSL.\n", + gLog.Info(tr("%sReceived secure channel request from %s (%ld) but we do not support OpenSSL.\n"), L_TCPxSTR, u->GetAlias(), nUin); // Send the nack back CPT_AckOpenSecureChannel p(theSequence, false, u); @@ -2138,10 +2142,10 @@ packet >> licqChar >> licqVersion; if (licqChar == 'L') - gLog.Info("%sSecure channel closed by %s (%ld) [Licq %s].\n", + gLog.Info(tr("%sSecure channel closed by %s (%ld) [Licq %s].\n"), L_TCPxSTR, u->GetAlias(), nUin, CUserEvent::LicqVersionToString(licqVersion)); else - gLog.Info("%sSecure channel closed by %s (%ld).\n", L_TCPxSTR, + gLog.Info(tr("%sSecure channel closed by %s (%ld).\n"), L_TCPxSTR, u->GetAlias(), nUin); // send ack @@ -2154,7 +2158,7 @@ break; #else // We do not support OpenSSL - gLog.Info("%sReceived secure channel close from %s (%ld) but we do not support OpenSSL.\n", + gLog.Info(tr("%sReceived secure channel close from %s (%ld) but we do not support OpenSSL.\n"), L_TCPxSTR, u->GetAlias(), nUin); // Send the nack back CPT_AckCloseSecureChannel p(theSequence, u); @@ -2167,7 +2171,7 @@ default: { char *buf; - gLog.Unknown("%sUnknown TCP message type (%04x):\n%s\n", L_UNKNOWNxSTR, + gLog.Unknown(tr("%sUnknown TCP message type (%04x):\n%s\n"), L_UNKNOWNxSTR, newCommand, packet.print(buf)); errorOccured = true; delete []buf; @@ -2276,7 +2280,7 @@ for (unsigned long i = 0; i < nLongLen; i++) packet >> szPlugin[i]; szPlugin[nLongLen] = '\0'; - + packet.incDataPosRead(nLen - 22 - nLongLen); packet.incDataPosRead(4); // left in packet @@ -2291,7 +2295,7 @@ nICBMCommand = ICQ_CMDxSUB_CONTACTxLIST; else { - gLog.Info("%sUnknown direct ack ICBM plugin type: %s\n", L_TCPxSTR, + gLog.Info(tr("%sUnknown direct ack ICBM plugin type: %s\n"), L_TCPxSTR, szPlugin); gUserManager.DropUser(u); return true; @@ -2364,7 +2368,7 @@ char l[32] = ""; if (licqChar == 'L') sprintf(l, " [Licq %s]", CUserEvent::LicqVersionToString(licqVersion)); - gLog.Info("%sSecure channel response from %s (%ld)%s.\n", L_TCPxSTR, + gLog.Info(tr("%sSecure channel response from %s (%ld)%s.\n"), L_TCPxSTR, u->GetAlias(), nUin, l); ICQEvent *e = NULL; @@ -2372,7 +2376,7 @@ // Check if the response is ok if (message[0] == '\0') { - gLog.Info("%s%s (%ld) does not support OpenSSL.\n", L_TCPxSTR, + gLog.Info(tr("%s%s (%ld) does not support OpenSSL.\n"), L_TCPxSTR, u->GetAlias(), nUin); u->SetSecure(false); PushPluginSignal(new CICQSignal(SIGNAL_UPDATExUSER, USER_SECURITY, nUin, 0)); @@ -2387,7 +2391,7 @@ // Check that a request was in progress...should always be ok if (e == NULL) { - gLog.Warn("%sSecure channel response from %s (%ld) when no request in progress.\n", + gLog.Warn(tr("%sSecure channel response from %s (%ld) when no request in progress.\n"), L_WARNxSTR, u->GetAlias(), nUin); // Close the connection as we are in trouble u->SetSecure(false); @@ -2403,7 +2407,7 @@ } else { - gLog.Info("%sSecure channel established with %s (%ld).\n", L_SSLxSTR, + gLog.Info(tr("%sSecure channel established with %s (%ld).\n"), L_SSLxSTR, u->GetAlias(), nUin); u->SetSecure(true); PushPluginSignal(new CICQSignal(SIGNAL_UPDATExUSER, USER_SECURITY, nUin, 1)); @@ -2436,7 +2440,7 @@ char l[32] = ""; if (licqChar == 'L') sprintf(l, " [Licq %s]", CUserEvent::LicqVersionToString(licqVersion)); - gLog.Info("%sSecure channel with %s (%ld) closed %s.\n", L_TCPxSTR, + gLog.Info(tr("%sSecure channel with %s (%ld) closed %s.\n"), L_TCPxSTR, u->GetAlias(), nUin, l); // Find the event, succeed it @@ -2468,7 +2472,7 @@ default: { char *buf; - gLog.Unknown("%sUnknown TCP Ack subcommand (%04x):\n%s\n", L_UNKNOWNxSTR, + gLog.Unknown(tr("%sUnknown TCP Ack subcommand (%04x):\n%s\n"), L_UNKNOWNxSTR, newCommand, packet.print(buf)); errorOccured = true; delete []buf; @@ -2485,7 +2489,7 @@ int nSubResult; if (ackFlags == ICQ_TCPxACK_REFUSE) { - gLog.Info("%sRefusal from %s (#%ld)%s.\n", L_TCPxSTR, u->GetAlias(), -theSequence, l); + gLog.Info(tr("%sRefusal from %s (#%ld)%s.\n"), L_TCPxSTR, u->GetAlias(), -theSequence, l); nSubResult = ICQ_TCPxACK_REFUSE; } else @@ -2495,14 +2499,14 @@ { u->SetAutoResponse(message); u->SetShowAwayMsg(*message); - gLog.Info("%sAuto response from %s (#%ld)%s.\n", L_TCPxSTR, + gLog.Info(tr("%sAuto response from %s (#%ld)%s.\n"), L_TCPxSTR, u->GetAlias(), -theSequence, l); } switch(ackFlags) { case ICQ_TCPxACK_ONLINE: - gLog.Info("%sAck from %s (#%ld)%s.\n", L_TCPxSTR, u->GetAlias(), + gLog.Info(tr("%sAck from %s (#%ld)%s.\n"), L_TCPxSTR, u->GetAlias(), -theSequence, l); if (pExtendedAck && !pExtendedAck->Accepted()) nSubResult = ICQ_TCPxACK_RETURN; @@ -2512,25 +2516,25 @@ case ICQ_TCPxACK_AWAY: case ICQ_TCPxACK_NA: case ICQ_TCPxACK_OCCUPIEDx2: //auto decline due to occupied mode - gLog.Info("%sAck from %s (#%ld)%s.\n", L_TCPxSTR, u->GetAlias(), + gLog.Info(tr("%sAck from %s (#%ld)%s.\n"), L_TCPxSTR, u->GetAlias(), -theSequence, l); nSubResult = ICQ_TCPxACK_REFUSE; break; case ICQ_TCPxACK_OCCUPIED: case ICQ_TCPxACK_DND: - gLog.Info("%sReturned from %s (#%ld)%s.\n", L_TCPxSTR, u->GetAlias(), + gLog.Info(tr("%sReturned from %s (#%ld)%s.\n"), L_TCPxSTR, u->GetAlias(), -theSequence, l); nSubResult = ICQ_TCPxACK_RETURN; break; case ICQ_TCPxACK_OCCUPIEDxCAR: case ICQ_TCPxACK_DNDxCAR: - gLog.Info("%sCustom %s response from %s (#%ld)%s.\n", L_TCPxSTR, - (ackFlags == ICQ_TCPxACK_DNDxCAR ? "DnD" : "Occupied"), u->GetAlias(), + gLog.Info(tr("%sCustom %s response from %s (#%ld)%s.\n"), L_TCPxSTR, + (ackFlags == ICQ_TCPxACK_DNDxCAR ? tr("DnD") : tr("Occupied")), u->GetAlias(), -theSequence, l); nSubResult = ICQ_TCPxACK_ACCEPT; // FIXME: or should this be ACK_RETURN ? break; default: - gLog.Unknown("%sUnknown ack flag from %s (#%ld): %04x %s.\n", L_UNKNOWNxSTR, + gLog.Unknown(tr("%sUnknown ack flag from %s (#%ld): %04x %s.\n"), L_UNKNOWNxSTR, u->GetAlias(), -theSequence, ackFlags, l); nSubResult = ICQ_TCPxACK_ACCEPT; } @@ -2547,7 +2551,7 @@ } else { - gLog.Warn("%sAck for unknown event.\n", L_TCPxSTR); + gLog.Warn(tr("%sAck for unknown event.\n"), L_TCPxSTR); errorOccured = true; delete pExtendedAck; } @@ -2563,7 +2567,7 @@ { case ICQ_CMDxSUB_CHAT: { - gLog.Info("%sChat request from %s (%ld) cancelled.\n", L_TCPxSTR, + gLog.Info(tr("%sChat request from %s (%ld) cancelled.\n"), L_TCPxSTR, u->GetAlias(), nUin); if (nInVersion <= 4) { @@ -2589,7 +2593,7 @@ } case ICQ_CMDxSUB_FILE: { - gLog.Info("%sFile transfer request from %s (%ld) cancelled.\n", + gLog.Info(tr("%sFile transfer request from %s (%ld) cancelled.\n"), L_TCPxSTR, u->GetAlias(), nUin); if (nInVersion <= 4) { @@ -2622,7 +2626,7 @@ default: char *buf; - gLog.Unknown("%sUnknown TCP packet (command 0x%04x):\n%s\n", L_UNKNOWNxSTR, command, packet.print(buf)); + gLog.Unknown(tr("%sUnknown TCP packet (command 0x%04x):\n%s\n"), L_UNKNOWNxSTR, command, packet.print(buf)); delete [] buf; errorOccured = true; break; @@ -2675,7 +2679,7 @@ if ((unsigned char)cHandshake != ICQ_CMDxTCP_HANDSHAKE) { char *buf; - gLog.Unknown("%sUnknown TCP handshake packet (command = 0x%02X):\n%s\n", + gLog.Unknown(tr("%sUnknown TCP handshake packet (command = 0x%02X):\n%s\n"), L_UNKNOWNxSTR, cHandshake, b.print(buf)); delete [] buf; return false; @@ -2710,7 +2714,7 @@ unsigned long nOk = s->RecvBuffer().UnpackUnsignedLong(); if (nOk != 1) { - gLog.Warn("%sBad handshake ack: %ld.\n", L_WARNxSTR, nOk); + gLog.Warn(tr("%sBad handshake ack: %ld.\n"), L_WARNxSTR, nOk); return false; } @@ -2720,7 +2724,7 @@ CPacketTcp_Handshake_Confirm p_confirm(true); int nGot = s->RecvBuffer().getDataSize(); s->ClearRecvBuffer(); - + if (nGot > 4) { if (!s->SendPacket(p_confirm.getBuffer())) goto sock_error; @@ -2765,7 +2769,7 @@ s->ClearRecvBuffer(); if (nOk != 1) { - gLog.Warn("%sBad handshake ack: %ld.\n", L_WARNxSTR, nOk); + gLog.Warn(tr("%sBad handshake ack: %ld.\n"), L_WARNxSTR, nOk); return false; } nVersion = 6; @@ -2794,7 +2798,7 @@ default: { char *buf; - gLog.Unknown("%sUnknown TCP handshake packet :\n%s\n", + gLog.Unknown(tr("%sUnknown TCP handshake packet :\n%s\n"), L_UNKNOWNxSTR, b.print(buf)); delete [] buf; return false; @@ -2809,9 +2813,9 @@ sock_error: char buf[128]; if (s->Error() == 0) - gLog.Warn("%sHandshake error, remote side closed connection.\n", L_WARNxSTR); + gLog.Warn(tr("%sHandshake error, remote side closed connection.\n"), L_WARNxSTR); else - gLog.Warn("%sHandshake socket error:\n%s%s.\n", L_WARNxSTR, L_BLANKxSTR, s->ErrorStr(buf, 128)); + gLog.Warn(tr("%sHandshake socket error:\n%s%s.\n"), L_WARNxSTR, L_BLANKxSTR, s->ErrorStr(buf, 128)); return false; } @@ -2831,13 +2835,13 @@ ICQUser *u = gUserManager.FetchUser(nUin, LOCK_W); if (u != NULL) { - gLog.Info("%sConnection from %s (%ld) [v%ld].\n", L_TCPxSTR, + gLog.Info(tr("%sConnection from %s (%ld) [v%ld].\n"), L_TCPxSTR, u->GetAlias(), nUin, s->Version()); if (u->SocketDesc() != s->Descriptor()) { if (u->SocketDesc() != -1) { - gLog.Warn("%sUser %s (%ld) already has an associated socket.\n", + gLog.Warn(tr("%sUser %s (%ld) already has an associated socket.\n"), L_WARNxSTR, u->GetAlias(), nUin); gSocketManager.CloseSocket(u->SocketDesc(), false); u->ClearSocketDesc(); @@ -2848,7 +2852,7 @@ } else { - gLog.Info("%sConnection from new user (%ld) [v%ld].\n", L_TCPxSTR, + gLog.Info(tr("%sConnection from new user (%ld) [v%ld].\n"), L_TCPxSTR, nUin, s->Version()); } Index: licq.cpp =================================================================== RCS file: /cvsroot/licq/licq/src/licq.cpp,v retrieving revision 1.74 diff -u -r1.74 licq.cpp --- licq.cpp 2 Jul 2003 04:41:01 -0000 1.74 +++ licq.cpp 4 Jul 2003 11:59:34 -0000 @@ -19,6 +19,10 @@ #include <string.h> #include <dlfcn.h> +//This is to gettext +#include <libintl.h> +#define tr(String) gettext(String) + #ifdef HAVE_ERRNO_H #include <errno.h> #else @@ -90,18 +94,18 @@ w = where & ~SSL_ST_MASK; - if (w & SSL_ST_CONNECT) str="SSL_connect"; - else if (w & SSL_ST_ACCEPT) str="SSL_accept"; - else str="undefined"; + if (w & SSL_ST_CONNECT) str=tr("SSL_connect"); + else if (w & SSL_ST_ACCEPT) str=tr("SSL_accept"); + else str=tr("undefined"); if (where & SSL_CB_LOOP) { - gLog.Info("%s%s:%s\n",L_SSLxSTR,str,SSL_state_string_long(s)); + gLog.Info(tr("%s%s:%s\n"),L_SSLxSTR,str,SSL_state_string_long(s)); } else if (where & SSL_CB_ALERT) { - str=(where & SSL_CB_READ)?"read":"write"; - gLog.Info("%sSSL3 alert %s:%s:%s\n",L_SSLxSTR, + str=(where & SSL_CB_READ)?tr("read"):tr("write"); + gLog.Info(tr("%sSSL3 alert %s:%s:%s\n"),L_SSLxSTR, str, SSL_alert_type_string_long(ret), SSL_alert_desc_string_long(ret)); @@ -109,17 +113,17 @@ else if (where & SSL_CB_EXIT) { if (ret == 0) - gLog.Info("%s%s:failed in %s\n",L_SSLxSTR, + gLog.Info(tr("%s%s:failed in %s\n"),L_SSLxSTR, str,SSL_state_string_long(s)); else if (ret < 0) { - gLog.Info("%s%s:%s\n",L_SSLxSTR,str,SSL_state_string_long(s)); + gLog.Info(tr("%s%s:%s\n"),L_SSLxSTR,str,SSL_state_string_long(s)); } } else if (where & SSL_CB_ALERT) { - str=(where & SSL_CB_READ)?"read":"write"; - gLog.Info("%sSSL3 alert %s:%s:%s\n",L_SSLxSTR, + str=(where & SSL_CB_READ)?tr("read"):tr("write"); + gLog.Info(tr("%sSSL3 alert %s:%s:%s\n"),L_SSLxSTR, str, SSL_alert_type_string_long(ret), SSL_alert_desc_string_long(ret)); @@ -127,11 +131,11 @@ else if (where & SSL_CB_EXIT) { if (ret == 0) - gLog.Info("%s%s:failed in %s\n",L_SSLxSTR, + gLog.Info(tr("%s%s:failed in %s\n"),L_SSLxSTR, str,SSL_state_string_long(s)); else if (ret < 0) { - gLog.Info("%s%s:error in %s\n",L_SSLxSTR, + gLog.Info(tr("%s%s:error in %s\n"),L_SSLxSTR, str,SSL_state_string_long(s)); } } @@ -163,6 +167,8 @@ char szFilename[MAX_FILENAME_LEN]; vector <char *> vszPlugins; + //setting up textdomain for translations + textdomain("licq"); // parse command line for arguments bool bHelp = false; bool bFork = false; @@ -174,7 +180,7 @@ // Check the no one is trying session management on us if (argc > 1 && strcmp(argv[1], "-session") == 0) { - fprintf(stderr, "Session management is not supported by Licq.\n"); + fprintf(stderr, tr("Session management is not supported by Licq.\n")); } else { @@ -241,9 +247,9 @@ // Redirect stdout and stderr if asked to if (szRedirect) { if (bRedirect_ok) - gLog.Info("%sOutput redirected to \"%s\".\n", L_INITxSTR, szRedirect); + gLog.Info(tr("%sOutput redirected to \"%s\".\n"), L_INITxSTR, szRedirect); else - gLog.Warn("%sRedirection to \"%s\" failed:\n%s%s.\n", L_WARNxSTR, + gLog.Warn(tr("%sRedirection to \"%s\" failed:\n%s%s.\n"), L_WARNxSTR, szRedirect, L_BLANKxSTR, strerror(errno)); free (szRedirect); szRedirect = NULL; @@ -255,7 +261,7 @@ char *home; if ((home = getenv("HOME")) == NULL) { - gLog.Error("%sLicq: $HOME not set, unable to determine config base directory.\n", L_ERRORxSTR); + gLog.Error(tr("%sLicq: $HOME not set, unable to determine config base directory.\n"), L_ERRORxSTR); return false; } snprintf(BASE_DIR, MAX_FILENAME_LEN, "%s/.licq", home); @@ -282,12 +288,12 @@ if (pid != 0) { if (kill(pid, 0) == -1) { - gLog.Warn("%sLicq: Ignoring stale lockfile (pid %d)\n", L_WARNxSTR, pid); + gLog.Warn(tr("%sLicq: Ignoring stale lockfile (pid %d)\n"), L_WARNxSTR, pid); } else { - gLog.Error("%sLicq: Already running at pid %d.\n" - "%s Kill process or remove %s.\n", + gLog.Error(tr("%sLicq: Already running at pid %d.\n" + "%s Kill process or remove %s.\n"), L_ERRORxSTR, pid, L_BLANKxSTR, szConf); return false; } @@ -302,8 +308,8 @@ fclose(fs); } else - gLog.Warn("%sLicq: %s cannot be opened for writing.\n" - "%s skipping lockfile protection.\n", + gLog.Warn(tr("%sLicq: %s cannot be opened for writing.\n" + "%s skipping lockfile protection.\n"), L_WARNxSTR, szConf, L_BLANKxSTR); // Open the config file @@ -318,10 +324,10 @@ licqConf.ReadNum("Version", nVersion, 0); if (nVersion < 710) { - fprintf(stderr, "Previous Licq config files detected.\n" + fprintf(stderr, tr("Previous Licq config files detected.\n" "Manual upgrade is necessary. Follow the instructions\n" "in the UPGRADE file included with the source tree or\n" - "in /usr/doc/licq-xxx/upgrade.\n"); + "in /usr/doc/licq-xxx/upgrade.\n")); return false; } if (nVersion < INT_VERSION) @@ -338,7 +344,7 @@ if (!LoadPlugin(*iter, argc, argv)) return false; if (bHelp) { - fprintf(stderr, "Licq Plugin: %s %s\n%s\n----------\n", + fprintf(stderr, tr("Licq Plugin: %s %s\n%s\n----------\n"), list_plugins.back()->Name(), list_plugins.back()->Version(), (*(list_plugins.back())->fUsage)() ); @@ -450,16 +456,16 @@ if (handle == NULL) { const char *error = dlerror(); - gLog.Error("%sUnable to load plugin (%s): %s.\n", L_ERRORxSTR, _szName, + gLog.Error(tr("%sUnable to load plugin (%s): %s.\n"), L_ERRORxSTR, _szName, error); if (!strstr(error, "No such file")) { - gLog.Warn("%sThis usually happens when your plugin\n" + gLog.Warn(tr("%sThis usually happens when your plugin\n" "%sis not kept in sync with the daemon.\n" "%sPlease try recompiling the plugin.\n" "%sIf you are still having problems, see\n" - "%sthe FAQ at www.licq.org\n", + "%sthe FAQ at www.licq.org\n"), L_WARNxSTR, L_SBLANKxSTR, L_SBLANKxSTR, L_SBLANKxSTR, L_SBLANKxSTR); } @@ -475,7 +481,7 @@ p->fName = (const char * (*)())dlsym(handle, "_LP_Name"); if ((error = dlerror()) != NULL) { - gLog.Error("%sFailed to find LP_Name() function in plugin (%s): %s\n", + gLog.Error(tr("%sFailed to find LP_Name() function in plugin (%s): %s\n"), L_ERRORxSTR, _szName, error); delete p; return NULL; @@ -488,7 +494,7 @@ p->fVersion = (const char * (*)())dlsym(handle, "_LP_Version"); if ((error = dlerror()) != NULL) { - gLog.Error("%sFailed to find LP_Version() function in plugin (%s): %s\n", + gLog.Error(tr("%sFailed to find LP_Version() function in plugin (%s): %s\n"), L_ERRORxSTR, p->Name(), error); delete p; return NULL; @@ -501,7 +507,7 @@ p->fStatus = (const char * (*)())dlsym(handle, "_LP_Status"); if ((error = dlerror()) != NULL) { - gLog.Error("%sFailed to find LP_Status() function in plugin (%s): %s\n", + gLog.Error(tr("%sFailed to find LP_Status() function in plugin (%s): %s\n"), L_ERRORxSTR, p->Name(), error); delete p; return NULL; @@ -514,7 +520,7 @@ p->fDescription = (const char * (*)())dlsym(handle, "_LP_Description"); if ((error = dlerror()) != NULL) { - gLog.Error("%sFailed to find LP_Description() function in plugin (%s): %s\n", + gLog.Error(tr("%sFailed to find LP_Description() function in plugin (%s): %s\n"), L_ERRORxSTR, p->Name(), error); delete p; return NULL; @@ -527,7 +533,7 @@ p->fBuildDate = (const char * (*)())dlsym(handle, "_LP_BuildDate"); if ((error = dlerror()) != NULL) { - gLog.Error("%sFailed to find LP_BuildDate() function in plugin (%s): %s.\n", + gLog.Error(tr("%sFailed to find LP_BuildDate() function in plugin (%s): %s.\n"), L_ERRORxSTR, p->Name(), error); delete p; return NULL; @@ -540,7 +546,7 @@ p->fBuildTime = (const char * (*)())dlsym(handle, "_LP_BuildTime"); if ((error = dlerror()) != NULL) { - gLog.Error("%sFailed to find LP_BuildTime() function in plugin (%s): %s\n", + gLog.Error(tr("%sFailed to find LP_BuildTime() function in plugin (%s): %s\n"), L_ERRORxSTR, p->Name(), error); delete p; return NULL; @@ -553,7 +559,7 @@ p->fInit = (bool (*)(int, char **))dlsym(handle, "_LP_Init"); if ((error = dlerror()) != NULL) { - gLog.Error("%sFailed to find LP_Init() function in plugin (%s): %s\n", + gLog.Error(tr("%sFailed to find LP_Init() function in plugin (%s): %s\n"), L_ERRORxSTR, p->Name(), error); delete p; return NULL; @@ -566,7 +572,7 @@ p->fUsage = (const char * (*)())dlsym(handle, "_LP_Usage"); if ((error = dlerror()) != NULL) { - gLog.Error("%sFailed to find LP_Usage() function in plugin (%s): %s\n", + gLog.Error(tr("%sFailed to find LP_Usage() function in plugin (%s): %s\n"), L_ERRORxSTR, p->Name(), error); delete p; return NULL; @@ -579,7 +585,7 @@ p->fMain = (int (*)(CICQDaemon *))dlsym(handle, "_LP_Main"); if ((error = dlerror()) != NULL) { - gLog.Error("%sFailed to find LP_Main() function in plugin (%s): %s\n", + gLog.Error(tr("%sFailed to find LP_Main() function in plugin (%s): %s\n"), L_ERRORxSTR, p->Name(), error); delete p; return NULL; @@ -592,7 +598,7 @@ p->fMain_tep = (void * (*)(void *))dlsym(handle, "_LP_Main_tep"); if ((error = dlerror()) != NULL) { - gLog.Error("%sFailed to find LP_Main_tep() function in plugin (%s): %s\n", + gLog.Error(tr("%sFailed to find LP_Main_tep() function in plugin (%s): %s\n"), L_ERRORxSTR, p->Name(), error); delete p; return NULL; @@ -613,7 +619,7 @@ p->nId = (unsigned short *)dlsym(handle, "_LP_Id"); if ((error = dlerror()) != NULL) { - gLog.Error("%sFailed to find LP_Id variable in plugin (%s): %s\n", + gLog.Error(tr("%sFailed to find LP_Id variable in plugin (%s): %s\n"), L_ERRORxSTR, p->Name(), error); delete p; return NULL; @@ -648,7 +654,7 @@ // Init the plugin if (!(*p->fInit)(p->localargc, p->localargv)) { - gLog.Error("%sFailed to initialize plugin (%s).\n", L_ERRORxSTR, p->Name()); + gLog.Error(tr("%sFailed to initialize plugin (%s).\n"), L_ERRORxSTR, p->Name()); delete p; return NULL; } @@ -664,7 +670,7 @@ void CLicq::StartPlugin(CPlugin *p) { - gLog.Info("%sStarting plugin %s (version %s).\n", L_INITxSTR, p->Name(), + gLog.Info(tr("%sStarting plugin %s (version %s).\n"), L_INITxSTR, p->Name(), p->Version()); pthread_create( &p->thread_plugin, NULL, p->fMain_tep, licqDaemon); } @@ -686,7 +692,7 @@ if (handle == NULL) { - gLog.Error("%sUnable to load plugin (%s): %s\n", L_ERRORxSTR, _szName, + gLog.Error(tr("%sUnable to load plugin (%s): %s\n"), L_ERRORxSTR, _szName, error); delete p; return NULL; @@ -697,7 +703,7 @@ if (p->fName == NULL) { error = dlerror(); - gLog.Error("%sFailed to find LProto_Name in plugin (%s): %s\n", + gLog.Error(tr("%sFailed to find LProto_Name in plugin (%s): %s\n"), L_ERRORxSTR, _szName, error); delete p; return NULL; @@ -707,7 +713,7 @@ if (p->fVersion == NULL) { error = dlerror(); - gLog.Error("%sFailed to find LProto_Version in plugin (%s): %s\n", + gLog.Error(tr("%sFailed to find LProto_Version in plugin (%s): %s\n"), L_ERRORxSTR, _szName, error); delete p; return NULL; @@ -717,7 +723,7 @@ if (p->fId == NULL) { error = dlerror(); - gLog.Error("%sFailed to find LProto_Id in plugin (%s): %s\n", + gLog.Error(tr("%sFailed to find LProto_Id in plugin (%s): %s\n"), L_ERRORxSTR, _szName, error); delete p; return NULL; @@ -727,7 +733,7 @@ if (p->fInit == NULL) { error = dlerror(); - gLog.Error("%sFailed to find LProto_Init in plugin (%s): %s\n", + gLog.Error(tr("%sFailed to find LProto_Init in plugin (%s): %s\n"), L_ERRORxSTR, _szName, error); delete p; return NULL; @@ -737,7 +743,7 @@ if (p->fMain == NULL) { error = dlerror(); - gLog.Error("%sFailed to find LProto_Main in plugin (%s): %s\n", + gLog.Error(tr("%sFailed to find LProto_Main in plugin (%s): %s\n"), L_ERRORxSTR, _szName, error); delete p; return NULL; @@ -747,7 +753,7 @@ if (p->fMain_tep == NULL) { error = dlerror(); - gLog.Error("%sFailed to find LProto_Main_tep in plugin (%s): %s\n", + gLog.Error(tr("%sFailed to find LProto_Main_tep in plugin (%s): %s\n"), L_ERRORxSTR, _szName, error); delete p; return NULL; @@ -755,7 +761,7 @@ if (!(*p->fInit)()) { - gLog.Error("%sFailed to initialize plugin (%s).\n", L_ERRORxSTR, p->Name()); + gLog.Error(tr("%sFailed to initialize plugin (%s).\n"), L_ERRORxSTR, p->Name()); delete p; return NULL; } @@ -777,7 +783,7 @@ void CLicq::StartProtoPlugin(CProtoPlugin *p) { - gLog.Info("%sStarting protocol plugin %s (version %s).\n", L_INITxSTR, p->Name(), + gLog.Info(tr("%sStarting protocol plugin %s (version %s).\n"), L_INITxSTR, p->Name(), p->Version()); pthread_create(&p->thread_plugin, NULL, p->fMain_tep, licqDaemon); } @@ -805,7 +811,7 @@ if (list_plugins.size() == 0) { - gLog.Warn("%sNo plugins specified on the command-line (-p option).\n%sSee the README for more information.\n", + gLog.Warn(tr("%sNo plugins specified on the command-line (-p option).\n%sSee the README for more information.\n"), L_WARNxSTR, L_BLANKxSTR); return nResult; } @@ -865,12 +871,12 @@ if (iter == list_plugins.end()) { - gLog.Error("%sInvalid plugin id (%d) in exit signal.\n", L_ERRORxSTR, nExitId); + gLog.Error(tr("%sInvalid plugin id (%d) in exit signal.\n"), L_ERRORxSTR, nExitId); continue; } pthread_join((*iter)->thread_plugin, (void **)&nPluginResult); - gLog.Info("%sPlugin %s exited with code %d.\n", L_ENDxSTR, (*iter)->Name(), *nPluginResult); + gLog.Info(tr("%sPlugin %s exited with code %d.\n"), L_ENDxSTR, (*iter)->Name(), *nPluginResult); free (nPluginResult); // We should close the dynamic link but under linux this makes Qt crash //dlclose((*iter)->dl_handle); @@ -882,7 +888,7 @@ for (iter = list_plugins.begin(); iter != list_plugins.end(); iter++) { - gLog.Info("%sPlugin %s failed to exit.\n", L_WARNxSTR, (*iter)->Name()); + gLog.Info(tr("%sPlugin %s failed to exit.\n"), L_WARNxSTR, (*iter)->Name()); pthread_cancel( (*iter)->thread_plugin); } pthread_mutex_unlock(&mutex_plugins); @@ -902,7 +908,7 @@ void CLicq::PrintUsage() { - printf("%s version %s.\n" + printf(tr("%s version %s.\n" "Usage: Licq [-h] [-d #] [-b configdir] [-I] [-p plugin] [-o file] [ -- <plugin #1 parameters>] [-- <plugin #2 parameters>...]\n\n" " -h : this help screen (and any plugin help screens as well)\n" " -d : set what information is logged to standard output:\n" @@ -916,7 +922,7 @@ " -b : set the base directory for the config and data files (~/.licq by default)\n" " -I : force initialization of the given base directory\n" " -p : load the given plugin library\n" - " -o : redirect stderr to <file>, which can be a device (ie /dev/ttyp4)\n", + " -o : redirect stderr to <file>, which can be a device (ie /dev/ttyp4)\n"), PACKAGE, VERSION); } @@ -969,19 +975,19 @@ // Create the directory if necessary if (mkdir(BASE_DIR, 0700) == -1 && errno != EEXIST) { - fprintf(stderr, "Couldn't mkdir %s: %s\n", BASE_DIR, strerror(errno)); + fprintf(stderr, tr("Couldn't mkdir %s: %s\n"), BASE_DIR, strerror(errno)); return (false); } snprintf(cmd, sizeof(cmd) - 1, "%s/%s", BASE_DIR, HISTORY_DIR); if (mkdir(cmd, 0700) == -1 && errno != EEXIST) { - fprintf(stderr, "Couldn't mkdir %s: %s\n", cmd, strerror(errno)); + fprintf(stderr, tr("Couldn't mkdir %s: %s\n"), cmd, strerror(errno)); return (false); } snprintf(cmd, sizeof(cmd) - 1, "%s/%s", BASE_DIR, USER_DIR); if (mkdir(cmd, 0700) == -1 && errno != EEXIST) { - fprintf(stderr, "Couldn't mkdir %s: %s\n", cmd, strerror(errno)); + fprintf(stderr, tr("Couldn't mkdir %s: %s\n"), cmd, strerror(errno)); return (false); }