print "Loading mod: patches v2016-10-05 (patching WG errors)"

from messenger.gui.Scaleform.channels.xmpp.lobby_controllers import ChatSessionController
from messenger.m_constants import PROTO_TYPE
from messenger.proto.xmpp.jid import makeContactJID

def _ChatSessionController__onUserStatusUpdated_patched(self, user):
    if not user.isCurrentPlayer():
        if user.getProtoType() == PROTO_TYPE.XMPP:
            uid = user.getJID()
        else:
            uid = makeContactJID(user.getID())
        member = self._channel.getMember(uid)
        if member is not None and hasattr(member, 'getItem'):
            presence = user.getItem().getPresence()
            member.update(status=presence)
    return

ChatSessionController._ChatSessionController__onUserStatusUpdated = _ChatSessionController__onUserStatusUpdated_patched
# 
# 
# def __onClanEmblemLoaded(self, url, data):
#     if not self._ModelStickers__isLoadingClanEmblems:
#         return
#     else:
#         self._ModelStickers__isLoadingClanEmblems = False
#         if data is None:
#             return
#         try:
#             self._ModelStickers__stickerModel.setTextureData(data)
#             self._ModelStickers__doAttachStickers(SlotTypes.CLAN)
#         except Exception:
#             #LOG_CURRENT_EXCEPTION()
#             pass
#         return
# 
# from VehicleStickers import ModelStickers, SlotTypes
# ModelStickers._ModelStickers__onClanEmblemLoaded = __onClanEmblemLoaded
