diff --git a/uno/.gitrepo b/uno/.gitrepo index 8af5a1c2..effa2387 100644 --- a/uno/.gitrepo +++ b/uno/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/prrvchr/uno.git branch = main - commit = 56abef3ff7d3ad9474d6b48cffb1019d0409fdbe - parent = 91bc3a620686cbf08f9b250eb30cb02572d8aa5c + commit = bbac33543c7f087ec486064776f93df42fd0ba37 + parent = 8286f03f7f68732bcd9d140a5cd4261bc6524559 method = merge cmdver = 0.4.3 diff --git a/uno/lib/uno/card/card/book.py b/uno/lib/uno/card/card/book.py index cf07a8cf..f62b2fd3 100644 --- a/uno/lib/uno/card/card/book.py +++ b/uno/lib/uno/card/card/book.py @@ -34,7 +34,7 @@ import traceback -class Books(unohelper.Base): +class Books(object): def __init__(self, ctx, metadata, new): self._ctx = ctx print("Books.__init__() 1") @@ -63,7 +63,7 @@ def _getBooks(self, metadata, new): return books -class Book(unohelper.Base): +class Book(object): def __init__(self, ctx, new, **kwargs): self._ctx = ctx self._new = new diff --git a/uno/lib/uno/card/card/database.py b/uno/lib/uno/card/card/database.py index 13054a3b..443a2ec5 100644 --- a/uno/lib/uno/card/card/database.py +++ b/uno/lib/uno/card/card/database.py @@ -86,7 +86,7 @@ import traceback -class DataBase(unohelper.Base): +class DataBase(object): def __init__(self, ctx, url, user='', pwd=''): self._ctx = ctx self._statement = None diff --git a/uno/lib/uno/card/card/provider.py b/uno/lib/uno/card/card/provider.py index 302579de..66e3c33a 100644 --- a/uno/lib/uno/card/card/provider.py +++ b/uno/lib/uno/card/card/provider.py @@ -32,12 +32,14 @@ from .book import Book +from ..cardtool import getSqlException + from ..dbtool import getDateTimeFromString import traceback -class Provider(unohelper.Base): +class Provider(object): @property def DateTimeFormat(self): @@ -53,10 +55,10 @@ def parseDateTime(self, timestamp): def insertUser(self, database, request, scheme, server, name, pwd): raise NotImplementedError - def initAddressbooks(self, database, user): + def initAddressbooks(self, source, database, user): raise NotImplementedError - def initUserBooks(self, database, user, books): + def initUserBooks(self, source, database, user, books): count = 0 modified = False for uri, name, tag, token in books: @@ -78,9 +80,8 @@ def initUserBooks(self, database, user, books): count += 1 print("Provider.initUserBooks() 4") if not count: - #TODO: Raise SqlException with correct message! - print("Provider.initUserBooks() 1 %s" % (books, )) - #raise getSqlException(self._ctx, self, 1004, 1108, 'initUserBooks', '%s has no support of CardDAV!' % user.Server) + cls, mtd = 'Provider', 'initUserBooks()' + raise getSqlException(self._ctx, source, 1006, 1109, cls, mtd, user.Name, user.Server) if modified and self.supportAddressBook(): database.initAddressbooks(user) diff --git a/uno/lib/uno/card/card/user.py b/uno/lib/uno/card/card/user.py index a817b418..a4eadb34 100644 --- a/uno/lib/uno/card/card/user.py +++ b/uno/lib/uno/card/card/user.py @@ -49,8 +49,8 @@ import traceback -class User(unohelper.Base): - def __init__(self, ctx, database, provider, scheme, server, name, pwd=''): +class User(object): + def __init__(self, ctx, source, database, provider, scheme, server, name, pwd=''): self._ctx = ctx self._password = pwd self._sessions = [] @@ -60,14 +60,15 @@ def __init__(self, ctx, database, provider, scheme, server, name, pwd=''): if not new: request = getRequest(ctx, server, name) if request is None: - raise getSqlException(ctx, self, 1002, 1105, cls, mtd, name) + raise getSqlException(ctx, source, 1002, 1105, cls, mtd, name) else: if self._isOffLine(server): - raise getSqlException(ctx, self, 1004, 1108, cls, mtd, name) + raise getSqlException(ctx, source, 1004, 1108, cls, mtd, name) request = getRequest(ctx, server, name) if request is None: - raise getSqlException(ctx, self, 1002, 1105, cls, mtd, name) - self._metadata, books = self._getUserData(cls, mtd, database, provider, request, scheme, server, name, pwd) + raise getSqlException(ctx, source, 1002, 1105, cls, mtd, name) + self._metadata, books = self._getUserData(ctx, source, cls, mtd, database, + provider, request, scheme, server, name, pwd) database.createUser(self.getSchema(), self.Id, name, '') self.Request = request self._books = Books(ctx, books, new) @@ -134,10 +135,10 @@ def unquoteUrl(self, url): def getBooks(self): return self._books.getBooks() - def _getUserData(self, cls, mtd, database, provider, request, scheme, server, name, pwd): + def _getUserData(self, ctx, source, cls, mtd, database, provider, request, scheme, server, name, pwd): data = provider.insertUser(database, request, scheme, server, name, pwd) if data is None: - raise getSqlException(self._ctx, self, 1006, 1107, cls, mtd, name) + raise getSqlException(ctx, source, 1006, 1107, cls, mtd, name) return data def _isOffLine(self, server): diff --git a/uno/lib/uno/card/datasource.py b/uno/lib/uno/card/datasource.py index c26778a3..3bbb65ea 100644 --- a/uno/lib/uno/card/datasource.py +++ b/uno/lib/uno/card/datasource.py @@ -39,12 +39,14 @@ from .listener import EventListener from .listener import TerminateListener +from .cardtool import getSqlException + from .unotool import getDesktop import traceback -class DataSource(unohelper.Base): +class DataSource(object): def __init__(self, ctx, database): self._ctx = ctx self._maps = {} @@ -72,18 +74,22 @@ def closeConnection(self, connection): print("DataSource.closeConnection() 2") # Procedures called by Driver - def getConnection(self, scheme, server, account, password): + def getConnection(self, source, scheme, server, account, password): uri = self._provider.getUserUri(server, account) if uri in self._maps: name = self._maps.get(uri) user = self._users.get(name) + if not user.Request.isAuthorized(): + cls, mtd = 'DataSource', 'getConnection()' + raise getSqlException(self._ctx, source, 1002, 1105, cls, mtd, name) else: - user = User(self._ctx, self._database, self._provider, scheme, server, account, password) + user = User(self._ctx, source, self._database, + self._provider, scheme, server, account, password) name = user.getName() self._users[name] = user self._maps[uri] = name if user.isOnLine(): - self._provider.initAddressbooks(self._database, user) + self._provider.initAddressbooks(source, self._database, user) connection = self._database.getConnection(name, user.getPassword()) user.addSession(self._database.getSessionId(connection)) # User and/or AddressBooks has been initialized and the connection to the database is done... diff --git a/uno/lib/uno/card/replicator.py b/uno/lib/uno/card/replicator.py index 690fa1ca..3c1dba51 100644 --- a/uno/lib/uno/card/replicator.py +++ b/uno/lib/uno/card/replicator.py @@ -51,6 +51,7 @@ def __init__(self, ctx, database, provider, users): self._ctx = ctx self._database = database self._provider = provider + self._config = getConfiguration(ctx, g_identifier, False) self._users = users self._started = Event() self._paused = Event() @@ -80,13 +81,8 @@ def start(self): def _canceled(self): return False - def _canceled1(self): - return self._disposed.is_set() or not self._started.is_set() - def _getReplicateTimeout(self): - configuration = getConfiguration(self._ctx, g_identifier, False) - timeout = configuration.getByName('ReplicateTimeout') - return timeout + return self._config.getByName('ReplicateTimeout') def _replicate(self): print("replicator.run()1") diff --git a/uno/lib/uno/card/resource/Driver_en_US.properties b/uno/lib/uno/card/resource/Driver_en_US.properties index e5ac91cf..6c38df59 100644 --- a/uno/lib/uno/card/resource/Driver_en_US.properties +++ b/uno/lib/uno/card/resource/Driver_en_US.properties @@ -34,7 +34,8 @@ 1104=You must provide a valid Google account! 1105=The user: %s has abandoned the OAuth2 authorization wizard, the driver cannot continue without this authorization!!! -1106=Can't insert User: %s in DataBase +1106=Can't insert user: %s in DataBase 1107=User: %s does not exist at this Provider -1108=Can't retrieve User: %s from provider: network is OffLine!!! +1108=Can't retrieve user: %s from provider: network is OffLine!!! +1109=Can't retrieve AddressBook for user: %s, the server: % don't support AddressBook!!! diff --git a/uno/lib/uno/card/resource/Driver_fr_FR.properties b/uno/lib/uno/card/resource/Driver_fr_FR.properties index 4128e3f1..ba0193ed 100644 --- a/uno/lib/uno/card/resource/Driver_fr_FR.properties +++ b/uno/lib/uno/card/resource/Driver_fr_FR.properties @@ -37,4 +37,5 @@ 1106=Impossible d'inserer l'utilisateur: %s dans la base de donn\u00e9es 1107=L'utilisateur: %s est inconnu chez ce fournisseur 1108=Impossible de retrouver l'utilisateur: %s chez le fournisseur: le r\u00e9seau est hors ligne!!! +1109=Impossible de r\u00e9cup\u00e9rer le carnet d'adresses pour l'utilisateur: %s, le serveur: % ne prend pas en charge les carnets d'adresses!!! diff --git a/uno/lib/uno/oauth2/configuration.py b/uno/lib/uno/oauth2/configuration.py index 518ee9a1..deefe9d2 100644 --- a/uno/lib/uno/oauth2/configuration.py +++ b/uno/lib/uno/oauth2/configuration.py @@ -31,7 +31,7 @@ g_extension = 'OAuth2OOo' g_identifier = 'io.github.prrvchr.%s' % g_extension g_service = '%s.OAuth2Service' % g_identifier -g_version = '1.2.1' +g_version = '1.2.2' g_oauth2 = g_service diff --git a/uno/lib/uno/ucb/database.py b/uno/lib/uno/ucb/database.py index a88bac64..b576c5e9 100644 --- a/uno/lib/uno/ucb/database.py +++ b/uno/lib/uno/ucb/database.py @@ -243,6 +243,11 @@ def getItem(self, user, itemid, rewrite=True): item = getDataFromResult(result) result.close() select.close() + if item.get('IsFolder'): + infos = user.getCreatableContentsInfo(item.get('CanAddChild')) + else: + infos = () + item['CreatableContentsInfo'] = infos return item def getChildren(self, username, itemid, properties, mode, scheme): diff --git a/uno/lib/uno/ucb/dbqueries.py b/uno/lib/uno/ucb/dbqueries.py index e6d0e4e2..5ca107ee 100644 --- a/uno/lib/uno/ucb/dbqueries.py +++ b/uno/lib/uno/ucb/dbqueries.py @@ -394,9 +394,11 @@ def getSqlQuery(ctx, name, format=None): SELECT I."ItemId" AS "Id", '' AS "Path", '' AS "ParentId", I."ItemId" AS "ObjectId", I."Title", I."Title" AS "TitleOnServer", I."DateCreated", I."DateModified", - I2."ContentType", I."MediaType", I."Size", I."Link", I."Trashed", TRUE AS "IsRoot", - I2."IsFolder", I2."IsLink", I2."IsDocument", C."CanAddChild", C."CanRename", - C."IsReadOnly", C."IsVersionable", I."ConnectionMode", '' AS "CasePreservingURL" + I2."ContentType", I."MediaType", I."Size", I."Link", I."Trashed", + TRUE AS "IsRoot", I2."IsFolder", I2."IsLink", I2."IsDocument", C."CanAddChild", + C."CanRename", C."IsReadOnly", C."IsVersionable", I."ConnectionMode", + '' AS "CasePreservingURL", FALSE AS "IsHidden", FALSE AS "IsVolume", FALSE AS "IsRemote", + FALSE AS "IsRemoveable", FALSE AS "IsFloppy", FALSE AS "IsCompactDisc" FROM "Users" AS U INNER JOIN "Items" AS I ON U."RootId"=I."ItemId" INNER JOIN "Item" AS I2 ON I."ItemId"=I2."ItemId" @@ -420,8 +422,10 @@ def getSqlQuery(ctx, name, format=None): "GetTitle"(I."Title",T."Title",SWAP) AS "Title", I."Title" AS "TitleOnServer", I."DateCreated", I."DateModified", I2."ContentType", I."MediaType", I."Size", I."Link", I."Trashed", - FALSE AS "IsRoot", I2."IsFolder", I2."IsLink", I2."IsDocument", C."CanAddChild", C."CanRename", - C."IsReadOnly", C."IsVersionable", I."ConnectionMode", '' AS "CasePreservingURL" + FALSE AS "IsRoot", I2."IsFolder", I2."IsLink", I2."IsDocument", C."CanAddChild", + C."CanRename", C."IsReadOnly", C."IsVersionable", I."ConnectionMode", + '' AS "CasePreservingURL", FALSE AS "IsHidden", FALSE AS "IsVolume", FALSE AS "IsRemote", + FALSE AS "IsRemoveable", FALSE AS "IsFloppy", FALSE AS "IsCompactDisc" FROM "Items" AS I INNER JOIN "Item" AS I2 ON I."ItemId"=I2."ItemId" INNER JOIN "Capabilities" AS C ON I."ItemId"=C."ItemId" diff --git a/uno/lib/uno/ucb/ucp/content.py b/uno/lib/uno/ucb/ucp/content.py index f2b1d89a..c193cf88 100644 --- a/uno/lib/uno/ucb/ucp/content.py +++ b/uno/lib/uno/ucb/ucp/content.py @@ -201,7 +201,7 @@ def removePropertiesChangeListener(self, names, listener): # XContentCreator def queryCreatableContentsInfo(self): - return self._user.getCreatableContentsInfo(self.CanAddChild) + return self.MetaData.get('CreatableContentsInfo') def createNewContent(self, info): path = self._user.getContentPath(self.Path, self.Title, self.IsRoot) return self._user.createNewContent(self.Id, self.Link, path, self._authority, info.Type) diff --git a/uno/lib/uno/ucb/ucp/user.py b/uno/lib/uno/ucb/ucp/user.py index eee6adb1..e0dcf8f6 100644 --- a/uno/lib/uno/ucb/ucp/user.py +++ b/uno/lib/uno/ucb/ucp/user.py @@ -269,6 +269,7 @@ def _getNewContent(self, parentid, link, path, contentype): data['Trashed'] = False data['IsRoot'] = False data['IsFolder'] = isfolder + data['IsLink'] = False data['IsDocument'] = isdocument data['CanAddChild'] = isfolder data['CanRename'] = True @@ -276,6 +277,14 @@ def _getNewContent(self, parentid, link, path, contentype): data['IsVersionable'] = isdocument data['ConnectionMode'] = True data['BaseURI'] = path + data['CasePreservingURL'] = '' + data['IsHidden'] = False + data['IsVolume'] = False + data['IsRemote'] = False + data['IsRemoveable'] = False + data['IsFloppy'] = False + data['IsCompactDisc'] = False + data['CreatableContentsInfo'] = self.getCreatableContentsInfo(isfolder) return data def _getNewIdentifier(self):