def start(self): from twisted.internet.defer import Deferred from logs import lg from main import listeners from storage import keys_synchronizer from storage import index_synchronizer from storage import backup_fs self.starting_deferred = Deferred() self.starting_deferred.addErrback( lambda err: lg.warn('service %r was not started: %r' % (self.service_name, err.getErrorMessage() if err else 'unknown reason'))) if keys_synchronizer.is_synchronized( ) and index_synchronizer.is_synchronized(): if not self.starting_deferred.called: self.starting_deferred.callback(True) if listeners.is_populate_requered('private_file'): listeners.populate_later().remove('private_file') backup_fs.populate_private_files() else: lg.warn( 'can not start service_my_data right now, keys_synchronizer.is_synchronized=%r index_synchronizer.is_synchronized=%r' % (keys_synchronizer.is_synchronized(), index_synchronizer.is_synchronized())) return self.starting_deferred
def start(self): from twisted.internet.defer import Deferred from transport import callback from main import events from main import listeners from p2p import online_status from p2p import p2p_service from p2p import p2p_connector from p2p import network_connector from p2p import ratings p2p_service.init() online_status.init() ratings.init() self._starting_defer = Deferred() p2p_connector.A('init') p2p_connector.A().addStateChangedCallback( self._on_p2p_connector_switched) network_connector.A().addStateChangedCallback( self._on_network_connector_switched) callback.append_inbox_callback(self._on_inbox_packet_received) callback.append_inbox_callback(p2p_service.inbox) events.add_subscriber(self._on_identity_url_changed, 'identity-url-changed') events.add_subscriber(self._on_my_identity_url_changed, 'my-identity-url-changed') if listeners.is_populate_requered('online_status'): listeners.populate_later().remove('online_status') online_status.populate_online_statuses() return True
def start(self): from storage import backup_fs from storage import backup_control from storage import backup_matrix from storage import backup_monitor from main.config import conf from main import control from main import events from main import listeners from transport import callback from p2p import p2p_connector backup_fs.init() backup_control.init() backup_matrix.init() backup_matrix.SetBackupStatusNotifyCallback(control.on_backup_stats) backup_matrix.SetLocalFilesNotifyCallback(control.on_read_local_files) backup_monitor.A('init') backup_monitor.A('restart') conf().addConfigNotifier('services/backups/keep-local-copies-enabled', self._on_keep_local_copies_modified) conf().addConfigNotifier('services/backups/wait-suppliers-enabled', self._on_wait_suppliers_modified) p2p_connector.A().addStateChangedCallback( self._on_p2p_connector_state_changed, 'INCOMMING?', 'CONNECTED') p2p_connector.A().addStateChangedCallback( self._on_p2p_connector_state_changed, 'MY_IDENTITY', 'CONNECTED') callback.append_inbox_callback(self._on_inbox_packet_received) events.add_subscriber(self._on_my_identity_rotated, 'my-identity-rotated') events.add_subscriber(self._on_key_erased, 'key-erased') if listeners.is_populate_requered('remote_version'): listeners.populate_later().remove('remote_version') backup_matrix.populate_remote_versions() return True
def _do_open_known_shares(self): from crypt import my_keys from main import listeners from access import shared_access_coordinator from storage import backup_fs known_offline_shares = [] for key_id in my_keys.known_keys(): if not key_id.startswith('share_'): continue active_share = shared_access_coordinator.get_active_share(key_id) if active_share: continue known_offline_shares.append(key_id) to_be_opened = [] for _, _, itemInfo in backup_fs.IterateIDs(): if not itemInfo.key_id: continue if itemInfo.key_id in to_be_opened: continue if itemInfo.key_id not in known_offline_shares: continue to_be_opened.append(itemInfo.key_id) for key_id in to_be_opened: active_share = shared_access_coordinator.SharedAccessCoordinator(key_id, log_events=True, publish_events=False, ) active_share.automat('restart') if listeners.is_populate_requered('shared_file'): listeners.populate_later().remove('shared_file') backup_fs.populate_shared_files(key_id=key_id)
def start(self): from chat import message_database from chat import message_keeper from main import events from main import listeners message_database.init() message_keeper.init() events.add_subscriber(self.on_key_registered, 'key-registered') events.add_subscriber(self.on_key_renamed, 'key-renamed') events.add_subscriber(self.on_key_generated, 'key-generated') if listeners.is_populate_requered('conversation'): listeners.populate_later().remove('conversation') message_database.populate_conversations() if listeners.is_populate_requered('message'): listeners.populate_later().remove('message') message_database.populate_messages() return True
def start(self): from transport import callback from main import listeners from crypt import my_keys from access import key_ring key_ring.init() callback.add_outbox_callback(self._on_outbox_packet_sent) callback.append_inbox_callback(self._on_inbox_packet_received) if listeners.is_populate_requered('key'): listeners.populate_later().remove('key') my_keys.populate_keys() return True
def _on_my_storage_ready(self, evt): from logs import lg from main import listeners from services import driver from storage import backup_fs if self.starting_deferred: if not self.starting_deferred.called: self.starting_deferred.callback(True) self.starting_deferred = None if listeners.is_populate_requered('private_file'): listeners.populate_later().remove('private_file') backup_fs.populate_private_files() if driver.is_enabled('service_my_data'): if not driver.is_started('service_my_data'): lg.info('my storage is ready, starting service_my_data()') driver.start_single('service_my_data')
def load_contacts(): """ Load all my contacts from disk. """ load_suppliers(all_customers=True) if _SuppliersChangedCallback is not None: _SuppliersChangedCallback([], suppliers()) load_customers() if _CustomersChangedCallback is not None: _CustomersChangedCallback([], customers()) load_correspondents() if _CorrespondentsChangedCallback is not None: _CorrespondentsChangedCallback([], correspondents()) AddContactsChangedCallback(on_contacts_changed) if listeners.is_populate_requered('correspondent'): listeners.populate_later().remove('correspondent') populate_correspondents()