Remove trailing whitespaces.

This commit is contained in:
Emmanuel Gil Peyrot 2013-01-18 17:55:34 +01:00
commit 27b3592e16
7 changed files with 899 additions and 899 deletions

View file

@ -37,7 +37,7 @@ class QuickApp(object):
self.profiles = {}
self.single_profile = single_profile
self.check_options()
## bridge ##
try:
self.bridge=DBusBridgeFrontend()
@ -81,11 +81,11 @@ class QuickApp(object):
self.bridge.register("quizGameAnswerResult", self.quizGameAnswerResult, "plugin")
self.bridge.register("quizGameTimerExpired", self.quizGameTimerExpired, "plugin")
self.bridge.register("quizGameTimerRestarted", self.quizGameTimerRestarted, "plugin")
self.current_action_ids = set()
self.current_action_ids_cb = {}
self.media_dir = self.bridge.getConfig('','media_dir')
def check_profile(self, profile):
"""Tell if the profile is currently followed by the application"""
return profile in self.profiles.keys()
@ -93,7 +93,7 @@ class QuickApp(object):
def postInit(self):
"""Must be called after initialization is done, do all automatic task (auto plug profile)"""
if self.options.profile:
if not self.bridge.getProfileName(self.options.profile):
if not self.bridge.getProfileName(self.options.profile):
error(_("Trying to plug an unknown profile (%s)" % self.options.profile))
else:
self.plug_profile(self.options.profile)
@ -116,7 +116,7 @@ class QuickApp(object):
def _getParamError(self, ignore):
error(_("Can't get profile parameter"))
def plug_profile(self, profile_key='@DEFAULT@'):
"""Tell application which profile must be used"""
if self.single_profile and self.profiles:
@ -132,11 +132,11 @@ class QuickApp(object):
self.profiles[profile]={}
if self.single_profile:
self.profile = profile
###now we get the essential params###
self.bridge.asyncGetParamA("JabberID","Connection", profile_key=profile,
callback=lambda _jid: self.plug_profile_2(_jid, profile), errback=self._getParamError)
def plug_profile_2(self, _jid, profile):
self.profiles[profile]['whoami'] = JID(_jid)
self.bridge.asyncGetParamA("autoconnect","Connection", profile_key=profile,
@ -152,7 +152,7 @@ class QuickApp(object):
self.bridge.asyncConnect(profile, callback=lambda: self.plug_profile_5(watched, autoconnect, profile), errback=lambda ignore: error(_('Error during autoconnection')))
else:
self.plug_profile_5(watched, autoconnect, profile)
def plug_profile_5(self, watched, autoconnect, profile):
self.profiles[profile]['watched'] = watched.split() #TODO: put this in a plugin
@ -198,7 +198,7 @@ class QuickApp(object):
for confirm_id, confirm_type, data in self.bridge.getWaitingConf(profile):
self.askConfirmation(confirm_id, confirm_type, data, profile)
def unplug_profile(self, profile):
"""Tell the application to not follow anymore the profile"""
@ -224,7 +224,7 @@ class QuickApp(object):
debug(_("Disconnected"))
self.contact_list.clearContacts()
self.setStatusOnline(False)
def connectionError(self, error_type, profile):
"""called when something goest wrong with the connection"""
if not self.check_profile(profile):
@ -250,15 +250,15 @@ class QuickApp(object):
return
from_jid = JID(from_jid_s)
to_jid = JID(to_jid_s)
from_me = from_jid.short == self.profiles[profile]['whoami'].short
win = to_jid if from_me else from_jid
if _type != "groupchat" and self.contact_list.getSpecial(win) == "MUC":
#we have a private message in a MUC room
#XXX: normaly we use bare jid as key, here we need the full jid
# so we cheat by replacing the "/" before the resource by
# a "@", so the jid is invalid,
# a "@", so the jid is invalid,
new_jid = escapePrivate(win)
if from_me:
to_jid = new_jid
@ -268,11 +268,11 @@ class QuickApp(object):
self.contact_list.add(new_jid)
self.newMessage(from_jid, to_jid, msg, _type, extra, profile)
def newMessage(self, from_jid, to_jid, msg, _type, extra, profile):
from_me = from_jid.short == self.profiles[profile]['whoami'].short
win = to_jid if from_me else from_jid
self.current_action_ids = set()
self.current_action_ids_cb = {}
@ -291,7 +291,7 @@ class QuickApp(object):
assert alert_type in ['INFO','ERROR']
self.showDialog(unicode(msg),unicode(title),alert_type.lower())
def setStatusOnline(self, online=True):
pass
@ -309,21 +309,21 @@ class QuickApp(object):
self.setStatusOnline(False)
return
self.contact_list.updatePresence(from_jid, show, priority, statuses)
self.contact_list.updatePresence(from_jid, show, priority, statuses)
if show != 'unavailable':
#FIXME: must be moved in a plugin
if from_jid.short in self.profiles[profile]['watched'] and not from_jid.short in self.profiles[profile]['onlineContact']:
self.showAlert(_("Watched jid [%s] is connected !") % from_jid.short)
self.profiles[profile]['onlineContact'].add(from_jid) #FIXME onlineContact is useless with CM, must be removed
#TODO: vcard data (avatar)
if show=="unavailable" and from_jid in self.profiles[profile]['onlineContact']:
self.profiles[profile]['onlineContact'].remove(from_jid)
def roomJoined(self, room_jid, room_nicks, user_nick, profile):
"""Called when a MUC room is joined"""
if not self.check_profile(profile):
@ -374,7 +374,7 @@ class QuickApp(object):
if self.chat_wins.has_key(room_jid):
self.chat_wins[room_jid].setSubject(subject)
debug (_("new subject for room [%(room_jid)s]: %(subject)s") % {'room_jid':room_jid, "subject":subject})
def tarotGameStarted(self, room_jid, referee, players, profile):
if not self.check_profile(profile):
return
@ -382,7 +382,7 @@ class QuickApp(object):
if self.chat_wins.has_key(room_jid):
self.chat_wins[room_jid].startGame("Tarot", referee, players)
debug (_("new Tarot game started by [%(referee)s] in room [%(room_jid)s] with %(players)s") % {'referee':referee, 'room_jid':room_jid, 'players':[str(player) for player in players]})
def tarotGameNew(self, room_jid, hand, profile):
if not self.check_profile(profile):
return
@ -411,8 +411,8 @@ class QuickApp(object):
debug (_("My turn to play"))
if self.chat_wins.has_key(room_jid):
self.chat_wins[room_jid].getGame("Tarot").myTurn()
def tarotScore(self, room_jid, xml_data, winners, loosers, profile):
def tarotScore(self, room_jid, xml_data, winners, loosers, profile):
"""Called when the game is finished and the score are updated"""
if not self.check_profile(profile):
return
@ -426,14 +426,14 @@ class QuickApp(object):
debug (_("Card(s) played (%(player)s): %(cards)s") % {"player":player, "cards":cards})
if self.chat_wins.has_key(room_jid):
self.chat_wins[room_jid].getGame("Tarot").cardsPlayed(player, cards)
def tarotInvalidCards(self, room_jid, phase, played_cards, invalid_cards, profile):
if not self.check_profile(profile):
return
debug (_("Cards played are not valid: %s") % invalid_cards)
if self.chat_wins.has_key(room_jid):
self.chat_wins[room_jid].getGame("Tarot").invalidCards(phase, played_cards, invalid_cards)
def quizGameStarted(self, room_jid, referee, players, profile):
if not self.check_profile(profile):
return
@ -441,7 +441,7 @@ class QuickApp(object):
if self.chat_wins.has_key(room_jid):
self.chat_wins[room_jid].startGame("Quiz", referee, players)
debug (_("new Quiz game started by [%(referee)s] in room [%(room_jid)s] with %(players)s") % {'referee':referee, 'room_jid':room_jid, 'players':[str(player) for player in players]})
def quizGameNew(self, room_jid, data, profile):
if not self.check_profile(profile):
return
@ -477,7 +477,7 @@ class QuickApp(object):
return
if self.chat_wins.has_key(room_jid):
self.chat_wins[room_jid].getGame("Quiz").quizGameAnswerResult(player, good_answer, score)
def quizGameTimerExpired(self, room_jid, profile):
"""Called when nobody answered the question in time"""
if not self.check_profile(profile):
@ -516,10 +516,10 @@ class QuickApp(object):
def showDialog(self, message, title, type="info", answer_cb = None):
raise NotImplementedError
def showAlert(self, message):
pass #FIXME
def paramUpdate(self, name, value, namespace, profile):
if not self.check_profile(profile):
return
@ -556,7 +556,7 @@ class QuickApp(object):
def askConfirmation(self, confirm_id, confirm_type, data, profile):
raise NotImplementedError
def actionResult(self, type, id, data):
raise NotImplementedError

View file

@ -25,7 +25,7 @@ from sat.tools.jid import JID
class QuickCardGame():
def __init__(self, parent, referee, players, player_nick):
self._autoplay = None #XXX: use 0 to activate fake play, None else
self.parent = parent
@ -58,7 +58,7 @@ class QuickCardGame():
self.state = None
for pl in self.played:
self.played[pl] = None
def getPlayerLocation(self, nick):
"""return player location (top,bottom,left or right)"""
for location in ['top','left','bottom','right']:
@ -76,7 +76,7 @@ class QuickCardGame():
self.cards["coeur"]={} #heart
self.cards["carreau"]={} #diamond
self.cards["trefle"]={} #club
def newGame(self, hand):
"""Start a new game, with given hand"""
assert (len(self.hand) == 0)
@ -84,7 +84,7 @@ class QuickCardGame():
self.hand.append(self.cards[suit, value])
self.hand.sort()
self.state = "init"
def contratSelected(self, contrat):
"""Called when the contrat has been choosed
@param data: form result"""
@ -94,7 +94,7 @@ class QuickCardGame():
"""Called when the player as to select his contrat
@param xml_data: SàT xml representation of the form"""
raise NotImplementedError
def showCards(self, game_stage, cards, data):
"""Display cards in the middle of the game (to show for e.g. chien ou poignée)"""
self.to_show = []
@ -111,7 +111,7 @@ class QuickCardGame():
self.to_show = []
self.state = "play"
self.__fakePlay()
def __fakePlay(self):
"""Convenience method for stupid autoplay
/!\ don't forgot to comment any interactive dialog for invalid card"""
@ -131,7 +131,7 @@ class QuickCardGame():
@param winners: list of winners' nicks
@param loosers: list of loosers' nicks"""
raise NotImplementedError
def cardsPlayed(self, player, cards):
"""A card has been played by player"""
if self.to_show:
@ -143,7 +143,7 @@ class QuickCardGame():
for suit, value in cards:
pl_cards.append(self.cards[suit, value])
self.played[player] = pl_cards[0]
def invalidCards(self, phase, played_cards, invalid_cards):
"""Invalid cards have been played
@param phase: phase of the game
@ -156,10 +156,10 @@ class QuickCardGame():
self.state = "ecart"
else:
error ('INTERNAL ERROR: unmanaged game phase')
for suit, value in played_cards:
self.hand.append(self.cards[suit, value])
self.hand.sort()
self.__fakePlay()

View file

@ -25,7 +25,7 @@ from sat_frontends.quick_frontend.quick_utils import unescapePrivate
class QuickChat():
def __init__(self, target, host, type='one2one'):
self.target = target
self.host = host
@ -49,7 +49,7 @@ class QuickChat():
error (_("[INTERNAL] trying to set presents nicks for a non group chat window"))
raise Exception("INTERNAL ERROR") #TODO: raise proper Exception here
self.occupants.update(nicks)
def replaceUser(self, nick, show_info=True):
"""Add user if it is not in the group list"""
debug (_("Replacing user %s") % nick)
@ -77,7 +77,7 @@ class QuickChat():
def getUserNick(self):
return unicode(self.nick)
def changeUserNick(self, old_nick, new_nick):
"""Change nick of a user in group list"""
debug(_("Changing nick of user %(old_nick)s to %(new_nick)s") % {"old_nick": old_nick, "new_nick": new_nick})
@ -99,13 +99,13 @@ class QuickChat():
"""Print the initial history"""
debug (_("now we print history"))
def onHistory(history):
for line in history:
for line in history:
timestamp, from_jid, to_jid, message, _type = line
if ((self.type == 'group' and _type != 'groupchat') or
(self.type == 'one2one' and _type == 'groupchat')):
continue
self.printMessage(JID(from_jid), message, profile, timestamp)
def onHistoryError(err):
error (_("Can't get history"))
@ -123,11 +123,11 @@ class QuickChat():
if jid.startswith(const_PRIVATE_PREFIX) or unescaped.short == jid.short:
return unescaped.resource
return jid.resource if self.type == "group" else (self.host.contact_list.getCache(jid,'nick') or self.host.contact_list.getCache(jid,'name') or jid.node)
def printMessage(self, from_jid, msg, profile, timestamp = ''):
"""Print message in chat window. Must be implemented by child class"""
jid=JID(from_jid)
nick = self._get_nick(jid)
nick = self._get_nick(jid)
mymess = (jid.resource == self.nick) if self.type == "group" else (jid.short == self.host.profiles[profile]['whoami'].short) #mymess = True if message comes from local user
if msg.startswith('/me '):
self.printInfo('* %s %s' % (nick, msg[4:]),type='me', timestamp=timestamp)
@ -143,12 +143,12 @@ class QuickChat():
"""
raise NotImplementedError
def startGame(self, game_type, referee, players):
"""Configure the chat window to start a game"""
#No need to raise an error as game are not mandatory
warning(_('startGame is not implemented in this frontend'))
def getGame(self, game_type):
"""Return class managing the game type"""
#No need to raise an error as game are not mandatory

View file

@ -25,7 +25,7 @@ from sat.tools.jid import JID
class QuickChatList(dict):
"""This class is used to manage the list of chat windows.
It act as a dict, but create a chat window when the name is found for the first time."""
def __init__(self, host):
dict.__init__(self)
self.host = host

View file

@ -49,16 +49,16 @@ class QuickContactList():
def __contains__(self, jid):
raise NotImplementedError
def clearContacts(self):
"""Clear all the contact list"""
self.specials.clear()
def replace(self, jid, groups=None, attributes=None):
"""add a contact to the list if doesn't exist, else update it"""
if attributes and 'name' in attributes:
self.setCache(jid, 'name', attributes['name'])
def remove(self, jid):
"""remove a contact from the list"""
try:

View file

@ -47,7 +47,7 @@ class QuickContactManagement():
if entity.resource in self.__contactlist[entity.short]['resources']:
self.__contactlist[entity.short]['resources'].remove(entity.resource)
self.__contactlist[entity.short]['resources'].append(entity.resource)
def getContFromGroup(self, group):
"""Return all contacts which are in given group"""
result = []
@ -71,7 +71,7 @@ class QuickContactManagement():
else:
debug(_('Trying to get attribute for an unknown contact'))
return None
def isConnected(self, entity):
"""Tell if the contact is online"""
return self.__contactlist.has_key(entity.short)
@ -101,4 +101,4 @@ class QuickContactManagement():
def get_full(self, entity):
return entity.short+'/'+self.__contactlist[entity.short]['resources'][-1]

View file

@ -24,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
class QuickGatewaysManager():
def __init__(self, host, gateways, title=_("Gateways manager"), server=None):
self.WARNING_MSG = _(u"""Be careful ! Gateways allow you to use an external IM (legacy IM), so you can see your contact as jabber contacts.
But when you do this, all your messages go throught the external legacy IM server, it is a huge privacy issue (i.e.: all your messages throught the gateway can be monitored, recorded, analyzed by the external server, most of time a private company).""")