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
PIM
KDE PIM Runtime
Commits
c2d84cc1
Commit
c2d84cc1
authored
Aug 02, 2016
by
Laurent Montel
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up. Use qCDebug
parent
b29f59b4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
83 deletions
+36
-83
agents/invitations/CMakeLists.txt
agents/invitations/CMakeLists.txt
+2
-1
agents/invitations/invitationsagent.cpp
agents/invitations/invitationsagent.cpp
+32
-67
agents/invitations/invitationsagent.h
agents/invitations/invitationsagent.h
+1
-15
kdepim-runtime.categories
kdepim-runtime.categories
+1
-0
No files found.
agents/invitations/CMakeLists.txt
View file @
c2d84cc1
add_definitions
(
-DTRANSLATION_DOMAIN=\"akonadi_invitations_agent\"
)
set
(
invitationsagent_SRCS
...
...
@@ -5,7 +6,7 @@ set( invitationsagent_SRCS
incidenceattribute.cpp
)
add_definitions
(
-DTRANSLATION_DOMAIN=\"akonadi
_invitation
s_
agent
\"
)
ecm_qt_declare_logging_category
(
invitationsagent_SRCS HEADER invitationagent_debug.h IDENTIFIER INVITATIONAGENT_LOG CATEGORY_NAME log
_invitationagent
)
add_executable
(
akonadi_invitations_agent
${
invitationsagent_SRCS
}
)
...
...
agents/invitations/invitationsagent.cpp
View file @
c2d84cc1
...
...
@@ -20,6 +20,7 @@
#include "invitationsagent.h"
#include "incidenceattribute.h"
#include "invitationagent_debug.h"
#include <AgentInstance>
#include <AgentInstanceCreateJob>
...
...
@@ -44,7 +45,6 @@
#include <KCalCore/Todo>
#include <KConfig>
#include <KConfigSkeleton>
#include <QDebug>
#include <KJob>
#include <KLocalizedString>
#include <KMime/Content>
...
...
@@ -168,7 +168,7 @@ InvitationsAgentItem::~InvitationsAgentItem()
void
InvitationsAgentItem
::
add
(
const
Item
&
item
)
{
qDebug
();
const
Collection
collection
=
m_agent
->
collection
();
Q_ASSERT
(
collection
.
isValid
());
...
...
@@ -185,7 +185,7 @@ void InvitationsAgentItem::createItemResult(KJob *job)
ItemCreateJob
*
createJob
=
qobject_cast
<
ItemCreateJob
*>
(
job
);
m_jobs
.
removeAll
(
createJob
);
if
(
createJob
->
error
())
{
qWarning
()
<<
"Failed to create new Item in invitations collection."
<<
createJob
->
errorText
();
q
C
Warning
(
INVITATIONAGENT_LOG
)
<<
"Failed to create new Item in invitations collection."
<<
createJob
->
errorText
();
return
;
}
...
...
@@ -201,7 +201,7 @@ void InvitationsAgentItem::createItemResult(KJob *job)
void
InvitationsAgentItem
::
fetchItemDone
(
KJob
*
job
)
{
if
(
job
->
error
())
{
qWarning
()
<<
"Failed to fetch Item in invitations collection."
<<
job
->
errorText
();
q
C
Warning
(
INVITATIONAGENT_LOG
)
<<
"Failed to fetch Item in invitations collection."
<<
job
->
errorText
();
return
;
}
...
...
@@ -220,19 +220,19 @@ void InvitationsAgentItem::fetchItemDone(KJob *job)
void
InvitationsAgentItem
::
modifyItemDone
(
KJob
*
job
)
{
if
(
job
->
error
())
{
qWarning
()
<<
"Failed to modify Item in invitations collection."
<<
job
->
errorText
();
q
C
Warning
(
INVITATIONAGENT_LOG
)
<<
"Failed to modify Item in invitations collection."
<<
job
->
errorText
();
return
;
}
//ItemModifyJob *mj = qobject_cast<ItemModifyJob*>( job );
//qDebug()<<"Job successful done.";
//q
C
Debug(
INVITATIONAGENT_LOG
)<<"Job successful done.";
}
InvitationsAgent
::
InvitationsAgent
(
const
QString
&
id
)
:
AgentBase
(
id
),
AgentBase
::
ObserverV2
()
,
m_invitationsCollection
(
new
InvitationsCollection
(
this
))
{
qDebug
();
changeRecorder
()
->
setChangeRecordingEnabled
(
false
);
// behave like Monitor
changeRecorder
()
->
itemFetchScope
().
fetchFullPayload
();
...
...
@@ -250,7 +250,7 @@ InvitationsAgent::~InvitationsAgent()
void
InvitationsAgent
::
initStart
()
{
qDebug
();
m_invitationsCollection
->
clear
();
if
(
m_invitationsCollection
->
hasDefaultCollection
())
{
...
...
@@ -260,32 +260,13 @@ void InvitationsAgent::initStart()
connect
(
job
,
&
InvitationsCollectionRequestJob
::
result
,
this
,
&
InvitationsAgent
::
initDone
);
job
->
start
();
}
/*
KConfig config( "akonadi_invitations_agent" );
KConfigGroup group = config.group( "General" );
m_resourceId = group.readEntry( "DefaultCalendarAgent", "default_ical_resource" );
newAgentCreated = false;
m_invitations = Akonadi::Collection();
AgentInstance resource = AgentManager::self()->instance( m_resourceId );
if ( resource.isValid() ) {
Q_EMIT status( AgentBase::Running, i18n( "Reading..." ) );
QMetaObject::invokeMethod( this, "createAgentResult", Qt::QueuedConnection );
} else {
Q_EMIT status( AgentBase::Running, i18n( "Creating..." ) );
AgentType type = AgentManager::self()->type( QLatin1String( "akonadi_ical_resource" ) );
AgentInstanceCreateJob *job = new AgentInstanceCreateJob( type, this );
connect(job, &InvitationsCollectionRequestJob::result, this, &InvitationsAgent::createAgentResult);
job->start();
}
*/
}
void
InvitationsAgent
::
initDone
(
KJob
*
job
)
{
if
(
job
)
{
if
(
job
->
error
())
{
qWarning
()
<<
"Failed to request default collection:"
<<
job
->
errorText
();
q
C
Warning
(
INVITATIONAGENT_LOG
)
<<
"Failed to request default collection:"
<<
job
->
errorText
();
return
;
}
...
...
@@ -296,42 +277,26 @@ void InvitationsAgent::initDone(KJob *job)
Q_EMIT
status
(
AgentBase
::
Idle
,
i18n
(
"Ready to dispatch invitations"
));
}
Collection
InvitationsAgent
::
collection
()
Collection
InvitationsAgent
::
collection
()
const
{
return
m_invitationsCollection
->
defaultCollection
();
}
#if 0
KIdentityManagement::IdentityManager *InvitationsAgent::identityManager()
{
if (!m_IdentityManager) {
m_IdentityManager = new KIdentityManagement::IdentityManager(true /* readonly */, this);
}
return m_IdentityManager;
}
#endif
void
InvitationsAgent
::
configure
(
WId
windowId
)
{
qDebug
()
<<
windowId
;
/*
QWidget *parent = QWidget::find( windowId );
QDialog *dialog = new QDialog( parent );
QVBoxLayout *layout = new QVBoxLayout( dialog->mainWidget() );
//layout->addWidget( );
dialog->mainWidget()->setLayout( layout );
*/
qCDebug
(
INVITATIONAGENT_LOG
)
<<
windowId
;
initStart
();
//reload
}
#if 0
void InvitationsAgent::createAgentResult(KJob *job)
{
qDebug();
AgentInstance agent;
if (job) {
if (job->error()) {
qWarning() << job->errorString();
q
C
Warning(
INVITATIONAGENT_LOG
) << job->errorString();
Q_EMIT status(AgentBase::Broken, i18n("Failed to create resource: %1", job->errorString()));
return;
}
...
...
@@ -348,7 +313,7 @@ void InvitationsAgent::createAgentResult(KJob *job)
QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + "akonadi_ical_resource");
if (!reply.isValid()) {
qWarning() << "dbus call failed, m_resourceId=" << m_resourceId;
q
C
Warning(
INVITATIONAGENT_LOG
) << "dbus call failed, m_resourceId=" << m_resourceId;
Q_EMIT status(AgentBase::Broken, i18n("Failed to set the directory for invitations via D-Bus"));
AgentManager::self()->removeInstance(agent);
return;
...
...
@@ -372,9 +337,9 @@ void InvitationsAgent::createAgentResult(KJob *job)
void InvitationsAgent::resourceSyncResult(KJob *job)
{
qDebug();
if (job->error()) {
qWarning() << job->errorString();
q
C
Warning(
INVITATIONAGENT_LOG
) << job->errorString();
Q_EMIT status(AgentBase::Broken, i18n("Failed to synchronize collection: %1", job->errorString()));
if (newAgentCreated) {
AgentManager::self()->removeInstance(AgentManager::self()->instance(m_resourceId));
...
...
@@ -390,10 +355,10 @@ void InvitationsAgent::resourceSyncResult(KJob *job)
void InvitationsAgent::collectionFetchResult(KJob *job)
{
qDebug();
if (job->error()) {
qWarning() << job->errorString();
q
C
Warning(
INVITATIONAGENT_LOG
) << job->errorString();
Q_EMIT status(AgentBase::Broken, i18n("Failed to fetch collection: %1", job->errorString()));
if (newAgentCreated) {
AgentManager::self()->removeInstance(AgentManager::self()->instance(m_resourceId));
...
...
@@ -448,9 +413,9 @@ void InvitationsAgent::collectionFetchResult(KJob *job)
void InvitationsAgent::collectionCreateResult(KJob *job)
{
qDebug();
if (job->error()) {
qWarning() << job->errorString();
q
C
Warning(
INVITATIONAGENT_LOG
) << job->errorString();
Q_EMIT status(AgentBase::Broken, i18n("Failed to create collection: %1", job->errorString()));
if (newAgentCreated) {
AgentManager::self()->removeInstance(AgentManager::self()->instance(m_resourceId));
...
...
@@ -470,11 +435,11 @@ Item InvitationsAgent::handleContent(const QString &vcal,
KCalCore
::
ICalFormat
format
;
KCalCore
::
ScheduleMessage
::
Ptr
message
=
format
.
parseScheduleMessage
(
calendar
,
vcal
);
if
(
!
message
)
{
qWarning
()
<<
"Invalid invitation:"
<<
vcal
;
q
C
Warning
(
INVITATIONAGENT_LOG
)
<<
"Invalid invitation:"
<<
vcal
;
return
Item
();
}
qDebug
()
<<
"id="
<<
item
.
id
()
<<
"remoteId="
<<
item
.
remoteId
()
<<
"vcal="
<<
vcal
;
q
C
Debug
(
INVITATIONAGENT_LOG
)
<<
"id="
<<
item
.
id
()
<<
"remoteId="
<<
item
.
remoteId
()
<<
"vcal="
<<
vcal
;
KCalCore
::
Incidence
::
Ptr
incidence
=
message
->
event
().
staticCast
<
KCalCore
::
Incidence
>
();
Q_ASSERT
(
incidence
);
...
...
@@ -493,11 +458,11 @@ Item InvitationsAgent::handleContent(const QString &vcal,
void
InvitationsAgent
::
itemAdded
(
const
Item
&
item
,
const
Collection
&
collection
)
{
qDebug
()
<<
item
.
id
()
<<
collection
;
q
C
Debug
(
INVITATIONAGENT_LOG
)
<<
item
.
id
()
<<
collection
;
Q_UNUSED
(
collection
);
if
(
!
m_invitationsCollection
->
defaultCollection
().
isValid
())
{
qDebug
()
<<
"No default collection found"
;
q
C
Debug
(
INVITATIONAGENT_LOG
)
<<
"No default collection found"
;
return
;
}
...
...
@@ -506,7 +471,7 @@ void InvitationsAgent::itemAdded(const Item &item, const Collection &collection)
}
if
(
!
item
.
hasPayload
<
KMime
::
Message
::
Ptr
>
())
{
qDebug
()
<<
"Item has no payload"
;
q
C
Debug
(
INVITATIONAGENT_LOG
)
<<
"Item has no payload"
;
return
;
}
...
...
@@ -518,21 +483,21 @@ void InvitationsAgent::itemAdded(const Item &item, const Collection &collection)
KCalCore
::
MemoryCalendar
::
Ptr
calendar
(
new
KCalCore
::
MemoryCalendar
(
KSystemTimeZones
::
local
()));
if
(
message
->
contentType
()
->
isMultipart
())
{
qDebug
()
<<
"message is multipart:"
<<
message
->
attachments
().
size
();
q
C
Debug
(
INVITATIONAGENT_LOG
)
<<
"message is multipart:"
<<
message
->
attachments
().
size
();
InvitationsAgentItem
*
it
=
Q_NULLPTR
;
foreach
(
KMime
::
Content
*
content
,
message
->
contents
())
{
KMime
::
Headers
::
ContentType
*
ct
=
content
->
contentType
();
Q_ASSERT
(
ct
);
qDebug
()
<<
"Mimetype of the body part is "
<<
ct
->
mimeType
();
q
C
Debug
(
INVITATIONAGENT_LOG
)
<<
"Mimetype of the body part is "
<<
ct
->
mimeType
();
if
(
ct
->
mimeType
()
!=
"text/calendar"
)
{
continue
;
}
Item
newItem
=
handleContent
(
QLatin1String
(
content
->
body
()),
calendar
,
item
);
if
(
!
newItem
.
hasPayload
())
{
qDebug
()
<<
"new item has no payload"
;
q
C
Debug
(
INVITATIONAGENT_LOG
)
<<
"new item has no payload"
;
continue
;
}
...
...
@@ -543,20 +508,20 @@ void InvitationsAgent::itemAdded(const Item &item, const Collection &collection)
it
->
add
(
newItem
);
}
}
else
{
qDebug
()
<<
"message is not multipart"
;
q
C
Debug
(
INVITATIONAGENT_LOG
)
<<
"message is not multipart"
;
KMime
::
Headers
::
ContentType
*
ct
=
message
->
contentType
();
Q_ASSERT
(
ct
);
qDebug
()
<<
"Mimetype of the body is "
<<
ct
->
mimeType
();
q
C
Debug
(
INVITATIONAGENT_LOG
)
<<
"Mimetype of the body is "
<<
ct
->
mimeType
();
if
(
ct
->
mimeType
()
!=
"text/calendar"
)
{
return
;
}
qDebug
()
<<
"Message has an invitation in the body, processing"
;
q
C
Debug
(
INVITATIONAGENT_LOG
)
<<
"Message has an invitation in the body, processing"
;
Item
newItem
=
handleContent
(
QLatin1String
(
message
->
body
()),
calendar
,
item
);
if
(
!
newItem
.
hasPayload
())
{
qDebug
()
<<
"new item has no payload"
;
q
C
Debug
(
INVITATIONAGENT_LOG
)
<<
"new item has no payload"
;
return
;
}
...
...
agents/invitations/invitationsagent.h
View file @
c2d84cc1
...
...
@@ -62,7 +62,7 @@ public:
explicit
InvitationsAgent
(
const
QString
&
id
);
virtual
~
InvitationsAgent
();
Akonadi
::
Collection
collection
();
Akonadi
::
Collection
collection
()
const
;
public
Q_SLOTS
:
void
configure
(
WId
windowId
)
Q_DECL_OVERRIDE
;
...
...
@@ -78,20 +78,6 @@ private:
void
itemAdded
(
const
Akonadi
::
Item
&
item
,
const
Akonadi
::
Collection
&
collection
)
Q_DECL_OVERRIDE
;
/*
virtual void itemChanged( const Akonadi::Item &item, const QSet<QByteArray> &partIdentifiers );
virtual void itemRemoved( const Akonadi::Item &item );
virtual void collectionAdded( const Akonadi::Collection &collection, const Akonadi::Collection &parent );
virtual void collectionChanged( const Akonadi::Collection &collection );
virtual void collectionRemoved( const Akonadi::Collection &collection );
virtual void itemMoved( const Akonadi::Item &item, const Akonadi::Collection &collectionSource, const Akonadi::Collection &collectionDestination );
virtual void itemLinked( const Akonadi::Item &item, const Akonadi::Collection &collection );
virtual void itemUnlinked( const Akonadi::Item &item, const Akonadi::Collection &collection );
virtual void collectionMoved( const Akonadi::Collection &collection, const Akonadi::Collection &collectionSource, const Akonadi::Collection &collectionDestination );
virtual void collectionChanged( const Akonadi::Collection &collection, const QSet<QByteArray> &changedAttributes );
*/
private:
QString
m_resourceId
;
InvitationsCollection
*
m_invitationsCollection
;
...
...
kdepim-runtime.categories
View file @
c2d84cc1
...
...
@@ -18,3 +18,4 @@ log_akonadi_serializer_mail akonadi mail plugins (kdepim-runtime)
log_resources_contacts contacts resource (kdepim-runtime)
log_pop3 kioslave (kdepim-runtime)
log_tomboynotesresource tomboynote resource (kdepim-runtime)
log_invitationagent invitationagent agent (kdepim-runtime)
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