comparison frontends/src/quick_frontend/quick_app.py @ 1351:ec43552f5f8b frontends_multi_profiles

quick_frontend: replace last occurences of QuickApp.chat_wins with QuickApp.widgets
author souliane <souliane@mailoo.org>
date Thu, 05 Mar 2015 13:48:49 +0100
parents a39d2db03c80
children 56c14cb29e0f
comparison
equal deleted inserted replaced
1350:32ccda01a2be 1351:ec43552f5f8b
530 530
531 def roomJoinedHandler(self, room_jid_s, room_nicks, user_nick, profile): 531 def roomJoinedHandler(self, room_jid_s, room_nicks, user_nick, profile):
532 """Called when a MUC room is joined""" 532 """Called when a MUC room is joined"""
533 log.debug("Room [%(room_jid)s] joined by %(profile)s, users presents:%(users)s" % {'room_jid': room_jid_s, 'profile': profile, 'users': room_nicks}) 533 log.debug("Room [%(room_jid)s] joined by %(profile)s, users presents:%(users)s" % {'room_jid': room_jid_s, 'profile': profile, 'users': room_nicks})
534 room_jid = jid.JID(room_jid_s) 534 room_jid = jid.JID(room_jid_s)
535 chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_='group', profile=profile) 535 chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_=C.CHAT_GROUP, profile=profile)
536 chat_widget.setUserNick(user_nick) 536 chat_widget.setUserNick(user_nick)
537 chat_widget.id = room_jid # FIXME: to be removed 537 chat_widget.id = room_jid # FIXME: to be removed
538 chat_widget.setPresents(list(set([user_nick] + room_nicks))) 538 chat_widget.setPresents(list(set([user_nick] + room_nicks)))
539 self.contact_lists[profile].setSpecial(room_jid, C.CONTACT_SPECIAL_GROUP) 539 self.contact_lists[profile].setSpecial(room_jid, C.CONTACT_SPECIAL_GROUP)
540 540
541 def roomLeftHandler(self, room_jid_s, profile): 541 def roomLeftHandler(self, room_jid_s, profile):
542 """Called when a MUC room is left""" 542 """Called when a MUC room is left"""
543 log.debug("Room [%(room_jid)s] left by %(profile)s" % {'room_jid': room_jid_s, 'profile': profile}) 543 log.debug("Room [%(room_jid)s] left by %(profile)s" % {'room_jid': room_jid_s, 'profile': profile})
544 del self.chat_wins[room_jid_s] 544 room_jid = jid.JID(room_jid_s)
545 self.contact_lists[profile].remove(jid.JID(room_jid_s)) 545 chat_widget = self.widgets.getWidget(quick_chat.QuickChat, room_jid, profile)
546 if chat_widget:
547 self.widgets.deleteWidget(chat_widget)
548 self.contact_lists[profile].remove(room_jid)
546 549
547 def roomUserJoinedHandler(self, room_jid_s, user_nick, user_data, profile): 550 def roomUserJoinedHandler(self, room_jid_s, user_nick, user_data, profile):
548 """Called when an user joined a MUC room""" 551 """Called when an user joined a MUC room"""
549 room_jid = jid.JID(room_jid_s) 552 room_jid = jid.JID(room_jid_s)
550 chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_='group', profile=profile) 553 chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_=C.CHAT_GROUP, profile=profile)
551 chat_widget.replaceUser(user_nick) 554 chat_widget.replaceUser(user_nick)
552 log.debug("user [%(user_nick)s] joined room [%(room_jid)s]" % {'user_nick': user_nick, 'room_jid': room_jid}) 555 log.debug("user [%(user_nick)s] joined room [%(room_jid)s]" % {'user_nick': user_nick, 'room_jid': room_jid})
553 556
554 def roomUserLeftHandler(self, room_jid_s, user_nick, user_data, profile): 557 def roomUserLeftHandler(self, room_jid_s, user_nick, user_data, profile):
555 """Called when an user joined a MUC room""" 558 """Called when an user joined a MUC room"""
556 room_jid = jid.JID(room_jid_s) 559 room_jid = jid.JID(room_jid_s)
557 chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_='group', profile=profile) 560 chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_=C.CHAT_GROUP, profile=profile)
558 chat_widget.removeUser(user_nick) 561 chat_widget.removeUser(user_nick)
559 log.debug("user [%(user_nick)s] left room [%(room_jid)s]" % {'user_nick': user_nick, 'room_jid': room_jid}) 562 log.debug("user [%(user_nick)s] left room [%(room_jid)s]" % {'user_nick': user_nick, 'room_jid': room_jid})
560 563
561 def roomUserChangedNickHandler(self, room_jid_s, old_nick, new_nick, profile): 564 def roomUserChangedNickHandler(self, room_jid_s, old_nick, new_nick, profile):
562 """Called when an user joined a MUC room""" 565 """Called when an user joined a MUC room"""
563 room_jid = jid.JID(room_jid_s) 566 room_jid = jid.JID(room_jid_s)
564 chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_='group', profile=profile) 567 chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_=C.CHAT_GROUP, profile=profile)
565 chat_widget.changeUserNick(old_nick, new_nick) 568 chat_widget.changeUserNick(old_nick, new_nick)
566 log.debug("user [%(old_nick)s] is now known as [%(new_nick)s] in room [%(room_jid)s]" % {'old_nick': old_nick, 'new_nick': new_nick, 'room_jid': room_jid}) 569 log.debug("user [%(old_nick)s] is now known as [%(new_nick)s] in room [%(room_jid)s]" % {'old_nick': old_nick, 'new_nick': new_nick, 'room_jid': room_jid})
567 570
568 def roomNewSubjectHandler(self, room_jid_s, subject, profile): 571 def roomNewSubjectHandler(self, room_jid_s, subject, profile):
569 """Called when subject of MUC room change""" 572 """Called when subject of MUC room change"""
570 room_jid = jid.JID(room_jid_s) 573 room_jid = jid.JID(room_jid_s)
571 chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_='group', profile=profile) 574 chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_=C.CHAT_GROUP, profile=profile)
572 chat_widget.setSubject(subject) 575 chat_widget.setSubject(subject)
573 log.debug("new subject for room [%(room_jid)s]: %(subject)s" % {'room_jid': room_jid, "subject": subject}) 576 log.debug("new subject for room [%(room_jid)s]: %(subject)s" % {'room_jid': room_jid, "subject": subject})
574 577
575 def tarotGameStartedHandler(self, room_jid_s, referee, players, profile): 578 def tarotGameStartedHandler(self, room_jid_s, referee, players, profile):
576 log.debug(_("Tarot Game Started \o/")) 579 log.debug(_("Tarot Game Started \o/"))
577 room_jid = jid.JID(room_jid_s) 580 room_jid = jid.JID(room_jid_s)
578 chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_='group', profile=profile) 581 chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_=C.CHAT_GROUP, profile=profile)
579 chat_widget.startGame("Tarot", referee, players) 582 chat_widget.startGame("Tarot", referee, players)
580 log.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]}) 583 log.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]})
581 584
582 def tarotGameNewHandler(self, room_jid, hand, profile): 585 def tarotGameNewHandler(self, room_jid_s, hand, profile):
583 log.debug(_("New Tarot Game")) 586 log.debug(_("New Tarot Game"))
584 if room_jid in self.chat_wins: 587 chat_widget = self.widgets.getWidget(quick_chat.QuickChat, jid.JID(room_jid_s), profile)
585 self.chat_wins[room_jid].getGame("Tarot").newGame(hand) 588 if chat_widget:
586 589 chat_widget.getGame("Tarot").newGame(hand)
587 def tarotGameChooseContratHandler(self, room_jid, xml_data, profile): 590
591 def tarotGameChooseContratHandler(self, room_jid_s, xml_data, profile):
588 """Called when the player has to select his contrat""" 592 """Called when the player has to select his contrat"""
589 log.debug(_("Tarot: need to select a contrat")) 593 log.debug(_("Tarot: need to select a contrat"))
590 if room_jid in self.chat_wins: 594 chat_widget = self.widgets.getWidget(quick_chat.QuickChat, jid.JID(room_jid_s), profile)
591 self.chat_wins[room_jid].getGame("Tarot").chooseContrat(xml_data) 595 if chat_widget:
592 596 chat_widget.getGame("Tarot").chooseContrat(xml_data)
593 def tarotGameShowCardsHandler(self, room_jid, game_stage, cards, data, profile): 597
598 def tarotGameShowCardsHandler(self, room_jid_s, game_stage, cards, data, profile):
594 log.debug(_("Show cards")) 599 log.debug(_("Show cards"))
595 if room_jid in self.chat_wins: 600 chat_widget = self.widgets.getWidget(quick_chat.QuickChat, jid.JID(room_jid_s), profile)
596 self.chat_wins[room_jid].getGame("Tarot").showCards(game_stage, cards, data) 601 if chat_widget:
597 602 chat_widget.getGame("Tarot").showCards(game_stage, cards, data)
598 def tarotGameYourTurnHandler(self, room_jid, profile): 603
604 def tarotGameYourTurnHandler(self, room_jid_s, profile):
599 log.debug(_("My turn to play")) 605 log.debug(_("My turn to play"))
600 if room_jid in self.chat_wins: 606 chat_widget = self.widgets.getWidget(quick_chat.QuickChat, jid.JID(room_jid_s), profile)
601 self.chat_wins[room_jid].getGame("Tarot").myTurn() 607 if chat_widget:
602 608 chat_widget.getGame("Tarot").myTurn()
603 def tarotGameScoreHandler(self, room_jid, xml_data, winners, loosers, profile): 609
610 def tarotGameScoreHandler(self, room_jid_s, xml_data, winners, loosers, profile):
604 """Called when the game is finished and the score are updated""" 611 """Called when the game is finished and the score are updated"""
605 log.debug(_("Tarot: score received")) 612 log.debug(_("Tarot: score received"))
606 if room_jid in self.chat_wins: 613 chat_widget = self.widgets.getWidget(quick_chat.QuickChat, jid.JID(room_jid_s), profile)
607 self.chat_wins[room_jid].getGame("Tarot").showScores(xml_data, winners, loosers) 614 if chat_widget:
608 615 chat_widget.getGame("Tarot").showScores(xml_data, winners, loosers)
609 def tarotGameCardsPlayedHandler(self, room_jid, player, cards, profile): 616
617 def tarotGameCardsPlayedHandler(self, room_jid_s, player, cards, profile):
610 log.debug(_("Card(s) played (%(player)s): %(cards)s") % {"player": player, "cards": cards}) 618 log.debug(_("Card(s) played (%(player)s): %(cards)s") % {"player": player, "cards": cards})
611 if room_jid in self.chat_wins: 619 chat_widget = self.widgets.getWidget(quick_chat.QuickChat, jid.JID(room_jid_s), profile)
612 self.chat_wins[room_jid].getGame("Tarot").cardsPlayed(player, cards) 620 if chat_widget:
613 621 chat_widget.getGame("Tarot").cardsPlayed(player, cards)
614 def tarotGameInvalidCardsHandler(self, room_jid, phase, played_cards, invalid_cards, profile): 622
623 def tarotGameInvalidCardsHandler(self, room_jid_s, phase, played_cards, invalid_cards, profile):
615 log.debug(_("Cards played are not valid: %s") % invalid_cards) 624 log.debug(_("Cards played are not valid: %s") % invalid_cards)
616 if room_jid in self.chat_wins: 625 chat_widget = self.widgets.getWidget(quick_chat.QuickChat, jid.JID(room_jid_s), profile)
617 self.chat_wins[room_jid].getGame("Tarot").invalidCards(phase, played_cards, invalid_cards) 626 if chat_widget:
618 627 chat_widget.getGame("Tarot").invalidCards(phase, played_cards, invalid_cards)
619 def quizGameStartedHandler(self, room_jid, referee, players, profile): 628
629 def quizGameStartedHandler(self, room_jid_s, referee, players, profile):
620 log.debug(_("Quiz Game Started \o/")) 630 log.debug(_("Quiz Game Started \o/"))
621 if room_jid in self.chat_wins: 631 chat_widget = self.widgets.getWidget(quick_chat.QuickChat, jid.JID(room_jid_s), profile)
622 self.chat_wins[room_jid].startGame("Quiz", referee, players) 632 if chat_widget:
623 log.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]}) 633 chat_widget.startGame("Quiz", referee, players)
624 634 log.debug(_("new Quiz game started by [%(referee)s] in room [%(room_jid)s] with %(players)s") % {'referee': referee, 'room_jid': room_jid_s, 'players': [str(player) for player in players]})
625 def quizGameNewHandler(self, room_jid, data, profile): 635
636 def quizGameNewHandler(self, room_jid_s, data, profile):
626 log.debug(_("New Quiz Game")) 637 log.debug(_("New Quiz Game"))
627 if room_jid in self.chat_wins: 638 chat_widget = self.widgets.getWidget(quick_chat.QuickChat, jid.JID(room_jid_s), profile)
628 self.chat_wins[room_jid].getGame("Quiz").quizGameNewHandler(data) 639 if chat_widget:
629 640 chat_widget.getGame("Quiz").quizGameNewHandler(data)
630 def quizGameQuestionHandler(self, room_jid, question_id, question, timer, profile): 641
642 def quizGameQuestionHandler(self, room_jid_s, question_id, question, timer, profile):
631 """Called when a new question is asked""" 643 """Called when a new question is asked"""
632 log.debug(_(u"Quiz: new question: %s") % question) 644 log.debug(_(u"Quiz: new question: %s") % question)
633 if room_jid in self.chat_wins: 645 chat_widget = self.widgets.getWidget(quick_chat.QuickChat, jid.JID(room_jid_s), profile)
634 self.chat_wins[room_jid].getGame("Quiz").quizGameQuestionHandler(question_id, question, timer) 646 if chat_widget:
635 647 chat_widget.getGame("Quiz").quizGameQuestionHandler(question_id, question, timer)
636 def quizGamePlayerBuzzedHandler(self, room_jid, player, pause, profile): 648
649 def quizGamePlayerBuzzedHandler(self, room_jid_s, player, pause, profile):
637 """Called when a player pushed the buzzer""" 650 """Called when a player pushed the buzzer"""
638 if room_jid in self.chat_wins: 651 chat_widget = self.widgets.getWidget(quick_chat.QuickChat, jid.JID(room_jid_s), profile)
639 self.chat_wins[room_jid].getGame("Quiz").quizGamePlayerBuzzedHandler(player, pause) 652 if chat_widget:
640 653 chat_widget.getGame("Quiz").quizGamePlayerBuzzedHandler(player, pause)
641 def quizGamePlayerSaysHandler(self, room_jid, player, text, delay, profile): 654
655 def quizGamePlayerSaysHandler(self, room_jid_s, player, text, delay, profile):
642 """Called when a player say something""" 656 """Called when a player say something"""
643 if room_jid in self.chat_wins: 657 chat_widget = self.widgets.getWidget(quick_chat.QuickChat, jid.JID(room_jid_s), profile)
644 self.chat_wins[room_jid].getGame("Quiz").quizGamePlayerSaysHandler(player, text, delay) 658 if chat_widget:
645 659 chat_widget.getGame("Quiz").quizGamePlayerSaysHandler(player, text, delay)
646 def quizGameAnswerResultHandler(self, room_jid, player, good_answer, score, profile): 660
661 def quizGameAnswerResultHandler(self, room_jid_s, player, good_answer, score, profile):
647 """Called when a player say something""" 662 """Called when a player say something"""
648 if room_jid in self.chat_wins: 663 chat_widget = self.widgets.getWidget(quick_chat.QuickChat, jid.JID(room_jid_s), profile)
649 self.chat_wins[room_jid].getGame("Quiz").quizGameAnswerResultHandler(player, good_answer, score) 664 if chat_widget:
650 665 chat_widget.getGame("Quiz").quizGameAnswerResultHandler(player, good_answer, score)
651 def quizGameTimerExpiredHandler(self, room_jid, profile): 666
667 def quizGameTimerExpiredHandler(self, room_jid_s, profile):
652 """Called when nobody answered the question in time""" 668 """Called when nobody answered the question in time"""
653 if room_jid in self.chat_wins: 669 chat_widget = self.widgets.getWidget(quick_chat.QuickChat, jid.JID(room_jid_s), profile)
654 self.chat_wins[room_jid].getGame("Quiz").quizGameTimerExpiredHandler() 670 if chat_widget:
655 671 chat_widget.getGame("Quiz").quizGameTimerExpiredHandler()
656 def quizGameTimerRestartedHandler(self, room_jid, time_left, profile): 672
673 def quizGameTimerRestartedHandler(self, room_jid_s, time_left, profile):
657 """Called when the question is not answered, and we still have time""" 674 """Called when the question is not answered, and we still have time"""
658 if room_jid in self.chat_wins: 675 chat_widget = self.widgets.getWidget(quick_chat.QuickChat, jid.JID(room_jid_s), profile)
659 self.chat_wins[room_jid].getGame("Quiz").quizGameTimerRestartedHandler(time_left) 676 if chat_widget:
677 chat_widget.getGame("Quiz").quizGameTimerRestartedHandler(time_left)
660 678
661 def chatStateReceivedHandler(self, from_jid_s, state, profile): 679 def chatStateReceivedHandler(self, from_jid_s, state, profile):
662 """Called when a new chat state is received. 680 """Called when a new chat state is received.
663 681
664 @param from_jid_s: JID of the contact who sent his state, or '@ALL@' 682 @param from_jid_s: JID of the contact who sent his state, or '@ALL@'