[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdenetwork/kopete/protocols/qq
From:       Hui Jin <blueangel.jin () gmail ! com>
Date:       2006-09-20 21:41:34
Message-ID: 1158788494.851014.12785.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 586896 by blueangel:

Still in refactory



 M  +12 -12    libeva.cpp  
 M  +36 -34    libeva.h  
 M  +33 -33    qqnotifysocket.cpp  


--- trunk/KDE/kdenetwork/kopete/protocols/qq/libeva.cpp #586895:586896
@@ -228,7 +228,7 @@
 	ByteArray loginToken( uint id, ushort sequence )
 	{
 		ByteArray data(16);
-		data += header(id, RequestLoginToken, sequence);
+		data += header(id, Command::RequestLoginToken, sequence);
 		data += '\0';
 		data += Tail;
 		setLength( data );
@@ -254,7 +254,7 @@
 		memset( login.data()+login.size(), 0, login.capacity()-login.size() );
 		login.setSize( login.capacity() );
 
-		data += header( id, Login, sequence );
+		data += header( id, Command::Login, sequence );
 		data += initKey;
 		data += Packet::encrypt( login, initKey );
 		data += Tail;
@@ -270,7 +270,7 @@
 		ByteArray text(1);
 		text += TransferKey;
 		
-		return Packet::create(id, RequestKey, sequence, key, text );
+		return Packet::create(id, Command::RequestKey, sequence, key, text );
 	}
 
 	ByteArray allContacts( uint id, ushort sequence, const ByteArray& key, short pos )
@@ -282,7 +282,7 @@
 		text += '\0';
 		text += '\1';
 
-		return Packet::create(id, AllContacts, sequence, key, text );
+		return Packet::create(id, Command::AllContacts, sequence, key, text );
 	}
 
 	ByteArray statusUpdate( uint id, ushort sequence, const ByteArray& key, uchar \
status ) @@ -290,7 +290,7 @@
 		ByteArray text(5);
 		text += status;
 		text += (int) 0;
-		return Packet::create(id, ChangeStatus, sequence, key, text );
+		return Packet::create(id, Command::ChangeStatus, sequence, key, text );
 	}
 
 	ByteArray contactDetail( uint id, ushort sequence, const ByteArray& key, int qqId )
@@ -298,7 +298,7 @@
 		ByteArray text(32);
 		snprintf( text.c_str(), 31, "%d", qqId );
 		text.setSize( strlen( text.c_str() ) );
-		return Packet::create(id, ContactDetail, sequence, key, text );
+		return Packet::create(id, Command::UserInfo, sequence, key, text );
 	}
 
 	ByteArray groupNames( uint id, ushort sequence, const ByteArray& key )
@@ -308,7 +308,7 @@
 		text += '\2' ;
 		text += (int) 0;
 
-		return Packet::create(id, GroupNames, sequence, key, text );
+		return Packet::create(id, Command::GroupNames, sequence, key, text );
 	}
 
 	ByteArray downloadGroups( uint id, ushort sequence, const ByteArray& key, int pos )
@@ -319,7 +319,7 @@
 		text += (int) 0;
 		text += htonl(pos);
 
-		return Packet::create(id, DownloadGroups, sequence, key, text );
+		return Packet::create(id, Command::DownloadGroups, sequence, key, text );
 	}
 
 	ByteArray textMessage( uint id, ushort sequence, const ByteArray& key, 
@@ -329,19 +329,19 @@
 		ByteArray text( 65536 );
 		text += messageHeader( id, toId, transferKey, IMText, sequence, time(NULL));
 		text += encodeMessage( message );
-		return Packet::create(id, SendMsg, sequence, key, text );
+		return Packet::create(id, Command::SendMsg, sequence, key, text );
 	}
 
 	ByteArray messageReply(uint id, ushort sequence, const ByteArray& key, const \
ByteArray& text )  {
-		return Packet::create(id, ReceiveMsg, sequence, key, text );
+		return Packet::create(id, Command::ReceiveMsg, sequence, key, text );
 	}
 
 	ByteArray heartbeat(uint id, ushort sequence, const ByteArray& key )
 	{
 		ByteArray text(4);
 		text += id;
-		return Packet::create(id, Heartbeat, sequence, key, text );
+		return Packet::create(id, Command::Heartbeat, sequence, key, text );
 	}
 
 	ByteArray onlineContacts(uint id, ushort sequence, const ByteArray& key, uchar pos \
) @@ -352,7 +352,7 @@
 		text += uchar(0x00);
 		text += uchar(0x00);
 		text += uchar(0x00);
-		return Packet::create(id, ContactsOnline, sequence, key, text );
+		return Packet::create(id, Command::ContactsOnline, sequence, key, text );
 	}
 		
 }
--- trunk/KDE/kdenetwork/kopete/protocols/qq/libeva.h #586895:586896
@@ -24,40 +24,42 @@
 	static const uchar Tail = 0x03;
 
 	// command sent to the server
-	static const ushort Logout = 0x0001;
-	static const ushort Heartbeat = 0x0002;
-	static const ushort UpdateInfo = 0x0004;
-	static const ushort Search = 0x0005;
-	static const ushort ContactDetail = 0x0006;
-	static const ushort AddFriend = 0x0009;
-	static const ushort RemoveFriend = 0x000A;
-	static const ushort AuthInvite = 0x000B;
-	static const ushort ChangeStatus = 0x000D;
-	static const ushort AckSysMsg = 0x0012;
-	static const ushort SendMsg = 0x0016;
-	static const ushort ReceiveMsg = 0x0017;
-	static const ushort RemoveMe = 0x001C;
-	static const ushort RequestKey = 0x001D;
-	static const ushort GetCell = 0x0021;
-	static const ushort Login = 0x0022;
-	static const ushort AllContacts= 0x0026;
-	static const ushort ContactsOnline = 0x0027;
-	static const ushort GetCell2 = 0x0029;
-	// Special Interest Group == Qun( in Chinese )
-	static const ushort SIP = 0x0030; 
-	static const ushort Test = 0x0031;
-	static const ushort GroupNames = 0x003C;
-	static const ushort UploadGroups = 0x003D;
-	static const ushort Memo = 0x003E;
-	static const ushort DownloadGroups = 0x0058;
-	// Level determines how active the use is
-	static const ushort GetLevel = 0x005C;
-	static const ushort RequestLoginToken = 0x0062;
-	static const ushort ExtraInfo = 0x0065;
-	static const ushort Signature = 0x0067;
-	static const ushort ReceiveSysMsg = 0x0080;
-	static const ushort ContactStausChanged = 0x0081;
-
+	namespace Command {
+		static const ushort Logout = 0x0001;
+		static const ushort Heartbeat = 0x0002;
+		static const ushort UpdateInfo = 0x0004;
+		static const ushort Search = 0x0005;
+		static const ushort UserInfo = 0x0006;
+		static const ushort AddBuddy = 0x0009;
+		static const ushort RemoveBuddy = 0x000A;
+		static const ushort AuthInvite = 0x000B;
+		static const ushort ChangeStatus = 0x000D;
+		static const ushort AckSysMsg = 0x0012;
+		static const ushort SendMsg = 0x0016;
+		static const ushort ReceiveMsg = 0x0017;
+		static const ushort RemoveMe = 0x001C;
+		static const ushort RequestKey = 0x001D;
+		static const ushort GetCell = 0x0021;
+		static const ushort Login = 0x0022;
+		static const ushort AllContacts= 0x0026;
+		static const ushort ContactsOnline = 0x0027;
+		static const ushort GetCell2 = 0x0029;
+		// Special Interest Group == Qun( in Chinese )
+		static const ushort SIP = 0x0030; 
+		static const ushort Test = 0x0031;
+		static const ushort GroupNames = 0x003C;
+		static const ushort UploadGroups = 0x003D;
+		static const ushort Memo = 0x003E;
+		static const ushort DownloadGroups = 0x0058;
+		// Level determines how active the use is
+		static const ushort GetLevel = 0x005C;
+		static const ushort RequestLoginToken = 0x0062;
+		static const ushort ExtraInfo = 0x0065;
+		static const ushort Signature = 0x0067;
+		static const ushort ReceiveSysMsg = 0x0080;
+		static const ushort ContactStausChanged = 0x0081;
+	};
+	
 	// Options
 	static const uchar NormalLogin = 0x0A;
 	static const uchar InvisibleLogin = 0x28;
--- trunk/KDE/kdenetwork/kopete/protocols/qq/qqnotifysocket.cpp #586895:586896
@@ -117,11 +117,11 @@
 	kDebug( 14140 ) << "command = " << packet.command() << endl;
 	switch( packet.command() )
 	{
-		case Eva::RequestLoginToken :
+		case Eva::Command::RequestLoginToken :
 			text = Eva::Packet::loginToken( packet.body() );
 			break;
 
-		case Eva::Login :
+		case Eva::Command::Login :
 			text = Eva::Packet::decrypt( packet.body(), m_passwordKey );
 			if( text.size() == 0 )
 				text = Eva::Packet::decrypt( packet.body(), initKey );
@@ -139,12 +139,12 @@
 	switch( packet.command() )
 	{
 		// FIXME: use table-driven pattern ?
-		case Eva::Logout :
-		case Eva::Heartbeat:
+		case Eva::Command::Logout :
+		case Eva::Command::Heartbeat:
 			break;
-		case Eva::UpdateInfo :
-		case Eva::Search :
-		case Eva::ContactDetail :
+		case Eva::Command::UpdateInfo :
+		case Eva::Command::Search :
+		case Eva::Command::UserInfo :
 		{
 			// map std::map to QMap
 			std::map<const char*, std::string, Eva::ltstr> dict = \
Eva::Packet::contactDetail(text); @@ -161,11 +161,11 @@
 
 			
 			break;
-		case Eva::AddFriend :
-		case Eva::RemoveFriend :
-		case Eva::AuthInvite :
+		case Eva::Command::AddBuddy:
+		case Eva::Command::RemoveBuddy:
+		case Eva::Command::AuthInvite :
 			break;
-		case Eva::ChangeStatus :
+		case Eva::Command::ChangeStatus :
 			if( Eva::Packet::replyCode(text) == Eva::ChangeStatusOK )
 			{
 				kDebug( 14140 ) << "ChangeStatus ok" << endl;
@@ -175,10 +175,10 @@
 				disconnect();
 			break;
 
-		case Eva::AckSysMsg :
-		case Eva::SendMsg :
+		case Eva::Command::AckSysMsg :
+		case Eva::Command::SendMsg :
 			break;
-		case Eva::ReceiveMsg :
+		case Eva::Command::ReceiveMsg :
 		{
 			Eva::MessageEnvelop envelop(text);
 			kDebug(14140) << "Received message from " << envelop.sender << " to " << \
envelop.receiver << " type=" << envelop.type << endl; @@ -234,10 +234,10 @@
 			break;
 		}
 
-		case Eva::RemoveMe :
+		case Eva::Command::RemoveMe :
 			break;
 
-		case Eva::RequestKey :
+		case Eva::Command::RequestKey :
 		{
 			char type = text.data()[0];
 			char reply = text.data()[1];
@@ -257,10 +257,10 @@
 			break;
 		}
 
-		case Eva::GetCell :
+		case Eva::Command::GetCell :
 			break;
 
-		case Eva::Login :
+		case Eva::Command::Login :
 			switch( Eva::Packet::replyCode(text)  )
 			{
 				case Eva::LoginOK:
@@ -322,7 +322,7 @@
 
 			break;
 
-		case Eva::AllContacts:
+		case Eva::Command::AllContacts:
 			/*
 			{
 				len = 2;
@@ -335,39 +335,39 @@
 			}
 			*/
 			break;
-		case Eva::ContactsOnline :
+		case Eva::Command::ContactsOnline :
 			
 			break;
-		case Eva::GetCell2 :
-		case Eva::SIP :
-		case Eva::Test :
+		case Eva::Command::GetCell2 :
+		case Eva::Command::SIP :
+		case Eva::Command::Test :
 			break;
-		case Eva::GroupNames :
+		case Eva::Command::GroupNames :
 			groupNames( text );
 			break;
 
-		case Eva::UploadGroups :
-		case Eva::Memo :
+		case Eva::Command::UploadGroups :
+		case Eva::Command::Memo :
 			break;
-		case Eva::DownloadGroups :
+		case Eva::Command::DownloadGroups :
 			groupInfos( text );
 			break;
 
-		case Eva::GetLevel :
+		case Eva::Command::GetLevel :
 			break;
 
-		case Eva::RequestLoginToken :
+		case Eva::Command::RequestLoginToken :
 			m_token = text;
 			kDebug( 14140 ) << "command = " << packet.command() << ": token = " << 
 				QByteArray ( m_token.c_str(), m_token.size() ) << endl;
 			sendPacket( Eva::login( m_qqId, m_id++, m_passwordKey, m_token, m_loginMode ) );
 			break;
 
-		case Eva::ExtraInfo :
-		case Eva::Signature :
-		case Eva::ReceiveSysMsg :
+		case Eva::Command::ExtraInfo :
+		case Eva::Command::Signature :
+		case Eva::Command::ReceiveSysMsg :
 			break;
-		case Eva::ContactStausChanged :
+		case Eva::Command::ContactStausChanged :
 		{
 			kDebug( 14140 ) << "contact status signal" << endl;
 			Eva::ContactStatus cs(text.data());


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic