Ignore:
Timestamp:
Dec 5, 2013 11:04:36 AM (10 years ago)
Author:
nanang
Message:

Re #1708:

  • Changed participant managements in Chat, e.g: changed Buddy based to URI based, create temporary Buddy for incoming call/IM from non-buddy.
  • Implemented simple media features in chat window (mute, volume, codec info).
  • Misc: added window menu listing chat windows, changed behaviour on closing chat window, etc.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/pjsua2/pjsip-apps/src/pygui/account.py

    r4677 r4686  
    5252                self.deleting = False 
    5353 
    54         def findBuddy(self, uri): 
     54        """ 
     55        def findBuddy2(self, uri): 
    5556                # TODO: proper URI comparison 
    5657                for bud in self.buddyList: 
     
    5859                                return bud 
    5960                return None 
    60                  
    61         def findChat(self, buddy, call_inst = None): 
     61        """ 
     62         
     63        def findChat(self, uri_str, call_inst = None): 
     64                uri = ch.ParseSipUri(uri_str) 
     65                if not uri: return None 
     66                         
    6267                for chat in self.chatList: 
    63                         if chat.isBuddyParticipant(buddy): 
     68                        if chat.isUriParticipant(uri): 
    6469                                if call_inst and chat.isCallRegistered(call_inst): 
    6570                                        return chat 
     
    6873                return None 
    6974         
    70         def newChat(self, buddy): 
    71                 chat = ch.Chat(self.app, self, buddy) 
     75        def newChat(self, uri_str): 
     76                uri = ch.ParseSipUri(uri_str) 
     77                if not uri: return None 
     78                         
     79                chat = ch.Chat(self.app, self, uri) 
    7280                self.chatList.append(chat) 
     81                self.app.updateWindowMenu() 
    7382                return chat 
    7483         
     
    113122                        c.answer(call_prm) 
    114123                         
    115                         # create chat instance 
    116                         bud = self.findBuddy(ci.remoteUri) 
    117                         if not bud: 
    118                                 print "=== Incoming call from '%s': cannot find buddy" % ci.remoteUri 
    119                                 return 
    120                         chat = self.findChat(bud) 
    121                         if not chat: chat = self.newChat(bud) 
     124                        # find/create chat instance 
     125                        chat = self.findChat(ci.remoteUri) 
     126                        if not chat: chat = self.newChat(ci.remoteUri) 
    122127                         
    123128                        chat.showWindow() 
    124                         chat.registerCall(bud, c) 
     129                        chat.registerCall(ci.remoteUri, c) 
    125130                        chat.updateCallState(c, ci) 
    126131                else: 
     
    128133                         
    129134        def onInstantMessage(self, prm): 
    130                 bud = self.findBuddy(prm.fromUri) 
    131                 if not bud: 
    132                         print "=== Incoming IM from '%s': cannot find buddy" % prm.fromUri 
    133                         return 
    134                 chat = self.findChat(bud) 
    135                 if not chat: chat = self.newChat(bud) 
    136                          
     135                chat = self.findChat(prm.fromUri) 
     136                if not chat: chat = self.newChat(prm.fromUri) 
     137                 
    137138                chat.showWindow() 
    138                 chat.addMessage(bud.cfg.uri, prm.msgBody) 
     139                chat.addMessage(prm.fromUri, prm.msgBody) 
    139140                 
    140141        def onInstantMessageStatus(self, prm): 
    141142                if prm.code/100 == 2: return 
    142143                 
    143                 bud = self.findBuddy(prm.toUri) 
    144                 if not bud: return 
    145                 chat = self.findChat(bud) 
    146                 if not chat: return 
    147                  
    148                 chat.addMessage(None, "Failed sending message to '%s': %s" % (bud.cfg.uri, prm.reason)) 
     144                chat = self.findChat(prm.toUri) 
     145                if not chat: 
     146                        print "=== IM status to '%s' cannot find chat" % prm.toUri 
     147                        return 
     148                 
     149                chat.addMessage(None, "Failed sending message to '%s': %s" % (prm.toUri, prm.reason)) 
    149150                 
    150151        def onTypingIndication(self, prm): 
    151                 bud = self.findBuddy(prm.fromUri) 
    152                 if not bud: 
    153                         print "=== Incoming typing indication from '%s': cannot find buddy" % prm.fromUri 
    154                         return 
    155                 chat = self.findChat(bud) 
    156                 if not chat: return 
    157                  
    158                 chat.setTypingIndication(bud.cfg.uri, prm.isTyping) 
     152                chat = self.findChat(prm.fromUri) 
     153                if not chat: 
     154                        print "=== Incoming typing indication from '%s' cannot find chat" % prm.fromUri 
     155                        return 
     156                 
     157                chat.setTypingIndication(prm.fromUri, prm.isTyping) 
    159158 
    160159                 
Note: See TracChangeset for help on using the changeset viewer.