Esempio n. 1
0
def search_for_buddy(metas, convo, sms):
    for win in ImWinPanel.all():
        with traceguard:
            c = win.Conversation

            # already talking to this buddy?
            if c is convo:
                LOG('direct conversation object match: win: %r, convo: %r', win, convo)
                return win

            # is this an SMS message?
            if validate_sms(convo.buddy.name):
                for num in win.SMS:
                    if validate_sms(num):
                        if smsize(num) == smsize(convo.buddy.name):
                            return win

            # chat messages will go only to windows with matching conversation objects.
            if convo.ischat != win.convo.ischat:
                continue

            # is there a window already open talking to another contact in this
            # contact's metacontact?
            winbud = win.Buddy
            if winbud is None:
                continue

            for meta in metas:
                for contact in meta:
                    if winbud == contact:
                        LOG('matched %r with %r', winbud, contact)
                        return win

                # a looser match--one that might not match "From:" but only "To:"
                for contact in meta:
                    if winbud.name == contact.name and winbud.protocol.name == contact.protocol.name:
                        LOG('loosely matched %r with %r', winbud, contact)
                        return win

            if winbud.info_key == convo.buddy.info_key:
                return win
Esempio n. 2
0
def im():
    from gui.imwin.imwin_gui import ImWinPanel
    for win in ImWinPanel.all():
        return win
Esempio n. 3
0
def im():
    from gui.imwin.imwin_gui import ImWinPanel
    for win in ImWinPanel.all():
        return win
Esempio n. 4
0
def on_status(status, on_done=None):
    for imwin in ImWinPanel.all():
        if imwin.Buddy == status.buddy:
            wx.CallAfter(imwin.show_status, status, on_done)
            break
Esempio n. 5
0
def create_imwin(convo, meta, sms, focus = None, mode = 'im'):
    '''
    Logic for where to place a new IM tab.

    Spawns a a new ImWin object, placing it as a new tab in _some_ window
    somewhere, and returns the ImWin.
    '''
    thread_check()

    from gui.imwin.imtabs import ImFrame
    f = None

    hooks.notify('imwin.created')

    focus = new_action() == 'stealfocus' if focus is None else focus

    # if tabs are enabled, search for the oldest living ImFrame and place
    # the new message there--unless CTRL is being held down.
    ctrlDown = pref('messaging.tabs.ctrl_new_window', True) and GetKeyState(WXK_CONTROL)

    if not ctrlDown and pref('messaging.tabs.enabled', True):
        for win in GetTopLevelWindows():
            if isinstance(win, ImFrame):
                f = win
                if f.IsActive():
                    focus = False
                break

    # if the focused control is an IM win's input box, don't steal focus.
    if isinstance(focused_top(), ImFrame):
        focus = False

    if getattr(wx.Window.FindFocus(), 'click_raises_imwin', False) and wx.LeftDown():
        focus = True

    # if we haven't found an ImFrame to put the tab in, create a new one
    if f is None:
        if pref('messaging.tabs.enabled', True):
            id = ''
        else:
            id = meta.idstr() if meta is not None else convo.buddy.idstr()
        f = ImFrame(startMinimized = not focus, posId = id)

    w = ImWinPanel(f)

    if convo is not None:
        w.set_conversation(convo, meta)

    if focus:
        global im_show
        im_show += lambda: raise_imwin(f, w)
        im_show += lambda: w.FocusTextCtrl()

    tab = f.AddTab(w, focus = focus)
    # NOTE: the native IM window doesn't use Page objects so we need to check
    # for it before adding to it.
    # FIXME: tab.OnActive seems to always be called by tab.SetActive, and tab.SetActive
    # also calls FocusTextCtrl on its text control, so is this needed still?
    if hasattr(tab, "OnActive"):
        tab.OnActive += w.FocusTextCtrl

    hooks.notify('digsby.statistics.imwin.imwin_created')

    return w