Branch 'kolab/integration/4.13.0' - pimcommon/acl
Sandro Knauß
knauss at kolabsys.com
Mon Oct 6 13:28:37 CEST 2014
pimcommon/acl/imapaclattribute.cpp | 47 ++++++++++++++++++++++++++++---------
pimcommon/acl/imapaclattribute.h | 15 +++++++----
2 files changed, 45 insertions(+), 17 deletions(-)
New commits:
commit f516270a7cf9f63ec22c94c38d6a959bd77e2aa9
Author: Sandro Knauà <knauss at kolabsys.com>
Date: Mon Oct 6 13:25:18 2014 +0200
Support myrights
copied from kdepim-runtime/resources/shared/imapaclattribute
(we should move this to kdepimlibs because kdepim-runtime and kdepim
needs the same file)
KOLAB: 3542
diff --git a/pimcommon/acl/imapaclattribute.cpp b/pimcommon/acl/imapaclattribute.cpp
index 41a9ba4..bf4a7fb 100644
--- a/pimcommon/acl/imapaclattribute.cpp
+++ b/pimcommon/acl/imapaclattribute.cpp
@@ -49,6 +49,16 @@ QMap<QByteArray, KIMAP::Acl::Rights> ImapAclAttribute::oldRights() const
return mOldRights;
}
+void ImapAclAttribute::setMyRights(KIMAP::Acl::Rights rights)
+{
+ mMyRights = rights;
+}
+
+KIMAP::Acl::Rights ImapAclAttribute::myRights() const
+{
+ return mMyRights;
+}
+
QByteArray ImapAclAttribute::type() const
{
return "imapacl";
@@ -56,7 +66,9 @@ QByteArray ImapAclAttribute::type() const
Akonadi::Attribute *ImapAclAttribute::clone() const
{
- return new ImapAclAttribute( mRights, mOldRights );
+ ImapAclAttribute *attr = new ImapAclAttribute( mRights, mOldRights );
+ attr->setMyRights( mMyRights );
+ return attr;
}
QByteArray ImapAclAttribute::serialized() const
@@ -64,7 +76,7 @@ QByteArray ImapAclAttribute::serialized() const
QByteArray result = "";
bool added = false;
- foreach ( const QByteArray &id, mRights.keys() ) { //krazy:exclude=foreach
+ foreach ( const QByteArray &id, mRights.keys() ) {
result += id;
result += ' ';
result += KIMAP::Acl::rightsToString( mRights[id] );
@@ -79,7 +91,7 @@ QByteArray ImapAclAttribute::serialized() const
result += " %% ";
added = false;
- foreach ( const QByteArray &id, mOldRights.keys() ) { //krazy:exclude=foreach
+ foreach ( const QByteArray &id, mOldRights.keys() ) {
result += id;
result += ' ';
result += KIMAP::Acl::rightsToString( mOldRights[id] );
@@ -91,6 +103,9 @@ QByteArray ImapAclAttribute::serialized() const
result.chop( 3 );
}
+ result+= " %% ";
+ result+= KIMAP::Acl::rightsToString( mMyRights );
+
return result;
}
@@ -116,13 +131,23 @@ void ImapAclAttribute::deserialize( const QByteArray &data )
{
mRights.clear();
mOldRights.clear();
- const int pos = data.indexOf( " %% " );
- if ( pos == -1 ) {
- return;
+ mMyRights = KIMAP::Acl::None;
+
+ QList<QByteArray> parts;
+ int lastPos = 0;
+ int pos;
+ while ((pos = data.indexOf( " %% ", lastPos )) != -1) {
+ parts << data.mid(lastPos, pos-lastPos);
+ lastPos = pos + 4;
}
+ parts << data.mid(lastPos);
- const QByteArray leftPart = data.left( pos );
- const QByteArray rightPart = data.mid( pos + 4 );
- fillRightsMap( leftPart.split( '%' ), mRights );
- fillRightsMap( rightPart.split( '%' ), mOldRights );
-}
+ if (parts.size() < 2) {
+ return;
+ }
+ fillRightsMap( parts.at(0).split( '%' ), mRights );
+ fillRightsMap( parts.at(1).split( '%' ), mOldRights );
+ if (parts.size() >= 3) {
+ mMyRights = KIMAP::Acl::rightsFromString(parts.at(2));
+ }
+}
\ No newline at end of file
diff --git a/pimcommon/acl/imapaclattribute.h b/pimcommon/acl/imapaclattribute.h
index b42390a..42c56f7 100644
--- a/pimcommon/acl/imapaclattribute.h
+++ b/pimcommon/acl/imapaclattribute.h
@@ -39,14 +39,17 @@ public:
void setRights( const QMap<QByteArray, KIMAP::Acl::Rights> &rights );
QMap<QByteArray, KIMAP::Acl::Rights> rights() const;
QMap<QByteArray, KIMAP::Acl::Rights> oldRights() const;
- QByteArray type() const;
- Attribute *clone() const;
- QByteArray serialized() const;
- void deserialize( const QByteArray &data );
-
-private:
+ void setMyRights( KIMAP::Acl::Rights rights );
+ KIMAP::Acl::Rights myRights() const;
+ virtual QByteArray type() const;
+ virtual Attribute *clone() const;
+ virtual QByteArray serialized() const;
+ virtual void deserialize( const QByteArray &data );
+
+ private:
QMap<QByteArray, KIMAP::Acl::Rights> mRights;
QMap<QByteArray, KIMAP::Acl::Rights> mOldRights;
+ KIMAP::Acl::Rights mMyRights;
};
}
More information about the commits
mailing list