示例#1
0
 def on_delete_avatar(self, *args):
     def on_response_cb(response):
         '''response callback for the confirm dialog'''
         if response == stock.YES:
             self.model.remove(self.avatarIter)
             os.remove(self.avatarPath)
     yes_no(_('Are you sure?'),on_response_cb)
示例#2
0
    def closeTab(self, conversation):
        '''Close a conversation, but if there's some transfer,
        ask first and warns about unread messages'''
        closeBool = False

        #if prevention is activated and there are unread messages in this tab
        #tab grabs focus and label appears, else, check transfers
        if conversation.ui.tabWidget.hasMessageWaiting and self.config.user[
                'preventClosingTime']:
            self.showTab(self.tabs.page_num(conversation.ui))
            message = _("There are unread messages in this tab")
            conversation.ui.set_label_closingPrevention(message)
            closeBool = False
        else:
            message = _(
                "Transfers are happening, are you sure you want to cancel them?"
            )
            if [
                    x for x in conversation.transfers
                    if x.state not in (x.RECEIVED, x.FAILED)
            ]:
                dialog.yes_no(message, self.close_tab_confirmation,
                              conversation)
                closeBool = False
            else:
                closeBool = True

        if closeBool:
            self.close_tab_for_real(conversation)
        return closeBool
示例#3
0
 def on_delete_all(self, *args):
     def on_response_cb(response):
         '''response callback for the confirm dialog'''
         if response == stock.YES:
             for row in self.model:
                    os.remove(row[1])
             self.model.clear()
     yes_no(_('Are you sure?'),on_response_cb)
    def on_delete_avatar(self, *args):
        def on_response_cb(response):
            '''response callback for the confirm dialog'''
            if response == stock.YES:
                self.model.remove(self.avatarIter)
                os.remove(self.avatarPath)

        yes_no(_('Are you sure?'), on_response_cb)
    def on_delete_all(self, *args):
        def on_response_cb(response):
            '''response callback for the confirm dialog'''
            if response == stock.YES:
                for row in self.model:
                    os.remove(row[1])
                self.model.clear()

        yes_no(_('Are you sure?'), on_response_cb)
示例#6
0
 def on_webcam_invite(self, p2p, session, sender, producer, fromwho):
     '''someone sent us an invite for webcam, either send or receive from us'''
     if not Webcam.HAVE_MIMIC: # silently drop webcam stuff (3)
         return
     if producer:
         self.appendOutputText(None, _("You have been requested to send your webcam to %s") % sender, 'information')
         dialog.yes_no(_("Accept to send your webcam to %s?") % sender, self.accept_send_webcam, p2p, session, sender)
     else:
         self.appendOutputText(None, _("%s wants to show you his/her webcam") % fromwho, 'information')
         dialog.yes_no(_("Accept webcam from %s?") % fromwho, self.accept_webcam_other, p2p, session, sender)
示例#7
0
    def hideOrClose(self, *args):
        '''hide or close depending if we have trayicon'''

        if TrayIcon.disabled:
            def remove_cb(response):
                if response == stock.YES:
                    self.quit(0)

            message = _('This action will close emesene, continue?')
            dialog.yes_no(message,remove_cb)
        else:
            self.hide()

        return True
示例#8
0
    def close(self, *args):
        '''close the window and set the attribute self.closed to true
           C10uD: i hate this function and its duplicated code, but 
           reusing the close tab code is real pain :D'''
        closeBool = True
        tabsWhitUnreadMessages = False

        #if the window have tabs, check if there are unread messages
        if self.config.user['preventClosingTime'] and not self.minimized:
            for conv in self.conversations:
                if conv.hasMessageWaiting or conv.ui.tabWidget.hasMessageWaiting:
                    tabsWhitUnreadMessages = True

        #if the window doesn't have tabs but it's not minimized with unread messages
        if tabsWhitUnreadMessages or (self.get_urgency_hint()
                                      and not self.minimized):
            message = _("There are unread messages in this window")
            self.conversation.ui.set_label_closingPrevention(message)
            #unset the "messageWaiting" so user can close the window if clicked again
            preventTime = 0
            if self.config.user['preventClosingTime']:
                preventTime = 1000
            gobject.timeout_add(preventTime,
                                self.conversation.setNoMessageWaiting)
            gobject.timeout_add(preventTime, self.unsetUrgency)
            for conv in self.conversations:
                gobject.timeout_add(preventTime, conv.setNoMessageWaiting)
                gobject.timeout_add(preventTime,
                                    conv.ui.tabWidget.setNoMessageWaiting)
            closeBool = False
        else:
            activeTransfers = []
            for conv in self.conversations:
                for tr in conv.transfers:
                    if tr.state not in (tr.RECEIVED, tr.FAILED):
                        activeTransfers.append(tr)
            if len(activeTransfers) > 0:
                message = _(
                    "Transfers are happening, are you sure you want to cancel them?"
                )
                dialog.yes_no(message, self.close_win_confirmation,
                              activeTransfers)
                closeBool = False
            else:
                closeBool = True

        if closeBool:
            self.unsetUrgency()
            self.close_win_for_real()
        return True
    def hideOrClose(self, *args):
        '''hide or close depending if we have trayicon'''

        if TrayIcon.disabled:

            def remove_cb(response):
                if response == stock.YES:
                    self.quit(0)

            message = _('This action will close emesene, continue?')
            dialog.yes_no(message, remove_cb)
        else:
            self.hide()

        return True
示例#10
0
    def do_send_message(self, message, retry=0):
        '''Send the message from the UI input. This chooses between OIM and
        switchboard to send the message.'''
        
        remoteMail = self.switchboard.firstUser
        remoteStatus = self.controller.contacts.get_status(remoteMail)

        def do_send_offline(response, mail='', message=''):
            '''callback for the confirm dialog asking to send offline 
            message'''
            if response == stock.YES:
                self.sendOffline = True
                self.switchboard.msn.msnOIM.send(mail, message)
                self.appendOutputText(self.user, message, 'outgoing')
        
        if self.switchboard.status == 'error' and remoteStatus == 'FLN':
            
            if self.sendOffline == True:
                do_send_offline(stock.YES, remoteMail, message)
            else:
                dialog.yes_no(
                 _("Are you sure you want to send a offline message to %s") %\
                 remoteMail, do_send_offline, remoteMail, message)

            return
            
        if self.switchboard.status == 'closed':
            self.reconnect()

        messageChunks = self.splitMessage(message)
        for chunk in messageChunks:
            try:
                self.switchboard.sendCustomEmoticons(chunk)
                self.switchboard.sendMessage(chunk, self.getStyle(chunk))
                self.appendOutputText(self.user, chunk, 'outgoing')
            except Exception, e:
                raise
                print str(e)
                self.reconnect()
                if retry < 3:
                    self.do_send_message(
                        ''.join(messageChunks[messageChunks.index(chunk):]), \
                        retry + 1)
                else:
                    self.appendOutputText(None, _('Can\'t send message'), \
                        'information')
                return
    def close(self, *args):
        '''close the window and set the attribute self.closed to true
           C10uD: i hate this function and its duplicated code, but 
           reusing the close tab code is real pain :D'''
        closeBool = True
        tabsWhitUnreadMessages = False

        #if the window have tabs, check if there are unread messages
        if self.config.user['preventClosingTime'] and not self.minimized:
            for conv in self.conversations:
                if conv.hasMessageWaiting or conv.ui.tabWidget.hasMessageWaiting:
                    tabsWhitUnreadMessages = True

        #if the window doesn't have tabs but it's not minimized with unread messages
        if tabsWhitUnreadMessages or (self.get_urgency_hint() and not self.minimized):
            message = _("There are unread messages in this window")
            self.conversation.ui.set_label_closingPrevention(message)
            #unset the "messageWaiting" so user can close the window if clicked again
            preventTime = 0
            if self.config.user['preventClosingTime']:
                preventTime = 1000
            gobject.timeout_add(preventTime, self.conversation.setNoMessageWaiting)
            gobject.timeout_add(preventTime, self.unsetUrgency)
            for conv in self.conversations:
                gobject.timeout_add(preventTime, conv.setNoMessageWaiting)
                gobject.timeout_add(preventTime, conv.ui.tabWidget.setNoMessageWaiting)
            closeBool = False
        else:
            activeTransfers = []
            for conv in self.conversations:
                for tr in conv.transfers:
                    if tr.state not in (tr.RECEIVED, tr.FAILED):
                        activeTransfers.append(tr)        
            if len(activeTransfers) > 0:
                message = _("Transfers are happening, are you sure you want to cancel them?")
                dialog.yes_no(message, self.close_win_confirmation, activeTransfers)
                closeBool = False
            else:
                closeBool = True

        if closeBool:
            self.unsetUrgency()
            self.close_win_for_real()
        return True
示例#12
0
    def onForgetMe(self, *args):
        '''This method is called when the user press the forget me event box'''
        def _yes_no_cb(response):
            '''callback from the confirmation dialog'''
            if response == stock.YES:
                try: # Delete user's folder
                    user = self.getUser().replace('@', '_').replace('.', '_')
                    shutil.rmtree(os.path.join(paths.CONFIG_DIR, user))
                except: 
                    pass

                self.users.removeUser(self.getUser())
                self.tUser.get_children()[0].set_text('')
                self.tPass.set_text('')
                self.forgetMe.set_child_visible(False)
                self.refreshUserList()
                self.users.save()

        dialog.yes_no(
            _('Are you sure you want to delete the account %s ?') % self.getUser() , _yes_no_cb)
    def closeTab(self, conversation):
        '''Close a conversation, but if there's some transfer,
        ask first and warns about unread messages'''
        closeBool = False

        #if prevention is activated and there are unread messages in this tab
        #tab grabs focus and label appears, else, check transfers
        if conversation.ui.tabWidget.hasMessageWaiting and self.config.user['preventClosingTime']:
            self.showTab(self.tabs.page_num(conversation.ui))
            message = _("There are unread messages in this tab")
            conversation.ui.set_label_closingPrevention(message)
            closeBool = False
        else:
            message = _("Transfers are happening, are you sure you want to cancel them?")
            if [x for x in conversation.transfers
                        if x.state not in (x.RECEIVED, x.FAILED)]:
                dialog.yes_no(message, self.close_tab_confirmation, conversation)
                closeBool = False
            else:
                closeBool = True

        if closeBool:
            self.close_tab_for_real(conversation)
        return closeBool
 def remove(self, account):
     '''remove an user'''
     message = _(
         'Are you sure you want to delete %s from your contacts?') % account
     window = dialog.yes_no(message, self.delete_confirmation, account)
示例#15
0
 def on_webcam_invite(self, p2p, session, sender):
     self.webcam_other = Webcam.Webcam(p2p, self, session, sender)
     dialog.yes_no(_("Accept webcam from %s?") % sender, self.accept_webcam_other)
 def remove(self, account):
     '''remove an user'''
     message = _('Are you sure you want to delete %s from your contacts?') %account
     window = dialog.yes_no(message, self.delete_confirmation, account)