Hi, this is a small patch which solves a tiny problem that the patch
before had. When I asked for the XStatus message, I had written an
arbitrary fixed user ID just to see if it worked (it actually does!),
but it's not how it should properly be done, so now we ask it by
passing our own user ID.
I've also added a new status, which I invented, so now the user has
Xtraz status and we can ask for his/her message no matter is he's
idle. Please let me know if another status should be used. I simply
chose status 0x0008, which wasn't used.
Jon, so far I didn't follow your advice to ask for the status message
when we connect, but as you suggested, I think it's better to do it at
that moment. ;-) I've created the CPU_ReqXtrazMessage method inside
the CPU_AdvancedMessage class. Of course that doesn't work if we want
to ask for the xtraz message on connect. Should I write a new method
inside the CICQDaemon class in order to retrieve the XStatus message
or should it be done somewhere else?
I'm thinking that once we retrieve the status title and description,
we can show the title as the status (instead of Xtraz, as it is now)
and the description should be showed as the auto responde. What do you
think? After that, the only thing left would be setting the proper
icon. I believe that at that point we could say we have XStatus
support. At least to retrieve it.
Next step is setting our own status, but that's a different task.
Well, comments and suggestions are more than welcome. :-) Thanks!
Seba
Index: icqd-srv.cpp
===================================================================
--- src/icqd-srv.cpp 2007-07-05 09:12:25.000000000 -0300
+++ src/icqd-srv.cpp 2007-07-06 09:55:51.000000000 -0300
@@ -600,6 +600,8 @@
nCmd = ICQ_CMDxTCP_READxOCCUPIEDxMSG; break;
case ICQ_STATUS_FREEFORCHAT:
nCmd = ICQ_CMDxTCP_READxFFCxMSG; break;
+ case ICQ_STATUS_XTRAZ:
+ nCmd = ICQ_CMDxTCP_READxXSTATUSxMSG; break;
default:
nCmd = ICQ_CMDxTCP_READxAWAYxMSG; break;
}
@@ -2802,7 +2804,10 @@
for (int xc=0; xc < XTRA_AWAY_COUNT; xc++) {
if (memcmp(caps+(i * CAP_LENGTH), XtraAwayCaps[xc],
16) == 0) {
- gLog.Info(tr("%s%s has xStatus (%s)\n"), L_SRVxSTR, u->GetAlias(),XtraAwayNames[xc]);
+ nNewStatus = ICQ_STATUS_XTRAZ;
+ ChangeUserStatus(u, nNewStatus);
+ gLog.Info(tr("%s%s (%s) changed status: %s (%s)\n"),
+ L_SRVxSTR, u->GetAlias(), u->IdString(), u->StatusStr(), XtraAwayNames[xc]);
break;
}
}
Index: icqpacket.cpp
===================================================================
--- src/icqpacket.cpp 2007-07-05 09:12:25.000000000 -0300
+++ src/icqpacket.cpp 2007-07-05 10:34:23.000000000 -0300
@@ -2044,8 +2044,9 @@
case ICQ_STATUS_DND: m_nSubCommand = ICQ_CMDxTCP_READxDNDxMSG; break;
case ICQ_STATUS_OCCUPIED: m_nSubCommand = ICQ_CMDxTCP_READxOCCUPIEDxMSG; break;
case ICQ_STATUS_FREEFORCHAT: m_nSubCommand = ICQ_CMDxTCP_READxFFCxMSG; break;
- //default: m_nSubCommand = ICQ_CMDxTCP_READxAWAYxMSG; break;
- default: CPU_ReqXtrazMessage(u, ICQ_CMDxTCP_READxXSTATUSxMSG, m_nMsgFlags, _bAck, _nSequence, nMsgID1, nMsgID2); return; break;
+ case ICQ_STATUS_XTRAZ: CPU_ReqXtrazMessage(u, ICQ_CMDxTCP_READxXSTATUSxMSG, m_nMsgFlags, _bAck, _nSequence, nMsgID1, nMsgID2); return; break;
+ default: m_nSubCommand = ICQ_CMDxTCP_READxAWAYxMSG; break;
+ //default: CPU_ReqXtrazMessage(u, ICQ_CMDxTCP_READxXSTATUSxMSG, m_nMsgFlags, _bAck, _nSequence, nMsgID1, nMsgID2); return; break;
}
InitBuffer();
}
@@ -2059,7 +2060,12 @@
unsigned short _nMsgFlags, bool _bAck, unsigned short _nSequence,
unsigned long nMsgID1, unsigned long nMsgID2)
{
- m_nSize += 347;
+ char szUin[13];
+ ICQOwner *o = gUserManager.FetchOwner(LOCK_R);
+ snprintf(szUin, 13, "%lu", o->Uin());
+ unsigned long nUinLen = strlen(szUin);
+
+ m_nSize += 339 + nUinLen;
m_nMsgFlags = _nMsgFlags;
m_nSequence = _nSequence;
@@ -2091,9 +2097,10 @@
buffer->PackUnsignedShort(0x0000);
buffer->PackUnsignedShort(0x0110);
buffer->PackUnsignedShort(0x0000);
- snprintf(tempXtraz, 273, "%s", "<N><QUERY><Q><PluginID>srvMng</PluginID></Q></QUERY><NOTIFY><srv><id>cAwaySrv</id><req><id>AwayStat</id><trans>2</trans><senderId>57974274</senderId></req></srv></NOTIFY></N>\r\n"); // text
- buffer->Pack(tempXtraz,272);
- }
+ snprintf(tempXtraz, 265+nUinLen, "<N><QUERY><Q><PluginID>srvMng</PluginID></Q></QUERY><NOTIFY><srv><id>cAwaySrv</id><req><id>AwayStat</id><trans>2</trans><senderId>%s</senderId></req></srv></NOTIFY></N>\r\n", szUin); // text
+ buffer->Pack(tempXtraz,264+nUinLen);
+ gUserManager.DropOwner();
+ }
}
void CPU_AdvancedMessage::InitBuffer()
@@ -5031,7 +5038,7 @@
gTranslator.ClientToServer(m_szMessage);
m_nSize -= m_nMsgLen;
- m_nMsgLen = strlen(m_szMessage) + 1;
+ m_nMsgLen = strlen(m_szMessage);
m_nSize += m_nMsgLen;
}
Index: user.cpp
===================================================================
--- src/user.cpp 2007-06-21 19:35:40.000000000 -0300
+++ src/user.cpp 2007-07-05 10:08:23.000000000 -0300
@@ -2450,7 +2450,8 @@
else if (m_nStatus & ICQ_STATUS_AWAY) return ICQ_STATUS_AWAY;
else if (m_nStatus & ICQ_STATUS_FREEFORCHAT) return ICQ_STATUS_FREEFORCHAT;
else if ((m_nStatus & 0xFF) == 0x00) return ICQ_STATUS_ONLINE;
- else return (ICQ_STATUS_OFFLINE - 1);
+ else if (m_nStatus & ICQ_STATUS_XTRAZ) return ICQ_STATUS_XTRAZ;
+ else return (ICQ_STATUS_OFFLINE - 1);
}
void ICQUser::SetStatusOffline()
@@ -2752,6 +2753,7 @@
else if (n & ICQ_STATUS_NA) return b ? tr("(Not Available)") : tr("Not Available");
else if (n & ICQ_STATUS_AWAY) return b ? tr("(Away)") : tr("Away");
else if (n & ICQ_STATUS_FREEFORCHAT) return b ? tr("(Free for Chat)") : tr("Free for Chat");
+ else if (n & ICQ_STATUS_XTRAZ) return b ? tr("(Xstatus)") : tr("Xstatus");
else if (n << 24 == 0x00) return b ? tr("(Online)") : tr("Online");
else return "Unknown";
}
@@ -2765,6 +2767,7 @@
else if (n & ICQ_STATUS_NA) return b ? tr("(N/A)") : tr("N/A");
else if (n & ICQ_STATUS_AWAY) return b ? tr("(Away)") : tr("Away");
else if (n & ICQ_STATUS_FREEFORCHAT) return b ? tr("(FFC)") : tr("FFC");
+ else if (n & ICQ_STATUS_XTRAZ) return b ? tr("(Xtra)") : tr("Xtra");
else if (n << 24 == 0x00) return b ? tr("(On)") : tr("On");
else return "???";
}
Index: licq_icq.h
===================================================================
--- include/licq_icq.h 2007-07-05 09:12:25.000000000 -0300
+++ include/licq_icq.h 2007-07-05 10:09:31.000000000 -0300
@@ -378,6 +378,7 @@
const unsigned short ICQ_STATUS_NA = 0x0004;
const unsigned short ICQ_STATUS_OCCUPIED = 0x0010;
const unsigned short ICQ_STATUS_FREEFORCHAT = 0x0020;
+const unsigned short ICQ_STATUS_XTRAZ = 0x0008; // Not a real status
// TCP status for ack packets
const unsigned short ICQ_TCPxACK_ONLINE = 0x0000;