Update SpectrumBackend and build protocol buffers
This is to use the new handleBuddies feature.
This commit is contained in:
parent
e111b0fcff
commit
06388685d4
|
@ -19,6 +19,7 @@ class SpectrumBackend:
|
||||||
@param host: Host where Spectrum2 NetworkPluginServer runs.
|
@param host: Host where Spectrum2 NetworkPluginServer runs.
|
||||||
@param port: Port.
|
@param port: Port.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.m_pingReceived = False
|
self.m_pingReceived = False
|
||||||
self.m_data = ""
|
self.m_data = ""
|
||||||
|
@ -344,6 +345,14 @@ class SpectrumBackend:
|
||||||
groups = [g for g in payload.group]
|
groups = [g for g in payload.group]
|
||||||
self.handleBuddyRemovedRequest(payload.userName, payload.buddyName, groups);
|
self.handleBuddyRemovedRequest(payload.userName, payload.buddyName, groups);
|
||||||
|
|
||||||
|
def handleBuddiesPayload(self, data):
|
||||||
|
payload = protocol_pb2.Buddies()
|
||||||
|
if (payload.ParseFromString(data) == False):
|
||||||
|
#TODO: ERROR
|
||||||
|
return
|
||||||
|
|
||||||
|
self.handleBuddies(payload);
|
||||||
|
|
||||||
def handleChatStatePayload(self, data, msgType):
|
def handleChatStatePayload(self, data, msgType):
|
||||||
payload = protocol_pb2.Buddy()
|
payload = protocol_pb2.Buddy()
|
||||||
if (payload.ParseFromString(data) == False):
|
if (payload.ParseFromString(data) == False):
|
||||||
|
@ -428,6 +437,8 @@ class SpectrumBackend:
|
||||||
self.handleConvMessageAckPayload(wrapper.payload)
|
self.handleConvMessageAckPayload(wrapper.payload)
|
||||||
elif wrapper.type == protocol_pb2.WrapperMessage.TYPE_RAW_XML:
|
elif wrapper.type == protocol_pb2.WrapperMessage.TYPE_RAW_XML:
|
||||||
self.handleRawXmlRequest(wrapper.payload)
|
self.handleRawXmlRequest(wrapper.payload)
|
||||||
|
elif wrapper.type == Protocol_pb2.WrapperMessage.TYPE_BUDDIES:
|
||||||
|
self.handleBuddiesPayload()
|
||||||
|
|
||||||
def send(self, data):
|
def send(self, data):
|
||||||
header = struct.pack('!I',len(data))
|
header = struct.pack('!I',len(data))
|
||||||
|
@ -488,6 +499,9 @@ class SpectrumBackend:
|
||||||
|
|
||||||
raise NotImplementedError, "Implement me"
|
raise NotImplementedError, "Implement me"
|
||||||
|
|
||||||
|
def handleBuddies(self, buddies):
|
||||||
|
pass
|
||||||
|
|
||||||
def handleLogoutRequest(self, user, legacyName):
|
def handleLogoutRequest(self, user, legacyName):
|
||||||
"""
|
"""
|
||||||
Called when XMPP user wants to disconnect legacy network.
|
Called when XMPP user wants to disconnect legacy network.
|
||||||
|
@ -505,7 +519,7 @@ class SpectrumBackend:
|
||||||
@param legacyName: Legacy network name of buddy or room.
|
@param legacyName: Legacy network name of buddy or room.
|
||||||
@param message: Plain text message.
|
@param message: Plain text message.
|
||||||
@param xhtml: XHTML message.
|
@param xhtml: XHTML message.
|
||||||
@param ID: message ID
|
@param ID: message ID
|
||||||
"""
|
"""
|
||||||
|
|
||||||
raise NotImplementedError, "Implement me"
|
raise NotImplementedError, "Implement me"
|
||||||
|
|
|
@ -63,6 +63,10 @@ message Buddy {
|
||||||
optional bool blocked = 8;
|
optional bool blocked = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message Buddies {
|
||||||
|
repeated Buddy buddy = 1;
|
||||||
|
}
|
||||||
|
|
||||||
message ConversationMessage {
|
message ConversationMessage {
|
||||||
required string userName = 1;
|
required string userName = 1;
|
||||||
required string buddyName = 2;
|
required string buddyName = 2;
|
||||||
|
@ -182,6 +186,7 @@ message WrapperMessage {
|
||||||
TYPE_ROOM_LIST = 32;
|
TYPE_ROOM_LIST = 32;
|
||||||
TYPE_CONV_MESSAGE_ACK = 33;
|
TYPE_CONV_MESSAGE_ACK = 33;
|
||||||
TYPE_RAW_XML = 34;
|
TYPE_RAW_XML = 34;
|
||||||
|
TYPE_BUDDIES = 35;
|
||||||
}
|
}
|
||||||
required Type type = 1;
|
required Type type = 1;
|
||||||
optional bytes payload = 2;
|
optional bytes payload = 2;
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue