Hello,
Here are three little patches with bugfixes and small feature:
1. utf16msg.patch. Then licq receive UTF-16 encoded message it is
converted to codepage of locale (which is KOI8-U for me), but GUI
assume that message in codepage that set for user who send message (and
it is CP1251 in my case). So message shown wrong. Looks like ICQ6 sends
messages only in UTF-16 so I think this would be problem for many licq
users.
For resolving this issue I've changed function FromUTF16 a add parameter
- codepage to which convert message (instead of default locale). Also
I've reworked some code in icqd-srv.cpp to pass user codepage to
function FromUTF16 and handle special case of message from new user
where we don't know codepage (so default from locale used).
2. onlinesince.patch. Sometime then you point mouse cursor on user in
contact list which just coming online you can see strange value in
field Logged In: in userbox. This happened when clock on computer a bit
wrong and current time on computer can be smaller then timestamp of
user login received from server. This patch adds additional checking
for such case.
3. registeredtime.patch. I think we can save to disk "Registration Date"
value from userinfo. It is not per session value (I think wouldn't be
changed at all) and sometime there is need to look this value for
offline user.
With best regards,
Sergey Kononenko.
diff -urN licq.orig/include/licq_translate.h licq/include/licq_translate.h
--- licq.orig/include/licq_translate.h 2008-03-16 22:16:54.000000000 +0200
+++ licq/include/licq_translate.h 2008-03-21 16:51:49.000000000 +0200
@@ -32,8 +32,8 @@
// Muse use delete[] on the returned value if it is not NULL
char* ToUnicode(char* _sz, const char *_szFrom = "");
char* FromUnicode(char* _sz, const char* _szTo = "");
- char *FromUTF16(char *_sz, int nMsgLen = -1);
- char *ToUTF16(char *_sz, char *_szEncoding, size_t &nLen);
+ char *FromUTF16(char *_sz, const char *_szEncoding, int nMsgLen = -1);
+ char *ToUTF16(char *_sz, const char *_szEncoding, size_t &nLen);
char *NToRN(const char* _szOldStr);
char *RNToN(const char* _szOldStr);
bool utf16to8(unsigned long c, string &s);
diff -urN licq.orig/src/icqd-srv.cpp licq/src/icqd-srv.cpp
--- licq.orig/src/icqd-srv.cpp 2008-03-16 22:16:54.000000000 +0200
+++ licq/src/icqd-srv.cpp 2008-03-22 14:45:45.000000000 +0200
@@ -3037,15 +3037,40 @@
char* szMessage = new char[nMsgLen+1];
for (int i = 0; i < nMsgLen; i++)
szMessage[i] = msgTxt.UnpackChar();
-
szMessage[nMsgLen] = '\0';
- char* szMsg = 0;
+
+ bool ignore = false;
+ // Lock the user to add the message to their queue
+ ICQUser *u = gUserManager.FetchUser(szId, LICQ_PPID, LOCK_W);
+ if (u == NULL)
+ {
+ if (Ignore(IGNORE_NEWUSERS))
+ {
+ gLog.Info(tr("%sMessage from new user (%s), ignoring.\n"), L_SBLANKxSTR, szId);
+ //TODO
+ ignore = true;
+ }
+ else
+ {
+ gLog.Info(tr("%sMessage from new user (%s).\n"),
+ L_SBLANKxSTR, szId);
+ AddUserToList(szId, LICQ_PPID);
+ u = gUserManager.FetchUser(szId, LICQ_PPID, LOCK_W);
+ }
+ }
+ else
+ gLog.Info(tr("%sMessage through server from %s (%s).\n"), L_SRVxSTR,
+ u->GetAlias(), szId);
+
+ char* szMsg = NULL;
if (nEncoding == 2) // utf-8 or utf-16?
{
- char *szTmpMsg = 0;
- szTmpMsg = gTranslator.FromUTF16(szMessage, nMsgLen);
+ char *szTmpMsg = NULL;
+ char *szEncoding = ignore ? strdup("") : strdup(u->UserEncoding());
+ szTmpMsg = gTranslator.FromUTF16(szMessage, szEncoding, nMsgLen);
szMsg = gTranslator.RNToN(szTmpMsg);
delete [] szTmpMsg;
+ free(szEncoding);
}
else
szMsg = gTranslator.RNToN(szMessage);
@@ -3055,28 +3080,12 @@
CEventMsg *e = CEventMsg::Parse(szMsg, ICQ_CMDxRCV_SYSxMSGxONLINE, nTimeSent, 0);
delete [] szMsg;
- // Lock the user to add the message to their queue
- ICQUser *u = gUserManager.FetchUser(szId, LICQ_PPID, LOCK_W);
- if (u == NULL)
+ if (ignore)
{
- if (Ignore(IGNORE_NEWUSERS))
- {
- gLog.Info(tr("%sMessage from new user (%s), ignoring.\n"), L_SBLANKxSTR, szId);
- //TODO
- RejectEvent(strtoul(szId, (char **)NULL, 10), e);
- break;
- }
-
- gLog.Info(tr("%sMessage from new user (%s).\n"),
- L_SBLANKxSTR, szId);
-
- AddUserToList(szId, LICQ_PPID);
- u = gUserManager.FetchUser(szId, LICQ_PPID, LOCK_W);
+ RejectEvent(strtoul(szId, (char **)NULL, 10), e);
+ break;
}
- else
- gLog.Info(tr("%sMessage through server from %s (%s).\n"), L_SRVxSTR,
- u->GetAlias(), szId);
-
+
u->SetTyping(ICQ_TYPING_INACTIVEx0);
if (AddUserEvent(u, e))
diff -urN licq.orig/src/translate.cpp licq/src/translate.cpp
--- licq.orig/src/translate.cpp 2008-03-16 22:16:54.000000000 +0200
+++ licq/src/translate.cpp 2008-03-21 16:50:25.000000000 +0200
@@ -349,8 +349,8 @@
return szNewStr;
}
-//-----FromUTF8--------------------------------------------------------------
-char *CTranslator::FromUTF16(char *_sz, int nMsgLen)
+//-----FromUTF16-------------------------------------------------------------
+char *CTranslator::FromUTF16(char *_sz, const char *_szEncoding, int nMsgLen)
{
if (_sz == NULL) return NULL;
unsigned short nLen = nMsgLen > 0 ? nMsgLen : strlen(_sz);
@@ -362,8 +362,19 @@
nInSize = nLen;
nOutSize = nLen * 2;
-
- tr = iconv_open("", "UCS-2BE");
+
+ // Clean up for iconv, remove any spaces
+ int nToLen = strlen(_szEncoding);
+ int j = 0;
+ char *szTo = new char [nToLen+1];
+ for (int i = 0; i < nToLen; i++)
+ {
+ if (_szEncoding[i] != ' ')
+ szTo[j++] = _szEncoding[i];
+ }
+ szTo[j] = '\0';
+
+ tr = iconv_open(szTo, "UCS-2BE");
if (tr != (iconv_t)-1)
{
size_t ret = iconv(tr, (ICONV_CONST char**)&szIn, &nInSize, &szOut, &nOutSize);
@@ -396,7 +407,7 @@
}
//-----ToUTF16-----------------------------------------------------------------
-char *CTranslator::ToUTF16(char *_sz, char *_szEncoding, size_t &nSize)
+char *CTranslator::ToUTF16(char *_sz, const char *_szEncoding, size_t &nSize)
{
if (_sz == NULL) return NULL;
unsigned short nLen = strlen(_sz) * 3;
diff -urN licq.orig/plugins/qt4-gui/src/contactlist/contactuserdata.cpp licq/plugins/qt4-gui/src/contactlist/contactuserdata.cpp
--- licq.orig/plugins/qt4-gui/src/contactlist/contactuserdata.cpp 2008-03-16 22:20:17.000000000 +0200
+++ licq/plugins/qt4-gui/src/contactlist/contactuserdata.cpp 2008-03-21 20:19:58.000000000 +0200
@@ -737,7 +737,7 @@
if (config->popupOnlineSince() && !u->StatusOffline())
{
- time_t nLoggedIn = time(0) - u->OnlineSince();
+ time_t nLoggedIn = (time(0) > u->OnlineSince()) ? time(0) - u->OnlineSince() : 0;
unsigned long nWeek, nDay, nHour, nMinute;
nWeek = nLoggedIn / 604800;
nDay = (nLoggedIn % 604800) / 86400;
diff -urN licq.orig/plugins/qt-gui/src/userbox.cpp licq/plugins/qt-gui/src/userbox.cpp
--- licq.orig/plugins/qt-gui/src/userbox.cpp 2007-10-22 16:21:27.000000000 +0300
+++ licq/plugins/qt-gui/src/userbox.cpp 2008-03-21 20:01:40.000000000 +0200
@@ -1769,7 +1769,7 @@
if ((!u->StatusOffline()) && gMainWindow->m_bPopOnlineSince)
{
- time_t nLoggedIn = time(0) - u->OnlineSince();
+ time_t nLoggedIn = (time(0) > u->OnlineSince()) ? time(0) - u->OnlineSince() : 0;
unsigned long nWeek, nDay, nHour, nMinute;
nWeek = nLoggedIn / 604800;
nDay = (nLoggedIn % 604800) / 86400;
diff -urN licq.orig/src/user.cpp licq/src/user.cpp
--- licq.orig/src/user.cpp 2007-11-25 17:37:21.000000000 +0200
+++ licq/src/user.cpp 2008-03-21 19:59:11.000000000 +0200
@@ -2044,6 +2044,8 @@
m_nLastCounters[LAST_RECV_EVENT] = nLast;
m_fConf.ReadNum("LastCheckedAR", nLast, 0);
m_nLastCounters[LAST_CHECKED_AR] = nLast;
+ m_fConf.ReadNum("RegisteredTime", nLast, 0);
+ m_nRegisteredTime = nLast;
m_fConf.ReadNum("AutoAccept", m_nAutoAccept, 0);
m_fConf.ReadNum("StatusToUser", m_nStatusToUser, ICQ_STATUS_OFFLINE);
if (User()) // Only allow to keep a modified alias for user uins
@@ -3547,6 +3549,7 @@
m_fConf.WriteNum("LastSent", (unsigned long)LastSentEvent());
m_fConf.WriteNum("LastRecv", (unsigned long)LastReceivedEvent());
m_fConf.WriteNum("LastCheckedAR", (unsigned long)LastCheckedAutoResponse());
+ m_fConf.WriteNum("RegisteredTime", (unsigned long)RegisteredTime());
m_fConf.WriteNum("AutoAccept", m_nAutoAccept);
m_fConf.WriteNum("StatusToUser", m_nStatusToUser);
m_fConf.WriteStr("CustomAutoRsp", CustomAutoResponse());