Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Unmaintained
KDE Pim
Commits
2d8cec9b
Commit
2d8cec9b
authored
Jan 02, 2015
by
Laurent Montel
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new class to get imapcapabilities
parent
99f41cbf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
147 additions
and
0 deletions
+147
-0
pimcommon/CMakeLists.txt
pimcommon/CMakeLists.txt
+1
-0
pimcommon/util/imapresourcemanager.cpp
pimcommon/util/imapresourcemanager.cpp
+95
-0
pimcommon/util/imapresourcemanager.h
pimcommon/util/imapresourcemanager.h
+51
-0
No files found.
pimcommon/CMakeLists.txt
View file @
2d8cec9b
...
...
@@ -184,6 +184,7 @@ set(libpimcommon_SRCS
util/createresource.cpp
util/pimutil.cpp
util/editorutil.cpp
util/imapresourcemanager.cpp
settings/pimcommonsettings.cpp
${
libpimcommon_texteditor_SRCS
}
${
libpimcommon_shorturl_SRCS
}
...
...
pimcommon/util/imapresourcemanager.cpp
0 → 100644
View file @
2d8cec9b
/*
Copyright (c) 2015 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "imapresourcemanager.h"
#include "util/pimutil.h"
#include <Akonadi/AgentManager>
#include <Akonadi/DBusConnectionPool>
#include <QDBusInterface>
#include <qdbuspendingcall.h>
#include <qdbuspendingreply.h>
#include <QDebug>
using
namespace
PimCommon
;
ImapResourceManager
::
ImapResourceManager
(
QObject
*
parent
)
:
QObject
(
parent
)
{
init
();
}
ImapResourceManager
::~
ImapResourceManager
()
{
}
void
ImapResourceManager
::
slotInstanceAdded
(
const
Akonadi
::
AgentInstance
&
instance
)
{
searchCapabilities
(
instance
.
type
().
identifier
());
}
void
ImapResourceManager
::
slotInstanceRemoved
(
const
Akonadi
::
AgentInstance
&
instance
)
{
mImapResource
.
remove
(
instance
.
type
().
identifier
());
}
void
ImapResourceManager
::
searchCapabilities
(
const
QString
&
identifier
)
{
//By default makes it as true.
mImapResource
.
insert
(
identifier
,
true
);
QDBusInterface
iface
(
QLatin1String
(
"org.freedesktop.Akonadi.Resource."
)
+
identifier
,
QLatin1String
(
"/"
),
QLatin1String
(
"org.kde.Akonadi.ImapResourceBase"
),
Akonadi
::
DBusConnectionPool
::
threadConnection
(),
this
);
QDBusPendingCall
call
=
iface
.
asyncCall
(
QLatin1String
(
"serverCapabilities"
)
);
QDBusPendingCallWatcher
*
watcher
=
new
QDBusPendingCallWatcher
(
call
,
this
);
watcher
->
setProperty
(
"identifier"
,
identifier
);
connect
(
watcher
,
SIGNAL
(
finished
(
QDBusPendingCallWatcher
*
)),
this
,
SLOT
(
slotCapabilities
(
QDBusPendingCallWatcher
*
)));
}
void
ImapResourceManager
::
slotCapabilities
(
QDBusPendingCallWatcher
*
watcher
)
{
QDBusPendingReply
<
QStringList
>
reply
=
*
watcher
;
if
(
reply
.
isValid
()
)
{
if
(
watcher
->
property
(
"identifier"
).
isValid
())
{
const
QStringList
capabilities
=
reply
.
value
();
mImapResource
.
insert
(
watcher
->
property
(
"identifier"
).
toString
(),
capabilities
.
contains
(
QLatin1String
(
"ANNOTATEMORE"
)));
}
}
watcher
->
deleteLater
();
watcher
=
0
;
}
void
ImapResourceManager
::
init
()
{
Q_FOREACH
(
const
Akonadi
::
AgentInstance
&
instance
,
Akonadi
::
AgentManager
::
self
()
->
instances
()
)
{
const
QString
identifier
=
instance
.
type
().
identifier
();
if
(
PimCommon
::
Util
::
isImapResource
(
identifier
))
{
searchCapabilities
(
identifier
);
}
}
connect
(
Akonadi
::
AgentManager
::
self
(),
SIGNAL
(
instanceAdded
(
Akonadi
::
AgentInstance
)),
SLOT
(
slotInstanceAdded
(
Akonadi
::
AgentInstance
))
);
connect
(
Akonadi
::
AgentManager
::
self
(),
SIGNAL
(
instanceRemoved
(
Akonadi
::
AgentInstance
)),
SLOT
(
slotInstanceRemoved
(
Akonadi
::
AgentInstance
))
);
}
bool
ImapResourceManager
::
hasAnnotationSupport
(
const
QString
&
identifier
)
const
{
if
(
!
PimCommon
::
Util
::
isImapResource
(
identifier
))
{
return
false
;
}
return
mImapResource
.
value
(
identifier
,
true
);
}
pimcommon/util/imapresourcemanager.h
0 → 100644
View file @
2d8cec9b
/*
Copyright (c) 2015 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef IMAPRESOURCEMANAGER_H
#define IMAPRESOURCEMANAGER_H
#include <QObject>
#include <QHash>
#include "pimcommon_export.h"
class
QDBusPendingCallWatcher
;
namespace
Akonadi
{
class
AgentInstance
;
}
namespace
PimCommon
{
class
PIMCOMMON_EXPORT
ImapResourceManager
:
public
QObject
{
Q_OBJECT
public:
explicit
ImapResourceManager
(
QObject
*
parent
=
0
);
~
ImapResourceManager
();
bool
hasAnnotationSupport
()
const
;
bool
hasAnnotationSupport
(
const
QString
&
identifier
)
const
;
private
Q_SLOTS
:
void
slotInstanceAdded
(
const
Akonadi
::
AgentInstance
&
instance
);
void
slotInstanceRemoved
(
const
Akonadi
::
AgentInstance
&
instance
);
void
slotCapabilities
(
QDBusPendingCallWatcher
*
watcher
);
private:
void
init
();
void
searchCapabilities
(
const
QString
&
identifier
);
QHash
<
QString
,
bool
>
mImapResource
;
};
}
#endif // IMAPRESOURCEMANAGER_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment