- Timestamp:
- Dec 5, 2013 11:04:36 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/pjsua2/pjsip-apps/src/pygui/account.py
r4677 r4686 52 52 self.deleting = False 53 53 54 def findBuddy(self, uri): 54 """ 55 def findBuddy2(self, uri): 55 56 # TODO: proper URI comparison 56 57 for bud in self.buddyList: … … 58 59 return bud 59 60 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 62 67 for chat in self.chatList: 63 if chat.is BuddyParticipant(buddy):68 if chat.isUriParticipant(uri): 64 69 if call_inst and chat.isCallRegistered(call_inst): 65 70 return chat … … 68 73 return None 69 74 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) 72 80 self.chatList.append(chat) 81 self.app.updateWindowMenu() 73 82 return chat 74 83 … … 113 122 c.answer(call_prm) 114 123 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) 122 127 123 128 chat.showWindow() 124 chat.registerCall( bud, c)129 chat.registerCall(ci.remoteUri, c) 125 130 chat.updateCallState(c, ci) 126 131 else: … … 128 133 129 134 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 137 138 chat.showWindow() 138 chat.addMessage( bud.cfg.uri, prm.msgBody)139 chat.addMessage(prm.fromUri, prm.msgBody) 139 140 140 141 def onInstantMessageStatus(self, prm): 141 142 if prm.code/100 == 2: return 142 143 143 bud = self.findBuddy(prm.toUri)144 if not bud: return145 chat = self.findChat(bud)146 if not chat:return147 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)) 149 150 150 151 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) 159 158 160 159
Note: See TracChangeset
for help on using the changeset viewer.