Exemplo n.º 1
0
 def __init__(self, profile):
     Observable.__init__(self)
     self.profile = profile
     self.profile.add_observer(self.profile_state_changed, 'state')
     self.waiting_blobs = set(self.blob_names[:])
     self.from_cache = {}
     self.blobhashes = {}
Exemplo n.º 2
0
 def __init__(self, profile):
     Observable.__init__(self)
     self.profile = profile
     self.profile.add_observer(self.profile_state_changed, 'state')
     self.waiting_blobs = set(self.blob_names[:])
     self.from_cache = {}
     self.blobhashes = {}
Exemplo n.º 3
0
    def __init__(self, name, status = None, protocol = 'aim', capabilities=None):
        Observable.__init__(self)
        self.remote_alias = self.name = name

        self.mockprofile       = getattr(MockProfiles,name,'')
        self.buddy             = Storage()
        self.buddy.name        = name
        self.buddy.nice_name   = name
        self.buddy.profile     = self.mockprofile
        self.icon              = skin.get('BuddiesPanel.BuddyIcons.NoIcon')
        self.icon_path         = self.icon.path
        self.icon = self.icon.PIL
        self.id                = 5
        self.status_message    = random.choice(status_messages)
        self.sightly_status    = self.status_orb = self.status = status if status else random.choice(statuses)
        self.buddy.away        = self.status=='away'

        self.protocol          = MockProtocol(protocol)
        self.protocol.icq      = random.choice([True, False])
        self.protocol.username = self.protocol.name

        self.mockcaps          = capabilities if capabilities else [caps.BLOCKABLE, caps.EMAIL, caps.FILES, caps.IM, caps.PICTURES, caps.SMS]
        self.online_time       = None
        self.buddy.protocol    = self.protocol
        self.caps              = self.mockcaps
Exemplo n.º 4
0
    def __init__(self, name, protocol):
        Observable.__init__(self)
        self.add_observer(self.store_remote_alias, 'remote_alias')
        self.name = name
        self.protocol = protocol
        self._notify_dirty = True

        self.entering = self.leaving = False

        # all Buddy slots default to None!
        do(setattr(self, s, None) for s in [
        'icon_bitmap'])

        self.icon_hash = self.get_icon_hash()
        self._getting_image = False
        self._cached_hash   = None
        self.icon_disabled  = False

        # register with the BuddyWatcher
        try:
            register = profile.account_manager.buddywatcher.register
        except AttributeError:
            log.debug('No buddy watcher to register with')
            return
        else:
            register(self)
Exemplo n.º 5
0
 def __init__(self, name, password, **options):
     Observable.__init__(self)
     self.name = name
     self.password = password
     self.id = options.pop('id') if 'id' in options else self.next_id()
     self.alias = options.pop('alias', None)
     self.error_count = 0
Exemplo n.º 6
0
    def __init__(self, name, protocol):
        Observable.__init__(self)
        self.add_observer(self.store_remote_alias, 'remote_alias')
        self.name = name
        self.protocol = protocol
        self._notify_dirty = True

        self.entering = self.leaving = False

        # all Buddy slots default to None!
        do(setattr(self, s, None) for s in ['icon_bitmap'])

        self.icon_hash = self.get_icon_hash()
        self._getting_image = False
        self._cached_hash = None
        self.icon_disabled = False

        # register with the BuddyWatcher
        try:
            register = profile.account_manager.buddywatcher.register
        except AttributeError:
            log.debug('No buddy watcher to register with')
            return
        else:
            register(self)
Exemplo n.º 7
0
 def __init__(self, name, password, **options):
     Observable.__init__(self)
     self.name = name
     self.password = password
     self.id = options.pop('id') if 'id' in options else self.next_id()
     self.alias = options.pop('alias', None)
     self.error_count = 0
Exemplo n.º 8
0
    def __init__(self, name, service):
        Observable.__init__(self)
        self.name = self.nice_name = name
        self._service = service

        self._notify_dirty = True

        self.protocol = p = S(name=self.service,
                              self_buddy=S(name=name),
                              connected=False)
Exemplo n.º 9
0
    def __init__(self, name, service):
        Observable.__init__(self)
        self.name = self.nice_name = name
        self._service  = service

        self._notify_dirty = True

        self.protocol = p = S(name = self.service,
                              self_buddy = S(name = name),
                              connected = False)
Exemplo n.º 10
0
    def __init__(self):
        Observable.__init__(self)

        self.state = self.states.CONNECTING
        self.bytecounts = []
        self._bytes_per_sec = 0
        self.filepath = None
        self.completed = 0
        self._starttime = None
        self._done = False
        self.xfer_display_strings = self._xfer_display_strings.copy()
Exemplo n.º 11
0
    def __init__(self):
        Observable.__init__(self)

        self.state          = self.states.CONNECTING
        self.bytecounts     = []
        self._bytes_per_sec = 0
        self.filepath       = None
        self.completed      = 0
        self._starttime     = None
        self._done          = False
        self.xfer_display_strings = self._xfer_display_strings.copy()
Exemplo n.º 12
0
 def __init__(self, protocol, screenname, cookie, capability=None):
     Observable.__init__(self)
     self.protocol = protocol
     self.screenname = screenname
     self.cookie = cookie
     if capability is not None:
         self.capability = capability
     assert self.capability
     self.buddy = protocol.buddies[screenname]
     self.stage = 0
     self.proxied = False
     self.accepted = False
Exemplo n.º 13
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
Exemplo n.º 14
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
Exemplo n.º 15
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
Exemplo n.º 16
0
    def __getattr__(self, attr):
        try:
            return Observable.__getattribute__(self, attr)

        except AttributeError, e:
            try:
                return getattr(self.account_manager, attr)
            except AttributeError:
                raise e
Exemplo n.º 17
0
    def __init__(self, conn_accts):
        Observable.__init__(self)

        self.dirty = False
        self.sorting_paused = True

        #self._listen_for_pref_load()

        self.rebuild_timer = wx.PyTimer(self.rebuild_later)
        self.rebuild_timer.StartRepeating(500)

        # Holds the final view that goes into the TreeList.
        self.view = DGroup('__root__', [], [])
        self.info = {}

        # Rootgroups are the "protocol" rootgroups with the original,
        # unmodified versions of the buddy list structure for each account
        self.rootgroups = []

        self.base_attrs = frozenset([None, 'alias', 'status', 'status_message', 'icon', 'icon_hash', 'entering', 'leaving', 'idle', 'away','mobile'])
        self.attrs = set(self.base_attrs)

        # conn_accts must be an observable list of connected accounts
        conn_accts.add_observer(self.on_connections_changed)

        self.metacontacts = MetaContactManager(self)
        self._init_order()
        self.contact_info_changed = Delegate()

        self.dispatch = ContactDispatcher()
        self.caches = dict(tofrom = DiskCache('im_history.dat', validator = validate_tofrom))
        self.load_local_data()

        # save local to/from data on exit
        hooks.register('digsby.app.exit', self.save_local_data)

        self._search_by = u''
        self._search_results = (0, 0) # number of contacts found in last two searches

        #todo: make then_bys based on a pref
        self.sort_models = sort_model.build_models(
                               then_bys = 1,
                               obj = self)
        self.sbw = sort_model.SortByWatcher(self.sort_models)
Exemplo n.º 18
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
Exemplo n.º 19
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
Exemplo n.º 20
0
    def notify(self, attr = None, *a, **k):
        # TODO: fix this when we have a better presence system
        self._notify_dirty = True
        profile.blist.buddy_changed(self, attr)

        return Observable.notify(self, attr, *a, **k)
Exemplo n.º 21
0
 def __init__(self):
     Observable.__init__(self)
     self._hidden = 'Hello world'
Exemplo n.º 22
0
 def __init__(self, name):
     Observable.__init__(self)
     self.name = name
Exemplo n.º 23
0
 def __init__(self, name):
     Observable.__init__(self)
     self.name = name
Exemplo n.º 24
0
    def __setstate__(self, info):
        if not hasattr(self, 'observers'):
            Observable.__init__(self)

        return SlotsSavable.__setstate__(self, info)
Exemplo n.º 25
0
 def __init__(self, name, callable):
     Observable.__init__(self)
     funcs.autoassign(self, locals())
Exemplo n.º 26
0
 def __init__(self, connection):
     Observable.__init__(self)
     self.display_name = self.name = connection.username
     self.connection = connection
     self.connection.account = self
Exemplo n.º 27
0
 def __init__(self):
     Observable.__init__(self)
Exemplo n.º 28
0
    def __init__(self, mucRoomUser, room):
        Observable.__init__(self)

        self.user = mucRoomUser
        self.room = room
Exemplo n.º 29
0
    def notify(self, attr=None, *a, **k):
        # TODO: fix this when we have a better presence system
        self._notify_dirty = True
        profile.blist.buddy_changed(self, attr)

        return Observable.notify(self, attr, *a, **k)
Exemplo n.º 30
0
    def __init__(self, mucRoomUser, room):
        Observable.__init__(self)

        self.user = mucRoomUser
        self.room = room
Exemplo n.º 31
0
 def __init__( self, name, callable ):
     Observable.__init__(self)
     funcs.autoassign( self, locals() )
Exemplo n.º 32
0
    def __init__(self, identity):
        Observable.__init__(self)
        ChatProtocol.__init__(self)

        self.identity = identity

        from AccountManager import AccountManager

        self.PreDisconnectHooks  = Delegate()
        self.PostDisconnectHooks = Delegate()

        if not getattr(getattr(sys, 'opts', None), 'limit_log', True):
            DelayedStreamLimiter = lambda s: s
        else:
            from fileutil import DelayedStreamLimiter

        self.consolehandlers = defaultdict(lambda: console_handler_class(DelayedStreamLimiter(sys.stdout)))

        self._status = None

        self.error_count = 0
        self.offline_reason = StateMixin.Reasons.NONE
        self.account_manager = AccountManager(profile = self)
        self.last_hiber_req = None
        self.hibernated = False
        self.linked_observers = False
        self.xfers = ObservableList()
        self.prefs = ObservableDict()
        self.defaultprefs = ObservableDict(prefs.defaultprefs())
        self.quiet = False
        self.prefs_loaded = False

        # set the common.pref lookup to point to our prefs
        import common
        common.set_active_prefs(self.prefs, self.defaultprefs)

        self.prefs.add_observer(self._prefs_changed)

        self.has_authorized = False

        self.statuses = ObservableList()
        self.statuses.add_observer(self._statuses_changed)

        self._xfercount = 0
        self.xfers.add_observer(self._on_file_transfer)

        self.widgets = ObservableList()

        self._encrypter, self._decrypter = util.cryptography.cipher_functions(sha1(self.password.encode('utf8')).digest()[:16])

        self.log_sizes = LogSizeDict()

        global profile
        if profile not in (self, None):
            warnmsg = 'Another DigsbyProfile has been created but the old one is still around!'
            if __debug__:
                raise ValueError(warnmsg)
            else:
                log.critical(warnmsg)

        profile = self  # hack! BuddyListStore needs profile.username

        from contacts.buddyliststore import BuddyListStore
        self.blist = BuddyListStore(self.account_manager.connected_accounts)

        self.set_contact_info = self.blist.set_contact_info
        self.get_contact_info = self.blist.get_contact_info

        from BlobManager import BlobManager
        self.blob_manager = BlobManager(self)

        self.account_manager.add_observer(self.check_loading, 'got_accounts')
        self.account_manager.add_observer(self.on_accounts_loaded, 'accounts_loaded')

        self.blob_manager.add_observer(self.check_loading, 'loading')
        self.loaded = False

        self.OnReturnFromIdle = Delegate()
        self.on_message = PausableDelegate()

        self.OnStatusChange = Delegate()

        self.setup_hub()

        self.idle_timer = None
        self.idle = False

        self.plugins_setup = False
        self.connection = None
        self.setup_plugins()

        self.do_local_load()