Changeset - 9813552ebfe1
[Not reviewed]
0 3 0
Jan Kaluza - 10 years ago 2015-12-03 12:19:34
jkaluza@redhat.com
Send api version to backend so it can use future features based on this version number
3 files changed with 24 insertions and 0 deletions:
0 comments (0 inline, 0 general)
include/transport/NetworkPluginServer.h
Show inline comments
 
@@ -40,12 +40,14 @@
 
#include "Swiften/Parser/XMPPParserClient.h"
 
#include "Swiften/Serializer/XMPPSerializer.h"
 
#include <Swiften/Version.h>
 
#include <Swiften/FileTransfer/FileTransfer.h>
 
#define HAVE_SWIFTEN_3  (SWIFTEN_VERSION >= 0x030000)
 

	
 
#define NETWORK_PLUGIN_API_VERSION (1)
 

	
 
namespace Transport {
 

	
 
class UserManager;
 
class User;
 
class Component;
 
class Buddy;
 
@@ -157,12 +159,13 @@ class NetworkPluginServer : Swift::XMPPParserClient {
 
		void handlePIDTerminated(unsigned long pid);
 
	private:
 
		void send(boost::shared_ptr<Swift::Connection> &, const std::string &data);
 

	
 
		void pingTimeout();
 
		void sendPing(Backend *c);
 
		void sendAPIVersion(Backend *c);
 
		Backend *getFreeClient(bool acceptUsers = true, bool longRun = false, bool check = false);
 
		void connectWaitingUsers();
 
		void loginDelayFinished();
 
		void handleRawIQReceived(boost::shared_ptr<Swift::IQ> iq);
 
		void handleRawPresenceReceived(boost::shared_ptr<Swift::Presence> presence);
 

	
include/transport/protocol.proto
Show inline comments
 
@@ -148,12 +148,16 @@ message FileTransferData {
 
}
 

	
 
message BackendConfig {
 
	required string config = 1;
 
}
 

	
 
message APIVersion {
 
	required int32 version = 1;
 
}
 

	
 
message WrapperMessage {
 
	enum Type { 
 
		TYPE_CONNECTED 				= 1;
 
		TYPE_DISCONNECTED 			= 2;
 
		TYPE_LOGIN 					= 3;
 
		TYPE_LOGOUT 				= 4;
 
@@ -184,11 +188,12 @@ message WrapperMessage {
 
		TYPE_BACKEND_CONFIG			= 30;
 
		TYPE_QUERY					= 31;
 
		TYPE_ROOM_LIST				= 32;
 
		TYPE_CONV_MESSAGE_ACK		= 33;
 
		TYPE_RAW_XML				= 34;
 
		TYPE_BUDDIES				= 35;
 
		TYPE_API_VERSION			= 36;
 
	}
 
	required Type type = 1;
 
	optional bytes payload = 2;
 
}
 
;
src/NetworkPluginServer.cpp
Show inline comments
 
@@ -1933,12 +1933,28 @@ void NetworkPluginServer::sendPing(Backend *c) {
 
		send(c->connection, message);
 
		c->pongReceived = false;
 
	}
 
// 	LOG4CXX_INFO(logger, "PING to " << c);
 
}
 

	
 
void NetworkPluginServer::sendAPIVersion(Backend *c) {
 

	
 
	pbnetwork::APIVersion apiver;
 
	apiver.set_version(NETWORK_PLUGIN_API_VERSION);
 

	
 
	std::string message;
 
	apiver.SerializeToString(&message);
 

	
 
	WRAP(message, pbnetwork::WrapperMessage_Type_TYPE_API_VERSION);
 

	
 
	if (c->connection) {
 
		LOG4CXX_INFO(logger, "API Version to " << c << " (ID=" << c->id << ")");
 
		send(c->connection, message);
 
	}
 
}
 

	
 
void NetworkPluginServer::handlePIDTerminated(unsigned long pid) {
 
	std::vector<unsigned long>::iterator log_id_it;
 
	log_id_it = std::find(m_pids.begin(), m_pids.end(), pid);
 
	if (log_id_it != m_pids.end()) {
 
		*log_id_it = 0;
 
	}
0 comments (0 inline, 0 general)