Skip to content

Commit

Permalink
new version 1.1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
prrvchr committed Nov 11, 2024
1 parent be2b415 commit ad0a9e3
Show file tree
Hide file tree
Showing 43 changed files with 944 additions and 966 deletions.
1 change: 1 addition & 0 deletions source/dDriveOOo/Options.xcs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
</group>
</templates>
<component>
<prop oor:name="ResetSync" oor:type="xs:boolean" />
<prop oor:name="SupportShare" oor:type="xs:boolean" />
<prop oor:name="SharedDocuments" oor:type="xs:boolean" />
<prop oor:name="SharedFolderName" oor:type="xs:string" oor:localized="true"/>
Expand Down
5 changes: 4 additions & 1 deletion source/dDriveOOo/Options.xcu
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:oor="http://openoffice.org/2001/registry"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<prop oor:name="ResetSync">
<value>false</value>
</prop>
<prop oor:name="SupportShare">
<value>false</value>
</prop>
Expand All @@ -40,7 +43,7 @@
<value xml:lang="fr">Documents partagés</value>
</prop>
<prop oor:name="ReplicateTimeout">
<value>600</value>
<value>60</value>
</prop>
<prop oor:name="SynchronizePolicy">
<value>CLIENT_IS_MASTER</value>
Expand Down
16 changes: 9 additions & 7 deletions source/dDriveOOo/dialogs/OptionsDialog_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,22 @@ OptionsDialog.CommandButton1.HelpText=
OptionsDialog.CommandButton1.Label=View DataBase
OptionsDialog.Label2.HelpText=
OptionsDialog.Label2.Label=Replication:
OptionsDialog.OptionButton1.HelpText=
OptionsDialog.OptionButton1.HelpText=Replication of your Dropbox files then your local files
OptionsDialog.OptionButton1.Label=Remote then local
OptionsDialog.OptionButton2.HelpText=
OptionsDialog.OptionButton2.HelpText=Replication of your local files then your Dropbox files
OptionsDialog.OptionButton2.Label=Local then remote
OptionsDialog.OptionButton3.HelpText=
OptionsDialog.OptionButton3.HelpText=Replication is suspended
OptionsDialog.OptionButton3.Label=None
OptionsDialog.CheckBox1.HelpText=Reset sync for all users on next replication
OptionsDialog.CheckBox1.Label=Reset
OptionsDialog.Label3.HelpText=
OptionsDialog.Label3.Label=Interval (minutes):
OptionsDialog.NumericField1.HelpText=Replication interval in minutes
OptionsDialog.Label4.HelpText=
OptionsDialog.Label4.Label=Transfer:
OptionsDialog.OptionButton4.HelpText=
OptionsDialog.OptionButton4.HelpText=Download options
OptionsDialog.OptionButton4.Label=Download
OptionsDialog.OptionButton5.HelpText=
OptionsDialog.OptionButton5.HelpText=Upload options
OptionsDialog.OptionButton5.Label=Upload
OptionsDialog.Label5.HelpText=
OptionsDialog.Label5.Label=Chunk:
Expand All @@ -43,8 +45,8 @@ OptionsDialog.Label7.HelpText=
OptionsDialog.Label7.Label=Retry:
OptionsDialog.NumericField6.HelpText=Number of download retry in case of failure
OptionsDialog.NumericField7.HelpText=Number of upload retry in case of failure
OptionsDialog.CheckBox1.HelpText=
OptionsDialog.CheckBox1.Label=Handle shared drives in folder:
OptionsDialog.CheckBox2.HelpText=
OptionsDialog.CheckBox2.Label=Handle shared drives in folder:
OptionsDialog.TextField1.HelpText=
OptionsDialog.TextField1.Text=
OptionsDialog.Label8.HelpText=
Expand Down
16 changes: 9 additions & 7 deletions source/dDriveOOo/dialogs/OptionsDialog_fr_FR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,22 @@ OptionsDialog.CommandButton1.HelpText=
OptionsDialog.CommandButton1.Label=Voir la base de données
OptionsDialog.Label2.HelpText=
OptionsDialog.Label2.Label=Réplication:
OptionsDialog.OptionButton1.HelpText=
OptionsDialog.OptionButton1.HelpText=Réplication de vos fichiers Dropbox puis de vos fichiers locaux
OptionsDialog.OptionButton1.Label=Distant puis local
OptionsDialog.OptionButton2.HelpText=
OptionsDialog.OptionButton2.HelpText=Réplication de vos fichiers locaux puis de vos fichiers Dropbox
OptionsDialog.OptionButton2.Label=Local puis distant
OptionsDialog.OptionButton3.HelpText=
OptionsDialog.OptionButton3.HelpText=La réplication est suspendue
OptionsDialog.OptionButton3.Label=Sans
OptionsDialog.CheckBox1.HelpText=Réinitialiser la synchronisation pour tous les utilisateurs lors de la prochaine réplication
OptionsDialog.CheckBox1.Label=Réinitialiser
OptionsDialog.Label3.HelpText=
OptionsDialog.Label3.Label=Intervalle (minutes):
OptionsDialog.NumericField1.HelpText=Intervalle de réplication en minutes
OptionsDialog.Label4.HelpText=
OptionsDialog.Label4.Label=Transfert:
OptionsDialog.OptionButton4.HelpText=
OptionsDialog.OptionButton4.HelpText=Options du téléchargement
OptionsDialog.OptionButton4.Label=Téléchargement
OptionsDialog.OptionButton5.HelpText=
OptionsDialog.OptionButton5.HelpText=Options de la mise à jour
OptionsDialog.OptionButton5.Label=Mise à jour
OptionsDialog.Label5.HelpText=
OptionsDialog.Label5.Label=Tampon:
Expand All @@ -43,8 +45,8 @@ OptionsDialog.Label7.HelpText=
OptionsDialog.Label7.Label=Essai:
OptionsDialog.NumericField6.HelpText=Nombre de tentatives de téléchargement en cas d'échec
OptionsDialog.NumericField7.HelpText=Nombre de tentatives de mise à jour en cas d'échec
OptionsDialog.CheckBox1.HelpText=
OptionsDialog.CheckBox1.Label=Gérer les lecteurs partagés dans le dossier:
OptionsDialog.CheckBox2.HelpText=
OptionsDialog.CheckBox2.Label=Gérer les lecteurs partagés dans le dossier:
OptionsDialog.TextField1.HelpText=
OptionsDialog.TextField1.Text=
OptionsDialog.Label8.HelpText=
Expand Down
1 change: 1 addition & 0 deletions source/dDriveOOo/service/pythonpath/ddrive/listener.py
163 changes: 87 additions & 76 deletions source/dDriveOOo/service/pythonpath/ddrive/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import uno
import unohelper

from com.sun.star.logging.LogLevel import INFO

from com.sun.star.ucb import IllegalIdentifierException

from com.sun.star.rest.ParameterType import JSON
Expand Down Expand Up @@ -64,92 +66,43 @@
class Provider(ProviderBase):

@property
def Name(self):
return g_provider
def BaseUrl(self):
return g_url
@property
def Host(self):
return g_host
@property
def BaseUrl(self):
return g_url
def Name(self):
return g_provider
@property
def UploadUrl(self):
return g_upload

# Must be implemented method
def getDocumentLocation(self, user, item):
# XXX: Nothing to do here
return item

def getFirstPullRoots(self, user):
return (user.RootId, )

def initUser(self, database, user, token):
# FIXME: Some APIs like Dropbox allow to have the token during the firstPull
#token = self.getUserToken(user)
if database.updateToken(user.Id, token):
user.setToken(token)

def getUser(self, source, request, name):
user = self._getUser(source, request, name)
root = self._getRoot(user[-1])
return user, root

def initSharedDocuments(self, user, datetime):
pass

def parseUserToken(self, response):
token = None
events = ijson.sendable_list()
parser = ijson.parse_coro(events)
iterator = response.iterContent(g_chunk, False)
while iterator.hasMoreElements():
parser.send(iterator.nextElement().value)
for prefix, event, value in events:
if (prefix, event) == ('cursor', 'string'):
token = value
del events[:]
parser.close()
return token

def getDocumentLocation(self, content):
# FIXME: This method being also called by the replicator,
# FIXME: we must provide a dictionary
return content.MetaData

def _getUser(self, source, request, name):
parameter = self.getRequestParameter(request, 'getUser')
response = request.execute(parameter)
if not response.Ok:
msg = self._logger.resolveString(403, name)
raise IllegalIdentifierException(msg, source)
return self._parseUser(response)

def _getRoot(self, rootid):
timestamp = currentUnoDateTime()
return rootid, timestamp, timestamp

def _parseUser(self, response):
userid = name = displayname = rootid = None
events = ijson.sendable_list()
parser = ijson.parse_coro(events)
iterator = response.iterContent(g_chunk, False)
while iterator.hasMoreElements():
parser.send(iterator.nextElement().value)
for prefix, event, value in events:
if (prefix, event) == ('account_id', 'string'):
userid = value
elif (prefix, event) == ('email', 'string'):
name = value
elif (prefix, event) == ('name.display_name', 'string'):
displayname = value
elif (prefix, event) == ('root_info.root_namespace_id', 'string'):
rootid = value
del events[:]
parser.close()
response.close()
return userid, name, displayname, rootid
def mergeNewFolder(self, user, oldid, response):
newid = None
items = self._parseNewFolder(response)
if all(items):
newid = user.DataBase.updateNewItemId(user.Id, oldid, *items)
return newid

def parseRootFolder(self, parameter, content):
def parseFolder(self, parameter, content):
return self.parseItems(content.User.Request, parameter, content.User.RootId)

def parseItems(self, request, parameter, rootid):
addchild = rename = True
addchild = canrename = True
trashed = readonly = versionable = False
link = ''
while parameter.hasNextPage():
Expand Down Expand Up @@ -193,7 +146,20 @@ def parseItems(self, request, parameter, rootid):
parents = (rootid, )
elif (prefix, event) == ('entries.item', 'end_map'):
if itemid and name:
yield itemid, name, created, modified, mimetype, size, link, trashed, addchild, rename, readonly, versionable, parents, path
yield {'Id': itemid,
'Name': name,
'DateCreated': created,
'DateModified': modified,
'MediaType': mimetype,
'Size': size,
'Link': link,
'Trashed': trashed,
'CanAddChild': addchild,
'CanRename': canrename,
'IsReadOnly': readonly,
'IsVersionable': versionable,
'Parents': parents,
'Path': path}
del events[:]
parser.close()
response.close()
Expand All @@ -203,20 +169,41 @@ def parseUploadLocation(self, response):
response.close()
return location

def updateItemId(self, database, oldid, response):
def parseUserToken(self, response):
token = None
events = ijson.sendable_list()
parser = ijson.parse_coro(events)
iterator = response.iterContent(g_chunk, False)
while iterator.hasMoreElements():
parser.send(iterator.nextElement().value)
for prefix, event, value in events:
if (prefix, event) == ('cursor', 'string'):
token = value
del events[:]
parser.close()
return token

def updateItemId(self, user, oldid, response):
newid = response.getJson().getString('id')
response.close()
if newid and oldid != newid:
database.updateItemId(newid, oldid)
user.DataBase.updateItemId(user.Id, newid, oldid)
self.updateNewItemId(oldid, newid)
return newid

def mergeNewFolder(self, user, oldid, response):
newid = None
items = self._parseNewFolder(response)
if all(items):
newid = user.DataBase.updateNewItemId(user.Id, oldid, *items)
return newid
# Private method
def _getRoot(self, rootid):
timestamp = currentUnoDateTime()
return rootid, timestamp, timestamp

def _getUser(self, source, request, name):
parameter = self.getRequestParameter(request, 'getUser')
response = request.execute(parameter)
if not response.Ok:
msg = self._logger.resolveString(561, parameter.Name, response.StatusCode, response.Text)
self._logger.logp(INFO, 'Provider', '_getUser()', msg)
raise IllegalIdentifierException(msg, source)
return self._parseUser(response)

def _parseNewFolder(self, response):
newid = created = modified = None
Expand All @@ -235,10 +222,33 @@ def _parseNewFolder(self, response):
response.close()
return newid, created, modified

def _parseUser(self, response):
userid = name = displayname = rootid = None
events = ijson.sendable_list()
parser = ijson.parse_coro(events)
iterator = response.iterContent(g_chunk, False)
while iterator.hasMoreElements():
parser.send(iterator.nextElement().value)
for prefix, event, value in events:
if (prefix, event) == ('account_id', 'string'):
userid = value
elif (prefix, event) == ('email', 'string'):
name = value
elif (prefix, event) == ('name.display_name', 'string'):
displayname = value
elif (prefix, event) == ('root_info.root_namespace_id', 'string'):
rootid = value
del events[:]
parser.close()
response.close()
return userid, name, displayname, rootid

# Requests get Parameter method
def getRequestParameter(self, request, method, data=None):
parameter = request.getRequestParameter(method)
parameter.Url = self.BaseUrl
parameter.NextUrl = self.BaseUrl

if method == 'getUser':
parameter.Method = 'POST'
parameter.Url += '/users/get_current_account'
Expand Down Expand Up @@ -278,7 +288,7 @@ def getRequestParameter(self, request, method, data=None):
parameter.setJson('include_deleted', False)
parameter.setJson('limit', g_pages)

elif method == 'getDocumentContent':
elif method == 'downloadFile':
parameter.Method = 'POST'
parameter.Url = self.UploadUrl + '/files/download'
parameter.setHeader('Dropbox-API-Arg', '{"path": "%s"}' % data.get('Id'))
Expand Down Expand Up @@ -339,3 +349,4 @@ def getRequestParameter(self, request, method, data=None):
parameter.setHeader('Content-Type', 'application/octet-stream')

return parameter

4 changes: 2 additions & 2 deletions uno/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = https://github.com/prrvchr/uno.git
branch = main
commit = c52477bd0abfa9de802a5c38224da5ffcce970cb
parent = 5fa0f39ca151caa992f0c31e023f76429e3b1ef4
commit = bfdcca9ee0af76b278e40197ea51eca293e1e945
parent = 9be194281820577cbe042fc6edb0cb3d88d430fe
method = merge
cmdver = 0.4.3
Loading

0 comments on commit ad0a9e3

Please sign in to comment.