Exemple #1
0
    def __init__(self, profile):
        Observable.__init__(self)

        self.accounts_loaded = False

        self.profile = profile
        self.connected_accounts = ObservableList()
        self.reconnect_timers   = {}

        # holds "cancel" objects from Popups
        self.cancellers = {}

        self.profile.add_observer(self.on_state_change,   'state')
        self.profile.add_observer(self.on_offline_change, 'offline_reason')
        self.profile.add_observer(self.profile_state_changed, 'state')

        import wx
        wx.GetApp().OnBuddyListShown.append(lambda *a, **k: Timer(.25,
            threaded(self.release_accounts), *a, **k).start())

        self._hash = sentinel

        self.got_accounts = False

        self.acct_calls = Delegate()
        self.delay_accounts = True
        self.acct_delay_lock = RLock()

        self._all_acct_hash = {}
        self.last_server_order = None

        self._all_accounts = Storage()
        for type_ in ('im', 'em', 'so'):

            s = Storage(accounts = ObservableList(),
                        old = [])

            setattr(self._all_accounts, type_, s)

            # when the order of accounts changes, or accounts are added or deleted,
            # calls profile.accounts_changed('im', list)
            s.accounts.add_observer(getattr(self, type_ + '_accounts_changed'))

        self.accounts = self._all_accounts.im.accounts
        self.emailaccounts = self._all_accounts.em.accounts
        self.socialaccounts = self._all_accounts.so.accounts

        self.buddywatcher = BuddyWatcher()

        import services.service_provider as sp
        container = sp.ServiceProviderContainer(self.profile)
        container.on_order_changed += self._set_order
Exemple #2
0
    def Construct(self):
        parent = self

        self.line1 = wx.StaticText(
            parent,
            label="We hope you've enjoyed using Digsby.",
            style=wx.TE_CENTER)
        self.line2 = wx.StaticText(
            parent,
            label="Please show your support and invite your friends.",
            style=wx.TE_CENTER)

        self.separator = wx.StaticLine(parent)

        self.name_label = wx.StaticText(parent, label='Full Name: ')
        self.name_text = wx.TextCtrl(parent)

        self.acct_list = AnyList(parent,
                                 ObservableList(self.data),
                                 row_control=StaticEmailRow,
                                 multiselect=False,
                                 edit_buttons=None,
                                 draggable_items=False,
                                 style=0,
                                 velocity=None)
        self.acct_list.SetMinSize(wx.Size(-1, (16 + 10) * 4))

        self.acct_panel = PrefPanel(parent, self.acct_list, 'Account')
        self.acct_panel._bg_brush = lambda: wx.Brush(
            wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DFACE))
        self.acct_panel._fg_pen = lambda: wx.Pen(
            wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DSHADOW))

        self.send_button = wx.Button(parent, wx.ID_OK, label='Send Invite!')
        self.send_button.MoveAfterInTabOrder(self.name_text)
Exemple #3
0
 def test_add_remove(self):
     from util.observe import ObservableList
     l = ObservableList()
     b = bar()
     l.add_observer(b.bar)
     l.remove_observer(b.bar)
     self.failIf(any(l.observers.values()), 'still have observers')
Exemple #4
0
    def __init__(self):
        Observable.__init__(self)

        bud = MockBuddy('fakebuddy')

        self.name = 'fakebuddy'
        self.me = MockBuddy('digsby007')

        self.room_list = ObservableList([bud, self.me])
        self.typing_status = ObservableDict()
        self.buddy = bud
        self.messages = Queue()
        self.protocol = Storage(self_buddy=self.me,
                                buddies={'digsby007': self.me})
        self.ischat = False
Exemple #5
0
    def __init__(self, enabled=True, updateNow=True, **options):

        AccountBase.__init__(self, **options)
        UpdateMixin.__init__(self, **options)
        FromNetMixin.__init__(self, **options)

        self.emails = ObservableList()
        self.count = 0
        self.seen = set()
        self._dirty_error = True  # The next error is new.

        log.info('Created EmailAccount: %r. Setting enabled to %r', self,
                 enabled)

        self.enabled = enabled
Exemple #6
0
def main():
    from tests.testapp import testapp
    a = testapp(skinname='Windows 7')
    f = wx.Frame(None, -1, 'roomlist')

    AIM = ('aim', [
        caps.BLOCKABLE, caps.EMAIL, caps.FILES, caps.IM, caps.PICTURES,
        caps.SMS
    ])
    MSN = ('msn', [caps.BLOCKABLE, caps.EMAIL, caps.FILES, caps.IM])
    JBR = ('jabber', [caps.EMAIL, caps.FILES, caps.IM])
    YHO = ('yahoo',
           [caps.BLOCKABLE, caps.EMAIL, caps.FILES, caps.IM, caps.SMS])

    global contacts
    contacts = ObservableList([
        MockBuddy('Aaron', 'away', *JBR),
        MockBuddy('Chris', 'available', *JBR),
        MockBuddy('Jeff', 'offline', *AIM),
        MockBuddy('Kevin', 'away', *YHO),
        MockBuddy('Mike', 'available', *MSN),
        MockBuddy('Steve', 'offline', *AIM),
    ])

    buddies = dict((c.name, c) for c in contacts)

    contacts.extend([
        MockBuddy('Agatha', 'offline', *AIM),
        MockBuddy('Abel', 'away', *YHO),
        MockBuddy('Adam', 'available', *MSN),
        MockBuddy('Amanda', 'offline', *AIM),
        MockBuddy('Beatrice', 'offline', *AIM),
        MockBuddy('Betty', 'away', *YHO),
        MockBuddy('Brian', 'available', *MSN),
        MockBuddy('Biff', 'away', *YHO),
        MockBuddy('Bart', 'available', *MSN),
    ])

    rl = RoomListPanel(f, buddies)
    rl.RoomList = contacts

    f.SetSize((200, 400))
    f.Show()

    a.MainLoop()
Exemple #7
0
    def __init__(self, protocol):

        Observable.__init__(self)

        self.room_list = ObservableList()

        self.protocol = protocol
        self.autoresponded = False
        self.typing_status = observable_dict()
        self.just_had_error = False

        self.pending_contacts_callbacks = set()

        self.start_time_utc = datetime.utcnow()

        self._bind_reconnect()
        self.protocol.add_observer(self.__on_proto_state, 'state')

        self.videochat_urlhandler = None
Exemple #8
0
def main():
    from util.observe import ObservableList, Observable

    app = wx.PySimpleApp()

    f = wx.Frame(None, -1, 'AnyList Test')
    f.Sizer = sz = wx.BoxSizer(wx.VERTICAL)

    class Foo(Observable):
        def __init__(self, name):
            Observable.__init__(self)
            self.name = name

        def __call__(self):
            wx.Bell()

        def __repr__(self):
            return '<Foo %s>' % self.name

    def on_doubleclick(e):
        print e

    foos = [
        Foo(n) for n in 'one two three four five six seven eight nine'.split()
    ]
    data = ObservableList(foos)

    splist = AnyList(f, data)
    splist.Bind(wx.EVT_LISTBOX_DCLICK, on_doubleclick)

    sz.Add(splist, 1, wx.EXPAND | wx.SOUTH,
           15 if 'wxMac' in wx.PlatformInfo else 0)
    splist.Bind(wx.EVT_CHECKBOX, lambda e: e.EventObject.Parent.data())

    f.Show()
    app.MainLoop()
Exemple #9
0
 def _init_contacts(self):
     self.contacts_view = []
     self.contact_enter_times = {}
     self.contact_leave_times = {}
     self.pending_contacts = ObservableList()
Exemple #10
0
def main():
    def on_close(e):
        twitter.disconnect()

        import AsyncoreThread
        AsyncoreThread.join()

        f.Destroy()

    def droptables():
        if wx.YES == wx.MessageBox(
                'Are you sure you want to drop all tables?',
                style = wx.YES_NO, parent = f):
            twitter.clear_cache()

    def build_test_frame():
        f = wx.Frame(None, title='Twitter Test')
        f.SetSize((500, 700))
        f.Bind(wx.EVT_CLOSE, on_close)

        buttons = []
        def button(title, callback):
            b = wx.Button(f, -1, title)
            b.Bind(wx.EVT_BUTTON, lambda e: callback())
            buttons.append(b)

        def infobox():
            from gui.toolbox import Monitor
            from gui.infobox.infobox import DEFAULT_INFOBOX_WIDTH
            from gui.infobox.infoboxapp import init_host, set_hosted_content

            f = wx.Frame(None)
            size = (DEFAULT_INFOBOX_WIDTH, Monitor.GetFromWindow(f).ClientArea.height * .75)
            f.SetClientSize(size)

            w = wx.webview.WebView(f)

            init_host(w)
            set_hosted_content(w, MockTwitterAccount(twitter))
            f.Show()

        def popup():
            twitter.webkitcontroller.evaljs('account.showTimelinePopup();')

        def fake_tweets():
            j('fakeTweets(%d);' % int(fake_tweets_txt.Value))
            twitter.webkitcontroller.webview.GarbageCollect()

        button('Open Window', twitter.open_timeline_window)
        button('Update',      twitter.update)
        button('Infobox',     infobox)
        button('Drop Tables', droptables)
        button('Popup',       popup)
        button('Fake Tweets', fake_tweets)

        s = f.Sizer = wx.BoxSizer(wx.HORIZONTAL)

        v = wx.BoxSizer(wx.VERTICAL)
        v.AddMany(buttons)

        fake_tweets_txt = wx.TextCtrl(f, -1, '1000')
        v.Add(fake_tweets_txt)

        s.Add(v, 0, wx.EXPAND)

        v2 = wx.BoxSizer(wx.VERTICAL)
        stxt = wx.StaticText(f)
        v2.Add(stxt, 0, wx.EXPAND)

        from pprint import pformat
        from common.commandline import wkstats
        def update_text():
            debug_txt = '\n\n'.join([
                pformat(wkstats()),
                j('debugCounts()')
            ])

            stxt.Label = debug_txt
            f.Sizer.Layout()

        f._timer = wx.PyTimer(update_text)
        f._timer.StartRepeating(1000)
        f.SetBackgroundColour(wx.WHITE)

        s.Add((50, 50))
        s.Add(v2, 0, wx.EXPAND)

        return f

    from tests.testapp import testapp

    username, password = '******', 'no passwords'
    if len(sys.argv) > 2:
        username, password = sys.argv[1:3]

    app = testapp(skinname='Windows 7', plugins=True)

    global twitter # on console
    from twitter.twitter import TwitterProtocol
    twitter = TwitterProtocol(username, password)
    twitter.events.state_changed += lambda state: print('state changed:', state)
    twitter.events.reply += lambda screen_name: print('reply:', screen_name)

    import common.protocolmeta
    account_opts = common.protocolmeta.protocols['twitter']['defaults'].copy()

    if '--twitter-offline' in sys.argv:
        account_opts['offlineMode'] = True

    #import simplejson
    #account_opts['feeds'] = simplejson.loads('[{"type": "timeline", "name": "timeline"}, {"type": "mentions", "name": "mentions"}, {"type": "directs", "name": "directs"}, {"name": "group:1", "popups": false, "ids": [14337372, 9499402, 8517312, 7341872, 32218792, 9853162], "filter": false, "groupName": ".syntax", "type": "group"}, {"name": "search:1", "title": "foramilliondollars", "popups": false, "merge": false, "query": "#foramilliondollars", "save": true, "type": "search"}]')

    twitter.connect(account_opts)

    # mock an accountmanager/social networks list for the global status dialog
    from util.observe import ObservableList, Observable
    class TwitterAccount(Observable):
        service = protocol = 'twitter'
        enabled = True
        ONLINE = True
        def __init__(self, connection):
            Observable.__init__(self)
            self.display_name = self.name = connection.username
            self.connection = connection
            self.connection.account = self

    import digsbyprofile
    from util import Storage as S

    acctmgr = digsbyprofile.profile.account_manager = S(
        socialaccounts = ObservableList([TwitterAccount(twitter)])
    )
    digsbyprofile.profile.socialaccounts = acctmgr.socialaccounts

    global j
    j = twitter.webkitcontroller.evaljs

    def _html():
        txt = twitter.webkitcontroller.FeedWindow.PageSource.encode('utf-8')
        from path import path
        p = path(r'c:\twitter.html')
        p.write_bytes(txt)
        wx.LaunchDefaultBrowser(p.url())

    global html
    html = _html

    f = build_test_frame()
    f.Show()

    if '--drop' in sys.argv:
        twitter.clear_cache()

    wx.CallLater(500, twitter.open_timeline_window)

    app.MainLoop()
Exemple #11
0
class Statuses(SerializableNetData):
    xml_element_namespace = DIGSBY_STATUS_NS

    fallback = lambda self: ObservableList()
    basetype = list
Exemple #12
0
if __name__ == '__main__':
    from util.observe import ObservableList
    from tests.mock.mockbuddy import MockBuddy
    from tests.testapp import testapp

    a = testapp(plugins=False)
    f = wx.Frame(None, title='File Transfers')
    f.Bind(wx.EVT_CLOSE, lambda e: a.ExitMainLoop())

    filexfers = ObservableList([
        MockFileTransfer(
            buddy=MockBuddy('digsby03'),
            filepath=path('c:\\YyyyYgq-v3.1.exe'),
            size=120.6 * 1024 * 1024,
            completed=0,
            direction='incoming',
        ),
        MockFileTransfer(buddy=MockBuddy('dotsyntax1'),
                         filepath=path('c:\\DL Manager(2).jpg'),
                         size=253 * 1024,
                         completed=253 * 1024,
                         direction='outgoing')
    ])

    ft = filexfers[0]
    ft.state = ft.states.WAITING_FOR_YOU
    filexfers[1].state = ft.states.WAITING_FOR_BUDDY

    def tick(self):
        newval = ft.completed + 320 * 1024
        ft._setcompleted(min(ft.size, newval))