Ignore:
Timestamp:
Dec 4, 2013 2:46:42 AM (10 years ago)
Author:
nanang
Message:

Re #1708: Initial work on chat window.

File:
1 edited

Legend:

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

    r4665 r4671  
    5252                 
    5353                # Logger 
    54                 self.logger = log.Logger() 
     54                self.logger = None #log.Logger() 
    5555                 
    5656                # Accounts 
     
    136136                # Start polling 
    137137                self._onTimer() 
    138  
    139         def updateCall(self, acc): 
    140                 iid = str(acc.randId) 
    141                 for call in acc.callList: 
    142                         calliid = str(call.randId) 
    143                         uri, status = call.statusText() 
    144                         if self.tv.exists(calliid): 
    145                                 self.tv.item(call.iid, text=uri, values=(status,)) 
    146                         else: 
    147                                 call.iid = self.tv.insert(iid, 0, calliid, open=True, text=uri, values=(status,)) 
    148138 
    149139        def updateAccount(self, acc): 
     
    226216                self.accMenu = tk.Menu(top, tearoff=False) 
    227217                # Labels, must match with _onAccContextMenu() 
    228                 labels = ['Call', '-', 'Unregister', 'Reregister', 'Add buddy...', '-', 
     218                labels = ['Unregister', 'Reregister', 'Add buddy...', '-', 
    229219                          'Online', 'Invisible', 'Away', 'Busy', '-', 
    230220                          'Settings...', '-', 
     
    238228                 
    239229                # Create Buddy context menu 
    240                 # Labels, must match with _onAccContextMenu() 
     230                # Labels, must match with _onBuddyContextMenu() 
    241231                self.buddyMenu = tk.Menu(top, tearoff=False) 
    242                 labels = ['Video call', 'Audio call', 'Send instant message', '-', 
     232                labels = ['Audio call', 'Send instant message', '-', 
    243233                          'Subscribe', 'Unsubscribe', '-', 
    244234                          'Settings...', '-', 
     
    257247                else: 
    258248                        self.tv.bind('<3>', self._onTvRightClick) 
     249                self.tv.bind('<Double-Button-1>', self._onTvDoubleClick) 
    259250 
    260251        def _getSelectedAccount(self): 
     
    303294                                self.buddyMenu.post(event.x_root, event.y_root) 
    304295         
     296        def _onTvDoubleClick(self, event): 
     297                iid = self.tv.identify_row(event.y) 
     298                if iid: 
     299                        self.tv.selection_set( (iid,) ) 
     300                        acc = self._getSelectedAccount() 
     301                        if acc: 
     302                                self.cfgChanged = False 
     303                                dlg = accountsetting.Dialog(self.master, acc.cfg) 
     304                                if dlg.doModal(): 
     305                                        self.updateAccount(acc) 
     306                                        acc.modify(acc.cfg) 
     307                        else: 
     308                                bud = self._getSelectedBuddy() 
     309                                acc = bud.account 
     310                                chat = acc.findChat(bud) 
     311                                if not chat: 
     312                                        chat = acc.newChat(bud) 
     313                                chat.showWindow() 
     314         
    305315        def _onAccContextMenu(self, label): 
    306316                acc = self._getSelectedAccount() 
     
    308318                        return 
    309319                 
    310                 if label=='Call': 
    311                         acc.makeCall() 
    312                 elif label=='Unregister': 
     320                if label=='Unregister': 
    313321                        acc.setRegistration(False) 
    314322                elif label=='Reregister': 
     
    362370                acc = bud.account 
    363371                         
    364                 if label=='Video call': 
    365                         pass 
    366                 elif label=='Audio call': 
    367                         pass 
     372                if label=='Audio call': 
     373                        chat = acc.findChat(bud) 
     374                        if not chat: chat = acc.newChat(bud) 
     375                        chat.showWindow() 
     376                        chat.startAudio() 
    368377                elif label=='Send instant message': 
    369                         pass 
     378                        chat = acc.findChat(bud) 
     379                        if not chat: chat = acc.newChat(bud) 
     380                        chat.showWindow() 
    370381                elif label=='Subscribe': 
    371382                        bud.subscribePresence(True) 
     
    476487                 
    477488if __name__ == '__main__': 
     489        print pj 
    478490        main() 
Note: See TracChangeset for help on using the changeset viewer.