Exemple #1
0
 def __init__(self, filename):
     values = dict()
     values["name"] = filename
     super(LockNotification, self).__init__("LOCK",
         title=Translator.get("LOCK_NOTIFICATION_TITLE", values),
         description=Translator.get("LOCK_NOTIFICATION_DESCRIPTION", values), level=Notification.LEVEL_INFO,
         flags=Notification.FLAG_VOLATILE|Notification.FLAG_BUBBLE|Notification.FLAG_DISCARD_ON_TRIGGER|Notification.FLAG_REMOVE_ON_DISCARD)
Exemple #2
0
    def menu_right(self):
        """
        Create the context menu.
        It shows up on left click.

        Note: icons will not be displayed on every GNU/Linux
        distributions, it depends on the graphical environment.
        """

        if not self.__menu_right:
            style = QApplication.style()
            menu = QMenu()
            menu.addAction(
                style.standardIcon(QStyle.SP_FileDialogInfoView),
                Translator.get('SETTINGS'),
                self.application.show_settings,
            )
            menu.addSeparator()
            menu.addAction(style.standardIcon(QStyle.SP_MessageBoxQuestion),
                           Translator.get('HELP'), self.application.open_help)
            menu.addSeparator()
            menu.addAction(style.standardIcon(QStyle.SP_DialogCloseButton),
                           Translator.get('QUIT'), self.application.quit)
            self.__menu_right = menu

        return self.__menu_right
Exemple #3
0
 def _root_moved(self, new_path):
     engine = self.sender()
     log.debug('Root has been moved for engine: %s to %r', engine.uid,
               new_path)
     info = {
         'folder': engine.local_folder,
         'new_folder': new_path,
     }
     dlg = WebModal(self, Translator.get('DRIVE_ROOT_MOVED', info))
     dlg.add_button('MOVE',
                    Translator.get('DRIVE_ROOT_UPDATE'),
                    style='primary')
     dlg.add_button('RECREATE', Translator.get('DRIVE_ROOT_RECREATE'))
     dlg.add_button('DISCONNECT',
                    Translator.get('DRIVE_ROOT_DISCONNECT'),
                    style='danger')
     res = dlg.exec_()
     if res == 'DISCONNECT':
         self.manager.unbind_engine(engine.uid)
     elif res == 'RECREATE':
         engine.reinit()
         engine.start()
     elif res == 'MOVE':
         engine.set_local_folder(unicode(new_path))
         engine.start()
Exemple #4
0
 def _direct_edit_conflict(self, filename, ref, digest):
     log.trace('Entering _direct_edit_conflict for %r / %r', filename, ref)
     try:
         filename = unicode(filename)
         if filename in self._conflicts_modals:
             log.trace('Filename already in _conflicts_modals: %r',
                       filename)
             return
         log.trace('Putting filename in _conflicts_modals: %r', filename)
         self._conflicts_modals[filename] = True
         info = dict(name=filename)
         dlg = WebModal(
             self,
             Translator.get('DIRECT_EDIT_CONFLICT_MESSAGE', info),
         )
         dlg.add_button('OVERWRITE',
                        Translator.get('DIRECT_EDIT_CONFLICT_OVERWRITE'))
         dlg.add_button('CANCEL',
                        Translator.get('DIRECT_EDIT_CONFLICT_CANCEL'))
         res = dlg.exec_()
         if res == 'OVERWRITE':
             self.manager.direct_edit.force_update(unicode(ref),
                                                   unicode(digest))
         del self._conflicts_modals[filename]
     except:
         log.exception(
             'Error while displaying Direct Edit'
             ' conflict modal dialog for %r', filename)
Exemple #5
0
    def change_systray_icon(self):
        syncing = False
        engines = self.manager.get_engines()
        invalid_credentials = True
        paused = True
        offline = True

        for engine in engines.itervalues():
            syncing |= engine.is_syncing()
            invalid_credentials &= engine.has_invalid_credentials()
            paused &= engine.is_paused()
            offline &= engine.is_offline()

        if offline:
            new_state = 'stopping'
            Action(Translator.get('OFFLINE'))
        elif invalid_credentials:
            new_state = 'stopping'
            Action(Translator.get('INVALID_CREDENTIALS'))
        elif not engines or paused:
            new_state = 'disabled'
            Action.finish_action()
        elif syncing:
            new_state = 'transferring'
        else:
            new_state = 'asleep'
            Action.finish_action()

        self.set_icon_state(new_state)
    def change_systray_icon(self):
        syncing = False
        engines = self.manager.get_engines()
        invalid_credentials = True
        paused = True
        offline = True

        for engine in engines.itervalues():
            syncing |= engine.is_syncing()
            invalid_credentials &= engine.has_invalid_credentials()
            paused &= engine.is_paused()
            offline &= engine.is_offline()

        if offline:
            new_state = 'stopping'
            Action(Translator.get('OFFLINE'))
        elif invalid_credentials:
            new_state = 'stopping'
            Action(Translator.get('INVALID_CREDENTIALS'))
        elif not engines or paused:
            new_state = 'disabled'
            Action.finish_action()
        elif syncing:
            new_state = 'transferring'
        else:
            new_state = 'asleep'
            Action.finish_action()

        self.set_icon_state(new_state)
Exemple #7
0
 def __init__(self, filename):
     values = dict()
     values["name"] = filename
     super(LockNotification, self).__init__("LOCK",
         title=Translator.get("LOCK_NOTIFICATION_TITLE", values),
         description=Translator.get("LOCK_NOTIFICATION_DESCRIPTION", values), level=Notification.LEVEL_INFO,
         flags=Notification.FLAG_VOLATILE|Notification.FLAG_BUBBLE|Notification.FLAG_DISCARD_ON_TRIGGER|Notification.FLAG_REMOVE_ON_DISCARD)
Exemple #8
0
 def _direct_edit_conflict(self, filename, ref, digest):
     try:
         log.trace('Entering _direct_edit_conflict for %r / %r', filename,
                   ref)
         filename = unicode(filename)
         log.trace('Unicode filename: %r', filename)
         if filename in self._conflicts_modals:
             log.trace('Filename already in _conflicts_modals: %r',
                       filename)
             return
         log.trace('Putting filename in _conflicts_modals: %r', filename)
         self._conflicts_modals[filename] = True
         info = dict()
         info["name"] = filename
         dlg = WebModal(
             self, Translator.get("DIRECT_EDIT_CONFLICT_MESSAGE", info))
         dlg.add_button("OVERWRITE",
                        Translator.get("DIRECT_EDIT_CONFLICT_OVERWRITE"))
         dlg.add_button("CANCEL",
                        Translator.get("DIRECT_EDIT_CONFLICT_CANCEL"))
         res = dlg.exec_()
         if res == "OVERWRITE":
             self.manager.get_drive_edit().force_update(
                 unicode(ref), unicode(digest))
         del self._conflicts_modals[filename]
     except Exception:
         log.exception(
             'Error while displaying Direct Edit conflict modal dialog for %r',
             filename)
Exemple #9
0
    def menu_right(self):
        """
        Create the context menu.
        It shows up on left click.

        Note: icons will not be displayed on every GNU/Linux
        distributions, it depends on the graphical environment.
        """

        if not self.__menu_right:
            style = QApplication.style()
            menu = QMenu()
            menu.addAction(
                style.standardIcon(QStyle.SP_FileDialogInfoView),
                Translator.get('SETTINGS'),
                self.application.show_settings,
            )
            menu.addSeparator()
            menu.addAction(
                style.standardIcon(QStyle.SP_MessageBoxQuestion),
                Translator.get('HELP'),
                self.application.open_help)
            menu.addSeparator()
            menu.addAction(
                style.standardIcon(QStyle.SP_DialogCloseButton),
                Translator.get('QUIT'),
                self.application.quit)
            self.__menu_right = menu

        return self.__menu_right
Exemple #10
0
 def _direct_edit_conflict(self, filename, ref, digest):
     log.trace('Entering _direct_edit_conflict for %r / %r', filename, ref)
     try:
         filename = unicode(filename)
         if filename in self._conflicts_modals:
             log.trace('Filename already in _conflicts_modals: %r', filename)
             return
         log.trace('Putting filename in _conflicts_modals: %r', filename)
         self._conflicts_modals[filename] = True
         info = dict(name=filename)
         dlg = WebModal(
             self,
             Translator.get('DIRECT_EDIT_CONFLICT_MESSAGE', info),
         )
         dlg.add_button('OVERWRITE',
                        Translator.get('DIRECT_EDIT_CONFLICT_OVERWRITE'))
         dlg.add_button('CANCEL',
                        Translator.get('DIRECT_EDIT_CONFLICT_CANCEL'))
         res = dlg.exec_()
         if res == 'OVERWRITE':
             self.manager.direct_edit.force_update(unicode(ref),
                                                   unicode(digest))
         del self._conflicts_modals[filename]
     except:
         log.exception('Error while displaying Direct Edit'
                       ' conflict modal dialog for %r', filename)
Exemple #11
0
 def testLoadExistingLanguage(self):
     Translator(MockManager(), self.getFolder('i18n.js'), "fr")
     # Should not fallback on en
     self.assertEqual("fr", Translator.locale())
     # Test the key fallback
     self.assertEqual("Fallback", Translator.get("FALLBACK"))
     self.assertEqual(u"Fran\xe7ais", Translator.get("LANGUAGE"))
     self.assertEqual("BOUZOUF", Translator.get("BOUZOUF"))
 def _update_notification(self):
     replacements = dict()
     replacements["version"] = self.manager.get_updater().get_status()[1]
     notification = Notification(uuid="AutoUpdate",
                                 flags=Notification.FLAG_BUBBLE|Notification.FLAG_VOLATILE|Notification.FLAG_UNIQUE,
                                 title=Translator.get("AUTOUPDATE_NOTIFICATION_TITLE", replacements),
                                 description=Translator.get("AUTOUPDATE_NOTIFICATION_MESSAGE", replacements))
     self.manager.get_notification_service().send_notification(notification)
 def __init__(self, engine_uid, filename):
     values = dict()
     values["name"] = filename
     title = Translator.get("DELETE_READONLY", values)
     description = Translator.get("DELETE_READONLY_DOCUMENT", values)
     super(DeleteReadOnlyNotification, self).__init__("DELETE_READONLY", title=title, description=description,
                                                      engine_uid=engine_uid, level=Notification.LEVEL_INFO,
                                                      flags=Notification.FLAG_VOLATILE|Notification.FLAG_BUBBLE|Notification.FLAG_DISCARD_ON_TRIGGER|Notification.FLAG_REMOVE_ON_DISCARD)
Exemple #14
0
 def __init__(self, engine_uid, filename):
     values = dict()
     values["name"] = filename
     title = Translator.get("DELETE_READONLY", values)
     description = Translator.get("DELETE_READONLY_DOCUMENT", values)
     super(DeleteReadOnlyNotification, self).__init__("DELETE_READONLY", title=title, description=description,
                                                      engine_uid=engine_uid, level=Notification.LEVEL_INFO,
                                                      flags=Notification.FLAG_VOLATILE|Notification.FLAG_BUBBLE|Notification.FLAG_DISCARD_ON_TRIGGER|Notification.FLAG_REMOVE_ON_DISCARD)
 def testLoadExistingLanguage(self):
     Translator(MockManager(),  self.getFolder('i18n.js'), "fr")
     # Should not fallback on en
     self.assertEqual("fr", Translator.locale())
     # Test the key fallback
     self.assertEqual("Fallback", Translator.get("FALLBACK"))
     self.assertEqual(u"Fran\xe7ais", Translator.get("LANGUAGE"))
     self.assertEqual("BOUZOUF", Translator.get("BOUZOUF"))
Exemple #16
0
 def __init__(self, filename):
     values = dict()
     values["name"] = filename
     title = Translator.get("READONLY", values)
     description = Translator.get("DIRECT_EDIT_READONLY_FILE", values)
     super(DirectEditReadOnlyNotification, self).__init__("DIRECT_EDIT_READONLY", title=title, description=description,
         level=Notification.LEVEL_WARNING,
         flags=Notification.FLAG_VOLATILE|Notification.FLAG_BUBBLE|Notification.FLAG_DISCARD_ON_TRIGGER|Notification.FLAG_REMOVE_ON_DISCARD)
Exemple #17
0
 def __init__(self, engine_uid, doc_pair):
     values = dict()
     values["name"] = doc_pair.local_name
     title = Translator.get("CONFLICT", values)
     description = Translator.get("CONFLICT_ON_FILE", values)
     super(ConflictNotification, self).__init__("CONFLICT_FILE", title=title, description=description,
         engine_uid=engine_uid, level=Notification.LEVEL_WARNING,
         flags=Notification.FLAG_VOLATILE|Notification.FLAG_ACTIONABLE|Notification.FLAG_BUBBLE|Notification.FLAG_PERSISTENT|Notification.FLAG_DISCARD_ON_TRIGGER|Notification.FLAG_REMOVE_ON_DISCARD,
         action="drive.showConflicts();")
Exemple #18
0
 def __init__(self, engine_uid, doc_pair):
     values = dict()
     values["name"] = doc_pair.local_name
     title = Translator.get("CONFLICT", values)
     description = Translator.get("CONFLICT_ON_FILE", values)
     super(ConflictNotification, self).__init__("CONFLICT_FILE", title=title, description=description,
         engine_uid=engine_uid, level=Notification.LEVEL_WARNING,
         flags=Notification.FLAG_VOLATILE|Notification.FLAG_ACTIONABLE|Notification.FLAG_BUBBLE|Notification.FLAG_PERSISTENT|Notification.FLAG_DISCARD_ON_TRIGGER|Notification.FLAG_REMOVE_ON_DISCARD,
         action="drive.showConflicts();")
Exemple #19
0
 def __init__(self, filename):
     values = dict(name=filename)
     super(DirectEditReadOnlyNotification, self).__init__(
         'DIRECT_EDIT_READONLY',
         title=Translator.get('READONLY', values),
         description=Translator.get('DIRECT_EDIT_READONLY_FILE', values),
         level=Notification.LEVEL_WARNING,
         flags=Notification.FLAG_PERSISTENT | Notification.FLAG_BUBBLE,
     )
Exemple #20
0
 def _export_state(self, state):
     if state is None:
         return None
     result = super(WebConflictsApi, self)._export_state(state)
     result["last_contributor"] = self._engine.get_user_full_name(state.last_remote_modifier)
     date_time = self.get_date_from_sqlite(state.last_remote_updated)
     result["last_remote_update"] = "" if date_time == 0 else Translator.format_datetime(date_time)
     date_time = self.get_date_from_sqlite(state.last_local_updated)
     result["last_local_update"] = "" if date_time == 0 else Translator.format_datetime(date_time)
     return result
Exemple #21
0
 def __init__(self, filename, lock_owner, lock_created):
     values = dict()
     values["name"] = filename
     values["lock_owner"] = lock_owner
     values["lock_created"] = lock_created.strftime("%m/%d/%Y %H:%M:%S")
     title = Translator.get("LOCKED", values)
     description = Translator.get("DIRECT_EDIT_LOCKED_FILE", values)
     super(DirectEditLockedNotification, self).__init__("DIRECT_EDIT_LOCKED", title=title, description=description,
         level=Notification.LEVEL_WARNING,
         flags=Notification.FLAG_VOLATILE|Notification.FLAG_BUBBLE|Notification.FLAG_DISCARD_ON_TRIGGER|Notification.FLAG_REMOVE_ON_DISCARD)
Exemple #22
0
 def __init__(self, engine_uid, filename):
     values = dict(name=filename)
     super(DeleteReadOnlyNotification, self).__init__(
         'DELETE_READONLY',
         title=Translator.get('DELETE_READONLY', values),
         description=Translator.get('DELETE_READONLY_DOCUMENT', values),
         engine_uid=engine_uid,
         level=Notification.LEVEL_WARNING,
         flags=Notification.FLAG_PERSISTENT | Notification.FLAG_BUBBLE,
     )
Exemple #23
0
 def __init__(self, engine_uid, filename, lock_owner, lock_created):
     values = dict()
     values["name"] = filename
     values["lock_owner"] = lock_owner
     values["lock_created"] = lock_created.strftime("%m/%d/%Y %H:%M:%S")
     title = Translator.get("LOCKED", values)
     description = Translator.get("LOCKED_FILE", values)
     super(LockedNotification, self).__init__("LOCKED", title=title, description=description,
         engine_uid=engine_uid, level=Notification.LEVEL_WARNING,
         flags=Notification.FLAG_VOLATILE|Notification.FLAG_BUBBLE|Notification.FLAG_DISCARD_ON_TRIGGER|Notification.FLAG_REMOVE_ON_DISCARD)
Exemple #24
0
 def create_debug_menu(self, parent):
     menuDebug = QtGui.QMenu(parent)
     menuDebug.addAction(Translator.get("DEBUG_WINDOW"), self.show_debug_window)
     menuDebug.addAction(Translator.get("DEBUG_SYSTRAY_MESSAGE"), self._debug_show_message)
     for engine in self.manager.get_engines().values():
         action = QtGui.QAction(engine._name, menuDebug)
         action.setMenu(self._create_debug_engine_menu(engine, menuDebug))
         action.setData(engine)
         menuDebug.addAction(action)
     return menuDebug
Exemple #25
0
 def __init__(self, engine_uid, filename, parent=None):
     values = dict(name=filename, folder=parent)
     description = 'READONLY_FILE' if parent is None else 'READONLY_FOLDER'
     super(ReadOnlyNotification, self).__init__(
         'READONLY',
         title=Translator.get('READONLY', values),
         description=Translator.get(description, values),
         engine_uid=engine_uid,
         level=Notification.LEVEL_WARNING,
         flags=Notification.FLAG_PERSISTENT | Notification.FLAG_BUBBLE,
     )
Exemple #26
0
 def _update_notification(self):
     replacements = dict(version=self.manager.get_updater().get_status()[1])
     notification = Notification(
         uuid='AutoUpdate',
         flags=(Notification.FLAG_BUBBLE
                | Notification.FLAG_VOLATILE
                | Notification.FLAG_UNIQUE),
         title=Translator.get('AUTOUPDATE_NOTIFICATION_TITLE', replacements),
         description=Translator.get('AUTOUPDATE_NOTIFICATION_MESSAGE',
                                    replacements),
     )
     self.manager.notification_service.send_notification(notification)
Exemple #27
0
 def __init__(self, engine_uid, filename, parent=None):
     values = dict()
     values["name"] = filename
     values["folder"] = parent
     title = Translator.get("READONLY", values)
     if parent is None:
         description = Translator.get("READONLY_FILE", values)
     else:
         description = Translator.get("READONLY_FOLDER", values)
     super(ReadOnlyNotification, self).__init__("READONLY", title=title, description=description,
         engine_uid=engine_uid, level=Notification.LEVEL_WARNING,
         flags=Notification.FLAG_VOLATILE|Notification.FLAG_BUBBLE|Notification.FLAG_DISCARD_ON_TRIGGER|Notification.FLAG_REMOVE_ON_DISCARD)
Exemple #28
0
 def _update_notification(self):
     replacements = dict()
     replacements["version"] = self.manager.get_updater().get_status()[1]
     notification = Notification(
         uuid="AutoUpdate",
         flags=Notification.FLAG_BUBBLE | Notification.FLAG_VOLATILE
         | Notification.FLAG_UNIQUE,
         title=Translator.get("AUTOUPDATE_NOTIFICATION_TITLE",
                              replacements),
         description=Translator.get("AUTOUPDATE_NOTIFICATION_MESSAGE",
                                    replacements))
     self.manager.get_notification_service().send_notification(notification)
Exemple #29
0
 def _export_state(self, state):
     if state is None:
         return None
     result = super(WebConflictsApi, self)._export_state(state)
     result["last_contributor"] = " " if state.last_remote_modifier is None \
                                     else self._engine.get_user_full_name(state.last_remote_modifier)
     date_time = self.get_date_from_sqlite(state.last_remote_updated)
     result["last_remote_update"] = "" if date_time == 0 else Translator.format_datetime(date_time)
     date_time = self.get_date_from_sqlite(state.last_local_updated)
     result["last_local_update"] = "" if date_time == 0 else Translator.format_datetime(date_time)
     result["remote_can_update"] = state.remote_can_update
     return result
Exemple #30
0
 def __init__(self, engine_uid, filename, parent=None):
     values = dict()
     values["name"] = filename
     values["folder"] = parent
     title = Translator.get("READONLY", values)
     if parent is None:
         description = Translator.get("READONLY_FILE", values)
     else:
         description = Translator.get("READONLY_FOLDER", values)
     super(ReadOnlyNotification, self).__init__("READONLY", title=title, description=description,
         engine_uid=engine_uid, level=Notification.LEVEL_WARNING,
         flags=Notification.FLAG_VOLATILE|Notification.FLAG_BUBBLE|Notification.FLAG_DISCARD_ON_TRIGGER|Notification.FLAG_REMOVE_ON_DISCARD)
Exemple #31
0
 def _update_notification(self):
     replacements = dict(version=self.manager.get_updater().get_status()[1])
     notification = Notification(
         uuid='AutoUpdate',
         flags=(Notification.FLAG_BUBBLE
                | Notification.FLAG_VOLATILE
                | Notification.FLAG_UNIQUE),
         title=Translator.get('AUTOUPDATE_NOTIFICATION_TITLE',
                              replacements),
         description=Translator.get('AUTOUPDATE_NOTIFICATION_MESSAGE',
                                    replacements),
     )
     self.manager.notification_service.send_notification(notification)
 def _create_debug_engine_menu(self, engine, parent):
     menuDebug = QtGui.QMenu(parent)
     action = QtGui.QAction(Translator.get("DEBUG_INVALID_CREDENTIALS"), menuDebug)
     action.setCheckable(True)
     action.setChecked(engine.has_invalid_credentials())
     action.setData(engine)
     action.triggered.connect(self._debug_toggle_invalid_credentials)
     menuDebug.addAction(action)
     action = QtGui.QAction(Translator.get("DEBUG_FILE_STATUS"), menuDebug)
     action.setData(engine)
     action.triggered.connect(self._debug_show_file_status)
     menuDebug.addAction(action)
     return menuDebug
Exemple #33
0
 def _create_debug_engine_menu(self, engine, parent):
     menuDebug = QtGui.QMenu(parent)
     action = QtGui.QAction(Translator.get("DEBUG_INVALID_CREDENTIALS"),
                            menuDebug)
     action.setCheckable(True)
     action.setChecked(engine.has_invalid_credentials())
     action.setData(engine)
     action.triggered.connect(self._debug_toggle_invalid_credentials)
     menuDebug.addAction(action)
     action = QtGui.QAction(Translator.get("DEBUG_FILE_STATUS"), menuDebug)
     action.setData(engine)
     action.triggered.connect(self._debug_show_file_status)
     menuDebug.addAction(action)
     return menuDebug
Exemple #34
0
 def __init__(self, engine_uid, doc_pair):
     values = dict()
     if doc_pair.local_name is not None:
         values["name"] = doc_pair.local_name
     elif doc_pair.remote_name is not None:
         values["name"] = doc_pair.remote_name
     else:
         values["name"] = ""
     title = Translator.get("ERROR", values)
     description = Translator.get("ERROR_ON_FILE", values)
     super(ErrorNotification, self).__init__("ERROR", title=title, description=description,
         engine_uid=engine_uid, level=Notification.LEVEL_ERROR,
         flags=Notification.FLAG_VOLATILE|Notification.FLAG_ACTIONABLE|Notification.FLAG_BUBBLE|Notification.FLAG_PERSISTENT|Notification.FLAG_DISCARD_ON_TRIGGER|Notification.FLAG_REMOVE_ON_DISCARD,
         action="drive.showConflicts();")
Exemple #35
0
 def __init__(self, type, filename, ref):
     values = dict()
     values["name"] = filename
     values["ref"] = ref
     if type == 'lock':
         title = Translator.get("DRIVE_EDIT_LOCK_ERROR", values)
         description = Translator.get("DRIVE_EDIT_LOCK_ERROR_DESCRIPTION", values)
     elif type == 'unlock':
         title = Translator.get("DRIVE_EDIT_UNLOCK_ERROR", values)
         description = Translator.get("DRIVE_EDIT_UNLOCK_ERROR_DESCRIPTION", values)
     else:
         raise Exception()
     super(DriveEditErrorLockNotification, self).__init__("ERROR", title=title, description=description, level=Notification.LEVEL_ERROR,
         flags=Notification.FLAG_VOLATILE|Notification.FLAG_BUBBLE|Notification.FLAG_DISCARD_ON_TRIGGER|Notification.FLAG_REMOVE_ON_DISCARD)
Exemple #36
0
 def _direct_edit_conflict(self, filename, ref, digest):
     filename = unicode(filename)
     if filename in self._conflicts_modals:
         return
     self._conflicts_modals[filename] = True
     info = dict()
     info["name"] = filename
     dlg = WebModal(self, Translator.get("DIRECT_EDIT_CONFLICT_MESSAGE", info))
     dlg.add_button("OVERWRITE", Translator.get("DIRECT_EDIT_CONFLICT_OVERWRITE"))
     dlg.add_button("CANCEL", Translator.get("DIRECT_EDIT_CONFLICT_CANCEL"))
     res = dlg.exec_()
     if res == "OVERWRITE":
         self.manager.get_drive_edit().force_update(unicode(ref), unicode(digest))
     del self._conflicts_modals
Exemple #37
0
 def _root_deleted(self):
     engine = self.sender()
     info = dict()
     log.debug("Root has been deleted for engine: %s", engine.get_uid())
     info["folder"] = engine.get_local_folder()
     dlg = WebModal(self, Translator.get("DRIVE_ROOT_DELETED", info))
     dlg.add_button("RECREATE", Translator.get("DRIVE_ROOT_RECREATE"), style="primary")
     dlg.add_button("DISCONNECT", Translator.get("DRIVE_ROOT_DISCONNECT"), style="danger")
     res = dlg.exec_()
     if res == "DISCONNECT":
         self.manager.unbind_engine(engine.get_uid())
     elif res == "RECREATE":
         engine.reinit()
         engine.start()
Exemple #38
0
 def __init__(self, type, filename, ref):
     values = dict()
     values["name"] = filename
     values["ref"] = ref
     if type == 'lock':
         title = Translator.get("DIRECT_EDIT_LOCK_ERROR", values)
         description = Translator.get("DIRECT_EDIT_LOCK_ERROR_DESCRIPTION", values)
     elif type == 'unlock':
         title = Translator.get("DIRECT_EDIT_UNLOCK_ERROR", values)
         description = Translator.get("DIRECT_EDIT_UNLOCK_ERROR_DESCRIPTION", values)
     else:
         raise Exception()
     super(DirectEditErrorLockNotification, self).__init__("ERROR", title=title, description=description, level=Notification.LEVEL_ERROR,
         flags=Notification.FLAG_VOLATILE|Notification.FLAG_BUBBLE|Notification.FLAG_DISCARD_ON_TRIGGER|Notification.FLAG_REMOVE_ON_DISCARD)
Exemple #39
0
 def __init__(self, engine_uid, doc_pair):
     values = dict()
     if doc_pair.local_name is not None:
         values["name"] = doc_pair.local_name
     elif doc_pair.remote_name is not None:
         values["name"] = doc_pair.remote_name
     else:
         values["name"] = ""
     title = Translator.get("ERROR", values)
     description = Translator.get("ERROR_ON_FILE", values)
     super(ErrorNotification, self).__init__("ERROR", title=title, description=description,
         engine_uid=engine_uid, level=Notification.LEVEL_ERROR,
         flags=Notification.FLAG_VOLATILE|Notification.FLAG_ACTIONABLE|Notification.FLAG_BUBBLE|Notification.FLAG_PERSISTENT|Notification.FLAG_DISCARD_ON_TRIGGER|Notification.FLAG_REMOVE_ON_DISCARD,
         action="drive.showConflicts();")
 def __init__(self, filename):
     values = dict()
     values["name"] = filename
     title = Translator.get("READONLY", values)
     description = Translator.get("DIRECT_EDIT_READONLY_FILE", values)
     super(DirectEditReadOnlyNotification, self).__init__(
         "DIRECT_EDIT_READONLY",
         title=title,
         description=description,
         level=Notification.LEVEL_WARNING,
         flags=Notification.FLAG_VOLATILE
         | Notification.FLAG_BUBBLE
         | Notification.FLAG_DISCARD_ON_TRIGGER
         | Notification.FLAG_REMOVE_ON_DISCARD,
     )
Exemple #41
0
 def _export_state(self, state):
     if state is None:
         return None
     result = super(WebConflictsApi, self)._export_state(state)
     result["last_contributor"] = " " if state.last_remote_modifier is None \
         else self._engine.get_user_full_name(state.last_remote_modifier, cache_only=not self.retrieve_name)
     date_time = self.get_date_from_sqlite(state.last_remote_updated)
     result["last_remote_update"] = "" if date_time == 0 else Translator.format_datetime(date_time)
     date_time = self.get_date_from_sqlite(state.last_local_updated)
     result["last_local_update"] = "" if date_time == 0 else Translator.format_datetime(date_time)
     result["remote_can_update"] = state.remote_can_update
     result['remote_can_rename'] = state.remote_can_rename
     result['duplication_enabled'] = (self._engine.get_local_client()
                                          .duplication_enabled())
     return result
Exemple #42
0
 def _export_state(self, state):
     if state is None:
         return None
     result = dict()
     # Direction
     result["state"] = state.pair_state
     # Last sync in sec
     try:
         current_time = int(time.time())
         date_time = self.get_date_from_sqlite(state.last_sync_date)
         sync_time = self.get_timestamp_from_date(date_time)
         if state.last_local_updated > state.last_remote_updated:
             result["last_sync_direction"] = "download"
         else:
             result["last_sync_direction"] = "upload"
         result["last_sync"] = current_time - sync_time
         if date_time == 0:
             result["last_sync_date"] = ""
         else:
             # As date_time is in UTC
             result["last_sync_date"] = Translator.format_datetime(date_time + tzlocal._dst_offset)
     except Exception as e:
         log.exception(e)
     result["name"] = state.local_name
     if state.local_name is None:
         result["name"] = state.remote_name
     result["remote_name"] = state.remote_name
     result["last_error"] = state.last_error
     result["local_path"] = state.local_path
     result["local_parent_path"] = state.local_parent_path
     result["remote_ref"] = state.remote_ref
     result["folderish"] = state.folderish
     result["last_transfer"] = state.last_transfer
     result["id"] = state.id
     return result
Exemple #43
0
 def _init_translator(self):
     if (self.options is not None):
         default_locale = self.options.locale
     else:
         default_locale = 'en'
     Translator(self.manager, self.get_htmlpage('i18n.js'),
                self.manager.get_config("locale", default_locale))
Exemple #44
0
 def __init__(self, filename, lock_owner, lock_created):
     values = {
         'name': filename,
         'lock_owner': lock_owner,
         'lock_created': lock_created.strftime('%m/%d/%Y %H:%M:%S'),
     }
     super(DirectEditLockedNotification, self).__init__(
         'DIRECT_EDIT_LOCKED',
         title=Translator.get('LOCKED', values),
         description=Translator.get('DIRECT_EDIT_LOCKED_FILE', values),
         level=Notification.LEVEL_WARNING,
         flags=(Notification.FLAG_VOLATILE
                | Notification.FLAG_BUBBLE
                | Notification.FLAG_DISCARD_ON_TRIGGER
                | Notification.FLAG_REMOVE_ON_DISCARD),
     )
Exemple #45
0
    def __init__(self, application, engine, parent=None):
        """
        Constructor
        """
        super(FiltersDialog, self).__init__(parent)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.setWindowTitle(Translator.get("FILTERS_WINDOW_TITLE"))

        self.resize(491, 443)
        self.verticalLayout = QtGui.QVBoxLayout(self)
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)

        self._engine = engine
        self._application = application
        icon = self._application.get_window_icon()
        if icon is not None:
            self.setWindowIcon(QtGui.QIcon(icon))

        self.treeview = self._get_tree_view()
        self.verticalLayout.addWidget(self.treeview)

        self.buttonBox = QtGui.QDialogButtonBox(self)
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel
                                          | QtGui.QDialogButtonBox.Ok)
        self.verticalLayout.addWidget(self.buttonBox)
        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)
Exemple #46
0
 def create_debug_menu(self, menu):
     menu.addAction(Translator.get('DEBUG_WINDOW'), self.show_debug_window)
     for engine in self.manager.get_engines().values():
         action = QtGui.QAction(engine.name, menu)
         action.setMenu(self._create_debug_engine_menu(engine, menu))
         action.setData(engine)
         menu.addAction(action)
Exemple #47
0
 def _init_translator(self):
     locale = Options.force_locale or Options.locale
     Translator(
         self.manager,
         self.get_htmlpage('i18n.js'),
         self.manager.get_config('locale', locale),
     )
    def __init__(self, application, engine, parent=None):
        """
        Constructor
        """
        super(FiltersDialog, self).__init__(parent)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.setWindowTitle(Translator.get("FILTERS_WINDOW_TITLE"))

        self.resize(491, 443)
        self.verticalLayout = QtGui.QVBoxLayout(self)
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)

        self._engine = engine
        self._application = application
        icon = self._application.get_window_icon()
        if icon is not None:
            self.setWindowIcon(QtGui.QIcon(icon))

        self.treeview = self._get_tree_view()
        self.verticalLayout.addWidget(self.treeview)

        self.buttonBox = QtGui.QDialogButtonBox(self)
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel
                                          | QtGui.QDialogButtonBox.Ok)
        self.verticalLayout.addWidget(self.buttonBox)
        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)
Exemple #49
0
    def _export_state(self, state):
        if state is None:
            return None

        result = dict(state=state.pair_state,
                      last_sync_date='',
                      last_sync_direction='upload')

        # Last sync in sec
        current_time = int(time.time())
        date_time = self.get_date_from_sqlite(state.last_sync_date)
        sync_time = self.get_timestamp_from_date(date_time)
        if state.last_local_updated > state.last_remote_updated:
            result['last_sync_direction'] = 'download'
        result['last_sync'] = current_time - sync_time
        if date_time != 0:
            # As date_time is in UTC
            result['last_sync_date'] = Translator.format_datetime(date_time + tzlocal()._dst_offset)

        result["name"] = state.local_name
        if state.local_name is None:
            result["name"] = state.remote_name
        result["remote_name"] = state.remote_name
        result["last_error"] = state.last_error
        result["local_path"] = state.local_path
        result["local_parent_path"] = state.local_parent_path
        result["remote_ref"] = state.remote_ref
        result["folderish"] = state.folderish
        result["last_transfer"] = state.last_transfer
        if result["last_transfer"] is None:
            result["last_transfer"] = result["last_sync_direction"]
        result["id"] = state.id
        return result
Exemple #50
0
 def create_debug_menu(self, menu):
     menu.addAction(Translator.get('DEBUG_WINDOW'), self.show_debug_window)
     for engine in self.manager.get_engines().values():
         action = QtGui.QAction(engine.name, menu)
         action.setMenu(self._create_debug_engine_menu(engine, menu))
         action.setData(engine)
         menu.addAction(action)
    def __init__(self, application, engine, parent=None):
        super(FiltersDialog, self).__init__(parent)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.setWindowTitle(Translator.get('FILTERS_WINDOW_TITLE'))

        self.vertical_layout = QtGui.QVBoxLayout(self)
        self.vertical_layout.setContentsMargins(0, 0, 0, 0)

        self._engine = engine
        self.syncing = self._engine.is_syncing()  # NXDRIVE-959
        self.application = application
        icon = self.application.get_window_icon()
        if icon is not None:
            self.setWindowIcon(QtGui.QIcon(icon))

        self.tree_view = self.get_tree_view()
        self.vertical_layout.addWidget(self.tree_view)

        self.button_box = QtGui.QDialogButtonBox(self)
        self.button_box.setOrientation(QtCore.Qt.Horizontal)
        buttons = QtGui.QDialogButtonBox.Ok
        if not self.syncing:
            buttons |= QtGui.QDialogButtonBox.Cancel
        self.button_box.setStandardButtons(buttons)
        self.vertical_layout.addWidget(self.button_box)
        self.button_box.accepted.connect(self.accept)
        self.button_box.rejected.connect(self.reject)
Exemple #52
0
    def _export_state(self, state):
        if state is None:
            return None

        result = dict(state=state.pair_state,
                      last_sync_date='',
                      last_sync_direction='upload')

        # Last sync in sec
        current_time = int(time.time())
        date_time = self.get_date_from_sqlite(state.last_sync_date)
        sync_time = self.get_timestamp_from_date(date_time)
        if state.last_local_updated > state.last_remote_updated:
            result['last_sync_direction'] = 'download'
        result['last_sync'] = current_time - sync_time
        if date_time != 0:
            # As date_time is in UTC
            result['last_sync_date'] = Translator.format_datetime(
                date_time + tzlocal()._dst_offset)

        result["name"] = state.local_name
        if state.local_name is None:
            result["name"] = state.remote_name
        result["remote_name"] = state.remote_name
        result["last_error"] = state.last_error
        result["local_path"] = state.local_path
        result["local_parent_path"] = state.local_parent_path
        result["remote_ref"] = state.remote_ref
        result["folderish"] = state.folderish
        result["last_transfer"] = state.last_transfer
        if result["last_transfer"] is None:
            result["last_transfer"] = result["last_sync_direction"]
        result["id"] = state.id
        return result
Exemple #53
0
 def __init__(self, application, url, api):
     super(WebAuthenticationDialog, self).__init__(
         application,
         url,
         title=Translator.get("WEB_AUTHENTICATION_WINDOW_TITLE"),
         api=api)
     self.resize(1000, 800)
Exemple #54
0
 def __init__(self, engine_uid, doc_pair):
     values = dict(name=doc_pair.local_name)
     super(ConflictNotification, self).__init__(
         'CONFLICT_FILE',
         title=Translator.get('CONFLICT', values),
         description=Translator.get('CONFLICT_ON_FILE', values),
         engine_uid=engine_uid,
         level=Notification.LEVEL_WARNING,
         flags=(Notification.FLAG_VOLATILE
                | Notification.FLAG_ACTIONABLE
                | Notification.FLAG_BUBBLE
                | Notification.FLAG_PERSISTENT
                | Notification.FLAG_DISCARD_ON_TRIGGER
                | Notification.FLAG_REMOVE_ON_DISCARD),
         action='drive.showConflicts();',
     )
Exemple #55
0
 def _export_state(self, state):
     if state is None:
         return None
     result = super(WebConflictsApi, self)._export_state(state)
     result["last_contributor"] = ""
     user_info = self._engine._dao.get_user_info(state.last_remote_modifier)
     if user_info:
         result["last_contributor"] = ("%s %s" % (user_info.first_name, user_info.last_name)).strip("(").strip(")")
     else:
         log.warn("User name failed to resolve for user_id : %r" % state.last_remote_modifier)
     date_time = self.get_date_from_sqlite(state.last_remote_updated)
     result["last_remote_update"] = "" if date_time == 0 else Translator.format_datetime(date_time)
     date_time = self.get_date_from_sqlite(state.last_local_updated)
     result["last_local_update"] = "" if date_time == 0 else Translator.format_datetime(date_time)
     result["remote_can_update"] = state.remote_can_update
     return result
Exemple #56
0
    def __init__(self, application, engine, parent=None):
        super(FiltersDialog, self).__init__(parent)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.setWindowTitle(Translator.get('FILTERS_WINDOW_TITLE'))

        self.vertical_layout = QtGui.QVBoxLayout(self)
        self.vertical_layout.setContentsMargins(0, 0, 0, 0)

        self._engine = engine
        self.syncing = self._engine.is_syncing()  # NXDRIVE-959
        self.application = application
        icon = self.application.get_window_icon()
        if icon is not None:
            self.setWindowIcon(QtGui.QIcon(icon))

        self.tree_view = self.get_tree_view()
        self.vertical_layout.addWidget(self.tree_view)

        self.button_box = QtGui.QDialogButtonBox(self)
        self.button_box.setOrientation(QtCore.Qt.Horizontal)
        buttons = QtGui.QDialogButtonBox.Ok
        if not self.syncing:
            buttons |= QtGui.QDialogButtonBox.Cancel
        self.button_box.setStandardButtons(buttons)
        self.vertical_layout.addWidget(self.button_box)
        self.button_box.accepted.connect(self.accept)
        self.button_box.rejected.connect(self.reject)
Exemple #57
0
    def __init__(self, application, section, api=None):
        self._section = section
        if not api:
            api = WebSettingsApi(application)

        super(WebSettingsDialog, self).__init__(
            application, 'settings.html', api=api,
            title=Translator.get('SETTINGS_WINDOW_TITLE'))
Exemple #58
0
 def __init__(self, engine_uid):
     # show_settings('Accounts_' + engine.uid)
     super(InvalidCredentialNotification, self).__init__("INVALID_CREDENTIALS",
         title=Translator.get("INVALID_CREDENTIALS"),
         description="",
         engine_uid=engine_uid, level=Notification.LEVEL_ERROR,
         flags=Notification.FLAG_UNIQUE|Notification.FLAG_VOLATILE|Notification.FLAG_BUBBLE|Notification.FLAG_ACTIONABLE|Notification.FLAG_SYSTRAY,
         action="drive.showSettings('Accounts_" + engine_uid + "');")
 def testToken(self):
     options = dict()
     options["token_1"] = "First Token"
     options["token_2"] = "Another One"
     Translator(MockManager(), self.getFolder('i18n.js'))
     '''
     "TOKEN_NORMAL": "Language {{ token_1 }}",
     "TOKEN_DOUBLE": "{{ token_1 }} Language {{ token_2 }}",
     "TOKEN_UNKNOWN": "{{ token_unknown }} TOKEN",
     "TOKEN_WITH_NO_SPACE": "{{token_1}} TOKEN",
     "TOKEN_REPEAT": "{{token_1}} TOKEN {{ token_1 }}"
     '''
     self.assertEqual("Language First Token", Translator.get("TOKEN_NORMAL", options))
     self.assertEqual("First Token Language Another One", Translator.get("TOKEN_DOUBLE", options))
     self.assertEqual(" TOKEN", Translator.get("TOKEN_UNKNOWN", options))
     self.assertEqual("First Token TOKEN", Translator.get("TOKEN_WITH_NO_SPACE", options))
     self.assertEqual("First Token TOKEN First Token", Translator.get("TOKEN_REPEAT", options))
 def bind_server(self, local_folder, url, username, password, name, check_fs=True, token=None):
     try:
         # Allow to override for other exception handling
         log.debug("URL: '%s'", url)
         return self._bind_server(local_folder, url, username, password, name, check_fs=check_fs, token=token)
     except RootAlreadyBindWithDifferentAccount as e:
         # Ask for the user
         values = dict()
         values["username"] = e.get_username()
         values["url"] = e.get_url()
         msgbox = QtGui.QMessageBox(QtGui.QMessageBox.Question, self._manager.get_appname(),
                                    Translator.get("ROOT_USED_WITH_OTHER_BINDING", values),
                                    QtGui.QMessageBox.NoButton, self._dialog)
         msgbox.addButton(Translator.get("ROOT_USED_CONTINUE"), QtGui.QMessageBox.AcceptRole)
         cancel = msgbox.addButton(Translator.get("ROOT_USED_CANCEL"), QtGui.QMessageBox.RejectRole)
         msgbox.exec_()
         if (msgbox.clickedButton() == cancel):
             return "FOLDER_USED"
         return self.bind_server(local_folder, url, username, password, name, check_fs=False, token=token)
     except NotFound:
         return "FOLDER_DOES_NOT_EXISTS"
     except AddonNotInstalled:
         return "ADDON_NOT_INSTALLED"
     except InvalidDriveException:
         return "INVALID_PARTITION"
     except Unauthorized:
         return "UNAUTHORIZED"
     except FolderAlreadyUsed:
         return "FOLDER_USED"
     except urllib2.HTTPError as e:
         if (isinstance(url, QtCore.QString)):
             url = str(url)
         if e.code == 404 and not url.endswith("nuxeo/"):
             if not url.endswith("/"):
                 url += "/"
             return self.bind_server(local_folder, url + "nuxeo/", username, password, name, check_fs, token)
         return "CONNECTION_ERROR"
     except urllib2.URLError as e:
         if e.errno == 61:
             return "CONNECTION_REFUSED"
         return "CONNECTION_ERROR"
     except Exception as e:
         log.exception(e)
         # Map error here
         return "CONNECTION_UNKNOWN"