Hi
This is the first patch for Xtraz status support. I'll try to explain
how it works so far.
Only the daemon has been modified so, when we connect if one of our
contacts has Xstatus set, we'll only see a text in the network log
window describing it. It would look something like:
Seba has xStatus (Working)
The description between ( ) indicates which icon should be displayed
in the gui.
We can retrieve the Xstatus title and description the same way we
would retrieve the Away message. At the moment, it only works if the
user appears as online. If the contact has Xstatus set and (s)he had a
timeout and became Away, the function will retrieve the Away message
instead of the Xstatus. This is due to the fact that I still haven't
created a new status (like online, Away, NA, etc).
When we retrieve the Xtatus it will be displayed in the Auto Response
window. You'll see 2 messages separated by a "-". The left part is the
title of the status and the right part is the actual message. This is
only provisional. I think we should discuss what would be the best way
to display it.
I've tested it for 2 days in my PC and I didn't have any issues, but
there's a lot to be done.
I'll keep on working on this. Please try the patch and feel free to
make any comments.
Thanks.
Seba
Index: src/icqd-srv.cpp
===================================================================
--- src/icqd-srv.cpp 2007-06-21 19:35:40.000000000 -0300
+++ src/icqd-srv.cpp 2007-07-04 13:38:00.000000000 -0300
@@ -39,6 +39,7 @@
#include "licq_countrycodes.h"
#include "licq_protoplugind.h"
+
void CICQDaemon::ProtoAddUser(const char *_szId, unsigned long _nPPID,
bool _bAuthRequired)
{
@@ -586,6 +587,7 @@
if (!u) return 0;
int nCmd;
+
switch (u->Status())
{
case ICQ_STATUS_AWAY:
@@ -2796,6 +2798,16 @@
{
version = "mICQ";
}
+ else {
+ 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]);
+ break;
+ }
+ }
+ }
+
}
delete [] caps;
@@ -3803,7 +3815,6 @@
nMsgID = packet.UnpackUnsignedLongBE(); // lower bits, what licq uses
nFormat = packet.UnpackUnsignedShortBE();
nUin = packet.UnpackUinString();
-
u = gUserManager.FetchUser(nUin, LOCK_W);
if (u == NULL)
{
@@ -3872,7 +3883,6 @@
nSequence = packet.UnpackUnsignedShortBE();
packet.incDataPosRead(nLen - 2);
packet >> nMsgType;
-
if (memcmp(GUID, PLUGIN_NORMAL, GUID_LENGTH) != 0)
{
unsigned char nChannel = ICQ_CHNxUNKNOWN;
@@ -3888,13 +3898,37 @@
}
packet >> nAckFlags >> nMsgFlags >> nLen;
+ char szMessage[600];
+ if (nMsgType == 0x1A) { // Xstatus
+ gLog.Warn(tr("%s Es una rta de XtraStatus!\n"), L_SRVxSTR);
+ nLen = 500;
+ for (unsigned short i = 0; i < 96; i++) {
+ packet >> szMessage[i];
+ }
+ }
- char szMessage[nLen + 1];
+ //char szMessage[nLen + 1];
for (unsigned short i = 0; i < nLen; i++)
packet >> szMessage[i];
szMessage[nLen] = '\0';
gTranslator.ServerToClient(szMessage);
-
+ if (nMsgType == 0x1A) { // Xstatus
+ char *desc, *title, *temp;
+ if ((desc=strstr(szMessage,"<desc>"))!= NULL) {
+ temp=strstr(szMessage,"</desc>");
+ temp[0]=0;
+ desc=desc+12;
+ }
+ if ((title=strstr(szMessage,"<title>"))!= NULL) {
+ temp=strstr(szMessage,"</title>");
+ temp[0]=0;
+ title=title+13;
+ }
+ strcpy(szMessage,title);
+ strcat(szMessage, " - ");
+ strcat(szMessage, desc);
+
+ }
if (nAckFlags == ICQ_TCPxACK_REFUSE)
{
pExtendedAck = new CExtendedAck(false, 0, szMessage);
Index: src/icqpacket.cpp
===================================================================
--- src/icqpacket.cpp 2007-06-15 12:22:10.000000000 -0300
+++ src/icqpacket.cpp 2007-07-04 13:41:40.000000000 -0300
@@ -923,7 +923,7 @@
CPU_CapabilitySettings::CPU_CapabilitySettings()
: CPU_CommonFamily(ICQ_SNACxFAM_LOCATION, ICQ_SNACxLOC_SETxUSERxINFO)
{
- char data[7][CAP_LENGTH];
+ char data[8][CAP_LENGTH];
m_nSize += 4 + sizeof(data);
InitBuffer();
@@ -934,6 +934,7 @@
memcpy(data[4], ICQ_CAPABILITY_AIMxINTER, CAP_LENGTH);
memcpy(data[5], ICQ_CAPABILITY_RTFxMSGS, CAP_LENGTH);
memcpy(data[6], ICQ_CAPABILITY_ICHAT, CAP_LENGTH);
+ memcpy(data[7], ICQ_CAPABILITY_XTRAZ, CAP_LENGTH);
// Send our licq version
data[3][12] = INT_VERSION / 1000;
@@ -2029,7 +2030,7 @@
ICQ_CAPABILITY_SRVxRELAY, nMsgID1, nMsgID2)
{
m_nSize += 54;
-
+
m_nMsgFlags = _nMsgFlags;
m_nSequence = _nSequence;
@@ -2043,7 +2044,8 @@
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: m_nSubCommand = ICQ_CMDxTCP_READxAWAYxMSG; break;
+ default: CPU_ReqXtrazMessage(u, ICQ_CMDxTCP_READxXSTATUSxMSG, m_nMsgFlags, _bAck, _nSequence, nMsgID1, nMsgID2); return; break;
}
InitBuffer();
}
@@ -2053,6 +2055,47 @@
}
}
+void CPU_AdvancedMessage::CPU_ReqXtrazMessage(ICQUser *u, unsigned short _nMsgType,
+ unsigned short _nMsgFlags, bool _bAck, unsigned short _nSequence,
+ unsigned long nMsgID1, unsigned long nMsgID2)
+{
+ m_nSize += 347;
+
+ m_nMsgFlags = _nMsgFlags;
+ m_nSequence = _nSequence;
+ m_nSubCommand = ICQ_CMDxTCP_READxXSTATUSxMSG;
+ m_bDirectInfo = 0;
+ InitBuffer();
+ if (m_nSubCommand == ICQ_CMDxTCP_READxXSTATUSxMSG) {
+ char tempXtraz[273];
+ buffer->PackUnsignedShort(0x004F);
+ buffer->PackUnsignedShort(0x603B);
+ buffer->PackUnsignedShort(0xEFB3);
+ buffer->PackUnsignedShort(0x2AD8);
+ buffer->PackUnsignedShort(0x456C);
+ buffer->PackUnsignedShort(0xE0A4);
+ buffer->PackUnsignedShort(0x5A9C);
+ buffer->PackUnsignedShort(0x675E);
+ buffer->PackUnsignedShort(0x65E8);
+ buffer->PackUnsignedShort(0x0008);
+ buffer->PackUnsignedShort(0x002A);
+ buffer->PackUnsignedShort(0x0000);
+ snprintf(tempXtraz, 43, "%s", "Script Plug-in: Remote Notification Arrive"); // text
+ buffer->Pack(tempXtraz,43);
+ buffer->PackChar(0x00);
+ buffer->PackChar(0x01);
+ buffer->PackUnsignedLongBE(0x00000000);
+ buffer->PackUnsignedLongBE(0x00000000);
+ buffer->PackUnsignedLongBE(0x00000000);
+ buffer->PackUnsignedShort(0x0114);
+ 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);
+ }
+}
+
void CPU_AdvancedMessage::InitBuffer()
{
CPU_Type2Message::InitBuffer();
Index: include/licq_icq.h
===================================================================
--- include/licq_icq.h 2007-05-09 19:16:08.000000000 -0300
+++ include/licq_icq.h 2007-06-29 19:32:59.000000000 -0300
@@ -7,8 +7,8 @@
#define MODE_INDIRECT 0x02
#define MODE_DENIED 0x01 // user denies direct connection from "any" user
-#define ICQ_VERSION 8
-const unsigned short ICQ_VERSION_TCP = 0x0008;
+#define ICQ_VERSION 9
+const unsigned short ICQ_VERSION_TCP = 0x0009;
#define LICQ_WITHSSL 0x7D800000
#define LICQ_WITHOUTSSL 0x7D000000
@@ -323,6 +323,8 @@
const unsigned short ICQ_CMDxTCP_READxDNDxMSG = 0x03EB;
const unsigned short ICQ_CMDxTCP_READxFFCxMSG = 0x03EC;
const unsigned char ICQ_CMDxTCP_HANDSHAKE = 0xFF;
+const unsigned short ICQ_CMDxTCP_READxXSTATUSxMSG = 0x001A;
+
// Sub Commands
const unsigned short ICQ_CMDxSUB_MSG = 0x0001;
@@ -598,6 +600,40 @@
{ 0xDD, 0xCF, 0x0E, 0xA9, 0x71, 0x95, 0x40, 0x48, 0xA9, 0xC6, 0x41, 0x32, 0x06, 0xD6, 0xF2, 0x80 }
};
+const char XtraAwayNames[XTRA_AWAY_COUNT][0x20] = {
+ "Angry",
+ "Taking a bath",
+ "Tired",
+ "Party",
+ "Drinking beer",
+ "Thinking",
+ "Eating",
+ "Watching TV",
+ "Meeting",
+ "Coffee",
+ "Listening to music",
+ "Business",
+ "Shooting",
+ "Having fun",
+ "On the phone",
+ "Gaming",
+ "Studying",
+ "Shopping",
+ "Feeling sick",
+ "Sleeping",
+ "Surfing",
+ "Browsing",
+ "Working",
+ "Typing",
+ "Picnic",
+ "Cooking",
+ "Smoking",
+ "I'm high",
+ "On WC",
+ "To be or not to be",
+ "Watching pro7 on TV",
+ "Love"
+};
// For protocol plugins
Index: include/licq-packets.h
===================================================================
--- include/licq_packets.h 2007-06-21 19:35:39.000000000 -0300
+++ include/licq_packets.h 2007-07-03 17:33:00.000000000 -0300
@@ -744,12 +744,36 @@
unsigned long nID2 = 0);
protected:
void InitBuffer();
+ void CPU_ReqXtrazMessage(ICQUser *u, unsigned short _nMsgType,
+ unsigned short _nMsgFlags, bool _bAck,
+ unsigned short _nSequence,
+ unsigned long nID1 = 0,
+ unsigned long nID2 = 0);
unsigned short m_nMsgType;
unsigned short m_nMsgFlags;
unsigned short m_nSequence;
};
+//-----AdvancedMessage---------------------------------------------------------
+/*class CPU_ReqXtrazMessage : public CPU_Type2Message
+{
+public:
+ CPU_ReqXtrazMessage(ICQUser *u, unsigned short _nMsgType,
+ unsigned short _nMsgFlags, bool _bAck,
+ unsigned short _nSequence,
+ unsigned long nID1 = 0,
+ unsigned long nID2 = 0);
+protected:
+ void InitBuffer();
+
+ unsigned short m_nMsgType;
+ unsigned short m_nMsgFlags;
+ unsigned short m_nSequence;
+};*/
+
+
+
//-----ChatRequest-------------------------------------------------------------
class CPU_ChatRequest : public CPU_AdvancedMessage
{